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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@openfin/native-window-integration-client

v0.0.17

Published

This library exports the NativeWindowIntegrationClient class to connect to a native component and add native windows to snapshots.

Downloads

1,059

Readme

OpenFin NWI Library

This library exports the NativeWindowIntegrationClient class to connect to a native component and add native windows to snapshots.

This class has the following methods: static create(options) A factory method which launches the provider and creates a connection to it.

decorateSnapshot(snapshot) an instance method which adds native window information to a snapshot.

applySnapshot(snapshot) an instance which will look for native window information in a snapshot and attempt to restore it.

Prerequisites

Installation

npm i @openfin/native-window-integration-client

Usage

Import the native provider into your project, see hosting, and create a connection to it using the NativeWindowIntegrationClient.create method, the url to the hosted native provider/asset should be passed in as the url property in the client options.


import { NativeWindowIntegrationClient } from '@openfin/native-window-integration-client';
// native provider url loaded using webpack's file-loader
import assetUrl from '@openfin/native-window-integration-client/lib/provider.zip';


const configuration = [
    {
        'name': 'Notepad',
        'title': 'my_platform_notes',
        'launch': {
            'alias': 'my_platform_notes',
            'target': 'my_platform_notes.txt',
            'lifetime': 'application',
            'arguments': ''
        }
    },
    {
        'name': 'Symphony',
        'title': 'Symphony',
        'launch': {
            'path': 'C:\\Users\\openfin\\AppData\\Local\\Programs\\Symphony\\Symphony\\Symphony.exe',
            'lifetime': 'application'
        }
    }
]

fin.Platform.init({
    overrideCallback: async (PlatformProvider, ...args) => {
        try {
            console.log('Native Window Integration Client is connecting...');
            const myClient = await NativeWindowIntegrationClient.create({ url: assetUrl, configuration });
            console.log('Native Window Integration Client connected successfully!');

            class WithNative extends PlatformProvider {
                async getSnapshot(...args: [undefined, OpenFin.ClientIdentity]) {
                    const snapshot = await super.getSnapshot(...args);
                    try {
                        const snapshotWithNativeWindows = await myClient.decorateSnapshot(snapshot);
                        return snapshotWithNativeWindows;
                    } catch (error) {
                        console.log('Native Window Integration failed to get snapshotWithNativeWindows:');
                        console.error(error);
                        return snapshot;
                    }
                }
                async applySnapshot(...args: [OpenFin.ApplySnapshotPayload, OpenFin.ClientIdentity]) {
                    await super.applySnapshot(...args);
                    try {
                        await myClient.applySnapshot(args[0].snapshot);
                    } catch (error) {
                        console.log('Native Window Integration error applying native snapshot:');
                        console.error(error);
                    }
                }
            }
            console.log('Native Window Integration successfully enabled!');
            return new WithNative(...args);
        } catch (error) {
            console.log('Native Window Integration failed to initialize:');
            console.error(error);
            return new PlatformProvider(args);
        }
    }
});

API Permissions Requirements

Necessary OpenFin Secure APIs permissions:

  • System.downloadAsset
  • System.launchExternalProcess
  • System.enableNativeWindowIntegrationProvider

These will be called internally by the library.

Hosting

The native provider must be hosted. We highly reccomend using a tool such as webpack's file-loader to include the asset as part of your build to ensure versions stay in sync between the provider and library. Version mismatches will cause the NativeWindowClient.Create call to fail. Copying the provider.zip file to your project's root directory will cause version mismatches when the library is updated, which is why we recommend using a tool such as webpack to include the asset as part of your build.

####Example of hosting the native provider with webpack's file-loader:

module.exports = {
  module: {
    rules: [
      {
        test: /\.(zip)/,
        use: [
          {
            loader: 'file-loader',
             options: {
                            name: '[name].[ext]',
                            outputPath: 'static/',
                        }
          },
        ],
      },
    ],
  },
};