Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@humany/widget-core

Package Overview
Dependencies
Maintainers
4
Versions
72
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@humany/widget-core

Core components for Humany widgets.

  • 1.0.15
  • previous
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

@humany/widget-core

Core components for the Humany widget framework.

Humany

The Humany runtime object is the main object in the widget framework and is used to create and setup implementations, as well as providing methods for accessing implementations and widgets in the runtime.

Humany.create(): Humany (static)

Creates a new Humany instance using default settings.

Humany.createFromGlobal(globalHumany: any): Humany (static)

Creates a new Humany instance from a global object which can be either a temporary object created by the Humany embed script or an existing Humany instance. This factory method is used to support eager runtime configurations in a setup when the Humany runtime is loaded asynchronously.

humany.widgets.find(selector: WidgetSelector): WidgetData

Returns the first widget that matches the provided selector.

humany.widgets.query(selector: WidgetSelector): WidgetData[]

Returns all widgets that matches the provided selector.

humany.widgets.all(): WidgetData[]

Returns all widgets in the the runtime.

humany.implementations.find(selector: ImplementationSelector): Implementation

Returns the first implementation that matches the provided selector.

humany.implementations.query(selector: ImplementationSelector): Implementation[]

Returns all implementations that matches the provided selector.

humany.implementations.all(): Implementation[]

Returns all implementations in the the runtime.

Widget

Base class for Humany widgets.

Plugin

Base class for Humany plugins.

loadImplementation(humany: Humany, url: string): Promise<Implementation>

Loads an implementation configuration from the Humany service and creates an instance of the implementation on the provided Humany object.

bootstrap(implementation: Implementation, (config: Configurator) => void): Promise

Bootstraps the provided implementation by scanning the document for trigger elements associated to the widgets in the implementation.

Example

The following example sets up a remote Humany implementation containing a Floating widget and bootstraps it using the default bootstrapping extensions (with support for "trigger elements").

import { Humany, loadImplementation, bootstrap } from '@humany/widget-core';
import { FloatingWidget } from '@humany/widget-types-floating';

(async () => {
  // create the runtime
  const humany = window.humany = Humany.createFromGlobal(window.humany);

  // load implementation
  const implementation = await loadImplementation(
    humany,
    'https://sandbox.humany.net/floating-demo',
  );

  // bootstrap implementation
  bootstrap(implementation, (config) => {
    // register widget-types
    config.types.register('@humany/floating-widget', FloatingWidget);

    config.ready(() => console.info('Implementation has been bootstrapped'));
  });

})();

Keywords

FAQs

Package last updated on 16 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc