@elurjs/android 0.0.0-stage → 0.2.0
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/README.md +10 -2
- package/index.mjs +11 -0
- package/package.json +29 -4
- package/template/.gitkeep +0 -0
- package/template/app/build.gradle.kts +192 -0
- package/template/app/proguard-rules-elur.pro +12 -0
- package/template/app/proguard-rules.pro +3 -0
- package/template/app/src/main/AndroidManifest.xml +81 -0
- package/template/app/src/main/assets/oss-notices.txt +153 -0
- package/template/app/src/main/assets/tck_pixel.png +0 -0
- package/template/app/src/main/cpp/CMakeLists.txt +117 -0
- package/template/app/src/main/cpp/dlEncoder.h +117 -0
- package/template/app/src/main/cpp/dlEncoderJsi.cpp +315 -0
- package/template/app/src/main/cpp/dlEncoderQjs.cpp +394 -0
- package/template/app/src/main/cpp/dlOps.inc +145 -0
- package/template/app/src/main/cpp/elurBridge.cpp +1350 -0
- package/template/app/src/main/cpp/elurBridgeHermes.cpp +1294 -0
- package/template/app/src/main/cpp/elurSkia.cpp +287 -0
- package/template/app/src/main/cpp/elurSkiaTree.cpp +448 -0
- package/template/app/src/main/cpp/elurUiWorklet.cpp +1233 -0
- package/template/app/src/main/cpp/elurYoga.cpp +1060 -0
- package/template/app/src/main/cpp/elurYoga.h +82 -0
- package/template/app/src/main/cpp/hermes-libs/LICENSE +21 -0
- package/template/app/src/main/cpp/hermes-libs/arm64-v8a/libhermesvm.so +0 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/AsyncDebuggerAPI.h +276 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/CompileJS.h +97 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/DebuggerAPI.h +502 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/Public/CrashManager.h +107 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/Public/CtorConfig.h +145 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/Public/DebuggerTypes.h +193 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/Public/GCConfig.h +211 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/Public/GCTripwireContext.h +40 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/Public/HermesExport.h +14 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/Public/JSOutOfMemoryError.h +27 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/Public/RuntimeConfig.h +141 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/Public/SamplingProfiler.h +270 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/RuntimeTaskRunner.h +64 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/SynthTrace.h +1566 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/SynthTraceParser.h +37 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/ThreadSafetyAnalysis.h +75 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/TimerStats.h +23 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/TraceInterpreter.h +334 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/TracingRuntime.h +328 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/CDPAgent.h +131 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/CDPDebugAPI.h +73 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/CallbackOStream.h +89 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/ConsoleMessage.h +135 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/DebuggerDomainAgent.h +280 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/DebuggerDomainCoordinator.h +137 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/DomainAgent.h +107 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/DomainState.h +140 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/HeapProfilerDomainAgent.h +71 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/JSONValueInterfaces.h +40 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageConverters.h +82 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageInterfaces.h +72 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageTypes.h +1279 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/MessageTypesInlines.h +313 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/ProfilerDomainAgent.h +38 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/RemoteObjectConverters.h +77 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/RemoteObjectsTable.h +127 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/cdp/RuntimeDomainAgent.h +138 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/Dummy.h +24 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/Extensions.h +20 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/ExtensionsBytecode.h +23 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/Intrinsics.h +44 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/JSIUtils.h +123 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/TextEncoder.h +29 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/ContribDummy.h +24 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/ContribExtensions.h +23 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/TextDecoder.h +30 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/extensions/contrib/TextDecoderUtils.h +113 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/hermes.h +242 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes/hermes_tracing.h +52 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_abi/HermesABIHelpers.h +295 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_abi/HermesABIRuntimeWrapper.h +25 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_abi/hermes_abi.h +642 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_abi/hermes_vtable.h +29 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_sandbox/HermesSandboxRuntime.h +41 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_compiled.h +12 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_dbg_compiled-impl.h +8516 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_dbg_compiled.h +137 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_opt_compiled-impl.h +3945 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/hermes_sandbox_impl_opt_compiled.h +119 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/wasm-rt-fb.h +124 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/wasm-rt-impl.h +66 -0
- package/template/app/src/main/cpp/hermes-libs/include/hermes_sandbox/external/wasm-rt.h +456 -0
- package/template/app/src/main/cpp/hermes-libs/include/jsi/JSIDynamic.h +26 -0
- package/template/app/src/main/cpp/hermes-libs/include/jsi/decorator.h +1157 -0
- package/template/app/src/main/cpp/hermes-libs/include/jsi/hermes-interfaces.h +242 -0
- package/template/app/src/main/cpp/hermes-libs/include/jsi/instrumentation.h +132 -0
- package/template/app/src/main/cpp/hermes-libs/include/jsi/jsi-inl.h +434 -0
- package/template/app/src/main/cpp/hermes-libs/include/jsi/jsi.h +2266 -0
- package/template/app/src/main/cpp/hermes-libs/include/jsi/jsilib.h +59 -0
- package/template/app/src/main/cpp/hermes-libs/include/jsi/threadsafe.h +79 -0
- package/template/app/src/main/cpp/hermes-libs/jsi-impl/jsi.cpp +1111 -0
- package/template/app/src/main/cpp/hermes-libs/x86_64/libhermesvm.so +0 -0
- package/template/app/src/main/java/com/elur/universal/BinaryCodec.kt +121 -0
- package/template/app/src/main/java/com/elur/universal/DlDecoder.kt +260 -0
- package/template/app/src/main/java/com/elur/universal/DlOpsDecode.kt +158 -0
- package/template/app/src/main/java/com/elur/universal/ElurBoxDrawable.kt +161 -0
- package/template/app/src/main/java/com/elur/universal/ElurBridge.kt +238 -0
- package/template/app/src/main/java/com/elur/universal/ElurBridgeHermes.kt +223 -0
- package/template/app/src/main/java/com/elur/universal/ElurCanvasView.kt +202 -0
- package/template/app/src/main/java/com/elur/universal/ElurCryptoModule.kt +206 -0
- package/template/app/src/main/java/com/elur/universal/ElurCustomLayout.kt +185 -0
- package/template/app/src/main/java/com/elur/universal/ElurEditText.kt +17 -0
- package/template/app/src/main/java/com/elur/universal/ElurFontRegistry.kt +190 -0
- package/template/app/src/main/java/com/elur/universal/ElurHttpModule.kt +306 -0
- package/template/app/src/main/java/com/elur/universal/ElurImageService.kt +348 -0
- package/template/app/src/main/java/com/elur/universal/ElurLicensesActivity.kt +84 -0
- package/template/app/src/main/java/com/elur/universal/ElurListView.kt +954 -0
- package/template/app/src/main/java/com/elur/universal/ElurManifest.kt +117 -0
- package/template/app/src/main/java/com/elur/universal/ElurMetrics.kt +325 -0
- package/template/app/src/main/java/com/elur/universal/ElurModuleRegistrar.kt +14 -0
- package/template/app/src/main/java/com/elur/universal/ElurPermissionGate.kt +36 -0
- package/template/app/src/main/java/com/elur/universal/ElurRenderer.kt +6164 -0
- package/template/app/src/main/java/com/elur/universal/ElurRowYoga.kt +130 -0
- package/template/app/src/main/java/com/elur/universal/ElurScrollView.kt +240 -0
- package/template/app/src/main/java/com/elur/universal/ElurShellView.kt +117 -0
- package/template/app/src/main/java/com/elur/universal/ElurSkiaCanvasView.kt +162 -0
- package/template/app/src/main/java/com/elur/universal/ElurSkiaTreeRenderer.kt +968 -0
- package/template/app/src/main/java/com/elur/universal/ElurStateModule.kt +69 -0
- package/template/app/src/main/java/com/elur/universal/ElurSwipeDriver.kt +34 -0
- package/template/app/src/main/java/com/elur/universal/ElurTckModule.kt +99 -0
- package/template/app/src/main/java/com/elur/universal/ElurTextMeasure.kt +16 -0
- package/template/app/src/main/java/com/elur/universal/ElurTrace.kt +24 -0
- package/template/app/src/main/java/com/elur/universal/ElurUiModule.kt +48 -0
- package/template/app/src/main/java/com/elur/universal/ElurUiWorklet.kt +305 -0
- package/template/app/src/main/java/com/elur/universal/JsBridge.kt +67 -0
- package/template/app/src/main/java/com/elur/universal/JsThread.kt +189 -0
- package/template/app/src/main/java/com/elur/universal/MainActivity.kt +844 -0
- package/template/app/src/main/java/com/elur/universal/ModuleRegistry.kt +701 -0
- package/template/app/src/main/java/com/elur/universal/YogaRowScope.kt +97 -0
- package/template/app/src/main/res/values/ids.xml +10 -0
- package/template/app/src/main/res/values/strings.xml +8 -0
- package/template/app/src/main/res/values-es/strings.xml +5 -0
- package/template/app/src/main/res/xml/network_security_config.xml +10 -0
- package/template/build.gradle.kts +5 -0
- package/template/gradle/libs.versions.toml +12 -0
- package/template/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/template/gradle/wrapper/gradle-wrapper.properties +8 -0
- package/template/gradle.properties +23 -0
- package/template/gradlew +251 -0
- package/template/gradlew.bat +94 -0
- package/template/settings.gradle.kts +32 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// dlEncoder.h — writer del Display List binario (ABI v2, ADR-0015)
|
|
2
|
+
// Núcleo compartido por los dos engines: cada bridge implementa el walker
|
|
3
|
+
// (jsi en elurBridgeHermes, quickjs en elurBridge) y este buffer emite los
|
|
4
|
+
// mismos bytes que encodeDisplayList() de src/transport/format.ts.
|
|
5
|
+
// La paridad byte-exacta se verifica on-device via ElurBridge.encodeOps.
|
|
6
|
+
|
|
7
|
+
#pragma once
|
|
8
|
+
|
|
9
|
+
#include <cstdint>
|
|
10
|
+
#include <cstring>
|
|
11
|
+
#include <stdexcept>
|
|
12
|
+
#include <string>
|
|
13
|
+
#include <vector>
|
|
14
|
+
|
|
15
|
+
namespace elur {
|
|
16
|
+
|
|
17
|
+
enum class DLOp : uint8_t {
|
|
18
|
+
CreateNode = 1,
|
|
19
|
+
UpdateText = 2,
|
|
20
|
+
UpdateStyle = 3,
|
|
21
|
+
UpdateProps = 4,
|
|
22
|
+
InsertChild = 5,
|
|
23
|
+
RemoveChild = 6,
|
|
24
|
+
MoveChild = 7,
|
|
25
|
+
DeleteNode = 8,
|
|
26
|
+
AttachEvent = 9,
|
|
27
|
+
DetachEvent = 10,
|
|
28
|
+
NavPush = 11,
|
|
29
|
+
NavPop = 12,
|
|
30
|
+
NavReplace = 13,
|
|
31
|
+
CreatePlatformView = 14,
|
|
32
|
+
UpdatePlatformViewProps = 15,
|
|
33
|
+
SetPlatformViewVisible = 16,
|
|
34
|
+
Layout = 17,
|
|
35
|
+
// ADR-0054 — lista nativa (nivel item): plantilla + datos + mutaciones.
|
|
36
|
+
SetListTemplate = 18,
|
|
37
|
+
SetListItems = 19,
|
|
38
|
+
ListSplice = 20,
|
|
39
|
+
ListUpdate = 21,
|
|
40
|
+
ListMove = 22,
|
|
41
|
+
// ADR-0057 — reset de estado efímero al rebind del pool estructural.
|
|
42
|
+
ResetNode = 23,
|
|
43
|
+
// ADR-0108 — a11y como op dedicada: str16 key · u8 tag · payload
|
|
44
|
+
// (tags: 0=f64, 1=str16, 2=null, 3=u8 bool).
|
|
45
|
+
UpdateSemantics = 24,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
constexpr uint8_t DL_ABI_VERSION = 11; // ADR-0165: transition lleva str32 JSON en custom
|
|
49
|
+
constexpr uint8_t DL_MAGIC_HI = 0x45; // 'E'
|
|
50
|
+
constexpr uint8_t DL_MAGIC_LO = 0x4c; // 'L'
|
|
51
|
+
|
|
52
|
+
class DLBuf {
|
|
53
|
+
public:
|
|
54
|
+
std::vector<uint8_t> bytes;
|
|
55
|
+
|
|
56
|
+
void u8(uint32_t v) { bytes.push_back(static_cast<uint8_t>(v & 0xff)); }
|
|
57
|
+
void u16(uint32_t v) {
|
|
58
|
+
bytes.push_back(static_cast<uint8_t>((v >> 8) & 0xff));
|
|
59
|
+
bytes.push_back(static_cast<uint8_t>(v & 0xff));
|
|
60
|
+
}
|
|
61
|
+
void i32(int32_t v) {
|
|
62
|
+
uint32_t u = static_cast<uint32_t>(v);
|
|
63
|
+
bytes.push_back(static_cast<uint8_t>((u >> 24) & 0xff));
|
|
64
|
+
bytes.push_back(static_cast<uint8_t>((u >> 16) & 0xff));
|
|
65
|
+
bytes.push_back(static_cast<uint8_t>((u >> 8) & 0xff));
|
|
66
|
+
bytes.push_back(static_cast<uint8_t>(u & 0xff));
|
|
67
|
+
}
|
|
68
|
+
void f32(float v) {
|
|
69
|
+
uint32_t u;
|
|
70
|
+
std::memcpy(&u, &v, 4);
|
|
71
|
+
i32(static_cast<int32_t>(u));
|
|
72
|
+
}
|
|
73
|
+
// f64 big-endian (ABI v5 — payload numérico de update-style).
|
|
74
|
+
void f64(double v) {
|
|
75
|
+
uint64_t u;
|
|
76
|
+
std::memcpy(&u, &v, 8);
|
|
77
|
+
for (int i = 7; i >= 0; i--) {
|
|
78
|
+
bytes.push_back(static_cast<uint8_t>((u >> (i * 8)) & 0xff));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// >0xffff no cabe en el prefijo u16: fail-fast (truncar
|
|
82
|
+
// desincronizaría el frame) — espejo del guard de format.ts.
|
|
83
|
+
void str16(const std::string &s) {
|
|
84
|
+
if (s.size() > 0xffff) {
|
|
85
|
+
throw std::overflow_error("str16 overflow");
|
|
86
|
+
}
|
|
87
|
+
u16(static_cast<uint32_t>(s.size()));
|
|
88
|
+
bytes.insert(bytes.end(), s.begin(), s.end());
|
|
89
|
+
}
|
|
90
|
+
void str32(const std::string &s) {
|
|
91
|
+
i32(static_cast<int32_t>(s.size()));
|
|
92
|
+
bytes.insert(bytes.end(), s.begin(), s.end());
|
|
93
|
+
}
|
|
94
|
+
void header(int32_t frame, int32_t opCount) {
|
|
95
|
+
u8(DL_MAGIC_HI);
|
|
96
|
+
u8(DL_MAGIC_LO);
|
|
97
|
+
u8(DL_ABI_VERSION);
|
|
98
|
+
u8(0);
|
|
99
|
+
i32(frame);
|
|
100
|
+
i32(opCount);
|
|
101
|
+
}
|
|
102
|
+
// opCount ocupa bytes 8..11 — el encoder lo escribe antes de que el
|
|
103
|
+
// árbol Yoga emita sus ops `layout`; los que llegan después se suman.
|
|
104
|
+
void addOpCount(int32_t extra) {
|
|
105
|
+
uint32_t cur = (static_cast<uint32_t>(bytes[8]) << 24) |
|
|
106
|
+
(static_cast<uint32_t>(bytes[9]) << 16) |
|
|
107
|
+
(static_cast<uint32_t>(bytes[10]) << 8) |
|
|
108
|
+
static_cast<uint32_t>(bytes[11]);
|
|
109
|
+
cur += static_cast<uint32_t>(extra);
|
|
110
|
+
bytes[8] = static_cast<uint8_t>((cur >> 24) & 0xff);
|
|
111
|
+
bytes[9] = static_cast<uint8_t>((cur >> 16) & 0xff);
|
|
112
|
+
bytes[10] = static_cast<uint8_t>((cur >> 8) & 0xff);
|
|
113
|
+
bytes[11] = static_cast<uint8_t>(cur & 0xff);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
} // namespace elur
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
// dlEncoderJsi.cpp — walker jsi del Display List binario (ABI v2)
|
|
2
|
+
// Equivalente byte-exacto a encodeDisplayList() de src/transport/format.ts.
|
|
3
|
+
// JSON de style/props via la propia JSON.stringify del runtime — no puede
|
|
4
|
+
// divergir del path JS.
|
|
5
|
+
|
|
6
|
+
#include "dlEncoder.h"
|
|
7
|
+
#include "elurYoga.h"
|
|
8
|
+
#include <hermes/hermes.h>
|
|
9
|
+
#include <jsi/jsi.h>
|
|
10
|
+
#include <string>
|
|
11
|
+
|
|
12
|
+
using namespace facebook;
|
|
13
|
+
|
|
14
|
+
namespace elur {
|
|
15
|
+
|
|
16
|
+
static inline std::string propStr(jsi::Runtime &rt, const jsi::Object &o,
|
|
17
|
+
const char *name) {
|
|
18
|
+
auto v = o.getProperty(rt, name);
|
|
19
|
+
return v.isString() ? v.asString(rt).utf8(rt) : std::string();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static inline int32_t propI32(jsi::Runtime &rt, const jsi::Object &o,
|
|
23
|
+
const char *name) {
|
|
24
|
+
auto v = o.getProperty(rt, name);
|
|
25
|
+
return v.isNumber() ? static_cast<int32_t>(v.asNumber()) : 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static inline bool propBool(jsi::Runtime &rt, const jsi::Object &o,
|
|
29
|
+
const char *name) {
|
|
30
|
+
auto v = o.getProperty(rt, name);
|
|
31
|
+
return v.isBool() ? v.getBool() : false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// JSON.stringify(v) via el propio runtime — bytes idénticos al encoder JS.
|
|
35
|
+
static std::string jsonStringify(jsi::Runtime &rt, const jsi::Value &v) {
|
|
36
|
+
auto json = rt.global().getPropertyAsObject(rt, "JSON");
|
|
37
|
+
auto stringify = json.getPropertyAsFunction(rt, "stringify");
|
|
38
|
+
auto r = stringify.call(rt, v);
|
|
39
|
+
return r.isString() ? r.asString(rt).utf8(rt) : std::string();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// TransitionSpec.kind → u8 (system=0, none=1, custom=2)
|
|
43
|
+
static uint8_t transitionCode(jsi::Runtime &rt, const jsi::Object &op) {
|
|
44
|
+
auto t = op.getProperty(rt, "transition");
|
|
45
|
+
if (!t.isObject())
|
|
46
|
+
return 0;
|
|
47
|
+
auto kind = propStr(rt, t.asObject(rt), "kind");
|
|
48
|
+
if (kind == "none")
|
|
49
|
+
return 1;
|
|
50
|
+
if (kind == "custom")
|
|
51
|
+
return 2;
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ADR-0032: estado post-commit autoritativo de las ops nav-*
|
|
56
|
+
// (u16 depth · u8 navV · u8 n · str16 stack[n]).
|
|
57
|
+
static void navStateJsi(jsi::Runtime &rt, const jsi::Object &op, DLBuf &w) {
|
|
58
|
+
w.u16(static_cast<uint32_t>(propI32(rt, op, "depth")));
|
|
59
|
+
w.u8(static_cast<uint8_t>(propI32(rt, op, "v")));
|
|
60
|
+
auto stack = op.getProperty(rt, "stack");
|
|
61
|
+
size_t n = 0;
|
|
62
|
+
jsi::Array arr(rt, 0);
|
|
63
|
+
bool has = stack.isObject() && stack.asObject(rt).isArray(rt);
|
|
64
|
+
if (has) {
|
|
65
|
+
arr = stack.asObject(rt).asArray(rt);
|
|
66
|
+
n = arr.size(rt);
|
|
67
|
+
}
|
|
68
|
+
// >0xff no cabe en el prefijo u8: fail-fast (espejo de format.ts).
|
|
69
|
+
if (n > 0xff) {
|
|
70
|
+
throw std::overflow_error("navState stack overflow");
|
|
71
|
+
}
|
|
72
|
+
w.u8(static_cast<uint8_t>(n));
|
|
73
|
+
for (size_t i = 0; i < n; i++) {
|
|
74
|
+
auto e = arr.getValueAtIndex(rt, i);
|
|
75
|
+
w.str16(e.isString() ? e.asString(rt).utf8(rt) : std::string());
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// ABI v5 (ADR-0050): style como entradas tipadas — i32 count +
|
|
80
|
+
// [str16 key · u8 tag · f64|str16|∅]. Mismo layout que el encoder JS
|
|
81
|
+
// y el QJS — la paridad byte-exacta la verifica enc-parity on-device.
|
|
82
|
+
static void encodeStyleJsi(jsi::Runtime &rt, const jsi::Value &styleV,
|
|
83
|
+
DLBuf &w) {
|
|
84
|
+
if (!styleV.isObject()) {
|
|
85
|
+
w.i32(0);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
auto obj = styleV.asObject(rt);
|
|
89
|
+
auto names = obj.getPropertyNames(rt);
|
|
90
|
+
size_t n = names.size(rt);
|
|
91
|
+
w.i32(static_cast<int32_t>(n));
|
|
92
|
+
for (size_t i = 0; i < n; i++) {
|
|
93
|
+
auto kv = names.getValueAtIndex(rt, i);
|
|
94
|
+
if (!kv.isString())
|
|
95
|
+
continue;
|
|
96
|
+
auto kstr = kv.asString(rt).utf8(rt);
|
|
97
|
+
w.str16(kstr);
|
|
98
|
+
auto v = obj.getProperty(rt, kstr.c_str());
|
|
99
|
+
if (v.isNumber()) {
|
|
100
|
+
w.u8(0);
|
|
101
|
+
w.f64(v.asNumber());
|
|
102
|
+
} else if (v.isString()) {
|
|
103
|
+
w.u8(1);
|
|
104
|
+
w.str16(v.asString(rt).utf8(rt));
|
|
105
|
+
} else {
|
|
106
|
+
w.u8(2); // null/undefined/otro → retirada de la clave
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// ADR-0108 — entries de update-semantics: idéntico a encodeStyleJsi +
|
|
112
|
+
// tag 3 = bool(u8) — el vocabulario a11y es mayormente flags.
|
|
113
|
+
static void encodeSemanticsJsi(jsi::Runtime &rt, const jsi::Value &semV,
|
|
114
|
+
DLBuf &w) {
|
|
115
|
+
if (!semV.isObject()) {
|
|
116
|
+
w.i32(0);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
auto obj = semV.asObject(rt);
|
|
120
|
+
auto names = obj.getPropertyNames(rt);
|
|
121
|
+
size_t n = names.size(rt);
|
|
122
|
+
w.i32(static_cast<int32_t>(n));
|
|
123
|
+
for (size_t i = 0; i < n; i++) {
|
|
124
|
+
auto kv = names.getValueAtIndex(rt, i);
|
|
125
|
+
if (!kv.isString())
|
|
126
|
+
continue;
|
|
127
|
+
auto kstr = kv.asString(rt).utf8(rt);
|
|
128
|
+
w.str16(kstr);
|
|
129
|
+
auto v = obj.getProperty(rt, kstr.c_str());
|
|
130
|
+
if (v.isBool()) {
|
|
131
|
+
w.u8(3);
|
|
132
|
+
w.u8(v.getBool() ? 1 : 0);
|
|
133
|
+
} else if (v.isNumber()) {
|
|
134
|
+
w.u8(0);
|
|
135
|
+
w.f64(v.asNumber());
|
|
136
|
+
} else if (v.isString()) {
|
|
137
|
+
w.u8(1);
|
|
138
|
+
w.str16(v.asString(rt).utf8(rt));
|
|
139
|
+
} else {
|
|
140
|
+
w.u8(2); // null/undefined/otro → retirada de la clave
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// Expande batch-update (igual que el encoder JS: op contenedora no viaja).
|
|
146
|
+
static void encodeOpJsi(jsi::Runtime &rt, const jsi::Object &op, DLBuf &w);
|
|
147
|
+
|
|
148
|
+
// ADR-0119 — adaptador Obj del vocabulario wire generado (dlOps.inc):
|
|
149
|
+
// la tabla canónica wireSchema define op→campos; este adaptador es lo
|
|
150
|
+
// único engine-specific (cómo leer props de un jsi::Object).
|
|
151
|
+
class ObjJsi {
|
|
152
|
+
jsi::Runtime &rt;
|
|
153
|
+
const jsi::Object &o;
|
|
154
|
+
|
|
155
|
+
public:
|
|
156
|
+
ObjJsi(jsi::Runtime &r, const jsi::Object &ob) : rt(r), o(ob) {}
|
|
157
|
+
bool isStr(const char *n) const { return o.getProperty(rt, n).isString(); }
|
|
158
|
+
bool isObj(const char *n) const { return o.getProperty(rt, n).isObject(); }
|
|
159
|
+
bool isArr(const char *n) const {
|
|
160
|
+
auto p = o.getProperty(rt, n);
|
|
161
|
+
return p.isObject() && p.asObject(rt).isArray(rt);
|
|
162
|
+
}
|
|
163
|
+
int32_t i32(const char *n) const { return propI32(rt, o, n); }
|
|
164
|
+
double num(const char *n) const {
|
|
165
|
+
auto p = o.getProperty(rt, n);
|
|
166
|
+
return p.isNumber() ? p.asNumber() : 0.0;
|
|
167
|
+
}
|
|
168
|
+
bool b(const char *n) const { return propBool(rt, o, n); }
|
|
169
|
+
std::string s(const char *n) const { return propStr(rt, o, n); }
|
|
170
|
+
std::string json(const char *n) const {
|
|
171
|
+
return jsonStringify(rt, o.getProperty(rt, n));
|
|
172
|
+
}
|
|
173
|
+
void entries(const char *n, bool sem, DLBuf &w) const {
|
|
174
|
+
auto p = o.getProperty(rt, n);
|
|
175
|
+
if (sem)
|
|
176
|
+
encodeSemanticsJsi(rt, p, w);
|
|
177
|
+
else
|
|
178
|
+
encodeStyleJsi(rt, p, w);
|
|
179
|
+
}
|
|
180
|
+
void navState(DLBuf &w) const { navStateJsi(rt, o, w); }
|
|
181
|
+
// ABI v11 (ADR-0165): u8 kind; custom(2) → str32 JSON del spec
|
|
182
|
+
// resuelto (name + duration? + def?).
|
|
183
|
+
void transition(DLBuf &w) const {
|
|
184
|
+
uint8_t code = elur::transitionCode(rt, o);
|
|
185
|
+
w.u8(code);
|
|
186
|
+
if (code == 2) {
|
|
187
|
+
auto t = o.getProperty(rt, "transition");
|
|
188
|
+
w.str32(jsonStringify(rt, t));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
static void encodeOpsJsi(jsi::Runtime &rt, const jsi::Array &ops, DLBuf &w) {
|
|
194
|
+
size_t n = ops.size(rt);
|
|
195
|
+
for (size_t i = 0; i < n; i++) {
|
|
196
|
+
auto v = ops.getValueAtIndex(rt, i);
|
|
197
|
+
if (v.isObject())
|
|
198
|
+
encodeOpJsi(rt, v.asObject(rt), w);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
static void encodeOpJsi(jsi::Runtime &rt, const jsi::Object &op, DLBuf &w) {
|
|
203
|
+
const std::string kind = propStr(rt, op, "op");
|
|
204
|
+
// batch-update: contenedor JS-side — se expande a hojas, no viaja.
|
|
205
|
+
if (kind == "batch-update") {
|
|
206
|
+
auto inner = op.getProperty(rt, "ops");
|
|
207
|
+
if (inner.isObject() && inner.asObject(rt).isArray(rt)) {
|
|
208
|
+
encodeOpsJsi(rt, inner.asObject(rt).asArray(rt), w);
|
|
209
|
+
}
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
// ADR-0119: emit por op derivado del esquema canónico (dlOps.inc).
|
|
213
|
+
ObjJsi o(rt, op);
|
|
214
|
+
#include "dlOps.inc"
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Cuenta ops reales tras expandir batch-update recursivamente (header
|
|
218
|
+
// opCount) — espejo de countExpandedOps en src/transport/format.ts: el
|
|
219
|
+
// contenedor no viaja al wire, solo sus hojas; un batch anidado cuenta
|
|
220
|
+
// sus propias hojas, no 1 (U15).
|
|
221
|
+
static int32_t countOpsJsi(jsi::Runtime &rt, const jsi::Array &ops) {
|
|
222
|
+
int32_t n = 0;
|
|
223
|
+
size_t size = ops.size(rt);
|
|
224
|
+
for (size_t i = 0; i < size; i++) {
|
|
225
|
+
auto v = ops.getValueAtIndex(rt, i);
|
|
226
|
+
if (!v.isObject())
|
|
227
|
+
continue;
|
|
228
|
+
auto o = v.asObject(rt);
|
|
229
|
+
if (propStr(rt, o, "op") == "batch-update") {
|
|
230
|
+
auto inner = o.getProperty(rt, "ops");
|
|
231
|
+
if (inner.isObject() && inner.asObject(rt).isArray(rt))
|
|
232
|
+
n += countOpsJsi(rt, inner.asObject(rt).asArray(rt));
|
|
233
|
+
} else {
|
|
234
|
+
n++;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
return n;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// P1-TREE: el árbol Yoga observa el stream de ops (estructura + style).
|
|
241
|
+
static void yogaObserveOpJsi(jsi::Runtime &rt, const jsi::Object &op) {
|
|
242
|
+
const std::string kind = propStr(rt, op, "op");
|
|
243
|
+
if (kind == "create-node") {
|
|
244
|
+
yogaCreateNode(propI32(rt, op, "id"), propStr(rt, op, "type"));
|
|
245
|
+
} else if (kind == "create-platform-view") {
|
|
246
|
+
yogaCreateNode(propI32(rt, op, "id"), "platform-view");
|
|
247
|
+
} else if (kind == "insert-child") {
|
|
248
|
+
yogaInsertChild(propI32(rt, op, "parentId"), propI32(rt, op, "childId"),
|
|
249
|
+
propI32(rt, op, "index"));
|
|
250
|
+
} else if (kind == "remove-child") {
|
|
251
|
+
yogaRemoveChild(propI32(rt, op, "parentId"), propI32(rt, op, "childId"));
|
|
252
|
+
} else if (kind == "move-child") {
|
|
253
|
+
yogaMoveChild(propI32(rt, op, "parentId"), propI32(rt, op, "childId"),
|
|
254
|
+
propI32(rt, op, "index"));
|
|
255
|
+
} else if (kind == "delete-node") {
|
|
256
|
+
yogaDeleteNode(propI32(rt, op, "id"));
|
|
257
|
+
} else if (kind == "update-style") {
|
|
258
|
+
int id = propI32(rt, op, "id");
|
|
259
|
+
auto s = op.getProperty(rt, "style");
|
|
260
|
+
if (!s.isObject())
|
|
261
|
+
return;
|
|
262
|
+
auto so = s.asObject(rt);
|
|
263
|
+
auto names = so.getPropertyNames(rt);
|
|
264
|
+
size_t n = names.size(rt);
|
|
265
|
+
for (size_t i = 0; i < n; i++) {
|
|
266
|
+
auto kv = names.getValueAtIndex(rt, i);
|
|
267
|
+
if (!kv.isString())
|
|
268
|
+
continue;
|
|
269
|
+
std::string key = kv.asString(rt).utf8(rt);
|
|
270
|
+
auto val = so.getProperty(rt, key.c_str());
|
|
271
|
+
if (val.isNumber()) {
|
|
272
|
+
yogaSetStyle(id, key, val.asNumber(), "", true);
|
|
273
|
+
} else if (val.isString()) {
|
|
274
|
+
yogaSetStyle(id, key, 0, val.asString(rt).utf8(rt), false);
|
|
275
|
+
} else if (val.isNull() || val.isUndefined()) {
|
|
276
|
+
// ADR-0122: null/undefined = valor ausente — str vacío: `layout`
|
|
277
|
+
// lo toma como off, el resto no-op.
|
|
278
|
+
yogaSetStyle(id, key, 0, "", false);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
} else if (kind == "batch-update") {
|
|
282
|
+
auto inner = op.getProperty(rt, "ops");
|
|
283
|
+
if (inner.isObject() && inner.asObject(rt).isArray(rt)) {
|
|
284
|
+
auto arr = inner.asObject(rt).asArray(rt);
|
|
285
|
+
size_t n = arr.size(rt);
|
|
286
|
+
for (size_t i = 0; i < n; i++) {
|
|
287
|
+
auto v = arr.getValueAtIndex(rt, i);
|
|
288
|
+
if (v.isObject())
|
|
289
|
+
yogaObserveOpJsi(rt, v.asObject(rt));
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
} // namespace elur
|
|
296
|
+
|
|
297
|
+
// API pública del encoder jsi — usada por elurBridgeHermes.
|
|
298
|
+
void elurEncodeFrameJsi(jsi::Runtime &rt, int32_t frame, const jsi::Array &ops,
|
|
299
|
+
elur::DLBuf &w) {
|
|
300
|
+
w.header(frame, elur::countOpsJsi(rt, ops));
|
|
301
|
+
elur::encodeOpsJsi(rt, ops, w);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Observa ops → árbol Yoga C++ y, si dirty + viewport, emite ops layout
|
|
305
|
+
// al final del frame (P1-TREE).
|
|
306
|
+
void elurYogaObserveAndLayoutJsi(jsi::Runtime &rt, const jsi::Array &ops,
|
|
307
|
+
elur::DLBuf &buf) {
|
|
308
|
+
size_t n = ops.size(rt);
|
|
309
|
+
for (size_t i = 0; i < n; i++) {
|
|
310
|
+
auto v = ops.getValueAtIndex(rt, i);
|
|
311
|
+
if (v.isObject())
|
|
312
|
+
elur::yogaObserveOpJsi(rt, v.asObject(rt));
|
|
313
|
+
}
|
|
314
|
+
buf.addOpCount(elur::yogaLayoutIfDirty(buf));
|
|
315
|
+
}
|