fluxfiles 1.0.2 → 1.0.3
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/fluxfiles.js +3 -1
- package/fluxfiles.min.js +1 -1
- package/package.json +2 -2
package/fluxfiles.js
CHANGED
|
@@ -63,7 +63,9 @@
|
|
|
63
63
|
config.onSelect(msg.payload);
|
|
64
64
|
}
|
|
65
65
|
emit('FM_SELECT', msg.payload);
|
|
66
|
-
|
|
66
|
+
// Only the modal overlay closes on select; an embedded (container)
|
|
67
|
+
// manager stays on the page and keeps listening (issue #309).
|
|
68
|
+
if (!config.container) FluxFiles.close();
|
|
67
69
|
break;
|
|
68
70
|
|
|
69
71
|
case 'FM_TOKEN_REFRESH':
|
package/fluxfiles.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(T){"use strict";var C=1,E="fluxfiles",L="clipboard-write; fullscreen",o=null,s={},n={},b=!1,m="",h=!1;function S(){return"ff-"+Math.random().toString(36).substr(2,9)+Date.now().toString(36)}function d(t,e){!o||!o.contentWindow||o.contentWindow.postMessage({source:E,type:t,v:C,id:S(),payload:e||{}},m||"*")}function _(t){if(!(!o||!o.contentWindow||t.source!==o.contentWindow)&&!(m&&t.origin!==m)){var e=t.data;if(!(!e||e.source!==E))switch(e.type){case"FM_READY":b=!0,d("FM_CONFIG",{disk:n.disk||"local",disks:n.disks||["local"],token:n.token||"",path:n.path||"",mode:n.mode||"picker",multiple:!!n.multiple,allowedTypes:n.allowedTypes||null,maxUploadMb:typeof n.maxUploadMb=="number"?n.maxUploadMb:typeof n.maxSize=="number"?Math.round(n.maxSize/(1024*1024)):null,maxFiles:typeof n.maxFiles=="number"?n.maxFiles:null,endpoint:n.endpoint||"",locale:n.locale||null,theme:n.theme||null}),c("FM_READY",e.payload);break;case"FM_SELECT":typeof n.onSelect=="function"&&n.onSelect(e.payload),c("FM_SELECT",e.payload),f.close();break;case"FM_TOKEN_REFRESH":if(h)break;h=!0,c("FM_TOKEN_REFRESH",e.payload),typeof n.onTokenRefresh=="function"?Promise.resolve().then(function(){return n.onTokenRefresh(e.payload)}).then(function(i){h=!1,i?(n.token=i,d("FM_TOKEN_UPDATED",{token:i})):d("FM_TOKEN_FAILED",{reason:"refresh_returned_null"})}).catch(function(i){h=!1,console.error("FluxFiles: onTokenRefresh failed",i),d("FM_TOKEN_FAILED",{reason:i.message||"refresh_error"})}):(h=!1,d("FM_TOKEN_FAILED",{reason:"no_handler"}));break;case"FM_EVENT":c("FM_EVENT",e.payload);break;case"FM_THEME":O(!!(e.payload&&e.payload.theme==="dark")),c("FM_THEME",e.payload);break;case"FM_CLOSE":typeof n.onClose=="function"&&n.onClose(),c("FM_CLOSE",e.payload);break}}}function c(t,e){for(var i=s[t]||[],l=0;l<i.length;l++)try{i[l](e)}catch(r){console.error("FluxFiles listener error:",r)}}function O(t){var e=document.getElementById("fluxfiles-modal");if(e){var i=t?"#2b2b2e":"#f5f5f7",l=t?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.06)";e.style.background=i;var r=e.firstElementChild;r&&(r.style.background=i,r.style.borderBottom="1px solid "+l)}}var f={open:function(t){n=t||{};var e=(n.endpoint||"").replace(/\/+$/,""),i=n.container?document.querySelector(n.container):document.body;try{var l=new URL(e+"/public/index.html");m=l.origin}catch{m=window.location.origin}if(this.close(),o=document.createElement("iframe"),o.id="fluxfiles-iframe",o.src=e+"/public/index.html",o.style.cssText="width:100%;height:100%;border:none;",o.setAttribute("allow",L),o.setAttribute("allowfullscreen","true"),n.container)i.appendChild(o);else{var r="fluxfiles_theme",x=null;try{x=window.localStorage&&localStorage.getItem(r)}catch{}try{(n.theme==="dark"||n.theme==="light")&&localStorage.setItem(r,n.theme)}catch{}var k=n.theme==="dark"||n.theme!=="light"&&(x==="dark"||x!=="light"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches),w=k?"#2b2b2e":"#f5f5f7",R=k?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.06)",u=document.createElement("div");u.id="fluxfiles-overlay",u.style.cssText="position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);z-index:99999;display:flex;align-items:center;justify-content:center;";var p=document.createElement("div");p.id="fluxfiles-modal",p.style.cssText="width:90vw;height:85vh;max-width:1200px;background:"+w+";border-radius:10px;overflow:hidden;box-shadow:0 25px 50px rgba(0,0,0,0.22);display:flex;flex-direction:column;";var v=document.createElement("div");v.style.cssText="flex-shrink:0;display:flex;align-items:center;justify-content:flex-start;padding:10px 12px;border-bottom:1px solid "+R+";background:"+w+";";var a=document.createElement("button");a.type="button",a.setAttribute("aria-label","Close"),a.style.cssText="width:13px;height:13px;padding:0;border:none;border-radius:50%;background:#ff5f57;box-shadow:inset 0 0 0 0.5px rgba(0,0,0,0.14);color:rgba(0,0,0,0);cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:11px;line-height:1;font-weight:700;transition:filter .15s,color .15s;flex-shrink:0;",a.textContent="\xD7";var F=function(){a.style.color="rgba(0,0,0,0.55)",a.style.filter="brightness(0.93)"},M=function(){a.style.color="rgba(0,0,0,0)",a.style.filter="none"};a.addEventListener("mouseenter",F),a.addEventListener("mouseleave",M),a.addEventListener("focus",F),a.addEventListener("blur",M),a.addEventListener("click",function(){f.close()}),v.appendChild(a),p.appendChild(v);var y=document.createElement("div");y.style.cssText="flex:1;min-height:0;display:flex;flex-direction:column;",y.appendChild(o),p.appendChild(y),u.appendChild(p),document.body.appendChild(u),u.addEventListener("click",function(g){g.target===u&&f.close()})}window.addEventListener("message",_)},close:function(){b=!1,window.removeEventListener("message",_);var t=document.getElementById("fluxfiles-overlay");t&&t.remove();var e=document.getElementById("fluxfiles-iframe");e&&e.remove(),o=null},command:function(t,e){d("FM_COMMAND",Object.assign({action:t},e||{}))},navigate:function(t){this.command("navigate",{path:t})},setDisk:function(t){this.command("setDisk",{disk:t})},refresh:function(){this.command("refresh")},search:function(t){this.command("search",{q:t})},crossCopy:function(t,e){this.command("crossCopy",{dst_disk:t,dst_path:e||""})},crossMove:function(t,e){this.command("crossMove",{dst_disk:t,dst_path:e||""})},aiTag:function(){this.command("aiTag")},setLocale:function(t){this.command("setLocale",{locale:t})},crop:function(t,e,i,l,r){this.command("crop",{x:t,y:e,width:i,height:l,save_path:r||""})},imgUrl:function(t,e){if(!t||!t.img_base)return"";e=e||{};var i=[];return e.width&&i.push("width="+encodeURIComponent(e.width)),e.quality&&i.push("quality="+encodeURIComponent(e.quality)),e.format&&i.push("format="+encodeURIComponent(e.format)),t.img_base+(i.length?"&"+i.join("&"):"")},updateToken:function(t){n.token=t,b&&o&&d("FM_TOKEN_UPDATED",{token:t})},on:function(t,e){return s[t]||(s[t]=[]),s[t].push(e),function(){f.off(t,e)}},off:function(t,e){s[t]&&(s[t]=s[t].filter(function(i){return i!==e}))}};typeof module<"u"&&module.exports?module.exports=f:typeof define=="function"&&define.amd?define(function(){return f}):T.FluxFiles=f})(typeof globalThis<"u"?globalThis:typeof window<"u"?window:this);
|
|
1
|
+
(function(T){"use strict";var C=1,E="fluxfiles",L="clipboard-write; fullscreen",o=null,s={},n={},b=!1,m="",h=!1;function S(){return"ff-"+Math.random().toString(36).substr(2,9)+Date.now().toString(36)}function d(t,e){!o||!o.contentWindow||o.contentWindow.postMessage({source:E,type:t,v:C,id:S(),payload:e||{}},m||"*")}function _(t){if(!(!o||!o.contentWindow||t.source!==o.contentWindow)&&!(m&&t.origin!==m)){var e=t.data;if(!(!e||e.source!==E))switch(e.type){case"FM_READY":b=!0,d("FM_CONFIG",{disk:n.disk||"local",disks:n.disks||["local"],token:n.token||"",path:n.path||"",mode:n.mode||"picker",multiple:!!n.multiple,allowedTypes:n.allowedTypes||null,maxUploadMb:typeof n.maxUploadMb=="number"?n.maxUploadMb:typeof n.maxSize=="number"?Math.round(n.maxSize/(1024*1024)):null,maxFiles:typeof n.maxFiles=="number"?n.maxFiles:null,endpoint:n.endpoint||"",locale:n.locale||null,theme:n.theme||null}),c("FM_READY",e.payload);break;case"FM_SELECT":typeof n.onSelect=="function"&&n.onSelect(e.payload),c("FM_SELECT",e.payload),n.container||f.close();break;case"FM_TOKEN_REFRESH":if(h)break;h=!0,c("FM_TOKEN_REFRESH",e.payload),typeof n.onTokenRefresh=="function"?Promise.resolve().then(function(){return n.onTokenRefresh(e.payload)}).then(function(i){h=!1,i?(n.token=i,d("FM_TOKEN_UPDATED",{token:i})):d("FM_TOKEN_FAILED",{reason:"refresh_returned_null"})}).catch(function(i){h=!1,console.error("FluxFiles: onTokenRefresh failed",i),d("FM_TOKEN_FAILED",{reason:i.message||"refresh_error"})}):(h=!1,d("FM_TOKEN_FAILED",{reason:"no_handler"}));break;case"FM_EVENT":c("FM_EVENT",e.payload);break;case"FM_THEME":O(!!(e.payload&&e.payload.theme==="dark")),c("FM_THEME",e.payload);break;case"FM_CLOSE":typeof n.onClose=="function"&&n.onClose(),c("FM_CLOSE",e.payload);break}}}function c(t,e){for(var i=s[t]||[],l=0;l<i.length;l++)try{i[l](e)}catch(r){console.error("FluxFiles listener error:",r)}}function O(t){var e=document.getElementById("fluxfiles-modal");if(e){var i=t?"#2b2b2e":"#f5f5f7",l=t?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.06)";e.style.background=i;var r=e.firstElementChild;r&&(r.style.background=i,r.style.borderBottom="1px solid "+l)}}var f={open:function(t){n=t||{};var e=(n.endpoint||"").replace(/\/+$/,""),i=n.container?document.querySelector(n.container):document.body;try{var l=new URL(e+"/public/index.html");m=l.origin}catch{m=window.location.origin}if(this.close(),o=document.createElement("iframe"),o.id="fluxfiles-iframe",o.src=e+"/public/index.html",o.style.cssText="width:100%;height:100%;border:none;",o.setAttribute("allow",L),o.setAttribute("allowfullscreen","true"),n.container)i.appendChild(o);else{var r="fluxfiles_theme",x=null;try{x=window.localStorage&&localStorage.getItem(r)}catch{}try{(n.theme==="dark"||n.theme==="light")&&localStorage.setItem(r,n.theme)}catch{}var k=n.theme==="dark"||n.theme!=="light"&&(x==="dark"||x!=="light"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches),w=k?"#2b2b2e":"#f5f5f7",R=k?"rgba(255,255,255,0.08)":"rgba(0,0,0,0.06)",u=document.createElement("div");u.id="fluxfiles-overlay",u.style.cssText="position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);z-index:99999;display:flex;align-items:center;justify-content:center;";var p=document.createElement("div");p.id="fluxfiles-modal",p.style.cssText="width:90vw;height:85vh;max-width:1200px;background:"+w+";border-radius:10px;overflow:hidden;box-shadow:0 25px 50px rgba(0,0,0,0.22);display:flex;flex-direction:column;";var v=document.createElement("div");v.style.cssText="flex-shrink:0;display:flex;align-items:center;justify-content:flex-start;padding:10px 12px;border-bottom:1px solid "+R+";background:"+w+";";var a=document.createElement("button");a.type="button",a.setAttribute("aria-label","Close"),a.style.cssText="width:13px;height:13px;padding:0;border:none;border-radius:50%;background:#ff5f57;box-shadow:inset 0 0 0 0.5px rgba(0,0,0,0.14);color:rgba(0,0,0,0);cursor:pointer;display:flex;align-items:center;justify-content:center;font-size:11px;line-height:1;font-weight:700;transition:filter .15s,color .15s;flex-shrink:0;",a.textContent="\xD7";var F=function(){a.style.color="rgba(0,0,0,0.55)",a.style.filter="brightness(0.93)"},M=function(){a.style.color="rgba(0,0,0,0)",a.style.filter="none"};a.addEventListener("mouseenter",F),a.addEventListener("mouseleave",M),a.addEventListener("focus",F),a.addEventListener("blur",M),a.addEventListener("click",function(){f.close()}),v.appendChild(a),p.appendChild(v);var y=document.createElement("div");y.style.cssText="flex:1;min-height:0;display:flex;flex-direction:column;",y.appendChild(o),p.appendChild(y),u.appendChild(p),document.body.appendChild(u),u.addEventListener("click",function(g){g.target===u&&f.close()})}window.addEventListener("message",_)},close:function(){b=!1,window.removeEventListener("message",_);var t=document.getElementById("fluxfiles-overlay");t&&t.remove();var e=document.getElementById("fluxfiles-iframe");e&&e.remove(),o=null},command:function(t,e){d("FM_COMMAND",Object.assign({action:t},e||{}))},navigate:function(t){this.command("navigate",{path:t})},setDisk:function(t){this.command("setDisk",{disk:t})},refresh:function(){this.command("refresh")},search:function(t){this.command("search",{q:t})},crossCopy:function(t,e){this.command("crossCopy",{dst_disk:t,dst_path:e||""})},crossMove:function(t,e){this.command("crossMove",{dst_disk:t,dst_path:e||""})},aiTag:function(){this.command("aiTag")},setLocale:function(t){this.command("setLocale",{locale:t})},crop:function(t,e,i,l,r){this.command("crop",{x:t,y:e,width:i,height:l,save_path:r||""})},imgUrl:function(t,e){if(!t||!t.img_base)return"";e=e||{};var i=[];return e.width&&i.push("width="+encodeURIComponent(e.width)),e.quality&&i.push("quality="+encodeURIComponent(e.quality)),e.format&&i.push("format="+encodeURIComponent(e.format)),t.img_base+(i.length?"&"+i.join("&"):"")},updateToken:function(t){n.token=t,b&&o&&d("FM_TOKEN_UPDATED",{token:t})},on:function(t,e){return s[t]||(s[t]=[]),s[t].push(e),function(){f.off(t,e)}},off:function(t,e){s[t]&&(s[t]=s[t].filter(function(i){return i!==e}))}};typeof module<"u"&&module.exports?module.exports=f:typeof define=="function"&&define.amd?define(function(){return f}):T.FluxFiles=f})(typeof globalThis<"u"?globalThis:typeof window<"u"?window:this);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fluxfiles",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "FluxFiles JavaScript SDK — embed the file manager in any web app",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "fluxfiles.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"LICENSE"
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "esbuild fluxfiles.js --minify --legal-comments=none --outfile=fluxfiles.min.js",
|
|
17
|
+
"build": "esbuild fluxfiles.js --minify --legal-comments=none --outfile=fluxfiles.min.js && cp fluxfiles.js fluxfiles.min.js ../core/",
|
|
18
18
|
"test": "vitest run"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|