@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.
- package/LICENSE +202 -0
- package/README.md +36 -0
- package/app_frame_perf.cpp +77 -0
- package/css.d.ts +1 -0
- package/events.cpp +67 -0
- package/gea_app_entry.cpp +317 -0
- package/gea_sources.mjs +126 -0
- package/gea_sources.sh +36 -0
- package/include/app.h +60 -0
- package/include/apps.h +46 -0
- package/include/audio.h +90 -0
- package/include/ble.h +212 -0
- package/include/bluetooth/hid_profile.h +92 -0
- package/include/camera.h +107 -0
- package/include/canvas.h +290 -0
- package/include/display.h +390 -0
- package/include/display_present.h +869 -0
- package/include/event.h +32 -0
- package/include/events.h +116 -0
- package/include/gea/embedded.h +13 -0
- package/include/gea/reactive_runtime.h +32 -0
- package/include/gea.h +14 -0
- package/include/gea_perf_config.h +96 -0
- package/include/geaos/abi.h +165 -0
- package/include/geolocation.h +126 -0
- package/include/gpio.h +61 -0
- package/include/graphics/font.h +122 -0
- package/include/i2c.h +20 -0
- package/include/image.h +156 -0
- package/include/imu.h +23 -0
- package/include/input.h +33 -0
- package/include/memory.h +52 -0
- package/include/pixel.h +907 -0
- package/include/platform/file_cache.h +18 -0
- package/include/power.h +11 -0
- package/include/runtime.h +83 -0
- package/include/services/app_runner.h +10 -0
- package/include/services/app_state.h +14 -0
- package/include/services/battery_service.h +12 -0
- package/include/services/bluetooth_service.h +13 -0
- package/include/services/diagnostics.h +76 -0
- package/include/services/diagnostics_platform.h +54 -0
- package/include/services/frame_scheduler.h +71 -0
- package/include/services/mirror.h +49 -0
- package/include/services/network_services.h +25 -0
- package/include/services/ota.h +32 -0
- package/include/services/runtime_log.h +11 -0
- package/include/services/storage_service.h +26 -0
- package/include/touch.h +38 -0
- package/include/ui/signal.h +149 -0
- package/include/wifi.h +67 -0
- package/index.d.ts +1940 -0
- package/jsx.d.ts +1 -0
- package/package.json +70 -0
- package/runtime/ble.ts +49 -0
- package/runtime/color.ts +21 -0
- package/runtime/compiler.ts +43 -0
- package/runtime/host.ts +1083 -0
- package/runtime/images.ts +129 -0
- package/runtime/primitives.ts +49 -0
- package/runtime-surface.ts +180 -0
- package/runtime.cpp +431 -0
- package/runtime.ts +34 -0
- package/scripts/build-gea-vite-geatsc.mjs +4514 -0
- package/scripts/dotenv-defines.mjs +98 -0
- package/scripts/gea-bundle-type-hints.mjs +546 -0
- package/scripts/gea-embedded-compat-staging.mjs +17 -0
- package/scripts/gea-embedded-compat-transform.mjs +427 -0
- package/scripts/gea-vite-module-graph-plugin.mjs +578 -0
- package/scripts/generate-gea-embedded-assets.mjs +296 -0
- package/scripts/generate-gea-embedded-fonts.mjs +1252 -0
- package/scripts/generate-installed-app-plan.mjs +55 -0
- 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
|