@silexlabs/silex 3.0.0-alpha.122 → 3.0.0-alpha.123

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/.env.default CHANGED
@@ -8,7 +8,7 @@ SILEX_PORT=6805 # 6805 is the date of sexual revolution started in paris france
8
8
  SILEX_HOST=localhost
9
9
  SILEX_PROTOCOL=http
10
10
  SILEX_DEBUG=FALSE
11
- SILEX_CONFIG=
11
+ SILEX_SERVER_CONFIG=
12
12
  SILEX_SSL_PORT=
13
13
  SILEX_FORCE_HTTPS=
14
14
  SILEX_SSL_PRIVATE_KEY=
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
- [![status of silex.me instance](https://monitoshi.lexoyo.me/badge/1525963562293-6552)](https://editor.silex.me)
1
+ [![status of silex.me instance](https://monitoshi.lexoyo.me/badge/1525963562293-6552)](https://v3.silex.me)
2
2
 
3
3
  ![Silex UI](https://github.com/silexlabs/www.silex.me/raw/gh-pages/assets/silex-ui.gif)
4
4
 
5
5
  Brought to you by [Alex Hoyau](https://www.patreon.com/lexoyo) and [Silex contributors](https://github.com/silexlabs/Silex/graphs/contributors).
6
6
 
7
- You can help make Silex sustainable by being part of the community, contributing documentation or making a financial contribution. [Let's chat - every little bit helps!](https://github.com/silexlabs/Silex/discussions)
7
+ Help make Silex sustainable by being [part of the community](https://community.silex.me/), [contributing documentation](https://docs.silex.me/), [making a financial contribution](https://opencollective.com/silex), [report bugs](https://github.com/silexlabs/Silex/issues).
8
8
 
9
- ## About Silex, live web creation.
9
+ ## Silex
10
10
 
11
11
  Silex is a no-code tool for building websites. It also lets you code when needed. It can be used online, offline or in a JAMStack project.
12
12
 
@@ -48,13 +48,15 @@ There is a desktop application that you can install on your computer which may b
48
48
 
49
49
  You can also run Silex locally or on your server using `npx`, `npm`, or `Docker`.
50
50
 
51
+ Check the [developer docs](https://docs.silex.me/en/dev) for configuration options and integration with your js projects.
52
+
51
53
  #### Using npx
52
54
 
53
55
  ```bash
54
56
  npx @silexlabs/silex
55
57
  ```
56
58
 
57
- This command will run Silex with the entry point being `src/ts/server/cli.ts`.
59
+ This command will run Silex with default config.
58
60
 
59
61
  #### Using Docker
60
62
 
@@ -62,7 +64,7 @@ This command will run Silex with the entry point being `src/ts/server/cli.ts`.
62
64
  docker run -p 6805:6805 silexlabs/silex
63
65
  ```
64
66
 
65
- This command will run Silex in a Docker container with the entry point being `src/ts/server/index.ts`.
67
+ This command will run Silex in a Docker container.
66
68
 
67
69
  #### Using npm
68
70
 
@@ -72,16 +74,30 @@ First, install Silex as a dev dependency in your project:
72
74
  npm install --save-dev @silexlabs/silex
73
75
  ```
74
76
 
75
- Then, you can run Silex with the `silex` command. The entry point is `src/ts/server/cli.ts`.
77
+ Then, you can run Silex with the `silex` command in your `package.json` scripts:
78
+
79
+ ```json
80
+ {
81
+ "scripts": {
82
+ "start": "silex"
83
+ }
84
+ }
85
+ ```
76
86
 
77
87
  ## Configuration
78
88
 
79
- You can configure Silex using environment variables and command-line options. All available options can be found in `src/ts/server/cli.ts`.
89
+ You can configure Silex using environment variables and command-line options. All available options can be found in the [developer docs](https://docs.silex.me/en/dev) as well as in the code: [`src/ts/server/cli.ts`](./src/ts/server/cli.ts).
90
+
91
+ Check the example config files - which are the same as plugins in Silex, in the [`examples/`](./examples/) folder. To test these configs, start Silex locally like this:
92
+
93
+ ```sh
94
+ $ npx silex --client-config=./examples/client-config-transformers.js --server-config=`pwd`/examples/server-config-plugins.js
95
+ ```
80
96
 
81
- There are config files (same as plugins) in the `examples/` folder. To start Silex locally with these config:
97
+ Or like this:
82
98
 
83
99
  ```sh
84
- $ SILEX_CLIENT_CONFIG=./examples/client-config-transformers.js SILEX_CONFIG=`pwd`/examples/server-config-plugins.js npm run start:debug
100
+ $ SILEX_CLIENT_CONFIG=./examples/client-config-transformers.js SILEX_SERVER_CONFIG=`pwd`/examples/server-config-plugins.js npm run start:debug
85
101
  ```
86
102
 
87
103
  ## Contributing
@@ -228,7 +228,7 @@ var silex;(()=>{var t={99:function(t){"undefined"!=typeof globalThis?globalThis:
228
228
  @click=${()=>this.editor.Commands.stop(wr)}
229
229
  >Close</button>
230
230
  </footer>
231
- `}}displayPending(t,e){this.errorMessage=null,this.renderDialog(t,e)}displayError(t,e,n){console.info(t),this.errorMessage=t,this.renderDialog(e,n)}async closeDialog(){this.isOpen=!1,this.renderDialog(null,null),this.sender&&this.sender.set("active",0),this.sender=null}async toggleDialog(){this.isOpen?this.closeDialog():this.openDialog()}async openDialog(){this.isOpen=!0;const t=this.editor.Panels.getPanel("options")?.view.el.querySelector(".publish-button");if(t){const e=t.getBoundingClientRect(),n=450,r=20,o=50;this.move({left:e.right-n-r,top:e.bottom+10,width:n,minHeight:o})}else console.error("Unable to find publish button");this.renderDialog(null,Wr.STATUS_NONE)}}var Cr;function Sr(t,e){t.Pages.getAll().forEach((t=>{t.getMainComponent().onAll((t=>e(t)))}))}!function(t){t.STARTUP_START="silex:startup:start",t.STARTUP_END="silex:startup:end",t.GRAPESJS_START="silex:grapesjs:start",t.GRAPESJS_END="silex:grapesjs:end",t.PUBLISH_START="silex:publish:start",t.PUBLISH_DATA="silex:publish:data",t.PUBLISH_END="silex:publish:end",t.PUBLISH_ERROR="silex:publish:error",t.PUBLISH_LOGIN_START="silex:publish:login:start",t.PUBLISH_LOGIN_END="silex:publish:login:end",t.ASSET_WRITE_END="silex:asset:write:end",t.WRITE_END="silex:write:end"}(Cr||(Cr={}));const Or="tmp-pre-publication-transformer-tohtml",Tr="tmp-pre-publication-transformer-src",Er="tmp-pre-publication-transformer-attributes-src",kr="tmp-pre-publication-transformer-inline-css",Ar="tmp-pre-publication-transformer-href",Pr="tmp-pre-publication-transformer-tocss",jr={renderComponent:(t,e)=>e(),renderCssRule:(t,e)=>e(),transformPath:(t,e)=>t,transformPermalink(t,e,n){switch(n){case Ae.HTML:return t;case Ae.CSS:return`../${t.replace(/^\//,"")}`;default:throw new Error(`Unknown initiator ${n}`)}},transformFile:t=>t};function Mr(t,e){const n=e["background-image"],r=n?.match(/url\(["']?(.*?)["']?\)/)?.pop();return r?{...e,"background-image":`url(${Lr(t,r,ke.ASSET,Ae.CSS)})`}:e}function Lr(t,e,n,r){return t.getModel().get("config").publicationTransformers.reduce(((t,e)=>{try{return e.transformPermalink?e.transformPermalink(t,n,r)??t:t}catch(e){return console.error("Publication transformer: error transforming path",t,e),t}}),e)}function Nr(t,e,n){return t.getModel().get("config").publicationTransformers.reduce(((t,e)=>{try{return e.transformPath?e.transformPath(t,n)??t:t}catch(e){return console.error("Publication transformer: error transforming path",t,e),t}}),e)}const Ir=window.location.pathname.replace(/\/$/,""),Dr=window.location.origin;function $r(t,e,n){if(t.startsWith("/assets")){const r=new URL(t,Dr);return r.pathname=r.pathname.replace(/^\/assets/,""),r.pathname=`${Ir}${rn}${gn}${xn}${r.pathname}`,r.searchParams.set("websiteId",e),r.searchParams.set("connectorId",n),`${decodeURIComponent(r.pathname)}${r.search}`}return console.warn("storedToDisplayed: path is not a stored path",t),t}function Rr(t){const e=`${Ir}${rn}${gn}${xn}`;if(t.startsWith(e)){const n=new URL(t,Dr);n.pathname=n.pathname.replace(new RegExp(`^${e}`),""),n.pathname=`${Ir}/assets${n.pathname}`,n.searchParams.delete("websiteId"),n.searchParams.delete("connectorId");const r="/"+n.toString().replace(new RegExp(`^${Dr}${Ir}`),"").replace(/^\//,"");return decodeURIComponent(r)}return console.warn("displayedToStored: path is not a displayed path",t),t}const Hr={transformPath(t,e){if(e===ke.ASSET)return Rr(t)},transformPermalink(t,e){if(e===ke.ASSET)return Rr(t)}};function Fr(t,e,n){const r=t.attributes?.src?{...t,attributes:{...t.attributes,src:$r(t.attributes.src,e,n)}}:t;return r.components&&(r.components=r.components.map((t=>Fr(t,e,n)))),r}function Vr(t){const e=t.attributes?.src?{...t,attributes:{...t.attributes,src:Rr(t.attributes.src)}}:t;return e.components&&(e.components=e.components.map((t=>Vr(t)))),e}const Ur="publish",Br="publish-login",zr="publish-logout";var Wr;function qr(t,e){t.PublicationManager=new Yr(t,e)}function Gr(t){switch(t){case je.IN_PROGRESS:return Wr.STATUS_PENDING;case je.ERROR:return Wr.STATUS_ERROR;case je.SUCCESS:return Wr.STATUS_SUCCESS}throw new Error(`Unknown job status ${t}`)}!function(t){t.STATUS_NONE="STATUS_NONE",t.STATUS_PENDING="STATUS_PENDING",t.STATUS_ERROR="STATUS_ERROR",t.STATUS_SUCCESS="STATUS_SUCCESS",t.STATUS_LOGGED_OUT="STATUS_AUTH_ERROR"}(Wr||(Wr={}));const Kr=window.location.origin+window.location.pathname.replace(/\/$/,"");class Yr{editor;dialog;_settings;get settings(){return this._settings}set settings(t){this._settings=t,this.dialog&&(this.dialog.settings=t)}options;job=null;status=Wr.STATUS_NONE;constructor(t,e){this.editor=t,this.options={appendTo:"options",...e},t.on("storage:start:store",(t=>{t.publication=this.settings})),t.on("storage:end:load",(t=>{this.settings=t.publication??{},De({type:Pe.HOSTING,connectorId:this.settings.connector?.connectorId}).then((t=>{})).catch((t=>{this.status=Wr.STATUS_LOGGED_OUT,this.settings={},this.dialog&&this.dialog.displayError("Please login",this.job,this.status)}))})),t.Commands.add(Ur,(()=>this.startPublication())),t.Commands.add(Br,((t,e,n)=>this.goLogin(n))),t.Commands.add(zr,(()=>this.goLogout())),this.options.appendTo?this.dialog=new xr(t,{appendTo:this.options.appendTo}):console.info("PublicationUi is disabled because no appendTo option is set")}async goLogin(t){if(t.isLoggedIn)return this.settings={...this.settings,connector:t},this.status=Wr.STATUS_NONE,this.editor.store(null),void(this.dialog&&this.dialog.displayPending(this.job,this.status));this.settings={},this.status=Wr.STATUS_LOGGED_OUT,this.dialog&&this.dialog.displayPending(this.job,this.status);const e=t.connectorId,n=t.type;return window.open(t.oauthUrl||`${Kr}${rn}${on}${cn}?connectorId=${e}&type=${n}`,"_blank"),new Promise((e=>{const n=async e=>{const r=e.data;"login"===r?.type&&(window.removeEventListener("message",n),r.error?(this.status=Wr.STATUS_LOGGED_OUT,this.settings={},this.dialog&&this.dialog.displayError(r.message,this.job,this.status)):(this.editor.trigger(Cr.PUBLISH_LOGIN_END),this.settings.connector=t,this.settings.options=r.options,this.status=Wr.STATUS_NONE,this.editor.store(null),this.dialog&&this.dialog.displayPending(this.job,this.status)))};window.addEventListener("message",n,!1)}))}async goLogout(){try{await $e({type:Pe.HOSTING,connectorId:this.settings.connector.connectorId}),this.settings={},this.dialog&&this.dialog.displayPending(this.job,this.status)}catch(t){console.error("logout error",t),this.status=Wr.STATUS_ERROR,this.dialog&&this.dialog.displayError(t.message,this.job,this.status)}}async startPublication(){if(this.status===Wr.STATUS_PENDING)throw new Error("Publication is already in progress");this.status=Wr.STATUS_PENDING,this.job=null,this.dialog&&this.dialog.displayPending(this.job,this.status),this.editor.trigger(Cr.PUBLISH_START);const t=this.editor.getModel().get("user");if(!t)throw new Error("User not logged in to a storage connector");if(!this.settings.connector?.connectorId)throw new Error("User not logged in to a hosting connector");const e=this.options.websiteId,n=t.storage.connectorId;this.setPublicationTransformers();const r=this.editor.getProjectData(),o=this.editor.getModel().get("settings"),i=(await this.getHtmlFiles(o)).flatMap((t=>[{path:t.htmlPath,content:t.html,type:ke.HTML},{path:t.cssPath,content:t.css,type:ke.CSS}])).concat(r.assets.map((t=>{const e=Nr(this.editor,t.src,ke.ASSET),n=Rr(t.src).replace(/^\/assets\//,"");return{...t,path:e,src:n,type:ke.ASSET}}))),a={...r,assets:r.assets.map((t=>({...t,src:Rr(t.src)}))),settings:o,publication:this.settings,files:i};this.resetPublicationTransformers(),function(t,e){const n=t.getModel().get("config");e.files=n.publicationTransformers.reduce(((t,n)=>t.map(((t,r)=>{try{return e.pages[r],n.transformFile?n.transformFile(t)??t:t}catch(e){return console.error("Publication transformer: error transforming file",t,e),t}}))),e.files)}(this.editor,a),this.editor.trigger(Cr.PUBLISH_DATA,a);try{const[t,r]=await Re({websiteId:e,hostingId:this.settings.connector.connectorId,storageId:n,data:a,options:this.settings.options});this.job=r,this.status=Gr(this.job.status),this.trackProgress()}catch(t){return console.error("publish error",t),401===t.code||401===t.httpStatusCode?(this.status=Wr.STATUS_LOGGED_OUT,this.settings={},this.dialog&&this.dialog.displayError("Please login.",this.job,this.status)):(this.status=Wr.STATUS_ERROR,this.dialog&&this.dialog.displayError(`An error occured, your site is not published. ${t.message}`,this.job,this.status)),this.editor.trigger(Cr.PUBLISH_ERROR,{success:!1,message:t.message}),void this.editor.trigger(Cr.PUBLISH_END,{success:!1,message:t.message})}}async getHtmlFiles(t){return this.editor.Pages.getAll().map((e=>{const n=e.get("settings");function r(e){return(n||{})[e]||(t||[])[e]||""}const o=e.getMainComponent(),i=vr(e.get("name")),a=`/css/${i}.css`,s=`/${i}.html`,l=Lr(this.editor,a,ke.CSS,Ae.HTML),c=Nr(this.editor,a,ke.CSS),u=Nr(this.editor,s,ke.HTML),p=this.editor.getHtml({component:o});return{html:`<!DOCTYPE html>\n<html lang="${r("lang")}">\n<head>\n<meta charset="UTF-8">\n<link rel="stylesheet" href="${l}" />\n${t?.head||""}\n${n?.head||""}\n<title>${r("title")}</title>\n<link rel="icon" href="${r("favicon")}" />\n${["description","og:title","og:description","og:image"].map((t=>`<meta name="${t}" property="${t}" content="${r(t)}"/>`)).join("\n")}\n</head>\n${p}\n</html>`,css:this.editor.getCss({component:o}),cssPath:c,htmlPath:u}}))}async trackProgress(){try{this.job=await He({jobId:this.job.jobId}),this.status=Gr(this.job.status)}catch(t){return this.status=Wr.STATUS_ERROR,this.dialog&&this.dialog.displayError(`An error occured, your site is not published. ${t.message}`,this.job,this.status),this.editor.trigger(Cr.PUBLISH_END,{success:!1,message:t.message}),void this.editor.trigger(Cr.PUBLISH_ERROR,{success:!1,message:t.message})}this.job.status===je.IN_PROGRESS?setTimeout((()=>this.trackProgress()),2e3):this.editor.trigger(Cr.PUBLISH_END,{success:this.job.status===je.SUCCESS,message:this.job.message}),this.dialog&&this.dialog.displayPending(this.job,this.status)}setPublicationTransformers(){!function(t){const e=t.getModel().get("config");Sr(t,(n=>{if(n.get(Or))console.warn("Publication transformer: HTML transform already altered",n);else{const r=n.toHTML.bind(n);n[Or]=n.toHTML;const o=n.getStyle.bind(n);n[kr]=n.getStyle;const i=n.get("attributes").href;if(i?.startsWith("./")&&(n[Ar]=i,n.set("attributes",{...n.get("attributes"),href:Lr(t,i,ke.HTML,Ae.HTML)})),n.get("attributes").src){n[Tr]=n.get("attributes").src;const e=Lr(t,n.get("attributes").src,ke.ASSET,Ae.HTML);n.set("attributes",{...n.get("attributes"),src:e})}if(n.get("src")){n[Er]=n.get("src");const e=Lr(t,n.get("src"),ke.ASSET,Ae.HTML);n.set("src",e)}n.toHTML=()=>e.publicationTransformers.reduce(((t,e)=>{try{return e.renderComponent?e.renderComponent(n,(()=>t))??t:t}catch(e){return console.error("Publication transformer: error rendering component",n,e),t}}),r()),n.getStyle=()=>Mr(t,o())}}))}(this.editor),function(t){const e=t.getModel().get("config");t.Css.getAll().forEach((n=>{if(n[Pr])console.warn("Publication transformer: CSS transform already altered",n);else{const r=n.getStyle.bind(n);n[Pr]=n.getStyle,n.getStyle=()=>{try{const n=Mr(t,r()),o=e.publicationTransformers.reduce(((t,e)=>({...e.renderCssRule?e.renderCssRule(t,(()=>n))??t:t})),n);return o}catch(t){return console.error("Publication transformer: error rendering style",n,t),r()}}}}))}(this.editor)}resetPublicationTransformers(){!function(t){Sr(t,(t=>{t[Or]&&(t.toHTML=t[Or],delete t[Or]),t[kr]&&(t.getStyle=t[kr],delete t[kr]),t[Tr]&&(t.set("attributes",{...t.get("attributes"),src:t[Tr]}),delete t[Tr]),t[Er]&&(t.set("src",t[Er]),delete t[Er]),t[Ar]&&(t.set("attributes",{...t.get("attributes"),href:t[Ar]}),delete t[Ar])}))}(this.editor),function(t){t.Css.getAll().forEach((t=>{t[Pr]&&(t.getStyle=t[Pr],delete t[Pr])}))}(this.editor)}}const Xr=[{name:"./project-bar",value:nr},{name:"grapesjs-style-bg",value:zn()},{name:"./settings",value:(t,e)=>{try{sr="3.0.0-alpha.122"}catch(t){}console.info("Silex version:",sr),t.Commands.add(ar,{run:(e,n,{page:r})=>{ir=t.Modal.open({title:r?"Page settings":"Site Settings",content:"",attributes:{class:"settings-dialog"}}).onceClose((()=>{n?.set&&n.set("active",0),t.stopCommand(ar)})),function(t,e,n=t.getModel()){const r=n.get("settings")||{};n.set("settings",r),qt(Et`
231
+ `}}displayPending(t,e){this.errorMessage=null,this.renderDialog(t,e)}displayError(t,e,n){console.info(t),this.errorMessage=t,this.renderDialog(e,n)}async closeDialog(){this.isOpen=!1,this.renderDialog(null,null),this.sender&&this.sender.set("active",0),this.sender=null}async toggleDialog(){this.isOpen?this.closeDialog():this.openDialog()}async openDialog(){this.isOpen=!0;const t=this.editor.Panels.getPanel("options")?.view.el.querySelector(".publish-button");if(t){const e=t.getBoundingClientRect(),n=450,r=20,o=50;this.move({left:e.right-n-r,top:e.bottom+10,width:n,minHeight:o})}else console.error("Unable to find publish button");this.renderDialog(null,Wr.STATUS_NONE)}}var Cr;function Sr(t,e){t.Pages.getAll().forEach((t=>{t.getMainComponent().onAll((t=>e(t)))}))}!function(t){t.STARTUP_START="silex:startup:start",t.STARTUP_END="silex:startup:end",t.GRAPESJS_START="silex:grapesjs:start",t.GRAPESJS_END="silex:grapesjs:end",t.PUBLISH_START="silex:publish:start",t.PUBLISH_DATA="silex:publish:data",t.PUBLISH_END="silex:publish:end",t.PUBLISH_ERROR="silex:publish:error",t.PUBLISH_LOGIN_START="silex:publish:login:start",t.PUBLISH_LOGIN_END="silex:publish:login:end",t.ASSET_WRITE_END="silex:asset:write:end",t.WRITE_END="silex:write:end"}(Cr||(Cr={}));const Or="tmp-pre-publication-transformer-tohtml",Tr="tmp-pre-publication-transformer-src",Er="tmp-pre-publication-transformer-attributes-src",kr="tmp-pre-publication-transformer-inline-css",Ar="tmp-pre-publication-transformer-href",Pr="tmp-pre-publication-transformer-tocss",jr={renderComponent:(t,e)=>e(),renderCssRule:(t,e)=>e(),transformPath:(t,e)=>t,transformPermalink(t,e,n){switch(n){case Ae.HTML:return t;case Ae.CSS:return`../${t.replace(/^\//,"")}`;default:throw new Error(`Unknown initiator ${n}`)}},transformFile:t=>t};function Mr(t,e){const n=e["background-image"],r=n?.match(/url\(["']?(.*?)["']?\)/)?.pop();return r?{...e,"background-image":`url(${Lr(t,r,ke.ASSET,Ae.CSS)})`}:e}function Lr(t,e,n,r){return t.getModel().get("config").publicationTransformers.reduce(((t,e)=>{try{return e.transformPermalink?e.transformPermalink(t,n,r)??t:t}catch(e){return console.error("Publication transformer: error transforming path",t,e),t}}),e)}function Nr(t,e,n){return t.getModel().get("config").publicationTransformers.reduce(((t,e)=>{try{return e.transformPath?e.transformPath(t,n)??t:t}catch(e){return console.error("Publication transformer: error transforming path",t,e),t}}),e)}const Ir=window.location.pathname.replace(/\/$/,""),Dr=window.location.origin;function $r(t,e,n){if(t.startsWith("/assets")){const r=new URL(t,Dr);return r.pathname=r.pathname.replace(/^\/assets/,""),r.pathname=`${Ir}${rn}${gn}${xn}${r.pathname}`,r.searchParams.set("websiteId",e),r.searchParams.set("connectorId",n),`${decodeURIComponent(r.pathname)}${r.search}`}return console.warn("storedToDisplayed: path is not a stored path",t),t}function Rr(t){const e=`${Ir}${rn}${gn}${xn}`;if(t.startsWith(e)){const n=new URL(t,Dr);n.pathname=n.pathname.replace(new RegExp(`^${e}`),""),n.pathname=`${Ir}/assets${n.pathname}`,n.searchParams.delete("websiteId"),n.searchParams.delete("connectorId");const r="/"+n.toString().replace(new RegExp(`^${Dr}${Ir}`),"").replace(/^\//,"");return decodeURIComponent(r)}return console.warn("displayedToStored: path is not a displayed path",t),t}const Hr={transformPath(t,e){if(e===ke.ASSET)return Rr(t)},transformPermalink(t,e){if(e===ke.ASSET)return Rr(t)}};function Fr(t,e,n){const r=t.attributes?.src?{...t,attributes:{...t.attributes,src:$r(t.attributes.src,e,n)}}:t;return r.components&&(r.components=r.components.map((t=>Fr(t,e,n)))),r}function Vr(t){const e=t.attributes?.src?{...t,attributes:{...t.attributes,src:Rr(t.attributes.src)}}:t;return e.components&&(e.components=e.components.map((t=>Vr(t)))),e}const Ur="publish",Br="publish-login",zr="publish-logout";var Wr;function qr(t,e){t.PublicationManager=new Yr(t,e)}function Gr(t){switch(t){case je.IN_PROGRESS:return Wr.STATUS_PENDING;case je.ERROR:return Wr.STATUS_ERROR;case je.SUCCESS:return Wr.STATUS_SUCCESS}throw new Error(`Unknown job status ${t}`)}!function(t){t.STATUS_NONE="STATUS_NONE",t.STATUS_PENDING="STATUS_PENDING",t.STATUS_ERROR="STATUS_ERROR",t.STATUS_SUCCESS="STATUS_SUCCESS",t.STATUS_LOGGED_OUT="STATUS_AUTH_ERROR"}(Wr||(Wr={}));const Kr=window.location.origin+window.location.pathname.replace(/\/$/,"");class Yr{editor;dialog;_settings;get settings(){return this._settings}set settings(t){this._settings=t,this.dialog&&(this.dialog.settings=t)}options;job=null;status=Wr.STATUS_NONE;constructor(t,e){this.editor=t,this.options={appendTo:"options",...e},t.on("storage:start:store",(t=>{t.publication=this.settings})),t.on("storage:end:load",(t=>{this.settings=t.publication??{},De({type:Pe.HOSTING,connectorId:this.settings.connector?.connectorId}).then((t=>{})).catch((t=>{this.status=Wr.STATUS_LOGGED_OUT,this.settings={},this.dialog&&this.dialog.displayError("Please login",this.job,this.status)}))})),t.Commands.add(Ur,(()=>this.startPublication())),t.Commands.add(Br,((t,e,n)=>this.goLogin(n))),t.Commands.add(zr,(()=>this.goLogout())),this.options.appendTo?this.dialog=new xr(t,{appendTo:this.options.appendTo}):console.info("PublicationUi is disabled because no appendTo option is set")}async goLogin(t){if(t.isLoggedIn)return this.settings={...this.settings,connector:t},this.status=Wr.STATUS_NONE,this.editor.store(null),void(this.dialog&&this.dialog.displayPending(this.job,this.status));this.settings={},this.status=Wr.STATUS_LOGGED_OUT,this.dialog&&this.dialog.displayPending(this.job,this.status);const e=t.connectorId,n=t.type;return window.open(t.oauthUrl||`${Kr}${rn}${on}${cn}?connectorId=${e}&type=${n}`,"_blank"),new Promise((e=>{const n=async e=>{const r=e.data;"login"===r?.type&&(window.removeEventListener("message",n),r.error?(this.status=Wr.STATUS_LOGGED_OUT,this.settings={},this.dialog&&this.dialog.displayError(r.message,this.job,this.status)):(this.editor.trigger(Cr.PUBLISH_LOGIN_END),this.settings.connector=t,this.settings.options=r.options,this.status=Wr.STATUS_NONE,this.editor.store(null),this.dialog&&this.dialog.displayPending(this.job,this.status)))};window.addEventListener("message",n,!1)}))}async goLogout(){try{await $e({type:Pe.HOSTING,connectorId:this.settings.connector.connectorId}),this.settings={},this.dialog&&this.dialog.displayPending(this.job,this.status)}catch(t){console.error("logout error",t),this.status=Wr.STATUS_ERROR,this.dialog&&this.dialog.displayError(t.message,this.job,this.status)}}async startPublication(){if(this.status===Wr.STATUS_PENDING)throw new Error("Publication is already in progress");this.status=Wr.STATUS_PENDING,this.job=null,this.dialog&&this.dialog.displayPending(this.job,this.status),this.editor.trigger(Cr.PUBLISH_START);const t=this.editor.getModel().get("user");if(!t)throw new Error("User not logged in to a storage connector");if(!this.settings.connector?.connectorId)throw new Error("User not logged in to a hosting connector");const e=this.options.websiteId,n=t.storage.connectorId;this.setPublicationTransformers();const r=this.editor.getProjectData(),o=this.editor.getModel().get("settings"),i=(await this.getHtmlFiles(o)).flatMap((t=>[{path:t.htmlPath,content:t.html,type:ke.HTML},{path:t.cssPath,content:t.css,type:ke.CSS}])).concat(r.assets.map((t=>{const e=Nr(this.editor,t.src,ke.ASSET),n=Rr(t.src).replace(/^\/assets\//,"");return{...t,path:e,src:n,type:ke.ASSET}}))),a={...r,assets:r.assets.map((t=>({...t,src:Rr(t.src)}))),settings:o,publication:this.settings,files:i};this.resetPublicationTransformers(),function(t,e){const n=t.getModel().get("config");e.files=n.publicationTransformers.reduce(((t,n)=>t.map(((t,r)=>{try{return e.pages[r],n.transformFile?n.transformFile(t)??t:t}catch(e){return console.error("Publication transformer: error transforming file",t,e),t}}))),e.files)}(this.editor,a),this.editor.trigger(Cr.PUBLISH_DATA,a);try{const[t,r]=await Re({websiteId:e,hostingId:this.settings.connector.connectorId,storageId:n,data:a,options:this.settings.options});this.job=r,this.status=Gr(this.job.status),this.trackProgress()}catch(t){return console.error("publish error",t),401===t.code||401===t.httpStatusCode?(this.status=Wr.STATUS_LOGGED_OUT,this.settings={},this.dialog&&this.dialog.displayError("Please login.",this.job,this.status)):(this.status=Wr.STATUS_ERROR,this.dialog&&this.dialog.displayError(`An error occured, your site is not published. ${t.message}`,this.job,this.status)),this.editor.trigger(Cr.PUBLISH_ERROR,{success:!1,message:t.message}),void this.editor.trigger(Cr.PUBLISH_END,{success:!1,message:t.message})}}async getHtmlFiles(t){return this.editor.Pages.getAll().map((e=>{const n=e.get("settings");function r(e){return(n||{})[e]||(t||[])[e]||""}const o=e.getMainComponent(),i=vr(e.get("name")),a=`/css/${i}.css`,s=`/${i}.html`,l=Lr(this.editor,a,ke.CSS,Ae.HTML),c=Nr(this.editor,a,ke.CSS),u=Nr(this.editor,s,ke.HTML),p=this.editor.getHtml({component:o});return{html:`<!DOCTYPE html>\n<html lang="${r("lang")}">\n<head>\n<meta charset="UTF-8">\n<link rel="stylesheet" href="${l}" />\n${t?.head||""}\n${n?.head||""}\n<title>${r("title")}</title>\n<link rel="icon" href="${r("favicon")}" />\n${["description","og:title","og:description","og:image"].map((t=>`<meta name="${t}" property="${t}" content="${r(t)}"/>`)).join("\n")}\n</head>\n${p}\n</html>`,css:this.editor.getCss({component:o}),cssPath:c,htmlPath:u}}))}async trackProgress(){try{this.job=await He({jobId:this.job.jobId}),this.status=Gr(this.job.status)}catch(t){return this.status=Wr.STATUS_ERROR,this.dialog&&this.dialog.displayError(`An error occured, your site is not published. ${t.message}`,this.job,this.status),this.editor.trigger(Cr.PUBLISH_END,{success:!1,message:t.message}),void this.editor.trigger(Cr.PUBLISH_ERROR,{success:!1,message:t.message})}this.job.status===je.IN_PROGRESS?setTimeout((()=>this.trackProgress()),2e3):this.editor.trigger(Cr.PUBLISH_END,{success:this.job.status===je.SUCCESS,message:this.job.message}),this.dialog&&this.dialog.displayPending(this.job,this.status)}setPublicationTransformers(){!function(t){const e=t.getModel().get("config");Sr(t,(n=>{if(n.get(Or))console.warn("Publication transformer: HTML transform already altered",n);else{const r=n.toHTML.bind(n);n[Or]=n.toHTML;const o=n.getStyle.bind(n);n[kr]=n.getStyle;const i=n.get("attributes").href;if(i?.startsWith("./")&&(n[Ar]=i,n.set("attributes",{...n.get("attributes"),href:Lr(t,i,ke.HTML,Ae.HTML)})),n.get("attributes").src){n[Tr]=n.get("attributes").src;const e=Lr(t,n.get("attributes").src,ke.ASSET,Ae.HTML);n.set("attributes",{...n.get("attributes"),src:e})}if(n.get("src")){n[Er]=n.get("src");const e=Lr(t,n.get("src"),ke.ASSET,Ae.HTML);n.set("src",e)}n.toHTML=()=>e.publicationTransformers.reduce(((t,e)=>{try{return e.renderComponent?e.renderComponent(n,(()=>t))??t:t}catch(e){return console.error("Publication transformer: error rendering component",n,e),t}}),r()),n.getStyle=()=>Mr(t,o())}}))}(this.editor),function(t){const e=t.getModel().get("config");t.Css.getAll().forEach((n=>{if(n[Pr])console.warn("Publication transformer: CSS transform already altered",n);else{const r=n.getStyle.bind(n);n[Pr]=n.getStyle,n.getStyle=()=>{try{const n=Mr(t,r()),o=e.publicationTransformers.reduce(((t,e)=>({...e.renderCssRule?e.renderCssRule(t,(()=>n))??t:t})),n);return o}catch(t){return console.error("Publication transformer: error rendering style",n,t),r()}}}}))}(this.editor)}resetPublicationTransformers(){!function(t){Sr(t,(t=>{t[Or]&&(t.toHTML=t[Or],delete t[Or]),t[kr]&&(t.getStyle=t[kr],delete t[kr]),t[Tr]&&(t.set("attributes",{...t.get("attributes"),src:t[Tr]}),delete t[Tr]),t[Er]&&(t.set("src",t[Er]),delete t[Er]),t[Ar]&&(t.set("attributes",{...t.get("attributes"),href:t[Ar]}),delete t[Ar])}))}(this.editor),function(t){t.Css.getAll().forEach((t=>{t[Pr]&&(t.getStyle=t[Pr],delete t[Pr])}))}(this.editor)}}const Xr=[{name:"./project-bar",value:nr},{name:"grapesjs-style-bg",value:zn()},{name:"./settings",value:(t,e)=>{try{sr="3.0.0-alpha.123"}catch(t){}console.info("Silex version:",sr),t.Commands.add(ar,{run:(e,n,{page:r})=>{ir=t.Modal.open({title:r?"Page settings":"Site Settings",content:"",attributes:{class:"settings-dialog"}}).onceClose((()=>{n?.set&&n.set("active",0),t.stopCommand(ar)})),function(t,e,n=t.getModel()){const r=n.get("settings")||{};n.set("settings",r),qt(Et`
232
232
  <p>The page settings will override site settings, <a href="https://github.com/silexlabs/Silex/wiki/Settings" target="_blank">more info about settings here</a>.</p>
233
233
  <form class="silex-form">
234
234
  <h2>General settings</h2>
@@ -48,7 +48,7 @@ class ServerConfig extends silex_plugins_1.Config {
48
48
  port = process.env.SILEX_PORT;
49
49
  debug = process.env.SILEX_DEBUG === 'true';
50
50
  url = process.env.SILEX_URL?.replace(/\/$/, '') ?? `${process.env.SILEX_PROTOCOL}://${process.env.SILEX_HOST}:${process.env.SILEX_PORT}`;
51
- userConfigPath = process.env.SILEX_CONFIG;
51
+ userConfigPath = process.env.SILEX_SERVER_CONFIG;
52
52
  configFilePath = (0, path_1.resolve)(__dirname, '../../../.silex.js');
53
53
  // All connectors or just the storage or hosting connectors
54
54
  getConnectors(type = null) {
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/ts/server/config.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH;;;GAGG;AAEH;;GAEG;AAEH,4DAAyD;AACzD,+BAA8B;AAC9B,4CAAsD;AAEtD,0CAAsC;AACtC,wDAA6F;AAC7F,sDAAkD;AAElD,oCAAwC;AACxC,sDAAkD;AAClD,2BAA2B;AAE3B;;GAEG;AACH,MAAa,YAAa,SAAQ,sBAAM;IAC/B,cAAc,GAAG;QACtB,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB;QAC/C,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB;QAC/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,GAAG,QAAQ;aACvD,CAAC,CAAC,CAAA;SACJ;QACD,iCAAiC;QACjC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE;YAClC,IAAI,CAAC,mBAAmB,CAAC,IAAI,qBAAS,CAAC,IAAI,EAAE;gBAC3C,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,IAAA,WAAM,GAAE,GAAG,oBAAoB;aAC3E,CAAC,CAAC,CAAA;SACJ;IACH,CAAC;CACF;AApJD,oCAoJC"}
@@ -11,12 +11,12 @@ const options = (0, cli_1.parse)({
11
11
  'host': ['', 'Sets the host param of the express module "cookie-session".', 'string'],
12
12
  'port': ['p', 'Port to listen to', 'int'],
13
13
  'protocol': ['', 'Sets the protocol param of the express module "cookie-session".', 'string'],
14
- 'config': ['c', 'Path for the server side config file to load at startup', 'file'],
15
- 'client-config': ['', 'Path to client config file to be served on .silex-client.js', 'string'],
14
+ 'server-config': ['s', 'Path for the server side config file to load at startup', 'file'],
15
+ 'client-config': ['c', 'Path to client config file to be served on .silex-client.js', 'file'],
16
16
  'fs-root': ['', 'Path to the root folder where to store websites. Used by the default storage connector (fs).', 'string'],
17
17
  'fs-hosting-root': ['', 'Path to the root folder where to publish websites. Used by the default hosting connector (fs).', 'string'],
18
18
  'session-name': ['', 'Sets the name param of the express module "cookie-session".', 'string'],
19
- 'session-secret': ['s', 'Session secret', 'string'],
19
+ 'session-secret': ['', 'Session secret', 'string'],
20
20
  'ssl-port': [false, 'Port to listen to for SSL/HTTPS', 'int'],
21
21
  'force-https': [false, 'Force HTTPS', 'boolean'],
22
22
  'ssl-private-key': [false, 'Path to private key for SSL', 'file'],
@@ -36,8 +36,8 @@ if (options.port)
36
36
  process.env.SILEX_PORT = options.port;
37
37
  if (options['protocol'])
38
38
  process.env.SILEX_PROTOCOL = options['protocol'];
39
- if (options.config)
40
- process.env.SILEX_CONFIG = options.config;
39
+ if (options['server-config'])
40
+ process.env.SILEX_SERVER_CONFIG = options['server-config'];
41
41
  if (options['client-config'])
42
42
  process.env.SILEX_CLIENT_CONFIG = options['client-config'];
43
43
  if (options['fs-root'])
@@ -22,7 +22,7 @@ class ServerConfig extends silex_plugins_1.Config {
22
22
  port = process.env.SILEX_PORT;
23
23
  debug = process.env.SILEX_DEBUG === 'true';
24
24
  url = process.env.SILEX_URL?.replace(/\/$/, '') ?? `${process.env.SILEX_PROTOCOL}://${process.env.SILEX_HOST}:${process.env.SILEX_PORT}`;
25
- userConfigPath = process.env.SILEX_CONFIG;
25
+ userConfigPath = process.env.SILEX_SERVER_CONFIG;
26
26
  configFilePath = (0, path_1.resolve)(__dirname, '../../../.silex.js');
27
27
  getConnectors(type = null) {
28
28
  if (!type) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@silexlabs/silex",
3
3
  "description": "Free and easy website builder for everyone.",
4
- "version": "3.0.0-alpha.122",
4
+ "version": "3.0.0-alpha.123",
5
5
  "version:backwardcompat": "3.0.0",
6
6
  "author": {
7
7
  "name": "Alex Hoyau",
@@ -25,12 +25,12 @@ const options = parse({
25
25
  'host': ['', 'Sets the host param of the express module "cookie-session".', 'string'],
26
26
  'port': [ 'p', 'Port to listen to', 'int'],
27
27
  'protocol': ['', 'Sets the protocol param of the express module "cookie-session".', 'string'],
28
- 'config': [ 'c', 'Path for the server side config file to load at startup', 'file'],
29
- 'client-config': ['', 'Path to client config file to be served on .silex-client.js', 'string'],
28
+ 'server-config': [ 's', 'Path for the server side config file to load at startup', 'file'],
29
+ 'client-config': ['c', 'Path to client config file to be served on .silex-client.js', 'file'],
30
30
  'fs-root': ['', 'Path to the root folder where to store websites. Used by the default storage connector (fs).', 'string'],
31
31
  'fs-hosting-root': ['', 'Path to the root folder where to publish websites. Used by the default hosting connector (fs).', 'string'],
32
32
  'session-name': ['', 'Sets the name param of the express module "cookie-session".', 'string'],
33
- 'session-secret': ['s', 'Session secret', 'string'],
33
+ 'session-secret': ['', 'Session secret', 'string'],
34
34
  'ssl-port': [ false, 'Port to listen to for SSL/HTTPS', 'int'],
35
35
  'force-https': [ false, 'Force HTTPS', 'boolean'],
36
36
  'ssl-private-key': [ false, 'Path to private key for SSL', 'file'],
@@ -47,7 +47,7 @@ if(options['url']) process.env.SILEX_URL = options['url']
47
47
  if(options['host']) process.env.SILEX_HOST = options['host']
48
48
  if(options.port) process.env.SILEX_PORT = options.port
49
49
  if(options['protocol']) process.env.SILEX_PROTOCOL = options['protocol']
50
- if(options.config) process.env.SILEX_CONFIG = options.config
50
+ if(options['server-config']) process.env.SILEX_SERVER_CONFIG = options['server-config']
51
51
  if(options['client-config']) process.env.SILEX_CLIENT_CONFIG = options['client-config']
52
52
  if(options['fs-root']) process.env.SILEX_FS_ROOT = options['fs-root']
53
53
  if(options['fs-hosting-root']) process.env.SILEX_FS_HOSTING_ROOT = options['fs-hosting-root']
@@ -51,7 +51,7 @@ export class ServerConfig extends Config {
51
51
  public port = process.env.SILEX_PORT
52
52
  public debug = process.env.SILEX_DEBUG === 'true'
53
53
  public url = process.env.SILEX_URL?.replace(/\/$/, '') ?? `${process.env.SILEX_PROTOCOL}://${process.env.SILEX_HOST}:${process.env.SILEX_PORT}`
54
- public userConfigPath: Plugin | undefined = process.env.SILEX_CONFIG
54
+ public userConfigPath: Plugin | undefined = process.env.SILEX_SERVER_CONFIG
55
55
  public configFilePath: Plugin = resolve(__dirname, '../../../.silex.js')
56
56
 
57
57
  // All connectors or just the storage or hosting connectors