@weborigami/origami 0.3.4-jse.6 → 0.3.4-jse.8

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.
Files changed (62) hide show
  1. package/main.js +4 -1
  2. package/package.json +4 -4
  3. package/src/builtinsJse.js +15 -5
  4. package/src/builtinsProgram.js +81 -0
  5. package/src/builtinsShell.js +41 -30
  6. package/src/cli/cli.js +1 -1
  7. package/src/common/documentObject.js +14 -3
  8. package/src/common/utilities.js +1 -1
  9. package/src/{tree → dev}/copy.js +2 -2
  10. package/src/dev/dev.js +6 -0
  11. package/src/dev/explore.js +2 -2
  12. package/src/{help → dev}/help.js +5 -5
  13. package/src/{help → dev}/help.yaml +80 -170
  14. package/src/dev/serve.js +1 -1
  15. package/src/{origami → dev}/version.js +2 -2
  16. package/src/dev/watch.js +1 -1
  17. package/src/handlers/ori.handler.js +2 -2
  18. package/src/handlers/oridocument.handler.js +2 -2
  19. package/src/handlers/txt.handler.js +15 -3
  20. package/src/handlers/xhtml.handler.js +1 -1
  21. package/src/handlers/yml.handler.js +1 -1
  22. package/src/image/format.js +1 -1
  23. package/src/image/resize.js +1 -1
  24. package/src/origami/csv.js +1 -1
  25. package/src/origami/json.js +1 -1
  26. package/src/origami/once.js +1 -1
  27. package/src/origami/ori.js +1 -1
  28. package/src/origami/origami.js +1 -3
  29. package/src/origami/pack.js +1 -1
  30. package/src/origami/project.js +1 -1
  31. package/src/origami/regexMatch.js +7 -4
  32. package/src/origami/string.js +1 -1
  33. package/src/origami/unpack.js +1 -1
  34. package/src/origami/yaml.js +1 -1
  35. package/src/protocols/explore.js +1 -1
  36. package/src/protocols/files.js +1 -1
  37. package/src/protocols/http.js +1 -1
  38. package/src/protocols/https.js +1 -1
  39. package/src/protocols/httpstree.js +1 -1
  40. package/src/protocols/httptree.js +1 -1
  41. package/src/protocols/inherited.js +7 -2
  42. package/src/protocols/js.js +10 -0
  43. package/src/protocols/new.js +7 -2
  44. package/src/protocols/scope.js +6 -1
  45. package/src/site/rss.js +1 -1
  46. package/src/site/sitemap.js +1 -1
  47. package/src/text/document.js +1 -1
  48. package/src/text/inline.js +1 -1
  49. package/src/text/mdHtml.js +1 -1
  50. package/src/tree/cache.js +1 -1
  51. package/src/tree/concat.js +1 -1
  52. package/src/tree/deepMerge.js +1 -1
  53. package/src/tree/filter.js +1 -1
  54. package/src/tree/fromFn.js +1 -1
  55. package/src/tree/globKeys.js +1 -1
  56. package/src/tree/mask.js +1 -1
  57. package/src/tree/match.js +1 -1
  58. package/src/tree/merge.js +1 -1
  59. package/src/tree/regExpKeys.js +1 -1
  60. package/src/tree/tree.js +0 -1
  61. package/src/BuiltinsTree.js +0 -18
  62. /package/src/{origami → dev}/stdin.js +0 -0
package/main.js CHANGED
@@ -3,10 +3,13 @@ export { toString } from "./src/common/utilities.js";
3
3
  export * from "./src/dev/dev.js";
4
4
  export { default as handlerBuiltins } from "./src/handlers/handlerBuiltins.js";
5
5
  export * from "./src/handlers/handlers.js";
6
- export * from "./src/image/image.js";
6
+ export * as image from "./src/image/image.js";
7
7
  export * from "./src/origami/origami.js";
8
8
  export { default as packageBuiltin } from "./src/protocols/package.js";
9
9
  export * from "./src/server/server.js";
10
10
  export * from "./src/site/site.js";
11
+ export { default as origamiHighlightDefinition } from "./src/text/origamiHighlightDefinition.js";
11
12
  export * from "./src/text/text.js";
13
+
14
+ // TODO: Remove once these all moves to async-tree
12
15
  export * from "./src/tree/tree.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weborigami/origami",
3
- "version": "0.3.4-jse.6",
3
+ "version": "0.3.4-jse.8",
4
4
  "description": "Web Origami language, CLI, framework, and server",
5
5
  "type": "module",
6
6
  "repository": {
@@ -17,10 +17,10 @@
17
17
  "typescript": "5.8.2"
18
18
  },
19
19
  "dependencies": {
20
- "@weborigami/async-tree": "0.3.4-jse.6",
20
+ "@weborigami/async-tree": "0.3.4-jse.8",
21
21
  "@weborigami/json-feed-to-rss": "1.0.0",
22
- "@weborigami/language": "0.3.4-jse.6",
23
- "@weborigami/types": "0.3.4-jse.6",
22
+ "@weborigami/language": "0.3.4-jse.8",
23
+ "@weborigami/types": "0.3.4-jse.8",
24
24
  "css-tree": "3.1.0",
25
25
  "exif-parser": "0.1.12",
26
26
  "graphviz-wasm": "3.0.2",
@@ -1,8 +1,8 @@
1
1
  import { text as treeText } from "@weborigami/async-tree";
2
2
  import { jsGlobals } from "@weborigami/language";
3
3
  import * as dev from "./dev/dev.js";
4
+ import help from "./dev/help.js";
4
5
  import handlerBuiltins from "./handlers/handlerBuiltins.js";
5
- import help from "./help/help.js";
6
6
  import * as image from "./image/image.js";
7
7
  import * as origami from "./origami/origami.js";
8
8
  import explore from "./protocols/explore.js";
@@ -11,7 +11,6 @@ import http from "./protocols/http.js";
11
11
  import https from "./protocols/https.js";
12
12
  import httpstree from "./protocols/httpstree.js";
13
13
  import httptree from "./protocols/httptree.js";
14
- import inherited from "./protocols/inherited.js";
15
14
  import node from "./protocols/node.js";
16
15
  import packageNamespace from "./protocols/package.js";
17
16
  import scope from "./protocols/scope.js";
@@ -31,14 +30,24 @@ export default function builtinsJse() {
31
30
  };
32
31
 
33
32
  const Origami = {
34
- ...dev,
35
- files,
36
33
  image,
37
34
  ...origami,
38
35
  ...site,
36
+ static: site.staticBuiltin,
39
37
  ...text,
40
38
  };
41
39
 
40
+ const Protocol = {
41
+ explore,
42
+ files,
43
+ http,
44
+ https,
45
+ httpstree,
46
+ httptree,
47
+ node,
48
+ package: packageNamespace,
49
+ };
50
+
42
51
  /** @type {any} */
43
52
  builtins = {
44
53
  ...jsGlobals,
@@ -50,13 +59,14 @@ export default function builtinsJse() {
50
59
  "https:": https,
51
60
  "httpstree:": httpstree,
52
61
  "httptree:": httptree,
53
- "inherited:": inherited,
54
62
  "node:": node,
55
63
  "package:": packageNamespace,
56
64
  "scope:": scope,
57
65
 
66
+ Dev: dev,
58
67
  Tree,
59
68
  Origami,
69
+ Protocol,
60
70
 
61
71
  // Handlers need to be exposed at top level
62
72
  ...handlerBuiltins(),
@@ -0,0 +1,81 @@
1
+ import { Tree } from "@weborigami/async-tree";
2
+ import { attachWarning } from "@weborigami/language";
3
+ import builtinsJse from "./builtinsJse.js";
4
+ import * as dev from "./dev/dev.js";
5
+ import * as image from "./image/image.js";
6
+ import * as origami from "./origami/origami.js";
7
+ import inherited from "./protocols/inherited.js";
8
+ import js from "./protocols/js.js";
9
+ import instantiate from "./protocols/new.js";
10
+ import scope from "./protocols/scope.js";
11
+ import * as site from "./site/site.js";
12
+ import * as text from "./text/text.js";
13
+ import * as tree from "./tree/tree.js";
14
+
15
+ let builtins;
16
+
17
+ export default function builtinsProgram() {
18
+ if (!builtins) {
19
+ builtins = {
20
+ // All JSE builtins
21
+ ...builtinsJse(),
22
+
23
+ // // Old protocols to be deprecated
24
+ "dev:": deprecateFunctions(dev, "dev:", "Dev."),
25
+ "image:": deprecateFunctions(image, "image:", "Origami.image."),
26
+ "inherited:": inherited,
27
+ "js:": js,
28
+ "new:": instantiate,
29
+ "origami:": deprecateFunctions(origami, "origami:", "Origami."),
30
+ "scope:": scope,
31
+ "site:": deprecateFunctions(
32
+ adjustReservedWords(site),
33
+ "site:",
34
+ "Origami."
35
+ ),
36
+ "text:": deprecateFunctions(text, "text:", "Origami."),
37
+ "tree:": deprecateFunctions(tree, "tree:", "Tree."),
38
+
39
+ // // For backward compat, include all methods at the top level
40
+ ...deprecateFunctions(dev, "", "Dev."),
41
+ ...deprecateFunctions(image, "", "Origami.image."),
42
+ ...deprecateFunctions(origami, "", "Origami."),
43
+ ...deprecateFunctions(adjustReservedWords(site), "site:", "Origami."),
44
+ ...deprecateFunctions(text, "", "Origami."),
45
+ ...deprecateFunctions(tree, "", "Tree."),
46
+ };
47
+ }
48
+
49
+ return builtins;
50
+ }
51
+
52
+ function deprecateFunctions(fns, oldPrefix, newPrefix) {
53
+ const wrappedEntries = Object.entries(fns).map(([key, value]) => {
54
+ const wrappedFn = async function (...args) {
55
+ const oldKey = key === "indent" ? key : `${oldPrefix}${key}()`;
56
+ const newKey =
57
+ key === "indent" ? `${newPrefix}${key}` : `${newPrefix}${key}()`;
58
+ const result =
59
+ value instanceof Function
60
+ ? await value.apply(this, args)
61
+ : await Tree.traverseOrThrow.call(this, value, ...args);
62
+ return attachWarning(
63
+ result,
64
+ `${oldKey} is deprecated, use ${newKey} instead.`
65
+ );
66
+ };
67
+ Object.assign(wrappedFn, value);
68
+ return [key, wrappedFn];
69
+ });
70
+ return Object.fromEntries(wrappedEntries);
71
+ }
72
+
73
+ // Handle cases where a builtin name conflicts with a JS reserved word
74
+ function adjustReservedWords(obj) {
75
+ const result = {};
76
+ for (const [key, value] of Object.entries(obj)) {
77
+ const name = value.key ?? key;
78
+ result[name] = value;
79
+ }
80
+ return result;
81
+ }
@@ -1,10 +1,16 @@
1
- import { jsGlobals } from "@weborigami/language";
1
+ import { text as treeText } from "@weborigami/async-tree";
2
2
  import builtinsJse from "./builtinsJse.js";
3
3
  import * as dev from "./dev/dev.js";
4
4
  import * as image from "./image/image.js";
5
5
  import * as origami from "./origami/origami.js";
6
- import instantiate from "./protocols/new.js";
7
- import scope from "./protocols/scope.js";
6
+ import explore from "./protocols/explore.js";
7
+ import files from "./protocols/files.js";
8
+ import http from "./protocols/http.js";
9
+ import https from "./protocols/https.js";
10
+ import httpstree from "./protocols/httpstree.js";
11
+ import httptree from "./protocols/httptree.js";
12
+ import node from "./protocols/node.js";
13
+ import packageNamespace from "./protocols/package.js";
8
14
  import * as site from "./site/site.js";
9
15
  import * as text from "./text/text.js";
10
16
  import * as tree from "./tree/tree.js";
@@ -13,40 +19,45 @@ let builtins;
13
19
 
14
20
  export default function builtinsShell() {
15
21
  if (!builtins) {
22
+ const Tree = {
23
+ ...tree,
24
+ indent: text.indent,
25
+ json: origami.json,
26
+ text: treeText,
27
+ };
28
+
29
+ const Origami = {
30
+ image,
31
+ ...origami,
32
+ ...site,
33
+ static: site.staticBuiltin,
34
+ ...text,
35
+ };
36
+
37
+ const Protocol = {
38
+ explore,
39
+ files,
40
+ http,
41
+ https,
42
+ httpstree,
43
+ httptree,
44
+ node,
45
+ package: packageNamespace,
46
+ };
47
+
16
48
  builtins = {
17
49
  // All JSE builtins
18
50
  ...builtinsJse(),
19
51
 
20
- // Old protocols to be deprecated
21
- "dev:": dev,
22
- "image:": image,
23
- "js:": jsGlobals,
24
- "new:": instantiate,
25
- "origami:": origami,
26
- "scope:": scope,
27
- "site:": adjustReservedWords(site),
28
- "text:": text,
29
- "tree:": tree,
30
-
31
- // For backward compat, include all methods at the top level
52
+ // Dev builtins exposed at the top level in shell
32
53
  ...dev,
33
- ...image,
34
- ...origami,
35
- ...adjustReservedWords(site),
36
- ...text,
37
- ...tree,
54
+
55
+ Dev: dev,
56
+ Origami,
57
+ Protocol,
58
+ Tree,
38
59
  };
39
60
  }
40
61
 
41
62
  return builtins;
42
63
  }
43
-
44
- // Handle cases where a builtin name conflicts with a JS reserved word
45
- function adjustReservedWords(obj) {
46
- const result = {};
47
- for (const [key, value] of Object.entries(obj)) {
48
- const name = value.key ?? key;
49
- result[name] = value;
50
- }
51
- return result;
52
- }
package/src/cli/cli.js CHANGED
@@ -4,7 +4,7 @@ import { Tree } from "@weborigami/async-tree";
4
4
  import { formatError } from "@weborigami/language";
5
5
  import path from "node:path";
6
6
  import process, { stdout } from "node:process";
7
- import help from "../help/help.js";
7
+ import help from "../dev/help.js";
8
8
  import ori from "../origami/ori.js";
9
9
  import project from "../origami/project.js";
10
10
 
@@ -1,4 +1,5 @@
1
1
  import { isPlainObject, isUnpackable, toString } from "@weborigami/async-tree";
2
+ import { attachWarning } from "@weborigami/language";
2
3
 
3
4
  /**
4
5
  * In Origami, a text document object is any object with a `@text` property and
@@ -21,7 +22,7 @@ export default async function documentObject(input, data) {
21
22
  }
22
23
 
23
24
  if (isPlainObject(input)) {
24
- text = input["@text"] ?? input._body;
25
+ text = input._body ?? input["@text"];
25
26
  inputData = input;
26
27
  } else {
27
28
  text = toString(input);
@@ -37,11 +38,21 @@ export default async function documentObject(input, data) {
37
38
  // const result = Object.create(base);
38
39
  const result = {};
39
40
  // TODO: Deprecate @text
40
- Object.assign(result, inputData, data, { "@text": text });
41
+ Object.assign(result, inputData, data);
42
+ Object.defineProperty(result, "@text", {
43
+ configurable: true,
44
+ enumerable: true,
45
+ get() {
46
+ return attachWarning(
47
+ text,
48
+ "The @text property is deprecated. Use _body instead."
49
+ );
50
+ },
51
+ });
41
52
  Object.defineProperty(result, "_body", {
42
53
  configurable: true,
54
+ enumerable: true,
43
55
  value: text,
44
- enumerable: false, // TODO: Make enumerable
45
56
  writable: true,
46
57
  });
47
58
  return result;
@@ -95,7 +95,7 @@ export function toFunction(obj) {
95
95
  */
96
96
  export function toString(object) {
97
97
  if (isPlainObject(object) && ("@text" in object || "_body" in object)) {
98
- object = object["@text"] ?? object._body;
98
+ object = object._body ?? object["@text"];
99
99
  }
100
100
  return asyncTreeToString(object);
101
101
  }
@@ -3,7 +3,7 @@ import { formatError } from "@weborigami/language";
3
3
  import process, { stdout } from "node:process";
4
4
  import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
5
5
  import { transformObject } from "../common/utilities.js";
6
- import setDeep from "./setDeep.js";
6
+ import setDeep from "../tree/setDeep.js";
7
7
 
8
8
  /**
9
9
  * @typedef {import("@weborigami/types").AsyncTree} AsyncTree
@@ -14,7 +14,7 @@ import setDeep from "./setDeep.js";
14
14
  * @param {Treelike} target
15
15
  */
16
16
  export default async function copy(source, target) {
17
- assertTreeIsDefined(this, "tree:copy");
17
+ assertTreeIsDefined(this, "copy");
18
18
  const sourceTree = Tree.from(source, { parent: this });
19
19
  /** @type {any} */ let targetTree = Tree.from(target, { parent: this });
20
20
 
package/src/dev/dev.js CHANGED
@@ -1,11 +1,17 @@
1
+ export { default as clear } from "../tree/clear.js";
2
+ export { default as keys } from "../tree/keys.js";
1
3
  export { default as breakpoint } from "./breakpoint.js";
2
4
  export { default as changes } from "./changes.js";
3
5
  export { default as code } from "./code.js";
6
+ export { default as copy } from "./copy.js";
4
7
  export { default as audit } from "./crawler/audit.js";
5
8
  export { default as crawl } from "./crawler/crawl.js";
6
9
  export { default as debug } from "./debug.js";
7
10
  export { default as explore } from "./explore.js";
11
+ export { default as help } from "./help.js";
8
12
  export { default as log } from "./log.js";
9
13
  export { default as serve } from "./serve.js";
14
+ export { default as stdin } from "./stdin.js";
10
15
  export { default as svg } from "./svg.js";
16
+ export { default as version } from "./version.js";
11
17
  export { default as watch } from "./watch.js";
@@ -5,7 +5,7 @@ import path from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
7
7
  import { getDescriptor } from "../common/utilities.js";
8
- import oriHandler from "../handlers/ori.handler.js";
8
+ import { oriHandler } from "../handlers/handlers.js";
9
9
  import debug from "./debug.js";
10
10
 
11
11
  let templatePromise;
@@ -14,7 +14,7 @@ let templatePromise;
14
14
  * @this {AsyncTree|null}
15
15
  */
16
16
  export default async function explore(...keys) {
17
- assertTreeIsDefined(this, "origami:explore");
17
+ assertTreeIsDefined(this, "explore");
18
18
  if (!this) {
19
19
  return undefined;
20
20
  }
@@ -3,7 +3,7 @@ import path from "node:path";
3
3
  import { fileURLToPath } from "url";
4
4
  import YAML from "yaml";
5
5
  import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
6
- import version from "../origami/version.js";
6
+ import version from "./version.js";
7
7
 
8
8
  /**
9
9
  * @typedef {import("@weborigami/types").AsyncTree} AsyncTree
@@ -12,7 +12,7 @@ import version from "../origami/version.js";
12
12
  * @param {string} [key]
13
13
  */
14
14
  export default async function help(key) {
15
- assertTreeIsDefined(this, "help:");
15
+ assertTreeIsDefined(this, "help");
16
16
 
17
17
  const helpFilename = path.resolve(
18
18
  fileURLToPath(import.meta.url),
@@ -57,7 +57,7 @@ async function commandDescription(commandHelp, namespace, command) {
57
57
 
58
58
  function formatCommandDescription(commandHelp, namespace, command) {
59
59
  const { args, description } = commandHelp;
60
- return ` ${namespace}:${command}${args ?? ""} - ${description}`;
60
+ return ` ${namespace}.${command}${args ?? ""} - ${description}`;
61
61
  }
62
62
 
63
63
  async function namespaceCommands(namespaceHelp, namespace) {
@@ -71,7 +71,7 @@ async function namespaceCommands(namespaceHelp, namespace) {
71
71
  const description = namespaceHelp.description;
72
72
  const lowercase = description[0].toLowerCase() + description.slice(1);
73
73
  text.push(
74
- `The "${namespace}" namespace contains commands to ${lowercase}.`
74
+ `The ${namespace} namespace contains commands to ${lowercase}.`
75
75
  );
76
76
  }
77
77
  text.push("");
@@ -97,7 +97,7 @@ async function namespaceDescriptions(helpData) {
97
97
  }
98
98
  }
99
99
  text.push(
100
- `\nType "ori help:<namespace>" for more or visit https://weborigami.org/builtins\n`
100
+ `\nType "ori help/<namespace>" for more or visit https://weborigami.org/builtins\n`
101
101
  );
102
102
  return text.join("\n");
103
103
  }