@weborigami/origami 0.6.4 → 0.6.6
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/main.js +1 -0
- package/package.json +3 -3
- package/src/cli/cli.js +5 -5
- package/src/dev/help.yaml +2 -2
- package/src/origami/ori.js +1 -2
- package/src/origami/origami.js +1 -0
- package/src/origami/project.js +4 -1
- package/src/origami/projectRoot.js +3 -0
- package/src/server/constructResponse.js +4 -3
- package/src/server/server.js +3 -3
package/main.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { default as documentObject } from "./src/common/documentObject.js";
|
|
2
2
|
export * as Dev from "./src/dev/dev.js";
|
|
3
|
+
export { default as initializeBuiltins } from "./src/initializeBuiltins.js";
|
|
3
4
|
export * as Origami from "./src/origami/origami.js";
|
|
4
5
|
export { default as origamiHighlightDefinition } from "./src/origami/origamiHighlightDefinition.js";
|
|
5
6
|
export { default as constructResponse } from "./src/server/constructResponse.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weborigami/origami",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.6",
|
|
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.
|
|
20
|
+
"@weborigami/async-tree": "0.6.6",
|
|
21
21
|
"@weborigami/json-feed-to-rss": "1.0.1",
|
|
22
|
-
"@weborigami/language": "0.6.
|
|
22
|
+
"@weborigami/language": "0.6.6",
|
|
23
23
|
"css-tree": "3.1.0",
|
|
24
24
|
"graphviz-wasm": "3.0.2",
|
|
25
25
|
"highlight.js": "11.11.1",
|
package/src/cli/cli.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { Tree } from "@weborigami/async-tree";
|
|
4
|
-
import { formatError,
|
|
4
|
+
import { formatError, projectRootFromPath } from "@weborigami/language";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import process, { stdout } from "node:process";
|
|
7
7
|
import help from "../dev/help.js";
|
|
@@ -18,7 +18,8 @@ async function main(...args) {
|
|
|
18
18
|
initializeBuiltins();
|
|
19
19
|
|
|
20
20
|
// Find the project root.
|
|
21
|
-
const
|
|
21
|
+
const currentDirectory = process.cwd();
|
|
22
|
+
const projectRoot = await projectRootFromPath(currentDirectory);
|
|
22
23
|
|
|
23
24
|
// If no arguments were passed, show usage.
|
|
24
25
|
if (!expression) {
|
|
@@ -28,9 +29,8 @@ async function main(...args) {
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
// Traverse from the project root to the current directory.
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const parent = await Tree.traversePath(projectTree, relative);
|
|
32
|
+
const relative = path.relative(projectRoot.path, currentDirectory);
|
|
33
|
+
const parent = await Tree.traversePath(projectRoot, relative);
|
|
34
34
|
|
|
35
35
|
const result = await ori(expression, { parent });
|
|
36
36
|
|
package/src/dev/help.yaml
CHANGED
|
@@ -5,8 +5,8 @@ Dev:
|
|
|
5
5
|
args: (tree)
|
|
6
6
|
description: Identify broken internal links and references
|
|
7
7
|
breakpoint:
|
|
8
|
-
args: (
|
|
9
|
-
description: Break into the JavaScript debugger, then return
|
|
8
|
+
args: (arg)
|
|
9
|
+
description: Break into the JavaScript debugger, then return arg
|
|
10
10
|
changes:
|
|
11
11
|
args: (old, new)
|
|
12
12
|
description: Return a tree of changes
|
package/src/origami/ori.js
CHANGED
|
@@ -4,8 +4,7 @@ import {
|
|
|
4
4
|
isStringlike,
|
|
5
5
|
toString,
|
|
6
6
|
} from "@weborigami/async-tree";
|
|
7
|
-
import { compile } from "@weborigami/language";
|
|
8
|
-
import projectGlobals from "@weborigami/language/src/project/projectGlobals.js";
|
|
7
|
+
import { compile, projectGlobals } from "@weborigami/language";
|
|
9
8
|
import { toYaml } from "../common/serialize.js";
|
|
10
9
|
import * as dev from "../dev/dev.js";
|
|
11
10
|
|
package/src/origami/origami.js
CHANGED
|
@@ -27,6 +27,7 @@ export { default as ori } from "./ori.js";
|
|
|
27
27
|
export { default as pack } from "./pack.js";
|
|
28
28
|
export { default as post } from "./post.js";
|
|
29
29
|
export { default as project } from "./project.js";
|
|
30
|
+
export { default as projectRoot } from "./projectRoot.js";
|
|
30
31
|
export { default as repeat } from "./repeat.js";
|
|
31
32
|
export { default as shell } from "./shell.js";
|
|
32
33
|
export { default as slash } from "./slash.js";
|
package/src/origami/project.js
CHANGED
|
@@ -28,7 +28,7 @@ export default async function constructResponse(request, resource) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
// Determine media type, what data we'll send, and encoding.
|
|
31
|
-
const url = new URL(request
|
|
31
|
+
const url = new URL(request?.url ?? "", `https://${request?.headers.host}`);
|
|
32
32
|
|
|
33
33
|
if (!url.pathname.endsWith("/") && Tree.isMaplike(resource)) {
|
|
34
34
|
// Maplike resource: redirect to its index page.
|
|
@@ -89,6 +89,7 @@ export default async function constructResponse(request, resource) {
|
|
|
89
89
|
const text = toString(resource);
|
|
90
90
|
if (text) {
|
|
91
91
|
mediaType = maybeHtml(text) ? "text/html" : "text/plain";
|
|
92
|
+
mediaType += "; charset=utf-8";
|
|
92
93
|
body = text;
|
|
93
94
|
}
|
|
94
95
|
} else if (mediaType && SiteMap.mediaTypeIsText(mediaType)) {
|
|
@@ -125,9 +126,9 @@ function maybeHtml(text) {
|
|
|
125
126
|
// - start with possible whitespace
|
|
126
127
|
// - followed by '<'
|
|
127
128
|
// - followed by a letter
|
|
128
|
-
// - followed by letters, digits, hyphens, underscores, colons, or periods
|
|
129
|
+
// - followed maybe by letters, digits, hyphens, underscores, colons, or periods
|
|
129
130
|
// - followed by '>', or
|
|
130
131
|
// - followed by whitespace, anything that's not '>', then a '>'
|
|
131
|
-
const tagRegex = /^\s*<[a-zA-Z][a-zA-Z0-9-_:\.]
|
|
132
|
+
const tagRegex = /^\s*<[a-zA-Z][a-zA-Z0-9-_:\.]*(>|[\s]+[^>]*>)/;
|
|
132
133
|
return tagRegex.test(text);
|
|
133
134
|
}
|
package/src/server/server.js
CHANGED
|
@@ -80,7 +80,7 @@ export async function handleRequest(request, response, map) {
|
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
function keysFromUrl(url) {
|
|
83
|
+
export function keysFromUrl(url) {
|
|
84
84
|
const encodedKeys = keysFromPath(url.pathname);
|
|
85
85
|
const keys = encodedKeys.map((key) => decodeURIComponent(key));
|
|
86
86
|
|
|
@@ -119,7 +119,7 @@ export function requestListener(maplike) {
|
|
|
119
119
|
* Construct a page in response in the given error, and also show the error in
|
|
120
120
|
* the console.
|
|
121
121
|
*/
|
|
122
|
-
function respondWithError(response, error) {
|
|
122
|
+
export function respondWithError(response, error) {
|
|
123
123
|
let message = formatError(error);
|
|
124
124
|
// Remove ANSI escape codes from the message.
|
|
125
125
|
message = message.replace(/\x1b\[[0-9;]*m/g, "");
|
|
@@ -138,7 +138,7 @@ ${message}
|
|
|
138
138
|
</body>
|
|
139
139
|
</html>
|
|
140
140
|
`;
|
|
141
|
-
response.writeHead(
|
|
141
|
+
response.writeHead(500, { "Content-Type": "text/html" });
|
|
142
142
|
response.end(html, "utf-8");
|
|
143
143
|
console.error(message);
|
|
144
144
|
}
|