fiverunner 0.9.0 → 1.2.0

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/README.md CHANGED
@@ -1,27 +1,58 @@
1
1
  <p align="center">
2
- <img src="src/dev/public/logo.svg" alt="" width="96" height="96">
2
+ <a href="https://dariushq.github.io/fiverunner/"><picture><source media="(prefers-reduced-motion: reduce)" srcset="https://raw.githubusercontent.com/DariusHQ/fiverunner/main/docs/media/banner.png"><img src="docs/media/banner.gif" alt="FiveRunner, your FiveM server in a browser tab: npx fiverunner dev starts a city in a browser, where the cash of a player goes to her bank and back, her phone tells her of it, and a car leaves the garage" width="100%"></picture></a>
3
3
  </p>
4
4
 
5
- <h1 align="center">FiveRunner</h1>
6
-
7
5
  <p align="center">Run FiveM resources in your browser and in CI.<br>No GTA V, no FXServer, no restarts.</p>
8
6
 
9
- > **Status:** early development. `npx fiverunner test` runs the Lua tests of FiveM resources in Node, and `npx fiverunner dev` runs resources and their NUI in your browser. Watch the repository to follow along.
7
+ <p align="center">
8
+ <a href="https://dariushq.github.io/fiverunner/"><img src="docs/media/playground.svg" alt="Playground: try it online"></a>
9
+ <a href="https://www.npmjs.com/package/fiverunner"><img src="https://img.shields.io/npm/v/fiverunner" alt="Version on npm"></a>
10
+ <a href="https://github.com/DariusHQ/fiverunner/actions/workflows/ci.yml"><img src="https://github.com/DariusHQ/fiverunner/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
11
+ <a href="https://github.com/DariusHQ/fiverunner/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/fiverunner" alt="License"></a>
12
+ </p>
10
13
 
11
- ![The appearance editor of illenium-appearance on the screen of a player, over a cartoon meadow where her little character wears what the editor picks](docs/media/appearance.png)
14
+ > Where a resource behaves differently than in FiveM, [tell us](https://github.com/DariusHQ/fiverunner/issues/new/choose).
12
15
 
13
- **[Watch the demo](https://github.com/DariusHQ/fiverunner/releases/download/v0.9.0/fiverunner.mp4)** (122 seconds, with sound): the whole Stable recipe of Qbox for txAdmin, tested, then in the dev UI, where a player registers a character, dresses her in illenium-appearance, opens ox_inventory and the bank of Renewed-Banking, and is dragged across the map to a garage, where she takes her car out.
16
+ ## Quick start
17
+
18
+ **[Try it in your browser](https://dariushq.github.io/fiverunner/)**, with nothing to install: a small city, in Lua and JavaScript, that runs in the page. Edit its files, press Run, and walk around it. Or run [a resource of GitHub](#resources-of-github-in-your-browser) in it.
19
+
20
+ On your machine, with Node 22 or later, in the folder of a resource or of a server, the one with `server.cfg` and `resources`:
14
21
 
15
22
  ```bash
16
- npx fiverunner test
17
23
  npx fiverunner dev
18
24
  ```
19
25
 
20
- - **Real resources, as they are released.** The 43 resources of the Stable recipe of Qbox start on your machine in seconds: its core, its inventory, its garages, its bank.
21
- - **Real NUIs.** Your pages run in a browser, and talk to your callbacks as they do in FiveM: the appearance editor, the inventory and the bank of the recipe work as players use them.
26
+ Open the address that it prints, connect a player, and click through your NUI, as your files change. A script that needs a framework runs in the folder of its server, next to the framework. To test it on every push, add a test and a GitHub workflow, then run it:
27
+
28
+ ```bash
29
+ npx fiverunner init
30
+ npx fiverunner test
31
+ ```
32
+
33
+ **[Watch the demo](https://github.com/DariusHQ/fiverunner/releases/download/v0.9.0/fiverunner.mp4)** (122 seconds, with sound): the whole Stable recipe of Qbox for txAdmin, tested, then in the dev UI, where a player registers a character, dresses her in illenium-appearance, opens ox_inventory and the bank of Renewed-Banking, and is dragged across the map to a garage, where she takes her car out.
34
+
35
+ ![The appearance editor of illenium-appearance on the screen of a player, over a cartoon meadow where her little character wears what the editor picks](docs/media/appearance.png)
36
+
37
+ - **Real resources, as they are released.** The 43 resources of the Stable recipe of Qbox start on your machine in seconds: its core, its inventory, its garages, its bank, and its phone, which is JavaScript.
38
+ - **Real NUIs.** Your pages run in a browser, and talk to your callbacks as they do in FiveM: the appearance editor, the inventory, the bank and the phone of the recipe work as players use them.
22
39
  - **Tests in CI.** Each test gets a server of its own, players, and a database in memory, and time moves as fast as it can.
23
40
  - **A world to look at.** Under the frames of NUI, the screen of each player shows the world round their ped, as a cartoon or in the style of GTA V, and the cartoon dresses them as your scripts do.
24
41
 
42
+ ## Resources of GitHub, in your browser
43
+
44
+ The playground runs the resources and servers of GitHub too, which `?gh=` and the name of a repository after its address name, such as [overextended/ox_target](https://dariushq.github.io/fiverunner/?gh=overextended/ox_target), [qbcore-fivem/qb-core](https://dariushq.github.io/fiverunner/?gh=qbcore-fivem/qb-core) or [Qbox-project/qbx_core](https://dariushq.github.io/fiverunner/?gh=Qbox-project/qbx_core), with `@` and a branch or a tag after the name, and the directory of a resource after a slash. It reads them from GitHub with the resources that they need, as far as it knows where those are: ox_lib, ox_target and ox_inventory, qb-core, qb-target, qb-weapons, qb-menu and qb-input, qbx_core and qbx_vehicles, es_extended and the tables of ESX, and PolyZone. A link brings others with `&with=owner/repo`.
45
+
46
+ Put its button in the README of your resource, and people run it with a click:
47
+
48
+ [![Run in FiveRunner](https://dariushq.github.io/fiverunner/badge.svg)](https://dariushq.github.io/fiverunner/?gh=overextended/ox_target)
49
+
50
+ ```markdown
51
+ [![Run in FiveRunner](https://dariushq.github.io/fiverunner/badge.svg)](https://dariushq.github.io/fiverunner/?gh=owner/repo)
52
+ ```
53
+
54
+ The playground gives the Markdown of the button of each repository that it runs. [docs/differences.md](docs/differences.md#the-playground) tells what it leaves out.
55
+
25
56
  ## Testing resources
26
57
 
27
58
  Start with a test that your resource or server starts without script errors, and a GitHub workflow that runs it on each push:
@@ -50,7 +81,7 @@ npx fiverunner test
50
81
 
51
82
  ![The tests of QBox, passing in a terminal](docs/media/tests.png)
52
83
 
53
- Each test gets a server of its own, with your resources started, and players whose clients run your client scripts. Resources that use oxmysql get a database of their own, in memory, that speaks MariaDB's SQL and starts with the tables of your `.sql` files. Time moves as fast as it can, so tests that wait take no time. [docs/testing.md](docs/testing.md) tells all that tests can do, and [examples/bank](examples/bank) is a resource with tests.
84
+ Each test gets a server of its own, with your resources started, and players whose clients run your client scripts. Resources that use oxmysql get a database of their own, in memory, that speaks MariaDB's SQL and starts with the tables of your `.sql` files. Time moves as fast as it can, so tests that wait take no time. `--coverage` writes the lines of Lua that they ran, for lcov, and `--junit` a report for your CI. [docs/testing.md](docs/testing.md) tells all that tests can do, and [examples/bank](examples/bank) is a resource with tests.
54
85
 
55
86
  ## Developing resources
56
87
 
@@ -60,19 +91,25 @@ Run your project in your browser:
60
91
  npx fiverunner dev
61
92
  ```
62
93
 
63
- The dev UI has the console of your server, where you run commands, its resources, which you start, stop and restart, the events that the server and the players send each other, which you trigger too, its state bags, and a map of its entities and of the blips of the players, classic, as a cartoon or in the style of GTA V, where you drag players to move them. Connect players, whose clients run your client scripts, each with a screen that shows the frames of its NUI over the world round their ped: click through your pages, which talk to your callbacks as they do in FiveM. As you save files, the dev UI restarts the resources that they belong to, and the players stay. [docs/dev.md](docs/dev.md) tells all that it does.
94
+ The dev UI has the console of your server, where you run commands, its resources, which you start, stop and restart, the events that the server and the players send each other, which you trigger too, its state bags, an inspector of what each resource has and of the time it takes, with a box that runs code inside it, and a map of its entities and of the blips of the players, classic, as a cartoon or in the style of GTA V, where you drag players to move them. Connect players, whose clients run your client scripts, each with a screen that shows the frames of its NUI over the world round their ped: click through your pages, which talk to your callbacks as they do in FiveM, and walk or drive with W, A, S and D. As you save files, the dev UI restarts the resources that they belong to, and the players stay. [docs/dev.md](docs/dev.md) tells all that it does, and [examples/city](examples/city) is a small server to play it on: citizens move in through a card, buy food, take a car out, and write to each other on a phone in JavaScript.
64
95
 
65
96
  ![The Stable recipe of Qbox in the dev UI: the console of its server, the events that its player sent, its resources and state bags, and the map of its world](docs/media/dev-ui.png)
66
97
 
98
+ ![The inspector of the dev UI: the resources of the server, with the time that each takes, the exports, events and commands of Renewed-Banking, and the convars of the server](docs/media/inspector.png)
99
+
67
100
  ![The map of the dev UI in the style of the pause menu of GTA V: the blips that the resources of Qbox put on the map of a player, with its header, a legend and its buttons](docs/media/map-gta.png)
68
101
 
69
102
  ![The map of the dev UI as a cartoon: the blips of Qbox as the tokens of a board game, on a meadow with trees](docs/media/map-cartoon.png)
70
103
 
71
104
  ## Frameworks
72
105
 
73
- QBox and ESX run on FiveRunner: CI runs qbx_core, ox_lib, ox_inventory, qbx_vehicles and es_extended, as they are released, on every change, with players who log in, earn money, carry items, get jobs and are saved as they leave. [docs/compatibility.md](docs/compatibility.md) lists what passes.
106
+ QBCore, QBox and ESX run on FiveRunner: CI runs them, as they are released, on every change, with players who log in, earn money, carry items, get jobs and are saved as they leave. [docs/compatibility.md](docs/compatibility.md) lists what passes.
74
107
 
75
- So does the whole Stable recipe of Qbox for txAdmin, with its 43 resources: they start without errors but those of npwd, whose phone is JavaScript, which FiveRunner does not run. A player takes a car out of a garage of qbx_garages, picks clothes in illenium-appearance, and opens ox_inventory and the bank of Renewed-Banking, as [its tests](compat/qbox-stable/tests/recipe.test.lua) check, which CI runs on every change on all of its resources but npwd and screencapture.
108
+ The whole recipe of QBCore for txAdmin runs too, with its 72 resources, without errors. A player creates a character in qb-multicharacter, picks where to start in qb-spawn, gets dressed in qb-clothing, opens qb-inventory and qb-banking, and takes a car out of qb-garages, with what the database keeps of it, as [its tests](compat/qbcore/tests/qbcore.test.lua) check.
109
+
110
+ ![The first clothes of a character in qb-clothing, with the HUD of qb-hud, on the screen of a player, over a cartoon meadow by the apartment that she picked](docs/media/qbcore.png)
111
+
112
+ So does the whole Stable recipe of Qbox for txAdmin, with its 43 resources, without errors. A player takes a car out of a garage of qbx_garages, picks clothes in illenium-appearance, opens ox_inventory and the bank of Renewed-Banking, and keeps a contact in the phone of npwd, whose server is JavaScript that talks to the database with its own mysql2, as [its tests](compat/qbox-stable/tests/recipe.test.lua) check, which CI runs on every change.
76
113
 
77
114
  ![The character registration of QBox, from the NUI of ox_lib, on the screen of a player in the dev UI](docs/media/qbox-registration.png)
78
115
 
@@ -82,14 +119,14 @@ So does the whole Stable recipe of Qbox for txAdmin, with its 43 resources: they
82
119
 
83
120
  ![The bank of Renewed-Banking on the screen of a player, with her personal account and her balance](docs/media/bank.png)
84
121
 
85
- ## Planned
86
-
87
- - A playground in the browser, which runs resources without installing anything.
122
+ ![The phone of npwd, with its apps, on the screen of a player, over a cartoon meadow where her little character stands](docs/media/phone.png)
88
123
 
89
124
  ## How it works
90
125
 
91
126
  Your scripts run on CfxLua, the Lua 5.4 runtime FiveM ships, compiled to WebAssembly: the same syntax extensions, vectors and quaternions, `json` and `msgpack`. Each resource gets its own Lua state, one per side and per player, the same isolation FiveM gives you. On top of that, FiveRunner reimplements the Cfx scripting runtime: events with `source` and net-safety, exports, function references, state bags, threads and `Wait`, and the natives API.
92
127
 
128
+ JavaScript runs on QuickJS, compiled to WebAssembly too, in a context for each resource on each side, with the globals of FiveM's runtime: `on`, `emit`, `exports`, `setTick` and the natives by their names. Servers also give it what bundles ask of Node, such as `require`, `Buffer` and `fs`, and the drivers of MySQL that resources carry reach FiveRunner's database on its port.
129
+
93
130
  Servers also get FiveM's own `io` and `os` libraries, its VFS and file permissions, its HTTP client and server, its server variables and its console, and oxmysql, whose exports run on SQLite, which FiveRunner teaches MariaDB's SQL.
94
131
 
95
132
  ## Differences from FiveM
@@ -98,7 +135,15 @@ FiveRunner follows FiveM's Windows server and its clients down to their error me
98
135
 
99
136
  ## Clean room
100
137
 
101
- FiveRunner's scripting runtime is a clean-room implementation and contains no code from the FiveM platform. CfxLua and its libraries are open source; see [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). FiveRunner is not affiliated with or endorsed by Cfx.re, Rockstar Games or Take-Two Interactive.
138
+ FiveRunner's scripting runtime is a clean-room implementation and contains no code from the FiveM platform. CfxLua, QuickJS and their libraries are open source; see [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). FiveRunner is not affiliated with or endorsed by Cfx.re, Rockstar Games or Take-Two Interactive.
139
+
140
+ ## Contributing
141
+
142
+ Resources that behave differently than in FiveM help most. [CONTRIBUTING.md](CONTRIBUTING.md) tells how to report them, how to run FiveRunner from its source, and the rules of its clean room. [CHANGELOG.md](CHANGELOG.md) tells what each version brought.
143
+
144
+ ## Spread the word
145
+
146
+ If FiveRunner saves you a restart, star it on GitHub: the stars of a project are how other FiveM developers find it.
102
147
 
103
148
  ## License
104
149
 
@@ -8,7 +8,8 @@ Every script runtime also loads one Lua library, [lua-promises](#lua-promises).
8
8
  catalog of FiveM natives is generated from the
9
9
  [CitizenFX typings](#citizenfx-typings), and the types of the files NUI serves from the
10
10
  [mime](#mime) package. The database of FiveRunner's oxmysql is
11
- [SQLite](#sqlite-and-sqlite-wasm). The dev UI gives the pages of frames [jQuery](#jquery) at
11
+ [SQLite](#sqlite-and-sqlite-wasm), and JavaScript runs on
12
+ [QuickJS](#quickjs-and-quickjs-emscripten). The dev UI gives the pages of frames [jQuery](#jquery) at
12
13
  nui://game/ui/jquery.js, as FiveM's NUI does.
13
14
 
14
15
  ## Lua and LuaGLM
@@ -385,6 +386,66 @@ at the version pinned in [package.json](package.json). SQLite is in the
385
386
  [public domain](https://sqlite.org/copyright.html). The package is licensed under the
386
387
  Apache License, Version 2.0. The license text is at the end of this file.
387
388
 
389
+ ## QuickJS and quickjs-emscripten
390
+
391
+ `quickjs.wasm`, next to the built tool, and its copy among the assets of the dev UI, are
392
+ QuickJS compiled to WebAssembly, and the built tool and the dev UI bundle the JavaScript
393
+ that runs them, all from the npm packages
394
+ [@jitl/quickjs-wasmfile-release-sync](https://www.npmjs.com/package/@jitl/quickjs-wasmfile-release-sync),
395
+ [@jitl/quickjs-ffi-types](https://www.npmjs.com/package/@jitl/quickjs-ffi-types) and
396
+ [quickjs-emscripten-core](https://www.npmjs.com/package/quickjs-emscripten-core) at the
397
+ versions pinned in [package.json](package.json). MIT License.
398
+
399
+ ```text
400
+ quickjs-emscripten:
401
+ The MIT License
402
+
403
+ quickjs-emscripten copyright (c) 2019-2024 Jake Teton-Landis
404
+
405
+ Permission is hereby granted, free of charge, to any person obtaining a copy
406
+ of this software and associated documentation files (the "Software"), to deal
407
+ in the Software without restriction, including without limitation the rights
408
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
409
+ copies of the Software, and to permit persons to whom the Software is
410
+ furnished to do so, subject to the following conditions:
411
+
412
+ The above copyright notice and this permission notice shall be included in all
413
+ copies or substantial portions of the Software.
414
+
415
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
416
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
417
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
418
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
419
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
420
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
421
+ SOFTWARE.
422
+
423
+
424
+ quickjs:
425
+ QuickJS Javascript Engine
426
+
427
+ Copyright (c) 2017-2021 Fabrice Bellard
428
+ Copyright (c) 2017-2021 Charlie Gordon
429
+
430
+ Permission is hereby granted, free of charge, to any person obtaining a copy
431
+ of this software and associated documentation files (the "Software"), to deal
432
+ in the Software without restriction, including without limitation the rights
433
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
434
+ copies of the Software, and to permit persons to whom the Software is
435
+ furnished to do so, subject to the following conditions:
436
+
437
+ The above copyright notice and this permission notice shall be included in
438
+ all copies or substantial portions of the Software.
439
+
440
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
441
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
442
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
443
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
444
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
445
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
446
+ THE SOFTWARE.
447
+ ```
448
+
388
449
  ## Apache License 2.0
389
450
 
390
451
  ```text