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.
- package/CHANGELOG.md +21 -11
- package/README.md +102 -174
- package/docs/README.md +2 -2
- package/docs/commands.md +125 -125
- package/docs/configuration.md +120 -120
- package/docs/debugging.md +1 -1
- package/docs/examples.md +0 -2
- package/docs/guide/deployment.md +15 -15
- package/docs/guide/first-plugin.md +22 -22
- package/docs/guide/quick-start.md +32 -32
- package/docs/index.html +872 -872
- package/docs/install.md +108 -95
- package/docs/limitations.md +1 -1
- package/package.json +77 -77
- package/packages/cli/dist/cli.js +27 -25
- package/packages/compiler/dist/build.d.ts +1 -0
- package/packages/compiler/dist/build.js +22 -4
- package/packages/compiler/dist/index.d.ts +1 -1
- package/packages/compiler/dist/index.js +2 -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,11 +1,21 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
## 1.0.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
1
|
+
# Changelog
|
|
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
|
+
|
|
8
|
+
## 1.0.1
|
|
9
|
+
|
|
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.
|
|
11
|
+
- The npm package name is `ts2077`. The installed commands remain `ts77` and `open77-ts`.
|
|
12
|
+
|
|
13
|
+
## 1.0.0
|
|
14
|
+
|
|
15
|
+
First package prepared for the npm name `ts2077`. The installed commands are `ts77` and `open77-ts`.
|
|
16
|
+
|
|
17
|
+
- Public CLI commands: `create`, `init`, `dev`, `build`, `watch`, `deploy`, `validate`, `doctor`, `types`, `docs`, `update`, `help`.
|
|
18
|
+
- New plugins get `package.json` scripts for `dev`, `build`, `deploy`, and `validate`.
|
|
19
|
+
- Optional `ts77.config.json` and `ts77.config.ts` overlay the resource config without replacing `open77-ts.json` on disk.
|
|
20
|
+
- TypeScript declarations stay generated from the OPEN//77 Devkit catalogue. This release's catalogue is 2.50.0+op77.148.
|
|
21
|
+
- `ts77 types` keeps the last generated declarations when the Devkit index is not on the machine, and says so.
|
package/README.md
CHANGED
|
@@ -1,174 +1,102 @@
|
|
|
1
|
-
# TS77
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
The
|
|
6
|
-
|
|
7
|
-
The
|
|
8
|
-
|
|
9
|
-
##
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
`
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
onClientResourceStart
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
window.Open77?.on("hud:state", (payload) => render(payload));
|
|
104
|
-
window.Open77?.emit("hud:ping", { text: "Night City" });
|
|
105
|
-
window.Open77?.ready();
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
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.
|
|
109
|
-
|
|
110
|
-
`hud` and `menu` do not need a WebUI permission. `modal`, `system`, and `debug` do, and the helper does not offer them.
|
|
111
|
-
|
|
112
|
-
## Targets
|
|
113
|
-
|
|
114
|
-
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.
|
|
115
|
-
|
|
116
|
-
| Target | Result |
|
|
117
|
-
|---|---|
|
|
118
|
-
| `open77-client` | One Lua 5.4 client bundle |
|
|
119
|
-
| `open77-server` | One Lua 5.4 server bundle |
|
|
120
|
-
| `node` | CommonJS from `src/backend`, run with Node.js 22 |
|
|
121
|
-
| `webui` | Vite bundle from `src/webui` or `ui` |
|
|
122
|
-
|
|
123
|
-
`@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.
|
|
124
|
-
|
|
125
|
-
`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.
|
|
126
|
-
|
|
127
|
-
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:
|
|
128
|
-
|
|
129
|
-
```jsonc
|
|
130
|
-
"http": { "enabled": true, "allowedHosts": ["127.0.0.1"] }
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
`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 `..`.
|
|
134
|
-
|
|
135
|
-
`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.
|
|
136
|
-
|
|
137
|
-
## Debugging
|
|
138
|
-
|
|
139
|
-
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:
|
|
140
|
-
|
|
141
|
-
```bash
|
|
142
|
-
npx open77-ts map examples/hello_world/dist/server/main.lua 120
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
When the map has a position, the output looks like:
|
|
146
|
-
|
|
147
|
-
```text
|
|
148
|
-
[OPEN77-TS] Resource: hello_world
|
|
149
|
-
|
|
150
|
-
Runtime Error:
|
|
151
|
-
src/shared/greeting.ts:2
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
## Updating OPEN//77
|
|
155
|
-
|
|
156
|
-
When a newer Devkit index is published, refresh the MCP cache and run `npm run generate` (or `npx open77-ts types`). Declarations, permissions, and reserved event prefixes are rewritten from that index. Do not hand-edit `packages/types/generated`.
|
|
157
|
-
|
|
158
|
-
## Example
|
|
159
|
-
|
|
160
|
-
`examples/hello_world` is a client, a server, a shared greeting module, a typed ping, and a React HUD.
|
|
161
|
-
|
|
162
|
-
- 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.
|
|
163
|
-
- The page emits `hud:ping`. The client sends `hello:ping`. The server checks the payload and replies to `authenticatedPlayer()` with `hello:notice`.
|
|
164
|
-
- The client updates the HUD with `page.send`.
|
|
165
|
-
|
|
166
|
-
```bash
|
|
167
|
-
npx open77-ts build examples/hello_world
|
|
168
|
-
npx open77-ts validate examples/hello_world
|
|
169
|
-
npm test
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
Build, Lua parse, call syntax, the `require` shim, and source-map lookup are covered by `npm test`. `open77_validate` is the Devkit's static check. Neither one replaces joining the server in Cyberpunk 2077.
|
|
173
|
-
|
|
174
|
-
See [docs/limitations.md](docs/limitations.md) for the runtime restrictions and what this project does not claim.
|
|
1
|
+
# TS77
|
|
2
|
+
|
|
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
|
+
|
|
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
|
+
|
|
7
|
+
The full guide is at [imviloh.github.io/TS77](https://imviloh.github.io/TS77/).
|
|
8
|
+
|
|
9
|
+
## Create a plugin
|
|
10
|
+
|
|
11
|
+
You need Node.js 20 or newer. A plugin with a Node companion needs Node.js 22 for that process.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx ts2077 create my_plugin --template basic --no-install
|
|
15
|
+
cd my_plugin
|
|
16
|
+
npm install
|
|
17
|
+
npm run dev
|
|
18
|
+
```
|
|
19
|
+
|
|
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. |
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
npx ts2077 create my_job --template gameplay
|
|
35
|
+
npx ts2077 create my_hud --template webui
|
|
36
|
+
npx ts2077 create my_notes --template fullstack
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Commands
|
|
40
|
+
|
|
41
|
+
Inside the plugin, `package.json` already has these scripts:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npm run dev
|
|
45
|
+
npm run build
|
|
46
|
+
npm run deploy
|
|
47
|
+
npm run validate
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The same actions from any directory:
|
|
51
|
+
|
|
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
|
+
```
|
|
58
|
+
|
|
59
|
+
`build` writes `open77.lua`, `dist/client/main.lua`, and `dist/server/main.lua`. Leave those files alone. Change the TypeScript and build again.
|
|
60
|
+
|
|
61
|
+
## Gameplay
|
|
62
|
+
|
|
63
|
+
Client code is `src/client`. Server code is `src/server`. Code imported by both is `src/shared`.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { onClientResourceStart } from "@open77/sdk/client";
|
|
67
|
+
import { greet } from "../shared/greeting";
|
|
68
|
+
|
|
69
|
+
onClientResourceStart(() => {
|
|
70
|
+
print(greet(GetCurrentResourceName()));
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { authenticatedPlayer, emitClient, onNet } from "@open77/sdk/server";
|
|
76
|
+
|
|
77
|
+
onNet("demo:ping", (payload) => {
|
|
78
|
+
const player = authenticatedPlayer();
|
|
79
|
+
if (player === undefined) return;
|
|
80
|
+
emitClient(player, "demo:pong", payload);
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`authenticatedPlayer()` is the server-assigned player. A client cannot choose that id. Check the payload before you use it.
|
|
85
|
+
|
|
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.
|
|
87
|
+
|
|
88
|
+
## Deploy
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npx ts2077 deploy --server <server-directory>
|
|
92
|
+
```
|
|
93
|
+
|
|
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.
|
|
95
|
+
|
|
96
|
+
## React and Node
|
|
97
|
+
|
|
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`.
|
|
99
|
+
|
|
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.
|
|
101
|
+
|
|
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/commands.md
CHANGED
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
# Commands
|
|
2
|
-
|
|
3
|
-
The public executable is `ts77`. `open77-ts` runs the same file. The npm package name is `ts2077`.
|
|
4
|
-
|
|
5
|
-
| Command | What it does |
|
|
6
|
-
|---|---|
|
|
7
|
-
| `ts77 create` | Writes a plugin. In a terminal with no name, it asks four questions. `--no-install` skips `npm install`. |
|
|
8
|
-
| `ts77 init` | Adds the basic template to a directory and skips files that already exist. |
|
|
9
|
-
| `ts77 dev` | Watches `src`, rebuilds, restarts a Node companion only when `dist/backend` exists, and starts Vite only when its dependencies are installed. |
|
|
10
|
-
| `ts77 build` | Compiles the plugin. |
|
|
11
|
-
| `ts77 watch` | Rebuilds on change and does not start Vite. |
|
|
12
|
-
| `ts77 deploy` | Builds and copies the resource. Refuses to run until a server resources directory is set. |
|
|
13
|
-
| `ts77 validate` | Checks the manifest and the Lua bundles. |
|
|
14
|
-
| `ts77 doctor` | Reports Node, TypeScriptToLua, the catalogue, and the plugin layout. |
|
|
15
|
-
| `ts77 types` | Regenerates declarations from the local Devkit index. |
|
|
16
|
-
| `ts77 docs` | Prints the path of `docs/index.html`. `--open` opens it. |
|
|
17
|
-
| `ts77 update` | Prints the catalogue build and the command that refreshes the Devkit index. It does not download or publish. |
|
|
18
|
-
| `ts77 help` | Prints the command list and examples. |
|
|
19
|
-
|
|
20
|
-
`ts77 --version` prints the package version. `--quiet` hides the success banner.
|
|
21
|
-
|
|
22
|
-
The sections below describe the same build in more detail.
|
|
23
|
-
|
|
24
|
-
The CLI is `npx ts2077` from the registry, or `npx open77-ts` from this repository. Every command except `types` and `map` takes an optional resource directory. The default is the current directory.
|
|
25
|
-
|
|
26
|
-
```text
|
|
27
|
-
open77-ts <command>
|
|
28
|
-
|
|
29
|
-
init [dir]
|
|
30
|
-
create <name> [--template basic|gameplay|webui|fullstack] [--out dir]
|
|
31
|
-
build [dir] [--dev] [--deploy]
|
|
32
|
-
watch [dir]
|
|
33
|
-
dev [dir]
|
|
34
|
-
validate [dir]
|
|
35
|
-
doctor [dir]
|
|
36
|
-
map <lua-file> <line> [column]
|
|
37
|
-
types
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## init
|
|
41
|
-
|
|
42
|
-
`init` copies the `basic` template into an existing directory. The directory's basename becomes the resource name and must already be a legal slug. If `open77-ts.json` is already there, the command leaves the directory alone.
|
|
43
|
-
|
|
44
|
-
## create
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
npx
|
|
48
|
-
npx
|
|
49
|
-
npx
|
|
50
|
-
npx
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
The destination folder name must equal `<name>`. `--out` sets that folder. Without `--out`, the folder is created in the current directory.
|
|
54
|
-
|
|
55
|
-
| Template | Layout |
|
|
56
|
-
|---|---|
|
|
57
|
-
| `basic` | Client and server scripts that print on start. No network permission. |
|
|
58
|
-
| `gameplay` | A typed ping from client to server and back. |
|
|
59
|
-
| `webui` | Gameplay plus a React HUD in `ui/`. |
|
|
60
|
-
| `fullstack` | `src/client`, `src/server`, `src/backend`, `src/webui`, and `src/shared`. |
|
|
61
|
-
|
|
62
|
-
`__RESOURCE__` in a template is replaced with the resource name. `fullstack` still needs `npm install` inside `src/webui` before the page will build, and `OPEN77_BRIDGE_SECRET` before the companion will listen.
|
|
63
|
-
|
|
64
|
-
## build
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
npx open77-ts build examples/player_notes
|
|
68
|
-
npx open77-ts build examples/hello_world --dev
|
|
69
|
-
npx open77-ts build examples/hello_world --deploy
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
For each selected target the build:
|
|
73
|
-
|
|
74
|
-
1. Writes `src/generated/flags.ts` with the WebUI entry. `--dev` uses `web.devEntry` when it is set, so the page can load Vite on the player's machine.
|
|
75
|
-
2. Writes `tsconfig.client.json
|
|
76
|
-
3. Rejects classes, async, Node imports, and SDK imports from the wrong runtime.
|
|
77
|
-
4. Compiles client and server TypeScript to one Lua 5.4 bundle each, inlines the small TypeScriptToLua helpers, and removes the global `require` fallback. TypeScript under `src/modules` is compiled to `modules/*.lua` and listed as `file` entries for the client sandbox loader. `src/backend` is compiled with `tsc` so `require` and `import` of npm packages stay in Node.
|
|
78
|
-
5. Scans the Lua for natives, refuses unknown or wrong-side calls, and records permissions.
|
|
79
|
-
6. Compiles `src/backend` to `dist/backend/index.js` when the `node` target is on.
|
|
80
|
-
7. Runs Vite when the `webui` target is on and `--` the WebUI dependencies are installed. A resource that lists `webui` explicitly fails the build if Vite fails. A resource that only has a `web.root` and does not list targets keeps going and prints the Vite error.
|
|
81
|
-
8. Writes `open77.lua`. Scripts that were not built are omitted. `files/` and `web/` are listed file by file. Source maps are not listed.
|
|
82
|
-
|
|
83
|
-
`--deploy` copies `open77.lua`, `dist`, and `web` into `<serverResourcesDir>/<resource name>`. It does not reload the server and it does not start Node. `dist/backend` is part of `dist`, so the JavaScript is copied, but the dedicated server does not execute it.
|
|
84
|
-
|
|
85
|
-
## watch
|
|
86
|
-
|
|
87
|
-
`watch` rebuilds when anything under `src/` changes. If `dist/backend/index.js` exists after a successful build, the previous companion process is killed and a new one is started with the current environment. The secret has to already be in that environment.
|
|
88
|
-
|
|
89
|
-
## dev
|
|
90
|
-
|
|
91
|
-
`dev` is `watch` plus Vite. It looks for `node_modules/vite/bin/vite.js` in `ui/` and then in `src/webui/`. The dev server binds `127.0.0.1:5173`. That address is the computer running Vite. In a real session that is the player's PC, not the dedicated server.
|
|
92
|
-
|
|
93
|
-
## validate
|
|
94
|
-
|
|
95
|
-
`validate` checks that every `client_script`, `server_script`, `file`, and `web_file` in `open77.lua` exists, that both Lua bundles parse, that the bundle does not fall back to the global `require`, and that the native scan still matches the catalogue. It does not typecheck TypeScript. Run `build` first.
|
|
96
|
-
|
|
97
|
-
## doctor
|
|
98
|
-
|
|
99
|
-
`doctor` prints `ok`, `warn`, or `fail` lines:
|
|
100
|
-
|
|
101
|
-
- Node version
|
|
102
|
-
- `typescript-to-lua` installed
|
|
103
|
-
- Catalogue present, with its build and counts
|
|
104
|
-
- A warning that the server binary may be newer than the catalogue
|
|
105
|
-
- Resource name, directory name, client entry, server entry, backend entry, and target list
|
|
106
|
-
- `serverResourcesDir` when it is set
|
|
107
|
-
|
|
108
|
-
Exit code 1 means at least one `fail` line.
|
|
109
|
-
|
|
110
|
-
## map
|
|
111
|
-
|
|
112
|
-
```bash
|
|
113
|
-
npx open77-ts map examples/hello_world/dist/server/main.lua 120
|
|
114
|
-
npx open77-ts map examples/hello_world/dist/server/main.lua 120 4
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Reads the `.map` beside the Lua file and prints a TypeScript file and line. Column 0 often has no mapping, so the tool also tries columns 0, 1, 2, 4, 8, and 16. The game cannot do this. `debug.traceback` is not in the sandbox, and `sourceMapTraceback` is off.
|
|
118
|
-
|
|
119
|
-
## types
|
|
120
|
-
|
|
121
|
-
Regenerates declarations from the Devkit index. Same as `npm run generate`.
|
|
122
|
-
|
|
123
|
-
## What the CLI does not do
|
|
124
|
-
|
|
125
|
-
It does not join a server, send `reload`, or open Cyberpunk 2077. Reloading a resource is a console command on that server.
|
|
1
|
+
# Commands
|
|
2
|
+
|
|
3
|
+
The public executable is `ts77`. `open77-ts` runs the same file. The npm package name is `ts2077`.
|
|
4
|
+
|
|
5
|
+
| Command | What it does |
|
|
6
|
+
|---|---|
|
|
7
|
+
| `ts77 create` | Writes a plugin. In a terminal with no name, it asks four questions. `--no-install` skips `npm install`. |
|
|
8
|
+
| `ts77 init` | Adds the basic template to a directory and skips files that already exist. |
|
|
9
|
+
| `ts77 dev` | Watches `src`, rebuilds, restarts a Node companion only when `dist/backend` exists, and starts Vite only when its dependencies are installed. |
|
|
10
|
+
| `ts77 build` | Compiles the plugin. |
|
|
11
|
+
| `ts77 watch` | Rebuilds on change and does not start Vite. |
|
|
12
|
+
| `ts77 deploy` | Builds and copies the resource. Refuses to run until a server resources directory is set. |
|
|
13
|
+
| `ts77 validate` | Checks the manifest and the Lua bundles. |
|
|
14
|
+
| `ts77 doctor` | Reports Node, TypeScriptToLua, the catalogue, and the plugin layout. |
|
|
15
|
+
| `ts77 types` | Regenerates declarations from the local Devkit index. |
|
|
16
|
+
| `ts77 docs` | Prints the path of `docs/index.html`. `--open` opens it. |
|
|
17
|
+
| `ts77 update` | Prints the catalogue build and the command that refreshes the Devkit index. It does not download or publish. |
|
|
18
|
+
| `ts77 help` | Prints the command list and examples. |
|
|
19
|
+
|
|
20
|
+
`ts77 --version` prints the package version. `--quiet` hides the success banner.
|
|
21
|
+
|
|
22
|
+
The sections below describe the same build in more detail.
|
|
23
|
+
|
|
24
|
+
The CLI is `npx ts2077` from the registry, or `npx open77-ts` from this repository. Every command except `types` and `map` takes an optional resource directory. The default is the current directory.
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
open77-ts <command>
|
|
28
|
+
|
|
29
|
+
init [dir]
|
|
30
|
+
create <name> [--template basic|gameplay|webui|fullstack] [--out dir]
|
|
31
|
+
build [dir] [--dev] [--deploy]
|
|
32
|
+
watch [dir]
|
|
33
|
+
dev [dir]
|
|
34
|
+
validate [dir]
|
|
35
|
+
doctor [dir]
|
|
36
|
+
map <lua-file> <line> [column]
|
|
37
|
+
types
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## init
|
|
41
|
+
|
|
42
|
+
`init` copies the `basic` template into an existing directory. The directory's basename becomes the resource name and must already be a legal slug. If `open77-ts.json` is already there, the command leaves the directory alone.
|
|
43
|
+
|
|
44
|
+
## create
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npx ts2077 create my_resource --template basic
|
|
48
|
+
npx ts2077 create my_job --template gameplay
|
|
49
|
+
npx ts2077 create my_hud --template webui
|
|
50
|
+
npx ts2077 create my_notes --template fullstack --out D:\open77-server\resources\my_notes
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The destination folder name must equal `<name>`. `--out` sets that folder. Without `--out`, the folder is created in the current directory.
|
|
54
|
+
|
|
55
|
+
| Template | Layout |
|
|
56
|
+
|---|---|
|
|
57
|
+
| `basic` | Client and server scripts that print on start. No network permission. |
|
|
58
|
+
| `gameplay` | A typed ping from client to server and back. |
|
|
59
|
+
| `webui` | Gameplay plus a React HUD in `ui/`. |
|
|
60
|
+
| `fullstack` | `src/client`, `src/server`, `src/backend`, `src/webui`, and `src/shared`. |
|
|
61
|
+
|
|
62
|
+
`__RESOURCE__` in a template is replaced with the resource name. `fullstack` still needs `npm install` inside `src/webui` before the page will build, and `OPEN77_BRIDGE_SECRET` before the companion will listen.
|
|
63
|
+
|
|
64
|
+
## build
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
npx open77-ts build examples/player_notes
|
|
68
|
+
npx open77-ts build examples/hello_world --dev
|
|
69
|
+
npx open77-ts build examples/hello_world --deploy
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
For each selected target the build:
|
|
73
|
+
|
|
74
|
+
1. Writes `src/generated/flags.ts` with the WebUI entry. `--dev` uses `web.devEntry` when it is set, so the page can load Vite on the player's machine.
|
|
75
|
+
2. Writes `tsconfig.json`, `tsconfig.client.json`, and `tsconfig.server.json` with paths to the SDK and the generated declarations. The editor reads `tsconfig.json`.
|
|
76
|
+
3. Rejects classes, async, Node imports, and SDK imports from the wrong runtime.
|
|
77
|
+
4. Compiles client and server TypeScript to one Lua 5.4 bundle each, inlines the small TypeScriptToLua helpers, and removes the global `require` fallback. TypeScript under `src/modules` is compiled to `modules/*.lua` and listed as `file` entries for the client sandbox loader. `src/backend` is compiled with `tsc` so `require` and `import` of npm packages stay in Node.
|
|
78
|
+
5. Scans the Lua for natives, refuses unknown or wrong-side calls, and records permissions.
|
|
79
|
+
6. Compiles `src/backend` to `dist/backend/index.js` when the `node` target is on.
|
|
80
|
+
7. Runs Vite when the `webui` target is on and `--` the WebUI dependencies are installed. A resource that lists `webui` explicitly fails the build if Vite fails. A resource that only has a `web.root` and does not list targets keeps going and prints the Vite error.
|
|
81
|
+
8. Writes `open77.lua`. Scripts that were not built are omitted. `files/` and `web/` are listed file by file. Source maps are not listed.
|
|
82
|
+
|
|
83
|
+
`--deploy` copies `open77.lua`, `dist`, and `web` into `<serverResourcesDir>/<resource name>`. It does not reload the server and it does not start Node. `dist/backend` is part of `dist`, so the JavaScript is copied, but the dedicated server does not execute it.
|
|
84
|
+
|
|
85
|
+
## watch
|
|
86
|
+
|
|
87
|
+
`watch` rebuilds when anything under `src/` changes. If `dist/backend/index.js` exists after a successful build, the previous companion process is killed and a new one is started with the current environment. The secret has to already be in that environment.
|
|
88
|
+
|
|
89
|
+
## dev
|
|
90
|
+
|
|
91
|
+
`dev` is `watch` plus Vite. It looks for `node_modules/vite/bin/vite.js` in `ui/` and then in `src/webui/`. The dev server binds `127.0.0.1:5173`. That address is the computer running Vite. In a real session that is the player's PC, not the dedicated server.
|
|
92
|
+
|
|
93
|
+
## validate
|
|
94
|
+
|
|
95
|
+
`validate` checks that every `client_script`, `server_script`, `file`, and `web_file` in `open77.lua` exists, that both Lua bundles parse, that the bundle does not fall back to the global `require`, and that the native scan still matches the catalogue. It does not typecheck TypeScript. Run `build` first.
|
|
96
|
+
|
|
97
|
+
## doctor
|
|
98
|
+
|
|
99
|
+
`doctor` prints `ok`, `warn`, or `fail` lines:
|
|
100
|
+
|
|
101
|
+
- Node version
|
|
102
|
+
- `typescript-to-lua` installed
|
|
103
|
+
- Catalogue present, with its build and counts
|
|
104
|
+
- A warning that the server binary may be newer than the catalogue
|
|
105
|
+
- Resource name, directory name, client entry, server entry, backend entry, and target list
|
|
106
|
+
- `serverResourcesDir` when it is set
|
|
107
|
+
|
|
108
|
+
Exit code 1 means at least one `fail` line.
|
|
109
|
+
|
|
110
|
+
## map
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npx open77-ts map examples/hello_world/dist/server/main.lua 120
|
|
114
|
+
npx open77-ts map examples/hello_world/dist/server/main.lua 120 4
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Reads the `.map` beside the Lua file and prints a TypeScript file and line. Column 0 often has no mapping, so the tool also tries columns 0, 1, 2, 4, 8, and 16. The game cannot do this. `debug.traceback` is not in the sandbox, and `sourceMapTraceback` is off.
|
|
118
|
+
|
|
119
|
+
## types
|
|
120
|
+
|
|
121
|
+
Regenerates declarations from the Devkit index. Same as `npm run generate`.
|
|
122
|
+
|
|
123
|
+
## What the CLI does not do
|
|
124
|
+
|
|
125
|
+
It does not join a server, send `reload`, or open Cyberpunk 2077. Reloading a resource is a console command on that server.
|