Upcoming change of Script-Actions and header_include.html

The next update will change two things the way Script-Actions and included JavaScript in the header_include.html are handled in Antetype. This might break existing usages of this features. This post will highlight the changes, if you think this is a bad idea or have other comments or questions: just let us know!

What will change?

Script Actions

Before script-actions where executed using eval inside our own JavaScript-code. This means the scope is basically the internal Antetype-Object and script could access everything in the scope of the internal ScriptAction-object.

Now we create a new Function-object with the parameters (targetCells, at etc.) as parameters. This means inside a Script-Action only local (defined inside the script-action) or global variables are accessible.

header_include.html

Internally we are switching to use JavaScript-Modules in our code. Which gives us a lot of advantages, but it restricts what it is usable inside <script>-tags. For example we had to change the the header_include.html of our Interactive Stuff-Template. It added a new function to a GDWidgetInstanceRootCell:

GDWidgetInstanceRootCell.prototype.getText = () => // ... get the text of the cell

This is not possible anymore. One possibility would be to use <script type="module"> and import the class … But since our exported WebViewer has to be runnable without a web server (directly opening on the file-system) and JavaScript-modules do not work here, we have to convert the modules into one big JavaScript-File without modules.

Changing the code to a function:

function getText(cell) {
      return cell.valueForKeyIn… // return the text of the cell
}

fixes it.