@cesdk/cesdk-js 1.77.0-rc.0 → 1.77.0-rc.2
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/assets/core/{cesdk-v1.77.0-rc.0-K3EOU2GE.wasm → cesdk-v1.77.0-rc.2-OGLLMVDH.wasm} +0 -0
- package/assets/core/{worker-host-v1.77.0-rc.0.js → worker-host-v1.77.0-rc.2.js} +1 -1
- package/assets/i18n/de.json +9 -0
- package/assets/i18n/en.json +9 -0
- package/cesdk.umd.js +1 -1
- package/index.d.ts +32 -3
- package/index.js +1 -1
- package/package.json +2 -2
- package/plugins/index.d.ts +14 -42
- package/plugins/index.js +1 -1
- /package/assets/core/{cesdk-v1.77.0-rc.0-MLEZSZ4D.data → cesdk-v1.77.0-rc.2-MLEZSZ4D.data} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cesdk/cesdk-js",
|
|
3
|
-
"version": "1.77.0-rc.
|
|
3
|
+
"version": "1.77.0-rc.2",
|
|
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.77.0-rc.
|
|
43
|
+
"@cesdk/engine": "1.77.0-rc.2"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@angular/common": ">=14.0.0",
|
package/plugins/index.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ declare interface BlurAssetSourceConfig {
|
|
|
49
49
|
declare type CaptionPresetAssetId = 'ly.img.caption.presets';
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
* Provides caption
|
|
52
|
+
* Provides reusable caption style presets for the Creative Editor SDK.
|
|
53
53
|
* @public
|
|
54
54
|
*/
|
|
55
55
|
export declare class CaptionPresetsAssetSource implements EditorPlugin {
|
|
@@ -60,8 +60,7 @@ export declare class CaptionPresetsAssetSource implements EditorPlugin {
|
|
|
60
60
|
constructor(config?: CaptionPresetsAssetSourceConfig);
|
|
61
61
|
/**
|
|
62
62
|
* Get asset library entry IDs for a given asset source ID.
|
|
63
|
-
* Uses custom mapping if provided, otherwise falls back to default mapping.
|
|
64
|
-
* Returns an array of library entry IDs.
|
|
63
|
+
* Uses custom mapping if provided, otherwise falls back to the default mapping.
|
|
65
64
|
*/
|
|
66
65
|
private getAssetLibraryEntries;
|
|
67
66
|
initialize({ engine, cesdk }: EditorPluginContext): Promise<void>;
|
|
@@ -70,17 +69,16 @@ export declare class CaptionPresetsAssetSource implements EditorPlugin {
|
|
|
70
69
|
|
|
71
70
|
declare interface CaptionPresetsAssetSourceConfig {
|
|
72
71
|
baseURL?: string;
|
|
73
|
-
customFetchImpl?: typeof fetch;
|
|
74
72
|
/**
|
|
75
|
-
* Include specific caption
|
|
73
|
+
* Include specific caption presets to load using GLOB patterns.
|
|
76
74
|
* Supports wildcards: `*` (match any) and `?` (match one character).
|
|
77
75
|
* @example ['ly.img.caption.presets.*'] - Include all caption presets
|
|
78
|
-
* @example ['ly.img.caption.presets.
|
|
76
|
+
* @example ['ly.img.caption.presets.outline'] - Include a specific preset
|
|
79
77
|
*/
|
|
80
78
|
include?: (`${CaptionPresetAssetId}.*` | (string & {}))[];
|
|
81
79
|
/**
|
|
82
80
|
* Custom mapping of asset source ID to asset library entry IDs.
|
|
83
|
-
* If not specified,
|
|
81
|
+
* If not specified, caption presets are added to the `ly.img.library.captionPresets` library.
|
|
84
82
|
*/
|
|
85
83
|
assetLibraryEntries?: Record<string, AssetEntryId | AssetEntryId[]>;
|
|
86
84
|
}
|
|
@@ -492,13 +490,7 @@ declare interface StickerAssetSourceConfig {
|
|
|
492
490
|
}
|
|
493
491
|
|
|
494
492
|
/**
|
|
495
|
-
*
|
|
496
|
-
* Includes title, headline, and paragraph text presets.
|
|
497
|
-
*/
|
|
498
|
-
declare type TextAssetId = 'ly.img.text';
|
|
499
|
-
|
|
500
|
-
/**
|
|
501
|
-
* Provides text preset assets for the Creative Editor SDK.
|
|
493
|
+
* Provides reusable text style presets for the Creative Editor SDK.
|
|
502
494
|
* @public
|
|
503
495
|
*/
|
|
504
496
|
export declare class TextAssetSource implements EditorPlugin {
|
|
@@ -509,8 +501,7 @@ export declare class TextAssetSource implements EditorPlugin {
|
|
|
509
501
|
constructor(config?: TextAssetSourceConfig);
|
|
510
502
|
/**
|
|
511
503
|
* Get asset library entry IDs for a given asset source ID.
|
|
512
|
-
* Uses custom mapping if provided, otherwise falls back to default mapping.
|
|
513
|
-
* Returns an array of library entry IDs.
|
|
504
|
+
* Uses custom mapping if provided, otherwise falls back to the default mapping.
|
|
514
505
|
*/
|
|
515
506
|
private getAssetLibraryEntries;
|
|
516
507
|
initialize({ engine, cesdk }: EditorPluginContext): Promise<void>;
|
|
@@ -520,14 +511,15 @@ export declare class TextAssetSource implements EditorPlugin {
|
|
|
520
511
|
declare interface TextAssetSourceConfig {
|
|
521
512
|
baseURL?: string;
|
|
522
513
|
/**
|
|
523
|
-
* Include specific text
|
|
514
|
+
* Include specific text presets to load using GLOB patterns.
|
|
524
515
|
* Supports wildcards: `*` (match any) and `?` (match one character).
|
|
525
|
-
* @example ['ly.img.text.*'] - Include all text presets
|
|
516
|
+
* @example ['ly.img.text.presets.*'] - Include all text presets
|
|
517
|
+
* @example ['ly.img.text.presets.outline'] - Include a specific preset
|
|
526
518
|
*/
|
|
527
|
-
include?: (`${
|
|
519
|
+
include?: (`${TextPresetAssetId}.*` | (string & {}))[];
|
|
528
520
|
/**
|
|
529
521
|
* Custom mapping of asset source ID to asset library entry IDs.
|
|
530
|
-
* If not specified,
|
|
522
|
+
* If not specified, text presets are added to the `ly.img.text.presets` library.
|
|
531
523
|
*/
|
|
532
524
|
assetLibraryEntries?: Record<string, AssetEntryId | AssetEntryId[]>;
|
|
533
525
|
}
|
|
@@ -574,29 +566,9 @@ declare interface TextComponentAssetSourceConfig {
|
|
|
574
566
|
}
|
|
575
567
|
|
|
576
568
|
/**
|
|
577
|
-
*
|
|
578
|
-
*
|
|
579
|
-
* Usage:
|
|
580
|
-
* ```ts
|
|
581
|
-
* await engine.addPlugin(new TextCurveAssetSource());
|
|
582
|
-
* const { assets } = await engine.asset.findAssets(SOURCE_ID, { page: 0, perPage: 100 });
|
|
583
|
-
* await engine.asset.applyToBlock(SOURCE_ID, assets[0], textBlockId);
|
|
584
|
-
* ```
|
|
585
|
-
* @public
|
|
569
|
+
* Known text preset asset ID patterns for GLOB matching.
|
|
586
570
|
*/
|
|
587
|
-
|
|
588
|
-
#private;
|
|
589
|
-
private config;
|
|
590
|
-
name: string;
|
|
591
|
-
version: string;
|
|
592
|
-
constructor(config?: TextCurveAssetSourceConfig);
|
|
593
|
-
initialize({ engine, cesdk }: EditorPluginContext): Promise<void>;
|
|
594
|
-
cleanup({ engine }: EditorPluginContext): void;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
declare interface TextCurveAssetSourceConfig {
|
|
598
|
-
baseURL?: string;
|
|
599
|
-
}
|
|
571
|
+
declare type TextPresetAssetId = 'ly.img.text.presets';
|
|
600
572
|
|
|
601
573
|
/**
|
|
602
574
|
* Known typeface asset ID patterns for GLOB matching.
|
package/plugins/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import CreativeEditorSDK from"@cesdk/cesdk-js";var e="ly.img.colors.imageColors",t=class{name="cesdk-image-colors-asset-source";version=CreativeEditorSDK.version;assetLibraryEntries;addedSourceId=null;translate;constructor(e={}){this.assetLibraryEntries=e.assetLibraryEntries??["ly.img.colors"]}async initialize({engine:t,cesdk:i}){if(this.translate=i?e=>i.i18n.translate(e):void 0,t.asset.findAllSources().includes(e)||t.asset.addSource({id:e,findAssets:e=>this.findAssets(t,e),getGroups:()=>this.getGroups(t)}),this.addedSourceId=e,i){for(const t of this.assetLibraryEntries)i.ui.updateAssetLibraryEntry(t,{sourceIds:({currentIds:t,engine:s})=>r(s)?Array.from(new Set([...t,e])):t.filter(t=>t!==e),title:s()});i.ui.updateAssetLibraryEntry("ly.img.colors.panel",{title:s()}),i.onReset(()=>this.cleanup({engine:t,cesdk:i}))}}cleanup({engine:t,cesdk:s}){if(s)for(const t of this.assetLibraryEntries)s.ui.updateAssetLibraryEntry(t,{sourceIds:({currentIds:t})=>t.filter(t=>t!==e)});if(null!=this.addedSourceId){try{t.asset.removeSource(this.addedSourceId)}catch(e){console.warn(`Unable to remove source with id: ${this.addedSourceId}`,e)}this.addedSourceId=null}n.delete(t)}async findAssets(e,t){const s=function(e){if(null==e)return null;const t=Array.isArray(e)?e:[e];return 0===t.length?null:new Set(t)}(t?.groups),r=function(e){if(null==e)return[];const t=e.toLowerCase().match(/\w+/g);return t??[]}(t?.query),i=(await a(e,this.translate)).filter(({group:e})=>null==s||s.has(e)).flatMap(({assets:e})=>e).filter(e=>function(e,t){if(0===t.length)return!0;const s=function(e){const t=[],s=e.payload?.color;if(null!=s)switch(s.colorSpace){case"sRGB":{const e=function(e,t,s){const r=e=>Math.round(255*Math.max(0,Math.min(1,e))).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(s)}`}(s.r,s.g,s.b);t.push(e,e.slice(1));break}case"CMYK":t.push("c",String(Math.round(100*s.c)),"m",String(Math.round(100*s.m)),"y",String(Math.round(100*s.y)),"k",String(Math.round(100*s.k)));break;case"SpotColor":t.push(s.name.toLowerCase())}for(const s of e.groups??[]){const e=s.toLowerCase().match(/\w+/g);null!=e&&t.push(...e)}return t}(e);return t.every(e=>s.some(t=>t.includes(e)))}(e,r));return{assets:i,total:i.length,currentPage:0,nextPage:void 0}}async getGroups(e){return(await a(e,this.translate)).map(({group:e})=>e)}};function s(){return({sourceId:t,group:s})=>{if(null!=s&&t===e)return s}}function r(e){return e.block.findByType("graphic").some(t=>i(e,t))}function i(e,t){try{if(!e.block.hasFill(t)||!e.block.isFillEnabled(t))return!1;const s=e.block.getFill(t);return"//ly.img.ubq/fill/image"===e.block.getType(s)}catch{return!1}}function o(e,t){let s;try{s=e.block.getFill(t)}catch{return null}try{const t=e.block.getString(s,"fill/image/imageFileURI");if(t.length>0)return`uri:${t}`}catch{}try{const t=e.block.getSourceSet(s,"fill/image/sourceSet").map(e=>e.uri).filter(e=>e.length>0).sort().join("|");if(t.length>0)return`set:${t}`}catch{}try{const t=e.block.getString(s,"fill/image/externalReference");if(t.length>0)return`ref:${t}`}catch{}return null}var n=new WeakMap;function a(e,t){const s=n.get(e),r=Date.now();if(null!=s&&r-s.createdAt<250)return s.palette;const a=async function(e,t){const s=e.block.findByType("graphic"),r=new Map,n={count:0},a=[],l=new Set;for(const u of s){if(!i(e,u))continue;const s=o(e,u);if(null!=s){if(l.has(s))continue;l.add(s)}const g=[],h=new Set,f=c(e,u,r,n,t);try{const t=await e.block.getDominantColors(u,{count:5,ignoreWhite:!0});for(const{r:e,g:s,b:r}of t)d(g,h,{colorSpace:"sRGB",r:e,g:s,b:r},f)}catch(e){console.warn(`[ImageColors] Failed to extract colors from block ${u}:`,e)}g.length>0&&a.push({group:f,assets:g})}return a}(e,t);return n.set(e,{palette:a,createdAt:r}),a}function c(e,t,s,r,i){const o=function(e,t){try{const s=e.block.getName(t);if(s&&s.trim().length>0)return s.trim()}catch{}try{const s=e.block.getMetadata(t,"fallback-name");if(s&&s.trim().length>0)return s.trim()}catch{}return null}(e,t),n=o??function(e,t){const s="libraries.ly.img.colors.imageColors.unnamedBlock",r=`Image ${e}`;if(null==t)return r;const i=t(s);return i===s||0===i.length?r:i.replace(/\{\{\s*n\s*\}\}/g,String(e))}(++r.count,i),a=s.get(n)??0;return s.set(n,a+1),0===a?n:`${n} (${a+1})`}function d(t,s,r,i){const o=function(e){switch(e.colorSpace){case"sRGB":return`rgb:${e.r.toFixed(3)},${e.g.toFixed(3)},${e.b.toFixed(3)}`;case"CMYK":return`cmyk:${e.c.toFixed(3)},${e.m.toFixed(3)},${e.y.toFixed(3)},${e.k.toFixed(3)}`;case"SpotColor":return`spot:${e.name} ${e.externalReference}`;default:return`unknown:${e.colorSpace}`}}(r);s.has(o)||(s.add(o),t.push({id:`${e}.${encodeURIComponent(i)}.${o}`,payload:{color:r},groups:[i]}))}import l from"@cesdk/cesdk-js";var u=class{constructor(e={}){this.config=e}name="cesdk-blur-asset-source";version=l.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const t=this.config.assetLibraryEntries[e];return Array.isArray(t)?t:[t]}return{"ly.img.blur":["ly.img.blur"]}[e]||[]}async initialize({engine:e,cesdk:t}){const s=this.config.baseURL||t?.getBaseURL()||e.editor.getSetting("basePath");if(!s)throw new Error("Cannot determine baseURL");const r=s.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),o="ly.img.blur";if(!i.has(o)){const t=`${r}${o}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(t,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(o),t){t.onReset(()=>this.cleanup({engine:e,cesdk:t}));const s=this.getAssetLibraryEntries(o);for(const e of s)t.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,o])]})}}cleanup({engine:e,cesdk:t}){for(const s of this.addedAssetSourceIds){if(t){const e=this.getAssetLibraryEntries(s);for(const r of e)t.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==s)})}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="ly.img.caption.presets",f=["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 p(e){const t=e.scene.getCurrentPage();if(null!=t)return e.block.getChildren(t).find(t=>"//ly.img.ubq/captionTrack"===e.block.getType(t))}function y(e){const t=p(e);if(null==t)return 1;try{const s=e.block.getMetadata(t,"previousScale"),r=parseFloat(s);return Number.isNaN(r)?1:r}catch(e){return 1}}function b(e,t,s){const r=y(e),i=e.block.getTextFontSizes(t)[0]/r,o=Math.round(i*s);if(e.block.setTextFontSize(t,o),e.block.isStrokeEnabled(t)){const i=e.block.getStrokeWidth(t)/r*s;e.block.setStrokeWidth(t,i)}if(e.block.isDropShadowEnabled(t)){const i=e.block.getDropShadowOffsetX(t)/r,o=e.block.getDropShadowOffsetY(t)/r,n=e.block.getDropShadowBlurRadiusX(t)/r,a=e.block.getDropShadowBlurRadiusY(t)/r;e.block.setDropShadowOffsetX(t,i*s),e.block.setDropShadowOffsetY(t,o*s),e.block.setDropShadowBlurRadiusX(t,n*s),e.block.setDropShadowBlurRadiusY(t,a*s)}!function(e,t){const s=p(e);null!=s&&e.block.setMetadata(s,"previousScale",t.toString())}(e,s)}var m=class{engine;assets=[];customFetchImpl;baseURL;constructor(e,t,s){this.engine=e,this.baseURL=t,this.customFetchImpl=s??window.fetch.bind(window)}async initialize(){await this.fetchAssets(),this.createSource()}async fetchAssets(){const e=function(...e){return e.map((e,t)=>0===t?e.replace(/\/$/,""):e.replace(/^\//,"").replace(/\/$/,"")).join("/")}(this.baseURL,`/${h}/content.json`);try{const t=await this.customFetchImpl(e);if(!t.ok)throw new Error(t.statusText);const s=await t.json();if(void 0===s.assets)throw new Error(`Invalid content.json for assets: ${h}`);this.assets=s.assets.map(e=>(e.meta&&Object.entries(e.meta).forEach(([t,s])=>{const r=s.toString();if(r.includes("{{base_url}}")){const s=r.replace("{{base_url}}",this.baseURL).replace(/([^:])\/\/+/g,"$1/");e.meta&&(e.meta[t]=s)}}),e))}catch(e){console.warn("Could not load caption presets:",e),this.assets=[]}}createSource(){if(new Set(this.engine.asset.findAllSources()).has(h))return;const e={id:h,findAssets:e=>{const{page:t,perPage:s,excludeGroups:r,groups:i,locale:o="en",query:n,sortActiveFirst:a,sortKey:c,sortingOrder:d,tags:l}=e,u=p(this.engine),g=null!=u&&this.engine.block.hasMetadata(u,"activePreset")?this.engine.block.getMetadata(u,"activePreset"):void 0;let f=[...this.assets];if(i&&i.length>0&&(f=f.filter(e=>e.groups?.some(e=>i.includes(e)))),n&&""!==n.trim()){const e=n.toLowerCase().trim();f=f.filter(t=>(t.label?.[o]?.toLowerCase()||"").includes(e))}l&&l.length>0&&(f=f.filter(e=>(e.tags?.[o]??[]).some(e=>l.includes(e)))),r&&r.length>0&&(f=f.filter(e=>!(e.groups??[]).some(e=>r.includes(e)))),"label"===c&&"None"!==d&&f.sort((e,t)=>{const s=e.label?.[o]?.toLocaleLowerCase()||"",r=t.label?.[o]?.toLocaleLowerCase()||"";return s<r?"Ascending"===d?-1:1:s>r?"Ascending"===d?1:-1:0}),a&&g&&f.sort((e,t)=>e.id===g?-1:t.id===g?1:0);const b=f.length,m=t*s,k=m+s,S=f.slice(m,k).map(e=>{const t=e.payload?.properties?.map(e=>"caption/scale"===e.property?{...e,value:y(this.engine)}:e);return{id:e.id,label:e.label?.[o],active:e.id===g,context:{id:h},meta:e.meta,groups:e.groups,tags:e.tags?.[o],payload:{...e.payload,properties:t},locale:o}});return Promise.resolve({assets:S,total:b,currentPage:t})},getGroups:()=>{const e=new Set;return this.assets.forEach(t=>{t.groups&&t.groups.forEach(t=>{e.add(t)})}),Promise.resolve(Array.from(e))},removeAsset:e=>{const t=this.assets.findIndex(t=>t.id===e);-1!==t&&this.assets.splice(t,1)},addAsset:e=>{const t=this.assets.findIndex(t=>t.id===e.id);-1!==t?this.assets[t]=e:this.assets.push(e)},applyAssetToBlock:(e,t)=>this.applyPreset(e,t),applyAssetProperty:(e,t)=>this.applyProperty(e,t),fetchAsset:async(e,t)=>new Promise(s=>{const r=this.assets.find(t=>t.id===e);if(null==r)s(null);else{const e=t?.locale??"en",i=p(this.engine),o=null!=i&&this.engine.block.hasMetadata(i,"activePreset")?this.engine.block.getMetadata(i,"activePreset"):void 0,n=r.payload?.properties?.map(e=>"caption/scale"===e.property?{...e,value:y(this.engine)}:e);s({id:r.id,label:r.label?.[e],active:r.id===o,meta:r.meta,groups:r.groups,tags:r.tags?.[e],payload:{...r.payload,properties:n}})}})};this.engine.asset.addSource(e)}async applyPreset(e,t){const s=e?.meta?.uri;if(null==s)throw new Error(`The asset ${e.id} does not have a preset block URL.`);const r=await this.customFetchImpl(s);if(!r.ok)throw new Error(`Failed to fetch the preset block from ${s}`);const i=await r.text(),[o]=await this.engine.block.loadFromString(i),n=null!=o?this.engine.block.getType(o):void 0;if("//ly.img.ubq/text"!==n&&"//ly.img.ubq/caption"!==n)return;const a=p(this.engine),c=null!=a?this.engine.block.getChildren(a):[];f.forEach(e=>{const s=e.replace("{{blockType}}","//ly.img.ubq/text"===n?"text":"caption"),r=this.engine.block.getPropertyType(s),i=e.replace("{{blockType}}","caption");switch(r){case"Int":{const e=this.engine.block.getInt(o,s);this.engine.block.setInt(t,i,e);break}case"Float":{const e=this.engine.block.getFloat(o,s);this.engine.block.setFloat(t,i,e);break}case"Double":{const e=this.engine.block.getDouble(o,s);this.engine.block.setDouble(t,i,e);break}case"Bool":{const e=this.engine.block.getBool(o,s);this.engine.block.setBool(t,i,e);break}case"Enum":{const e=this.engine.block.getEnum(o,s);this.engine.block.setEnum(t,i,e);break}case"Color":{if("fill/solid/color"===s){const[e]=this.engine.block.getTextColors(o);this.engine.block.setColor(t,i,e),"Text"===this.engine.editor.getEditMode()&&this.engine.editor.setEditMode("Transform"),this.engine.block.setTextColor(t,e);break}const e=this.engine.block.getColor(o,s);this.engine.block.setColor(t,i,e);break}case"String":{if("text/typeface"===s||"caption/typeface"===s){const e=this.engine.block.getTypeface(o);this.engine.block.setTypeface(t,e);break}const e=this.engine.block.getString(o,s);this.engine.block.setString(t,i,e);break}}}),e.payload?.properties?.forEach(async t=>{"Color"===t.type&&await this.applyProperty(e,t)});const[d]=this.engine.block.getTextFontWeights(o);null!=d&&this.engine.block.setTextFontWeight(t,d);const[l]=this.engine.block.getTextFontStyles(o);null!=l&&this.engine.block.setTextFontStyle(t,l),function(e,t,s){const r={in:e.block.getInAnimation(t),loop:e.block.getLoopAnimation(t),out:e.block.getOutAnimation(t)},i=(t,s)=>{const i=r[s],o=(()=>{switch(s){case"in":return e.block.getInAnimation(t);case"loop":return e.block.getLoopAnimation(t);case"out":return e.block.getOutAnimation(t);default:return}})();if(null!=o&&e.block.isValid(o)&&e.block.destroy(o),e.block.isValid(i)){const r=e.block.duplicate(i);switch(s){case"in":e.block.setInAnimation(t,r);break;case"loop":e.block.setLoopAnimation(t,r);break;case"out":e.block.setOutAnimation(t,r)}}};s.forEach(e=>{i(e,"in"),i(e,"loop"),i(e,"out")})}(this.engine,o,c),null!=a&&this.engine.block.setMetadata(a,"activePreset",e.id),this.engine.block.destroy(o),this.engine.editor.addUndoStep(),this.engine.asset.assetSourceContentsChanged(h)}async applyProperty(e,t){const s=p(this.engine);if(null==s)return;const[r]=this.engine.block.findAllSelected(),i="//ly.img.ubq/caption"===(null!=r?this.engine.block.getType(r):void 0)?r:this.engine.block.getChildren(s)[0];if(null!=i){switch(t.type){case"Color":if("fill/solid/color"===t.property){this.engine.block.setColor(i,t.property,t.value),this.engine.block.setTextColor(i,t.value);break}this.engine.block.setColor(i,t.property,t.value);break;case"Int":this.engine.block.setInt(i,t.property,t.value);break;case"Float":if("caption/scale"===t.property){b(this.engine,i,t.value);break}this.engine.block.setFloat(i,t.property,t.value);break;case"Double":this.engine.block.setDouble(i,t.property,t.value);break;case"Boolean":this.engine.block.setBool(i,t.property,t.value);break;case"Enum":this.engine.block.setEnum(i,t.property,t.value);break;case"String":this.engine.block.setString(i,t.property,t.value)}this.assets=function(e,t,s){return e.map(e=>{if("caption/scale"===s.property){const t=e.payload?.properties?.map(e=>"caption/scale"===e.property?{...e,value:s.value}:e);return{...e,payload:{...e.payload,properties:t}}}if(e.id===t.id){const t=e.payload?.properties?.map(e=>e.property===s.property?{...e,value:s.value}:e);return{...e,payload:{...e.payload,properties:t}}}return e})}(this.assets,e,t),this.engine.asset.assetSourceContentsChanged(h)}}},k=class{constructor(e={}){this.config=e}name="cesdk-caption-presets-asset-source";version=g.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const t=this.config.assetLibraryEntries[e];return Array.isArray(t)?t:[t]}return{"ly.img.caption.presets":["ly.img.library.captionPresets"]}[e]||[]}async initialize({engine:e,cesdk:t}){const s=this.config.baseURL||t?.getBaseURL()||e.editor.getSetting("basePath");if(!s)throw new Error("Cannot determine baseURL");const r=s.replace(/\/*$/,"/"),i=new m(e,r,this.config.customFetchImpl);await i.initialize();const o="ly.img.caption.presets";if(this.addedAssetSourceIds.push(o),t){t.onReset(()=>this.cleanup({engine:e,cesdk:t}));const s=this.getAssetLibraryEntries(o);for(const e of s)t.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,o])]})}}cleanup({engine:e,cesdk:t}){for(const s of this.addedAssetSourceIds){if(t){const e=this.getAssetLibraryEntries(s);for(const r of e)t.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==s)})}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 A=class{constructor(e={}){this.config=e}name="cesdk-color-palette-asset-source";version=S.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const t=this.config.assetLibraryEntries[e];return Array.isArray(t)?t:[t]}return{"ly.img.color.palette":["ly.img.colors"]}[e]||[]}async initialize({engine:e,cesdk:t}){const s=this.config.baseURL||t?.getBaseURL()||e.editor.getSetting("basePath");if(!s)throw new Error("Cannot determine baseURL");const r=s.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),o="ly.img.color.palette";if(!i.has(o)){const t=`${r}${o}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(t,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(o),t){t.onReset(()=>this.cleanup({engine:e,cesdk:t}));const s=this.getAssetLibraryEntries(o);for(const e of s)t.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,o])]})}}cleanup({engine:e,cesdk:t}){for(const s of this.addedAssetSourceIds){if(t){const e=this.getAssetLibraryEntries(s);for(const r of e)t.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==s)})}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 w=class{constructor(e={}){this.config=e}name="cesdk-crop-presets-asset-source";version=L.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const t=this.config.assetLibraryEntries[e];return Array.isArray(t)?t:[t]}return{"ly.img.crop.presets":["ly.img.cropPresets"]}[e]||[]}async initialize({engine:e,cesdk:t}){const s=this.config.baseURL||t?.getBaseURL()||e.editor.getSetting("basePath");if(!s)throw new Error("Cannot determine baseURL");const r=s.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),o="ly.img.crop.presets";if(!i.has(o)){const t=`${r}${o}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(t,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(o),t){t.onReset(()=>this.cleanup({engine:e,cesdk:t}));const s=this.getAssetLibraryEntries(o);for(const e of s)t.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,o])]})}}cleanup({engine:e,cesdk:t}){for(const s of this.addedAssetSourceIds){if(t){const e=this.getAssetLibraryEntries(s);for(const r of e)t.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==s)})}try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}}this.addedAssetSourceIds=[]}};import I from"@cesdk/cesdk-js";var E=class{constructor(e={}){this.config=e}name="cesdk-demo-asset-sources";version=I.version;addedAssetSourceIds=[];globToRegex(e){const t=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp(`^${t}$`,"i")}sourceMatchesAnyPattern(e,t){return t.some(t=>{if(t===e||t.startsWith(`${e}.`))return!0;return this.globToRegex(t).test(e)})}filterAssetSources(e,t){return e.filter(e=>this.sourceMatchesAnyPattern(e,t))}filterMatchersForSource(e,t){return t.filter(t=>{if(t===e||t.startsWith(`${e}.`))return!0;return this.globToRegex(t).test(e)})}getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const t=this.config.assetLibraryEntries[e];return Array.isArray(t)?t:[t]}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:t}){const s=this.config.baseURL||t?.getBaseURL()||e.editor.getSetting("basePath");if(!s)throw new Error("Cannot determine baseURL");const r=s.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),o=["ly.img.audio","ly.img.video","ly.img.image","ly.img.templates"],n=this.config.include?this.filterAssetSources(o,this.config.include):o;for(const t of n)if(!i.has(t)){const s=`${r}${t}/content.json`,i=this.config.include?this.filterMatchersForSource(t,this.config.include):void 0;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:i}),this.addedAssetSourceIds.push(t)}if(t){t.onReset(()=>this.cleanup({engine:e,cesdk:t}));for(const e of this.addedAssetSourceIds){const s=this.getAssetLibraryEntries(e);for(const r of s)t.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:t})=>[...new Set([...t,e])]})}}}cleanup({engine:e,cesdk:t}){for(const s of this.addedAssetSourceIds){if(t){const e=this.getAssetLibraryEntries(s);for(const r of e)t.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==s)})}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 R=class{constructor(e={}){this.config=e}name="cesdk-effects-asset-source";version=v.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const t=this.config.assetLibraryEntries[e];return Array.isArray(t)?t:[t]}return{"ly.img.effect":["ly.img.effect"]}[e]||[]}async initialize({engine:e,cesdk:t}){const s=this.config.baseURL||t?.getBaseURL()||e.editor.getSetting("basePath");if(!s)throw new Error("Cannot determine baseURL");const r=s.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),o="ly.img.effect";if(!i.has(o)){const t=`${r}${o}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(t,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(o),t){t.onReset(()=>this.cleanup({engine:e,cesdk:t}));const s=this.getAssetLibraryEntries(o);for(const e of s)t.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,o])]})}}cleanup({engine:e,cesdk:t}){for(const s of this.addedAssetSourceIds){if(t){const e=this.getAssetLibraryEntries(s);for(const r of e)t.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==s)})}try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}}this.addedAssetSourceIds=[]}};import $ from"@cesdk/cesdk-js";var U=class{constructor(e={}){this.config=e}name="cesdk-filters-asset-source";version=$.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const t=this.config.assetLibraryEntries[e];return Array.isArray(t)?t:[t]}return{"ly.img.filter":["ly.img.filter"]}[e]||[]}async initialize({engine:e,cesdk:t}){const s=this.config.baseURL||t?.getBaseURL()||e.editor.getSetting("basePath");if(!s)throw new Error("Cannot determine baseURL");const r=s.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),o="ly.img.filter";if(!i.has(o)){const t=`${r}${o}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(t,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(o),t){t.onReset(()=>this.cleanup({engine:e,cesdk:t}));const s=this.getAssetLibraryEntries(o);for(const e of s)t.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,o])]})}}cleanup({engine:e,cesdk:t}){for(const s of this.addedAssetSourceIds){if(t){const e=this.getAssetLibraryEntries(s);for(const r of e)t.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==s)})}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 C=class{constructor(e={}){this.config=e}name="cesdk-page-presets-asset-source";version=x.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const t=this.config.assetLibraryEntries[e];return Array.isArray(t)?t:[t]}return{"ly.img.page.presets":["ly.img.pagePresets"]}[e]||[]}async initialize({engine:e,cesdk:t}){const s=this.config.baseURL||t?.getBaseURL()||e.editor.getSetting("basePath");if(!s)throw new Error("Cannot determine baseURL");const r=s.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),o="ly.img.page.presets";if(!i.has(o)){const t=`${r}${o}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(t,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(o),t){t.onReset(()=>this.cleanup({engine:e,cesdk:t}));const s=this.getAssetLibraryEntries(o);for(const e of s)t.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,o])]})}}cleanup({engine:e,cesdk:t}){for(const s of this.addedAssetSourceIds){if(t){const e=this.getAssetLibraryEntries(s);for(const r of e)t.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==s)})}try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}}this.addedAssetSourceIds=[]}};import F from"@cesdk/cesdk-js";var T="ly.img.templates.premium",P=class{constructor(e={}){this.config=e}name="cesdk-premium-asset-sources";version=F.version;sourceAdded=!1;globToRegex(e){const t=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp(`^${t}$`,"i")}filterMatchersForSource(e){return e.filter(e=>{if(e===T||e.startsWith(`${T}.`))return!0;return this.globToRegex(e).test(T)})}getAssetLibraryEntries(){if(this.config.assetLibraryEntries?.[T]){const e=this.config.assetLibraryEntries[T];return Array.isArray(e)?e:[e]}return["ly.img.templates"]}async initialize({engine:e,cesdk:t}){const s=this.config.baseURL||t?.getBaseURL()||e.editor.getSetting("basePath");if(!s)throw new Error("Cannot determine baseURL");const r=s.replace(/\/*$/,"/");if(!new Set(e.asset.findAllSources()).has(T)){e.asset.addLocalSource(T,void 0,async t=>{if(t.meta?.uri)return await e.scene.loadFromArchiveURL(t.meta.uri),e.scene.get()??void 0});const t=`${r}${T}/content.json`,s=this.config.include?this.filterMatchersForSource(this.config.include):void 0;await e.asset.addLocalAssetSourceFromJSONURI(t,{matcher:s}),this.sourceAdded=!0}if(t&&(t.onReset(()=>this.cleanup({engine:e,cesdk:t})),this.sourceAdded)){const e=this.getAssetLibraryEntries();for(const s of e)t.ui.updateAssetLibraryEntry(s,{sourceIds:({currentIds:e})=>[...new Set([...e,T])]})}}cleanup({engine:e,cesdk:t}){if(this.sourceAdded){if(t){const e=this.getAssetLibraryEntries();for(const s of e)t.ui.updateAssetLibraryEntry(s,{sourceIds:({currentIds:e})=>e.filter(e=>e!==T)})}try{e.asset.removeSource(T)}catch(e){console.warn("Unable to remove source with id: ",T)}this.sourceAdded=!1}}};import M from"@cesdk/cesdk-js";var j=class{constructor(e={}){this.config=e}name="cesdk-sticker-asset-source";version=M.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const t=this.config.assetLibraryEntries[e];return Array.isArray(t)?t:[t]}return{"ly.img.sticker":["ly.img.sticker"]}[e]||[]}async initialize({engine:e,cesdk:t}){const s=this.config.baseURL||t?.getBaseURL()||e.editor.getSetting("basePath");if(!s)throw new Error("Cannot determine baseURL");const r=s.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),o="ly.img.sticker";if(!i.has(o)){const t=`${r}${o}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(t,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(o),t){t.onReset(()=>this.cleanup({engine:e,cesdk:t}));const s=this.getAssetLibraryEntries(o);for(const e of s)t.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,o])]})}}cleanup({engine:e,cesdk:t}){for(const s of this.addedAssetSourceIds){if(t){const e=this.getAssetLibraryEntries(s);for(const r of e)t.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==s)})}try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}}this.addedAssetSourceIds=[]}};import B from"@cesdk/cesdk-js";var z=class{constructor(e={}){this.config=e}name="cesdk-text-asset-source";version=B.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const t=this.config.assetLibraryEntries[e];return Array.isArray(t)?t:[t]}return{"ly.img.text":["ly.img.text"]}[e]||[]}async initialize({engine:e,cesdk:t}){const s=this.config.baseURL||t?.getBaseURL()||e.editor.getSetting("basePath");if(!s)throw new Error("Cannot determine baseURL");const r=s.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),o="ly.img.text";if(!i.has(o)){const t=`${r}${o}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(t,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(o),t){t.onReset(()=>this.cleanup({engine:e,cesdk:t}));const s=this.getAssetLibraryEntries(o);for(const e of s)t.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,o])]})}}cleanup({engine:e,cesdk:t}){for(const s of this.addedAssetSourceIds){if(t){const e=this.getAssetLibraryEntries(s);for(const r of e)t.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==s)})}try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}}this.addedAssetSourceIds=[]}};import O from"@cesdk/cesdk-js";var N=class{constructor(e={}){this.config=e}name="cesdk-text-component-asset-source";version=O.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const t=this.config.assetLibraryEntries[e];return Array.isArray(t)?t:[t]}return{"ly.img.text.components":["ly.img.text"]}[e]||[]}async initialize({engine:e,cesdk:t}){const s=this.config.baseURL||t?.getBaseURL()||e.editor.getSetting("basePath");if(!s)throw new Error("Cannot determine baseURL");const r=s.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),o="ly.img.text.components";if(!i.has(o)){const t=`${r}${o}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(t,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(o),t){t.onReset(()=>this.cleanup({engine:e,cesdk:t}));const s=this.getAssetLibraryEntries(o);for(const e of s)t.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,o])]})}}cleanup({engine:e,cesdk:t}){for(const s of this.addedAssetSourceIds){if(t){const e=this.getAssetLibraryEntries(s);for(const r of e)t.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==s)})}try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}}this.addedAssetSourceIds=[]}};import D from"@cesdk/cesdk-js";var J=class{constructor(e={}){this.config=e}name="cesdk-typeface-asset-source";version=D.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const t=this.config.assetLibraryEntries[e];return Array.isArray(t)?t:[t]}return{"ly.img.typeface":["ly.img.typefaces"]}[e]||[]}async initialize({engine:e,cesdk:t}){const s=this.config.baseURL||t?.getBaseURL()||e.editor.getSetting("basePath");if(!s)throw new Error("Cannot determine baseURL");const r=s.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),o="ly.img.typeface";if(!i.has(o)){const t=`${r}${o}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(t,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(o),t){t.onReset(()=>this.cleanup({engine:e,cesdk:t}));const s=this.getAssetLibraryEntries(o);for(const e of s)t.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,o])]})}}cleanup({engine:e,cesdk:t}){for(const s of this.addedAssetSourceIds){if(t){const e=this.getAssetLibraryEntries(s);for(const r of e)t.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==s)})}try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}}this.addedAssetSourceIds=[]}};import q from"@cesdk/cesdk-js";var G=[{id:"ly.img.image.upload",mimeTypes:["image/jpeg","image/png","image/webp","image/svg+xml","image/bmp","image/gif","image/apng"],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","image/apng"],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"]}],W=class{constructor(e={}){this.config=e}name="cesdk-upload-asset-sources";version=q.version;addedAssetSourceIds=[];addedLibraryEntryMappings=new Map;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:t}){const s=new Set(e.asset.findAllSources()),r=this.isExplicitMode(),i=this.getExplicitIncludes(),o=this.getCustomizations(),n=new Map;if(r)for(const e of G)i.has(e.id)&&n.set(e.id,e);else for(const e of G)n.set(e.id,e);for(const e of o){const t=n.get(e.id);t?n.set(e.id,{...t,...e}):n.set(e.id,e)}const a=Array.from(n.values());for(const r of a){const{id:i,mimeTypes:o,assetLibraryEntries:n}=r;if(!s.has(i)&&(e.asset.addLocalSource(i,o),this.addedAssetSourceIds.push(i),t)){const e=this.getAssetLibraryEntries(n);this.addedLibraryEntryMappings.set(i,e);for(const s of e)t.ui.updateAssetLibraryEntry(s,{sourceIds:({currentIds:e})=>[...new Set([...e,i])]})}}t&&t.onReset(()=>this.cleanup({engine:e,cesdk:t}))}cleanup({engine:e,cesdk:t}){for(const s of this.addedAssetSourceIds){if(t){const e=this.addedLibraryEntryMappings.get(s)??[];for(const r of e)t.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==s)})}try{e.asset.removeSource(s)}catch(e){console.warn("Unable to remove source with id: ",s)}}this.addedAssetSourceIds=[],this.addedLibraryEntryMappings.clear()}};import Y from"@cesdk/cesdk-js";var X=class{constructor(e={}){this.config=e}name="cesdk-vectorshape-asset-source";version=Y.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const t=this.config.assetLibraryEntries[e];return Array.isArray(t)?t:[t]}return{"ly.img.vector.shape":["ly.img.vector.shape","ly.img.shape.replace"]}[e]||[]}async initialize({engine:e,cesdk:t}){const s=this.config.baseURL||t?.getBaseURL()||e.editor.getSetting("basePath");if(!s)throw new Error("Cannot determine baseURL");const r=s.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),o="ly.img.vector.shape";if(!i.has(o)){const t=`${r}${o}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(t,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(o),t){t.onReset(()=>this.cleanup({engine:e,cesdk:t}));const s=this.getAssetLibraryEntries(o);for(const e of s)t.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,o])]})}}cleanup({engine:e,cesdk:t}){for(const s of this.addedAssetSourceIds){if(t){const e=this.getAssetLibraryEntries(s);for(const r of e)t.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==s)})}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 V="ly.img.text.curve",_=class{constructor(e={}){this.config=e}name="cesdk-textcurve-asset-source";version=K.version;#e;async initialize({engine:e,cesdk:t}){const s=this.config.baseURL||t?.getBaseURL()||e.editor.getSetting("basePath");if(!s)throw new Error("TextCurveAssetSource: cannot determine baseURL — pass it via config.baseURL or set basePath in editor settings.");const r=s.replace(/\/*$/,"/");if(!new Set(e.asset.findAllSources()).has(V)){const t=`${r}ly.img.textcurve/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(t)}this.#e=e.asset.registerApplyToBlockMiddleware(async(t,s,r,i)=>{if(t!==V)return i(t,s,r);const o=s.meta?.vectorPath;"string"==typeof o&&e.block.isValid(r)&&(e.block.setTextOnPath(r,o),e.block.setString(r,"text/pathExternalRef",`${V}|${s.id}`))}),t&&t.onReset(()=>this.cleanup({engine:e,cesdk:t}))}cleanup({engine:e}){this.#e?.(),this.#e=void 0;try{e.asset.removeSource(V)}catch{}}};export{u as BlurAssetSource,k as CaptionPresetsAssetSource,A as ColorPaletteAssetSource,w as CropPresetsAssetSource,E as DemoAssetSources,R as EffectsAssetSource,U as FiltersAssetSource,e as IMAGE_COLORS_SOURCE_ID,t as ImageColorsAssetSource,C as PagePresetsAssetSource,P as PremiumTemplatesAssetSource,j as StickerAssetSource,z as TextAssetSource,N as TextComponentAssetSource,_ as TextCurveAssetSource,J as TypefaceAssetSource,W as UploadAssetSources,X as VectorShapeAssetSource};
|
|
1
|
+
import CreativeEditorSDK from"@cesdk/cesdk-js";var e="ly.img.colors.imageColors",s=class{name="cesdk-image-colors-asset-source";version=CreativeEditorSDK.version;assetLibraryEntries;addedSourceId=null;translate;constructor(e={}){this.assetLibraryEntries=e.assetLibraryEntries??["ly.img.colors"]}async initialize({engine:s,cesdk:i}){if(this.translate=i?e=>i.i18n.translate(e):void 0,s.asset.findAllSources().includes(e)||s.asset.addSource({id:e,findAssets:e=>this.findAssets(s,e),getGroups:()=>this.getGroups(s)}),this.addedSourceId=e,i){for(const s of this.assetLibraryEntries)i.ui.updateAssetLibraryEntry(s,{sourceIds:({currentIds:s,engine:t})=>r(t)?Array.from(new Set([...s,e])):s.filter(s=>s!==e),title:t()});i.ui.updateAssetLibraryEntry("ly.img.colors.panel",{title:t()}),i.onReset(()=>this.cleanup({engine:s,cesdk:i}))}}cleanup({engine:s,cesdk:t}){if(t)for(const s of this.assetLibraryEntries)t.ui.updateAssetLibraryEntry(s,{sourceIds:({currentIds:s})=>s.filter(s=>s!==e)});if(null!=this.addedSourceId){try{s.asset.removeSource(this.addedSourceId)}catch(e){console.warn(`Unable to remove source with id: ${this.addedSourceId}`,e)}this.addedSourceId=null}o.delete(s)}async findAssets(e,s){const t=function(e){if(null==e)return null;const s=Array.isArray(e)?e:[e];return 0===s.length?null:new Set(s)}(s?.groups),r=function(e){if(null==e)return[];const s=e.toLowerCase().match(/\w+/g);return s??[]}(s?.query),i=(await c(e,this.translate)).filter(({group:e})=>null==t||t.has(e)).flatMap(({assets:e})=>e).filter(e=>function(e,s){if(0===s.length)return!0;const t=function(e){const s=[],t=e.payload?.color;if(null!=t)switch(t.colorSpace){case"sRGB":{const e=function(e,s,t){const r=e=>Math.round(255*Math.max(0,Math.min(1,e))).toString(16).padStart(2,"0");return`#${r(e)}${r(s)}${r(t)}`}(t.r,t.g,t.b);s.push(e,e.slice(1));break}case"CMYK":s.push("c",String(Math.round(100*t.c)),"m",String(Math.round(100*t.m)),"y",String(Math.round(100*t.y)),"k",String(Math.round(100*t.k)));break;case"SpotColor":s.push(t.name.toLowerCase())}for(const t of e.groups??[]){const e=t.toLowerCase().match(/\w+/g);null!=e&&s.push(...e)}return s}(e);return s.every(e=>t.some(s=>s.includes(e)))}(e,r));return{assets:i,total:i.length,currentPage:0,nextPage:void 0}}async getGroups(e){return(await c(e,this.translate)).map(({group:e})=>e)}};function t(){return({sourceId:s,group:t})=>{if(null!=t&&s===e)return t}}function r(e){return e.block.findByType("graphic").some(s=>i(e,s))}function i(e,s){try{if(!e.block.hasFill(s)||!e.block.isFillEnabled(s))return!1;const t=e.block.getFill(s);return"//ly.img.ubq/fill/image"===e.block.getType(t)}catch{return!1}}function n(e,s){let t;try{t=e.block.getFill(s)}catch{return null}try{const s=e.block.getString(t,"fill/image/imageFileURI");if(s.length>0)return`uri:${s}`}catch{}try{const s=e.block.getSourceSet(t,"fill/image/sourceSet").map(e=>e.uri).filter(e=>e.length>0).sort().join("|");if(s.length>0)return`set:${s}`}catch{}try{const s=e.block.getString(t,"fill/image/externalReference");if(s.length>0)return`ref:${s}`}catch{}return null}var o=new WeakMap;function c(e,s){const t=o.get(e),r=Date.now();if(null!=t&&r-t.createdAt<250)return t.palette;const c=async function(e,s){const t=e.block.findByType("graphic"),r=new Map,o={count:0},c=[],u=new Set;for(const l of t){if(!i(e,l))continue;const t=n(e,l);if(null!=t){if(u.has(t))continue;u.add(t)}const f=[],g=new Set,h=a(e,l,r,o,s);try{const s=await e.block.getDominantColors(l,{count:5,ignoreWhite:!0});for(const{r:e,g:t,b:r}of s)d(f,g,{colorSpace:"sRGB",r:e,g:t,b:r},h)}catch(e){console.warn(`[ImageColors] Failed to extract colors from block ${l}:`,e)}f.length>0&&c.push({group:h,assets:f})}return c}(e,s);return o.set(e,{palette:c,createdAt:r}),c}function a(e,s,t,r,i){const n=function(e,s){try{const t=e.block.getName(s);if(t&&t.trim().length>0)return t.trim()}catch{}try{const t=e.block.getMetadata(s,"fallback-name");if(t&&t.trim().length>0)return t.trim()}catch{}return null}(e,s),o=n??function(e,s){const t="libraries.ly.img.colors.imageColors.unnamedBlock",r=`Image ${e}`;if(null==s)return r;const i=s(t);return i===t||0===i.length?r:i.replace(/\{\{\s*n\s*\}\}/g,String(e))}(++r.count,i),c=t.get(o)??0;return t.set(o,c+1),0===c?o:`${o} (${c+1})`}function d(s,t,r,i){const n=function(e){switch(e.colorSpace){case"sRGB":return`rgb:${e.r.toFixed(3)},${e.g.toFixed(3)},${e.b.toFixed(3)}`;case"CMYK":return`cmyk:${e.c.toFixed(3)},${e.m.toFixed(3)},${e.y.toFixed(3)},${e.k.toFixed(3)}`;case"SpotColor":return`spot:${e.name} ${e.externalReference}`;default:return`unknown:${e.colorSpace}`}}(r);t.has(n)||(t.add(n),s.push({id:`${e}.${encodeURIComponent(i)}.${n}`,payload:{color:r},groups:[i]}))}import u from"@cesdk/cesdk-js";var l=class{constructor(e={}){this.config=e}name="cesdk-blur-asset-source";version=u.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 r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.blur";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import f from"@cesdk/cesdk-js";var g="ly.img.caption.presets",h=class{constructor(e={}){this.config=e}name="cesdk-caption-presets-asset-source";version=f.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{[g]:["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 r=t.replace(/\/*$/,"/");if(!new Set(e.asset.findAllSources()).has(g)){const s=`${r}${g}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include}),this.addedAssetSourceIds.push(g)}if(s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));for(const e of this.addedAssetSourceIds){const t=this.getAssetLibraryEntries(e);for(const r of t)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:s})=>[...new Set([...s,e])]})}}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import y from"@cesdk/cesdk-js";var m=class{constructor(e={}){this.config=e}name="cesdk-color-palette-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.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 r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.color.palette";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import p from"@cesdk/cesdk-js";var b=class{constructor(e={}){this.config=e}name="cesdk-crop-presets-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.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 r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.crop.presets";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import A from"@cesdk/cesdk-js";var S=class{constructor(e={}){this.config=e}name="cesdk-demo-asset-sources";version=A.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 r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n=["ly.img.audio","ly.img.video","ly.img.image","ly.img.templates"],o=this.config.include?this.filterAssetSources(n,this.config.include):n;for(const s of o)if(!i.has(s)){const t=`${r}${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,cesdk:s}));for(const e of this.addedAssetSourceIds){const t=this.getAssetLibraryEntries(e);for(const r of t)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:s})=>[...new Set([...s,e])]})}}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import L from"@cesdk/cesdk-js";var I=class{constructor(e={}){this.config=e}name="cesdk-effects-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.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 r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.effect";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import E from"@cesdk/cesdk-js";var w=class{constructor(e={}){this.config=e}name="cesdk-filters-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.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 r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.filter";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import k from"@cesdk/cesdk-js";var v=class{constructor(e={}){this.config=e}name="cesdk-page-presets-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.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 r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.page.presets";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import R from"@cesdk/cesdk-js";var $="ly.img.templates.premium",U=class{constructor(e={}){this.config=e}name="cesdk-premium-asset-sources";version=R.version;sourceAdded=!1;globToRegex(e){const s=e.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".");return new RegExp(`^${s}$`,"i")}filterMatchersForSource(e){return e.filter(e=>{if(e===$||e.startsWith(`${$}.`))return!0;return this.globToRegex(e).test($)})}getAssetLibraryEntries(){if(this.config.assetLibraryEntries?.[$]){const e=this.config.assetLibraryEntries[$];return Array.isArray(e)?e:[e]}return["ly.img.templates"]}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 r=t.replace(/\/*$/,"/");if(!new Set(e.asset.findAllSources()).has($)){e.asset.addLocalSource($,void 0,async s=>{if(s.meta?.uri)return await e.scene.loadFromArchiveURL(s.meta.uri),e.scene.get()??void 0});const s=`${r}${$}/content.json`,t=this.config.include?this.filterMatchersForSource(this.config.include):void 0;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:t}),this.sourceAdded=!0}if(s&&(s.onReset(()=>this.cleanup({engine:e,cesdk:s})),this.sourceAdded)){const e=this.getAssetLibraryEntries();for(const t of e)s.ui.updateAssetLibraryEntry(t,{sourceIds:({currentIds:e})=>[...new Set([...e,$])]})}}cleanup({engine:e,cesdk:s}){if(this.sourceAdded){if(s){const e=this.getAssetLibraryEntries();for(const t of e)s.ui.updateAssetLibraryEntry(t,{sourceIds:({currentIds:e})=>e.filter(e=>e!==$)})}try{e.asset.removeSource($)}catch(e){console.warn("Unable to remove source with id: ",$)}this.sourceAdded=!1}}};import j from"@cesdk/cesdk-js";var x=class{constructor(e={}){this.config=e}name="cesdk-sticker-asset-source";version=j.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 r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.sticker";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import F from"@cesdk/cesdk-js";var C="ly.img.text.presets",M=class{constructor(e={}){this.config=e}name="cesdk-text-asset-source";version=F.version;addedAssetSourceIds=[];getAssetLibraryEntries(e){if(this.config.assetLibraryEntries?.[e]){const s=this.config.assetLibraryEntries[e];return Array.isArray(s)?s:[s]}return{[C]:["ly.img.text.presets"]}[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 r=t.replace(/\/*$/,"/");if(!new Set(e.asset.findAllSources()).has(C)){const s=`${r}${C}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include}),this.addedAssetSourceIds.push(C)}if(s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));for(const e of this.addedAssetSourceIds){const t=this.getAssetLibraryEntries(e);for(const r of t)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:s})=>[...new Set([...s,e])]})}}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import P from"@cesdk/cesdk-js";var B=class{constructor(e={}){this.config=e}name="cesdk-text-component-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.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 r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.text.components";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import z from"@cesdk/cesdk-js";var N=class{constructor(e={}){this.config=e}name="cesdk-typeface-asset-source";version=z.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 r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.typeface";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};import J from"@cesdk/cesdk-js";var O=[{id:"ly.img.image.upload",mimeTypes:["image/jpeg","image/png","image/webp","image/svg+xml","image/bmp","image/gif","image/apng"],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","image/apng"],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"]}],T=class{constructor(e={}){this.config=e}name="cesdk-upload-asset-sources";version=J.version;addedAssetSourceIds=[];addedLibraryEntryMappings=new Map;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()),r=this.isExplicitMode(),i=this.getExplicitIncludes(),n=this.getCustomizations(),o=new Map;if(r)for(const e of O)i.has(e.id)&&o.set(e.id,e);else for(const e of O)o.set(e.id,e);for(const e of n){const s=o.get(e.id);s?o.set(e.id,{...s,...e}):o.set(e.id,e)}const c=Array.from(o.values());for(const r of c){const{id:i,mimeTypes:n,assetLibraryEntries:o}=r;if(!t.has(i)&&(e.asset.addLocalSource(i,n),this.addedAssetSourceIds.push(i),s)){const e=this.getAssetLibraryEntries(o);this.addedLibraryEntryMappings.set(i,e);for(const t of e)s.ui.updateAssetLibraryEntry(t,{sourceIds:({currentIds:e})=>[...new Set([...e,i])]})}}s&&s.onReset(()=>this.cleanup({engine:e,cesdk:s}))}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.addedLibraryEntryMappings.get(t)??[];for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[],this.addedLibraryEntryMappings.clear()}};import G from"@cesdk/cesdk-js";var W=class{constructor(e={}){this.config=e}name="cesdk-vectorshape-asset-source";version=G.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","ly.img.shape.replace"]}[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 r=t.replace(/\/*$/,"/"),i=new Set(e.asset.findAllSources()),n="ly.img.vector.shape";if(!i.has(n)){const s=`${r}${n}/content.json`;await e.asset.addLocalAssetSourceFromJSONURI(s,{matcher:this.config.include})}if(this.addedAssetSourceIds.push(n),s){s.onReset(()=>this.cleanup({engine:e,cesdk:s}));const t=this.getAssetLibraryEntries(n);for(const e of t)s.ui.updateAssetLibraryEntry(e,{sourceIds:({currentIds:e})=>[...new Set([...e,n])]})}}cleanup({engine:e,cesdk:s}){for(const t of this.addedAssetSourceIds){if(s){const e=this.getAssetLibraryEntries(t);for(const r of e)s.ui.updateAssetLibraryEntry(r,{sourceIds:({currentIds:e})=>e.filter(e=>e!==t)})}try{e.asset.removeSource(t)}catch(e){console.warn("Unable to remove source with id: ",t)}}this.addedAssetSourceIds=[]}};export{l as BlurAssetSource,h as CaptionPresetsAssetSource,m as ColorPaletteAssetSource,b as CropPresetsAssetSource,S as DemoAssetSources,I as EffectsAssetSource,w as FiltersAssetSource,e as IMAGE_COLORS_SOURCE_ID,s as ImageColorsAssetSource,v as PagePresetsAssetSource,U as PremiumTemplatesAssetSource,x as StickerAssetSource,M as TextAssetSource,B as TextComponentAssetSource,N as TypefaceAssetSource,T as UploadAssetSources,W as VectorShapeAssetSource};
|
|
File without changes
|