@@ -91,18 +91,18 @@ bool IsESModule(const std::string& path) {
91
91
.ToLocal (&script) &&
92
92
tc.HasCaught ()) {
93
93
tns::LogError (isolate, tc);
94
- NSLog (@" FATAL: Failed to compile require factory script" );
94
+ Log (@" FATAL: Failed to compile require factory script" );
95
95
return ;
96
96
}
97
97
98
98
Local<Value> result;
99
99
if (!script->Run (context).ToLocal (&result) && tc.HasCaught ()) {
100
100
tns::LogError (isolate, tc);
101
- NSLog (@" FATAL: Failed to run require factory script" );
101
+ Log (@" FATAL: Failed to run require factory script" );
102
102
return ;
103
103
}
104
104
if (result.IsEmpty () || !result->IsFunction ()) {
105
- NSLog (@" FATAL: Require factory script did not return a function" );
105
+ Log (@" FATAL: Require factory script did not return a function" );
106
106
return ;
107
107
}
108
108
@@ -121,7 +121,7 @@ bool IsESModule(const std::string& path) {
121
121
bool success =
122
122
global->Set (context, tns::ToV8String (isolate, " require" ), globalRequire).FromMaybe (false );
123
123
if (!success) {
124
- NSLog (@" FATAL: Failed to set global require function" );
124
+ Log (@" FATAL: Failed to set global require function" );
125
125
}
126
126
}
127
127
@@ -139,7 +139,7 @@ bool IsESModule(const std::string& path) {
139
139
ToV8String (isolate, RuntimeConfig.ApplicationPath ))
140
140
.FromMaybe (false );
141
141
if (!setDir) {
142
- NSLog (@" Warning: Failed to set __dirname on global object" );
142
+ Log (@" Warning: Failed to set __dirname on global object" );
143
143
}
144
144
}
145
145
}
@@ -154,12 +154,12 @@ bool IsESModule(const std::string& path) {
154
154
moduleNamespace = ModuleInternal::LoadESModule (isolate, path);
155
155
} catch (const NativeScriptException& ex) {
156
156
if (RuntimeConfig.IsDebug ) {
157
- NSLog (@" ***** JavaScript exception occurred - detailed stack trace follows *****" );
158
- NSLog (@" Error loading ES module: %s " , path.c_str());
159
- NSLog (@" Exception: %s " , ex.getMessage().c_str());
160
- NSLog (@" ***** End stack trace - continuing execution *****" );
161
- NSLog (@" Debug mode - ES module loading failed, but telling iOS it succeeded to prevent "
162
- @" app termination" );
157
+ Log (@" ***** JavaScript exception occurred - detailed stack trace follows *****" );
158
+ Log (@" Error loading ES module: %s " , path.c_str ());
159
+ Log (@" Exception: %s " , ex.getMessage ().c_str ());
160
+ Log (@" ***** End stack trace - continuing execution *****" );
161
+ Log (@" Debug mode - ES module loading failed, but telling iOS it succeeded to prevent "
162
+ @" app termination" );
163
163
return true ; // LIE TO iOS - return success to prevent app termination
164
164
} else {
165
165
return false ;
@@ -168,7 +168,7 @@ bool IsESModule(const std::string& path) {
168
168
169
169
if (moduleNamespace.IsEmpty ()) {
170
170
if (RuntimeConfig.IsDebug ) {
171
- NSLog (@" Debug mode - ES module returned empty namespace, but telling iOS it succeeded" );
171
+ Log (@" Debug mode - ES module returned empty namespace, but telling iOS it succeeded" );
172
172
return true ; // LIE TO iOS - return success to prevent app termination
173
173
} else {
174
174
return false ;
@@ -182,7 +182,7 @@ bool IsESModule(const std::string& path) {
182
182
Local<Value> requireObj;
183
183
bool success = globalObject->Get (context, ToV8String (isolate, " require" )).ToLocal (&requireObj);
184
184
if (!success || !requireObj->IsFunction ()) {
185
- NSLog (@" Warning: Failed to get require function from global object" );
185
+ Log (@" Warning: Failed to get require function from global object" );
186
186
return false ;
187
187
}
188
188
Local<v8::Function> requireFunc = requireObj.As <v8::Function>();
@@ -195,24 +195,24 @@ bool IsESModule(const std::string& path) {
195
195
196
196
if (!success || tc.HasCaught ()) {
197
197
if (RuntimeConfig.IsDebug ) {
198
- NSLog (@" ***** JavaScript exception occurred - detailed stack trace follows *****" );
199
- NSLog (@" Error in require() call:" );
200
- NSLog (@" Requested module: '%s '" , path.c_str());
201
- NSLog (@" Called from: %s " , RuntimeConfig.ApplicationPath.c_str());
198
+ Log (@" ***** JavaScript exception occurred - detailed stack trace follows *****" );
199
+ Log (@" Error in require() call:" );
200
+ Log (@" Requested module: '%s '" , path.c_str ());
201
+ Log (@" Called from: %s " , RuntimeConfig.ApplicationPath .c_str ());
202
202
203
203
if (tc.HasCaught ()) {
204
204
tns::LogError (isolate, tc);
205
205
}
206
206
207
- NSLog (@" ***** End stack trace - continuing execution *****" );
208
- NSLog (@" Debug mode - Main script execution failed, but telling iOS it succeeded to prevent "
209
- @" app termination" );
207
+ Log (@" ***** End stack trace - continuing execution *****" );
208
+ Log (@" Debug mode - Main script execution failed, but telling iOS it succeeded to prevent "
209
+ @" app termination" );
210
210
211
211
// Add a small delay to ensure error modal has time to render before we return
212
212
dispatch_after (
213
213
dispatch_time (DISPATCH_TIME_NOW, (int64_t )(0.3 * NSEC_PER_SEC)),
214
214
dispatch_get_main_queue (), ^{
215
- NSLog (@" 🛡️ Debug mode - Crash prevention complete, app should remain stable" );
215
+ Log (@" 🛡️ Debug mode - Crash prevention complete, app should remain stable" );
216
216
});
217
217
218
218
return true ; // LIE TO iOS - return success to prevent app termination
@@ -241,11 +241,11 @@ bool IsESModule(const std::string& path) {
241
241
if (tc.HasCaught ()) {
242
242
tns::LogError (isolate, tc);
243
243
}
244
- NSLog (@" FATAL: Failed to call require factory function" );
244
+ Log (@" FATAL: Failed to call require factory function" );
245
245
// Return a dummy function to avoid further crashes
246
246
result = v8::Function::New (context, [](const v8::FunctionCallbackInfo<v8::Value>& info) {
247
247
if (RuntimeConfig.IsDebug ) {
248
- NSLog (@" Debug mode - Require function unavailable (factory failed)" );
248
+ Log (@" Debug mode - Require function unavailable (factory failed)" );
249
249
info.GetReturnValue ().SetUndefined ();
250
250
} else {
251
251
info.GetIsolate ()->ThrowException (v8::Exception::Error (
@@ -255,11 +255,11 @@ bool IsESModule(const std::string& path) {
255
255
}
256
256
257
257
if (result.IsEmpty () || !result->IsFunction ()) {
258
- NSLog (@" FATAL: Require factory did not return a function" );
258
+ Log (@" FATAL: Require factory did not return a function" );
259
259
// Return a dummy function
260
260
result = v8::Function::New (context, [](const v8::FunctionCallbackInfo<v8::Value>& info) {
261
261
if (RuntimeConfig.IsDebug ) {
262
- NSLog (@" Debug mode - Require function unavailable (no function returned)" );
262
+ Log (@" Debug mode - Require function unavailable (no function returned)" );
263
263
info.GetReturnValue ().SetUndefined ();
264
264
} else {
265
265
info.GetIsolate ()->ThrowException (v8::Exception::Error (
@@ -351,7 +351,7 @@ bool IsESModule(const std::string& path) {
351
351
if (success) {
352
352
info.GetReturnValue ().Set (exportsObj);
353
353
} else {
354
- NSLog (@" Warning: Failed to get exports from module object" );
354
+ Log (@" Warning: Failed to get exports from module object" );
355
355
}
356
356
}
357
357
} catch (NativeScriptException& ex) {
@@ -481,7 +481,7 @@ bool IsESModule(const std::string& path) {
481
481
bool success =
482
482
moduleObj->Set (context, tns::ToV8String (isolate, " exports" ), exportsObj).FromMaybe (false );
483
483
if (!success) {
484
- NSLog (@" Warning: Failed to set exports property on module object" );
484
+ Log (@" Warning: Failed to set exports property on module object" );
485
485
}
486
486
487
487
const PropertyAttribute readOnlyFlags =
@@ -492,7 +492,7 @@ bool IsESModule(const std::string& path) {
492
492
moduleObj->DefineOwnProperty (context, tns::ToV8String (isolate, " id" ), fileName, readOnlyFlags)
493
493
.FromMaybe (false );
494
494
if (!success) {
495
- NSLog (@" Warning: Failed to set id property on module object" );
495
+ Log (@" Warning: Failed to set id property on module object" );
496
496
}
497
497
498
498
std::shared_ptr<Persistent<Object>> poModuleObj =
@@ -523,8 +523,8 @@ bool IsESModule(const std::string& path) {
523
523
// First check if scriptValue is empty (from debug mode graceful returns)
524
524
if (scriptValue.IsEmpty ()) {
525
525
if (RuntimeConfig.IsDebug ) {
526
- NSLog (@" Debug mode - ES module returned empty value, returning gracefully: %s " ,
527
- modulePath.c_str());
526
+ Log (@" Debug mode - ES module returned empty value, returning gracefully: %s " ,
527
+ modulePath.c_str ());
528
528
return Local<Object>();
529
529
} else {
530
530
throw NativeScriptException (isolate, " ES module load returned empty value " + modulePath);
@@ -533,7 +533,7 @@ bool IsESModule(const std::string& path) {
533
533
534
534
if (!scriptValue->IsObject ()) {
535
535
if (RuntimeConfig.IsDebug ) {
536
- NSLog (@" Debug mode - ES module load failed, returning gracefully: %s " , modulePath.c_str());
536
+ Log (@" Debug mode - ES module load failed, returning gracefully: %s " , modulePath.c_str ());
537
537
// Return empty module object to prevent crashes
538
538
return Local<Object>();
539
539
} else {
@@ -572,7 +572,7 @@ bool IsESModule(const std::string& path) {
572
572
bool succ =
573
573
moduleObj->Set (context, tns::ToV8String (isolate, " exports" ), exportsObj).FromMaybe (false );
574
574
if (!succ) {
575
- NSLog (@" Warning: Failed to set exports property after module execution" );
575
+ Log (@" Warning: Failed to set exports property after module execution" );
576
576
}
577
577
578
578
tempModule.SaveToCache ();
@@ -619,7 +619,7 @@ throw NativeScriptException(isolate,
619
619
620
620
success = moduleObj->Set (context, tns::ToV8String (isolate, " require" ), require).FromMaybe (false );
621
621
if (!success) {
622
- NSLog (@" Warning: Failed to set require property on module object" );
622
+ Log (@" Warning: Failed to set require property on module object" );
623
623
}
624
624
625
625
{
@@ -678,8 +678,8 @@ throw NativeScriptException(isolate,
678
678
// Check if script compilation failed (debug mode graceful returns)
679
679
if (script.IsEmpty ()) {
680
680
if (RuntimeConfig.IsDebug ) {
681
- NSLog (@" Debug mode - Classic script compilation returned empty, returning gracefully: %s " ,
682
- path.c_str());
681
+ Log (@" Debug mode - Classic script compilation returned empty, returning gracefully: %s " ,
682
+ path.c_str ());
683
683
return Local<Value>();
684
684
} else {
685
685
throw NativeScriptException (isolate, " Classic script compilation failed for " + path);
@@ -698,13 +698,13 @@ throw NativeScriptException(isolate,
698
698
jsErrorOccurred = true ;
699
699
700
700
// Log the detailed JavaScript error with full stack trace
701
- NSLog (@" ***** JavaScript exception occurred - detailed stack trace follows *****" );
702
- NSLog (@" Error executing script: %s " , path.c_str());
701
+ Log (@" ***** JavaScript exception occurred - detailed stack trace follows *****" );
702
+ Log (@" Error executing script: %s " , path.c_str ());
703
703
if (tc.HasCaught ()) {
704
704
tns::LogError (isolate, tc);
705
705
}
706
- NSLog (@" ***** End stack trace - continuing execution *****" );
707
- NSLog (@" Debug mode - Script execution failed, returning gracefully: %s " , path.c_str());
706
+ Log (@" ***** End stack trace - continuing execution *****" );
707
+ Log (@" Debug mode - Script execution failed, returning gracefully: %s " , path.c_str ());
708
708
return Local<Value>();
709
709
} else {
710
710
if (tc.HasCaught ()) {
@@ -764,13 +764,13 @@ ScriptOrigin origin(isolate, urlString,
764
764
jsErrorOccurred = true ;
765
765
766
766
// Log the detailed JavaScript error with full stack trace
767
- NSLog (@" ***** JavaScript exception occurred - detailed stack trace follows *****" );
768
- NSLog (@" Error compiling classic script: %s " , path.c_str());
767
+ Log (@" ***** JavaScript exception occurred - detailed stack trace follows *****" );
768
+ Log (@" Error compiling classic script: %s " , path.c_str ());
769
769
if (tc.HasCaught ()) {
770
770
tns::LogError (isolate, tc);
771
771
}
772
- NSLog (@" ***** End stack trace - continuing execution *****" );
773
- NSLog (@" Debug mode - Script compilation failed, returning gracefully: %s " , path.c_str());
772
+ Log (@" ***** End stack trace - continuing execution *****" );
773
+ Log (@" Debug mode - Script compilation failed, returning gracefully: %s " , path.c_str ());
774
774
// Return empty script to prevent crashes
775
775
return Local<Script>();
776
776
} else {
@@ -816,13 +816,13 @@ ScriptOrigin origin(isolate, urlString, 0, 0, false, -1, Local<Value>(), false,
816
816
// V8 threw a syntax error or similar
817
817
if (RuntimeConfig.IsDebug ) {
818
818
// Log the detailed JavaScript error with full stack trace
819
- NSLog (@" ***** JavaScript exception occurred - detailed stack trace follows *****" );
820
- NSLog (@" Error compiling ES module: %s " , path.c_str());
819
+ Log (@" ***** JavaScript exception occurred - detailed stack trace follows *****" );
820
+ Log (@" Error compiling ES module: %s " , path.c_str ());
821
821
if (tcCompile.HasCaught ()) {
822
822
tns::LogError (isolate, tcCompile);
823
823
}
824
- NSLog (@" ***** End stack trace - continuing execution *****" );
825
- NSLog (@" Debug mode - ES module compilation failed, returning gracefully: %s " , path.c_str());
824
+ Log (@" ***** End stack trace - continuing execution *****" );
825
+ Log (@" Debug mode - ES module compilation failed, returning gracefully: %s " , path.c_str ());
826
826
// Return empty to prevent crashes
827
827
return Local<Value>();
828
828
} else {
@@ -859,13 +859,13 @@ ScriptOrigin origin(isolate, urlString, 0, 0, false, -1, Local<Value>(), false,
859
859
if (!linked) {
860
860
if (RuntimeConfig.IsDebug ) {
861
861
// Log the detailed JavaScript error with full stack trace
862
- NSLog (@" ***** JavaScript exception occurred - detailed stack trace follows *****" );
863
- NSLog (@" Error instantiating module: %s " , path.c_str());
862
+ Log (@" ***** JavaScript exception occurred - detailed stack trace follows *****" );
863
+ Log (@" Error instantiating module: %s " , path.c_str ());
864
864
if (tcLink.HasCaught ()) {
865
865
tns::LogError (isolate, tcLink);
866
866
}
867
- NSLog (@" ***** End stack trace - continuing execution *****" );
868
- NSLog (@" Debug mode - Module instantiation failed, returning gracefully: %s " , path.c_str());
867
+ Log (@" ***** End stack trace - continuing execution *****" );
868
+ Log (@" Debug mode - Module instantiation failed, returning gracefully: %s " , path.c_str ());
869
869
return Local<Value>();
870
870
} else {
871
871
if (tcLink.HasCaught ()) {
@@ -887,13 +887,13 @@ ScriptOrigin origin(isolate, urlString, 0, 0, false, -1, Local<Value>(), false,
887
887
printf (" LoadESModule: Evaluation failed for module: %s\n " , path.c_str ());
888
888
if (RuntimeConfig.IsDebug ) {
889
889
// Log the detailed JavaScript error with full stack trace
890
- NSLog (@" ***** JavaScript exception occurred - detailed stack trace follows *****" );
891
- NSLog (@" Error evaluating ES module: %s " , path.c_str());
890
+ Log (@" ***** JavaScript exception occurred - detailed stack trace follows *****" );
891
+ Log (@" Error evaluating ES module: %s " , path.c_str ());
892
892
if (tcEval.HasCaught ()) {
893
893
tns::LogError (isolate, tcEval);
894
894
}
895
- NSLog (@" ***** End stack trace - continuing execution *****" );
896
- NSLog (@" Debug mode - Module evaluation failed, returning gracefully: %s " , path.c_str());
895
+ Log (@" ***** End stack trace - continuing execution *****" );
896
+ Log (@" Debug mode - Module evaluation failed, returning gracefully: %s " , path.c_str ());
897
897
return Local<Value>();
898
898
} else {
899
899
throw NativeScriptException (isolate, tcEval, " Cannot evaluate module " + path);
@@ -935,7 +935,7 @@ ScriptOrigin origin(isolate, urlString, 0, 0, false, -1, Local<Value>(), false,
935
935
jsErrorOccurred = true ;
936
936
937
937
// First log the detailed JavaScript error with full stack trace
938
- NSLog (@" ***** JavaScript exception occurred - detailed stack trace follows *****" );
938
+ Log (@" ***** JavaScript exception occurred - detailed stack trace follows *****" );
939
939
940
940
std::string errorTitle = " Uncaught JavaScript Exception" ;
941
941
std::string errorMessage = " Module evaluation promise rejected" ;
@@ -983,9 +983,9 @@ ScriptOrigin origin(isolate, urlString, 0, 0, false, -1, Local<Value>(), false,
983
983
}
984
984
985
985
// Log the extracted error information
986
- NSLog (@" NativeScript encountered a fatal error: %s " , errorMessage.c_str());
986
+ Log (@" NativeScript encountered a fatal error: %s " , errorMessage.c_str ());
987
987
if (!stackTrace.empty ()) {
988
- NSLog (@" JavaScript stack trace:\n %s " , stackTrace.c_str());
988
+ Log (@" JavaScript stack trace:\n %s " , stackTrace.c_str ());
989
989
}
990
990
}
991
991
@@ -994,7 +994,7 @@ ScriptOrigin origin(isolate, urlString, 0, 0, false, -1, Local<Value>(), false,
994
994
tns::LogError (isolate, promiseTc);
995
995
}
996
996
997
- NSLog (@" ***** End stack trace - Fix to continue *****" );
997
+ Log (@" ***** End stack trace - Fix to continue *****" );
998
998
999
999
NativeScriptException::ShowErrorModal (errorTitle, errorMessage, stackTrace);
1000
1000
@@ -1051,7 +1051,7 @@ ScriptOrigin origin(isolate, urlString, 0, 0, false, -1, Local<Value>(), false,
1051
1051
Local<Value> requireObj;
1052
1052
bool success = globalObject->Get (context, ToV8String (isolate, " require" )).ToLocal (&requireObj);
1053
1053
if (!success || !requireObj->IsFunction ()) {
1054
- NSLog (@" Warning: Failed to get require function from global object in RunScript" );
1054
+ Log (@" Warning: Failed to get require function from global object in RunScript" );
1055
1055
return ;
1056
1056
}
1057
1057
Local<Value> result;
@@ -1322,7 +1322,7 @@ throw NativeScriptException(
1322
1322
bool success = moduleObj->Set (context, tns::ToV8String (isolate, " exports" ), proxyObject)
1323
1323
.FromMaybe (false );
1324
1324
if (!success) {
1325
- NSLog (@" Warning: Failed to set exports property on proxy module object" );
1325
+ Log (@" Warning: Failed to set exports property on proxy module object" );
1326
1326
}
1327
1327
}
1328
1328
}
@@ -1333,14 +1333,14 @@ throw NativeScriptException(
1333
1333
tns::ToV8String (isolate, moduleName.c_str ()))
1334
1334
.FromMaybe (false );
1335
1335
if (!success) {
1336
- NSLog (@" Warning: Failed to set id property on module object" );
1336
+ Log (@" Warning: Failed to set id property on module object" );
1337
1337
}
1338
1338
1339
1339
success =
1340
1340
moduleObj->Set (context, tns::ToV8String (isolate, " loaded" ), v8::Boolean::New (isolate, true ))
1341
1341
.FromMaybe (false );
1342
1342
if (!success) {
1343
- NSLog (@" Warning: Failed to set loaded property on module object" );
1343
+ Log (@" Warning: Failed to set loaded property on module object" );
1344
1344
}
1345
1345
1346
1346
// Cache the placeholder module
0 commit comments