#760: $.evalFile and a minimal BridgeTalk host identification

Problem: `$.evalFile` always threw, and `typeof BridgeTalk` was
`undefined`, so frameworks such as DuAEF failed during initialisation
when they load their modules or ask which application they run in.

Fix: `$.evalFile(file[, timeout])` evaluates a script file in the global
scope and returns its last value. Relative paths resolve against the
folder of the file being evaluated (the running script's for the
outermost call, else the project's); reads follow the same file gate,
16 MiB size cap and 32-deep nesting limit as `#include` (#759, shared
`scriptfile.rs`), and the bracket-depth check runs before parsing.
`BridgeTalk` names the host honestly (`appName` "effectcraft", its
version, `appSpecifier`, `isRunning` / `getSpecifier` / `getStatus` /
`getTargets` for ourselves only); `send()` throws a clear "not
supported" error instead of messaging other applications.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
vangel76
2026-10-11 12:37:22 +02:00
co-authored by Claude Opus 5.5
parent 9a7d3e7699
commit 88278ea871
6 changed files with 259 additions and 6 deletions
+42 -1
View File
@@ -111,9 +111,50 @@ var $ = {
get os() { return "EffectCraft"; },
get version() { return "EffectCraft scripting"; },
get locale() { return "en_US"; },
evalFile: function () { throw __err("$.evalFile is not supported: scripts can't run scripts"); },
// Evaluates the file in the global scope and returns its last value (`timeout` is ignored).
evalFile: function (file, timeout) { return __evalFile(__str(file)); },
};
// ------------------------------------------------------------------ BridgeTalk
// Which application a script runs in, for scripts and frameworks that ask during initialisation.
// EffectCraft names itself rather than posing as another application; messages to other
// applications aren't supported.
function BridgeTalk() {
if (!(this instanceof BridgeTalk)) return new BridgeTalk();
this.target = "";
this.sender = BridgeTalk.appSpecifier;
this.body = "";
this.type = "ExtendScript";
this.headers = {};
this.timeout = 0;
this.onResult = null;
this.onError = null;
this.onReceived = null;
this.onTimeout = null;
}
BridgeTalk.prototype.send = function () {
throw __err("BridgeTalk: sending messages to other applications is not supported in EffectCraft");
};
BridgeTalk.prototype.sendResult = BridgeTalk.prototype.send;
BridgeTalk.prototype.toString = function () { return "[object BridgeTalk]"; };
BridgeTalk.appName = "effectcraft";
Object.defineProperty(BridgeTalk, "appVersion", { get: function () { return __get("app").buildName; } });
Object.defineProperty(BridgeTalk, "appSpecifier", { get: function () { return "effectcraft-" + BridgeTalk.appVersion; } });
BridgeTalk.appLocale = "en_US";
BridgeTalk.appInstance = "";
BridgeTalk.appStatus = "idle";
BridgeTalk.onReceive = null;
BridgeTalk.__isSelf = function (spec) { return String(spec === undefined || spec === null ? "" : spec).split("-")[0].toLowerCase() === "effectcraft"; };
BridgeTalk.isRunning = function (spec) { return BridgeTalk.__isSelf(spec); };
BridgeTalk.launch = function (spec) { return BridgeTalk.__isSelf(spec); };
BridgeTalk.getSpecifier = function (name) { return BridgeTalk.__isSelf(name) ? BridgeTalk.appSpecifier : null; };
BridgeTalk.getDisplayName = function (spec) { return BridgeTalk.__isSelf(spec) ? "EffectCraft" : null; };
BridgeTalk.getTargets = function () { return [BridgeTalk.appName]; };
BridgeTalk.getStatus = function (spec) { return spec === undefined || BridgeTalk.__isSelf(spec) ? "IDLE" : "ISNOTINSTALLED"; };
BridgeTalk.bringToFront = function () {};
BridgeTalk.pump = function () { return false; };
// ------------------------------------------------------------------ File / Folder
function __join(a, b) { return a.replace(/[\/\\]+$/, "") + "/" + b; }