pulse-ui-client 0.0.12 → 0.0.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/dist/client.d.ts +1 -1
- package/dist/index.bun.js +3 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +6 -6
- package/dist/index.node.js +3 -3
- package/dist/messages.d.ts +2 -0
- package/dist/pulse.d.ts +7 -2
- package/dist/renderer.d.ts +21 -3
- package/dist/vdom.d.ts +16 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{useEffect as E,useState as a,useMemo as t,createContext as AW,useContext as NW}from"react";import jW,{cloneElement as L,createElement as XW,lazy as BW,Suspense as KW}from"react";var QW="$$fragment",qW="$$";function zW(W){return typeof W==="object"&&W!==null}function JW(W){return typeof W==="object"&&W!==null&&W.tag.startsWith("$$")&&W.tag!=="$$fragment"}import{jsx as n,Fragment as YW}from"react/jsx-runtime";class h{client;path;components;callbackCache;constructor(W,Z,$){this.client=W;this.path=Z;this.components=$;this.callbackCache=new Map}getCallback(W){let Z=this.callbackCache.get(W);if(!Z)Z=(...$)=>this.client.invokeCallback(this.path,W,$),this.callbackCache.set(W,Z);return Z}renderNode(W){if(W==null||typeof W==="boolean"||typeof W==="number"||typeof W==="string")return W;if(zW(W)){let{tag:Z,props:$={},children:Q=[]}=W,q={};for(let[U,z]of Object.entries($))if(typeof z==="string"&&z.startsWith("$$fn:")){let V=z.substring(5);q[U]=this.getCallback(V)}else q[U]=z;if(W.key)q.key=W.key;let J=[];for(let U of Q)J.push(this.renderNode(U));if(JW(W)){let U=W.tag.slice(qW.length),z=this.components[U];return XW(z,q,...J)}return XW(Z===QW?jW.Fragment:Z,q,...J)}return null}}function g(W){let Z=W.props?.children;if(Z==null)return[];return Array.isArray(Z)?Z.slice():[Z]}function kW(W,Z){let $={};for(let[Q,q]of Object.entries(Z||{}))if(typeof q==="string"&&q.startsWith("$$fn:")){let J=q.substring(5);$[Q]=W.getCallback(J)}else $[Q]=q;return $}function HW(W,Z){return L(W,void 0,...Z)}function d(W,Z,$){let Q=W;for(let q of Z){let J=q.path.split(".").filter((z)=>z.length>0).map(Number),U=(z,V)=>{if(V<J.length){M(z,J,V),z=z;let X=J[V],P=g(z),C=P[X];return P[X]=U(C,V+1),HW(z,P)}switch(q.type){case"replace":return $.renderNode(q.data);case"update_props":{M(z,J,V),z=z;let P={...z.props??{}},C=q.data;if(C.remove&&C.remove.length>0){for(let D of C.remove)if(D in P)delete P[D]}if(C.set){let D=kW($,C.set);for(let[G,f]of Object.entries(D))P[G]=f}return L(z,P)}case"insert":{M(z,J,V),z=z;let X=g(z);return X.splice(q.idx,0,$.renderNode(q.data)),L(z,null,...X)}case"remove":{M(z,J,V),z=z;let X=g(z);return X.splice(q.idx,1),L(z,null,...X)}case"move":{M(z,J,V),z=z;let X=g(z),P=X.splice(q.data.from_index,1)[0];return X.splice(q.data.to_index,0,P),L(z,null,...X)}default:throw Error(`[Pulse renderer] Unknown update type: ${q.type}`)}};Q=U(Q,0)}return Q}function yW(W,Z){let $=BW(W);return({children:Q,...q})=>{return n(KW,{fallback:Z??n(YW,{}),children:n($,{...q,children:Q})})}}function M(W,Z,$){return!0}function B(){function W(Z,$){return(Q)=>{let q={};for(let J of Z)q[J]=Q[J];if($)for(let J in $){let U=$[J];q[J]=U(Q)}return q}}return W}var bW=(W)=>W.tagName.toLowerCase(),MW=["id","className","tagName","localName","clientHeight","clientLeft","clientTop","clientWidth","scrollHeight","scrollLeft","scrollTop","scrollWidth","slot"],LW=["autofocus","tabIndex","nonce"],SW=["accessKey","accessKeyLabel","autocapitalize","dir","draggable","hidden","inert","lang","offsetHeight","offsetLeft","offsetTop","offsetWidth","popover","spellcheck","title","translate","writingSuggestions","contentEditable","enterKeyHint","isContentEditable","inputMode"],TW=B()(MW,{tagName:bW}),_W=B()(LW),gW=B()(SW);function K(W){return{...TW(W),..._W(W),...gW(W)}}function F(W,Z){let $=B()(W,Z);return(Q)=>({...K(Q),...$(Q)})}var hW=["hash","host","hostname","href","origin","password","pathname","port","protocol","search","target","download","rel","hreflang","type","username","ping","referrerPolicy","text"],xW=F(hW),pW=["alt","coords","download","hash","host","hostname","href","origin","password","pathname","port","protocol","rel","search","shape","target","username","ping","referrerPolicy"],mW=F(pW),vW=["autoplay","controls","crossOrigin","currentSrc","currentTime","defaultMuted","defaultPlaybackRate","duration","ended","loop","muted","networkState","paused","playbackRate","preload","readyState","seeking","src","volume","preservesPitch"],DW=F(vW),uW=(W)=>DW(W),EW=["disabled","name","type","value","formAction","formEnctype","formMethod","formNoValidate","formTarget","popoverTargetAction"],iW=F(EW),cW=["value"],nW=F(cW),dW=["height","src","type","width","align","name"],lW=F(dW),oW=["disabled","name","type","validationMessage","willValidate"],sW=F(oW),rW=["acceptCharset","action","autocomplete","encoding","enctype","length","method","name","noValidate","target","rel"],aW=F(rW),tW=["allow","allowFullscreen","height","name","referrerPolicy","src","srcdoc","width","align","frameBorder","longDesc","marginHeight","marginWidth","scrolling","sandbox"],eW=F(tW),W1=["alt","crossOrigin","decoding","height","isMap","loading","naturalHeight","naturalWidth","referrerPolicy","sizes","src","srcset","useMap","width","align","border","complete","hspace","longDesc","lowsrc","name","vspace","x","y","fetchPriority"],Z1=F(W1),$1=["accept","alt","autocomplete","checked","defaultChecked","defaultValue","dirName","disabled","height","indeterminate","max","maxLength","min","minLength","multiple","name","pattern","placeholder","readOnly","required","selectionDirection","selectionEnd","selectionStart","size","src","step","type","value","valueAsNumber","width","align","capture","formAction","formEnctype","formMethod","formNoValidate","formTarget","useMap","validationMessage","willValidate","popoverTargetAction"],Q1=F($1),q1=["htmlFor"],z1=F(q1),J1=["value","type"],X1=F(J1),F1=["as","crossOrigin","disabled","fetchPriority","href","hreflang","imageSizes","imageSrcset","integrity","media","referrerPolicy","rel","type","charset","rev","target","sizes"],G1=F(F1),V1=["name"],U1=F(V1),D1=["high","low","max","min","optimum","value"],P1=F(D1),f1=["cite","dateTime"],FW=F(f1),C1=["reversed","start","type","compact"],A1=F(C1),N1=["data","height","name","type","useMap","width","validationMessage","willValidate","align","archive","border","code","codeBase","codeType","declare","hspace","standby","vspace"],O1=F(N1),R1=["disabled","label"],I1=F(R1),w1=["defaultSelected","disabled","index","label","selected","text","value"],j1=F(w1),B1=["defaultValue","name","type","value","htmlFor","validationMessage","willValidate"],K1=F(B1),k1=["max","position","value"],H1=F(k1),y1=["cite"],GW=F(y1),Y1=(W)=>K(W),b1=["async","crossOrigin","defer","fetchPriority","integrity","noModule","referrerPolicy","src","text","type","charset"],M1=B()(b1,{event:(W)=>W.event,htmlFor:(W)=>W.htmlFor}),L1=(W)=>({...K(W),...M1(W)}),S1=["autocomplete","disabled","length","multiple","name","required","selectedIndex","size","type","value","validationMessage","willValidate"],T1=F(S1),_1=["name"],g1=F(_1),h1=["height","media","sizes","src","srcset","type","width"],x1=F(h1),p1=["align"],m1=F(p1),v1=["abbr","cellIndex","colSpan","headers","rowSpan","scope","align","axis","bgColor","ch","chOff","height","noWrap","vAlign","width"],VW=F(v1),u1=["span","align","ch","chOff","vAlign","width"],UW=F(u1),E1=["align","bgColor","border","cellPadding","cellSpacing","frame","rules","summary","width"],i1=F(E1),c1=["rowIndex","sectionRowIndex","align","bgColor","ch","chOff","vAlign"],n1=F(c1),d1=["align","ch","chOff","vAlign"],l=F(d1),l1=(W)=>K(W),o1=["autocomplete","cols","defaultValue","dirName","disabled","maxLength","minLength","name","placeholder","readOnly","required","rows","selectionDirection","selectionEnd","selectionStart","value","wrap","textLength","validationMessage","willValidate"],s1=F(o1),r1=["dateTime"],a1=F(r1),t1=["default","kind","label","readyState","src","srclang"],e1=F(t1),W3=["height","poster","videoHeight","videoWidth","width","playsInline"],Z3=B()(W3),$3=(W)=>({...DW(W),...Z3(W)}),Q3=["clear"],q3=F(Q3),z3=["href","target"],J3=F(z3),X3=["aLink","background","bgColor","link","text","vLink"],F3=F(X3),G3=["compact"],V3=F(G3),U3=["open"],D3=F(U3),P3=["open","returnValue"],f3=F(P3),C3=["align"],A3=F(C3),N3=(W)=>K(W),O3=["align"],y=F(O3),R3=["align","color","noShade","size","width"],I3=F(R3),w3=["version"],j3=F(w3),B3=(W)=>K(W),K3=["content","httpEquiv","name","scheme"],k3=F(K3),H3=["align"],y3=F(H3),Y3=(W)=>K(W),b3=["width"],M3=F(b3),L3=(W)=>K(W),S3=["media","type","disabled"],T3=F(S3),_3=["text"],g3=F(_3),h3=["compact","type"],x3=F(h3),p3={A:xW,AREA:mW,AUDIO:uW,BASE:J3,BLOCKQUOTE:GW,Q:GW,BODY:F3,BR:q3,BUTTON:iW,CANVAS:K,CAPTION:m1,CITE:Y1,COL:UW,COLGROUP:UW,DATA:nW,DETAILS:D3,DIALOG:f3,DIV:A3,DL:V3,EMBED:lW,FIELDSET:sW,FORM:aW,H1:y,H2:y,H3:y,H4:y,H5:y,H6:y,HEAD:N3,HR:I3,HTML:j3,IFRAME:eW,IMG:Z1,INPUT:Q1,LABEL:z1,LI:X1,LINK:G1,MAP:U1,MENU:B3,META:k3,METER:P1,INS:FW,DEL:FW,OBJECT:O1,OL:A1,OPTGROUP:I1,OPTION:j1,OUTPUT:K1,P:y3,PICTURE:Y3,PRE:M3,PROGRESS:H1,SCRIPT:L1,SELECT:T1,SLOT:g1,SOURCE:x1,SPAN:L3,STYLE:T3,TABLE:i1,TBODY:l,THEAD:l,TFOOT:l,TD:VW,TH:VW,TEMPLATE:l1,TEXTAREA:s1,TIME:a1,TITLE:g3,TR:n1,TRACK:e1,UL:x3,VIDEO:$3};function x(W){let Z=W.tagName.toUpperCase(),$=p3[Z];if($)return $(W);throw Error(`Unexpected HTML element tag: ${W.tagName} (update .web/custom/serialize.ts)`)}var m3=(W)=>x(W.target),S=(W)=>W.relatedTarget?x(W.relatedTarget):null;function A(W,Z){return B()(W,{target:m3,...Z||{}})}var w=["target","bubbles","cancelable","defaultPrevented","eventPhase","isTrusted","timeStamp","type"],p=[...w,"detail"],m=[...p,"altKey","button","buttons","clientX","clientY","ctrlKey","metaKey","movementX","movementY","pageX","pageY","screenX","screenY","shiftKey"],v3=[...m,"pointerId","pressure","tangentialPressure","tiltX","tiltY","twist","width","height","pointerType","isPrimary"],u3=A(w),E3=A(p),i3=A(m,{relatedTarget:S}),c3=A(w,{clipboardData:(W)=>PW(W.clipboardData)}),n3=A([...w,"data"]),d3=A(m,{relatedTarget:S,dataTransfer:(W)=>PW(W.dataTransfer)}),l3=A(v3,{relatedTarget:S}),o3=A(w,{relatedTarget:S}),s3=A(w),r3=A(w),a3=A(w),t3=A([...p,"altKey","ctrlKey","code","key","locale","location","metaKey","repeat","shiftKey"]),e3=A([...p,"altKey","ctrlKey","metaKey","shiftKey","changedTouches","targetTouches","touches"],{changedTouches:(W)=>o(W.changedTouches),targetTouches:(W)=>o(W.targetTouches),touches:(W)=>o(W.touches)}),WZ=A([...m,"deltaMode","deltaX","deltaY","deltaZ"],{relatedTarget:S}),ZZ=A([...w,"animationName","elapsedTime","pseudoElement"]),$Z=A([...w,"oldState","newState"]),QZ=A([...w,"elapsedTime","propertyName","pseudoElement"]);function o(W){return Array.from(W).map((Z)=>({target:x(Z.target),identifier:Z.identifier,screenX:Z.screenX,screenY:Z.screenY,clientX:Z.clientX,clientY:Z.clientY,pageX:Z.pageX,pageY:Z.pageY}))}function PW(W){if(!W)return null;let Z=[];if(W.items)for(let $=0;$<W.items.length;$++){let Q=W.items[$];Z.push({kind:Q.kind,type:Q.type})}return{drop_effect:W.dropEffect,effect_allowed:W.effectAllowed,items:Z,types:Array.from(W.types||[])}}var N={};function R(W,Z,$){for(let Q of Z)W[Q]=$}R(N,["pointerdown","pointermove","pointerup","pointercancel","gotpointercapture","lostpointercapture","pointerenter","pointerleave","pointerover","pointerout"],l3);R(N,["click","contextmenu","dblclick","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup"],i3);R(N,["drag","dragend","dragenter","dragexit","dragleave","dragover","dragstart","drop"],d3);R(N,["keydown","keypress","keyup"],t3);R(N,["focus","blur"],o3);R(N,["change","input"],a3);R(N,["invalid"],r3);R(N,["reset","submit"],s3);R(N,["copy","cut","paste"],c3);R(N,["compositionend","compositionstart","compositionupdate"],n3);R(N,["touchcancel","touchend","touchmove","touchstart"],e3);R(N,["scroll"],E3);R(N,["wheel"],WZ);R(N,["animationstart","animationend","animationiteration"],ZZ);R(N,["transitionend"],QZ);R(N,["toggle"],$Z);function s(W){if(W&&typeof W==="object"&&"nativeEvent"in W&&typeof W.isDefaultPrevented==="function"){let Z=W;if(typeof Z.type!=="string")return W;let $=N[Z.type.toLowerCase()];if($)return $(Z);return u3(Z)}return W}function T(W){let Z=new Map,$=[],Q=[],q=[],J=[],U=0;function z(X){if(X==null||typeof X==="number"||typeof X==="string"||typeof X==="boolean")return X;let P=U++,C=Z.get(X);if(C!==void 0)return $.push(P),C;if(Z.set(X,P),X instanceof Date)return Q.push(P),X.getTime();if(Array.isArray(X)){let D=X.length,G=Array(D);for(let f=0;f<D;f++)G[f]=z(X[f]);return G}if(X instanceof Map){J.push(P);let D={};for(let[G,f]of X.entries())D[String(G)]=z(f);return D}if(X instanceof Set){q.push(P);let D=X.size,G=Array(D),f=0;for(let I of X)G[f]=z(I),f+=1;return G}if(typeof X==="object"){let D={},G=Object.keys(X);for(let f=0;f<G.length;f++){let I=G[f];D[I]=z(X[I])}return D}throw Error(`Unsupported value in serialization: ${X}`)}let V=z(W);return[[$,Q,q,J],V]}function r(W,Z){let[[$,Q,q,J],U]=W,z=new Set($),V=new Set(Q),X=new Set(q),P=new Set(J),C=[];function D(G){let f=C.length;if(z.has(f))return C.push(null),C[G];if(V.has(f)){let I=new Date(G);return C.push(I),I}if(G==null||typeof G==="number"||typeof G==="string"||typeof G==="boolean"){if(Z?.coerceNullsToUndefined)return G??void 0;return G}if(Array.isArray(G)){if(X.has(f)){let O=new Set;C.push(O);for(let j=0;j<G.length;j++)O.add(D(G[j]));return O}let I=G.length,H=Array(I);C.push(H);for(let O=0;O<I;O++)H[O]=D(G[O]);return H}if(typeof G==="object"){if(P.has(f)){let O=new Map;C.push(O);let j=Object.keys(G);for(let c=0;c<j.length;c++){let $W=j[c];O.set($W,D(G[$W]))}return O}let I={};C.push(I);let H=Object.keys(G);for(let O=0;O<H.length;O++){let j=H[O];I[j]=D(G[j])}return I}throw Error(`Unsupported value in deserialization: ${G}`)}return D(U)}import{io as FZ}from"socket.io-client";class k extends Error{constructor(W){super(W);this.name="PulseChannelResetError"}}function qZ(){if(typeof crypto<"u"&&typeof crypto.randomUUID==="function")return crypto.randomUUID().replace(/-/g,"");return Math.random().toString(16).slice(2)+Math.random().toString(16).slice(2)}function zZ(W){if(W instanceof Error)return W.message;if(typeof W==="string")return W;try{return JSON.stringify(W)}catch{return String(W)}}function JZ(W){return typeof W.responseTo==="string"}function XZ(W){return typeof W.event==="string"}class fW{client;id;handlers=new Map;pending=new Map;backlog=[];closed=!1;constructor(W,Z){this.client=W;this.id=Z}emit(W,Z){this.ensureOpen(),this.client.sendChannelMessage({type:"channel_message",channel:this.id,event:W,payload:Z})}async request(W,Z){this.ensureOpen();let $=qZ();return new Promise((Q,q)=>{this.pending.set($,{resolve:Q,reject:q}),this.client.sendChannelMessage({type:"channel_message",channel:this.id,event:W,payload:Z,requestId:$}).catch((J)=>{this.pending.delete($),q(J)})})}on(W,Z){this.ensureOpen();let $=this.handlers.get(W);if(!$)$=new Set,this.handlers.set(W,$);return $.add(Z),this.flushBacklog(W),()=>{let Q=this.handlers.get(W);if(!Q)return;if(Q.delete(Z),Q.size===0)this.handlers.delete(W)}}handleServerMessage(W){if(JZ(W))return this.resolvePending(W),this.closed;if(this.closed)return!0;if(!XZ(W))return this.closed;if(W.event==="__close__")return this.close(new k("Channel closed by server")),!0;if(W.requestId)this.dispatchRequest(W);else this.dispatchEvent(W);return this.closed}handleDisconnect(W){this.close(W)}dispose(W){this.close(W)}ensureOpen(){if(this.closed)throw new k("Channel is closed")}flushBacklog(W){if(this.backlog.length===0)return;let Z=[];for(let $ of this.backlog)if($.event===W)this.dispatchEvent($);else Z.push($);this.backlog=Z}dispatchEvent(W){let Z=this.handlers.get(W.event);if(!Z||Z.size===0){this.backlog.push(W);return}for(let $ of Z)try{let Q=$(W.payload);if(Q&&typeof Q.then==="function")Q.catch((q)=>{console.error("Pulse channel handler error",q)})}catch(Q){console.error("Pulse channel handler error",Q)}}async dispatchRequest(W){let Z=this.handlers.get(W.event),$,Q;if(Z&&Z.size>0)for(let q of Z)try{let J=q(W.payload);if($=await Promise.resolve(J),$!==void 0)break}catch(J){Q=J;break}if(Q){await this.client.sendChannelMessage({type:"channel_message",channel:this.id,event:void 0,responseTo:W.requestId,error:zZ(Q)});return}await this.client.sendChannelMessage({type:"channel_message",channel:this.id,event:void 0,responseTo:W.requestId,payload:$})}resolvePending(W){let Z=W.responseTo?this.pending.get(W.responseTo):void 0;if(!Z)return;if(this.pending.delete(W.responseTo),W.error!==void 0&&W.error!==null)Z.reject(new k(String(W.error)));else Z.resolve(W.payload)}close(W){if(this.closed)return;this.closed=!0;for(let Z of this.pending.values())Z.reject(W);this.pending.clear(),this.handlers.clear(),this.backlog=[]}}function CW(W,Z){return new fW(W,Z)}class v{url;renderId;frameworkNavigate;activeViews;socket=null;messageQueue;connectionListeners=new Set;serverErrors=new Map;serverErrorListeners=new Set;channels=new Map;constructor(W,Z,$){this.url=W;this.renderId=Z;this.frameworkNavigate=$;this.socket=null,this.activeViews=new Map,this.messageQueue=[]}isConnected(){return this.socket?.connected??!1}async connect(){if(this.socket)return;return new Promise((W,Z)=>{let $=FZ(this.url,{transports:["websocket","webtransport"],auth:{renderId:this.renderId}});this.socket=$,$.on("connect",()=>{console.log("[SocketIOTransport] Connected:",this.socket?.id);for(let[Q,q]of this.activeViews)$.emit("message",T({type:"mount",path:Q,routeInfo:q.routeInfo}));for(let Q of this.messageQueue){if(Q.type==="mount"&&this.activeViews.has(Q.path))continue;if(Q.type==="navigate")continue;$.emit("message",T(Q))}this.messageQueue=[],this.notifyConnectionListeners(!0),W()}),$.on("connect_error",(Q)=>{console.error("[SocketIOTransport] Connection failed:",Q),this.notifyConnectionListeners(!1),Z(Q)}),$.on("disconnect",()=>{console.log("[SocketIOTransport] Disconnected"),this.handleTransportDisconnect(),this.notifyConnectionListeners(!1)}),$.on("message",(Q)=>this.handleServerMessage(r(Q,{coerceNullsToUndefined:!0})))})}onConnectionChange(W){return this.connectionListeners.add(W),W(this.isConnected()),()=>{this.connectionListeners.delete(W)}}notifyConnectionListeners(W){for(let Z of this.connectionListeners)Z(W)}onServerError(W){this.serverErrorListeners.add(W);for(let[Z,$]of this.serverErrors)W(Z,$);return()=>{this.serverErrorListeners.delete(W)}}notifyServerError(W,Z){for(let $ of this.serverErrorListeners)$(W,Z)}async sendMessage(W){if(this.isConnected())this.socket.emit("message",T(W));else this.messageQueue.push(W)}async sendChannelMessage(W){await this.sendMessage(W)}mountView(W,Z){if(this.activeViews.has(W))throw Error(`Path ${W} is already mounted`);this.activeViews.set(W,Z),this.sendMessage({type:"mount",path:W,routeInfo:Z.routeInfo})}async navigate(W,Z){await this.sendMessage({type:"navigate",path:W,routeInfo:Z})}unmount(W){this.sendMessage({type:"unmount",path:W}),this.activeViews.delete(W)}disconnect(){this.socket?.disconnect(),this.socket=null,this.messageQueue=[],this.connectionListeners.clear(),this.activeViews.clear(),this.serverErrors.clear(),this.serverErrorListeners.clear();for(let{bridge:W}of this.channels.values())W.dispose(new k("Client disconnected"));this.channels.clear()}handleServerMessage(W){switch(W.type){case"vdom_init":{let Z=this.activeViews.get(W.path);if(!Z)return;if(Z)Z.onInit(W.vdom);if(this.serverErrors.has(W.path))this.serverErrors.delete(W.path),this.notifyServerError(W.path,null);break}case"vdom_update":{let Z=this.activeViews.get(W.path);if(!Z)return;if(Z.onUpdate(W.ops),this.serverErrors.has(W.path))this.serverErrors.delete(W.path),this.notifyServerError(W.path,null);break}case"server_error":{if(!this.activeViews.has(W.path))return;this.serverErrors.set(W.path,W.error),this.notifyServerError(W.path,W.error);break}case"api_call":{this.performApiCall(W);break}case"navigate_to":{let Z=!!W.replace,$=W.path||"";if($.startsWith("//"))$=`${window.location.protocol}${$}`;if(/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test($))if($.startsWith("http://")||$.startsWith("https://"))try{let q=new URL($);if(q.origin===window.location.origin){let J=`${q.pathname}${q.search}${q.hash}`;this.frameworkNavigate(J,{replace:Z})}else if(Z)window.location.replace($);else window.location.assign($)}catch{if(Z)window.location.replace($);else window.location.assign($)}else if(Z)window.location.replace($);else window.location.assign($);else this.frameworkNavigate($,{replace:Z});break}case"channel_message":{this.routeChannelMessage(W);break}default:console.error("Unexpected message:",W)}}async performApiCall(W){try{let Z=await fetch(W.url,{method:W.method||"GET",headers:{...W.headers||{},...W.body!=null&&!("content-type"in(W.headers||{}))?{"content-type":"application/json"}:{}},body:W.body!=null?typeof W.body==="string"?W.body:JSON.stringify(W.body):void 0,credentials:W.credentials||"include"}),$={};Z.headers.forEach((U,z)=>$[z]=U);let Q=null;if((Z.headers.get("content-type")||"").includes("application/json"))Q=await Z.json().catch(()=>null);else Q=await Z.text().catch(()=>null);let J={type:"api_result",id:W.id,ok:Z.ok,status:Z.status,headers:$,body:Q};await this.sendMessage(J)}catch(Z){let $={type:"api_result",id:W.id,ok:!1,status:0,headers:{},body:{error:String(Z)}};await this.sendMessage($)}}async invokeCallback(W,Z,$){await this.sendMessage({type:"callback",path:W,callback:Z,args:$.map(s)})}acquireChannel(W){let Z=this.ensureChannelEntry(W);return Z.refCount+=1,Z.bridge}releaseChannel(W){let Z=this.channels.get(W);if(!Z)return;if(Z.refCount=Math.max(0,Z.refCount-1),Z.refCount===0)Z.bridge.dispose(new k("Channel released")),this.channels.delete(W)}ensureChannelEntry(W){let Z=this.channels.get(W);if(!Z)Z={bridge:CW(this,W),refCount:0},this.channels.set(W,Z);return Z}routeChannelMessage(W){let Z=this.ensureChannelEntry(W.channel);if(Z.bridge.handleServerMessage(W)&&Z.refCount===0)this.channels.delete(W.channel)}handleTransportDisconnect(){for(let W of this.channels.values())W.bridge.handleDisconnect(new k("Connection lost"))}}import{useLocation as GZ,useParams as VZ,useNavigate as UZ}from"react-router";import{jsx as Y,jsxs as u}from"react/jsx-runtime";var OW=AW(null),RW=AW(null),i=()=>{let W=NW(OW);if(!W)throw Error("usePulseClient must be used within a PulseProvider");return W},DZ=(W)=>{let Z=NW(RW);if(!Z)throw Error("usePulsePrerender must be used within a PulseProvider");let $=Z.views[W];if(!$)throw Error(`No prerender found for '${W}'`);return $},e=typeof window<"u";function PZ({children:W,config:Z,prerender:$}){let[Q,q]=a(!0),J=UZ(),{renderId:U}=$,z=t(()=>new v(Z.serverAddress,U,J),[Z.serverAddress,J,U]);return E(()=>z.onConnectionChange(q),[z]),E(()=>{if(e)return z.connect(),()=>z.disconnect()},[z]),Y(OW.Provider,{value:z,children:u(RW.Provider,{value:$,children:[!Q&&Y("div",{style:{position:"fixed",bottom:"20px",right:"20px",backgroundColor:"red",color:"white",padding:"10px",borderRadius:"5px",zIndex:1000},children:"Failed to connect to the server."}),W]})})}function fZ({externalComponents:W,path:Z}){let $=i(),Q=DZ(Z),q=t(()=>new h($,Z,W),[$,Z,W]),[J,U]=a(()=>q.renderNode(Q)),[z,V]=a(null),X=GZ(),P=VZ(),C=t(()=>{let{"*":D="",...G}=P,f=new URLSearchParams(X.search);return{hash:X.hash,pathname:X.pathname,query:X.search,queryParams:Object.fromEntries(f.entries()),pathParams:G,catchall:D.length>0?D.split("/"):[]}},[X.hash,X.pathname,X.search,JSON.stringify(P)]);if(E(()=>{if(e){$.mountView(Z,{routeInfo:C,onInit:(G)=>{U(q.renderNode(G))},onUpdate:(G)=>{U((f)=>f==null?f:d(f,G,q))}});let D=$.onServerError((G,f)=>{if(G===Z)V(f)});return()=>{D(),$.unmount(Z)}}},[$]),E(()=>{if(e)$.navigate(Z,C)},[$,Z,C]),z)return Y(CZ,{error:z});return J}function CZ({error:W}){return u("div",{style:{padding:16,border:"1px solid #e00",background:"#fff5f5",color:"#900",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',whiteSpace:"pre-wrap"},children:[u("div",{style:{fontWeight:700,marginBottom:8},children:["Server Error during ",W.phase]}),W.message&&Y("div",{children:W.message}),W.stack&&u("details",{open:!0,style:{marginTop:8},children:[Y("summary",{children:"Stack trace"}),Y("pre",{style:{margin:0},children:W.stack})]})]})}import{useEffect as AZ,useMemo as NZ}from"react";function OZ(W){let Z=i(),$=NZ(()=>{if(!W)throw Error("usePulseChannel requires a non-empty channelId");return Z.acquireChannel(W)},[Z,W]);return AZ(()=>{return()=>{Z.releaseChannel(W)}},[Z,W]),$}import{forwardRef as RZ,useCallback as IZ}from"react";import{jsx as jZ}from"react/jsx-runtime";var wZ=RZ(function({onSubmit:Z,action:$,...Q},q){return jZ("form",{...Q,action:$,ref:q,onSubmit:IZ((J)=>IW({event:J,action:$,onSubmit:Z}),[$,Z])})});async function IW({event:W,action:Z,onSubmit:$,formData:Q,force:q}){if($?.(W),!q&&W.defaultPrevented)return;let J=W.currentTarget;W.preventDefault();let U=W.nativeEvent;if(!Q)Q=new FormData(J,U.submitter);let z=new URL(Z,window.location.href);try{await fetch(z,{method:"POST",credentials:"include",body:Q})}catch(V){throw V}}import{io as BZ}from"socket.io-client";class wW{url;socket=null;listener=null;messageQueue=[];connectionListeners=new Set;constructor(W){this.url=W}connect(W){return this.listener=W,new Promise((Z,$)=>{this.socket=BZ(this.url,{transports:["websocket"]}),this.socket.on("connect",()=>{console.log("[SocketIOTransport] Connected:",this.socket?.id);for(let Q of this.messageQueue)this.socket?.emit("message",Q);this.messageQueue=[],this.notifyConnectionListeners(!0),Z()}),this.socket.on("connect_error",(Q)=>{console.error("[SocketIOTransport] Connection failed:",Q),this.notifyConnectionListeners(!1),$(Q)}),this.socket.on("disconnect",()=>{console.log("[SocketIOTransport] Disconnected"),this.notifyConnectionListeners(!1)}),this.socket.on("message",(Q)=>{this.listener?.(Q)})})}disconnect(){this.socket?.disconnect(),this.socket=null,this.listener=null,this.messageQueue=[],this.connectionListeners.clear()}async sendMessage(W){if(this.isConnected())this.socket.emit("message",W);else this.messageQueue.push(W)}isConnected(){return this.socket?.connected||!1}onConnectionChange(W){return this.connectionListeners.add(W),W(this.isConnected()),()=>{this.connectionListeners.delete(W)}}notifyConnectionListeners(W){for(let Z of this.connectionListeners)Z(W)}}function KZ({params:W,request:Z}){let{"*":$="",...Q}=W,q=new URL(Z.url);return{hash:q.hash,pathname:q.pathname,query:q.search,queryParams:Object.fromEntries(q.searchParams.entries()),pathParams:Q,catchall:$.length>1?$.split("/"):[]}}function kZ(W){if(W===null||typeof W!=="object")return!1;let Z=Object.getPrototypeOf(W);return Z===Object.prototype||Z===null}function WW(W){return typeof W==="function"||typeof W==="symbol"||typeof W>"u"}async function HZ(W){let Z=await W.arrayBuffer();return Array.from(new Uint8Array(Z))}async function yZ(W){return await _(W,{seen:new WeakMap,nextId:1})}function YZ(W,Z){if(W.seen.get(Z)!==void 0)return null;let Q=W.nextId++;return W.seen.set(Z,Q),Q}async function _(W,Z){if(W===null||typeof W!=="object")return W;if(W instanceof Date)return{__t:"datetime",timestamp:W.getTime()};if(W instanceof FormData){let z=YZ(Z,W);if(z===null)return{__t:"ref",id:Z.seen.get(W)};let V={};for(let[P,C]of W.entries()){let D=await _(C,Z);if(D===void 0)continue;if(Object.prototype.hasOwnProperty.call(V,P)){let G=V[P];if(Array.isArray(G))G.push(D);else V[P]=[G,D]}else V[P]=D}return{__t:"formdata",fields:V,__id:z}}if(W instanceof File){let z=W,V=await HZ(W);return{__t:"file",name:z.name,type:z.type,size:z.size,lastModified:z.lastModified,content:V}}let $=W,Q=Z.seen.get($);if(Q!==void 0)return{__t:"ref",id:Q};let q=Z.nextId++;if(Z.seen.set($,q),Array.isArray(W)){let V=(await Promise.all(W.map((P)=>_(P,Z)))).filter((P)=>P!==void 0);return{__t:"array",__id:q,items:V}}let J={};if(kZ(W))for(let z of Object.keys(W)){let V=W[z];if(WW(V))continue;let X=await _(V,Z);if(X!==void 0)J[z]=X}else for(let z in W){let V=W[z];if(WW(V))continue;let X=await _(V,Z);if(X!==void 0)J[z]=X}return{__t:"object",__id:q,props:J}}function bZ(W){return b(W)}function b(W){if(W===null||typeof W!=="object")return W;let Z=W,$=Z.__t;if($==="datetime"){let q=Z.timestamp;return new Date(q)}if($==="file"){let q=Z.content;if(Array.isArray(q))return{...Z,content:new Uint8Array(q)};return Z}if($==="formdata"){let q=Z.fields,J={};for(let U of Object.keys(q)){let z=q[U];if(Array.isArray(z))J[U]=z.map((V)=>b(V));else J[U]=b(z)}return{__t:"formdata",fields:J}}if($==="array")return Z.items.map((J)=>b(J));if($==="object"){let q=Z.props,J={};for(let U of Object.keys(q))J[U]=b(q[U]);return J}if($==="ref")return Z;let Q={};for(let q of Object.keys(Z))Q[q]=b(Z[q]);return Q}function MZ(W){return ZW(W,new WeakSet)}function ZW(W,Z){if(W===null||typeof W!=="object")return W;if(Z.has(W))return;if(Z.add(W),Array.isArray(W))return W.map((Q)=>ZW(Q,Z)).filter((Q)=>Q!==void 0);let $={};for(let Q in W){let q=W[Q];if(WW(q))continue;let J=ZW(q,Z);if(J!==void 0)$[Q]=J}return $}export{i as usePulseClient,OZ as usePulseChannel,IW as submitForm,T as serialize,KZ as extractServerRouteInfo,s as extractEvent,yZ as encodeForWire,r as deserialize,bZ as decodeFromWire,MZ as cleanForSerialization,d as applyReactTreeUpdates,h as VDOMRenderer,wW as SocketIOTransport,yW as RenderLazy,fZ as PulseView,v as PulseSocketIOClient,PZ as PulseProvider,wZ as PulseForm,k as PulseChannelResetError};
|
|
1
|
+
import{useEffect as p,useState as a,useMemo as t,createContext as RW,useContext as NW}from"react";import wW,{cloneElement as K,createElement as JW,isValidElement as BW,lazy as KW,Suspense as HW}from"react";var QW="$$fragment",qW="$$";function zW(W){return typeof W==="object"&&W!==null}function FW(W){return typeof W==="object"&&W!==null&&W.tag.startsWith("$$")&&W.tag!=="$$fragment"}import{jsx as d,Fragment as LW}from"react/jsx-runtime";class x{client;path;components;callbackCache;callbackProps;renderPropKeys;constructor(W,Z,$,Q=[],q=[]){this.client=W;this.path=Z;this.components=$;this.callbackCache=new Map,this.callbackProps=new Map,this.renderPropKeys=new Set(q),this.setCallbacks(Q)}setCallbacks(W){this.callbackProps.clear(),this.callbackCache.clear();for(let Z of W){let[$,Q]=this.splitPropPath(Z);if(!this.callbackProps.has($))this.callbackProps.set($,new Set);this.callbackProps.get($).add(Q)}}applyCallbackDelta(W,Z){let $=new Map,Q=(z)=>{if(!$.has(z))$.set(z,new Set(this.callbackProps.get(z)??[]))};if(W.remove)for(let z of W.remove){let[O,F]=this.splitPropPath(z);Q(O);let X=this.callbackProps.get(O);if(!X){this.callbackCache.delete(z);continue}if(this.callbackCache.delete(z),X.delete(F),X.size===0)this.callbackProps.delete(O)}if(W.add)for(let z of W.add){let[O,F]=this.splitPropPath(z);if(Q(O),!this.callbackProps.has(O))this.callbackProps.set(O,new Set);this.callbackProps.get(O).add(F)}let q=Z;for(let[z,O]of $.entries()){let F=new Set(this.callbackProps.get(z)??[]);if(this.setsEqual(O,F))continue;let X=z?z.split(".").filter((G)=>G.length>0):[];q=this.updateCallbacksOnTree(q,X,0,z,O,F)}return q}setRenderProps(W){this.renderPropKeys=new Set(W)}applyRenderPropsDelta(W){if(W.remove)for(let Z of W.remove)this.renderPropKeys.delete(Z);if(W.add)for(let Z of W.add)this.renderPropKeys.add(Z)}getCallback(W,Z){let $=this.propPath(W,Z),Q=this.callbackCache.get($);if(!Q)Q=(...q)=>this.client.invokeCallback(this.path,$,q),this.callbackCache.set($,Q);return Q}renderNode(W,Z=""){if(W==null||typeof W==="boolean"||typeof W==="number"||typeof W==="string")return W;if(zW(W)){let{tag:$,props:Q={},children:q=[]}=W,z={...Q||{}};for(let F of this.getCallbackNames(Z))z[F]=this.getCallback(Z,F);for(let[F,X]of Object.entries(z)){let G=this.propPath(Z,F);if(this.renderPropKeys.has(G)){let J=Z?`${Z}.${F}`:F;z[F]=this.renderNode(X,J)}}if(W.key)z.key=W.key;let O=[];for(let F=0;F<q.length;F+=1){let X=q[F],G=Z?`${Z}.${F}`:String(F);O.push(this.renderNode(X,G))}if(FW(W)){let F=W.tag.slice(qW.length),X=this.components[F];return JW(X,z,...O)}return JW($===QW?wW.Fragment:$,z,...O)}return null}splitPropPath(W){let Z=W.lastIndexOf(".");if(Z===-1)return["",W];return[W.slice(0,Z),W.slice(Z+1)]}propPath(W,Z){return W?`${W}.${Z}`:Z}getCallbackNames(W){let Z=this.callbackProps.get(W);return Z?Array.from(Z):[]}transformValue(W,Z,$){let Q=this.callbackProps.get(W),q=this.propPath(W,Z);if(Q&&Q.size>0&&Q.has(Z))return this.getCallback(W,Z);if(this.renderPropKeys.has(q))return this.renderNode($,q);return $}updateCallbacksOnTree(W,Z,$,Q,q,z){if($<Z.length){M(W,Z,$);let J=W,C=Z[$],A=Number(C),V=Q?`${Q}.${C}`:C;if(!Number.isNaN(A)){let D=y(J),R=D[A],I=this.updateCallbacksOnTree(R,Z,$+1,V,q,z);if(I===R)return W;return D[A]=I,K(J,void 0,...D)}else{let D=J.props??{},R=D[C],I=this.updateCallbacksOnTree(R,Z,$+1,V,q,z);if(I===R)return W;return K(J,{...D,[C]:I})}}if(!BW(W))return W;let O=W,F=O.props??{},X=!1,G={...F};for(let J of q)if(!z.has(J)&&J in G)delete G[J],X=!0;for(let J of z){let C=this.getCallback(Q,J);if(G[J]!==C)G[J]=C,X=!0}if(!X)return W;return K(O,G)}setsEqual(W,Z){if(W.size!==Z.size)return!1;for(let $ of W)if(!Z.has($))return!1;return!0}}function y(W){let Z=W.props?.children;if(Z==null)return[];return Array.isArray(Z)?Z.slice():[Z]}function n(W,Z,$){let Q=W;for(let q of Z){if(q.type==="update_callbacks"){Q=$.applyCallbackDelta(q.data,Q);continue}if(q.type==="update_render_props"){$.applyRenderPropsDelta(q.data);continue}let z=q.path.split(".").filter((F)=>F.length>0),O=(F,X,G)=>{if(X<z.length){M(F,z,X);let J=F,C=z[X],A=+C,V=G?`${G}.${C}`:C;if(!Number.isNaN(A)){let D=y(J),R=D[A];return D[A]=O(R,X+1,V),K(J,void 0,...D)}else{let D=J.props??{},R=D[C],I={...D,[C]:O(R,X+1,V)};return K(J,I)}}switch(q.type){case"replace":return $.renderNode(q.data,q.path);case"update_props":{M(F,z,X);let J=F,A={...J.props??{}},V=q.data;if(V.remove&&V.remove.length>0){for(let D of V.remove)if(D in A)delete A[D]}if(V.set)for(let[D,R]of Object.entries(V.set))A[D]=$.transformValue(G,D,R);return K(J,A)}case"insert":{M(F,z,X);let J=F,C=y(J),A=G?`${G}.${q.idx}`:String(q.idx);return C.splice(q.idx,0,$.renderNode(q.data,A)),K(J,null,...C)}case"remove":{M(F,z,X);let J=F,C=y(J);return C.splice(q.idx,1),K(J,null,...C)}case"move":{M(F,z,X);let J=F,C=y(J),A=C.splice(q.data.from_index,1)[0];return C.splice(q.data.to_index,0,A),K(J,null,...C)}default:throw Error(`[Pulse renderer] Unknown update type: ${q.type}`)}};Q=O(Q,0,"")}return Q}function YW(W,Z){let $=KW(W);return({children:Q,...q})=>{return d(HW,{fallback:Z??d(LW,{}),children:d($,{...q,children:Q})})}}function M(W,Z,$){return!0}function H(){function W(Z,$){return(Q)=>{let q={};for(let z of Z)q[z]=Q[z];if($)for(let z in $){let O=$[z];q[z]=O(Q)}return q}}return W}var MW=(W)=>W.tagName.toLowerCase(),bW=["id","className","tagName","localName","clientHeight","clientLeft","clientTop","clientWidth","scrollHeight","scrollLeft","scrollTop","scrollWidth","slot"],SW=["autofocus","tabIndex","nonce"],kW=["accessKey","accessKeyLabel","autocapitalize","dir","draggable","hidden","inert","lang","offsetHeight","offsetLeft","offsetTop","offsetWidth","popover","spellcheck","title","translate","writingSuggestions","contentEditable","enterKeyHint","isContentEditable","inputMode"],yW=H()(bW,{tagName:MW}),_W=H()(SW),TW=H()(kW);function Y(W){return{...yW(W),..._W(W),...TW(W)}}function U(W,Z){let $=H()(W,Z);return(Q)=>({...Y(Q),...$(Q)})}var gW=["hash","host","hostname","href","origin","password","pathname","port","protocol","search","target","download","rel","hreflang","type","username","ping","referrerPolicy","text"],xW=U(gW),vW=["alt","coords","download","hash","host","hostname","href","origin","password","pathname","port","protocol","rel","search","shape","target","username","ping","referrerPolicy"],mW=U(vW),hW=["autoplay","controls","crossOrigin","currentSrc","currentTime","defaultMuted","defaultPlaybackRate","duration","ended","loop","muted","networkState","paused","playbackRate","preload","readyState","seeking","src","volume","preservesPitch"],DW=U(hW),EW=(W)=>DW(W),uW=["disabled","name","type","value","formAction","formEnctype","formMethod","formNoValidate","formTarget","popoverTargetAction"],pW=U(uW),iW=["value"],cW=U(iW),dW=["height","src","type","width","align","name"],nW=U(dW),lW=["disabled","name","type","validationMessage","willValidate"],oW=U(lW),sW=["acceptCharset","action","autocomplete","encoding","enctype","length","method","name","noValidate","target","rel"],rW=U(sW),aW=["allow","allowFullscreen","height","name","referrerPolicy","src","srcdoc","width","align","frameBorder","longDesc","marginHeight","marginWidth","scrolling","sandbox"],tW=U(aW),eW=["alt","crossOrigin","decoding","height","isMap","loading","naturalHeight","naturalWidth","referrerPolicy","sizes","src","srcset","useMap","width","align","border","complete","hspace","longDesc","lowsrc","name","vspace","x","y","fetchPriority"],W1=U(eW),Z1=["accept","alt","autocomplete","checked","defaultChecked","defaultValue","dirName","disabled","height","indeterminate","max","maxLength","min","minLength","multiple","name","pattern","placeholder","readOnly","required","selectionDirection","selectionEnd","selectionStart","size","src","step","type","value","valueAsNumber","width","align","capture","formAction","formEnctype","formMethod","formNoValidate","formTarget","useMap","validationMessage","willValidate","popoverTargetAction"],$1=U(Z1),Q1=["htmlFor"],q1=U(Q1),z1=["value","type"],F1=U(z1),J1=["as","crossOrigin","disabled","fetchPriority","href","hreflang","imageSizes","imageSrcset","integrity","media","referrerPolicy","rel","type","charset","rev","target","sizes"],X1=U(J1),G1=["name"],U1=U(G1),V1=["high","low","max","min","optimum","value"],D1=U(V1),O1=["cite","dateTime"],XW=U(O1),C1=["reversed","start","type","compact"],A1=U(C1),R1=["data","height","name","type","useMap","width","validationMessage","willValidate","align","archive","border","code","codeBase","codeType","declare","hspace","standby","vspace"],N1=U(R1),f1=["disabled","label"],I1=U(f1),P1=["defaultSelected","disabled","index","label","selected","text","value"],j1=U(P1),w1=["defaultValue","name","type","value","htmlFor","validationMessage","willValidate"],B1=U(w1),K1=["max","position","value"],H1=U(K1),Y1=["cite"],GW=U(Y1),L1=(W)=>Y(W),M1=["async","crossOrigin","defer","fetchPriority","integrity","noModule","referrerPolicy","src","text","type","charset"],b1=H()(M1,{event:(W)=>W.event,htmlFor:(W)=>W.htmlFor}),S1=(W)=>({...Y(W),...b1(W)}),k1=["autocomplete","disabled","length","multiple","name","required","selectedIndex","size","type","value","validationMessage","willValidate"],y1=U(k1),_1=["name"],T1=U(_1),g1=["height","media","sizes","src","srcset","type","width"],x1=U(g1),v1=["align"],m1=U(v1),h1=["abbr","cellIndex","colSpan","headers","rowSpan","scope","align","axis","bgColor","ch","chOff","height","noWrap","vAlign","width"],UW=U(h1),E1=["span","align","ch","chOff","vAlign","width"],VW=U(E1),u1=["align","bgColor","border","cellPadding","cellSpacing","frame","rules","summary","width"],p1=U(u1),i1=["rowIndex","sectionRowIndex","align","bgColor","ch","chOff","vAlign"],c1=U(i1),d1=["align","ch","chOff","vAlign"],l=U(d1),n1=(W)=>Y(W),l1=["autocomplete","cols","defaultValue","dirName","disabled","maxLength","minLength","name","placeholder","readOnly","required","rows","selectionDirection","selectionEnd","selectionStart","value","wrap","textLength","validationMessage","willValidate"],o1=U(l1),s1=["dateTime"],r1=U(s1),a1=["default","kind","label","readyState","src","srclang"],t1=U(a1),e1=["height","poster","videoHeight","videoWidth","width","playsInline"],W3=H()(e1),Z3=(W)=>({...DW(W),...W3(W)}),$3=["clear"],Q3=U($3),q3=["href","target"],z3=U(q3),F3=["aLink","background","bgColor","link","text","vLink"],J3=U(F3),X3=["compact"],G3=U(X3),U3=["open"],V3=U(U3),D3=["open","returnValue"],O3=U(D3),C3=["align"],A3=U(C3),R3=(W)=>Y(W),N3=["align"],b=U(N3),f3=["align","color","noShade","size","width"],I3=U(f3),P3=["version"],j3=U(P3),w3=(W)=>Y(W),B3=["content","httpEquiv","name","scheme"],K3=U(B3),H3=["align"],Y3=U(H3),L3=(W)=>Y(W),M3=["width"],b3=U(M3),S3=(W)=>Y(W),k3=["media","type","disabled"],y3=U(k3),_3=["text"],T3=U(_3),g3=["compact","type"],x3=U(g3),v3={A:xW,AREA:mW,AUDIO:EW,BASE:z3,BLOCKQUOTE:GW,Q:GW,BODY:J3,BR:Q3,BUTTON:pW,CANVAS:Y,CAPTION:m1,CITE:L1,COL:VW,COLGROUP:VW,DATA:cW,DETAILS:V3,DIALOG:O3,DIV:A3,DL:G3,EMBED:nW,FIELDSET:oW,FORM:rW,H1:b,H2:b,H3:b,H4:b,H5:b,H6:b,HEAD:R3,HR:I3,HTML:j3,IFRAME:tW,IMG:W1,INPUT:$1,LABEL:q1,LI:F1,LINK:X1,MAP:U1,MENU:w3,META:K3,METER:D1,INS:XW,DEL:XW,OBJECT:N1,OL:A1,OPTGROUP:I1,OPTION:j1,OUTPUT:B1,P:Y3,PICTURE:L3,PRE:b3,PROGRESS:H1,SCRIPT:S1,SELECT:y1,SLOT:T1,SOURCE:x1,SPAN:S3,STYLE:y3,TABLE:p1,TBODY:l,THEAD:l,TFOOT:l,TD:UW,TH:UW,TEMPLATE:n1,TEXTAREA:o1,TIME:r1,TITLE:T3,TR:c1,TRACK:t1,UL:x3,VIDEO:Z3};function v(W){let Z=W.tagName.toUpperCase(),$=v3[Z];if($)return $(W);throw Error(`Unexpected HTML element tag: ${W.tagName} (update .web/custom/serialize.ts)`)}var m3=(W)=>v(W.target),_=(W)=>W.relatedTarget?v(W.relatedTarget):null;function N(W,Z){return H()(W,{target:m3,...Z||{}})}var w=["target","bubbles","cancelable","defaultPrevented","eventPhase","isTrusted","timeStamp","type"],m=[...w,"detail"],h=[...m,"altKey","button","buttons","clientX","clientY","ctrlKey","metaKey","movementX","movementY","pageX","pageY","screenX","screenY","shiftKey"],h3=[...h,"pointerId","pressure","tangentialPressure","tiltX","tiltY","twist","width","height","pointerType","isPrimary"],E3=N(w),u3=N(m),p3=N(h,{relatedTarget:_}),i3=N(w,{clipboardData:(W)=>OW(W.clipboardData)}),c3=N([...w,"data"]),d3=N(h,{relatedTarget:_,dataTransfer:(W)=>OW(W.dataTransfer)}),n3=N(h3,{relatedTarget:_}),l3=N(w,{relatedTarget:_}),o3=N(w),s3=N(w),r3=N(w),a3=N([...m,"altKey","ctrlKey","code","key","locale","location","metaKey","repeat","shiftKey"]),t3=N([...m,"altKey","ctrlKey","metaKey","shiftKey","changedTouches","targetTouches","touches"],{changedTouches:(W)=>o(W.changedTouches),targetTouches:(W)=>o(W.targetTouches),touches:(W)=>o(W.touches)}),e3=N([...h,"deltaMode","deltaX","deltaY","deltaZ"],{relatedTarget:_}),WZ=N([...w,"animationName","elapsedTime","pseudoElement"]),ZZ=N([...w,"oldState","newState"]),$Z=N([...w,"elapsedTime","propertyName","pseudoElement"]);function o(W){return Array.from(W).map((Z)=>({target:v(Z.target),identifier:Z.identifier,screenX:Z.screenX,screenY:Z.screenY,clientX:Z.clientX,clientY:Z.clientY,pageX:Z.pageX,pageY:Z.pageY}))}function OW(W){if(!W)return null;let Z=[];if(W.items)for(let $=0;$<W.items.length;$++){let Q=W.items[$];Z.push({kind:Q.kind,type:Q.type})}return{drop_effect:W.dropEffect,effect_allowed:W.effectAllowed,items:Z,types:Array.from(W.types||[])}}var f={};function j(W,Z,$){for(let Q of Z)W[Q]=$}j(f,["pointerdown","pointermove","pointerup","pointercancel","gotpointercapture","lostpointercapture","pointerenter","pointerleave","pointerover","pointerout"],n3);j(f,["click","contextmenu","dblclick","mousedown","mouseenter","mouseleave","mousemove","mouseout","mouseover","mouseup"],p3);j(f,["drag","dragend","dragenter","dragexit","dragleave","dragover","dragstart","drop"],d3);j(f,["keydown","keypress","keyup"],a3);j(f,["focus","blur"],l3);j(f,["change","input"],r3);j(f,["invalid"],s3);j(f,["reset","submit"],o3);j(f,["copy","cut","paste"],i3);j(f,["compositionend","compositionstart","compositionupdate"],c3);j(f,["touchcancel","touchend","touchmove","touchstart"],t3);j(f,["scroll"],u3);j(f,["wheel"],e3);j(f,["animationstart","animationend","animationiteration"],WZ);j(f,["transitionend"],$Z);j(f,["toggle"],ZZ);function s(W){if(W&&typeof W==="object"&&"nativeEvent"in W&&typeof W.isDefaultPrevented==="function"){let Z=W;if(typeof Z.type!=="string")return W;let $=f[Z.type.toLowerCase()];if($)return $(Z);return E3(Z)}return W}function T(W){let Z=new Map,$=[],Q=[],q=[],z=[],O=0;function F(G){if(G==null||typeof G==="number"||typeof G==="string"||typeof G==="boolean")return G;let J=O++,C=Z.get(G);if(C!==void 0)return $.push(J),C;if(Z.set(G,J),G instanceof Date)return Q.push(J),G.getTime();if(Array.isArray(G)){let A=G.length,V=Array(A);for(let D=0;D<A;D++)V[D]=F(G[D]);return V}if(G instanceof Map){z.push(J);let A={};for(let[V,D]of G.entries())A[String(V)]=F(D);return A}if(G instanceof Set){q.push(J);let A=G.size,V=Array(A),D=0;for(let R of G)V[D]=F(R),D+=1;return V}if(typeof G==="object"){let A={},V=Object.keys(G);for(let D=0;D<V.length;D++){let R=V[D];A[R]=F(G[R])}return A}throw Error(`Unsupported value in serialization: ${G}`)}let X=F(W);return[[$,Q,q,z],X]}function r(W,Z){let[[$,Q,q,z],O]=W,F=new Set($),X=new Set(Q),G=new Set(q),J=new Set(z),C=[];function A(V){let D=C.length;if(F.has(D))return C.push(null),C[V];if(X.has(D)){let R=new Date(V);return C.push(R),R}if(V==null||typeof V==="number"||typeof V==="string"||typeof V==="boolean"){if(Z?.coerceNullsToUndefined)return V??void 0;return V}if(Array.isArray(V)){if(G.has(D)){let P=new Set;C.push(P);for(let B=0;B<V.length;B++)P.add(A(V[B]));return P}let R=V.length,I=Array(R);C.push(I);for(let P=0;P<R;P++)I[P]=A(V[P]);return I}if(typeof V==="object"){if(J.has(D)){let P=new Map;C.push(P);let B=Object.keys(V);for(let c=0;c<B.length;c++){let $W=B[c];P.set($W,A(V[$W]))}return P}let R={};C.push(R);let I=Object.keys(V);for(let P=0;P<I.length;P++){let B=I[P];R[B]=A(V[B])}return R}throw Error(`Unsupported value in deserialization: ${V}`)}return A(O)}import{io as JZ}from"socket.io-client";class L extends Error{constructor(W){super(W);this.name="PulseChannelResetError"}}function QZ(){if(typeof crypto<"u"&&typeof crypto.randomUUID==="function")return crypto.randomUUID().replace(/-/g,"");return Math.random().toString(16).slice(2)+Math.random().toString(16).slice(2)}function qZ(W){if(W instanceof Error)return W.message;if(typeof W==="string")return W;try{return JSON.stringify(W)}catch{return String(W)}}function zZ(W){return typeof W.responseTo==="string"}function FZ(W){return typeof W.event==="string"}class CW{client;id;handlers=new Map;pending=new Map;backlog=[];closed=!1;constructor(W,Z){this.client=W;this.id=Z}emit(W,Z){this.ensureOpen(),this.client.sendChannelMessage({type:"channel_message",channel:this.id,event:W,payload:Z})}async request(W,Z){this.ensureOpen();let $=QZ();return new Promise((Q,q)=>{this.pending.set($,{resolve:Q,reject:q}),this.client.sendChannelMessage({type:"channel_message",channel:this.id,event:W,payload:Z,requestId:$}).catch((z)=>{this.pending.delete($),q(z)})})}on(W,Z){this.ensureOpen();let $=this.handlers.get(W);if(!$)$=new Set,this.handlers.set(W,$);return $.add(Z),this.flushBacklog(W),()=>{let Q=this.handlers.get(W);if(!Q)return;if(Q.delete(Z),Q.size===0)this.handlers.delete(W)}}handleServerMessage(W){if(zZ(W))return this.resolvePending(W),this.closed;if(this.closed)return!0;if(!FZ(W))return this.closed;if(W.event==="__close__")return this.close(new L("Channel closed by server")),!0;if(W.requestId)this.dispatchRequest(W);else this.dispatchEvent(W);return this.closed}handleDisconnect(W){this.close(W)}dispose(W){this.close(W)}ensureOpen(){if(this.closed)throw new L("Channel is closed")}flushBacklog(W){if(this.backlog.length===0)return;let Z=[];for(let $ of this.backlog)if($.event===W)this.dispatchEvent($);else Z.push($);this.backlog=Z}dispatchEvent(W){let Z=this.handlers.get(W.event);if(!Z||Z.size===0){this.backlog.push(W);return}for(let $ of Z)try{let Q=$(W.payload);if(Q&&typeof Q.then==="function")Q.catch((q)=>{console.error("Pulse channel handler error",q)})}catch(Q){console.error("Pulse channel handler error",Q)}}async dispatchRequest(W){let Z=this.handlers.get(W.event),$,Q;if(Z&&Z.size>0)for(let q of Z)try{let z=q(W.payload);if($=await Promise.resolve(z),$!==void 0)break}catch(z){Q=z;break}if(Q){await this.client.sendChannelMessage({type:"channel_message",channel:this.id,event:void 0,responseTo:W.requestId,error:qZ(Q)});return}await this.client.sendChannelMessage({type:"channel_message",channel:this.id,event:void 0,responseTo:W.requestId,payload:$})}resolvePending(W){let Z=W.responseTo?this.pending.get(W.responseTo):void 0;if(!Z)return;if(this.pending.delete(W.responseTo),W.error!==void 0&&W.error!==null)Z.reject(new L(String(W.error)));else Z.resolve(W.payload)}close(W){if(this.closed)return;this.closed=!0;for(let Z of this.pending.values())Z.reject(W);this.pending.clear(),this.handlers.clear(),this.backlog=[]}}function AW(W,Z){return new CW(W,Z)}class E{url;renderId;frameworkNavigate;activeViews;socket=null;messageQueue;connectionListeners=new Set;serverErrors=new Map;serverErrorListeners=new Set;channels=new Map;constructor(W,Z,$){this.url=W;this.renderId=Z;this.frameworkNavigate=$;this.socket=null,this.activeViews=new Map,this.messageQueue=[]}isConnected(){return this.socket?.connected??!1}async connect(){if(this.socket)return;return new Promise((W,Z)=>{let $=JZ(this.url,{transports:["websocket","webtransport"],auth:{renderId:this.renderId}});this.socket=$,$.on("connect",()=>{console.log("[SocketIOTransport] Connected:",this.socket?.id);for(let[Q,q]of this.activeViews)$.emit("message",T({type:"mount",path:Q,routeInfo:q.routeInfo}));for(let Q of this.messageQueue){if(Q.type==="mount"&&this.activeViews.has(Q.path))continue;if(Q.type==="navigate")continue;$.emit("message",T(Q))}this.messageQueue=[],this.notifyConnectionListeners(!0),W()}),$.on("connect_error",(Q)=>{console.error("[SocketIOTransport] Connection failed:",Q),this.notifyConnectionListeners(!1),Z(Q)}),$.on("disconnect",()=>{console.log("[SocketIOTransport] Disconnected"),this.handleTransportDisconnect(),this.notifyConnectionListeners(!1)}),$.on("message",(Q)=>this.handleServerMessage(r(Q,{coerceNullsToUndefined:!0})))})}onConnectionChange(W){return this.connectionListeners.add(W),W(this.isConnected()),()=>{this.connectionListeners.delete(W)}}notifyConnectionListeners(W){for(let Z of this.connectionListeners)Z(W)}onServerError(W){this.serverErrorListeners.add(W);for(let[Z,$]of this.serverErrors)W(Z,$);return()=>{this.serverErrorListeners.delete(W)}}notifyServerError(W,Z){for(let $ of this.serverErrorListeners)$(W,Z)}async sendMessage(W){if(this.isConnected())this.socket.emit("message",T(W));else this.messageQueue.push(W)}async sendChannelMessage(W){await this.sendMessage(W)}mountView(W,Z){if(this.activeViews.has(W))throw Error(`Path ${W} is already mounted`);this.activeViews.set(W,Z),this.sendMessage({type:"mount",path:W,routeInfo:Z.routeInfo})}async navigate(W,Z){await this.sendMessage({type:"navigate",path:W,routeInfo:Z})}unmount(W){this.sendMessage({type:"unmount",path:W}),this.activeViews.delete(W)}disconnect(){this.socket?.disconnect(),this.socket=null,this.messageQueue=[],this.connectionListeners.clear(),this.activeViews.clear(),this.serverErrors.clear(),this.serverErrorListeners.clear();for(let{bridge:W}of this.channels.values())W.dispose(new L("Client disconnected"));this.channels.clear()}handleServerMessage(W){switch(W.type){case"vdom_init":{let Z=this.activeViews.get(W.path);if(!Z)return;if(Z)Z.onInit(W.vdom,W.callbacks,W.render_props);if(this.serverErrors.has(W.path))this.serverErrors.delete(W.path),this.notifyServerError(W.path,null);break}case"vdom_update":{let Z=this.activeViews.get(W.path);if(!Z)return;if(Z.onUpdate(W.ops),this.serverErrors.has(W.path))this.serverErrors.delete(W.path),this.notifyServerError(W.path,null);break}case"server_error":{if(!this.activeViews.has(W.path))return;this.serverErrors.set(W.path,W.error),this.notifyServerError(W.path,W.error);break}case"api_call":{this.performApiCall(W);break}case"navigate_to":{let Z=!!W.replace,$=W.path||"";if($.startsWith("//"))$=`${window.location.protocol}${$}`;if(/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test($))if($.startsWith("http://")||$.startsWith("https://"))try{let q=new URL($);if(q.origin===window.location.origin){let z=`${q.pathname}${q.search}${q.hash}`;this.frameworkNavigate(z,{replace:Z})}else if(Z)window.location.replace($);else window.location.assign($)}catch{if(Z)window.location.replace($);else window.location.assign($)}else if(Z)window.location.replace($);else window.location.assign($);else this.frameworkNavigate($,{replace:Z});break}case"channel_message":{this.routeChannelMessage(W);break}default:console.error("Unexpected message:",W)}}async performApiCall(W){try{let Z=await fetch(W.url,{method:W.method||"GET",headers:{...W.headers||{},...W.body!=null&&!("content-type"in(W.headers||{}))?{"content-type":"application/json"}:{}},body:W.body!=null?typeof W.body==="string"?W.body:JSON.stringify(W.body):void 0,credentials:W.credentials||"include"}),$={};Z.headers.forEach((O,F)=>$[F]=O);let Q=null;if((Z.headers.get("content-type")||"").includes("application/json"))Q=await Z.json().catch(()=>null);else Q=await Z.text().catch(()=>null);let z={type:"api_result",id:W.id,ok:Z.ok,status:Z.status,headers:$,body:Q};await this.sendMessage(z)}catch(Z){let $={type:"api_result",id:W.id,ok:!1,status:0,headers:{},body:{error:String(Z)}};await this.sendMessage($)}}async invokeCallback(W,Z,$){await this.sendMessage({type:"callback",path:W,callback:Z,args:$.map(s)})}acquireChannel(W){let Z=this.ensureChannelEntry(W);return Z.refCount+=1,Z.bridge}releaseChannel(W){let Z=this.channels.get(W);if(!Z)return;if(Z.refCount=Math.max(0,Z.refCount-1),Z.refCount===0)Z.bridge.dispose(new L("Channel released")),this.channels.delete(W)}ensureChannelEntry(W){let Z=this.channels.get(W);if(!Z)Z={bridge:AW(this,W),refCount:0},this.channels.set(W,Z);return Z}routeChannelMessage(W){let Z=this.ensureChannelEntry(W.channel);if(Z.bridge.handleServerMessage(W)&&Z.refCount===0)this.channels.delete(W.channel)}handleTransportDisconnect(){for(let W of this.channels.values())W.bridge.handleDisconnect(new L("Connection lost"))}}import{useLocation as XZ,useParams as GZ,useNavigate as UZ}from"react-router";import{jsx as S,jsxs as u}from"react/jsx-runtime";var fW=RW(null),IW=RW(null),i=()=>{let W=NW(fW);if(!W)throw Error("usePulseClient must be used within a PulseProvider");return W},VZ=(W)=>{let Z=NW(IW);if(!Z)throw Error("usePulsePrerender must be used within a PulseProvider");let $=Z.views[W];if(!$)throw Error(`No prerender found for '${W}'`);return $},e=typeof window<"u";function DZ({children:W,config:Z,prerender:$}){let[Q,q]=a(!0),z=UZ(),{renderId:O}=$,F=t(()=>new E(Z.serverAddress,O,z),[Z.serverAddress,z,O]);return p(()=>F.onConnectionChange(q),[F]),p(()=>{if(e)return F.connect(),()=>F.disconnect()},[F]),S(fW.Provider,{value:F,children:u(IW.Provider,{value:$,children:[!Q&&S("div",{style:{position:"fixed",bottom:"20px",right:"20px",backgroundColor:"red",color:"white",padding:"10px",borderRadius:"5px",zIndex:1000},children:"Failed to connect to the server."}),W]})})}function OZ({externalComponents:W,path:Z}){let $=i(),Q=VZ(Z),q=Q.vdom,z=t(()=>new x($,Z,W,Q.callbacks,Q.render_props),[$,Z,W,Q]),[O,F]=a(()=>z.renderNode(q)),[X,G]=a(null),J=XZ(),C=GZ(),A=t(()=>{let{"*":V="",...D}=C,R=new URLSearchParams(J.search);return{hash:J.hash,pathname:J.pathname,query:J.search,queryParams:Object.fromEntries(R.entries()),pathParams:D,catchall:V.length>0?V.split("/"):[]}},[J.hash,J.pathname,J.search,JSON.stringify(C)]);if(p(()=>{if(e){$.mountView(Z,{routeInfo:A,onInit:(D,R,I)=>{z.setCallbacks(R),z.setRenderProps(I),F(z.renderNode(D))},onUpdate:(D)=>{F((R)=>R==null?R:n(R,D,z))}});let V=$.onServerError((D,R)=>{if(D===Z)G(R)});return()=>{V(),$.unmount(Z)}}},[$]),p(()=>{if(e)$.navigate(Z,A)},[$,Z,A]),X)return S(CZ,{error:X});return O}function CZ({error:W}){return u("div",{style:{padding:16,border:"1px solid #e00",background:"#fff5f5",color:"#900",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',whiteSpace:"pre-wrap"},children:[u("div",{style:{fontWeight:700,marginBottom:8},children:["Server Error during ",W.phase]}),W.message&&S("div",{children:W.message}),W.stack&&u("details",{open:!0,style:{marginTop:8},children:[S("summary",{children:"Stack trace"}),S("pre",{style:{margin:0},children:W.stack})]})]})}import{useEffect as AZ,useMemo as RZ}from"react";function NZ(W){let Z=i(),$=RZ(()=>{if(!W)throw Error("usePulseChannel requires a non-empty channelId");return Z.acquireChannel(W)},[Z,W]);return AZ(()=>{return()=>{Z.releaseChannel(W)}},[Z,W]),$}import{forwardRef as fZ,useCallback as IZ}from"react";import{jsx as jZ}from"react/jsx-runtime";var PZ=fZ(function({onSubmit:Z,action:$,...Q},q){return jZ("form",{...Q,action:$,ref:q,onSubmit:IZ((z)=>PW({event:z,action:$,onSubmit:Z}),[$,Z])})});async function PW({event:W,action:Z,onSubmit:$,formData:Q,force:q}){if($?.(W),!q&&W.defaultPrevented)return;let z=W.currentTarget;W.preventDefault();let O=W.nativeEvent;if(!Q)Q=new FormData(z,O.submitter);let F=new URL(Z,window.location.href);try{await fetch(F,{method:"POST",credentials:"include",body:Q})}catch(X){throw X}}import{io as wZ}from"socket.io-client";class jW{url;socket=null;listener=null;messageQueue=[];connectionListeners=new Set;constructor(W){this.url=W}connect(W){return this.listener=W,new Promise((Z,$)=>{this.socket=wZ(this.url,{transports:["websocket"]}),this.socket.on("connect",()=>{console.log("[SocketIOTransport] Connected:",this.socket?.id);for(let Q of this.messageQueue)this.socket?.emit("message",Q);this.messageQueue=[],this.notifyConnectionListeners(!0),Z()}),this.socket.on("connect_error",(Q)=>{console.error("[SocketIOTransport] Connection failed:",Q),this.notifyConnectionListeners(!1),$(Q)}),this.socket.on("disconnect",()=>{console.log("[SocketIOTransport] Disconnected"),this.notifyConnectionListeners(!1)}),this.socket.on("message",(Q)=>{this.listener?.(Q)})})}disconnect(){this.socket?.disconnect(),this.socket=null,this.listener=null,this.messageQueue=[],this.connectionListeners.clear()}async sendMessage(W){if(this.isConnected())this.socket.emit("message",W);else this.messageQueue.push(W)}isConnected(){return this.socket?.connected||!1}onConnectionChange(W){return this.connectionListeners.add(W),W(this.isConnected()),()=>{this.connectionListeners.delete(W)}}notifyConnectionListeners(W){for(let Z of this.connectionListeners)Z(W)}}function BZ({params:W,request:Z}){let{"*":$="",...Q}=W,q=new URL(Z.url);return{hash:q.hash,pathname:q.pathname,query:q.search,queryParams:Object.fromEntries(q.searchParams.entries()),pathParams:Q,catchall:$.length>1?$.split("/"):[]}}function KZ(W){if(W===null||typeof W!=="object")return!1;let Z=Object.getPrototypeOf(W);return Z===Object.prototype||Z===null}function WW(W){return typeof W==="function"||typeof W==="symbol"||typeof W>"u"}async function HZ(W){let Z=await W.arrayBuffer();return Array.from(new Uint8Array(Z))}async function YZ(W){return await g(W,{seen:new WeakMap,nextId:1})}function LZ(W,Z){if(W.seen.get(Z)!==void 0)return null;let Q=W.nextId++;return W.seen.set(Z,Q),Q}async function g(W,Z){if(W===null||typeof W!=="object")return W;if(W instanceof Date)return{__t:"datetime",timestamp:W.getTime()};if(W instanceof FormData){let F=LZ(Z,W);if(F===null)return{__t:"ref",id:Z.seen.get(W)};let X={};for(let[J,C]of W.entries()){let A=await g(C,Z);if(A===void 0)continue;if(Object.prototype.hasOwnProperty.call(X,J)){let V=X[J];if(Array.isArray(V))V.push(A);else X[J]=[V,A]}else X[J]=A}return{__t:"formdata",fields:X,__id:F}}if(W instanceof File){let F=W,X=await HZ(W);return{__t:"file",name:F.name,type:F.type,size:F.size,lastModified:F.lastModified,content:X}}let $=W,Q=Z.seen.get($);if(Q!==void 0)return{__t:"ref",id:Q};let q=Z.nextId++;if(Z.seen.set($,q),Array.isArray(W)){let X=(await Promise.all(W.map((J)=>g(J,Z)))).filter((J)=>J!==void 0);return{__t:"array",__id:q,items:X}}let z={};if(KZ(W))for(let F of Object.keys(W)){let X=W[F];if(WW(X))continue;let G=await g(X,Z);if(G!==void 0)z[F]=G}else for(let F in W){let X=W[F];if(WW(X))continue;let G=await g(X,Z);if(G!==void 0)z[F]=G}return{__t:"object",__id:q,props:z}}function MZ(W){return k(W)}function k(W){if(W===null||typeof W!=="object")return W;let Z=W,$=Z.__t;if($==="datetime"){let q=Z.timestamp;return new Date(q)}if($==="file"){let q=Z.content;if(Array.isArray(q))return{...Z,content:new Uint8Array(q)};return Z}if($==="formdata"){let q=Z.fields,z={};for(let O of Object.keys(q)){let F=q[O];if(Array.isArray(F))z[O]=F.map((X)=>k(X));else z[O]=k(F)}return{__t:"formdata",fields:z}}if($==="array")return Z.items.map((z)=>k(z));if($==="object"){let q=Z.props,z={};for(let O of Object.keys(q))z[O]=k(q[O]);return z}if($==="ref")return Z;let Q={};for(let q of Object.keys(Z))Q[q]=k(Z[q]);return Q}function bZ(W){return ZW(W,new WeakSet)}function ZW(W,Z){if(W===null||typeof W!=="object")return W;if(Z.has(W))return;if(Z.add(W),Array.isArray(W))return W.map((Q)=>ZW(Q,Z)).filter((Q)=>Q!==void 0);let $={};for(let Q in W){let q=W[Q];if(WW(q))continue;let z=ZW(q,Z);if(z!==void 0)$[Q]=z}return $}export{i as usePulseClient,NZ as usePulseChannel,PW as submitForm,T as serialize,BZ as extractServerRouteInfo,s as extractEvent,YZ as encodeForWire,r as deserialize,MZ as decodeFromWire,bZ as cleanForSerialization,n as applyReactTreeUpdates,x as VDOMRenderer,jW as SocketIOTransport,YW as RenderLazy,OZ as PulseView,E as PulseSocketIOClient,DZ as PulseProvider,PZ as PulseForm,L as PulseChannelResetError};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=64B394FF0FA9B88A64756E2164756E21
|