@weborigami/origami 0.6.1 → 0.6.2
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/package.json +4 -4
- package/src/dev/crawler/audit.js +3 -7
- package/src/dev/crawler/crawl.js +3 -7
- package/src/dev/crawler/getSiteArgument.js +12 -0
- package/src/dev/help.yaml +3 -0
- package/src/origami/htmlEscape.js +14 -0
- package/src/origami/inline.js +2 -1
- package/src/origami/origami.js +1 -0
- package/src/server/server.js +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weborigami/origami",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"description": "Web Origami language, CLI, framework, and server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"typescript": "5.9.3"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@weborigami/async-tree": "0.6.
|
|
21
|
-
"@weborigami/json-feed-to-rss": "1.0.
|
|
22
|
-
"@weborigami/language": "0.6.
|
|
20
|
+
"@weborigami/async-tree": "0.6.2",
|
|
21
|
+
"@weborigami/json-feed-to-rss": "1.0.1",
|
|
22
|
+
"@weborigami/language": "0.6.2",
|
|
23
23
|
"css-tree": "3.1.0",
|
|
24
24
|
"graphviz-wasm": "3.0.2",
|
|
25
25
|
"highlight.js": "11.11.1",
|
package/src/dev/crawler/audit.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getTreeArgument,
|
|
3
|
-
pathFromKeys,
|
|
4
|
-
symbols,
|
|
5
|
-
Tree,
|
|
6
|
-
} from "@weborigami/async-tree";
|
|
1
|
+
import { pathFromKeys, symbols, Tree } from "@weborigami/async-tree";
|
|
7
2
|
import crawlResources from "./crawlResources.js";
|
|
3
|
+
import getSiteArgument from "./getSiteArgument.js";
|
|
8
4
|
import { getBaseUrl } from "./utilities.js";
|
|
9
5
|
|
|
10
6
|
/**
|
|
@@ -17,7 +13,7 @@ import { getBaseUrl } from "./utilities.js";
|
|
|
17
13
|
* @param {string} [baseHref]
|
|
18
14
|
*/
|
|
19
15
|
export default async function audit(maplike, baseHref) {
|
|
20
|
-
const tree = await
|
|
16
|
+
const tree = await getSiteArgument(maplike, "audit");
|
|
21
17
|
const baseUrl = getBaseUrl(baseHref, maplike);
|
|
22
18
|
|
|
23
19
|
let errors = {};
|
package/src/dev/crawler/crawl.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ObjectMap,
|
|
3
|
-
Tree,
|
|
4
|
-
getTreeArgument,
|
|
5
|
-
keysFromPath,
|
|
6
|
-
} from "@weborigami/async-tree";
|
|
1
|
+
import { ObjectMap, Tree, keysFromPath } from "@weborigami/async-tree";
|
|
7
2
|
import crawlResources from "./crawlResources.js";
|
|
3
|
+
import getSiteArgument from "./getSiteArgument.js";
|
|
8
4
|
import { addValueToObject, getBaseUrl } from "./utilities.js";
|
|
9
5
|
|
|
10
6
|
/**
|
|
@@ -23,7 +19,7 @@ import { addValueToObject, getBaseUrl } from "./utilities.js";
|
|
|
23
19
|
* @returns {Promise<AsyncMap>}
|
|
24
20
|
*/
|
|
25
21
|
export default async function crawlBuiltin(maplike, baseHref) {
|
|
26
|
-
const tree = await
|
|
22
|
+
const tree = await getSiteArgument(maplike, "crawl");
|
|
27
23
|
const baseUrl = getBaseUrl(baseHref, maplike);
|
|
28
24
|
|
|
29
25
|
const cache = {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getTreeArgument, SiteMap } from "@weborigami/async-tree";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Return a site: if it's a tree, return the tree; if it's a string, create a
|
|
5
|
+
* tree for that URL.
|
|
6
|
+
*/
|
|
7
|
+
export default async function getSiteArgument(site, command) {
|
|
8
|
+
if (typeof site === "string") {
|
|
9
|
+
return new SiteMap(site);
|
|
10
|
+
}
|
|
11
|
+
return getTreeArgument(site, command);
|
|
12
|
+
}
|
package/src/dev/help.yaml
CHANGED
|
@@ -68,6 +68,9 @@ Origami:
|
|
|
68
68
|
fetch:
|
|
69
69
|
args: (url, options)
|
|
70
70
|
description: Fetch a resource from a URL with support for extensions
|
|
71
|
+
htmlEscape:
|
|
72
|
+
args: (text)
|
|
73
|
+
description: Escape HTML entities in the text
|
|
71
74
|
image:
|
|
72
75
|
description: Collection of functions for working with images
|
|
73
76
|
indexPage:
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { toString } from "@weborigami/async-tree";
|
|
2
|
+
import loadJsDom from "../common/loadJsDom.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Escapes HTML entities in a string.
|
|
6
|
+
*
|
|
7
|
+
* @param {import("@weborigami/async-tree").Stringlike} html
|
|
8
|
+
*/
|
|
9
|
+
export default async function htmlEscape(html) {
|
|
10
|
+
const { JSDOM } = await loadJsDom();
|
|
11
|
+
const div = JSDOM.fragment("<div></div>").firstChild;
|
|
12
|
+
div.textContent = toString(html);
|
|
13
|
+
return div.innerHTML;
|
|
14
|
+
}
|
package/src/origami/inline.js
CHANGED
|
@@ -9,7 +9,7 @@ import documentObject from "../common/documentObject.js";
|
|
|
9
9
|
*
|
|
10
10
|
* @param {any} input
|
|
11
11
|
*/
|
|
12
|
-
export default async function inline(input) {
|
|
12
|
+
export default async function inline(input, options = {}) {
|
|
13
13
|
// Get the input text and any attached front matter.
|
|
14
14
|
if (isUnpackable(input)) {
|
|
15
15
|
input = await input.unpack();
|
|
@@ -21,6 +21,7 @@ export default async function inline(input) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
const parent =
|
|
24
|
+
options.parent ??
|
|
24
25
|
/** @type {any} */ (input).parent ??
|
|
25
26
|
/** @type {any} */ (input)[symbols.parent];
|
|
26
27
|
|
package/src/origami/origami.js
CHANGED
|
@@ -14,6 +14,7 @@ export { default as static } from "../origami/static.js";
|
|
|
14
14
|
export { default as basename } from "./basename.js";
|
|
15
15
|
export { default as csv } from "./csv.js";
|
|
16
16
|
export { default as fetch } from "./fetch.js";
|
|
17
|
+
export { default as htmlEscape } from "./htmlEscape.js";
|
|
17
18
|
export { default as format } from "./image/format.js";
|
|
18
19
|
export * as image from "./image/image.js";
|
|
19
20
|
export { default as resize } from "./image/resize.js";
|
package/src/server/server.js
CHANGED
|
@@ -121,6 +121,8 @@ export function requestListener(maplike) {
|
|
|
121
121
|
*/
|
|
122
122
|
function respondWithError(response, error) {
|
|
123
123
|
let message = formatError(error);
|
|
124
|
+
// Remove ANSI escape codes from the message.
|
|
125
|
+
message = message.replace(/\x1b\[[0-9;]*m/g, "");
|
|
124
126
|
// Prevent HTML in the error message from being interpreted as HTML.
|
|
125
127
|
message = message.replace(/</g, "<").replace(/>/g, ">");
|
|
126
128
|
const html = `<!DOCTYPE html>
|