@thigasdevelopment/luam 0.1.1 → 0.2.1

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.
Files changed (3) hide show
  1. package/README.md +160 -31
  2. package/luam.mjs +3333 -1548
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -4,6 +4,12 @@
4
4
 
5
5
  <p align="center">Typed Lua for Multi Theft Auto. Compiles to plain Lua 5.1.</p>
6
6
 
7
+ <p align="center">
8
+ <a href="https://thigasdevelopment.github.io/luam/"><b>Manual</b></a> ·
9
+ <a href="https://thigasdevelopment.github.io/luam/en/">English</a> ·
10
+ <a href="https://thigasdevelopment.github.io/luam/pt-br/">Português (Brasil)</a>
11
+ </p>
12
+
7
13
  <p align="center">
8
14
  <a href="https://www.npmjs.com/package/@thigasdevelopment/luam"><img alt="npm" src="https://img.shields.io/npm/v/@thigasdevelopment/luam?color=cb3837&label=npm"></a>
9
15
  <img alt="Target" src="https://img.shields.io/badge/target-Lua%205.1-000080">
@@ -38,6 +44,10 @@ before the server ever starts. A build with any error writes nothing.
38
44
 
39
45
  ## Install
40
46
 
47
+ > Full instructions, including `PATH` troubleshooting:
48
+ > **[Installation](https://thigasdevelopment.github.io/luam/en/guide/installation)**
49
+ > · [Instalação](https://thigasdevelopment.github.io/luam/pt-br/guide/installation)
50
+
41
51
  You need [Node.js](https://nodejs.org/) 20 or newer and an
42
52
  [MTA:SA](https://multitheftauto.com/) 1.5+ server. No Lua toolchain — the
43
53
  compiler emits Lua text, it never runs it.
@@ -114,12 +124,29 @@ bin directory is not on your `PATH`.
114
124
 
115
125
  The VS Code extension gives you types, completion and errors while you type —
116
126
  from the same checker the CLI runs, so the editor and the build never disagree.
117
- See [Editor support](#editor-support) below for how to install it.
127
+ Let the CLI detect supported editors and ask before changing each one:
128
+
129
+ ```bash
130
+ luam setup
131
+ ```
132
+
133
+ For an unattended development-machine setup, approve every detected editor:
134
+
135
+ ```bash
136
+ luam setup --yes
137
+ ```
138
+
139
+ Run `luam doctor` afterward to check the CLI, detected editors, and extension.
140
+ See [Editor support](#editor-support) for the compatibility matrix and manual installation.
118
141
 
119
142
  ---
120
143
 
121
144
  ## Quick start
122
145
 
146
+ > Step by step, with a checked example:
147
+ > **[Quick start](https://thigasdevelopment.github.io/luam/en/guide/quick-start)**
148
+ > · [Início rápido](https://thigasdevelopment.github.io/luam/pt-br/guide/quick-start)
149
+
123
150
  **1. Scaffold.** `init` writes exactly one file, `luam.json`. No framework, no
124
151
  example tree, nothing to delete.
125
152
 
@@ -203,8 +230,12 @@ luam dev
203
230
 
204
231
  ## The CLI
205
232
 
206
- Five commands. Every one of them reads `luam.json` from the current directory,
207
- or from `--cwd`.
233
+ > Every command, option and exit code:
234
+ > **[CLI commands](https://thigasdevelopment.github.io/luam/en/tooling/cli)**
235
+ > · [Comandos da CLI](https://thigasdevelopment.github.io/luam/pt-br/tooling/cli)
236
+
237
+ Project commands read `luam.json` from the current directory or from `--cwd`.
238
+ `setup`, `doctor`, and `init` do not require an existing project.
208
239
 
209
240
  ### `luam init`
210
241
 
@@ -217,6 +248,29 @@ luam init --name gamemode-race
217
248
 
218
249
  An existing `luam.json` is kept and reported — pass `--force` to overwrite it.
219
250
 
251
+ ### `luam setup`
252
+
253
+ Detects supported editor commands on `PATH`, asks for consent, and installs the
254
+ Luam extension. It tries the editor's marketplace first and falls back to the
255
+ official `.vsix` from the GitHub release that matches the CLI version.
256
+
257
+ ```bash
258
+ luam setup
259
+ luam setup --yes
260
+ ```
261
+
262
+ The command never installs into an editor silently. In CI or another
263
+ non-interactive terminal, pass `--yes` explicitly.
264
+
265
+ ### `luam doctor`
266
+
267
+ Reports the running CLI and Node.js versions, every supported editor detected
268
+ on `PATH`, and whether that editor has the Luam extension.
269
+
270
+ ```bash
271
+ luam doctor
272
+ ```
273
+
220
274
  ### `luam check`
221
275
 
222
276
  Compiles everything and prints diagnostics. **Writes nothing.** This is the
@@ -233,7 +287,9 @@ Build failed: 1 error, 0 warnings in 4 ms.
233
287
 
234
288
  ### `luam build`
235
289
 
236
- Compiles and writes the resource into `<outDir>/<name>`.
290
+ Compiles and writes the bundled production resource into `<outDir>/<name>`, plus
291
+ `<outDir>/<name>.luam-map.json` for resolving production error positions. Pass
292
+ `--no-bundle` for tree output or `--no-map` to suppress the map.
237
293
 
238
294
  ```bash
239
295
  luam build
@@ -337,6 +393,9 @@ a deploy script wants.
337
393
  | `--name <name>` | Resource name for `init` |
338
394
  | `--force` | Let `init` overwrite a file that exists |
339
395
  | `--watch` / `--no-watch` | Keep `ensure` or `dev` watching, or run it once. Both watch by default |
396
+ | `--bundle` / `--no-bundle` | Select bundle or tree output for `build` and `ensure`; `dev` always uses tree |
397
+ | `--no-map` | Disable source position maps |
398
+ | `--map <path>` | Select the resource map for `luam trace` |
340
399
  | `--offline` | Skip the `min_mta_version` lookup. `LUAM_OFFLINE` does the same |
341
400
  | `--no-color` | Plain output, no colour or emoji. `NO_COLOR` does the same |
342
401
  | `-h`, `--help` | Print the usage text |
@@ -364,6 +423,8 @@ Only `name` is required.
364
423
  | `assetDirs` | `["assets"]` | Copied verbatim and declared `<file>`, so clients download them |
365
424
  | `outDir` | `"build"` | Receives `<outDir>/<name>` |
366
425
  | `loadOrder` | `[]` | Source paths pinned ahead of their group in `meta.xml`. An entry matching no file fails the build |
426
+ | `output.bundle` | `true` | Default `build` layout; command flags override it |
427
+ | `output.map` | `true` | Generate source position maps; only `build` writes one to disk |
367
428
  | `oop` | `false` | Enables the MTA OOP API (`player:getName()`) and writes `<oop>true</oop>` |
368
429
  | `helpers` | `[]` | Runtime helpers to copy even when no feature requires them |
369
430
  | `serverPath` | unset | MTA server root, for `ensure` |
@@ -375,12 +436,20 @@ Paths must stay inside their base directory — an absolute path or a `..` segme
375
436
  is rejected.
376
437
 
377
438
  Every field, the transport in detail, `.env` handling and declaration files:
378
- **[`packages/cli/README.md`](packages/cli/README.md)**.
439
+ **[luam.json](https://thigasdevelopment.github.io/luam/en/tooling/luam-json)**
440
+ and
441
+ [Configuration fields](https://thigasdevelopment.github.io/luam/en/reference/configuration-fields)
442
+ · [luam.json](https://thigasdevelopment.github.io/luam/pt-br/tooling/luam-json)
443
+ · also in [`packages/cli/README.md`](packages/cli/README.md).
379
444
 
380
445
  ---
381
446
 
382
447
  ## The language
383
448
 
449
+ > Every feature, with emitted Lua and the errors it catches:
450
+ > **[The language](https://thigasdevelopment.github.io/luam/en/language/)**
451
+ > · [A linguagem](https://thigasdevelopment.github.io/luam/pt-br/language/)
452
+
384
453
  ```lua
385
454
  local name: string = 'Thigas'
386
455
  local player: Player? = nil # optional
@@ -424,13 +493,18 @@ local vip = new VIPPlayer('Thigas', 2)
424
493
  | `export` | Erased from the Lua, written into `meta.xml` as `<export function="f" />` |
425
494
  | Native libraries | `sleep` plus the `Threads`, `Async` and `Dotenv` classes, injected only when named |
426
495
  | Native classes | `local tasks = new Async(100)` — same `new` as a project class |
496
+ | MTA OOP classes | `Player.getRandom()`, `File.exists(path)`, and callable constructors such as `File(path)` |
427
497
  | Deployment values | `.env` keys typed and reachable as `env.SERVER_NAME`, server-only |
428
498
  | Strictness | `#!strict` (default), `#!nonstrict`, `#!nocheck` per file |
429
499
 
430
- `class`, `interface`, `enum`, `new`, `fun` and `export` are contextual keywords —
431
- existing Lua that uses them as identifiers keeps compiling. Reach for
432
- `#!nocheck` when porting existing Lua: rename to `.luam` and the build passes
433
- while you annotate module by module.
500
+ `class`, `constructor`, `declare`, `enum`, `export`, `extends`, `implements`,
501
+ `interface`, `new` and `type` are **reserved**, on top of the 21 Lua 5.1
502
+ keywords. Existing Lua that uses one as an identifier needs a rename — but a
503
+ property name still works (`config.type`), and `type(value)` keeps working
504
+ because `type` stays callable. `fun` is the one term that stays contextual.
505
+
506
+ Reach for `#!nocheck` when porting existing Lua: rename to `.luam` and the build
507
+ passes while you annotate module by module.
434
508
 
435
509
  ### Environments
436
510
 
@@ -451,31 +525,38 @@ a build.
451
525
 
452
526
  The catalog ships **1294 MTA declarations**, **203 events**, **57 element types**
453
527
  and the Lua standard library, generated from the MTA wiki — plus the OOP surface
454
- (**57 classes, 652 methods**) behind `"oop": true`.
528
+ (**57 classes, 652 methods, 118 static methods, 46 constructors**) behind
529
+ `"oop": true`.
530
+
531
+ `File(path)` opens an existing file read/write and creates it when missing.
532
+ Use `File.new(path)` only for destructive creation because it truncates an
533
+ existing file. Use `fileOpen(path, true)` when read-only access is required.
455
534
 
456
535
  ---
457
536
 
458
537
  ## What you get out
459
538
 
460
539
  ```
461
- build/my-resource/
462
- ├── meta.xml generated: scripts typed by environment, helpers first
463
- ├── config.lua copied verbatim, yours to edit
464
- ├── .env written once, never overwritten
465
- ├── lib/shared/class.lua
466
- └── src/
467
- ├── shared/config.lua
468
- ├── server/main.lua
469
- └── client/hud.lua
540
+ build/
541
+ ├── my-resource.luam-map.json
542
+ └── my-resource/
543
+ ├── meta.xml
544
+ ├── config.lua
545
+ ├── .env
546
+ ├── assets/
547
+ └── src/
548
+ ├── shared.lua
549
+ ├── server.lua
550
+ └── client.lua
470
551
  ```
471
552
 
472
- The output mirrors the tree you authored, changing only the extension, so a path
473
- in an MTA error maps straight back to a source file. Runtime helpers land in
474
- `lib/<environment>` and are copied **only when the generated code uses the
475
- feature** a resource with no classes never carries `class.lua`.
553
+ `build` ships at most one bundle per non-empty environment. `config.lua`, `.env`,
554
+ and assets remain unbundled at their stable paths, and the map remains outside
555
+ the resource. `ensure` defaults to a mirrored tree and `dev` always uses one.
556
+ Use `luam trace src/server.lua:42` with the matching map to recover the authored
557
+ file, line, and symbol. See [output layouts and source maps](https://thigasdevelopment.github.io/luam/en/reference/output-layouts).
476
558
 
477
- `meta.xml` uses one wildcard per environment, so adding a module leaves it byte
478
- identical. `min_mta_version` is resolved from the latest MTA release and cached;
559
+ `min_mta_version` is resolved from the latest MTA release and cached;
479
560
  with no network and no cache it is omitted with a warning, and the build still
480
561
  succeeds.
481
562
 
@@ -483,6 +564,10 @@ succeeds.
483
564
 
484
565
  ## Editor support
485
566
 
567
+ > Compatibility matrix, manual `.vsix` install, settings:
568
+ > **[Editors](https://thigasdevelopment.github.io/luam/en/tooling/editors)**
569
+ > · [Editores](https://thigasdevelopment.github.io/luam/pt-br/tooling/editors)
570
+
486
571
  The **Luam** extension for VS Code starts a language server built on the same
487
572
  frontend the CLI uses, so the editor and the build never disagree about a file.
488
573
 
@@ -491,7 +576,7 @@ frontend the CLI uses, so the editor and the build never disagree about a file.
491
576
  | Syntax highlighting | `.luam` files, including type annotations and template strings |
492
577
  | Diagnostics | On open and on every keystroke, cleared when you fix the file |
493
578
  | Completion | Scope symbols, workspace globals, MTA APIs scoped to the file's environment, keywords |
494
- | Member completion | `.` and `:` complete class fields and methods (inherited too), enum members, and native extensions |
579
+ | Member completion | `.` completes fields and static methods; `:` completes instance methods, including inherited MTA members |
495
580
  | Hover | Declared or inferred type, function signature, and the environment of an MTA API |
496
581
  | Navigation | Go to definition, find references, rename — across files for globals |
497
582
 
@@ -500,17 +585,40 @@ server file, `kickPlayer` never appears in a client file.
500
585
 
501
586
  ### Installing it
502
587
 
503
- The extension is not on the Marketplace yet, so install the `.vsix` by hand.
588
+ **Through the CLI (recommended).** The command detects all supported editors
589
+ whose launchers are on `PATH` and asks before installing:
504
590
 
505
- **From a release (easiest).** Download `luam-<version>.vsix` from the
506
- [Releases page](https://github.com/ThigasDevelopment/luam/releases), then:
591
+ ```bash
592
+ luam setup
593
+ ```
594
+
595
+ | Editor | Launcher detected | Automatic installation | Distribution path |
596
+ | --- | --- | --- | --- |
597
+ | Visual Studio Code | `code` | Yes | Marketplace, then release `.vsix` fallback |
598
+ | Visual Studio Code Insiders | `code-insiders` | Yes | Marketplace, then release `.vsix` fallback |
599
+ | Cursor | `cursor` | Yes | Editor marketplace, then release `.vsix` fallback |
600
+ | VSCodium | `codium` | Yes | Open VSX when available, then release `.vsix` fallback |
601
+ | Windsurf | `windsurf` | Yes | Editor marketplace, then release `.vsix` fallback |
602
+
603
+ Other VS Code-compatible forks can usually install the release `.vsix`
604
+ manually, but `luam setup` does not claim support until their launcher and
605
+ extension APIs are stable. JetBrains IDEs need a separate plugin and are not
606
+ supported by this VS Code extension. Neovim, Zed, and Sublime Text need their
607
+ own LSP adapter or extension and are not currently supported.
608
+
609
+ **From a release.** Download `luam-<version>.vsix` from the
610
+ [Releases page](https://github.com/ThigasDevelopment/luam/releases), then use
611
+ the launcher for your editor:
507
612
 
508
613
  ```bash
509
614
  code --install-extension luam-0.1.1.vsix
615
+ cursor --install-extension luam-0.1.1.vsix
616
+ codium --install-extension luam-0.1.1.vsix
617
+ windsurf --install-extension luam-0.1.1.vsix
510
618
  ```
511
619
 
512
- Or in VS Code: **Extensions** **⋯** menu **Install from VSIX…** → pick the
513
- file. Reload the window when it asks.
620
+ In a compatible editor, you can also open **Extensions**, choose **Install from
621
+ VSIX**, and select the downloaded file. Reload the window when prompted.
514
622
 
515
623
  **From source.** Build the VSIX yourself:
516
624
 
@@ -561,6 +669,10 @@ node packages/lsp/dist/luam-lsp.mjs --stdio
561
669
 
562
670
  ## Known limitations
563
671
 
672
+ > With the workaround for each:
673
+ > **[Limitations](https://thigasdevelopment.github.io/luam/en/reference/limitations)**
674
+ > · [Limitações](https://thigasdevelopment.github.io/luam/pt-br/reference/limitations)
675
+
564
676
  - **No type narrowing.** `if value ~= nil then` does not refine `string?`.
565
677
  - **Declaration order matters for classes within a file.** `extends` and `new`
566
678
  resolve against classes declared earlier in the same file.
@@ -598,6 +710,23 @@ Each package documents itself: [`cli`](packages/cli/README.md),
598
710
  [`template`](packages/template/README.md). Released milestones and their changes
599
711
  are in the [changelog](CHANGELOG.md).
600
712
 
713
+ ### The manual
714
+
715
+ The user-facing manual lives in [`docs/`](docs/) and is published to
716
+ [thigasdevelopment.github.io/luam](https://thigasdevelopment.github.io/luam/).
717
+
718
+ ```bash
719
+ pnpm docs:dev # local preview with hot reload
720
+ pnpm docs:verify # locale parity, snippet checks, and a full build
721
+ ```
722
+
723
+ English is the source locale and pt-BR is translated from it; every page exists in
724
+ both, and CI fails when one is missing. Code samples are real files under
725
+ `docs/snippets/`, verified with `luam check` on every documentation build, and
726
+ rendered into both locales from the same source — so a sample cannot drift. See
727
+ the [documentation changelog](https://thigasdevelopment.github.io/luam/en/changelog)
728
+ for the conventions.
729
+
601
730
  ---
602
731
 
603
732
  ## Acknowledgments