Have ideas to improve npm?Join in the discussion! »

    ffxiv-overlay-api

    3.4.2 • Public • Published

    🗡 ffxiv-overlay-api 🛡

    BADGE BADGE BADGE BADGE

    Build your own modern FFXIV overlay with npm.

    This library needs to be used along with ngld/OverlayPlugin.

    Table of Contents

    Installation

    You can install it from npm registry:

    npm install ffxiv-overlay-api --save

    Or import the library from jsDelivr CDN:

    <script src="https://cdn.jsdelivr.net/npm/ffxiv-overlay-api@3.4/lib/overlay.min.js"></script>
    <script>
      const overlay = new OverlayAPI({
        extendData: true,
        silentMode: false,
      });
    </script>

    Usage

    After installation, you can import the library:

    import OverlayAPI from 'ffxiv-overlay-api';
    const overlay = new OverlayAPI();

    Note that this library only works in browser.

    You can also pass options to constructor (default option below):

    const overlay = new OverlayAPI({
      extendData: true,
      silentMode: false,
    });

    Then you can add bunch of different listeners.

    const overlay = new OverlayAPI();
    overlay.addListener('CombatData', (data) => {
      console.log('listener of `CombatData`', data);
    });
    overlay.addListener('ChangeZone', (data) => {
      console.log('listener of `ChangeZone`', data);
    });

    Call this function once you’re done adding all of your listeners:

    overlay.startEvent();

    Once this function has been called, OverlayPlugin will start sending events. Some events will be raised immediately with current state information like ChangeZone or ChangePrimaryPlayer.

    After that, put the URL of your overlay into OverlayPlugin, or use the WebSocket URL when enabled. Checkout the index.html for example usage, you can download this file and load it from the OverlayPlugin. Enable WebSocked in your plugin and add ?OVERLAY_WS=ws://127.0.0.1:[port]/ws or ?HOST_PORT=ws://127.0.0.1:[port] after you overlay URL to access the WebSocket server.

    Checkout Development section for more details.

    Options

    Option Default Description
    extendData true Parse and add cleaner data to listeners of CombatData
    silentMode false For production use, do not log all API stats info

    API

    You can find all events available in https://ngld.github.io/OverlayPlugin/devs/event_types.

    OverlayAPI.addListener(event, cb)

    add an event listener

    • @param {string} event event to listen
    • @param {Function} cb callback function

    OverlayAPI.removeListener(event, cb)

    remove a listener

    • @param {string} event event type which listener belongs to
    • @param {Function} cb function which listener to remove

    OverlayAPI.removeAllListener(event)

    remove all listener of one event type

    • @param {string} event event type which listener belongs to

    OverlayAPI.getAllListener(event)

    get all listeners of a event

    • @param {string} event event type which listener belongs to
    • @return {Array<Function>}

    OverlayAPI.startEvent()

    start listening event

    OverlayAPI.endEncounter()

    ends current encounter and save it

    • @return {Promise<any>}

    OverlayAPI.callHandler(msg)

    this function allows you to call an overlay handler, these handlers are declared by Event Sources, either built into OverlayPlugin or loaded through addons like Cactbot

    • @param {Object} msg message send to OverlayPlugin
    • @return {Promise<any>}

    OverlayAPI.simulateData(msg)

    simulate triggering event once

    Development

    Clone this repo, then:

    npm install
    npm start

    You can access the test overlay at http://localhost:5000/test/, http://localhost:5000/test/?OVERLAY_WS=ws://127.0.0.1:[port]/ws or http://localhost:5000/test/?HOST_PORT=ws://127.0.0.1:[port].

    Remember to run npm run build before release commit.

    Contributon

    Please use the .prettierrc at the root of the project along with Prettier default settings to format your code.

    Annotations

    Copyright © 2020-present DSRKafuU (https://dsrkafuu.su)

    Install

    npm i ffxiv-overlay-api

    DownloadsWeekly Downloads

    3

    Version

    3.4.2

    License

    MIT

    Unpacked Size

    55.3 kB

    Total Files

    6

    Last publish

    Collaborators

    • avatar
    • avatar