Initial commit

This commit is contained in:
karniv00l 2021-09-26 14:21:51 +02:00
commit c7e929ae71
No known key found for this signature in database
GPG Key ID: F40F61D5587F5673
14 changed files with 5150 additions and 0 deletions

10
.editorconfig Normal file
View File

@ -0,0 +1,10 @@
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2

1
.eslintignore Normal file
View File

@ -0,0 +1 @@
/dist

50
.eslintrc.yml Normal file
View File

@ -0,0 +1,50 @@
---
parser: '@typescript-eslint/parser'
env:
node: true
es6: true
settings:
import/resolver:
node:
extensions:
- ".js"
- ".ts"
extends:
- eslint:recommended
- prettier
- plugin:import/errors
- plugin:import/warnings
- plugin:import/typescript
plugins:
- '@typescript-eslint'
- prettier
- modules-newline
rules:
indent: [2, 2, { "SwitchCase": 1 }]
semi:
- error
- always
comma-dangle:
- error
- always-multiline
import/extensions: 0
object-curly-spacing:
- error
- always
object-curly-newline: [1, {
"ImportDeclaration": { "multiline": true, "minProperties": 2 },
"ExportDeclaration": { "multiline": true, "minProperties": 1 }
}]
modules-newline/import-declaration-newline: 1
modules-newline/export-declaration-newline: 1
quotes:
- error
- single
no-console: 0
no-plusplus: 0
import/no-extraneous-dependencies: 0
no-undef: 1
no-unused-vars: 0
'@typescript-eslint/no-unused-vars': 1
no-shadow: 0
'@typescript-eslint/no-shadow': 2

11
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"

30
.github/workflows/lint.js.yml vendored Normal file
View File

@ -0,0 +1,30 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Lint code
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
env:
CI: true
strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm i
- run: npm run lint

18
.gitignore vendored Normal file
View File

@ -0,0 +1,18 @@
# dependencies
node_modules
# testing
/coverage
# production
/build
/dist
# misc
.DS_Store
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.eslintcache

1
.npmignore Normal file
View File

@ -0,0 +1 @@
/build

15
README.md Normal file
View File

@ -0,0 +1,15 @@
# 📦 SpeedyTuner common TypeScript types
## Installation
Make sure you have registry specified in the `.npmrc` file:
```bash
@speedy-tuner:registry=https://npm.pkg.github.com
```
Proceed with the installation:
```bash
npm i --save @speedy-tuner/types
```

4710
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

33
package.json Normal file
View File

@ -0,0 +1,33 @@
{
"name": "@speedy-tuner/types",
"description": "SpeedyTuner common TypeScript types",
"version": "0.1.0",
"private": true,
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/speedy-tuner/types"
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsc",
"prepublishOnly": "npm run build",
"start": "tsc --watch",
"lint": "tsc && eslint --max-warnings=0 src/*"
},
"devDependencies": {
"@types/node": "^16.9.1",
"@typescript-eslint/eslint-plugin": "^4.31.0",
"@typescript-eslint/parser": "^4.31.0",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.24.1",
"eslint-plugin-modules-newline": "^0.0.6",
"eslint-plugin-prettier": "^4.0.0",
"typescript": "^4.4.3"
}
}

211
src/config.ts Normal file
View File

@ -0,0 +1,211 @@
export enum Switches {
YES = 'Yes',
NO = 'No',
ON = 'On',
OFF = 'Off',
}
export interface Field {
title: string;
name: string;
condition?: string;
}
export interface Panel {
layout: string;
panels?: {
[name: string]: Panel;
};
fields?: Field[];
condition?: string;
}
export interface Dialog {
title: string;
layout: string;
help?: string;
panels: {
[name: string]: Panel;
};
fields: Field[];
// TODO:
// settingSelector
// commandButton
}
export interface Dialogs {
[name: string]: Dialog;
}
export interface SubMenu {
title: string;
page: number;
condition: string;
}
export interface Menu {
title: string;
subMenus: {
[name: string]: SubMenu;
};
}
export interface Menus {
[name: string]: Menu;
}
export interface ArrayShape {
columns: number;
rows: number;
}
export enum ConstantTypes {
SCALAR = 'scalar',
BITS = 'bits',
ARRAY = 'array',
STRING = 'string',
}
export type ConstantSize = 'U08' | 'S08' | 'U16' | 'S16' | 'U32' | 'S32' | 'S64' | 'F32' | 'ASCII';
export interface ScalarConstant {
type: ConstantTypes.SCALAR;
size: ConstantSize;
offset?: number;
units: string;
scale: number | string;
transform: number | string;
min: number | string;
max: number | string;
digits: number;
}
export interface BitsConstant {
type: ConstantTypes.BITS;
size: ConstantSize;
offset?: number;
address: number[];
values: string[];
}
export interface ArrayConstant {
type: ConstantTypes.ARRAY;
size: ConstantSize;
offset?: number;
shape: ArrayShape;
units: string;
scale: number | string;
transform: number | string;
min: number | string;
max: number | string;
digits: number;
}
export interface StringConstant {
type: ConstantTypes.SCALAR;
size: ConstantSize;
length: number;
}
export interface OutputChannel {
type: ConstantTypes.SCALAR | ConstantTypes.BITS;
size: ConstantSize;
offset: number;
units: string;
scale: number | string;
transform: number | string;
}
export interface SimpleConstant {
value: string;
}
export type Constant = ScalarConstant | BitsConstant | ArrayConstant | StringConstant;
export interface Constants {
[name: string]: Constant;
}
export interface Page {
number: number;
size: number;
data: Constants;
}
export interface Help {
[key: string]: string;
}
export interface Curve {
title: string;
labels: string[];
xAxis: number[];
yAxis: number[];
xBins: string[];
yBins: string[];
size: number[];
gauge?: string;
}
export interface Table {
map: string;
title: string;
page: number;
help?: string;
xBins: string[];
yBins: string[];
xyLabels: string[];
zBins: string[];
gridHeight: number;
gridOrient: number[];
upDownLabel: string[];
}
export interface OutputChannels {
[name: string]: OutputChannel | SimpleConstant;
}
export interface DatalogEntry {
name: string;
label: string;
type: 'int' | 'float';
format: string;
condition: string;
}
export interface Config {
[key: string]: any;
megaTune: {
[key: string]: any;
signature: string;
MTversion: number;
queryCommand: string;
versionInfo: string;
};
tunerStudio: {
[key: string]: any;
iniSpecVersion: number;
};
pcVariables: Constants;
constants: {
pages: Page[];
};
defines: {
[name: string]: string[];
};
menus: Menus;
help: Help;
dialogs: {
[name: string]: Dialog;
};
curves: {
[name: string]: Curve;
};
tables: {
[name: string]: Table;
};
outputChannels: OutputChannels;
datalog: {
[name: string]: DatalogEntry;
};
}

26
src/state.ts Normal file
View File

@ -0,0 +1,26 @@
import { Config } from './config';
import { Tune } from './tune';
export interface ConfigState extends Config {}
export interface TuneState extends Tune {}
export interface UIState {
sidebarCollapsed: boolean;
}
export interface StatusState {
text: string | null;
}
export interface AppState {
tune: TuneState;
config: ConfigState;
ui: UIState;
status: StatusState;
}
export interface UpdateTunePayload {
name: string;
value: string | number;
}

12
src/tune.ts Normal file
View File

@ -0,0 +1,12 @@
export interface Constant {
units?: string;
value: string | number;
}
export interface Constants {
[name: string]: Constant;
}
export interface Tune {
constants: Constants;
}

22
tsconfig.json Normal file
View File

@ -0,0 +1,22 @@
{
"compilerOptions": {
"target": "ES2017",
"declaration": true,
"module": "commonjs",
"outDir": "dist",
"removeComments": true,
"strict": true,
"strictNullChecks": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
},
"include": [
"src",
]
}