Skip to content

Commit 79caf7b

Browse files
committed
Add js sdk changes
With type declarations and various missing parts added by Willy-JL
1 parent 8a2cf4d commit 79caf7b

File tree

19 files changed

+378
-26
lines changed

19 files changed

+378
-26
lines changed

applications/system/js_app/js_modules.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,15 @@ void js_check_sdk_compatibility(struct mjs* mjs) {
267267

268268
static const char* extra_features[] = {
269269
"baseline", // dummy "feature"
270+
271+
// extra modules
272+
"blebeacon",
273+
"i2c",
274+
"spi",
275+
"subghz",
276+
"usbdisk",
277+
"vgm",
278+
"widget",
270279
};
271280

272281
/**

applications/system/js_app/modules/js_subghz/js_subghz.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static void js_subghz_transmit_file(struct mjs* mjs) {
223223
// - "repeat" as variable and loop in this code applies to RAW files only
224224
// parsed files handle repeat in protocol layer instead
225225
// We keep 0 as default, or literal value if specified by user
226-
// If user did not specify, -1 is detected below, and we use:
226+
// If user did not specify, 0 is detected below, and we use:
227227
// - 1 repeat for RAW
228228
// - 10 repeats for parsed, which is passed to protocol, and we loop once here
229229
uint32_t repeat = 0;

applications/system/js_app/packages/create-fz-app/README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
# Flipper Zero JavaScript SDK Wizard
1+
# Flipper Unleashed Firmware JavaScript SDK Wizard
22
This package contains an interactive wizard that lets you scaffold a JavaScript
3-
application for Flipper Zero.
3+
application for Flipper Zero using the Custom Unleashed Firmware JS SDK.
4+
5+
This is a fork of the [Official Flipper Zero JS SDK Wizard](https://www.npmjs.com/package/@flipperdevices/create-fz-app),
6+
configured to use the [Unleashed FW JavaScript SDK]((https://www.npmjs.com/package/@darkflippers/fz-sdk-ul)) instead.
7+
No other changes are included.
48

59
## Getting started
610
Create your application using the interactive wizard:
711
```shell
8-
npx @flipperdevices/create-fz-app@latest
12+
npx @darkflippers/create-fz-app-ul@latest
913
```
1014

1115
Then, enter the directory with your application and launch it:

applications/system/js_app/packages/create-fz-app/package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
{
2-
"name": "@flipperdevices/create-fz-app",
3-
"version": "0.1.0",
4-
"description": "Template package for JS apps Flipper Zero",
2+
"name": "@darkflippers/create-fz-app-ul",
3+
"version": "0.1.1",
4+
"description": "Template package for JS apps for Flipper Zero using Unleashed Firmware JS SDK",
55
"bin": "index.js",
66
"type": "module",
77
"keywords": [
8+
"unleashed",
9+
"unleashed firmware",
10+
"ul",
11+
"darkflippers",
12+
"flipper cfw js",
813
"flipper",
914
"flipper zero"
1015
],
1116
"author": "Flipper Devices",
1217
"license": "GPL-3.0-only",
1318
"repository": {
1419
"type": "git",
15-
"url": "git+https://github.com/flipperdevices/flipperzero-firmware.git",
20+
"url": "git+https://github.com/DarkFlippers/unleashed-firmware.git",
1621
"directory": "applications/system/js_app/packages/create-fz-app"
1722
},
1823
"dependencies": {

applications/system/js_app/packages/create-fz-app/template/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// import modules
22
// caution: `eventLoop` HAS to be imported before `gui`, and `gui` HAS to be
33
// imported before any `gui` submodules.
4-
import * as eventLoop from "@flipperdevices/fz-sdk/event_loop";
5-
import * as gui from "@flipperdevices/fz-sdk/gui";
6-
import * as dialog from "@flipperdevices/fz-sdk/gui/dialog";
4+
import * as eventLoop from "@darkflippers/fz-sdk-ul/event_loop";
5+
import * as gui from "@darkflippers/fz-sdk-ul/gui";
6+
import * as dialog from "@darkflippers/fz-sdk-ul/gui/dialog";
77

88
// a common pattern is to declare all the views that your app uses on one object
99
const views = {

applications/system/js_app/packages/create-fz-app/template/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"name": "<app_name>",
33
"version": "1.0.0",
44
"scripts": {
5-
"build": "tsc && node node_modules/@flipperdevices/fz-sdk/sdk.js build",
6-
"start": "npm run build && node node_modules/@flipperdevices/fz-sdk/sdk.js upload"
5+
"build": "tsc && node node_modules/@darkflippers/fz-sdk-ul/sdk.js build",
6+
"start": "npm run build && node node_modules/@darkflippers/fz-sdk-ul/sdk.js upload"
77
},
88
"devDependencies": {
9-
"@flipperdevices/fz-sdk": "^0.1",
9+
"@darkflippers/fz-sdk-ul": "^0.1",
1010
"typescript": "^5.6.3"
1111
}
1212
}

applications/system/js_app/packages/create-fz-app/template/tsconfig.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
"module": "CommonJS",
66
"noLib": true,
77
"target": "ES2015",
8+
"types": [],
89
},
910
"files": [
10-
"./node_modules/@flipperdevices/fz-sdk/global.d.ts",
11+
"./node_modules/@darkflippers/fz-sdk-ul/global.d.ts",
1112
],
1213
"include": [
1314
"./**/*.ts",
14-
"./**/*.js"
15+
"./**/*.js",
1516
],
1617
"exclude": [
1718
"./node_modules/**/*",

applications/system/js_app/packages/fz-sdk/README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
# Flipper Zero JavaScript SDK
2-
This package contains official tooling and typings for developing Flipper Zero
3-
applications in JavaScript.
1+
# Flipper Unleashed FW JavaScript SDK
2+
This package contains tooling and typings for developing Flipper Zero
3+
applications in JavaScript for Unleashed Custom Firmware (based on official SDK).
4+
5+
This is a fork of the [Official Flipper Zero JS SDK](https://www.npmjs.com/package/@flipperdevices/fz-sdk),
6+
with added types for the extra features provided by the Unleashed firmware JavaScript API.
7+
8+
Scripts made for Official Flipper Zero JS SDK will work on Unleashed Firmware too.
9+
If you use extra features provided by Unleashed FW JS SDK, you are encouraged to use syntax like
10+
`if (doesSdkSupport(["feature-name"])) { ... }` so that your JS app can work on Official
11+
Firmware too, aswell as all other compliant Custom Firmwares. If some of those extra
12+
features are essential to the functionality of your app, you can use `checkSdkFeatures(["feature1", "feature2"])`
13+
near the beginning of your script, which will show a warning to the user that these features
14+
are not available in their firmware distribution.
415

516
## Getting started
617
Create your application using the interactive wizard:
718
```shell
8-
npx @flipperdevices/create-fz-app@latest
19+
npx @darkflippers/create-fz-app-ul@latest
920
```
1021

1122
Then, enter the directory with your application and launch it:
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Module for using the BLE extra beacon
3+
* @version Available with JS feature `blebeacon`
4+
* @module
5+
*/
6+
7+
/**
8+
* @brief Check if the BLE beacon is active
9+
*/
10+
export declare function isActive(): boolean;
11+
12+
/**
13+
* @brief Set BLE beacon configuration
14+
* @param mac The MAC address to use
15+
* @param power The power level to use, in GapAdvPowerLevel scale: 0x00 (-40dBm) to 0x1F (+6dBm)
16+
* @param minInterval Minimum advertisement interval
17+
* @param maxInterval Maximum advertisement interval
18+
*/
19+
export declare function setConfig(mac: Uint8Array, power?: number, minInterval?: number, maxInterval?: number): void;
20+
21+
/**
22+
* @brief Set BLE beacon advertisement data
23+
* @param data The advertisement data to use
24+
*/
25+
export declare function setData(data: Uint8Array): void;
26+
27+
/**
28+
* @brief Start BLE beacon
29+
*/
30+
export declare function start(): void;
31+
32+
/**
33+
* @brief Stop BLE beacon
34+
*/
35+
export declare function stop(): void;
36+
37+
/**
38+
* @brief Set whether the BLE beacon will remain active after the script exits
39+
* @param keep True if BLE beacon should remain active after script exit
40+
*/
41+
export declare function keepAlive(keep: boolean): void;

applications/system/js_app/packages/fz-sdk/flipper/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export declare function getBatteryCharge(): number;
2626
* @warning Do **NOT** use this to check the presence or absence of features. If
2727
* you do, I'm gonna be sad :( Instead, refer to `checkSdkFeatures` and
2828
* other similar mechanisms.
29-
* @note Original firmware reports `"flipperdevices"`.
29+
* @note Unleashed firmware reports `"unleashed"`. / Official firmware reports `"flipperdevices"`.
3030
* @version Added in JS SDK 0.1
3131
*/
3232
export declare const firmwareVendor: string;

0 commit comments

Comments
 (0)