@weborigami/origami 0.0.64-beta.2 → 0.0.64
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/exports/exports.js +2 -0
- package/package.json +4 -4
- package/src/builtins/@calendarTree.js +5 -0
- package/src/builtins/@js.js +2 -0
- package/src/builtins/@log.js +16 -0
- package/src/builtins/@mapFn.js +5 -3
- package/src/misc/treeDot.js +11 -10
package/exports/exports.js
CHANGED
|
@@ -4,6 +4,7 @@ export { default as basename } from "../src/builtins/@basename.js";
|
|
|
4
4
|
export { default as breakpoint } from "../src/builtins/@breakpoint.js";
|
|
5
5
|
export { default as builtins } from "../src/builtins/@builtins.js";
|
|
6
6
|
export { default as cache } from "../src/builtins/@cache.js";
|
|
7
|
+
export { default as calendarTree } from "../src/builtins/@calendarTree.js";
|
|
7
8
|
export { default as changes } from "../src/builtins/@changes.js";
|
|
8
9
|
export { default as clean } from "../src/builtins/@clean.js";
|
|
9
10
|
export { default as concat } from "../src/builtins/@concat.js";
|
|
@@ -50,6 +51,7 @@ export { default as jsonParse } from "../src/builtins/@jsonParse.js";
|
|
|
50
51
|
export { default as keys } from "../src/builtins/@keys.js";
|
|
51
52
|
export { default as keysJson } from "../src/builtins/@keysJson.js";
|
|
52
53
|
export { default as length } from "../src/builtins/@length.js";
|
|
54
|
+
export { default as log } from "../src/builtins/@log.js";
|
|
53
55
|
export { default as map } from "../src/builtins/@map.js";
|
|
54
56
|
export { default as mapFn } from "../src/builtins/@mapFn.js";
|
|
55
57
|
export { default as match } from "../src/builtins/@match.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weborigami/origami",
|
|
3
|
-
"version": "0.0.64
|
|
3
|
+
"version": "0.0.64",
|
|
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.5.3"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@weborigami/async-tree": "0.0.64
|
|
21
|
-
"@weborigami/language": "0.0.64
|
|
22
|
-
"@weborigami/types": "0.0.64
|
|
20
|
+
"@weborigami/async-tree": "0.0.64",
|
|
21
|
+
"@weborigami/language": "0.0.64",
|
|
22
|
+
"@weborigami/types": "0.0.64",
|
|
23
23
|
"exif-parser": "0.1.12",
|
|
24
24
|
"graphviz-wasm": "3.0.2",
|
|
25
25
|
"highlight.js": "11.9.0",
|
package/src/builtins/@js.js
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import yaml from "./@yaml.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Log the first argument to the console as a side effect and return the second
|
|
5
|
+
* argument. If no second argument is provided, return the first argument.
|
|
6
|
+
*
|
|
7
|
+
* @this {import("@weborigami/types").AsyncTree|null}
|
|
8
|
+
* @param {any} object
|
|
9
|
+
* @param {any} [result]
|
|
10
|
+
*/
|
|
11
|
+
export default async function log(result, object = result) {
|
|
12
|
+
let text = await yaml.call(this, object);
|
|
13
|
+
text = text?.trim();
|
|
14
|
+
console.log(text);
|
|
15
|
+
return result;
|
|
16
|
+
}
|
package/src/builtins/@mapFn.js
CHANGED
|
@@ -79,13 +79,15 @@ export default function mapFnBuiltin(operation) {
|
|
|
79
79
|
extendedInverseKeyFn = keyFns.inverseKey;
|
|
80
80
|
} else if (keyFn) {
|
|
81
81
|
const resolvedKeyFn = toFunction(keyFn);
|
|
82
|
-
async function scopedKeyFn(sourceKey,
|
|
83
|
-
const sourceValue = await
|
|
82
|
+
async function scopedKeyFn(sourceKey, sourceTree) {
|
|
83
|
+
const sourceValue = await sourceTree.get(sourceKey);
|
|
84
|
+
// The key function will be given the source tree, but will run with the
|
|
85
|
+
// scope of this tree.
|
|
84
86
|
const resultKey = await resolvedKeyFn.call(
|
|
85
87
|
tree,
|
|
86
88
|
sourceValue,
|
|
87
89
|
sourceKey,
|
|
88
|
-
|
|
90
|
+
sourceTree
|
|
89
91
|
);
|
|
90
92
|
return resultKey;
|
|
91
93
|
}
|
package/src/misc/treeDot.js
CHANGED
|
@@ -47,7 +47,7 @@ async function statements(tree, nodePath, nodeLabel, options) {
|
|
|
47
47
|
);
|
|
48
48
|
|
|
49
49
|
// Draw edges and collect labels for the nodes they lead to.
|
|
50
|
-
let nodes =
|
|
50
|
+
let nodes = new Map();
|
|
51
51
|
for (const key of await tree.keys()) {
|
|
52
52
|
const destPath = nodePath ? `${nodePath}/${key}` : key;
|
|
53
53
|
const arc = ` "${nodePath}" -> "${destPath}" [label="${key}"];`;
|
|
@@ -80,27 +80,29 @@ async function statements(tree, nodePath, nodeLabel, options) {
|
|
|
80
80
|
if (value === undefined) {
|
|
81
81
|
isError = true;
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
|
|
84
|
+
const data = { label };
|
|
84
85
|
if (isError) {
|
|
85
|
-
|
|
86
|
+
data.isError = true;
|
|
86
87
|
}
|
|
88
|
+
nodes.set(key, data);
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
|
|
90
92
|
// If we have more than one label, we'll focus on the labels' differences.
|
|
91
93
|
// We'll use the first label as a representative baseline for all labels but
|
|
92
94
|
// the first (which will use the second label as a baseline).
|
|
93
|
-
const values =
|
|
95
|
+
const values = [...nodes.values()];
|
|
94
96
|
const showLabelDiffs = values.length > 1;
|
|
95
97
|
const label1 = showLabelDiffs ? String(values[0].label) : undefined;
|
|
96
98
|
const label2 = showLabelDiffs ? String(values[1].label) : undefined;
|
|
97
99
|
|
|
98
100
|
// Trim labels.
|
|
99
101
|
let i = 0;
|
|
100
|
-
for (const
|
|
101
|
-
let label =
|
|
102
|
+
for (const data of nodes.values()) {
|
|
103
|
+
let label = data.label;
|
|
102
104
|
if (label === null) {
|
|
103
|
-
|
|
105
|
+
data.label = "[binary data]";
|
|
104
106
|
} else if (label) {
|
|
105
107
|
let clippedStart = false;
|
|
106
108
|
let clippedEnd = false;
|
|
@@ -146,14 +148,13 @@ async function statements(tree, nodePath, nodeLabel, options) {
|
|
|
146
148
|
label += "\\l";
|
|
147
149
|
}
|
|
148
150
|
|
|
149
|
-
|
|
151
|
+
data.label = label;
|
|
150
152
|
}
|
|
151
153
|
i++;
|
|
152
154
|
}
|
|
153
155
|
|
|
154
156
|
// Draw labels.
|
|
155
|
-
for (const key
|
|
156
|
-
const node = nodes[key];
|
|
157
|
+
for (const [key, node] of nodes.entries()) {
|
|
157
158
|
const icon = node.isError ? "⚠️ " : "";
|
|
158
159
|
// GraphViz has trouble rendering DOT nodes whose labels contain ellipsis
|
|
159
160
|
// characters, so we map those to three periods. GraphViz appears to turn
|