Skip to content

Commit

Permalink
prepare for using with widChargingStatus
Browse files Browse the repository at this point in the history
global types are not yet received correctly, but we're close!

- use widChargerStatus as first example to make setup work
- add github action to compile supplied types/globals on pushes
  • Loading branch information
maybeanerd committed Dec 7, 2021
1 parent 3cd9c39 commit 61cc93b
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 6 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Node CI

on: [push]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: go to typescript directory
run: cd typescript
- name: npm ci
run: npm ci
- name: build types
run: npm run build:types
File renamed without changes.
File renamed without changes.
File renamed without changes.
145 changes: 145 additions & 0 deletions typescript/globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
// TODO all of these globals (copied from eslintrc need to be typed at some point)
/* "globals": {
// Methods and Fields at https://banglejs.com/reference
"Array": "readonly",
"ArrayBuffer": "readonly",
"ArrayBufferView": "readonly",
"Bangle": "readonly",
"BluetoothDevice": "readonly",
"BluetoothRemoteGATTCharacteristic": "readonly",
"BluetoothRemoteGATTServer": "readonly",
"BluetoothRemoteGATTService": "readonly",
"Boolean": "readonly",
"console": "readonly",
"DataView": "readonly",
"Date": "readonly",
"E": "readonly",
"Error": "readonly",
"Flash": "readonly",
"Float32Array": "readonly",
"Float64Array": "readonly",
"fs": "readonly",
"Function": "readonly",
"Graphics": "readonly",
"heatshrink": "readonly",
"I2C": "readonly",
"Int16Array": "readonly",
"Int32Array": "readonly",
"Int8Array": "readonly",
"InternalError": "readonly",
"JSON": "readonly",
"Math": "readonly",
"Modules": "readonly",
"NRF": "readonly",
"Number": "readonly",
"Object": "readonly",
"OneWire": "readonly",
"Pin": "readonly",
"process": "readonly",
"Promise": "readonly",
"ReferenceError": "readonly",
"RegExp": "readonly",
"Serial": "readonly",
"SPI": "readonly",
"Storage": "readonly",
"StorageFile": "readonly",
"String": "readonly",
"SyntaxError": "readonly",
"tensorflow": "readonly",
"TFMicroInterpreter": "readonly",
"TypeError": "readonly",
"Uint16Array": "readonly",
"Uint24Array": "readonly",
"Uint32Array": "readonly",
"Uint8Array": "readonly",
"Uint8ClampedArray": "readonly",
"Waveform": "readonly",
// Methods and Fields at https://banglejs.com/reference
"analogRead": "readonly",
"analogWrite": "readonly",
"arguments": "readonly",
"atob": "readonly",
"Bluetooth": "readonly",
"BTN": "readonly",
"BTN1": "readonly",
"BTN2": "readonly",
"BTN3": "readonly",
"BTN4": "readonly",
"BTN5": "readonly",
"btoa": "readonly",
"changeInterval": "readonly",
"clearInterval": "readonly",
"clearTimeout": "readonly",
"clearWatch": "readonly",
"decodeURIComponent": "readonly",
"digitalPulse": "readonly",
"digitalRead": "readonly",
"digitalWrite": "readonly",
"dump": "readonly",
"echo": "readonly",
"edit": "readonly",
"encodeURIComponent": "readonly",
"eval": "readonly",
"getPinMode": "readonly",
"getSerial": "readonly",
"getTime": "readonly",
"global": "readonly",
"HIGH": "readonly",
"I2C1": "readonly",
"Infinity": "readonly",
"isFinite": "readonly",
"isNaN": "readonly",
"LED": "readonly",
"LED1": "readonly",
"LED2": "readonly",
"load": "readonly",
"LoopbackA": "readonly",
"LoopbackB": "readonly",
"LOW": "readonly",
"NaN": "readonly",
"parseFloat": "readonly",
"parseInt": "readonly",
"peek16": "readonly",
"peek32": "readonly",
"peek8": "readonly",
"pinMode": "readonly",
"poke16": "readonly",
"poke32": "readonly",
"poke8": "readonly",
"print": "readonly",
"require": "readonly",
"reset": "readonly",
"save": "readonly",
"Serial1": "readonly",
"setBusyIndicator": "readonly",
"setInterval": "readonly",
"setSleepIndicator": "readonly",
"setTime": "readonly",
"setTimeout": "readonly",
"setWatch": "readonly",
"shiftOut": "readonly",
"SPI1": "readonly",
"Terminal": "readonly",
"trace": "readonly",
"VIBRATE": "readonly",
// Aliases and not defined at https://banglejs.com/reference
"g": "readonly",
*/

declare const Bangle: {
// functions
buzz: () => void;
drawWidgets: () => void;
isCharging: () => boolean;
// events
on(event: 'charging', listener: (charging: boolean) => void): void;
// TODO add more
};

type Widget = {
area: 'tr' | 'tl';
width: number;
draw: () => void;
};

declare const WIDGETS: { [key: string]: Widget };
File renamed without changes.
4 changes: 2 additions & 2 deletions typescript/sharedLib/package.json → typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"main": "app.js",
"types": "app.d.ts",
"scripts": {
"build:testapp": "tsc ./src/app.ts --outDir ./dist",
"build:types": "tsc ./src/bangle.d.ts"
"build:example": "tsc ../apps/widChargingStatus/widget.ts --outDir ../apps/widChargingStatus/dist",
"build:types": "tsc ./globals.d.ts"
},
"author": {
"name": "Sebastian Di Luzio",
Expand Down
2 changes: 0 additions & 2 deletions typescript/sharedLib/src/app.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"module": "es2015",
"noImplicitAny": true,
"target": "es2015",
"outDir": "../dist"
}
"outDir": "../dist",
"isolatedModules": false
},
"include": ["./globals.d.ts"]
}

0 comments on commit 61cc93b

Please sign in to comment.