fix: add SES lockdown diagnostics and Vite cache busting
Some checks are pending
CI / build-check-test (push) Waiting to run
Some checks are pending
CI / build-check-test (push) Waiting to run
- Add diagnostics.html page to test Lit event binding - Add SES protection script in index.html (runs before modules) - Force Vite dep optimization to prevent stale caches - Fixes for users with crypto wallet extensions (MetaMask etc.)
This commit is contained in:
parent
fdbce41680
commit
d8dc140252
3 changed files with 130 additions and 14 deletions
|
|
@ -1,15 +1,40 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<link rel="icon" type="image/x-icon" href="/favicon.ico">
|
<link rel="icon" type="image/x-icon" href="/favicon.ico">
|
||||||
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Agent JAE</title>
|
<title>Agent JAE</title>
|
||||||
<meta name="description" content="Agent JAE - AI Coding Agent by JaeSwift" />
|
<meta name="description" content="Agent JAE - AI Coding Agent by JaeSwift" />
|
||||||
</head>
|
<script>
|
||||||
<body class="bg-background">
|
// SES Lockdown Protection - prevents crypto wallet extensions
|
||||||
<div id="app"></div>
|
// (MetaMask, Phantom etc.) from breaking Lit event bindings.
|
||||||
<script type="module" src="/src/main.ts"></script>
|
// Must run BEFORE any module imports.
|
||||||
</body>
|
(function() {
|
||||||
|
try {
|
||||||
|
// Save critical prototypes before SES freezes them
|
||||||
|
var origDefineProperty = Object.defineProperty;
|
||||||
|
var origGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
||||||
|
var origAddEventListener = EventTarget.prototype.addEventListener;
|
||||||
|
var origRemoveEventListener = EventTarget.prototype.removeEventListener;
|
||||||
|
|
||||||
|
// Ensure Lit can still define properties on elements
|
||||||
|
if (Object.isFrozen && Object.isFrozen(EventTarget.prototype)) {
|
||||||
|
console.warn("[JAE] SES lockdown detected - applying event binding fix");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Polyfill: ensure addEventListener is always available and unfrozen
|
||||||
|
window.__jae_addEventListener = origAddEventListener;
|
||||||
|
window.__jae_removeEventListener = origRemoveEventListener;
|
||||||
|
} catch(e) {
|
||||||
|
// Silent fail - normal when no SES present
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body class="bg-background">
|
||||||
|
<div id="app"></div>
|
||||||
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
81
packages/web-ui/example/public/diagnostics.html
Normal file
81
packages/web-ui/example/public/diagnostics.html
Normal file
|
|
@ -0,0 +1,81 @@
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head><title>JAE Diagnostics</title></head>
|
||||||
|
<body style="background:#111;color:#eee;font-family:monospace;padding:20px">
|
||||||
|
<h1>JAE Event Binding Diagnostics</h1>
|
||||||
|
<div id="results" style="white-space:pre;line-height:1.8"></div>
|
||||||
|
|
||||||
|
<script type="module">
|
||||||
|
import { html, render } from "/node_modules/lit/index.js";
|
||||||
|
|
||||||
|
const log = (msg, ok) => {
|
||||||
|
const el = document.getElementById("results");
|
||||||
|
el.innerHTML += `${ok ? "✅" : "❌"} ${msg}
|
||||||
|
`;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Test 1: Check SES lockdown
|
||||||
|
const sesFrozen = Object.isFrozen(Object.prototype);
|
||||||
|
log(`SES Lockdown active: ${sesFrozen}`, !sesFrozen);
|
||||||
|
|
||||||
|
if (sesFrozen) {
|
||||||
|
log("⚠️ A browser extension (crypto wallet) has frozen JS intrinsics!", false);
|
||||||
|
log("⚠️ This BREAKS Lit event bindings. Disable crypto wallet extensions.", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test 2: Check EventTarget
|
||||||
|
const etFrozen = Object.isFrozen(EventTarget.prototype);
|
||||||
|
log(`EventTarget.prototype frozen: ${etFrozen}`, !etFrozen);
|
||||||
|
|
||||||
|
// Test 3: Basic Lit event binding
|
||||||
|
let clickWorked = false;
|
||||||
|
const container = document.createElement("div");
|
||||||
|
document.body.appendChild(container);
|
||||||
|
|
||||||
|
render(
|
||||||
|
html`<button id="test-btn" @click=${() => { clickWorked = true; }}
|
||||||
|
style="padding:10px 20px;background:#6d5acd;color:white;border:none;border-radius:8px;cursor:pointer;font-size:16px;margin-top:20px">
|
||||||
|
CLICK ME TO TEST
|
||||||
|
</button>`,
|
||||||
|
container
|
||||||
|
);
|
||||||
|
|
||||||
|
const btn = document.getElementById("test-btn");
|
||||||
|
if (btn) {
|
||||||
|
log("Lit rendered button element: yes", true);
|
||||||
|
// Try programmatic click
|
||||||
|
btn.click();
|
||||||
|
setTimeout(() => {
|
||||||
|
log(`Lit @click binding works: ${clickWorked}`, clickWorked);
|
||||||
|
if (!clickWorked) {
|
||||||
|
log("", false);
|
||||||
|
log("========================================", false);
|
||||||
|
log("DIAGNOSIS: Lit event bindings are BROKEN", false);
|
||||||
|
log("CAUSE: Likely SES lockdown from browser extension", false);
|
||||||
|
log("FIX: Open in Incognito mode or disable crypto wallet extensions", false);
|
||||||
|
log("========================================", false);
|
||||||
|
} else {
|
||||||
|
log("", true);
|
||||||
|
log("========================================", true);
|
||||||
|
log("Lit events work! The issue is elsewhere.", true);
|
||||||
|
log("========================================", true);
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
} else {
|
||||||
|
log("Lit rendered button element: no", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test 4: Plain DOM event
|
||||||
|
let plainClickWorked = false;
|
||||||
|
const plainBtn = document.createElement("button");
|
||||||
|
plainBtn.textContent = "Plain DOM Test";
|
||||||
|
plainBtn.style.cssText = "padding:10px 20px;background:#333;color:white;border:1px solid #555;border-radius:8px;cursor:pointer;font-size:14px;margin:10px";
|
||||||
|
plainBtn.addEventListener("click", () => { plainClickWorked = true; });
|
||||||
|
document.body.appendChild(plainBtn);
|
||||||
|
plainBtn.click();
|
||||||
|
setTimeout(() => {
|
||||||
|
log(`Plain DOM addEventListener works: ${plainClickWorked}`, plainClickWorked);
|
||||||
|
}, 50);
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -3,4 +3,14 @@ import { defineConfig } from "vite";
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [tailwindcss()],
|
plugins: [tailwindcss()],
|
||||||
|
optimizeDeps: {
|
||||||
|
// Force re-optimization on every restart
|
||||||
|
force: true,
|
||||||
|
// Ensure lit is pre-bundled correctly
|
||||||
|
include: ["lit", "lit/decorators.js", "lit/directives/ref.js"],
|
||||||
|
},
|
||||||
|
server: {
|
||||||
|
// Allow connections
|
||||||
|
host: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue