@weborigami/origami 0.0.41 → 0.0.43
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/buildExports.js +1 -1
- package/exports/exports.js +32 -34
- package/package.json +4 -4
- package/src/builtins/@arrows.js +1 -1
- package/src/builtins/@builtins.js +2 -5
- package/src/builtins/@cache.js +1 -1
- package/src/builtins/{@tree/concat.js → @concat.js} +3 -3
- package/src/builtins/@copy.js +2 -2
- package/src/builtins/{@tree/count.js → @count.js} +3 -3
- package/src/builtins/@crawl.js +1 -1
- package/src/builtins/@debug.js +1 -1
- package/src/builtins/{@tree/defineds.js → @defineds.js} +2 -2
- package/src/builtins/@document.js +1 -1
- package/src/builtins/{@tree/exceptions.js → @exceptions.js} +4 -4
- package/src/builtins/@explore.js +2 -5
- package/src/builtins/@files.js +1 -1
- package/src/builtins/@filter.js +1 -1
- package/src/builtins/{@tree/first.js → @first.js} +3 -3
- package/src/builtins/{@tree/fn.js → @fnTree.js} +7 -7
- package/src/builtins/@globs.js +1 -1
- package/src/builtins/{@tree/groupBy.js → @groupBy.js} +6 -6
- package/src/builtins/@help.js +1 -1
- package/src/builtins/@http.js +1 -1
- package/src/builtins/@https.js +1 -1
- package/src/builtins/@if.js +1 -1
- package/src/builtins/@image/format.js +36 -2
- package/src/builtins/@image/resize.js +32 -2
- package/src/builtins/@index.js +1 -1
- package/src/builtins/@inherited.js +1 -1
- package/src/builtins/@inline.js +2 -2
- package/src/builtins/{@tree/inners.js → @inners.js} +3 -3
- package/src/builtins/@invoke.js +1 -1
- package/src/builtins/{@tree/isAsyncTree.js → @isAsyncTree.js} +1 -1
- package/src/builtins/@json.js +1 -1
- package/src/builtins/{@tree/keys.js → @keys.js} +3 -3
- package/src/builtins/{@tree/keysJson.js → @keysJson.js} +3 -3
- package/src/builtins/@loaders/ori.js +18 -18
- package/src/builtins/@map.js +13 -1
- package/src/builtins/@match.js +1 -1
- package/src/builtins/{@tree/merge.js → @merge.js} +2 -2
- package/src/builtins/{@tree/mergeDeep.js → @mergeDeep.js} +3 -3
- package/src/builtins/@once.js +1 -1
- package/src/builtins/@ori.js +1 -1
- package/src/builtins/@pack.js +1 -1
- package/src/builtins/{@tree/parent.js → @parent.js} +3 -3
- package/src/builtins/{@tree/paths.js → @paths.js} +3 -3
- package/src/builtins/@perf.js +18 -0
- package/src/builtins/{@tree/plain.js → @plain.js} +3 -3
- package/src/builtins/@project.js +1 -1
- package/src/builtins/@redirect.js +8 -0
- package/src/builtins/{@tree/reverse.js → @reverse.js} +3 -3
- package/src/builtins/@rss.js +1 -1
- package/src/builtins/@scope/extend.js +6 -6
- package/src/builtins/@scope/get.js +1 -1
- package/src/builtins/@scope/set.js +4 -4
- package/src/builtins/@serve.js +1 -1
- package/src/builtins/{@tree/setDeep.js → @setDeep.js} +1 -1
- package/src/builtins/{@tree/shuffle.js → @shuffle.js} +5 -5
- package/src/builtins/{@tree/sitemap.js → @sitemap.js} +8 -8
- package/src/builtins/{@tree/sort.js → @sort.js} +4 -4
- package/src/builtins/{@tree/sortBy.js → @sortBy.js} +6 -6
- package/src/builtins/{@tree/static.js → @static.js} +5 -5
- package/src/builtins/@svg.js +2 -2
- package/src/builtins/{@tree/table.js → @table.js} +3 -3
- package/src/builtins/{@tree/take.js → @take.js} +3 -3
- package/src/builtins/{@tree/from.js → @tree.js} +3 -3
- package/src/builtins/@treeHttp.js +1 -1
- package/src/builtins/@treeHttps.js +1 -1
- package/src/builtins/@unpack.js +1 -1
- package/src/builtins/{@tree/values.js → @values.js} +3 -3
- package/src/builtins/{@tree/valuesDeep.js → @valuesDeep.js} +3 -3
- package/src/builtins/@watch.js +1 -1
- package/src/builtins/@with.js +1 -1
- package/src/builtins/@yaml.js +1 -1
- package/src/builtins/{@tree/map.d.ts → map.d.ts} +1 -1
- package/src/cli/cli.js +2 -15
- package/src/common/ExplorableSiteTransform.js +6 -4
- package/src/misc/assertScopeIsDefined.js +2 -2
- package/src/misc/explore.ori +4 -4
- package/src/misc/getTreeArgument.js +16 -6
- package/src/{builtins/@tree/dot.js → misc/treeDot.js} +8 -8
- package/src/server/constructResponse.js +126 -0
- package/src/server/mediaTypes.js +0 -16
- package/src/server/server.js +62 -131
- package/src/builtins/@tree/flowSvg.js +0 -55
- package/src/builtins/@tree/fromJson.js +0 -6
- package/src/builtins/@tree/fromYaml.js +0 -24
- package/src/builtins/@tree/nextKey.js +0 -29
- package/src/builtins/@tree/previousKey.js +0 -29
package/exports/buildExports.js
CHANGED
|
@@ -15,7 +15,7 @@ const specialBuiltinNames = {
|
|
|
15
15
|
|
|
16
16
|
// Top-level template for the export file
|
|
17
17
|
const templateText = `=\`// This file is generated by running buildExports.js -- do not edit by hand.
|
|
18
|
-
{
|
|
18
|
+
\${ _ }\``;
|
|
19
19
|
|
|
20
20
|
// Generate a top-level export file for the entire project. For each .js file in
|
|
21
21
|
// the given source tree, generate an appropriate statement that includes that
|
package/exports/exports.js
CHANGED
|
@@ -4,17 +4,24 @@ export { default as arrows } from "../src/builtins/@arrows.js";
|
|
|
4
4
|
export { default as basename } from "../src/builtins/@basename.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 concat } from "../src/builtins/@concat.js";
|
|
7
8
|
export { default as config } from "../src/builtins/@config.js";
|
|
8
9
|
export { default as copy } from "../src/builtins/@copy.js";
|
|
10
|
+
export { default as count } from "../src/builtins/@count.js";
|
|
9
11
|
export { default as crawl } from "../src/builtins/@crawl.js";
|
|
10
12
|
export { default as debug } from "../src/builtins/@debug.js";
|
|
13
|
+
export { default as defineds } from "../src/builtins/@defineds.js";
|
|
11
14
|
export { default as document } from "../src/builtins/@document.js";
|
|
12
15
|
export { default as equals } from "../src/builtins/@equals.js";
|
|
16
|
+
export { default as exceptions } from "../src/builtins/@exceptions.js";
|
|
13
17
|
export { default as explore } from "../src/builtins/@explore.js";
|
|
14
18
|
export { default as fetch } from "../src/builtins/@fetch.js";
|
|
15
19
|
export { default as files } from "../src/builtins/@files.js";
|
|
16
20
|
export { default as filter } from "../src/builtins/@filter.js";
|
|
21
|
+
export { default as first } from "../src/builtins/@first.js";
|
|
22
|
+
export { default as fnTree } from "../src/builtins/@fnTree.js";
|
|
17
23
|
export { default as globs } from "../src/builtins/@globs.js";
|
|
24
|
+
export { default as groupBy } from "../src/builtins/@groupBy.js";
|
|
18
25
|
export { default as help } from "../src/builtins/@help.js";
|
|
19
26
|
export { default as http } from "../src/builtins/@http.js";
|
|
20
27
|
export { default as https } from "../src/builtins/@https.js";
|
|
@@ -24,9 +31,13 @@ export { default as imageResize } from "../src/builtins/@image/resize.js";
|
|
|
24
31
|
export { default as index } from "../src/builtins/@index.js";
|
|
25
32
|
export { default as inherited } from "../src/builtins/@inherited.js";
|
|
26
33
|
export { default as inline } from "../src/builtins/@inline.js";
|
|
34
|
+
export { default as inners } from "../src/builtins/@inners.js";
|
|
27
35
|
export { default as invoke } from "../src/builtins/@invoke.js";
|
|
36
|
+
export { default as isAsyncTree } from "../src/builtins/@isAsyncTree.js";
|
|
28
37
|
export { default as js } from "../src/builtins/@js.js";
|
|
29
38
|
export { default as json } from "../src/builtins/@json.js";
|
|
39
|
+
export { default as keys } from "../src/builtins/@keys.js";
|
|
40
|
+
export { default as keysJson } from "../src/builtins/@keysJson.js";
|
|
30
41
|
export { default as loadersCss } from "../src/builtins/@loaders/css.js";
|
|
31
42
|
export { default as loadersHtm } from "../src/builtins/@loaders/htm.js";
|
|
32
43
|
export { default as loadersHtml } from "../src/builtins/@loaders/html.js";
|
|
@@ -43,6 +54,8 @@ export { default as map } from "../src/builtins/@map.js";
|
|
|
43
54
|
export { default as mapDeep } from "../src/builtins/@mapDeep.js";
|
|
44
55
|
export { default as match } from "../src/builtins/@match.js";
|
|
45
56
|
export { default as mdHtml } from "../src/builtins/@mdHtml.js";
|
|
57
|
+
export { default as merge } from "../src/builtins/@merge.js";
|
|
58
|
+
export { default as mergeDeep } from "../src/builtins/@mergeDeep.js";
|
|
46
59
|
export { default as node } from "../src/builtins/@node.js";
|
|
47
60
|
export { default as not } from "../src/builtins/@not.js";
|
|
48
61
|
export { default as once } from "../src/builtins/@once.js";
|
|
@@ -50,56 +63,39 @@ export { default as or } from "../src/builtins/@or.js";
|
|
|
50
63
|
export { default as ori } from "../src/builtins/@ori.js";
|
|
51
64
|
export { default as pack } from "../src/builtins/@pack.js";
|
|
52
65
|
export { default as package } from "../src/builtins/@package.js";
|
|
66
|
+
export { default as parent } from "../src/builtins/@parent.js";
|
|
53
67
|
export { default as parseJson } from "../src/builtins/@parse/json.js";
|
|
54
68
|
export { default as parseYaml } from "../src/builtins/@parse/yaml.js";
|
|
69
|
+
export { default as paths } from "../src/builtins/@paths.js";
|
|
70
|
+
export { default as perf } from "../src/builtins/@perf.js";
|
|
71
|
+
export { default as plain } from "../src/builtins/@plain.js";
|
|
55
72
|
export { default as project } from "../src/builtins/@project.js";
|
|
73
|
+
export { default as redirect } from "../src/builtins/@redirect.js";
|
|
56
74
|
export { default as repeat } from "../src/builtins/@repeat.js";
|
|
75
|
+
export { default as reverse } from "../src/builtins/@reverse.js";
|
|
57
76
|
export { default as rss } from "../src/builtins/@rss.js";
|
|
58
77
|
export { default as scopeExtend } from "../src/builtins/@scope/extend.js";
|
|
59
78
|
export { default as scopeGet } from "../src/builtins/@scope/get.js";
|
|
60
79
|
export { default as scopeInvoke } from "../src/builtins/@scope/invoke.js";
|
|
61
80
|
export { default as scopeSet } from "../src/builtins/@scope/set.js";
|
|
62
81
|
export { default as serve } from "../src/builtins/@serve.js";
|
|
82
|
+
export { default as setDeep } from "../src/builtins/@setDeep.js";
|
|
63
83
|
export { default as shell } from "../src/builtins/@shell.js";
|
|
84
|
+
export { default as shuffle } from "../src/builtins/@shuffle.js";
|
|
85
|
+
export { default as sitemap } from "../src/builtins/@sitemap.js";
|
|
86
|
+
export { default as sort } from "../src/builtins/@sort.js";
|
|
87
|
+
export { default as sortBy } from "../src/builtins/@sortBy.js";
|
|
88
|
+
export { default as static } from "../src/builtins/@static.js";
|
|
64
89
|
export { default as stdin } from "../src/builtins/@stdin.js";
|
|
65
90
|
export { default as svg } from "../src/builtins/@svg.js";
|
|
66
|
-
export { default as
|
|
67
|
-
export { default as
|
|
68
|
-
export { default as
|
|
69
|
-
export { default as treeDot } from "../src/builtins/@tree/dot.js";
|
|
70
|
-
export { default as treeExceptions } from "../src/builtins/@tree/exceptions.js";
|
|
71
|
-
export { default as treeFirst } from "../src/builtins/@tree/first.js";
|
|
72
|
-
export { default as treeFlowSvg } from "../src/builtins/@tree/flowSvg.js";
|
|
73
|
-
export { default as treeFn } from "../src/builtins/@tree/fn.js";
|
|
74
|
-
export { default as treeFrom } from "../src/builtins/@tree/from.js";
|
|
75
|
-
export { default as treeFromJson } from "../src/builtins/@tree/fromJson.js";
|
|
76
|
-
export { default as treeFromYaml } from "../src/builtins/@tree/fromYaml.js";
|
|
77
|
-
export { default as treeGroupBy } from "../src/builtins/@tree/groupBy.js";
|
|
78
|
-
export { default as treeInners } from "../src/builtins/@tree/inners.js";
|
|
79
|
-
export { default as treeIsAsyncTree } from "../src/builtins/@tree/isAsyncTree.js";
|
|
80
|
-
export { default as treeKeys } from "../src/builtins/@tree/keys.js";
|
|
81
|
-
export { default as treeKeysJson } from "../src/builtins/@tree/keysJson.js";
|
|
82
|
-
export { default as treeMerge } from "../src/builtins/@tree/merge.js";
|
|
83
|
-
export { default as treeMergeDeep } from "../src/builtins/@tree/mergeDeep.js";
|
|
84
|
-
export { default as treeNextKey } from "../src/builtins/@tree/nextKey.js";
|
|
85
|
-
export { default as treeParent } from "../src/builtins/@tree/parent.js";
|
|
86
|
-
export { default as treePaths } from "../src/builtins/@tree/paths.js";
|
|
87
|
-
export { default as treePlain } from "../src/builtins/@tree/plain.js";
|
|
88
|
-
export { default as treePreviousKey } from "../src/builtins/@tree/previousKey.js";
|
|
89
|
-
export { default as treeReverse } from "../src/builtins/@tree/reverse.js";
|
|
90
|
-
export { default as treeSetDeep } from "../src/builtins/@tree/setDeep.js";
|
|
91
|
-
export { default as treeShuffle } from "../src/builtins/@tree/shuffle.js";
|
|
92
|
-
export { default as treeSitemap } from "../src/builtins/@tree/sitemap.js";
|
|
93
|
-
export { default as treeSort } from "../src/builtins/@tree/sort.js";
|
|
94
|
-
export { default as treeSortBy } from "../src/builtins/@tree/sortBy.js";
|
|
95
|
-
export { default as treeStatic } from "../src/builtins/@tree/static.js";
|
|
96
|
-
export { default as treeTable } from "../src/builtins/@tree/table.js";
|
|
97
|
-
export { default as treeTake } from "../src/builtins/@tree/take.js";
|
|
98
|
-
export { default as treeValues } from "../src/builtins/@tree/values.js";
|
|
99
|
-
export { default as treeValuesDeep } from "../src/builtins/@tree/valuesDeep.js";
|
|
91
|
+
export { default as table } from "../src/builtins/@table.js";
|
|
92
|
+
export { default as take } from "../src/builtins/@take.js";
|
|
93
|
+
export { default as tree } from "../src/builtins/@tree.js";
|
|
100
94
|
export { default as treeHttp } from "../src/builtins/@treeHttp.js";
|
|
101
95
|
export { default as treeHttps } from "../src/builtins/@treeHttps.js";
|
|
102
96
|
export { default as unpack } from "../src/builtins/@unpack.js";
|
|
97
|
+
export { default as values } from "../src/builtins/@values.js";
|
|
98
|
+
export { default as valuesDeep } from "../src/builtins/@valuesDeep.js";
|
|
103
99
|
export { default as watch } from "../src/builtins/@watch.js";
|
|
104
100
|
export { default as with } from "../src/builtins/@with.js";
|
|
105
101
|
export { default as yaml } from "../src/builtins/@yaml.js";
|
|
@@ -121,6 +117,8 @@ export * from "../src/common/utilities.js";
|
|
|
121
117
|
export { default as assertScopeIsDefined } from "../src/misc/assertScopeIsDefined.js";
|
|
122
118
|
export { default as getTreeArgument } from "../src/misc/getTreeArgument.js";
|
|
123
119
|
export { default as OriCommandTransform } from "../src/misc/OriCommandTransform.js";
|
|
120
|
+
export { default as treeDot } from "../src/misc/treeDot.js";
|
|
124
121
|
export { default as yamlOrigamiTag } from "../src/misc/yamlOrigamiTag.js";
|
|
122
|
+
export { default as constructResponse } from "../src/server/constructResponse.js";
|
|
125
123
|
export * from "../src/server/mediaTypes.js";
|
|
126
124
|
export * from "../src/server/server.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weborigami/origami",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.43",
|
|
4
4
|
"description": "Web Origami language, CLI, framework, and server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"typescript": "5.3.3"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@weborigami/async-tree": "0.0.
|
|
23
|
-
"@weborigami/language": "0.0.
|
|
24
|
-
"@weborigami/types": "0.0.
|
|
22
|
+
"@weborigami/async-tree": "0.0.43",
|
|
23
|
+
"@weborigami/language": "0.0.43",
|
|
24
|
+
"@weborigami/types": "0.0.43",
|
|
25
25
|
"graphviz-wasm": "3.0.1",
|
|
26
26
|
"highlight.js": "11.9.0",
|
|
27
27
|
"marked": "11.1.1",
|
package/src/builtins/@arrows.js
CHANGED
|
@@ -13,7 +13,7 @@ import getTreeArgument from "../misc/getTreeArgument.js";
|
|
|
13
13
|
* @param {Treelike} [treelike]
|
|
14
14
|
*/
|
|
15
15
|
export default async function arrows(treelike) {
|
|
16
|
-
const tree = await getTreeArgument(this, arguments, treelike);
|
|
16
|
+
const tree = await getTreeArgument(this, arguments, treelike, "@arrows");
|
|
17
17
|
const mapped = functionResultsMap(arrowFunctionsMap()(tree));
|
|
18
18
|
const scope = this ?? builtins;
|
|
19
19
|
const scoped = Scope.treeWithScope(mapped, scope);
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { FileTree } from "@weborigami/async-tree";
|
|
2
2
|
import { ImportModulesMixin } from "@weborigami/language";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { fileURLToPath } from "node:url";
|
|
5
3
|
import CommandModulesTransform from "../common/CommandModulesTransform.js";
|
|
6
4
|
|
|
7
|
-
const
|
|
8
|
-
const commandsFolder = path.resolve(dirname, "../builtins");
|
|
5
|
+
const commandsUrl = new URL("../builtins", import.meta.url);
|
|
9
6
|
|
|
10
7
|
/** @type {any} */
|
|
11
8
|
const builtins = new (CommandModulesTransform(ImportModulesMixin(FileTree)))(
|
|
12
|
-
|
|
9
|
+
commandsUrl
|
|
13
10
|
);
|
|
14
11
|
|
|
15
12
|
builtins.usage = `@builtins\tThe Tree Origami built-in functions`;
|
package/src/builtins/@cache.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Tree } from "@weborigami/async-tree";
|
|
2
2
|
import { ops } from "@weborigami/language";
|
|
3
|
-
import assertScopeIsDefined from "
|
|
3
|
+
import assertScopeIsDefined from "../misc/assertScopeIsDefined.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Concatenate the text content of objects or trees.
|
|
@@ -11,11 +11,11 @@ import assertScopeIsDefined from "../../misc/assertScopeIsDefined.js";
|
|
|
11
11
|
* @param {any[]} args
|
|
12
12
|
*/
|
|
13
13
|
export default async function concat(...args) {
|
|
14
|
-
assertScopeIsDefined(this);
|
|
14
|
+
assertScopeIsDefined(this, "concat");
|
|
15
15
|
const tree =
|
|
16
16
|
args.length === 0 ? await this?.get("@current") : Tree.from(args);
|
|
17
17
|
return ops.concat.call(this, tree);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
concat.usage =
|
|
20
|
+
concat.usage = `@concat <...objs>\tConcatenate text and/or trees of text`;
|
|
21
21
|
concat.documentation = "https://weborigami.org/cli/@tree.html#concat";
|
package/src/builtins/@copy.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Tree } from "@weborigami/async-tree";
|
|
|
2
2
|
import process, { stdout } from "node:process";
|
|
3
3
|
import { transformObject } from "../common/utilities.js";
|
|
4
4
|
import assertScopeIsDefined from "../misc/assertScopeIsDefined.js";
|
|
5
|
-
import setDeep from "./@
|
|
5
|
+
import setDeep from "./@setDeep.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @typedef {import("@weborigami/types").AsyncTree} AsyncTree
|
|
@@ -13,7 +13,7 @@ import setDeep from "./@tree/setDeep.js";
|
|
|
13
13
|
* @param {Treelike} target
|
|
14
14
|
*/
|
|
15
15
|
export default async function copy(source, target) {
|
|
16
|
-
assertScopeIsDefined(this);
|
|
16
|
+
assertScopeIsDefined(this, "copy");
|
|
17
17
|
// const start = performance.now();
|
|
18
18
|
const sourceTree = Tree.from(source);
|
|
19
19
|
/** @type {any} */ let targetTree = Tree.from(target);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import getTreeArgument from "
|
|
1
|
+
import getTreeArgument from "../misc/getTreeArgument.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Return the number of keys in the tree.
|
|
@@ -9,10 +9,10 @@ import getTreeArgument from "../../misc/getTreeArgument.js";
|
|
|
9
9
|
* @param {Treelike} [treelike]
|
|
10
10
|
*/
|
|
11
11
|
export default async function count(treelike) {
|
|
12
|
-
const tree = await getTreeArgument(this, arguments, treelike);
|
|
12
|
+
const tree = await getTreeArgument(this, arguments, treelike, "@count");
|
|
13
13
|
const keys = [...(await tree.keys())];
|
|
14
14
|
return keys.length;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
count.usage =
|
|
17
|
+
count.usage = `@count <treelike>\tReturn the number of keys in the tree`;
|
|
18
18
|
count.documentation = "https://weborigami.org/cli/@tree.html#count";
|
package/src/builtins/@crawl.js
CHANGED
|
@@ -30,7 +30,7 @@ const fakeBaseUrl = new URL("https://fake");
|
|
|
30
30
|
* @returns {Promise<AsyncTree>}
|
|
31
31
|
*/
|
|
32
32
|
export default async function crawl(treelike, baseHref) {
|
|
33
|
-
assertScopeIsDefined(this);
|
|
33
|
+
assertScopeIsDefined(this, "crawl");
|
|
34
34
|
const tree =
|
|
35
35
|
typeof treelike === "string"
|
|
36
36
|
? treeHttps.call(this, treelike)
|
package/src/builtins/@debug.js
CHANGED
|
@@ -16,7 +16,7 @@ import getTreeArgument from "../misc/getTreeArgument.js";
|
|
|
16
16
|
export default async function debug(treelike) {
|
|
17
17
|
// The debug command leaves the tree's existing scope intact; it does not
|
|
18
18
|
// apply its own scope to the tree.
|
|
19
|
-
let tree = await getTreeArgument(this, arguments, treelike);
|
|
19
|
+
let tree = await getTreeArgument(this, arguments, treelike, "@debug");
|
|
20
20
|
|
|
21
21
|
if (!isTransformApplied(ExplorableSiteTransform, tree)) {
|
|
22
22
|
tree = transformObject(ExplorableSiteTransform, tree);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Tree } from "@weborigami/async-tree";
|
|
2
2
|
import { Scope } from "@weborigami/language";
|
|
3
|
-
import getTreeArgument from "
|
|
3
|
+
import getTreeArgument from "../misc/getTreeArgument.js";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Return only the defined (not `undefined`) values in the tree.
|
|
@@ -12,7 +12,7 @@ import getTreeArgument from "../../misc/getTreeArgument.js";
|
|
|
12
12
|
* @param {Treelike} treelike
|
|
13
13
|
*/
|
|
14
14
|
export default async function defineds(treelike) {
|
|
15
|
-
const tree = await getTreeArgument(this, arguments, treelike);
|
|
15
|
+
const tree = await getTreeArgument(this, arguments, treelike, "@defineds");
|
|
16
16
|
|
|
17
17
|
/** @type {AsyncTree} */
|
|
18
18
|
let result = await Tree.mapReduce(tree, null, async (values, keys) => {
|
|
@@ -12,7 +12,7 @@ import assertScopeIsDefined from "../misc/assertScopeIsDefined.js";
|
|
|
12
12
|
* @returns
|
|
13
13
|
*/
|
|
14
14
|
export default function document(text, data, parent) {
|
|
15
|
-
assertScopeIsDefined(this);
|
|
15
|
+
assertScopeIsDefined(this, "document");
|
|
16
16
|
const merged = Object.assign({}, data, { "@text": text });
|
|
17
17
|
return new TextDocument(merged, parent ?? this);
|
|
18
18
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Tree } from "@weborigami/async-tree";
|
|
2
2
|
import { Scope } from "@weborigami/language";
|
|
3
|
-
import getTreeArgument from "
|
|
4
|
-
import defineds from "
|
|
3
|
+
import getTreeArgument from "../misc/getTreeArgument.js";
|
|
4
|
+
import defineds from "./@defineds.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {import("@weborigami/types").AsyncTree} AsyncTree
|
|
@@ -10,7 +10,7 @@ import defineds from "./defineds.js";
|
|
|
10
10
|
* @param {Treelike} treelike
|
|
11
11
|
*/
|
|
12
12
|
export default async function exceptions(treelike) {
|
|
13
|
-
const tree = await getTreeArgument(this, arguments, treelike);
|
|
13
|
+
const tree = await getTreeArgument(this, arguments, treelike, "@exceptions");
|
|
14
14
|
|
|
15
15
|
/** @type {AsyncTree} */
|
|
16
16
|
let exceptionsTree = new ExceptionsTree(tree);
|
|
@@ -44,6 +44,6 @@ class ExceptionsTree {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
exceptions.usage =
|
|
47
|
+
exceptions.usage = `@exceptions tree\tReturn a tree of exceptions thrown in the tree`;
|
|
48
48
|
exceptions.documentation =
|
|
49
49
|
"https://weborigami.org/cli/builtins.html#exceptions";
|
package/src/builtins/@explore.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
/** @typedef {import("@weborigami/types").AsyncTree} AsyncTree */
|
|
2
2
|
import { ObjectTree, Tree } from "@weborigami/async-tree";
|
|
3
3
|
import { OrigamiFiles, Scope } from "@weborigami/language";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
4
|
import builtins from "../builtins/@builtins.js";
|
|
7
5
|
import { keySymbol } from "../common/utilities.js";
|
|
8
6
|
import debug from "./@debug.js";
|
|
9
7
|
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const miscFiles = Scope.treeWithScope(new OrigamiFiles(miscDir), builtins);
|
|
8
|
+
const miscUrl = new URL("../misc", import.meta.url);
|
|
9
|
+
const miscFiles = Scope.treeWithScope(new OrigamiFiles(miscUrl), builtins);
|
|
13
10
|
|
|
14
11
|
/**
|
|
15
12
|
* @this {AsyncTree|null}
|
package/src/builtins/@files.js
CHANGED
|
@@ -10,7 +10,7 @@ import assertScopeIsDefined from "../misc/assertScopeIsDefined.js";
|
|
|
10
10
|
* @param {string[]} keys
|
|
11
11
|
*/
|
|
12
12
|
export default async function files(...keys) {
|
|
13
|
-
assertScopeIsDefined(this);
|
|
13
|
+
assertScopeIsDefined(this, "files");
|
|
14
14
|
const resolved = path.resolve(process.cwd(), ...keys);
|
|
15
15
|
/** @type {AsyncTree} */
|
|
16
16
|
let result = new OrigamiFiles(resolved);
|
package/src/builtins/@filter.js
CHANGED
|
@@ -12,7 +12,7 @@ import assertScopeIsDefined from "../misc/assertScopeIsDefined.js";
|
|
|
12
12
|
* @param {Treelike} filterVariant
|
|
13
13
|
*/
|
|
14
14
|
export default async function filter(treelike, filterVariant) {
|
|
15
|
-
assertScopeIsDefined(this);
|
|
15
|
+
assertScopeIsDefined(this, "filter");
|
|
16
16
|
/** @type {AsyncTree} */
|
|
17
17
|
let result = new FilterTree(treelike, filterVariant);
|
|
18
18
|
result = Scope.treeWithScope(result, this);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import getTreeArgument from "
|
|
1
|
+
import getTreeArgument from "../misc/getTreeArgument.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Return the first value in the tree.
|
|
@@ -9,7 +9,7 @@ import getTreeArgument from "../../misc/getTreeArgument.js";
|
|
|
9
9
|
* @param {Treelike} [treelike]
|
|
10
10
|
*/
|
|
11
11
|
export default async function first(treelike) {
|
|
12
|
-
const tree = await getTreeArgument(this, arguments, treelike);
|
|
12
|
+
const tree = await getTreeArgument(this, arguments, treelike, "@first");
|
|
13
13
|
for (const key of await tree.keys()) {
|
|
14
14
|
// Just return first value immediately.
|
|
15
15
|
const value = await tree.get(key);
|
|
@@ -18,5 +18,5 @@ export default async function first(treelike) {
|
|
|
18
18
|
return undefined;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
first.usage =
|
|
21
|
+
first.usage = `@first <tree>\tReturns the first value in the tree.`;
|
|
22
22
|
first.documentation = "https://weborigami.org/cli/builtins.html#first";
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { FunctionTree } from "@weborigami/async-tree";
|
|
2
2
|
import { Scope } from "@weborigami/language";
|
|
3
|
-
import { toFunction } from "
|
|
4
|
-
import assertScopeIsDefined from "
|
|
3
|
+
import { toFunction } from "../common/utilities.js";
|
|
4
|
+
import assertScopeIsDefined from "../misc/assertScopeIsDefined.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Create a tree from a function and a set of keys.
|
|
8
8
|
*
|
|
9
9
|
* @typedef {import("@weborigami/types").AsyncTree} AsyncTree
|
|
10
10
|
* @typedef {import("@weborigami/async-tree").Treelike} Treelike
|
|
11
|
-
* @typedef {import("
|
|
11
|
+
* @typedef {import("../../index.ts").Invocable} Invocable
|
|
12
12
|
*
|
|
13
13
|
* @this {AsyncTree|null}
|
|
14
14
|
* @param {Invocable} [invocable]
|
|
15
15
|
*/
|
|
16
|
-
export default async function
|
|
17
|
-
assertScopeIsDefined(this);
|
|
16
|
+
export default async function fnTree(invocable, keys = []) {
|
|
17
|
+
assertScopeIsDefined(this, "fnTree");
|
|
18
18
|
// A fragment of the logic from getTreeArgument.js
|
|
19
19
|
if (arguments.length > 0 && invocable === undefined) {
|
|
20
20
|
throw new Error(
|
|
@@ -36,5 +36,5 @@ export default async function fn(invocable, keys = []) {
|
|
|
36
36
|
return new FunctionTree(extendedFn, keys);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
fnTree.usage = `@fnTree <fn>, [<keys>]\tCreate a tree from a function and a set of keys`;
|
|
40
|
+
fnTree.documentation = "https://weborigami.org/cli/tree.html#fn";
|
package/src/builtins/@globs.js
CHANGED
|
@@ -12,7 +12,7 @@ import assertScopeIsDefined from "../misc/assertScopeIsDefined.js";
|
|
|
12
12
|
* @this {AsyncTree|null}
|
|
13
13
|
*/
|
|
14
14
|
export default async function globs(tree) {
|
|
15
|
-
assertScopeIsDefined(this);
|
|
15
|
+
assertScopeIsDefined(this, "globs");
|
|
16
16
|
/** @type {AsyncTree} */
|
|
17
17
|
let result = new GlobTree(tree);
|
|
18
18
|
result = Scope.treeWithScope(result, this);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { groupBy } from "@weborigami/async-tree";
|
|
2
2
|
import { Scope } from "@weborigami/language";
|
|
3
|
-
import addValueKeyToScope from "
|
|
4
|
-
import { toFunction } from "
|
|
5
|
-
import getTreeArgument from "
|
|
3
|
+
import addValueKeyToScope from "../common/addValueKeyToScope.js";
|
|
4
|
+
import { toFunction } from "../common/utilities.js";
|
|
5
|
+
import getTreeArgument from "../misc/getTreeArgument.js";
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Return a new tree with the values from the original tree in groups.
|
|
@@ -10,14 +10,14 @@ import getTreeArgument from "../../misc/getTreeArgument.js";
|
|
|
10
10
|
*
|
|
11
11
|
* @typedef {import("@weborigami/types").AsyncTree} AsyncTree
|
|
12
12
|
* @typedef {import("@weborigami/async-tree").Treelike} Treelike
|
|
13
|
-
* @typedef {import("
|
|
13
|
+
* @typedef {import("../../index.ts").Invocable} Invocable
|
|
14
14
|
*
|
|
15
15
|
* @this {AsyncTree|null}
|
|
16
16
|
* @param {Treelike} treelike
|
|
17
17
|
* @param {Invocable} groupKeyFn
|
|
18
18
|
*/
|
|
19
19
|
export default async function groupByBuiltin(treelike, groupKeyFn) {
|
|
20
|
-
const tree = await getTreeArgument(this, arguments, treelike);
|
|
20
|
+
const tree = await getTreeArgument(this, arguments, treelike, "@groupBy");
|
|
21
21
|
|
|
22
22
|
const fn = toFunction(groupKeyFn);
|
|
23
23
|
const baseScope = Scope.getScope(this);
|
|
@@ -32,6 +32,6 @@ export default async function groupByBuiltin(treelike, groupKeyFn) {
|
|
|
32
32
|
return scoped;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
groupByBuiltin.usage =
|
|
35
|
+
groupByBuiltin.usage = `@groupBy <tree>, [groupKeyFn]\tReturn a new tree with the original's values grouped`;
|
|
36
36
|
groupByBuiltin.documentation =
|
|
37
37
|
"https://weborigami.org/cli/builtins.html#@group";
|
package/src/builtins/@help.js
CHANGED
package/src/builtins/@http.js
CHANGED
|
@@ -11,7 +11,7 @@ import assertScopeIsDefined from "../misc/assertScopeIsDefined.js";
|
|
|
11
11
|
* @param {...string} keys
|
|
12
12
|
*/
|
|
13
13
|
export default async function http(host, ...keys) {
|
|
14
|
-
assertScopeIsDefined(this);
|
|
14
|
+
assertScopeIsDefined(this, "http");
|
|
15
15
|
return ops.http.call(this, host, ...keys);
|
|
16
16
|
}
|
|
17
17
|
|
package/src/builtins/@https.js
CHANGED
|
@@ -11,7 +11,7 @@ import assertScopeIsDefined from "../misc/assertScopeIsDefined.js";
|
|
|
11
11
|
* @param {...string} keys
|
|
12
12
|
*/
|
|
13
13
|
export default async function https(host, ...keys) {
|
|
14
|
-
assertScopeIsDefined(this);
|
|
14
|
+
assertScopeIsDefined(this, "https");
|
|
15
15
|
return ops.https.call(this, host, ...keys);
|
|
16
16
|
}
|
|
17
17
|
|
package/src/builtins/@if.js
CHANGED
|
@@ -9,7 +9,7 @@ import assertScopeIsDefined from "../misc/assertScopeIsDefined.js";
|
|
|
9
9
|
* @param {any} [falseResult]
|
|
10
10
|
*/
|
|
11
11
|
export default async function ifCommand(value, trueResult, falseResult) {
|
|
12
|
-
assertScopeIsDefined(this);
|
|
12
|
+
assertScopeIsDefined(this, "if");
|
|
13
13
|
let condition = await value;
|
|
14
14
|
if (Tree.isAsyncTree(condition)) {
|
|
15
15
|
const keys = Array.from(await condition.keys());
|
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
import sharp from "sharp";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Return the image in a different format.
|
|
5
|
+
*
|
|
6
|
+
* @this {import("@weborigami/types").AsyncTree|null}
|
|
7
|
+
*
|
|
8
|
+
* @typedef {import("sharp").ResizeOptions} ResizeOptions
|
|
9
|
+
*
|
|
10
|
+
* @overload
|
|
11
|
+
* @param {any} param1
|
|
12
|
+
* @param {any} param2
|
|
13
|
+
* @returns {(buffer: Buffer) => Promise<Buffer>}
|
|
14
|
+
*
|
|
15
|
+
* @overload
|
|
16
|
+
* @param {Buffer} param1
|
|
17
|
+
* @param {any} param2
|
|
18
|
+
* @param {any} param3
|
|
19
|
+
* @returns {Promise<Buffer>}
|
|
20
|
+
*/
|
|
21
|
+
export default function format(param1, param2, param3) {
|
|
22
|
+
// Identify which overload was used.
|
|
23
|
+
let buffer;
|
|
24
|
+
let format;
|
|
25
|
+
let options;
|
|
26
|
+
if (param1 instanceof Buffer) {
|
|
27
|
+
buffer = param1;
|
|
28
|
+
format = param2;
|
|
29
|
+
options = param3;
|
|
30
|
+
} else {
|
|
31
|
+
format = param1;
|
|
32
|
+
options = param2;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const transform = (buffer) =>
|
|
36
|
+
sharp(buffer).toFormat(format, options).toBuffer();
|
|
37
|
+
|
|
38
|
+
return buffer ? transform(buffer) : transform;
|
|
5
39
|
}
|
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
import sharp from "sharp";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Resize an image.
|
|
5
|
+
*
|
|
6
|
+
* @this {import("@weborigami/types").AsyncTree|null}
|
|
7
|
+
*
|
|
8
|
+
* @typedef {import("sharp").ResizeOptions} ResizeOptions
|
|
9
|
+
*
|
|
10
|
+
* @overload
|
|
11
|
+
* @param {ResizeOptions} param1
|
|
12
|
+
* @returns {(buffer: Buffer) => Promise<Buffer>}
|
|
13
|
+
*
|
|
14
|
+
* @overload
|
|
15
|
+
* @param {Buffer} param1
|
|
16
|
+
* @param {ResizeOptions} param2
|
|
17
|
+
* @returns {Promise<Buffer>}
|
|
18
|
+
*/
|
|
19
|
+
export default function resize(param1, param2) {
|
|
20
|
+
// Identify which overload was used.
|
|
21
|
+
let buffer;
|
|
22
|
+
let options;
|
|
23
|
+
if (param2 === undefined) {
|
|
24
|
+
options = param1;
|
|
25
|
+
} else {
|
|
26
|
+
buffer = param1;
|
|
27
|
+
options = param2;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Include `rotate()` to auto-rotate according to EXIF data.
|
|
31
|
+
const transform = (buffer) =>
|
|
32
|
+
sharp(buffer).rotate().resize(options).toBuffer();
|
|
33
|
+
|
|
34
|
+
return buffer ? transform(buffer) : transform;
|
|
5
35
|
}
|
package/src/builtins/@index.js
CHANGED
|
@@ -10,7 +10,7 @@ import getTreeArgument from "../misc/getTreeArgument.js";
|
|
|
10
10
|
* @param {Treelike} [treelike]
|
|
11
11
|
*/
|
|
12
12
|
export default async function index(treelike) {
|
|
13
|
-
const tree = await getTreeArgument(this, arguments, treelike);
|
|
13
|
+
const tree = await getTreeArgument(this, arguments, treelike, "@index");
|
|
14
14
|
const keys = Array.from(await tree.keys());
|
|
15
15
|
|
|
16
16
|
// Skip system-ish files that start with a period. Also skip `index.html`.
|
|
@@ -9,7 +9,7 @@ import assertScopeIsDefined from "../misc/assertScopeIsDefined.js";
|
|
|
9
9
|
* @this {AsyncTree|null}
|
|
10
10
|
*/
|
|
11
11
|
export default async function inherited(key) {
|
|
12
|
-
assertScopeIsDefined(this);
|
|
12
|
+
assertScopeIsDefined(this, "inherited");
|
|
13
13
|
return ops.inherited.call(this, key);
|
|
14
14
|
}
|
|
15
15
|
|