mono-jsx 0.0.0-alpha.13 → 0.0.0-alpha.14

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/README.md CHANGED
@@ -394,7 +394,7 @@ export default {
394
394
  };
395
395
  ```
396
396
 
397
- You can also set `rendering` attribute to control the rendering strategy of the async component. Currently, only `eager` is supported that renders the async component immediately.
397
+ You can also set `rendering` attribute to "eager" to render the async component eagerly, which means the async component will be rendered as a sync function component and the `placeholder` will be ignored.
398
398
 
399
399
  ```jsx
400
400
  async function Sleep(ms) {
package/jsx-runtime.mjs CHANGED
@@ -37,7 +37,7 @@ var computed = (fn) => {
37
37
  };
38
38
 
39
39
  // runtime/index.ts
40
- var RUNTIME_STATE_JS = "const r=Object.create(null),m=new Map,d=(t,n)=>t.getAttribute(n),h=(t,n)=>t.hasAttribute(n);function g(t,n,i,f){let l;if(n==='text')l=()=>t.textContent=''+i();else if(n==='toggle'){let s;l=()=>{if(!s){const e=t.firstElementChild;e&&e.tagName==='TEMPLATE'&&h(e,'m-slot')?(s=e.content.childNodes,t.innerHTML=''):s=t.childNodes}i()?t.append(...s):t.innerHTML=''}}else if(n==='switch'){let s=d(t,'match'),e,o,p=a=>e.get(a)??e.set(a,[]).get(a),u;l=()=>{if(!e){e=new Map,o=[];for(const a of t.childNodes)if(a.nodeType===1&&a.tagName==='TEMPLATE'&&h(a,'m-slot')){for(const c of a.content.childNodes)c.nodeType===1&&h(c,'slot')?p(d(c,'slot')).push(c):o.push(c);a.remove()}else s?p(s).push(a):o.push(a)}u=i(),t.innerHTML='',t.append(...e.has(u)?e.get(u):o)}}else if(n.length>2&&n.startsWith('[')&&n.endsWith(']')){let s=n.slice(1,-1),e=t.parentElement;e.tagName==='M-GROUP'&&(e=e.previousElementSibling),l=()=>{const o=i();o===!1?e.removeAttribute(s):(s==='class'||s==='style')&&o&&typeof o=='object'?e.setAttribute(s,s==='class'?cx(o):styleToCSS(o)):e.setAttribute(s,o===!0?'':''+o)}}if(l)for(const s of f){let e=m.get(s);e||(e=[],m.set(s,e)),e.push(l)}}function T(t,n){let i=n;Object.defineProperty(r,t,{get:()=>i,set:f=>{if(f!==i){const l=m.get(t);l&&queueMicrotask(()=>l.forEach(s=>s())),i=f}}})}customElements.define('m-state',class extends HTMLElement{connectedCallback(){const t=this,n=d(t,'mode')||'text',i=d(t,'use');i?g(t,n,()=>r[i],[i]):setTimeout(()=>{const f=t.firstChild;if(f&&f.nodeType===1&&f.type==='computed'){const l=f.textContent;l&&new Function('$state','$memo',l)(r,(s,e)=>{g(t,n,s,e)})}},0)}}),Object.assign(globalThis,{$state:r,defineState:T});";
40
+ var RUNTIME_STATE_JS = "const r=Object.create(null),m=new Map,d=(t,s)=>t.getAttribute(s),h=(t,s)=>t.hasAttribute(s);function g(t,s,i,f){let l;if(s==='text')l=()=>t.textContent=''+i();else if(s==='toggle'){let n;l=()=>{if(!n){const e=t.firstElementChild;e&&e.tagName==='TEMPLATE'&&h(e,'m-slot')?(n=e.content.childNodes,t.innerHTML=''):n=t.childNodes}i()?t.append(...n):t.innerHTML=''}}else if(s==='switch'){let n=d(t,'match'),e,o,p=a=>e.get(a)??e.set(a,[]).get(a),u;l=()=>{if(!e){e=new Map,o=[];for(const a of t.childNodes)if(a.nodeType===1&&a.tagName==='TEMPLATE'&&h(a,'m-slot')){for(const c of a.content.childNodes)c.nodeType===1&&h(c,'slot')?p(d(c,'slot')).push(c):o.push(c);a.remove()}else n?p(n).push(a):o.push(a)}u=i(),t.innerHTML='',t.append(...e.has(u)?e.get(u):o)}}else if(s.length>2&&s.startsWith('[')&&s.endsWith(']')){let n=s.slice(1,-1),e=t.parentElement;e.tagName==='M-GROUP'&&(e=e.previousElementSibling),l=()=>{const o=i();o===!1?e.removeAttribute(n):(n==='class'||n==='style')&&o&&typeof o=='object'?e.setAttribute(n,n==='class'?cx(o):styleToCSS(o)):e.setAttribute(n,o===!0?'':''+o)}}if(l)for(const n of f){let e=m.get(n);e||(e=[],m.set(n,e)),e.push(l)}}function T(t,s){let i=s;Object.defineProperty(r,t,{get:()=>i,set:f=>{if(f!==i){const l=m.get(t);l&&queueMicrotask(()=>l.forEach(n=>n())),i=f}}})}customElements.define('m-state',class extends HTMLElement{connectedCallback(){const t=this,s=d(t,'mode')??'text',i=d(t,'key');i?g(t,s,()=>r[i],[i]):setTimeout(()=>{const f=t.firstChild;if(f&&f.nodeType===1&&f.type==='computed'){const l=f.textContent;l&&new Function('$state','$',l)(r,(n,e)=>{g(t,s,n,e)})}},0)}}),Object.assign(globalThis,{$state:r,defineState:T});";
41
41
  var RUNTIME_SUSPENSE_JS = "const n={},o=e=>e.getAttribute('chunk-id');c('m-portal',e=>{n[o(e)]=e}),c('m-chunk',e=>{const t=o(e),s=n[t];s&&setTimeout(()=>{s.replaceWith(...e.firstChild.content.childNodes),delete n[t],e.remove()})});function c(e,t){customElements.define(e,class extends HTMLElement{connectedCallback(){t(this)}})}";
42
42
  var RUNTIME_COMPONENTS_JS = { "cx": "var cx=(()=>{var e=r=>typeof r=='string',n=r=>typeof r=='object'&&r!==null;function t(r){return e(r)?r:n(r)?Array.isArray(r)?r.map(t).filter(Boolean).join(' '):Object.entries(r).filter(([,o])=>!!o).map(([o])=>o).join(' '):''}return t;})();", "styleToCSS": "var styleToCSS=(()=>{var a=new Set(['animation-iteration-count','aspect-ratio','border-image-outset','border-image-slice','border-image-width','box-flex-group','box-flex','box-ordinal-group','column-count','columns','fill-opacity','flex-grow','flex-negative','flex-order','flex-positive','flex-shrink','flex','flood-opacity','font-weight','grid-area','grid-column-end','grid-column-span','grid-column-start','grid-column','grid-row-end','grid-row-span','grid-row-start','grid-row','line-clamp','line-height','opacity','order','orphans','stop-opacity','stroke-dasharray','stroke-dashoffset','stroke-miterlimit','stroke-opacity','stroke-width','tab-size','widows','z-index','zoom']),s=r=>typeof r=='string',c=r=>typeof r=='object'&&r!==null,f=r=>r.replace(/[a-z][A-Z]/g,t=>t.charAt(0)+'-'+t.charAt(1).toLowerCase());function u(r){if(s(r))return r;if(!c(r))return'';let t='';for(let[n,o]of Array.isArray(r)?r:Object.entries(r)){if(o==null||o===!1||Number.isNaN(o)||!s(n))return'';let e=f(n),i=typeof o=='number'?a.has(e)?''+o:o+'px':''+o;t+=(t!==''?';':'')+e+':'+(e==='content'?JSON.stringify(i):i)}return t}return u;})();" };
43
43
 
@@ -178,7 +178,7 @@ async function renderNode(ctx, node, stripSlotProp) {
178
178
  }
179
179
  if (tag === $state) {
180
180
  const { key, value } = props;
181
- write("<m-state use=" + toAttrStringLit(key) + ">");
181
+ write("<m-state key=" + toAttrStringLit(key) + ">");
182
182
  if (value !== void 0 && value !== null) {
183
183
  write(escapeHTML("" + value));
184
184
  }
@@ -188,7 +188,7 @@ async function renderNode(ctx, node, stripSlotProp) {
188
188
  }
189
189
  if (tag === $computed) {
190
190
  const { deps, value, fn } = props;
191
- write('<m-state><script type="computed">$memo(' + fn + "," + JSON.stringify(Object.keys(deps)) + ")<\/script>");
191
+ write('<m-state computed><script type="computed">$(' + fn + ", " + JSON.stringify(Object.keys(deps)) + ")<\/script>");
192
192
  if (value !== void 0) {
193
193
  write(escapeHTML("" + value));
194
194
  }
@@ -203,20 +203,18 @@ async function renderNode(ctx, node, stripSlotProp) {
203
203
  if (tag === "toggle") {
204
204
  if (children !== void 0) {
205
205
  const valueProp = props.value;
206
- const defaultValue = props.defaultValue;
207
206
  if (isVNode(valueProp) && valueProp[0] === $state || valueProp[0] === $computed) {
208
207
  const { key, deps, value, fn } = valueProp[1];
209
- const valueOrDefault = value ?? defaultValue;
210
208
  write(
211
- '<m-state mode="toggle" ' + (key ? "use=" + toAttrStringLit(key) : "") + ">" + (fn ? '<script type="computed">$memo(' + fn + "," + JSON.stringify(Object.keys(deps)) + ")<\/script>" : "") + (!valueOrDefault ? "<template m-slot>" : "")
209
+ '<m-state mode="toggle" ' + (key ? "key=" + toAttrStringLit(key) : "computed") + ">" + (fn ? '<script type="computed">$(' + fn + ", " + JSON.stringify(Object.keys(deps)) + ")<\/script>" : "") + (!value ? "<template m-slot>" : "")
212
210
  );
213
211
  await renderChildren(ctx, children);
214
- if (!valueOrDefault) {
212
+ if (!value) {
215
213
  write("</template>");
216
214
  }
217
215
  write("</m-state>");
218
216
  if (key) {
219
- stateStore.set(key, valueOrDefault);
217
+ stateStore.set(key, !!value);
220
218
  } else {
221
219
  for (const [key2, value2] of Object.entries(deps)) {
222
220
  if (!stateStore.has(key2)) {
@@ -224,7 +222,7 @@ async function renderNode(ctx, node, stripSlotProp) {
224
222
  }
225
223
  }
226
224
  }
227
- } else if (valueProp ?? defaultValue) {
225
+ } else if (valueProp) {
228
226
  await renderChildren(ctx, children);
229
227
  }
230
228
  }
@@ -240,9 +238,9 @@ async function renderNode(ctx, node, stripSlotProp) {
240
238
  let valueOrDefault;
241
239
  if (isVNode(valueProp) && (valueProp[0] === $state || valueProp[0] === $computed)) {
242
240
  const { key, deps, value, fn } = valueProp[1];
243
- stateful = '<m-state mode="switch" ' + (key ? "use=" + toAttrStringLit(key) : "") + ">";
241
+ stateful = '<m-state mode="switch" ' + (key ? "key=" + toAttrStringLit(key) : "computed") + ">";
244
242
  if (fn) {
245
- computed2 = '<script type="computed">$memo(' + fn + "," + JSON.stringify(deps) + ")<\/script>";
243
+ computed2 = '<script type="computed">$(' + fn + ", " + JSON.stringify(deps) + ")<\/script>";
246
244
  }
247
245
  valueOrDefault = value ?? defaultValue;
248
246
  if (key) {
@@ -340,10 +338,12 @@ async function renderNode(ctx, node, stripSlotProp) {
340
338
  await renderNode({ ...ctx, eager, slots: children }, v);
341
339
  }
342
340
  } catch (err) {
343
- if (typeof catchFC === "function") {
344
- await renderNode({ ...ctx, eager: true }, catchFC(err));
345
- } else {
346
- write('<pre style="color:red;font-size:1rem"><code>' + escapeHTML(err.stack) + "</code></pre>");
341
+ if (err instanceof Error) {
342
+ if (typeof catchFC === "function") {
343
+ await renderNode({ ...ctx, eager: true }, catchFC(err));
344
+ } else {
345
+ write('<pre style="color:red;font-size:1rem"><code>' + escapeHTML(err.stack ?? err.message) + "</code></pre>");
346
+ }
347
347
  }
348
348
  }
349
349
  break;
@@ -371,7 +371,7 @@ async function renderNode(ctx, node, stripSlotProp) {
371
371
  ctx.rtComponents.styleToCSS = true;
372
372
  }
373
373
  propEffects.push(
374
- "<m-state mode=" + toAttrStringLit("[" + propName + "]") + (key ? " use=" + toAttrStringLit(key) : "") + ">" + (fn ? '<script type="computed">$memo(' + fn + "," + JSON.stringify(Object.keys(deps)) + ")<\/script>" : "") + "</m-state>"
374
+ "<m-state mode=" + toAttrStringLit("[" + propName + "]") + (key ? " key=" + toAttrStringLit(key) : " computed") + ">" + (fn ? '<script type="computed">$(' + fn + ", " + JSON.stringify(Object.keys(deps)) + ")<\/script>" : "") + "</m-state>"
375
375
  );
376
376
  if (key) {
377
377
  ctx.stateStore.set(key, propValue[1].value);
@@ -459,7 +459,7 @@ async function renderNode(ctx, node, stripSlotProp) {
459
459
  break;
460
460
  case "action":
461
461
  if (typeof propValue === "function" && tag === "form") {
462
- const id = "$mf_" + (ctx.evtHandlerIndex++).toString(36);
462
+ const id = "$MEH_" + (ctx.evtHandlerIndex++).toString(36);
463
463
  write("<script>var " + id + "=" + propValue.toString() + "<\/script>");
464
464
  buffer += " " + renderAttr("onsubmit", "event.preventDefault();" + id + ".call(this,new FormData(this))");
465
465
  } else if (isString(propValue)) {
@@ -475,7 +475,7 @@ async function renderNode(ctx, node, stripSlotProp) {
475
475
  if (regexpHtmlTag.test(propName) && propValue !== void 0) {
476
476
  if (propName.startsWith("on")) {
477
477
  if (typeof propValue === "function") {
478
- const id = "$mf_" + (ctx.evtHandlerIndex++).toString(36);
478
+ const id = "$MEH_" + (ctx.evtHandlerIndex++).toString(36);
479
479
  write("<script>var " + id + "=" + propValue.toString() + "<\/script>");
480
480
  buffer += " " + renderAttr(propName.toLowerCase(), id + ".call(this,event)");
481
481
  }
@@ -627,6 +627,7 @@ function render(node, renderOptions = {}) {
627
627
  }
628
628
 
629
629
  // jsx-runtime.ts
630
+ var Fragment = $fragment;
630
631
  var jsx = (tag, props = /* @__PURE__ */ Object.create(null), key) => {
631
632
  const vnode = new Array(3).fill(null);
632
633
  vnode[0] = tag;
@@ -648,34 +649,34 @@ var jsx = (tag, props = /* @__PURE__ */ Object.create(null), key) => {
648
649
  }
649
650
  return vnode;
650
651
  };
651
- function jsxIcon(name, svg) {
652
+ var jsxIcon = (name, svg) => {
652
653
  const svgTagStart = svg.indexOf("<svg");
653
654
  const svgTagEnd = svg.indexOf(">", svgTagStart);
654
655
  const viewBox = svg.slice(0, svgTagEnd).match(/viewBox=['"]([^'"]+)['"]/)?.[1] ?? "";
655
656
  const iconSvg = '<svg class="icon" role="img" aria-hidden="true" style="width:auto;height:1em" fill="none" viewBox=' + JSON.stringify(viewBox) + ' xmlns="http://www.w3.org/2000/svg">' + svg.slice(svgTagEnd + 1).replace(/\n/g, "").replace(/=['"](black|#000000)['"]/g, '="currentColor"');
656
657
  $iconsRegistry.set(name.replace(/^icon-/, ""), iconSvg);
657
- }
658
- var html = (raw, ...values) => [
659
- $html,
660
- { innerHTML: String.raw({ raw }, ...values) },
661
- $vnode
662
- ];
658
+ };
663
659
  var context = () => {
664
660
  if (!Object.hasOwn($context, "request") || !Object.hasOwn($context, "data")) {
665
661
  throw new Error("calling `$context` outside of a component");
666
662
  }
667
663
  return $context;
668
664
  };
665
+ var html = (raw, ...values) => [
666
+ $html,
667
+ { innerHTML: String.raw({ raw }, ...values) },
668
+ $vnode
669
+ ];
669
670
  Object.assign(globalThis, {
670
- html,
671
- css: html,
672
- js: html,
671
+ $computed: computed,
673
672
  $context: context,
674
673
  $state: state,
675
- $computed: computed
674
+ css: html,
675
+ html,
676
+ js: html
676
677
  });
677
678
  export {
678
- $fragment as Fragment,
679
+ Fragment,
679
680
  jsx,
680
681
  jsx as jsxDEV,
681
682
  jsxIcon,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mono-jsx",
3
- "version": "0.0.0-alpha.13",
3
+ "version": "0.0.0-alpha.14",
4
4
  "description": "`<html>` as a `Response`.",
5
5
  "type": "module",
6
6
  "module": "./index.mjs",
@@ -9,18 +9,15 @@
9
9
  },
10
10
  "exports": {
11
11
  ".": {
12
- "import": "./index.mjs",
13
- "require": "./index.cjs"
12
+ "import": "./index.mjs"
14
13
  },
15
14
  "./jsx-runtime": {
16
15
  "types": "./types/jsx-runtime.d.ts",
17
- "import": "./jsx-runtime.mjs",
18
- "require": "./jsx-runtime.cjs"
16
+ "import": "./jsx-runtime.mjs"
19
17
  },
20
18
  "./jsx-dev-runtime": {
21
19
  "types": "./types/jsx-runtime.d.ts",
22
- "import": "./jsx-runtime.mjs",
23
- "require": "./jsx-runtime.cjs"
20
+ "import": "./jsx-runtime.mjs"
24
21
  }
25
22
  },
26
23
  "scripts": {
@@ -28,7 +25,6 @@
28
25
  },
29
26
  "files": [
30
27
  "*.mjs",
31
- "*.cjs",
32
28
  "./types/"
33
29
  ],
34
30
  "license": "MIT",
package/types/jsx.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // deno-lint-ignore-file no-explicit-any no-var
1
+ // deno-lint-ignore-file no-explicit-any
2
2
 
3
3
  import type * as Mono from "./mono.d.ts";
4
4
  import type { HTML } from "./html.d.ts";
package/types/mono.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- // deno-lint-ignore-file no-explicit-any no-var
1
+ // deno-lint-ignore-file no-explicit-any
2
2
 
3
3
  import type * as CSS from "./css.d.ts";
4
4
 
@@ -80,7 +80,6 @@ export interface AsyncComponentAttributes {
80
80
  export interface Elements {
81
81
  toggle: {
82
82
  value: boolean;
83
- defaultValue?: boolean;
84
83
  };
85
84
  switch: {
86
85
  value: string;
package/index.cjs DELETED
@@ -1,2 +0,0 @@
1
- // index.ts
2
- console.log("Weclome to mono-jsx!");
package/jsx-runtime.cjs DELETED
@@ -1,705 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
-
19
- // jsx-runtime.ts
20
- var jsx_runtime_exports = {};
21
- __export(jsx_runtime_exports, {
22
- Fragment: () => $fragment,
23
- jsx: () => jsx,
24
- jsxDEV: () => jsx,
25
- jsxIcon: () => jsxIcon,
26
- jsxs: () => jsx
27
- });
28
- module.exports = __toCommonJS(jsx_runtime_exports);
29
-
30
- // symbols.ts
31
- var $vnode = Symbol.for("jsx.vnode");
32
- var $fragment = Symbol.for("jsx.fragment");
33
- var $html = Symbol.for("jsx.html");
34
- var $state = Symbol.for("mono.state");
35
- var $computed = Symbol.for("mono.computed");
36
- var $iconsRegistry = /* @__PURE__ */ new Map();
37
- var $context = /* @__PURE__ */ Object.create(null);
38
-
39
- // state.ts
40
- var collectDeps;
41
- var state = new Proxy(/* @__PURE__ */ Object.create(null), {
42
- get(target, key, receiver) {
43
- const value = Reflect.get(target, key, receiver);
44
- if (typeof key === "symbol") {
45
- return value;
46
- }
47
- if (collectDeps) {
48
- collectDeps(key, value);
49
- return value;
50
- }
51
- return [$state, { key, value }, $vnode];
52
- },
53
- set(target, key, value, receiver) {
54
- const vt = typeof value;
55
- value = vt === "boolean" || vt === "number" || vt === "bigint" ? value : structuredClone(value);
56
- return Reflect.set(target, key, value, receiver);
57
- }
58
- });
59
- var computed = (fn) => {
60
- const deps = /* @__PURE__ */ Object.create(null);
61
- collectDeps = (key, value2) => deps[key] = value2;
62
- const value = fn();
63
- collectDeps = void 0;
64
- if (deps.size === 0) return value;
65
- return [$computed, { value, deps, fn: fn.toString() }, $vnode];
66
- };
67
-
68
- // runtime/index.ts
69
- var RUNTIME_STATE_JS = "const r=Object.create(null),m=new Map,d=(t,n)=>t.getAttribute(n),h=(t,n)=>t.hasAttribute(n);function g(t,n,i,f){let l;if(n==='text')l=()=>t.textContent=''+i();else if(n==='toggle'){let s;l=()=>{if(!s){const e=t.firstElementChild;e&&e.tagName==='TEMPLATE'&&h(e,'m-slot')?(s=e.content.childNodes,t.innerHTML=''):s=t.childNodes}i()?t.append(...s):t.innerHTML=''}}else if(n==='switch'){let s=d(t,'match'),e,o,p=a=>e.get(a)??e.set(a,[]).get(a),u;l=()=>{if(!e){e=new Map,o=[];for(const a of t.childNodes)if(a.nodeType===1&&a.tagName==='TEMPLATE'&&h(a,'m-slot')){for(const c of a.content.childNodes)c.nodeType===1&&h(c,'slot')?p(d(c,'slot')).push(c):o.push(c);a.remove()}else s?p(s).push(a):o.push(a)}u=i(),t.innerHTML='',t.append(...e.has(u)?e.get(u):o)}}else if(n.length>2&&n.startsWith('[')&&n.endsWith(']')){let s=n.slice(1,-1),e=t.parentElement;e.tagName==='M-GROUP'&&(e=e.previousElementSibling),l=()=>{const o=i();o===!1?e.removeAttribute(s):(s==='class'||s==='style')&&o&&typeof o=='object'?e.setAttribute(s,s==='class'?cx(o):styleToCSS(o)):e.setAttribute(s,o===!0?'':''+o)}}if(l)for(const s of f){let e=m.get(s);e||(e=[],m.set(s,e)),e.push(l)}}function T(t,n){let i=n;Object.defineProperty(r,t,{get:()=>i,set:f=>{if(f!==i){const l=m.get(t);l&&queueMicrotask(()=>l.forEach(s=>s())),i=f}}})}customElements.define('m-state',class extends HTMLElement{connectedCallback(){const t=this,n=d(t,'mode')||'text',i=d(t,'use');i?g(t,n,()=>r[i],[i]):setTimeout(()=>{const f=t.firstChild;if(f&&f.nodeType===1&&f.type==='computed'){const l=f.textContent;l&&new Function('$state','$memo',l)(r,(s,e)=>{g(t,n,s,e)})}},0)}}),Object.assign(globalThis,{$state:r,defineState:T});";
70
- var RUNTIME_SUSPENSE_JS = "const n={},o=e=>e.getAttribute('chunk-id');c('m-portal',e=>{n[o(e)]=e}),c('m-chunk',e=>{const t=o(e),s=n[t];s&&setTimeout(()=>{s.replaceWith(...e.firstChild.content.childNodes),delete n[t],e.remove()})});function c(e,t){customElements.define(e,class extends HTMLElement{connectedCallback(){t(this)}})}";
71
- var RUNTIME_COMPONENTS_JS = { "cx": "var cx=(()=>{var e=r=>typeof r=='string',n=r=>typeof r=='object'&&r!==null;function t(r){return e(r)?r:n(r)?Array.isArray(r)?r.map(t).filter(Boolean).join(' '):Object.entries(r).filter(([,o])=>!!o).map(([o])=>o).join(' '):''}return t;})();", "styleToCSS": "var styleToCSS=(()=>{var a=new Set(['animation-iteration-count','aspect-ratio','border-image-outset','border-image-slice','border-image-width','box-flex-group','box-flex','box-ordinal-group','column-count','columns','fill-opacity','flex-grow','flex-negative','flex-order','flex-positive','flex-shrink','flex','flood-opacity','font-weight','grid-area','grid-column-end','grid-column-span','grid-column-start','grid-column','grid-row-end','grid-row-span','grid-row-start','grid-row','line-clamp','line-height','opacity','order','orphans','stop-opacity','stroke-dasharray','stroke-dashoffset','stroke-miterlimit','stroke-opacity','stroke-width','tab-size','widows','z-index','zoom']),s=r=>typeof r=='string',c=r=>typeof r=='object'&&r!==null,f=r=>r.replace(/[a-z][A-Z]/g,t=>t.charAt(0)+'-'+t.charAt(1).toLowerCase());function u(r){if(s(r))return r;if(!c(r))return'';let t='';for(let[n,o]of Array.isArray(r)?r:Object.entries(r)){if(o==null||o===!1||Number.isNaN(o)||!s(n))return'';let e=f(n),i=typeof o=='number'?a.has(e)?''+o:o+'px':''+o;t+=(t!==''?';':'')+e+':'+(e==='content'?JSON.stringify(i):i)}return t}return u;})();" };
72
-
73
- // runtime/utils.ts
74
- var cssBareUnitProps = /* @__PURE__ */ new Set([
75
- "animation-iteration-count",
76
- "aspect-ratio",
77
- "border-image-outset",
78
- "border-image-slice",
79
- "border-image-width",
80
- "box-flex-group",
81
- "box-flex",
82
- "box-ordinal-group",
83
- "column-count",
84
- "columns",
85
- "fill-opacity",
86
- "flex-grow",
87
- "flex-negative",
88
- "flex-order",
89
- "flex-positive",
90
- "flex-shrink",
91
- "flex",
92
- "flood-opacity",
93
- "font-weight",
94
- "grid-area",
95
- "grid-column-end",
96
- "grid-column-span",
97
- "grid-column-start",
98
- "grid-column",
99
- "grid-row-end",
100
- "grid-row-span",
101
- "grid-row-start",
102
- "grid-row",
103
- "line-clamp",
104
- "line-height",
105
- "opacity",
106
- "order",
107
- "orphans",
108
- "stop-opacity",
109
- "stroke-dasharray",
110
- "stroke-dashoffset",
111
- "stroke-miterlimit",
112
- "stroke-opacity",
113
- "stroke-width",
114
- "tab-size",
115
- "widows",
116
- "z-index",
117
- "zoom"
118
- ]);
119
- var isString = (v) => typeof v === "string";
120
- var isObject = (v) => typeof v === "object" && v !== null;
121
- var toHyphenCase = (k) => k.replace(/[a-z][A-Z]/g, (m) => m.charAt(0) + "-" + m.charAt(1).toLowerCase());
122
- function cx(className) {
123
- if (isString(className)) {
124
- return className;
125
- }
126
- if (isObject(className)) {
127
- if (Array.isArray(className)) {
128
- return className.map(cx).filter(Boolean).join(" ");
129
- }
130
- return Object.entries(className).filter(([, v]) => !!v).map(([k]) => k).join(" ");
131
- }
132
- return "";
133
- }
134
- function styleToCSS(style) {
135
- if (isString(style)) return style;
136
- if (!isObject(style)) return "";
137
- let css = "";
138
- for (const [k, v] of Array.isArray(style) ? style : Object.entries(style)) {
139
- if (v === null || v === void 0 || v === false || Number.isNaN(v) || !isString(k)) return "";
140
- const cssKey = toHyphenCase(k);
141
- const cssValue = typeof v === "number" ? cssBareUnitProps.has(cssKey) ? "" + v : v + "px" : "" + v;
142
- css += (css !== "" ? ";" : "") + cssKey + ":" + (cssKey === "content" ? JSON.stringify(cssValue) : cssValue);
143
- }
144
- return css;
145
- }
146
-
147
- // render.ts
148
- var encoder = new TextEncoder();
149
- var regexpHtmlTag = /^[a-z][\w\-$]*$/;
150
- var regexpHtmlSafe = /["'&<>]/;
151
- var selfClosingTags = new Set("area,base,br,col,embed,hr,img,input,keygen,link,meta,param,source,track,wbr".split(","));
152
- var toAttrStringLit = (str) => JSON.stringify(escapeHTML(str));
153
- var isVNode = (v) => Array.isArray(v) && v.length === 3 && v[2] === $vnode;
154
- var hashCode = (s) => [...s].reduce((hash, c) => Math.imul(31, hash) + c.charCodeAt(0) | 0, 0);
155
- async function renderNode(ctx, node, stripSlotProp) {
156
- const { write, stateStore } = ctx;
157
- switch (typeof node) {
158
- case "string":
159
- write(escapeHTML(node));
160
- break;
161
- case "number":
162
- case "bigint":
163
- write("" + node);
164
- break;
165
- case "object":
166
- if (isVNode(node)) {
167
- let [tag, props] = node;
168
- let children = props.children;
169
- if (tag === $fragment) {
170
- if (children !== void 0) {
171
- await renderChildren(ctx, children);
172
- }
173
- break;
174
- }
175
- if (tag === $html) {
176
- if (props.innerHTML) {
177
- write(props.innerHTML);
178
- }
179
- break;
180
- }
181
- if (tag === "slot") {
182
- const ctxSlots = ctx.slots;
183
- let slots;
184
- if (ctxSlots !== void 0) {
185
- if (Array.isArray(ctxSlots)) {
186
- if (isVNode(ctxSlots)) {
187
- slots = [ctxSlots];
188
- } else {
189
- slots = ctxSlots;
190
- }
191
- } else {
192
- slots = [ctxSlots];
193
- }
194
- }
195
- if (props.name) {
196
- children = slots?.filter((v) => isVNode(v) && v[1].slot === props.name);
197
- } else {
198
- children = slots?.filter((v) => !isVNode(v) || !v[1].slot);
199
- }
200
- if (children === void 0 || Array(children) && children.length === 0) {
201
- children = node[1].children;
202
- }
203
- if (children !== void 0) {
204
- await renderChildren(ctx, children, true);
205
- }
206
- break;
207
- }
208
- if (tag === $state) {
209
- const { key, value } = props;
210
- write("<m-state use=" + toAttrStringLit(key) + ">");
211
- if (value !== void 0 && value !== null) {
212
- write(escapeHTML("" + value));
213
- }
214
- write("</m-state>");
215
- stateStore.set(key, value);
216
- break;
217
- }
218
- if (tag === $computed) {
219
- const { deps, value, fn } = props;
220
- write('<m-state><script type="computed">$memo(' + fn + "," + JSON.stringify(Object.keys(deps)) + ")<\/script>");
221
- if (value !== void 0) {
222
- write(escapeHTML("" + value));
223
- }
224
- write("</m-state>");
225
- for (const [key, value2] of Object.entries(deps)) {
226
- if (!stateStore.has(key)) {
227
- stateStore.set(key, value2);
228
- }
229
- }
230
- break;
231
- }
232
- if (tag === "toggle") {
233
- if (children !== void 0) {
234
- const valueProp = props.value;
235
- const defaultValue = props.defaultValue;
236
- if (isVNode(valueProp) && valueProp[0] === $state || valueProp[0] === $computed) {
237
- const { key, deps, value, fn } = valueProp[1];
238
- const valueOrDefault = value ?? defaultValue;
239
- write(
240
- '<m-state mode="toggle" ' + (key ? "use=" + toAttrStringLit(key) : "") + ">" + (fn ? '<script type="computed">$memo(' + fn + "," + JSON.stringify(Object.keys(deps)) + ")<\/script>" : "") + (!valueOrDefault ? "<template m-slot>" : "")
241
- );
242
- await renderChildren(ctx, children);
243
- if (!valueOrDefault) {
244
- write("</template>");
245
- }
246
- write("</m-state>");
247
- if (key) {
248
- stateStore.set(key, valueOrDefault);
249
- } else {
250
- for (const [key2, value2] of Object.entries(deps)) {
251
- if (!stateStore.has(key2)) {
252
- stateStore.set(key2, value2);
253
- }
254
- }
255
- }
256
- } else if (valueProp ?? defaultValue) {
257
- await renderChildren(ctx, children);
258
- }
259
- }
260
- break;
261
- }
262
- if (tag === "switch") {
263
- if (children !== void 0) {
264
- let slots = Array.isArray(children) ? isVNode(children) ? [children] : children : [children];
265
- let valueProp = props.value;
266
- let defaultValue = props.defaultValue;
267
- let stateful;
268
- let computed2;
269
- let valueOrDefault;
270
- if (isVNode(valueProp) && (valueProp[0] === $state || valueProp[0] === $computed)) {
271
- const { key, deps, value, fn } = valueProp[1];
272
- stateful = '<m-state mode="switch" ' + (key ? "use=" + toAttrStringLit(key) : "") + ">";
273
- if (fn) {
274
- computed2 = '<script type="computed">$memo(' + fn + "," + JSON.stringify(deps) + ")<\/script>";
275
- }
276
- valueOrDefault = value ?? defaultValue;
277
- if (key) {
278
- stateStore.set(key, valueOrDefault);
279
- } else {
280
- for (const dep of deps) {
281
- if (!stateStore.has(dep)) {
282
- stateStore.set(dep, void 0);
283
- }
284
- }
285
- }
286
- } else {
287
- valueOrDefault = valueProp ?? defaultValue;
288
- }
289
- let matchedSlot;
290
- let namedSlots = new Array(slots.length);
291
- let unnamedSlots = new Array(slots.length);
292
- for (const slot of slots) {
293
- if (!isVNode(slot) || !slot[1].slot) {
294
- unnamedSlots.push(slot);
295
- continue;
296
- }
297
- const slotName = slot[1].slot;
298
- if (slotName === valueOrDefault) {
299
- matchedSlot = [slotName, slot];
300
- } else {
301
- namedSlots.push(slot);
302
- }
303
- }
304
- if (stateful) {
305
- write(matchedSlot ? stateful.slice(0, -1) + " match=" + toAttrStringLit(matchedSlot[0]) + ">" : stateful);
306
- if (computed2) {
307
- write(computed2);
308
- }
309
- }
310
- if (matchedSlot) {
311
- await renderNode(ctx, matchedSlot[1], true);
312
- } else if (unnamedSlots.length > 0) {
313
- await renderChildren(ctx, unnamedSlots);
314
- }
315
- if (stateful) {
316
- if (namedSlots.length > 0 || matchedSlot && unnamedSlots.length > 0) {
317
- write("<template m-slot>");
318
- await renderChildren(ctx, namedSlots);
319
- if (matchedSlot && unnamedSlots.length > 0) {
320
- await renderChildren(ctx, unnamedSlots);
321
- }
322
- write("</template>");
323
- }
324
- write("</m-state>");
325
- }
326
- }
327
- break;
328
- }
329
- if (typeof tag === "function") {
330
- const { rendering, placeholder, catch: catchFC, ...fcProps } = props ?? /* @__PURE__ */ Object.create(null);
331
- let eager = ctx.eager;
332
- if ((rendering ?? tag.rendering) === "eager") {
333
- eager = true;
334
- }
335
- try {
336
- $context.request = ctx.request;
337
- $context.data = ctx.data;
338
- const v = tag(fcProps);
339
- delete $context.request;
340
- delete $context.data;
341
- if (v instanceof Promise) {
342
- if (eager) {
343
- await renderNode({ ...ctx, eager: true, slots: children }, await v);
344
- } else {
345
- const chunkId = (ctx.suspenses.length + 1).toString(36);
346
- ctx.suspenses.push(v.then(async (c) => {
347
- write('<m-chunk chunk-id="' + chunkId + '"><template>');
348
- await renderNode({ ...ctx, eager, slots: children }, c);
349
- write("</template></m-chunk>");
350
- }));
351
- write('<m-portal chunk-id="' + chunkId + '">');
352
- if (placeholder) {
353
- await renderNode({ ...ctx, eager: true }, placeholder);
354
- }
355
- write("</m-portal>");
356
- }
357
- } else if (isObject(v) && Symbol.iterator in v && !isVNode(v)) {
358
- for (const c of v) {
359
- await renderNode({ ...ctx, eager, slots: children }, c);
360
- }
361
- } else if (isObject(v) && Symbol.asyncIterator in v) {
362
- if (eager) {
363
- for await (const c of v) {
364
- await renderNode({ ...ctx, eager: true, slots: children }, c);
365
- }
366
- } else {
367
- }
368
- } else {
369
- await renderNode({ ...ctx, eager, slots: children }, v);
370
- }
371
- } catch (err) {
372
- if (typeof catchFC === "function") {
373
- await renderNode({ ...ctx, eager: true }, catchFC(err));
374
- } else {
375
- write('<pre style="color:red;font-size:1rem"><code>' + escapeHTML(err.stack) + "</code></pre>");
376
- }
377
- }
378
- break;
379
- }
380
- if (isString(tag) && regexpHtmlTag.test(tag)) {
381
- if (tag.startsWith("icon-")) {
382
- const svg = $iconsRegistry.get(tag.slice(5));
383
- if (svg) {
384
- write(svg);
385
- break;
386
- }
387
- }
388
- let buffer = "<" + tag;
389
- let propEffects = [];
390
- let onMountHandler;
391
- for (let [propName, propValue] of Object.entries(props)) {
392
- if (propName === "children") {
393
- continue;
394
- }
395
- if (isVNode(propValue) && (propValue[0] === $state || propValue[0] === $computed)) {
396
- const { key, deps, fn } = propValue[1];
397
- if (propName === "class") {
398
- ctx.rtComponents.cx = true;
399
- } else if (propName === "style") {
400
- ctx.rtComponents.styleToCSS = true;
401
- }
402
- propEffects.push(
403
- "<m-state mode=" + toAttrStringLit("[" + propName + "]") + (key ? " use=" + toAttrStringLit(key) : "") + ">" + (fn ? '<script type="computed">$memo(' + fn + "," + JSON.stringify(Object.keys(deps)) + ")<\/script>" : "") + "</m-state>"
404
- );
405
- if (key) {
406
- ctx.stateStore.set(key, propValue[1].value);
407
- } else {
408
- for (const [key2, value] of Object.entries(deps)) {
409
- if (!stateStore.has(key2)) {
410
- stateStore.set(key2, value);
411
- }
412
- }
413
- }
414
- propValue = propValue[1].value;
415
- }
416
- switch (propName) {
417
- case "class":
418
- buffer += " " + renderAttr(propName, cx(propValue));
419
- break;
420
- case "style":
421
- if (isString(propValue) && propValue !== "") {
422
- buffer += " " + renderAttr(propName, cx(propValue));
423
- } else if (isObject(propValue) && !Array.isArray(propValue)) {
424
- const style = [];
425
- const pseudoStyles = [];
426
- const atRuleStyles = [];
427
- const nestingStyles = [];
428
- for (const [k, v] of Object.entries(propValue)) {
429
- switch (k.charCodeAt(0)) {
430
- case /* ':' */
431
- 58:
432
- pseudoStyles.push([k, styleToCSS(v)]);
433
- break;
434
- case /* '@' */
435
- 64:
436
- atRuleStyles.push([k, styleToCSS(v)]);
437
- break;
438
- case /* '&' */
439
- 38:
440
- nestingStyles.push([k, styleToCSS(v)]);
441
- break;
442
- default:
443
- style.push([k, v]);
444
- }
445
- }
446
- if (pseudoStyles.length > 0 || atRuleStyles.length > 0 || nestingStyles.length > 0) {
447
- let raw = "";
448
- let css = "";
449
- let styleIds;
450
- let id;
451
- let cssSelector;
452
- let key;
453
- let value;
454
- if (style.length > 0) {
455
- css = styleToCSS(style);
456
- raw += css + "|";
457
- }
458
- raw += [pseudoStyles, atRuleStyles, nestingStyles].flat(1).map(([k, v]) => k + ">" + v).join("|");
459
- styleIds = ctx.styleIds ?? (ctx.styleIds = /* @__PURE__ */ new Set());
460
- id = hashCode(raw).toString(36);
461
- cssSelector = "[data-css-" + id + "]";
462
- if (!styleIds.has(id)) {
463
- styleIds.add(id);
464
- if (css) {
465
- css = cssSelector + "{" + css + "}";
466
- }
467
- for ([key, value] of pseudoStyles) {
468
- css += cssSelector + key + "{" + value + "}";
469
- }
470
- for ([key, value] of atRuleStyles) {
471
- css += key + "{" + cssSelector + "{" + value + "}}";
472
- }
473
- for ([key, value] of nestingStyles) {
474
- css += cssSelector + key.slice(1) + "{" + value + "}";
475
- }
476
- write('<style id="css-' + id + '">' + css + "</style>");
477
- }
478
- buffer += " data-css-" + id;
479
- } else if (style.length > 0) {
480
- buffer += " " + renderAttr(propName, styleToCSS(style));
481
- }
482
- }
483
- break;
484
- case "onMount":
485
- if (typeof propValue === "function") {
486
- onMountHandler = propValue;
487
- }
488
- break;
489
- case "action":
490
- if (typeof propValue === "function" && tag === "form") {
491
- const id = "$mf_" + (ctx.evtHandlerIndex++).toString(36);
492
- write("<script>var " + id + "=" + propValue.toString() + "<\/script>");
493
- buffer += " " + renderAttr("onsubmit", "event.preventDefault();" + id + ".call(this,new FormData(this))");
494
- } else if (isString(propValue)) {
495
- buffer += " " + renderAttr(propName, propValue);
496
- }
497
- break;
498
- case "slot":
499
- if (!stripSlotProp && isString(propValue)) {
500
- buffer += " " + renderAttr(propName, propValue);
501
- }
502
- break;
503
- default:
504
- if (regexpHtmlTag.test(propName) && propValue !== void 0) {
505
- if (propName.startsWith("on")) {
506
- if (typeof propValue === "function") {
507
- const id = "$mf_" + (ctx.evtHandlerIndex++).toString(36);
508
- write("<script>var " + id + "=" + propValue.toString() + "<\/script>");
509
- buffer += " " + renderAttr(propName.toLowerCase(), id + ".call(this,event)");
510
- }
511
- } else if (typeof propValue === "boolean") {
512
- if (propValue) {
513
- buffer += " " + propName;
514
- }
515
- } else {
516
- buffer += " " + renderAttr(propName, propValue);
517
- }
518
- }
519
- }
520
- }
521
- write(buffer + ">");
522
- if (!selfClosingTags.has(tag)) {
523
- if (propEffects.length > 0) {
524
- write(propEffects.join(""));
525
- }
526
- if (props.innerHTML) {
527
- write(props.innerHTML);
528
- } else if (children !== void 0) {
529
- await renderChildren(ctx, children);
530
- }
531
- write("</" + tag + ">");
532
- } else if (propEffects.length > 0) {
533
- write("<m-group>");
534
- write(propEffects.join(""));
535
- write("</m-group>");
536
- }
537
- if (onMountHandler) {
538
- write(
539
- "<script>{const target=document.currentScript.previousElementSibling;(" + onMountHandler.toString() + ')({type:"mount",currentTarget:target,target})}<\/script>'
540
- );
541
- }
542
- }
543
- } else if (Array.isArray(node) || node && Symbol.iterator in node) {
544
- for (const child of node) {
545
- await renderNode(ctx, child);
546
- }
547
- }
548
- break;
549
- }
550
- }
551
- async function renderChildren(ctx, children, stripSlotProp) {
552
- if (Array.isArray(children) && !isVNode(children)) {
553
- for (const child of children) {
554
- await renderNode(ctx, child, stripSlotProp);
555
- }
556
- } else {
557
- await renderNode(ctx, children, stripSlotProp);
558
- }
559
- }
560
- function renderAttr(key, value) {
561
- return value === true ? key : key + "=" + toAttrStringLit("" + value);
562
- }
563
- function escapeHTML(str) {
564
- const match = regexpHtmlSafe.exec(str);
565
- if (!match) {
566
- return str;
567
- }
568
- if (typeof Bun === "object" && "escapeHTML" in Bun) return Bun.escapeHTML(str);
569
- let escape;
570
- let index;
571
- let lastIndex = 0;
572
- let html2 = "";
573
- for (index = match.index; index < str.length; index++) {
574
- switch (str.charCodeAt(index)) {
575
- case 34:
576
- escape = "&quot;";
577
- break;
578
- case 38:
579
- escape = "&amp;";
580
- break;
581
- case 39:
582
- escape = "&#x27;";
583
- break;
584
- case 60:
585
- escape = "&lt;";
586
- break;
587
- case 62:
588
- escape = "&gt;";
589
- break;
590
- default:
591
- continue;
592
- }
593
- if (lastIndex !== index) {
594
- html2 += str.slice(lastIndex, index);
595
- }
596
- lastIndex = index + 1;
597
- html2 += escape;
598
- }
599
- return lastIndex !== index ? html2 + str.slice(lastIndex, index) : html2;
600
- }
601
- function render(node, renderOptions = {}) {
602
- const { request, status = 200, headers: headersRaw, rendering, data } = renderOptions;
603
- const headers = /* @__PURE__ */ Object.create(null);
604
- if (headersRaw) {
605
- const { etag, lastModified } = headersRaw;
606
- if (etag && request?.headers.get("if-none-match") === etag) {
607
- return new Response(null, { status: 304 });
608
- }
609
- if (lastModified && request?.headers.get("if-modified-since") === lastModified) {
610
- return new Response(null, { status: 304 });
611
- }
612
- for (const [key, value] of Object.entries(headersRaw)) {
613
- if (value) {
614
- headers[toHyphenCase(key)] = value;
615
- }
616
- }
617
- }
618
- headers["transfer-encoding"] = "chunked";
619
- headers["content-type"] = "text/html; charset=utf-8";
620
- return new Response(
621
- new ReadableStream({
622
- async start(controller) {
623
- const write = (chunk) => controller.enqueue(encoder.encode(chunk));
624
- const stateStore = /* @__PURE__ */ new Map();
625
- const suspenses = [];
626
- const rtComponents = {};
627
- const ctx = {
628
- request,
629
- data,
630
- write,
631
- stateStore,
632
- suspenses,
633
- rtComponents,
634
- evtHandlerIndex: 0,
635
- eager: rendering === "eager"
636
- };
637
- try {
638
- write("<!DOCTYPE html>");
639
- await renderNode(ctx, node);
640
- if (stateStore.size > 0) {
641
- write(
642
- "<script>(()=>{" + (rtComponents.cx ? RUNTIME_COMPONENTS_JS.cx : "") + (rtComponents.styleToCSS ? RUNTIME_COMPONENTS_JS.styleToCSS : "") + RUNTIME_STATE_JS + "for(let[n,v]of" + JSON.stringify(Array.from(stateStore.entries()).map((e) => e[1] === void 0 ? [e[0]] : e)) + ")defineState(n,v)})()<\/script>"
643
- );
644
- }
645
- if (suspenses.length > 0) {
646
- write("<script>(()=>{" + RUNTIME_SUSPENSE_JS + "})()<\/script>");
647
- await Promise.all(suspenses);
648
- }
649
- } finally {
650
- controller.close();
651
- }
652
- }
653
- }),
654
- { headers, status }
655
- );
656
- }
657
-
658
- // jsx-runtime.ts
659
- var jsx = (tag, props = /* @__PURE__ */ Object.create(null), key) => {
660
- const vnode = new Array(3).fill(null);
661
- vnode[0] = tag;
662
- vnode[1] = props;
663
- vnode[2] = $vnode;
664
- if (key !== void 0) {
665
- props.key = key;
666
- }
667
- if (tag === "html") {
668
- const renderOptions = /* @__PURE__ */ Object.create(null);
669
- for (const key2 of ["request", "data", "status", "headers", "rendering"]) {
670
- if (Object.hasOwn(props, key2)) {
671
- renderOptions[key2] = props[key2];
672
- delete props[key2];
673
- }
674
- }
675
- const res = render(vnode, renderOptions);
676
- return res;
677
- }
678
- return vnode;
679
- };
680
- function jsxIcon(name, svg) {
681
- const svgTagStart = svg.indexOf("<svg");
682
- const svgTagEnd = svg.indexOf(">", svgTagStart);
683
- const viewBox = svg.slice(0, svgTagEnd).match(/viewBox=['"]([^'"]+)['"]/)?.[1] ?? "";
684
- const iconSvg = '<svg class="icon" role="img" aria-hidden="true" style="width:auto;height:1em" fill="none" viewBox=' + JSON.stringify(viewBox) + ' xmlns="http://www.w3.org/2000/svg">' + svg.slice(svgTagEnd + 1).replace(/\n/g, "").replace(/=['"](black|#000000)['"]/g, '="currentColor"');
685
- $iconsRegistry.set(name.replace(/^icon-/, ""), iconSvg);
686
- }
687
- var html = (raw, ...values) => [
688
- $html,
689
- { innerHTML: String.raw({ raw }, ...values) },
690
- $vnode
691
- ];
692
- var context = () => {
693
- if (!Object.hasOwn($context, "request") || !Object.hasOwn($context, "data")) {
694
- throw new Error("calling `$context` outside of a component");
695
- }
696
- return $context;
697
- };
698
- Object.assign(globalThis, {
699
- html,
700
- css: html,
701
- js: html,
702
- $context: context,
703
- $state: state,
704
- $computed: computed
705
- });