Workplace Widget 5.10.23

This commit is contained in:
chris
2026-11-08 17:45:04 +00:00
parent 180127e2ae
commit 60d35e2326
98 changed files with 4221 additions and 268 deletions

View File

@@ -1,14 +1,115 @@
/* WidgetWorkbench CheerpJ 4.3 runner.
import jaasNativeHandlers from './cheerpj/natives/jaas.js';
/* WidgetWorkbench CheerpJ 5.0 runner (4.3 selectable as a compatibility fallback).
* CheerpJ Core has no documented runJNLP(url) API: parse the manifest and run JAR(s).
* Deliberately SAME-ORIGIN only. Do not turn this into an open server-side URL proxy.
*/
const screen=document.getElementById('display');
const notice=document.getElementById('state');
const BRIDGE_JAR='/app/backend/hmi/cheerpj/workplace-resize-bridge-v2.jar';
const BRIDGE_JAR='/app/backend/hmi/cheerpj/workplace-window-monitor-v4.jar';
const CREDENTIAL_BRIDGE_JAR='/app/backend/hmi/cheerpj/workplace-credential-bridge.jar';
const CREDENTIAL_BRIDGE_URL='/backend/hmi/cheerpj/workplace-credential-bridge.jar';
let credentialWaiter=null;
// JS implementation for OpenJDK UnixSystem.getUnixInfo. Register the handler via
// cheerpjInit({natives}) AND keep the JS native library for System.loadLibrary.
// Note: registration cannot repair a missing CheerpJ JVM_LoadLibrary import.
const JAAS_JS_URL='/backend/hmi/cheerpj/natives/jaas.js';
const JAAS_NATIVE_PATH='/app/backend/hmi/cheerpj/natives';
const JAAS_BRIDGE_JAR='/app/backend/hmi/cheerpj/jaas-identity-bridge.jar';
// JSON-P 1.1 provider required by iTAC ParameterType; NOT included in Workplace.jnlp.
// Maven packages this dependency as a static WAR resource.
const JSONP_PROVIDER_URL='/backend/hmi/cheerpj-libs/javax.json-1.1.4.jar';
const JSONP_PROVIDER_JAR='/app'+JSONP_PROVIDER_URL;
const WORKPLACE_MANIFEST='/backend/api/hmi/v1/cheerpj/workplace/manifest.jnlp';
// Writable, browser-local CheerpJ directory; never a GlassFish/server filesystem path.
const WORKPLACE_TMP_DIR='/files/itac-workplace/tmp';
// CheerpJ /files is writable. A flat and finally root fallback handle engines
// that cannot create nested directories or previously conflicting user files.
const WORKPLACE_TMP_CANDIDATES=[WORKPLACE_TMP_DIR,'/files/itac-workplace-tmp','/files'];
let busy=false;
// Collect the last boot stage so a CheerpJ WASM exit code can be tied to the
// Java startup phase. No credentials, JNLP arguments or MES URLs are logged.
let bootStage='not-started';
function boot(stage){
bootStage=stage;
console.info('[WidgetWorkbench/CheerpJ] '+stage);
}
// CheerpJ can reject library-mode calls with a Java Throwable proxy. Such
// objects do NOT necessarily implement JS Symbol.toPrimitive/toString, so
// String(error), a template literal or `'' + error` can replace the original
// JAAS exception with "Cannot convert object to primitive value".
function primitiveText(value){
switch(typeof value){
case 'string': return value;
case 'number': case 'boolean': case 'bigint': return String(value);
default: return null;
}
}
async function describeThrowable(error,depth=0,seen=new Set()){
const direct=primitiveText(error);
if(direct!==null)return direct;
if(error===null||error===undefined)return 'Unbekannte JavaScript-Ausnahme';
if(depth>2||seen.has(error))return 'Weitere Exception (rekursiv)';
seen.add(error);
let className=null, message=null, stack=null, cause=null;
try{
const getClass=error.getClass;
if(typeof getClass==='function'){
const cls=await getClass.call(error);
if(cls && typeof cls.getName==='function')className=primitiveText(await cls.getName());
}
}catch(_ignored){ /* Java proxy may not expose class metadata. */ }
try{if(!className)className=primitiveText(error.name);}catch(_ignored){}
try{
const getMessage=error.getMessage;
if(typeof getMessage==='function')message=primitiveText(await getMessage.call(error));
}catch(_ignored){ /* Read the original exception below without replacing it. */ }
try{if(!message)message=primitiveText(error.message);}catch(_ignored){}
try{
if(!message && typeof error.toString==='function'){
message=primitiveText(await error.toString());
}
}catch(_ignored){}
try{stack=primitiveText(error.stack);}catch(_ignored){}
try{
if(typeof error.getCause==='function')cause=await error.getCause();
else cause=error.cause;
}catch(_ignored){}
let result=[className,message].filter(Boolean).join(': ');
if(!result && stack)result=stack;
if(!result)result='CheerpJ-Java-Exception (nicht als JavaScript-String lesbar)';
if(cause!==null&&cause!==undefined&&cause!==error)
result+=' | Ursache: '+await describeThrowable(cause,depth+1,seen);
return result.slice(0,900);
}
async function describeFailure(error){
// Keep the original object accessible in DevTools, not only a reformatted copy.
console.error('[WidgetWorkbench/CheerpJ] Failure in '+bootStage+' (original):',error);
const reason=await describeThrowable(error);
return 'CheerpJ-Start fehlgeschlagen in Phase "'+bootStage+'": '+reason+
'. Details in der Browser-Konsole (WidgetWorkbench/CheerpJ).';
}
// Optional browser-JVM probe: ?diagnose=jaas. Only exercised on demand.
// Does not replace the real iTAC authentication or modify vendor JARs.
async function probeJaasRuntime(lib){
boot('JAAS: UnixSystem-Klasse laden');
const UnixSystem=await lib.com.sun.security.auth.module.UnixSystem;
boot('JAAS: UnixSystem-Konstruktor (System.loadLibrary)');
const instance=await new UnixSystem();
boot('JAAS: UnixSystem.getUsername()');
const user=await instance.getUsername();
let identityOk=user==='cheerpj-client';
// CheerpJ generally passes Java String by value, but guard versions that
// expose a Java proxy instead of coercing that object with String(user).
if(!identityOk && user!=null){
try{if(typeof user.equals==='function')identityOk=(await user.equals('cheerpj-client'))===true;}
catch(_ignored){}
}
console.info('[WidgetWorkbench/CheerpJ] UnixSystem konstruiert; synthetische Benutzeridentität gültig:',identityOk);
if(!identityOk)throw Error('JAAS-Runtimeprüfung: unerwartete virtuelle Benutzeridentität');
boot('JAAS-Laufzeittest erfolgreich (UnixSystem)');
}
const trusted=(raw,base=location.href)=>{
const u=new URL(raw,base);
if(u.origin!==location.origin)throw Error('JNLP und alle JARs müssen von derselben Origin wie WidgetWorkbench kommen.');
@@ -69,74 +170,108 @@ function readManifest(xml,jnlpUrl){
* Only the immutable, locally packaged Bridge JAR is loaded; no vendor JAR is modified.
* When the JVM has not created MesSuiteFrame yet, retry for a bounded startup window.
*/
async function ensureWorkplaceTempDirectory() {
// /app is read-only and /str is read-only to Java. CheerpJ's /files mount
// supports Java writes (IndexedDB, per-browser origin). Create via Java NIO,
// not JavaScript, because JS cannot write directly into /files.
if (typeof window.cheerpjRunLibrary !== 'function')
throw Error('CheerpJ Library Mode für die Temp-Verzeichnisanlage nicht verfügbar.');
const lib=await window.cheerpjRunLibrary('');
async function ensureWorkplaceTempDirectory(lib) {
// Use Java NIO through CheerpJ Library Mode. Checking Files.isDirectory()
// with `=== true` is not reliable across CheerpJ versions: the reported
// value can be a bridge wrapper, even when the directory is writable.
// The real requirement for java.io.tmpdir is that Java can create a file.
if (!lib)throw Error('CheerpJ Library Mode für das Temp-Verzeichnis nicht verfügbar.');
const Paths=await lib.java.nio.file.Paths;
const Files=await lib.java.nio.file.Files;
const path=await Paths.get(WORKPLACE_TMP_DIR);
try {
await Files.createDirectories(path, []);
if (await Files.isDirectory(path, []) !== true)
throw Error('Pfad ist kein Verzeichnis.');
// Checking the directory alone is not enough: verify actual write access.
const probe=await Files.createTempFile(path,'hmi-tmp-check-','.tmp',[]);
await Files.deleteIfExists(probe);
} catch(error) {
throw Error('CheerpJ-Temp-Verzeichnis '+WORKPLACE_TMP_DIR+' nicht verfügbar: '+
(error instanceof Error ? error.message : String(error)));
}
}
async function attachWorkplaceResize(container, classPath, mode) {
if (typeof window.cheerpjRunLibrary !== 'function')
throw Error('CheerpJ Library Mode für die ResizeBridge nicht verfügbar.');
const lib=await window.cheerpjRunLibrary(classPath);
const bridge=await lib.com.widgetworkbench.cheerpj.WorkplaceResizeBridge;
let closed=false, inFlight=false, pending=false, lastSize='', retry=0;
let retryTimer=null;
const desired=()=>{
if(mode==='original')return [1280,1024];
const size=container.getBoundingClientRect();
return [Math.max(200,Math.floor(size.width)),Math.max(150,Math.floor(size.height))];
};
async function update(){
if(closed||inFlight){pending=true;return;}
const [width,height]=desired(), size=width+'x'+height;
if(size===lastSize && retry>=24)return;
inFlight=true;
const System=await lib.java.lang.System;
const errors=[];
for(const candidate of WORKPLACE_TMP_CANDIDATES){
try{
const found=await bridge.resize(width,height);
// The frame appears asynchronously while cheerpjRunMain is active.
if(Number(found)>0){lastSize=size;retry=24;}
const dir=await Paths.get(candidate);
if(candidate!=='/files')await Files.createDirectories(dir,[]);
// A successful write/delete is stronger proof than isDirectory() and
// works independently of Java boolean conversion in the JS bridge.
const probe=await Files.createTempFile(dir,'hmi-tmp-check-','.tmp',[]);
try{
const deleted=await Files.deleteIfExists(probe);
if(deleted===false)throw Error('Schreibtestdatei konnte nicht entfernt werden.');
}catch(cleanupError){
throw Error('Temporäre Testdatei konnte nicht gelöscht werden: '+await describeThrowable(cleanupError));
}
// Bootstrap with java.io.tmpdir=/files (always an existing mount point),
// then configure the tested directory before invoking Workplace main().
await System.setProperty('java.io.tmpdir',candidate);
return candidate;
}catch(error){
console.warn('Workplace resize bridge:',error);
retry=24;
}finally{
inFlight=false;
if(pending&&!closed){pending=false;void update();}
errors.push(candidate+': '+await describeThrowable(error));
}
}
const observer=typeof ResizeObserver!=='undefined' ? new ResizeObserver(()=>{retry=24;void update();}) : null;
observer?.observe(container);
// Retry initialization until first Workplace JFrame is shown, stop after 24 attempts.
retryTimer=setInterval(()=>{
if(closed||retry>=24){clearInterval(retryTimer);return;}
retry++;
void update();
},750);
void update();
return {stop(){closed=true;observer?.disconnect();if(retryTimer)clearInterval(retryTimer);},refresh:()=>update()};
throw Error('CheerpJ-Temp-Verzeichnis nicht beschreibbar ('+errors.join(' | ')+').');
}
// V5.10.21: Do NOT concurrently call a CheerpJ Library Mode method from
// JS timers. CheerpJ may reject the second invocation with:
// "Java code still running, check for a missing 'await'".
// The Java bridge starts ONE daemon monitor before main(), which handles
// resize and window inspection entirely inside the JVM/AWT thread domain.
// No further JS -> CheerpJ library-mode calls are made while main() runs.
async function attachWorkplaceRuntimeMonitor(container, lib, windowMode, displayMode) {
if(!lib)throw Error('CheerpJ Library Mode für Fensterüberwachung nicht verfügbar.');
const bridge=await lib.com.widgetworkbench.cheerpj.WorkplaceResizeBridge;
if(typeof bridge.startRuntimeMonitor!=='function')
throw Error('Workplace Window Monitor v4 fehlt: startRuntimeMonitor nicht vorhanden. JAR V5.10.22 prüfen.');
const panel=document.getElementById('window-diagnostics');
const output=document.getElementById('window-diagnostics-output');
const bounds=container.getBoundingClientRect();
const width=displayMode==='original'?1280:Math.max(200,Math.floor(bounds.width));
const height=displayMode==='original'?1024:Math.max(150,Math.floor(bounds.height));
// This is the LAST library-mode method call before cheerpjRunMain().
// startRuntimeMonitor returns immediately; Java then polls independently.
const started=await bridge.startRuntimeMonitor(width,height,windowMode);
if(Number(started)!==1&&Number(started)!==2)
throw Error('Workplace Window Monitor wurde nicht gestartet (Code '+(primitiveText(started)??'?')+').');
if(windowMode!=='off'){
if(panel)panel.hidden=false;
if(output)output.textContent='Java-11-Fensterdiagnose aktiv ('+windowMode+').\n'
+'Ausgabe in der Browser-Konsole: [WidgetWorkbench/WindowGeometry]\n'
+'Die Abfragen laufen im Java-Hintergrundthread, ohne parallele CheerpJ-Library-Aufrufe.\n'
+'MES_LOGIN: NOT_SEEN / CREATED_HIDDEN / VISIBLE_ONSCREEN / VISIBLE_OFFSCREEN.\n'
+'MES_LOGIN_OWNER zeigt das iTAC-Besitzerfenster; COMPONENT_TREE erfasst JInternalFrame/MyDoggy.\n'
+'Eine JAAS UnsatisfiedLinkError kann die Dialogerzeugung verhindern und wird hier NICHT umgangen.';
}
console.info('[WidgetWorkbench/WindowGeometry] Java-interner Monitor gestartet; '
+width+'x'+height+'; Modus='+windowMode+'; keine JS-Library-Polling-Aufrufe.');
return {stop(){ /* Monitor lebt als Java-Daemon bis zum Ende der JVM. */ }};
}
// Request secrets only after the JVM has initialized and immediately before
// main(). No URL/query parameters, storage or server-side password endpoint.
async function requestBrowserCredentials(requestId){
if(window.parent===window)return null; // standalone window has no trusted parent
return new Promise(resolve=>{
const waiter={requestId,resolve};credentialWaiter=waiter;
const timeout=setTimeout(()=>{
if(credentialWaiter===waiter){credentialWaiter=null;resolve(null);}
},5000);
waiter.finish=value=>{
clearTimeout(timeout);
if(credentialWaiter===waiter)credentialWaiter=null;
resolve(value);
};
window.parent.postMessage({type:'hmi-cheerpj-credential-request',requestId},location.origin);
});
}
function credentialNativeHandlers(requestId){
return {
...jaasNativeHandlers,
// Direct JNI, not System.loadLibrary(). Results contain codes only.
async Java_com_widgetworkbench_cheerpj_WorkplaceCredentialBridge_nativeReport(_lib,_self,code){
const result=Number(code);
const labels={1:'MES_LOGIN_SUCCESS',2:'MES_LOGIN_REJECTED',3:'ALREADY_AUTHENTICATED',4:'EXPIRED',5:'BRIDGE_ERROR'};
console.info('[WidgetWorkbench/WorkplaceAuth]',labels[result]||'UNKNOWN_RESULT');
if(window.parent!==window)window.parent.postMessage({type:'hmi-cheerpj-auth-result',requestId,code:result},location.origin);
}
};
}
function status(requestId,state,message){
const text=String(message).slice(0,350);
notice.textContent=text;notice.className=state==='error'?'fail':'';
parent.postMessage({type:'hmi-cheerpj-state',requestId,state,message:text},location.origin);
if(window.parent!==window)parent.postMessage({type:'hmi-cheerpj-state',requestId,state,message:text},location.origin);
}
async function start(e,data){
const id=data.requestId;
@@ -148,6 +283,11 @@ async function start(e,data){
if(![8,11,17].includes(version))throw Error('Ungültige Java-Version.');
const isWorkplace=data.workplace===true && url.pathname===WORKPLACE_MANIFEST;
const displayMode=data.displayMode==='original'?'original':'fit';
const params=new URL(location.href).searchParams;
const rawWindowMode=data.windowMode ?? params.get('windows');
const windowMode=isWorkplace && ['off','diagnose','rescue'].includes(rawWindowMode)
? rawWindowMode : (isWorkplace ? 'diagnose' : 'off');
boot('JNLP-Abruf');
status(id,'loading','JNLP wird gelesen …');
const r=await fetch(url.href,{credentials:'same-origin',redirect:'follow',cache:'no-store'});
if(!r.ok||!r.url||trusted(r.url).origin!==location.origin)throw Error('JNLP nicht abrufbar (HTTP '+r.status+').');
@@ -158,45 +298,165 @@ async function start(e,data){
if(typeof window.cheerpjInit!=='function'){
await new Promise((resolve,reject)=>{let count=0;const timer=setInterval(()=>{if(typeof window.cheerpjInit==='function'){clearInterval(timer);resolve();}else if(++count>150){clearInterval(timer);reject(Error('CheerpJ CDN nicht erreichbar oder durch CSP blockiert.'));}},100);});
}
// Keep a single JVM library context for tmp, optional JAAS diagnostics and
// ResizeBridge: CheerpJ allows only one library thread in this configuration.
const cp=manifest.paths.join(':')+(isWorkplace
? ':'+JSONP_PROVIDER_JAR+':'+JAAS_BRIDGE_JAR+':'+CREDENTIAL_BRIDGE_JAR+':'+BRIDGE_JAR : '');
const diag=new URL(location.href).searchParams.get('diagnose');
// Explicitly verify native JavaScript is delivered before VM initialization;
// a successful HTTP response alone does NOT guarantee System.loadLibrary works.
if(isWorkplace){
boot('JAAS-JavaScript abrufen');
const nativeResponse=await fetch(JAAS_JS_URL,{credentials:'same-origin',cache:'no-store'});
if(!nativeResponse.ok)throw Error('JAAS-Kompatibilitätsmodul fehlt (HTTP '+nativeResponse.status+').');
if(typeof jaasNativeHandlers?.Java_com_sun_security_auth_module_UnixSystem_getUnixInfo!=='function')
throw Error('JAAS-JavaScript enthält keine gültige UnixSystem-JNI-Implementierung.');
}
// JNLP URL query parameters are not Java system properties.
// CheerpJ 4.3 supplies -D equivalents through javaProperties.
// CheerpJ supplies -D equivalents through javaProperties.
const javaProperties=isWorkplace && manifest.clusterNodes
? ['itac.artes.clusternodes='+manifest.clusterNodes] : [];
if(isWorkplace)javaProperties.push('java.io.tmpdir='+WORKPLACE_TMP_DIR);
await window.cheerpjInit({version,status:'none',javaProperties});
// /files exists already when the Java VM initializes; choose the actual
// writable subdirectory after probing, before launching the application.
if(isWorkplace){
status(id,'loading','Virtuelles Workplace-Temp-Verzeichnis wird vorbereitet …');
await ensureWorkplaceTempDirectory();
javaProperties.push('java.io.tmpdir=/files');
// Must be present at VM initialization: UnixSystem() calls loadLibrary("jaas")
// before running its private native method getUnixInfo().
javaProperties.push('java.library.path='+JAAS_NATIVE_PATH);
}
boot('CheerpJ-Initialisierung');
await window.cheerpjInit({version,status:'none',javaProperties,
...(isWorkplace ? {natives:credentialNativeHandlers(id)} : {})});
boot('CheerpJ initialisiert');
let sharedLib=null;
if(isWorkplace){
boot('Gemeinsamen Java-Library-Kontext starten');
sharedLib=await window.cheerpjRunLibrary(cp);
status(id,'loading','Virtuelles Workplace-Temp-Verzeichnis wird vorbereitet …');
boot('Temp-Verzeichnis prüfen');
const tempDir=await ensureWorkplaceTempDirectory(sharedLib);
if(tempDir!==WORKPLACE_TMP_DIR)manifest.warnings.push('Temp-Ausweichverzeichnis: '+tempDir+'.');
}
boot('Java-Anzeigefläche vorbereiten');
if(isWorkplace && displayMode==='original'){
document.body.classList.add('cheerpj-original-mode');
window.cheerpjCreateDisplay(1280,1024,screen);
}else{
window.cheerpjCreateDisplay(-1,-1,screen);
}
let resizeBridge=null;
let cp=manifest.paths.join(':');
let windowMonitor=null;
if(isWorkplace){
cp+=':'+BRIDGE_JAR;
// Range probe catches a missing WAR-bundled provider (or server-side
// Range misconfiguration) before Java reports opaque ExceptionInInitializerError.
boot('JSON-P-JAR prüfen');
const jsonpProbe=await fetch(JSONP_PROVIDER_URL,{
credentials:'same-origin',cache:'no-store',headers:{Range:'bytes=0-0'}
});
if(jsonpProbe.status!==206){
throw Error('JSON-P-Provider im WAR fehlt oder unterstützt kein HTTP Range '
+'(HTTP '+jsonpProbe.status+'). Maven-Build und '
+'hmi/cheerpj-libs/javax.json-1.1.4.jar prüfen.');
}
// Validate the helper JAR before Java main(); the native JS module has
// already been registered via cheerpjInit({natives}) above.
boot('JAAS-Bridge-JAR prüfen');
const bridgeProbe=await fetch(JAAS_BRIDGE_JAR.slice(4),{
credentials:'same-origin',cache:'no-store',headers:{Range:'bytes=0-0'}
});
if(bridgeProbe.status!==206)throw Error('JAAS-Java-Hilfsklasse nicht als JAR abrufbar '
+'(HTTP '+bridgeProbe.status+'). hmi/cheerpj/jaas-identity-bridge.jar prüfen.');
// The vendor JNLP contains javax.json API but not its implementation.
// Keep proprietary JARs untouched; helpers are part of the shared cp.
if(diag==='jaas' || diag==='jaas-only'){
try{
await probeJaasRuntime(sharedLib);
}catch(error){
console.error('[WidgetWorkbench/CheerpJ] JAAS-Laufzeittest Original-Exception:',error);
const msg=await describeThrowable(error);
throw Error('JAAS-Laufzeittest fehlgeschlagen. '+msg+'; '
+'falls JVM_LoadLibrary oder no jaas in java.library.path gemeldet wird, '
+'liegt das Problem bereits beim nativen Library-Loader der CheerpJ-JVM.',
{cause:error});
}
if(diag==='jaas-only'){
boot('JAAS-Laufzeittest erfolgreich – kein Workplace-Start');
status(id,'finished','JAAS UnixSystem erfolgreich initialisiert. Workplace nicht gestartet (Diagnosemodus).');
return;
}
}
if(data.browserCredentials===true){
boot('Einmalige Browser-Anmeldung vorbereiten');
const credentials=await requestBrowserCredentials(id);
if(credentials){
// Probe only when a one-time offer was made. Server must support Range.
const credentialProbe=await fetch(CREDENTIAL_BRIDGE_URL,{
credentials:'same-origin',cache:'no-store',headers:{Range:'bytes=0-0'}
});
if(credentialProbe.status!==206){
status(id,'loading','Workplace-Anmeldebridge ist nicht verfügbar; normaler Login bleibt aktiv.');
}else{
try{
const authBridge=await sharedLib.com.widgetworkbench.cheerpj.WorkplaceCredentialBridge;
const accepted=await authBridge.offer(credentials.username,credentials.password,credentials.client);
if(Number(accepted)!==1)throw Error('Einmalige Anmeldung wurde von der Java-Bridge abgelehnt.');
// No success claim until the Java nativeReport callback reports code 1.
console.info('[WidgetWorkbench/WorkplaceAuth] One-shot offer accepted; waiting for PersonService');
}catch(error){
console.warn('[WidgetWorkbench/WorkplaceAuth] Übergabe fehlgeschlagen (Zugangsdaten und Exception werden nicht protokolliert).');
status(id,'loading','Workplace-Übergabe fehlgeschlagen; manueller MES-Login bleibt möglich.');
}
}
}else{
console.info('[WidgetWorkbench/WorkplaceAuth] Keine Browser-Zugangsdaten angeboten; normaler MES-Login.');
}
}
boot('Java-internen Swing-Fenstermonitor starten ('+windowMode+')');
try{
resizeBridge=await attachWorkplaceResize(screen,cp,displayMode);
windowMonitor=await attachWorkplaceRuntimeMonitor(screen,sharedLib,windowMode,displayMode);
}catch(error){
console.warn('Optional Workplace ResizeBridge unavailable:',error);
manifest.warnings.push('ResizeBridge konnte nicht gestartet werden; Anzeige bleibt nutzbar, interne Größe möglicherweise fix.');
console.warn('[WidgetWorkbench/WindowGeometry] Java-interner Monitor nicht verfügbar:',error);
manifest.warnings.push('Fenstermonitor nicht verfügbar; Workplace-Start wird fortgesetzt.');
}
}
boot('iTAC Workplace main(): '+(manifest.main?'Startklasse vorhanden':'JAR-Start'));
status(id,'running','Java-Anwendungsstart wird versucht. '+manifest.warnings.join(' '));
try{
const exitCode=manifest.main
? await window.cheerpjRunMain(manifest.main,cp,...manifest.args)
: await window.cheerpjRunJar(manifest.paths[0],...manifest.args);
boot('Java main() beendet');
status(id,'finished','Anwendung beendet (Exit-Code '+exitCode+').');
}finally{resizeBridge?.stop();}
}catch(error){status(id,'error',error instanceof Error?error.message:String(error));}
}finally{windowMonitor?.stop();}
}catch(error){status(id,'error',await describeFailure(error));}
}
window.addEventListener('message',event=>{
if(event.source!==window.parent||event.origin!==location.origin)return;
const data=event.data;
if(!data||data.type!=='hmi-cheerpj-launch'||typeof data.requestId!=='string'||data.requestId.length>150)return;
void start(event,data);
if(!data||typeof data.requestId!=='string'||data.requestId.length>150)return;
if(data.type==='hmi-cheerpj-credentials'||data.type==='hmi-cheerpj-credentials-unavailable'){
const waiter=credentialWaiter;
if(!waiter||waiter.requestId!==data.requestId)return;
if(data.type==='hmi-cheerpj-credentials-unavailable'){waiter.finish(null);return;}
if(typeof data.username!=='string'||!data.username||data.username.length>120
||typeof data.password!=='string'||!data.password||data.password.length>1024
||typeof data.client!=='string'||!data.client||data.client.length>120)return;
waiter.finish({username:data.username,password:data.password,client:data.client});
return;
}
if(data.type==='hmi-cheerpj-launch')void start(event,data);
});
// Direct, full-window workplace mode. This URL is deliberately limited to the
// fixed authenticated MES JNLP bridge. No arbitrary JNLP or Java class name
// can be supplied through query parameters.
if(new URL(location.href).searchParams.get('standalone')==='workplace'){
document.body.classList.add('cheerpj-standalone');
void start(null,{
requestId:'standalone-workplace',
jnlpUrl:new URL(WORKPLACE_MANIFEST,location.href).href,
javaVersion:11,
workplace:true,
displayMode:'fit',
windowMode:new URL(location.href).searchParams.get('windows')
});
}