npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dimina-kit/electron-runtime

v0.1.0

Published

Embeddable Dimina mini-app runtime for Electron hosts

Downloads

178

Readme

@dimina-kit/electron-runtime

Run a Dimina mini-app inside an Electron app you already have.

The host keeps ownership of Electron's app, BrowserWindow, layout, and shutdown lifecycle. This package owns the rest: compilation-session wiring, the mini-app bridge, and the WebContentsView the mini-app renders into.

Install

pnpm add @dimina-kit/electron-runtime @dimina-kit/devkit

electron (^43.2.0) is a required peer dependency; react is optional. @dimina-kit/devkit supplies the openProject compiler adapter used below — substitute your own adapter if you compile mini-apps some other way.

Quick start

import { app, BrowserWindow } from 'electron'
import {
  createElectronRuntime,
  registerElectronRuntimeSchemes,
} from '@dimina-kit/electron-runtime'
import { openProject } from '@dimina-kit/devkit'

// 必须在 app ready 之前、模块顶层调用。
registerElectronRuntimeSchemes()

async function start() {
  await app.whenReady()
  const window = new BrowserWindow()
  const runtime = await createElectronRuntime({
    hostWindow: window,
    adapter: { openProject },
  })
  const session = await runtime.openProject({ projectPath: '/absolute/miniapp' })
  window.contentView.addChildView(session.view)
  session.setBounds({ x: 0, y: 0, width: 390, height: 844 })
  await session.ready
}

start().catch((err) => {
  console.error(err)
  app.quit()
})

别在 main 模块顶层 await app.whenReady()。Electron 要等 main 模块求值 完成才触发 ready,顶层 await 会让两边互相等待,应用永远起不来(Electron 43.2.0 实测:进程挂住,顶层 await 之后的代码一行都不执行)。把启动逻辑放进 上面这样的 async 函数,或用 app.whenReady().then(...)。

Call session.dispose() before removing a project, and runtime.dispose() when the host tears down the integration. One runtime may be active per Electron process because its bridge uses process-global ipcMain channels.

Process-global schemes

Electron allows protocol.registerSchemesAsPrivileged() to run only once and only before the app is ready. registerElectronRuntimeSchemes() is a convenience for hosts that do not register any other privileged schemes. If the host owns that registration, merge the exported descriptors into its one call instead:

import { protocol } from 'electron'
import { ELECTRON_RUNTIME_SCHEMES } from '@dimina-kit/electron-runtime'

protocol.registerSchemesAsPrivileged([
  ...ELECTRON_RUNTIME_SCHEMES,
  { scheme: 'my-app', privileges: { standard: true, secure: true } },
])

Bundling and assets

The package ships renderer, preload, and HTML assets under its dist/ directory. When the main-process bundler keeps @dimina-kit/electron-runtime external, the runtime resolves that directory from the installed package.

When bundling the runtime code into the host's main bundle, copy the package's complete dist/ directory into the packaged application and pass its absolute path explicitly:

const runtime = await createElectronRuntime({
  hostWindow: window,
  adapter: { openProject },
  assetsRoot: path.join(process.resourcesPath, 'dimina-electron-runtime'),
})

The assetsRoot directory must directly contain simulator/, preload/, render-host/, service-host/, and native-host/. Copy the complete directory rather than selecting individual files: the service and render host HTML files load JavaScript and CSS from native-host/. Runtime creation validates these files before installing process-global IPC handlers, so a packaging error fails without leaving a partial integration behind.

License

MIT © EchoTechFE