├── src ├── packages │ ├── Rx-Core.2.1.30214.0 │ │ ├── lib │ │ │ ├── SL4 │ │ │ │ └── _._ │ │ │ ├── SL5 │ │ │ │ └── System.Reactive.Core.dll │ │ │ ├── WP8 │ │ │ │ └── System.Reactive.Core.dll │ │ │ ├── Net40 │ │ │ │ └── System.Reactive.Core.dll │ │ │ ├── Net45 │ │ │ │ └── System.Reactive.Core.dll │ │ │ ├── NetCore45 │ │ │ │ └── System.Reactive.Core.dll │ │ │ ├── SL4-WindowsPhone71 │ │ │ │ └── System.Reactive.Core.dll │ │ │ └── Portable-Net45+WinRT45+WP8 │ │ │ │ └── System.Reactive.Core.dll │ │ ├── Rx-Core.2.1.30214.0.nupkg │ │ └── Rx-Core.2.1.30214.0.nuspec │ ├── Rx-Linq.2.1.30214.0 │ │ ├── lib │ │ │ ├── SL4 │ │ │ │ └── _._ │ │ │ ├── SL5 │ │ │ │ └── System.Reactive.Linq.dll │ │ │ ├── WP8 │ │ │ │ └── System.Reactive.Linq.dll │ │ │ ├── Net40 │ │ │ │ └── System.Reactive.Linq.dll │ │ │ ├── Net45 │ │ │ │ └── System.Reactive.Linq.dll │ │ │ ├── NetCore45 │ │ │ │ └── System.Reactive.Linq.dll │ │ │ ├── SL4-WindowsPhone71 │ │ │ │ └── System.Reactive.Linq.dll │ │ │ └── Portable-Net45+WinRT45+WP8 │ │ │ │ └── System.Reactive.Linq.dll │ │ ├── Rx-Linq.2.1.30214.0.nupkg │ │ └── Rx-Linq.2.1.30214.0.nuspec │ ├── Rx-Interfaces.2.1.30214.0 │ │ ├── lib │ │ │ ├── SL4 │ │ │ │ └── _._ │ │ │ ├── SL5 │ │ │ │ └── System.Reactive.Interfaces.dll │ │ │ ├── WP8 │ │ │ │ └── System.Reactive.Interfaces.dll │ │ │ ├── Net40 │ │ │ │ └── System.Reactive.Interfaces.dll │ │ │ ├── Net45 │ │ │ │ └── System.Reactive.Interfaces.dll │ │ │ ├── NetCore45 │ │ │ │ └── System.Reactive.Interfaces.dll │ │ │ ├── SL4-WindowsPhone71 │ │ │ │ └── System.Reactive.Interfaces.dll │ │ │ └── Portable-Net45+WinRT45+WP8 │ │ │ │ └── System.Reactive.Interfaces.dll │ │ ├── Rx-Interfaces.2.1.30214.0.nupkg │ │ └── Rx-Interfaces.2.1.30214.0.nuspec │ ├── Rx-PlatformServices.2.1.30214.0 │ │ ├── lib │ │ │ ├── SL4 │ │ │ │ └── _._ │ │ │ ├── Portable-Net45+WinRT45+WP8 │ │ │ │ └── _._ │ │ │ ├── SL5 │ │ │ │ └── System.Reactive.PlatformServices.dll │ │ │ ├── WP8 │ │ │ │ └── System.Reactive.PlatformServices.dll │ │ │ ├── Net40 │ │ │ │ └── System.Reactive.PlatformServices.dll │ │ │ ├── Net45 │ │ │ │ └── System.Reactive.PlatformServices.dll │ │ │ ├── NetCore45 │ │ │ │ └── System.Reactive.PlatformServices.dll │ │ │ └── SL4-WindowsPhone71 │ │ │ │ └── System.Reactive.PlatformServices.dll │ │ ├── content │ │ │ ├── Net40 │ │ │ │ └── _._ │ │ │ ├── Net45 │ │ │ │ └── _._ │ │ │ ├── SL4 │ │ │ │ └── _._ │ │ │ ├── SL5 │ │ │ │ └── _._ │ │ │ ├── WP8 │ │ │ │ └── _._ │ │ │ ├── NetCore45 │ │ │ │ └── _._ │ │ │ ├── SL4-WindowsPhone71 │ │ │ │ └── _._ │ │ │ └── Portable-Net45+WinRT45+WP8 │ │ │ │ └── Readme.txt │ │ ├── Rx-PlatformServices.2.1.30214.0.nupkg │ │ └── Rx-PlatformServices.2.1.30214.0.nuspec │ ├── RazorTemplates.1.2.0 │ │ ├── RazorTemplates.1.2.0.nupkg │ │ ├── lib │ │ │ ├── System.Web.Razor.dll │ │ │ └── RazorTemplates.Core.dll │ │ └── RazorTemplates.1.2.0.nuspec │ └── Rx-Main.2.1.30214.0 │ │ ├── Rx-Main.2.1.30214.0.nupkg │ │ └── Rx-Main.2.1.30214.0.nuspec ├── NodeRTLib │ ├── DefinitonTemplates │ │ ├── Ts │ │ │ ├── IClosableCloseMethod.ts │ │ │ ├── NotImplementedMethod.ts │ │ │ ├── MemberPropertyGetter.ts │ │ │ ├── StaticPropertyGetter.ts │ │ │ ├── MemberAsyncMethod.ts │ │ │ ├── StaticAsyncMethod.ts │ │ │ ├── Enum.ts │ │ │ ├── MemberSyncMethod.ts │ │ │ ├── ValueType.ts │ │ │ ├── Constructor.ts │ │ │ ├── StaticSyncMethod.ts │ │ │ ├── Wrapper.ts │ │ │ ├── Event.ts │ │ │ └── Type.ts │ │ └── Js │ │ │ ├── IClosableCloseMethod.js │ │ │ ├── NotImplementedMethod.js │ │ │ ├── StaticPropertyGetter.js │ │ │ ├── MemberPropertyGetter.js │ │ │ ├── StaticSyncMethod.js │ │ │ ├── MemberSyncMethod.js │ │ │ ├── StaticAsyncMethod.js │ │ │ ├── MemberAsyncMethod.js │ │ │ ├── Event.js │ │ │ ├── Enum.js │ │ │ ├── AsyncMethodBody.js │ │ │ ├── Wrapper.js │ │ │ ├── ValueType.js │ │ │ ├── Constructor.js │ │ │ ├── SyncMethodBody.js │ │ │ └── Type.js │ ├── JsPackageFiles │ │ ├── .npmignore │ │ ├── package.json │ │ ├── package.vs2022.json │ │ ├── package.vs2019.json │ │ ├── README.md │ │ ├── main.js │ │ ├── README.vs2019.md │ │ └── README.vs2022.md │ ├── packages │ │ ├── repositories.config │ │ └── RazorTemplates.1.2.0 │ │ │ ├── RazorTemplates.1.2.0.nupkg │ │ │ ├── lib │ │ │ ├── System.Web.Razor.dll │ │ │ └── RazorTemplates.Core.dll │ │ │ └── RazorTemplates.1.2.0.nuspec │ ├── packages.config │ ├── CppTemplates │ │ ├── TypeWrapperForwardDeclaration.cpp │ │ ├── NotImplementedMethod.cpp │ │ ├── Enum.cpp │ │ ├── StaticPropertyGetter.cpp │ │ ├── CastFrom.cpp │ │ ├── StaticPropertySetter.cpp │ │ ├── IClosableCloseMethod.cpp │ │ ├── MemberPropertyGetter.cpp │ │ ├── MemberPropertySetter.cpp │ │ ├── ValueType.cpp │ │ ├── RegisterEventWithWinRT.cpp │ │ ├── Type.cpp │ │ ├── Constructor.cpp │ │ ├── Wrapper.cpp │ │ ├── InitExports.cpp │ │ ├── StaticAsyncMethod.cpp │ │ ├── MemberAsyncMethod.cpp │ │ ├── StaticSyncMethod.cpp │ │ ├── MemberSyncMethod.cpp │ │ └── Event.cpp │ ├── ProjectTemplates │ │ ├── common.gypi │ │ └── binding.gyp │ ├── ProjectFiles │ │ ├── WrapperBase.h │ │ ├── CollectionsConverterUtils.h │ │ ├── CollectionsConverterUtils.cpp │ │ ├── OpaqueWrapper.h │ │ ├── OpaqueWrapper.cpp │ │ └── NodeRtUtils.h │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── NodeRTProjectBuildUtils.cs │ └── ExternalTypesHelper.cs ├── NodeRTCmd │ ├── nodert.ico │ ├── App.config │ ├── Properties │ │ └── AssemblyInfo.cs │ └── NodeRTCmd.csproj ├── NodeRTUI │ ├── nodert.ico │ ├── packages.config │ ├── Properties │ │ ├── Settings.settings │ │ ├── AssemblyInfo.cs │ │ ├── Resources.Designer.cs │ │ ├── Settings.Designer.cs │ │ └── Resources.resx │ ├── Program.cs │ ├── App.config │ └── NodeRTUI.csproj └── NodeRT.sln ├── doc └── images │ ├── object_contents.png │ ├── golocation__proto.png │ └── nodert_screenshot.png ├── samples ├── geolocation │ ├── README.md │ └── print_location.js ├── media │ ├── README.md │ └── capture_image.js ├── lock_screen │ ├── set_lock_screen.js │ └── README.md ├── speech_stream │ ├── README.md │ └── speak.js └── notification │ ├── README.md │ └── notification.js ├── .github ├── dependabot.yml └── workflows │ └── generate.yml ├── scripts ├── mass-release.ps1 ├── automated-mass-release.ps1 ├── mass-creation.ps1 └── automated-mass-creation.ps1 ├── .gitignore ├── LICENSE └── MODULE_CREATION.md /src/packages/Rx-Core.2.1.30214.0/lib/SL4/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/packages/Rx-Linq.2.1.30214.0/lib/SL4/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/packages/Rx-Interfaces.2.1.30214.0/lib/SL4/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/packages/Rx-PlatformServices.2.1.30214.0/lib/SL4/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/packages/Rx-PlatformServices.2.1.30214.0/content/Net40/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/packages/Rx-PlatformServices.2.1.30214.0/content/Net45/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/packages/Rx-PlatformServices.2.1.30214.0/content/SL4/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/packages/Rx-PlatformServices.2.1.30214.0/content/SL5/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/packages/Rx-PlatformServices.2.1.30214.0/content/WP8/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/packages/Rx-PlatformServices.2.1.30214.0/content/NetCore45/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Ts/IClosableCloseMethod.ts: -------------------------------------------------------------------------------- 1 | close(): void; -------------------------------------------------------------------------------- /src/packages/Rx-PlatformServices.2.1.30214.0/content/SL4-WindowsPhone71/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/packages/Rx-PlatformServices.2.1.30214.0/lib/Portable-Net45+WinRT45+WP8/_._: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Ts/NotImplementedMethod.ts: -------------------------------------------------------------------------------- 1 | @(TX.Uncap(Model.Name))(); -------------------------------------------------------------------------------- /src/NodeRTCmd/nodert.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/NodeRTCmd/nodert.ico -------------------------------------------------------------------------------- /src/NodeRTUI/nodert.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/NodeRTUI/nodert.ico -------------------------------------------------------------------------------- /src/NodeRTLib/JsPackageFiles/.npmignore: -------------------------------------------------------------------------------- 1 | *.vcxproj 2 | *.filters 3 | *.user 4 | Debug 5 | Release 6 | test -------------------------------------------------------------------------------- /doc/images/object_contents.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/doc/images/object_contents.png -------------------------------------------------------------------------------- /doc/images/golocation__proto.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/doc/images/golocation__proto.png -------------------------------------------------------------------------------- /doc/images/nodert_screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/doc/images/nodert_screenshot.png -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Js/IClosableCloseMethod.js: -------------------------------------------------------------------------------- 1 | cls.prototype.close = function close() { 2 | } 3 | 4 | -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Js/NotImplementedMethod.js: -------------------------------------------------------------------------------- 1 | cls.prototype.@(TX.Uncap(Model.Name)) = function () { 2 | } 3 | -------------------------------------------------------------------------------- /src/NodeRTLib/packages/repositories.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/packages/RazorTemplates.1.2.0/RazorTemplates.1.2.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/RazorTemplates.1.2.0/RazorTemplates.1.2.0.nupkg -------------------------------------------------------------------------------- /src/packages/RazorTemplates.1.2.0/lib/System.Web.Razor.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/RazorTemplates.1.2.0/lib/System.Web.Razor.dll -------------------------------------------------------------------------------- /src/packages/Rx-Core.2.1.30214.0/Rx-Core.2.1.30214.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Core.2.1.30214.0/Rx-Core.2.1.30214.0.nupkg -------------------------------------------------------------------------------- /src/packages/Rx-Linq.2.1.30214.0/Rx-Linq.2.1.30214.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Linq.2.1.30214.0/Rx-Linq.2.1.30214.0.nupkg -------------------------------------------------------------------------------- /src/packages/Rx-Main.2.1.30214.0/Rx-Main.2.1.30214.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Main.2.1.30214.0/Rx-Main.2.1.30214.0.nupkg -------------------------------------------------------------------------------- /src/NodeRTLib/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/packages/RazorTemplates.1.2.0/lib/RazorTemplates.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/RazorTemplates.1.2.0/lib/RazorTemplates.Core.dll -------------------------------------------------------------------------------- /src/packages/Rx-Core.2.1.30214.0/lib/SL5/System.Reactive.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Core.2.1.30214.0/lib/SL5/System.Reactive.Core.dll -------------------------------------------------------------------------------- /src/packages/Rx-Core.2.1.30214.0/lib/WP8/System.Reactive.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Core.2.1.30214.0/lib/WP8/System.Reactive.Core.dll -------------------------------------------------------------------------------- /src/packages/Rx-Linq.2.1.30214.0/lib/SL5/System.Reactive.Linq.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Linq.2.1.30214.0/lib/SL5/System.Reactive.Linq.dll -------------------------------------------------------------------------------- /src/packages/Rx-Linq.2.1.30214.0/lib/WP8/System.Reactive.Linq.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Linq.2.1.30214.0/lib/WP8/System.Reactive.Linq.dll -------------------------------------------------------------------------------- /src/packages/Rx-Core.2.1.30214.0/lib/Net40/System.Reactive.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Core.2.1.30214.0/lib/Net40/System.Reactive.Core.dll -------------------------------------------------------------------------------- /src/packages/Rx-Core.2.1.30214.0/lib/Net45/System.Reactive.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Core.2.1.30214.0/lib/Net45/System.Reactive.Core.dll -------------------------------------------------------------------------------- /src/packages/Rx-Linq.2.1.30214.0/lib/Net40/System.Reactive.Linq.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Linq.2.1.30214.0/lib/Net40/System.Reactive.Linq.dll -------------------------------------------------------------------------------- /src/packages/Rx-Linq.2.1.30214.0/lib/Net45/System.Reactive.Linq.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Linq.2.1.30214.0/lib/Net45/System.Reactive.Linq.dll -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Ts/MemberPropertyGetter.ts: -------------------------------------------------------------------------------- 1 | @(TX.Uncap(Model.Name)): @(Converter.ToJsDefinitonType(Model.PropertyType, TX.MainModel.Types.ContainsKey(Model.PropertyType))); -------------------------------------------------------------------------------- /src/NodeRTLib/packages/RazorTemplates.1.2.0/RazorTemplates.1.2.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/NodeRTLib/packages/RazorTemplates.1.2.0/RazorTemplates.1.2.0.nupkg -------------------------------------------------------------------------------- /src/NodeRTLib/packages/RazorTemplates.1.2.0/lib/System.Web.Razor.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/NodeRTLib/packages/RazorTemplates.1.2.0/lib/System.Web.Razor.dll -------------------------------------------------------------------------------- /src/packages/Rx-Interfaces.2.1.30214.0/Rx-Interfaces.2.1.30214.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Interfaces.2.1.30214.0/Rx-Interfaces.2.1.30214.0.nupkg -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Js/StaticPropertyGetter.js: -------------------------------------------------------------------------------- 1 | cls.@(TX.Uncap(Model.Name)) = new @(Converter.ToJsDefinitonType(Model.PropertyType, TX.MainModel.Types.ContainsKey(Model.PropertyType)))(); -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Ts/StaticPropertyGetter.ts: -------------------------------------------------------------------------------- 1 | static @(TX.Uncap(Model.Name)): @(Converter.ToJsDefinitonType(Model.PropertyType, TX.MainModel.Types.ContainsKey(Model.PropertyType))); -------------------------------------------------------------------------------- /src/NodeRTLib/packages/RazorTemplates.1.2.0/lib/RazorTemplates.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/NodeRTLib/packages/RazorTemplates.1.2.0/lib/RazorTemplates.Core.dll -------------------------------------------------------------------------------- /src/packages/Rx-Core.2.1.30214.0/lib/NetCore45/System.Reactive.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Core.2.1.30214.0/lib/NetCore45/System.Reactive.Core.dll -------------------------------------------------------------------------------- /src/packages/Rx-Linq.2.1.30214.0/lib/NetCore45/System.Reactive.Linq.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Linq.2.1.30214.0/lib/NetCore45/System.Reactive.Linq.dll -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Js/MemberPropertyGetter.js: -------------------------------------------------------------------------------- 1 | this.@(TX.Uncap(Model.Name)) = new @(Converter.ToJsDefinitonType(Model.PropertyType, TX.MainModel.Types.ContainsKey(Model.PropertyType)))(); -------------------------------------------------------------------------------- /src/packages/Rx-Interfaces.2.1.30214.0/lib/SL5/System.Reactive.Interfaces.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Interfaces.2.1.30214.0/lib/SL5/System.Reactive.Interfaces.dll -------------------------------------------------------------------------------- /src/packages/Rx-Interfaces.2.1.30214.0/lib/WP8/System.Reactive.Interfaces.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Interfaces.2.1.30214.0/lib/WP8/System.Reactive.Interfaces.dll -------------------------------------------------------------------------------- /src/packages/Rx-Core.2.1.30214.0/lib/SL4-WindowsPhone71/System.Reactive.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Core.2.1.30214.0/lib/SL4-WindowsPhone71/System.Reactive.Core.dll -------------------------------------------------------------------------------- /src/packages/Rx-Interfaces.2.1.30214.0/lib/Net40/System.Reactive.Interfaces.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Interfaces.2.1.30214.0/lib/Net40/System.Reactive.Interfaces.dll -------------------------------------------------------------------------------- /src/packages/Rx-Interfaces.2.1.30214.0/lib/Net45/System.Reactive.Interfaces.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Interfaces.2.1.30214.0/lib/Net45/System.Reactive.Interfaces.dll -------------------------------------------------------------------------------- /src/packages/Rx-Linq.2.1.30214.0/lib/SL4-WindowsPhone71/System.Reactive.Linq.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Linq.2.1.30214.0/lib/SL4-WindowsPhone71/System.Reactive.Linq.dll -------------------------------------------------------------------------------- /src/packages/Rx-PlatformServices.2.1.30214.0/Rx-PlatformServices.2.1.30214.0.nupkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-PlatformServices.2.1.30214.0/Rx-PlatformServices.2.1.30214.0.nupkg -------------------------------------------------------------------------------- /src/packages/Rx-Interfaces.2.1.30214.0/lib/NetCore45/System.Reactive.Interfaces.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Interfaces.2.1.30214.0/lib/NetCore45/System.Reactive.Interfaces.dll -------------------------------------------------------------------------------- /src/NodeRTCmd/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Ts/MemberAsyncMethod.ts: -------------------------------------------------------------------------------- 1 | @{ 2 | foreach(var overload in Model.Overloads) { 3 | @:@(TX.Uncap(Model.Name))(@(TX.GetParamsFromTsMethodForDefinitions(overload, isAsync: true))): void ; 4 | } 5 | } -------------------------------------------------------------------------------- /src/packages/Rx-Core.2.1.30214.0/lib/Portable-Net45+WinRT45+WP8/System.Reactive.Core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Core.2.1.30214.0/lib/Portable-Net45+WinRT45+WP8/System.Reactive.Core.dll -------------------------------------------------------------------------------- /src/packages/Rx-Linq.2.1.30214.0/lib/Portable-Net45+WinRT45+WP8/System.Reactive.Linq.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Linq.2.1.30214.0/lib/Portable-Net45+WinRT45+WP8/System.Reactive.Linq.dll -------------------------------------------------------------------------------- /src/packages/Rx-PlatformServices.2.1.30214.0/lib/SL5/System.Reactive.PlatformServices.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-PlatformServices.2.1.30214.0/lib/SL5/System.Reactive.PlatformServices.dll -------------------------------------------------------------------------------- /src/packages/Rx-PlatformServices.2.1.30214.0/lib/WP8/System.Reactive.PlatformServices.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-PlatformServices.2.1.30214.0/lib/WP8/System.Reactive.PlatformServices.dll -------------------------------------------------------------------------------- /src/packages/Rx-Interfaces.2.1.30214.0/lib/SL4-WindowsPhone71/System.Reactive.Interfaces.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Interfaces.2.1.30214.0/lib/SL4-WindowsPhone71/System.Reactive.Interfaces.dll -------------------------------------------------------------------------------- /src/packages/Rx-PlatformServices.2.1.30214.0/lib/Net40/System.Reactive.PlatformServices.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-PlatformServices.2.1.30214.0/lib/Net40/System.Reactive.PlatformServices.dll -------------------------------------------------------------------------------- /src/packages/Rx-PlatformServices.2.1.30214.0/lib/Net45/System.Reactive.PlatformServices.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-PlatformServices.2.1.30214.0/lib/Net45/System.Reactive.PlatformServices.dll -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Ts/StaticAsyncMethod.ts: -------------------------------------------------------------------------------- 1 | @{ 2 | foreach(var overload in Model.Overloads) { 3 | @:static @(TX.Uncap(Model.Name))(@(TX.GetParamsFromTsMethodForDefinitions(overload, isAsync: true))): void ; 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/packages/Rx-PlatformServices.2.1.30214.0/lib/NetCore45/System.Reactive.PlatformServices.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-PlatformServices.2.1.30214.0/lib/NetCore45/System.Reactive.PlatformServices.dll -------------------------------------------------------------------------------- /src/packages/Rx-Interfaces.2.1.30214.0/lib/Portable-Net45+WinRT45+WP8/System.Reactive.Interfaces.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-Interfaces.2.1.30214.0/lib/Portable-Net45+WinRT45+WP8/System.Reactive.Interfaces.dll -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/TypeWrapperForwardDeclaration.cpp: -------------------------------------------------------------------------------- 1 | @foreach(var t in Model.Types.Values) { 2 | @:v8::Local Wrap@(t.Name)(@(TX.ToWinRT(t.Type)) wintRtInstance); 3 | @:@TX.ToWinRT(t.Type) Unwrap@(t.Name)(Local value); 4 | @: 5 | } -------------------------------------------------------------------------------- /src/packages/Rx-PlatformServices.2.1.30214.0/lib/SL4-WindowsPhone71/System.Reactive.PlatformServices.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/demosjarco/NodeRT/HEAD/src/packages/Rx-PlatformServices.2.1.30214.0/lib/SL4-WindowsPhone71/System.Reactive.PlatformServices.dll -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/NotImplementedMethod.cpp: -------------------------------------------------------------------------------- 1 | static void @(TX.CSharpMethodToCppMethod(Model.Name))(Nan::NAN_METHOD_ARGS_TYPE info) { 2 | HandleScope scope; 3 | Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Not implemented"))); 4 | } 5 | -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Js/StaticSyncMethod.js: -------------------------------------------------------------------------------- 1 | @{ 2 | foreach(var overload in Model.Overloads) { 3 | @:cls.@(TX.Uncap(Model.Name)) = function @(TX.Uncap(Model.Name))(@(TX.GetParamsFromJsMethodForDefinitions(overload))) @TX.JsDefinitionTemplates.SyncMethodBody(overload) 4 | } 5 | } -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Ts/Enum.ts: -------------------------------------------------------------------------------- 1 | @{ 2 | @:export enum @(Model.Name) { 3 | var counter = 0; 4 | foreach(var field in Model.DeclaredFields) 5 | { 6 | if (counter != 0) 7 | { 8 | @:@(TX.Uncap(field.Name)), 9 | } 10 | counter++; 11 | } 12 | @:} 13 | } -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Js/MemberSyncMethod.js: -------------------------------------------------------------------------------- 1 | @{ 2 | foreach(var overload in Model.Overloads) { 3 | @:cls.prototype.@(TX.Uncap(Model.Name)) = function @(TX.Uncap(Model.Name))(@(TX.GetParamsFromJsMethodForDefinitions(overload))) @TX.JsDefinitionTemplates.SyncMethodBody(overload) 4 | } 5 | } -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Js/StaticAsyncMethod.js: -------------------------------------------------------------------------------- 1 | @{ 2 | foreach(var overload in Model.Overloads) { 3 | @:cls.@(TX.Uncap(Model.Name)) = function @(TX.Uncap(Model.Name))(@(TX.GetParamsFromJsMethodForDefinitions(overload, isAsync: true))) @TX.JsDefinitionTemplates.AsyncMethodBody(overload) 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Ts/MemberSyncMethod.ts: -------------------------------------------------------------------------------- 1 | @{ 2 | foreach(var overload in Model.Overloads) { 3 | @:@(TX.Uncap(Model.Name))(@(TX.GetParamsFromTsMethodForDefinitions(overload))): @(Converter.ToJsDefinitonType(overload.ReturnType, TX.MainModel.Types.ContainsKey(overload.ReturnType))); 4 | } 5 | } -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Ts/ValueType.ts: -------------------------------------------------------------------------------- 1 | @{ 2 | @:export class @(Model.Name) { 3 | foreach(var field in Model.GetFields()) { 4 | @:@(TX.Uncap(field.Name)): @(Converter.ToJsDefinitonType(field.FieldType, TX.MainModel.Types.ContainsKey(field.FieldType))); 5 | } 6 | @:constructor(); 7 | @:} 8 | } -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Js/MemberAsyncMethod.js: -------------------------------------------------------------------------------- 1 | @{ 2 | foreach(var overload in Model.Overloads) { 3 | @:cls.prototype.@(TX.Uncap(Model.Name)) = function @(TX.Uncap(Model.Name))(@(TX.GetParamsFromJsMethodForDefinitions(overload, isAsync: true))) @TX.JsDefinitionTemplates.AsyncMethodBody(overload) 4 | } 5 | } -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Ts/Constructor.ts: -------------------------------------------------------------------------------- 1 | constructor(); 2 | @{ 3 | foreach(var constructor in Model.Type.GetConstructors()) 4 | { 5 | if (constructor.GetParameters().Length > 0) 6 | { 7 | @:constructor(@(TX.GetParamsFromTsMethodForDefinitions(constructor))); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Ts/StaticSyncMethod.ts: -------------------------------------------------------------------------------- 1 | @{ 2 | foreach(var overload in Model.Overloads) { 3 | @:static @(TX.Uncap(Model.Name))(@(TX.GetParamsFromTsMethodForDefinitions(overload))): @(Converter.ToJsDefinitonType(overload.ReturnType, TX.MainModel.Types.ContainsKey(overload.ReturnType))); 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Js/Event.js: -------------------------------------------------------------------------------- 1 | @{ 2 | @:cls.prototype.addListener = function addListener(eventName, callback){} 3 | @:cls.prototype.removeListener = function removeListener(eventName, callback){} 4 | @:cls.prototype.on = function on(eventName, callback){} 5 | @:cls.prototype.off = function off(eventName, callback){} 6 | } -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Js/Enum.js: -------------------------------------------------------------------------------- 1 | @{ 2 | @:_@(Model.Name) = function () { 3 | var counter = 0; 4 | foreach(var field in Model.DeclaredFields) 5 | { 6 | if (counter != 0) 7 | { 8 | @:this.@(TX.Uncap(field.Name)) = @(counter-1); 9 | } 10 | counter++; 11 | } 12 | @:} 13 | @:exports.@(Model.Name) = new _@(Model.Name)(); 14 | } -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Js/AsyncMethodBody.js: -------------------------------------------------------------------------------- 1 | @{ 2 | @:{ 3 | @:/// 4 | @:/// Function summary. 5 | foreach (var paramInfo in Model.GetParameters()) { 6 | @:/// A param. 7 | } 8 | @:/// 9 | @:} 10 | } -------------------------------------------------------------------------------- /samples/geolocation/README.md: -------------------------------------------------------------------------------- 1 | NodeRT sample - printing current location 2 | ========================================= 3 | 4 | A sample script for printing the current location by using the windows.devices.geolocation module and the Geolocator class. 5 | 6 | **Perquisites**: 7 | 8 | In order to run this sample you should generate the following namespaces and place them in a node_modules directory near the script file: 9 | * Windows.Devices.Geolocation -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Js/Wrapper.js: -------------------------------------------------------------------------------- 1 | @{ 2 | foreach(var vt in Model.ExternalReferencedValueTypes) { 3 | @:@TX.JsDefinitionTemplates.ValueType(vt) 4 | } 5 | 6 | foreach(var vt in Model.ValueTypes) { 7 | @:@TX.JsDefinitionTemplates.ValueType(vt) 8 | } 9 | 10 | foreach(var en in Model.Enums) { 11 | @:@TX.JsDefinitionTemplates.Enum(en) 12 | } 13 | 14 | foreach(var t in Model.Types.Values) { 15 | @:@TX.JsDefinitionTemplates.Type(t) 16 | } 17 | } -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Js/ValueType.js: -------------------------------------------------------------------------------- 1 | @{ 2 | @: 3 | @:@(Model.Name) = (function () { 4 | 5 | @:var cls = function @(Model.Name)() { 6 | 7 | foreach(var field in Model.GetFields()) { 8 | @:this.@(TX.Uncap(field.Name)) = new @(Converter.ToJsDefinitonType(field.FieldType, TX.MainModel.Types.ContainsKey(field.FieldType)))(); 9 | } 10 | 11 | @:}; 12 | 13 | @:return cls; 14 | 15 | @:}) (); 16 | @:exports.@(Model.Name) = @(Model.Name); 17 | @: 18 | } -------------------------------------------------------------------------------- /src/NodeRTUI/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/Enum.cpp: -------------------------------------------------------------------------------- 1 | 2 | static void Init@(Model.Name)Enum(const Local exports) { 3 | HandleScope scope; 4 | 5 | Local enumObject = Nan::New(); 6 | 7 | Nan::Set(exports, Nan::New("@(Model.Name)").ToLocalChecked(), enumObject); 8 | @foreach(var name in Enum.GetNames(Model)) { 9 | @:Nan::Set(enumObject, Nan::New("@(TX.Uncap(name))").ToLocalChecked(), Nan::New(static_cast(@TX.ToWinRT(Model)::@(name)))); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /samples/media/README.md: -------------------------------------------------------------------------------- 1 | NodeRT sample - using the device camera 2 | ========================================= 3 | 4 | A sample script for taking a picture using the device camera and saving it to the local pictures folder. 5 | 6 | **Perquisites**: 7 | 8 | In order to run this sample you should generate the following namespaces and place them in a node_modules directory near the script file: 9 | 10 | * Windows.Media 11 | * Windows.Media.Capture 12 | * Windows.Media.MediaProperties 13 | * Windows.Media.Devices 14 | * Windows.Storage -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Ts/Wrapper.ts: -------------------------------------------------------------------------------- 1 | declare module "@(TX.MainModel.winrtnamespace.ToLower())" { 2 | @{ 3 | foreach(var vt in Model.ExternalReferencedValueTypes) { 4 | @:@TX.TsDefinitionTemplates.ValueType(vt) 5 | } 6 | foreach(var vt in Model.ValueTypes) { 7 | @:@TX.TsDefinitionTemplates.ValueType(vt) 8 | } 9 | foreach(var en in Model.Enums) { 10 | @:@TX.TsDefinitionTemplates.Enum(en) 11 | } 12 | foreach(var t in Model.Types.Values) { 13 | @:@TX.TsDefinitionTemplates.Type(t) 14 | } 15 | @:} 16 | } 17 | 18 | 19 | -------------------------------------------------------------------------------- /samples/lock_screen/set_lock_screen.js: -------------------------------------------------------------------------------- 1 | var profile = require('windows.system.userprofile'); 2 | var storage = require('windows.storage'); 3 | 4 | var imageFileName = 'image.jpg'; 5 | 6 | storage.KnownFolders.picturesLibrary.getFileAsync(imageFileName, function(err, file) { 7 | if (err) { 8 | return console.error('Error getting image file:', err); 9 | } 10 | 11 | profile.LockScreen.setImageFileAsync(file, function(err) { 12 | if (err) { 13 | return console.error('Error setting lock screen image:', err); 14 | } 15 | console.info('Lock screen image was set successfully!'); 16 | }); 17 | }); -------------------------------------------------------------------------------- /samples/geolocation/print_location.js: -------------------------------------------------------------------------------- 1 | // retrieves the current geolocation using the Windows.Devices.Geolocation API 2 | var util = require('util'); 3 | 4 | var geolocation = require('windows.devices.geolocation'); 5 | var locator = new geolocation.Geolocator(); 6 | 7 | var msgTemplate = 'Your current location is: (%s, %s)'; 8 | 9 | locator.getGeopositionAsync( function(err, res) { 10 | // result is of type Windows.Devices.Geolocation.Geoposition 11 | if (err) { 12 | console.error(err); 13 | return; 14 | } 15 | 16 | console.info(util.format(msgTemplate, 17 | res.coordinate.longitude, res.coordinate.latitude)); 18 | }); -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "github-actions" 9 | directory: "/" 10 | schedule: 11 | interval: "daily" 12 | open-pull-requests-limit: 999 13 | - package-ecosystem: "nuget" 14 | directory: "/" 15 | schedule: 16 | interval: "daily" 17 | open-pull-requests-limit: 999 18 | -------------------------------------------------------------------------------- /samples/lock_screen/README.md: -------------------------------------------------------------------------------- 1 | NodeRT sample - setting the lock screen image 2 | ============================================= 3 | 4 | A sample script for setting the lock screen image using Windows.System.Profile and Windows.Storage namespaces. 5 | 6 | The sample uses an image file named 'image.jpg' which resides in the pictures library, in order to run the script, make sure such file exists on your machine, or change the name and location of the file and folder in the script. 7 | 8 | **Perquisites**: 9 | 10 | In order to run this sample you should generate the following namespaces and place them in a node_modules directory near the script file: 11 | 12 | * Windows.System.UserProfile 13 | * Windows.Storage 14 | -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Js/Constructor.js: -------------------------------------------------------------------------------- 1 | @{ 2 | @:var cls = function @(Model.Name)() { 3 | 4 | foreach(var propertyInfo in Model.MemberProperties) { 5 | @:@TX.JsDefinitionTemplates.MemberPropertyGetter(propertyInfo) 6 | } 7 | 8 | @:}; 9 | @: 10 | 11 | foreach(var constructor in Model.Type.GetConstructors()) 12 | { 13 | if (constructor.GetParameters().Length == 0) 14 | { 15 | continue; 16 | } 17 | 18 | @:var cls = function @(Model.Name)(@(TX.GetParamsFromJsMethodForDefinitions(constructor))) { 19 | 20 | foreach(var propertyInfo in Model.MemberProperties) { 21 | @:@TX.JsDefinitionTemplates.MemberPropertyGetter(propertyInfo) 22 | } 23 | 24 | @:}; 25 | @: 26 | } 27 | } -------------------------------------------------------------------------------- /scripts/mass-release.ps1: -------------------------------------------------------------------------------- 1 | Function Get-Folder($initialDirectory) { 2 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 3 | 4 | $foldername = New-Object System.Windows.Forms.FolderBrowserDialog 5 | $foldername.Description = "Select a folder to relase from" 6 | $foldername.rootfolder = "MyComputer" 7 | 8 | if ($foldername.ShowDialog() -eq "OK") { 9 | $folder += $foldername.SelectedPath 10 | } 11 | return $folder 12 | } 13 | 14 | $dir = Get-Folder 15 | 16 | if ($dir -eq $null) { 17 | return 18 | } 19 | 20 | $dirs = dir $dir 21 | 22 | foreach ($d in $dirs) { 23 | Write-Host "Publishing $d" 24 | 25 | cd $d.FullName 26 | npm publish . --access public 27 | cd $dir 28 | } 29 | -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/StaticPropertyGetter.cpp: -------------------------------------------------------------------------------- 1 | 2 | static void @(Model.Name)Getter(Local property, const Nan::PropertyCallbackInfo &info) { 3 | HandleScope scope; 4 | 5 | try 6 | {@{ 7 | var jsConversionInfo = Converter.ToJS(Model.PropertyType, TX.MainModel.Types.ContainsKey(Model.PropertyType)); 8 | var winrtConversionInfo = Converter.ToWinRT(Model.PropertyType); 9 | } 10 | @winrtConversionInfo[0] result = @(TX.ToWinRT(Model.DeclaringType, false))::@(Model.Name); 11 | info.GetReturnValue().Set(@string.Format(jsConversionInfo[1], "result")); 12 | return; 13 | } catch (Platform::Exception ^exception) { 14 | NodeRT::Utils::ThrowWinRtExceptionInJs(exception); 15 | return; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/NodeRTLib/JsPackageFiles/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "{PackageName}", 3 | "version": "{PackageVersion}", 4 | "description": "Use the {Namespace} UWP API directly from Node.js", 5 | "main": "lib/main.js", 6 | "keywords": [ 7 | {Keywords}, 8 | "NodeRT", 9 | "WinRT", 10 | "Microsoft" 11 | ], 12 | "dependencies" : { 13 | "nan" : "latest" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git://github.com/NodeRT/NodeRT.git" 18 | }, 19 | "homepage": "https://github.com/NodeRT/NodeRT", 20 | "author": "Generated by NodeRT", 21 | "contributors": [ 22 | "nadavbar (http://www.nadavos.com)", 23 | "Felix Rieseberg (https://www.felix.fun)" 24 | ], 25 | "gypfile": true, 26 | "license": "Apache-2.0" 27 | } 28 | -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Js/SyncMethodBody.js: -------------------------------------------------------------------------------- 1 | @{ 2 | @:{ 3 | @:/// 4 | @:/// Function summary. 5 | foreach (var paramInfo in Model.GetParameters()) { 6 | @:/// A param. 7 | } 8 | if (Model.ReturnType != typeof(void)) 9 | { 10 | @:/// 11 | } 12 | @:/// 13 | 14 | if (Model.ReturnType != typeof(void)) 15 | { 16 | @:return new @(Converter.ToJsDefinitonType(Model.ReturnType, TX.MainModel.Types.ContainsKey(Model.ReturnType)))(); 17 | } 18 | @:} 19 | } -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Ts/Event.ts: -------------------------------------------------------------------------------- 1 | @{ 2 | for(var i = 0; i < Model.Events.Length; i++) { 3 | @:addListener(type: "@(Model.Events[i].EventInfo.Name)", listener: (ev: Event) => void): void ; 4 | @:removeListener(type: "@(Model.Events[i].EventInfo.Name)", listener: (ev: Event) => void): void ; 5 | @:on(type: "@(Model.Events[i].EventInfo.Name)", listener: (ev: Event) => void): void ; 6 | @:off(type: "@(Model.Events[i].EventInfo.Name)", listener: (ev: Event) => void): void ; 7 | @: 8 | } 9 | @:addListener(type: string, listener: (ev: Event) => void): void ; 10 | @:removeListener(type: string, listener: (ev: Event) => void): void ; 11 | @:on(type: string, listener: (ev: Event) => void): void ; 12 | @:off(type: string, listener: (ev: Event) => void): void ; 13 | @: 14 | } 15 | -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/CastFrom.cpp: -------------------------------------------------------------------------------- 1 | 2 | static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) { 3 | HandleScope scope; 4 | if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<@TX.ToWinRT(Model.Type)>(info[0])) { 5 | Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type"))); 6 | return; 7 | } 8 | 9 | @TX.ToWinRT(Model.Type) winRtInstance; 10 | try { 11 | winRtInstance = (@TX.ToWinRT(Model.Type)) NodeRT::Utils::GetObjectInstance(info[0]); 12 | } catch (Platform::Exception ^exception) { 13 | NodeRT::Utils::ThrowWinRtExceptionInJs(exception); 14 | return; 15 | } 16 | 17 | info.GetReturnValue().Set(Wrap@(Model.Name)(winRtInstance)); 18 | } -------------------------------------------------------------------------------- /src/NodeRTLib/ProjectTemplates/common.gypi: -------------------------------------------------------------------------------- 1 | { 2 | 'variables' : { 3 | 'node_shared': 'true' 4 | }, 5 | 'target_defaults': { 6 | 'default_configuration': 'Release', 7 | 'configurations': { 8 | 'Debug': { 9 | 'msvs_settings': { 10 | 'VCCLCompilerTool': { 11 | 'ExceptionHandling': 1, # /EHsc, 12 | 'RuntimeLibrary': '3', # /MDd 13 | } 14 | } 15 | }, 16 | 'Release': { 17 | 'msvs_settings': { 18 | 'VCCLCompilerTool': { 19 | 'ExceptionHandling': 1, # /EHsc, 20 | 'RuntimeLibrary': '2', # /MD 21 | } 22 | } 23 | } 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/StaticPropertySetter.cpp: -------------------------------------------------------------------------------- 1 | 2 | static void @(Model.Name)Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { 3 | HandleScope scope; 4 | 5 | if (!@(String.Format(Converter.TypeCheck(Model.PropertyType, TX.MainModel.Types.ContainsKey(Model.PropertyType)),"value"))) { 6 | Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); 7 | return; 8 | } 9 | 10 | try { 11 | @{ 12 | var winrtConversionInfo = Converter.ToWinRT(Model.PropertyType); 13 | } 14 | 15 | @(winrtConversionInfo[0]) winRtValue = @(string.Format(winrtConversionInfo[1], "value")); 16 | 17 | @(TX.ToWinRT(Model.DeclaringType, false))::@(Model.Name) = winRtValue; 18 | } catch (Platform::Exception ^exception) { 19 | NodeRT::Utils::ThrowWinRtExceptionInJs(exception); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/packages/RazorTemplates.1.2.0/RazorTemplates.1.2.0.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | RazorTemplates 5 | 1.2.0 6 | RazorTemplates Project 7 | RazorTemplates Project 8 | https://github.com/volkovku/RazorTemplates/blob/master/license.txt 9 | https://github.com/volkovku/RazorTemplates 10 | false 11 | Open source templating engine based on Microsoft's Razor parsing engine. Thread safe. Allows run Razor templates outside ASP.Net MVC Projects. 12 | Visual Basic support was added. 13 | Copyright © RazorTemplates Project 2012 14 | razor razorengine templating razortemplates 15 | 16 | -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/IClosableCloseMethod.cpp: -------------------------------------------------------------------------------- 1 | 2 | static void @(TX.CSharpMethodToCppMethod(Model.Name))(Nan::NAN_METHOD_ARGS_TYPE info) { 3 | HandleScope scope; 4 | 5 | if (!NodeRT::Utils::IsWinRtWrapperOf<@(TX.ToWinRT(Model.Overloads[0].DeclaringType,true))>(info.This())) { 6 | return; 7 | } 8 | 9 | @(Model.Overloads[0].DeclaringType.Name) *wrapper = @(Model.Overloads[0].DeclaringType.Name)::Unwrap<@(Model.Overloads[0].DeclaringType.Name)>(info.This()); 10 | 11 | if (info.Length() == 0) { 12 | try { 13 | delete wrapper->_instance; 14 | wrapper->_instance = nullptr; 15 | return; 16 | } catch (Platform::Exception ^exception) { 17 | NodeRT::Utils::ThrowWinRtExceptionInJs(exception); 18 | return; 19 | } 20 | } else { 21 | Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); 22 | return; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/NodeRTLib/JsPackageFiles/package.vs2022.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "{PackageName}", 3 | "version": "{PackageVersion}", 4 | "description": "Use the {Namespace} UWP API directly from Node.js", 5 | "main": "lib/main.js", 6 | "keywords": [ 7 | {Keywords}, 8 | "NodeRT", 9 | "WinRT", 10 | "Microsoft" 11 | ], 12 | "dependencies": { 13 | "nan": "latest" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git://github.com/demosjarco/NodeRT.git" 18 | }, 19 | "homepage": "https://github.com/demosjarco/NodeRT/tree/vs2022", 20 | "author": "Generated by NodeRT (modified)", 21 | "contributors": [ 22 | "nadavbar (http://www.nadavos.com)", 23 | "Felix Rieseberg (https://www.felix.fun)", 24 | "MaySoMusician (https://msmsm.work/)", 25 | "DemosJarco <1209494+demosjarco@users.noreply.github.com> (https://github.com/demosjarco)" 26 | ], 27 | "gypfile": true, 28 | "license": "Apache-2.0" 29 | } 30 | -------------------------------------------------------------------------------- /src/NodeRTLib/ProjectFiles/WrapperBase.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the ""License""); you may not 5 | // use this file except in compliance with the License. You may obtain a copy of 6 | // the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS 9 | // OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY 10 | // IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | #pragma once 17 | #include 18 | 19 | namespace NodeRT { 20 | class WrapperBase : public Nan::ObjectWrap { 21 | public: 22 | virtual ::Platform::Object ^ GetObjectInstance() const = 0; 23 | }; 24 | } // namespace NodeRT -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/MemberPropertyGetter.cpp: -------------------------------------------------------------------------------- 1 | static void @(Model.Name)Getter(Local property, const Nan::PropertyCallbackInfo &info) { 2 | HandleScope scope; 3 | 4 | if (!NodeRT::Utils::IsWinRtWrapperOf<@(TX.ToWinRT(Model.DeclaringType,true))>(info.This())) { 5 | return; 6 | } 7 | 8 | @(Model.DeclaringType.Name) *wrapper = @(Model.DeclaringType.Name)::Unwrap<@(Model.DeclaringType.Name)>(info.This()); 9 | 10 | try {@{ 11 | var jsConversionInfo = Converter.ToJS(Model.PropertyType, TX.MainModel.Types.ContainsKey(Model.PropertyType)); 12 | var winrtConversionInfo = Converter.ToWinRT(Model.PropertyType);} 13 | @winrtConversionInfo[0] result = wrapper->_instance->@(Model.Name); 14 | info.GetReturnValue().Set(@string.Format(jsConversionInfo[1], "result")); 15 | return; 16 | } catch (Platform::Exception ^exception) { 17 | NodeRT::Utils::ThrowWinRtExceptionInJs(exception); 18 | return; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/NodeRTLib/JsPackageFiles/package.vs2019.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "{PackageName}", 3 | "version": "{PackageVersion}", 4 | "description": "Use the {Namespace} UWP API directly from Node.js", 5 | "main": "lib/main.js", 6 | "keywords": [ 7 | {Keywords}, 8 | "NodeRT", 9 | "WinRT", 10 | "Microsoft" 11 | ], 12 | "dependencies": { 13 | "nan": "latest" 14 | }, 15 | "repository": { 16 | "type": "git", 17 | "url": "git://github.com/demosjarco/NodeRT.git" 18 | }, 19 | "homepage": "https://github.com/demosjarco/NodeRT/tree/feature/136-vs2019", 20 | "author": "Generated by NodeRT (modified)", 21 | "contributors": [ 22 | "nadavbar (http://www.nadavos.com)", 23 | "Felix Rieseberg (https://www.felix.fun)", 24 | "MaySoMusician (https://msmsm.work/)", 25 | "DemosJarco <1209494+demosjarco@users.noreply.github.com> (https://github.com/demosjarco)" 26 | ], 27 | "gypfile": true, 28 | "license": "Apache-2.0" 29 | } 30 | -------------------------------------------------------------------------------- /src/NodeRTLib/packages/RazorTemplates.1.2.0/RazorTemplates.1.2.0.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | RazorTemplates 5 | 1.2.0 6 | RazorTemplates 7 | RazorTemplates Project 8 | RazorTemplates Project 9 | https://github.com/volkovku/RazorTemplates/blob/master/license.txt 10 | https://github.com/volkovku/RazorTemplates 11 | false 12 | Open source templating engine based on Microsoft's Razor parsing engine. Thread safe. Allows run Razor templates outside ASP.Net MVC Projects. 13 | Visual Basic support was added. 14 | Copyright © RazorTemplates Project 2012 15 | 16 | razor razorengine templating razortemplates 17 | 18 | -------------------------------------------------------------------------------- /scripts/automated-mass-release.ps1: -------------------------------------------------------------------------------- 1 | # Function Get-Folder($initialDirectory) { 2 | # [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null 3 | 4 | # $foldername = New-Object System.Windows.Forms.FolderBrowserDialog 5 | # $foldername.Description = "Select a folder to relase from" 6 | # $foldername.rootfolder = "MyComputer" 7 | 8 | # if ($foldername.ShowDialog() -eq "OK") { 9 | # $folder += $foldername.SelectedPath 10 | # } 11 | # return $folder 12 | # } 13 | 14 | $dir = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$PSScriptRoot\..\NodeRT-Bindings") 15 | 16 | # if ($dir -eq $null) { 17 | # return 18 | # } 19 | if (-Not (Test-Path -Path $dir)) { 20 | return 21 | } 22 | 23 | $dirs = Get-ChildItem $dir 24 | 25 | foreach ($d in $dirs) { 26 | Write-Host "Publishing $d" 27 | 28 | cd $d.FullName 29 | 30 | $dryRun = "false" 31 | if ((Test-Path env:\npmDryRun) -And ($Env:npmDryRun -eq "true")) { 32 | $dryRun = "true" 33 | } 34 | 35 | npm publish . --access public --dry-run $dryRun 36 | cd $dir 37 | } 38 | -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/MemberPropertySetter.cpp: -------------------------------------------------------------------------------- 1 | static void @(Model.Name)Setter(Local property, Local value, const Nan::PropertyCallbackInfo &info) { 2 | HandleScope scope; 3 | 4 | if (!@(String.Format(Converter.TypeCheck(Model.PropertyType, TX.MainModel.Types.ContainsKey(Model.PropertyType)),"value"))) { 5 | Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type"))); 6 | return; 7 | } 8 | 9 | if (!NodeRT::Utils::IsWinRtWrapperOf<@(TX.ToWinRT(Model.DeclaringType,true))>(info.This())) { 10 | return; 11 | } 12 | 13 | @(Model.DeclaringType.Name) *wrapper = @(Model.DeclaringType.Name)::Unwrap<@(Model.DeclaringType.Name)>(info.This()); 14 | 15 | try {@{ 16 | var winrtConversionInfo = Converter.ToWinRT(Model.PropertyType); } 17 | 18 | @(winrtConversionInfo[0]) winRtValue = @(string.Format(winrtConversionInfo[1], "value")); 19 | 20 | wrapper->_instance->@(Model.Name) = winRtValue; 21 | } catch (Platform::Exception ^exception) { 22 | NodeRT::Utils::ThrowWinRtExceptionInJs(exception); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/packages/Rx-Interfaces.2.1.30214.0/Rx-Interfaces.2.1.30214.0.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Rx-Interfaces 5 | 2.1.30214.0 6 | Reactive Extensions - Interfaces Library 7 | Microsoft Corporation 8 | Microsoft Corporation 9 | http://go.microsoft.com/fwlink/?LinkID=261272 10 | http://go.microsoft.com/fwlink/?LinkID=261273 11 | http://go.microsoft.com/fwlink/?LinkId=261274 12 | true 13 | Reactive Extensions Interfaces Library containing essential interfaces. 14 | Microsoft Corporation © 2012 15 | en-us 16 | Rx Reactive Extensions Observable LINQ Events 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/packages/Rx-PlatformServices.2.1.30214.0/content/Portable-Net45+WinRT45+WP8/Readme.txt: -------------------------------------------------------------------------------- 1 | Portable libraries built using Rx do not include the System.Reactive.PlatformServices assembly 2 | containing "platform enlightenments" that depend on platform-specific functionality. (Doing so 3 | would prevent the library to be portable due to the dependencies on a specific platform.) 4 | 5 | When including the resulting portable library in another project, please include the platform's 6 | System.Reactive.PlatformServices assembly in order to get the best performance. To include this 7 | assembly, use any of the following options: 8 | 9 | 1. Select the System.Reactive.PlatformServices assembly from the Visual Studio "Add Reference" 10 | dialog. This option works for Windows Store apps, .NET 4.5, and Windows Phone 8 projects. 11 | 12 | 2. For Windows Store apps and Windows Phone 8 projects, use the Reactive Extensions Extension SDK 13 | which can be found in the "Add Reference" dialog. 14 | 15 | 3. Use NuGet to include the Rx-Main package (or any package that depends on Rx-Main, such as 16 | Rx-Xaml) which will automatically include the Rx-PlatformServices enlightenment package. 17 | -------------------------------------------------------------------------------- /samples/media/capture_image.js: -------------------------------------------------------------------------------- 1 | // Uses the media capture API to take an image and save it to the pictures library 2 | 3 | var media = require('windows.media'); 4 | var capture = require('windows.media.capture'); 5 | var storage = require('windows.storage'); 6 | var mp = require('windows.media.mediaproperties'); 7 | var devices = require('windows.media.devices'); 8 | 9 | function captureImage(fileName) { 10 | storage.KnownFolders.picturesLibrary.createFileAsync(fileName, 11 | storage.CreationCollisionOption.replaceExisting, function (err, newFile) { 12 | var storageFile = newFile; 13 | if (err) { 14 | return console.info('file', err); 15 | } 16 | capture.capturePhotoToStorageFileAsync(mp.ImageEncodingProperties.createJpeg(), storageFile, function (err, res) { 17 | if (err) { 18 | return console.info(err); 19 | } 20 | console.info('Image was succesfully saved to:', storageFile.path); 21 | }); 22 | }); 23 | } 24 | 25 | var capture = new capture.MediaCapture(); 26 | capture.initializeAsync(function (err, res) { 27 | if (err) { 28 | return console.info(err); 29 | } 30 | 31 | capture.videoDeviceController.brightness.trySetValue(-1); 32 | captureImage('image_capture_test.jpg'); 33 | }); -------------------------------------------------------------------------------- /src/NodeRTUI/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 4 13 | 14 | 15 | 16 | 17 | 18 | True 19 | 20 | 21 | True 22 | 23 | 24 | 2 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/packages/Rx-Main.2.1.30214.0/Rx-Main.2.1.30214.0.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Rx-Main 5 | 2.1.30214.0 6 | Reactive Extensions - Main Library 7 | Microsoft Corporation 8 | Microsoft Corporation 9 | http://go.microsoft.com/fwlink/?LinkID=261272 10 | http://go.microsoft.com/fwlink/?LinkID=261273 11 | http://go.microsoft.com/fwlink/?LinkId=261274 12 | true 13 | Reactive Extensions Main Library combining the interfaces, core, LINQ, and platform services libraries. 14 | Microsoft Corporation © 2012 15 | en-us 16 | Rx Reactive Extensions Observable LINQ Events 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /samples/speech_stream/README.md: -------------------------------------------------------------------------------- 1 | NodeRT sample - using speech synthesis and streams 2 | ========================================= 3 | 4 | A sample script for synthesizing text to speech using the Windows.Media.SpeechSynthesis API, writing the output audio stream to file using nodert_streams, and then playing it using the media player. 5 | 6 | In order to play the audio file, this sample uses edge.js and a code snippet from this great blog post. 7 | 8 | **Perquisites**: 9 | 10 | Install edge.js by running: 11 | ``` 12 | npm install edge 13 | ``` 14 | 15 | This sample uses the nodert-streams module. 16 | In order to use it - clone it to your machine to a node_modules directory near the script, then build the native bindings of nodert-streams by running the following command from inside the nodert-streams directory: 17 | 18 | ``` 19 | node-gyp rebuild 20 | ``` 21 | 22 | In order to run this sample you should generate the following namespaces and place them in a node_modules directory near the script file: 23 | 24 | * Windows.Media.SpeechSynthesis 25 | * Windows.Storage.Streams (for nodert-streams) 26 | -------------------------------------------------------------------------------- /samples/speech_stream/speak.js: -------------------------------------------------------------------------------- 1 | var nodert_streams = require('nodert-streams'); 2 | var speech = require('windows.media.speechsynthesis'); 3 | var fs = require('fs'); 4 | var path = require('path'); 5 | 6 | // taken from this great post: http://tomasz.janczuk.org/2014/06/playing-audio-from-nodejs-using-edgejs.html 7 | var edge = require('edge'); 8 | var play = edge.func(function() {/* 9 | async (input) => { 10 | return await Task.Run(async () => { 11 | var player = new System.Media.SoundPlayer((string)input); 12 | player.PlaySync(); 13 | return null; 14 | }); 15 | } 16 | */}); 17 | 18 | var outputFilePath = path.join(__dirname, 'synthesized_text.wav'); 19 | 20 | var synth = new speech.SpeechSynthesizer(); 21 | synth.synthesizeTextToStreamAsync('Hello Node R T!', function(err, res) { 22 | if (err) { 23 | return console.info(err); 24 | } 25 | var inputStream = new nodert_streams.InputStream(res); 26 | var fileStream = fs.createWriteStream(outputFilePath); 27 | fileStream.on('close', function () { 28 | play(outputFilePath, function (err) { 29 | if (err) return console.error(err); 30 | fs.unlinkSync(outputFilePath); 31 | }); 32 | }); 33 | 34 | inputStream.pipe(fileStream); 35 | }); -------------------------------------------------------------------------------- /src/NodeRTUI/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the ""License""); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 5 | // 6 | // THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. 7 | // 8 | // See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. 9 | 10 | using System; 11 | using System.Collections.Generic; 12 | using System.Linq; 13 | using System.Threading.Tasks; 14 | using System.Windows.Forms; 15 | 16 | namespace NodeRTUI 17 | { 18 | static class Program 19 | { 20 | /// 21 | /// The main entry point for the application. 22 | /// 23 | [STAThread] 24 | static void Main() 25 | { 26 | Application.EnableVisualStyles(); 27 | Application.SetCompatibleTextRenderingDefault(false); 28 | Application.Run(new MainForm()); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/packages/Rx-Core.2.1.30214.0/Rx-Core.2.1.30214.0.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Rx-Core 5 | 2.1.30214.0 6 | Reactive Extensions - Core Library 7 | Microsoft Corporation 8 | Microsoft Corporation 9 | http://go.microsoft.com/fwlink/?LinkID=261272 10 | http://go.microsoft.com/fwlink/?LinkID=261273 11 | http://go.microsoft.com/fwlink/?LinkId=261274 12 | true 13 | Reactive Extensions Core Library containing base classes and scheduler infrastructure. 14 | Microsoft Corporation © 2012 15 | en-us 16 | Rx Reactive Extensions Observable LINQ Events 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /samples/notification/README.md: -------------------------------------------------------------------------------- 1 | NodeRT sample - showing a notification on the desktop 2 | ===================================================== 3 | 4 | A sample script for showing a notification on the desktop. 5 | 6 | **Perquisites**: 7 | 8 | In order to show notifications from a desktop application you need to have a shortcut with an **app-id** 9 | More info on this is available here: http://msdn.microsoft.com/en-us/library/windows/desktop/hh802762 10 | 11 | You can create a shortcut in node.js easily using the following node module: https://www.npmjs.org/package/node-win-shortcut: 12 | 13 | First, Run: 14 | ```javascript 15 | npm install node-win-shortcut 16 | ``` 17 | 18 | Then, you can run the following node.js code in order to create the shortcut with the app-id (you can use whatever string you like instead of 'node_app_id'): 19 | 20 | ```javascript 21 | var win_shortcut = require('node-win-shortcut'); 22 | win_shortcut.createShortcut(process.execPath, 'node', 'node_app_id'); 23 | ``` 24 | 25 | After you've created the shortcut, replace 'node_app_id' in the following line in the notification.js script with your shortcut's app-id (if necessary): 26 | 27 | ```javascript 28 | var appId = 'node_app_id'; 29 | ``` 30 | 31 | In order to run this sample you should generate the following namespaces and place them in a node_modules directory near the script file: 32 | 33 | * Windows.Data.Xml.Dom 34 | * Windows.Ui.Notifications 35 | -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Js/Type.js: -------------------------------------------------------------------------------- 1 | @{ 2 | @:@(Model.Name) = (function () { 3 | 4 | @:@TX.JsDefinitionTemplates.Constructor(Model) 5 | 6 | foreach(var methodInfo in Model.MemberAsyncMethods) { 7 | @:@TX.JsDefinitionTemplates.MemberAsyncMethod(methodInfo) 8 | } 9 | 10 | foreach(var methodInfo in Model.MemberSyncMethods) 11 | { 12 | if (TX.IsMethodNotImplemented(methodInfo)) 13 | { 14 | @:@TX.JsDefinitionTemplates.NotImplementedMethod(methodInfo) 15 | } 16 | else 17 | { 18 | if (TX.IsIClosableClose(methodInfo.Overloads[0])) 19 | { 20 | @:@TX.JsDefinitionTemplates.IClosableCloseMethod(methodInfo) 21 | } 22 | else 23 | { 24 | @:@TX.JsDefinitionTemplates.MemberSyncMethod(methodInfo) 25 | } 26 | } 27 | } 28 | 29 | foreach(var methodInfo in Model.StaticAsyncMethods) { 30 | @:@TX.JsDefinitionTemplates.StaticAsyncMethod(methodInfo) 31 | } 32 | 33 | foreach(var methodInfo in Model.StaticSyncMethods) { 34 | @:@TX.JsDefinitionTemplates.StaticSyncMethod(methodInfo) 35 | } 36 | 37 | if (Model.StaticProperties.Length > 0) 38 | { 39 | foreach(var propertyInfo in Model.StaticProperties) { 40 | @:@TX.JsDefinitionTemplates.StaticPropertyGetter(propertyInfo) 41 | } 42 | } 43 | 44 | @if(Model.Events.Length > 0) 45 | { 46 | @TX.JsDefinitionTemplates.Event(Model) 47 | } 48 | 49 | @:return cls; 50 | @:}) (); 51 | @:exports.@(Model.Name) = @(Model.Name); 52 | } -------------------------------------------------------------------------------- /src/packages/Rx-Linq.2.1.30214.0/Rx-Linq.2.1.30214.0.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Rx-Linq 5 | 2.1.30214.0 6 | Reactive Extensions - Query Library 7 | Microsoft Corporation 8 | Microsoft Corporation 9 | http://go.microsoft.com/fwlink/?LinkID=261272 10 | http://go.microsoft.com/fwlink/?LinkID=261273 11 | http://go.microsoft.com/fwlink/?LinkId=261274 12 | true 13 | Reactive Extensions Query Library used to express complex event processing queries over observable sequences. 14 | Microsoft Corporation © 2012 15 | en-us 16 | Rx Reactive Extensions Observable LINQ Events 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/NodeRTLib/DefinitonTemplates/Ts/Type.ts: -------------------------------------------------------------------------------- 1 | @{ 2 | @:export class @(Model.Name) { 3 | 4 | if (Model.StaticProperties.Length > 0) 5 | { 6 | foreach(var propertyInfo in Model.StaticProperties) { 7 | @:@TX.TsDefinitionTemplates.StaticPropertyGetter(propertyInfo) 8 | } 9 | } 10 | 11 | foreach(var propertyInfo in Model.MemberProperties) { 12 | @:@TX.TsDefinitionTemplates.MemberPropertyGetter(propertyInfo) 13 | } 14 | 15 | @:@TX.TsDefinitionTemplates.Constructor(Model) 16 | 17 | foreach(var methodInfo in Model.StaticAsyncMethods) { 18 | @:@TX.TsDefinitionTemplates.StaticAsyncMethod(methodInfo) 19 | } 20 | 21 | foreach(var methodInfo in Model.StaticSyncMethods) { 22 | @:@TX.TsDefinitionTemplates.StaticSyncMethod(methodInfo) 23 | } 24 | 25 | foreach(var methodInfo in Model.MemberAsyncMethods) { 26 | @:@TX.TsDefinitionTemplates.MemberAsyncMethod(methodInfo) 27 | } 28 | 29 | foreach(var methodInfo in Model.MemberSyncMethods) 30 | { 31 | if (TX.IsMethodNotImplemented(methodInfo)) 32 | { 33 | @:@TX.TsDefinitionTemplates.NotImplementedMethod(methodInfo) 34 | } 35 | else 36 | { 37 | if (TX.IsIClosableClose(methodInfo.Overloads[0])) 38 | { 39 | @:@TX.TsDefinitionTemplates.IClosableCloseMethod(methodInfo) 40 | } 41 | else 42 | { 43 | @:@TX.TsDefinitionTemplates.MemberSyncMethod(methodInfo) 44 | } 45 | } 46 | } 47 | 48 | @if (Model.Events.Length > 0) 49 | { 50 | @TX.TsDefinitionTemplates.Event(Model) 51 | } 52 | 53 | @:} 54 | } -------------------------------------------------------------------------------- /src/packages/Rx-PlatformServices.2.1.30214.0/Rx-PlatformServices.2.1.30214.0.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Rx-PlatformServices 5 | 2.1.30214.0 6 | Reactive Extensions - Platform Services Library 7 | Microsoft Corporation 8 | Microsoft Corporation 9 | http://go.microsoft.com/fwlink/?LinkID=261272 10 | http://go.microsoft.com/fwlink/?LinkID=261273 11 | http://go.microsoft.com/fwlink/?LinkId=261274 12 | true 13 | Reactive Extensions Platform Services Library used to access platform-specific functionality and enlightenment services. 14 | Microsoft Corporation © 2012 15 | en-us 16 | Rx Reactive Extensions Observable LINQ Events 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/NodeRTUI/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("NodeRTUI")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NodeRTUI")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("5c8a0b85-ce67-47a4-b77c-d2c13c0a9fdf")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("3.1.1.0")] 36 | [assembly: AssemblyFileVersion("3.1.1.0")] 37 | -------------------------------------------------------------------------------- /src/NodeRTCmd/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("NodeRTCmd")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NodeRTCmd")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("9487c439-ccb1-49e8-b978-54b0cdf3f2b6")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("3.1.1.0")] 36 | [assembly: AssemblyFileVersion("3.1.1.0")] 37 | -------------------------------------------------------------------------------- /src/NodeRTLib/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("NodeRTLib")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NodeRTLib")] 13 | [assembly: AssemblyCopyright("Copyright © 2019")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3517449e-fc4e-4515-8fb7-4a58c0b9b046")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("3.1.1.0")] 36 | [assembly: AssemblyFileVersion("3.1.1.0")] 37 | -------------------------------------------------------------------------------- /src/NodeRTLib/ProjectFiles/CollectionsConverterUtils.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) The NodeRT Contributors 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the ""License""); you may 5 | // not use this file except in compliance with the License. You may obtain a 6 | // copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS 9 | // OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY 10 | // IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | #pragma once 17 | 18 | // Every type used in Vector or VectorView template instantiation must have 19 | // operator== Implement operator== for types that don't have an operator== 20 | // implementation available and there is no acceptable conversion to an existing 21 | // operator== 22 | namespace std { 23 | 24 | bool operator==(const ::Windows::Foundation::TimeSpan& first, 25 | const ::Windows::Foundation::TimeSpan& second); 26 | 27 | bool operator==( 28 | const ::Windows::Devices::Geolocation::BasicGeoposition& first, 29 | const ::Windows::Devices::Geolocation::BasicGeoposition& second); 30 | 31 | bool operator==(const ::Windows::Storage::Search::SortEntry& first, 32 | const ::Windows::Storage::Search::SortEntry& second); 33 | 34 | bool operator==(const ::Windows::Data::Text::TextSegment& first, 35 | const ::Windows::Data::Text::TextSegment& second); 36 | 37 | } // namespace std 38 | -------------------------------------------------------------------------------- /samples/notification/notification.js: -------------------------------------------------------------------------------- 1 | // Show a windows notification from node.js using NodeRT modules 2 | var util = require('util'); 3 | 4 | var xml = require('windows.data.xml.dom'); 5 | var notifications = require('windows.ui.notifications'); 6 | 7 | // for more info please see: http://msdn.microsoft.com/en-us/library/windows/apps/hh465448.aspx 8 | var msgTemplate = '' + 9 | '' + 10 | '%s' + 11 | '%s' + 12 | ''; 13 | 14 | // use here an app id that was used for creating a shortcut 15 | // for more info see: http://msdn.microsoft.com/en-us/library/windows/desktop/hh802762 16 | // and: https://github.com/nadavbar/node-win-shortcut 17 | var appId = 'node_app_id'; 18 | 19 | // A Helper function for showing notifications 20 | function showNotification(title, text, onActiviation, onDismissal) { 21 | 22 | var toastXml = new xml.XmlDocument(); 23 | toastXml.loadXml(util.format(msgTemplate, title, text)); 24 | var toast = new notifications.ToastNotification(toastXml); 25 | 26 | toast.on("activated", function (sender, eventArgs) { 27 | onActiviation(); 28 | }); 29 | 30 | toast.on("dismissed", function () { 31 | onDismissal(); 32 | }); 33 | 34 | notifications.ToastNotificationManager.createToastNotifier(appId).show(toast); 35 | } 36 | 37 | showNotification('Hello NodeRT!', 'Please click here', function() { 38 | console.info('got event: toast activated!'); 39 | process.exit(0); 40 | }, function() { 41 | console.info('got event: toast dismissed!'); 42 | process.exit(0); 43 | }); 44 | 45 | // wait for user interaction: 46 | setTimeout(function() { 47 | console.info('no event was fired'); 48 | }, 30000); -------------------------------------------------------------------------------- /src/NodeRTLib/ProjectFiles/CollectionsConverterUtils.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) The NodeRT Contributors 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the ""License""); you may 5 | // not use this file except in compliance with the License. You may obtain a 6 | // copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS 9 | // OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY 10 | // IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | #include "CollectionsConverterUtils.h" 17 | 18 | namespace std { 19 | bool operator==(const ::Windows::Foundation::TimeSpan& first, 20 | const ::Windows::Foundation::TimeSpan& second) { 21 | return first.Duration == second.Duration; 22 | } 23 | 24 | bool operator==( 25 | const ::Windows::Devices::Geolocation::BasicGeoposition& first, 26 | const ::Windows::Devices::Geolocation::BasicGeoposition& second) { 27 | return (first.Altitude == second.Altitude) && 28 | (first.Latitude == second.Latitude) && 29 | (first.Longitude == second.Longitude); 30 | } 31 | 32 | bool operator==(const ::Windows::Storage::Search::SortEntry& first, 33 | const ::Windows::Storage::Search::SortEntry& second) { 34 | return (first.AscendingOrder == second.AscendingOrder) && 35 | (first.PropertyName == second.PropertyName); 36 | } 37 | 38 | bool operator==(const ::Windows::Data::Text::TextSegment& first, 39 | const ::Windows::Data::Text::TextSegment& second) { 40 | return (first.Length == second.Length) && 41 | (first.StartPosition == second.StartPosition); 42 | } 43 | 44 | } // namespace std 45 | -------------------------------------------------------------------------------- /src/NodeRTUI/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 |
7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 4 22 | 23 | 24 | 25 | 26 | 27 | True 28 | 29 | 30 | True 31 | 32 | 33 | 2 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/NodeRT.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.21005.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NodeRTCmd", "NodeRTCmd\NodeRTCmd.csproj", "{E2B7205A-D21F-4EDC-947B-F9B1B35DC988}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NodeRTLib", "NodeRTLib\NodeRTLib.csproj", "{8B785E90-8642-41CC-9859-8FC0D2AB7D57}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NodeRTUI", "NodeRTUI\NodeRTUI.csproj", "{E3C8CF58-6AA0-42F1-8363-835958CC6D2B}" 11 | EndProject 12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6A8FB495-9501-42EC-ABF4-AB02805BB5E7}" 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {E2B7205A-D21F-4EDC-947B-F9B1B35DC988}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {E2B7205A-D21F-4EDC-947B-F9B1B35DC988}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {E2B7205A-D21F-4EDC-947B-F9B1B35DC988}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {E2B7205A-D21F-4EDC-947B-F9B1B35DC988}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {8B785E90-8642-41CC-9859-8FC0D2AB7D57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {8B785E90-8642-41CC-9859-8FC0D2AB7D57}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {8B785E90-8642-41CC-9859-8FC0D2AB7D57}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {8B785E90-8642-41CC-9859-8FC0D2AB7D57}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {E3C8CF58-6AA0-42F1-8363-835958CC6D2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {E3C8CF58-6AA0-42F1-8363-835958CC6D2B}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {E3C8CF58-6AA0-42F1-8363-835958CC6D2B}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {E3C8CF58-6AA0-42F1-8363-835958CC6D2B}.Release|Any CPU.Build.0 = Release|Any CPU 32 | EndGlobalSection 33 | GlobalSection(SolutionProperties) = preSolution 34 | HideSolutionNode = FALSE 35 | EndGlobalSection 36 | EndGlobal 37 | -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/ValueType.cpp: -------------------------------------------------------------------------------- 1 | static bool Is@(Model.Name)JsObject(Local value) { 2 | if (!value->IsObject()) { 3 | return false; 4 | } 5 | 6 | Local symbol; 7 | Local obj = Nan::To(value).ToLocalChecked(); 8 | 9 | @foreach (var field in Model.GetFields()) 10 | { 11 | @:symbol = Nan::New("@TX.Uncap(field.Name)").ToLocalChecked(); 12 | @:if (Nan::Has(obj, symbol).FromMaybe(false)) { 13 | @: if (!@(String.Format(Converter.TypeCheck(field.FieldType, TX.MainModel.Types.ContainsKey(field.FieldType)), "Nan::Get(obj,symbol).ToLocalChecked()"))) { 14 | @: return false; 15 | @: } 16 | @:} 17 | @: 18 | } 19 | return true; 20 | } 21 | 22 | @TX.ToWinRT(Model) @(Model.Name)FromJsObject(Local value) { 23 | HandleScope scope; 24 | @TX.ToWinRT(Model) returnValue; 25 | 26 | if (!value->IsObject()) { 27 | Nan::ThrowError(Nan::TypeError(NodeRT::Utils::NewString(L"Unexpected type, expected an object"))); 28 | return returnValue; 29 | } 30 | 31 | Local obj = Nan::To(value).ToLocalChecked(); 32 | Local symbol; 33 | 34 | @foreach (var field in Model.GetFields()) 35 | { 36 | @:symbol = Nan::New("@TX.Uncap(field.Name)").ToLocalChecked(); 37 | @:if (Nan::Has(obj, symbol).FromMaybe(false)) { 38 | var winRtConversionInfo = Converter.ToWinRT(field.FieldType); 39 | @: returnValue.@(field.Name) = @(String.Format(winRtConversionInfo[1],"Nan::Get(obj,symbol).ToLocalChecked()")); 40 | @:} 41 | @: 42 | } 43 | return returnValue; 44 | } 45 | 46 | Local @(Model.Name)ToJsObject(@TX.ToWinRT(Model) value) { 47 | EscapableHandleScope scope; 48 | 49 | Local obj = Nan::New(); 50 | 51 | @foreach (var field in Model.GetFields()) 52 | { 53 | var jsConversionInfo = Converter.ToJS(field.FieldType, TX.MainModel.Types.ContainsKey(field.FieldType)); 54 | @:Nan::Set(obj, Nan::New("@TX.Uncap(field.Name)").ToLocalChecked(), @string.Format(jsConversionInfo[1], "value." + field.Name)); 55 | } 56 | 57 | return scope.Escape(obj); 58 | } 59 | -------------------------------------------------------------------------------- /src/NodeRTLib/ProjectFiles/OpaqueWrapper.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) The NodeRT Contributors 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the ""License""); you may 5 | // not use this file except in compliance with the License. You may obtain a 6 | // copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS 9 | // OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY 10 | // IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | #pragma once 17 | 18 | #include 19 | #include 20 | #include 21 | #include "NodeRTUtils.h" 22 | #include "WrapperBase.h" 23 | #include "nan.h" 24 | #include "nan_object_wrap.h" 25 | 26 | namespace NodeRT { 27 | class OpaqueWrapperInitializer; 28 | 29 | v8::Local CreateOpaqueWrapper(::Platform::Object ^ wintRtHandle); 30 | 31 | class OpaqueWrapper : public WrapperBase { 32 | public: 33 | virtual ::Platform::Object ^ GetObjectInstance() const override { 34 | return _instance; 35 | } 36 | 37 | static bool IsOpaqueWrapper(v8::Local value) { 38 | if (value.IsEmpty() || !value->IsObject()) { 39 | return false; 40 | } 41 | 42 | v8::Local hiddenVal = NodeRT::Utils::GetHiddenValue( 43 | value.As(), 44 | Nan::New("__winrtOpaqueWrapper__").ToLocalChecked()); 45 | 46 | if (hiddenVal.IsEmpty() || !hiddenVal->IsBoolean()) { 47 | return false; 48 | } 49 | 50 | return hiddenVal->IsTrue(); 51 | } 52 | 53 | private: 54 | OpaqueWrapper(::Platform::Object ^ instance) : _instance(instance) {} 55 | 56 | static void New(Nan::NAN_METHOD_ARGS_TYPE info); 57 | static void Init(); 58 | 59 | private: 60 | ::Platform::Object ^ _instance; 61 | static Nan::Persistent s_constructorTemplate; 62 | 63 | friend OpaqueWrapperInitializer; 64 | friend v8::Local CreateOpaqueWrapper(::Platform::Object ^ 65 | wintRtInstance); 66 | }; 67 | } // namespace NodeRT 68 | -------------------------------------------------------------------------------- /src/NodeRTLib/JsPackageFiles/README.md: -------------------------------------------------------------------------------- 1 | {PackageName} 2 | ===== 3 | 4 | A Node.js wrapper for the {Namespace} WinRT namespace, compatible with Windows {WinVersion} APIs. 5 | 6 | Using this module, you'll be able to consume the {Namespace} API directly from Node.js. 7 | 8 | This module was automatically generated by NodeRT. 9 | For more information on NodeRT and examples on how to use NodeRT modules, please visit the project page at: https://github.com/NodeRT/NodeRT. 10 | 11 | The API exposed by this module is (almost) the same as the API that is listed in: http://msdn.microsoft.com/en-us/library/windows/apps/{Namespace}.aspx 12 | 13 | The only difference in the API is in the way that asynchronous methods and events are used. (See https://github.com/NodeRT/NodeRT#ConsumingNodeRT for more details) 14 | 15 | This module also contains TypeScript definition files for the API exposed by the module, as well as JavaScript intellisense support for Node.js tools for Visual Studio. 16 | 17 | Prequisites: 18 | ============ 19 | * Visual Studio version {VSVersion} and above. (Express Desktop versions also work!) 20 | * Python 2.7 (for node-gyp) 21 | * Important: Updated versions of npm and node-gyp. (Note that the ones that are bundled with node might not be up to date). In order to install latest npm, run: 22 | ``` 23 | npm install -g npm 24 | ``` 25 | 26 | In order to install latest node-gyp run: 27 | ``` 28 | npm install -g node-gyp 29 | ``` 30 | 31 | Installation: 32 | ============= 33 | In order to install this module, run npm install: 34 | 35 | ``` 36 | npm install {PackageName} 37 | ``` 38 | 39 | If you wish to rebuild this module using node-gyp, make sure to use the appropriate VS version using --msvs_version=2012/2013/2015/2017 flag: 40 | 41 | For example: 42 | 43 | ``` 44 | cd [module folder path] 45 | node-gyp rebuild --msvs_version={VSVersion} 46 | ``` -------------------------------------------------------------------------------- /src/NodeRTLib/JsPackageFiles/main.js: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation, Nadav Bar, and Felix Rieseberg 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the ""License""); you may 5 | // not use this file except in compliance with the License. You may obtain a 6 | // copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS 9 | // OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY 10 | // IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing permissions 14 | // and limitations under the License. 15 | 16 | const path = require('path'); 17 | const fs = require('fs'); 18 | 19 | const npmScope = '{NpmScope}'; 20 | 21 | // This little trick makes Node.js Tools for VS load IntelliSense for the module 22 | if (fs.existsSync(path.join(__dirname, '{ProjectName}.d.js)'))) { 23 | module.exports = require('./{ProjectName}.d.js'); 24 | } else { 25 | module.exports = require('../build/Release/binding.node'); 26 | } 27 | 28 | var externalReferencedNamespaces = [{ExternalReferencedNamespaces}]; 29 | 30 | if (externalReferencedNamespaces.length > 0) { 31 | var namespaceRegistry = global.__winRtNamespaces__; 32 | 33 | if (!namespaceRegistry) { 34 | namespaceRegistry = {}; 35 | 36 | Object.defineProperty(global, '__winRtNamespaces__', { 37 | configurable: true, 38 | writable: false, 39 | enumerable: false, 40 | value: namespaceRegistry 41 | }); 42 | } 43 | 44 | function requireNamespace(namespace) { 45 | var moduleName = namespace.toLowerCase(); 46 | 47 | if (npmScope) { 48 | moduleName = '@' + npmScope + '/' + moduleName; 49 | } 50 | 51 | var m = require(moduleName); 52 | delete namespaceRegistry[namespace]; 53 | namespaceRegistry[namespace] = m; 54 | return m; 55 | } 56 | 57 | for (var i in externalReferencedNamespaces) { 58 | var ns = externalReferencedNamespaces[i]; 59 | 60 | if (!namespaceRegistry.hasOwnProperty(ns)) { 61 | Object.defineProperty(namespaceRegistry, ns, { 62 | configurable: true, 63 | enumerable: true, 64 | get: requireNamespace.bind(null, ns) 65 | }); 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/NodeRTLib/ProjectFiles/OpaqueWrapper.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) The NodeRT Contributors 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the ""License""); you may 5 | // not use this file except in compliance with the License. You may obtain a 6 | // copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS 9 | // OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY 10 | // IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing permissions 14 | // and limitations under the License. 15 | 16 | #include "OpaqueWrapper.h" 17 | #include "NodeRtUtils.h" 18 | 19 | using v8::String; 20 | using v8::FunctionTemplate; 21 | 22 | Nan::Persistent NodeRT::OpaqueWrapper::s_constructorTemplate; 23 | 24 | void NodeRT::OpaqueWrapper::New(Nan::NAN_METHOD_ARGS_TYPE info) 25 | { 26 | NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winrtOpaqueWrapper__").ToLocalChecked(), Nan::True()); 27 | 28 | info.GetReturnValue().Set(info.This()); 29 | } 30 | 31 | 32 | void NodeRT::OpaqueWrapper::Init() 33 | { 34 | Nan::HandleScope scope; 35 | // Prepare constructor template 36 | s_constructorTemplate.Reset(Nan::New(New)); 37 | v8::Local localRef = Nan::New(s_constructorTemplate); 38 | localRef->SetClassName(Nan::New("OpaqueWrapper").ToLocalChecked()); 39 | localRef->InstanceTemplate()->SetInternalFieldCount(1); 40 | } 41 | 42 | namespace NodeRT { 43 | v8::Local CreateOpaqueWrapper(::Platform::Object^ winRtInstance) 44 | { 45 | Nan::EscapableHandleScope scope; 46 | if (winRtInstance == nullptr) 47 | { 48 | return scope.Escape(Nan::Undefined()); 49 | } 50 | 51 | v8::Local args[] = { Nan::Undefined() }; 52 | if (OpaqueWrapper::s_constructorTemplate.IsEmpty()) 53 | { 54 | OpaqueWrapper::Init(); 55 | } 56 | 57 | v8::Local localRef = Nan::New(OpaqueWrapper::s_constructorTemplate); 58 | v8::Local objectInstance = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), 0, args).ToLocalChecked(); 59 | if (objectInstance.IsEmpty()) 60 | { 61 | return scope.Escape(Nan::Undefined()); 62 | } 63 | OpaqueWrapper* wrapperInstance = new OpaqueWrapper(winRtInstance); 64 | wrapperInstance->Wrap(objectInstance); 65 | return scope.Escape(objectInstance); 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /scripts/mass-creation.ps1: -------------------------------------------------------------------------------- 1 | Param( 2 | [Parameter(Mandatory=$true)] 3 | [string]$npmVersion 4 | ) 5 | 6 | Function Get-Folder { 7 | $description = $args[0] 8 | $initialPath = $args[1] 9 | 10 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null; 11 | [System.Windows.Forms.Application]::EnableVisualStyles(); 12 | 13 | $foldername = New-Object System.Windows.Forms.FolderBrowserDialog; 14 | $foldername.Description = $description; 15 | #$foldername.rootfolder = "MyComputer"; 16 | 17 | if (Test-Path $initialPath) { 18 | $foldername.SelectedPath = $initialPath; 19 | } 20 | 21 | if ($foldername.ShowDialog() -eq "OK") { 22 | $folder += $foldername.SelectedPath; 23 | } 24 | 25 | return $folder; 26 | } 27 | 28 | $nodertCmd = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$PSScriptRoot\..\src\NodeRTCmd\bin\Debug\NodeRTCmd.exe"); 29 | 30 | if ((Test-Path -Path $nodertCmd) -eq $false) { 31 | Write-Host "Could not find $nodertCmd."; 32 | Write-Host "Now exiting."; 33 | return; 34 | } 35 | 36 | $unionMetadataDir = Get-Folder "Select your Windows SDK UnionMetadata folder" "C:\Program Files (x86)\Windows Kits\10\UnionMetadata"; 37 | 38 | if ($unionMetadataDir -eq $null) { 39 | return; 40 | } 41 | 42 | $unionMetadataDirs = Get-ChildItem -dir $unionMetadataDir -Filter "10.*" 43 | $sdks = @{}; 44 | 45 | foreach ($d in $unionMetadataDirs) { 46 | $namespace = "" 47 | 48 | Switch ($d.Name) { 49 | "10.0.15063.0" { $namespace = "nodert-win10-cu"; } 50 | "10.0.16299.0" { $namespace = "nodert-win10-rs3"; } 51 | "10.0.17134.0" { $namespace = "nodert-win10-rs4"; } 52 | "10.0.17763.0" { $namespace = "nodert-win10-rs5"; } 53 | "10.0.18362.0" { $namespace = "nodert-win10-19h1"; } 54 | "10.0.19041.0" { $namespace = "nodert-win10-20h1"; } 55 | "10.0.20348.0" { $namespace = "nodert-win10-21h1"; } 56 | 57 | "10.0.22000.0" { $namespace = "nodert-win11"; } 58 | "10.0.22621.0" { $namespace = "nodert-win11-22h2"; } 59 | } 60 | 61 | if ($namespace -eq "") { 62 | Write-Host "Found SDK folder $d, but it's unknown. We won't use it."; 63 | } else { 64 | Write-Host "Will generate NodeRT modules using metadata found in $d (as $namespace)" 65 | 66 | $sdks[$namespace] = $d.FullName; 67 | } 68 | } 69 | 70 | $reply = Read-Host -Prompt "Continue? [y/n]" 71 | if ($reply -match "[yY]") { 72 | foreach ($sdk in $sdks.keys) { 73 | $sdkFolder = $sdks.$sdk; 74 | Write-Host "Generating packages for @$sdk using $sdkFolder"; 75 | 76 | $outDir = New-Item -Path "~/Desktop/NodeRT/$sdk" -ItemType directory; 77 | Write-Host "Output will be available in $outDir" 78 | 79 | & $nodertCmd --winmd $sdkFolder\Windows.winmd --outdir $outDir --npmscope $sdk --npmversion $npmVersion --nobuild 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/NodeRTLib/ProjectTemplates/binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "WIN_VER": "{WinVer}", 4 | "USE_ADDITIONAL_WINMD": "{UseAdditionalWinmd}" 5 | }, 6 | "includes": ["common.gypi"], 7 | "targets": [{ 8 | "target_name": "binding", 9 | "sources": [], 10 | "include_dirs": [ 11 | " 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.34011 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace NodeRTUI.Properties { 12 | using System; 13 | 14 | 15 | /// 16 | /// A strongly-typed resource class, for looking up localized strings, etc. 17 | /// 18 | // This class was auto-generated by the StronglyTypedResourceBuilder 19 | // class via a tool like ResGen or Visual Studio. 20 | // To add or remove a member, edit your .ResX file then rerun ResGen 21 | // with the /str option, or rebuild your VS project. 22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] 23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 25 | internal class Resources { 26 | 27 | private static global::System.Resources.ResourceManager resourceMan; 28 | 29 | private static global::System.Globalization.CultureInfo resourceCulture; 30 | 31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] 32 | internal Resources() { 33 | } 34 | 35 | /// 36 | /// Returns the cached ResourceManager instance used by this class. 37 | /// 38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 39 | internal static global::System.Resources.ResourceManager ResourceManager { 40 | get { 41 | if (object.ReferenceEquals(resourceMan, null)) { 42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("NodeRTUI.Properties.Resources", typeof(Resources).Assembly); 43 | resourceMan = temp; 44 | } 45 | return resourceMan; 46 | } 47 | } 48 | 49 | /// 50 | /// Overrides the current thread's CurrentUICulture property for all 51 | /// resource lookups using this strongly typed resource class. 52 | /// 53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] 54 | internal static global::System.Globalization.CultureInfo Culture { 55 | get { 56 | return resourceCulture; 57 | } 58 | set { 59 | resourceCulture = value; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | 11 | [Dd]ebug/ 12 | [Rr]elease/ 13 | x64/ 14 | build/ 15 | [Bb]in/ 16 | [Oo]bj/ 17 | 18 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 19 | !packages/*/build/ 20 | 21 | # MSTest test Results 22 | [Tt]est[Rr]esult*/ 23 | [Bb]uild[Ll]og.* 24 | 25 | *_i.c 26 | *_p.c 27 | *.ilk 28 | *.meta 29 | *.obj 30 | *.pch 31 | *.pdb 32 | *.pgc 33 | *.pgd 34 | *.rsp 35 | *.sbr 36 | *.tlb 37 | *.tli 38 | *.tlh 39 | *.tmp 40 | *.tmp_proj 41 | *.log 42 | *.vspscc 43 | *.vssscc 44 | .builds 45 | *.pidb 46 | *.log 47 | *.scc 48 | 49 | # Visual C++ cache files 50 | ipch/ 51 | *.aps 52 | *.ncb 53 | *.opensdf 54 | *.sdf 55 | *.cachefile 56 | 57 | # Visual Studio profiler 58 | *.psess 59 | *.vsp 60 | *.vspx 61 | 62 | # Guidance Automation Toolkit 63 | *.gpState 64 | 65 | # ReSharper is a .NET coding add-in 66 | _ReSharper*/ 67 | *.[Rr]e[Ss]harper 68 | 69 | # TeamCity is a build add-in 70 | _TeamCity* 71 | 72 | # DotCover is a Code Coverage Tool 73 | *.dotCover 74 | 75 | # NCrunch 76 | *.ncrunch* 77 | .*crunch*.local.xml 78 | 79 | # Installshield output folder 80 | [Ee]xpress/ 81 | 82 | # DocProject is a documentation generator add-in 83 | DocProject/buildhelp/ 84 | DocProject/Help/*.HxT 85 | DocProject/Help/*.HxC 86 | DocProject/Help/*.hhc 87 | DocProject/Help/*.hhk 88 | DocProject/Help/*.hhp 89 | DocProject/Help/Html2 90 | DocProject/Help/html 91 | 92 | # Click-Once directory 93 | publish/ 94 | 95 | # Publish Web Output 96 | *.Publish.xml 97 | *.pubxml 98 | 99 | # NuGet Packages Directory 100 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 101 | #packages/ 102 | 103 | # Windows Azure Build Output 104 | csx 105 | *.build.csdef 106 | 107 | # Windows Store app package directory 108 | AppPackages/ 109 | 110 | # Others 111 | sql/ 112 | *.Cache 113 | ClientBin/ 114 | [Ss]tyle[Cc]op.* 115 | ~$* 116 | *~ 117 | *.dbmdl 118 | *.[Pp]ublish.xml 119 | *.pfx 120 | *.publishsettings 121 | 122 | # RIA/Silverlight projects 123 | Generated_Code/ 124 | 125 | # Backup & report files from converting an old project file to a newer 126 | # Visual Studio version. Backup files are not needed, because we have git ;-) 127 | _UpgradeReport_Files/ 128 | Backup*/ 129 | UpgradeLog*.XML 130 | UpgradeLog*.htm 131 | 132 | # SQL Server files 133 | App_Data/*.mdf 134 | App_Data/*.ldf 135 | 136 | # ========================= 137 | # Windows detritus 138 | # ========================= 139 | 140 | # Windows image file caches 141 | Thumbs.db 142 | ehthumbs.db 143 | 144 | # Folder config file 145 | Desktop.ini 146 | 147 | # Recycle Bin used on file shares 148 | $RECYCLE.BIN/ 149 | 150 | # Mac crap 151 | .DS_Store 152 | 153 | # Output folder 154 | NodeRT-Bindings/ 155 | 156 | # VS2017 157 | src/.vs/NodeRT/v15 158 | 159 | # VS2019 160 | src/.vs/NodeRT/v16 161 | 162 | # VS2022 163 | src/.vs/NodeRT/v17 -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/RegisterEventWithWinRT.cpp: -------------------------------------------------------------------------------- 1 | @{ 2 | Type t = Model.EventInfo.EventHandlerType; 3 | Type [] eventArgs = t.GetMethods().Where((methodInfo) => { return (methodInfo.Name == "Invoke"); }).First().GetParameters().Select((pi) => { return pi.ParameterType; }).ToArray(); 4 | 5 | var foreachArg = new Func((format, len) => { 6 | return TX.ForEachType(eventArgs, format, len); 7 | }); 8 | } 9 | try { 10 | Persistent* perstPtr = new Persistent(); 11 | perstPtr->Reset(NodeRT::Utils::CreateCallbackObjectInDomain(callback)); 12 | std::shared_ptr> callbackObjPtr(perstPtr, 13 | [] (Persistent *ptr ) { 14 | NodeUtils::Async::RunOnMain([ptr]() { 15 | ptr->Reset(); 16 | delete ptr; 17 | }); 18 | }); 19 | 20 | @if (Model.IsStatic) 21 | { 22 | @:registrationToken = @(TX.ToWinRT(Model.EventInfo.DeclaringType, false))::@(Model.EventInfo.Name)::add( 23 | } else { 24 | @:registrationToken = wrapper->_instance->@(Model.EventInfo.Name)::add( 25 | } 26 | ref new @(TX.ToWinRT(Model.EventInfo.EventHandlerType,false))( 27 | [callbackObjPtr](@foreachArg("{1} arg{2}, ", 2)) { 28 | NodeUtils::Async::RunOnMain([callbackObjPtr @foreachArg(", arg{2}", 0)]() { 29 | HandleScope scope; 30 | 31 | @{var k = 0;} 32 | @foreach (var type in eventArgs) 33 | { 34 | @:Local wrappedArg@(k); 35 | k++; 36 | } 37 | 38 | { 39 | TryCatch tryCatch; 40 | 41 | @{var j = 0;} 42 | @foreach (var type in eventArgs) 43 | { 44 | var jsConversionInfo = Converter.ToJS(type, TX.MainModel.Types.ContainsKey(type)); 45 | @:wrappedArg@(j) = @(string.Format(jsConversionInfo[1], String.Format("arg{0}", j))); 46 | j++; 47 | } 48 | 49 | @{var i = 0;} 50 | @foreach (var type in eventArgs) 51 | { 52 | @:if (wrappedArg@(i).IsEmpty()) wrappedArg@(i) = Undefined(); 53 | i++; 54 | } 55 | } 56 | 57 | @if (eventArgs.Length > 0) { 58 | @:Local args[] = { @foreachArg("wrappedArg{2}, ", 2) }; 59 | @:Local callbackObjLocalRef = Nan::New(*callbackObjPtr); 60 | @:NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef, _countof(args), args); 61 | } else { 62 | @:Local callbackObjLocalRef = Nan::New(*callbackObjPtr); 63 | @:NodeRT::Utils::CallCallbackInDomain(callbackObjLocalRef,0, nullptr); 64 | } 65 | }); 66 | }) 67 | ); 68 | } 69 | catch (Platform::Exception ^exception) { 70 | NodeRT::Utils::ThrowWinRtExceptionInJs(exception); 71 | return; 72 | } 73 | -------------------------------------------------------------------------------- /src/NodeRTLib/JsPackageFiles/README.vs2019.md: -------------------------------------------------------------------------------- 1 | {PackageName} 2 | ===== 3 | 4 | ## Notice 5 | 6 | The series of `@:::org:::` packages is unofficially-published NodeRT modules for **Windows :::win-major::: SDK, version :::win-minor::: (10.0.:::target-build-ver:::.0)** corresponding to Windows :::target-ver::: (:::win-desc:::). 7 | 8 | These are generated by the modified version of NodeRT thus are experimental, as the original doesn't have support for :::win-minor::: SDK, nor for building with VS2019. Supporting for VS2019 is based on Taosenai's workaround with lxbndr's suggestion. The modified source code can be found here. 9 | 10 | Below is the original description about this module. 11 | 12 | --- 13 | 14 | A Node.js wrapper for the {Namespace} WinRT namespace, compatible with Windows {WinVersion} APIs. 15 | 16 | Using this module, you'll be able to consume the {Namespace} API directly from Node.js. 17 | 18 | This module was automatically generated by NodeRT. 19 | For more information on NodeRT and examples on how to use NodeRT modules, please visit the project page at: https://github.com/NodeRT/NodeRT. 20 | 21 | The API exposed by this module is (almost) the same as the API that is listed in: http://msdn.microsoft.com/en-us/library/windows/apps/{Namespace}.aspx 22 | 23 | The only difference in the API is in the way that asynchronous methods and events are used. (See https://github.com/NodeRT/NodeRT#ConsumingNodeRT for more details) 24 | 25 | This module also contains TypeScript definition files for the API exposed by the module, as well as JavaScript intellisense support for Node.js tools for Visual Studio. 26 | 27 | Prequisites: 28 | ============ 29 | * Visual Studio 2019 and above. (Community edition works, other editions aren't tested but surely work!) 30 | * Python 2.7, 3.5, 3.6, 3.7, or 3.8 (for node-gyp) 31 | * Important: Updated versions of npm and node-gyp. (Note that the ones that are bundled with node might not be up to date). In order to install latest npm, run: 32 | ``` 33 | npm install -g npm 34 | ``` 35 | 36 | In order to install latest node-gyp run: 37 | ``` 38 | npm install -g node-gyp 39 | ``` 40 | 41 | Installation: 42 | ============= 43 | In order to install this module, run npm install: 44 | 45 | ``` 46 | npm install {PackageName} 47 | ``` 48 | 49 | If you wish to rebuild this module using node-gyp, make sure to use the appropriate VS version using --msvs_version=2012/2013/2015/2017/2019 flag: 50 | 51 | For example: 52 | 53 | ``` 54 | cd [module folder path] 55 | node-gyp rebuild --msvs_version=2019 56 | ``` 57 | 58 | If you fail to rebuild due to unable to find module 'nan', try running `npm install --ignore-scripts` -------------------------------------------------------------------------------- /src/NodeRTLib/JsPackageFiles/README.vs2022.md: -------------------------------------------------------------------------------- 1 | {PackageName} 2 | ===== 3 | 4 | ## Notice 5 | 6 | The series of `@:::org:::` packages is unofficially-published NodeRT modules for **Windows :::win-major::: SDK, version :::win-minor::: (10.0.:::target-build-ver:::.0)** corresponding to Windows :::target-ver::: (:::win-desc:::). 7 | 8 | These are generated by the modified version of NodeRT thus are experimental, as the original doesn't have support for :::win-minor::: SDK, nor for building with VS2022. Supporting for VS2022 is based on Taosenai's workaround with lxbndr's suggestion. The modified source code can be found here. 9 | 10 | Below is the original description about this module. 11 | 12 | --- 13 | 14 | A Node.js wrapper for the {Namespace} WinRT namespace, compatible with Windows {WinVersion} APIs. 15 | 16 | Using this module, you'll be able to consume the {Namespace} API directly from Node.js. 17 | 18 | This module was automatically generated by NodeRT. 19 | For more information on NodeRT and examples on how to use NodeRT modules, please visit the project page at: https://github.com/NodeRT/NodeRT. 20 | 21 | The API exposed by this module is (almost) the same as the API that is listed in: http://msdn.microsoft.com/en-us/library/windows/apps/{Namespace}.aspx 22 | 23 | The only difference in the API is in the way that asynchronous methods and events are used. (See https://github.com/NodeRT/NodeRT#ConsumingNodeRT for more details) 24 | 25 | This module also contains TypeScript definition files for the API exposed by the module, as well as JavaScript intellisense support for Node.js tools for Visual Studio. 26 | 27 | Prequisites: 28 | ============ 29 | * Visual Studio 2022 and above. (Community edition works, other editions aren't tested but surely work!) 30 | * Python 2.7, 3.5, 3.6, 3.7, or 3.8 (for node-gyp) 31 | * Important: Updated versions of npm and node-gyp. (Note that the ones that are bundled with node might not be up to date). In order to install latest npm, run: 32 | ``` 33 | npm install -g npm 34 | ``` 35 | 36 | In order to install latest node-gyp run: 37 | ``` 38 | npm install -g node-gyp 39 | ``` 40 | 41 | Installation: 42 | ============= 43 | In order to install this module, run npm install: 44 | 45 | ``` 46 | npm install {PackageName} 47 | ``` 48 | 49 | If you wish to rebuild this module using node-gyp, make sure to use the appropriate VS version using --msvs_version=2012/2013/2015/2017/2022 flag: 50 | 51 | For example: 52 | 53 | ``` 54 | cd [module folder path] 55 | node-gyp rebuild --msvs_version=2022 56 | ``` 57 | 58 | If you fail to rebuild due to unable to find module 'nan', try running `npm install --ignore-scripts` -------------------------------------------------------------------------------- /scripts/automated-mass-creation.ps1: -------------------------------------------------------------------------------- 1 | # Param( 2 | # [Parameter(Mandatory=$true)] 3 | # [string]$npmVersion 4 | # ) 5 | 6 | # Function Get-Folder { 7 | # $description = $args[0] 8 | # $initialPath = $args[1] 9 | 10 | # [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null; 11 | # [System.Windows.Forms.Application]::EnableVisualStyles(); 12 | 13 | # $foldername = New-Object System.Windows.Forms.FolderBrowserDialog; 14 | # $foldername.Description = $description; 15 | # #$foldername.rootfolder = "MyComputer"; 16 | 17 | # if (Test-Path $initialPath) { 18 | # $foldername.SelectedPath = $initialPath; 19 | # } 20 | 21 | # if ($foldername.ShowDialog() -eq "OK") { 22 | # $folder += $foldername.SelectedPath; 23 | # } 24 | 25 | # return $folder; 26 | # } 27 | 28 | $nodertCmd = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$PSScriptRoot\..\src\NodeRTCmd\bin\Debug\NodeRTCmd.exe"); 29 | 30 | if ((Test-Path -Path $nodertCmd) -eq $false) { 31 | Write-Host "Could not find $nodertCmd."; 32 | Write-Host "Now exiting."; 33 | return; 34 | } 35 | 36 | # $unionMetadataDir = Get-Folder "Select your Windows SDK UnionMetadata folder" "C:\Program Files (x86)\Windows Kits\10\UnionMetadata"; 37 | $unionMetadataDir = "${Env:ProgramFiles(x86)}\Windows Kits\10\UnionMetadata"; 38 | 39 | # if ($unionMetadataDir -eq $null) { 40 | # return; 41 | # } 42 | if (-Not (Test-Path -Path $unionMetadataDir)) { 43 | return 44 | } 45 | 46 | $unionMetadataDirs = Get-ChildItem -dir $unionMetadataDir -Filter "10.*" 47 | $sdks = @{}; 48 | 49 | foreach ($d in $unionMetadataDirs) { 50 | $namespace = "" 51 | 52 | Switch ($d.Name) { 53 | "10.0.15063.0" { $namespace = "nodert-win10-cu"; } 54 | "10.0.16299.0" { $namespace = "nodert-win10-rs3"; } 55 | "10.0.17134.0" { $namespace = "nodert-win10-rs4"; } 56 | "10.0.17763.0" { $namespace = "nodert-win10-rs5"; } 57 | "10.0.18362.0" { $namespace = "nodert-win10-19h1"; } 58 | "10.0.19041.0" { $namespace = "nodert-win10-20h1"; } 59 | "10.0.20348.0" { $namespace = "nodert-win10-21h1"; } 60 | 61 | "10.0.22000.0" { $namespace = "nodert-win11"; } 62 | "10.0.22621.0" { $namespace = "nodert-win11-22h2"; } 63 | } 64 | 65 | if ($namespace -eq "") { 66 | Write-Host "Found SDK folder $d, but it's unknown. We won't use it."; 67 | } elseif (Test-Path env:\desiredSdk) { 68 | if ($namespace -eq $Env:desiredSdk) { 69 | Write-Host "Will generate NodeRT modules using metadata found in $d (as $namespace)" 70 | 71 | $sdks[$namespace] = $d.FullName; 72 | } else { 73 | Write-Host "Found SDK folder $d (as $namespace), but it's not desired. We won't use it."; 74 | } 75 | } else { 76 | Write-Host "Will generate NodeRT modules using metadata found in $d (as $namespace)" 77 | 78 | $sdks[$namespace] = $d.FullName; 79 | } 80 | } 81 | 82 | # $reply = Read-Host -Prompt "Continue? [y/n]" 83 | # if ($reply -match "[yY]") { 84 | foreach ($sdk in $sdks.keys) { 85 | $sdkFolder = $sdks.$sdk; 86 | Write-Host "Generating packages for @$sdk using $sdkFolder"; 87 | 88 | # $outDir = New-Item -Path "~/Desktop/NodeRT/$sdk" -ItemType directory; 89 | $outDir = New-Item -Path $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath("$PSScriptRoot\..\NodeRT-Bindings\$sdk") -ItemType directory; 90 | Write-Host "Output will be available in $outDir" 91 | 92 | & $nodertCmd --winmd $sdkFolder\Windows.winmd --outdir $outDir --npmscope $sdk --npmversion $Env:npmVersion --nobuild 93 | } 94 | # } -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/Type.cpp: -------------------------------------------------------------------------------- 1 | class @(Model.Name) : public WrapperBase { 2 | public: 3 | @TX.CppTemplates.InitExports(Model) 4 | 5 | virtual ::Platform::Object^ GetObjectInstance() const override { 6 | return _instance; 7 | } 8 | 9 | private: 10 | 11 | @(Model.Name)(@TX.ToWinRT(Model.Type) instance) { 12 | _instance = instance; 13 | } 14 | 15 | @TX.CppTemplates.Constructor(Model) 16 | 17 | @TX.CppTemplates.CastFrom(Model) 18 | 19 | @foreach(var methodInfo in Model.MemberAsyncMethods) { 20 | @TX.CppTemplates.MemberASyncMethod(methodInfo) 21 | } 22 | 23 | @foreach(var methodInfo in Model.MemberSyncMethods) { 24 | if (TX.IsMethodNotImplemented(methodInfo)) { 25 | @TX.CppTemplates.NotImplementedMethod(methodInfo) 26 | } else { 27 | if (TX.IsIClosableClose(methodInfo.Overloads[0])) { 28 | @TX.CppTemplates.IClosableCloseMethod(methodInfo) 29 | } else { 30 | @TX.CppTemplates.MemberSyncMethod(methodInfo) 31 | } 32 | } 33 | } 34 | 35 | @foreach(var methodInfo in Model.StaticAsyncMethods) { 36 | @TX.CppTemplates.StaticASyncMethod(methodInfo) 37 | } 38 | 39 | @foreach(var methodInfo in Model.StaticSyncMethods) { 40 | @TX.CppTemplates.StaticSyncMethod(methodInfo) 41 | } 42 | 43 | @foreach(var propertyInfo in Model.MemberProperties) { 44 | @TX.CppTemplates.MemberPropertyGetter(propertyInfo) 45 | 46 | @: 47 | if (propertyInfo.GetSetMethod() != null) { 48 | @TX.CppTemplates.MemberPropertySetter(propertyInfo) 49 | @: 50 | } 51 | } 52 | 53 | @if (Model.StaticProperties.Length > 0) 54 | { 55 | @foreach(var propertyInfo in Model.StaticProperties) 56 | { 57 | @TX.CppTemplates.StaticPropertyGetter(propertyInfo) 58 | 59 | @: 60 | if (propertyInfo.GetSetMethod() != null) { 61 | @TX.CppTemplates.StaticPropertySetter(propertyInfo) 62 | @: 63 | } 64 | } 65 | } 66 | 67 | @if(Model.Events.Length > 0) 68 | { 69 | @TX.CppTemplates.Event(Model) 70 | } 71 | private: 72 | @(TX.ToWinRT(Model.Type)) _instance; 73 | static Persistent s_constructorTemplate; 74 | 75 | friend v8::Local Wrap@(Model.Name)(@(TX.ToWinRT(Model.Type)) wintRtInstance); 76 | friend @(TX.ToWinRT(Model.Type)) Unwrap@(Model.Name)(Local value); 77 | }; 78 | 79 | Persistent @(Model.Name)::s_constructorTemplate; 80 | 81 | v8::Local Wrap@(Model.Name)(@(TX.ToWinRT(Model.Type)) winRtInstance) { 82 | EscapableHandleScope scope; 83 | 84 | if (winRtInstance == nullptr) { 85 | return scope.Escape(Undefined()); 86 | } 87 | 88 | Local opaqueWrapper = CreateOpaqueWrapper(winRtInstance); 89 | Local args[] = {opaqueWrapper}; 90 | Local localRef = Nan::New(@(Model.Name)::s_constructorTemplate); 91 | return scope.Escape(Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(),_countof(args), args).ToLocalChecked()); 92 | } 93 | 94 | @(TX.ToWinRT(Model.Type)) Unwrap@(Model.Name)(Local value) { 95 | return @(Model.Name)::Unwrap<@(Model.Name)>(Nan::To(value).ToLocalChecked())->_instance; 96 | } 97 | 98 | void Init@(Model.Name)(Local exports) { 99 | @(Model.Name)::Init(exports); 100 | } 101 | 102 | -------------------------------------------------------------------------------- /src/NodeRTCmd/NodeRTCmd.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {E2B7205A-D21F-4EDC-947B-F9B1B35DC988} 8 | Exe 9 | Properties 10 | NodeRTLib 11 | WinRTReflect 12 | NodeRTCmd 13 | NodeRTCmd 14 | v4.8 15 | 512 16 | 8.0 17 | 18 | 19 | AnyCPU 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | AnyCPU 30 | pdbonly 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | nodert.ico 39 | 40 | 41 | 42 | 43 | 44 | False 45 | ..\packages\RazorTemplates.1.2.0\lib\System.Web.Razor.dll 46 | True 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | {8b785e90-8642-41cc-9859-8fc0d2ab7d57} 64 | NodeRTLib 65 | 66 | 67 | 68 | 69 | 70 | 71 | 78 | -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/Constructor.cpp: -------------------------------------------------------------------------------- 1 | 2 | static void New(Nan::NAN_METHOD_ARGS_TYPE info) { 3 | HandleScope scope; 4 | 5 | Local localRef = Nan::New(s_constructorTemplate); 6 | 7 | // in case the constructor was called without the new operator 8 | if (!localRef->HasInstance(info.This())) { 9 | if (info.Length() > 0) { 10 | std::unique_ptr []> constructorArgs(new Local[info.Length()]); 11 | 12 | Local *argsPtr = constructorArgs.get(); 13 | for (int i = 0; i < info.Length(); i++) { 14 | argsPtr[i] = info[i]; 15 | } 16 | 17 | MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), constructorArgs.get()); 18 | if (res.IsEmpty()) { 19 | return; 20 | } 21 | 22 | info.GetReturnValue().Set(res.ToLocalChecked()); 23 | return; 24 | } else { 25 | MaybeLocal res = Nan::NewInstance(Nan::GetFunction(localRef).ToLocalChecked(), info.Length(), nullptr); 26 | 27 | if (res.IsEmpty()) { 28 | return; 29 | } 30 | 31 | info.GetReturnValue().Set(res.ToLocalChecked()); 32 | return; 33 | } 34 | } 35 | 36 | @TX.ToWinRT(Model.Type) winRtInstance; 37 | @{ 38 | int c = 0; 39 | var constructors = Model.Type.GetConstructors(); 40 | } 41 | 42 | if (info.Length() == 1 && OpaqueWrapper::IsOpaqueWrapper(info[0]) && 43 | NodeRT::Utils::IsWinRtWrapperOf<@TX.ToWinRT(Model.Type)>(info[0])) { 44 | try { 45 | winRtInstance = (@(TX.ToWinRT(Model.Type))) NodeRT::Utils::GetObjectInstance(info[0]); 46 | } catch (Platform::Exception ^exception) { 47 | NodeRT::Utils::ThrowWinRtExceptionInJs(exception); 48 | return; 49 | } 50 | } 51 | @foreach(var overload in constructors) { 52 | int i = 1; 53 | @:else if (info.Length() == @(overload.GetParameters().Length)@{if (overload.GetParameters().Length==0)@(")")} 54 | 55 | foreach (var paramInfo in overload.GetParameters()) { 56 | 57 | @:&& @(String.Format(Converter.TypeCheck(paramInfo.ParameterType, TX.MainModel.Types.ContainsKey(paramInfo.ParameterType)), "info[" + (i-1).ToString() + "]"))@{if (overload.GetParameters().Length==i) @(")")} 58 | i++; 59 | } 60 | @:{ 61 | @:try { 62 | int parameterCounter = 0; 63 | foreach (var paramInfo in overload.GetParameters()) { 64 | var winrtConversionInfo = Converter.ToWinRT(paramInfo.ParameterType, TX.MainModel.Types.ContainsKey(paramInfo.ParameterType)); 65 | 66 | @:@(winrtConversionInfo[0]) arg@(parameterCounter) = @(string.Format(winrtConversionInfo[1], "info[" +parameterCounter + "]" )); 67 | parameterCounter++; 68 | } 69 | 70 | if (overload.GetParameters().Length > 0) { 71 | @: 72 | } 73 | @:winRtInstance = ref new @(TX.ToWinRT(Model.Type, false))(@{int j=0;foreach(var paramInfo in overload.GetParameters()){if(j>0)@(","); @("arg" + j.ToString()); j++;}}); 74 | @:} catch (Platform::Exception ^exception) { 75 | @:NodeRT::Utils::ThrowWinRtExceptionInJs(exception); 76 | @:return; 77 | @:} 78 | @:} 79 | } else { 80 | Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no suitable constructor found"))); 81 | return; 82 | } 83 | 84 | NodeRT::Utils::SetHiddenValue(info.This(), Nan::New("__winRtInstance__").ToLocalChecked(), True()); 85 | 86 | @(Model.Name) *wrapperInstance = new @(Model.Name)(winRtInstance); 87 | wrapperInstance->Wrap(info.This()); 88 | 89 | info.GetReturnValue().Set(info.This()); 90 | } 91 | -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/Wrapper.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) The NodeRT Contributors 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the ""License""); you may 5 | // not use this file except in compliance with the License. You may obtain a 6 | // copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS 9 | // OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY 10 | // IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing permissions 14 | // and limitations under the License. 15 | 16 | // TODO: Verify that this is is still needed.. 17 | #define NTDDI_VERSION 0x06010000 18 | 19 | #include 20 | #include "nan.h" 21 | #include 22 | #include 23 | #include "CollectionsConverter.h" 24 | #include "CollectionsWrap.h" 25 | #include "node-async.h" 26 | #include "NodeRtUtils.h" 27 | #include "OpaqueWrapper.h" 28 | #include "WrapperBase.h" 29 | 30 | #using <@(Model.Assembly.GetName().Name).WinMD> 31 | 32 | // this undefs fixes the issues of compiling Windows.Data.Json, Windows.Storag.FileProperties, and Windows.Stroage.Search 33 | // Some of the node header files brings windows definitions with the same names as some of the WinRT methods 34 | #undef DocumentProperties 35 | #undef GetObject 36 | #undef CreateEvent 37 | #undef FindText 38 | #undef SendMessage 39 | 40 | const char* REGISTRATION_TOKEN_MAP_PROPERTY_NAME = "__registrationTokenMap__"; 41 | 42 | using v8::Array; 43 | using v8::String; 44 | using v8::Value; 45 | using v8::Boolean; 46 | using v8::Integer; 47 | using v8::FunctionTemplate; 48 | using v8::Object; 49 | using v8::Local; 50 | using v8::Function; 51 | using v8::Date; 52 | using v8::Number; 53 | using v8::PropertyAttribute; 54 | using v8::Primitive; 55 | using Nan::HandleScope; 56 | using Nan::Persistent; 57 | using Nan::Undefined; 58 | using Nan::True; 59 | using Nan::False; 60 | using Nan::Null; 61 | using Nan::MaybeLocal; 62 | using Nan::EscapableHandleScope; 63 | using Nan::HandleScope; 64 | using Nan::TryCatch; 65 | using namespace concurrency; 66 | 67 | @foreach(var name in Model.Namespaces) @("namespace " + name + " { ") 68 | 69 | @TX.CppTemplates.TypeWrapperForwardDeclaration(Model) 70 | 71 | @foreach(var en in Model.Enums) { 72 | @TX.CppTemplates.Enum(en); 73 | } 74 | 75 | @foreach(var vt in Model.ValueTypes) { 76 | @TX.CppTemplates.ValueType(vt); 77 | } 78 | 79 | @foreach(var vt in Model.ExternalReferencedValueTypes) { 80 | @TX.CppTemplates.ValueType(vt); 81 | } 82 | 83 | @foreach(var t in Model.Types.Values) { 84 | @TX.CppTemplates.Type(t); 85 | } 86 | 87 | @foreach(var name in Model.Namespaces) @("} ") 88 | 89 | 90 | NAN_MODULE_INIT(init) { 91 | // We ignore failures for now since it probably means that 92 | // the initialization already happened for STA, and that's cool 93 | 94 | CoInitializeEx(nullptr, COINIT_MULTITHREADED); 95 | 96 | /* 97 | if (FAILED(CoInitializeEx(nullptr, COINIT_MULTITHREADED))) { 98 | Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"error in CoInitializeEx()"))); 99 | return; 100 | } 101 | */ 102 | 103 | @{ 104 | var namespacePrefix = ""; 105 | foreach(var name in Model.Namespaces) { 106 | namespacePrefix += name + "::"; 107 | } 108 | 109 | foreach(var en in Model.Enums) { 110 | @:@(namespacePrefix)Init@(en.Name)Enum(target); 111 | } 112 | 113 | foreach(var t in Model.Types.Values) { 114 | @:@(namespacePrefix)Init@(t.Name)(target); 115 | } 116 | } 117 | 118 | NodeRT::Utils::RegisterNameSpace("@(Model.WinRTNamespace)", target); 119 | } 120 | 121 | @{ 122 | var moduleName = Model.Namespaces[0]; 123 | var counter = 0; 124 | 125 | for (var i=1; i< Model.Namespaces.Count; i++) { 126 | moduleName += "_" + Model.Namespaces[i]; 127 | } 128 | } 129 | 130 | NODE_MODULE(binding, init) 131 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | NodeRT License: 2 | 3 | Copyright (c) Microsoft Corporation 4 | All rights reserved. 5 | Licensed under the Apache License, Version 2.0 (the ""License""); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 6 | THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. 7 | See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. 8 | 9 | 10 | RazorTemplates Library License: 11 | https://github.com/volkovku/RazorTemplates/blob/master/license.txt 12 | 13 | Microsoft Public License (Ms-PL) 14 | 15 | This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software. 16 | 17 | Definitions 18 | The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law. 19 | A "contribution" is the original software, or any additions or changes to the software. 20 | A "contributor" is any person that distributes its contribution under this license. 21 | "Licensed patents" are a contributor's patent claims that read directly on its contribution. 22 | Grant of Rights 23 | (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. 24 | (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. 25 | Conditions and Limitations 26 | (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. 27 | (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically. 28 | (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software. 29 | (D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license. 30 | (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. 31 | 32 | RX.Net Library License: 33 | https://github.com/Reactive-Extensions/Rx.NET/blob/master/Rx.NET/Source/license.txt 34 | 35 | Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. 36 | Microsoft Open Technologies would like to thank its contributors, a list 37 | of whom are at http://rx.codeplex.com/wikipage?title=Contributors. 38 | 39 | Licensed under the Apache License, Version 2.0 (the "License"); you 40 | may not use this file except in compliance with the License. You may 41 | obtain a copy of the License at 42 | 43 | http://www.apache.org/licenses/LICENSE-2.0 44 | 45 | Unless required by applicable law or agreed to in writing, software 46 | distributed under the License is distributed on an "AS IS" BASIS, 47 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 48 | implied. See the License for the specific language governing permissions 49 | and limitations under the License. -------------------------------------------------------------------------------- /src/NodeRTUI/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace NodeRTUI.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | 26 | [global::System.Configuration.UserScopedSettingAttribute()] 27 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 28 | [global::System.Configuration.DefaultSettingValueAttribute("")] 29 | public string LastWinMDPath { 30 | get { 31 | return ((string)(this["LastWinMDPath"])); 32 | } 33 | set { 34 | this["LastWinMDPath"] = value; 35 | } 36 | } 37 | 38 | [global::System.Configuration.UserScopedSettingAttribute()] 39 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 40 | [global::System.Configuration.DefaultSettingValueAttribute("")] 41 | public string LastFilter { 42 | get { 43 | return ((string)(this["LastFilter"])); 44 | } 45 | set { 46 | this["LastFilter"] = value; 47 | } 48 | } 49 | 50 | [global::System.Configuration.UserScopedSettingAttribute()] 51 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 52 | [global::System.Configuration.DefaultSettingValueAttribute("3")] 53 | public int VsVersionComboSelection { 54 | get { 55 | return ((int)(this["VsVersionComboSelection"])); 56 | } 57 | set { 58 | this["VsVersionComboSelection"] = value; 59 | } 60 | } 61 | 62 | [global::System.Configuration.UserScopedSettingAttribute()] 63 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 64 | [global::System.Configuration.DefaultSettingValueAttribute("")] 65 | public string OutputDirPath { 66 | get { 67 | return ((string)(this["OutputDirPath"])); 68 | } 69 | set { 70 | this["OutputDirPath"] = value; 71 | } 72 | } 73 | 74 | [global::System.Configuration.UserScopedSettingAttribute()] 75 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 76 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 77 | public bool GenerateDefsChk { 78 | get { 79 | return ((bool)(this["GenerateDefsChk"])); 80 | } 81 | set { 82 | this["GenerateDefsChk"] = value; 83 | } 84 | } 85 | 86 | [global::System.Configuration.UserScopedSettingAttribute()] 87 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 88 | [global::System.Configuration.DefaultSettingValueAttribute("True")] 89 | public bool BuildModuleChk { 90 | get { 91 | return ((bool)(this["BuildModuleChk"])); 92 | } 93 | set { 94 | this["BuildModuleChk"] = value; 95 | } 96 | } 97 | 98 | [global::System.Configuration.UserScopedSettingAttribute()] 99 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] 100 | [global::System.Configuration.DefaultSettingValueAttribute("2")] 101 | public int WinVersionComboSelection { 102 | get { 103 | return ((int)(this["WinVersionComboSelection"])); 104 | } 105 | set { 106 | this["WinVersionComboSelection"] = value; 107 | } 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/InitExports.cpp: -------------------------------------------------------------------------------- 1 | 2 | static void Init(const Local exports) { 3 | HandleScope scope; 4 | 5 | Local localRef = Nan::New(New); 6 | s_constructorTemplate.Reset(localRef); 7 | localRef->SetClassName(Nan::New("@(Model.Name)").ToLocalChecked()); 8 | localRef->InstanceTemplate()->SetInternalFieldCount(1); 9 | 10 | @if(Model.MemberASyncMethods.Length > 0 || Model.StaticASyncMethods.Length > 0) { 11 | @:Local func; 12 | @:Local funcTemplate; 13 | } 14 | 15 | @if(Model.MemberSyncMethods.Length > 0) { 16 | @: 17 | foreach(var method in Model.MemberSyncMethods) { 18 | @:Nan::SetPrototypeMethod(localRef, "@(TX.Uncap(TX.CSharpMethodToCppMethod(method.Name)))", @(TX.CSharpMethodToCppMethod(method.Name))); 19 | } 20 | @: 21 | } 22 | 23 | @if(Model.MemberASyncMethods.Length > 0) { 24 | @: 25 | foreach(var method in Model.MemberASyncMethods) { 26 | @:Nan::SetPrototypeMethod(localRef, "@(TX.Uncap(TX.CSharpMethodToCppMethod(method.Name)))", @TX.CSharpMethodToCppMethod(method.Name)); 27 | } 28 | @: 29 | } 30 | 31 | @if(Model.HasMemberEvents) { 32 | @: 33 | @:Nan::SetPrototypeMethod(localRef,"addListener", AddListener); 34 | @:Nan::SetPrototypeMethod(localRef,"on", AddListener); 35 | @:Nan::SetPrototypeMethod(localRef,"removeListener", RemoveListener); 36 | @:Nan::SetPrototypeMethod(localRef, "off", RemoveListener); 37 | } 38 | 39 | @if(Model.MemberProperties.Length > 0) { 40 | @: 41 | foreach(var prop in Model.MemberProperties) { 42 | var propName = TX.Uncap(prop.Name); 43 | if (prop.GetSetMethod() != null) { 44 | @:Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("@(propName)").ToLocalChecked(), @(prop.Name)Getter, @(prop.Name)Setter); 45 | } else { 46 | @:Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New("@(propName)").ToLocalChecked(), @(prop.Name)Getter); 47 | } 48 | } 49 | } 50 | 51 | Local constructor = Nan::To(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked(); 52 | Nan::SetMethod(constructor, "castFrom", CastFrom); 53 | 54 | @{ 55 | if(Model.StaticSyncMethods.Length > 0) { 56 | foreach(var method in Model.StaticSyncMethods) { 57 | @:Nan::SetMethod(constructor, "@(TX.Uncap(TX.CSharpMethodToCppMethod(method.Name)))", @TX.CSharpMethodToCppMethod(method.Name)); 58 | } 59 | } 60 | if (Model.StaticASyncMethods.Length > 0) { 61 | foreach(var method in Model.StaticASyncMethods) { 62 | @:func = Nan::GetFunction(Nan::New(@TX.CSharpMethodToCppMethod(method.Name))).ToLocalChecked(); 63 | @:Nan::Set(constructor, Nan::New("@(TX.Uncap(TX.CSharpMethodToCppMethod(method.Name)))").ToLocalChecked(), func); 64 | } 65 | } 66 | 67 | if(Model.StaticProperties.Length > 0) { 68 | foreach(var prop in Model.StaticProperties) { 69 | var propName = TX.Uncap(prop.Name); 70 | if (prop.GetSetMethod() != null) { 71 | @:Nan::SetAccessor(constructor, Nan::New("@(propName)").ToLocalChecked(), @(prop.Name)Getter, @(prop.Name)Setter); 72 | } else { 73 | @:Nan::SetAccessor(constructor, Nan::New("@(propName)").ToLocalChecked(), @(prop.Name)Getter); 74 | } 75 | } 76 | } 77 | 78 | if (Model.HasStaticEvents) { 79 | @: 80 | if (!Model.HasMemberEvents) { 81 | @:Local addListenerFunc = Nan::GetFunction(Nan::New(AddListener)).ToLocalChecked(); 82 | @:Nan::Set(constructor, Nan::New("addListener").ToLocalChecked(), addListenerFunc); 83 | @:Nan::Set(constructor, Nan::New("on").ToLocalChecked(), addListenerFunc); 84 | } 85 | 86 | if (!Model.HasMemberEvents) { 87 | @:Local removeListenerFunc = Nan::GetFunction(Nan::New(RemoveListener)).ToLocalChecked(); 88 | @:Nan::Set(constructor, Nan::New("removeListener").ToLocalChecked(), removeListenerFunc); 89 | @:Nan::Set(constructor, Nan::New("off").ToLocalChecked(), removeListenerFunc); 90 | } 91 | } 92 | } 93 | 94 | Nan::Set(exports, Nan::New("@(Model.Name)").ToLocalChecked(), constructor); 95 | } -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/StaticAsyncMethod.cpp: -------------------------------------------------------------------------------- 1 | 2 | static void @(Model.Name)(Nan::NAN_METHOD_ARGS_TYPE info) { 3 | HandleScope scope; 4 | 5 | if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) { 6 | Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given"))); 7 | return; 8 | } 9 | 10 | @TX.ToWinRT(Model.Overloads[0].ReturnType) op; 11 | 12 | @{int c = 0;} 13 | @foreach(var overload in Model.Overloads) { 14 | int i = 0; 15 | var elseString = ""; 16 | if (c > 0) { 17 | elseString = "else "; 18 | } 19 | @:@(elseString)if (info.Length() == @(overload.GetParameters().Length+1)@{if (overload.GetParameters().Length==0)@(")")} 20 | 21 | foreach (var paramInfo in overload.GetParameters()) { 22 | @:&& @(String.Format(Converter.TypeCheck(paramInfo.ParameterType, TX.MainModel.Types.ContainsKey(paramInfo.ParameterType)), "info[" + i.ToString() + "]"))@{if (overload.GetParameters().Length==(i+1)) @(")")} 23 | i++; 24 | } 25 | @:{ 26 | @:try 27 | @:{ 28 | int parameterCounter = 0; 29 | foreach (var paramInfo in overload.GetParameters()) 30 | { 31 | var winrtConversionInfo = Converter.ToWinRT(paramInfo.ParameterType, TX.MainModel.Types.ContainsKey(paramInfo.ParameterType)); 32 | 33 | @:@(winrtConversionInfo[0]) arg@(parameterCounter) = @(string.Format(winrtConversionInfo[1], "info[" +parameterCounter + "]" )); 34 | parameterCounter++; 35 | } 36 | 37 | if (overload.GetParameters().Length > 0) { 38 | @: 39 | } 40 | @:op = @TX.ToWinRT(Model.Overloads[0].DeclaringType, false)::@(overload.Name)(@{int j=0;foreach(var paramInfo in overload.GetParameters()){if(j>0)@(","); @("arg" + j.ToString()); j++;}}); 41 | @:} catch (Platform::Exception ^exception) { 42 | @:NodeRT::Utils::ThrowWinRtExceptionInJs(exception); 43 | @:return; 44 | @:} 45 | @:} 46 | c++; 47 | } else { 48 | Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); 49 | return; 50 | } 51 | 52 | auto opTask = create_task(op); 53 | uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As()); 54 | @{ 55 | System.Reflection.MethodInfo[] returnTypeMethods = Model.Overloads[0].ReturnType.GetMethods(); 56 | Type taskReturnType = returnTypeMethods.Where((methodInfo) => { return (methodInfo.Name == "GetResults"); }).First().ReturnType; 57 | string taskGenericType = TX.ToWinRT(taskReturnType); 58 | } 59 | opTask.then( [asyncToken] (task<@(taskGenericType)> t) 60 | { 61 | try { 62 | @{ 63 | if (taskReturnType != typeof(void)) 64 | { 65 | @:auto result = t.get(); 66 | @:NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) { 67 | } 68 | else 69 | { 70 | @:t.get(); 71 | @:NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) { 72 | } 73 | } 74 | 75 | @{ 76 | if (taskReturnType == typeof(void)) { 77 | @:Local args[] = {Undefined()}; 78 | } else { 79 | var jsConversionInfo = Converter.ToJS(taskReturnType, TX.MainModel.Types.ContainsKey(taskReturnType)); 80 | 81 | @:Local error; 82 | @:Local arg1; 83 | 84 | @:{ 85 | @:TryCatch tryCatch; 86 | @:arg1 = @string.Format(jsConversionInfo[1], "result"); 87 | 88 | @:if (tryCatch.HasCaught()) 89 | @:{ 90 | @: error = Nan::To(tryCatch.Exception()).ToLocalChecked(); 91 | @:} 92 | @:else 93 | @:{ 94 | @: error = Undefined(); 95 | @:} 96 | 97 | @:if (arg1.IsEmpty()) arg1 = Undefined(); 98 | @:} 99 | 100 | @:Local args[] = {error, arg1}; 101 | } 102 | } 103 | 104 | invokeCallback(_countof(args), args); 105 | }); 106 | } 107 | catch (Platform::Exception^ exception) 108 | { 109 | NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) { 110 | 111 | Local error = NodeRT::Utils::WinRtExceptionToJsError(exception); 112 | 113 | Local args[] = {error}; 114 | invokeCallback(_countof(args), args); 115 | }); 116 | } 117 | }); 118 | } 119 | -------------------------------------------------------------------------------- /src/NodeRTLib/NodeRTProjectBuildUtils.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) The NodeRT Contributors 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the ""License""); you may 5 | // not use this file except in compliance with the License. You may obtain a 6 | // copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS 9 | // OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY 10 | // IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing permissions 14 | // and limitations under the License. 15 | 16 | using System; 17 | using System.Diagnostics; 18 | 19 | namespace NodeRTLib 20 | { 21 | // Provides helper methods for compiling the genrated projects and copying the needed files for a package to an output directory 22 | public class NodeRTProjectBuildUtils 23 | { 24 | private const string NODE_GYP_CMD_TEMPLATE = "\"cd \"{0}\" & npm install --ignore-scripts & node-gyp rebuild --msvs_version={1}\""; 25 | 26 | // Builds the given project/sln for the given platforms and copies the output & package file to the output directory 27 | public static void BuildWithNodeGyp(string moduleDirectory, VsVersions vsVersion, bool verbose = false) 28 | { 29 | BuildModule(moduleDirectory, vsVersion, verbose); 30 | } 31 | 32 | private static string CreateBuildCmd(string moduleDirectory, VsVersions vsVersion) 33 | { 34 | string versionString; 35 | 36 | switch (vsVersion) 37 | { 38 | case VsVersions.Vs2012: 39 | versionString = "2012"; 40 | break; 41 | case VsVersions.Vs2013: 42 | versionString = "2013"; 43 | break; 44 | case VsVersions.Vs2015: 45 | versionString = "2015"; 46 | break; 47 | case VsVersions.Vs2017: 48 | versionString = "2017"; 49 | break; 50 | case VsVersions.Vs2019: 51 | versionString = "2019"; 52 | break; 53 | case VsVersions.Vs2022: 54 | versionString = "2022"; 55 | break; 56 | default: 57 | throw new Exception("Unknown VS Version"); 58 | } 59 | return String.Format(NODE_GYP_CMD_TEMPLATE, moduleDirectory, versionString); 60 | } 61 | 62 | private static void BuildModule(string moduleDirectory, VsVersions vsVersion, bool verbose) 63 | { 64 | string cmd = CreateBuildCmd(moduleDirectory, vsVersion); 65 | bool result = ExecuteCommand(cmd, verbose); 66 | 67 | if (!result) 68 | throw new Exception("Failed to build project"); 69 | } 70 | 71 | private static bool ExecuteCommand(string cmd, bool verbose) 72 | { 73 | Process process = new Process(); 74 | process.StartInfo.FileName = "cmd.exe"; 75 | process.StartInfo.Arguments = "/c " + cmd; 76 | process.StartInfo.CreateNoWindow = true; 77 | process.StartInfo.UseShellExecute = false; 78 | process.StartInfo.LoadUserProfile = true; 79 | 80 | if (process.StartInfo.EnvironmentVariables.ContainsKey("VisualStudioDir")) 81 | process.StartInfo.EnvironmentVariables.Remove("VisualStudioDir"); 82 | if (process.StartInfo.EnvironmentVariables.ContainsKey("VisualStudioEdition")) 83 | process.StartInfo.EnvironmentVariables.Remove("VisualStudioEdition"); 84 | if (process.StartInfo.EnvironmentVariables.ContainsKey("VisualStudioVersion")) 85 | process.StartInfo.EnvironmentVariables.Remove("VisualStudioVersion"); 86 | 87 | if (verbose) 88 | { 89 | process.StartInfo.RedirectStandardOutput = true; 90 | process.StartInfo.RedirectStandardError = true; 91 | 92 | Action actionWrite = (sender, e) => 93 | { 94 | Console.WriteLine(e.Data); 95 | }; 96 | 97 | process.ErrorDataReceived += (sender, e) => actionWrite(sender, e); 98 | process.OutputDataReceived += (sender, e) => actionWrite(sender, e); 99 | } 100 | 101 | process.Start(); 102 | 103 | if (verbose) 104 | { 105 | process.BeginOutputReadLine(); 106 | process.BeginErrorReadLine(); 107 | } 108 | 109 | process.WaitForExit(); 110 | bool success = (process.ExitCode == 0); 111 | 112 | process.Close(); 113 | 114 | return success; 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/MemberAsyncMethod.cpp: -------------------------------------------------------------------------------- 1 | static void @(Model.Name)(Nan::NAN_METHOD_ARGS_TYPE info) { 2 | HandleScope scope; 3 | 4 | if (!NodeRT::Utils::IsWinRtWrapperOf<@(TX.ToWinRT(Model.Overloads[0].DeclaringType,true))>(info.This())) { 5 | return; 6 | } 7 | 8 | if (info.Length() == 0 || !info[info.Length() -1]->IsFunction()) { 9 | Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: No callback was given"))); 10 | return; 11 | } 12 | 13 | @(Model.Overloads[0].DeclaringType.Name) *wrapper = @(Model.Overloads[0].DeclaringType.Name)::Unwrap<@(Model.Overloads[0].DeclaringType.Name)>(info.This()); 14 | 15 | @TX.ToWinRT(Model.Overloads[0].ReturnType) op; 16 | 17 | @{int c = 0;} 18 | @foreach(var overload in Model.Overloads) { 19 | int i = 0; 20 | var elseString = ""; 21 | 22 | if (c > 0) { 23 | elseString = "else "; 24 | } 25 | @:@(elseString)if (info.Length() == @(overload.GetParameters().Length+1)@{if (overload.GetParameters().Length==0)@(")")} 26 | 27 | foreach (var paramInfo in overload.GetParameters()) { 28 | @:&& @(String.Format(Converter.TypeCheck(paramInfo.ParameterType, TX.MainModel.Types.ContainsKey(paramInfo.ParameterType)), "info[" + i.ToString() + "]"))@{if (overload.GetParameters().Length==(i+1)) @(")")} 29 | i++; 30 | } 31 | @:{ 32 | @:try 33 | @:{ 34 | int parameterCounter = 0; 35 | foreach (var paramInfo in overload.GetParameters()) 36 | { 37 | var winrtConversionInfo = Converter.ToWinRT(paramInfo.ParameterType, TX.MainModel.Types.ContainsKey(paramInfo.ParameterType)); 38 | 39 | @:@(winrtConversionInfo[0]) arg@(parameterCounter) = @(string.Format(winrtConversionInfo[1], "info[" +parameterCounter + "]" )); 40 | parameterCounter++; 41 | } 42 | 43 | if (overload.GetParameters().Length > 0) 44 | { 45 | @: 46 | } 47 | @:op = wrapper->_instance->@(overload.Name)(@{int j=0;foreach(var paramInfo in overload.GetParameters()){if(j>0)@(","); @("arg" + j.ToString()); j++;}}); 48 | @:} 49 | @:catch (Platform::Exception ^exception) 50 | @:{ 51 | @:NodeRT::Utils::ThrowWinRtExceptionInJs(exception); 52 | @:return; 53 | @:} 54 | @:} 55 | c++; 56 | } else { 57 | Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); 58 | return; 59 | } 60 | 61 | auto opTask = create_task(op); 62 | uv_async_t* asyncToken = NodeUtils::Async::GetAsyncToken(info[info.Length() -1].As()); 63 | @{ 64 | System.Reflection.MethodInfo[] returnTypeMethods = Model.Overloads[0].ReturnType.GetMethods(); 65 | Type taskReturnType = returnTypeMethods.Where((methodInfo) => { return (methodInfo.Name == "GetResults"); }).First().ReturnType; 66 | string taskGenericType = TX.ToWinRT(taskReturnType); 67 | } 68 | opTask.then( [asyncToken] (task<@(taskGenericType)> t) { 69 | try { 70 | @{ 71 | if (taskReturnType != typeof(void)) 72 | { 73 | @:auto result = t.get(); 74 | @:NodeUtils::Async::RunCallbackOnMain(asyncToken, [result](NodeUtils::InvokeCallbackDelegate invokeCallback) { 75 | } 76 | else 77 | { 78 | @:t.get(); 79 | @:NodeUtils::Async::RunCallbackOnMain(asyncToken, [](NodeUtils::InvokeCallbackDelegate invokeCallback) { 80 | } 81 | } 82 | 83 | @{ 84 | if (taskReturnType == typeof(void)) { 85 | @:Local args[] = {Undefined()}; 86 | } else { 87 | var jsConversionInfo = Converter.ToJS(taskReturnType, TX.MainModel.Types.ContainsKey(taskReturnType)); 88 | 89 | @:Local error; 90 | @:Local arg1; 91 | 92 | @:{ 93 | @:TryCatch tryCatch; 94 | @:arg1 = @string.Format(jsConversionInfo[1], "result"); 95 | 96 | @:if (tryCatch.HasCaught()) 97 | @:{ 98 | @: error = Nan::To(tryCatch.Exception()).ToLocalChecked(); 99 | @:} 100 | @:else 101 | @:{ 102 | @: error = Undefined(); 103 | @:} 104 | 105 | @:if (arg1.IsEmpty()) arg1 = Undefined(); 106 | @:} 107 | 108 | @:Local args[] = {error, arg1}; 109 | } 110 | } 111 | 112 | invokeCallback(_countof(args), args); 113 | }); 114 | } catch (Platform::Exception^ exception) { 115 | NodeUtils::Async::RunCallbackOnMain(asyncToken, [exception](NodeUtils::InvokeCallbackDelegate invokeCallback) { 116 | Local error = NodeRT::Utils::WinRtExceptionToJsError(exception); 117 | 118 | Local args[] = {error}; 119 | invokeCallback(_countof(args), args); 120 | }); 121 | } 122 | }); 123 | } 124 | -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/StaticSyncMethod.cpp: -------------------------------------------------------------------------------- 1 | 2 | static void @(TX.CSharpMethodToCppMethod(Model.Name))(Nan::NAN_METHOD_ARGS_TYPE info) { 3 | HandleScope scope; 4 | @{int c = 0;} 5 | @foreach(var overload in Model.Overloads) 6 | { 7 | int i = 0; 8 | var elseString = ""; 9 | if (c > 0) { 10 | elseString = "else "; 11 | } 12 | var inParamsCount = 0; 13 | bool methodHasOutParams = false; 14 | foreach (var paramInfo in overload.GetParameters()) 15 | { 16 | if (!paramInfo.IsOut) 17 | inParamsCount++; 18 | else 19 | methodHasOutParams = true; 20 | } 21 | @:@(elseString)if (info.Length() == @(inParamsCount)@{if (inParamsCount==0)@(")")} 22 | 23 | foreach (var paramInfo in overload.GetParameters()) { 24 | if (paramInfo.IsOut) 25 | continue; 26 | @:&& @(String.Format(Converter.TypeCheck(paramInfo.ParameterType, TX.MainModel.Types.ContainsKey(paramInfo.ParameterType)), "info[" + i.ToString() + "]"))@{if (inParamsCount==(i+1)) @(")")} 27 | i++; 28 | } 29 | @:{ 30 | @:try 31 | @:{ 32 | int parameterCounter = 0; 33 | foreach (var paramInfo in overload.GetParameters()) 34 | { 35 | var winrtConversionInfo = Converter.ToWinRT(paramInfo.ParameterType, TX.MainModel.Types.ContainsKey(paramInfo.ParameterType)); 36 | 37 | if (paramInfo.ParameterType.IsByRef) { 38 | winrtConversionInfo = Converter.ToWinRT(paramInfo.ParameterType.GetElementType(), TX.MainModel.Types.ContainsKey(paramInfo.ParameterType.GetElementType())); 39 | } 40 | 41 | if (paramInfo.IsOut) { 42 | if (paramInfo.ParameterType.IsArray) { 43 | @:#error please initialize array below with ...=ref new ::Platform::Array<...>(size); 44 | } 45 | @:@(winrtConversionInfo[0]) arg@(parameterCounter); @if (paramInfo.ParameterType.IsArray) {@("// = ref new ::Platform::Array<" + TX.ToWinRT(paramInfo.ParameterType.GetElementType()) + ">(size);")} 46 | } else { 47 | @:@(winrtConversionInfo[0]) arg@(parameterCounter) = @(string.Format(winrtConversionInfo[1], "info[" +parameterCounter + "]" )); 48 | } 49 | parameterCounter++; 50 | } 51 | 52 | if (overload.GetParameters().Length > 0) { 53 | @: 54 | } 55 | if (Model.Overloads[0].ReturnType == typeof(void)) { 56 | @:@(TX.ToWinRT(Model.Overloads[0].DeclaringType, false))::@(TX.CSharpMethodToCppMethod(overload.Name))(@{int j=0;foreach(var paramInfo in overload.GetParameters()){if(j>0)@(", "); if (paramInfo.ParameterType.IsByRef){@("&")} @("arg" + j.ToString()); j++;}}); 57 | } else { 58 | var winrtConversionInfo = Converter.ToWinRT(overload.ReturnType, TX.MainModel.Types.ContainsKey(overload.ReturnType)); 59 | @:@(winrtConversionInfo[0]) result; 60 | var jsConversionInfo = Converter.ToJS(overload.ReturnType, TX.MainModel.Types.ContainsKey(overload.ReturnType)); 61 | @:result = @(TX.ToWinRT(overload.DeclaringType, false))::@(TX.CSharpMethodToCppMethod(overload.Name))(@{int j=0;foreach(var paramInfo in overload.GetParameters()){if(j>0)@(", "); if (paramInfo.ParameterType.IsByRef){@("&")} @("arg" + j.ToString()); j++;}}); 62 | } 63 | 64 | if (methodHasOutParams) 65 | { 66 | @:Local resObj = Nan::New(); 67 | 68 | if (Model.Overloads[0].ReturnType != typeof(void)) 69 | { 70 | var jsConversionInfo = Converter.ToJS(overload.ReturnType, TX.MainModel.Types.ContainsKey(overload.ReturnType)); 71 | 72 | @:Nan::Set(resObj, Nan::New("@(Converter.ToOutParameterName(overload.ReturnType))").ToLocalChecked(), @(string.Format(jsConversionInfo[1], "result"))); 73 | } 74 | parameterCounter = 0; 75 | foreach (var paramInfo in overload.GetParameters()) 76 | { 77 | if (paramInfo.IsOut) 78 | { 79 | var paramJsConversionInfo = Converter.ToJS(paramInfo.ParameterType, TX.MainModel.Types.ContainsKey(paramInfo.ParameterType)); 80 | @:Nan::Set(resObj, Nan::New("@(paramInfo.Name)").ToLocalChecked(), @(string.Format(paramJsConversionInfo[1], "arg" + parameterCounter.ToString()))); 81 | } 82 | parameterCounter++; 83 | } 84 | 85 | @:info.GetReturnValue().Set(resObj); 86 | @:return; 87 | } else { 88 | if (Model.Overloads[0].ReturnType != typeof(void)) { 89 | var jsConversionInfo = Converter.ToJS(Model.Overloads[0].ReturnType, TX.MainModel.Types.ContainsKey(Model.Overloads[0].ReturnType)); 90 | @:info.GetReturnValue().Set(@string.Format(jsConversionInfo[1], "result")); 91 | @:return; 92 | } else { 93 | @:return; 94 | } 95 | } 96 | 97 | @:} 98 | @:catch (Platform::Exception ^exception) 99 | @:{ 100 | @:NodeRT::Utils::ThrowWinRtExceptionInJs(exception); 101 | @:return; 102 | @:} 103 | @:} 104 | c++; 105 | } else { 106 | Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); 107 | return; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/NodeRTLib/ProjectFiles/NodeRtUtils.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) The NodeRT Contributors 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the ""License""); you may 5 | // not use this file except in compliance with the License. You may obtain a 6 | // copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS 9 | // OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY 10 | // IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing 14 | // permissions and limitations under the License. 15 | 16 | #pragma once 17 | 18 | #include 19 | #include "nan.h" 20 | 21 | #define WCHART_NOT_BUILTIN_IN_NODE 1 22 | 23 | namespace NodeRT { 24 | namespace Utils { 25 | 26 | v8::Local WinRtExceptionToJsError(Platform::Exception ^ exception); 27 | 28 | void ThrowWinRtExceptionInJs(Platform::Exception ^ exception); 29 | 30 | // creates an object with the following structure: 31 | // { 32 | // "callback" : [callback function] 33 | // "domain" : [the domain in which the async function/event was 34 | // called/registered] (this is optional) 35 | // } 36 | v8::Local CreateCallbackObjectInDomain( 37 | v8::Local callback); 38 | 39 | // Calls the callback in the appropriate domwin, expects an object in the 40 | // following format: 41 | // { 42 | // "callback" : [callback fuction] 43 | // "domain" : [the domain in which the async function/event was 44 | // called/registered] (this is optional) 45 | // } 46 | v8::Local CallCallbackInDomain(v8::Local callbackObject, 47 | int argc, 48 | v8::Local argv[]); 49 | 50 | v8::Local NewString(const wchar_t* str); 51 | 52 | const wchar_t* StringToWchar(v8::String::Value& str); 53 | 54 | ::Platform::String ^ V8StringToPlatformString(v8::Local value); 55 | 56 | #ifdef WCHART_NOT_BUILTIN_IN_NODE 57 | // compares 2 strings using a case insensitive comparison 58 | bool CaseInsenstiveEquals(const wchar_t* str1, const uint16_t* str2); 59 | #endif 60 | 61 | // compares 2 strings using a case insensitive comparison 62 | bool CaseInsenstiveEquals(const wchar_t* str1, const wchar_t* str2); 63 | 64 | // registers the namespace & required object on the global object 65 | void RegisterNameSpace(const char* ns, v8::Local nsExports); 66 | 67 | v8::Local CreateExternalWinRTObject(const char* ns, 68 | const char* objectName, 69 | ::Platform::Object ^ instance); 70 | 71 | bool IsWinRtWrapper(v8::Local value); 72 | 73 | template 74 | bool IsWinRtWrapperOf(v8::Local value) { 75 | if (!IsWinRtWrapper(value)) { 76 | return false; 77 | } 78 | 79 | if (value->IsNull()) { 80 | return true; 81 | } 82 | 83 | WrapperBase* wrapper = 84 | Nan::ObjectWrap::Unwrap(value.As()); 85 | 86 | if (wrapper->GetObjectInstance() == nullptr) { 87 | return false; 88 | } 89 | 90 | try { 91 | T instance = dynamic_cast(wrapper->GetObjectInstance()); 92 | return (instance != nullptr); 93 | } catch (...) { 94 | return false; 95 | } 96 | } 97 | 98 | ::Platform::Object ^ GetObjectInstance(v8::Local value); 99 | 100 | void SetHiddenValue(v8::Local obj, 101 | v8::Local symbol, 102 | v8::Local data); 103 | void SetHiddenValueWithObject(v8::Local obj, 104 | v8::Local symbol, 105 | v8::Local data); 106 | v8::Local GetHiddenValue(v8::Local obj, 107 | v8::Local symbol); 108 | 109 | v8::Local DateTimeToJS(::Windows::Foundation::DateTime value); 110 | ::Windows::Foundation::TimeSpan TimeSpanFromMilli(int64_t millis); 111 | ::Windows::Foundation::DateTime DateTimeFromJSDate(v8::Local value); 112 | 113 | bool IsGuid(v8::Local value); 114 | ::Platform::Guid GuidFromJs(v8::Local value); 115 | v8::Local GuidToJs(::Platform::Guid guid); 116 | 117 | v8::Local ColorToJs(::Windows::UI::Color color); 118 | ::Windows::UI::Color ColorFromJs(v8::Local value); 119 | bool IsColor(v8::Local value); 120 | 121 | v8::Local RectToJs(::Windows::Foundation::Rect rect); 122 | ::Windows::Foundation::Rect RectFromJs(v8::Local value); 123 | bool IsRect(v8::Local value); 124 | 125 | v8::Local PointToJs(::Windows::Foundation::Point point); 126 | ::Windows::Foundation::Point PointFromJs(v8::Local value); 127 | bool IsPoint(v8::Local value); 128 | 129 | v8::Local SizeToJs(::Windows::Foundation::Size size); 130 | ::Windows::Foundation::Size SizeFromJs(v8::Local value); 131 | bool IsSize(v8::Local value); 132 | 133 | wchar_t GetFirstChar(v8::Local value); 134 | v8::Local JsStringFromChar(wchar_t value); 135 | 136 | ::Windows::Foundation::HResult HResultFromJsInt32(int32_t value); 137 | 138 | } // namespace Utils 139 | } // namespace NodeRT -------------------------------------------------------------------------------- /src/NodeRTUI/Properties/Resources.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/MemberSyncMethod.cpp: -------------------------------------------------------------------------------- 1 | static void @(TX.CSharpMethodToCppMethod(Model.Name))(Nan::NAN_METHOD_ARGS_TYPE info) { 2 | HandleScope scope; 3 | 4 | if (!NodeRT::Utils::IsWinRtWrapperOf<@(TX.ToWinRT(Model.Overloads[0].DeclaringType,true))>(info.This())) { 5 | return; 6 | } 7 | 8 | @(Model.Overloads[0].DeclaringType.Name) *wrapper = @(Model.Overloads[0].DeclaringType.Name)::Unwrap<@(Model.Overloads[0].DeclaringType.Name)>(info.This()); 9 | @{int c = 0;} 10 | @foreach(var overload in Model.Overloads) 11 | { 12 | int i = 0; 13 | var elseString = ""; 14 | if (c > 0) { 15 | elseString = "else "; 16 | } 17 | var inParamsCount = 0; 18 | bool methodHasOutParams = false; 19 | foreach (var paramInfo in overload.GetParameters()) 20 | { 21 | if (!paramInfo.IsOut) 22 | inParamsCount++; 23 | else 24 | methodHasOutParams = true; 25 | } 26 | @:@(elseString)if (info.Length() == @(inParamsCount)@{if (inParamsCount==0)@(")")} 27 | 28 | foreach (var paramInfo in overload.GetParameters()) 29 | { 30 | if (paramInfo.IsOut) 31 | continue; 32 | @:&& @(String.Format(Converter.TypeCheck(paramInfo.ParameterType, TX.MainModel.Types.ContainsKey(paramInfo.ParameterType)), "info[" + i.ToString() + "]"))@{if (inParamsCount==(i+1)) @(")")} 33 | i++; 34 | } 35 | @:{ 36 | @:try 37 | @:{ 38 | int parameterCounter = 0; 39 | foreach (var paramInfo in overload.GetParameters()) 40 | { 41 | var winrtConversionInfo = Converter.ToWinRT(paramInfo.ParameterType, TX.MainModel.Types.ContainsKey(paramInfo.ParameterType)); 42 | 43 | if (paramInfo.ParameterType.IsByRef) { 44 | winrtConversionInfo = Converter.ToWinRT(paramInfo.ParameterType.GetElementType(), TX.MainModel.Types.ContainsKey(paramInfo.ParameterType.GetElementType())); 45 | } 46 | 47 | if (paramInfo.IsOut) { 48 | if (paramInfo.ParameterType.IsArray) { 49 | string sizeStr; 50 | if (TX.IsArrayAsOut(overload, out sizeStr)) { 51 | @:@(winrtConversionInfo[0]) arg@(parameterCounter) = ref new ::Platform::Array<@(TX.ToWinRT(paramInfo.ParameterType.GetElementType()))>(@(sizeStr)); 52 | } else { 53 | @:#error please initialize array below with ...=ref new ::Platform::Array<...>(size); 54 | @:@(winrtConversionInfo[0]) arg@(parameterCounter); @if (paramInfo.ParameterType.IsArray) {@("// = ref new ::Platform::Array<" + TX.ToWinRT(paramInfo.ParameterType.GetElementType()) + ">(size);")} 55 | } 56 | } else { 57 | @:@(winrtConversionInfo[0]) arg@(parameterCounter); 58 | } 59 | } else { 60 | @:@(winrtConversionInfo[0]) arg@(parameterCounter) = @(string.Format(winrtConversionInfo[1], "info[" +parameterCounter + "]" )); 61 | } 62 | parameterCounter++; 63 | } 64 | 65 | if (overload.GetParameters().Length > 0) { 66 | @: 67 | } 68 | if (overload.ReturnType == typeof(void)) { 69 | @:wrapper->_instance->@(TX.CSharpMethodToCppMethod(overload.Name))(@{int j=0;foreach(var paramInfo in overload.GetParameters()){if(j>0)@(", "); if (paramInfo.ParameterType.IsByRef){@("&")} @("arg" + j.ToString()); j++;}}); 70 | } else { 71 | var winrtConversionInfo = Converter.ToWinRT(overload.ReturnType, TX.MainModel.Types.ContainsKey(overload.ReturnType)); 72 | @:@(winrtConversionInfo[0]) result; 73 | var jsConversionInfo = Converter.ToJS(overload.ReturnType, TX.MainModel.Types.ContainsKey(overload.ReturnType)); 74 | @:result = wrapper->_instance->@(TX.CSharpMethodToCppMethod(overload.Name))(@{int j=0;foreach(var paramInfo in overload.GetParameters()){if(j>0)@(", "); if (paramInfo.IsOut && paramInfo.ParameterType.IsByRef){@("&")} @("arg" + j.ToString()); j++;}}); 75 | } 76 | 77 | if (methodHasOutParams) { 78 | @:Local resObj = Nan::New(); 79 | 80 | if (Model.Overloads[0].ReturnType != typeof(void)) { 81 | var jsConversionInfo = Converter.ToJS(overload.ReturnType, TX.MainModel.Types.ContainsKey(overload.ReturnType)); 82 | 83 | @:Nan::Set(resObj, Nan::New("@(Converter.ToOutParameterName(overload.ReturnType))").ToLocalChecked(), @(string.Format(jsConversionInfo[1], "result"))); 84 | } 85 | parameterCounter = 0; 86 | foreach (var paramInfo in overload.GetParameters()) { 87 | if (paramInfo.IsOut) { 88 | var paramJsConversionInfo = Converter.ToJS(paramInfo.ParameterType, TX.MainModel.Types.ContainsKey(paramInfo.ParameterType)); 89 | @:Nan::Set(resObj, Nan::New("@(paramInfo.Name)").ToLocalChecked(), @(string.Format(paramJsConversionInfo[1], "arg" + parameterCounter.ToString()))); 90 | } 91 | parameterCounter++; 92 | } 93 | 94 | @:info.GetReturnValue().Set(resObj); 95 | @:return; 96 | } else { 97 | if (Model.Overloads[0].ReturnType != typeof(void)) { 98 | var jsConversionInfo = Converter.ToJS(Model.Overloads[0].ReturnType, TX.MainModel.Types.ContainsKey(Model.Overloads[0].ReturnType)); 99 | @:info.GetReturnValue().Set(@string.Format(jsConversionInfo[1], "result")); 100 | @:return; 101 | } 102 | else { 103 | @:return; 104 | } 105 | } 106 | 107 | @:} catch (Platform::Exception ^exception) { 108 | @:NodeRT::Utils::ThrowWinRtExceptionInJs(exception); 109 | @:return; 110 | @:} 111 | @:} 112 | c++; 113 | } else { 114 | Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Bad arguments: no suitable overload found"))); 115 | return; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /src/NodeRTUI/NodeRTUI.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {E3C8CF58-6AA0-42F1-8363-835958CC6D2B} 8 | WinExe 9 | Properties 10 | NodeRTUI 11 | NodeRTGen 12 | NodeRTUI 13 | v4.8 14 | 512 15 | 16 | 17 | AnyCPU 18 | true 19 | full 20 | false 21 | bin\Debug\ 22 | DEBUG;TRACE 23 | prompt 24 | 4 25 | 26 | 27 | AnyCPU 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | nodert.ico 37 | 38 | 39 | 40 | 41 | 42 | 43 | False 44 | ..\packages\Rx-Core.2.1.30214.0\lib\Net45\System.Reactive.Core.dll 45 | 46 | 47 | False 48 | ..\packages\Rx-Interfaces.2.1.30214.0\lib\Net45\System.Reactive.Interfaces.dll 49 | 50 | 51 | False 52 | ..\packages\Rx-Linq.2.1.30214.0\lib\Net45\System.Reactive.Linq.dll 53 | 54 | 55 | False 56 | ..\packages\Rx-PlatformServices.2.1.30214.0\lib\Net45\System.Reactive.PlatformServices.dll 57 | 58 | 59 | False 60 | ..\packages\RazorTemplates.1.2.0\lib\System.Web.Razor.dll 61 | True 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | Form 75 | 76 | 77 | MainForm.cs 78 | 79 | 80 | 81 | 82 | MainForm.cs 83 | 84 | 85 | ResXFileCodeGenerator 86 | Resources.Designer.cs 87 | Designer 88 | 89 | 90 | True 91 | Resources.resx 92 | True 93 | 94 | 95 | 96 | SettingsSingleFileGenerator 97 | Settings.Designer.cs 98 | 99 | 100 | True 101 | Settings.settings 102 | True 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | {8b785e90-8642-41cc-9859-8fc0d2ab7d57} 114 | NodeRTLib 115 | 116 | 117 | 118 | 125 | -------------------------------------------------------------------------------- /MODULE_CREATION.md: -------------------------------------------------------------------------------- 1 | # :wrench: Creation of WinRT Modules 2 | 3 | NodeRT is a tool that automatically generates node.js Native add-on wrappers for UWP/WinRT APIs. 4 | 5 | NodeRT automatically exposes Microsoft’s UWP/WinRT APIs to the Node.js environment by generating Node modules. This enables Node.js developers to write code that consumes native Windows capabilities. The generated modules' APIs are (almost) the same as the UWP/WinRT APIs listed in MSDN. 6 | NodeRT can be used to generate Node modules both from command line (NodeRTCmd) and from its UI tool (NodeRTUI). NodeRT is developed and released by a group of Node.js enthusiasts at Microsoft. 7 | 8 | Here is an example of using NodeRT windows.devices.geolocation module to retrieve the current location: 9 | 10 | ```js 11 | const { Geolocator } = require('windows.devices.geolocation') 12 | const locator = new Geolocator() 13 | 14 | locator.getGeopositionAsync((error, result) => { 15 | if (error) { 16 | console.error(error) 17 | return 18 | } 19 | 20 | const { coordinate } = result 21 | const { longitude, latitude } = coordinate 22 | 23 | console.info(longitude, latitude) 24 | }) 25 | ``` 26 | 27 | ## Table of Contents 28 | 29 | * [NodeRT Prerequisites](#prerequisites) 30 | * [Generating a NodeRT module using the UI](#generating-a-nodert-module-using-the-ui) 31 | * [Generating a NodeRT module using the CLI](#generating-a-nodert-module-using-the-cli) 32 | 33 | ## Prerequisites 34 | 35 | 36 |

NodeRT Prerequisites

37 | First, in order to use WinRT you must be running on a Windows environment that supports WinRT - meaning Windows 10, Windows 8.1, Windows 8, or Windows Server 2012. 38 | 39 | In order to use NodeRT, make sure you have the following installed:
40 | * Visual Studio 2022 or 2019 for generating Windows 11 compatible modules
41 | * Visual Studio 2019, 2017, or 2015 for generating Windows 10 compatible modules
42 | * Visual Studio 2013 or 2012 for generating Windows 8.1/8 compatible modules respectively. 43 | * Windows SDK for the version of Windows your are using: 44 | - [Windows 10 SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk) 45 | - [Windows 8.1 SDK](https://developer.microsoft.com/en-us/windows/downloads/windows-8-1-sdk) 46 | - [Windows 8](https://developer.microsoft.com/en-us/windows/downloads/windows-8-sdk) 47 | * node.js (version > 8.*) - from nodejs.org
48 | * node-gyp - make sure to get the latest version from npm by running: 49 | ``` 50 | npm install -g node-gyp 51 | ``` 52 | 53 | Next, download the latest NodeRT release from here, or clone this repository to your machine and build the NodeRT solution using Visual Studio. 54 | 55 | ## Generating a NodeRT module using the UI 56 | 57 | First, launch the UI tool by running `NodeRTUI.exe`: 58 | 59 | ![Windows.Devices.Geolocation NodeRT module contents](/doc/images/nodert_screenshot.png) 60 | 61 | Then, follow this short list of steps in order to create a NodeRT module: 62 | 63 | * Choose a WinMD file:
64 | - For Windows 10 SDK:
65 | ``` 66 | c:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd 67 | ``` 68 | - For Windows 8.1 SDK:
69 | ``` 70 | c:\Program Files (x86)\Windows Kits\8.1\References\CommonConfiguration\Neutral\Windows.winmd 71 | ``` 72 | - For Windows 8.0 SDK:
73 | ``` 74 | c:\Program Files (x86)\Windows Kits\8.0\References\CommonConfiguration\Neutral\Windows.winmd 75 | ``` 76 | * Choose a namespace to generate from the list of namespaces.
77 | * Select whether you are generating a Windows 10 compatible module using VS 015, Windows 8.1 compatible module using VS2013 or a Windows 8.0 compatible module using VS2012.
78 | * Choose the output directory in which the module will be created, or just stick with the default ones. 79 | * You're good to go, hit the Generate & Build button! A message box with (hopefully) a success message should appear shortly. 80 | 81 | ## Generating a NodeRT module using the CLI 82 | 83 | If you prefer a command line interface, modules can be created with the `NodeRTCmd` tool. 84 | 85 | An example of generating the Windows.Devices.Geolocation namespace from the Windows 10 Windows.winmd: 86 | ``` 87 | NodeRTCmd.exe --winmd "c:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd" --outdir c:\NodeRT\output --namespace Windows.Devices.Geolocation 88 | ``` 89 | Note that omitting the --namespace option will generate all of the namespaces in the Winmd file. 90 | 91 | The following is the list of options that the tool supports: 92 | 93 | ```sh 94 | --winmd [path] File path to winmd file from which the module 95 | will be generated 96 | 97 | --namespaces Lists all of the namespaces in the winmd file 98 | (only needs --winmd) 99 | 100 | --namespace [namespace] The namespace to generate from the winmd when 101 | not specified , all namespaces will be generated 102 | 103 | --outdir [path] The output dir in which the compiled NodeRT module 104 | will be created in 105 | 106 | --vs [Vs2022|Vs2019|Vs2017|Vs2015|Vs2013|Vs2012] Optional, VS version to use, default is Vs2022 107 | 108 | --winver [10|8.1|8] Optional, Windows SDK version to use, default is 10 109 | 110 | --npmscope Optional, the scope that will be specified for the generated 111 | npm package 112 | 113 | --npmversion Optional, the version that will be specified for the generated 114 | npm package 115 | 116 | --nodefgen Optional, specifying this option will reult in 117 | skipping the generation of TypeScript and 118 | JavaScript definition files 119 | 120 | --nobuild Optional, specifying this option will result in 121 | skipping the build process for the NodeRT module 122 | 123 | --verbose Optional, specifying this option will result in 124 | verbose output for the module build operation 125 | 126 | --help Print this help screen 127 | 128 | ``` 129 | -------------------------------------------------------------------------------- /src/NodeRTLib/CppTemplates/Event.cpp: -------------------------------------------------------------------------------- 1 | static void AddListener(Nan::NAN_METHOD_ARGS_TYPE info) { 2 | HandleScope scope; 3 | 4 | if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { 5 | Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected arguments are eventName(string),callback(function)"))); 6 | return; 7 | } 8 | 9 | String::Value eventName(v8::Isolate::GetCurrent(), info[0]); 10 | auto str = *eventName; 11 | 12 | Local callback = info[1].As(); 13 | 14 | ::Windows::Foundation::EventRegistrationToken registrationToken; 15 | if (NodeRT::Utils::CaseInsenstiveEquals(L"@TX.Uncap(Model.Events[0].EventInfo.Name)", str)) 16 | { 17 | @if (!Model.Events[0].IsStatic) 18 | { 19 | @:if (!NodeRT::Utils::IsWinRtWrapperOf<@(TX.ToWinRT(Model.Type,true))>(info.This())) 20 | @:{ 21 | @: Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); 22 | @: return; 23 | @:} 24 | @:@(Model.Name) *wrapper = @(Model.Name)::Unwrap<@(Model.Name)>(info.This()); 25 | } 26 | @TX.CppTemplates.RegisterEventWithWinRT(Model.Events[0]) 27 | } 28 | @for(var i=1; i(info.This())) 34 | @:{ 35 | @: Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); 36 | @: return; 37 | @:} 38 | @:@(Model.Name) *wrapper = @(Model.Name)::Unwrap<@(Model.Name)>(info.This()); 39 | } 40 | @:@TX.CppTemplates.RegisterEventWithWinRT(Model.Events[i]) 41 | @:} 42 | } else { 43 | Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); 44 | return; 45 | } 46 | 47 | Local tokenMapVal = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); 48 | Local tokenMap; 49 | 50 | if (tokenMapVal.IsEmpty() || Nan::Equals(tokenMapVal, Undefined()).FromMaybe(false)) { 51 | tokenMap = Nan::New(); 52 | NodeRT::Utils::SetHiddenValueWithObject(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked(), tokenMap); 53 | } else { 54 | tokenMap = Nan::To(tokenMapVal).ToLocalChecked(); 55 | } 56 | 57 | Nan::Set(tokenMap, info[0], CreateOpaqueWrapper(::Windows::Foundation::PropertyValue::CreateInt64(registrationToken.Value))); 58 | } 59 | 60 | static void RemoveListener(Nan::NAN_METHOD_ARGS_TYPE info) { 61 | HandleScope scope; 62 | 63 | if (info.Length() < 2 || !info[0]->IsString() || !info[1]->IsFunction()) { 64 | Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"wrong arguments, expected a string and a callback"))); 65 | return; 66 | } 67 | 68 | String::Value eventName(v8::Isolate::GetCurrent(), info[0]); 69 | auto str = *eventName; 70 | 71 | if (@TX.ForEachEvent(Model.Events ,"(!NodeRT::Utils::CaseInsenstiveEquals(L\"{1}\", str)) &&", 3)) { 72 | Nan::ThrowError(Nan::Error(String::Concat(v8::Isolate::GetCurrent(), NodeRT::Utils::NewString(L"given event name isn't supported: "), info[0].As()))); 73 | return; 74 | } 75 | 76 | Local callback = info[1].As(); 77 | Local tokenMap = NodeRT::Utils::GetHiddenValue(callback, Nan::New(REGISTRATION_TOKEN_MAP_PROPERTY_NAME).ToLocalChecked()); 78 | 79 | if (tokenMap.IsEmpty() || Nan::Equals(tokenMap, Undefined()).FromMaybe(false)) { 80 | return; 81 | } 82 | 83 | Local opaqueWrapperObj = Nan::Get(Nan::To(tokenMap).ToLocalChecked(), info[0]).ToLocalChecked(); 84 | 85 | if (opaqueWrapperObj.IsEmpty() || Nan::Equals(opaqueWrapperObj,Undefined()).FromMaybe(false)) { 86 | return; 87 | } 88 | 89 | OpaqueWrapper *opaqueWrapper = OpaqueWrapper::Unwrap(opaqueWrapperObj.As()); 90 | 91 | long long tokenValue = (long long) opaqueWrapper->GetObjectInstance(); 92 | ::Windows::Foundation::EventRegistrationToken registrationToken; 93 | registrationToken.Value = tokenValue; 94 | 95 | try { 96 | if (NodeRT::Utils::CaseInsenstiveEquals(L"@TX.Uncap(Model.Events[0].EventInfo.Name)", str)) { 97 | @if (!Model.Events[0].IsStatic) 98 | { 99 | @:if (!NodeRT::Utils::IsWinRtWrapperOf<@(TX.ToWinRT(Model.Type,true))>(info.This())) 100 | @:{ 101 | @: Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); 102 | @: return; 103 | @:} 104 | @:@(Model.Name) *wrapper = @(Model.Name)::Unwrap<@(Model.Name)>(info.This()); 105 | @:wrapper->_instance->@(Model.Events[0].EventInfo.Name)::remove(registrationToken); 106 | } 107 | else 108 | { 109 | @:@(TX.ToWinRT(Model.Events[0].EventInfo.DeclaringType, false))::@(Model.Events[0].EventInfo.Name)::remove(registrationToken); 110 | } 111 | } 112 | @for(var i=1; i(info.This())) 118 | @:{ 119 | @: Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"The caller of this method isn't of the expected type or internal WinRt object was disposed"))); 120 | @: return; 121 | @:} 122 | @:@(Model.Name) *wrapper = @(Model.Name)::Unwrap<@(Model.Name)>(info.This()); 123 | @:wrapper->_instance->@(Model.Events[i].EventInfo.Name)::remove(registrationToken); 124 | } 125 | else 126 | { 127 | @:@(TX.ToWinRT(Model.Events[i].EventInfo.DeclaringType, false))::@(Model.Events[i].EventInfo.Name)::remove(registrationToken); 128 | } 129 | @:} 130 | } 131 | } catch (Platform::Exception ^exception) { 132 | NodeRT::Utils::ThrowWinRtExceptionInJs(exception); 133 | } 134 | 135 | Nan::Delete(Nan::To(tokenMap).ToLocalChecked(), Nan::To(info[0]).ToLocalChecked()); 136 | } 137 | -------------------------------------------------------------------------------- /src/NodeRTLib/ExternalTypesHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) The NodeRT Contributors 2 | // All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the ""License""); you may 5 | // not use this file except in compliance with the License. You may obtain a 6 | // copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | // 8 | // THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS 9 | // OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY 10 | // IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 11 | // MERCHANTABLITY OR NON-INFRINGEMENT. 12 | // 13 | // See the Apache Version 2.0 License for specific language governing permissions 14 | // and limitations under the License. 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using System.Linq; 19 | using System.Reflection; 20 | 21 | namespace NodeRTLib 22 | { 23 | // a helper utility class used for fetching value types which are used by the types in the namespace 24 | // but are not part of the current namespace 25 | class ExternalTypesHelper 26 | { 27 | static List ExcludedExternalNamespaces = new List() 28 | { 29 | "System", 30 | "System.Collections", 31 | "Platform", 32 | "Windows.Foundation.Collections" 33 | }; 34 | 35 | public static bool IsValueTypeNoEnumOrPrimitve(Type type) 36 | { 37 | return type.IsValueType && !type.IsEnum && !type.IsPrimitive && type.Namespace != "System"; 38 | } 39 | 40 | public static void TestAndAddRecursive(Type type, String declaringTypeNamespace, List valueTypes, List namespaces) 41 | { 42 | if (type.IsGenericType) 43 | { 44 | if (type.GetGenericArguments() != null) 45 | { 46 | foreach (var genericArg in type.GetGenericArguments()) 47 | { 48 | TestAndAddRecursive(genericArg, declaringTypeNamespace, valueTypes, namespaces); 49 | } 50 | } 51 | return; 52 | } 53 | 54 | if (IsValueTypeNoEnumOrPrimitve(type) && !valueTypes.Contains(type) && 55 | type.Namespace != "System" && type.Namespace != declaringTypeNamespace) 56 | { 57 | valueTypes.Add(type); 58 | } 59 | 60 | if (!IsValueTypeNoEnumOrPrimitve(type) && type.Namespace != declaringTypeNamespace) 61 | { 62 | if (!ExcludedExternalNamespaces.Contains(type.Namespace) && !namespaces.Contains(type.Namespace)) 63 | { 64 | namespaces.Add(type.Namespace); 65 | } 66 | else if (type.Namespace == "System" && type.Name == "Uri" && !namespaces.Contains("Windows.Foundation")) // Uri is special.. 67 | { 68 | namespaces.Add("Windows.Foundation"); 69 | } 70 | } 71 | } 72 | 73 | public static void TestAndAddNamespaceRecursive(Type type, List namespaces, String declaringTypeNamespace) 74 | { 75 | if (type.IsGenericType) 76 | { 77 | if (type.GetGenericArguments() != null) 78 | { 79 | foreach (var genericArg in type.GetGenericArguments()) 80 | { 81 | TestAndAddNamespaceRecursive(genericArg, namespaces, declaringTypeNamespace); 82 | } 83 | } 84 | } 85 | else if (type.Namespace != declaringTypeNamespace && !ExcludedExternalNamespaces.Contains(type.Namespace)) 86 | { 87 | namespaces.Add(type.Namespace); 88 | } 89 | } 90 | 91 | public static void GetExternalReferencedData(EventInfo info, List types, List namespaces) 92 | { 93 | var invokeMethodInfo = info.EventHandlerType.GetMethods().Where((methodInfo) => { return (methodInfo.Name == "Invoke"); }).First(); 94 | 95 | GetExternalReferencedData(invokeMethodInfo.GetParameters(), info.DeclaringType.Namespace, types, namespaces); 96 | } 97 | 98 | public static void GetExternalReferencedData(ParameterInfo[] info, string declaringNamespace, List types, List namespaces) 99 | { 100 | foreach (var param in info) 101 | { 102 | TestAndAddRecursive(param.ParameterType, declaringNamespace, types, namespaces); 103 | } 104 | } 105 | 106 | public static void GetExternalReferencedData(MethodInfo info, List types, List namespaces) 107 | { 108 | TestAndAddRecursive(info.ReturnType, info.DeclaringType.Namespace, types, namespaces); 109 | 110 | GetExternalReferencedData(info.GetParameters(), info.DeclaringType.Namespace, types, namespaces); 111 | } 112 | 113 | public static void GetExternalReferencedData(PropertyInfo info, List types, List namespaces) 114 | { 115 | TestAndAddRecursive(info.PropertyType, info.DeclaringType.Namespace, types, namespaces); 116 | } 117 | 118 | public static void GetExternalReferencedDataFromMethods(dynamic[] methods, List types, List namespaces) 119 | { 120 | foreach (dynamic method in methods) 121 | { 122 | foreach (MethodInfo mi in method.Overloads) 123 | { 124 | GetExternalReferencedData(mi, types, namespaces); 125 | } 126 | } 127 | } 128 | 129 | public static void GetExternalReferencedDataForType(dynamic typeDefinition, List externalValueTypes, List externalNamespaces) 130 | { 131 | foreach (ConstructorInfo ci in typeDefinition.Type.GetConstructors()) 132 | { 133 | GetExternalReferencedData(ci.GetParameters(), typeDefinition.Type.Namespace, externalValueTypes, externalNamespaces); 134 | } 135 | 136 | foreach (PropertyInfo pi in typeDefinition.MemberProperties) 137 | { 138 | GetExternalReferencedData(pi, externalValueTypes, externalNamespaces); 139 | } 140 | 141 | foreach (PropertyInfo pi in typeDefinition.StaticProperties) 142 | { 143 | GetExternalReferencedData(pi, externalValueTypes, externalNamespaces); 144 | } 145 | 146 | foreach (dynamic ev in typeDefinition.Events) 147 | { 148 | EventInfo ei = ev.EventInfo; 149 | GetExternalReferencedData(ei, externalValueTypes, externalNamespaces); 150 | } 151 | 152 | GetExternalReferencedDataFromMethods(typeDefinition.MemberAsyncMethods, externalValueTypes, externalNamespaces); 153 | GetExternalReferencedDataFromMethods(typeDefinition.StaticAsyncMethods, externalValueTypes, externalNamespaces); 154 | GetExternalReferencedDataFromMethods(typeDefinition.MemberSyncMethods, externalValueTypes, externalNamespaces); 155 | GetExternalReferencedDataFromMethods(typeDefinition.StaticSyncMethods, externalValueTypes, externalNamespaces); 156 | } 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /.github/workflows/generate.yml: -------------------------------------------------------------------------------- 1 | name: Generate new version 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | semver: 7 | description: "Version increment" 8 | required: true 9 | default: patch 10 | type: choice 11 | options: 12 | - major 13 | - minor 14 | - patch 15 | 16 | jobs: 17 | generate-tag: 18 | runs-on: ubuntu-latest 19 | outputs: 20 | tagVersion: ${{ steps.tagGen.outputs.new_tag }} 21 | npmVersion: ${{ steps.tagGen.outputs.new_version }} 22 | steps: 23 | - uses: step-security/harden-runner@v2 24 | with: 25 | egress-policy: audit 26 | - uses: actions/checkout@v4 27 | with: 28 | # Set to 0 so that we can get tags 29 | fetch-depth: 0 30 | - name: Bump version and push tag 31 | id: tagGen 32 | uses: hennejg/github-tag-action@v4.4.0 33 | with: 34 | github_token: ${{ secrets.GITHUB_TOKEN }} 35 | default_bump: ${{ inputs.semver }} 36 | release_branches: ${{ github.ref_name }} 37 | build-bindings: 38 | needs: generate-tag 39 | strategy: 40 | fail-fast: true 41 | matrix: 42 | # What to actually run 43 | win-target-ver: [10v1903, 10v21H1, 11v21H2, 11v22H2] 44 | # Details about each run 45 | include: 46 | # - win-target-ver: 10v1809 47 | # win-target-build-ver: 17763 48 | # npm-org: nodert-win10-rs5 49 | # npm-win-major: 10 50 | # npm-win-minor: 18H2 51 | # npm-win-desc: Codename Redstone 5 / October 2018 Update 52 | - win-target-ver: 10v1903 53 | win-target-build-ver: 18362 54 | npm-org: nodert-win10-19h1 55 | npm-win-major: 10 56 | npm-win-minor: 1903 57 | npm-win-desc: Codename 19H1 / May 2019 Update 58 | - win-target-ver: 10v21H1 59 | win-target-build-ver: 20348 60 | npm-org: nodert-win10-21h1 61 | npm-win-major: 10 62 | npm-win-minor: 21H1 63 | npm-win-desc: May 2021 Update 64 | - win-target-ver: 11v21H2 65 | win-target-build-ver: 22000 66 | npm-org: nodert-win11 67 | npm-win-major: 11 68 | npm-win-minor: 21H2 69 | npm-win-desc: Original Release 70 | - win-target-ver: 11v22H2 71 | win-target-build-ver: 22621 72 | npm-org: nodert-win11-22h2 73 | npm-win-major: 11 74 | npm-win-minor: 22H2 75 | npm-win-desc: September 2022 Update 76 | runs-on: windows-latest 77 | steps: 78 | - uses: actions/checkout@v4 79 | 80 | # Replace text in files before compiling 81 | - run: sed -i "s~$SEARCH~$REPLACE~g" src/NodeRTLib/JsPackageFiles/README.*.md 82 | shell: bash 83 | env: 84 | SEARCH: ":::org:::" 85 | REPLACE: ${{ matrix.npm-org }} 86 | - run: sed -i "s~$SEARCH~$REPLACE~g" src/NodeRTLib/JsPackageFiles/README.*.md 87 | shell: bash 88 | env: 89 | SEARCH: ":::win-major:::" 90 | REPLACE: ${{ matrix.npm-win-major }} 91 | - run: sed -i "s~$SEARCH~$REPLACE~g" src/NodeRTLib/JsPackageFiles/README.*.md 92 | shell: bash 93 | env: 94 | SEARCH: ":::win-minor:::" 95 | REPLACE: ${{ matrix.npm-win-minor }} 96 | - run: sed -i "s~$SEARCH~$REPLACE~g" src/NodeRTLib/JsPackageFiles/README.*.md 97 | shell: bash 98 | env: 99 | SEARCH: ":::target-build-ver:::" 100 | REPLACE: ${{ matrix.win-target-build-ver }} 101 | - run: sed -i "s~$SEARCH~$REPLACE~g" src/NodeRTLib/JsPackageFiles/README.*.md 102 | shell: bash 103 | env: 104 | SEARCH: ":::target-ver:::" 105 | REPLACE: ${{ matrix.win-target-ver }} 106 | - run: sed -i "s~$SEARCH~$REPLACE~g" src/NodeRTLib/JsPackageFiles/README.*.md 107 | shell: bash 108 | env: 109 | SEARCH: ":::win-desc:::" 110 | REPLACE: ${{ matrix.npm-win-desc }} 111 | 112 | # Download SDK to compile against 113 | - uses: GuillaumeFalourd/setup-windows10-sdk-action@v1.11 114 | with: 115 | sdk-version: ${{ matrix.win-target-build-ver }} 116 | 117 | # .NET 4.x is already installed in windows image 118 | # https://github.com/actions/runner-images/blob/main/images/win/Windows2019-Readme.md#net-framework 119 | # https://github.com/actions/runner-images/blob/main/images/win/Windows2022-Readme.md#net-framework 120 | # - uses: actions/setup-dotnet@v2 121 | # with: 122 | # dotnet-version: '4.5.x' 123 | 124 | - uses: actions/setup-node@v4 125 | with: 126 | node-version: lts/* 127 | check-latest: true 128 | - run: npm install --global --fund=false node-gyp 129 | 130 | # Needed to setup visual studio builder 131 | - uses: microsoft/setup-msbuild@v1.3 132 | with: 133 | # 17.x = 2022 134 | vs-version: '[17,18)' 135 | # Available only on 17 and later 136 | msbuild-architecture: x64 137 | 138 | # Actually build generator 139 | - run: dotnet build NodeRTCmd --configuration Debug 140 | # working directory has to be where *.sln is located 141 | working-directory: ./src 142 | 143 | # Run script to mass create modules 144 | - run: .\scripts\automated-mass-creation.ps1 145 | shell: pwsh 146 | env: 147 | npmVersion: ${{ needs.generate-tag.outputs.npmVersion }} 148 | desiredSdk: ${{ matrix.npm-org }} 149 | 150 | # Upload to artifact to download in other workflow job or manually 151 | - uses: actions/upload-artifact@v4 152 | with: 153 | name: ${{ matrix.npm-org }} 154 | path: NodeRT-Bindings/${{ matrix.npm-org }} 155 | if-no-files-found: error 156 | generate-release: 157 | needs: generate-tag 158 | permissions: 159 | contents: write 160 | runs-on: ubuntu-latest 161 | steps: 162 | - uses: step-security/harden-runner@v2 163 | with: 164 | egress-policy: audit 165 | - uses: actions/checkout@v4 166 | # Create GitHub Release matching npm release 167 | - uses: softprops/action-gh-release@v1 168 | with: 169 | tag_name: ${{ needs.generate-tag.outputs.tagVersion }} 170 | fail_on_unmatched_files: false 171 | generate_release_notes: true 172 | publish-bindings: 173 | needs: [build-bindings, generate-release] 174 | strategy: 175 | fail-fast: true 176 | matrix: 177 | # What to actually run 178 | win-target-ver: [10v1903, 10v21H1, 11v21H2, 11v22H2] 179 | # Details about each run 180 | include: 181 | # - win-target-ver: 10v1809 182 | # npm-org: nodert-win10-rs5 183 | - win-target-ver: 10v1903 184 | npm-org: nodert-win10-19h1 185 | - win-target-ver: 10v21H1 186 | npm-org: nodert-win10-21h1 187 | - win-target-ver: 11v21H2 188 | npm-org: nodert-win11 189 | - win-target-ver: 11v22H2 190 | npm-org: nodert-win11-22h2 191 | runs-on: ubuntu-latest 192 | steps: 193 | - uses: step-security/harden-runner@v2 194 | with: 195 | egress-policy: audit 196 | - uses: actions/checkout@v4 197 | - uses: actions/setup-node@v4 198 | with: 199 | node-version: lts/* 200 | check-latest: true 201 | registry-url: 'https://registry.npmjs.org' 202 | # Download compiled npm package set 203 | - uses: actions/download-artifact@v4 204 | with: 205 | name: ${{ matrix.npm-org }} 206 | path: NodeRT-Bindings 207 | 208 | # Run script to mass upload modules 209 | - run: .\scripts\automated-mass-release.ps1 210 | shell: pwsh 211 | env: 212 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 213 | --------------------------------------------------------------------------------