@stacksjs/stx 0.2.82 → 0.2.84
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/app-shell.js +21 -11
- package/dist/build-assets.js +19 -9
- package/dist/build-mode-detector.js +22 -12
- package/dist/build-views.js +22 -12
- package/dist/build.js +21 -11
- package/dist/caching.js +19 -9
- package/dist/cli.js +22 -12
- package/dist/component-processing.js +21 -11
- package/dist/component-renderer.js +21 -11
- package/dist/components.js +22 -12
- package/dist/conditionals.js +1 -1
- package/dist/custom-directives.js +1 -1
- package/dist/dev-server/index.js +22 -12
- package/dist/dev-server/serve-app.js +21 -11
- package/dist/dev-server/serve-file.js +21 -11
- package/dist/dev-server/serve-markdown.js +22 -12
- package/dist/dev-server/serve-multi.js +21 -11
- package/dist/dev-server.js +21 -11
- package/dist/docs.js +22 -12
- package/dist/dynamic-components.js +21 -11
- package/dist/error-handling.js +1 -1
- package/dist/errors/formatter.js +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/i18n.js +1 -1
- package/dist/includes.js +21 -11
- package/dist/index.js +21 -11
- package/dist/interactive.js +22 -12
- package/dist/lazy-loader.js +98 -88
- package/dist/misc-directives.js +1 -1
- package/dist/plugin.js +21 -11
- package/dist/process.js +21 -11
- package/dist/production-builder.js +21 -11
- package/dist/production-server.js +21 -11
- package/dist/pwa/index.js +22 -12
- package/dist/pwa/offline.js +22 -12
- package/dist/pwa.js +21 -11
- package/dist/reactive.js +1 -1
- package/dist/render.js +22 -12
- package/dist/runtime-injection.js +19 -9
- package/dist/seo.js +1 -1
- package/dist/serve.js +22 -12
- package/dist/signal-processing.js +41 -31
- package/dist/signals.js +19 -9
- package/dist/site-builder/build.js +22 -12
- package/dist/site-builder/index.js +22 -12
- package/dist/ssg.js +21 -11
- package/dist/ssr.js +22 -12
- package/dist/store-loader.js +18 -18
- package/dist/story/cli.js +22 -12
- package/dist/story/commands/dev.js +22 -12
- package/dist/story/commands/index.js +22 -12
- package/dist/story/index.js +22 -12
- package/dist/story/renderer.js +22 -12
- package/dist/story/server.js +22 -12
- package/dist/story/visual-testing.js +22 -12
- package/dist/streaming.js +21 -11
- package/dist/template-compiler.js +22 -12
- package/dist/template-hydrator.js +22 -12
- package/dist/testing.js +147 -137
- package/dist/utils.js +21 -11
- package/dist/web-components.js +22 -12
- package/package.json +5 -5
package/dist/store-loader.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var h4=Object.defineProperty;var d4=($)=>$;function
|
|
2
|
+
var h4=Object.defineProperty;var d4=($)=>$;function u4($,Z){this[$]=d4.bind(null,Z)}var e0=($,Z)=>{for(var Y in Z)h4($,Y,{get:Z[Y],enumerable:!0,configurable:!0,set:u4.bind(Z,Y)})};var H=($,Z)=>()=>($&&(Z=$($=0)),Z);var S=import.meta.require;var O5,V5;var $1=H(()=>{O5={name:"a11y",handler:($,Z,Y,J)=>{if(!Z.length)return $;let X=Z[0].replace(/['"]/g,""),G=Z.length>1?Z[1].replace(/['"]/g,""):"",U={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[X]||"Make this element accessible";return`<!-- a11y-hint: ${G||U} -->${$}`},hasEndTag:!1},V5={name:"screenReader",handler:($)=>{return`<span class="sr-only">${$}</span>`},hasEndTag:!0}});function m4($,Z={}){let{duration:Y,delay:J,ease:X,direction:G,custom:Q}={...i,...Z};if($==="custom"&&Q)return Q;switch($){case"fade":return`${G==="in"?"opacity: 0; animation: fadeIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":G==="out"?"opacity: 1; animation: fadeOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"opacity: 1; transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
|
|
3
3
|
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
|
|
4
4
|
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }`;case"slide":return`${G==="in"?"transform: translateY(20px); opacity: 0; animation: slideIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":G==="out"?"transform: translateY(0); opacity: 1; animation: slideOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: translateY(0); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
|
|
5
5
|
@keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
|
|
@@ -74,7 +74,7 @@ else {
|
|
|
74
74
|
}
|
|
75
75
|
})();
|
|
76
76
|
</script>
|
|
77
|
-
`}var i,L5,F5,w5,R5;var Z1=H(()=>{i={duration:300,delay:0,ease:"ease",direction:"both"};L5={name:"transition",handler:($,Z,Y,J)=>{if(Z.length<1)return`<div class="stx-error">@transition directive requires at least a transition type</div>${$}`;let X=Z[0],G=Z.length>1?Number.parseInt(Z[1],10)||i.duration:i.duration,Q=Z.length>2?Z[2]||i.ease:i.ease,U=Z.length>3?Number.parseInt(Z[3],10)||i.delay:i.delay,K=Z.length>4?Z[4]||i.direction:i.direction,z=`stx-transition-${Math.random().toString(36).substr(2,9)}`,W=
|
|
77
|
+
`}var i,L5,F5,w5,R5;var Z1=H(()=>{i={duration:300,delay:0,ease:"ease",direction:"both"};L5={name:"transition",handler:($,Z,Y,J)=>{if(Z.length<1)return`<div class="stx-error">@transition directive requires at least a transition type</div>${$}`;let X=Z[0],G=Z.length>1?Number.parseInt(Z[1],10)||i.duration:i.duration,Q=Z.length>2?Z[2]||i.ease:i.ease,U=Z.length>3?Number.parseInt(Z[3],10)||i.delay:i.delay,K=Z.length>4?Z[4]||i.direction:i.direction,z=`stx-transition-${Math.random().toString(36).substr(2,9)}`,W=m4(X,{duration:G,delay:U,ease:Q,direction:K}),q="stx-transition",_="";if(X==="fade")_="stx-fade";else if(X==="slide")_="stx-slide";else if(X==="scale")_="stx-scale";else if(X==="flip")_="stx-flip";else if(X==="rotate")_="stx-rotate";return`<div id="${z}" class="${q} ${_} ${K==="out"?"stx-out":""}"
|
|
78
78
|
style="--stx-transition-duration: ${G}ms; --stx-transition-ease: ${Q}; --stx-transition-delay: ${U}ms;">${$}</div>`},hasEndTag:!0,description:"Applies transition effects to an element"},F5={name:"scrollAnimate",handler:($,Z,Y,J)=>{if(Z.length<1)return`<div class="stx-error">@scrollAnimate directive requires at least an animation type</div>${$}`;let X=Z[0],G=Z.length>1?Number.parseInt(Z[1],10)||300:300,Q=Z.length>2?Z[2]||"ease":"ease",U=Z.length>3?Number.parseFloat(Z[3])||0.2:0.2,K=Z.length>4?Number.parseInt(Z[4],10)||0:0,z=`stx-scroll-${Math.random().toString(36).substr(2,9)}`,W=`--stx-transition-duration: ${G}ms; --stx-transition-ease: ${Q}; --stx-transition-delay: ${K}ms; will-change: opacity, transform;`,q="stx-transition stx-observe stx-out";if(X==="fade")q+=" stx-fade";else if(X==="slide-up"||X==="slide")q+=" stx-from-bottom";else if(X==="slide-down")q+=" stx-from-top";else if(X==="slide-left")q+=" stx-from-right";else if(X==="slide-right")q+=" stx-from-left";else if(X==="scale")q+=" stx-scale";else if(X.includes("-"))q+=` stx-${X}`;else q+=` stx-${X}`;return`<div id="${z}" class="${q}" style="${W}" data-threshold="${U}">${$}</div>`},hasEndTag:!0,description:"Applies animations that trigger when scrolled into view"},w5={name:"animationGroup",handler:($,Z,Y,J)=>{if(Z.length<2)return`<div class="stx-error">@animationGroup directive requires a group name and at least one element selector</div>${$}`;let X=Z[0],G=Z.slice(1).map((z)=>z.startsWith("#")||z.startsWith(".")?z:`#${z}`),Q=Y.staggerDelay||50,U=Y.sequence||!0,K=c4(X,G,{staggerDelay:Q,sequence:U});return`${$}
|
|
79
79
|
${K}`},hasEndTag:!1,description:"Coordinates multiple animations together as a group"},R5={name:"motion",handler:($,Z,Y,J)=>{let X=Z.length>0?Z[0].toLowerCase()==="true":!0,G=l4();return`<div data-animate="${X?"auto":"true"}">${$}</div>${G}`},hasEndTag:!0,description:"Controls motion and animation preferences"}});import{getRouterScript as A5}from"stx-router";var N5=H(()=>{Y1()});async function p4($,Z,Y,J){let X=Z[0]?.replace(/['"]/g,"")||"main",G=A5();if(X!=="main")G=G.replace("container:'main'",`container:'${X}'`);return`<script data-stx-router>${G}</script>`}var T5;var Y1=H(()=>{N5();T5={name:"stxRouter",handler:p4,hasEndTag:!1,description:"Inject the STX SPA router script for client-side navigation"}});function n4($){let Z=$.heatmap;if(!Z?.enabled)return"";let Y={...i4,...Z};return`
|
|
80
80
|
<!-- stx Heatmap - Privacy-Compliant Tracking -->
|
|
@@ -487,11 +487,11 @@ catch (e) {
|
|
|
487
487
|
}
|
|
488
488
|
throw e;
|
|
489
489
|
}
|
|
490
|
-
`),X.set(z,W)}return W(...U)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:Q,context:Z.slice()});return Q}clear(){this.pool.length=0,this.fnCache.clear()}}class S5{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled($){this.enabled=$}isEnabled(){return this.enabled}setBudget($,Z){this.budgets.set($,{warnThreshold:0.8,action:"warn",...Z})}setBudgets($){for(let[Z,Y]of Object.entries($))this.setBudget(Z,Y)}removeBudget($){this.budgets.delete($)}getBudgets(){let $={};for(let[Z,Y]of this.budgets.entries())$[Z]=Y;return $}onViolation($){this.violationHandlers.push($)}offViolation($){let Z=this.violationHandlers.indexOf($);if(Z!==-1)this.violationHandlers.splice(Z,1)}time($,Z){if(!this.enabled)return Z();let Y=performance.now(),J=Z(),X=performance.now()-Y;return this.recordTime($,X),this.checkBudget($,X),J}async timeAsync($,Z){if(!this.enabled)return Z();let Y=performance.now(),J=await Z(),X=performance.now()-Y;return this.recordTime($,X),this.checkBudget($,X),J}checkBudget($,Z){let Y=this.budgets.get($);if(!Y)return;let J=Z/Y.maxTime*100,X=Y.warnThreshold!==void 0?Z>=Y.maxTime*Y.warnThreshold&&Z<Y.maxTime:!1,G=Z>=Y.maxTime;if(!X&&!G)return;let Q={label:$,actualTime:Z,budgetTime:Y.maxTime,exceedancePercent:J,timestamp:new Date,isWarning:X};this.violations.push(Q);while(this.violations.length>this.maxViolations)this.violations.shift();for(let K of this.violationHandlers)try{K(Q)}catch{}let U=X?`[Performance Warning] "${$}" took ${Z.toFixed(2)}ms (${J.toFixed(1)}% of ${Y.maxTime}ms budget)`:`[Performance Budget Exceeded] "${$}" took ${Z.toFixed(2)}ms (exceeded ${Y.maxTime}ms budget by ${(J-100).toFixed(1)}%)`;switch(Y.action){case"log":console.log(U);break;case"warn":console.warn(U);break;case"error":console.error(U);break;case"throw":if(G)throw Error(U);else console.warn(U);break}}recordTime($,Z){let Y=this.metrics.get($);if(Y)Y.count++,Y.totalTime+=Z,Y.maxTime=Math.max(Y.maxTime,Z),Y.minTime=Math.min(Y.minTime,Z);else this.metrics.set($,{count:1,totalTime:Z,maxTime:Z,minTime:Z})}getStats($){if($){let Y=this.metrics.get($);if(!Y)return{};let J=this.budgets.get($);return{count:Y.count,avgTime:Y.totalTime/Y.count,totalTime:Y.totalTime,maxTime:Y.maxTime,minTime:Y.minTime,budget:J?.maxTime,budgetUtilization:J?Y.totalTime/Y.count/J.maxTime*100:void 0}}let Z={};for(let[Y,J]of this.metrics.entries()){let X=this.budgets.get(Y);Z[Y]={count:J.count,avgTime:J.totalTime/J.count,totalTime:J.totalTime,maxTime:J.maxTime,minTime:J.minTime,budget:X?.maxTime,budgetUtilization:X?J.totalTime/J.count/X.maxTime*100:void 0}}return Z}getViolations($){if($)return this.violations.filter((Z)=>Z.label===$);return[...this.violations]}getViolationStats(){let $={},Z=0,Y=0;for(let J of this.violations)if($[J.label]=($[J.label]||0)+1,J.isWarning)Z++;else Y++;return{total:this.violations.length,byLabel:$,warnings:Z,errors:Y}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}function a4(){if(!Q1)Q1=new S5;return Q1}var
|
|
490
|
+
`),X.set(z,W)}return W(...U)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:Q,context:Z.slice()});return Q}clear(){this.pool.length=0,this.fnCache.clear()}}class S5{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled($){this.enabled=$}isEnabled(){return this.enabled}setBudget($,Z){this.budgets.set($,{warnThreshold:0.8,action:"warn",...Z})}setBudgets($){for(let[Z,Y]of Object.entries($))this.setBudget(Z,Y)}removeBudget($){this.budgets.delete($)}getBudgets(){let $={};for(let[Z,Y]of this.budgets.entries())$[Z]=Y;return $}onViolation($){this.violationHandlers.push($)}offViolation($){let Z=this.violationHandlers.indexOf($);if(Z!==-1)this.violationHandlers.splice(Z,1)}time($,Z){if(!this.enabled)return Z();let Y=performance.now(),J=Z(),X=performance.now()-Y;return this.recordTime($,X),this.checkBudget($,X),J}async timeAsync($,Z){if(!this.enabled)return Z();let Y=performance.now(),J=await Z(),X=performance.now()-Y;return this.recordTime($,X),this.checkBudget($,X),J}checkBudget($,Z){let Y=this.budgets.get($);if(!Y)return;let J=Z/Y.maxTime*100,X=Y.warnThreshold!==void 0?Z>=Y.maxTime*Y.warnThreshold&&Z<Y.maxTime:!1,G=Z>=Y.maxTime;if(!X&&!G)return;let Q={label:$,actualTime:Z,budgetTime:Y.maxTime,exceedancePercent:J,timestamp:new Date,isWarning:X};this.violations.push(Q);while(this.violations.length>this.maxViolations)this.violations.shift();for(let K of this.violationHandlers)try{K(Q)}catch{}let U=X?`[Performance Warning] "${$}" took ${Z.toFixed(2)}ms (${J.toFixed(1)}% of ${Y.maxTime}ms budget)`:`[Performance Budget Exceeded] "${$}" took ${Z.toFixed(2)}ms (exceeded ${Y.maxTime}ms budget by ${(J-100).toFixed(1)}%)`;switch(Y.action){case"log":console.log(U);break;case"warn":console.warn(U);break;case"error":console.error(U);break;case"throw":if(G)throw Error(U);else console.warn(U);break}}recordTime($,Z){let Y=this.metrics.get($);if(Y)Y.count++,Y.totalTime+=Z,Y.maxTime=Math.max(Y.maxTime,Z),Y.minTime=Math.min(Y.minTime,Z);else this.metrics.set($,{count:1,totalTime:Z,maxTime:Z,minTime:Z})}getStats($){if($){let Y=this.metrics.get($);if(!Y)return{};let J=this.budgets.get($);return{count:Y.count,avgTime:Y.totalTime/Y.count,totalTime:Y.totalTime,maxTime:Y.maxTime,minTime:Y.minTime,budget:J?.maxTime,budgetUtilization:J?Y.totalTime/Y.count/J.maxTime*100:void 0}}let Z={};for(let[Y,J]of this.metrics.entries()){let X=this.budgets.get(Y);Z[Y]={count:J.count,avgTime:J.totalTime/J.count,totalTime:J.totalTime,maxTime:J.maxTime,minTime:J.minTime,budget:X?.maxTime,budgetUtilization:X?J.totalTime/J.count/X.maxTime*100:void 0}}return Z}getViolations($){if($)return this.violations.filter((Z)=>Z.label===$);return[...this.violations]}getViolationStats(){let $={},Z=0,Y=0;for(let J of this.violations)if($[J.label]=($[J.label]||0)+1,J.isWarning)Z++;else Y++;return{total:this.violations.length,byLabel:$,warnings:Z,errors:Y}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}function a4(){if(!Q1)Q1=new S5;return Q1}var m6,Q1=null,t4;var J0=H(()=>{m6=new b5;t4=new Proxy({},{get($,Z){return a4()[Z]}})});var y5=()=>{};var C5=H(()=>{y5()});function K1($){return Symbol($)}var o6,s6,r6;var P5=H(()=>{o6=K1("theme"),s6=K1("router"),r6=K1("i18n")});var v5=()=>{};var x5=()=>{};var f5=()=>{};var g5=H(()=>{$0()});import{createHighlighter as Q9}from"ts-syntax-highlighter";var h5=H(()=>{U1();x()});var d5=H(()=>{y()});function q1($){for(let[Z,Y]of Object.entries(f))if(Y===$)return Z;return}var f;var A0=H(()=>{f={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 z1(){return!1}function W1(){return!z1()||process.env.STX_DEBUG==="true"}import $3 from"path";function _1($){if(!u5.showRelativePaths||!$)return $;let Z=u5.baseDir||process.cwd();try{let Y=$3.relative(Z,$);return Y.startsWith("..")?$:Y}catch{return $}}var Z3,u5;var N0=H(()=>{A0();Z3={showRelativePaths:!1,enableAutoRecovery:W1(),logRecoveryWarnings:!0},u5={...Z3}});function l5($){let{type:Z,message:Y,code:J,filePath:X,line:G,column:Q,template:U,offset:K,snippet:z,suggestion:W,format:q="text"}=$,_=G,j=Q;if(!_&&U&&K!==void 0){let F=K3(U,K);_=F.line,j=F.column}let B=X?_1(X):void 0,V=J?q1(J):void 0,O={type:Z,code:J,codeName:V,message:Y,filePath:B,line:_,column:j,snippet:z,suggestion:W,timestamp:new Date().toISOString()},L;switch(q){case"html":L=X3(O);break;case"json":L=JSON.stringify(O,null,2);break;case"console":L=J3(O,U,K);break;case"text":default:L=Y3(O,U,K);break}return{formatted:L,data:O}}function Y3($,Z,Y){let J=[],X=$.code?` [${$.codeName||$.code}]`:"";if(J.push(`[${$.type} Error${X}]`),$.filePath){let G=$.filePath;if($.line){if(G+=`:${$.line}`,$.column)G+=`:${$.column}`}J.push(`at ${G}`)}if(J.push(`
|
|
491
491
|
${$.message}`),Z&&$.line){let G=G3(Z,$.line,2);if(G)J.push(`
|
|
492
492
|
${G}`)}if($.snippet)J.push(`
|
|
493
493
|
Snippet: ${$.snippet}`);if($.suggestion)J.push(`
|
|
494
|
-
Suggestion: ${$.suggestion}`);return J.join(" ")}function X3($){let Z=$.code?` [${$.code}]`:"",Y=$.filePath?` in ${$.filePath}${$.line?`:${$.line}`:""}`:"",J=`<!-- [${$.type} Error${Z}]${Y}: ${
|
|
494
|
+
Suggestion: ${$.suggestion}`);return J.join(" ")}function X3($){let Z=$.code?` [${$.code}]`:"",Y=$.filePath?` in ${$.filePath}${$.line?`:${$.line}`:""}`:"",J=`<!-- [${$.type} Error${Z}]${Y}: ${m5($.message)}`;if($.suggestion)J+=` | Suggestion: ${m5($.suggestion)}`;return J+=" -->",J}function J3($,Z,Y){let z=[],W=$.code?` [${$.codeName||$.code}]`:"";if(z.push(`\x1B[1m${"\x1B[31m"}\u2501\u2501\u2501 ${$.type} Error${W} \u2501\u2501\u2501${"\x1B[0m"}`),$.filePath){let q=`\x1B[36m${$.filePath}\x1B[0m`;if($.line){if(q+=`\x1B[90m:${$.line}\x1B[0m`,$.column)q+=`\x1B[90m:${$.column}\x1B[0m`}z.push(`
|
|
495
495
|
\x1B[90mat\x1B[0m ${q}`)}if(z.push(`
|
|
496
496
|
|
|
497
497
|
${$.message}`),Z&&$.line){let q=Q3(Z,$.line,2);if(q)z.push(`
|
|
@@ -504,14 +504,14 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
|
|
|
504
504
|
`),X=Math.max(0,Z-Y-1),G=Math.min(J.length-1,Z+Y-1),Q=[];for(let U=X;U<=G;U++){let K=(U+1).toString().padStart(4),z=U===Z-1?">":" ";Q.push(`${z}${K} | ${J[U]}`)}return Q.join(`
|
|
505
505
|
`)}function Q3($,Z,Y){let J=$.split(`
|
|
506
506
|
`),X=Math.max(0,Z-Y-1),G=Math.min(J.length-1,Z+Y-1),Q="\x1B[90m",U="\x1B[31m",K="\x1B[0m",z=[];for(let W=X;W<=G;W++){let q=(W+1).toString().padStart(4),_=W===Z-1,j=_?"\x1B[31m>\x1B[0m":" ",B=_?`\x1B[31m${J[W]}\x1B[0m`:`\x1B[90m${J[W]}\x1B[0m`;z.push(`${j}\x1B[90m${q}\x1B[0m | ${B}`)}return z.join(`
|
|
507
|
-
`)}function
|
|
508
|
-
`);return{line:J.length,column:J[J.length-1].length}}function
|
|
507
|
+
`)}function m5($){return $.replace(/--/g,"- -").replace(/>/g,">")}function K3($,Z){let J=$.substring(0,Z).split(`
|
|
508
|
+
`);return{line:J.length,column:J[J.length-1].length}}function m($,Z,Y){return l5({type:$,message:Z,code:Y,format:"html"}).formatted}var c5=H(()=>{A0();N0()});class B1{errors=[];maxErrors;enableFileLogging;logFilePath;logFormat;maxFileSize;maxLogFiles;minLevel;writeQueue=Promise.resolve();constructor($={}){this.maxErrors=$.maxErrors??1000,this.enableFileLogging=$.enableFileLogging??!1,this.logFilePath=$.logFilePath??".stx/errors.log",this.logFormat=$.logFormat??"json",this.maxFileSize=$.maxFileSize??10485760,this.maxLogFiles=$.maxLogFiles??5,this.minLevel=$.minLevel??"all"}configure($){if($.maxErrors!==void 0)this.maxErrors=$.maxErrors;if($.enableFileLogging!==void 0)this.enableFileLogging=$.enableFileLogging;if($.logFilePath!==void 0)this.logFilePath=$.logFilePath;if($.logFormat!==void 0)this.logFormat=$.logFormat;if($.maxFileSize!==void 0)this.maxFileSize=$.maxFileSize;if($.maxLogFiles!==void 0)this.maxLogFiles=$.maxLogFiles;if($.minLevel!==void 0)this.minLevel=$.minLevel}log($,Z,Y="error"){let J={timestamp:new Date,error:$,context:Z,level:Y};if(this.errors.push(J),this.errors.length>this.maxErrors)this.errors=this.errors.slice(-this.maxErrors);if(this.enableFileLogging&&this.shouldLog(Y))this.writeToFile(J)}shouldLog($){if(this.minLevel==="all")return!0;if(this.minLevel==="warning")return $==="error"||$==="warning";if(this.minLevel==="error")return $==="error";return!0}formatEntry($){if(this.logFormat==="json")return JSON.stringify({timestamp:$.timestamp.toISOString(),level:$.level||"error",type:$.error.constructor.name,message:$.error.message,stack:$.error.stack,context:$.context});let Z=[`[${$.timestamp.toISOString()}] [${($.level||"error").toUpperCase()}] ${$.error.constructor.name}: ${$.error.message}`];if($.error.stack)Z.push(` Stack: ${$.error.stack.split(`
|
|
509
509
|
`).slice(1).join(`
|
|
510
510
|
`)}`);if($.context)Z.push(` Context: ${JSON.stringify($.context)}`);return Z.join(`
|
|
511
511
|
`)}writeToFile($){this.writeQueue=this.writeQueue.then(async()=>{try{let Z=await import("fs"),J=(await import("path")).dirname(this.logFilePath);if(!Z.existsSync(J))Z.mkdirSync(J,{recursive:!0});await this.rotateIfNeeded(Z);let X=`${this.formatEntry($)}
|
|
512
512
|
`;Z.appendFileSync(this.logFilePath,X,"utf-8")}catch(Z){if(process.env.STX_DEBUG==="true")console.error("Failed to write to error log:",Z)}})}async rotateIfNeeded($){try{if(!$.existsSync(this.logFilePath))return;if($.statSync(this.logFilePath).size<this.maxFileSize)return;for(let Y=this.maxLogFiles-1;Y>=1;Y--){let J=`${this.logFilePath}.${Y}`,X=`${this.logFilePath}.${Y+1}`;if($.existsSync(J))if(Y>=this.maxLogFiles-1)$.unlinkSync(J);else $.renameSync(J,X)}if(this.maxLogFiles<=1)$.writeFileSync(this.logFilePath,"");else $.renameSync(this.logFilePath,`${this.logFilePath}.1`)}catch(Z){if(process.env.STX_DEBUG==="true")console.error("Failed to rotate error logs:",Z)}}getRecentErrors($=10){return this.errors.slice(-$)}getErrorsByType($){return this.errors.filter((Z)=>Z.error.constructor.name===$)}getErrorsByLevel($){return this.errors.filter((Z)=>Z.level===$)}clear(){this.errors.length=0}async clearLogFile(){try{let $=await import("fs");if($.existsSync(this.logFilePath))$.writeFileSync(this.logFilePath,"","utf-8")}catch($){if(process.env.STX_DEBUG==="true")console.error("Failed to clear error log:",$)}}getStats(){let $={},Z={error:0,warning:0,info:0};for(let Y of this.errors){let J=Y.error.constructor.name;$[J]=($[J]||0)+1;let X=Y.level||"error";Z[X]=(Z[X]||0)+1}return{total:this.errors.length,byType:$,byLevel:Z}}async exportToFile($,Z="json"){let Y=await import("fs"),X=(await import("path")).dirname($);if(!Y.existsSync(X))Y.mkdirSync(X,{recursive:!0});if(Z==="json"){let G=this.errors.map((Q)=>({timestamp:Q.timestamp.toISOString(),level:Q.level||"error",type:Q.error.constructor.name,message:Q.error.message,stack:Q.error.stack,context:Q.context}));Y.writeFileSync($,JSON.stringify(G,null,2),"utf-8")}else{let G=this.errors.map((Q)=>this.formatEntry(Q));Y.writeFileSync($,G.join(`
|
|
513
513
|
|
|
514
|
-
`),"utf-8")}}async flush(){await this.writeQueue}}var H1;var p5=H(()=>{N0();H1=new B1});var i5=()=>{};var n5=H(()=>{A0();c5();p5();i5();N0()});var o=H(()=>{n5()});var o5=()=>{};var s5=()=>{};var I0=H(()=>{o5();s5()});var M0=H(()=>{d5();o();I0();y()});var a5=()=>{};var t5=()=>{};var e5=H(()=>{o();J0()});var j1=()=>{};var $$=H(()=>{y()});var Z$=H(()=>{o();y()});var
|
|
514
|
+
`),"utf-8")}}async flush(){await this.writeQueue}}var H1;var p5=H(()=>{N0();H1=new B1});var i5=()=>{};var n5=H(()=>{A0();c5();p5();i5();N0()});var o=H(()=>{n5()});var o5=()=>{};var s5=()=>{};var I0=H(()=>{o5();s5()});var M0=H(()=>{d5();o();I0();y()});var a5=()=>{};var t5=()=>{};var e5=H(()=>{o();J0()});var j1=()=>{};var $$=H(()=>{y()});var Z$=H(()=>{o();y()});var u8;var X$=H(()=>{M0();$0();J0();y();x();u8=new _0(500)});var J$=H(()=>{J0();x()});var G$=H(()=>{M0();o();$0();I0();y()});var Q$=H(()=>{$0();x()});import{defineRoute as zZ,defineRoutes as WZ,resetRoutes as _Z,route as BZ,setAppUrl as HZ}from"stx-router";import{route as QZ}from"stx-router";var K$=H(()=>{y()});function U$($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var q$,z$;var V1=H(()=>{o();y();q$={name:"meta",handler:($,Z,Y,J)=>{if(Z.length<1)return m("Meta","meta directive requires at least the meta name",f.INVALID_DIRECTIVE_SYNTAX);let X=Z[0].replace(/['"]/g,""),G=Z.length>1?Z[1].replace(/['"]/g,""):"";return`<meta name="${U$(X)}" content="${U$(G)}">`},hasEndTag:!1},z$={name:"structuredData",handler:($,Z,Y,J)=>{if($.trim()==="")return m("StructuredData","structuredData directive requires JSON-LD content",f.INVALID_DIRECTIVE_SYNTAX);try{let X=JSON.parse($);if(!X["@context"])X["@context"]="https://schema.org";if(!X["@type"])return m("StructuredData","structuredData requires @type property",f.INVALID_DIRECTIVE_SYNTAX);return`<script type="application/ld+json">${JSON.stringify(X)}</script>`}catch(X){let G=X instanceof Error?X.message:String(X);return m("StructuredData",G,f.EVALUATION_ERROR)}},hasEndTag:!0}});var W$=()=>{};var _$=()=>{};var B$=()=>{};var H$=H(()=>{x();y()});var L1=()=>{};var O$=H(()=>{w0();I0();x()});import l from"path";import F1 from"fs";function V$($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function L$($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class F${builtins=new Map;registerBuiltin($){this.builtins.set($.name.toLowerCase(),$);for(let Z of $.aliases)this.builtins.set(Z.toLowerCase(),$)}isBuiltin($){return this.builtins.has($.toLowerCase())}getBuiltin($){return this.builtins.get($.toLowerCase())??null}async resolveFile($,Z,Y,J){let X=$.endsWith(".stx")?$.slice(0,-4):$,G=J?.__importedComponents;if(G){let j=[X,X.toLowerCase(),V$(X),L$(X)];for(let B of j)if(G.has(B))return G.get(B)}let Q=[...new Set([`${X}.stx`,`${V$(X)}.stx`,`${L$(X)}.stx`])];if(X.startsWith("./")||X.startsWith("../")){let j=l.resolve(l.dirname(Z),`${X}.stx`);if(await n(j))return j;return null}let U=[],K=Y.componentsDir||"",z=J?.__originalFilePath;if(z)U.push(l.join(l.dirname(z),"components"));if(K)U.push(K);let W=l.join(l.dirname(Z),"components");if(!U.includes(W))U.push(W);let q=process.cwd(),_=[l.resolve(q,"src/components"),l.resolve(q,"components"),l.resolve(import.meta.dir,"components")];for(let j of _)if(!U.includes(j))U.push(j);for(let j of U){if(!j)continue;for(let B of Q){let V=l.join(j,B);if(await n(V))return V}try{if(!F1.statSync(j,{throwIfNoEntry:!1})?.isDirectory())continue;let V=F1.readdirSync(j,{withFileTypes:!0});for(let O of V)if(O.isDirectory()){let L=l.join(j,O.name);for(let F of Q){let w=l.join(L,F);if(await n(w))return w}}}catch{}}return null}}var w$;var w1=H(()=>{x();w$=new F$});var R1=()=>{};var A1=()=>{};var N1=()=>{};var T1=()=>{};var M1=()=>{};var D1=()=>{};var E1=()=>{};var k1=()=>{};var b1=()=>{};var S1=()=>{};var R$=H(()=>{R1();A1();N1();T1();M1();D1();E1();k1();b1();S1();w1();R1();A1();N1();T1();M1();D1();E1();k1();b1();S1()});var A$=H(()=>{y();x();R0()});var N$=H(()=>{w1();R$();A$();x();y()});import x3 from"process";function B0($="STX_PUBLIC_"){let Z={},Y={};for(let[J,X]of Object.entries(x3.env)){if(!J.startsWith($)||X===void 0)continue;Z[`import.meta.env.${J}`]=JSON.stringify(X),Y[J]=X}return Z["import.meta.env"]=JSON.stringify(Y),Z}var H0=()=>{};var T$=H(()=>{H0()});var y1=H(()=>{o();y()});var C1=()=>{};var I$=()=>{};import{deriveLayoutGroup as eX}from"stx-router/layout-metadata";var M$=H(()=>{C5();R0();$1();P5();v5();x5();X1();Z1();f5();w0();g5();h5();M0();a5();t5();e5();o();j1();$0();$$();Z$();X$();J$();G$();P1();Q$();J0();K$();V1();x();W$();_$();B$();H$();L1();O$();N$();T$();y1();C1();y();I$();y1();C1()});var D$=()=>{};var E$=H(()=>{j1();H0();y()});async function n($){return Bun.file($).exists()}var yJ;var x=H(()=>{w0();$0();J0();M$();H0();L1();D$();E$();yJ=new _0(500)});async function k$($,Z,Y,J){let X={gfm:!0,breaks:!1};return Z.forEach((G)=>{let Q=G.trim().replace(/['"]/g,"");if(Q==="breaks")X.breaks=!0;if(Q==="no-gfm")X.gfm=!1}),J1($.trim(),X)}var P1=H(()=>{x()});function n3($){if(p3.set($.name,$),$.client)i3.set($.name,$.client)}function D0($){return n3($),{name:$.name,hasEndTag:$.hasEndTag??!0,description:$.description,handler:async(Y,J,X,G)=>{let Q=o3(J,$.defaults);if($.validate){let K=$.validate(Q);if(K!==!0){let z=typeof K==="string"?K:`Invalid parameters for @${$.name}`;throw Error(z)}}let U=Y;if($.transform)U=await $.transform(Y,Q,X,G);if($.clientScript){let K=$.clientScript(Q);U+=`<script>${K}</script>`}if($.css){let K=$.css(Q);U+=`<style>${K}</style>`}return U}}}function o3($,Z){let Y={...Z};for(let J of $){let X=J.indexOf(":"),G=J.indexOf("="),Q=X>=0&&(G<0||X<G)?X:G;if(Q>=0){let U=J.slice(0,Q).trim(),K=J.slice(Q+1).trim();if(K==="true")K=!0;else if(K==="false")K=!1;else if(K==="null")K=null;else if(!Number.isNaN(Number(K)))K=Number(K);else if(typeof K==="string"&&K.startsWith("{"))try{K=JSON.parse(K)}catch{}Y[U]=K}else{let U=Object.keys(Y).filter((K)=>!Z||!(K in Z)).length;Y[U===0?"value":`arg${U}`]=J}}return Y}var p3,i3;var v1=H(()=>{p3=new Map,i3=new Map});function x1($,Z=Q0,Y={},J){return Z.sort((X,G)=>X-G).map((X)=>{return`${O0($,{...Y,w:X,fm:J})} ${X}w`}).join(", ")}function b$($,Z,Y=s3,J={},X){return Y.sort((G,Q)=>G-Q).map((G)=>{let Q=Math.round(Z*G);return`${O0($,{...J,w:Q,dpr:G,fm:X})} ${G}x`}).join(", ")}function f1($,Z="100vw"){if(!$||Object.keys($).length===0)return Z;let J=Object.entries($).map(([X,G])=>{let Q=/^\d+$/.test(X)?`${X}px`:X;return{bp:Q,size:G,numericBp:Number.parseInt(Q)||0}}).sort((X,G)=>X.numericBp-G.numericBp).map(({bp:X,size:G})=>`(max-width: ${X}) ${G}`);return J.push(Z),J.join(", ")}function O0($,Z={}){let Y=Object.entries(Z).filter(([,G])=>G!==void 0&&G!==null).map(([G,Q])=>{if(Array.isArray(Q))return[G,Q.join(",")];return[G,String(Q)]});if(Y.length===0)return $;let J=Y.map(([G,Q])=>`${G}=${encodeURIComponent(Q)}`).join("&"),X=$.includes("?")?"&":"?";return`${$}${X}${J}`}function g1($){return r3[$]||"application/octet-stream"}var Q0,s3,j0,r3;var h1=H(()=>{Q0=[320,480,640,768,1024,1280,1536,1920,2560],s3=[1,1.5,2,3],j0=["avif","webp","jpeg"],r3={avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif"}});async function t3(){try{return await import("ts-images")}catch{return null}}async function e3($,Z={}){let Y={...a3,...Z},J=await t3();if(J)try{return await $7($,Y,J)}catch(X){console.warn(`[stx-media] ts-images placeholder generation failed, using fallback: ${X}`)}return Z7($,Y)}async function $7($,Z,Y){let{generatePlaceholder:J,generateThumbHash:X}=Y,Q={blur:"blur",thumbhash:"thumbhash",blurhash:"thumbhash",pixelate:"pixelate","dominant-color":"dominant-color",none:"blur"}[Z.strategy]||"blur";if(Z.strategy==="thumbhash")return{dataURL:(await X($)).dataUrl,width:32,height:32,aspectRatio:1,originalWidth:0,originalHeight:0,strategy:"thumbhash"};let U=await J($,{width:Z.width,height:Z.height,quality:Z.quality,blurLevel:Z.blurLevel,strategy:Q,base64Encode:!0});return{dataURL:U.dataURL,width:U.width,height:U.height,aspectRatio:U.aspectRatio,originalWidth:U.originalWidth,originalHeight:U.originalHeight,strategy:Z.strategy,dominantColor:U.dominantColor,css:U.css}}function Z7($,Z){let Y=Z.width||20,J=Z.height||Y,X="#e5e7eb",G=`<svg xmlns="http://www.w3.org/2000/svg" width="${Y}" height="${J}" viewBox="0 0 ${Y} ${J}"><rect fill="#e5e7eb" width="${Y}" height="${J}"/></svg>`;return{dataURL:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(G)}`,width:Y,height:J,aspectRatio:Y/J,originalWidth:0,originalHeight:0,strategy:Z.strategy,dominantColor:"#e5e7eb"}}function S$($,Z,Y={}){let J=Y.transitionDuration||300,X=Y.easing||"ease-out";return`
|
|
515
515
|
#${$} {
|
|
516
516
|
--stx-img-transition-duration: ${J}ms;
|
|
517
517
|
--stx-img-transition-easing: ${X};
|
|
@@ -528,7 +528,7 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
|
|
|
528
528
|
#${$}.stx-img-loaded img {
|
|
529
529
|
opacity: 1;
|
|
530
530
|
}
|
|
531
|
-
`.trim()}async function y$($,Z={}){let Y=`${$}:${JSON.stringify(Z)}`;if(d1.has(Y))return d1.get(Y);let J=await e3($,Z);return d1.set(Y,J),J}var a3,
|
|
531
|
+
`.trim()}async function y$($,Z={}){let Y=`${$}:${JSON.stringify(Z)}`;if(d1.has(Y))return d1.get(Y);let J=await e3($,Z);return d1.set(Y,J),J}var a3,u1,d1;var C$=H(()=>{a3={strategy:"thumbhash",width:20,quality:50,blurLevel:40,transitionDuration:300,easing:"ease-out"},u1=`
|
|
532
532
|
.stx-img-placeholder {
|
|
533
533
|
position: relative;
|
|
534
534
|
overflow: hidden;
|
|
@@ -557,8 +557,8 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
|
|
|
557
557
|
filter: blur(0);
|
|
558
558
|
transform: scale(1);
|
|
559
559
|
}
|
|
560
|
-
`.trim();d1=new Map});import{createHash as v$}from"crypto";import{readFile as Y7,stat as x$}from"fs/promises";async function g($){try{let Z=await Y7($);return v$("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function P$($){return v$("sha256").update($).digest("hex").slice(0,16)}function E0($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${P$($)}-${P$(Y)}`}async function u1($){try{return(await x$($)).mtimeMs}catch{return 0}}async function C($){try{return await x$($),!0}catch{return!1}}var Z0=()=>{};import{mkdir as X7,readFile as J7,writeFile as G7,readdir as iJ,rm as Q7,stat as nJ}from"fs/promises";import{join as g$,dirname as K7}from"path";async function U7($){try{await X7($,{recursive:!0})}catch{}}function h$($,Z,Y){return g$($,Y,`${Z}.json`)}async function f$($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await u1(Z)!==$.srcMtime)return!1;return!0}async function k0($,Z,Y,J=l1){if(!J.enabled)return null;let X=E0($,Z),G=K0.get(X);if(G){if(await f$(G,$,J.maxAge))return G.lastAccessedAt=Date.now(),G.data;K0.delete(X)}let Q=h$(J.directory,X,Y);if(await C(Q))try{let U=await J7(Q,"utf-8"),K=JSON.parse(U);if(await f$(K,$,J.maxAge))return K.lastAccessedAt=Date.now(),K0.set(X,K),K.data}catch{}return null}async function b0($,Z,Y,J,X=l1){if(!X.enabled)return;let G=E0($,Z),Q=await g($),U=await u1($),K={key:G,src:$,srcHash:Q,srcMtime:U,optionsHash:E0("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};K0.set(G,K);let z=h$(X.directory,G,J);try{await U7(K7(z)),await G7(z,JSON.stringify(K,null,2))}catch(W){console.warn(`[stx-media] Failed to write cache: ${W}`)}}async function S0($,Z=l1){if($==="all")K0.clear();else K0.clear();let Y=$==="all"?["image","video"]:[$];for(let J of Y){let X=g$(Z.directory,J);try{await Q7(X,{recursive:!0,force:!0})}catch{}}}var K0,l1;var c1=H(()=>{Z0();K0=new Map,l1={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class C0{config;constructor($={}){this.config={...q7,...$}}async get($,Z){return k0($,Z,"image",this.config)}async set($,Z,Y){return b0($,Z,Y,"image",this.config)}async clear(){return S0("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function p1($){if(!y0)y0=new C0($);else if($)y0.updateConfig($);return y0}async function P0($,Z,Y){let J=Y?{directory:`${Y.outputDir}/../.cache`}:{};return p1(J).get($,Z)}async function v0($,Z,Y,J){let X=J?{directory:`${J.outputDir}/../.cache`}:{};return p1(X).set($,Z,Y)}async function d$(){return p1().clear()}var q7,y0=null;var i1=H(()=>{c1();q7={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as z7,basename as W7,extname as _7,join as B7}from"path";import{mkdir as H7}from"fs/promises";async function n1(){try{return await import("ts-images")}catch{return null}}function m$($){switch($){case"quality":return{jpeg:{quality:90,mozjpeg:!0,progressive:!0},png:{compressionLevel:6,palette:!1},webp:{quality:90,effort:6,smartSubsample:!0},avif:{quality:85,effort:6}};case"performance":return{jpeg:{quality:70,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!0},webp:{quality:70,effort:4,smartSubsample:!0},avif:{quality:60,effort:2}};case"web":default:return{jpeg:{quality:82,mozjpeg:!0,progressive:!0},png:{compressionLevel:8,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4}}}}function j7($,Z){let Y=Z?m$(Z):m$("web"),J=$.formatQuality||{};return{jpeg:{...Y.jpeg,...J.jpeg},png:{...Y.png,...J.png},webp:{...Y.webp,...J.webp},avif:{...Y.avif,...J.avif}}}async function u$($,Z,Y){let J=await n1();if(!J)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let X=await P0($,Z,Y);if(X)return X;try{let G=z7($);if(!await C(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let Q=j7(Y,Z.preset),U=Y.outputDir||"dist/images",K=Y.baseUrl||"/images";await H7(U,{recursive:!0});let z=await g(G),W=W7($,_7($)),q=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],_={src:$,processed:!0,variants:[],hash:z},j=null;if(Z.transformations&&Z.transformations.length>0)j=await o1(G,Z.transformations,J);for(let B of q){let V=Q[B]||{},O=`${W}-${z}.${B}`,L=B7(U,O);try{let F=await J.optimizeImage({input:j||G,output:L,format:B,quality:V.quality,progressive:V.progressive});if(F){if(_.variants.push({path:L,url:`${K}/${O}`,width:F.width||0,height:F.height||0,format:B,size:F.outputSize||0}),!_.originalWidth&&F.width)_.originalWidth=F.width,_.originalHeight=F.height}}catch(F){_.errors=_.errors||[],_.errors.push(`Failed to optimize ${B}: ${F}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let B=await J.generateThumbHash(G);_.placeholder=B.dataUrl}catch(B){_.errors=_.errors||[],_.errors.push(`Failed to generate thumbhash: ${B}`)}if(Z.useDominantColor)try{let B=await J.generatePlaceholder(G,{strategy:"dominant-color"});_.dominantColor=B.dominantColor}catch(B){_.errors=_.errors||[],_.errors.push(`Failed to extract dominant color: ${B}`)}return await v0($,Z,_,Y),_}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function l$($,Z,Y,J){let X=await n1();if(!X)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await X.optimizeImage({input:$,output:J,format:Z,quality:Y}))?.outputSize}}catch(G){return{success:!1,error:String(G)}}}async function o1($,Z,Y){let J=Y||await n1();if(!J)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let X=await J.decode($);for(let G of Z){let Q=G.options||{};switch(G.type){case"resize":if(Q.width||Q.height)X=await J.resize(X,{width:Q.width,height:Q.height,fit:Q.fit});break;case"blur":if(Q.sigma!==void 0)X=await J.blur(X,Q.sigma);break;case"sharpen":if(Q.amount!==void 0)X=await J.sharpen(X,Q.amount);break;case"grayscale":X=await J.grayscale(X);break;case"rotate":if(Q.angle!==void 0)X=await J.rotate(X,Q.angle);break;case"flip":X=await J.flip(X);break;case"flop":X=await J.flop(X);break;case"brightness":if(Q.value!==void 0)X=await J.brightness(X,Q.value);break;case"contrast":if(Q.value!==void 0)X=await J.contrast(X,Q.value);break;case"saturation":if(Q.value!==void 0)X=await J.saturation(X,Q.value);break}}return await J.encode(X,"png")}catch(X){return console.error(`[stx-media] Transformation failed: ${X}`),null}}var c$=H(()=>{Z0();i1()});import{resolve as O7,basename as V7,extname as L7,join as F7}from"path";import{mkdir as w7}from"fs/promises";async function R7(){try{return await import("ts-images")}catch{return null}}async function p$($,Z,Y){let J=await R7();if(!J)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let X=O7($);if(!await C(X))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let G=Z.responsiveWidths||Y.breakpoints||A7,Q=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],U=Y.outputDir||"dist/images",K=Y.baseUrl||"/images";await w7(U,{recursive:!0});let z=await g(X),W=V7($,L7($)),q=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},_={src:$,byFormat:{},srcsets:{}};for(let B of Q){_.byFormat[B]=[];let V=[];for(let O of G){let L=`${W}-${O}w-${z}.${B}`,F=F7(U,L),w=`${K}/${L}`;try{let T=q[B]?.quality||80;if(await C(F)){_.byFormat[B].push({path:F,url:w,width:O,height:0,format:B,size:0}),V.push(`${w} ${O}w`);continue}let R=await J.processImage({input:X,output:F,format:B,quality:T,resize:{width:O}});if(R)_.byFormat[B].push({path:F,url:w,width:O,height:R.height||Math.round(O*(R.height||1)/(R.width||1)),format:B,size:R.outputSize||0}),V.push(`${w} ${O}w`)}catch(T){console.warn(`[stx-media] Failed to generate ${B} at ${O}w: ${T}`)}}_.srcsets[B]=V.join(", ")}let j=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(j!=="none")try{if(j==="thumbhash"){let B=await J.generateThumbHash(X);_.placeholder={dataURL:B.dataUrl,width:B.width||32,height:B.height||32,strategy:"thumbhash"}}else{let B=await J.generatePlaceholder(X,{strategy:j,width:20});_.placeholder={dataURL:B.dataURL,width:B.width,height:B.height,strategy:j}}}catch(B){console.warn(`[stx-media] Failed to generate placeholder: ${B}`)}return _.sizes=Z.sizes||N7(G),_}catch(G){return console.error(`[stx-media] Responsive generation failed: ${G}`),null}}function N7($){let Z=[...$].sort((J,X)=>J-X),Y=[];for(let J=0;J<Z.length-1;J++){let X=Z[J];Y.push(`(max-width: ${X}px) ${X}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function i$($,Z="width"){if(!$||$.length===0)return"";if(Z==="dpr")return $.filter((Y)=>Y.dpr).map((Y)=>`${Y.url} ${Y.dpr}x`).join(", ");return $.map((Y)=>`${Y.url} ${Y.width}w`).join(", ")}var A7;var n$=H(()=>{Z0();A7=[320,480,640,768,1024,1280,1536,1920]});var o$={};e0(o$,{setCachedImageResult:()=>v0,processImage:()=>u$,optimizeImage:()=>l$,getCachedImageResult:()=>P0,generateSrcset:()=>i$,generateResponsiveVariants:()=>p$,clearImageCache:()=>d$,applyTransformations:()=>o1,ImageProcessorCache:()=>C0});var s$=H(()=>{c$();n$();i1()});async function T7(){try{return await Promise.resolve().then(() => (s$(),o$))}catch($){if(!r$)console.warn("[stx-media] Image processor not available, some features disabled:",$),r$=!0;return null}}async function x0($,Z={}){let Y=Z,J=$;if(J.process&&!J.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return E7(J,Y)}if(Y.processedResult?.processed)return t1($,Y.processedResult,Z);if(Y.responsiveVariants)return $4($,Y.responsiveVariants,Z);let{src:X,alt:G,width:Q,height:U,sizes:K,widths:z=Q0,dpr:W,formats:q=j0,quality:_=s1,params:j={},placeholder:B="none",placeholderOptions:V={},lazy:O=!0,priority:L=!1,loading:F=L?"eager":g0,decoding:w=f0,fetchpriority:T,objectFit:R,objectPosition:N,crossorigin:A,referrerpolicy:P}=$,d=$.class,D=$.style,b=$.id,I=$.data||{},{isDev:v=!1,baseUrl:t=""}=Z;if(v&&!Z.optimize)return D7($);let m,M,c=b||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(B!=="none"&&!L)try{m=await y$(X,{strategy:B,...V}),M=S$(c,m,V)}catch{}let L0=W!==void 0&&Q!==void 0,X0;if(L0)X0=M7($,c,m,Z);else X0=await I7($,c,m,Z);let z0;if(L){let j5=q.includes("webp")?"webp":q[0],f4=x1(X,z,{...j,q:_},j5),g4=typeof K==="object"?f1(K):K||"100vw";z0=`<link rel="preload" as="image" imagesrcset="${f4}" imagesizes="${g4}" />`}let F0=[];if(!a$&&B!=="none")F0.push(m1),a$=!0;if(M)F0.push(M);let x4=O?e$(c):void 0;return{html:X0,preloadLink:z0,css:F0.length>0?F0.join(`
|
|
561
|
-
`):void 0,script:x4}}async function I7($,Z,Y,J){let{src:X,alt:G,width:Q,height:U,sizes:K,widths:z=Q0,formats:W=j0,quality:q=s1,params:_={},lazy:j=!0,priority:B=!1,loading:V=B?"eager":g0,decoding:O=f0,fetchpriority:L,objectFit:F,objectPosition:w,crossorigin:T,referrerpolicy:R}=$,N=$.class,A=$.style,P=$.data||{},d=typeof K==="object"?f1(K):K||"100vw",D=[];for(let v of W){let t=x1(X,z,{..._,q},v),
|
|
560
|
+
`.trim();d1=new Map});import{createHash as v$}from"crypto";import{readFile as Y7,stat as x$}from"fs/promises";async function g($){try{let Z=await Y7($);return v$("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function P$($){return v$("sha256").update($).digest("hex").slice(0,16)}function E0($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${P$($)}-${P$(Y)}`}async function m1($){try{return(await x$($)).mtimeMs}catch{return 0}}async function C($){try{return await x$($),!0}catch{return!1}}var Z0=()=>{};import{mkdir as X7,readFile as J7,writeFile as G7,readdir as iJ,rm as Q7,stat as nJ}from"fs/promises";import{join as g$,dirname as K7}from"path";async function U7($){try{await X7($,{recursive:!0})}catch{}}function h$($,Z,Y){return g$($,Y,`${Z}.json`)}async function f$($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await m1(Z)!==$.srcMtime)return!1;return!0}async function k0($,Z,Y,J=l1){if(!J.enabled)return null;let X=E0($,Z),G=K0.get(X);if(G){if(await f$(G,$,J.maxAge))return G.lastAccessedAt=Date.now(),G.data;K0.delete(X)}let Q=h$(J.directory,X,Y);if(await C(Q))try{let U=await J7(Q,"utf-8"),K=JSON.parse(U);if(await f$(K,$,J.maxAge))return K.lastAccessedAt=Date.now(),K0.set(X,K),K.data}catch{}return null}async function b0($,Z,Y,J,X=l1){if(!X.enabled)return;let G=E0($,Z),Q=await g($),U=await m1($),K={key:G,src:$,srcHash:Q,srcMtime:U,optionsHash:E0("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};K0.set(G,K);let z=h$(X.directory,G,J);try{await U7(K7(z)),await G7(z,JSON.stringify(K,null,2))}catch(W){console.warn(`[stx-media] Failed to write cache: ${W}`)}}async function S0($,Z=l1){if($==="all")K0.clear();else K0.clear();let Y=$==="all"?["image","video"]:[$];for(let J of Y){let X=g$(Z.directory,J);try{await Q7(X,{recursive:!0,force:!0})}catch{}}}var K0,l1;var c1=H(()=>{Z0();K0=new Map,l1={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class C0{config;constructor($={}){this.config={...q7,...$}}async get($,Z){return k0($,Z,"image",this.config)}async set($,Z,Y){return b0($,Z,Y,"image",this.config)}async clear(){return S0("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function p1($){if(!y0)y0=new C0($);else if($)y0.updateConfig($);return y0}async function P0($,Z,Y){let J=Y?{directory:`${Y.outputDir}/../.cache`}:{};return p1(J).get($,Z)}async function v0($,Z,Y,J){let X=J?{directory:`${J.outputDir}/../.cache`}:{};return p1(X).set($,Z,Y)}async function d$(){return p1().clear()}var q7,y0=null;var i1=H(()=>{c1();q7={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as z7,basename as W7,extname as _7,join as B7}from"path";import{mkdir as H7}from"fs/promises";async function n1(){try{return await import("ts-images")}catch{return null}}function u$($){switch($){case"quality":return{jpeg:{quality:90,mozjpeg:!0,progressive:!0},png:{compressionLevel:6,palette:!1},webp:{quality:90,effort:6,smartSubsample:!0},avif:{quality:85,effort:6}};case"performance":return{jpeg:{quality:70,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!0},webp:{quality:70,effort:4,smartSubsample:!0},avif:{quality:60,effort:2}};case"web":default:return{jpeg:{quality:82,mozjpeg:!0,progressive:!0},png:{compressionLevel:8,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4}}}}function j7($,Z){let Y=Z?u$(Z):u$("web"),J=$.formatQuality||{};return{jpeg:{...Y.jpeg,...J.jpeg},png:{...Y.png,...J.png},webp:{...Y.webp,...J.webp},avif:{...Y.avif,...J.avif}}}async function m$($,Z,Y){let J=await n1();if(!J)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let X=await P0($,Z,Y);if(X)return X;try{let G=z7($);if(!await C(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let Q=j7(Y,Z.preset),U=Y.outputDir||"dist/images",K=Y.baseUrl||"/images";await H7(U,{recursive:!0});let z=await g(G),W=W7($,_7($)),q=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],_={src:$,processed:!0,variants:[],hash:z},j=null;if(Z.transformations&&Z.transformations.length>0)j=await o1(G,Z.transformations,J);for(let B of q){let V=Q[B]||{},O=`${W}-${z}.${B}`,L=B7(U,O);try{let F=await J.optimizeImage({input:j||G,output:L,format:B,quality:V.quality,progressive:V.progressive});if(F){if(_.variants.push({path:L,url:`${K}/${O}`,width:F.width||0,height:F.height||0,format:B,size:F.outputSize||0}),!_.originalWidth&&F.width)_.originalWidth=F.width,_.originalHeight=F.height}}catch(F){_.errors=_.errors||[],_.errors.push(`Failed to optimize ${B}: ${F}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let B=await J.generateThumbHash(G);_.placeholder=B.dataUrl}catch(B){_.errors=_.errors||[],_.errors.push(`Failed to generate thumbhash: ${B}`)}if(Z.useDominantColor)try{let B=await J.generatePlaceholder(G,{strategy:"dominant-color"});_.dominantColor=B.dominantColor}catch(B){_.errors=_.errors||[],_.errors.push(`Failed to extract dominant color: ${B}`)}return await v0($,Z,_,Y),_}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function l$($,Z,Y,J){let X=await n1();if(!X)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await X.optimizeImage({input:$,output:J,format:Z,quality:Y}))?.outputSize}}catch(G){return{success:!1,error:String(G)}}}async function o1($,Z,Y){let J=Y||await n1();if(!J)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let X=await J.decode($);for(let G of Z){let Q=G.options||{};switch(G.type){case"resize":if(Q.width||Q.height)X=await J.resize(X,{width:Q.width,height:Q.height,fit:Q.fit});break;case"blur":if(Q.sigma!==void 0)X=await J.blur(X,Q.sigma);break;case"sharpen":if(Q.amount!==void 0)X=await J.sharpen(X,Q.amount);break;case"grayscale":X=await J.grayscale(X);break;case"rotate":if(Q.angle!==void 0)X=await J.rotate(X,Q.angle);break;case"flip":X=await J.flip(X);break;case"flop":X=await J.flop(X);break;case"brightness":if(Q.value!==void 0)X=await J.brightness(X,Q.value);break;case"contrast":if(Q.value!==void 0)X=await J.contrast(X,Q.value);break;case"saturation":if(Q.value!==void 0)X=await J.saturation(X,Q.value);break}}return await J.encode(X,"png")}catch(X){return console.error(`[stx-media] Transformation failed: ${X}`),null}}var c$=H(()=>{Z0();i1()});import{resolve as O7,basename as V7,extname as L7,join as F7}from"path";import{mkdir as w7}from"fs/promises";async function R7(){try{return await import("ts-images")}catch{return null}}async function p$($,Z,Y){let J=await R7();if(!J)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let X=O7($);if(!await C(X))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let G=Z.responsiveWidths||Y.breakpoints||A7,Q=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],U=Y.outputDir||"dist/images",K=Y.baseUrl||"/images";await w7(U,{recursive:!0});let z=await g(X),W=V7($,L7($)),q=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},_={src:$,byFormat:{},srcsets:{}};for(let B of Q){_.byFormat[B]=[];let V=[];for(let O of G){let L=`${W}-${O}w-${z}.${B}`,F=F7(U,L),w=`${K}/${L}`;try{let T=q[B]?.quality||80;if(await C(F)){_.byFormat[B].push({path:F,url:w,width:O,height:0,format:B,size:0}),V.push(`${w} ${O}w`);continue}let R=await J.processImage({input:X,output:F,format:B,quality:T,resize:{width:O}});if(R)_.byFormat[B].push({path:F,url:w,width:O,height:R.height||Math.round(O*(R.height||1)/(R.width||1)),format:B,size:R.outputSize||0}),V.push(`${w} ${O}w`)}catch(T){console.warn(`[stx-media] Failed to generate ${B} at ${O}w: ${T}`)}}_.srcsets[B]=V.join(", ")}let j=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(j!=="none")try{if(j==="thumbhash"){let B=await J.generateThumbHash(X);_.placeholder={dataURL:B.dataUrl,width:B.width||32,height:B.height||32,strategy:"thumbhash"}}else{let B=await J.generatePlaceholder(X,{strategy:j,width:20});_.placeholder={dataURL:B.dataURL,width:B.width,height:B.height,strategy:j}}}catch(B){console.warn(`[stx-media] Failed to generate placeholder: ${B}`)}return _.sizes=Z.sizes||N7(G),_}catch(G){return console.error(`[stx-media] Responsive generation failed: ${G}`),null}}function N7($){let Z=[...$].sort((J,X)=>J-X),Y=[];for(let J=0;J<Z.length-1;J++){let X=Z[J];Y.push(`(max-width: ${X}px) ${X}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function i$($,Z="width"){if(!$||$.length===0)return"";if(Z==="dpr")return $.filter((Y)=>Y.dpr).map((Y)=>`${Y.url} ${Y.dpr}x`).join(", ");return $.map((Y)=>`${Y.url} ${Y.width}w`).join(", ")}var A7;var n$=H(()=>{Z0();A7=[320,480,640,768,1024,1280,1536,1920]});var o$={};e0(o$,{setCachedImageResult:()=>v0,processImage:()=>m$,optimizeImage:()=>l$,getCachedImageResult:()=>P0,generateSrcset:()=>i$,generateResponsiveVariants:()=>p$,clearImageCache:()=>d$,applyTransformations:()=>o1,ImageProcessorCache:()=>C0});var s$=H(()=>{c$();n$();i1()});async function T7(){try{return await Promise.resolve().then(() => (s$(),o$))}catch($){if(!r$)console.warn("[stx-media] Image processor not available, some features disabled:",$),r$=!0;return null}}async function x0($,Z={}){let Y=Z,J=$;if(J.process&&!J.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return E7(J,Y)}if(Y.processedResult?.processed)return t1($,Y.processedResult,Z);if(Y.responsiveVariants)return $4($,Y.responsiveVariants,Z);let{src:X,alt:G,width:Q,height:U,sizes:K,widths:z=Q0,dpr:W,formats:q=j0,quality:_=s1,params:j={},placeholder:B="none",placeholderOptions:V={},lazy:O=!0,priority:L=!1,loading:F=L?"eager":g0,decoding:w=f0,fetchpriority:T,objectFit:R,objectPosition:N,crossorigin:A,referrerpolicy:P}=$,d=$.class,D=$.style,b=$.id,I=$.data||{},{isDev:v=!1,baseUrl:t=""}=Z;if(v&&!Z.optimize)return D7($);let u,M,c=b||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(B!=="none"&&!L)try{u=await y$(X,{strategy:B,...V}),M=S$(c,u,V)}catch{}let L0=W!==void 0&&Q!==void 0,X0;if(L0)X0=M7($,c,u,Z);else X0=await I7($,c,u,Z);let z0;if(L){let j5=q.includes("webp")?"webp":q[0],f4=x1(X,z,{...j,q:_},j5),g4=typeof K==="object"?f1(K):K||"100vw";z0=`<link rel="preload" as="image" imagesrcset="${f4}" imagesizes="${g4}" />`}let F0=[];if(!a$&&B!=="none")F0.push(u1),a$=!0;if(M)F0.push(M);let x4=O?e$(c):void 0;return{html:X0,preloadLink:z0,css:F0.length>0?F0.join(`
|
|
561
|
+
`):void 0,script:x4}}async function I7($,Z,Y,J){let{src:X,alt:G,width:Q,height:U,sizes:K,widths:z=Q0,formats:W=j0,quality:q=s1,params:_={},lazy:j=!0,priority:B=!1,loading:V=B?"eager":g0,decoding:O=f0,fetchpriority:L,objectFit:F,objectPosition:w,crossorigin:T,referrerpolicy:R}=$,N=$.class,A=$.style,P=$.data||{},d=typeof K==="object"?f1(K):K||"100vw",D=[];for(let v of W){let t=x1(X,z,{..._,q},v),u=g1(v);if(j&&!B)D.push(` <source type="${u}" data-srcset="${t}" data-sizes="${d}" />`);else D.push(` <source type="${u}" srcset="${t}" sizes="${d}" />`)}let b=r1({src:O0(X,{..._,q}),alt:G,width:Q,height:U,loading:B?void 0:V,decoding:O,fetchpriority:B?"high":L,objectFit:F,objectPosition:w,crossorigin:T,referrerpolicy:R,className:t$(N,Y),style:a1(A,F,w,Y),lazy:j&&!B,data:P}),I;if(Y){let v=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;I=`<div id="${Z}" class="stx-img-placeholder" style="${v}">
|
|
562
562
|
<picture>
|
|
563
563
|
${D.join(`
|
|
564
564
|
`)}
|
|
@@ -617,11 +617,11 @@ ${R.join(`
|
|
|
617
617
|
${R.join(`
|
|
618
618
|
`)}
|
|
619
619
|
<img ${A.join(" ")} />
|
|
620
|
-
</picture>`;let v=[];if(Z.placeholder)v.push(
|
|
620
|
+
</picture>`;let v=[];if(Z.placeholder)v.push(u1);let t=Q?e$(B):void 0,u;if(U&&w)u=`<link rel="preload" as="image" imagesrcset="${w}" />`;return{html:I,preloadLink:u,css:v.length>0?v.join(`
|
|
621
621
|
`):void 0,script:t}}async function $4($,Z,Y){let J={src:Z.src,processed:!0,variants:[],placeholder:Z.placeholder?.dataURL,originalWidth:Z.placeholder?.width,originalHeight:Z.placeholder?.height};for(let[X,G]of Object.entries(Z.byFormat))if(G)J.variants.push(...G);return t1($,J,Y)}var r$=!1,s1=80,f0="async",g0="lazy",a$=!1;var Z4=H(()=>{h1();C$()});function k7(){return D0({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async($,Z,Y,J)=>{let{src:X,alt:G,options:Q}=b7($,Z,Y);if(!X)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let U={src:X,alt:G||"",widths:Q.widths||Q0,formats:Q.formats||j0,quality:Q.quality,sizes:Q.sizes,dpr:Q.dpr,params:Q.params,placeholder:Q.placeholder,placeholderOptions:Q.placeholderOptions,lazy:Q.lazy!==!1,priority:Q.priority||!1,loading:Q.loading,decoding:Q.decoding,fetchpriority:Q.fetchpriority,objectFit:Q.objectFit,objectPosition:Q.objectPosition,class:Q.class,style:Q.style,id:Q.id,width:Q.width,height:Q.height},K=Y.__isDev||!1,z=await x0(U,{isDev:K}),W=z.html;if(z.preloadLink)W=z.preloadLink+`
|
|
622
622
|
`+W;if(z.css)W+=`
|
|
623
623
|
<style>${z.css}</style>`;if(z.script)W+=`
|
|
624
|
-
<script>${z.script}</script>`;return W},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function b7($,Z,Y){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),options:Z.options||{}};let J=$.trim();if(J.startsWith("@img(")||J.startsWith("("))J=J.replace(/^@img\(/,"").replace(/^\(/,"").replace(/\)$/,"");let X=S7(J),G=e1(X[0],Y)||"",Q=e1(X[1],Y)||"",U={};if(X[2]){let K=e1(X[2],Y);if(typeof K==="object"&&K!==null)U=K;else if(typeof X[2]==="string")try{U=JSON.parse(X[2])}catch{}}return{src:G,alt:Q,options:U}}function S7($){let Z=[],Y="",J=!1,X="",G=0,Q=0;for(let U=0;U<$.length;U++){let K=$[U],z=U>0?$[U-1]:"";if((K==='"'||K==="'"||K==="`")&&z!=="\\"){if(!J)J=!0,X=K;else if(K===X)J=!1,X="";else Y+=K;continue}if(!J){if(K==="{")G++;if(K==="}")G--;if(K==="[")Q++;if(K==="]")Q--;if(K===","&&G===0&&Q===0){Z.push(Y.trim()),Y="";continue}}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function e1($,Z){if(typeof $!=="string")return $;let Y=$.trim();if(Y.startsWith('"')&&Y.endsWith('"')||Y.startsWith("'")&&Y.endsWith("'"))return Y.slice(1,-1);if(!Y.startsWith("/")&&!Y.startsWith(".")&&!Y.startsWith("http")&&!Y.startsWith("{")){let J=Z[Y];if(J!==void 0)return J}if(Y.startsWith("{")||Y.startsWith("["))try{return JSON.parse(Y)}catch{}return Y}var Y4;var X4=H(()=>{v1();Z4();h1();Y4=k7()});class d0{config;constructor($={}){this.config={...y7,...$}}async get($,Z){return k0($,Z,"video",this.config)}async set($,Z,Y){return b0($,Z,Y,"video",this.config)}async clear(){return S0("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function $5($){if(!h0)h0=new d0($);else if($)h0.updateConfig($);return h0}async function
|
|
624
|
+
<script>${z.script}</script>`;return W},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function b7($,Z,Y){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),options:Z.options||{}};let J=$.trim();if(J.startsWith("@img(")||J.startsWith("("))J=J.replace(/^@img\(/,"").replace(/^\(/,"").replace(/\)$/,"");let X=S7(J),G=e1(X[0],Y)||"",Q=e1(X[1],Y)||"",U={};if(X[2]){let K=e1(X[2],Y);if(typeof K==="object"&&K!==null)U=K;else if(typeof X[2]==="string")try{U=JSON.parse(X[2])}catch{}}return{src:G,alt:Q,options:U}}function S7($){let Z=[],Y="",J=!1,X="",G=0,Q=0;for(let U=0;U<$.length;U++){let K=$[U],z=U>0?$[U-1]:"";if((K==='"'||K==="'"||K==="`")&&z!=="\\"){if(!J)J=!0,X=K;else if(K===X)J=!1,X="";else Y+=K;continue}if(!J){if(K==="{")G++;if(K==="}")G--;if(K==="[")Q++;if(K==="]")Q--;if(K===","&&G===0&&Q===0){Z.push(Y.trim()),Y="";continue}}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function e1($,Z){if(typeof $!=="string")return $;let Y=$.trim();if(Y.startsWith('"')&&Y.endsWith('"')||Y.startsWith("'")&&Y.endsWith("'"))return Y.slice(1,-1);if(!Y.startsWith("/")&&!Y.startsWith(".")&&!Y.startsWith("http")&&!Y.startsWith("{")){let J=Z[Y];if(J!==void 0)return J}if(Y.startsWith("{")||Y.startsWith("["))try{return JSON.parse(Y)}catch{}return Y}var Y4;var X4=H(()=>{v1();Z4();h1();Y4=k7()});class d0{config;constructor($={}){this.config={...y7,...$}}async get($,Z){return k0($,Z,"video",this.config)}async set($,Z,Y){return b0($,Z,Y,"video",this.config)}async clear(){return S0("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function $5($){if(!h0)h0=new d0($);else if($)h0.updateConfig($);return h0}async function u0($,Z,Y){let J=Y?{directory:`${Y.outputDir}/../.cache`}:{};return $5(J).get($,Z)}async function m0($,Z,Y,J){let X=J?{directory:`${J.outputDir}/../.cache`}:{};return $5(X).set($,Z,Y)}async function J4(){return $5().clear()}var y7,h0=null;var Z5=H(()=>{c1();y7={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as Y5,basename as X5,extname as J5,join as l0}from"path";import{mkdir as G5}from"fs/promises";async function Q5(){try{return await import("ts-videos")}catch{return null}}async function c0($,Z,Y,J){let X=await Q5();if(!X)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let G=Y5($);if(!await C(G))return null;await G5(Y,{recursive:!0});let Q=await g(G),U=X5($,J5($)),K=Z.format||"webp",z=Z.timestamp||0,W=`${U}-poster-${Q}.${K}`,q=l0(Y,W),_=await X.extractThumbnails(G,{timestamps:[z],width:Z.width||1280,height:Z.height,format:K,quality:Z.quality||85,outputDir:Y,outputPattern:W.replace(`.${K}`,"")});if(_&&_.length>0){let j=_[0];return{path:q,url:`${J}/${W}`,width:j.width||Z.width||1280,height:j.height||720,timestamp:z,size:j.size||0}}return null}catch(G){return console.warn(`[stx-media] Failed to generate poster: ${G}`),null}}async function p0($,Z,Y,J){let X=await Q5();if(!X)return[];try{let G=Y5($);if(!await C(G))return[];await G5(Y,{recursive:!0});let Q=await g(G),U=X5($,J5($)),K=Z.format||"webp",q=(await new X.Input(G).getInfo()).duration||60,_=Z.count||10,j=Z.interval||q/_,B=[];for(let O=0;O<_&&O*j<q;O++)B.push(O*j);let V=await X.extractThumbnails(G,{timestamps:B,width:Z.width||320,format:K,quality:Z.quality||80,outputDir:Y,outputPattern:`${U}-thumb-${Q}`});if(V&&V.length>0)return V.map((O,L)=>({path:O.path||l0(Y,`${U}-thumb-${Q}-${L}.${K}`),url:`${J}/${U}-thumb-${Q}-${L}.${K}`,width:O.width||Z.width||320,height:O.height||180,timestamp:B[L],size:O.size||0}));return[]}catch(G){return console.warn(`[stx-media] Failed to generate thumbnails: ${G}`),[]}}async function G4($,Z,Y,J){let X=await Q5();if(!X)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let G=Y5($);if(!await C(G))return null;await G5(Y,{recursive:!0});let Q=await g(G),U=X5($,J5($)),W=(await new X.Input(G).getInfo()).duration||60,q=Z.columns||10,_=Z.interval||5,j=Z.thumbnailWidth||160,B=Z.thumbnailHeight||90,V=Z.format||"jpeg",O=Math.ceil(W/_),L=Math.ceil(O/q),F=`${U}-sprite-${Q}.${V}`,w=l0(Y,F),T=[];for(let N=0;N<O;N++)T.push(N*_);let R=await X.extractThumbnails(G,{timestamps:T,width:j,height:B,format:V,quality:Z.quality||70,outputDir:l0(Y,".temp")});if(!R||R.length===0)return null;try{let N=await import("ts-images"),A=q*j,P=L*B,d=await N.createSprite({images:R.map((D)=>D.path),columns:q,padding:0,outputPath:w,format:V,quality:Z.quality||70});return{url:`${J}/${F}`,path:w,columns:q,rows:L,thumbnailWidth:j,thumbnailHeight:B,interval:_,totalFrames:O}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(G){return console.warn(`[stx-media] Failed to generate sprite sheet: ${G}`),null}}var K5=H(()=>{Z0()});import{resolve as K4,basename as U4,extname as q4,join as Y0}from"path";import{mkdir as i0,writeFile as z4}from"fs/promises";async function W4(){try{return await import("ts-videos")}catch{return null}}async function n0($,Z,Y,J,X){let G=await W4();if(!G)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let Q=K4($);if(!await C(Q))return null;let U=await g(Q),K=U4($,q4($)),z=Y0(Y,`${K}-${U}-hls`);await i0(z,{recursive:!0});let W=Z.length>0?Z:_4,q=X?.segmentDuration||6,B=(await new G.Input(Q).getInfo()).duration||0,V=[],O=0;for(let w of W){let T=Y0(z,w.label);await i0(T,{recursive:!0});let R=`${w.label}.m3u8`,N=Y0(T,R);try{let A=await G.generateHLS(Q,{outputDir:T,segmentDuration:q,width:w.width,height:w.height,videoBitrate:w.bitrate,audioBitrate:w.audioBitrate,playlistName:w.label});if(A)V.push({quality:w,url:`${J}/${K}-${U}-hls/${w.label}/${R}`,path:N}),O+=A.segmentCount||Math.ceil(B/q)}catch(A){console.warn(`[stx-media] Failed to generate HLS for ${w.label}: ${A}`)}}if(V.length===0)return null;let L=Y0(z,"master.m3u8"),F=C7(V,J,K,U);return await z4(L,F),{manifestUrl:`${J}/${K}-${U}-hls/master.m3u8`,manifestPath:L,playlists:V,segmentCount:O,duration:B}}catch(Q){return console.warn(`[stx-media] Failed to generate HLS manifest: ${Q}`),null}}function C7($,Z,Y,J){let X=["#EXTM3U","#EXT-X-VERSION:3"];for(let G of $){let{quality:Q}=G,U=Q.bitrate+(Q.audioBitrate||128000),K=`${Q.width}x${Q.height||Math.round(Q.width*9/16)}`;X.push(`#EXT-X-STREAM-INF:BANDWIDTH=${U},RESOLUTION=${K},NAME="${Q.label}"`,`${Q.label}/${Q.label}.m3u8`)}return X.join(`
|
|
625
625
|
`)}async function o0($,Z,Y,J,X){let G=await W4();if(!G)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let Q=K4($);if(!await C(Q))return null;let U=await g(Q),K=U4($,q4($)),z=Y0(Y,`${K}-${U}-dash`);await i0(z,{recursive:!0});let W=Z.length>0?Z:_4,q=X?.segmentDuration||4,_=X?.minBufferTime||2,V=(await new G.Input(Q).getInfo()).duration||0,O=[],L=[];for(let R of W){let N=Y0(z,R.label);await i0(N,{recursive:!0});try{if(await G.generateDASH(Q,{outputDir:N,segmentDuration:q,width:R.width,height:R.height,videoBitrate:R.bitrate,audioBitrate:R.audioBitrate})){if(O.push({bandwidth:R.bitrate,width:R.width,height:R.height||Math.round(R.width*9/16),url:`${J}/${K}-${U}-dash/${R.label}/video`}),R.audioBitrate)L.push({bandwidth:R.audioBitrate,url:`${J}/${K}-${U}-dash/${R.label}/audio`})}}catch(A){console.warn(`[stx-media] Failed to generate DASH for ${R.label}: ${A}`)}}if(O.length===0)return null;let F=Y0(z,"manifest.mpd"),w=P7(O,L,V,q,_);await z4(F,w);let T=[{type:"video",representations:O}];if(L.length>0)T.push({type:"audio",representations:L});return{manifestUrl:`${J}/${K}-${U}-dash/manifest.mpd`,manifestPath:F,adaptationSets:T,duration:V}}catch(Q){return console.warn(`[stx-media] Failed to generate DASH manifest: ${Q}`),null}}function P7($,Z,Y,J,X){let G=Q4(Y),Q=Q4(X),U=`<?xml version="1.0" encoding="UTF-8"?>
|
|
626
626
|
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
|
|
627
627
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
@@ -648,11 +648,11 @@ ${R.join(`
|
|
|
648
648
|
</Representation>
|
|
649
649
|
`}U+=` </AdaptationSet>
|
|
650
650
|
`}return U+=` </Period>
|
|
651
|
-
</MPD>`,U}function Q4($){let Z=Math.floor($/3600),Y=Math.floor($%3600/60),J=Math.floor($%60),X="PT";if(Z>0)X+=`${Z}H`;if(Y>0)X+=`${Y}M`;return X+=`${J}S`,X}var _4;var U5=H(()=>{Z0();_4=[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}]});import{resolve as B4,basename as v7,extname as x7,join as f7}from"path";import{mkdir as g7}from"fs/promises";async function H4(){try{return await import("ts-videos")}catch{return null}}function h7($){switch($){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function d7($){switch($){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function q5($){let Z=await H4();if(!Z)return null;try{let Y=B4($),X=await new Z.Input(Y).getInfo();return{duration:X.duration||0,width:X.width||0,height:X.height||0,frameRate:X.frameRate||0,bitrate:X.bitrate||0,codec:X.videoCodec||"",audioCodec:X.audioCodec}}catch(Y){return console.warn(`[stx-media] Failed to analyze video: ${Y}`),null}}async function j4($,Z,Y,J){let X=await H4();if(!X)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let G=await
|
|
651
|
+
</MPD>`,U}function Q4($){let Z=Math.floor($/3600),Y=Math.floor($%3600/60),J=Math.floor($%60),X="PT";if(Z>0)X+=`${Z}H`;if(Y>0)X+=`${Y}M`;return X+=`${J}S`,X}var _4;var U5=H(()=>{Z0();_4=[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}]});import{resolve as B4,basename as v7,extname as x7,join as f7}from"path";import{mkdir as g7}from"fs/promises";async function H4(){try{return await import("ts-videos")}catch{return null}}function h7($){switch($){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function d7($){switch($){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function q5($){let Z=await H4();if(!Z)return null;try{let Y=B4($),X=await new Z.Input(Y).getInfo();return{duration:X.duration||0,width:X.width||0,height:X.height||0,frameRate:X.frameRate||0,bitrate:X.bitrate||0,codec:X.videoCodec||"",audioCodec:X.audioCodec}}catch(Y){return console.warn(`[stx-media] Failed to analyze video: ${Y}`),null}}async function j4($,Z,Y,J){let X=await H4();if(!X)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let G=await u0($,Z,Y);if(G)return G;try{let Q=B4($);if(!await C(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let U=Y.outputDir||"dist/videos",K=Y.baseUrl||"/videos";await g7(U,{recursive:!0});let z=await g(Q),W=v7($,x7($)),q={src:$,processed:!0,hash:z};J?.({percentage:5,stage:"analyzing"}),q.metadata=await q5(Q)||void 0;let _={};if(Z.quality)_.bitrate=h7(Z.quality);if(Z.platform)Object.assign(_,d7(Z.platform));if(Z.transcode)Object.assign(_,Z.transcode);if(Object.keys(_).length>0||Z.process){J?.({percentage:10,stage:"transcoding"});let j=`${W}-${z}.mp4`,B=f7(U,j);try{let V=await u7(Q,B,_,X,(O)=>J?.({percentage:10+O*0.5,stage:"transcoding"}));if(V)q.transcoded={path:B,url:`${K}/${j}`,duration:V.duration,size:V.size,video:{codec:_.codec||"h264",width:V.width,height:V.height,bitrate:V.bitrate,frameRate:V.frameRate},audio:V.audioCodec?{codec:_.audioCodec||"aac",bitrate:_.audioBitrate||128000,sampleRate:_.sampleRate||48000,channels:_.channels||2}:void 0}}catch(V){q.errors=q.errors||[],q.errors.push(`Transcoding failed: ${V}`)}}if(Z.generatePoster){J?.({percentage:65,stage:"generating-poster"});let j=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},B=await c0(Q,j,U,K);if(B)q.poster=B}if(Y.thumbnails?.enabled){J?.({percentage:70,stage:"generating-thumbnails"});let j=await p0(Q,Y.thumbnails,U,K);if(j.length>0)q.thumbnails=j}if(Z.streaming){J?.({percentage:80,stage:"generating-manifests"});let j=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(j.format==="hls"||j.format===void 0){let B=await n0(Q,j.qualities||Y.streaming?.defaultQualities||[],U,K);if(B)q.streaming={...q.streaming,hls:B}}if(j.format==="dash"){let B=await o0(Q,j.qualities||Y.streaming?.defaultQualities||[],U,K);if(B)q.streaming={...q.streaming,dash:B}}}if(Z.spriteSheet)J?.({percentage:90,stage:"generating-sprite-sheet"});return J?.({percentage:100,stage:"complete"}),await m0($,Z,q,Y),q}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function u7($,Z,Y,J,X){try{let Q=await new J.Conversion($,Z,{videoCodec:Y.codec,videoBitrate:Y.bitrate,width:Y.maxWidth,height:Y.maxHeight,frameRate:Y.frameRate,audioCodec:Y.audioCodec,audioBitrate:Y.audioBitrate,sampleRate:Y.sampleRate,channels:Y.channels}).run((U)=>{X?.(U.percentage/100)});return{duration:Q.duration||0,size:Q.size||0,width:Q.width||Y.maxWidth||0,height:Q.height||Y.maxHeight||0,bitrate:Q.bitrate||Y.bitrate||0,frameRate:Q.frameRate||Y.frameRate||30,audioCodec:Q.audioCodec}}catch(G){return console.error(`[stx-media] Transcoding failed: ${G}`),null}}var O4=H(()=>{Z0();Z5();K5();U5()});var V4={};e0(V4,{setCachedVideoResult:()=>m0,processVideo:()=>j4,getCachedVideoResult:()=>u0,generateThumbnails:()=>p0,generateSpriteSheet:()=>G4,generatePoster:()=>c0,generateHLSManifest:()=>n0,generateDASHManifest:()=>o0,clearVideoCache:()=>J4,analyzeVideo:()=>q5,VideoProcessorCache:()=>d0});var L4=H(()=>{O4();K5();U5();Z5()});async function w4(){try{return await Promise.resolve().then(() => (L4(),V4))}catch($){if(!F4)console.warn("[stx-media] Video processor not available, some features disabled:",$),F4=!0;return null}}async function s0($,Z={}){let Y=Z,J=$;if(J.process&&!J.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return n7(J,Y)}if(Y.processedResult?.processed)return T4($,Y.processedResult,Z);let X;if(J.generatePoster&&J.src&&!$.poster)X=await o7(J,Y);let{src:G,sources:Q=[],poster:U,posterPlaceholder:K,controls:z=R4,autoplay:W=!1,muted:q=!1,loop:_=!1,preload:j=A4,playsinline:B=!0,lazy:V=!0,player:O="native",type:L,width:F,height:w,crossorigin:T,disablePictureInPicture:R=!1,disableRemotePlayback:N=!1}=$,A=X||U,P=$.class,d=$.style,D=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(O==="ts-video")return c7($,Z);if(L&&L!=="video")return l7(G||"",L,$);let b=Q.length>0?Q:G?[{src:G,type:N4(G)}]:[],I=[`id="${D}"`];if(z)I.push("controls");if(W)I.push("autoplay");if(q)I.push("muted");if(_)I.push("loop");if(B)I.push("playsinline");if(R)I.push("disablepictureinpicture");if(N)I.push("disableremoteplayback");if(T)I.push(`crossorigin="${T}"`);if(V){if(I.push(`data-preload="${j}"`),I.push('preload="none"'),A)I.push(`data-poster="${k(A)}"`);I.push("data-stx-lazy")}else if(I.push(`preload="${j}"`),A)I.push(`poster="${k(A)}"`);if(F)I.push(`width="${F}"`);if(w)I.push(`height="${w}"`);if(P)I.push(`class="${k(P)}"`);if(d)I.push(`style="${k(d)}"`);let v=b.map((M)=>{return` <source ${V?`data-src="${k(M.src)}"`:`src="${k(M.src)}"`} type="${M.type}"${M.media?` media="${M.media}"`:""} />`}).join(`
|
|
652
652
|
`),t=`<video ${I.join(" ")}>
|
|
653
653
|
${v}
|
|
654
654
|
Your browser does not support the video tag.
|
|
655
|
-
</video>`,
|
|
655
|
+
</video>`,u;if(V)u=`
|
|
656
656
|
(function() {
|
|
657
657
|
var video = document.getElementById('${D}');
|
|
658
658
|
if (!video) return;
|
|
@@ -687,7 +687,7 @@ ${v}
|
|
|
687
687
|
|
|
688
688
|
observer.observe(video);
|
|
689
689
|
})();
|
|
690
|
-
`.trim();return{html:t,script:
|
|
690
|
+
`.trim();return{html:t,script:u}}function l7($,Z,Y){let{width:J=640,height:X=360}=Y,G=Y.class,Q=Y.style,U=Y.id||`stx-embed-${Math.random().toString(36).slice(2,8)}`,K,z=null;switch(Z){case"youtube":z=p7($),K=z?`https://www.youtube-nocookie.com/embed/${z}`:$;break;case"vimeo":z=i7($),K=z?`https://player.vimeo.com/video/${z}`:$;break;case"dailymotion":z=$.split("/").pop()||"",K=`https://www.dailymotion.com/embed/video/${z}`;break;case"twitch":z=$.split("/").pop()||"",K=`https://player.twitch.tv/?video=${z}&parent=${typeof window<"u"?window.location.hostname:"localhost"}`;break;default:K=$}let W=[`id="${U}"`,`src="${k(K)}"`,`width="${J}"`,`height="${X}"`,'frameborder="0"',"allowfullscreen",'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"'];if(G)W.push(`class="${k(G)}"`);if(Q)W.push(`style="${k(Q)}"`);if(Y.lazy)W.push('loading="lazy"');return{html:`<div class="stx-video-embed" style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
|
|
691
691
|
<iframe ${W.join(" ")} style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe>
|
|
692
692
|
</div>`}}function c7($,Z={}){let{src:Y,sources:J=[],poster:X,controls:G=!0,autoplay:Q=!1,muted:U=!1,loop:K=!1,preload:z="metadata",playsinline:W=!0,lazy:q=!0,width:_,height:j}=$,B=$.class,V=$.style,O=$.id||`ts-video-${Math.random().toString(36).slice(2,8)}`,L={src:J.length>0?J:Y,autoplay:Q,loop:K,muted:U,playsinline:W,preload:z,poster:X,controls:G,title:$.title},F=["position: relative",_?`width: ${typeof _==="number"?_+"px":_}`:"width: 100%",j?`height: ${typeof j==="number"?j+"px":j}`:"",V||""].filter(Boolean).join("; "),w=`
|
|
693
693
|
<div
|
|
@@ -726,7 +726,7 @@ ${v}
|
|
|
726
726
|
|
|
727
727
|
// Load ts-video-player from CDN
|
|
728
728
|
var script = document.createElement('script');
|
|
729
|
-
script.src = '${
|
|
729
|
+
script.src = '${m7}';
|
|
730
730
|
script.onload = initPlayer;
|
|
731
731
|
script.onerror = function() {
|
|
732
732
|
console.error('[stx] Failed to load ts-video-player');
|
|
@@ -905,7 +905,7 @@ ${b}
|
|
|
905
905
|
width: 100%;
|
|
906
906
|
height: auto;
|
|
907
907
|
}
|
|
908
|
-
`.trim();return{html:b,script:I,css:v}}var F4=!1,R4=!0,A4="metadata",
|
|
908
|
+
`.trim();return{html:b,script:I,css:v}}var F4=!1,R4=!0,A4="metadata",m7="https://cdn.jsdelivr.net/npm/ts-video-player@latest/dist/index.min.js";var I4=H(()=>{W5()});function M4(){return D0({name:"video",hasEndTag:!1,description:"Render a video with optional ts-videos processing, streaming, and poster generation",transform:async($,Z,Y,J)=>{let{src:X,options:G}=s7($,Z,Y);if(!X)return console.warn("@video directive: missing src argument"),"<!-- @video: missing src -->";let Q={src:X,poster:G.poster,controls:G.controls!==!1,autoplay:G.autoplay||!1,muted:G.muted||!1,loop:G.loop||!1,preload:G.preload||"metadata",playsinline:G.playsinline!==!1,lazy:G.lazy!==!1,player:G.player||"native",type:G.type,width:G.width,height:G.height,class:G.class,style:G.style,id:G.id,crossorigin:G.crossorigin,disablePictureInPicture:G.disablePictureInPicture,disableRemotePlayback:G.disableRemotePlayback,title:G.title,quality:G.quality,platform:G.platform,process:G.process,generatePoster:G.generatePoster,streaming:G.streaming,transcode:G.transcode,spriteSheet:G.spriteSheet,waveform:G.waveform},K={isDev:Y.__isDev||!1,tsVideosConfig:Y.__tsVideosConfig},z=await s0(Q,K),W=z.html;if(z.css)W+=`
|
|
909
909
|
<style>${z.css}</style>`;if(z.script)W+=`
|
|
910
910
|
<script>${z.script}</script>`;return W},defaults:{src:"",options:{controls:!0,lazy:!0,preload:"metadata"}}})}function s7($,Z,Y){if(Z.src)return{src:String(Z.src),options:Z.options||{}};let J=$.trim();if(J.startsWith("@video(")||J.startsWith("("))J=J.replace(/^@video\(/,"").replace(/^\(/,"").replace(/\)$/,"");let X=r7(J),G=D4(X[0],Y)||"",Q={};if(X[1]){let U=D4(X[1],Y);if(typeof U==="object"&&U!==null)Q=U;else if(typeof X[1]==="string")try{Q=JSON.parse(X[1])}catch{}}return{src:G,options:Q}}function r7($){let Z=[],Y="",J=!1,X="",G=0,Q=0;for(let U=0;U<$.length;U++){let K=$[U],z=U>0?$[U-1]:"";if((K==='"'||K==="'"||K==="`")&&z!=="\\"){if(!J)J=!0,X=K;else if(K===X)J=!1,X="";else Y+=K;continue}if(!J){if(K==="{")G++;if(K==="}")G--;if(K==="[")Q++;if(K==="]")Q--;if(K===","&&G===0&&Q===0){Z.push(Y.trim()),Y="";continue}}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function D4($,Z){if(typeof $!=="string")return $;let Y=$.trim();if(Y.startsWith('"')&&Y.endsWith('"')||Y.startsWith("'")&&Y.endsWith("'"))return Y.slice(1,-1);if(!Y.startsWith("/")&&!Y.startsWith(".")&&!Y.startsWith("http")&&!Y.startsWith("{")){let J=Z[Y];if(J!==void 0)return J}if(Y.startsWith("{")||Y.startsWith("["))try{return JSON.parse(Y)}catch{}return Y}var z5;var W5=H(()=>{v1();I4();z5=M4()});function a7($,Z){let Y=Z.pwa?.manifest?.themeColor||"#4f46e5";return`<div class="stx-pwa-install" style="display:none;">
|
|
911
911
|
${$}
|
|
@@ -1257,7 +1257,7 @@ ${W}
|
|
|
1257
1257
|
}
|
|
1258
1258
|
|
|
1259
1259
|
customElements.define('${Z}', ${Q});
|
|
1260
|
-
`}async function b4($,Z,Y,J){if(Z.length<1)return
|
|
1260
|
+
`}async function b4($,Z,Y,J){if(Z.length<1)return m("WebComponent","@webcomponent directive requires at least the tag name parameter",f.INVALID_DIRECTIVE_SYNTAX);let X=Z[0].replace(/['"]/g,""),Q=(Y.__stx_options||{}).componentsDir||"components",U=[V0.join(V0.dirname(J),Q,`${X}.stx`),V0.join(process.cwd(),Q,`${X}.stx`),V0.join(V0.dirname(J),`${X}.stx`)],K=null;for(let q of U)if(await n(q)){K=await Bun.file(q).text();break}if(!K)return m("WebComponent",`Component file not found: ${X}.stx`,f.FILE_NOT_FOUND);let z=G6(K,X);return`<script type="module">
|
|
1261
1261
|
${Q6(z)}
|
|
1262
1262
|
</script>`}var S4=H(()=>{o();x()});var y4={};e0(y4,{timingPlugin:()=>W6,pluginManager:()=>K6,definePlugin:()=>r0,debugPlugin:()=>z6,createVariablesPlugin:()=>_6,createFilterPlugin:()=>q6,createDirectivePlugin:()=>U6,PluginManager:()=>_5});function r0($){return $}class _5{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,Z){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let Y of $.dependencies)if(!this.plugins.has(Y))throw Error(`Plugin "${$.name}" depends on "${Y}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(Z);this.sortPlugins()}async unregister($){let Z=this.plugins.get($);if(!Z)return!1;for(let[Y,J]of this.plugins)if(J.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${Y}" depends on it`);if(Z.onUnregister)await Z.onUnregister();return this.plugins.delete($),this.sortPlugins(),!0}get($){return this.plugins.get($)}has($){return this.plugins.has($)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let $=[];for(let Z of this.sortedPlugins)if(Z.registerDirectives)$.push(...Z.registerDirectives());return $}getAllFilters(){let $={};for(let Z of this.sortedPlugins)if(Z.registerFilters)Object.assign($,Z.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,Z){return this.runDirectiveHooks("beforeDirective",$,Z)}async runAfterDirective($,Z){return this.runDirectiveHooks("afterDirective",$,Z)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let Z of this.sortedPlugins)if(Z.onError)try{let Y=await Z.onError($);if(Y){if(Y.template!==void 0)$.template=Y.template;if(Y.context)$.context={...$.context,...Y.context};if(Y.metadata)$.metadata={...$.metadata,...Y.metadata};if(Y.skip)return $}}catch(Y){console.error(`Error in plugin "${Z.name}" onError hook:`,Y)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,Z)=>($.priority??100)-(Z.priority??100))}async runHooks($,Z){let Y={...Z};for(let J of this.sortedPlugins){let X=J[$];if(X)try{let G=await X(Y);if(G){if(G.template!==void 0)Y.template=G.template;if(G.context)Y.context={...Y.context,...G.context};if(G.metadata)Y.metadata={...Y.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${J.name}" ${$} hook:`,G)}}return Y}async runDirectiveHooks($,Z,Y){let J={...Y};for(let X of this.sortedPlugins){let G=X[$];if(G)try{let Q=await G(Z,J);if(Q){if(Q.template!==void 0)J.template=Q.template;if(Q.context)J.context={...J.context,...Q.context};if(Q.metadata)J.metadata={...J.metadata,...Q.metadata};if(Q.skip)break}}catch(Q){console.error(`Error in plugin "${X.name}" ${$} hook:`,Q)}}return J}}function U6($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function q6($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function _6($){return r0({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var K6,z6,W6;var C4=H(()=>{K6=new _5;z6=r0({name:"stx-debug",version:"1.0.0",description:"Logs all plugin lifecycle events for debugging",priority:0,beforeProcess($){console.log("[stx-debug] beforeProcess:",$.filePath)},afterParse($){console.log("[stx-debug] afterParse:",$.template.length,"chars")},beforeDirective($,Z){console.log("[stx-debug] beforeDirective:",$)},afterDirective($,Z){console.log("[stx-debug] afterDirective:",$)},beforeRender($){console.log("[stx-debug] beforeRender")},afterRender($){console.log("[stx-debug] afterRender:",$.template.length,"chars")},onError($){console.error("[stx-debug] onError:",$.error.message,"in phase:",$.phase)}}),W6=r0({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let Z=$.metadata.startTime;if(Z){let Y=performance.now()-Z;console.log(`[stx-timing] Processing took ${Y.toFixed(2)}ms`)}}})});import B5 from"fs";import h from"path";import{loadConfigWithResult as B6}from"bunfig";function H6($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let J=h.join(process.cwd(),"resources","views"),X=h.join(process.cwd(),"resources","layouts");if(B5.existsSync(J)&&B5.existsSync(X))return{root:"resources",pagesDir:"views"};let G=h.join(process.cwd(),"resources","views","pages");if(B5.existsSync(G))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function H5($){if(!$){if(U0)return U0;if(a0)return a0}let Z=$?h.resolve($):process.cwd(),Y=P4.get(Z);if(Y)return Y;let J=(async()=>{let G=(await B6({name:"stx",alias:"ui",cwd:Z,defaultConfig:v4,verbose:!1})).config,Q=H6(G.root,G.pagesDir);if(G.root=Q.root,G.pagesDir=Q.pagesDir,G.root&&G.root!=="."){let U=G.root;if(G.partialsDir&&!h.isAbsolute(G.partialsDir))G.partialsDir=h.join(U,G.partialsDir);if(G.componentsDir&&!h.isAbsolute(G.componentsDir))G.componentsDir=h.join(U,G.componentsDir);if(G.layoutsDir&&!h.isAbsolute(G.layoutsDir))G.layoutsDir=h.join(U,G.layoutsDir)}if(G.plugins&&G.plugins.length>0){let{pluginManager:U}=await Promise.resolve().then(() => (C4(),y4)),K=[],z=[];for(let W of G.plugins){let q=typeof W==="string"?W:W[0],_=typeof W==="string"?{}:W[1]||{};try{let j,B;try{j=await import(q),B=h.dirname(S.resolve(q))}catch{let O=h.resolve(process.cwd(),q);j=await import(O),B=h.dirname(O)}let V=j.default||j;if(U.register(V,G),V.components){let O=h.resolve(B,V.components);K.push(O)}if(V.pages){let O=h.resolve(B,V.pages),L=_.path||"/";z.push({dir:O,prefix:L})}if(V.setup){let O={addDirective:(L)=>{G.customDirectives=G.customDirectives||[],G.customDirectives.push(L)},addRoute:(L,F)=>{G.apiRoutes=G.apiRoutes||{},G.apiRoutes[L]=F},addMiddleware:(L)=>{G.middleware=G.middleware||[],G.middleware.push(L)},pluginDir:B,config:G};await V.setup(_,O)}console.log(`[stx] Plugin loaded: ${V.name||q}`)}catch(j){console.warn(`[stx] Failed to load plugin ${q}:`,j.message)}}G._pluginComponentDirs=K,G._pluginPageDirs=z}return G})();if(P4.set(Z,J),!$)a0=J,J.then((X)=>{U0=X}).catch(()=>{});return J}var v4,U0=null,P4,a0=null,e4;var U1=H(()=>{$1();Z1();Y1();X1();P1();X4();W5();k4();V1();S4();v4={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:k$,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:b4,hasEndTag:!1,description:"Include a web component in the template"},O5,V5,q$,z$,L5,w5,R5,F5,T5,I5,Y4,z5,...E4],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"#app-content",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};P4=new Map;e4=new Proxy(v4,{get($,Z){if(U0&&Z in U0)return U0[Z];if(!a0)H5().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import t0 from"path";async function jQ($){let Z;if($)Z=t0.resolve($);else{let W=await H5();Z=t0.resolve(W.root||process.cwd(),W.storesDir||"stores")}let Y=q0.get(Z);if(Y!==void 0)return Y||null;let J=new Bun.Glob("*.ts"),X=[];try{for await(let W of J.scan({cwd:Z,absolute:!0})){let q=t0.basename(W,".ts");if(["index","types"].includes(q))continue;if(W.includes(".d.ts"))continue;X.push(W)}}catch{return q0.set(Z,""),null}if(X.length===0)return q0.set(Z,""),null;let G=[];for(let W of X){let q=await Bun.file(W).text();G.push({file:W,hasUseStore:/useStore\s*\(/.test(q)})}G.sort((W,q)=>{if(W.hasUseStore===q.hasUseStore)return 0;return W.hasUseStore?1:-1});let Q=G.map((W)=>W.file),U=[],K=new Bun.Transpiler({loader:"ts",target:"browser",define:B0()});for(let W of Q)try{let q=await Bun.file(W).text(),_=t0.basename(W,".ts");q=q.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),q=q.replace(/^export\s+(default\s+)?/gm,""),q=K.transformSync(q),U.push(`// Store: ${_}
|
|
1263
1263
|
${q.trim()}`)}catch(q){console.warn(`[stx] Failed to load store ${W}:`,q)}if(U.length===0)return q0.set(Z,""),null;let z=`;(function(){
|
package/dist/story/cli.js
CHANGED
|
@@ -1783,7 +1783,7 @@ ${q}`)}if($.suggestion)W.push(`
|
|
|
1783
1783
|
${"\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"}`),W.join("")}function yW($,Z,Y){let X=$.split(`
|
|
1784
1784
|
`),J=Math.max(0,Z-Y-1),Q=Math.min(X.length-1,Z+Y-1),G=[];for(let K=J;K<=Q;K++){let z=(K+1).toString().padStart(4),W=K===Z-1?">":" ";G.push(`${W}${z} | ${X[K]}`)}return G.join(`
|
|
1785
1785
|
`)}function vW($,Z,Y){let X=$.split(`
|
|
1786
|
-
`),J=Math.max(0,Z-Y-1),Q=Math.min(X.length-1,Z+Y-1),G="\x1B[90m",K="\x1B[31m",z="\x1B[0m",W=[];for(let U=J;U<=Q;U++){let q=(U+1).toString().padStart(4),_=U===Z-1,B=_?"\x1B[31m>\x1B[0m":" ",j=_?`\x1B[31m${X[U]}\x1B[0m`:`\x1B[90m${X[U]}\x1B[0m`;W.push(`${B}${q}\x1B[0m | ${j}`)}return W.join(`
|
|
1786
|
+
`),J=Math.max(0,Z-Y-1),Q=Math.min(X.length-1,Z+Y-1),G="\x1B[90m",K="\x1B[31m",z="\x1B[0m",W=[];for(let U=J;U<=Q;U++){let q=(U+1).toString().padStart(4),_=U===Z-1,B=_?"\x1B[31m>\x1B[0m":" ",j=_?`\x1B[31m${X[U]}\x1B[0m`:`\x1B[90m${X[U]}\x1B[0m`;W.push(`${B}\x1B[90m${q}\x1B[0m | ${j}`)}return W.join(`
|
|
1787
1787
|
`)}function zY($){return $.replace(/--/g,"- -").replace(/>/g,">")}function WY($,Z){let X=$.substring(0,Z).split(`
|
|
1788
1788
|
`);return{line:X.length,column:X[X.length-1].length}}function r($,Z,Y){return v6({type:$,message:Z,code:Y,format:"html"}).formatted}function xW($,Z,Y,X,J){return v6({type:$,message:Z,code:J,filePath:Y,line:X,format:"console"}).formatted}function fW($,Z,Y){let X=Y.template.split(`
|
|
1789
1789
|
`),J=WY(Y.template,Y.offset),Q=`[${$} Error at line ${J.line} in ${Y.filePath}]: ${Z}
|
|
@@ -3756,7 +3756,7 @@ window.__stx_reactive = (function() {
|
|
|
3756
3756
|
|
|
3757
3757
|
return { initScope: initScope, reactive: reactive };
|
|
3758
3758
|
})();
|
|
3759
|
-
`}function nY($,Z){let Y=$.replace(/\{!!([\s\S]*?)!!\}/g,(X,J)=>{try{let Q=m0(J,Z,!0);if(Q===void 0)return X;return String(Q)}catch{return X}});return Y=Y.replace(/\{\{([\s\S]*?)\}\}/g,(X,J)=>{try{let Q=m0(J,Z,!0);if(Q===void 0)return X;return JSON.stringify(Q)}catch{return X}}),Y}function cU($,Z){if($.length===0)return"";let Y=$.map((X)=>{let J=JSON.stringify(Object.fromEntries(X.refs)),Q=nY(X.stateExpr,Z),G=X.initExpr?nY(X.initExpr,Z):null,K=JSON.stringify(Q),z=G?JSON.stringify(G):"null";return`
|
|
3759
|
+
`}function nY($,Z){let Y=$.replace(/\{!!([\s\S]*?)!!\}/g,(X,J)=>{try{let Q=m0(J,Z,!0);if(Q===void 0)return X;return String(Q)}catch{return X}});return Y=Y.replace(/\{\{([\s\S]*?)\}\}/g,(X,J)=>{try{let Q=m0(J,Z,!0);if(Q===void 0)return X;if(typeof Q==="string"){let G=Q.trim();if(G.startsWith("{")&&G.endsWith("}")||G.startsWith("[")&&G.endsWith("]"))try{return JSON.parse(G),G}catch{}}return JSON.stringify(Q)}catch{return X}}),Y}function cU($,Z){if($.length===0)return"";let Y=$.map((X)=>{let J=JSON.stringify(Object.fromEntries(X.refs)),Q=nY(X.stateExpr,Z),G=X.initExpr?nY(X.initExpr,Z):null,K=JSON.stringify(Q),z=G?JSON.stringify(G):"null";return`
|
|
3760
3760
|
(function() {
|
|
3761
3761
|
var scopeEl = document.querySelector('${X.selector}');
|
|
3762
3762
|
if (!scopeEl) return;
|
|
@@ -5996,6 +5996,13 @@ catch (e2) {
|
|
|
5996
5996
|
|
|
5997
5997
|
// Known directive names to exclude from generic :attr binding
|
|
5998
5998
|
var DIRECTIVE_NAMES = {class:1, style:1, text:1, html:1, show:1, model:1, 'if':1, 'for':1, ref:1};
|
|
5999
|
+
// SVG attributes are case-sensitive, but the HTML parser lowercases
|
|
6000
|
+
// prefixed attribute names \u2014 ':viewBox' arrives as ':viewbox' because
|
|
6001
|
+
// the spec's "adjust SVG attributes" step only covers unprefixed names.
|
|
6002
|
+
// Without restoring the canonical casing, setAttribute('viewbox') creates
|
|
6003
|
+
// a dead duplicate attribute and the real viewBox never updates.
|
|
6004
|
+
var SVG_ATTR_CASE = {attributename:'attributeName', attributetype:'attributeType', basefrequency:'baseFrequency', baseprofile:'baseProfile', calcmode:'calcMode', clippathunits:'clipPathUnits', diffuseconstant:'diffuseConstant', edgemode:'edgeMode', filterunits:'filterUnits', glyphref:'glyphRef', gradienttransform:'gradientTransform', gradientunits:'gradientUnits', kernelmatrix:'kernelMatrix', kernelunitlength:'kernelUnitLength', keypoints:'keyPoints', keysplines:'keySplines', keytimes:'keyTimes', lengthadjust:'lengthAdjust', limitingconeangle:'limitingConeAngle', markerheight:'markerHeight', markerunits:'markerUnits', markerwidth:'markerWidth', maskcontentunits:'maskContentUnits', maskunits:'maskUnits', numoctaves:'numOctaves', pathlength:'pathLength', patterncontentunits:'patternContentUnits', patterntransform:'patternTransform', patternunits:'patternUnits', pointsatx:'pointsAtX', pointsaty:'pointsAtY', pointsatz:'pointsAtZ', preservealpha:'preserveAlpha', preserveaspectratio:'preserveAspectRatio', primitiveunits:'primitiveUnits', refx:'refX', refy:'refY', repeatcount:'repeatCount', repeatdur:'repeatDur', requiredextensions:'requiredExtensions', requiredfeatures:'requiredFeatures', specularconstant:'specularConstant', specularexponent:'specularExponent', spreadmethod:'spreadMethod', startoffset:'startOffset', stddeviation:'stdDeviation', stitchtiles:'stitchTiles', surfacescale:'surfaceScale', systemlanguage:'systemLanguage', tablevalues:'tableValues', targetx:'targetX', targety:'targetY', textlength:'textLength', viewbox:'viewBox', viewtarget:'viewTarget', xchannelselector:'xChannelSelector', ychannelselector:'yChannelSelector', zoomandpan:'zoomAndPan'};
|
|
6005
|
+
var SVG_NS = 'http://www.w3.org/2000/svg';
|
|
5999
6006
|
var EVENT_RE = /^(click|dblclick|mousedown|mouseup|mousemove|mouseenter|mouseleave|keydown|keyup|keypress|input|change|submit|focus|blur|scroll|resize|touchstart|touchend|touchmove|contextmenu|wheel|pointerdown|pointerup|pointermove)/;
|
|
6000
6007
|
var KEY_MAP = {enter:'Enter', tab:'Tab', escape:'Escape', space:' ', up:'ArrowUp', down:'ArrowDown', left:'ArrowLeft', right:'ArrowRight', 'delete':'Delete', backspace:'Backspace'};
|
|
6001
6008
|
|
|
@@ -6020,7 +6027,8 @@ catch (e2) {
|
|
|
6020
6027
|
if (name.startsWith('@bind:') || name.startsWith('x-bind:')
|
|
6021
6028
|
|| (name.startsWith(':') && !name.startsWith('::') && !DIRECTIVE_NAMES[name.slice(1).split('.')[0]] && !EVENT_RE.test(name.slice(1)))
|
|
6022
6029
|
|| (name.startsWith('x-') && !X_HANDLED[name.split('.')[0]] && !X_HANDLED[name])) {
|
|
6023
|
-
|
|
6030
|
+
let attrName = name.startsWith('@bind:') ? name.slice(6) : name.startsWith('x-bind:') ? name.slice(7) : name.startsWith('x-') ? name.slice(2) : name.slice(1);
|
|
6031
|
+
if (el.namespaceURI === SVG_NS && SVG_ATTR_CASE[attrName]) attrName = SVG_ATTR_CASE[attrName];
|
|
6024
6032
|
effect(() => {
|
|
6025
6033
|
const v = evalAttrExpr(value);
|
|
6026
6034
|
if (v === false || v === null || v === undefined) {
|
|
@@ -6399,10 +6407,12 @@ else {
|
|
|
6399
6407
|
});
|
|
6400
6408
|
}
|
|
6401
6409
|
else if (Array.isArray(value)) {
|
|
6402
|
-
|
|
6410
|
+
var _clsArr = originalClasses + ' ' + value.filter(Boolean).join(' ');
|
|
6411
|
+
if (typeof el.className === 'string') el.className = _clsArr; else el.setAttribute('class', _clsArr);
|
|
6403
6412
|
}
|
|
6404
6413
|
else {
|
|
6405
|
-
|
|
6414
|
+
var _clsStr = originalClasses + (value ? ' ' + value : '');
|
|
6415
|
+
if (typeof el.className === 'string') el.className = _clsStr; else el.setAttribute('class', _clsStr);
|
|
6406
6416
|
}
|
|
6407
6417
|
});
|
|
6408
6418
|
}
|
|
@@ -8726,10 +8736,10 @@ else {
|
|
|
8726
8736
|
var root = scriptEl ? scriptEl.nextElementSibling : null;
|
|
8727
8737
|
if (!root && scriptEl) root = scriptEl.previousElementSibling || scriptEl.parentElement;
|
|
8728
8738
|
|
|
8729
|
-
// SPA fallback: during router navigation, script is appended to
|
|
8739
|
+
// SPA fallback: during router navigation, script is appended to body>
|
|
8730
8740
|
// (not inside the content container), so nextElementSibling won't find the page content.
|
|
8731
8741
|
// Only use fallback when we genuinely couldn't find a suitable root element.
|
|
8732
|
-
// Do NOT fallback just because the script is in
|
|
8742
|
+
// Do NOT fallback just because the script is in body> \u2014 layout scripts in body>
|
|
8733
8743
|
// with valid siblings (e.g. sidebar <aside>) should use those siblings as root.
|
|
8734
8744
|
var needsFallback = !root || root === document.body
|
|
8735
8745
|
|| (root && root.tagName === 'SCRIPT');
|
|
@@ -9048,7 +9058,7 @@ else {
|
|
|
9048
9058
|
mountCallbacks.forEach(fn => fn());
|
|
9049
9059
|
});
|
|
9050
9060
|
|
|
9051
|
-
// Multi-root fragment fix: a no
|
|
9061
|
+
// Multi-root fragment fix: a no-body> setup page tags only the FIRST
|
|
9052
9062
|
// top-level element with data-stx (signal-processing.ts marks one element),
|
|
9053
9063
|
// so sibling root elements were orphaned \u2014 their :if / :for / {{ }} / x-text
|
|
9054
9064
|
// never hydrated, which read as "{{ }} doesn't work under :if/:for". The
|
|
@@ -9145,7 +9155,7 @@ else {
|
|
|
9145
9155
|
el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });
|
|
9146
9156
|
});
|
|
9147
9157
|
|
|
9148
|
-
// Process
|
|
9158
|
+
// Process head> elements (title, meta) that may contain {{ }} expressions
|
|
9149
9159
|
// Use componentScope which now contains variables from processed components
|
|
9150
9160
|
const headElements = document.querySelectorAll('head title, head meta[content]');
|
|
9151
9161
|
headElements.forEach(el => {
|
|
@@ -9341,7 +9351,7 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
|
|
|
9341
9351
|
|
|
9342
9352
|
// Apply new page's SFC setup function. During SPA navigation, re-executed page
|
|
9343
9353
|
// scripts set window.stx._latestSetup to the new setup function. This takes priority
|
|
9344
|
-
// over the stale data-stx attribute on
|
|
9354
|
+
// over the stale data-stx attribute on body> (which has the PREVIOUS page's function name).
|
|
9345
9355
|
var usedLatestSetup = false;
|
|
9346
9356
|
if (window.stx._latestSetup && typeof window.stx._latestSetup === 'function') {
|
|
9347
9357
|
try {
|
|
@@ -9425,7 +9435,7 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
|
|
|
9425
9435
|
|
|
9426
9436
|
// Process the container content \u2014 bind {{ }}, :attr, @event directives.
|
|
9427
9437
|
// Run synchronously (not in setTimeout) so componentScope is captured correctly.
|
|
9428
|
-
// The DOMContentLoaded path processes
|
|
9438
|
+
// The DOMContentLoaded path processes body> synchronously \u2014 the SPA path must match.
|
|
9429
9439
|
console.log('[stx:load] container:', container.tagName, '__stx_scope:', !!container.__stx_scope, 'scope keys:', Object.keys(componentScope).slice(0, 10));
|
|
9430
9440
|
if (!container.__stx_scope) {
|
|
9431
9441
|
// Dispose previous effects on the container (from prior navigation)
|
|
@@ -9535,7 +9545,7 @@ ${_}${U}
|
|
|
9535
9545
|
return { ${q} };
|
|
9536
9546
|
}
|
|
9537
9547
|
if(window.stx)window.stx._latestSetup=${G};
|
|
9538
|
-
</script>`,j=$;for(let H of Q)j=j.split(H.fullMatch).join("");if(j.includes("<body"))j=j.replace(/<body([^>]*)>/,`<body$1 data-stx="${G}">`);else{let H=["script","style","html","head","meta","link","title","!doctype"];j=j.replace(/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*)>/
|
|
9548
|
+
</script>`,j=$;for(let H of Q)j=j.split(H.fullMatch).join("");if(j.includes("<body"))j=j.replace(/<body([^>]*)>/,`<body$1 data-stx="${G}">`);else{let H=["script","style","html","head","meta","link","title","!doctype"],L=!1;j=j.replace(/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*)>/gi,(F,O,V)=>{if(L||H.includes(O.toLowerCase()))return F;return L=!0,`<${O}${V} data-stx="${G}">`})}return{output:j,setupCode:B}}function wJ($){let Z=$,Y=[],X=new Set,J=0,Q=0,G=Z.length,K="",z=()=>{Q++;let j=!1;while(Q<G){let H=Z[Q];if(H==="\\"){Q+=2;continue}if(H==="["&&!j){j=!0,Q++;continue}if(H==="]"&&j){j=!1,Q++;continue}if(H==="/"&&!j){Q++;while(Q<G&&/[gimsuyd]/.test(Z[Q]))Q++;return}if(H===`
|
|
9539
9549
|
`)return;Q++}},W=()=>{if(!K)return!0;if(/[\w)\]]/.test(K))return!1;return!0},U=(j)=>{Q++;while(Q<G){if(Z[Q]==="\\"){Q+=2;continue}if(Z[Q]===j){Q++;return}Q++}},q=()=>{Q++;while(Q<G){if(Z[Q]==="\\"){Q+=2;continue}if(Z[Q]==="`"){Q++;return}if(Z[Q]==="$"&&Z[Q+1]==="{"){Q+=2;let j=1;while(Q<G&&j>0)if(Z[Q]==="{")j++,Q++;else if(Z[Q]==="}")j--,Q++;else if(Z[Q]==="'"||Z[Q]==='"')U(Z[Q]);else if(Z[Q]==="`")q();else Q++;continue}Q++}},_=()=>{if(Z[Q]==="/"&&Z[Q+1]==="/"){while(Q<G&&Z[Q]!==`
|
|
9540
9550
|
`)Q++;return!0}if(Z[Q]==="/"&&Z[Q+1]==="*"){Q+=2;while(Q<G-1&&!(Z[Q]==="*"&&Z[Q+1]==="/"))Q++;return Q+=2,!0}return!1},B=()=>{if(J!==0)return;let j=Z.slice(Q).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(j){let V=j[2];if(!X.has(V))Y.push(V),X.add(V);return}let H=Z.slice(Q).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(H){H[1].split(",").forEach((V)=>{let A=V.trim();if(!A)return;let w=A.indexOf(":"),N=(w>=0?A.slice(w+1).trim():A).split(/[\s=]/)[0];if(N&&!X.has(N))Y.push(N),X.add(N)});return}let L=Z.slice(Q).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(L){L[1].split(",").forEach((V)=>{let A=V.trim().replace(/^\.\.\./,"");if(!A)return;let w=A.split(/[\s=]/)[0];if(w&&!X.has(w))Y.push(w),X.add(w)});return}let F=Z.slice(Q).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(F){let V=F[1];if(!X.has(V))Y.push(V),X.add(V);return}let O=Z.slice(Q).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(O){let V=O[1];if(!X.has(V))Y.push(V),X.add(V)}};while(Q<G){if(_())continue;if(Z[Q]==="'"||Z[Q]==='"'){U(Z[Q]),K=Z[Q-1];continue}if(Z[Q]==="`"){q(),K="`";continue}if(Z[Q]==="/"&&Z[Q+1]!=="/"&&Z[Q+1]!=="*"&&W()){z(),K="/";continue}if(Z[Q]==="{"){J++,K="{",Q++;continue}if(Z[Q]==="}"){J--,K="}",Q++;continue}if(J===0&&/[a-z]/i.test(Z[Q])&&(Q===0||/\s|[;{}()]/.test(Z[Q-1])))B();if(!/\s/.test(Z[Q]))K=Z[Q];Q++}return Y.join(", ")}async function I9($,Z,Y,X){if(!F7($))return $;let J=$;if(Z.skipSignalsRuntime)return J;let{output:Q,setupCode:G}=await VJ(J,Y,X);if(J=Q,J=await qJ(J,Z),J=UJ(J),G)if(J.includes("</head>"))J=J.replace("</head>",`${G}
|
|
9541
9551
|
</head>`);else if(J.includes("<body"))J=J.replace(/<body([^>]*)>/,`<body$1>
|