@nativescript/windows 0.1.0-alpha.75 → 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.
@@ -0,0 +1,15 @@
1
+ <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2
+ <!-- Default property values for manifest overrides.
3
+ Override these in Directory.Build.props or via /p: properties. -->
4
+ <PropertyGroup>
5
+ <AppDisplayName Condition=" '$(AppDisplayName)' == '' ">__PROJECT_NAME__</AppDisplayName>
6
+ <AppDescription Condition=" '$(AppDescription)' == '' ">A NativeScript Windows application</AppDescription>
7
+ <Square150x150Logo Condition=" '$(Square150x150Logo)' == '' ">Assets\Square150x150Logo.png</Square150x150Logo>
8
+ <Square44x44Logo Condition=" '$(Square44x44Logo)' == '' ">Assets\Square44x44Logo.png</Square44x44Logo>
9
+ <Wide310x150Logo Condition=" '$(Wide310x150Logo)' == '' ">Assets\Wide310x150Logo.png</Wide310x150Logo>
10
+ <StoreLogo Condition=" '$(StoreLogo)' == '' ">Assets\StoreLogo.png</StoreLogo>
11
+ <LockScreenLogo Condition=" '$(LockScreenLogo)' == '' ">Assets\LockScreenLogo.png</LockScreenLogo>
12
+ <SplashBackgroundColor Condition=" '$(SplashBackgroundColor)' == '' ">#65ADF1</SplashBackgroundColor>
13
+ <SplashImage Condition=" '$(SplashImage)' == '' ">Assets\SplashScreen.png</SplashImage>
14
+ </PropertyGroup>
15
+ </Project>
@@ -0,0 +1,153 @@
1
+ <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2
+ <!-- Directory.Build.targets for the Windows project template.
3
+ This file applies manifest overrides at build time using XmlPoke.
4
+ Place in the template root so generated projects inherit it. -->
5
+ <!-- Default properties are provided in Directory.Build.props so they can be
6
+ easily overridden per-app or via MSBuild /p: properties. -->
7
+
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" Condition="'$(MSBuildRuntimeType)' != 'Core'">
10
+ <ParameterGroup>
11
+ <SourceManifest ParameterType="System.String" Required="true" />
12
+ <TargetManifest ParameterType="System.String" Required="true" />
13
+ </ParameterGroup>
14
+ <Task>
15
+ <Reference Include="System.Core" />
16
+ <Reference Include="System.Xml" />
17
+ <Reference Include="System.Xml.Linq" />
18
+ <Using Namespace="System" />
19
+ <Using Namespace="System.IO" />
20
+ <Using Namespace="System.Linq" />
21
+ <Using Namespace="System.Xml.Linq" />
22
+ <Code Type="Fragment" Language="cs"><![CDATA[
23
+ try {
24
+ if (!File.Exists(SourceManifest)) { Log.LogMessage(MessageImportance.Low, "No source manifest found: " + SourceManifest); return true; }
25
+ if (!File.Exists(TargetManifest)) { Log.LogMessage(MessageImportance.Low, "No target manifest found: " + TargetManifest); return true; }
26
+ XDocument src = XDocument.Load(SourceManifest);
27
+ XDocument dest = XDocument.Load(TargetManifest);
28
+
29
+ Func<XElement, XElement, bool> mergeElement = null;
30
+ mergeElement = (srcElem, destParent) => {
31
+ XElement match = destParent.Elements().FirstOrDefault(c => c.Name.LocalName == srcElem.Name.LocalName);
32
+ if (match == null) {
33
+ destParent.Add(new XElement(srcElem));
34
+ return true;
35
+ }
36
+ // copy/overwrite attributes
37
+ foreach (var a in srcElem.Attributes()) { match.SetAttributeValue(a.Name, a.Value); }
38
+ // merge children
39
+ foreach (var child in srcElem.Elements()) {
40
+ // skip if identical child exists
41
+ bool exists = match.Elements().Any(mc => mc.Name.LocalName == child.Name.LocalName && mc.ToString() == child.ToString());
42
+ if (exists) { continue; }
43
+ // try to find same-named child to merge into
44
+ XElement matchChild = match.Elements().FirstOrDefault(mc => mc.Name.LocalName == child.Name.LocalName);
45
+ if (matchChild != null) { mergeElement(child, matchChild); } else { match.Add(new XElement(child)); }
46
+ }
47
+ return true;
48
+ };
49
+
50
+ // Merge VisualElements (common case) into the Application node
51
+ var srcVisuals = src.Descendants().Where(e => e.Name.LocalName == "VisualElements");
52
+ foreach (var ve in srcVisuals) {
53
+ var destApp = dest.Descendants().FirstOrDefault(e => e.Name.LocalName == "Application");
54
+ if (destApp == null) { dest.Root.Add(new XElement(ve)); }
55
+ else { mergeElement(ve, destApp); }
56
+ }
57
+
58
+ // Merge Capabilities (if present)
59
+ var srcCaps = src.Descendants().Where(e => e.Name.LocalName == "Capabilities");
60
+ foreach (var cap in srcCaps) {
61
+ var destCaps = dest.Descendants().FirstOrDefault(e => e.Name.LocalName == "Capabilities");
62
+ if (destCaps == null) { dest.Root.Add(new XElement(cap)); }
63
+ else { mergeElement(cap, destCaps); }
64
+ }
65
+
66
+ // Merge other top-level sections present in src (e.g., Extensions) by local-name
67
+ foreach (var top in src.Root.Elements()) {
68
+ if (top.Name.LocalName == "Dependencies" || top.Name.LocalName == "Applications") { continue; }
69
+ var existing = dest.Root.Elements().FirstOrDefault(e => e.Name.LocalName == top.Name.LocalName);
70
+ if (existing == null) { dest.Root.Add(new XElement(top)); }
71
+ else {
72
+ // merge children of this section
73
+ foreach (var child in top.Elements()) {
74
+ bool exists = existing.Elements().Any(ec => ec.Name.LocalName == child.Name.LocalName && ec.ToString() == child.ToString());
75
+ if (!exists) { existing.Add(new XElement(child)); }
76
+ }
77
+ }
78
+ }
79
+
80
+ dest.Save(TargetManifest);
81
+ Log.LogMessage(MessageImportance.High, $"Merged manifest from {SourceManifest} into {TargetManifest}");
82
+ return true;
83
+ } catch (Exception ex) { Log.LogErrorFromException(ex); return false; }
84
+ ]]></Code>
85
+ </Task>
86
+ </UsingTask>
87
+
88
+ <Target Name="MergeAppResourcesManifest" AfterTargets="ApplyManifestOverrides" Condition="Exists('$(MSBuildProjectDirectory)\Package.appxmanifest') and '$(MSBuildRuntimeType)' != 'Core'">
89
+ <PropertyGroup>
90
+ <_AppResourcesManifest>$(MSBuildProjectDirectory)\App_Resources\Windows\Package.appxmanifest</_AppResourcesManifest>
91
+ <!-- Allow CLI or callers to override the source manifest via MSBuild property 'AppResourcesManifestPath' -->
92
+ <_AppResourcesManifest Condition="'$(AppResourcesManifestPath)' != ''">$(AppResourcesManifestPath)</_AppResourcesManifest>
93
+ <!-- Fallback template manifest name (no '.partial' suffix) -->
94
+ <_PartialManifest>$(MSBuildProjectDirectory)\Package.appxmanifest</_PartialManifest>
95
+ </PropertyGroup>
96
+ <Message Text="Merging app manifest (if present) into generated Package.appxmanifest (app wins)" Importance="Low" />
97
+ <MergeAppxManifest SourceManifest="$([System.IO.File]::Exists('$(_AppResourcesManifest)') ? '$(_AppResourcesManifest)' : '$(_PartialManifest)')" TargetManifest="$(MSBuildProjectDirectory)\Package.appxmanifest" Condition=" $([System.IO.File]::Exists('$(_AppResourcesManifest)')) Or $([System.IO.File]::Exists('$(_PartialManifest)')) " />
98
+ </Target>
99
+
100
+ <Target Name="ApplyManifestOverrides" BeforeTargets="BeforeBuild" Condition="Exists('$(MSBuildProjectDirectory)\Package.appxmanifest')">
101
+ <Message Text="Applying manifest overrides (VisualElements, logos, splash) via XmlPoke..." Importance="High" />
102
+
103
+ <!-- DisplayName -->
104
+ <XmlPoke XmlInputPath="$(MSBuildProjectDirectory)\Package.appxmanifest"
105
+ Query="/*[local-name()='Package']/*[local-name()='Applications']/*[local-name()='Application']/*[local-name()='VisualElements']/@DisplayName"
106
+ Value="$(AppDisplayName)"
107
+ Condition="'$(AppDisplayName)' != ''" />
108
+
109
+ <!-- Description -->
110
+ <XmlPoke XmlInputPath="$(MSBuildProjectDirectory)\Package.appxmanifest"
111
+ Query="/*[local-name()='Package']/*[local-name()='Applications']/*[local-name()='Application']/*[local-name()='VisualElements']/@Description"
112
+ Value="$(AppDescription)"
113
+ Condition="'$(AppDescription)' != ''" />
114
+
115
+ <!-- Logos -->
116
+ <XmlPoke XmlInputPath="$(MSBuildProjectDirectory)\Package.appxmanifest"
117
+ Query="/*[local-name()='Package']/*[local-name()='Applications']/*[local-name()='Application']/*[local-name()='VisualElements']/@Square150x150Logo"
118
+ Value="$(Square150x150Logo)"
119
+ Condition="'$(Square150x150Logo)' != ''" />
120
+
121
+ <XmlPoke XmlInputPath="$(MSBuildProjectDirectory)\Package.appxmanifest"
122
+ Query="/*[local-name()='Package']/*[local-name()='Applications']/*[local-name()='Application']/*[local-name()='VisualElements']/@Square44x44Logo"
123
+ Value="$(Square44x44Logo)"
124
+ Condition="'$(Square44x44Logo)' != ''" />
125
+
126
+ <XmlPoke XmlInputPath="$(MSBuildProjectDirectory)\Package.appxmanifest"
127
+ Query="/*[local-name()='Package']/*[local-name()='Applications']/*[local-name()='Application']/*[local-name()='VisualElements']/*[local-name()='DefaultTile']/@Wide310x150Logo"
128
+ Value="$(Wide310x150Logo)"
129
+ Condition="'$(Wide310x150Logo)' != ''" />
130
+
131
+ <XmlPoke XmlInputPath="$(MSBuildProjectDirectory)\Package.appxmanifest"
132
+ Query="/*[local-name()='Package']/*[local-name()='Applications']/*[local-name()='Application']/*[local-name()='VisualElements']/@StoreLogo"
133
+ Value="$(StoreLogo)"
134
+ Condition="'$(StoreLogo)' != ''" />
135
+
136
+ <XmlPoke XmlInputPath="$(MSBuildProjectDirectory)\Package.appxmanifest"
137
+ Query="/*[local-name()='Package']/*[local-name()='Applications']/*[local-name()='Application']/*[local-name()='VisualElements']/@LockScreenLogo"
138
+ Value="$(LockScreenLogo)"
139
+ Condition="'$(LockScreenLogo)' != ''" />
140
+
141
+ <!-- BackgroundColor and SplashScreen image -->
142
+ <XmlPoke XmlInputPath="$(MSBuildProjectDirectory)\Package.appxmanifest"
143
+ Query="/*[local-name()='Package']/*[local-name()='Applications']/*[local-name()='Application']/*[local-name()='VisualElements']/@BackgroundColor"
144
+ Value="$(SplashBackgroundColor)"
145
+ Condition="'$(SplashBackgroundColor)' != ''" />
146
+
147
+ <XmlPoke XmlInputPath="$(MSBuildProjectDirectory)\Package.appxmanifest"
148
+ Query="/*[local-name()='Package']/*[local-name()='Applications']/*[local-name()='Application']/*[local-name()='VisualElements']/*[local-name()='SplashScreen']/@Image"
149
+ Value="$(SplashImage)"
150
+ Condition="'$(SplashImage)' != ''" />
151
+
152
+ </Target>
153
+ </Project>
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript/windows",
3
- "version": "0.1.0-alpha.75",
3
+ "version": "0.1.0-alpha.77",
4
4
  "description": "NativeScript for using Windows v8",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,55 +0,0 @@
1
- [
2
- {
3
- "typeName": "TemplateNamedJsonObject",
4
- "className": "TemplateNamedJsonObject",
5
- "namespace": null,
6
- "baseClass": "Windows.Data.Json.JsonObject",
7
- "methods": [
8
- {
9
- "name": "ToString",
10
- "returnType": "String",
11
- "parameters": []
12
- }
13
- ],
14
- "properties": [],
15
- "interfaces": [],
16
- "isAutoGeneratedName": false,
17
- "registeredAt": "2026-05-21T19:10:11.007Z"
18
- },
19
- {
20
- "typeName": "com.tns.gen.winrt.windows.data.json.JsonObject_AutoProxy_2",
21
- "className": "JsonObject_AutoProxy_2",
22
- "namespace": "com.tns.gen.winrt.windows.data.json",
23
- "baseClass": "Windows.Data.Json.JsonObject",
24
- "methods": [
25
- {
26
- "name": "ToString",
27
- "returnType": "String",
28
- "parameters": []
29
- }
30
- ],
31
- "properties": [],
32
- "interfaces": [],
33
- "isAutoGeneratedName": false,
34
- "registeredAt": "2026-05-21T19:10:11.024Z"
35
- },
36
- {
37
- "typeName": "com.tns.gen.winrt.windows.Object_AutoProxy_3",
38
- "className": "Object_AutoProxy_3",
39
- "namespace": "com.tns.gen.winrt.windows",
40
- "baseClass": "Object",
41
- "methods": [
42
- {
43
- "name": "ToString",
44
- "returnType": "String",
45
- "parameters": []
46
- }
47
- ],
48
- "properties": [],
49
- "interfaces": [
50
- "Windows.Foundation.IStringable"
51
- ],
52
- "isAutoGeneratedName": false,
53
- "registeredAt": "2026-05-21T19:10:11.042Z"
54
- }
55
- ]