@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
@@ -0,0 +1,149 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ #pragma once
3
+
4
+ #include <cstring>
5
+ #include <functional>
6
+ #include <string>
7
+ #include <utility>
8
+ #include <vector>
9
+
10
+ namespace gea::embedded::ui {
11
+
12
+ // Typed per-store notification registry for the embedded reactive renderer.
13
+ //
14
+ // Regular (CompiledStore-based) stores carry one SignalHub member; the store's
15
+ // write paths (re-lowered method dirty-flush + the dynamic proxy `set` trap)
16
+ // call `notify(field)`, and statically-dep'd renderer bindings register their
17
+ // scheduling thunk via `subscribe(field, effect)`. This replaces the dynamic
18
+ // `_priv` state-record → `direct` map → `gea_cpp_value` handler-list chain for
19
+ // those bindings: no record lookups, no boxed handler values — a flat typed
20
+ // vector with string keys (codegen literals on the subscribe side).
21
+ class SignalHub {
22
+ public:
23
+ std::size_t subscribe(const char *field, std::function<void()> effect) {
24
+ const std::size_t id = next_id_++;
25
+ entries_.push_back(Entry{field, id, std::move(effect)});
26
+ return id;
27
+ }
28
+
29
+ void unsubscribe(std::size_t id) {
30
+ for (std::size_t i = 0; i < entries_.size(); ++i) {
31
+ if (entries_[i].id == id) {
32
+ entries_.erase(entries_.begin() + static_cast<std::ptrdiff_t>(i));
33
+ return;
34
+ }
35
+ }
36
+ }
37
+
38
+ void notify(const char *field) const {
39
+ // Index-based: an effect may subscribe more entries while running.
40
+ for (std::size_t i = 0; i < entries_.size(); ++i) {
41
+ if (std::strcmp(entries_[i].field.c_str(), field) == 0 && entries_[i].effect) entries_[i].effect();
42
+ }
43
+ }
44
+
45
+ void notify(const std::string &field) const { notify(field.c_str()); }
46
+
47
+ private:
48
+ struct Entry {
49
+ std::string field;
50
+ std::size_t id;
51
+ std::function<void()> effect;
52
+ };
53
+ std::vector<Entry> entries_;
54
+ std::size_t next_id_ = 1;
55
+ };
56
+
57
+ // Typed reactive cell for the lean `ReactiveComponent` (component-as-store).
58
+ //
59
+ // A `ReactiveComponent`'s reactive fields compile to `Signal<T>` members on the
60
+ // generated instance. Reads convert to `const T&` (so `this->count + 1`,
61
+ // `gea_cpp_to_string(this->count)`, `static_cast<double>(this->count)` all work
62
+ // unchanged), and writes (`this->count = x`) assign and notify ONLY this field's
63
+ // subscribers. The mounted renderer subscribes a typed effect per node that
64
+ // reads the field, so a write re-runs exactly the effects that depend on it.
65
+ //
66
+ // Fully typed: no `gea_cpp_value`, no string-keyed observe, no Proxy. This is the
67
+ // lean counterpart to `CompiledStore`'s dynamic per-property observer map.
68
+ template <typename T>
69
+ class Signal {
70
+ public:
71
+ Signal() = default;
72
+ Signal(T value) : value_(std::move(value)) {} // NOLINT(google-explicit-constructor)
73
+
74
+ // Read. Implicit so a `Signal<T>` is a drop-in for a `T` everywhere the
75
+ // generated code reads the field (arithmetic, stringify, casts, comparisons).
76
+ operator const T &() const { return value_; } // NOLINT(google-explicit-constructor)
77
+ const T &get() const { return value_; }
78
+
79
+ // Write + notify. Unchanged-value writes are skipped so a no-op assignment
80
+ // (or a write that recomputes the same value) does not re-render.
81
+ Signal &operator=(const T &next) {
82
+ if (value_ == next) return *this;
83
+ value_ = next;
84
+ notify();
85
+ return *this;
86
+ }
87
+ Signal &operator=(T &&next) {
88
+ if (value_ == next) return *this;
89
+ value_ = std::move(next);
90
+ notify();
91
+ return *this;
92
+ }
93
+
94
+ // Comparisons against the underlying value. Needed explicitly for class types:
95
+ // e.g. std::string's operator== is a TEMPLATE, and template argument deduction
96
+ // does not consider Signal's implicit conversion, so `signal == std::string`
97
+ // finds no candidate without these. (Arithmetic types ride the implicit
98
+ // conversion to built-in operators and don't strictly need them.)
99
+ friend bool operator==(const Signal &lhs, const T &rhs) { return lhs.value_ == rhs; }
100
+ friend bool operator==(const T &lhs, const Signal &rhs) { return lhs == rhs.value_; }
101
+ friend bool operator!=(const Signal &lhs, const T &rhs) { return !(lhs.value_ == rhs); }
102
+ friend bool operator!=(const T &lhs, const Signal &rhs) { return !(lhs == rhs.value_); }
103
+
104
+ // Register a typed effect. Called once per reactive node by the mounted
105
+ // renderer; the effect re-reads the field and updates its node.
106
+ //
107
+ // Returns a token, exactly like `SignalHub::subscribe` above, so an effect
108
+ // whose node is gone can be released. A renderer that rebuilds a list
109
+ // re-subscribes the SAME element cells (they live in the store and survive
110
+ // the rebuild), so without a release the subscriber list grows without bound
111
+ // AND the previous generation's effects keep writing to node ids the tree has
112
+ // since recycled -- a silent cross-wire, not a crash. Existing callers that
113
+ // ignore the return value are unaffected.
114
+ std::size_t subscribe(std::function<void()> effect) const {
115
+ const std::size_t id = next_id_++;
116
+ subscribers_.push_back(Entry{id, std::move(effect)});
117
+ return id;
118
+ }
119
+
120
+ void unsubscribe(std::size_t id) const {
121
+ for (std::size_t i = 0; i < subscribers_.size(); ++i) {
122
+ if (subscribers_[i].id == id) {
123
+ subscribers_.erase(subscribers_.begin() + static_cast<std::ptrdiff_t>(i));
124
+ return;
125
+ }
126
+ }
127
+ }
128
+
129
+ void notify() const {
130
+ // Index-based and size-rechecked, matching `SignalHub::notify`: an effect
131
+ // may subscribe or release entries while it runs.
132
+ for (std::size_t i = 0; i < subscribers_.size(); ++i) {
133
+ if (subscribers_[i].effect) subscribers_[i].effect();
134
+ }
135
+ }
136
+
137
+ private:
138
+ struct Entry {
139
+ std::size_t id;
140
+ std::function<void()> effect;
141
+ };
142
+ T value_{};
143
+ // `mutable` so `notify()` can stay `const` and so the auto-emitted (and
144
+ // neutralized) `__gea_to_value() const` never forces a non-const path.
145
+ mutable std::vector<Entry> subscribers_;
146
+ mutable std::size_t next_id_ = 1;
147
+ };
148
+
149
+ } // namespace gea::embedded::ui
package/include/wifi.h ADDED
@@ -0,0 +1,67 @@
1
+ #pragma once
2
+
3
+ #include <cstddef>
4
+ #include <string>
5
+ #include <vector>
6
+
7
+ namespace gea::framework::network {
8
+
9
+ struct WifiNetwork {
10
+ std::string ssid;
11
+ int rssi = 0;
12
+ bool secured = false;
13
+ };
14
+
15
+ class WifiDriver {
16
+ public:
17
+ virtual ~WifiDriver() = default;
18
+
19
+ virtual bool init() = 0;
20
+ virtual bool enabled() const = 0;
21
+ virtual void setEnabled(bool enabled) = 0;
22
+ virtual bool connected() const = 0;
23
+ virtual int rssi() = 0;
24
+ virtual std::string ssid() = 0;
25
+ virtual std::string ip() const = 0;
26
+ virtual std::string mac() = 0;
27
+ virtual void configure(const std::string &ssid, const std::string &password) = 0;
28
+ virtual void scan() = 0;
29
+ virtual bool scanning() const = 0;
30
+ virtual int scanCount() const = 0;
31
+ virtual WifiNetwork networkAt(int index) const = 0;
32
+ virtual std::vector<WifiNetwork> scanResults() const = 0;
33
+ virtual void setWebState(bool connected, const char *ssid, const char *ip, int rssi);
34
+ virtual void setWebScanCount(int count);
35
+ virtual void setWebScanEntry(int index, const char *ssid, int rssi, bool secured);
36
+ };
37
+
38
+ class WifiAdapter {
39
+ public:
40
+ static void setDriver(WifiDriver *driver);
41
+ static WifiDriver *driver();
42
+
43
+ bool init() const;
44
+ bool enabled() const;
45
+ void setEnabled(bool enabled) const;
46
+ bool connected() const;
47
+ int rssi() const;
48
+ std::string ssid() const;
49
+ std::string ip() const;
50
+ std::string mac() const;
51
+ void configure(const std::string &ssid, const std::string &password) const;
52
+ void scan() const;
53
+ bool scanning() const;
54
+ int scanCount() const;
55
+ WifiNetwork networkAt(int index) const;
56
+ std::vector<WifiNetwork> scanResults() const;
57
+ void setWebState(bool connected, const char *ssid, const char *ip, int rssi) const;
58
+ void setWebScanCount(int count) const;
59
+ void setWebScanEntry(int index, const char *ssid, int rssi, bool secured) const;
60
+ };
61
+
62
+ inline WifiAdapter wifi()
63
+ {
64
+ return WifiAdapter{};
65
+ }
66
+
67
+ } // namespace gea::framework::network