Giter Site home page Giter Site logo

node-nodert's Introduction

About

NodeRT but precompiled (use WinRT API directly from node).

Usage is similar to the original NodeRT package(s).
For more details on NodeRT, please kindly see the corresponding NodeRT package.

๐Ÿ“ฆ Scoped @xan105 packages are for my own personal use but feel free to use them.

Example

Dummy toast notification

import * as winRT from "@xan105/nodert";

const xml = new winRT.data.xml.dom.XmlDocument();
xml.loadXml(xmlString);

const toast = new winRT.ui.notifications.ToastNotification(xml);
const toaster = winRT.ui.notifications.ToastNotificationManager.createToastNotifier(appID);
toaster.show(toast);

setTimeout(() => {}, 100); //Keep alive

๐Ÿ’ก Interested in toast notification ? check out powertoast.

Install

npm i @xan105/nodert

An internet connection is required to download the prebuilt binaries. They are hosted on github.

By default every NodeRT bindings will be installed.
Similar to nodert-npm you can choose to only keep the NodeRT bindings you do need by:

  • passing a comma separated list of modules as argument
npm i @xan105/nodert --modules="windows.ui.notifications, windows.data.xml.dom"
  • or by adding a list of modules in your package.json file under the _nodert/modules path

For example, having the following section in your package.json will result with the installation of the "windows.devices.geolocation" and "windows.devices.sensors" modules:

"_nodert" : {
  "modules" : [
    "windows.devices.geolocation",
    "windows.device.sensors"
  ]
},

NodeRT scope used as a base is nodert-win11-22h2.
XAML and *.preview WinRT namespaces are removed.
Some namespaces have been kept back to win10-rs4 due to compilation failure (regression).

List of namespaces can be found here (GitHub).

ABI

NodeRT package are not using n-api they must be compiled for every ABI.
Unless exception, expect prebuilds for current and previous Node.js LTS releases (x64).
โš ๏ธ Due to the fast Electron release cycle, do not expect this package to always keep up with the latest.

List of provided ABI can be found here (GitHub) or in the corresponding GitHub release.

Electron

Switching to Electron ABI instead of Node can be done by adding the --electron flag or the env. variable npm_config_runtime set to electron.

Alternatively in your package.json file under the _nodert path:

"_nodert" : {
  "runtime": "electron",
  "modules" : [
    "windows.devices.geolocation",
    "windows.device.sensors"
  ]
},

Electron's packages.json file will be read to determine Electron's ABI.

โš ๏ธ NodeRT should be loaded in the main process NodeRT#158

API

Please see the NodeRT and Microsoft docs for more details.

โš ๏ธ This module is only available as an ECMAScript module (ESM).

WinRT namespaces are also exported under their respective namespace:

import { ui } from "@xan105/nodert" 
const toast = new ui.notifications.ToastNotification(xml);

import { notifications } from "@xan105/nodert/ui" 
const toast = new notifications.ToastNotification(xml);

โš ๏ธ Please be warned that in case of missing bindings the corresponding exports will be undefined.
They are a couple of them due to compilation failure.

๐Ÿž NB: Provided types are those from NodeRT packages. I know they have some errors but I haven't the courage to fix them up by hand.

Build Env

๐Ÿ†š Visual Studio 2022:

  • Visual Studio Installer:

    • C/C++ Desktop
    • C++ ATL for latest v143
    • C++ MFC for latest v143
    • C++/CLI support for v143 build tools
    • MSVC v140 - VS 2015 C++ build tools (v14.00) //VS2015 build tools
    • Windows 11 SDK 22h2 (10.0.22621.0)
  • Manual:

โฌข Node.js native addon:

  • Node.js v20.11.0
  • npm v10.2.4
  • node-gyp v10.0.1
  • Python3 v3.11.3

node-nodert's People

Contributors

xan105 avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

matthiasleitner

node-nodert's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.