@silexlabs/silex 3.0.0-alpha.39 → 3.0.0-alpha.41
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/.silex.js +38 -8
- package/dist/client/client/config.d.ts +11 -41
- package/dist/client/client/grapesjs/LoginDialog.d.ts +13 -0
- package/dist/client/client/grapesjs/PublicationManager.d.ts +69 -0
- package/dist/client/client/grapesjs/PublicationUi.d.ts +58 -0
- package/dist/client/client/grapesjs/index.d.ts +18 -44
- package/dist/client/client/grapesjs/storage.d.ts +1 -0
- package/dist/client/client/services.d.ts +35 -0
- package/dist/client/constants.d.ts +17 -0
- package/dist/client/css/admin.css +86 -3
- package/dist/client/js/main.js +201 -90
- package/dist/client/js/main.js.LICENSE.txt +6 -0
- package/dist/client/types.d.ts +200 -29
- package/dist/constants.d.ts +21 -0
- package/dist/constants.js +38 -1
- package/dist/constants.js.map +1 -0
- package/dist/events.d.ts +2 -0
- package/dist/events.js +17 -0
- package/dist/events.js.map +1 -0
- package/dist/plugins/AuthPlugin.d.ts +1 -0
- package/dist/plugins/AuthPlugin.js +38 -0
- package/dist/plugins/AuthPlugin.js.map +1 -0
- package/dist/plugins/Cache.d.ts +2 -0
- package/dist/plugins/Cache.js +32 -0
- package/dist/plugins/Cache.js.map +1 -0
- package/dist/plugins/FtpBackend.d.ts +92 -0
- package/dist/plugins/FtpBackend.js +604 -0
- package/dist/plugins/FtpBackend.js.map +1 -0
- package/dist/plugins/HooksPlugin.d.ts +7 -0
- package/dist/plugins/HooksPlugin.js +76 -0
- package/dist/plugins/HooksPlugin.js.map +1 -0
- package/dist/plugins/PublicationPlugin.d.ts +17 -0
- package/dist/plugins/PublicationPlugin.js +170 -0
- package/dist/plugins/PublicationPlugin.js.map +1 -0
- package/dist/plugins/SslPlugin.d.ts +1 -0
- package/dist/plugins/SslPlugin.js +86 -0
- package/dist/plugins/SslPlugin.js.map +1 -0
- package/dist/plugins/StaticPlugin.d.ts +1 -0
- package/dist/plugins/StaticPlugin.js +66 -0
- package/dist/plugins/StaticPlugin.js.map +1 -0
- package/dist/plugins/WebsitePlugin.d.ts +14 -0
- package/dist/plugins/WebsitePlugin.js +302 -0
- package/dist/plugins/WebsitePlugin.js.map +1 -0
- package/dist/server/backends/FsBackend.d.ts +42 -0
- package/dist/server/backends/FsBackend.js +269 -0
- package/dist/server/backends/FsBackend.js.map +1 -0
- package/dist/server/backends/index.d.ts +95 -0
- package/dist/server/backends/index.js +255 -0
- package/dist/server/backends/index.js.map +1 -0
- package/dist/server/cli.js +0 -1
- package/dist/server/config.d.ts +58 -0
- package/dist/server/config.js +128 -24
- package/dist/server/config.js.map +1 -0
- package/dist/server/express.js +31 -3
- package/dist/server/index.js +9 -20
- package/dist/server/jobs.d.ts +6 -0
- package/dist/server/jobs.js +75 -0
- package/dist/server/jobs.js.map +1 -0
- package/dist/server/utils/validation.d.ts +7 -0
- package/dist/server/utils/validation.js +37 -0
- package/dist/server/utils/validation.js.map +1 -0
- package/dist/types.d.ts +270 -0
- package/dist/types.js +35 -28
- package/dist/types.js.map +1 -0
- package/package.json +19 -8
- package/public/silex.js +17 -0
- package/src/css/dialog.scss +9 -2
- package/src/css/grapesjs.scss +79 -0
- package/src/css/project-bar.scss +2 -2
- package/src/example-client-config.js +17 -0
- package/src/html/templates/includes.pug +0 -1
- package/src/ts/client/config.ts +7 -6
- package/src/ts/client/grapesjs/LoginDialog.ts +190 -0
- package/src/ts/client/grapesjs/PublicationManager.ts +333 -0
- package/src/ts/client/grapesjs/PublicationUi.ts +320 -0
- package/src/ts/client/grapesjs/index.ts +88 -85
- package/src/ts/client/grapesjs/storage.ts +110 -0
- package/src/ts/client/index.ts +5 -7
- package/src/ts/client/services.ts +129 -0
- package/src/ts/constants.ts +21 -0
- package/src/ts/plugins/AuthPlugin.ts +38 -0
- package/src/ts/plugins/Cache.ts +28 -0
- package/src/ts/plugins/FtpBackend.ts +689 -0
- package/src/ts/plugins/HooksPlugin.ts +79 -0
- package/src/ts/plugins/PublicationPlugin.ts +170 -0
- package/src/{plugins/SslPlugin.js → ts/plugins/SslPlugin.ts} +24 -6
- package/src/ts/plugins/StaticPlugin.ts +68 -0
- package/src/ts/plugins/WebsitePlugin.ts +318 -0
- package/src/ts/server/backends/FsBackend.ts +266 -0
- package/src/ts/server/backends/index.ts +309 -0
- package/src/ts/server/cli.ts +0 -2
- package/src/ts/server/config.ts +103 -33
- package/src/ts/server/express.ts +37 -3
- package/src/ts/server/index.ts +24 -14
- package/src/ts/server/jobs.test.ts +74 -0
- package/src/ts/server/jobs.ts +77 -0
- package/src/ts/server/utils/validation.ts +33 -0
- package/src/ts/types.ts +167 -59
- package/dist/client/client/grapesjs/publish.d.ts +0 -18
- package/dist/page.js +0 -15
- package/src/plugins/AuthPlugin.js +0 -21
- package/src/plugins/Cache.js +0 -11
- package/src/plugins/DefaultBackend.js +0 -149
- package/src/plugins/ExpressPlugin.js +0 -39
- package/src/plugins/HooksPlugin.js +0 -58
- package/src/plugins/PublishPlugin.js +0 -69
- package/src/plugins/StaticPlugin.js +0 -48
- package/src/plugins/WebsitePlugin.js +0 -207
- package/src/ts/client/grapesjs/publish.ts +0 -403
- /package/.silex/default/{.silex.data.json → website.json} +0 -0
package/dist/server/express.js
CHANGED
|
@@ -3,11 +3,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.start = exports.create = void 0;
|
|
6
7
|
const express_1 = __importDefault(require("express"));
|
|
8
|
+
const body_parser_1 = __importDefault(require("body-parser"));
|
|
9
|
+
const compression_1 = __importDefault(require("compression"));
|
|
10
|
+
const cookie_parser_1 = __importDefault(require("cookie-parser"));
|
|
11
|
+
const cookie_session_1 = __importDefault(require("cookie-session"));
|
|
12
|
+
const cors_1 = __importDefault(require("cors"));
|
|
7
13
|
const events_1 = require("../events");
|
|
8
|
-
|
|
14
|
+
function create(config) {
|
|
9
15
|
const app = (0, express_1.default)();
|
|
10
|
-
|
|
16
|
+
app.set('config', config);
|
|
17
|
+
const options = config.expressOptions;
|
|
18
|
+
if (options.cors) {
|
|
19
|
+
console.log('> CORS are ENABLED:', options.cors);
|
|
20
|
+
app.use((0, cors_1.default)({
|
|
21
|
+
origin: options.cors,
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
app.use((0, compression_1.default)());
|
|
25
|
+
app.use(body_parser_1.default.json({ limit: options.jsonLimit }));
|
|
26
|
+
app.use(body_parser_1.default.text({ limit: options.textLimit }));
|
|
27
|
+
console.log('> Session name:', options.sessionName);
|
|
28
|
+
app.use((0, cookie_parser_1.default)());
|
|
29
|
+
app.use((0, cookie_session_1.default)({
|
|
30
|
+
name: options.sessionName,
|
|
31
|
+
secret: options.sessionSecret,
|
|
32
|
+
}));
|
|
33
|
+
return app;
|
|
34
|
+
}
|
|
35
|
+
exports.create = create;
|
|
36
|
+
async function start(app) {
|
|
37
|
+
const config = app.get('config');
|
|
38
|
+
config.emit(events_1.EVENT_STARTUP_START, { app });
|
|
11
39
|
return new Promise((resolve, reject) => {
|
|
12
40
|
app.listen(config.port, () => {
|
|
13
41
|
config.emit(events_1.EVENT_STARTUP_END, { app });
|
|
@@ -15,4 +43,4 @@ async function default_1(config) {
|
|
|
15
43
|
});
|
|
16
44
|
});
|
|
17
45
|
}
|
|
18
|
-
exports.
|
|
46
|
+
exports.start = start;
|
package/dist/server/index.js
CHANGED
|
@@ -22,28 +22,17 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
const express_1 = __importDefault(require("./express"));
|
|
33
|
-
exports.start = express_1.default;
|
|
34
|
-
const config = __importStar(require("./config"));
|
|
35
|
-
exports.config = config;
|
|
36
|
-
const types = __importStar(require("../types"));
|
|
37
|
-
exports.types = types;
|
|
38
|
-
const events = __importStar(require("../events"));
|
|
39
|
-
exports.events = events;
|
|
40
|
-
const constants = __importStar(require("../constants"));
|
|
41
|
-
exports.constants = constants;
|
|
42
|
-
const page = __importStar(require("../page"));
|
|
43
|
-
exports.page = page;
|
|
26
|
+
const backends = __importStar(require("./backends"));
|
|
27
|
+
const silexApp = __importStar(require("./express"));
|
|
28
|
+
const config_1 = require("./config");
|
|
44
29
|
async function main() {
|
|
45
|
-
const config =
|
|
46
|
-
const app =
|
|
30
|
+
const config = (0, config_1.createConfig)();
|
|
31
|
+
const app = silexApp.create(config);
|
|
32
|
+
await config.addRoutes(app);
|
|
33
|
+
await config.loadConfigFiles();
|
|
34
|
+
backends.addRoutes(config, app);
|
|
35
|
+
await silexApp.start(app);
|
|
47
36
|
console.info(`
|
|
48
37
|
I'm ready, listening to port ${config.port}
|
|
49
38
|
`);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { JobData, JobId } from '../types';
|
|
2
|
+
export declare function startJob(message?: string): JobData;
|
|
3
|
+
export declare function getJob(id: JobId): JobData | undefined;
|
|
4
|
+
export declare function jobSuccess(id: JobId, message?: string): boolean;
|
|
5
|
+
export declare function jobError(id: JobId, message?: string): boolean;
|
|
6
|
+
export declare function killJob(job: JobData): void;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Silex website builder, free/libre no-code tool for makers.
|
|
4
|
+
* Copyright (c) 2023 lexoyo and Silex Labs foundation
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.killJob = exports.jobError = exports.jobSuccess = exports.getJob = exports.startJob = void 0;
|
|
20
|
+
const types_1 = require("../types");
|
|
21
|
+
// Delay after which the job is deleted from memory
|
|
22
|
+
const TIME_TO_KEEP_AFTER_STOP = 60 * 10 * 1000; // 10 min
|
|
23
|
+
// Store the jobs in memory
|
|
24
|
+
const jobs = new Array();
|
|
25
|
+
// Key which will change on server restart
|
|
26
|
+
const processKey = Math.ceil(Math.random() * 1000000);
|
|
27
|
+
// Next id for the next job
|
|
28
|
+
let nextJobId = 0;
|
|
29
|
+
// Create a new job
|
|
30
|
+
function startJob(message = '') {
|
|
31
|
+
const jobId = `${processKey}_${++nextJobId}`;
|
|
32
|
+
const job = {
|
|
33
|
+
jobId,
|
|
34
|
+
status: types_1.JobStatus.IN_PROGRESS,
|
|
35
|
+
message: message
|
|
36
|
+
};
|
|
37
|
+
jobs.push(job);
|
|
38
|
+
return job;
|
|
39
|
+
}
|
|
40
|
+
exports.startJob = startJob;
|
|
41
|
+
// Retriev a job if it exists
|
|
42
|
+
function getJob(id) {
|
|
43
|
+
return jobs.find(job => job.jobId === id);
|
|
44
|
+
}
|
|
45
|
+
exports.getJob = getJob;
|
|
46
|
+
// End the job with success
|
|
47
|
+
function jobSuccess(id, message = '') {
|
|
48
|
+
return end(id, types_1.JobStatus.SUCCESS, message);
|
|
49
|
+
}
|
|
50
|
+
exports.jobSuccess = jobSuccess;
|
|
51
|
+
// End the job with error
|
|
52
|
+
function jobError(id, message = '') {
|
|
53
|
+
return end(id, types_1.JobStatus.ERROR, message);
|
|
54
|
+
}
|
|
55
|
+
exports.jobError = jobError;
|
|
56
|
+
// Remove a job from memory
|
|
57
|
+
// This is also used in unit tests to avoid memory lea
|
|
58
|
+
function killJob(job) {
|
|
59
|
+
clearTimeout(job._timeout);
|
|
60
|
+
jobs.splice(jobs.findIndex(j => job.jobId === j.jobId), 1);
|
|
61
|
+
}
|
|
62
|
+
exports.killJob = killJob;
|
|
63
|
+
// End the job
|
|
64
|
+
function end(id, status, message = '') {
|
|
65
|
+
const job = getJob(id);
|
|
66
|
+
if (job) {
|
|
67
|
+
job.status = status;
|
|
68
|
+
if (message)
|
|
69
|
+
job.message = message;
|
|
70
|
+
job._timeout = setTimeout(() => killJob(job), TIME_TO_KEEP_AFTER_STOP);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=jobs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jobs.js","sourceRoot":"","sources":["../../src/ts/server/jobs.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH,oCAAoD;AAEpD,mDAAmD;AACnD,MAAM,uBAAuB,GAAG,EAAE,GAAC,EAAE,GAAC,IAAI,CAAA,CAAC,SAAS;AAEpD,2BAA2B;AAC3B,MAAM,IAAI,GAAG,IAAI,KAAK,EAAW,CAAA;AAEjC,0CAA0C;AAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,CAAA;AAErD,2BAA2B;AAC3B,IAAI,SAAS,GAAG,CAAC,CAAA;AAEjB,mBAAmB;AACnB,SAAgB,QAAQ,CAAC,OAAO,GAAG,EAAE;IACnC,MAAM,KAAK,GAAG,GAAG,UAAU,IAAI,EAAE,SAAS,EAAE,CAAA;IAC5C,MAAM,GAAG,GAAY;QACnB,KAAK;QACL,MAAM,EAAE,iBAAS,CAAC,WAAW;QAC7B,OAAO,EAAE,OAAO;KACjB,CAAA;IACD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACd,OAAO,GAAG,CAAA;AACZ,CAAC;AATD,4BASC;AAED,6BAA6B;AAC7B,SAAgB,MAAM,CAAC,EAAS;IAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,EAAE,CAAC,CAAA;AAC3C,CAAC;AAFD,wBAEC;AAGD,2BAA2B;AAC3B,SAAgB,UAAU,CAAC,EAAS,EAAE,OAAO,GAAG,EAAE;IAChD,OAAO,GAAG,CAAC,EAAE,EAAE,iBAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAC5C,CAAC;AAFD,gCAEC;AAED,yBAAyB;AACzB,SAAgB,QAAQ,CAAC,EAAS,EAAE,OAAO,GAAG,EAAE;IAC9C,OAAO,GAAG,CAAC,EAAE,EAAE,iBAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;AAC1C,CAAC;AAFD,4BAEC;AAED,2BAA2B;AAC3B,sDAAsD;AACtD,SAAgB,OAAO,CAAC,GAAY;IAClC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAC1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAA;AAC5D,CAAC;AAHD,0BAGC;AAED,cAAc;AACd,SAAS,GAAG,CAAC,EAAS,EAAE,MAAiB,EAAE,OAAO,GAAG,EAAE;IACrD,MAAM,GAAG,GAAG,MAAM,CAAC,EAAE,CAAC,CAAA;IACtB,IAAG,GAAG,EAAE;QACN,GAAG,CAAC,MAAM,GAAG,MAAM,CAAA;QACnB,IAAG,OAAO;YAAE,GAAG,CAAC,OAAO,GAAG,OAAO,CAAA;QACjC,GAAG,CAAC,QAAQ,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,uBAAuB,CAAC,CAAA;QACtE,OAAO,IAAI,CAAA;KACZ;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throw an error if a parameter is missing
|
|
3
|
+
* @param value the value to check
|
|
4
|
+
* @param name the name of the parameter
|
|
5
|
+
* @throws Error if the parameter is missing
|
|
6
|
+
*/
|
|
7
|
+
export declare function requiredParam<T>(value: T | undefined, name: string, defaultValue?: T): NonNullable<T>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Silex website builder, free/libre no-code tool for makers.
|
|
4
|
+
* Copyright (c) 2023 lexoyo and Silex Labs foundation
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.requiredParam = void 0;
|
|
20
|
+
/**
|
|
21
|
+
* Throw an error if a parameter is missing
|
|
22
|
+
* @param value the value to check
|
|
23
|
+
* @param name the name of the parameter
|
|
24
|
+
* @throws Error if the parameter is missing
|
|
25
|
+
*/
|
|
26
|
+
function requiredParam(value, name, defaultValue) {
|
|
27
|
+
if (value === undefined) {
|
|
28
|
+
if (defaultValue !== undefined) {
|
|
29
|
+
return defaultValue;
|
|
30
|
+
}
|
|
31
|
+
console.error(`Missing required parameter ${name}`);
|
|
32
|
+
throw new Error(`Missing required parameter ${name}`);
|
|
33
|
+
}
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
exports.requiredParam = requiredParam;
|
|
37
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/ts/server/utils/validation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAEH;;;;;GAKG;AACH,SAAgB,aAAa,CAAI,KAAoB,EAAE,IAAY,EAAE,YAAgB;IACnF,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,IAAI,YAAY,KAAK,SAAS,EAAE;YAC9B,OAAO,YAA8B,CAAA;SACtC;QACD,OAAO,CAAC,KAAK,CAAC,8BAA8B,IAAI,EAAE,CAAC,CAAA;QACnD,MAAM,IAAI,KAAK,CAAC,8BAA8B,IAAI,EAAE,CAAC,CAAA;KACtD;IACD,OAAO,KAAuB,CAAA;AAChC,CAAC;AATD,sCASC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview define types for Silex client and server
|
|
4
|
+
*/
|
|
5
|
+
export interface PublicationSettings {
|
|
6
|
+
backend?: BackendData;
|
|
7
|
+
url?: string;
|
|
8
|
+
autoHomePage?: boolean;
|
|
9
|
+
assets?: {
|
|
10
|
+
path?: string;
|
|
11
|
+
url?: string;
|
|
12
|
+
};
|
|
13
|
+
html?: {
|
|
14
|
+
path?: string;
|
|
15
|
+
ext?: string;
|
|
16
|
+
};
|
|
17
|
+
css?: {
|
|
18
|
+
path?: string;
|
|
19
|
+
url?: string;
|
|
20
|
+
ext?: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export interface WebsiteFile {
|
|
24
|
+
html: string;
|
|
25
|
+
css: string;
|
|
26
|
+
htmlPath: string;
|
|
27
|
+
cssPath: string;
|
|
28
|
+
}
|
|
29
|
+
export type ApiResponseError = {
|
|
30
|
+
message: string;
|
|
31
|
+
};
|
|
32
|
+
export type ApiPublicationPublishRequestBody = WebsiteData;
|
|
33
|
+
export type ApiPublicationPublishRequestQuery = {
|
|
34
|
+
id: WebsiteId;
|
|
35
|
+
};
|
|
36
|
+
export type ApiPublicationPublishResponse = {
|
|
37
|
+
url: string;
|
|
38
|
+
job: PublicationJobData;
|
|
39
|
+
};
|
|
40
|
+
export type ApiPublicationStatusRequestQuery = {
|
|
41
|
+
jobId: JobId;
|
|
42
|
+
};
|
|
43
|
+
export type ApiPublicationStatusResponse = PublicationJobData;
|
|
44
|
+
export type ApiWebsiteReadRequestQuery = {
|
|
45
|
+
id?: WebsiteId;
|
|
46
|
+
backendId?: BackendId;
|
|
47
|
+
};
|
|
48
|
+
export type ApiWebsiteReadResponse = WebsiteMeta[] | WebsiteData;
|
|
49
|
+
export type ApiWebsiteWriteRequestQuery = {
|
|
50
|
+
id: WebsiteId;
|
|
51
|
+
backendId?: BackendId;
|
|
52
|
+
};
|
|
53
|
+
export type ApiWebsiteWriteRequestBody = WebsiteData;
|
|
54
|
+
export type ApiWebsiteWriteResponse = {
|
|
55
|
+
message: string;
|
|
56
|
+
};
|
|
57
|
+
export type ApiWebsiteDeleteRequestQuery = {
|
|
58
|
+
id: WebsiteId;
|
|
59
|
+
backendId?: BackendId;
|
|
60
|
+
};
|
|
61
|
+
export type ApiWebsiteAssetsReadRequestQuery = {
|
|
62
|
+
id: WebsiteId;
|
|
63
|
+
backendId?: BackendId;
|
|
64
|
+
};
|
|
65
|
+
export type ApiWebsiteAssetsReadRequestParams = {
|
|
66
|
+
path: string;
|
|
67
|
+
};
|
|
68
|
+
export type ApiWebsiteAssetsReadResponse = string;
|
|
69
|
+
export type ApiWebsiteAssetsWriteRequestQuery = {
|
|
70
|
+
id: WebsiteId;
|
|
71
|
+
backendId?: BackendId;
|
|
72
|
+
};
|
|
73
|
+
export type ApiWebsiteAssetsWriteRequestBody = ClientSideFile[];
|
|
74
|
+
export type ApiWebsiteAssetsWriteResponse = {
|
|
75
|
+
data: string[];
|
|
76
|
+
};
|
|
77
|
+
export type ApiBackendListRequestQuery = {
|
|
78
|
+
type: BackendType;
|
|
79
|
+
};
|
|
80
|
+
export type ApiBackendListResponse = BackendData[];
|
|
81
|
+
export type ApiBackendLoginRequestQuery = {
|
|
82
|
+
backendId: BackendId;
|
|
83
|
+
type: BackendType;
|
|
84
|
+
options?: string;
|
|
85
|
+
error?: string;
|
|
86
|
+
};
|
|
87
|
+
export type ApiBackendLoggedInPostMessage = {
|
|
88
|
+
type: string;
|
|
89
|
+
error: boolean;
|
|
90
|
+
message: string;
|
|
91
|
+
backendId: BackendId;
|
|
92
|
+
};
|
|
93
|
+
export type ApiBackendLogoutRequestQuery = {
|
|
94
|
+
backendId: BackendId;
|
|
95
|
+
type: BackendType;
|
|
96
|
+
};
|
|
97
|
+
export type ApiBackendLoginStatusRequestQuery = {
|
|
98
|
+
id?: WebsiteId;
|
|
99
|
+
backendId?: BackendId;
|
|
100
|
+
type: BackendType;
|
|
101
|
+
};
|
|
102
|
+
export type ApiBackendLoginStatusResponse = {
|
|
103
|
+
user: BackendUser;
|
|
104
|
+
backend: BackendData;
|
|
105
|
+
websiteMeta?: WebsiteMeta;
|
|
106
|
+
};
|
|
107
|
+
export interface WebsiteData {
|
|
108
|
+
pages: Page[];
|
|
109
|
+
assets: Asset[];
|
|
110
|
+
styles: Style[];
|
|
111
|
+
name: string;
|
|
112
|
+
settings: WebsiteSettings;
|
|
113
|
+
fonts: Font[];
|
|
114
|
+
symbols: symbol[];
|
|
115
|
+
publication: PublicationSettings;
|
|
116
|
+
}
|
|
117
|
+
export interface PublicationData extends WebsiteData {
|
|
118
|
+
files?: WebsiteFile[];
|
|
119
|
+
}
|
|
120
|
+
export interface WebsiteSettings {
|
|
121
|
+
description: string;
|
|
122
|
+
title: string;
|
|
123
|
+
lang: string;
|
|
124
|
+
head: string;
|
|
125
|
+
favicon: string;
|
|
126
|
+
'og:title': string;
|
|
127
|
+
'og:description': string;
|
|
128
|
+
'og:image': string;
|
|
129
|
+
}
|
|
130
|
+
export interface Font {
|
|
131
|
+
name: string;
|
|
132
|
+
value: string;
|
|
133
|
+
variants: string[];
|
|
134
|
+
}
|
|
135
|
+
export interface Page {
|
|
136
|
+
name?: string;
|
|
137
|
+
id: string;
|
|
138
|
+
type?: string;
|
|
139
|
+
frames: Frame[];
|
|
140
|
+
settings?: WebsiteSettings;
|
|
141
|
+
cssExt?: string;
|
|
142
|
+
htmlExt?: string;
|
|
143
|
+
}
|
|
144
|
+
export interface Frame {
|
|
145
|
+
component: {
|
|
146
|
+
type: string;
|
|
147
|
+
stylable: string[];
|
|
148
|
+
};
|
|
149
|
+
components: Component[];
|
|
150
|
+
}
|
|
151
|
+
export interface Component {
|
|
152
|
+
type: string;
|
|
153
|
+
content?: string;
|
|
154
|
+
attributes: {
|
|
155
|
+
[key: string]: string;
|
|
156
|
+
};
|
|
157
|
+
conponents: Component[];
|
|
158
|
+
}
|
|
159
|
+
export declare enum Unit {
|
|
160
|
+
PX = "px"
|
|
161
|
+
}
|
|
162
|
+
export interface Asset {
|
|
163
|
+
type: string;
|
|
164
|
+
src: string;
|
|
165
|
+
unitDim: Unit;
|
|
166
|
+
height: number;
|
|
167
|
+
width: number;
|
|
168
|
+
name: string;
|
|
169
|
+
}
|
|
170
|
+
export interface Style {
|
|
171
|
+
selectors: Selector[];
|
|
172
|
+
style: {
|
|
173
|
+
[key: string]: string;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
export type Selector = string | {
|
|
177
|
+
name: string;
|
|
178
|
+
type: number;
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Type for a backend id
|
|
182
|
+
*/
|
|
183
|
+
export type BackendId = string;
|
|
184
|
+
/**
|
|
185
|
+
* Type for a client side file
|
|
186
|
+
* @see backend/File
|
|
187
|
+
*/
|
|
188
|
+
export interface ClientSideFile {
|
|
189
|
+
path: string;
|
|
190
|
+
content: Buffer | string;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Type for file listing
|
|
194
|
+
*/
|
|
195
|
+
export interface FileMeta {
|
|
196
|
+
name: string;
|
|
197
|
+
isDir: boolean;
|
|
198
|
+
size: number;
|
|
199
|
+
createdAt: Date;
|
|
200
|
+
updatedAt: Date;
|
|
201
|
+
metadata?: object;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Enum to express if the backend is a storage or a hosting
|
|
205
|
+
*/
|
|
206
|
+
export declare enum BackendType {
|
|
207
|
+
STORAGE = "STORAGE",
|
|
208
|
+
HOSTING = "HOSTING"
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Type for a website id
|
|
212
|
+
*/
|
|
213
|
+
export type WebsiteId = string;
|
|
214
|
+
/**
|
|
215
|
+
* Back end data sent to the front end
|
|
216
|
+
*/
|
|
217
|
+
export interface BackendData {
|
|
218
|
+
backendId: BackendId;
|
|
219
|
+
type: BackendType;
|
|
220
|
+
displayName: string;
|
|
221
|
+
icon: string;
|
|
222
|
+
disableLogout: boolean;
|
|
223
|
+
isLoggedIn: boolean;
|
|
224
|
+
authUrl: string | null;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Back end data sent to the front end
|
|
228
|
+
*/
|
|
229
|
+
export interface BackendUser {
|
|
230
|
+
name: string;
|
|
231
|
+
email?: string;
|
|
232
|
+
picture?: string;
|
|
233
|
+
metadata?: object;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Back end data sent to the front end
|
|
237
|
+
* Meta data can be the root path of the websites, or the bucket name, etc.
|
|
238
|
+
*/
|
|
239
|
+
export interface WebsiteMeta {
|
|
240
|
+
websiteId: WebsiteId;
|
|
241
|
+
createdAt: Date;
|
|
242
|
+
updatedAt: Date;
|
|
243
|
+
metadata?: object;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Enum to express if the job is in progress or finished or errored
|
|
247
|
+
*/
|
|
248
|
+
export declare enum JobStatus {
|
|
249
|
+
IN_PROGRESS = "IN_PROGRESS",
|
|
250
|
+
SUCCESS = "SUCCESS",
|
|
251
|
+
ERROR = "ERROR"
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Id used to track the progress of a publication
|
|
255
|
+
*/
|
|
256
|
+
export type JobId = string;
|
|
257
|
+
/**
|
|
258
|
+
* Data structure which is sent to the client to display the progress of a job
|
|
259
|
+
*/
|
|
260
|
+
export interface JobData {
|
|
261
|
+
jobId: JobId;
|
|
262
|
+
status: JobStatus;
|
|
263
|
+
message: string;
|
|
264
|
+
url?: string;
|
|
265
|
+
_timeout?: ReturnType<typeof setTimeout>;
|
|
266
|
+
}
|
|
267
|
+
export interface PublicationJobData extends JobData {
|
|
268
|
+
logs: string[][];
|
|
269
|
+
errors: string[][];
|
|
270
|
+
}
|
package/dist/types.js
CHANGED
|
@@ -1,34 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Silex website builder, free/libre no-code tool for makers.
|
|
4
|
+
* Copyright (c) 2023 lexoyo and Silex Labs foundation
|
|
5
|
+
*
|
|
6
|
+
* This program is free software: you can redistribute it and/or modify
|
|
7
|
+
* it under the terms of the GNU Affero General Public License as published by
|
|
8
|
+
* the Free Software Foundation, either version 3 of the License, or any later version.
|
|
9
|
+
*
|
|
10
|
+
* This program is distributed in the hope that it will be useful,
|
|
11
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
* GNU Affero General Public License for more details.
|
|
14
|
+
*
|
|
15
|
+
* You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
2
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.defaultPublicationSettings = {
|
|
5
|
-
path: 'publication',
|
|
6
|
-
url: '',
|
|
7
|
-
autoHomePage: true,
|
|
8
|
-
assets: { path: 'assets', url: '/assets' },
|
|
9
|
-
html: { path: '' },
|
|
10
|
-
css: { path: 'css', url: '/css' },
|
|
11
|
-
};
|
|
12
|
-
exports.defaultSite = {
|
|
13
|
-
pages: [{ name: 'Main', id: 'main', frames: [{ component: { type: 'text', stylable: [] }, components: [] }] }],
|
|
14
|
-
assets: [],
|
|
15
|
-
styles: [],
|
|
16
|
-
name: 'New website',
|
|
17
|
-
settings: {
|
|
18
|
-
description: '',
|
|
19
|
-
title: '',
|
|
20
|
-
head: '',
|
|
21
|
-
lang: '',
|
|
22
|
-
favicon: '',
|
|
23
|
-
'og:title': '',
|
|
24
|
-
'og:description': '',
|
|
25
|
-
'og:image': '',
|
|
26
|
-
},
|
|
27
|
-
fonts: [],
|
|
28
|
-
symbols: [],
|
|
29
|
-
publication: exports.defaultPublicationSettings,
|
|
30
|
-
};
|
|
19
|
+
exports.JobStatus = exports.BackendType = exports.Unit = void 0;
|
|
31
20
|
var Unit;
|
|
32
21
|
(function (Unit) {
|
|
33
22
|
Unit["PX"] = "px";
|
|
34
23
|
})(Unit || (exports.Unit = Unit = {}));
|
|
24
|
+
/**
|
|
25
|
+
* Enum to express if the backend is a storage or a hosting
|
|
26
|
+
*/
|
|
27
|
+
var BackendType;
|
|
28
|
+
(function (BackendType) {
|
|
29
|
+
BackendType["STORAGE"] = "STORAGE";
|
|
30
|
+
BackendType["HOSTING"] = "HOSTING";
|
|
31
|
+
})(BackendType || (exports.BackendType = BackendType = {}));
|
|
32
|
+
/**
|
|
33
|
+
* Enum to express if the job is in progress or finished or errored
|
|
34
|
+
*/
|
|
35
|
+
var JobStatus;
|
|
36
|
+
(function (JobStatus) {
|
|
37
|
+
JobStatus["IN_PROGRESS"] = "IN_PROGRESS";
|
|
38
|
+
JobStatus["SUCCESS"] = "SUCCESS";
|
|
39
|
+
JobStatus["ERROR"] = "ERROR";
|
|
40
|
+
})(JobStatus || (exports.JobStatus = JobStatus = {}));
|
|
41
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/ts/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;;;AAmHH,IAAY,IAEX;AAFD,WAAY,IAAI;IACd,iBAAS,CAAA;AACX,CAAC,EAFW,IAAI,oBAAJ,IAAI,QAEf;AAiDD;;GAEG;AACH,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,kCAAmB,CAAA;IACnB,kCAAmB,CAAA;AACrB,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB;AAyCD;;GAEG;AACH,IAAY,SAIX;AAJD,WAAY,SAAS;IACnB,wCAA2B,CAAA;IAC3B,gCAAmB,CAAA;IACnB,4BAAe,CAAA;AACjB,CAAC,EAJW,SAAS,yBAAT,SAAS,QAIpB"}
|
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.
|
|
4
|
+
"version": "3.0.0-alpha.41",
|
|
5
5
|
"version:backwardcompat": "3.0.0",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Alex Hoyau",
|
|
@@ -41,21 +41,28 @@
|
|
|
41
41
|
},
|
|
42
42
|
"build:client:debug": {
|
|
43
43
|
"patterns": [
|
|
44
|
-
"src/ts/client/"
|
|
44
|
+
"src/ts/client/",
|
|
45
|
+
"src/ts/plugins/"
|
|
45
46
|
],
|
|
46
47
|
"extensions": [
|
|
47
|
-
"ts"
|
|
48
|
-
"js"
|
|
48
|
+
"ts"
|
|
49
49
|
]
|
|
50
50
|
},
|
|
51
51
|
"build:server:debug": {
|
|
52
52
|
"patterns": [
|
|
53
53
|
"src/ts/server/",
|
|
54
|
-
"src/plugins/"
|
|
54
|
+
"src/ts/plugins/"
|
|
55
55
|
],
|
|
56
56
|
"extensions": [
|
|
57
|
-
"ts"
|
|
58
|
-
|
|
57
|
+
"ts"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"build:plugins": {
|
|
61
|
+
"patterns": [
|
|
62
|
+
"src/ts/plugins/"
|
|
63
|
+
],
|
|
64
|
+
"extensions": [
|
|
65
|
+
"ts"
|
|
59
66
|
]
|
|
60
67
|
}
|
|
61
68
|
},
|
|
@@ -66,7 +73,7 @@
|
|
|
66
73
|
"start:debug": "cross-env FS_ROOT=`pwd`/.silex cross-env SILEX_DEBUG=true nodemon --watch dist/server dist/server/index.js",
|
|
67
74
|
"prepublishOnly": "$npm_execpath run lint && $npm_execpath test && $npm_execpath run build",
|
|
68
75
|
"preversion": "$npm_execpath run prepublishOnly",
|
|
69
|
-
"build": "run-s build:css:release build:html build:client:release build:server:release",
|
|
76
|
+
"build": "run-s build:css:release build:html build:client:release build:server:release build:plugins",
|
|
70
77
|
"webpack": "webpack --config webpack.config.js",
|
|
71
78
|
"build:css:release": "sass --load-path ../../node_modules --load-path node_modules --no-source-map src/css/index.scss dist/client/css/admin.css",
|
|
72
79
|
"build:css:debug": "sass --load-path ../../node_modules --load-path node_modules src/css/index.scss dist/client/css/admin.css",
|
|
@@ -76,6 +83,7 @@
|
|
|
76
83
|
"build:client:debug": "webpack --config webpack.debug.config.js",
|
|
77
84
|
"build:server:release": "tsc -p tsconfig-server-release.json",
|
|
78
85
|
"build:server:debug": "SILEX_DEBUG=true tsc -p tsconfig-server-debug.json",
|
|
86
|
+
"build:plugins": "SILEX_DEBUG=true tsc -p tsconfig-plugins.json",
|
|
79
87
|
"lint": "eslint 'src/ts/**/*.ts'",
|
|
80
88
|
"lint:fix": "$npm_execpath run lint -- --fix",
|
|
81
89
|
"test": "node --experimental-vm-modules `node_modules jest`/jest/bin/jest.js",
|
|
@@ -83,6 +91,7 @@
|
|
|
83
91
|
},
|
|
84
92
|
"dependencies": {
|
|
85
93
|
"@directus/sdk": "10.3.3",
|
|
94
|
+
"@fortawesome/fontawesome-free": "6.4.0",
|
|
86
95
|
"@silexlabs/grapesjs-directus-storage": "1.0.15",
|
|
87
96
|
"@silexlabs/grapesjs-fonts": "1.0.12",
|
|
88
97
|
"@silexlabs/grapesjs-loading": "1.0.8",
|
|
@@ -100,12 +109,14 @@
|
|
|
100
109
|
"express": "4.18.2",
|
|
101
110
|
"express-force-ssl": "0.3.2",
|
|
102
111
|
"formidable": "2.1.1",
|
|
112
|
+
"fs-extra": "^11.1.1",
|
|
103
113
|
"grapesjs": "0.21.2",
|
|
104
114
|
"grapesjs-blocks-basic": "1.0.2",
|
|
105
115
|
"grapesjs-custom-code": "1.0.2",
|
|
106
116
|
"grapesjs-plugin-forms": "2.0.6",
|
|
107
117
|
"grapesjs-style-filter": "1.0.2",
|
|
108
118
|
"html-minifier": "4.0.0",
|
|
119
|
+
"jsftp": "^2.1.3",
|
|
109
120
|
"lit-html": "2.7.4",
|
|
110
121
|
"mkdirp": "3.0.1",
|
|
111
122
|
"node_modules-path": "2.0.7",
|
package/public/silex.js
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
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
|
+
|
|
1
18
|
// This file is loaded by Silex when the user opens the editor
|
|
2
19
|
// Unless you override the default config with the environment variable SILEX_CLIENT_CONFIG or the CLI option --client-config
|
|
3
20
|
export default async function (config) {
|