@noego/forge 0.1.6 → 0.1.8
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 +86 -0
- package/dist/client.cjs +2 -2
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.mjs +28 -21
- package/dist/client.mjs.map +1 -1
- package/dist/page.svelte-Bq1Q01H0.js.map +1 -1
- package/dist/page.svelte-Dvj7306U.cjs.map +1 -1
- package/dist-ssr/path-BqcF5dbs.js.map +1 -1
- package/dist-ssr/path-sxXxpB6R.cjs.map +1 -1
- package/dist-ssr/server.cjs +2 -2
- package/dist-ssr/server.cjs.map +1 -1
- package/dist-ssr/server.js +2 -2
- package/dist-ssr/server.js.map +1 -1
- package/dist-ssr/shared.cjs.map +1 -1
- package/dist-ssr/shared.js.map +1 -1
- package/dist-ssr/static.cjs +1 -1
- package/dist-ssr/static.cjs.map +1 -1
- package/dist-ssr/static.d.ts +2 -4
- package/dist-ssr/static.js +1 -1
- package/dist-ssr/static.js.map +1 -1
- package/dist-ssr/test.cjs +50 -2
- package/dist-ssr/test.cjs.map +1 -1
- package/dist-ssr/test.d.ts +4 -4
- package/dist-ssr/test.js +50 -2
- package/dist-ssr/test.js.map +1 -1
- package/dist-ssr/{url_parser-DRWHePkU.js → url_parser-ISwdI34H.js} +29 -7
- package/dist-ssr/url_parser-ISwdI34H.js.map +1 -0
- package/dist-ssr/{url_parser-CsBTlLeJ.cjs → url_parser-Wa8lcFZL.cjs} +29 -7
- package/dist-ssr/url_parser-Wa8lcFZL.cjs.map +1 -0
- package/package.json +3 -3
- package/dist-ssr/url_parser-CsBTlLeJ.cjs.map +0 -1
- package/dist-ssr/url_parser-DRWHePkU.js.map +0 -1
package/README.md
CHANGED
|
@@ -535,6 +535,92 @@ afterAll(() => {
|
|
|
535
535
|
- Always close the server after tests to release handles
|
|
536
536
|
- `buildServer()` doesn't call `listen()`, so you control the lifecycle
|
|
537
537
|
|
|
538
|
+
### Screenshot Testing with ImageRenderer
|
|
539
|
+
|
|
540
|
+
Forge includes an `ImageRenderer` for capturing screenshots of your Svelte components. This is useful for visual regression testing.
|
|
541
|
+
|
|
542
|
+
#### Prerequisites
|
|
543
|
+
|
|
544
|
+
Install Playwright as a dev dependency:
|
|
545
|
+
|
|
546
|
+
```bash
|
|
547
|
+
npm install --save-dev playwright
|
|
548
|
+
npx playwright install chromium
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
#### Basic Usage
|
|
552
|
+
|
|
553
|
+
```typescript
|
|
554
|
+
import { createImageRenderer } from '@noego/forge/test';
|
|
555
|
+
|
|
556
|
+
const renderer = await createImageRenderer({
|
|
557
|
+
outputDir: './screenshots',
|
|
558
|
+
stitchConfig: './stitch.yaml',
|
|
559
|
+
componentDir: './components',
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
// Capture a route
|
|
563
|
+
await renderer.capture('homepage', '/');
|
|
564
|
+
|
|
565
|
+
// Capture with custom viewport
|
|
566
|
+
await renderer.capture('mobile-home', '/', {
|
|
567
|
+
width: 375,
|
|
568
|
+
height: 667,
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
// Capture viewport only (not full page)
|
|
572
|
+
await renderer.capture('above-fold', '/', { fullPage: false });
|
|
573
|
+
|
|
574
|
+
// Don't forget to close when done
|
|
575
|
+
await renderer.close();
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
#### Loading Static Assets
|
|
579
|
+
|
|
580
|
+
By default, `ImageRenderer` cannot load static assets (images, fonts, etc.) because it renders HTML without a server. To enable asset loading, provide an `assets` mapping:
|
|
581
|
+
|
|
582
|
+
```typescript
|
|
583
|
+
const renderer = await createImageRenderer({
|
|
584
|
+
outputDir: './screenshots',
|
|
585
|
+
stitchConfig: './stitch.yaml',
|
|
586
|
+
componentDir: './components',
|
|
587
|
+
// Map URL paths to filesystem directories
|
|
588
|
+
assets: {
|
|
589
|
+
'/images': ['ui/resources/images'],
|
|
590
|
+
'/assets': ['public'],
|
|
591
|
+
}
|
|
592
|
+
});
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
This intercepts browser requests and serves files from your local filesystem. The format matches the server's asset configuration.
|
|
596
|
+
|
|
597
|
+
#### Configuration Options
|
|
598
|
+
|
|
599
|
+
| Option | Type | Default | Description |
|
|
600
|
+
|--------|------|---------|-------------|
|
|
601
|
+
| `outputDir` | `string` | required | Directory to save screenshots |
|
|
602
|
+
| `stitchConfig` | `string` | - | Path to stitch.yaml |
|
|
603
|
+
| `componentDir` | `string` | - | Path to Svelte components |
|
|
604
|
+
| `staticRenderer` | `StaticRenderer` | - | Pre-created StaticRenderer instance |
|
|
605
|
+
| `assets` | `Record<string, string[]>` | - | Asset path mappings |
|
|
606
|
+
| `width` | `number` | 1920 | Default viewport width |
|
|
607
|
+
| `height` | `number` | 1080 | Default viewport height |
|
|
608
|
+
| `deviceScaleFactor` | `number` | 1 | Device pixel ratio (2 for retina) |
|
|
609
|
+
| `format` | `'png' \| 'jpeg'` | `'png'` | Image format |
|
|
610
|
+
| `quality` | `number` | 80 | JPEG quality (0-100) |
|
|
611
|
+
| `waitUntil` | `string` | `'networkidle'` | When to consider page loaded |
|
|
612
|
+
| `timeoutMs` | `number` | 10000 | Render timeout |
|
|
613
|
+
|
|
614
|
+
#### Capture Options
|
|
615
|
+
|
|
616
|
+
| Option | Type | Default | Description |
|
|
617
|
+
|--------|------|---------|-------------|
|
|
618
|
+
| `view` | `any` | - | Data for view component |
|
|
619
|
+
| `layout` | `any[]` | - | Data for layout components |
|
|
620
|
+
| `width` | `number` | config.width | Override viewport width |
|
|
621
|
+
| `height` | `number` | config.height | Override viewport height |
|
|
622
|
+
| `fullPage` | `boolean` | `true` | Capture full page or viewport only |
|
|
623
|
+
|
|
538
624
|
### Server-Side Middleware
|
|
539
625
|
|
|
540
626
|
Define custom middleware in `x-middleware` arrays to run before rendering:
|
package/dist/client.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("./page.svelte-Dvj7306U.cjs"),Gt=require("svelte/internal/client"),Vt=require("svelte"),Ht=require("../src/components/RecursiveRender.svelte");function Wt(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,n.get?n:{enumerable:!0,get:()=>t[e]})}}return r.default=t,Object.freeze(r)}const pt=Wt(Gt);function zt(t){const r=new _.path_to_regex(t);return e=>r.match(e)
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("./page.svelte-Dvj7306U.cjs"),Gt=require("svelte/internal/client"),Vt=require("svelte"),Ht=require("../src/components/RecursiveRender.svelte");function Wt(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(r,e,n.get?n:{enumerable:!0,get:()=>t[e]})}}return r.default=t,Object.freeze(r)}const pt=Wt(Gt);function zt(t){const r=new _.path_to_regex(t);return e=>{const n=r.match(e);if(!n)return null;const o={};for(const[i,a]of Object.entries(n))o[i]=decodeURIComponent(a);return o}}function Yt(t){return t.map(r=>{const e=r.path,n=zt(e);return{pattern:e,parser:n}})}function V(){return V=Object.assign?Object.assign.bind():function(t){for(var r=1;r<arguments.length;r++){var e=arguments[r];for(var n in e)({}).hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},V.apply(null,arguments)}var j;(function(t){t.Pop="POP",t.Push="PUSH",t.Replace="REPLACE"})(j||(j={}));var at=process.env.NODE_ENV!=="production"?function(t){return Object.freeze(t)}:function(t){return t};function Bt(t,r){{typeof console<"u"&&console.warn(r);try{throw new Error(r)}catch{}}}var st="beforeunload",Kt="popstate";function Jt(t){t===void 0&&(t={});var r=t,e=r.window,n=e===void 0?document.defaultView:e,o=n.history;function i(){var p=n.location,b=p.pathname,O=p.search,x=p.hash,E=o.state||{};return[E.idx,at({pathname:b,search:O,hash:x,state:E.usr||null,key:E.key||"default"})]}var a=null;function c(){if(a)l.call(a),a=null;else{var p=j.Pop,b=i(),O=b[0],x=b[1];if(l.length)if(O!=null){var E=f-O;E&&(a={action:p,location:x,retry:function(){L(E*-1)}},L(E))}else process.env.NODE_ENV!=="production"&&Bt(!1,"You are trying to block a POP navigation to a location that was not created by the history library. The block will fail silently in production, but in general you should do all navigation with the history library (instead of using window.history.pushState directly) to avoid this situation.");else T(p)}}n.addEventListener(Kt,c);var s=j.Pop,u=i(),f=u[0],d=u[1],h=ut(),l=ut();f==null&&(f=0,o.replaceState(V({},o.state,{idx:f}),""));function y(p){return typeof p=="string"?p:Xt(p)}function w(p,b){return b===void 0&&(b=null),at(V({pathname:d.pathname,hash:"",search:""},typeof p=="string"?Zt(p):p,{state:b,key:Qt()}))}function S(p,b){return[{usr:p.state,key:p.key,idx:b},y(p)]}function v(p,b,O){return!l.length||(l.call({action:p,location:b,retry:O}),!1)}function T(p){s=p;var b=i();f=b[0],d=b[1],h.call({action:s,location:d})}function ot(p,b){var O=j.Push,x=w(p,b);function E(){ot(p,b)}if(v(O,x,E)){var R=S(x,f+1),Y=R[0],F=R[1];try{o.pushState(Y,"",F)}catch{n.location.assign(F)}T(O)}}function it(p,b){var O=j.Replace,x=w(p,b);function E(){it(p,b)}if(v(O,x,E)){var R=S(x,f),Y=R[0],F=R[1];o.replaceState(Y,"",F),T(O)}}function L(p){o.go(p)}var Dt={get action(){return s},get location(){return d},createHref:y,push:ot,replace:it,go:L,back:function(){L(-1)},forward:function(){L(1)},listen:function(b){return h.push(b)},block:function(b){var O=l.push(b);return l.length===1&&n.addEventListener(st,ct),function(){O(),l.length||n.removeEventListener(st,ct)}}};return Dt}function ct(t){t.preventDefault(),t.returnValue=""}function ut(){var t=[];return{get length(){return t.length},push:function(e){return t.push(e),function(){t=t.filter(function(n){return n!==e})}},call:function(e){t.forEach(function(n){return n&&n(e)})}}}function Qt(){return Math.random().toString(36).substr(2,8)}function Xt(t){var r=t.pathname,e=r===void 0?"/":r,n=t.search,o=n===void 0?"":n,i=t.hash,a=i===void 0?"":i;return o&&o!=="?"&&(e+=o.charAt(0)==="?"?o:"?"+o),a&&a!=="#"&&(e+=a.charAt(0)==="#"?a:"#"+a),e}function Zt(t){var r={};if(t){var e=t.indexOf("#");e>=0&&(r.hash=t.substr(e),t=t.substr(0,e));var n=t.indexOf("?");n>=0&&(r.search=t.substr(n),t=t.substr(0,n)),t&&(r.pathname=t)}return r}var Q=function(t,r){return Q=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])},Q(t,r)};function q(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");Q(t,r);function e(){this.constructor=t}t.prototype=r===null?Object.create(r):(e.prototype=r.prototype,new e)}function te(t,r,e,n){function o(i){return i instanceof e?i:new e(function(a){a(i)})}return new(e||(e=Promise))(function(i,a){function c(f){try{u(n.next(f))}catch(d){a(d)}}function s(f){try{u(n.throw(f))}catch(d){a(d)}}function u(f){f.done?i(f.value):o(f.value).then(c,s)}u((n=n.apply(t,r||[])).next())})}function vt(t,r){var e={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=c(0),a.throw=c(1),a.return=c(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function c(u){return function(f){return s([u,f])}}function s(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(e=0)),e;)try{if(n=1,o&&(i=u[0]&2?o.return:u[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,u[1])).done)return i;switch(o=0,i&&(u=[u[0]&2,i.value]),u[0]){case 0:case 1:i=u;break;case 4:return e.label++,{value:u[1],done:!1};case 5:e.label++,o=u[1],u=[0];continue;case 7:u=e.ops.pop(),e.trys.pop();continue;default:if(i=e.trys,!(i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){e=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){e.label=u[1];break}if(u[0]===6&&e.label<i[1]){e.label=i[1],i=u;break}if(i&&e.label<i[2]){e.label=i[2],e.ops.push(u);break}i[2]&&e.ops.pop(),e.trys.pop();continue}u=r.call(t,e)}catch(f){u=[6,f],o=0}finally{n=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function U(t){var r=typeof Symbol=="function"&&Symbol.iterator,e=r&&t[r],n=0;if(e)return e.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function X(t,r){var e=typeof Symbol=="function"&&t[Symbol.iterator];if(!e)return t;var n=e.call(t),o,i=[],a;try{for(;(r===void 0||r-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(c){a={error:c}}finally{try{o&&!o.done&&(e=n.return)&&e.call(n)}finally{if(a)throw a.error}}return i}function Z(t,r,e){if(e||arguments.length===2)for(var n=0,o=r.length,i;n<o;n++)(i||!(n in r))&&(i||(i=Array.prototype.slice.call(r,0,n)),i[n]=r[n]);return t.concat(i||Array.prototype.slice.call(r))}function k(t){return this instanceof k?(this.v=t,this):new k(t)}function ee(t,r,e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=e.apply(t,r||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),c("next"),c("throw"),c("return",a),o[Symbol.asyncIterator]=function(){return this},o;function a(l){return function(y){return Promise.resolve(y).then(l,d)}}function c(l,y){n[l]&&(o[l]=function(w){return new Promise(function(S,v){i.push([l,w,S,v])>1||s(l,w)})},y&&(o[l]=y(o[l])))}function s(l,y){try{u(n[l](y))}catch(w){h(i[0][3],w)}}function u(l){l.value instanceof k?Promise.resolve(l.value.v).then(f,d):h(i[0][2],l)}function f(l){s("next",l)}function d(l){s("throw",l)}function h(l,y){l(y),i.shift(),i.length&&s(i[0][0],i[0][1])}}function re(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r=t[Symbol.asyncIterator],e;return r?r.call(t):(t=typeof U=="function"?U(t):t[Symbol.iterator](),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(i){e[i]=t[i]&&function(a){return new Promise(function(c,s){a=t[i](a),o(c,s,a.done,a.value)})}}function o(i,a,c,s){Promise.resolve(s).then(function(u){i({value:u,done:c})},a)}}function g(t){return typeof t=="function"}function yt(t){var r=function(n){Error.call(n),n.stack=new Error().stack},e=t(r);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var B=yt(function(t){return function(e){t(this),this.message=e?e.length+` errors occurred during unsubscription:
|
|
2
2
|
`+e.map(function(n,o){return o+1+") "+n.toString()}).join(`
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=e}});function tt(t,r){if(t){var e=t.indexOf(r);0<=e&&t.splice(e,1)}}var W=function(){function t(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var r,e,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=U(a),s=c.next();!s.done;s=c.next()){var u=s.value;u.remove(this)}}catch(w){r={error:w}}finally{try{s&&!s.done&&(e=c.return)&&e.call(c)}finally{if(r)throw r.error}}else a.remove(this);var f=this.initialTeardown;if(g(f))try{f()}catch(w){i=w instanceof B?w.errors:[w]}var h=this._finalizers;if(h){this._finalizers=null;try{for(var d=U(h),l=d.next();!l.done;l=d.next()){var y=l.value;try{lt(y)}catch(w){i=i??[],w instanceof B?i=Z(Z([],X(i)),X(w.errors)):i.push(w)}}}catch(w){n={error:w}}finally{try{l&&!l.done&&(o=d.return)&&o.call(d)}finally{if(n)throw n.error}}}if(i)throw new B(i)}},t.prototype.add=function(r){var e;if(r&&r!==this)if(this.closed)lt(r);else{if(r instanceof t){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(r)}},t.prototype._hasParent=function(r){var e=this._parentage;return e===r||Array.isArray(e)&&e.includes(r)},t.prototype._addParent=function(r){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(r),e):e?[e,r]:r},t.prototype._removeParent=function(r){var e=this._parentage;e===r?this._parentage=null:Array.isArray(e)&&tt(e,r)},t.prototype.remove=function(r){var e=this._finalizers;e&&tt(e,r),r instanceof t&&r._removeParent(this)},t.EMPTY=function(){var r=new t;return r.closed=!0,r}(),t}(),wt=W.EMPTY;function bt(t){return t instanceof W||t&&"closed"in t&&g(t.remove)&&g(t.add)&&g(t.unsubscribe)}function lt(t){g(t)?t():t.unsubscribe()}var ne={Promise:void 0},oe={setTimeout:function(t,r){for(var e=[],n=2;n<arguments.length;n++)e[n-2]=arguments[n];return setTimeout.apply(void 0,Z([t,r],X(e)))},clearTimeout:function(t){return clearTimeout(t)},delegate:void 0};function mt(t){oe.setTimeout(function(){throw t})}function ft(){}function D(t){t()}var rt=function(t){q(r,t);function r(e){var n=t.call(this)||this;return n.isStopped=!1,e?(n.destination=e,bt(e)&&e.add(n)):n.destination=se,n}return r.create=function(e,n,o){return new et(e,n,o)},r.prototype.next=function(e){this.isStopped||this._next(e)},r.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(e){this.destination.next(e)},r.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(W),ie=function(){function t(r){this.partialObserver=r}return t.prototype.next=function(r){var e=this.partialObserver;if(e.next)try{e.next(r)}catch(n){M(n)}},t.prototype.error=function(r){var e=this.partialObserver;if(e.error)try{e.error(r)}catch(n){M(n)}else M(r)},t.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(e){M(e)}},t}(),et=function(t){q(r,t);function r(e,n,o){var i=t.call(this)||this,a;return g(e)||!e?a={next:e??void 0,error:n??void 0,complete:o??void 0}:a=e,i.destination=new ie(a),i}return r}(rt);function M(t){mt(t)}function ae(t){throw t}var se={closed:!0,next:ft,error:ae,complete:ft},nt=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function gt(t){return t}function ce(t){return t.length===0?gt:t.length===1?t[0]:function(e){return t.reduce(function(n,o){return o(n)},e)}}var P=function(){function t(r){r&&(this._subscribe=r)}return t.prototype.lift=function(r){var e=new t;return e.source=this,e.operator=r,e},t.prototype.subscribe=function(r,e,n){var o=this,i=le(r)?r:new et(r,e,n);return D(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},t.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(e){r.error(e)}},t.prototype.forEach=function(r,e){var n=this;return e=ht(e),new e(function(o,i){var a=new et({next:function(c){try{r(c)}catch(s){i(s),a.unsubscribe()}},error:i,complete:o});n.subscribe(a)})},t.prototype._subscribe=function(r){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(r)},t.prototype[nt]=function(){return this},t.prototype.pipe=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return ce(r)(this)},t.prototype.toPromise=function(r){var e=this;return r=ht(r),new r(function(n,o){var i;e.subscribe(function(a){return i=a},function(a){return o(a)},function(){return n(i)})})},t.create=function(r){return new t(r)},t}();function ht(t){var r;return(r=t??ne.Promise)!==null&&r!==void 0?r:Promise}function ue(t){return t&&g(t.next)&&g(t.error)&&g(t.complete)}function le(t){return t&&t instanceof rt||ue(t)&&bt(t)}function fe(t){return g(t==null?void 0:t.lift)}function $(t){return function(r){if(fe(r))return r.lift(function(e){try{return t(e,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function C(t,r,e,n,o){return new he(t,r,e,n,o)}var he=function(t){q(r,t);function r(e,n,o,i,a,c){var s=t.call(this,e)||this;return s.onFinalize=a,s.shouldUnsubscribe=c,s._next=n?function(u){try{n(u)}catch(f){e.error(f)}}:t.prototype._next,s._error=i?function(u){try{i(u)}catch(f){e.error(f)}finally{this.unsubscribe()}}:t.prototype._error,s._complete=o?function(){try{o()}catch(u){e.error(u)}finally{this.unsubscribe()}}:t.prototype._complete,s}return r.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;t.prototype.unsubscribe.call(this),!n&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},r}(rt),de=yt(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),St=function(t){q(r,t);function r(){var e=t.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return r.prototype.lift=function(e){var n=new dt(this,this);return n.operator=e,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new de},r.prototype.next=function(e){var n=this;D(function(){var o,i;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var a=U(n.currentObservers),c=a.next();!c.done;c=a.next()){var s=c.value;s.next(e)}}catch(u){o={error:u}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}}})},r.prototype.error=function(e){var n=this;D(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=e;for(var o=n.observers;o.length;)o.shift().error(e)}})},r.prototype.complete=function(){var e=this;D(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var n=e.observers;n.length;)n.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},r.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},r.prototype._innerSubscribe=function(e){var n=this,o=this,i=o.hasError,a=o.isStopped,c=o.observers;return i||a?wt:(this.currentObservers=null,c.push(e),new W(function(){n.currentObservers=null,tt(c,e)}))},r.prototype._checkFinalizedStatuses=function(e){var n=this,o=n.hasError,i=n.thrownError,a=n.isStopped;o?e.error(i):a&&e.complete()},r.prototype.asObservable=function(){var e=new P;return e.source=this,e},r.create=function(e,n){return new dt(e,n)},r}(P),dt=function(t){q(r,t);function r(e,n){var o=t.call(this)||this;return o.destination=e,o.source=n,o}return r.prototype.next=function(e){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,e)},r.prototype.error=function(e){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,e)},r.prototype.complete=function(){var e,n;(n=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||n===void 0||n.call(e)},r.prototype._subscribe=function(e){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(e))!==null&&o!==void 0?o:wt},r}(St),_t=function(t){return t&&typeof t.length=="number"&&typeof t!="function"};function Ot(t){return g(t==null?void 0:t.then)}function Et(t){return g(t[nt])}function Pt(t){return Symbol.asyncIterator&&g(t==null?void 0:t[Symbol.asyncIterator])}function xt(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function pe(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var It=pe();function At(t){return g(t==null?void 0:t[It])}function Tt(t){return ee(this,arguments,function(){var e,n,o,i;return vt(this,function(a){switch(a.label){case 0:e=t.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,k(e.read())];case 3:return n=a.sent(),o=n.value,i=n.done,i?[4,k(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,k(o)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function Rt(t){return g(t==null?void 0:t.getReader)}function z(t){if(t instanceof P)return t;if(t!=null){if(Et(t))return ve(t);if(_t(t))return ye(t);if(Ot(t))return we(t);if(Pt(t))return jt(t);if(At(t))return be(t);if(Rt(t))return me(t)}throw xt(t)}function ve(t){return new P(function(r){var e=t[nt]();if(g(e.subscribe))return e.subscribe(r);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function ye(t){return new P(function(r){for(var e=0;e<t.length&&!r.closed;e++)r.next(t[e]);r.complete()})}function we(t){return new P(function(r){t.then(function(e){r.closed||(r.next(e),r.complete())},function(e){return r.error(e)}).then(null,mt)})}function be(t){return new P(function(r){var e,n;try{for(var o=U(t),i=o.next();!i.done;i=o.next()){var a=i.value;if(r.next(a),r.closed)return}}catch(c){e={error:c}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}r.complete()})}function jt(t){return new P(function(r){ge(t,r).catch(function(e){return r.error(e)})})}function me(t){return jt(Tt(t))}function ge(t,r){var e,n,o,i;return te(this,void 0,void 0,function(){var a,c;return vt(this,function(s){switch(s.label){case 0:s.trys.push([0,5,6,11]),e=re(t),s.label=1;case 1:return[4,e.next()];case 2:if(n=s.sent(),!!n.done)return[3,4];if(a=n.value,r.next(a),r.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=e.return)?[4,i.call(e)]:[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 r.complete(),[2]}})})}function A(t,r,e,n,o){n===void 0&&(n=0),o===void 0&&(o=!1);var i=r.schedule(function(){e(),o?t.add(this.schedule(null,n)):this.unsubscribe()},n);if(t.add(i),!o)return i}function kt(t,r){return r===void 0&&(r=0),$(function(e,n){e.subscribe(C(n,function(o){return A(n,t,function(){return n.next(o)},r)},function(){return A(n,t,function(){return n.complete()},r)},function(o){return A(n,t,function(){return n.error(o)},r)}))})}function Ut(t,r){return r===void 0&&(r=0),$(function(e,n){n.add(t.schedule(function(){return e.subscribe(n)},r))})}function Se(t,r){return z(t).pipe(Ut(r),kt(r))}function _e(t,r){return z(t).pipe(Ut(r),kt(r))}function Oe(t,r){return new P(function(e){var n=0;return r.schedule(function(){n===t.length?e.complete():(e.next(t[n++]),e.closed||this.schedule())})})}function Ee(t,r){return new P(function(e){var n;return A(e,r,function(){n=t[It](),A(e,r,function(){var o,i,a;try{o=n.next(),i=o.value,a=o.done}catch(c){e.error(c);return}a?e.complete():e.next(i)},0,!0)}),function(){return g(n==null?void 0:n.return)&&n.return()}})}function Lt(t,r){if(!t)throw new Error("Iterable cannot be null");return new P(function(e){A(e,r,function(){var n=t[Symbol.asyncIterator]();A(e,r,function(){n.next().then(function(o){o.done?e.complete():e.next(o.value)})},0,!0)})})}function Pe(t,r){return Lt(Tt(t),r)}function xe(t,r){if(t!=null){if(Et(t))return Se(t,r);if(_t(t))return Oe(t,r);if(Ot(t))return _e(t,r);if(Pt(t))return Lt(t,r);if(At(t))return Ee(t,r);if(Rt(t))return Pe(t,r)}throw xt(t)}function Ie(t,r){return r?xe(t,r):z(t)}function Ae(t,r){return $(function(e,n){var o=0;e.subscribe(C(n,function(i){return t.call(r,i,o++)&&n.next(i)}))})}function Te(t,r){return r===void 0&&(r=gt),t=t??Re,$(function(e,n){var o,i=!0;e.subscribe(C(n,function(a){var c=r(a);(i||!t(o,c))&&(i=!1,o=c,n.next(a))}))})}function Re(t,r){return t===r}function je(t,r){return $(function(e,n){var o=null,i=0,a=!1,c=function(){return a&&!o&&n.complete()};e.subscribe(C(n,function(s){o==null||o.unsubscribe();var u=0,f=i++;z(t(s,f)).subscribe(o=C(n,function(h){return n.next(r?r(s,h,f,u++):h)},function(){o=null,c()}))},function(){a=!0,c()}))})}const ke=Jt(),Nt=new St;let Ct=null;Nt.pipe(Te((t,r)=>t.url===r.url&&!r.update),Ae(t=>t.url===Ct&&!t.update?(console.log("[NAVIGATION] Skipping duplicate navigation to",t.url),!1):!0),je(t=>Ie(Le(t)))).subscribe({error:t=>console.error("[NAVIGATION] Stream error:",t)});function Ue(t){Nt.next(t)}const m=pt.proxy({layouts:[],view:null,data:null,params:null,urlParams:null,query:null,page:_.page});function H(...t){let r=t.map((e,n)=>n===0?e.replace(/\/+$/,""):e.replace(/^\/+|\/+$/g,"")).join("/");return r.startsWith("/")||(r="/"+r),r.split("?")[0]}async function qt(t,r,e,n,o,i){try{const a=typeof r=="string"&&r.indexOf("assets")!==-1,c=(e.layout||[]).map(h=>{let d=H(r,h).toString();return a&&(d=d.endsWith(".svelte")?d.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(d)?d:d+".js"),d});let s=H(r,e.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(h=>import(h).then(d=>d.default)));s.startsWith("/")||(s="/"+s);const f=await import(s).then(h=>h.default);m.layouts=u,m.view=f,m.params=n,m.data=window.__INITIAL_DATA__,m.urlParams=o,m.query=i,Vt.hydrate(Ht,{target:t,props:m})}catch(a){console.error("Client-side route loading failed:",a)}}function N(t,r,e,n,o,i,a=!1,c=!0){Ue({url:t,base_path:r,route:e,params:n,urlParams:o,query:i,server_loading:a,update:c})}async function Le(t){const{url:r,base_path:e,route:n,params:o,urlParams:i,query:a,server_loading:c,update:s}=t;console.log("[NAVIGATION] updateRoute called",{url:r,server_loading:c,route_path:n.path,route_middleware:n.middleware});try{let u=null,f=!1;if(c){console.log("[NAVIGATION] Making server fetch FIRST for",r);const S={method:n.method,headers:{"Content-Type":"application/json",Accept:"application/json"}};if(S[Mt]=!0,await fetch(r,S).then(v=>{if(console.log("[NAVIGATION] Fetch response",{url:r,ok:v.ok,status:v.status,type:v.type,redirected:v.redirected,finalUrl:v.url}),v.redirected)return console.log("[NAVIGATION] Redirect detected, not loading components"),f=!0,null;if(v.ok)return v.json();throw new Error("Network response was not ok")}).then(v=>{u=v}),f){console.log("[NAVIGATION] Exiting early due to redirect");return}}const h=typeof e=="string"&&e.indexOf("assets")!==-1,d=(n.layout||[]).map(S=>{let v=H(e,S).toString();return h&&(v=v.endsWith(".svelte")?v.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(v)?v:v+".js"),v});let l=H(e,n.view).toString();h&&(l=l.endsWith(".svelte")?l.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(l)?l:l+".js");const y=await Promise.all(d.map(S=>import(S).then(v=>v.default))),w=await import(l).then(S=>S.default);c?(m.data=u,m.params=o,m.layouts=y,m.view=w,m.urlParams=i,m.query=a):(console.log("[NAVIGATION] No server loading needed for",r),m.data={layout:[],view:{}},m.params=o,m.layouts=y,m.view=w,m.urlParams=i,m.query=a),window&&window.scroll(0,0),s&&ke.push(r),Ct=r}catch(u){console.error("Client-side navigation failed for URL:",r,u)}}const I=pt.proxy({});async function $t(){Object.assign(I,window.__MANIFEST__)}function Ft(t,r,e){if(!document){console.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],f=i.getAttribute("method")||"get",h=r.find(d=>d.method.toLowerCase()===f&&e.find(l=>l.parser(u)&&l.pattern===d.path));if(h){n.preventDefault();const d=e.find(T=>T.parser(u)&&T.pattern===h.path),l=(d==null?void 0:d.parser(u))||{},y=new URLSearchParams(s.split("?")[1]||""),w=Object.fromEntries(y.entries())||{},S={...l,...w},v=I[d==null?void 0:d.pattern];console.log("[EVENTS] Navigation to",s,{pattern:d==null?void 0:d.pattern,requires_server_data:v,manifest_store:I,middleware:h.middleware}),N(s,t,h,S,l,w,v)}else console.log("No matching route found for URL:",s,"- using fallback navigation")}}}),window.addEventListener("popstate",n=>{const o=window.location.pathname,i=window.location.pathname+window.location.search;_.page.url=i,_.page.pathname=window.location.pathname;const a="get",c=r.find(s=>s.method.toLowerCase()===a&&e.find(u=>u.parser(o)&&u.pattern===s.path));if(c){const s=e.find(y=>y.parser(o)&&y.pattern===c.path),u=(s==null?void 0:s.parser(o))||{},f=new URLSearchParams(window.location.search),h=Object.fromEntries(f.entries())||{};_.page.params=u,_.page.query=h;const d={...u,...h},l=I[s==null?void 0:s.pattern];N(i,t,c,d,u,h,l,!1)}else console.log("No matching route found for popstate navigation to:",o,"- using fallback navigation"),window.location.href=o}),function(){const n=history.pushState,o=history.replaceState;history.pushState=function(...i){const a=n.apply(this,i),c=new Event("pushstate");return c.state=i[0],c.url=i[2],window.dispatchEvent(c),a},history.replaceState=function(...i){const a=o.apply(this,i),c=i[2],s=window.location.pathname;if((c?new URL(c,window.location.origin).pathname:s)!==s){const f=new Event("replacestate");f.state=i[0],f.url=i[2],window.dispatchEvent(f)}return a}}(),window.addEventListener("pushstate",n=>{const o=n.url||window.location.pathname+window.location.search,i=o.split("?")[0],a="get",c=r.find(s=>s.method.toLowerCase()===a&&e.find(u=>u.parser(i)&&u.pattern===s.path));if(c){const s=e.find(y=>y.parser(i)&&y.pattern===c.path),u=s==null?void 0:s.parser(i),f=new URLSearchParams(o.split("?")[1]||""),h=Object.fromEntries(f.entries());_.page.url=o,_.page.pathname=window.location.pathname,Object.assign(_.page.params,u),Object.assign(_.page.query,h);const d={...u,...h},l=I[s==null?void 0:s.pattern];N(o,t,c,d,u,h,l,!1)}else console.log("No matching route found for pushstate to:",i,"- using fallback navigation"),window.location.href=i}),window.addEventListener("replacestate",n=>{const o=n.url||window.location.pathname+window.location.search,i=o.split("?")[0];_.page.url=o,_.page.pathname=window.location.pathname,_.page.query=Object.fromEntries(new URLSearchParams(o.split("?")[1]||""));const a="get",c=r.find(s=>s.method.toLowerCase()===a&&e.find(u=>u.parser(i)&&u.pattern===s.path));if(c){const s=e.find(y=>y.parser(i)&&y.pattern===c.path),u=(s==null?void 0:s.parser(i))||{},f=new URLSearchParams(o.split("?")[1]||""),h=Object.fromEntries(f.entries())||{},d={...u,...h},l=I[s==null?void 0:s.pattern];N(o,t,c,d,u,h,l,!1)}else console.log("No matching route found for replacestate to:",i,"- using fallback navigation"),window.location.href=i})}const Mt=Symbol("forge-load-function");let G=[],K=null;function Ne(t){try{const r=new URL(t,window.location.origin);return r.origin===window.location.origin&&!r.pathname.startsWith("/api/")}catch{return!t.startsWith("/api/")}}function Ce(){typeof window<"u"&&!K&&(K=window.fetch,window.fetch=async function(t,r={}){let e={...r};for(const i of G)try{if(i.length===2){const a=new Headers(e.headers),c=Object.fromEntries(a.entries());await new Promise((s,u)=>{try{i(c,f=>{if(f)u(f);else{const h=new Headers;Object.entries(c).forEach(([d,l])=>{l!==void 0&&h.set(d,l)}),e.headers=h,s()}})}catch(f){u(f)}})}else{const a=await i(e,t);a&&typeof a=="object"&&(e=a)}}catch(a){throw console.error("🔴 Middleware error:",a),a}const n=e==null?void 0:e[Mt];console.log("[FETCH OVERRIDE] Request",{url:t,hasForgeSymbol:n,headers:e==null?void 0:e.headers});const o=await K(t,e);if(console.log("[FETCH OVERRIDE] Response",{url:t,responseUrl:o.url,redirected:o.redirected,status:o.status,type:o.type,hasForgeSymbol:n}),n&&o.redirected){const i=typeof t=="string"?t:t.url,a=o.url;if(console.log("[FORGE REDIRECT] Detected redirect",{requested:i,final:a,redirected:o.redirected}),Ne(a)){const c=new URL(a),s=c.pathname+c.search;return console.log("[FORGE REDIRECT] Using pushState for SPA navigation to:",s,"from:",a),history.pushState(null,"",s),new Response(JSON.stringify({layout:[],view:{}}),{status:200,headers:{"Content-Type":"application/json"}})}}return o})}Ce();const qe={configUpdate(t){if(typeof t!="function")throw new Error("Middleware must be a function");G.push(t)},reset(){G.length=0},getMiddlewareCount(){return G.length}};let J;async function $e(t,r){let e=window.__COMPONENT_DIR__||r.component_dir;if(!e&&typeof e!="string")throw new Error("No component directory provided");let n=window.__ROUTING__;if(J=Yt(n),window&&window.location){const o=(window.location.pathname||"/").split("?")[0],i=J.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())||{},f={...c,...u};$t(),qt(t,e,a,f,c,u),Ft(e,n,J)}else console.warn("No matching route found for:",o)}}exports.page=_.page;exports.shadowUrl=_.shadowUrl;exports.MANIFEST_STORE=I;exports.bootstrap_events=Ft;exports.createApp=$e;exports.fetch=qe;exports.loadRoute=qt;exports.updateManifestStore=$t;exports.updateRoute=N;
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=e}});function tt(t,r){if(t){var e=t.indexOf(r);0<=e&&t.splice(e,1)}}var W=(function(){function t(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var r,e,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=U(a),s=c.next();!s.done;s=c.next()){var u=s.value;u.remove(this)}}catch(w){r={error:w}}finally{try{s&&!s.done&&(e=c.return)&&e.call(c)}finally{if(r)throw r.error}}else a.remove(this);var f=this.initialTeardown;if(g(f))try{f()}catch(w){i=w instanceof B?w.errors:[w]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var h=U(d),l=h.next();!l.done;l=h.next()){var y=l.value;try{lt(y)}catch(w){i=i??[],w instanceof B?i=Z(Z([],X(i)),X(w.errors)):i.push(w)}}}catch(w){n={error:w}}finally{try{l&&!l.done&&(o=h.return)&&o.call(h)}finally{if(n)throw n.error}}}if(i)throw new B(i)}},t.prototype.add=function(r){var e;if(r&&r!==this)if(this.closed)lt(r);else{if(r instanceof t){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(r)}},t.prototype._hasParent=function(r){var e=this._parentage;return e===r||Array.isArray(e)&&e.includes(r)},t.prototype._addParent=function(r){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(r),e):e?[e,r]:r},t.prototype._removeParent=function(r){var e=this._parentage;e===r?this._parentage=null:Array.isArray(e)&&tt(e,r)},t.prototype.remove=function(r){var e=this._finalizers;e&&tt(e,r),r instanceof t&&r._removeParent(this)},t.EMPTY=(function(){var r=new t;return r.closed=!0,r})(),t})(),wt=W.EMPTY;function bt(t){return t instanceof W||t&&"closed"in t&&g(t.remove)&&g(t.add)&&g(t.unsubscribe)}function lt(t){g(t)?t():t.unsubscribe()}var ne={Promise:void 0},oe={setTimeout:function(t,r){for(var e=[],n=2;n<arguments.length;n++)e[n-2]=arguments[n];return setTimeout.apply(void 0,Z([t,r],X(e)))},clearTimeout:function(t){return clearTimeout(t)},delegate:void 0};function mt(t){oe.setTimeout(function(){throw t})}function ft(){}function D(t){t()}var rt=(function(t){q(r,t);function r(e){var n=t.call(this)||this;return n.isStopped=!1,e?(n.destination=e,bt(e)&&e.add(n)):n.destination=se,n}return r.create=function(e,n,o){return new et(e,n,o)},r.prototype.next=function(e){this.isStopped||this._next(e)},r.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(e){this.destination.next(e)},r.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r})(W),ie=(function(){function t(r){this.partialObserver=r}return t.prototype.next=function(r){var e=this.partialObserver;if(e.next)try{e.next(r)}catch(n){M(n)}},t.prototype.error=function(r){var e=this.partialObserver;if(e.error)try{e.error(r)}catch(n){M(n)}else M(r)},t.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(e){M(e)}},t})(),et=(function(t){q(r,t);function r(e,n,o){var i=t.call(this)||this,a;return g(e)||!e?a={next:e??void 0,error:n??void 0,complete:o??void 0}:a=e,i.destination=new ie(a),i}return r})(rt);function M(t){mt(t)}function ae(t){throw t}var se={closed:!0,next:ft,error:ae,complete:ft},nt=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function gt(t){return t}function ce(t){return t.length===0?gt:t.length===1?t[0]:function(e){return t.reduce(function(n,o){return o(n)},e)}}var P=(function(){function t(r){r&&(this._subscribe=r)}return t.prototype.lift=function(r){var e=new t;return e.source=this,e.operator=r,e},t.prototype.subscribe=function(r,e,n){var o=this,i=le(r)?r:new et(r,e,n);return D(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},t.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(e){r.error(e)}},t.prototype.forEach=function(r,e){var n=this;return e=dt(e),new e(function(o,i){var a=new et({next:function(c){try{r(c)}catch(s){i(s),a.unsubscribe()}},error:i,complete:o});n.subscribe(a)})},t.prototype._subscribe=function(r){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(r)},t.prototype[nt]=function(){return this},t.prototype.pipe=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return ce(r)(this)},t.prototype.toPromise=function(r){var e=this;return r=dt(r),new r(function(n,o){var i;e.subscribe(function(a){return i=a},function(a){return o(a)},function(){return n(i)})})},t.create=function(r){return new t(r)},t})();function dt(t){var r;return(r=t??ne.Promise)!==null&&r!==void 0?r:Promise}function ue(t){return t&&g(t.next)&&g(t.error)&&g(t.complete)}function le(t){return t&&t instanceof rt||ue(t)&&bt(t)}function fe(t){return g(t==null?void 0:t.lift)}function $(t){return function(r){if(fe(r))return r.lift(function(e){try{return t(e,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}function C(t,r,e,n,o){return new de(t,r,e,n,o)}var de=(function(t){q(r,t);function r(e,n,o,i,a,c){var s=t.call(this,e)||this;return s.onFinalize=a,s.shouldUnsubscribe=c,s._next=n?function(u){try{n(u)}catch(f){e.error(f)}}:t.prototype._next,s._error=i?function(u){try{i(u)}catch(f){e.error(f)}finally{this.unsubscribe()}}:t.prototype._error,s._complete=o?function(){try{o()}catch(u){e.error(u)}finally{this.unsubscribe()}}:t.prototype._complete,s}return r.prototype.unsubscribe=function(){var e;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;t.prototype.unsubscribe.call(this),!n&&((e=this.onFinalize)===null||e===void 0||e.call(this))}},r})(rt),he=yt(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),St=(function(t){q(r,t);function r(){var e=t.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return r.prototype.lift=function(e){var n=new ht(this,this);return n.operator=e,n},r.prototype._throwIfClosed=function(){if(this.closed)throw new he},r.prototype.next=function(e){var n=this;D(function(){var o,i;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var a=U(n.currentObservers),c=a.next();!c.done;c=a.next()){var s=c.value;s.next(e)}}catch(u){o={error:u}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}}})},r.prototype.error=function(e){var n=this;D(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=e;for(var o=n.observers;o.length;)o.shift().error(e)}})},r.prototype.complete=function(){var e=this;D(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var n=e.observers;n.length;)n.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(e){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,e)},r.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},r.prototype._innerSubscribe=function(e){var n=this,o=this,i=o.hasError,a=o.isStopped,c=o.observers;return i||a?wt:(this.currentObservers=null,c.push(e),new W(function(){n.currentObservers=null,tt(c,e)}))},r.prototype._checkFinalizedStatuses=function(e){var n=this,o=n.hasError,i=n.thrownError,a=n.isStopped;o?e.error(i):a&&e.complete()},r.prototype.asObservable=function(){var e=new P;return e.source=this,e},r.create=function(e,n){return new ht(e,n)},r})(P),ht=(function(t){q(r,t);function r(e,n){var o=t.call(this)||this;return o.destination=e,o.source=n,o}return r.prototype.next=function(e){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,e)},r.prototype.error=function(e){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,e)},r.prototype.complete=function(){var e,n;(n=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||n===void 0||n.call(e)},r.prototype._subscribe=function(e){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(e))!==null&&o!==void 0?o:wt},r})(St),_t=(function(t){return t&&typeof t.length=="number"&&typeof t!="function"});function Ot(t){return g(t==null?void 0:t.then)}function Et(t){return g(t[nt])}function Pt(t){return Symbol.asyncIterator&&g(t==null?void 0:t[Symbol.asyncIterator])}function xt(t){return new TypeError("You provided "+(t!==null&&typeof t=="object"?"an invalid object":"'"+t+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function pe(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var It=pe();function At(t){return g(t==null?void 0:t[It])}function Tt(t){return ee(this,arguments,function(){var e,n,o,i;return vt(this,function(a){switch(a.label){case 0:e=t.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,k(e.read())];case 3:return n=a.sent(),o=n.value,i=n.done,i?[4,k(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,k(o)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return e.releaseLock(),[7];case 10:return[2]}})})}function Rt(t){return g(t==null?void 0:t.getReader)}function z(t){if(t instanceof P)return t;if(t!=null){if(Et(t))return ve(t);if(_t(t))return ye(t);if(Ot(t))return we(t);if(Pt(t))return jt(t);if(At(t))return be(t);if(Rt(t))return me(t)}throw xt(t)}function ve(t){return new P(function(r){var e=t[nt]();if(g(e.subscribe))return e.subscribe(r);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function ye(t){return new P(function(r){for(var e=0;e<t.length&&!r.closed;e++)r.next(t[e]);r.complete()})}function we(t){return new P(function(r){t.then(function(e){r.closed||(r.next(e),r.complete())},function(e){return r.error(e)}).then(null,mt)})}function be(t){return new P(function(r){var e,n;try{for(var o=U(t),i=o.next();!i.done;i=o.next()){var a=i.value;if(r.next(a),r.closed)return}}catch(c){e={error:c}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}r.complete()})}function jt(t){return new P(function(r){ge(t,r).catch(function(e){return r.error(e)})})}function me(t){return jt(Tt(t))}function ge(t,r){var e,n,o,i;return te(this,void 0,void 0,function(){var a,c;return vt(this,function(s){switch(s.label){case 0:s.trys.push([0,5,6,11]),e=re(t),s.label=1;case 1:return[4,e.next()];case 2:if(n=s.sent(),!!n.done)return[3,4];if(a=n.value,r.next(a),r.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=e.return)?[4,i.call(e)]:[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 r.complete(),[2]}})})}function A(t,r,e,n,o){n===void 0&&(n=0),o===void 0&&(o=!1);var i=r.schedule(function(){e(),o?t.add(this.schedule(null,n)):this.unsubscribe()},n);if(t.add(i),!o)return i}function kt(t,r){return r===void 0&&(r=0),$(function(e,n){e.subscribe(C(n,function(o){return A(n,t,function(){return n.next(o)},r)},function(){return A(n,t,function(){return n.complete()},r)},function(o){return A(n,t,function(){return n.error(o)},r)}))})}function Ut(t,r){return r===void 0&&(r=0),$(function(e,n){n.add(t.schedule(function(){return e.subscribe(n)},r))})}function Se(t,r){return z(t).pipe(Ut(r),kt(r))}function _e(t,r){return z(t).pipe(Ut(r),kt(r))}function Oe(t,r){return new P(function(e){var n=0;return r.schedule(function(){n===t.length?e.complete():(e.next(t[n++]),e.closed||this.schedule())})})}function Ee(t,r){return new P(function(e){var n;return A(e,r,function(){n=t[It](),A(e,r,function(){var o,i,a;try{o=n.next(),i=o.value,a=o.done}catch(c){e.error(c);return}a?e.complete():e.next(i)},0,!0)}),function(){return g(n==null?void 0:n.return)&&n.return()}})}function Lt(t,r){if(!t)throw new Error("Iterable cannot be null");return new P(function(e){A(e,r,function(){var n=t[Symbol.asyncIterator]();A(e,r,function(){n.next().then(function(o){o.done?e.complete():e.next(o.value)})},0,!0)})})}function Pe(t,r){return Lt(Tt(t),r)}function xe(t,r){if(t!=null){if(Et(t))return Se(t,r);if(_t(t))return Oe(t,r);if(Ot(t))return _e(t,r);if(Pt(t))return Lt(t,r);if(At(t))return Ee(t,r);if(Rt(t))return Pe(t,r)}throw xt(t)}function Ie(t,r){return r?xe(t,r):z(t)}function Ae(t,r){return $(function(e,n){var o=0;e.subscribe(C(n,function(i){return t.call(r,i,o++)&&n.next(i)}))})}function Te(t,r){return r===void 0&&(r=gt),t=t??Re,$(function(e,n){var o,i=!0;e.subscribe(C(n,function(a){var c=r(a);(i||!t(o,c))&&(i=!1,o=c,n.next(a))}))})}function Re(t,r){return t===r}function je(t,r){return $(function(e,n){var o=null,i=0,a=!1,c=function(){return a&&!o&&n.complete()};e.subscribe(C(n,function(s){o==null||o.unsubscribe();var u=0,f=i++;z(t(s,f)).subscribe(o=C(n,function(d){return n.next(r?r(s,d,f,u++):d)},function(){o=null,c()}))},function(){a=!0,c()}))})}const ke=Jt(),Nt=new St;let Ct=null;Nt.pipe(Te((t,r)=>t.url===r.url&&!r.update),Ae(t=>t.url===Ct&&!t.update?(console.log("[NAVIGATION] Skipping duplicate navigation to",t.url),!1):!0),je(t=>Ie(Le(t)))).subscribe({error:t=>console.error("[NAVIGATION] Stream error:",t)});function Ue(t){Nt.next(t)}const m=pt.proxy({layouts:[],view:null,data:null,params:null,urlParams:null,query:null,page:_.page});function H(...t){let r=t.map((e,n)=>n===0?e.replace(/\/+$/,""):e.replace(/^\/+|\/+$/g,"")).join("/");return r.startsWith("/")||(r="/"+r),r.split("?")[0]}async function qt(t,r,e,n,o,i){try{const a=typeof r=="string"&&r.indexOf("assets")!==-1,c=(e.layout||[]).map(d=>{let h=H(r,d).toString();return a&&(h=h.endsWith(".svelte")?h.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(h)?h:h+".js"),h});let s=H(r,e.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(h=>h.default)));s.startsWith("/")||(s="/"+s);const f=await import(s).then(d=>d.default);m.layouts=u,m.view=f,m.params=n,m.data=window.__INITIAL_DATA__,m.urlParams=o,m.query=i,Vt.hydrate(Ht,{target:t,props:m})}catch(a){console.error("Client-side route loading failed:",a)}}function N(t,r,e,n,o,i,a=!1,c=!0){Ue({url:t,base_path:r,route:e,params:n,urlParams:o,query:i,server_loading:a,update:c})}async function Le(t){const{url:r,base_path:e,route:n,params:o,urlParams:i,query:a,server_loading:c,update:s}=t;console.log("[NAVIGATION] updateRoute called",{url:r,server_loading:c,route_path:n.path,route_middleware:n.middleware});try{let u=null,f=!1;if(c){console.log("[NAVIGATION] Making server fetch FIRST for",r);const S={method:n.method,headers:{"Content-Type":"application/json",Accept:"application/json"}};if(S[Mt]=!0,await fetch(r,S).then(v=>{if(console.log("[NAVIGATION] Fetch response",{url:r,ok:v.ok,status:v.status,type:v.type,redirected:v.redirected,finalUrl:v.url}),v.redirected)return console.log("[NAVIGATION] Redirect detected, not loading components"),f=!0,null;if(v.ok)return v.json();throw new Error("Network response was not ok")}).then(v=>{u=v}),f){console.log("[NAVIGATION] Exiting early due to redirect");return}}const d=typeof e=="string"&&e.indexOf("assets")!==-1,h=(n.layout||[]).map(S=>{let v=H(e,S).toString();return d&&(v=v.endsWith(".svelte")?v.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(v)?v:v+".js"),v});let l=H(e,n.view).toString();d&&(l=l.endsWith(".svelte")?l.replace(/\.svelte$/,".js"):/[.][a-z]+$/.test(l)?l:l+".js");const y=await Promise.all(h.map(S=>import(S).then(v=>v.default))),w=await import(l).then(S=>S.default);c?(m.data=u,m.params=o,m.layouts=y,m.view=w,m.urlParams=i,m.query=a):(console.log("[NAVIGATION] No server loading needed for",r),m.data={layout:[],view:{}},m.params=o,m.layouts=y,m.view=w,m.urlParams=i,m.query=a),window&&window.scroll(0,0),s&&ke.push(r),Ct=r}catch(u){console.error("Client-side navigation failed for URL:",r,u)}}const I=pt.proxy({});async function $t(){Object.assign(I,window.__MANIFEST__)}function Ft(t,r,e){if(!document){console.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],f=i.getAttribute("method")||"get",d=r.find(h=>h.method.toLowerCase()===f&&e.find(l=>l.parser(u)&&l.pattern===h.path));if(d){n.preventDefault();const h=e.find(T=>T.parser(u)&&T.pattern===d.path),l=(h==null?void 0:h.parser(u))||{},y=new URLSearchParams(s.split("?")[1]||""),w=Object.fromEntries(y.entries())||{},S={...l,...w},v=I[h==null?void 0:h.pattern];console.log("[EVENTS] Navigation to",s,{pattern:h==null?void 0:h.pattern,requires_server_data:v,manifest_store:I,middleware:d.middleware}),N(s,t,d,S,l,w,v)}else console.log("No matching route found for URL:",s,"- using fallback navigation")}}}),window.addEventListener("popstate",n=>{const o=window.location.pathname,i=window.location.pathname+window.location.search;_.page.url=i,_.page.pathname=window.location.pathname;const a="get",c=r.find(s=>s.method.toLowerCase()===a&&e.find(u=>u.parser(o)&&u.pattern===s.path));if(c){const s=e.find(y=>y.parser(o)&&y.pattern===c.path),u=(s==null?void 0:s.parser(o))||{},f=new URLSearchParams(window.location.search),d=Object.fromEntries(f.entries())||{};_.page.params=u,_.page.query=d;const h={...u,...d},l=I[s==null?void 0:s.pattern];N(i,t,c,h,u,d,l,!1)}else console.log("No matching route found for popstate navigation to:",o,"- using fallback navigation"),window.location.href=o}),(function(){const n=history.pushState,o=history.replaceState;history.pushState=function(...i){const a=n.apply(this,i),c=new Event("pushstate");return c.state=i[0],c.url=i[2],window.dispatchEvent(c),a},history.replaceState=function(...i){const a=o.apply(this,i),c=i[2],s=window.location.pathname;if((c?new URL(c,window.location.origin).pathname:s)!==s){const f=new Event("replacestate");f.state=i[0],f.url=i[2],window.dispatchEvent(f)}return a}})(),window.addEventListener("pushstate",n=>{const o=n.url||window.location.pathname+window.location.search,i=o.split("?")[0],a="get",c=r.find(s=>s.method.toLowerCase()===a&&e.find(u=>u.parser(i)&&u.pattern===s.path));if(c){const s=e.find(y=>y.parser(i)&&y.pattern===c.path),u=s==null?void 0:s.parser(i),f=new URLSearchParams(o.split("?")[1]||""),d=Object.fromEntries(f.entries());_.page.url=o,_.page.pathname=window.location.pathname,Object.assign(_.page.params,u),Object.assign(_.page.query,d);const h={...u,...d},l=I[s==null?void 0:s.pattern];N(o,t,c,h,u,d,l,!1)}else console.log("No matching route found for pushstate to:",i,"- using fallback navigation"),window.location.href=i}),window.addEventListener("replacestate",n=>{const o=n.url||window.location.pathname+window.location.search,i=o.split("?")[0];_.page.url=o,_.page.pathname=window.location.pathname,_.page.query=Object.fromEntries(new URLSearchParams(o.split("?")[1]||""));const a="get",c=r.find(s=>s.method.toLowerCase()===a&&e.find(u=>u.parser(i)&&u.pattern===s.path));if(c){const s=e.find(y=>y.parser(i)&&y.pattern===c.path),u=(s==null?void 0:s.parser(i))||{},f=new URLSearchParams(o.split("?")[1]||""),d=Object.fromEntries(f.entries())||{},h={...u,...d},l=I[s==null?void 0:s.pattern];N(o,t,c,h,u,d,l,!1)}else console.log("No matching route found for replacestate to:",i,"- using fallback navigation"),window.location.href=i})}const Mt=Symbol("forge-load-function");let G=[],K=null;function Ne(t){try{const r=new URL(t,window.location.origin);return r.origin===window.location.origin&&!r.pathname.startsWith("/api/")}catch{return!t.startsWith("/api/")}}function Ce(){typeof window<"u"&&!K&&(K=window.fetch,window.fetch=async function(t,r={}){let e={...r};for(const i of G)try{if(i.length===2){const a=new Headers(e.headers),c=Object.fromEntries(a.entries());await new Promise((s,u)=>{try{i(c,f=>{if(f)u(f);else{const d=new Headers;Object.entries(c).forEach(([h,l])=>{l!==void 0&&d.set(h,l)}),e.headers=d,s()}})}catch(f){u(f)}})}else{const a=await i(e,t);a&&typeof a=="object"&&(e=a)}}catch(a){throw console.error("🔴 Middleware error:",a),a}const n=e==null?void 0:e[Mt];console.log("[FETCH OVERRIDE] Request",{url:t,hasForgeSymbol:n,headers:e==null?void 0:e.headers});const o=await K(t,e);if(console.log("[FETCH OVERRIDE] Response",{url:t,responseUrl:o.url,redirected:o.redirected,status:o.status,type:o.type,hasForgeSymbol:n}),n&&o.redirected){const i=typeof t=="string"?t:t.url,a=o.url;if(console.log("[FORGE REDIRECT] Detected redirect",{requested:i,final:a,redirected:o.redirected}),Ne(a)){const c=new URL(a),s=c.pathname+c.search;return console.log("[FORGE REDIRECT] Using pushState for SPA navigation to:",s,"from:",a),history.pushState(null,"",s),new Response(JSON.stringify({layout:[],view:{}}),{status:200,headers:{"Content-Type":"application/json"}})}}return o})}Ce();const qe={configUpdate(t){if(typeof t!="function")throw new Error("Middleware must be a function");G.push(t)},reset(){G.length=0},getMiddlewareCount(){return G.length}};let J;async function $e(t,r){let e=window.__COMPONENT_DIR__||r.component_dir;if(!e&&typeof e!="string")throw new Error("No component directory provided");let n=window.__ROUTING__;if(J=Yt(n),window&&window.location){const o=(window.location.pathname||"/").split("?")[0],i=J.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())||{},f={...c,...u};$t(),qt(t,e,a,f,c,u),Ft(e,n,J)}else console.warn("No matching route found for:",o)}}exports.page=_.page;exports.shadowUrl=_.shadowUrl;exports.MANIFEST_STORE=I;exports.bootstrap_events=Ft;exports.createApp=$e;exports.fetch=qe;exports.loadRoute=qt;exports.updateManifestStore=$t;exports.updateRoute=N;
|
|
4
4
|
//# sourceMappingURL=client.cjs.map
|