@nativescript/windows 0.1.0-alpha.76 → 0.1.0-alpha.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/framework/__PROJECT_NAME__/Directory.Build.targets +2 -2
- package/framework/dotnet-bridge/Bridge.cs +99 -0
- package/framework/libs/arm64/nativescript.dll +0 -0
- package/framework/libs/devtools/arm64/nativescript.dll +0 -0
- package/framework/libs/devtools/x64/nativescript.dll +0 -0
- package/framework/libs/x64/nativescript.dll +0 -0
- package/package.json +1 -1
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
easily overridden per-app or via MSBuild /p: properties. -->
|
|
7
7
|
|
|
8
8
|
<!-- Inline merge task: will merge App_Resources/Windows/Package.appxmanifest or Package.appxmanifest.partial.xml into the generated Package.appxmanifest -->
|
|
9
|
-
<UsingTask TaskName="MergeAppxManifest" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
|
|
9
|
+
<UsingTask TaskName="MergeAppxManifest" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" Condition="'$(MSBuildRuntimeType)' != 'Core'">
|
|
10
10
|
<ParameterGroup>
|
|
11
11
|
<SourceManifest ParameterType="System.String" Required="true" />
|
|
12
12
|
<TargetManifest ParameterType="System.String" Required="true" />
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
</Task>
|
|
86
86
|
</UsingTask>
|
|
87
87
|
|
|
88
|
-
<Target Name="MergeAppResourcesManifest" AfterTargets="ApplyManifestOverrides" Condition="Exists('$(MSBuildProjectDirectory)\Package.appxmanifest')">
|
|
88
|
+
<Target Name="MergeAppResourcesManifest" AfterTargets="ApplyManifestOverrides" Condition="Exists('$(MSBuildProjectDirectory)\Package.appxmanifest') and '$(MSBuildRuntimeType)' != 'Core'">
|
|
89
89
|
<PropertyGroup>
|
|
90
90
|
<_AppResourcesManifest>$(MSBuildProjectDirectory)\App_Resources\Windows\Package.appxmanifest</_AppResourcesManifest>
|
|
91
91
|
<!-- Allow CLI or callers to override the source manifest via MSBuild property 'AppResourcesManifestPath' -->
|
|
@@ -326,6 +326,105 @@ public static partial class Bridge
|
|
|
326
326
|
return 0;
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
// Callback id registered by the runtime/JS that should receive unhandled
|
|
330
|
+
// managed exceptions and unobserved task exceptions.
|
|
331
|
+
private static int s_unhandledExceptionCallbackId = -1;
|
|
332
|
+
|
|
333
|
+
// Called from JS/Rust to request that managed unhandled exceptions be
|
|
334
|
+
// forwarded to the registered JS callback id. The callback id must have
|
|
335
|
+
// been created on the Rust side and point to a JS function stored in the
|
|
336
|
+
// runtime's `DOTNET_JS_CALLBACKS` map.
|
|
337
|
+
public static int RegisterUnhandledExceptionCallback(int callbackId)
|
|
338
|
+
{
|
|
339
|
+
s_unhandledExceptionCallbackId = callbackId;
|
|
340
|
+
|
|
341
|
+
// Subscribe once (idempotent).
|
|
342
|
+
try
|
|
343
|
+
{
|
|
344
|
+
AppDomain.CurrentDomain.UnhandledException -= OnAppDomainUnhandledException;
|
|
345
|
+
AppDomain.CurrentDomain.UnhandledException += OnAppDomainUnhandledException;
|
|
346
|
+
|
|
347
|
+
TaskScheduler.UnobservedTaskException -= OnUnobservedTaskException;
|
|
348
|
+
TaskScheduler.UnobservedTaskException += OnUnobservedTaskException;
|
|
349
|
+
|
|
350
|
+
// Try to subscribe to Windows.CoreApplication.UnhandledErrorDetected if available
|
|
351
|
+
foreach (var asm in AppDomain.CurrentDomain.GetAssemblies())
|
|
352
|
+
{
|
|
353
|
+
var coreAppType = asm.GetType("Windows.ApplicationModel.Core.CoreApplication");
|
|
354
|
+
if (coreAppType == null) continue;
|
|
355
|
+
var ev = coreAppType.GetEvent("UnhandledErrorDetected");
|
|
356
|
+
if (ev == null) continue;
|
|
357
|
+
try
|
|
358
|
+
{
|
|
359
|
+
var handlerType = ev.EventHandlerType;
|
|
360
|
+
var method = typeof(Bridge).GetMethod(nameof(CoreApplicationUnhandledErrorHandler), BindingFlags.NonPublic | BindingFlags.Static);
|
|
361
|
+
if (method != null)
|
|
362
|
+
{
|
|
363
|
+
var del = Delegate.CreateDelegate(handlerType, method);
|
|
364
|
+
ev.AddEventHandler(null, del);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
catch { }
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
catch { }
|
|
371
|
+
|
|
372
|
+
return 0;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
private static void OnAppDomainUnhandledException(object? sender, UnhandledExceptionEventArgs e)
|
|
376
|
+
{
|
|
377
|
+
try
|
|
378
|
+
{
|
|
379
|
+
var ex = e.ExceptionObject as Exception;
|
|
380
|
+
var msg = ex?.ToString() ?? e.ExceptionObject?.ToString() ?? "(unknown)";
|
|
381
|
+
SendUnhandledToJs("unhandled", msg);
|
|
382
|
+
}
|
|
383
|
+
catch { }
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
private static void OnUnobservedTaskException(object? sender, UnobservedTaskExceptionEventArgs e)
|
|
387
|
+
{
|
|
388
|
+
try
|
|
389
|
+
{
|
|
390
|
+
var msg = e.Exception?.ToString() ?? "(unobserved task exception)";
|
|
391
|
+
SendUnhandledToJs("unobservedTask", msg);
|
|
392
|
+
}
|
|
393
|
+
catch { }
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
// Fallback handler for platform-specific CoreApplication unhandled events.
|
|
397
|
+
private static void CoreApplicationUnhandledErrorHandler(object? sender, object? args)
|
|
398
|
+
{
|
|
399
|
+
try
|
|
400
|
+
{
|
|
401
|
+
var msg = args?.ToString() ?? "(core unhandled)";
|
|
402
|
+
SendUnhandledToJs("coreUnhandled", msg);
|
|
403
|
+
}
|
|
404
|
+
catch { }
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
private static void SendUnhandledToJs(string kind, string message)
|
|
408
|
+
{
|
|
409
|
+
try
|
|
410
|
+
{
|
|
411
|
+
if (s_jsInvoker == null || s_unhandledExceptionCallbackId <= 0) return;
|
|
412
|
+
var payload = JsonSerializer.Serialize(new { kind = kind, message = message });
|
|
413
|
+
var bytes = System.Text.Encoding.UTF8.GetBytes(payload);
|
|
414
|
+
unsafe
|
|
415
|
+
{
|
|
416
|
+
fixed (byte* p = bytes)
|
|
417
|
+
{
|
|
418
|
+
byte* respPtr = null;
|
|
419
|
+
int respLen = 0;
|
|
420
|
+
s_jsInvoker(s_unhandledExceptionCallbackId, p, bytes.Length, &respPtr, &respLen);
|
|
421
|
+
if (respPtr != null && respLen > 0) Marshal.FreeHGlobal((IntPtr)respPtr);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
catch { }
|
|
426
|
+
}
|
|
427
|
+
|
|
329
428
|
[UnmanagedCallersOnly(EntryPoint = "Invoke",
|
|
330
429
|
CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
|
|
331
430
|
public static unsafe int Invoke(
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|