@lightspeed/crane 1.0.3 → 1.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.
Files changed (29) hide show
  1. package/dist/cli.mjs +11 -6
  2. package/package.json +3 -2
  3. package/template/footers/example-footer/ExampleFooter.vue +17 -0
  4. package/template/footers/example-footer/assets/example_footer_showcase_1_preview.png +0 -0
  5. package/template/footers/example-footer/assets/sample_image.jpg +0 -0
  6. package/template/footers/example-footer/client.ts +5 -0
  7. package/template/footers/example-footer/component/SampleComponent.vue +11 -0
  8. package/template/footers/example-footer/server.ts +5 -0
  9. package/template/footers/example-footer/showcases/1.ts +11 -0
  10. package/template/footers/example-footer/type.ts +5 -0
  11. package/template/footers/settings/content.ts +1 -0
  12. package/template/footers/settings/design.ts +1 -0
  13. package/template/footers/settings/layout.ts +1 -0
  14. package/template/footers/settings/translations.ts +5 -0
  15. package/template/headers/example-header/ExampleHeader.vue +17 -0
  16. package/template/headers/example-header/assets/example_header_showcase_1_preview.png +0 -0
  17. package/template/headers/example-header/assets/sample_image.jpg +0 -0
  18. package/template/headers/example-header/client.ts +5 -0
  19. package/template/headers/example-header/component/SampleComponent.vue +11 -0
  20. package/template/headers/example-header/server.ts +5 -0
  21. package/template/headers/example-header/showcases/1.ts +0 -0
  22. package/template/headers/example-header/type.ts +5 -0
  23. package/template/headers/settings/content.ts +1 -0
  24. package/template/headers/settings/design.ts +1 -0
  25. package/template/headers/settings/layout.ts +1 -0
  26. package/template/headers/settings/translations.ts +5 -0
  27. package/template/package.json +1 -1
  28. package/template/sections/example-section/showcases/translations.ts +2 -0
  29. package/template/templates/template.ts +137 -118
package/dist/cli.mjs CHANGED
@@ -1,7 +1,12 @@
1
- import Ue from"cac";import h from"node:fs";import $ from"node:path";import{fileURLToPath as _}from"node:url";import*as L from"fs";import{rename as Me,unlink as Xe,existsSync as N,statSync as Fe,writeFileSync as qe,createReadStream as ze}from"fs";import*as D from"path";import{resolve as l,parse as P,dirname as Ke,sep as Je}from"path";import{red as He,yellow as Ve,green as I}from"kolorist";import{glob as m,globSync as X}from"glob";import{build as F,defineConfig as q}from"vite";import{pathToFileURL as j}from"url";import{builtinModules as z}from"module";import K from"@vitejs/plugin-vue";import G from"vite-tsconfig-paths";import We from"vite-plugin-checker";import{viteExternalsPlugin as Ze}from"vite-plugin-externals";import Ye from"ajv/dist/2020.js";import Qe from"ajv-formats";import*as d from"process";import{readFile as J}from"fs/promises";import et from"axios";import{inc as tt}from"semver";import ot from"tinycolor2";import st from"prompts";function H(e,t){L.statSync(e).isDirectory()?(L.mkdirSync(t,{recursive:!0}),L.readdirSync(e).forEach(o=>{const s=D.resolve(e,o),n=D.resolve(t,o);H(s,n)})):L.copyFileSync(e,t)}function x(e,t,o,s){const n=D.join(e,s?.[o]??o);H(D.join(t,o),n)}function V(e,t=2){if(!+e)return"0 Bytes";const o=1024,s=t<0?0:t,n=["Bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],i=Math.floor(Math.log(e)/Math.log(o));return`${parseFloat((e/Math.pow(o,i)).toFixed(s))} ${n[i]}`}const c={error:e=>console.log(He(e)),warn:e=>console.log(Ve(e)),info:e=>console.log(I(e))},O="_temp",r="dist/sections",v="dist/templates",W=2*1024*1024;function k(e){return!!e}async function Z(e){try{const t=e,o=process.cwd(),s=$.join(o,t),n=["templates"],i={_gitignore:".gitignore"};if(!h.existsSync(s))h.mkdirSync(s);else{c.error(`App with the name: ${e} already exists. If you'd like to override it, delete previous version first`);return}const a=$.resolve(_(import.meta.url),"../..","template");h.readdirSync(a).filter(w=>w!=="package.json").filter(w=>!n.includes(w)).forEach(async w=>x(s,a,w,i));const u=JSON.parse(h.readFileSync($.join(a,"package.json"),"utf-8"));u.name=e;const b=$.join(s,"package.json");h.writeFileSync(b,`${JSON.stringify(u,null,2)}
2
- `),c.info(`App ${e} created`)}catch(t){c.error(`Error while creating app: ${t.message}`)}}async function Y(e){try{const t=e,o=process.cwd(),s=$.join(o,"sections",t);if(!h.existsSync(s))h.mkdirSync(s);else{c.error(`Section with the name: ${e} already exists. If you'd like to override it, delete previous version first`);return}const n=$.resolve(_(import.meta.url),"../..","template/sections/example-section");h.readdirSync(n).forEach(async i=>x(s,n,i)),c.info(`Section ${e} created`)}catch(t){c.error(`Error while creating section: ${t.message}`)}}async function Q(e){try{const t=process.cwd(),o=$.join(t,"templates"),s={"template.ts":`${e}.ts`};if(!h.existsSync(o))h.mkdirSync(o);else if(h.existsSync($.join(o,`${e}.ts`))){c.error(`Template with the name: ${e} already exists. If you'd like to override it, delete previous version first`);return}const n=$.resolve(_(import.meta.url),"../..","template/templates");h.readdirSync(n).forEach(async i=>x(o,n,i,s)),c.info(`Template descriptor file [${e}.ts] has been created`)}catch(t){c.error(`Error while creating template descriptors: ${t.message}`)}}var f=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.SectionSetting=2]="SectionSetting",e[e.SectionShowcase=3]="SectionShowcase",e[e.SectionAsset=4]="SectionAsset",e[e.TemplateDescriptor=5]="TemplateDescriptor",e[e.TemplateAsset=6]="TemplateAsset",e))(f||{}),g=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.Misc=2]="Misc",e))(g||{});const nt={[g.Server]:[K(),G()],[g.Client]:[K(),G(),te(),Ze({vue:"EcVue"})],[g.Misc]:[G(),te()]},ee={"process.env":{NODE_ENV:"production"}},E={[f.Server]:{pluginType:g.Server,define:ee,ssr:!0,ssrOptions:{noExternal:!0},outDir:e=>`./${r}/${e}/js/main/server`,externalOption:[...z,...z.map(e=>`node:${e}`)],entryFileNames:"[name].js"},[f.Client]:{pluginType:g.Client,define:ee,ssr:!1,outDir:e=>`./${r}/${e}/js/main/client`,entryFileNames:"[name].js",chunkFileNames:"[name].js",assetFileNames:"assets/[name].[ext]"},[f.SectionSetting]:{pluginType:g.Misc,ssr:!1,outDir:e=>`./${r}/${e}/js/settings`,entryFileNames:"[name].mjs"},[f.SectionShowcase]:{pluginType:g.Misc,ssr:!1,outDir:e=>`./${r}/${e}/js/showcases`,entryFileNames:"[name].mjs"},[f.SectionAsset]:{pluginType:g.Misc,ssr:!1,outDir:e=>`./${r}/${e}/assets`,assetFileNames:"[name].[ext]"},[f.TemplateDescriptor]:{pluginType:g.Misc,ssr:!1,outDir:()=>`./${v}/js`,entryFileNames:`[name]${O}.mjs`},[f.TemplateAsset]:{pluginType:g.Misc,ssr:!1,outDir:()=>`./${v}/assets`,assetFileNames:"[name].[ext]"}};function it(e){switch(typeof e){case"string":return[l(process.cwd(),e)];case"object":return e.map(t=>l(process.cwd(),t));default:return[]}}function te(){const e=process.env.npm_lifecycle_event;return We({typescript:!0,vueTsc:!1,eslint:{lintCommand:`eslint --max-warnings=0 "./sections/**/*.{js,ts,vue}" --cache --cache-location "./build/eslintcache/${e}.json"`}})}function oe(e,t,o){const s=E[o].define,n=E[o].ssrOptions,i=E[o].externalOption,a=E[o].entryFileNames,u=E[o].chunkFileNames,b=E[o].assetFileNames;return{plugins:nt[E[o].pluginType],...s!=null&&{define:s},...n!=null&&{ssr:n},resolve:{alias:{"@":"/src"}},build:{ssr:E[o].ssr,outDir:E[o].outDir(e),emptyOutDir:!0,rollupOptions:{...i!=null&&{external:i},preserveEntrySignatures:"strict",input:it(t),output:{validate:!0,...a!=null&&{entryFileNames:a},...u!=null&&{chunkFileNames:u},...b!=null&&{assetFileNames:b}}}}}}const se="https://json-schema.org/draft/2020-12/schema",ne="https://lightspeedhq.com/template.schema.json",ie="Custom Template",re="A custom template enclosing the necessary custom and default blocks",ae="object",ce={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},test_site_id:{description:"Site ID of the demo website",type:"integer"},cover_image:{type:"object",properties:{set:{description:"Name of the image set",type:"object",patternProperties:{".*":{type:"object",properties:{url:{description:"Path to the preview image relative to the 'assets' folder for a specific resolution",type:"string"}},required:["url"],additionalProperties:!1}}}},required:["set"],additionalProperties:!1}},required:["name","description","test_site_id","cover_image"],additionalProperties:!1},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}},pe=["metadata","sections"],rt={$schema:se,$id:ne,title:ie,description:re,type:ae,properties:ce,required:pe},le={__proto__:null,$id:ne,$schema:se,default:rt,description:re,properties:ce,required:pe,title:ie,type:ae},de="https://json-schema.org/draft/2020-12/schema",fe="https://lightspeedhq.com/template-default.schema.json",ue="Default Section",me="Default section for a Custom Template",ye="object",he={"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}},at={$schema:de,$id:fe,title:ue,description:me,type:ye,$defs:he},ct={__proto__:null,$defs:he,$id:fe,$schema:de,default:at,description:me,title:ue,type:ye},ge="https://json-schema.org/draft/2020-12/schema",$e="https://lightspeedhq.com/template-custom.schema.json",Ee="Custom Section",Te="Custom section for a Custom Template",be="object",we={"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}},pt={$schema:ge,$id:$e,title:Ee,description:Te,type:be,$defs:we},lt={__proto__:null,$defs:we,$id:$e,$schema:ge,default:pt,description:Te,title:Ee,type:be},je="https://json-schema.org/draft/2020-12/schema",Oe="https://lightspeedhq.com/template-custom-content.schema.json",ve="Custom Section :: Content Configuration",Se="Content tab configuration of a Custom Section for a Custom Template",Ce="object",Ae={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}},dt={$schema:je,$id:Oe,title:ve,description:Se,type:Ce,$defs:Ae},ft={__proto__:null,$defs:Ae,$id:Oe,$schema:je,default:dt,description:Se,title:ve,type:Ce},Le="https://json-schema.org/draft/2020-12/schema",Ne="https://lightspeedhq.com/template-custom-design.schema.json",De="Custom Section :: Design Configuration",Pe="Design tab configuration of a Custom Section for a Custom Template",Ie="object",_e={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:100},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]{6}|[a-fA-F0-9]{3})$"},visible:{description:"Default visibility for the text",type:"boolean"}},required:["font","size","bold","italic","color","visible"],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}},ut={$schema:Le,$id:Ne,title:De,description:Pe,type:Ie,$defs:_e},mt={__proto__:null,$defs:_e,$id:Ne,$schema:Le,default:ut,description:Pe,title:De,type:Ie};async function yt(){const e=await m("**/server.{js,ts}",{ignore:["node_modules/**","dist/**"]});return Promise.all(e.map(async t=>{const o=Ke(t).split(Je).pop()??"default",s=await m(`**/${o}/client.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),n=await m(`**/${o}/settings/content.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),i=await m(`**/${o}/settings/design.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),a=await m(`**/${o}/settings/layout.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),u=await m(`**/${o}/settings/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),b=await m(`**/${o}/showcases/*.{js,ts}`,{ignore:["node_modules/**","dist/**",`**/${o}/showcases/translations.{js,ts}`]}),w=await m(`**/${o}/showcases/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),Re=await m(`**/${o}/assets/*`,{ignore:["node_modules/**","dist/**"]});return{name:o,serverEntrypoint:t,clientEntrypoint:s.at(0),contentSettingsEntrypoint:n.at(0),designSettingsEntrypoint:i.at(0),layoutSettingsEntrypoint:a.at(0),settingsTranslationsEntrypoint:u.at(0),showcasesEntrypoints:b,showcasesTranslationsEntrypoint:w.at(0),assetsEntrypoints:Re}}))}async function ht(){const e=await m("**/templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]}),t=await m("**/templates/assets/*",{ignore:["node_modules/**","dist/**"]});return{templates:e,assets:t}}async function B(e,t){try{const o=l(d.cwd(),t?`${e}${O}.mjs`:`${e}.mjs`);return(await import(j(o).href)).default}catch{throw new Error(`File [${e}${O}.mjs] is either invalid or undefined`)}}async function gt(){let e=new Ye({allErrors:!0,schemas:[le,ct,lt,ft,mt]});return Qe(e),e.compile(le)}async function $t(e,t,o,s){if(e(t)&&s===void 0)new Promise(n=>{Me(`${o}${O}.mjs`,`${o}.mjs`,function(i){i&&n(i)})});else throw new Promise(n=>{Xe(`${o}${O}.mjs`,function(i){i&&n(i)})}),new Error(`Invalid file [${P(o).name}].
1
+ import We from"cac";import h from"node:fs";import T from"node:path";import{fileURLToPath as P}from"node:url";import*as _ from"fs";import{rmSync as Ve,rename as Ye,unlink as Qe,existsSync as S,statSync as et,writeFileSync as tt,createReadStream as st}from"fs";import*as D from"path";import{resolve as m,parse as I,dirname as ot,sep as nt}from"path";import{red as it,yellow as rt,green as x}from"kolorist";import*as z from"node:process";import w from"node:process";import{glob as u,globSync as K}from"glob";import{build as J,defineConfig as H}from"vite";import{pathToFileURL as v}from"url";import{builtinModules as Z}from"module";import W from"@vitejs/plugin-vue";import R from"vite-tsconfig-paths";import at from"vite-plugin-checker";import{viteExternalsPlugin as ct}from"vite-plugin-externals";import pt from"ajv/dist/2020.js";import lt from"ajv-formats";import{readFile as V}from"fs/promises";import dt,{AxiosError as Y}from"axios";import{inc as mt}from"semver";import*as l from"process";import{ConcurrencyManager as ft}from"axios-concurrency";import ut from"tinycolor2";import yt from"prompts";function Q(e,t){_.statSync(e).isDirectory()?(_.mkdirSync(t,{recursive:!0}),_.readdirSync(e).forEach(s=>{const o=D.resolve(e,s),n=D.resolve(t,s);Q(o,n)})):_.copyFileSync(e,t)}function k(e,t,s,o){const n=D.join(e,o?.[s]??s);Q(D.join(t,s),n)}function ee(e,t=2){if(!+e)return"0 Bytes";const s=1024,o=t<0?0:t,n=["Bytes","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"],i=Math.floor(Math.log(e)/Math.log(s));return`${parseFloat((e/Math.pow(s,i)).toFixed(o))} ${n[i]}`}const p={error:e=>console.log(it(e)),warn:e=>console.log(rt(e)),info:e=>console.log(x(e))},b="_temp",a="dist/sections",C="dist/templates",te=2*1024*1024;function B(e){return!!e}function se(){const e=["|","/","-","\\"];let t=0;return setInterval(()=>{process.stdout.write(`\r${e[t]}`),t=(t+1)%e.length},100)}function U(e){clearInterval(e),process.stdout.write("\r")}async function oe(e){try{const t=e,s=w.cwd(),o=T.join(s,t),n=["templates"],i={_gitignore:".gitignore"};h.existsSync(o)?(p.error(`App with the name: ${e} already exists. If you'd like to override it, delete previous version first`),w.exit(1)):h.mkdirSync(o);const c=T.resolve(P(import.meta.url),"../..","template");h.readdirSync(c).filter(g=>g!=="package.json").filter(g=>!n.includes(g)).forEach(async g=>k(o,c,g,i));const r=JSON.parse(h.readFileSync(T.join(c,"package.json"),"utf-8"));r.name=e;const E=T.join(o,"package.json");h.writeFileSync(E,`${JSON.stringify(r,null,2)}
2
+ `),p.info(`App ${e} created`)}catch(t){p.error(`Error while creating app: ${t.message}`),w.exit(1)}}async function ne(e){try{const t=e,s=w.cwd(),o=T.join(s,"sections",t);h.existsSync(o)?(p.error(`Section with the name: ${e} already exists. If you'd like to override it, delete previous version first`),w.exit(1)):h.mkdirSync(o);const n=T.resolve(P(import.meta.url),"../..","template/sections/example-section");h.readdirSync(n).forEach(async i=>k(o,n,i)),p.info(`Section ${e} created`)}catch(t){p.error(`Error while creating section: ${t.message}`),w.exit(1)}}async function ie(e){try{const t=w.cwd(),s=T.join(t,"templates"),o={"template.ts":`${e}.ts`};h.existsSync(s)?h.existsSync(T.join(s,`${e}.ts`))&&(p.error(`Template with the name: ${e} already exists. If you'd like to override it, delete previous version first`),w.exit(1)):h.mkdirSync(s);const n=T.resolve(P(import.meta.url),"../..","template/templates");h.readdirSync(n).forEach(async i=>k(s,n,i,o)),p.info(`Template descriptor file [${e}.ts] has been created`)}catch(t){p.error(`Error while creating template descriptors: ${t.message}`),w.exit(1)}}var f=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.SectionSetting=2]="SectionSetting",e[e.SectionShowcase=3]="SectionShowcase",e[e.SectionAsset=4]="SectionAsset",e[e.TemplateDescriptor=5]="TemplateDescriptor",e[e.TemplateAsset=6]="TemplateAsset",e))(f||{}),$=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.Misc=2]="Misc",e))($||{});const ht={[$.Server]:[W(),R()],[$.Client]:[W(),R(),ae(),ct({vue:"EcVue"})],[$.Misc]:[R(),ae()]},re={"process.env":{NODE_ENV:"production"}},j={[f.Server]:{pluginType:$.Server,define:re,ssr:!0,ssrOptions:{noExternal:!0},outDir:e=>`./${a}/${e}/js/main/server`,externalOption:[...Z,...Z.map(e=>`node:${e}`)],entryFileNames:"[name].js"},[f.Client]:{pluginType:$.Client,define:re,ssr:!1,outDir:e=>`./${a}/${e}/js/main/client`,entryFileNames:"[name].js",chunkFileNames:"[name].js",assetFileNames:"assets/[name].[ext]"},[f.SectionSetting]:{pluginType:$.Misc,ssr:!1,outDir:e=>`./${a}/${e}/js/settings`,entryFileNames:"[name].mjs"},[f.SectionShowcase]:{pluginType:$.Misc,ssr:!1,outDir:e=>`./${a}/${e}/js/showcases`,entryFileNames:"[name].mjs"},[f.SectionAsset]:{pluginType:$.Misc,ssr:!1,outDir:e=>`./${a}/${e}/assets`,assetFileNames:"[name].[ext]"},[f.TemplateDescriptor]:{pluginType:$.Misc,ssr:!1,outDir:()=>`./${C}/js`,entryFileNames:`[name]${b}.mjs`},[f.TemplateAsset]:{pluginType:$.Misc,ssr:!1,outDir:()=>`./${C}/assets`,assetFileNames:"[name].[ext]"}};function gt(e){switch(typeof e){case"string":return[m(process.cwd(),e)];case"object":return e.map(t=>m(process.cwd(),t));default:return[]}}function ae(){const e=process.env.npm_lifecycle_event;return at({typescript:!0,vueTsc:!1,eslint:{lintCommand:`eslint --max-warnings=0 "./sections/**/*.{js,ts,vue}" --cache --cache-location "./build/eslintcache/${e}.json"`}})}function ce(e,t,s){const o=j[s].define,n=j[s].ssrOptions,i=j[s].externalOption,c=j[s].entryFileNames,r=j[s].chunkFileNames,E=j[s].assetFileNames;return{plugins:ht[j[s].pluginType],...o!=null&&{define:o},...n!=null&&{ssr:n},resolve:{alias:{"@":"/src"}},build:{ssr:j[s].ssr,outDir:j[s].outDir(e),emptyOutDir:!0,rollupOptions:{...i!=null&&{external:i},preserveEntrySignatures:"strict",input:gt(t),output:{validate:!0,...c!=null&&{entryFileNames:c},...r!=null&&{chunkFileNames:r},...E!=null&&{assetFileNames:E}}}}}}const pe="https://json-schema.org/draft/2020-12/schema",le="https://lightspeedhq.com/template.schema.json",de="Custom Template",me="A custom template enclosing the necessary custom and default blocks",fe="object",ue={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},preview_url:{description:"Preview url of the demo website",type:"string",format:"uri",pattern:"^(https?)://([^.]+?\\.)company\\.site($|/[A-Za-z0-9\\-._~:/?#\\[\\]@!$&'()*+,;=]*)?$"},cover_image:{type:"object",properties:{set:{description:"Name of the image set",type:"object",patternProperties:{".*":{type:"object",properties:{url:{description:"Path to the preview image relative to the 'assets' folder for a specific resolution",type:"string"}},required:["url"],additionalProperties:!1}}}},required:["set"],additionalProperties:!1}},required:["name","description","cover_image"],additionalProperties:!1},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}},ye=["metadata","sections"],$t={$schema:pe,$id:le,title:de,description:me,type:fe,properties:ue,required:ye},he={__proto__:null,$id:le,$schema:pe,default:$t,description:me,properties:ue,required:ye,title:de,type:fe},ge="https://json-schema.org/draft/2020-12/schema",$e="https://lightspeedhq.com/template-default.schema.json",Ee="Default Section",Te="Default section for a Custom Template",we="object",je={"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}},Et={$schema:ge,$id:$e,title:Ee,description:Te,type:we,$defs:je},Tt={__proto__:null,$defs:je,$id:$e,$schema:ge,default:Et,description:Te,title:Ee,type:we},Oe="https://json-schema.org/draft/2020-12/schema",ve="https://lightspeedhq.com/template-custom.schema.json",Se="Custom Section",be="Custom section for a Custom Template",Ce="object",Ae={"custom-section":{type:"object",properties:{type:{description:"Type of the section",type:"string",enum:["custom","default"]},id:{description:"Identification of the section",type:"string"},showcase_id:{description:"Showcase id of the section",type:"string"},showcase_overrides:{type:"object",description:"Overrides for the showcase",properties:{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},layoutId:{description:"Layout ID for the showcase",type:"string"},blockName:{description:"Section name for the showcase",type:"string"}},required:["content","design"]}},required:["type","id"],additionalProperties:!1}},wt={$schema:Oe,$id:ve,title:Se,description:be,type:Ce,$defs:Ae},jt={__proto__:null,$defs:Ae,$id:ve,$schema:Oe,default:wt,description:be,title:Se,type:Ce},Ne="https://json-schema.org/draft/2020-12/schema",Le="https://lightspeedhq.com/template-custom-content.schema.json",_e="Custom Section :: Content Configuration",De="Content tab configuration of a Custom Section for a Custom Template",Ie="object",xe={input_box:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},text:{type:"string"}},required:["type","text"],additionalProperties:!1},text_area:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},text:{type:"string"}},required:["type","text"],additionalProperties:!1},button:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},title:{type:"string"},buttonType:{type:"string",enum:["SCROLL_TO_TILE","HYPER_LINK","MAIL_LINK","TEL_LINK","GO_TO_STORE_LINK","GO_TO_PAGE"]},link:{type:"string",format:"uri"},linkTarget:{type:"string"},email:{type:"string"},phone:{type:"string"},tileId:{type:"string"}},required:["type","title"],additionalProperties:!1},image:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},imageData:{type:"object",properties:{set:{type:"object"},borderInfo:{type:"object"},bucket:{type:"string"}},required:["set"]}},required:["type"],additionalProperties:!1},toggle:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},enabled:{type:"boolean"}},required:["type"],additionalProperties:!1},select_box:{type:"object",properties:{type:{description:"Type of the content configuration element",type:"string",enum:["INPUTBOX","TEXTAREA","BUTTON","IMAGE","TOGGLE","SELECTBOX"]},value:{type:"string"}},required:["type"],additionalProperties:!1}},Ot={$schema:Ne,$id:Le,title:_e,description:De,type:Ie,$defs:xe},vt={__proto__:null,$defs:xe,$id:Le,$schema:Ne,default:Ot,description:De,title:_e,type:Ie},Ge="https://json-schema.org/draft/2020-12/schema",Pe="https://lightspeedhq.com/template-custom-design.schema.json",Re="Custom Section :: Design Configuration",ke="Design tab configuration of a Custom Section for a Custom Template",Be="object",Ue={text:{type:"object",properties:{type:{description:"Type of the text",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},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]{6}|[a-fA-F0-9]{3})$"},visible:{description:"Default visibility for the text",type:"boolean"}},additionalProperties:!1},button:{type:"object",properties:{type:{description:"Type of the button",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},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]{6}|[a-fA-F0-9]{3})$"}},additionalProperties:!1},image:{type:"object",properties:{type:{description:"Type of the image",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},overlay:{description:"Default overlay for the image",type:"string",enum:["COLOR","GRADIENT","NONE"]}},if:{properties:{overlay:{const:"GRADIENT"}}},then:{properties:{color:{description:"Default color for the image",type:"array",items:{type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},minItems:2,maxItems:2}}},else:{properties:{color:{description:"Default color for the image",type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"}}}},toggle:{type:"object",properties:{type:{description:"Type of the toggle",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},enabled:{description:"Default enabled status for the toggle",type:"boolean"}},additionalProperties:!1},select_box:{type:"object",properties:{type:{description:"Type of the checkbox",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},value:{description:"Default option for the checkbox",type:"string"}},additionalProperties:!1},background:{type:"object",properties:{type:{description:"Type of the background",type:"string",enum:["TEXT","BUTTON","IMAGE","TOGGLE","SELECTBOX","BACKGROUND"]},style:{description:"Default style for the background",type:"string",enum:["COLOR","GRADIENT"]}},if:{properties:{style:{const:"GRADIENT"}}},then:{properties:{color:{description:"Default colors for the image",type:"array",items:{type:"string",pattern:"^#([a-fA-F0-9]{8}|[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$"},minItems:2,maxItems:2}}},else:{properties:{color:{description:"Default color for the image",type:"string"}}}}},St={$schema:Ge,$id:Pe,title:Re,description:ke,type:Be,$defs:Ue},bt={__proto__:null,$defs:Ue,$id:Pe,$schema:Ge,default:St,description:ke,title:Re,type:Be};async function Ct(){const e=await u("**/server.{js,ts}",{ignore:["node_modules/**","dist/**","headers/**","footers/**"]});return Promise.all(e.map(async t=>{const s=ot(t).split(nt).pop()??"default",o=await u(`**/${s}/client.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),n=await u(`**/${s}/settings/content.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),i=await u(`**/${s}/settings/design.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),c=await u(`**/${s}/settings/layout.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),r=await u(`**/${s}/settings/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),E=await u(`**/${s}/showcases/*.{js,ts}`,{ignore:["node_modules/**","dist/**",`**/${s}/showcases/translations.{js,ts}`]}),g=await u(`**/${s}/showcases/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),G=await u(`**/${s}/assets/*`,{ignore:["node_modules/**","dist/**"]});return{name:s,serverEntrypoint:t,clientEntrypoint:o.at(0),contentSettingsEntrypoint:n.at(0),designSettingsEntrypoint:i.at(0),layoutSettingsEntrypoint:c.at(0),settingsTranslationsEntrypoint:r.at(0),showcasesEntrypoints:E,showcasesTranslationsEntrypoint:g.at(0),assetsEntrypoints:G}}))}async function At(){const e=await u("./templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]}),t=await u("./templates/assets/*",{ignore:["node_modules/**","dist/**"]});return{templates:e,assets:t}}async function M(e,t){try{const s=m(z.cwd(),t?`${e}${b}.mjs`:`${e}.mjs`);return(await import(v(s).href)).default}catch{throw new Error(`File [${e}${b}.mjs] is either invalid or undefined`)}}async function Nt(){let e=new pt({allErrors:!0,schemas:[he,Tt,jt,vt,bt]});return lt(e),e.compile(he)}async function Lt(e,t,s,o){if(e(t)&&o===void 0)new Promise(n=>{Ye(`${s}${b}.mjs`,`${s}.mjs`,function(i){i&&n(i)})});else throw new Promise(n=>{Qe(`${s}${b}.mjs`,function(i){i&&n(i)})}),new Error(`Invalid file [${I(s).name}].
3
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 Et(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(!N(`${r}/${o.id}`))t.push({instancePath:`/sections/${s}/id`,message:"Custom section must have a corresponding block defined"});else{if(o.content!==void 0)if(!N(`${r}/${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 B(`${r}/${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(!N(`${r}/${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 B(`${r}/${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}function Tt(e){const t=e.reduce((o,s)=>{const n=Fe(s);return n.size>W&&(o[s]=V(n.size)),o},{});if(Object.keys(t).length!==0){const o=Math.max(...Object.keys(t).map(s=>s.length));c.error(`Size of individual assets must not exceed threshold [${V(W)}]!`);for(let s in t)c.error(`File: ${s}`.padEnd(o+10)+`| ${t[s]}`);throw new Error("Invalid asset file size")}}async function bt(){async function e(t,o,s){o.length!==0&&await F({configFile:!1,...q(oe(t,o,s))})}try{const t=await yt().then(s=>s.map(n=>({name:n.name,serverEntrypoint:n.serverEntrypoint,clientEntrypoint:[n.clientEntrypoint].filter(k).flat(),settingsEntryPoints:[n.contentSettingsEntrypoint,n.designSettingsEntrypoint,n.layoutSettingsEntrypoint,n.settingsTranslationsEntrypoint].filter(k),showcaseEntryPoints:[...n.showcasesEntrypoints??[],n.showcasesTranslationsEntrypoint].filter(k),assetEntryPoints:n.assetsEntrypoints??[]})));for(const s of t)Tt(s.assetEntryPoints),await F({configFile:!1,...q(oe(s.name,s.serverEntrypoint,f.Server))}),await e(s.name,s.clientEntrypoint,f.Client),await e(s.name,s.settingsEntryPoints,f.SectionSetting),await e(s.name,s.showcaseEntryPoints,f.SectionShowcase),await e(s.name,s.assetEntryPoints,f.SectionAsset);const o=await ht();if(o.templates.length!==0){const s=await gt();await e(void 0,o.assets,f.TemplateAsset),await e(void 0,o.templates,f.TemplateDescriptor);for(const n of o.templates){const i=`${v}/js/${P(n).name}`,a=await B(i,!0);await $t(s,a,i,await Et(a))}}c.info("Build successful. For deploy run: npx @lightspeed/crane@latest deploy")}catch(t){c.error(`Error while building: ${t.message}`)}}function Ge(e){if(e!==void 0)return e.startsWith("global.")?{type:"GLOBAL_FONT",font:e}:{type:"PRESET_FONT",font:e}}function T(e){if(e===void 0)return;if(e.startsWith("global."))return{type:"GLOBAL_COLOR",raw:e};const t=ot(e);return{type:"STRUCTURED_COLOR",raw:e,hex:t.toHex8String(),hsl:t.toHsl(),rgba:t.toRgb(),auto:!1}}function wt(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 jt={COLOR:"COLOR",GRADIENT:"GRADIENT"};function Ot(e){switch(e){case"COLOR":return"solid";case"GRADIENT":return"gradient";default:throw new Error(`Unknown background type: ${e}. Right options: ${Object.keys(jt)}`)}}function vt(e){const t=e.style,o=e.color,s=Array.isArray(o)?o:[o,o];return e.background={type:Ot(t),solid:{color:T(s.at(0))},gradient:{fromColor:T(s.at(0)),toColor:T(s.at(1))}},e.style=void 0,e.color=void 0,e}const St={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"};function Ct(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(St)}`)}}const At={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"};function Lt(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(At)}`)}}const Nt={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"};function Dt(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(Nt)}`)}}function Pt(e){const t=e.appearance;t!==void 0&&(e.appearance=Ct(t));const o=e.size;o!==void 0&&(e.size=Lt(o));const s=e.shape;s!==void 0&&(e.style=Dt(s),e.shape=void 0);const n=e.font;e.font=Ge(n);const i=e.color;return e.color=T(i),e}const It={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"};function _t(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(It)}`)}}function Gt(e){const t=e.overlay,o=e.color,s=Array.isArray(o)?o:[o,o];return e.overlay={type:_t(t),solid:{color:T(s.at(0))},gradient:{fromColor:T(s.at(0)),toColor:T(s.at(1))}},e.color=void 0,e}function xt(e){const t=e.font;e.font=Ge(t);const o=e.color;e.color=T(o);const s=e.size;return e.size=wt(s),e}function kt(e){const t=e.color;return e.color=T(t),e}function xe(e){Object.keys(e).forEach(t=>{const o=e[t],s=o.type;R(s,o.defaults)})}function Bt(e){e.forEach(t=>{t.type!==void 0&&t.defaults!==void 0&&(R(t.type,t.defaults),t.defaults.type=t.type)})}function Rt(e){Object.keys(e).forEach(t=>{const o=e[t],s=o.type;R(s,o)})}function R(e,t){switch(e){case"TEXT":{xt(t);break}case"BUTTON":{Pt(t);break}case"IMAGE":{Gt(t);break}case"BACKGROUND":{vt(t);break}case"COLOR_PICKER":{kt(t);break}case"TOGGLE":case"SELECTBOX":break;default:throw new Error(`Unknown design editor type: ${e}`)}return t}var y=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.ClientAsset=2]="ClientAsset",e[e.Asset=3]="Asset",e[e.TemplateAsset=4]="TemplateAsset",e[e.Dependency=5]="Dependency",e))(y||{});const S={[y.Server]:{type:"server_js",isSingleton:!0,toPath:e=>`${r}/${e}/js/main/server/`,fileName:"server.js"},[y.Client]:{type:"client_js",isSingleton:!1,toPath:e=>`${r}/${e}/js/main/client/`,fileName:"client.js"},[y.ClientAsset]:{type:"assets",isSingleton:!1,toPath:e=>`${r}/${e}/js/main/client/assets/`,fileName:"*"},[y.Asset]:{type:"assets",isSingleton:!1,toPath:e=>`${r}/${e}/assets/`,fileName:"*"},[y.TemplateAsset]:{type:"template_assets",isSingleton:!1,toPath:()=>`${v}/assets/`,fileName:"*"},[y.Dependency]:{type:"dependencies",isSingleton:!0,toPath:()=>{},fileName:"package.json"}},Ut="https://blockbuster.ecwid.com",Mt="/api/v1/app/resource/upload",Xt="/api/v1/app/manifest";async function Ft(){const e=await J(l(d.cwd(),"crane.config.json")),t=JSON.parse(e.toString());return{appClientId:t.app_client_id,appSecretKey:btoa(t.app_secret_key)}}async function qt(){const e=l(d.cwd(),"package.json"),t=await J(e),o=JSON.parse(t.toString());if(zt(o))return o;throw new Error(`Package file located at path: ${e} does not contain a version field`)}function zt(e){return typeof e=="object"&&e!==null&&"version"in e&&typeof e.version=="string"}async function Kt(e){const t=tt(e.version,"patch");if(t===null)throw Error("Error while incrementing app version");e.version=t,qe(l(d.cwd(),"package.json"),`${JSON.stringify(e,null,2)}
5
- `)}async function Jt(e,t){try{const o=l(d.cwd(),`${r}/${e}/js/settings/content.mjs`),s=(await import(j(o).href)).default;return C(s,t),s}catch{throw new Error(`Content descriptor for section [${e}] is either invalid or undefined`)}}async function Ht(e,t){try{const o=l(d.cwd(),`${r}/${e}/js/settings/design.mjs`),s=(await import(j(o).href)).default;return xe(s),C(s,t),s}catch(o){const s=o;throw new Error(`Design settings is invalid or undefined. Error ${s.stack}`)}}async function Vt(e,t){try{const o=await m("*.mjs",{cwd:l(d.cwd(),`${r}/${e}/js/showcases/`),ignore:"**/translations.mjs"});return Promise.all(o.map(async s=>{const n=l(d.cwd(),`${r}/${e}/js/showcases/${s}`),i=(await import(j(n).href)).default;return Rt(i.design),C(i,t),i}))}catch(o){throw new Error(`Showcases is invalid or undefined. Error ${o}`)}}async function Wt(e){try{const t=l(d.cwd(),`${r}/${e}/js/settings/layout.mjs`),o=(await import(j(t).href)).default;return o.forEach(s=>Bt(s.selectedDesignSettings)),o}catch{throw new Error(`Layout descriptor for section [${e}] is either invalid or undefined`)}}async function ke(e){return await Be(`${r}/${e}/js/settings/translations.mjs`)}async function Zt(e){return await Be(`${r}/${e}/js/showcases/translations.mjs`)}async function Be(e){const t=l(d.cwd(),e),o=(await import(j(t).href)).default;return Qt(o)}function C(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]=Yt(t,n)),typeof n=="object"&&C(n,t)}}}function Yt(e,t){if(!t)return;const o=e[t];return o===void 0?{en:t}:o}function Qt(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 eo(){const e=await m("*/",{cwd:l(d.cwd(),`${r}/`)});return Promise.all(e.map(async t=>{const o=await ke(t),s=await Zt(t),n=await Jt(t,o),i=await Ht(t,o),a=await Vt(t,s),u=await Wt(t);return{id:t,name:{en:t},contentEditors:n,designEditors:i,layouts:u,showcases:a}}))}async function to(e){try{return(await import(j(l(d.cwd(),e)).href)).default}catch{throw new Error(`Template descriptor [${e}] is either invalid or undefined`)}}async function oo(){const e=await m(`${v}/js/**.mjs`,{ignore:[`${v}/js/**${O}.mjs`]});return Promise.all(e.map(async t=>{const o=await to(t),s=o.sections.filter(n=>n.type==="custom");for(const n of s){const i=await ke(n.id);n.content!==void 0&&C(n.content,i),n.design!==void 0&&(xe(n.design),C(n.design,i))}return{id:`${P(d.cwd()).name.replace(/[^a-zA-Z0-9]/g,"_")}_${P(t).name}`,descriptor:o}}))}function so(e){const t=e.pathContext,o=t.toPath(e.currentSection),s=o===void 0?X(t.fileName):X(t.fileName,{cwd:l(d.cwd(),o),ignore:t.ignore});return t.isSingleton?s.splice(0):s}function A(e){const t=so(e),o=e.pathContext.toPath(e.currentSection);return t.map(s=>e.config.axios.post(Mt,{file:ze(l(d.cwd(),o!==void 0?o+s:s))},{params:{appClientId:e.config.app.crane.appClientId,type:e.pathContext.type,version:e.config.app.packageJson.version,...e.currentSection!==void 0&&{block:e.currentSection},...e.pathContext.type!=="dependencies"&&{fileName:s}},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${e.config.app.crane.appSecretKey}`}}).then(n=>n.data))}function no(e){return[...e.app.sections.flatMap(t=>[...A({config:e,currentSection:t.id,pathContext:S[y.Server]}),...A({config:e,currentSection:t.id,pathContext:S[y.Client]}),...A({config:e,currentSection:t.id,pathContext:S[y.ClientAsset]}),...A({config:e,currentSection:t.id,pathContext:S[y.Asset]})]),...A({config:e,pathContext:S[y.Dependency]}),...A({config:e,pathContext:S[y.TemplateAsset]})]}async function io(e){try{return e.axios.post(Xt,{version:e.app.packageJson.version,name:"Custom Block App",blocks:e.app.sections,templates:e.app.templates},{params:{appClientId:e.app.crane.appClientId},headers:{Authorization:`Bearer ${e.app.crane.appSecretKey}`}})}catch(t){c.error(`Error while deploying manifest file: ${t.message}`)}}async function ro(e){try{if(!N(l(d.cwd(),r))){c.error(`Error while deploying: ${r} folder not found`);return}const t=e??Ut;c.info(`Custom application deployment [${t}] :: Started`);const o=et.create({baseURL:t});c.info("Loading configuration files ...");const s=await Promise.all([Ft(),qt(),eo(),oo()]).then(([i,a,u,b])=>({axios:o,app:{crane:i,packageJson:a,sections:u,templates:b}}));c.info("Uploading asset files ..."),await Promise.all(no(s)),c.info("Uploading manifest files ..."),await io(s);const n=s.app.sections.map(i=>i.id);c.info(`Custom application deployment [${t}] :: Successful
6
- Current app version: ${s.app.packageJson.version}
7
- Deployed sections: ${n.join(", ")}`),await Kt(s.app.packageJson),s.app.templates.length>0&&c.info(`Deployed templates: ${s.app.templates.map(i=>i.id).join(", ")}`)}catch(t){c.error(`Error while deploying: ${t.message}`)}}const ao="1.0.3",p=Ue("crane");function co(){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 Z(e.app);if(e.section)return Y(e.section);if(e.template)return Q(e.template);p.outputHelp()}),p.command("build","Builds your resource code").action(bt),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;M(t)?U("app",I("init --app <name>"),Z):M(e)?U("section",I("init --section <name>"),Y):M(o)&&U("template",I("init --template <name>"),Q)}),p.on("command:deploy",()=>ro(p.options.url)),p.help(),p.usage("<action> <resource>"),p.version(ao),p.parse()}try{co()}catch{}async function U(e,t,o){const s=`You can use ${t} to directly specify the name of the ${e}.`;console.log(s);const n=await st({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 M(e){return e&&(typeof e!="string"||e.trim().length==0)}
4
+ Errors: ${JSON.stringify([...e.errors??[],...o??[]],null,2)}`)}async function _t(e){const t=[];for(const s of e.sections){const o=e.sections.indexOf(s);if(o===0&&s.id!=="header"&&t.push({instancePath:`/sections/${o}/id`,message:"The first section must be a default `header`"}),o===e.sections.length-1&&s.id!=="footer"&&t.push({instancePath:`/sections/${o}/id`,message:"The last section must be a default `footer`"}),s.type==="custom")if(!S(`${a}/${s.id}`))t.push({instancePath:`/sections/${o}/id`,message:"Custom section must have a corresponding block defined"});else{if(s.content!==void 0)if(!S(`${a}/${s.id}/js/settings/content.mjs`))t.push({instancePath:`/sections/${o}/content`,message:"Content descriptor is overridden, please provide a default descriptor in the block's settings folder"});else{const n=await M(`${a}/${s.id}/js/settings/content`,!1),i=new Set(Object.keys(n));Object.keys(s.content).every(c=>i.has(c))||t.push({instancePath:`/sections/${o}/content`,message:"Content descriptor must be a subset of the default content descriptor"})}if(s.design!==void 0)if(!S(`${a}/${s.id}/js/settings/design.mjs`))t.push({instancePath:`/sections/${o}/design`,message:"Design descriptor is overridden, please provide a default descriptor in the block's settings folder"});else{const n=await M(`${a}/${s.id}/js/settings/design`,!1),i=new Set(Object.keys(n));Object.keys(s.design).every(c=>i.has(c))||t.push({instancePath:`/sections/${o}/design`,message:"Design descriptor must be a subset of the default design descriptor"})}s.showcase_id!==void 0&&(S(`${a}/${s.id}/js/showcases/${s.showcase_id}.mjs`)||t.push({instancePath:`/sections/${o}/showcase-id`,message:"Custom section must have a corresponding showcase defined in case showcase_id is specified"}))}}return t.length===0?void 0:t}function Dt(e){const t=e.reduce((s,o)=>{const n=et(o);return n.size>te&&(s[o]=ee(n.size)),s},{});if(Object.keys(t).length!==0){const s=Math.max(...Object.keys(t).map(o=>o.length));p.error(`Size of individual assets must not exceed threshold [${ee(te)}]!`);for(let o in t)p.error(`File: ${o}`.padEnd(s+10)+`| ${t[o]}`);throw new Error("Invalid asset file size")}}async function It(){async function e(t,s,o){s.length!==0&&await J({configFile:!1,...H(ce(t,s,o))})}Ve("dist",{recursive:!0,force:!0});try{const t=await Ct().then(o=>o.map(n=>({name:n.name,serverEntrypoint:n.serverEntrypoint,clientEntrypoint:[n.clientEntrypoint].filter(B).flat(),settingsEntryPoints:[n.contentSettingsEntrypoint,n.designSettingsEntrypoint,n.layoutSettingsEntrypoint,n.settingsTranslationsEntrypoint].filter(B),showcaseEntryPoints:[...n.showcasesEntrypoints??[],n.showcasesTranslationsEntrypoint].filter(B),assetEntryPoints:n.assetsEntrypoints??[]})));for(const o of t)Dt(o.assetEntryPoints),await J({configFile:!1,...H(ce(o.name,o.serverEntrypoint,f.Server))}),await e(o.name,o.clientEntrypoint,f.Client),await e(o.name,o.settingsEntryPoints,f.SectionSetting),await e(o.name,o.showcaseEntryPoints,f.SectionShowcase),await e(o.name,o.assetEntryPoints,f.SectionAsset);const s=await At();if(s.templates.length!==0){const o=await Nt();await e(void 0,s.assets,f.TemplateAsset),await e(void 0,s.templates,f.TemplateDescriptor);for(const n of s.templates){const i=`${C}/js/${I(n).name}`,c=await M(i,!0);await Lt(o,c,i,await _t(c))}}p.info("Build successful. For deploy run: npx @lightspeed/crane@latest deploy")}catch(t){p.error(`Error while building: ${t.message}`),z.exit(1)}}function Me(e){if(e!==void 0)return e.startsWith("global.")?{type:"GLOBAL_FONT",font:e}:{type:"PRESET_FONT",font:e}}function O(e){if(e===void 0)return;if(e.startsWith("global."))return{type:"GLOBAL_COLOR",raw:e};const t=ut(e);return{type:"STRUCTURED_COLOR",raw:e,hex:t.toHex8String(),hsl:t.toHsl(),rgba:t.toRgb(),auto:!1}}function xt(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 Gt={COLOR:"COLOR",GRADIENT:"GRADIENT"};function Pt(e){switch(e){case"COLOR":return"solid";case"GRADIENT":return"gradient";default:throw new Error(`Unknown background type: ${e}. Right options: ${Object.keys(Gt)}`)}}function Rt(e){const t=e.style,s=e.color,o=Array.isArray(s)?s:[s,s];return e.background={type:Pt(t),solid:{color:O(o.at(0))},gradient:{fromColor:O(o.at(0)),toColor:O(o.at(1))}},e.style=void 0,e.color=void 0,e}const kt={SOLID:"SOLID",OUTLINE:"OUTLINE",TEXT:"TEXT"};function Bt(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(kt)}`)}}const Ut={SMALL:"SMALL",MEDIUM:"MEDIUM",LARGE:"LARGE"};function Mt(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(Ut)}`)}}const Xt={ROUND_CORNER:"ROUND_CORNER",RECTANGLE:"RECTANGLE",PILL:"PILL"};function Ft(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(Xt)}`)}}function qt(e){const t=e.appearance;t!==void 0&&(e.appearance=Bt(t));const s=e.size;s!==void 0&&(e.size=Mt(s));const o=e.shape;o!==void 0&&(e.style=Ft(o),e.shape=void 0);const n=e.font;e.font=Me(n);const i=e.color;return e.color=O(i),e}const zt={COLOR:"COLOR",GRADIENT:"GRADIENT",NONE:"NONE"};function Kt(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(zt)}`)}}function Jt(e){const t=e.overlay,s=e.color,o=Array.isArray(s)?s:[s,s];return e.overlay={type:Kt(t),solid:{color:O(o.at(0))},gradient:{fromColor:O(o.at(0)),toColor:O(o.at(1))}},e.color=void 0,e}function Ht(e){const t=e.font;e.font=Me(t);const s=e.color;e.color=O(s);const o=e.size;return e.size=xt(o),e}function Zt(e){const t=e.color;return e.color=O(t),e}function Wt(e){Object.keys(e).forEach(t=>{const s=e[t],o=s.type;X(o,s.defaults)})}function Vt(e){e.forEach(t=>{t.type!==void 0&&t.defaults!==void 0&&(X(t.type,t.defaults),t.defaults.type=t.type)})}function Xe(e){Object.keys(e).forEach(t=>{const s=e[t],o=s.type;X(o,s)})}function X(e,t){switch(e){case"TEXT":{Ht(t);break}case"BUTTON":{qt(t);break}case"IMAGE":{Jt(t);break}case"BACKGROUND":{Rt(t);break}case"COLOR_PICKER":{Zt(t);break}case"TOGGLE":case"SELECTBOX":break;default:throw new Error(`Unknown design editor type: ${e}`)}return t}const Yt=200;var y=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.ClientAsset=2]="ClientAsset",e[e.Asset=3]="Asset",e[e.TemplateAsset=4]="TemplateAsset",e[e.Dependency=5]="Dependency",e))(y||{});const A={[y.Server]:{type:"server_js",isSingleton:!0,toPath:e=>`${a}/${e}/js/main/server/`,fileName:"server.js"},[y.Client]:{type:"client_js",isSingleton:!1,toPath:e=>`${a}/${e}/js/main/client/`,fileName:"client.js"},[y.ClientAsset]:{type:"assets",isSingleton:!1,toPath:e=>`${a}/${e}/js/main/client/assets/`,fileName:"*"},[y.Asset]:{type:"assets",isSingleton:!1,toPath:e=>`${a}/${e}/assets/`,fileName:"*"},[y.TemplateAsset]:{type:"template_assets",isSingleton:!1,toPath:()=>`${C}/assets/`,fileName:"*"},[y.Dependency]:{type:"dependencies",isSingleton:!0,toPath:()=>{},fileName:"package.json"}},Qt="https://blockbuster.ecwid.com",es="/api/v1/custom-apps/resources/sections/upload",ts="/api/v1/custom-apps/resources/templates/upload",ss="/api/v1/custom-apps/manifests/sections",os="/api/v1/custom-apps/manifests/templates",ns=5,is=3;async function rs(){const e=await V(m(l.cwd(),"crane.config.json")),t=JSON.parse(e.toString());return{appClientId:t.app_client_id,appSecretKey:btoa(t.app_secret_key)}}async function as(){const e=m(l.cwd(),"package.json"),t=await V(e),s=JSON.parse(t.toString());if(cs(s))return s;throw new Error(`Package file located at path: ${e} does not contain a version field`)}function cs(e){return typeof e=="object"&&e!==null&&"version"in e&&typeof e.version=="string"}async function ps(e){const t=mt(e.version,"patch");if(t===null)throw Error("Error while incrementing app version");e.version=t,tt(m(l.cwd(),"package.json"),`${JSON.stringify(e,null,2)}
5
+ `)}async function ls(e,t){try{const s=m(l.cwd(),`${a}/${e}/js/settings/content.mjs`),o=(await import(v(s).href)).default;return L(o,t),o}catch{throw new Error(`Content descriptor for section [${e}] is either invalid or undefined`)}}async function ds(e,t){try{const s=m(l.cwd(),`${a}/${e}/js/settings/design.mjs`),o=(await import(v(s).href)).default;return Wt(o),L(o,t),o}catch(s){const o=s;throw new Error(`Design settings is invalid or undefined. Error ${o.stack}`)}}async function ms(e,t){try{const s=await u("*.mjs",{cwd:m(l.cwd(),`${a}/${e}/js/showcases/`),ignore:"**/translations.mjs"});return Promise.all(s.map(async o=>{const n=m(l.cwd(),`${a}/${e}/js/showcases/${o}`),i=(await import(v(n).href)).default;return Xe(i.design),L(i,t),i}))}catch(s){throw new Error(`Showcases is invalid or undefined. Error ${s}`)}}async function fs(e){try{const t=m(l.cwd(),`${a}/${e}/js/settings/layout.mjs`);if(!S(t))return[];const s=(await import(v(t).href)).default;return s.forEach(o=>Vt(o.selectedDesignSettings)),s}catch{throw new Error(`Layout descriptor for section [${e}] is either invalid or undefined`)}}async function us(e){return await qe(`${a}/${e}/js/settings/translations.mjs`)}async function Fe(e){return await qe(`${a}/${e}/js/showcases/translations.mjs`)}async function qe(e){const t=m(l.cwd(),e),s=(await import(v(t).href)).default;return hs(s)}function L(e,t){if(e&&typeof e=="object"){const s=e;for(let o in s){const n=s[o];typeof n=="string"&&n.startsWith("$")&&(s[o]=ys(t,n)),typeof n=="object"&&L(n,t)}}}function ys(e,t){if(!t)return;const s=e[t];return s===void 0?{en:t}:s}function hs(e){const t={};for(let s in e){const o=e[s];for(let n in o){const i=t[n],c=o[n];if(i===void 0){const r={};r[s]=c,t[n]=r}else i[s]=c}}return t}async function gs(){const e=await u("*/",{cwd:m(l.cwd(),`${a}/`)});return Promise.all(e.map(async t=>{const s=await us(t),o=await Fe(t),n=await ls(t,s),i=await ds(t,s),c=await ms(t,o),r=await fs(t);return{id:t,name:{en:t},contentEditors:n,designEditors:i,layouts:r,showcases:c}}))}async function $s(e){try{return(await import(v(m(l.cwd(),e)).href)).default}catch{throw new Error(`Template descriptor [${e}] is either invalid or undefined`)}}async function Es(){const e=await u(`${C}/js/**.mjs`,{ignore:[`${C}/js/**${b}.mjs`]});return Promise.all(e.map(async t=>{const s=await $s(t),o=s.sections.filter(n=>n.type==="custom");for(const n of o){const i=await Fe(n.id);n.showcase_overrides!==void 0&&(L(n.showcase_overrides,i),Xe(n.showcase_overrides.design))}return{id:`${I(l.cwd()).name.replace(/[^a-zA-Z0-9]/g,"_")}_${I(t).name}`,descriptor:s}}))}function Ts(e){const t=e.pathContext,s=t.toPath(e.currentSection),o=s===void 0?K(t.fileName):K(t.fileName,{cwd:m(l.cwd(),s),ignore:t.ignore});return t.isSingleton?o.splice(0):o}function ws(e){return e instanceof Y&&(e.code==="ECONNRESET"||e.response?.status!==void 0&&e.response?.status>=500&&e.response?.status<600)}function ze(e,t){return e<is&&ws(t)}async function Ke(e){await new Promise(t=>{setTimeout(t,2**e*500)})}function Je(e,t,s,o){const n=e.config.app.templates.length>0?ts:es;return e.config.axios.post(n,{file:st(m(l.cwd(),s!==void 0?s+t:t))},{params:{appClientId:e.config.app.crane.appClientId,type:e.pathContext.type,version:e.config.app.packageJson.version,...e.currentSection!==void 0&&{block:e.currentSection},...e.pathContext.type!=="dependencies"&&{fileName:t}},headers:{"Content-Type":"multipart/form-data",Authorization:`Bearer ${e.config.app.crane.appSecretKey}`}}).then(i=>({status:i.status})).catch(async i=>ze(o,i)?(await Ke(o),Je(e,t,s,o+1)):{status:i.response?.status,message:i.message})}function N(e){const t=Ts(e),s=e.pathContext.toPath(e.currentSection);return t.map(o=>Je(e,o,s,0))}function js(e){return[...e.app.sections.flatMap(t=>[...N({config:e,currentSection:t.id,pathContext:A[y.Server]}),...N({config:e,currentSection:t.id,pathContext:A[y.Client]}),...N({config:e,currentSection:t.id,pathContext:A[y.ClientAsset]}),...N({config:e,currentSection:t.id,pathContext:A[y.Asset]})]),...N({config:e,pathContext:A[y.Dependency]}),...N({config:e,pathContext:A[y.TemplateAsset]})]}function Os(e){return e.includes(`
6
+ `)}function vs(e,t,s){return e.split(`
7
+ `).map((o,n)=>n>=s?t+o:o).join(`
8
+ `)}function He(e,t){const s=[];if(e instanceof Y){e.response?.status!==void 0&&s.push(` HTTP Status Code: ${e.response.status}`);const i=e.response?.data;if(i?.errorCode&&s.push(` Error Code: ${i.errorCode}`),i?.errorMessage){const c=Os(i.errorMessage)?vs(i.errorMessage," ",1):i.errorMessage;s.push(` Error Message: ${c}`)}}const o=s.length>0?s.join(`
9
+ `):e?.message??"Unknown error";if(!t||t.length===0)return o;const n=s.length>0?`
10
+ `:" ";return`${t}${n}${o}`}async function Ze(e,t=0){const s=e.app.templates.length>0?os:ss;return e.axios.post(s,{version:e.app.packageJson.version,name:"Custom Block App",blocks:e.app.sections,templates:e.app.templates},{params:{appClientId:e.app.crane.appClientId},headers:{Authorization:`Bearer ${e.app.crane.appSecretKey}`}}).catch(async o=>{if(ze(t,o))return await Ke(t),Ze(e,t+1);throw o})}async function Ss(e){try{S(m(l.cwd(),a))||(p.error(`Distribution folder [${a}] not found, please execute the build command first.`),l.exit(1));const t=e??Qt;p.info("Custom application deployment :: Started");const s=dt.create({baseURL:t});ft(s,ns),p.info("Loading configuration files ...");const o=await Promise.all([rs(),as(),gs(),Es()]).then(([r,E,g,G])=>({axios:s,app:{crane:r,packageJson:E,sections:g,templates:G}}));p.info("Uploading asset files ...");let n=se();const i=await Promise.all(js(o)).finally(()=>{U(n)});i.every(r=>r.status===Yt)||(i.map(r=>r.message).filter((r,E,g)=>g.indexOf(r)===E).forEach(r=>p.error(`Error while uploading asset files: ${r}`)),l.exit(1)),p.info("Uploading manifest files ..."),n=se(),await Ze(o).catch(r=>{U(n),p.error(He(r,"Error while deploying manifest file:")),l.exit(1)}).finally(()=>{U(n)});const c=o.app.sections.map(r=>r.id);p.info(`Custom application deployment :: Successful
11
+ Current app version: ${o.app.packageJson.version}
12
+ Deployed sections: ${c.join(", ")}`),await ps(o.app.packageJson),o.app.templates.length>0&&p.info(`Deployed templates: ${o.app.templates.map(r=>r.id).join(", ")}`)}catch(t){p.error(He(t,"Error while deploying:")),l.exit(1)}}const bs="1.1.0",d=We("crane");function Cs(){d.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 oe(e.app);if(e.section)return ne(e.section);if(e.template)return ie(e.template);d.outputHelp()}),d.command("build","Builds your resource code").action(It),d.command("deploy","Deploys your resource code into Ecwid"),d.on("command:*",()=>{console.error("Invalid command: %s",d.args.join(" ")),d.outputHelp(),process.exit(1)}),d.on("command:init",()=>{const e=d.options.section,t=d.options.app,s=d.options.template;q(t)?F("app",x("init --app <name>"),oe):q(e)?F("section",x("init --section <name>"),ne):q(s)&&F("template",x("init --template <name>"),ie)}),d.on("command:deploy",()=>Ss(d.options.url)),d.help(),d.usage("<action> <resource>"),d.version(bs),d.parse()}try{Cs()}catch{}async function F(e,t,s){const o=`You can use ${t} to directly specify the name of the ${e}.`;console.log(o);const n=await yt({type:"text",name:"name",message:`Please specify a name for your ${e}:`});if(n.name)return s(n.name);console.log("Please provide a name for the template."),d.outputHelp()}function q(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": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "bin": "bin/crane.js",
6
6
  "main": "./dist/app.mjs",
@@ -54,7 +54,8 @@
54
54
  "@vitejs/plugin-vue": "^4.1.0",
55
55
  "ajv": "^8.12.0",
56
56
  "ajv-formats": "^2.1.1",
57
- "axios": "^1.4.0",
57
+ "axios": "^1.7.7",
58
+ "axios-concurrency": "^1.0.4",
58
59
  "cac": "^6.7.14",
59
60
  "eslint": "npm:eslint-customized-for-crane@8.57.0",
60
61
  "fs-extra": "^11.1.1",
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <div
3
+ class="custom-footer"
4
+ >
5
+ <div>
6
+ the components will sit here
7
+ </div>
8
+ </div>
9
+ </template>
10
+
11
+ <script setup lang="ts">
12
+
13
+ </script>
14
+
15
+ <style scoped lang="scss">
16
+
17
+ </style>
@@ -0,0 +1,5 @@
1
+ import { createVueClientApp } from '@lightspeed/crane';
2
+ import ExampleFooter from './ExampleFooter.vue';
3
+ import { Content, Design } from './type.ts';
4
+
5
+ export default createVueClientApp<Content, Design>(ExampleFooter);
@@ -0,0 +1,11 @@
1
+ <script setup lang="ts">
2
+
3
+ </script>
4
+
5
+ <template>
6
+
7
+ </template>
8
+
9
+ <style scoped lang="scss">
10
+
11
+ </style>
@@ -0,0 +1,5 @@
1
+ import { createVueServerApp } from '@lightspeed/crane';
2
+ import ExampleFooter from './ExampleFooter.vue';
3
+ import { Content, Design } from './type.ts';
4
+
5
+ export default createVueServerApp<Content, Design>(ExampleFooter);
@@ -0,0 +1,11 @@
1
+ export default {
2
+ previewImage: {
3
+ set: {
4
+ ORIGINAL: {
5
+ url: 'example_footer_showcase_1_preview.jpg',
6
+ },
7
+ },
8
+ },
9
+ content: {},
10
+ design: {},
11
+ } as const;
@@ -0,0 +1,5 @@
1
+ import ContentSettings from '../settings/content.ts';
2
+ import DesignSettings from '../settings/design.ts';
3
+
4
+ export type Content = InferContentType<typeof ContentSettings>;
5
+ export type Design = InferDesignType<typeof DesignSettings>;
@@ -0,0 +1 @@
1
+ export default {} as const;
@@ -0,0 +1 @@
1
+ export default {} as const;
@@ -0,0 +1 @@
1
+ export default [] as const;
@@ -0,0 +1,5 @@
1
+ export default {
2
+ en: {},
3
+
4
+ nl: {},
5
+ } as const;
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <div
3
+ class="custom-header"
4
+ >
5
+ <div>
6
+ the components will sit here
7
+ </div>
8
+ </div>
9
+ </template>
10
+
11
+ <script setup lang="ts">
12
+
13
+ </script>
14
+
15
+ <style scoped lang="scss">
16
+
17
+ </style>
@@ -0,0 +1,5 @@
1
+ import { createVueClientApp } from '@lightspeed/crane';
2
+ import ExampleHeader from './ExampleHeader.vue';
3
+ import { Content, Design } from './type.ts';
4
+
5
+ export default createVueClientApp<Content, Design>(ExampleHeader);
@@ -0,0 +1,11 @@
1
+ <script setup lang="ts">
2
+
3
+ </script>
4
+
5
+ <template>
6
+
7
+ </template>
8
+
9
+ <style scoped lang="scss">
10
+
11
+ </style>
@@ -0,0 +1,5 @@
1
+ import { createVueServerApp } from '@lightspeed/crane';
2
+ import ExampleHeader from './ExampleHeader.vue';
3
+ import { Content, Design } from './type.ts';
4
+
5
+ export default createVueServerApp<Content, Design>(ExampleHeader);
File without changes
@@ -0,0 +1,5 @@
1
+ import ContentSettings from '../settings/content.ts';
2
+ import DesignSettings from '../settings/design.ts';
3
+
4
+ export type Content = InferContentType<typeof ContentSettings>;
5
+ export type Design = InferDesignType<typeof DesignSettings>;
@@ -0,0 +1 @@
1
+ export default {} as const;
@@ -0,0 +1 @@
1
+ export default {} as const;
@@ -0,0 +1 @@
1
+ export default [] as const;
@@ -0,0 +1,5 @@
1
+ export default {
2
+ en: {},
3
+
4
+ nl: {},
5
+ } as const;
@@ -7,7 +7,7 @@
7
7
  "deploy": "crane build && crane deploy"
8
8
  },
9
9
  "dependencies": {
10
- "@lightspeed/crane": "1.0.3",
10
+ "@lightspeed/crane": "1.1.0",
11
11
  "@lightspeed/eslint-config-crane": "1.0.2",
12
12
  "vue": "^3.4.0"
13
13
  },
@@ -17,6 +17,7 @@ export default {
17
17
  '$label.showcase_2.image_text_3.text': 'Bianka\'s wardrobe',
18
18
  '$label.showcase_2.image_text_4.text': 'Story of Jane',
19
19
  '$label.showcase_2.image_link_1.text': '/products',
20
+ '$label.template_standard_showcase_1.section_title.text': 'Something really catchy',
20
21
  },
21
22
 
22
23
  nl: {
@@ -37,5 +38,6 @@ export default {
37
38
  '$label.showcase_2.image_text_3.text': 'Bianka\'s kledingkast',
38
39
  '$label.showcase_2.image_text_4.text': 'Verhaal van Jane',
39
40
  '$label.showcase_2.image_link_1.text': '/products',
41
+ '$label.template_standard_showcase_1.section_title.text': 'Iets heel pakkends',
40
42
  },
41
43
  } as const;
@@ -2,7 +2,7 @@ export default {
2
2
  metadata: {
3
3
  name: 'Example Template :: Standard Preset',
4
4
  description: 'Standard Preset for the Example template',
5
- test_site_id: 1,
5
+ preview_url: 'https://template_preview.company.site',
6
6
  cover_image: {
7
7
  set: {
8
8
  ORIGINAL: {
@@ -23,139 +23,158 @@ export default {
23
23
  {
24
24
  type: 'custom',
25
25
  id: 'example-section',
26
+ showcase_id: '1',
26
27
  },
27
28
  {
28
29
  type: 'custom',
29
30
  id: 'example-section',
30
- content: {
31
- section_title: {
32
- type: 'INPUTBOX',
33
- label: '$label.section_title.label',
34
- placeholder: '$label.section_title.placeholder',
35
- },
36
- section_description: {
37
- type: 'TEXTAREA',
38
- label: '$label.section_description.label',
39
- placeholder: '$label.section_description.placeholder',
40
- },
41
- image_content_1: {
42
- type: 'IMAGE',
43
- label: '$label.image_content_1.label',
44
- },
45
- image_text_1: {
46
- type: 'TEXTAREA',
47
- label: '$label.image_text_1.label',
48
- placeholder: '$label.image_text.placeholder',
49
- },
50
- image_link_1: {
51
- type: 'INPUTBOX',
52
- label: '$label.image_link_1.label',
53
- placeholder: '$label.image_link.placeholder',
54
- },
55
- image_content_2: {
56
- type: 'IMAGE',
57
- label: '$label.image_content_2.label',
58
- },
59
- image_text_2: {
60
- type: 'TEXTAREA',
61
- label: '$label.image_text_2.label',
62
- placeholder: '$label.image_text.placeholder',
63
- },
64
- image_link_2: {
65
- type: 'INPUTBOX',
66
- label: '$label.image_link_2.label',
67
- placeholder: '$label.image_link.placeholder',
68
- },
69
- image_content_3: {
70
- type: 'IMAGE',
71
- label: '$label.image_content_3.label',
72
- },
73
- image_text_3: {
74
- type: 'TEXTAREA',
75
- label: '$label.image_text_3.label',
76
- placeholder: '$label.image_text.placeholder',
77
- },
78
- image_link_3: {
79
- type: 'INPUTBOX',
80
- label: '$label.image_link_3.label',
81
- placeholder: '$label.image_link.placeholder',
82
- },
83
- image_content_4: {
84
- type: 'IMAGE',
85
- label: '$label.image_content_4.label',
86
- },
87
- image_text_4: {
88
- type: 'TEXTAREA',
89
- label: '$label.image_text_4.label',
90
- placeholder: '$label.image_text.placeholder',
91
- },
92
- image_link_4: {
93
- type: 'INPUTBOX',
94
- label: '$label.image_link_4.label',
95
- placeholder: '$label.image_link.placeholder',
96
- },
97
- },
98
- design: {
99
- section_title: {
100
- type: 'TEXT',
101
- label: '$label.section_title.label',
102
- colors: ['#FFFFFF66', '#0000004D', '#00000099', '#64C7FF66', '#F9947266', '#C794CD66', '#FFD17466'],
103
- sizes: [18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60],
104
- defaults: {
105
- font: 'global.fontFamily.body',
106
- size: 40,
107
- bold: true,
108
- italic: false,
109
- color: '#313131',
110
- visible: true,
31
+ showcase_overrides: {
32
+ content: {
33
+ section_title: {
34
+ type: 'INPUTBOX',
35
+ text: '$label.template_standard_showcase_1.section_title.text',
36
+ },
37
+ image_text_1: {
38
+ type: 'TEXTAREA',
39
+ text: '$label.showcase_2.image_text_1.text',
40
+ },
41
+ image_text_2: {
42
+ type: 'TEXTAREA',
43
+ text: '$label.showcase_2.image_text_2.text',
44
+ },
45
+ image_text_3: {
46
+ type: 'TEXTAREA',
47
+ text: '$label.showcase_2.image_text_3.text',
48
+ },
49
+ image_text_4: {
50
+ type: 'TEXTAREA',
51
+ text: '$label.showcase_2.image_text_4.text',
52
+ },
53
+ image_content_1: {
54
+ type: 'IMAGE',
55
+ imageData: {
56
+ set: {
57
+ LOW_RES: {
58
+ url: 'new_tshirts_collection_mobile_low.jpeg',
59
+ },
60
+ MOBILE_WEBP_LOW_RES: {
61
+ url: 'new_tshirts_collection_mobile_low.jpeg',
62
+ },
63
+ MOBILE_WEBP_HI_RES: {
64
+ url: 'new_tshirts_collection_mobile_high.jpeg',
65
+ },
66
+ WEBP_LOW_RES: {
67
+ url: 'new_tshirts_collection_pc_low.jpeg',
68
+ },
69
+ WEBP_HI_2X_RES: {
70
+ url: 'new_tshirts_collection_pc_high.jpeg',
71
+ },
72
+ },
73
+ borderInfo: {},
74
+ },
75
+ },
76
+ image_content_2: {
77
+ type: 'IMAGE',
78
+ imageData: {
79
+ set: {
80
+ LOW_RES: {
81
+ url: 'autumn_looks_mobile_low.jpeg',
82
+ },
83
+ MOBILE_WEBP_LOW_RES: {
84
+ url: 'autumn_looks_mobile_low.jpeg',
85
+ },
86
+ MOBILE_WEBP_HI_RES: {
87
+ url: 'autumn_looks_mobile_high.jpeg',
88
+ },
89
+ WEBP_LOW_RES: {
90
+ url: 'autumn_looks_pc_low.jpeg',
91
+ },
92
+ WEBP_HI_2X_RES: {
93
+ url: 'autumn_looks_pc_high.jpeg',
94
+ },
95
+ },
96
+ borderInfo: {},
97
+ },
98
+ },
99
+ image_content_3: {
100
+ type: 'IMAGE',
101
+ imageData: {
102
+ set: {
103
+ LOW_RES: {
104
+ url: 'bianka_wardrobe_mobile_low.jpeg',
105
+ },
106
+ MOBILE_WEBP_LOW_RES: {
107
+ url: 'bianka_wardrobe_mobile_low.jpeg',
108
+ },
109
+ MOBILE_WEBP_HI_RES: {
110
+ url: 'bianka_wardrobe_mobile_high.jpeg',
111
+ },
112
+ WEBP_LOW_RES: {
113
+ url: 'bianka_wardrobe_pc_low.jpeg',
114
+ },
115
+ WEBP_HI_2X_RES: {
116
+ url: 'bianka_wardrobe_pc_high.jpeg',
117
+ },
118
+ },
119
+ borderInfo: {},
120
+ },
121
+ },
122
+ image_content_4: {
123
+ type: 'IMAGE',
124
+ imageData: {
125
+ set: {
126
+ LOW_RES: {
127
+ url: 'story_of_jane_mobile_low.jpeg',
128
+ },
129
+ MOBILE_WEBP_LOW_RES: {
130
+ url: 'story_of_jane_mobile_low.jpeg',
131
+ },
132
+ MOBILE_WEBP_HI_RES: {
133
+ url: 'story_of_jane_mobile_high.jpeg',
134
+ },
135
+ WEBP_LOW_RES: {
136
+ url: 'story_of_jane_pc_low.jpeg',
137
+ },
138
+ WEBP_HI_2X_RES: {
139
+ url: 'story_of_jane_pc_high.jpeg',
140
+ },
141
+ },
142
+ borderInfo: {},
143
+ },
144
+ },
145
+ image_link_1: {
146
+ type: 'TEXTAREA',
147
+ text: '$label.showcase_2.image_link_1.text',
111
148
  },
112
149
  },
113
- section_description: {
114
- type: 'TEXT',
115
- label: '$label.section_description.label',
116
- colors: ['#FFFFFF66', '#0000004D', '#00000099', '#64C7FF66', '#F9947266', '#C794CD66', '#FFD17466'],
117
- sizes: [12, 13, 14, 15, 16, 17, 18, 20],
118
- defaults: {
150
+ design: {
151
+ section_title: {
152
+ type: 'TEXT',
119
153
  font: 'global.fontFamily.body',
120
- size: 18,
121
- bold: false,
154
+ size: 42,
155
+ bold: true,
122
156
  italic: true,
123
- color: '#313131',
124
- visible: true,
157
+ color: '#222',
125
158
  },
126
- },
127
- image_text: {
128
- type: 'TEXT',
129
- label: '$label.image_text.label',
130
- colors: ['#FFFFFF66', '#0000004D', '#00000099', '#64C7FF66', '#F9947266', '#C794CD66', '#FFD17466'],
131
- sizes: [12, 13, 14, 15, 16, 17, 18, 20],
132
- defaults: {
133
- font: 'global.fontFamily.body',
134
- size: 16,
159
+ image_text: {
160
+ type: 'TEXT',
161
+ size: 22,
135
162
  bold: false,
136
163
  italic: true,
137
- color: '#FFFFFF',
138
- visible: true,
139
164
  },
140
- },
141
- image_content: {
142
- type: 'IMAGE',
143
- label: '$label.image_content.label',
144
- colors: ['#FFFFFF66', '#0000004D', '#00000099', '#64C7FF66', '#F9947266', '#C794CD66', '#FFD17466'],
145
- defaults: {
146
- overlay: 'COLOR',
147
- color: '#333',
148
- },
149
- },
150
- background: {
151
- type: 'BACKGROUND',
152
- label: '$label.background.label',
153
- colors: ['#FFFFFF66', '#0000004D', '#00000099', '#64C7FF66', '#F9947266', '#C794CD66', '#FFD17466'],
154
- defaults: {
165
+ background: {
166
+ type: 'BACKGROUND',
155
167
  style: 'COLOR',
156
168
  color: 'global.color.background',
157
169
  },
170
+ image_content: {
171
+ type: 'IMAGE',
172
+ overlay: 'GRADIENT',
173
+ color: ['#FFFFFF', '#CCCCCC'],
174
+ },
158
175
  },
176
+ layoutId: 'Caption_Under_Image',
177
+ blockName: '$label.showcase_1.blockName',
159
178
  },
160
179
  },
161
180
  {