169 lines
14 KiB
HTML
169 lines
14 KiB
HTML
<!doctype html>
|
|
<html lang="en" data-theme="dark">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>JumPHP IDE</title>
|
|
<link rel="icon" href="img/icon.png">
|
|
<link rel="stylesheet" href="css/ide.css">
|
|
<link rel="stylesheet" href="css/designer.css">
|
|
<script>
|
|
// The start guard. It is inline on purpose: it must run even when every other script is broken. One syntax error in one module
|
|
// (0.1.78 / 0.1.79) stops app.js from loading and left a dead window with no word about it. Here, an error before the interface
|
|
// is up is shown on screen (what, which file, which line) with buttons to copy it, send it to JumPHP's developers and reload;
|
|
// PHP also gets it (log + report). Later errors only go to PHP's log.
|
|
(function () {
|
|
const fr = /^fr/i.test(navigator.language || '');
|
|
const T = fr ? {
|
|
title: "L'interface de l'IDE n'a pas pu démarrer",
|
|
why: "Un script de l'interface a une erreur. Ce n'est pas votre faute : envoyez-nous ce rapport (ou copiez-le dans un ticket), nous corrigeons.",
|
|
slow: "L'interface n'a pas fini de démarrer après 20 secondes.",
|
|
copy: 'Copier le rapport', copied: 'Copié', send: 'Envoyer le rapport', sent: 'Rapport envoyé, merci', reload: 'Recharger', nosend: 'Envoi impossible : copiez le rapport',
|
|
} : {
|
|
title: "The IDE's interface could not start",
|
|
why: 'A script of the interface has an error. It is not your fault: send us this report (or paste it in a ticket) and we fix it.',
|
|
slow: 'The interface had not finished starting after 20 seconds.',
|
|
copy: 'Copy the report', copied: 'Copied', send: 'Send the report', sent: 'Report sent, thank you', reload: 'Reload', nosend: 'Cannot send: copy the report',
|
|
};
|
|
const errors = [];
|
|
let booted = false, started = false, shown = null, forwarded = 0;
|
|
const short = (u) => String(u || '').replace(/^.*?\/(js|vendor|css)\//, '$1/').replace(/^https?:\/\/[^/]+\//, '');
|
|
const note = (kind, message, file, line, col, stack) => {
|
|
const e = { kind, message: String(message || '').slice(0, 600), file: short(file), line: line || 0, col: col || 0, stack: String(stack || '').split('\n').slice(0, 8).map(short).join('\n').slice(0, 1200) };
|
|
if (errors.some((x) => x.message === e.message && x.file === e.file && x.line === e.line)) return;
|
|
errors.push(e);
|
|
if (errors.length > 20) errors.shift();
|
|
if (!booted) { setTimeout(show, 400); } else if (forwarded++ < 20) { forward(false); }
|
|
};
|
|
const text = () => 'JumPHP IDE interface error\n' + 'page: ' + short(location.href) + '\nagent: ' + navigator.userAgent + '\nwhen: ' + new Date().toISOString() + '\n'
|
|
+ (booted ? 'after start' : 'while starting') + '\n\n' + (errors.length ? errors.map((e) => `[${e.kind}] ${e.message}\n at ${e.file}:${e.line}:${e.col}${e.stack ? '\n' + e.stack : ''}`).join('\n\n') : '(no script reported an error: the start never finished)');
|
|
const forward = (send) => {
|
|
try { window.jumphp && window.jumphp.send('ide-page-error', { errors, report: text(), page: short(location.href), booted, send }); } catch (_) { /* no PHP side (the web IDE) */ }
|
|
};
|
|
const show = () => {
|
|
if (booted) return;
|
|
const old = document.getElementById('boot-guard');
|
|
if (old) old.remove();
|
|
const box = document.createElement('div');
|
|
box.id = 'boot-guard';
|
|
box.setAttribute('style', 'position:fixed;inset:0;z-index:2147483647;background:rgba(20,21,24,.97);color:#e6e6e6;font:14px/1.5 system-ui,sans-serif;display:flex;align-items:center;justify-content:center;padding:24px');
|
|
const card = document.createElement('div');
|
|
card.setAttribute('style', 'max-width:860px;width:100%;max-height:100%;overflow:auto');
|
|
const h = document.createElement('h2'); h.textContent = T.title; h.setAttribute('style', 'margin:0 0 8px;font-size:20px;color:#ff8a80');
|
|
const p = document.createElement('p'); p.textContent = (errors.length ? '' : T.slow + ' ') + T.why; p.setAttribute('style', 'margin:0 0 12px;color:#bbb');
|
|
const pre = document.createElement('pre'); pre.textContent = text(); pre.setAttribute('style', 'background:#111;border:1px solid #333;border-radius:6px;padding:12px;white-space:pre-wrap;word-break:break-word;max-height:45vh;overflow:auto;font:12px/1.45 ui-monospace,monospace;user-select:text');
|
|
const row = document.createElement('div'); row.setAttribute('style', 'display:flex;gap:8px;margin-top:12px;flex-wrap:wrap;align-items:center');
|
|
const btn = (label, fn) => { const b = document.createElement('button'); b.textContent = label; b.setAttribute('style', 'padding:7px 14px;border-radius:6px;border:1px solid #555;background:#2d2f36;color:#eee;cursor:pointer;font:inherit'); b.onclick = () => fn(b); return b; };
|
|
const msg = document.createElement('span'); msg.setAttribute('style', 'color:#9ccc65');
|
|
row.append(
|
|
btn(T.copy, () => { const t = text(); const ok = () => { msg.textContent = T.copied; }; try { navigator.clipboard.writeText(t).then(ok, () => { const r = document.createRange(); r.selectNodeContents(pre); const s = getSelection(); s.removeAllRanges(); s.addRange(r); document.execCommand('copy'); ok(); }); } catch (_) { const r = document.createRange(); r.selectNodeContents(pre); const s = getSelection(); s.removeAllRanges(); s.addRange(r); try { document.execCommand('copy'); ok(); } catch (__) {} } }),
|
|
btn(T.send, () => { if (window.jumphp) { forward(true); msg.textContent = T.sent; } else { msg.textContent = T.nosend; } }),
|
|
btn(T.reload, () => location.reload()), msg);
|
|
card.append(h, p, pre, row); box.append(card);
|
|
(document.body || document.documentElement).append(box);
|
|
shown = box;
|
|
forward(false); // PHP writes it in the log and keeps a report for the next start
|
|
};
|
|
window.addEventListener('error', (e) => {
|
|
if (e.target && e.target !== window && (e.target.src || e.target.href)) { note('load', 'cannot load ' + (e.target.src || e.target.href), e.target.src || e.target.href, 0, 0, ''); return; }
|
|
note('error', e.message, e.filename, e.lineno, e.colno, e.error && e.error.stack);
|
|
}, true);
|
|
window.addEventListener('unhandledrejection', (e) => {
|
|
const r = e.reason;
|
|
note('promise', (r && r.message) || String(r), (r && (r.sourceURL || r.fileName)) || '', (r && (r.line || r.lineNumber)) || 0, (r && (r.column || r.columnNumber)) || 0, r && r.stack);
|
|
});
|
|
window.ideBootStarted = () => { started = true; };
|
|
window.ideBootDone = () => { booted = true; if (shown) shown.remove(); };
|
|
window.ideBootFail = (e) => note('start', (e && e.message) || String(e), (e && (e.sourceURL || e.fileName)) || '', (e && (e.line || e.lineNumber)) || 0, (e && (e.column || e.columnNumber)) || 0, e && e.stack);
|
|
setTimeout(() => { if (!started) show(); }, 20000); // app.js never ran
|
|
setTimeout(() => { if (!booted) show(); }, 120000); // it ran, and never finished
|
|
})();
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div id="app" class="app">
|
|
<header class="header" id="header">
|
|
<button class="hbtn menu-btn" id="mainMenu" data-tour="main-menu" title="Main menu (Alt+\)"></button>
|
|
<button class="hbtn" id="screenBtn" title="Screen on a phone: see and drive this computer from a phone (WebRTC)" hidden><i class="ico" data-icon="cast"></i></button>
|
|
<button class="hbtn" id="updateBtn" title="Update the IDE now (downloads the newest version, then restarts)"><i class="ico" data-icon="download"></i></button>
|
|
<button class="hbtn" id="bugBtn" title="Report a bug"><i class="ico" data-icon="bug"></i></button>
|
|
<button class="hbtn" id="shareBtn" title="Share this IDE with a phone or another computer"><i class="ico" data-icon="screen"></i></button>
|
|
<button class="hwidget" id="projectWidget" data-tour="project-widget" title="Projects"><span class="avatar-letter" id="projectLetter">J</span><span id="projectName">JumPHP IDE</span><i class="chev"></i></button>
|
|
<button class="hwidget" id="branchWidget" title="Git branches" hidden><i class="ico" data-icon="branch"></i><span id="branchName">main</span><i class="chev"></i></button>
|
|
<button class="hbtn" id="refreshProjectBtn" data-tour="refresh-project" title="Refresh the project: files, Git, Composer, scripts, the PHP index (Ctrl+Alt+Y)"><i class="ico" data-icon="refresh"></i></button>
|
|
<button class="hbtn docs-btn new-btn" id="newBtn" data-tour="new-button" title="Create something new: file, controller, entity, form, command, script… (Alt+N)"><i class="ico" data-icon="plus"></i><span id="newBtnLabel">New</span></button>
|
|
<div class="hspacer"></div>
|
|
<div class="run-widget" id="runWidget" hidden>
|
|
<button class="hwidget" id="runConfig" data-tour="run-config" title="Run configurations"><i class="ico" data-icon="play"></i><span id="runConfigName">Run</span><i class="chev"></i></button>
|
|
<button class="hbtn run" id="runBtn" data-tour="run-button" title="Run (Shift+F10)"><i class="ico" data-icon="play"></i></button>
|
|
<button class="hbtn debug" id="debugBtn" title="Debug (Shift+F9): click for the debugger menu" aria-haspopup="menu"><i class="ico" data-icon="debug"></i><span class="engine-badge" id="debugEngineBadge">X</span></button>
|
|
<button class="hbtn" id="testBtn" data-tour="test-button" title="Test (Ctrl+Shift+F10)"><i class="ico" data-icon="test"></i></button>
|
|
<button class="hbtn stop" id="stopBtn" title="Stop (Ctrl+F2)" disabled><i class="ico" data-icon="stop"></i></button>
|
|
</div>
|
|
<div class="hgroup scr-pins" id="scriptButtons" hidden></div>
|
|
<div class="hgroup" id="gitButtons" hidden>
|
|
<button class="hbtn" id="pullBtn" title="Update project (Ctrl+T)"><i class="ico" data-icon="pull"></i></button>
|
|
<button class="hbtn" id="commitBtn" title="Commit (Ctrl+K)"><i class="ico" data-icon="commit"></i></button>
|
|
<button class="hbtn" id="commitAllBtn" title="Commit everything and push (Ctrl+Alt+K)"><i class="ico" data-icon="upload"></i></button>
|
|
<button class="hbtn" id="pushBtn" title="Push (Ctrl+Shift+K)"><i class="ico" data-icon="push"></i></button>
|
|
</div>
|
|
<button class="hbtn" id="previewBtn" title="Play the game beside the code (Shift+F10)" hidden><i class="ico" data-icon="game"></i></button>
|
|
<button class="hbtn" id="publishBtn" title="Publish on jumphp.net" hidden><i class="ico" data-icon="upload"></i></button>
|
|
<button class="hbtn docs-btn" id="docBtn" data-tour="doc-button" title="Documentation of the IDE: every feature, searchable"><i class="ico" data-icon="book"></i><span>Doc</span></button>
|
|
<button class="hbtn" id="searchBtn" data-tour="search-button" title="Search Everywhere (Double Shift)"><i class="ico" data-icon="search"></i></button>
|
|
<button class="hbtn" id="settingsBtn" data-tour="settings-button" title="Settings"><i class="ico" data-icon="settings"></i></button>
|
|
<button class="huser" id="userWidget" title="Account"></button>
|
|
</header>
|
|
|
|
<div class="body" id="body">
|
|
<nav class="stripe left" id="leftStripe" data-tour="left-stripe"></nav>
|
|
<aside class="toolwindow left" id="leftPanel" data-tour="panel-left"></aside>
|
|
<div class="splitter v" id="leftSplitter"></div>
|
|
<main class="center" id="center">
|
|
<div class="editors" id="editors" data-tour="editors"></div>
|
|
<div class="splitter h" id="bottomSplitter"></div>
|
|
<section class="toolwindow bottom" id="bottomPanel" data-tour="panel-bottom"></section>
|
|
</main>
|
|
<div class="splitter v" id="rightSplitter"></div>
|
|
<aside class="toolwindow right" id="rightPanel" data-tour="panel-right"></aside>
|
|
<nav class="stripe right" id="rightStripe" data-tour="right-stripe"></nav>
|
|
</div>
|
|
|
|
<footer class="statusbar" id="statusbar" data-tour="statusbar">
|
|
<span class="sb-item" id="sbBreadcrumbs"></span>
|
|
<span class="sb-spacer"></span>
|
|
<span class="sb-item" id="sbStatus"></span>
|
|
<span class="sb-item" id="sbTask"></span>
|
|
<span class="sb-item clickable" id="sbPosition"></span>
|
|
<span class="sb-item" id="sbLanguage"></span>
|
|
<span class="sb-item clickable" id="sbEol"></span>
|
|
<span class="sb-item clickable" id="sbEncoding"></span>
|
|
<span class="sb-item clickable" id="sbBranch"></span>
|
|
<span class="sb-item clickable" id="sbReindex" data-tour="sb-reindex" title="Re-index the project and its libraries"><i class="ico" data-icon="refresh"></i></span>
|
|
<span class="sb-item clickable" id="sbNotifications" title="Notifications"><i class="ico" data-icon="bell"></i></span>
|
|
</footer>
|
|
|
|
<section class="welcome" id="welcome" hidden></section>
|
|
</div>
|
|
<div id="overlays"></div>
|
|
|
|
<script>
|
|
// Monaco's loader (AMD), served from the IDE's own folder: offline in the desktop app.
|
|
// A blob: worker (the page's origin), not a data: one: a data: worker has an opaque origin, so the AMD loader's fetch of
|
|
// vs/language/typescript/tsWorker.js (and css / json / html) is cross-origin there and fails ("Load failed"): no JS / TS completion.
|
|
window.MonacoEnvironment = {
|
|
getWorkerUrl() {
|
|
const base = new URL('vendor/monaco/', document.baseURI).href;
|
|
return URL.createObjectURL(new Blob([`self.MonacoEnvironment = {baseUrl: '${base}'}; importScripts('${base}vs/base/worker/workerMain.js');`],
|
|
{ type: 'text/javascript' }));
|
|
},
|
|
};
|
|
</script>
|
|
<!-- xterm.js (Terminal tool window): before Monaco's AMD loader, so that it defines window.Terminal -->
|
|
<link rel="stylesheet" href="vendor/xterm/xterm.css">
|
|
<script src="vendor/xterm/xterm.js"></script>
|
|
<script src="vendor/xterm/addon-fit.js"></script>
|
|
<script src="vendor/monaco/vs/loader.js"></script>
|
|
<script type="module" src="js/app.js"></script>
|
|
</body>
|
|
</html>
|