hytopia 0.1.8 → 0.1.11

Sign up to get free protection for your applications and to get access to all the features.
package/bin/scripts.js CHANGED
@@ -7,16 +7,21 @@ const mkcert = require('mkcert');
7
7
  (async () => {
8
8
  const command = process.argv[2];
9
9
 
10
+ /**
11
+ * Init command
12
+ *
13
+ * Initializes a new HYTOPIA project.
14
+ */
10
15
  if (command === 'init') {
11
16
  const srcDir = path.join(__dirname, '..', 'boilerplate');
12
17
  const destDir = process.cwd();
13
18
 
14
19
  // Copy boilerplate
15
- console.log(`Copying boilerplate to ${destDir}`);
20
+ console.log(`🖨️ Copying boilerplate to ${destDir}`);
16
21
  fs.cpSync(srcDir, destDir, { recursive: true });
17
22
 
18
23
  // Generate SSL cert and allow mkcert to auto handle CA/Cert setup
19
- console.log(`Generating SSL cert for local development...`);
24
+ console.log(`🔒 Generating SSL cert for local development`);
20
25
  const validity = 3650; // 10 years
21
26
  const ca = await mkcert.createCA({
22
27
  organization: 'HYTOPIA',
@@ -25,6 +25,7 @@
25
25
 
26
26
  import {
27
27
  startServer,
28
+ GameServer,
28
29
  PlayerEntity,
29
30
  } from 'hytopia';
30
31
 
@@ -41,6 +42,17 @@ import worldMap from './assets/map.json';
41
42
  */
42
43
 
43
44
  startServer(world => {
45
+ /**
46
+ * Enable SSL for local development. This allows you to
47
+ * connect to your local game server from https://play.hytopia.com
48
+ * without having to manually set up SSL.
49
+ *
50
+ * If you are using a reverse proxy like ngrok (IE, `ngrok http 8080`)
51
+ * so others can connect to your local game server via the ngrok
52
+ * provided URL, make sure to remove this or comment it out.
53
+ */
54
+ GameServer.instance.webServer.enableLocalSSL();
55
+
44
56
  /**
45
57
  * Enable debug rendering of the physics simulation.
46
58
  * This will overlay lines in-game representing colliders,
@@ -84,6 +84,27 @@ The singleton instance of the game server.
84
84
  The player manager for the game server.
85
85
 
86
86
 
87
+ </td></tr>
88
+ <tr><td>
89
+
90
+ [webServer](./server.gameserver.webserver.md)
91
+
92
+
93
+ </td><td>
94
+
95
+ `readonly`
96
+
97
+
98
+ </td><td>
99
+
100
+ [WebServer](./server.webserver.md)
101
+
102
+
103
+ </td><td>
104
+
105
+ The web server for the game server.
106
+
107
+
87
108
  </td></tr>
88
109
  <tr><td>
89
110
 
@@ -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; [GameServer](./server.gameserver.md) &gt; [webServer](./server.gameserver.webserver.md)
4
+
5
+ ## GameServer.webServer property
6
+
7
+ The web server for the game server.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ get webServer(): WebServer;
13
+ ```
@@ -84,6 +84,27 @@ The singleton instance of the game server.
84
84
  The player manager for the game server.
85
85
 
86
86
 
87
+ </td></tr>
88
+ <tr><td>
89
+
90
+ [webServer](./server.hytopia.gameserver.webserver.md)
91
+
92
+
93
+ </td><td>
94
+
95
+ `readonly`
96
+
97
+
98
+ </td><td>
99
+
100
+ [WebServer](./server.webserver.md)
101
+
102
+
103
+ </td><td>
104
+
105
+ The web server for the game server.
106
+
107
+
87
108
  </td></tr>
88
109
  <tr><td>
89
110
 
@@ -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; [GameServer](./server.hytopia.gameserver.md) &gt; [webServer](./server.hytopia.gameserver.webserver.md)
4
+
5
+ ## HYTOPIA.GameServer.webServer property
6
+
7
+ The web server for the game server.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ get webServer(): WebServer;
13
+ ```
@@ -236,6 +236,17 @@ Represents a rigid body in a world's physics simulation.
236
236
  Represents the physics simulation for a world.
237
237
 
238
238
 
239
+ </td></tr>
240
+ <tr><td>
241
+
242
+ [WebServer](./server.hytopia.webserver.md)
243
+
244
+
245
+ </td><td>
246
+
247
+ Manages the internal HTTP server for the game server.
248
+
249
+
239
250
  </td></tr>
240
251
  <tr><td>
241
252
 
@@ -0,0 +1,17 @@
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; [WebServer](./server.hytopia.webserver.md) &gt; [enableLocalSSL](./server.hytopia.webserver.enablelocalssl.md)
4
+
5
+ ## HYTOPIA.WebServer.enableLocalSSL() method
6
+
7
+ Enables SSL for local development. The server will be available at https://localhost:8080. This is intended for local development without a reverse proxy. Don't use it when using tunnels like ngrok.com that already handle SSL. Usage of this method will be ignored in production. Must be called in init function of [startServer()](./server.startserver.md)<!-- -->.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ enableLocalSSL(): void;
13
+ ```
14
+ **Returns:**
15
+
16
+ void
17
+
@@ -0,0 +1,54 @@
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; [WebServer](./server.hytopia.webserver.md)
4
+
5
+ ## HYTOPIA.WebServer class
6
+
7
+ Manages the internal HTTP server for the game server.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export default class WebServer implements Readyable
13
+ ```
14
+ **Implements:** Readyable
15
+
16
+ ## Remarks
17
+
18
+ This class is used as a singleton and should be accessed via the GameServer.webServer property.
19
+
20
+ The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `WebServer` class.
21
+
22
+ ## Methods
23
+
24
+ <table><thead><tr><th>
25
+
26
+ Method
27
+
28
+
29
+ </th><th>
30
+
31
+ Modifiers
32
+
33
+
34
+ </th><th>
35
+
36
+ Description
37
+
38
+
39
+ </th></tr></thead>
40
+ <tbody><tr><td>
41
+
42
+ [enableLocalSSL()](./server.hytopia.webserver.enablelocalssl.md)
43
+
44
+
45
+ </td><td>
46
+
47
+
48
+ </td><td>
49
+
50
+ Enables SSL for local development. The server will be available at https://localhost:8080. This is intended for local development without a reverse proxy. Don't use it when using tunnels like ngrok.com that already handle SSL. Usage of this method will be ignored in production. Must be called in init function of [startServer()](./server.startserver.md)<!-- -->.
51
+
52
+
53
+ </td></tr>
54
+ </tbody></table>
package/docs/server.md CHANGED
@@ -236,6 +236,17 @@ Represents a rigid body in a world's physics simulation.
236
236
  Represents the physics simulation for a world.
237
237
 
238
238
 
239
+ </td></tr>
240
+ <tr><td>
241
+
242
+ [WebServer](./server.webserver.md)
243
+
244
+
245
+ </td><td>
246
+
247
+ Manages the internal HTTP server for the game server.
248
+
249
+
239
250
  </td></tr>
240
251
  <tr><td>
241
252
 
@@ -0,0 +1,17 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [WebServer](./server.webserver.md) &gt; [enableLocalSSL](./server.webserver.enablelocalssl.md)
4
+
5
+ ## WebServer.enableLocalSSL() method
6
+
7
+ Enables SSL for local development. The server will be available at https://localhost:8080. This is intended for local development without a reverse proxy. Don't use it when using tunnels like ngrok.com that already handle SSL. Usage of this method will be ignored in production. Must be called in init function of [startServer()](./server.startserver.md)<!-- -->.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ enableLocalSSL(): void;
13
+ ```
14
+ **Returns:**
15
+
16
+ void
17
+
@@ -0,0 +1,54 @@
1
+ <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
+
3
+ [Home](./index.md) &gt; [server](./server.md) &gt; [WebServer](./server.webserver.md)
4
+
5
+ ## WebServer class
6
+
7
+ Manages the internal HTTP server for the game server.
8
+
9
+ **Signature:**
10
+
11
+ ```typescript
12
+ export default class WebServer implements Readyable
13
+ ```
14
+ **Implements:** Readyable
15
+
16
+ ## Remarks
17
+
18
+ This class is used as a singleton and should be accessed via the GameServer.webServer property.
19
+
20
+ The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `WebServer` class.
21
+
22
+ ## Methods
23
+
24
+ <table><thead><tr><th>
25
+
26
+ Method
27
+
28
+
29
+ </th><th>
30
+
31
+ Modifiers
32
+
33
+
34
+ </th><th>
35
+
36
+ Description
37
+
38
+
39
+ </th></tr></thead>
40
+ <tbody><tr><td>
41
+
42
+ [enableLocalSSL()](./server.webserver.enablelocalssl.md)
43
+
44
+
45
+ </td><td>
46
+
47
+
48
+ </td><td>
49
+
50
+ Enables SSL for local development. The server will be available at https://localhost:8080. This is intended for local development without a reverse proxy. Don't use it when using tunnels like ngrok.com that already handle SSL. Usage of this method will be ignored in production. Must be called in init function of [startServer()](./server.startserver.md)<!-- -->.
51
+
52
+
53
+ </td></tr>
54
+ </tbody></table>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hytopia",
3
- "version": "0.1.8",
3
+ "version": "0.1.11",
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": {
@@ -47,7 +47,7 @@
47
47
  "url": "https://github.com/hytopiagg/sdk/issues"
48
48
  },
49
49
  "homepage": "https://github.com/hytopiagg/sdk#readme",
50
- "devDependencies": {
50
+ "dependencies": {
51
51
  "mkcert": "^3.2.0"
52
52
  }
53
53
  }
package/server.api.json CHANGED
@@ -11284,6 +11284,37 @@
11284
11284
  "isProtected": false,
11285
11285
  "isAbstract": false
11286
11286
  },
11287
+ {
11288
+ "kind": "Property",
11289
+ "canonicalReference": "server!GameServer#webServer:member",
11290
+ "docComment": "/**\n * The web server for the game server.\n */\n",
11291
+ "excerptTokens": [
11292
+ {
11293
+ "kind": "Content",
11294
+ "text": "get webServer(): "
11295
+ },
11296
+ {
11297
+ "kind": "Reference",
11298
+ "text": "WebServer",
11299
+ "canonicalReference": "server!WebServer:class"
11300
+ },
11301
+ {
11302
+ "kind": "Content",
11303
+ "text": ";"
11304
+ }
11305
+ ],
11306
+ "isReadonly": true,
11307
+ "isOptional": false,
11308
+ "releaseTag": "Public",
11309
+ "name": "webServer",
11310
+ "propertyTypeTokenRange": {
11311
+ "startIndex": 1,
11312
+ "endIndex": 2
11313
+ },
11314
+ "isStatic": false,
11315
+ "isProtected": false,
11316
+ "isAbstract": false
11317
+ },
11287
11318
  {
11288
11319
  "kind": "Property",
11289
11320
  "canonicalReference": "server!GameServer#worlds:member",
@@ -22611,6 +22642,37 @@
22611
22642
  "isProtected": false,
22612
22643
  "isAbstract": false
22613
22644
  },
22645
+ {
22646
+ "kind": "Property",
22647
+ "canonicalReference": "server!HYTOPIA.GameServer#webServer:member",
22648
+ "docComment": "/**\n * The web server for the game server.\n */\n",
22649
+ "excerptTokens": [
22650
+ {
22651
+ "kind": "Content",
22652
+ "text": "get webServer(): "
22653
+ },
22654
+ {
22655
+ "kind": "Reference",
22656
+ "text": "WebServer",
22657
+ "canonicalReference": "server!WebServer:class"
22658
+ },
22659
+ {
22660
+ "kind": "Content",
22661
+ "text": ";"
22662
+ }
22663
+ ],
22664
+ "isReadonly": true,
22665
+ "isOptional": false,
22666
+ "releaseTag": "Public",
22667
+ "name": "webServer",
22668
+ "propertyTypeTokenRange": {
22669
+ "startIndex": 1,
22670
+ "endIndex": 2
22671
+ },
22672
+ "isStatic": false,
22673
+ "isProtected": false,
22674
+ "isAbstract": false
22675
+ },
22614
22676
  {
22615
22677
  "kind": "Property",
22616
22678
  "canonicalReference": "server!HYTOPIA.GameServer#worlds:member",
@@ -28593,6 +28655,70 @@
28593
28655
  ],
28594
28656
  "extendsTokenRanges": []
28595
28657
  },
28658
+ {
28659
+ "kind": "Class",
28660
+ "canonicalReference": "server!HYTOPIA.WebServer:class",
28661
+ "docComment": "/**\n * Manages the internal HTTP server for the game server.\n *\n * @remarks\n *\n * This class is used as a singleton and should be accessed via the GameServer.webServer property.\n *\n * The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `WebServer` class.\n *\n * @public\n */\n",
28662
+ "excerptTokens": [
28663
+ {
28664
+ "kind": "Content",
28665
+ "text": "export default class WebServer implements "
28666
+ },
28667
+ {
28668
+ "kind": "Reference",
28669
+ "text": "Readyable",
28670
+ "canonicalReference": "server!~Readyable:interface"
28671
+ },
28672
+ {
28673
+ "kind": "Content",
28674
+ "text": " "
28675
+ }
28676
+ ],
28677
+ "fileUrlPath": "src/networking/WebServer.ts",
28678
+ "releaseTag": "Public",
28679
+ "isAbstract": false,
28680
+ "name": "WebServer",
28681
+ "preserveMemberOrder": false,
28682
+ "members": [
28683
+ {
28684
+ "kind": "Method",
28685
+ "canonicalReference": "server!HYTOPIA.WebServer#enableLocalSSL:member(1)",
28686
+ "docComment": "/**\n * Enables SSL for local development. The server will be available at https://localhost:8080. This is intended for local development without a reverse proxy. Don't use it when using tunnels like ngrok.com that already handle SSL. Usage of this method will be ignored in production. Must be called in init function of {@link startServer}.\n */\n",
28687
+ "excerptTokens": [
28688
+ {
28689
+ "kind": "Content",
28690
+ "text": "enableLocalSSL(): "
28691
+ },
28692
+ {
28693
+ "kind": "Content",
28694
+ "text": "void"
28695
+ },
28696
+ {
28697
+ "kind": "Content",
28698
+ "text": ";"
28699
+ }
28700
+ ],
28701
+ "isStatic": false,
28702
+ "returnTypeTokenRange": {
28703
+ "startIndex": 1,
28704
+ "endIndex": 2
28705
+ },
28706
+ "releaseTag": "Public",
28707
+ "isProtected": false,
28708
+ "overloadIndex": 1,
28709
+ "parameters": [],
28710
+ "isOptional": false,
28711
+ "isAbstract": false,
28712
+ "name": "enableLocalSSL"
28713
+ }
28714
+ ],
28715
+ "implementsTokenRanges": [
28716
+ {
28717
+ "startIndex": 1,
28718
+ "endIndex": 2
28719
+ }
28720
+ ]
28721
+ },
28596
28722
  {
28597
28723
  "kind": "Class",
28598
28724
  "canonicalReference": "server!HYTOPIA.World:class",
@@ -35330,6 +35456,70 @@
35330
35456
  ],
35331
35457
  "extendsTokenRanges": []
35332
35458
  },
35459
+ {
35460
+ "kind": "Class",
35461
+ "canonicalReference": "server!WebServer:class",
35462
+ "docComment": "/**\n * Manages the internal HTTP server for the game server.\n *\n * @remarks\n *\n * This class is used as a singleton and should be accessed via the GameServer.webServer property.\n *\n * The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the `WebServer` class.\n *\n * @public\n */\n",
35463
+ "excerptTokens": [
35464
+ {
35465
+ "kind": "Content",
35466
+ "text": "export default class WebServer implements "
35467
+ },
35468
+ {
35469
+ "kind": "Reference",
35470
+ "text": "Readyable",
35471
+ "canonicalReference": "server!~Readyable:interface"
35472
+ },
35473
+ {
35474
+ "kind": "Content",
35475
+ "text": " "
35476
+ }
35477
+ ],
35478
+ "fileUrlPath": "src/networking/WebServer.ts",
35479
+ "releaseTag": "Public",
35480
+ "isAbstract": false,
35481
+ "name": "WebServer",
35482
+ "preserveMemberOrder": false,
35483
+ "members": [
35484
+ {
35485
+ "kind": "Method",
35486
+ "canonicalReference": "server!WebServer#enableLocalSSL:member(1)",
35487
+ "docComment": "/**\n * Enables SSL for local development. The server will be available at https://localhost:8080. This is intended for local development without a reverse proxy. Don't use it when using tunnels like ngrok.com that already handle SSL. Usage of this method will be ignored in production. Must be called in init function of {@link startServer}.\n */\n",
35488
+ "excerptTokens": [
35489
+ {
35490
+ "kind": "Content",
35491
+ "text": "enableLocalSSL(): "
35492
+ },
35493
+ {
35494
+ "kind": "Content",
35495
+ "text": "void"
35496
+ },
35497
+ {
35498
+ "kind": "Content",
35499
+ "text": ";"
35500
+ }
35501
+ ],
35502
+ "isStatic": false,
35503
+ "returnTypeTokenRange": {
35504
+ "startIndex": 1,
35505
+ "endIndex": 2
35506
+ },
35507
+ "releaseTag": "Public",
35508
+ "isProtected": false,
35509
+ "overloadIndex": 1,
35510
+ "parameters": [],
35511
+ "isOptional": false,
35512
+ "isAbstract": false,
35513
+ "name": "enableLocalSSL"
35514
+ }
35515
+ ],
35516
+ "implementsTokenRanges": [
35517
+ {
35518
+ "startIndex": 1,
35519
+ "endIndex": 2
35520
+ }
35521
+ ]
35522
+ },
35333
35523
  {
35334
35524
  "kind": "Class",
35335
35525
  "canonicalReference": "server!World:class",
package/server.d.ts CHANGED
@@ -1528,7 +1528,8 @@ export declare class GameServer {
1528
1528
  /** The player manager for the game server. */
1529
1529
  get playerManager(): PlayerManager;
1530
1530
 
1531
-
1531
+ /** The web server for the game server. */
1532
+ get webServer(): WebServer;
1532
1533
  /** The worlds managed by the game server. */
1533
1534
  get worlds(): {
1534
1535
  [id: string]: World;
@@ -1616,6 +1617,7 @@ declare namespace HYTOPIA {
1616
1617
  RigidBodyAdditionalMassProperties,
1617
1618
  RigidBodyOptions,
1618
1619
  Simulation,
1620
+ WebServer,
1619
1621
  World,
1620
1622
  WorldMap,
1621
1623
  WorldOptions,
@@ -2367,6 +2369,43 @@ export declare interface Vector3Boolean {
2367
2369
  x: boolean;
2368
2370
  y: boolean;
2369
2371
  z: boolean;
2372
+ }
2373
+
2374
+ /**
2375
+ * Manages the internal HTTP server for the game server.
2376
+ *
2377
+ * @remarks
2378
+ * This class is used as a singleton and should be
2379
+ * accessed via the GameServer.webServer property.
2380
+ *
2381
+ * @public
2382
+ */
2383
+ export declare class WebServer implements Readyable {
2384
+
2385
+
2386
+
2387
+
2388
+
2389
+
2390
+
2391
+
2392
+
2393
+ /**
2394
+ * Enables SSL for local development. The server will be
2395
+ * available at https://localhost:8080. This is intended
2396
+ * for local development without a reverse proxy. Don't
2397
+ * use it when using tunnels like ngrok.com that already
2398
+ * handle SSL. Usage of this method will be ignored
2399
+ * in production. Must be called in init function of
2400
+ * {@link startServer}.
2401
+ */
2402
+ enableLocalSSL(): void;
2403
+
2404
+
2405
+
2406
+
2407
+
2408
+
2370
2409
  }
2371
2410
 
2372
2411
  /**