mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-20 04:54:45 -07:00
[FL-3918] Full-fledged JS SDK + npm packages (#3963)
* feat: js sdk * refactor: move js back where it belongs * docs: generate docs using typedoc * feat: sdk versioning scheme * ci: silence pvs warning * docs: bring back old incomplete js docs * style: readAnalog naming * fix: rename script compatibility screens Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
2
applications/system/js_app/packages/create-fz-app/template/.gitignore
vendored
Normal file
2
applications/system/js_app/packages/create-fz-app/template/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/dist
|
||||
node_modules/
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
build: {
|
||||
// Where to put the compiled file
|
||||
output: "dist/<app_name>.js",
|
||||
|
||||
// Whether to reduce the final file size at the cost of readability and
|
||||
// clarity of error messages
|
||||
minify: false,
|
||||
|
||||
// Set this to `false` if you've thoroughly read the documentation and
|
||||
// are sure that you can use manual version checks to your advantage
|
||||
enforceSdkVersion: true,
|
||||
},
|
||||
|
||||
upload: {
|
||||
// Where to grab the file from. If you're not doing any extra processing
|
||||
// after the SDK, this should match `build.output`
|
||||
input: "dist/<app_name>.js",
|
||||
|
||||
// Where to put the file on the device
|
||||
output: "/ext/apps/Scripts/<app_name>.js",
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// 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";
|
||||
|
||||
// a common pattern is to declare all the views that your app uses on one object
|
||||
const views = {
|
||||
dialog: dialog.makeWith({
|
||||
header: "Hello from <app_name>",
|
||||
text: "Check out index.ts and\nchange something :)",
|
||||
center: "Gonna do that!",
|
||||
}),
|
||||
};
|
||||
|
||||
// stop app on center button press
|
||||
eventLoop.subscribe(views.dialog.input, (_sub, button, eventLoop) => {
|
||||
if (button === "center")
|
||||
eventLoop.stop();
|
||||
}, eventLoop);
|
||||
|
||||
// stop app on back button press
|
||||
eventLoop.subscribe(gui.viewDispatcher.navigation, (_sub, _item, eventLoop) => {
|
||||
eventLoop.stop();
|
||||
}, eventLoop);
|
||||
|
||||
// run app
|
||||
gui.viewDispatcher.switchTo(views.dialog);
|
||||
eventLoop.run();
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"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"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@flipperdevices/fz-sdk": "^0.1",
|
||||
"typescript": "^5.6.3"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"checkJs": true,
|
||||
"module": "CommonJS",
|
||||
"noLib": true,
|
||||
"target": "ES2015",
|
||||
},
|
||||
"files": [
|
||||
"./node_modules/@flipperdevices/fz-sdk/global.d.ts",
|
||||
],
|
||||
"include": [
|
||||
"./**/*.ts",
|
||||
"./**/*.js"
|
||||
],
|
||||
"exclude": [
|
||||
"./node_modules/**/*",
|
||||
"dist/**/*",
|
||||
],
|
||||
}
|
||||
Reference in New Issue
Block a user