Error in "Generate Single-page HTML Export" after upgrade to jArchi 1.6.1

Started by Xiaoqi, March 08, 2024, 15:23:55 PM

Previous topic - Next topic

Xiaoqi

Hello,

I use the "Generate Single-page HTML Export" quite a lot, after upgrading to jArchi 1.6.1, I start to see below error which looks like the "_" is not recognized:

org.graalvm.polyglot.PolyglotException: ReferenceError: "_" is not defined
at <js>.:program(Generate Single-page HTML Export.ajs:44)
at <js>.:program(<eval>:1)
at org.graalvm.polyglot.Context.eval(Context.java:399)
at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:478)
at com.oracle.truffle.js.scriptengine.GraalJSScriptEngine.eval(GraalJSScriptEngine.java:446)

In the source, the line 44 shows this usage:

// Use Mustache.js-style templating
_.templateSettings = {                      --> this is line 44
  interpolate: /\{\{(.+?)\}\}/g
};

And the GitHub site for the plug-in script is still the old one, do you have any advise what I can change to make it working again? Or downgrade jArchi?

Thanks,
Xiaoqi

Xiaoqi

Added: I tried to downgrade to jArchi 1.6.0, it's the same error message.
Further downgrade back to jArchi 1.5.0, now the Export to Single HTML Page is working again.

So suspect something different from 1.5.0 to later version. FYI...

Phil Beauvoir

Hi, there's a preference in Archi, under "Scripting" tab to "Enable Common JS Support". You can turn that off to get it working for now.

The script needs changing those instances of __DIR__ loading. See https://github.com/archimatetool/archi-scripting-plugin/wiki/Using-Node.js-modules

@Jean-Baptiste Sarrodie What do you advise?
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

I think you need to replace those load statements with these:

const _ = require(__DIR__ + "libs/underscore-min.js");
const readFully = require(__DIR__ + "libs/marked.min.js");
const marked = require(__DIR__ + "libs/marked.min.js");

If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Xiaoqi

Quote from: Phil Beauvoir on March 08, 2024, 15:36:26 PMHi, there's a preference in Archi, under "Scripting" tab to "Enable Common JS Support". You can turn that off to get it working for now.

Thanks Phil for your quick reply, yes, that's the one, I upgraded to 1.6.1 again and as you mentioned, uncheck that "Enable Common JS Support" and the script can generate one-page HTML now.

So, it would need to wait JB to update this script then I can check this option I think. For now, I can continue work.

Thanks!
Xiaoqi

Phil Beauvoir

> So, it would need to wait JB to update this script then I can check this option I think.

You could edit your copy of the script if you want.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Xiaoqi

Thanks Phil again.

I've tested and it's working now with following changes in the definition part:

// 2024/02/08: Comment below after jArchi 1.6.1 and give cost definition
load(__DIR__ + 'libs/nashorn-polyfills.js');
// load(__DIR__ + 'libs/underscore-min.js');
// load(__DIR__ + 'libs/marked.min.js');
const _ = require(__DIR__ + 'libs/underscore-min.js');
const marked = require(__DIR__ + 'libs/marked.min.js');

I only change the "underscore-min.js" and "marked.min.js", then re-check the "Enable CommonJS Support", it's enough for generating the HTML. So I leave the first Load without change yet.

Regards,
Xiaoqi