remove redundant app wrappers
This commit is contained in:
parent
d91611947e
commit
9e2076e80d
2 changed files with 32 additions and 29 deletions
|
|
@ -3,25 +3,25 @@
|
||||||
// ============================================================
|
// ============================================================
|
||||||
|
|
||||||
// ── Client-side error logging ──────────────────────────────
|
// ── Client-side error logging ──────────────────────────────
|
||||||
(function() {
|
function sendError(data) {
|
||||||
function sendError(data) {
|
try {
|
||||||
try {
|
navigator.sendBeacon('/api/logs/client-error', new Blob(
|
||||||
navigator.sendBeacon('/api/logs/client-error', new Blob(
|
[JSON.stringify(data)], { type: 'application/json' }
|
||||||
[JSON.stringify(data)], { type: 'application/json' }
|
));
|
||||||
));
|
} catch(e) {}
|
||||||
} catch(e) {}
|
}
|
||||||
}
|
|
||||||
window.onerror = function(msg, src, line, col, err) {
|
window.onerror = function(msg, src, line, col, err) {
|
||||||
// Ignore errors from browser extensions
|
// Ignore errors from browser extensions
|
||||||
if (src && src.indexOf('moz-extension') !== -1) return;
|
if (src && src.indexOf('moz-extension') !== -1) return;
|
||||||
if (src && src.indexOf('chrome-extension') !== -1) return;
|
if (src && src.indexOf('chrome-extension') !== -1) return;
|
||||||
sendError({ type: 'uncaught', message: String(msg), source: src, line: line, col: col, stack: err && err.stack });
|
sendError({ type: 'uncaught', message: String(msg), source: src, line: line, col: col, stack: err && err.stack });
|
||||||
};
|
};
|
||||||
window.addEventListener('unhandledrejection', function(e) {
|
|
||||||
var msg = e.reason ? (e.reason.message || String(e.reason)) : 'Unhandled promise rejection';
|
window.addEventListener('unhandledrejection', function(e) {
|
||||||
sendError({ type: 'unhandledrejection', message: msg, stack: e.reason && e.reason.stack });
|
var msg = e.reason ? (e.reason.message || String(e.reason)) : 'Unhandled promise rejection';
|
||||||
});
|
sendError({ type: 'unhandledrejection', message: msg, stack: e.reason && e.reason.stack });
|
||||||
})();
|
});
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
|
||||||
|
|
@ -410,15 +410,13 @@ function loadAnnouncement() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close button — dismiss for this page view only (reappears on refresh/re-login)
|
// Close button — dismiss for this page view only (reappears on refresh/re-login)
|
||||||
(function() {
|
var closeBtn = document.getElementById('announcement-close');
|
||||||
var closeBtn = document.getElementById('announcement-close');
|
if (closeBtn) {
|
||||||
if (closeBtn) {
|
closeBtn.addEventListener('click', function() {
|
||||||
closeBtn.addEventListener('click', function() {
|
var banner = document.getElementById('announcement-banner');
|
||||||
var banner = document.getElementById('announcement-banner');
|
if (banner) banner.classList.add('hidden');
|
||||||
if (banner) banner.classList.add('hidden');
|
});
|
||||||
});
|
}
|
||||||
}
|
|
||||||
})();
|
|
||||||
|
|
||||||
function getSelectedModel() {
|
function getSelectedModel() {
|
||||||
// Prefer the active tab's own model selector if present
|
// Prefer the active tab's own model selector if present
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,11 @@ const moduleEntrypoints = [
|
||||||
'public/js/wellVisit.js'
|
'public/js/wellVisit.js'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const iifeFreeEntrypoints = [
|
||||||
|
...moduleEntrypoints,
|
||||||
|
'public/js/app.js'
|
||||||
|
];
|
||||||
|
|
||||||
function readProjectFile(relativePath) {
|
function readProjectFile(relativePath) {
|
||||||
return fs.readFileSync(path.join(__dirname, '..', relativePath), 'utf8');
|
return fs.readFileSync(path.join(__dirname, '..', relativePath), 'utf8');
|
||||||
}
|
}
|
||||||
|
|
@ -25,7 +30,7 @@ test('refactored frontend entrypoints are loaded as modules', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('refactored module entrypoints do not use redundant IIFE wrappers', () => {
|
test('refactored module entrypoints do not use redundant IIFE wrappers', () => {
|
||||||
moduleEntrypoints.forEach((entrypoint) => {
|
iifeFreeEntrypoints.forEach((entrypoint) => {
|
||||||
const source = readProjectFile(entrypoint);
|
const source = readProjectFile(entrypoint);
|
||||||
assert.doesNotMatch(source, /^\s*\(function\s*\(/m, `${entrypoint} should not open an IIFE wrapper`);
|
assert.doesNotMatch(source, /^\s*\(function\s*\(/m, `${entrypoint} should not open an IIFE wrapper`);
|
||||||
assert.doesNotMatch(source, /^\s*\}\)\(\);\s*$/m, `${entrypoint} should not close an IIFE wrapper`);
|
assert.doesNotMatch(source, /^\s*\}\)\(\);\s*$/m, `${entrypoint} should not close an IIFE wrapper`);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue