import { useEffect, useState } from "react"; import { os, path } from "../lib/cep/node"; import { csi, evalES, openLinkInBrowser, subscribeBackgroundColor, evalTS, } from "../lib/utils/bolt"; import "./main.scss"; // BOLT_SAMPLECODE_START import reactLogo from "../assets/react.svg"; import viteLogo from "../assets/vite.svg"; import tsLogo from "../assets/typescript.svg"; import sassLogo from "../assets/sass.svg"; import nodeJs from "../assets/node-js.svg"; import adobe from "../assets/adobe.svg"; import bolt from "../assets/bolt-cep.svg"; // BOLT_SAMPLECODE_END export const App = () => { const [bgColor, setBgColor] = useState("#282c34"); // BOLT_SAMPLECODE_START const [count, setCount] = useState(0); //* Demonstration of Traditional string eval-based ExtendScript Interaction const jsxTest = () => { console.log(evalES(`helloWorld("${csi.getApplicationID()}")`)); }; //* Demonstration of End-to-End Type-safe ExtendScript Interaction const jsxTestTS = () => { evalTS("helloStr", "test").then((res) => { console.log(res); }); evalTS("helloNum", 1000).then((res) => { console.log(typeof res, res); }); evalTS("helloArrayStr", ["ddddd", "aaaaaa", "zzzzzzz"]).then((res) => { console.log(typeof res, res); }); evalTS("helloObj", { height: 90, width: 100 }).then((res) => { console.log(typeof res, res); console.log(res.x); console.log(res.y); }); evalTS("helloVoid").then(() => { console.log("function returning void complete"); }); evalTS("helloError", "test").catch((e) => { console.log("there was an error", e); }); }; const nodeTest = () => { alert( `Node.js ${process.version}\nPlatform: ${ os.platform }\nFolder: ${path.basename(window.cep_node.global.__dirname)}` ); }; // BOLT_SAMPLECODE_END useEffect(() => { if (window.cep) { subscribeBackgroundColor(setBgColor); } }, []); return (
{/* BOLT_SAMPLECODE_START */}
Vite
+
React
+
TypeScript
+
Sass

Edit main.tsx and save to test HMR updates.

{" | "} {" | "}

{/* BOLT_SAMPLECODE_END */}
); };