@nativescript/windows 0.1.0-alpha.1
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/build.ps1 +107 -0
- package/framework/__PROJECT_NAME__/App/main.js +12 -0
- package/framework/__PROJECT_NAME__/App.xaml +7 -0
- package/framework/__PROJECT_NAME__/App.xaml.cs +79 -0
- package/framework/__PROJECT_NAME__/CrashDiagnostics.cs +66 -0
- package/framework/__PROJECT_NAME__/Package.appxmanifest +50 -0
- package/framework/__PROJECT_NAME__/Program.cs +15 -0
- package/framework/__PROJECT_NAME__/Properties/Default.rd.xml +9 -0
- package/framework/__PROJECT_NAME__/RuntimeHost.cs +196 -0
- package/framework/__PROJECT_NAME__/__PROJECT_NAME__.csproj +50 -0
- package/framework/libs/README.md +17 -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 +18 -0
package/build.ps1
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#Requires -Version 5.1
|
|
2
|
+
<#
|
|
3
|
+
.SYNOPSIS
|
|
4
|
+
Builds both nativescript.dll configurations and copies them into
|
|
5
|
+
template/framework/libs/ ready for npm publish.
|
|
6
|
+
|
|
7
|
+
.DESCRIPTION
|
|
8
|
+
Produces four DLLs (x64 + arm64, release + devtools) from the workspace
|
|
9
|
+
Rust crate and places them at:
|
|
10
|
+
|
|
11
|
+
framework/libs/x64/nativescript.dll # release, no devtools
|
|
12
|
+
framework/libs/arm64/nativescript.dll
|
|
13
|
+
framework/libs/devtools/x64/nativescript.dll # release-with-devtools
|
|
14
|
+
framework/libs/devtools/arm64/nativescript.dll
|
|
15
|
+
|
|
16
|
+
Run from anywhere; the script locates the repo root via its own path.
|
|
17
|
+
|
|
18
|
+
.PARAMETER SkipArm64
|
|
19
|
+
Skip the arm64 cross-compilation steps (faster, x64-only output).
|
|
20
|
+
|
|
21
|
+
.PARAMETER SkipRelease
|
|
22
|
+
Skip the stripped release builds (devtools builds only).
|
|
23
|
+
|
|
24
|
+
.PARAMETER SkipDevtools
|
|
25
|
+
Skip the devtools builds (release builds only).
|
|
26
|
+
#>
|
|
27
|
+
param(
|
|
28
|
+
[switch]$SkipArm64,
|
|
29
|
+
[switch]$SkipRelease,
|
|
30
|
+
[switch]$SkipDevtools
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
Set-StrictMode -Version Latest
|
|
34
|
+
$ErrorActionPreference = "Stop"
|
|
35
|
+
|
|
36
|
+
# ── Paths ─────────────────────────────────────────────────────────────────────
|
|
37
|
+
|
|
38
|
+
$ScriptDir = $PSScriptRoot
|
|
39
|
+
$RepoRoot = (Resolve-Path (Join-Path $ScriptDir "..")).Path
|
|
40
|
+
$FrameworkLibs = Join-Path $ScriptDir "framework\libs"
|
|
41
|
+
|
|
42
|
+
Write-Host "Repo root : $RepoRoot"
|
|
43
|
+
Write-Host "Output dir : $FrameworkLibs"
|
|
44
|
+
|
|
45
|
+
# ── Helper ────────────────────────────────────────────────────────────────────
|
|
46
|
+
|
|
47
|
+
function Copy-Dll {
|
|
48
|
+
param([string]$Src, [string]$Dest)
|
|
49
|
+
$null = New-Item -ItemType Directory -Force -Path (Split-Path $Dest)
|
|
50
|
+
Copy-Item -Force $Src $Dest
|
|
51
|
+
Write-Host " copied $(Split-Path $Src -Leaf) → $(Resolve-Path $Dest -Relative 2>$null)"
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function Build-Crate {
|
|
55
|
+
param(
|
|
56
|
+
[string]$Profile, # e.g. "release" or "release-with-devtools"
|
|
57
|
+
[string]$Target, # e.g. "x86_64-pc-windows-msvc"
|
|
58
|
+
[string[]]$ExtraArgs # e.g. @("--features","devtools")
|
|
59
|
+
)
|
|
60
|
+
$args = @("build", "--profile", $Profile, "-p", "nativescript", "--target", $Target) + $ExtraArgs
|
|
61
|
+
Write-Host ""
|
|
62
|
+
Write-Host "cargo $($args -join ' ')"
|
|
63
|
+
Push-Location $RepoRoot
|
|
64
|
+
try {
|
|
65
|
+
& cargo @args
|
|
66
|
+
if ($LASTEXITCODE -ne 0) { throw "cargo build failed (exit $LASTEXITCODE)" }
|
|
67
|
+
} finally {
|
|
68
|
+
Pop-Location
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
# ── Targets ───────────────────────────────────────────────────────────────────
|
|
73
|
+
|
|
74
|
+
$Targets = @(
|
|
75
|
+
@{ Arch = "x64"; RustTarget = "x86_64-pc-windows-msvc" }
|
|
76
|
+
)
|
|
77
|
+
if (-not $SkipArm64) {
|
|
78
|
+
$Targets += @{ Arch = "arm64"; RustTarget = "aarch64-pc-windows-msvc" }
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
# ── Build ─────────────────────────────────────────────────────────────────────
|
|
82
|
+
|
|
83
|
+
foreach ($t in $Targets) {
|
|
84
|
+
$arch = $t.Arch
|
|
85
|
+
$rustTarget = $t.RustTarget
|
|
86
|
+
|
|
87
|
+
if (-not $SkipRelease) {
|
|
88
|
+
Write-Host "`n=== Release ($arch) ===" -ForegroundColor Cyan
|
|
89
|
+
Build-Crate -Profile "release" -Target $rustTarget
|
|
90
|
+
$dll = Join-Path $RepoRoot "target\$rustTarget\release\nativescript.dll"
|
|
91
|
+
Copy-Dll -Src $dll -Dest (Join-Path $FrameworkLibs "$arch\nativescript.dll")
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (-not $SkipDevtools) {
|
|
95
|
+
Write-Host "`n=== Release-with-devtools ($arch) ===" -ForegroundColor Cyan
|
|
96
|
+
Build-Crate -Profile "release-with-devtools" -Target $rustTarget -ExtraArgs @("--features", "devtools")
|
|
97
|
+
$dll = Join-Path $RepoRoot "target\$rustTarget\release-with-devtools\nativescript.dll"
|
|
98
|
+
Copy-Dll -Src $dll -Dest (Join-Path $FrameworkLibs "devtools\$arch\nativescript.dll")
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
Write-Host ""
|
|
103
|
+
Write-Host "Done." -ForegroundColor Green
|
|
104
|
+
Write-Host ""
|
|
105
|
+
Write-Host "libs layout:"
|
|
106
|
+
Get-ChildItem -Recurse $FrameworkLibs -Filter "*.dll" |
|
|
107
|
+
ForEach-Object { " " + $_.FullName.Substring($FrameworkLibs.Length + 1) }
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const page = new Windows.UI.Xaml.Controls.Page();
|
|
2
|
+
const text = new Windows.UI.Xaml.Controls.TextBlock();
|
|
3
|
+
text.Text = "Hello from NativeScript on Windows!";
|
|
4
|
+
text.FontSize = 24;
|
|
5
|
+
text.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center;
|
|
6
|
+
text.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center;
|
|
7
|
+
|
|
8
|
+
const grid = new Windows.UI.Xaml.Controls.Grid();
|
|
9
|
+
grid.Children.Append(text);
|
|
10
|
+
page.Content = grid;
|
|
11
|
+
|
|
12
|
+
Windows.UI.Xaml.Window.Current.Content = page;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using Windows.ApplicationModel;
|
|
3
|
+
using Windows.ApplicationModel.Activation;
|
|
4
|
+
using Windows.Storage;
|
|
5
|
+
using Windows.UI.Xaml;
|
|
6
|
+
using Windows.UI.Xaml.Navigation;
|
|
7
|
+
|
|
8
|
+
namespace __PROJECT_NAME__
|
|
9
|
+
{
|
|
10
|
+
sealed partial class App : Application
|
|
11
|
+
{
|
|
12
|
+
private const string LastLaunchArgsKey = "LastLaunchArgs";
|
|
13
|
+
private readonly RuntimeHost _runtimeHost = new RuntimeHost();
|
|
14
|
+
|
|
15
|
+
public App()
|
|
16
|
+
{
|
|
17
|
+
CrashDiagnostics.InstallGlobalHandlers();
|
|
18
|
+
this.Suspending += OnSuspending;
|
|
19
|
+
this.UnhandledException += OnUnhandledException;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
protected override void OnLaunched(LaunchActivatedEventArgs e)
|
|
23
|
+
{
|
|
24
|
+
_runtimeHost.Initialize();
|
|
25
|
+
try
|
|
26
|
+
{
|
|
27
|
+
_runtimeHost.RunMainScript();
|
|
28
|
+
}
|
|
29
|
+
catch (Exception scriptEx)
|
|
30
|
+
{
|
|
31
|
+
System.Diagnostics.Debug.WriteLine($"[NativeScript] Script exception: {scriptEx.Message}");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
#if DEBUG
|
|
35
|
+
Windows.UI.Xaml.Media.CompositionTarget.Rendering += OnRenderFrame;
|
|
36
|
+
#endif
|
|
37
|
+
|
|
38
|
+
if (Window.Current.Content == null)
|
|
39
|
+
{
|
|
40
|
+
Window.Current.Content = new Windows.UI.Xaml.Controls.TextBlock
|
|
41
|
+
{
|
|
42
|
+
Text = "NativeScript runtime initialized but no UI was rendered.\n" +
|
|
43
|
+
"Check the Output window for JS errors.",
|
|
44
|
+
Margin = new Windows.UI.Xaml.Thickness(20),
|
|
45
|
+
TextWrapping = Windows.UI.Xaml.TextWrapping.Wrap,
|
|
46
|
+
FontSize = 16,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (!e.PrelaunchActivated)
|
|
51
|
+
{
|
|
52
|
+
Window.Current.Activate();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private void OnSuspending(object sender, SuspendingEventArgs e)
|
|
57
|
+
{
|
|
58
|
+
var deferral = e.SuspendingOperation.GetDeferral();
|
|
59
|
+
#if DEBUG
|
|
60
|
+
Windows.UI.Xaml.Media.CompositionTarget.Rendering -= OnRenderFrame;
|
|
61
|
+
#endif
|
|
62
|
+
ApplicationData.Current.LocalSettings.Values[LastLaunchArgsKey] = string.Empty;
|
|
63
|
+
_runtimeHost.Dispose();
|
|
64
|
+
deferral.Complete();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
private void OnUnhandledException(object sender, Windows.UI.Xaml.UnhandledExceptionEventArgs e)
|
|
68
|
+
{
|
|
69
|
+
CrashDiagnostics.WriteExceptionReport(
|
|
70
|
+
"Xaml.UnhandledException",
|
|
71
|
+
e.Exception,
|
|
72
|
+
"Message=" + e.Message + "; Handled=" + e.Handled);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
#if DEBUG
|
|
76
|
+
private void OnRenderFrame(object sender, object e) => _runtimeHost.PumpDevtools();
|
|
77
|
+
#endif
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.IO;
|
|
3
|
+
using System.Text;
|
|
4
|
+
using System.Threading.Tasks;
|
|
5
|
+
using Windows.Storage;
|
|
6
|
+
|
|
7
|
+
namespace __PROJECT_NAME__
|
|
8
|
+
{
|
|
9
|
+
internal static class CrashDiagnostics
|
|
10
|
+
{
|
|
11
|
+
private static bool _installed;
|
|
12
|
+
|
|
13
|
+
public static void InstallGlobalHandlers()
|
|
14
|
+
{
|
|
15
|
+
if (_installed) return;
|
|
16
|
+
_installed = true;
|
|
17
|
+
|
|
18
|
+
AppDomain.CurrentDomain.UnhandledException += (_, args) =>
|
|
19
|
+
{
|
|
20
|
+
var ex = args.ExceptionObject as Exception;
|
|
21
|
+
WriteExceptionReport("AppDomain.UnhandledException", ex, "IsTerminating=" + args.IsTerminating);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
TaskScheduler.UnobservedTaskException += (_, args) =>
|
|
25
|
+
{
|
|
26
|
+
WriteExceptionReport("TaskScheduler.UnobservedTaskException", args.Exception, null);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public static void WriteExceptionReport(string source, Exception ex, string details)
|
|
31
|
+
{
|
|
32
|
+
var sb = new StringBuilder();
|
|
33
|
+
sb.AppendLine("============================================================");
|
|
34
|
+
sb.AppendLine("Timestamp: " + DateTimeOffset.UtcNow.ToString("o"));
|
|
35
|
+
sb.AppendLine("Source: " + source);
|
|
36
|
+
if (!string.IsNullOrWhiteSpace(details)) sb.AppendLine("Details: " + details);
|
|
37
|
+
if (ex != null) { sb.AppendLine("Exception:"); sb.AppendLine(ex.ToString()); }
|
|
38
|
+
else sb.AppendLine("Exception: <null>");
|
|
39
|
+
sb.AppendLine("Managed stack snapshot:");
|
|
40
|
+
sb.AppendLine(Environment.StackTrace);
|
|
41
|
+
sb.AppendLine();
|
|
42
|
+
AppendToLog(sb.ToString());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public static void WriteMessage(string source, string message)
|
|
46
|
+
{
|
|
47
|
+
var sb = new StringBuilder();
|
|
48
|
+
sb.AppendLine("============================================================");
|
|
49
|
+
sb.AppendLine("Timestamp: " + DateTimeOffset.UtcNow.ToString("o"));
|
|
50
|
+
sb.AppendLine("Source: " + source);
|
|
51
|
+
sb.AppendLine("Message: " + message);
|
|
52
|
+
sb.AppendLine();
|
|
53
|
+
AppendToLog(sb.ToString());
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private static void AppendToLog(string content)
|
|
57
|
+
{
|
|
58
|
+
try
|
|
59
|
+
{
|
|
60
|
+
var logPath = Path.Combine(ApplicationData.Current.LocalFolder.Path, "nativescript-crash.log");
|
|
61
|
+
File.AppendAllText(logPath, content, Encoding.UTF8);
|
|
62
|
+
}
|
|
63
|
+
catch { }
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
|
|
3
|
+
<Package
|
|
4
|
+
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
|
5
|
+
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
|
|
6
|
+
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
|
7
|
+
IgnorableNamespaces="uap mp">
|
|
8
|
+
|
|
9
|
+
<Identity
|
|
10
|
+
Name="__APP_IDENTIFIER__"
|
|
11
|
+
Publisher="CN=__PROJECT_NAME__"
|
|
12
|
+
Version="1.0.0.0" />
|
|
13
|
+
|
|
14
|
+
<mp:PhoneIdentity PhoneProductId="__APP_IDENTIFIER__" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
|
15
|
+
|
|
16
|
+
<Properties>
|
|
17
|
+
<DisplayName>__PROJECT_NAME__</DisplayName>
|
|
18
|
+
<PublisherDisplayName>__PROJECT_NAME__</PublisherDisplayName>
|
|
19
|
+
<Logo>Assets\StoreLogo.png</Logo>
|
|
20
|
+
</Properties>
|
|
21
|
+
|
|
22
|
+
<Dependencies>
|
|
23
|
+
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.26100.0" />
|
|
24
|
+
</Dependencies>
|
|
25
|
+
|
|
26
|
+
<Resources>
|
|
27
|
+
<Resource Language="x-generate"/>
|
|
28
|
+
</Resources>
|
|
29
|
+
|
|
30
|
+
<Applications>
|
|
31
|
+
<Application Id="App"
|
|
32
|
+
Executable="$targetnametoken$.exe"
|
|
33
|
+
EntryPoint="__PROJECT_NAME__.App">
|
|
34
|
+
<uap:VisualElements
|
|
35
|
+
DisplayName="__PROJECT_NAME__"
|
|
36
|
+
Square150x150Logo="Assets\Square150x150Logo.png"
|
|
37
|
+
Square44x44Logo="Assets\Square44x44Logo.png"
|
|
38
|
+
Description="A NativeScript Windows application"
|
|
39
|
+
BackgroundColor="transparent">
|
|
40
|
+
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
|
|
41
|
+
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
|
42
|
+
</uap:VisualElements>
|
|
43
|
+
</Application>
|
|
44
|
+
</Applications>
|
|
45
|
+
|
|
46
|
+
<Capabilities>
|
|
47
|
+
<Capability Name="internetClient" />
|
|
48
|
+
<Capability Name="privateNetworkClientServer" />
|
|
49
|
+
</Capabilities>
|
|
50
|
+
</Package>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Runtime Directives for .NET Native.
|
|
3
|
+
See https://go.microsoft.com/fwlink/?LinkID=391919
|
|
4
|
+
-->
|
|
5
|
+
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
|
|
6
|
+
<Application>
|
|
7
|
+
<Assembly Name="*Application*" Dynamic="Required All" />
|
|
8
|
+
</Application>
|
|
9
|
+
</Directives>
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.IO;
|
|
3
|
+
using System.Runtime.InteropServices;
|
|
4
|
+
using System.Text.Json;
|
|
5
|
+
|
|
6
|
+
namespace __PROJECT_NAME__
|
|
7
|
+
{
|
|
8
|
+
internal sealed class RuntimeHost : IDisposable
|
|
9
|
+
{
|
|
10
|
+
private const string NativeScriptLibrary = "nativescript";
|
|
11
|
+
|
|
12
|
+
[DllImport("kernel32.dll")]
|
|
13
|
+
private static extern bool AttachConsole(int dwProcessId);
|
|
14
|
+
|
|
15
|
+
private const int ATTACH_PARENT_PROCESS = -1;
|
|
16
|
+
|
|
17
|
+
[DllImport(NativeScriptLibrary, EntryPoint = nameof(runtime_init))]
|
|
18
|
+
private static extern long runtime_init([MarshalAs(UnmanagedType.LPUTF8Str)] string appRoot);
|
|
19
|
+
|
|
20
|
+
[DllImport(NativeScriptLibrary, EntryPoint = nameof(runtime_deinit))]
|
|
21
|
+
private static extern void runtime_deinit(long runtime);
|
|
22
|
+
|
|
23
|
+
[DllImport(NativeScriptLibrary, EntryPoint = nameof(runtime_runscript))]
|
|
24
|
+
private static extern void runtime_runscript(long runtime, [MarshalAs(UnmanagedType.LPUTF8Str)] string script, [MarshalAs(UnmanagedType.LPUTF8Str)] string filename);
|
|
25
|
+
|
|
26
|
+
[DllImport(NativeScriptLibrary, EntryPoint = nameof(runtime_install_ctrlc_handler))]
|
|
27
|
+
private static extern void runtime_install_ctrlc_handler(int exitCode);
|
|
28
|
+
|
|
29
|
+
#if DEBUG
|
|
30
|
+
[DllImport(NativeScriptLibrary, EntryPoint = nameof(runtime_devtools_start))]
|
|
31
|
+
private static extern IntPtr runtime_devtools_start(long runtime, ushort port);
|
|
32
|
+
|
|
33
|
+
[DllImport(NativeScriptLibrary, EntryPoint = nameof(runtime_devtools_pump))]
|
|
34
|
+
private static extern void runtime_devtools_pump(long runtime);
|
|
35
|
+
|
|
36
|
+
[DllImport(NativeScriptLibrary, EntryPoint = nameof(runtime_free_string))]
|
|
37
|
+
private static extern void runtime_free_string(IntPtr ptr);
|
|
38
|
+
|
|
39
|
+
public string DevtoolsFrontendUrl { get; private set; }
|
|
40
|
+
|
|
41
|
+
public void PumpDevtools()
|
|
42
|
+
{
|
|
43
|
+
if (!_initialized) return;
|
|
44
|
+
try { runtime_devtools_pump(_runtime); }
|
|
45
|
+
catch (Exception ex)
|
|
46
|
+
{
|
|
47
|
+
System.Diagnostics.Debug.WriteLine($"[NativeScript DevTools] Pump failed: {ex.Message}");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private void StartDevtoolsSafely()
|
|
52
|
+
{
|
|
53
|
+
IntPtr urlPtr = IntPtr.Zero;
|
|
54
|
+
try
|
|
55
|
+
{
|
|
56
|
+
urlPtr = runtime_devtools_start(_runtime, 42000);
|
|
57
|
+
if (urlPtr == IntPtr.Zero) return;
|
|
58
|
+
var wsUrl = Marshal.PtrToStringUTF8(urlPtr);
|
|
59
|
+
DevtoolsFrontendUrl = wsUrl != null
|
|
60
|
+
? $"devtools://devtools/bundled/inspector.html?ws={wsUrl.Replace("ws://", "")}"
|
|
61
|
+
: null;
|
|
62
|
+
if (DevtoolsFrontendUrl != null)
|
|
63
|
+
System.Diagnostics.Debug.WriteLine($"[NativeScript DevTools] {DevtoolsFrontendUrl}");
|
|
64
|
+
}
|
|
65
|
+
catch (Exception ex)
|
|
66
|
+
{
|
|
67
|
+
DevtoolsFrontendUrl = null;
|
|
68
|
+
System.Diagnostics.Debug.WriteLine($"[NativeScript DevTools] Start failed: {ex.Message}");
|
|
69
|
+
}
|
|
70
|
+
finally
|
|
71
|
+
{
|
|
72
|
+
if (urlPtr != IntPtr.Zero) runtime_free_string(urlPtr);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
#endif
|
|
76
|
+
|
|
77
|
+
private long _runtime;
|
|
78
|
+
private bool _initialized;
|
|
79
|
+
|
|
80
|
+
public void Initialize()
|
|
81
|
+
{
|
|
82
|
+
if (_initialized) return;
|
|
83
|
+
AttachConsole(ATTACH_PARENT_PROCESS);
|
|
84
|
+
runtime_install_ctrlc_handler(0);
|
|
85
|
+
_runtime = runtime_init(AppContext.BaseDirectory);
|
|
86
|
+
#if DEBUG
|
|
87
|
+
if (ConsumeDebugBreakMarker())
|
|
88
|
+
StartDevtoolsSafely();
|
|
89
|
+
#endif
|
|
90
|
+
_initialized = true;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
#if DEBUG
|
|
94
|
+
/// <summary>
|
|
95
|
+
/// Returns true and deletes the marker if the CLI wrote ns-debugbreak to LocalFolder,
|
|
96
|
+
/// matching the Android sentinel-file pattern used by the NativeScript CLI.
|
|
97
|
+
/// </summary>
|
|
98
|
+
private static bool ConsumeDebugBreakMarker()
|
|
99
|
+
{
|
|
100
|
+
try
|
|
101
|
+
{
|
|
102
|
+
var markerPath = System.IO.Path.Combine(
|
|
103
|
+
Windows.Storage.ApplicationData.Current.LocalFolder.Path,
|
|
104
|
+
"ns-debugbreak");
|
|
105
|
+
if (!System.IO.File.Exists(markerPath))
|
|
106
|
+
return false;
|
|
107
|
+
System.IO.File.Delete(markerPath);
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
catch { return false; }
|
|
111
|
+
}
|
|
112
|
+
#endif
|
|
113
|
+
|
|
114
|
+
public void RunMainScript()
|
|
115
|
+
{
|
|
116
|
+
if (!_initialized)
|
|
117
|
+
throw new InvalidOperationException("Runtime must be initialized before running scripts.");
|
|
118
|
+
|
|
119
|
+
var entryPath = ResolveEntryScriptPath();
|
|
120
|
+
var script = File.ReadAllText(Path.GetFullPath(entryPath));
|
|
121
|
+
try
|
|
122
|
+
{
|
|
123
|
+
runtime_runscript(_runtime, script, Path.GetFileName(entryPath));
|
|
124
|
+
}
|
|
125
|
+
catch (Exception ex)
|
|
126
|
+
{
|
|
127
|
+
CrashDiagnostics.WriteExceptionReport("RuntimeHost.RunMainScript", ex, "EntryScript=" + entryPath);
|
|
128
|
+
System.Diagnostics.Debug.WriteLine($"[NativeScript Runtime] Script execution failed ({entryPath}): {ex}");
|
|
129
|
+
throw;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private sealed class RuntimePackageConfig
|
|
134
|
+
{
|
|
135
|
+
public string Main { get; set; } = string.Empty;
|
|
136
|
+
public string WindowsMain { get; set; } = string.Empty;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
private static string ResolveEntryScriptPath()
|
|
140
|
+
{
|
|
141
|
+
var baseDir = AppContext.BaseDirectory;
|
|
142
|
+
var defaultPath = Path.Combine(baseDir, "App", "main.js");
|
|
143
|
+
var packageJsonPath = Path.Combine(baseDir, "package.json");
|
|
144
|
+
|
|
145
|
+
if (!File.Exists(packageJsonPath)) return defaultPath;
|
|
146
|
+
|
|
147
|
+
try
|
|
148
|
+
{
|
|
149
|
+
var config = ParsePackageConfig(packageJsonPath);
|
|
150
|
+
if (!string.IsNullOrWhiteSpace(config.WindowsMain))
|
|
151
|
+
{
|
|
152
|
+
var p = ResolveScriptPath(baseDir, config.WindowsMain);
|
|
153
|
+
if (p != null) return p;
|
|
154
|
+
}
|
|
155
|
+
if (!string.IsNullOrWhiteSpace(config.Main))
|
|
156
|
+
{
|
|
157
|
+
var p = ResolveScriptPath(baseDir, config.Main);
|
|
158
|
+
if (p != null) return p;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
catch { }
|
|
162
|
+
|
|
163
|
+
return defaultPath;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private static RuntimePackageConfig ParsePackageConfig(string packageJsonPath)
|
|
167
|
+
{
|
|
168
|
+
using var doc = JsonDocument.Parse(File.ReadAllText(packageJsonPath));
|
|
169
|
+
var config = new RuntimePackageConfig();
|
|
170
|
+
if (doc.RootElement.TryGetProperty("main", out var main) && main.ValueKind == JsonValueKind.String)
|
|
171
|
+
config.Main = main.GetString();
|
|
172
|
+
if (doc.RootElement.TryGetProperty("windows", out var win) && win.ValueKind == JsonValueKind.Object &&
|
|
173
|
+
win.TryGetProperty("main", out var winMain) && winMain.ValueKind == JsonValueKind.String)
|
|
174
|
+
config.WindowsMain = winMain.GetString();
|
|
175
|
+
return config;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private static string ResolveScriptPath(string baseDir, string scriptPath)
|
|
179
|
+
{
|
|
180
|
+
if (string.IsNullOrWhiteSpace(scriptPath)) return null;
|
|
181
|
+
var normalized = scriptPath.Replace('/', Path.DirectorySeparatorChar);
|
|
182
|
+
var direct = Path.IsPathRooted(normalized) ? normalized : Path.Combine(baseDir, normalized);
|
|
183
|
+
if (File.Exists(direct)) return direct;
|
|
184
|
+
var appPath = Path.Combine(baseDir, "App", normalized);
|
|
185
|
+
return File.Exists(appPath) ? appPath : null;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
public void Dispose()
|
|
189
|
+
{
|
|
190
|
+
if (!_initialized) return;
|
|
191
|
+
runtime_deinit(_runtime);
|
|
192
|
+
_runtime = 0;
|
|
193
|
+
_initialized = false;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
|
2
|
+
<PropertyGroup>
|
|
3
|
+
<OutputType>WinExe</OutputType>
|
|
4
|
+
<TargetFramework>net10.0-windows10.0.26100.0</TargetFramework>
|
|
5
|
+
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
|
6
|
+
<RootNamespace>__PROJECT_NAME__</RootNamespace>
|
|
7
|
+
<AssemblyName>__PROJECT_NAME__</AssemblyName>
|
|
8
|
+
<UseUwp>true</UseUwp>
|
|
9
|
+
<Platforms>x64;arm64</Platforms>
|
|
10
|
+
<RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
|
|
11
|
+
<DefaultLanguage>en-US</DefaultLanguage>
|
|
12
|
+
<EnableMsixTooling>true</EnableMsixTooling>
|
|
13
|
+
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
|
|
14
|
+
<CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
|
|
15
|
+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
|
16
|
+
<Nullable>disable</Nullable>
|
|
17
|
+
<DefineConstants>$(DefineConstants);DISABLE_XAML_GENERATED_MAIN</DefineConstants>
|
|
18
|
+
<!-- Parent of the project directory — contains the pre-built libs/ folder from the npm package -->
|
|
19
|
+
<NSWindowsRoot>$(MSBuildProjectDirectory)\..</NSWindowsRoot>
|
|
20
|
+
</PropertyGroup>
|
|
21
|
+
|
|
22
|
+
<ItemGroup>
|
|
23
|
+
<AppxManifest Include="Package.appxmanifest" />
|
|
24
|
+
<Content Include="Properties\Default.rd.xml" />
|
|
25
|
+
|
|
26
|
+
<!-- App JS/resource files — copied to the output directory on every build -->
|
|
27
|
+
<Content Include="App\**\*">
|
|
28
|
+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
29
|
+
</Content>
|
|
30
|
+
|
|
31
|
+
<!-- App_Resources: platform-specific assets (images, fonts, etc.) -->
|
|
32
|
+
<Content Include="App_Resources\**\*" Condition="Exists('App_Resources')">
|
|
33
|
+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
34
|
+
</Content>
|
|
35
|
+
|
|
36
|
+
<!-- Debug: devtools-enabled runtime DLL -->
|
|
37
|
+
<Content Include="$(NSWindowsRoot)\libs\devtools\$(Platform)\nativescript.dll"
|
|
38
|
+
Condition="'$(Configuration)' == 'Debug'">
|
|
39
|
+
<Link>nativescript.dll</Link>
|
|
40
|
+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
41
|
+
</Content>
|
|
42
|
+
|
|
43
|
+
<!-- Release: production runtime DLL -->
|
|
44
|
+
<Content Include="$(NSWindowsRoot)\libs\$(Platform)\nativescript.dll"
|
|
45
|
+
Condition="'$(Configuration)' != 'Debug'">
|
|
46
|
+
<Link>nativescript.dll</Link>
|
|
47
|
+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
48
|
+
</Content>
|
|
49
|
+
</ItemGroup>
|
|
50
|
+
</Project>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Runtime DLLs
|
|
2
|
+
|
|
3
|
+
This directory contains the pre-built NativeScript Windows runtime DLLs.
|
|
4
|
+
|
|
5
|
+
Expected structure:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
libs/
|
|
9
|
+
x64/nativescript.dll # Release build, 64-bit
|
|
10
|
+
arm64/nativescript.dll # Release build, ARM64
|
|
11
|
+
devtools/
|
|
12
|
+
x64/nativescript.dll # Debug build with DevTools, 64-bit
|
|
13
|
+
arm64/nativescript.dll # Debug build with DevTools, ARM64
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
These are populated by the CI release pipeline (cargo build --release / --features devtools).
|
|
17
|
+
They are not included in the git repository — download a release package or build from source.
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nativescript/windows",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "NativeScript for using Windows v8",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/NativeScript/windows.git"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "pwsh -File build.ps1",
|
|
11
|
+
"build:x64": "pwsh -File build.ps1 -SkipArm64"
|
|
12
|
+
},
|
|
13
|
+
"keywords": ["nativescript", "windows", "winrt", "uwp"],
|
|
14
|
+
"license": "Apache-2.0",
|
|
15
|
+
"files": [
|
|
16
|
+
"**/*"
|
|
17
|
+
]
|
|
18
|
+
}
|