Skip to content

Commit

Permalink
fix: correctly load ts_helpers.js in workers (#1798)
Browse files Browse the repository at this point in the history
* fix: correctly load ts_helpers.js in workers

* chore: remove redundant arguments

* feat: don't polyfill JavaProxy on worker

* chore: remove unneeded appDir

---------

Co-authored-by: farfromrefuge <>
Co-authored-by: Eduardo Speroni <[email protected]>
  • Loading branch information
farfromrefug and edusperoni authored Jun 20, 2024
1 parent fb30932 commit 31f8501
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion test-app/app/src/main/assets/internal/ts_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@
Object.defineProperty(global, "__extends", { value: __extends });
Object.defineProperty(global, "__decorate", { value: __decorate });

global.JavaProxy = JavaProxy;
if (!global.__ns__worker) {
global.JavaProxy = JavaProxy;
}
global.Interfaces = Interfaces;
})()
2 changes: 1 addition & 1 deletion test-app/app/src/main/java/com/tns/RuntimeHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public static Runtime initRuntime(Context context) {
waitForLiveSync(context);
}

runtime.runScript(new File(appDir, "internal/ts_helpers.js"));
// runtime.runScript(new File(appDir, "internal/ts_helpers.js"));

File javaClassesModule = new File(appDir, "app/tns-java-classes.js");
if (javaClassesModule.exists()) {
Expand Down
1 change: 1 addition & 0 deletions test-app/runtime/src/main/cpp/Runtime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ Isolate* Runtime::PrepareV8Runtime(const string& filesPath, const string& native
else {
m_isMainThread = false;
auto postMessageFuncTemplate = FunctionTemplate::New(isolate, CallbackHandlers::WorkerGlobalPostMessageCallback);
globalTemplate->Set(ArgConverter::ConvertToV8String(isolate, "__ns__worker"), Boolean::New(isolate, true));
globalTemplate->Set(ArgConverter::ConvertToV8String(isolate, "postMessage"), postMessageFuncTemplate);
auto closeFuncTemplate = FunctionTemplate::New(isolate, CallbackHandlers::WorkerGlobalCloseCallback);
globalTemplate->Set(ArgConverter::ConvertToV8String(isolate, "close"), closeFuncTemplate);
Expand Down
1 change: 1 addition & 0 deletions test-app/runtime/src/main/java/com/tns/Runtime.java
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ public static void initWorker(String jsFileName, String callingJsDir, int id) {
private static Runtime initRuntime(DynamicConfiguration dynamicConfiguration) {
Runtime runtime = new Runtime(staticConfiguration, dynamicConfiguration);
runtime.init();
runtime.runScript(new File(staticConfiguration.appDir, "internal/ts_helpers.js"));

return runtime;
}
Expand Down

0 comments on commit 31f8501

Please sign in to comment.