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.
Files changed (2) hide show
  1. package/jsx-runtime.mjs +16 -16
  2. 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 || rc.flags.runtime & flag) && !(runtimeFlag & flag)) {
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, rc.mfs.size > 0);
360
- if (signals.store.size > 0 || rc.mcs.size > 0 || hasEffect) {
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 } = rc.flags;
375
+ const { scope, chunk } = flags;
375
376
  js += 'window.$FLAGS="' + scope + "|" + chunk + "|" + runtimeFlag + '";';
376
377
  }
377
- if (rc.mfs.size > 0) {
378
- js += rc.mfs.toJS(
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
- rc.mfs.clear();
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 (rc.mcs.size > 0) {
403
- js += rc.mcs.toJS((scope, seq, signal) => {
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
- rc.mcs.clear();
408
+ mcs.clear();
408
409
  }
409
- if (rc.session && rc.session.isDirty) {
410
- const sessionEntries = rc.session.entries();
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 (rc.extraJS.length > 0) {
446
- js += rc.extraJS.join("");
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(" + hrefLit + (replace ? ",!1" : "") + ")}else{location.href=" + hrefLit + "}"
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mono-jsx",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "`<html>` as a `Response`.",
5
5
  "type": "module",
6
6
  "module": "./index.mjs",