Fix JIT closure isolation, SX wire format, server diagnostics
Root cause: _env_bind_hook mirrored ALL env_bind calls (including
lambda parameter bindings) to the shared VM globals table. Factory
functions like make-page-fn that return closures capturing different
values for the same param names (default-name, prefix, suffix) would
have the last call's values overwrite all previous closures' captured
state in globals. OP_GLOBAL_GET reads globals first, so all closures
returned the last factory call's values.
Fix: only sync root-env bindings (parent=None) to VM globals. Lambda
parameter bindings stay in their local env, found via vm_closure_env
fallback in OP_GLOBAL_GET.
Also in this commit:
- OP_CLOSURE propagates parent vm_closure_env to child closures
- Remove JIT globals injection (closure vars found via env chain)
- sx_server.ml: SX-Request header → returns text/sx (aser only)
- sx_server.ml: diagnostic endpoint GET /sx/_debug/{env,eval,route}
- sx_server.ml: page helper stubs for deep page rendering
- sx_server.ml: skip client-libs/ dir (browser-only definitions)
- adapter-html.sx: unknown components → HTML comment (not error)
- sx-platform.js: .sxbc fallback loader for bytecode modules
- Delete sx_http.ml (standalone HTTP server, unused)
- Delete stale .sxbc.json files (arity=0 bug, replaced by .sxbc)
- 7 new closure isolation tests in test-closure-isolation.sx
- mcp_tree.ml: emit arity + upvalue-count in .sxbc.json output
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
// =========================================================================
|
||||
|
||||
var NIL = Object.freeze({ _nil: true, toString: function() { return "nil"; } });
|
||||
var SX_VERSION = "2026-03-28T22:04:02Z";
|
||||
var SX_VERSION = "2026-03-30T12:33:49Z";
|
||||
|
||||
function isNil(x) { return x === NIL || x === null || x === undefined; }
|
||||
function isSxTruthy(x) { return x !== false && !isNil(x); }
|
||||
@@ -1104,6 +1104,63 @@ PRIMITIVES["make-ho-setup-frame"] = makeHoSetupFrame;
|
||||
var makeCompTraceFrame = function(name, file) { return {"env": file, "type": "comp-trace", "name": name}; };
|
||||
PRIMITIVES["make-comp-trace-frame"] = makeCompTraceFrame;
|
||||
|
||||
// kont-collect-comp-trace
|
||||
var kontCollectCompTrace = function(kont) { return (isSxTruthy(isEmpty(kont)) ? [] : (function() {
|
||||
var frame = first(kont);
|
||||
return (isSxTruthy((frameType(frame) == "comp-trace")) ? cons({"file": get(frame, "file"), "name": get(frame, "name")}, kontCollectCompTrace(rest(kont))) : kontCollectCompTrace(rest(kont)));
|
||||
})()); };
|
||||
PRIMITIVES["kont-collect-comp-trace"] = kontCollectCompTrace;
|
||||
|
||||
// make-handler-frame
|
||||
var makeHandlerFrame = function(handlers, remaining, env) { return {"env": env, "type": "handler", "f": handlers, "remaining": remaining}; };
|
||||
PRIMITIVES["make-handler-frame"] = makeHandlerFrame;
|
||||
|
||||
// make-restart-frame
|
||||
var makeRestartFrame = function(restarts, remaining, env) { return {"env": env, "type": "restart", "f": restarts, "remaining": remaining}; };
|
||||
PRIMITIVES["make-restart-frame"] = makeRestartFrame;
|
||||
|
||||
// make-signal-return-frame
|
||||
var makeSignalReturnFrame = function(env, savedKont) { return {"env": env, "type": "signal-return", "f": savedKont}; };
|
||||
PRIMITIVES["make-signal-return-frame"] = makeSignalReturnFrame;
|
||||
|
||||
// find-matching-handler
|
||||
var findMatchingHandler = function(handlers, condition) { return (isSxTruthy(isEmpty(handlers)) ? NIL : (function() {
|
||||
var pair = first(handlers);
|
||||
return (function() {
|
||||
var pred = first(pair);
|
||||
var handlerFn = nth(pair, 1);
|
||||
return (isSxTruthy(cekCall(pred, [condition])) ? handlerFn : findMatchingHandler(rest(handlers), condition));
|
||||
})();
|
||||
})()); };
|
||||
PRIMITIVES["find-matching-handler"] = findMatchingHandler;
|
||||
|
||||
// kont-find-handler
|
||||
var kontFindHandler = function(kont, condition) { return (isSxTruthy(isEmpty(kont)) ? NIL : (function() {
|
||||
var frame = first(kont);
|
||||
return (isSxTruthy((frameType(frame) == "handler")) ? (function() {
|
||||
var match = findMatchingHandler(get(frame, "f"), condition);
|
||||
return (isSxTruthy(isNil(match)) ? kontFindHandler(rest(kont), condition) : match);
|
||||
})() : kontFindHandler(rest(kont), condition));
|
||||
})()); };
|
||||
PRIMITIVES["kont-find-handler"] = kontFindHandler;
|
||||
|
||||
// find-named-restart
|
||||
var findNamedRestart = function(restarts, name) { return (isSxTruthy(isEmpty(restarts)) ? NIL : (function() {
|
||||
var entry = first(restarts);
|
||||
return (isSxTruthy((first(entry) == name)) ? entry : findNamedRestart(rest(restarts), name));
|
||||
})()); };
|
||||
PRIMITIVES["find-named-restart"] = findNamedRestart;
|
||||
|
||||
// kont-find-restart
|
||||
var kontFindRestart = function(kont, name) { return (isSxTruthy(isEmpty(kont)) ? NIL : (function() {
|
||||
var frame = first(kont);
|
||||
return (isSxTruthy((frameType(frame) == "restart")) ? (function() {
|
||||
var match = findNamedRestart(get(frame, "f"), name);
|
||||
return (isSxTruthy(isNil(match)) ? kontFindRestart(rest(kont), name) : [match, frame, rest(kont)]);
|
||||
})() : kontFindRestart(rest(kont), name));
|
||||
})()); };
|
||||
PRIMITIVES["kont-find-restart"] = kontFindRestart;
|
||||
|
||||
// frame-type
|
||||
var frameType = function(f) { return get(f, "type"); };
|
||||
PRIMITIVES["frame-type"] = frameType;
|
||||
@@ -1200,7 +1257,7 @@ PRIMITIVES["*prim-param-types*"] = _primParamTypes_;
|
||||
PRIMITIVES["set-prim-param-types!"] = setPrimParamTypes_b;
|
||||
|
||||
// value-matches-type?
|
||||
var valueMatchesType_p = function(val, expectedType) { return (isSxTruthy((expectedType == "any")) ? true : (isSxTruthy((expectedType == "number")) ? isNumber(val) : (isSxTruthy((expectedType == "string")) ? isString(val) : (isSxTruthy((expectedType == "boolean")) ? boolean_p(val) : (isSxTruthy((expectedType == "nil")) ? isNil(val) : (isSxTruthy((expectedType == "list")) ? isList(val) : (isSxTruthy((expectedType == "dict")) ? isDict(val) : (isSxTruthy((expectedType == "lambda")) ? isLambda(val) : (isSxTruthy((expectedType == "symbol")) ? (typeOf(val) == "symbol") : (isSxTruthy((expectedType == "keyword")) ? (typeOf(val) == "keyword") : (isSxTruthy((isSxTruthy(isString(expectedType)) && endsWith(expectedType, "?"))) ? sxOr(isNil(val), valueMatchesType_p(val, slice(expectedType, 0, (stringLength(expectedType) - 1)))) : true))))))))))); };
|
||||
var valueMatchesType_p = function(val, expectedType) { return match(expectedType, ["any", true], ["number", isNumber(val)], ["string", isString(val)], ["boolean", boolean_p(val)], ["nil", isNil(val)], ["list", isList(val)], ["dict", isDict(val)], ["lambda", isLambda(val)], ["symbol", (typeOf(val) == "symbol")], ["keyword", (typeOf(val) == "keyword")], _((isSxTruthy((isSxTruthy(isString(expectedType)) && endsWith(expectedType, "?"))) ? sxOr(isNil(val), valueMatchesType_p(val, slice(expectedType, 0, (stringLength(expectedType) - 1)))) : true))); };
|
||||
PRIMITIVES["value-matches-type?"] = valueMatchesType_p;
|
||||
|
||||
// strict-check-args
|
||||
@@ -1334,6 +1391,9 @@ PRIMITIVES["sf-lambda"] = sfLambda;
|
||||
effectAnns[symbolName(nameSym)] = effectList;
|
||||
return envBind(env, "*effect-annotations*", effectAnns);
|
||||
})();
|
||||
}
|
||||
if (isSxTruthy(envHas(env, "*current-file*"))) {
|
||||
componentSetFile_b(comp, envGet(env, "*current-file*"));
|
||||
}
|
||||
envBind(env, symbolName(nameSym), comp);
|
||||
return comp;
|
||||
@@ -1388,6 +1448,9 @@ PRIMITIVES["parse-comp-params"] = parseCompParams;
|
||||
var hasChildren = nth(parsed, 1);
|
||||
return (function() {
|
||||
var island = makeIsland(compName, params, hasChildren, body, env);
|
||||
if (isSxTruthy(envHas(env, "*current-file*"))) {
|
||||
componentSetFile_b(island, envGet(env, "*current-file*"));
|
||||
}
|
||||
envBind(env, symbolName(nameSym), island);
|
||||
return island;
|
||||
})();
|
||||
@@ -1555,14 +1618,96 @@ PRIMITIVES["step-eval"] = stepEval;
|
||||
var args = rest(expr);
|
||||
return (isSxTruthy(!isSxTruthy(sxOr((typeOf(head) == "symbol"), (typeOf(head) == "lambda"), (typeOf(head) == "list")))) ? (isSxTruthy(isEmpty(expr)) ? makeCekValue([], env, kont) : makeCekState(first(expr), env, kontPush(makeMapFrame(NIL, rest(expr), [], env), kont))) : (isSxTruthy((typeOf(head) == "symbol")) ? (function() {
|
||||
var name = symbolName(head);
|
||||
return (isSxTruthy((name == "if")) ? stepSfIf(args, env, kont) : (isSxTruthy((name == "when")) ? stepSfWhen(args, env, kont) : (isSxTruthy((name == "cond")) ? stepSfCond(args, env, kont) : (isSxTruthy((name == "case")) ? stepSfCase(args, env, kont) : (isSxTruthy((name == "and")) ? stepSfAnd(args, env, kont) : (isSxTruthy((name == "or")) ? stepSfOr(args, env, kont) : (isSxTruthy((name == "let")) ? stepSfLet(args, env, kont) : (isSxTruthy((name == "let*")) ? stepSfLet(args, env, kont) : (isSxTruthy((name == "lambda")) ? stepSfLambda(args, env, kont) : (isSxTruthy((name == "fn")) ? stepSfLambda(args, env, kont) : (isSxTruthy((name == "define")) ? stepSfDefine(args, env, kont) : (isSxTruthy((name == "defcomp")) ? makeCekValue(sfDefcomp(args, env), env, kont) : (isSxTruthy((name == "defisland")) ? makeCekValue(sfDefisland(args, env), env, kont) : (isSxTruthy((name == "defmacro")) ? makeCekValue(sfDefmacro(args, env), env, kont) : (isSxTruthy((name == "begin")) ? stepSfBegin(args, env, kont) : (isSxTruthy((name == "do")) ? stepSfBegin(args, env, kont) : (isSxTruthy((name == "quote")) ? makeCekValue((isSxTruthy(isEmpty(args)) ? NIL : first(args)), env, kont) : (isSxTruthy((name == "quasiquote")) ? makeCekValue(qqExpand(first(args), env), env, kont) : (isSxTruthy((name == "->")) ? stepSfThreadFirst(args, env, kont) : (isSxTruthy((name == "set!")) ? stepSfSet(args, env, kont) : (isSxTruthy((name == "letrec")) ? stepSfLetrec(args, env, kont) : (isSxTruthy((name == "reset")) ? stepSfReset(args, env, kont) : (isSxTruthy((name == "shift")) ? stepSfShift(args, env, kont) : (isSxTruthy((name == "deref")) ? stepSfDeref(args, env, kont) : (isSxTruthy((name == "scope")) ? stepSfScope(args, env, kont) : (isSxTruthy((name == "provide")) ? stepSfProvide(args, env, kont) : (isSxTruthy((name == "context")) ? stepSfContext(args, env, kont) : (isSxTruthy((name == "emit!")) ? stepSfEmit(args, env, kont) : (isSxTruthy((name == "emitted")) ? stepSfEmitted(args, env, kont) : (isSxTruthy((name == "dynamic-wind")) ? makeCekValue(sfDynamicWind(args, env), env, kont) : (isSxTruthy((name == "map")) ? stepHoMap(args, env, kont) : (isSxTruthy((name == "map-indexed")) ? stepHoMapIndexed(args, env, kont) : (isSxTruthy((name == "filter")) ? stepHoFilter(args, env, kont) : (isSxTruthy((name == "reduce")) ? stepHoReduce(args, env, kont) : (isSxTruthy((name == "some")) ? stepHoSome(args, env, kont) : (isSxTruthy((name == "every?")) ? stepHoEvery(args, env, kont) : (isSxTruthy((name == "for-each")) ? stepHoForEach(args, env, kont) : (isSxTruthy(dictHas(_customSpecialForms, name)) ? makeCekValue((get(_customSpecialForms, name))(args, env), env, kont) : (isSxTruthy((isSxTruthy(envHas(env, name)) && isMacro(envGet(env, name)))) ? (function() {
|
||||
return match(name, ["if", stepSfIf(args, env, kont)], ["when", stepSfWhen(args, env, kont)], ["cond", stepSfCond(args, env, kont)], ["case", stepSfCase(args, env, kont)], ["and", stepSfAnd(args, env, kont)], ["or", stepSfOr(args, env, kont)], ["let", stepSfLet(args, env, kont)], ["let*", stepSfLet(args, env, kont)], ["lambda", stepSfLambda(args, env, kont)], ["fn", stepSfLambda(args, env, kont)], ["define", stepSfDefine(args, env, kont)], ["defcomp", makeCekValue(sfDefcomp(args, env), env, kont)], ["defisland", makeCekValue(sfDefisland(args, env), env, kont)], ["defmacro", makeCekValue(sfDefmacro(args, env), env, kont)], ["begin", stepSfBegin(args, env, kont)], ["do", stepSfBegin(args, env, kont)], ["quote", makeCekValue((isSxTruthy(isEmpty(args)) ? NIL : first(args)), env, kont)], ["quasiquote", makeCekValue(qqExpand(first(args), env), env, kont)], ["->", stepSfThreadFirst(args, env, kont)], ["set!", stepSfSet(args, env, kont)], ["letrec", stepSfLetrec(args, env, kont)], ["reset", stepSfReset(args, env, kont)], ["shift", stepSfShift(args, env, kont)], ["deref", stepSfDeref(args, env, kont)], ["scope", stepSfScope(args, env, kont)], ["provide", stepSfProvide(args, env, kont)], ["context", stepSfContext(args, env, kont)], ["emit!", stepSfEmit(args, env, kont)], ["emitted", stepSfEmitted(args, env, kont)], ["handler-bind", stepSfHandlerBind(args, env, kont)], ["restart-case", stepSfRestartCase(args, env, kont)], ["signal-condition", stepSfSignal(args, env, kont)], ["invoke-restart", stepSfInvokeRestart(args, env, kont)], ["match", stepSfMatch(args, env, kont)], ["dynamic-wind", makeCekValue(sfDynamicWind(args, env), env, kont)], ["map", stepHoMap(args, env, kont)], ["map-indexed", stepHoMapIndexed(args, env, kont)], ["filter", stepHoFilter(args, env, kont)], ["reduce", stepHoReduce(args, env, kont)], ["some", stepHoSome(args, env, kont)], ["every?", stepHoEvery(args, env, kont)], ["for-each", stepHoForEach(args, env, kont)], _((isSxTruthy(dictHas(_customSpecialForms, name)) ? makeCekValue((get(_customSpecialForms, name))(args, env), env, kont) : (isSxTruthy((isSxTruthy(envHas(env, name)) && isMacro(envGet(env, name)))) ? (function() {
|
||||
var mac = envGet(env, name);
|
||||
return makeCekState(expandMacro(mac, args, env), env, kont);
|
||||
})() : (isSxTruthy((isSxTruthy(_renderCheck) && _renderCheck(expr, env))) ? makeCekValue(_renderFn(expr, env), env, kont) : stepEvalCall(head, args, env, kont)))))))))))))))))))))))))))))))))))))))));
|
||||
})() : (isSxTruthy((isSxTruthy(_renderCheck) && _renderCheck(expr, env))) ? makeCekValue(_renderFn(expr, env), env, kont) : stepEvalCall(head, args, env, kont))))));
|
||||
})() : stepEvalCall(head, args, env, kont)));
|
||||
})(); };
|
||||
PRIMITIVES["step-eval-list"] = stepEvalList;
|
||||
|
||||
// match-find-clause
|
||||
var matchFindClause = function(val, clauses, env) { return (isSxTruthy(isEmpty(clauses)) ? NIL : (function() {
|
||||
var clause = first(clauses);
|
||||
var pattern = first(clause);
|
||||
var body = nth(clause, 1);
|
||||
var local = envExtend(env);
|
||||
return (isSxTruthy(matchPattern(pattern, val, local)) ? [local, body] : matchFindClause(val, rest(clauses), env));
|
||||
})()); };
|
||||
PRIMITIVES["match-find-clause"] = matchFindClause;
|
||||
|
||||
// match-pattern
|
||||
var matchPattern = function(pattern, value, env) { return (isSxTruthy((pattern == new Symbol("_"))) ? true : (isSxTruthy((isSxTruthy(isList(pattern)) && isSxTruthy((len(pattern) == 2)) && (first(pattern) == new Symbol("?")))) ? (function() {
|
||||
var pred = trampoline(evalExpr(nth(pattern, 1), env));
|
||||
return cekCall(pred, [value]);
|
||||
})() : (isSxTruthy((isSxTruthy(isList(pattern)) && isSxTruthy(!isSxTruthy(isEmpty(pattern))) && (first(pattern) == new Symbol("quote")))) ? (value == nth(pattern, 1)) : (isSxTruthy(symbol_p(pattern)) ? (envBind(env, symbolName(pattern), value), true) : (isSxTruthy((isSxTruthy(isList(pattern)) && isList(value))) ? (isSxTruthy(!isSxTruthy((len(pattern) == len(value)))) ? false : (function() {
|
||||
var pairs = zip(pattern, value);
|
||||
return isEvery(function(pair) { return matchPattern(first(pair), nth(pair, 1), env); }, pairs);
|
||||
})()) : (pattern == value)))))); };
|
||||
PRIMITIVES["match-pattern"] = matchPattern;
|
||||
|
||||
// step-sf-match
|
||||
var stepSfMatch = function(args, env, kont) { return (function() {
|
||||
var val = trampoline(evalExpr(first(args), env));
|
||||
var clauses = rest(args);
|
||||
return (function() {
|
||||
var result = matchFindClause(val, clauses, env);
|
||||
return (isSxTruthy(isNil(result)) ? error((String("match: no clause matched ") + String(inspect(val)))) : makeCekState(nth(result, 1), first(result), kont));
|
||||
})();
|
||||
})(); };
|
||||
PRIMITIVES["step-sf-match"] = stepSfMatch;
|
||||
|
||||
// step-sf-handler-bind
|
||||
var stepSfHandlerBind = function(args, env, kont) { return (function() {
|
||||
var handlerSpecs = first(args);
|
||||
var body = rest(args);
|
||||
var handlers = map(function(spec) { return [trampoline(evalExpr(first(spec), env)), trampoline(evalExpr(nth(spec, 1), env))]; }, handlerSpecs);
|
||||
return (isSxTruthy(isEmpty(body)) ? makeCekValue(NIL, env, kont) : makeCekState(first(body), env, kontPush(makeHandlerFrame(handlers, rest(body), env), kont)));
|
||||
})(); };
|
||||
PRIMITIVES["step-sf-handler-bind"] = stepSfHandlerBind;
|
||||
|
||||
// step-sf-restart-case
|
||||
var stepSfRestartCase = function(args, env, kont) { return (function() {
|
||||
var body = first(args);
|
||||
var restartSpecs = rest(args);
|
||||
var restarts = map(function(spec) { return [(isSxTruthy(symbol_p(first(spec))) ? symbolName(first(spec)) : first(spec)), nth(spec, 1), nth(spec, 2)]; }, restartSpecs);
|
||||
return makeCekState(body, env, kontPush(makeRestartFrame(restarts, [], env), kont));
|
||||
})(); };
|
||||
PRIMITIVES["step-sf-restart-case"] = stepSfRestartCase;
|
||||
|
||||
// step-sf-signal
|
||||
var stepSfSignal = function(args, env, kont) { return (function() {
|
||||
var condition = trampoline(evalExpr(first(args), env));
|
||||
var handlerFn = kontFindHandler(kont, condition);
|
||||
return (isSxTruthy(isNil(handlerFn)) ? error((String("Unhandled condition: ") + String(inspect(condition)))) : continueWithCall(handlerFn, [condition], env, [condition], kontPush(makeSignalReturnFrame(env, kont), kont)));
|
||||
})(); };
|
||||
PRIMITIVES["step-sf-signal"] = stepSfSignal;
|
||||
|
||||
// step-sf-invoke-restart
|
||||
var stepSfInvokeRestart = function(args, env, kont) { return (function() {
|
||||
var restartName = (function() {
|
||||
var rn = (isSxTruthy(symbol_p(first(args))) ? symbolName(first(args)) : trampoline(evalExpr(first(args), env)));
|
||||
return (isSxTruthy(symbol_p(rn)) ? symbolName(rn) : rn);
|
||||
})();
|
||||
var restartArg = (isSxTruthy((len(args) >= 2)) ? trampoline(evalExpr(nth(args, 1), env)) : NIL);
|
||||
var found = kontFindRestart(kont, restartName);
|
||||
return (isSxTruthy(isNil(found)) ? error((String("No restart named: ") + String(inspect(restartName)))) : (function() {
|
||||
var entry = first(found);
|
||||
var restartFrame = nth(found, 1);
|
||||
var restKont = nth(found, 2);
|
||||
return (function() {
|
||||
var params = nth(entry, 1);
|
||||
var body = nth(entry, 2);
|
||||
var restartEnv = envExtend(get(restartFrame, "env"));
|
||||
if (isSxTruthy(!isSxTruthy(isEmpty(params)))) {
|
||||
envBind(restartEnv, first(params), restartArg);
|
||||
}
|
||||
return makeCekState(body, restartEnv, restKont);
|
||||
})();
|
||||
})());
|
||||
})(); };
|
||||
PRIMITIVES["step-sf-invoke-restart"] = stepSfInvokeRestart;
|
||||
|
||||
// step-sf-if
|
||||
var stepSfIf = function(args, env, kont) { return makeCekState(first(args), env, kontPush(makeIfFrame(nth(args, 1), (isSxTruthy((len(args) > 2)) ? nth(args, 2) : NIL), env), kont)); };
|
||||
PRIMITIVES["step-sf-if"] = stepSfIf;
|
||||
@@ -1786,29 +1931,29 @@ PRIMITIVES["ho-swap-args"] = hoSwapArgs;
|
||||
var ordered = hoSwapArgs(hoType, evaled);
|
||||
return (function() {
|
||||
var f = first(ordered);
|
||||
return (isSxTruthy((hoType == "map")) ? (function() {
|
||||
return match(hoType, ["map", (function() {
|
||||
var coll = nth(ordered, 1);
|
||||
return (isSxTruthy(isEmpty(coll)) ? makeCekValue([], env, kont) : continueWithCall(f, [first(coll)], env, [], kontPush(makeMapFrame(f, rest(coll), [], env), kont)));
|
||||
})() : (isSxTruthy((hoType == "map-indexed")) ? (function() {
|
||||
})()], ["map-indexed", (function() {
|
||||
var coll = nth(ordered, 1);
|
||||
return (isSxTruthy(isEmpty(coll)) ? makeCekValue([], env, kont) : continueWithCall(f, [0, first(coll)], env, [], kontPush(makeMapIndexedFrame(f, rest(coll), [], env), kont)));
|
||||
})() : (isSxTruthy((hoType == "filter")) ? (function() {
|
||||
})()], ["filter", (function() {
|
||||
var coll = nth(ordered, 1);
|
||||
return (isSxTruthy(isEmpty(coll)) ? makeCekValue([], env, kont) : continueWithCall(f, [first(coll)], env, [], kontPush(makeFilterFrame(f, rest(coll), [], first(coll), env), kont)));
|
||||
})() : (isSxTruthy((hoType == "reduce")) ? (function() {
|
||||
})()], ["reduce", (function() {
|
||||
var init = nth(ordered, 1);
|
||||
var coll = nth(ordered, 2);
|
||||
return (isSxTruthy(isEmpty(coll)) ? makeCekValue(init, env, kont) : continueWithCall(f, [init, first(coll)], env, [], kontPush(makeReduceFrame(f, rest(coll), env), kont)));
|
||||
})() : (isSxTruthy((hoType == "some")) ? (function() {
|
||||
})()], ["some", (function() {
|
||||
var coll = nth(ordered, 1);
|
||||
return (isSxTruthy(isEmpty(coll)) ? makeCekValue(false, env, kont) : continueWithCall(f, [first(coll)], env, [], kontPush(makeSomeFrame(f, rest(coll), env), kont)));
|
||||
})() : (isSxTruthy((hoType == "every")) ? (function() {
|
||||
})()], ["every", (function() {
|
||||
var coll = nth(ordered, 1);
|
||||
return (isSxTruthy(isEmpty(coll)) ? makeCekValue(true, env, kont) : continueWithCall(f, [first(coll)], env, [], kontPush(makeEveryFrame(f, rest(coll), env), kont)));
|
||||
})() : (isSxTruthy((hoType == "for-each")) ? (function() {
|
||||
})()], ["for-each", (function() {
|
||||
var coll = nth(ordered, 1);
|
||||
return (isSxTruthy(isEmpty(coll)) ? makeCekValue(NIL, env, kont) : continueWithCall(f, [first(coll)], env, [], kontPush(makeForEachFrame(f, rest(coll), env), kont)));
|
||||
})() : error((String("Unknown HO type: ") + String(hoType))))))))));
|
||||
})()], _(error((String("Unknown HO type: ") + String(hoType)))));
|
||||
})();
|
||||
})(); };
|
||||
PRIMITIVES["ho-setup-dispatch"] = hoSetupDispatch;
|
||||
@@ -1850,15 +1995,15 @@ PRIMITIVES["step-ho-for-each"] = stepHoForEach;
|
||||
var frame = kontTop(kont);
|
||||
var restK = kontPop(kont);
|
||||
var ft = frameType(frame);
|
||||
return (isSxTruthy((ft == "if")) ? (isSxTruthy((isSxTruthy(value) && !isSxTruthy(isNil(value)))) ? makeCekState(get(frame, "then"), get(frame, "env"), restK) : (isSxTruthy(isNil(get(frame, "else"))) ? makeCekValue(NIL, env, restK) : makeCekState(get(frame, "else"), get(frame, "env"), restK))) : (isSxTruthy((ft == "when")) ? (isSxTruthy((isSxTruthy(value) && !isSxTruthy(isNil(value)))) ? (function() {
|
||||
return match(ft, ["if", (isSxTruthy((isSxTruthy(value) && !isSxTruthy(isNil(value)))) ? makeCekState(get(frame, "then"), get(frame, "env"), restK) : (isSxTruthy(isNil(get(frame, "else"))) ? makeCekValue(NIL, env, restK) : makeCekState(get(frame, "else"), get(frame, "env"), restK)))], ["when", (isSxTruthy((isSxTruthy(value) && !isSxTruthy(isNil(value)))) ? (function() {
|
||||
var body = get(frame, "body");
|
||||
var fenv = get(frame, "env");
|
||||
return (isSxTruthy(isEmpty(body)) ? makeCekValue(NIL, fenv, restK) : (isSxTruthy((len(body) == 1)) ? makeCekState(first(body), fenv, restK) : makeCekState(first(body), fenv, kontPush(makeBeginFrame(rest(body), fenv), restK))));
|
||||
})() : makeCekValue(NIL, env, restK)) : (isSxTruthy((ft == "begin")) ? (function() {
|
||||
})() : makeCekValue(NIL, env, restK))], ["begin", (function() {
|
||||
var remaining = get(frame, "remaining");
|
||||
var fenv = get(frame, "env");
|
||||
return (isSxTruthy(isEmpty(remaining)) ? makeCekValue(value, fenv, restK) : (isSxTruthy((len(remaining) == 1)) ? makeCekState(first(remaining), fenv, restK) : makeCekState(first(remaining), fenv, kontPush(makeBeginFrame(rest(remaining), fenv), restK))));
|
||||
})() : (isSxTruthy((ft == "let")) ? (function() {
|
||||
})()], ["let", (function() {
|
||||
var name = get(frame, "name");
|
||||
var remaining = get(frame, "remaining");
|
||||
var body = get(frame, "body");
|
||||
@@ -1869,7 +2014,7 @@ PRIMITIVES["step-ho-for-each"] = stepHoForEach;
|
||||
var vname = (isSxTruthy((typeOf(first(nextBinding)) == "symbol")) ? symbolName(first(nextBinding)) : first(nextBinding));
|
||||
return makeCekState(nth(nextBinding, 1), local, kontPush(makeLetFrame(vname, rest(remaining), body, local), restK));
|
||||
})());
|
||||
})() : (isSxTruthy((ft == "define")) ? (function() {
|
||||
})()], ["define", (function() {
|
||||
var name = get(frame, "name");
|
||||
var fenv = get(frame, "env");
|
||||
var hasEffects = get(frame, "has-effects");
|
||||
@@ -1880,25 +2025,25 @@ PRIMITIVES["step-ho-for-each"] = stepHoForEach;
|
||||
envBind(fenv, name, value);
|
||||
if (isSxTruthy(hasEffects)) {
|
||||
(function() {
|
||||
var effectNames = (isSxTruthy((typeOf(effectList) == "list")) ? map(function(e) { return (isSxTruthy((typeOf(e) == "symbol")) ? symbolName(e) : (String(e))); }, effectList) : [(String(effectList))]);
|
||||
var effectNames = map(function(e) { return (isSxTruthy((typeOf(e) == "symbol")) ? symbolName(e) : e); }, effectList);
|
||||
var effectAnns = (isSxTruthy(envHas(fenv, "*effect-annotations*")) ? envGet(fenv, "*effect-annotations*") : {});
|
||||
effectAnns[name] = effectNames;
|
||||
return envBind(fenv, "*effect-annotations*", effectAnns);
|
||||
})();
|
||||
}
|
||||
return makeCekValue(value, fenv, restK);
|
||||
})() : (isSxTruthy((ft == "set")) ? (function() {
|
||||
})()], ["set", (function() {
|
||||
var name = get(frame, "name");
|
||||
var fenv = get(frame, "env");
|
||||
envSet(fenv, name, value);
|
||||
return makeCekValue(value, env, restK);
|
||||
})() : (isSxTruthy((ft == "and")) ? (isSxTruthy(!isSxTruthy(value)) ? makeCekValue(value, env, restK) : (function() {
|
||||
})()], ["and", (isSxTruthy(!isSxTruthy(value)) ? makeCekValue(value, env, restK) : (function() {
|
||||
var remaining = get(frame, "remaining");
|
||||
return (isSxTruthy(isEmpty(remaining)) ? makeCekValue(value, env, restK) : makeCekState(first(remaining), get(frame, "env"), (isSxTruthy((len(remaining) == 1)) ? restK : kontPush(makeAndFrame(rest(remaining), get(frame, "env")), restK))));
|
||||
})()) : (isSxTruthy((ft == "or")) ? (isSxTruthy(value) ? makeCekValue(value, env, restK) : (function() {
|
||||
})())], ["or", (isSxTruthy(value) ? makeCekValue(value, env, restK) : (function() {
|
||||
var remaining = get(frame, "remaining");
|
||||
return (isSxTruthy(isEmpty(remaining)) ? makeCekValue(false, env, restK) : makeCekState(first(remaining), get(frame, "env"), (isSxTruthy((len(remaining) == 1)) ? restK : kontPush(makeOrFrame(rest(remaining), get(frame, "env")), restK))));
|
||||
})()) : (isSxTruthy((ft == "cond")) ? (function() {
|
||||
})())], ["cond", (function() {
|
||||
var remaining = get(frame, "remaining");
|
||||
var fenv = get(frame, "env");
|
||||
var scheme_p = get(frame, "scheme");
|
||||
@@ -1910,18 +2055,18 @@ PRIMITIVES["step-ho-for-each"] = stepHoForEach;
|
||||
return (isSxTruthy(isElseClause(nextTest)) ? makeCekState(nth(nextClause, 1), fenv, restK) : makeCekState(nextTest, fenv, kontPush(makeCondFrame(nextClauses, fenv, true), restK)));
|
||||
})());
|
||||
})()) : (isSxTruthy(value) ? makeCekState(nth(remaining, 1), fenv, restK) : (function() {
|
||||
var next = slice(remaining, 2);
|
||||
var next = slice(remaining, 2, len(remaining));
|
||||
return (isSxTruthy((len(next) < 2)) ? makeCekValue(NIL, fenv, restK) : (function() {
|
||||
var nextTest = first(next);
|
||||
return (isSxTruthy(isElseClause(nextTest)) ? makeCekState(nth(next, 1), fenv, restK) : makeCekState(nextTest, fenv, kontPush(makeCondFrame(next, fenv, false), restK)));
|
||||
})());
|
||||
})()));
|
||||
})() : (isSxTruthy((ft == "case")) ? (function() {
|
||||
})()], ["case", (function() {
|
||||
var matchVal = get(frame, "match-val");
|
||||
var remaining = get(frame, "remaining");
|
||||
var fenv = get(frame, "env");
|
||||
return (isSxTruthy(isNil(matchVal)) ? sfCaseStepLoop(value, remaining, fenv, restK) : sfCaseStepLoop(matchVal, remaining, fenv, restK));
|
||||
})() : (isSxTruthy((ft == "thread")) ? (function() {
|
||||
})()], ["thread", (function() {
|
||||
var remaining = get(frame, "remaining");
|
||||
var fenv = get(frame, "env");
|
||||
return (isSxTruthy(isEmpty(remaining)) ? makeCekValue(value, fenv, restK) : (function() {
|
||||
@@ -1929,19 +2074,11 @@ PRIMITIVES["step-ho-for-each"] = stepHoForEach;
|
||||
var restForms = rest(remaining);
|
||||
var newKont = (isSxTruthy(isEmpty(rest(remaining))) ? restK : kontPush(makeThreadFrame(rest(remaining), fenv), restK));
|
||||
return (isSxTruthy((isSxTruthy((typeOf(form) == "list")) && isSxTruthy(!isSxTruthy(isEmpty(form))) && isSxTruthy((typeOf(first(form)) == "symbol")) && hoFormName_p(symbolName(first(form))))) ? makeCekState(cons(first(form), cons([new Symbol("quote"), value], rest(form))), fenv, newKont) : (function() {
|
||||
var result = (isSxTruthy((typeOf(form) == "list")) ? (function() {
|
||||
var f = trampoline(evalExpr(first(form), fenv));
|
||||
var rargs = map(function(a) { return trampoline(evalExpr(a, fenv)); }, rest(form));
|
||||
var allArgs = cons(value, rargs);
|
||||
return (isSxTruthy((isSxTruthy(isCallable(f)) && !isSxTruthy(isLambda(f)))) ? apply(f, allArgs) : (isSxTruthy(isLambda(f)) ? trampoline(callLambda(f, allArgs, fenv)) : error((String("-> form not callable: ") + String(inspect(f))))));
|
||||
})() : (function() {
|
||||
var f = trampoline(evalExpr(form, fenv));
|
||||
return (isSxTruthy((isSxTruthy(isCallable(f)) && !isSxTruthy(isLambda(f)))) ? f(value) : (isSxTruthy(isLambda(f)) ? trampoline(callLambda(f, [value], fenv)) : error((String("-> form not callable: ") + String(inspect(f))))));
|
||||
})());
|
||||
var result = threadInsertArg(form, value, fenv);
|
||||
return (isSxTruthy(isEmpty(restForms)) ? makeCekValue(result, fenv, restK) : makeCekValue(result, fenv, kontPush(makeThreadFrame(restForms, fenv), restK)));
|
||||
})());
|
||||
})());
|
||||
})() : (isSxTruthy((ft == "arg")) ? (function() {
|
||||
})()], ["arg", (function() {
|
||||
var f = get(frame, "f");
|
||||
var evaled = get(frame, "evaled");
|
||||
var remaining = get(frame, "remaining");
|
||||
@@ -1952,7 +2089,7 @@ PRIMITIVES["step-ho-for-each"] = stepHoForEach;
|
||||
var newEvaled = append(evaled, [value]);
|
||||
return (isSxTruthy(isEmpty(remaining)) ? ((isSxTruthy((isSxTruthy(_strict_) && hname)) ? strictCheckArgs(hname, newEvaled) : NIL), continueWithCall(f, newEvaled, fenv, rawArgs, restK)) : makeCekState(first(remaining), fenv, kontPush(makeArgFrame(f, newEvaled, rest(remaining), fenv, rawArgs, hname), restK)));
|
||||
})());
|
||||
})() : (isSxTruthy((ft == "dict")) ? (function() {
|
||||
})()], ["dict", (function() {
|
||||
var remaining = get(frame, "remaining");
|
||||
var results = get(frame, "results");
|
||||
var fenv = get(frame, "env");
|
||||
@@ -1968,48 +2105,48 @@ PRIMITIVES["step-ho-for-each"] = stepHoForEach;
|
||||
return makeCekState(nth(nextEntry, 1), fenv, kontPush(makeDictFrame(rest(remaining), append(completed, [[first(nextEntry)]]), fenv), restK));
|
||||
})());
|
||||
})();
|
||||
})() : (isSxTruthy((ft == "ho-setup")) ? (function() {
|
||||
})()], ["ho-setup", (function() {
|
||||
var hoType = get(frame, "ho-type");
|
||||
var remaining = get(frame, "remaining");
|
||||
var evaled = append(get(frame, "evaled"), [value]);
|
||||
var fenv = get(frame, "env");
|
||||
return (isSxTruthy(isEmpty(remaining)) ? hoSetupDispatch(hoType, evaled, fenv, restK) : makeCekState(first(remaining), fenv, kontPush(makeHoSetupFrame(hoType, rest(remaining), evaled, fenv), restK)));
|
||||
})() : (isSxTruthy((ft == "reset")) ? makeCekValue(value, env, restK) : (isSxTruthy((ft == "deref")) ? (function() {
|
||||
var val = value;
|
||||
})()], ["reset", makeCekValue(value, env, restK)], ["deref", (function() {
|
||||
var val = get(frame, "value");
|
||||
var fenv = get(frame, "env");
|
||||
return (isSxTruthy(!isSxTruthy(isSignal(val))) ? makeCekValue(val, fenv, restK) : (isSxTruthy(hasReactiveResetFrame_p(restK)) ? reactiveShiftDeref(val, fenv, restK) : ((function() {
|
||||
var ctx = sxContext("sx-reactive", NIL);
|
||||
var ctx = getTrackingContext();
|
||||
return (isSxTruthy(ctx) ? (function() {
|
||||
var depList = get(ctx, "deps");
|
||||
var notifyFn = get(ctx, "notify");
|
||||
return (isSxTruthy(!isSxTruthy(contains(depList, val))) ? (append_b(depList, val), signalAddSub(val, notifyFn)) : NIL);
|
||||
})() : NIL);
|
||||
})(), makeCekValue(signalValue(val), fenv, restK))));
|
||||
})() : (isSxTruthy((ft == "reactive-reset")) ? (function() {
|
||||
})()], ["reactive-reset", (function() {
|
||||
var updateFn = get(frame, "update-fn");
|
||||
var first_p = get(frame, "first-render");
|
||||
if (isSxTruthy((isSxTruthy(updateFn) && !isSxTruthy(first_p)))) {
|
||||
cekCall(updateFn, [value]);
|
||||
}
|
||||
return makeCekValue(value, env, restK);
|
||||
})() : (isSxTruthy((ft == "scope")) ? (function() {
|
||||
})()], ["scope", (function() {
|
||||
var name = get(frame, "name");
|
||||
var remaining = get(frame, "remaining");
|
||||
var fenv = get(frame, "env");
|
||||
return (isSxTruthy(isEmpty(remaining)) ? (scopePop(name), makeCekValue(value, fenv, restK)) : makeCekState(first(remaining), fenv, kontPush(makeScopeFrame(name, rest(remaining), fenv), restK)));
|
||||
})() : (isSxTruthy((ft == "provide")) ? (function() {
|
||||
})()], ["provide", (function() {
|
||||
var remaining = get(frame, "remaining");
|
||||
var fenv = get(frame, "env");
|
||||
return (isSxTruthy(isEmpty(remaining)) ? makeCekValue(value, fenv, restK) : makeCekState(first(remaining), fenv, kontPush(makeProvideFrame(get(frame, "name"), get(frame, "value"), rest(remaining), fenv), restK)));
|
||||
})() : (isSxTruthy((ft == "scope-acc")) ? (function() {
|
||||
})()], ["scope-acc", (function() {
|
||||
var remaining = get(frame, "remaining");
|
||||
var fenv = get(frame, "env");
|
||||
return (isSxTruthy(isEmpty(remaining)) ? makeCekValue(value, fenv, restK) : makeCekState(first(remaining), fenv, kontPush((function() {
|
||||
var newFrame = makeScopeAccFrame(get(frame, "name"), get(frame, "value"), rest(remaining), fenv);
|
||||
var newFrame = makeScopeAccFrame(get(frame, "name"), rest(remaining), fenv);
|
||||
newFrame["emitted"] = get(frame, "emitted");
|
||||
return newFrame;
|
||||
})(), restK)));
|
||||
})() : (isSxTruthy((ft == "map")) ? (function() {
|
||||
})()], ["map", (function() {
|
||||
var f = get(frame, "f");
|
||||
var remaining = get(frame, "remaining");
|
||||
var results = get(frame, "results");
|
||||
@@ -2023,7 +2160,7 @@ PRIMITIVES["step-ho-for-each"] = stepHoForEach;
|
||||
return continueWithCall(f, callArgs, fenv, [], kontPush(nextFrame, restK));
|
||||
})());
|
||||
})();
|
||||
})() : (isSxTruthy((ft == "filter")) ? (function() {
|
||||
})()], ["filter", (function() {
|
||||
var f = get(frame, "f");
|
||||
var remaining = get(frame, "remaining");
|
||||
var results = get(frame, "results");
|
||||
@@ -2033,27 +2170,34 @@ PRIMITIVES["step-ho-for-each"] = stepHoForEach;
|
||||
var newResults = (isSxTruthy(value) ? append(results, [currentItem]) : results);
|
||||
return (isSxTruthy(isEmpty(remaining)) ? makeCekValue(newResults, fenv, restK) : continueWithCall(f, [first(remaining)], fenv, [], kontPush(makeFilterFrame(f, rest(remaining), newResults, first(remaining), fenv), restK)));
|
||||
})();
|
||||
})() : (isSxTruthy((ft == "reduce")) ? (function() {
|
||||
})()], ["reduce", (function() {
|
||||
var f = get(frame, "f");
|
||||
var remaining = get(frame, "remaining");
|
||||
var fenv = get(frame, "env");
|
||||
return (isSxTruthy(isEmpty(remaining)) ? makeCekValue(value, fenv, restK) : continueWithCall(f, [value, first(remaining)], fenv, [], kontPush(makeReduceFrame(f, rest(remaining), fenv), restK)));
|
||||
})() : (isSxTruthy((ft == "for-each")) ? (function() {
|
||||
})()], ["for-each", (function() {
|
||||
var f = get(frame, "f");
|
||||
var remaining = get(frame, "remaining");
|
||||
var fenv = get(frame, "env");
|
||||
return (isSxTruthy(isEmpty(remaining)) ? makeCekValue(NIL, fenv, restK) : continueWithCall(f, [first(remaining)], fenv, [], kontPush(makeForEachFrame(f, rest(remaining), fenv), restK)));
|
||||
})() : (isSxTruthy((ft == "some")) ? (function() {
|
||||
})()], ["some", (function() {
|
||||
var f = get(frame, "f");
|
||||
var remaining = get(frame, "remaining");
|
||||
var fenv = get(frame, "env");
|
||||
return (isSxTruthy(value) ? makeCekValue(value, fenv, restK) : (isSxTruthy(isEmpty(remaining)) ? makeCekValue(false, fenv, restK) : continueWithCall(f, [first(remaining)], fenv, [], kontPush(makeSomeFrame(f, rest(remaining), fenv), restK))));
|
||||
})() : (isSxTruthy((ft == "every")) ? (function() {
|
||||
})()], ["every", (function() {
|
||||
var f = get(frame, "f");
|
||||
var remaining = get(frame, "remaining");
|
||||
var fenv = get(frame, "env");
|
||||
return (isSxTruthy(!isSxTruthy(value)) ? makeCekValue(false, fenv, restK) : (isSxTruthy(isEmpty(remaining)) ? makeCekValue(true, fenv, restK) : continueWithCall(f, [first(remaining)], fenv, [], kontPush(makeEveryFrame(f, rest(remaining), fenv), restK))));
|
||||
})() : (isSxTruthy((ft == "comp-trace")) ? makeCekValue(value, env, restK) : error((String("Unknown frame type: ") + String(ft))))))))))))))))))))))))))))));
|
||||
})()], ["handler", (function() {
|
||||
var remaining = get(frame, "remaining");
|
||||
var fenv = get(frame, "env");
|
||||
return (isSxTruthy(isEmpty(remaining)) ? makeCekValue(value, fenv, restK) : makeCekState(first(remaining), fenv, kontPush(makeHandlerFrame(get(frame, "f"), rest(remaining), fenv), restK)));
|
||||
})()], ["restart", makeCekValue(value, env, restK)], ["signal-return", (function() {
|
||||
var savedKont = get(frame, "saved-kont");
|
||||
return makeCekValue(value, get(frame, "env"), savedKont);
|
||||
})()], ["comp-trace", makeCekValue(value, env, restK)], _(error((String("Unknown frame type: ") + String(ft)))));
|
||||
})());
|
||||
})(); };
|
||||
PRIMITIVES["step-continue"] = stepContinue;
|
||||
@@ -2082,7 +2226,7 @@ PRIMITIVES["step-continue"] = stepContinue;
|
||||
if (isSxTruthy(componentHasChildren(f))) {
|
||||
envBind(local, "children", children);
|
||||
}
|
||||
return makeCekState(componentBody(f), local, kontPush(makeCompTraceFrame(componentName(f), NIL), kont));
|
||||
return makeCekState(componentBody(f), local, kontPush(makeCompTraceFrame(componentName(f), componentFile(f)), kont));
|
||||
})() : error((String("Not callable: ") + String(inspect(f)))))))); };
|
||||
PRIMITIVES["continue-with-call"] = continueWithCall;
|
||||
|
||||
@@ -2897,7 +3041,7 @@ PRIMITIVES["render-html-marsh"] = renderHtmlMarsh;
|
||||
envBind(local, "children", makeRawHtml(join("", map(function(c) { return renderToHtml(c, env); }, children))));
|
||||
}
|
||||
return (function() {
|
||||
var bodyHtml = cekTry(function() { return renderToHtml(componentBody(island), local); }, function(err) { return ""; });
|
||||
var bodyHtml = renderToHtml(componentBody(island), local);
|
||||
var stateSx = serializeIslandState(kwargs);
|
||||
return (String("<span data-sx-island=\"") + String(escapeAttr(islandName)) + String("\"") + String((isSxTruthy(stateSx) ? (String(" data-sx-state=\"") + String(escapeAttr(stateSx)) + String("\"")) : "")) + String(">") + String(bodyHtml) + String("</span>"));
|
||||
})();
|
||||
@@ -3713,7 +3857,20 @@ PRIMITIVES["render-to-dom"] = renderToDom;
|
||||
return (isSxTruthy((name == "raw!")) ? renderDomRaw(args, env) : (isSxTruthy((name == "<>")) ? renderDomFragment(args, env, ns) : (isSxTruthy((name == "lake")) ? renderDomLake(args, env, ns) : (isSxTruthy((name == "marsh")) ? renderDomMarsh(args, env, ns) : (isSxTruthy(startsWith(name, "html:")) ? renderDomElement(slice(name, 5), args, env, ns) : (isSxTruthy(isRenderDomForm(name)) ? (isSxTruthy((isSxTruthy(contains(HTML_TAGS, name)) && sxOr((isSxTruthy((len(args) > 0)) && (typeOf(first(args)) == "keyword")), ns))) ? renderDomElement(name, args, env, ns) : dispatchRenderForm(name, expr, env, ns)) : (isSxTruthy((isSxTruthy(envHas(env, name)) && isMacro(envGet(env, name)))) ? renderToDom(expandMacro(envGet(env, name), args, env), env, ns) : (isSxTruthy(contains(HTML_TAGS, name)) ? renderDomElement(name, args, env, ns) : (isSxTruthy((isSxTruthy(startsWith(name, "~")) && isSxTruthy(envHas(env, name)) && isIsland(envGet(env, name)))) ? (isSxTruthy(scopePeek("sx-render-markers")) ? (function() {
|
||||
var island = envGet(env, name);
|
||||
var marker = domCreateElement("span", NIL);
|
||||
var kwState = {};
|
||||
reduce(function(state, arg) { return (function() {
|
||||
var skip = get(state, "skip");
|
||||
return (isSxTruthy(skip) ? assoc(state, "skip", false, "i", (get(state, "i") + 1)) : (isSxTruthy((isSxTruthy((typeOf(arg) == "keyword")) && ((get(state, "i") + 1) < len(args)))) ? (function() {
|
||||
var kname = keywordName(arg);
|
||||
var kval = trampoline(evalExpr(nth(args, (get(state, "i") + 1)), env));
|
||||
kwState[kname] = kval;
|
||||
return assoc(state, "skip", true, "i", (get(state, "i") + 1));
|
||||
})() : assoc(state, "i", (get(state, "i") + 1))));
|
||||
})(); }, {["i"]: 0, ["skip"]: false}, args);
|
||||
domSetAttr(marker, "data-sx-island", componentName(island));
|
||||
if (isSxTruthy(!isSxTruthy(isEmptyDict(kwState)))) {
|
||||
domSetAttr(marker, "data-sx-state", sxSerialize(kwState));
|
||||
}
|
||||
return marker;
|
||||
})() : renderDomIsland(envGet(env, name), args, env, ns)) : (isSxTruthy(startsWith(name, "~")) ? (function() {
|
||||
var comp = envGet(env, name);
|
||||
@@ -4074,6 +4231,9 @@ PRIMITIVES["render-lambda-dom"] = renderLambdaDom;
|
||||
var container = domCreateElement("span", NIL);
|
||||
var disposers = [];
|
||||
domSetAttr(container, "data-sx-island", islandName);
|
||||
if (isSxTruthy(!isSxTruthy(isEmptyDict(kwargs)))) {
|
||||
domSetAttr(container, "data-sx-state", sxSerialize(kwargs));
|
||||
}
|
||||
markProcessed(container, "island-hydrated");
|
||||
return (function() {
|
||||
var bodyDom = withIslandScope(function(disposable) { return append_b(disposers, disposable); }, function() { return renderToDom(componentBody(island), local, ns); });
|
||||
@@ -4875,7 +5035,7 @@ return processElements(t); });
|
||||
disposeIslandsIn(target);
|
||||
return withTransition(useTransition, function() { return (function() {
|
||||
var swapResult = swapDomNodes(target, content, swapStyle);
|
||||
return postSwap(sxOr(swapResult, target));
|
||||
return postSwap((isSxTruthy((swapStyle == "outerHTML")) ? domParent(sxOr(swapResult, target)) : sxOr(swapResult, target)));
|
||||
})(); });
|
||||
})();
|
||||
})() : NIL);
|
||||
@@ -4892,8 +5052,11 @@ PRIMITIVES["handle-sx-response"] = handleSxResponse;
|
||||
disposeIslandsIn(target);
|
||||
return (isSxTruthy(selectSel) ? (function() {
|
||||
var html = selectHtmlFromDoc(doc, selectSel);
|
||||
return withTransition(useTransition, function() { swapHtmlString(target, html, swapStyle);
|
||||
return postSwap(target); });
|
||||
return withTransition(useTransition, function() { return (function() {
|
||||
var swapRoot = swapHtmlString(target, html, swapStyle);
|
||||
logInfo((String("swap-root: ") + String((isSxTruthy(swapRoot) ? domTagName(swapRoot) : "nil")) + String(" target: ") + String(domTagName(target))));
|
||||
return postSwap(sxOr(swapRoot, target));
|
||||
})(); });
|
||||
})() : (function() {
|
||||
var container = domCreateElement("div", NIL);
|
||||
domSetInnerHtml(container, domBodyInnerHtml(doc));
|
||||
@@ -5684,7 +5847,7 @@ return cekCall(hook, NIL); }, _postRenderHooks_); };
|
||||
PRIMITIVES["run-post-render-hooks"] = runPostRenderHooks;
|
||||
|
||||
// boot-init
|
||||
var bootInit = function() { return (logInfo((String("sx-browser ") + String(SX_VERSION))), initCssTracking(), processPageScripts(), processSxScripts(NIL), sxHydrateElements(NIL), sxHydrateIslands(NIL), runPostRenderHooks(), processElements(NIL), domListen(domWindow(), "popstate", function(e) { return handlePopstate(0); })); };
|
||||
var bootInit = function() { return (logInfo((String("sx-browser ") + String(SX_VERSION))), initCssTracking(), processPageScripts(), processSxScripts(NIL), sxHydrateElements(NIL), sxHydrateIslands(NIL), runPostRenderHooks(), processElements(NIL), domListen(domWindow(), "popstate", function(e) { return handlePopstate(0); }), domSetAttr(hostGet(domDocument(), "documentElement"), "data-sx-ready", "true"), domDispatch(domDocument(), "sx:ready", NIL), logInfo("sx:ready")); };
|
||||
PRIMITIVES["boot-init"] = bootInit;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user