@noego/forge 0.1.24 → 0.1.27
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 +2 -0
- package/dist/client.cjs +3 -3
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +25 -0
- package/dist/client.mjs +895 -824
- package/dist/client.mjs.map +1 -1
- package/dist/lint/cli.js +28 -2
- package/dist/lint/cli.js.map +1 -1
- package/dist/lint/config.js +19 -2
- package/dist/lint/config.js.map +1 -1
- package/dist/lint/route_parser.js +8 -30
- package/dist/lint/route_parser.js.map +1 -1
- package/dist/lint/rules/no_invalid_html_nesting.d.ts +3 -0
- package/dist/lint/rules/no_invalid_html_nesting.js +123 -0
- package/dist/lint/rules/no_invalid_html_nesting.js.map +1 -0
- package/dist/lint/tests/no_invalid_html_nesting.test.d.ts +1 -0
- package/dist/lint/tests/no_invalid_html_nesting.test.js +61 -0
- package/dist/lint/tests/no_invalid_html_nesting.test.js.map +1 -0
- package/dist/page.svelte-4uv4nQ2i.js.map +1 -1
- package/dist/page.svelte-CW8PJDdH.cjs.map +1 -1
- package/dist-ssr/{path-BqcF5dbs.js → path-2bYzpvRB.js} +3 -1
- package/dist-ssr/{path-BqcF5dbs.js.map → path-2bYzpvRB.js.map} +1 -1
- package/dist-ssr/{path-sxXxpB6R.cjs → path-DCxJMpj7.cjs} +3 -1
- package/dist-ssr/{path-sxXxpB6R.cjs.map → path-DCxJMpj7.cjs.map} +1 -1
- package/dist-ssr/server.cjs +20 -3
- package/dist-ssr/server.cjs.map +1 -1
- package/dist-ssr/server.js +20 -3
- package/dist-ssr/server.js.map +1 -1
- package/dist-ssr/shared.cjs +1 -1
- package/dist-ssr/shared.js +1 -1
- package/dist-ssr/static.cjs +1 -1
- package/dist-ssr/static.d.ts +4 -0
- package/dist-ssr/static.js +1 -1
- package/dist-ssr/test.d.ts +4 -0
- package/dist-ssr/{url_parser-DHQiBy_-.js → url_parser-B6dvK0DX.js} +36 -3
- package/dist-ssr/{url_parser-DHQiBy_-.js.map → url_parser-B6dvK0DX.js.map} +1 -1
- package/dist-ssr/{url_parser-BGkQselu.cjs → url_parser-D7ZqJUTw.cjs} +36 -3
- package/dist-ssr/{url_parser-BGkQselu.cjs.map → url_parser-D7ZqJUTw.cjs.map} +1 -1
- package/package.json +2 -2
- package/src/components/RecursiveRender.svelte +39 -18
package/README.md
CHANGED
|
@@ -246,6 +246,7 @@ Forge extends OpenAPI 3 with custom `x-*` vendor extensions to define your appli
|
|
|
246
246
|
|-----------|-------------|
|
|
247
247
|
| `x-view` | Path to the Svelte component that renders the page view |
|
|
248
248
|
| `x-layout` | Array of layout components (rendered outside-in) that wrap the view |
|
|
249
|
+
| `x-controller` | Path to a PageController class for client-side state/input/events (optional) |
|
|
249
250
|
| `x-fallback-view` | Component to render for 404 errors |
|
|
250
251
|
| `x-fallback-layout` | Default layout when none is specified |
|
|
251
252
|
| `x-middleware` | Array of middleware functions to run before rendering |
|
|
@@ -717,6 +718,7 @@ For deeper topics, check the documentation in [`/docs`](./docs):
|
|
|
717
718
|
| **state_sharing.md** | Reactive global state with Svelte 5 context and `$state` |
|
|
718
719
|
| **tailwind-layouts.md** | Design layouts with Tailwind CSS |
|
|
719
720
|
| **FETCH_MIDDLEWARE.md** | Client-side fetch middleware, authentication, security |
|
|
721
|
+
| **page_controllers.md** | Client-side PageController pattern (state, input, events) |
|
|
720
722
|
| **server_middleware.md** | Per-route server middleware and request context |
|
|
721
723
|
|
|
722
724
|
|
package/dist/client.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`+r.map(function(n,
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=r}});function ue(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var Z=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,n,o,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var c=$(a),s=c.next();!s.done;s=c.next()){var u=s.value;u.remove(this)}}catch(h){t={error:h}}finally{try{s&&!s.done&&(r=c.return)&&r.call(c)}finally{if(t)throw t.error}}else a.remove(this);var l=this.initialTeardown;if(w(l))try{l()}catch(h){i=h instanceof te?h.errors:[h]}var f=this._finalizers;if(f){this._finalizers=null;try{for(var v=$(f),d=v.next();!d.done;d=v.next()){var p=d.value;try{we(p)}catch(h){i=i??[],h instanceof te?i=G(G([],M(i)),M(h.errors)):i.push(h)}}}catch(h){n={error:h}}finally{try{d&&!d.done&&(o=v.return)&&o.call(v)}finally{if(n)throw n.error}}}if(i)throw new te(i)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)we(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&ue(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&ue(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),Ae=Z.EMPTY;function Pe(e){return e instanceof Z||e&&"closed"in e&&w(e.remove)&&w(e.add)&&w(e.unsubscribe)}function we(e){w(e)?e():e.unsubscribe()}var rt={Promise:void 0},nt={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,G([e,t],M(r)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function Te(e){nt.setTimeout(function(){throw e})}function ge(){}function H(e){e()}var he=(function(e){W(t,e);function t(r){var n=e.call(this)||this;return n.isStopped=!1,r?(n.destination=r,Pe(r)&&r.add(n)):n.destination=at,n}return t.create=function(r,n,o){return new D(r,n,o)},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(Z),ot=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var r=this.partialObserver;if(r.next)try{r.next(t)}catch(n){Y(n)}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t)}catch(n){Y(n)}else Y(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(r){Y(r)}},e})(),D=(function(e){W(t,e);function t(r,n,o){var i=e.call(this)||this,a;return w(r)||!r?a={next:r??void 0,error:n??void 0,complete:o??void 0}:a=r,i.destination=new ot(a),i}return t})(he);function Y(e){Te(e)}function it(e){throw e}var at={closed:!0,next:ge,error:it,complete:ge},pe=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function ve(e){return e}function st(e){return e.length===0?ve:e.length===1?e[0]:function(r){return e.reduce(function(n,o){return o(n)},r)}}var E=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(t,r,n){var o=this,i=ct(t)?t:new D(t,r,n);return H(function(){var a=o,c=a.operator,s=a.source;i.add(c?c.call(i,s):s?o._subscribe(i):o._trySubscribe(i))}),i},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(r){t.error(r)}},e.prototype.forEach=function(t,r){var n=this;return r=Se(r),new r(function(o,i){var a=new D({next:function(c){try{t(c)}catch(s){i(s),a.unsubscribe()}},error:i,complete:o});n.subscribe(a)})},e.prototype._subscribe=function(t){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(t)},e.prototype[pe]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return st(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=Se(t),new t(function(n,o){var i;r.subscribe(function(a){return i=a},function(a){return o(a)},function(){return n(i)})})},e.create=function(t){return new e(t)},e})();function Se(e){var t;return(t=e??rt.Promise)!==null&&t!==void 0?t:Promise}function ut(e){return e&&w(e.next)&&w(e.error)&&w(e.complete)}function ct(e){return e&&e instanceof he||ut(e)&&Pe(e)}function lt(e){return w(e==null?void 0:e.lift)}function P(e){return function(t){if(lt(t))return t.lift(function(r){try{return e(r,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function A(e,t,r,n,o){return new ft(e,t,r,n,o)}var ft=(function(e){W(t,e);function t(r,n,o,i,a,c){var s=e.call(this,r)||this;return s.onFinalize=a,s.shouldUnsubscribe=c,s._next=n?function(u){try{n(u)}catch(l){r.error(l)}}:e.prototype._next,s._error=i?function(u){try{i(u)}catch(l){r.error(l)}finally{this.unsubscribe()}}:e.prototype._error,s._complete=o?function(){try{o()}catch(u){r.error(u)}finally{this.unsubscribe()}}:e.prototype._complete,s}return t.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((r=this.onFinalize)===null||r===void 0||r.call(this))}},t})(he),dt=de(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Q=(function(e){W(t,e);function t(){var r=e.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return t.prototype.lift=function(r){var n=new _e(this,this);return n.operator=r,n},t.prototype._throwIfClosed=function(){if(this.closed)throw new dt},t.prototype.next=function(r){var n=this;H(function(){var o,i;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var a=$(n.currentObservers),c=a.next();!c.done;c=a.next()){var s=c.value;s.next(r)}}catch(u){o={error:u}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}}})},t.prototype.error=function(r){var n=this;H(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var o=n.observers;o.length;)o.shift().error(r)}})},t.prototype.complete=function(){var r=this;H(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var n=this,o=this,i=o.hasError,a=o.isStopped,c=o.observers;return i||a?Ae:(this.currentObservers=null,c.push(r),new Z(function(){n.currentObservers=null,ue(c,r)}))},t.prototype._checkFinalizedStatuses=function(r){var n=this,o=n.hasError,i=n.thrownError,a=n.isStopped;o?r.error(i):a&&r.complete()},t.prototype.asObservable=function(){var r=new E;return r.source=this,r},t.create=function(r,n){return new _e(r,n)},t})(E),_e=(function(e){W(t,e);function t(r,n){var o=e.call(this)||this;return o.destination=r,o.source=n,o}return t.prototype.next=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,r)},t.prototype.error=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,r)},t.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},t.prototype._subscribe=function(r){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&o!==void 0?o:Ae},t})(Q),Ie={now:function(){return(Ie.delegate||Date).now()},delegate:void 0},ht=(function(e){W(t,e);function t(r,n,o){r===void 0&&(r=1/0),n===void 0&&(n=1/0),o===void 0&&(o=Ie);var i=e.call(this)||this;return i._bufferSize=r,i._windowTime=n,i._timestampProvider=o,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,r),i._windowTime=Math.max(1,n),i}return t.prototype.next=function(r){var n=this,o=n.isStopped,i=n._buffer,a=n._infiniteTimeWindow,c=n._timestampProvider,s=n._windowTime;o||(i.push(r),!a&&i.push(c.now()+s)),this._trimBuffer(),e.prototype.next.call(this,r)},t.prototype._subscribe=function(r){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(r),o=this,i=o._infiniteTimeWindow,a=o._buffer,c=a.slice(),s=0;s<c.length&&!r.closed;s+=i?1:2)r.next(c[s]);return this._checkFinalizedStatuses(r),n},t.prototype._trimBuffer=function(){var r=this,n=r._bufferSize,o=r._timestampProvider,i=r._buffer,a=r._infiniteTimeWindow,c=(a?1:2)*n;if(n<1/0&&c<i.length&&i.splice(0,i.length-c),!a){for(var s=o.now(),u=0,l=1;l<i.length&&i[l]<=s;l+=2)u=l;u&&i.splice(0,u+1)}},t})(Q),me=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function Re(e){return w(e==null?void 0:e.then)}function Ce(e){return w(e[pe])}function je(e){return Symbol.asyncIterator&&w(e==null?void 0:e[Symbol.asyncIterator])}function Le(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function pt(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Ne=pt();function Ue(e){return w(e==null?void 0:e[Ne])}function Fe(e){return et(this,arguments,function(){var r,n,o,i;return xe(this,function(a){switch(a.label){case 0:r=e.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,F(r.read())];case 3:return n=a.sent(),o=n.value,i=n.done,i?[4,F(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,F(o)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function ke(e){return w(e==null?void 0:e.getReader)}function T(e){if(e instanceof E)return e;if(e!=null){if(Ce(e))return vt(e);if(me(e))return mt(e);if(Re(e))return yt(e);if(je(e))return $e(e);if(Ue(e))return bt(e);if(ke(e))return wt(e)}throw Le(e)}function vt(e){return new E(function(t){var r=e[pe]();if(w(r.subscribe))return r.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function mt(e){return new E(function(t){for(var r=0;r<e.length&&!t.closed;r++)t.next(e[r]);t.complete()})}function yt(e){return new E(function(t){e.then(function(r){t.closed||(t.next(r),t.complete())},function(r){return t.error(r)}).then(null,Te)})}function bt(e){return new E(function(t){var r,n;try{for(var o=$(e),i=o.next();!i.done;i=o.next()){var a=i.value;if(t.next(a),t.closed)return}}catch(c){r={error:c}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}t.complete()})}function $e(e){return new E(function(t){gt(e,t).catch(function(r){return t.error(r)})})}function wt(e){return $e(Fe(e))}function gt(e,t){var r,n,o,i;return Qe(this,void 0,void 0,function(){var a,c;return xe(this,function(s){switch(s.label){case 0:s.trys.push([0,5,6,11]),r=tt(e),s.label=1;case 1:return[4,r.next()];case 2:if(n=s.sent(),!!n.done)return[3,4];if(a=n.value,t.next(a),t.closed)return[2];s.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return c=s.sent(),o={error:c},[3,11];case 6:return s.trys.push([6,,9,10]),n&&!n.done&&(i=r.return)?[4,i.call(r)]:[3,8];case 7:s.sent(),s.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function N(e,t,r,n,o){n===void 0&&(n=0),o===void 0&&(o=!1);var i=t.schedule(function(){r(),o?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(i),!o)return i}function Me(e,t){return t===void 0&&(t=0),P(function(r,n){r.subscribe(A(n,function(o){return N(n,e,function(){return n.next(o)},t)},function(){return N(n,e,function(){return n.complete()},t)},function(o){return N(n,e,function(){return n.error(o)},t)}))})}function De(e,t){return t===void 0&&(t=0),P(function(r,n){n.add(e.schedule(function(){return r.subscribe(n)},t))})}function St(e,t){return T(e).pipe(De(t),Me(t))}function _t(e,t){return T(e).pipe(De(t),Me(t))}function Et(e,t){return new E(function(r){var n=0;return t.schedule(function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())})})}function Ot(e,t){return new E(function(r){var n;return N(r,t,function(){n=e[Ne](),N(r,t,function(){var o,i,a;try{o=n.next(),i=o.value,a=o.done}catch(c){r.error(c);return}a?r.complete():r.next(i)},0,!0)}),function(){return w(n==null?void 0:n.return)&&n.return()}})}function We(e,t){if(!e)throw new Error("Iterable cannot be null");return new E(function(r){N(r,t,function(){var n=e[Symbol.asyncIterator]();N(r,t,function(){n.next().then(function(o){o.done?r.complete():r.next(o.value)})},0,!0)})})}function xt(e,t){return We(Fe(e),t)}function At(e,t){if(e!=null){if(Ce(e))return St(e,t);if(me(e))return Et(e,t);if(Re(e))return _t(e,t);if(je(e))return We(e,t);if(Ue(e))return Ot(e,t);if(ke(e))return xt(e,t)}throw Le(e)}function qe(e,t){return t?At(e,t):T(e)}var Pt=de(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Tt(e,t){return new Promise(function(r,n){var o=new D({next:function(i){r(i),o.unsubscribe()},error:n,complete:function(){n(new Pt)}});e.subscribe(o)})}function ye(e,t){return P(function(r,n){var o=0;r.subscribe(A(n,function(i){n.next(e.call(t,i,o++))}))})}var It=Array.isArray;function Rt(e,t){return It(t)?e.apply(void 0,G([],M(t))):e(t)}function Ct(e){return ye(function(t){return Rt(e,t)})}function jt(e,t,r,n,o,i,a,c){var s=[],u=0,l=0,f=!1,v=function(){f&&!s.length&&!u&&t.complete()},d=function(h){return u<n?p(h):s.push(h)},p=function(h){u++;var S=!1;T(r(h,l++)).subscribe(A(t,function(g){t.next(g)},function(){S=!0},void 0,function(){if(S)try{u--;for(var g=function(){var m=s.shift();a||p(m)};s.length&&u<n;)g();v()}catch(m){t.error(m)}}))};return e.subscribe(A(t,d,function(){f=!0,v()})),function(){}}function Ge(e,t,r){return r===void 0&&(r=1/0),w(t)?Ge(function(n,o){return ye(function(i,a){return t(n,i,o,a)})(T(e(n,o)))},r):(typeof t=="number"&&(r=t),P(function(n,o){return jt(n,o,e,r)}))}var Lt=["addListener","removeListener"],Nt=["addEventListener","removeEventListener"],Ut=["on","off"];function ce(e,t,r,n){if(w(r)&&(n=r,r=void 0),n)return ce(e,t,r).pipe(Ct(n));var o=M($t(e)?Nt.map(function(c){return function(s){return e[c](t,s,r)}}):Ft(e)?Lt.map(Ee(e,t)):kt(e)?Ut.map(Ee(e,t)):[],2),i=o[0],a=o[1];if(!i&&me(e))return Ge(function(c){return ce(c,t,r)})(T(e));if(!i)throw new TypeError("Invalid event target");return new E(function(c){var s=function(){for(var u=[],l=0;l<arguments.length;l++)u[l]=arguments[l];return c.next(1<u.length?u:u[0])};return i(s),function(){return a(s)}})}function Ee(e,t){return function(r){return function(n){return e[r](t,n)}}}function Ft(e){return w(e.addListener)&&w(e.removeListener)}function kt(e){return w(e.on)&&w(e.off)}function $t(e){return w(e.addEventListener)&&w(e.removeEventListener)}function re(e,t){return P(function(r,n){var o=0;r.subscribe(A(n,function(i){return e.call(t,i,o++)&&n.next(i)}))})}function Mt(e,t){return t===void 0&&(t=ve),e=e??Dt,P(function(r,n){var o,i=!0;r.subscribe(A(n,function(a){var c=t(a);(i||!e(o,c))&&(i=!1,o=c,n.next(a))}))})}function Dt(e,t){return e===t}function Wt(e){e===void 0&&(e={});var t=e.connector,r=t===void 0?function(){return new Q}:t,n=e.resetOnError,o=n===void 0?!0:n,i=e.resetOnComplete,a=i===void 0?!0:i,c=e.resetOnRefCountZero,s=c===void 0?!0:c;return function(u){var l,f,v,d=0,p=!1,h=!1,S=function(){f==null||f.unsubscribe(),f=void 0},g=function(){S(),l=v=void 0,p=h=!1},m=function(){var b=l;g(),b==null||b.unsubscribe()};return P(function(b,O){d++,!h&&!p&&S();var B=v=v??r();O.add(function(){d--,d===0&&!h&&!p&&(f=ne(m,s))}),B.subscribe(O),!l&&d>0&&(l=new D({next:function(z){return B.next(z)},error:function(z){h=!0,S(),f=ne(g,o,z),B.error(z)},complete:function(){p=!0,S(),f=ne(g,a),B.complete()}}),T(b).subscribe(l))})(u)}}function ne(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];if(t===!0){e();return}if(t!==!1){var o=new D({next:function(){o.unsubscribe(),e()}});return T(t.apply(void 0,G([],M(r)))).subscribe(o)}}function Be(e,t){return P(function(r,n){var o=null,i=0,a=!1,c=function(){return a&&!o&&n.complete()};r.subscribe(A(n,function(s){o==null||o.unsubscribe();var u=0,l=i++;T(e(s,l)).subscribe(o=A(n,function(f){return n.next(t?t(s,f,l,u++):f)},function(){o=null,c()}))},function(){a=!0,c()}))})}function qt(e,t,r){var n=w(e)||t||r?{next:e,error:t,complete:r}:e;return n?P(function(o,i){var a;(a=n.subscribe)===null||a===void 0||a.call(n);var c=!0;o.subscribe(A(i,function(s){var u;(u=n.next)===null||u===void 0||u.call(n,s),i.next(s)},function(){var s;c=!1,(s=n.complete)===null||s===void 0||s.call(n),i.complete()},function(s){var u;c=!1,(u=n.error)===null||u===void 0||u.call(n,s),i.error(s)},function(){var s,u;c&&((s=n.unsubscribe)===null||s===void 0||s.call(n)),(u=n.finalize)===null||u===void 0||u.call(n)}))}):ve}const k=C.writable({});async function ze(){k.update(e=>(Object.assign(e,window.__MANIFEST__),e))}const I=new Map,V=5e3;function Gt(e){const t=I.get(e);return t?(I.delete(e),Date.now()-t.createdAt>V?(t.abortController.abort(),null):t.response$):null}function Bt(e,t){ce(document,"mouseover").pipe(Wt()).pipe(ye(o=>{const i=o.target,a=(i==null?void 0:i.tagName)==="A"?i:i==null?void 0:i.closest("A");if(!a)return null;const c=a.getAttribute("href");return!c||!c.startsWith("/")&&!c.startsWith(".")?null:c}),re(o=>o!==null),re(o=>o!==window.location.pathname),Mt(),re(o=>{const i=o.split("?")[0],a="get",c=e.find(l=>l.method.toLowerCase()===a&&t.find(f=>f.parser(i)&&f.pattern===l.path));if(!c)return!1;const s=t.find(l=>l.parser(i)&&l.pattern===c.path);return!!C.get(k)[s==null?void 0:s.pattern]}),Be(o=>{const i=I.get(o);if(i&&Date.now()-i.createdAt<V)return[];const a=new AbortController,c=new ht(1),s={response$:c,createdAt:Date.now(),abortController:a};I.set(o,s);const u={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:a.signal};return u[ee]=!0,qe(fetch(o,u).then(l=>(c.next(l),c.complete(),o),l=>(c.error(l),I.delete(o),null))).pipe(qt({unsubscribe:()=>{a.abort(),I.delete(o)}}))})).subscribe(),setInterval(()=>{const o=Date.now();for(const[i,a]of I)o-a.createdAt>V&&(a.abortController.abort(),I.delete(i))},V)}var L=(e=>(e[e.TRACE=0]="TRACE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.FATAL=5]="FATAL",e))(L||{});const zt={trace:0,debug:1,info:2,warn:3,error:4,fatal:5};function Yt(e){if(!e)return 2;const t=e.trim().toLowerCase(),r=zt[t];if(typeof r=="number")return r;const n=Number(t);return Number.isFinite(n)&&n>=0&&n<=5?n:2}function Ye(e){switch(e){case 0:return"TRACE";case 1:return"DEBUG";case 2:return"INFO";case 3:return"WARN";case 4:return"ERROR";case 5:return"FATAL";default:return"INFO"}}function Oe(e){if(e===void 0)return"undefined";if(e===null)return null;if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};switch(typeof e){case"string":case"number":case"boolean":return e;case"bigint":return e.toString();case"symbol":return String(e);case"function":return`[Function${e.name?`: ${e.name}`:""}]`;default:return e}}class Ht{constructor(t,r,n){this.name=t,this.manager=r,this.contextData=n}named(t){return new le(t,this.manager,this.contextData)}withContext(t){const r=this.contextData?{...this.contextData,...t}:t;return new le(this.name,this.manager,r)}trace(t,...r){this.log(L.TRACE,t,r)}debug(t,...r){this.log(L.DEBUG,t,r)}info(t,...r){this.log(L.INFO,t,r)}warn(t,...r){this.log(L.WARN,t,r)}error(t,...r){this.log(L.ERROR,t,r)}fatal(t,...r){this.log(L.FATAL,t,r)}log(t,r,n){if(!this.manager.shouldLog(t,this.name))return;const o=new Date().toISOString();let i=n.length>0?n.length===1?Oe(n[0]):n.map(Oe):void 0,a;this.contextData&&i!==void 0?a={...this.contextData,args:i}:this.contextData?a=this.contextData:a=i,this.manager.log({timestamp:o,level:Ye(t),logger:this.name,message:r,context:a})}}class le extends Ht{constructor(t,r,n){super(t,r,n)}}class Vt{log(t){const r=t.context!==void 0?` ${JSON.stringify(t.context)}`:"",n=`[${t.timestamp}] [${t.logger}] [${t.level}] ${t.message}${r}`;switch(t.level){case"ERROR":case"FATAL":console.error(n);break;case"WARN":console.warn(n);break;default:console.log(n);break}}}const oe=Symbol.for("@noego/logger");class Kt{constructor(){var o,i,a;this.transports=[],this.loggerLevels=new Map;const t=typeof process<"u"?(o=process.env)==null?void 0:o.LOG_LEVEL:void 0,r=typeof process<"u"?(i=process.env)==null?void 0:i.SERVICE_NAME:void 0,n=typeof process<"u"?(a=process.env)==null?void 0:a.NODE_ENV:void 0;this.level=Yt(t),this.service=r??"noego",this.environment=n??"development"}getLevel(){return this.level}setLevel(t){this.level=t}setLoggerLevel(t,r){this.loggerLevels.set(t,r)}shouldLog(t,r){if(r){const n=this.loggerLevels.get(r);if(n!==void 0)return t>=n}return t>=this.level}addTransport(t){this.transports.push(t)}setTransports(t){this.transports=[...t]}clearTransports(){this.transports=[]}setServiceName(t){this.service=t}log(t){const r={...t,environment:this.environment,service:this.service};for(const n of this.transports)n.log(r)}async closeAll(){for(const t of this.transports)t.close&&await t.close()}formatMessage(t,r,n){return`[${new Date().toISOString()}] [${r}] [${Ye(t)}] ${n}`}}function Jt(){const e=globalThis;if(!e[oe]){const t=new Kt;t.addTransport(new Vt),e[oe]=t}return e[oe]}function be(e){return new le(e,Jt())}const y=be("forge:nav"),Xt=1e4;function Zt(e,t,r){let n=null,o=!1;const i=new Promise((a,c)=>{n=setTimeout(()=>{o=!0,y.error("Timeout fired after",t,"ms"),r(),c(new Error(`Navigation timed out after ${t}ms`))},t),y.debug("Timeout scheduled for",t,"ms, timeoutId:",n)});return Promise.race([e.finally(()=>{n!==null&&(o?y.warn("Promise settled AFTER timeout already fired"):(y.debug("Clearing timeout",n,"- promise settled successfully"),clearTimeout(n)))}),i])}const fe=new Q;let _=0,q=null;function Qt(e){e&&e.redirectPath&&(y.debug("Handling redirect to",e.redirectPath),setTimeout(()=>{window.dispatchEvent(new CustomEvent("forge-redirect",{detail:{path:e.redirectPath}}))},0))}fe.pipe(Be(e=>qe(Zt(rr(e),Xt,()=>{y.error("Navigation timed out"),_++,q&&(q.abort(),q=null)}).catch(t=>{y.error("Navigation failed:",t)})))).subscribe({next:Qt,error:e=>{y.error("Stream error:",e)}});function er(e){var t;y.debug("Pushing navigation event to stream",{url:e.url,currentNavigationId:_,subscriberCount:((t=fe.observers)==null?void 0:t.length)||0}),fe.next(e)}const x=C.writable({active:{layouts:[],view:null,viewPath:null,layoutPaths:[],data:{layout:[],view:{}},params:{},urlParams:{},query:{}},phase:"idle",navigationId:0,page:R.page}),tr=async()=>{const e=C.get(x).navigationId;try{const t=window.location.pathname+window.location.search,r={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"}};r[ee]=!0;const n=await fetch(t,r);if(!n.ok)return!1;const o=await n.json(),i=C.get(x).navigationId;return e!==i?(y.debug("Discarding stale poll response",{pollNavigationId:e,currentNavigationId:i}),!1):(x.update(a=>{var c;return a.active.data={layout:((c=a.active.data)==null?void 0:c.layout)||[],view:o.view},a}),!0)}catch{return!1}};R.page.update(e=>(e.poll=tr,e));function X(...e){let t=e.map((r,n)=>n===0?r.replace(/\/+$/,""):r.replace(/^\/+|\/+$/g,"")).join("/");return t.startsWith("/")||(t="/"+t),t.split("?")[0]}async function He(e,t,r,n,o,i){try{const a=typeof t=="string"&&t.indexOf("assets")!==-1,c=(r.layout||[]).map(d=>{let p=X(t,d).toString();return a&&(p=p.endsWith(".svelte")?p.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(p)?p:p+".js"),p});let s=X(t,r.view).toString();a&&(s=s.endsWith(".svelte")?s.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(s)?s:s+".js");const u=await Promise.all(c.map(d=>import(d).then(p=>p.default)));s.startsWith("/")||(s="/"+s);const l=await import(s).then(d=>d.default),f=window.__INITIAL_DATA__||{layout:[],view:{}},v={layouts:u,view:l,viewPath:r.view||null,layoutPaths:r.layout||[],data:f,params:n,urlParams:o,query:i};x.update(d=>(d.active=v,d.phase="idle",d)),Ke.hydrate(Je,{target:e,props:{root:x}})}catch(a){y.error("Client-side route loading failed:",a)}}function K(e,t,r,n,o,i,a=!1,c=!0){er({url:e,base_path:t,route:r,params:n,urlParams:o,query:i,server_loading:a,updateUrl:c})}async function rr(e){const{url:t,base_path:r,route:n,params:o,urlParams:i,query:a,server_loading:c,updateUrl:s}=e,u=++_,l=new AbortController;q=l,y.debug("Starting navigation",{navigationId:u,url:t,updateUrl:s,server_loading:c,currentNavigationId:_,hasAbortController:!!q}),x.update(f=>(f.phase="loading",f.navigationId=u,f));try{let f={layout:[],view:{}};if(c){y.debug("Fetching server data",{navigationId:u,url:t});let m=null;const b=Gt(t);if(b)try{y.debug("Using prefetched response for",t),m=await Tt(b)}catch{y.debug("Prefetch failed, falling back to fetch",t),m=null}if(!m){const O={method:n.method,headers:{"Content-Type":"application/json",Accept:"application/json"},signal:l.signal};O[ee]=!0,m=await fetch(t,O)}if(y.debug("Fetch response received",{navigationId:u,url:t,ok:m.ok,status:m.status,redirected:m.redirected,currentNavigationId:_}),m.redirected||m.headers.get("X-Forge-Redirect")==="true")return y.debug("Redirect detected"),x.update(O=>(O.phase="idle",O)),{redirectPath:m.headers.get("X-Forge-Redirect-Path")||void 0};if(!m.ok)throw new Error(`Network response was not ok: ${m.status}`);f=await m.json(),y.debug("Server data received:",f)}if(u!==_){y.debug("Stale navigation after fetch, aborting",{navigationId:u,currentNavigationId:_});return}y.debug("Loading components",{navigationId:u,view:n.view,layouts:n.layout});const v=typeof r=="string"&&r.indexOf("assets")!==-1,d=(n.layout||[]).map(m=>{let b=X(r,m).toString();return v&&(b=b.endsWith(".svelte")?b.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(b)?b:b+".js"),b});let p=X(r,n.view).toString();v&&(p=p.endsWith(".svelte")?p.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(p)?p:p+".js"),p.startsWith("/")||(p="/"+p);const h=await Promise.all(d.map(m=>import(m).then(b=>b.default))),S=await import(p).then(m=>m.default);if(y.debug("Components loaded",{navigationId:u,currentNavigationId:_,layoutsCount:h.length,viewLoaded:!!S}),u!==_){y.debug("Stale navigation after component load, aborting",{navigationId:u,currentNavigationId:_});return}const g={layouts:h,view:S,viewPath:n.view||null,layoutPaths:n.layout||[],data:f,params:o,urlParams:i,query:a};y.debug("Committing new state",{navigationId:u,currentNavigationId:_,layoutsCount:g.layouts.length,viewSet:!!g.view,dataKeys:Object.keys(g.data||{})}),x.update(m=>(m.active=g,m.phase="idle",y.debug("ROOT.active updated",{navigationId:u,layoutsCount:m.active.layouts.length,viewSet:!!m.active.view,dataKeys:Object.keys(m.active.data||{}),paramsKeys:Object.keys(m.active.params||{})}),m)),typeof window<"u"&&window.scroll(0,0),s&&(y.debug("Updating browser URL",{url:t}),window.history.pushState({},"",t)),y.debug("Navigation complete",{navigationId:u,url:t})}catch(f){if(y.error("Navigation failed",{navigationId:u,currentNavigationId:_,url:t,error:f instanceof Error?f.message:String(f)}),x.update(v=>(v.phase="idle",v)),f.name==="AbortError"){y.debug("Navigation aborted");return}throw f}}const j=be("forge:events");function Ve(e,t,r){if(!document){j.error("Document not found");return}document.addEventListener("click",n=>{var a,c;const o=window.location.pathname,i=((a=n.target)==null?void 0:a.tagName)==="A"?n.target:(c=n.target)==null?void 0:c.closest("A");if(i){let s=i.getAttribute("href");if(o===s){n.preventDefault();return}if(s&&s.startsWith("/")||s.startsWith(".")){const u=s.split("?")[0],l=i.getAttribute("method")||"get",f=t.find(v=>v.method.toLowerCase()===l&&r.find(d=>d.parser(u)&&d.pattern===v.path));if(f){n.preventDefault();const v=r.find(b=>b.parser(u)&&b.pattern===f.path),d=(v==null?void 0:v.parser(u))||{},p=new URLSearchParams(s.split("?")[1]||""),h=Object.fromEntries(p.entries())||{},S={...d,...h},m=C.get(k)[v==null?void 0:v.pattern];R.page.update(b=>(b.url=s,b.pathname=u,b.params=d,b.query=h,b)),j.debug("Click navigation to",s),K(s,e,f,S,d,h,m,!0)}else j.warn("No matching route found",s,"- using fallback navigation")}}}),window.addEventListener("popstate",n=>{const o=window.location.pathname,i=window.location.pathname+window.location.search,a="get",c=t.find(s=>s.method.toLowerCase()===a&&r.find(u=>u.parser(o)&&u.pattern===s.path));if(c){const s=r.find(h=>h.parser(o)&&h.pattern===c.path),u=(s==null?void 0:s.parser(o))||{},l=new URLSearchParams(window.location.search),f=Object.fromEntries(l.entries())||{};R.page.update(h=>(h.url=i,h.pathname=window.location.pathname,h.params=u,h.query=f,h));const v={...u,...f},p=C.get(k)[s==null?void 0:s.pattern];j.debug("Popstate navigation to",i),K(i,e,c,v,u,f,p,!1)}else j.warn("No matching route found",o,"- using fallback navigation"),window.location.href=o}),window.addEventListener("forge-redirect",(n=>{const o=n.detail.path,i=o.split("?")[0];j.debug("Handling forge-redirect to:",o);const a="get",c=t.find(s=>s.method.toLowerCase()===a&&r.find(u=>u.parser(i)&&u.pattern===s.path));if(c){const s=r.find(h=>h.parser(i)&&h.pattern===c.path),u=(s==null?void 0:s.parser(i))||{},l=new URLSearchParams(o.split("?")[1]||""),f=Object.fromEntries(l.entries())||{},v={...u,...f},p=C.get(k)[s==null?void 0:s.pattern];R.page.update(h=>(h.url=o,h.pathname=i,h.params=u,h.query=f,h)),K(o,e,c,v,u,f,p,!0)}else j.warn("No matching route found",i,"- using fallback navigation"),window.location.href=i})),Bt(t,r)}const U=be("forge:client"),ee=Symbol("forge-load-function");let J=[],ie=null;function nr(e){try{const t=new URL(e,window.location.origin);return t.origin===window.location.origin&&!t.pathname.startsWith("/api/")}catch{return!e.startsWith("/api/")}}function or(){typeof window<"u"&&!ie&&(ie=window.fetch,window.fetch=async function(e,t={}){let r={...t};for(const i of J)try{if(i.length===2){const a=new Headers(r.headers),c=Object.fromEntries(a.entries());await new Promise((s,u)=>{try{i(c,l=>{if(l)u(l);else{const f=new Headers;Object.entries(c).forEach(([v,d])=>{d!==void 0&&f.set(v,d)}),r.headers=f,s()}})}catch(l){u(l)}})}else{const a=await i(r,e);a&&typeof a=="object"&&(r=a)}}catch(a){throw U.error("Middleware error",a),a}const n=r==null?void 0:r[ee];U.debug("Fetch override request",{url:e,hasForgeSymbol:n,headers:r==null?void 0:r.headers});const o=await ie(e,r);if(U.debug("Fetch override response",{url:e,responseUrl:o.url,redirected:o.redirected,status:o.status,type:o.type,hasForgeSymbol:n}),n&&o.redirected){const i=typeof e=="string"?e:e.url,a=o.url;if(U.debug("Redirect detected",{requested:i,final:a,redirected:o.redirected}),nr(a)){const c=new URL(a),s=c.pathname+c.search;return U.debug("Redirect detected to:",s,"- will navigate after current request completes"),new Response(JSON.stringify({layout:[],view:{}}),{status:200,headers:{"Content-Type":"application/json","X-Forge-Redirect":"true","X-Forge-Redirect-Path":s}})}}return o})}or();const ir={configUpdate(e){if(typeof e!="function")throw new Error("Middleware must be a function");J.push(e)},reset(){J.length=0},getMiddlewareCount(){return J.length}};let ae;async function ar(e,t){let r=window.__COMPONENT_DIR__||t.component_dir;if(!r&&typeof r!="string")throw new Error("No component directory provided");let n=window.__ROUTING__;if(ae=Ze(n),window&&window.location){const o=(window.location.pathname||"/").split("?")[0],i=ae.find(c=>c.parser(o));let a=i?n.find(c=>c.path===i.pattern):null;if(i&&a){const c=i.parser(o)||{},s=new URLSearchParams(window.location.search),u=Object.fromEntries(s.entries())||{},l={...c,...u};ze(),He(e,r,a,l,c,u),Ve(r,n,ae)}else U.warn("No matching route",o)}}exports.page=R.page;exports.shadowUrl=R.shadowUrl;exports.MANIFEST_STORE=k;exports.bootstrap_events=Ve;exports.createApp=ar;exports.fetch=ir;exports.loadRoute=He;exports.updateManifestStore=ze;exports.updateRoute=K;
|
|
1
|
+
"use strict";var nt=Object.defineProperty;var ot=(e,t,r)=>t in e?nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var ie=(e,t,r)=>ot(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("./page.svelte-CW8PJDdH.cjs");require("svelte/internal/client");const it=require("svelte"),at=require("../src/components/RecursiveRender.svelte"),A=require("svelte/store");function st(e){const t=new I.path_to_regex(e);return r=>{const n=t.match(r);if(!n)return null;const i={};for(const[o,a]of Object.entries(n))i[o]=decodeURIComponent(a);return i}}function ut(e){return e.map(t=>{const r=t.path,n=st(r);return{pattern:r,parser:n}})}var fe=function(e,t){return fe=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])},fe(e,t)};function V(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");fe(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function ct(e,t,r,n){function i(o){return o instanceof r?o:new r(function(a){a(o)})}return new(r||(r=Promise))(function(o,a){function u(l){try{c(n.next(l))}catch(p){a(p)}}function s(l){try{c(n.throw(l))}catch(p){a(p)}}function c(l){l.done?o(l.value):i(l.value).then(u,s)}c((n=n.apply(e,t||[])).next())})}function Ce(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},n,i,o,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(c){return function(l){return s([c,l])}}function s(c){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(r=0)),r;)try{if(n=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,i=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){r.label=c[1];break}if(c[0]===6&&r.label<o[1]){r.label=o[1],o=c;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(c);break}o[2]&&r.ops.pop(),r.trys.pop();continue}c=t.call(e,r)}catch(l){c=[6,l],i=0}finally{n=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function z(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function B(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,o=[],a;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(u){a={error:u}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return o}function Y(e,t,r){if(r||arguments.length===2)for(var n=0,i=t.length,o;n<i;n++)(o||!(n in t))&&(o||(o=Array.prototype.slice.call(t,0,n)),o[n]=t[n]);return e.concat(o||Array.prototype.slice.call(t))}function W(e){return this instanceof W?(this.v=e,this):new W(e)}function lt(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),i,o=[];return i=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",a),i[Symbol.asyncIterator]=function(){return this},i;function a(d){return function(v){return Promise.resolve(v).then(d,p)}}function u(d,v){n[d]&&(i[d]=function(f){return new Promise(function(S,w){o.push([d,f,S,w])>1||s(d,f)})},v&&(i[d]=v(i[d])))}function s(d,v){try{c(n[d](v))}catch(f){h(o[0][3],f)}}function c(d){d.value instanceof W?Promise.resolve(d.value.v).then(l,p):h(o[0][2],d)}function l(d){s("next",d)}function p(d){s("throw",d)}function h(d,v){d(v),o.shift(),o.length&&s(o[0][0],o[0][1])}}function ft(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof z=="function"?z(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(o){r[o]=e[o]&&function(a){return new Promise(function(u,s){a=e[o](a),i(u,s,a.done,a.value)})}}function i(o,a,u,s){Promise.resolve(s).then(function(c){o({value:c,done:u})},a)}}function b(e){return typeof e=="function"}function me(e){var t=function(n){Error.call(n),n.stack=new Error().stack},r=e(t);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var ae=me(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription:
|
|
2
|
+
`+r.map(function(n,i){return i+1+") "+n.toString()}).join(`
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=r}});function de(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var re=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,n,i,o;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var u=z(a),s=u.next();!s.done;s=u.next()){var c=s.value;c.remove(this)}}catch(f){t={error:f}}finally{try{s&&!s.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}else a.remove(this);var l=this.initialTeardown;if(b(l))try{l()}catch(f){o=f instanceof ae?f.errors:[f]}var p=this._finalizers;if(p){this._finalizers=null;try{for(var h=z(p),d=h.next();!d.done;d=h.next()){var v=d.value;try{Ee(v)}catch(f){o=o??[],f instanceof ae?o=Y(Y([],B(o)),B(f.errors)):o.push(f)}}}catch(f){n={error:f}}finally{try{d&&!d.done&&(i=h.return)&&i.call(h)}finally{if(n)throw n.error}}}if(o)throw new ae(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)Ee(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&de(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&de(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),je=re.EMPTY;function Le(e){return e instanceof re||e&&"closed"in e&&b(e.remove)&&b(e.add)&&b(e.unsubscribe)}function Ee(e){b(e)?e():e.unsubscribe()}var dt={Promise:void 0},ht={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return setTimeout.apply(void 0,Y([e,t],B(r)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function Ne(e){ht.setTimeout(function(){throw e})}function Oe(){}function Z(e){e()}var ye=(function(e){V(t,e);function t(r){var n=e.call(this)||this;return n.isStopped=!1,r?(n.destination=r,Le(r)&&r.add(n)):n.destination=mt,n}return t.create=function(r,n,i){return new G(r,n,i)},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(re),pt=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var r=this.partialObserver;if(r.next)try{r.next(t)}catch(n){K(n)}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t)}catch(n){K(n)}else K(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(r){K(r)}},e})(),G=(function(e){V(t,e);function t(r,n,i){var o=e.call(this)||this,a;return b(r)||!r?a={next:r??void 0,error:n??void 0,complete:i??void 0}:a=r,o.destination=new pt(a),o}return t})(ye);function K(e){Ne(e)}function vt(e){throw e}var mt={closed:!0,next:Oe,error:vt,complete:Oe},be=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function we(e){return e}function yt(e){return e.length===0?we:e.length===1?e[0]:function(r){return e.reduce(function(n,i){return i(n)},r)}}var x=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(t,r,n){var i=this,o=wt(t)?t:new G(t,r,n);return Z(function(){var a=i,u=a.operator,s=a.source;o.add(u?u.call(o,s):s?i._subscribe(o):i._trySubscribe(o))}),o},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(r){t.error(r)}},e.prototype.forEach=function(t,r){var n=this;return r=xe(r),new r(function(i,o){var a=new G({next:function(u){try{t(u)}catch(s){o(s),a.unsubscribe()}},error:o,complete:i});n.subscribe(a)})},e.prototype._subscribe=function(t){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(t)},e.prototype[be]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return yt(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=xe(t),new t(function(n,i){var o;r.subscribe(function(a){return o=a},function(a){return i(a)},function(){return n(o)})})},e.create=function(t){return new e(t)},e})();function xe(e){var t;return(t=e??dt.Promise)!==null&&t!==void 0?t:Promise}function bt(e){return e&&b(e.next)&&b(e.error)&&b(e.complete)}function wt(e){return e&&e instanceof ye||bt(e)&&Le(e)}function gt(e){return b(e==null?void 0:e.lift)}function L(e){return function(t){if(gt(t))return t.lift(function(r){try{return e(r,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function j(e,t,r,n,i){return new St(e,t,r,n,i)}var St=(function(e){V(t,e);function t(r,n,i,o,a,u){var s=e.call(this,r)||this;return s.onFinalize=a,s.shouldUnsubscribe=u,s._next=n?function(c){try{n(c)}catch(l){r.error(l)}}:e.prototype._next,s._error=o?function(c){try{o(c)}catch(l){r.error(l)}finally{this.unsubscribe()}}:e.prototype._error,s._complete=i?function(){try{i()}catch(c){r.error(c)}finally{this.unsubscribe()}}:e.prototype._complete,s}return t.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((r=this.onFinalize)===null||r===void 0||r.call(this))}},t})(ye),_t=me(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),ne=(function(e){V(t,e);function t(){var r=e.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return t.prototype.lift=function(r){var n=new Ae(this,this);return n.operator=r,n},t.prototype._throwIfClosed=function(){if(this.closed)throw new _t},t.prototype.next=function(r){var n=this;Z(function(){var i,o;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var a=z(n.currentObservers),u=a.next();!u.done;u=a.next()){var s=u.value;s.next(r)}}catch(c){i={error:c}}finally{try{u&&!u.done&&(o=a.return)&&o.call(a)}finally{if(i)throw i.error}}}})},t.prototype.error=function(r){var n=this;Z(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var i=n.observers;i.length;)i.shift().error(r)}})},t.prototype.complete=function(){var r=this;Z(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var n=this,i=this,o=i.hasError,a=i.isStopped,u=i.observers;return o||a?je:(this.currentObservers=null,u.push(r),new re(function(){n.currentObservers=null,de(u,r)}))},t.prototype._checkFinalizedStatuses=function(r){var n=this,i=n.hasError,o=n.thrownError,a=n.isStopped;i?r.error(o):a&&r.complete()},t.prototype.asObservable=function(){var r=new x;return r.source=this,r},t.create=function(r,n){return new Ae(r,n)},t})(x),Ae=(function(e){V(t,e);function t(r,n){var i=e.call(this)||this;return i.destination=r,i.source=n,i}return t.prototype.next=function(r){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,r)},t.prototype.error=function(r){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,r)},t.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},t.prototype._subscribe=function(r){var n,i;return(i=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&i!==void 0?i:je},t})(ne),Fe={now:function(){return(Fe.delegate||Date).now()},delegate:void 0},Et=(function(e){V(t,e);function t(r,n,i){r===void 0&&(r=1/0),n===void 0&&(n=1/0),i===void 0&&(i=Fe);var o=e.call(this)||this;return o._bufferSize=r,o._windowTime=n,o._timestampProvider=i,o._buffer=[],o._infiniteTimeWindow=!0,o._infiniteTimeWindow=n===1/0,o._bufferSize=Math.max(1,r),o._windowTime=Math.max(1,n),o}return t.prototype.next=function(r){var n=this,i=n.isStopped,o=n._buffer,a=n._infiniteTimeWindow,u=n._timestampProvider,s=n._windowTime;i||(o.push(r),!a&&o.push(u.now()+s)),this._trimBuffer(),e.prototype.next.call(this,r)},t.prototype._subscribe=function(r){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(r),i=this,o=i._infiniteTimeWindow,a=i._buffer,u=a.slice(),s=0;s<u.length&&!r.closed;s+=o?1:2)r.next(u[s]);return this._checkFinalizedStatuses(r),n},t.prototype._trimBuffer=function(){var r=this,n=r._bufferSize,i=r._timestampProvider,o=r._buffer,a=r._infiniteTimeWindow,u=(a?1:2)*n;if(n<1/0&&u<o.length&&o.splice(0,o.length-u),!a){for(var s=i.now(),c=0,l=1;l<o.length&&o[l]<=s;l+=2)c=l;c&&o.splice(0,c+1)}},t})(ne),ge=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function Ue(e){return b(e==null?void 0:e.then)}function ke(e){return b(e[be])}function $e(e){return Symbol.asyncIterator&&b(e==null?void 0:e[Symbol.asyncIterator])}function Me(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function Ot(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var De=Ot();function We(e){return b(e==null?void 0:e[De])}function qe(e){return lt(this,arguments,function(){var r,n,i,o;return Ce(this,function(a){switch(a.label){case 0:r=e.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,W(r.read())];case 3:return n=a.sent(),i=n.value,o=n.done,o?[4,W(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,W(i)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function ze(e){return b(e==null?void 0:e.getReader)}function N(e){if(e instanceof x)return e;if(e!=null){if(ke(e))return xt(e);if(ge(e))return At(e);if(Ue(e))return Tt(e);if($e(e))return Be(e);if(We(e))return It(e);if(ze(e))return Pt(e)}throw Me(e)}function xt(e){return new x(function(t){var r=e[be]();if(b(r.subscribe))return r.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function At(e){return new x(function(t){for(var r=0;r<e.length&&!t.closed;r++)t.next(e[r]);t.complete()})}function Tt(e){return new x(function(t){e.then(function(r){t.closed||(t.next(r),t.complete())},function(r){return t.error(r)}).then(null,Ne)})}function It(e){return new x(function(t){var r,n;try{for(var i=z(e),o=i.next();!o.done;o=i.next()){var a=o.value;if(t.next(a),t.closed)return}}catch(u){r={error:u}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}t.complete()})}function Be(e){return new x(function(t){Rt(e,t).catch(function(r){return t.error(r)})})}function Pt(e){return Be(qe(e))}function Rt(e,t){var r,n,i,o;return ct(this,void 0,void 0,function(){var a,u;return Ce(this,function(s){switch(s.label){case 0:s.trys.push([0,5,6,11]),r=ft(e),s.label=1;case 1:return[4,r.next()];case 2:if(n=s.sent(),!!n.done)return[3,4];if(a=n.value,t.next(a),t.closed)return[2];s.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return u=s.sent(),i={error:u},[3,11];case 6:return s.trys.push([6,,9,10]),n&&!n.done&&(o=r.return)?[4,o.call(r)]:[3,8];case 7:s.sent(),s.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function $(e,t,r,n,i){n===void 0&&(n=0),i===void 0&&(i=!1);var o=t.schedule(function(){r(),i?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(o),!i)return o}function Ge(e,t){return t===void 0&&(t=0),L(function(r,n){r.subscribe(j(n,function(i){return $(n,e,function(){return n.next(i)},t)},function(){return $(n,e,function(){return n.complete()},t)},function(i){return $(n,e,function(){return n.error(i)},t)}))})}function Ve(e,t){return t===void 0&&(t=0),L(function(r,n){n.add(e.schedule(function(){return r.subscribe(n)},t))})}function Ct(e,t){return N(e).pipe(Ve(t),Ge(t))}function jt(e,t){return N(e).pipe(Ve(t),Ge(t))}function Lt(e,t){return new x(function(r){var n=0;return t.schedule(function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())})})}function Nt(e,t){return new x(function(r){var n;return $(r,t,function(){n=e[De](),$(r,t,function(){var i,o,a;try{i=n.next(),o=i.value,a=i.done}catch(u){r.error(u);return}a?r.complete():r.next(o)},0,!0)}),function(){return b(n==null?void 0:n.return)&&n.return()}})}function He(e,t){if(!e)throw new Error("Iterable cannot be null");return new x(function(r){$(r,t,function(){var n=e[Symbol.asyncIterator]();$(r,t,function(){n.next().then(function(i){i.done?r.complete():r.next(i.value)})},0,!0)})})}function Ft(e,t){return He(qe(e),t)}function Ut(e,t){if(e!=null){if(ke(e))return Ct(e,t);if(ge(e))return Lt(e,t);if(Ue(e))return jt(e,t);if($e(e))return He(e,t);if(We(e))return Nt(e,t);if(ze(e))return Ft(e,t)}throw Me(e)}function Ye(e,t){return t?Ut(e,t):N(e)}var kt=me(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function $t(e,t){return new Promise(function(r,n){var i=new G({next:function(o){r(o),i.unsubscribe()},error:n,complete:function(){n(new kt)}});e.subscribe(i)})}function Se(e,t){return L(function(r,n){var i=0;r.subscribe(j(n,function(o){n.next(e.call(t,o,i++))}))})}var Mt=Array.isArray;function Dt(e,t){return Mt(t)?e.apply(void 0,Y([],B(t))):e(t)}function Wt(e){return Se(function(t){return Dt(e,t)})}function qt(e,t,r,n,i,o,a,u){var s=[],c=0,l=0,p=!1,h=function(){p&&!s.length&&!c&&t.complete()},d=function(f){return c<n?v(f):s.push(f)},v=function(f){c++;var S=!1;N(r(f,l++)).subscribe(j(t,function(w){t.next(w)},function(){S=!0},void 0,function(){if(S)try{c--;for(var w=function(){var g=s.shift();a||v(g)};s.length&&c<n;)w();h()}catch(g){t.error(g)}}))};return e.subscribe(j(t,d,function(){p=!0,h()})),function(){}}function Je(e,t,r){return r===void 0&&(r=1/0),b(t)?Je(function(n,i){return Se(function(o,a){return t(n,o,i,a)})(N(e(n,i)))},r):(typeof t=="number"&&(r=t),L(function(n,i){return qt(n,i,e,r)}))}var zt=["addListener","removeListener"],Bt=["addEventListener","removeEventListener"],Gt=["on","off"];function he(e,t,r,n){if(b(r)&&(n=r,r=void 0),n)return he(e,t,r).pipe(Wt(n));var i=B(Yt(e)?Bt.map(function(u){return function(s){return e[u](t,s,r)}}):Vt(e)?zt.map(Te(e,t)):Ht(e)?Gt.map(Te(e,t)):[],2),o=i[0],a=i[1];if(!o&&ge(e))return Je(function(u){return he(u,t,r)})(N(e));if(!o)throw new TypeError("Invalid event target");return new x(function(u){var s=function(){for(var c=[],l=0;l<arguments.length;l++)c[l]=arguments[l];return u.next(1<c.length?c:c[0])};return o(s),function(){return a(s)}})}function Te(e,t){return function(r){return function(n){return e[r](t,n)}}}function Vt(e){return b(e.addListener)&&b(e.removeListener)}function Ht(e){return b(e.on)&&b(e.off)}function Yt(e){return b(e.addEventListener)&&b(e.removeEventListener)}function se(e,t){return L(function(r,n){var i=0;r.subscribe(j(n,function(o){return e.call(t,o,i++)&&n.next(o)}))})}function Jt(e,t){return t===void 0&&(t=we),e=e??Kt,L(function(r,n){var i,o=!0;r.subscribe(j(n,function(a){var u=t(a);(o||!e(i,u))&&(o=!1,i=u,n.next(a))}))})}function Kt(e,t){return e===t}function Xt(e){e===void 0&&(e={});var t=e.connector,r=t===void 0?function(){return new ne}:t,n=e.resetOnError,i=n===void 0?!0:n,o=e.resetOnComplete,a=o===void 0?!0:o,u=e.resetOnRefCountZero,s=u===void 0?!0:u;return function(c){var l,p,h,d=0,v=!1,f=!1,S=function(){p==null||p.unsubscribe(),p=void 0},w=function(){S(),l=h=void 0,v=f=!1},g=function(){var _=l;w(),_==null||_.unsubscribe()};return L(function(_,P){d++,!f&&!v&&S();var R=h=h??r();P.add(function(){d--,d===0&&!f&&!v&&(p=ue(g,s))}),R.subscribe(P),!l&&d>0&&(l=new G({next:function(C){return R.next(C)},error:function(C){f=!0,S(),p=ue(w,i,C),R.error(C)},complete:function(){v=!0,S(),p=ue(w,a),R.complete()}}),N(_).subscribe(l))})(c)}}function ue(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];if(t===!0){e();return}if(t!==!1){var i=new G({next:function(){i.unsubscribe(),e()}});return N(t.apply(void 0,Y([],B(r)))).subscribe(i)}}function Ke(e,t){return L(function(r,n){var i=null,o=0,a=!1,u=function(){return a&&!i&&n.complete()};r.subscribe(j(n,function(s){i==null||i.unsubscribe();var c=0,l=o++;N(e(s,l)).subscribe(i=j(n,function(p){return n.next(t?t(s,p,l,c++):p)},function(){i=null,u()}))},function(){a=!0,u()}))})}function Zt(e,t,r){var n=b(e)||t||r?{next:e,error:t,complete:r}:e;return n?L(function(i,o){var a;(a=n.subscribe)===null||a===void 0||a.call(n);var u=!0;i.subscribe(j(o,function(s){var c;(c=n.next)===null||c===void 0||c.call(n,s),o.next(s)},function(){var s;u=!1,(s=n.complete)===null||s===void 0||s.call(n),o.complete()},function(s){var c;u=!1,(c=n.error)===null||c===void 0||c.call(n,s),o.error(s)},function(){var s,c;u&&((s=n.unsubscribe)===null||s===void 0||s.call(n)),(c=n.finalize)===null||c===void 0||c.call(n)}))}):we}const q=A.writable({});async function Xe(){q.update(e=>(Object.assign(e,window.__MANIFEST__),e))}const F=new Map,Q=5e3;function Qt(e){const t=F.get(e);return t?(F.delete(e),Date.now()-t.createdAt>Q?(t.abortController.abort(),null):t.response$):null}function er(e,t){he(document,"mouseover").pipe(Xt()).pipe(Se(i=>{const o=i.target,a=(o==null?void 0:o.tagName)==="A"?o:o==null?void 0:o.closest("A");if(!a)return null;const u=a.getAttribute("href");return!u||!u.startsWith("/")&&!u.startsWith(".")?null:u}),se(i=>i!==null),se(i=>i!==window.location.pathname),Jt(),se(i=>{const o=i.split("?")[0],a="get",u=e.find(l=>l.method.toLowerCase()===a&&t.find(p=>p.parser(o)&&p.pattern===l.path));if(!u)return!1;const s=t.find(l=>l.parser(o)&&l.pattern===u.path);return!!A.get(q)[s==null?void 0:s.pattern]}),Ke(i=>{const o=F.get(i);if(o&&Date.now()-o.createdAt<Q)return[];const a=new AbortController,u=new Et(1),s={response$:u,createdAt:Date.now(),abortController:a};F.set(i,s);const c={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:a.signal};return c[oe]=!0,Ye(fetch(i,c).then(l=>(u.next(l),u.complete(),i),l=>(u.error(l),F.delete(i),null))).pipe(Zt({unsubscribe:()=>{a.abort(),F.delete(i)}}))})).subscribe(),setInterval(()=>{const i=Date.now();for(const[o,a]of F)i-a.createdAt>Q&&(a.abortController.abort(),F.delete(o))},Q)}var k=(e=>(e[e.TRACE=0]="TRACE",e[e.DEBUG=1]="DEBUG",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.FATAL=5]="FATAL",e))(k||{});const tr={trace:0,debug:1,info:2,warn:3,error:4,fatal:5};function rr(e){if(!e)return 2;const t=e.trim().toLowerCase(),r=tr[t];if(typeof r=="number")return r;const n=Number(t);return Number.isFinite(n)&&n>=0&&n<=5?n:2}function Ze(e){switch(e){case 0:return"TRACE";case 1:return"DEBUG";case 2:return"INFO";case 3:return"WARN";case 4:return"ERROR";case 5:return"FATAL";default:return"INFO"}}function Ie(e){if(e===void 0)return"undefined";if(e===null)return null;if(e instanceof Error)return{name:e.name,message:e.message,stack:e.stack};switch(typeof e){case"string":case"number":case"boolean":return e;case"bigint":return e.toString();case"symbol":return String(e);case"function":return`[Function${e.name?`: ${e.name}`:""}]`;default:return e}}class nr{constructor(t,r,n){this.name=t,this.manager=r,this.contextData=n}named(t){return new pe(t,this.manager,this.contextData)}withContext(t){const r=this.contextData?{...this.contextData,...t}:t;return new pe(this.name,this.manager,r)}trace(t,...r){this.log(k.TRACE,t,r)}debug(t,...r){this.log(k.DEBUG,t,r)}info(t,...r){this.log(k.INFO,t,r)}warn(t,...r){this.log(k.WARN,t,r)}error(t,...r){this.log(k.ERROR,t,r)}fatal(t,...r){this.log(k.FATAL,t,r)}log(t,r,n){if(!this.manager.shouldLog(t,this.name))return;const i=new Date().toISOString();let o=n.length>0?n.length===1?Ie(n[0]):n.map(Ie):void 0,a;this.contextData&&o!==void 0?a={...this.contextData,args:o}:this.contextData?a=this.contextData:a=o,this.manager.log({timestamp:i,level:Ze(t),logger:this.name,message:r,context:a})}}class pe extends nr{constructor(t,r,n){super(t,r,n)}}class or{log(t){const r=t.context!==void 0?` ${JSON.stringify(t.context)}`:"",n=`[${t.timestamp}] [${t.logger}] [${t.level}] ${t.message}${r}`;switch(t.level){case"ERROR":case"FATAL":console.error(n);break;case"WARN":console.warn(n);break;default:console.log(n);break}}}const ce=Symbol.for("@noego/logger");class ir{constructor(){var i,o,a;this.transports=[],this.loggerLevels=new Map;const t=typeof process<"u"?(i=process.env)==null?void 0:i.LOG_LEVEL:void 0,r=typeof process<"u"?(o=process.env)==null?void 0:o.SERVICE_NAME:void 0,n=typeof process<"u"?(a=process.env)==null?void 0:a.NODE_ENV:void 0;this.level=rr(t),this.service=r??"noego",this.environment=n??"development"}getLevel(){return this.level}setLevel(t){this.level=t}setLoggerLevel(t,r){this.loggerLevels.set(t,r)}shouldLog(t,r){if(r){const n=this.loggerLevels.get(r);if(n!==void 0)return t>=n}return t>=this.level}addTransport(t){this.transports.push(t)}setTransports(t){this.transports=[...t]}clearTransports(){this.transports=[]}setServiceName(t){this.service=t}log(t){const r={...t,environment:this.environment,service:this.service};for(const n of this.transports)n.log(r)}async closeAll(){for(const t of this.transports)t.close&&await t.close()}formatMessage(t,r,n){return`[${new Date().toISOString()}] [${r}] [${Ze(t)}] ${n}`}}function Qe(){const e=globalThis;if(!e[ce]){const t=new ir;t.addTransport(new or),e[ce]=t}return e[ce]}function _e(e){return new pe(e,Qe())}const m=_e("forge:nav"),ar=1e4;function sr(e,t,r){let n=null,i=!1;const o=new Promise((a,u)=>{n=setTimeout(()=>{i=!0,m.error("Timeout fired after",t,"ms"),r(),u(new Error(`Navigation timed out after ${t}ms`))},t),m.debug("Timeout scheduled for",t,"ms, timeoutId:",n)});return Promise.race([e.finally(()=>{n!==null&&(i?m.warn("Promise settled AFTER timeout already fired"):(m.debug("Clearing timeout",n,"- promise settled successfully"),clearTimeout(n)))}),o])}const ve=new ne;let E=0,H=null;function ur(e){e&&e.redirectPath&&(m.debug("Handling redirect to",e.redirectPath),setTimeout(()=>{window.dispatchEvent(new CustomEvent("forge-redirect",{detail:{path:e.redirectPath}}))},0))}ve.pipe(Ke(e=>Ye(sr(fr(e),ar,()=>{m.error("Navigation timed out"),E++,H&&(H.abort(),H=null)}).catch(t=>{m.error("Navigation failed:",t)})))).subscribe({next:ur,error:e=>{m.error("Stream error:",e)}});function cr(e){var t;m.debug("Pushing navigation event to stream",{url:e.url,currentNavigationId:E,subscriberCount:((t=ve.observers)==null?void 0:t.length)||0}),ve.next(e)}const T=A.writable({active:{layouts:[],view:null,viewPath:null,layoutPaths:[],data:{layout:[],view:{}},params:{},urlParams:{},query:{}},phase:"idle",navigationId:0,page:I.page}),lr=async()=>{const e=A.get(T).navigationId;try{const t=window.location.pathname+window.location.search,r={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"}};r[oe]=!0;const n=await fetch(t,r);if(!n.ok)return!1;const i=await n.json(),o=A.get(T).navigationId;return e!==o?(m.debug("Discarding stale poll response",{pollNavigationId:e,currentNavigationId:o}),!1):(T.update(a=>{var u;return a.active.data={layout:((u=a.active.data)==null?void 0:u.layout)||[],view:i.view},a}),!0)}catch{return!1}};I.page.update(e=>(e.poll=lr,e));async function et(e,t,r,n,i){if(!t.controller)return;let o=J(e,t.controller).toString();i&&(o=o.replace(/\.svelte\.ts$/,".js").replace(/\.ts$/,".js"),/\.[a-z]+$/.test(o)||(o+=".js")),o.startsWith("/")||(o="/"+o);const u=(await import(o)).default,s=new u;return typeof s.initialize=="function"&&await Promise.resolve(s.initialize(r,n)),s}function J(...e){let t=e.map((r,n)=>n===0?r.replace(/\/+$/,""):r.replace(/^\/+|\/+$/g,"")).join("/");return t.startsWith("/")||(t="/"+t),t.split("?")[0]}async function tt(e,t,r,n,i,o){try{const a=typeof t=="string"&&t.indexOf("assets")!==-1,u=(r.layout||[]).map(w=>{let g=J(t,w).toString();return a&&(g=g.endsWith(".svelte")?g.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(g)?g:g+".js"),g});let s=J(t,r.view).toString();a&&(s=s.endsWith(".svelte")?s.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(s)?s:s+".js");const c=await Promise.all(u.map(w=>import(w).then(g=>g.default)));s.startsWith("/")||(s="/"+s);const l=await import(s).then(w=>w.default),p=window.__INITIAL_DATA__||{layout:[],view:{}},h=typeof t=="string"&&t.indexOf("assets")!==-1,d=A.get(I.page),v={params:n,urlParams:i,query:o,page:d},f=await et(t,r,p.view,v,h),S={layouts:c,view:l,viewPath:r.view||null,layoutPaths:r.layout||[],data:p,params:n,urlParams:i,query:o,controller:f};T.update(w=>(w.active=S,w.phase="idle",w)),it.hydrate(at,{target:e,props:{root:T}})}catch(a){m.error("Client-side route loading failed:",a)}}function ee(e,t,r,n,i,o,a=!1,u=!0){cr({url:e,base_path:t,route:r,params:n,urlParams:i,query:o,server_loading:a,updateUrl:u})}async function fr(e){var p;const{url:t,base_path:r,route:n,params:i,urlParams:o,query:a,server_loading:u,updateUrl:s}=e,c=++E,l=new AbortController;H=l,m.debug("Starting navigation",{navigationId:c,url:t,updateUrl:s,server_loading:u,currentNavigationId:E,hasAbortController:!!H}),T.update(h=>(h.phase="loading",h.navigationId=c,h));try{let h={layout:[],view:{}};if(u){m.debug("Fetching server data",{navigationId:c,url:t});let y=null;const O=Qt(t);if(O)try{m.debug("Using prefetched response for",t),y=await $t(O)}catch{m.debug("Prefetch failed, falling back to fetch",t),y=null}if(!y){const M={method:n.method,headers:{"Content-Type":"application/json",Accept:"application/json"},signal:l.signal};M[oe]=!0,y=await fetch(t,M)}if(m.debug("Fetch response received",{navigationId:c,url:t,ok:y.ok,status:y.status,redirected:y.redirected,currentNavigationId:E}),y.redirected||y.headers.get("X-Forge-Redirect")==="true")return m.debug("Redirect detected"),T.update(M=>(M.phase="idle",M)),{redirectPath:y.headers.get("X-Forge-Redirect-Path")||void 0};if(!y.ok)throw new Error(`Network response was not ok: ${y.status}`);h=await y.json(),m.debug("Server data received:",h)}if(c!==E){m.debug("Stale navigation after fetch, aborting",{navigationId:c,currentNavigationId:E});return}m.debug("Loading components",{navigationId:c,view:n.view,layouts:n.layout});const d=typeof r=="string"&&r.indexOf("assets")!==-1,v=(n.layout||[]).map(y=>{let O=J(r,y).toString();return d&&(O=O.endsWith(".svelte")?O.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(O)?O:O+".js"),O});let f=J(r,n.view).toString();d&&(f=f.endsWith(".svelte")?f.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(f)?f:f+".js"),f.startsWith("/")||(f="/"+f);const S=await Promise.all(v.map(y=>import(y).then(O=>O.default))),w=await import(f).then(y=>y.default);if(m.debug("Components loaded",{navigationId:c,currentNavigationId:E,layoutsCount:S.length,viewLoaded:!!w}),c!==E){m.debug("Stale navigation after component load, aborting",{navigationId:c,currentNavigationId:E});return}const g=A.get(I.page),_={params:i,urlParams:o,query:a,page:g},P=await et(r,n,h.view,_,d);if(c!==E){m.debug("Stale navigation after controller resolution, aborting",{navigationId:c,currentNavigationId:E}),(p=P==null?void 0:P.destroy)==null||p.call(P);return}const R=A.get(T).active.controller;R!=null&&R.destroy&&R.destroy();const C={layouts:S,view:w,viewPath:n.view||null,layoutPaths:n.layout||[],data:h,params:i,urlParams:o,query:a,controller:P};m.debug("Committing new state",{navigationId:c,currentNavigationId:E,layoutsCount:C.layouts.length,viewSet:!!C.view,dataKeys:Object.keys(C.data||{})}),T.update(y=>(y.active=C,y.phase="idle",m.debug("ROOT.active updated",{navigationId:c,layoutsCount:y.active.layouts.length,viewSet:!!y.active.view,dataKeys:Object.keys(y.active.data||{}),paramsKeys:Object.keys(y.active.params||{})}),y)),typeof window<"u"&&window.scroll(0,0),s&&(m.debug("Updating browser URL",{url:t}),window.history.pushState({},"",t)),m.debug("Navigation complete",{navigationId:c,url:t})}catch(h){if(m.error("Navigation failed",{navigationId:c,currentNavigationId:E,url:t,error:h instanceof Error?h.message:String(h)}),T.update(d=>(d.phase="idle",d)),h.name==="AbortError"){m.debug("Navigation aborted");return}throw h}}const U=_e("forge:events");function rt(e,t,r){if(!document){U.error("Document not found");return}document.addEventListener("click",n=>{var a,u;const i=window.location.pathname,o=((a=n.target)==null?void 0:a.tagName)==="A"?n.target:(u=n.target)==null?void 0:u.closest("A");if(o){let s=o.getAttribute("href");if(i===s){n.preventDefault();return}if(s&&s.startsWith("/")||s.startsWith(".")){const c=s.split("?")[0],l=o.getAttribute("method")||"get",p=t.find(h=>h.method.toLowerCase()===l&&r.find(d=>d.parser(c)&&d.pattern===h.path));if(p){n.preventDefault();const h=r.find(_=>_.parser(c)&&_.pattern===p.path),d=(h==null?void 0:h.parser(c))||{},v=new URLSearchParams(s.split("?")[1]||""),f=Object.fromEntries(v.entries())||{},S={...d,...f},g=A.get(q)[h==null?void 0:h.pattern];I.page.update(_=>(_.url=s,_.pathname=c,_.params=d,_.query=f,_)),U.debug("Click navigation to",s),ee(s,e,p,S,d,f,g,!0)}else U.warn("No matching route found",s,"- using fallback navigation")}}}),window.addEventListener("popstate",n=>{const i=window.location.pathname,o=window.location.pathname+window.location.search,a="get",u=t.find(s=>s.method.toLowerCase()===a&&r.find(c=>c.parser(i)&&c.pattern===s.path));if(u){const s=r.find(f=>f.parser(i)&&f.pattern===u.path),c=(s==null?void 0:s.parser(i))||{},l=new URLSearchParams(window.location.search),p=Object.fromEntries(l.entries())||{};I.page.update(f=>(f.url=o,f.pathname=window.location.pathname,f.params=c,f.query=p,f));const h={...c,...p},v=A.get(q)[s==null?void 0:s.pattern];U.debug("Popstate navigation to",o),ee(o,e,u,h,c,p,v,!1)}else U.warn("No matching route found",i,"- using fallback navigation"),window.location.href=i}),window.addEventListener("forge-redirect",(n=>{const i=n.detail.path,o=i.split("?")[0];U.debug("Handling forge-redirect to:",i);const a="get",u=t.find(s=>s.method.toLowerCase()===a&&r.find(c=>c.parser(o)&&c.pattern===s.path));if(u){const s=r.find(f=>f.parser(o)&&f.pattern===u.path),c=(s==null?void 0:s.parser(o))||{},l=new URLSearchParams(i.split("?")[1]||""),p=Object.fromEntries(l.entries())||{},h={...c,...p},v=A.get(q)[s==null?void 0:s.pattern];I.page.update(f=>(f.url=i,f.pathname=o,f.params=c,f.query=p,f)),ee(i,e,u,h,c,p,v,!0)}else U.warn("No matching route found",o,"- using fallback navigation"),window.location.href=o})),er(t,r)}const Pe="/__forge/dev-logs",dr=100,hr=20;class pr{constructor(){ie(this,"buffer",[]);ie(this,"timer",null);typeof window<"u"&&window.addEventListener("beforeunload",()=>{this.beaconFlush()})}log(t){if(this.buffer.push(t),this.buffer.length>=hr){this.flush();return}this.timer||(this.timer=setTimeout(()=>this.flush(),dr))}flush(){if(this.timer&&(clearTimeout(this.timer),this.timer=null),this.buffer.length===0)return;const t=this.buffer;this.buffer=[];try{fetch(Pe,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),keepalive:!0}).catch(()=>{})}catch{}}beaconFlush(){if(this.buffer.length===0)return;const t=this.buffer;this.buffer=[];try{navigator.sendBeacon(Pe,JSON.stringify(t))}catch{}}}const D=_e("forge:client"),oe=Symbol("forge-load-function");let te=[],X=null;function vr(e){try{const t=new URL(e,window.location.origin);return t.origin===window.location.origin&&!t.pathname.startsWith("/api/")}catch{return!e.startsWith("/api/")}}function mr(){typeof window<"u"&&!X&&(X=window.fetch,window.fetch=async function(e,t={}){if((typeof e=="string"?e:e instanceof URL?e.toString():e.url)==="/__forge/dev-logs")return X(e,t);let n={...t};for(const a of te)try{if(a.length===2){const u=new Headers(n.headers),s=Object.fromEntries(u.entries());await new Promise((c,l)=>{try{a(s,p=>{if(p)l(p);else{const h=new Headers;Object.entries(s).forEach(([d,v])=>{v!==void 0&&h.set(d,v)}),n.headers=h,c()}})}catch(p){l(p)}})}else{const u=await a(n,e);u&&typeof u=="object"&&(n=u)}}catch(u){throw D.error("Middleware error",u),u}const i=n==null?void 0:n[oe];D.debug("Fetch override request",{url:e,hasForgeSymbol:i,headers:n==null?void 0:n.headers});const o=await X(e,n);if(D.debug("Fetch override response",{url:e,responseUrl:o.url,redirected:o.redirected,status:o.status,type:o.type,hasForgeSymbol:i}),i&&o.redirected){const a=typeof e=="string"?e:e.url,u=o.url;if(D.debug("Redirect detected",{requested:a,final:u,redirected:o.redirected}),vr(u)){const s=new URL(u),c=s.pathname+s.search;return D.debug("Redirect detected to:",c,"- will navigate after current request completes"),new Response(JSON.stringify({layout:[],view:{}}),{status:200,headers:{"Content-Type":"application/json","X-Forge-Redirect":"true","X-Forge-Redirect-Path":c}})}}return o})}mr();var Re;if(typeof window<"u"){const e=window.__CONFIGURATION__;(Re=e==null?void 0:e.dev)!=null&&Re.enable_debug_log&&Qe().addTransport(new pr)}const yr={configUpdate(e){if(typeof e!="function")throw new Error("Middleware must be a function");te.push(e)},reset(){te.length=0},getMiddlewareCount(){return te.length}};let le;async function br(e,t){let r=window.__COMPONENT_DIR__||t.component_dir;if(!r&&typeof r!="string")throw new Error("No component directory provided");let n=window.__ROUTING__;if(le=ut(n),window&&window.location){const i=(window.location.pathname||"/").split("?")[0],o=le.find(u=>u.parser(i));let a=o?n.find(u=>u.path===o.pattern):null;if(o&&a){const u=o.parser(i)||{},s=new URLSearchParams(window.location.search),c=Object.fromEntries(s.entries())||{},l={...u,...c};Xe(),tt(e,r,a,l,u,c),rt(r,n,le)}else D.warn("No matching route",i)}}exports.page=I.page;exports.shadowUrl=I.shadowUrl;exports.MANIFEST_STORE=q;exports.bootstrap_events=rt;exports.createApp=br;exports.fetch=yr;exports.loadRoute=tt;exports.updateManifestStore=Xe;exports.updateRoute=ee;
|
|
4
4
|
//# sourceMappingURL=client.cjs.map
|