@lytjs/renderer 5.0.0 → 6.0.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 +371 -204
- package/dist/dom.cjs +12 -1
- package/dist/dom.cjs.map +1 -0
- package/dist/dom.d.cts +1 -0
- package/dist/dom.d.ts +1 -0
- package/dist/dom.mjs +3 -1
- package/dist/dom.mjs.map +1 -0
- package/dist/index.cjs +3312 -1
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1004 -0
- package/dist/index.d.ts +1004 -0
- package/dist/index.mjs +3190 -1
- package/dist/index.mjs.map +1 -0
- package/dist/ssr.cjs +310 -1
- package/dist/ssr.cjs.map +1 -0
- package/dist/ssr.d.cts +21 -0
- package/dist/ssr.d.ts +21 -0
- package/dist/ssr.mjs +308 -1
- package/dist/ssr.mjs.map +1 -0
- package/package.json +35 -58
- package/dist/miniapp.cjs +0 -21
- package/dist/miniapp.mjs +0 -21
- package/dist/native.cjs +0 -1
- package/dist/native.mjs +0 -1
- package/dist/types/create-renderer.d.ts +0 -20
- package/dist/types/create-renderer.d.ts.map +0 -1
- package/dist/types/dom/dom-ops.d.ts +0 -74
- package/dist/types/dom/dom-ops.d.ts.map +0 -1
- package/dist/types/dom/dom-renderer.d.ts +0 -243
- package/dist/types/dom/dom-renderer.d.ts.map +0 -1
- package/dist/types/dom/index.d.ts +0 -17
- package/dist/types/dom/index.d.ts.map +0 -1
- package/dist/types/dom/patch-events.d.ts +0 -123
- package/dist/types/dom/patch-events.d.ts.map +0 -1
- package/dist/types/dom/patch-props.d.ts +0 -118
- package/dist/types/dom/patch-props.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -36
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/miniapp/index.d.ts +0 -21
- package/dist/types/miniapp/index.d.ts.map +0 -1
- package/dist/types/miniapp/miniapp-compiler.d.ts +0 -269
- package/dist/types/miniapp/miniapp-compiler.d.ts.map +0 -1
- package/dist/types/miniapp/miniapp-event-bridge.d.ts +0 -255
- package/dist/types/miniapp/miniapp-event-bridge.d.ts.map +0 -1
- package/dist/types/miniapp/miniapp-lifecycle.d.ts +0 -224
- package/dist/types/miniapp/miniapp-lifecycle.d.ts.map +0 -1
- package/dist/types/miniapp/miniapp-renderer.d.ts +0 -269
- package/dist/types/miniapp/miniapp-renderer.d.ts.map +0 -1
- package/dist/types/miniapp/miniapp-utils.d.ts +0 -168
- package/dist/types/miniapp/miniapp-utils.d.ts.map +0 -1
- package/dist/types/miniapp/shared-constants.d.ts +0 -28
- package/dist/types/miniapp/shared-constants.d.ts.map +0 -1
- package/dist/types/mount.d.ts +0 -32
- package/dist/types/mount.d.ts.map +0 -1
- package/dist/types/native/index.d.ts +0 -13
- package/dist/types/native/index.d.ts.map +0 -1
- package/dist/types/native/native-renderer.d.ts +0 -249
- package/dist/types/native/native-renderer.d.ts.map +0 -1
- package/dist/types/patch.d.ts +0 -23
- package/dist/types/patch.d.ts.map +0 -1
- package/dist/types/props.d.ts +0 -19
- package/dist/types/props.d.ts.map +0 -1
- package/dist/types/renderer-interfaces.d.ts +0 -157
- package/dist/types/renderer-interfaces.d.ts.map +0 -1
- package/dist/types/shared/abstract-renderer.d.ts +0 -74
- package/dist/types/shared/abstract-renderer.d.ts.map +0 -1
- package/dist/types/ssr/hydration.d.ts +0 -267
- package/dist/types/ssr/hydration.d.ts.map +0 -1
- package/dist/types/ssr/index.d.ts +0 -15
- package/dist/types/ssr/index.d.ts.map +0 -1
- package/dist/types/ssr/ssr-renderer.d.ts +0 -277
- package/dist/types/ssr/ssr-renderer.d.ts.map +0 -1
- package/dist/types/unmount.d.ts +0 -16
- package/dist/types/unmount.d.ts.map +0 -1
- package/dist/types/vapor/index.d.ts +0 -18
- package/dist/types/vapor/index.d.ts.map +0 -1
- package/dist/types/vapor/vapor-compiler.d.ts +0 -76
- package/dist/types/vapor/vapor-compiler.d.ts.map +0 -1
- package/dist/types/vapor/vapor-component.d.ts +0 -55
- package/dist/types/vapor/vapor-component.d.ts.map +0 -1
- package/dist/types/vapor/vapor-reactive.d.ts +0 -133
- package/dist/types/vapor/vapor-reactive.d.ts.map +0 -1
- package/dist/types/vapor/vapor-renderer.d.ts +0 -135
- package/dist/types/vapor/vapor-renderer.d.ts.map +0 -1
- package/dist/types/vnode.d.ts +0 -203
- package/dist/types/vnode.d.ts.map +0 -1
- package/dist/vapor.cjs +0 -1
- package/dist/vapor.mjs +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1 +1,3190 @@
|
|
|
1
|
-
import{registerDOMOperations as pe}from"@lytjs/vdom";var v=(s=>(s[s.ELEMENT=1]="ELEMENT",s[s.FUNCTIONAL_COMPONENT=2]="FUNCTIONAL_COMPONENT",s[s.STATEFUL_COMPONENT=4]="STATEFUL_COMPONENT",s[s.TEXT_CHILDREN=8]="TEXT_CHILDREN",s[s.ARRAY_CHILDREN=16]="ARRAY_CHILDREN",s[s.SLOTS_CHILDREN=32]="SLOTS_CHILDREN",s))(v||{}),k=(l=>(l[l.TEXT=1]="TEXT",l[l.CLASS=2]="CLASS",l[l.STYLE=4]="STYLE",l[l.PROPS=8]="PROPS",l[l.FULL_PROPS=16]="FULL_PROPS",l[l.STABLE_FRAGMENT=32]="STABLE_FRAGMENT",l[l.KEYED_FRAGMENT=64]="KEYED_FRAGMENT",l[l.UNKEYED_FRAGMENT=128]="UNKEYED_FRAGMENT",l[l.NEED_PATCH=256]="NEED_PATCH",l[l.DYNAMIC_SLOTS=512]="DYNAMIC_SLOTS",l[l.HOISTED=-1]="HOISTED",l[l.BAIL=-2]="BAIL",l))(k||{}),j=Symbol("Fragment"),H=Symbol("Text"),F=Symbol("Comment");function y(n){return n.type===j}function N(n){return n.type===H}function E(n){return n.type===F}function U(n,e){return n.type===e.type&&n.key===e.key}function S(n){return Array.isArray(n.dynamicChildren)}function B(n,e,t,o){if(t==="class")n.setClass(e,o);else if(t==="style")n.setStyle(e,o);else if(t.startsWith("on")||t.startsWith("@")){let r=t.startsWith("@")?t.slice(1).toLowerCase():t.slice(2).toLowerCase();n.addEventListener(e,r,o)}else t==="key"||t==="ref"||n.setAttribute(e,t,o)}function w(n,e,t,o,r){if(t==="class")n.setClass(e,o);else if(t==="style")n.setStyle(e,o||{});else if(t.startsWith("on")||t.startsWith("@")){let i=t.startsWith("@")?t.slice(1).toLowerCase():t.slice(2).toLowerCase();r&&n.removeEventListener(e,i,r),o&&n.addEventListener(e,i,o)}else n.setAttribute(e,t,o)}function _(n,e,t,o){for(let r in o){if(r==="key"||r==="ref")continue;let i=t[r],s=o[r];s!==i&&w(n,e,r,s,i)}for(let r in t)if(!(r==="key"||r==="ref")&&!(r in o))if(r==="class")n.setClass(e,"");else if(r==="style")n.setStyle(e,{});else if(r.startsWith("on")||r.startsWith("@")){let i=r.startsWith("@")?r.slice(1).toLowerCase():r.slice(2).toLowerCase();n.removeEventListener(e,i,t[r])}else n.removeAttribute(e,r)}function I(n,e,t,o,r,i){let{shapeFlag:s}=t;if(y(t)){oe(n,e,t,o,r,i);return}if(N(t)){let a=n.createText(t.children);t.el=a,n.insert(o,a,r);return}if(E(t)){let a=n.createComment(t.children);t.el=a,n.insert(o,a,r);return}if(s&1){ne(n,e,t,o,r,i);return}if(s&6){re(e,t,o,r,i);return}}function ne(n,e,t,o,r,i){let s=t.type,a=n.createElement(s);if(t.el=a,t.props)for(let d in t.props){let p=t.props[d];B(n,a,d,p)}let{shapeFlag:c,children:f}=t;c&8?a.textContent=f:c&16&&g(e,f,a,null,i),n.insert(o,a,r)}function g(n,e,t,o,r){for(let i=0;i<e.length;i++)n(null,e[i],t,o,r)}function oe(n,e,t,o,r,i){let{children:s}=t,a=n.createComment("");n.insert(o,a,r),Array.isArray(s)&&s.length>0&&g(e,s,o,a,i),t.el=a,t.anchor=a}function re(n,e,t,o,r){let i=e.component;i&&i.update&&i.update(),i&&i.subTree&&(n(null,i.subTree,t,o,i),e.el=i.subTree.el)}function G(n,e,t,o){let{shapeFlag:r,children:i}=t;if(y(t)){if(Array.isArray(i))for(let s=0;s<i.length;s++)e(i[s],o);t.anchor&&t.anchor.parentNode&&n.remove(t.anchor);return}if(r&6){t.component&&t.component.subTree&&e(t.component.subTree,o);return}t.el&&n.remove(t.el)}function C(n,e){for(let t=0;t<e.length;t++)n(e[t])}import{patchKeyedChildren as ie,patchUnkeyedChildren as se}from"@lytjs/vdom";function L(n,e,t,o,r,i=null,s=null){if(o==null){t&&e(t,r);return}if(t===null){I(n,P(n,e),o,r,i,s);return}if(S(o)&&S(t)){fe(n,e,t,o,r,s);return}if(!U(t,o)){e(t,r),I(n,P(n,e),o,r,i,s);return}o.el=t.el,o.anchor=t.anchor;let{shapeFlag:a}=o;if(y(o)){le(n,e,t,o,r,i,s);return}if(N(o)){o.children!==t.children&&(o.el.nodeValue=o.children);return}if(E(o)){o.children!==t.children&&(o.el.nodeValue=o.children);return}if(a&1){ae(n,e,t,o,s);return}if(a&6){de(t,o,s);return}}function P(n,e){return(t,o,r,i,s)=>{L(n,e,t,o,r,i,s)}}function ae(n,e,t,o,r=null){let i=o.el=t.el,s=t.props||{},a=o.props||{},{patchFlag:c,dynamicProps:f}=o;if(c&&c>0){if(c&1&&t.children!==o.children&&(i.textContent=o.children),c&2&&s.class!==a.class&&n.setClass(i,a.class),c&4&&s.style!==a.style&&n.setStyle(i,a.style||{}),c&8&&f)for(let d=0;d<f.length;d++){let p=f[d],l=s[p],K=a[p];K!==l&&w(n,i,p,K,l)}c&16&&_(n,i,s,a)}else _(n,i,s,a);(!c||!(c&1))&&Y(n,e,t,o,i,null,r)}function Y(n,e,t,o,r,i,s){let a=t.shapeFlag,c=o.shapeFlag,f=t.children,d=o.children;if(c&8){a&16&&C(e,f),f!==d&&(r.textContent=d);return}if(c&16){a&16?ce(n,e,f,d,r,i,s):(a&8&&(r.textContent=""),g(P(n,e),d,r,i,s));return}d==null&&(a&8?r.textContent="":a&16&&C(e,f))}function ce(n,e,t,o,r,i,s){o.every(c=>c.key!==null&&c.key!==void 0)&&t.every(c=>c.key!==null&&c.key!==void 0)?ie(t,o,r,i,s,null,!1):se(t,o,r,i,s,null,!1)}function le(n,e,t,o,r,i,s){let a=t.children,c=o.children;Array.isArray(c)&&c.length>0?(Y(n,e,t,o,r,i,s),o.el=c[0].el,o.anchor=c[c.length-1].el?n.nextSibling(c[c.length-1].el):i):Array.isArray(a)&&a.length>0&&c===null?(C(e,a),o.el=t.el,o.anchor=t.anchor):(o.el=t.el,o.anchor=t.anchor)}function fe(n,e,t,o,r,i){let s=t.dynamicChildren,a=o.dynamicChildren;for(let c=0;c<a.length;c++)L(n,e,s[c],a[c],r,null,i)}function de(n,e,t){e.component=n.component,e.el=n.el,e.component&&e.component.update&&e.component.update()}function ue(n){function e(r,i){G(n,e,r,i)}pe({insert(r,i,s){n.insert(i,r,s)},createElement(r){return n.createElement(r)},createText(r){return n.createText(r)},setText(r,i){r.nodeValue=i},setElementText(r,i){r.textContent=i},remove(r){n.remove(r)},createComment(r){return n.createComment(r)},mount(r,i,s,a,c,f,d){o(null,r,i,s,a)},patch(r,i,s,a,c,f,d,p){o(r,i,s,a,c)},unmount(r,i,s,a){e(r)},move(r,i,s){n.insert(i,r.el,s)}});function o(r,i,s,a,c){L(n,e,r,i,s,a,c)}return{mount(r,i){i.nodeType===1&&(i.textContent=""),o(null,r,i,null,null)},patch(r,i,s){var a;o(r,i,s||((a=r.el)==null?void 0:a.parentNode),null,null)},unmount(r,i){e(r,i)}}}var X={acceptCharset:"acceptCharset",accessKey:"accessKey",className:"className",htmlFor:"htmlFor",httpEquiv:"httpEquiv",tabIndex:"tabIndex"},q={allowfullscreen:!0,async:!0,autofocus:!0,autoplay:!0,checked:!0,controls:!0,default:!0,defer:!0,disabled:!0,formnovalidate:!0,hidden:!0,inert:!0,ismap:!0,itemscope:!0,loop:!0,multiple:!0,muted:!0,nomodule:!0,novalidate:!0,open:!0,playsinline:!0,readonly:!0,required:!0,reversed:!0,selected:!0},ye={"accent-height":"accentHeight","alignment-baseline":"alignmentBaseline","baseline-shift":"baselineShift","clip-path":"clipPath","clip-rule":"clipRule","color-interpolation":"colorInterpolation","color-interpolation-filters":"colorInterpolationFilters","dominant-baseline":"dominantBaseline","enable-background":"enableBackground","fill-opacity":"fillOpacity","fill-rule":"fillRule","flood-color":"floodColor","flood-opacity":"floodOpacity","glyph-orientation-horizontal":"glyphOrientationHorizontal","glyph-orientation-vertical":"glyphOrientationVertical","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-variant":"fontVariant","font-weight":"fontWeight","image-rendering":"imageRendering","letter-spacing":"letterSpacing","lighting-color":"lightingColor","marker-end":"markerEnd","marker-mid":"markerMid","marker-start":"markerStart","paint-order":"paintOrder","pointer-events":"pointerEvents","shape-rendering":"shapeRendering","stop-color":"stopColor","stop-opacity":"stopOpacity","stroke-dasharray":"strokeDasharray","stroke-dashoffset":"strokeDashoffset","stroke-linecap":"strokeLinecap","stroke-linejoin":"strokeLinejoin","stroke-miterlimit":"strokeMiterlimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-anchor":"textAnchor","text-decoration":"textDecoration","text-rendering":"textRendering","transform-origin":"transformOrigin","word-spacing":"wordSpacing","writing-mode":"writingMode","xlink:href":"xlinkHref","xlink:title":"xlinkTitle","xml:lang":"xmlLang","xml:space":"xmlSpace"};function x(n,e,t){if(e==="class"){n.className=t==null?"":String(t);return}if(e==="style"){if(typeof t=="string")n.style.cssText=t;else if(t!=null&&typeof t=="object")for(let r in t)n.style[r]=t[r];else n.style.cssText="";return}if(e.startsWith("on")||e.startsWith("@")){let r=e.startsWith("@")?e.slice(1).toLowerCase():e.slice(2).toLowerCase();typeof t=="function"&&n.addEventListener(r,t);return}if(e in q){t?(n.setAttribute(e,""),e in n&&(n[e]=!0)):(n.removeAttribute(e),e in n&&(n[e]=!1));return}let o=X[e]||e;if(o in n){try{n[o]=t==null?"":t}catch(r){n.setAttribute(e,t==null?"":String(t))}return}t==null||t===!1?n.removeAttribute(e):n.setAttribute(e,String(t))}function T(n,e){if(e==="class"){n.className="";return}if(e==="style"){n.style.cssText="";return}if(e.startsWith("on")||e.startsWith("@")){let o=e.startsWith("@")?e.slice(1).toLowerCase():e.slice(2).toLowerCase(),r=n._vei;if(r){let i="on"+o.charAt(0).toUpperCase()+o.slice(1),s=r[i];s&&(n.removeEventListener(o,s),r[i]=void 0)}return}if(e in q){n.removeAttribute(e),e in n&&(n[e]=!1);return}let t=X[e]||e;if(t in n){try{n[t]=""}catch(o){n.removeAttribute(e)}return}n.removeAttribute(e)}function z(n){return n.startsWith("on")||n.startsWith("@")}function me(n,e,t){let o=e?Object.keys(e):[],r=t?Object.keys(t):[];for(let i=0;i<r.length;i++){let s=r[i],a=t[s],c=e?e[s]:void 0;s==="key"||s==="ref"||a!==c&&(s==="class"?n.className=a==null?"":String(a):s==="style"?ve(n,a,c):z(s)||x(n,s,a))}for(let i=0;i<o.length;i++){let s=o[i];s==="key"||s==="ref"||(!t||!(s in t))&&(s==="class"?n.className="":s==="style"?n.style.cssText="":z(s)||T(n,s))}}function ve(n,e,t){if(!e||typeof e=="string"&&!e.trim()){n.style.cssText="";return}if(typeof e=="string"){n.style.cssText=e;return}if(typeof t=="object"&&t!==null)for(let o in t)o in e||(n.style[o]="");for(let o in e)n.style[o]=e[o]}function D(n){return n==="svg"||n==="path"||n==="circle"||n==="rect"||n==="line"||n==="polyline"||n==="polygon"||n==="ellipse"||n==="g"||n==="defs"||n==="use"||n==="text"||n==="tspan"||n==="clipPath"||n==="mask"||n==="filter"||n==="linearGradient"||n==="radialGradient"||n==="stop"||n==="pattern"||n==="symbol"||n==="image"||n==="foreignObject"||n==="animate"||n==="animateTransform"||n==="animateMotion"}function he(n){return ye[n]||n}var Ne=/^(?:@|on)/;function M(n){return n.replace(Ne,"").toLowerCase()}function $(n){let e=M(n);return"on"+e.charAt(0).toUpperCase()+e.slice(1)}var Ee={stop:"stop",prevent:"prevent",capture:"capture",once:"once",self:"self",passive:"passive"};function J(n){let e=n.split("."),o={name:e[0],stop:!1,prevent:!1,capture:!1,once:!1,self:!1,passive:!1};for(let r=1;r<e.length;r++){let i=e[r],s=Ee[i];s&&(o[s]=!0)}return o}function Q(n){let e=(t=>{e.value&&e.value(t)});return e.value=n,e}var h="_vei";function ge(n){return n[h]||null}function R(n,e,t,o,r){let i=$(e),s=J(M(e)),a=s.name,c=n[h];c||(c=n[h]={});let f=c[i];if(t&&f)f.value=t;else if(t&&!f){let d=Q(t);c[i]=d;let p={};s.capture&&(p.capture=!0),s.once&&(p.once=!0),s.passive&&(p.passive=!0),n.addEventListener(a,d,p)}else!t&&f&&(n.removeEventListener(a,f),c[i]=void 0)}function W(n){let e=n[h];if(e){for(let t in e){let o=e[t];if(o){let r=t.charAt(2).toLowerCase()+t.slice(3);n.removeEventListener(r,o)}}n[h]={}}}import{PatchFlags as u}from"@lytjs/vdom";function b(n,e,t){let o=ee(e);o!==t&&(n.className=o)}function ee(n){if(n==null)return"";if(typeof n=="string")return n;if(typeof n=="object"){if(Array.isArray(n)){let t="";for(let o=0;o<n.length;o++){let r=ee(n[o]);r&&(t+=(t?" ":"")+r)}return t}let e="";for(let t in n)n[t]&&(e+=(e?" ":"")+t);return e}return String(n)}function A(n,e,t){if(!e){n.style.cssText="";return}if(!t){typeof e=="string"?n.style.cssText=e:typeof e=="object"&&Z(n,e);return}if(typeof e!=typeof t){n.style.cssText="",typeof e=="string"?n.style.cssText=e:typeof e=="object"&&Z(n,e);return}if(typeof e=="string"){e!==t&&(n.style.cssText=e);return}if(typeof e=="object"&&typeof t=="object"){for(let o in t)o in e||(n.style[o]="");for(let o in e){let r=e[o],i=t[o];r!==i&&(n.style[o]=r==null?"":r)}}}function Z(n,e){for(let t in e)n.style[t]=e[t]===null||e[t]===void 0?"":e[t]}function Ce(n,e,t,o){R(n,"",e,t,o)}var Le=new Set(["class","style","key","ref"]);function xe(n){return n.length>2&&(n[0]==="o"||n[0]==="O"||n[0]==="@")&&(n[1]==="n"||n[1]==="N")}function te(n,e,t,o,r){if(!Le.has(e)){if(xe(e)){R(n,e,t,o,r);return}if(t===!1||t===null||t===void 0){n.removeAttribute(e);return}if(e in n)try{n[e]=t}catch(i){n.setAttribute(e,String(t))}else n.setAttribute(e,String(t))}}function m(n,e,t,o,r){te(n,e,t,o,r)}function V(n,e,t,o){if(t)for(let r in t){if(r==="key"||r==="ref")continue;let i=t[r],s=e?e[r]:void 0;i!==s&&m(n,r,i,s,o)}if(e)for(let r in e)r==="key"||r==="ref"||(!t||!(r in t))&&m(n,r,null,e[r],o)}function Te(n,e,t,o){let r=e.props||{},i=t.props||{},{patchFlag:s,dynamicProps:a}=t;if(!s||s===u.HOISTED){V(n,r,i,o);return}if(s===u.BAIL){V(n,r,i,o);return}if(s&u.TEXT&&e.children!==t.children&&(n.textContent=t.children),s&u.CLASS&&r.class!==i.class&&b(n,i.class,r.class),s&u.STYLE&&r.style!==i.style&&A(n,i.style,r.style),s&u.PROPS&&a)for(let c=0;c<a.length;c++){let f=a[c],d=r[f],p=i[f];p!==d&&m(n,f,p,d,o)}s&u.FULL_PROPS&&V(n,r,i,o)}var O=class{createElement(e){return D(e)?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e)}createText(e){return document.createTextNode(e)}createComment(e){return document.createComment(e)}setAttribute(e,t,o){x(e,t,o)}removeAttribute(e,t){T(e,t)}setStyle(e,t){if(typeof t=="string")e.style.cssText=t;else if(t&&typeof t=="object")for(let o in t)e.style[o]=t[o]}setClass(e,t){if(typeof t=="string")e.className=t;else if(t&&typeof t=="object"){let o="";for(let r in t)t[r]&&(o+=(o?" ":"")+r);e.className=o}else e.className=""}insert(e,t,o){o!=null?e.insertBefore(t,o):e.appendChild(t)}remove(e){e.parentNode&&e.parentNode.removeChild(e)}replace(e,t,o){e.replaceChild(o,t)}addEventListener(e,t,o,r){e.addEventListener(t,o,r)}removeEventListener(e,t,o){e.removeEventListener(t,o)}nextTick(e){Promise.resolve().then(e)}parentNode(e){return e.parentNode}nextSibling(e){return e.nextSibling}querySelector(e){return document.querySelector(e)}setClassWithOld(e,t,o){b(e,t,o)}setStyleWithOld(e,t,o){A(e,t,o)}setAttributeWithOld(e,t,o,r){m(e,t,o,r)}setElementText(e,t){e.textContent=t}setText(e,t){e.nodeValue=t}insertBefore(e,t,o){o!=null?e.insertBefore(t,o):e.appendChild(t)}removeChild(e,t){e.removeChild(t)}setAnchor(e,t){e.anchor=t}getNextSibling(e){return e.nextSibling}cleanupEvents(e){W(e)}},Re=new O;export{F as Comment,O as DOMRenderer,j as Fragment,k as PatchFlags,u as PatchPropFlags,v as ShapeFlags,H as Text,Q as createInvoker,ue as createRenderer,Re as domRenderer,ge as getEventInvokers,$ as getEventKey,he as getSVGPropName,D as isSVGElement,M as normalizeEventName,J as parseEventModifier,V as patchAllProps,b as patchClass,te as patchDOMProp,me as patchDOMProps,Te as patchElementProps,R as patchEvent,Ce as patchEventOnElement,m as patchProp,A as patchStyle,W as removeAllEventListeners,T as removeDOMProp,x as setDOMProp};
|
|
1
|
+
import { warn } from '@lytjs/common-error';
|
|
2
|
+
import { VOID_ELEMENTS, escapeHtml, camelToKebab, isBooleanAttr } from '@lytjs/common-string';
|
|
3
|
+
export { escapeHtml, isBooleanAttr } from '@lytjs/common-string';
|
|
4
|
+
import { isFunction, isArray, isString, isNullish, isObject } from '@lytjs/common-is';
|
|
5
|
+
import { ShapeFlags, Fragment, Text, Comment } from '@lytjs/vdom';
|
|
6
|
+
export { createRenderer } from '@lytjs/vdom';
|
|
7
|
+
import { compile } from '@lytjs/compiler';
|
|
8
|
+
import { effect, ref, watch } from '@lytjs/reactivity';
|
|
9
|
+
export { getSkippedTrackingCount, resetSkippedTrackingCount, shouldSkipTracking, withFirstRenderOptimization } from '@lytjs/reactivity';
|
|
10
|
+
import { reconcileArray, createTemplate, setText, setAttribute, setProperty, setStyle, setClass, insert, remove, createEventHandler, bindEffect, onCleanup, runCleanups } from '@lytjs/dom-runtime';
|
|
11
|
+
export { WebRendererHost, createDOMRenderer, createHydrationFunctions, createInvoker, createWebHost, getEventKey, normalizeEventName, parseEventModifier, patchAttr, patchClass, patchEvent, patchProp, patchStyle, removeAllEventListeners, wrapDOMEvent } from '@lytjs/adapter-web';
|
|
12
|
+
export { isOn } from '@lytjs/common-events';
|
|
13
|
+
|
|
14
|
+
var __defProp = Object.defineProperty;
|
|
15
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
16
|
+
var __esm = (fn, res) => function __init() {
|
|
17
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
18
|
+
};
|
|
19
|
+
var __export = (target, all) => {
|
|
20
|
+
for (var name in all)
|
|
21
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// src/hydration/enhanced-hydration.ts
|
|
25
|
+
var enhanced_hydration_exports = {};
|
|
26
|
+
__export(enhanced_hydration_exports, {
|
|
27
|
+
HydrationErrorHandler: () => HydrationErrorHandler,
|
|
28
|
+
createHydrationErrorHandler: () => createHydrationErrorHandler,
|
|
29
|
+
hydrateApp: () => hydrateApp,
|
|
30
|
+
hydrateVisible: () => hydrateVisible,
|
|
31
|
+
queueHydration: () => queueHydration,
|
|
32
|
+
safeHydrate: () => safeHydrate
|
|
33
|
+
});
|
|
34
|
+
async function hydrateApp(component, container, options = {}) {
|
|
35
|
+
const startTime = performance.now();
|
|
36
|
+
const stats = {
|
|
37
|
+
totalNodes: 0,
|
|
38
|
+
hydratedNodes: 0,
|
|
39
|
+
skippedNodes: 0,
|
|
40
|
+
mismatches: 0,
|
|
41
|
+
errors: 0,
|
|
42
|
+
duration: 0
|
|
43
|
+
};
|
|
44
|
+
const containerEl = typeof container === "string" ? document.querySelector(container) : container;
|
|
45
|
+
if (!containerEl) {
|
|
46
|
+
throw new Error(`[LytJS] hydrateApp: container not found: ${container}`);
|
|
47
|
+
}
|
|
48
|
+
if (containerEl.hasAttribute("data-hydrated")) {
|
|
49
|
+
warn("[LytJS] Container already hydrated");
|
|
50
|
+
const { createApp: createApp2 } = await import('@lytjs/core');
|
|
51
|
+
return {
|
|
52
|
+
app: createApp2(component),
|
|
53
|
+
stats
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const { createApp } = await import('@lytjs/core');
|
|
57
|
+
const app = createApp(component);
|
|
58
|
+
try {
|
|
59
|
+
await performHydration(containerEl, app, stats, options);
|
|
60
|
+
} catch (error2) {
|
|
61
|
+
stats.errors++;
|
|
62
|
+
options.onError?.({
|
|
63
|
+
type: "script",
|
|
64
|
+
message: error2 instanceof Error ? error2.message : String(error2),
|
|
65
|
+
error: error2 instanceof Error ? error2 : void 0
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
containerEl.setAttribute("data-hydrated", "true");
|
|
69
|
+
stats.duration = performance.now() - startTime;
|
|
70
|
+
options.onComplete?.();
|
|
71
|
+
return { app, stats };
|
|
72
|
+
}
|
|
73
|
+
async function performHydration(container, _app, stats, _options) {
|
|
74
|
+
const walker = document.createTreeWalker(
|
|
75
|
+
container,
|
|
76
|
+
NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT
|
|
77
|
+
);
|
|
78
|
+
const nodes = [];
|
|
79
|
+
let node;
|
|
80
|
+
while (node = walker.nextNode()) {
|
|
81
|
+
nodes.push(node);
|
|
82
|
+
stats.totalNodes++;
|
|
83
|
+
}
|
|
84
|
+
for (const n of nodes) {
|
|
85
|
+
if (n instanceof Element) {
|
|
86
|
+
await hydrateElement(n, stats);
|
|
87
|
+
stats.hydratedNodes++;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async function hydrateElement(element, stats, _options) {
|
|
92
|
+
const ssrId = element.getAttribute("data-ssr-id");
|
|
93
|
+
if (!ssrId) {
|
|
94
|
+
stats.skippedNodes++;
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const eventAttrs = Array.from(element.attributes).filter(
|
|
98
|
+
(attr) => attr.name.startsWith("on") || attr.name.startsWith("@")
|
|
99
|
+
);
|
|
100
|
+
for (const attr of eventAttrs) {
|
|
101
|
+
element.removeAttribute(attr.name);
|
|
102
|
+
}
|
|
103
|
+
const directives = Array.from(element.attributes).filter(
|
|
104
|
+
(attr) => attr.name.startsWith("v-")
|
|
105
|
+
);
|
|
106
|
+
for (const attr of directives) {
|
|
107
|
+
processDirective(element, attr.name, attr.value);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function processDirective(element, name, value, _options) {
|
|
111
|
+
switch (name) {
|
|
112
|
+
case "v-if":
|
|
113
|
+
case "v-show":
|
|
114
|
+
case "v-for":
|
|
115
|
+
break;
|
|
116
|
+
case "v-model":
|
|
117
|
+
setupVModel(element);
|
|
118
|
+
break;
|
|
119
|
+
case "v-bind":
|
|
120
|
+
setupVBind(element, value);
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function setupVModel(element, _expression) {
|
|
125
|
+
if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) {
|
|
126
|
+
element.addEventListener("input", (e) => {
|
|
127
|
+
const event = new CustomEvent("update:modelValue", {
|
|
128
|
+
detail: e.target.value
|
|
129
|
+
});
|
|
130
|
+
element.dispatchEvent(event);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function setupVBind(element, expression) {
|
|
135
|
+
const bindValue = element.getAttribute(`data-bind-${expression}`);
|
|
136
|
+
if (bindValue) {
|
|
137
|
+
try {
|
|
138
|
+
const value = JSON.parse(bindValue);
|
|
139
|
+
element.setAttribute(expression, value);
|
|
140
|
+
} catch {
|
|
141
|
+
element.setAttribute(expression, bindValue);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async function hydrateVisible(component, container, options = {}) {
|
|
146
|
+
const containerEl = typeof container === "string" ? document.querySelector(container) : container;
|
|
147
|
+
if (!containerEl) {
|
|
148
|
+
throw new Error(`[LytJS] hydrateVisible: container not found: ${container}`);
|
|
149
|
+
}
|
|
150
|
+
const hydrateElements = containerEl.querySelectorAll("[data-hydrate]");
|
|
151
|
+
const stats = {
|
|
152
|
+
totalNodes: hydrateElements.length,
|
|
153
|
+
hydratedNodes: 0,
|
|
154
|
+
skippedNodes: 0,
|
|
155
|
+
mismatches: 0,
|
|
156
|
+
errors: 0,
|
|
157
|
+
duration: 0
|
|
158
|
+
};
|
|
159
|
+
const startTime = performance.now();
|
|
160
|
+
const { createApp } = await import('@lytjs/core');
|
|
161
|
+
const app = createApp(component);
|
|
162
|
+
const observer = new IntersectionObserver(
|
|
163
|
+
async (entries) => {
|
|
164
|
+
for (const entry of entries) {
|
|
165
|
+
if (entry.isIntersecting) {
|
|
166
|
+
const element = entry.target;
|
|
167
|
+
await hydrateElement(element, stats);
|
|
168
|
+
stats.hydratedNodes++;
|
|
169
|
+
observer.unobserve(element);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
rootMargin: options.lazyThreshold ? `${options.lazyThreshold}px` : "100px"
|
|
175
|
+
}
|
|
176
|
+
);
|
|
177
|
+
for (const element of hydrateElements) {
|
|
178
|
+
observer.observe(element);
|
|
179
|
+
}
|
|
180
|
+
await new Promise((resolve) => {
|
|
181
|
+
const checkComplete = () => {
|
|
182
|
+
if (stats.hydratedNodes >= stats.totalNodes) {
|
|
183
|
+
resolve();
|
|
184
|
+
} else {
|
|
185
|
+
requestIdleCallback(checkComplete);
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
checkComplete();
|
|
189
|
+
});
|
|
190
|
+
stats.duration = performance.now() - startTime;
|
|
191
|
+
observer.disconnect();
|
|
192
|
+
return { app, stats };
|
|
193
|
+
}
|
|
194
|
+
function queueHydration(element, priority, callback) {
|
|
195
|
+
hydrationQueue.push({ element, priority, callback });
|
|
196
|
+
hydrationQueue.sort((a, b) => {
|
|
197
|
+
const priorityOrder = { high: 0, medium: 1, low: 2 };
|
|
198
|
+
return priorityOrder[a.priority] - priorityOrder[b.priority];
|
|
199
|
+
});
|
|
200
|
+
if (!isProcessingQueue) {
|
|
201
|
+
processHydrationQueue();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
async function processHydrationQueue() {
|
|
205
|
+
isProcessingQueue = true;
|
|
206
|
+
while (hydrationQueue.length > 0) {
|
|
207
|
+
const task = hydrationQueue.shift();
|
|
208
|
+
if (task) {
|
|
209
|
+
await task.callback();
|
|
210
|
+
}
|
|
211
|
+
await new Promise((resolve) => requestIdleCallback(resolve));
|
|
212
|
+
}
|
|
213
|
+
isProcessingQueue = false;
|
|
214
|
+
}
|
|
215
|
+
function createHydrationErrorHandler(options = {}) {
|
|
216
|
+
return new HydrationErrorHandler(options);
|
|
217
|
+
}
|
|
218
|
+
async function safeHydrate(component, container, options = {}) {
|
|
219
|
+
const errorHandler = createHydrationErrorHandler(options);
|
|
220
|
+
try {
|
|
221
|
+
const result = await hydrateApp(component, container, {
|
|
222
|
+
...options,
|
|
223
|
+
onError: (error2) => {
|
|
224
|
+
errorHandler.handleError(error2);
|
|
225
|
+
options.onError?.(error2);
|
|
226
|
+
},
|
|
227
|
+
onMismatch: (mismatch) => {
|
|
228
|
+
options.onMismatch?.(mismatch);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
return {
|
|
232
|
+
...result,
|
|
233
|
+
errorHandler
|
|
234
|
+
};
|
|
235
|
+
} catch (error2) {
|
|
236
|
+
const containerEl = typeof container === "string" ? document.querySelector(container) : container;
|
|
237
|
+
if (containerEl) {
|
|
238
|
+
containerEl.innerHTML = "";
|
|
239
|
+
const { createApp } = await import('@lytjs/core');
|
|
240
|
+
const app = createApp(component);
|
|
241
|
+
app.mount(containerEl);
|
|
242
|
+
return {
|
|
243
|
+
app,
|
|
244
|
+
stats: {
|
|
245
|
+
totalNodes: 0,
|
|
246
|
+
hydratedNodes: 0,
|
|
247
|
+
skippedNodes: 0,
|
|
248
|
+
mismatches: 0,
|
|
249
|
+
errors: 1,
|
|
250
|
+
duration: 0
|
|
251
|
+
},
|
|
252
|
+
errorHandler
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
throw error2;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
var hydrationQueue, isProcessingQueue, HydrationErrorHandler;
|
|
259
|
+
var init_enhanced_hydration = __esm({
|
|
260
|
+
"src/hydration/enhanced-hydration.ts"() {
|
|
261
|
+
hydrationQueue = [];
|
|
262
|
+
isProcessingQueue = false;
|
|
263
|
+
HydrationErrorHandler = class {
|
|
264
|
+
constructor(options = {}) {
|
|
265
|
+
this.errors = [];
|
|
266
|
+
this.mismatches = [];
|
|
267
|
+
this.options = options;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* 处理 Hydration 错误
|
|
271
|
+
*/
|
|
272
|
+
handleError(error2) {
|
|
273
|
+
this.errors.push(error2);
|
|
274
|
+
this.options.onError?.(error2);
|
|
275
|
+
switch (error2.type) {
|
|
276
|
+
case "mismatch":
|
|
277
|
+
return this.handleMismatch(error2);
|
|
278
|
+
case "missing":
|
|
279
|
+
return "fallback";
|
|
280
|
+
case "invalid":
|
|
281
|
+
return "rerender";
|
|
282
|
+
case "script":
|
|
283
|
+
return "keep-server";
|
|
284
|
+
default:
|
|
285
|
+
return "rerender";
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* 处理不匹配错误
|
|
290
|
+
*/
|
|
291
|
+
handleMismatch(error2) {
|
|
292
|
+
const mismatch = {
|
|
293
|
+
expected: error2.node?.getAttribute("data-ssr-expected") || "",
|
|
294
|
+
actual: error2.node?.innerHTML || "",
|
|
295
|
+
path: this.getNodePath(error2.node),
|
|
296
|
+
recoveryStrategy: "rerender"
|
|
297
|
+
};
|
|
298
|
+
this.mismatches.push(mismatch);
|
|
299
|
+
this.options.onMismatch?.(mismatch);
|
|
300
|
+
if (this.isMinorMismatch(mismatch)) {
|
|
301
|
+
mismatch.recoveryStrategy = "keep-server";
|
|
302
|
+
return "keep-server";
|
|
303
|
+
}
|
|
304
|
+
if (this.isCriticalMismatch(mismatch)) {
|
|
305
|
+
mismatch.recoveryStrategy = "rerender";
|
|
306
|
+
return "rerender";
|
|
307
|
+
}
|
|
308
|
+
return "keep-client";
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* 判断是否是轻微不匹配
|
|
312
|
+
*/
|
|
313
|
+
isMinorMismatch(mismatch) {
|
|
314
|
+
if (mismatch.expected.trim() === mismatch.actual.trim()) {
|
|
315
|
+
return true;
|
|
316
|
+
}
|
|
317
|
+
const normalize = (html) => html.replace(/\s+/g, " ").replace(/\s*=\s*/g, "=");
|
|
318
|
+
if (normalize(mismatch.expected) === normalize(mismatch.actual)) {
|
|
319
|
+
return true;
|
|
320
|
+
}
|
|
321
|
+
return false;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* 判断是否是严重不匹配
|
|
325
|
+
*/
|
|
326
|
+
isCriticalMismatch(mismatch) {
|
|
327
|
+
const expectedTags = mismatch.expected.match(/<\w+/g) || [];
|
|
328
|
+
const actualTags = mismatch.actual.match(/<\w+/g) || [];
|
|
329
|
+
if (expectedTags.length !== actualTags.length) {
|
|
330
|
+
return true;
|
|
331
|
+
}
|
|
332
|
+
if (mismatch.expected.includes("data-") && !mismatch.actual.includes("data-")) {
|
|
333
|
+
return true;
|
|
334
|
+
}
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* 获取节点路径
|
|
339
|
+
*/
|
|
340
|
+
getNodePath(node) {
|
|
341
|
+
if (!node) return "";
|
|
342
|
+
const path = [];
|
|
343
|
+
let current = node;
|
|
344
|
+
while (current && current !== document.body) {
|
|
345
|
+
const tagName = current.tagName.toLowerCase();
|
|
346
|
+
const siblings = current.parentElement?.children;
|
|
347
|
+
const index = siblings ? Array.from(siblings).indexOf(current) : 0;
|
|
348
|
+
path.unshift(`${tagName}[${index}]`);
|
|
349
|
+
current = current.parentElement;
|
|
350
|
+
}
|
|
351
|
+
return path.join(" > ");
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* 获取所有错误
|
|
355
|
+
*/
|
|
356
|
+
getErrors() {
|
|
357
|
+
return [...this.errors];
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* 获取所有不匹配
|
|
361
|
+
*/
|
|
362
|
+
getMismatches() {
|
|
363
|
+
return [...this.mismatches];
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* 清除错误记录
|
|
367
|
+
*/
|
|
368
|
+
clear() {
|
|
369
|
+
this.errors = [];
|
|
370
|
+
this.mismatches = [];
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
});
|
|
375
|
+
function isVoidElement(tag) {
|
|
376
|
+
return VOID_ELEMENTS.has(tag);
|
|
377
|
+
}
|
|
378
|
+
var init_utils = __esm({
|
|
379
|
+
"src/utils.ts"() {
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
function isValidHTMLElementTag(tag) {
|
|
383
|
+
return /^[a-z][a-z0-9-]*$/.test(tag);
|
|
384
|
+
}
|
|
385
|
+
function isSafeURL(url) {
|
|
386
|
+
let decoded = url;
|
|
387
|
+
let prev = "";
|
|
388
|
+
let maxIterations = 10;
|
|
389
|
+
while (decoded !== prev && maxIterations-- > 0) {
|
|
390
|
+
prev = decoded;
|
|
391
|
+
decoded = decoded.replace(NUMERIC_ENTITY_REGEX, (match) => {
|
|
392
|
+
const codePoint = match.startsWith("&#x") ? parseInt(match.slice(3, -1), 16) : parseInt(match.slice(2, -1), 10);
|
|
393
|
+
if (isNaN(codePoint) || codePoint < 0 || codePoint > 1114111) {
|
|
394
|
+
return match;
|
|
395
|
+
}
|
|
396
|
+
return String.fromCodePoint(codePoint);
|
|
397
|
+
});
|
|
398
|
+
decoded = decoded.replace(NAMED_ENTITY_REGEX, (match) => NAMED_ENTITIES[match] || match);
|
|
399
|
+
}
|
|
400
|
+
try {
|
|
401
|
+
const parsed = new URL(decoded, "http://example.com");
|
|
402
|
+
const protocol = parsed.protocol.toLowerCase().replace(":", "");
|
|
403
|
+
if (protocol === "javascript") {
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
if (protocol === "data") {
|
|
407
|
+
if (/^data:image\/svg\+xml/i.test(decoded)) {
|
|
408
|
+
return false;
|
|
409
|
+
}
|
|
410
|
+
return /^data:image\/(png|jpeg|jpg|gif|webp|bmp|ico|avif);/i.test(decoded);
|
|
411
|
+
}
|
|
412
|
+
return true;
|
|
413
|
+
} catch {
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
function renderAttributeToString(key, value) {
|
|
418
|
+
if (isNullish(value)) return "";
|
|
419
|
+
if (/^on[A-Z]/.test(key)) return "";
|
|
420
|
+
if (key === "class") {
|
|
421
|
+
const classValue = value == null ? "" : String(value);
|
|
422
|
+
if (!classValue) return "";
|
|
423
|
+
return ` class="${escapeHtml(classValue)}"`;
|
|
424
|
+
}
|
|
425
|
+
if (key === "style") {
|
|
426
|
+
if (isString(value)) {
|
|
427
|
+
if (!value) return "";
|
|
428
|
+
return ` style="${escapeHtml(value)}"`;
|
|
429
|
+
}
|
|
430
|
+
if (isObject(value)) {
|
|
431
|
+
const styles = [];
|
|
432
|
+
for (const k in value) {
|
|
433
|
+
const val = value[k];
|
|
434
|
+
if (val != null && val !== "") {
|
|
435
|
+
styles.push(`${camelToKebab(k)}:${String(val)}`);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
if (styles.length === 0) return "";
|
|
439
|
+
return ` style="${escapeHtml(styles.join(";"))}"`;
|
|
440
|
+
}
|
|
441
|
+
return "";
|
|
442
|
+
}
|
|
443
|
+
if (isBooleanAttr(key)) {
|
|
444
|
+
if (value === false || value === "") return "";
|
|
445
|
+
return ` ${key}`;
|
|
446
|
+
}
|
|
447
|
+
if (URL_ATTRS.has(key)) {
|
|
448
|
+
if (!isSafeURL(String(value))) {
|
|
449
|
+
return "";
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return ` ${key}="${escapeHtml(String(value))}"`;
|
|
453
|
+
}
|
|
454
|
+
var URL_ATTRS, NAMED_ENTITIES, NAMED_ENTITY_REGEX, NUMERIC_ENTITY_REGEX;
|
|
455
|
+
var init_ssr_utils = __esm({
|
|
456
|
+
"src/ssr/ssr-utils.ts"() {
|
|
457
|
+
init_utils();
|
|
458
|
+
URL_ATTRS = /* @__PURE__ */ new Set([
|
|
459
|
+
"href",
|
|
460
|
+
"src",
|
|
461
|
+
"action",
|
|
462
|
+
"formaction",
|
|
463
|
+
"xlink:href",
|
|
464
|
+
"data",
|
|
465
|
+
"srcdoc"
|
|
466
|
+
]);
|
|
467
|
+
NAMED_ENTITIES = {
|
|
468
|
+
":": ":",
|
|
469
|
+
"&tab;": " ",
|
|
470
|
+
"&newline;": "\n",
|
|
471
|
+
"(": "(",
|
|
472
|
+
")": ")",
|
|
473
|
+
" ": "\xA0",
|
|
474
|
+
"©": "\xA9",
|
|
475
|
+
"®": "\xAE",
|
|
476
|
+
"™": "\u2122",
|
|
477
|
+
"×": "\xD7",
|
|
478
|
+
"÷": "\xF7",
|
|
479
|
+
"£": "\xA3",
|
|
480
|
+
"¥": "\xA5",
|
|
481
|
+
"¢": "\xA2",
|
|
482
|
+
"§": "\xA7",
|
|
483
|
+
"¶": "\xB6",
|
|
484
|
+
"·": "\xB7",
|
|
485
|
+
"«": "\xAB",
|
|
486
|
+
"»": "\xBB",
|
|
487
|
+
"¡": "\xA1",
|
|
488
|
+
"¿": "\xBF",
|
|
489
|
+
"°": "\xB0",
|
|
490
|
+
"±": "\xB1",
|
|
491
|
+
"µ": "\xB5",
|
|
492
|
+
"¼": "\xBC",
|
|
493
|
+
"½": "\xBD",
|
|
494
|
+
"¾": "\xBE",
|
|
495
|
+
"¹": "\xB9",
|
|
496
|
+
"²": "\xB2",
|
|
497
|
+
"³": "\xB3",
|
|
498
|
+
"´": "\xB4",
|
|
499
|
+
"¸": "\xB8",
|
|
500
|
+
"ª": "\xAA",
|
|
501
|
+
"¬": "\xAC",
|
|
502
|
+
"­": "\xAD",
|
|
503
|
+
"¯": "\xAF",
|
|
504
|
+
"¨": "\xA8",
|
|
505
|
+
"ˆ": "\u02C6",
|
|
506
|
+
"˜": "\u02DC",
|
|
507
|
+
" ": "\u2002",
|
|
508
|
+
" ": "\u2003",
|
|
509
|
+
" ": "\u2009",
|
|
510
|
+
"‌": "\u200C",
|
|
511
|
+
"‍": "\u200D",
|
|
512
|
+
"‎": "\u200E",
|
|
513
|
+
"‏": "\u200F",
|
|
514
|
+
"–": "\u2013",
|
|
515
|
+
"—": "\u2014",
|
|
516
|
+
"‘": "\u2018",
|
|
517
|
+
"’": "\u2019",
|
|
518
|
+
"‚": "\u201A",
|
|
519
|
+
"“": "\u201C",
|
|
520
|
+
"”": "\u201D",
|
|
521
|
+
"„": "\u201E",
|
|
522
|
+
"†": "\u2020",
|
|
523
|
+
"‡": "\u2021",
|
|
524
|
+
"•": "\u2022",
|
|
525
|
+
"…": "\u2026",
|
|
526
|
+
"‰": "\u2030",
|
|
527
|
+
"′": "\u2032",
|
|
528
|
+
"″": "\u2033",
|
|
529
|
+
"‹": "\u2039",
|
|
530
|
+
"›": "\u203A",
|
|
531
|
+
"‾": "\u203E",
|
|
532
|
+
"⁄": "\u2044",
|
|
533
|
+
"€": "\u20AC",
|
|
534
|
+
"←": "\u2190",
|
|
535
|
+
"↑": "\u2191",
|
|
536
|
+
"→": "\u2192",
|
|
537
|
+
"↓": "\u2193",
|
|
538
|
+
"↔": "\u2194",
|
|
539
|
+
"↵": "\u21B5",
|
|
540
|
+
"⌈": "\u2308",
|
|
541
|
+
"⌉": "\u2309",
|
|
542
|
+
"⌊": "\u230A",
|
|
543
|
+
"⌋": "\u230B",
|
|
544
|
+
"⟨": "\u27E8",
|
|
545
|
+
"⟩": "\u27E9",
|
|
546
|
+
"◊": "\u25CA",
|
|
547
|
+
"♠": "\u2660",
|
|
548
|
+
"♣": "\u2663",
|
|
549
|
+
"♥": "\u2665",
|
|
550
|
+
"♦": "\u2666",
|
|
551
|
+
"Œ": "\u0152",
|
|
552
|
+
"œ": "\u0153",
|
|
553
|
+
"Š": "\u0160",
|
|
554
|
+
"š": "\u0161",
|
|
555
|
+
"Ÿ": "\u0178",
|
|
556
|
+
"ƒ": "\u0192",
|
|
557
|
+
"Α": "\u0391",
|
|
558
|
+
"Β": "\u0392",
|
|
559
|
+
"Γ": "\u0393",
|
|
560
|
+
"Δ": "\u0394",
|
|
561
|
+
"Ε": "\u0395",
|
|
562
|
+
"Ζ": "\u0396",
|
|
563
|
+
"Η": "\u0397",
|
|
564
|
+
"Θ": "\u0398",
|
|
565
|
+
"Ι": "\u0399",
|
|
566
|
+
"Κ": "\u039A",
|
|
567
|
+
"Λ": "\u039B",
|
|
568
|
+
"Μ": "\u039C",
|
|
569
|
+
"Ν": "\u039D",
|
|
570
|
+
"Ξ": "\u039E",
|
|
571
|
+
"Ο": "\u039F",
|
|
572
|
+
"Π": "\u03A0",
|
|
573
|
+
"Ρ": "\u03A1",
|
|
574
|
+
"Σ": "\u03A3",
|
|
575
|
+
"Τ": "\u03A4",
|
|
576
|
+
"Υ": "\u03A5",
|
|
577
|
+
"Φ": "\u03A6",
|
|
578
|
+
"Χ": "\u03A7",
|
|
579
|
+
"Ψ": "\u03A8",
|
|
580
|
+
"Ω": "\u03A9",
|
|
581
|
+
"α": "\u03B1",
|
|
582
|
+
"β": "\u03B2",
|
|
583
|
+
"γ": "\u03B3",
|
|
584
|
+
"δ": "\u03B4",
|
|
585
|
+
"ε": "\u03B5",
|
|
586
|
+
"ζ": "\u03B6",
|
|
587
|
+
"η": "\u03B7",
|
|
588
|
+
"θ": "\u03B8",
|
|
589
|
+
"ι": "\u03B9",
|
|
590
|
+
"κ": "\u03BA",
|
|
591
|
+
"λ": "\u03BB",
|
|
592
|
+
"μ": "\u03BC",
|
|
593
|
+
"ν": "\u03BD",
|
|
594
|
+
"ξ": "\u03BE",
|
|
595
|
+
"ο": "\u03BF",
|
|
596
|
+
"π": "\u03C0",
|
|
597
|
+
"ρ": "\u03C1",
|
|
598
|
+
"ς": "\u03C2",
|
|
599
|
+
"σ": "\u03C3",
|
|
600
|
+
"τ": "\u03C4",
|
|
601
|
+
"υ": "\u03C5",
|
|
602
|
+
"φ": "\u03C6",
|
|
603
|
+
"χ": "\u03C7",
|
|
604
|
+
"ψ": "\u03C8",
|
|
605
|
+
"ω": "\u03C9",
|
|
606
|
+
"ϑ": "\u03D1",
|
|
607
|
+
"ϒ": "\u03D2",
|
|
608
|
+
"ϖ": "\u03D6",
|
|
609
|
+
"'": "'",
|
|
610
|
+
""": '"',
|
|
611
|
+
"&": "&",
|
|
612
|
+
"<": "<",
|
|
613
|
+
">": ">"
|
|
614
|
+
};
|
|
615
|
+
NAMED_ENTITY_REGEX = new RegExp(
|
|
616
|
+
Object.keys(NAMED_ENTITIES).map((e) => e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"),
|
|
617
|
+
"g"
|
|
618
|
+
);
|
|
619
|
+
NUMERIC_ENTITY_REGEX = /&#x?[0-9a-f]+;/gi;
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
|
|
623
|
+
// src/ssr/ssr-stream-optimized.ts
|
|
624
|
+
var ssr_stream_optimized_exports = {};
|
|
625
|
+
__export(ssr_stream_optimized_exports, {
|
|
626
|
+
OptimizedSSRStream: () => OptimizedSSRStream,
|
|
627
|
+
createOptimizedStream: () => createOptimizedStream,
|
|
628
|
+
renderDocumentToStream: () => renderDocumentToStream
|
|
629
|
+
});
|
|
630
|
+
function createOptimizedStream(vnode, options) {
|
|
631
|
+
return new ReadableStream({
|
|
632
|
+
async start(controller) {
|
|
633
|
+
const stream = new OptimizedSSRStream(controller, options);
|
|
634
|
+
try {
|
|
635
|
+
await stream.renderVNode(vnode);
|
|
636
|
+
stream.finish();
|
|
637
|
+
controller.close();
|
|
638
|
+
} catch (error2) {
|
|
639
|
+
controller.error(error2);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
async function renderDocumentToStream(vnode, options = {}) {
|
|
645
|
+
return new ReadableStream({
|
|
646
|
+
async start(controller) {
|
|
647
|
+
const stream = new OptimizedSSRStream(controller, options.stream);
|
|
648
|
+
try {
|
|
649
|
+
const head = stream.generateDocumentHead(options.head || {});
|
|
650
|
+
stream.push(head);
|
|
651
|
+
if (options.stream?.earlyFlush !== false) {
|
|
652
|
+
stream.flush();
|
|
653
|
+
}
|
|
654
|
+
await stream.renderVNode(vnode);
|
|
655
|
+
const footer = stream.generateDocumentFooter(options.footer || {});
|
|
656
|
+
stream.push(footer);
|
|
657
|
+
stream.finish();
|
|
658
|
+
controller.close();
|
|
659
|
+
} catch (error2) {
|
|
660
|
+
controller.error(error2);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
var COMPONENT_MASK, OptimizedSSRStream;
|
|
666
|
+
var init_ssr_stream_optimized = __esm({
|
|
667
|
+
"src/ssr/ssr-stream-optimized.ts"() {
|
|
668
|
+
init_utils();
|
|
669
|
+
init_ssr_utils();
|
|
670
|
+
COMPONENT_MASK = ShapeFlags.STATEFUL_COMPONENT | ShapeFlags.FUNCTIONAL_COMPONENT;
|
|
671
|
+
OptimizedSSRStream = class {
|
|
672
|
+
constructor(controller, options = {}) {
|
|
673
|
+
this.flushedFirstChunk = false;
|
|
674
|
+
this.controller = controller;
|
|
675
|
+
this.encoder = new TextEncoder();
|
|
676
|
+
this.options = {
|
|
677
|
+
preloadHints: options.preloadHints ?? true,
|
|
678
|
+
http2Push: options.http2Push ?? false,
|
|
679
|
+
criticalCSS: options.criticalCSS ?? "",
|
|
680
|
+
deferThreshold: options.deferThreshold ?? 50,
|
|
681
|
+
compression: options.compression ?? false,
|
|
682
|
+
bufferSize: options.bufferSize ?? 4096,
|
|
683
|
+
earlyFlush: options.earlyFlush ?? true
|
|
684
|
+
};
|
|
685
|
+
this.buffer = [];
|
|
686
|
+
this.bufferSize = 0;
|
|
687
|
+
this.startTime = Date.now();
|
|
688
|
+
this.stats = {
|
|
689
|
+
ttfb: 0,
|
|
690
|
+
totalTime: 0,
|
|
691
|
+
chunkCount: 0,
|
|
692
|
+
totalBytes: 0,
|
|
693
|
+
suspenseBoundaries: 0
|
|
694
|
+
};
|
|
695
|
+
this.preloadHints = /* @__PURE__ */ new Set();
|
|
696
|
+
}
|
|
697
|
+
// ============================================================
|
|
698
|
+
// 公共方法
|
|
699
|
+
// ============================================================
|
|
700
|
+
/**
|
|
701
|
+
* 推送 HTML 内容到流
|
|
702
|
+
*/
|
|
703
|
+
push(html) {
|
|
704
|
+
this.buffer.push(html);
|
|
705
|
+
this.bufferSize += html.length;
|
|
706
|
+
if (this.bufferSize >= this.options.bufferSize) {
|
|
707
|
+
this.flush();
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
/**
|
|
711
|
+
* 刷新缓冲区到流
|
|
712
|
+
*/
|
|
713
|
+
flush() {
|
|
714
|
+
if (this.buffer.length === 0) return;
|
|
715
|
+
const chunk = this.buffer.join("");
|
|
716
|
+
this.buffer = [];
|
|
717
|
+
this.bufferSize = 0;
|
|
718
|
+
this.controller.enqueue(this.encoder.encode(chunk));
|
|
719
|
+
if (!this.flushedFirstChunk) {
|
|
720
|
+
this.flushedFirstChunk = true;
|
|
721
|
+
this.stats.ttfb = Date.now() - this.startTime;
|
|
722
|
+
}
|
|
723
|
+
this.stats.chunkCount++;
|
|
724
|
+
this.stats.totalBytes += chunk.length;
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* 添加预加载提示
|
|
728
|
+
*/
|
|
729
|
+
addPreloadHint(hint) {
|
|
730
|
+
const key = `${hint.type}:${hint.href}`;
|
|
731
|
+
if (this.preloadHints.has(key)) return;
|
|
732
|
+
this.preloadHints.add(key);
|
|
733
|
+
const linkHeader = this.generateLinkHeader(hint);
|
|
734
|
+
this.push(linkHeader);
|
|
735
|
+
}
|
|
736
|
+
/**
|
|
737
|
+
* 生成文档头部
|
|
738
|
+
*/
|
|
739
|
+
generateDocumentHead(options) {
|
|
740
|
+
const { title, meta = [], links = [], styles = [] } = options;
|
|
741
|
+
let head = "<!DOCTYPE html><html><head>";
|
|
742
|
+
head += '<meta charset="utf-8">';
|
|
743
|
+
head += '<meta name="viewport" content="width=device-width, initial-scale=1">';
|
|
744
|
+
if (title) {
|
|
745
|
+
head += `<title>${escapeHtml(title)}</title>`;
|
|
746
|
+
}
|
|
747
|
+
for (const m of meta) {
|
|
748
|
+
const attrs = Object.entries(m).map(([k, v]) => `${k}="${escapeHtml(v)}"`).join(" ");
|
|
749
|
+
head += `<meta ${attrs}>`;
|
|
750
|
+
}
|
|
751
|
+
for (const l of links) {
|
|
752
|
+
const attrs = Object.entries(l).map(([k, v]) => `${k}="${escapeHtml(v)}"`).join(" ");
|
|
753
|
+
head += `<link ${attrs}>`;
|
|
754
|
+
}
|
|
755
|
+
if (this.options.criticalCSS) {
|
|
756
|
+
head += `<style>${this.options.criticalCSS}</style>`;
|
|
757
|
+
}
|
|
758
|
+
for (const style of styles) {
|
|
759
|
+
head += `<style>${style}</style>`;
|
|
760
|
+
}
|
|
761
|
+
head += "</head><body>";
|
|
762
|
+
return head;
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* 生成文档尾部
|
|
766
|
+
*/
|
|
767
|
+
generateDocumentFooter(options) {
|
|
768
|
+
const { scripts = [], inlineScripts = [] } = options;
|
|
769
|
+
let footer = "";
|
|
770
|
+
for (const script of inlineScripts) {
|
|
771
|
+
footer += `<script>${script}</script>`;
|
|
772
|
+
}
|
|
773
|
+
for (const src of scripts) {
|
|
774
|
+
footer += `<script src="${escapeHtml(src)}"></script>`;
|
|
775
|
+
}
|
|
776
|
+
footer += "</body></html>";
|
|
777
|
+
return footer;
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* 流式渲染 VNode
|
|
781
|
+
*/
|
|
782
|
+
async renderVNode(vnode) {
|
|
783
|
+
await this.streamVNode(vnode);
|
|
784
|
+
this.flush();
|
|
785
|
+
}
|
|
786
|
+
/**
|
|
787
|
+
* 获取渲染统计
|
|
788
|
+
*/
|
|
789
|
+
getStats() {
|
|
790
|
+
this.stats.totalTime = Date.now() - this.startTime;
|
|
791
|
+
return { ...this.stats };
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* 完成渲染
|
|
795
|
+
*/
|
|
796
|
+
finish() {
|
|
797
|
+
this.flush();
|
|
798
|
+
this.stats.totalTime = Date.now() - this.startTime;
|
|
799
|
+
}
|
|
800
|
+
// ============================================================
|
|
801
|
+
// 内部方法
|
|
802
|
+
// ============================================================
|
|
803
|
+
generateLinkHeader(hint) {
|
|
804
|
+
const attrs = [`rel="preload"`, `href="${escapeHtml(hint.href)}"`, `as="${hint.type}"`];
|
|
805
|
+
if (hint.crossorigin) {
|
|
806
|
+
attrs.push("crossorigin");
|
|
807
|
+
}
|
|
808
|
+
if (hint.importance) {
|
|
809
|
+
attrs.push(`importance="${hint.importance}"`);
|
|
810
|
+
}
|
|
811
|
+
return `<link ${attrs.join(" ")}>`;
|
|
812
|
+
}
|
|
813
|
+
async streamVNode(vnode) {
|
|
814
|
+
const { type, shapeFlag, children } = vnode;
|
|
815
|
+
if (type === Fragment) {
|
|
816
|
+
await this.streamFragment(vnode);
|
|
817
|
+
return;
|
|
818
|
+
}
|
|
819
|
+
if (type === Text) {
|
|
820
|
+
const text = isFunction(children) ? "" : String(children ?? "");
|
|
821
|
+
this.push(escapeHtml(text));
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
if (type === Comment) {
|
|
825
|
+
const text = isFunction(children) ? "" : String(children ?? "");
|
|
826
|
+
let safe = text.replace(/<!--/g, "<!--").replace(/-->/g, "-->");
|
|
827
|
+
safe = safe.replace(/--/g, "- -");
|
|
828
|
+
this.push(`<!--${safe}-->`);
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
if (shapeFlag & ShapeFlags.ELEMENT) {
|
|
832
|
+
await this.streamElement(vnode);
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
if (this.isComponentVNode(vnode)) {
|
|
836
|
+
await this.streamComponent(vnode);
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
async streamFragment(vnode) {
|
|
841
|
+
const children = vnode.children;
|
|
842
|
+
if (isArray(children)) {
|
|
843
|
+
for (const child of children) {
|
|
844
|
+
if (child != null) {
|
|
845
|
+
await this.streamVNode(child);
|
|
846
|
+
await this.yieldToMicrotask();
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
async streamElement(vnode) {
|
|
852
|
+
const tag = vnode.type;
|
|
853
|
+
if (!isValidHTMLElementTag(tag)) {
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
const props = vnode.props ?? {};
|
|
857
|
+
const { shapeFlag, children } = vnode;
|
|
858
|
+
let openTag = `<${tag}`;
|
|
859
|
+
for (const key of Object.keys(props)) {
|
|
860
|
+
if (key === "key" || key === "ref") continue;
|
|
861
|
+
openTag += renderAttributeToString(key, props[key]);
|
|
862
|
+
}
|
|
863
|
+
if (isVoidElement(tag)) {
|
|
864
|
+
this.push(`${openTag} />`);
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
this.push(`${openTag}>`);
|
|
868
|
+
if (shapeFlag & ShapeFlags.TEXT_CHILDREN) {
|
|
869
|
+
const text = isFunction(children) ? "" : String(children ?? "");
|
|
870
|
+
this.push(escapeHtml(text));
|
|
871
|
+
} else if (shapeFlag & ShapeFlags.ARRAY_CHILDREN && isArray(children)) {
|
|
872
|
+
for (const child of children) {
|
|
873
|
+
if (child != null) {
|
|
874
|
+
await this.streamVNode(child);
|
|
875
|
+
await this.yieldToMicrotask();
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
this.push(`</${tag}>`);
|
|
880
|
+
}
|
|
881
|
+
async streamComponent(vnode) {
|
|
882
|
+
const component = vnode.type;
|
|
883
|
+
if (typeof component === "object" && component !== null) {
|
|
884
|
+
if (typeof component.render === "function") {
|
|
885
|
+
const result = component.render(vnode.props ?? {});
|
|
886
|
+
if (result && typeof result === "object" && "type" in result) {
|
|
887
|
+
await this.streamVNode(result);
|
|
888
|
+
return;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
if (typeof component.setup === "function") {
|
|
892
|
+
const setupResult = component.setup(vnode.props ?? {});
|
|
893
|
+
const resolved = setupResult instanceof Promise ? await setupResult : setupResult;
|
|
894
|
+
if (resolved && typeof resolved === "object" && "type" in resolved) {
|
|
895
|
+
await this.streamVNode(resolved);
|
|
896
|
+
return;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
isComponentVNode(vnode) {
|
|
902
|
+
return !!(vnode.shapeFlag & COMPONENT_MASK);
|
|
903
|
+
}
|
|
904
|
+
yieldToMicrotask() {
|
|
905
|
+
return new Promise((resolve) => {
|
|
906
|
+
if (typeof queueMicrotask === "function") {
|
|
907
|
+
queueMicrotask(resolve);
|
|
908
|
+
} else {
|
|
909
|
+
Promise.resolve().then(resolve);
|
|
910
|
+
}
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
});
|
|
916
|
+
|
|
917
|
+
// src/vapor/vapor-hmr.ts
|
|
918
|
+
var vapor_hmr_exports = {};
|
|
919
|
+
__export(vapor_hmr_exports, {
|
|
920
|
+
DEFAULT_STATE_PRESERVATION: () => DEFAULT_STATE_PRESERVATION,
|
|
921
|
+
captureStateSnapshot: () => captureStateSnapshot,
|
|
922
|
+
clearHMRState: () => clearHMRState,
|
|
923
|
+
createVaporHMRHandler: () => createVaporHMRHandler,
|
|
924
|
+
forceRerender: () => forceRerender,
|
|
925
|
+
generateComponentId: () => generateComponentId,
|
|
926
|
+
generateHMRCode: () => generateHMRCode,
|
|
927
|
+
getComponentInstance: () => getComponentInstance,
|
|
928
|
+
getRegisteredComponentIds: () => getRegisteredComponentIds,
|
|
929
|
+
handleComponentUpdate: () => handleComponentUpdate,
|
|
930
|
+
isHMRAvailable: () => isHMRAvailable,
|
|
931
|
+
onHMRUpdate: () => onHMRUpdate,
|
|
932
|
+
registerComponent: () => registerComponent,
|
|
933
|
+
restoreStateSnapshot: () => restoreStateSnapshot,
|
|
934
|
+
unregisterComponent: () => unregisterComponent
|
|
935
|
+
});
|
|
936
|
+
function generateComponentId() {
|
|
937
|
+
return `vapor-c-${++componentIdCounter}`;
|
|
938
|
+
}
|
|
939
|
+
function registerComponent(id, component, container) {
|
|
940
|
+
componentRegistry.set(id, {
|
|
941
|
+
id,
|
|
942
|
+
component,
|
|
943
|
+
container,
|
|
944
|
+
state: /* @__PURE__ */ new Map(),
|
|
945
|
+
mounted: true
|
|
946
|
+
});
|
|
947
|
+
}
|
|
948
|
+
function unregisterComponent(id) {
|
|
949
|
+
componentRegistry.delete(id);
|
|
950
|
+
}
|
|
951
|
+
function getComponentInstance(id) {
|
|
952
|
+
return componentRegistry.get(id);
|
|
953
|
+
}
|
|
954
|
+
function getRegisteredComponentIds() {
|
|
955
|
+
return Array.from(componentRegistry.keys());
|
|
956
|
+
}
|
|
957
|
+
function captureStateSnapshot(id) {
|
|
958
|
+
const instance = componentRegistry.get(id);
|
|
959
|
+
if (!instance) return null;
|
|
960
|
+
return new Map(instance.state);
|
|
961
|
+
}
|
|
962
|
+
function restoreStateSnapshot(id, snapshot) {
|
|
963
|
+
const instance = componentRegistry.get(id);
|
|
964
|
+
if (!instance) return false;
|
|
965
|
+
for (const [key, value] of snapshot) {
|
|
966
|
+
instance.state.set(key, value);
|
|
967
|
+
}
|
|
968
|
+
return true;
|
|
969
|
+
}
|
|
970
|
+
function onHMRUpdate(listener) {
|
|
971
|
+
hmrListeners.add(listener);
|
|
972
|
+
return () => hmrListeners.delete(listener);
|
|
973
|
+
}
|
|
974
|
+
function emitHMRUpdate(update) {
|
|
975
|
+
for (const listener of hmrListeners) {
|
|
976
|
+
try {
|
|
977
|
+
listener(update);
|
|
978
|
+
} catch (error2) {
|
|
979
|
+
console.error("[LytJS HMR] Listener error:", error2);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
function handleComponentUpdate(componentId, newComponent, updateType, _preservation = DEFAULT_STATE_PRESERVATION) {
|
|
984
|
+
const instance = componentRegistry.get(componentId);
|
|
985
|
+
if (!instance) {
|
|
986
|
+
console.warn(`[LytJS HMR] Component not found: ${componentId}`);
|
|
987
|
+
return false;
|
|
988
|
+
}
|
|
989
|
+
const oldComponent = instance.component;
|
|
990
|
+
if (updateType === "full") {
|
|
991
|
+
emitHMRUpdate({
|
|
992
|
+
type: "full",
|
|
993
|
+
componentId,
|
|
994
|
+
oldComponent,
|
|
995
|
+
newComponent,
|
|
996
|
+
timestamp: Date.now()
|
|
997
|
+
});
|
|
998
|
+
if (typeof window !== "undefined" && window.location) {
|
|
999
|
+
window.location.reload();
|
|
1000
|
+
}
|
|
1001
|
+
return true;
|
|
1002
|
+
}
|
|
1003
|
+
const stateSnapshot = captureStateSnapshot(componentId);
|
|
1004
|
+
instance.component = newComponent;
|
|
1005
|
+
switch (updateType) {
|
|
1006
|
+
case "template":
|
|
1007
|
+
if (stateSnapshot) {
|
|
1008
|
+
restoreStateSnapshot(componentId, stateSnapshot);
|
|
1009
|
+
}
|
|
1010
|
+
break;
|
|
1011
|
+
case "script":
|
|
1012
|
+
emitHMRUpdate({
|
|
1013
|
+
type: "script",
|
|
1014
|
+
componentId,
|
|
1015
|
+
oldComponent,
|
|
1016
|
+
newComponent,
|
|
1017
|
+
timestamp: Date.now()
|
|
1018
|
+
});
|
|
1019
|
+
if (typeof window !== "undefined" && window.location) {
|
|
1020
|
+
window.location.reload();
|
|
1021
|
+
}
|
|
1022
|
+
return true;
|
|
1023
|
+
}
|
|
1024
|
+
emitHMRUpdate({
|
|
1025
|
+
type: updateType,
|
|
1026
|
+
componentId,
|
|
1027
|
+
oldComponent,
|
|
1028
|
+
newComponent,
|
|
1029
|
+
timestamp: Date.now()
|
|
1030
|
+
});
|
|
1031
|
+
return true;
|
|
1032
|
+
}
|
|
1033
|
+
function createVaporHMRHandler(componentId) {
|
|
1034
|
+
return (newModule) => {
|
|
1035
|
+
if (!newModule) {
|
|
1036
|
+
console.warn(`[LytJS HMR] No new module for ${componentId}`);
|
|
1037
|
+
return;
|
|
1038
|
+
}
|
|
1039
|
+
const newComponent = newModule.default;
|
|
1040
|
+
if (!newComponent) {
|
|
1041
|
+
console.warn(`[LytJS HMR] No default export in new module for ${componentId}`);
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
const instance = componentRegistry.get(componentId);
|
|
1045
|
+
if (!instance) {
|
|
1046
|
+
console.warn(`[LytJS HMR] Component instance not found: ${componentId}`);
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
const oldComponent = instance.component;
|
|
1050
|
+
const templateChanged = oldComponent.template !== newComponent.template;
|
|
1051
|
+
const setupChanged = oldComponent.setup?.toString() !== newComponent.setup?.toString();
|
|
1052
|
+
let updateType;
|
|
1053
|
+
if (setupChanged) {
|
|
1054
|
+
updateType = "script";
|
|
1055
|
+
} else if (templateChanged) {
|
|
1056
|
+
updateType = "template";
|
|
1057
|
+
} else {
|
|
1058
|
+
updateType = "style";
|
|
1059
|
+
}
|
|
1060
|
+
handleComponentUpdate(componentId, newComponent, updateType);
|
|
1061
|
+
};
|
|
1062
|
+
}
|
|
1063
|
+
function generateHMRCode(componentId) {
|
|
1064
|
+
return `
|
|
1065
|
+
if (import.meta.hot) {
|
|
1066
|
+
import.meta.hot.accept((newModule) => {
|
|
1067
|
+
if (newModule && newModule.default) {
|
|
1068
|
+
const instance = window.__LYTJS_HMR_REGISTRY__?.get('${componentId}');
|
|
1069
|
+
if (instance) {
|
|
1070
|
+
instance.component = newModule.default;
|
|
1071
|
+
// \u89E6\u53D1\u91CD\u65B0\u6E32\u67D3
|
|
1072
|
+
if (instance.container && instance.component.template) {
|
|
1073
|
+
// Vapor \u6A21\u5F0F\u4F1A\u81EA\u52A8\u901A\u8FC7 effect \u91CD\u65B0\u6E32\u67D3
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
}
|
|
1077
|
+
});
|
|
1078
|
+
}
|
|
1079
|
+
`;
|
|
1080
|
+
}
|
|
1081
|
+
function isHMRAvailable() {
|
|
1082
|
+
return typeof import.meta !== "undefined" && !!import.meta.hot;
|
|
1083
|
+
}
|
|
1084
|
+
function forceRerender(componentId) {
|
|
1085
|
+
const instance = componentRegistry.get(componentId);
|
|
1086
|
+
if (!instance) return false;
|
|
1087
|
+
emitHMRUpdate({
|
|
1088
|
+
type: "template",
|
|
1089
|
+
componentId,
|
|
1090
|
+
oldComponent: instance.component,
|
|
1091
|
+
newComponent: instance.component,
|
|
1092
|
+
timestamp: Date.now()
|
|
1093
|
+
});
|
|
1094
|
+
return true;
|
|
1095
|
+
}
|
|
1096
|
+
function clearHMRState() {
|
|
1097
|
+
componentRegistry.clear();
|
|
1098
|
+
hmrListeners.clear();
|
|
1099
|
+
componentIdCounter = 0;
|
|
1100
|
+
}
|
|
1101
|
+
var DEFAULT_STATE_PRESERVATION, componentRegistry, componentIdCounter, hmrListeners;
|
|
1102
|
+
var init_vapor_hmr = __esm({
|
|
1103
|
+
"src/vapor/vapor-hmr.ts"() {
|
|
1104
|
+
DEFAULT_STATE_PRESERVATION = {
|
|
1105
|
+
refs: true,
|
|
1106
|
+
reactive: true,
|
|
1107
|
+
computed: true,
|
|
1108
|
+
watches: false
|
|
1109
|
+
// watch 通常需要重新创建
|
|
1110
|
+
};
|
|
1111
|
+
componentRegistry = /* @__PURE__ */ new Map();
|
|
1112
|
+
componentIdCounter = 0;
|
|
1113
|
+
hmrListeners = /* @__PURE__ */ new Set();
|
|
1114
|
+
if (typeof window !== "undefined") {
|
|
1115
|
+
window.__LYTJS_HMR_REGISTRY__ = componentRegistry;
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
});
|
|
1119
|
+
|
|
1120
|
+
// src/signal/signal-renderer.ts
|
|
1121
|
+
var signal_renderer_exports = {};
|
|
1122
|
+
__export(signal_renderer_exports, {
|
|
1123
|
+
createSignalRenderer: () => createSignalRenderer
|
|
1124
|
+
});
|
|
1125
|
+
function setSafeHTML(el, html) {
|
|
1126
|
+
const wrapper = el;
|
|
1127
|
+
const realNode = "content" in wrapper && "firstChild" in wrapper && wrapper.firstChild !== null ? wrapper.firstChild : el;
|
|
1128
|
+
realNode.textContent = html;
|
|
1129
|
+
}
|
|
1130
|
+
function createSignalRenderer(template, context) {
|
|
1131
|
+
let cleanup = null;
|
|
1132
|
+
let code;
|
|
1133
|
+
let renderBody;
|
|
1134
|
+
try {
|
|
1135
|
+
const compileResult = compile(template, { rendererMode: "signal" });
|
|
1136
|
+
code = compileResult.code;
|
|
1137
|
+
renderBody = extractRenderBody(code);
|
|
1138
|
+
if (!renderBody) {
|
|
1139
|
+
throw new Error(
|
|
1140
|
+
`[LytJS] SignalRenderer: failed to extract render function from compiled code.`
|
|
1141
|
+
);
|
|
1142
|
+
}
|
|
1143
|
+
} catch (e) {
|
|
1144
|
+
throw e instanceof Error ? new Error(`[LytJS] SignalRenderer: template compilation failed. ${e.message}`) : new Error(`[LytJS] SignalRenderer: template compilation failed. ${String(e)}`);
|
|
1145
|
+
}
|
|
1146
|
+
return {
|
|
1147
|
+
render(container) {
|
|
1148
|
+
if (cleanup) {
|
|
1149
|
+
cleanup();
|
|
1150
|
+
cleanup = null;
|
|
1151
|
+
}
|
|
1152
|
+
const el = typeof container === "string" ? document.querySelector(container) : container;
|
|
1153
|
+
if (!el) {
|
|
1154
|
+
throw new Error(`[LytJS] SignalRenderer: cannot find element matching "${container}".`);
|
|
1155
|
+
}
|
|
1156
|
+
try {
|
|
1157
|
+
const renderFn = new Function(
|
|
1158
|
+
"effect",
|
|
1159
|
+
"reconcileArray",
|
|
1160
|
+
"createTemplate",
|
|
1161
|
+
"setText",
|
|
1162
|
+
"setHTML",
|
|
1163
|
+
"setAttribute",
|
|
1164
|
+
"setProperty",
|
|
1165
|
+
"setStyle",
|
|
1166
|
+
"setClass",
|
|
1167
|
+
"insert",
|
|
1168
|
+
"remove",
|
|
1169
|
+
"createEventHandler",
|
|
1170
|
+
"bindEffect",
|
|
1171
|
+
"onCleanup",
|
|
1172
|
+
"runCleanups",
|
|
1173
|
+
"_ctx",
|
|
1174
|
+
"_container",
|
|
1175
|
+
renderBody
|
|
1176
|
+
);
|
|
1177
|
+
const cleanupFn = renderFn(
|
|
1178
|
+
effect,
|
|
1179
|
+
reconcileArray,
|
|
1180
|
+
createTemplate,
|
|
1181
|
+
setText,
|
|
1182
|
+
setSafeHTML,
|
|
1183
|
+
setAttribute,
|
|
1184
|
+
setProperty,
|
|
1185
|
+
setStyle,
|
|
1186
|
+
setClass,
|
|
1187
|
+
insert,
|
|
1188
|
+
remove,
|
|
1189
|
+
createEventHandler,
|
|
1190
|
+
bindEffect,
|
|
1191
|
+
onCleanup,
|
|
1192
|
+
runCleanups,
|
|
1193
|
+
context,
|
|
1194
|
+
el
|
|
1195
|
+
);
|
|
1196
|
+
if (typeof cleanupFn === "function") {
|
|
1197
|
+
cleanup = cleanupFn;
|
|
1198
|
+
}
|
|
1199
|
+
} catch (e) {
|
|
1200
|
+
throw e instanceof Error ? new Error(`[LytJS] SignalRenderer: render execution failed. ${e.message}`) : new Error(`[LytJS] SignalRenderer: render execution failed. ${String(e)}`);
|
|
1201
|
+
}
|
|
1202
|
+
},
|
|
1203
|
+
unmount() {
|
|
1204
|
+
if (cleanup) {
|
|
1205
|
+
cleanup();
|
|
1206
|
+
cleanup = null;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
};
|
|
1210
|
+
}
|
|
1211
|
+
function extractRenderBody(code) {
|
|
1212
|
+
const funcMatch = code.match(/export\s+function\s+render\s*\([^)]*\)\s*\{/);
|
|
1213
|
+
if (!funcMatch) {
|
|
1214
|
+
return null;
|
|
1215
|
+
}
|
|
1216
|
+
const startIndex = funcMatch.index + funcMatch[0].length;
|
|
1217
|
+
let depth = 1;
|
|
1218
|
+
let i = startIndex;
|
|
1219
|
+
while (i < code.length && depth > 0) {
|
|
1220
|
+
const ch = code[i];
|
|
1221
|
+
if (ch === "'") {
|
|
1222
|
+
i++;
|
|
1223
|
+
while (i < code.length && code[i] !== "'") {
|
|
1224
|
+
if (code[i] === "\\") i++;
|
|
1225
|
+
i++;
|
|
1226
|
+
}
|
|
1227
|
+
i++;
|
|
1228
|
+
continue;
|
|
1229
|
+
}
|
|
1230
|
+
if (ch === '"') {
|
|
1231
|
+
i++;
|
|
1232
|
+
while (i < code.length && code[i] !== '"') {
|
|
1233
|
+
if (code[i] === "\\") i++;
|
|
1234
|
+
i++;
|
|
1235
|
+
}
|
|
1236
|
+
i++;
|
|
1237
|
+
continue;
|
|
1238
|
+
}
|
|
1239
|
+
if (ch === "`") {
|
|
1240
|
+
i++;
|
|
1241
|
+
while (i < code.length && code[i] !== "`") {
|
|
1242
|
+
if (code[i] === "\\") i++;
|
|
1243
|
+
if (code[i] === "$" && code[i + 1] === "{") {
|
|
1244
|
+
i += 2;
|
|
1245
|
+
let exprDepth = 1;
|
|
1246
|
+
while (i < code.length && exprDepth > 0) {
|
|
1247
|
+
if (code[i] === "'") {
|
|
1248
|
+
i++;
|
|
1249
|
+
while (i < code.length && code[i] !== "'") {
|
|
1250
|
+
if (code[i] === "\\") i++;
|
|
1251
|
+
i++;
|
|
1252
|
+
}
|
|
1253
|
+
i++;
|
|
1254
|
+
continue;
|
|
1255
|
+
}
|
|
1256
|
+
if (code[i] === '"') {
|
|
1257
|
+
i++;
|
|
1258
|
+
while (i < code.length && code[i] !== '"') {
|
|
1259
|
+
if (code[i] === "\\") i++;
|
|
1260
|
+
i++;
|
|
1261
|
+
}
|
|
1262
|
+
i++;
|
|
1263
|
+
continue;
|
|
1264
|
+
}
|
|
1265
|
+
if (code[i] === "`") {
|
|
1266
|
+
i++;
|
|
1267
|
+
while (i < code.length && code[i] !== "`") {
|
|
1268
|
+
if (code[i] === "\\") i++;
|
|
1269
|
+
i++;
|
|
1270
|
+
}
|
|
1271
|
+
i++;
|
|
1272
|
+
continue;
|
|
1273
|
+
}
|
|
1274
|
+
if (code[i] === "{") exprDepth++;
|
|
1275
|
+
if (code[i] === "}") exprDepth--;
|
|
1276
|
+
i++;
|
|
1277
|
+
}
|
|
1278
|
+
continue;
|
|
1279
|
+
}
|
|
1280
|
+
i++;
|
|
1281
|
+
}
|
|
1282
|
+
i++;
|
|
1283
|
+
continue;
|
|
1284
|
+
}
|
|
1285
|
+
if (ch === "/" && code[i + 1] === "/") {
|
|
1286
|
+
i += 2;
|
|
1287
|
+
while (i < code.length && code[i] !== "\n") {
|
|
1288
|
+
i++;
|
|
1289
|
+
}
|
|
1290
|
+
i++;
|
|
1291
|
+
continue;
|
|
1292
|
+
}
|
|
1293
|
+
if (ch === "/" && code[i + 1] === "*") {
|
|
1294
|
+
i += 2;
|
|
1295
|
+
while (i < code.length && !(code[i] === "*" && code[i + 1] === "/")) {
|
|
1296
|
+
i++;
|
|
1297
|
+
}
|
|
1298
|
+
i += 2;
|
|
1299
|
+
continue;
|
|
1300
|
+
}
|
|
1301
|
+
if (ch === "{") {
|
|
1302
|
+
depth++;
|
|
1303
|
+
} else if (ch === "}") {
|
|
1304
|
+
depth--;
|
|
1305
|
+
}
|
|
1306
|
+
i++;
|
|
1307
|
+
}
|
|
1308
|
+
if (depth !== 0) {
|
|
1309
|
+
return null;
|
|
1310
|
+
}
|
|
1311
|
+
const body = code.substring(startIndex, i - 1).trim();
|
|
1312
|
+
return body;
|
|
1313
|
+
}
|
|
1314
|
+
var init_signal_renderer = __esm({
|
|
1315
|
+
"src/signal/signal-renderer.ts"() {
|
|
1316
|
+
}
|
|
1317
|
+
});
|
|
1318
|
+
|
|
1319
|
+
// src/vapor/vapor-ssr.ts
|
|
1320
|
+
var vapor_ssr_exports = {};
|
|
1321
|
+
__export(vapor_ssr_exports, {
|
|
1322
|
+
definePrefetch: () => definePrefetch,
|
|
1323
|
+
hydrateVaporComponent: () => hydrateVaporComponent,
|
|
1324
|
+
renderToStream: () => renderVaporToStream,
|
|
1325
|
+
renderToString: () => renderVaporToString,
|
|
1326
|
+
renderVaporToStream: () => renderVaporToStream,
|
|
1327
|
+
renderVaporToString: () => renderVaporToString,
|
|
1328
|
+
usePrefetchData: () => usePrefetchData
|
|
1329
|
+
});
|
|
1330
|
+
async function renderVaporToString(component, props = {}, options = {}) {
|
|
1331
|
+
const {
|
|
1332
|
+
includePrefetchScript = false,
|
|
1333
|
+
serialize = defaultSerialize
|
|
1334
|
+
} = options;
|
|
1335
|
+
const setupResult = await executeSetup(component, props);
|
|
1336
|
+
const compiledTemplate = compileTemplateForSSR(component.template);
|
|
1337
|
+
const html = renderTemplateToHTML(compiledTemplate, setupResult);
|
|
1338
|
+
let prefetchData;
|
|
1339
|
+
if (setupResult.__prefetchData__) {
|
|
1340
|
+
prefetchData = setupResult.__prefetchData__;
|
|
1341
|
+
}
|
|
1342
|
+
const scripts = [];
|
|
1343
|
+
if (includePrefetchScript && prefetchData) {
|
|
1344
|
+
scripts.push(
|
|
1345
|
+
`<script>window.__LYTJS_PREFETCH_DATA__=${serialize(prefetchData)};</script>`
|
|
1346
|
+
);
|
|
1347
|
+
}
|
|
1348
|
+
return {
|
|
1349
|
+
html,
|
|
1350
|
+
prefetchData,
|
|
1351
|
+
scripts: scripts.length > 0 ? scripts : void 0
|
|
1352
|
+
};
|
|
1353
|
+
}
|
|
1354
|
+
async function renderVaporToStream(component, props = {}, _options = {}) {
|
|
1355
|
+
let prefetchResolve;
|
|
1356
|
+
const prefetchPromise = new Promise((resolve) => {
|
|
1357
|
+
prefetchResolve = resolve;
|
|
1358
|
+
});
|
|
1359
|
+
const encoder = new TextEncoder();
|
|
1360
|
+
const stream = new ReadableStream({
|
|
1361
|
+
async start(controller) {
|
|
1362
|
+
try {
|
|
1363
|
+
const setupResult = await executeSetup(component, props);
|
|
1364
|
+
const _compiledTemplate = compileTemplateForSSR(component.template);
|
|
1365
|
+
const htmlChunks = renderTemplateToChunks(_compiledTemplate, setupResult);
|
|
1366
|
+
for (const chunk of htmlChunks) {
|
|
1367
|
+
controller.enqueue(encoder.encode(chunk));
|
|
1368
|
+
await yieldToMicrotask();
|
|
1369
|
+
}
|
|
1370
|
+
if (setupResult.__prefetchData__) {
|
|
1371
|
+
prefetchResolve(setupResult.__prefetchData__);
|
|
1372
|
+
} else {
|
|
1373
|
+
prefetchResolve({});
|
|
1374
|
+
}
|
|
1375
|
+
controller.close();
|
|
1376
|
+
} catch (error2) {
|
|
1377
|
+
controller.error(error2);
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
});
|
|
1381
|
+
return {
|
|
1382
|
+
stream,
|
|
1383
|
+
prefetchData: prefetchPromise
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
async function executeSetup(component, props) {
|
|
1387
|
+
const ctx = { ...props };
|
|
1388
|
+
if (typeof component.setup === "function") {
|
|
1389
|
+
const vaporContext = {
|
|
1390
|
+
attrs: { ...props },
|
|
1391
|
+
slots: {},
|
|
1392
|
+
emit: () => {
|
|
1393
|
+
}
|
|
1394
|
+
};
|
|
1395
|
+
const result = component.setup(props, vaporContext);
|
|
1396
|
+
if (result instanceof Promise) {
|
|
1397
|
+
const asyncResult = await result;
|
|
1398
|
+
if (asyncResult && typeof asyncResult === "object") {
|
|
1399
|
+
Object.assign(ctx, asyncResult);
|
|
1400
|
+
}
|
|
1401
|
+
} else if (result && typeof result === "object") {
|
|
1402
|
+
Object.assign(ctx, result);
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
return ctx;
|
|
1406
|
+
}
|
|
1407
|
+
function compileTemplateForSSR(template) {
|
|
1408
|
+
const result = compile(template, {
|
|
1409
|
+
ssrMode: true,
|
|
1410
|
+
rendererMode: "signal"
|
|
1411
|
+
});
|
|
1412
|
+
return result.code;
|
|
1413
|
+
}
|
|
1414
|
+
function renderTemplateToHTML(_compiledCode, ctx) {
|
|
1415
|
+
return renderContextToHTML(ctx);
|
|
1416
|
+
}
|
|
1417
|
+
function renderContextToHTML(ctx) {
|
|
1418
|
+
const dataAttr = Object.entries(ctx).filter(([key]) => !key.startsWith("__")).map(([key, value]) => `data-${key}="${escapeHtml(String(value))}"`).join(" ");
|
|
1419
|
+
return `<div ${dataAttr} data-vapor-ssr="true"><!-- Vapor SSR Placeholder --></div>`;
|
|
1420
|
+
}
|
|
1421
|
+
function renderTemplateToChunks(_compiledCode, ctx) {
|
|
1422
|
+
const html = renderContextToHTML(ctx);
|
|
1423
|
+
const chunks = [];
|
|
1424
|
+
const chunkSize = 1024;
|
|
1425
|
+
for (let i = 0; i < html.length; i += chunkSize) {
|
|
1426
|
+
chunks.push(html.slice(i, i + chunkSize));
|
|
1427
|
+
}
|
|
1428
|
+
return chunks.length > 0 ? chunks : [""];
|
|
1429
|
+
}
|
|
1430
|
+
function defaultSerialize(data) {
|
|
1431
|
+
return JSON.stringify(data, (_key, value) => {
|
|
1432
|
+
if (typeof value === "function") {
|
|
1433
|
+
return void 0;
|
|
1434
|
+
}
|
|
1435
|
+
if (value instanceof Map) {
|
|
1436
|
+
return { __type: "Map", value: Array.from(value.entries()) };
|
|
1437
|
+
}
|
|
1438
|
+
if (value instanceof Set) {
|
|
1439
|
+
return { __type: "Set", value: Array.from(value.values()) };
|
|
1440
|
+
}
|
|
1441
|
+
if (typeof value === "bigint") {
|
|
1442
|
+
return { __type: "BigInt", value: value.toString() };
|
|
1443
|
+
}
|
|
1444
|
+
return value;
|
|
1445
|
+
});
|
|
1446
|
+
}
|
|
1447
|
+
function yieldToMicrotask() {
|
|
1448
|
+
return new Promise((resolve) => {
|
|
1449
|
+
if (typeof queueMicrotask === "function") {
|
|
1450
|
+
queueMicrotask(resolve);
|
|
1451
|
+
} else {
|
|
1452
|
+
Promise.resolve().then(resolve);
|
|
1453
|
+
}
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
function definePrefetch(fetcher) {
|
|
1457
|
+
return {
|
|
1458
|
+
data: void 0,
|
|
1459
|
+
__prefetchFn__: fetcher
|
|
1460
|
+
};
|
|
1461
|
+
}
|
|
1462
|
+
function usePrefetchData(key, _fetcher) {
|
|
1463
|
+
if (typeof window !== "undefined") {
|
|
1464
|
+
const prefetchData = window.__LYTJS_PREFETCH_DATA__;
|
|
1465
|
+
if (prefetchData && prefetchData[key]) {
|
|
1466
|
+
return {
|
|
1467
|
+
data: prefetchData[key],
|
|
1468
|
+
pending: false,
|
|
1469
|
+
error: null
|
|
1470
|
+
};
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
return {
|
|
1474
|
+
data: void 0,
|
|
1475
|
+
pending: true,
|
|
1476
|
+
error: null
|
|
1477
|
+
};
|
|
1478
|
+
}
|
|
1479
|
+
async function hydrateVaporComponent(container, component, _options = {}) {
|
|
1480
|
+
const el = typeof container === "string" ? document.querySelector(container) : container;
|
|
1481
|
+
if (!el) {
|
|
1482
|
+
throw new Error(`[LytJS] hydrateVaporComponent: container not found`);
|
|
1483
|
+
}
|
|
1484
|
+
const ssrMarker = el.querySelector("[data-vapor-ssr]");
|
|
1485
|
+
if (!ssrMarker) {
|
|
1486
|
+
console.warn("[LytJS] hydrateVaporComponent: no SSR marker found");
|
|
1487
|
+
}
|
|
1488
|
+
const props = {};
|
|
1489
|
+
if (typeof component.setup === "function") {
|
|
1490
|
+
const vaporContext = {
|
|
1491
|
+
attrs: {},
|
|
1492
|
+
slots: {},
|
|
1493
|
+
emit: () => {
|
|
1494
|
+
}
|
|
1495
|
+
};
|
|
1496
|
+
const result = component.setup(props, vaporContext);
|
|
1497
|
+
if (result && typeof result === "object") {
|
|
1498
|
+
Object.assign(props, result);
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
const { createSignalRenderer: createSignalRenderer3 } = await Promise.resolve().then(() => (init_signal_renderer(), signal_renderer_exports));
|
|
1502
|
+
const renderer = createSignalRenderer3(component.template, props);
|
|
1503
|
+
renderer.render(el);
|
|
1504
|
+
el.setAttribute("data-vapor-hydrated", "true");
|
|
1505
|
+
}
|
|
1506
|
+
var init_vapor_ssr = __esm({
|
|
1507
|
+
"src/vapor/vapor-ssr.ts"() {
|
|
1508
|
+
init_utils();
|
|
1509
|
+
}
|
|
1510
|
+
});
|
|
1511
|
+
|
|
1512
|
+
// src/ssr/ssr-renderer.ts
|
|
1513
|
+
var ssr_renderer_exports = {};
|
|
1514
|
+
__export(ssr_renderer_exports, {
|
|
1515
|
+
renderToString: () => renderToString
|
|
1516
|
+
});
|
|
1517
|
+
function renderToString(input) {
|
|
1518
|
+
return Promise.resolve(renderVNodeToString(input.vnode));
|
|
1519
|
+
}
|
|
1520
|
+
function renderVNodeToString(vnode) {
|
|
1521
|
+
const { type, shapeFlag, children } = vnode;
|
|
1522
|
+
if (type === Fragment) {
|
|
1523
|
+
return renderFragmentToString(vnode);
|
|
1524
|
+
}
|
|
1525
|
+
if (type === Text) {
|
|
1526
|
+
const text = isFunction(children) ? "" : String(children ?? "");
|
|
1527
|
+
return escapeHtml(text);
|
|
1528
|
+
}
|
|
1529
|
+
if (type === Comment) {
|
|
1530
|
+
const text = isFunction(children) ? "" : String(children ?? "");
|
|
1531
|
+
let safe = text.replace(/<!--/g, "<!--").replace(/-->/g, "-->");
|
|
1532
|
+
safe = safe.replace(/--/g, "- -");
|
|
1533
|
+
return `<!--${safe}-->`;
|
|
1534
|
+
}
|
|
1535
|
+
if (shapeFlag & ShapeFlags.ELEMENT) {
|
|
1536
|
+
return renderElementToString(vnode);
|
|
1537
|
+
}
|
|
1538
|
+
return "";
|
|
1539
|
+
}
|
|
1540
|
+
function renderFragmentToString(vnode) {
|
|
1541
|
+
const children = vnode.children;
|
|
1542
|
+
if (isArray(children)) {
|
|
1543
|
+
return children.map((child) => child != null ? renderVNodeToString(child) : "").join("");
|
|
1544
|
+
}
|
|
1545
|
+
return "";
|
|
1546
|
+
}
|
|
1547
|
+
function renderElementToString(vnode) {
|
|
1548
|
+
const tag = vnode.type;
|
|
1549
|
+
if (!isValidHTMLElementTag(tag)) {
|
|
1550
|
+
return "";
|
|
1551
|
+
}
|
|
1552
|
+
const props = vnode.props ?? {};
|
|
1553
|
+
const { shapeFlag, children } = vnode;
|
|
1554
|
+
let html = `<${tag}`;
|
|
1555
|
+
for (const key in props) {
|
|
1556
|
+
if (key === "key" || key === "ref") continue;
|
|
1557
|
+
html += renderAttributeToString(key, props[key]);
|
|
1558
|
+
}
|
|
1559
|
+
if (isVoidElement(tag)) {
|
|
1560
|
+
html += " />";
|
|
1561
|
+
return html;
|
|
1562
|
+
}
|
|
1563
|
+
html += ">";
|
|
1564
|
+
if (shapeFlag & ShapeFlags.TEXT_CHILDREN) {
|
|
1565
|
+
const text = isFunction(children) ? "" : String(children ?? "");
|
|
1566
|
+
html += escapeHtml(text);
|
|
1567
|
+
} else if (shapeFlag & ShapeFlags.ARRAY_CHILDREN && isArray(children)) {
|
|
1568
|
+
for (let i = 0; i < children.length; i++) {
|
|
1569
|
+
const child = children[i];
|
|
1570
|
+
if (child != null) {
|
|
1571
|
+
html += renderVNodeToString(child);
|
|
1572
|
+
}
|
|
1573
|
+
}
|
|
1574
|
+
}
|
|
1575
|
+
html += `</${tag}>`;
|
|
1576
|
+
return html;
|
|
1577
|
+
}
|
|
1578
|
+
var init_ssr_renderer = __esm({
|
|
1579
|
+
"src/ssr/ssr-renderer.ts"() {
|
|
1580
|
+
init_utils();
|
|
1581
|
+
init_ssr_utils();
|
|
1582
|
+
}
|
|
1583
|
+
});
|
|
1584
|
+
|
|
1585
|
+
// src/ssr/ssr-stream.ts
|
|
1586
|
+
var ssr_stream_exports = {};
|
|
1587
|
+
__export(ssr_stream_exports, {
|
|
1588
|
+
NAMED_ENTITIES: () => NAMED_ENTITIES,
|
|
1589
|
+
renderToStream: () => renderToStream
|
|
1590
|
+
});
|
|
1591
|
+
function isComponentVNode(vnode) {
|
|
1592
|
+
return !!(vnode.shapeFlag & COMPONENT_MASK2);
|
|
1593
|
+
}
|
|
1594
|
+
function isSuspenseVNode(vnode) {
|
|
1595
|
+
if (!isComponentVNode(vnode)) return false;
|
|
1596
|
+
const type = vnode.type;
|
|
1597
|
+
if (typeof type === "object" && type !== null && "name" in type) {
|
|
1598
|
+
return type.name === "Suspense";
|
|
1599
|
+
}
|
|
1600
|
+
if (typeof type === "function" && "name" in type) {
|
|
1601
|
+
return type.name === "Suspense";
|
|
1602
|
+
}
|
|
1603
|
+
return false;
|
|
1604
|
+
}
|
|
1605
|
+
function renderToStream(input, options) {
|
|
1606
|
+
const encoder = new TextEncoder();
|
|
1607
|
+
const commentMarkers = options?.commentMarkers ?? false;
|
|
1608
|
+
return new ReadableStream({
|
|
1609
|
+
async pull(controller) {
|
|
1610
|
+
try {
|
|
1611
|
+
await streamVNodeAsync(input.vnode, controller, encoder, commentMarkers);
|
|
1612
|
+
} catch (err) {
|
|
1613
|
+
controller.error(err);
|
|
1614
|
+
return;
|
|
1615
|
+
}
|
|
1616
|
+
controller.close();
|
|
1617
|
+
}
|
|
1618
|
+
});
|
|
1619
|
+
}
|
|
1620
|
+
function pushChunk(controller, encoder, html, commentMarkers, label) {
|
|
1621
|
+
if (commentMarkers && label) {
|
|
1622
|
+
const marker = `<!-- stream:${label} -->`;
|
|
1623
|
+
controller.enqueue(encoder.encode(marker));
|
|
1624
|
+
}
|
|
1625
|
+
controller.enqueue(encoder.encode(html));
|
|
1626
|
+
}
|
|
1627
|
+
async function streamVNodeAsync(vnode, controller, encoder, commentMarkers) {
|
|
1628
|
+
const { type, shapeFlag, children } = vnode;
|
|
1629
|
+
if (type === Fragment) {
|
|
1630
|
+
await streamFragmentAsync(vnode, controller, encoder, commentMarkers);
|
|
1631
|
+
return;
|
|
1632
|
+
}
|
|
1633
|
+
if (type === Text) {
|
|
1634
|
+
const text = isFunction(children) ? "" : String(children ?? "");
|
|
1635
|
+
pushChunk(controller, encoder, escapeHtml(text), commentMarkers, "text");
|
|
1636
|
+
return;
|
|
1637
|
+
}
|
|
1638
|
+
if (type === Comment) {
|
|
1639
|
+
const text = isFunction(children) ? "" : String(children ?? "");
|
|
1640
|
+
let safe = text.replace(/<!--/g, "<!--").replace(/-->/g, "-->");
|
|
1641
|
+
safe = safe.replace(/--/g, "- -");
|
|
1642
|
+
pushChunk(controller, encoder, `<!--${safe}-->`, commentMarkers, "comment");
|
|
1643
|
+
return;
|
|
1644
|
+
}
|
|
1645
|
+
if (isSuspenseVNode(vnode)) {
|
|
1646
|
+
await streamSuspenseBoundary(vnode, controller, encoder, commentMarkers);
|
|
1647
|
+
return;
|
|
1648
|
+
}
|
|
1649
|
+
if (shapeFlag & ShapeFlags.ELEMENT) {
|
|
1650
|
+
await streamElementAsync(vnode, controller, encoder, commentMarkers);
|
|
1651
|
+
return;
|
|
1652
|
+
}
|
|
1653
|
+
if (isComponentVNode(vnode)) {
|
|
1654
|
+
await streamComponentAsync(vnode, controller, encoder, commentMarkers);
|
|
1655
|
+
return;
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
async function streamFragmentAsync(vnode, controller, encoder, commentMarkers) {
|
|
1659
|
+
const children = vnode.children;
|
|
1660
|
+
if (isArray(children)) {
|
|
1661
|
+
for (let i = 0; i < children.length; i++) {
|
|
1662
|
+
const child = children[i];
|
|
1663
|
+
if (child != null) {
|
|
1664
|
+
await streamVNodeAsync(child, controller, encoder, commentMarkers);
|
|
1665
|
+
await yieldToMicrotask2();
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
}
|
|
1670
|
+
async function streamSuspenseBoundary(vnode, controller, encoder, commentMarkers) {
|
|
1671
|
+
const suspenseId = `suspense-${++suspenseIdCounter}`;
|
|
1672
|
+
pushChunk(controller, encoder, `<!--${suspenseId}-start-->`, commentMarkers, "suspense:start");
|
|
1673
|
+
const defaultSlot = vnode.props?.default;
|
|
1674
|
+
const fallbackSlot = vnode.props?.fallback;
|
|
1675
|
+
if (fallbackSlot) {
|
|
1676
|
+
pushChunk(
|
|
1677
|
+
controller,
|
|
1678
|
+
encoder,
|
|
1679
|
+
`<!--${suspenseId}-fallback-start-->`,
|
|
1680
|
+
commentMarkers,
|
|
1681
|
+
"suspense:fallback"
|
|
1682
|
+
);
|
|
1683
|
+
try {
|
|
1684
|
+
const fallbackResult = fallbackSlot();
|
|
1685
|
+
if (isArray(fallbackResult)) {
|
|
1686
|
+
for (const child of fallbackResult) {
|
|
1687
|
+
if (child != null && typeof child === "object" && "type" in child) {
|
|
1688
|
+
await streamVNodeAsync(child, controller, encoder, commentMarkers);
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
} else if (fallbackResult != null && typeof fallbackResult === "object" && "type" in fallbackResult) {
|
|
1692
|
+
await streamVNodeAsync(fallbackResult, controller, encoder, commentMarkers);
|
|
1693
|
+
}
|
|
1694
|
+
} catch (_err) {
|
|
1695
|
+
}
|
|
1696
|
+
pushChunk(
|
|
1697
|
+
controller,
|
|
1698
|
+
encoder,
|
|
1699
|
+
`<!--${suspenseId}-fallback-end-->`,
|
|
1700
|
+
commentMarkers,
|
|
1701
|
+
"suspense:fallback-end"
|
|
1702
|
+
);
|
|
1703
|
+
}
|
|
1704
|
+
if (defaultSlot) {
|
|
1705
|
+
try {
|
|
1706
|
+
const result = defaultSlot();
|
|
1707
|
+
const resolved = result instanceof Promise ? await result : result;
|
|
1708
|
+
pushChunk(
|
|
1709
|
+
controller,
|
|
1710
|
+
encoder,
|
|
1711
|
+
`<!--${suspenseId}-content-start-->`,
|
|
1712
|
+
commentMarkers,
|
|
1713
|
+
"suspense:content"
|
|
1714
|
+
);
|
|
1715
|
+
if (isArray(resolved)) {
|
|
1716
|
+
for (const child of resolved) {
|
|
1717
|
+
if (child != null && typeof child === "object" && "type" in child) {
|
|
1718
|
+
await streamVNodeAsync(child, controller, encoder, commentMarkers);
|
|
1719
|
+
await yieldToMicrotask2();
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
} else if (resolved != null && typeof resolved === "object" && "type" in resolved) {
|
|
1723
|
+
await streamVNodeAsync(resolved, controller, encoder, commentMarkers);
|
|
1724
|
+
}
|
|
1725
|
+
pushChunk(
|
|
1726
|
+
controller,
|
|
1727
|
+
encoder,
|
|
1728
|
+
`<!--${suspenseId}-content-end-->`,
|
|
1729
|
+
commentMarkers,
|
|
1730
|
+
"suspense:content-end"
|
|
1731
|
+
);
|
|
1732
|
+
} catch (_err) {
|
|
1733
|
+
pushChunk(
|
|
1734
|
+
controller,
|
|
1735
|
+
encoder,
|
|
1736
|
+
`<!--${suspenseId}-error-->`,
|
|
1737
|
+
commentMarkers,
|
|
1738
|
+
"suspense:error"
|
|
1739
|
+
);
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
pushChunk(controller, encoder, `<!--${suspenseId}-end-->`, commentMarkers, "suspense:end");
|
|
1743
|
+
}
|
|
1744
|
+
async function streamComponentAsync(vnode, controller, encoder, commentMarkers) {
|
|
1745
|
+
const component = vnode.type;
|
|
1746
|
+
if (typeof component === "object" && component !== null) {
|
|
1747
|
+
if (typeof component.render === "function") {
|
|
1748
|
+
const result = component.render(vnode.props ?? {});
|
|
1749
|
+
if (result && typeof result === "object" && "type" in result) {
|
|
1750
|
+
await streamVNodeAsync(result, controller, encoder, commentMarkers);
|
|
1751
|
+
return;
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
if (typeof component.setup === "function") {
|
|
1755
|
+
const setupResult = component.setup(vnode.props ?? {});
|
|
1756
|
+
const resolved = setupResult instanceof Promise ? await setupResult : setupResult;
|
|
1757
|
+
if (resolved && typeof resolved === "object" && "type" in resolved) {
|
|
1758
|
+
await streamVNodeAsync(resolved, controller, encoder, commentMarkers);
|
|
1759
|
+
return;
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
async function streamElementAsync(vnode, controller, encoder, commentMarkers) {
|
|
1765
|
+
const tag = vnode.type;
|
|
1766
|
+
if (!isValidHTMLElementTag(tag)) {
|
|
1767
|
+
return;
|
|
1768
|
+
}
|
|
1769
|
+
const props = vnode.props ?? {};
|
|
1770
|
+
const { shapeFlag, children } = vnode;
|
|
1771
|
+
let openTag = `<${tag}`;
|
|
1772
|
+
for (const key of Object.keys(props)) {
|
|
1773
|
+
if (key === "key" || key === "ref") continue;
|
|
1774
|
+
openTag += renderAttributeToString(key, props[key]);
|
|
1775
|
+
}
|
|
1776
|
+
if (isVoidElement(tag)) {
|
|
1777
|
+
openTag += " />";
|
|
1778
|
+
pushChunk(controller, encoder, openTag, commentMarkers, `element:${tag}`);
|
|
1779
|
+
return;
|
|
1780
|
+
}
|
|
1781
|
+
openTag += ">";
|
|
1782
|
+
pushChunk(controller, encoder, openTag, commentMarkers, `element:${tag}:open`);
|
|
1783
|
+
if (shapeFlag & ShapeFlags.TEXT_CHILDREN) {
|
|
1784
|
+
const text = isFunction(children) ? "" : String(children ?? "");
|
|
1785
|
+
pushChunk(controller, encoder, escapeHtml(text), commentMarkers, `element:${tag}:text`);
|
|
1786
|
+
} else if (shapeFlag & ShapeFlags.ARRAY_CHILDREN && isArray(children)) {
|
|
1787
|
+
for (let i = 0; i < children.length; i++) {
|
|
1788
|
+
const child = children[i];
|
|
1789
|
+
if (child != null) {
|
|
1790
|
+
await streamVNodeAsync(child, controller, encoder, commentMarkers);
|
|
1791
|
+
await yieldToMicrotask2();
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
const closeTag = `</${tag}>`;
|
|
1796
|
+
pushChunk(controller, encoder, closeTag, commentMarkers, `element:${tag}:close`);
|
|
1797
|
+
}
|
|
1798
|
+
function yieldToMicrotask2() {
|
|
1799
|
+
return new Promise((resolve) => {
|
|
1800
|
+
if (typeof queueMicrotask === "function") {
|
|
1801
|
+
queueMicrotask(resolve);
|
|
1802
|
+
} else {
|
|
1803
|
+
Promise.resolve().then(resolve);
|
|
1804
|
+
}
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1807
|
+
var suspenseIdCounter, COMPONENT_MASK2;
|
|
1808
|
+
var init_ssr_stream = __esm({
|
|
1809
|
+
"src/ssr/ssr-stream.ts"() {
|
|
1810
|
+
init_utils();
|
|
1811
|
+
init_ssr_utils();
|
|
1812
|
+
suspenseIdCounter = 0;
|
|
1813
|
+
COMPONENT_MASK2 = ShapeFlags.STATEFUL_COMPONENT | ShapeFlags.FUNCTIONAL_COMPONENT;
|
|
1814
|
+
}
|
|
1815
|
+
});
|
|
1816
|
+
|
|
1817
|
+
// src/ssr/ssr-island.ts
|
|
1818
|
+
var ssr_island_exports = {};
|
|
1819
|
+
__export(ssr_island_exports, {
|
|
1820
|
+
createIslandSSRContent: () => createIslandSSRContent,
|
|
1821
|
+
getIslandComponent: () => getIslandComponent,
|
|
1822
|
+
hydrateIsland: () => hydrateIsland,
|
|
1823
|
+
registerIslandComponent: () => registerIslandComponent
|
|
1824
|
+
});
|
|
1825
|
+
function registerIslandComponent(name, component) {
|
|
1826
|
+
if (!name || typeof name !== "string") {
|
|
1827
|
+
return;
|
|
1828
|
+
}
|
|
1829
|
+
islandRegistry.set(name, component);
|
|
1830
|
+
}
|
|
1831
|
+
function getIslandComponent(name) {
|
|
1832
|
+
return islandRegistry.get(name);
|
|
1833
|
+
}
|
|
1834
|
+
function createIslandSSRContent(name, props) {
|
|
1835
|
+
const encodedProps = encodeProps(props);
|
|
1836
|
+
return `<div data-island="${escapeHtml(name)}" data-props="${escapeHtml(encodedProps)}"><!-- island placeholder --></div>`;
|
|
1837
|
+
}
|
|
1838
|
+
async function hydrateIsland(container, component, props) {
|
|
1839
|
+
let root;
|
|
1840
|
+
if (isString(container)) {
|
|
1841
|
+
root = document.querySelector(container);
|
|
1842
|
+
} else {
|
|
1843
|
+
root = container;
|
|
1844
|
+
}
|
|
1845
|
+
if (!root) {
|
|
1846
|
+
return;
|
|
1847
|
+
}
|
|
1848
|
+
const islandElements = root.querySelectorAll("[data-island]");
|
|
1849
|
+
for (let i = 0; i < islandElements.length; i++) {
|
|
1850
|
+
const el = islandElements[i];
|
|
1851
|
+
const islandName = el.getAttribute("data-island");
|
|
1852
|
+
if (!islandName) continue;
|
|
1853
|
+
let resolvedComponent = islandRegistry.get(islandName);
|
|
1854
|
+
if (!resolvedComponent && islandName === component.name) {
|
|
1855
|
+
resolvedComponent = component;
|
|
1856
|
+
}
|
|
1857
|
+
if (!resolvedComponent) {
|
|
1858
|
+
continue;
|
|
1859
|
+
}
|
|
1860
|
+
const resolvedProps = props ?? decodeProps(el.getAttribute("data-props") ?? "");
|
|
1861
|
+
await hydrateIslandElement(el, resolvedComponent, resolvedProps);
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
async function hydrateIslandElement(el, component, props) {
|
|
1865
|
+
let setupResult = void 0;
|
|
1866
|
+
if (typeof component.setup === "function") {
|
|
1867
|
+
setupResult = component.setup(props);
|
|
1868
|
+
}
|
|
1869
|
+
let vnode;
|
|
1870
|
+
if (setupResult && typeof setupResult === "object" && "type" in setupResult) {
|
|
1871
|
+
vnode = setupResult;
|
|
1872
|
+
} else if (typeof component.render === "function") {
|
|
1873
|
+
const ctx = setupResult && typeof setupResult === "object" ? setupResult : {};
|
|
1874
|
+
vnode = component.render(ctx);
|
|
1875
|
+
}
|
|
1876
|
+
if (vnode) {
|
|
1877
|
+
const placeholderComments = [];
|
|
1878
|
+
for (let i = el.childNodes.length - 1; i >= 0; i--) {
|
|
1879
|
+
const child = el.childNodes[i];
|
|
1880
|
+
if (child && child.nodeType === Node.COMMENT_NODE) {
|
|
1881
|
+
placeholderComments.push(child);
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
for (const comment of placeholderComments) {
|
|
1885
|
+
comment.remove();
|
|
1886
|
+
}
|
|
1887
|
+
hydrateVNode(el, vnode);
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
function hydrateVNode(parent, vnode) {
|
|
1891
|
+
const { type, children } = vnode;
|
|
1892
|
+
if (type === Fragment) {
|
|
1893
|
+
if (isArray(children)) {
|
|
1894
|
+
let domIndex = 0;
|
|
1895
|
+
const existingChildren = Array.from(parent.childNodes);
|
|
1896
|
+
for (let i = 0; i < children.length; i++) {
|
|
1897
|
+
const childVNode = children[i];
|
|
1898
|
+
if (childVNode == null) continue;
|
|
1899
|
+
domIndex = hydrateChildVNode(parent, childVNode, existingChildren, domIndex);
|
|
1900
|
+
}
|
|
1901
|
+
removeRemainingChildren(parent, existingChildren, domIndex);
|
|
1902
|
+
}
|
|
1903
|
+
return;
|
|
1904
|
+
}
|
|
1905
|
+
if (type === Text) {
|
|
1906
|
+
const text = isString(children) ? children : String(children ?? "");
|
|
1907
|
+
const firstChild = parent.firstChild;
|
|
1908
|
+
if (firstChild && firstChild.nodeType === Node.TEXT_NODE) {
|
|
1909
|
+
if (firstChild.textContent !== text) {
|
|
1910
|
+
firstChild.textContent = text;
|
|
1911
|
+
}
|
|
1912
|
+
} else {
|
|
1913
|
+
const textNode = document.createTextNode(text);
|
|
1914
|
+
parent.appendChild(textNode);
|
|
1915
|
+
}
|
|
1916
|
+
return;
|
|
1917
|
+
}
|
|
1918
|
+
if (typeof type === "string") {
|
|
1919
|
+
const tag = type.toLowerCase();
|
|
1920
|
+
let matchedElement = null;
|
|
1921
|
+
const existingChildren = Array.from(parent.childNodes);
|
|
1922
|
+
for (let i = 0; i < existingChildren.length; i++) {
|
|
1923
|
+
const child = existingChildren[i];
|
|
1924
|
+
if (child && child.nodeType === Node.ELEMENT_NODE) {
|
|
1925
|
+
const el = child;
|
|
1926
|
+
if (el.tagName.toLowerCase() === tag) {
|
|
1927
|
+
matchedElement = el;
|
|
1928
|
+
break;
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
}
|
|
1932
|
+
if (matchedElement) {
|
|
1933
|
+
hydrateAttributes(matchedElement, vnode);
|
|
1934
|
+
hydrateElementChildren(matchedElement, vnode);
|
|
1935
|
+
} else {
|
|
1936
|
+
const newElement = createElementFromVNode(vnode);
|
|
1937
|
+
if (newElement) {
|
|
1938
|
+
parent.appendChild(newElement);
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
return;
|
|
1942
|
+
}
|
|
1943
|
+
if (typeof type === "object" && type !== null) {
|
|
1944
|
+
const component = type;
|
|
1945
|
+
let childVNode;
|
|
1946
|
+
if (typeof component.render === "function") {
|
|
1947
|
+
const ctx = vnode.props ?? {};
|
|
1948
|
+
const result = component.render(ctx);
|
|
1949
|
+
if (result && typeof result === "object" && "type" in result) {
|
|
1950
|
+
childVNode = result;
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
if (!childVNode && typeof component.setup === "function") {
|
|
1954
|
+
const setupResult = component.setup(vnode.props ?? {});
|
|
1955
|
+
if (setupResult && typeof setupResult === "object" && "type" in setupResult) {
|
|
1956
|
+
childVNode = setupResult;
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
if (childVNode) {
|
|
1960
|
+
hydrateVNode(parent, childVNode);
|
|
1961
|
+
}
|
|
1962
|
+
return;
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
function hydrateChildVNode(parent, vnode, existingChildren, domIndex) {
|
|
1966
|
+
const { type, children } = vnode;
|
|
1967
|
+
if (type === Fragment) {
|
|
1968
|
+
if (isArray(children)) {
|
|
1969
|
+
for (let i = 0; i < children.length; i++) {
|
|
1970
|
+
const child = children[i];
|
|
1971
|
+
if (child != null) {
|
|
1972
|
+
domIndex = hydrateChildVNode(parent, child, existingChildren, domIndex);
|
|
1973
|
+
}
|
|
1974
|
+
}
|
|
1975
|
+
}
|
|
1976
|
+
return domIndex;
|
|
1977
|
+
}
|
|
1978
|
+
if (type === Text) {
|
|
1979
|
+
const text = isString(children) ? children : String(children ?? "");
|
|
1980
|
+
if (domIndex < existingChildren.length) {
|
|
1981
|
+
const existingNode = existingChildren[domIndex];
|
|
1982
|
+
if (!existingNode) {
|
|
1983
|
+
parent.appendChild(document.createTextNode(text));
|
|
1984
|
+
return domIndex + 1;
|
|
1985
|
+
}
|
|
1986
|
+
if (existingNode.nodeType === Node.TEXT_NODE) {
|
|
1987
|
+
if (existingNode.textContent !== text) {
|
|
1988
|
+
existingNode.textContent = text;
|
|
1989
|
+
}
|
|
1990
|
+
return domIndex + 1;
|
|
1991
|
+
}
|
|
1992
|
+
const textNode = document.createTextNode(text);
|
|
1993
|
+
parent.replaceChild(textNode, existingNode);
|
|
1994
|
+
return domIndex + 1;
|
|
1995
|
+
}
|
|
1996
|
+
parent.appendChild(document.createTextNode(text));
|
|
1997
|
+
return domIndex + 1;
|
|
1998
|
+
}
|
|
1999
|
+
if (typeof type === "string") {
|
|
2000
|
+
const tag = type.toLowerCase();
|
|
2001
|
+
vnodeToSimpleHTML(vnode);
|
|
2002
|
+
if (domIndex < existingChildren.length) {
|
|
2003
|
+
const existingNode = existingChildren[domIndex];
|
|
2004
|
+
if (!existingNode) {
|
|
2005
|
+
const newElement3 = createElementFromVNode(vnode);
|
|
2006
|
+
if (newElement3) {
|
|
2007
|
+
parent.appendChild(newElement3);
|
|
2008
|
+
}
|
|
2009
|
+
return domIndex + 1;
|
|
2010
|
+
}
|
|
2011
|
+
if (existingNode.nodeType === Node.ELEMENT_NODE) {
|
|
2012
|
+
const el = existingNode;
|
|
2013
|
+
if (el.tagName.toLowerCase() === tag) {
|
|
2014
|
+
hydrateAttributes(el, vnode);
|
|
2015
|
+
hydrateElementChildren(el, vnode);
|
|
2016
|
+
return domIndex + 1;
|
|
2017
|
+
}
|
|
2018
|
+
const newElement3 = createElementFromVNode(vnode);
|
|
2019
|
+
if (newElement3) {
|
|
2020
|
+
parent.replaceChild(newElement3, existingNode);
|
|
2021
|
+
}
|
|
2022
|
+
return domIndex + 1;
|
|
2023
|
+
}
|
|
2024
|
+
const newElement2 = createElementFromVNode(vnode);
|
|
2025
|
+
if (newElement2) {
|
|
2026
|
+
parent.replaceChild(newElement2, existingNode);
|
|
2027
|
+
}
|
|
2028
|
+
return domIndex + 1;
|
|
2029
|
+
}
|
|
2030
|
+
const newElement = createElementFromVNode(vnode);
|
|
2031
|
+
if (newElement) {
|
|
2032
|
+
parent.appendChild(newElement);
|
|
2033
|
+
}
|
|
2034
|
+
return domIndex + 1;
|
|
2035
|
+
}
|
|
2036
|
+
if (typeof type === "object" && type !== null) {
|
|
2037
|
+
const component = type;
|
|
2038
|
+
let childVNode;
|
|
2039
|
+
if (typeof component.render === "function") {
|
|
2040
|
+
const ctx = vnode.props ?? {};
|
|
2041
|
+
const result = component.render(ctx);
|
|
2042
|
+
if (result && typeof result === "object" && "type" in result) {
|
|
2043
|
+
childVNode = result;
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
if (!childVNode && typeof component.setup === "function") {
|
|
2047
|
+
const setupResult = component.setup(vnode.props ?? {});
|
|
2048
|
+
if (setupResult && typeof setupResult === "object" && "type" in setupResult) {
|
|
2049
|
+
childVNode = setupResult;
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
if (childVNode) {
|
|
2053
|
+
domIndex = hydrateChildVNode(parent, childVNode, existingChildren, domIndex);
|
|
2054
|
+
}
|
|
2055
|
+
return domIndex;
|
|
2056
|
+
}
|
|
2057
|
+
return domIndex;
|
|
2058
|
+
}
|
|
2059
|
+
function removeRemainingChildren(parent, existingChildren, domIndex) {
|
|
2060
|
+
for (let i = existingChildren.length - 1; i >= domIndex; i--) {
|
|
2061
|
+
const child = existingChildren[i];
|
|
2062
|
+
if (child) {
|
|
2063
|
+
parent.removeChild(child);
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
function hydrateAttributes(el, vnode) {
|
|
2068
|
+
const props = vnode.props ?? {};
|
|
2069
|
+
const vnodeKeys = /* @__PURE__ */ new Set();
|
|
2070
|
+
for (const key in props) {
|
|
2071
|
+
if (key === "key" || key === "ref") continue;
|
|
2072
|
+
vnodeKeys.add(key);
|
|
2073
|
+
const value = props[key];
|
|
2074
|
+
if (typeof value === "boolean") {
|
|
2075
|
+
if (value) {
|
|
2076
|
+
el.setAttribute(key, "");
|
|
2077
|
+
} else {
|
|
2078
|
+
el.removeAttribute(key);
|
|
2079
|
+
}
|
|
2080
|
+
} else if (value != null && value !== "") {
|
|
2081
|
+
el.setAttribute(key, String(value));
|
|
2082
|
+
} else {
|
|
2083
|
+
el.removeAttribute(key);
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
const existingAttrs = Array.from(el.attributes);
|
|
2087
|
+
for (const attr of existingAttrs) {
|
|
2088
|
+
if (!vnodeKeys.has(attr.name) && attr.name !== "data-island" && attr.name !== "data-props") {
|
|
2089
|
+
el.removeAttribute(attr.name);
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
function hydrateElementChildren(el, vnode) {
|
|
2094
|
+
const { children, shapeFlag } = vnode;
|
|
2095
|
+
if (shapeFlag != null && shapeFlag & ShapeFlags.TEXT_CHILDREN) {
|
|
2096
|
+
const text = isString(children) ? children : String(children ?? "");
|
|
2097
|
+
if (el.childNodes.length > 0) {
|
|
2098
|
+
const firstChild = el.firstChild;
|
|
2099
|
+
if (!firstChild) {
|
|
2100
|
+
el.appendChild(document.createTextNode(text));
|
|
2101
|
+
return;
|
|
2102
|
+
}
|
|
2103
|
+
if (firstChild.nodeType === Node.TEXT_NODE) {
|
|
2104
|
+
if (firstChild.textContent !== text) {
|
|
2105
|
+
firstChild.textContent = text;
|
|
2106
|
+
}
|
|
2107
|
+
while (el.childNodes.length > 1) {
|
|
2108
|
+
const lastChild = el.lastChild;
|
|
2109
|
+
if (lastChild) {
|
|
2110
|
+
el.removeChild(lastChild);
|
|
2111
|
+
} else {
|
|
2112
|
+
break;
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
} else {
|
|
2116
|
+
el.textContent = text;
|
|
2117
|
+
}
|
|
2118
|
+
} else {
|
|
2119
|
+
el.appendChild(document.createTextNode(text));
|
|
2120
|
+
}
|
|
2121
|
+
return;
|
|
2122
|
+
}
|
|
2123
|
+
if (isArray(children)) {
|
|
2124
|
+
const existingChildren = Array.from(el.childNodes);
|
|
2125
|
+
let domIndex = 0;
|
|
2126
|
+
for (let i = 0; i < children.length; i++) {
|
|
2127
|
+
const child = children[i];
|
|
2128
|
+
if (child != null) {
|
|
2129
|
+
domIndex = hydrateChildVNode(el, child, existingChildren, domIndex);
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
removeRemainingChildren(el, existingChildren, domIndex);
|
|
2133
|
+
return;
|
|
2134
|
+
}
|
|
2135
|
+
}
|
|
2136
|
+
function createElementFromVNode(vnode) {
|
|
2137
|
+
const type = vnode.type;
|
|
2138
|
+
if (typeof type !== "string") return null;
|
|
2139
|
+
const el = document.createElement(type);
|
|
2140
|
+
if (vnode.props) {
|
|
2141
|
+
for (const [key, value] of Object.entries(vnode.props)) {
|
|
2142
|
+
if (key === "children" || key === "key") continue;
|
|
2143
|
+
if (value != null) {
|
|
2144
|
+
el.setAttribute(key, String(value));
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
}
|
|
2148
|
+
if (vnode.children) {
|
|
2149
|
+
if (typeof vnode.children === "string") {
|
|
2150
|
+
el.textContent = vnode.children;
|
|
2151
|
+
} else if (Array.isArray(vnode.children)) {
|
|
2152
|
+
for (const child of vnode.children) {
|
|
2153
|
+
if (typeof child === "string") {
|
|
2154
|
+
el.appendChild(document.createTextNode(child));
|
|
2155
|
+
} else if (child && typeof child === "object" && "type" in child) {
|
|
2156
|
+
const childEl = createElementFromVNode(child);
|
|
2157
|
+
if (childEl) {
|
|
2158
|
+
el.appendChild(childEl);
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
}
|
|
2164
|
+
return el;
|
|
2165
|
+
}
|
|
2166
|
+
function vnodeToSimpleHTML(vnode) {
|
|
2167
|
+
const { type, children } = vnode;
|
|
2168
|
+
if (type === Fragment) {
|
|
2169
|
+
if (isArray(children)) {
|
|
2170
|
+
return children.map((child) => child != null ? vnodeToSimpleHTML(child) : "").join("");
|
|
2171
|
+
}
|
|
2172
|
+
return "";
|
|
2173
|
+
}
|
|
2174
|
+
if (type === Text) {
|
|
2175
|
+
const text = isString(children) ? children : String(children ?? "");
|
|
2176
|
+
return escapeHtml(text);
|
|
2177
|
+
}
|
|
2178
|
+
if (typeof type === "string") {
|
|
2179
|
+
const props = vnode.props ?? {};
|
|
2180
|
+
let attrs = "";
|
|
2181
|
+
for (const key in props) {
|
|
2182
|
+
if (key === "key" || key === "ref") continue;
|
|
2183
|
+
const value = props[key];
|
|
2184
|
+
if (typeof value === "boolean" && value) {
|
|
2185
|
+
attrs += ` ${key}`;
|
|
2186
|
+
} else if (value != null && value !== "") {
|
|
2187
|
+
attrs += ` ${key}="${escapeHtml(String(value))}"`;
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
const tag = type;
|
|
2191
|
+
let childContent = "";
|
|
2192
|
+
if (children != null) {
|
|
2193
|
+
if (isString(children)) {
|
|
2194
|
+
childContent = escapeHtml(children);
|
|
2195
|
+
} else if (isArray(children)) {
|
|
2196
|
+
childContent = children.map((child) => child != null ? vnodeToSimpleHTML(child) : "").join("");
|
|
2197
|
+
} else if (typeof children === "object" && "type" in children) {
|
|
2198
|
+
if (children != null && typeof children === "object" && "type" in children) {
|
|
2199
|
+
childContent = vnodeToSimpleHTML(children);
|
|
2200
|
+
}
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
return `<${tag}${attrs}>${childContent}</${tag}>`;
|
|
2204
|
+
}
|
|
2205
|
+
return "";
|
|
2206
|
+
}
|
|
2207
|
+
function uint8ToBase64(bytes) {
|
|
2208
|
+
const CHUNK_SIZE = 8192;
|
|
2209
|
+
const chunks = [];
|
|
2210
|
+
for (let i = 0; i < bytes.length; i += CHUNK_SIZE) {
|
|
2211
|
+
const chunk = bytes.subarray(i, Math.min(i + CHUNK_SIZE, bytes.length));
|
|
2212
|
+
chunks.push(String.fromCharCode(...chunk));
|
|
2213
|
+
}
|
|
2214
|
+
return btoa(chunks.join(""));
|
|
2215
|
+
}
|
|
2216
|
+
function base64ToUint8(base64) {
|
|
2217
|
+
const binary = atob(base64);
|
|
2218
|
+
const bytes = new Uint8Array(binary.length);
|
|
2219
|
+
for (let i = 0; i < binary.length; i++) {
|
|
2220
|
+
bytes[i] = binary.charCodeAt(i);
|
|
2221
|
+
}
|
|
2222
|
+
return bytes;
|
|
2223
|
+
}
|
|
2224
|
+
function encodeProps(props) {
|
|
2225
|
+
const json = JSON.stringify(props);
|
|
2226
|
+
const bytes = new TextEncoder().encode(json);
|
|
2227
|
+
return uint8ToBase64(bytes);
|
|
2228
|
+
}
|
|
2229
|
+
function decodeProps(encoded) {
|
|
2230
|
+
if (!encoded) return {};
|
|
2231
|
+
try {
|
|
2232
|
+
const bytes = base64ToUint8(encoded);
|
|
2233
|
+
const json = new TextDecoder().decode(bytes);
|
|
2234
|
+
return JSON.parse(json);
|
|
2235
|
+
} catch {
|
|
2236
|
+
return {};
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
var islandRegistry;
|
|
2240
|
+
var init_ssr_island = __esm({
|
|
2241
|
+
"src/ssr/ssr-island.ts"() {
|
|
2242
|
+
init_utils();
|
|
2243
|
+
islandRegistry = /* @__PURE__ */ new Map();
|
|
2244
|
+
}
|
|
2245
|
+
});
|
|
2246
|
+
|
|
2247
|
+
// src/vapor/vapor-app.ts
|
|
2248
|
+
var vapor_app_exports = {};
|
|
2249
|
+
__export(vapor_app_exports, {
|
|
2250
|
+
createVaporApp: () => createVaporApp,
|
|
2251
|
+
defineVaporComponent: () => defineVaporComponent
|
|
2252
|
+
});
|
|
2253
|
+
function defineVaporComponent(options) {
|
|
2254
|
+
const { name, props, setup, template } = options;
|
|
2255
|
+
let compiledCode;
|
|
2256
|
+
try {
|
|
2257
|
+
const compileResult = compile(template, { rendererMode: "signal" });
|
|
2258
|
+
compiledCode = compileResult.code;
|
|
2259
|
+
} catch (e) {
|
|
2260
|
+
{
|
|
2261
|
+
console.error(
|
|
2262
|
+
`[LytJS] defineVaporComponent: template compilation failed for "${name || "anonymous"}". Error: ${e instanceof Error ? e.message : String(e)}`
|
|
2263
|
+
);
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
return {
|
|
2267
|
+
name,
|
|
2268
|
+
props,
|
|
2269
|
+
setup,
|
|
2270
|
+
template,
|
|
2271
|
+
compiledCode
|
|
2272
|
+
};
|
|
2273
|
+
}
|
|
2274
|
+
function createVaporApp(rootComponent, options) {
|
|
2275
|
+
const provides = /* @__PURE__ */ new Map();
|
|
2276
|
+
const components = /* @__PURE__ */ new Map();
|
|
2277
|
+
let signalRenderer = null;
|
|
2278
|
+
let isMounted = false;
|
|
2279
|
+
let isUnmounted = false;
|
|
2280
|
+
const componentId = generateComponentId();
|
|
2281
|
+
const vaporApp = {
|
|
2282
|
+
mount(container) {
|
|
2283
|
+
if (isUnmounted) {
|
|
2284
|
+
throw new Error(
|
|
2285
|
+
`[LytJS] VaporApp has been unmounted and cannot be remounted. Create a new app instance instead.`
|
|
2286
|
+
);
|
|
2287
|
+
}
|
|
2288
|
+
if (isMounted) {
|
|
2289
|
+
throw new Error(
|
|
2290
|
+
`[LytJS] VaporApp is already mounted. Call app.unmount() first before mounting again.`
|
|
2291
|
+
);
|
|
2292
|
+
}
|
|
2293
|
+
const el = typeof container === "string" ? document.querySelector(container) : container;
|
|
2294
|
+
if (!el) {
|
|
2295
|
+
throw new Error(`[LytJS] VaporApp: cannot find element matching "${container}".`);
|
|
2296
|
+
}
|
|
2297
|
+
const rootProps = options?.rootProps ?? {};
|
|
2298
|
+
const ctx = { ...rootProps };
|
|
2299
|
+
const vaporContext = {
|
|
2300
|
+
attrs: { ...rootProps },
|
|
2301
|
+
slots: {},
|
|
2302
|
+
emit(event, ...args) {
|
|
2303
|
+
}
|
|
2304
|
+
};
|
|
2305
|
+
if (typeof rootComponent.setup === "function") {
|
|
2306
|
+
const setupResult = rootComponent.setup(rootProps, vaporContext);
|
|
2307
|
+
if (setupResult && typeof setupResult === "object") {
|
|
2308
|
+
Object.assign(ctx, setupResult);
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
if (!rootComponent.template) {
|
|
2312
|
+
throw new Error(
|
|
2313
|
+
`[LytJS] createVaporApp: rootComponent must have a 'template' property. Received: ${typeof rootComponent.template}`
|
|
2314
|
+
);
|
|
2315
|
+
}
|
|
2316
|
+
signalRenderer = createSignalRenderer(rootComponent.template, ctx);
|
|
2317
|
+
signalRenderer.render(el);
|
|
2318
|
+
if (isHMRAvailable()) {
|
|
2319
|
+
registerComponent(componentId, rootComponent, el);
|
|
2320
|
+
}
|
|
2321
|
+
isMounted = true;
|
|
2322
|
+
},
|
|
2323
|
+
unmount() {
|
|
2324
|
+
if (signalRenderer) {
|
|
2325
|
+
signalRenderer.unmount();
|
|
2326
|
+
signalRenderer = null;
|
|
2327
|
+
}
|
|
2328
|
+
if (isHMRAvailable()) {
|
|
2329
|
+
unregisterComponent(componentId);
|
|
2330
|
+
}
|
|
2331
|
+
isMounted = false;
|
|
2332
|
+
isUnmounted = true;
|
|
2333
|
+
provides.clear();
|
|
2334
|
+
components.clear();
|
|
2335
|
+
},
|
|
2336
|
+
provide(key, value) {
|
|
2337
|
+
provides.set(key, value);
|
|
2338
|
+
},
|
|
2339
|
+
component(name, component) {
|
|
2340
|
+
components.set(name, component);
|
|
2341
|
+
return vaporApp;
|
|
2342
|
+
}
|
|
2343
|
+
};
|
|
2344
|
+
return vaporApp;
|
|
2345
|
+
}
|
|
2346
|
+
var init_vapor_app = __esm({
|
|
2347
|
+
"src/vapor/vapor-app.ts"() {
|
|
2348
|
+
init_signal_renderer();
|
|
2349
|
+
init_vapor_hmr();
|
|
2350
|
+
}
|
|
2351
|
+
});
|
|
2352
|
+
|
|
2353
|
+
// src/server/server-components.ts
|
|
2354
|
+
var server_components_exports = {};
|
|
2355
|
+
__export(server_components_exports, {
|
|
2356
|
+
createServerActionHandler: () => createServerActionHandler,
|
|
2357
|
+
defineServerComponent: () => defineServerComponent,
|
|
2358
|
+
deserializeServerData: () => deserializeServerData,
|
|
2359
|
+
getServerComponent: () => getServerComponent,
|
|
2360
|
+
getServerFunction: () => getServerFunction,
|
|
2361
|
+
handleServerAction: () => handleServerAction,
|
|
2362
|
+
registerServerComponent: () => registerServerComponent,
|
|
2363
|
+
registerServerFunction: () => registerServerFunction,
|
|
2364
|
+
renderServerComponent: () => renderServerComponent,
|
|
2365
|
+
serializeServerData: () => serializeServerData
|
|
2366
|
+
});
|
|
2367
|
+
function registerServerComponent(component) {
|
|
2368
|
+
registry.components.set(component.id, component);
|
|
2369
|
+
}
|
|
2370
|
+
function registerServerFunction(componentId, functionName, fn) {
|
|
2371
|
+
if (!registry.functions.has(componentId)) {
|
|
2372
|
+
registry.functions.set(componentId, /* @__PURE__ */ new Map());
|
|
2373
|
+
}
|
|
2374
|
+
registry.functions.get(componentId).set(functionName, fn);
|
|
2375
|
+
}
|
|
2376
|
+
function getServerComponent(id) {
|
|
2377
|
+
return registry.components.get(id);
|
|
2378
|
+
}
|
|
2379
|
+
function getServerFunction(componentId, functionName) {
|
|
2380
|
+
return registry.functions.get(componentId)?.get(functionName);
|
|
2381
|
+
}
|
|
2382
|
+
async function handleServerAction(request) {
|
|
2383
|
+
const { componentName, functionName, args } = request;
|
|
2384
|
+
try {
|
|
2385
|
+
const fn = getServerFunction(componentName, functionName);
|
|
2386
|
+
if (!fn) {
|
|
2387
|
+
return {
|
|
2388
|
+
success: false,
|
|
2389
|
+
error: `Server function not found: ${componentName}.${functionName}`
|
|
2390
|
+
};
|
|
2391
|
+
}
|
|
2392
|
+
const result = await fn(...args);
|
|
2393
|
+
return {
|
|
2394
|
+
success: true,
|
|
2395
|
+
data: result
|
|
2396
|
+
};
|
|
2397
|
+
} catch (error2) {
|
|
2398
|
+
console.error(`[LytJS Server Action Error] ${componentName}.${functionName}:`, error2);
|
|
2399
|
+
return {
|
|
2400
|
+
success: false,
|
|
2401
|
+
error: error2 instanceof Error ? error2.message : String(error2)
|
|
2402
|
+
};
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
function createServerActionHandler() {
|
|
2406
|
+
return async (req, res) => {
|
|
2407
|
+
const componentName = req.headers["x-server-component"];
|
|
2408
|
+
const functionName = req.headers["x-server-function"];
|
|
2409
|
+
if (!componentName || !functionName) {
|
|
2410
|
+
res.status(400).json({ error: "Missing server component or function headers" });
|
|
2411
|
+
return;
|
|
2412
|
+
}
|
|
2413
|
+
const args = req.body?.args || [];
|
|
2414
|
+
const result = await handleServerAction({
|
|
2415
|
+
componentName,
|
|
2416
|
+
functionName,
|
|
2417
|
+
args
|
|
2418
|
+
});
|
|
2419
|
+
if (result.success) {
|
|
2420
|
+
res.json(result.data);
|
|
2421
|
+
} else {
|
|
2422
|
+
res.status(500).json({ error: result.error });
|
|
2423
|
+
}
|
|
2424
|
+
};
|
|
2425
|
+
}
|
|
2426
|
+
function serializeServerData(data) {
|
|
2427
|
+
return JSON.stringify(data, (_key, value) => {
|
|
2428
|
+
if (value instanceof Date) {
|
|
2429
|
+
return { __type: "Date", value: value.toISOString() };
|
|
2430
|
+
}
|
|
2431
|
+
if (value instanceof Map) {
|
|
2432
|
+
return { __type: "Map", value: Array.from(value.entries()) };
|
|
2433
|
+
}
|
|
2434
|
+
if (value instanceof Set) {
|
|
2435
|
+
return { __type: "Set", value: Array.from(value.values()) };
|
|
2436
|
+
}
|
|
2437
|
+
if (typeof value === "bigint") {
|
|
2438
|
+
return { __type: "BigInt", value: value.toString() };
|
|
2439
|
+
}
|
|
2440
|
+
if (value === void 0) {
|
|
2441
|
+
return { __type: "undefined" };
|
|
2442
|
+
}
|
|
2443
|
+
return value;
|
|
2444
|
+
});
|
|
2445
|
+
}
|
|
2446
|
+
function deserializeServerData(json) {
|
|
2447
|
+
return JSON.parse(json, (_key, value) => {
|
|
2448
|
+
if (value && typeof value === "object" && "__type" in value) {
|
|
2449
|
+
switch (value.__type) {
|
|
2450
|
+
case "Date":
|
|
2451
|
+
return new Date(value.value);
|
|
2452
|
+
case "Map":
|
|
2453
|
+
return new Map(value.value);
|
|
2454
|
+
case "Set":
|
|
2455
|
+
return new Set(value.value);
|
|
2456
|
+
case "BigInt":
|
|
2457
|
+
return BigInt(value.value);
|
|
2458
|
+
case "undefined":
|
|
2459
|
+
return void 0;
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
return value;
|
|
2463
|
+
});
|
|
2464
|
+
}
|
|
2465
|
+
async function renderServerComponent(componentId, _context = {}) {
|
|
2466
|
+
const component = getServerComponent(componentId);
|
|
2467
|
+
if (!component) {
|
|
2468
|
+
throw new Error(`[LytJS] Server component not found: ${componentId}`);
|
|
2469
|
+
}
|
|
2470
|
+
if (component.fetchData) {
|
|
2471
|
+
await component.fetchData();
|
|
2472
|
+
}
|
|
2473
|
+
const html = await component.render();
|
|
2474
|
+
const dataScript = component.serializeData ? `<script>window.__LYTJS_SERVER_DATA__=${component.serializeData()};</script>` : "";
|
|
2475
|
+
return html + dataScript;
|
|
2476
|
+
}
|
|
2477
|
+
function defineServerComponent(options) {
|
|
2478
|
+
const component = {
|
|
2479
|
+
...options,
|
|
2480
|
+
serializeData: options.serializeData ?? (() => serializeServerData({}))
|
|
2481
|
+
};
|
|
2482
|
+
registerServerComponent(component);
|
|
2483
|
+
return component;
|
|
2484
|
+
}
|
|
2485
|
+
var registry;
|
|
2486
|
+
var init_server_components = __esm({
|
|
2487
|
+
"src/server/server-components.ts"() {
|
|
2488
|
+
registry = {
|
|
2489
|
+
components: /* @__PURE__ */ new Map(),
|
|
2490
|
+
functions: /* @__PURE__ */ new Map()
|
|
2491
|
+
};
|
|
2492
|
+
}
|
|
2493
|
+
});
|
|
2494
|
+
|
|
2495
|
+
// src/client/server-components-client.ts
|
|
2496
|
+
var server_components_client_exports = {};
|
|
2497
|
+
__export(server_components_client_exports, {
|
|
2498
|
+
autoHydrate: () => autoHydrate,
|
|
2499
|
+
callServer: () => callServer,
|
|
2500
|
+
configureServerAction: () => configureServerAction,
|
|
2501
|
+
createServerFunction: () => createServerFunction,
|
|
2502
|
+
getHydrationState: () => getHydrationState,
|
|
2503
|
+
getServerData: () => getServerData,
|
|
2504
|
+
hasServerData: () => hasServerData,
|
|
2505
|
+
isHydrated: () => isHydrated,
|
|
2506
|
+
markHydrated: () => markHydrated
|
|
2507
|
+
});
|
|
2508
|
+
function configureServerAction(config) {
|
|
2509
|
+
defaultConfig = { ...defaultConfig, ...config };
|
|
2510
|
+
}
|
|
2511
|
+
async function callServer(componentName, functionName, ...args) {
|
|
2512
|
+
const { endpoint, headers, onError } = defaultConfig;
|
|
2513
|
+
try {
|
|
2514
|
+
const response = await fetch(endpoint, {
|
|
2515
|
+
method: "POST",
|
|
2516
|
+
headers: {
|
|
2517
|
+
"Content-Type": "application/json",
|
|
2518
|
+
"X-Server-Component": componentName,
|
|
2519
|
+
"X-Server-Function": functionName,
|
|
2520
|
+
...headers
|
|
2521
|
+
},
|
|
2522
|
+
body: JSON.stringify({ args })
|
|
2523
|
+
});
|
|
2524
|
+
if (!response.ok) {
|
|
2525
|
+
throw new Error(
|
|
2526
|
+
`Server action failed: ${response.status} ${response.statusText}`
|
|
2527
|
+
);
|
|
2528
|
+
}
|
|
2529
|
+
const result = await response.json();
|
|
2530
|
+
return result;
|
|
2531
|
+
} catch (error2) {
|
|
2532
|
+
const err = error2 instanceof Error ? error2 : new Error(String(error2));
|
|
2533
|
+
onError?.(err);
|
|
2534
|
+
throw err;
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
function createServerFunction(componentName, functionName) {
|
|
2538
|
+
return (...args) => callServer(componentName, functionName, ...args);
|
|
2539
|
+
}
|
|
2540
|
+
function getServerData(key) {
|
|
2541
|
+
const serverData = window.__LYTJS_SERVER_DATA__;
|
|
2542
|
+
if (!serverData) return void 0;
|
|
2543
|
+
if (key) {
|
|
2544
|
+
return serverData[key];
|
|
2545
|
+
}
|
|
2546
|
+
return serverData;
|
|
2547
|
+
}
|
|
2548
|
+
function hasServerData() {
|
|
2549
|
+
return !!window.__LYTJS_SERVER_DATA__;
|
|
2550
|
+
}
|
|
2551
|
+
function isHydrated(componentId) {
|
|
2552
|
+
return hydrationState.get(componentId)?.hydrated ?? false;
|
|
2553
|
+
}
|
|
2554
|
+
function markHydrated(componentId) {
|
|
2555
|
+
hydrationState.set(componentId, {
|
|
2556
|
+
hydrated: true,
|
|
2557
|
+
pending: false,
|
|
2558
|
+
error: null
|
|
2559
|
+
});
|
|
2560
|
+
}
|
|
2561
|
+
function getHydrationState(componentId) {
|
|
2562
|
+
return hydrationState.get(componentId) ?? {
|
|
2563
|
+
hydrated: false,
|
|
2564
|
+
pending: false,
|
|
2565
|
+
error: null
|
|
2566
|
+
};
|
|
2567
|
+
}
|
|
2568
|
+
async function autoHydrate() {
|
|
2569
|
+
const elements = document.querySelectorAll("[data-server-component]");
|
|
2570
|
+
for (const el of elements) {
|
|
2571
|
+
const componentId = el.getAttribute("data-server-component");
|
|
2572
|
+
if (!componentId) continue;
|
|
2573
|
+
if (isHydrated(componentId)) continue;
|
|
2574
|
+
hydrationState.set(componentId, {
|
|
2575
|
+
hydrated: false,
|
|
2576
|
+
pending: true,
|
|
2577
|
+
error: null
|
|
2578
|
+
});
|
|
2579
|
+
try {
|
|
2580
|
+
const module = await import(
|
|
2581
|
+
/* @vite-ignore */
|
|
2582
|
+
`/components/${componentId}.client.js`
|
|
2583
|
+
);
|
|
2584
|
+
if (module.default && typeof module.default.hydrate === "function") {
|
|
2585
|
+
await module.default.hydrate(el);
|
|
2586
|
+
}
|
|
2587
|
+
markHydrated(componentId);
|
|
2588
|
+
} catch (error2) {
|
|
2589
|
+
hydrationState.set(componentId, {
|
|
2590
|
+
hydrated: false,
|
|
2591
|
+
pending: false,
|
|
2592
|
+
error: error2 instanceof Error ? error2 : new Error(String(error2))
|
|
2593
|
+
});
|
|
2594
|
+
console.error(`[LytJS] Failed to hydrate ${componentId}:`, error2);
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
var defaultConfig, hydrationState;
|
|
2599
|
+
var init_server_components_client = __esm({
|
|
2600
|
+
"src/client/server-components-client.ts"() {
|
|
2601
|
+
defaultConfig = {
|
|
2602
|
+
endpoint: "/__lytjs_server_action",
|
|
2603
|
+
headers: {},
|
|
2604
|
+
onError: (error2) => console.error("[LytJS Server Action Error]", error2)
|
|
2605
|
+
};
|
|
2606
|
+
hydrationState = /* @__PURE__ */ new Map();
|
|
2607
|
+
if (typeof document !== "undefined" && document.readyState === "complete") {
|
|
2608
|
+
autoHydrate();
|
|
2609
|
+
} else if (typeof document !== "undefined") {
|
|
2610
|
+
document.addEventListener("DOMContentLoaded", autoHydrate);
|
|
2611
|
+
}
|
|
2612
|
+
}
|
|
2613
|
+
});
|
|
2614
|
+
|
|
2615
|
+
// src/data/data-fetching.ts
|
|
2616
|
+
var data_fetching_exports = {};
|
|
2617
|
+
__export(data_fetching_exports, {
|
|
2618
|
+
createPrefetchManager: () => createPrefetchManager,
|
|
2619
|
+
deserializeData: () => deserializeData,
|
|
2620
|
+
getPrefetchData: () => getPrefetchData,
|
|
2621
|
+
injectPrefetchData: () => injectPrefetchData,
|
|
2622
|
+
serializeData: () => serializeData,
|
|
2623
|
+
useAsyncData: () => useAsyncData,
|
|
2624
|
+
useFetch: () => useFetch
|
|
2625
|
+
});
|
|
2626
|
+
function serializeData(data) {
|
|
2627
|
+
return JSON.stringify(data, (_key, value) => {
|
|
2628
|
+
if (value instanceof Date) {
|
|
2629
|
+
return { __type: "Date", __value: value.toISOString() };
|
|
2630
|
+
}
|
|
2631
|
+
if (value instanceof Map) {
|
|
2632
|
+
return { __type: "Map", __value: Array.from(value.entries()) };
|
|
2633
|
+
}
|
|
2634
|
+
if (value instanceof Set) {
|
|
2635
|
+
return { __type: "Set", __value: Array.from(value.values()) };
|
|
2636
|
+
}
|
|
2637
|
+
if (typeof value === "bigint") {
|
|
2638
|
+
return { __type: "BigInt", __value: value.toString() };
|
|
2639
|
+
}
|
|
2640
|
+
if (value === void 0) {
|
|
2641
|
+
return { __type: "undefined" };
|
|
2642
|
+
}
|
|
2643
|
+
if (value instanceof Error) {
|
|
2644
|
+
return {
|
|
2645
|
+
__type: "Error",
|
|
2646
|
+
__value: {
|
|
2647
|
+
name: value.name,
|
|
2648
|
+
message: value.message,
|
|
2649
|
+
stack: value.stack
|
|
2650
|
+
}
|
|
2651
|
+
};
|
|
2652
|
+
}
|
|
2653
|
+
if (value instanceof RegExp) {
|
|
2654
|
+
return { __type: "RegExp", __value: value.toString() };
|
|
2655
|
+
}
|
|
2656
|
+
return value;
|
|
2657
|
+
});
|
|
2658
|
+
}
|
|
2659
|
+
function deserializeData(json) {
|
|
2660
|
+
return JSON.parse(json, (_key, value) => {
|
|
2661
|
+
if (value && typeof value === "object" && "__type" in value) {
|
|
2662
|
+
switch (value.__type) {
|
|
2663
|
+
case "Date":
|
|
2664
|
+
return new Date(value.__value);
|
|
2665
|
+
case "Map":
|
|
2666
|
+
return new Map(value.__value);
|
|
2667
|
+
case "Set":
|
|
2668
|
+
return new Set(value.__value);
|
|
2669
|
+
case "BigInt":
|
|
2670
|
+
return BigInt(value.__value);
|
|
2671
|
+
case "undefined":
|
|
2672
|
+
return void 0;
|
|
2673
|
+
case "Error": {
|
|
2674
|
+
const err = new Error(value.__value.message);
|
|
2675
|
+
err.name = value.__value.name;
|
|
2676
|
+
err.stack = value.__value.stack;
|
|
2677
|
+
return err;
|
|
2678
|
+
}
|
|
2679
|
+
case "RegExp": {
|
|
2680
|
+
const match = value.__value.match(/^\/(.*)\/([gimsuy]*)$/);
|
|
2681
|
+
if (match) {
|
|
2682
|
+
return new RegExp(match[1], match[2]);
|
|
2683
|
+
}
|
|
2684
|
+
return new RegExp(value.__value);
|
|
2685
|
+
}
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
return value;
|
|
2689
|
+
});
|
|
2690
|
+
}
|
|
2691
|
+
function createPrefetchManager() {
|
|
2692
|
+
return {
|
|
2693
|
+
async prefetch(key, fetcher) {
|
|
2694
|
+
const cached = prefetchStore.get(key);
|
|
2695
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
2696
|
+
return cached.data;
|
|
2697
|
+
}
|
|
2698
|
+
const pending = pendingPrefetches.get(key);
|
|
2699
|
+
if (pending) {
|
|
2700
|
+
return pending;
|
|
2701
|
+
}
|
|
2702
|
+
const fetchPromise = fetcher();
|
|
2703
|
+
pendingPrefetches.set(key, fetchPromise);
|
|
2704
|
+
try {
|
|
2705
|
+
const data = await fetchPromise;
|
|
2706
|
+
const now = Date.now();
|
|
2707
|
+
prefetchStore.set(key, {
|
|
2708
|
+
key,
|
|
2709
|
+
data,
|
|
2710
|
+
timestamp: now,
|
|
2711
|
+
expiresAt: now + 5 * 60 * 1e3
|
|
2712
|
+
// 默认 5 分钟过期
|
|
2713
|
+
});
|
|
2714
|
+
return data;
|
|
2715
|
+
} finally {
|
|
2716
|
+
pendingPrefetches.delete(key);
|
|
2717
|
+
}
|
|
2718
|
+
},
|
|
2719
|
+
getPrefetchedData(key) {
|
|
2720
|
+
const entry = prefetchStore.get(key);
|
|
2721
|
+
if (entry && entry.expiresAt > Date.now()) {
|
|
2722
|
+
return entry.data;
|
|
2723
|
+
}
|
|
2724
|
+
return void 0;
|
|
2725
|
+
},
|
|
2726
|
+
serialize() {
|
|
2727
|
+
const entries = Array.from(prefetchStore.values());
|
|
2728
|
+
return serializeData(entries);
|
|
2729
|
+
},
|
|
2730
|
+
deserialize(data) {
|
|
2731
|
+
const entries = deserializeData(data);
|
|
2732
|
+
if (isArray(entries)) {
|
|
2733
|
+
for (const entry of entries) {
|
|
2734
|
+
prefetchStore.set(entry.key, entry);
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
},
|
|
2738
|
+
clear() {
|
|
2739
|
+
prefetchStore.clear();
|
|
2740
|
+
pendingPrefetches.clear();
|
|
2741
|
+
}
|
|
2742
|
+
};
|
|
2743
|
+
}
|
|
2744
|
+
function useFetch(url, options = {}) {
|
|
2745
|
+
const {
|
|
2746
|
+
immediate = true,
|
|
2747
|
+
initialData,
|
|
2748
|
+
cacheKey,
|
|
2749
|
+
cacheTime = 5 * 60 * 1e3,
|
|
2750
|
+
watch: watchDeps,
|
|
2751
|
+
transform,
|
|
2752
|
+
onError,
|
|
2753
|
+
onSuccess,
|
|
2754
|
+
retry = 0,
|
|
2755
|
+
retryDelay = 1e3
|
|
2756
|
+
} = options;
|
|
2757
|
+
const data = ref(initialData);
|
|
2758
|
+
const loading = ref(false);
|
|
2759
|
+
const error2 = ref(null);
|
|
2760
|
+
const fromCache = ref(false);
|
|
2761
|
+
const timestamp = ref(null);
|
|
2762
|
+
let retryCount = 0;
|
|
2763
|
+
const fetchData = async () => {
|
|
2764
|
+
const resolvedUrl = typeof url === "function" ? url() : url;
|
|
2765
|
+
const resolvedCacheKey = typeof cacheKey === "function" ? cacheKey() : cacheKey;
|
|
2766
|
+
if (resolvedCacheKey) {
|
|
2767
|
+
const cached = prefetchStore.get(resolvedCacheKey);
|
|
2768
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
2769
|
+
data.value = cached.data;
|
|
2770
|
+
fromCache.value = true;
|
|
2771
|
+
timestamp.value = cached.timestamp;
|
|
2772
|
+
return;
|
|
2773
|
+
}
|
|
2774
|
+
if (typeof window !== "undefined") {
|
|
2775
|
+
const serverData = window.__LYTJS_PREFETCH_DATA__;
|
|
2776
|
+
if (serverData && serverData[resolvedCacheKey]) {
|
|
2777
|
+
data.value = serverData[resolvedCacheKey];
|
|
2778
|
+
fromCache.value = true;
|
|
2779
|
+
delete serverData[resolvedCacheKey];
|
|
2780
|
+
return;
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2784
|
+
loading.value = true;
|
|
2785
|
+
error2.value = null;
|
|
2786
|
+
try {
|
|
2787
|
+
const response = await fetch(resolvedUrl);
|
|
2788
|
+
if (!response.ok) {
|
|
2789
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
|
2790
|
+
}
|
|
2791
|
+
let result = await response.json();
|
|
2792
|
+
if (transform) {
|
|
2793
|
+
result = transform(result);
|
|
2794
|
+
}
|
|
2795
|
+
data.value = result;
|
|
2796
|
+
timestamp.value = Date.now();
|
|
2797
|
+
retryCount = 0;
|
|
2798
|
+
if (resolvedCacheKey) {
|
|
2799
|
+
prefetchStore.set(resolvedCacheKey, {
|
|
2800
|
+
key: resolvedCacheKey,
|
|
2801
|
+
data: result,
|
|
2802
|
+
timestamp: timestamp.value,
|
|
2803
|
+
expiresAt: timestamp.value + cacheTime
|
|
2804
|
+
});
|
|
2805
|
+
}
|
|
2806
|
+
onSuccess?.(result);
|
|
2807
|
+
} catch (err) {
|
|
2808
|
+
const fetchError = err instanceof Error ? err : new Error(String(err));
|
|
2809
|
+
error2.value = fetchError;
|
|
2810
|
+
if (retryCount < retry) {
|
|
2811
|
+
retryCount++;
|
|
2812
|
+
setTimeout(fetchData, retryDelay);
|
|
2813
|
+
return;
|
|
2814
|
+
}
|
|
2815
|
+
onError?.(fetchError);
|
|
2816
|
+
} finally {
|
|
2817
|
+
loading.value = false;
|
|
2818
|
+
}
|
|
2819
|
+
};
|
|
2820
|
+
if (watchDeps && watchDeps.length > 0) {
|
|
2821
|
+
watch(watchDeps, () => {
|
|
2822
|
+
fetchData();
|
|
2823
|
+
});
|
|
2824
|
+
}
|
|
2825
|
+
if (immediate) {
|
|
2826
|
+
fetchData();
|
|
2827
|
+
}
|
|
2828
|
+
return {
|
|
2829
|
+
data,
|
|
2830
|
+
loading,
|
|
2831
|
+
error: error2,
|
|
2832
|
+
refetch: fetchData
|
|
2833
|
+
};
|
|
2834
|
+
}
|
|
2835
|
+
function useAsyncData(key, fetcher, options = {}) {
|
|
2836
|
+
const {
|
|
2837
|
+
immediate = true,
|
|
2838
|
+
initialData,
|
|
2839
|
+
transform,
|
|
2840
|
+
onError,
|
|
2841
|
+
onSuccess
|
|
2842
|
+
} = options;
|
|
2843
|
+
const data = ref(initialData);
|
|
2844
|
+
const pending = ref(false);
|
|
2845
|
+
const error2 = ref(null);
|
|
2846
|
+
const execute = async () => {
|
|
2847
|
+
const cached = prefetchStore.get(key);
|
|
2848
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
2849
|
+
data.value = cached.data;
|
|
2850
|
+
return;
|
|
2851
|
+
}
|
|
2852
|
+
if (typeof window !== "undefined") {
|
|
2853
|
+
const serverData = window.__LYTJS_PREFETCH_DATA__;
|
|
2854
|
+
if (serverData && serverData[key]) {
|
|
2855
|
+
data.value = serverData[key];
|
|
2856
|
+
delete serverData[key];
|
|
2857
|
+
return;
|
|
2858
|
+
}
|
|
2859
|
+
}
|
|
2860
|
+
pending.value = true;
|
|
2861
|
+
error2.value = null;
|
|
2862
|
+
try {
|
|
2863
|
+
let result = await fetcher();
|
|
2864
|
+
if (transform) {
|
|
2865
|
+
result = transform(result);
|
|
2866
|
+
}
|
|
2867
|
+
data.value = result;
|
|
2868
|
+
const now = Date.now();
|
|
2869
|
+
prefetchStore.set(key, {
|
|
2870
|
+
key,
|
|
2871
|
+
data: result,
|
|
2872
|
+
timestamp: now,
|
|
2873
|
+
expiresAt: now + (options.cacheTime || 5 * 60 * 1e3)
|
|
2874
|
+
});
|
|
2875
|
+
onSuccess?.(result);
|
|
2876
|
+
} catch (err) {
|
|
2877
|
+
const fetchError = err instanceof Error ? err : new Error(String(err));
|
|
2878
|
+
error2.value = fetchError;
|
|
2879
|
+
onError?.(fetchError);
|
|
2880
|
+
} finally {
|
|
2881
|
+
pending.value = false;
|
|
2882
|
+
}
|
|
2883
|
+
};
|
|
2884
|
+
if (immediate) {
|
|
2885
|
+
execute();
|
|
2886
|
+
}
|
|
2887
|
+
return {
|
|
2888
|
+
data,
|
|
2889
|
+
pending,
|
|
2890
|
+
error: error2,
|
|
2891
|
+
refresh: execute
|
|
2892
|
+
};
|
|
2893
|
+
}
|
|
2894
|
+
function injectPrefetchData() {
|
|
2895
|
+
const data = {};
|
|
2896
|
+
for (const [key, entry] of prefetchStore) {
|
|
2897
|
+
data[key] = entry.data;
|
|
2898
|
+
}
|
|
2899
|
+
if (Object.keys(data).length === 0) {
|
|
2900
|
+
return "";
|
|
2901
|
+
}
|
|
2902
|
+
return `<script>window.__LYTJS_PREFETCH_DATA__=${serializeData(data)};</script>`;
|
|
2903
|
+
}
|
|
2904
|
+
function getPrefetchData(key) {
|
|
2905
|
+
const cached = prefetchStore.get(key);
|
|
2906
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
2907
|
+
return cached.data;
|
|
2908
|
+
}
|
|
2909
|
+
if (typeof window !== "undefined") {
|
|
2910
|
+
const serverData = window.__LYTJS_PREFETCH_DATA__;
|
|
2911
|
+
if (serverData && serverData[key]) {
|
|
2912
|
+
const data = serverData[key];
|
|
2913
|
+
delete serverData[key];
|
|
2914
|
+
return data;
|
|
2915
|
+
}
|
|
2916
|
+
}
|
|
2917
|
+
return void 0;
|
|
2918
|
+
}
|
|
2919
|
+
var prefetchStore, pendingPrefetches;
|
|
2920
|
+
var init_data_fetching = __esm({
|
|
2921
|
+
"src/data/data-fetching.ts"() {
|
|
2922
|
+
prefetchStore = /* @__PURE__ */ new Map();
|
|
2923
|
+
pendingPrefetches = /* @__PURE__ */ new Map();
|
|
2924
|
+
}
|
|
2925
|
+
});
|
|
2926
|
+
|
|
2927
|
+
// src/index.ts
|
|
2928
|
+
init_enhanced_hydration();
|
|
2929
|
+
init_ssr_stream_optimized();
|
|
2930
|
+
init_vapor_hmr();
|
|
2931
|
+
init_vapor_ssr();
|
|
2932
|
+
|
|
2933
|
+
// src/unmount.ts
|
|
2934
|
+
var eventListenerRegistry = /* @__PURE__ */ new WeakMap();
|
|
2935
|
+
var effectSubscriptionRegistry = /* @__PURE__ */ new WeakMap();
|
|
2936
|
+
var cleanupHookRegistry = /* @__PURE__ */ new WeakMap();
|
|
2937
|
+
function registerComponentEventListener(component, el, event, handler, options) {
|
|
2938
|
+
let listeners = eventListenerRegistry.get(component);
|
|
2939
|
+
if (!listeners) {
|
|
2940
|
+
listeners = [];
|
|
2941
|
+
eventListenerRegistry.set(component, listeners);
|
|
2942
|
+
}
|
|
2943
|
+
listeners.push({ el, event, handler, options });
|
|
2944
|
+
}
|
|
2945
|
+
function registerComponentEffectSubscription(component, dispose) {
|
|
2946
|
+
let subscriptions = effectSubscriptionRegistry.get(component);
|
|
2947
|
+
if (!subscriptions) {
|
|
2948
|
+
subscriptions = [];
|
|
2949
|
+
effectSubscriptionRegistry.set(component, subscriptions);
|
|
2950
|
+
}
|
|
2951
|
+
subscriptions.push(dispose);
|
|
2952
|
+
}
|
|
2953
|
+
function registerComponentCleanup(component, cleanup) {
|
|
2954
|
+
let cleanups = cleanupHookRegistry.get(component);
|
|
2955
|
+
if (!cleanups) {
|
|
2956
|
+
cleanups = [];
|
|
2957
|
+
cleanupHookRegistry.set(component, cleanups);
|
|
2958
|
+
}
|
|
2959
|
+
cleanups.push(cleanup);
|
|
2960
|
+
}
|
|
2961
|
+
function cleanupComponentResources(renderer, component) {
|
|
2962
|
+
const cleanups = cleanupHookRegistry.get(component);
|
|
2963
|
+
if (cleanups) {
|
|
2964
|
+
for (const cleanup of cleanups) {
|
|
2965
|
+
try {
|
|
2966
|
+
cleanup();
|
|
2967
|
+
} catch (err) {
|
|
2968
|
+
}
|
|
2969
|
+
}
|
|
2970
|
+
cleanupHookRegistry.delete(component);
|
|
2971
|
+
}
|
|
2972
|
+
const subscriptions = effectSubscriptionRegistry.get(component);
|
|
2973
|
+
if (subscriptions) {
|
|
2974
|
+
for (const dispose of subscriptions) {
|
|
2975
|
+
try {
|
|
2976
|
+
dispose();
|
|
2977
|
+
} catch (err) {
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
effectSubscriptionRegistry.delete(component);
|
|
2981
|
+
}
|
|
2982
|
+
const listeners = eventListenerRegistry.get(component);
|
|
2983
|
+
if (listeners) {
|
|
2984
|
+
for (const { el, event, handler, options } of listeners) {
|
|
2985
|
+
try {
|
|
2986
|
+
renderer.removeEventListener(el, event, handler, options);
|
|
2987
|
+
} catch (err) {
|
|
2988
|
+
}
|
|
2989
|
+
}
|
|
2990
|
+
eventListenerRegistry.delete(component);
|
|
2991
|
+
}
|
|
2992
|
+
}
|
|
2993
|
+
|
|
2994
|
+
// src/index.ts
|
|
2995
|
+
init_utils();
|
|
2996
|
+
var installedPlugins = [];
|
|
2997
|
+
var hooks = {
|
|
2998
|
+
beforeMount: /* @__PURE__ */ new Set(),
|
|
2999
|
+
afterMount: /* @__PURE__ */ new Set(),
|
|
3000
|
+
beforePatch: /* @__PURE__ */ new Set(),
|
|
3001
|
+
afterPatch: /* @__PURE__ */ new Set(),
|
|
3002
|
+
beforeUnmount: /* @__PURE__ */ new Set(),
|
|
3003
|
+
afterUnmount: /* @__PURE__ */ new Set()
|
|
3004
|
+
};
|
|
3005
|
+
function use(plugin) {
|
|
3006
|
+
if (installedPlugins.includes(plugin)) {
|
|
3007
|
+
return;
|
|
3008
|
+
}
|
|
3009
|
+
const context = {
|
|
3010
|
+
on: (event, handler) => {
|
|
3011
|
+
hooks[event].add(handler);
|
|
3012
|
+
},
|
|
3013
|
+
off: (event, handler) => {
|
|
3014
|
+
hooks[event].delete(handler);
|
|
3015
|
+
}
|
|
3016
|
+
};
|
|
3017
|
+
plugin.install(context);
|
|
3018
|
+
installedPlugins.push(plugin);
|
|
3019
|
+
if (plugin.beforeMount) hooks.beforeMount.add(plugin.beforeMount);
|
|
3020
|
+
if (plugin.afterMount) hooks.afterMount.add(plugin.afterMount);
|
|
3021
|
+
if (plugin.beforePatch) hooks.beforePatch.add(plugin.beforePatch);
|
|
3022
|
+
if (plugin.afterPatch) hooks.afterPatch.add(plugin.afterPatch);
|
|
3023
|
+
if (plugin.beforeUnmount) hooks.beforeUnmount.add(plugin.beforeUnmount);
|
|
3024
|
+
if (plugin.afterUnmount) hooks.afterUnmount.add(plugin.afterUnmount);
|
|
3025
|
+
}
|
|
3026
|
+
function getInstalledPlugins() {
|
|
3027
|
+
return [...installedPlugins];
|
|
3028
|
+
}
|
|
3029
|
+
function isPluginInstalled(pluginName) {
|
|
3030
|
+
return installedPlugins.some((p) => p.name === pluginName);
|
|
3031
|
+
}
|
|
3032
|
+
function removePlugin(pluginName) {
|
|
3033
|
+
const index = installedPlugins.findIndex((p) => p.name === pluginName);
|
|
3034
|
+
if (index === -1) return false;
|
|
3035
|
+
const plugin = installedPlugins[index];
|
|
3036
|
+
if (plugin.beforeMount) hooks.beforeMount.delete(plugin.beforeMount);
|
|
3037
|
+
if (plugin.afterMount) hooks.afterMount.delete(plugin.afterMount);
|
|
3038
|
+
if (plugin.beforePatch) hooks.beforePatch.delete(plugin.beforePatch);
|
|
3039
|
+
if (plugin.afterPatch) hooks.afterPatch.delete(plugin.afterPatch);
|
|
3040
|
+
if (plugin.beforeUnmount) hooks.beforeUnmount.delete(plugin.beforeUnmount);
|
|
3041
|
+
if (plugin.afterUnmount) hooks.afterUnmount.delete(plugin.afterUnmount);
|
|
3042
|
+
installedPlugins.splice(index, 1);
|
|
3043
|
+
return true;
|
|
3044
|
+
}
|
|
3045
|
+
function executeHooks(event, ...args) {
|
|
3046
|
+
const handlers = hooks[event];
|
|
3047
|
+
for (const handler of handlers) {
|
|
3048
|
+
try {
|
|
3049
|
+
handler(...args);
|
|
3050
|
+
} catch (e) {
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
3054
|
+
async function getEnhancedHydrationFunctions() {
|
|
3055
|
+
const hydration = await Promise.resolve().then(() => (init_enhanced_hydration(), enhanced_hydration_exports));
|
|
3056
|
+
return {
|
|
3057
|
+
hydrateApp: hydration.hydrateApp,
|
|
3058
|
+
hydrateVisible: hydration.hydrateVisible,
|
|
3059
|
+
queueHydration: hydration.queueHydration,
|
|
3060
|
+
safeHydrate: hydration.safeHydrate,
|
|
3061
|
+
createHydrationErrorHandler: hydration.createHydrationErrorHandler
|
|
3062
|
+
};
|
|
3063
|
+
}
|
|
3064
|
+
async function renderToString2(input) {
|
|
3065
|
+
const { renderToString: _renderToString } = await Promise.resolve().then(() => (init_ssr_renderer(), ssr_renderer_exports));
|
|
3066
|
+
return _renderToString(input);
|
|
3067
|
+
}
|
|
3068
|
+
async function renderToStream2(input, options) {
|
|
3069
|
+
const { renderToStream: _renderToStream } = await Promise.resolve().then(() => (init_ssr_stream(), ssr_stream_exports));
|
|
3070
|
+
return _renderToStream(input, options);
|
|
3071
|
+
}
|
|
3072
|
+
async function createOptimizedStream2(vnode, options) {
|
|
3073
|
+
const { createOptimizedStream: _createOptimizedStream } = await Promise.resolve().then(() => (init_ssr_stream_optimized(), ssr_stream_optimized_exports));
|
|
3074
|
+
return _createOptimizedStream(vnode, options);
|
|
3075
|
+
}
|
|
3076
|
+
async function renderDocumentToStream2(vnode, options) {
|
|
3077
|
+
const { renderDocumentToStream: _renderDocumentToStream } = await Promise.resolve().then(() => (init_ssr_stream_optimized(), ssr_stream_optimized_exports));
|
|
3078
|
+
return _renderDocumentToStream(vnode, options);
|
|
3079
|
+
}
|
|
3080
|
+
async function hydrateIsland2(el, component, props) {
|
|
3081
|
+
const { hydrateIsland: _hydrateIsland } = await Promise.resolve().then(() => (init_ssr_island(), ssr_island_exports));
|
|
3082
|
+
return _hydrateIsland(el, component, props);
|
|
3083
|
+
}
|
|
3084
|
+
async function registerIslandComponent2(name, component) {
|
|
3085
|
+
const { registerIslandComponent: _registerIslandComponent } = await Promise.resolve().then(() => (init_ssr_island(), ssr_island_exports));
|
|
3086
|
+
return _registerIslandComponent(name, component);
|
|
3087
|
+
}
|
|
3088
|
+
async function createIslandSSRContent2(name, props = {}) {
|
|
3089
|
+
const { createIslandSSRContent: _createIslandSSRContent } = await Promise.resolve().then(() => (init_ssr_island(), ssr_island_exports));
|
|
3090
|
+
return _createIslandSSRContent(name, props);
|
|
3091
|
+
}
|
|
3092
|
+
async function createSignalRenderer2(template = "", context = {}) {
|
|
3093
|
+
const { createSignalRenderer: _createSignalRenderer } = await Promise.resolve().then(() => (init_signal_renderer(), signal_renderer_exports));
|
|
3094
|
+
return _createSignalRenderer(template, context);
|
|
3095
|
+
}
|
|
3096
|
+
async function createVaporRenderer(template = "", context = {}) {
|
|
3097
|
+
const { createSignalRenderer: _createSignalRenderer } = await Promise.resolve().then(() => (init_signal_renderer(), signal_renderer_exports));
|
|
3098
|
+
return _createSignalRenderer(template, context);
|
|
3099
|
+
}
|
|
3100
|
+
async function defineVaporComponent2(options) {
|
|
3101
|
+
const { defineVaporComponent: _defineVaporComponent } = await Promise.resolve().then(() => (init_vapor_app(), vapor_app_exports));
|
|
3102
|
+
return _defineVaporComponent(options);
|
|
3103
|
+
}
|
|
3104
|
+
async function createVaporApp2(rootComponent, props) {
|
|
3105
|
+
const { createVaporApp: _createVaporApp } = await Promise.resolve().then(() => (init_vapor_app(), vapor_app_exports));
|
|
3106
|
+
return _createVaporApp(rootComponent, props);
|
|
3107
|
+
}
|
|
3108
|
+
async function getVaporHMRFunctions() {
|
|
3109
|
+
const vaporHMR = await Promise.resolve().then(() => (init_vapor_hmr(), vapor_hmr_exports));
|
|
3110
|
+
return {
|
|
3111
|
+
generateComponentId: vaporHMR.generateComponentId,
|
|
3112
|
+
registerComponent: vaporHMR.registerComponent,
|
|
3113
|
+
unregisterComponent: vaporHMR.unregisterComponent,
|
|
3114
|
+
handleComponentUpdate: vaporHMR.handleComponentUpdate,
|
|
3115
|
+
createVaporHMRHandler: vaporHMR.createVaporHMRHandler,
|
|
3116
|
+
isHMRAvailable: vaporHMR.isHMRAvailable,
|
|
3117
|
+
forceRerender: vaporHMR.forceRerender,
|
|
3118
|
+
clearHMRState: vaporHMR.clearHMRState,
|
|
3119
|
+
onHMRUpdate: vaporHMR.onHMRUpdate
|
|
3120
|
+
};
|
|
3121
|
+
}
|
|
3122
|
+
async function renderVaporToString2(component, props, options) {
|
|
3123
|
+
const { renderVaporToString: _renderVaporToString } = await Promise.resolve().then(() => (init_vapor_ssr(), vapor_ssr_exports));
|
|
3124
|
+
return _renderVaporToString(
|
|
3125
|
+
component,
|
|
3126
|
+
props,
|
|
3127
|
+
options
|
|
3128
|
+
);
|
|
3129
|
+
}
|
|
3130
|
+
async function renderVaporToStream2(component, props, options) {
|
|
3131
|
+
const { renderVaporToStream: _renderVaporToStream } = await Promise.resolve().then(() => (init_vapor_ssr(), vapor_ssr_exports));
|
|
3132
|
+
return _renderVaporToStream(
|
|
3133
|
+
component,
|
|
3134
|
+
props,
|
|
3135
|
+
options
|
|
3136
|
+
);
|
|
3137
|
+
}
|
|
3138
|
+
async function hydrateVaporComponent2(container, component, options) {
|
|
3139
|
+
const { hydrateVaporComponent: _hydrateVaporComponent } = await Promise.resolve().then(() => (init_vapor_ssr(), vapor_ssr_exports));
|
|
3140
|
+
return _hydrateVaporComponent(
|
|
3141
|
+
container,
|
|
3142
|
+
component,
|
|
3143
|
+
options
|
|
3144
|
+
);
|
|
3145
|
+
}
|
|
3146
|
+
async function getServerComponentFunctions() {
|
|
3147
|
+
const serverComponents = await Promise.resolve().then(() => (init_server_components(), server_components_exports));
|
|
3148
|
+
return {
|
|
3149
|
+
registerServerComponent: serverComponents.registerServerComponent,
|
|
3150
|
+
registerServerFunction: serverComponents.registerServerFunction,
|
|
3151
|
+
getServerComponent: serverComponents.getServerComponent,
|
|
3152
|
+
getServerFunction: serverComponents.getServerFunction,
|
|
3153
|
+
handleServerAction: serverComponents.handleServerAction,
|
|
3154
|
+
createServerActionHandler: serverComponents.createServerActionHandler,
|
|
3155
|
+
serializeServerData: serverComponents.serializeServerData,
|
|
3156
|
+
deserializeServerData: serverComponents.deserializeServerData,
|
|
3157
|
+
renderServerComponent: serverComponents.renderServerComponent,
|
|
3158
|
+
defineServerComponent: serverComponents.defineServerComponent
|
|
3159
|
+
};
|
|
3160
|
+
}
|
|
3161
|
+
async function getServerComponentClientFunctions() {
|
|
3162
|
+
const client = await Promise.resolve().then(() => (init_server_components_client(), server_components_client_exports));
|
|
3163
|
+
return {
|
|
3164
|
+
callServer: client.callServer,
|
|
3165
|
+
createServerFunction: client.createServerFunction,
|
|
3166
|
+
getServerData: client.getServerData,
|
|
3167
|
+
hasServerData: client.hasServerData,
|
|
3168
|
+
isHydrated: client.isHydrated,
|
|
3169
|
+
markHydrated: client.markHydrated,
|
|
3170
|
+
getHydrationState: client.getHydrationState,
|
|
3171
|
+
autoHydrate: client.autoHydrate,
|
|
3172
|
+
configureServerAction: client.configureServerAction
|
|
3173
|
+
};
|
|
3174
|
+
}
|
|
3175
|
+
async function getDataFetchingFunctions() {
|
|
3176
|
+
const data = await Promise.resolve().then(() => (init_data_fetching(), data_fetching_exports));
|
|
3177
|
+
return {
|
|
3178
|
+
serializeData: data.serializeData,
|
|
3179
|
+
deserializeData: data.deserializeData,
|
|
3180
|
+
createPrefetchManager: data.createPrefetchManager,
|
|
3181
|
+
useFetch: data.useFetch,
|
|
3182
|
+
useAsyncData: data.useAsyncData,
|
|
3183
|
+
injectPrefetchData: data.injectPrefetchData,
|
|
3184
|
+
getPrefetchData: data.getPrefetchData
|
|
3185
|
+
};
|
|
3186
|
+
}
|
|
3187
|
+
|
|
3188
|
+
export { DEFAULT_STATE_PRESERVATION, HydrationErrorHandler, OptimizedSSRStream, cleanupComponentResources, createIslandSSRContent2 as createIslandSSRContent, createOptimizedStream2 as createOptimizedStream, createSignalRenderer2 as createSignalRenderer, createVaporApp2 as createVaporApp, createVaporRenderer, definePrefetch, defineVaporComponent2 as defineVaporComponent, executeHooks, getDataFetchingFunctions, getEnhancedHydrationFunctions, getInstalledPlugins, getServerComponentClientFunctions, getServerComponentFunctions, getVaporHMRFunctions, hydrateIsland2 as hydrateIsland, hydrateVaporComponent2 as hydrateVaporComponent, isPluginInstalled, isVoidElement, registerComponentCleanup, registerComponentEffectSubscription, registerComponentEventListener, registerIslandComponent2 as registerIslandComponent, removePlugin, renderDocumentToStream2 as renderDocumentToStream, renderToStream2 as renderToStream, renderToString2 as renderToString, renderVaporToStream2 as renderVaporToStream, renderVaporToString2 as renderVaporToString, use, usePrefetchData };
|
|
3189
|
+
//# sourceMappingURL=index.mjs.map
|
|
3190
|
+
//# sourceMappingURL=index.mjs.map
|