@lightspeed/crane 0.0.1-beta.23 → 0.1.0

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/dist/app.mjs CHANGED
@@ -1 +1 @@
1
- import{getCurrentInstance as k,ref as b,computed as o,reactive as d,createSSRApp as E}from"vue";import{renderToString as C}from"vue/server-renderer";const m=new Map;function c(){const n=(r,a,i,u,g)=>{m.set(r._uid,{context:b(a),content:b(i),design:b(u),defaults:b(g)})},t=(r,a,i)=>{const u=m.get(r._uid);u!==void 0&&(u.content.value=a,u.design.value=i)},e=k()?.appContext.app._uid??-1,l=m.get(e);return{init:n,update:t,context:l?.context,content:l?.content,design:l?.design,defaults:l?.defaults}}function x(n){const t=c(),e=o(()=>{const a=t.content.value[n];if(a!==void 0){if(typeof a=="string")return a;throw new Error(`Element ${n} is not inputbox`)}}),l=o(()=>e.value!==void 0),r=o(()=>e.value);return d({hasContent:l,value:r})}function h(n){const t=c(),e=o(()=>{const a=t.content.value[n];if(a!==void 0){if(typeof a=="string")return a;throw new Error(`Element ${n} is not textarea`)}}),l=o(()=>e.value!==void 0),r=o(()=>e.value);return d({hasContent:l,value:r})}function I(n){return"title"in n&&"type"in n}function $(n){const t=c(),e=o(()=>{const u=t.content.value[n];if(u!==void 0){if(I(u))return u;throw new Error(`Element ${n} is not action link`)}}),l=o(()=>e.value?.title),r=o(()=>e.value?.link),a=o(()=>!!l.value),i=o(()=>!!r.value);return d({title:l,link:r,hasTitle:a,hasLink:i,performAction:()=>{if(e.value!==void 0)switch(e.value.type){case"HYPER_LINK":e.value.link&&window.open(e.value.link,"_blank");break;case"GO_TO_STORE_LINK":window.open("/products");break;case"MAIL_LINK":e.value.email&&window.open(`mailto:${e.value.email}`,"_self");break;case"TEL_LINK":e.value.phone&&window.open(`tel:${e.value.phone}`,"_self");break;case"SCROLL_TO_TILE":{if(typeof document>"u")return;const u=e.value.tileId;document.getElementById(`tile-${u}`)?.scrollIntoView();break}default:throw new Error("Unknown ButtonType: ")}}})}function _(n){return"bucket"in n&&"borderInfo"in n&&"set"in n}function T(n){const t=c(),e=o(()=>{const s=t.content.value[n];if(s!==void 0){if(_(s))return s;throw new Error(`Element ${n} is not image`)}}),l=o(()=>e.value===void 0?"":t.context.value.imageBuckets?.[e.value?.bucket]),r=o(()=>e.value!==void 0),a=o(()=>`${l.value}/${e.value?.set?.["cropped-webp-100x200"]?.url}`),i=o(()=>`${l.value}/${e.value?.set?.["cropped-webp-1000x2000"]?.url}`),u=o(()=>`${l.value}/${e.value?.set?.["webp-200x200"]?.url}`),g=o(()=>`${l.value}/${e.value?.set?.["webp-2000x2000"]?.url}`);return d({hasContent:r,lowResolutionMobileImage:a,highResolutionMobileImage:i,lowResolutionDesktopImage:u,highResolutionDesktopImage:g})}function z(n){return"enabled"in n}function D(n){const t=c(),e=o(()=>{const a=t.content.value[n];if(a!==void 0){if(z(a))return a;throw new Error(`Element ${n} is not toggle`)}}),l=o(()=>e.value!==void 0),r=o(()=>e.value?.enabled);return d({hasContent:l,value:r})}function L(n){const t=c(),e=o(()=>{const a=t.content.value[n];if(a!==void 0){if(typeof a=="string")return a;throw new Error(`Element ${n} is not selectbox`)}}),l=o(()=>e.value!==void 0),r=o(()=>e.value);return d({hasContent:l,value:r})}function y(n,t){if(t===void 0)return;if(!t.startsWith("global."))return t;const e=t.split(".").at(2);if(e!==void 0)return n.fontFamily[e]}function S(n,t){if(t===void 0)return;if(typeof t!="string"||!t.startsWith("global."))return t;const e=t.split(".").at(2);if(e!==void 0)return n.textSize[e]}function f(n,t){if(t===void 0)return;if(typeof t!="string"||!t.startsWith("global."))return t;const e=t.split(".").at(2);if(e!==void 0)return n.color[e]}function R(n){const t=c(),e=o(()=>{const s=t.design.value[n],v=t.defaults.value[n],p=t.context.value.globalDesign;return{font:s?.font??y(p,v?.font),size:s?.size??S(p,v?.size),bold:s?.bold??v?.bold,italic:s?.italic??v?.italic,color:s?.color??f(p,v?.color),visible:s?.visible??v?.visible??!1}}),l=o(()=>e.value?.font),r=o(()=>e.value?.size),a=o(()=>e.value?.bold),i=o(()=>e.value?.italic),u=o(()=>e.value?.color),g=o(()=>e.value?.visible);return d({font:l,size:r,bold:a,italic:i,color:u,visible:g})}function B(n){const t=c(),e=o(()=>{const s=t.design.value[n],v=t.defaults.value[n],p=t.context.value.globalDesign;return{appearance:s?.appearance??v?.appearance,font:s?.font??y(p,v?.font),size:s?.size??v?.size,style:s?.style??v?.style,color:s?.color??f(p,v?.color),visible:s?.visible??v?.visible??!1}}),l=o(()=>e.value?.appearance),r=o(()=>e.value?.font),a=o(()=>e.value?.size),i=o(()=>e.value?.style),u=o(()=>e.value?.color),g=o(()=>e.value?.visible);return d({appearance:l,font:r,size:a,style:i,color:u,visible:g})}function A(n){const t=c(),e=o(()=>{const a=t.design.value[n],i=t.defaults.value[n],u=t.context.value.globalDesign;return{overlay:{type:a?.overlay?.type??i?.overlay?.type,solid:{color:a?.overlay?.solid?.color??f(u,i?.overlay?.solid?.color)},gradient:{fromColor:a?.overlay?.gradient?.fromColor??f(u,i?.overlay?.gradient?.fromColor),toColor:a?.overlay?.gradient?.toColor??f(u,i?.overlay?.gradient?.toColor)}},visible:a?.visible??i?.visible??!1}}),l=o(()=>e.value?.overlay),r=o(()=>e.value?.visible);return d({overlay:l,visible:r})}function O(n){const t=c(),e=o(()=>{const r=t.design.value[n],a=t.defaults.value[n];return{enabled:r?.enabled??a?.enabled}}),l=o(()=>e.value?.enabled);return d({enabled:l})}function G(n){const t=c(),e=o(()=>{const r=t.design.value[n],a=t.defaults.value[n];return{value:r?.value??a?.value}}),l=o(()=>e.value?.value);return d({value:l})}function K(n){const t=c(),e=o(()=>{const r=t.design.value[n],a=t.defaults.value[n],i=t.context.value.globalDesign;return{background:{type:r?.background?.type??a?.background?.type,solid:{color:r?.background?.solid?.color??f(i,a?.background?.solid?.color)},gradient:{fromColor:r?.background?.gradient?.fromColor??f(i,a?.background?.gradient?.fromColor),toColor:r?.background?.gradient?.toColor??f(i,a?.background?.gradient?.toColor)}}}}),l=o(()=>e.value?.background);return d({background:l})}function w(n){return{app:E(n)}}function M(n,t){return{init:()=>{const{app:e}=w(n);return t?.init?.(e),{render:async(l,r)=>(c().init(e,l,r.content,r.design,r.defaults),t?.render?.(e,l,r),{html:await C(e,{context:l}),state:{context:l,data:r}})}}}}function N(n,t){return{init:()=>{const{app:e}=w(n);return t?.init?.(e),{mount:(l,r)=>{c().init(e,r.context,r.data.content,r.data.design,r.data.defaults),t?.mount?.(e,l,r),e.mount(l)},update:l=>{c().update(e,l.data.content,l.data.design),t?.update?.(e,l)},unmount:()=>{t?.unmount?.(e),e.unmount()}}}}}export{N as createVueClientApp,M as createVueServerApp,K as useBackgroundElementDesign,$ as useButtonElementContent,B as useButtonElementDesign,T as useImageElementContent,A as useImageElementDesign,x as useInputboxElementContent,L as useSelectboxElementContent,G as useSelectboxElementDesign,R as useTextElementDesign,h as useTextareaElementContent,D as useToggleElementContent,O as useToggleElementDesign,c as useVueBaseProps};
1
+ import{getCurrentInstance as k,ref as b,computed as o,reactive as d,createSSRApp as E}from"vue";import{renderToString as C}from"vue/server-renderer";const m=new Map;function c(){const n=(r,a,i,u,g)=>{m.set(r._uid,{context:b(a),content:b(i),design:b(u),defaults:b(g)})},t=(r,a,i)=>{const u=m.get(r._uid);u!==void 0&&(u.content.value=a,u.design.value=i)},e=k()?.appContext.app._uid??-1,l=m.get(e);return{init:n,update:t,context:l?.context,content:l?.content,design:l?.design,defaults:l?.defaults}}function x(n){const t=c(),e=o(()=>{const a=t.content.value[n];if(a!==void 0){if(typeof a=="string")return a;throw new Error(`Element ${n} is not inputbox`)}}),l=o(()=>e.value!==void 0),r=o(()=>e.value);return d({hasContent:l,value:r})}function h(n){const t=c(),e=o(()=>{const a=t.content.value[n];if(a!==void 0){if(typeof a=="string")return a;throw new Error(`Element ${n} is not textarea`)}}),l=o(()=>e.value!==void 0),r=o(()=>e.value);return d({hasContent:l,value:r})}function I(n){return"title"in n&&"type"in n}function $(n){const t=c(),e=o(()=>{const u=t.content.value[n];if(u!==void 0){if(I(u))return u;throw new Error(`Element ${n} is not action link`)}}),l=o(()=>e.value?.title),r=o(()=>e.value?.link),a=o(()=>!!l.value),i=o(()=>!!r.value);return d({title:l,link:r,hasTitle:a,hasLink:i,performAction:()=>{if(e.value!==void 0)switch(e.value.buttonType){case"HYPER_LINK":e.value.link&&window.open(e.value.link,"_blank");break;case"GO_TO_STORE_LINK":window.open("/products");break;case"MAIL_LINK":e.value.email&&window.open(`mailto:${e.value.email}`,"_self");break;case"TEL_LINK":e.value.phone&&window.open(`tel:${e.value.phone}`,"_self");break;case"SCROLL_TO_TILE":{if(typeof document>"u")return;const u=e.value.tileId;document.getElementById(`tile-${u}`)?.scrollIntoView();break}default:throw new Error("Unknown ButtonType: ")}}})}function T(n){return"bucket"in n&&"borderInfo"in n&&"set"in n}function _(n){const t=c(),e=o(()=>{const s=t.content.value[n];if(s!==void 0){if(T(s))return s;throw new Error(`Element ${n} is not image`)}}),l=o(()=>e.value===void 0?"":t.context.value.imageBuckets?.[e.value?.bucket]),r=o(()=>e.value!==void 0),a=o(()=>`${l.value}/${e.value?.set?.["cropped-webp-100x200"]?.url}`),i=o(()=>`${l.value}/${e.value?.set?.["cropped-webp-1000x2000"]?.url}`),u=o(()=>`${l.value}/${e.value?.set?.["webp-200x200"]?.url}`),g=o(()=>`${l.value}/${e.value?.set?.["webp-2000x2000"]?.url}`);return d({hasContent:r,lowResolutionMobileImage:a,highResolutionMobileImage:i,lowResolutionDesktopImage:u,highResolutionDesktopImage:g})}function z(n){return"enabled"in n}function D(n){const t=c(),e=o(()=>{const a=t.content.value[n];if(a!==void 0){if(z(a))return a;throw new Error(`Element ${n} is not toggle`)}}),l=o(()=>e.value!==void 0),r=o(()=>e.value?.enabled);return d({hasContent:l,value:r})}function L(n){const t=c(),e=o(()=>{const a=t.content.value[n];if(a!==void 0){if(typeof a=="string")return a;throw new Error(`Element ${n} is not selectbox`)}}),l=o(()=>e.value!==void 0),r=o(()=>e.value);return d({hasContent:l,value:r})}function y(n,t){if(t===void 0)return;if(!t.startsWith("global."))return t;const e=t.split(".").at(2);if(e!==void 0)return n.fontFamily[e]}function S(n,t){if(t===void 0)return;if(typeof t!="string"||!t.startsWith("global."))return t;const e=t.split(".").at(2);if(e!==void 0)return n.textSize[e]}function f(n,t){if(t===void 0)return;if(typeof t!="string"||!t.startsWith("global."))return t;const e=t.split(".").at(2);if(e!==void 0)return n.color[e]}function R(n){const t=c(),e=o(()=>{const s=t.design.value[n],v=t.defaults.value[n],p=t.context.value.globalDesign;return{font:s?.font??y(p,v?.font),size:s?.size??S(p,v?.size),bold:s?.bold??v?.bold,italic:s?.italic??v?.italic,color:s?.color??f(p,v?.color),visible:s?.visible??v?.visible??!1}}),l=o(()=>e.value?.font),r=o(()=>e.value?.size),a=o(()=>e.value?.bold),i=o(()=>e.value?.italic),u=o(()=>e.value?.color),g=o(()=>e.value?.visible);return d({font:l,size:r,bold:a,italic:i,color:u,visible:g})}function B(n){const t=c(),e=o(()=>{const s=t.design.value[n],v=t.defaults.value[n],p=t.context.value.globalDesign;return{appearance:s?.appearance??v?.appearance,font:s?.font??y(p,v?.font),size:s?.size??v?.size,style:s?.style??v?.style,color:s?.color??f(p,v?.color),visible:s?.visible??v?.visible??!1}}),l=o(()=>e.value?.appearance),r=o(()=>e.value?.font),a=o(()=>e.value?.size),i=o(()=>e.value?.style),u=o(()=>e.value?.color),g=o(()=>e.value?.visible);return d({appearance:l,font:r,size:a,style:i,color:u,visible:g})}function A(n){const t=c(),e=o(()=>{const a=t.design.value[n],i=t.defaults.value[n],u=t.context.value.globalDesign;return{overlay:{type:a?.overlay?.type??i?.overlay?.type,solid:{color:a?.overlay?.solid?.color??f(u,i?.overlay?.solid?.color)},gradient:{fromColor:a?.overlay?.gradient?.fromColor??f(u,i?.overlay?.gradient?.fromColor),toColor:a?.overlay?.gradient?.toColor??f(u,i?.overlay?.gradient?.toColor)}},visible:a?.visible??i?.visible??!1}}),l=o(()=>e.value?.overlay),r=o(()=>e.value?.visible);return d({overlay:l,visible:r})}function O(n){const t=c(),e=o(()=>{const r=t.design.value[n],a=t.defaults.value[n];return{enabled:r?.enabled??a?.enabled}}),l=o(()=>e.value?.enabled);return d({enabled:l})}function G(n){const t=c(),e=o(()=>{const r=t.design.value[n],a=t.defaults.value[n];return{value:r?.value??a?.value}}),l=o(()=>e.value?.value);return d({value:l})}function K(n){const t=c(),e=o(()=>{const r=t.design.value[n],a=t.defaults.value[n],i=t.context.value.globalDesign;return{background:{type:r?.background?.type??a?.background?.type,solid:{color:r?.background?.solid?.color??f(i,a?.background?.solid?.color)},gradient:{fromColor:r?.background?.gradient?.fromColor??f(i,a?.background?.gradient?.fromColor),toColor:r?.background?.gradient?.toColor??f(i,a?.background?.gradient?.toColor)}}}}),l=o(()=>e.value?.background);return d({background:l})}function w(n){return{app:E(n)}}function M(n,t){return{init:()=>{const{app:e}=w(n);return t?.init?.(e),{render:async(l,r)=>(c().init(e,l,r.content,r.design,r.defaults),t?.render?.(e,l,r),{html:await C(e,{context:l}),state:{context:l,data:r}})}}}}function N(n,t){return{init:()=>{const{app:e}=w(n);return t?.init?.(e),{mount:(l,r)=>{c().init(e,r.context,r.data.content,r.data.design,r.data.defaults),t?.mount?.(e,l,r),e.mount(l)},update:l=>{c().update(e,l.data.content,l.data.design),t?.update?.(e,l)},unmount:()=>{t?.unmount?.(e),e.unmount()}}}}}export{N as createVueClientApp,M as createVueServerApp,K as useBackgroundElementDesign,$ as useButtonElementContent,B as useButtonElementDesign,_ as useImageElementContent,A as useImageElementDesign,x as useInputboxElementContent,L as useSelectboxElementContent,G as useSelectboxElementDesign,R as useTextElementDesign,h as useTextareaElementContent,D as useToggleElementContent,O as useToggleElementDesign,c as useVueBaseProps};
package/dist/cli.mjs CHANGED
@@ -1,5 +1,7 @@
1
- import D from"cac";import a from"node:fs";import l from"node:path";import{fileURLToPath as v}from"node:url";import{red as I,yellow as A,green as _}from"kolorist";import{resolve as i,dirname as U,sep as F}from"path";import{glob as d}from"glob";import{build as g,defineConfig as E}from"vite";import{builtinModules as S}from"module";import k from"@vitejs/plugin-vue";import $ from"vite-tsconfig-paths";import B from"vite-plugin-checker";import{viteExternalsPlugin as G}from"vite-plugin-externals";import{writeFileSync as x,createReadStream as h}from"fs";import{readFile as C}from"fs/promises";import z from"axios";import{inc as M}from"semver";import*as c from"process";import P from"tinycolor2";function N(t,e){a.statSync(t).isDirectory()?(a.mkdirSync(e,{recursive:!0}),a.readdirSync(t).forEach(n=>{const o=l.resolve(t,n),r=l.resolve(e,n);N(o,r)})):a.copyFileSync(t,e)}function j(t,e,n,o){const r=l.join(t,o?.[n]??n);N(l.join(e,n),r)}const f={error:t=>console.log(I(t)),warn:t=>console.log(A(t)),info:t=>console.log(_(t))};async function K(t){try{const e=t,n=process.cwd(),o=l.join(n,e),r=["templates"],s={_gitignore:".gitignore"};a.existsSync(o)||a.mkdirSync(o);const p=l.resolve(v(import.meta.url),"../..","template");a.readdirSync(p).filter(w=>w!=="package.json").filter(w=>!r.includes(w)).forEach(async w=>j(o,p,w,s));const u=JSON.parse(a.readFileSync(l.join(p,"package.json"),"utf-8"));u.name=t;const L=l.join(o,"package.json");a.writeFileSync(L,`${JSON.stringify(u,null,2)}
2
- `),f.info(`App ${t} created`)}catch(e){f.error(`Error while creating app: ${e.message}`)}}async function X(t){try{const e=t,n=process.cwd(),o=l.join(n,"sections",e);a.existsSync(o)||a.mkdirSync(o);const r=l.resolve(v(import.meta.url),"../..","template/sections/block-example");a.readdirSync(r).forEach(async s=>j(o,r,s)),f.info(`Block ${t} created`)}catch(e){f.error(`Error while creating block: ${e.message}`)}}async function J(t){try{const e=process.cwd(),n=l.join(e,"templates"),o={"template.json":`${t}.json`};a.existsSync(n)||a.mkdirSync(n);const r=l.resolve(v(import.meta.url),"../..","template/templates");a.readdirSync(r).forEach(async s=>j(n,r,s,o)),f.info(`Template descriptor file [${t}.json] has been created`)}catch(e){f.error(`Error while creating template descriptors: ${e.message}`)}}function T(){const t=process.env.npm_lifecycle_event;return B({typescript:!0,vueTsc:!1,eslint:{lintCommand:`eslint --max-warnings=0 "./sections/**/*.{js,ts,vue}" --cache --cache-location "./build/eslintcache/${t}.json"`}})}function W(t,e){return{plugins:[k(),$(),T(),G({vue:"EcVue"})],define:{"process.env":{NODE_ENV:"production"}},resolve:{alias:{"@":"/src"}},build:{outDir:`./dist/${t}`,emptyOutDir:!1,rollupOptions:{preserveEntrySignatures:"strict",input:i(process.cwd(),e),output:{validate:!0,entryFileNames:"js/[name].js",chunkFileNames:"js/[name].js",assetFileNames:"assets/[name].[ext]"}}}}}function H(t,e){return{plugins:[k(),$()],define:{"process.env":{NODE_ENV:"production"}},resolve:{alias:{"@":"/src"}},ssr:{noExternal:!0},build:{ssr:!0,outDir:`./dist/${t}`,emptyOutDir:!0,rollupOptions:{external:[...S,...S.map(n=>`node:${n}`)],preserveEntrySignatures:"strict",input:i(process.cwd(),e),output:{validate:!0,entryFileNames:"js/[name].js"}}}}}function O(t,e){return{plugins:[$(),T()],resolve:{alias:{"@":"/src"}},build:{outDir:`./dist/${t}`,emptyOutDir:!1,rollupOptions:{preserveEntrySignatures:"strict",input:i(process.cwd(),e),output:{validate:!0,entryFileNames:"js/settings/[name].mjs"}}}}}async function V(){const t=await d("**/server.{js,ts}",{ignore:["node_modules/**","dist/**"]});return Promise.all(t.map(async e=>{const n=U(e).split(F).pop()??"default",o=await d(`**/${n}/client.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),r=await d(`**/${n}/settings/content.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),s=await d(`**/${n}/settings/design.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),p=await d(`**/${n}/settings/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]});return{name:n,serverEntrypoint:e,clientEntrypoint:o.at(0),contentSettingsEntrypoint:r.at(0),designSettingsEntrypoint:s.at(0),translationsEntrypoint:p.at(0)}}))}async function Z(){try{const t=await V();for(const e of t){const{name:n,serverEntrypoint:o,clientEntrypoint:r,contentSettingsEntrypoint:s,designSettingsEntrypoint:p,translationsEntrypoint:u}=e;await g({configFile:!1,...E(H(n,o))}),r!==void 0&&await g({configFile:!1,...E(W(n,r))}),s!==void 0&&await g({configFile:!1,...E(O(n,s))}),p!==void 0&&await g({configFile:!1,...E(O(n,p))}),u!==void 0&&await g({configFile:!1,...E(O(n,u))})}f.info("Build successful. For deploy run: npm run deploy")}catch(t){f.error(`Error while building: ${t.message}`)}}function R(t){if(t!==void 0)return t.startsWith("global.")?{type:"GLOBAL_FONT",font:t}:{type:"PRESET_FONT",font:t}}function y(t){if(t===void 0)return;if(t.startsWith("global."))return{type:"GLOBAL_COLOR",raw:t};const e=P(t);return{type:"STRUCTURED_COLOR",raw:t,hex:e.toHex8String(),hsl:e.toHsl(),rgba:e.toRgb(),auto:!1}}function q(t){if(t!==void 0)return typeof t=="string"&&t.startsWith("global.")?{type:"GLOBAL_TEXT_SIZE",size:t}:{type:"NUMERIC_TEXT_SIZE",size:t}}const Q={COLOR:"COLOR",GRADIENT:"GRADIENT"};function Y(t){switch(t){case"COLOR":return"solid";case"GRADIENT":return"gradient";default:throw new Error(`Unknown background type: ${t}. Right options: ${Object.keys(Q)}`)}}function tt(t){const e=t.style,n=t.color,o=Array.isArray(n)?n:[n,n];return t.background={type:Y(e),solid:{color:y(o.at(0))},gradient:{fromColor:y(o.at(0)),toColor:y(o.at(1))}},t.style=void 0,t.color=void 0,t}const et={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"};function nt(t){switch(t){case"SOLID":return"solid-button";case"OUTLINE":return"outline-button";case"TEXT":return"text-link";default:throw new Error(`Unknown button appearance: ${t}. Right options: ${Object.keys(et)}`)}}const ot={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"};function rt(t){switch(t){case"SMALL":return"small";case"MEDIUM":return"medium";case"LARGE":return"large";default:throw new Error(`Unknown button size: ${t}. Right options: ${Object.keys(ot)}`)}}const st={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"};function it(t){switch(t){case"ROUND_CORNER":return"round-corner";case"RECTANGLE":return"rectangle";case"PILL":return"pill";default:throw new Error(`Unknown button shape: ${t}. Right options: ${Object.keys(st)}`)}}function at(t){const e=t.appearance;e!==void 0&&(t.appearance=nt(e));const n=t.size;n!==void 0&&(t.size=rt(n));const o=t.shape;o!==void 0&&(t.style=it(o),t.shape=void 0);const r=t.font;t.font=R(r);const s=t.color;return t.color=y(s),t}const ct={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"};function pt(t){switch(t){case"COLOR":return"solid";case"GRADIENT":return"gradient";case"NONE":return"none";default:throw new Error(`Unknown image overlay type: ${t}. Right options: ${Object.keys(ct)}`)}}function lt(t){const e=t.overlay,n=t.color,o=Array.isArray(n)?n:[n,n];return t.overlay={type:pt(e),solid:{color:y(o.at(0))},gradient:{fromColor:y(o.at(0)),toColor:y(o.at(1))}},t.color=void 0,t}function ut(t){const e=t.font;t.font=R(e);const n=t.color;t.color=y(n);const o=t.size;return t.size=q(o),t}function dt(t){Object.keys(t).forEach(e=>{const n=t[e],o=n.type;switch(o){case"TEXT":{n.defaults=ut(n.defaults);break}case"BUTTON":{n.defaults=at(n.defaults);break}case"IMAGE":{n.defaults=lt(n.defaults);break}case"BACKGROUND":{n.defaults=tt(n.defaults);break}case"TOGGLE":case"SELECTBOX":break;default:throw new Error(`Unknown design editor type: ${o}`)}})}const ft="https://blockbuster.ecwid.com";async function mt(){const t=await C(i(c.cwd(),"crane.config.json")),e=JSON.parse(t.toString());return{appClientId:e.app_client_id,appSecretKey:btoa(e.app_secret_key)}}async function yt(){const t=await C(i(c.cwd(),"package.json")),e=JSON.parse(t.toString()),n=M(e.version,"patch");return e.version=n,x(i(c.cwd(),"package.json"),`${JSON.stringify(e,null,2)}
3
- `),e.version}async function wt(t,e){try{const n=(await import(i(c.cwd(),`dist/${t}/js/settings/content.mjs`))).default;return b(n,e),n}catch{throw new Error("Content settings is invalid or undefined")}}async function gt(t,e){try{const n=(await import(i(c.cwd(),`dist/${t}/js/settings/design.mjs`))).default;return dt(n),b(n,e),n}catch(n){throw new Error(`Design settings is invalid or undefined. Error ${n}`)}}async function Et(t){const e=(await import(i(c.cwd(),`dist/${t}/js/settings/translations.mjs`))).default;return vt(e)}function b(t,e){if(t&&typeof t=="object"){const n=t;for(let o in n){const r=n[o];typeof r=="string"&&r.startsWith("$")&&(n[o]=ht(e,r)),typeof r=="object"&&b(r,e)}}}function ht(t,e){if(!e)return;const n=t[e];return n===void 0?{en:e}:n}function vt(t){const e={};for(let n in t){const o=t[n];for(let r in o){const s=e[r],p=o[r];if(s===void 0){const u={};u[n]=p,e[r]=u}else s[n]=p}}return e}async function $t(){const t=await d("*/",{cwd:i(c.cwd(),"dist/")});return Promise.all(t.map(async e=>{const n=await Et(e),o=await wt(e,n),r=await gt(e,n);return{id:e,name:{en:e},contentEditors:o,designEditors:r}}))}async function jt(t,e,n,o){const r=(await d("server.js",{cwd:i(c.cwd(),`dist/${o}/js/`)})).at(0);r!==void 0&&await t.post("/api/v1/app/resource/upload",{file:h(i(c.cwd(),`dist/${o}/js/server.js`))},{params:{appClientId:e.appClientId,type:"server_js",version:n,block:o,fileName:r},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${e.appSecretKey}`}})}async function Ot(t,e,n,o){(await d("*.js",{cwd:i(c.cwd(),`dist/${o}/js/`),ignore:"**/server.js"})).forEach(async r=>{await t.post("/api/v1/app/resource/upload",{file:h(i(c.cwd(),`dist/${o}/js/${r}`))},{params:{appClientId:e.appClientId,type:"client_js",version:n,block:o,fileName:r},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${e.appSecretKey}`}})})}async function bt(t,e,n,o){(await d("*",{cwd:i(c.cwd(),`dist/${o}/assets/`)})).forEach(async r=>{await t.post("/api/v1/app/resource/upload",{file:h(i(c.cwd(),`dist/${o}/assets/${r}`))},{params:{appClientId:e.appClientId,type:"assets",version:n,block:o,fileName:r},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${e.appSecretKey}`}})})}async function St(t,e,n){(await d("package.json")).at(0)!==void 0&&await t.post("/api/v1/app/resource/upload",{file:h(i(c.cwd(),"package.json"))},{params:{appClientId:e.appClientId,type:"dependencies",version:n},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${e.appSecretKey}`}})}async function kt(t,e,n,o){o.forEach(async r=>{await jt(t,e,n,r.id),await Ot(t,e,n,r.id),await bt(t,e,n,r.id),await St(t,e,n)})}async function Ct(t,e,n,o){await t.post("/api/v1/app/manifest",{version:n,name:"Custom Block App",blocks:o},{params:{appClientId:e.appClientId},headers:{Authorization:`Bearer ${e.appSecretKey}`}})}async function Nt(t){try{const e=t??ft,n=z.create({baseURL:e}),o=await mt(),r=await yt(),s=await $t();await Ct(n,o,r,s),await kt(n,o,r,s);const p=s.map(u=>u.id);f.info(`Deploy to ${e} successful
4
- Current app version: ${r}
5
- Deployed blocks: ${p.join(", ")}`)}catch(e){f.error(`Error while deploying: ${e.message}`)}}const Tt="0.0.1-beta.22",m=D("crane");function Rt(){m.command("create-app <appName>","Create app with custom blocks").action(K),m.command("create-block <blockName>","Create custom block").action(X),m.command("create-template <templateName>","Create custom template descriptor").action(J),m.command("build","Build app with custom blocks").action(Z),m.command("deploy","Deploy app with custom blocks").option("--url <url>","Custom deploy url").action(t=>Nt(t.url)),m.help(),m.version(Tt),m.parse()}try{Rt()}catch{m.outputHelp(),process.exit(1)}
1
+ import Ae from"cac";import d from"node:fs";import f from"node:path";import{fileURLToPath as D}from"node:url";import{red as Ne,yellow as Se,green as j}from"kolorist";import{resolve as r,parse as v,dirname as Ie,sep as Ge}from"path";import{rename as _e,unlink as Re,existsSync as A,writeFileSync as ke,createReadStream as C}from"fs";import{glob as l}from"glob";import{build as h,defineConfig as $}from"vite";import{builtinModules as P}from"module";import U from"@vitejs/plugin-vue";import b from"vite-tsconfig-paths";import Be from"vite-plugin-checker";import{viteExternalsPlugin as Pe}from"vite-plugin-externals";import Ue from"ajv/dist/2020.js";import xe from"ajv-formats";import{readFile as x}from"fs/promises";import Xe from"axios";import{inc as Fe}from"semver";import*as c from"process";import qe from"tinycolor2";import Me from"prompts";function X(e,t){d.statSync(e).isDirectory()?(d.mkdirSync(t,{recursive:!0}),d.readdirSync(e).forEach(o=>{const s=f.resolve(e,o),n=f.resolve(t,o);X(s,n)})):d.copyFileSync(e,t)}function N(e,t,o,s){const n=f.join(e,s?.[o]??o);X(f.join(t,o),n)}const m={error:e=>console.log(Ne(e)),warn:e=>console.log(Se(e)),info:e=>console.log(j(e))},T="_temp";async function F(e){try{const t=e,o=process.cwd(),s=f.join(o,t),n=["templates"],i={_gitignore:".gitignore"};d.existsSync(s)||d.mkdirSync(s);const a=f.resolve(D(import.meta.url),"../..","template");d.readdirSync(a).filter(g=>g!=="package.json").filter(g=>!n.includes(g)).forEach(async g=>N(s,a,g,i));const u=JSON.parse(d.readFileSync(f.join(a,"package.json"),"utf-8"));u.name=e;const y=f.join(s,"package.json");d.writeFileSync(y,`${JSON.stringify(u,null,2)}
2
+ `),m.info(`App ${e} created`)}catch(t){m.error(`Error while creating app: ${t.message}`)}}async function q(e){try{const t=e,o=process.cwd(),s=f.join(o,"sections",t);d.existsSync(s)||d.mkdirSync(s);const n=f.resolve(D(import.meta.url),"../..","template/sections/block-example");d.readdirSync(n).forEach(async i=>N(s,n,i)),m.info(`Section ${e} created`)}catch(t){m.error(`Error while creating block: ${t.message}`)}}async function M(e){try{const t=process.cwd(),o=f.join(t,"templates"),s={"template.ts":`${e}.ts`};d.existsSync(o)||d.mkdirSync(o);const n=f.resolve(D(import.meta.url),"../..","template/templates");d.readdirSync(n).forEach(async i=>N(o,n,i,s)),m.info(`Template descriptor file [${e}.ts] has been created`)}catch(t){m.error(`Error while creating template descriptors: ${t.message}`)}}function O(){const e=process.env.npm_lifecycle_event;return Be({typescript:!0,vueTsc:!1,eslint:{lintCommand:`eslint --max-warnings=0 "./sections/**/*.{js,ts,vue}" --cache --cache-location "./build/eslintcache/${e}.json"`}})}function ze(e,t){return{plugins:[U(),b(),O(),Pe({vue:"EcVue"})],define:{"process.env":{NODE_ENV:"production"}},resolve:{alias:{"@":"/src"}},build:{outDir:`./dist/sections/${e}`,emptyOutDir:!1,rollupOptions:{preserveEntrySignatures:"strict",input:r(process.cwd(),t),output:{validate:!0,entryFileNames:"js/[name].js",chunkFileNames:"js/[name].js",assetFileNames:"assets/[name].[ext]"}}}}}function Ke(e,t){return{plugins:[U(),b()],define:{"process.env":{NODE_ENV:"production"}},resolve:{alias:{"@":"/src"}},ssr:{noExternal:!0},build:{ssr:!0,outDir:`./dist/sections/${e}`,emptyOutDir:!0,rollupOptions:{external:[...P,...P.map(o=>`node:${o}`)],preserveEntrySignatures:"strict",input:r(process.cwd(),t),output:{validate:!0,entryFileNames:"js/[name].js"}}}}}function S(e,t){return{plugins:[b(),O()],resolve:{alias:{"@":"/src"}},build:{outDir:`./dist/sections/${e}`,emptyOutDir:!1,rollupOptions:{preserveEntrySignatures:"strict",input:r(process.cwd(),t),output:{validate:!0,entryFileNames:"js/settings/[name].mjs"}}}}}function Je(e,t){return{plugins:[b(),O()],resolve:{alias:{"@":"/src"}},build:{outDir:"./dist/template",emptyOutDir:!1,rollupOptions:{preserveEntrySignatures:"strict",input:r(process.cwd(),e),output:{validate:!0,entryFileNames:`js/[name]${t}.mjs`}}}}}function z(e,t){return{plugins:[b(),O()],resolve:{alias:{"@":"/src"}},build:{outDir:`./dist/sections/${e}`,emptyOutDir:!1,rollupOptions:{preserveEntrySignatures:"strict",input:r(process.cwd(),t),output:{validate:!0,entryFileNames:"js/showcases/[name].mjs"}}}}}function Ve(e,t){return{plugins:[b(),O()],resolve:{alias:{"@":"/src"}},build:{outDir:`./dist/sections/${e}`,emptyOutDir:!1,rollupOptions:{preserveEntrySignatures:"strict",input:r(process.cwd(),t),output:{validate:!0,assetFileNames:"assets/[name].[ext]"}}}}}const K="https://json-schema.org/draft/2020-12/schema",J="https://lightspeedhq.com/template.schema.json",V="Custom Template",H="A custom template enclosing the necessary custom and default blocks",W="object",Z={metadata:{type:"object",properties:{name:{description:"Name of the template",type:"string",minLength:2,maxLength:60},description:{description:"Short description of the template",type:"string",minLength:2,maxLength:150},url:{type:"object",properties:{demo_website:{description:"URL to the demo website",type:"string",format:"uri",pattern:"^(https?|wss?|ftp)://"},cover_image:{description:"URL to the cover image",type:"string",format:"uri",pattern:"^(https?|wss?|ftp)://"}},required:["demo_website","cover_image"]}},required:["name","description","url"]},sections:{description:"List of sections contained by this template",type:"array",items:{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]}},allOf:[{if:{properties:{type:{const:"default"}}},then:{$ref:"template-default.schema.json#/$defs/default-section"}},{if:{properties:{type:{const:"custom"}}},then:{$ref:"template-custom.schema.json#/$defs/custom-section"}}]},minItems:1,uniqueItems:!1}},Y=["metadata","sections"],He={$schema:K,$id:J,title:V,description:H,type:W,properties:Z,required:Y},Q={__proto__:null,$id:J,$schema:K,default:He,description:H,properties:Z,required:Y,title:V,type:W},ee="https://json-schema.org/draft/2020-12/schema",te="https://lightspeedhq.com/template-default.schema.json",oe="Default Section",se="Default section for a Custom Template",ne="object",ie={"default-section":{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]},id:{description:"Identification of the section",type:"string",pattern:"^((header|cover|announcement_bar|slider|special_offer|customer_review|company_info|shipping_payment|location|store|footer)(_\\d{3})?)$"}},required:["type","id"],additionalProperties:!1}},We={$schema:ee,$id:te,title:oe,description:se,type:ne,$defs:ie},Ze={__proto__:null,$defs:ie,$id:te,$schema:ee,default:We,description:se,title:oe,type:ne},re="https://json-schema.org/draft/2020-12/schema",ae="https://lightspeedhq.com/template-custom.schema.json",ce="Custom Section",pe="Custom section for a Custom Template",le="object",de={"custom-section":{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]},id:{description:"Identification of the section",type:"string"},content:{type:"object",patternProperties:{".*":{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]}},allOf:[{if:{properties:{type:{const:"INPUTBOX"}}},then:{$ref:"template-custom-content.schema.json#/$defs/input_box"}},{if:{properties:{type:{const:"TEXTAREA"}}},then:{$ref:"template-custom-content.schema.json#/$defs/text_area"}},{if:{properties:{type:{const:"BUTTON"}}},then:{$ref:"template-custom-content.schema.json#/$defs/button"}},{if:{properties:{type:{const:"IMAGE"}}},then:{$ref:"template-custom-content.schema.json#/$defs/image"}},{if:{properties:{type:{const:"TOGGLE"}}},then:{$ref:"template-custom-content.schema.json#/$defs/toggle"}},{if:{properties:{type:{const:"SELECTBOX"}}},then:{$ref:"template-custom-content.schema.json#/$defs/select_box"}}]}},minProperties:1},design:{type:"object",patternProperties:{".*":{type:"object",properties:{type:{description:"Type of the design configuration element",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]}},allOf:[{if:{properties:{type:{const:"TEXT"}}},then:{$ref:"template-custom-design.schema.json#/$defs/text"}},{if:{properties:{type:{const:"BUTTON"}}},then:{$ref:"template-custom-design.schema.json#/$defs/button"}},{if:{properties:{type:{const:"IMAGE"}}},then:{$ref:"template-custom-design.schema.json#/$defs/image"}},{if:{properties:{type:{const:"TOGGLE"}}},then:{$ref:"template-custom-design.schema.json#/$defs/toggle"}},{if:{properties:{type:{const:"SELECTBOX"}}},then:{$ref:"template-custom-design.schema.json#/$defs/select_box"}},{if:{properties:{type:{const:"BACKGROUND"}}},then:{$ref:"template-custom-design.schema.json#/$defs/background"}}]}},minProperties:1}},required:["type","id"],additionalProperties:!1}},Ye={$schema:re,$id:ae,title:ce,description:pe,type:le,$defs:de},Qe={__proto__:null,$defs:de,$id:ae,$schema:re,default:Ye,description:pe,title:ce,type:le},ue="https://json-schema.org/draft/2020-12/schema",fe="https://lightspeedhq.com/template-custom-content.schema.json",me="Custom Section :: Content Configuration",ye="Content tab configuration of a Custom Section for a Custom Template",ge="object",he={input_box:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},label:{description:"Label of the content configuration element",type:"string"},placeholder:{description:"Placeholder of the content configuration element",type:"string"}},required:["type","label","placeholder"],additionalProperties:!1},text_area:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},label:{description:"Label of the content configuration element",type:"string"},placeholder:{description:"Placeholder of the content configuration element",type:"string"}},required:["type","label","placeholder"],additionalProperties:!1},button:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},label:{description:"Label of the content configuration element",type:"string"}},required:["type","label"],additionalProperties:!1},image:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},label:{description:"Label of the content configuration element",type:"string"}},required:["type","label"],additionalProperties:!1},toggle:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},label:{description:"Label of the content configuration element",type:"string"},description:{description:"Description of the content configuration element",type:"string"}},required:["type","label"],additionalProperties:!1},select_box:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},label:{description:"Label of the content configuration element",type:"string"},placeholder:{description:"Placeholder of the content configuration element",type:"string"},description:{description:"Description of the content configuration element",type:"string"},options:{description:"Individual options of the content configuration element",type:"array",items:{type:"object",properties:{value:{description:"Value of the option",type:"string"},label:{description:"Label of the option",type:"string"}},required:["value","label"],additionalProperties:!1},minItems:1}},required:["type","label","placeholder","options"],additionalProperties:!1}},et={$schema:ue,$id:fe,title:me,description:ye,type:ge,$defs:he},tt={__proto__:null,$defs:he,$id:fe,$schema:ue,default:et,description:ye,title:me,type:ge},$e="https://json-schema.org/draft/2020-12/schema",Ee="https://lightspeedhq.com/template-custom-design.schema.json",be="Custom Section :: Design Configuration",Te="Design tab configuration of a Custom Section for a Custom Template",we="object",Oe={text:{type:"object",properties:{type:{description:"Type of the text",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},label:{description:"Label of the text",type:"string"},colors:{description:"Color options for the text",type:"array",items:{type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"},minItems:1,uniqueItems:!0},sizes:{description:"Size options for the text",type:"array",items:{type:"integer",minimum:0,exclusiveMaximum:50},minItems:1,uniqueItems:!0},defaults:{description:"Default values for the text",type:"object",properties:{font:{description:"Default font for the text",type:"string"},size:{description:"Default size for the text",type:"integer",minimum:1,exclusiveMaximum:50},bold:{description:"Default boldness for the text",type:"boolean"},italic:{description:"Default italic style for the text",type:"boolean"},color:{description:"Default color for the text",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"}},required:["font","size","bold","italic","color"],additionalProperties:!1}},required:["type","label","colors","sizes","defaults"],additionalProperties:!1},button:{type:"object",properties:{type:{description:"Type of the button",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},label:{description:"Label of the button",type:"string"},colors:{description:"Color options for the button",type:"array",items:{type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"},minItems:1,uniqueItems:!0},defaults:{description:"Default values for the button",type:"object",properties:{font:{description:"Default font for the button",type:"string"},size:{description:"Default size for the button",type:"string",enum:["SMALL","MEDIUM","LARGE"]},appearance:{description:"Default appearance for the button",type:"string",enum:["SOLID","OUTLINE","TEXT"]},shape:{description:"Default shape for the button",type:"string",enum:["ROUND_CORNER","RECTANGLE","PILL"]},color:{description:"Default color for the button",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"}},required:["font","size","appearance","shape","color"],additionalProperties:!1}},required:["type","label","colors","defaults"],additionalProperties:!1},image:{type:"object",properties:{type:{description:"Type of the image",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},label:{description:"Label of the image",type:"string"},colors:{description:"Color options for the image",type:"array",items:{type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"},minItems:1,uniqueItems:!0},defaults:{description:"Default values for the image",type:"object",properties:{overlay:{description:"Default overlay for the image",type:"string",enum:["COLOR","GRADIENT","NONE"]},color:{description:"Default color for the image",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"}},required:["overlay","color"],additionalProperties:!1}},required:["type","label","colors","defaults"],additionalProperties:!1},toggle:{type:"object",properties:{type:{description:"Type of the toggle",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},label:{description:"Label of the toggle",type:"string"},description:{description:"Description of the toggle",type:"string"},defaults:{description:"Default values for the toggle",type:"object",properties:{enabled:{description:"Default enabled status for the toggle",type:"boolean"}},required:["enabled"],additionalProperties:!1}},required:["type","label"],additionalProperties:!1},select_box:{type:"object",properties:{type:{description:"Type of the checkbox",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},label:{description:"Label of the checkbox",type:"string"},placeholder:{description:"Placeholder of the checkbox",type:"string"},description:{description:"Description of the checkbox",type:"string"},options:{description:"Individual options of the checkbox",type:"array",items:{type:"object",properties:{value:{description:"Value of the option",type:"string"},label:{description:"Label of the option",type:"string"}},required:["value","label"],additionalProperties:!1},minItems:1},defaults:{description:"Default values for the checkbox",type:"object",properties:{value:{description:"Default option for the checkbox",type:"string"}},required:["value"],additionalProperties:!1}},required:["type","label","placeholder","description","options","defaults"],additionalProperties:!1},background:{type:"object",properties:{type:{description:"Type of the background",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},label:{description:"Label of the background",type:"string"},colors:{description:"Color options for the background",type:"array",items:{type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{3})$"},minItems:1,uniqueItems:!0},defaults:{description:"Default values for the background",type:"object",properties:{style:{description:"Default style for the background",type:"string",enum:["COLOR","GRADIENT"]},color:{description:"Default color style for the background",type:"string"}},required:["style","color"],additionalProperties:!1}},required:["type","label","colors","defaults"],additionalProperties:!1}},ot={$schema:$e,$id:Ee,title:be,description:Te,type:we,$defs:Oe},st={__proto__:null,$defs:Oe,$id:Ee,$schema:$e,default:ot,description:Te,title:be,type:we};async function nt(){const e=await l("**/server.{js,ts}",{ignore:["node_modules/**","dist/**"]});return Promise.all(e.map(async t=>{const o=Ie(t).split(Ge).pop()??"default",s=await l(`**/${o}/client.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),n=await l(`**/${o}/settings/content.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),i=await l(`**/${o}/settings/design.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),a=await l(`**/${o}/settings/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),u=await l(`**/${o}/showcases/*.{js,ts}`,{ignore:["node_modules/**","dist/**","translations.{js,ts}"]}),y=await l(`**/${o}/showcases/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),g=await l(`**/${o}/assets/*`,{ignore:["node_modules/**","dist/**"]});return{name:o,serverEntrypoint:t,clientEntrypoint:s.at(0),contentSettingsEntrypoint:n.at(0),designSettingsEntrypoint:i.at(0),settingsTranslationsEntrypoint:a.at(0),showcasesEntrypoints:u,showcasesTranslationsEntrypoint:y.at(0),assetsEntrypoints:g}}))}async function it(){return{entryPoints:await l("**/templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]})}}async function I(e,t){try{return(await import(r(process.cwd(),t?`${e}${T}.mjs`:`${e}.mjs`))).default}catch{throw new Error(`File [${e}${T}.mjs] is either invalid or undefined`)}}async function rt(){let e=new Ue({allErrors:!0,schemas:[Q,Ze,Qe,tt,st]});return xe(e),e.compile(Q)}async function at(e,t,o,s){if(e(t)&&s===void 0)new Promise(n=>{_e(`${o}${T}.mjs`,`${o}.mjs`,function(i){i&&n(i)})});else throw new Promise(n=>{Re(`${o}${T}.mjs`,function(i){i&&n(i)})}),new Error(`Invalid file [${v(o).name}].
3
+ Note: Errors regarding failingKeyword: "then" can sometimes be false negatives. Please focus on fixing other errors first!
4
+ Errors: ${JSON.stringify([...e.errors??[],...s??[]],null,2)}`)}async function ct(e){const t=[];for(const o of e.sections){const s=e.sections.indexOf(o);if(s===0&&o.id!=="header"&&t.push({instancePath:`/sections/${s}/id`,message:"The first section must be a default `header`"}),s===e.sections.length-1&&o.id!=="footer"&&t.push({instancePath:`/sections/${s}/id`,message:"The last section must be a default `footer`"}),o.type==="custom")if(!A(`dist/sections/${o.id}`))t.push({instancePath:`/sections/${s}/id`,message:"Custom section must have a corresponding block defined"});else{if(o.content!==void 0)if(!A(`dist/sections/${o.id}/js/settings/content.mjs`))t.push({instancePath:`/sections/${s}/content`,message:"Content descriptor is overridden, please provide a default descriptor in the block's settings folder"});else{const n=await I(`dist/sections/${o.id}/js/settings/content`,!1),i=new Set(Object.keys(n));Object.keys(o.content).every(a=>i.has(a))||t.push({instancePath:`/sections/${s}/content`,message:"Content descriptor must be a subset of the default content descriptor"})}if(o.design!==void 0)if(!A(`dist/sections/${o.id}/js/settings/design.mjs`))t.push({instancePath:`/sections/${s}/design`,message:"Design descriptor is overridden, please provide a default descriptor in the block's settings folder"});else{const n=await I(`dist/sections/${o.id}/js/settings/design`,!1),i=new Set(Object.keys(n));Object.keys(o.design).every(a=>i.has(a))||t.push({instancePath:`/sections/${s}/design`,message:"Design descriptor must be a subset of the default design descriptor"})}}}return t.length===0?void 0:t}async function pt(){try{const e=await nt();for(const s of e){const{name:n,serverEntrypoint:i,clientEntrypoint:a,contentSettingsEntrypoint:u,designSettingsEntrypoint:y,settingsTranslationsEntrypoint:g,showcasesEntrypoints:R,showcaseTranslationsEntrypoint:k,assetsEntrypoints:B}=s;if(await h({configFile:!1,...$(Ke(n,i))}),a!==void 0&&await h({configFile:!1,...$(ze(n,a))}),u!==void 0&&await h({configFile:!1,...$(S(n,u))}),y!==void 0&&await h({configFile:!1,...$(S(n,y))}),g!==void 0&&await h({configFile:!1,...$(S(n,g))}),R!==void 0)for(const L of R)await h({configFile:!1,...$(z(n,L))});if(k!==void 0&&await h({configFile:!1,...$(z(n,k))}),B!==void 0)for(const L of B)await h({configFile:!1,...$(Ve(n,L))})}const t=await rt(),o=await it();for(const s of o.entryPoints){await h({configFile:!1,...$(Je(s,T))});const n=`dist/template/js/${v(s).name}`,i=await I(n,!0);await at(t,i,n,await ct(i))}m.info("Build successful. For deploy run: npx @lightspeed/crane@latest deploy")}catch(e){m.error(`Error while building: ${e.message}`)}}function je(e){if(e!==void 0)return e.startsWith("global.")?{type:"GLOBAL_FONT",font:e}:{type:"PRESET_FONT",font:e}}function E(e){if(e===void 0)return;if(e.startsWith("global."))return{type:"GLOBAL_COLOR",raw:e};const t=qe(e);return{type:"STRUCTURED_COLOR",raw:e,hex:t.toHex8String(),hsl:t.toHsl(),rgba:t.toRgb(),auto:!1}}function lt(e){if(e!==void 0)return typeof e=="string"&&e.startsWith("global.")?{type:"GLOBAL_TEXT_SIZE",size:e}:{type:"NUMERIC_TEXT_SIZE",size:e}}const dt={COLOR:"COLOR",GRADIENT:"GRADIENT"};function ut(e){switch(e){case"COLOR":return"solid";case"GRADIENT":return"gradient";default:throw new Error(`Unknown background type: ${e}. Right options: ${Object.keys(dt)}`)}}function ft(e){const t=e.style,o=e.color,s=Array.isArray(o)?o:[o,o];return e.background={type:ut(t),solid:{color:E(s.at(0))},gradient:{fromColor:E(s.at(0)),toColor:E(s.at(1))}},e.style=void 0,e.color=void 0,e}const mt={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"};function yt(e){switch(e){case"SOLID":return"solid-button";case"OUTLINE":return"outline-button";case"TEXT":return"text-link";default:throw new Error(`Unknown button appearance: ${e}. Right options: ${Object.keys(mt)}`)}}const gt={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"};function ht(e){switch(e){case"SMALL":return"small";case"MEDIUM":return"medium";case"LARGE":return"large";default:throw new Error(`Unknown button size: ${e}. Right options: ${Object.keys(gt)}`)}}const $t={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"};function Et(e){switch(e){case"ROUND_CORNER":return"round-corner";case"RECTANGLE":return"rectangle";case"PILL":return"pill";default:throw new Error(`Unknown button shape: ${e}. Right options: ${Object.keys($t)}`)}}function bt(e){const t=e.appearance;t!==void 0&&(e.appearance=yt(t));const o=e.size;o!==void 0&&(e.size=ht(o));const s=e.shape;s!==void 0&&(e.style=Et(s),e.shape=void 0);const n=e.font;e.font=je(n);const i=e.color;return e.color=E(i),e}const Tt={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"};function wt(e){switch(e){case"COLOR":return"solid";case"GRADIENT":return"gradient";case"NONE":return"none";default:throw new Error(`Unknown image overlay type: ${e}. Right options: ${Object.keys(Tt)}`)}}function Ot(e){const t=e.overlay,o=e.color,s=Array.isArray(o)?o:[o,o];return e.overlay={type:wt(t),solid:{color:E(s.at(0))},gradient:{fromColor:E(s.at(0)),toColor:E(s.at(1))}},e.color=void 0,e}function jt(e){const t=e.font;e.font=je(t);const o=e.color;e.color=E(o);const s=e.size;return e.size=lt(s),e}function vt(e){const t=e.color;return e.color=E(t),e}function ve(e){Object.keys(e).forEach(t=>{const o=e[t],s=o.type;Ce(s,o.defaults)})}function Ct(e){Object.keys(e).forEach(t=>{const o=e[t],s=o.type;Ce(s,o)})}function Ce(e,t){switch(e){case"TEXT":{jt(t);break}case"BUTTON":{bt(t);break}case"IMAGE":{Ot(t);break}case"BACKGROUND":{ft(t);break}case"COLOR_PICKER":{vt(t);break}case"TOGGLE":case"SELECTBOX":break;default:throw new Error(`Unknown design editor type: ${e}`)}return t}const Lt="https://blockbuster.ecwid.com";async function Dt(){const e=await x(r(c.cwd(),"crane.config.json")),t=JSON.parse(e.toString());return{appClientId:t.app_client_id,appSecretKey:btoa(t.app_secret_key)}}async function At(){const e=await x(r(c.cwd(),"package.json")),t=JSON.parse(e.toString()),o=Fe(t.version,"patch");return t.version=o,ke(r(c.cwd(),"package.json"),`${JSON.stringify(t,null,2)}
5
+ `),t.version}async function Nt(e,t){try{const o=(await import(r(c.cwd(),`dist/sections/${e}/js/settings/content.mjs`))).default;return w(o,t),o}catch{throw new Error(`Content descriptor for section [${e}] is either invalid or undefined`)}}async function St(e,t){try{const o=(await import(r(c.cwd(),`dist/sections/${e}/js/settings/design.mjs`))).default;return ve(o),w(o,t),o}catch(o){const s=o;throw new Error(`Design settings is invalid or undefined. Error ${s.stack}`)}}async function It(e,t){try{const o=await l("*.mjs",{cwd:r(c.cwd(),`dist/sections/${e}/js/showcases/`),ignore:"**/translations.mjs"});return Promise.all(o.map(async s=>{const n=(await import(r(c.cwd(),`dist/sections/${e}/js/showcases/${s}`))).default;return Ct(n.design),w(n,t),n}))}catch(o){throw new Error(`Showcases is invalid or undefined. Error ${o}`)}}async function Le(e){return await De(`dist/sections/${e}/js/settings/translations.mjs`)}async function Gt(e){return await De(`dist/sections/${e}/js/showcases/translations.mjs`)}async function De(e){const t=(await import(r(c.cwd(),e))).default;return Rt(t)}function w(e,t){if(e&&typeof e=="object"){const o=e;for(let s in o){const n=o[s];typeof n=="string"&&n.startsWith("$")&&(o[s]=_t(t,n)),typeof n=="object"&&w(n,t)}}}function _t(e,t){if(!t)return;const o=e[t];return o===void 0?{en:t}:o}function Rt(e){const t={};for(let o in e){const s=e[o];for(let n in s){const i=t[n],a=s[n];if(i===void 0){const u={};u[o]=a,t[n]=u}else i[o]=a}}return t}async function kt(){const e=await l("*/",{cwd:r(c.cwd(),"dist/sections/")});return Promise.all(e.map(async t=>{const o=await Le(t),s=await Gt(t),n=await Nt(t,o),i=await St(t,o),a=await It(t,s);return{id:t,name:{en:t},contentEditors:n,designEditors:i,showcases:a}}))}async function Bt(e){try{return(await import(r(c.cwd(),e))).default}catch{throw new Error(`Template descriptor [${e}] is either invalid or undefined`)}}async function Pt(){const e=await l("dist/template/js/**.mjs",{ignore:[`dist/template/js/**${T}.mjs`]});return Promise.all(e.map(async t=>{const o=await Bt(t),s=o.sections.filter(n=>n.type==="custom");for(const n of s){const i=await Le(n.id);n.content!==void 0&&w(n.content,i),n.design!==void 0&&(ve(n.design),w(n.design,i))}return{id:`${v(c.cwd()).name.replace(/[^a-zA-Z0-9]/g,"_")}_${v(t).name}`,descriptor:o}}))}async function Ut(e,t,o,s){const n=(await l("server.js",{cwd:r(c.cwd(),`dist/sections/${s}/js/`)})).at(0);n!==void 0&&await e.post("/api/v1/app/resource/upload",{file:C(r(c.cwd(),`dist/sections/${s}/js/server.js`))},{params:{appClientId:t.appClientId,type:"server_js",version:o,block:s,fileName:n},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${t.appSecretKey}`}})}async function xt(e,t,o,s){(await l("*.js",{cwd:r(c.cwd(),`dist/sections/${s}/js/`),ignore:"**/server.js"})).forEach(async n=>{await e.post("/api/v1/app/resource/upload",{file:C(r(c.cwd(),`dist/sections/${s}/js/${n}`))},{params:{appClientId:t.appClientId,type:"client_js",version:o,block:s,fileName:n},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${t.appSecretKey}`}})})}async function Xt(e,t,o,s){(await l("*",{cwd:r(c.cwd(),`dist/sections/${s}/assets/`)})).forEach(async n=>{await e.post("/api/v1/app/resource/upload",{file:C(r(c.cwd(),`dist/sections/${s}/assets/${n}`))},{params:{appClientId:t.appClientId,type:"assets",version:o,block:s,fileName:n},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${t.appSecretKey}`}})})}async function Ft(e,t,o){(await l("package.json")).at(0)!==void 0&&await e.post("/api/v1/app/resource/upload",{file:C(r(c.cwd(),"package.json"))},{params:{appClientId:t.appClientId,type:"dependencies",version:o},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${t.appSecretKey}`}})}async function qt(e,t,o,s){for(const n of s)await Ut(e,t,o,n.id),await xt(e,t,o,n.id),await Xt(e,t,o,n.id),await Ft(e,t,o)}async function Mt(e,t,o,s,n){await e.post("/api/v1/app/manifest",{version:o,name:"Custom Block App",blocks:s,templates:n},{params:{appClientId:t.appClientId},headers:{Authorization:`Bearer ${t.appSecretKey}`}})}async function zt(e){try{const t=e??Lt,o=Xe.create({baseURL:t}),s=await Dt(),n=await At(),i=await kt(),a=await Pt();await qt(o,s,n,i),await Mt(o,s,n,i,a);const u=i.map(y=>y.id);m.info(`Deploy to ${t} successful
6
+ Current app version: ${n}
7
+ Deployed blocks: ${u.join(", ")}`),a.length>0&&m.info(`Deployed templates: ${a.map(y=>y.id).join(", ")}`)}catch(t){m.error(`Error while deploying: ${t.message}`)}}const Kt="0.1.0",p=Ae("crane");function Jt(){p.command("init","Initialize a new resource in the form of a directory.").option("--app <name>","Creates an app folder inside your current directory.").option("--section <name>","Creates the files necessary for one custom section with the given name, this can be repeated for each section.").option("--template <name>","Creates the directory and files necessary to build a custom template inside your app folder.").action(e=>{if(e.app)return F(e.app);if(e.section)return q(e.section);if(e.template)return M(e.template);p.outputHelp()}),p.command("build","Builds your resource code").action(pt),p.command("deploy","Deploys your resource code into Ecwid"),p.on("command:*",()=>{console.error("Invalid command: %s",p.args.join(" ")),p.outputHelp(),process.exit(1)}),p.on("command:init",()=>{const e=p.options.section,t=p.options.app,o=p.options.template;_(t)?G("app",j("init --app <name>"),F):_(e)?G("section",j("init --section <name>"),q):_(o)&&G("template",j("init --template <name>"),M)}),p.on("command:deploy",()=>zt(p.options.url)),p.help(),p.usage("<action> <resource>"),p.version(Kt),p.parse()}try{Jt()}catch{}async function G(e,t,o){const s=`You can use ${t} to directly specify the name of the ${e}.`;console.log(s);const n=await Me({type:"text",name:"name",message:`Please specify a name for your ${e}:`});if(n.name)return o(n.name);console.log("Please provide a name for the template."),p.outputHelp()}function _(e){return e&&(typeof e!="string"||e.trim().length==0)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightspeed/crane",
3
- "version": "0.0.1-beta.23",
3
+ "version": "0.1.0",
4
4
  "type": "module",
5
5
  "bin": "bin/crane.js",
6
6
  "main": "./dist/app.mjs",
@@ -26,27 +26,35 @@
26
26
  "build": "unbuild",
27
27
  "lint": "eslint \"./{src,test}/**/*.{js,ts}\""
28
28
  },
29
+ "engines": {
30
+ "node": ">=20"
31
+ },
29
32
  "devDependencies": {
30
33
  "@types/fs-extra": "^11.0.1",
31
34
  "@types/node": "^20.4.5",
35
+ "typescript": "5.4.5",
32
36
  "unbuild": "^2.0.0",
33
37
  "vite-plugin-dts": "^3.4.0",
34
38
  "vite-plugin-static-copy": "^0.17.0"
35
39
  },
36
40
  "dependencies": {
37
- "@lightspeed/eslint-config-crane": "0.0.1-beta.2",
41
+ "@jridgewell/sourcemap-codec": "^1.4.15",
42
+ "@lightspeed/eslint-config-crane": "0.1.0",
43
+ "@types/prompts": "^2.4.2",
38
44
  "@vitejs/plugin-vue": "^4.1.0",
45
+ "ajv": "^8.12.0",
46
+ "ajv-formats": "^2.1.1",
39
47
  "axios": "^1.4.0",
40
48
  "cac": "^6.7.14",
41
- "eslint": "~8.15.0",
49
+ "eslint": "npm:eslint-customized-for-crane@8.57.0",
42
50
  "fs-extra": "^11.1.1",
43
- "glob": "^10.3.3",
51
+ "glob": "^9.3.5",
44
52
  "kolorist": "^1.8.0",
45
53
  "prompts": "^2.4.2",
46
54
  "semver": "^7.5.4",
47
55
  "tinycolor2": "^1.6.0",
48
- "typescript": "^5.3.0",
49
- "vite": "^5.1.0",
56
+ "typescript": "5.4.5",
57
+ "vite": "^5.3.3",
50
58
  "vite-plugin-checker": "^0.6.1",
51
59
  "vite-plugin-externals": "^0.6.2",
52
60
  "vite-tsconfig-paths": "^4.2.0",
@@ -55,5 +63,13 @@
55
63
  },
56
64
  "peerDependencies": {
57
65
  "vue": "^3.4.0"
66
+ },
67
+ "overrides": {
68
+ "eslint": {
69
+ "file-entry-cache": "8.0.0"
70
+ },
71
+ "magic-string": "0.30.10",
72
+ "glob": "^9.3.5",
73
+ "stylus": "^0.63.0"
58
74
  }
59
75
  }
@@ -7,8 +7,18 @@
7
7
  "deploy": "crane build && crane deploy"
8
8
  },
9
9
  "dependencies": {
10
- "@lightspeed/crane": "0.0.1-beta.23",
11
- "@lightspeed/eslint-config-crane": "0.0.1-beta.2",
10
+ "@lightspeed/crane": "0.1.0",
11
+ "@lightspeed/eslint-config-crane": "0.1.0",
12
12
  "vue": "^3.4.0"
13
+ },
14
+ "engines": {
15
+ "node": ">=20"
16
+ },
17
+ "overrides": {
18
+ "eslint": {
19
+ "file-entry-cache": "8.0.0"
20
+ },
21
+ "glob": "^9.3.5",
22
+ "stylus": "^0.63.0"
13
23
  }
14
24
  }
@@ -7,7 +7,7 @@ import {
7
7
  useToggleElementContent,
8
8
  useSelectboxElementContent,
9
9
  } from '@lightspeed/crane';
10
- import { Content } from './type';
10
+ import { Content } from './type.ts';
11
11
 
12
12
  const inputboxContent = useInputboxElementContent<Content>('inputbox');
13
13
  const textareaContent = useTextareaElementContent<Content>('textarea');
@@ -30,6 +30,7 @@ const selectboxContent = useSelectboxElementContent<Content>('selectbox');
30
30
  </h1>
31
31
  </div>
32
32
  <div>
33
+ <!-- eslint-disable vue/html-button-has-type -->
33
34
  <button
34
35
  v-if="buttonContent.hasTitle"
35
36
  @click="buttonContent.performAction"
@@ -1,5 +1,5 @@
1
1
  import { createVueClientApp } from '@lightspeed/crane';
2
2
  import CustomBlock from './CustomBlock.vue';
3
- import { Content, Design } from './type';
3
+ import { Content, Design } from './type.ts';
4
4
 
5
5
  export default createVueClientApp<Content, Design>(CustomBlock);
@@ -1,5 +1,5 @@
1
1
  import { createVueServerApp } from '@lightspeed/crane';
2
2
  import CustomBlock from './CustomBlock.vue';
3
- import { Content, Design } from './type';
3
+ import { Content, Design } from './type.ts';
4
4
 
5
5
  export default createVueServerApp<Content, Design>(CustomBlock);
@@ -82,4 +82,13 @@ export default {
82
82
  color: 'global.color.background',
83
83
  },
84
84
  },
85
+ color: {
86
+ type: 'COLOR_PICKER',
87
+ label: '$label.colorpicker.label',
88
+ description: '$label.colorpicker.description',
89
+ colors: ['#FFFFFF66', '#0000004D', '#00000099', '#64C7FF66', '#F9947266', '#C794CD66', '#FFD17466'],
90
+ defaults: {
91
+ color: 'global.color.background',
92
+ },
93
+ },
85
94
  } as const;
@@ -0,0 +1,88 @@
1
+ export default {
2
+ showcaseId: '1',
3
+ previewImage: {
4
+ set: {
5
+ ORIGINAL: {
6
+ url: 'showcase_preview_1.png',
7
+ },
8
+ },
9
+ },
10
+ blockName: '$label.showcase_1.blockName',
11
+ content: {
12
+ inputbox: {
13
+ type: 'INPUTBOX',
14
+ text: '$label.showcase_1.inputbox.text',
15
+ },
16
+ textarea: {
17
+ type: 'TEXTAREA',
18
+ text: '$label.showcase_1.textarea.text',
19
+ },
20
+ button: {
21
+ type: 'BUTTON',
22
+ title: '$label.showcase_1.button.title',
23
+ buttonType: 'MAIL_LINK',
24
+ email: 'from@showcase.one.com',
25
+ },
26
+ image: {
27
+ type: 'IMAGE',
28
+ imageData: {
29
+ set: {
30
+ ORIGINAL: {
31
+ url: 'showcase_preview_1.png',
32
+ },
33
+ },
34
+ borderInfo: {},
35
+ },
36
+ },
37
+ toggle: {
38
+ type: 'TOGGLE',
39
+ enabled: true,
40
+ },
41
+ selectbox: {
42
+ type: 'SELECTBOX',
43
+ value: 'one',
44
+ },
45
+ },
46
+ design: {
47
+ inputbox: {
48
+ type: 'TEXT',
49
+ font: 'global.fontFamily.body',
50
+ size: 18,
51
+ bold: true,
52
+ italic: false,
53
+ color: '#333',
54
+ visible: false,
55
+ },
56
+ button: {
57
+ type: 'BUTTON',
58
+ font: 'global.fontFamily.body',
59
+ size: 'MEDIUM',
60
+ appearance: 'OUTLINE',
61
+ shape: 'PILL',
62
+ color: '#333',
63
+ visible: false,
64
+ },
65
+ background: {
66
+ type: 'BACKGROUND',
67
+ style: 'COLOR',
68
+ color: 'global.color.background',
69
+ },
70
+ image: {
71
+ type: 'IMAGE',
72
+ overlay: 'COLOR',
73
+ color: '#333',
74
+ },
75
+ toggle: {
76
+ type: 'TOGGLE',
77
+ enabled: true,
78
+ },
79
+ color: {
80
+ type: 'COLOR_PICKER',
81
+ color: 'global.color.background',
82
+ },
83
+ selectbox: {
84
+ type: 'SELECTBOX',
85
+ value: 'one',
86
+ },
87
+ },
88
+ } as const;
@@ -0,0 +1,88 @@
1
+ export default {
2
+ showcaseId: '2',
3
+ previewImage: {
4
+ set: {
5
+ ORIGINAL: {
6
+ url: 'showcase_preview_1.png',
7
+ },
8
+ },
9
+ },
10
+ blockName: '$label.showcase_2.blockName',
11
+ content: {
12
+ inputbox: {
13
+ type: 'INPUTBOX',
14
+ text: '$label.showcase_2.inputbox.text',
15
+ },
16
+ textarea: {
17
+ type: 'TEXTAREA',
18
+ text: '$label.showcase_2.textarea.text',
19
+ },
20
+ button: {
21
+ type: 'BUTTON',
22
+ title: '$label.showcase_2.button.title',
23
+ buttonType: 'MAIL_LINK',
24
+ email: 'from@showcase.two.com',
25
+ },
26
+ image: {
27
+ type: 'IMAGE',
28
+ imageData: {
29
+ set: {
30
+ ORIGINAL: {
31
+ url: 'showcase_preview_2.png',
32
+ },
33
+ },
34
+ borderInfo: {},
35
+ },
36
+ },
37
+ toggle: {
38
+ type: 'TOGGLE',
39
+ enabled: false,
40
+ },
41
+ selectbox: {
42
+ type: 'SELECTBOX',
43
+ value: 'two',
44
+ },
45
+ },
46
+ design: {
47
+ inputbox: {
48
+ type: 'TEXT',
49
+ font: 'global.fontFamily.body',
50
+ size: 18,
51
+ bold: true,
52
+ italic: false,
53
+ color: '#333',
54
+ visible: false,
55
+ },
56
+ button: {
57
+ type: 'BUTTON',
58
+ font: 'global.fontFamily.body',
59
+ size: 'MEDIUM',
60
+ appearance: 'OUTLINE',
61
+ shape: 'PILL',
62
+ color: '#333',
63
+ visible: false,
64
+ },
65
+ background: {
66
+ type: 'BACKGROUND',
67
+ style: 'COLOR',
68
+ color: 'global.color.background',
69
+ },
70
+ image: {
71
+ type: 'IMAGE',
72
+ overlay: 'COLOR',
73
+ color: '#333',
74
+ },
75
+ toggle: {
76
+ type: 'TOGGLE',
77
+ enabled: true,
78
+ },
79
+ color: {
80
+ type: 'COLOR_PICKER',
81
+ color: 'global.color.background',
82
+ },
83
+ selectbox: {
84
+ type: 'SELECTBOX',
85
+ value: 'one',
86
+ },
87
+ },
88
+ } as const;
@@ -0,0 +1,23 @@
1
+ export default {
2
+ en: {
3
+ '$label.showcase_1.blockName': 'Name of block 1',
4
+ '$label.showcase_1.inputbox.text': 'Input text 1',
5
+ '$label.showcase_1.textarea.text': 'Textarea 1',
6
+ '$label.showcase_1.button.title': 'Button 1',
7
+ '$label.showcase_2.blockName': 'Name of block 2',
8
+ '$label.showcase_2.inputbox.text': 'Input text 2',
9
+ '$label.showcase_2.textarea.text': 'Textarea 2',
10
+ '$label.showcase_2.button.title': 'Button 2',
11
+ },
12
+
13
+ ru: {
14
+ '$label.showcase_1.blockName': 'Имя блока 1',
15
+ '$label.showcase_1.inputbox.text': 'Введите текст 1',
16
+ '$label.showcase_1.textarea.text': 'Многострочный текст 1',
17
+ '$label.showcase_1.button.title': 'Кнопка 1',
18
+ '$label.showcase_2.blockName': 'Имя блока 2',
19
+ '$label.showcase_2.inputbox.text': 'Введите текст 2',
20
+ '$label.showcase_2.textarea.text': 'Многострочный текст 2',
21
+ '$label.showcase_2.button.title': 'Кнопка 2',
22
+ },
23
+ } as const;
@@ -1,5 +1,5 @@
1
- import ContentSettings from './settings/content';
2
- import DesignSettings from './settings/design';
1
+ import ContentSettings from './settings/content.ts';
2
+ import DesignSettings from './settings/design.ts';
3
3
 
4
4
  export type Content = InferContentType<typeof ContentSettings>;
5
5
  export type Design = InferDesignType<typeof DesignSettings>;
@@ -0,0 +1,158 @@
1
+ export default {
2
+ metadata: {
3
+ name: 'Example Template :: Standard Preset',
4
+ description: 'Standard Preset for the Example template',
5
+ url: {
6
+ demo_website: 'https://www.example.com',
7
+ cover_image: 'https://www.example.com/cover.jpg'
8
+ }
9
+ },
10
+ sections: [
11
+ {
12
+ type: 'default',
13
+ id: 'header'
14
+ },
15
+ {
16
+ type: 'default',
17
+ id: 'slider_001'
18
+ },
19
+ {
20
+ type: 'custom',
21
+ id: 'block-example'
22
+ },
23
+ {
24
+ type: 'custom',
25
+ id: 'block-example',
26
+ content: {
27
+ inputbox: {
28
+ type: 'INPUTBOX',
29
+ label: '$label.inputbox.label',
30
+ placeholder: '$label.inputbox.placeholder',
31
+ },
32
+ textarea: {
33
+ type: 'TEXTAREA',
34
+ label: '$label.textarea.label',
35
+ placeholder: '$label.textarea.placeholder',
36
+ },
37
+ button: {
38
+ type: 'BUTTON',
39
+ label: '$label.button.label',
40
+ },
41
+ image: {
42
+ type: 'IMAGE',
43
+ label: '$label.image.label',
44
+ },
45
+ toggle: {
46
+ type: 'TOGGLE',
47
+ label: '$label.toggle.label',
48
+ description: '$label.toggle.description',
49
+ },
50
+ selectbox: {
51
+ type: 'SELECTBOX',
52
+ label: '$label.selectbox.label',
53
+ placeholder: '$label.selectbox.placeholder',
54
+ description: '$label.selectbox.description',
55
+ options: [
56
+ {
57
+ value: 'one',
58
+ label: '$label.selectbox.one.label',
59
+ },
60
+ {
61
+ value: 'two',
62
+ label: '$label.selectbox.two.label',
63
+ }
64
+ ]
65
+ }
66
+ },
67
+ design: {
68
+ inputbox: {
69
+ type: 'TEXT',
70
+ label: '$label.inputbox.label',
71
+ colors: ['#FFFFFF66', '#0000004D', '#00000099', '#64C7FF66', '#F9947266', '#C794CD66', '#FFD17466'],
72
+ sizes: [12, 13, 14, 15, 16, 17, 18, 20],
73
+ defaults: {
74
+ font: 'global.fontFamily.body',
75
+ size: 18,
76
+ bold: true,
77
+ italic: false,
78
+ color: '#333'
79
+ }
80
+ },
81
+ textarea: {
82
+ type: 'TEXT',
83
+ label: '$label.textarea.label',
84
+ colors: ['#FFFFFF66', '#0000004D', '#00000099', '#64C7FF66', '#F9947266', '#C794CD66', '#FFD17466'],
85
+ sizes: [12, 13, 14, 15, 16, 17, 18, 20],
86
+ defaults: {
87
+ font: 'global.fontFamily.body',
88
+ size: 16,
89
+ bold: false,
90
+ italic: true,
91
+ color: '#333'
92
+ }
93
+ },
94
+ button: {
95
+ type: 'BUTTON',
96
+ label: '$label.button.label',
97
+ colors: ['#FFFFFF66', '#0000004D', '#00000099', '#64C7FF66', '#F9947266', '#C794CD66', '#FFD17466'],
98
+ defaults: {
99
+ font: 'global.fontFamily.body',
100
+ size: 'MEDIUM',
101
+ appearance: 'OUTLINE',
102
+ shape: 'PILL',
103
+ color: '#333'
104
+ }
105
+ },
106
+ image: {
107
+ type: 'IMAGE',
108
+ label: '$label.image.label',
109
+ colors: ['#FFFFFF66', '#0000004D', '#00000099', '#64C7FF66', '#F9947266', '#C794CD66', '#FFD17466'],
110
+ defaults: {
111
+ overlay: 'COLOR',
112
+ color: '#333'
113
+ }
114
+ },
115
+ toggle: {
116
+ type: 'TOGGLE',
117
+ label: '$label.toggle.label',
118
+ description: '$label.toggle.description',
119
+ defaults: {
120
+ enabled: true
121
+ }
122
+ },
123
+ selectbox: {
124
+ type: 'SELECTBOX',
125
+ label: '$label.selectbox.label',
126
+ placeholder: '$label.selectbox.placeholder',
127
+ description: '$label.selectbox.description',
128
+ options: [
129
+ {
130
+ value: 'one',
131
+ label: '$label.selectbox.one.label',
132
+ },
133
+ {
134
+ value: 'two',
135
+ label: '$label.selectbox.two.label',
136
+ }
137
+ ],
138
+ defaults: {
139
+ value: 'two'
140
+ }
141
+ },
142
+ background: {
143
+ type: 'BACKGROUND',
144
+ label: '$label.background.label',
145
+ colors: ['#FFFFFF66', '#0000004D', '#00000099', '#64C7FF66', '#F9947266', '#C794CD66', '#FFD17466'],
146
+ defaults: {
147
+ style: 'COLOR',
148
+ color: 'global.color.background'
149
+ }
150
+ }
151
+ }
152
+ },
153
+ {
154
+ type: 'default',
155
+ id: 'footer'
156
+ }
157
+ ]
158
+ }
package/types.d.ts CHANGED
@@ -16,7 +16,7 @@ type ButtonType =
16
16
 
17
17
  interface ButtonContentData {
18
18
  readonly title: string;
19
- readonly type: ButtonType;
19
+ readonly buttonType: ButtonType;
20
20
  readonly link?: string;
21
21
  readonly email?: string;
22
22
  readonly phone?: string;
@@ -235,6 +235,7 @@ type MapEditorDesignTypes = {
235
235
  readonly TOGGLE: string;
236
236
  readonly SELECTBOX: string;
237
237
  readonly BACKGROUND: string;
238
+ readonly COLOR_PICKER: string;
238
239
  };
239
240
 
240
241
  interface TextDesignEditor {
@@ -273,13 +274,19 @@ interface BackgroundDesignEditor {
273
274
  defaults: Record<string, unknown>;
274
275
  }
275
276
 
277
+ interface ColorPickerDesignEditor {
278
+ readonly type: 'COLOR_PICKER';
279
+ defaults: Record<string, unknown>;
280
+ }
281
+
276
282
  type DesignEditor =
277
283
  TextDesignEditor
278
284
  | ButtonDesignEditor
279
285
  | ImageDesignEditor
280
286
  | ToggleDesignEditor
281
287
  | SelectboxDesignEditor
282
- | BackgroundDesignEditor;
288
+ | BackgroundDesignEditor
289
+ | ColorPickerDesignEditor;
283
290
 
284
291
  type InferDesignType<T extends Record<string, DesignEditor>> = {
285
292
  readonly [P in keyof T]: MapEditorDesignTypes[T[P]['type']]
@@ -1,159 +0,0 @@
1
- {
2
- "$schema": "template.schema.json",
3
- "metadata": {
4
- "name": "Example Template :: Standard Preset",
5
- "description": "Standard Preset for the Example template",
6
- "url": {
7
- "demo_website": "https://www.example.com",
8
- "cover_image": "https://www.example.com/cover.jpg"
9
- }
10
- },
11
- "sections": [
12
- {
13
- "type": "default",
14
- "id": "header"
15
- },
16
- {
17
- "type": "default",
18
- "id": "slider_001"
19
- },
20
- {
21
- "type": "custom",
22
- "id": "example-block"
23
- },
24
- {
25
- "type": "custom",
26
- "id": "example-block",
27
- "content": {
28
- "inputbox": {
29
- "type": "INPUTBOX",
30
- "label": "$label.example.label",
31
- "placeholder": "$label.example.placeholder"
32
- },
33
- "textarea": {
34
- "type": "TEXTAREA",
35
- "label": "$label.example.label",
36
- "placeholder": "$label.example.placeholder"
37
- },
38
- "button": {
39
- "type": "BUTTON",
40
- "label": "$label.example.label"
41
- },
42
- "image": {
43
- "type": "IMAGE",
44
- "label": "$label.example.label"
45
- },
46
- "toggle": {
47
- "type": "TOGGLE",
48
- "label": "$label.example.label",
49
- "description": "$label.example.description"
50
- },
51
- "selectBox": {
52
- "type": "SELECTBOX",
53
- "label": "$label.example.label",
54
- "placeholder": "$label.example.placeholder",
55
- "description": "$label.example.description",
56
- "options": [
57
- {
58
- "value": "one",
59
- "label": "$label.example.one.label"
60
- },
61
- {
62
- "value": "two",
63
- "label": "$label.example.two.label"
64
- }
65
- ]
66
- }
67
- },
68
- "design": {
69
- "inputbox": {
70
- "type": "TEXT",
71
- "label": "$label.example.label",
72
- "colors": ["#FFFFFF66", "#0000004D", "#00000099", "#64C7FF66", "#F9947266", "#C794CD66", "#FFD17466"],
73
- "sizes": [12, 13, 14, 15, 16, 17, 18, 20],
74
- "defaults": {
75
- "font": "global.fontFamily.body",
76
- "size": 18,
77
- "bold": true,
78
- "italic": false,
79
- "color": "#333"
80
- }
81
- },
82
- "textarea": {
83
- "type": "TEXT",
84
- "label": "$label.example.label",
85
- "colors": ["#FFFFFF66", "#0000004D", "#00000099", "#64C7FF66", "#F9947266", "#C794CD66", "#FFD17466"],
86
- "sizes": [12, 13, 14, 15, 16, 17, 18, 20],
87
- "defaults": {
88
- "font": "global.fontFamily.body",
89
- "size": 16,
90
- "bold": false,
91
- "italic": true,
92
- "color": "#333"
93
- }
94
- },
95
- "button": {
96
- "type": "BUTTON",
97
- "label": "$label.example.label",
98
- "colors": ["#FFFFFF66", "#0000004D", "#00000099", "#64C7FF66", "#F9947266", "#C794CD66", "#FFD17466"],
99
- "defaults": {
100
- "font": "global.fontFamily.body",
101
- "size": "MEDIUM",
102
- "appearance": "OUTLINE",
103
- "shape": "PILL",
104
- "color": "#333"
105
- }
106
- },
107
- "image": {
108
- "type": "IMAGE",
109
- "label": "$label.example.label",
110
- "colors": ["#FFFFFF66", "#0000004D", "#00000099", "#64C7FF66", "#F9947266", "#C794CD66", "#FFD17466"],
111
- "defaults": {
112
- "overlay": "COLOR",
113
- "color": "#333"
114
- }
115
- },
116
- "toggle": {
117
- "type": "TOGGLE",
118
- "label": "$label.example.label",
119
- "description": "$label.example.description",
120
- "defaults": {
121
- "enabled": true
122
- }
123
- },
124
- "selectbox": {
125
- "type": "SELECTBOX",
126
- "label": "$label.example.label",
127
- "placeholder": "$label.example.placeholder",
128
- "description": "$label.example.description",
129
- "options": [
130
- {
131
- "value": "one",
132
- "label": "$label.example.one.label"
133
- },
134
- {
135
- "value": "two",
136
- "label": "$label.example.two.label"
137
- }
138
- ],
139
- "defaults": {
140
- "value": "two"
141
- }
142
- },
143
- "background": {
144
- "type": "BACKGROUND",
145
- "label": "$label.example.label",
146
- "colors": ["#FFFFFF66", "#0000004D", "#00000099", "#64C7FF66", "#F9947266", "#C794CD66", "#FFD17466"],
147
- "defaults": {
148
- "style": "COLOR",
149
- "color": "global.color.background"
150
- }
151
- }
152
- }
153
- },
154
- {
155
- "type": "default",
156
- "id": "footer"
157
- }
158
- ]
159
- }