Persist home stepper state to localStorage via freeze scope
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled

- freeze-scope "home-stepper" captures step-idx signal
- Each step/back saves to localStorage via freeze-to-sx
- On mount, restores from localStorage via thaw-from-sx
- Invalid state resets to default (step 9)
- Clear preview lake before replay to prevent duplicates
- Register local-storage-get/set/remove as primitives
- Arrows 3x bigger

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-14 23:27:46 +00:00
parent cb4f4b85e5
commit 488fc53fda
3 changed files with 50 additions and 6 deletions

View File

@@ -14,7 +14,7 @@
// =========================================================================
var NIL = Object.freeze({ _nil: true, toString: function() { return "nil"; } });
var SX_VERSION = "2026-03-14T22:48:39Z";
var SX_VERSION = "2026-03-15T00:04:32Z";
function isNil(x) { return x === NIL || x === null || x === undefined; }
function isSxTruthy(x) { return x !== false && !isNil(x); }
@@ -5757,6 +5757,20 @@ PRIMITIVES["resource"] = resource;
PRIMITIVES["is-html-tag?"] = function(n) { return HTML_TAGS.indexOf(n) >= 0; };
PRIMITIVES["make-env"] = function() { return merge(componentEnv, PRIMITIVES); };
// localStorage — defined here (before boot) so islands can use at hydration
PRIMITIVES["local-storage-get"] = function(key) {
try { var v = localStorage.getItem(key); return v === null ? NIL : v; }
catch (e) { return NIL; }
};
PRIMITIVES["local-storage-set"] = function(key, val) {
try { localStorage.setItem(key, val); } catch (e) {}
return NIL;
};
PRIMITIVES["local-storage-remove"] = function(key) {
try { localStorage.removeItem(key); } catch (e) {}
return NIL;
};
// =========================================================================
// Platform interface — DOM adapter (browser-only)
@@ -7019,6 +7033,7 @@ PRIMITIVES["resource"] = resource;
function localStorageRemove(key) {
try { localStorage.removeItem(key); } catch (e) {}
}
// localStorage primitives registered in CEK_FIXUPS_JS for ordering
// --- Cookies ---

View File

@@ -1531,6 +1531,20 @@ CEK_FIXUPS_JS = '''
PRIMITIVES["make-symbol"] = function(n) { return new Symbol(n); };
PRIMITIVES["is-html-tag?"] = function(n) { return HTML_TAGS.indexOf(n) >= 0; };
PRIMITIVES["make-env"] = function() { return merge(componentEnv, PRIMITIVES); };
// localStorage — defined here (before boot) so islands can use at hydration
PRIMITIVES["local-storage-get"] = function(key) {
try { var v = localStorage.getItem(key); return v === null ? NIL : v; }
catch (e) { return NIL; }
};
PRIMITIVES["local-storage-set"] = function(key, val) {
try { localStorage.setItem(key, val); } catch (e) {}
return NIL;
};
PRIMITIVES["local-storage-remove"] = function(key) {
try { localStorage.removeItem(key); } catch (e) {}
return NIL;
};
'''
@@ -2912,6 +2926,7 @@ PLATFORM_BOOT_JS = """
function localStorageRemove(key) {
try { localStorage.removeItem(key); } catch (e) {}
}
// localStorage primitives registered in CEK_FIXUPS_JS for ordering
// --- Cookies ---