mono-jsx 0.3.4 → 0.5.0
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 +269 -127
- package/jsx-runtime.mjs +587 -507
- package/package.json +1 -1
- package/setup.mjs +1 -0
- package/types/html.d.ts +20 -11
- package/types/jsx.d.ts +11 -5
- package/types/mono.d.ts +31 -20
- package/types/render.d.ts +2 -2
package/jsx-runtime.mjs
CHANGED
|
@@ -2,19 +2,15 @@
|
|
|
2
2
|
var $vnode = Symbol.for("jsx.vnode");
|
|
3
3
|
var $fragment = Symbol.for("jsx.fragment");
|
|
4
4
|
var $html = Symbol.for("jsx.html");
|
|
5
|
-
var $
|
|
6
|
-
var $computed = Symbol.for("mono.computed");
|
|
5
|
+
var $effects = Symbol.for("mono.effects");
|
|
7
6
|
|
|
8
7
|
// runtime/index.ts
|
|
9
|
-
var
|
|
10
|
-
var SUSPENSE_JS = `const
|
|
8
|
+
var SIGNALS_JS = `{const h=globalThis,y=new Map,M=new Map,u=e=>M.get(e)??M.set(e,k(e)).get(e),d=(e,t)=>e.getAttribute(t),p=(e,t)=>e.hasAttribute(t),E=(e,t,o)=>e.setAttribute(t,o),T=(e,t)=>e.replaceChildren(...t),k=e=>{const t=Object.create(null),o=(c,l)=>{t[c]=l},n=new Map,r=(c,l)=>{let s=n.get(c);return s||(s=new Set,n.set(c,s)),s.add(l),()=>{s.delete(l),s.size===0&&n.delete(c)}},i=new Proxy(Object.create(null),{get:(c,l)=>document.querySelector("[data-ref='"+e+":"+l+"']")});return new Proxy(t,{get:(c,l,s)=>{switch(l){case"$init":return o;case"$watch":return r;case"app":return u(0);case"refs":return i;default:return w?.(e,l),Reflect.get(c,l,s)}},set:(c,l,s,a)=>{if(s!==Reflect.get(c,l,a)){const f=n.get(l);return f&&queueMicrotask(()=>f.forEach(g=>g())),Reflect.set(c,l,s,a)}return!1}})},v=(e,t,o)=>{if(t==="toggle"){let n;return()=>{if(!n){const r=e.firstElementChild;r&&r.tagName==="TEMPLATE"&&p(r,"m-slot")?n=[...r.content.childNodes]:n=[...e.childNodes]}T(e,o()?n:[])}}if(t==="switch"){let n,r=d(e,"match"),i,c,l=s=>i.get(s)??i.set(s,[]).get(s);return()=>{if(!i){i=new Map,c=[];for(const s of e.childNodes)if(s.nodeType===1&&s.tagName==="TEMPLATE"&&p(s,"m-slot")){for(const a of s.content.childNodes)a.nodeType===1&&p(a,"slot")?l(d(a,"slot")).push(a):c.push(a);s.remove()}else r?l(r).push(s):c.push(s)}n=""+o(),T(e,i.has(n)?i.get(n):c)}}if(t&&t.length>2&&t.startsWith("[")&&t.endsWith("]")){let n=t.slice(1,-1),r=e.parentElement;return r.tagName==="M-GROUP"&&(r=r.previousElementSibling),()=>{const i=o();if(i===!1)r.removeAttribute(n);else if((n==="class"||n==="style")&&typeof i=="object"&&i!==null)if(n==="class")E(r,n,$cx(i));else{const{inline:c}=$styleToCSS(i);c&&E(r,n,c)}else E(r,n,i===!0?"":""+i)}}return()=>e.textContent=""+o()},N=e=>{const t=e.indexOf(":");if(t>0)return[Number(e.slice(0,t)),e.slice(t+1)];throw new Error("Invalid Singal ID")},b=async e=>{const t=e();return t!==void 0?t:(await new Promise(o=>setTimeout(o,0)),b(e))},S=(e,t)=>customElements.define(e,class extends HTMLElement{disposes=[];connectedCallback(){t(this)}disconnectedCallback(){this.disposes.forEach(o=>o()),this.disposes.length=0}});S("m-signal",e=>{const t=u(Number(d(e,"scope"))),o=d(e,"key");if(o)e.disposes.push(t.$watch(o,v(e,d(e,"mode"),()=>Reflect.get(t,o))));else{const n=Number(d(e,"computed"));b(()=>y.get(n)).then(([r,i])=>{const c=v(e,d(e,"mode"),r.bind(t));i.forEach(l=>{const[s,a]=N(l);e.disposes.push(u(s).$watch(a,c))})})}});let w;S("m-effect",e=>{const{disposes:t}=e,o=Number(d(e,"scope")),n=Number(d(e,"n")),r=new Array(n);t.push(()=>{r.forEach(i=>typeof i=="function"&&i()),r.length=0});for(let i=0;i<n;i++){const c="$ME_"+o+"_"+i;b(()=>h[c]).then(l=>{const s=[],a=u(o),f=()=>{r[i]=l.call(a)};w=(g,m)=>s.push([g,m]),f(),w=void 0;for(const[g,m]of s)t.push(u(g).$watch(m,f))},()=>{})}}),h.$signals=e=>e!==void 0?u(e):void 0,h.$MS=(e,t)=>{const[o,n]=N(e);u(o).$init(n,t)},h.$MC=(e,t,o)=>{y.set(e,[t,o])};}`;
|
|
9
|
+
var SUSPENSE_JS = `{const s=new Map,i=(e,t)=>e.hasAttribute(t),l=e=>e.getAttribute("chunk-id"),c=(e,t)=>customElements.define(e,class extends HTMLElement{connectedCallback(){t(this)}});c("m-portal",e=>{s.set(l(e),e)}),c("m-chunk",e=>{setTimeout(()=>{const t=e.firstChild?.content.childNodes,o=l(e),n=s.get(o);n&&(i(e,"next")?n.before(...t):(s.delete(o),i(e,"done")?n.remove():n.replaceWith(...t)),e.remove())})});}`;
|
|
11
10
|
var UTILS_JS = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
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"]),o=e=>typeof e=="string",u=e=>typeof e=="object"&&e!==null,f=e=>e.replace(/[a-z][A-Z]/g,r=>r.charAt(0)+"-"+r.charAt(1).toLowerCase());function p(e){if(o(e))return e;if(u(e)){let r="";for(let[i,t]of Array.isArray(e)?e:Object.entries(e))if(o(i)&&(o(t)||typeof t=="number")){let n=f(i),c=typeof t=="number"?a.has(n)?""+t:t+"px":s(""+t);r+=(r?";":"")+s(n)+":"+(n==="content"?JSON.stringify(c):c)}return r}return""}function s(e){return e.replace(/["<>]/g,r=>r==="<"?"<":r===">"?">":"'")}window.$styleToCSS=p;`,
|
|
16
|
-
/** event.js (347 bytes) */
|
|
17
|
-
event: `var w=window;w.$emit=(e,fn,fc)=>fn.call(w.$state?.(fc)??e.target,e);w.$onsubmit=(e,fn,fc)=>{e.preventDefault();fn.call(w.$state?.(fc)??e.target,new FormData(e.target),e)};w.$onstage=()=>document.querySelectorAll("[onmount]").forEach(t=>{const k="onmount",j=t.getAttribute(k);t.removeAttribute(k);new Function("event",j)({type:"mount",target:t})});`
|
|
11
|
+
cx: `{var n=e=>typeof e=="string",o=e=>typeof e=="object"&&e!==null;var t=e=>n(e)?e:o(e)?Array.isArray(e)?e.map(t).filter(Boolean).join(" "):Object.entries(e).filter(([,r])=>!!r).map(([r])=>r).join(" "):"";window.$cx=t;}`,
|
|
12
|
+
styleToCSS: `{var c=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"]),a=e=>typeof e=="string",l=e=>typeof e=="object"&&e!==null,u=e=>e.replace(/[a-z][A-Z]/g,t=>t.charAt(0)+"-"+t.charAt(1).toLowerCase());var p=e=>{let t=[],o=[],r={};for(let[n,i]of Object.entries(e))switch(n.charCodeAt(0)){case 58:o.push(null,n+"{"+s(i)+"}");break;case 64:o.push(n+"{",null,"{"+s(i)+"}}");break;case 38:o.push(null,n.slice(1)+"{"+s(i)+"}");break;default:t.push([n,i])}return t.length>0&&(r.inline=s(t)),o.length>0&&(r.css=o),r},s=e=>{if(l(e)){let t="";for(let[o,r]of Array.isArray(e)?e:Object.entries(e))if(a(r)||typeof r=="number"){let n=u(o),i=typeof r=="number"?c.has(n)?""+r:r+"px":""+r;t+=(t?";":"")+n+":"+(n==="content"?JSON.stringify(i):i)}return t}return""};window.$styleToCSS=p;}`,
|
|
13
|
+
event: `{var w=window;w.$emit=(e,f,s)=>f.call(w.$signals?.(s)??e.target,e.type==="mount"?e.target:e);w.$onsubmit=(e,f,s)=>{e.preventDefault();f.call(w.$signals?.(s)??e.target,new FormData(e.target),e)};w.$onstage=()=>document.querySelectorAll("[onmount]").forEach(t=>{const k="onmount",j=t.getAttribute(k);t.removeAttribute(k);new Function("event",j)({type:"mount",target:t})});}`
|
|
18
14
|
};
|
|
19
15
|
|
|
20
16
|
// runtime/utils.ts
|
|
@@ -66,7 +62,7 @@ var cssBareUnitProps = /* @__PURE__ */ new Set([
|
|
|
66
62
|
var isString = (v) => typeof v === "string";
|
|
67
63
|
var isObject = (v) => typeof v === "object" && v !== null;
|
|
68
64
|
var toHyphenCase = (k) => k.replace(/[a-z][A-Z]/g, (m) => m.charAt(0) + "-" + m.charAt(1).toLowerCase());
|
|
69
|
-
|
|
65
|
+
var cx = (className) => {
|
|
70
66
|
if (isString(className)) {
|
|
71
67
|
return className;
|
|
72
68
|
}
|
|
@@ -77,44 +73,64 @@ function cx(className) {
|
|
|
77
73
|
return Object.entries(className).filter(([, v]) => !!v).map(([k]) => k).join(" ");
|
|
78
74
|
}
|
|
79
75
|
return "";
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
76
|
+
};
|
|
77
|
+
var styleToCSS = (style) => {
|
|
78
|
+
const inline = [];
|
|
79
|
+
const css = [];
|
|
80
|
+
const ret = {};
|
|
81
|
+
for (const [k, v] of Object.entries(style)) {
|
|
82
|
+
switch (k.charCodeAt(0)) {
|
|
83
|
+
case /* ':' */
|
|
84
|
+
58:
|
|
85
|
+
css.push(null, k + "{" + renderStyle(v) + "}");
|
|
86
|
+
break;
|
|
87
|
+
case /* '@' */
|
|
88
|
+
64:
|
|
89
|
+
css.push(k + "{", null, "{" + renderStyle(v) + "}}");
|
|
90
|
+
break;
|
|
91
|
+
case /* '&' */
|
|
92
|
+
38:
|
|
93
|
+
css.push(null, k.slice(1) + "{" + renderStyle(v) + "}");
|
|
94
|
+
break;
|
|
95
|
+
default:
|
|
96
|
+
inline.push([k, v]);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (inline.length > 0) {
|
|
100
|
+
ret.inline = renderStyle(inline);
|
|
84
101
|
}
|
|
102
|
+
if (css.length > 0) {
|
|
103
|
+
ret.css = css;
|
|
104
|
+
}
|
|
105
|
+
return ret;
|
|
106
|
+
};
|
|
107
|
+
var renderStyle = (style) => {
|
|
85
108
|
if (isObject(style)) {
|
|
86
109
|
let css = "";
|
|
87
110
|
for (const [k, v] of Array.isArray(style) ? style : Object.entries(style)) {
|
|
88
|
-
if (isString(
|
|
111
|
+
if (isString(v) || typeof v === "number") {
|
|
89
112
|
const cssKey = toHyphenCase(k);
|
|
90
|
-
const cssValue = typeof v === "number" ? cssBareUnitProps.has(cssKey) ? "" + v : v + "px" :
|
|
91
|
-
css += (css ? ";" : "") +
|
|
113
|
+
const cssValue = typeof v === "number" ? cssBareUnitProps.has(cssKey) ? "" + v : v + "px" : "" + v;
|
|
114
|
+
css += (css ? ";" : "") + cssKey + ":" + (cssKey === "content" ? JSON.stringify(cssValue) : cssValue);
|
|
92
115
|
}
|
|
93
116
|
}
|
|
94
117
|
return css;
|
|
95
118
|
}
|
|
96
119
|
return "";
|
|
97
|
-
}
|
|
98
|
-
function escapeCSSText(str2) {
|
|
99
|
-
return str2.replace(/["<>]/g, (m) => {
|
|
100
|
-
if (m === "<") return "<";
|
|
101
|
-
if (m === ">") return ">";
|
|
102
|
-
return "'";
|
|
103
|
-
});
|
|
104
|
-
}
|
|
120
|
+
};
|
|
105
121
|
var regexpHtmlSafe = /["'&<>]/;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const match = regexpHtmlSafe.exec(str2);
|
|
122
|
+
var escapeHTML = (str) => {
|
|
123
|
+
const match = regexpHtmlSafe.exec(str);
|
|
109
124
|
if (!match) {
|
|
110
|
-
return
|
|
125
|
+
return str;
|
|
111
126
|
}
|
|
127
|
+
if (typeof Bun === "object" && "escapeHTML" in Bun) return Bun.escapeHTML(str);
|
|
112
128
|
let escape;
|
|
113
129
|
let index;
|
|
114
130
|
let lastIndex = 0;
|
|
115
131
|
let html2 = "";
|
|
116
|
-
for (index = match.index; index <
|
|
117
|
-
switch (
|
|
132
|
+
for (index = match.index; index < str.length; index++) {
|
|
133
|
+
switch (str.charCodeAt(index)) {
|
|
118
134
|
case 34:
|
|
119
135
|
escape = """;
|
|
120
136
|
break;
|
|
@@ -134,456 +150,59 @@ function escapeHTML(str2) {
|
|
|
134
150
|
continue;
|
|
135
151
|
}
|
|
136
152
|
if (lastIndex !== index) {
|
|
137
|
-
html2 +=
|
|
153
|
+
html2 += str.slice(lastIndex, index);
|
|
138
154
|
}
|
|
139
155
|
lastIndex = index + 1;
|
|
140
156
|
html2 += escape;
|
|
141
157
|
}
|
|
142
|
-
return lastIndex !== index ? html2 +
|
|
143
|
-
}
|
|
158
|
+
return lastIndex !== index ? html2 + str.slice(lastIndex, index) : html2;
|
|
159
|
+
};
|
|
144
160
|
|
|
145
161
|
// render.ts
|
|
162
|
+
var RUNTIME_SIGNALS = 1;
|
|
163
|
+
var RUNTIME_SUSPENSE = 2;
|
|
164
|
+
var RUNTIME_CX = 4;
|
|
165
|
+
var RUNTIME_STYLE_TO_CSS = 8;
|
|
166
|
+
var RUNTIME_EVENT = 16;
|
|
167
|
+
var cdn = "https://raw.esm.sh";
|
|
146
168
|
var encoder = new TextEncoder();
|
|
147
|
-
var
|
|
169
|
+
var customElements = /* @__PURE__ */ new Map();
|
|
148
170
|
var selfClosingTags = new Set("area,base,br,col,embed,hr,img,input,keygen,link,meta,param,source,track,wbr".split(","));
|
|
149
|
-
var cdn = "https://raw.esm.sh";
|
|
150
171
|
var isVNode = (v) => Array.isArray(v) && v.length === 3 && v[2] === $vnode;
|
|
151
172
|
var hashCode = (s) => [...s].reduce((hash, c) => Math.imul(31, hash) + c.charCodeAt(0) | 0, 0);
|
|
152
|
-
var
|
|
153
|
-
var
|
|
154
|
-
var
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
collectDeps = void 0;
|
|
161
|
-
if (value instanceof Promise || Object.keys(deps).length === 0) return value;
|
|
162
|
-
return [$computed, { value, deps, fc, fn }, $vnode];
|
|
163
|
-
};
|
|
164
|
-
const thisProxy = new Proxy(/* @__PURE__ */ Object.create(null), {
|
|
165
|
-
get(target, key, receiver) {
|
|
166
|
-
switch (key) {
|
|
167
|
-
case "app":
|
|
168
|
-
return appState;
|
|
169
|
-
case "context":
|
|
170
|
-
return context ?? {};
|
|
171
|
-
case "request":
|
|
172
|
-
if (!request) {
|
|
173
|
-
throw new Error("request is not defined");
|
|
174
|
-
}
|
|
175
|
-
return request;
|
|
176
|
-
case "computed":
|
|
177
|
-
return computed;
|
|
178
|
-
default: {
|
|
179
|
-
const value = Reflect.get(target, key, receiver);
|
|
180
|
-
if (typeof key === "symbol") {
|
|
181
|
-
return value;
|
|
182
|
-
}
|
|
183
|
-
if (collectDeps) {
|
|
184
|
-
collectDeps(fc, key, value);
|
|
185
|
-
return value;
|
|
186
|
-
}
|
|
187
|
-
return [$state, { key, value, fc }, $vnode];
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
set(target, key, value, receiver) {
|
|
192
|
-
return Reflect.set(target, key, value, receiver);
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
return thisProxy;
|
|
196
|
-
}
|
|
197
|
-
async function renderNode(rc, node, stripSlotProp) {
|
|
198
|
-
const { write } = rc;
|
|
199
|
-
switch (typeof node) {
|
|
200
|
-
case "string":
|
|
201
|
-
write(escapeHTML(node));
|
|
202
|
-
break;
|
|
203
|
-
case "number":
|
|
204
|
-
case "bigint":
|
|
205
|
-
write("" + node);
|
|
206
|
-
break;
|
|
207
|
-
case "object":
|
|
208
|
-
if (isVNode(node)) {
|
|
209
|
-
const [tag, props] = node;
|
|
210
|
-
const { stateStore } = rc;
|
|
211
|
-
if (tag === $fragment) {
|
|
212
|
-
if (props.children !== void 0) {
|
|
213
|
-
await renderChildren(rc, props.children);
|
|
214
|
-
}
|
|
215
|
-
break;
|
|
216
|
-
}
|
|
217
|
-
if (tag === $html) {
|
|
218
|
-
if (props.innerHTML) {
|
|
219
|
-
write(props.innerHTML);
|
|
220
|
-
}
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
if (tag === $state) {
|
|
224
|
-
const { key, value, fc } = props;
|
|
225
|
-
write('<m-state fc="' + fc + '" key=' + toAttrStringLit(key) + ">");
|
|
226
|
-
if (value !== void 0 && value !== null) {
|
|
227
|
-
write(escapeHTML("" + value));
|
|
228
|
-
}
|
|
229
|
-
write("</m-state>");
|
|
230
|
-
stateStore.set(fc + ":" + key, value);
|
|
231
|
-
break;
|
|
232
|
-
}
|
|
233
|
-
if (tag === $computed) {
|
|
234
|
-
const { deps, value, fc } = props;
|
|
235
|
-
write('<m-state fc="' + fc + '" computed="' + rc.mcs.gen(node) + '">');
|
|
236
|
-
if (value !== void 0) {
|
|
237
|
-
write(escapeHTML("" + value));
|
|
238
|
-
}
|
|
239
|
-
write("</m-state>");
|
|
240
|
-
for (const [key, value2] of Object.entries(deps)) {
|
|
241
|
-
if (!stateStore.has(key)) {
|
|
242
|
-
stateStore.set(key, value2);
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
break;
|
|
246
|
-
}
|
|
247
|
-
if (tag === "slot") {
|
|
248
|
-
const { fcSlots } = rc;
|
|
249
|
-
if (fcSlots) {
|
|
250
|
-
let slots;
|
|
251
|
-
if (props.name) {
|
|
252
|
-
slots = fcSlots.filter((v) => isVNode(v) && v[1].slot === props.name);
|
|
253
|
-
} else {
|
|
254
|
-
slots = fcSlots.filter((v) => !isVNode(v) || !v[1].slot);
|
|
255
|
-
}
|
|
256
|
-
if (slots.length === 0) {
|
|
257
|
-
slots = props.children;
|
|
258
|
-
}
|
|
259
|
-
await renderChildren(rc, slots, true);
|
|
260
|
-
}
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
263
|
-
if (tag === "toggle") {
|
|
264
|
-
const { value: valueProp, children } = props;
|
|
265
|
-
if (children !== void 0) {
|
|
266
|
-
if (isVNode(valueProp) && (valueProp[0] === $state || valueProp[0] === $computed)) {
|
|
267
|
-
const { key, deps, value, fc } = valueProp[1];
|
|
268
|
-
write('<m-state mode="toggle" fc="' + fc + '" ');
|
|
269
|
-
if (key) {
|
|
270
|
-
write("key=" + toAttrStringLit(key) + ">");
|
|
271
|
-
stateStore.set(fc + ":" + key, !!value);
|
|
272
|
-
} else {
|
|
273
|
-
write('computed="' + rc.mcs.gen(valueProp) + '">');
|
|
274
|
-
for (const [key2, value2] of Object.entries(deps)) {
|
|
275
|
-
if (!stateStore.has(key2)) {
|
|
276
|
-
stateStore.set(key2, value2);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
if (!value) {
|
|
281
|
-
write("<template m-slot>");
|
|
282
|
-
}
|
|
283
|
-
await renderChildren(rc, children);
|
|
284
|
-
if (!value) {
|
|
285
|
-
write("</template>");
|
|
286
|
-
}
|
|
287
|
-
write("</m-state>");
|
|
288
|
-
} else if (valueProp) {
|
|
289
|
-
await renderChildren(rc, children);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
break;
|
|
293
|
-
}
|
|
294
|
-
if (tag === "switch") {
|
|
295
|
-
const { value: valueProp, defaultValue, children } = props;
|
|
296
|
-
if (children !== void 0) {
|
|
297
|
-
let slots = Array.isArray(children) ? isVNode(children) ? [children] : children : [children];
|
|
298
|
-
let stateful;
|
|
299
|
-
let computed;
|
|
300
|
-
let valueOrDefault;
|
|
301
|
-
if (isVNode(valueProp) && (valueProp[0] === $state || valueProp[0] === $computed)) {
|
|
302
|
-
const { key, deps, value, fc } = valueProp[1];
|
|
303
|
-
valueOrDefault = value ?? defaultValue;
|
|
304
|
-
stateful = '<m-state mode="switch" fc="' + fc + '" ';
|
|
305
|
-
if (key) {
|
|
306
|
-
stateful += "key=" + toAttrStringLit(key) + ">";
|
|
307
|
-
stateStore.set(fc + ":" + key, valueOrDefault);
|
|
308
|
-
} else {
|
|
309
|
-
stateful += 'computed="' + rc.mcs.gen(valueProp) + '">';
|
|
310
|
-
for (const [key2, value2] of Object.entries(deps)) {
|
|
311
|
-
if (!stateStore.has(key2)) {
|
|
312
|
-
stateStore.set(key2, value2);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
} else {
|
|
317
|
-
valueOrDefault = valueProp ?? defaultValue;
|
|
318
|
-
}
|
|
319
|
-
let matchedSlot;
|
|
320
|
-
let namedSlots = new Array(slots.length);
|
|
321
|
-
let unnamedSlots = new Array(slots.length);
|
|
322
|
-
for (const slot of slots) {
|
|
323
|
-
if (!isVNode(slot) || !slot[1].slot) {
|
|
324
|
-
unnamedSlots.push(slot);
|
|
325
|
-
continue;
|
|
326
|
-
}
|
|
327
|
-
const slotName = slot[1].slot;
|
|
328
|
-
if (slotName === valueOrDefault) {
|
|
329
|
-
matchedSlot = [slotName, slot];
|
|
330
|
-
} else {
|
|
331
|
-
namedSlots.push(slot);
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
if (stateful) {
|
|
335
|
-
write(matchedSlot ? stateful.slice(0, -1) + " match=" + toAttrStringLit(matchedSlot[0]) + ">" : stateful);
|
|
336
|
-
if (computed) {
|
|
337
|
-
write(computed);
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
if (matchedSlot) {
|
|
341
|
-
await renderNode(rc, matchedSlot[1], true);
|
|
342
|
-
} else if (unnamedSlots.length > 0) {
|
|
343
|
-
await renderChildren(rc, unnamedSlots);
|
|
344
|
-
}
|
|
345
|
-
if (stateful) {
|
|
346
|
-
if (namedSlots.length > 0 || matchedSlot && unnamedSlots.length > 0) {
|
|
347
|
-
write("<template m-slot>");
|
|
348
|
-
await renderChildren(rc, namedSlots);
|
|
349
|
-
if (matchedSlot && unnamedSlots.length > 0) {
|
|
350
|
-
await renderChildren(rc, unnamedSlots);
|
|
351
|
-
}
|
|
352
|
-
write("</template>");
|
|
353
|
-
}
|
|
354
|
-
write("</m-state>");
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
break;
|
|
358
|
-
}
|
|
359
|
-
if (typeof tag === "function") {
|
|
360
|
-
const fcIndex = ++rc.status.fcIndex;
|
|
361
|
-
const { children, rendering, placeholder, catch: catchFC } = props;
|
|
362
|
-
try {
|
|
363
|
-
const v = tag.call(createThis(fcIndex, rc.appState, rc.context, rc.request), props);
|
|
364
|
-
const fcSlots = children !== void 0 ? Array.isArray(children) ? isVNode(children) ? [children] : children : [children] : void 0;
|
|
365
|
-
const eager = (rendering ?? tag.rendering) === "eager";
|
|
366
|
-
if (v instanceof Promise) {
|
|
367
|
-
if (eager) {
|
|
368
|
-
await renderNode({ ...rc, fcIndex, fcSlots }, await v);
|
|
369
|
-
} else {
|
|
370
|
-
const chunkIdAttr = 'chunk-id="' + (rc.status.chunkIndex++).toString(36) + '"';
|
|
371
|
-
rc.suspenses.push(v.then(async (node2) => {
|
|
372
|
-
let buf = "<m-chunk " + chunkIdAttr + "><template>";
|
|
373
|
-
await renderNode({
|
|
374
|
-
...rc,
|
|
375
|
-
fcIndex,
|
|
376
|
-
fcSlots,
|
|
377
|
-
write: (chunk) => {
|
|
378
|
-
buf += chunk;
|
|
379
|
-
}
|
|
380
|
-
}, node2);
|
|
381
|
-
return buf + "</template></m-chunk>";
|
|
382
|
-
}));
|
|
383
|
-
write("<m-portal " + chunkIdAttr + ">");
|
|
384
|
-
if (placeholder) {
|
|
385
|
-
await renderNode({ ...rc, fcIndex }, placeholder);
|
|
386
|
-
}
|
|
387
|
-
write("</m-portal>");
|
|
388
|
-
}
|
|
389
|
-
} else if (isObject(v) && Symbol.asyncIterator in v) {
|
|
390
|
-
if (eager) {
|
|
391
|
-
for await (const c of v) {
|
|
392
|
-
await renderNode({ ...rc, fcIndex, fcSlots }, c);
|
|
393
|
-
}
|
|
394
|
-
} else {
|
|
395
|
-
}
|
|
396
|
-
} else if (isObject(v) && Symbol.iterator in v && !isVNode(v)) {
|
|
397
|
-
for (const node2 of v) {
|
|
398
|
-
await renderNode({ ...rc, fcIndex, fcSlots }, node2);
|
|
399
|
-
}
|
|
400
|
-
} else {
|
|
401
|
-
await renderNode({ ...rc, fcIndex, fcSlots }, v);
|
|
402
|
-
}
|
|
403
|
-
} catch (err) {
|
|
404
|
-
if (err instanceof Error) {
|
|
405
|
-
if (typeof catchFC === "function") {
|
|
406
|
-
await renderNode({ ...rc, fcIndex }, catchFC(err));
|
|
407
|
-
} else {
|
|
408
|
-
write('<pre style="color:red;font-size:1rem"><code>' + escapeHTML(err.message) + "</code></pre>");
|
|
409
|
-
console.error(err);
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
break;
|
|
414
|
-
}
|
|
415
|
-
if (isString(tag) && regexpHtmlTag.test(tag)) {
|
|
416
|
-
let buffer = "<" + tag;
|
|
417
|
-
let stateTags = "";
|
|
418
|
-
for (let [propName, propValue] of Object.entries(props)) {
|
|
419
|
-
if (propName === "children") {
|
|
420
|
-
continue;
|
|
421
|
-
}
|
|
422
|
-
if (isVNode(propValue) && (propValue[0] === $state || propValue[0] === $computed)) {
|
|
423
|
-
const { key, value, deps, fc } = propValue[1];
|
|
424
|
-
if (propName === "class") {
|
|
425
|
-
rc.status.cx = true;
|
|
426
|
-
} else if (propName === "style") {
|
|
427
|
-
rc.status.styleToCSS = true;
|
|
428
|
-
}
|
|
429
|
-
stateTags += "<m-state mode=" + toAttrStringLit("[" + propName + "]") + ' fc="' + fc + '" ';
|
|
430
|
-
if (key) {
|
|
431
|
-
stateTags += "key=" + toAttrStringLit(key) + ">";
|
|
432
|
-
stateStore.set(fc + ":" + key, value);
|
|
433
|
-
} else {
|
|
434
|
-
stateTags += 'computed="' + rc.mcs.gen(propValue) + '">';
|
|
435
|
-
for (const [key2, value2] of Object.entries(deps)) {
|
|
436
|
-
if (!stateStore.has(key2)) {
|
|
437
|
-
stateStore.set(key2, value2);
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
stateTags += "</m-state>";
|
|
442
|
-
propValue = value;
|
|
443
|
-
}
|
|
444
|
-
switch (propName) {
|
|
445
|
-
case "class":
|
|
446
|
-
buffer += " class=" + toAttrStringLit(cx(propValue));
|
|
447
|
-
break;
|
|
448
|
-
case "style":
|
|
449
|
-
if (isString(propValue) && propValue !== "") {
|
|
450
|
-
buffer += ' style="' + escapeCSSText(propValue) + '"';
|
|
451
|
-
} else if (isObject(propValue) && !Array.isArray(propValue)) {
|
|
452
|
-
const style = [];
|
|
453
|
-
const pseudoStyles = [];
|
|
454
|
-
const atRuleStyles = [];
|
|
455
|
-
const nestingStyles = [];
|
|
456
|
-
for (const [k, v] of Object.entries(propValue)) {
|
|
457
|
-
switch (k.charCodeAt(0)) {
|
|
458
|
-
case /* ':' */
|
|
459
|
-
58:
|
|
460
|
-
pseudoStyles.push([escapeCSSText(k), styleToCSS(v)]);
|
|
461
|
-
break;
|
|
462
|
-
case /* '@' */
|
|
463
|
-
64:
|
|
464
|
-
atRuleStyles.push([escapeCSSText(k), styleToCSS(v)]);
|
|
465
|
-
break;
|
|
466
|
-
case /* '&' */
|
|
467
|
-
38:
|
|
468
|
-
nestingStyles.push([escapeCSSText(k), styleToCSS(v)]);
|
|
469
|
-
break;
|
|
470
|
-
default:
|
|
471
|
-
style.push([k, v]);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
if (pseudoStyles.length > 0 || atRuleStyles.length > 0 || nestingStyles.length > 0) {
|
|
475
|
-
let css = "";
|
|
476
|
-
let raw = "";
|
|
477
|
-
let id;
|
|
478
|
-
let cssSelector;
|
|
479
|
-
let cssIds;
|
|
480
|
-
if (style.length > 0) {
|
|
481
|
-
css = styleToCSS(style);
|
|
482
|
-
raw += css + "|";
|
|
483
|
-
}
|
|
484
|
-
raw += [pseudoStyles, atRuleStyles, nestingStyles].flat(1).map(([k, v]) => k + ">" + v).join("|");
|
|
485
|
-
id = hashCode(raw).toString(36);
|
|
486
|
-
cssSelector = "[data-css-" + id + "]";
|
|
487
|
-
cssIds = rc.cssIds ?? (rc.cssIds = /* @__PURE__ */ new Set());
|
|
488
|
-
if (!cssIds.has(id)) {
|
|
489
|
-
cssIds.add(id);
|
|
490
|
-
if (css) {
|
|
491
|
-
css = cssSelector + "{" + css + "}";
|
|
492
|
-
}
|
|
493
|
-
for (const [p, styles] of pseudoStyles) {
|
|
494
|
-
css += cssSelector + p + "{" + styles + "}";
|
|
495
|
-
}
|
|
496
|
-
for (const [at, styles] of atRuleStyles) {
|
|
497
|
-
css += at + "{" + cssSelector + "{" + styles + "}}";
|
|
498
|
-
}
|
|
499
|
-
for (const [n, styles] of nestingStyles) {
|
|
500
|
-
css += cssSelector + n.slice(1) + "{" + styles + "}";
|
|
501
|
-
}
|
|
502
|
-
write('<style id="css-' + id + '">' + css + "</style>");
|
|
503
|
-
}
|
|
504
|
-
buffer += " data-css-" + id;
|
|
505
|
-
} else if (style.length > 0) {
|
|
506
|
-
buffer += ' style="' + styleToCSS(style) + '"';
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
break;
|
|
510
|
-
case "onMount":
|
|
511
|
-
if (typeof propValue === "function") {
|
|
512
|
-
rc.status.onmount++;
|
|
513
|
-
buffer += ' onmount="$emit(event,' + rc.mfs.gen(propValue) + str(rc.fcIndex, (i) => "," + i) + ')"';
|
|
514
|
-
}
|
|
515
|
-
break;
|
|
516
|
-
case "action":
|
|
517
|
-
if (typeof propValue === "function" && tag === "form") {
|
|
518
|
-
buffer += ' onsubmit="$onsubmit(event,' + rc.mfs.gen(propValue) + str(rc.fcIndex, (i) => "," + i) + ')"';
|
|
519
|
-
} else if (isString(propValue)) {
|
|
520
|
-
buffer += " action=" + toAttrStringLit(propValue);
|
|
521
|
-
}
|
|
522
|
-
break;
|
|
523
|
-
case "slot":
|
|
524
|
-
if (!stripSlotProp && isString(propValue)) {
|
|
525
|
-
buffer += " slot=" + toAttrStringLit(propValue);
|
|
526
|
-
}
|
|
527
|
-
break;
|
|
528
|
-
default:
|
|
529
|
-
if (regexpHtmlTag.test(propName) && propValue !== void 0) {
|
|
530
|
-
if (propName.startsWith("on")) {
|
|
531
|
-
if (typeof propValue === "function") {
|
|
532
|
-
buffer += " " + propName.toLowerCase() + '="$emit(event,' + rc.mfs.gen(propValue) + str(rc.fcIndex, (i) => "," + i) + ')"';
|
|
533
|
-
}
|
|
534
|
-
} else if (typeof propValue === "boolean") {
|
|
535
|
-
if (propValue) {
|
|
536
|
-
buffer += " " + propName;
|
|
537
|
-
}
|
|
538
|
-
} else {
|
|
539
|
-
buffer += " " + escapeHTML(propName) + (propValue === true ? "" : "=" + toAttrStringLit("" + propValue));
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
}
|
|
544
|
-
write(buffer + ">");
|
|
545
|
-
if (!selfClosingTags.has(tag)) {
|
|
546
|
-
if (stateTags) {
|
|
547
|
-
write(stateTags);
|
|
548
|
-
}
|
|
549
|
-
if (props.innerHTML) {
|
|
550
|
-
write(props.innerHTML);
|
|
551
|
-
} else if (props.children !== void 0) {
|
|
552
|
-
await renderChildren(rc, props.children);
|
|
553
|
-
}
|
|
554
|
-
write("</" + tag + ">");
|
|
555
|
-
} else if (stateTags) {
|
|
556
|
-
write("<m-group>" + stateTags + "</m-group>");
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
} else if (Array.isArray(node) && node.length > 0) {
|
|
560
|
-
renderChildren(rc, node, stripSlotProp);
|
|
561
|
-
}
|
|
562
|
-
break;
|
|
173
|
+
var escapeCSSText = (str) => str.replace(/[<>]/g, (m) => m.charCodeAt(0) === 60 ? "<" : ">");
|
|
174
|
+
var toAttrStringLit = (str) => '"' + escapeHTML(str) + '"';
|
|
175
|
+
var toStr = (v, str) => v !== void 0 ? str(v) : "";
|
|
176
|
+
var Signal = class {
|
|
177
|
+
constructor(scope, key, value) {
|
|
178
|
+
this.scope = scope;
|
|
179
|
+
this.key = key;
|
|
180
|
+
this.value = value;
|
|
563
181
|
}
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
if (Array.isArray(children) && !isVNode(children)) {
|
|
567
|
-
for (const child of children) {
|
|
568
|
-
await renderNode(rc, child, stripSlotProp);
|
|
569
|
-
}
|
|
570
|
-
} else {
|
|
571
|
-
await renderNode(rc, children, stripSlotProp);
|
|
182
|
+
toString() {
|
|
183
|
+
return this.value === null || this.value === void 0 ? "" : String(this.value);
|
|
572
184
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
185
|
+
map(_fn) {
|
|
186
|
+
return [];
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
var Ref = class {
|
|
190
|
+
constructor(scope, name) {
|
|
191
|
+
this.scope = scope;
|
|
192
|
+
this.name = name;
|
|
578
193
|
}
|
|
194
|
+
};
|
|
195
|
+
var IdGenImpl = class extends Map {
|
|
579
196
|
_id = 0;
|
|
580
197
|
gen(v) {
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
198
|
+
return this.get(v) ?? this.set(v, this._id++).get(v);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
var JSX = {
|
|
202
|
+
customElements: {
|
|
203
|
+
define(tagName, fc) {
|
|
204
|
+
customElements.set(tagName, fc);
|
|
585
205
|
}
|
|
586
|
-
return id;
|
|
587
206
|
}
|
|
588
207
|
};
|
|
589
208
|
function render(node, renderOptions = {}) {
|
|
@@ -609,70 +228,75 @@ function render(node, renderOptions = {}) {
|
|
|
609
228
|
return new Response(
|
|
610
229
|
new ReadableStream({
|
|
611
230
|
async start(controller) {
|
|
612
|
-
const {
|
|
613
|
-
const
|
|
614
|
-
const
|
|
615
|
-
const
|
|
231
|
+
const { app, context, htmx } = renderOptions;
|
|
232
|
+
const appSignals = createSignals(0, null, context, request);
|
|
233
|
+
const signals = /* @__PURE__ */ new Map();
|
|
234
|
+
const effects = [];
|
|
616
235
|
const suspenses = [];
|
|
236
|
+
const write = (chunk) => controller.enqueue(encoder.encode(chunk));
|
|
617
237
|
const rc = {
|
|
618
238
|
write,
|
|
619
239
|
suspenses,
|
|
620
240
|
context,
|
|
621
241
|
request,
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
242
|
+
appSignals,
|
|
243
|
+
signals,
|
|
244
|
+
effects,
|
|
245
|
+
mcs: new IdGenImpl(),
|
|
246
|
+
mfs: new IdGenImpl(),
|
|
247
|
+
status: { scopeIndex: 0, chunkIndex: 0, refs: 0 }
|
|
627
248
|
};
|
|
628
|
-
|
|
629
|
-
|
|
249
|
+
let runtimeJSFlags = 0;
|
|
250
|
+
async function finalize() {
|
|
630
251
|
let js = "";
|
|
631
|
-
if (rc.status.cx && !
|
|
632
|
-
|
|
252
|
+
if (rc.status.cx && !(runtimeJSFlags & RUNTIME_CX)) {
|
|
253
|
+
runtimeJSFlags |= RUNTIME_CX;
|
|
633
254
|
js += UTILS_JS.cx;
|
|
634
255
|
}
|
|
635
|
-
if (rc.status.styleToCSS && !
|
|
636
|
-
|
|
256
|
+
if (rc.status.styleToCSS && !(runtimeJSFlags & RUNTIME_STYLE_TO_CSS)) {
|
|
257
|
+
runtimeJSFlags |= RUNTIME_STYLE_TO_CSS;
|
|
637
258
|
js += UTILS_JS.styleToCSS;
|
|
638
259
|
}
|
|
639
|
-
if (rc.mfs.size > 0 && !
|
|
640
|
-
|
|
260
|
+
if (rc.mfs.size > 0 && !(runtimeJSFlags & RUNTIME_EVENT)) {
|
|
261
|
+
runtimeJSFlags |= RUNTIME_EVENT;
|
|
641
262
|
js += UTILS_JS.event;
|
|
642
263
|
}
|
|
643
|
-
if (
|
|
644
|
-
|
|
645
|
-
js +=
|
|
264
|
+
if (signals.size + effects.length > 0 && !(runtimeJSFlags & RUNTIME_SIGNALS)) {
|
|
265
|
+
runtimeJSFlags |= RUNTIME_SIGNALS;
|
|
266
|
+
js += SIGNALS_JS;
|
|
646
267
|
}
|
|
647
|
-
if (
|
|
648
|
-
|
|
649
|
-
js +=
|
|
268
|
+
if (suspenses.length > 0 && !(runtimeJSFlags & RUNTIME_SUSPENSE)) {
|
|
269
|
+
runtimeJSFlags |= RUNTIME_SUSPENSE;
|
|
270
|
+
js += SUSPENSE_JS;
|
|
650
271
|
}
|
|
651
272
|
if (js) {
|
|
652
273
|
write("<script>/* runtime.js (generated by mono-jsx) */(()=>{" + js + "})()<\/script>");
|
|
653
274
|
}
|
|
654
275
|
js = "";
|
|
655
276
|
if (rc.mfs.size > 0) {
|
|
656
|
-
for (const [fn,
|
|
657
|
-
js += "function " +
|
|
277
|
+
for (const [fn, i] of rc.mfs.entries()) {
|
|
278
|
+
js += "function $MF_" + i + "(){(" + fn.toString() + ").apply(this,arguments)};";
|
|
658
279
|
}
|
|
659
280
|
rc.mfs.clear();
|
|
660
281
|
}
|
|
661
|
-
if (
|
|
662
|
-
|
|
663
|
-
|
|
282
|
+
if (rc.effects.length > 0) {
|
|
283
|
+
js += rc.effects.splice(0, rc.effects.length).join("");
|
|
284
|
+
}
|
|
285
|
+
if (signals.size > 0) {
|
|
286
|
+
for (const [key, value] of signals.entries()) {
|
|
287
|
+
js += "$MS(" + JSON.stringify(key) + (value !== void 0 ? "," + JSON.stringify(value) : "") + ");";
|
|
664
288
|
}
|
|
665
|
-
|
|
289
|
+
signals.clear();
|
|
666
290
|
}
|
|
667
291
|
if (rc.mcs.size > 0) {
|
|
668
|
-
for (const [vnode,
|
|
669
|
-
const {
|
|
670
|
-
js +=
|
|
292
|
+
for (const [vnode, i] of rc.mcs.entries()) {
|
|
293
|
+
const { compute, deps } = vnode.key;
|
|
294
|
+
js += "$MC(" + i + ",function(){return(" + compute.toString() + ").call(this)}," + JSON.stringify(Object.keys(deps)) + ");";
|
|
671
295
|
}
|
|
672
296
|
rc.mcs.clear();
|
|
673
297
|
}
|
|
674
|
-
if (rc.status.
|
|
675
|
-
rc.status.
|
|
298
|
+
if (rc.status.refs > 0) {
|
|
299
|
+
rc.status.refs = 0;
|
|
676
300
|
js += "$onstage();";
|
|
677
301
|
}
|
|
678
302
|
if (js) {
|
|
@@ -682,11 +306,11 @@ function render(node, renderOptions = {}) {
|
|
|
682
306
|
await Promise.all(suspenses.splice(0, suspenses.length).map((suspense) => suspense.then(write)));
|
|
683
307
|
await finalize();
|
|
684
308
|
}
|
|
685
|
-
}
|
|
686
|
-
if (
|
|
687
|
-
for (const [key, value] of Object.entries(
|
|
309
|
+
}
|
|
310
|
+
if (app) {
|
|
311
|
+
for (const [key, value] of Object.entries(app)) {
|
|
688
312
|
if (value !== void 0) {
|
|
689
|
-
|
|
313
|
+
appSignals[key] = value;
|
|
690
314
|
}
|
|
691
315
|
}
|
|
692
316
|
}
|
|
@@ -710,8 +334,455 @@ function render(node, renderOptions = {}) {
|
|
|
710
334
|
{ headers, status }
|
|
711
335
|
);
|
|
712
336
|
}
|
|
337
|
+
async function renderNode(rc, node, stripSlotProp) {
|
|
338
|
+
const { write } = rc;
|
|
339
|
+
switch (typeof node) {
|
|
340
|
+
case "string":
|
|
341
|
+
write(escapeHTML(node));
|
|
342
|
+
break;
|
|
343
|
+
case "number":
|
|
344
|
+
case "bigint":
|
|
345
|
+
write(String(node));
|
|
346
|
+
break;
|
|
347
|
+
case "object":
|
|
348
|
+
if (node === null) {
|
|
349
|
+
} else if (node instanceof Signal) {
|
|
350
|
+
const { scope, key, value } = node;
|
|
351
|
+
if (isString(key)) {
|
|
352
|
+
write('<m-signal scope="' + scope + '" key=' + toAttrStringLit(key) + ">");
|
|
353
|
+
if (value !== void 0 && value !== null) {
|
|
354
|
+
write(escapeHTML(String(value)));
|
|
355
|
+
}
|
|
356
|
+
write("</m-signal>");
|
|
357
|
+
} else {
|
|
358
|
+
write('<m-signal scope="' + scope + '" computed="' + rc.mcs.gen(node) + '">');
|
|
359
|
+
if (value !== void 0) {
|
|
360
|
+
write(escapeHTML(String(value)));
|
|
361
|
+
}
|
|
362
|
+
write("</m-signal>");
|
|
363
|
+
}
|
|
364
|
+
markSignal(rc, node);
|
|
365
|
+
} else if (isVNode(node)) {
|
|
366
|
+
const [tag, props] = node;
|
|
367
|
+
switch (tag) {
|
|
368
|
+
// fragment element
|
|
369
|
+
case $fragment: {
|
|
370
|
+
if (props.children !== void 0) {
|
|
371
|
+
await renderChildren(rc, props.children);
|
|
372
|
+
}
|
|
373
|
+
break;
|
|
374
|
+
}
|
|
375
|
+
// XSS!
|
|
376
|
+
case $html: {
|
|
377
|
+
if (props.innerHTML) {
|
|
378
|
+
write(props.innerHTML);
|
|
379
|
+
}
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
// `<slot>` element
|
|
383
|
+
case "slot": {
|
|
384
|
+
const { slots: fcSlots } = rc;
|
|
385
|
+
if (fcSlots) {
|
|
386
|
+
let slots;
|
|
387
|
+
if (props.name) {
|
|
388
|
+
slots = fcSlots.filter((v) => isVNode(v) && v[1].slot === props.name);
|
|
389
|
+
} else {
|
|
390
|
+
slots = fcSlots.filter((v) => !isVNode(v) || !v[1].slot);
|
|
391
|
+
}
|
|
392
|
+
if (slots.length === 0) {
|
|
393
|
+
slots = props.children;
|
|
394
|
+
}
|
|
395
|
+
await renderChildren(rc, slots, true);
|
|
396
|
+
}
|
|
397
|
+
break;
|
|
398
|
+
}
|
|
399
|
+
// `<toggle>` element
|
|
400
|
+
case "toggle": {
|
|
401
|
+
const { show, children } = props;
|
|
402
|
+
if (children !== void 0) {
|
|
403
|
+
if (show instanceof Signal) {
|
|
404
|
+
const { scope, key, value } = show;
|
|
405
|
+
write('<m-signal mode="toggle" scope="' + scope + '" ');
|
|
406
|
+
if (isString(key)) {
|
|
407
|
+
write("key=" + toAttrStringLit(key) + ">");
|
|
408
|
+
} else {
|
|
409
|
+
write('computed="' + rc.mcs.gen(show) + '">');
|
|
410
|
+
}
|
|
411
|
+
markSignal(rc, show);
|
|
412
|
+
if (!value) {
|
|
413
|
+
write("<template m-slot>");
|
|
414
|
+
}
|
|
415
|
+
await renderChildren(rc, children);
|
|
416
|
+
if (!value) {
|
|
417
|
+
write("</template>");
|
|
418
|
+
}
|
|
419
|
+
write("</m-signal>");
|
|
420
|
+
} else if (show) {
|
|
421
|
+
await renderChildren(rc, children);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
break;
|
|
425
|
+
}
|
|
426
|
+
// `<switch>` element
|
|
427
|
+
case "switch": {
|
|
428
|
+
const { value: valueProp, children } = props;
|
|
429
|
+
if (children !== void 0) {
|
|
430
|
+
let slots = Array.isArray(children) ? isVNode(children) ? [children] : children : [children];
|
|
431
|
+
let stateful;
|
|
432
|
+
let toSlotName;
|
|
433
|
+
if (valueProp instanceof Signal) {
|
|
434
|
+
const { scope, key, value } = valueProp;
|
|
435
|
+
markSignal(rc, valueProp);
|
|
436
|
+
stateful = '<m-signal mode="switch" scope="' + scope + '" ';
|
|
437
|
+
if (isString(key)) {
|
|
438
|
+
stateful += "key=" + toAttrStringLit(key) + ">";
|
|
439
|
+
} else {
|
|
440
|
+
stateful += 'computed="' + rc.mcs.gen(valueProp) + '">';
|
|
441
|
+
}
|
|
442
|
+
toSlotName = String(value);
|
|
443
|
+
} else {
|
|
444
|
+
toSlotName = String(valueProp);
|
|
445
|
+
}
|
|
446
|
+
let matchedSlot;
|
|
447
|
+
let namedSlots = new Array(slots.length);
|
|
448
|
+
let unnamedSlots = new Array(slots.length);
|
|
449
|
+
for (const slot of slots) {
|
|
450
|
+
if (!isVNode(slot) || !slot[1].slot) {
|
|
451
|
+
unnamedSlots.push(slot);
|
|
452
|
+
continue;
|
|
453
|
+
}
|
|
454
|
+
const slotName = slot[1].slot;
|
|
455
|
+
if (slotName === toSlotName) {
|
|
456
|
+
matchedSlot = [slotName, slot];
|
|
457
|
+
} else {
|
|
458
|
+
namedSlots.push(slot);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
if (stateful) {
|
|
462
|
+
write(matchedSlot ? stateful.slice(0, -1) + " match=" + toAttrStringLit(matchedSlot[0]) + ">" : stateful);
|
|
463
|
+
}
|
|
464
|
+
if (matchedSlot) {
|
|
465
|
+
await renderNode(rc, matchedSlot[1], true);
|
|
466
|
+
} else if (unnamedSlots.length > 0) {
|
|
467
|
+
await renderChildren(rc, unnamedSlots);
|
|
468
|
+
}
|
|
469
|
+
if (stateful) {
|
|
470
|
+
if (namedSlots.length > 0 || matchedSlot && unnamedSlots.length > 0) {
|
|
471
|
+
write("<template m-slot>");
|
|
472
|
+
await renderChildren(rc, namedSlots);
|
|
473
|
+
if (matchedSlot && unnamedSlots.length > 0) {
|
|
474
|
+
await renderChildren(rc, unnamedSlots);
|
|
475
|
+
}
|
|
476
|
+
write("</template>");
|
|
477
|
+
}
|
|
478
|
+
write("</m-signal>");
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
default: {
|
|
484
|
+
if (typeof tag === "function") {
|
|
485
|
+
await renderFC(rc, tag, props);
|
|
486
|
+
break;
|
|
487
|
+
}
|
|
488
|
+
if (isString(tag)) {
|
|
489
|
+
if (customElements.has(tag)) {
|
|
490
|
+
await renderFC(rc, customElements.get(tag), props);
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
let buffer = "<" + tag;
|
|
494
|
+
let attrModifiers = "";
|
|
495
|
+
for (let [propName, propValue] of Object.entries(props)) {
|
|
496
|
+
if (propName === "children") {
|
|
497
|
+
continue;
|
|
498
|
+
}
|
|
499
|
+
const [attr, addonHtml, signal] = renderAttr(rc, propName, propValue, stripSlotProp);
|
|
500
|
+
if (addonHtml) {
|
|
501
|
+
write(addonHtml);
|
|
502
|
+
}
|
|
503
|
+
if (signal) {
|
|
504
|
+
const { scope, key } = signal;
|
|
505
|
+
attrModifiers += "<m-signal mode=" + toAttrStringLit("[" + propName + "]") + ' scope="' + scope + '" ';
|
|
506
|
+
if (isString(key)) {
|
|
507
|
+
attrModifiers += "key=" + toAttrStringLit(key);
|
|
508
|
+
} else {
|
|
509
|
+
attrModifiers += 'computed="' + rc.mcs.gen(signal) + '"';
|
|
510
|
+
}
|
|
511
|
+
attrModifiers += "></m-signal>";
|
|
512
|
+
}
|
|
513
|
+
buffer += attr;
|
|
514
|
+
}
|
|
515
|
+
write(buffer + ">");
|
|
516
|
+
if (!selfClosingTags.has(tag)) {
|
|
517
|
+
if (attrModifiers) {
|
|
518
|
+
write(attrModifiers);
|
|
519
|
+
}
|
|
520
|
+
if (props.innerHTML) {
|
|
521
|
+
write(props.innerHTML);
|
|
522
|
+
} else if (props.children !== void 0) {
|
|
523
|
+
await renderChildren(rc, props.children);
|
|
524
|
+
}
|
|
525
|
+
write("</" + tag + ">");
|
|
526
|
+
} else if (attrModifiers) {
|
|
527
|
+
write("<m-group>" + attrModifiers + "</m-group>");
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
} else if (Array.isArray(node)) {
|
|
533
|
+
if (node.length > 0) {
|
|
534
|
+
await renderChildren(rc, node);
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
break;
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
function renderAttr(rc, attrName, attrValue, stripSlotProp) {
|
|
541
|
+
let attr = "";
|
|
542
|
+
let addonHtml = "";
|
|
543
|
+
let signal;
|
|
544
|
+
if (isObject(attrValue)) {
|
|
545
|
+
if (attrValue instanceof Signal) {
|
|
546
|
+
if (attrName === "class") {
|
|
547
|
+
rc.status.cx = true;
|
|
548
|
+
} else if (attrName === "style") {
|
|
549
|
+
rc.status.styleToCSS = true;
|
|
550
|
+
}
|
|
551
|
+
signal = attrValue;
|
|
552
|
+
attrValue = signal.value;
|
|
553
|
+
markSignal(rc, signal);
|
|
554
|
+
} else {
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
switch (attrName) {
|
|
558
|
+
case "class":
|
|
559
|
+
attr += " class=" + toAttrStringLit(cx(attrValue));
|
|
560
|
+
break;
|
|
561
|
+
case "style":
|
|
562
|
+
if (isString(attrValue)) {
|
|
563
|
+
attr += ' style="' + escapeCSSText(attrValue) + '"';
|
|
564
|
+
} else if (isObject(attrValue) && !Array.isArray(attrValue)) {
|
|
565
|
+
const { inline, css } = styleToCSS(attrValue);
|
|
566
|
+
if (inline) {
|
|
567
|
+
attr += " style=" + toAttrStringLit(inline);
|
|
568
|
+
}
|
|
569
|
+
if (css) {
|
|
570
|
+
const id = hashCode(css.join("")).toString(36);
|
|
571
|
+
addonHtml += '<style id="css-' + id + '">' + escapeCSSText(css.map((v) => v === null ? "[data-css-" + id + "]" : v).join("")) + "</style>";
|
|
572
|
+
attr += " data-css-" + id;
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
break;
|
|
576
|
+
case "ref":
|
|
577
|
+
if (typeof attrValue === "function") {
|
|
578
|
+
rc.status.refs++;
|
|
579
|
+
attr += ' onmount="$emit(event,$MF_' + rc.mfs.gen(attrValue) + toStr(rc.scope, (i) => "," + i) + ')"';
|
|
580
|
+
} else if (isObject(attrValue) && attrValue instanceof Ref) {
|
|
581
|
+
attr += " data-ref=" + toAttrStringLit(attrValue.scope + ":" + attrValue.name);
|
|
582
|
+
}
|
|
583
|
+
break;
|
|
584
|
+
case "action":
|
|
585
|
+
if (typeof attrValue === "function") {
|
|
586
|
+
attr += ' onsubmit="$onsubmit(event,$MF_' + rc.mfs.gen(attrValue) + toStr(rc.scope, (i) => "," + i) + ')"';
|
|
587
|
+
} else if (isString(attrValue)) {
|
|
588
|
+
attr += " action=" + toAttrStringLit(attrValue);
|
|
589
|
+
}
|
|
590
|
+
break;
|
|
591
|
+
case "slot":
|
|
592
|
+
if (!stripSlotProp && isString(attrValue)) {
|
|
593
|
+
attr += " slot=" + toAttrStringLit(attrValue);
|
|
594
|
+
}
|
|
595
|
+
break;
|
|
596
|
+
default:
|
|
597
|
+
if (attrValue !== void 0 && attrValue !== null && attrValue !== false) {
|
|
598
|
+
if (attrName.startsWith("on") && typeof attrValue === "function") {
|
|
599
|
+
attr += " " + escapeHTML(attrName.toLowerCase()) + '="$emit(event,$MF_' + rc.mfs.gen(attrValue) + toStr(rc.scope, (i) => "," + i) + ')"';
|
|
600
|
+
} else {
|
|
601
|
+
attr += " " + escapeHTML(attrName);
|
|
602
|
+
if (attrValue !== "" && attrValue !== true) {
|
|
603
|
+
attr += "=" + toAttrStringLit(String(attrValue));
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
return [attr, addonHtml, signal];
|
|
609
|
+
}
|
|
610
|
+
async function renderFC(rc, fc, props) {
|
|
611
|
+
const { write } = rc;
|
|
612
|
+
const { children } = props;
|
|
613
|
+
const scope = ++rc.status.scopeIndex;
|
|
614
|
+
const signals = createSignals(scope, rc.appSignals, rc.context, rc.request);
|
|
615
|
+
const slots = children !== void 0 ? Array.isArray(children) ? isVNode(children) ? [children] : children : [children] : void 0;
|
|
616
|
+
try {
|
|
617
|
+
const v = fc.call(signals, props);
|
|
618
|
+
if (isObject(v) && !isVNode(v)) {
|
|
619
|
+
if (v instanceof Promise) {
|
|
620
|
+
if ((props.rendering ?? fc.rendering) === "eager") {
|
|
621
|
+
await renderNode({ ...rc, scope, slots }, await v);
|
|
622
|
+
writeEffects(rc, scope, signals);
|
|
623
|
+
} else {
|
|
624
|
+
const chunkIdAttr = 'chunk-id="' + (rc.status.chunkIndex++).toString(36) + '"';
|
|
625
|
+
write("<m-portal " + chunkIdAttr + ">");
|
|
626
|
+
if (props.placeholder) {
|
|
627
|
+
await renderNode({ ...rc, scope }, props.placeholder);
|
|
628
|
+
}
|
|
629
|
+
write("</m-portal>");
|
|
630
|
+
rc.suspenses.push(v.then(async (node) => {
|
|
631
|
+
let buf = "";
|
|
632
|
+
let write2 = (chunk) => {
|
|
633
|
+
buf += chunk;
|
|
634
|
+
};
|
|
635
|
+
buf += "<m-chunk " + chunkIdAttr + "><template>";
|
|
636
|
+
await renderNode({ ...rc, scope, slots, write: write2 }, node);
|
|
637
|
+
writeEffects({ ...rc, write: write2 }, scope, signals);
|
|
638
|
+
return buf + "</template></m-chunk>";
|
|
639
|
+
}));
|
|
640
|
+
}
|
|
641
|
+
} else if (Symbol.asyncIterator in v) {
|
|
642
|
+
if ((props.rendering ?? fc.rendering) === "eager") {
|
|
643
|
+
for await (const c of v) {
|
|
644
|
+
await renderNode({ ...rc, scope, slots }, c);
|
|
645
|
+
}
|
|
646
|
+
writeEffects(rc, scope, signals);
|
|
647
|
+
} else {
|
|
648
|
+
const chunkIdAttr = 'chunk-id="' + (rc.status.chunkIndex++).toString(36) + '"';
|
|
649
|
+
write("<m-portal " + chunkIdAttr + ">");
|
|
650
|
+
if (props.placeholder) {
|
|
651
|
+
await renderNode({ ...rc, scope }, props.placeholder);
|
|
652
|
+
}
|
|
653
|
+
write("</m-portal>");
|
|
654
|
+
const iter = () => rc.suspenses.push(
|
|
655
|
+
v.next().then(async ({ done, value }) => {
|
|
656
|
+
let buf = "<m-chunk " + chunkIdAttr;
|
|
657
|
+
let write2 = (chunk) => {
|
|
658
|
+
buf += chunk;
|
|
659
|
+
};
|
|
660
|
+
if (done) {
|
|
661
|
+
buf += " done>";
|
|
662
|
+
writeEffects({ ...rc, write: write2 }, scope, signals);
|
|
663
|
+
return buf + "</m-chunk>";
|
|
664
|
+
}
|
|
665
|
+
buf += " next><template>";
|
|
666
|
+
await renderNode({ ...rc, scope, slots, write: write2 }, value);
|
|
667
|
+
iter();
|
|
668
|
+
return buf + "</template></m-chunk>";
|
|
669
|
+
})
|
|
670
|
+
);
|
|
671
|
+
iter();
|
|
672
|
+
}
|
|
673
|
+
} else if (Symbol.iterator in v) {
|
|
674
|
+
for (const node of v) {
|
|
675
|
+
await renderNode({ ...rc, scope, slots }, node);
|
|
676
|
+
}
|
|
677
|
+
writeEffects(rc, scope, signals);
|
|
678
|
+
}
|
|
679
|
+
} else if (v) {
|
|
680
|
+
await renderNode({ ...rc, scope, slots }, v);
|
|
681
|
+
writeEffects(rc, scope, signals);
|
|
682
|
+
}
|
|
683
|
+
} catch (err) {
|
|
684
|
+
if (err instanceof Error) {
|
|
685
|
+
if (props.catch) {
|
|
686
|
+
await renderNode({ ...rc, scope }, props.catch(err));
|
|
687
|
+
} else {
|
|
688
|
+
write('<pre style="color:red;font-size:1rem"><code>' + escapeHTML(err.message) + "</code></pre>");
|
|
689
|
+
console.error(err);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
async function renderChildren(rc, children, stripSlotProp) {
|
|
695
|
+
if (Array.isArray(children) && !isVNode(children)) {
|
|
696
|
+
for (const child of children) {
|
|
697
|
+
await renderNode(rc, child, stripSlotProp);
|
|
698
|
+
}
|
|
699
|
+
} else {
|
|
700
|
+
await renderNode(rc, children, stripSlotProp);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
var collectDeps;
|
|
704
|
+
function createSignals(scope, appSignals, context = {}, request) {
|
|
705
|
+
const effects = [];
|
|
706
|
+
const computed = (compute) => {
|
|
707
|
+
const deps = /* @__PURE__ */ Object.create(null);
|
|
708
|
+
collectDeps = (fc, key, value2) => deps[fc + ":" + key] = value2;
|
|
709
|
+
const value = compute.call(thisProxy);
|
|
710
|
+
collectDeps = void 0;
|
|
711
|
+
if (value instanceof Promise || Object.keys(deps).length === 0) return value;
|
|
712
|
+
return new Signal(scope, { compute, deps }, value);
|
|
713
|
+
};
|
|
714
|
+
const refs = new Proxy(/* @__PURE__ */ Object.create(null), {
|
|
715
|
+
get(_target, key) {
|
|
716
|
+
return new Ref(scope, key);
|
|
717
|
+
}
|
|
718
|
+
});
|
|
719
|
+
const thisProxy = new Proxy(/* @__PURE__ */ Object.create(null), {
|
|
720
|
+
get(target, key, receiver) {
|
|
721
|
+
switch (key) {
|
|
722
|
+
case "app":
|
|
723
|
+
return appSignals;
|
|
724
|
+
case "context":
|
|
725
|
+
return context;
|
|
726
|
+
case "request":
|
|
727
|
+
return request;
|
|
728
|
+
case "refs":
|
|
729
|
+
return refs;
|
|
730
|
+
case "computed":
|
|
731
|
+
return computed;
|
|
732
|
+
case "effect":
|
|
733
|
+
return (effect) => {
|
|
734
|
+
effects.push(effect.toString());
|
|
735
|
+
};
|
|
736
|
+
case $effects:
|
|
737
|
+
return effects;
|
|
738
|
+
default:
|
|
739
|
+
if (typeof key === "string") {
|
|
740
|
+
const value = Reflect.get(target, key, receiver);
|
|
741
|
+
if (value instanceof Signal) {
|
|
742
|
+
return value;
|
|
743
|
+
}
|
|
744
|
+
if (collectDeps) {
|
|
745
|
+
collectDeps(scope, key, value);
|
|
746
|
+
return value;
|
|
747
|
+
}
|
|
748
|
+
return new Signal(scope, key, value);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
},
|
|
752
|
+
set(target, key, value, receiver) {
|
|
753
|
+
return Reflect.set(target, key, value, receiver);
|
|
754
|
+
}
|
|
755
|
+
});
|
|
756
|
+
return thisProxy;
|
|
757
|
+
}
|
|
758
|
+
function markSignal({ signals }, { scope, key, value }) {
|
|
759
|
+
if (isString(key)) {
|
|
760
|
+
signals.set(scope + ":" + key, value);
|
|
761
|
+
} else {
|
|
762
|
+
for (const [id, value2] of Object.entries(key.deps)) {
|
|
763
|
+
if (!signals.has(id)) {
|
|
764
|
+
signals.set(id, value2);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
function writeEffects({ effects, write }, scope, signals) {
|
|
770
|
+
const v = signals[$effects];
|
|
771
|
+
if (Array.isArray(v) && v.length > 0) {
|
|
772
|
+
const n = v.length;
|
|
773
|
+
if (n > 0) {
|
|
774
|
+
const js = new Array(n);
|
|
775
|
+
for (let i = 0; i < n; i++) {
|
|
776
|
+
js[i] = "function $ME_" + scope + "_" + i + "(){return(" + v[i] + ").call(this)};";
|
|
777
|
+
}
|
|
778
|
+
write('<m-effect scope="' + scope + '" n="' + n + '"></m-effect>');
|
|
779
|
+
effects.push(js.join(""));
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
713
783
|
|
|
714
784
|
// jsx-runtime.ts
|
|
785
|
+
var Fragment = $fragment;
|
|
715
786
|
var jsx = (tag, props = /* @__PURE__ */ Object.create(null), key) => {
|
|
716
787
|
const vnode = new Array(3).fill(null);
|
|
717
788
|
vnode[0] = tag;
|
|
@@ -722,7 +793,7 @@ var jsx = (tag, props = /* @__PURE__ */ Object.create(null), key) => {
|
|
|
722
793
|
}
|
|
723
794
|
if (tag === "html") {
|
|
724
795
|
const renderOptions = /* @__PURE__ */ Object.create(null);
|
|
725
|
-
const optionsKeys = /* @__PURE__ */ new Set(["
|
|
796
|
+
const optionsKeys = /* @__PURE__ */ new Set(["app", "context", "request", "status", "headers", "rendering", "htmx"]);
|
|
726
797
|
for (const [key2, value] of Object.entries(props)) {
|
|
727
798
|
if (optionsKeys.has(key2) || key2.startsWith("htmx-ext-")) {
|
|
728
799
|
renderOptions[key2] = value;
|
|
@@ -733,13 +804,22 @@ var jsx = (tag, props = /* @__PURE__ */ Object.create(null), key) => {
|
|
|
733
804
|
}
|
|
734
805
|
return vnode;
|
|
735
806
|
};
|
|
736
|
-
var
|
|
807
|
+
var jsxEscape = (value) => {
|
|
808
|
+
if (value === null || value === void 0 || typeof value === "boolean") {
|
|
809
|
+
return "";
|
|
810
|
+
}
|
|
811
|
+
if (typeof value === "number" || typeof value === "bigint") {
|
|
812
|
+
return String(value);
|
|
813
|
+
}
|
|
814
|
+
return escapeHTML(String(value));
|
|
815
|
+
};
|
|
737
816
|
var html = (raw, ...values) => [
|
|
738
817
|
$html,
|
|
739
|
-
{ innerHTML: String.raw({ raw }, ...values) },
|
|
818
|
+
{ innerHTML: String.raw({ raw }, ...values.map(jsxEscape)) },
|
|
740
819
|
$vnode
|
|
741
820
|
];
|
|
742
821
|
Object.assign(globalThis, {
|
|
822
|
+
JSX,
|
|
743
823
|
html,
|
|
744
824
|
css: html,
|
|
745
825
|
js: html
|