@stacksjs/stx 0.2.379 → 0.2.381
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-m7zebyq5.js → chunk-01mh30km.js} +1 -1
- package/dist/chunk-0t944mfd.js +2 -0
- package/dist/chunk-1b2e4vhn.js +2 -0
- package/dist/{chunk-ykyecpyx.js → chunk-1c4vex8k.js} +1 -1
- package/dist/{chunk-n7m0zs73.js → chunk-1k0bcce4.js} +1 -1
- package/dist/{chunk-myyj9qp3.js → chunk-1rdm5y91.js} +1 -1
- package/dist/{chunk-nvksp2ws.js → chunk-2pbx4h33.js} +1 -1
- package/dist/chunk-2q1w57n3.js +2 -0
- package/dist/chunk-2y0xpsm9.js +2 -0
- package/dist/{chunk-1n3syq26.js → chunk-347ry9a1.js} +1 -1
- package/dist/chunk-3q9rpjx0.js +2 -0
- package/dist/{chunk-j19ep0nb.js → chunk-3t2xac1c.js} +1 -1
- package/dist/chunk-4djwtq0y.js +47 -0
- package/dist/{chunk-cjxs8r0c.js → chunk-4fc6gjr5.js} +1 -1
- package/dist/{chunk-wqa77pdn.js → chunk-4vscfb5b.js} +1 -1
- package/dist/{chunk-qsrmt975.js → chunk-4xjxkcp9.js} +1 -1
- package/dist/chunk-57nk505p.js +30 -0
- package/dist/{chunk-9n88pgdr.js → chunk-5jvagdgn.js} +1 -1
- package/dist/chunk-5yrc8emq.js +2 -0
- package/dist/{chunk-an1vn2mr.js → chunk-61tpvbag.js} +1 -1
- package/dist/chunk-63vmf8y1.js +2 -0
- package/dist/{chunk-xf1dwv3x.js → chunk-6bvdtf6k.js} +1 -1
- package/dist/chunk-6w3j9g4h.js +2 -0
- package/dist/{chunk-wcn0v9az.js → chunk-7m7xy16d.js} +1 -1
- package/dist/chunk-7qjqwrhq.js +2 -0
- package/dist/chunk-7s3vjr7c.js +2 -0
- package/dist/{chunk-s3tpyage.js → chunk-7wkxs25k.js} +1 -1
- package/dist/{chunk-3gj9jts7.js → chunk-8569hftj.js} +1 -1
- package/dist/chunk-8k85q2zt.js +2 -0
- package/dist/{chunk-2sa8rk32.js → chunk-8kwtg74v.js} +1 -1
- package/dist/chunk-9mvz85xs.js +2 -0
- package/dist/chunk-9z016nwp.js +2 -0
- package/dist/{chunk-21kjq7eq.js → chunk-a97fpbsa.js} +1 -1
- package/dist/chunk-ac8cy837.js +3 -0
- package/dist/{chunk-6pywgdcs.js → chunk-af6gmyj3.js} +1 -1
- package/dist/{chunk-mva7ef38.js → chunk-b3gmkqzg.js} +1 -1
- package/dist/{chunk-ttfx0b5m.js → chunk-b5d9pmy1.js} +1 -1
- package/dist/{chunk-123vn4r5.js → chunk-bhaave87.js} +1 -1
- package/dist/{chunk-tatyh40f.js → chunk-bpyq447k.js} +1 -1
- package/dist/{chunk-68vgysme.js → chunk-bsfkdb4p.js} +15 -2
- package/dist/{chunk-h2dpcnhr.js → chunk-cc97w3eq.js} +1 -1
- package/dist/{chunk-0380epk7.js → chunk-dfeq9d99.js} +1 -1
- package/dist/{chunk-vd9ss2dm.js → chunk-dvqwp792.js} +1 -1
- package/dist/{chunk-bzcg4efj.js → chunk-e06p66kh.js} +2 -2
- package/dist/{chunk-yv4d9nzf.js → chunk-e0n9r2b8.js} +1 -1
- package/dist/{chunk-dv2x6xxs.js → chunk-e4k05e63.js} +1 -1
- package/dist/{chunk-a96rnwf0.js → chunk-e6d229x4.js} +1 -1
- package/dist/{chunk-v6ebzqkd.js → chunk-e6jjec9v.js} +1 -1
- package/dist/{chunk-x8t29tnr.js → chunk-eap7w3a8.js} +1 -1
- package/dist/chunk-egpdk2dj.js +2 -0
- package/dist/{chunk-tpqyvmqd.js → chunk-ekaghc8q.js} +1 -1
- package/dist/chunk-etyqf0vg.js +2 -0
- package/dist/chunk-ez4jw7cw.js +2 -0
- package/dist/{chunk-05c62pqd.js → chunk-fx32tvka.js} +2 -2
- package/dist/chunk-fxhszz9j.js +2 -0
- package/dist/chunk-g191xwrt.js +2 -0
- package/dist/{chunk-pecjvzrk.js → chunk-g1qfrafq.js} +1 -1
- package/dist/chunk-gj7b89m1.js +2 -0
- package/dist/chunk-h1q5w95d.js +2 -0
- package/dist/{chunk-0xh7vqce.js → chunk-h5pdcxre.js} +2 -2
- package/dist/{chunk-2e0fg0jk.js → chunk-hmwhjmma.js} +1 -1
- package/dist/{chunk-ha15g06r.js → chunk-hwevsa8j.js} +1 -1
- package/dist/{chunk-y2s9c0f0.js → chunk-j4af4f7v.js} +1 -1
- package/dist/{chunk-05rf12xd.js → chunk-jcyv8qs0.js} +2 -2
- package/dist/{chunk-hfqycvep.js → chunk-jmdd817r.js} +1 -1
- package/dist/chunk-jnt6dbky.js +2 -0
- package/dist/{chunk-cypwvwpa.js → chunk-kagjfzk0.js} +29 -24
- package/dist/chunk-kse5r2my.js +2 -0
- package/dist/chunk-kt6wm51e.js +3 -0
- package/dist/{chunk-s5r9pd0e.js → chunk-kynnyass.js} +2 -2
- package/dist/{chunk-nh6p0k17.js → chunk-ma41bbjn.js} +1 -1
- package/dist/chunk-mjm2x2px.js +2 -0
- package/dist/chunk-mrnekpgh.js +2 -0
- package/dist/{chunk-m2c9847h.js → chunk-mtr8g311.js} +1 -1
- package/dist/{chunk-an5y1z0q.js → chunk-mza7h890.js} +1 -1
- package/dist/{chunk-mywxdq28.js → chunk-ne27x5e6.js} +1 -1
- package/dist/{chunk-ht2496q5.js → chunk-pxfztwya.js} +1 -1
- package/dist/{chunk-qg9rm36c.js → chunk-q3vkf153.js} +1 -1
- package/dist/{chunk-km3e88cy.js → chunk-q4vhc2hd.js} +1 -1
- package/dist/{chunk-eewneg7t.js → chunk-qg4e12et.js} +1 -1
- package/dist/{chunk-3jm88rme.js → chunk-qppqwhhy.js} +1 -1
- package/dist/{chunk-e4kxhcyn.js → chunk-qrm0k16b.js} +1 -1
- package/dist/chunk-qt0kz3t5.js +12 -0
- package/dist/{chunk-ms3xppjb.js → chunk-r75c4h16.js} +1 -1
- package/dist/{chunk-geztv535.js → chunk-r9vpgmbd.js} +2 -2
- package/dist/{chunk-e4jsntps.js → chunk-s7j42ma7.js} +1 -1
- package/dist/chunk-sbskfp38.js +2 -0
- package/dist/chunk-sdych4rv.js +2 -0
- package/dist/{chunk-zhzcahz5.js → chunk-sh77d4tv.js} +1 -1
- package/dist/chunk-t6118t47.js +2 -0
- package/dist/chunk-tkskx23v.js +2 -0
- package/dist/{chunk-w3xwpe5f.js → chunk-tznfbxj3.js} +1 -1
- package/dist/{chunk-4tarjrqw.js → chunk-vjb3v63z.js} +144 -144
- package/dist/chunk-vk6v8kzj.js +2 -0
- package/dist/{chunk-cjqqh2cn.js → chunk-wb2rvvkh.js} +1 -1
- package/dist/{chunk-yz2yk0p1.js → chunk-wgsmawhw.js} +188 -188
- package/dist/chunk-wnc0fadc.js +2 -0
- package/dist/{chunk-reafpw3e.js → chunk-wnpyb1f4.js} +1 -1
- package/dist/chunk-wrmj0cn4.js +2 -0
- package/dist/{chunk-bt3nnbkm.js → chunk-wwvasdjy.js} +1 -1
- package/dist/{chunk-n0qssshb.js → chunk-xaddzx9d.js} +1 -1
- package/dist/{chunk-xpc8ygpz.js → chunk-xbfc6cw2.js} +1 -1
- package/dist/chunk-xyangbca.js +2 -0
- package/dist/{chunk-8kwmj99g.js → chunk-ystnxqsq.js} +1 -1
- package/dist/{chunk-a6a1b4yj.js → chunk-zf7daamg.js} +1 -1
- package/dist/{chunk-g4q00dv4.js → chunk-zkzp83x3.js} +1 -1
- package/dist/{chunk-bhbex20z.js → chunk-zt3tkx1m.js} +1 -1
- package/dist/{chunk-836z41ss.js → chunk-zyqa38rq.js} +1 -1
- package/dist/cli.js +14 -14
- package/dist/craft-entry.js +1 -1
- package/dist/craft.js +1 -1
- package/dist/database.js +1 -1
- package/dist/pwa/workbox.js +9 -3
- package/dist/pwa.js +2 -2
- package/dist/signals.js +14 -1
- package/dist/ssg.js +2 -2
- package/dist/utils.js +1 -1
- package/dist/visual-testing.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-0m9dp2nx.js +0 -2
- package/dist/chunk-0nknfsxa.js +0 -2
- package/dist/chunk-2ggshmdx.js +0 -2
- package/dist/chunk-367ce1y2.js +0 -2
- package/dist/chunk-3ckt56vs.js +0 -2
- package/dist/chunk-3eq3h4cm.js +0 -2
- package/dist/chunk-4vg0zgas.js +0 -2
- package/dist/chunk-5ztqaab9.js +0 -2
- package/dist/chunk-7j6stht9.js +0 -2
- package/dist/chunk-7ngmxv4z.js +0 -47
- package/dist/chunk-8nxdktsm.js +0 -2
- package/dist/chunk-93f8avhm.js +0 -2
- package/dist/chunk-ctkz8peg.js +0 -2
- package/dist/chunk-dvc615rq.js +0 -2
- package/dist/chunk-e854gjy9.js +0 -2
- package/dist/chunk-ev7q8enz.js +0 -30
- package/dist/chunk-fdc118yv.js +0 -2
- package/dist/chunk-gy8m2nrh.js +0 -2
- package/dist/chunk-h58jrhw7.js +0 -2
- package/dist/chunk-jxcjp8f8.js +0 -2
- package/dist/chunk-ksfmp87v.js +0 -12
- package/dist/chunk-pvptmxgd.js +0 -2
- package/dist/chunk-qj58fpc2.js +0 -2
- package/dist/chunk-sqj228wh.js +0 -2
- package/dist/chunk-sqj46125.js +0 -2
- package/dist/chunk-sy5x1tma.js +0 -2
- package/dist/chunk-tep3p25g.js +0 -2
- package/dist/chunk-tfk1w25g.js +0 -3
- package/dist/chunk-tmcnptq6.js +0 -2
- package/dist/chunk-vafmd261.js +0 -2
- package/dist/chunk-ws7dy2jt.js +0 -2
- package/dist/chunk-xa8ry8an.js +0 -2
- package/dist/chunk-z3rm0hsv.js +0 -2
- package/dist/chunk-zs8tf2cm.js +0 -2
- package/dist/chunk-zwnh04k9.js +0 -2
- package/dist/chunk-zzgkm8ee.js +0 -2
package/dist/database.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Tw as Q}from"./chunk-myyj9qp3.js";var $={default:"sqlite",connections:{},logging:!1,cacheTTL:0,maxCacheSize:1000},V={},A={},L=new Map,S=[];function i(z){$={...$,...z}}function o(){return{...$}}function r(){$={default:"sqlite",connections:{},logging:!1,cacheTTL:0,maxCacheSize:1000};for(let z of Object.keys(V))delete V[z];L.clear(),S.length=0}function a(z,H){V[z]=H}function F(z){let H=z||$.default;if(V[H])return V[H];let U=$.connections[H];if(!U)throw Error(`Database connection "${H}" not configured`);let W=h(U);return V[H]=W,W}function h(z){switch(z.driver){case"sqlite":return q(z);case"postgres":return y(z);case"mysql":return f(z);default:throw Error(`Unsupported database driver: ${z.driver}`)}}function q(z){let H=null,U=!1;return{async connect(){if(U)return;let{Database:W}=await import("bun:sqlite");H=new W(z.database,{create:!0,readwrite:!0}),U=!0},async disconnect(){if(H)H.close(),H=null,U=!1},async query(W,J=[]){if(!U)await this.connect();let X=performance.now();try{let Y=H.prepare(W).all(...J);if($.logging)B(W,J,performance.now()-X);return Y}catch(Z){throw new O(`Query failed: ${Z}`,W,J)}},async insert(W,J=[]){if(!U)await this.connect();let X=performance.now();try{let Y=H.prepare(W).run(...J);if($.logging)B(W,J,performance.now()-X);return Y.lastInsertRowid}catch(Z){throw new O(`Insert failed: ${Z}`,W,J)}},async execute(W,J=[]){if(!U)await this.connect();let X=performance.now();try{let Y=H.prepare(W).run(...J);if($.logging)B(W,J,performance.now()-X);return Y.changes}catch(Z){throw new O(`Execute failed: ${Z}`,W,J)}},async beginTransaction(){if(!U)await this.connect();H.run("BEGIN TRANSACTION")},async commit(){H.run("COMMIT")},async rollback(){H.run("ROLLBACK")},isConnected(){return U}}}function y(z){let H=!1,U=null;return{async connect(){if(H)return;try{let{Client:W}=await import("pg");U=new W({host:z.host||"localhost",port:z.port||5432,database:z.database,user:z.username,password:z.password,ssl:z.ssl}),await U.connect(),H=!0}catch(W){throw Error(`PostgreSQL connection failed. Install 'pg' package: ${W}`)}},async disconnect(){if(U)await U.end(),U=null,H=!1},async query(W,J=[]){if(!H)await this.connect();let X=performance.now();try{let Z=await U.query(W,J);if($.logging)B(W,J,performance.now()-X);return Z.rows}catch(Z){throw new O(`Query failed: ${Z}`,W,J)}},async insert(W,J=[]){if(!H)await this.connect();let X=performance.now();try{let Z=await U.query(`${W} RETURNING id`,J);if($.logging)B(W,J,performance.now()-X);return Z.rows[0]?.id}catch(Z){throw new O(`Insert failed: ${Z}`,W,J)}},async execute(W,J=[]){if(!H)await this.connect();let X=performance.now();try{let Z=await U.query(W,J);if($.logging)B(W,J,performance.now()-X);return Z.rowCount||0}catch(Z){throw new O(`Execute failed: ${Z}`,W,J)}},async beginTransaction(){if(!H)await this.connect();await U.query("BEGIN")},async commit(){await U.query("COMMIT")},async rollback(){await U.query("ROLLBACK")},isConnected(){return H}}}function f(z){let H=!1,U=null;return{async connect(){if(H)return;try{U=(await import("mysql2/promise")).createPool({host:z.host||"localhost",port:z.port||3306,database:z.database,user:z.username,password:z.password,waitForConnections:!0,connectionLimit:z.poolSize||10,queueLimit:0}),H=!0}catch(W){throw Error(`MySQL connection failed. Install 'mysql2' package: ${W}`)}},async disconnect(){if(U)await U.end(),U=null,H=!1},async query(W,J=[]){if(!H)await this.connect();let X=performance.now();try{let[Z]=await U.execute(W,J);if($.logging)B(W,J,performance.now()-X);return Z}catch(Z){throw new O(`Query failed: ${Z}`,W,J)}},async insert(W,J=[]){if(!H)await this.connect();let X=performance.now();try{let[Z]=await U.execute(W,J);if($.logging)B(W,J,performance.now()-X);return Z.insertId}catch(Z){throw new O(`Insert failed: ${Z}`,W,J)}},async execute(W,J=[]){if(!H)await this.connect();let X=performance.now();try{let[Z]=await U.execute(W,J);if($.logging)B(W,J,performance.now()-X);return Z.affectedRows||0}catch(Z){throw new O(`Execute failed: ${Z}`,W,J)}},async beginTransaction(){if(!H)await this.connect();let W=await U.getConnection();return await W.beginTransaction(),W},async commit(){await U.execute("COMMIT")},async rollback(){await U.execute("ROLLBACK")},isConnected(){return H}}}class D{_table="";_columns=["*"];_wheres=[];_orders=[];_joins=[];_groupBy=[];_having=[];_limit;_offset;_distinct=!1;_connection;_bindings=[];_modelDefinition;constructor(z){if(z)this._table=z}table(z){return this._table=z,this}from(z){return this.table(z)}connection(z){return this._connection=z,this}select(...z){return this._columns=z.length>0?z:["*"],this}addSelect(...z){if(this._columns[0]==="*")this._columns=z;else this._columns.push(...z);return this}distinct(){return this._distinct=!0,this}where(z,H,U){let W="=",J=H;if(U!==void 0)W=H,J=U;return this._wheres.push({column:z,operator:W,value:J,boolean:"and"}),this}orWhere(z,H,U){let W="=",J=H;if(U!==void 0)W=H,J=U;return this._wheres.push({column:z,operator:W,value:J,boolean:"or"}),this}whereIn(z,H){return this._wheres.push({column:z,operator:"in",value:H,boolean:"and"}),this}whereNotIn(z,H){return this._wheres.push({column:z,operator:"not in",value:H,boolean:"and"}),this}whereNull(z){return this._wheres.push({column:z,operator:"is null",value:null,boolean:"and"}),this}whereNotNull(z){return this._wheres.push({column:z,operator:"is not null",value:null,boolean:"and"}),this}whereBetween(z,H,U){return this._wheres.push({column:z,operator:"between",value:[H,U],boolean:"and"}),this}whereLike(z,H){return this._wheres.push({column:z,operator:"like",value:H,boolean:"and"}),this}join(z,H,U,W){return this._joins.push({type:"inner",table:z,first:H,operator:U,second:W}),this}leftJoin(z,H,U,W){return this._joins.push({type:"left",table:z,first:H,operator:U,second:W}),this}rightJoin(z,H,U,W){return this._joins.push({type:"right",table:z,first:H,operator:U,second:W}),this}orderBy(z,H="asc"){return this._orders.push({column:z,direction:H}),this}orderByDesc(z){return this.orderBy(z,"desc")}groupBy(...z){return this._groupBy.push(...z),this}having(z,H,U){return this._having.push({column:z,operator:H,value:U,boolean:"and"}),this}limit(z){return this._limit=z,this}take(z){return this.limit(z)}offset(z){return this._offset=z,this}skip(z){return this.offset(z)}forPage(z,H=15){return this.offset((z-1)*H).limit(H)}async get(){let{sql:z,bindings:H}=this.toSql();if($.cacheTTL&&$.cacheTTL>0){let J=this.getCacheKey(z,H),X=g(J);if(X!==void 0)return X}let W=await F(this._connection).query(z,H);if($.cacheTTL&&$.cacheTTL>0){let J=this.getCacheKey(z,H);m(J,W,$.cacheTTL)}return W}async first(){return(await this.limit(1).get())[0]||null}async firstOrFail(){let z=await this.first();if(!z)throw Error("No results found");return z}async find(z,H="id"){return this.where(H,z).first()}async value(z){let H=await this.select(z).first();return H?H[z]:null}async pluck(z){return(await this.select(z).get()).map((U)=>U[z])}async exists(){return(await this.select(E("1")).limit(1).get()).length>0}async doesntExist(){return!await this.exists()}async count(z="*"){let H=await this.select(E(`COUNT(${z}) as count`)).first();return Number(H?.count||0)}async max(z){return(await this.select(E(`MAX(${z}) as max`)).first())?.max}async min(z){return(await this.select(E(`MIN(${z}) as min`)).first())?.min}async sum(z){let H=await this.select(E(`SUM(${z}) as sum`)).first();return Number(H?.sum||0)}async avg(z){return(await this.select(E(`AVG(${z}) as avg`)).first())?.avg}async insert(z){let H=Object.keys(z),U=H.map(()=>"?").join(", "),W=Object.values(z),J=`INSERT INTO ${this._table} (${H.join(", ")}) VALUES (${U})`,X=F(this._connection);return P(this._table),X.insert(J,W)}async insertAll(z){if(z.length===0)return;let H=Object.keys(z[0]),U=z.map(()=>`(${H.map(()=>"?").join(", ")})`).join(", "),W=z.flatMap((Z)=>Object.values(Z)),J=`INSERT INTO ${this._table} (${H.join(", ")}) VALUES ${U}`,X=F(this._connection);P(this._table),await X.execute(J,W)}async update(z){this._bindings=[];let H=this.buildWhereClause(),U=[...this._bindings],W=Object.keys(z).map((Y)=>`${Y} = ?`).join(", "),J=[...Object.values(z),...U],X=`UPDATE ${this._table} SET ${W}${H}`,Z=F(this._connection);return P(this._table),Z.execute(X,J)}async increment(z,H=1){this._bindings=[];let U=this.buildWhereClause(),W=`UPDATE ${this._table} SET ${z} = ${z} + ?${U}`,J=F(this._connection);return P(this._table),J.execute(W,[H,...this._bindings])}async decrement(z,H=1){return this.increment(z,-H)}async delete(){this._bindings=[];let z=this.buildWhereClause(),H=`DELETE FROM ${this._table}${z}`,U=F(this._connection);return P(this._table),U.execute(H,this._bindings)}async truncate(){let z=F(this._connection);P(this._table),await z.execute(`DELETE FROM ${this._table}`)}toSql(){this._bindings=[];let z="SELECT ";if(this._distinct)z+="DISTINCT ";z+=this._columns.map((H)=>{if(typeof H==="object"&&H.__raw)return H.sql;return H}).join(", "),z+=` FROM ${this._table}`;for(let H of this._joins)z+=` ${H.type.toUpperCase()} JOIN ${H.table} ON ${H.first} ${H.operator} ${H.second}`;if(z+=this.buildWhereClause(),this._groupBy.length>0)z+=` GROUP BY ${this._groupBy.join(", ")}`;if(this._having.length>0){let H=this._having.map((U,W)=>{let J=W===0?"":` ${U.boolean.toUpperCase()} `;return this._bindings.push(U.value),`${J}${U.column} ${U.operator} ?`});z+=` HAVING ${H.join("")}`}if(this._orders.length>0)z+=` ORDER BY ${this._orders.map((H)=>`${H.column} ${H.direction.toUpperCase()}`).join(", ")}`;if(this._limit!==void 0)z+=` LIMIT ${this._limit}`;if(this._offset!==void 0)z+=` OFFSET ${this._offset}`;return{sql:z,bindings:this._bindings}}buildWhereClause(){if(this._wheres.length===0)return"";return this._wheres.map((H,U)=>{let W=U===0?" WHERE ":` ${H.boolean.toUpperCase()} `;switch(H.operator){case"in":{let J=H.value,X=J.map(()=>"?").join(", ");return this._bindings.push(...J),`${W}${H.column} IN (${X})`}case"not in":{let J=H.value,X=J.map(()=>"?").join(", ");return this._bindings.push(...J),`${W}${H.column} NOT IN (${X})`}case"between":{let[J,X]=H.value;return this._bindings.push(J,X),`${W}${H.column} BETWEEN ? AND ?`}case"is null":return`${W}${H.column} IS NULL`;case"is not null":return`${W}${H.column} IS NOT NULL`;default:return this._bindings.push(H.value),`${W}${H.column} ${H.operator} ?`}}).join("")}getCacheKey(z,H){return`${this._table}:${z}:${JSON.stringify(H)}`}clone(){let z=new D(this._table);return z._columns=[...this._columns],z._wheres=[...this._wheres],z._orders=[...this._orders],z._joins=[...this._joins],z._groupBy=[...this._groupBy],z._having=[...this._having],z._limit=this._limit,z._offset=this._offset,z._distinct=this._distinct,z._connection=this._connection,z}}function G(z){return new D(z)}function t(z){return G(z)}function E(z,H=[]){return{__raw:!0,sql:z,bindings:H}}function n(z,H){let U=H.primaryKey||"id",W={name:z,definition:H,async find(J){let X=await G(H.table).where(U,J).first();return X?N(W,X):null},async findOrFail(J){let X=await this.find(J);if(!X)throw Error(`${z} not found with ${U} = ${J}`);return X},async all(){return(await G(H.table).get()).map((X)=>N(W,X))},async create(J){let X={...H.defaults,...J},Z=H.fillable?Object.fromEntries(Object.entries(X).filter(([_])=>H.fillable.includes(_))):X;if(H.timestamps!==!1){let _=new Date().toISOString(),R=typeof H.timestamps==="object"?H.timestamps.createdAt||"created_at":"created_at",T=typeof H.timestamps==="object"?H.timestamps.updatedAt||"updated_at":"updated_at";Z[R]=_,Z[T]=_}let Y=await G(H.table).insert(Z);return this.findOrFail(Y)},async update(J){return G(H.table).update(J)},async destroy(J){let X=Array.isArray(J)?J:[J];return G(H.table).whereIn(U,X).delete()},query(){return G(H.table)},where(J,X,Z){return this.query().where(J,X,Z)},async first(){let J=await this.query().first();return J?N(W,J):null},async get(){return(await this.query().get()).map((X)=>N(W,X))},async count(){return this.query().count()}};return A[z]=W,W}function k(z){let H=A[z];if(!H)throw Error(`Model "${z}" not defined. Use defineModel() first.`);return H}function e(z){return z in A}function N(z,H){let{definition:U}=z,W=U.primaryKey||"id",J={...H},X={...H};if(U.casts){for(let[Y,_]of Object.entries(U.casts))if(Y in X)X[Y]=p(X[Y],_)}let Z={exists:!0,original:J,attributes:X,get(Y){return X[Y]},set(Y,_){X[Y]=_},toJSON(){let Y={...X};if(U.hidden)for(let _ of U.hidden)delete Y[_];return Y},async save(){let Y={};for(let _ of Object.keys(X))if(X[_]!==J[_])Y[_]=X[_];if(Object.keys(Y).length>0){if(U.timestamps!==!1){let _=typeof U.timestamps==="object"?U.timestamps.updatedAt||"updated_at":"updated_at";Y[_]=new Date().toISOString()}await G(U.table).where(W,J[W]).update(Y),Object.assign(J,Y)}},async delete(){if(U.softDeletes){let Y=typeof U.softDeletes==="string"?U.softDeletes:"deleted_at";await G(U.table).where(W,J[W]).update({[Y]:new Date().toISOString()})}else await G(U.table).where(W,J[W]).delete();Z.exists=!1},async refresh(){let Y=await G(U.table).where(W,J[W]).first();if(Y)Object.assign(J,Y),Object.assign(X,Y)},isDirty(Y){if(Y)return X[Y]!==J[Y];return Object.keys(X).some((_)=>X[_]!==J[_])}};if(U.relationships)for(let[Y,_]of Object.entries(U.relationships))Object.defineProperty(Z,Y,{value:async()=>{return b(Z,_,z)},enumerable:!1});return new Proxy(Z,{get(Y,_){if(_ in Y)return Y[_];return X[_]},set(Y,_,R){if(_ in Y)Y[_]=R;else X[_]=R;return!0}})}async function b(z,H,U){let W=k(H.model),J=U.definition.primaryKey||"id";switch(H.type){case"hasOne":{let X=H.foreignKey||`${U.name.toLowerCase()}_id`,Z=await G(W.definition.table).where(X,z.get(J)).first();return Z?N(W,Z):null}case"hasMany":{let X=H.foreignKey||`${U.name.toLowerCase()}_id`;return(await G(W.definition.table).where(X,z.get(J)).get()).map((Y)=>N(W,Y))}case"belongsTo":{let X=H.foreignKey||`${H.model.toLowerCase()}_id`,Z=H.localKey||"id",Y=await G(W.definition.table).where(Z,z.get(X)).first();return Y?N(W,Y):null}case"belongsToMany":{let X=H.pivotTable||[U.name,H.model].sort().join("_").toLowerCase(),Z=H.pivotForeignKey||`${U.name.toLowerCase()}_id`,Y=H.pivotRelatedKey||`${H.model.toLowerCase()}_id`,_=W.definition.primaryKey||"id";return(await G(W.definition.table).join(X,`${W.definition.table}.${_}`,"=",`${X}.${Y}`).where(`${X}.${Z}`,z.get(J)).get()).map((T)=>N(W,T))}default:return null}}function p(z,H){if(z===null||z===void 0)return z;switch(H){case"string":return String(z);case"number":return Number(z);case"boolean":return Boolean(z);case"date":return new Date(z);case"json":case"array":return typeof z==="string"?JSON.parse(z):z;default:return z}}async function zz(z,H){let U=F(H);await U.beginTransaction();try{let W=await z();return await U.commit(),W}catch(W){throw await U.rollback(),W}}function g(z){let H=L.get(z);if(!H)return;if(Date.now()-H.timestamp>H.ttl*1000){L.delete(z);return}return H.result}function m(z,H,U){if(L.size>=($.maxCacheSize||1000)){let W=L.keys().next().value;if(W)L.delete(W)}L.set(z,{result:H,timestamp:Date.now(),ttl:U})}function P(z){for(let H of L.keys())if(H.startsWith(`${z}:`))L.delete(H)}function Hz(){L.clear()}function Jz(){return{size:L.size,keys:[...L.keys()]}}function B(z,H,U){if(S.push({sql:z,bindings:H,duration:U,timestamp:new Date}),S.length>1000)S.shift()}function Uz(){return[...S]}function Wz(){S.length=0}function Xz(z=!0){$.logging=z}class O extends Error{sql;bindings;constructor(z,H,U){super(z);this.sql=H;this.bindings=U;this.name="DatabaseError"}}async function u(z,H,U,W){let J=/@db\(\s*['"]([^'"]+)['"]\s*\)((?:->\w+\([^)]*\))*)/g,X=z,Z=[...z.matchAll(J)];for(let Y of Z){let[_,R,T]=Y;try{let j=await s(R,T),I=`$${R}`;H[I]=j,X=X.replace(_,"")}catch(j){X=X.replace(_,`<!-- DB Error: ${j instanceof Error?j.message:String(j)} -->`)}}return X}async function d(z,H,U,W){let J=/@model\(\s*['"]([^'"]+)['"]\s*\)((?:->\w+\([^)]*\))*)/g,X=z,Z=[...z.matchAll(J)];for(let Y of Z){let[_,R,T]=Y;try{let j=k(R),I=await l(j,T),K=`$${R.toLowerCase()}`;H[K]=I,X=X.replace(_,"")}catch(j){X=X.replace(_,`<!-- Model Error: ${j instanceof Error?j.message:String(j)} -->`)}}return X}async function c(z,H,U,W){let J=/@query\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\[[^\]]*\]))?\s*\)\s*as\s+\$(\w+)/g,X=z,Z=[...z.matchAll(J)];for(let Y of Z){let[_,R,T,j]=Y;try{let I=T?JSON.parse(T):[],v=await F().query(R,I);H[`$${j}`]=v,X=X.replace(_,"")}catch(I){X=X.replace(_,`<!-- Query Error: ${I instanceof Error?I.message:String(I)} -->`)}}return X}async function s(z,H){let U=G(z),W=/->(\w+)\(([^)]*)\)/g,J=[...H.matchAll(W)],X=U;for(let[,Z,Y]of J){let _=M(Y);if(typeof X[Z]==="function"){if(X=X[Z](..._),X instanceof Promise){X=await X;break}}}if(X instanceof D)X=await X.get();return X}async function l(z,H){let U=/->(\w+)\(([^)]*)\)/g,W=[...H.matchAll(U)],J=z;for(let[,X,Z]of W){let Y=M(Z);if(typeof J[X]==="function"){if(J=J[X](...Y),J instanceof Promise)J=await J}else if(J instanceof D){if(typeof J[X]==="function"){if(J=J[X](...Y),J instanceof Promise)J=await J}}}if(J instanceof D)J=await J.get();return J}function M(z){if(!z.trim())return[];let H=[],U="",W=0,J=!1,X="";for(let Z=0;Z<z.length;Z++){let Y=z[Z];if(!J&&(Y==='"'||Y==="'"))J=!0,X=Y,U+=Y;else if(J&&Y===X)J=!1,U+=Y;else if(!J&&(Y==="["||Y==="{"||Y==="("))W++,U+=Y;else if(!J&&(Y==="]"||Y==="}"||Y===")"))W--,U+=Y;else if(!J&&W===0&&Y===",")H.push(x(U.trim())),U="";else U+=Y}if(U.trim())H.push(x(U.trim()));return H}function x(z){if(z.startsWith('"')&&z.endsWith('"')||z.startsWith("'")&&z.endsWith("'"))return z.slice(1,-1);if(z==="true")return!0;if(z==="false")return!1;if(z==="null")return null;let H=Number(z);if(!Number.isNaN(H))return H;try{return JSON.parse(z)}catch{return z}}async function Yz(z,H,U,W){let J=z;return J=await c(J,H,U,W),J=await d(J,H,U,W),J=await u(J,H,U,W),J}class w{_connection;connection(z){return this._connection=z,this}async create(z,H){let U=new C(z);H(U);let W=U.toCreateSQL();await F(this._connection).execute(W)}async drop(z){await F(this._connection).execute(`DROP TABLE IF EXISTS ${z}`)}async rename(z,H){await F(this._connection).execute(`ALTER TABLE ${z} RENAME TO ${H}`)}async hasTable(z){let H=F(this._connection);try{return await H.query(`SELECT 1 FROM ${z} LIMIT 1`),!0}catch{return!1}}}class C{table;columns=[];indices=[];constructor(z){this.table=z}id(z="id"){return this.columns.push(`${z} INTEGER PRIMARY KEY AUTOINCREMENT`),this}string(z,H=255){return this.columns.push(`${z} VARCHAR(${H})`),this}text(z){return this.columns.push(`${z} TEXT`),this}integer(z){return this.columns.push(`${z} INTEGER`),this}boolean(z){return this.columns.push(`${z} BOOLEAN DEFAULT 0`),this}datetime(z){return this.columns.push(`${z} DATETIME`),this}timestamps(){return this.columns.push("created_at DATETIME DEFAULT CURRENT_TIMESTAMP"),this.columns.push("updated_at DATETIME DEFAULT CURRENT_TIMESTAMP"),this}softDeletes(){return this.columns.push("deleted_at DATETIME"),this}json(z){return this.columns.push(`${z} TEXT`),this}foreignId(z){return this.columns.push(`${z} INTEGER`),this}index(z){let H=Array.isArray(z)?z:[z],U=`idx_${this.table}_${H.join("_")}`;return this.indices.push(`CREATE INDEX ${U} ON ${this.table} (${H.join(", ")})`),this}unique(z){let H=Array.isArray(z)?z:[z],U=`uniq_${this.table}_${H.join("_")}`;return this.indices.push(`CREATE UNIQUE INDEX ${U} ON ${this.table} (${H.join(", ")})`),this}toCreateSQL(){return`CREATE TABLE IF NOT EXISTS ${this.table} (
|
|
2
|
+
import{Uw as Q}from"./chunk-1rdm5y91.js";var $={default:"sqlite",connections:{},logging:!1,cacheTTL:0,maxCacheSize:1000},V={},A={},L=new Map,S=[];function i(z){$={...$,...z}}function o(){return{...$}}function r(){$={default:"sqlite",connections:{},logging:!1,cacheTTL:0,maxCacheSize:1000};for(let z of Object.keys(V))delete V[z];L.clear(),S.length=0}function a(z,H){V[z]=H}function F(z){let H=z||$.default;if(V[H])return V[H];let U=$.connections[H];if(!U)throw Error(`Database connection "${H}" not configured`);let W=h(U);return V[H]=W,W}function h(z){switch(z.driver){case"sqlite":return q(z);case"postgres":return y(z);case"mysql":return f(z);default:throw Error(`Unsupported database driver: ${z.driver}`)}}function q(z){let H=null,U=!1;return{async connect(){if(U)return;let{Database:W}=await import("bun:sqlite");H=new W(z.database,{create:!0,readwrite:!0}),U=!0},async disconnect(){if(H)H.close(),H=null,U=!1},async query(W,J=[]){if(!U)await this.connect();let X=performance.now();try{let Y=H.prepare(W).all(...J);if($.logging)B(W,J,performance.now()-X);return Y}catch(Z){throw new O(`Query failed: ${Z}`,W,J)}},async insert(W,J=[]){if(!U)await this.connect();let X=performance.now();try{let Y=H.prepare(W).run(...J);if($.logging)B(W,J,performance.now()-X);return Y.lastInsertRowid}catch(Z){throw new O(`Insert failed: ${Z}`,W,J)}},async execute(W,J=[]){if(!U)await this.connect();let X=performance.now();try{let Y=H.prepare(W).run(...J);if($.logging)B(W,J,performance.now()-X);return Y.changes}catch(Z){throw new O(`Execute failed: ${Z}`,W,J)}},async beginTransaction(){if(!U)await this.connect();H.run("BEGIN TRANSACTION")},async commit(){H.run("COMMIT")},async rollback(){H.run("ROLLBACK")},isConnected(){return U}}}function y(z){let H=!1,U=null;return{async connect(){if(H)return;try{let{Client:W}=await import("pg");U=new W({host:z.host||"localhost",port:z.port||5432,database:z.database,user:z.username,password:z.password,ssl:z.ssl}),await U.connect(),H=!0}catch(W){throw Error(`PostgreSQL connection failed. Install 'pg' package: ${W}`)}},async disconnect(){if(U)await U.end(),U=null,H=!1},async query(W,J=[]){if(!H)await this.connect();let X=performance.now();try{let Z=await U.query(W,J);if($.logging)B(W,J,performance.now()-X);return Z.rows}catch(Z){throw new O(`Query failed: ${Z}`,W,J)}},async insert(W,J=[]){if(!H)await this.connect();let X=performance.now();try{let Z=await U.query(`${W} RETURNING id`,J);if($.logging)B(W,J,performance.now()-X);return Z.rows[0]?.id}catch(Z){throw new O(`Insert failed: ${Z}`,W,J)}},async execute(W,J=[]){if(!H)await this.connect();let X=performance.now();try{let Z=await U.query(W,J);if($.logging)B(W,J,performance.now()-X);return Z.rowCount||0}catch(Z){throw new O(`Execute failed: ${Z}`,W,J)}},async beginTransaction(){if(!H)await this.connect();await U.query("BEGIN")},async commit(){await U.query("COMMIT")},async rollback(){await U.query("ROLLBACK")},isConnected(){return H}}}function f(z){let H=!1,U=null;return{async connect(){if(H)return;try{U=(await import("mysql2/promise")).createPool({host:z.host||"localhost",port:z.port||3306,database:z.database,user:z.username,password:z.password,waitForConnections:!0,connectionLimit:z.poolSize||10,queueLimit:0}),H=!0}catch(W){throw Error(`MySQL connection failed. Install 'mysql2' package: ${W}`)}},async disconnect(){if(U)await U.end(),U=null,H=!1},async query(W,J=[]){if(!H)await this.connect();let X=performance.now();try{let[Z]=await U.execute(W,J);if($.logging)B(W,J,performance.now()-X);return Z}catch(Z){throw new O(`Query failed: ${Z}`,W,J)}},async insert(W,J=[]){if(!H)await this.connect();let X=performance.now();try{let[Z]=await U.execute(W,J);if($.logging)B(W,J,performance.now()-X);return Z.insertId}catch(Z){throw new O(`Insert failed: ${Z}`,W,J)}},async execute(W,J=[]){if(!H)await this.connect();let X=performance.now();try{let[Z]=await U.execute(W,J);if($.logging)B(W,J,performance.now()-X);return Z.affectedRows||0}catch(Z){throw new O(`Execute failed: ${Z}`,W,J)}},async beginTransaction(){if(!H)await this.connect();let W=await U.getConnection();return await W.beginTransaction(),W},async commit(){await U.execute("COMMIT")},async rollback(){await U.execute("ROLLBACK")},isConnected(){return H}}}class D{_table="";_columns=["*"];_wheres=[];_orders=[];_joins=[];_groupBy=[];_having=[];_limit;_offset;_distinct=!1;_connection;_bindings=[];_modelDefinition;constructor(z){if(z)this._table=z}table(z){return this._table=z,this}from(z){return this.table(z)}connection(z){return this._connection=z,this}select(...z){return this._columns=z.length>0?z:["*"],this}addSelect(...z){if(this._columns[0]==="*")this._columns=z;else this._columns.push(...z);return this}distinct(){return this._distinct=!0,this}where(z,H,U){let W="=",J=H;if(U!==void 0)W=H,J=U;return this._wheres.push({column:z,operator:W,value:J,boolean:"and"}),this}orWhere(z,H,U){let W="=",J=H;if(U!==void 0)W=H,J=U;return this._wheres.push({column:z,operator:W,value:J,boolean:"or"}),this}whereIn(z,H){return this._wheres.push({column:z,operator:"in",value:H,boolean:"and"}),this}whereNotIn(z,H){return this._wheres.push({column:z,operator:"not in",value:H,boolean:"and"}),this}whereNull(z){return this._wheres.push({column:z,operator:"is null",value:null,boolean:"and"}),this}whereNotNull(z){return this._wheres.push({column:z,operator:"is not null",value:null,boolean:"and"}),this}whereBetween(z,H,U){return this._wheres.push({column:z,operator:"between",value:[H,U],boolean:"and"}),this}whereLike(z,H){return this._wheres.push({column:z,operator:"like",value:H,boolean:"and"}),this}join(z,H,U,W){return this._joins.push({type:"inner",table:z,first:H,operator:U,second:W}),this}leftJoin(z,H,U,W){return this._joins.push({type:"left",table:z,first:H,operator:U,second:W}),this}rightJoin(z,H,U,W){return this._joins.push({type:"right",table:z,first:H,operator:U,second:W}),this}orderBy(z,H="asc"){return this._orders.push({column:z,direction:H}),this}orderByDesc(z){return this.orderBy(z,"desc")}groupBy(...z){return this._groupBy.push(...z),this}having(z,H,U){return this._having.push({column:z,operator:H,value:U,boolean:"and"}),this}limit(z){return this._limit=z,this}take(z){return this.limit(z)}offset(z){return this._offset=z,this}skip(z){return this.offset(z)}forPage(z,H=15){return this.offset((z-1)*H).limit(H)}async get(){let{sql:z,bindings:H}=this.toSql();if($.cacheTTL&&$.cacheTTL>0){let J=this.getCacheKey(z,H),X=g(J);if(X!==void 0)return X}let W=await F(this._connection).query(z,H);if($.cacheTTL&&$.cacheTTL>0){let J=this.getCacheKey(z,H);m(J,W,$.cacheTTL)}return W}async first(){return(await this.limit(1).get())[0]||null}async firstOrFail(){let z=await this.first();if(!z)throw Error("No results found");return z}async find(z,H="id"){return this.where(H,z).first()}async value(z){let H=await this.select(z).first();return H?H[z]:null}async pluck(z){return(await this.select(z).get()).map((U)=>U[z])}async exists(){return(await this.select(E("1")).limit(1).get()).length>0}async doesntExist(){return!await this.exists()}async count(z="*"){let H=await this.select(E(`COUNT(${z}) as count`)).first();return Number(H?.count||0)}async max(z){return(await this.select(E(`MAX(${z}) as max`)).first())?.max}async min(z){return(await this.select(E(`MIN(${z}) as min`)).first())?.min}async sum(z){let H=await this.select(E(`SUM(${z}) as sum`)).first();return Number(H?.sum||0)}async avg(z){return(await this.select(E(`AVG(${z}) as avg`)).first())?.avg}async insert(z){let H=Object.keys(z),U=H.map(()=>"?").join(", "),W=Object.values(z),J=`INSERT INTO ${this._table} (${H.join(", ")}) VALUES (${U})`,X=F(this._connection);return P(this._table),X.insert(J,W)}async insertAll(z){if(z.length===0)return;let H=Object.keys(z[0]),U=z.map(()=>`(${H.map(()=>"?").join(", ")})`).join(", "),W=z.flatMap((Z)=>Object.values(Z)),J=`INSERT INTO ${this._table} (${H.join(", ")}) VALUES ${U}`,X=F(this._connection);P(this._table),await X.execute(J,W)}async update(z){this._bindings=[];let H=this.buildWhereClause(),U=[...this._bindings],W=Object.keys(z).map((Y)=>`${Y} = ?`).join(", "),J=[...Object.values(z),...U],X=`UPDATE ${this._table} SET ${W}${H}`,Z=F(this._connection);return P(this._table),Z.execute(X,J)}async increment(z,H=1){this._bindings=[];let U=this.buildWhereClause(),W=`UPDATE ${this._table} SET ${z} = ${z} + ?${U}`,J=F(this._connection);return P(this._table),J.execute(W,[H,...this._bindings])}async decrement(z,H=1){return this.increment(z,-H)}async delete(){this._bindings=[];let z=this.buildWhereClause(),H=`DELETE FROM ${this._table}${z}`,U=F(this._connection);return P(this._table),U.execute(H,this._bindings)}async truncate(){let z=F(this._connection);P(this._table),await z.execute(`DELETE FROM ${this._table}`)}toSql(){this._bindings=[];let z="SELECT ";if(this._distinct)z+="DISTINCT ";z+=this._columns.map((H)=>{if(typeof H==="object"&&H.__raw)return H.sql;return H}).join(", "),z+=` FROM ${this._table}`;for(let H of this._joins)z+=` ${H.type.toUpperCase()} JOIN ${H.table} ON ${H.first} ${H.operator} ${H.second}`;if(z+=this.buildWhereClause(),this._groupBy.length>0)z+=` GROUP BY ${this._groupBy.join(", ")}`;if(this._having.length>0){let H=this._having.map((U,W)=>{let J=W===0?"":` ${U.boolean.toUpperCase()} `;return this._bindings.push(U.value),`${J}${U.column} ${U.operator} ?`});z+=` HAVING ${H.join("")}`}if(this._orders.length>0)z+=` ORDER BY ${this._orders.map((H)=>`${H.column} ${H.direction.toUpperCase()}`).join(", ")}`;if(this._limit!==void 0)z+=` LIMIT ${this._limit}`;if(this._offset!==void 0)z+=` OFFSET ${this._offset}`;return{sql:z,bindings:this._bindings}}buildWhereClause(){if(this._wheres.length===0)return"";return this._wheres.map((H,U)=>{let W=U===0?" WHERE ":` ${H.boolean.toUpperCase()} `;switch(H.operator){case"in":{let J=H.value,X=J.map(()=>"?").join(", ");return this._bindings.push(...J),`${W}${H.column} IN (${X})`}case"not in":{let J=H.value,X=J.map(()=>"?").join(", ");return this._bindings.push(...J),`${W}${H.column} NOT IN (${X})`}case"between":{let[J,X]=H.value;return this._bindings.push(J,X),`${W}${H.column} BETWEEN ? AND ?`}case"is null":return`${W}${H.column} IS NULL`;case"is not null":return`${W}${H.column} IS NOT NULL`;default:return this._bindings.push(H.value),`${W}${H.column} ${H.operator} ?`}}).join("")}getCacheKey(z,H){return`${this._table}:${z}:${JSON.stringify(H)}`}clone(){let z=new D(this._table);return z._columns=[...this._columns],z._wheres=[...this._wheres],z._orders=[...this._orders],z._joins=[...this._joins],z._groupBy=[...this._groupBy],z._having=[...this._having],z._limit=this._limit,z._offset=this._offset,z._distinct=this._distinct,z._connection=this._connection,z}}function G(z){return new D(z)}function t(z){return G(z)}function E(z,H=[]){return{__raw:!0,sql:z,bindings:H}}function n(z,H){let U=H.primaryKey||"id",W={name:z,definition:H,async find(J){let X=await G(H.table).where(U,J).first();return X?N(W,X):null},async findOrFail(J){let X=await this.find(J);if(!X)throw Error(`${z} not found with ${U} = ${J}`);return X},async all(){return(await G(H.table).get()).map((X)=>N(W,X))},async create(J){let X={...H.defaults,...J},Z=H.fillable?Object.fromEntries(Object.entries(X).filter(([_])=>H.fillable.includes(_))):X;if(H.timestamps!==!1){let _=new Date().toISOString(),R=typeof H.timestamps==="object"?H.timestamps.createdAt||"created_at":"created_at",T=typeof H.timestamps==="object"?H.timestamps.updatedAt||"updated_at":"updated_at";Z[R]=_,Z[T]=_}let Y=await G(H.table).insert(Z);return this.findOrFail(Y)},async update(J){return G(H.table).update(J)},async destroy(J){let X=Array.isArray(J)?J:[J];return G(H.table).whereIn(U,X).delete()},query(){return G(H.table)},where(J,X,Z){return this.query().where(J,X,Z)},async first(){let J=await this.query().first();return J?N(W,J):null},async get(){return(await this.query().get()).map((X)=>N(W,X))},async count(){return this.query().count()}};return A[z]=W,W}function k(z){let H=A[z];if(!H)throw Error(`Model "${z}" not defined. Use defineModel() first.`);return H}function e(z){return z in A}function N(z,H){let{definition:U}=z,W=U.primaryKey||"id",J={...H},X={...H};if(U.casts){for(let[Y,_]of Object.entries(U.casts))if(Y in X)X[Y]=p(X[Y],_)}let Z={exists:!0,original:J,attributes:X,get(Y){return X[Y]},set(Y,_){X[Y]=_},toJSON(){let Y={...X};if(U.hidden)for(let _ of U.hidden)delete Y[_];return Y},async save(){let Y={};for(let _ of Object.keys(X))if(X[_]!==J[_])Y[_]=X[_];if(Object.keys(Y).length>0){if(U.timestamps!==!1){let _=typeof U.timestamps==="object"?U.timestamps.updatedAt||"updated_at":"updated_at";Y[_]=new Date().toISOString()}await G(U.table).where(W,J[W]).update(Y),Object.assign(J,Y)}},async delete(){if(U.softDeletes){let Y=typeof U.softDeletes==="string"?U.softDeletes:"deleted_at";await G(U.table).where(W,J[W]).update({[Y]:new Date().toISOString()})}else await G(U.table).where(W,J[W]).delete();Z.exists=!1},async refresh(){let Y=await G(U.table).where(W,J[W]).first();if(Y)Object.assign(J,Y),Object.assign(X,Y)},isDirty(Y){if(Y)return X[Y]!==J[Y];return Object.keys(X).some((_)=>X[_]!==J[_])}};if(U.relationships)for(let[Y,_]of Object.entries(U.relationships))Object.defineProperty(Z,Y,{value:async()=>{return b(Z,_,z)},enumerable:!1});return new Proxy(Z,{get(Y,_){if(_ in Y)return Y[_];return X[_]},set(Y,_,R){if(_ in Y)Y[_]=R;else X[_]=R;return!0}})}async function b(z,H,U){let W=k(H.model),J=U.definition.primaryKey||"id";switch(H.type){case"hasOne":{let X=H.foreignKey||`${U.name.toLowerCase()}_id`,Z=await G(W.definition.table).where(X,z.get(J)).first();return Z?N(W,Z):null}case"hasMany":{let X=H.foreignKey||`${U.name.toLowerCase()}_id`;return(await G(W.definition.table).where(X,z.get(J)).get()).map((Y)=>N(W,Y))}case"belongsTo":{let X=H.foreignKey||`${H.model.toLowerCase()}_id`,Z=H.localKey||"id",Y=await G(W.definition.table).where(Z,z.get(X)).first();return Y?N(W,Y):null}case"belongsToMany":{let X=H.pivotTable||[U.name,H.model].sort().join("_").toLowerCase(),Z=H.pivotForeignKey||`${U.name.toLowerCase()}_id`,Y=H.pivotRelatedKey||`${H.model.toLowerCase()}_id`,_=W.definition.primaryKey||"id";return(await G(W.definition.table).join(X,`${W.definition.table}.${_}`,"=",`${X}.${Y}`).where(`${X}.${Z}`,z.get(J)).get()).map((T)=>N(W,T))}default:return null}}function p(z,H){if(z===null||z===void 0)return z;switch(H){case"string":return String(z);case"number":return Number(z);case"boolean":return Boolean(z);case"date":return new Date(z);case"json":case"array":return typeof z==="string"?JSON.parse(z):z;default:return z}}async function zz(z,H){let U=F(H);await U.beginTransaction();try{let W=await z();return await U.commit(),W}catch(W){throw await U.rollback(),W}}function g(z){let H=L.get(z);if(!H)return;if(Date.now()-H.timestamp>H.ttl*1000){L.delete(z);return}return H.result}function m(z,H,U){if(L.size>=($.maxCacheSize||1000)){let W=L.keys().next().value;if(W)L.delete(W)}L.set(z,{result:H,timestamp:Date.now(),ttl:U})}function P(z){for(let H of L.keys())if(H.startsWith(`${z}:`))L.delete(H)}function Hz(){L.clear()}function Jz(){return{size:L.size,keys:[...L.keys()]}}function B(z,H,U){if(S.push({sql:z,bindings:H,duration:U,timestamp:new Date}),S.length>1000)S.shift()}function Uz(){return[...S]}function Wz(){S.length=0}function Xz(z=!0){$.logging=z}class O extends Error{sql;bindings;constructor(z,H,U){super(z);this.sql=H;this.bindings=U;this.name="DatabaseError"}}async function u(z,H,U,W){let J=/@db\(\s*['"]([^'"]+)['"]\s*\)((?:->\w+\([^)]*\))*)/g,X=z,Z=[...z.matchAll(J)];for(let Y of Z){let[_,R,T]=Y;try{let j=await s(R,T),I=`$${R}`;H[I]=j,X=X.replace(_,"")}catch(j){X=X.replace(_,`<!-- DB Error: ${j instanceof Error?j.message:String(j)} -->`)}}return X}async function d(z,H,U,W){let J=/@model\(\s*['"]([^'"]+)['"]\s*\)((?:->\w+\([^)]*\))*)/g,X=z,Z=[...z.matchAll(J)];for(let Y of Z){let[_,R,T]=Y;try{let j=k(R),I=await l(j,T),K=`$${R.toLowerCase()}`;H[K]=I,X=X.replace(_,"")}catch(j){X=X.replace(_,`<!-- Model Error: ${j instanceof Error?j.message:String(j)} -->`)}}return X}async function c(z,H,U,W){let J=/@query\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\[[^\]]*\]))?\s*\)\s*as\s+\$(\w+)/g,X=z,Z=[...z.matchAll(J)];for(let Y of Z){let[_,R,T,j]=Y;try{let I=T?JSON.parse(T):[],v=await F().query(R,I);H[`$${j}`]=v,X=X.replace(_,"")}catch(I){X=X.replace(_,`<!-- Query Error: ${I instanceof Error?I.message:String(I)} -->`)}}return X}async function s(z,H){let U=G(z),W=/->(\w+)\(([^)]*)\)/g,J=[...H.matchAll(W)],X=U;for(let[,Z,Y]of J){let _=M(Y);if(typeof X[Z]==="function"){if(X=X[Z](..._),X instanceof Promise){X=await X;break}}}if(X instanceof D)X=await X.get();return X}async function l(z,H){let U=/->(\w+)\(([^)]*)\)/g,W=[...H.matchAll(U)],J=z;for(let[,X,Z]of W){let Y=M(Z);if(typeof J[X]==="function"){if(J=J[X](...Y),J instanceof Promise)J=await J}else if(J instanceof D){if(typeof J[X]==="function"){if(J=J[X](...Y),J instanceof Promise)J=await J}}}if(J instanceof D)J=await J.get();return J}function M(z){if(!z.trim())return[];let H=[],U="",W=0,J=!1,X="";for(let Z=0;Z<z.length;Z++){let Y=z[Z];if(!J&&(Y==='"'||Y==="'"))J=!0,X=Y,U+=Y;else if(J&&Y===X)J=!1,U+=Y;else if(!J&&(Y==="["||Y==="{"||Y==="("))W++,U+=Y;else if(!J&&(Y==="]"||Y==="}"||Y===")"))W--,U+=Y;else if(!J&&W===0&&Y===",")H.push(x(U.trim())),U="";else U+=Y}if(U.trim())H.push(x(U.trim()));return H}function x(z){if(z.startsWith('"')&&z.endsWith('"')||z.startsWith("'")&&z.endsWith("'"))return z.slice(1,-1);if(z==="true")return!0;if(z==="false")return!1;if(z==="null")return null;let H=Number(z);if(!Number.isNaN(H))return H;try{return JSON.parse(z)}catch{return z}}async function Yz(z,H,U,W){let J=z;return J=await c(J,H,U,W),J=await d(J,H,U,W),J=await u(J,H,U,W),J}class w{_connection;connection(z){return this._connection=z,this}async create(z,H){let U=new C(z);H(U);let W=U.toCreateSQL();await F(this._connection).execute(W)}async drop(z){await F(this._connection).execute(`DROP TABLE IF EXISTS ${z}`)}async rename(z,H){await F(this._connection).execute(`ALTER TABLE ${z} RENAME TO ${H}`)}async hasTable(z){let H=F(this._connection);try{return await H.query(`SELECT 1 FROM ${z} LIMIT 1`),!0}catch{return!1}}}class C{table;columns=[];indices=[];constructor(z){this.table=z}id(z="id"){return this.columns.push(`${z} INTEGER PRIMARY KEY AUTOINCREMENT`),this}string(z,H=255){return this.columns.push(`${z} VARCHAR(${H})`),this}text(z){return this.columns.push(`${z} TEXT`),this}integer(z){return this.columns.push(`${z} INTEGER`),this}boolean(z){return this.columns.push(`${z} BOOLEAN DEFAULT 0`),this}datetime(z){return this.columns.push(`${z} DATETIME`),this}timestamps(){return this.columns.push("created_at DATETIME DEFAULT CURRENT_TIMESTAMP"),this.columns.push("updated_at DATETIME DEFAULT CURRENT_TIMESTAMP"),this}softDeletes(){return this.columns.push("deleted_at DATETIME"),this}json(z){return this.columns.push(`${z} TEXT`),this}foreignId(z){return this.columns.push(`${z} INTEGER`),this}index(z){let H=Array.isArray(z)?z:[z],U=`idx_${this.table}_${H.join("_")}`;return this.indices.push(`CREATE INDEX ${U} ON ${this.table} (${H.join(", ")})`),this}unique(z){let H=Array.isArray(z)?z:[z],U=`uniq_${this.table}_${H.join("_")}`;return this.indices.push(`CREATE UNIQUE INDEX ${U} ON ${this.table} (${H.join(", ")})`),this}toCreateSQL(){return`CREATE TABLE IF NOT EXISTS ${this.table} (
|
|
3
3
|
${this.columns.join(`,
|
|
4
4
|
`)}
|
|
5
5
|
)`}getIndexSQL(){return this.indices}}function Zz(){return new w}export{zz as transaction,t as table,Zz as schema,r as resetDatabaseConfig,a as registerAdapter,E as raw,G as query,c as processQueryDirective,d as processModelDirective,u as processDbDirective,Yz as processDatabaseDirectives,e as hasModel,Uz as getQueryLog,Jz as getQueryCacheStats,k as getModel,o as getDatabaseConfig,F as getAdapter,Xz as enableQueryLogging,n as defineModel,i as configureDatabase,Wz as clearQueryLog,Hz as clearQueryCache,w as SchemaBuilder,D as QueryBuilder,O as DatabaseError,C as Blueprint};
|
package/dist/pwa/workbox.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
var {require}=import.meta;import {
|
|
1
|
+
var {require}=import.meta;import { isProduction } from "../env.js";
|
|
2
|
+
import {
|
|
2
3
|
generateRuntimeCachingCode,
|
|
3
4
|
getWorkboxStrategyName
|
|
4
5
|
} from "./workbox-strategies.js";
|
|
@@ -84,8 +85,13 @@ export function generateWorkboxServiceWorker(options, outputDir) {
|
|
|
84
85
|
// Import Workbox modules from CDN
|
|
85
86
|
importScripts('https://storage.googleapis.com/workbox-cdn/releases/7.0.0/workbox-sw.js');
|
|
86
87
|
|
|
87
|
-
// Disable Workbox logging in production
|
|
88
|
-
|
|
88
|
+
// Disable Workbox logging in production. Through isProduction() rather than
|
|
89
|
+
// off process.env.NODE_ENV: this is inside a template literal, so the
|
|
90
|
+
// comparison is evaluated when the service worker is GENERATED -- and the
|
|
91
|
+
// build's transpiler folds that particular read to a constant, so every
|
|
92
|
+
// published copy of stx emitted "debug: true" and no app could turn Workbox's
|
|
93
|
+
// logging off in production however it set NODE_ENV (see ../env.ts).
|
|
94
|
+
workbox.setConfig({ debug: ${!isProduction()} });
|
|
89
95
|
|
|
90
96
|
// Extract modules from workbox global
|
|
91
97
|
${imports}
|
package/dist/pwa.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Gk as wq,Hk as dq,Ik as Cq,Jk as mq,Kk as gq}from"./chunk-kaet6r9w.js";import{Lk as S,Mk as Tq,Nk as _q,Ok as z,Pk as D,Qk as P,Rk as kq,Sk as vq,Tk as w,Uk as Iq,Vk as d,Wk as Hq,Xk as Oq,Yk as Mq}from"./chunk-
|
|
3
|
-
Icon generation requires the sharp package for image processing.`),q.success=!1,q}let R=await y.default(Y).metadata();if(R.width&&R.width<512)q.warnings.push(`Source icon is ${R.width}x${R.height}. Recommend using at least 512x512 for best quality.`);for(let $ of X){let x=L.join(Q,`icon-${$}x${$}.png`);if(await y.default(Y).resize($,$,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(x),q.generatedFiles.push(x),j){let F=L.join(Q,`icon-${$}x${$}.webp`);await y.default(Y).resize($,$,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(F),q.generatedFiles.push(F)}}if(J){for(let x of v){let F=L.join(Q,`apple-touch-icon-${x}x${x}.png`);await y.default(Y).resize(x,x,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(F),q.generatedFiles.push(F)}let $=L.join(Q,"apple-touch-icon.png");await y.default(Y).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile($),q.generatedFiles.push($)}for(let $ of I){let x=L.join(Q,`favicon-${$}x${$}.png`);await y.default(Y).resize($,$,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(x),q.generatedFiles.push(x)}let U=512,T=L.join(Q,`icon-maskable-${U}x${U}.png`),Z=Math.floor(U*0.1),_=U-Z*2;await y.default(Y).resize(_,_,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:Z,bottom:Z,left:Z,right:Z,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(T),q.generatedFiles.push(T)}catch(y){let V=y instanceof Error?y.message:String(y);q.errors.push(`Icon generation failed: ${V}`),q.success=!1}return q}function n(G){let B=G.sizes||k,q=G.outputDir?`/${G.outputDir}`:"/pwa-icons",K=G.generateWebP??!0,Y=G.generateAppleIcons??!0,Q=[];for(let X of B)if(Q.push(`${q}/icon-${X}x${X}.png`),K)Q.push(`${q}/icon-${X}x${X}.webp`);if(Y){Q.push(`${q}/apple-touch-icon.png`);for(let X of v)Q.push(`${q}/apple-touch-icon-${X}x${X}.png`)}for(let X of I)Q.push(`${q}/favicon-${X}x${X}.png`);return Q.push(`${q}/icon-maskable-512x512.png`),Q}async function O(){try{return await import("sharp"),!0}catch{return!1}}function m(G,B,q,K){let Y=[],Q=K.join(" ");for(let X of G)if(Y.push({src:`${B}/icon-${X}x${X}.png`,sizes:`${X}x${X}`,type:"image/png",purpose:Q}),q)Y.push({src:`${B}/icon-${X}x${X}.webp`,sizes:`${X}x${X}`,type:"image/webp",purpose:Q});return Y}function g(G){return G.map((B)=>({name:B.name,short_name:B.shortName,description:B.description,url:B.url,icons:B.icons?.map((q)=>({src:q.src,sizes:q.sizes,type:q.type}))}))}function h(G){let B=G.pwa?.shareTarget;if(!B?.enabled)return;let q={action:B.action||"/share",method:B.method||"POST",enctype:B.enctype||"multipart/form-data",params:{title:B.params?.title||"title",text:B.params?.text||"text",url:B.params?.url||"url"}};if(B.acceptFiles&&B.acceptFiles.length>0)q.params.files=B.acceptFiles.map((K)=>({name:K.name,accept:K.accept}));return q}function c(G){let B=G.pwa?.fileHandlers;if(!B?.enabled||!B.accept)return;let q=[{action:B.action||"/",accept:B.accept,launch_type:B.launchType||"single-client"}];if(B.icons)q[0].icons=B.icons.map((K)=>({src:K.src,sizes:K.sizes,type:K.type}));return q}function l(G){let B=G.pwa?.protocolHandlers;if(!B||B.length===0)return;return B.map((q)=>({protocol:q.protocol,url:q.url}))}function u(G){let B=G.pwa;if(!B?.enabled||!B.manifest)return null;let{manifest:q,icons:K}=B,Y=K?.sizes||[72,96,128,144,152,192,384,512],Q=K?.outputDir?`/${K.outputDir}`:"/pwa-icons",X=K?.generateWebP??!0,j=K?.purpose||["any","maskable"],J={name:q.name,short_name:q.shortName||q.name,description:q.description,start_url:q.startUrl||"/",display:q.display||"standalone",display_override:q.displayOverride,orientation:q.orientation,theme_color:q.themeColor,background_color:q.backgroundColor,scope:q.scope||"/",lang:q.lang,dir:q.dir,id:q.id,categories:q.categories,icons:m(Y,Q,X,j)};if(q.shortcuts&&q.shortcuts.length>0)J.shortcuts=g(q.shortcuts);if(q.screenshots&&q.screenshots.length>0)J.screenshots=q.screenshots.map((U)=>({src:U.src,sizes:U.sizes,type:U.type,label:U.label,form_factor:U.platform}));let y=h(G);if(y)J.share_target=y;let V=c(G);if(V)J.file_handlers=V;let R=l(G);if(R)J.protocol_handlers=R;if(q.launchHandler)J.launch_handler={client_mode:q.launchHandler};if(q.handleLinks)J.handle_links=q.handleLinks;if(q.edgeSidePanel?.enabled)J.edge_side_panel={preferred_width:q.edgeSidePanel.preferredWidth};return J}function M(G){let B=u(G);if(!B)return"";let q=JSON.parse(JSON.stringify(B));return JSON.stringify(q,null,2)}function i(G,B){return{...B,...G,shortcuts:G.shortcuts||B.shortcuts,screenshots:G.screenshots||B.screenshots,categories:G.categories||B.categories}}function s(G){let B=[],q=G.pwa;if(!q?.enabled)return B;let K=q.manifest;if(!K)return B.push("PWA manifest configuration is missing"),B;if(!K.name)B.push("Manifest name is required");let Y=["fullscreen","standalone","minimal-ui","browser"];if(K.display&&!Y.includes(K.display))B.push(`Invalid display mode: ${K.display}. Must be one of: ${Y.join(", ")}`);let Q=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(K.orientation&&!Q.includes(K.orientation))B.push(`Invalid orientation: ${K.orientation}`);let X=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(K.themeColor&&!X.test(K.themeColor))B.push(`Invalid theme color: ${K.themeColor}. Must be a valid hex color.`);if(K.backgroundColor&&!X.test(K.backgroundColor))B.push(`Invalid background color: ${K.backgroundColor}. Must be a valid hex color.`);if(q.shareTarget?.enabled){if(!q.shareTarget.action)B.push("Share target action URL is required")}if(q.fileHandlers?.enabled){if(!q.fileHandlers.accept||Object.keys(q.fileHandlers.accept).length===0)B.push("File handlers must specify accepted MIME types")}if(q.protocolHandlers)for(let j of q.protocolHandlers){if(!j.protocol)B.push("Protocol handler missing protocol");if(!j.url||!j.url.includes("%s"))B.push(`Protocol handler URL must contain %s placeholder: ${j.protocol}`)}return B}import A from"path";async function b(G){let B=G.pwa?.offline;if(!B?.enabled)return"";if(B.page){let q=A.isAbsolute(B.page)?B.page:A.resolve(process.cwd(),B.page);if(await Bun.file(q).exists())try{let{processDirectives:K}=await import("./chunk-
|
|
2
|
+
import{Gk as wq,Hk as dq,Ik as Cq,Jk as mq,Kk as gq}from"./chunk-kaet6r9w.js";import{Lk as S,Mk as Tq,Nk as _q,Ok as z,Pk as D,Qk as P,Rk as kq,Sk as vq,Tk as w,Uk as Iq,Vk as d,Wk as Hq,Xk as Oq,Yk as Mq}from"./chunk-kagjfzk0.js";import{Hw as Aq,Iw as bq,Jw as Sq,Kw as zq,Lw as Dq,Mw as Pq}from"./chunk-4vscfb5b.js";import"./chunk-kt6wm51e.js";import{Uw as N}from"./chunk-1rdm5y91.js";import p from"fs";import E from"path";import C from"fs";import L from"path";var k=[72,96,128,144,152,192,384,512],v=[120,152,167,180],I=[16,32];async function H(G,B){let q={success:!0,generatedFiles:[],errors:[],warnings:[]},K=G.pwa?.icons;if(!K?.src)return q.errors.push("No source icon specified in pwa.icons.src"),q.success=!1,q;let Y=L.isAbsolute(K.src)?K.src:L.resolve(process.cwd(),K.src);if(!await Bun.file(Y).exists())return q.errors.push(`Source icon not found: ${Y}`),q.success=!1,q;let Q=L.resolve(B,K.outputDir||"pwa-icons");try{C.mkdirSync(Q,{recursive:!0})}catch{return q.errors.push(`Failed to create output directory: ${Q}`),q.success=!1,q}let X=K.sizes||k,j=K.generateWebP??!0,J=K.generateAppleIcons??!0;try{let y;try{y=await import("sharp")}catch{return q.errors.push(`sharp is not installed. Install it with: bun add sharp
|
|
3
|
+
Icon generation requires the sharp package for image processing.`),q.success=!1,q}let R=await y.default(Y).metadata();if(R.width&&R.width<512)q.warnings.push(`Source icon is ${R.width}x${R.height}. Recommend using at least 512x512 for best quality.`);for(let $ of X){let x=L.join(Q,`icon-${$}x${$}.png`);if(await y.default(Y).resize($,$,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(x),q.generatedFiles.push(x),j){let F=L.join(Q,`icon-${$}x${$}.webp`);await y.default(Y).resize($,$,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).webp({quality:90}).toFile(F),q.generatedFiles.push(F)}}if(J){for(let x of v){let F=L.join(Q,`apple-touch-icon-${x}x${x}.png`);await y.default(Y).resize(x,x,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile(F),q.generatedFiles.push(F)}let $=L.join(Q,"apple-touch-icon.png");await y.default(Y).resize(180,180,{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}).png().toFile($),q.generatedFiles.push($)}for(let $ of I){let x=L.join(Q,`favicon-${$}x${$}.png`);await y.default(Y).resize($,$,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).png().toFile(x),q.generatedFiles.push(x)}let U=512,T=L.join(Q,`icon-maskable-${U}x${U}.png`),Z=Math.floor(U*0.1),_=U-Z*2;await y.default(Y).resize(_,_,{fit:"contain",background:{r:0,g:0,b:0,alpha:0}}).extend({top:Z,bottom:Z,left:Z,right:Z,background:{r:255,g:255,b:255,alpha:1}}).png().toFile(T),q.generatedFiles.push(T)}catch(y){let V=y instanceof Error?y.message:String(y);q.errors.push(`Icon generation failed: ${V}`),q.success=!1}return q}function n(G){let B=G.sizes||k,q=G.outputDir?`/${G.outputDir}`:"/pwa-icons",K=G.generateWebP??!0,Y=G.generateAppleIcons??!0,Q=[];for(let X of B)if(Q.push(`${q}/icon-${X}x${X}.png`),K)Q.push(`${q}/icon-${X}x${X}.webp`);if(Y){Q.push(`${q}/apple-touch-icon.png`);for(let X of v)Q.push(`${q}/apple-touch-icon-${X}x${X}.png`)}for(let X of I)Q.push(`${q}/favicon-${X}x${X}.png`);return Q.push(`${q}/icon-maskable-512x512.png`),Q}async function O(){try{return await import("sharp"),!0}catch{return!1}}function m(G,B,q,K){let Y=[],Q=K.join(" ");for(let X of G)if(Y.push({src:`${B}/icon-${X}x${X}.png`,sizes:`${X}x${X}`,type:"image/png",purpose:Q}),q)Y.push({src:`${B}/icon-${X}x${X}.webp`,sizes:`${X}x${X}`,type:"image/webp",purpose:Q});return Y}function g(G){return G.map((B)=>({name:B.name,short_name:B.shortName,description:B.description,url:B.url,icons:B.icons?.map((q)=>({src:q.src,sizes:q.sizes,type:q.type}))}))}function h(G){let B=G.pwa?.shareTarget;if(!B?.enabled)return;let q={action:B.action||"/share",method:B.method||"POST",enctype:B.enctype||"multipart/form-data",params:{title:B.params?.title||"title",text:B.params?.text||"text",url:B.params?.url||"url"}};if(B.acceptFiles&&B.acceptFiles.length>0)q.params.files=B.acceptFiles.map((K)=>({name:K.name,accept:K.accept}));return q}function c(G){let B=G.pwa?.fileHandlers;if(!B?.enabled||!B.accept)return;let q=[{action:B.action||"/",accept:B.accept,launch_type:B.launchType||"single-client"}];if(B.icons)q[0].icons=B.icons.map((K)=>({src:K.src,sizes:K.sizes,type:K.type}));return q}function l(G){let B=G.pwa?.protocolHandlers;if(!B||B.length===0)return;return B.map((q)=>({protocol:q.protocol,url:q.url}))}function u(G){let B=G.pwa;if(!B?.enabled||!B.manifest)return null;let{manifest:q,icons:K}=B,Y=K?.sizes||[72,96,128,144,152,192,384,512],Q=K?.outputDir?`/${K.outputDir}`:"/pwa-icons",X=K?.generateWebP??!0,j=K?.purpose||["any","maskable"],J={name:q.name,short_name:q.shortName||q.name,description:q.description,start_url:q.startUrl||"/",display:q.display||"standalone",display_override:q.displayOverride,orientation:q.orientation,theme_color:q.themeColor,background_color:q.backgroundColor,scope:q.scope||"/",lang:q.lang,dir:q.dir,id:q.id,categories:q.categories,icons:m(Y,Q,X,j)};if(q.shortcuts&&q.shortcuts.length>0)J.shortcuts=g(q.shortcuts);if(q.screenshots&&q.screenshots.length>0)J.screenshots=q.screenshots.map((U)=>({src:U.src,sizes:U.sizes,type:U.type,label:U.label,form_factor:U.platform}));let y=h(G);if(y)J.share_target=y;let V=c(G);if(V)J.file_handlers=V;let R=l(G);if(R)J.protocol_handlers=R;if(q.launchHandler)J.launch_handler={client_mode:q.launchHandler};if(q.handleLinks)J.handle_links=q.handleLinks;if(q.edgeSidePanel?.enabled)J.edge_side_panel={preferred_width:q.edgeSidePanel.preferredWidth};return J}function M(G){let B=u(G);if(!B)return"";let q=JSON.parse(JSON.stringify(B));return JSON.stringify(q,null,2)}function i(G,B){return{...B,...G,shortcuts:G.shortcuts||B.shortcuts,screenshots:G.screenshots||B.screenshots,categories:G.categories||B.categories}}function s(G){let B=[],q=G.pwa;if(!q?.enabled)return B;let K=q.manifest;if(!K)return B.push("PWA manifest configuration is missing"),B;if(!K.name)B.push("Manifest name is required");let Y=["fullscreen","standalone","minimal-ui","browser"];if(K.display&&!Y.includes(K.display))B.push(`Invalid display mode: ${K.display}. Must be one of: ${Y.join(", ")}`);let Q=["any","natural","landscape","landscape-primary","landscape-secondary","portrait","portrait-primary","portrait-secondary"];if(K.orientation&&!Q.includes(K.orientation))B.push(`Invalid orientation: ${K.orientation}`);let X=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/;if(K.themeColor&&!X.test(K.themeColor))B.push(`Invalid theme color: ${K.themeColor}. Must be a valid hex color.`);if(K.backgroundColor&&!X.test(K.backgroundColor))B.push(`Invalid background color: ${K.backgroundColor}. Must be a valid hex color.`);if(q.shareTarget?.enabled){if(!q.shareTarget.action)B.push("Share target action URL is required")}if(q.fileHandlers?.enabled){if(!q.fileHandlers.accept||Object.keys(q.fileHandlers.accept).length===0)B.push("File handlers must specify accepted MIME types")}if(q.protocolHandlers)for(let j of q.protocolHandlers){if(!j.protocol)B.push("Protocol handler missing protocol");if(!j.url||!j.url.includes("%s"))B.push(`Protocol handler URL must contain %s placeholder: ${j.protocol}`)}return B}import A from"path";async function b(G){let B=G.pwa?.offline;if(!B?.enabled)return"";if(B.page){let q=A.isAbsolute(B.page)?B.page:A.resolve(process.cwd(),B.page);if(await Bun.file(q).exists())try{let{processDirectives:K}=await import("./chunk-9mvz85xs.js"),Y=await Bun.file(q).text();return await K(Y,{},q,G,new Set)}catch(K){console.warn(`[PWA] Failed to process custom offline page: ${K}`)}else console.warn(`[PWA] Custom offline page not found: ${q}`)}return f(G)}function f(G){let B=G.pwa?.offline,q=G.pwa?.manifest,K=B?.fallbackTitle||"You are offline",Y=B?.fallbackMessage||"Please check your internet connection and try again.",Q=q?.themeColor||"#4f46e5",X=q?.shortName||q?.name||"App";return`<!DOCTYPE html>
|
|
4
4
|
<html lang="en">
|
|
5
5
|
<head>
|
|
6
6
|
<meta charset="UTF-8">
|
package/dist/signals.js
CHANGED
|
@@ -8306,7 +8306,20 @@ else {
|
|
|
8306
8306
|
// the work, so onMount must fire when the trigger actually hydrates the
|
|
8307
8307
|
// scope, not now. deferHydration's run() flushes it then.
|
|
8308
8308
|
var scopeDeferred = el.hasAttribute && el.hasAttribute('stx-hydrate') && !el.__stx_hydrated;
|
|
8309
|
-
if
|
|
8309
|
+
// A component behind a false :if is in the document's MARKUP but not in
|
|
8310
|
+
// the document: bindIf detached the subtree before this walk reached it,
|
|
8311
|
+
// while the component's own setup script already ran and queued its
|
|
8312
|
+
// onMount. Mounting it from here anyway is what made being mounted
|
|
8313
|
+
// unusable as an open state (stacksjs/stx#2036) -- three gated modal
|
|
8314
|
+
// shells each locked body scroll and registered an Escape handler before
|
|
8315
|
+
// anything had been opened, so the page could not be scrolled and Escape
|
|
8316
|
+
// reached whichever instance registered last.
|
|
8317
|
+
//
|
|
8318
|
+
// Left unmounted rather than mounted-and-torn-down, so hydrateComponentScopes
|
|
8319
|
+
// flushes it when bindIf shows the subtree -- the same deferral
|
|
8320
|
+
// stx-hydrate uses above, and the same flush an island gets.
|
|
8321
|
+
var scopeDetached = el.isConnected === false;
|
|
8322
|
+
if (scopeVars && scopeVars.__mountCallbacks && !scopeVars.__mounted && !scopeDeferred && !scopeDetached) {
|
|
8310
8323
|
scopeVars.__mounted = true;
|
|
8311
8324
|
runMountCallbacks(scopeVars.__mountCallbacks, scopeDestroySink(scopeVars));
|
|
8312
8325
|
}
|
package/dist/ssg.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{Ck as wq,xk as Uq,yk as Iq}from"./chunk-
|
|
2
|
+
import{Ck as wq,xk as Uq,yk as Iq}from"./chunk-s7j42ma7.js";import{Dk as Eq,Ek as Tq,Fk as Dq}from"./chunk-frp9fc7j.js";import{_k as _q,bl as zq,cl as Aq}from"./chunk-5jvagdgn.js";import"./chunk-r9vpgmbd.js";import"./chunk-qjvny3wf.js";import{Mp as C,Um as Oq,ko as l,no as Hq,yr as n}from"./chunk-wgsmawhw.js";import"./chunk-ma41bbjn.js";import"./chunk-49trnqad.js";import"./chunk-c0vjhzjf.js";import"./chunk-vjn3r3sq.js";import"./chunk-cbj5a2tk.js";import{ot as Xq}from"./chunk-fx32tvka.js";import{tt as d}from"./chunk-2zbmyvqc.js";import"./chunk-sjpjge04.js";import"./chunk-dfeq9d99.js";import"./chunk-k6bagvmz.js";import{_t as Bq}from"./chunk-sh77d4tv.js";import"./chunk-ystnxqsq.js";import"./chunk-4djwtq0y.js";import"./chunk-7wkxs25k.js";import"./chunk-8kwtg74v.js";import"./chunk-eap7w3a8.js";import{uw as Yq,vw as Vq,ww as jq,xw as Gq,yw as Lq,zw as Nq}from"./chunk-h5pdcxre.js";import"./chunk-4vscfb5b.js";import"./chunk-kt6wm51e.js";import{Uw as P}from"./chunk-1rdm5y91.js";import X from"fs";import j from"path";import{createHash as xq}from"crypto";function yq(q){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(q).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return q}}var Pq=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function Cq(q){return Bun.hash(q).toString(16)}function Qq(q,Z={}){if(!q.includes('type="stx/island"'))return{html:q,chunks:[]};let $=new Map,Q=q.replace(Pq,(J,W,_,z)=>{let L=z.trim();if(!L)return J;if(/\bdata-stx-src=/.test(_))return J;if(Z.minify)L=yq(L);let A=Cq(L);if(!$.has(A))$.set(A,L);let B=Z.integrity?` data-stx-integrity="sha384-${xq("sha384").update(L).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${W}" data-stx-src="/_stx/islands/${A}.js"${B}${_}></script>`}),K=Array.from($,([J,W])=>({hash:J,code:W}));return{html:Q,chunks:K}}var gq=new Set(["visible","idle"]);function Zq(q){if(!q.includes("data-stx-src="))return q;let Z=new Map,$=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,Q;while((Q=$.exec(q))!==null)Z.set(Q[1],Q[2]);let K=new Set,J=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,W;while((W=J.exec(q))!==null)if(gq.has(Z.get(W[1])||""))K.add(W[2]);let _=q.lastIndexOf("</head>");if(K.size===0||_===-1)return q;let z=Array.from(K).filter((L)=>!q.includes(`rel="prefetch" href="${L}"`)).map((L)=>`<link rel="prefetch" href="${L}" as="script">`).join("");if(!z)return q;return q.slice(0,_)+z+q.slice(_)}var fq=["STX_SITE_URL","SITE_URL","URL","VERCEL_URL","CF_PAGES_URL"];function h(q){let Z=q.trim();if(!Z)return null;let $=/^https?:\/\//i.test(Z)?Z:`https://${Z}`;try{return new URL($).origin+new URL($).pathname.replace(/\/$/,"")}catch{return null}}function mq(q){for(let Z of fq){let $=q[Z];if(!$)continue;let Q=h($);if(Q)return{url:Q,source:"env",via:Z}}return null}function $q(q){if(!q||typeof q!=="object")return null;let Z=q,$=Z.site?.url??Z.url??Z.app?.url;return typeof $==="string"?h($):null}async function dq(q){let{existsSync:Z}=await import("fs"),$=await import("path");for(let Q of["site.config.ts","site.config.js",".config/site.config.ts"]){let K=$.resolve(q,Q);if(!Z(K))continue;try{let J=await import(K),W=$q(J.default??J);if(W)return W}catch{}}return null}async function Kq(q={}){let Z=q.cwd??process.cwd(),$=q.env??process.env;if(q.explicit){let W=h(q.explicit);if(W)return{url:W,source:"option"}}let Q=$q(q.stxConfig);if(Q)return{url:Q,source:"stx.config",via:"site.url"};let K=await dq(Z);if(K)return{url:K,source:"site.config",via:"url"};let J=mq($);if(J)return J;return{url:"http://localhost",source:"fallback"}}function Wq(){return["No site URL configured \u2014 sitemap.xml and robots.txt will point at http://localhost."," Set one in stx.config.ts (site: { url: 'https://example.com' }), in site.config.ts,"," via --domain, or with SITE_URL in the build environment."].join(`
|
|
3
3
|
`)}class Fq{cacheDir;cache=new Map;loaded=!1;salt;constructor(q,Z=""){this.cacheDir=q,this.salt=Z}async load(){if(this.loaded)return;let q=j.join(this.cacheDir,"build-cache.json");if(await Bun.file(q).exists())try{let Z=JSON.parse(await Bun.file(q).text());for(let[$,Q]of Object.entries(Z))this.cache.set($,Q)}catch{}this.loaded=!0}async save(){await X.promises.mkdir(this.cacheDir,{recursive:!0});let q=j.join(this.cacheDir,"build-cache.json"),Z={};for(let[$,Q]of this.cache)Z[$]=Q;await Bun.write(q,JSON.stringify(Z))}getHash(q,Z){let $=X.statSync(q),Q=`${this.salt}|${q}:${$.mtimeMs}`;for(let J of Z)if(X.existsSync(J)){let W=X.statSync(J);Q+=`:${J}:${W.mtimeMs}`}let K=0;for(let J=0;J<Q.length;J++){let W=Q.charCodeAt(J);K=(K<<5)-K+W,K=K&K}return Math.abs(K).toString(36)}get(q,Z){let $=this.cache.get(q);if(!$)return null;let Q=this.getHash(Z,$.dependencies??[]);if($.hash!==Q)return this.cache.delete(q),null;return $.html}set(q,Z,$,Q){let K=this.getHash(Z,$);this.cache.set(q,{hash:K,html:Q,generatedAt:Date.now(),dependencies:$})}}class Rq{cacheDir;constructor(q){this.cacheDir=q}getFilePath(q){let Z=q.replace(/[^a-zA-Z0-9]/g,"_")+".json";return j.join(this.cacheDir,"isr",Z)}async get(q){let Z=this.getFilePath(q);if(!await Bun.file(Z).exists())return null;try{return JSON.parse(await Bun.file(Z).text())}catch{return null}}async set(q,Z){let $=this.getFilePath(q);await X.promises.mkdir(j.dirname($),{recursive:!0}),await Bun.write($,JSON.stringify(Z))}async invalidate(q){let Z=this.getFilePath(q);if(await Bun.file(Z).exists())await X.promises.unlink(Z)}async invalidatePattern(q){let Z=j.join(this.cacheDir,"isr");if(!X.existsSync(Z))return;let $=await X.promises.readdir(Z);for(let Q of $){let K=Q.replace(/_/g,"/").replace(".json","");if(q.test(K))await X.promises.unlink(j.join(Z,Q))}}async needsRevalidation(q){let Z=await this.get(q);if(!Z)return!0;return Date.now()>Z.revalidateAfter}}async function pq(q){try{let $=(await Bun.file(q).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!$)return null;let Q=$[1];if(!Q.includes("getStaticPaths"))return null;let K=Q.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!K)return null;return await Function(`
|
|
4
4
|
return (async function getStaticPaths() {
|
|
5
5
|
${K[1]}
|
|
@@ -41,7 +41,7 @@ ${q.map((Q)=>{let K=new URL(Q.loc,Z).href,J=` <url>
|
|
|
41
41
|
${$.join(`
|
|
42
42
|
`)}
|
|
43
43
|
</channel>
|
|
44
|
-
</rss>`}async function tq(q={}){let Z=Date.now();Aq();let $=await n(process.cwd()),Q=$.build||{},K=await Kq({explicit:q.domain||Q.domain,stxConfig:$});if(K.source==="fallback"&&(q.sitemap??Q.sitemap??!0))console.warn(Wq());let J={router:q.router??$?.router??{},pagesDir:q.pagesDir||Q.pagesDir||"pages",outputDir:q.outputDir||Q.outputDir||"dist",baseUrl:q.baseUrl||Q.baseUrl||"/",domain:K.url,revalidate:q.revalidate??Q.revalidate??!1,sitemap:q.sitemap??Q.sitemap??!0,sitemapExclude:q.sitemapExclude||Q.sitemapExclude||[],robots:q.robots??Q.robots??!0,rss:q.rss??Q.rss??!1,concurrency:q.concurrency||Q.concurrency||10,cache:q.cache??Q.cache??!0,cacheDir:q.cacheDir||Q.cacheDir||d(process.cwd(),"ssg-cache"),contentLoaders:q.contentLoaders||[],hooks:q.hooks||{},minify:q.minify??Q.minify??!0,generate404:q.generate404??Q.generate404??!0,publicDir:q.publicDir||Q.publicDir||"public",trailingSlash:q.trailingSlash??Q.trailingSlash??!1,cleanOutput:q.cleanOutput??Q.cleanOutput??!0,cacheSalt:q.cacheSalt??"",partialsDir:q.partialsDir||$?.partialsDir||"",componentsDir:q.componentsDir||$?.componentsDir||"",failOnIncludeError:q.failOnIncludeError??!0,failOnServerScriptError:q.failOnServerScriptError??!0,chunkIslands:q.chunkIslands===!0,prefetchIslands:q.prefetchIslands===!0,integrityIslands:q.integrityIslands===!0},W={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},_=new Set,z=0,L={},A={};await J.hooks.onBuildStart?.();try{if(J.cleanOutput&&X.existsSync(J.outputDir))await X.promises.rm(J.outputDir,{recursive:!0});await X.promises.mkdir(J.outputDir,{recursive:!0});let U=J.cacheSalt;if(!U){let{resolveUserCssConfig:Y,fingerprintConfig:N}=await import("./chunk-
|
|
44
|
+
</rss>`}async function tq(q={}){let Z=Date.now();Aq();let $=await n(process.cwd()),Q=$.build||{},K=await Kq({explicit:q.domain||Q.domain,stxConfig:$});if(K.source==="fallback"&&(q.sitemap??Q.sitemap??!0))console.warn(Wq());let J={router:q.router??$?.router??{},pagesDir:q.pagesDir||Q.pagesDir||"pages",outputDir:q.outputDir||Q.outputDir||"dist",baseUrl:q.baseUrl||Q.baseUrl||"/",domain:K.url,revalidate:q.revalidate??Q.revalidate??!1,sitemap:q.sitemap??Q.sitemap??!0,sitemapExclude:q.sitemapExclude||Q.sitemapExclude||[],robots:q.robots??Q.robots??!0,rss:q.rss??Q.rss??!1,concurrency:q.concurrency||Q.concurrency||10,cache:q.cache??Q.cache??!0,cacheDir:q.cacheDir||Q.cacheDir||d(process.cwd(),"ssg-cache"),contentLoaders:q.contentLoaders||[],hooks:q.hooks||{},minify:q.minify??Q.minify??!0,generate404:q.generate404??Q.generate404??!0,publicDir:q.publicDir||Q.publicDir||"public",trailingSlash:q.trailingSlash??Q.trailingSlash??!1,cleanOutput:q.cleanOutput??Q.cleanOutput??!0,cacheSalt:q.cacheSalt??"",partialsDir:q.partialsDir||$?.partialsDir||"",componentsDir:q.componentsDir||$?.componentsDir||"",failOnIncludeError:q.failOnIncludeError??!0,failOnServerScriptError:q.failOnServerScriptError??!0,chunkIslands:q.chunkIslands===!0,prefetchIslands:q.prefetchIslands===!0,integrityIslands:q.integrityIslands===!0},W={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},_=new Set,z=0,L={},A={};await J.hooks.onBuildStart?.();try{if(J.cleanOutput&&X.existsSync(J.outputDir))await X.promises.rm(J.outputDir,{recursive:!0});await X.promises.mkdir(J.outputDir,{recursive:!0});let U=J.cacheSalt;if(!U){let{resolveUserCssConfig:Y,fingerprintConfig:N}=await import("./chunk-8569hftj.js");try{U=N(await Y(process.cwd()))}catch{}}let{prepareImageDelivery:G}=await import("./chunk-e0n9r2b8.js"),H=await G(J.publicDir,J.outputDir);if(H.count>0)console.log(`Optimized ${H.count} image(s) for responsive delivery`),U=[U,H.fingerprint].filter(Boolean).join(":");let F=new Fq(J.cacheDir,U);if(J.cache)await F.load();try{let{generateCss:Y}=await import("./chunk-8569hftj.js");await Y('<div class="bg-black"></div>')}catch{}Yq();let kq=$?.routeMiddleware?.dir||"middleware";await jq(process.cwd(),kq);let p=Vq();if(p.length>0)console.log(`Loaded ${p.length} middleware: ${p.join(", ")}`);let bq=$?.routeMiddleware?.global||[];wq($?.layoutsDir,d(process.cwd()));let i=l(".",{pagesDir:J.pagesDir,pagesDirs:$?._layerPageDirs});console.log(`Found ${i.length} routes`);let g=[];for(let Y of i){let N=await uq(Y);for(let O of N)g.push({route:Y,url:O.url,params:O.params,props:O.props,revalidate:O.revalidate??J.revalidate})}W.totalPages=g.length,console.log(`Generating ${W.totalPages} pages...`);let S=[],o=[];for(let Y=0;Y<g.length;Y+=J.concurrency)o.push(g.slice(Y,Y+J.concurrency));for(let Y of o)await Promise.all(Y.map(async(N)=>{let{route:O,url:V,params:v,props:Sq,revalidate:r}=N;try{await J.hooks.onPageStart?.(V);let R=await Bun.file(O.filePath).text(),M=QJ(R),vq=M?.middleware?Array.isArray(M.middleware)?M.middleware:[M.middleware]:[],t=[...bq,...vq];if(t.length>0){let T=Gq(V,v,M||{}),k=Lq(T,null,void 0,{isServer:!0}),D=await Nq(t,k);if(D.redirect){let I=typeof D.redirect==="string"?D.redirect:D.redirect.path||D.redirect,y=ZJ(String(I),V),b=$J(V,J);await X.promises.mkdir(j.dirname(b),{recursive:!0}),await Bun.write(b,y),W.successCount++,W.pages.push({route:V,outputPath:b,size:Buffer.byteLength(y),cached:!1}),S.push({loc:V,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${V} \u2192 redirect to ${I}`);return}if(D.abort){let I=typeof D.abort==="string"?D.abort:D.abort?.error?.message||"aborted";console.warn(` \u21B3 ${V} \u2014 middleware aborted: ${I}`);return}}let e=R.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(e)try{if(!await Function("route",`
|
|
45
45
|
const validate = ${e[1]};
|
|
46
46
|
return validate(route);
|
|
47
47
|
`)({params:v})){console.warn(`Validation failed for ${V}, skipping...`);return}}catch{}let E=null,qq=!1;if(J.cache){if(E=F.get(V,O.filePath),E)qq=!0,W.cachedCount++}if(!E){let T=await Mq(O,v,Sq,J,$);if(E=T.html,J.failOnIncludeError&&T.includeFailures.length>0)throw Error(`${T.includeFailures.length} include(s) failed to resolve, so this page would have shipped with an error banner where the markup should be:
|
package/dist/utils.js
CHANGED
|
@@ -828,7 +828,7 @@ export async function renderComponentWithSlot(componentPath, props, slotContent,
|
|
|
828
828
|
}
|
|
829
829
|
if (slotContent && templateContent.includes("{{ text || slot }}"))
|
|
830
830
|
templateContent = templateContent.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g, () => slotContent);
|
|
831
|
-
const { applySlots } = await importOnce("stx/slots", () => import("./slots.js")), { defaultSlot, namedSlots } = parsedSlotContent, hasSignalScripts = clientScripts.some((s) => /\b(?:state|derived|effect|ref|useRef|reactive|computed|watch|watchEffect|useModel|useReactiveProp|defineProps|withDefaults|defineEmits|defineExpose|defineSlots)\s*(?:<[^<>()]*>)?\s*\(/.test(s)), projectRefs = (content) => hasSignalScripts ? markProjectedRefs(content, componentUid) : content, projectedSlots = new Map([...namedSlots].map(([name, slot]) => [name, {
|
|
831
|
+
const { applySlots } = await importOnce("stx/slots", () => import("./slots.js")), { defaultSlot, namedSlots } = parsedSlotContent, hasSignalScripts = clientScripts.some((s) => /\b(?:state|derived|effect|ref|useRef|reactive|computed|watch|watchEffect|useModel|useReactiveProp|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots)\s*(?:<[^<>()]*>)?\s*\(/.test(s)), projectRefs = (content) => hasSignalScripts ? markProjectedRefs(content, componentUid) : content, projectedSlots = new Map([...namedSlots].map(([name, slot]) => [name, {
|
|
832
832
|
...slot,
|
|
833
833
|
content: projectRefs(slot.content)
|
|
834
834
|
}]));
|
package/dist/visual-testing.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import"./chunk-
|
|
2
|
+
import"./chunk-1rdm5y91.js";import B from"fs";import $ from"path";import k from"crypto";var V=[{name:"mobile",width:375,height:667,isMobile:!0,hasTouch:!0},{name:"tablet",width:768,height:1024,isMobile:!0,hasTouch:!0},{name:"desktop",width:1280,height:800,isMobile:!1,hasTouch:!1},{name:"wide",width:1920,height:1080,isMobile:!1,hasTouch:!1}];function J(N={}){let Y={snapshotDir:N.snapshotDir||"__snapshots__",screenshotDir:N.screenshotDir||"__screenshots__",updateSnapshots:N.updateSnapshots||process.env.UPDATE_SNAPSHOTS==="true",threshold:N.threshold??0.01,viewports:N.viewports||V,generateDiff:N.generateDiff??!0,diffDir:N.diffDir||"__diffs__",compare:N.compare||b,ci:N.ci??process.env.CI==="true",retries:N.retries??(N.ci?3:1)};return{async snapshot(M,X){let q=$.join(Y.snapshotDir,`${X}.html`),G=C(M),Q=K(G);if(await Bun.file(q).exists()){let W=await Bun.file(q).text(),Z=K(C(W));if(Q===Z)return{passed:!0,snapshotPath:q,message:"Snapshot matches"};if(Y.updateSnapshots)return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"Snapshot updated"};let F=$.join(Y.diffDir,`${X}.actual.html`),U=$.join(Y.diffDir,`${X}.diff.html`);return await B.promises.mkdir(Y.diffDir,{recursive:!0}),await Bun.write(F,G),await Bun.write(U,I(W,G)),{passed:!1,snapshotPath:q,actualPath:F,diffPath:U,message:"Snapshot does not match"}}return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"New snapshot created"}},async snapshotJson(M,X){let q=$.join(Y.snapshotDir,`${X}.json`),G=JSON.stringify(M,null,2);if(await Bun.file(q).exists()){let Q=await Bun.file(q).text();if(G===Q)return{passed:!0,snapshotPath:q};if(Y.updateSnapshots)return await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"Snapshot updated"};return{passed:!1,snapshotPath:q,message:`JSON snapshot mismatch:
|
|
3
3
|
${z(Q,G)}`}}return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"New snapshot created"}},matchInlineSnapshot(M,X){let q=C(M);if(X===void 0)return{passed:!0,expected:q};let G=C(X);return{passed:q===G,expected:q}},getConfig(){return Y}}}function D(N={}){let Y=J(N),M=Y.getConfig();return{async compareScreenshots(X,q,G="desktop"){let Q=$.join(M.screenshotDir,G,`${X}.png`),W=$.join(M.diffDir,G,`${X}.actual.png`),Z=$.join(M.diffDir,G,`${X}.diff.png`);if(await Bun.file(Q).exists()){let F=await Bun.file(Q).arrayBuffer(),U=Buffer.from(F),_=await M.compare(q,U);if(_.match||_.diffPercentage<=M.threshold)return{viewport:G,passed:!0,baselinePath:Q};if(M.updateSnapshots)return await B.promises.mkdir($.dirname(Q),{recursive:!0}),await Bun.write(Q,q),{viewport:G,passed:!0,baselinePath:Q};if(await B.promises.mkdir($.dirname(W),{recursive:!0}),await Bun.write(W,q),_.diffImage&&M.generateDiff)await Bun.write(Z,_.diffImage);return{viewport:G,passed:!1,baselinePath:Q,actualPath:W,diffPath:M.generateDiff?Z:void 0,diffPercentage:_.diffPercentage}}return await B.promises.mkdir($.dirname(Q),{recursive:!0}),await Bun.write(Q,q),{viewport:G,passed:!0,baselinePath:Q}},async testViewports(X,q,G=M.viewports){let Q=[];for(let W of G){let Z=null;for(let F=0;F<M.retries;F++)try{let U=await q(W),_=await this.compareScreenshots(X,U,W.name);Q.push(_),Z=null;break}catch(U){if(Z=U,F<M.retries-1)await new Promise((_)=>setTimeout(_,100*(F+1)))}if(Z)Q.push({viewport:W.name,passed:!1,baselinePath:"",diffPercentage:100})}return Q},getSnapshotTester(){return Y}}}function L(N={}){let M=D(N).getSnapshotTester(),X=new Map;return{addStory(q){X.set(`${q.component}/${q.name}`,q)},addStories(q){for(let G of q)this.addStory(G)},getStories(){return Array.from(X.values())},getStoriesForComponent(q){return Array.from(X.values()).filter((G)=>G.component===q)},async testStory(q){let G=X.get(q);if(!G)return{name:q,passed:!1,duration:0,snapshots:[],screenshots:[],errors:[Error(`Story not found: ${q}`)]};let Q=Date.now(),W={name:q,passed:!0,duration:0,snapshots:[],screenshots:[],errors:[]};try{let Z=await G.render(),F=await M.snapshot(Z,q.replace(/\//g,"-"));if(W.snapshots.push(F),!F.passed)W.passed=!1}catch(Z){W.passed=!1,W.errors.push(Z)}return W.duration=Date.now()-Q,W},async testAllStories(){let q=[];for(let G of X.keys()){let Q=await this.testStory(G);q.push(Q)}return q},async generateStoryIndex(){let q={};for(let G of X.values()){if(!q[G.component])q[G.component]=[];q[G.component].push({name:G.name,args:G.args})}return JSON.stringify(q,null,2)}}}async function S(N,Y={}){let M={outputDir:Y.outputDir||"visual-test-report",format:Y.format||"html",title:Y.title||"Visual Test Report",includeScreenshots:Y.includeScreenshots??!0};await B.promises.mkdir(M.outputDir,{recursive:!0});let X=N.length,q=N.filter((F)=>F.passed).length,G=X-q,Q=N.reduce((F,U)=>F+U.duration,0);if(M.format==="json"){let F={title:M.title,summary:{total:X,passed:q,failed:G,duration:Q},results:N,generatedAt:new Date().toISOString()},U=$.join(M.outputDir,"report.json");return await Bun.write(U,JSON.stringify(F,null,2)),U}if(M.format==="markdown"){let F=`# ${M.title}
|
|
4
4
|
|
|
5
5
|
`;F+=`## Summary
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/stx",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.381",
|
|
5
5
|
"description": "A performant UI Framework. Powered by Bun.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -118,12 +118,12 @@
|
|
|
118
118
|
"dependencies": {
|
|
119
119
|
"@stacksjs/ts-css": "^0.3.2",
|
|
120
120
|
"@stacksjs/clapp": "^0.2.16",
|
|
121
|
-
"@stacksjs/desktop": "0.2.
|
|
122
|
-
"@stacksjs/sanitizer": "0.2.
|
|
121
|
+
"@stacksjs/desktop": "0.2.381",
|
|
122
|
+
"@stacksjs/sanitizer": "0.2.381",
|
|
123
123
|
"@stacksjs/ts-i18n": "^0.1.11",
|
|
124
|
-
"bun-plugin-stx": "0.2.
|
|
124
|
+
"bun-plugin-stx": "0.2.381",
|
|
125
125
|
"bunfig": "^0.15.19",
|
|
126
|
-
"stx-router": "0.2.
|
|
126
|
+
"stx-router": "0.2.381",
|
|
127
127
|
"ts-broadcasting": "^0.0.11",
|
|
128
128
|
"ts-images": "^0.2.22",
|
|
129
129
|
"ts-syntax-highlighter": "^0.2.1"
|
package/dist/chunk-0m9dp2nx.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Am as g,Bm as h,Cm as i,Dm as j,Em as k,Fm as l,Gm as m,Hm as n,Im as o,Jm as p,Km as q,Lm as r,Mm as s,um as a,vm as b,wm as c,xm as d,ym as e,zm as f}from"./chunk-yz2yk0p1.js";import"./chunk-nh6p0k17.js";import"./chunk-49trnqad.js";import"./chunk-c0vjhzjf.js";import"./chunk-vjn3r3sq.js";import"./chunk-cbj5a2tk.js";import"./chunk-05c62pqd.js";import"./chunk-2zbmyvqc.js";import"./chunk-sjpjge04.js";import"./chunk-0380epk7.js";import"./chunk-k6bagvmz.js";import"./chunk-zhzcahz5.js";import"./chunk-8kwmj99g.js";import"./chunk-7ngmxv4z.js";import"./chunk-s3tpyage.js";import"./chunk-2sa8rk32.js";import"./chunk-x8t29tnr.js";import"./chunk-0xh7vqce.js";import"./chunk-wqa77pdn.js";import"./chunk-myyj9qp3.js";export{j as usesSignalsInScript,s as unescapeHtml,q as resetRejectedExpressionWarnings,g as replaceInterpolations,c as registerFilters,b as registerFilter,o as processExpressions,n as interpolateScriptsInTemplate,l as interpolateScriptExpressions,m as interpolateScriptAttributes,d as getAllFilters,f as findMustacheEnd,r as evaluateExpression,i as escapeHtmlValue,h as escapeHtml,a as defaultFilters,k as clientLoopScopes,e as clearCustomFilters,p as applyFilters};
|
package/dist/chunk-0nknfsxa.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Au as n,Bu as o,Cu as p,nu as a,ou as b,pu as c,qu as d,ru as e,su as f,tu as g,uu as h,vu as i,wu as j,xu as k,yu as l,zu as m}from"./chunk-8kwmj99g.js";import"./chunk-7ngmxv4z.js";import"./chunk-myyj9qp3.js";export{i as useTitle,f as useSeoMeta,i as usePageTitle,d as useHead,g as seoMetaToHeadConfig,c as resetHead,k as renderHtmlAttrs,j as renderHead,l as renderBodyAttrs,o as processTitleDirective,p as processMetaDirective,n as processHeadDirective,e as mergeHeadConfigs,b as getPageMeta,a as getHead,h as definePageMeta,m as applyHead};
|
package/dist/chunk-2ggshmdx.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Le as c,Me as d,Ne as e,Oe as f,Pe as g,Qe as h,Re as i}from"./chunk-xf1dwv3x.js";import"./chunk-an5y1z0q.js";import"./chunk-ra1s4s6b.js";import"./chunk-9n88pgdr.js";import"./chunk-geztv535.js";import"./chunk-qjvny3wf.js";import{Np as a,Qp as b}from"./chunk-yz2yk0p1.js";import"./chunk-nh6p0k17.js";import"./chunk-49trnqad.js";import"./chunk-c0vjhzjf.js";import"./chunk-vjn3r3sq.js";import"./chunk-cbj5a2tk.js";import"./chunk-05c62pqd.js";import"./chunk-2zbmyvqc.js";import"./chunk-sjpjge04.js";import"./chunk-0380epk7.js";import"./chunk-k6bagvmz.js";import"./chunk-zhzcahz5.js";import"./chunk-8kwmj99g.js";import"./chunk-7ngmxv4z.js";import"./chunk-s3tpyage.js";import"./chunk-2sa8rk32.js";import"./chunk-x8t29tnr.js";import"./chunk-0xh7vqce.js";import"./chunk-wqa77pdn.js";import"./chunk-myyj9qp3.js";export{d as virtualPathFor,h as typecheckStxFiles,e as sourcePathFor,i as formatTypecheckDiagnostics,g as findStxModuleDeclarations,f as findRuntimeTypeDeclarations,b as extractTemplateExpressions,a as extractScriptBlocks,c as buildVirtualSource};
|
package/dist/chunk-367ce1y2.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Ve as a}from"./chunk-cjxs8r0c.js";import"./chunk-0knxnyq6.js";import"./chunk-yz2yk0p1.js";import"./chunk-nh6p0k17.js";import"./chunk-49trnqad.js";import"./chunk-c0vjhzjf.js";import"./chunk-vjn3r3sq.js";import"./chunk-cbj5a2tk.js";import"./chunk-05c62pqd.js";import"./chunk-2zbmyvqc.js";import"./chunk-sjpjge04.js";import"./chunk-0380epk7.js";import"./chunk-k6bagvmz.js";import"./chunk-zhzcahz5.js";import"./chunk-8kwmj99g.js";import"./chunk-7ngmxv4z.js";import"./chunk-s3tpyage.js";import"./chunk-2sa8rk32.js";import"./chunk-x8t29tnr.js";import"./chunk-0xh7vqce.js";import"./chunk-wqa77pdn.js";import"./chunk-myyj9qp3.js";export{a as buildApp};
|
package/dist/chunk-3ckt56vs.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{lk as a,mk as b,nk as c,ok as d}from"./chunk-reafpw3e.js";import"./chunk-s5r9pd0e.js";import"./chunk-yz2yk0p1.js";import"./chunk-nh6p0k17.js";import"./chunk-49trnqad.js";import"./chunk-c0vjhzjf.js";import"./chunk-vjn3r3sq.js";import"./chunk-cbj5a2tk.js";import"./chunk-05c62pqd.js";import"./chunk-2zbmyvqc.js";import"./chunk-sjpjge04.js";import"./chunk-0380epk7.js";import"./chunk-k6bagvmz.js";import"./chunk-zhzcahz5.js";import"./chunk-8kwmj99g.js";import"./chunk-7ngmxv4z.js";import"./chunk-s3tpyage.js";import"./chunk-2sa8rk32.js";import"./chunk-x8t29tnr.js";import"./chunk-0xh7vqce.js";import"./chunk-wqa77pdn.js";import"./chunk-myyj9qp3.js";export{b as getAvailableTargets,c as getAvailableFormats,d as default,a as buildNative};
|
package/dist/chunk-3eq3h4cm.js
DELETED
package/dist/chunk-4vg0zgas.js
DELETED
package/dist/chunk-5ztqaab9.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Ni as a,Oi as b,Pi as c,Qi as d,Ri as e,Si as f,Ti as g,Ui as h,Vi as i,Wi as j,Xi as k,Yi as l,Zi as m,_i as n}from"./chunk-21kjq7eq.js";import"./chunk-yz2yk0p1.js";import"./chunk-nh6p0k17.js";import"./chunk-49trnqad.js";import"./chunk-c0vjhzjf.js";import"./chunk-vjn3r3sq.js";import"./chunk-cbj5a2tk.js";import"./chunk-05c62pqd.js";import"./chunk-2zbmyvqc.js";import"./chunk-sjpjge04.js";import"./chunk-0380epk7.js";import"./chunk-k6bagvmz.js";import"./chunk-zhzcahz5.js";import"./chunk-8kwmj99g.js";import"./chunk-7ngmxv4z.js";import"./chunk-s3tpyage.js";import"./chunk-2sa8rk32.js";import"./chunk-x8t29tnr.js";import"./chunk-0xh7vqce.js";import"./chunk-wqa77pdn.js";import"./chunk-myyj9qp3.js";export{i as streamingSuspenseDirective,m as streamToResponse,g as streamTemplateSimple,a as streamTemplate,d as renderStreamingPage,k as registerStreamingDirectives,e as processStreamDirectives,l as processSectionDirectives,j as islandDirective,n as generateHydrationRuntime,f as extractStreamBoundaries,h as createStreamRenderer,b as buildSuspenseResolveScript,c as SUSPENSE_RESOLVER_RUNTIME};
|
package/dist/chunk-7j6stht9.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Ao as m,oo as a,po as b,qo as c,ro as d,so as e,to as f,uo as g,vo as h,wo as i,xo as j,yo as k,zo as l}from"./chunk-yz2yk0p1.js";import"./chunk-nh6p0k17.js";import"./chunk-49trnqad.js";import"./chunk-c0vjhzjf.js";import"./chunk-vjn3r3sq.js";import"./chunk-cbj5a2tk.js";import"./chunk-05c62pqd.js";import"./chunk-2zbmyvqc.js";import"./chunk-sjpjge04.js";import"./chunk-0380epk7.js";import"./chunk-k6bagvmz.js";import"./chunk-zhzcahz5.js";import"./chunk-8kwmj99g.js";import"./chunk-7ngmxv4z.js";import"./chunk-s3tpyage.js";import"./chunk-2sa8rk32.js";import"./chunk-x8t29tnr.js";import"./chunk-0xh7vqce.js";import"./chunk-wqa77pdn.js";import"./chunk-myyj9qp3.js";export{m as stripStxRuntimeImports,b as scanScriptTags,l as rewriteStxImportSpecifiers,j as processSignals,h as processScriptSetup,f as preEvalLiteralReactiveIfs,c as parseLoopExpression,d as hasSignalsSyntax,k as findMarkupIndexOutsideScripts,i as extractExports,g as convertSignalLoopsToAttributes,e as convertSignalDirectivesToAttributes,a as clearScriptScanCache};
|
package/dist/chunk-7ngmxv4z.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Tw as z}from"./chunk-myyj9qp3.js";var Yq={1001:{message:"Unclosed directive: {{directive}}",help:"Make sure to close the directive with the appropriate end tag"},1002:{message:"Unclosed expression at position {{position}}",help:"Check for missing closing braces }}"},1003:{message:"Invalid directive syntax: {{directive}}",help:"Review the directive documentation for correct syntax"},1004:{message:"Malformed expression: {{expression}}",help:"Check for syntax errors in your expression"},1005:{message:"Unexpected token: {{token}}",help:"Remove or fix the unexpected token"},1101:{message:"Undefined variable: {{variable}}",help:"Make sure the variable is defined in the template context"},1102:{message:"Type error: {{details}}",help:"Check that you are using the correct types"},1103:{message:"Evaluation error: {{details}}",help:"Review the expression for errors"},1104:{message:"Infinite loop detected in {{location}}",help:"Check your loop conditions"},1105:{message:"Circular reference detected: {{path}}",help:"Remove the circular dependency"},1201:{message:"Unsafe expression blocked: {{expression}}",help:"This expression contains potentially dangerous code"},1202:{message:"Path traversal attempt blocked: {{path}}",help:"Use only relative paths within allowed directories"},1203:{message:"Potential XSS attempt blocked",help:"Sanitize user input before rendering"},1204:{message:"Code injection attempt blocked: {{code}}",help:"Avoid executing dynamic code"},1205:{message:"Prohibited DOM API usage: {{api}}",help:"Use STX.useRefs(), STX.useRef(), STX.el() and other STX helpers instead of direct DOM manipulation"},1301:{message:"File not found: {{path}}",help:"Check that the file exists and the path is correct"},1302:{message:"Error reading file: {{path}}",help:"Check file permissions and encoding"},1303:{message:"Invalid file path: {{path}}",help:"Use a valid file path"},1304:{message:"Permission denied: {{path}}",help:"Check file permissions"},1401:{message:"Invalid configuration: {{details}}",help:"Review your stx.config.ts file"},1402:{message:"Missing required configuration: {{key}}",help:"Add the required configuration option"},1403:{message:"Deprecated configuration: {{key}}",help:"Update to the new configuration format"},1501:{message:"Component not found: {{name}}",help:"Check that the component exists in your components directory"},1502:{message:"Invalid props for component {{name}}: {{details}}",help:"Check the component prop requirements"},1503:{message:"Error rendering component {{name}}: {{details}}",help:"Check the component template for errors"},1601:{message:"Filter not found: {{filter}}",help:"Register the filter or check the filter name"},1602:{message:"Invalid arguments for filter {{filter}}: {{details}}",help:"Check the filter documentation for correct arguments"},1603:{message:"Expression evaluation timed out",help:"Simplify the expression or increase the timeout"}},N={},u="en";function Gq(q){u=q}function Bq(){return u}function Hq(q){N={...N,...q}}function wq(){N={}}function f(q,V={}){let J=N[q]||Yq[q]||{message:`Unknown error (code: ${q})`},Q=J.message,Z=J.help;for(let[$,Y]of Object.entries(V)){let X=`{{${$}}}`;if(Q=Q.replace(new RegExp(X,"g"),Y),Z)Z=Z.replace(new RegExp(X,"g"),Y)}return{message:Q,help:Z}}function Wq(q,V={}){let{message:J,help:Q}=f(q,V);return Q?`${J}
|
|
3
|
-
Help: ${Q}`:J}var D={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603};function S(q){for(let[V,J]of Object.entries(D))if(J===q)return V;return}function Mq(){let{NODE_ENV:q}=process.env;return q==="production"}function K(){let{STX_DEBUG:q}=process.env;return!Mq()||q==="true"}function aq(){let{NODE_ENV:q}=process.env;return q==="test"}import Dq from"path";var x={showRelativePaths:!1,enableAutoRecovery:K(),logRecoveryWarnings:!0},j={...x};function Iq(q){j={...j,...q}}function T(){return{...j}}function Fq(){j={...x}}function _(q){if(!j.showRelativePaths||!q)return q;let V=j.baseDir||process.cwd();try{let J=Dq.relative(V,q);return J.startsWith("..")?q:J}catch{return q}}class O extends Error{code;filePath;line;column;context;numericCode;constructor(q,V,J,Q,Z,$,Y){super(q);this.code=V;this.filePath=J;this.line=Q;this.column=Z;this.context=$;if(this.name="StxError",this.numericCode=Y||D.EVALUATION_ERROR,this.filePath)this.filePath=_(this.filePath)}}class c extends O{constructor(q,V,J,Q,Z,$){super(q,"stx_SYNTAX_ERROR",V,J,Q,Z,$||D.INVALID_DIRECTIVE_SYNTAX);this.name="StxSyntaxError"}}class m extends O{constructor(q,V,J,Q,Z,$){super(q,"stx_RUNTIME_ERROR",V,J,Q,Z,$||D.EVALUATION_ERROR);this.name="StxRuntimeError"}}class d extends O{constructor(q,V,J,Q,Z,$){super(q,"stx_SECURITY_ERROR",V,J,Q,Z,$||D.UNSAFE_EXPRESSION);this.name="StxSecurityError"}}class p extends O{constructor(q,V,J,Q,Z,$){super(q,"stx_FILE_ERROR",V,J,Q,Z,$||D.FILE_NOT_FOUND);this.name="StxFileError"}}class l extends O{isFatal=!0;constructor(q,V,J,Q,Z,$){super(q,"stx_VALIDATION_ERROR",V,J,Q,Z,$||D.DOM_API_VIOLATION);this.name="StxValidationError"}}function h(q){let{type:V,message:J,code:Q,filePath:Z,line:$,column:Y,template:X,offset:B,snippet:G,suggestion:H,format:w="text"}=q,W=$,M=Y;if(!W&&X&&B!==void 0){let E=o(X,B);W=E.line,M=E.column}let F=Z?_(Z):void 0,Xq=Q?S(Q):void 0,U={type:V,code:Q,codeName:Xq,message:J,filePath:F,line:W,column:M,snippet:G,suggestion:H,timestamp:new Date().toISOString()},k;switch(w){case"html":k=jq(U);break;case"json":k=JSON.stringify(U,null,2);break;case"console":k=Uq(U,X,B);break;case"text":default:k=Oq(U,X,B);break}return{formatted:k,data:U}}function Oq(q,V,J){let Q=[],Z=q.code?` [${q.codeName||q.code}]`:"";if(Q.push(`[${q.type} Error${Z}]`),q.filePath){let $=q.filePath;if(q.line){if($+=`:${q.line}`,q.column)$+=`:${q.column}`}Q.push(`at ${$}`)}if(Q.push(`
|
|
4
|
-
${q.message}`),V&&q.line){let $=kq(V,q.line,2);if($)Q.push(`
|
|
5
|
-
${$}`)}if(q.snippet)Q.push(`
|
|
6
|
-
Snippet: ${q.snippet}`);if(q.suggestion)Q.push(`
|
|
7
|
-
Suggestion: ${q.suggestion}`);return Q.join(" ")}function jq(q){let V=q.code?` [${q.code}]`:"",J=q.filePath?` in ${q.filePath}${q.line?`:${q.line}`:""}`:"",Q=`<!-- [${q.type} Error${V}]${J}: ${s(q.message)}`;if(q.suggestion)Q+=` | Suggestion: ${s(q.suggestion)}`;return Q+=" -->",Q}function Uq(q,V,J){let G=[],H=q.code?` [${q.codeName||q.code}]`:"";if(G.push(`\x1B[1m${"\x1B[31m"}\u2501\u2501\u2501 ${q.type} Error${H} \u2501\u2501\u2501${"\x1B[0m"}`),q.filePath){let w=`\x1B[36m${q.filePath}\x1B[0m`;if(q.line){if(w+=`\x1B[90m:${q.line}\x1B[0m`,q.column)w+=`\x1B[90m:${q.column}\x1B[0m`}G.push(`
|
|
8
|
-
\x1B[90mat\x1B[0m ${w}`)}if(G.push(`
|
|
9
|
-
|
|
10
|
-
${q.message}`),V&&q.line){let w=Kq(V,q.line,2);if(w)G.push(`
|
|
11
|
-
|
|
12
|
-
\x1B[90mContext:\x1B[0m
|
|
13
|
-
${w}`)}if(q.suggestion)G.push(`
|
|
14
|
-
|
|
15
|
-
\x1B[33mSuggestion:\x1B[0m ${q.suggestion}`);return G.push(`
|
|
16
|
-
${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501${"\x1B[0m"}`),G.join("")}function kq(q,V,J){let Q=q.split(`
|
|
17
|
-
`),Z=Math.max(0,V-J-1),$=Math.min(Q.length-1,V+J-1),Y=[];for(let X=Z;X<=$;X++){let B=(X+1).toString().padStart(4),G=X===V-1?">":" ";Y.push(`${G}${B} | ${Q[X]}`)}return Y.join(`
|
|
18
|
-
`)}function Kq(q,V,J){let Q=q.split(`
|
|
19
|
-
`),Z=Math.max(0,V-J-1),$=Math.min(Q.length-1,V+J-1),Y="\x1B[90m",X="\x1B[31m",B="\x1B[0m",G=[];for(let H=Z;H<=$;H++){let w=(H+1).toString().padStart(4),W=H===V-1,M=W?"\x1B[31m>\x1B[0m":" ",F=W?`\x1B[31m${Q[H]}\x1B[0m`:`\x1B[90m${Q[H]}\x1B[0m`;G.push(`${M}\x1B[90m${w}\x1B[0m | ${F}`)}return G.join(`
|
|
20
|
-
`)}function s(q){return q.replace(/--/g,"- -").replace(/>/g,">")}function o(q,V){let Q=q.substring(0,V).split(`
|
|
21
|
-
`);return{line:Q.length,column:Q[Q.length-1].length}}function zq(q,V,J){return h({type:q,message:V,code:J,format:"html"}).formatted}function Nq(q,V,J,Q,Z){return h({type:q,message:V,code:Z,filePath:J,line:Q,format:"console"}).formatted}function Tq(q,V,J){let Q=J.template.split(`
|
|
22
|
-
`),Z=o(J.template,J.offset),$=`[${q} Error at line ${Z.line} in ${J.filePath}]: ${V}
|
|
23
|
-
|
|
24
|
-
`,Y=Math.max(0,Z.line-3),X=Math.min(Q.length-1,Z.line+2);$+=`Context:
|
|
25
|
-
`;for(let B=Y;B<=X;B++){let G=B+1,H=Q[B]||"",w=B===Z.line-1?">":" ";$+=`${w} ${G.toString().padStart(3)}: ${H}
|
|
26
|
-
`}if(Z.line-1<Q.length){let B=" ".repeat(Z.column+5);$+=`${B}^
|
|
27
|
-
`}return $}function _q(q,V,J){try{return q()}catch(Q){if(J&&Q instanceof Error)J(Q);return V}}async function Lq(q,V,J){try{return await q()}catch(Q){if(J&&Q instanceof Error)J(Q);return V}}var bq={isEnabled(){return T().enableAutoRecovery},fixCommonSyntaxErrors(q){let V=T();if(!V.enableAutoRecovery)return{fixed:q,fixes:[]};let J=q,Q=[],Z=(J.match(/\{\{/g)||[]).length,$=(J.match(/\}\}/g)||[]).length;if(Z>$){let X=Z-$;J+="}}".repeat(X),Q.push(`Added ${X} missing closing braces '}}'`)}let Y=["if","foreach","for","switch","section"];for(let X of Y){let B=(J.match(new RegExp(`@${X}\\b`,"g"))||[]).length,G=(J.match(new RegExp(`@end${X}\\b`,"g"))||[]).length;if(B>G){let H=B-G;for(let w=0;w<H;w++)J+=`
|
|
28
|
-
@end${X}`;Q.push(`Added ${H} missing @end${X}`)}}if(Q.length>0&&V.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),Q.forEach((X)=>console.warn(` - ${X}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:J,fixes:Q}},createFallbackContent(q,V){if(K())return`<!-- ${q} failed: ${V.message} -->`;return"<!-- stx rendering error -->"}};class v{errors=[];maxErrors;enableFileLogging;logFilePath;logFormat;maxFileSize;maxLogFiles;minLevel;writeQueue=Promise.resolve();constructor(q={}){this.maxErrors=q.maxErrors??1000,this.enableFileLogging=q.enableFileLogging??!1,this.logFilePath=q.logFilePath??".stx/errors.log",this.logFormat=q.logFormat??"json",this.maxFileSize=q.maxFileSize??10485760,this.maxLogFiles=q.maxLogFiles??5,this.minLevel=q.minLevel??"all"}configure(q){if(q.maxErrors!==void 0)this.maxErrors=q.maxErrors;if(q.enableFileLogging!==void 0)this.enableFileLogging=q.enableFileLogging;if(q.logFilePath!==void 0)this.logFilePath=q.logFilePath;if(q.logFormat!==void 0)this.logFormat=q.logFormat;if(q.maxFileSize!==void 0)this.maxFileSize=q.maxFileSize;if(q.maxLogFiles!==void 0)this.maxLogFiles=q.maxLogFiles;if(q.minLevel!==void 0)this.minLevel=q.minLevel}log(q,V,J="error"){let Q={timestamp:new Date,error:q,context:V,level:J};if(this.errors.push(Q),this.errors.length>this.maxErrors)this.errors=this.errors.slice(-this.maxErrors);if(this.enableFileLogging&&this.shouldLog(J))this.writeToFile(Q)}shouldLog(q){if(this.minLevel==="all")return!0;if(this.minLevel==="warning")return q==="error"||q==="warning";if(this.minLevel==="error")return q==="error";return!0}formatEntry(q){if(this.logFormat==="json")return JSON.stringify({timestamp:q.timestamp.toISOString(),level:q.level||"error",type:q.error.constructor.name,message:q.error.message,stack:q.error.stack,context:q.context});let V=[`[${q.timestamp.toISOString()}] [${(q.level||"error").toUpperCase()}] ${q.error.constructor.name}: ${q.error.message}`];if(q.error.stack)V.push(` Stack: ${q.error.stack.split(`
|
|
29
|
-
`).slice(1).join(`
|
|
30
|
-
`)}`);if(q.context)V.push(` Context: ${JSON.stringify(q.context)}`);return V.join(`
|
|
31
|
-
`)}writeToFile(q){this.writeQueue=this.writeQueue.then(async()=>{try{let V=await import("fs"),Q=(await import("path")).dirname(this.logFilePath);if(!V.existsSync(Q))V.mkdirSync(Q,{recursive:!0});await this.rotateIfNeeded(V);let Z=`${this.formatEntry(q)}
|
|
32
|
-
`;V.appendFileSync(this.logFilePath,Z,"utf-8")}catch(V){if(process.env.STX_DEBUG==="true")console.error("Failed to write to error log:",V)}})}async rotateIfNeeded(q){try{if(!q.existsSync(this.logFilePath))return;if(q.statSync(this.logFilePath).size<this.maxFileSize)return;for(let J=this.maxLogFiles-1;J>=1;J--){let Q=`${this.logFilePath}.${J}`,Z=`${this.logFilePath}.${J+1}`;if(q.existsSync(Q))if(J>=this.maxLogFiles-1)q.unlinkSync(Q);else q.renameSync(Q,Z)}if(this.maxLogFiles<=1)q.writeFileSync(this.logFilePath,"");else q.renameSync(this.logFilePath,`${this.logFilePath}.1`)}catch(V){if(process.env.STX_DEBUG==="true")console.error("Failed to rotate error logs:",V)}}getRecentErrors(q=10){return this.errors.slice(-q)}getErrorsByType(q){return this.errors.filter((V)=>V.error.constructor.name===q)}getErrorsByLevel(q){return this.errors.filter((V)=>V.level===q)}clear(){this.errors.length=0}async clearLogFile(){try{let q=await import("fs");if(q.existsSync(this.logFilePath))q.writeFileSync(this.logFilePath,"","utf-8")}catch(q){if(process.env.STX_DEBUG==="true")console.error("Failed to clear error log:",q)}}getStats(){let q={},V={error:0,warning:0,info:0};for(let J of this.errors){let Q=J.error.constructor.name;q[Q]=(q[Q]||0)+1;let Z=J.level||"error";V[Z]=(V[Z]||0)+1}return{total:this.errors.length,byType:q,byLevel:V}}async exportToFile(q,V="json"){let J=await import("fs"),Z=(await import("path")).dirname(q);if(!J.existsSync(Z))J.mkdirSync(Z,{recursive:!0});if(V==="json"){let $=this.errors.map((Y)=>({timestamp:Y.timestamp.toISOString(),level:Y.level||"error",type:Y.error.constructor.name,message:Y.error.message,stack:Y.error.stack,context:Y.context}));J.writeFileSync(q,JSON.stringify($,null,2),"utf-8")}else{let $=this.errors.map((Y)=>this.formatEntry(Y));J.writeFileSync(q,$.join(`
|
|
33
|
-
|
|
34
|
-
`),"utf-8")}}async flush(){await this.writeQueue}}var Aq=new v,Rq={isDevelopment(){return K()},logDetailedError(q,V){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",q.message),console.error("Stack:",q.stack),V)console.error("Context:",V);console.error("========================")},createErrorReport(q,V){let J=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${q.message}`,`Type: ${q.constructor.name}`,`Stack: ${q.stack}`];if(V)J.push(`Context: ${JSON.stringify(V,null,2)}`);return J.push("========================"),J.join(`
|
|
35
|
-
`)}};import g from"path";var P={isValidFilePath(q,V){let J=q.replace(/\\/g,"/");if(J.includes("\x00"))return!1;if(J.includes("../")||J.includes("..\\")||J===".."||J.startsWith("../")||J.endsWith("/..")||J.includes("/..\\")||J.includes("\\../"))return!1;if(/^[a-z][a-z0-9+.-]*:/i.test(J))return!1;if(J.startsWith("/")){if(["/etc/","/root/","/var/","/usr/","/bin/","/sbin/","/proc/","/sys/","/dev/","/boot/","/home/","/private/","/Library/","/System/"].some(($)=>J===$.slice(0,-1)||J.startsWith($)))return!1}if(/^[a-z]:/i.test(J)){if(["Windows/","Windows\\","System32/","System32\\","Program Files/","Program Files\\"].some(($)=>J.includes($)))return!1}if(V){let Z=g.resolve(V,q),$=g.resolve(V);if(!Z.startsWith($+g.sep)&&Z!==$)return!1}return!0},isValidVariableName(q){return/^[a-z_$]\w*$/i.test(q)},isValidDirectiveName(q){return/^[a-z][\w-]*$/i.test(q)},isSafeContent(q){return![/<script[^>]*>[\s\S]*?<\/script>/i,/javascript:/i,/data:text\/html/i,/vbscript:/i,/on\w+\s*=/i].some((J)=>J.test(q))}};function Sq(q){let V={"&":"&","<":"<",">":">",'"':""","'":"'"};return q.replace(/[&<>"']/g,(J)=>V[J]||J)}function L(q,V={}){let{allowHtml:J=!1,maxLength:Q=1e4,allowSpecialChars:Z=!0,customSanitizer:$}=V,Y=[],X=q,B=!1;if($){let H=$(X);if(H!==X)X=H,B=!0}if(X.includes("\x00"))X=X.replace(/\0/g,""),B=!0,Y.push("Null bytes removed from parameter");if(X.length>Q)X=X.substring(0,Q),B=!0,Y.push(`Parameter truncated to ${Q} characters`);if(!J&&/<[^>]+>/.test(X))X=Sq(X),B=!0,Y.push("HTML content was escaped");let G=[{pattern:/javascript:/gi,replacement:"",name:"javascript: URI"},{pattern:/vbscript:/gi,replacement:"",name:"vbscript: URI"},{pattern:/data:text\/html/gi,replacement:"",name:"data:text/html URI"}];for(let{pattern:H,replacement:w,name:W}of G)if(H.test(X))X=X.replace(H,w),B=!0,Y.push(`Removed ${W} from parameter`);if(!Z){let H=X;if(X=X.split("").filter((w)=>{let W=w.charCodeAt(0);return W>=32&&W!==127}).join(""),X!==H)B=!0,Y.push("Control characters removed")}return{value:X,modified:B,warnings:Y}}function hq(q,V){let J=q.replace(/\0/g,"");J=J.replace(/\\/g,"/"),J=J.replace(/^[a-z][a-z0-9+.-]*:/i,"");while(J.includes("../")||J.includes("./"))J=J.replace(/\.\.\//g,"").replace(/\.\//g,"");if(!P.isValidFilePath(J,V))return null;return J}function vq(q){let V=[],J=q.trim(),Q=J!==q,Z=[{pattern:/\beval\s*\(/gi,name:"eval()"},{pattern:/\bFunction\s*\(/gi,name:"Function()"},{pattern:/\bsetTimeout\s*\(/gi,name:"setTimeout()"},{pattern:/\bsetInterval\s*\(/gi,name:"setInterval()"},{pattern:/\bimport\s*\(/gi,name:"dynamic import()"},{pattern:/\brequire\s*\(/gi,name:"require()"},{pattern:/\b__proto__\b/gi,name:"__proto__"},{pattern:/\bconstructor\b/gi,name:"constructor"},{pattern:/\bprototype\b/gi,name:"prototype"}];for(let{pattern:$,name:Y}of Z)if($.test(J))V.push(`Potentially dangerous pattern detected: ${Y}`);if(J.includes("\x00"))J=J.replace(/\0/g,""),Q=!0,V.push("Null bytes removed from expression");return{value:J,modified:Q,warnings:V}}function gq(q,V={}){return q.map((J)=>L(J,V))}function r(q){let V={};for(let[J,Q]of Object.entries(q)){if(!P.isValidVariableName(J))continue;if(typeof Q==="string"){let Z=L(Q);V[J]=Z.value}else if(Array.isArray(Q))V[J]=Q.map((Z)=>typeof Z==="string"?L(Z).value:Z);else if(typeof Q==="object"&&Q!==null)V[J]=r(Q);else V[J]=Q}return V}var Pq={maxSanitizeDepth:10,allowBracketNotation:!1},e={...Pq};var A=/\bnew\s+/,R="__stx_safe_ctors",qq=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,A,/\bdelete\s+/,/\bthis\b/],Cq=new Set(["eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this",R]),Vq=new Set(["__proto__","constructor","prototype"]),yq=/[\w)\]]\s*\[\s*['"]/;function Jq(q){let V="",J=[],Q=null,Z=!1;for(let $=0;$<q.length;$++){let Y=q[$];if(Z){Z=!1;continue}if(Y==="\\"&&Q){Z=!0;continue}if(Q){if(Q==="`"&&Y==="$"&&$+1<q.length&&q[$+1]==="{"){let X=1;$+=2;while($<q.length&&X>0){if(q[$]==="{")X++;else if(q[$]==="}")X--;if(X>0)V+=q[$],J.push($),$++}continue}if(Y===Q)Q=null;continue}if(Y==='"'||Y==="'"||Y==="`"){Q=Y;continue}V+=Y,J.push($)}return{text:V,map:J}}function Eq(q){return Jq(q).text}var Qq=["Collator","DateTimeFormat","DisplayNames","ListFormat","Locale","NumberFormat","PluralRules","RelativeTimeFormat","Segmenter"],Zq=(()=>{let q={Date,URL,URLSearchParams},V=Intl;for(let J of Qq)if(typeof V[J]==="function")q[`Intl_${J}`]=V[J];return Object.freeze(Object.assign(Object.create(null),q))})(),uq=/^new(\s+)(Date|URLSearchParams|URL|Intl\s*\.\s*([A-Z_a-z]\w*))\s*\(/,n=/(?<![\w$])new(?![\w$])/g,i=`only new Date(), new URL(), new URLSearchParams() and new Intl.{${Qq.join(",")}}() are allowed`;function fq(q){let{text:V,map:J}=Jq(q),Q=[];n.lastIndex=0;let Z;while((Z=n.exec(V))!==null){let Y=Z.index;if(/(?<!\.)\.\s*$/.test(V.slice(0,Y)))continue;let X=uq.exec(V.slice(Y)),B=X?.[3],G=!X?null:B?`Intl_${B}`:X[2];if(!X||!G||!(G in Zq))throw new I(`matched /${A.source}/; ${i}`,q);let H=Y+X[0].length,w=J[Y],W=J[H-1]+1;if(q.slice(w,W)!==V.slice(Y,H))throw new I(`matched /${A.source}/; ${i}`,q);let M=w+3+X[1].length;Q.push({start:M,end:M+X[2].length,key:G})}let $=q;for(let Y=Q.length-1;Y>=0;Y--){let X=Q[Y];$=`${$.slice(0,X.start)}${R}.${X.key}${$.slice(X.end)}`}return{source:$,usesSafeConstructors:Q.length>0}}class I extends Error{rule;expression;constructor(q,V,J){super(J??`Potentially unsafe expression (${q}): ${V}`);this.name="UnsafeExpressionError",this.rule=q,this.expression=V}}function UV(q){try{return y(q),null}catch(V){return V instanceof I?V.rule:V instanceof Error?V.message:String(V)}}function xq(q,V){let J=/[$A-Z_a-z][$\w]*/g,Q;while((Q=J.exec(q))!==null){let Z=Q[0],$=q[Q.index-1];if(Cq.has(Z))throw new I(`matched /\\b${Z}\\b/; identifier ${Z}`,V);if($==="."&&Vq.has(Z))throw new I(`matched /.${Z}/; property ${Z}`,V)}}function cq(q){let V=/\[\s*(['"])(.*?)\1\s*\]/g,J;while((J=V.exec(q))!==null){let Q=J[2];if(!Vq.has(Q))continue;let Z=q.slice(0,J.index).match(/\S(?=\s*$)/)?.[0],$=q.slice(J.index+J[0].length).match(/^\s*(\S)/)?.[1];if(!((Z==="{"||Z===",")&&$===":"))throw new I(`bracket key ${J[2]}`,q)}}function y(q){let V=q.trim(),J=Eq(V);xq(J,V),cq(V);for(let Q of qq){if(Q===A)continue;if(Q.test(J))throw new I(`matched /${Q.source}/`,V)}if(!e.allowBracketNotation&&yq.test(V))throw new I("bracket notation with a string key; enable with configureSafeEvaluator({ allowBracketNotation: true })",V,`Bracket notation with strings not allowed: ${V}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);return fq(V)}function mq(q){return y(q),q.trim()}function dq(q){let V={};V.Math=Math,V.JSON=JSON,V.Date=Date,V.String=String,V.Number=Number,V.Boolean=Boolean,V.Array=Array,V.parseInt=Number.parseInt,V.parseFloat=Number.parseFloat,V.isNaN=Number.isNaN,V.isFinite=Number.isFinite,V.encodeURIComponent=encodeURIComponent,V.decodeURIComponent=decodeURIComponent;for(let[J,Q]of Object.entries(q)){if(J.startsWith("__")||qq.some((Z)=>Z.test(J)))continue;if(Q&&typeof Q==="object"&&!Array.isArray(Q))V[J]=C(Q);else V[J]=Q}return V}function C(q,V=0){if(V>=e.maxSanitizeDepth)return"[Object too deep]";if(q===null||typeof q!=="object")return q;if(Array.isArray(q))return q.map((Q)=>C(Q,V+1));if(q instanceof Date||q instanceof RegExp||q instanceof Map||q instanceof Set||q instanceof Error)return q;let J={};for(let[Q,Z]of Object.entries(q)){if(Q.startsWith("__")||Q==="constructor"||Q==="prototype")continue;if(Z&&typeof Z==="object")J[Q]=C(Z,V+1);else J[Q]=Z}return J}function pq(q,V){try{let J=dq(V),Q=Object.keys(J),Z=Object.values(J);return rq(q,Q)(...Z)}catch{return}}function kV(q){try{return mq(q),!0}catch{return!1}}function KV(q,V){try{let J=pq(q,V);if(J&&typeof J==="object"&&!Array.isArray(J))return J;return{}}catch{return{}}}var $q=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"]),lq=2000,b=new Map;function a(q,V){let J=`${q.join(",")}\x00${V}`,Q=b.get(J);if(Q)return Q;let Z=Function(...q,V);if(b.size>=lq)b.clear();return b.set(J,Z),Z}function zV(q){return q.replace(/'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|`(?:[^`\\]|\\.)*`/g," ").replace(/\??\.\s*[a-zA-Z_$][\w$]*/g," ").replace(/([{,]\s*)[a-zA-Z_$][\w$]*(\s*:)/g,"$1$2").match(/\b[a-zA-Z_$][\w$]*\b/g)||[]}var sq=/^[A-Za-z_$][\w$]*$/;function oq(q){return sq.test(q)&&!$q.has(q)}function rq(q,V){let{source:J,usesSafeConstructors:Q}=y(q),Z=[];for(let G=0;G<V.length;G++){if(!oq(V[G]))continue;if(V[G]===R)continue;Z.push({key:V[G],index:G})}Z.sort((G,H)=>G.key.localeCompare(H.key));let $=Z.map((G)=>G.key),Y=Z.map((G)=>G.index),X=`
|
|
36
|
-
'use strict';
|
|
37
|
-
try {
|
|
38
|
-
return ${J};
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
if (e instanceof TypeError) {
|
|
42
|
-
return undefined;
|
|
43
|
-
}
|
|
44
|
-
throw e;
|
|
45
|
-
}
|
|
46
|
-
`;return nq(Q?(G)=>{let H=a([R,...$,...G],X);return(...w)=>H(Zq,...w)}:(G)=>a([...$,...G],X),$,V,Z,Y)}function nq(q,V,J,Q,Z){let $=q([]),Y=Q.every((B,G)=>B.index===G);if(V.length===J.length&&Y)return t($,V,q);return t((...B)=>{let G=Array(Z.length);for(let H=0;H<Z.length;H++)G[H]=B[Z[H]];return $(...G)},V,q,(B)=>{$=q(B)})}function t(q,V,J,Q){let $=/^(\w+) is not defined$/,Y=q,X=[],B=new Set(V);return(...G)=>{for(let H=0;H<=8;H++)try{return Y(...G)}catch(w){let W=w instanceof Error?w.message:"",M=$.exec(W);if(!(w instanceof ReferenceError)||!M)return;let F=M[1];if(B.has(F)||$q.has(F))return;if(B.add(F),X.push(F),Q)Q(X);else Y=J(X)}return}}function NV(q){let V=q.trim(),J=[/\beval\s*\(/i,/\bFunction\s*\(/i,/\bimport\s*\(/i,/\brequire\s*\(/i,/\bprocess\b/i,/\b__proto__\b/i,/\bconstructor\s*[.(]/i,/\bglobalThis\b/i,/\bwindow\b/i,/\bdocument\b/i,/\bfetch\s*\(/i,/\bBun\b/i,/\bDeno\b/i,/\bconsole\b/i,/\bthis\b/i,/\bReflect\b/i,/\bProxy\b/i,/\bprototype\b/i,/\.(bind|call|apply)\s*\(/i];for(let Q of J)if(Q.test(V))return!1;return!0}
|
|
47
|
-
export{Gq as Du,Bq as Eu,Hq as Fu,wq as Gu,f as Hu,Wq as Iu,D as Ju,S as Ku,Mq as Lu,K as Mu,aq as Nu,Iq as Ou,T as Pu,Fq as Qu,_ as Ru,O as Su,c as Tu,m as Uu,d as Vu,p as Wu,l as Xu,h as Yu,zq as Zu,Nq as _u,Tq as $u,_q as av,Lq as bv,bq as cv,v as dv,Aq as ev,Rq as fv,P as gv,L as hv,hq as iv,vq as jv,gq as kv,r as lv,UV as mv,mq as nv,dq as ov,pq as pv,kV as qv,KV as rv,zV as sv,oq as tv,rq as uv,NV as vv};
|
package/dist/chunk-8nxdktsm.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Ue as a}from"./chunk-j19ep0nb.js";import"./chunk-yz2yk0p1.js";import"./chunk-nh6p0k17.js";import"./chunk-49trnqad.js";import"./chunk-c0vjhzjf.js";import"./chunk-vjn3r3sq.js";import"./chunk-cbj5a2tk.js";import"./chunk-05c62pqd.js";import"./chunk-2zbmyvqc.js";import"./chunk-sjpjge04.js";import"./chunk-0380epk7.js";import"./chunk-k6bagvmz.js";import"./chunk-zhzcahz5.js";import"./chunk-8kwmj99g.js";import"./chunk-7ngmxv4z.js";import"./chunk-s3tpyage.js";import"./chunk-2sa8rk32.js";import"./chunk-x8t29tnr.js";import"./chunk-0xh7vqce.js";import"./chunk-wqa77pdn.js";import"./chunk-myyj9qp3.js";export{a as startInteractive};
|
package/dist/chunk-93f8avhm.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Ar as e,Br as f,wr as a,xr as b,yr as c,zr as d}from"./chunk-yz2yk0p1.js";import"./chunk-nh6p0k17.js";import"./chunk-49trnqad.js";import"./chunk-c0vjhzjf.js";import"./chunk-vjn3r3sq.js";import"./chunk-cbj5a2tk.js";import"./chunk-05c62pqd.js";import"./chunk-2zbmyvqc.js";import"./chunk-sjpjge04.js";import"./chunk-0380epk7.js";import"./chunk-k6bagvmz.js";import"./chunk-zhzcahz5.js";import"./chunk-8kwmj99g.js";import"./chunk-7ngmxv4z.js";import"./chunk-s3tpyage.js";import"./chunk-2sa8rk32.js";import"./chunk-x8t29tnr.js";import"./chunk-0xh7vqce.js";import"./chunk-wqa77pdn.js";import"./chunk-myyj9qp3.js";export{f as validateConfig,b as resolveStxDirectories,c as loadStxConfig,e as defineStxConfig,a as defaultConfig,d as config};
|
package/dist/chunk-ctkz8peg.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{$p as e,Jo as a,Lo as b,No as c,Oo as d,aq as f,bq as g,cq as h,dq as i,eq as j,fq as k,gq as l,hq as m,iq as n,jq as o,kq as p,lq as q,mq as r,nq as s,oq as t,pq as u,qq as v,rq as w,sq as x,tq as y}from"./chunk-yz2yk0p1.js";import"./chunk-nh6p0k17.js";import"./chunk-49trnqad.js";import"./chunk-c0vjhzjf.js";import"./chunk-vjn3r3sq.js";import"./chunk-cbj5a2tk.js";import"./chunk-05c62pqd.js";import"./chunk-2zbmyvqc.js";import"./chunk-sjpjge04.js";import"./chunk-0380epk7.js";import"./chunk-k6bagvmz.js";import"./chunk-zhzcahz5.js";import"./chunk-8kwmj99g.js";import"./chunk-7ngmxv4z.js";import"./chunk-s3tpyage.js";import"./chunk-2sa8rk32.js";import"./chunk-x8t29tnr.js";import"./chunk-0xh7vqce.js";import"./chunk-wqa77pdn.js";import"./chunk-myyj9qp3.js";export{e as validateTemplate,g as validateDirective,o as userComponentFileExists,m as transpileTypeScript,q as slotContentHasExpressions,k as shouldTranspileTypeScript,n as scopeOnRootElement,u as resolveTemplatePath,s as renderComponentWithSlot,j as isJavaScriptScript,p as isHydrateTrigger,d as hasVariables,h as hasDirectives,v as getSourceLineInfo,l as getSharedTranspiler,f as getPositionInfo,y as getComponentCacheStats,t as fileExists,a as extractVariables,c as extractScriptFromTemplate,i as extractDirectiveNames,w as createDetailedErrorMessage,b as convertToCommonJS,r as componentClientSignalNames,x as clearComponentCache};
|
package/dist/chunk-dvc615rq.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{Ii as a,Ji as b}from"./chunk-836z41ss.js";import"./chunk-ra1s4s6b.js";import"./chunk-9n88pgdr.js";import"./chunk-geztv535.js";import"./chunk-qjvny3wf.js";import"./chunk-yz2yk0p1.js";import"./chunk-nh6p0k17.js";import"./chunk-49trnqad.js";import"./chunk-c0vjhzjf.js";import"./chunk-vjn3r3sq.js";import"./chunk-cbj5a2tk.js";import"./chunk-05c62pqd.js";import"./chunk-2zbmyvqc.js";import"./chunk-sjpjge04.js";import"./chunk-0380epk7.js";import"./chunk-k6bagvmz.js";import"./chunk-zhzcahz5.js";import"./chunk-8kwmj99g.js";import"./chunk-7ngmxv4z.js";import"./chunk-s3tpyage.js";import"./chunk-2sa8rk32.js";import"./chunk-x8t29tnr.js";import"./chunk-0xh7vqce.js";import"./chunk-wqa77pdn.js";import"./chunk-myyj9qp3.js";export{a as getStoreScript,b as clearStoreCache};
|
package/dist/chunk-e854gjy9.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{To as a,Uo as b,Vo as c,Wo as d,Xo as e,Yo as f,Zo as g}from"./chunk-yz2yk0p1.js";import"./chunk-nh6p0k17.js";import"./chunk-49trnqad.js";import"./chunk-c0vjhzjf.js";import"./chunk-vjn3r3sq.js";import"./chunk-cbj5a2tk.js";import"./chunk-05c62pqd.js";import"./chunk-2zbmyvqc.js";import"./chunk-sjpjge04.js";import"./chunk-0380epk7.js";import"./chunk-k6bagvmz.js";import"./chunk-zhzcahz5.js";import"./chunk-8kwmj99g.js";import"./chunk-7ngmxv4z.js";import"./chunk-s3tpyage.js";import"./chunk-2sa8rk32.js";import"./chunk-x8t29tnr.js";import"./chunk-0xh7vqce.js";import"./chunk-wqa77pdn.js";import"./chunk-myyj9qp3.js";export{a as resetUnscopedSignalWarnings,g as processStackReplacements,f as processStackPushDirectives,e as processIncludes,b as partialsCache,c as onceStore,d as clearOnceStore};
|
package/dist/chunk-ev7q8enz.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{$m as c,Cm as P,Do as i,Fp as h,Jo as T,Lm as k,an as l,sm as R,tm as O}from"./chunk-yz2yk0p1.js";import{Qs as S,Ss as y}from"./chunk-05c62pqd.js";import{Mu as m}from"./chunk-7ngmxv4z.js";import{Fw as YJ,Iw as ZJ,Jw as $J}from"./chunk-0xh7vqce.js";import{Qw as XJ,Tw as q}from"./chunk-myyj9qp3.js";var r=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/;function s(J,Y,Q){let X={fullTag:Q,content:Y,attrs:J};if(/\bserver\b/.test(J))return{...X,type:"server"};if(/\bdata-stx-scoped\b/.test(J))return{...X,type:"client"};if(r.test(Y))return{...X,type:"signals"};if(/\bclient\b/.test(J)||/\btype\s*=\s*["']module["']/.test(J)||/\bsrc\s*=/.test(J))return{...X,type:"client"};return{...X,type:"server"}}var o=/^<script\b([^>]*)>([\s\S]*)<\/script\s*>$/i;function C(J){let Y=[],Q=[],X=[],$=0;while($<J.length){let Z=J.indexOf("<",$);if(Z===-1)break;let U=y(J,Z);if(U>Z){$=U;continue}let W=S(J,Z);if(W>Z){let j=J.slice(Z,W),F=o.exec(j);if(F){let K=s(F[1],F[2],j);switch(K.type){case"signals":Y.push(K);break;case"client":Q.push(K);break;case"server":X.push(K);break}}$=W;continue}$=Z+(J.startsWith("<!--",Z)?4:1)}return{signals:Y,client:Q,server:X}}var a=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);function t(J){let Y=[],Q=/<!--[\s\S]*?(?:-->|$)|<(script|style|textarea|title|template)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,X;while((X=Q.exec(J))!==null)Y.push({start:X.index,end:X.index+X[0].length});return Y}function v(J,Y){return Y.some((Q)=>J>=Q.start&&J<Q.end)}function e(J){let Y=(J||"").trim();if(!Y)return null;if(/[\s>+~,:]/.test(Y))return null;let Q={},X=Y,$=X.match(/^[a-z][\w-]*/i);if($)Q.tag=$[0].toLowerCase(),X=X.slice($[0].length);while(X.length>0){let Z=X.match(/^\[([\w-]+)(?:=(["']?)([^\]"']*)\2)?\]/);if(Z){if(Q.attr=Z[1],Z[3]!==void 0&&Z[3]!=="")Q.attrValue=Z[3];X=X.slice(Z[0].length);continue}let U=X.match(/^#([\w-]+)/);if(U){Q.id=U[1],X=X.slice(U[0].length);continue}let W=X.match(/^\.([\w-]+)/);if(W){Q.className=W[1],X=X.slice(W[0].length);continue}return null}if(!Q.tag&&!Q.attr&&!Q.id&&!Q.className)return null;return Q}function JJ(J,Y){if(Y.attr){if(!(Y.attrValue===void 0?new RegExp(`\\b${Y.attr}(?=[\\s=>/]|$)`,"i"):new RegExp(`\\b${Y.attr}\\s*=\\s*(["'])\\s*${Y.attrValue}\\s*\\1`,"i")).test(J))return!1}if(Y.id){if(!new RegExp(`\\bid\\s*=\\s*(["'])\\s*${Y.id}\\s*\\1`,"i").test(J))return!1}if(Y.className){let Q=J.match(/\bclass\s*=\s*(["'])([\s\S]*?)\1/i);if(!Q)return!1;if(!Q[2].split(/\s+/).includes(Y.className))return!1}return!0}function x(J,Y="main"){let Q=e(Y);if(!Q)return null;let X=/<([a-z][\w-]*)\b([^>]*)>/gi,$=t(J),Z;while((Z=X.exec(J))!==null){if(v(Z.index,$))continue;let U=Z[1].toLowerCase(),W=Z[2]||"";if(W.trimEnd().endsWith("/")||a.has(U))continue;if(Q.tag&&Q.tag!==U)continue;if(!JJ(W,Q))continue;let j=Z[0],F=Z.index+j.length,K=new RegExp(`<(/?)${U}\\b([^>]*)>`,"gi");K.lastIndex=F;let G=1,B;while((B=K.exec(J))!==null){if(v(B.index,$))continue;let w=B[1]==="/";if(!w&&(B[2]||"").trimEnd().endsWith("/"))continue;if(G+=w?-1:1,G===0)return{openTag:j,openIndex:Z.index,start:F,end:B.index,tagName:U}}return null}return null}var NJ="X-STX-Router",_J="private, no-store";function AJ(J){return J.replace(/&#(\d+);/g,(Y,Q)=>f(Number(Q),Y)).replace(/&#x([0-9a-f]+);/gi,(Y,Q)=>f(Number.parseInt(Q,16),Y)).replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/&/g,"&")}function f(J,Y){if(!Number.isInteger(J)||J<0||J>1114111)return Y;try{return String.fromCodePoint(J)}catch{return Y}}function g(J){return J.headers.get("X-STX-Router")==="true"}function QJ(J,Y){if(!J)return Y;return J.split(",").some((X)=>X.trim().toLowerCase()===Y.toLowerCase())?J:`${J}, ${Y}`}function IJ(J){return{Vary:QJ(J,"X-STX-Router")}}import E from"path";YJ();var UJ="stx-page-head:",WJ=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/,D={dev:null,prod:null};function jJ(){let J=m()?"dev":"prod",Y=D[J];if(Y!==null)return Y;try{let Q=($J(),XJ(ZJ)),X=J==="dev"&&typeof Q.getRouterScriptDev==="function"?Q.getRouterScriptDev:Q.getRouterScript;D[J]=`<script>${X()}</script>`}catch{D[J]=""}return D[J]}async function RJ(J,Y){if(Y===!1)return null;if(Y&&typeof Y==="string"){let X=E.resolve(J,Y);if(await Bun.file(X).exists())return X;return null}let Q=E.join(J,"app.stx");if(await Bun.file(Q).exists())return Q;return null}async function PJ(J,Y){try{let Q=await Bun.file(J).text(),X=Q,$=Q.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if($)X=$[1].trim();let Z=C(Q),U=[...Z.client.map((V)=>V.fullTag),...Z.signals.map((V)=>V.fullTag)],W=[],j=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,F;while((F=j.exec(Q))!==null)W.push(F[0]);let K=X;for(let V of Z.server)K=K.replace(V.fullTag,"");for(let V of Z.client)K=K.replace(V.fullTag,"");K=K.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let G="<!--__STX_PAGE_SLOT__-->";if(K=K.replace(/<slot\s*\/>/gi,G).replace(/<slot\s*>\s*<\/slot>/gi,G),!K.includes(G))return console.warn(`[stx] Shell ${J} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:B,extractVariables:w,defaultConfig:N,loadStxConfig:A}=await import("./chunk-jxcjp8f8.js"),I=await A(),z={__filename:J,__dirname:E.dirname(J)};for(let V of U){let L=V.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(L&&!V.includes("client")&&!V.includes('type="module"'))await w(L[1],z,J)}let _=await B(K,z,J,{...N,...I,...Y},new Set),H=_.indexOf(G);if(H===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:_.substring(0,H),afterSlot:_.substring(H+G.length),filePath:J,shellScripts:U,shellStyles:W}}catch(Q){return console.error(`[stx] Error processing shell ${J}:`,Q),null}}function kJ(J,Y,Q){let X,$="",Z=Y.match(WJ);if(Z){Y=Y.replace(Z[0],"");try{let K=Buffer.from(Z[1],"base64").toString("utf8"),G=K.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(G)X=G[1].trim();$=K.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let U=Q||X||"stx App",W=jJ(),j="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
|
|
3
|
-
<html lang="en">
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="UTF-8">
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
7
|
-
<title>${U}</title>
|
|
8
|
-
${$?` ${$}
|
|
9
|
-
`:""} ${J.shellStyles.join(`
|
|
10
|
-
`)}
|
|
11
|
-
</head>
|
|
12
|
-
<body>
|
|
13
|
-
${J.beforeSlot}
|
|
14
|
-
<div data-stx-content>${Y}</div>
|
|
15
|
-
${J.afterSlot}
|
|
16
|
-
${J.shellScripts.filter((K)=>!K.includes("server")).join(`
|
|
17
|
-
`)}
|
|
18
|
-
${j}
|
|
19
|
-
${W}
|
|
20
|
-
</body>
|
|
21
|
-
</html>`}function KJ(J,Y={}){let Q=J.trim();if(!h(Q))return J;let X=[],$=Q.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if($){let j=$[1],F=/<style\b[^>]*>[\s\S]*?<\/style>/gi,K;while((K=F.exec(j))!==null)X.push(K[0]);let G=j.match(/<script\b[^>]*data-stx-server-data[^>]*>[\s\S]*?<\/script>/i);if(G)X.push(G[0]);let B=j.match(/<script\b[^>]*data-stx-runtime-config[^>]*>[\s\S]*?<\/script>/i);if(B)X.push(B[0])}if(Y.preserveHead&&$){let j=[],F=/<title\b[^>]*>[\s\S]*?<\/title>|<meta\b[^>]*>|<link\b[^>]*>/gi,K;while((K=F.exec($[1]))!==null){if(/<meta\b[^>]*(?:\bcharset|name="viewport")/i.test(K[0]))continue;j.push(K[0])}if(j.length>0)X.unshift(`<!--${UJ}${Buffer.from(j.join(`
|
|
22
|
-
`),"utf8").toString("base64")}-->`)}let Z=Q.match(/<body\b[^>]*>/i),U=Q.lastIndexOf("</body>");if(Z&&U!==-1){let j=Z.index+Z[0].length,F=Q.slice(j,U).trim();if(X.length>0)return X.join(`
|
|
23
|
-
`)+`
|
|
24
|
-
`+F;return F}let W=Q;if(W=W.replace(/<!DOCTYPE\b[^>]*>/i,""),W=W.replace(/<html\b[^>]*>/i,""),W=W.replace(/<\/html\s*>/i,""),$)W=W.replace(/<head\b[^>]*>[\s\S]*?<\/head>/i,X.join(`
|
|
25
|
-
`));return W=W.replace(/<body\b[^>]*>/i,""),W=W.replace(/<\/body\s*>/i,""),W.trim()}var u=/^<script\b[^>]*\sdata-stx-(?:owner|instance)(?=[\s=/>])/i;function TJ(J){return g(J)}function SJ(J,Y="main"){let Q=J.trim(),X=[],$=[],Z=Q.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(Z){let A=Z[1],I=/<style\b[^>]*>[\s\S]*?<\/style>/gi,z;while((z=I.exec(A))!==null)X.push(z[0]);let _=/<script\b[^>]*data-stx-(?:route-params|server-data|scoped|component-factories)[^>]*>[\s\S]*?<\/script>/gi;while((z=_.exec(A))!==null){if(u.test(z[0])||z[0].includes("__stx_early_mounts")||/^<script\b[^>]*\bdata-stx-runtime(?=[\s=>])/i.test(z[0]))continue;$.push(z[0])}}let U=x(Q,Y);if(!U)return KJ(J);let{tagName:W,start:j,end:F}=U,K=Q.slice(j,F).trim(),G=[],B=Q.match(/<body\b[^>]*>/i),w=Q.lastIndexOf("</body>");if(B&&B.index!==void 0&&w!==-1){let I=[[B.index+B[0].length,U.openIndex],[F+`</${W}>`.length,w]],z=/<script\b[^>]*>[\s\S]*?<\/script>/gi;for(let[_,H]of I){if(_>=H)continue;let V=Q.slice(_,H),L;z.lastIndex=0;while((L=z.exec(V))!==null){if(u.test(L[0]))continue;G.push(L[0])}}}let N=[];if(X.length>0)N.push(X.join(`
|
|
26
|
-
`));if($.length>0)N.push($.join(`
|
|
27
|
-
`));if(G.length>0)N.push(G.join(`
|
|
28
|
-
`));return N.push(K),N.join(`
|
|
29
|
-
`)}import M from"fs";import p from"path";function fJ(J,Y,Q){return{version:1,buildTime:new Date().toISOString(),routes:J,assets:Y,outputDir:Q}}function gJ(J,Y){let Q=p.join(Y,"manifest.json");M.writeFileSync(Q,JSON.stringify(J,null,2))}function uJ(J){let Y=p.join(J,"manifest.json");if(!M.existsSync(Y))return null;try{let Q=M.readFileSync(Y,"utf-8"),X=JSON.parse(Q);if(X.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${X.version}`),null;return X}catch(Q){return console.warn("[stx] Failed to load manifest:",Q),null}}function b(J,Y,Q={}){let X=`${encodeURIComponent(J)}=${encodeURIComponent(Y)}`;if(Q.maxAge!==void 0)X+=`; Max-Age=${Q.maxAge}`;if(Q.expires)X+=`; Expires=${Q.expires.toUTCString()}`;if(Q.path)X+=`; Path=${Q.path}`;if(Q.domain)X+=`; Domain=${Q.domain}`;if(Q.secure)X+="; Secure";if(Q.httpOnly)X+="; HttpOnly";if(Q.sameSite)X+=`; SameSite=${Q.sameSite}`;return X}async function FJ(J){let Y=J.headers.get("content-type")||"",Q={},X=($,Z)=>{let U=Q[$];if(U===void 0)Q[$]=Z;else if(Array.isArray(U))U.push(Z);else Q[$]=[U,Z]};if(Y.includes("multipart/form-data")){let $=await J.formData();for(let[Z,U]of $.entries())if(typeof U==="string")X(Z,U);return Q}if(Y.includes("application/x-www-form-urlencoded")){for(let[$,Z]of new URLSearchParams(await J.text()).entries())X($,Z);return Q}return Q}function GJ(J){if(!J)return!1;let Y=J.toUpperCase();return Y!=="GET"&&Y!=="HEAD"}async function d(J,Y={}){let Q=Y.request,X=Y.method??Q?.method;if(!Q||!GJ(X))return{ran:!1};if(typeof J.action!=="function")return{ran:!1};let $={};try{$=await FJ(Q)}catch{}let Z=await J.action({request:Q,form:$,params:Y.params??{},query:J.query??{},cookies:Y.cookies??{}});if(Z&&typeof Z==="object"){let U=Z,W=zJ(U.cookies),j=U.redirect;if(typeof j==="string"&&j)return{redirect:j,ran:!0,...W.length>0?{cookies:W}:{}};let{cookies:F,redirect:K,...G}=U;if(Object.assign(J,G),W.length>0)return{ran:!0,cookies:W}}return{ran:!0}}function zJ(J){if(!J||typeof J!=="object"||Array.isArray(J))return[];let Y=[];for(let[Q,X]of Object.entries(J)){if(!Q)continue;if(typeof X==="string"){Y.push(b(Q,X));continue}if(X&&typeof X==="object"){let $=X;if(typeof $.value!=="string")continue;Y.push(b(Q,$.value,$))}}return Y}function dJ(J,Y=[],Q){let X=new Headers({Location:J,"Cache-Control":"no-store"});for(let $ of Y)X.append("Set-Cookie",$);for(let[$,Z]of Object.entries(Q??{}))if($.toLowerCase()!=="location")X.set($,Z);return new Response(null,{status:303,headers:X})}async function aJ(J,Y={}){return(await n(J,Y)).html}async function tJ(J,Y={}){let{html:Q,context:X,redirect:$,cookies:Z}=await n(J,Y),U=c(X),W=l(X);if($)return{html:Q,redirect:$,cookies:Z,status:U,headers:W};let{extractStreamBoundaries:j}=await import("./chunk-5ztqaab9.js"),F=j(X),K=J.streamTemplates;if(K&&Object.keys(K).length>0){let{processDirectives:G}=await import("./chunk-sy5x1tma.js"),{defaultConfig:B}=await import("./chunk-93f8avhm.js"),w=X.streamBoundaries||{},N={...B,autoShell:!1},A=Object.keys(K).map((z)=>({id:z,render:async()=>{let _=typeof w[z]==="function"?await w[z]():void 0;return G(K[z],{...X,$boundary:_},J.sourceFile,N,new Set)}})),I=new Set(A.map((z)=>z.id));F=[...(F||[]).filter((z)=>!I.has(z.id)),...A]}return{html:Q,boundaries:F&&F.length>0?F:void 0,cookies:Z,status:U,headers:W}}async function n(J,Y){let Q={__filename:J.sourceFile,__dirname:J.sourceFile.replace(/[/\\][^/\\]+$/,""),...Y};if(!J.hasServerScripts&&!O(J.html))return{html:J.html,context:Q};for(let U of J.serverScriptContent)try{await T(U,Q,J.sourceFile)}catch(W){if(Y.__stx_strict_hydration)throw W;console.warn(`[stx] Server script error in ${J.sourceFile}:`,W)}let X=await d(Q,{request:Y.request,method:Y.method,params:Y.params??{},cookies:Y.cookies??{}}),$=(U)=>{let W=U.replace(/<script\b[^>]*\bdata-stx-server-data\b[^>]*>[\s\S]*?<\/script>/gi,""),j=i(Q);if(!j)return W;let F=W.indexOf("</head>");return F<0?j+W:W.slice(0,F)+j+W.slice(F)};if(X.redirect)return{html:J.html,context:Q,redirect:X.redirect,cookies:X.cookies};if(!O(J.html))return{html:$(J.html),context:Q,cookies:X.cookies};let Z=new Map;for(let[U,W]of Object.entries(J.placeholders))if(W.expression)try{let j=k(W.expression,Q);if(W.type==="raw")Z.set(U,j!==void 0&&j!==null?String(j):"");else Z.set(U,j!==void 0&&j!==null?P(String(j)):"")}catch(j){if(Y.__stx_strict_hydration)throw j;Z.set(U,"")}return{html:$(R(J.html,Z)),context:Q,cookies:X.cookies}}async function eJ(J,Y={}){if(!J.hasServerScripts&&!O(J.fragment))return J.fragment;let Q={__filename:J.sourceFile,__dirname:J.sourceFile.replace(/[/\\][^/\\]+$/,""),...Y};for(let $ of J.serverScriptContent)try{await T($,Q,J.sourceFile)}catch(Z){console.warn(`[stx] Server script error in ${J.sourceFile}:`,Z)}if(!O(J.fragment))return J.fragment;let X=new Map;for(let[$,Z]of Object.entries(J.placeholders))if(Z.expression)try{let U=k(Z.expression,Q);if(Z.type==="raw")X.set($,U!==void 0&&U!==null?String(U):"");else X.set($,U!==void 0&&U!==null?P(String(U)):"")}catch{X.set($,"")}return R(J.fragment,X)}
|
|
30
|
-
export{s as Yf,C as Zf,e as _f,x as $f,NJ as ag,_J as bg,AJ as cg,g as dg,QJ as eg,IJ as fg,RJ as gg,PJ as hg,kJ as ig,KJ as jg,TJ as kg,SJ as lg,fJ as mg,gJ as ng,uJ as og,b as pg,FJ as qg,GJ as rg,d as sg,dJ as tg,aJ as ug,tJ as vg,eJ as wg};
|
package/dist/chunk-fdc118yv.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{fi as a,gi as b,hi as c}from"./chunk-an5y1z0q.js";import"./chunk-ra1s4s6b.js";import"./chunk-9n88pgdr.js";import"./chunk-geztv535.js";import"./chunk-qjvny3wf.js";import"./chunk-yz2yk0p1.js";import"./chunk-nh6p0k17.js";import"./chunk-49trnqad.js";import"./chunk-c0vjhzjf.js";import"./chunk-vjn3r3sq.js";import"./chunk-cbj5a2tk.js";import"./chunk-05c62pqd.js";import"./chunk-2zbmyvqc.js";import"./chunk-sjpjge04.js";import"./chunk-0380epk7.js";import"./chunk-k6bagvmz.js";import"./chunk-zhzcahz5.js";import"./chunk-8kwmj99g.js";import"./chunk-7ngmxv4z.js";import"./chunk-s3tpyage.js";import"./chunk-2sa8rk32.js";import"./chunk-x8t29tnr.js";import"./chunk-0xh7vqce.js";import"./chunk-wqa77pdn.js";import"./chunk-myyj9qp3.js";export{a as listComposableModules,b as getComposableScript,c as clearComposableCache};
|