Skip to content

NativeScript/runtime-node-api

Repository files navigation

NativeScript (Node-API)

An embeddable, engine-agnostic NativeScript runtime based on Node-API and libffi.

This library allows any JavaScript engine or runtime that supports Node-API to access native APIs directly from JavaScript. At present, it supports accessing Objective-C APIs (thus most of the iOS and macOS SDKs). We hope to support other native APIs, such as the Java-based Android SDK, in future.

Initializing the repo

The repo makes use of npm workspaces, so installation is straightforward.

npm install

Generating the metadata

# ① Build the metadata generator.
deno task build-metagen
# Output:
#   metadata/build/Release/MetadataGenerator

# ② Generate metadata for iOS.
deno task metagen ios
# Output:
#   metadata/metadata.ios.arm64.nsmd
#   metadata/metadata.ios.x86_64.nsmd
#   packages/ios/types/*.d.ts

# ③ Generate metadata for macOS.
deno task metagen macos
# Output:
#   metadata/metadata.macos.arm64.nsmd
#   metadata/metadata.macos.x86_64.nsmd
#   packages/macos/types/*.d.ts

Building the runtimes

# Build the runtime for macOS.
deno task build macos
# Output:
#   packages/macos/build/macos/Release/libNativeScript.dylib
#   packages/macos/dist/macos/NativeScript.node

# Build the runtime for iOS as a universal binary.
deno task build ios-universal
# Output:
#   packages/ios/build/ios/Release-iphoneos/NativeScript.framework/NativeScript
#   packages/ios/build/ios-sim/Release-iphonesimulator/NativeScript.framework/NativeScript
#   packages/ios/dist/ios-universal/NativeScript.xcframework

Run examples

These macOS AppKit examples depend upon having run the "Generating metadata" and "Building the runtimes" for macOS already.

node examples/foundation.js
# or
deno run -A examples/foundation.js

# ML Compute example
node examples/mlcompute.js

# AppKit related examples
node examples/appkit.js
node examples/split_view.js
node examples/view_controller.js
node examples/spritekit.js

Copyright notice

Copyright OpenJS Foundation and NativeScript contributors. All rights reserved. The OpenJS Foundation has registered trademarks and uses trademarks. For a list of trademarks of the OpenJS Foundation, please see our Trademark Policy and Trademark List. Trademarks and logos not indicated on the list of OpenJS Foundation trademarks are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.

The OpenJS Foundation | Terms of Use | Privacy Policy | OpenJS Foundation Bylaws | Trademark Policy | Trademark List | Cookie Policy

Made with ❤️

About

An embeddable, engine-agnostic NativeScript runtime based on Node-API

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Contributors 3

  •  
  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy