ts2077 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,120 +1,120 @@
1
- # Configuration
2
-
3
- `open77-ts.json` is the file the compiler reads. `ts77.config.json` and `ts77.config.ts` are optional overlays. Fields in an overlay replace the same fields for that build. The overlay is not written back over `open77-ts.json`.
4
-
5
- `ts77 deploy --server <directory>` is the command that does write `serverResourcesDir`. It looks for `server.jsonc` and then uses the `resources` folder inside that server directory.
6
-
7
- A `ts77.config.ts` file must export an object. The compiler transpiles it in memory. Keep it free of gameplay code.
8
-
9
- `open77-ts.json` sits next to the resource directory name. The `name` field and the directory name must be the same slug: a lowercase letter, then letters, digits, or underscores, 3 to 64 characters.
10
-
11
- ## Fields
12
-
13
- ```json
14
- {
15
- "name": "player_notes",
16
- "version": "1.0.0",
17
- "autoStart": true,
18
- "targets": ["open77-client", "open77-server", "node", "webui"],
19
- "client": "src/client/index.ts",
20
- "server": "src/server/index.ts",
21
- "backend": "src/backend/index.ts",
22
- "dependencies": [],
23
- "permissions": [],
24
- "serverResourcesDir": "E:/CODING/VOSS/resources",
25
- "web": {
26
- "root": "src/webui",
27
- "entry": "web/index.html",
28
- "devEntry": "http://127.0.0.1:5173/"
29
- }
30
- }
31
- ```
32
-
33
- | Field | Default | Meaning |
34
- |---|---|---|
35
- | `version` | required | Written into `open77.lua`. |
36
- | `autoStart` | `true` | `auto_start` in the manifest. |
37
- | `targets` | client, server, plus `webui` if `web.root` is set, plus `node` if `backend` is set | Which compilers run. |
38
- | `client` | `src/client/main.ts` | Client bundle entry. |
39
- | `server` | `src/server/main.ts` | Server bundle entry. |
40
- | `backend` | none | Node entry. Required when `node` is listed. |
41
- | `dependencies` | `[]` | Other resource names, emitted as `dependency`. |
42
- | `permissions` | `[]` | Extra manifest permissions, unioned with natives the scanner found. |
43
- | `serverResourcesDir` | none | Destination parent for `--deploy`. |
44
- | `web.root` | none | Folder that contains `vite.config` and `package.json`. |
45
- | `web.entry` | `web/index.html` | Page the production build opens. |
46
- | `web.devEntry` | none | Page used when building with `--dev`. |
47
-
48
- `permissions` you list are kept even if the scanner did not see that native. The scanner still adds the permissions for natives that were actually called. It does not remove one you listed.
49
-
50
- ## Targets
51
-
52
- | Target | Compiler | Output |
53
- |---|---|---|
54
- | `open77-client` | TypeScriptToLua 5.4, bundled | `dist/client/main.lua` |
55
- | `open77-server` | TypeScriptToLua 5.4, bundled | `dist/server/main.lua` |
56
- | `node` | `tsc`, CommonJS, ES2022 | `dist/backend/index.js` |
57
- | `webui` | Vite | `web/` |
58
-
59
- Shared gameplay modules live in `src/shared` and are copied into each Lua bundle that imports them. They are not `shared_script` files. The Node program does not compile `src/shared` unless the backend file imports it. The notes example keeps the Lua contracts in `src/shared/contracts.ts` and lets the companion use `@open77-ts/shared`.
60
-
61
- ## Generated files
62
-
63
- Each build rewrites:
64
-
65
- - `src/generated/flags.ts` — `webuiEntry`
66
- - `tsconfig.client.json`, `tsconfig.server.json`, and `tsconfig.node.json` when those targets run
67
- - `dist/client/main.lua` and `.map`
68
- - `dist/server/main.lua` and `.map`
69
- - `dist/backend/index.js`
70
- - `open77.lua`
71
-
72
- Cursor should use the generated tsconfig so completion follows the catalogue. Client files cannot see `TriggerClientEvent`. Server files cannot see `TriggerServerEvent`.
73
-
74
- ## Companion environment
75
-
76
- | Variable | Default | Used by |
77
- |---|---|---|
78
- | `OPEN77_BRIDGE_SECRET` | none, and the process refuses to start | HMAC key. 16–256 characters. |
79
- | `OPEN77_BRIDGE_PORT` | `11782` | Listen port. |
80
- | `OPEN77_NOTES_DRIVER` | `memory` | `memory`, `mysql`, `postgres`, or `redis`. |
81
- | `OPEN77_DATABASE_URL` | none | Required unless the driver is `memory`. |
82
-
83
- ## Game-server settings the resource reads
84
-
85
- `Open77.tunables.declare` registers:
86
-
87
- | Key | Default | Purpose |
88
- |---|---|---|
89
- | `open77_bridge_secret` | `""` | Same secret as `OPEN77_BRIDGE_SECRET`. Empty means calls fail with `bridge_secret_missing`. |
90
- | `open77_bridge_url` | `http://127.0.0.1:11782/v1/call` | Where `Open77.http.request` posts. |
91
-
92
- `Open77.convars.get` is checked first. Resolution order on the server is: an in-memory `SetConvar`, the `convars` block of `server.jsonc`, then this resource's tunable of the same name, then the caller's default. A value set in Warden is visible on the next read because the code reads it at the call, not at file load.
93
-
94
- String tunables are capped at 256 characters by the host. That is why the companion also rejects a longer secret.
95
-
96
- ## server.jsonc
97
-
98
- Only the fields this bridge uses:
99
-
100
- ```jsonc
101
- {
102
- "http": {
103
- "enabled": true,
104
- "allowedHosts": ["127.0.0.1"],
105
- "timeoutSeconds": 5,
106
- "maxResponseBytes": 1048576
107
- },
108
- "httpHandlers": {
109
- "enabled": true,
110
- "listenUrl": "http://127.0.0.1:11781",
111
- "timeoutSeconds": 5
112
- }
113
- }
114
- ```
115
-
116
- `allowedHosts` entries are exact hosts (`discord.com`) or one subdomain wildcard (`*.example.com`). No scheme, path, or port. An empty list reaches nothing.
117
-
118
- `httpHandlers.listenUrl` is an `http://` origin with no path. The listener adds `/<resource>/<prefix>` itself. Sixteen requests may be in flight per resource. A larger body than 16 KiB is refused before Lua sees it. A handler that never answers is timed out by the host.
119
-
120
- The resource manifest still has to list `http.request` and, if it serves a route, `http.serve`. The build adds those when it sees the calls.
1
+ # Configuration
2
+
3
+ `open77-ts.json` is the file the compiler reads. `ts77.config.json` and `ts77.config.ts` are optional overlays. Fields in an overlay replace the same fields for that build. The overlay is not written back over `open77-ts.json`.
4
+
5
+ `ts77 deploy --server <directory>` is the command that does write `serverResourcesDir`. It looks for `server.jsonc` and then uses the `resources` folder inside that server directory.
6
+
7
+ A `ts77.config.ts` file must export an object. The compiler transpiles it in memory. Keep it free of gameplay code.
8
+
9
+ `open77-ts.json` sits next to the resource directory name. The `name` field and the directory name must be the same slug: a lowercase letter, then letters, digits, or underscores, 3 to 64 characters.
10
+
11
+ ## Fields
12
+
13
+ ```json
14
+ {
15
+ "name": "player_notes",
16
+ "version": "1.0.0",
17
+ "autoStart": true,
18
+ "targets": ["open77-client", "open77-server", "node", "webui"],
19
+ "client": "src/client/index.ts",
20
+ "server": "src/server/index.ts",
21
+ "backend": "src/backend/index.ts",
22
+ "dependencies": [],
23
+ "permissions": [],
24
+ "serverResourcesDir": "D:/open77-server/resources",
25
+ "web": {
26
+ "root": "src/webui",
27
+ "entry": "web/index.html",
28
+ "devEntry": "http://127.0.0.1:5173/"
29
+ }
30
+ }
31
+ ```
32
+
33
+ | Field | Default | Meaning |
34
+ |---|---|---|
35
+ | `version` | required | Written into `open77.lua`. |
36
+ | `autoStart` | `true` | `auto_start` in the manifest. |
37
+ | `targets` | client, server, plus `webui` if `web.root` is set, plus `node` if `backend` is set | Which compilers run. |
38
+ | `client` | `src/client/main.ts` | Client bundle entry. |
39
+ | `server` | `src/server/main.ts` | Server bundle entry. |
40
+ | `backend` | none | Node entry. Required when `node` is listed. |
41
+ | `dependencies` | `[]` | Other resource names, emitted as `dependency`. |
42
+ | `permissions` | `[]` | Extra manifest permissions, unioned with natives the scanner found. |
43
+ | `serverResourcesDir` | none | Destination parent for `--deploy`. |
44
+ | `web.root` | none | Folder that contains `vite.config` and `package.json`. |
45
+ | `web.entry` | `web/index.html` | Page the production build opens. |
46
+ | `web.devEntry` | none | Page used when building with `--dev`. |
47
+
48
+ `permissions` you list are kept even if the scanner did not see that native. The scanner still adds the permissions for natives that were actually called. It does not remove one you listed.
49
+
50
+ ## Targets
51
+
52
+ | Target | Compiler | Output |
53
+ |---|---|---|
54
+ | `open77-client` | TypeScriptToLua 5.4, bundled | `dist/client/main.lua` |
55
+ | `open77-server` | TypeScriptToLua 5.4, bundled | `dist/server/main.lua` |
56
+ | `node` | `tsc`, CommonJS, ES2022 | `dist/backend/index.js` |
57
+ | `webui` | Vite | `web/` |
58
+
59
+ Shared gameplay modules live in `src/shared` and are copied into each Lua bundle that imports them. They are not `shared_script` files. The Node program does not compile `src/shared` unless the backend file imports it. The notes example keeps the Lua contracts in `src/shared/contracts.ts` and lets the companion use `@open77-ts/shared`.
60
+
61
+ ## Generated files
62
+
63
+ Each build rewrites:
64
+
65
+ - `src/generated/flags.ts` — `webuiEntry`
66
+ - `tsconfig.json` for the editor, plus `tsconfig.client.json`, `tsconfig.server.json`, and `tsconfig.node.json` when those targets run
67
+ - `dist/client/main.lua` and `.map`
68
+ - `dist/server/main.lua` and `.map`
69
+ - `dist/backend/index.js`
70
+ - `open77.lua`
71
+
72
+ The editor reads `tsconfig.json`, which selects the client or server project for the open file. Completion follows the catalogue. Client files cannot see `TriggerClientEvent`. Server files cannot see `TriggerServerEvent`.
73
+
74
+ ## Companion environment
75
+
76
+ | Variable | Default | Used by |
77
+ |---|---|---|
78
+ | `OPEN77_BRIDGE_SECRET` | none, and the process refuses to start | HMAC key. 16–256 characters. |
79
+ | `OPEN77_BRIDGE_PORT` | `11782` | Listen port. |
80
+ | `OPEN77_NOTES_DRIVER` | `memory` | `memory`, `mysql`, `postgres`, or `redis`. |
81
+ | `OPEN77_DATABASE_URL` | none | Required unless the driver is `memory`. |
82
+
83
+ ## Game-server settings the resource reads
84
+
85
+ `Open77.tunables.declare` registers:
86
+
87
+ | Key | Default | Purpose |
88
+ |---|---|---|
89
+ | `open77_bridge_secret` | `""` | Same secret as `OPEN77_BRIDGE_SECRET`. Empty means calls fail with `bridge_secret_missing`. |
90
+ | `open77_bridge_url` | `http://127.0.0.1:11782/v1/call` | Where `Open77.http.request` posts. |
91
+
92
+ `Open77.convars.get` is checked first. Resolution order on the server is: an in-memory `SetConvar`, the `convars` block of `server.jsonc`, then this resource's tunable of the same name, then the caller's default. A value set in Warden is visible on the next read because the code reads it at the call, not at file load.
93
+
94
+ String tunables are capped at 256 characters by the host. That is why the companion also rejects a longer secret.
95
+
96
+ ## server.jsonc
97
+
98
+ Only the fields this bridge uses:
99
+
100
+ ```jsonc
101
+ {
102
+ "http": {
103
+ "enabled": true,
104
+ "allowedHosts": ["127.0.0.1"],
105
+ "timeoutSeconds": 5,
106
+ "maxResponseBytes": 1048576
107
+ },
108
+ "httpHandlers": {
109
+ "enabled": true,
110
+ "listenUrl": "http://127.0.0.1:11781",
111
+ "timeoutSeconds": 5
112
+ }
113
+ }
114
+ ```
115
+
116
+ `allowedHosts` entries are exact hosts (`discord.com`) or one subdomain wildcard (`*.example.com`). No scheme, path, or port. An empty list reaches nothing.
117
+
118
+ `httpHandlers.listenUrl` is an `http://` origin with no path. The listener adds `/<resource>/<prefix>` itself. Sixteen requests may be in flight per resource. A larger body than 16 KiB is refused before Lua sees it. A handler that never answers is timed out by the host.
119
+
120
+ The resource manifest still has to list `http.request` and, if it serves a route, `http.serve`. The build adds those when it sees the calls.
package/docs/debugging.md CHANGED
@@ -8,7 +8,7 @@ A Node entry that imports `@open77-ts/client` fails before `tsc` runs, with `Nod
8
8
 
9
9
  ## Lua that does not parse
10
10
 
11
- `validate` parses each bundle with luaparse. `open77_validate` from the Devkit compiles them with the server's own Lua when the server is installed. The notes resource has been compiled that way against binary 2.50.0+op77.156. That check is static. It does not start a session.
11
+ `validate` parses each bundle. `open77_validate` from the Devkit compiles them with the server's Lua when a server is installed. That check does not start a session.
12
12
 
13
13
  The manifest is not Lua. Do not run it through a Lua parser.
14
14
 
package/docs/examples.md CHANGED
@@ -1,7 +1,5 @@
1
1
  # Examples
2
2
 
3
- Neither example has been played inside Cyberpunk 2077 as part of this repository's checks. `npm test` compiles them. `open77_validate` has compiled `hello_world` and `player_notes` with the server's Lua. Join a server before treating gameplay as verified.
4
-
5
3
  ## hello_world
6
4
 
7
5
  `examples/hello_world` is a client, a server, a shared greeting, and a React HUD in `ui/`.
@@ -1,15 +1,15 @@
1
- # Deployment
2
-
3
- `ts77 deploy` builds the plugin, then copies `open77.lua`, `dist`, `web`, `modules`, and `files` into `<server>/resources/<plugin-name>`.
4
-
5
- ```bash
6
- npx ts2077 deploy --server D:\open77-server
7
- ```
8
-
9
- The server directory is the folder that contains `server.jsonc`. The resources directory is the `resources` folder inside it. The path is saved in `open77-ts.json` as `serverResourcesDir`.
10
-
11
- If that field is missing, deploy stops and tells you. It does not guess a server and it does not copy the resource somewhere else.
12
-
13
- After a successful copy, restart the resource on the OPEN//77 server. TS77 does not call a reload API. A live reload was not available as a verified command in this toolchain.
14
-
15
- The copy does not include `node_modules`, `src`, or `.env`. The Node companion is a separate process. Start it with `npm run dev` on the machine that should run it, with `OPEN77_BRIDGE_SECRET` set in that environment.
1
+ # Deployment
2
+
3
+ `ts77 deploy` builds the plugin, then copies `open77.lua`, `dist`, `web`, `modules`, and `files` into `<server>/resources/<plugin-name>`.
4
+
5
+ ```bash
6
+ npx ts2077 deploy --server D:\open77-server
7
+ ```
8
+
9
+ The server directory is the folder that contains `server.jsonc`. The resources directory is the `resources` folder inside it. The path is saved in `open77-ts.json` as `serverResourcesDir`.
10
+
11
+ If that field is missing, deploy stops and tells you. It does not guess a server and it does not copy the resource somewhere else.
12
+
13
+ After a successful copy, restart the resource on the OPEN//77 server. TS77 does not reload the server.
14
+
15
+ The copy does not include `node_modules`, `src`, or `.env`. The Node companion is a separate process. Start it with `npm run dev` on the machine that should run it, with `OPEN77_BRIDGE_SECRET` set in that environment.
@@ -1,22 +1,22 @@
1
- # Your first plugin
2
-
3
- `ts77 create` asks for a name, a template, an optional server directory, and whether to install dependencies. In a script or in CI, pass the answers as flags so it does not wait for input:
4
-
5
- ```bash
6
- npx ts2077 create my_plugin --template gameplay --no-install
7
- ```
8
-
9
- The name has to match the folder: a lowercase letter, then letters, digits, or underscores, 3 to 64 characters. `my-plugin` is rejected because of the hyphen. `my_plugin` is accepted.
10
-
11
- Templates:
12
-
13
- | Template | What you get |
14
- |---|---|
15
- | `basic` | One client file and one server file. No network permission. |
16
- | `gameplay` | A typed client-to-server ping. |
17
- | `webui` | A React page plus the client Lua that opens it. |
18
- | `fullstack` | Gameplay, React, and a Node companion. |
19
-
20
- Edit `src/client/main.ts` and `src/server/main.ts`. Save the file. `npm run dev` rebuilds. You do not edit the generated Lua.
21
-
22
- If `create` finds `server.jsonc` in the current directory, a parent directory, `OPEN77_SERVER`, or a folder next to the toolchain, the wizard offers that server. Declining leaves deployment unset.
1
+ # Your first plugin
2
+
3
+ `ts77 create` asks for a name, a template, an optional server directory, and whether to install dependencies. In a script or in CI, pass the answers as flags so it does not wait for input:
4
+
5
+ ```bash
6
+ npx ts2077 create my_plugin --template gameplay --no-install
7
+ ```
8
+
9
+ The name has to match the folder: a lowercase letter, then letters, digits, or underscores, 3 to 64 characters. `my-plugin` is rejected because of the hyphen. `my_plugin` is accepted.
10
+
11
+ Templates:
12
+
13
+ | Template | What you get |
14
+ |---|---|
15
+ | `basic` | One client file and one server file. No network permission. |
16
+ | `gameplay` | A typed client-to-server ping. |
17
+ | `webui` | A React page plus the client Lua that opens it. |
18
+ | `fullstack` | Gameplay, React, and a Node companion. |
19
+
20
+ Edit `src/client/main.ts` and `src/server/main.ts`. Save the file. `npm run dev` rebuilds. You do not edit the generated Lua.
21
+
22
+ If `create` finds `server.jsonc` in the current directory, a parent directory, `OPEN77_SERVER`, or a folder next to the toolchain, the wizard offers that server. Declining leaves deployment unset.
@@ -1,32 +1,32 @@
1
- # Quick start
2
-
3
- Install Node.js 20 or newer. The Node companion, when a plugin has one, expects Node.js 22 or newer.
4
-
5
- From a terminal:
6
-
7
- ```bash
8
- npx ts2077 create my_plugin --template basic --no-install
9
- cd my_plugin
10
- npm install
11
- npm run dev
12
- ```
13
-
14
- `npm run dev` watches `src/` and rebuilds Lua. This plugin has no WebUI and no Node process.
15
-
16
- When the output is what you want:
17
-
18
- ```bash
19
- npm run build
20
- ```
21
-
22
- That writes `open77.lua`, `dist/client/main.lua`, and `dist/server/main.lua`.
23
-
24
- To copy the resource onto a server you already have:
25
-
26
- ```bash
27
- npx ts2077 deploy --server <path-to-the-server>
28
- ```
29
-
30
- Restart that resource in OPEN//77 after the copy. TS77 does not reload the dedicated server.
31
-
32
- Open the project folder in Cursor or VS Code. The generated declarations in the toolchain supply hover text for natives: the summary, parameters, permissions, and the catalogue version.
1
+ # Quick start
2
+
3
+ Install Node.js 20 or newer. The Node companion, when a plugin has one, expects Node.js 22 or newer.
4
+
5
+ From a terminal:
6
+
7
+ ```bash
8
+ npx ts2077 create my_plugin --template basic --no-install
9
+ cd my_plugin
10
+ npm install
11
+ npm run dev
12
+ ```
13
+
14
+ `npm run dev` watches `src/` and rebuilds Lua. This plugin has no WebUI and no Node process.
15
+
16
+ When the output is what you want:
17
+
18
+ ```bash
19
+ npm run build
20
+ ```
21
+
22
+ That writes `open77.lua`, `dist/client/main.lua`, and `dist/server/main.lua`.
23
+
24
+ To copy the resource onto a server you already have:
25
+
26
+ ```bash
27
+ npx ts2077 deploy --server <path-to-the-server>
28
+ ```
29
+
30
+ Restart that resource in OPEN//77 after the copy. TS77 does not reload the dedicated server.
31
+
32
+ Open the project folder in Cursor or VS Code. `tsconfig.json` is already there. It points the editor at the client and server projects, so `@open77/sdk/client` and natives such as `GetCurrentResourceName` resolve. The hover text comes from the generated declarations: the summary, parameters, permissions, and the catalogue version.