@nativescript/windows-quickjs 0.1.0-alpha.0

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.
Files changed (48) hide show
  1. package/README.md +27 -0
  2. package/framework/__PROJECT_NAME__/App.xaml +13 -0
  3. package/framework/__PROJECT_NAME__/App.xaml.cs +240 -0
  4. package/framework/__PROJECT_NAME__/Assets/SplashScreen.png +0 -0
  5. package/framework/__PROJECT_NAME__/Assets/Square150x150Logo.png +0 -0
  6. package/framework/__PROJECT_NAME__/Assets/Square44x44Logo.png +0 -0
  7. package/framework/__PROJECT_NAME__/Assets/StoreLogo.png +0 -0
  8. package/framework/__PROJECT_NAME__/Assets/Wide310x150Logo.png +0 -0
  9. package/framework/__PROJECT_NAME__/CrashDiagnostics.cs +281 -0
  10. package/framework/__PROJECT_NAME__/Directory.Build.props +15 -0
  11. package/framework/__PROJECT_NAME__/Directory.Build.targets +106 -0
  12. package/framework/__PROJECT_NAME__/Package.appxmanifest +35 -0
  13. package/framework/__PROJECT_NAME__/Program.cs +34 -0
  14. package/framework/__PROJECT_NAME__/Properties/Default.rd.xml +9 -0
  15. package/framework/__PROJECT_NAME__/RuntimeHost.cs +359 -0
  16. package/framework/__PROJECT_NAME__/__PROJECT_NAME__.csproj +263 -0
  17. package/framework/dotnet-bridge/BinaryProtocol.cs +161 -0
  18. package/framework/dotnet-bridge/Bridge.BinaryDispatch.cs +373 -0
  19. package/framework/dotnet-bridge/Bridge.Dispatch.cs +597 -0
  20. package/framework/dotnet-bridge/Bridge.JsDelegate.cs +244 -0
  21. package/framework/dotnet-bridge/Bridge.Proxy.cs +573 -0
  22. package/framework/dotnet-bridge/Bridge.TaskHelper.cs +207 -0
  23. package/framework/dotnet-bridge/Bridge.cs +724 -0
  24. package/framework/dotnet-bridge/DispatchTypes.cs +333 -0
  25. package/framework/dotnet-bridge/DotNetBridge.csproj +30 -0
  26. package/framework/dotnet-bridge/publish_build/DotNetBridge.deps.json +23 -0
  27. package/framework/dotnet-bridge/publish_build/DotNetBridge.dll +0 -0
  28. package/framework/dotnet-bridge/publish_build/DotNetBridge.pdb +0 -0
  29. package/framework/dotnet-bridge/publish_build/DotNetBridge.runtimeconfig.json +14 -0
  30. package/framework/libs/x64/nativescript.dll +0 -0
  31. package/framework/tools/ManifestMerger/ManifestMerger.deps.json +24 -0
  32. package/framework/tools/ManifestMerger/ManifestMerger.dll +0 -0
  33. package/framework/tools/ManifestMerger/ManifestMerger.pdb +0 -0
  34. package/framework/tools/dotnet-tool-arm64.exe +0 -0
  35. package/framework/tools/dotnet-tool-x64.exe +0 -0
  36. package/framework/tools/dotnet-tool.exe +0 -0
  37. package/framework/tools/dotnet-typings-gen/dotnet-typings-gen.deps.json +23 -0
  38. package/framework/tools/dotnet-typings-gen/dotnet-typings-gen.dll +0 -0
  39. package/framework/tools/dotnet-typings-gen/dotnet-typings-gen.exe +0 -0
  40. package/framework/tools/dotnet-typings-gen/dotnet-typings-gen.pdb +0 -0
  41. package/framework/tools/dotnet-typings-gen/dotnet-typings-gen.runtimeconfig.json +13 -0
  42. package/framework/tools/sbg-arm64.exe +0 -0
  43. package/framework/tools/sbg-x64.exe +0 -0
  44. package/framework/tools/sbg.exe +0 -0
  45. package/framework/tools/typings-generator-arm64.exe +0 -0
  46. package/framework/tools/typings-generator-x64.exe +0 -0
  47. package/framework/tools/typings-generator.exe +0 -0
  48. package/package.json +43 -0
@@ -0,0 +1,263 @@
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
+ <SupportedOSPlatformVersion>10.0.17763.0</SupportedOSPlatformVersion>
7
+ <RootNamespace>$(MSBuildProjectName)</RootNamespace>
8
+ <AssemblyName>$(MSBuildProjectName)</AssemblyName>
9
+ <UseWinUI>true</UseWinUI>
10
+ <Platform Condition="'$(Platform)' == '' or '$(Platform)' == 'AnyCPU'">x64</Platform>
11
+ <PlatformTarget Condition="'$(PlatformTarget)' == '' or '$(PlatformTarget)' == 'AnyCPU'">x64</PlatformTarget>
12
+ <Platforms>x64;arm64</Platforms>
13
+ <RuntimeIdentifiers>win-x64;win-arm64</RuntimeIdentifiers>
14
+ <RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' and ('$(Platform)' == '' or '$(Platform)' == 'AnyCPU')">win-x64</RuntimeIdentifier>
15
+ <RuntimeIdentifier Condition="'$(RuntimeIdentifier)' == '' and '$(Platform)' != '' and '$(Platform)' != 'AnyCPU'">win-$([System.String]::Copy('$(Platform)').ToLowerInvariant())</RuntimeIdentifier>
16
+ <DefaultLanguage>en-US</DefaultLanguage>
17
+ <EnableMsixTooling>true</EnableMsixTooling>
18
+ <AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
19
+ <WindowsAppSdkDeploymentManagerInitialize>false</WindowsAppSdkDeploymentManagerInitialize>
20
+ <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
21
+ <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
22
+ <Nullable>disable</Nullable>
23
+ <DefineConstants>$(DefineConstants);DISABLE_XAML_GENERATED_MAIN</DefineConstants>
24
+ <!-- Parent of the project directory — contains the pre-built libs/ folder from the npm package -->
25
+ <NSWindowsRoot>$(MSBuildProjectDirectory)\..</NSWindowsRoot>
26
+ </PropertyGroup>
27
+
28
+ <!-- Static Binding Generator (SBG) output folder and helper properties for integrating generated proxies. -->
29
+ <PropertyGroup>
30
+ <NSGenDir>$(BaseIntermediateOutputPath)_ns_\gen</NSGenDir>
31
+ <SBG_OUTPUT_DIR>$(MSBuildProjectDirectory)\$(NSGenDir)</SBG_OUTPUT_DIR>
32
+ <!-- Path to the windows-runtime repository root. Can be overridden by setting the environment
33
+ variable `NS_WINDOWS_RUNTIME_ROOT` (useful when building an app that lives outside the
34
+ runtime repo). If not set, fall back to the project parent directory (legacy behavior). -->
35
+ <WindowsRuntimeRepoRoot Condition="'$(WindowsRuntimeRepoRoot)'=='' and '$(NS_WINDOWS_RUNTIME_ROOT)' != ''">$(NS_WINDOWS_RUNTIME_ROOT)</WindowsRuntimeRepoRoot>
36
+ <WindowsRuntimeRepoRoot Condition="'$(WindowsRuntimeRepoRoot)'==''">$(MSBuildProjectDirectory)\..</WindowsRuntimeRepoRoot>
37
+ <SBGMetadataSource>$(SBG_OUTPUT_DIR)\sbg_metadata.json</SBGMetadataSource>
38
+ <!-- Resolve pre-built tool binaries shipped inside the npm package tools/ directory -->
39
+ <NSToolsDir>$(NSWindowsRoot)\tools</NSToolsDir>
40
+ <SbgExe Condition="Exists('$(NSToolsDir)\sbg.exe')">$(NSToolsDir)\sbg.exe</SbgExe>
41
+ <DotNetToolExe Condition="Exists('$(NSToolsDir)\dotnet-tool.exe')">$(NSToolsDir)\dotnet-tool.exe</DotNetToolExe>
42
+ </PropertyGroup>
43
+
44
+ <PropertyGroup>
45
+ <!-- Derived library platform for selecting prebuilt native libs.
46
+ Prefer $(Platform); fall back to trimming 'win-' from $(RuntimeIdentifier); default to x64. -->
47
+ <NSLibPlatform Condition="'$(Platform)' != ''">$(Platform)</NSLibPlatform>
48
+ <NSLibPlatform Condition="'$(NSLibPlatform)' == '' and '$(RuntimeIdentifier)' != ''">$([System.Text.RegularExpressions.Regex]::Replace('$(RuntimeIdentifier)','^win-',''))</NSLibPlatform>
49
+ <NSLibPlatform Condition="'$(NSLibPlatform)' == ''">x64</NSLibPlatform>
50
+ </PropertyGroup>
51
+
52
+ <ItemGroup>
53
+ <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.250205002" />
54
+ <PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
55
+ </ItemGroup>
56
+
57
+ <PropertyGroup>
58
+ <!-- Deploys Microsoft.Web.WebView2.Core.winmd (~120 KB) next to the exe so the runtime can
59
+ project CoreWebView2 members (Navigate, Stop, …) dynamically. Set to false (App_Resources
60
+ props or /p:) for apps that never use WebView. -->
61
+ <NSIncludeWebView2Metadata Condition="'$(NSIncludeWebView2Metadata)' == ''">true</NSIncludeWebView2Metadata>
62
+ </PropertyGroup>
63
+
64
+ <!-- WinRT metadata for WebView2. The .NET build never deploys .winmd files (compiled apps bake
65
+ their projections at compile time), but the NativeScript runtime resolves WinRT types
66
+ dynamically and auto-scans the output dir for *.winmd on startup — without it, CoreWebView2
67
+ members (Navigate, Stop, …) don't project. WebView2 arrives transitively via
68
+ Microsoft.WindowsAppSDK, so we locate the winmd next to the resolved Core dll (it sits one
69
+ package's lib\). Version-agnostic: no pinned PackageReference, tracks whatever WebView2 version
70
+ WindowsAppSDK pulls in. WinUI resolves the Core dll from runtimes\<rid>\native_uap\, so the
71
+ winmd sits three directories up, in <pkgroot>\lib\. -->
72
+ <Target Name="NSDeployWebView2CoreMetadata"
73
+ AfterTargets="CopyFilesToOutputDirectory"
74
+ Condition="'$(NSIncludeWebView2Metadata)' == 'true'">
75
+ <PropertyGroup>
76
+ <_NSWebView2CoreDll>@(ReferenceCopyLocalPaths->WithMetadataValue('Filename','Microsoft.Web.WebView2.Core')->WithMetadataValue('Extension','.dll'))</_NSWebView2CoreDll>
77
+ <_NSWebView2CoreWinmd Condition="'$(_NSWebView2CoreDll)' != ''">$([System.IO.Path]::GetFullPath('$([System.IO.Path]::GetDirectoryName($(_NSWebView2CoreDll)))\..\..\..\lib\Microsoft.Web.WebView2.Core.winmd'))</_NSWebView2CoreWinmd>
78
+ </PropertyGroup>
79
+ <Copy SourceFiles="$(_NSWebView2CoreWinmd)"
80
+ DestinationFolder="$(OutDir)"
81
+ SkipUnchangedFiles="true"
82
+ Condition="'$(_NSWebView2CoreWinmd)' != '' and Exists('$(_NSWebView2CoreWinmd)')" />
83
+ </Target>
84
+
85
+ <ItemGroup>
86
+ <AppxManifest Include="Package.appxmanifest" />
87
+ <Content Include="Properties\Default.rd.xml" />
88
+
89
+ <!-- App JS/resource files — copied to the output directory on every build -->
90
+ <Content Include="app\**\*">
91
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
92
+ </Content>
93
+
94
+ <!-- App_Resources: platform-specific assets (images, fonts, etc.) -->
95
+ <Content Include="App_Resources\**\*" Condition="Exists('App_Resources')">
96
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
97
+ </Content>
98
+
99
+ <!-- Logo and splash assets required for the packaged desktop app manifest -->
100
+ <Content Include="Assets\**\*" Condition="Exists('Assets')">
101
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
102
+ </Content>
103
+
104
+ <!-- Debug: devtools-enabled runtime DLL (platform fallback via NSLibPlatform) -->
105
+ <Content Include="$(NSWindowsRoot)\libs\devtools\$(NSLibPlatform)\nativescript.dll"
106
+ Condition="'$(Configuration)' == 'Debug' and Exists('$(NSWindowsRoot)\libs\devtools\$(NSLibPlatform)\nativescript.dll')">
107
+ <Link>nativescript.dll</Link>
108
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
109
+ </Content>
110
+
111
+ <!-- Debug fallback: engine variants (quickjs/hermes/v8/jsc) ship no devtools build (no
112
+ inspector), so a Debug build must still pick up their plain runtime DLL instead of
113
+ silently omitting nativescript.dll from the output. -->
114
+ <Content Include="$(NSWindowsRoot)\libs\$(NSLibPlatform)\nativescript.dll"
115
+ Condition="'$(Configuration)' == 'Debug' and !Exists('$(NSWindowsRoot)\libs\devtools\$(NSLibPlatform)\nativescript.dll') and Exists('$(NSWindowsRoot)\libs\$(NSLibPlatform)\nativescript.dll')">
116
+ <Link>nativescript.dll</Link>
117
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
118
+ </Content>
119
+
120
+ <!-- Release: production runtime DLL (platform fallback via NSLibPlatform) -->
121
+ <Content Include="$(NSWindowsRoot)\libs\$(NSLibPlatform)\nativescript.dll"
122
+ Condition="'$(Configuration)' != 'Debug' and Exists('$(NSWindowsRoot)\libs\$(NSLibPlatform)\nativescript.dll')">
123
+ <Link>nativescript.dll</Link>
124
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
125
+ </Content>
126
+
127
+ <!-- Sidecar engine runtime DLLs some engine variants ship alongside nativescript.dll (e.g.
128
+ hermes.dll/hermes-icu.dll, JavaScriptCore.dll/icu*.dll) — same files regardless of
129
+ Debug/Release. nativescript.dll itself is excluded since it's handled above per config. -->
130
+ <Content Include="$(NSWindowsRoot)\libs\$(NSLibPlatform)\*.dll"
131
+ Exclude="$(NSWindowsRoot)\libs\$(NSLibPlatform)\nativescript.dll"
132
+ Condition="Exists('$(NSWindowsRoot)\libs\$(NSLibPlatform)')">
133
+ <Link>%(Filename)%(Extension)</Link>
134
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
135
+ </Content>
136
+
137
+ </ItemGroup>
138
+
139
+ <!--
140
+ Publishes DotNetBridge.dll before the app build.
141
+ Inputs/Outputs make this incremental: MSBuild skips the Exec when DotNetBridge.dll
142
+ is already newer than both source files.
143
+ -->
144
+ <Target Name="PublishDotNetBridge"
145
+ BeforeTargets="Build"
146
+ Inputs="$(NSWindowsRoot)\dotnet-bridge\DotNetBridge.csproj;
147
+ $(NSWindowsRoot)\dotnet-bridge\Bridge.cs"
148
+ Outputs="$(NSWindowsRoot)\dotnet-bridge\publish\DotNetBridge.dll"
149
+ Condition="Exists('$(NSWindowsRoot)\dotnet-bridge\DotNetBridge.csproj')">
150
+ <Message Text="[NativeScript] Publishing DotNetBridge..." Importance="low" />
151
+ <Exec Command="dotnet publish &quot;$(NSWindowsRoot)\dotnet-bridge\DotNetBridge.csproj&quot; -c Release -o &quot;$(NSWindowsRoot)\dotnet-bridge\publish&quot; --no-self-contained /nologo" />
152
+ </Target>
153
+
154
+ <!--
155
+ Copies the published bridge files to the output directory AFTER PublishDotNetBridge
156
+ runs, avoiding the MSBuild evaluation-order problem where Condition="Exists(...)"
157
+ on a static Content item is checked before the publish target creates the directory.
158
+ Must land at dotnet-bridge\publish\ relative to the EXE so the Rust runtime can
159
+ locate DotNetBridge.dll via AppContext.BaseDirectory.
160
+ -->
161
+ <Target Name="CopyDotNetBridge"
162
+ AfterTargets="PublishDotNetBridge"
163
+ BeforeTargets="Build"
164
+ Condition="Exists('$(NSWindowsRoot)\dotnet-bridge\publish')">
165
+ <ItemGroup>
166
+ <_DotNetBridgeFiles Include="$(NSWindowsRoot)\dotnet-bridge\publish\**\*" />
167
+ </ItemGroup>
168
+ <Copy SourceFiles="@(_DotNetBridgeFiles)"
169
+ DestinationFiles="@(_DotNetBridgeFiles->'$(OutDir)dotnet-bridge\%(RecursiveDir)%(Filename)%(Extension)')"
170
+ SkipUnchangedFiles="true" />
171
+ </Target>
172
+
173
+ <!-- Run the Static Binding Generator (sbg) when project contains an sbg entry script
174
+ or when pre-existing metadata is present. Generated proxies will be written
175
+ into $(NSGenDir) and included in compilation. -->
176
+ <Target Name="RunStaticBindingGenerator" BeforeTargets="CoreCompile">
177
+ <MakeDir Directories="$(NSGenDir)" />
178
+ <!-- Run dotnet-tool to auto-detect .NET usage and publish/copy DotNetBridge.
179
+ Prefer the pre-built binary shipped in the npm package; fall back to cargo run for dev. -->
180
+ <Exec Command="&quot;$(DotNetToolExe)&quot; --app-root &quot;$(MSBuildProjectDirectory)&quot; --dir App --sbg-output &quot;$(SBG_OUTPUT_DIR)&quot;"
181
+ Condition="'$(DotNetToolExe)' != ''" />
182
+ <Exec WorkingDirectory="$(WindowsRuntimeRepoRoot)"
183
+ Command="cargo run --quiet --manifest-path &quot;$(WindowsRuntimeRepoRoot)\Cargo.toml&quot; -p dotnet-tool -- --app-root &quot;$(MSBuildProjectDirectory)&quot; --dir App --sbg-output &quot;$(SBG_OUTPUT_DIR)&quot;"
184
+ Condition="'$(DotNetToolExe)' == '' and Exists('$(WindowsRuntimeRepoRoot)\Cargo.toml')" />
185
+ <!-- Run SBG to generate C# proxies from captured metadata.
186
+ sbg_metadata.json is written by __nsProxyAutoCapture when the app runs
187
+ with extensions that use .extend() / @Interfaces / @CSharpProxy.
188
+ Search order: pre-built tools/ binary, then cargo run for dev. -->
189
+ <Exec
190
+ Command="&quot;$(SbgExe)&quot;"
191
+ EnvironmentVariables="NSWINRT_AUTO_METADATA_PATH=$(SBGMetadataSource);SBG_OUTPUT_DIR=$(SBG_OUTPUT_DIR);SBG_METADATA_SOURCE=$(SBGMetadataSource);SBG_TARGET_FRAMEWORK=$(TargetFramework);SBG_TARGET_PLATFORM_MIN_VERSION=$(TargetPlatformMinVersion);SBG_USE_UWP=false;SBG_APP_CS_SOURCES_DIR=$(MSBuildProjectDirectory)"
192
+ Condition="'$(SbgExe)' != '' and Exists('$(SBGMetadataSource)')" />
193
+ <Exec WorkingDirectory="$(WindowsRuntimeRepoRoot)"
194
+ Command="cargo run --quiet --manifest-path &quot;$(WindowsRuntimeRepoRoot)\Cargo.toml&quot; -p sbg"
195
+ EnvironmentVariables="NSWINRT_AUTO_METADATA_PATH=$(SBGMetadataSource);SBG_OUTPUT_DIR=$(SBG_OUTPUT_DIR);SBG_METADATA_SOURCE=$(SBGMetadataSource);SBG_TARGET_FRAMEWORK=$(TargetFramework);SBG_TARGET_PLATFORM_MIN_VERSION=$(TargetPlatformMinVersion);SBG_USE_UWP=false;SBG_APP_CS_SOURCES_DIR=$(MSBuildProjectDirectory)"
196
+ Condition="'$(SbgExe)' == '' and Exists('$(SBGMetadataSource)') and Exists('$(WindowsRuntimeRepoRoot)\Cargo.toml')" />
197
+ </Target>
198
+
199
+ <Target Name="CleanStaticBindingGeneratorOutput" AfterTargets="CoreClean">
200
+ <RemoveDir Directories="$(NSGenDir)" Condition="Exists('$(NSGenDir)')" />
201
+ </Target>
202
+
203
+ <ItemGroup>
204
+ <Compile Include="$(NSGenDir)\NSWinRTProxies\**\*.cs" Visible="false" Condition="Exists('$(NSGenDir)\NSWinRTProxies')" />
205
+ <Compile Remove="$(NSGenDir)\NSWinRTProxies\obj\**\*.cs" Condition="Exists('$(NSGenDir)\NSWinRTProxies\obj')" />
206
+ <Content Include="$(NSGenDir)\sbg-manifest.json" Link="sbg-manifest.json" CopyToOutputDirectory="PreserveNewest" Condition="Exists('$(NSGenDir)\sbg-manifest.json')" />
207
+ <Content Include="$(NSGenDir)\NSWinRTProxies\bin\Release\**\NSWinRTProxies.dll" Link="NSWinRTProxies.dll" CopyToOutputDirectory="PreserveNewest" Condition="Exists('$(NSGenDir)\NSWinRTProxies\bin\Release')" />
208
+ </ItemGroup>
209
+
210
+
211
+ <!-- Ensure bridge files are included in the final `dotnet publish` output. -->
212
+ <Target Name="CopyDotNetBridgeToPublishDir"
213
+ AfterTargets="Publish"
214
+ Condition="Exists('$(NSWindowsRoot)\dotnet-bridge\publish')">
215
+ <ItemGroup>
216
+ <_DotNetBridgePublishFiles Include="$(NSWindowsRoot)\dotnet-bridge\publish\**\*" />
217
+ </ItemGroup>
218
+ <Copy SourceFiles="@(_DotNetBridgePublishFiles)"
219
+ DestinationFiles="@(_DotNetBridgePublishFiles->'$(PublishDir)dotnet-bridge\%(RecursiveDir)%(Filename)%(Extension)')"
220
+ SkipUnchangedFiles="true" />
221
+ </Target>
222
+
223
+ <!-- Inject the bridge publish files as Content before Publish so `dotnet publish` includes them automatically -->
224
+ <Target Name="AddDotNetBridgeContent" BeforeTargets="Publish" Condition="Exists('$(NSWindowsRoot)\dotnet-bridge\publish')">
225
+ <ItemGroup>
226
+ <Content Include="$(NSWindowsRoot)\dotnet-bridge\publish\**\*">
227
+ <Link>dotnet-bridge\%(RecursiveDir)%(Filename)%(Extension)</Link>
228
+ <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
229
+ </Content>
230
+ </ItemGroup>
231
+ </Target>
232
+
233
+ <!--
234
+ Wait for the `dotnet-tool` sentinel marker so Build/Publish don't race with
235
+ the external tool that publishes/copies DotNetBridge into the repo.
236
+ This polls for `dotnet-bridge/publish/.dotnet_tool_done` with a short timeout.
237
+ -->
238
+ <Target Name="WaitForDotNetToolDone" BeforeTargets="Build;Publish" Condition="Exists('$(NSWindowsRoot)\dotnet-bridge')">
239
+ <PropertyGroup>
240
+ <DotNetToolMarker>$(NSWindowsRoot)\dotnet-bridge\publish\.dotnet_tool_done</DotNetToolMarker>
241
+ <DotNetWaitTimeout>30</DotNetWaitTimeout>
242
+ </PropertyGroup>
243
+ <Message Text="[NativeScript] Waiting for dotnet-tool marker at $(DotNetToolMarker) (timeout $(DotNetWaitTimeout)s)..." Importance="low" />
244
+ <Exec Command="powershell -NoProfile -Command &quot;$t=0; while(-not(Test-Path '$(DotNetToolMarker)') -and $t -lt $(DotNetWaitTimeout)) { Start-Sleep -Seconds 1; $t++; }; if(-not(Test-Path '$(DotNetToolMarker)')) { Write-Error 'dotnet-tool marker not found after timeout'; exit 1 };&quot;" />
245
+ </Target>
246
+
247
+ <!-- Allow project-level Windows overrides: place App_Resources\Windows\app.csproj to extend/override generated settings -->
248
+ <Import Project="App_Resources\Windows\app.csproj" Condition="Exists('App_Resources\Windows\app.csproj')" />
249
+
250
+ <!-- App-level hook evaluated BEFORE plugins, analogous to Android's
251
+ App_Resources/Android/before-plugins.gradle. Place App_Resources\Windows\before-plugins.props
252
+ to declare NuGet package sources/feeds, pin or override versions, or set any properties/items
253
+ that plugin PackageReferences (added by each plugin's plugin.props) should resolve against. -->
254
+ <Import Project="App_Resources\Windows\before-plugins.props" Condition="Exists('App_Resources\Windows\before-plugins.props')" />
255
+
256
+ <!-- CLI-generated plugin imports (managed by the CLI during prepare) -->
257
+ <Import Project="plugins\Plugins.props" Condition="Exists('plugins\Plugins.props')" />
258
+ <Import Project="plugins\Plugins.targets" Condition="Exists('plugins\Plugins.targets')" />
259
+
260
+ <!-- App-level hook evaluated AFTER plugins, analogous to Android's App_Resources/Android/app.gradle.
261
+ Place App_Resources\Windows\after-plugins.props to override or extend anything a plugin set. -->
262
+ <Import Project="App_Resources\Windows\after-plugins.props" Condition="Exists('App_Resources\Windows\after-plugins.props')" />
263
+ </Project>
@@ -0,0 +1,161 @@
1
+ using System;
2
+ using System.Buffers;
3
+ using System.Buffers.Binary;
4
+ using System.Text;
5
+
6
+ namespace NativeScriptBridge;
7
+
8
+ internal readonly struct HandleRef(int id)
9
+ {
10
+ public readonly int Id = id;
11
+ }
12
+
13
+ // Carries a raw IUnknown/IInspectable pointer from a WinRT proxy (tag 0x0A).
14
+ // CoerceBin calls Marshal.GetObjectForIUnknown to create a managed RCW.
15
+ internal readonly struct WinRtRef(long ptr)
16
+ {
17
+ public readonly long Ptr = ptr;
18
+ }
19
+
20
+ internal ref struct BinReader(ReadOnlySpan<byte> buf)
21
+ {
22
+ private readonly ReadOnlySpan<byte> _buf = buf;
23
+ private int _pos = 0;
24
+
25
+ public byte ReadByte() => _buf[_pos++];
26
+
27
+ public int ReadI32()
28
+ {
29
+ var v = BinaryPrimitives.ReadInt32LittleEndian(_buf[_pos..]);
30
+ _pos += 4;
31
+ return v;
32
+ }
33
+
34
+ public long ReadI64()
35
+ {
36
+ var v = BinaryPrimitives.ReadInt64LittleEndian(_buf[_pos..]);
37
+ _pos += 8;
38
+ return v;
39
+ }
40
+
41
+ public ushort ReadU16()
42
+ {
43
+ var v = BinaryPrimitives.ReadUInt16LittleEndian(_buf[_pos..]);
44
+ _pos += 2;
45
+ return v;
46
+ }
47
+
48
+ public double ReadF64()
49
+ {
50
+ var v = BinaryPrimitives.ReadDoubleLittleEndian(_buf[_pos..]);
51
+ _pos += 8;
52
+ return v;
53
+ }
54
+
55
+ public string ReadString16()
56
+ {
57
+ var len = ReadU16();
58
+ var s = Encoding.UTF8.GetString(_buf.Slice(_pos, len));
59
+ _pos += len;
60
+ // Intern so repeated method/type names reuse the same heap string.
61
+ // Eliminates the allocation on every subsequent warm-path call.
62
+ return string.Intern(s);
63
+ }
64
+
65
+ public string ReadString32()
66
+ {
67
+ var len = BinaryPrimitives.ReadUInt32LittleEndian(_buf.Slice(_pos, 4));
68
+ _pos += 4;
69
+ var s = Encoding.UTF8.GetString(_buf.Slice(_pos, (int)len));
70
+ _pos += (int)len;
71
+ return string.Intern(s);
72
+ }
73
+
74
+ public uint ReadU32()
75
+ {
76
+ var v = BinaryPrimitives.ReadUInt32LittleEndian(_buf.Slice(_pos, 4));
77
+ _pos += 4;
78
+ return v;
79
+ }
80
+
81
+ public object?[] ReadArgs()
82
+ {
83
+ var count = ReadByte();
84
+ if (count == 0) return [];
85
+ var args = new object?[count];
86
+ for (int i = 0; i < count; i++)
87
+ {
88
+ var tag = ReadByte();
89
+ args[i] = tag switch
90
+ {
91
+ 0x00 => null,
92
+ 0x01 => (object)false,
93
+ 0x02 => (object)true,
94
+ 0x03 => (object)ReadI32(),
95
+ 0x04 => (object)ReadF64(),
96
+ 0x05 => (object)ReadString16(),
97
+ 0x06 => (object)new HandleRef(ReadI32()),
98
+ 0x0A => (object)new WinRtRef(ReadI64()),
99
+ _ => null,
100
+ };
101
+ }
102
+ return args;
103
+ }
104
+ }
105
+
106
+ internal ref struct BinWriter(ArrayBufferWriter<byte> buf)
107
+ {
108
+ private readonly ArrayBufferWriter<byte> _buf = buf;
109
+
110
+ public void WriteByte(byte b)
111
+ {
112
+ _buf.GetSpan(1)[0] = b;
113
+ _buf.Advance(1);
114
+ }
115
+
116
+ public void WriteI32(int v)
117
+ {
118
+ BinaryPrimitives.WriteInt32LittleEndian(_buf.GetSpan(4), v);
119
+ _buf.Advance(4);
120
+ }
121
+
122
+ public void WriteU16(ushort v)
123
+ {
124
+ BinaryPrimitives.WriteUInt16LittleEndian(_buf.GetSpan(2), v);
125
+ _buf.Advance(2);
126
+ }
127
+
128
+ public void WriteU32(uint v)
129
+ {
130
+ BinaryPrimitives.WriteUInt32LittleEndian(_buf.GetSpan(4), v);
131
+ _buf.Advance(4);
132
+ }
133
+
134
+ public void WriteI64(long v)
135
+ {
136
+ BinaryPrimitives.WriteInt64LittleEndian(_buf.GetSpan(8), v);
137
+ _buf.Advance(8);
138
+ }
139
+
140
+ public void WriteF64(double v)
141
+ {
142
+ BinaryPrimitives.WriteDoubleLittleEndian(_buf.GetSpan(8), v);
143
+ _buf.Advance(8);
144
+ }
145
+
146
+ public void WriteString32(ReadOnlySpan<char> s)
147
+ {
148
+ var byteCount = Encoding.UTF8.GetByteCount(s);
149
+ WriteU32((uint)byteCount);
150
+ Encoding.UTF8.GetBytes(s, _buf.GetSpan(byteCount));
151
+ _buf.Advance(byteCount);
152
+ }
153
+
154
+ public void WriteString16(ReadOnlySpan<char> s)
155
+ {
156
+ var byteCount = Encoding.UTF8.GetByteCount(s);
157
+ WriteU16((ushort)byteCount);
158
+ Encoding.UTF8.GetBytes(s, _buf.GetSpan(byteCount));
159
+ _buf.Advance(byteCount);
160
+ }
161
+ }