Git Product home page Git Product logo

nx.js's Introduction

nx.js

nx.js is a framework that enables the development of Nintendo Switch homebrew applications using JavaScript. Powered by the QuickJS engine, nx.js provides a streamlined environment for writing homebrew applications for the Nintendo Switch console.

With nx.js, developers can leverage their JavaScript skills and tools to create engaging and interactive experiences for the Nintendo Switch platform. The framework abstracts the underlying low-level details and provides a high-level JavaScript API that simplifies the development process.

nx.js is designed with Web standards in mind, so familiar APIs like setTimeout(), fetch(), new URL(), Canvas and much more are supported. If you are familar with web development then you should feel right at home.

Features

  • JavaScript Development: Write homebrew applications for the Nintendo Switch using JavaScript, a popular and widely supported programming language.
  • High-Level API: Benefit from a high-level JavaScript API designed specifically for the Nintendo Switch platform, providing easy access to console-specific features and functionality.
  • Input Handling: Capture and process user input with ease, including buttons, touch screen, and motion controls, to create engaging gameplay experiences.
  • Graphics and UI: Create visually appealing and interactive user interfaces using the web Canvas API.
  • Audio Support: Integrate audio playback and sound effects into your applications using the web Audio API.
  • WebAssembly: Support for executing code compiled to WebAssembly (WASM).

Getting Started

  1. Set up a custom firmware on your Switch, so that it can run homebrew applications (instructions).
  2. Download the nxjs.nro file from the Releases page.
  3. Create a file called nxjs.js with the following contents:
    console.log('Hello Switch, from JavaScript!');
  4. Copy both files into the /switch directory on your SD card.
  5. Launch the app from the homebrew loader.
  6. Profit!

See the API docs for further details, and check out the apps directory for examples.

Creating an application

Run the following command to bootstrap the creation of an nx.js application:

npm create nxjs-app@latest

You will be able to choose from one of the example applications as a starting point. Follow the prompts, and afterwards a new directory will be created with the project name that you entered.

The following package.json scripts are configured:

  • build - Bundle the application code into a single JavaScript file using esbuild
  • nro - Package the bundled app (+ any other files in the romfs dir) into a self-contained .nro file

Contributing

Contributions to nx.js are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request in the GitHub repository.

Join the Discord server!

License

nx.js is released under the MIT License. Please see the LICENSE file for more details.

nx.js's People

Contributors

github-actions[bot] avatar tootallnate avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nx.js's Issues

video m3u8 support?

Does nx.js support video streaming. I plan to play videos through nx.js with m3u8 stream file format
Google translator

Add TLS upgrade mechanism

Probably by leveraging the mbedtls C library (which is already available on Switch ports in devkitpro), we need to expose a mechanism to upgrade a TCP socket connection to TLS. Possibly by having a startTls(): Socket function on the Socket interface.

Once this exists, then it will be possible to implement the https: protocol in fetch().

`Switch` global should be a "namespace"

Currently, the Switch global is a variable that is an instance of the SwitchClass class.

Instead, Switch should be a singleton module that is defined as:

import * as Switch from './switch';

export type * as Switch from './switch';
def('Switch', Switch);

This way, it will be a namespace at the TypeScript and TypeDoc level, and we get rid of SwitchClass entirely.

Make relative `fetch()` URLs work

fetch() currently requires an absolute URL.

For compat with i.e. browsers, or Deno with --location flag, fetch() should work with a relative path, which would resolve based off of import.meta.url. Ex:

fetch('hello.wasm');

// should be the same as:

fetch(new URL('hello.wasm', import.meta.url));

// Examples:
//   "romfs://hello.wasm" when `main.js` is packaged into the RomFS
//   "sdmc://switch/hello.wasm" when entrypoint was `/switch/nxjs.js`

If this is implemented before #26, then replace import.meta.url with Switch.entrypoint, until that issue is resolved and then switch to the preferred import.meta.url value in the future.

There was an error during the cloning process

full error:

There was an error during the cloning process:
DegitError: could not find commit hash for v0.0.17
    at Degit._cloneWithTar (C:\Users\andrei1010\AppData\Local\npm-cache\_npx\f598e7a88fe11b20\node_modules\degit\dist\index-688c5d50.js:14258:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Degit.clone (C:\Users\andrei1010\AppData\Local\npm-cache\_npx\f598e7a88fe11b20\node_modules\degit\dist\index-688c5d50.js:14096:4) {
  code: 'MISSING_REF',
  ref: 'v0.0.17'
}
x  Canceled
npm ERR! code 1
npm ERR! path C:\Users\andrei1010
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c create-nxjs-app

npm ERR! A complete log of this run can be found in: C:\Users\andrei1010\AppData\Local\npm-cache\_logs\2023-09-28T14_25_55_116Z-debug-0.log

log file:

2023-09-28T14_25_55_116Z-debug-0.log

Bluetooth support?

Could be like web bluetooth (like what chromium-based browsers use) if that makes things easier, but all in all I think it would just be interesting to be able to look for, connect to, and communicate with nearby Bluetooth LE devices, as spherov2.js would be pretty nice to have as something I could use in a Switch homebrew app, plus other people might think of better ways to utilize bluetooth here, like maybe communicating with a smart phone to transfer things like system info?

EDIT: Turns out safari doesn't support web bluetooth. Why the hell is such a spectacular thing ONLY supported in Chromium? (chrome, edge, opera, etc)

Get game list and launch games

This project looks awesome! I would love to use it to build a custom game launcher with more features, similar to uLaunch. I know the API's are still in progress, but was wondering if there's already a way to get the list of games on the device and launch them.

Prompt for error when creating project.

I am a developer who only knows how to write JavaScript, and now I am encountering some problems. The error message is 'npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c create-nxjs-app'. How can I solve it? I really hope you can help me answer.

Game doesn't appear.

I did the getting started documentation, but the app doesn't appear.

Does the Switch need to be modded?

Make `data:` scheme URLs work with `fetch()`

Sometimes npm modules which include WASM binary data load that data with the fetch() function using a base64-encoded data: URL. Make this work:

import { loadYoga } from 'yoga-layout/wasm-async';

(async () => {
    console.log(loadYoga);
    const yoga = await loadYoga();
    console.log(yoga);
})().catch(console.error);

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.