From 453f15628e4eadb4e0383d9ff6e0d7d1cb30832f Mon Sep 17 00:00:00 2001 From: lucas-spin Date: Fri, 12 Jun 2026 16:37:02 +0000 Subject: [PATCH] fix(playground): inject in-memory localStorage shim to fix SecurityError in sandbox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sandbox="allow-scripts" (added in PR #34) blocks real localStorage access inside the iframe, causing TypeComposer's runtime to throw: SecurityError: Failed to read the 'localStorage' property from 'Window': The document is sandboxed and lacks the 'allow-same-origin' flag. Adding allow-same-origin is not the right fix: - The iframe loads a blob: URL, which always has an opaque origin, so allow-same-origin cannot grant access to the parent page's storage anyway. - It would also weaken the sandbox comment/intent and confuse future readers. The correct fix is to shim window.localStorage and window.sessionStorage with a lightweight in-memory Map-backed implementation that is installed before any module code runs (as the first