mono-jsx 0.7.2 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/jsx-runtime.mjs CHANGED
@@ -16,7 +16,7 @@ var STYLE_JS = `{var l=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^o
16
16
  var RENDER_ATTR_JS = `{var s=(l,n,r)=>{let e=l.parentElement;return e.tagName==="M-GROUP"&&(e=e.previousElementSibling),()=>{let t=r();n==="value"?e.value=String(t):n==="checked"?e.checked=!!t:typeof t=="boolean"?e.toggleAttribute(n,t):t==null?e.removeAttribute(n):typeof t=="object"?n==="class"?e.setAttribute(n,$cx(t)):n==="style"?$applyStyle(e,t):e.setAttribute(n,JSON.stringify(t)):e.setAttribute(n,String(t))}};window.$renderAttr=s;}`;
17
17
  var RENDER_TOGGLE_JS = `{var i=(e,s)=>{let t,l=()=>e.replaceChildren(...s()?t:[]);return()=>{if(!t){let n=e.firstElementChild;n&&n.tagName==="TEMPLATE"&&n.hasAttribute("m-slot")?t=[...n.content.childNodes]:t=[...e.childNodes]}e.hasAttribute("vt")&&document.startViewTransition?document.startViewTransition(l):l()}};window.$renderToggle=i;}`;
18
18
  var RENDER_SWITCH_JS = `{var a=(l,u)=>{let s,r=l.getAttribute("value"),t,i,o=e=>t.get(e)??t.set(e,[]).get(e),d=()=>l.replaceChildren(...t.has(s)?t.get(s):i);return()=>{if(!t){t=new Map,i=[];for(let e of l.childNodes)if(e.nodeType===1&&e.tagName==="TEMPLATE"&&e.hasAttribute("m-slot")){for(let n of e.content.childNodes)n.nodeType===1&&n.hasAttribute("slot")?o(n.getAttribute("slot")).push(n):i.push(n);e.remove()}else r?o(r).push(e):i.push(e)}s=""+u(),l.hasAttribute("vt")&&document.startViewTransition?document.startViewTransition(d):d()}};window.$renderSwitch=a;}`;
19
- var SIGNALS_JS = `{let m;const w=window,p=document,y=new Map,k=new Map,l=n=>k.get(n)??k.set(n,T(n)).get(n),$=()=>Object.create(null),f=(n,e)=>n.getAttribute(e),T=n=>{const e=$(),t=(c,r)=>{e[c]=r},s=new Map,o=(c,r)=>{let i=s.get(c);return i||(i=new Set,s.set(c,i)),i.add(r),()=>{i.delete(r),i.size===0&&s.delete(c)}},a=new Proxy($(),{get:(c,r)=>p.querySelector("[data-ref='"+n+":"+r+"']")});return new Proxy(e,{get:(c,r,i)=>{switch(r){case"$init":return t;case"$watch":return o;case"app":return l(0);case"refs":return a;default:return m?.(n,r),Reflect.get(c,r,i)}},set:(c,r,i,d)=>{if(i!==Reflect.get(c,r,d)){const u=s.get(r);return u&&queueMicrotask(()=>u.forEach(g=>g())),Reflect.set(c,r,i,d)}return!1}})},v=(n,e,t)=>{switch(e){case"toggle":return $renderToggle(n,t);case"switch":return $renderSwitch(n,t);case"html":return()=>n.innerHTML=""+t()}if(e&&e.length>2&&e.startsWith("[")&&e.endsWith("]"))return $renderAttr(n,e.slice(1,-1),t);const s=n.parentElement,o=()=>n.textContent=""+t();return p.startViewTransition&&s.hasAttribute("data-vt")?(s.style.viewTransitionName=s.getAttribute("data-vt"),()=>p.startViewTransition(o)):o},E=n=>{const e=n.indexOf(":");return e>0?[Number(n.slice(0,e)),n.slice(e+1)]:null},b=async n=>{const e=n();return e!==void 0?e:(await new Promise(t=>setTimeout(t,0)),b(n))},S=n=>{typeof n=="function"&&n()},M=(n,e)=>customElements.define(n,class extends HTMLElement{disposes=[];connectedCallback(){e(this)}disconnectedCallback(){this.disposes.forEach(t=>t()),this.disposes.length=0}});M("m-signal",n=>{const e=Number(f(n,"scope")),t=l(e),s=f(n,"key");if(s)n.disposes.push(t.$watch(s,v(n,f(n,"mode"),()=>t[s])));else{const o=Number(f(n,"computed"));b(()=>y.get(e*1e9+o)).then(([a,c])=>{const r=v(n,f(n,"mode"),a.bind(t));c.forEach(i=>{const[d,u]=E(i);n.disposes.push(l(d).$watch(u,r))})})}}),M("m-effect",n=>{const{disposes:e}=n,t=Number(f(n,"scope")),s=Number(f(n,"n")),o=new Array(s);e.push(()=>{o.forEach(S),o.length=0});for(let a=0;a<s;a++){const c="$ME_"+t+"_"+a;b(()=>w[c]).then(r=>{const i=[],d=l(t),u=()=>{S(o[a]),o[a]=r.call(d)};m=(g,h)=>i.push([g,h]),u(),m=void 0;for(const[g,h]of i)e.push(l(g).$watch(h,u))},()=>{})}}),w.$MS=(n,e)=>{const[t,s]=E(n);l(t).$init(s,e)},w.$MC=(n,e,t,s)=>{y.set(n*1e9+e,[t,s])},w.$patch=(n,...e)=>{for(const[t,...s]of e){const o=s.pop();let a=n;for(const c of s)a=a[c];a[o]=t}return n},w.$signals=n=>n!==void 0?l(n):void 0;}`;
19
+ var SIGNALS_JS = `{let m;const w=window,p=document,y=new Map,k=new Map,l=n=>k.get(n)??k.set(n,M(n)).get(n),$=()=>Object.create(null),f=(n,e)=>n.getAttribute(e),M=n=>{const e=$(),t=(i,r)=>{e[i]=r},s=new Map,a=(i,r)=>{let o=s.get(i);return o||(o=new Set,s.set(i,o)),o.add(r),()=>{o.delete(r),o.size===0&&s.delete(i)}},c=new Proxy($(),{get:(i,r)=>p.querySelector("[data-ref='"+n+":"+r+"']")});return new Proxy(e,{get:(i,r,o)=>{switch(r){case"$init":return t;case"$watch":return a;case"app":return l(0);case"refs":return c;default:return m?.(n,r),Reflect.get(i,r,o)}},set:(i,r,o,d)=>{if(o!==Reflect.get(i,r,d)){const u=s.get(r);return u&&queueMicrotask(()=>u.forEach(g=>g())),Reflect.set(i,r,o,d)}return!1}})},v=(n,e,t)=>{switch(e){case"toggle":return $renderToggle(n,t);case"switch":return $renderSwitch(n,t);case"html":return()=>n.innerHTML=""+t()}if(e&&e.length>2&&e.startsWith("[")&&e.endsWith("]"))return $renderAttr(n,e.slice(1,-1),t);const s=n.parentElement,a=()=>n.textContent=""+t();if(p.startViewTransition&&s.hasAttribute("data-vt")){const c=s.getAttribute("data-vt");return c&&(s.style.viewTransitionName=c),()=>p.startViewTransition(a)}return a},E=n=>{const e=n.indexOf(":");return e>0?[Number(n.slice(0,e)),n.slice(e+1)]:null},b=async n=>{const e=n();return e!==void 0?e:(await new Promise(t=>setTimeout(t,0)),b(n))},S=n=>{typeof n=="function"&&n()},T=(n,e)=>customElements.define(n,class extends HTMLElement{disposes=[];connectedCallback(){e(this)}disconnectedCallback(){this.disposes.forEach(t=>t()),this.disposes.length=0}});T("m-signal",n=>{const e=Number(f(n,"scope")),t=l(e),s=f(n,"key");if(s)n.disposes.push(t.$watch(s,v(n,f(n,"mode"),()=>t[s])));else{const a=Number(f(n,"computed"));b(()=>y.get(e*1e9+a)).then(([c,i])=>{const r=v(n,f(n,"mode"),c.bind(t));i.forEach(o=>{const[d,u]=E(o);n.disposes.push(l(d).$watch(u,r))})})}}),T("m-effect",n=>{const{disposes:e}=n,t=Number(f(n,"scope")),s=Number(f(n,"n")),a=new Array(s);e.push(()=>{a.forEach(S),a.length=0});for(let c=0;c<s;c++){const i="$ME_"+t+"_"+c;b(()=>w[i]).then(r=>{const o=[],d=l(t),u=()=>{S(a[c]),a[c]=r.call(d)};m=(g,h)=>o.push([g,h]),u(),m=void 0;for(const[g,h]of o)e.push(l(g).$watch(h,u))},()=>{})}}),w.$MS=(n,e)=>{const[t,s]=E(n);l(t).$init(s,e)},w.$MC=(n,e,t,s)=>{y.set(n*1e9+e,[t,s])},w.$patch=(n,...e)=>{for(const[t,...s]of e){const a=s.pop();let c=n;for(const i of s)c=c[i];c[a]=t}return n},w.$signals=n=>n!==void 0?l(n):void 0;}`;
20
20
  var SUSPENSE_JS = `{const i=new Map,o=e=>e.getAttribute("chunk-id"),l=(e,t)=>customElements.define(e,class extends HTMLElement{connectedCallback(){t(this)}});l("m-portal",e=>{i.set(o(e),e)}),l("m-chunk",e=>{setTimeout(()=>{const t=o(e),n=i.get(t),s=e.firstChild?.content.childNodes;n&&(e.hasAttribute("next")?s&&n.before(...s):(e.hasAttribute("done")?n.remove():s&&n.replaceWith(...s),i.delete(t)),e.remove())})});}`;
21
21
  var COMPONENT_JS = `{const e=document,a=(t,s)=>t.getAttribute(s);customElements.define("m-component",class extends HTMLElement{static observedAttributes=["name","props"];#t;#s;#r;#h;#i;#e=new Map;#a=!0;async#l(){if(!this.#t){this.#n("");return}const t=this.#s||"{}",s=this.#t+t,i={"x-component":this.#t,"x-props":t,"x-flags":$FLAGS},n=new AbortController;if(this.#h?.abort(),this.#h=n,this.#e.has(s)){this.#n(this.#e.get(s));return}this.#r?.length&&this.#n(this.#r);const r=await fetch(location.href,{headers:i,signal:n.signal});if(!r.ok)throw this.#n(""),new Error("Failed to fetch component '"+this.#t+"'");const[h,o]=await r.json();this.#e.set(s,h),this.#n(h),o&&(e.body.appendChild(e.createElement("script")).textContent=o)}#n(t){const s=()=>typeof t=="string"?this.innerHTML=t:this.replaceChildren(...t);this.hasAttribute("vt")&&e.startViewTransition&&!this.#a?e.startViewTransition(s):s(),this.#a=!1}get name(){return this.#t??null}set name(t){t&&t!==this.#t&&(this.#t=t,this.#o())}get props(){return this.#s?JSON.parse(this.#s):void 0}set props(t){const s=typeof t=="string"?t:JSON.stringify(t);s&&s!==this.#s&&(this.#s=s,this.#o())}attributeChangedCallback(t,s,i){this.#t&&i&&(t==="name"?this.name=i:t==="props"&&(this.props=i))}connectedCallback(){setTimeout(()=>{if(!this.#r){const t=a(this,"props");this.#t=a(this,"name"),this.#s=t?.startsWith("base64,")?atob(t.slice(7)):void 0,this.#r=[...this.childNodes]}this.#l()})}disconnectedCallback(){this.#e.clear(),this.#h?.abort(),this.#h=void 0,this.#i&&clearTimeout(this.#i),this.#i=void 0}#o(){this.#i&&clearTimeout(this.#i),this.#i=setTimeout(()=>{this.#i=void 0,this.#l()},50)}refresh(){this.#t&&this.#e.delete(this.#t+(this.#s||"{}")),this.#o()}});}`;
22
22
  var ROUTER_JS = `{const n=document,a=location,o=t=>t.split("#",1)[0],l=t=>o(t)===o(a.href);customElements.define("m-router",class extends HTMLElement{#t;#s;#i;#n;#e=new Map;#r=!0;async#c(t){const s=new AbortController,i={"x-route":"true","x-flags":$FLAGS};this.#n?.abort(),this.#n=s;const e=await fetch(t,{headers:i,signal:s.signal});if(e.status===404)return null;if(!e.ok)throw this.replaceChildren(),new Error("Failed to fetch route: "+e.status+" "+e.statusText);return e.json()}#a(t){const s=()=>typeof t=="string"?this.innerHTML=t:this.replaceChildren(...t);this.hasAttribute("vt")&&n.startViewTransition&&!this.#r?n.startViewTransition(s):s(),this.#r=!1}#o(){n.querySelectorAll("nav a").forEach(t=>{const{href:s,classList:i}=t,e=t.closest("nav")?.getAttribute("data-active-class")??"active";l(s)?i.add(e):i.remove(e)})}async#l(t,s){const i=this.#c(t).then(e=>{if(e){const[r,c]=e;return this.#e.set(t,r),this.#a(r),c}else this.#e.delete(t),this.#a(this.#t??[]),typeof $signals<"u"&&($signals(0).url=new URL(t))});this.#e.has(t)?this.#a(this.#e.get(t)):await i,history[s?.replace?"replaceState":"pushState"]({},"",t),this.#o(),window.scrollTo(0,0),i.then(e=>{e&&(n.body.appendChild(n.createElement("script")).textContent=e)})}navigate(t,s){const i=new URL(t,a.href);if(i.origin!==a.origin){a.href=t;return}l(i.href)||this.#l(t,s)}connectedCallback(){setTimeout(()=>{if(!this.#t)if(this.hasAttribute("fallback"))this.removeAttribute("fallback"),this.#t=[...this.childNodes];else{this.#t=[];for(const t of this.childNodes)if(t.nodeType===1&&t.tagName==="TEMPLATE"&&t.hasAttribute("m-slot")){this.#t.push(...t.content.childNodes),t.remove();break}}}),this.#s=t=>{if(t.defaultPrevented||t.altKey||t.ctrlKey||t.metaKey||t.shiftKey||!(t.target instanceof HTMLAnchorElement))return;const{download:s,href:i,rel:e,target:r}=t.target;s||e==="external"||r==="_blank"||!i.startsWith(a.origin)||(t.preventDefault(),this.navigate(i))},this.#i=()=>this.#l(a.href),addEventListener("popstate",this.#i),n.addEventListener("click",this.#s),setTimeout(()=>this.#o()),globalThis.$router=this}disconnectedCallback(){removeEventListener("popstate",this.#i),n.removeEventListener("click",this.#s),delete globalThis.$router,this.#n?.abort(),this.#n=void 0,this.#e.clear(),this.#s=void 0,this.#i=void 0}});}`;
@@ -143,7 +143,7 @@ var $signal = Symbol.for("mono.signal");
143
143
  var $vnode = Symbol.for("jsx.vnode");
144
144
 
145
145
  // version.ts
146
- var VERSION = "0.7.2";
146
+ var VERSION = "0.7.3";
147
147
 
148
148
  // render.ts
149
149
  var cdn = "https://raw.esm.sh";
@@ -408,12 +408,15 @@ async function render(node, options, write, writeJS, componentMode, routeForm) {
408
408
  mcs.clear();
409
409
  }
410
410
  if (session && session.isDirty) {
411
- const sessionEntries = session.entries();
411
+ const sessionStore = session.all();
412
412
  const { name = "session", domain, path, expires, maxAge, secure, sameSite, secret } = options.session?.cookie ?? {};
413
413
  if (secret) {
414
414
  let cookie = name + "=";
415
- if (sessionEntries.length > 0) {
416
- const data = JSON.stringify(sessionEntries);
415
+ if (Object.keys(sessionStore).length > 0) {
416
+ const data = JSON.stringify([
417
+ sessionStore,
418
+ Math.floor((expires ? expires.getTime() : Date.now() + (maxAge ?? 18e5)) / 1e3)
419
+ ]);
417
420
  const signature = await subtle.sign(
418
421
  "HMAC",
419
422
  await subtle.importKey("raw", encoder.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]),
@@ -1230,7 +1233,7 @@ async function createSession(request, options) {
1230
1233
  return isDirty;
1231
1234
  },
1232
1235
  get: (key) => sessionStore.get(key),
1233
- entries: () => [...sessionStore.entries()],
1236
+ all: () => Object.fromEntries(sessionStore.entries()),
1234
1237
  set: (key, value) => {
1235
1238
  sessionStore.set(key, value);
1236
1239
  isDirty = true;
@@ -1263,8 +1266,11 @@ async function createSession(request, options) {
1263
1266
  encoder.encode(data)
1264
1267
  );
1265
1268
  if (verified) {
1266
- sessionId = sid;
1267
- sessionStore = new Map(JSON.parse(data));
1269
+ const [map, exp] = JSON.parse(data);
1270
+ if (typeof exp === "number" && exp * 1e3 > Date.now()) {
1271
+ sessionStore = new Map(Object.entries(map));
1272
+ sessionId = sid;
1273
+ }
1268
1274
  }
1269
1275
  } catch (_) {
1270
1276
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mono-jsx",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "description": "`<html>` as a `Response`.",
5
5
  "type": "module",
6
6
  "module": "./index.mjs",
package/types/html.d.ts CHANGED
@@ -46,6 +46,7 @@ export namespace HTML {
46
46
  interface GlobalAttributes<T extends EventTarget> extends EventAttributes<T>, Aria.Attributes, Mono.BaseAttributes, JSX.HtmlTag {
47
47
  /**
48
48
  * A reference to the element.
49
+ * @mono-jsx
49
50
  */
50
51
  ref?: HTMLElement | ((el: T) => unknown);
51
52
  /** Defines a unique identifier (ID) which must be unique in the whole document. Its purpose is to identify the element when linking (using a fragment identifier), scripting, or styling (with CSS). */
@@ -105,6 +106,12 @@ export namespace HTML {
105
106
  is?: string;
106
107
  /** A boolean value that makes the browser disregard user input events for the element. Useful when click events are present. */
107
108
  inert?: boolean;
109
+ /**
110
+ * Enables view transition for the element.
111
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/View_Transitions_API
112
+ * @mono-jsx
113
+ */
114
+ viewTransition?: string | boolean;
108
115
  }
109
116
 
110
117
  interface HtmlAttributes<T extends EventTarget> extends GlobalAttributes<T>, RenderOptions {}
package/types/mono.d.ts CHANGED
@@ -98,11 +98,6 @@ export interface BaseAttributes {
98
98
  * The `slot` attribute assigns a slot in a [shadow DOM](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM) shadow tree to an element: An element with a `slot` attribute is assigned to the slot created by the `<slot>` element whose name attribute's value matches that slot attribute's value.
99
99
  */
100
100
  slot?: string;
101
- /**
102
- * The `viewTransition` attribute is used to control the view transition of the children.
103
- * @mono-jsx
104
- */
105
- viewTransition?: string | boolean;
106
101
  }
107
102
 
108
103
  export interface AsyncComponentAttributes {
@@ -123,95 +118,123 @@ export interface AsyncComponentAttributes {
123
118
 
124
119
  export interface Elements {
125
120
  /**
126
- * The `toggle` element is a built-in element of mono-jsx that toggles the visibility of its children.
121
+ * A built-in element of mono-jsx that toggles the visibility of its children.
122
+ * @mono-jsx
127
123
  */
128
124
  toggle: BaseAttributes & {
129
125
  /**
130
- * The `show` attribute is used to control the visibility of the children.
126
+ * The visibility of the children.
131
127
  */
132
128
  show?: any;
133
129
  /**
134
- * The `hidden` attribute is used to control the visibility of the children.
130
+ * The visibility of the children.
135
131
  */
136
132
  hidden?: any;
133
+
134
+ /**
135
+ * Enables view transition for the children.
136
+ */
137
+ viewTransition?: string | boolean;
137
138
  };
138
139
  /**
139
- * The `switch` element is a built-in element of mono-jsx that chooses one of its children based on the `slot` attribute to display.
140
+ * A a built-in element of mono-jsx that chooses one of its children based on the `slot` attribute to display.
140
141
  * It is similar to a switch statement in programming languages.
142
+ * @mono-jsx
141
143
  */
142
144
  switch: BaseAttributes & {
143
145
  /**
144
- * The `value` attribute is used to control the value of the children.
146
+ * Which child to display.
145
147
  */
146
148
  value?: string | number | boolean | null;
149
+
150
+ /**
151
+ * Enables view transition for the children.
152
+ */
153
+ viewTransition?: string | boolean;
147
154
  };
148
155
  /**
149
- * The `component` element is a built-in element of mono-jsx that is used to load components lazily,
156
+ * A built-in element of mono-jsx that is used to load components lazily,
150
157
  * which can improve performance by reducing the initial load time of the application.
158
+ * @mono-jsx
151
159
  */
152
160
  component: BaseAttributes & AsyncComponentAttributes & {
153
161
  /**
154
- * The `name` attribute is used to control the name of the component.
162
+ * The name of the component to render.
155
163
  */
156
164
  name?: string;
157
165
  /**
158
- * The `props` attribute is used to control the props of the component.
166
+ * The props of the component to render.
159
167
  */
160
168
  props?: Record<string, unknown>;
161
169
  /**
162
- * The `ref` attribute is used to control the ref of the component.
170
+ * The ref of the component.
163
171
  */
164
172
  ref?: ComponentElement | ((el: ComponentElement) => void);
173
+
174
+ /**
175
+ * Enables view transition for the children.
176
+ */
177
+ viewTransition?: string | boolean;
165
178
  };
166
179
  /**
167
- * The `router` element is a built-in element of mono-jsx that provides SPA routing.
180
+ * A built-in element of mono-jsx that provides SPA routing.
181
+ * @mono-jsx
168
182
  */
169
183
  router: BaseAttributes & AsyncComponentAttributes & {
170
184
  /**
171
- * The `base` attribute is used to set the base URL for the router.
185
+ * The base URL for the router.
172
186
  */
173
187
  base?: string;
174
188
  /**
175
- * The `ref` attribute is used to control the ref of the router.
189
+ * The ref of the router.
176
190
  */
177
191
  ref?: RouterElement | ((el: RouterElement) => void);
192
+ /**
193
+ * Enables view transition for the children.
194
+ * @mono-jsx
195
+ */
196
+ viewTransition?: string | boolean;
178
197
  };
179
198
  /**
180
- * The `cache` element is a built-in element of mono-jsx that caches the rendered content of the child nodes
199
+ * A built-in element of mono-jsx that caches the rendered content of the child nodes
181
200
  * with the given key and TTL.
201
+ * @mono-jsx
182
202
  */
183
203
  cache: BaseAttributes & {
184
204
  /**
185
- * The `key` attribute is used to control the key of the cache.
205
+ * The key of the cache.
186
206
  */
187
207
  key?: string;
188
208
  /**
189
- * The `ttl` attribute is used to control the TTL of the cache.
209
+ * The time-to-live of the cache in seconds.
190
210
  */
191
211
  ttl?: number;
192
212
  };
193
213
  /**
194
- * The `static` element is a built-in element of mono-jsx that treats the child nodes as static content,
214
+ * A built-in element of mono-jsx that treats the child nodes as static content,
195
215
  * When the child nodes are rendered once, they will be cached in memory and reused on subsequent renders.
216
+ * @mono-jsx
196
217
  */
197
218
  static: BaseAttributes;
198
219
  /**
199
- * The `redirect` element is a built-in element of mono-jsx that redirects to the given URL in the client side.
220
+ * A built-in element of mono-jsx that redirects to the given URL in the client side.
221
+ * @mono-jsx
200
222
  */
201
223
  redirect: {
202
224
  /**
203
- * The `to` attribute is used to control the redirect URL.
225
+ * The redirect URL.
204
226
  */
205
227
  to?: string | URL;
206
228
  /**
207
- * The `replace` attribute is used to control the replace behavior of the redirect.
229
+ * The replace behavior of the redirect.
208
230
  * Only works when the `router` element is used.
209
231
  */
210
232
  replace?: boolean;
211
233
  };
212
234
  /**
213
- * The `invalid` element is a built-in element of mono-jsx that sets custom validation
235
+ * A built-in element of mono-jsx that sets custom validation
214
236
  * state for the form elements.
237
+ * @mono-jsx
215
238
  */
216
239
  invalid: BaseAttributes & {
217
240
  /**
@@ -220,63 +243,67 @@ export interface Elements {
220
243
  for?: string;
221
244
  };
222
245
  /**
223
- * The `formslot` element is a built-in element of mono-jsx that is used to display the content of the route form
246
+ * A built-in element of mono-jsx that is used to display the content of the route form
224
247
  * in the `form` element.
248
+ * @mono-jsx
225
249
  */
226
250
  formslot: BaseAttributes & {
251
+ /**
252
+ * The insert position of the formslot.
253
+ */
227
254
  mode?: "insertbefore" | "insertafter" | "replace";
228
255
  };
229
256
  }
230
257
 
231
258
  /**
232
- * The `Session` type defines the session API.
259
+ * The session storage API.
233
260
  */
234
261
  export interface Session {
235
262
  /**
236
- * The `sessionId` is used to identify the session.
263
+ * The session ID.
237
264
  */
238
265
  readonly sessionId: string;
239
266
  /**
240
- * The `isDirty` is true, update the session cookie to the client.
267
+ * If true, update the session cookie to the client.
241
268
  */
242
269
  readonly isDirty: boolean;
243
270
  /**
244
- * The `get` method is used to get a value from the session.
271
+ * Gets a value from the session.
245
272
  */
246
273
  get<T = unknown>(key: string): T | undefined;
247
274
  /**
248
- * The `entries` method is used to get all the entries from the session.
275
+ * Gets all the entries from the session.
249
276
  */
250
- entries(): [string, unknown][];
277
+ all(): Record<string, unknown>;
251
278
  /**
252
- * The `set` method is used to set a value in the session.
279
+ * Sets a value in the session.
253
280
  */
254
281
  set(key: string, value: string | number | boolean | any[] | Record<string, unknown>): void;
255
282
  /**
256
- * The `delete` method is used to delete a value from the session.
283
+ * Deletes a value from the session.
257
284
  */
258
285
  delete(key: string): void;
259
286
  /**
260
- * The `destroy` method is used to destroy the session.
287
+ * Destroys the session.
261
288
  */
262
289
  destroy(): void;
263
290
  }
264
291
 
265
292
  declare global {
266
293
  /**
267
- * The `html` function is used to create XSS-unsafed HTML content.
294
+ * Creates XSS-unsafed HTML content.
268
295
  */
269
296
  var html: JSX.Raw;
270
297
  /**
271
- * The `css` function is an alias to `html`.
298
+ * An alias to `html`.
272
299
  */
273
300
  var css: JSX.Raw;
274
301
  /**
275
- * The `js` function is an alias to `html`.
302
+ * An alias to `html`.
276
303
  */
277
304
  var js: JSX.Raw;
278
305
  /**
279
- * The `FC` type defines Signals/Context/Refs API.
306
+ * Defines the Signals/Context/Refs types.
280
307
  */
281
308
  type FC<Signals = {}, AppSignals = {}, Context = {}, Refs = {}, AppRefs = {}> = {
282
309
  /**
@@ -284,78 +311,78 @@ declare global {
284
311
  */
285
312
  readonly app: {
286
313
  /**
287
- * The `app.refs` object is used to store variables in the application scope.
314
+ * The `app.refs` object stores variables in the application scope.
288
315
  * It is similar to `refs`, but it is shared across all components in the application.
289
316
  *
290
317
  * **⚠ This is a client-side only API.**
291
318
  */
292
319
  readonly refs: AppRefs;
293
320
  /**
294
- * The `app.url` object contains the current URL information.
321
+ * The `app.url` object contains the current URL.
295
322
  */
296
323
  readonly url: WithParams<URL>;
297
324
  } & Omit<AppSignals, "refs" | "url">;
298
325
  /**
299
- * The rendering context.
326
+ * The rendering context object.
300
327
  *
301
328
  * **⚠ This is a server-side only API.**
302
329
  */
303
330
  readonly context: Context;
304
331
  /**
305
- * The `request` object contains the current request information.
332
+ * The `request` object contains the current request.
306
333
  *
307
334
  * **⚠ This is a server-side only API.**
308
335
  */
309
336
  readonly request: WithParams<
310
337
  Request & {
311
338
  /**
312
- * Returns the URL of request as a URL object.
339
+ * Returns the URL of the request as a URL object.
313
340
  */
314
341
  URL: URL;
315
342
  }
316
343
  >;
317
344
  /**
318
- * The `form` object created by the route form submission.
345
+ * The `form` object created by the route form.
319
346
  *
320
347
  * **⚠ This is a server-side only API.**
321
348
  */
322
349
  readonly form?: FormData;
323
350
  /**
324
- * The `session` object contains the current session information.
351
+ * The `session` object contains the current session.
325
352
  *
326
353
  * **⚠ This is a server-side only API.**
327
354
  */
328
355
  readonly session: Session;
329
356
  /**
330
- * The `refs` object is used to store variables in clide side.
357
+ * The `refs` object stores variables in clide side.
331
358
  *
332
359
  * **⚠ This is a client-side only API.**
333
360
  */
334
361
  readonly refs: Refs;
335
362
  /**
336
- * The `computed` method is used to create a computed signal.
363
+ * Creates a computed signal.
337
364
  */
338
365
  readonly computed: <T = unknown>(fn: () => T) => T;
339
366
  /**
340
- * `this.$(fn)` is a shortcut for `this.computed(fn)`.
367
+ * A shortcut for `this.computed(fn)`.
341
368
  */
342
369
  readonly $: FC["computed"];
343
370
  /**
344
- * The `effect` method is used to create a side effect.
371
+ * Creates a side effect.
345
372
  * **The effect function is only called on client side.**
346
373
  */
347
374
  readonly effect: (fn: () => void | (() => void)) => void;
348
375
  } & Omit<Signals, "app" | "context" | "request" | "session" | "form" | "refs" | "computed" | "$" | "effect">;
349
376
  /**
350
- * The `Refs` defines the `refs` types.
377
+ * Defines the `refs` type.
351
378
  */
352
379
  type Refs<T, R = {}, RR = {}> = T extends FC<infer S, infer A, infer C> ? FC<S, A, C, R, RR> : never;
353
380
  /**
354
- * The `Context` defines the `context` types.
381
+ * Defines the `context` type.
355
382
  */
356
383
  type Context<T, C = {}> = T extends FC<infer S, infer A, infer _, infer R, infer RR> ? FC<S, A, C, R, RR> : never;
357
384
  /**
358
- * The `ComponentElement` type defines the component element.
385
+ * The `<component>` element.
359
386
  */
360
387
  type ComponentElement = {
361
388
  name: string;
@@ -363,7 +390,7 @@ declare global {
363
390
  refresh: () => Promise<void>;
364
391
  };
365
392
  /**
366
- * The `RouterElement` type defines the router element.
393
+ * The `<router>` element.
367
394
  */
368
395
  type RouterElement = {
369
396
  navigate: (url: string | URL, options?: { replace?: boolean }) => Promise<void>;