@fgv/ts-res-browser 5.0.0-12 → 5.0.0-14
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/681.bundle.js +1 -0
- package/dist/828.bundle.js +1 -0
- package/dist/bundle.js +1 -1
- package/dist/bundle.js.LICENSE.txt +1 -1
- package/package.json +33 -34
- package/dist/25.bundle.js +0 -1
- package/dist/948.bundle.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_fgv_ts_res_browser=self.webpackChunk_fgv_ts_res_browser||[]).push([[681],{56681:(t,e,s)=>{s.d(e,{BrowserZipFileTreeAccessors:()=>c});var r=s(78013),i=s.n(r),n=s(66486);class a{type="file";constructor(t,e,s){this._contents=e,this._accessors=s,this.absolutePath="/"+t,this.name=s.getBaseName(t),this.extension=s.getExtension(t),this.baseName=s.getBaseName(t,this.extension)}getContents(t){return this.getRawContents().withErrorFormat(t=>`${this.absolutePath}: read raw contents failed: ${t}`).onSuccess(t=>(0,n.captureResult)(()=>JSON.parse(t)).withErrorFormat(t=>`${this.absolutePath}: JSON parse error: ${t}`)).onSuccess(e=>t?"convert"in t?t.convert(e):t.validate(e):(0,n.succeed)(e))}getRawContents(){return(0,n.succeed)(this._contents)}}class o{type="directory";constructor(t,e){this._accessors=e,this.absolutePath="/"+t.replace(/\/$/,""),this.name=e.getBaseName(t)}getChildren(){return this._accessors.getChildren(this.absolutePath)}}class c{_itemCache=new Map;_fileContents=new Map;constructor(t,e,s){this._zip=t,this._fileContents=e,this._prefix=s||"",this._buildItemCache()}static async fromBuffer(t,e){try{const s=new(i());await s.loadAsync(t);const r=new Map,a=[];return s.forEach((t,e)=>{if(!e.dir){const s=e.async("string").then(e=>{r.set(t,e)});a.push(s)}}),await Promise.all(a),(0,n.succeed)(new c(s,r,e))}catch(t){return(0,n.fail)(`Failed to load ZIP archive: ${t instanceof Error?t.message:String(t)}`)}}static async fromFile(t,e){try{const s=await t.arrayBuffer();return await c.fromBuffer(s,e)}catch(t){return(0,n.fail)(`Failed to read file: ${t instanceof Error?t.message:String(t)}`)}}_buildItemCache(){const t=new Set;this._zip.forEach((e,s)=>{if(!s.dir){const s=e.split("/");for(let e=1;e<s.length;e++){const r=s.slice(0,e).join("/");t.add(r)}}}),t.forEach(t=>{const e=this.resolveAbsolutePath(t),s=new o(t,this);this._itemCache.set(e,s)}),this._zip.forEach((t,e)=>{if(!e.dir){const e=this.resolveAbsolutePath(t),s=this._fileContents.get(t)||"",r=new a(t,s,this);this._itemCache.set(e,r)}})}resolveAbsolutePath(...t){const e=this.joinPaths(...t),s=this._prefix?this.joinPaths(this._prefix,e):e;return s.startsWith("/")?s:"/"+s}getExtension(t){const e=this.getBaseName(t),s=e.lastIndexOf(".");return s>=0?e.substring(s):""}getBaseName(t,e){const s=t.replace(/\/$/,"").split("/");let r=s[s.length-1]||"";return e&&r.endsWith(e)&&(r=r.substring(0,r.length-e.length)),r}joinPaths(...t){return t.filter(t=>t&&t.length>0).map(t=>t.replace(/^\/+|\/+$/g,"")).join("/").replace(/\/+/g,"/")}getItem(t){const e=this.resolveAbsolutePath(t),s=this._itemCache.get(e);return s?(0,n.succeed)(s):(0,n.fail)(`Item not found: ${e}`)}getFileContents(t){return this.getItem(t).onSuccess(e=>"file"!==e.type?(0,n.fail)(`Path is not a file: ${t}`):e.getRawContents())}getChildren(t){const e=this.resolveAbsolutePath(t),s=[];for(const[t,r]of this._itemCache)this._isDirectChild(e,t)&&s.push(r);return(0,n.succeed)(s)}_isDirectChild(t,e){const s=t.replace(/\/$/,""),r=e.replace(/\/$/,"");return!!r.startsWith(s+"/")&&!r.substring(s.length+1).includes("/")}}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_fgv_ts_res_browser=self.webpackChunk_fgv_ts_res_browser||[]).push([[828],{27828:(e,t,r)=>{r.d(t,{FileTreeConverter:()=>i});var s=r(66486);class i{static convertDirectory(e,t){try{const r=e.getItem(t);if(r.isFailure())return(0,s.fail)(`Directory not found: ${t}`);const i=r.value;if("directory"!==i.type)return(0,s.fail)(`Path is not a directory: ${t}`);const n=i.getChildren();if(n.isFailure())return(0,s.fail)(`Failed to get directory children: ${n.message}`);const c=[],o=[];for(const t of n.value)if("file"===t.type){const e=this.convertFile(t);e.isSuccess()&&c.push(e.value)}else if("directory"===t.type){const r=this.convertDirectory(e,t.absolutePath);r.isSuccess()&&o.push(r.value)}const a={name:i.name,path:i.absolutePath,files:c,subdirectories:o};return(0,s.succeed)(a)}catch(e){return(0,s.fail)(`Failed to convert directory: ${e instanceof Error?e.message:String(e)}`)}}static convertFile(e){try{const t=e.getRawContents();if(t.isFailure())return(0,s.fail)(`Failed to read file contents: ${t.message}`);const r={name:e.name,path:e.absolutePath,content:t.value};return(0,s.succeed)(r)}catch(e){return(0,s.fail)(`Failed to convert file: ${e instanceof Error?e.message:String(e)}`)}}static convertFiles(e){try{const t=[];for(const r of e){const e=this.convertFile(r);if(!e.isSuccess())return(0,s.fail)(`Failed to convert file ${r.name}: ${e.message}`);t.push(e.value)}return(0,s.succeed)(t)}catch(e){return(0,s.fail)(`Failed to convert files: ${e instanceof Error?e.message:String(e)}`)}}static convertPath(e,t){try{const r=e.getItem(t);if(r.isFailure())return(0,s.fail)(`Path not found: ${t}`);const i=r.value;if("directory"===i.type)return this.convertDirectory(e,t);if("file"===i.type){const e=this.convertFile(i);return e.isSuccess()?(0,s.succeed)([e.value]):e}return(0,s.fail)(`Unknown item type: ${t}`)}catch(e){return(0,s.fail)(`Failed to convert path: ${e instanceof Error?e.message:String(e)}`)}}}}}]);
|