{"id":19749990,"url":"https://github.com/b1naryth1ef/dcs-ts","last_synced_at":"2025-04-30T09:31:51.370Z","repository":{"id":44711219,"uuid":"448542899","full_name":"b1naryth1ef/dcs-ts","owner":"b1naryth1ef","description":"DCS-TS provides TypeScript support embedded within the Digital Combat Simulator Mission Scripting Environment","archived":false,"fork":false,"pushed_at":"2022-01-31T06:35:52.000Z","size":207,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-16T01:50:06.025Z","etag":null,"topics":["dcs","scripting","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/b1naryth1ef.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-16T12:07:59.000Z","updated_at":"2024-04-12T14:18:59.000Z","dependencies_parsed_at":"2022-09-11T20:21:09.828Z","dependency_job_id":null,"html_url":"https://github.com/b1naryth1ef/dcs-ts","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b1naryth1ef%2Fdcs-ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b1naryth1ef%2Fdcs-ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b1naryth1ef%2Fdcs-ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b1naryth1ef%2Fdcs-ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/b1naryth1ef","download_url":"https://codeload.github.com/b1naryth1ef/dcs-ts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224205810,"owners_count":17273350,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dcs","scripting","typescript"],"created_at":"2024-11-12T02:29:39.337Z","updated_at":"2024-11-12T02:29:39.985Z","avatar_url":"https://github.com/b1naryth1ef.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DCS-TS\n\nDCS-TS provides native Javascript scripting and TypeScript support within the\nDCS mission environment. DCS-TS is built using a native Lua module written in\nRust which embeds the [Deno](https://github.com/denoland/deno) runtime. User\nscripts run within a separate thread embedded within the DCS server, and\ncommunicate with the Lua mission scripting environment via asynchronous\nfunctions.\n\n## Features\n\n- **Deno Runtime** provides you with a modern and extremely powerful language\n  runtime.\n- **Custom TypeScript SDK** gives you a best-in-class editing experience with\n  editor tooling, type checking, auto-documentation, and more.\n- **Rich Debugging** allows you to diagnose and experiment at runtime via the\n  Chrome web inspector, attached _directly_ into your running DCS server.\n- **Reloading** reload your scripts as required, either for fast development or\n  to hotfix issues without disrupting players.\n\n## Examples\n\n- [catfacts.ts](/examples/catfacts.ts) adds a command to the in-game F10 menu\n  for receiving a random cat fact\n- [http.ts](/examples/http.ts) provides an example embedded http server which\n  interacts with the running DCS server\n- [scramble.ts](/examples/scramble.ts) scrambles AI aircraft when players reach\n  pre-defined distances from captured air-fields\n\n## Documentation\n\n- [Getting Started Guide](/docs/getting_started.md)\n- [SDK Patterns](/docs/sdk_patterns.md)\n- [FAQ](/docs/faq.md)\n\n## How\n\nDCS-TS is based off the work in\n[DCS-gRPC/rust-server](https://github.com/DCS-gRPC/rust-server), which supports\nembedding a rust DLL and associated functionality within the DCS Lua\nenvironment. Instead of using this to provide an external API surface like\nDCS-gRPC, DCS-TS embeds an instance of the Deno Javascript runtime (based on\nv8). To communicate between Lua and Deno DCS-TS implements \"tasks\" which are\nasynchronous Lua function calls made from Javascript, and \"channels\" which\nprovide one-ended communication either from or too the Lua environment.\n\nOn top of these abstractions and Deno a TypeScript SDK is provided which allows\ntype-safe and clearly documented interaction with the DCS MSE functionality.\n\n### Performance\n\nThe Deno runtime within DCS-TS is ran via a separate system thread and utilizes\npolling from Lua to process pending tasks and channel messages. This results in\nquite good performance, and allows you to off-load a lot of processing and logic\nfrom the DCS engine itself. Unfortunately this comes with a caveat based on\nlimitations within the DCS engine itself. The scheduled function feature within\nthe MSE is quite inaccurate and will regularly experience hitches of 10-40ms.\nThis means some thought must be taken when designing abstractions which you want\nto perform quickly:\n\n```typescript\n// This will perform badly, as the await calls are lineally sequenced.\nconst updatedUnits = [];\nfor (const unit of units) {\n  updatedUnits.push(await getUnit(unit));\n}\n\n// using Promise.all we can ensure operations into the scripting environment get\n//  batched efficiently\nconst updatedUnits = await Promise.all(units.map((it) =\u003e getUnit(it)));\n```\n\n### Safety\n\nDCS-TS is written in rust and when possible attempts to avoid potential program\ncrashes. Additionally Lua itself guards against program faults when calling into\nremote DLLs, which prevents the DCS server from crashing if there is a bug in\nDCS-TS.\n\n## Installation\n\n1. Download the latest release and unpack the zip somewhere on your local disk,\n   it should contain two files `ts-init.lua` and `dcs_ts.dll`.\n2. Edit the `Scripts\\MissionScripting.lua` file contained within your DCS server\n   **data** directory, generally this is in `Saved Games\\DCS.openbeta_server`:\n\n```diff\ndofile('Scripts/ScriptingSystem.lua')\n+  dofile([[C:\\Users\\dcs\\Documents\\dcs-ts\\ts-init.lua]])\n```\n\n3. Create a configuration file at `Config/ts.json` within your DCS server\n   **data** directory:\n\n```javascript\n{\n  // whether to enable development features like the inspector server\n  \"development\": true,\n\n  // whether to enable debug logging\n  \"debugging\": true,\n\n  // optionally we can provide the path to the bundled sdk we're using, which will\n  //  export all the available functions for use within the chrome inspector.\n  \"sdk_path\": \"C:\\\\Users\\\\dcs\\\\Documents\\\\build\\\\sdk.js\",\n\n  // path to scripts that will be loaded on initialization\n  \"scripts\": [\n    \"C:\\\\Users\\\\dcs\\\\Documents\\\\dcs-ts\\\\build\\\\project.js\"\n  ]\n}\n```\n\n## Development\n\nTo configure your development environment simply clone the repository and create\na link from the `res/dcs_ts.dll` directory pointing at\n`target/debug/dcs_ts.dll`. Then follow the normal installation procedure with\nthe `ts-init.lua` file contained in `res/`. You will need to shutdown DCS when\nrebuilding the DLL.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb1naryth1ef%2Fdcs-ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fb1naryth1ef%2Fdcs-ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb1naryth1ef%2Fdcs-ts/lists"}