Giter Site home page Giter Site logo

inventsable / aihostadapter-for-bolt Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 359 KB

Example of using AIHostAdapter for Illustrator within a Bolt-CEP project

License: MIT License

TypeScript 19.35% SCSS 1.08% HTML 0.16% Vue 0.62% JavaScript 78.79%

aihostadapter-for-bolt's Introduction

Bolt AIHostAdapter Demo

This panel is very barebones and relies on AIHostAdapter to function, which you must install manually in your program files as an SDK extension. This panel receives a call each time the selection of the document is changed to update in console as an example of how to implement AIHostAdapter in a Bolt project.

With Bolt

If you're using a project created from Bolt-CEP, you'll need to explicitly import and export required objects from the HostAdapter file located here:

//    ./src/public/BoltHostAdapter.js

import { CSInterface, CSEvent } from "../js/lib/cep/csinterface"; // We need to pull CSInterface from Bolt first

/**
 * EventAdapter provides the base implementation for Creative Cloud
 * application-specific event adapter libraries.
 *
 * ...
 **/

export { AIEventAdapter, AIEvent }; // then export our needs from this file

Then you're free to import and use the HostAdapter as needed in your project:

// ./src/js/main.vue

// @ts-ignore - Since HostAdapter isn't explicitly typed, linting throws an error we'll ignore
import { AIEventAdapter, AIEvent } from "../../public/BoltHostAdapter.js";

const adapter = AIEventAdapter.getInstance();
adapter.addEventListener(AIEvent.ART_SELECTION_CHANGED, async (e: any) => {
  console.log("Host Adapter triggered:");
  console.log(e);
});
console.log(AIEventAdapter); // Successfully fires each time a user changes selection in app (even empty so includes any click on canvas, really)

Without Bolt

If you're trying to get HostAdapter to work with a smaller or simpler project that isn't generated from Bolt-CEP and Vite, the needs are essentially the same as any other library.

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>My CEP PAnel</title>
    <!-- Manually include it in the head of your HTML document, potentially after loading CSInterface.js -->
    <script src="./aiHostAdapter.js"></script>
  </head>
</html>

A non-Bolt example of using the library can be found here with an unmodified file.

aihostadapter-for-bolt's People

Contributors

inventsable avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.