Skip to content

Commit 0cf8102

Browse files
authored
Merge pull request #918 from jpudysz/feature/folly
feat: add debugPrintFollyDynamic helper to debug shadow tree updates
2 parents de519c9 + 80c633b commit 0cf8102

File tree

2 files changed

+66
-2
lines changed

2 files changed

+66
-2
lines changed

cxx/common/Helpers.h

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,4 +314,68 @@ inline void debugPrintJSIObject(jsi::Runtime& rt, std::string& name, jsi::Object
314314
log.call(rt, "===/" + name + "===");
315315
}
316316

317+
inline void debugPrintFollyDynamic(jsi::Runtime& rt, const std::string& name, const folly::dynamic& obj) {
318+
auto console = rt.global().getPropertyAsObject(rt, "console");
319+
auto log = console.getPropertyAsFunction(rt, "log");
320+
321+
std::function<void(const std::string&, const folly::dynamic&)> parser = [&](const std::string& key, const folly::dynamic& value) {
322+
if (value.isBool()) {
323+
std::string output = key + ": " + (value.getBool() ? "true" : "false");
324+
log.call(rt, output);
325+
return;
326+
}
327+
328+
if (value.isNumber()) {
329+
std::string output = key + ": " + std::to_string(value.asDouble());
330+
log.call(rt, output);
331+
return;
332+
}
333+
334+
if (value.isString()) {
335+
std::string output = key + ": " + value.getString();
336+
log.call(rt, output);
337+
return;
338+
}
339+
340+
if (value.isNull()) {
341+
std::string output = key + ": null";
342+
log.call(rt, output);
343+
return;
344+
}
345+
346+
if (value.isArray()) {
347+
for (size_t i = 0; i < value.size(); i++) {
348+
std::string arrayKey = key + ": Array[" + std::to_string(i) + "]";
349+
log.call(rt, arrayKey);
350+
parser(arrayKey, value[i]);
351+
std::string endKey = key + ": Array[end]";
352+
log.call(rt, endKey);
353+
}
354+
return;
355+
}
356+
357+
if (value.isObject()) {
358+
for (const auto& pair : value.items()) {
359+
parser(pair.first.asString(), pair.second);
360+
}
361+
return;
362+
}
363+
364+
std::string output = key + ": [Unknown type]";
365+
log.call(rt, output);
366+
};
367+
368+
log.call(rt, "===" + name + "===");
369+
370+
if (obj.isObject()) {
371+
for (const auto& pair : obj.items()) {
372+
parser(pair.first.asString(), pair.second);
373+
}
374+
} else {
375+
parser(name, obj);
376+
}
377+
378+
log.call(rt, "===/" + name + "===");
379+
}
380+
317381
}

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2331,7 +2331,7 @@ PODS:
23312331
- SocketRocket
23322332
- Yoga
23332333
- SocketRocket (0.7.1)
2334-
- Unistyles (3.0.0-nightly-20250613):
2334+
- Unistyles (3.0.3):
23352335
- boost
23362336
- DoubleConversion
23372337
- fast_float
@@ -2678,7 +2678,7 @@ SPEC CHECKSUMS:
26782678
ReactCommon: b028d09a66e60ebd83ca59d8cc9a1216360db147
26792679
RNReanimated: bc1ddb7a5352648bcf0d592256069833bf935a46
26802680
SocketRocket: d4aabe649be1e368d1318fdf28a022d714d65748
2681-
Unistyles: bb3bf4963083b85127207c42d6fd5df2b35bc63a
2681+
Unistyles: 18a8be1f8f58856842736a474e7373ed6eb98ff6
26822682
Yoga: 0c4b7d2aacc910a1f702694fa86be830386f4ceb
26832683

26842684
PODFILE CHECKSUM: a5de45e2350a9515567a6e18ca8ceea718b48523

0 commit comments

Comments
 (0)