@weborigami/origami 0.0.68 → 0.0.70

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.
@@ -7,6 +7,7 @@ export { default as cache } from "../src/builtins/@cache.js";
7
7
  export { default as calendarTree } from "../src/builtins/@calendarTree.js";
8
8
  export { default as changes } from "../src/builtins/@changes.js";
9
9
  export { default as clean } from "../src/builtins/@clean.js";
10
+ export { default as code } from "../src/builtins/@code.js";
10
11
  export { default as concat } from "../src/builtins/@concat.js";
11
12
  export { default as config } from "../src/builtins/@config.js";
12
13
  export { default as copy } from "../src/builtins/@copy.js";
@@ -40,6 +41,7 @@ export { default as imageFormat } from "../src/builtins/@image/format.js";
40
41
  export { default as imageFormatFn } from "../src/builtins/@image/formatFn.js";
41
42
  export { default as imageResize } from "../src/builtins/@image/resize.js";
42
43
  export { default as imageResizeFn } from "../src/builtins/@image/resizeFn.js";
44
+ export { default as indent } from "../src/builtins/@indent.js";
43
45
  export { default as index } from "../src/builtins/@index.js";
44
46
  export { default as inherited } from "../src/builtins/@inherited.js";
45
47
  export { default as inline } from "../src/builtins/@inline.js";
@@ -86,6 +88,7 @@ export { default as serve } from "../src/builtins/@serve.js";
86
88
  export { default as setDeep } from "../src/builtins/@setDeep.js";
87
89
  export { default as shell } from "../src/builtins/@shell.js";
88
90
  export { default as shuffle } from "../src/builtins/@shuffle.js";
91
+ export { default as siteAudit } from "../src/builtins/@siteAudit.js";
89
92
  export { default as sitemap } from "../src/builtins/@sitemap.js";
90
93
  export * from "../src/builtins/@slash.js";
91
94
  export { default as slug } from "../src/builtins/@slug.js";
@@ -136,6 +139,9 @@ export { default as processUnpackedContent } from "../src/common/processUnpacked
136
139
  export * from "../src/common/serialize.js";
137
140
  export { default as ShuffleTransform } from "../src/common/ShuffleTransform.js";
138
141
  export * from "../src/common/utilities.js";
142
+ export { default as crawlResources } from "../src/crawler/crawlResources.js";
143
+ export { default as findPaths } from "../src/crawler/findPaths.js";
144
+ export * from "../src/crawler/utilities.js";
139
145
  export { default as assertTreeIsDefined } from "../src/misc/assertTreeIsDefined.js";
140
146
  export { default as getTreeArgument } from "../src/misc/getTreeArgument.js";
141
147
  export { default as OriCommandTransform } from "../src/misc/OriCommandTransform.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weborigami/origami",
3
- "version": "0.0.68",
3
+ "version": "0.0.70",
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.6.2"
18
18
  },
19
19
  "dependencies": {
20
- "@weborigami/async-tree": "0.0.68",
21
- "@weborigami/language": "0.0.68",
22
- "@weborigami/types": "0.0.68",
20
+ "@weborigami/async-tree": "0.0.70",
21
+ "@weborigami/language": "0.0.70",
22
+ "@weborigami/types": "0.0.70",
23
23
  "exif-parser": "0.1.12",
24
24
  "graphviz-wasm": "3.0.2",
25
25
  "highlight.js": "11.10.0",
@@ -1,4 +1,4 @@
1
- import { Tree } from "@weborigami/async-tree";
1
+ import { trailingSlash, Tree } from "@weborigami/async-tree";
2
2
 
3
3
  /**
4
4
  * Given an old tree and a new tree, return a tree of changes indicated
@@ -17,36 +17,46 @@ export default async function changes(oldTreelike, newTreelike) {
17
17
  const oldKeys = Array.from(await oldTree.keys());
18
18
  const newKeys = Array.from(await newTree.keys());
19
19
 
20
- const result = {};
20
+ const oldKeysNormalized = oldKeys.map(trailingSlash.remove);
21
+ const newKeysNormalized = newKeys.map(trailingSlash.remove);
21
22
 
22
- for (const key of oldKeys) {
23
- if (!newKeys.includes(key)) {
24
- result[key] = "deleted";
23
+ let result;
24
+
25
+ for (const oldKey of oldKeys) {
26
+ const oldNormalized = trailingSlash.remove(oldKey);
27
+ if (!newKeysNormalized.includes(oldNormalized)) {
28
+ result ??= {};
29
+ result[oldKey] = "deleted";
25
30
  continue;
26
31
  }
27
32
 
28
- const oldValue = await oldTree.get(key);
29
- const newValue = await newTree.get(key);
33
+ const oldValue = await oldTree.get(oldKey);
34
+ const newValue = await newTree.get(oldKey);
30
35
 
31
36
  if (Tree.isAsyncTree(oldValue) && Tree.isAsyncTree(newValue)) {
32
37
  const treeChanges = await changes.call(this, oldValue, newValue);
33
- if (Object.keys(treeChanges).length > 0) {
34
- result[key] = treeChanges;
38
+ if (treeChanges && Object.keys(treeChanges).length > 0) {
39
+ result ??= {};
40
+ result[oldKey] = treeChanges;
35
41
  }
36
42
  } else if (oldValue?.toString && newValue?.toString) {
37
43
  const oldText = oldValue.toString();
38
44
  const newText = newValue.toString();
39
45
  if (oldText !== newText) {
40
- result[key] = "changed";
46
+ result ??= {};
47
+ result[oldKey] = "changed";
41
48
  }
42
49
  } else {
43
- result[key] = "changed";
50
+ result ??= {};
51
+ result[oldKey] = "changed";
44
52
  }
45
53
  }
46
54
 
47
- for (const key of newKeys) {
48
- if (!oldKeys.includes(key)) {
49
- result[key] = "added";
55
+ for (const newKey of newKeys) {
56
+ const newNormalized = trailingSlash.remove(newKey);
57
+ if (!oldKeysNormalized.includes(newNormalized)) {
58
+ result ??= {};
59
+ result[newKey] = "added";
50
60
  }
51
61
  }
52
62
 
@@ -0,0 +1,37 @@
1
+ import { symbols } from "@weborigami/language";
2
+ import getTreeArgument from "../misc/getTreeArgument.js";
3
+
4
+ /**
5
+ * @typedef {import("@weborigami/types").AsyncTree} AsyncTree
6
+ *
7
+ * @this {AsyncTree|null}
8
+ * @param {any} value
9
+ */
10
+ export default async function code(value) {
11
+ if (value === undefined) {
12
+ value = await getTreeArgument(this, arguments, value, "@clean");
13
+ }
14
+ if (value === undefined) {
15
+ return undefined;
16
+ }
17
+ const code = value.code ?? value[symbols.codeSymbol];
18
+ return code ? functionNames(code) : undefined;
19
+ }
20
+
21
+ function functionNames(code) {
22
+ if (!Array.isArray(code)) {
23
+ return code;
24
+ }
25
+ let [head, ...tail] = code;
26
+ if (typeof head === "function") {
27
+ const text = head.toString();
28
+ if (text.startsWith("«ops.")) {
29
+ head = text;
30
+ } else {
31
+ head = head.name;
32
+ }
33
+ } else {
34
+ head = functionNames(head);
35
+ }
36
+ return [head, ...tail.map(functionNames)];
37
+ }