fusepilot / create-cep-extension

A near zero config approach to creating CEP extensions with Webpack and React.
Other
87 stars 15 forks source link

Can't use extendscript #67

Open quetslaurent opened 3 years ago

quetslaurent commented 3 years ago

Description

I can't use extend script inside of App.js

Expected behavior

Write hello world in console

Actual behavior

Unhandled Rejection (TypeError): Cannot read property 'evalScript' of undefined

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls create-cep-extension-scripts (if you haven’t ejected): -- create-cep-extension-scripts@1.0.0-beta.31
  2. node -v: v12.18.4
  3. npm -v: 7.5.3

Then, specify:

  1. Operating system: Windows 10
  2. Browser and version: Google Chrome Version 88.0.4324.150

Reproducible Demo

import React, { Component } from 'react';
import { evalExtendscript } from 'cep-interface';
import logo from './logo.svg';
import './App.css';

class App extends Component {

  test = () => {
    evalExtendscript('$.writeln("Hello Foo");');
  }

  render() {
    return (
      <div className="App">
        <div className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h2>Welcome to React</h2>
        </div>
        <p className="App-intro">
          To get started, edit <code>src/App.js</code> and save to reload.
        </p>
        <button onClick={this.test}>TEST</button>
      </div>
    );
  }
}

export default App;

I got my error : I was trying to use it from react dev server, but I had to use it from PS debug server. It still can't access cep variable for example to read files