@devwareng/vanilla-ts 1.4.55 → 1.4.57
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/index.cjs +10 -18
- package/dist/index.js +6 -14
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,27 +1,19 @@
|
|
|
1
|
-
"use strict";var be=Object.create;var B=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var Me=Object.getOwnPropertyNames;var Oe=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty;var ot=(s,t)=>()=>(s&&(t=s(s=0)),t);var qt=(s,t)=>{for(var e in t)B(s,e,{get:t[e],enumerable:!0})},Yt=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Me(t))!Ce.call(s,r)&&r!==e&&B(s,r,{get:()=>t[r],enumerable:!(n=Ae(t,r))||n.enumerable});return s};var R=(s,t,e)=>(e=s!=null?be(Oe(s)):{},Yt(t||!s||!s.__esModule?B(e,"default",{value:s,enumerable:!0}):e,s)),He=s=>Yt(B({},"__esModule",{value:!0}),s);function ce(s,t={}){let e=t.entryType||t.type;if(e==="both"&&(e=L.FILE_DIR_TYPE),e&&(t.type=e),s){if(typeof s!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(e&&!ne.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${ne.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=s,new It(t)}var b,oe,A,L,Ht,ae,$e,ne,je,Ue,qe,Ye,re,ie,It,le=ot(()=>{"use strict";b=require("fs/promises"),oe=require("stream"),A=require("path"),L={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},Ht={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:L.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(Ht);ae="READDIRP_RECURSIVE_ERROR",$e=new Set(["ENOENT","EPERM","EACCES","ELOOP",ae]),ne=[L.DIR_TYPE,L.EVERYTHING_TYPE,L.FILE_DIR_TYPE,L.FILE_TYPE],je=new Set([L.DIR_TYPE,L.EVERYTHING_TYPE,L.FILE_DIR_TYPE]),Ue=new Set([L.EVERYTHING_TYPE,L.FILE_DIR_TYPE,L.FILE_TYPE]),qe=s=>$e.has(s.code),Ye=process.platform==="win32",re=s=>!0,ie=s=>{if(s===void 0)return re;if(typeof s=="function")return s;if(typeof s=="string"){let t=s.trim();return e=>e.basename===t}if(Array.isArray(s)){let t=s.map(e=>e.trim());return e=>t.some(n=>e.basename===n)}return re},It=class extends oe.Readable{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...Ht,...t},{root:n,type:r}=e;this._fileFilter=ie(e.fileFilter),this._directoryFilter=ie(e.directoryFilter);let i=e.lstat?b.lstat:b.stat;Ye?this._stat=a=>i(a,{bigint:!0}):this._stat=i,this._maxDepth=e.depth??Ht.depth,this._wantsDir=r?je.has(r):!1,this._wantsFile=r?Ue.has(r):!1,this._wantsEverything=r===L.EVERYTHING_TYPE,this._root=(0,A.resolve)(n),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let e=this.parent,n=e&&e.files;if(n&&n.length>0){let{path:r,depth:i}=e,a=n.splice(0,t).map(c=>this._formatEntry(c,r)),o=await Promise.all(a);for(let c of o){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,i+1)),this._wantsDir&&(this.push(c),t--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),t--)}}else{let r=this.parents.pop();if(!r){this.push(null);break}if(this.parent=await r,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(t,e){let n;try{n=await(0,b.readdir)(t,this._rdOptions)}catch(r){this._onError(r)}return{files:n,depth:e,path:t}}async _formatEntry(t,e){let n,r=this._isDirent?t.name:t;try{let i=(0,A.resolve)((0,A.join)(e,r));n={path:(0,A.relative)(this._root,i),fullPath:i,basename:r},n[this._statsProp]=this._isDirent?t:await this._stat(i)}catch(i){this._onError(i);return}return n}_onError(t){qe(t)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let e=t[this._statsProp];if(e.isFile())return"file";if(e.isDirectory())return"directory";if(e&&e.isSymbolicLink()){let n=t.fullPath;try{let r=await(0,b.realpath)(n),i=await(0,b.lstat)(r);if(i.isFile())return"file";if(i.isDirectory()){let a=r.length;if(n.startsWith(r)&&n.substr(a,1)===A.sep){let o=new Error(`Circular symlink detected: "${n}" points to "${r}"`);return o.code=ae,this._onError(o)}return"directory"}}catch(r){return this._onError(r),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}}});function ue(s,t,e,n,r){let i=(a,o)=>{e(s),r(a,o,{watchedPath:s}),o&&s!==o&&Z(p.resolve(s,o),I,p.join(s,o))};try{return(0,F.watch)(s,{persistent:t.persistent},i)}catch(a){n(a);return}}var F,x,p,he,Ge,kt,de,et,st,zt,Be,Ve,Ke,fe,E,D,Qe,Je,I,J,N,Xe,Ze,ts,Nt,q,es,Y,me,X,Z,ss,Ft,ns,tt,pe=ot(()=>{"use strict";F=require("fs"),x=require("fs/promises"),p=R(require("path"),1),he=require("os"),Ge="data",kt="end",de="close",et=()=>{},st=process.platform,zt=st==="win32",Be=st==="darwin",Ve=st==="linux",Ke=st==="freebsd",fe=(0,he.type)()==="OS400",E={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},D=E,Qe="watch",Je={lstat:x.lstat,stat:x.stat},I="listeners",J="errHandlers",N="rawEmitters",Xe=[I,J,N],Ze=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),ts=s=>Ze.has(p.extname(s).slice(1).toLowerCase()),Nt=(s,t)=>{s instanceof Set?s.forEach(t):t(s)},q=(s,t,e)=>{let n=s[t];n instanceof Set||(s[t]=n=new Set([n])),n.add(e)},es=s=>t=>{let e=s[t];e instanceof Set?e.clear():delete s[t]},Y=(s,t,e)=>{let n=s[t];n instanceof Set?n.delete(e):n===e&&delete s[t]},me=s=>s instanceof Set?s.size===0:!s,X=new Map;Z=(s,t,e,n,r)=>{let i=X.get(s);i&&Nt(i[t],a=>{a(e,n,r)})},ss=(s,t,e,n)=>{let{listener:r,errHandler:i,rawEmitter:a}=n,o=X.get(t),c;if(!e.persistent)return c=ue(s,e,r,i,a),c?c.close.bind(c):void 0;if(o)q(o,I,r),q(o,J,i),q(o,N,a);else{if(c=ue(s,e,Z.bind(null,t,I),i,Z.bind(null,t,N)),!c)return;c.on(D.ERROR,async l=>{let u=Z.bind(null,t,J);if(o&&(o.watcherUnusable=!0),zt&&l.code==="EPERM")try{await(await(0,x.open)(s,"r")).close(),u(l)}catch{}else u(l)}),o={listeners:r,errHandlers:i,rawEmitters:a,watcher:c},X.set(t,o)}return()=>{Y(o,I,r),Y(o,J,i),Y(o,N,a),me(o.listeners)&&(o.watcher.close(),X.delete(t),Xe.forEach(es(o)),o.watcher=void 0,Object.freeze(o))}},Ft=new Map,ns=(s,t,e,n)=>{let{listener:r,rawEmitter:i}=n,a=Ft.get(t),o=a&&a.options;return o&&(o.persistent<e.persistent||o.interval>e.interval)&&((0,F.unwatchFile)(t),a=void 0),a?(q(a,I,r),q(a,N,i)):(a={listeners:r,rawEmitters:i,options:e,watcher:(0,F.watchFile)(t,e,(c,l)=>{Nt(a.rawEmitters,h=>{h(D.CHANGE,t,{curr:c,prev:l})});let u=c.mtimeMs;(c.size!==l.size||u>l.mtimeMs||u===0)&&Nt(a.listeners,h=>h(s,c))})},Ft.set(t,a)),()=>{Y(a,I,r),Y(a,N,i),me(a.listeners)&&(Ft.delete(t),(0,F.unwatchFile)(t),a.options=a.watcher=void 0,Object.freeze(a))}},tt=class{constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let n=this.fsw.options,r=p.dirname(t),i=p.basename(t);this.fsw._getWatchedDir(r).add(i);let o=p.resolve(t),c={persistent:n.persistent};e||(e=et);let l;if(n.usePolling){let u=n.interval!==n.binaryInterval;c.interval=u&&ts(i)?n.binaryInterval:n.interval,l=ns(t,o,c,{listener:e,rawEmitter:this.fsw._emitRaw})}else l=ss(t,o,c,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return l}_handleFile(t,e,n){if(this.fsw.closed)return;let r=p.dirname(t),i=p.basename(t),a=this.fsw._getWatchedDir(r),o=e;if(a.has(i))return;let c=async(u,h)=>{if(this.fsw._throttle(Qe,t,5)){if(!h||h.mtimeMs===0)try{let d=await(0,x.stat)(t);if(this.fsw.closed)return;let f=d.atimeMs,y=d.mtimeMs;if((!f||f<=y||y!==o.mtimeMs)&&this.fsw._emit(D.CHANGE,t,d),(Be||Ve||Ke)&&o.ino!==d.ino){this.fsw._closeFile(u),o=d;let P=this._watchWithNodeFs(t,c);P&&this.fsw._addPathCloser(u,P)}else o=d}catch{this.fsw._remove(r,i)}else if(a.has(i)){let d=h.atimeMs,f=h.mtimeMs;(!d||d<=f||f!==o.mtimeMs)&&this.fsw._emit(D.CHANGE,t,h),o=h}}},l=this._watchWithNodeFs(t,c);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(D.ADD,t,0))return;this.fsw._emit(D.ADD,t,e)}return l}async _handleSymlink(t,e,n,r){if(this.fsw.closed)return;let i=t.fullPath,a=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let o;try{o=await(0,x.realpath)(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(r)?this.fsw._symlinkPaths.get(i)!==o&&(this.fsw._symlinkPaths.set(i,o),this.fsw._emit(D.CHANGE,n,t.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,o),this.fsw._emit(D.ADD,n,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(t,e,n,r,i,a,o){if(t=p.join(t,""),o=this.fsw._throttle("readdir",t,1e3),!o)return;let c=this.fsw._getWatchedDir(n.path),l=new Set,u=this.fsw._readdirp(t,{fileFilter:h=>n.filterPath(h),directoryFilter:h=>n.filterDir(h)});if(u)return u.on(Ge,async h=>{if(this.fsw.closed){u=void 0;return}let d=h.path,f=p.join(t,d);if(l.add(d),!(h.stats.isSymbolicLink()&&await this._handleSymlink(h,t,f,d))){if(this.fsw.closed){u=void 0;return}(d===r||!r&&!c.has(d))&&(this.fsw._incrReadyCount(),f=p.join(i,p.relative(i,f)),this._addToNodeFs(f,e,n,a+1))}}).on(D.ERROR,this._boundHandleError),new Promise((h,d)=>{if(!u)return d();u.once(kt,()=>{if(this.fsw.closed){u=void 0;return}let f=o?o.clear():!1;h(void 0),c.getChildren().filter(y=>y!==t&&!l.has(y)).forEach(y=>{this.fsw._remove(t,y)}),u=void 0,f&&this._handleRead(t,!1,n,r,i,a,o)})})}async _handleDir(t,e,n,r,i,a,o){let c=this.fsw._getWatchedDir(p.dirname(t)),l=c.has(p.basename(t));!(n&&this.fsw.options.ignoreInitial)&&!i&&!l&&this.fsw._emit(D.ADD_DIR,t,e),c.add(p.basename(t)),this.fsw._getWatchedDir(t);let u,h,d=this.fsw.options.depth;if((d==null||r<=d)&&!this.fsw._symlinkPaths.has(o)){if(!i&&(await this._handleRead(t,n,a,i,t,r,u),this.fsw.closed))return;h=this._watchWithNodeFs(t,(f,y)=>{y&&y.mtimeMs===0||this._handleRead(f,!1,a,i,t,r,u)})}return h}async _addToNodeFs(t,e,n,r,i){let a=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(t);n&&(o.filterPath=c=>n.filterPath(c),o.filterDir=c=>n.filterDir(c));try{let c=await Je[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,c))return a(),!1;let l=this.fsw.options.followSymlinks,u;if(c.isDirectory()){let h=p.resolve(t),d=l?await(0,x.realpath)(t):t;if(this.fsw.closed||(u=await this._handleDir(o.watchPath,c,e,r,i,o,d),this.fsw.closed))return;h!==d&&d!==void 0&&this.fsw._symlinkPaths.set(h,d)}else if(c.isSymbolicLink()){let h=l?await(0,x.realpath)(t):t;if(this.fsw.closed)return;let d=p.dirname(o.watchPath);if(this.fsw._getWatchedDir(d).add(o.watchPath),this.fsw._emit(D.ADD,o.watchPath,c),u=await this._handleDir(d,c,e,r,t,o,h),this.fsw.closed)return;h!==void 0&&this.fsw._symlinkPaths.set(p.resolve(t),h)}else u=this._handleFile(o.watchPath,c,e);return a(),u&&this.fsw._addPathCloser(t,u),!1}catch(c){if(this.fsw._handleError(c))return a(),t}}}});var Le={};qt(Le,{FSWatcher:()=>G,WatchHelper:()=>rt,default:()=>ws,watch:()=>Re});function nt(s){return Array.isArray(s)?s:[s]}function us(s){return typeof s=="function"?s:typeof s=="string"?t=>s===t:s instanceof RegExp?t=>s.test(t):typeof s=="object"&&s!==null?t=>{if(s.path===t)return!0;if(s.recursive){let e=m.relative(s.path,t);return e?!e.startsWith("..")&&!m.isAbsolute(e):!1}return!1}:()=>!1}function hs(s){if(typeof s!="string")throw new Error("string expected");s=m.normalize(s),s=s.replace(/\\/g,"/");let t=!1;s.startsWith("//")&&(t=!0);let e=/\/\//;for(;s.match(e);)s=s.replace(e,"/");return t&&(s="/"+s),s}function we(s,t,e){let n=hs(t);for(let r=0;r<s.length;r++){let i=s[r];if(i(n,e))return!0}return!1}function ds(s,t){if(s==null)throw new TypeError("anymatch: specify first argument");let n=nt(s).map(r=>us(r));return t==null?(r,i)=>we(n,r,i):we(n,t)}function Re(s,t={}){let e=new G(t);return e.add(s),e}var _e,it,Se,m,Wt,rs,Pe,is,os,as,ge,cs,ls,$t,Ee,ye,ve,Te,fs,ms,jt,ps,gs,rt,G,ws,De=ot(()=>{"use strict";_e=require("fs"),it=require("fs/promises"),Se=require("events"),m=R(require("path"),1);le();pe();Wt="/",rs="//",Pe=".",is="..",os="string",as=/\\/g,ge=/\/\//,cs=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,ls=/^\.[/\\]/;$t=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);Ee=s=>{let t=nt(s).flat();if(!t.every(e=>typeof e===os))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(ve)},ye=s=>{let t=s.replace(as,Wt),e=!1;for(t.startsWith(rs)&&(e=!0);t.match(ge);)t=t.replace(ge,Wt);return e&&(t=Wt+t),t},ve=s=>ye(m.normalize(ye(s))),Te=(s="")=>t=>typeof t=="string"?ve(m.isAbsolute(t)?t:m.join(s,t)):t,fs=(s,t)=>m.isAbsolute(s)?s:m.join(t,s),ms=Object.freeze(new Set),jt=class{constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&t!==Pe&&t!==is&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let n=this.path;try{await(0,it.readdir)(n)}catch{this._removeWatcher&&this._removeWatcher(m.dirname(n),m.basename(n))}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=et,this.items=ms,Object.freeze(this)}},ps="stat",gs="lstat",rt=class{constructor(t,e,n){this.fsw=n;let r=t;this.path=t=t.replace(ls,""),this.watchPath=r,this.fullWatchPath=m.resolve(r),this.dirParts=[],this.dirParts.forEach(i=>{i.length>1&&i.pop()}),this.followSymlinks=e,this.statMethod=e?ps:gs}entryPath(t){return m.join(this.watchPath,m.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let n=this.entryPath(t);return this.fsw._isntIgnored(n,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},G=class extends Se.EventEmitter{constructor(t={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let e=t.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?nt(t.ignored):nt([]),awaitWriteFinish:e===!0?n:typeof e=="object"?{...n,...e}:!1};fe&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let c=i.toLowerCase();c==="false"||c==="0"?r.usePolling=!1:c==="true"||c==="1"?r.usePolling=!0:r.usePolling=!!c}let a=process.env.CHOKIDAR_INTERVAL;a&&(r.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=et,this._readyEmitted=!0,process.nextTick(()=>this.emit(E.READY)))},this._emitRaw=(...c)=>this.emit(E.RAW,...c),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new tt(this),Object.freeze(r)}_addIgnoredPath(t){if($t(t)){for(let e of this._ignoredPaths)if($t(e)&&e.path===t.path&&e.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),typeof t=="string")for(let e of this._ignoredPaths)$t(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,n){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let i=Ee(t);return r&&(i=i.map(a=>fs(a,r))),i.forEach(a=>{this._removeIgnoredPath(a)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=i.length,Promise.all(i.map(async a=>{let o=await this._nodeFsHandler._addToNodeFs(a,!n,void 0,0,e);return o&&this._emitReady(),o})).then(a=>{this.closed||a.forEach(o=>{o&&this.add(m.dirname(o),m.basename(e||o))})}),this}unwatch(t){if(this.closed)return this;let e=Ee(t),{cwd:n}=this.options;return e.forEach(r=>{!m.isAbsolute(r)&&!this._closers.has(r)&&(n&&(r=m.join(n,r)),r=m.resolve(r)),this._closePath(r),this._addIgnoredPath(r),this._watched.has(r)&&this._addIgnoredPath({path:r,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let t=[];return this._closers.forEach(e=>e.forEach(n=>{let r=n();r instanceof Promise&&t.push(r)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,n)=>{let i=(this.options.cwd?m.relative(this.options.cwd,n):n)||Pe;t[i]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==E.ERROR&&this.emit(E.ALL,t,...e)}async _emit(t,e,n){if(this.closed)return;let r=this.options;zt&&(e=m.normalize(e)),r.cwd&&(e=m.relative(r.cwd,e));let i=[e];n!=null&&i.push(n);let a=r.awaitWriteFinish,o;if(a&&(o=this._pendingWrites.get(e)))return o.lastChange=new Date,this;if(r.atomic){if(t===E.UNLINK)return this._pendingUnlinks.set(e,[t,...i]),setTimeout(()=>{this._pendingUnlinks.forEach((c,l)=>{this.emit(...c),this.emit(E.ALL,...c),this._pendingUnlinks.delete(l)})},typeof r.atomic=="number"?r.atomic:100),this;t===E.ADD&&this._pendingUnlinks.has(e)&&(t=E.CHANGE,this._pendingUnlinks.delete(e))}if(a&&(t===E.ADD||t===E.CHANGE)&&this._readyEmitted){let c=(l,u)=>{l?(t=E.ERROR,i[0]=l,this.emitWithAll(t,i)):u&&(i.length>1?i[1]=u:i.push(u),this.emitWithAll(t,i))};return this._awaitWriteFinish(e,a.stabilityThreshold,t,c),this}if(t===E.CHANGE&&!this._throttle(E.CHANGE,e,50))return this;if(r.alwaysStat&&n===void 0&&(t===E.ADD||t===E.ADD_DIR||t===E.CHANGE)){let c=r.cwd?m.join(r.cwd,e):e,l;try{l=await(0,it.stat)(c)}catch{}if(!l||this.closed)return;i.push(l)}return this.emitWithAll(t,i),this}_handleError(t){let e=t&&t.code;return t&&e!=="ENOENT"&&e!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||e!=="EPERM"&&e!=="EACCES")&&this.emit(E.ERROR,t),t||this.closed}_throttle(t,e,n){this._throttled.has(t)||this._throttled.set(t,new Map);let r=this._throttled.get(t);if(!r)throw new Error("invalid throttle");let i=r.get(e);if(i)return i.count++,!1;let a,o=()=>{let l=r.get(e),u=l?l.count:0;return r.delete(e),clearTimeout(a),l&&clearTimeout(l.timeoutObject),u};a=setTimeout(o,n);let c={timeoutObject:a,clear:o,count:0};return r.set(e,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,n,r){let i=this.options.awaitWriteFinish;if(typeof i!="object")return;let a=i.pollInterval,o,c=t;this.options.cwd&&!m.isAbsolute(t)&&(c=m.join(this.options.cwd,t));let l=new Date,u=this._pendingWrites;function h(d){(0,_e.stat)(c,(f,y)=>{if(f||!u.has(t)){f&&f.code!=="ENOENT"&&r(f);return}let P=Number(new Date);d&&y.size!==d.size&&(u.get(t).lastChange=P);let g=u.get(t);P-g.lastChange>=e?(u.delete(t),r(void 0,y)):o=setTimeout(h,a,y)})}u.has(t)||(u.set(t,{lastChange:l,cancelWait:()=>(u.delete(t),clearTimeout(o),n)}),o=setTimeout(h,a))}_isIgnored(t,e){if(this.options.atomic&&cs.test(t))return!0;if(!this._userIgnored){let{cwd:n}=this.options,i=(this.options.ignored||[]).map(Te(n)),o=[...[...this._ignoredPaths].map(Te(n)),...i];this._userIgnored=ds(o,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new rt(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=m.resolve(t);return this._watched.has(e)||this._watched.set(e,new jt(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,e,n){let r=m.join(t,e),i=m.resolve(r);if(n=n??(this._watched.has(r)||this._watched.has(i)),!this._throttle("remove",r,100))return;!n&&this._watched.size===1&&this.add(t,e,!0),this._getWatchedDir(r).getChildren().forEach(d=>this._remove(r,d));let c=this._getWatchedDir(t),l=c.has(e);c.remove(e),this._symlinkPaths.has(i)&&this._symlinkPaths.delete(i);let u=r;if(this.options.cwd&&(u=m.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(u)&&this._pendingWrites.get(u).cancelWait()===E.ADD)return;this._watched.delete(r),this._watched.delete(i);let h=n?E.UNLINK_DIR:E.UNLINK;l&&!this._isIgnored(r)&&this._emit(h,r),this._closePath(r)}_closePath(t){this._closeFile(t);let e=m.dirname(t);this._getWatchedDir(e).remove(m.basename(t))}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(n=>n()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let n=this._closers.get(t);n||(n=[],this._closers.set(t,n)),n.push(e)}_readdirp(t,e){if(this.closed)return;let n={type:E.ALL,alwaysStat:!0,lstat:!0,...e,depth:0},r=ce(t,n);return this._streams.add(r),r.once(de,()=>{r=void 0}),r.once(kt,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};ws={watch:Re,FSWatcher:G}});var Es={};qt(Es,{TSFilebasedRouter:()=>xe,TSRouter:()=>Q,createEffect:()=>Lt,createSignal:()=>Rt,html:()=>at,loadPyFiles:()=>At,mapper:()=>Gt,renderChildRoutes:()=>vt,useAnchor:()=>j,useAnchorSingle:()=>wt,useInitialDOM:()=>pt,useTSAnchorMount:()=>xt,useTSAuth:()=>_t,useTSCollection:()=>yt,useTSComponent:()=>z,useTSElementEach:()=>W,useTSElements:()=>mt,useTSEvent:()=>ut,useTSEventAll:()=>ft,useTSExtractParams:()=>dt,useTSHashAnchor:()=>$,useTSLazy:()=>Mt,useTSMetaData:()=>Et,useTSNavigate:()=>St,useTSNoReload:()=>U,useTSOutlet:()=>Pt,useTSParams:()=>k,useTSPurifier:()=>lt,useTSSSRHydration:()=>Ot,useTSSelect:()=>Tt,useTSloadBrython:()=>bt});module.exports=He(Es);function Ie(s){return(s==null?"":String(s)).replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>.*?<\s*\/\s*\1\s*>/gi,"").replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>/gi,"").replace(/\son\w+\s*=\s*(['"]).*?\1/gi,"").replace(/\s(href|src)\s*=\s*(['"])\s*javascript:[^'"]*\2/gi,"")}function at(s,...t){return s.reduce((e,n,r)=>{let i=r<t.length?Ie(t[r]):"";return e+n+i},"")}var Fe=s=>s.replace(/<\/?(script|iframe|object|embed|link|meta|style)[^>]*>/gi,"").replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/\s+(href|src)\s*=\s*(['"]?)\s*javascript:[^'"\s>]*/gi,""),Gt=s=>s?.map(t=>Fe(t)).join("")??"";var ct=R(require("dompurify"),1),lt=(s,t)=>{let n={...{ADD_TAGS:["my-custom-tag"]},...t};return typeof s=="string"?ct.default.sanitize(s,n):ct.default.sanitize(s.innerHTML,n)};var ut=(s,t,e)=>{if(typeof s=="string"){let n=document.getElementById(s);n?n.addEventListener(t,e):console.warn(`Element with id '${s}' not found.`)}else s===document?document.addEventListener(t,e):console.warn("Invalid id parameter provided.")};var Bt=require("zustand/vanilla"),ht=R(require("dompurify"),1);function Ne(s,t){let e=[],n=s.replace(/:[^/]+/g,o=>(e.push(o.slice(1)),"([^/]+)")),r=new RegExp(`^${n}$`),i=t.match(r),a={};return i&&e.forEach((o,c)=>{a[o]=ht.default.sanitize(i[c+1]??"")}),a}function ke(s){let t={},e=new URLSearchParams(s);for(let[n,r]of e.entries())t[n]=ht.default.sanitize(r);return t}var k=(0,Bt.createStore)((s,t)=>({params:{},query:{},setFromPattern:e=>{let n=window.location.pathname,r=Ne(e,n),i=ke(window.location.search);s({params:r,query:i})},getParam:e=>t().params[e],getQuery:e=>t().query[e]}));function dt(s){let t=k.getState();t.setFromPattern(s);let e=t.params,n=t.query;return{...e,...n}}var ft=(s,t,e)=>{let n=document.querySelectorAll(s);return n.forEach(r=>{r.addEventListener(t,e)}),()=>{n.forEach(r=>{r.removeEventListener(t,e)})}};var V=R(require("dompurify"),1),mt=(s,t,e,n={})=>{let r={USE_PROFILES:{svg:!0,html:!0},ALLOWED_TAGS:["svg","path","circle","rect","line","polyline","polygon","g","main","div","h1","h2","h3","h4","h5","h6","p","button","span","a","img","input","ul","li","i"],ALLOWED_ATTR:["class","id","href","src","alt","fill","stroke","stroke-width","viewBox","xmlns","d","x","y","cx","cy","r","width","height","data-onclick","data-onchange","data-onselect"],FORBID_TAGS:["script","iframe"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|ftp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,...e};V.default.addHook("uponSanitizeElement",(a,o)=>{let c=o.tagName.toLowerCase();c.includes("-")&&(o.allowedTags[c]=!0)}),V.default.addHook("uponSanitizeAttribute",(a,o)=>{o.attrName&&o.attrName.toLowerCase().startsWith("on")&&(o.keepAttr=!1)});let i=V.default.sanitize(t,r);s.innerHTML=i,s.querySelectorAll("[data-onclick]").forEach(a=>{let o=a.dataset.onclick;n[o]&&a.addEventListener("click",n[o])}),s.querySelectorAll("[data-onchange]").forEach(a=>{let o=a.dataset.onchange;n[o]&&a.addEventListener("change",n[o])}),s.querySelectorAll("[data-onselect]").forEach(a=>{let o=a.dataset.onselect;n[o]&&a.addEventListener("select",n[o])})};var Vt=R(require("dompurify"),1),K=null,pt=(s,t)=>{if(typeof document>"u")return;let e=document.getElementById(s);if(!e)return;let n=e.innerHTML,i=Vt.default.sanitize(n,{ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br"],ALLOWED_ATTR:["href","src","alt","title","class","id","data-onclick","data-onchange"],ALLOW_DATA_ATTR:!1,KEEP_CONTENT:!1}).replace(/\b(href|src)=["']?(?!https?:|mailto:|\/|#)/gi,'$1="#"');if(K!==null&&i!==K){let a=document.createElement("div");t(a),e.innerHTML=K}else K=i,e.innerHTML=i,t(e)};var gt=R(require("dompurify"),1);typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",s=>{let t=s.state;t?.scrollPosition!==void 0&&window.scrollTo(0,t.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var wt=(s,t,e,n="",r=null)=>{if(!s)return;let i=gt.default.sanitize(t,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=gt.default.sanitize(e,{USE_PROFILES:{html:!1}});s.setAttribute("href",i),s.setAttribute("aria-label",a),n&&(s.className=n.trim()),r&&s.replaceChildren(r),typeof window<"u"&&s.addEventListener("click",o=>{o.preventDefault();let l=o.currentTarget.getAttribute("href");if(l){let u=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:u},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};var H=R(require("dompurify"),1);var Kt=(s="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",t="'self' 'nonce-rAnd0m123'",e="'none'",n="'self' https://fonts.googleapis.com https://fonts.gstatic.com",r="'self' https://blogger.googleusercontent.com",i=["'self'","https://fonts.googleapis.com","https://fonts.gstatic.com","https://www.google.com/maps/"],a="'self' https://www.youtube.com",o="'self'",c="/csp-report",l=!1)=>{let u=()=>{try{let h=document.querySelector('meta[http-equiv="Content-Security-Policy"]');h||(h=document.createElement("meta"),h.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(h));let d=l?`report-uri ${c};`:"";h.setAttribute("content",`default-src 'self'; script-src ${s}; style-src ${t}; object-src ${e}; font-src ${n}; img-src ${r}; connect-src ${i.join(" ")}; frame-src ${a}; base-uri ${o}; ${d}`)}catch(h){console.error("Error adding CSP meta element:",h)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",u):u()};var Et=(s,t)=>{let e={name:H.default.sanitize(s.name||""),description:H.default.sanitize(s.description||"Default description"),author:H.default.sanitize(s.author||"")},n=f=>{e.name=H.default.sanitize(f),h("name",e.name)},r=f=>{e.description=H.default.sanitize(f),h("description",e.description)},i=f=>{e.author=H.default.sanitize(f),h("author",e.author)},a=()=>e.name,o=()=>e.description,c=()=>e.author,l=()=>e,u=(f,y)=>{let P=document.createElement("meta");P.setAttribute("name",f),P.setAttribute("content",y),document.head.appendChild(P)},h=(f,y)=>{let P=document.querySelector(`meta[name="${f}"]`);P?P.setAttribute("content",y):u(f,y)},d=()=>{h("name",e.name),h("description",e.description),h("author",e.author)};return t&&Kt(t.scriptSrc,t.styleSrc,t.objectSrc,Array.isArray(t.connectSrc)?t.connectSrc.join(" "):t.connectSrc,t.reportOnly!==void 0?String(t.reportOnly):void 0),d(),{setName:n,setDescription:r,setAuthor:i,getName:a,getDescription:o,getAuthor:c,getAllMetaData:l,appendMetaTagsToHead:d}};var Qt=R(require("dompurify"),1),z=(s,t,e,n,r)=>{let i=`#${s}`,a=t.querySelectorAll(i);if(a.length===0)throw new Error(`[useTSComponent] No element found with id '${s}' in the given parent.`);if(a.length>1)throw new Error(`[useTSComponent] Duplicate id '${s}' detected. Found ${a.length} elements.`);let o=a[0];o.innerHTML=Qt.default.sanitize(o.innerHTML,{USE_PROFILES:{html:!0}}),e(o,n,r)};var yt=(s,t,e,n=[])=>{let r=new Set;s.forEach((i,a)=>{if(r.has(i)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${i}" \u2014 skipping.`);return}r.add(i);let o=t.querySelectorAll(`#${i}`);if(o.length>1){console.warn(`[useTSCollection] Duplicate ID in DOM: "${i}" (${o.length} elements found) \u2014 skipping component mount.`);return}let c=e[a],l=Array.isArray(n)?n[a]:void 0;typeof c=="function"?z(i,t,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var Tt=(s,t)=>{let n=(t??document).querySelectorAll(s);if(n.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${s}'`),null;if(s.startsWith("#")&&n.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${s}'. Found ${n.length} elements with this ID.`);return n[0]}return n.length>1&&process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] Multiple elements found for selector: '${s}'. Returning the first one.`),n[0]};var Jt=require("jwt-decode"),_t=(s,t)=>{let e=localStorage.getItem("token");if(!e)return window.location.href=t,null;try{let n=(0,Jt.jwtDecode)(e),r=Date.now()/1e3;return n.exp&&n.exp<r&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=t),null}catch(n){return console.error("Invalid token:",n),window.location.href=t,null}};var W=(s,t,e)=>{s.forEach(n=>{t.forEach(r=>{n.addEventListener(r,i=>{e(n,i)})})})};var St=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var Pt=(s,t)=>{let e=document.querySelector(`#${s}`)||document.querySelector(`.${s}`);if(!e)return;let n=window.location.pathname.replace(/\/$/,"");for(let r of t){let i=r.path.replace(/\/$/,"");if(n===i||n.startsWith(`${i}/`)){r.component(e);break}}};function vt(s,t){let e=window.location.pathname.replace(/\/$/,"");t.routes.forEach(n=>{n.children?.length&&n.children.forEach(r=>{let i=r.path.replace(/\/$/,"");if(e===i||e.startsWith(`${i}/`)){let a=s.querySelector(`#${r.outlet}`)||s.querySelector(`.${r.outlet}`);a instanceof HTMLElement&&r.element&&r.element(a)}})})}var Xt=require("zustand/vanilla");function Rt(s){let t=(0,Xt.createStore)(()=>({value:s})),e=new Set;return{get:()=>t.getState().value,set:n=>{t.setState({value:n}),e.forEach(r=>r(n))},subscribe:n=>(e.add(n),n(t.getState().value),()=>e.delete(n))}}function Lt(s){let t=s();typeof t=="function"&&t()}var $=()=>{let s=document.querySelectorAll('a[href^="#"]');W(s,["click"],(t,e)=>{e.preventDefault();let n=t.getAttribute("href")?.substring(1),r=n?document.getElementById(n):null;r&&r.scrollIntoView({behavior:"smooth",block:"start"})})};var Zt=require("lodash-es"),Dt=s=>s;typeof window<"u"&&typeof document<"u"&&(Dt=s=>{let t=document.createElement("div");return t.innerText=s,t.innerHTML});var ze=s=>{(s?Array.isArray(s)?s:s instanceof HTMLAnchorElement?[s]:Array.from(s):Array.from(document.querySelectorAll("a"))).forEach(e=>{if(!e||e.dataset.anchorEnhanced==="true")return;e.dataset.anchorEnhanced="true";let n=e.getAttribute("class")||"";e.setAttribute("class",Dt(n));let r=e.getAttribute("aria-label");r&&e.setAttribute("aria-label",Dt(r));let i=e.querySelector(":scope > *");i&&(e.innerHTML="",e.appendChild(i));let a=e.getAttribute("href")||"";if(!a.startsWith("#")){try{if(new URL(a,window.location.href).origin!==window.location.origin)return}catch{return}e.addEventListener("click",o=>{o.preventDefault();let c=e.getAttribute("href")||"";try{let l=new URL(c,window.location.href);window.history.pushState({},"",l.pathname+l.search+l.hash),window.dispatchEvent(new PopStateEvent("popstate"))}catch(l){console.error("Invalid URL in anchor:",c,l)}})}})},We=(0,Zt.debounce)(ze,50),j=s=>{We(s)};var U=s=>{let t=s.querySelectorAll("a");j(t)};var xt=s=>{$(),U(s)};var bt=async()=>{let s="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",t="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",e=n=>new Promise((r,i)=>{let a=document.createElement("script");a.src=n,a.onload=()=>r(),a.onerror=()=>i(new Error(`Failed to load ${n}`)),document.head.appendChild(a)});await e(s),await e(t),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},At=s=>new Promise((t,e)=>{let n=document.createElement("script");n.type="text/python",n.src=`/src/python/${s}`,n.onload=()=>t(),n.onerror=()=>e(new Error(`Failed to load ${s}`)),document.body.appendChild(n)});function Mt(s){let t=null;return async(e,n)=>{try{if(!t){let r=await s();t=r.default||r}if(typeof t=="function")return t(e,n);if(t instanceof HTMLElement){e?.appendChild(t);return}if(t&&typeof t.render=="function")return t.render(e,n);console.warn("useTSLazy: Unsupported module type",t)}catch(r){console.error("useTSLazy failed:",r)}}}var Ot=s=>typeof window>"u"?{isDOM:null}:{isDOM:s||document.body};var Ct=R(require("dompurify"),1);var ee=require("zustand/vanilla"),se=R(require("dompurify"),1),C=(0,ee.createStore)(s=>({params:{},query:{},setParams:t=>s(()=>({params:te(t)})),setQuery:t=>s(()=>({query:te(t)}))}));function te(s){let t={};for(let e in s)t[e]=se.default.sanitize(s[e]);return t}var Q=class{constructor(t,e){this.routes=[];this.routes=t,this.expectedParams=new Set(e),window.addEventListener("popstate",this.handlePopState.bind(this)),this.handlePopState()}handlePopState(){let t=window.location.pathname,e=window.location.search,n=this.parseQueryParams(e),r=this.findMatchingRoute(t,this.routes);if(r){if(r.routeto){this.navigate(r.routeto);return}let i=this.filterAndSanitizeParams(r.params);C.getState().setParams(i),C.getState().setQuery(n);let a=document.createElement("div");if(r.element?.(a,i,n),r.children){let o=t.slice(r.path.length),c=a.querySelector("#child");c&&this.renderChildren(r.children,o,c,i,n)}}else{let i=this.findMatchingRoute("*",this.routes);if(i){let a=this.filterAndSanitizeParams(i.params);C.getState().setParams(a),C.getState().setQuery(n);let o=document.createElement("div");i.element?.(o,a,n)}}}renderChildren(t,e,n,r,i){if(!t||t.length===0){let o=n.querySelector("#child");o&&o.remove();return}let a=this.findMatchingRoute(e,t);if(a){let o=document.createElement("div");o.id="child";let c={...r,...a.params},l=this.filterAndSanitizeParams(c);if(C.getState().setParams(l),C.getState().setQuery(i),a.element?.(o,l,i),n.appendChild(o),a.children){let u=e.slice(a.path.length);this.renderChildren(a.children,u,o,l,i)}}}parseQueryParams(t){let e={},n=new URLSearchParams(t);for(let[r,i]of n.entries())this.expectedParams.has(r)&&(e[r]=Ct.default.sanitize(i));return e}findMatchingRoute(t,e,n={}){for(let r of e){let i=r.path;if(i==="*")return r;{let o=[],c=i.replace(/:[^\s/]+/g,h=>(o.push(h.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),u=t.match(l);if(u){let h={...n};if(o.forEach((d,f)=>{h[d]=u[f+1]??""}),r.children){let d=t.slice(u[0].length),f=this.findMatchingRoute(d,r.children,h);if(f)return f}return{...r,params:h}}}}}filterAndSanitizeParams(t){if(!t)return{};let e={};for(let n in t)this.expectedParams.has(n)&&(e[n]=Ct.default.sanitize(t[n]??""));return e}navigate(t){history.pushState(null,"",t),this.handlePopState()}addRoute(t){this.routes.push(t)}};var xe=()=>({name:"ts-filebased-router",async buildStart(){if(typeof process>"u"||!process.versions?.node)return;let s=await import("fs/promises"),t=await import("path"),e=await Promise.resolve().then(()=>(De(),Le)),n=t.resolve("src/pages"),r=t.resolve("src/gen"),i=t.resolve("src/routes"),a=t.join(r,"tsrouter.gen.ts"),o=t.join(i,"__root.ts");async function c(g){try{await s.mkdir(g,{recursive:!0})}catch{}}function l(g,w){let T="/"+t.relative(w,g).replace(/\\/g,"/");return T=T.replace(/\.ts$/,"").replace(/\/index$/,"")||"/",T.replace(/\[(.+?)\]/g,":$1")}function u(g){return g.replace(/^\//,"").split("/").map(w=>w.startsWith(":")?w.slice(1):w).filter(Boolean).join("-")||"index"}function h(g,w){let S=t.relative(w,g).replace(/\\/g,"/").split("/").filter(Boolean),v=S[S.length-1].replace(".ts",""),M=S.length>1?S[S.length-2]:"";if(v.startsWith("[")&&v.endsWith("]")){let O=v.slice(1,-1);return M.charAt(0).toUpperCase()+M.slice(1)+O.charAt(0).toUpperCase()+O.slice(1)+"Param"}else return v.charAt(0).toUpperCase()+v.slice(1)}async function d(g){let w=await s.readdir(g,{withFileTypes:!0}),T=[];for(let S of w){let v=t.join(g,S.name);if(S.isDirectory())T=T.concat(await d(v));else if(S.isFile()&&S.name.endsWith(".ts")){let M=l(v,n),O=u(M),_=h(v,n);T.push({file:v,route:M,routeName:O,importName:_})}}return T}function f(g,w){let T=w.includes(":"),S=T?w.match(/:([^/]+)/)?.[1]:null;return`import { html, useTSElements, useTSMetaData${T?", useTSExtractParams":""} } from '@devwareng/vanilla-ts';
|
|
1
|
+
"use strict";var Ae=Object.create;var V=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Oe=Object.getOwnPropertyNames;var Ce=Object.getPrototypeOf,He=Object.prototype.hasOwnProperty;var at=(s,t)=>()=>(s&&(t=s(s=0)),t);var Yt=(s,t)=>{for(var e in t)V(s,e,{get:t[e],enumerable:!0})},Gt=(s,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Oe(t))!He.call(s,r)&&r!==e&&V(s,r,{get:()=>t[r],enumerable:!(n=Me(t,r))||n.enumerable});return s};var R=(s,t,e)=>(e=s!=null?Ae(Ce(s)):{},Gt(t||!s||!s.__esModule?V(e,"default",{value:s,enumerable:!0}):e,s)),Ie=s=>Gt(V({},"__esModule",{value:!0}),s);function le(s,t={}){let e=t.entryType||t.type;if(e==="both"&&(e=L.FILE_DIR_TYPE),e&&(t.type=e),s){if(typeof s!="string")throw new TypeError("readdirp: root argument must be a string. Usage: readdirp(root, options)");if(e&&!re.includes(e))throw new Error(`readdirp: Invalid type passed. Use one of ${re.join(", ")}`)}else throw new Error("readdirp: root argument is required. Usage: readdirp(root, options)");return t.root=s,new Nt(t)}var b,ae,A,L,It,ce,je,re,Ue,qe,Ye,Ge,ie,oe,Nt,ue=at(()=>{"use strict";b=require("fs/promises"),ae=require("stream"),A=require("path"),L={FILE_TYPE:"files",DIR_TYPE:"directories",FILE_DIR_TYPE:"files_directories",EVERYTHING_TYPE:"all"},It={root:".",fileFilter:s=>!0,directoryFilter:s=>!0,type:L.FILE_TYPE,lstat:!1,depth:2147483648,alwaysStat:!1,highWaterMark:4096};Object.freeze(It);ce="READDIRP_RECURSIVE_ERROR",je=new Set(["ENOENT","EPERM","EACCES","ELOOP",ce]),re=[L.DIR_TYPE,L.EVERYTHING_TYPE,L.FILE_DIR_TYPE,L.FILE_TYPE],Ue=new Set([L.DIR_TYPE,L.EVERYTHING_TYPE,L.FILE_DIR_TYPE]),qe=new Set([L.EVERYTHING_TYPE,L.FILE_DIR_TYPE,L.FILE_TYPE]),Ye=s=>je.has(s.code),Ge=process.platform==="win32",ie=s=>!0,oe=s=>{if(s===void 0)return ie;if(typeof s=="function")return s;if(typeof s=="string"){let t=s.trim();return e=>e.basename===t}if(Array.isArray(s)){let t=s.map(e=>e.trim());return e=>t.some(n=>e.basename===n)}return ie},Nt=class extends ae.Readable{constructor(t={}){super({objectMode:!0,autoDestroy:!0,highWaterMark:t.highWaterMark});let e={...It,...t},{root:n,type:r}=e;this._fileFilter=oe(e.fileFilter),this._directoryFilter=oe(e.directoryFilter);let i=e.lstat?b.lstat:b.stat;Ge?this._stat=a=>i(a,{bigint:!0}):this._stat=i,this._maxDepth=e.depth??It.depth,this._wantsDir=r?Ue.has(r):!1,this._wantsFile=r?qe.has(r):!1,this._wantsEverything=r===L.EVERYTHING_TYPE,this._root=(0,A.resolve)(n),this._isDirent=!e.alwaysStat,this._statsProp=this._isDirent?"dirent":"stats",this._rdOptions={encoding:"utf8",withFileTypes:this._isDirent},this.parents=[this._exploreDir(n,1)],this.reading=!1,this.parent=void 0}async _read(t){if(!this.reading){this.reading=!0;try{for(;!this.destroyed&&t>0;){let e=this.parent,n=e&&e.files;if(n&&n.length>0){let{path:r,depth:i}=e,a=n.splice(0,t).map(c=>this._formatEntry(c,r)),o=await Promise.all(a);for(let c of o){if(!c)continue;if(this.destroyed)return;let l=await this._getEntryType(c);l==="directory"&&this._directoryFilter(c)?(i<=this._maxDepth&&this.parents.push(this._exploreDir(c.fullPath,i+1)),this._wantsDir&&(this.push(c),t--)):(l==="file"||this._includeAsFile(c))&&this._fileFilter(c)&&this._wantsFile&&(this.push(c),t--)}}else{let r=this.parents.pop();if(!r){this.push(null);break}if(this.parent=await r,this.destroyed)return}}}catch(e){this.destroy(e)}finally{this.reading=!1}}}async _exploreDir(t,e){let n;try{n=await(0,b.readdir)(t,this._rdOptions)}catch(r){this._onError(r)}return{files:n,depth:e,path:t}}async _formatEntry(t,e){let n,r=this._isDirent?t.name:t;try{let i=(0,A.resolve)((0,A.join)(e,r));n={path:(0,A.relative)(this._root,i),fullPath:i,basename:r},n[this._statsProp]=this._isDirent?t:await this._stat(i)}catch(i){this._onError(i);return}return n}_onError(t){Ye(t)&&!this.destroyed?this.emit("warn",t):this.destroy(t)}async _getEntryType(t){if(!t&&this._statsProp in t)return"";let e=t[this._statsProp];if(e.isFile())return"file";if(e.isDirectory())return"directory";if(e&&e.isSymbolicLink()){let n=t.fullPath;try{let r=await(0,b.realpath)(n),i=await(0,b.lstat)(r);if(i.isFile())return"file";if(i.isDirectory()){let a=r.length;if(n.startsWith(r)&&n.substr(a,1)===A.sep){let o=new Error(`Circular symlink detected: "${n}" points to "${r}"`);return o.code=ce,this._onError(o)}return"directory"}}catch(r){return this._onError(r),""}}}_includeAsFile(t){let e=t&&t[this._statsProp];return e&&this._wantsEverything&&!e.isDirectory()}}});function he(s,t,e,n,r){let i=(a,o)=>{e(s),r(a,o,{watchedPath:s}),o&&s!==o&&tt(p.resolve(s,o),I,p.join(s,o))};try{return(0,N.watch)(s,{persistent:t.persistent},i)}catch(a){n(a);return}}var N,x,p,de,Be,zt,fe,st,nt,Wt,Ve,Ke,Qe,me,g,D,Je,Xe,I,X,F,Ze,ts,es,kt,q,ss,Y,pe,Z,tt,ns,Ft,rs,et,ge=at(()=>{"use strict";N=require("fs"),x=require("fs/promises"),p=R(require("path"),1),de=require("os"),Be="data",zt="end",fe="close",st=()=>{},nt=process.platform,Wt=nt==="win32",Ve=nt==="darwin",Ke=nt==="linux",Qe=nt==="freebsd",me=(0,de.type)()==="OS400",g={ALL:"all",READY:"ready",ADD:"add",CHANGE:"change",ADD_DIR:"addDir",UNLINK:"unlink",UNLINK_DIR:"unlinkDir",RAW:"raw",ERROR:"error"},D=g,Je="watch",Xe={lstat:x.lstat,stat:x.stat},I="listeners",X="errHandlers",F="rawEmitters",Ze=[I,X,F],ts=new Set(["3dm","3ds","3g2","3gp","7z","a","aac","adp","afdesign","afphoto","afpub","ai","aif","aiff","alz","ape","apk","appimage","ar","arj","asf","au","avi","bak","baml","bh","bin","bk","bmp","btif","bz2","bzip2","cab","caf","cgm","class","cmx","cpio","cr2","cur","dat","dcm","deb","dex","djvu","dll","dmg","dng","doc","docm","docx","dot","dotm","dra","DS_Store","dsk","dts","dtshd","dvb","dwg","dxf","ecelp4800","ecelp7470","ecelp9600","egg","eol","eot","epub","exe","f4v","fbs","fh","fla","flac","flatpak","fli","flv","fpx","fst","fvt","g3","gh","gif","graffle","gz","gzip","h261","h263","h264","icns","ico","ief","img","ipa","iso","jar","jpeg","jpg","jpgv","jpm","jxr","key","ktx","lha","lib","lvp","lz","lzh","lzma","lzo","m3u","m4a","m4v","mar","mdi","mht","mid","midi","mj2","mka","mkv","mmr","mng","mobi","mov","movie","mp3","mp4","mp4a","mpeg","mpg","mpga","mxu","nef","npx","numbers","nupkg","o","odp","ods","odt","oga","ogg","ogv","otf","ott","pages","pbm","pcx","pdb","pdf","pea","pgm","pic","png","pnm","pot","potm","potx","ppa","ppam","ppm","pps","ppsm","ppsx","ppt","pptm","pptx","psd","pya","pyc","pyo","pyv","qt","rar","ras","raw","resources","rgb","rip","rlc","rmf","rmvb","rpm","rtf","rz","s3m","s7z","scpt","sgi","shar","snap","sil","sketch","slk","smv","snk","so","stl","suo","sub","swf","tar","tbz","tbz2","tga","tgz","thmx","tif","tiff","tlz","ttc","ttf","txz","udf","uvh","uvi","uvm","uvp","uvs","uvu","viv","vob","war","wav","wax","wbmp","wdp","weba","webm","webp","whl","wim","wm","wma","wmv","wmx","woff","woff2","wrm","wvx","xbm","xif","xla","xlam","xls","xlsb","xlsm","xlsx","xlt","xltm","xltx","xm","xmind","xpi","xpm","xwd","xz","z","zip","zipx"]),es=s=>ts.has(p.extname(s).slice(1).toLowerCase()),kt=(s,t)=>{s instanceof Set?s.forEach(t):t(s)},q=(s,t,e)=>{let n=s[t];n instanceof Set||(s[t]=n=new Set([n])),n.add(e)},ss=s=>t=>{let e=s[t];e instanceof Set?e.clear():delete s[t]},Y=(s,t,e)=>{let n=s[t];n instanceof Set?n.delete(e):n===e&&delete s[t]},pe=s=>s instanceof Set?s.size===0:!s,Z=new Map;tt=(s,t,e,n,r)=>{let i=Z.get(s);i&&kt(i[t],a=>{a(e,n,r)})},ns=(s,t,e,n)=>{let{listener:r,errHandler:i,rawEmitter:a}=n,o=Z.get(t),c;if(!e.persistent)return c=he(s,e,r,i,a),c?c.close.bind(c):void 0;if(o)q(o,I,r),q(o,X,i),q(o,F,a);else{if(c=he(s,e,tt.bind(null,t,I),i,tt.bind(null,t,F)),!c)return;c.on(D.ERROR,async l=>{let u=tt.bind(null,t,X);if(o&&(o.watcherUnusable=!0),Wt&&l.code==="EPERM")try{await(await(0,x.open)(s,"r")).close(),u(l)}catch{}else u(l)}),o={listeners:r,errHandlers:i,rawEmitters:a,watcher:c},Z.set(t,o)}return()=>{Y(o,I,r),Y(o,X,i),Y(o,F,a),pe(o.listeners)&&(o.watcher.close(),Z.delete(t),Ze.forEach(ss(o)),o.watcher=void 0,Object.freeze(o))}},Ft=new Map,rs=(s,t,e,n)=>{let{listener:r,rawEmitter:i}=n,a=Ft.get(t),o=a&&a.options;return o&&(o.persistent<e.persistent||o.interval>e.interval)&&((0,N.unwatchFile)(t),a=void 0),a?(q(a,I,r),q(a,F,i)):(a={listeners:r,rawEmitters:i,options:e,watcher:(0,N.watchFile)(t,e,(c,l)=>{kt(a.rawEmitters,h=>{h(D.CHANGE,t,{curr:c,prev:l})});let u=c.mtimeMs;(c.size!==l.size||u>l.mtimeMs||u===0)&&kt(a.listeners,h=>h(s,c))})},Ft.set(t,a)),()=>{Y(a,I,r),Y(a,F,i),pe(a.listeners)&&(Ft.delete(t),(0,N.unwatchFile)(t),a.options=a.watcher=void 0,Object.freeze(a))}},et=class{constructor(t){this.fsw=t,this._boundHandleError=e=>t._handleError(e)}_watchWithNodeFs(t,e){let n=this.fsw.options,r=p.dirname(t),i=p.basename(t);this.fsw._getWatchedDir(r).add(i);let o=p.resolve(t),c={persistent:n.persistent};e||(e=st);let l;if(n.usePolling){let u=n.interval!==n.binaryInterval;c.interval=u&&es(i)?n.binaryInterval:n.interval,l=rs(t,o,c,{listener:e,rawEmitter:this.fsw._emitRaw})}else l=ns(t,o,c,{listener:e,errHandler:this._boundHandleError,rawEmitter:this.fsw._emitRaw});return l}_handleFile(t,e,n){if(this.fsw.closed)return;let r=p.dirname(t),i=p.basename(t),a=this.fsw._getWatchedDir(r),o=e;if(a.has(i))return;let c=async(u,h)=>{if(this.fsw._throttle(Je,t,5)){if(!h||h.mtimeMs===0)try{let d=await(0,x.stat)(t);if(this.fsw.closed)return;let f=d.atimeMs,E=d.mtimeMs;if((!f||f<=E||E!==o.mtimeMs)&&this.fsw._emit(D.CHANGE,t,d),(Ve||Ke||Qe)&&o.ino!==d.ino){this.fsw._closeFile(u),o=d;let P=this._watchWithNodeFs(t,c);P&&this.fsw._addPathCloser(u,P)}else o=d}catch{this.fsw._remove(r,i)}else if(a.has(i)){let d=h.atimeMs,f=h.mtimeMs;(!d||d<=f||f!==o.mtimeMs)&&this.fsw._emit(D.CHANGE,t,h),o=h}}},l=this._watchWithNodeFs(t,c);if(!(n&&this.fsw.options.ignoreInitial)&&this.fsw._isntIgnored(t)){if(!this.fsw._throttle(D.ADD,t,0))return;this.fsw._emit(D.ADD,t,e)}return l}async _handleSymlink(t,e,n,r){if(this.fsw.closed)return;let i=t.fullPath,a=this.fsw._getWatchedDir(e);if(!this.fsw.options.followSymlinks){this.fsw._incrReadyCount();let o;try{o=await(0,x.realpath)(n)}catch{return this.fsw._emitReady(),!0}return this.fsw.closed?void 0:(a.has(r)?this.fsw._symlinkPaths.get(i)!==o&&(this.fsw._symlinkPaths.set(i,o),this.fsw._emit(D.CHANGE,n,t.stats)):(a.add(r),this.fsw._symlinkPaths.set(i,o),this.fsw._emit(D.ADD,n,t.stats)),this.fsw._emitReady(),!0)}if(this.fsw._symlinkPaths.has(i))return!0;this.fsw._symlinkPaths.set(i,!0)}_handleRead(t,e,n,r,i,a,o){if(t=p.join(t,""),o=this.fsw._throttle("readdir",t,1e3),!o)return;let c=this.fsw._getWatchedDir(n.path),l=new Set,u=this.fsw._readdirp(t,{fileFilter:h=>n.filterPath(h),directoryFilter:h=>n.filterDir(h)});if(u)return u.on(Be,async h=>{if(this.fsw.closed){u=void 0;return}let d=h.path,f=p.join(t,d);if(l.add(d),!(h.stats.isSymbolicLink()&&await this._handleSymlink(h,t,f,d))){if(this.fsw.closed){u=void 0;return}(d===r||!r&&!c.has(d))&&(this.fsw._incrReadyCount(),f=p.join(i,p.relative(i,f)),this._addToNodeFs(f,e,n,a+1))}}).on(D.ERROR,this._boundHandleError),new Promise((h,d)=>{if(!u)return d();u.once(zt,()=>{if(this.fsw.closed){u=void 0;return}let f=o?o.clear():!1;h(void 0),c.getChildren().filter(E=>E!==t&&!l.has(E)).forEach(E=>{this.fsw._remove(t,E)}),u=void 0,f&&this._handleRead(t,!1,n,r,i,a,o)})})}async _handleDir(t,e,n,r,i,a,o){let c=this.fsw._getWatchedDir(p.dirname(t)),l=c.has(p.basename(t));!(n&&this.fsw.options.ignoreInitial)&&!i&&!l&&this.fsw._emit(D.ADD_DIR,t,e),c.add(p.basename(t)),this.fsw._getWatchedDir(t);let u,h,d=this.fsw.options.depth;if((d==null||r<=d)&&!this.fsw._symlinkPaths.has(o)){if(!i&&(await this._handleRead(t,n,a,i,t,r,u),this.fsw.closed))return;h=this._watchWithNodeFs(t,(f,E)=>{E&&E.mtimeMs===0||this._handleRead(f,!1,a,i,t,r,u)})}return h}async _addToNodeFs(t,e,n,r,i){let a=this.fsw._emitReady;if(this.fsw._isIgnored(t)||this.fsw.closed)return a(),!1;let o=this.fsw._getWatchHelpers(t);n&&(o.filterPath=c=>n.filterPath(c),o.filterDir=c=>n.filterDir(c));try{let c=await Xe[o.statMethod](o.watchPath);if(this.fsw.closed)return;if(this.fsw._isIgnored(o.watchPath,c))return a(),!1;let l=this.fsw.options.followSymlinks,u;if(c.isDirectory()){let h=p.resolve(t),d=l?await(0,x.realpath)(t):t;if(this.fsw.closed||(u=await this._handleDir(o.watchPath,c,e,r,i,o,d),this.fsw.closed))return;h!==d&&d!==void 0&&this.fsw._symlinkPaths.set(h,d)}else if(c.isSymbolicLink()){let h=l?await(0,x.realpath)(t):t;if(this.fsw.closed)return;let d=p.dirname(o.watchPath);if(this.fsw._getWatchedDir(d).add(o.watchPath),this.fsw._emit(D.ADD,o.watchPath,c),u=await this._handleDir(d,c,e,r,t,o,h),this.fsw.closed)return;h!==void 0&&this.fsw._symlinkPaths.set(p.resolve(t),h)}else u=this._handleFile(o.watchPath,c,e);return a(),u&&this.fsw._addPathCloser(t,u),!1}catch(c){if(this.fsw._handleError(c))return a(),t}}}});var De={};Yt(De,{FSWatcher:()=>G,WatchHelper:()=>it,default:()=>ws,watch:()=>Le});function rt(s){return Array.isArray(s)?s:[s]}function hs(s){return typeof s=="function"?s:typeof s=="string"?t=>s===t:s instanceof RegExp?t=>s.test(t):typeof s=="object"&&s!==null?t=>{if(s.path===t)return!0;if(s.recursive){let e=m.relative(s.path,t);return e?!e.startsWith("..")&&!m.isAbsolute(e):!1}return!1}:()=>!1}function ds(s){if(typeof s!="string")throw new Error("string expected");s=m.normalize(s),s=s.replace(/\\/g,"/");let t=!1;s.startsWith("//")&&(t=!0);let e=/\/\//;for(;s.match(e);)s=s.replace(e,"/");return t&&(s="/"+s),s}function we(s,t,e){let n=ds(t);for(let r=0;r<s.length;r++){let i=s[r];if(i(n,e))return!0}return!1}function fs(s,t){if(s==null)throw new TypeError("anymatch: specify first argument");let n=rt(s).map(r=>hs(r));return t==null?(r,i)=>we(n,r,i):we(n,t)}function Le(s,t={}){let e=new G(t);return e.add(s),e}var Se,ot,Pe,m,$t,is,ve,os,as,cs,Ee,ls,us,jt,ye,Te,Re,_e,ms,ps,Ut,gs,Es,it,G,ws,xe=at(()=>{"use strict";Se=require("fs"),ot=require("fs/promises"),Pe=require("events"),m=R(require("path"),1);ue();ge();$t="/",is="//",ve=".",os="..",as="string",cs=/\\/g,Ee=/\/\//,ls=/\..*\.(sw[px])$|~$|\.subl.*\.tmp/,us=/^\.[/\\]/;jt=s=>typeof s=="object"&&s!==null&&!(s instanceof RegExp);ye=s=>{let t=rt(s).flat();if(!t.every(e=>typeof e===as))throw new TypeError(`Non-string provided as watch path: ${t}`);return t.map(Re)},Te=s=>{let t=s.replace(cs,$t),e=!1;for(t.startsWith(is)&&(e=!0);t.match(Ee);)t=t.replace(Ee,$t);return e&&(t=$t+t),t},Re=s=>Te(m.normalize(Te(s))),_e=(s="")=>t=>typeof t=="string"?Re(m.isAbsolute(t)?t:m.join(s,t)):t,ms=(s,t)=>m.isAbsolute(s)?s:m.join(t,s),ps=Object.freeze(new Set),Ut=class{constructor(t,e){this.path=t,this._removeWatcher=e,this.items=new Set}add(t){let{items:e}=this;e&&t!==ve&&t!==os&&e.add(t)}async remove(t){let{items:e}=this;if(!e||(e.delete(t),e.size>0))return;let n=this.path;try{await(0,ot.readdir)(n)}catch{this._removeWatcher&&this._removeWatcher(m.dirname(n),m.basename(n))}}has(t){let{items:e}=this;if(e)return e.has(t)}getChildren(){let{items:t}=this;return t?[...t.values()]:[]}dispose(){this.items.clear(),this.path="",this._removeWatcher=st,this.items=ps,Object.freeze(this)}},gs="stat",Es="lstat",it=class{constructor(t,e,n){this.fsw=n;let r=t;this.path=t=t.replace(us,""),this.watchPath=r,this.fullWatchPath=m.resolve(r),this.dirParts=[],this.dirParts.forEach(i=>{i.length>1&&i.pop()}),this.followSymlinks=e,this.statMethod=e?gs:Es}entryPath(t){return m.join(this.watchPath,m.relative(this.watchPath,t.fullPath))}filterPath(t){let{stats:e}=t;if(e&&e.isSymbolicLink())return this.filterDir(t);let n=this.entryPath(t);return this.fsw._isntIgnored(n,e)&&this.fsw._hasReadPermissions(e)}filterDir(t){return this.fsw._isntIgnored(this.entryPath(t),t.stats)}},G=class extends Pe.EventEmitter{constructor(t={}){super(),this.closed=!1,this._closers=new Map,this._ignoredPaths=new Set,this._throttled=new Map,this._streams=new Set,this._symlinkPaths=new Map,this._watched=new Map,this._pendingWrites=new Map,this._pendingUnlinks=new Map,this._readyCount=0,this._readyEmitted=!1;let e=t.awaitWriteFinish,n={stabilityThreshold:2e3,pollInterval:100},r={persistent:!0,ignoreInitial:!1,ignorePermissionErrors:!1,interval:100,binaryInterval:300,followSymlinks:!0,usePolling:!1,atomic:!0,...t,ignored:t.ignored?rt(t.ignored):rt([]),awaitWriteFinish:e===!0?n:typeof e=="object"?{...n,...e}:!1};me&&(r.usePolling=!0),r.atomic===void 0&&(r.atomic=!r.usePolling);let i=process.env.CHOKIDAR_USEPOLLING;if(i!==void 0){let c=i.toLowerCase();c==="false"||c==="0"?r.usePolling=!1:c==="true"||c==="1"?r.usePolling=!0:r.usePolling=!!c}let a=process.env.CHOKIDAR_INTERVAL;a&&(r.interval=Number.parseInt(a,10));let o=0;this._emitReady=()=>{o++,o>=this._readyCount&&(this._emitReady=st,this._readyEmitted=!0,process.nextTick(()=>this.emit(g.READY)))},this._emitRaw=(...c)=>this.emit(g.RAW,...c),this._boundRemove=this._remove.bind(this),this.options=r,this._nodeFsHandler=new et(this),Object.freeze(r)}_addIgnoredPath(t){if(jt(t)){for(let e of this._ignoredPaths)if(jt(e)&&e.path===t.path&&e.recursive===t.recursive)return}this._ignoredPaths.add(t)}_removeIgnoredPath(t){if(this._ignoredPaths.delete(t),typeof t=="string")for(let e of this._ignoredPaths)jt(e)&&e.path===t&&this._ignoredPaths.delete(e)}add(t,e,n){let{cwd:r}=this.options;this.closed=!1,this._closePromise=void 0;let i=ye(t);return r&&(i=i.map(a=>ms(a,r))),i.forEach(a=>{this._removeIgnoredPath(a)}),this._userIgnored=void 0,this._readyCount||(this._readyCount=0),this._readyCount+=i.length,Promise.all(i.map(async a=>{let o=await this._nodeFsHandler._addToNodeFs(a,!n,void 0,0,e);return o&&this._emitReady(),o})).then(a=>{this.closed||a.forEach(o=>{o&&this.add(m.dirname(o),m.basename(e||o))})}),this}unwatch(t){if(this.closed)return this;let e=ye(t),{cwd:n}=this.options;return e.forEach(r=>{!m.isAbsolute(r)&&!this._closers.has(r)&&(n&&(r=m.join(n,r)),r=m.resolve(r)),this._closePath(r),this._addIgnoredPath(r),this._watched.has(r)&&this._addIgnoredPath({path:r,recursive:!0}),this._userIgnored=void 0}),this}close(){if(this._closePromise)return this._closePromise;this.closed=!0,this.removeAllListeners();let t=[];return this._closers.forEach(e=>e.forEach(n=>{let r=n();r instanceof Promise&&t.push(r)})),this._streams.forEach(e=>e.destroy()),this._userIgnored=void 0,this._readyCount=0,this._readyEmitted=!1,this._watched.forEach(e=>e.dispose()),this._closers.clear(),this._watched.clear(),this._streams.clear(),this._symlinkPaths.clear(),this._throttled.clear(),this._closePromise=t.length?Promise.all(t).then(()=>{}):Promise.resolve(),this._closePromise}getWatched(){let t={};return this._watched.forEach((e,n)=>{let i=(this.options.cwd?m.relative(this.options.cwd,n):n)||ve;t[i]=e.getChildren().sort()}),t}emitWithAll(t,e){this.emit(t,...e),t!==g.ERROR&&this.emit(g.ALL,t,...e)}async _emit(t,e,n){if(this.closed)return;let r=this.options;Wt&&(e=m.normalize(e)),r.cwd&&(e=m.relative(r.cwd,e));let i=[e];n!=null&&i.push(n);let a=r.awaitWriteFinish,o;if(a&&(o=this._pendingWrites.get(e)))return o.lastChange=new Date,this;if(r.atomic){if(t===g.UNLINK)return this._pendingUnlinks.set(e,[t,...i]),setTimeout(()=>{this._pendingUnlinks.forEach((c,l)=>{this.emit(...c),this.emit(g.ALL,...c),this._pendingUnlinks.delete(l)})},typeof r.atomic=="number"?r.atomic:100),this;t===g.ADD&&this._pendingUnlinks.has(e)&&(t=g.CHANGE,this._pendingUnlinks.delete(e))}if(a&&(t===g.ADD||t===g.CHANGE)&&this._readyEmitted){let c=(l,u)=>{l?(t=g.ERROR,i[0]=l,this.emitWithAll(t,i)):u&&(i.length>1?i[1]=u:i.push(u),this.emitWithAll(t,i))};return this._awaitWriteFinish(e,a.stabilityThreshold,t,c),this}if(t===g.CHANGE&&!this._throttle(g.CHANGE,e,50))return this;if(r.alwaysStat&&n===void 0&&(t===g.ADD||t===g.ADD_DIR||t===g.CHANGE)){let c=r.cwd?m.join(r.cwd,e):e,l;try{l=await(0,ot.stat)(c)}catch{}if(!l||this.closed)return;i.push(l)}return this.emitWithAll(t,i),this}_handleError(t){let e=t&&t.code;return t&&e!=="ENOENT"&&e!=="ENOTDIR"&&(!this.options.ignorePermissionErrors||e!=="EPERM"&&e!=="EACCES")&&this.emit(g.ERROR,t),t||this.closed}_throttle(t,e,n){this._throttled.has(t)||this._throttled.set(t,new Map);let r=this._throttled.get(t);if(!r)throw new Error("invalid throttle");let i=r.get(e);if(i)return i.count++,!1;let a,o=()=>{let l=r.get(e),u=l?l.count:0;return r.delete(e),clearTimeout(a),l&&clearTimeout(l.timeoutObject),u};a=setTimeout(o,n);let c={timeoutObject:a,clear:o,count:0};return r.set(e,c),c}_incrReadyCount(){return this._readyCount++}_awaitWriteFinish(t,e,n,r){let i=this.options.awaitWriteFinish;if(typeof i!="object")return;let a=i.pollInterval,o,c=t;this.options.cwd&&!m.isAbsolute(t)&&(c=m.join(this.options.cwd,t));let l=new Date,u=this._pendingWrites;function h(d){(0,Se.stat)(c,(f,E)=>{if(f||!u.has(t)){f&&f.code!=="ENOENT"&&r(f);return}let P=Number(new Date);d&&E.size!==d.size&&(u.get(t).lastChange=P);let B=u.get(t);P-B.lastChange>=e?(u.delete(t),r(void 0,E)):o=setTimeout(h,a,E)})}u.has(t)||(u.set(t,{lastChange:l,cancelWait:()=>(u.delete(t),clearTimeout(o),n)}),o=setTimeout(h,a))}_isIgnored(t,e){if(this.options.atomic&&ls.test(t))return!0;if(!this._userIgnored){let{cwd:n}=this.options,i=(this.options.ignored||[]).map(_e(n)),o=[...[...this._ignoredPaths].map(_e(n)),...i];this._userIgnored=fs(o,void 0)}return this._userIgnored(t,e)}_isntIgnored(t,e){return!this._isIgnored(t,e)}_getWatchHelpers(t){return new it(t,this.options.followSymlinks,this)}_getWatchedDir(t){let e=m.resolve(t);return this._watched.has(e)||this._watched.set(e,new Ut(e,this._boundRemove)),this._watched.get(e)}_hasReadPermissions(t){return this.options.ignorePermissionErrors?!0:!!(Number(t.mode)&256)}_remove(t,e,n){let r=m.join(t,e),i=m.resolve(r);if(n=n??(this._watched.has(r)||this._watched.has(i)),!this._throttle("remove",r,100))return;!n&&this._watched.size===1&&this.add(t,e,!0),this._getWatchedDir(r).getChildren().forEach(d=>this._remove(r,d));let c=this._getWatchedDir(t),l=c.has(e);c.remove(e),this._symlinkPaths.has(i)&&this._symlinkPaths.delete(i);let u=r;if(this.options.cwd&&(u=m.relative(this.options.cwd,r)),this.options.awaitWriteFinish&&this._pendingWrites.has(u)&&this._pendingWrites.get(u).cancelWait()===g.ADD)return;this._watched.delete(r),this._watched.delete(i);let h=n?g.UNLINK_DIR:g.UNLINK;l&&!this._isIgnored(r)&&this._emit(h,r),this._closePath(r)}_closePath(t){this._closeFile(t);let e=m.dirname(t);this._getWatchedDir(e).remove(m.basename(t))}_closeFile(t){let e=this._closers.get(t);e&&(e.forEach(n=>n()),this._closers.delete(t))}_addPathCloser(t,e){if(!e)return;let n=this._closers.get(t);n||(n=[],this._closers.set(t,n)),n.push(e)}_readdirp(t,e){if(this.closed)return;let n={type:g.ALL,alwaysStat:!0,lstat:!0,...e,depth:0},r=le(t,n);return this._streams.add(r),r.once(fe,()=>{r=void 0}),r.once(zt,()=>{r&&(this._streams.delete(r),r=void 0)}),r}};ws={watch:Le,FSWatcher:G}});var ys={};Yt(ys,{TSFilebasedRouter:()=>be,TSRouter:()=>J,createEffect:()=>Dt,createSignal:()=>Lt,html:()=>ct,loadPyFiles:()=>Mt,mapper:()=>Bt,renderChildRoutes:()=>Rt,useAnchor:()=>j,useAnchorSingle:()=>wt,useInitialDOM:()=>gt,useTSAnchorMount:()=>bt,useTSAuth:()=>St,useTSCollection:()=>Tt,useTSComponent:()=>z,useTSElementEach:()=>W,useTSElements:()=>pt,useTSEvent:()=>ht,useTSEventAll:()=>mt,useTSExtractParams:()=>ft,useTSHashAnchor:()=>$,useTSLazy:()=>Ot,useTSMetaData:()=>yt,useTSNavigate:()=>Pt,useTSNoReload:()=>U,useTSOutlet:()=>vt,useTSParams:()=>k,useTSPurifier:()=>ut,useTSSSRHydration:()=>Ct,useTSSelect:()=>_t,useTSloadBrython:()=>At});module.exports=Ie(ys);function Ne(s){return(s==null?"":String(s)).replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>.*?<\s*\/\s*\1\s*>/gi,"").replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>/gi,"").replace(/\son\w+\s*=\s*(['"]).*?\1/gi,"").replace(/\s(href|src)\s*=\s*(['"])\s*javascript:[^'"]*\2/gi,"")}function ct(s,...t){return s.reduce((e,n,r)=>{let i=r<t.length?Ne(t[r]):"";return e+n+i},"")}var Fe=s=>s.replace(/<\/?(script|iframe|object|embed|link|meta|style)[^>]*>/gi,"").replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/\s+(href|src)\s*=\s*(['"]?)\s*javascript:[^'"\s>]*/gi,""),Bt=s=>s?.map(t=>Fe(t)).join("")??"";var lt=R(require("dompurify"),1),ut=(s,t)=>{let n={...{ADD_TAGS:["my-custom-tag"]},...t};return typeof s=="string"?lt.default.sanitize(s,n):lt.default.sanitize(s.innerHTML,n)};var ht=(s,t,e)=>{if(typeof s=="string"){let n=document.getElementById(s);n?n.addEventListener(t,e):console.warn(`Element with id '${s}' not found.`)}else s===document?document.addEventListener(t,e):console.warn("Invalid id parameter provided.")};var Vt=require("zustand/vanilla"),dt=R(require("dompurify"),1);function ke(s,t){let e=[],n=s.replace(/:[^/]+/g,o=>(e.push(o.slice(1)),"([^/]+)")),r=new RegExp(`^${n}$`),i=t.match(r),a={};return i&&e.forEach((o,c)=>{a[o]=dt.default.sanitize(i[c+1]??"")}),a}function ze(s){let t={},e=new URLSearchParams(s);for(let[n,r]of e.entries())t[n]=dt.default.sanitize(r);return t}var k=(0,Vt.createStore)((s,t)=>({params:{},query:{},setFromPattern:e=>{let n=window.location.pathname,r=ke(e,n),i=ze(window.location.search);s({params:r,query:i})},getParam:e=>t().params[e],getQuery:e=>t().query[e]}));function ft(s){let t=k.getState();t.setFromPattern(s);let e=t.params,n=t.query;return{...e,...n}}var mt=(s,t,e)=>{let n=document.querySelectorAll(s);return n.forEach(r=>{r.addEventListener(t,e)}),()=>{n.forEach(r=>{r.removeEventListener(t,e)})}};var K=R(require("dompurify"),1),pt=(s,t,e,n={})=>{let r={USE_PROFILES:{svg:!0,html:!0},ALLOWED_TAGS:["svg","path","circle","rect","line","polyline","polygon","g","main","div","h1","h2","h3","h4","h5","h6","p","button","span","a","img","input","ul","li","i"],ALLOWED_ATTR:["class","id","href","src","alt","fill","stroke","stroke-width","viewBox","xmlns","d","x","y","cx","cy","r","width","height","data-onclick","data-onchange","data-onselect"],FORBID_TAGS:["script","iframe"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|ftp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,...e};K.default.addHook("uponSanitizeElement",(a,o)=>{let c=o.tagName.toLowerCase();c.includes("-")&&(o.allowedTags[c]=!0)}),K.default.addHook("uponSanitizeAttribute",(a,o)=>{o.attrName&&o.attrName.toLowerCase().startsWith("on")&&(o.keepAttr=!1)});let i=K.default.sanitize(t,r);s.innerHTML=i,s.querySelectorAll("[data-onclick]").forEach(a=>{let o=a.dataset.onclick;n[o]&&a.addEventListener("click",n[o])}),s.querySelectorAll("[data-onchange]").forEach(a=>{let o=a.dataset.onchange;n[o]&&a.addEventListener("change",n[o])}),s.querySelectorAll("[data-onselect]").forEach(a=>{let o=a.dataset.onselect;n[o]&&a.addEventListener("select",n[o])})};var Kt=R(require("dompurify"),1),Q=null,gt=(s,t)=>{if(typeof document>"u")return;let e=document.getElementById(s);if(!e)return;let n=e.innerHTML,i=Kt.default.sanitize(n,{ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br"],ALLOWED_ATTR:["href","src","alt","title","class","id","data-onclick","data-onchange"],ALLOW_DATA_ATTR:!1,KEEP_CONTENT:!1}).replace(/\b(href|src)=["']?(?!https?:|mailto:|\/|#)/gi,'$1="#"');if(Q!==null&&i!==Q){let a=document.createElement("div");t(a),e.innerHTML=Q}else Q=i,e.innerHTML=i,t(e)};var Et=R(require("dompurify"),1);typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",s=>{let t=s.state;t?.scrollPosition!==void 0&&window.scrollTo(0,t.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var wt=(s,t,e,n="",r=null)=>{if(!s)return;let i=Et.default.sanitize(t,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),a=Et.default.sanitize(e,{USE_PROFILES:{html:!1}});s.setAttribute("href",i),s.setAttribute("aria-label",a),n&&(s.className=n.trim()),r&&s.replaceChildren(r),typeof window<"u"&&s.addEventListener("click",o=>{o.preventDefault();let l=o.currentTarget.getAttribute("href");if(l){let u=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:u},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};var H=R(require("dompurify"),1);var Qt=(s="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",t="'self' 'nonce-rAnd0m123'",e="'none'",n="'self' https://fonts.googleapis.com https://fonts.gstatic.com",r="'self' https://blogger.googleusercontent.com",i=["'self'","https://fonts.googleapis.com","https://fonts.gstatic.com","https://www.google.com/maps/"],a="'self' https://www.youtube.com",o="'self'",c="/csp-report",l=!1)=>{let u=()=>{try{let h=document.querySelector('meta[http-equiv="Content-Security-Policy"]');h||(h=document.createElement("meta"),h.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(h));let d=l?`report-uri ${c};`:"";h.setAttribute("content",`default-src 'self'; script-src ${s}; style-src ${t}; object-src ${e}; font-src ${n}; img-src ${r}; connect-src ${i.join(" ")}; frame-src ${a}; base-uri ${o}; ${d}`)}catch(h){console.error("Error adding CSP meta element:",h)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",u):u()};var yt=(s,t)=>{let e={name:H.default.sanitize(s.name||""),description:H.default.sanitize(s.description||"Default description"),author:H.default.sanitize(s.author||"")},n=f=>{e.name=H.default.sanitize(f),h("name",e.name)},r=f=>{e.description=H.default.sanitize(f),h("description",e.description)},i=f=>{e.author=H.default.sanitize(f),h("author",e.author)},a=()=>e.name,o=()=>e.description,c=()=>e.author,l=()=>e,u=(f,E)=>{let P=document.createElement("meta");P.setAttribute("name",f),P.setAttribute("content",E),document.head.appendChild(P)},h=(f,E)=>{let P=document.querySelector(`meta[name="${f}"]`);P?P.setAttribute("content",E):u(f,E)},d=()=>{h("name",e.name),h("description",e.description),h("author",e.author)};return t&&Qt(t.scriptSrc,t.styleSrc,t.objectSrc,Array.isArray(t.connectSrc)?t.connectSrc.join(" "):t.connectSrc,t.reportOnly!==void 0?String(t.reportOnly):void 0),d(),{setName:n,setDescription:r,setAuthor:i,getName:a,getDescription:o,getAuthor:c,getAllMetaData:l,appendMetaTagsToHead:d}};var Jt=R(require("dompurify"),1),z=(s,t,e,n,r)=>{let i=`#${s}`,a=t.querySelectorAll(i);if(a.length===0)throw new Error(`[useTSComponent] No element found with id '${s}' in the given parent.`);if(a.length>1)throw new Error(`[useTSComponent] Duplicate id '${s}' detected. Found ${a.length} elements.`);let o=a[0];o.innerHTML=Jt.default.sanitize(o.innerHTML,{USE_PROFILES:{html:!0}}),e(o,n,r)};var Tt=(s,t,e,n=[])=>{let r=new Set;s.forEach((i,a)=>{if(r.has(i)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${i}" \u2014 skipping.`);return}r.add(i);let o=t.querySelectorAll(`#${i}`);if(o.length>1){console.warn(`[useTSCollection] Duplicate ID in DOM: "${i}" (${o.length} elements found) \u2014 skipping component mount.`);return}let c=e[a],l=Array.isArray(n)?n[a]:void 0;typeof c=="function"?z(i,t,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${i}"`)})};var _t=(s,t)=>{let n=(t??document).querySelectorAll(s);if(n.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${s}'`),null;if(s.startsWith("#")&&n.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${s}'. Found ${n.length} elements with this ID.`);return n[0]}return n.length>1&&process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] Multiple elements found for selector: '${s}'. Returning the first one.`),n[0]};var Xt=require("jwt-decode"),St=(s,t)=>{let e=localStorage.getItem("token");if(!e)return window.location.href=t,null;try{let n=(0,Xt.jwtDecode)(e),r=Date.now()/1e3;return n.exp&&n.exp<r&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=t),null}catch(n){return console.error("Invalid token:",n),window.location.href=t,null}};var W=(s,t,e)=>{s.forEach(n=>{t.forEach(r=>{n.addEventListener(r,i=>{e(n,i)})})})};var Pt=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var vt=(s,t)=>{let e=document.querySelector(`#${s}`)||document.querySelector(`.${s}`);if(!e)return;let n=window.location.pathname.replace(/\/$/,"");for(let r of t){let i=r.path.replace(/\/$/,"");if(n===i||n.startsWith(`${i}/`)){r.component(e);break}}};function Rt(s,t){let e=window.location.pathname.replace(/\/$/,"");t.routes.forEach(n=>{n.children?.length&&n.children.forEach(r=>{let i=r.path.replace(/\/$/,"");if(e===i||e.startsWith(`${i}/`)){let a=s.querySelector(`#${r.outlet}`)||s.querySelector(`.${r.outlet}`);a instanceof HTMLElement&&r.element&&r.element(a)}})})}var Zt=require("zustand/vanilla");function Lt(s){let t=(0,Zt.createStore)(()=>({value:s})),e=new Set;return{get:()=>t.getState().value,set:n=>{t.setState({value:n}),e.forEach(r=>r(n))},subscribe:n=>(e.add(n),n(t.getState().value),()=>e.delete(n))}}function Dt(s){let t=s();typeof t=="function"&&t()}var $=()=>{let s=document.querySelectorAll('a[href^="#"]');W(s,["click"],(t,e)=>{e.preventDefault();let n=t.getAttribute("href")?.substring(1),r=n?document.getElementById(n):null;r&&r.scrollIntoView({behavior:"smooth",block:"start"})})};var te=require("lodash-es"),xt=s=>s;typeof window<"u"&&typeof document<"u"&&(xt=s=>{let t=document.createElement("div");return t.innerText=s,t.innerHTML});var We=s=>{(s?Array.isArray(s)?s:s instanceof HTMLAnchorElement?[s]:Array.from(s):Array.from(document.querySelectorAll("a"))).forEach(e=>{if(!e||e.dataset.anchorEnhanced==="true")return;e.dataset.anchorEnhanced="true";let n=e.getAttribute("class")||"";e.setAttribute("class",xt(n));let r=e.getAttribute("aria-label");r&&e.setAttribute("aria-label",xt(r));let i=e.querySelector(":scope > *");i&&(e.innerHTML="",e.appendChild(i));let a=e.getAttribute("href")||"";if(!a.startsWith("#")){try{if(new URL(a,window.location.href).origin!==window.location.origin)return}catch{return}e.addEventListener("click",o=>{o.preventDefault();let c=e.getAttribute("href")||"";try{let l=new URL(c,window.location.href);window.history.pushState({},"",l.pathname+l.search+l.hash),window.dispatchEvent(new PopStateEvent("popstate"))}catch(l){console.error("Invalid URL in anchor:",c,l)}})}})},$e=(0,te.debounce)(We,50),j=s=>{$e(s)};var U=s=>{let t=s.querySelectorAll("a");j(t)};var bt=s=>{$(),U(s)};var At=async()=>{let s="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",t="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",e=n=>new Promise((r,i)=>{let a=document.createElement("script");a.src=n,a.onload=()=>r(),a.onerror=()=>i(new Error(`Failed to load ${n}`)),document.head.appendChild(a)});await e(s),await e(t),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},Mt=s=>new Promise((t,e)=>{let n=document.createElement("script");n.type="text/python",n.src=`/src/python/${s}`,n.onload=()=>t(),n.onerror=()=>e(new Error(`Failed to load ${s}`)),document.body.appendChild(n)});function Ot(s){let t=null;return async(e,n)=>{try{if(!t){let r=await s();t=r.default||r}if(typeof t=="function")return t(e,n);if(t instanceof HTMLElement){e?.appendChild(t);return}if(t&&typeof t.render=="function")return t.render(e,n);console.warn("useTSLazy: Unsupported module type",t)}catch(r){console.error("useTSLazy failed:",r)}}}var Ct=s=>typeof window>"u"?{isDOM:null}:{isDOM:s||document.body};var Ht=R(require("dompurify"),1);var se=require("zustand/vanilla"),ne=R(require("dompurify"),1),C=(0,se.createStore)(s=>({params:{},query:{},setParams:t=>s(()=>({params:ee(t)})),setQuery:t=>s(()=>({query:ee(t)}))}));function ee(s){let t={};for(let e in s)t[e]=ne.default.sanitize(s[e]);return t}var J=class{constructor(t,e){this.routes=[];this.routes=t,this.expectedParams=new Set(e),window.addEventListener("popstate",this.handlePopState.bind(this)),this.handlePopState()}handlePopState(){let t=window.location.pathname,e=window.location.search,n=this.parseQueryParams(e),r=this.findMatchingRoute(t,this.routes);if(r){if(r.routeto){this.navigate(r.routeto);return}let i=this.filterAndSanitizeParams(r.params);C.getState().setParams(i),C.getState().setQuery(n);let a=document.createElement("div");if(r.element?.(a,i,n),r.children){let o=t.slice(r.path.length),c=a.querySelector("#child");c&&this.renderChildren(r.children,o,c,i,n)}}else{let i=this.findMatchingRoute("*",this.routes);if(i){let a=this.filterAndSanitizeParams(i.params);C.getState().setParams(a),C.getState().setQuery(n);let o=document.createElement("div");i.element?.(o,a,n)}}}renderChildren(t,e,n,r,i){if(!t||t.length===0){let o=n.querySelector("#child");o&&o.remove();return}let a=this.findMatchingRoute(e,t);if(a){let o=document.createElement("div");o.id="child";let c={...r,...a.params},l=this.filterAndSanitizeParams(c);if(C.getState().setParams(l),C.getState().setQuery(i),a.element?.(o,l,i),n.appendChild(o),a.children){let u=e.slice(a.path.length);this.renderChildren(a.children,u,o,l,i)}}}parseQueryParams(t){let e={},n=new URLSearchParams(t);for(let[r,i]of n.entries())this.expectedParams.has(r)&&(e[r]=Ht.default.sanitize(i));return e}findMatchingRoute(t,e,n={}){for(let r of e){let i=r.path;if(i==="*")return r;{let o=[],c=i.replace(/:[^\s/]+/g,h=>(o.push(h.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),u=t.match(l);if(u){let h={...n};if(o.forEach((d,f)=>{h[d]=u[f+1]??""}),r.children){let d=t.slice(u[0].length),f=this.findMatchingRoute(d,r.children,h);if(f)return f}return{...r,params:h}}}}}filterAndSanitizeParams(t){if(!t)return{};let e={};for(let n in t)this.expectedParams.has(n)&&(e[n]=Ht.default.sanitize(t[n]??""));return e}navigate(t){history.pushState(null,"",t),this.handlePopState()}addRoute(t){this.routes.push(t)}};var be=()=>({name:"ts-filebased-router",async buildStart(){if(typeof process>"u"||!process.versions?.node)return;let s=await import("fs/promises"),t=await import("path"),e=await Promise.resolve().then(()=>(xe(),De)),n=t.resolve("src/pages"),r=t.resolve("src/gen"),i=t.resolve("src/routes"),a=t.join(r,"tsrouter.gen.ts"),o=t.join(i,"__root.ts"),c=process.env.NODE_ENV!=="production";async function l(w){try{await s.mkdir(w,{recursive:!0})}catch{}}function u(w,y){let T="/"+t.relative(y,w).replace(/\\/g,"/");return T=T.replace(/\.ts$/,"").replace(/\/index$/,"")||"/",T.replace(/\[(.+?)\]/g,":$1")}function h(w){return w.replace(/^\//,"").split("/").map(y=>y.startsWith(":")?y.slice(1):y).filter(Boolean).join("-")||"index"}function d(w,y){let S=t.relative(y,w).replace(/\\/g,"/").split("/").filter(Boolean),v=S[S.length-1].replace(".ts",""),M=S.length>1?S[S.length-2]:"";if(v.startsWith("[")&&v.endsWith("]")){let O=v.slice(1,-1);return M.charAt(0).toUpperCase()+M.slice(1)+O.charAt(0).toUpperCase()+O.slice(1)+"Param"}else return v.charAt(0).toUpperCase()+v.slice(1)}async function f(w){let y=await s.readdir(w,{withFileTypes:!0}),T=[];for(let S of y){let v=t.join(w,S.name);if(S.isDirectory())T=T.concat(await f(v));else if(S.isFile()&&S.name.endsWith(".ts")){let M=u(v,n),O=h(M),_=d(v,n);T.push({file:v,route:M,routeName:O,importName:_})}}return T}function E(w,y){let T=y.includes(":"),S=T?y.match(/:([^/]+)/)?.[1]:null;return`import { html, useTSElements, useTSMetaData${T?", useTSExtractParams":""} } from '@devwareng/vanilla-ts';
|
|
2
2
|
|
|
3
|
-
export default function ${
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
description: '',
|
|
7
|
-
author: ''
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
${T?`const params = useTSExtractParams("${w}");
|
|
3
|
+
export default function ${w}(DOM: HTMLElement) {
|
|
4
|
+
useTSMetaData({ name: '${w.toLowerCase()}', description: '', author: '' });
|
|
5
|
+
${T?`const params = useTSExtractParams("${y}");
|
|
11
6
|
if (!params.${S}) return;`:""}
|
|
12
|
-
|
|
13
|
-
const ui = useTSElements(
|
|
7
|
+
return useTSElements(
|
|
14
8
|
DOM,
|
|
15
9
|
html\`
|
|
16
10
|
<div class="p-4">
|
|
17
|
-
<h1>${
|
|
11
|
+
<h1>${w}</h1>
|
|
18
12
|
${T?"<pre>${JSON.stringify(params, null, 2)}</pre>":""}
|
|
19
13
|
</div>
|
|
20
14
|
\`
|
|
21
15
|
);
|
|
22
|
-
|
|
23
|
-
return ui
|
|
24
|
-
}`}function y(){return`import { createRouter } from "@/gen/tsrouter.gen";
|
|
16
|
+
}`}function P(){return`import { createRouter } from "@/gen/tsrouter.gen";
|
|
25
17
|
import { useTSParams } from "@devwareng/vanilla-ts";
|
|
26
18
|
|
|
27
19
|
export const Router = (DOM: HTMLElement) => {
|
|
@@ -32,9 +24,9 @@ export const Router = (DOM: HTMLElement) => {
|
|
|
32
24
|
window.addEventListener("popstate", () => {
|
|
33
25
|
router.navigate(window.location.pathname);
|
|
34
26
|
});
|
|
35
|
-
};`}async function
|
|
27
|
+
};`}async function B(){let w=await f(n),y=w.find(_=>_.route==="/notfound"),T=w.filter(_=>_.route!=="/notfound");for(let _ of w)(await s.readFile(_.file,"utf-8")).trim()||await s.writeFile(_.file,E(_.importName,_.route),"utf-8");let S=w.map(_=>{let qt="../pages/"+t.relative(n,_.file).replace(/\\/g,"/").replace(/\.ts$/,"");return`import ${_.importName} from "${qt}";`}).join(`
|
|
36
28
|
`),v=T.map(_=>`{ path: "${_.route}", name: "${_.routeName}", component: (DOM: HTMLElement) => ${_.importName}(DOM) }`).join(`,
|
|
37
|
-
`),M=
|
|
29
|
+
`),M=y?`export const NotFound = ${y.importName}`:"export function NotFound(DOM: HTMLElement) {\n return useTSElements(DOM, html`<div><h1>404 - Page Not Found</h1></div>`)\n}",O=`// AUTO-GENERATED FILE. DO NOT EDIT MANUALLY.
|
|
38
30
|
import { html, useTSElements } from "@devwareng/vanilla-ts"
|
|
39
31
|
|
|
40
32
|
${S}
|
|
@@ -84,7 +76,7 @@ export function createRouter(DOM: HTMLElement) {
|
|
|
84
76
|
navigate(window.location.pathname + window.location.search)
|
|
85
77
|
return { navigate, routes: routeTree }
|
|
86
78
|
}
|
|
87
|
-
`;await
|
|
79
|
+
`;await l(r),await s.writeFile(a,O,"utf-8"),await s.writeFile(o,P(),"utf-8")}await l(r),await l(i),await B(),c&&(e.watch(n).on("all",async(w,y)=>{if(w==="add"&&y.endsWith(".ts")){let S=t.basename(y,".ts").replace(/\[|\]/g,"Param").replace(/(^\w|-\w)/g,O=>O.replace("-","").toUpperCase()),v=u(y,n);(await s.readFile(y,"utf-8")).trim()||await s.writeFile(y,E(S,v),"utf-8"),await B()}}),e.watch(o).on("unlink",async()=>{await s.writeFile(o,P(),"utf-8")})),console.log("\u{1F7E2} TS Filebased Router Generated Successfully...")}});0&&(module.exports={TSFilebasedRouter,TSRouter,createEffect,createSignal,html,loadPyFiles,mapper,renderChildRoutes,useAnchor,useAnchorSingle,useInitialDOM,useTSAnchorMount,useTSAuth,useTSCollection,useTSComponent,useTSElementEach,useTSElements,useTSEvent,useTSEventAll,useTSExtractParams,useTSHashAnchor,useTSLazy,useTSMetaData,useTSNavigate,useTSNoReload,useTSOutlet,useTSParams,useTSPurifier,useTSSSRHydration,useTSSelect,useTSloadBrython});
|
|
88
80
|
/*! Bundled license information:
|
|
89
81
|
|
|
90
82
|
chokidar/esm/index.js:
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
function me(t){return(t==null?"":String(t)).replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>.*?<\s*\/\s*\1\s*>/gi,"").replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>/gi,"").replace(/\son\w+\s*=\s*(['"]).*?\1/gi,"").replace(/\s(href|src)\s*=\s*(['"])\s*javascript:[^'"]*\2/gi,"")}function F(t,...e){return t.reduce((n,r,o)=>{let s=o<e.length?me(e[o]):"";return n+r+s},"")}var de=t=>t.replace(/<\/?(script|iframe|object|embed|link|meta|style)[^>]*>/gi,"").replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/\s+(href|src)\s*=\s*(['"]?)\s*javascript:[^'"\s>]*/gi,""),pe=t=>t?.map(e=>de(e)).join("")??"";import z from"dompurify";var I=(t,e)=>{let r={...{ADD_TAGS:["my-custom-tag"]},...e};return typeof t=="string"?z.sanitize(t,r):z.sanitize(t.innerHTML,r)};var _=(t,e,n)=>{if(typeof t=="string"){let r=document.getElementById(t);r?r.addEventListener(e,n):console.warn(`Element with id '${t}' not found.`)}else t===document?document.addEventListener(e,n):console.warn("Invalid id parameter provided.")};import{createStore as fe}from"zustand/vanilla";import q from"dompurify";function he(t,e){let n=[],r=t.replace(/:[^/]+/g,a=>(n.push(a.slice(1)),"([^/]+)")),o=new RegExp(`^${r}$`),s=e.match(o),i={};return s&&n.forEach((a,c)=>{i[a]=q.sanitize(s[c+1]??"")}),i}function ge(t){let e={},n=new URLSearchParams(t);for(let[r,o]of n.entries())e[r]=q.sanitize(o);return e}var A=fe((t,e)=>({params:{},query:{},setFromPattern:n=>{let r=window.location.pathname,o=he(n,r),s=ge(window.location.search);t({params:o,query:s})},getParam:n=>e().params[n],getQuery:n=>e().query[n]}));function U(t){let e=A.getState();e.setFromPattern(t);let n=e.params,r=e.query;return{...n,...r}}var j=(t,e,n)=>{let r=document.querySelectorAll(t);return r.forEach(o=>{o.addEventListener(e,n)}),()=>{r.forEach(o=>{o.removeEventListener(e,n)})}};import C from"dompurify";var W=(t,e,n,r={})=>{let o={USE_PROFILES:{svg:!0,html:!0},ALLOWED_TAGS:["svg","path","circle","rect","line","polyline","polygon","g","main","div","h1","h2","h3","h4","h5","h6","p","button","span","a","img","input","ul","li","i"],ALLOWED_ATTR:["class","id","href","src","alt","fill","stroke","stroke-width","viewBox","xmlns","d","x","y","cx","cy","r","width","height","data-onclick","data-onchange","data-onselect"],FORBID_TAGS:["script","iframe"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|ftp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,...n};C.addHook("uponSanitizeElement",(i,a)=>{let c=a.tagName.toLowerCase();c.includes("-")&&(a.allowedTags[c]=!0)}),C.addHook("uponSanitizeAttribute",(i,a)=>{a.attrName&&a.attrName.toLowerCase().startsWith("on")&&(a.keepAttr=!1)});let s=C.sanitize(e,o);t.innerHTML=s,t.querySelectorAll("[data-onclick]").forEach(i=>{let a=i.dataset.onclick;r[a]&&i.addEventListener("click",r[a])}),t.querySelectorAll("[data-onchange]").forEach(i=>{let a=i.dataset.onchange;r[a]&&i.addEventListener("change",r[a])}),t.querySelectorAll("[data-onselect]").forEach(i=>{let a=i.dataset.onselect;r[a]&&i.addEventListener("select",r[a])})};import Te from"dompurify";var P=null,B=(t,e)=>{if(typeof document>"u")return;let n=document.getElementById(t);if(!n)return;let r=n.innerHTML,s=Te.sanitize(r,{ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br"],ALLOWED_ATTR:["href","src","alt","title","class","id","data-onclick","data-onchange"],ALLOW_DATA_ATTR:!1,KEEP_CONTENT:!1}).replace(/\b(href|src)=["']?(?!https?:|mailto:|\/|#)/gi,'$1="#"');if(P!==null&&s!==P){let i=document.createElement("div");e(i),n.innerHTML=P}else P=s,n.innerHTML=s,e(n)};import G from"dompurify";typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",t=>{let e=t.state;e?.scrollPosition!==void 0&&window.scrollTo(0,e.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var Q=(t,e,n,r="",o=null)=>{if(!t)return;let s=G.sanitize(e,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),i=G.sanitize(n,{USE_PROFILES:{html:!1}});t.setAttribute("href",s),t.setAttribute("aria-label",i),r&&(t.className=r.trim()),o&&t.replaceChildren(o),typeof window<"u"&&t.addEventListener("click",a=>{a.preventDefault();let l=a.currentTarget.getAttribute("href");if(l){let T=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:T},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};import R from"dompurify";var V=(t="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",e="'self' 'nonce-rAnd0m123'",n="'none'",r="'self' https://fonts.googleapis.com https://fonts.gstatic.com",o="'self' https://blogger.googleusercontent.com",s=["'self'","https://fonts.googleapis.com","https://fonts.gstatic.com","https://www.google.com/maps/"],i="'self' https://www.youtube.com",a="'self'",c="/csp-report",l=!1)=>{let T=()=>{try{let u=document.querySelector('meta[http-equiv="Content-Security-Policy"]');u||(u=document.createElement("meta"),u.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(u));let E=l?`report-uri ${c};`:"";u.setAttribute("content",`default-src 'self'; script-src ${t}; style-src ${e}; object-src ${n}; font-src ${r}; img-src ${o}; connect-src ${s.join(" ")}; frame-src ${i}; base-uri ${a}; ${E}`)}catch(u){console.error("Error adding CSP meta element:",u)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",T):T()};var J=(t,e)=>{let n={name:R.sanitize(t.name||""),description:R.sanitize(t.description||"Default description"),author:R.sanitize(t.author||"")},r=p=>{n.name=R.sanitize(p),u("name",n.name)},o=p=>{n.description=R.sanitize(p),u("description",n.description)},s=p=>{n.author=R.sanitize(p),u("author",n.author)},i=()=>n.name,a=()=>n.description,c=()=>n.author,l=()=>n,T=(p,M)=>{let y=document.createElement("meta");y.setAttribute("name",p),y.setAttribute("content",M),document.head.appendChild(y)},u=(p,M)=>{let y=document.querySelector(`meta[name="${p}"]`);y?y.setAttribute("content",M):T(p,M)},E=()=>{u("name",n.name),u("description",n.description),u("author",n.author)};return e&&V(e.scriptSrc,e.styleSrc,e.objectSrc,Array.isArray(e.connectSrc)?e.connectSrc.join(" "):e.connectSrc,e.reportOnly!==void 0?String(e.reportOnly):void 0),E(),{setName:r,setDescription:o,setAuthor:s,getName:i,getDescription:a,getAuthor:c,getAllMetaData:l,appendMetaTagsToHead:E}};import Se from"dompurify";var x=(t,e,n,r,o)=>{let s=`#${t}`,i=e.querySelectorAll(s);if(i.length===0)throw new Error(`[useTSComponent] No element found with id '${t}' in the given parent.`);if(i.length>1)throw new Error(`[useTSComponent] Duplicate id '${t}' detected. Found ${i.length} elements.`);let a=i[0];a.innerHTML=Se.sanitize(a.innerHTML,{USE_PROFILES:{html:!0}}),n(a,r,o)};var X=(t,e,n,r=[])=>{let o=new Set;t.forEach((s,i)=>{if(o.has(s)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${s}" \u2014 skipping.`);return}o.add(s);let a=e.querySelectorAll(`#${s}`);if(a.length>1){console.warn(`[useTSCollection] Duplicate ID in DOM: "${s}" (${a.length} elements found) \u2014 skipping component mount.`);return}let c=n[i],l=Array.isArray(r)?r[i]:void 0;typeof c=="function"?x(s,e,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${s}"`)})};var Y=(t,e)=>{let r=(e??document).querySelectorAll(t);if(r.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${t}'`),null;if(t.startsWith("#")&&r.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${t}'. Found ${r.length} elements with this ID.`);return r[0]}return r.length>1&&process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] Multiple elements found for selector: '${t}'. Returning the first one.`),r[0]};import{jwtDecode as Ee}from"jwt-decode";var K=(t,e)=>{let n=localStorage.getItem("token");if(!n)return window.location.href=e,null;try{let r=Ee(n),o=Date.now()/1e3;return r.exp&&r.exp<o&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=e),null}catch(r){return console.error("Invalid token:",r),window.location.href=e,null}};var D=(t,e,n)=>{t.forEach(r=>{e.forEach(o=>{r.addEventListener(o,s=>{n(r,s)})})})};var Z=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var ee=(t,e)=>{let n=document.querySelector(`#${t}`)||document.querySelector(`.${t}`);if(!n)return;let r=window.location.pathname.replace(/\/$/,"");for(let o of e){let s=o.path.replace(/\/$/,"");if(r===s||r.startsWith(`${s}/`)){o.component(n);break}}};function te(t,e){let n=window.location.pathname.replace(/\/$/,"");e.routes.forEach(r=>{r.children?.length&&r.children.forEach(o=>{let s=o.path.replace(/\/$/,"");if(n===s||n.startsWith(`${s}/`)){let i=t.querySelector(`#${o.outlet}`)||t.querySelector(`.${o.outlet}`);i instanceof HTMLElement&&o.element&&o.element(i)}})})}import{createStore as ye}from"zustand/vanilla";function ne(t){let e=ye(()=>({value:t})),n=new Set;return{get:()=>e.getState().value,set:r=>{e.setState({value:r}),n.forEach(o=>o(r))},subscribe:r=>(n.add(r),r(e.getState().value),()=>n.delete(r))}}function re(t){let e=t();typeof e=="function"&&e()}var H=()=>{let t=document.querySelectorAll('a[href^="#"]');D(t,["click"],(e,n)=>{n.preventDefault();let r=e.getAttribute("href")?.substring(1),o=r?document.getElementById(r):null;o&&o.scrollIntoView({behavior:"smooth",block:"start"})})};import{debounce as ve}from"lodash-es";var $=t=>t;typeof window<"u"&&typeof document<"u"&&($=t=>{let e=document.createElement("div");return e.innerText=t,e.innerHTML});var we=t=>{(t?Array.isArray(t)?t:t instanceof HTMLAnchorElement?[t]:Array.from(t):Array.from(document.querySelectorAll("a"))).forEach(n=>{if(!n||n.dataset.anchorEnhanced==="true")return;n.dataset.anchorEnhanced="true";let r=n.getAttribute("class")||"";n.setAttribute("class",$(r));let o=n.getAttribute("aria-label");o&&n.setAttribute("aria-label",$(o));let s=n.querySelector(":scope > *");s&&(n.innerHTML="",n.appendChild(s));let i=n.getAttribute("href")||"";if(!i.startsWith("#")){try{if(new URL(i,window.location.href).origin!==window.location.origin)return}catch{return}n.addEventListener("click",a=>{a.preventDefault();let c=n.getAttribute("href")||"";try{let l=new URL(c,window.location.href);window.history.pushState({},"",l.pathname+l.search+l.hash),window.dispatchEvent(new PopStateEvent("popstate"))}catch(l){console.error("Invalid URL in anchor:",c,l)}})}})},Le=ve(we,50),O=t=>{Le(t)};var b=t=>{let e=t.querySelectorAll("a");O(e)};var oe=t=>{H(),b(t)};var se=async()=>{let t="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",e="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",n=r=>new Promise((o,s)=>{let i=document.createElement("script");i.src=r,i.onload=()=>o(),i.onerror=()=>s(new Error(`Failed to load ${r}`)),document.head.appendChild(i)});await n(t),await n(e),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},ie=t=>new Promise((e,n)=>{let r=document.createElement("script");r.type="text/python",r.src=`/src/python/${t}`,r.onload=()=>e(),r.onerror=()=>n(new Error(`Failed to load ${t}`)),document.body.appendChild(r)});function ae(t){let e=null;return async(n,r)=>{try{if(!e){let o=await t();e=o.default||o}if(typeof e=="function")return e(n,r);if(e instanceof HTMLElement){n?.appendChild(e);return}if(e&&typeof e.render=="function")return e.render(n,r);console.warn("useTSLazy: Unsupported module type",e)}catch(o){console.error("useTSLazy failed:",o)}}}var ce=t=>typeof window>"u"?{isDOM:null}:{isDOM:t||document.body};import ue from"dompurify";import{createStore as Me}from"zustand/vanilla";import Re from"dompurify";var L=Me(t=>({params:{},query:{},setParams:e=>t(()=>({params:le(e)})),setQuery:e=>t(()=>({query:le(e)}))}));function le(t){let e={};for(let n in t)e[n]=Re.sanitize(t[n]);return e}var N=class{constructor(e,n){this.routes=[];this.routes=e,this.expectedParams=new Set(n),window.addEventListener("popstate",this.handlePopState.bind(this)),this.handlePopState()}handlePopState(){let e=window.location.pathname,n=window.location.search,r=this.parseQueryParams(n),o=this.findMatchingRoute(e,this.routes);if(o){if(o.routeto){this.navigate(o.routeto);return}let s=this.filterAndSanitizeParams(o.params);L.getState().setParams(s),L.getState().setQuery(r);let i=document.createElement("div");if(o.element?.(i,s,r),o.children){let a=e.slice(o.path.length),c=i.querySelector("#child");c&&this.renderChildren(o.children,a,c,s,r)}}else{let s=this.findMatchingRoute("*",this.routes);if(s){let i=this.filterAndSanitizeParams(s.params);L.getState().setParams(i),L.getState().setQuery(r);let a=document.createElement("div");s.element?.(a,i,r)}}}renderChildren(e,n,r,o,s){if(!e||e.length===0){let a=r.querySelector("#child");a&&a.remove();return}let i=this.findMatchingRoute(n,e);if(i){let a=document.createElement("div");a.id="child";let c={...o,...i.params},l=this.filterAndSanitizeParams(c);if(L.getState().setParams(l),L.getState().setQuery(s),i.element?.(a,l,s),r.appendChild(a),i.children){let T=n.slice(i.path.length);this.renderChildren(i.children,T,a,l,s)}}}parseQueryParams(e){let n={},r=new URLSearchParams(e);for(let[o,s]of r.entries())this.expectedParams.has(o)&&(n[o]=ue.sanitize(s));return n}findMatchingRoute(e,n,r={}){for(let o of n){let s=o.path;if(s==="*")return o;{let a=[],c=s.replace(/:[^\s/]+/g,u=>(a.push(u.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),T=e.match(l);if(T){let u={...r};if(a.forEach((E,p)=>{u[E]=T[p+1]??""}),o.children){let E=e.slice(T[0].length),p=this.findMatchingRoute(E,o.children,u);if(p)return p}return{...o,params:u}}}}}filterAndSanitizeParams(e){if(!e)return{};let n={};for(let r in e)this.expectedParams.has(r)&&(n[r]=ue.sanitize(e[r]??""));return n}navigate(e){history.pushState(null,"",e),this.handlePopState()}addRoute(e){this.routes.push(e)}};var Ae=()=>({name:"ts-filebased-router",async buildStart(){if(typeof process>"u"||!process.versions?.node)return;let t=await import("fs/promises"),e=await import("path"),n=await import("./esm-KRNKVVL7.js"),r=e.resolve("src/pages"),o=e.resolve("src/gen"),s=e.resolve("src/routes"),i=e.join(o,"tsrouter.gen.ts"),a=e.join(s,"__root.ts");async function c(d){try{await t.mkdir(d,{recursive:!0})}catch{}}function l(d,m){let f="/"+e.relative(m,d).replace(/\\/g,"/");return f=f.replace(/\.ts$/,"").replace(/\/index$/,"")||"/",f.replace(/\[(.+?)\]/g,":$1")}function T(d){return d.replace(/^\//,"").split("/").map(m=>m.startsWith(":")?m.slice(1):m).filter(Boolean).join("-")||"index"}function u(d,m){let g=e.relative(m,d).replace(/\\/g,"/").split("/").filter(Boolean),S=g[g.length-1].replace(".ts",""),v=g.length>1?g[g.length-2]:"";if(S.startsWith("[")&&S.endsWith("]")){let w=S.slice(1,-1);return v.charAt(0).toUpperCase()+v.slice(1)+w.charAt(0).toUpperCase()+w.slice(1)+"Param"}else return S.charAt(0).toUpperCase()+S.slice(1)}async function E(d){let m=await t.readdir(d,{withFileTypes:!0}),f=[];for(let g of m){let S=e.join(d,g.name);if(g.isDirectory())f=f.concat(await E(S));else if(g.isFile()&&g.name.endsWith(".ts")){let v=l(S,r),w=T(v),h=u(S,r);f.push({file:S,route:v,routeName:w,importName:h})}}return f}function p(d,m){let f=m.includes(":"),g=f?m.match(/:([^/]+)/)?.[1]:null;return`import { html, useTSElements, useTSMetaData${f?", useTSExtractParams":""} } from '@devwareng/vanilla-ts';
|
|
1
|
+
function de(t){return(t==null?"":String(t)).replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>.*?<\s*\/\s*\1\s*>/gi,"").replace(/<\s*(script|iframe|object|embed|link|style)[^>]*>/gi,"").replace(/\son\w+\s*=\s*(['"]).*?\1/gi,"").replace(/\s(href|src)\s*=\s*(['"])\s*javascript:[^'"]*\2/gi,"")}function z(t,...e){return t.reduce((n,r,o)=>{let s=o<e.length?de(e[o]):"";return n+r+s},"")}var pe=t=>t.replace(/<\/?(script|iframe|object|embed|link|meta|style)[^>]*>/gi,"").replace(/\s+on[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi,"").replace(/\s+(href|src)\s*=\s*(['"]?)\s*javascript:[^'"\s>]*/gi,""),fe=t=>t?.map(e=>pe(e)).join("")??"";import I from"dompurify";var _=(t,e)=>{let r={...{ADD_TAGS:["my-custom-tag"]},...e};return typeof t=="string"?I.sanitize(t,r):I.sanitize(t.innerHTML,r)};var q=(t,e,n)=>{if(typeof t=="string"){let r=document.getElementById(t);r?r.addEventListener(e,n):console.warn(`Element with id '${t}' not found.`)}else t===document?document.addEventListener(e,n):console.warn("Invalid id parameter provided.")};import{createStore as he}from"zustand/vanilla";import U from"dompurify";function ge(t,e){let n=[],r=t.replace(/:[^/]+/g,a=>(n.push(a.slice(1)),"([^/]+)")),o=new RegExp(`^${r}$`),s=e.match(o),i={};return s&&n.forEach((a,c)=>{i[a]=U.sanitize(s[c+1]??"")}),i}function Te(t){let e={},n=new URLSearchParams(t);for(let[r,o]of n.entries())e[r]=U.sanitize(o);return e}var A=he((t,e)=>({params:{},query:{},setFromPattern:n=>{let r=window.location.pathname,o=ge(n,r),s=Te(window.location.search);t({params:o,query:s})},getParam:n=>e().params[n],getQuery:n=>e().query[n]}));function j(t){let e=A.getState();e.setFromPattern(t);let n=e.params,r=e.query;return{...n,...r}}var W=(t,e,n)=>{let r=document.querySelectorAll(t);return r.forEach(o=>{o.addEventListener(e,n)}),()=>{r.forEach(o=>{o.removeEventListener(e,n)})}};import C from"dompurify";var B=(t,e,n,r={})=>{let o={USE_PROFILES:{svg:!0,html:!0},ALLOWED_TAGS:["svg","path","circle","rect","line","polyline","polygon","g","main","div","h1","h2","h3","h4","h5","h6","p","button","span","a","img","input","ul","li","i"],ALLOWED_ATTR:["class","id","href","src","alt","fill","stroke","stroke-width","viewBox","xmlns","d","x","y","cx","cy","r","width","height","data-onclick","data-onchange","data-onselect"],FORBID_TAGS:["script","iframe"],ALLOWED_URI_REGEXP:/^(?:(?:https?|mailto|tel|ftp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,...n};C.addHook("uponSanitizeElement",(i,a)=>{let c=a.tagName.toLowerCase();c.includes("-")&&(a.allowedTags[c]=!0)}),C.addHook("uponSanitizeAttribute",(i,a)=>{a.attrName&&a.attrName.toLowerCase().startsWith("on")&&(a.keepAttr=!1)});let s=C.sanitize(e,o);t.innerHTML=s,t.querySelectorAll("[data-onclick]").forEach(i=>{let a=i.dataset.onclick;r[a]&&i.addEventListener("click",r[a])}),t.querySelectorAll("[data-onchange]").forEach(i=>{let a=i.dataset.onchange;r[a]&&i.addEventListener("change",r[a])}),t.querySelectorAll("[data-onselect]").forEach(i=>{let a=i.dataset.onselect;r[a]&&i.addEventListener("select",r[a])})};import Se from"dompurify";var P=null,G=(t,e)=>{if(typeof document>"u")return;let n=document.getElementById(t);if(!n)return;let r=n.innerHTML,s=Se.sanitize(r,{ALLOWED_TAGS:["div","span","p","h1","h2","h3","h4","h5","h6","ul","ol","li","strong","em","a","img","br"],ALLOWED_ATTR:["href","src","alt","title","class","id","data-onclick","data-onchange"],ALLOW_DATA_ATTR:!1,KEEP_CONTENT:!1}).replace(/\b(href|src)=["']?(?!https?:|mailto:|\/|#)/gi,'$1="#"');if(P!==null&&s!==P){let i=document.createElement("div");e(i),n.innerHTML=P}else P=s,n.innerHTML=s,e(n)};import Q from"dompurify";typeof window<"u"&&!window.__anchorSinglePopstateHandlerAttached&&(window.addEventListener("popstate",t=>{let e=t.state;e?.scrollPosition!==void 0&&window.scrollTo(0,e.scrollPosition)}),window.__anchorSinglePopstateHandlerAttached=!0);var V=(t,e,n,r="",o=null)=>{if(!t)return;let s=Q.sanitize(e,{ALLOWED_URI_REGEXP:/^(https?:|\/)/}),i=Q.sanitize(n,{USE_PROFILES:{html:!1}});t.setAttribute("href",s),t.setAttribute("aria-label",i),r&&(t.className=r.trim()),o&&t.replaceChildren(o),typeof window<"u"&&t.addEventListener("click",a=>{a.preventDefault();let l=a.currentTarget.getAttribute("href");if(l){let T=window.scrollY;window.scrollTo(0,0),window.history.pushState({scrollPosition:T},"",l),dispatchEvent(new PopStateEvent("popstate"))}})};import R from"dompurify";var J=(t="'self' 'nonce-rAnd0m123' 'unsafe-inline' 'unsafe-eval'",e="'self' 'nonce-rAnd0m123'",n="'none'",r="'self' https://fonts.googleapis.com https://fonts.gstatic.com",o="'self' https://blogger.googleusercontent.com",s=["'self'","https://fonts.googleapis.com","https://fonts.gstatic.com","https://www.google.com/maps/"],i="'self' https://www.youtube.com",a="'self'",c="/csp-report",l=!1)=>{let T=()=>{try{let u=document.querySelector('meta[http-equiv="Content-Security-Policy"]');u||(u=document.createElement("meta"),u.setAttribute("http-equiv","Content-Security-Policy"),document.head.appendChild(u));let E=l?`report-uri ${c};`:"";u.setAttribute("content",`default-src 'self'; script-src ${t}; style-src ${e}; object-src ${n}; font-src ${r}; img-src ${o}; connect-src ${s.join(" ")}; frame-src ${i}; base-uri ${a}; ${E}`)}catch(u){console.error("Error adding CSP meta element:",u)}};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",T):T()};var X=(t,e)=>{let n={name:R.sanitize(t.name||""),description:R.sanitize(t.description||"Default description"),author:R.sanitize(t.author||"")},r=p=>{n.name=R.sanitize(p),u("name",n.name)},o=p=>{n.description=R.sanitize(p),u("description",n.description)},s=p=>{n.author=R.sanitize(p),u("author",n.author)},i=()=>n.name,a=()=>n.description,c=()=>n.author,l=()=>n,T=(p,M)=>{let y=document.createElement("meta");y.setAttribute("name",p),y.setAttribute("content",M),document.head.appendChild(y)},u=(p,M)=>{let y=document.querySelector(`meta[name="${p}"]`);y?y.setAttribute("content",M):T(p,M)},E=()=>{u("name",n.name),u("description",n.description),u("author",n.author)};return e&&J(e.scriptSrc,e.styleSrc,e.objectSrc,Array.isArray(e.connectSrc)?e.connectSrc.join(" "):e.connectSrc,e.reportOnly!==void 0?String(e.reportOnly):void 0),E(),{setName:r,setDescription:o,setAuthor:s,getName:i,getDescription:a,getAuthor:c,getAllMetaData:l,appendMetaTagsToHead:E}};import Ee from"dompurify";var x=(t,e,n,r,o)=>{let s=`#${t}`,i=e.querySelectorAll(s);if(i.length===0)throw new Error(`[useTSComponent] No element found with id '${t}' in the given parent.`);if(i.length>1)throw new Error(`[useTSComponent] Duplicate id '${t}' detected. Found ${i.length} elements.`);let a=i[0];a.innerHTML=Ee.sanitize(a.innerHTML,{USE_PROFILES:{html:!0}}),n(a,r,o)};var Y=(t,e,n,r=[])=>{let o=new Set;t.forEach((s,i)=>{if(o.has(s)){console.warn(`[useTSCollection] Duplicate ID in collection array: "${s}" \u2014 skipping.`);return}o.add(s);let a=e.querySelectorAll(`#${s}`);if(a.length>1){console.warn(`[useTSCollection] Duplicate ID in DOM: "${s}" (${a.length} elements found) \u2014 skipping component mount.`);return}let c=n[i],l=Array.isArray(r)?r[i]:void 0;typeof c=="function"?x(s,e,c,l):console.warn(`[useTSCollection] No valid component function found for ID: "${s}"`)})};var K=(t,e)=>{let r=(e??document).querySelectorAll(t);if(r.length===0)return process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] No element found for selector: '${t}'`),null;if(t.startsWith("#")&&r.length>1){if(process.env.NODE_ENV!=="production")throw new Error(`[useTSSelect] Duplicate ID detected: '${t}'. Found ${r.length} elements with this ID.`);return r[0]}return r.length>1&&process.env.NODE_ENV!=="production"&&console.warn(`[useTSSelect] Multiple elements found for selector: '${t}'. Returning the first one.`),r[0]};import{jwtDecode as ye}from"jwt-decode";var Z=(t,e)=>{let n=localStorage.getItem("token");if(!n)return window.location.href=e,null;try{let r=ye(n),o=Date.now()/1e3;return r.exp&&r.exp<o&&(console.error("Token has expired"),window.localStorage.removeItem("token"),window.location.href=e),null}catch(r){return console.error("Invalid token:",r),window.location.href=e,null}};var D=(t,e,n)=>{t.forEach(r=>{e.forEach(o=>{r.addEventListener(o,s=>{n(r,s)})})})};var ee=()=>({back:()=>window.history.back(),forward:()=>window.history.forward()});var te=(t,e)=>{let n=document.querySelector(`#${t}`)||document.querySelector(`.${t}`);if(!n)return;let r=window.location.pathname.replace(/\/$/,"");for(let o of e){let s=o.path.replace(/\/$/,"");if(r===s||r.startsWith(`${s}/`)){o.component(n);break}}};function ne(t,e){let n=window.location.pathname.replace(/\/$/,"");e.routes.forEach(r=>{r.children?.length&&r.children.forEach(o=>{let s=o.path.replace(/\/$/,"");if(n===s||n.startsWith(`${s}/`)){let i=t.querySelector(`#${o.outlet}`)||t.querySelector(`.${o.outlet}`);i instanceof HTMLElement&&o.element&&o.element(i)}})})}import{createStore as ve}from"zustand/vanilla";function re(t){let e=ve(()=>({value:t})),n=new Set;return{get:()=>e.getState().value,set:r=>{e.setState({value:r}),n.forEach(o=>o(r))},subscribe:r=>(n.add(r),r(e.getState().value),()=>n.delete(r))}}function oe(t){let e=t();typeof e=="function"&&e()}var H=()=>{let t=document.querySelectorAll('a[href^="#"]');D(t,["click"],(e,n)=>{n.preventDefault();let r=e.getAttribute("href")?.substring(1),o=r?document.getElementById(r):null;o&&o.scrollIntoView({behavior:"smooth",block:"start"})})};import{debounce as we}from"lodash-es";var $=t=>t;typeof window<"u"&&typeof document<"u"&&($=t=>{let e=document.createElement("div");return e.innerText=t,e.innerHTML});var Le=t=>{(t?Array.isArray(t)?t:t instanceof HTMLAnchorElement?[t]:Array.from(t):Array.from(document.querySelectorAll("a"))).forEach(n=>{if(!n||n.dataset.anchorEnhanced==="true")return;n.dataset.anchorEnhanced="true";let r=n.getAttribute("class")||"";n.setAttribute("class",$(r));let o=n.getAttribute("aria-label");o&&n.setAttribute("aria-label",$(o));let s=n.querySelector(":scope > *");s&&(n.innerHTML="",n.appendChild(s));let i=n.getAttribute("href")||"";if(!i.startsWith("#")){try{if(new URL(i,window.location.href).origin!==window.location.origin)return}catch{return}n.addEventListener("click",a=>{a.preventDefault();let c=n.getAttribute("href")||"";try{let l=new URL(c,window.location.href);window.history.pushState({},"",l.pathname+l.search+l.hash),window.dispatchEvent(new PopStateEvent("popstate"))}catch(l){console.error("Invalid URL in anchor:",c,l)}})}})},Me=we(Le,50),O=t=>{Me(t)};var b=t=>{let e=t.querySelectorAll("a");O(e)};var se=t=>{H(),b(t)};var ie=async()=>{let t="https://cdn.jsdelivr.net/npm/brython@3/brython.min.js",e="https://cdn.jsdelivr.net/npm/brython@3/brython_stdlib.js",n=r=>new Promise((o,s)=>{let i=document.createElement("script");i.src=r,i.onload=()=>o(),i.onerror=()=>s(new Error(`Failed to load ${r}`)),document.head.appendChild(i)});await n(t),await n(e),typeof window.brython=="function"?window.brython():console.error("Brython did not load correctly.")},ae=t=>new Promise((e,n)=>{let r=document.createElement("script");r.type="text/python",r.src=`/src/python/${t}`,r.onload=()=>e(),r.onerror=()=>n(new Error(`Failed to load ${t}`)),document.body.appendChild(r)});function ce(t){let e=null;return async(n,r)=>{try{if(!e){let o=await t();e=o.default||o}if(typeof e=="function")return e(n,r);if(e instanceof HTMLElement){n?.appendChild(e);return}if(e&&typeof e.render=="function")return e.render(n,r);console.warn("useTSLazy: Unsupported module type",e)}catch(o){console.error("useTSLazy failed:",o)}}}var le=t=>typeof window>"u"?{isDOM:null}:{isDOM:t||document.body};import me from"dompurify";import{createStore as Re}from"zustand/vanilla";import Ae from"dompurify";var L=Re(t=>({params:{},query:{},setParams:e=>t(()=>({params:ue(e)})),setQuery:e=>t(()=>({query:ue(e)}))}));function ue(t){let e={};for(let n in t)e[n]=Ae.sanitize(t[n]);return e}var N=class{constructor(e,n){this.routes=[];this.routes=e,this.expectedParams=new Set(n),window.addEventListener("popstate",this.handlePopState.bind(this)),this.handlePopState()}handlePopState(){let e=window.location.pathname,n=window.location.search,r=this.parseQueryParams(n),o=this.findMatchingRoute(e,this.routes);if(o){if(o.routeto){this.navigate(o.routeto);return}let s=this.filterAndSanitizeParams(o.params);L.getState().setParams(s),L.getState().setQuery(r);let i=document.createElement("div");if(o.element?.(i,s,r),o.children){let a=e.slice(o.path.length),c=i.querySelector("#child");c&&this.renderChildren(o.children,a,c,s,r)}}else{let s=this.findMatchingRoute("*",this.routes);if(s){let i=this.filterAndSanitizeParams(s.params);L.getState().setParams(i),L.getState().setQuery(r);let a=document.createElement("div");s.element?.(a,i,r)}}}renderChildren(e,n,r,o,s){if(!e||e.length===0){let a=r.querySelector("#child");a&&a.remove();return}let i=this.findMatchingRoute(n,e);if(i){let a=document.createElement("div");a.id="child";let c={...o,...i.params},l=this.filterAndSanitizeParams(c);if(L.getState().setParams(l),L.getState().setQuery(s),i.element?.(a,l,s),r.appendChild(a),i.children){let T=n.slice(i.path.length);this.renderChildren(i.children,T,a,l,s)}}}parseQueryParams(e){let n={},r=new URLSearchParams(e);for(let[o,s]of r.entries())this.expectedParams.has(o)&&(n[o]=me.sanitize(s));return n}findMatchingRoute(e,n,r={}){for(let o of n){let s=o.path;if(s==="*")return o;{let a=[],c=s.replace(/:[^\s/]+/g,u=>(a.push(u.substring(1)),"([^\\s/]+)")),l=new RegExp(`^${c}(?:/|$)`),T=e.match(l);if(T){let u={...r};if(a.forEach((E,p)=>{u[E]=T[p+1]??""}),o.children){let E=e.slice(T[0].length),p=this.findMatchingRoute(E,o.children,u);if(p)return p}return{...o,params:u}}}}}filterAndSanitizeParams(e){if(!e)return{};let n={};for(let r in e)this.expectedParams.has(r)&&(n[r]=me.sanitize(e[r]??""));return n}navigate(e){history.pushState(null,"",e),this.handlePopState()}addRoute(e){this.routes.push(e)}};var Pe=()=>({name:"ts-filebased-router",async buildStart(){if(typeof process>"u"||!process.versions?.node)return;let t=await import("fs/promises"),e=await import("path"),n=await import("./esm-KRNKVVL7.js"),r=e.resolve("src/pages"),o=e.resolve("src/gen"),s=e.resolve("src/routes"),i=e.join(o,"tsrouter.gen.ts"),a=e.join(s,"__root.ts"),c=process.env.NODE_ENV!=="production";async function l(d){try{await t.mkdir(d,{recursive:!0})}catch{}}function T(d,m){let f="/"+e.relative(m,d).replace(/\\/g,"/");return f=f.replace(/\.ts$/,"").replace(/\/index$/,"")||"/",f.replace(/\[(.+?)\]/g,":$1")}function u(d){return d.replace(/^\//,"").split("/").map(m=>m.startsWith(":")?m.slice(1):m).filter(Boolean).join("-")||"index"}function E(d,m){let g=e.relative(m,d).replace(/\\/g,"/").split("/").filter(Boolean),S=g[g.length-1].replace(".ts",""),v=g.length>1?g[g.length-2]:"";if(S.startsWith("[")&&S.endsWith("]")){let w=S.slice(1,-1);return v.charAt(0).toUpperCase()+v.slice(1)+w.charAt(0).toUpperCase()+w.slice(1)+"Param"}else return S.charAt(0).toUpperCase()+S.slice(1)}async function p(d){let m=await t.readdir(d,{withFileTypes:!0}),f=[];for(let g of m){let S=e.join(d,g.name);if(g.isDirectory())f=f.concat(await p(S));else if(g.isFile()&&g.name.endsWith(".ts")){let v=T(S,r),w=u(v),h=E(S,r);f.push({file:S,route:v,routeName:w,importName:h})}}return f}function M(d,m){let f=m.includes(":"),g=f?m.match(/:([^/]+)/)?.[1]:null;return`import { html, useTSElements, useTSMetaData${f?", useTSExtractParams":""} } from '@devwareng/vanilla-ts';
|
|
2
2
|
|
|
3
3
|
export default function ${d}(DOM: HTMLElement) {
|
|
4
|
-
|
|
5
|
-
useTSMetaData({ name: '${d.toLowerCase()}',
|
|
6
|
-
description: '',
|
|
7
|
-
author: ''
|
|
8
|
-
});
|
|
9
|
-
|
|
4
|
+
useTSMetaData({ name: '${d.toLowerCase()}', description: '', author: '' });
|
|
10
5
|
${f?`const params = useTSExtractParams("${m}");
|
|
11
6
|
if (!params.${g}) return;`:""}
|
|
12
|
-
|
|
13
|
-
const ui = useTSElements(
|
|
7
|
+
return useTSElements(
|
|
14
8
|
DOM,
|
|
15
9
|
html\`
|
|
16
10
|
<div class="p-4">
|
|
@@ -19,9 +13,7 @@ export default function ${d}(DOM: HTMLElement) {
|
|
|
19
13
|
</div>
|
|
20
14
|
\`
|
|
21
15
|
);
|
|
22
|
-
|
|
23
|
-
return ui
|
|
24
|
-
}`}function M(){return`import { createRouter } from "@/gen/tsrouter.gen";
|
|
16
|
+
}`}function y(){return`import { createRouter } from "@/gen/tsrouter.gen";
|
|
25
17
|
import { useTSParams } from "@devwareng/vanilla-ts";
|
|
26
18
|
|
|
27
19
|
export const Router = (DOM: HTMLElement) => {
|
|
@@ -32,7 +24,7 @@ export const Router = (DOM: HTMLElement) => {
|
|
|
32
24
|
window.addEventListener("popstate", () => {
|
|
33
25
|
router.navigate(window.location.pathname);
|
|
34
26
|
});
|
|
35
|
-
};`}async function
|
|
27
|
+
};`}async function k(){let d=await p(r),m=d.find(h=>h.route==="/notfound"),f=d.filter(h=>h.route!=="/notfound");for(let h of d)(await t.readFile(h.file,"utf-8")).trim()||await t.writeFile(h.file,M(h.importName,h.route),"utf-8");let g=d.map(h=>{let F="../pages/"+e.relative(r,h.file).replace(/\\/g,"/").replace(/\.ts$/,"");return`import ${h.importName} from "${F}";`}).join(`
|
|
36
28
|
`),S=f.map(h=>`{ path: "${h.route}", name: "${h.routeName}", component: (DOM: HTMLElement) => ${h.importName}(DOM) }`).join(`,
|
|
37
29
|
`),v=m?`export const NotFound = ${m.importName}`:"export function NotFound(DOM: HTMLElement) {\n return useTSElements(DOM, html`<div><h1>404 - Page Not Found</h1></div>`)\n}",w=`// AUTO-GENERATED FILE. DO NOT EDIT MANUALLY.
|
|
38
30
|
import { html, useTSElements } from "@devwareng/vanilla-ts"
|
|
@@ -84,4 +76,4 @@ export function createRouter(DOM: HTMLElement) {
|
|
|
84
76
|
navigate(window.location.pathname + window.location.search)
|
|
85
77
|
return { navigate, routes: routeTree }
|
|
86
78
|
}
|
|
87
|
-
`;await
|
|
79
|
+
`;await l(o),await t.writeFile(i,w,"utf-8"),await t.writeFile(a,y(),"utf-8")}await l(o),await l(s),await k(),c&&(n.watch(r).on("all",async(d,m)=>{if(d==="add"&&m.endsWith(".ts")){let g=e.basename(m,".ts").replace(/\[|\]/g,"Param").replace(/(^\w|-\w)/g,w=>w.replace("-","").toUpperCase()),S=T(m,r);(await t.readFile(m,"utf-8")).trim()||await t.writeFile(m,M(g,S),"utf-8"),await k()}}),n.watch(a).on("unlink",async()=>{await t.writeFile(a,y(),"utf-8")})),console.log("\u{1F7E2} TS Filebased Router Generated Successfully...")}});export{Pe as TSFilebasedRouter,N as TSRouter,oe as createEffect,re as createSignal,z as html,ae as loadPyFiles,fe as mapper,ne as renderChildRoutes,O as useAnchor,V as useAnchorSingle,G as useInitialDOM,se as useTSAnchorMount,Z as useTSAuth,Y as useTSCollection,x as useTSComponent,D as useTSElementEach,B as useTSElements,q as useTSEvent,W as useTSEventAll,j as useTSExtractParams,H as useTSHashAnchor,ce as useTSLazy,X as useTSMetaData,ee as useTSNavigate,b as useTSNoReload,te as useTSOutlet,A as useTSParams,_ as useTSPurifier,le as useTSSSRHydration,K as useTSSelect,ie as useTSloadBrython};
|