@lexho111/plainblog 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Blog.js CHANGED
@@ -6,16 +6,16 @@ import process from "node:process";
6
6
  import path from "path";
7
7
  import { fileURLToPath } from "url";
8
8
  import pkg from "./package.json" with { type: "json" };
9
- import { debuglog as createDebug } from "node:util";
10
9
  import Article from "./Article.js";
11
10
  import DatabaseModel from "./model/DatabaseModel.js";
12
11
  import { fetchData, postData } from "./model/APIModel.js";
13
- import { formatHTML, header, formatMarkdown, validate } from "./Formatter.js"; // import pkg from "./package.json" with { type: "json" };
12
+ import { formatHTML, header, formatMarkdown, validate } from "./Formatter.js";
14
13
  import { compileStyles, mergeStyles } from "./build-styles.js";
15
14
  import { compileScripts } from "./build-scripts.js";
16
15
  import FileAdapter from "./model/FileAdapter.js";
17
16
  import DataModel from "./model/DataModel.js";
18
17
  import { BinarySearchTreeHashMap } from "./model/datastructures/BinarySearchTreeHashMap.js";
18
+ import createDebug from "./debug-loader.js";
19
19
 
20
20
  // Initialize the debugger with a specific namespace
21
21
  const debug = createDebug("plainblog:Blog");
Binary file
package/blog_test_load.db CHANGED
Binary file
@@ -0,0 +1,26 @@
1
+ import { debuglog } from "node:util";
2
+ import { createRequire } from "node:module";
3
+
4
+ const require = createRequire(import.meta.url);
5
+
6
+ /**
7
+ * Tries to load the 'debug' package synchronously, falling back to node:util.debuglog if not found.
8
+ * @param {string} namespace - The debug namespace (e.g., 'app:module').
9
+ * @returns {Function} - The debug function.
10
+ */
11
+ export default function createDebug(namespace) {
12
+ try {
13
+ // Attempt to load the external package synchronously
14
+ const debugFactory = require("debug");
15
+ return debugFactory(namespace);
16
+ } catch (err) {
17
+ if (
18
+ err.code === "ERR_MODULE_NOT_FOUND" ||
19
+ err.code === "MODULE_NOT_FOUND"
20
+ ) {
21
+ // Fallback to built-in node:util
22
+ return debuglog(namespace);
23
+ }
24
+ throw err; // Re-throw if it's a different error
25
+ }
26
+ }
@@ -1,4 +1,4 @@
1
- import { debuglog as createDebug } from "node:util";
1
+ import createDebug from "../debug-loader.js";
2
2
  import Article from "../Article.js";
3
3
 
4
4
  const debug = createDebug("plainblog:DataModel");
@@ -1,4 +1,4 @@
1
- import { debuglog as createDebug } from "node:util";
1
+ import createDebug from "../debug-loader.js";
2
2
 
3
3
  const debug = createDebug("plainblog:DatabaseModel");
4
4
 
@@ -6,7 +6,7 @@ import {
6
6
  initFiles,
7
7
  saveArticles,
8
8
  } from "./FileModel.js";
9
- import { debuglog as createDebug } from "node:util";
9
+ import createDebug from "../debug-loader.js";
10
10
 
11
11
  const debug = createDebug("plainblog:FileAdapter");
12
12
 
@@ -1,6 +1,6 @@
1
1
  import { promises as promise } from "fs";
2
- import { appendFile, appendFileSync, readFile, readFileSync } from "node:fs";
3
- import { debuglog as createDebug } from "node:util";
2
+ import { appendFileSync, readFileSync } from "node:fs";
3
+ import createDebug from "../debug-loader.js";
4
4
  import Article from "../Article.js";
5
5
 
6
6
  const debug = createDebug("plainblog:FileModel");
@@ -1,5 +1,5 @@
1
- import { debuglog as createDebug } from "node:util";
2
1
  import Article from "../../Article.js";
2
+ import createDebug from "../../debug-loader.js";
3
3
 
4
4
  const debug = createDebug("plainblog:BinarySearchTree");
5
5
 
@@ -1,4 +1,4 @@
1
- import { debuglog as createDebug } from "node:util";
1
+ import createDebug from "../../debug-loader.js";
2
2
  import { BinarySearchTree } from "./BinarySearchTree.js";
3
3
 
4
4
  // Initialize the debugger with a specific namespace
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lexho111/plainblog",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "A tool for creating and serving a minimalist, single-page blog.",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -26,6 +26,7 @@
26
26
  "@types/node": "^25.0.3",
27
27
  "autoprefixer": "^10.4.23",
28
28
  "cssnano": "^7.1.2",
29
+ "debug": "^4.4.3",
29
30
  "eslint": "^9.39.2",
30
31
  "eslint-plugin-jest": "^28.6.0",
31
32
  "globals": "^17.0.0",
@@ -38,6 +39,5 @@
38
39
  "typescript": "^5.9.3",
39
40
  "uglify-js": "^3.19.3",
40
41
  "w3c-css-validator": "^1.4.1"
41
- },
42
- "dependencies": {}
42
+ }
43
43
  }
@@ -1,2 +1,2 @@
1
- body{font-family:Arial,sans-serif}h1{color:#333}body{font-family:Arial;margin:0}nav{margin-top:10px}.box,h1,nav{margin-left:10px}.grid{border:0 solid #000;display:grid;gap:.25rem;grid-template-columns:1fr}.grid article{border:0 solid #ccc;border-radius:4px;min-width:0;overflow-wrap:break-word;padding:.25rem}.grid article h2{color:#353535;margin-bottom:5px}.grid article .datetime{color:#757575;margin:0}.grid article p{margin-bottom:0;margin-top:10px}article a,article a:visited,h1{color:#696969}nav a{color:#3b40c1;font-size:20px;text-decoration:underline}nav a:visited{color:#3b40c1;text-decoration-color:#3b40c1}#wrapper{max-width:500px;width:100%}.hide-image{display:none}@media screen and (max-width:1000px){*{font-size:4vw}#wrapper{box-sizing:border-box;max-width:100%;padding:0 10px;width:100%}}h2{margin-top:0}.buttons,h2{border:0 solid #000}.buttons{height:25px;margin-bottom:0;width:100%}.button{border:1px solid #000;cursor:pointer;float:left;height:19px;padding:2px;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100px}.button:focus{outline:2px solid orange}.edit{background-color:blue}.delete{background-color:red}
2
- /* source-hash: 22048a393d87cbbefd7a61fb300fff916360a30934da974ee2fd45739e446492 */
1
+ body{font-family:Arial;font-size:1.2em;margin:0}nav{margin-top:10px}.box,h1,nav{margin-left:10px}.grid{border:0 solid #000;display:grid;gap:.25rem;grid-template-columns:1fr}.grid article{border:0 solid #ccc;border-radius:4px;min-width:0;overflow-wrap:break-word;padding:.25rem}.grid article h2{color:#353535;margin-bottom:5px}.grid article .datetime{color:#757575;margin:0}.grid article p{margin-bottom:0;margin-top:10px}article a,article a:visited,h1{color:#696969}nav a{color:#3b40c1;font-size:20px;text-decoration:underline}nav a:visited{color:#3b40c1;text-decoration-color:#3b40c1}#wrapper{max-width:500px;width:100%}.hide-image{display:none}@media screen and (max-width:1000px){*{font-size:4vw}#wrapper{box-sizing:border-box;max-width:100%;padding:0 10px;width:100%}}h2{margin-top:0}.buttons,h2{border:0 solid #000}.buttons{height:25px;margin-bottom:0;width:100%}.button{border:1px solid #000;cursor:pointer;float:left;height:19px;padding:2px;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:100px}.button:focus{outline:2px solid orange}.edit{background-color:blue}.delete{background-color:red}
2
+ /* source-hash: 7a6ecb305ffe4d3fcc2e1cd1647043ccfc7088eda42b61e0d6f9471a334cd0f6 */