diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index aab3ff35318..dcf964addc5 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -36,7 +36,7 @@ /applications/services/power_settings_app/ @skotopes @DrZlo13 @hedger @gsurkov @gornekich /applications/system/storage_move_to_sd/ @skotopes @DrZlo13 @hedger @gsurkov @nminaylov -/applications/system/js_app/ @skotopes @DrZlo13 @hedger @gsurkov @nminaylov +/applications/system/js_app/ @skotopes @DrZlo13 @hedger @gsurkov @nminaylov @portasynthinca3 /applications/debug/unit_tests/ @skotopes @DrZlo13 @hedger @gsurkov @nminaylov @gornekich @Astrrra @Skorpionm @@ -49,8 +49,8 @@ /applications/main/infrared/resources/ @skotopes @DrZlo13 @hedger @gsurkov # Documentation -/documentation/ @skotopes @DrZlo13 @hedger @gsurkov @drunkbatya -/scripts/toolchain/ @skotopes @DrZlo13 @hedger @gsurkov @drunkbatya +/documentation/ @skotopes @DrZlo13 @hedger @gsurkov +/scripts/toolchain/ @skotopes @DrZlo13 @hedger @gsurkov # Lib /lib/stm32wb_copro/ @skotopes @DrZlo13 @hedger @gsurkov @gornekich @@ -59,11 +59,11 @@ /lib/lfrfid/ @skotopes @DrZlo13 @hedger @gsurkov @nminaylov /lib/libusb_stm32/ @skotopes @DrZlo13 @hedger @gsurkov @nminaylov /lib/mbedtls/ @skotopes @DrZlo13 @hedger @gsurkov @nminaylov -/lib/mjs/ @skotopes @DrZlo13 @hedger @gsurkov @nminaylov +/lib/mjs/ @skotopes @DrZlo13 @hedger @gsurkov @nminaylov @portasynthinca3 /lib/nanopb/ @skotopes @DrZlo13 @hedger @gsurkov @nminaylov /lib/nfc/ @skotopes @DrZlo13 @hedger @gsurkov @gornekich @Astrrra /lib/one_wire/ @skotopes @DrZlo13 @hedger @gsurkov /lib/subghz/ @skotopes @DrZlo13 @hedger @gsurkov @Skorpionm # CI/CD -/.github/workflows/ @skotopes @DrZlo13 @hedger @gsurkov @drunkbatya +/.github/workflows/ @skotopes @DrZlo13 @hedger @gsurkov diff --git a/applications/system/js_app/js_thread.c b/applications/system/js_app/js_thread.c index 97c9f742502..600c2676e12 100644 --- a/applications/system/js_app/js_thread.c +++ b/applications/system/js_app/js_thread.c @@ -217,16 +217,6 @@ static void js_parse_int(struct mjs* mjs) { mjs_return(mjs, mjs_mk_number(mjs, num)); } -static void js_global_to_string(struct mjs* mjs) { - int base = 10; - if(mjs_nargs(mjs) > 1) base = mjs_get_int(mjs, mjs_arg(mjs, 1)); - double num = mjs_get_int(mjs, mjs_arg(mjs, 0)); - char tmp_str[] = "-2147483648"; - itoa(num, tmp_str, base); - mjs_val_t ret = mjs_mk_string(mjs, tmp_str, ~0, true); - mjs_return(mjs, ret); -} - #ifdef JS_DEBUG static void js_dump_write_callback(void* ctx, const char* format, ...) { File* file = ctx; @@ -278,7 +268,6 @@ static int32_t js_thread(void* arg) { JS_ASSIGN_MULTI(mjs, global) { JS_FIELD("print", MJS_MK_FN(js_print)); JS_FIELD("delay", MJS_MK_FN(js_delay)); - JS_FIELD("toString", MJS_MK_FN(js_global_to_string)); JS_FIELD("parseInt", MJS_MK_FN(js_parse_int)); JS_FIELD("ffi_address", MJS_MK_FN(js_ffi_address)); JS_FIELD("require", MJS_MK_FN(js_require)); diff --git a/applications/system/js_app/packages/create-fz-app/package.json b/applications/system/js_app/packages/create-fz-app/package.json index 21642339656..7778104e208 100644 --- a/applications/system/js_app/packages/create-fz-app/package.json +++ b/applications/system/js_app/packages/create-fz-app/package.json @@ -1,6 +1,6 @@ { "name": "@flipperdevices/create-fz-app", - "version": "0.1.0", + "version": "0.1.1", "description": "Template package for JS apps Flipper Zero", "bin": "index.js", "type": "module", diff --git a/applications/system/js_app/packages/create-fz-app/template/tsconfig.json b/applications/system/js_app/packages/create-fz-app/template/tsconfig.json index c7b83cd5d39..1e6fc601806 100644 --- a/applications/system/js_app/packages/create-fz-app/template/tsconfig.json +++ b/applications/system/js_app/packages/create-fz-app/template/tsconfig.json @@ -5,13 +5,14 @@ "module": "CommonJS", "noLib": true, "target": "ES2015", + "types": [], }, "files": [ "./node_modules/@flipperdevices/fz-sdk/global.d.ts", ], "include": [ "./**/*.ts", - "./**/*.js" + "./**/*.js", ], "exclude": [ "./node_modules/**/*", diff --git a/applications/system/js_app/packages/fz-sdk/global.d.ts b/applications/system/js_app/packages/fz-sdk/global.d.ts index 953afc30d0b..d2e73f7de5b 100644 --- a/applications/system/js_app/packages/fz-sdk/global.d.ts +++ b/applications/system/js_app/packages/fz-sdk/global.d.ts @@ -120,6 +120,7 @@ declare function checkSdkCompatibility(expectedMajor: number, expectedMinor: num * recognized as a baseline feature. For more info, consult the module * documentation. * @param features Array of named features to query + * @version Added in JS SDK 0.1 */ declare function doesSdkSupport(features: string[]): boolean; @@ -131,6 +132,7 @@ declare function doesSdkSupport(features: string[]): boolean; * features that are now recognized as baseline features. For more * info, consult the module documentation. * @param features Array of named features to query + * @version Added in JS SDK 0.1 */ declare function checkSdkFeatures(features: string[]): void | never; @@ -150,15 +152,48 @@ declare function delay(ms: number): void; declare function print(...args: any[]): void; /** - * @brief Reads a JS value from a file + * @brief Converts a string to a number + * @param text The string to convert to a number + * @param base Integer base (`2`...`16`), default: 10 + * @version Added in JS SDK 0.1 + */ +declare function parseInt(text: string, base?: number): number; + +/** + * @brief Path to the directory containing the current script + * @version Added in JS SDK 0.1 + */ +declare const __dirname: string; + +/** + * @brief Path to the current script file + * @version Added in JS SDK 0.1 + */ +declare const __filename: string; + +/** + * @brief Runs a JS file and returns value from it * - * Reads a file at the specified path, interprets it as a JS value and returns - * said value. + * Reads a file at the specified path and runs it as JS, returning the last evaluated value. + * + * The result is cached and this filepath will not re-evaluated on future + * load() calls for this session. * * @param path The path to the file + * @param scope An object to use as global scope while running this file + * @version Added in JS SDK 0.1 + */ +declare function load(path: string, scope?: object): any; + +/** + * @brief Return 1-byte string whose ASCII code is the integer `n` + * + * If `n` is not numeric or outside of `0-255` range, `null` is returned + * + * @param n The ASCII code to convert to string * @version Added in JS SDK 0.1 */ -declare function load(path: string): any; +declare function chr(n: number): string | null; /** * @brief Loads a natively implemented module diff --git a/applications/system/js_app/packages/fz-sdk/gui/index.d.ts b/applications/system/js_app/packages/fz-sdk/gui/index.d.ts index 3184a57180b..93a6846c216 100644 --- a/applications/system/js_app/packages/fz-sdk/gui/index.d.ts +++ b/applications/system/js_app/packages/fz-sdk/gui/index.d.ts @@ -30,7 +30,7 @@ * |----------------------|------------------| * | `button_menu` | ❌ | * | `button_panel` | ❌ | - * | `byte_input` | ❌ | + * | `byte_input` | ✅ | * | `dialog_ex` | ✅ (as `dialog`) | * | `empty_screen` | ✅ | * | `file_browser` | ❌ | @@ -122,11 +122,26 @@ import type { Contract } from "../event_loop"; type Properties = { [K: string]: any }; export declare class View { + /** + * Assign value to property by name + * @param property Name of the property + * @param value Value to assign + * @version Added in JS SDK 0.1 + */ set

(property: P, value: Props[P]): void; } export declare class ViewFactory> { + /** + * Create view instance with default values, can be changed later with set() + * @version Added in JS SDK 0.1 + */ make(): V; + /** + * Create view instance with custom values, can be changed later with set() + * @param initial Dictionary of property names to values + * @version Added in JS SDK 0.1 + */ makeWith(initial: Partial): V; } @@ -144,6 +159,11 @@ declare class ViewDispatcher { * @version Added in JS SDK 0.1 */ navigation: Contract; + /** + * View object currently shown + * @version Added in JS SDK 0.1 + */ + currentView: View; /** * Sends a number to the custom event handler * @param event number to send diff --git a/applications/system/js_app/packages/fz-sdk/notification/index.d.ts b/applications/system/js_app/packages/fz-sdk/notification/index.d.ts index 2199a14794c..499994d3a32 100644 --- a/applications/system/js_app/packages/fz-sdk/notification/index.d.ts +++ b/applications/system/js_app/packages/fz-sdk/notification/index.d.ts @@ -14,6 +14,7 @@ export declare function success(): void; /** * @brief Signals failure to the user via the color LED, speaker and vibration * motor + * @version Added in JS SDK 0.1 */ export declare function error(): void; diff --git a/applications/system/js_app/packages/fz-sdk/package.json b/applications/system/js_app/packages/fz-sdk/package.json index 219b2645b6c..4d18f3f2019 100644 --- a/applications/system/js_app/packages/fz-sdk/package.json +++ b/applications/system/js_app/packages/fz-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@flipperdevices/fz-sdk", - "version": "0.1.0", + "version": "0.1.1", "description": "Type declarations and documentation for native JS modules available on Flipper Zero", "keywords": [ "flipper", @@ -15,14 +15,12 @@ "directory": "applications/system/js_app/packages/fz-sdk" }, "type": "module", - "devDependencies": { + "dependencies": { "esbuild": "^0.24.0", "esbuild-plugin-tsc": "^0.4.0", "json5": "^2.2.3", "typedoc": "^0.26.10", - "typedoc-material-theme": "^1.1.0" - }, - "dependencies": { + "typedoc-material-theme": "^1.1.0", "prompts": "^2.4.2", "serialport": "^12.0.0" }