@realsee/five 6.8.0-alpha.17 → 6.8.0-alpha.18

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.
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * @license
3
3
  * @realsee/five
4
- * Generated: 3/13/2026
5
- * Version: 6.8.0-alpha.17
4
+ * Generated: 3/17/2026
5
+ * Version: 6.8.0-alpha.18
6
6
  * Terms:
7
7
  * Realsee SDK License Agreement
8
8
  * Update: July 28, 2021
@@ -252,4 +252,4 @@
252
252
  * No amendment to or modification of this Agreement will be binding unless in
253
253
  * writing and signed by Realsee. You and Realsee hereto confirm that this
254
254
  * Agreement and all related documents shall be drafted in English.
255
- */"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("node:fs"),B=require("node:fs/promises"),L=require("node:path"),K=require("node:stream"),Q=require("sharp");function S(n,r,e,a){function i(t){return t instanceof e?t:new e(function(u){u(t)})}return new(e||(e=Promise))(function(t,u){function o(c){try{s(a.next(c))}catch(f){u(f)}}function l(c){try{s(a.throw(c))}catch(f){u(f)}}function s(c){c.done?t(c.value):i(c.value).then(o,l)}s((a=a.apply(n,r||[])).next())})}function F(n,r){var e={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},a,i,t,u=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return u.next=o(0),u.throw=o(1),u.return=o(2),typeof Symbol=="function"&&(u[Symbol.iterator]=function(){return this}),u;function o(s){return function(c){return l([s,c])}}function l(s){if(a)throw new TypeError("Generator is already executing.");for(;u&&(u=0,s[0]&&(e=0)),e;)try{if(a=1,i&&(t=s[0]&2?i.return:s[0]?i.throw||((t=i.return)&&t.call(i),0):i.next)&&!(t=t.call(i,s[1])).done)return t;switch(i=0,t&&(s=[s[0]&2,t.value]),s[0]){case 0:case 1:t=s;break;case 4:return e.label++,{value:s[1],done:!1};case 5:e.label++,i=s[1],s=[0];continue;case 7:s=e.ops.pop(),e.trys.pop();continue;default:if(t=e.trys,!(t=t.length>0&&t[t.length-1])&&(s[0]===6||s[0]===2)){e=0;continue}if(s[0]===3&&(!t||s[1]>t[0]&&s[1]<t[3])){e.label=s[1];break}if(s[0]===6&&e.label<t[1]){e.label=t[1],t=s;break}if(t&&e.label<t[2]){e.label=t[2],e.ops.push(s);break}t[2]&&e.ops.pop(),e.trys.pop();continue}s=r.call(n,e)}catch(c){s=[6,c],i=0}finally{a=t=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function O(n,r){if(r&&r[r.length-1]!=="/"&&(r+="/"),n.length>r.length&&n.startsWith(r))return n.slice(r.length);throw new Error("".concat(n," is not starting with ").concat(r))}function V(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var e=[];n=n.map(function(o){return(o!=null?o:"").trim()}).filter(function(o){return o.length>0&&!/^\/+$/.test(o)});for(var a=0;a<n.length;a++){var i=a===0,t=a===n.length-1,u=n[a];i||(u=u.replace(/^\.\//,"").replace(/^\/+/,"")),t||(u=u.replace(/\/+$/,"")),e.push(u)}return e.join("/")}var Y=1024*1024*5;function T(n,r,e){return S(this,void 0,void 0,function(){var a,i,t,u;return F(this,function(o){switch(o.label){case 0:return I.existsSync(r)?[2,r]:[4,e(n)];case 1:return a=o.sent(),a.ok&&a.body?[4,B.mkdir(L.dirname(r),{recursive:!0})]:[3,6];case 2:return o.sent(),i=Number((u=a.headers.get("content-length"))!==null&&u!==void 0?u:"Infinity"),i>Y?[2,new Promise(function(l,s){var c=K.Readable.fromWeb(a.body),f=I.createWriteStream(r);c.pipe(f),c.on("error",s),f.on("finish",function(){return l(r)})})]:[3,3];case 3:return[4,a.arrayBuffer()];case 4:return t=o.sent(),[4,B.writeFile(r,Buffer.from(t))];case 5:return o.sent(),[2,r];case 6:throw new Error("url: ".concat(n,"(").concat(a.statusText,")"))}})})}var Z=["jpg","png"],x=95;function G(n,r){var e=L.extname(n).slice(1)||"jpg",a=r.cut,i=r.size,t=r.format,u=t===void 0?e:t,o="";if(r.toFilename)o=r.toFilename(n,{cut:r.cut,size:r.size,format:r.format});else{var l="",s="",c=u;a&&(l=a.join("x")),i&&(s="".concat(i,"x")),c===e&&!s&&!l&&(c=""),o=[n,l,s,c].filter(function(f){return f.length>0}).join(".")}return o}function J(n,r){return S(this,void 0,void 0,function(){var e,a,i,t,u,o,l,s,c;return F(this,function(f){return e=L.extname(n).slice(1)||"jpg",a=r.cut,i=r.size,t=r.format,u=t===void 0?e:t,o=n,(a||i)&&u!==e&&Z.includes(u)&&(l=G(n,{format:u,toFilename:r.toFilename}),l!==o&&I.existsSync(l)&&(o=l)),s=Q(o),a&&(s=s.extract({left:a[0],top:a[1],width:a[2],height:a[3]})),i&&(s=s.resize(i)),s=s.toFormat(u,{quality:x}),c=G(n,r),c!==n&&!I.existsSync(c)?[2,s.toFile(c).then(function(){return c})]:[2,c]})})}function X(n){var r=[];if(n.content&&(n.content.uri?r.push(n.content.uri):n.content.url&&r.push(n.content.url)),n.children)for(var e=0,a=n.children;e<a.length;e++){var i=a[e],t=X(i);if(t.length>0)for(var u=0;u<t.length;u++)r.push(t[u])}return r}function ee(n,r,e){return S(this,void 0,void 0,function(){var a,i,t;return F(this,function(u){switch(u.label){case 0:return a=new URL(n,r).href,i=L.join(e.distPath,O(a,e.baseURL)),t=T(a,i,e.fetch),e.log(function(o){return"download: ".concat(a," -> ").concat(o)},t),[4,t];case 1:return u.sent(),/\.json$/.test(n)?[4,H(a,e)]:[3,3];case 2:u.sent(),u.label=3;case 3:return[2]}})})}function H(n,r){return S(this,void 0,void 0,function(){var e,a,i,t,u,o,l,s,c,f,v,m,p,b,w,d,h,y,k;return F(this,function(g){switch(g.label){case 0:return e=L.join(r.distPath,O(n,r.baseURL)),a=T(n,e,r.fetch),r.log(function(z){return"download: ".concat(n," -> ").concat(z)},a),[4,a];case 1:return g.sent(),u=(t=JSON).parse,[4,B.readFile(e,"utf8")];case 2:return i=u.apply(t,[g.sent()]),i.asset.overview?(o=new URL(i.asset.overview.imageFile,n).href,l=L.join(r.distPath,O(o,r.baseURL)),s=T(o,l,r.fetch),r.log(function(z){return"download: ".concat(o," -> ").concat(z)},s),[4,s]):[3,4];case 3:g.sent(),g.label=4;case 4:if(!i.asset.trajectories)return[3,8];c=function(z){var j,P,R;return F(this,function(U){switch(U.label){case 0:return j=new URL(z.file,n).href,P=L.join(r.distPath,O(j,r.baseURL)),R=T(j,P,r.fetch),r.log(function(_){return"download: ".concat(j," -> ").concat(_)},R),[4,R];case 1:return U.sent(),[2]}})},f=0,v=i.asset.trajectories.list,g.label=5;case 5:return f<v.length?(m=v[f],[5,c(m)]):[3,8];case 6:g.sent(),g.label=7;case 7:return f++,[3,5];case 8:p=X(i.root),b=6,w=0,g.label=9;case 9:if(!(w<p.length))return[3,12];for(d=[],h=0;h<b;h++)y=p[w+h],y&&(k=ee(y,n,r),d.push(k));return[4,Promise.all(d)];case 10:g.sent(),g.label=11;case 11:return w+=b,[3,9];case 12:return[2]}})})}function re(n,r){return S(this,void 0,void 0,function(){var e,a,i,t,u,d,o,l,s,c,f,v,m,p,b,w,d;return F(this,function(h){switch(h.label){case 0:return r.log("process model"),n.model?(e=n.model,a=e.textures,i=e.layers,t=e.file,u=e.textureBase,t?(r.log("process model file"),d=n.getURL(t),o=L.join(r.distPath,O(d,r.baseURL)),l=T(d,o,r.fetch),r.log(function(y){return"download: ".concat(t," -> ").concat(y)},l),[4,l]):[3,5]):[3,9];case 1:if(h.sent(),!a)return[3,5];s=function(y){var k,g,z,j,P,R,U,_,E,$,C,A,D;return F(this,function(M){switch(M.label){case 0:return k=V(n.getURL(u!=null?u:""),y),g=L.join(r.distPath,O(k,r.baseURL)),z=T(k,g,r.fetch),r.log(function(W){return"download: ".concat(k," -> ").concat(W)},z),[4,z];case 1:for(M.sent(),j=r.imageOptions.format,j.length===0&&j.push(void 0),P=r.imageOptions.size,P.length===0&&P.push(void 0),R=[],U=0,_=j;U<_.length;U++)for(E=_[U],$=0,C=P;$<C.length;$++)A=C[$],D=J(g,{format:E,size:A,toFilename:r.imageProcessingFilename}),r.log(function(W){return"imageProcessing: ".concat(g," -> ").concat(W)},D),R.push(D);return[4,Promise.all(R)];case 2:return M.sent(),[2]}})},c=0,f=a,h.label=2;case 2:return c<f.length?(v=f[c],[5,s(v)]):[3,5];case 3:h.sent(),h.label=4;case 4:return c++,[3,2];case 5:if(!i)return[3,9];m=0,p=i,h.label=6;case 6:return m<p.length?(b=p[m],w=b.tileset,r.log("process model layer"),d=n.getURL(w),[4,H(d,r)]):[3,9];case 7:h.sent(),h.label=8;case 8:return m++,[3,6];case 9:return[2]}})})}function q(n,r,e){return S(this,void 0,void 0,function(){var a,i,t,u,o,l,s,c,f,v,m,p,b,w;return F(this,function(d){switch(d.label){case 0:return a=L.join(e.distPath,O(n,e.baseURL)),i=T(n,a,e.fetch),e.log(function(h){return"download: ".concat(n," -> ").concat(h)},i),[4,i];case 1:if(d.sent(),t=Math.pow(2,r.level),u=e.imageOptions.format,u.length===0&&u.push(void 0),o=[],t>1)for(l=0;l<t;l++)for(s=0;s<t;s++)for(c=0,f=u;c<f.length;c++)v=f[c],m=[r.size/t*s,r.size/t*l,r.size/t,r.size/t],p=r.scale>=1?void 0:r.scale*r.size/t,b=J(a,{format:v,size:p,cut:m,toFilename:e.imageProcessingFilename}),e.log(function(h){return"imageProcessing: ".concat(a," -> ").concat(h)},b),o.push(b),r.level===1&&r.scale>=.5&&(v==="jpg"||/\.jpg$/.test(a))&&(w=J(a,{format:v,size:void 0,cut:m,toFilename:e.imageProcessingFilename}),e.log(function(h){return"imageProcessing: ".concat(a," -> ").concat(h)},w),o.push(w));return[4,Promise.all(o)];case 2:return d.sent(),[2]}})})}function ne(n,r){return S(this,void 0,void 0,function(){return F(this,function(e){switch(e.label){case 0:return[4,Promise.all([q(n.work.getURL(n.front),n,r),q(n.work.getURL(n.back),n,r),q(n.work.getURL(n.left),n,r),q(n.work.getURL(n.right),n,r),q(n.work.getURL(n.up),n,r),q(n.work.getURL(n.down),n,r)])];case 1:return e.sent(),[2]}})})}function N(n,r,e){return S(this,void 0,void 0,function(){var a,i,t,u,o,l,s,c,f,v,m,p,b,w,d,h;return F(this,function(y){switch(y.label){case 0:return a=L.join(e.distPath,O(n,e.baseURL)),i=T(n,a,e.fetch),e.log(function(k){return"download: ".concat(n," -> ").concat(k)},i),[4,i];case 1:y.sent(),t=e.imageOptions.format,t.length===0&&t.push(void 0),u=e.imageOptions.size,u.length===0&&u.push(void 0),o=function(k){var g,z,j,P,R,U,_;return F(this,function(E){switch(E.label){case 0:return g=n.replace(/cube\_\d+/,"cube_".concat(k)),z=L.join(e.distPath,O(g,e.baseURL)),j=T(g,z,e.fetch),e.log(function($){return"download ".concat(g," -> ").concat(z)},j),[4,j];case 1:E.sent(),P=0,R=t,E.label=2;case 2:return P<R.length?(U=R[P],_=J(z,{format:U,toFilename:e.imageProcessingFilename}),e.log(function($){return"imageProcessing: ".concat(z," -> ").concat($)},_),[4,_]):[3,5];case 3:E.sent(),E.label=4;case 4:return P++,[3,2];case 5:return[2]}})},l=0,s=r,y.label=2;case 2:return l<s.length?(c=s[l],[5,o(c)]):[3,5];case 3:y.sent(),y.label=4;case 4:return l++,[3,2];case 5:for(f=[],v=0,m=t;v<m.length;v++)for(p=m[v],b=0,w=u;b<w.length;b++)d=w[b],h=J(a,{format:p,size:d,toFilename:e.imageProcessingFilename}),e.log(function(k){return"imageProcessing: ".concat(a," -> ").concat(k)},h),f.push(h);return[4,Promise.all(f)];case 6:return y.sent(),[2]}})})}function te(n,r){return S(this,void 0,void 0,function(){var e;return F(this,function(a){switch(a.label){case 0:return e=n.images,[4,Promise.all([N(e.work.getURL(e.front),e.sizeList,r),N(e.work.getURL(e.back),e.sizeList,r),N(e.work.getURL(e.left),e.sizeList,r),N(e.work.getURL(e.right),e.sizeList,r),N(e.work.getURL(e.up),e.sizeList,r),N(e.work.getURL(e.down),e.sizeList,r)])];case 1:return a.sent(),e.tiles?[4,Promise.all(e.tiles.map(function(i){return ne(i,r)}))]:[3,3];case 2:a.sent(),a.label=3;case 3:return[2]}})})}function ae(n,r){return S(this,void 0,void 0,function(){var e,a,i,t,u;return F(this,function(o){switch(o.label){case 0:e=n.observers,a=0,i=e,o.label=1;case 1:return a<i.length?(t=i[a],u=te(t,r),r.log("process observer #".concat(t.index," derived: ").concat(t.derivedIdStr),u),[4,u]):[3,4];case 2:o.sent(),o.label=3;case 3:return a++,[3,1];case 4:return[2]}})})}function ie(n,r){if(r){var e=Date.now();r.then(function(i){var t=Date.now()-e,u=typeof n=="function"?n(i):n;console.log(u+"(".concat(t,"ms)"))}).catch(function(){})}else{var a=typeof n=="function"?n(null):n;console.log(a)}}function se(n){return S(this,arguments,void 0,function(r,e){var a,i,t,u,o,l,s,c,f,v,m,p,b,w,d;return e===void 0&&(e={}),F(this,function(h){switch(h.label){case 0:if(a=r.baseURL,i="",e.distPath)i=L.resolve(process.cwd(),e.distPath);else for(i=L.resolve(process.cwd(),(l=r.workCode)!==null&&l!==void 0?l:"work-".concat(Date.now()));I.existsSync(i);)/.-(\d+)$/.test(i)?i=i.replace(/.-(\d+)$/,function(y,k){return"-"+(Number(k)+1)}):i=i+"-1";return t={baseURL:a,distPath:i,fetch:(s=e.fetch)!==null&&s!==void 0?s:fetch,imageOptions:{size:(f=(c=e.imageOptions)===null||c===void 0?void 0:c.size)!==null&&f!==void 0?f:[],format:(m=(v=e.imageOptions)===null||v===void 0?void 0:v.format)!==null&&m!==void 0?m:[]},textureOptions:{size:(b=(p=e.textureOptions)===null||p===void 0?void 0:p.size)!==null&&b!==void 0?b:[],format:(d=(w=e.textureOptions)===null||w===void 0?void 0:w.format)!==null&&d!==void 0?d:[]},log:e.log?ie:(function(){return Promise.resolve()}),imageProcessingFilename:e.imageProcessingFilename},t.log(JSON.stringify(t,null," ")),[4,B.mkdir(i,{recursive:!0})];case 1:return h.sent(),u="work.json",o=L.resolve(i,u),[4,B.writeFile(o,JSON.stringify(r.toJSON(),null," "))];case 2:return h.sent(),[4,ae(r,t)];case 3:return h.sent(),[4,re(r,t)];case 4:return h.sent(),[2]}})})}exports.download=se;
255
+ */Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`node:fs`),l=require(`node:fs/promises`),u=require(`node:path`),d=require(`node:stream`),f=require(`sharp`);f=s(f);function p(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function m(e,t){if(t&&t[t.length-1]!==`/`&&(t+=`/`),e.length>t.length&&e.startsWith(t))return e.slice(t.length);throw Error(`${e} is not starting with ${t}`)}function h(...e){let t=[];e=e.map(e=>(e==null?``:e).trim()).filter(e=>e.length>0&&!/^\/+$/.test(e));for(let n=0;n<e.length;n++){let r=n===0,i=n===e.length-1,a=e[n];r||(a=a.replace(/^\.\//,``).replace(/^\/+/,``)),i||(a=a.replace(/\/+$/,``)),t.push(a)}return t.join(`/`)}var g=1024*1024*5;function _(e,t,n){return p(this,void 0,void 0,function*(){var r;if((0,c.existsSync)(t))return t;let i=yield n(e);if(i.ok&&i.body){if(yield(0,l.mkdir)((0,u.dirname)(t),{recursive:!0}),Number((r=i.headers.get(`content-length`))==null?`Infinity`:r)>g)return new Promise((e,n)=>{let r=d.Readable.fromWeb(i.body),a=(0,c.createWriteStream)(t);r.pipe(a),r.on(`error`,n),a.on(`finish`,()=>e(t))});{let e=yield i.arrayBuffer();return yield(0,l.writeFile)(t,Buffer.from(e)),t}}throw Error(`url: ${e}(${i.statusText})`)})}var v=[`jpg`,`png`],y=95;function b(e,t){let n=(0,u.extname)(e).slice(1)||`jpg`,{cut:r,size:i,format:a=n}=t,o=``;if(t.toFilename)o=t.toFilename(e,{cut:t.cut,size:t.size,format:t.format});else{let t=``,s=``,c=a;r&&(t=r.join(`x`)),i&&(s=`${i}x`),c===n&&!s&&!t&&(c=``),o=[e,t,s,c].filter(e=>e.length>0).join(`.`)}return o}function x(e,t){return p(this,void 0,void 0,function*(){let n=(0,u.extname)(e).slice(1)||`jpg`,{cut:r,size:i,format:a=n}=t,o=e;if((r||i)&&a!==n&&v.includes(a)){let n=b(e,{format:a,toFilename:t.toFilename});n!==o&&(0,c.existsSync)(n)&&(o=n)}let s=(0,f.default)(o);r&&(s=s.extract({left:r[0],top:r[1],width:r[2],height:r[3]})),i&&(s=s.resize(i)),s=s.toFormat(a,{quality:y});let l=b(e,t);return l!==e&&!(0,c.existsSync)(l)?s.toFile(l).then(()=>l):l})}function S(e){let t=[];if(e.content&&(e.content.uri?t.push(e.content.uri):e.content.url&&t.push(e.content.url)),e.children)for(let n of e.children){let e=S(n);if(e.length>0)for(let n=0;n<e.length;n++)t.push(e[n])}return t}function C(e,t,n){return p(this,void 0,void 0,function*(){let r=new URL(e,t).href,i=_(r,(0,u.join)(n.distPath,m(r,n.baseURL)),n.fetch);n.log(e=>`download: ${r} -> ${e}`,i),yield i,/\.json$/.test(e)&&(yield w(r,n))})}function w(e,t){return p(this,void 0,void 0,function*(){let n=(0,u.join)(t.distPath,m(e,t.baseURL)),r=_(e,n,t.fetch);t.log(t=>`download: ${e} -> ${t}`,r),yield r;let i=JSON.parse(yield(0,l.readFile)(n,`utf8`));if(i.asset.overview){let n=new URL(i.asset.overview.imageFile,e).href,r=_(n,(0,u.join)(t.distPath,m(n,t.baseURL)),t.fetch);t.log(e=>`download: ${n} -> ${e}`,r),yield r}if(i.asset.trajectories)for(let n of i.asset.trajectories.list){let r=new URL(n.file,e).href,i=_(r,(0,u.join)(t.distPath,m(r,t.baseURL)),t.fetch);t.log(e=>`download: ${r} -> ${e}`,i),yield i}let a=S(i.root);for(let n=0;n<a.length;n+=6){let r=[];for(let i=0;i<6;i++){let o=a[n+i];if(o){let n=C(o,e,t);r.push(n)}}yield Promise.all(r)}})}function T(e,t){return p(this,void 0,void 0,function*(){if(t.log(`process model`),e.model){let{textures:n,layers:r,file:i,textureBase:a}=e.model;if(i){t.log(`process model file`);let r=e.getURL(i),o=_(r,(0,u.join)(t.distPath,m(r,t.baseURL)),t.fetch);if(t.log(e=>`download: ${i} -> ${e}`,o),yield o,n)for(let r of n){let n=h(e.getURL(a==null?``:a),r),i=(0,u.join)(t.distPath,m(n,t.baseURL)),o=_(n,i,t.fetch);t.log(e=>`download: ${n} -> ${e}`,o),yield o;let s=t.imageOptions.format;s.length===0&&s.push(void 0);let c=t.imageOptions.size;c.length===0&&c.push(void 0);let l=[];for(let e of s)for(let n of c){let r=x(i,{format:e,size:n,toFilename:t.imageProcessingFilename});t.log(e=>`imageProcessing: ${i} -> ${e}`,r),l.push(r)}yield Promise.all(l)}}if(r)for(let n of r){let{tileset:r}=n;t.log(`process model layer`),yield w(e.getURL(r),t)}}})}function E(e,t,n){return p(this,void 0,void 0,function*(){let r=(0,u.join)(n.distPath,m(e,n.baseURL)),i=_(e,r,n.fetch);n.log(t=>`download: ${e} -> ${t}`,i),yield i;let a=Math.pow(2,t.level),o=n.imageOptions.format;o.length===0&&o.push(void 0);let s=[];if(a>1)for(let e=0;e<a;e++)for(let i=0;i<a;i++)for(let c of o){let o=[t.size/a*i,t.size/a*e,t.size/a,t.size/a],l=x(r,{format:c,size:t.scale>=1?void 0:t.scale*t.size/a,cut:o,toFilename:n.imageProcessingFilename});if(n.log(e=>`imageProcessing: ${r} -> ${e}`,l),s.push(l),t.level===1&&t.scale>=.5&&(c===`jpg`||/\.jpg$/.test(r))){let e=x(r,{format:c,size:void 0,cut:o,toFilename:n.imageProcessingFilename});n.log(e=>`imageProcessing: ${r} -> ${e}`,e),s.push(e)}}yield Promise.all(s)})}function D(e,t){return p(this,void 0,void 0,function*(){yield Promise.all([E(e.work.getURL(e.front),e,t),E(e.work.getURL(e.back),e,t),E(e.work.getURL(e.left),e,t),E(e.work.getURL(e.right),e,t),E(e.work.getURL(e.up),e,t),E(e.work.getURL(e.down),e,t)])})}function O(e,t,n){return p(this,void 0,void 0,function*(){let r=(0,u.join)(n.distPath,m(e,n.baseURL)),i=_(e,r,n.fetch);n.log(t=>`download: ${e} -> ${t}`,i),yield i;let a=n.imageOptions.format;a.length===0&&a.push(void 0);let o=n.imageOptions.size;o.length===0&&o.push(void 0);for(let r of t){let t=e.replace(/cube\_\d+/,`cube_${r}`),i=(0,u.join)(n.distPath,m(t,n.baseURL)),o=_(t,i,n.fetch);n.log(e=>`download ${t} -> ${i}`,o),yield o;for(let e of a){let t=x(i,{format:e,toFilename:n.imageProcessingFilename});n.log(e=>`imageProcessing: ${i} -> ${e}`,t),yield t}}let s=[];for(let e of a)for(let t of o){let i=x(r,{format:e,size:t,toFilename:n.imageProcessingFilename});n.log(e=>`imageProcessing: ${r} -> ${e}`,i),s.push(i)}yield Promise.all(s)})}function k(e,t){return p(this,void 0,void 0,function*(){let{images:n}=e;yield Promise.all([O(n.work.getURL(n.front),n.sizeList,t),O(n.work.getURL(n.back),n.sizeList,t),O(n.work.getURL(n.left),n.sizeList,t),O(n.work.getURL(n.right),n.sizeList,t),O(n.work.getURL(n.up),n.sizeList,t),O(n.work.getURL(n.down),n.sizeList,t)]),n.tiles&&(yield Promise.all(n.tiles.map(e=>D(e,t))))})}function A(e,t){return p(this,void 0,void 0,function*(){let{observers:n}=e;for(let e of n){let n=k(e,t);t.log(`process observer #${e.index} derived: ${e.derivedIdStr}`,n),yield n}})}function j(e,t){if(t){let n=Date.now();t.then(t=>{let r=Date.now()-n,i=typeof e==`function`?e(t):e;console.log(i+`(${r}ms)`)}).catch(()=>{})}else{let t=typeof e==`function`?e(null):e;console.log(t)}}function M(e){return p(this,arguments,void 0,function*(e,t={}){var n,r,i,a,o,s,d,f,p,m;let h=e.baseURL,g=``;if(t.distPath)g=(0,u.resolve)(process.cwd(),t.distPath);else for(g=(0,u.resolve)(process.cwd(),(n=e.workCode)==null?`work-${Date.now()}`:n);(0,c.existsSync)(g);)/.-(\d+)$/.test(g)?g=g.replace(/.-(\d+)$/,(e,t)=>`-`+(Number(t)+1)):g+=`-1`;let _={baseURL:h,distPath:g,fetch:(r=t.fetch)==null?fetch:r,imageOptions:{size:(a=(i=t.imageOptions)==null?void 0:i.size)==null?[]:a,format:(s=(o=t.imageOptions)==null?void 0:o.format)==null?[]:s},textureOptions:{size:(f=(d=t.textureOptions)==null?void 0:d.size)==null?[]:f,format:(m=(p=t.textureOptions)==null?void 0:p.format)==null?[]:m},log:t.log?j:(()=>Promise.resolve()),imageProcessingFilename:t.imageProcessingFilename};_.log(JSON.stringify(_,null,` `)),yield(0,l.mkdir)(g,{recursive:!0}),yield(0,l.writeFile)((0,u.resolve)(g,`work.json`),JSON.stringify(e.toJSON(),null,` `)),yield A(e,_),yield T(e,_)})}exports.download=M;