@lexho111/plainblog 0.7.2 → 0.7.4
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/Article.js +82 -90
- package/Article.ts +97 -0
- package/AssetManager.js +63 -116
- package/Auth.js +2 -2
- package/Blog.js +103 -82
- package/cluster-server.js +36 -31
- package/debug-loader.js +16 -1
- package/index.js +2 -0
- package/model/DataModel.js +11 -9
- package/model/SqliteAdapter.js +15 -7
- package/model/datastructures/BinarySearchTree.js +1 -1
- package/modules/csscompiler/compile-style-worker.js +72 -0
- package/modules/csscompiler/csscompiler.js +135 -0
- package/modules/jscompiler/compile-js-worker.js +34 -0
- package/{build-scripts.js → modules/jscompiler/jscompiler.js} +3 -1
- package/package.json +4 -7
- package/public/styles.min.css +8 -2
- package/router.js +60 -64
- package/server.js +190 -155
- package/src/styles.css +1 -1
- package/styles.hash +1 -0
- package/tsconfig.json +12 -0
- package/.dependency-cruiser.cjs +0 -382
- package/ArrayList.cpuprofile +0 -1
- package/BinarySearchTree.cpuprofile +0 -1
- package/FlameChartProfile.cpuprofile +0 -1
- package/FlameChartProfile2.cpuprofile +0 -1
- package/FlameChartProfile3.cpuprofile +0 -1
- package/StandaloneProfile.cpuprofile +0 -1
- package/blog_test_empty +0 -0
- package/blog_test_load +0 -0
- package/build-styles.js +0 -87
- package/workers/compiler-worker.js +0 -42
package/blog_test_empty
DELETED
|
Binary file
|
package/blog_test_load
DELETED
|
Binary file
|
package/build-styles.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Compiles CSS styles from file content objects.
|
|
5
|
-
* @param {Array<{path: string, content: string}>} fileData - An array of objects containing file paths and content.
|
|
6
|
-
* @returns {Promise<string>} The compiled and minified CSS.
|
|
7
|
-
*/
|
|
8
|
-
export async function compileStyles(fileData) {
|
|
9
|
-
let combinedCss = "";
|
|
10
|
-
try {
|
|
11
|
-
// 1. filter out css files
|
|
12
|
-
if (fileData) {
|
|
13
|
-
const scssFiles = fileData.filter(
|
|
14
|
-
(f) =>
|
|
15
|
-
f.path.endsWith(".scss") && !path.basename(f.path).startsWith("_"),
|
|
16
|
-
);
|
|
17
|
-
if (scssFiles.length > 0) console.error("sass files are not supported.");
|
|
18
|
-
|
|
19
|
-
// make one big css file
|
|
20
|
-
const cssFiles = fileData.filter((f) => f.path.endsWith(".css"));
|
|
21
|
-
for (const file of cssFiles) {
|
|
22
|
-
combinedCss += file.content + "\n";
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// 2. minify and uglify with PostCSS
|
|
27
|
-
if (combinedCss) {
|
|
28
|
-
return await runPostcss(combinedCss);
|
|
29
|
-
}
|
|
30
|
-
return "";
|
|
31
|
-
} catch (error) {
|
|
32
|
-
if (error.message !== "Missing optional dependencies") {
|
|
33
|
-
console.error("Build failed:", error);
|
|
34
|
-
}
|
|
35
|
-
return combinedCss;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async function runPostcss(css) {
|
|
40
|
-
let postcss, autoprefixer, cssnano;
|
|
41
|
-
|
|
42
|
-
try {
|
|
43
|
-
postcss = (await import("postcss")).default;
|
|
44
|
-
autoprefixer = (await import("autoprefixer")).default;
|
|
45
|
-
cssnano = (await import("cssnano")).default;
|
|
46
|
-
} catch (error) {
|
|
47
|
-
if (
|
|
48
|
-
error.code === "ERR_MODULE_NOT_FOUND" ||
|
|
49
|
-
error.code === "MODULE_NOT_FOUND"
|
|
50
|
-
) {
|
|
51
|
-
const deps = "postcss autoprefixer cssnano";
|
|
52
|
-
console.error(
|
|
53
|
-
`The build-style dependencies are not installed. Please install them by running: npm install ${deps}`,
|
|
54
|
-
);
|
|
55
|
-
throw new Error(`Missing optional dependencies: '${deps}'`);
|
|
56
|
-
} else {
|
|
57
|
-
throw new Error("Missing optional dependencies");
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const plugins = [autoprefixer(), cssnano()];
|
|
62
|
-
const result = await postcss(plugins).process(css, {
|
|
63
|
-
from: undefined, // do not print source map warning
|
|
64
|
-
});
|
|
65
|
-
return result.css; // final result
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Merges and minifies multiple CSS content strings.
|
|
70
|
-
* @param {...string} cssContents - CSS strings to merge.
|
|
71
|
-
* @returns {Promise<string>} The merged and minified CSS.
|
|
72
|
-
*/
|
|
73
|
-
export async function mergeStyles(...cssContents) {
|
|
74
|
-
try {
|
|
75
|
-
const combinedCss = cssContents.join("\n");
|
|
76
|
-
|
|
77
|
-
if (combinedCss) {
|
|
78
|
-
return await runPostcss(combinedCss);
|
|
79
|
-
}
|
|
80
|
-
return "";
|
|
81
|
-
} catch (error) {
|
|
82
|
-
if (error.message !== "Missing optional dependencies") {
|
|
83
|
-
console.error("Merge failed:", error);
|
|
84
|
-
}
|
|
85
|
-
return cssContents.join("\n"); // fallback: return unminified css
|
|
86
|
-
}
|
|
87
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { parentPort, workerData } from "worker_threads";
|
|
2
|
-
import { compileStyles, mergeStyles } from "../build-styles.js";
|
|
3
|
-
import { compileScripts } from "../build-scripts.js";
|
|
4
|
-
import { createDebug, debug_perf } from "../debug-loader.js";
|
|
5
|
-
|
|
6
|
-
async function run() {
|
|
7
|
-
if (!parentPort) {
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
const { type, fileData, cssContents } = workerData;
|
|
11
|
-
try {
|
|
12
|
-
const time_start = performance.now();
|
|
13
|
-
let result;
|
|
14
|
-
if (type === "styles") {
|
|
15
|
-
result = await compileStyles(fileData);
|
|
16
|
-
} else if (type === "scripts") {
|
|
17
|
-
result = await compileScripts(fileData);
|
|
18
|
-
} else if (type === "mergeStyles") {
|
|
19
|
-
result = await mergeStyles(...cssContents);
|
|
20
|
-
} else {
|
|
21
|
-
throw new Error(`Unknown compilation type: ${type}`);
|
|
22
|
-
}
|
|
23
|
-
const time_end = performance.now();
|
|
24
|
-
const duration = time_end - time_start;
|
|
25
|
-
debug_perf("compilerWorker took " + duration + "ms", duration);
|
|
26
|
-
parentPort.postMessage({ status: "success", result });
|
|
27
|
-
} catch (error) {
|
|
28
|
-
parentPort.postMessage({ status: "error", error: error.message });
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
run();
|
|
33
|
-
|
|
34
|
-
process.on("uncaughtException", (err) => {
|
|
35
|
-
console.error("KRITISCHER FEHLER:", err.stack);
|
|
36
|
-
// Logge den Fehler in eine Datei oder einen Dienst
|
|
37
|
-
process.exit(1); // Kontrollierter Neustart durch PM2
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
process.on("unhandledRejection", (reason, promise) => {
|
|
41
|
-
console.error("UNBEHANDELTES PROMISE:", reason);
|
|
42
|
-
});
|