@lightspeed/crane 1.0.1 → 1.0.3
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/README.md +1 -1
- package/dist/app.d.mts +16 -2
- package/dist/app.d.ts +16 -2
- package/dist/app.mjs +1 -1
- package/dist/cli.mjs +6 -6
- package/package.json +2 -2
- package/template/package.json +2 -2
- package/template/sections/example-section/component/image/Image.vue +22 -19
- package/template/sections/example-section/component/title/Title.vue +5 -2
- package/template/sections/example-section/settings/design.ts +1 -20
- package/template/sections/example-section/settings/layout.ts +34 -0
- package/template/sections/example-section/settings/translations.ts +0 -10
- package/template/sections/example-section/showcases/1.ts +1 -1
- package/template/templates/assets/template_cover_image.png +0 -0
- package/template/templates/template.ts +16 -31
- package/types.d.ts +5 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ within the Lightspeed E-Commerce ecosystem.
|
|
|
20
20
|
In order to use this utility, first a Lightspeed specific application needs to be created containing the necessary
|
|
21
21
|
permissions granted, as well as an optional test site in order to verify the changes made in a custom application.
|
|
22
22
|
|
|
23
|
-
```For both the test site and the permission, please contact
|
|
23
|
+
```For both the test site and the permission, please contact your Partner Manager!```
|
|
24
24
|
|
|
25
25
|
### Installation
|
|
26
26
|
|
package/dist/app.d.mts
CHANGED
|
@@ -20,7 +20,7 @@ interface AppBaseState<C, D> {
|
|
|
20
20
|
|
|
21
21
|
interface VueBaseProps<CONTENT, DESIGN> {
|
|
22
22
|
init: (app: App<Element>, contextValue: AppBaseContext, contentValue: CONTENT, designValue: DESIGN, defaultsValue: Record<string, unknown>) => void;
|
|
23
|
-
update: (app: App<Element>, contentValue: CONTENT, designValue: DESIGN) => void;
|
|
23
|
+
update: (app: App<Element>, contentValue: CONTENT, designValue: DESIGN, defaultsValue: Record<string, unknown>) => void;
|
|
24
24
|
readonly context: Ref<AppBaseContext>;
|
|
25
25
|
readonly content: Ref<CONTENT>;
|
|
26
26
|
readonly design: Ref<DESIGN>;
|
|
@@ -73,6 +73,16 @@ declare function useTextElementDesign<DESIGN>(elementName: keyof DESIGN): {
|
|
|
73
73
|
visible: boolean | undefined;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
+
declare function useTextareaElementDesign<DESIGN>(elementName: keyof DESIGN): {
|
|
77
|
+
font: string | undefined;
|
|
78
|
+
size: number | GlobalTextSizeString | undefined;
|
|
79
|
+
bold: boolean | undefined;
|
|
80
|
+
italic: boolean | undefined;
|
|
81
|
+
color: Color | GlobalColorsString | undefined;
|
|
82
|
+
visible: boolean;
|
|
83
|
+
whiteSpace: string;
|
|
84
|
+
};
|
|
85
|
+
|
|
76
86
|
declare function useButtonElementDesign<DESIGN>(elementName: keyof DESIGN): {
|
|
77
87
|
appearance: ButtonAppearance | undefined;
|
|
78
88
|
font: string | undefined;
|
|
@@ -99,6 +109,10 @@ declare function useBackgroundElementDesign<DESIGN>(elementName: keyof DESIGN):
|
|
|
99
109
|
background: Background | undefined;
|
|
100
110
|
};
|
|
101
111
|
|
|
112
|
+
declare function useLayoutElementDesign(): {
|
|
113
|
+
layout: string | undefined;
|
|
114
|
+
};
|
|
115
|
+
|
|
102
116
|
interface VueServerAppExtensions {
|
|
103
117
|
init?: (app: App<Element>) => void;
|
|
104
118
|
render?: <C, D>(app: App<Element>, context: AppBaseContext, data: AppBaseData<C, D>) => void;
|
|
@@ -127,4 +141,4 @@ declare function createVueClientApp<C, D>(appComponent: Component, extensions?:
|
|
|
127
141
|
};
|
|
128
142
|
};
|
|
129
143
|
|
|
130
|
-
export { createVueClientApp, createVueServerApp, useBackgroundElementDesign, useButtonElementContent, useButtonElementDesign, useImageElementContent, useImageElementDesign, useInputboxElementContent, useSelectboxElementContent, useSelectboxElementDesign, useTextElementDesign, useTextareaElementContent, useToggleElementContent, useToggleElementDesign, useVueBaseProps };
|
|
144
|
+
export { createVueClientApp, createVueServerApp, useBackgroundElementDesign, useButtonElementContent, useButtonElementDesign, useImageElementContent, useImageElementDesign, useInputboxElementContent, useLayoutElementDesign, useSelectboxElementContent, useSelectboxElementDesign, useTextElementDesign, useTextareaElementContent, useTextareaElementDesign, useToggleElementContent, useToggleElementDesign, useVueBaseProps };
|
package/dist/app.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ interface AppBaseState<C, D> {
|
|
|
20
20
|
|
|
21
21
|
interface VueBaseProps<CONTENT, DESIGN> {
|
|
22
22
|
init: (app: App<Element>, contextValue: AppBaseContext, contentValue: CONTENT, designValue: DESIGN, defaultsValue: Record<string, unknown>) => void;
|
|
23
|
-
update: (app: App<Element>, contentValue: CONTENT, designValue: DESIGN) => void;
|
|
23
|
+
update: (app: App<Element>, contentValue: CONTENT, designValue: DESIGN, defaultsValue: Record<string, unknown>) => void;
|
|
24
24
|
readonly context: Ref<AppBaseContext>;
|
|
25
25
|
readonly content: Ref<CONTENT>;
|
|
26
26
|
readonly design: Ref<DESIGN>;
|
|
@@ -73,6 +73,16 @@ declare function useTextElementDesign<DESIGN>(elementName: keyof DESIGN): {
|
|
|
73
73
|
visible: boolean | undefined;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
|
+
declare function useTextareaElementDesign<DESIGN>(elementName: keyof DESIGN): {
|
|
77
|
+
font: string | undefined;
|
|
78
|
+
size: number | GlobalTextSizeString | undefined;
|
|
79
|
+
bold: boolean | undefined;
|
|
80
|
+
italic: boolean | undefined;
|
|
81
|
+
color: Color | GlobalColorsString | undefined;
|
|
82
|
+
visible: boolean;
|
|
83
|
+
whiteSpace: string;
|
|
84
|
+
};
|
|
85
|
+
|
|
76
86
|
declare function useButtonElementDesign<DESIGN>(elementName: keyof DESIGN): {
|
|
77
87
|
appearance: ButtonAppearance | undefined;
|
|
78
88
|
font: string | undefined;
|
|
@@ -99,6 +109,10 @@ declare function useBackgroundElementDesign<DESIGN>(elementName: keyof DESIGN):
|
|
|
99
109
|
background: Background | undefined;
|
|
100
110
|
};
|
|
101
111
|
|
|
112
|
+
declare function useLayoutElementDesign(): {
|
|
113
|
+
layout: string | undefined;
|
|
114
|
+
};
|
|
115
|
+
|
|
102
116
|
interface VueServerAppExtensions {
|
|
103
117
|
init?: (app: App<Element>) => void;
|
|
104
118
|
render?: <C, D>(app: App<Element>, context: AppBaseContext, data: AppBaseData<C, D>) => void;
|
|
@@ -127,4 +141,4 @@ declare function createVueClientApp<C, D>(appComponent: Component, extensions?:
|
|
|
127
141
|
};
|
|
128
142
|
};
|
|
129
143
|
|
|
130
|
-
export { createVueClientApp, createVueServerApp, useBackgroundElementDesign, useButtonElementContent, useButtonElementDesign, useImageElementContent, useImageElementDesign, useInputboxElementContent, useSelectboxElementContent, useSelectboxElementDesign, useTextElementDesign, useTextareaElementContent, useToggleElementContent, useToggleElementDesign, useVueBaseProps };
|
|
144
|
+
export { createVueClientApp, createVueServerApp, useBackgroundElementDesign, useButtonElementContent, useButtonElementDesign, useImageElementContent, useImageElementDesign, useInputboxElementContent, useLayoutElementDesign, useSelectboxElementContent, useSelectboxElementDesign, useTextElementDesign, useTextareaElementContent, useTextareaElementDesign, useToggleElementContent, useToggleElementDesign, useVueBaseProps };
|
package/dist/app.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getCurrentInstance as
|
|
1
|
+
import{getCurrentInstance as h,ref as b,computed as o,reactive as f,createSSRApp as C}from"vue";import{renderToString as I}from"vue/server-renderer";const y=new Map;function v(){const n=(a,i,r,u,d)=>{y.set(a._uid,{context:b(i),content:b(r),design:b(u),defaults:b(d)})},t=(a,i,r,u)=>{const d=y.get(a._uid);d!==void 0&&(d.content.value=i,d.design.value=r,d.defaults.value=u)},e=h()?.appContext.app._uid??-1,l=y.get(e);return{init:n,update:t,context:l?.context,content:l?.content,design:l?.design,defaults:l?.defaults}}function z(n){const t=v(),e=o(()=>{const i=t.content.value[n];if(i!==void 0){if(typeof i=="string")return i;throw new Error(`Element ${n} is not inputbox`)}}),l=o(()=>e.value!==void 0),a=o(()=>e.value);return f({hasContent:l,value:a})}function _(n){const t=v(),e=o(()=>{const i=t.content.value[n];if(i!==void 0){if(typeof i=="string")return i;throw new Error(`Element ${n} is not textarea`)}}),l=o(()=>e.value!==void 0),a=o(()=>e.value);return f({hasContent:l,value:a})}function D(n){return"title"in n&&"type"in n}function T(n){const t=v(),e=o(()=>{const u=t.content.value[n];if(u!==void 0){if(D(u))return u;throw new Error(`Element ${n} is not action link`)}}),l=o(()=>e.value?.title),a=o(()=>e.value?.link),i=o(()=>!!l.value),r=o(()=>!!a.value);return f({title:l,link:a,hasTitle:i,hasLink:r,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 S(n){return"bucket"in n&&"borderInfo"in n&&"set"in n}function m(n,t){const e=new RegExp(/^https?:\/\//);return n!=null&&e.test(n)?n:`${t}/${n}`}function L(n){const t=v(),e=o(()=>{const c=t.content.value[n];if(c!==void 0){if(S(c))return c;throw new Error(`Element ${n} is not image`)}}),l=o(()=>e.value===void 0?"":t.context.value.imageBuckets?.[e.value?.bucket]),a=o(()=>e.value!==void 0),i=o(()=>m(e.value?.set?.["cropped-webp-100x200"]?.url,l.value)),r=o(()=>m(e.value?.set?.["cropped-webp-1000x2000"]?.url,l.value)),u=o(()=>m(e.value?.set?.["webp-200x200"]?.url,l.value)),d=o(()=>m(e.value?.set?.["webp-2000x2000"]?.url,l.value));return f({hasContent:a,lowResolutionMobileImage:i,highResolutionMobileImage:r,lowResolutionDesktopImage:u,highResolutionDesktopImage:d})}function $(n){return"enabled"in n}function R(n){const t=v(),e=o(()=>{const i=t.content.value[n];if(i!==void 0){if($(i))return i;throw new Error(`Element ${n} is not toggle`)}}),l=o(()=>e.value!==void 0),a=o(()=>e.value?.enabled);return f({hasContent:l,value:a})}function A(n){const t=v(),e=o(()=>{const i=t.content.value[n];if(i!==void 0){if(typeof i=="string")return i;throw new Error(`Element ${n} is not selectbox`)}}),l=o(()=>e.value!==void 0),a=o(()=>e.value);return f({hasContent:l,value:a})}function E(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 k(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 p(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 B(n){const t=v(),e=o(()=>{const c=t.design.value[n],s=t.defaults.value[n],g=t.context.value.globalDesign;return{font:c?.font?.replaceAll("_"," ")??E(g,s?.font),size:c?.size??k(g,s?.size),bold:c?.bold??s?.bold,italic:c?.italic??s?.italic,color:c?.color??p(g,s?.color),visible:c?.visible??s?.visible??!1}}),l=o(()=>e.value?.font),a=o(()=>e.value?.size),i=o(()=>e.value?.bold),r=o(()=>e.value?.italic),u=o(()=>e.value?.color),d=o(()=>e.value?.visible);return f({font:l,size:a,bold:i,italic:r,color:u,visible:d})}function O(n){const t=v(),e=o(()=>{const s=t.design.value[n],g=t.defaults.value[n],w=t.context.value.globalDesign;return{font:s?.font?.replaceAll("_"," ")??E(w,g?.font),size:s?.size??k(w,g?.size),bold:s?.bold??g?.bold,italic:s?.italic??g?.italic,color:s?.color??p(w,g?.color),visible:s?.visible??g?.visible??!1,whiteSpace:"pre-wrap"}}),l=o(()=>e.value?.font),a=o(()=>e.value?.size),i=o(()=>e.value?.bold),r=o(()=>e.value?.italic),u=o(()=>e.value?.color),d=o(()=>e.value?.visible),c=o(()=>e.value?.whiteSpace);return f({font:l,size:a,bold:i,italic:r,color:u,visible:d,whiteSpace:c})}function G(n){const t=v(),e=o(()=>{const c=t.design.value[n],s=t.defaults.value[n],g=t.context.value.globalDesign;return{appearance:c?.appearance??s?.appearance,font:c?.font??E(g,s?.font),size:c?.size??s?.size,style:c?.style??s?.style,color:c?.color??p(g,s?.color),visible:c?.visible??s?.visible??!1}}),l=o(()=>e.value?.appearance),a=o(()=>e.value?.font),i=o(()=>e.value?.size),r=o(()=>e.value?.style),u=o(()=>e.value?.color),d=o(()=>e.value?.visible);return f({appearance:l,font:a,size:i,style:r,color:u,visible:d})}function K(n){const t=v(),e=o(()=>{const i=t.design.value[n],r=t.defaults.value[n],u=t.context.value.globalDesign;return{overlay:{type:i?.overlay?.type??r?.overlay?.type,solid:{color:i?.overlay?.solid?.color??p(u,r?.overlay?.solid?.color)},gradient:{fromColor:i?.overlay?.gradient?.fromColor??p(u,r?.overlay?.gradient?.fromColor),toColor:i?.overlay?.gradient?.toColor??p(u,r?.overlay?.gradient?.toColor)}},visible:i?.visible??r?.visible??!1}}),l=o(()=>e.value?.overlay),a=o(()=>e.value?.visible);return f({overlay:l,visible:a})}function M(n){const t=v(),e=o(()=>{const a=t.design.value[n],i=t.defaults.value[n];return{enabled:a?.enabled??i?.enabled}}),l=o(()=>e.value?.enabled);return f({enabled:l})}function N(n){const t=v(),e=o(()=>{const a=t.design.value[n],i=t.defaults.value[n];return{value:a?.value??i?.value}}),l=o(()=>e.value?.value);return f({value:l})}function V(n){const t=v(),e=o(()=>{const a=t.design.value[n],i=t.defaults.value[n],r=t.context.value.globalDesign;return{background:{type:a?.background?.type??i?.background?.type,solid:{color:a?.background?.solid?.color??p(r,i?.background?.solid?.color)},gradient:{fromColor:a?.background?.gradient?.fromColor??p(r,i?.background?.gradient?.fromColor),toColor:a?.background?.gradient?.toColor??p(r,i?.background?.gradient?.toColor)}}}}),l=o(()=>e.value?.background);return f({background:l})}function W(){const n=v(),t=o(()=>n.design.value.layout),e=o(()=>t.value);return f({layout:e})}function x(n){return{app:C(n)}}function F(n,t){return{init:()=>{const{app:e}=x(n);return t?.init?.(e),{render:async(l,a)=>(v().init(e,l,a.content,a.design,a.defaults),t?.render?.(e,l,a),{html:await I(e,{context:l}),state:{context:l,data:a}})}}}}function P(n,t){return{init:()=>{const{app:e}=x(n);return t?.init?.(e),{mount:(l,a)=>{v().init(e,a.context,a.data.content,a.data.design,a.data.defaults),t?.mount?.(e,l,a),e.mount(l)},update:l=>{v().update(e,l.data.content,l.data.design,l.data.defaults),t?.update?.(e,l)},unmount:()=>{t?.unmount?.(e),e.unmount()}}}}}export{P as createVueClientApp,F as createVueServerApp,V as useBackgroundElementDesign,T as useButtonElementContent,G as useButtonElementDesign,L as useImageElementContent,K as useImageElementDesign,z as useInputboxElementContent,W as useLayoutElementDesign,A as useSelectboxElementContent,N as useSelectboxElementDesign,B as useTextElementDesign,_ as useTextareaElementContent,O as useTextareaElementDesign,R as useToggleElementContent,M as useToggleElementDesign,v as useVueBaseProps};
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
`),a.info(`App ${e} created`)}catch(t){a.error(`Error while creating app: ${t.message}`)}}async function K(e){try{const t=e,o=process.cwd(),n=f.join(o,"sections",t);if(!p.existsSync(n))p.mkdirSync(n);else{a.error(`Section with the name: ${e} already exists. If you'd like to override it, delete previous version first`);return}const s=f.resolve(N(import.meta.url),"../..","template/sections/example-section");p.readdirSync(s).forEach(async i=>_(n,s,i)),a.info(`Section ${e} created`)}catch(t){a.error(`Error while creating block: ${t.message}`)}}async function J(e){try{const t=process.cwd(),o=f.join(t,"templates"),n={"template.ts":`${e}.ts`};if(!p.existsSync(o))p.mkdirSync(o);else if(p.existsSync(f.join(o,`${e}.ts`))){a.error(`Template with the name: ${e} already exists. If you'd like to override it, delete previous version first`);return}const s=f.resolve(N(import.meta.url),"../..","template/templates");p.readdirSync(s).forEach(async i=>_(o,s,i,n)),a.info(`Template descriptor file [${e}.ts] has been created`)}catch(t){a.error(`Error while creating template descriptors: ${t.message}`)}}var u=(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))(u||{}),g=(e=>(e[e.Server=0]="Server",e[e.Client=1]="Client",e[e.Misc=2]="Misc",e))(g||{});const We={[g.Server]:[F(),P()],[g.Client]:[F(),P(),V(),Me({vue:"EcVue"})],[g.Misc]:[P(),V()]},H={"process.env":{NODE_ENV:"production"}},$={[u.Server]:{pluginType:g.Server,define:H,ssr:!0,ssrOptions:{noExternal:!0},outDir:e=>`./dist/sections/${e}/js/main/server`,externalOption:[...X,...X.map(e=>`node:${e}`)],entryFileNames:"[name].js"},[u.Client]:{pluginType:g.Client,define:H,ssr:!1,outDir:e=>`./dist/sections/${e}/js/main/client`,entryFileNames:"[name].js",chunkFileNames:"[name].js",assetFileNames:"assets/[name].[ext]"},[u.SectionSetting]:{pluginType:g.Misc,ssr:!1,outDir:e=>`./dist/sections/${e}/js/settings`,entryFileNames:"[name].mjs"},[u.SectionShowcase]:{pluginType:g.Misc,ssr:!1,outDir:e=>`./dist/sections/${e}/js/showcases`,entryFileNames:"[name].mjs"},[u.SectionAsset]:{pluginType:g.Misc,ssr:!1,outDir:e=>`./dist/sections/${e}/assets`,assetFileNames:"[name].[ext]"},[u.TemplateDescriptor]:{pluginType:g.Misc,ssr:!1,outDir:()=>"./dist/template/js",entryFileNames:`[name]${w}.mjs`}};function Ze(e){switch(typeof e){case"string":return[l(process.cwd(),e)];case"object":return e.map(t=>l(process.cwd(),t));default:return[]}}function V(){const e=process.env.npm_lifecycle_event;return Fe({typescript:!0,vueTsc:!1,eslint:{lintCommand:`eslint --max-warnings=0 "./sections/**/*.{js,ts,vue}" --cache --cache-location "./build/eslintcache/${e}.json"`}})}function k(e,t,o){const n=$[o].define,s=$[o].ssrOptions,i=$[o].externalOption,r=$[o].entryFileNames,m=$[o].chunkFileNames,T=$[o].assetFileNames;return{plugins:We[$[o].pluginType],...n!=null&&{define:n},...s!=null&&{ssr:s},resolve:{alias:{"@":"/src"}},build:{ssr:$[o].ssr,outDir:$[o].outDir(e),emptyOutDir:!0,rollupOptions:{...i!=null&&{external:i},preserveEntrySignatures:"strict",input:Ze(t),output:{validate:!0,...r!=null&&{entryFileNames:r},...m!=null&&{chunkFileNames:m},...T!=null&&{assetFileNames:T}}}}}}const W="https://json-schema.org/draft/2020-12/schema",Z="https://lightspeedhq.com/template.schema.json",Y="Custom Template",Q="A custom template enclosing the necessary custom and default blocks",ee="object",te={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}},oe=["metadata","sections"],Ye={$schema:W,$id:Z,title:Y,description:Q,type:ee,properties:te,required:oe},ne={__proto__:null,$id:Z,$schema:W,default:Ye,description:Q,properties:te,required:oe,title:Y,type:ee},se="https://json-schema.org/draft/2020-12/schema",ie="https://lightspeedhq.com/template-default.schema.json",re="Default Section",ae="Default section for a Custom Template",ce="object",pe={"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}},Qe={$schema:se,$id:ie,title:re,description:ae,type:ce,$defs:pe},et={__proto__:null,$defs:pe,$id:ie,$schema:se,default:Qe,description:ae,title:re,type:ce},le="https://json-schema.org/draft/2020-12/schema",de="https://lightspeedhq.com/template-custom.schema.json",fe="Custom Section",ue="Custom section for a Custom Template",me="object",ye={"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}},tt={$schema:le,$id:de,title:fe,description:ue,type:me,$defs:ye},ot={__proto__:null,$defs:ye,$id:de,$schema:le,default:tt,description:ue,title:fe,type:me},he="https://json-schema.org/draft/2020-12/schema",ge="https://lightspeedhq.com/template-custom-content.schema.json",$e="Custom Section :: Content Configuration",Ee="Content tab configuration of a Custom Section for a Custom Template",Te="object",be={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}},nt={$schema:he,$id:ge,title:$e,description:Ee,type:Te,$defs:be},st={__proto__:null,$defs:be,$id:ge,$schema:he,default:nt,description:Ee,title:$e,type:Te},we="https://json-schema.org/draft/2020-12/schema",je="https://lightspeedhq.com/template-custom-design.schema.json",Oe="Custom Section :: Design Configuration",ve="Design tab configuration of a Custom Section for a Custom Template",Se="object",Ce={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}},it={$schema:we,$id:je,title:Oe,description:ve,type:Se,$defs:Ce},rt={__proto__:null,$defs:Ce,$id:je,$schema:we,default:it,description:ve,title:Oe,type:Se};async function at(){const e=await y("**/server.{js,ts}",{ignore:["node_modules/**","dist/**"]});return Promise.all(e.map(async t=>{const o=ke(t).split(xe).pop()??"default",n=await y(`**/${o}/client.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),s=await y(`**/${o}/settings/content.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),i=await y(`**/${o}/settings/design.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),r=await y(`**/${o}/settings/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),m=await y(`**/${o}/showcases/*.{js,ts}`,{ignore:["node_modules/**","dist/**",`**/${o}/showcases/translations.{js,ts}`]}),T=await y(`**/${o}/showcases/translations.{js,ts}`,{ignore:["node_modules/**","dist/**"]}),b=await y(`**/${o}/assets/*`,{ignore:["node_modules/**","dist/**"]});return{name:o,serverEntrypoint:t,clientEntrypoint:n.at(0),contentSettingsEntrypoint:s.at(0),designSettingsEntrypoint:i.at(0),settingsTranslationsEntrypoint:r.at(0),showcasesEntrypoints:m,showcasesTranslationsEntrypoint:T.at(0),assetsEntrypoints:b}}))}async function ct(){return{entryPoints:await y("**/templates/**.{js,ts}",{ignore:["node_modules/**","dist/**"]})}}async function x(e,t){try{return(await import(l(process.cwd(),t?`${e}${w}.mjs`:`${e}.mjs`))).default}catch{throw new Error(`File [${e}${w}.mjs] is either invalid or undefined`)}}async function pt(){let e=new qe({allErrors:!0,schemas:[ne,et,ot,st,rt]});return ze(e),e.compile(ne)}async function lt(e,t,o,n){if(e(t)&&n===void 0)new Promise(s=>{Re(`${o}${w}.mjs`,`${o}.mjs`,function(i){i&&s(i)})});else throw new Promise(s=>{Be(`${o}${w}.mjs`,function(i){i&&s(i)})}),new Error(`Invalid file [${L(o).name}].
|
|
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}].
|
|
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??[],...
|
|
5
|
-
`)}async function
|
|
6
|
-
Current app version: ${
|
|
7
|
-
Deployed sections: ${
|
|
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)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightspeed/crane",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": "bin/crane.js",
|
|
6
6
|
"main": "./dist/app.mjs",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@jridgewell/sourcemap-codec": "^1.4.15",
|
|
52
|
-
"@lightspeed/eslint-config-crane": "1.0.
|
|
52
|
+
"@lightspeed/eslint-config-crane": "1.0.2",
|
|
53
53
|
"@types/prompts": "^2.4.2",
|
|
54
54
|
"@vitejs/plugin-vue": "^4.1.0",
|
|
55
55
|
"ajv": "^8.12.0",
|
package/template/package.json
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
"deploy": "crane build && crane deploy"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@lightspeed/crane": "1.0.
|
|
11
|
-
"@lightspeed/eslint-config-crane": "1.0.
|
|
10
|
+
"@lightspeed/crane": "1.0.3",
|
|
11
|
+
"@lightspeed/eslint-config-crane": "1.0.2",
|
|
12
12
|
"vue": "^3.4.0"
|
|
13
13
|
},
|
|
14
14
|
"engines": {
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
<div class="image-section__link-wrap">
|
|
11
11
|
<div
|
|
12
12
|
class="image-section__content-block"
|
|
13
|
-
:class="
|
|
14
|
-
:style="overlayStyle"
|
|
13
|
+
:class="`image-section__content-block-${imagePosition}`"
|
|
14
|
+
:style="[imagePosition === 'position-under' ? '' : overlayStyle]"
|
|
15
15
|
>
|
|
16
16
|
<img
|
|
17
17
|
v-if="url !== undefined"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
<div
|
|
23
23
|
v-if="textDesign.visible"
|
|
24
24
|
class="image-section__text"
|
|
25
|
-
:class="
|
|
25
|
+
:class="`image-section__text-${imagePosition}`"
|
|
26
26
|
>
|
|
27
27
|
<h1
|
|
28
28
|
:style="textStyle"
|
|
@@ -37,7 +37,11 @@
|
|
|
37
37
|
|
|
38
38
|
<script setup lang="ts">
|
|
39
39
|
import { computed, toRefs } from 'vue';
|
|
40
|
-
import {
|
|
40
|
+
import {
|
|
41
|
+
useImageElementDesign,
|
|
42
|
+
useTextareaElementDesign,
|
|
43
|
+
useLayoutElementDesign,
|
|
44
|
+
} from '@lightspeed/crane';
|
|
41
45
|
import { Design } from '../../type.ts';
|
|
42
46
|
import { ColorType } from '../../entity/color.ts';
|
|
43
47
|
|
|
@@ -52,9 +56,9 @@ const props = defineProps<{
|
|
|
52
56
|
}>();
|
|
53
57
|
|
|
54
58
|
const { url, text, link } = toRefs(props);
|
|
55
|
-
const textDesign =
|
|
59
|
+
const textDesign = useTextareaElementDesign<Design>('image_text');
|
|
56
60
|
const imageDesign = useImageElementDesign<Design>('image_content');
|
|
57
|
-
const
|
|
61
|
+
const layoutDesign = useLayoutElementDesign();
|
|
58
62
|
|
|
59
63
|
const component = computed(() => {
|
|
60
64
|
if (link.value !== undefined && link.value !== '') {
|
|
@@ -80,26 +84,25 @@ const overlayStyle = computed(() => {
|
|
|
80
84
|
return {};
|
|
81
85
|
});
|
|
82
86
|
|
|
87
|
+
const imagePosition = computed(() => {
|
|
88
|
+
switch (layoutDesign.layout) {
|
|
89
|
+
case 'Caption_Under_Image':
|
|
90
|
+
return 'position-under';
|
|
91
|
+
case 'Caption_On_Image':
|
|
92
|
+
return 'position-on';
|
|
93
|
+
default:
|
|
94
|
+
return 'position-on';
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
83
98
|
const textStyle = computed(() => ({
|
|
84
99
|
fontSize: `${textDesign.size}px`,
|
|
85
100
|
fontFamily: textDesign.font,
|
|
86
101
|
color: (textDesign.color as Color).hex,
|
|
87
102
|
'font-style': textDesign.italic ? 'italic' : 'normal',
|
|
88
103
|
'font-weight': textDesign.bold ? 'bold' : 'normal',
|
|
104
|
+
'white-space': textDesign.whiteSpace,
|
|
89
105
|
}));
|
|
90
|
-
|
|
91
|
-
const textPositionClass = computed(() => {
|
|
92
|
-
if (textDesign.visible && positionDesign.value === 'under') {
|
|
93
|
-
return 'image-section__text-position-under';
|
|
94
|
-
}
|
|
95
|
-
return 'image-section__text-position-on';
|
|
96
|
-
});
|
|
97
|
-
const imagePositionClass = computed(() => {
|
|
98
|
-
if (textDesign.visible && positionDesign.value === 'under') {
|
|
99
|
-
return 'image-section__content-block-position-under';
|
|
100
|
-
}
|
|
101
|
-
return 'image-section__content-block-position-on';
|
|
102
|
-
});
|
|
103
106
|
</script>
|
|
104
107
|
|
|
105
108
|
<style lang="scss" scoped>
|
|
@@ -18,13 +18,15 @@
|
|
|
18
18
|
|
|
19
19
|
<script setup lang="ts">
|
|
20
20
|
import { computed } from 'vue';
|
|
21
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
useInputboxElementContent, useTextareaElementContent, useTextElementDesign, useTextareaElementDesign,
|
|
23
|
+
} from '@lightspeed/crane';
|
|
22
24
|
import { Content, Design } from '../../type.ts';
|
|
23
25
|
|
|
24
26
|
const titleContent = useInputboxElementContent<Content>('section_title');
|
|
25
27
|
const descriptionContent = useTextareaElementContent<Content>('section_description');
|
|
26
28
|
const titleDesign = useTextElementDesign<Design>('section_title');
|
|
27
|
-
const descriptionDesign =
|
|
29
|
+
const descriptionDesign = useTextareaElementDesign<Design>('section_description');
|
|
28
30
|
|
|
29
31
|
const showTitle = computed(() => titleDesign.visible && titleContent.hasContent);
|
|
30
32
|
const showDescription = computed(() => descriptionDesign.visible && descriptionContent.hasContent);
|
|
@@ -43,6 +45,7 @@ const descriptionStyle = computed(() => ({
|
|
|
43
45
|
color: (descriptionDesign.color as Color).hex,
|
|
44
46
|
'font-style': descriptionDesign.italic ? 'italic' : 'normal',
|
|
45
47
|
'font-weight': descriptionDesign.bold ? 'bold' : 'normal',
|
|
48
|
+
'white-space': descriptionDesign.whiteSpace,
|
|
46
49
|
}));
|
|
47
50
|
</script>
|
|
48
51
|
|
|
@@ -37,7 +37,7 @@ export default {
|
|
|
37
37
|
size: 16,
|
|
38
38
|
bold: false,
|
|
39
39
|
italic: true,
|
|
40
|
-
color: '#
|
|
40
|
+
color: '#FFFFFF',
|
|
41
41
|
visible: true,
|
|
42
42
|
},
|
|
43
43
|
},
|
|
@@ -50,25 +50,6 @@ export default {
|
|
|
50
50
|
color: '#333',
|
|
51
51
|
},
|
|
52
52
|
},
|
|
53
|
-
image_text_position: {
|
|
54
|
-
type: 'SELECTBOX',
|
|
55
|
-
label: '$label.image_text_position.label',
|
|
56
|
-
placeholder: '$label.image_text_position.placeholder',
|
|
57
|
-
description: '$label.image_text_position.description',
|
|
58
|
-
options: [
|
|
59
|
-
{
|
|
60
|
-
value: 'on',
|
|
61
|
-
label: '$label.image_text_position.on.label',
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
value: 'under',
|
|
65
|
-
label: '$label.image_text_position.under.label',
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
defaults: {
|
|
69
|
-
value: 'on',
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
53
|
background: {
|
|
73
54
|
type: 'BACKGROUND',
|
|
74
55
|
label: '$label.background.label',
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export default [
|
|
2
|
+
{
|
|
3
|
+
layoutId: 'Caption_On_Image',
|
|
4
|
+
selectedContentSettings: [],
|
|
5
|
+
selectedDesignSettings: [],
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
layoutId: 'Caption_Under_Image',
|
|
9
|
+
selectedContentSettings: [],
|
|
10
|
+
selectedDesignSettings: [
|
|
11
|
+
{
|
|
12
|
+
fieldName: 'section_title',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
fieldName: 'section_description',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
fieldName: 'image_text',
|
|
19
|
+
type: 'TEXT',
|
|
20
|
+
defaults: {
|
|
21
|
+
font: 'global.fontFamily.body',
|
|
22
|
+
size: 16,
|
|
23
|
+
bold: true,
|
|
24
|
+
italic: false,
|
|
25
|
+
color: '#000000',
|
|
26
|
+
visible: true,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
fieldName: 'background',
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
] as const;
|
|
@@ -20,11 +20,6 @@ export default {
|
|
|
20
20
|
'$label.image_link_3.label': 'Image 3 link',
|
|
21
21
|
'$label.image_link_4.label': 'Image 4 link',
|
|
22
22
|
'$label.image_link.placeholder': 'Enter an optional URL for the image',
|
|
23
|
-
'$label.image_text_position.label': 'Image caption position',
|
|
24
|
-
'$label.image_text_position.placeholder': 'Choose',
|
|
25
|
-
'$label.image_text_position.description': 'Select the position of the image caption',
|
|
26
|
-
'$label.image_text_position.on.label': 'On the image',
|
|
27
|
-
'$label.image_text_position.under.label': 'Below the image',
|
|
28
23
|
'$label.background.label': 'Background',
|
|
29
24
|
},
|
|
30
25
|
|
|
@@ -49,11 +44,6 @@ export default {
|
|
|
49
44
|
'$label.image_link_3.label': 'Afbeelding 3 link',
|
|
50
45
|
'$label.image_link_4.label': 'Afbeelding 4 link',
|
|
51
46
|
'$label.image_link.placeholder': 'Voer een optionele URL in voor de afbeelding',
|
|
52
|
-
'$label.image_text_position.label': 'Positie van bijschrift afbeelding',
|
|
53
|
-
'$label.image_text_position.placeholder': 'Kies',
|
|
54
|
-
'$label.image_text_position.description': 'Selecteer de positie van het afbeeldingsbijschrift',
|
|
55
|
-
'$label.image_text_position.on.label': 'Op de afbeelding',
|
|
56
|
-
'$label.image_text_position.under.label': 'Onder de afbeelding',
|
|
57
47
|
'$label.background.label': 'Achtergrond',
|
|
58
48
|
},
|
|
59
49
|
} as const;
|
|
@@ -8,6 +8,7 @@ export default {
|
|
|
8
8
|
},
|
|
9
9
|
},
|
|
10
10
|
blockName: '$label.showcase_1.blockName',
|
|
11
|
+
layoutId: 'Caption_On_Image',
|
|
11
12
|
content: {
|
|
12
13
|
section_title: {
|
|
13
14
|
type: 'INPUTBOX',
|
|
@@ -144,7 +145,6 @@ export default {
|
|
|
144
145
|
size: 20,
|
|
145
146
|
bold: false,
|
|
146
147
|
italic: false,
|
|
147
|
-
color: '#FFFFFF',
|
|
148
148
|
},
|
|
149
149
|
background: {
|
|
150
150
|
type: 'BACKGROUND',
|
|
Binary file
|
|
@@ -2,23 +2,27 @@ export default {
|
|
|
2
2
|
metadata: {
|
|
3
3
|
name: 'Example Template :: Standard Preset',
|
|
4
4
|
description: 'Standard Preset for the Example template',
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
test_site_id: 1,
|
|
6
|
+
cover_image: {
|
|
7
|
+
set: {
|
|
8
|
+
ORIGINAL: {
|
|
9
|
+
url: 'template_cover_image.png',
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
},
|
|
9
13
|
},
|
|
10
14
|
sections: [
|
|
11
15
|
{
|
|
12
16
|
type: 'default',
|
|
13
|
-
id: 'header'
|
|
17
|
+
id: 'header',
|
|
14
18
|
},
|
|
15
19
|
{
|
|
16
20
|
type: 'default',
|
|
17
|
-
id: 'slider_001'
|
|
21
|
+
id: 'slider_001',
|
|
18
22
|
},
|
|
19
23
|
{
|
|
20
24
|
type: 'custom',
|
|
21
|
-
id: 'example-section'
|
|
25
|
+
id: 'example-section',
|
|
22
26
|
},
|
|
23
27
|
{
|
|
24
28
|
type: 'custom',
|
|
@@ -130,7 +134,7 @@ export default {
|
|
|
130
134
|
size: 16,
|
|
131
135
|
bold: false,
|
|
132
136
|
italic: true,
|
|
133
|
-
color: '#
|
|
137
|
+
color: '#FFFFFF',
|
|
134
138
|
visible: true,
|
|
135
139
|
},
|
|
136
140
|
},
|
|
@@ -143,25 +147,6 @@ export default {
|
|
|
143
147
|
color: '#333',
|
|
144
148
|
},
|
|
145
149
|
},
|
|
146
|
-
image_text_position: {
|
|
147
|
-
type: 'SELECTBOX',
|
|
148
|
-
label: '$label.image_text_position.label',
|
|
149
|
-
placeholder: '$label.image_text_position.placeholder',
|
|
150
|
-
description: '$label.image_text_position.description',
|
|
151
|
-
options: [
|
|
152
|
-
{
|
|
153
|
-
value: 'on',
|
|
154
|
-
label: '$label.image_text_position.on.label',
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
value: 'under',
|
|
158
|
-
label: '$label.image_text_position.under.label',
|
|
159
|
-
},
|
|
160
|
-
],
|
|
161
|
-
defaults: {
|
|
162
|
-
value: 'on',
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
150
|
background: {
|
|
166
151
|
type: 'BACKGROUND',
|
|
167
152
|
label: '$label.background.label',
|
|
@@ -175,7 +160,7 @@ export default {
|
|
|
175
160
|
},
|
|
176
161
|
{
|
|
177
162
|
type: 'default',
|
|
178
|
-
id: 'footer'
|
|
179
|
-
}
|
|
180
|
-
]
|
|
181
|
-
}
|
|
163
|
+
id: 'footer',
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
};
|
package/types.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ type ButtonType =
|
|
|
16
16
|
|
|
17
17
|
interface ButtonContentData {
|
|
18
18
|
readonly title: string;
|
|
19
|
-
readonly
|
|
19
|
+
readonly type: ButtonType;
|
|
20
20
|
readonly link?: string;
|
|
21
21
|
readonly email?: string;
|
|
22
22
|
readonly phone?: string;
|
|
@@ -104,6 +104,10 @@ interface TextDesignData {
|
|
|
104
104
|
visible: boolean;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
interface TextareaDesignData extends TextDesignData {
|
|
108
|
+
readonly whiteSpace: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
107
111
|
type ButtonAppearance =
|
|
108
112
|
'solid-button'
|
|
109
113
|
| 'outline-button'
|