@elurjs/universal 0.1.10 → 0.1.11
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/cli/create-app.mjs +4 -2
- package/cli/dev.mjs +1 -1
- package/cli/elur.mjs +18 -4
- package/docs/INSTALACION-Y-DEV.md +7 -4
- package/package.json +5 -1
- package/targets/linux/CMakeLists.txt +196 -0
- package/targets/linux/README.md +422 -0
- package/targets/linux/ci/tsan.supp +15 -0
- package/targets/linux/generated/elur_module_registrar.cpp +14 -0
- package/targets/linux/generated/module_sources.cmake +5 -0
- package/targets/linux/src/elur_applicator.cpp +5073 -0
- package/targets/linux/src/elur_applicator.h +387 -0
- package/targets/linux/src/elur_clip.cpp +76 -0
- package/targets/linux/src/elur_clip.h +23 -0
- package/targets/linux/src/elur_crypto_module.cpp +121 -0
- package/targets/linux/src/elur_events.h +57 -0
- package/targets/linux/src/elur_fonts.cpp +106 -0
- package/targets/linux/src/elur_fonts.h +31 -0
- package/targets/linux/src/elur_host.cpp +1041 -0
- package/targets/linux/src/elur_host.h +66 -0
- package/targets/linux/src/elur_http_module.cpp +437 -0
- package/targets/linux/src/elur_js.h +40 -0
- package/targets/linux/src/elur_modules.cpp +453 -0
- package/targets/linux/src/elur_modules.h +159 -0
- package/targets/linux/src/elur_renderer.h +46 -0
- package/targets/linux/src/elur_shot.cpp +64 -0
- package/targets/linux/src/elur_shot.h +17 -0
- package/targets/linux/src/elur_skia_a11y.cpp +987 -0
- package/targets/linux/src/elur_skia_a11y.h +146 -0
- package/targets/linux/src/elur_skia_app.cpp +1770 -0
- package/targets/linux/src/elur_skia_app.h +18 -0
- package/targets/linux/src/elur_state_module.cpp +99 -0
- package/targets/linux/src/elur_tck_module.cpp +186 -0
- package/targets/linux/src/elur_ui_module.cpp +84 -0
- package/targets/linux/src/elur_yoga.cpp +452 -0
- package/targets/linux/src/elur_yoga.h +95 -0
- package/targets/linux/src/main.cpp +294 -0
- package/targets/windows/Package.appxmanifest +28 -0
- package/targets/windows/README.md +44 -0
- package/targets/windows/elur-windows.vcxproj +133 -0
- package/targets/windows/packages.config +10 -0
- package/targets/windows/src/elur_crypto_module_win.cpp +106 -0
- package/targets/windows/src/elur_events.h +58 -0
- package/targets/windows/src/elur_host_win.cpp +645 -0
- package/targets/windows/src/elur_host_win.h +75 -0
- package/targets/windows/src/elur_http_module_win.cpp +331 -0
- package/targets/windows/src/elur_js.h +40 -0
- package/targets/windows/src/elur_modules.cpp +460 -0
- package/targets/windows/src/elur_modules.h +159 -0
- package/targets/windows/src/elur_state_module.cpp +99 -0
- package/targets/windows/src/elur_ui_module_win.cpp +75 -0
- package/targets/windows/src/elur_uia_host.h +129 -0
- package/targets/windows/src/elur_win_applicator.cpp +3118 -0
- package/targets/windows/src/elur_win_applicator.h +186 -0
- package/targets/windows/src/elur_yoga.cpp +452 -0
- package/targets/windows/src/elur_yoga.h +95 -0
- package/targets/windows/src/main.cpp +321 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// elur_state_module.cpp — módulo builtin "state" (U21/ADR-0075, port
|
|
2
|
+
// de ElurStateModule.kt). Retiene el último snapshot NavState que JS
|
|
3
|
+
// empuja ("save", fire-and-forget) y lo devuelve por "getRestore".
|
|
4
|
+
// La serialización es íntegramente JS — el host almacena el payload
|
|
5
|
+
// sin inspeccionarlo.
|
|
6
|
+
//
|
|
7
|
+
// En Android el medio es savedInstanceState; en escritorio no hay
|
|
8
|
+
// equivalente — el host persiste a disco write-through:
|
|
9
|
+
// $XDG_STATE_HOME/elur/<appId>/navstate.json (fallback
|
|
10
|
+
// ~/.local/state/elur/...). Escritura atómica tmp+rename. El seed se
|
|
11
|
+
// lee perezoso en el primer getRestore y queda fijo el resto de la
|
|
12
|
+
// sesión (misma semántica que restoreJson en Android).
|
|
13
|
+
|
|
14
|
+
#include "elur_modules.h"
|
|
15
|
+
|
|
16
|
+
#include <filesystem>
|
|
17
|
+
#include <fstream>
|
|
18
|
+
#include <cstdlib>
|
|
19
|
+
|
|
20
|
+
#include <string>
|
|
21
|
+
|
|
22
|
+
namespace {
|
|
23
|
+
|
|
24
|
+
std::string statePath() {
|
|
25
|
+
// %LOCALAPPDATA%\elur\<appId>\navstate.json (XDG_STATE_HOME no existe).
|
|
26
|
+
const char *base = std::getenv("LOCALAPPDATA");
|
|
27
|
+
const std::string dir = base ? base : ".";
|
|
28
|
+
return dir + "/elur/" + elur::modules::registry().appId() +
|
|
29
|
+
"/navstate.json";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Escritura atómica: tmp + rename — un crash a mitad de write no
|
|
33
|
+
// deja un snapshot truncado que el siguiente boot intente leer.
|
|
34
|
+
void writeSnapshot(const std::string &json) {
|
|
35
|
+
const std::string path = statePath();
|
|
36
|
+
const std::string dir = path.substr(0, path.rfind('/'));
|
|
37
|
+
std::error_code ec;
|
|
38
|
+
std::filesystem::create_directories(dir, ec);
|
|
39
|
+
const std::string tmp = path + ".tmp";
|
|
40
|
+
{
|
|
41
|
+
std::ofstream f(tmp, std::ios::binary | std::ios::trunc);
|
|
42
|
+
f << json;
|
|
43
|
+
if (!f) return;
|
|
44
|
+
}
|
|
45
|
+
std::filesystem::rename(tmp, path, ec);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
std::string readSnapshot() {
|
|
49
|
+
std::ifstream f(statePath(), std::ios::binary);
|
|
50
|
+
if (!f) return "";
|
|
51
|
+
std::string s((std::istreambuf_iterator<char>(f)),
|
|
52
|
+
std::istreambuf_iterator<char>());
|
|
53
|
+
return s;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
class ElurStateModule : public elur::modules::ElurModule {
|
|
57
|
+
public:
|
|
58
|
+
std::string name() const override { return "state"; }
|
|
59
|
+
|
|
60
|
+
void onCommand(int, const std::string &command, const std::string &argsJson,
|
|
61
|
+
elur::modules::Reply reply) override {
|
|
62
|
+
if (command == "save") {
|
|
63
|
+
// §4.2.2: reply único por callId — aunque JS lo invoque
|
|
64
|
+
// fire-and-forget, una invocación sin respuesta deja el slot
|
|
65
|
+
// pending ocupado hasta reset (fuga de callIds).
|
|
66
|
+
writeSnapshot(argsJson);
|
|
67
|
+
reply(true, "{}");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
if (command == "getRestore") {
|
|
71
|
+
if (!seedLoaded_) {
|
|
72
|
+
seedLoaded_ = true;
|
|
73
|
+
seed_ = readSnapshot();
|
|
74
|
+
// Snapshot truncado/corrupto → cold boot (el reader JS valida
|
|
75
|
+
// la ventana de versiones, pero un payload no-JSON rompería
|
|
76
|
+
// el reply entero — el host solo chequea la forma externa).
|
|
77
|
+
if (!seed_.empty() && seed_.front() != '{')
|
|
78
|
+
seed_.clear();
|
|
79
|
+
}
|
|
80
|
+
reply(true, seed_.empty() ? "{\"snapshot\":null}"
|
|
81
|
+
: "{\"snapshot\":" + seed_ + "}");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
reply(false,
|
|
85
|
+
"{\"code\":\"unknown_command\",\"message\":" +
|
|
86
|
+
elur::modules::jsonQuote("comando desconocido: " + command) +
|
|
87
|
+
"}");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private:
|
|
91
|
+
bool seedLoaded_ = false;
|
|
92
|
+
std::string seed_;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
} // namespace
|
|
96
|
+
|
|
97
|
+
void elurRegisterStateModule() {
|
|
98
|
+
elur::modules::registry().registerModule(std::make_unique<ElurStateModule>());
|
|
99
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// elur_ui_module_win.cpp — módulo builtin "ui" del host Windows
|
|
2
|
+
// (paridad elur_ui_module.cpp Linux, ADR-0200/0202):
|
|
3
|
+
// - setBackIntercept { active } → {} (Escape/Back de app, M1: flag
|
|
4
|
+
// almacenado — el enrutado al __elur_back llega con el key handler
|
|
5
|
+
// de ventana).
|
|
6
|
+
// - measureInWindow { id } → { x, y, width, height } lógicas.
|
|
7
|
+
|
|
8
|
+
#include "elur_host_win.h"
|
|
9
|
+
#include "elur_modules.h"
|
|
10
|
+
#include "elur_win_applicator.h"
|
|
11
|
+
#include "elur_yoga.h"
|
|
12
|
+
|
|
13
|
+
#include <cstdio>
|
|
14
|
+
#include <string>
|
|
15
|
+
|
|
16
|
+
namespace {
|
|
17
|
+
|
|
18
|
+
bool g_backIntercept = false;
|
|
19
|
+
|
|
20
|
+
class ElurUiModule : public elur::modules::ElurModule {
|
|
21
|
+
public:
|
|
22
|
+
std::string name() const override { return "ui"; }
|
|
23
|
+
|
|
24
|
+
void onCommand(int, const std::string &command,
|
|
25
|
+
const std::string &argsJson,
|
|
26
|
+
elur::modules::Reply reply) override {
|
|
27
|
+
if (command == "setBackIntercept") {
|
|
28
|
+
elur::modules::Json args;
|
|
29
|
+
if (elur::modules::jsonParse(argsJson, args)) {
|
|
30
|
+
if (auto *a = args.get("active"))
|
|
31
|
+
g_backIntercept = a->kind == elur::modules::Json::Bool && a->b;
|
|
32
|
+
}
|
|
33
|
+
reply(true, "{}");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (command == "measureInWindow") {
|
|
37
|
+
elur::modules::Json args;
|
|
38
|
+
if (!elur::modules::jsonParse(argsJson, args)) {
|
|
39
|
+
reply(false, "{\"code\":\"bad_args\"}");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
int id = 0;
|
|
43
|
+
if (auto *i = args.get("id"))
|
|
44
|
+
id = (int)i->num;
|
|
45
|
+
float x = 0, y = 0, w = 0, h = 0;
|
|
46
|
+
if (!elur::yoga::rectOf(id, x, y, w, h)) {
|
|
47
|
+
reply(false, "{\"code\":\"no_node\"}");
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
// Yoga da coords relativas al padre; la ventana = walk-up no
|
|
51
|
+
// existe en M1 — se reporta el rect del árbol (padre=root para
|
|
52
|
+
// los casos de uso actuales; TODO M2: acumular por ancestros).
|
|
53
|
+
char buf[128];
|
|
54
|
+
snprintf(buf, sizeof(buf),
|
|
55
|
+
"{\"x\":%.1f,\"y\":%.1f,\"width\":%.1f,\"height\":%.1f}",
|
|
56
|
+
x, y, w, h);
|
|
57
|
+
reply(true, buf);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
reply(false, "{\"code\":\"unknown_command\"}");
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
} // namespace
|
|
65
|
+
|
|
66
|
+
bool elurWinBackInterceptActive() { return g_backIntercept; }
|
|
67
|
+
|
|
68
|
+
void elurRegisterUiModule() {
|
|
69
|
+
elur::modules::registry().registerModule(
|
|
70
|
+
std::make_unique<ElurUiModule>());
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Registrar generado por `elur build` (ADR-0103): sin bindings de
|
|
74
|
+
// paquetes en M1 — stub vacío hasta que exista el codegen windows.
|
|
75
|
+
void elur::modules::registerGeneratedModules() {}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// elur_uia_host.h — AutomationPeer por nodo (ADR-0220): `selected`,
|
|
2
|
+
// `expanded`, `valueText` y las acciones derivadas de `expanded` no
|
|
3
|
+
// tienen attached-prop UIA — un peer propio es el único canal nativo
|
|
4
|
+
// (paridad GTK org.a11y.atspi.Action/State y Android AccessibilityNodeInfo).
|
|
5
|
+
//
|
|
6
|
+
// Modelo: todo nodo lleva `ElurHost` (ContentControl) como `el` externo
|
|
7
|
+
// y el control real dentro — el peer se materializa una vez por host y
|
|
8
|
+
// lee el estado desde `ElurA11y` (el applicator lo muta sin rehacer el
|
|
9
|
+
// árbol UIA). UIA no tiene patrón provider para acciones con nombre —
|
|
10
|
+
// `actions` sigue `no` honesto; las acciones derivadas de `expanded`
|
|
11
|
+
// sí entran por Expand()/Collapse() → evento `action` (mismo contrato
|
|
12
|
+
// que onA11yAction en GTK).
|
|
13
|
+
#pragma once
|
|
14
|
+
|
|
15
|
+
#include <functional>
|
|
16
|
+
#include <memory>
|
|
17
|
+
#include <string>
|
|
18
|
+
// commdlg.h/winuser.h (vía windows.h) definen FindText→FindTextW y
|
|
19
|
+
// GetClassName→GetClassNameW: los headers UIA generados declaran métodos
|
|
20
|
+
// con esos nombres — se desactivan durante su procesado y se restauran.
|
|
21
|
+
#pragma push_macro("FindText")
|
|
22
|
+
#pragma push_macro("GetClassName")
|
|
23
|
+
#undef FindText
|
|
24
|
+
#undef GetClassName
|
|
25
|
+
#include <winrt/Microsoft.UI.Xaml.Automation.Provider.h>
|
|
26
|
+
#include <winrt/Microsoft.UI.Xaml.Automation.Peers.h>
|
|
27
|
+
#include <winrt/Microsoft.UI.Xaml.Automation.h>
|
|
28
|
+
#pragma pop_macro("FindText")
|
|
29
|
+
#pragma pop_macro("GetClassName")
|
|
30
|
+
#include <winrt/Microsoft.UI.Xaml.Controls.h>
|
|
31
|
+
#include <winrt/Microsoft.UI.Xaml.h>
|
|
32
|
+
#include <winrt/Windows.Foundation.Collections.h>
|
|
33
|
+
#include <winrt/Windows.Foundation.h>
|
|
34
|
+
|
|
35
|
+
namespace elur {
|
|
36
|
+
|
|
37
|
+
namespace mux = winrt::Microsoft::UI::Xaml;
|
|
38
|
+
namespace muxc = winrt::Microsoft::UI::Xaml::Controls;
|
|
39
|
+
namespace muxa = winrt::Microsoft::UI::Xaml::Automation;
|
|
40
|
+
namespace muxap = winrt::Microsoft::UI::Xaml::Automation::Peers;
|
|
41
|
+
namespace muxprov = winrt::Microsoft::UI::Xaml::Automation::Provider;
|
|
42
|
+
|
|
43
|
+
// Estado a11y mutable por nodo — hasX marca "prop declarada" (el peer
|
|
44
|
+
// solo expone el patrón si el nodo lo declaró, como android/linux).
|
|
45
|
+
struct ElurA11y {
|
|
46
|
+
bool hasSel = false, sel = false;
|
|
47
|
+
bool hasExp = false, exp = false;
|
|
48
|
+
bool hasVal = false;
|
|
49
|
+
// `accessible=false` — el host sale de ControlView (Raw) y el peer
|
|
50
|
+
// corta el subárbol (paridad GTK accessible-role=NONE).
|
|
51
|
+
bool hidden = false;
|
|
52
|
+
winrt::hstring valueText{};
|
|
53
|
+
// AT invoca una acción derivada → emitEvent action {action:"<id>"}.
|
|
54
|
+
std::function<void(const char *)> invoke;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
struct ElurPeer : muxap::FrameworkElementAutomationPeerT<
|
|
58
|
+
ElurPeer, muxprov::ISelectionItemProvider,
|
|
59
|
+
muxprov::IExpandCollapseProvider,
|
|
60
|
+
muxprov::IValueProvider> {
|
|
61
|
+
ElurPeer(mux::FrameworkElement const &owner,
|
|
62
|
+
std::shared_ptr<ElurA11y> const &st)
|
|
63
|
+
: FrameworkElementAutomationPeerT(owner), st_(st) {}
|
|
64
|
+
|
|
65
|
+
winrt::Windows::Foundation::IInspectable
|
|
66
|
+
GetPatternCore(muxap::PatternInterface const &pi) {
|
|
67
|
+
if (pi == muxap::PatternInterface::SelectionItem && st_->hasSel)
|
|
68
|
+
return *this;
|
|
69
|
+
if (pi == muxap::PatternInterface::ExpandCollapse && st_->hasExp)
|
|
70
|
+
return *this;
|
|
71
|
+
if (pi == muxap::PatternInterface::Value && st_->hasVal)
|
|
72
|
+
return *this;
|
|
73
|
+
return muxap::IAutomationPeerOverridesT<ElurPeer>::GetPatternCore(pi);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// ISelectionItemProvider — estado + invocación `select`/`deselect`
|
|
77
|
+
// hacia el evento `action` (paridad GTK: AT selecciona → action).
|
|
78
|
+
bool IsSelected() { return st_->hasSel && st_->sel; }
|
|
79
|
+
muxprov::IRawElementProviderSimple SelectionContainer() {
|
|
80
|
+
return nullptr;
|
|
81
|
+
}
|
|
82
|
+
void Select() { fire("select"); }
|
|
83
|
+
void AddToSelection() { fire("select"); }
|
|
84
|
+
void RemoveFromSelection() { fire("deselect"); }
|
|
85
|
+
|
|
86
|
+
// IExpandCollapseProvider — expand/collapse son las acciones que
|
|
87
|
+
// `expanded` deriva en linux/android (ADR-0190).
|
|
88
|
+
muxa::ExpandCollapseState ExpandCollapseState() {
|
|
89
|
+
return st_->exp ? muxa::ExpandCollapseState::Expanded
|
|
90
|
+
: muxa::ExpandCollapseState::Collapsed;
|
|
91
|
+
}
|
|
92
|
+
void Expand() { fire("expand"); }
|
|
93
|
+
void Collapse() { fire("collapse"); }
|
|
94
|
+
|
|
95
|
+
// IValueProvider — valueText de solo lectura.
|
|
96
|
+
winrt::hstring Value() { return st_->hasVal ? st_->valueText : L""; }
|
|
97
|
+
bool IsReadOnly() { return true; }
|
|
98
|
+
void SetValue(winrt::hstring const &) {}
|
|
99
|
+
|
|
100
|
+
// `accessible=false` corta el subárbol: el host ya salió por
|
|
101
|
+
// AccessibilityView=Raw y aquí se podan sus hijos (los descendientes
|
|
102
|
+
// conservan su propia vista — sin poda seguirían en ControlView).
|
|
103
|
+
winrt::Windows::Foundation::Collections::IVector<muxap::AutomationPeer>
|
|
104
|
+
GetChildrenCore() {
|
|
105
|
+
if (st_->hidden)
|
|
106
|
+
return winrt::single_threaded_vector<muxap::AutomationPeer>();
|
|
107
|
+
return muxap::IAutomationPeerOverridesT<ElurPeer>::GetChildrenCore();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private:
|
|
111
|
+
std::shared_ptr<ElurA11y> st_;
|
|
112
|
+
void fire(const char *act) {
|
|
113
|
+
if (st_->invoke)
|
|
114
|
+
st_->invoke(act);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// Wrapper transparente del nodo — lleva el peer; el control real (o el
|
|
119
|
+
// Border de chrome) va como Content. ContentControlT es derivable sin
|
|
120
|
+
// IDL; los controles concretos (Button/TextBox/…) son sealed.
|
|
121
|
+
struct ElurHost : muxc::ContentControlT<ElurHost> {
|
|
122
|
+
ElurHost() = default;
|
|
123
|
+
std::shared_ptr<ElurA11y> a11y{std::make_shared<ElurA11y>()};
|
|
124
|
+
muxap::AutomationPeer OnCreateAutomationPeer() {
|
|
125
|
+
return winrt::make<ElurPeer>(*this, a11y);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
} // namespace elur
|