Extract `types` into separate package (#209)

This commit is contained in:
Piotr Rogowski 2021-09-26 18:07:54 +02:00 committed by GitHub
parent fc61990b00
commit c176779f19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 119 additions and 310 deletions

View File

@ -14,6 +14,7 @@ jobs:
runs-on: ubuntu-latest
env:
CI: true
NPM_GITHUB_TOKEN: ${{ secrets.NPM_GITHUB_PAT }}
strategy:
matrix:
@ -21,10 +22,10 @@ jobs:
# 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
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run lint

2
.npmrc Normal file
View File

@ -0,0 +1,2 @@
@speedy-tuner:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${NPM_GITHUB_TOKEN}

View File

@ -38,10 +38,18 @@ There are many ways in which you can participate in the project and every bit of
## Development
Recommended dev environment:
### Recommended dev environment
- [Node](https://nodejs.org/) 16.x.x
### Authenticate to GitHub Packages
Project uses shared packages (`@speedy-tuner/...`).
They are hosted using `GitHub Packages`, to install them you need to [authenticate to GitHub Packages](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-to-github-packages) first.
### Install and run
```bash
# install packages
npm install

60
package-lock.json generated
View File

@ -12,10 +12,11 @@
"@reduxjs/toolkit": "^1.6.1",
"@sentry/react": "^6.13.2",
"@sentry/tracing": "^6.13.2",
"@speedy-tuner/types": "^0.1.1",
"antd": "^4.16.13",
"electron-squirrel-startup": "^1.0.0",
"js-yaml": "^4.1.0 ",
"mlg-converter": "^0.5.0",
"mlg-converter": "^0.5.1",
"pako": "^2.0.4",
"parsimmon": "^1.18.0",
"react": "^17.0.1",
@ -50,6 +51,7 @@
"eslint-config-airbnb": "^18.2.1",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-modules-newline": "^0.0.6",
@ -3435,6 +3437,12 @@
"@sinonjs/commons": "^1.7.0"
}
},
"node_modules/@speedy-tuner/types": {
"version": "0.1.1",
"resolved": "https://npm.pkg.github.com/download/@speedy-tuner/types/0.1.1/fc3f3f3bfd51904c40688b8a3a93c3c9b4f3bb982886558bdbed00fa51bbc7dc",
"integrity": "sha512-2GDG6iL0/Eo7Wt3P4labAqxakHkK1QxVuMFBy82f5WOWtsR0dOgZHyotPV6wueRPLo3qzdHrcxPpSdgwszc6Fw==",
"license": "MIT"
},
"node_modules/@surma/rollup-plugin-off-main-thread": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-1.4.2.tgz",
@ -9864,6 +9872,26 @@
"ms": "^2.1.1"
}
},
"node_modules/eslint-import-resolver-typescript": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-2.5.0.tgz",
"integrity": "sha512-qZ6e5CFr+I7K4VVhQu3M/9xGv9/YmwsEXrsm3nimw8vWaVHRDrQRp26BgCypTxBp3vUp4o5aVEJRiy0F2DFddQ==",
"dev": true,
"dependencies": {
"debug": "^4.3.1",
"glob": "^7.1.7",
"is-glob": "^4.0.1",
"resolve": "^1.20.0",
"tsconfig-paths": "^3.9.0"
},
"engines": {
"node": ">=4"
},
"peerDependencies": {
"eslint": "*",
"eslint-plugin-import": "*"
}
},
"node_modules/eslint-module-utils": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.2.tgz",
@ -16613,9 +16641,9 @@
}
},
"node_modules/mlg-converter": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/mlg-converter/-/mlg-converter-0.5.0.tgz",
"integrity": "sha512-FKqJ0vbbxFZuziwMbih8fRF8JFF2xFSWmYNOylji1IkRPu83dCWCGV4AkG9fkKs/z9ThOqfuSkaUEnWbL33c8g=="
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mlg-converter/-/mlg-converter-0.5.1.tgz",
"integrity": "sha512-t9jvCRmOpGLKBPHaSjnJt+83rBicWVV7qHLDtZ0M651zl8IMrOJ9jPp8W5zGqukKP5sOgxYWbgejIBSdJ1SAXQ=="
},
"node_modules/moment": {
"version": "2.29.1",
@ -29856,6 +29884,11 @@
"@sinonjs/commons": "^1.7.0"
}
},
"@speedy-tuner/types": {
"version": "0.1.1",
"resolved": "https://npm.pkg.github.com/download/@speedy-tuner/types/0.1.1/fc3f3f3bfd51904c40688b8a3a93c3c9b4f3bb982886558bdbed00fa51bbc7dc",
"integrity": "sha512-2GDG6iL0/Eo7Wt3P4labAqxakHkK1QxVuMFBy82f5WOWtsR0dOgZHyotPV6wueRPLo3qzdHrcxPpSdgwszc6Fw=="
},
"@surma/rollup-plugin-off-main-thread": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-1.4.2.tgz",
@ -34976,6 +35009,19 @@
}
}
},
"eslint-import-resolver-typescript": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-2.5.0.tgz",
"integrity": "sha512-qZ6e5CFr+I7K4VVhQu3M/9xGv9/YmwsEXrsm3nimw8vWaVHRDrQRp26BgCypTxBp3vUp4o5aVEJRiy0F2DFddQ==",
"dev": true,
"requires": {
"debug": "^4.3.1",
"glob": "^7.1.7",
"is-glob": "^4.0.1",
"resolve": "^1.20.0",
"tsconfig-paths": "^3.9.0"
}
},
"eslint-module-utils": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.2.tgz",
@ -40110,9 +40156,9 @@
}
},
"mlg-converter": {
"version": "0.5.0",
"resolved": "https://registry.npmjs.org/mlg-converter/-/mlg-converter-0.5.0.tgz",
"integrity": "sha512-FKqJ0vbbxFZuziwMbih8fRF8JFF2xFSWmYNOylji1IkRPu83dCWCGV4AkG9fkKs/z9ThOqfuSkaUEnWbL33c8g=="
"version": "0.5.1",
"resolved": "https://registry.npmjs.org/mlg-converter/-/mlg-converter-0.5.1.tgz",
"integrity": "sha512-t9jvCRmOpGLKBPHaSjnJt+83rBicWVV7qHLDtZ0M651zl8IMrOJ9jPp8W5zGqukKP5sOgxYWbgejIBSdJ1SAXQ=="
},
"moment": {
"version": "2.29.1",

View File

@ -5,6 +5,10 @@
"private": true,
"license": "MIT",
"homepage": "./",
"repository": {
"type": "git",
"url": "https://github.com/speedy-tuner/speedy-tuner-cloud"
},
"main": "src/electron.js",
"scripts": {
"start": "craco start",
@ -37,10 +41,11 @@
"@reduxjs/toolkit": "^1.6.1",
"@sentry/react": "^6.13.2",
"@sentry/tracing": "^6.13.2",
"@speedy-tuner/types": "^0.1.1",
"antd": "^4.16.13",
"electron-squirrel-startup": "^1.0.0",
"js-yaml": "^4.1.0 ",
"mlg-converter": "^0.5.0",
"mlg-converter": "^0.5.1",
"pako": "^2.0.4",
"parsimmon": "^1.18.0",
"react": "^17.0.1",
@ -60,8 +65,6 @@
"@electron-forge/maker-rpm": "^6.0.0-beta.61",
"@electron-forge/maker-squirrel": "^6.0.0-beta.61",
"@electron-forge/maker-zip": "^6.0.0-beta.61",
"@typescript-eslint/eslint-plugin": "^4.31.0",
"@typescript-eslint/parser": "^4.31.0",
"@types/js-yaml": "^4.0.3",
"@types/node": "^16.9.6",
"@types/pako": "^1.0.2",
@ -70,11 +73,14 @@
"@types/react-dom": "^17.0.9",
"@types/react-redux": "^7.1.18",
"@types/react-router-dom": "^5.3.0",
"@typescript-eslint/eslint-plugin": "^4.31.0",
"@typescript-eslint/parser": "^4.31.0",
"electron": "^15.0.0",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-modules-newline": "^0.0.6",

View File

@ -16,13 +16,14 @@ import {
useEffect,
useMemo,
} from 'react';
import Dialog from './components/Dialog';
import { loadAll } from './utils/api';
import SideBar, { DialogMatchedPathType } from './components/SideBar';
import {
AppState,
UIState,
} from './types/state';
Config as ConfigType,
} from '@speedy-tuner/types';
import Dialog from './components/Dialog';
import { loadAll } from './utils/api';
import SideBar, { DialogMatchedPathType } from './components/SideBar';
import BurnButton from './components/BurnButton';
import TopBar from './components/TopBar';
import StatusBar from './components/StatusBar';
@ -30,7 +31,6 @@ import { isDesktop } from './utils/env';
import 'react-perfect-scrollbar/dist/css/styles.css';
import './App.less';
import { Routes } from './routes';
import { Config as ConfigType } from './types/config';
import Log from './components/Log';
import useStorage from './hooks/useStorage';
import useConfig from './hooks/useConfig';

View File

@ -11,12 +11,8 @@ import {
Result,
} from 'antd';
import { QuestionCircleOutlined } from '@ant-design/icons';
import { AppState } from '../types/state';
import SmartSelect from './Dialog/SmartSelect';
import SmartNumber from './Dialog/SmartNumber';
import TextField from './Dialog/TextField';
import Curve from './Dialog/Curve';
import {
AppState,
Dialogs as DialogsType,
Dialog as DialogType,
Config as ConfigType,
@ -25,8 +21,12 @@ import {
Table as TableType,
ScalarConstant as ScalarConstantType,
ConstantTypes,
} from '../types/config';
import { Tune as TuneType } from '../types/tune';
Tune as TuneType,
} from '@speedy-tuner/types';
import SmartSelect from './Dialog/SmartSelect';
import SmartNumber from './Dialog/SmartNumber';
import TextField from './Dialog/TextField';
import Curve from './Dialog/Curve';
import {
parseXy,
parseZ,

View File

@ -7,7 +7,7 @@ import {
CheckOutlined,
CloseOutlined,
} from '@ant-design/icons';
import { Switches } from '../../types/config';
import { Switches } from '@speedy-tuner/types';
const SmartSelect = ({
values,

View File

@ -33,19 +33,17 @@ import {
import PerfectScrollbar from 'react-perfect-scrollbar';
// eslint-disable-next-line import/no-unresolved
import MlgParserWorker from 'worker-loader!../workers/mlgParser.worker';
import {
AppState,
UIState,
Config,
OutputChannel,
} from '@speedy-tuner/types';
import { loadLogs } from '../utils/api';
import Canvas, {
LogEntry,
SelectedField,
} from './Log/Canvas';
import {
AppState,
UIState,
} from '../types/state';
import {
Config,
OutputChannel,
} from '../types/config';
import store from '../store';
import {
formatBytes,

View File

@ -10,16 +10,14 @@ import {
} from 'react-router-dom';
import PerfectScrollbar from 'react-perfect-scrollbar';
import { useCallback } from 'react';
import store from '../store';
import {
AppState,
UIState,
} from '../types/state';
import {
Config as ConfigType,
Menus as MenusType,
} from '../types/config';
import { Tune as TuneType } from '../types/tune';
AppState,
UIState,
Tune as TuneType,
} from '@speedy-tuner/types';
import store from '../store';
import Icon from './SideBar/Icon';
import { evaluateExpression } from '../utils/tune/expression';
import { Routes } from '../routes';

View File

@ -3,18 +3,18 @@ import {
Layout,
Space,
Row,
Col,
Col,
} from 'antd';
import {
CarOutlined,
InfoCircleOutlined,
InfoCircleOutlined,
} from '@ant-design/icons';
import { connect } from 'react-redux';
import {
AppState,
ConfigState,
StatusState,
} from '../types/state';
StatusState,
} from '@speedy-tuner/types';
const { Footer } = Layout;

View File

@ -1,7 +1,7 @@
import {
ConstantTypes,
ScalarConstant,
} from '../types/config';
} from '@speedy-tuner/types';
// eslint-disable-next-line import/prefer-default-export
export const divider: ScalarConstant = {

View File

@ -1,4 +1,4 @@
import { Help as HelpType } from '../types/config';
import { Help as HelpType } from '@speedy-tuner/types';
const help: HelpType = {
reqFuel: 'The base reference pulse width required to achieve stoichiometric at 100% VE and a manifold absolute pressure (MAP) of 100kPa using current settings.',

View File

@ -1,4 +1,4 @@
import { Dialogs as DialogsType } from '../types/config';
import { Dialogs as DialogsType } from '@speedy-tuner/types';
const standardDialogs: DialogsType = {
std_injection: {

View File

@ -6,7 +6,7 @@ import {
OutputChannel,
SimpleConstant,
DatalogEntry,
} from '../types/config';
} from '@speedy-tuner/types';
const findConstantOnPage = (config: ConfigType, fieldName: string): Constant => {
const foundPage = config

View File

@ -6,7 +6,7 @@ import * as P from 'parsimmon';
import {
Config as ConfigType,
Constant,
} from '../types/config';
} from '@speedy-tuner/types';
console.log('------- start --------');

View File

@ -3,9 +3,9 @@
import {
configureStore,
createAction,
createReducer,
createReducer,
} from '@reduxjs/toolkit';
import * as Types from './types/state';
import * as Types from '@speedy-tuner/types';
// tune and config
const updateTune = createAction<Types.UpdateTunePayload>('tune/update');

View File

@ -1,211 +0,0 @@
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;
};
}

View File

@ -1,26 +0,0 @@
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;
}

View File

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

View File

@ -1,5 +1,5 @@
import { Config as ConfigType } from '@speedy-tuner/types';
import store from '../store';
import { Config as ConfigType } from '../types/config';
import stdDialogs from '../data/standardDialogs';
import help from '../data/help';
import { divider } from '../data/constants';

View File

@ -1,11 +1,10 @@
import { Constants as TuneConstantsType } from '../../types/tune';
import {
Config as ConfigType,
OutputChannels as OutputChannelsType,
Page as ConfigPageType,
SimpleConstant as SimpleConstantType,
} from '../../types/config';
TuneConstants as TuneConstantsType,
} from '@speedy-tuner/types';
export const isExpression = (val: any) => `${val}`.startsWith('{') && `${val}`.endsWith('}');