@jsenv/server 16.3.5 → 16.4.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/dist/client/route_inspector/route_inspector.html +24 -18
- package/dist/formidable_index/formidable_index.js +2 -2
- package/dist/formidable_index/jsenv_server_node_modules.js +1 -1
- package/dist/jsenv_server.js +271 -189
- package/dist/ws/ws.js +56 -40
- package/index.js +53 -0
- package/package.json +9 -8
- package/src/{filesystem → services/filesystem}/fetch_filesystem.js +6 -5
- package/src/services/filesystem/jsenv_service_static_files.js +44 -0
- package/src/{filesystem → services/filesystem}/serve_directory.js +2 -1
- package/src/main.js +0 -52
- /package/src/{internal → services/filesystem}/etag.js +0 -0
- /package/src/{internal/convertFileSystemErrorToResponseProperties.js → services/filesystem/filesystem_error_to_response.js} +0 -0
- /package/src/{internal/filesystem.js → services/filesystem/filesystem_path_and_url.js} +0 -0
|
@@ -482,7 +482,9 @@ main {
|
|
|
482
482
|
}
|
|
483
483
|
|
|
484
484
|
.note_button_open:hover {
|
|
485
|
-
background-color: color-mix(in srgb,
|
|
485
|
+
background-color: color-mix(in srgb,
|
|
486
|
+
var(--primary-color) 15%,
|
|
487
|
+
transparent);
|
|
486
488
|
opacity: 1;
|
|
487
489
|
}
|
|
488
490
|
|
|
@@ -544,7 +546,9 @@ main {
|
|
|
544
546
|
}
|
|
545
547
|
|
|
546
548
|
#theme-toggle-btn:hover {
|
|
547
|
-
background-color: color-mix(in srgb,
|
|
549
|
+
background-color: color-mix(in srgb,
|
|
550
|
+
var(--primary-color) 15%,
|
|
551
|
+
transparent);
|
|
548
552
|
}
|
|
549
553
|
|
|
550
554
|
#theme-toggle-btn svg {
|
|
@@ -1025,7 +1029,9 @@ label .filter_text {
|
|
|
1025
1029
|
}
|
|
1026
1030
|
|
|
1027
1031
|
.filter_button:hover {
|
|
1028
|
-
background-color: color-mix(in srgb,
|
|
1032
|
+
background-color: color-mix(in srgb,
|
|
1033
|
+
var(--primary-color) 15%,
|
|
1034
|
+
transparent);
|
|
1029
1035
|
}
|
|
1030
1036
|
|
|
1031
1037
|
.status_pill {
|
|
@@ -1125,7 +1131,7 @@ label .filter_text {
|
|
|
1125
1131
|
});
|
|
1126
1132
|
</script>
|
|
1127
1133
|
<script type="module">/* esm.sh - preact@10.23.1 */
|
|
1128
|
-
var M$2,h,X,ie,x$2,J,Y,R,j,$,O$1,T$1={},ee=[],le=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,I=Array.isArray;function b$3(_,e){for(var t in e)_[t]=e[t];return _}function _e(_){var e=_.parentNode;e&&e.removeChild(_);}function se(_,e,t){var i,n,r,l={};for(r in e)r=="key"?i=e[r]:r=="ref"?n=e[r]:l[r]=e[r];if(arguments.length>2&&(l.children=arguments.length>3?M$2.call(arguments,2):t),typeof _=="function"&&_.defaultProps!=null)for(r in _.defaultProps)l[r]===void 0&&(l[r]=_.defaultProps[r]);return U(_,l,i,n,null)}function U(_,e,t,i,n){var r={type:_,props:e,key:t,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:n??++X,__i:-1,__u:0};return n==null&&h.vnode!=null&&h.vnode(r),r}function N$1(_){return _.children}function F$1(_,e){this.props=_,this.context=e;}function C$2(_,e){if(e==null)return _.__?C$2(_.__,_.__i+1):null;for(var t;e<_.__k.length;e++)if((t=_.__k[e])!=null&&t.__e!=null)return t.__e;return typeof _.type=="function"?C$2(_):null}function te(_){var e,t;if((_=_.__)!=null&&_.__c!=null){for(_.__e=_.__c.base=null,e=0;e<_.__k.length;e++)if((t=_.__k[e])!=null&&t.__e!=null){_.__e=_.__c.base=t.__e;break}return te(_)}}function B(_){(!_.__d&&(_.__d=true)&&x$2.push(_)&&!H$1.__r++||J!==h.debounceRendering)&&((J=h.debounceRendering)||Y)(H$1);}function H$1(){var _,e,t,i,n,r,l,s;for(x$2.sort(R);_=x$2.shift();)_.__d&&(e=x$2.length,i=void 0,r=(n=(t=_).__v).__e,l=[],s=[],t.__P&&((i=b$3({},n)).__v=n.__v+1,h.vnode&&h.vnode(i),z$1(t.__P,i,n,t.__n,t.__P.namespaceURI,32&n.__u?[r]:null,l,r??C$2(n),!!(32&n.__u),s),i.__v=n.__v,i.__.__k[i.__i]=i,re(l,i,s),i.__e!=r&&te(i)),x$2.length>e&&x$2.sort(R));H$1.__r=0;}function ne(_,e,t,i,n,r,l,s,c,u,p){var o,m,f,v,g,y=i&&i.__k||ee,a=e.length;for(t.__d=c,ue(t,e,y),c=t.__d,o=0;o<a;o++)(f=t.__k[o])!=null&&typeof f!="boolean"&&typeof f!="function"&&(m=f.__i===-1?T$1:y[f.__i]||T$1,f.__i=o,z$1(_,f,m,n,r,l,s,c,u,p),v=f.__e,f.ref&&m.ref!=f.ref&&(m.ref&&q$1(m.ref,null,f),p.push(f.ref,f.__c||v,f)),g==null&&v!=null&&(g=v),65536&f.__u||m.__k===f.__k?c=oe(f,c,_):typeof f.type=="function"&&f.__d!==void 0?c=f.__d:v&&(c=v.nextSibling),f.__d=void 0,f.__u&=-196609);t.__d=c,t.__e=g;}function ue(_,e,t){var i,n,r,l,s,c=e.length,u=t.length,p=u,o=0;for(_.__k=[],i=0;i<c;i++)l=i+o,(n=_.__k[i]=(n=e[i])==null||typeof n=="boolean"||typeof n=="function"?null:typeof n=="string"||typeof n=="number"||typeof n=="bigint"||n.constructor==String?U(null,n,null,null,null):I(n)?U(N$1,{children:n},null,null,null):n.constructor===void 0&&n.__b>0?U(n.type,n.props,n.key,n.ref?n.ref:null,n.__v):n)!=null?(n.__=_,n.__b=_.__b+1,s=ce(n,t,l,p),n.__i=s,r=null,s!==-1&&(p--,(r=t[s])&&(r.__u|=131072)),r==null||r.__v===null?(s==-1&&o--,typeof n.type!="function"&&(n.__u|=65536)):s!==l&&(s==l-1?o=s-l:s==l+1?o++:s>l?p>c-l?o+=s-l:o--:s<l&&o++,s!==i+o&&(n.__u|=65536))):(r=t[l])&&r.key==null&&r.__e&&(131072&r.__u)==0&&(r.__e==_.__d&&(_.__d=C$2(r)),V(r,r,false),t[l]=null,p--);if(p)for(i=0;i<u;i++)(r=t[i])!=null&&(131072&r.__u)==0&&(r.__e==_.__d&&(_.__d=C$2(r)),V(r,r));}function oe(_,e,t){var i,n;if(typeof _.type=="function"){for(i=_.__k,n=0;i&&n<i.length;n++)i[n]&&(i[n].__=_,e=oe(i[n],e,t));return e}_.__e!=e&&(e&&_.type&&!t.contains(e)&&(e=C$2(_)),t.insertBefore(_.__e,e||null),e=_.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType===8);return e}function ce(_,e,t,i){var n=_.key,r=_.type,l=t-1,s=t+1,c=e[t];if(c===null||c&&n==c.key&&r===c.type&&(131072&c.__u)==0)return t;if(i>(c!=null&&(131072&c.__u)==0?1:0))for(;l>=0||s<e.length;){if(l>=0){if((c=e[l])&&(131072&c.__u)==0&&n==c.key&&r===c.type)return l;l--;}if(s<e.length){if((c=e[s])&&(131072&c.__u)==0&&n==c.key&&r===c.type)return s;s++;}}return -1}function K(_,e,t){e[0]==="-"?_.setProperty(e,t??""):_[e]=t==null?"":typeof t!="number"||le.test(e)?t:t+"px";}function W$1(_,e,t,i,n){var r;e:if(e==="style")if(typeof t=="string")_.style.cssText=t;else {if(typeof i=="string"&&(_.style.cssText=i=""),i)for(e in i)t&&e in t||K(_.style,e,"");if(t)for(e in t)i&&t[e]===i[e]||K(_.style,e,t[e]);}else if(e[0]==="o"&&e[1]==="n")r=e!==(e=e.replace(/(PointerCapture)$|Capture$/i,"$1")),e=e.toLowerCase()in _||e==="onFocusOut"||e==="onFocusIn"?e.toLowerCase().slice(2):e.slice(2),_.l||(_.l={}),_.l[e+r]=t,t?i?t.u=i.u:(t.u=j,_.addEventListener(e,r?O$1:$,r)):_.removeEventListener(e,r?O$1:$,r);else {if(n=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in _)try{_[e]=t??"";break e}catch{}typeof t=="function"||(t==null||t===false&&e[4]!=="-"?_.removeAttribute(e):_.setAttribute(e,e=="popover"&&t==1?"":t));}}function Q(_){return function(e){if(this.l){var t=this.l[e.type+_];if(e.t==null)e.t=j++;else if(e.t<t.u)return;return t(h.event?h.event(e):e)}}}function z$1(_,e,t,i,n,r,l,s,c,u){var p,o,m,f,v,g,y,a,d,P,w,D,S,G,E,A,k=e.type;if(e.constructor!==void 0)return null;128&t.__u&&(c=!!(32&t.__u),r=[s=e.__e=t.__e]),(p=h.__b)&&p(e);e:if(typeof k=="function")try{if(a=e.props,d="prototype"in k&&k.prototype.render,P=(p=k.contextType)&&i[p.__c],w=p?P?P.props.value:p.__:i,t.__c?y=(o=e.__c=t.__c).__=o.__E:(d?e.__c=o=new k(a,w):(e.__c=o=new F$1(a,w),o.constructor=k,o.render=ae),P&&P.sub(o),o.props=a,o.state||(o.state={}),o.context=w,o.__n=i,m=o.__d=!0,o.__h=[],o._sb=[]),d&&o.__s==null&&(o.__s=o.state),d&&k.getDerivedStateFromProps!=null&&(o.__s==o.state&&(o.__s=b$3({},o.__s)),b$3(o.__s,k.getDerivedStateFromProps(a,o.__s))),f=o.props,v=o.state,o.__v=e,m)d&&k.getDerivedStateFromProps==null&&o.componentWillMount!=null&&o.componentWillMount(),d&&o.componentDidMount!=null&&o.__h.push(o.componentDidMount);else {if(d&&k.getDerivedStateFromProps==null&&a!==f&&o.componentWillReceiveProps!=null&&o.componentWillReceiveProps(a,w),!o.__e&&(o.shouldComponentUpdate!=null&&o.shouldComponentUpdate(a,o.__s,w)===!1||e.__v===t.__v)){for(e.__v!==t.__v&&(o.props=a,o.state=o.__s,o.__d=!1),e.__e=t.__e,e.__k=t.__k,e.__k.forEach(function(L){L&&(L.__=e);}),D=0;D<o._sb.length;D++)o.__h.push(o._sb[D]);o._sb=[],o.__h.length&&l.push(o);break e}o.componentWillUpdate!=null&&o.componentWillUpdate(a,o.__s,w),d&&o.componentDidUpdate!=null&&o.__h.push(function(){o.componentDidUpdate(f,v,g);});}if(o.context=w,o.props=a,o.__P=_,o.__e=!1,S=h.__r,G=0,d){for(o.state=o.__s,o.__d=!1,S&&S(e),p=o.render(o.props,o.state,o.context),E=0;E<o._sb.length;E++)o.__h.push(o._sb[E]);o._sb=[];}else do o.__d=!1,S&&S(e),p=o.render(o.props,o.state,o.context),o.state=o.__s;while(o.__d&&++G<25);o.state=o.__s,o.getChildContext!=null&&(i=b$3(b$3({},i),o.getChildContext())),d&&!m&&o.getSnapshotBeforeUpdate!=null&&(g=o.getSnapshotBeforeUpdate(f,v)),ne(_,I(A=p!=null&&p.type===N$1&&p.key==null?p.props.children:p)?A:[A],e,t,i,n,r,l,s,c,u),o.base=e.__e,e.__u&=-161,o.__h.length&&l.push(o),y&&(o.__E=o.__=null);}catch(L){if(e.__v=null,c||r!=null){for(e.__u|=c?160:32;s&&s.nodeType===8&&s.nextSibling;)s=s.nextSibling;r[r.indexOf(s)]=null,e.__e=s;}else e.__e=t.__e,e.__k=t.__k;h.__e(L,e,t);}else r==null&&e.__v===t.__v?(e.__k=t.__k,e.__e=t.__e):e.__e=pe(t.__e,e,t,i,n,r,l,c,u);(p=h.diffed)&&p(e);}function re(_,e,t){e.__d=void 0;for(var i=0;i<t.length;i++)q$1(t[i],t[++i],t[++i]);h.__c&&h.__c(e,_),_.some(function(n){try{_=n.__h,n.__h=[],_.some(function(r){r.call(n);});}catch(r){h.__e(r,n.__v);}});}function pe(_,e,t,i,n,r,l,s,c){var u,p,o,m,f,v,g,y=t.props,a=e.props,d=e.type;if(d==="svg"?n="http://www.w3.org/2000/svg":d==="math"?n="http://www.w3.org/1998/Math/MathML":n||(n="http://www.w3.org/1999/xhtml"),r!=null){for(u=0;u<r.length;u++)if((f=r[u])&&"setAttribute"in f==!!d&&(d?f.localName===d:f.nodeType===3)){_=f,r[u]=null;break}}if(_==null){if(d===null)return document.createTextNode(a);_=document.createElementNS(n,d,a.is&&a),r=null,s=false;}if(d===null)y===a||s&&_.data===a||(_.data=a);else {if(r=r&&M$2.call(_.childNodes),y=t.props||T$1,!s&&r!=null)for(y={},u=0;u<_.attributes.length;u++)y[(f=_.attributes[u]).name]=f.value;for(u in y)if(f=y[u],u!="children"){if(u=="dangerouslySetInnerHTML")o=f;else if(u!=="key"&&!(u in a)){if(u=="value"&&"defaultValue"in a||u=="checked"&&"defaultChecked"in a)continue;W$1(_,u,null,f,n);}}for(u in a)f=a[u],u=="children"?m=f:u=="dangerouslySetInnerHTML"?p=f:u=="value"?v=f:u=="checked"?g=f:u==="key"||s&&typeof f!="function"||y[u]===f||W$1(_,u,f,y[u],n);if(p)s||o&&(p.__html===o.__html||p.__html===_.innerHTML)||(_.innerHTML=p.__html),e.__k=[];else if(o&&(_.innerHTML=""),ne(_,I(m)?m:[m],e,t,i,d==="foreignObject"?"http://www.w3.org/1999/xhtml":n,r,l,r?r[0]:t.__k&&C$2(t,0),s,c),r!=null)for(u=r.length;u--;)r[u]!=null&&_e(r[u]);s||(u="value",v!==void 0&&(v!==_[u]||d==="progress"&&!v||d==="option"&&v!==y[u])&&W$1(_,u,v,y[u],n),u="checked",g!==void 0&&g!==_[u]&&W$1(_,u,g,y[u],n));}return _}function q$1(_,e,t){try{if(typeof _=="function"){var i=typeof _.__u=="function";i&&_.__u(),i&&e==null||(_.__u=_(e));}else _.current=e;}catch(n){h.__e(n,t);}}function V(_,e,t){var i,n;if(h.unmount&&h.unmount(_),(i=_.ref)&&(i.current&&i.current!==_.__e||q$1(i,null,e)),(i=_.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount();}catch(r){h.__e(r,e);}i.base=i.__P=null;}if(i=_.__k)for(n=0;n<i.length;n++)i[n]&&V(i[n],e,t||typeof _.type!="function");t||_.__e==null||_e(_.__e),_.__c=_.__=_.__e=_.__d=void 0;}function ae(_,e,t){return this.constructor(_,t)}function de(_,e,t){var i,n,r,l;h.__&&h.__(_,e),n=(i="undefined"=="function")?null:e.__k,r=[],l=[],z$1(e,_=(e).__k=se(N$1,null,[_]),n||T$1,T$1,e.namespaceURI,n?null:e.firstChild?M$2.call(e.childNodes):null,r,n?n.__e:e.firstChild,i,l),re(r,_,l);}M$2=ee.slice,h={__e:function(_,e,t,i){for(var n,r,l;e=e.__;)if((n=e.__c)&&!n.__)try{if((r=n.constructor)&&r.getDerivedStateFromError!=null&&(n.setState(r.getDerivedStateFromError(_)),l=n.__d),n.componentDidCatch!=null&&(n.componentDidCatch(_,i||{}),l=n.__d),l)return n.__E=n}catch(s){_=s;}throw _}},X=0,ie=function(_){return _!=null&&_.constructor==null},F$1.prototype.setState=function(_,e){var t;t=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=b$3({},this.state),typeof _=="function"&&(_=_(b$3({},t),this.props)),_&&b$3(t,_),_!=null&&this.__v&&(e&&this._sb.push(e),B(this));},F$1.prototype.forceUpdate=function(_){this.__v&&(this.__e=true,_&&this.__h.push(_),B(this));},F$1.prototype.render=N$1,x$2=[],Y=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,R=function(_,e){return _.__v.__b-e.__v.__b},H$1.__r=0,j=0,$=Q(false),O$1=Q(true);
|
|
1134
|
+
var M$2,h$1,X,ie,x$2,J$1,Y,R,j,$,O,T$1={},ee=[],le=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,I=Array.isArray;function b$3(_,e){for(var t in e)_[t]=e[t];return _}function _e(_){var e=_.parentNode;e&&e.removeChild(_);}function se(_,e,t){var i,n,r,l={};for(r in e)r=="key"?i=e[r]:r=="ref"?n=e[r]:l[r]=e[r];if(arguments.length>2&&(l.children=arguments.length>3?M$2.call(arguments,2):t),typeof _=="function"&&_.defaultProps!=null)for(r in _.defaultProps)l[r]===void 0&&(l[r]=_.defaultProps[r]);return U(_,l,i,n,null)}function U(_,e,t,i,n){var r={type:_,props:e,key:t,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:n??++X,__i:-1,__u:0};return n==null&&h$1.vnode!=null&&h$1.vnode(r),r}function N(_){return _.children}function F$1(_,e){this.props=_,this.context=e;}function C$3(_,e){if(e==null)return _.__?C$3(_.__,_.__i+1):null;for(var t;e<_.__k.length;e++)if((t=_.__k[e])!=null&&t.__e!=null)return t.__e;return typeof _.type=="function"?C$3(_):null}function te(_){var e,t;if((_=_.__)!=null&&_.__c!=null){for(_.__e=_.__c.base=null,e=0;e<_.__k.length;e++)if((t=_.__k[e])!=null&&t.__e!=null){_.__e=_.__c.base=t.__e;break}return te(_)}}function B(_){(!_.__d&&(_.__d=true)&&x$2.push(_)&&!H$1.__r++||J$1!==h$1.debounceRendering)&&((J$1=h$1.debounceRendering)||Y)(H$1);}function H$1(){var _,e,t,i,n,r,l,s;for(x$2.sort(R);_=x$2.shift();)_.__d&&(e=x$2.length,i=void 0,r=(n=(t=_).__v).__e,l=[],s=[],t.__P&&((i=b$3({},n)).__v=n.__v+1,h$1.vnode&&h$1.vnode(i),z$1(t.__P,i,n,t.__n,t.__P.namespaceURI,32&n.__u?[r]:null,l,r??C$3(n),!!(32&n.__u),s),i.__v=n.__v,i.__.__k[i.__i]=i,re(l,i,s),i.__e!=r&&te(i)),x$2.length>e&&x$2.sort(R));H$1.__r=0;}function ne(_,e,t,i,n,r,l,s,c,u,p){var o,m,f,v,g,y=i&&i.__k||ee,a=e.length;for(t.__d=c,ue(t,e,y),c=t.__d,o=0;o<a;o++)(f=t.__k[o])!=null&&typeof f!="boolean"&&typeof f!="function"&&(m=f.__i===-1?T$1:y[f.__i]||T$1,f.__i=o,z$1(_,f,m,n,r,l,s,c,u,p),v=f.__e,f.ref&&m.ref!=f.ref&&(m.ref&&q$1(m.ref,null,f),p.push(f.ref,f.__c||v,f)),g==null&&v!=null&&(g=v),65536&f.__u||m.__k===f.__k?c=oe(f,c,_):typeof f.type=="function"&&f.__d!==void 0?c=f.__d:v&&(c=v.nextSibling),f.__d=void 0,f.__u&=-196609);t.__d=c,t.__e=g;}function ue(_,e,t){var i,n,r,l,s,c=e.length,u=t.length,p=u,o=0;for(_.__k=[],i=0;i<c;i++)l=i+o,(n=_.__k[i]=(n=e[i])==null||typeof n=="boolean"||typeof n=="function"?null:typeof n=="string"||typeof n=="number"||typeof n=="bigint"||n.constructor==String?U(null,n,null,null,null):I(n)?U(N,{children:n},null,null,null):n.constructor===void 0&&n.__b>0?U(n.type,n.props,n.key,n.ref?n.ref:null,n.__v):n)!=null?(n.__=_,n.__b=_.__b+1,s=ce(n,t,l,p),n.__i=s,r=null,s!==-1&&(p--,(r=t[s])&&(r.__u|=131072)),r==null||r.__v===null?(s==-1&&o--,typeof n.type!="function"&&(n.__u|=65536)):s!==l&&(s==l-1?o=s-l:s==l+1?o++:s>l?p>c-l?o+=s-l:o--:s<l&&o++,s!==i+o&&(n.__u|=65536))):(r=t[l])&&r.key==null&&r.__e&&(131072&r.__u)==0&&(r.__e==_.__d&&(_.__d=C$3(r)),V(r,r,false),t[l]=null,p--);if(p)for(i=0;i<u;i++)(r=t[i])!=null&&(131072&r.__u)==0&&(r.__e==_.__d&&(_.__d=C$3(r)),V(r,r));}function oe(_,e,t){var i,n;if(typeof _.type=="function"){for(i=_.__k,n=0;i&&n<i.length;n++)i[n]&&(i[n].__=_,e=oe(i[n],e,t));return e}_.__e!=e&&(e&&_.type&&!t.contains(e)&&(e=C$3(_)),t.insertBefore(_.__e,e||null),e=_.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType===8);return e}function ce(_,e,t,i){var n=_.key,r=_.type,l=t-1,s=t+1,c=e[t];if(c===null||c&&n==c.key&&r===c.type&&(131072&c.__u)==0)return t;if(i>(c!=null&&(131072&c.__u)==0?1:0))for(;l>=0||s<e.length;){if(l>=0){if((c=e[l])&&(131072&c.__u)==0&&n==c.key&&r===c.type)return l;l--;}if(s<e.length){if((c=e[s])&&(131072&c.__u)==0&&n==c.key&&r===c.type)return s;s++;}}return -1}function K(_,e,t){e[0]==="-"?_.setProperty(e,t??""):_[e]=t==null?"":typeof t!="number"||le.test(e)?t:t+"px";}function W$2(_,e,t,i,n){var r;e:if(e==="style")if(typeof t=="string")_.style.cssText=t;else {if(typeof i=="string"&&(_.style.cssText=i=""),i)for(e in i)t&&e in t||K(_.style,e,"");if(t)for(e in t)i&&t[e]===i[e]||K(_.style,e,t[e]);}else if(e[0]==="o"&&e[1]==="n")r=e!==(e=e.replace(/(PointerCapture)$|Capture$/i,"$1")),e=e.toLowerCase()in _||e==="onFocusOut"||e==="onFocusIn"?e.toLowerCase().slice(2):e.slice(2),_.l||(_.l={}),_.l[e+r]=t,t?i?t.u=i.u:(t.u=j,_.addEventListener(e,r?O:$,r)):_.removeEventListener(e,r?O:$,r);else {if(n=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in _)try{_[e]=t??"";break e}catch{}typeof t=="function"||(t==null||t===false&&e[4]!=="-"?_.removeAttribute(e):_.setAttribute(e,e=="popover"&&t==1?"":t));}}function Q(_){return function(e){if(this.l){var t=this.l[e.type+_];if(e.t==null)e.t=j++;else if(e.t<t.u)return;return t(h$1.event?h$1.event(e):e)}}}function z$1(_,e,t,i,n,r,l,s,c,u){var p,o,m,f,v,g,y,a,d,P,w,D,S,G,E,A,k=e.type;if(e.constructor!==void 0)return null;128&t.__u&&(c=!!(32&t.__u),r=[s=e.__e=t.__e]),(p=h$1.__b)&&p(e);e:if(typeof k=="function")try{if(a=e.props,d="prototype"in k&&k.prototype.render,P=(p=k.contextType)&&i[p.__c],w=p?P?P.props.value:p.__:i,t.__c?y=(o=e.__c=t.__c).__=o.__E:(d?e.__c=o=new k(a,w):(e.__c=o=new F$1(a,w),o.constructor=k,o.render=ae),P&&P.sub(o),o.props=a,o.state||(o.state={}),o.context=w,o.__n=i,m=o.__d=!0,o.__h=[],o._sb=[]),d&&o.__s==null&&(o.__s=o.state),d&&k.getDerivedStateFromProps!=null&&(o.__s==o.state&&(o.__s=b$3({},o.__s)),b$3(o.__s,k.getDerivedStateFromProps(a,o.__s))),f=o.props,v=o.state,o.__v=e,m)d&&k.getDerivedStateFromProps==null&&o.componentWillMount!=null&&o.componentWillMount(),d&&o.componentDidMount!=null&&o.__h.push(o.componentDidMount);else {if(d&&k.getDerivedStateFromProps==null&&a!==f&&o.componentWillReceiveProps!=null&&o.componentWillReceiveProps(a,w),!o.__e&&(o.shouldComponentUpdate!=null&&o.shouldComponentUpdate(a,o.__s,w)===!1||e.__v===t.__v)){for(e.__v!==t.__v&&(o.props=a,o.state=o.__s,o.__d=!1),e.__e=t.__e,e.__k=t.__k,e.__k.forEach(function(L){L&&(L.__=e);}),D=0;D<o._sb.length;D++)o.__h.push(o._sb[D]);o._sb=[],o.__h.length&&l.push(o);break e}o.componentWillUpdate!=null&&o.componentWillUpdate(a,o.__s,w),d&&o.componentDidUpdate!=null&&o.__h.push(function(){o.componentDidUpdate(f,v,g);});}if(o.context=w,o.props=a,o.__P=_,o.__e=!1,S=h$1.__r,G=0,d){for(o.state=o.__s,o.__d=!1,S&&S(e),p=o.render(o.props,o.state,o.context),E=0;E<o._sb.length;E++)o.__h.push(o._sb[E]);o._sb=[];}else do o.__d=!1,S&&S(e),p=o.render(o.props,o.state,o.context),o.state=o.__s;while(o.__d&&++G<25);o.state=o.__s,o.getChildContext!=null&&(i=b$3(b$3({},i),o.getChildContext())),d&&!m&&o.getSnapshotBeforeUpdate!=null&&(g=o.getSnapshotBeforeUpdate(f,v)),ne(_,I(A=p!=null&&p.type===N&&p.key==null?p.props.children:p)?A:[A],e,t,i,n,r,l,s,c,u),o.base=e.__e,e.__u&=-161,o.__h.length&&l.push(o),y&&(o.__E=o.__=null);}catch(L){if(e.__v=null,c||r!=null){for(e.__u|=c?160:32;s&&s.nodeType===8&&s.nextSibling;)s=s.nextSibling;r[r.indexOf(s)]=null,e.__e=s;}else e.__e=t.__e,e.__k=t.__k;h$1.__e(L,e,t);}else r==null&&e.__v===t.__v?(e.__k=t.__k,e.__e=t.__e):e.__e=pe(t.__e,e,t,i,n,r,l,c,u);(p=h$1.diffed)&&p(e);}function re(_,e,t){e.__d=void 0;for(var i=0;i<t.length;i++)q$1(t[i],t[++i],t[++i]);h$1.__c&&h$1.__c(e,_),_.some(function(n){try{_=n.__h,n.__h=[],_.some(function(r){r.call(n);});}catch(r){h$1.__e(r,n.__v);}});}function pe(_,e,t,i,n,r,l,s,c){var u,p,o,m,f,v,g,y=t.props,a=e.props,d=e.type;if(d==="svg"?n="http://www.w3.org/2000/svg":d==="math"?n="http://www.w3.org/1998/Math/MathML":n||(n="http://www.w3.org/1999/xhtml"),r!=null){for(u=0;u<r.length;u++)if((f=r[u])&&"setAttribute"in f==!!d&&(d?f.localName===d:f.nodeType===3)){_=f,r[u]=null;break}}if(_==null){if(d===null)return document.createTextNode(a);_=document.createElementNS(n,d,a.is&&a),r=null,s=false;}if(d===null)y===a||s&&_.data===a||(_.data=a);else {if(r=r&&M$2.call(_.childNodes),y=t.props||T$1,!s&&r!=null)for(y={},u=0;u<_.attributes.length;u++)y[(f=_.attributes[u]).name]=f.value;for(u in y)if(f=y[u],u!="children"){if(u=="dangerouslySetInnerHTML")o=f;else if(u!=="key"&&!(u in a)){if(u=="value"&&"defaultValue"in a||u=="checked"&&"defaultChecked"in a)continue;W$2(_,u,null,f,n);}}for(u in a)f=a[u],u=="children"?m=f:u=="dangerouslySetInnerHTML"?p=f:u=="value"?v=f:u=="checked"?g=f:u==="key"||s&&typeof f!="function"||y[u]===f||W$2(_,u,f,y[u],n);if(p)s||o&&(p.__html===o.__html||p.__html===_.innerHTML)||(_.innerHTML=p.__html),e.__k=[];else if(o&&(_.innerHTML=""),ne(_,I(m)?m:[m],e,t,i,d==="foreignObject"?"http://www.w3.org/1999/xhtml":n,r,l,r?r[0]:t.__k&&C$3(t,0),s,c),r!=null)for(u=r.length;u--;)r[u]!=null&&_e(r[u]);s||(u="value",v!==void 0&&(v!==_[u]||d==="progress"&&!v||d==="option"&&v!==y[u])&&W$2(_,u,v,y[u],n),u="checked",g!==void 0&&g!==_[u]&&W$2(_,u,g,y[u],n));}return _}function q$1(_,e,t){try{if(typeof _=="function"){var i=typeof _.__u=="function";i&&_.__u(),i&&e==null||(_.__u=_(e));}else _.current=e;}catch(n){h$1.__e(n,t);}}function V(_,e,t){var i,n;if(h$1.unmount&&h$1.unmount(_),(i=_.ref)&&(i.current&&i.current!==_.__e||q$1(i,null,e)),(i=_.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount();}catch(r){h$1.__e(r,e);}i.base=i.__P=null;}if(i=_.__k)for(n=0;n<i.length;n++)i[n]&&V(i[n],e,t||typeof _.type!="function");t||_.__e==null||_e(_.__e),_.__c=_.__=_.__e=_.__d=void 0;}function ae(_,e,t){return this.constructor(_,t)}function de(_,e,t){var i,n,r,l;h$1.__&&h$1.__(_,e),n=(i="undefined"=="function")?null:e.__k,r=[],l=[],z$1(e,_=(e).__k=se(N,null,[_]),n||T$1,T$1,e.namespaceURI,n?null:e.firstChild?M$2.call(e.childNodes):null,r,n?n.__e:e.firstChild,i,l),re(r,_,l);}M$2=ee.slice,h$1={__e:function(_,e,t,i){for(var n,r,l;e=e.__;)if((n=e.__c)&&!n.__)try{if((r=n.constructor)&&r.getDerivedStateFromError!=null&&(n.setState(r.getDerivedStateFromError(_)),l=n.__d),n.componentDidCatch!=null&&(n.componentDidCatch(_,i||{}),l=n.__d),l)return n.__E=n}catch(s){_=s;}throw _}},X=0,ie=function(_){return _!=null&&_.constructor==null},F$1.prototype.setState=function(_,e){var t;t=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=b$3({},this.state),typeof _=="function"&&(_=_(b$3({},t),this.props)),_&&b$3(t,_),_!=null&&this.__v&&(e&&this._sb.push(e),B(this));},F$1.prototype.forceUpdate=function(_){this.__v&&(this.__e=true,_&&this.__h.push(_),B(this));},F$1.prototype.render=N,x$2=[],Y=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,R=function(_,e){return _.__v.__b-e.__v.__b},H$1.__r=0,j=0,$=Q(false),O=Q(true);
|
|
1129
1135
|
|
|
1130
1136
|
/* esm.sh - htm@3.1.1 */
|
|
1131
1137
|
var a$2=function(p,f,c,n){var l;f[0]=0;for(var u=1;u<f.length;u++){var g=f[u++],o=f[u]?(f[0]|=g?1:2,c[f[u++]]):f[++u];g===3?n[0]=o:g===4?n[1]=Object.assign(n[1]||{},o):g===5?(n[1]=n[1]||{})[f[++u]]=o:g===6?n[1][f[++u]]+=o+"":g?(l=p.apply(o,a$2(p,o,c,["",null])),n.push(l),o[0]?f[0]|=2:(f[u-2]=0,f[u]=l)):n.push(o);}return n},M$1=new Map;function b$2(p){var f=M$1.get(this);return f||(f=new Map,M$1.set(this,f)),(f=a$2(this,f.get(p)||(f.set(p,f=(function(c){for(var n,l,u=1,g="",o="",i=[0],s=function(v){u===1&&(v||(g=g.replace(/^\s*\n\s*|\s*\n\s*$/g,"")))?i.push(0,v,g):u===3&&(v||g)?(i.push(3,v,g),u=2):u===2&&g==="..."&&v?i.push(4,v,0):u===2&&g&&!v?i.push(5,0,true,g):u>=5&&((g||!v&&u===5)&&(i.push(u,0,g,l),u=6),v&&(i.push(u,v,0,l),u=6)),g="";},t=0;t<c.length;t++){t&&(u===1&&s(),s(t));for(var w=0;w<c[t].length;w++)n=c[t][w],u===1?n==="<"?(s(),i=[i],u=3):g+=n:u===4?g==="--"&&n===">"?(u=1,g=""):g=n+g[0]:o?n===o?o="":g+=n:n==='"'||n==="'"?o=n:n===">"?(s(),u=1):u&&(n==="="?(u=5,l=g,g=""):n==="/"&&(u<5||c[t][w+1]===">")?(s(),u===3&&(i=i[0]),u=i,(i=i[0]).push(2,0,u),u=0):n===" "||n===" "||n===`
|
|
@@ -1134,21 +1140,21 @@ var a$2=function(p,f,c,n){var l;f[0]=0;for(var u=1;u<f.length;u++){var g=f[u++],
|
|
|
1134
1140
|
/* esm.sh - htm@3.1.1/preact */
|
|
1135
1141
|
var p$3=b$2.bind(se);
|
|
1136
1142
|
|
|
1137
|
-
/* esm.sh - @preact/signals-core@1.
|
|
1138
|
-
var
|
|
1143
|
+
/* esm.sh - @preact/signals-core@1.14.1 */
|
|
1144
|
+
var C$2=Symbol.for("preact-signals");function p$2(){if(h>1)h--;else {var t,i=false;for((function(){var f=d$1;for(d$1=void 0;f!==void 0;)f.S.v===f.v&&(f.S.i=f.i),f=f.o;})();a$1!==void 0;){var o=a$1;for(a$1=void 0,c$2++;o!==void 0;){var r=o.u;if(o.u=void 0,o.f&=-3,!(8&o.f)&&b$1(o))try{o.c();}catch(f){i||(t=f,i=true);}o=r;}}if(c$2=0,h--,i)throw t}}var n=void 0;function S$2(t){var i=n;n=void 0;try{return t()}finally{n=i;}}var a$1=void 0,h=0,c$2=0,y=0,d$1=void 0,l$1=0;function m(t){if(n!==void 0){var i=t.n;if(i===void 0||i.t!==n)return i={i:0,S:t,p:n.s,n:void 0,t:n,e:void 0,x:void 0,r:i},n.s!==void 0&&(n.s.n=i),n.s=i,t.n=i,32&n.f&&t.S(i),i;if(i.i===-1)return i.i=0,i.n!==void 0&&(i.n.p=i.p,i.p!==void 0&&(i.p.n=i.n),i.p=n.s,i.n=void 0,n.s.n=i,n.s=i),i}}function s(t,i){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=i?.watched,this.Z=i?.unwatched,this.name=i?.name;}s.prototype.brand=C$2;s.prototype.h=function(){return true};s.prototype.S=function(t){var i=this,o=this.t;o!==t&&t.e===void 0&&(t.x=o,this.t=t,o!==void 0?o.e=t:S$2(function(){var r;(r=i.W)==null||r.call(i);}));};s.prototype.U=function(t){var i=this;if(this.t!==void 0){var o=t.e,r=t.x;o!==void 0&&(o.x=r,t.e=void 0),r!==void 0&&(r.e=o,t.x=void 0),t===this.t&&(this.t=r,r===void 0&&S$2(function(){var f;(f=i.Z)==null||f.call(i);}));}};s.prototype.subscribe=function(t){var i=this;return W$1(function(){var o=i.value,r=n;n=void 0;try{t(o);}finally{n=r;}},{name:"sub"})};s.prototype.valueOf=function(){return this.value};s.prototype.toString=function(){return this.value+""};s.prototype.toJSON=function(){return this.value};s.prototype.peek=function(){var t=n;n=void 0;try{return this.value}finally{n=t;}};Object.defineProperty(s.prototype,"value",{get:function(){var t=m(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(c$2>100)throw new Error("Cycle detected");((function(o){h!==0&&c$2===0&&o.l!==y&&(o.l=y,d$1={S:o,v:o.v,i:o.i,o:d$1});}))(this),this.v=t,this.i++,l$1++,h++;try{for(var i=this.t;i!==void 0;i=i.x)i.t.N();}finally{p$2();}}}});function P(t,i){return new s(t,i)}function b$1(t){for(var i=t.s;i!==void 0;i=i.n)if(i.S.i!==i.i||!i.S.h()||i.S.i!==i.i)return true;return false}function x$1(t){for(var i=t.s;i!==void 0;i=i.n){var o=i.S.n;if(o!==void 0&&(i.r=o),i.S.n=i,i.i=-1,i.n===void 0){t.s=i;break}}}function g$1(t){for(var i=t.s,o=void 0;i!==void 0;){var r=i.p;i.i===-1?(i.S.U(i),r!==void 0&&(r.n=i.n),i.n!==void 0&&(i.n.p=r)):o=i,i.S.n=i.r,i.r!==void 0&&(i.r=void 0),i=r;}t.s=o;}function v$1(t,i){s.call(this,void 0),this.x=t,this.s=void 0,this.g=l$1-1,this.f=4,this.W=i?.watched,this.Z=i?.unwatched,this.name=i?.name;}v$1.prototype=new s;v$1.prototype.h=function(){if(this.f&=-3,1&this.f)return false;if((36&this.f)==32||(this.f&=-5,this.g===l$1))return true;if(this.g=l$1,this.f|=1,this.i>0&&!b$1(this))return this.f&=-2,true;var t=n;try{x$1(this),n=this;var i=this.x();(16&this.f||this.v!==i||this.i===0)&&(this.v=i,this.f&=-17,this.i++);}catch(o){this.v=o,this.f|=16,this.i++;}return n=t,g$1(this),this.f&=-2,true};v$1.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var i=this.s;i!==void 0;i=i.n)i.S.S(i);}s.prototype.S.call(this,t);};v$1.prototype.U=function(t){if(this.t!==void 0&&(s.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var i=this.s;i!==void 0;i=i.n)i.S.U(i);}};v$1.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N();}};Object.defineProperty(v$1.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=m(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function J(t,i){return new v$1(t,i)}function E$1(t){var i=t.m;if(t.m=void 0,typeof i=="function"){h++;var o=n;n=void 0;try{i();}catch(r){throw t.f&=-2,t.f|=8,w$1(t),r}finally{n=o,p$2();}}}function w$1(t){for(var i=t.s;i!==void 0;i=i.n)i.S.U(i);t.x=void 0,t.s=void 0,E$1(t);}function k$1(t){if(n!==this)throw new Error("Out-of-order effect");g$1(this),n=t,this.f&=-2,8&this.f&&w$1(this),p$2();}function u(t,i){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=i?.name;}u.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var i=this.x();typeof i=="function"&&(this.m=i);}finally{t();}};u.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,E$1(this),x$1(this),h++;var t=n;return n=this,k$1.bind(this,t)};u.prototype.N=function(){2&this.f||(this.f|=2,this.u=a$1,a$1=this);};u.prototype.d=function(){this.f|=8,1&this.f||w$1(this);};u.prototype.dispose=function(){this.d();};function W$1(t,i){var o=new u(t,i);try{o.c();}catch(f){throw o.d(),f}var r=o.d.bind(o);return r[Symbol.dispose]=r,r}
|
|
1139
1145
|
|
|
1140
1146
|
/* esm.sh - preact@10.23.1/hooks */
|
|
1141
|
-
var c$1,r,d,b,v=0,x=[],o=h,g=o.__b,C$1=o.__r,A=o.diffed,D=o.__c,F=o.unmount,k=o.__;function l(t,_){o.__h&&o.__h(r,t,v||_),v=0;var u=r.__H||(r.__H={__:[],__h:[]});return t>=u.__.length&&u.__.push({}),u.__[t]}function z(t){return v=5,T(function(){return {current:t}},[])}function T(t,_){var u=l(c$1++,7);return E(u.__H,_)&&(u.__=t(),u.__H=_,u.__h=t),u.__}function M(t,_){return v=8,T(function(){return t},_)}function S$1(){for(var t;t=x.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(p$1),t.__H.__h.forEach(H),t.__H.__h=[];}catch(_){t.__H.__h=[],o.__e(_,t.__v);}}o.__b=function(t){r=null,g&&g(t);},o.__=function(t,_){t&&_.__k&&_.__k.__m&&(t.__m=_.__k.__m),k&&k(t,_);},o.__r=function(t){C$1&&C$1(t),c$1=0;var _=(r=t.__c).__H;_&&(d===r?(_.__h=[],r.__h=[],_.__.forEach(function(u){u.__N&&(u.__=u.__N),u.i=u.__N=void 0;})):(_.__h.forEach(p$1),_.__h.forEach(H),_.__h=[],c$1=0)),d=r;},o.diffed=function(t){A&&A(t);var _=t.__c;_&&_.__H&&(_.__H.__h.length&&(x.push(_)!==1&&b===o.requestAnimationFrame||((b=o.requestAnimationFrame)||W)(S$1)),_.__H.__.forEach(function(u){u.i&&(u.__H=u.i),u.i=void 0;})),d=r=null;},o.__c=function(t,_){_.some(function(u){try{u.__h.forEach(p$1),u.__h=u.__h.filter(function(n){return !n.__||H(n)});}catch(n){_.some(function(i){i.__h&&(i.__h=[]);}),_=[],o.__e(n,u.__v);}}),D&&D(t,_);},o.unmount=function(t){F&&F(t);var _,u=t.__c;u&&u.__H&&(u.__H.__.forEach(function(n){try{p$1(n);}catch(i){_=i;}}),u.__H=void 0,_&&o.__e(_,u.__v));};var q=typeof requestAnimationFrame=="function";function W(t){var _,u=function(){clearTimeout(n),q&&cancelAnimationFrame(_),setTimeout(t);},n=setTimeout(u,100);q&&(_=requestAnimationFrame(u));}function p$1(t){var _=r,u=t.__c;typeof u=="function"&&(t.__c=void 0,u()),r=_;}function H(t){var _=r;t.__c=t.__(),r=_;}function E(t,_){return !t||t.length!==_.length||_.some(function(u,n){return u!==t[n]})}
|
|
1147
|
+
var c$1,r,d,b,v=0,x=[],o=h$1,g=o.__b,C$1=o.__r,A=o.diffed,D=o.__c,F=o.unmount,k=o.__;function l(t,_){o.__h&&o.__h(r,t,v||_),v=0;var u=r.__H||(r.__H={__:[],__h:[]});return t>=u.__.length&&u.__.push({}),u.__[t]}function z(t){return v=5,T(function(){return {current:t}},[])}function T(t,_){var u=l(c$1++,7);return E(u.__H,_)&&(u.__=t(),u.__H=_,u.__h=t),u.__}function M(t,_){return v=8,T(function(){return t},_)}function S$1(){for(var t;t=x.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(p$1),t.__H.__h.forEach(H),t.__H.__h=[];}catch(_){t.__H.__h=[],o.__e(_,t.__v);}}o.__b=function(t){r=null,g&&g(t);},o.__=function(t,_){t&&_.__k&&_.__k.__m&&(t.__m=_.__k.__m),k&&k(t,_);},o.__r=function(t){C$1&&C$1(t),c$1=0;var _=(r=t.__c).__H;_&&(d===r?(_.__h=[],r.__h=[],_.__.forEach(function(u){u.__N&&(u.__=u.__N),u.i=u.__N=void 0;})):(_.__h.forEach(p$1),_.__h.forEach(H),_.__h=[],c$1=0)),d=r;},o.diffed=function(t){A&&A(t);var _=t.__c;_&&_.__H&&(_.__H.__h.length&&(x.push(_)!==1&&b===o.requestAnimationFrame||((b=o.requestAnimationFrame)||W)(S$1)),_.__H.__.forEach(function(u){u.i&&(u.__H=u.i),u.i=void 0;})),d=r=null;},o.__c=function(t,_){_.some(function(u){try{u.__h.forEach(p$1),u.__h=u.__h.filter(function(n){return !n.__||H(n)});}catch(n){_.some(function(i){i.__h&&(i.__h=[]);}),_=[],o.__e(n,u.__v);}}),D&&D(t,_);},o.unmount=function(t){F&&F(t);var _,u=t.__c;u&&u.__H&&(u.__H.__.forEach(function(n){try{p$1(n);}catch(i){_=i;}}),u.__H=void 0,_&&o.__e(_,u.__v));};var q=typeof requestAnimationFrame=="function";function W(t){var _,u=function(){clearTimeout(n),q&&cancelAnimationFrame(_),setTimeout(t);},n=setTimeout(u,100);q&&(_=requestAnimationFrame(u));}function p$1(t){var _=r,u=t.__c;typeof u=="function"&&(t.__c=void 0,u()),r=_;}function H(t){var _=r;t.__c=t.__(),r=_;}function E(t,_){return !t||t.length!==_.length||_.some(function(u,n){return u!==t[n]})}
|
|
1142
1148
|
|
|
1143
1149
|
/* esm.sh - @preact/signals@1.3.0 */
|
|
1144
|
-
var p;function a(e,n){h[e]=n.bind(null,h[e]||function(){});}function c(e){p&&p(),p=e&&e.S();}function S(e){var n=this,t=e.data,i=w(t);i.value=t;var u=T(function(){for(var r=n.__v;r=r.__;)if(r.__c){r.__c.__$f|=4;break}return n.__$u.c=function(){var f;!ie(u.peek())&&((f=n.base)==null?void 0:f.nodeType)===3?n.base.data=u.peek():(n.__$f|=1,n.setState({}));},
|
|
1150
|
+
var p;function a(e,n){h$1[e]=n.bind(null,h$1[e]||function(){});}function c(e){p&&p(),p=e&&e.S();}function S(e){var n=this,t=e.data,i=w(t);i.value=t;var u=T(function(){for(var r=n.__v;r=r.__;)if(r.__c){r.__c.__$f|=4;break}return n.__$u.c=function(){var f;!ie(u.peek())&&((f=n.base)==null?void 0:f.nodeType)===3?n.base.data=u.peek():(n.__$f|=1,n.setState({}));},J(function(){var f=i.value.value;return f===0?0:f===true?"":f||""})},[]);return u.value}S.displayName="_st";Object.defineProperties(s.prototype,{constructor:{configurable:true,value:void 0},type:{configurable:true,value:S},props:{configurable:true,get:function(){return {data:this}}},__b:{configurable:true,value:1}});a("__b",function(e,n){if(typeof n.type=="string"){var t,i=n.props;for(var u in i)if(u!=="children"){var r=i[u];r instanceof s&&(t||(n.__np=t={}),t[u]=r,i[u]=r.peek());}}e(n);});a("__r",function(e,n){c();var t,i=n.__c;i&&(i.__$f&=-2,(t=i.__$u)===void 0&&(i.__$u=t=(function(u){var r;return W$1(function(){r=this;}),r.c=function(){i.__$f|=1,i.setState({});},r})())),c(t),e(n);});a("__e",function(e,n,t,i){c(),e(n,t,i);});a("diffed",function(e,n){c();var t;if(typeof n.type=="string"&&(t=n.__e)){var i=n.__np,u=n.props;if(i){var r=t.U;if(r)for(var f in r){var o=r[f];o!==void 0&&!(f in i)&&(o.d(),r[f]=void 0);}else t.U=r={};for(var _ in i){var v=r[_],m=i[_];v===void 0?(v=C(t,_,m,u),r[_]=v):v.o(m,u);}}}e(n);});function C(e,n,t,i){var u=n in e&&e.ownerSVGElement===void 0,r=P(t);return {o:function(f,o){r.value=f,i=o;},d:W$1(function(){var f=r.value.value;i[n]!==f&&(i[n]=f,u?e[n]=f:f?e.setAttribute(n,f):e.removeAttribute(n));})}}a("unmount",function(e,n){if(typeof n.type=="string"){var t=n.__e;if(t){var i=t.U;if(i){t.U=void 0;for(var u in i){var r=i[u];r&&r.d();}}}}else {var f=n.__c;if(f){var o=f.__$u;o&&(f.__$u=void 0,o.d());}}e(n);});a("__h",function(e,n,t,i){(i<3||i===9)&&(n.__$f|=2),e(n,t,i);});F$1.prototype.shouldComponentUpdate=function(e,n){var t=this.__$u;if(!(t&&t.s!==void 0||4&this.__$f)||3&this.__$f)return true;for(var i in n)return true;for(var u in e)if(u!=="__source"&&e[u]!==this.props[u])return true;for(var r in this.props)if(!(r in e))return true;return false};function w(e){return T(function(){return P(e)},[])}
|
|
1145
1151
|
|
|
1146
|
-
const routesLoadingSignal =
|
|
1147
|
-
const routeLoadingErrorSignal =
|
|
1148
|
-
const routesSignal =
|
|
1152
|
+
const routesLoadingSignal = P(false);
|
|
1153
|
+
const routeLoadingErrorSignal = P(null);
|
|
1154
|
+
const routesSignal = P([]);
|
|
1149
1155
|
const NO_PACKAGE_NAME = "unknown";
|
|
1150
1156
|
|
|
1151
|
-
const repartitionsSignal =
|
|
1157
|
+
const repartitionsSignal = J(() => {
|
|
1152
1158
|
const routes = routesSignal.value;
|
|
1153
1159
|
const methodRepartition = {};
|
|
1154
1160
|
const packageRepartition = {};
|
|
@@ -1170,16 +1176,16 @@ const routesLoadingSignal = N(false);
|
|
|
1170
1176
|
packageRepartition,
|
|
1171
1177
|
};
|
|
1172
1178
|
});
|
|
1173
|
-
const methodRepartitionSignal =
|
|
1179
|
+
const methodRepartitionSignal = J(() => {
|
|
1174
1180
|
return repartitionsSignal.value.methodRepartition;
|
|
1175
1181
|
});
|
|
1176
|
-
const packageRepartitionSignal =
|
|
1182
|
+
const packageRepartitionSignal = J(() => {
|
|
1177
1183
|
return repartitionsSignal.value.packageRepartition;
|
|
1178
1184
|
});
|
|
1179
|
-
const availableMethodNamesSignal =
|
|
1185
|
+
const availableMethodNamesSignal = J(() => {
|
|
1180
1186
|
return Object.keys(methodRepartitionSignal.value);
|
|
1181
1187
|
});
|
|
1182
|
-
const availablePackageNamesSignal =
|
|
1188
|
+
const availablePackageNamesSignal = J(() => {
|
|
1183
1189
|
return Object.keys(packageRepartitionSignal.value);
|
|
1184
1190
|
});
|
|
1185
1191
|
|
|
@@ -1328,7 +1334,7 @@ const routesLoadingSignal = N(false);
|
|
|
1328
1334
|
</div>`;
|
|
1329
1335
|
};
|
|
1330
1336
|
|
|
1331
|
-
const documentUrlSignal =
|
|
1337
|
+
const documentUrlSignal = P(window.location.href);
|
|
1332
1338
|
window.addEventListener("popstate", async (popstateEvent) => {
|
|
1333
1339
|
documentUrlSignal.value = popstateEvent.target.location.href;
|
|
1334
1340
|
});
|
|
@@ -1394,7 +1400,7 @@ const routesLoadingSignal = N(false);
|
|
|
1394
1400
|
if (existingSignal) {
|
|
1395
1401
|
return existingSignal;
|
|
1396
1402
|
}
|
|
1397
|
-
const signalForFirstCall =
|
|
1403
|
+
const signalForFirstCall = J(() => {
|
|
1398
1404
|
const url = documentUrlSignal.value;
|
|
1399
1405
|
const valueInUrl = getter(url);
|
|
1400
1406
|
return valueInUrl;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IncomingForm } from "./jsenv_server_node_modules.js";
|
|
2
|
-
export { DummyParser, PersistentFile as File, JSONParser, MultipartParser, OctetStreamParser, OctetStreamParser as OctetstreamParser, PersistentFile, QuerystringParser as QueryStringParser, QuerystringParser, VolatileFile, DEFAULT_OPTIONS as defaultOptions, plugin
|
|
2
|
+
export { DummyParser, PersistentFile as File, JSONParser, MultipartParser, OctetStreamParser, OctetStreamParser as OctetstreamParser, PersistentFile, QuerystringParser as QueryStringParser, QuerystringParser, VolatileFile, DEFAULT_OPTIONS as defaultOptions, plugin as json, plugin$1 as multipart, plugin$2 as octetstream, plugin$3 as querystring } from "./jsenv_server_node_modules.js";
|
|
3
3
|
import "node:domain";
|
|
4
4
|
import "node:events";
|
|
5
5
|
import "node:fs/promises";
|
|
@@ -14,4 +14,4 @@ import "node:stream";
|
|
|
14
14
|
// if you want it access `const formidable.IncomingForm` as v1
|
|
15
15
|
const formidable = (...args) => new IncomingForm(...args);
|
|
16
16
|
|
|
17
|
-
export { IncomingForm as Formidable, IncomingForm, formidable
|
|
17
|
+
export { IncomingForm as Formidable, IncomingForm, formidable };
|
|
@@ -2846,4 +2846,4 @@ class IncomingForm extends EventEmitter {
|
|
|
2846
2846
|
}
|
|
2847
2847
|
}
|
|
2848
2848
|
|
|
2849
|
-
export { DEFAULT_OPTIONS, DummyParser, IncomingForm, JSONParser, MultipartParser$1 as MultipartParser, OctetStreamParser, PersistentFile, QuerystringParser, VolatileFile, plugin
|
|
2849
|
+
export { DEFAULT_OPTIONS, DummyParser, IncomingForm, JSONParser, MultipartParser$1 as MultipartParser, OctetStreamParser, PersistentFile, QuerystringParser, VolatileFile, plugin, plugin$1, plugin$3 as plugin$2, plugin$2 as plugin$3 };
|
package/dist/jsenv_server.js
CHANGED
|
@@ -3051,6 +3051,48 @@ const resourceToExtension = (resource) => {
|
|
|
3051
3051
|
return pathnameToExtension(pathname);
|
|
3052
3052
|
};
|
|
3053
3053
|
|
|
3054
|
+
const urlToScheme = (url) => {
|
|
3055
|
+
const urlString = String(url);
|
|
3056
|
+
const colonIndex = urlString.indexOf(":");
|
|
3057
|
+
if (colonIndex === -1) {
|
|
3058
|
+
return "";
|
|
3059
|
+
}
|
|
3060
|
+
|
|
3061
|
+
const scheme = urlString.slice(0, colonIndex);
|
|
3062
|
+
return scheme;
|
|
3063
|
+
};
|
|
3064
|
+
|
|
3065
|
+
const urlToResource = (url) => {
|
|
3066
|
+
const scheme = urlToScheme(url);
|
|
3067
|
+
|
|
3068
|
+
if (scheme === "file") {
|
|
3069
|
+
const urlAsStringWithoutFileProtocol = String(url).slice("file://".length);
|
|
3070
|
+
return urlAsStringWithoutFileProtocol;
|
|
3071
|
+
}
|
|
3072
|
+
|
|
3073
|
+
if (scheme === "https" || scheme === "http") {
|
|
3074
|
+
// remove origin
|
|
3075
|
+
const afterProtocol = String(url).slice(scheme.length + "://".length);
|
|
3076
|
+
const pathnameSlashIndex = afterProtocol.indexOf("/", "://".length);
|
|
3077
|
+
const urlAsStringWithoutOrigin = afterProtocol.slice(pathnameSlashIndex);
|
|
3078
|
+
return urlAsStringWithoutOrigin;
|
|
3079
|
+
}
|
|
3080
|
+
|
|
3081
|
+
const urlAsStringWithoutProtocol = String(url).slice(scheme.length + 1);
|
|
3082
|
+
return urlAsStringWithoutProtocol;
|
|
3083
|
+
};
|
|
3084
|
+
|
|
3085
|
+
const urlToPathname = (url) => {
|
|
3086
|
+
const resource = urlToResource(url);
|
|
3087
|
+
const pathname = resourceToPathname(resource);
|
|
3088
|
+
return pathname;
|
|
3089
|
+
};
|
|
3090
|
+
|
|
3091
|
+
const urlToExtension = (url) => {
|
|
3092
|
+
const pathname = urlToPathname(url);
|
|
3093
|
+
return pathnameToExtension(pathname);
|
|
3094
|
+
};
|
|
3095
|
+
|
|
3054
3096
|
const getCommonPathname = (pathname, otherPathname) => {
|
|
3055
3097
|
if (pathname === otherPathname) {
|
|
3056
3098
|
return pathname;
|
|
@@ -7610,6 +7652,198 @@ const jsenvServiceErrorHandler = ({ sendErrorDetails = false } = {}) => {
|
|
|
7610
7652
|
};
|
|
7611
7653
|
};
|
|
7612
7654
|
|
|
7655
|
+
class ProgressiveResponse {
|
|
7656
|
+
constructor(responseBodyHandler, { status = 200, statusText, headers } = {}) {
|
|
7657
|
+
const contentType = headers ? headers["content-type"] : "text/plain";
|
|
7658
|
+
const progressiveResponse = {
|
|
7659
|
+
status,
|
|
7660
|
+
statusText,
|
|
7661
|
+
headers,
|
|
7662
|
+
body: createObservable(({ next, complete, addTeardown }) => {
|
|
7663
|
+
// we must write something for fetch promise to resolve
|
|
7664
|
+
// this is conform to HTTP spec where client expect body to starts writing
|
|
7665
|
+
// before resolving response promise client side
|
|
7666
|
+
if (CONTENT_TYPE.isTextual(contentType)) {
|
|
7667
|
+
next("");
|
|
7668
|
+
} else {
|
|
7669
|
+
next(new Uint8Array());
|
|
7670
|
+
}
|
|
7671
|
+
const returnValue = responseBodyHandler({
|
|
7672
|
+
write: (data) => {
|
|
7673
|
+
next(data);
|
|
7674
|
+
},
|
|
7675
|
+
end: () => {
|
|
7676
|
+
complete();
|
|
7677
|
+
},
|
|
7678
|
+
});
|
|
7679
|
+
if (typeof returnValue === "function") {
|
|
7680
|
+
addTeardown(() => {
|
|
7681
|
+
returnValue();
|
|
7682
|
+
});
|
|
7683
|
+
}
|
|
7684
|
+
}),
|
|
7685
|
+
};
|
|
7686
|
+
// eslint-disable-next-line no-constructor-return
|
|
7687
|
+
return progressiveResponse;
|
|
7688
|
+
}
|
|
7689
|
+
}
|
|
7690
|
+
|
|
7691
|
+
/**
|
|
7692
|
+
* @jsenv/server is already registering a route to handle OPTIONS request
|
|
7693
|
+
* so here we just need to add the CORS headers to the response
|
|
7694
|
+
*/
|
|
7695
|
+
|
|
7696
|
+
const jsenvAccessControlAllowedHeaders = ["x-requested-with"];
|
|
7697
|
+
|
|
7698
|
+
const jsenvAccessControlAllowedMethods = [
|
|
7699
|
+
"GET",
|
|
7700
|
+
"POST",
|
|
7701
|
+
"PUT",
|
|
7702
|
+
"DELETE",
|
|
7703
|
+
"OPTIONS",
|
|
7704
|
+
];
|
|
7705
|
+
|
|
7706
|
+
const jsenvServiceCORS = ({
|
|
7707
|
+
accessControlAllowedOrigins = [],
|
|
7708
|
+
accessControlAllowedMethods = jsenvAccessControlAllowedMethods,
|
|
7709
|
+
accessControlAllowedHeaders = jsenvAccessControlAllowedHeaders,
|
|
7710
|
+
accessControlAllowRequestOrigin = false,
|
|
7711
|
+
accessControlAllowRequestMethod = false,
|
|
7712
|
+
accessControlAllowRequestHeaders = false,
|
|
7713
|
+
accessControlAllowCredentials = false,
|
|
7714
|
+
// by default OPTIONS request can be cache for a long time, it's not going to change soon ?
|
|
7715
|
+
// we could put a lot here, see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age
|
|
7716
|
+
accessControlMaxAge = 600,
|
|
7717
|
+
timingAllowOrigin = false,
|
|
7718
|
+
} = {}) => {
|
|
7719
|
+
// TODO: we should check access control params and throw/warn if we find strange values
|
|
7720
|
+
|
|
7721
|
+
const corsEnabled =
|
|
7722
|
+
accessControlAllowRequestOrigin || accessControlAllowedOrigins.length;
|
|
7723
|
+
|
|
7724
|
+
if (!corsEnabled) {
|
|
7725
|
+
return [];
|
|
7726
|
+
}
|
|
7727
|
+
|
|
7728
|
+
return {
|
|
7729
|
+
name: "jsenv:cors",
|
|
7730
|
+
injectResponseProperties: (request) => {
|
|
7731
|
+
const accessControlHeaders = generateAccessControlHeaders({
|
|
7732
|
+
request,
|
|
7733
|
+
accessControlAllowedOrigins,
|
|
7734
|
+
accessControlAllowRequestOrigin,
|
|
7735
|
+
accessControlAllowedMethods,
|
|
7736
|
+
accessControlAllowRequestMethod,
|
|
7737
|
+
accessControlAllowedHeaders,
|
|
7738
|
+
accessControlAllowRequestHeaders,
|
|
7739
|
+
accessControlAllowCredentials,
|
|
7740
|
+
accessControlMaxAge,
|
|
7741
|
+
timingAllowOrigin,
|
|
7742
|
+
});
|
|
7743
|
+
return {
|
|
7744
|
+
headers: accessControlHeaders,
|
|
7745
|
+
};
|
|
7746
|
+
},
|
|
7747
|
+
};
|
|
7748
|
+
};
|
|
7749
|
+
|
|
7750
|
+
// https://www.w3.org/TR/cors/
|
|
7751
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
|
7752
|
+
const generateAccessControlHeaders = ({
|
|
7753
|
+
request: { headers },
|
|
7754
|
+
accessControlAllowedOrigins,
|
|
7755
|
+
accessControlAllowRequestOrigin,
|
|
7756
|
+
accessControlAllowedMethods,
|
|
7757
|
+
accessControlAllowRequestMethod,
|
|
7758
|
+
accessControlAllowedHeaders,
|
|
7759
|
+
accessControlAllowRequestHeaders,
|
|
7760
|
+
accessControlAllowCredentials,
|
|
7761
|
+
// by default OPTIONS request can be cache for a long time, it's not going to change soon ?
|
|
7762
|
+
// we could put a lot here, see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age
|
|
7763
|
+
accessControlMaxAge = 600,
|
|
7764
|
+
timingAllowOrigin,
|
|
7765
|
+
} = {}) => {
|
|
7766
|
+
const vary = [];
|
|
7767
|
+
|
|
7768
|
+
const allowedOriginArray = [...accessControlAllowedOrigins];
|
|
7769
|
+
if (accessControlAllowRequestOrigin) {
|
|
7770
|
+
if ("origin" in headers && headers.origin !== "null") {
|
|
7771
|
+
allowedOriginArray.push(headers.origin);
|
|
7772
|
+
vary.push("origin");
|
|
7773
|
+
} else if ("referer" in headers) {
|
|
7774
|
+
allowedOriginArray.push(new URL(headers.referer).origin);
|
|
7775
|
+
vary.push("referer");
|
|
7776
|
+
} else {
|
|
7777
|
+
allowedOriginArray.push("*");
|
|
7778
|
+
}
|
|
7779
|
+
}
|
|
7780
|
+
|
|
7781
|
+
const allowedMethodArray = [...accessControlAllowedMethods];
|
|
7782
|
+
if (
|
|
7783
|
+
accessControlAllowRequestMethod &&
|
|
7784
|
+
"access-control-request-method" in headers
|
|
7785
|
+
) {
|
|
7786
|
+
const requestMethodName = headers["access-control-request-method"];
|
|
7787
|
+
if (!allowedMethodArray.includes(requestMethodName)) {
|
|
7788
|
+
allowedMethodArray.push(requestMethodName);
|
|
7789
|
+
vary.push("access-control-request-method");
|
|
7790
|
+
}
|
|
7791
|
+
}
|
|
7792
|
+
|
|
7793
|
+
const allowedHeaderArray = [...accessControlAllowedHeaders];
|
|
7794
|
+
if (
|
|
7795
|
+
accessControlAllowRequestHeaders &&
|
|
7796
|
+
"access-control-request-headers" in headers
|
|
7797
|
+
) {
|
|
7798
|
+
const requestHeaderNameArray =
|
|
7799
|
+
headers["access-control-request-headers"].split(", ");
|
|
7800
|
+
requestHeaderNameArray.forEach((headerName) => {
|
|
7801
|
+
const headerNameLowerCase = headerName.toLowerCase();
|
|
7802
|
+
if (!allowedHeaderArray.includes(headerNameLowerCase)) {
|
|
7803
|
+
allowedHeaderArray.push(headerNameLowerCase);
|
|
7804
|
+
if (!vary.includes("access-control-request-headers")) {
|
|
7805
|
+
vary.push("access-control-request-headers");
|
|
7806
|
+
}
|
|
7807
|
+
}
|
|
7808
|
+
});
|
|
7809
|
+
}
|
|
7810
|
+
|
|
7811
|
+
return {
|
|
7812
|
+
"access-control-allow-origin": allowedOriginArray.join(", "),
|
|
7813
|
+
"access-control-allow-methods": allowedMethodArray.join(", "),
|
|
7814
|
+
"access-control-allow-headers": allowedHeaderArray.join(", "),
|
|
7815
|
+
...(accessControlAllowCredentials
|
|
7816
|
+
? { "access-control-allow-credentials": true }
|
|
7817
|
+
: {}),
|
|
7818
|
+
"access-control-max-age": accessControlMaxAge,
|
|
7819
|
+
...(timingAllowOrigin
|
|
7820
|
+
? { "timing-allow-origin": allowedOriginArray.join(", ") }
|
|
7821
|
+
: {}),
|
|
7822
|
+
...(vary.length ? { vary: vary.join(", ") } : {}),
|
|
7823
|
+
};
|
|
7824
|
+
};
|
|
7825
|
+
|
|
7826
|
+
const ETAG_FOR_EMPTY_CONTENT = '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"';
|
|
7827
|
+
|
|
7828
|
+
const bufferToEtag = (buffer) => {
|
|
7829
|
+
if (!Buffer.isBuffer(buffer)) {
|
|
7830
|
+
throw new TypeError(`buffer expect,got ${buffer}`);
|
|
7831
|
+
}
|
|
7832
|
+
|
|
7833
|
+
if (buffer.length === 0) {
|
|
7834
|
+
return ETAG_FOR_EMPTY_CONTENT;
|
|
7835
|
+
}
|
|
7836
|
+
|
|
7837
|
+
const hash = createHash("sha1");
|
|
7838
|
+
hash.update(buffer, "utf8");
|
|
7839
|
+
|
|
7840
|
+
const hashBase64String = hash.digest("base64");
|
|
7841
|
+
const hashBase64StringSubset = hashBase64String.slice(0, 27);
|
|
7842
|
+
const length = buffer.length;
|
|
7843
|
+
|
|
7844
|
+
return `"${length.toString(16)}-${hashBase64StringSubset}"`;
|
|
7845
|
+
};
|
|
7846
|
+
|
|
7613
7847
|
const convertFileSystemErrorToResponseProperties = (error) => {
|
|
7614
7848
|
// https://iojs.org/api/errors.html#errors_eacces_permission_denied
|
|
7615
7849
|
if (isErrorWithCode(error, "EACCES")) {
|
|
@@ -7664,27 +7898,6 @@ const isErrorWithCode = (error, code) => {
|
|
|
7664
7898
|
return typeof error === "object" && error.code === code;
|
|
7665
7899
|
};
|
|
7666
7900
|
|
|
7667
|
-
const ETAG_FOR_EMPTY_CONTENT = '"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"';
|
|
7668
|
-
|
|
7669
|
-
const bufferToEtag = (buffer) => {
|
|
7670
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
7671
|
-
throw new TypeError(`buffer expect,got ${buffer}`);
|
|
7672
|
-
}
|
|
7673
|
-
|
|
7674
|
-
if (buffer.length === 0) {
|
|
7675
|
-
return ETAG_FOR_EMPTY_CONTENT;
|
|
7676
|
-
}
|
|
7677
|
-
|
|
7678
|
-
const hash = createHash("sha1");
|
|
7679
|
-
hash.update(buffer, "utf8");
|
|
7680
|
-
|
|
7681
|
-
const hashBase64String = hash.digest("base64");
|
|
7682
|
-
const hashBase64StringSubset = hashBase64String.slice(0, 27);
|
|
7683
|
-
const length = buffer.length;
|
|
7684
|
-
|
|
7685
|
-
return `"${length.toString(16)}-${hashBase64StringSubset}"`;
|
|
7686
|
-
};
|
|
7687
|
-
|
|
7688
7901
|
const isFileSystemPath = (value) => {
|
|
7689
7902
|
if (typeof value !== "string") {
|
|
7690
7903
|
throw new TypeError(
|
|
@@ -8223,176 +8436,45 @@ const asUrlString = (value) => {
|
|
|
8223
8436
|
return null;
|
|
8224
8437
|
};
|
|
8225
8438
|
|
|
8226
|
-
|
|
8227
|
-
constructor(responseBodyHandler, { status = 200, statusText, headers } = {}) {
|
|
8228
|
-
const contentType = headers ? headers["content-type"] : "text/plain";
|
|
8229
|
-
const progressiveResponse = {
|
|
8230
|
-
status,
|
|
8231
|
-
statusText,
|
|
8232
|
-
headers,
|
|
8233
|
-
body: createObservable(({ next, complete, addTeardown }) => {
|
|
8234
|
-
// we must write something for fetch promise to resolve
|
|
8235
|
-
// this is conform to HTTP spec where client expect body to starts writing
|
|
8236
|
-
// before resolving response promise client side
|
|
8237
|
-
if (CONTENT_TYPE.isTextual(contentType)) {
|
|
8238
|
-
next("");
|
|
8239
|
-
} else {
|
|
8240
|
-
next(new Uint8Array());
|
|
8241
|
-
}
|
|
8242
|
-
const returnValue = responseBodyHandler({
|
|
8243
|
-
write: (data) => {
|
|
8244
|
-
next(data);
|
|
8245
|
-
},
|
|
8246
|
-
end: () => {
|
|
8247
|
-
complete();
|
|
8248
|
-
},
|
|
8249
|
-
});
|
|
8250
|
-
if (typeof returnValue === "function") {
|
|
8251
|
-
addTeardown(() => {
|
|
8252
|
-
returnValue();
|
|
8253
|
-
});
|
|
8254
|
-
}
|
|
8255
|
-
}),
|
|
8256
|
-
};
|
|
8257
|
-
// eslint-disable-next-line no-constructor-return
|
|
8258
|
-
return progressiveResponse;
|
|
8259
|
-
}
|
|
8260
|
-
}
|
|
8261
|
-
|
|
8262
|
-
/**
|
|
8263
|
-
* @jsenv/server is already registering a route to handle OPTIONS request
|
|
8264
|
-
* so here we just need to add the CORS headers to the response
|
|
8265
|
-
*/
|
|
8266
|
-
|
|
8267
|
-
const jsenvAccessControlAllowedHeaders = ["x-requested-with"];
|
|
8268
|
-
|
|
8269
|
-
const jsenvAccessControlAllowedMethods = [
|
|
8270
|
-
"GET",
|
|
8271
|
-
"POST",
|
|
8272
|
-
"PUT",
|
|
8273
|
-
"DELETE",
|
|
8274
|
-
"OPTIONS",
|
|
8275
|
-
];
|
|
8276
|
-
|
|
8277
|
-
const jsenvServiceCORS = ({
|
|
8278
|
-
accessControlAllowedOrigins = [],
|
|
8279
|
-
accessControlAllowedMethods = jsenvAccessControlAllowedMethods,
|
|
8280
|
-
accessControlAllowedHeaders = jsenvAccessControlAllowedHeaders,
|
|
8281
|
-
accessControlAllowRequestOrigin = false,
|
|
8282
|
-
accessControlAllowRequestMethod = false,
|
|
8283
|
-
accessControlAllowRequestHeaders = false,
|
|
8284
|
-
accessControlAllowCredentials = false,
|
|
8285
|
-
// by default OPTIONS request can be cache for a long time, it's not going to change soon ?
|
|
8286
|
-
// we could put a lot here, see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age
|
|
8287
|
-
accessControlMaxAge = 600,
|
|
8288
|
-
timingAllowOrigin = false,
|
|
8289
|
-
} = {}) => {
|
|
8290
|
-
// TODO: we should check access control params and throw/warn if we find strange values
|
|
8291
|
-
|
|
8292
|
-
const corsEnabled =
|
|
8293
|
-
accessControlAllowRequestOrigin || accessControlAllowedOrigins.length;
|
|
8294
|
-
|
|
8295
|
-
if (!corsEnabled) {
|
|
8296
|
-
return [];
|
|
8297
|
-
}
|
|
8298
|
-
|
|
8299
|
-
return {
|
|
8300
|
-
name: "jsenv:cors",
|
|
8301
|
-
injectResponseProperties: (request) => {
|
|
8302
|
-
const accessControlHeaders = generateAccessControlHeaders({
|
|
8303
|
-
request,
|
|
8304
|
-
accessControlAllowedOrigins,
|
|
8305
|
-
accessControlAllowRequestOrigin,
|
|
8306
|
-
accessControlAllowedMethods,
|
|
8307
|
-
accessControlAllowRequestMethod,
|
|
8308
|
-
accessControlAllowedHeaders,
|
|
8309
|
-
accessControlAllowRequestHeaders,
|
|
8310
|
-
accessControlAllowCredentials,
|
|
8311
|
-
accessControlMaxAge,
|
|
8312
|
-
timingAllowOrigin,
|
|
8313
|
-
});
|
|
8314
|
-
return {
|
|
8315
|
-
headers: accessControlHeaders,
|
|
8316
|
-
};
|
|
8317
|
-
},
|
|
8318
|
-
};
|
|
8319
|
-
};
|
|
8320
|
-
|
|
8321
|
-
// https://www.w3.org/TR/cors/
|
|
8322
|
-
// https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
|
|
8323
|
-
const generateAccessControlHeaders = ({
|
|
8324
|
-
request: { headers },
|
|
8325
|
-
accessControlAllowedOrigins,
|
|
8326
|
-
accessControlAllowRequestOrigin,
|
|
8327
|
-
accessControlAllowedMethods,
|
|
8328
|
-
accessControlAllowRequestMethod,
|
|
8329
|
-
accessControlAllowedHeaders,
|
|
8330
|
-
accessControlAllowRequestHeaders,
|
|
8331
|
-
accessControlAllowCredentials,
|
|
8332
|
-
// by default OPTIONS request can be cache for a long time, it's not going to change soon ?
|
|
8333
|
-
// we could put a lot here, see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age
|
|
8334
|
-
accessControlMaxAge = 600,
|
|
8335
|
-
timingAllowOrigin,
|
|
8336
|
-
} = {}) => {
|
|
8337
|
-
const vary = [];
|
|
8338
|
-
|
|
8339
|
-
const allowedOriginArray = [...accessControlAllowedOrigins];
|
|
8340
|
-
if (accessControlAllowRequestOrigin) {
|
|
8341
|
-
if ("origin" in headers && headers.origin !== "null") {
|
|
8342
|
-
allowedOriginArray.push(headers.origin);
|
|
8343
|
-
vary.push("origin");
|
|
8344
|
-
} else if ("referer" in headers) {
|
|
8345
|
-
allowedOriginArray.push(new URL(headers.referer).origin);
|
|
8346
|
-
vary.push("referer");
|
|
8347
|
-
} else {
|
|
8348
|
-
allowedOriginArray.push("*");
|
|
8349
|
-
}
|
|
8350
|
-
}
|
|
8351
|
-
|
|
8352
|
-
const allowedMethodArray = [...accessControlAllowedMethods];
|
|
8353
|
-
if (
|
|
8354
|
-
accessControlAllowRequestMethod &&
|
|
8355
|
-
"access-control-request-method" in headers
|
|
8356
|
-
) {
|
|
8357
|
-
const requestMethodName = headers["access-control-request-method"];
|
|
8358
|
-
if (!allowedMethodArray.includes(requestMethodName)) {
|
|
8359
|
-
allowedMethodArray.push(requestMethodName);
|
|
8360
|
-
vary.push("access-control-request-method");
|
|
8361
|
-
}
|
|
8362
|
-
}
|
|
8363
|
-
|
|
8364
|
-
const allowedHeaderArray = [...accessControlAllowedHeaders];
|
|
8365
|
-
if (
|
|
8366
|
-
accessControlAllowRequestHeaders &&
|
|
8367
|
-
"access-control-request-headers" in headers
|
|
8368
|
-
) {
|
|
8369
|
-
const requestHeaderNameArray =
|
|
8370
|
-
headers["access-control-request-headers"].split(", ");
|
|
8371
|
-
requestHeaderNameArray.forEach((headerName) => {
|
|
8372
|
-
const headerNameLowerCase = headerName.toLowerCase();
|
|
8373
|
-
if (!allowedHeaderArray.includes(headerNameLowerCase)) {
|
|
8374
|
-
allowedHeaderArray.push(headerNameLowerCase);
|
|
8375
|
-
if (!vary.includes("access-control-request-headers")) {
|
|
8376
|
-
vary.push("access-control-request-headers");
|
|
8377
|
-
}
|
|
8378
|
-
}
|
|
8379
|
-
});
|
|
8380
|
-
}
|
|
8381
|
-
|
|
8439
|
+
const jsenvServiceStaticFiles = ({ directoryUrl, mainFilePath }) => {
|
|
8382
8440
|
return {
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
8393
|
-
|
|
8441
|
+
name: "jsenv:file_service",
|
|
8442
|
+
routes: [
|
|
8443
|
+
{
|
|
8444
|
+
endpoint: "GET *",
|
|
8445
|
+
description: "Serve static files.",
|
|
8446
|
+
fetch: (request, helpers) => {
|
|
8447
|
+
const urlIsVersioned = new URL(request.url).searchParams.has("v");
|
|
8448
|
+
if (mainFilePath && request.resource === "/") {
|
|
8449
|
+
request = {
|
|
8450
|
+
...request,
|
|
8451
|
+
resource: `/${mainFilePath}`,
|
|
8452
|
+
};
|
|
8453
|
+
}
|
|
8454
|
+
const urlObject = new URL(request.resource.slice(1), directoryUrl);
|
|
8455
|
+
return createFileSystemFetch(directoryUrl, {
|
|
8456
|
+
cacheControl: urlIsVersioned
|
|
8457
|
+
? `private,max-age=${SECONDS_IN_30_DAYS},immutable`
|
|
8458
|
+
: "private,max-age=0,must-revalidate",
|
|
8459
|
+
etagEnabled: true,
|
|
8460
|
+
compressionEnabled: true,
|
|
8461
|
+
canReadDirectory: true,
|
|
8462
|
+
ENOENTFallback: () => {
|
|
8463
|
+
if (
|
|
8464
|
+
!urlToExtension(urlObject) &&
|
|
8465
|
+
!urlToPathname(urlObject).endsWith("/")
|
|
8466
|
+
) {
|
|
8467
|
+
return new URL(mainFilePath, directoryUrl);
|
|
8468
|
+
}
|
|
8469
|
+
return null;
|
|
8470
|
+
},
|
|
8471
|
+
})(request, helpers);
|
|
8472
|
+
},
|
|
8473
|
+
},
|
|
8474
|
+
],
|
|
8394
8475
|
};
|
|
8395
8476
|
};
|
|
8477
|
+
const SECONDS_IN_30_DAYS = 60 * 60 * 24 * 30;
|
|
8396
8478
|
|
|
8397
8479
|
const jsenvServiceResponseAcceptanceCheck = () => {
|
|
8398
8480
|
return {
|
|
@@ -8483,4 +8565,4 @@ const replaceResource = (resourceBeforeAlias, newValue) => {
|
|
|
8483
8565
|
return resource;
|
|
8484
8566
|
};
|
|
8485
8567
|
|
|
8486
|
-
export { LazyServerEvents, ProgressiveResponse, STOP_REASON_INTERNAL_ERROR, STOP_REASON_NOT_SPECIFIED, STOP_REASON_PROCESS_BEFORE_EXIT, STOP_REASON_PROCESS_EXIT, STOP_REASON_PROCESS_SIGHUP, STOP_REASON_PROCESS_SIGINT, STOP_REASON_PROCESS_SIGTERM, ServerEvents, WebSocketResponse, composeTwoResponses, createFileSystemFetch, fetchFileSystem, findFreePort, jsenvAccessControlAllowedHeaders, jsenvAccessControlAllowedMethods, jsenvServiceCORS, jsenvServiceErrorHandler, jsenvServiceRequestAliases, jsenvServiceResponseAcceptanceCheck, pickContentEncoding, pickContentLanguage, pickContentType, serveDirectory, startServer };
|
|
8568
|
+
export { LazyServerEvents, ProgressiveResponse, STOP_REASON_INTERNAL_ERROR, STOP_REASON_NOT_SPECIFIED, STOP_REASON_PROCESS_BEFORE_EXIT, STOP_REASON_PROCESS_EXIT, STOP_REASON_PROCESS_SIGHUP, STOP_REASON_PROCESS_SIGINT, STOP_REASON_PROCESS_SIGTERM, ServerEvents, WebSocketResponse, composeTwoResponses, createFileSystemFetch, fetchFileSystem, findFreePort, jsenvAccessControlAllowedHeaders, jsenvAccessControlAllowedMethods, jsenvServiceCORS, jsenvServiceErrorHandler, jsenvServiceRequestAliases, jsenvServiceResponseAcceptanceCheck, jsenvServiceStaticFiles, pickContentEncoding, pickContentLanguage, pickContentType, serveDirectory, startServer };
|
package/dist/ws/ws.js
CHANGED
|
@@ -29,6 +29,7 @@ function requireConstants () {
|
|
|
29
29
|
|
|
30
30
|
constants = {
|
|
31
31
|
BINARY_TYPES,
|
|
32
|
+
CLOSE_TIMEOUT: 30000,
|
|
32
33
|
EMPTY_BUFFER: Buffer.alloc(0),
|
|
33
34
|
GUID: '258EAFA5-E914-47DA-95CA-C5AB0DC85B11',
|
|
34
35
|
hasBlob,
|
|
@@ -242,11 +243,11 @@ function requireLimiter () {
|
|
|
242
243
|
return limiter;
|
|
243
244
|
}
|
|
244
245
|
|
|
245
|
-
var permessageDeflate;
|
|
246
|
+
var permessageDeflate$1;
|
|
246
247
|
var hasRequiredPermessageDeflate;
|
|
247
248
|
|
|
248
249
|
function requirePermessageDeflate () {
|
|
249
|
-
if (hasRequiredPermessageDeflate) return permessageDeflate;
|
|
250
|
+
if (hasRequiredPermessageDeflate) return permessageDeflate$1;
|
|
250
251
|
hasRequiredPermessageDeflate = 1;
|
|
251
252
|
|
|
252
253
|
const zlib = require$$0;
|
|
@@ -286,6 +287,9 @@ function requirePermessageDeflate () {
|
|
|
286
287
|
* acknowledge disabling of client context takeover
|
|
287
288
|
* @param {Number} [options.concurrencyLimit=10] The number of concurrent
|
|
288
289
|
* calls to zlib
|
|
290
|
+
* @param {Boolean} [options.isServer=false] Create the instance in either
|
|
291
|
+
* server or client mode
|
|
292
|
+
* @param {Number} [options.maxPayload=0] The maximum allowed message length
|
|
289
293
|
* @param {(Boolean|Number)} [options.serverMaxWindowBits] Request/confirm the
|
|
290
294
|
* use of a custom server window size
|
|
291
295
|
* @param {Boolean} [options.serverNoContextTakeover=false] Request/accept
|
|
@@ -296,16 +300,13 @@ function requirePermessageDeflate () {
|
|
|
296
300
|
* deflate
|
|
297
301
|
* @param {Object} [options.zlibInflateOptions] Options to pass to zlib on
|
|
298
302
|
* inflate
|
|
299
|
-
* @param {Boolean} [isServer=false] Create the instance in either server or
|
|
300
|
-
* client mode
|
|
301
|
-
* @param {Number} [maxPayload=0] The maximum allowed message length
|
|
302
303
|
*/
|
|
303
|
-
constructor(options
|
|
304
|
-
this._maxPayload = maxPayload | 0;
|
|
304
|
+
constructor(options) {
|
|
305
305
|
this._options = options || {};
|
|
306
306
|
this._threshold =
|
|
307
307
|
this._options.threshold !== undefined ? this._options.threshold : 1024;
|
|
308
|
-
this.
|
|
308
|
+
this._maxPayload = this._options.maxPayload | 0;
|
|
309
|
+
this._isServer = !!this._options.isServer;
|
|
309
310
|
this._deflate = null;
|
|
310
311
|
this._inflate = null;
|
|
311
312
|
|
|
@@ -709,7 +710,7 @@ function requirePermessageDeflate () {
|
|
|
709
710
|
}
|
|
710
711
|
}
|
|
711
712
|
|
|
712
|
-
permessageDeflate = PerMessageDeflate;
|
|
713
|
+
permessageDeflate$1 = PerMessageDeflate;
|
|
713
714
|
|
|
714
715
|
/**
|
|
715
716
|
* The listener of the `zlib.DeflateRaw` stream `'data'` event.
|
|
@@ -775,7 +776,7 @@ function requirePermessageDeflate () {
|
|
|
775
776
|
err[kStatusCode] = 1007;
|
|
776
777
|
this[kCallback](err);
|
|
777
778
|
}
|
|
778
|
-
return permessageDeflate;
|
|
779
|
+
return permessageDeflate$1;
|
|
779
780
|
}
|
|
780
781
|
|
|
781
782
|
var validation = {exports: {}};
|
|
@@ -2563,11 +2564,11 @@ function requireEventTarget () {
|
|
|
2563
2564
|
return eventTarget;
|
|
2564
2565
|
}
|
|
2565
2566
|
|
|
2566
|
-
var extension;
|
|
2567
|
+
var extension$1;
|
|
2567
2568
|
var hasRequiredExtension;
|
|
2568
2569
|
|
|
2569
2570
|
function requireExtension () {
|
|
2570
|
-
if (hasRequiredExtension) return extension;
|
|
2571
|
+
if (hasRequiredExtension) return extension$1;
|
|
2571
2572
|
hasRequiredExtension = 1;
|
|
2572
2573
|
|
|
2573
2574
|
const { tokenChars } = requireValidation();
|
|
@@ -2770,8 +2771,8 @@ function requireExtension () {
|
|
|
2770
2771
|
.join(', ');
|
|
2771
2772
|
}
|
|
2772
2773
|
|
|
2773
|
-
extension = { format, parse };
|
|
2774
|
-
return extension;
|
|
2774
|
+
extension$1 = { format, parse };
|
|
2775
|
+
return extension$1;
|
|
2775
2776
|
}
|
|
2776
2777
|
|
|
2777
2778
|
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex|Readable$", "caughtErrors": "none" }] */
|
|
@@ -2799,6 +2800,7 @@ function requireWebsocket () {
|
|
|
2799
2800
|
|
|
2800
2801
|
const {
|
|
2801
2802
|
BINARY_TYPES,
|
|
2803
|
+
CLOSE_TIMEOUT,
|
|
2802
2804
|
EMPTY_BUFFER,
|
|
2803
2805
|
GUID,
|
|
2804
2806
|
kForOnEventAttribute,
|
|
@@ -2813,7 +2815,6 @@ function requireWebsocket () {
|
|
|
2813
2815
|
const { format, parse } = requireExtension();
|
|
2814
2816
|
const { toBuffer } = requireBufferUtil();
|
|
2815
2817
|
|
|
2816
|
-
const closeTimeout = 30 * 1000;
|
|
2817
2818
|
const kAborted = Symbol('kAborted');
|
|
2818
2819
|
const protocolVersions = [8, 13];
|
|
2819
2820
|
const readyStates = ['CONNECTING', 'OPEN', 'CLOSING', 'CLOSED'];
|
|
@@ -2869,6 +2870,7 @@ function requireWebsocket () {
|
|
|
2869
2870
|
initAsClient(this, address, protocols, options);
|
|
2870
2871
|
} else {
|
|
2871
2872
|
this._autoPong = options.autoPong;
|
|
2873
|
+
this._closeTimeout = options.closeTimeout;
|
|
2872
2874
|
this._isServer = true;
|
|
2873
2875
|
}
|
|
2874
2876
|
}
|
|
@@ -3410,6 +3412,8 @@ function requireWebsocket () {
|
|
|
3410
3412
|
* times in the same tick
|
|
3411
3413
|
* @param {Boolean} [options.autoPong=true] Specifies whether or not to
|
|
3412
3414
|
* automatically send a pong in response to a ping
|
|
3415
|
+
* @param {Number} [options.closeTimeout=30000] Duration in milliseconds to wait
|
|
3416
|
+
* for the closing handshake to finish after `websocket.close()` is called
|
|
3413
3417
|
* @param {Function} [options.finishRequest] A function which can be used to
|
|
3414
3418
|
* customize the headers of each http request before it is sent
|
|
3415
3419
|
* @param {Boolean} [options.followRedirects=false] Whether or not to follow
|
|
@@ -3436,6 +3440,7 @@ function requireWebsocket () {
|
|
|
3436
3440
|
const opts = {
|
|
3437
3441
|
allowSynchronousEvents: true,
|
|
3438
3442
|
autoPong: true,
|
|
3443
|
+
closeTimeout: CLOSE_TIMEOUT,
|
|
3439
3444
|
protocolVersion: protocolVersions[1],
|
|
3440
3445
|
maxPayload: 100 * 1024 * 1024,
|
|
3441
3446
|
skipUTF8Validation: false,
|
|
@@ -3454,6 +3459,7 @@ function requireWebsocket () {
|
|
|
3454
3459
|
};
|
|
3455
3460
|
|
|
3456
3461
|
websocket._autoPong = opts.autoPong;
|
|
3462
|
+
websocket._closeTimeout = opts.closeTimeout;
|
|
3457
3463
|
|
|
3458
3464
|
if (!protocolVersions.includes(opts.protocolVersion)) {
|
|
3459
3465
|
throw new RangeError(
|
|
@@ -3469,7 +3475,7 @@ function requireWebsocket () {
|
|
|
3469
3475
|
} else {
|
|
3470
3476
|
try {
|
|
3471
3477
|
parsedUrl = new URL(address);
|
|
3472
|
-
} catch
|
|
3478
|
+
} catch {
|
|
3473
3479
|
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
3474
3480
|
}
|
|
3475
3481
|
}
|
|
@@ -3531,11 +3537,11 @@ function requireWebsocket () {
|
|
|
3531
3537
|
opts.timeout = opts.handshakeTimeout;
|
|
3532
3538
|
|
|
3533
3539
|
if (opts.perMessageDeflate) {
|
|
3534
|
-
perMessageDeflate = new PerMessageDeflate(
|
|
3535
|
-
opts.perMessageDeflate
|
|
3536
|
-
false,
|
|
3537
|
-
opts.maxPayload
|
|
3538
|
-
);
|
|
3540
|
+
perMessageDeflate = new PerMessageDeflate({
|
|
3541
|
+
...opts.perMessageDeflate,
|
|
3542
|
+
isServer: false,
|
|
3543
|
+
maxPayload: opts.maxPayload
|
|
3544
|
+
});
|
|
3539
3545
|
opts.headers['Sec-WebSocket-Extensions'] = format({
|
|
3540
3546
|
[PerMessageDeflate.extensionName]: perMessageDeflate.offer()
|
|
3541
3547
|
});
|
|
@@ -4071,7 +4077,7 @@ function requireWebsocket () {
|
|
|
4071
4077
|
function setCloseTimer(websocket) {
|
|
4072
4078
|
websocket._closeTimer = setTimeout(
|
|
4073
4079
|
websocket._socket.destroy.bind(websocket._socket),
|
|
4074
|
-
|
|
4080
|
+
websocket._closeTimeout
|
|
4075
4081
|
);
|
|
4076
4082
|
}
|
|
4077
4083
|
|
|
@@ -4089,23 +4095,23 @@ function requireWebsocket () {
|
|
|
4089
4095
|
|
|
4090
4096
|
websocket._readyState = WebSocket.CLOSING;
|
|
4091
4097
|
|
|
4092
|
-
let chunk;
|
|
4093
|
-
|
|
4094
4098
|
//
|
|
4095
4099
|
// The close frame might not have been received or the `'end'` event emitted,
|
|
4096
4100
|
// for example, if the socket was destroyed due to an error. Ensure that the
|
|
4097
4101
|
// `receiver` stream is closed after writing any remaining buffered data to
|
|
4098
4102
|
// it. If the readable side of the socket is in flowing mode then there is no
|
|
4099
|
-
// buffered data as everything has been already written
|
|
4100
|
-
//
|
|
4101
|
-
//
|
|
4103
|
+
// buffered data as everything has been already written. If instead, the
|
|
4104
|
+
// socket is paused, any possible buffered data will be read as a single
|
|
4105
|
+
// chunk.
|
|
4102
4106
|
//
|
|
4103
4107
|
if (
|
|
4104
4108
|
!this._readableState.endEmitted &&
|
|
4105
4109
|
!websocket._closeFrameReceived &&
|
|
4106
4110
|
!websocket._receiver._writableState.errorEmitted &&
|
|
4107
|
-
|
|
4111
|
+
this._readableState.length !== 0
|
|
4108
4112
|
) {
|
|
4113
|
+
const chunk = this.read(this._readableState.length);
|
|
4114
|
+
|
|
4109
4115
|
websocket._receiver.write(chunk);
|
|
4110
4116
|
}
|
|
4111
4117
|
|
|
@@ -4342,17 +4348,19 @@ function requireStream () {
|
|
|
4342
4348
|
|
|
4343
4349
|
requireStream();
|
|
4344
4350
|
|
|
4351
|
+
requireExtension();
|
|
4352
|
+
|
|
4353
|
+
requirePermessageDeflate();
|
|
4354
|
+
|
|
4345
4355
|
requireReceiver();
|
|
4346
4356
|
|
|
4347
4357
|
requireSender();
|
|
4348
4358
|
|
|
4349
|
-
|
|
4350
|
-
|
|
4351
|
-
var subprotocol;
|
|
4359
|
+
var subprotocol$1;
|
|
4352
4360
|
var hasRequiredSubprotocol;
|
|
4353
4361
|
|
|
4354
4362
|
function requireSubprotocol () {
|
|
4355
|
-
if (hasRequiredSubprotocol) return subprotocol;
|
|
4363
|
+
if (hasRequiredSubprotocol) return subprotocol$1;
|
|
4356
4364
|
hasRequiredSubprotocol = 1;
|
|
4357
4365
|
|
|
4358
4366
|
const { tokenChars } = requireValidation();
|
|
@@ -4414,10 +4422,14 @@ function requireSubprotocol () {
|
|
|
4414
4422
|
return protocols;
|
|
4415
4423
|
}
|
|
4416
4424
|
|
|
4417
|
-
subprotocol = { parse };
|
|
4418
|
-
return subprotocol;
|
|
4425
|
+
subprotocol$1 = { parse };
|
|
4426
|
+
return subprotocol$1;
|
|
4419
4427
|
}
|
|
4420
4428
|
|
|
4429
|
+
requireSubprotocol();
|
|
4430
|
+
|
|
4431
|
+
requireWebsocket();
|
|
4432
|
+
|
|
4421
4433
|
/* eslint no-unused-vars: ["error", { "varsIgnorePattern": "^Duplex$", "caughtErrors": "none" }] */
|
|
4422
4434
|
|
|
4423
4435
|
var websocketServer$1;
|
|
@@ -4436,7 +4448,7 @@ function requireWebsocketServer () {
|
|
|
4436
4448
|
const PerMessageDeflate = requirePermessageDeflate();
|
|
4437
4449
|
const subprotocol = requireSubprotocol();
|
|
4438
4450
|
const WebSocket = requireWebsocket();
|
|
4439
|
-
const { GUID, kWebSocket } = requireConstants();
|
|
4451
|
+
const { CLOSE_TIMEOUT, GUID, kWebSocket } = requireConstants();
|
|
4440
4452
|
|
|
4441
4453
|
const keyRegex = /^[+/0-9A-Za-z]{22}==$/;
|
|
4442
4454
|
|
|
@@ -4463,6 +4475,9 @@ function requireWebsocketServer () {
|
|
|
4463
4475
|
* pending connections
|
|
4464
4476
|
* @param {Boolean} [options.clientTracking=true] Specifies whether or not to
|
|
4465
4477
|
* track clients
|
|
4478
|
+
* @param {Number} [options.closeTimeout=30000] Duration in milliseconds to
|
|
4479
|
+
* wait for the closing handshake to finish after `websocket.close()` is
|
|
4480
|
+
* called
|
|
4466
4481
|
* @param {Function} [options.handleProtocols] A hook to handle protocols
|
|
4467
4482
|
* @param {String} [options.host] The hostname where to bind the server
|
|
4468
4483
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
@@ -4492,6 +4507,7 @@ function requireWebsocketServer () {
|
|
|
4492
4507
|
perMessageDeflate: false,
|
|
4493
4508
|
handleProtocols: null,
|
|
4494
4509
|
clientTracking: true,
|
|
4510
|
+
closeTimeout: CLOSE_TIMEOUT,
|
|
4495
4511
|
verifyClient: null,
|
|
4496
4512
|
noServer: false,
|
|
4497
4513
|
backlog: null, // use default (511 as implemented in net.js)
|
|
@@ -4714,11 +4730,11 @@ function requireWebsocketServer () {
|
|
|
4714
4730
|
this.options.perMessageDeflate &&
|
|
4715
4731
|
secWebSocketExtensions !== undefined
|
|
4716
4732
|
) {
|
|
4717
|
-
const perMessageDeflate = new PerMessageDeflate(
|
|
4718
|
-
this.options.perMessageDeflate,
|
|
4719
|
-
true,
|
|
4720
|
-
this.options.maxPayload
|
|
4721
|
-
);
|
|
4733
|
+
const perMessageDeflate = new PerMessageDeflate({
|
|
4734
|
+
...this.options.perMessageDeflate,
|
|
4735
|
+
isServer: true,
|
|
4736
|
+
maxPayload: this.options.maxPayload
|
|
4737
|
+
});
|
|
4722
4738
|
|
|
4723
4739
|
try {
|
|
4724
4740
|
const offers = extension.parse(secWebSocketExtensions);
|
package/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is the first file executed by code using the package
|
|
3
|
+
* Its responsability is to export what is documented
|
|
4
|
+
* Ideally this file should be kept simple to help discovering codebase progressively.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// tslint:disable:ordered-imports
|
|
8
|
+
|
|
9
|
+
export { startServer } from "./src/start_server.js";
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
STOP_REASON_INTERNAL_ERROR,
|
|
13
|
+
STOP_REASON_PROCESS_SIGHUP,
|
|
14
|
+
STOP_REASON_PROCESS_SIGTERM,
|
|
15
|
+
STOP_REASON_PROCESS_SIGINT,
|
|
16
|
+
STOP_REASON_PROCESS_BEFORE_EXIT,
|
|
17
|
+
STOP_REASON_PROCESS_EXIT,
|
|
18
|
+
STOP_REASON_NOT_SPECIFIED,
|
|
19
|
+
} from "./src/stopReasons.js";
|
|
20
|
+
export { jsenvServiceErrorHandler } from "./src/services/error_handler/jsenv_service_error_handler.js";
|
|
21
|
+
|
|
22
|
+
// webSocket
|
|
23
|
+
export { WebSocketResponse } from "./src/web_socket_response.js";
|
|
24
|
+
// long polling
|
|
25
|
+
export { ProgressiveResponse } from "./src/progressive_response.js";
|
|
26
|
+
// Server event (can be used to push events to clients that can be connected with WebSocket or EventSource)
|
|
27
|
+
export { ServerEvents, LazyServerEvents } from "./src/server_events.js";
|
|
28
|
+
|
|
29
|
+
// CORS
|
|
30
|
+
export {
|
|
31
|
+
jsenvServiceCORS,
|
|
32
|
+
jsenvAccessControlAllowedHeaders,
|
|
33
|
+
jsenvAccessControlAllowedMethods,
|
|
34
|
+
} from "./src/services/cors/jsenv_service_cors.js";
|
|
35
|
+
|
|
36
|
+
// filesystem
|
|
37
|
+
export {
|
|
38
|
+
createFileSystemFetch,
|
|
39
|
+
fetchFileSystem,
|
|
40
|
+
} from "./src/services/filesystem/fetch_filesystem.js";
|
|
41
|
+
export { serveDirectory } from "./src/services/filesystem/serve_directory.js";
|
|
42
|
+
export { jsenvServiceStaticFiles } from "./src/services/filesystem/jsenv_service_static_files.js";
|
|
43
|
+
|
|
44
|
+
// content-negotiation
|
|
45
|
+
export { pickContentType } from "./src/content_negotiation/pick_content_type.js";
|
|
46
|
+
export { pickContentEncoding } from "./src/content_negotiation/pick_content_encoding.js";
|
|
47
|
+
export { pickContentLanguage } from "./src/content_negotiation/pick_content_language.js";
|
|
48
|
+
export { jsenvServiceResponseAcceptanceCheck } from "./src/services/response_acceptance_check/jsenv_service_response_acceptance_check.js";
|
|
49
|
+
|
|
50
|
+
// others
|
|
51
|
+
export { composeTwoResponses } from "./src/internal/response_composition.js";
|
|
52
|
+
export { jsenvServiceRequestAliases } from "./src/services/request_aliases/jsenv_service_request_aliases.js";
|
|
53
|
+
export { findFreePort } from "./src/internal/listen.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/server",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.4.0",
|
|
4
4
|
"description": "A modern Node.js HTTP server with declarative routing, content negotiation, and WebSocket support",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,23 +19,24 @@
|
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
21
|
"import": {
|
|
22
|
-
"dev:jsenv": "./
|
|
22
|
+
"dev:jsenv": "./index.js",
|
|
23
23
|
"default": "./dist/jsenv_server.js"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"./*": "./*"
|
|
27
27
|
},
|
|
28
|
-
"main": "./
|
|
28
|
+
"main": "./index.js",
|
|
29
29
|
"files": [
|
|
30
30
|
"/dist/",
|
|
31
|
-
"/src/"
|
|
31
|
+
"/src/",
|
|
32
|
+
"/index.js"
|
|
32
33
|
],
|
|
33
34
|
"scripts": {
|
|
34
35
|
"build": "node --experimental-import-meta-resolve ./scripts/build.mjs",
|
|
35
36
|
"prepublishOnly": "npm run build"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"launch-editor": "2.
|
|
39
|
+
"launch-editor": "2.13.2"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {
|
|
41
42
|
"@jsenv/abort": "../../tooling/abort",
|
|
@@ -55,9 +56,9 @@
|
|
|
55
56
|
"@jsenv/utils": "../../tooling/utils",
|
|
56
57
|
"eventsource": "4.1.0",
|
|
57
58
|
"formidable": "3.5.4",
|
|
58
|
-
"playwright": "1.
|
|
59
|
-
"undici": "7.
|
|
60
|
-
"ws": "8.
|
|
59
|
+
"playwright": "1.58.1",
|
|
60
|
+
"undici": "7.24.2",
|
|
61
|
+
"ws": "8.20.0"
|
|
61
62
|
},
|
|
62
63
|
"engines": {
|
|
63
64
|
"node": ">=22.13.1"
|
|
@@ -6,14 +6,15 @@
|
|
|
6
6
|
|
|
7
7
|
import { CONTENT_TYPE } from "@jsenv/utils/src/content_type/content_type.js";
|
|
8
8
|
import { createReadStream, readFile, statSync } from "node:fs";
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
|
|
10
|
+
import { pickContentEncoding } from "../../content_negotiation/pick_content_encoding.js";
|
|
11
|
+
import { composeTwoResponses } from "../../internal/response_composition.js";
|
|
12
|
+
import { bufferToEtag } from "./etag.js";
|
|
13
|
+
import { convertFileSystemErrorToResponseProperties } from "./filesystem_error_to_response.js";
|
|
12
14
|
import {
|
|
13
15
|
fileSystemPathToUrl,
|
|
14
16
|
isFileSystemPath,
|
|
15
|
-
} from "
|
|
16
|
-
import { composeTwoResponses } from "../internal/response_composition.js";
|
|
17
|
+
} from "./filesystem_path_and_url.js";
|
|
17
18
|
import { serveDirectory } from "./serve_directory.js";
|
|
18
19
|
|
|
19
20
|
export const createFileSystemFetch = (directoryUrl, options) => {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { urlToExtension, urlToPathname } from "@jsenv/urls";
|
|
2
|
+
|
|
3
|
+
import { createFileSystemFetch } from "./fetch_filesystem.js";
|
|
4
|
+
|
|
5
|
+
export const jsenvServiceStaticFiles = ({ directoryUrl, mainFilePath }) => {
|
|
6
|
+
return {
|
|
7
|
+
name: "jsenv:file_service",
|
|
8
|
+
routes: [
|
|
9
|
+
{
|
|
10
|
+
endpoint: "GET *",
|
|
11
|
+
description: "Serve static files.",
|
|
12
|
+
fetch: (request, helpers) => {
|
|
13
|
+
const urlIsVersioned = new URL(request.url).searchParams.has("v");
|
|
14
|
+
if (mainFilePath && request.resource === "/") {
|
|
15
|
+
request = {
|
|
16
|
+
...request,
|
|
17
|
+
resource: `/${mainFilePath}`,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
const urlObject = new URL(request.resource.slice(1), directoryUrl);
|
|
21
|
+
return createFileSystemFetch(directoryUrl, {
|
|
22
|
+
cacheControl: urlIsVersioned
|
|
23
|
+
? `private,max-age=${SECONDS_IN_30_DAYS},immutable`
|
|
24
|
+
: "private,max-age=0,must-revalidate",
|
|
25
|
+
etagEnabled: true,
|
|
26
|
+
compressionEnabled: true,
|
|
27
|
+
rootDirectoryUrl: directoryUrl,
|
|
28
|
+
canReadDirectory: true,
|
|
29
|
+
ENOENTFallback: () => {
|
|
30
|
+
if (
|
|
31
|
+
!urlToExtension(urlObject) &&
|
|
32
|
+
!urlToPathname(urlObject).endsWith("/")
|
|
33
|
+
) {
|
|
34
|
+
return new URL(mainFilePath, directoryUrl);
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
},
|
|
38
|
+
})(request, helpers);
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
const SECONDS_IN_30_DAYS = 60 * 60 * 24 * 30;
|
package/src/main.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is the first file executed by code using the package
|
|
3
|
-
* Its responsability is to export what is documented
|
|
4
|
-
* Ideally this file should be kept simple to help discovering codebase progressively.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
// tslint:disable:ordered-imports
|
|
8
|
-
|
|
9
|
-
export { startServer } from "./start_server.js";
|
|
10
|
-
|
|
11
|
-
export {
|
|
12
|
-
STOP_REASON_INTERNAL_ERROR,
|
|
13
|
-
STOP_REASON_PROCESS_SIGHUP,
|
|
14
|
-
STOP_REASON_PROCESS_SIGTERM,
|
|
15
|
-
STOP_REASON_PROCESS_SIGINT,
|
|
16
|
-
STOP_REASON_PROCESS_BEFORE_EXIT,
|
|
17
|
-
STOP_REASON_PROCESS_EXIT,
|
|
18
|
-
STOP_REASON_NOT_SPECIFIED,
|
|
19
|
-
} from "./stopReasons.js";
|
|
20
|
-
export { jsenvServiceErrorHandler } from "./services/error_handler/jsenv_service_error_handler.js";
|
|
21
|
-
|
|
22
|
-
// filesystem
|
|
23
|
-
export {
|
|
24
|
-
createFileSystemFetch,
|
|
25
|
-
fetchFileSystem,
|
|
26
|
-
} from "./filesystem/fetch_filesystem.js";
|
|
27
|
-
|
|
28
|
-
// webSocket
|
|
29
|
-
export { WebSocketResponse } from "./web_socket_response.js";
|
|
30
|
-
// long polling
|
|
31
|
-
export { ProgressiveResponse } from "./progressive_response.js";
|
|
32
|
-
// Server event (can be used to push events to clients that can be connected with WebSocket or EventSource)
|
|
33
|
-
export { ServerEvents, LazyServerEvents } from "./server_events.js";
|
|
34
|
-
|
|
35
|
-
// CORS
|
|
36
|
-
export {
|
|
37
|
-
jsenvServiceCORS,
|
|
38
|
-
jsenvAccessControlAllowedHeaders,
|
|
39
|
-
jsenvAccessControlAllowedMethods,
|
|
40
|
-
} from "./services/cors/jsenv_service_cors.js";
|
|
41
|
-
|
|
42
|
-
// content-negotiation
|
|
43
|
-
export { pickContentType } from "./content_negotiation/pick_content_type.js";
|
|
44
|
-
export { pickContentEncoding } from "./content_negotiation/pick_content_encoding.js";
|
|
45
|
-
export { pickContentLanguage } from "./content_negotiation/pick_content_language.js";
|
|
46
|
-
export { jsenvServiceResponseAcceptanceCheck } from "./services/response_acceptance_check/jsenv_service_response_acceptance_check.js";
|
|
47
|
-
|
|
48
|
-
// others
|
|
49
|
-
export { serveDirectory } from "./filesystem/serve_directory.js";
|
|
50
|
-
export { composeTwoResponses } from "./internal/response_composition.js";
|
|
51
|
-
export { jsenvServiceRequestAliases } from "./services/request_aliases/jsenv_service_request_aliases.js";
|
|
52
|
-
export { findFreePort } from "./internal/listen.js";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|