@cesdk/cesdk-js 1.69.0-rc.3 → 1.69.0-rc.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cesdk/cesdk-js",
3
- "version": "1.69.0-rc.3",
3
+ "version": "1.69.0-rc.4",
4
4
  "module": "./index.js",
5
5
  "type": "module",
6
6
  "types": "./index.d.ts",
@@ -40,7 +40,7 @@
40
40
  "license": "SEE LICENSE IN LICENSE.md",
41
41
  "readme": "README.md",
42
42
  "dependencies": {
43
- "@cesdk/engine": "1.69.0-rc.3"
43
+ "@cesdk/engine": "1.69.0-rc.4"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@angular/common": ">=14.0.0",
package/plugins/index.js CHANGED
@@ -1 +1 @@
1
- import CreativeEditorSDK from"@cesdk/cesdk-js";var e=class{constructor(e={}){this.config=e}name="cesdk-blur-asset-source";version=CreativeEditorSDK.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.blur":["ly.img.blur"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.blur";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import s from"@cesdk/cesdk-js";var t="ly.img.caption.presets",o=["backgroundColor/enabled","backgroundColor/color","backgroundColor/cornerRadius","backgroundColor/paddingBottom","backgroundColor/paddingLeft","backgroundColor/paddingRight","backgroundColor/paddingTop","blend/mode","dropShadow/enabled","dropShadow/color","dropShadow/offset/x","dropShadow/offset/y","dropShadow/blurRadius/x","dropShadow/blurRadius/y","dropShadow/clip","fill/enabled","fill/solid/color","opacity","stroke/enabled","stroke/color","stroke/width","stroke/style","stroke/position","stroke/cornerGeometry","{{blockType}}/typeface","{{blockType}}/fontSize","{{blockType}}/horizontalAlignment","{{blockType}}/verticalAlignment","{{blockType}}/letterSpacing","{{blockType}}/lineHeight","{{blockType}}/automaticFontSizeEnabled","{{blockType}}/maxAutomaticFontSize","{{blockType}}/minAutomaticFontSize","{{blockType}}/paragraphSpacing"];function i(e){const s=e.scene.getCurrentPage();if(null!=s)return e.block.getChildren(s).find((s=>"//ly.img.ubq/captionTrack"===e.block.getType(s)))}function r(e){const s=i(e);if(null==s)return 1;try{const t=e.block.getMetadata(s,"previousScale"),o=parseFloat(t);return Number.isNaN(o)?1:o}catch(e){return 1}}function n(e,s,t){const o=r(e),n=e.block.getTextFontSizes(s)[0]/o,a=Math.round(n*t);if(e.block.setTextFontSize(s,a),e.block.isStrokeEnabled(s)){const i=e.block.getStrokeWidth(s)/o*t;e.block.setStrokeWidth(s,i)}if(e.block.isDropShadowEnabled(s)){const i=e.block.getDropShadowOffsetX(s)/o,r=e.block.getDropShadowOffsetY(s)/o,n=e.block.getDropShadowBlurRadiusX(s)/o,a=e.block.getDropShadowBlurRadiusY(s)/o;e.block.setDropShadowOffsetX(s,i*t),e.block.setDropShadowOffsetY(s,r*t),e.block.setDropShadowBlurRadiusX(s,n*t),e.block.setDropShadowBlurRadiusY(s,a*t)}!function(e,s){const t=i(e);null!=t&&e.block.setMetadata(t,"previousScale",s.toString())}(e,t)}var a=class{engine;assets=[];customFetchImpl;baseURL;constructor(e,s,t){this.engine=e,this.baseURL=s,this.customFetchImpl=t??window.fetch.bind(window)}async initialize(){await this.fetchAssets(),this.createSource()}async fetchAssets(){const e=function(...e){return e.map(((e,s)=>0===s?e.replace(/\/$/,""):e.replace(/^\//,"").replace(/\/$/,""))).join("/")}(this.baseURL,`/${t}/content.json`);try{const s=await this.customFetchImpl(e);if(!s.ok)throw new Error(s.statusText);const o=await s.json();if(void 0===o.assets)throw new Error(`Invalid content.json for assets: ${t}`);this.assets=o.assets.map((e=>(e.meta&&Object.entries(e.meta).forEach((([s,t])=>{const o=t.toString();if(o.includes("{{base_url}}")){const t=o.replace("{{base_url}}",this.baseURL);e.meta&&(e.meta[s]=t)}})),e)))}catch(e){console.warn("Could not load caption presets:",e),this.assets=[]}}createSource(){if(new Set(this.engine.asset.findAllSources()).has(t))return;const e={id:t,findAssets:e=>{const{page:s,perPage:o,excludeGroups:n,groups:a,locale:c="en",query:d,sortActiveFirst:l,sortKey:u,sortingOrder:g,tags:h}=e,p=i(this.engine),f=null!=p&&this.engine.block.hasMetadata(p,"activePreset")?this.engine.block.getMetadata(p,"activePreset"):void 0;let y=[...this.assets];if(a&&a.length>0&&(y=y.filter((e=>e.groups?.some((e=>a.includes(e)))))),d&&""!==d.trim()){const e=d.toLowerCase().trim();y=y.filter((s=>(s.label?.[c]?.toLowerCase()||"").includes(e)))}h&&h.length>0&&(y=y.filter((e=>(e.tags?.[c]??[]).some((e=>h.includes(e)))))),n&&n.length>0&&(y=y.filter((e=>!(e.groups??[]).some((e=>n.includes(e)))))),"label"===u&&"None"!==g&&y.sort(((e,s)=>{const t=e.label?.[c]?.toLocaleLowerCase()||"",o=s.label?.[c]?.toLocaleLowerCase()||"";return t<o?"Ascending"===g?-1:1:t>o?"Ascending"===g?1:-1:0})),l&&f&&y.sort(((e,s)=>e.id===f?-1:s.id===f?1:0));const b=y.length,m=s*o,S=m+o,k=y.slice(m,S).map((e=>{const s=e.payload?.properties?.map((e=>"caption/scale"===e.property?{...e,value:r(this.engine)}:e));return{id:e.id,label:e.label?.[c],active:e.id===f,context:{id:t},meta:e.meta,groups:e.groups,tags:e.tags?.[c],payload:{...e.payload,properties:s},locale:c}}));return Promise.resolve({assets:k,total:b,currentPage:s})},getGroups:()=>{const e=new Set;return this.assets.forEach((s=>{s.groups&&s.groups.forEach((s=>{e.add(s)}))})),Promise.resolve(Array.from(e))},removeAsset:e=>{const s=this.assets.findIndex((s=>s.id===e));-1!==s&&this.assets.splice(s,1)},addAsset:e=>{const s=this.assets.findIndex((s=>s.id===e.id));-1!==s?this.assets[s]=e:this.assets.push(e)},applyAssetToBlock:(e,s)=>this.applyPreset(e,s),applyAssetProperty:(e,s)=>this.applyProperty(e,s),fetchAsset:async(e,s)=>new Promise((t=>{const o=this.assets.find((s=>s.id===e));if(null==o)t(null);else{const e=s?.locale??"en",n=i(this.engine),a=null!=n&&this.engine.block.hasMetadata(n,"activePreset")?this.engine.block.getMetadata(n,"activePreset"):void 0,c=o.payload?.properties?.map((e=>"caption/scale"===e.property?{...e,value:r(this.engine)}:e));t({id:o.id,label:o.label?.[e],active:o.id===a,meta:o.meta,groups:o.groups,tags:o.tags?.[e],payload:{...o.payload,properties:c}})}}))};this.engine.asset.addSource(e)}async applyPreset(e,s){const r=e?.meta?.uri;if(null==r)throw new Error(`The asset ${e.id} does not have a preset block URL.`);const n=await this.customFetchImpl(r);if(!n.ok)throw new Error(`Failed to fetch the preset block from ${r}`);const a=await n.text(),[c]=await this.engine.block.loadFromString(a),d=null!=c?this.engine.block.getType(c):void 0;if("//ly.img.ubq/text"!==d&&"//ly.img.ubq/caption"!==d)return;const l=i(this.engine),u=null!=l?this.engine.block.getChildren(l):[];o.forEach((e=>{const t=e.replace("{{blockType}}","//ly.img.ubq/text"===d?"text":"caption"),o=this.engine.block.getPropertyType(t),i=e.replace("{{blockType}}","caption");switch(o){case"Int":{const e=this.engine.block.getInt(c,t);this.engine.block.setInt(s,i,e);break}case"Float":{const e=this.engine.block.getFloat(c,t);this.engine.block.setFloat(s,i,e);break}case"Double":{const e=this.engine.block.getDouble(c,t);this.engine.block.setDouble(s,i,e);break}case"Bool":{const e=this.engine.block.getBool(c,t);this.engine.block.setBool(s,i,e);break}case"Enum":{if("stroke/position"===t)break;const e=this.engine.block.getEnum(c,t);this.engine.block.setEnum(s,i,e);break}case"Color":{if("fill/solid/color"===t){const[e]=this.engine.block.getTextColors(c);this.engine.block.setColor(s,i,e),"Text"===this.engine.editor.getEditMode()&&this.engine.editor.setEditMode("Transform"),this.engine.block.setTextColor(s,e);break}const e=this.engine.block.getColor(c,t);this.engine.block.setColor(s,i,e);break}case"String":{if("text/typeface"===t||"caption/typeface"===t){const e=this.engine.block.getTypeface(c);this.engine.block.setTypeface(s,e);break}const e=this.engine.block.getString(c,t);this.engine.block.setString(s,i,e);break}}})),e.payload?.properties?.forEach((async s=>{"Color"===s.type&&await this.applyProperty(e,s)}));const[g]=this.engine.block.getTextFontWeights(c);null!=g&&this.engine.block.setTextFontWeight(s,g);const[h]=this.engine.block.getTextFontStyles(c);null!=h&&this.engine.block.setTextFontStyle(s,h),function(e,s,t){const o={in:e.block.getInAnimation(s),loop:e.block.getLoopAnimation(s),out:e.block.getOutAnimation(s)},i=(s,t)=>{const i=o[t],r=(()=>{switch(t){case"in":return e.block.getInAnimation(s);case"loop":return e.block.getLoopAnimation(s);case"out":return e.block.getOutAnimation(s);default:return}})();if(null!=r&&e.block.isValid(r)&&e.block.destroy(r),e.block.isValid(i)){const o=e.block.duplicate(i);switch(t){case"in":e.block.setInAnimation(s,o);break;case"loop":e.block.setLoopAnimation(s,o);break;case"out":e.block.setOutAnimation(s,o)}}};t.forEach((e=>{i(e,"in"),i(e,"loop"),i(e,"out")}))}(this.engine,c,u),null!=l&&this.engine.block.setMetadata(l,"activePreset",e.id),this.engine.block.destroy(c),this.engine.editor.addUndoStep(),this.engine.asset.assetSourceContentsChanged(t)}async applyProperty(e,s){const o=i(this.engine);if(null==o)return;const[r]=this.engine.block.findAllSelected(),a="//ly.img.ubq/caption"===(null!=r?this.engine.block.getType(r):void 0)?r:this.engine.block.getChildren(o)[0];if(null!=a){switch(s.type){case"Color":if("fill/solid/color"===s.property){this.engine.block.setColor(a,s.property,s.value),this.engine.block.setTextColor(a,s.value);break}this.engine.block.setColor(a,s.property,s.value);break;case"Int":this.engine.block.setInt(a,s.property,s.value);break;case"Float":if("caption/scale"===s.property){n(this.engine,a,s.value);break}this.engine.block.setFloat(a,s.property,s.value);break;case"Double":this.engine.block.setDouble(a,s.property,s.value);break;case"Boolean":this.engine.block.setBool(a,s.property,s.value);break;case"Enum":this.engine.block.setEnum(a,s.property,s.value);break;case"String":this.engine.block.setString(a,s.property,s.value)}this.assets=function(e,s,t){return e.map((e=>{if("caption/scale"===t.property){const s=e.payload?.properties?.map((e=>"caption/scale"===e.property?{...e,value:t.value}:e));return{...e,payload:{...e.payload,properties:s}}}if(e.id===s.id){const s=e.payload?.properties?.map((e=>e.property===t.property?{...e,value:t.value}:e));return{...e,payload:{...e.payload,properties:s}}}return e}))}(this.assets,e,s),this.engine.asset.assetSourceContentsChanged(t)}}},c=class{constructor(e={}){this.config=e}name="cesdk-caption-presets-asset-source";version=s.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.caption.presets":["ly.img.library.captionPresets"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new a(e,o,this.config.customFetchImpl);await i.initialize();const r="ly.img.caption.presets";if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}},d=class{constructor(e={}){this.config=e}name="cesdk-color-palette-asset-source";version="1.61";addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.color.palette":["ly.img.colors"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.color.palette";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import l from"@cesdk/cesdk-js";var u=class{constructor(e={}){this.config=e}name="cesdk-crop-presets-asset-source";version=l.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.crop.presets":["ly.img.cropPresets"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.crop.presets";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import g from"@cesdk/cesdk-js";var h=class{constructor(e={}){this.config=e}name="cesdk-demo-asset-sources";version=g.version;addedAssetSourceIds=[];globToRegex(e){const s=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp(`^${s}$`,"i")}sourceMatchesAnyPattern(e,s){return s.some((s=>{if(s===e||s.startsWith(`${e}.`))return!0;return this.globToRegex(s).test(e)}))}filterAssetSources(e,s){return e.filter((e=>this.sourceMatchesAnyPattern(e,s)))}filterMatchersForSource(e,s){return s.filter((s=>{if(s===e||s.startsWith(`${e}.`))return!0;return this.globToRegex(s).test(e)}))}getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.image":["ly.img.image"],"ly.img.video":["ly.img.video"],"ly.img.audio":["ly.img.audio"],"ly.img.templates":["ly.img.templates"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r=["ly.img.audio","ly.img.video","ly.img.image","ly.img.templates"],n=this.config.include?this.filterAssetSources(r,this.config.include):r;for(const s of n)if(!i.has(s)){const t=`${o}${s}/content.json`,i=this.config.include?this.filterMatchersForSource(s,this.config.include):void 0;await e.asset.addLocalAssetSourceFromJSONURI(t,{matcher:i}),this.addedAssetSourceIds.push(s)}if(s){s.onReset((()=>this.cleanup({engine:e})));for(const e of this.addedAssetSourceIds){const t=this.getAssetLibraryEntries(e);for(const o of t)s.ui.updateAssetLibraryEntry(o,{sourceIds:({currentIds:s})=>[...new Set([...s,e])]})}}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import p from"@cesdk/cesdk-js";var f=class{constructor(e={}){this.config=e}name="cesdk-effects-asset-source";version=p.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.effect":["ly.img.effect"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.effect";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import y from"@cesdk/cesdk-js";var b=class{constructor(e={}){this.config=e}name="cesdk-filters-asset-source";version=y.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.filter":["ly.img.filter"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.filter";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import m from"@cesdk/cesdk-js";var S=class{constructor(e={}){this.config=e}name="cesdk-page-presets-asset-source";version=m.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.page.presets":["ly.img.pagePresets"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.page.presets";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import k from"@cesdk/cesdk-js";var A=class{constructor(e={}){this.config=e}name="cesdk-sticker-asset-source";version=k.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.sticker":["ly.img.sticker"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.sticker";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import w from"@cesdk/cesdk-js";var L=class{constructor(e={}){this.config=e}name="cesdk-text-asset-source";version=w.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.text":["ly.img.text"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.text";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import v from"@cesdk/cesdk-js";var I=class{constructor(e={}){this.config=e}name="cesdk-text-component-asset-source";version=v.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.text.components":["ly.img.text"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.text.components";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import E from"@cesdk/cesdk-js";var R=class{constructor(e={}){this.config=e}name="cesdk-typeface-asset-source";version=E.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.typeface":["ly.img.typefaces"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.typeface";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import U from"@cesdk/cesdk-js";var $=[{id:"ly.img.image.upload",mimeTypes:["image/jpeg","image/png","image/webp","image/svg+xml","image/bmp","image/gif"],assetLibraryEntries:["ly.img.image","ly.img.upload"]},{id:"ly.img.video.upload",mimeTypes:["application/json","video/mp4","video/quicktime","video/webm","video/matroska","image/gif"],assetLibraryEntries:["ly.img.video","ly.img.upload"]},{id:"ly.img.audio.upload",mimeTypes:["audio/mpeg","audio/mp3","audio/x-m4a","audio/wav"],assetLibraryEntries:["ly.img.audio","ly.img.upload"]}],C=class{constructor(e={}){this.config=e}name="cesdk-upload-asset-sources";version=U.version;addedAssetSourceIds=[];isExplicitMode(){return this.config.include?.some((e=>"string"==typeof e))??!1}getExplicitIncludes(){return this.config.include?new Set(this.config.include.filter((e=>"string"==typeof e))):new Set}getCustomizations(){return this.config.include?this.config.include.filter((e=>"object"==typeof e)):[]}getAssetLibraryEntries(e){return e?Array.isArray(e)?e:[e]:[]}async initialize({engine:e,cesdk:s}){const t=new Set(e.asset.findAllSources()),o=this.isExplicitMode(),i=this.getExplicitIncludes(),r=this.getCustomizations(),n=new Map;if(o)for(const e of $)i.has(e.id)&&n.set(e.id,e);else for(const e of $)n.set(e.id,e);for(const e of r){const s=n.get(e.id);s?n.set(e.id,{...s,...e}):n.set(e.id,e)}const a=Array.from(n.values());for(const o of a){const{id:i,mimeTypes:r,assetLibraryEntries:n}=o;if(!t.has(i)&&(e.asset.addLocalSource(i,r),this.addedAssetSourceIds.push(i),s)){const e=this.getAssetLibraryEntries(n);for(const t of e)s.ui.updateAssetLibraryEntry(t,{sourceIds:({currentIds:e})=>[...new Set([...e,i])]})}}s&&s.onReset((()=>this.cleanup({engine:e})))}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import x from"@cesdk/cesdk-js";var T=class{constructor(e={}){this.config=e}name="cesdk-vectorshape-asset-source";version=x.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.vector.shape":["ly.img.vector.shape"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.vector.shape";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};export{e as BlurAssetSource,c as CaptionPresetsAssetSource,d as ColorPaletteAssetSource,u as CropPresetsAssetSource,h as DemoAssetSources,f as EffectsAssetSource,b as FiltersAssetSource,S as PagePresetsAssetSource,A as StickerAssetSource,L as TextAssetSource,I as TextComponentAssetSource,R as TypefaceAssetSource,C as UploadAssetSources,T as VectorShapeAssetSource};
1
+ import CreativeEditorSDK from"@cesdk/cesdk-js";var e=class{constructor(e={}){this.config=e}name="cesdk-blur-asset-source";version=CreativeEditorSDK.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.blur":["ly.img.blur"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.blur";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import s from"@cesdk/cesdk-js";var t="ly.img.caption.presets",o=["backgroundColor/enabled","backgroundColor/color","backgroundColor/cornerRadius","backgroundColor/paddingBottom","backgroundColor/paddingLeft","backgroundColor/paddingRight","backgroundColor/paddingTop","blend/mode","dropShadow/enabled","dropShadow/color","dropShadow/offset/x","dropShadow/offset/y","dropShadow/blurRadius/x","dropShadow/blurRadius/y","dropShadow/clip","fill/enabled","fill/solid/color","opacity","stroke/enabled","stroke/color","stroke/width","stroke/style","stroke/position","stroke/cornerGeometry","{{blockType}}/typeface","{{blockType}}/fontSize","{{blockType}}/horizontalAlignment","{{blockType}}/verticalAlignment","{{blockType}}/letterSpacing","{{blockType}}/lineHeight","{{blockType}}/automaticFontSizeEnabled","{{blockType}}/maxAutomaticFontSize","{{blockType}}/minAutomaticFontSize","{{blockType}}/paragraphSpacing"];function i(e){const s=e.scene.getCurrentPage();if(null!=s)return e.block.getChildren(s).find((s=>"//ly.img.ubq/captionTrack"===e.block.getType(s)))}function r(e){const s=i(e);if(null==s)return 1;try{const t=e.block.getMetadata(s,"previousScale"),o=parseFloat(t);return Number.isNaN(o)?1:o}catch(e){return 1}}function n(e,s,t){const o=r(e),n=e.block.getTextFontSizes(s)[0]/o,a=Math.round(n*t);if(e.block.setTextFontSize(s,a),e.block.isStrokeEnabled(s)){const i=e.block.getStrokeWidth(s)/o*t;e.block.setStrokeWidth(s,i)}if(e.block.isDropShadowEnabled(s)){const i=e.block.getDropShadowOffsetX(s)/o,r=e.block.getDropShadowOffsetY(s)/o,n=e.block.getDropShadowBlurRadiusX(s)/o,a=e.block.getDropShadowBlurRadiusY(s)/o;e.block.setDropShadowOffsetX(s,i*t),e.block.setDropShadowOffsetY(s,r*t),e.block.setDropShadowBlurRadiusX(s,n*t),e.block.setDropShadowBlurRadiusY(s,a*t)}!function(e,s){const t=i(e);null!=t&&e.block.setMetadata(t,"previousScale",s.toString())}(e,t)}var a=class{engine;assets=[];customFetchImpl;baseURL;constructor(e,s,t){this.engine=e,this.baseURL=s,this.customFetchImpl=t??window.fetch.bind(window)}async initialize(){await this.fetchAssets(),this.createSource()}async fetchAssets(){const e=function(...e){return e.map(((e,s)=>0===s?e.replace(/\/$/,""):e.replace(/^\//,"").replace(/\/$/,""))).join("/")}(this.baseURL,`/${t}/content.json`);try{const s=await this.customFetchImpl(e);if(!s.ok)throw new Error(s.statusText);const o=await s.json();if(void 0===o.assets)throw new Error(`Invalid content.json for assets: ${t}`);this.assets=o.assets.map((e=>(e.meta&&Object.entries(e.meta).forEach((([s,t])=>{const o=t.toString();if(o.includes("{{base_url}}")){const t=o.replace("{{base_url}}",this.baseURL).replace(/([^:])\/\/+/g,"$1/");e.meta&&(e.meta[s]=t)}})),e)))}catch(e){console.warn("Could not load caption presets:",e),this.assets=[]}}createSource(){if(new Set(this.engine.asset.findAllSources()).has(t))return;const e={id:t,findAssets:e=>{const{page:s,perPage:o,excludeGroups:n,groups:a,locale:c="en",query:d,sortActiveFirst:l,sortKey:u,sortingOrder:g,tags:h}=e,p=i(this.engine),f=null!=p&&this.engine.block.hasMetadata(p,"activePreset")?this.engine.block.getMetadata(p,"activePreset"):void 0;let y=[...this.assets];if(a&&a.length>0&&(y=y.filter((e=>e.groups?.some((e=>a.includes(e)))))),d&&""!==d.trim()){const e=d.toLowerCase().trim();y=y.filter((s=>(s.label?.[c]?.toLowerCase()||"").includes(e)))}h&&h.length>0&&(y=y.filter((e=>(e.tags?.[c]??[]).some((e=>h.includes(e)))))),n&&n.length>0&&(y=y.filter((e=>!(e.groups??[]).some((e=>n.includes(e)))))),"label"===u&&"None"!==g&&y.sort(((e,s)=>{const t=e.label?.[c]?.toLocaleLowerCase()||"",o=s.label?.[c]?.toLocaleLowerCase()||"";return t<o?"Ascending"===g?-1:1:t>o?"Ascending"===g?1:-1:0})),l&&f&&y.sort(((e,s)=>e.id===f?-1:s.id===f?1:0));const b=y.length,m=s*o,S=m+o,k=y.slice(m,S).map((e=>{const s=e.payload?.properties?.map((e=>"caption/scale"===e.property?{...e,value:r(this.engine)}:e));return{id:e.id,label:e.label?.[c],active:e.id===f,context:{id:t},meta:e.meta,groups:e.groups,tags:e.tags?.[c],payload:{...e.payload,properties:s},locale:c}}));return Promise.resolve({assets:k,total:b,currentPage:s})},getGroups:()=>{const e=new Set;return this.assets.forEach((s=>{s.groups&&s.groups.forEach((s=>{e.add(s)}))})),Promise.resolve(Array.from(e))},removeAsset:e=>{const s=this.assets.findIndex((s=>s.id===e));-1!==s&&this.assets.splice(s,1)},addAsset:e=>{const s=this.assets.findIndex((s=>s.id===e.id));-1!==s?this.assets[s]=e:this.assets.push(e)},applyAssetToBlock:(e,s)=>this.applyPreset(e,s),applyAssetProperty:(e,s)=>this.applyProperty(e,s),fetchAsset:async(e,s)=>new Promise((t=>{const o=this.assets.find((s=>s.id===e));if(null==o)t(null);else{const e=s?.locale??"en",n=i(this.engine),a=null!=n&&this.engine.block.hasMetadata(n,"activePreset")?this.engine.block.getMetadata(n,"activePreset"):void 0,c=o.payload?.properties?.map((e=>"caption/scale"===e.property?{...e,value:r(this.engine)}:e));t({id:o.id,label:o.label?.[e],active:o.id===a,meta:o.meta,groups:o.groups,tags:o.tags?.[e],payload:{...o.payload,properties:c}})}}))};this.engine.asset.addSource(e)}async applyPreset(e,s){const r=e?.meta?.uri;if(null==r)throw new Error(`The asset ${e.id} does not have a preset block URL.`);const n=await this.customFetchImpl(r);if(!n.ok)throw new Error(`Failed to fetch the preset block from ${r}`);const a=await n.text(),[c]=await this.engine.block.loadFromString(a),d=null!=c?this.engine.block.getType(c):void 0;if("//ly.img.ubq/text"!==d&&"//ly.img.ubq/caption"!==d)return;const l=i(this.engine),u=null!=l?this.engine.block.getChildren(l):[];o.forEach((e=>{const t=e.replace("{{blockType}}","//ly.img.ubq/text"===d?"text":"caption"),o=this.engine.block.getPropertyType(t),i=e.replace("{{blockType}}","caption");switch(o){case"Int":{const e=this.engine.block.getInt(c,t);this.engine.block.setInt(s,i,e);break}case"Float":{const e=this.engine.block.getFloat(c,t);this.engine.block.setFloat(s,i,e);break}case"Double":{const e=this.engine.block.getDouble(c,t);this.engine.block.setDouble(s,i,e);break}case"Bool":{const e=this.engine.block.getBool(c,t);this.engine.block.setBool(s,i,e);break}case"Enum":{if("stroke/position"===t)break;const e=this.engine.block.getEnum(c,t);this.engine.block.setEnum(s,i,e);break}case"Color":{if("fill/solid/color"===t){const[e]=this.engine.block.getTextColors(c);this.engine.block.setColor(s,i,e),"Text"===this.engine.editor.getEditMode()&&this.engine.editor.setEditMode("Transform"),this.engine.block.setTextColor(s,e);break}const e=this.engine.block.getColor(c,t);this.engine.block.setColor(s,i,e);break}case"String":{if("text/typeface"===t||"caption/typeface"===t){const e=this.engine.block.getTypeface(c);this.engine.block.setTypeface(s,e);break}const e=this.engine.block.getString(c,t);this.engine.block.setString(s,i,e);break}}})),e.payload?.properties?.forEach((async s=>{"Color"===s.type&&await this.applyProperty(e,s)}));const[g]=this.engine.block.getTextFontWeights(c);null!=g&&this.engine.block.setTextFontWeight(s,g);const[h]=this.engine.block.getTextFontStyles(c);null!=h&&this.engine.block.setTextFontStyle(s,h),function(e,s,t){const o={in:e.block.getInAnimation(s),loop:e.block.getLoopAnimation(s),out:e.block.getOutAnimation(s)},i=(s,t)=>{const i=o[t],r=(()=>{switch(t){case"in":return e.block.getInAnimation(s);case"loop":return e.block.getLoopAnimation(s);case"out":return e.block.getOutAnimation(s);default:return}})();if(null!=r&&e.block.isValid(r)&&e.block.destroy(r),e.block.isValid(i)){const o=e.block.duplicate(i);switch(t){case"in":e.block.setInAnimation(s,o);break;case"loop":e.block.setLoopAnimation(s,o);break;case"out":e.block.setOutAnimation(s,o)}}};t.forEach((e=>{i(e,"in"),i(e,"loop"),i(e,"out")}))}(this.engine,c,u),null!=l&&this.engine.block.setMetadata(l,"activePreset",e.id),this.engine.block.destroy(c),this.engine.editor.addUndoStep(),this.engine.asset.assetSourceContentsChanged(t)}async applyProperty(e,s){const o=i(this.engine);if(null==o)return;const[r]=this.engine.block.findAllSelected(),a="//ly.img.ubq/caption"===(null!=r?this.engine.block.getType(r):void 0)?r:this.engine.block.getChildren(o)[0];if(null!=a){switch(s.type){case"Color":if("fill/solid/color"===s.property){this.engine.block.setColor(a,s.property,s.value),this.engine.block.setTextColor(a,s.value);break}this.engine.block.setColor(a,s.property,s.value);break;case"Int":this.engine.block.setInt(a,s.property,s.value);break;case"Float":if("caption/scale"===s.property){n(this.engine,a,s.value);break}this.engine.block.setFloat(a,s.property,s.value);break;case"Double":this.engine.block.setDouble(a,s.property,s.value);break;case"Boolean":this.engine.block.setBool(a,s.property,s.value);break;case"Enum":this.engine.block.setEnum(a,s.property,s.value);break;case"String":this.engine.block.setString(a,s.property,s.value)}this.assets=function(e,s,t){return e.map((e=>{if("caption/scale"===t.property){const s=e.payload?.properties?.map((e=>"caption/scale"===e.property?{...e,value:t.value}:e));return{...e,payload:{...e.payload,properties:s}}}if(e.id===s.id){const s=e.payload?.properties?.map((e=>e.property===t.property?{...e,value:t.value}:e));return{...e,payload:{...e.payload,properties:s}}}return e}))}(this.assets,e,s),this.engine.asset.assetSourceContentsChanged(t)}}},c=class{constructor(e={}){this.config=e}name="cesdk-caption-presets-asset-source";version=s.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.caption.presets":["ly.img.library.captionPresets"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new a(e,o,this.config.customFetchImpl);await i.initialize();const r="ly.img.caption.presets";if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}},d=class{constructor(e={}){this.config=e}name="cesdk-color-palette-asset-source";version="1.61";addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.color.palette":["ly.img.colors"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.color.palette";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import l from"@cesdk/cesdk-js";var u=class{constructor(e={}){this.config=e}name="cesdk-crop-presets-asset-source";version=l.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.crop.presets":["ly.img.cropPresets"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.crop.presets";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import g from"@cesdk/cesdk-js";var h=class{constructor(e={}){this.config=e}name="cesdk-demo-asset-sources";version=g.version;addedAssetSourceIds=[];globToRegex(e){const s=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp(`^${s}$`,"i")}sourceMatchesAnyPattern(e,s){return s.some((s=>{if(s===e||s.startsWith(`${e}.`))return!0;return this.globToRegex(s).test(e)}))}filterAssetSources(e,s){return e.filter((e=>this.sourceMatchesAnyPattern(e,s)))}filterMatchersForSource(e,s){return s.filter((s=>{if(s===e||s.startsWith(`${e}.`))return!0;return this.globToRegex(s).test(e)}))}getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.image":["ly.img.image"],"ly.img.video":["ly.img.video"],"ly.img.audio":["ly.img.audio"],"ly.img.templates":["ly.img.templates"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r=["ly.img.audio","ly.img.video","ly.img.image","ly.img.templates"],n=this.config.include?this.filterAssetSources(r,this.config.include):r;for(const s of n)if(!i.has(s)){const t=`${o}${s}/content.json`,i=this.config.include?this.filterMatchersForSource(s,this.config.include):void 0;await e.asset.addLocalAssetSourceFromJSONURI(t,{matcher:i}),this.addedAssetSourceIds.push(s)}if(s){s.onReset((()=>this.cleanup({engine:e})));for(const e of this.addedAssetSourceIds){const t=this.getAssetLibraryEntries(e);for(const o of t)s.ui.updateAssetLibraryEntry(o,{sourceIds:({currentIds:s})=>[...new Set([...s,e])]})}}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import p from"@cesdk/cesdk-js";var f=class{constructor(e={}){this.config=e}name="cesdk-effects-asset-source";version=p.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.effect":["ly.img.effect"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.effect";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import y from"@cesdk/cesdk-js";var b=class{constructor(e={}){this.config=e}name="cesdk-filters-asset-source";version=y.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.filter":["ly.img.filter"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.filter";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import m from"@cesdk/cesdk-js";var S=class{constructor(e={}){this.config=e}name="cesdk-page-presets-asset-source";version=m.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.page.presets":["ly.img.pagePresets"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.page.presets";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import k from"@cesdk/cesdk-js";var A=class{constructor(e={}){this.config=e}name="cesdk-sticker-asset-source";version=k.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.sticker":["ly.img.sticker"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.sticker";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import w from"@cesdk/cesdk-js";var L=class{constructor(e={}){this.config=e}name="cesdk-text-asset-source";version=w.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.text":["ly.img.text"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.text";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import v from"@cesdk/cesdk-js";var I=class{constructor(e={}){this.config=e}name="cesdk-text-component-asset-source";version=v.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.text.components":["ly.img.text"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.text.components";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import E from"@cesdk/cesdk-js";var R=class{constructor(e={}){this.config=e}name="cesdk-typeface-asset-source";version=E.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.typeface":["ly.img.typefaces"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.typeface";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import U from"@cesdk/cesdk-js";var $=[{id:"ly.img.image.upload",mimeTypes:["image/jpeg","image/png","image/webp","image/svg+xml","image/bmp","image/gif"],assetLibraryEntries:["ly.img.image","ly.img.upload"]},{id:"ly.img.video.upload",mimeTypes:["application/json","video/mp4","video/quicktime","video/webm","video/matroska","image/gif"],assetLibraryEntries:["ly.img.video","ly.img.upload"]},{id:"ly.img.audio.upload",mimeTypes:["audio/mpeg","audio/mp3","audio/x-m4a","audio/wav"],assetLibraryEntries:["ly.img.audio","ly.img.upload"]}],C=class{constructor(e={}){this.config=e}name="cesdk-upload-asset-sources";version=U.version;addedAssetSourceIds=[];isExplicitMode(){return this.config.include?.some((e=>"string"==typeof e))??!1}getExplicitIncludes(){return this.config.include?new Set(this.config.include.filter((e=>"string"==typeof e))):new Set}getCustomizations(){return this.config.include?this.config.include.filter((e=>"object"==typeof e)):[]}getAssetLibraryEntries(e){return e?Array.isArray(e)?e:[e]:[]}async initialize({engine:e,cesdk:s}){const t=new Set(e.asset.findAllSources()),o=this.isExplicitMode(),i=this.getExplicitIncludes(),r=this.getCustomizations(),n=new Map;if(o)for(const e of $)i.has(e.id)&&n.set(e.id,e);else for(const e of $)n.set(e.id,e);for(const e of r){const s=n.get(e.id);s?n.set(e.id,{...s,...e}):n.set(e.id,e)}const a=Array.from(n.values());for(const o of a){const{id:i,mimeTypes:r,assetLibraryEntries:n}=o;if(!t.has(i)&&(e.asset.addLocalSource(i,r),this.addedAssetSourceIds.push(i),s)){const e=this.getAssetLibraryEntries(n);for(const t of e)s.ui.updateAssetLibraryEntry(t,{sourceIds:({currentIds:e})=>[...new Set([...e,i])]})}}s&&s.onReset((()=>this.cleanup({engine:e})))}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};import x from"@cesdk/cesdk-js";var T=class{constructor(e={}){this.config=e}name="cesdk-vectorshape-asset-source";version=x.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{"ly.img.vector.shape":["ly.img.vector.shape"]}[e]||[]}async initialize({engine:e,cesdk:s}){const t=this.config.baseURL||s?.getBaseURL()||e.editor.getSetting("basePath");if(!t)throw new Error("Cannot determine baseURL");const o=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),r="ly.img.vector.shape";if(!i.has(r)){const s=`${o}${r}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(r),s){s.onReset((()=>this.cleanup({engine:e})));const t=this.getAssetLibraryEntries(r);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,r])]})}}cleanup({engine:e}){for(const s of this.addedAssetSourceIds)try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}this.addedAssetSourceIds=[]}};export{e as BlurAssetSource,c as CaptionPresetsAssetSource,d as ColorPaletteAssetSource,u as CropPresetsAssetSource,h as DemoAssetSources,f as EffectsAssetSource,b as FiltersAssetSource,S as PagePresetsAssetSource,A as StickerAssetSource,L as TextAssetSource,I as TextComponentAssetSource,R as TypefaceAssetSource,C as UploadAssetSources,T as VectorShapeAssetSource};