ts2077 1.0.1 → 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.
- package/CHANGELOG.md +5 -0
- package/README.md +44 -115
- package/docs/README.md +2 -2
- package/docs/debugging.md +1 -1
- package/docs/examples.md +0 -2
- package/docs/guide/deployment.md +1 -1
- package/docs/index.html +1 -1
- package/docs/install.md +15 -2
- package/docs/limitations.md +1 -1
- package/package.json +1 -1
- package/packages/types/dist/generate.js +0 -2
- package/packages/types/generated/catalogue.json +1 -1
- package/packages/types/generated/client.d.ts +0 -1
- package/packages/types/generated/server.d.ts +0 -1
- package/packages/types/generated/shared.d.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.2
|
|
4
|
+
|
|
5
|
+
- The README and the guide are written for people installing the package.
|
|
6
|
+
- Published files no longer include a path from the machine that generated them.
|
|
7
|
+
|
|
3
8
|
## 1.0.1
|
|
4
9
|
|
|
5
10
|
- `create`, `init`, and `build` write `tsconfig.json`. The editor reads that file and then the client or server project, so `@open77/sdk/client` and the native declarations resolve.
|
package/README.md
CHANGED
|
@@ -1,71 +1,73 @@
|
|
|
1
1
|
# TS77
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Write OPEN//77 plugins in TypeScript. TS77 compiles the client and the server to Lua 5.4, writes the `open77.lua` manifest, and can build a React page and an optional Node companion.
|
|
4
4
|
|
|
5
|
-
The
|
|
5
|
+
The game runs the Lua. It does not run TypeScript. A web page cannot call natives. The server decides anything a player can gain.
|
|
6
6
|
|
|
7
|
-
The
|
|
8
|
-
|
|
9
|
-
## Requirements
|
|
10
|
-
|
|
11
|
-
- Node.js 20 or newer
|
|
12
|
-
- The Devkit index cache created by `npx -y @open2077/mcp init --server-dir <server>`
|
|
13
|
-
|
|
14
|
-
## Install
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
npm install
|
|
18
|
-
npm run build:tools
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
`build:tools` compiles the compiler and regenerates `packages/types/generated` from the Devkit index.
|
|
7
|
+
The full guide is at [imviloh.github.io/TS77](https://imviloh.github.io/TS77/).
|
|
22
8
|
|
|
23
9
|
## Create a plugin
|
|
24
10
|
|
|
25
|
-
|
|
11
|
+
You need Node.js 20 or newer. A plugin with a Node companion needs Node.js 22 for that process.
|
|
26
12
|
|
|
27
13
|
```bash
|
|
28
14
|
npx ts2077 create my_plugin --template basic --no-install
|
|
29
15
|
cd my_plugin
|
|
30
16
|
npm install
|
|
31
17
|
npm run dev
|
|
32
|
-
npm run build
|
|
33
18
|
```
|
|
34
19
|
|
|
35
|
-
|
|
20
|
+
The npm package is `ts2077`. It installs the `ts77` and `open77-ts` commands. `npm run dev` watches `src/` and rebuilds Lua when you save.
|
|
21
|
+
|
|
22
|
+
Open the folder in your editor. `tsconfig.json` is already there, so `@open77/sdk/client` and the native declarations resolve.
|
|
23
|
+
|
|
24
|
+
The folder name is the resource name: a lowercase letter, then letters, digits, or underscores, 3 to 64 characters. `my_plugin` is valid. `my-plugin` is not.
|
|
25
|
+
|
|
26
|
+
| Template | What you get |
|
|
27
|
+
|---|---|
|
|
28
|
+
| `basic` | A client and a server that print a greeting. No network permission. |
|
|
29
|
+
| `gameplay` | One typed event from the client to the server and back. |
|
|
30
|
+
| `webui` | Gameplay plus a React page in `ui/`. |
|
|
31
|
+
| `fullstack` | Gameplay, a React page, and a Node companion. |
|
|
36
32
|
|
|
37
33
|
```bash
|
|
38
|
-
npx ts2077 create my_resource --template basic
|
|
39
34
|
npx ts2077 create my_job --template gameplay
|
|
40
35
|
npx ts2077 create my_hud --template webui
|
|
41
36
|
npx ts2077 create my_notes --template fullstack
|
|
42
37
|
```
|
|
43
38
|
|
|
44
|
-
|
|
39
|
+
## Commands
|
|
40
|
+
|
|
41
|
+
Inside the plugin, `package.json` already has these scripts:
|
|
45
42
|
|
|
46
43
|
```bash
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
npm run dev
|
|
45
|
+
npm run build
|
|
46
|
+
npm run deploy
|
|
47
|
+
npm run validate
|
|
51
48
|
```
|
|
52
49
|
|
|
53
|
-
|
|
50
|
+
The same actions from any directory:
|
|
54
51
|
|
|
55
|
-
|
|
52
|
+
```bash
|
|
53
|
+
npx ts2077 build my_plugin
|
|
54
|
+
npx ts2077 watch my_plugin
|
|
55
|
+
npx ts2077 validate my_plugin
|
|
56
|
+
npx ts2077 doctor my_plugin
|
|
57
|
+
```
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
`build` writes `open77.lua`, `dist/client/main.lua`, and `dist/server/main.lua`. Leave those files alone. Change the TypeScript and build again.
|
|
58
60
|
|
|
59
|
-
|
|
61
|
+
## Gameplay
|
|
62
|
+
|
|
63
|
+
Client code is `src/client`. Server code is `src/server`. Code imported by both is `src/shared`.
|
|
60
64
|
|
|
61
65
|
```ts
|
|
62
|
-
import {
|
|
66
|
+
import { onClientResourceStart } from "@open77/sdk/client";
|
|
63
67
|
import { greet } from "../shared/greeting";
|
|
64
68
|
|
|
65
69
|
onClientResourceStart(() => {
|
|
66
70
|
print(greet(GetCurrentResourceName()));
|
|
67
|
-
const ok = emitServer("demo:ping", { text: "Night City" });
|
|
68
|
-
if (!ok) print("demo:ping was not sent");
|
|
69
71
|
});
|
|
70
72
|
```
|
|
71
73
|
|
|
@@ -79,95 +81,22 @@ onNet("demo:ping", (payload) => {
|
|
|
79
81
|
});
|
|
80
82
|
```
|
|
81
83
|
|
|
82
|
-
`authenticatedPlayer()`
|
|
84
|
+
`authenticatedPlayer()` is the server-assigned player. A client cannot choose that id. Check the payload before you use it.
|
|
83
85
|
|
|
84
|
-
Natives
|
|
86
|
+
Natives come from the OPEN//77 catalogue shipped with this package, **2.50.0+op77.148**. A client file cannot call `TriggerClientEvent`. A server file cannot call `TriggerServerEvent`. `class`, `async`, and Node.js imports are compile errors in gameplay.
|
|
85
87
|
|
|
86
|
-
|
|
87
|
-
const [page, reason] = Open77.webui.create({ entry: "web/index.html" });
|
|
88
|
-
const [ok, failure] = TriggerClientEvent("demo:pong", playerId, payload);
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
`tsconfig.json` points the editor at `tsconfig.client.json` and `tsconfig.server.json`. Those two files are rewritten on each build and point at the generated declarations, so completion follows the catalogue.
|
|
92
|
-
|
|
93
|
-
A client file cannot see `TriggerClientEvent`. A server file cannot see `TriggerServerEvent`. `class`, `async`, `Promise`, `Map`, `Set`, and Node.js imports are compile errors.
|
|
94
|
-
|
|
95
|
-
The build writes `open77.lua` with the Lua files that were actually produced and the permissions of the natives it found. `network.events` is added when the resource sends or receives network events. Empty script globs are not written.
|
|
96
|
-
|
|
97
|
-
## React WebUI
|
|
98
|
-
|
|
99
|
-
The `webui` template and `examples/hello_world` put a Vite React app in `ui/`. `npm run build` inside `ui/` writes `web/`, and the manifest lists those files one by one. The page talks to Lua through the documented bridge:
|
|
100
|
-
|
|
101
|
-
```ts
|
|
102
|
-
window.Open77?.on("hud:state", (payload) => render(payload));
|
|
103
|
-
window.Open77?.emit("hud:ping", { text: "Night City" });
|
|
104
|
-
window.Open77?.ready();
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
Lua listens with `page.on` and sends with `page.send`. For Vite during development, build with `--dev` or set the WebUI entry to `http://127.0.0.1:5173/`. That address is the player's PC. Call `Open77.ready()` again after a hot reload so Lua can send the current state.
|
|
108
|
-
|
|
109
|
-
`hud` and `menu` do not need a WebUI permission. `modal`, `system`, and `debug` do, and the helper does not offer them.
|
|
110
|
-
|
|
111
|
-
## Targets
|
|
112
|
-
|
|
113
|
-
A resource lists the runtimes it actually builds. The defaults are client Lua, server Lua, a WebUI when `web.root` is set, and a Node companion when `backend` is set.
|
|
114
|
-
|
|
115
|
-
| Target | Result |
|
|
116
|
-
|---|---|
|
|
117
|
-
| `open77-client` | One Lua 5.4 client bundle |
|
|
118
|
-
| `open77-server` | One Lua 5.4 server bundle |
|
|
119
|
-
| `node` | CommonJS from `src/backend`, run with Node.js 22 |
|
|
120
|
-
| `webui` | Vite bundle from `src/webui` or `ui` |
|
|
121
|
-
|
|
122
|
-
`@open77-ts/client`, `@open77-ts/server`, and `@open77-ts/shared` are compiled into Lua. `@open77-ts/shared` in gameplay is the contract module: plain values and checks, no Node APIs. `@open77-ts/node` is the companion and is rejected in a Lua or page build. `@open77-ts/webui` is the page bridge and is rejected in Lua. The older `@open77/sdk/client` and `@open77/sdk/server` names still resolve.
|
|
123
|
-
|
|
124
|
-
`npx open77-ts create my_notes --template fullstack` writes `src/client`, `src/server`, `src/backend`, `src/webui`, and `src/shared`. `dev` rebuilds those targets, restarts `dist/backend/index.js` when that file exists, and starts Vite when its dependencies are installed. Set `OPEN77_BRIDGE_SECRET` in the environment before starting the companion. The game server reads the same value from the `open77_bridge_secret` convar or from that resource's tunable. Leave it empty and the server reports `bridge_secret_missing` instead of calling out.
|
|
125
|
-
|
|
126
|
-
The companion listens on `127.0.0.1:11782` unless `OPEN77_BRIDGE_PORT` is set. The dedicated server must enable outbound HTTP and allow that host:
|
|
127
|
-
|
|
128
|
-
```jsonc
|
|
129
|
-
"http": { "enabled": true, "allowedHosts": ["127.0.0.1"] }
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
`http.allowedHosts` is a hostname, not a URL. Inbound calls from Node use `httpHandlers` and `Open77.http.listen`, which is off until the operator enables it. `OPEN77_NOTES_DRIVER` may be `memory` (the default), `mysql`, `postgres`, or `redis`. The database URL is `OPEN77_DATABASE_URL`. File reads stay inside the root configured on the companion and reject `..`.
|
|
133
|
-
|
|
134
|
-
`examples/player_notes` is the full path: the React page emits `notes:submit`, client Lua sends `notes:save`, the server checks `authenticatedPlayer()` and the text, `Open77.http.request` calls `notes.save`, and the page renders the saved text or `backend_offline`. The page's health `fetch` does not save anything. Saving does not grant money, items, or vehicles. No play session in Cyberpunk 2077 was run for this example.
|
|
135
|
-
|
|
136
|
-
## Debugging
|
|
137
|
-
|
|
138
|
-
Type errors name the TypeScript file and line. Lua is formatted by TypeScriptToLua and carries a source map next to the bundle. The sandbox cannot run `debug.traceback`, so the map is applied by the CLI:
|
|
88
|
+
## Deploy
|
|
139
89
|
|
|
140
90
|
```bash
|
|
141
|
-
npx
|
|
91
|
+
npx ts2077 deploy --server <server-directory>
|
|
142
92
|
```
|
|
143
93
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
```text
|
|
147
|
-
[OPEN77-TS] Resource: hello_world
|
|
148
|
-
|
|
149
|
-
Runtime Error:
|
|
150
|
-
src/shared/greeting.ts:2
|
|
151
|
-
```
|
|
94
|
+
`<server-directory>` is the folder that contains `server.jsonc`. TS77 copies the built resource into `resources/<plugin>` inside it. Restart that resource on the server afterward. TS77 does not reload the server.
|
|
152
95
|
|
|
153
|
-
##
|
|
96
|
+
## React and Node
|
|
154
97
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
## Example
|
|
158
|
-
|
|
159
|
-
`examples/hello_world` is a client, a server, a shared greeting module, a typed ping, and a React HUD.
|
|
160
|
-
|
|
161
|
-
- The server registers `/hello` with `RegisterCommand`. Arguments arrive as strings. A console `source` of `0` is not sent to a client, because target `0` is a host error.
|
|
162
|
-
- The page emits `hud:ping`. The client sends `hello:ping`. The server checks the payload and replies to `authenticatedPlayer()` with `hello:notice`.
|
|
163
|
-
- The client updates the HUD with `page.send`.
|
|
164
|
-
|
|
165
|
-
```bash
|
|
166
|
-
npx open77-ts build examples/hello_world
|
|
167
|
-
npx open77-ts validate examples/hello_world
|
|
168
|
-
npm test
|
|
169
|
-
```
|
|
98
|
+
A `webui` plugin keeps its page in `ui/`. Run `npm install` there before the first page build. The page uses `window.Open77` only: `ready`, `on`, `emit`, and `invoke`.
|
|
170
99
|
|
|
171
|
-
|
|
100
|
+
A `fullstack` plugin adds `src/backend`. Set `OPEN77_BRIDGE_SECRET` to the same value on Node and on the game server before the companion will accept a call. Databases and other npm packages belong in that process, not in Lua.
|
|
172
101
|
|
|
173
|
-
|
|
102
|
+
Details, the native index, and the companion protocol are in the [guide](https://imviloh.github.io/TS77/).
|
package/docs/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# TS77 documentation
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The published guide is [index.html](index.html), also served at [imviloh.github.io/TS77](https://imviloh.github.io/TS77/).
|
|
4
4
|
|
|
5
5
|
The catalogue this tree was generated from is **2.50.0+op77.148**. Natives, permissions, and reserved event names come from that index. They are not invented.
|
|
6
6
|
|
|
@@ -22,4 +22,4 @@ The catalogue this tree was generated from is **2.50.0+op77.148**. Natives, perm
|
|
|
22
22
|
| [Examples](examples.md) | `hello_world` and `player_notes`, end to end |
|
|
23
23
|
| [Limitations](limitations.md) | What the sandbox and this toolchain do not do |
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
Plugin authors should start at the [published guide](https://imviloh.github.io/TS77/). [Install](install.md) also covers building this repository. [Commands](commands.md) lists every flag. The player-notes walkthrough is in [Examples](examples.md).
|
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
|
|
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/`.
|
package/docs/guide/deployment.md
CHANGED
|
@@ -10,6 +10,6 @@ The server directory is the folder that contains `server.jsonc`. The resources d
|
|
|
10
10
|
|
|
11
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
12
|
|
|
13
|
-
After a successful copy, restart the resource on the OPEN//77 server. TS77 does not
|
|
13
|
+
After a successful copy, restart the resource on the OPEN//77 server. TS77 does not reload the server.
|
|
14
14
|
|
|
15
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.
|
package/docs/index.html
CHANGED
|
@@ -703,7 +703,7 @@ const db = require("rethinkdb");</pre>
|
|
|
703
703
|
<section id="limits">
|
|
704
704
|
<h2>Limits</h2>
|
|
705
705
|
<p>The dedicated server sandbox has no <code>require</code>, <code>os</code>, <code>io</code>, <code>debug</code>, <code>package</code>, <code>load</code>, or <code>collectgarbage</code>. The client also removes <code>setmetatable</code>. Bundles inline their helpers and do not fall back to a global <code>require</code>.</p>
|
|
706
|
-
<p>
|
|
706
|
+
<p>Declarations in this package follow catalogue 2.50.0+op77.148. A native added in a later server build is not declared until that catalogue is updated.</p>
|
|
707
707
|
<footer>TS77 · catalogue 2.50.0+op77.148 · declarations generated from the OPEN//77 Devkit index · 1595 declared natives · 164 omitted</footer>
|
|
708
708
|
</section>
|
|
709
709
|
</main>
|
package/docs/install.md
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
# Install
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Install the package
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Node.js 20 or newer. A Node companion needs Node.js 22.
|
|
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
|
+
The npm package is `ts2077`. The commands are `ts77` and `open77-ts`. The rest of this page is for working on the TS77 repository itself.
|
|
15
|
+
|
|
16
|
+
## What the repository build needs
|
|
17
|
+
|
|
18
|
+
- Node.js 20 or newer. `ts77 doctor` fails below 20 and warns below 22.
|
|
6
19
|
- An OPEN//77 dedicated server if you want to deploy a resource. Compiling a plugin does not require one.
|
|
7
20
|
- The Devkit index produced by:
|
|
8
21
|
|
package/docs/limitations.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Limitations
|
|
2
2
|
|
|
3
|
-
This
|
|
3
|
+
This package targets OPEN//77 catalogue **2.50.0+op77.148**. A native added in a later server build is not declared until that catalogue is updated. A native removed from the catalogue is not invented.
|
|
4
4
|
|
|
5
5
|
## Runtime
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -302,7 +302,6 @@ function renderRuntime(runtime, cards, build, skipped) {
|
|
|
302
302
|
`/**`,
|
|
303
303
|
` * OPEN//77 ${runtime} declarations for catalogue build ${build}.`,
|
|
304
304
|
` * Generated from the official Devkit index. Do not edit by hand.`,
|
|
305
|
-
` * Regenerate with \`npm run generate\` inside the TS77 repo.`,
|
|
306
305
|
` */`,
|
|
307
306
|
`/// <reference path="./tstl-language-extensions.d.ts" />`,
|
|
308
307
|
``,
|
|
@@ -435,7 +434,6 @@ function main() {
|
|
|
435
434
|
const reserved = [...new Set((events.reservedPrefixes ?? []).map((entry) => entry.prefix))].sort();
|
|
436
435
|
const catalogue = {
|
|
437
436
|
build,
|
|
438
|
-
indexDir: directory,
|
|
439
437
|
omittedUnavailable: omitted,
|
|
440
438
|
skipped,
|
|
441
439
|
reservedPrefixes: reserved,
|