@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,106 @@
|
|
|
1
|
+
// elur_fonts.cpp — ver header. fonts.json del bundle:
|
|
2
|
+
// {"fonts": {"<familia declarada>": [{file, weight?, style?}]}}
|
|
3
|
+
// Por cara: FcConfigAppFontAddFile registra el archivo (su familia
|
|
4
|
+
// real queda disponible); fontconfig elige la cara correcta dentro
|
|
5
|
+
// de la familia por weight/style de la propia fuente. El alias
|
|
6
|
+
// declarada→real se sirve vía resolveFamily() — ver header.
|
|
7
|
+
|
|
8
|
+
#include "elur_fonts.h"
|
|
9
|
+
#include "elur_modules.h"
|
|
10
|
+
#include <fontconfig/fontconfig.h>
|
|
11
|
+
#include <glib.h>
|
|
12
|
+
#include <unordered_map>
|
|
13
|
+
|
|
14
|
+
namespace {
|
|
15
|
+
|
|
16
|
+
std::unordered_map<std::string, std::string> g_aliases;
|
|
17
|
+
|
|
18
|
+
// Familia real de un archivo de fuente (name table vía FreeType).
|
|
19
|
+
std::string realFamily(const std::string &path) {
|
|
20
|
+
int count = 0;
|
|
21
|
+
FcPattern *pat = FcFreeTypeQuery(
|
|
22
|
+
reinterpret_cast<const FcChar8 *>(path.c_str()), 0, nullptr, &count);
|
|
23
|
+
std::string fam;
|
|
24
|
+
if (pat) {
|
|
25
|
+
FcChar8 *f = nullptr;
|
|
26
|
+
if (FcPatternGetString(pat, FC_FAMILY, 0, &f) == FcResultMatch && f)
|
|
27
|
+
fam = reinterpret_cast<const char *>(f);
|
|
28
|
+
FcPatternDestroy(pat);
|
|
29
|
+
}
|
|
30
|
+
return fam;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
} // namespace
|
|
34
|
+
|
|
35
|
+
void elur::fonts::registerBundleFonts(const std::string &bundleDir) {
|
|
36
|
+
std::string dir = bundleDir + "/fonts";
|
|
37
|
+
std::string manifestPath = dir + "/fonts.json";
|
|
38
|
+
gchar *buf = nullptr;
|
|
39
|
+
gsize len = 0;
|
|
40
|
+
if (!g_file_get_contents(manifestPath.c_str(), &buf, &len, nullptr))
|
|
41
|
+
return; // app sin fuentes declarativas — fuentes del sistema
|
|
42
|
+
|
|
43
|
+
elur::modules::Json doc;
|
|
44
|
+
if (!elur::modules::jsonParse(buf, doc)) {
|
|
45
|
+
g_warning("[elur-fonts] fonts.json inválido — se ignora (%.80s)", buf);
|
|
46
|
+
g_free(buf);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
g_free(buf);
|
|
50
|
+
const elur::modules::Json *fonts = doc.get("fonts");
|
|
51
|
+
if (!fonts || fonts->kind != elur::modules::Json::Obj)
|
|
52
|
+
return;
|
|
53
|
+
|
|
54
|
+
FcConfig *cfg = FcConfigGetCurrent();
|
|
55
|
+
int registered = 0;
|
|
56
|
+
for (auto &[declared, faces] : fonts->obj) {
|
|
57
|
+
if (faces.kind != elur::modules::Json::Arr)
|
|
58
|
+
continue;
|
|
59
|
+
for (auto &face : faces.arr) {
|
|
60
|
+
const elur::modules::Json *f = face.get("file");
|
|
61
|
+
if (!f || f->str.empty())
|
|
62
|
+
continue;
|
|
63
|
+
std::string path = dir + "/" + f->str;
|
|
64
|
+
if (!g_file_test(path.c_str(), G_FILE_TEST_EXISTS)) {
|
|
65
|
+
g_warning("[elur-fonts] %s no existe — omitida", path.c_str());
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (!FcConfigAppFontAddFile(
|
|
69
|
+
cfg, reinterpret_cast<const FcChar8 *>(path.c_str()))) {
|
|
70
|
+
g_warning("[elur-fonts] fontconfig rechazó %s", path.c_str());
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
registered++;
|
|
74
|
+
std::string real = realFamily(path);
|
|
75
|
+
if (!real.empty() && real != declared)
|
|
76
|
+
g_aliases[declared] = real;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (registered)
|
|
80
|
+
g_message("[elur-fonts] %d cara(s) registradas (%zu alias)", registered,
|
|
81
|
+
g_aliases.size());
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const std::string &elur::fonts::resolveFamily(const std::string &declared) {
|
|
85
|
+
auto it = g_aliases.find(declared);
|
|
86
|
+
return it != g_aliases.end() ? it->second : declared;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
std::string elur::fonts::resolveStack(const std::string &stack) {
|
|
90
|
+
auto comma = stack.find(',');
|
|
91
|
+
std::string first =
|
|
92
|
+
comma == std::string::npos ? stack : stack.substr(0, comma);
|
|
93
|
+
// trim + descomilla la primera familia del stack
|
|
94
|
+
auto b = first.find_first_not_of(" \t");
|
|
95
|
+
auto e = first.find_last_not_of(" \t");
|
|
96
|
+
if (b == std::string::npos)
|
|
97
|
+
return stack;
|
|
98
|
+
first = first.substr(b, e - b + 1);
|
|
99
|
+
if (first.size() > 1 && first.front() == '"' && first.back() == '"')
|
|
100
|
+
first = first.substr(1, first.size() - 2);
|
|
101
|
+
const std::string &real = resolveFamily(first);
|
|
102
|
+
if (real == first)
|
|
103
|
+
return stack; // no declarada → stack intacto (genéricas/sistema)
|
|
104
|
+
return "\"" + real + "\"" +
|
|
105
|
+
(comma == std::string::npos ? "" : stack.substr(comma));
|
|
106
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// elur_fonts.h — registro de fuentes declarativas del bundle en el
|
|
2
|
+
// host Linux (ADR-0135, port del carril Android/web):
|
|
3
|
+
// <bundleDir>/fonts/fonts.json (mismo manifiesto que assets de
|
|
4
|
+
// Android) + archivos TTF/OTF junto a él.
|
|
5
|
+
//
|
|
6
|
+
// La familia declarada (p.ej. "Mareas Serif") NO es la familia real
|
|
7
|
+
// del archivo ("DejaVu Serif") — el host registra cada cara en
|
|
8
|
+
// fontconfig del proceso (la familia real pasa a existir) y expone
|
|
9
|
+
// resolveFamily() con el mapa declarada→real. La traducción ocurre
|
|
10
|
+
// en el aplicador al emitir `font-family` CSS — fontconfig ignora
|
|
11
|
+
// reglas <match>/<alias> inyectadas en runtime
|
|
12
|
+
// (FcConfigParseAndLoadFromMemory parsea pero no sustituye), así que
|
|
13
|
+
// el alias vive en el host, no en la config.
|
|
14
|
+
#pragma once
|
|
15
|
+
|
|
16
|
+
#include <string>
|
|
17
|
+
|
|
18
|
+
namespace elur::fonts {
|
|
19
|
+
|
|
20
|
+
// Registra las fuentes del bundle en fontconfig del proceso. Llamar
|
|
21
|
+
// tras gtk_init (FcConfigGetCurrent listo) y antes de crear widgets.
|
|
22
|
+
void registerBundleFonts(const std::string &bundleDir);
|
|
23
|
+
|
|
24
|
+
// Familia real para una familia declarada — identidad si no hay alias.
|
|
25
|
+
const std::string &resolveFamily(const std::string &declared);
|
|
26
|
+
|
|
27
|
+
// Stack CSS ("A", B, serif): traduce solo la primera familia si es
|
|
28
|
+
// declarada → real citada; el resto queda de fallback intacto.
|
|
29
|
+
std::string resolveStack(const std::string &stack);
|
|
30
|
+
|
|
31
|
+
} // namespace elur::fonts
|