BSB Developer Docs
Loading...
Searching...
No Matches
js_app_launcher_i.h
1#pragma once
2
3#include "js_app_launcher.h"
4
5#include <furi.h>
6
7#include <gui/gui.h>
8#include <gui/scene_manager.h>
11
12#include <js_runner/js_runner.h>
13
14#include <js_app/js_app.h>
16
17#include <toolbox/api_lock.h>
18#include <m-array.h>
19
20#define TAG "JsAppLauncher"
21
22#define JS_APP_LAUNCHER_APP_ID "js_app_launcher"
23#define RECORD_JS_APP_LAUNCHER JS_APP_LAUNCHER_APP_ID
24
25/*
26 * Special suffix to be added to the JS application ID
27 * to force JsAppLauncher to resume it (i.e. to skip the menu).
28 *
29 * Example: "app.busy.js_example" -> "app.busy.js_example+".
30 */
31#define JS_APP_LAUNCHER_ARG_RESUME "+"
32
33typedef enum {
34 JsAppLauncherErrorNone,
35 JsAppLauncherErrorLoadFailed,
36 JsAppLauncherErrorApiVersionMismatch,
37 JsAppLauncherErrorSettingsSchemaMissing,
38 JsAppLauncherErrorSettingsSchemaInvalid,
39 JsAppLauncherErrorSettingsStorageFailure,
40 JsAppLauncherErrorSettingsLoadFailed,
41 JsAppLauncherErrorSyntaxError,
42 JsAppLauncherErrorProgramCrashed,
43 JsAppLauncherErrorMax,
44} JsAppLauncherError;
45
46typedef struct {
47 struct {
48 const char* front;
49 const char* back;
50 } primary;
51 struct {
52 const char* back;
53 } auxiliary;
55
56typedef enum {
57 JsAppLauncherApiMessageTypeInvalid,
58 JsAppLauncherApiMessageTypeStop,
59 JsAppLauncherApiMessageTypeGetAppId,
60 JsAppLauncherApiMessageTypeMax,
61} JsAppLauncherApiMessageType;
62
66
67typedef struct {
68 FuriString* app_id;
70
71typedef struct {
72 JsAppLauncherApiMessageType type;
73 JsAppLauncherStatus* status;
74 FuriApiLock lock;
75 union {
78 };
80
81typedef struct {
82 const SettingProviderSetting* settings;
83 size_t settings_count;
84 const SettingProviderSetting* selected_setting;
86
87ARRAY_DEF(JsAppLauncherSceneSetupLevels, JsAppLauncherSceneSetupLevel, M_POD_OPLIST)
88
89typedef struct {
90 FuriEventLoop* event_loop;
91 FuriMessageQueue* input_queue;
92 FuriMessageQueue* event_queue;
93 FuriMessageQueue* api_queue;
94 SceneManager* scene_manager;
95 uint32_t input_sequence_num;
96 Gui* gui;
97
98 Widget* front_window;
99 Widget* back_window;
100 FlexLayout* back_container;
101 NavBar* nav_bar;
102
103 JsApp* js_app;
104 JsAppInfo js_app_info;
105 JsAppSettingsStorage* settings_storage;
106 JsAppLauncherSceneSetupLevels_t setup_levels;
107 JsAppLauncherError error;
108 JsAppLauncherStartMode start_mode;
110
111typedef enum {
112 JsAppLauncherCustomEventIndexMax = 0x7F,
113 JsAppLauncherCustomEventScriptStarted,
114 JsAppLauncherCustomEventScriptFinished,
115 JsAppLauncherCustomEventSettingsChanged,
116 JsAppLauncherCustomEventSettingsItemSelected,
117 JsAppLauncherCustomEventLongBackPressed,
118 JsAppLauncherCustomEventSceneExitRequested,
119 JsAppLauncherCustomEventScriptErrorBase = 0x100,
120 JsAppLauncherCustomEventScriptErrorMask = 0x0ff,
121} JsAppLauncherCustomEvent;
122
123static_assert(JsRunnerErrorMax <= JsAppLauncherCustomEventScriptErrorMask + 1);
124
125void js_app_launcher_send_custom_event(JsAppLauncher* instance, uint32_t event);
126
127const JsAppLauncherErrorDesc* js_app_launcher_get_error_desc(const JsAppLauncher* instance);
128
129JsAppLauncherError js_app_launcher_translate_from_js_runner_error(JsRunnerError js_runner_error);
130
131void js_app_launcher_api_unlock_message(
132 JsAppLauncherApiMessage* api_message,
133 JsAppLauncherStatus status);
134
135void js_app_launcher_api_abort_pending_messages(JsAppLauncher* instance);
A widget that arranges its elements in flexible rows or columns.
struct FlexLayout FlexLayout
FlexLayout opaque structure.
Definition flex_layout.h:16
GUI system APIs.
JavaScript application library.
JS Application Launcher public API.
JsAppLauncherStartMode
Modes for starting JS applications.
Definition js_app_launcher.h:29
JsAppLauncherStopMode
Modes for stopping JS applications.
Definition js_app_launcher.h:38
JsAppLauncherStatus
Status codes returned by the JsApplication APIs.
Definition js_app_launcher.h:16
Settings storage bridge for JavaScript applications.
Javascript app runner.
Definition gui_i.h:48
Definition js_app.c:27
JsApp information structure.
Definition js_app.h:82
Definition js_app_launcher_i.h:67
Definition js_app_launcher_i.h:71
Definition js_app_launcher_i.h:63
Definition js_app_launcher_i.h:46
Definition js_app_launcher_i.h:89
Definition js_app_launcher_i.h:81
Definition js_app_settings_storage.c:16
Definition nav_bar.c:20
Definition scene_manager.c:13
Setting descriptor.
Definition setting_provider.h:40
Definition widget_i.h:35