2.3.0 • Published 12 months ago

vitron v2.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Vitron 🖥️

npm version CI Known Vulnerabilities semantic-release: angular

A library to build and develop desktop apps with vite and electron 🔥.

Features

  • Hot Module Replacement

Table of Contents

Installation

npm install --save vitron

Setup

To init a project folder with the necessary files, run the command:

npx vitron@latest init

This will create the following files/directories, if they do not already exist:

  • src
    • main
      • index.ts
    • preload
      • index.ts
    • renderer
      • main.ts
      • index.html
  • .electron-builder.yml

After the directory structure has been created, the dependencies must be installed using a package manager like npm, pnpm, .... In the following example, npm is used:

npm install

The default location of the main, preload and renderer directory can be changed with a configuration file in the root directory of the project.

Therefore, create a vitron.config.js file in the root folder with the following content:

module.exports = {
    mainDirectory: 'src/main',
    preloadDirectory: 'src/preload',
    rendererDirectory: 'src/renderer',
}

Frameworks

Various frontend frameworks, such as Nuxt.js and Next.js, can be used out of the box and do not require any special configuration 🎉. The framework files only need to be placed in the rendererDirectory.

Usage

In a project where Vitron is installed, the vitron binary can be used as npm script. Alternatively run it directly with npx vitron. Here are the default npm scripts in a scaffolded Vitron project:

The best way to use the following commands, is by creating shortcuts in the package.json file.

{
    "scripts": {
        "dev": "vitron dev",
        "build": "vitron build"
    }
}

Utilities

Vitron provides different utilities for the main, preload and renderer code.

Main

For the main code, the import path vitron/main is provided.

serve

Serve the renderer app (ink. static assets) for production and development.

import { serve } from 'vitron/main';
import { BrowserWindow } from 'electron';

const mainWindow = new BrowserWindow({
    /* ... */
});

await serve(mainWindow, {
    directory: path.join(`${__dirname}/../renderer/`),
    port: process.env.PORT,
});

To see an exemplary use, the following example can be used as a basis examples/vanilla/src/main/index.ts.

Preload

For the preload code, the import path vitron/preload is provided.

provide

Simple abstraction to expose an API to the renderer process.

import { provide } from 'vitron/preload';

provide('foo', 'bar');

To see an exemplary use, the following example can be used as a basis examples/vanilla/src/preload/index.ts.

Renderer

For the preload code, the import path vitron/renderer is provided.

inject

Simple abstraction to inject an API from the preload script.

import { inject } from 'vitron/renderer';

const foo = inject<string>('foo');
console.log(foo);
// bar

To see an exemplary use, the following example can be used as a basis examples/vanilla/src/renderer/index.ts.

License

Made with 💚

Published under MIT License.

2.3.0

12 months ago

2.2.0

1 year ago

2.1.0

1 year ago

2.0.0

2 years ago

1.2.0

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

2.0.0-alpha.3

2 years ago

2.0.0-alpha.4

2 years ago

2.0.0-alpha.0

2 years ago

2.0.0-alpha.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.2

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago