@silexlabs/silex 3.0.0-alpha.50 → 3.0.0-alpha.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/dist/client/client/config.d.ts +14 -1
  2. package/dist/client/client/grapesjs/PublicationManager.d.ts +4 -7
  3. package/dist/client/client/publication-transformers.d.ts +41 -0
  4. package/dist/client/css/admin.css +4 -1
  5. package/dist/client/js/main.js +55 -55
  6. package/dist/client/page.d.ts +1 -1
  7. package/dist/client/types.d.ts +35 -18
  8. package/dist/plugins/client/client/api.d.ts +83 -0
  9. package/dist/plugins/client/client/api.js +105 -0
  10. package/dist/plugins/client/client/api.js.map +1 -0
  11. package/dist/plugins/client/client/config.d.ts +58 -0
  12. package/dist/plugins/client/client/config.js +90 -0
  13. package/dist/plugins/client/client/config.js.map +1 -0
  14. package/dist/plugins/client/client/events.js +2 -0
  15. package/dist/plugins/client/client/events.js.map +1 -1
  16. package/dist/plugins/client/client/grapesjs/LoginDialog.d.ts +15 -0
  17. package/dist/plugins/client/client/grapesjs/LoginDialog.js +193 -0
  18. package/dist/plugins/client/client/grapesjs/LoginDialog.js.map +1 -0
  19. package/dist/plugins/client/client/grapesjs/PublicationManager.d.ts +72 -0
  20. package/dist/plugins/client/client/grapesjs/PublicationManager.js +334 -0
  21. package/dist/plugins/client/client/grapesjs/PublicationManager.js.map +1 -0
  22. package/dist/plugins/client/client/grapesjs/PublicationUi.d.ts +61 -0
  23. package/dist/plugins/client/client/grapesjs/PublicationUi.js +324 -0
  24. package/dist/plugins/client/client/grapesjs/PublicationUi.js.map +1 -0
  25. package/dist/plugins/client/client/grapesjs/blocks.d.ts +1 -0
  26. package/dist/plugins/client/client/grapesjs/blocks.js +37 -0
  27. package/dist/plugins/client/client/grapesjs/blocks.js.map +1 -0
  28. package/dist/plugins/client/client/grapesjs/index.d.ts +5 -0
  29. package/dist/plugins/client/client/grapesjs/index.js +264 -0
  30. package/dist/plugins/client/client/grapesjs/index.js.map +1 -0
  31. package/dist/plugins/client/client/grapesjs/internal-links.d.ts +1 -0
  32. package/dist/plugins/client/client/grapesjs/internal-links.js +220 -0
  33. package/dist/plugins/client/client/grapesjs/internal-links.js.map +1 -0
  34. package/dist/plugins/client/client/grapesjs/new-page-dialog.d.ts +2 -0
  35. package/dist/plugins/client/client/grapesjs/new-page-dialog.js +83 -0
  36. package/dist/plugins/client/client/grapesjs/new-page-dialog.js.map +1 -0
  37. package/dist/plugins/client/client/grapesjs/openImport.d.ts +9 -0
  38. package/dist/plugins/client/client/grapesjs/openImport.js +74 -0
  39. package/dist/plugins/client/client/grapesjs/openImport.js.map +1 -0
  40. package/dist/plugins/client/client/grapesjs/page-panel.d.ts +3 -0
  41. package/dist/plugins/client/client/grapesjs/page-panel.js +113 -0
  42. package/dist/plugins/client/client/grapesjs/page-panel.js.map +1 -0
  43. package/dist/plugins/client/client/grapesjs/project-bar.d.ts +1 -0
  44. package/dist/plugins/client/client/grapesjs/project-bar.js +106 -0
  45. package/dist/plugins/client/client/grapesjs/project-bar.js.map +1 -0
  46. package/dist/plugins/client/client/grapesjs/rich-text.d.ts +1 -0
  47. package/dist/plugins/client/client/grapesjs/rich-text.js +31 -0
  48. package/dist/plugins/client/client/grapesjs/rich-text.js.map +1 -0
  49. package/dist/plugins/client/client/grapesjs/semantic.d.ts +1 -0
  50. package/dist/plugins/client/client/grapesjs/semantic.js +110 -0
  51. package/dist/plugins/client/client/grapesjs/semantic.js.map +1 -0
  52. package/dist/plugins/client/client/grapesjs/settings.d.ts +2 -0
  53. package/dist/plugins/client/client/grapesjs/settings.js +197 -0
  54. package/dist/plugins/client/client/grapesjs/settings.js.map +1 -0
  55. package/dist/plugins/client/client/grapesjs/storage.d.ts +1 -0
  56. package/dist/plugins/client/client/grapesjs/storage.js +124 -0
  57. package/dist/plugins/client/client/grapesjs/storage.js.map +1 -0
  58. package/dist/plugins/client/client/grapesjs/symbolDialogs.d.ts +3 -0
  59. package/dist/plugins/client/client/grapesjs/symbolDialogs.js +36 -0
  60. package/dist/plugins/client/client/grapesjs/symbolDialogs.js.map +1 -0
  61. package/dist/plugins/client/client/publication-transformers.d.ts +41 -0
  62. package/dist/plugins/client/client/publication-transformers.js +222 -0
  63. package/dist/plugins/client/client/publication-transformers.js.map +1 -0
  64. package/dist/plugins/client/constants.d.ts +29 -0
  65. package/dist/plugins/client/constants.js +46 -0
  66. package/dist/plugins/client/constants.js.map +1 -0
  67. package/dist/plugins/client/page.d.ts +1 -1
  68. package/dist/plugins/client/page.js +2 -2
  69. package/dist/plugins/client/page.js.map +1 -1
  70. package/dist/plugins/client/plugins/client/11ty.d.ts +17 -0
  71. package/dist/plugins/client/plugins/client/11ty.js +88 -0
  72. package/dist/plugins/client/plugins/client/11ty.js.map +1 -0
  73. package/dist/plugins/client/plugins/client/publicationRenderer.js +63 -21
  74. package/dist/plugins/client/plugins/client/publicationRenderer.js.map +1 -1
  75. package/dist/plugins/client/plugins/client/website-info.js +1 -1
  76. package/dist/plugins/client/plugins/client/website-info.js.map +1 -1
  77. package/dist/plugins/client/types.d.ts +35 -18
  78. package/dist/plugins/client/types.js +6 -0
  79. package/dist/plugins/client/types.js.map +1 -1
  80. package/dist/plugins/server/plugins/server/FtpConnector.d.ts +4 -1
  81. package/dist/plugins/server/plugins/server/FtpConnector.js +13 -9
  82. package/dist/plugins/server/plugins/server/FtpConnector.js.map +1 -1
  83. package/dist/plugins/server/plugins/server/GitlabConnector.js +19 -14
  84. package/dist/plugins/server/plugins/server/GitlabConnector.js.map +1 -1
  85. package/dist/plugins/server/server/connectors/FsHosting.d.ts +2 -1
  86. package/dist/plugins/server/server/connectors/FsHosting.js +5 -6
  87. package/dist/plugins/server/server/connectors/FsHosting.js.map +1 -1
  88. package/dist/plugins/server/server/connectors/FsStorage.d.ts +1 -0
  89. package/dist/plugins/server/server/connectors/FsStorage.js +4 -1
  90. package/dist/plugins/server/server/connectors/FsStorage.js.map +1 -1
  91. package/dist/plugins/server/server/connectors/connectors.d.ts +2 -1
  92. package/dist/plugins/server/server/connectors/connectors.js.map +1 -1
  93. package/dist/plugins/server/server/jobs.d.ts +6 -0
  94. package/dist/plugins/server/server/jobs.js +3 -1
  95. package/dist/plugins/server/server/jobs.js.map +1 -1
  96. package/dist/plugins/server/types.d.ts +35 -18
  97. package/dist/plugins/server/types.js +7 -1
  98. package/dist/plugins/server/types.js.map +1 -1
  99. package/dist/server/server/api/publicationApi.js +14 -20
  100. package/dist/server/server/connectors/FsHosting.js +5 -6
  101. package/dist/server/server/connectors/FsStorage.js +4 -1
  102. package/dist/server/server/jobs.js +2 -1
  103. package/dist/server/types.js +7 -1
  104. package/package.json +1 -1
  105. package/public/silex.js +23 -0
  106. package/src/css/website-info.scss +4 -1
  107. package/src/ts/client/config.ts +32 -2
  108. package/src/ts/client/events.ts +3 -0
  109. package/src/ts/client/grapesjs/PublicationManager.ts +49 -8
  110. package/src/ts/client/grapesjs/PublicationUi.ts +1 -1
  111. package/src/ts/client/grapesjs/eleventy.ts +9 -3
  112. package/src/ts/client/grapesjs/internal-links.ts +1 -3
  113. package/src/ts/client/grapesjs/storage.ts +1 -1
  114. package/src/ts/client/index.ts +5 -0
  115. package/src/ts/client/publication-transformers.test.ts +199 -0
  116. package/src/ts/client/publication-transformers.ts +248 -0
  117. package/src/ts/page.ts +2 -2
  118. package/src/ts/plugins/client/11ty.ts +108 -0
  119. package/src/ts/plugins/client/publicationRenderer.ts +68 -22
  120. package/src/ts/plugins/client/website-info.ts +1 -1
  121. package/src/ts/plugins/server/FtpConnector.ts +19 -6
  122. package/src/ts/plugins/server/GitlabConnector.ts +20 -16
  123. package/src/ts/server/api/publicationApi.ts +16 -23
  124. package/src/ts/server/connectors/FsHosting.ts +3 -3
  125. package/src/ts/server/connectors/FsStorage.ts +5 -1
  126. package/src/ts/server/connectors/connectors.ts +3 -1
  127. package/src/ts/server/jobs.ts +10 -0
  128. package/src/ts/types.ts +39 -19
@@ -1,2 +1,2 @@
1
1
  export declare function getPageSlug(pageName: any): any;
2
- export declare function getPageLink(pageName?: string): string;
2
+ export declare function getPageLink(pageName: any): string;
@@ -4,8 +4,6 @@
4
4
  export interface PublicationSettings {
5
5
  connector?: ConnectorData;
6
6
  options?: ConnectorOptions;
7
- url?: string;
8
- autoHomePage?: boolean;
9
7
  }
10
8
  export interface WebsiteFile {
11
9
  html: string;
@@ -137,7 +135,7 @@ export type ApiConnectorUserQuery = {
137
135
  export type ApiConnectorUserResponse = ConnectorUser;
138
136
  export declare const defaultWebsiteData: WebsiteData;
139
137
  export interface WebsiteData {
140
- pages: Page[];
138
+ pages: any[];
141
139
  assets: Asset[];
142
140
  styles: Style[];
143
141
  settings: WebsiteSettings;
@@ -146,7 +144,7 @@ export interface WebsiteData {
146
144
  publication: PublicationSettings;
147
145
  }
148
146
  export interface PublicationData extends WebsiteData {
149
- files?: WebsiteFile[];
147
+ files?: ClientSideFile[];
150
148
  }
151
149
  export interface WebsiteSettings {
152
150
  description?: string;
@@ -163,16 +161,6 @@ export interface Font {
163
161
  value: string;
164
162
  variants: string[];
165
163
  }
166
- export interface Page {
167
- name?: string;
168
- id: string;
169
- type?: string;
170
- frames: Frame[];
171
- settings?: WebsiteSettings;
172
- cssExt?: string;
173
- htmlExt?: string;
174
- slug?: string;
175
- }
176
164
  export interface Frame {
177
165
  component: {
178
166
  type: string;
@@ -214,15 +202,44 @@ export type Selector = string | {
214
202
  * Type for a connector id
215
203
  */
216
204
  export type ConnectorId = string;
217
- export type ConnectorOptions = object;
205
+ export type ConnectorOptions = {
206
+ websiteUrl?: string;
207
+ [key: string]: any;
208
+ };
209
+ export declare enum ClientSideFileType {
210
+ HTML = "html",
211
+ ASSET = "asset",
212
+ CSS = "css"
213
+ }
218
214
  /**
219
- * Type for a client side file
220
- * @see connector/File
215
+ * Type for a client side file when the content is not available, used to handle file names and paths and urls
216
+ */
217
+ export interface ClientSideFileWithPermalink {
218
+ path: string;
219
+ permalink: string;
220
+ type: ClientSideFileType;
221
+ }
222
+ /**
223
+ * Type for a client side file when the content is available as a string
221
224
  */
222
- export interface ClientSideFile {
225
+ export interface ClientSideFileWithContent {
223
226
  path: string;
224
227
  content: string;
228
+ type: ClientSideFileType;
225
229
  }
230
+ /**
231
+ * Type for a client side file when the content is in the connector
232
+ */
233
+ export interface ClientSideFileWithSrc {
234
+ path: string;
235
+ src: string;
236
+ type: ClientSideFileType;
237
+ }
238
+ /**
239
+ * Type for a client side file
240
+ * @see connector/File
241
+ */
242
+ export type ClientSideFile = ClientSideFileWithContent | ClientSideFileWithSrc;
226
243
  /**
227
244
  * Type for file listing
228
245
  */
@@ -0,0 +1,83 @@
1
+ import { ConnectorId, JobId, PublicationJobData, WebsiteId, ConnectorData, ConnectorType, WebsiteData, ClientSideFile, PublicationData, ConnectorUser, WebsiteMeta, WebsiteMetaFileContent, ConnectorOptions } from '../types';
2
+ export declare enum ApiRoute {
3
+ PUBLICATION_PUBLISH = "/api/publication/",
4
+ PUBLICATION_STATUS = "/api/publication/publication/status",
5
+ CONNECTOR_USER = "/api/connector/user",
6
+ CONNECTOR_LOGOUT = "/api/connector/logout",
7
+ CONNECTOR_LIST = "/api/connector/",
8
+ WEBSITE_READ = "/api/website/",
9
+ WEBSITE_WRITE = "/api/website/",
10
+ WEBSITE_DELETE = "/api/website/",
11
+ WEBSITE_CREATE = "/api/website/",
12
+ WEBSITE_LIST = "/api/website/",
13
+ WEBSITE_ASSETS_READ = "/api/website/assets",
14
+ WEBSITE_ASSETS_WRITE = "/api/website/assets",
15
+ WEBSITE_META_READ = "/api/website/meta",
16
+ WEBSITE_META_WRITE = "/api/website/meta"
17
+ }
18
+ export declare function getUser({ type, connectorId }: {
19
+ type: ConnectorType;
20
+ connectorId?: ConnectorId;
21
+ }): Promise<ConnectorUser>;
22
+ export declare function logout({ type, connectorId }: {
23
+ type: ConnectorType;
24
+ connectorId?: ConnectorId;
25
+ }): Promise<void>;
26
+ export declare function publish({ websiteId, hostingId, storageId, data, options }: {
27
+ websiteId: WebsiteId;
28
+ hostingId: ConnectorId;
29
+ storageId: ConnectorId;
30
+ data: PublicationData;
31
+ options: ConnectorOptions;
32
+ }): Promise<[url: string, job: PublicationJobData]>;
33
+ export declare function publicationStatus({ jobId }: {
34
+ jobId: JobId;
35
+ }): Promise<PublicationJobData>;
36
+ export declare function connectorList({ type }: {
37
+ type: ConnectorType;
38
+ }): Promise<ConnectorData[]>;
39
+ export declare function websiteList({ connectorId }: {
40
+ connectorId?: ConnectorId;
41
+ }): Promise<WebsiteMeta[]>;
42
+ export declare function websiteLoad({ websiteId, connectorId }: {
43
+ websiteId: WebsiteId;
44
+ connectorId?: ConnectorId;
45
+ }): Promise<WebsiteData>;
46
+ export declare function websiteSave({ websiteId, data, connectorId }: {
47
+ websiteId: WebsiteId;
48
+ data: WebsiteData;
49
+ connectorId?: ConnectorId;
50
+ }): Promise<void>;
51
+ export declare function websiteDelete({ websiteId, connectorId }: {
52
+ websiteId: WebsiteId;
53
+ connectorId?: ConnectorId;
54
+ }): Promise<void>;
55
+ export declare function websiteCreate({ websiteId, data, connectorId }: {
56
+ websiteId: WebsiteId;
57
+ data: WebsiteMetaFileContent;
58
+ connectorId?: ConnectorId;
59
+ }): Promise<void>;
60
+ export declare function websiteMetaWrite({ websiteId, data, connectorId }: {
61
+ websiteId: WebsiteId;
62
+ data: WebsiteMetaFileContent;
63
+ connectorId?: ConnectorId;
64
+ }): Promise<void>;
65
+ export declare function websiteMetaRead({ websiteId, connectorId }: {
66
+ websiteId: WebsiteId;
67
+ connectorId?: ConnectorId;
68
+ }): Promise<WebsiteMeta>;
69
+ export declare function websiteAssetsLoad({ path, websiteId, connectorId }: {
70
+ path: string;
71
+ websiteId: WebsiteId;
72
+ connectorId: ConnectorId;
73
+ }): Promise<string>;
74
+ /**
75
+ * Not used directly, grapesjs handles the upload
76
+ * @see assetManager in src/ts/client/grapesjs/index.ts
77
+ */
78
+ export declare function websiteAssetsSave({ websiteId, connectorId, files }: {
79
+ websiteId: WebsiteId;
80
+ connectorId: ConnectorId;
81
+ files: ClientSideFile[];
82
+ }): Promise<string[]>;
83
+ export declare function api<ReqQuery, ReqBody, ResBody>(route: ApiRoute | string, method: string, query?: ReqQuery, payload?: ReqBody): Promise<ResBody>;
@@ -0,0 +1,105 @@
1
+ /*
2
+ * Silex website builder, free/libre no-code tool for makers.
3
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ */
17
+ import { API_CONNECTOR_LIST, API_CONNECTOR_USER, API_CONNECTOR_LOGOUT, API_CONNECTOR_PATH, API_PATH, API_PUBLICATION_PATH, API_PUBLICATION_PUBLISH, API_PUBLICATION_STATUS, API_WEBSITE_ASSET_READ, API_WEBSITE_ASSETS_WRITE, API_WEBSITE_DELETE, API_WEBSITE_LIST, API_WEBSITE_PATH, API_WEBSITE_READ, API_WEBSITE_WRITE, API_WEBSITE_META_READ, API_WEBSITE_META_WRITE, API_WEBSITE_CREATE } from '../constants';
18
+ import { ApiError } from '../types';
19
+ export var ApiRoute;
20
+ (function (ApiRoute) {
21
+ ApiRoute["PUBLICATION_PUBLISH"] = "/api/publication/";
22
+ ApiRoute["PUBLICATION_STATUS"] = "/api/publication/publication/status";
23
+ ApiRoute["CONNECTOR_USER"] = "/api/connector/user";
24
+ ApiRoute["CONNECTOR_LOGOUT"] = "/api/connector/logout";
25
+ ApiRoute["CONNECTOR_LIST"] = "/api/connector/";
26
+ ApiRoute["WEBSITE_READ"] = "/api/website/";
27
+ ApiRoute["WEBSITE_WRITE"] = "/api/website/";
28
+ ApiRoute["WEBSITE_DELETE"] = "/api/website/";
29
+ ApiRoute["WEBSITE_CREATE"] = "/api/website/";
30
+ ApiRoute["WEBSITE_LIST"] = "/api/website/";
31
+ ApiRoute["WEBSITE_ASSETS_READ"] = "/api/website/assets";
32
+ ApiRoute["WEBSITE_ASSETS_WRITE"] = "/api/website/assets";
33
+ ApiRoute["WEBSITE_META_READ"] = "/api/website/meta";
34
+ ApiRoute["WEBSITE_META_WRITE"] = "/api/website/meta";
35
+ })(ApiRoute || (ApiRoute = {}));
36
+ const ROOT_URL = window.location.origin;
37
+ export async function getUser({ type, connectorId }) {
38
+ return api(ApiRoute.CONNECTOR_USER, 'GET', {
39
+ type,
40
+ connectorId,
41
+ });
42
+ }
43
+ export async function logout({ type, connectorId }) {
44
+ return api(ApiRoute.CONNECTOR_LOGOUT, 'POST', { connectorId, type });
45
+ }
46
+ export async function publish({ websiteId, hostingId, storageId, data, options }) {
47
+ const { url, job } = await api(ApiRoute.PUBLICATION_PUBLISH, 'POST', { websiteId, hostingId, storageId, options }, data);
48
+ return [url, job];
49
+ }
50
+ export async function publicationStatus({ jobId }) {
51
+ return api(ApiRoute.PUBLICATION_STATUS, 'GET', { jobId });
52
+ }
53
+ export async function connectorList({ type }) {
54
+ const list = await api(ApiRoute.CONNECTOR_LIST, 'GET', { type });
55
+ return list;
56
+ }
57
+ export async function websiteList({ connectorId }) {
58
+ return api(ApiRoute.WEBSITE_LIST, 'GET', { connectorId });
59
+ }
60
+ export async function websiteLoad({ websiteId, connectorId }) {
61
+ return api(ApiRoute.WEBSITE_READ, 'GET', { websiteId, connectorId: connectorId });
62
+ }
63
+ export async function websiteSave({ websiteId, data, connectorId }) {
64
+ const { message } = await api(ApiRoute.WEBSITE_WRITE, 'POST', { websiteId, connectorId: connectorId }, data);
65
+ }
66
+ export async function websiteDelete({ websiteId, connectorId }) {
67
+ await api(ApiRoute.WEBSITE_DELETE, 'DELETE', { websiteId, connectorId: connectorId });
68
+ }
69
+ export async function websiteCreate({ websiteId, data, connectorId }) {
70
+ await api(ApiRoute.WEBSITE_CREATE, 'PUT', { connectorId: connectorId }, data);
71
+ }
72
+ export async function websiteMetaWrite({ websiteId, data, connectorId }) {
73
+ await api(ApiRoute.WEBSITE_META_WRITE, 'POST', { websiteId, connectorId: connectorId }, data);
74
+ }
75
+ export async function websiteMetaRead({ websiteId, connectorId }) {
76
+ return api(ApiRoute.WEBSITE_META_WRITE, 'GET', { websiteId, connectorId });
77
+ }
78
+ export async function websiteAssetsLoad({ path, websiteId, connectorId }) {
79
+ return api(`${ApiRoute.WEBSITE_ASSETS_READ}/${path}`, 'GET', { websiteId, connectorId: connectorId });
80
+ }
81
+ /**
82
+ * Not used directly, grapesjs handles the upload
83
+ * @see assetManager in src/ts/client/grapesjs/index.ts
84
+ */
85
+ export async function websiteAssetsSave({ websiteId, connectorId, files }) {
86
+ const { data } = await api(ApiRoute.WEBSITE_ASSETS_WRITE, 'POST', { websiteId, connectorId: connectorId }, files);
87
+ return data;
88
+ }
89
+ export async function api(route, method, query, payload) {
90
+ const url = `${ROOT_URL}${route.toString()}?${new URLSearchParams(Object.entries(query).filter(([key, value]) => !!value)).toString()}`;
91
+ const response = await fetch(url, {
92
+ method,
93
+ headers: {
94
+ 'Content-Type': 'application/json',
95
+ },
96
+ body: payload && JSON.stringify(payload),
97
+ credentials: 'include', // sends the cookies with the request
98
+ });
99
+ if (!response.ok) {
100
+ const json = await response.json();
101
+ throw new ApiError(json.message, response.status);
102
+ }
103
+ return response.json();
104
+ }
105
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../src/ts/client/api.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,QAAQ,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,sBAAsB,EA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EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE,KAAK,CAAC,CAAA;IACvM,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,GAAG,CAA6B,KAAwB,EAAE,MAAc,EAAE,KAAgB,EAAE,OAAiB;IACjI,MAAM,GAAG,GAAG,GAAG,QAAQ,GAAG,KAAK,CAAC,QAAQ,EAAE,IAAI,IAAI,eAAe,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAA;IACvI,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAChC,MAAM;QACN,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;QACxC,WAAW,EAAE,SAAS,EAAE,qCAAqC;KAC9D,CAAC,CAAA;IAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;QAChB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAClC,MAAM,IAAI,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAA;KAClD;IAED,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;AACxB,CAAC"}
@@ -0,0 +1,58 @@
1
+ import { Config } from '@silexlabs/silex-plugins';
2
+ import { ConnectorId, WebsiteId } from '../types';
3
+ import { Editor, EditorConfig } from 'grapesjs';
4
+ import { PublicationTransformer } from './publication-transformers';
5
+ import * as api from './api';
6
+ /**
7
+ * @fileoverview Silex client side config
8
+ */
9
+ export declare class ClientConfig extends Config {
10
+ api: typeof api;
11
+ /**
12
+ * The website to load
13
+ * This is the id of the website in the storage connector
14
+ */
15
+ websiteId: WebsiteId;
16
+ /**
17
+ * The storage connector to use
18
+ * If not found in the URL and the user is not logged in to any storage, use the first storage
19
+ */
20
+ storageId: ConnectorId;
21
+ /**
22
+ * language for I18n module
23
+ */
24
+ lang: string;
25
+ /**
26
+ * root url of Silex app
27
+ */
28
+ rootUrl: string;
29
+ /**
30
+ * debug mode
31
+ */
32
+ debug: boolean;
33
+ /**
34
+ * Grapesjs config
35
+ */
36
+ grapesJsConfig: EditorConfig;
37
+ /**
38
+ * Client config url
39
+ * This is the url of the config file which is a plugin
40
+ */
41
+ clientConfigUrl: string;
42
+ /**
43
+ * Init GrapesJS config which depend on the config file properties
44
+ */
45
+ initGrapesConfig(): void;
46
+ /**
47
+ * Get grapesjs editor
48
+ */
49
+ getEditor(): Editor;
50
+ /**
51
+ * Publication transformers let plugins change files before they are published
52
+ */
53
+ publicationTransformers: Array<PublicationTransformer>;
54
+ /**
55
+ * Add a publication transformer(s)
56
+ */
57
+ addPublicationTransformers(transformers: PublicationTransformer | PublicationTransformer[]): void;
58
+ }
@@ -0,0 +1,90 @@
1
+ /*
2
+ * Silex website builder, free/libre no-code tool for makers.
3
+ * Copyright (c) 2023 lexoyo and Silex Labs foundation
4
+ *
5
+ * This program is free software: you can redistribute it and/or modify
6
+ * it under the terms of the GNU Affero General Public License as published by
7
+ * the Free Software Foundation, either version 3 of the License, or any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ */
17
+ import { Config } from '@silexlabs/silex-plugins';
18
+ import { getEditor, getEditorConfig } from './grapesjs';
19
+ import { CLIENT_CONFIG_FILE_NAME, DEFAULT_LANGUAGE, DEFAULT_WEBSITE_ID } from '../constants';
20
+ import { validatePublicationTransformer } from './publication-transformers';
21
+ import * as api from './api';
22
+ /**
23
+ * @fileoverview Silex client side config
24
+ */
25
+ export class ClientConfig extends Config {
26
+ api = api;
27
+ /**
28
+ * The website to load
29
+ * This is the id of the website in the storage connector
30
+ */
31
+ websiteId = new URL(location.href).searchParams.get('id') ?? DEFAULT_WEBSITE_ID;
32
+ /**
33
+ * The storage connector to use
34
+ * If not found in the URL and the user is not logged in to any storage, use the first storage
35
+ */
36
+ storageId = new URL(location.href).searchParams.get('connectorId');
37
+ /**
38
+ * language for I18n module
39
+ */
40
+ lang = new URL(location.href).searchParams.get('lang') ?? DEFAULT_LANGUAGE;
41
+ /**
42
+ * root url of Silex app
43
+ */
44
+ rootUrl = window.location.origin;
45
+ /**
46
+ * debug mode
47
+ */
48
+ debug = false;
49
+ /**
50
+ * Grapesjs config
51
+ */
52
+ grapesJsConfig;
53
+ /**
54
+ * Client config url
55
+ * This is the url of the config file which is a plugin
56
+ */
57
+ clientConfigUrl = `${this.rootUrl}/${CLIENT_CONFIG_FILE_NAME}`;
58
+ /**
59
+ * Init GrapesJS config which depend on the config file properties
60
+ */
61
+ initGrapesConfig() {
62
+ this.grapesJsConfig = getEditorConfig(this.websiteId, this.storageId, this.rootUrl);
63
+ }
64
+ /**
65
+ * Get grapesjs editor
66
+ */
67
+ getEditor() {
68
+ return getEditor();
69
+ }
70
+ /**
71
+ * Publication transformers let plugins change files before they are published
72
+ */
73
+ publicationTransformers = [];
74
+ /**
75
+ * Add a publication transformer(s)
76
+ */
77
+ addPublicationTransformers(transformers) {
78
+ // Make sure it is an array
79
+ if (!Array.isArray(transformers)) {
80
+ transformers = [transformers];
81
+ }
82
+ // Validate
83
+ transformers.forEach(transformer => {
84
+ validatePublicationTransformer(transformer);
85
+ });
86
+ // Add to the list
87
+ this.publicationTransformers = this.publicationTransformers.concat(transformers);
88
+ }
89
+ }
90
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sour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;OAEG;IACH,SAAS;QACP,OAAO,SAAS,EAAE,CAAA;IACpB,CAAC;IAED;;OAEG;IACH,uBAAuB,GAAkC,EAAE,CAAA;IAE3D;;OAEG;IACH,0BAA0B,CAAC,YAA+D;QACxF,2BAA2B;QAC3B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;YAChC,YAAY,GAAG,CAAC,YAAY,CAAC,CAAA;SAC9B;QACD,WAAW;QACX,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;YACjC,8BAA8B,CAAC,WAAW,CAAC,CAAA;QAC7C,CAAC,CAAC,CAAA;QAEF,kBAAkB;QAClB,IAAI,CAAC,uBAAuB,GAAG,IAAI,CAAC,uBAAuB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAA;IAClF,CAAC;CACF"}
@@ -16,10 +16,12 @@
16
16
  */
17
17
  export var ClientEvent;
18
18
  (function (ClientEvent) {
19
+ // Sent on the config object
19
20
  ClientEvent["STARTUP_START"] = "silex:startup:start";
20
21
  ClientEvent["STARTUP_END"] = "silex:startup:end";
21
22
  ClientEvent["GRAPESJS_START"] = "silex:grapesjs:start";
22
23
  ClientEvent["GRAPESJS_END"] = "silex:grapesjs:end";
24
+ // Sent on the editor object
23
25
  ClientEvent["PUBLISH_START"] = "silex:publish:start";
24
26
  ClientEvent["PUBLISH_DATA"] = "silex:publish:data";
25
27
  ClientEvent["PUBLISH_END"] = "silex:publish:end";
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sourceRoot":"","sources":["../../../../src/ts/client/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,CAAN,IAAY,WAaX;AAbD,WAAY,WAAW;IACrB,oDAAqC,CAAA;IACrC,gDAAiC,CAAA;IACjC,sDAAuC,CAAA;IACvC,kDAAmC,CAAA;IACnC,oDAAqC,CAAA;IACrC,kDAAmC,CAAA;IACnC,gDAAiC,CAAA;IACjC,oDAAqC,CAAA;IACrC,gEAAiD,CAAA;IACjD,4DAA6C,CAAA;IAC7C,wDAAyC,CAAA;IACzC,4CAA6B,CAAA;AAC/B,CAAC,EAbW,WAAW,KAAX,WAAW,QAatB"}
1
+ {"version":3,"file":"events.js","sourceRoot":"","sources":["../../../../src/ts/client/events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,CAAN,IAAY,WAgBX;AAhBD,WAAY,WAAW;IACrB,4BAA4B;IAC5B,oDAAqC,CAAA;IACrC,gDAAiC,CAAA;IACjC,sDAAuC,CAAA;IACvC,kDAAmC,CAAA;IAEnC,4BAA4B;IAC5B,oDAAqC,CAAA;IACrC,kDAAmC,CAAA;IACnC,gDAAiC,CAAA;IACjC,oDAAqC,CAAA;IACrC,gEAAiD,CAAA;IACjD,4DAA6C,CAAA;IAC7C,wDAAyC,CAAA;IACzC,4CAA6B,CAAA;AAC/B,CAAC,EAhBW,WAAW,KAAX,WAAW,QAgBtB"}
@@ -0,0 +1,15 @@
1
+ import { Editor } from 'grapesjs';
2
+ import { ConnectorId, ConnectorType, ConnectorUser } from '../../types';
3
+ import { WebsiteId } from '../../types';
4
+ export declare const cmdLogin = "silex:auth:login";
5
+ export declare const cmdLogout = "silex:auth:logout";
6
+ export declare const eventLoggingIn = "silex:auth:logging-in";
7
+ export declare const eventLoggedIn = "silex:auth:logged-in";
8
+ export declare const eventLoginFailed = "silex:auth:login-failed";
9
+ export declare const eventLoggedOut = "silex:auth:logged-out";
10
+ export interface LoginDialogOptions {
11
+ id: WebsiteId;
12
+ }
13
+ export declare function getCurrentUser(editor: Editor): Promise<ConnectorUser>;
14
+ export declare function updateUser(editor: Editor, type: ConnectorType, connectorId?: ConnectorId): Promise<ConnectorUser>;
15
+ export default function loginDialogPlugin(editor: any, opts: any): void;