-
Notifications
You must be signed in to change notification settings - Fork 0
API HotPatch
模块运行时更新
Runtime module updates
HotPatch 仅在宿主启用热更新时可用。补丁的顶层代码会在应用时执行,因此只应对可信脚本和经过验证的模块图使用。replace 清空目标模块原有成员后应用新代码;incremental 保留现有成员并新增或覆盖补丁声明。
HotPatchis available only when the host enables hot reload. Top-level patch code runs while the patch is applied, so use it only for trusted scripts and validated module graphs.replaceclears existing target members before applying new code;incrementalretains members and adds or overwrites declarations from the patch.
Parameters:
-
script
当前模块的完整替换源码。Complete replacement source for the current module.
-
ignoreDepends
可选布尔值,是否忽略依赖更新。Optional Boolean controlling whether dependency updates are ignored.
Returns
null。
null.
@module(MAIN);
export func replaceSelf() {
HotPatch.replace("@module(MAIN); export func run() { return 42; }");
return 0;
}Parameters:
-
modulePath
目标模块路径;相对路径相对当前模块目录解析。Target module path; relative paths resolve from the current module directory.
-
script
完整替换源码。Complete replacement source.
-
ignoreDepends
可选依赖开关。Optional dependency flag.
Returns
null。
null.
HotPatch.replace("./feature", "@module(FEATURE); export func run() { return 1; }");Parameters:
-
script
当前模块的增量补丁源码。Incremental patch source for the current module.
-
ignoreDepends
可选依赖开关。Optional dependency flag.
Returns
null。
null.
HotPatch.incremental("export func added() { return 7; }");Parameters:
-
modulePath
目标模块路径。Target module path.
-
script
增量源码。Incremental source.
-
ignoreDepends
可选依赖开关。Optional dependency flag.
Returns
null。
null.
HotPatch.incremental("./feature", "export func refresh() { return true; }");AuroraScript.JIT 4.0.0 · Documentation Home · Repository · MIT License