@dropins/tools 1.5.0-beta1 → 1.5.0-beta2

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/lib/aem/assets.js CHANGED
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{getConfigValue as O}from"./configs.js";import{p as f,I as g}from"../../chunks/Image.js";import"../../chunks/get-path-value.js";import"../../chunks/cjs.js";import"../../preact-jsx-runtime.js";import"../../chunks/icons/Add.js";import"../../i18n.js";import"../../chunks/vcomponent.js";import"../../chunks/image-params-keymap.js";import"../../signals.js";const b=["gif","jpg","jpeg","png","webp"],v=[90,180,270],U=["h","v","hv"];function l(e){let t=e;if(t.startsWith("//")){const{protocol:s}=window.location;t=s+t}return t}function I(e){return U.includes(e)}function L(e){return v.includes(e)}function y(e){return b.includes(e)}function u(e,t,s){if(e!==void 0&&!t(e))throw new Error(s)}function h(){const e=O("commerce-assets-enabled");return e&&(typeof e=="string"&&e.toLowerCase()==="true"||typeof e=="boolean"&&e===!0)}function R(){return{quality:80,format:"webp"}}function A(e){return!!(typeof e=="string"?new URL(l(e)):e).pathname.startsWith("/adobe/assets/urn:aaid:aem")}function w(e,t,s={}){const r={...R(),...s},{format:i,crop:n,...o}=r;u(i,y,"Invalid format"),u(o.flip,I,"Invalid flip"),u(o.rotate,L,"Invalid rotation");const a=Object.fromEntries(Object.entries(o).map(([p,d])=>[p,String(d)])),c=new URLSearchParams(a);if(n){const[p,d]=[n.xOrigin||0,n.yOrigin||0],[P,E]=[n.width||100,n.height||100],S=`${p}p,${d}p,${P}p,${E}p`;c.set("crop",S)}return`${e}/as/${t}.${i}?${c.toString()}`}function q(e,t,s={}){if(!h())return e;const r=new URL(l(e));if(!A(r))return e;const i=r.origin+r.pathname;return w(i,t,s)}function _(e){return t=>{const{wrapper:s,alias:m,params:r,imageProps:i}=e;if(!i.src)throw new Error("An image source is required. Please provide a `src` or `imageProps.src`.");const n=s??document.createElement("div"),o=w(i.src,m,r),a={width:r.width,height:r.height,crop:void 0,fit:void 0,auto:void 0},c={...i,width:r.width,height:r.height,src:o,params:a};f.render(g,c)(n),t.replaceWith(n)}}function x(e,t){function s(){const i=t.wrapper??document.createElement("div"),{imageProps:n,params:o}=t,a={...n,width:o.width,height:o.height};f.render(g,a)(i),e.replaceWith(i)}if(!h()){s();return}if(!t.imageProps.src)throw new Error("An image source is required. Please provide a `src` or `imageProps.src`.");const r=new URL(l(t.imageProps.src));if(!A(r)){s();return}_(t)(e)}export{w as generateAemAssetsOptimizedUrl,R as getDefaultAemAssetsOptimizationParams,h as isAemAssetsEnabled,A as isAemAssetsUrl,_ as makeAemAssetsImageSlot,q as tryGenerateAemAssetsOptimizedUrl,x as tryRenderAemAssetsImage};
3
+ import{getConfigValue as O}from"./configs.js";import{p as f,I as g}from"../../chunks/Image.js";import"../../chunks/cjs.js";import"../../chunks/get-path-value.js";import"../../preact-jsx-runtime.js";import"../../chunks/icons/Add.js";import"../../i18n.js";import"../../chunks/vcomponent.js";import"../../chunks/image-params-keymap.js";import"../../signals.js";const b=["gif","jpg","jpeg","png","webp"],v=[90,180,270],U=["h","v","hv"];function l(e){let t=e;if(t.startsWith("//")){const{protocol:s}=window.location;t=s+t}return t}function I(e){return U.includes(e)}function L(e){return v.includes(e)}function y(e){return b.includes(e)}function u(e,t,s){if(e!==void 0&&!t(e))throw new Error(s)}function h(){const e=O("commerce-assets-enabled");return e&&(typeof e=="string"&&e.toLowerCase()==="true"||typeof e=="boolean"&&e===!0)}function R(){return{quality:80,format:"webp"}}function A(e){return!!(typeof e=="string"?new URL(l(e)):e).pathname.startsWith("/adobe/assets/urn:aaid:aem")}function w(e,t,s={}){const r={...R(),...s},{format:i,crop:n,...o}=r;u(i,y,"Invalid format"),u(o.flip,I,"Invalid flip"),u(o.rotate,L,"Invalid rotation");const a=Object.fromEntries(Object.entries(o).map(([p,d])=>[p,String(d)])),c=new URLSearchParams(a);if(n){const[p,d]=[n.xOrigin||0,n.yOrigin||0],[P,E]=[n.width||100,n.height||100],S=`${p}p,${d}p,${P}p,${E}p`;c.set("crop",S)}return`${e}/as/${t}.${i}?${c.toString()}`}function q(e,t,s={}){if(!h())return e;const r=new URL(l(e));if(!A(r))return e;const i=r.origin+r.pathname;return w(i,t,s)}function _(e){return t=>{const{wrapper:s,alias:m,params:r,imageProps:i}=e;if(!i.src)throw new Error("An image source is required. Please provide a `src` or `imageProps.src`.");const n=s??document.createElement("div"),o=w(i.src,m,r),a={width:r.width,height:r.height,crop:void 0,fit:void 0,auto:void 0},c={...i,width:r.width,height:r.height,src:o,params:a};f.render(g,c)(n),t.replaceWith(n)}}function x(e,t){function s(){const i=t.wrapper??document.createElement("div"),{imageProps:n,params:o}=t,a={...n,width:o.width,height:o.height};f.render(g,a)(i),e.replaceWith(i)}if(!h()){s();return}if(!t.imageProps.src)throw new Error("An image source is required. Please provide a `src` or `imageProps.src`.");const r=new URL(l(t.imageProps.src));if(!A(r)){s();return}_(t)(e)}export{w as generateAemAssetsOptimizedUrl,R as getDefaultAemAssetsOptimizationParams,h as isAemAssetsEnabled,A as isAemAssetsUrl,_ as makeAemAssetsImageSlot,q as tryGenerateAemAssetsOptimizedUrl,x as tryRenderAemAssetsImage};
4
4
  //# sourceMappingURL=assets.js.map
@@ -1,4 +1,4 @@
1
1
  /*! Copyright 2025 Adobe
2
2
  All Rights Reserved. */
3
- import{g as u}from"../../chunks/get-path-value.js";import{d as f}from"../../chunks/cjs.js";let e=null,r=null,l=null;function C(){e=null,r=null,l=null}function s(t=e){return t?Object.keys(t==null?void 0:t.public).sort((i,o)=>{const a=i.split("/").filter(Boolean).length;return o.split("/").filter(Boolean).length-a}).find(i=>window.location.pathname===i||window.location.pathname.startsWith(i))??"/":(console.warn("No config found. Please call initializeConfig() first."),"/")}function c(){return e?Object.keys(e.public).filter(t=>t!=="default"):(console.warn("No config found. Please call initializeConfig() first."),[])}function m(){return c().length>=1}function w(t){if(!l)throw new Error("Configuration not initialized. Call initializeConfig() first.");const n=l.headers??{};return{...n.all??{},...n[t]??{}}}function g(t,n){var o;const i=(o=t.public)==null?void 0:o.default;return n==="/"||!t.public[n]?i:f(i,t.public[n])}function z(t){return e=t,r=s(e),l=g(e,r),l}function P(t){if(!l)throw new Error("Configuration not initialized. Call initializeConfig() first.");return u(l,t)}export{P as getConfigValue,w as getHeaders,c as getListOfRootPaths,s as getRootPath,z as initializeConfig,m as isMultistore,C as resetConfig};
3
+ import{d as u}from"../../chunks/cjs.js";import{g as f}from"../../chunks/get-path-value.js";let e=null,r=null,l=null;function C(){e=null,r=null,l=null}function s(t=e){return t?Object.keys(t==null?void 0:t.public).sort((i,o)=>{const a=i.split("/").filter(Boolean).length;return o.split("/").filter(Boolean).length-a}).find(i=>window.location.pathname===i||window.location.pathname.startsWith(i))??"/":(console.warn("No config found. Please call initializeConfig() first."),"/")}function c(){return e?Object.keys(e.public).filter(t=>t!=="default"):(console.warn("No config found. Please call initializeConfig() first."),[])}function m(){return c().length>=1}function w(t){if(!l)throw new Error("Configuration not initialized. Call initializeConfig() first.");const n=l.headers??{};return{...n.all??{},...n[t]??{}}}function g(t,n){var o;const i=(o=t.public)==null?void 0:o.default;return n==="/"||!t.public[n]?i:u(i,t.public[n])}function z(t){return e=t,r=s(e),l=g(e,r),l}function P(t){if(!l)throw new Error("Configuration not initialized. Call initializeConfig() first.");return f(l,t)}export{P as getConfigValue,w as getHeaders,c as getListOfRootPaths,s as getRootPath,z as initializeConfig,m as isMultistore,C as resetConfig};
4
4
  //# sourceMappingURL=configs.js.map
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name": "@dropins/tools", "version": "1.5.0-beta1", "license": "SEE LICENSE IN LICENSE.md"}
1
+ {"name": "@dropins/tools", "version": "1.5.0-beta2", "license": "SEE LICENSE IN LICENSE.md"}
@@ -24,10 +24,15 @@ export declare class Render {
24
24
  * @returns A function to render the component to a root element.
25
25
  */
26
26
  render<T>(Component: Container<T>, props: T): (rootElement: HTMLElement) => Promise<RenderAPI>;
27
+ /**
28
+ * Unmounts a container from a root element.
29
+ * @param rootElement - The root element to unmount the container from.
30
+ */
31
+ static unmount(rootElement: HTMLElement): void;
27
32
  /**
28
33
  * UnRenders a component from a root element.
29
34
  * @param rootElement - The root element to unmount the component from.
30
- * @deprecated Use `remove` method from the returned object of the `mount` method instead.
35
+ * @deprecated Use `remove` method from the returned object of the `mount` method instead or `unmount` method from the `Render` class.
31
36
  */
32
37
  unmount(rootElement: HTMLElement): void;
33
38
  /**