mono-jsx 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jsx-runtime.mjs +16 -16
- package/package.json +1 -1
package/jsx-runtime.mjs
CHANGED
|
@@ -346,9 +346,10 @@ async function render(node, options, write, writeJS, componentMode, routeForm) {
|
|
|
346
346
|
};
|
|
347
347
|
signals.app = Object.assign(createThisScope(rc, 0), app);
|
|
348
348
|
const finalize = async () => {
|
|
349
|
+
const { extraJS, mfs, mcs, session, flags } = rc;
|
|
349
350
|
const hasEffect = signals.effects.length > 0;
|
|
350
351
|
const treeshake = (flag, code, force) => {
|
|
351
|
-
if ((force ||
|
|
352
|
+
if ((force || flags.runtime & flag) && !(runtimeFlag & flag)) {
|
|
352
353
|
runtimeFlag |= flag;
|
|
353
354
|
js += code;
|
|
354
355
|
}
|
|
@@ -356,8 +357,8 @@ async function render(node, options, write, writeJS, componentMode, routeForm) {
|
|
|
356
357
|
let js = "";
|
|
357
358
|
treeshake(CX, CX_JS);
|
|
358
359
|
treeshake(STYLE, STYLE_JS);
|
|
359
|
-
treeshake(EVENT, EVENT_JS,
|
|
360
|
-
if (signals.store.size > 0 ||
|
|
360
|
+
treeshake(EVENT, EVENT_JS, mfs.size > 0);
|
|
361
|
+
if (signals.store.size > 0 || mcs.size > 0 || hasEffect) {
|
|
361
362
|
treeshake(RENDER_ATTR, RENDER_ATTR_JS);
|
|
362
363
|
treeshake(RENDER_TOGGLE, RENDER_TOGGLE_JS);
|
|
363
364
|
treeshake(RENDER_SWITCH, RENDER_SWITCH_JS);
|
|
@@ -371,14 +372,14 @@ async function render(node, options, write, writeJS, componentMode, routeForm) {
|
|
|
371
372
|
js = "(()=>{" + js + "})();/* --- */";
|
|
372
373
|
}
|
|
373
374
|
if (runtimeFlag & COMPONENT || runtimeFlag & ROUTER || runtimeFlag & FORM) {
|
|
374
|
-
const { scope, chunk } =
|
|
375
|
+
const { scope, chunk } = flags;
|
|
375
376
|
js += 'window.$FLAGS="' + scope + "|" + chunk + "|" + runtimeFlag + '";';
|
|
376
377
|
}
|
|
377
|
-
if (
|
|
378
|
-
js +=
|
|
378
|
+
if (mfs.size > 0) {
|
|
379
|
+
js += mfs.toJS(
|
|
379
380
|
(scope, seq, fn) => "function $MF_" + scope + "_" + seq + "(){(" + (fn.str ?? String(fn)) + ").apply(this,arguments)};"
|
|
380
381
|
);
|
|
381
|
-
|
|
382
|
+
mfs.clear();
|
|
382
383
|
}
|
|
383
384
|
if (hasEffect) {
|
|
384
385
|
js += signals.effects.splice(0, signals.effects.length).join("");
|
|
@@ -399,15 +400,15 @@ async function render(node, options, write, writeJS, componentMode, routeForm) {
|
|
|
399
400
|
}
|
|
400
401
|
signals.store.clear();
|
|
401
402
|
}
|
|
402
|
-
if (
|
|
403
|
-
js +=
|
|
403
|
+
if (mcs.size > 0) {
|
|
404
|
+
js += mcs.toJS((scope, seq, signal) => {
|
|
404
405
|
const { compute, deps } = signal[$signal].key;
|
|
405
406
|
return "$MC(" + scope + "," + seq + ",function(){return(" + String(compute) + ").call(this)}," + stringify([...deps.values()]) + ");";
|
|
406
407
|
});
|
|
407
|
-
|
|
408
|
+
mcs.clear();
|
|
408
409
|
}
|
|
409
|
-
if (
|
|
410
|
-
const sessionEntries =
|
|
410
|
+
if (session && session.isDirty) {
|
|
411
|
+
const sessionEntries = session.entries();
|
|
411
412
|
const { name = "session", domain, path, expires, maxAge, secure, sameSite, secret } = options.session?.cookie ?? {};
|
|
412
413
|
if (secret) {
|
|
413
414
|
let cookie = name + "=";
|
|
@@ -442,8 +443,8 @@ async function render(node, options, write, writeJS, componentMode, routeForm) {
|
|
|
442
443
|
js += "document.cookie=" + toAttrStringLit(cookie) + ";";
|
|
443
444
|
}
|
|
444
445
|
}
|
|
445
|
-
if (
|
|
446
|
-
js +=
|
|
446
|
+
if (extraJS.length > 0) {
|
|
447
|
+
js += extraJS.splice(0, extraJS.length).join("");
|
|
447
448
|
}
|
|
448
449
|
if (js.length > 0) {
|
|
449
450
|
writeJS(js);
|
|
@@ -717,9 +718,8 @@ async function renderNode(rc, node, stripSlotProp) {
|
|
|
717
718
|
case "redirect": {
|
|
718
719
|
const { to, replace } = props;
|
|
719
720
|
if (to) {
|
|
720
|
-
const hrefLit = toAttrStringLit(String(to));
|
|
721
721
|
rc.extraJS.push(
|
|
722
|
-
"if(window.$router){$router.navigate(
|
|
722
|
+
'{let u=decodeURI("' + encodeURI(String(to)) + '");if(window.$router){$router.navigate(u' + (replace ? ",!1" : "") + ")}else{location.href=u}}"
|
|
723
723
|
);
|
|
724
724
|
}
|
|
725
725
|
break;
|