Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions harmony/pushy/src/main/cpp/pushy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "flow_json.h"
#include "native_config.h"
#include "native_round.h"
#include "round_engine.h"
#include <js_native_api.h>
#include <js_native_api_types.h>

Expand Down Expand Up @@ -1333,6 +1334,18 @@ static napi_value FlowPrepareRound(napi_env env, napi_callback_info info) {
env, flowcore::PrepareRound(text[0], ParseFlowObject(text[1]), sample));
}

// stepRound(stateJson?, eventJson) — one step of the round driver
// (round_engine.h); stateJson undefined/null starts fresh. Synchronous and
// cheap: the round's IO stays in ArkTS.
static napi_value FlowStepRound(napi_env env, napi_callback_info info) {
napi_value args[2] = {nullptr, nullptr};
std::string text[2];
if (!GetFlowArgs(env, info, "stepRound", 2, 0b11, args, text)) {
return nullptr;
}
return NewString(env, flowcore::StepRoundJson(text[0], text[1]));
}

// nextQueryStep(stateJson, responseText?) — responseText undefined/null for
// a failed (or no) request.
static napi_value FlowNextQueryStep(napi_env env, napi_callback_info info) {
Expand Down Expand Up @@ -1448,6 +1461,7 @@ napi_value Init(napi_env env, napi_value exports) {
!ExportFunction(env, exports, "getSupportedDiffVersion", Guarded<GetSupportedDiffVersion>) ||
!ExportFunction(env, exports, "prepareRound", Guarded<FlowPrepareRound>) ||
!ExportFunction(env, exports, "nextQueryStep", Guarded<FlowNextQueryStep>) ||
!ExportFunction(env, exports, "stepRound", Guarded<FlowStepRound>) ||
!ExportFunction(env, exports, "handleResponse", Guarded<FlowHandleResponse>) ||
!ExportFunction(env, exports, "configsEquivalent", Guarded<FlowConfigsEquivalent>) ||
!ExportFunction(env, exports, "runnableConfig", Guarded<FlowRunnableConfig>) ||
Expand Down
5 changes: 5 additions & 0 deletions harmony/pushy/src/main/ets/NativePatchCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,11 @@ interface NativePatchCoreBindings {
stateJson: string,
responseText: string | undefined,
): string | undefined;
/**
* 轮次驱动的一步(cpp/update_flow_core/round_engine.h):返回
* {"state", "commands"};stateJson 为 undefined 表示开始新一轮。
*/
stepRound(stateJson: string | undefined, eventJson: string): string;
/** 决策(已按本机规划的 attempts)、要持久化的 hashInfo 与响应缓存文本 */
handleResponse(
responseText: string,
Expand Down
Loading
Loading