@nativescript/windows 0.1.0-alpha.21 → 0.1.0-alpha.22
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__/CrashDiagnostics.cs +59 -8
- 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
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
using System;
|
|
2
2
|
using System.IO;
|
|
3
3
|
using System.Text;
|
|
4
|
+
using System.Text.RegularExpressions;
|
|
4
5
|
using System.Threading.Tasks;
|
|
5
6
|
using Windows.ApplicationModel.Core;
|
|
6
7
|
using Windows.ApplicationModel.DataTransfer;
|
|
7
8
|
using Windows.Storage;
|
|
9
|
+
using Windows.System;
|
|
8
10
|
using Windows.UI.Popups;
|
|
9
11
|
|
|
10
12
|
namespace __PROJECT_NAME__
|
|
@@ -118,6 +120,31 @@ namespace __PROJECT_NAME__
|
|
|
118
120
|
catch { return null; }
|
|
119
121
|
}
|
|
120
122
|
|
|
123
|
+
/// Parses the first "path:line:col" source location from a JS stack trace.
|
|
124
|
+
/// Returns null if none found. Handles Windows drive-letter paths (C:\...).
|
|
125
|
+
public static (string file, int line, int col)? TryExtractSourceLocation(string errorReport)
|
|
126
|
+
{
|
|
127
|
+
if (string.IsNullOrEmpty(errorReport)) return null;
|
|
128
|
+
|
|
129
|
+
// Match the contents of the first (path:line:col) group in the stack trace.
|
|
130
|
+
var m = Regex.Match(errorReport, @"\(([^)]+)\)");
|
|
131
|
+
if (!m.Success) return null;
|
|
132
|
+
|
|
133
|
+
var inner = m.Groups[1].Value; // e.g. "C:\app\bundle.js:42:13"
|
|
134
|
+
|
|
135
|
+
// Parse col from the right (last :digits).
|
|
136
|
+
var lastColon = inner.LastIndexOf(':');
|
|
137
|
+
if (lastColon < 0 || !int.TryParse(inner.Substring(lastColon + 1), out int col)) return null;
|
|
138
|
+
inner = inner.Substring(0, lastColon);
|
|
139
|
+
|
|
140
|
+
// Parse line from the right (second-to-last :digits).
|
|
141
|
+
lastColon = inner.LastIndexOf(':');
|
|
142
|
+
if (lastColon < 0 || !int.TryParse(inner.Substring(lastColon + 1), out int line)) return null;
|
|
143
|
+
var file = inner.Substring(0, lastColon);
|
|
144
|
+
|
|
145
|
+
return string.IsNullOrEmpty(file) ? null : (file, line, col);
|
|
146
|
+
}
|
|
147
|
+
|
|
121
148
|
public static async Task ShowCrashDialogAsync(string heading, string errorReport)
|
|
122
149
|
{
|
|
123
150
|
try
|
|
@@ -139,16 +166,40 @@ namespace __PROJECT_NAME__
|
|
|
139
166
|
|
|
140
167
|
var dialog = new MessageDialog(summary, "NativeScript Runtime Error");
|
|
141
168
|
|
|
142
|
-
|
|
169
|
+
// MessageDialog supports at most 3 commands. When a source location is
|
|
170
|
+
// available, swap "Copy Details" for "Open in VS Code" so the user can
|
|
171
|
+
// choose between jumping to the error or restarting. Full details are
|
|
172
|
+
// always written to the log file shown in the dialog text.
|
|
173
|
+
var srcLocation = TryExtractSourceLocation(errorReport);
|
|
174
|
+
if (srcLocation.HasValue)
|
|
143
175
|
{
|
|
144
|
-
|
|
176
|
+
var (srcFile, srcLine, srcCol) = srcLocation.Value;
|
|
177
|
+
dialog.Commands.Add(new UICommand("Open Source File", async _ =>
|
|
145
178
|
{
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
179
|
+
try
|
|
180
|
+
{
|
|
181
|
+
var normalizedPath = srcFile.Replace('\\', '/');
|
|
182
|
+
var uriStr = $"file:///{normalizedPath}";
|
|
183
|
+
if (Uri.TryCreate(uriStr, UriKind.Absolute, out var fileUri))
|
|
184
|
+
await Launcher.LaunchUriAsync(fileUri,
|
|
185
|
+
new LauncherOptions { DisplayApplicationPicker = true });
|
|
186
|
+
}
|
|
187
|
+
catch { }
|
|
188
|
+
}));
|
|
189
|
+
}
|
|
190
|
+
else
|
|
191
|
+
{
|
|
192
|
+
dialog.Commands.Add(new UICommand("Copy Details", _ =>
|
|
193
|
+
{
|
|
194
|
+
try
|
|
195
|
+
{
|
|
196
|
+
var dp = new DataPackage();
|
|
197
|
+
dp.SetText(errorReport);
|
|
198
|
+
Clipboard.SetContent(dp);
|
|
199
|
+
}
|
|
200
|
+
catch { }
|
|
201
|
+
}));
|
|
202
|
+
}
|
|
152
203
|
|
|
153
204
|
dialog.Commands.Add(new UICommand("Restart App", async _ =>
|
|
154
205
|
{
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|