1.0.4 • Published 4 years ago

audience-backend v1.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

Audience Backend Integration Library

This is the backend integration library of Audience.

You will find further information on github.com/core-process/audience.

Example

import { audience, AudienceRect } from 'audience-backend';
import path from 'path';

async function main() {
  // retrieve audience interface
  const app = await audience({
    icons: [16, 32, 48, 64, 96, 512, 1024].map(icon => path.join(__dirname, '../icons', icon + '.png')),
  });

  // handle close related events
  app.onWindowCloseIntent(async ({ handle }) => {
    await app.windowDestroy(handle);
  });

  app.onWindowClose(async ({ is_last_window }) => {
    if (is_last_window) {
      await app.quit();
    }
  });

  // handle window messages
  app.onWindowMessage(async ({ handle, message }) => {
    if (message == 'ping') {
        await app.windowPostMessage(handle, 'pong');
    }
  });

  // create application window
  await app.windowCreate({ dir: path.join(__dirname, '../webapp'), dev: true });

  // wait for future exit of app
  // not required, but nice to manage lifecycle of main()
  await app.futureExit();
};

main()
  .catch((error) => { console.error('error', error); process.exit(1); })
  .then(() => { console.log('completed'); });

See here for a complete example.

What is Audience?

A small adaptive cross-platform and cross-technology webview window library to build modern cross-platform user interfaces.

  • It is small: The size of the Audience runtime is just a fraction of the size of the Electron runtime. Currently, the ratio is about 1%, further optimizations pending.

  • It is compatible: Currently, we provide ready-to-go APIs for C/C++ and Node.js, but you can plug it into any environment, which supports either C bindings or can talk to Unix sockets respectively named pipes.

  • It is adaptive: Audience adapts to its environment using the best available webview technology based on a priority list. E.g., on Windows, it can be configured to try embedding of EdgeHTML first and fall back to the embedding of IE11.

  • It supports two-way messaging: the web app can post messages to the native backend, and the native backend can post messages to the web app.

  • It supports web apps provided via a filesystem folder or URL. Audience provides its custom web server and websocket service tightly integrated into the library. But if you prefer a regular http URL schema, you can use Express or any other http based framework you like.

  • The core provides a lightweight C API, a command-line interface, as well as a channel-based API (using Unix sockets and named pipes on Windows). Integrations into other environments are provided on top, e.g., for Node.js.

Authors and Contributors

Authored and maintained by Niklas Salmoukas [@GitHub @LinkedIn @Xing @Twitter @Facebook @Instagram].

npm.ionpm.ionpm.ionpm.ionpm.ionpm.ionpm.ionpm.io

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.9.22

4 years ago

0.9.21

4 years ago

0.9.20

4 years ago

0.9.19

4 years ago

0.9.18

4 years ago

0.9.17

4 years ago

0.9.16

4 years ago

0.9.15

4 years ago

0.9.14

4 years ago

0.9.13

4 years ago

0.9.12

4 years ago

0.9.10

4 years ago

0.9.4

4 years ago

0.9.3

4 years ago

0.9.2

4 years ago

0.9.1

4 years ago