electronade
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

electronade

It's a framework helper for the electron projects.

npm NPM npms.io (quality) Libraries.io dependency status for latest release Maintenance

Installation

npm install electronade

Usage

See electronade.netlify.app for details.

setting handles from electronade packages

main.ts

import { app } from "electron";
import { setHandles } from "electronade";
import { handles as someHandles } from "electronade-some";
import { handles as otherHandles } from "electronade-other";

app.whenReady().then(() => {
  setHandles({
    someHandles,
    otherHandles
  });
});

exposing from electronade packages

get ready for generation of preload file, base file should exist preload_base.ts

import {
  contextBridge,
  ipcRenderer,
  IpcRendererEvent
} from "electron";

contextBridge.exposeInMainWorld("ownAPI", {
  mine: {
    work: (message: string) =>
      ipcRenderer.invoke("mine:work", message)
  }
});

initialize config file for preload preparation. electronade.config.js will be generated.

npx electronade --init

edit electronade.config.js

const { preloadObject: somePreload } = require("electronade-some");
const { preloadObject: otherPreload } = require("electronade-other");

module.exports = {
  input: {
    baseFile: "path/to/preload_base.ts",
    exposingName: "electronade",
    preloadObjects: {
      somePreload,
      otherPreload
    }
  },
  output: {
    file: "path/to/preload.ts"
  }
};

prepare merged preload file.

npx electronade --prepare-preload --config electronade.config.js

calling from renderer

const result1 = await electronade.some.work(params);
const result2 = await electronade.other.anotherWork();
const result3 = await ownAPI.mine.work("message");

Readme

Keywords

Package Sidebar

Install

npm i electronade

Weekly Downloads

1

Version

0.1.2

License

MIT

Unpacked Size

13.2 kB

Total Files

9

Last publish

Collaborators

  • tomsd