Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions ...wasm_navdata_interface/.cargo/config.toml → .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[target.wasm32-wasi]
rustflags = [
"-Clink-arg=--export-table",
"-Clink-arg=--export=malloc",
"-Clink-arg=--export=free",
"-Clink-arg=-L/usr/lib/llvm-15/lib/clang/15.0.7/lib/wasi",
"-Clink-arg=-lclang_rt.builtins-wasm32"
]
[build]
[target.wasm32-wasi]
rustflags = [
"-Clink-arg=--export-table",
"-Clink-arg=--export=malloc",
"-Clink-arg=--export=free",
"-Clink-arg=-L/usr/lib/llvm-15/lib/clang/15.0.7/lib/wasi",
"-Clink-arg=-lclang_rt.builtins-wasm32"
]

[build]
target = "wasm32-wasi"
4 changes: 2 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
root: true,
ignorePatterns: [".eslintrc.js", "src/wasm_navdata_interface/", "msfstypes/"],
ignorePatterns: [".eslintrc.js", "src/wasm/", "msfstypes/"],
env: { browser: true, commonjs: true, es6: true },
plugins: ["@typescript-eslint"],
extends: [
Expand All @@ -11,7 +11,7 @@ module.exports = {
],
parserOptions: {
tsconfigRootDir: __dirname,
project: ["./examples/gauge/tsconfig.json"],
project: ["./tsconfig.json"],
ecmaVersion: 2022,
sourceType: "module",
ecmaFeatures: { jsx: true },
Expand Down
13 changes: 9 additions & 4 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Build WASM module
- name: create env file
run: |
./src/wasm_navdata_interface/scripts/run_docker_cmd.sh ./scripts/build.sh
touch .env
echo NAVDATA_SIGNED_URL=${{ secrets.NAVDATA_SIGNED_URL }} >> .env
- name: Build WASM module
run: npm run build:wasm-workflow
- name: Test
run: npm run test-workflow
- name: Upload WASM module to GitHub
uses: actions/upload-artifact@v2
with:
name: navdata_interface.wasm
path: ./src/wasm_navdata_interface/out/navdata_interface.wasm
name: msfs_navdata_interface.wasm
path: ./out/msfs_navdata_interface.wasm
5 changes: 2 additions & 3 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Build WASM module
run: |
./src/wasm_navdata_interface/scripts/run_docker_cmd.sh ./scripts/build.sh
run: npm run build:wasm-workflow
- name: Pre-Release
uses: softprops/action-gh-release@v1
with:
files: ./src/wasm_navdata_interface/out/navdata_interface.wasm
files: ./out/msfs_navdata_interface.wasm
prerelease: true
24 changes: 24 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on:
push:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: create env file
run: |
touch .env
echo NAVDATA_SIGNED_URL=${{ secrets.NAVDATA_SIGNED_URL }} >> .env
- name: Build WASM module
run: npm run build:wasm-workflow
- name: Test
run: npm run test-workflow
- name: Upload WASM module to GitHub
uses: actions/upload-artifact@v2
with:
name: msfs_navdata_interface.wasm
path: ./out/msfs_navdata_interface.wasm
5 changes: 2 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Build WASM module
run: |
./src/wasm_navdata_interface/scripts/run_docker_cmd.sh ./scripts/build.sh
run: npm run build:wasm-workflow
- name: Release
uses: softprops/action-gh-release@v1
with:
files: ./src/wasm_navdata_interface/out/navdata_interface.wasm
files: ./out/msfs_navdata_interface.wasm
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ _PackageInt
tsconfig.tsbuildinfo
.vs
examples/aircraft/PackageSources/html_ui/Pages/VCockpit/Instruments/Navigraph/NavdataInterfaceSample
examples/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navdata_Interface_Aircraft/panel/navdata_interface.wasm
src/wasm_navdata_interface/out
examples/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navdata_Interface_Aircraft/panel/msfs_navdata_interface.wasm
out

# Rust
# will have compiled files and executables
Expand All @@ -27,3 +27,5 @@ Cargo.lock
.env
*.local
.DS_Store

test_work/
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# @Navigraph/app-dev will be requested for
# review when someone opens a pull request.
* @pepperoni505
* @professoralex13
11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[workspace]
resolver = "2"

members = ["src/wasm"]

[profile.release]
lto = true
strip = true

[patch.crates-io]
rusqlite = { git = "https://github.com/navigraph/rusqlite", rev = "7921774" }
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ Here's an overview on the structure of this repository, which is designed to be
- `aircraft/` includes a base aircraft to test in the sim
- `gauge/` includes a very simple TypeScript instrument to communicate with the WASM module
- `src/`
- Contains the source for the navdata interface (and soon the JS library)
- `wasm_navdata_interface` includes the Rust source code for the WASM module
- `js` Includes source code for the JS interface for using the sdk
- `test` Includes code for testing the JS and Rust code using a Node runtime
- `wasm` includes the Rust source code for the WASM module which handles the database interface

## Including in Your Aircraft

Expand Down Expand Up @@ -44,7 +45,6 @@ Before building, make sure you have properly created and set an `.env` file in `
## Building the WASM Module Yourself

1. [Download](https://www.docker.com/products/docker-desktop/) Docker Desktop
2. Open the `src/wasm_navdata_interface` folder in a terminal
3. Run `.\build.bat` (must be on Windows)
2. Run `npm run build:wasm` (must be on Windows)
- This will take a while to download and build the first time, but subsequent runs will be quicker
4. The compiled WASM module will be copied to `src/wasm_navdata_interface/out` **and** `examples/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navdata_Interface_Aircraft/panel`
3. The compiled WASM module will be copied to `out` **and** `examples/aircraft/PackageSources/SimObjects/Airplanes/Navigraph_Navdata_Interface_Aircraft/panel`
9 changes: 9 additions & 0 deletions env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Add secret to global env

declare namespace NodeJS {
interface ProcessEnv {
// For test running
// Must be a client which supports password auth grants
NAVDATA_SIGNED_URL: string
}
}
2 changes: 1 addition & 1 deletion examples/gauge/Components/NavigraphLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CancelToken } from "navigraph/auth"
import { packages } from "../Lib/navigraph"
import { AuthService } from "../Services/AuthService"
import "./NavigraphLogin.css"
import { DownloadProgressPhase, NavigraphEventType, NavigraphNavdataInterface } from "@navigraph/navdata-sdk"
import { DownloadProgressPhase, NavigraphEventType, NavigraphNavdataInterface } from "msfs-navdata-interface"
import { Dropdown } from "./Dropdown"

interface NavigraphLoginProps extends ComponentProps {
Expand Down
2 changes: 1 addition & 1 deletion examples/gauge/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"rollup-plugin-import-css": "^3.3.5"
},
"dependencies": {
"@navigraph/navdata-sdk": "*",
"msfs-navdata-interface": "*",
"navigraph": "1.2.35"
}
}
9 changes: 9 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
testEnvironment: "node",
transform: {
"^.+\\.tsx?$": "ts-jest",
},
testRegex: "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$",
moduleFileExtensions: ["ts", "js", "json", "node"],
setupFilesAfterEnv: ["./src/test/setup.ts"],
}
Loading