Skip to content

Commit

Permalink
Initial JS CFW SDK changes
Browse files Browse the repository at this point in the history
TODO: Check documentation and other package options

TODO: Transform CFW SDK name to OFW SDK name in build step so all firmwares understand it
  • Loading branch information
Willy-JL committed Nov 1, 2024
1 parent 2dd9b84 commit bbe69e7
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ tests.assert_eq("firmwareTooNew", sdkCompatibilityStatus(-100500, 0));
tests.assert_eq(true, doesSdkSupport(["baseline"]));
tests.assert_eq(false, doesSdkSupport(["abobus", "other-nonexistent-feature"]));

tests.assert_eq("flipperdevices", flipper.firmwareVendor);
tests.assert_eq("momentum", flipper.firmwareVendor);
tests.assert_eq(0, flipper.jsSdkVersion[0]);
tests.assert_eq(1, flipper.jsSdkVersion[1]);
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ application for Flipper Zero.
## Getting started
Create your application using the interactive wizard:
```shell
npx @flipperdevices/create-fz-app@latest
npx @next-flip/create-fz-app-mntm@latest
```

Then, enter the directory with your application and launch it:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@flipperdevices/create-fz-app",
"name": "@next-flip/create-fz-app-mntm",
"version": "0.1.0",
"description": "Template package for JS apps Flipper Zero",
"bin": "index.js",
Expand All @@ -12,7 +12,7 @@
"license": "GPL-3.0-only",
"repository": {
"type": "git",
"url": "git+https://github.com/flipperdevices/flipperzero-firmware.git",
"url": "git+https://github.com/Next-Flip/Momentum-Firmware.git",
"directory": "applications/system/js_app/packages/create-fz-app"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// import modules
// caution: `eventLoop` HAS to be imported before `gui`, and `gui` HAS to be
// imported before any `gui` submodules.
import * as eventLoop from "@flipperdevices/fz-sdk/event_loop";
import * as gui from "@flipperdevices/fz-sdk/gui";
import * as dialog from "@flipperdevices/fz-sdk/gui/dialog";
import * as eventLoop from "@next-flip/fz-sdk-mntm/event_loop";
import * as gui from "@next-flip/fz-sdk-mntm/gui";
import * as dialog from "@next-flip/fz-sdk-mntm/gui/dialog";

// a common pattern is to declare all the views that your app uses on one object
const views = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"name": "<app_name>",
"version": "1.0.0",
"scripts": {
"build": "tsc && node node_modules/@flipperdevices/fz-sdk/sdk.js build",
"start": "npm run build && node node_modules/@flipperdevices/fz-sdk/sdk.js upload"
"build": "tsc && node node_modules/@next-flip/fz-sdk-mntm/sdk.js build",
"start": "npm run build && node node_modules/@next-flip/fz-sdk-mntm/sdk.js upload"
},
"devDependencies": {
"@flipperdevices/fz-sdk": "^0.1",
"@next-flip/fz-sdk-mntm": "^0.1",
"typescript": "^5.6.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"target": "ES2015",
},
"files": [
"./node_modules/@flipperdevices/fz-sdk/global.d.ts",
"./node_modules/@next-flip/fz-sdk-mntm/global.d.ts",
],
"include": [
"./**/*.ts",
Expand Down
2 changes: 1 addition & 1 deletion applications/system/js_app/packages/fz-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ applications in JavaScript.
## Getting started
Create your application using the interactive wizard:
```shell
npx @flipperdevices/create-fz-app@latest
npx @next-flip/create-fz-app-mntm@latest
```

Then, enter the directory with your application and launch it:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export declare function getBatteryCharge(): number;
* @warning Do **NOT** use this to check the presence or absence of features. If
* you do, I'm gonna be sad :( Instead, refer to `checkSdkFeatures` and
* other similar mechanisms.
* @note Original firmware reports `"flipperdevices"`.
* @note Momentum firmware reports `"momentum"`.
* @version Added in JS SDK 0.1
*/
export declare const firmwareVendor: string;
Expand Down
4 changes: 2 additions & 2 deletions applications/system/js_app/packages/fz-sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@flipperdevices/fz-sdk",
"name": "@next-flip/fz-sdk-mntm",
"version": "0.1.1",
"description": "Type declarations and documentation for native JS modules available on Flipper Zero",
"keywords": [
Expand All @@ -11,7 +11,7 @@
"license": "GPL-3.0-only",
"repository": {
"type": "git",
"url": "git+https://github.com/flipperdevices/flipperzero-firmware.git",
"url": "git+https://github.com/Next-Flip/Momentum-Firmware.git",
"directory": "applications/system/js_app/packages/fz-sdk"
},
"type": "module",
Expand Down
4 changes: 3 additions & 1 deletion applications/system/js_app/packages/fz-sdk/sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async function build(config) {
bundle: true,
minify: config.minify,
external: [
"@flipperdevices/fz-sdk/*"
"@next-flip/fz-sdk-mntm/*"
],
supported: {
"array-spread": false,
Expand Down Expand Up @@ -74,6 +74,8 @@ async function build(config) {
let outContents = fs.readFileSync(config.output, "utf8");
outContents = "let exports = {};\n" + outContents;

// TODO: Transform CFW SDK name to OFW SDK name so all firmwares understand it

if (config.enforceSdkVersion) {
const version = json5.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf8")).version;
let [major, minor, _] = version.split(".");
Expand Down

0 comments on commit bbe69e7

Please sign in to comment.