@geastack/core 0.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +36 -0
  3. package/app_frame_perf.cpp +77 -0
  4. package/css.d.ts +1 -0
  5. package/events.cpp +67 -0
  6. package/gea_app_entry.cpp +317 -0
  7. package/gea_sources.mjs +126 -0
  8. package/gea_sources.sh +36 -0
  9. package/include/app.h +60 -0
  10. package/include/apps.h +46 -0
  11. package/include/audio.h +90 -0
  12. package/include/ble.h +212 -0
  13. package/include/bluetooth/hid_profile.h +92 -0
  14. package/include/camera.h +107 -0
  15. package/include/canvas.h +290 -0
  16. package/include/display.h +390 -0
  17. package/include/display_present.h +869 -0
  18. package/include/event.h +32 -0
  19. package/include/events.h +116 -0
  20. package/include/gea/embedded.h +13 -0
  21. package/include/gea/reactive_runtime.h +32 -0
  22. package/include/gea.h +14 -0
  23. package/include/gea_perf_config.h +96 -0
  24. package/include/geaos/abi.h +165 -0
  25. package/include/geolocation.h +126 -0
  26. package/include/gpio.h +61 -0
  27. package/include/graphics/font.h +122 -0
  28. package/include/i2c.h +20 -0
  29. package/include/image.h +156 -0
  30. package/include/imu.h +23 -0
  31. package/include/input.h +33 -0
  32. package/include/memory.h +52 -0
  33. package/include/pixel.h +907 -0
  34. package/include/platform/file_cache.h +18 -0
  35. package/include/power.h +11 -0
  36. package/include/runtime.h +83 -0
  37. package/include/services/app_runner.h +10 -0
  38. package/include/services/app_state.h +14 -0
  39. package/include/services/battery_service.h +12 -0
  40. package/include/services/bluetooth_service.h +13 -0
  41. package/include/services/diagnostics.h +76 -0
  42. package/include/services/diagnostics_platform.h +54 -0
  43. package/include/services/frame_scheduler.h +71 -0
  44. package/include/services/mirror.h +49 -0
  45. package/include/services/network_services.h +25 -0
  46. package/include/services/ota.h +32 -0
  47. package/include/services/runtime_log.h +11 -0
  48. package/include/services/storage_service.h +26 -0
  49. package/include/touch.h +38 -0
  50. package/include/ui/signal.h +149 -0
  51. package/include/wifi.h +67 -0
  52. package/index.d.ts +1940 -0
  53. package/jsx.d.ts +1 -0
  54. package/package.json +70 -0
  55. package/runtime/ble.ts +49 -0
  56. package/runtime/color.ts +21 -0
  57. package/runtime/compiler.ts +43 -0
  58. package/runtime/host.ts +1083 -0
  59. package/runtime/images.ts +129 -0
  60. package/runtime/primitives.ts +49 -0
  61. package/runtime-surface.ts +180 -0
  62. package/runtime.cpp +431 -0
  63. package/runtime.ts +34 -0
  64. package/scripts/build-gea-vite-geatsc.mjs +4514 -0
  65. package/scripts/dotenv-defines.mjs +98 -0
  66. package/scripts/gea-bundle-type-hints.mjs +546 -0
  67. package/scripts/gea-embedded-compat-staging.mjs +17 -0
  68. package/scripts/gea-embedded-compat-transform.mjs +427 -0
  69. package/scripts/gea-vite-module-graph-plugin.mjs +578 -0
  70. package/scripts/generate-gea-embedded-assets.mjs +296 -0
  71. package/scripts/generate-gea-embedded-fonts.mjs +1252 -0
  72. package/scripts/generate-installed-app-plan.mjs +55 -0
  73. package/scripts/native-object-cache.sh +244 -0
package/include/ble.h ADDED
@@ -0,0 +1,212 @@
1
+ #pragma once
2
+
3
+ #include <cstdint>
4
+
5
+ namespace gea::framework::bluetooth {
6
+
7
+ class BluetoothHidDriver {
8
+ public:
9
+ virtual ~BluetoothHidDriver() = default;
10
+
11
+ virtual void preinit() = 0;
12
+ virtual void init(const char *deviceName, std::uint16_t appearance, const char *macAddress = nullptr) = 0;
13
+ virtual bool enabled() const = 0;
14
+ virtual void setEnabled(bool enabled) = 0;
15
+ virtual void startAdvertising() = 0;
16
+ virtual void stopAdvertising() = 0;
17
+ virtual bool connected() const = 0;
18
+ virtual bool bound() const = 0;
19
+ virtual std::uint8_t batteryLevel() const = 0;
20
+ virtual const char *mac() = 0;
21
+ virtual const char *deviceName() const = 0;
22
+ virtual void keyTap(int hidCode) = 0;
23
+ virtual void keyDown(int modifier, int hidCode) = 0;
24
+ virtual void keyUp() = 0;
25
+ virtual void mouseMove(int dx, int dy, int buttons, int wheel) = 0;
26
+ virtual void mouseClick(int button) = 0;
27
+ virtual void setBatteryLevel(std::uint8_t level) = 0;
28
+
29
+ // BLE-MIDI (MIDI over GATT, service 03B80E5A-EDE8-4B33-A751-6CE34EC4C700).
30
+ // Optional capability: drivers that do not implement it inherit these
31
+ // no-ops, so the HID-only targets are unaffected. midiEnable() registers
32
+ // the MIDI service in the GATT database (call before/independent of
33
+ // init(); the driver folds it into its advertising data). midiSend()
34
+ // transmits one already-framed BLE-MIDI packet (header + timestamp +
35
+ // MIDI bytes) as a notification on the MIDI I/O characteristic.
36
+ virtual void midiEnable() {}
37
+ virtual bool midiBound() const { return false; }
38
+ virtual void midiSend(const std::uint8_t *packet, int length)
39
+ {
40
+ (void)packet;
41
+ (void)length;
42
+ }
43
+
44
+ // BLE-MIDI central role: scan for BLE-MIDI peripherals (WIDI adapters,
45
+ // pedals), connect as a GATT client, and write framed packets to the
46
+ // peer's MIDI I/O characteristic. One role is active at a time: starting
47
+ // a scan stops advertising; a central link suppresses re-advertising.
48
+ virtual void midiStartScan() {}
49
+ virtual void midiStopScan() {}
50
+ virtual bool midiScanning() const { return false; }
51
+ virtual int midiScanCount() const { return 0; }
52
+ virtual const char *midiScanNameAt(int index)
53
+ {
54
+ (void)index;
55
+ return "";
56
+ }
57
+ virtual void midiConnect(int index) { (void)index; }
58
+ virtual void midiDisconnect() {}
59
+
60
+ // HID host role: the device acts as a BLE central hosting a remote HID
61
+ // peripheral (a keyboard/macro pad such as the XPPen ACK05). Scan,
62
+ // connect, subscribe to every input-report characteristic in the peer's
63
+ // HID service, and queue the raw notification payloads for the app to
64
+ // poll and decode. Optional capability with no-op defaults like MIDI.
65
+ virtual void hidHostStartScan() {}
66
+ virtual void hidHostStopScan() {}
67
+ virtual bool hidHostScanning() const { return false; }
68
+ virtual int hidHostScanCount() const { return 0; }
69
+ virtual const char *hidHostScanNameAt(int index)
70
+ {
71
+ (void)index;
72
+ return "";
73
+ }
74
+ virtual void hidHostConnect(int index) { (void)index; }
75
+ virtual void hidHostDisconnect() {}
76
+ virtual bool hidHostBound() const { return false; }
77
+ // Raw input-report queue (oldest first). reportIdAt() is the report ID
78
+ // the notification came from; bytes are the payload after the ID.
79
+ virtual int hidHostReportCount() const { return 0; }
80
+ virtual int hidHostReportIdAt(int index) const
81
+ {
82
+ (void)index;
83
+ return 0;
84
+ }
85
+ virtual int hidHostReportLenAt(int index) const
86
+ {
87
+ (void)index;
88
+ return 0;
89
+ }
90
+ virtual int hidHostReportByteAt(int index, int byteIndex) const
91
+ {
92
+ (void)index;
93
+ (void)byteIndex;
94
+ return 0;
95
+ }
96
+ virtual void hidHostClearReports() {}
97
+
98
+ // Connection registry across every role this device holds at once.
99
+ // kind: 0 = central peer connected TO us while we serve HID (a desktop
100
+ // using us as keyboard/mouse), 1 = central peer on our MIDI service (a
101
+ // DAW), 2 = HID peripheral WE host (the XPPen), 3 = BLE-MIDI peripheral
102
+ // WE drive (the pedal/WIDI adapter).
103
+ virtual int connectionCount() const { return 0; }
104
+ virtual int connectionKindAt(int index) const
105
+ {
106
+ (void)index;
107
+ return 0;
108
+ }
109
+ virtual const char *connectionNameAt(int index)
110
+ {
111
+ (void)index;
112
+ return "";
113
+ }
114
+
115
+ // Config service (custom GATT, service A1E0F000-...). A Web Bluetooth
116
+ // portal reads the app's config blob and writes a new one, gated by a
117
+ // 4-digit pairing code shown on the device. Optional capability with
118
+ // no-op defaults like MIDI/HID-host. configSetDocument() publishes the
119
+ // blob the portal reads back; configPending*() expose a committed inbound
120
+ // blob for the app to drain; the pairing trio drives the on-device
121
+ // pairing overlay.
122
+ virtual void configSetDocument(const std::uint8_t *bytes, int length)
123
+ {
124
+ (void)bytes;
125
+ (void)length;
126
+ }
127
+ virtual int configPendingLength() const { return 0; }
128
+ virtual int configPendingByteAt(int index) const
129
+ {
130
+ (void)index;
131
+ return 0;
132
+ }
133
+ virtual void configConsumePending() {}
134
+ virtual bool configPairing() const { return false; }
135
+ virtual const char *configPairCode() { return ""; }
136
+ virtual void configDismissPairing() {}
137
+
138
+ // Device -> portal activity push. When a control fires on the device, the
139
+ // app calls this with the control's index; a driver that hosts the config
140
+ // service sends a CTRL notification (opcode 0xA0 + index) so a subscribed
141
+ // portal can highlight the matching control live. No-op default.
142
+ virtual void configPushActivity(int index) { (void)index; }
143
+ };
144
+
145
+ class BluetoothHidDevice {
146
+ public:
147
+ static void setDriver(BluetoothHidDriver *driver);
148
+ static BluetoothHidDriver *driver();
149
+
150
+ void preinit() const;
151
+ void init(const char *deviceName, std::uint16_t appearance, const char *macAddress = nullptr) const;
152
+ bool enabled() const;
153
+ void setEnabled(bool enabled) const;
154
+ void startAdvertising() const;
155
+ void stopAdvertising() const;
156
+ bool connected() const;
157
+ bool bound() const;
158
+ std::uint8_t batteryLevel() const;
159
+ const char *mac() const;
160
+ const char *deviceName() const;
161
+ void keyTap(int hidCode) const;
162
+ void keyDown(int modifier, int hidCode) const;
163
+ void keyUp() const;
164
+ void mouseMove(int dx, int dy, int buttons, int wheel) const;
165
+ void mouseClick(int button) const;
166
+ void setBatteryLevel(std::uint8_t level) const;
167
+ void midiEnable() const;
168
+ bool midiBound() const;
169
+ void midiSend(const std::uint8_t *packet, int length) const;
170
+ void midiStartScan() const;
171
+ void midiStopScan() const;
172
+ bool midiScanning() const;
173
+ int midiScanCount() const;
174
+ const char *midiScanNameAt(int index) const;
175
+ void midiConnect(int index) const;
176
+ void midiDisconnect() const;
177
+ void hidHostStartScan() const;
178
+ void hidHostStopScan() const;
179
+ bool hidHostScanning() const;
180
+ int hidHostScanCount() const;
181
+ const char *hidHostScanNameAt(int index) const;
182
+ void hidHostConnect(int index) const;
183
+ void hidHostDisconnect() const;
184
+ bool hidHostBound() const;
185
+ int hidHostReportCount() const;
186
+ int hidHostReportIdAt(int index) const;
187
+ int hidHostReportLenAt(int index) const;
188
+ int hidHostReportByteAt(int index, int byteIndex) const;
189
+ void hidHostClearReports() const;
190
+ int connectionCount() const;
191
+ int connectionKindAt(int index) const;
192
+ const char *connectionNameAt(int index) const;
193
+ void configSetDocument(const std::uint8_t *bytes, int length) const;
194
+ int configPendingLength() const;
195
+ int configPendingByteAt(int index) const;
196
+ void configConsumePending() const;
197
+ bool configPairing() const;
198
+ const char *configPairCode() const;
199
+ void configDismissPairing() const;
200
+ void configPushActivity(int index) const;
201
+ };
202
+
203
+ class Bluetooth {
204
+ public:
205
+ BluetoothHidDevice hid() const { return BluetoothHidDevice{}; }
206
+ };
207
+
208
+ inline Bluetooth bluetooth() {
209
+ return Bluetooth{};
210
+ }
211
+
212
+ } // namespace gea::framework::bluetooth
@@ -0,0 +1,92 @@
1
+ #pragma once
2
+
3
+ #include <cstddef>
4
+ #include <cstdint>
5
+ #include <cstring>
6
+
7
+ namespace gea::framework::bluetooth::hid {
8
+
9
+ struct ByteView {
10
+ const std::uint8_t *data = nullptr;
11
+ std::size_t size = 0;
12
+ };
13
+
14
+ inline constexpr std::uint16_t kServiceUuid = 0x1812;
15
+ inline constexpr std::uint16_t kBatteryServiceUuid = 0x180F;
16
+ inline constexpr std::uint16_t kInformationUuid = 0x2A4A;
17
+ inline constexpr std::uint16_t kReportMapUuid = 0x2A4B;
18
+ inline constexpr std::uint16_t kControlPointUuid = 0x2A4C;
19
+ inline constexpr std::uint16_t kProtocolModeUuid = 0x2A4E;
20
+ inline constexpr std::uint16_t kReportUuid = 0x2A4D;
21
+ inline constexpr std::uint16_t kReportReferenceUuid = 0x2908;
22
+ inline constexpr std::uint16_t kBatteryLevelUuid = 0x2A19;
23
+
24
+ inline constexpr std::uint16_t kDefaultAppearance = 0x03C2; // HID Mouse (hid-clicker is a pointer)
25
+ inline constexpr std::uint8_t kReportProtocol = 1;
26
+ inline constexpr const char *kDefaultDeviceName = "Gea Embedded BLE";
27
+
28
+ inline constexpr std::uint8_t kInformation[] = {0x0B, 0x01, 0x00, 0x15};
29
+ inline constexpr std::uint8_t kKeyboardReportReference[] = {0x01, 0x01};
30
+ inline constexpr std::uint8_t kMouseReportReference[] = {0x03, 0x01};
31
+
32
+ inline constexpr std::uint8_t kReportMap[] = {
33
+ 0x05, 0x01, 0x09, 0x06, 0xA1, 0x01, 0x85, 0x01,
34
+ 0x05, 0x07, 0x19, 0xE0, 0x29, 0xE7, 0x15, 0x00,
35
+ 0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x81, 0x02,
36
+ 0x95, 0x01, 0x75, 0x08, 0x81, 0x01, 0x95, 0x05,
37
+ 0x75, 0x01, 0x05, 0x08, 0x19, 0x01, 0x29, 0x05,
38
+ 0x91, 0x02, 0x95, 0x01, 0x75, 0x03, 0x91, 0x01,
39
+ 0x95, 0x06, 0x75, 0x08, 0x15, 0x00, 0x25, 0x65,
40
+ 0x05, 0x07, 0x19, 0x00, 0x29, 0x65, 0x81, 0x00,
41
+ 0xC0,
42
+ 0x05, 0x01, 0x09, 0x02, 0xA1, 0x01, 0x85, 0x03,
43
+ 0x09, 0x01, 0xA1, 0x00, 0x05, 0x09, 0x19, 0x01,
44
+ 0x29, 0x03, 0x15, 0x00, 0x25, 0x01, 0x95, 0x03,
45
+ 0x75, 0x01, 0x81, 0x02, 0x95, 0x01, 0x75, 0x05,
46
+ 0x81, 0x01, 0x05, 0x01, 0x09, 0x30, 0x09, 0x31,
47
+ 0x09, 0x38, 0x15, 0x81, 0x25, 0x7F, 0x75, 0x08,
48
+ 0x95, 0x03, 0x81, 0x06, 0xC0, 0xC0,
49
+ };
50
+
51
+ class KeyboardMouseReports {
52
+ public:
53
+ ByteView keyboard() const { return {keyboard_, sizeof(keyboard_)}; }
54
+ ByteView mouse() const { return {mouse_, sizeof(mouse_)}; }
55
+
56
+ void clearKeyboard() { std::memset(keyboard_, 0, sizeof(keyboard_)); }
57
+ void clearMouse() { std::memset(mouse_, 0, sizeof(mouse_)); }
58
+ void clear()
59
+ {
60
+ clearKeyboard();
61
+ clearMouse();
62
+ }
63
+
64
+ void keyDown(int modifier, int hidCode)
65
+ {
66
+ keyboard_[0] = static_cast<std::uint8_t>(modifier);
67
+ keyboard_[2] = static_cast<std::uint8_t>(hidCode);
68
+ }
69
+
70
+ void keyUp() { clearKeyboard(); }
71
+
72
+ void mouseMove(int dx, int dy, int buttons, int wheel)
73
+ {
74
+ mouse_[0] = static_cast<std::uint8_t>(buttons & 0x07);
75
+ mouse_[1] = static_cast<std::uint8_t>(clampSignedByte(dx));
76
+ mouse_[2] = static_cast<std::uint8_t>(clampSignedByte(dy));
77
+ mouse_[3] = static_cast<std::uint8_t>(clampSignedByte(wheel));
78
+ }
79
+
80
+ private:
81
+ static std::int8_t clampSignedByte(int value)
82
+ {
83
+ if (value < -127) return -127;
84
+ if (value > 127) return 127;
85
+ return static_cast<std::int8_t>(value);
86
+ }
87
+
88
+ std::uint8_t keyboard_[8] = {};
89
+ std::uint8_t mouse_[4] = {};
90
+ };
91
+
92
+ } // namespace gea::framework::bluetooth::hid
@@ -0,0 +1,107 @@
1
+ #pragma once
2
+
3
+ #include "pixel.h"
4
+
5
+ #include <cstdint>
6
+ #include <string>
7
+
8
+ namespace gea::platform::camera {
9
+
10
+ enum class Facing {
11
+ Back = 0,
12
+ Front = 1,
13
+ External = 2,
14
+ };
15
+
16
+ struct DeviceInfo {
17
+ std::string id;
18
+ Facing facing = Facing::Back;
19
+ int sensorWidth = 0;
20
+ int sensorHeight = 0;
21
+ };
22
+
23
+ // Static facade — one active camera at a time on the device. The platform
24
+ // layer maintains the live preview buffer and exposes a small surface that
25
+ // the host bridge forwards into.
26
+ class Camera {
27
+ public:
28
+ static bool isAvailable();
29
+ static bool hasPermission();
30
+ static bool requestPermission();
31
+
32
+ // facingHint: "front"|"back"|"external"|<device id>
33
+ // preferredWidth/Height: 0 = platform default. The platform may pick the
34
+ // closest supported size; query width()/height() after open() to read back.
35
+ static bool open(const std::string &facingHint, int preferredWidth, int preferredHeight);
36
+ static void close();
37
+ static bool isOpen();
38
+
39
+ static int width();
40
+ static int height();
41
+ static int orientation();
42
+ static Facing currentFacing();
43
+ static std::string currentFacingString();
44
+
45
+ static int deviceCount();
46
+ static DeviceInfo deviceAt(int index);
47
+
48
+ // Render the latest preview frame into the framebuffer at (x, y). When
49
+ // destW/destH are >0 the frame is scaled; otherwise it's drawn at its
50
+ // native capture size.
51
+ static void drawPreview(int x, int y, int destW, int destH);
52
+
53
+ // How the platform composites the live preview for a <camera> leaf node:
54
+ // 0 = Framebuffer — the runtime owns an RGB565 buffer the backend fills
55
+ // (fillPreview) and blits through the normal display
56
+ // list, so the preview obeys CSS clip / z-order.
57
+ // 1 = NativeOverlay — the backend owns a native preview surface (e.g. an
58
+ // iOS AVCaptureVideoPreviewLayer) which the runtime
59
+ // positions over the node's computed rect.
60
+ static int previewMode();
61
+
62
+ // Framebuffer mode: scale + convert the latest frame into the caller's
63
+ // native-pixel buffer of size dstWidth x dstHeight (pixel::native_t is RGB565
64
+ // on 16-bit targets, RGBA8888 on full-colour targets like iOS). `fit` is
65
+ // 0=cover, 1=contain, 2=fill; `mirror` flips horizontally. Returns true if a
66
+ // frame was written.
67
+ static bool fillPreview(gea::framework::graphics::pixel::native_t *dst, int dstWidth, int dstHeight, int fit, bool mirror);
68
+
69
+ // NativeOverlay mode: position / hide the native preview surface. The rect
70
+ // is in framebuffer pixels (the <camera> node's computed layout box).
71
+ static void positionPreviewLayer(int x, int y, int width, int height);
72
+ static void hidePreviewLayer();
73
+
74
+ // NativeOverlay mode: present one fresh frame into the positioned rect (called
75
+ // once per frame by the render tick). On the ESP32-P4 this PPA-scales the
76
+ // frame straight into the display framebuffer and flushes just that rect.
77
+ static void presentNativeOverlay();
78
+
79
+ // Captures a still and registers it with the embedded ImageStore so it
80
+ // can be drawn via image.draw(id, ...). Returns -1 on failure.
81
+ static int capture(bool mirror);
82
+
83
+ // Video recording. startRecording opens a sink at `path` (platform decides
84
+ // the container/codec — MJPEG on esp32-p4). stopRecording finalizes and
85
+ // returns the duration in milliseconds, or -1 on failure.
86
+ static bool startRecording(const std::string &path, double fps);
87
+ static double stopRecording();
88
+ static bool isRecording();
89
+
90
+ static void setFlash(const std::string &mode);
91
+ static void setZoom(double factor);
92
+ static void setMirror(bool mirror);
93
+
94
+ // Capture controls. `mode` is a lowercase keyword the backend maps to its
95
+ // native control set:
96
+ // exposure: "auto" | "continuous" | "locked" | "manual"
97
+ // whiteBalance: "auto" | "continuous" | "locked"
98
+ // focus: "auto" | "continuous" | "locked"
99
+ // torch: "off" | "on" | "auto"
100
+ // Unused numeric args are 0 (meaning "platform default / leave as is").
101
+ static void setExposure(const std::string &mode, double bias, double iso, double durationMs);
102
+ static void setWhiteBalance(const std::string &mode, double temperatureK, double tint);
103
+ static void setFocus(const std::string &mode, double pointX, double pointY);
104
+ static void setTorch(const std::string &mode, double level);
105
+ };
106
+
107
+ } // namespace gea::platform::camera