diff --git a/packages/react-native/ReactCommon/cxxreact/ModuleRegistry.cpp b/packages/react-native/ReactCommon/cxxreact/ModuleRegistry.cpp index fe31f1a0276..b4654735105 100644 --- a/packages/react-native/ReactCommon/cxxreact/ModuleRegistry.cpp +++ b/packages/react-native/ReactCommon/cxxreact/ModuleRegistry.cpp @@ -190,7 +190,7 @@ std::optional ModuleRegistry::getConfig(const std::string& name) { // no constants or methods return std::nullopt; } else { - return ModuleConfig{index, std::move(config)}; + return ModuleConfig{.index = index, .config = std::move(config)}; } } diff --git a/packages/react-native/ReactCommon/cxxreact/RAMBundleRegistry.cpp b/packages/react-native/ReactCommon/cxxreact/RAMBundleRegistry.cpp index 1d8312292ec..29ff2885705 100644 --- a/packages/react-native/ReactCommon/cxxreact/RAMBundleRegistry.cpp +++ b/packages/react-native/ReactCommon/cxxreact/RAMBundleRegistry.cpp @@ -70,8 +70,8 @@ JSModulesUnbundle::Module RAMBundleRegistry::getModule( } return { - "seg-" + std::to_string(bundleId) + '_' + module.name, - std::move(module.code), + .name = "seg-" + std::to_string(bundleId) + '_' + module.name, + .code = std::move(module.code), }; } diff --git a/packages/react-native/ReactCommon/jserrorhandler/tests/StackTraceParserTest.cpp b/packages/react-native/ReactCommon/jserrorhandler/tests/StackTraceParserTest.cpp index 437c7deee46..54dbb2cba4d 100644 --- a/packages/react-native/ReactCommon/jserrorhandler/tests/StackTraceParserTest.cpp +++ b/packages/react-native/ReactCommon/jserrorhandler/tests/StackTraceParserTest.cpp @@ -263,36 +263,42 @@ TEST(StackTraceParser, nodeWithSpaceInPath) { EXPECT_EQ(actualStackFrames.size(), 9); std::vector expectedStackFrames = - {{R"(C:\project files\spect\src\index.js)", "Spect.get", 161, 25}, - {R"(C:\project files\spect\src\index.js)", "Object.get", 43, 35}, - {R"(C:\project files\spect\src\index.js)", - "(anonymous function).then", - 165, - 32}, - {"internal/process/task_queues.js", - "process.runNextTicks [as _tickCallback]", - 52, - 4}, - {R"(C:\project files\spect\node_modules\esm\esm.js)", - "", - 1, - 34534}, - {R"(C:\project files\spect\node_modules\esm\esm.js)", - "", - 1, - 34175}, - {R"(C:\project files\spect\node_modules\esm\esm.js)", - "process.", - 1, - 34505}, - {R"(C:\project files\spect\node_modules\esm\esm.js)", - "Function.", - 1, - 296855}, - {R"(C:\project files\spect\node_modules\esm\esm.js)", - "Function.", - 1, - 296554}}; + {{.file = R"(C:\project files\spect\src\index.js)", + .methodName = "Spect.get", + .lineNumber = 161, + .column = 25}, + {.file = R"(C:\project files\spect\src\index.js)", + .methodName = "Object.get", + .lineNumber = 43, + .column = 35}, + {.file = R"(C:\project files\spect\src\index.js)", + .methodName = "(anonymous function).then", + .lineNumber = 165, + .column = 32}, + {.file = "internal/process/task_queues.js", + .methodName = "process.runNextTicks [as _tickCallback]", + .lineNumber = 52, + .column = 4}, + {.file = R"(C:\project files\spect\node_modules\esm\esm.js)", + .methodName = "", + .lineNumber = 1, + .column = 34534}, + {.file = R"(C:\project files\spect\node_modules\esm\esm.js)", + .methodName = "", + .lineNumber = 1, + .column = 34175}, + {.file = R"(C:\project files\spect\node_modules\esm\esm.js)", + .methodName = "process.", + .lineNumber = 1, + .column = 34505}, + {.file = R"(C:\project files\spect\node_modules\esm\esm.js)", + .methodName = "Function.", + .lineNumber = 1, + .column = 296855}, + {.file = R"(C:\project files\spect\node_modules\esm\esm.js)", + .methodName = "Function.", + .lineNumber = 1, + .column = 296554}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -310,19 +316,24 @@ TEST(StackTraceParser, javaScriptCore) { EXPECT_EQ(actualStackFrames.size(), 4); std::vector expectedStackFrames = { - {"/home/test/project/App.js", "_exampleFunction", 125, 12}, - {"/home/test/project/node_modules/dep/index.js", - "_depRunCallbacks", - 77, - 44}, - {"/home/test/project/node_modules/react-native/node_modules/promise/lib/core.js", - "tryCallTwo", - 45, - 4}, - {"/home/test/project/node_modules/react-native/node_modules/promise/lib/core.js", - "doResolve", - 200, - 12}}; + {.file = "/home/test/project/App.js", + .methodName = "_exampleFunction", + .lineNumber = 125, + .column = 12}, + {.file = "/home/test/project/node_modules/dep/index.js", + .methodName = "_depRunCallbacks", + .lineNumber = 77, + .column = 44}, + {.file = + "/home/test/project/node_modules/react-native/node_modules/promise/lib/core.js", + .methodName = "tryCallTwo", + .lineNumber = 45, + .column = 4}, + {.file = + "/home/test/project/node_modules/react-native/node_modules/promise/lib/core.js", + .methodName = "doResolve", + .lineNumber = 200, + .column = 12}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -340,17 +351,41 @@ TEST(StackTraceParser, errorInReactNative) { EXPECT_EQ(actualStackFrames.size(), 11); std::vector expectedStackFrames = - {{"33.js", "s", 1, 530}, - {"1959.js", "b", 1, 1468}, - {"2932.js", "onSocketClose", 1, 726}, - {"81.js", "value", 1, 1504}, - {"102.js", "", 1, 2955}, - {"89.js", "value", 1, 1246}, - {"42.js", "value", 1, 3310}, - {"42.js", "", 1, 821}, - {"42.js", "value", 1, 2564}, - {"42.js", "value", 1, 793}, - {"[native code]", "value", std::nullopt, std::nullopt}}; + {{.file = "33.js", .methodName = "s", .lineNumber = 1, .column = 530}, + {.file = "1959.js", .methodName = "b", .lineNumber = 1, .column = 1468}, + {.file = "2932.js", + .methodName = "onSocketClose", + .lineNumber = 1, + .column = 726}, + {.file = "81.js", + .methodName = "value", + .lineNumber = 1, + .column = 1504}, + {.file = "102.js", + .methodName = "", + .lineNumber = 1, + .column = 2955}, + {.file = "89.js", + .methodName = "value", + .lineNumber = 1, + .column = 1246}, + {.file = "42.js", + .methodName = "value", + .lineNumber = 1, + .column = 3310}, + {.file = "42.js", + .methodName = "", + .lineNumber = 1, + .column = 821}, + {.file = "42.js", + .methodName = "value", + .lineNumber = 1, + .column = 2564}, + {.file = "42.js", .methodName = "value", .lineNumber = 1, .column = 793}, + {.file = "[native code]", + .methodName = "value", + .lineNumber = std::nullopt, + .column = std::nullopt}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -368,7 +403,10 @@ TEST(StackTraceParser, simpleJavaScriptCoreErrors) { EXPECT_EQ(actualStackFrames.size(), 1); std::vector expectedStackFrames = - {{"stack_traces/test", "global code", 83, 54}}; + {{.file = "stack_traces/test", + .methodName = "global code", + .lineNumber = 83, + .column = 54}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -386,10 +424,22 @@ TEST(StackTraceParser, safari6Error) { EXPECT_EQ(actualStackFrames.size(), 4); std::vector expectedStackFrames = - {{"http://path/to/file.js", "", 48, std::nullopt}, - {"http://path/to/file.js", "dumpException3", 52, std::nullopt}, - {"http://path/to/file.js", "onclick", 82, std::nullopt}, - {"[native code]", "", std::nullopt, std::nullopt}}; + {{.file = "http://path/to/file.js", + .methodName = "", + .lineNumber = 48, + .column = std::nullopt}, + {.file = "http://path/to/file.js", + .methodName = "dumpException3", + .lineNumber = 52, + .column = std::nullopt}, + {.file = "http://path/to/file.js", + .methodName = "onclick", + .lineNumber = 82, + .column = std::nullopt}, + {.file = "[native code]", + .methodName = "", + .lineNumber = std::nullopt, + .column = std::nullopt}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -407,9 +457,18 @@ TEST(StackTraceParser, safari7Error) { EXPECT_EQ(actualStackFrames.size(), 3); std::vector expectedStackFrames = - {{"http://path/to/file.js", "", 48, 21}, - {"http://path/to/file.js", "foo", 52, 14}, - {"http://path/to/file.js", "bar", 108, 106}}; + {{.file = "http://path/to/file.js", + .methodName = "", + .lineNumber = 48, + .column = 21}, + {.file = "http://path/to/file.js", + .methodName = "foo", + .lineNumber = 52, + .column = 14}, + {.file = "http://path/to/file.js", + .methodName = "bar", + .lineNumber = 108, + .column = 106}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -427,9 +486,18 @@ TEST(StackTraceParser, safari8Error) { EXPECT_EQ(actualStackFrames.size(), 3); std::vector expectedStackFrames = - {{"http://path/to/file.js", "", 47, 21}, - {"http://path/to/file.js", "foo", 52, 14}, - {"http://path/to/file.js", "bar", 108, 22}}; + {{.file = "http://path/to/file.js", + .methodName = "", + .lineNumber = 47, + .column = 21}, + {.file = "http://path/to/file.js", + .methodName = "foo", + .lineNumber = 52, + .column = 14}, + {.file = "http://path/to/file.js", + .methodName = "bar", + .lineNumber = 108, + .column = 22}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -447,9 +515,18 @@ TEST(StackTraceParser, safari8EvalError) { EXPECT_EQ(actualStackFrames.size(), 3); std::vector expectedStackFrames = - {{"[native code]", "eval", std::nullopt, std::nullopt}, - {"http://path/to/file.js", "foo", 58, 20}, - {"http://path/to/file.js", "bar", 109, 90}}; + {{.file = "[native code]", + .methodName = "eval", + .lineNumber = std::nullopt, + .column = std::nullopt}, + {.file = "http://path/to/file.js", + .methodName = "foo", + .lineNumber = 58, + .column = 20}, + {.file = "http://path/to/file.js", + .methodName = "bar", + .lineNumber = 109, + .column = 90}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -467,22 +544,34 @@ TEST(StackTraceParser, firefox3Error) { EXPECT_EQ(actualStackFrames.size(), 7); std::vector expectedStackFrames = - {{"http://127.0.0.1:8000/js/stacktrace.js", - "", - 44, - std::nullopt}, - {"http://127.0.0.1:8000/js/stacktrace.js", - "", - 31, - std::nullopt}, - {"http://127.0.0.1:8000/js/stacktrace.js", - "printStackTrace", - 18, - std::nullopt}, - {"http://127.0.0.1:8000/js/file.js", "bar", 13, std::nullopt}, - {"http://127.0.0.1:8000/js/file.js", "bar", 16, std::nullopt}, - {"http://127.0.0.1:8000/js/file.js", "foo", 20, std::nullopt}, - {"http://127.0.0.1:8000/js/file.js", "", 24, std::nullopt}}; + {{.file = "http://127.0.0.1:8000/js/stacktrace.js", + .methodName = "", + .lineNumber = 44, + .column = std::nullopt}, + {.file = "http://127.0.0.1:8000/js/stacktrace.js", + .methodName = "", + .lineNumber = 31, + .column = std::nullopt}, + {.file = "http://127.0.0.1:8000/js/stacktrace.js", + .methodName = "printStackTrace", + .lineNumber = 18, + .column = std::nullopt}, + {.file = "http://127.0.0.1:8000/js/file.js", + .methodName = "bar", + .lineNumber = 13, + .column = std::nullopt}, + {.file = "http://127.0.0.1:8000/js/file.js", + .methodName = "bar", + .lineNumber = 16, + .column = std::nullopt}, + {.file = "http://127.0.0.1:8000/js/file.js", + .methodName = "foo", + .lineNumber = 20, + .column = std::nullopt}, + {.file = "http://127.0.0.1:8000/js/file.js", + .methodName = "", + .lineNumber = 24, + .column = std::nullopt}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -500,13 +589,34 @@ TEST(StackTraceParser, firefox7Error) { EXPECT_EQ(actualStackFrames.size(), 7); std::vector expectedStackFrames = - {{"file:///G:/js/stacktrace.js", "", 44, std::nullopt}, - {"file:///G:/js/stacktrace.js", "", 31, std::nullopt}, - {"file:///G:/js/stacktrace.js", "printStackTrace", 18, std::nullopt}, - {"file:///G:/js/file.js", "bar", 13, std::nullopt}, - {"file:///G:/js/file.js", "bar", 16, std::nullopt}, - {"file:///G:/js/file.js", "foo", 20, std::nullopt}, - {"file:///G:/js/file.js", "", 24, std::nullopt}}; + {{.file = "file:///G:/js/stacktrace.js", + .methodName = "", + .lineNumber = 44, + .column = std::nullopt}, + {.file = "file:///G:/js/stacktrace.js", + .methodName = "", + .lineNumber = 31, + .column = std::nullopt}, + {.file = "file:///G:/js/stacktrace.js", + .methodName = "printStackTrace", + .lineNumber = 18, + .column = std::nullopt}, + {.file = "file:///G:/js/file.js", + .methodName = "bar", + .lineNumber = 13, + .column = std::nullopt}, + {.file = "file:///G:/js/file.js", + .methodName = "bar", + .lineNumber = 16, + .column = std::nullopt}, + {.file = "file:///G:/js/file.js", + .methodName = "foo", + .lineNumber = 20, + .column = std::nullopt}, + {.file = "file:///G:/js/file.js", + .methodName = "", + .lineNumber = 24, + .column = std::nullopt}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -524,9 +634,18 @@ TEST(StackTraceParser, firefox14Error) { EXPECT_EQ(actualStackFrames.size(), 3); std::vector expectedStackFrames = - {{"http://path/to/file.js", "", 48, std::nullopt}, - {"http://path/to/file.js", "dumpException3", 52, std::nullopt}, - {"http://path/to/file.js", "onclick", 1, std::nullopt}}; + {{.file = "http://path/to/file.js", + .methodName = "", + .lineNumber = 48, + .column = std::nullopt}, + {.file = "http://path/to/file.js", + .methodName = "dumpException3", + .lineNumber = 52, + .column = std::nullopt}, + {.file = "http://path/to/file.js", + .methodName = "onclick", + .lineNumber = 1, + .column = std::nullopt}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -544,9 +663,18 @@ TEST(StackTraceParser, firefox31Error) { EXPECT_EQ(actualStackFrames.size(), 3); std::vector expectedStackFrames = - {{"http://path/to/file.js", "foo", 41, 12}, - {"http://path/to/file.js", "bar", 1, 0}, - {"http://path/to/file.js", ".plugin/e.fn[c]/<", 1, 0}}; + {{.file = "http://path/to/file.js", + .methodName = "foo", + .lineNumber = 41, + .column = 12}, + {.file = "http://path/to/file.js", + .methodName = "bar", + .lineNumber = 1, + .column = 0}, + {.file = "http://path/to/file.js", + .methodName = ".plugin/e.fn[c]/<", + .lineNumber = 1, + .column = 0}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -564,10 +692,22 @@ TEST(StackTraceParser, firefox44) { EXPECT_EQ(actualStackFrames.size(), 4); std::vector expectedStackFrames = - {{"http://path/to/file.js", "[2]", 23, 0}}; + {{.file = "http://path/to/file.js", + .methodName = "[2] expectedStackFrames = - {{std::nullopt, "Array.forEach", std::nullopt, std::nullopt}}; + {{.file = std::nullopt, + .methodName = "Array.forEach", + .lineNumber = std::nullopt, + .column = std::nullopt}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -603,10 +746,22 @@ TEST(StackTraceParser, chrome15Error) { EXPECT_EQ(actualStackFrames.size(), 4); std::vector expectedStackFrames = - {{"http://path/to/file.js", "bar", 13, 16}, - {"http://path/to/file.js", "bar", 16, 4}, - {"http://path/to/file.js", "foo", 20, 4}, - {"http://path/to/file.js", "", 24, 3}}; + {{.file = "http://path/to/file.js", + .methodName = "bar", + .lineNumber = 13, + .column = 16}, + {.file = "http://path/to/file.js", + .methodName = "bar", + .lineNumber = 16, + .column = 4}, + {.file = "http://path/to/file.js", + .methodName = "foo", + .lineNumber = 20, + .column = 4}, + {.file = "http://path/to/file.js", + .methodName = "", + .lineNumber = 24, + .column = 3}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -624,12 +779,18 @@ TEST(StackTraceParser, chrome36Error) { EXPECT_EQ(actualStackFrames.size(), 3); std::vector expectedStackFrames = - {{"http://localhost:8080/file.js", "dumpExceptionError", 41, 26}, - {"http://localhost:8080/file.js", "HTMLButtonElement.onclick", 107, 145}, - {"http://localhost:8080/file.js", - "I.e.fn.(anonymous function) [as index]", - 10, - 3650}}; + {{.file = "http://localhost:8080/file.js", + .methodName = "dumpExceptionError", + .lineNumber = 41, + .column = 26}, + {.file = "http://localhost:8080/file.js", + .methodName = "HTMLButtonElement.onclick", + .lineNumber = 107, + .column = 145}, + {.file = "http://localhost:8080/file.js", + .methodName = "I.e.fn.(anonymous function) [as index]", + .lineNumber = 10, + .column = 3650}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -647,7 +808,14 @@ TEST(StackTraceParser, chrome76Error) { EXPECT_EQ(actualStackFrames.size(), 2); std::vector expectedStackFrames = - {{"", "bar", 8, 8}, {"", "async foo", 2, 2}}; + {{.file = "", + .methodName = "bar", + .lineNumber = 8, + .column = 8}, + {.file = "", + .methodName = "async foo", + .lineNumber = 2, + .column = 2}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -665,26 +833,26 @@ TEST(StackTraceParser, chromeErrorWithWebpackURLS) { EXPECT_EQ(actualStackFrames.size(), 5); std::vector expectedStackFrames = - {{"webpack:///./src/components/test/test.jsx?", - "TESTTESTTEST.eval", - 295, - 107}, - {"webpack:///./src/components/test/test.jsx?", - "TESTTESTTEST.render", - 272, - 31}, - {"webpack:///./~/react-transform-catch-errors/lib/index.js?", - "TESTTESTTEST.tryRender", - 34, - 30}, - {"webpack:///./~/react-proxy/modules/createPrototypeProxy.js?", - "TESTTESTTEST.proxiedMethod", - 44, - 29}, - {R"(C:\root\server\development\pages\index.js)", - "Module../pages/index.js", - 182, - 6}}; + {{.file = "webpack:///./src/components/test/test.jsx?", + .methodName = "TESTTESTTEST.eval", + .lineNumber = 295, + .column = 107}, + {.file = "webpack:///./src/components/test/test.jsx?", + .methodName = "TESTTESTTEST.render", + .lineNumber = 272, + .column = 31}, + {.file = "webpack:///./~/react-transform-catch-errors/lib/index.js?", + .methodName = "TESTTESTTEST.tryRender", + .lineNumber = 34, + .column = 30}, + {.file = "webpack:///./~/react-proxy/modules/createPrototypeProxy.js?", + .methodName = "TESTTESTTEST.proxiedMethod", + .lineNumber = 44, + .column = 29}, + {.file = R"(C:\root\server\development\pages\index.js)", + .methodName = "Module../pages/index.js", + .lineNumber = 182, + .column = 6}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -702,11 +870,26 @@ TEST(StackTraceParser, nestedEvalsFromChrome) { EXPECT_EQ(actualStackFrames.size(), 5); std::vector expectedStackFrames = - {{"http://localhost:8080/file.js", "baz", 21, 16}, - {"http://localhost:8080/file.js", "foo", 21, 16}, - {"http://localhost:8080/file.js", "eval", 21, 16}, - {"http://localhost:8080/file.js", "Object.speak", 21, 16}, - {"http://localhost:8080/file.js", "", 31, 12}}; + {{.file = "http://localhost:8080/file.js", + .methodName = "baz", + .lineNumber = 21, + .column = 16}, + {.file = "http://localhost:8080/file.js", + .methodName = "foo", + .lineNumber = 21, + .column = 16}, + {.file = "http://localhost:8080/file.js", + .methodName = "eval", + .lineNumber = 21, + .column = 16}, + {.file = "http://localhost:8080/file.js", + .methodName = "Object.speak", + .lineNumber = 21, + .column = 16}, + {.file = "http://localhost:8080/file.js", + .methodName = "", + .lineNumber = 31, + .column = 12}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -723,32 +906,41 @@ TEST(StackTraceParser, chromeErrorWithBlobURLs) { StackTraceParser::parse(false, CapturedExceptions["CHROME_48_BLOB"]); EXPECT_EQ(actualStackFrames.size(), 7); - std::vector expectedStackFrames = - {{std::nullopt, "Error", std::nullopt, std::nullopt}, - {"blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", - "s", - 31, - 29145}, - {"blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", - "Object.d [as add]", - 31, - 30038}, - {"blob:http%3A//localhost%3A8080/d4eefe0f-361a-4682-b217-76587d9f712a", - "", - 15, - 10977}, - {"blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", - "", - 1, - 6910}, - {"blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", - "n.fire", - 7, - 3018}, - {"blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", - "n.handle", - 7, - 2862}}; + std::vector expectedStackFrames = { + {.file = std::nullopt, + .methodName = "Error", + .lineNumber = std::nullopt, + .column = std::nullopt}, + {.file = + "blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", + .methodName = "s", + .lineNumber = 31, + .column = 29145}, + {.file = + "blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", + .methodName = "Object.d [as add]", + .lineNumber = 31, + .column = 30038}, + {.file = + "blob:http%3A//localhost%3A8080/d4eefe0f-361a-4682-b217-76587d9f712a", + .methodName = "", + .lineNumber = 15, + .column = 10977}, + {.file = + "blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", + .methodName = "", + .lineNumber = 1, + .column = 6910}, + {.file = + "blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", + .methodName = "n.fire", + .lineNumber = 7, + .column = 3018}, + {.file = + "blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379", + .methodName = "n.handle", + .lineNumber = 7, + .column = 2862}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -766,9 +958,18 @@ TEST(StackTraceParser, ie10Error) { EXPECT_EQ(actualStackFrames.size(), 3); std::vector expectedStackFrames = - {{"http://path/to/file.js", "Anonymous function", 48, 12}, - {"http://path/to/file.js", "foo", 46, 8}, - {"http://path/to/file.js", "bar", 82, 0}}; + {{.file = "http://path/to/file.js", + .methodName = "Anonymous function", + .lineNumber = 48, + .column = 12}, + {.file = "http://path/to/file.js", + .methodName = "foo", + .lineNumber = 46, + .column = 8}, + {.file = "http://path/to/file.js", + .methodName = "bar", + .lineNumber = 82, + .column = 0}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -786,9 +987,18 @@ TEST(StackTraceParser, ie11Error) { EXPECT_EQ(actualStackFrames.size(), 3); std::vector expectedStackFrames = - {{"http://path/to/file.js", "Anonymous function", 47, 20}, - {"http://path/to/file.js", "foo", 45, 12}, - {"http://path/to/file.js", "bar", 108, 0}}; + {{.file = "http://path/to/file.js", + .methodName = "Anonymous function", + .lineNumber = 47, + .column = 20}, + {.file = "http://path/to/file.js", + .methodName = "foo", + .lineNumber = 45, + .column = 12}, + {.file = "http://path/to/file.js", + .methodName = "bar", + .lineNumber = 108, + .column = 0}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -805,9 +1015,18 @@ TEST(StackTraceParser, ie11EvalError) { StackTraceParser::parse(false, CapturedExceptions["IE_11_EVAL"]); EXPECT_EQ(actualStackFrames.size(), 3); std::vector expectedStackFrames = - {{"eval code", "eval code", 1, 0}, - {"http://path/to/file.js", "foo", 58, 16}, - {"http://path/to/file.js", "bar", 109, 0}}; + {{.file = "eval code", + .methodName = "eval code", + .lineNumber = 1, + .column = 0}, + {.file = "http://path/to/file.js", + .methodName = "foo", + .lineNumber = 58, + .column = 16}, + {.file = "http://path/to/file.js", + .methodName = "bar", + .lineNumber = 109, + .column = 0}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -823,9 +1042,18 @@ TEST(StackTraceParser, Opera25Error) { StackTraceParser::parse(false, CapturedExceptions["OPERA_25"]); EXPECT_EQ(actualStackFrames.size(), 3); std::vector expectedStackFrames = - {{"http://path/to/file.js", "", 47, 21}, - {"http://path/to/file.js", "foo", 52, 14}, - {"http://path/to/file.js", "bar", 108, 167}}; + {{.file = "http://path/to/file.js", + .methodName = "", + .lineNumber = 47, + .column = 21}, + {.file = "http://path/to/file.js", + .methodName = "foo", + .lineNumber = 52, + .column = 14}, + {.file = "http://path/to/file.js", + .methodName = "bar", + .lineNumber = 108, + .column = 167}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -841,9 +1069,18 @@ TEST(StackTraceParser, PhantomJS119Error) { StackTraceParser::parse(false, CapturedExceptions["PHANTOMJS_1_19"]); EXPECT_EQ(actualStackFrames.size(), 3); std::vector expectedStackFrames = - {{"file:///path/to/file.js", "", 878, std::nullopt}, - {"http://path/to/file.js", "foo", 4283, std::nullopt}, - {"http://path/to/file.js", "", 4287, std::nullopt}}; + {{.file = "file:///path/to/file.js", + .methodName = "", + .lineNumber = 878, + .column = std::nullopt}, + {.file = "http://path/to/file.js", + .methodName = "foo", + .lineNumber = 4283, + .column = std::nullopt}, + {.file = "http://path/to/file.js", + .methodName = "", + .lineNumber = 4287, + .column = std::nullopt}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -859,7 +1096,10 @@ TEST(StackTraceParser, FirefoxResourceUrlError) { false, CapturedExceptions["FIREFOX_50_RESOURCE_URL"]); EXPECT_EQ(actualStackFrames.size(), 3); std::vector expectedStackFrames = - {{"resource://path/data/content/bundle.js", "render", 5529, 15}}; + {{.file = "resource://path/data/content/bundle.js", + .methodName = "render", + .lineNumber = 5529, + .column = 15}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -875,11 +1115,26 @@ TEST(StackTraceParser, FirefoxEvalUrlError) { StackTraceParser::parse(false, CapturedExceptions["FIREFOX_43_EVAL"]); EXPECT_EQ(actualStackFrames.size(), 5); std::vector expectedStackFrames = - {{"http://localhost:8080/file.js", "baz", 26, std::nullopt}, - {"http://localhost:8080/file.js", "foo", 26, std::nullopt}, - {"http://localhost:8080/file.js", "", 26, std::nullopt}, - {"http://localhost:8080/file.js", "speak", 26, 16}, - {"http://localhost:8080/file.js", "", 33, 8}}; + {{.file = "http://localhost:8080/file.js", + .methodName = "baz", + .lineNumber = 26, + .column = std::nullopt}, + {.file = "http://localhost:8080/file.js", + .methodName = "foo", + .lineNumber = 26, + .column = std::nullopt}, + {.file = "http://localhost:8080/file.js", + .methodName = "", + .lineNumber = 26, + .column = std::nullopt}, + {.file = "http://localhost:8080/file.js", + .methodName = "speak", + .lineNumber = 26, + .column = 16}, + {.file = "http://localhost:8080/file.js", + .methodName = "", + .lineNumber = 33, + .column = 8}}; for (auto i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -895,14 +1150,16 @@ TEST(StackTraceParser, ReactNativeAndroidError) { false, CapturedExceptions["ANDROID_REACT_NATIVE"]); EXPECT_EQ(actualStackFrames.size(), 8); std::vector expectedStackFrames = { - {"/home/username/sample-workspace/sampleapp.collect.react/src/components/GpsMonitorScene.js", - "render", - 78, - 23}, - {"/home/username/sample-workspace/sampleapp.collect.react/node_modules/react-native/Libraries/Renderer/src/renderers/native/ReactNativeBaseComponent.js", - "this", - 74, - 40}}; + {.file = + "/home/username/sample-workspace/sampleapp.collect.react/src/components/GpsMonitorScene.js", + .methodName = "render", + .lineNumber = 78, + .column = 23}, + {.file = + "/home/username/sample-workspace/sampleapp.collect.react/node_modules/react-native/Libraries/Renderer/src/renderers/native/ReactNativeBaseComponent.js", + .methodName = "this", + .lineNumber = 74, + .column = 40}}; EXPECT_EQ(actualStackFrames[0].column, expectedStackFrames[0].column); EXPECT_EQ(actualStackFrames[0].file, expectedStackFrames[0].file); @@ -920,9 +1177,18 @@ TEST(StackTraceParser, ReactNativeAndroidProdError) { false, CapturedExceptions["ANDROID_REACT_NATIVE_PROD"]); EXPECT_EQ(actualStackFrames.size(), 37); std::vector expectedStackFrames = - {{"index.android.bundle", "value", 12, 1916}, - {"index.android.bundle", "value", 29, 926}, - {"[native code]", "", std::nullopt, std::nullopt}}; + {{.file = "index.android.bundle", + .methodName = "value", + .lineNumber = 12, + .column = 1916}, + {.file = "index.android.bundle", + .methodName = "value", + .lineNumber = 29, + .column = 926}, + {.file = "[native code]", + .methodName = "", + .lineNumber = std::nullopt, + .column = std::nullopt}}; EXPECT_EQ(actualStackFrames[0].column, expectedStackFrames[0].column); EXPECT_EQ(actualStackFrames[0].file, expectedStackFrames[0].file); EXPECT_EQ(actualStackFrames[0].lineNumber, expectedStackFrames[0].lineNumber); @@ -948,8 +1214,14 @@ TEST(StackTraceParser, NodeJsAsyncErrorsVersion12) { StackTraceParser::parse(false, CapturedExceptions["NODE_12"]); EXPECT_EQ(actualStackFrames.size(), 2); std::vector expectedStackFrames = - {{"/home/xyz/hack/asyncnode.js", "promiseMe", 11, 8}, - {"/home/xyz/hack/asyncnode.js", "async main", 15, 12}}; + {{.file = "/home/xyz/hack/asyncnode.js", + .methodName = "promiseMe", + .lineNumber = 11, + .column = 8}, + {.file = "/home/xyz/hack/asyncnode.js", + .methodName = "async main", + .lineNumber = 15, + .column = 12}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -966,16 +1238,22 @@ TEST(StackTraceParser, NodeJsErrorsWithAnonymousCalls) { StackTraceParser::parse(false, CapturedExceptions["NODE_ANONYM"]); EXPECT_EQ(actualStackFrames.size(), 9); std::vector expectedStackFrames = - {{R"(C:\projects\spect\src\index.js)", "Spect.get", 161, 25}, - {R"(C:\projects\spect\src\index.js)", - "(anonymous function).then", - 165, - 32}, - {R"(C:\projects\spect\node_modules\esm\esm.js)", "", 1, 34534}, - {R"(C:\projects\spect\node_modules\esm\esm.js)", - "process.", - 1, - 34505}}; + {{.file = R"(C:\projects\spect\src\index.js)", + .methodName = "Spect.get", + .lineNumber = 161, + .column = 25}, + {.file = R"(C:\projects\spect\src\index.js)", + .methodName = "(anonymous function).then", + .lineNumber = 165, + .column = 32}, + {.file = R"(C:\projects\spect\node_modules\esm\esm.js)", + .methodName = "", + .lineNumber = 1, + .column = 34534}, + {.file = R"(C:\projects\spect\node_modules\esm\esm.js)", + .methodName = "process.", + .lineNumber = 1, + .column = 34505}}; // Check specific stack frames as per the JavaScript test EXPECT_EQ(actualStackFrames[0].column, expectedStackFrames[0].column); EXPECT_EQ(actualStackFrames[0].file, expectedStackFrames[0].file); @@ -1003,8 +1281,14 @@ TEST(StackTraceParser, AnonymousSources) { StackTraceParser::parse(false, CapturedExceptions["ANONYMOUS_SOURCES"]); EXPECT_EQ(actualStackFrames.size(), 2); std::vector expectedStackFrames = - {{"http://www.example.com/test.js", "new ", 2, 0}, - {"", "", 1, 1}}; + {{.file = "http://www.example.com/test.js", + .methodName = "new ", + .lineNumber = 2, + .column = 0}, + {.file = "", + .methodName = "", + .lineNumber = 1, + .column = 1}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -1021,11 +1305,26 @@ TEST(StackTraceParser, NodeJsTest1) { StackTraceParser::parse(false, CapturedExceptions["NODE_JS_TEST_1"]); EXPECT_EQ(actualStackFrames.size(), 5); std::vector expectedStackFrames = - {{"repl", "", 1, 1}, - {"repl.js", "REPLServer.self.eval", 110, 20}, - {"repl.js", "Interface.", 239, 11}, - {"events.js", "Interface.EventEmitter.emit", 95, 16}, - {"readline.js", "emitKey", 1095, 11}}; + {{.file = "repl", + .methodName = "", + .lineNumber = 1, + .column = 1}, + {.file = "repl.js", + .methodName = "REPLServer.self.eval", + .lineNumber = 110, + .column = 20}, + {.file = "repl.js", + .methodName = "Interface.", + .lineNumber = 239, + .column = 11}, + {.file = "events.js", + .methodName = "Interface.EventEmitter.emit", + .lineNumber = 95, + .column = 16}, + {.file = "readline.js", + .methodName = "emitKey", + .lineNumber = 1095, + .column = 11}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -1041,8 +1340,14 @@ TEST(StackTraceParser, NodeJsTest2) { StackTraceParser::parse(false, CapturedExceptions["NODE_JS_TEST_2"]); EXPECT_EQ(actualStackFrames.size(), 2); std::vector expectedStackFrames = - {{"repl", "null._onTimeout", 1, 24}, - {"timers.js", "Timer.listOnTimeout [as ontimeout]", 110, 14}}; + {{.file = "repl", + .methodName = "null._onTimeout", + .lineNumber = 1, + .column = 24}, + {.file = "timers.js", + .methodName = "Timer.listOnTimeout [as ontimeout]", + .lineNumber = 110, + .column = 14}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -1058,16 +1363,46 @@ TEST(StackTraceParser, IoJs) { StackTraceParser::parse(false, CapturedExceptions["IO_JS"]); EXPECT_EQ(actualStackFrames.size(), 10); std::vector expectedStackFrames = - {{"repl", "", 1, 0}, - {"repl.js", "REPLServer.defaultEval", 154, 26}, - {"domain.js", "bound", 254, 13}, - {"domain.js", "REPLServer.runBound [as eval]", 267, 11}, - {"repl.js", "REPLServer.", 308, 11}, - {"events.js", "emitOne", 77, 12}, - {"events.js", "REPLServer.emit", 169, 6}, - {"readline.js", "REPLServer.Interface._onLine", 210, 9}, - {"readline.js", "REPLServer.Interface._line", 549, 7}, - {"readline.js", "REPLServer.Interface._ttyWrite", 826, 13}}; + {{.file = "repl", + .methodName = "", + .lineNumber = 1, + .column = 0}, + {.file = "repl.js", + .methodName = "REPLServer.defaultEval", + .lineNumber = 154, + .column = 26}, + {.file = "domain.js", + .methodName = "bound", + .lineNumber = 254, + .column = 13}, + {.file = "domain.js", + .methodName = "REPLServer.runBound [as eval]", + .lineNumber = 267, + .column = 11}, + {.file = "repl.js", + .methodName = "REPLServer.", + .lineNumber = 308, + .column = 11}, + {.file = "events.js", + .methodName = "emitOne", + .lineNumber = 77, + .column = 12}, + {.file = "events.js", + .methodName = "REPLServer.emit", + .lineNumber = 169, + .column = 6}, + {.file = "readline.js", + .methodName = "REPLServer.Interface._onLine", + .lineNumber = 210, + .column = 9}, + {.file = "readline.js", + .methodName = "REPLServer.Interface._line", + .lineNumber = 549, + .column = 7}, + {.file = "readline.js", + .methodName = "REPLServer.Interface._ttyWrite", + .lineNumber = 826, + .column = 13}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -1090,7 +1425,14 @@ TEST(StackTraceParser, hermesBytecodeLocation) { EXPECT_EQ(actualStackFrames.size(), 2); std::vector expectedStackFrames = - {{"unknown", "global", 1, 9}, {"/js/foo.hbc", "foo$bar", 10, 1234}}; + {{.file = "unknown", + .methodName = "global", + .lineNumber = 1, + .column = 9}, + {.file = "/js/foo.hbc", + .methodName = "foo$bar", + .lineNumber = 10, + .column = 1234}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -1110,7 +1452,10 @@ TEST(StackTraceParser, internalBytecodeLocation) { " at notInternal (address at /js/InternalBytecode.js:10:1234)"); EXPECT_EQ(actualStackFrames.size(), 1); std::vector expectedStackFrames = - {{"/js/InternalBytecode.js", "notInternal", 10, 1234}}; + {{.file = "/js/InternalBytecode.js", + .methodName = "notInternal", + .lineNumber = 10, + .column = 1234}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -1130,7 +1475,14 @@ TEST(StackTraceParser, sourceLocation) { " at foo$bar (/js/foo.js:10:1234)"); EXPECT_EQ(actualStackFrames.size(), 2); std::vector expectedStackFrames = - {{"unknown", "global", 1, 8}, {"/js/foo.js", "foo$bar", 10, 1233}}; + {{.file = "unknown", + .methodName = "global", + .lineNumber = 1, + .column = 8}, + {.file = "/js/foo.js", + .methodName = "foo$bar", + .lineNumber = 10, + .column = 1233}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); @@ -1150,7 +1502,11 @@ TEST(StackTraceParser, tolerateEmptyFilename) { " at foo$bar (:10:1234)"); EXPECT_EQ(actualStackFrames.size(), 2); std::vector expectedStackFrames = - {{"unknown", "global", 1, 8}, {"", "foo$bar", 10, 1233}}; + {{.file = "unknown", + .methodName = "global", + .lineNumber = 1, + .column = 8}, + {.file = "", .methodName = "foo$bar", .lineNumber = 10, .column = 1233}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -1170,7 +1526,14 @@ TEST(StackTraceParser, skippedFrames) { " at foo$bar (/js/foo.js:10:1234)"); EXPECT_EQ(actualStackFrames.size(), 2); std::vector expectedStackFrames = - {{"unknown", "global", 1, 8}, {"/js/foo.js", "foo$bar", 10, 1233}}; + {{.file = "unknown", + .methodName = "global", + .lineNumber = 1, + .column = 8}, + {.file = "/js/foo.js", + .methodName = "foo$bar", + .lineNumber = 10, + .column = 1233}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); @@ -1190,7 +1553,10 @@ TEST(StackTraceParser, handleNonStandardLines) { " at foo$bar (/js/foo.js:10:1234)"); EXPECT_EQ(actualStackFrames.size(), 1); std::vector expectedStackFrames = - {{"/js/foo.js", "foo$bar", 10, 1233}}; + {{.file = "/js/foo.js", + .methodName = "foo$bar", + .lineNumber = 10, + .column = 1233}}; for (size_t i = 0; i < expectedStackFrames.size(); i++) { EXPECT_EQ(actualStackFrames[i].column, expectedStackFrames[i].column); EXPECT_EQ(actualStackFrames[i].file, expectedStackFrames[i].file); diff --git a/packages/react-native/ReactCommon/jsinspector-modern/NetworkIOAgent.cpp b/packages/react-native/ReactCommon/jsinspector-modern/NetworkIOAgent.cpp index eafa48563cf..5e061505953 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/NetworkIOAgent.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/NetworkIOAgent.cpp @@ -137,8 +137,10 @@ class Stream : public NetworkRequestListener, // called with it. if (initCb_) { auto cb = std::move(initCb_); - (*cb)( - InitStreamResult{httpStatusCode, headers, this->shared_from_this()}); + (*cb)(InitStreamResult{ + .httpStatusCode = httpStatusCode, + .headers = headers, + .stream = this->shared_from_this()}); } } diff --git a/packages/react-native/ReactCommon/jsinspector-modern/network/BoundedRequestBuffer.cpp b/packages/react-native/ReactCommon/jsinspector-modern/network/BoundedRequestBuffer.cpp index bfd1481c112..bd828c36cf4 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/network/BoundedRequestBuffer.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/network/BoundedRequestBuffer.cpp @@ -51,8 +51,8 @@ bool BoundedRequestBuffer::put( // `data` is copied at the point of insertion responses_.emplace( requestId, - std::make_shared( - ResponseBody{std::string(data), base64Encoded})); + std::make_shared(ResponseBody{ + .data = std::string(data), .base64Encoded = base64Encoded})); order_.push_back(requestId); return true; diff --git a/packages/react-native/ReactCommon/jsinspector-modern/tracing/tests/ProfileTreeNodeTest.cpp b/packages/react-native/ReactCommon/jsinspector-modern/tracing/tests/ProfileTreeNodeTest.cpp index 3ca35e3e439..8a83eabb036 100644 --- a/packages/react-native/ReactCommon/jsinspector-modern/tracing/tests/ProfileTreeNodeTest.cpp +++ b/packages/react-native/ReactCommon/jsinspector-modern/tracing/tests/ProfileTreeNodeTest.cpp @@ -14,9 +14,13 @@ namespace facebook::react::jsinspector_modern::tracing { TEST(ProfileTreeNodeTest, OnlyAddsUniqueChildren) { auto fooCallFrame = RuntimeSamplingProfile::SampleCallStackFrame{ - RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction, 0, "foo"}; + .kind = RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction, + .scriptId = 0, + .functionName = "foo"}; auto barCallFrame = RuntimeSamplingProfile::SampleCallStackFrame{ - RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction, 0, "bar"}; + .kind = RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction, + .scriptId = 0, + .functionName = "bar"}; ProfileTreeNode parent( 1, ProfileTreeNode::CodeType::JavaScript, fooCallFrame); @@ -34,9 +38,13 @@ TEST(ProfileTreeNodeTest, OnlyAddsUniqueChildren) { TEST(ProfileTreeNodeTest, ConsidersCodeTypeOfChild) { auto parentCallFrame = RuntimeSamplingProfile::SampleCallStackFrame{ - RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction, 0, "foo"}; + .kind = RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction, + .scriptId = 0, + .functionName = "foo"}; auto childCallFrame = RuntimeSamplingProfile::SampleCallStackFrame{ - RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction, 0, "bar"}; + .kind = RuntimeSamplingProfile::SampleCallStackFrame::Kind::JSFunction, + .scriptId = 0, + .functionName = "bar"}; ProfileTreeNode parent( 1, ProfileTreeNode::CodeType::JavaScript, parentCallFrame); diff --git a/packages/react-native/ReactCommon/react/nativemodule/fantomtestspecificmethods/internal/FantomForcedCloneCommitHook.cpp b/packages/react-native/ReactCommon/react/nativemodule/fantomtestspecificmethods/internal/FantomForcedCloneCommitHook.cpp index c694a1c708e..d60ba84ee39 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/fantomtestspecificmethods/internal/FantomForcedCloneCommitHook.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/fantomtestspecificmethods/internal/FantomForcedCloneCommitHook.cpp @@ -26,9 +26,10 @@ std::shared_ptr findAndClone( if (maybeClone != child) { children[i] = maybeClone; return node->clone( - {ShadowNodeFragment::propsPlaceholder(), - std::make_shared>>( - children)}); + {.props = ShadowNodeFragment::propsPlaceholder(), + .children = + std::make_shared>>( + children)}); } } diff --git a/packages/react-native/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp b/packages/react-native/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp index 2dbba431756..22562fd67bf 100644 --- a/packages/react-native/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp +++ b/packages/react-native/ReactCommon/react/renderer/animations/LayoutAnimationKeyFrameManager.cpp @@ -123,13 +123,13 @@ void LayoutAnimationKeyFrameManager::uiManagerDidConfigureNextLayoutAnimation( std::scoped_lock lock(currentAnimationMutex_); uiManagerDidConfigureNextLayoutAnimation(LayoutAnimation{ - -1, - 0, - false, - *layoutAnimationConfig, - successCallback, - failureCallback, - {}}); + .surfaceId = -1, + .startTime = 0, + .completed = false, + .layoutAnimationConfig = *layoutAnimationConfig, + .successCallback = successCallback, + .failureCallback = failureCallback, + .keyFrames = {}}); } else { LOG(ERROR) << "Parsing LayoutAnimationConfig failed: " << (folly::dynamic)config; @@ -500,14 +500,15 @@ LayoutAnimationKeyFrameManager::pullTransaction( mutation); keyFrame = AnimationKeyFrame{ - /* .finalMutationsForKeyFrame = */ {}, - /* .type = */ AnimationConfigurationType::Create, - /* .tag = */ tag, - /* .parentTag = */ parentTag, - /* .viewStart = */ viewStart, - /* .viewEnd = */ viewFinal, - /* .viewPrev = */ baselineShadowView, - /* .initialProgress = */ 0}; + /* .finalMutationsForKeyFrame = */ .finalMutationsForKeyFrame = + {}, + /* .type = */ .type = AnimationConfigurationType::Create, + /* .tag = */ .tag = tag, + /* .parentTag = */ .parentTag = parentTag, + /* .viewStart = */ .viewStart = viewStart, + /* .viewEnd = */ .viewEnd = viewFinal, + /* .viewPrev = */ .viewPrev = baselineShadowView, + /* .initialProgress = */ .initialProgress = 0}; } else if (mutation.type == ShadowViewMutation::Type::Delete) { // This is just for assertion purposes. // The NDEBUG check here is to satisfy the compiler in certain environments @@ -538,14 +539,15 @@ LayoutAnimationKeyFrameManager::pullTransaction( mutation); keyFrame = AnimationKeyFrame{ - /* .finalMutationsForKeyFrame = */ {mutation}, - /* .type = */ AnimationConfigurationType::Update, - /* .tag = */ tag, - /* .parentTag = */ parentTag, - /* .viewStart = */ viewStart, - /* .viewEnd = */ viewFinal, - /* .viewPrev = */ baselineShadowView, - /* .initialProgress = */ 0}; + /* .finalMutationsForKeyFrame = */ .finalMutationsForKeyFrame = + {mutation}, + /* .type = */ .type = AnimationConfigurationType::Update, + /* .tag = */ .tag = tag, + /* .parentTag = */ .parentTag = parentTag, + /* .viewStart = */ .viewStart = viewStart, + /* .viewEnd = */ .viewEnd = viewFinal, + /* .viewPrev = */ .viewPrev = baselineShadowView, + /* .initialProgress = */ .initialProgress = 0}; } else { // This should just be "Remove" instructions that are not animated // (either this is a "move", or there's a corresponding "Delete" @@ -624,14 +626,15 @@ LayoutAnimationKeyFrameManager::pullTransaction( mutation); keyFrame = AnimationKeyFrame{ - /* .finalMutationsForKeyFrame */ {mutation, deleteMutation}, - /* .type */ AnimationConfigurationType::Delete, - /* .tag */ tag, - /* .parentTag */ parentTag, - /* .viewStart */ viewStart, - /* .viewEnd */ viewFinal, - /* .viewPrev */ baselineShadowView, - /* .initialProgress */ 0}; + /* .finalMutationsForKeyFrame */ .finalMutationsForKeyFrame = + {mutation, deleteMutation}, + /* .type */ .type = AnimationConfigurationType::Delete, + /* .tag */ .tag = tag, + /* .parentTag */ .parentTag = parentTag, + /* .viewStart */ .viewStart = viewStart, + /* .viewEnd */ .viewEnd = viewFinal, + /* .viewPrev */ .viewPrev = baselineShadowView, + /* .initialProgress */ .initialProgress = 0}; } else { PrintMutationInstruction( "Executing Remove Immediately, due to reordering operation", diff --git a/packages/react-native/ReactCommon/react/renderer/animations/conversions.h b/packages/react-native/ReactCommon/react/renderer/animations/conversions.h index 34a0957c650..2dd7cbc23e3 100644 --- a/packages/react-native/ReactCommon/react/renderer/animations/conversions.h +++ b/packages/react-native/ReactCommon/react/renderer/animations/conversions.h @@ -64,12 +64,12 @@ static inline std::optional parseAnimationConfig( bool parsePropertyType) { if (config.empty() || !config.isObject()) { return AnimationConfig{ - AnimationType::Linear, - AnimationProperty::NotApplicable, - defaultDuration, - 0, - 0, - 0}; + .animationType = AnimationType::Linear, + .animationProperty = AnimationProperty::NotApplicable, + .duration = defaultDuration, + .delay = 0, + .springDamping = 0, + .initialVelocity = 0}; } const auto typeIt = config.find("type"); @@ -165,12 +165,12 @@ static inline std::optional parseAnimationConfig( } return std::optional(AnimationConfig{ - *animationType, - animationProperty, - duration, - delay, - springDamping, - initialVelocity}); + .animationType = *animationType, + .animationProperty = animationProperty, + .duration = duration, + .delay = delay, + .springDamping = springDamping, + .initialVelocity = initialVelocity}); } // Parse animation config from JS @@ -206,7 +206,10 @@ static inline std::optional parseLayoutAnimationConfig( } return LayoutAnimationConfig{ - duration, *createConfig, *updateConfig, *deleteConfig}; + .duration = duration, + .createConfig = *createConfig, + .updateConfig = *updateConfig, + .deleteConfig = *deleteConfig}; } } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp b/packages/react-native/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp index 6abac1a9ae9..2eeb5c3ecb6 100644 --- a/packages/react-native/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp +++ b/packages/react-native/ReactCommon/react/renderer/animations/tests/LayoutAnimationTest.cpp @@ -50,8 +50,10 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations( auto eventDispatcher = EventDispatcher::Shared{}; auto contextContainer = std::make_shared(); - auto componentDescriptorParameters = - ComponentDescriptorParameters{eventDispatcher, contextContainer, nullptr}; + auto componentDescriptorParameters = ComponentDescriptorParameters{ + .eventDispatcher = eventDispatcher, + .contextContainer = contextContainer, + .flavor = nullptr}; auto viewComponentDescriptor = ViewComponentDescriptor(componentDescriptorParameters); auto rootComponentDescriptor = @@ -93,20 +95,27 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations( auto surfaceId = SurfaceId(surfaceIdInt); auto family = rootComponentDescriptor.createFamily( - {Tag(surfaceIdInt), surfaceId, nullptr}); + {.tag = Tag(surfaceIdInt), + .surfaceId = surfaceId, + .instanceHandle = nullptr}); // Creating an initial root shadow node. auto emptyRootNode = std::const_pointer_cast( std::static_pointer_cast( rootComponentDescriptor.createShadowNode( - ShadowNodeFragment{RootShadowNode::defaultSharedProps()}, + ShadowNodeFragment{ + .props = RootShadowNode::defaultSharedProps()}, family))); // Applying size constraints. emptyRootNode = emptyRootNode->clone( parserContext, LayoutConstraints{ - Size{512, 0}, Size{512, std::numeric_limits::infinity()}}, + .minimumSize = Size{.width = 512, .height = 0}, + .maximumSize = + Size{ + .width = 512, + .height = std::numeric_limits::infinity()}}, LayoutContext{}); // Generation of a random tree. @@ -116,8 +125,9 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations( // Injecting a tree into the root node. auto currentRootNode = std::static_pointer_cast( emptyRootNode->ShadowNode::clone(ShadowNodeFragment{ - ShadowNodeFragment::propsPlaceholder(), - std::make_shared>>( + .props = ShadowNodeFragment::propsPlaceholder(), + .children = std::make_shared< + std::vector>>( std::vector>{ singleRootChildNode})})); @@ -169,31 +179,35 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations( // Configure animation animationDriver->uiManagerDidConfigureNextLayoutAnimation( - {surfaceId, - 0, - false, - {(double)animation_duration, - {/* Create */ AnimationType::EaseInEaseOut, - AnimationProperty::Opacity, - (double)animation_duration, - 0, - 0, - 0}, - {/* Update */ AnimationType::EaseInEaseOut, - AnimationProperty::ScaleXY, - (double)animation_duration, - 0, - 0, - 0}, - {/* Delete */ AnimationType::EaseInEaseOut, - AnimationProperty::Opacity, - (double)animation_duration, - 0, - 0, - 0}}, - {}, - {}, - {}}); + {.surfaceId = surfaceId, + .startTime = 0, + .completed = false, + .layoutAnimationConfig = + {.duration = (double)animation_duration, + .createConfig = { + /* Create */ .animationType = AnimationType::EaseInEaseOut, + .animationProperty = AnimationProperty::Opacity, + .duration = (double)animation_duration, + .delay = 0, + .springDamping = 0, + .initialVelocity = 0}, + .updateConfig = { + /* Update */ .animationType = AnimationType::EaseInEaseOut, + .animationProperty = AnimationProperty::ScaleXY, + .duration = (double)animation_duration, + .delay = 0, + .springDamping = 0, + .initialVelocity = 0}, + .deleteConfig = { + /* Delete */ .animationType = AnimationType::EaseInEaseOut, + .animationProperty = AnimationProperty::Opacity, + .duration = (double)animation_duration, + .delay = 0, + .springDamping = 0, + .initialVelocity = 0}}, + .successCallback = {}, + .failureCallback = {}, + .keyFrames = {}}); // Get mutations for each frame for (int k = 0; k < animation_frames + 2; k++) { diff --git a/packages/react-native/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp b/packages/react-native/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp index 38d19ba01e0..4838b3b6013 100644 --- a/packages/react-native/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp +++ b/packages/react-native/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.cpp @@ -33,9 +33,9 @@ void ComponentDescriptorRegistry::add( std::unique_lock lock(mutex_); auto componentDescriptor = componentDescriptorProvider.constructor( - {parameters_.eventDispatcher, - parameters_.contextContainer, - componentDescriptorProvider.flavor}); + {.eventDispatcher = parameters_.eventDispatcher, + .contextContainer = parameters_.contextContainer, + .flavor = componentDescriptorProvider.flavor}); react_native_assert( componentDescriptor->getComponentHandle() == componentDescriptorProvider.handle);