@weborigami/origami 0.4.2 → 0.5.0

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 (71) hide show
  1. package/main.js +3 -6
  2. package/package.json +12 -12
  3. package/src/builtinsProgram.js +49 -71
  4. package/src/builtinsShell.js +3 -48
  5. package/src/common/documentObject.js +4 -16
  6. package/src/common/utilities.js +3 -3
  7. package/src/dev/ExplorableSiteTransform.js +1 -1
  8. package/src/dev/code.js +10 -8
  9. package/src/dev/crawler/audit.js +1 -1
  10. package/src/dev/crawler/crawl.js +1 -1
  11. package/src/dev/debug.js +1 -1
  12. package/src/dev/dev.js +1 -1
  13. package/src/dev/explore.ori +2 -2
  14. package/src/dev/help.yaml +11 -2
  15. package/src/dev/serve.js +3 -1
  16. package/src/dev/svg.js +1 -7
  17. package/src/dev/watch.js +1 -6
  18. package/src/handlers/handlerBuiltins.js +3 -2
  19. package/src/handlers/handlers.js +0 -4
  20. package/src/handlers/ori.handler.js +4 -2
  21. package/src/handlers/oridocument.handler.js +7 -7
  22. package/src/handlers/txt.handler.js +4 -17
  23. package/src/origami/fetch.js +22 -0
  24. package/src/{image → origami/image}/format.js +5 -3
  25. package/src/{image → origami/image}/resize.js +1 -1
  26. package/src/{site → origami}/indexPage.js +1 -1
  27. package/src/{text → origami}/inline.js +5 -10
  28. package/src/{site → origami}/jsonKeys.js +11 -12
  29. package/src/{text → origami}/mdHtml.js +1 -2
  30. package/src/origami/origami.js +15 -2
  31. package/src/{text → origami}/origamiHighlightDefinition.js +5 -20
  32. package/src/origami/project.js +2 -0
  33. package/src/{site → origami}/sitemap.js +1 -1
  34. package/src/{site → origami}/static.js +11 -12
  35. package/src/tree/addNextPrevious.js +1 -1
  36. package/src/tree/clear.js +1 -1
  37. package/src/tree/deepMap.js +1 -1
  38. package/src/tree/deepReverse.js +1 -1
  39. package/src/tree/deepTake.js +1 -1
  40. package/src/tree/deepValues.js +1 -1
  41. package/src/tree/defineds.js +1 -6
  42. package/src/tree/first.js +1 -1
  43. package/src/tree/group.js +1 -1
  44. package/src/tree/inners.js +1 -1
  45. package/src/tree/keys.js +1 -1
  46. package/src/tree/length.js +1 -1
  47. package/src/tree/map.js +6 -1
  48. package/src/tree/paginate.js +1 -6
  49. package/src/tree/parent.js +1 -1
  50. package/src/tree/plain.js +1 -1
  51. package/src/tree/reverse.js +1 -1
  52. package/src/tree/shuffle.js +1 -1
  53. package/src/tree/sort.js +1 -1
  54. package/src/tree/take.js +1 -1
  55. package/src/tree/values.js +1 -1
  56. package/src/builtinsJse.js +0 -77
  57. package/src/handlers/jse.handler.js +0 -17
  58. package/src/handlers/jsedocument.handler.js +0 -17
  59. package/src/image/formatFn.js +0 -18
  60. package/src/origami/regexMatch.js +0 -16
  61. package/src/protocols/inherited.js +0 -26
  62. package/src/protocols/new.js +0 -51
  63. package/src/protocols/scope.js +0 -31
  64. package/src/site/site.js +0 -7
  65. package/src/text/text.js +0 -5
  66. /package/src/{text → origami}/document.js +0 -0
  67. /package/src/{text → origami}/htmlDom.js +0 -0
  68. /package/src/{image → origami/image}/image.js +0 -0
  69. /package/src/{site → origami}/redirect.js +0 -0
  70. /package/src/{site → origami}/rss.js +0 -0
  71. /package/src/{site → origami}/slug.js +0 -0
package/main.js CHANGED
@@ -3,13 +3,10 @@ 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 * as image from "./src/image/image.js";
7
6
  export * from "./src/origami/origami.js";
8
- export { default as packageBuiltin } from "./src/protocols/package.js";
7
+ export { default as origamiHighlightDefinition } from "./src/origami/origamiHighlightDefinition.js";
8
+ export { default as package } from "./src/protocols/package.js";
9
9
  export * from "./src/server/server.js";
10
- export * from "./src/site/site.js";
11
- export { default as origamiHighlightDefinition } from "./src/text/origamiHighlightDefinition.js";
12
- export * from "./src/text/text.js";
13
10
 
14
- // TODO: Remove once these all moves to async-tree
11
+ // TODO: Remove once these async-tree owns sole copy of all tree builtins
15
12
  export * from "./src/tree/tree.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weborigami/origami",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "description": "Web Origami language, CLI, framework, and server",
5
5
  "type": "module",
6
6
  "repository": {
@@ -13,25 +13,25 @@
13
13
  "main": "./main.js",
14
14
  "types": "./index.ts",
15
15
  "devDependencies": {
16
- "@types/node": "22.13.13",
17
- "typescript": "5.8.2"
16
+ "@types/node": "24.3.0",
17
+ "typescript": "5.9.2"
18
18
  },
19
19
  "dependencies": {
20
- "@weborigami/async-tree": "0.4.2",
20
+ "@weborigami/async-tree": "0.5.0",
21
21
  "@weborigami/json-feed-to-rss": "1.0.0",
22
- "@weborigami/language": "0.4.2",
23
- "@weborigami/types": "0.4.2",
22
+ "@weborigami/language": "0.5.0",
23
+ "@weborigami/types": "0.5.0",
24
24
  "css-tree": "3.1.0",
25
25
  "exif-parser": "0.1.12",
26
26
  "graphviz-wasm": "3.0.2",
27
27
  "highlight.js": "11.11.1",
28
28
  "jsdom": "26.1.0",
29
- "marked": "15.0.7",
30
- "marked-gfm-heading-id": "4.1.1",
31
- "marked-highlight": "2.2.1",
32
- "marked-smartypants": "1.1.9",
33
- "sharp": "0.33.5",
34
- "yaml": "2.7.0"
29
+ "marked": "16.2.0",
30
+ "marked-gfm-heading-id": "4.1.2",
31
+ "marked-highlight": "2.2.2",
32
+ "marked-smartypants": "1.1.10",
33
+ "sharp": "0.34.3",
34
+ "yaml": "2.8.1"
35
35
  },
36
36
  "scripts": {
37
37
  "test": "node --test --test-reporter=spec",
@@ -1,87 +1,65 @@
1
- import { Tree } from "@weborigami/async-tree";
2
- import { attachWarning } from "@weborigami/language";
3
- import builtinsJse from "./builtinsJse.js";
1
+ import { deepText, indent, json, text } from "@weborigami/async-tree";
2
+ import { jsGlobals } from "@weborigami/language";
4
3
  import * as dev from "./dev/dev.js";
5
- import * as image from "./image/image.js";
4
+ import help from "./dev/help.js";
5
+ import handlerBuiltins from "./handlers/handlerBuiltins.js";
6
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";
7
+ import explore from "./protocols/explore.js";
8
+ import files from "./protocols/files.js";
9
+ import http from "./protocols/http.js";
10
+ import https from "./protocols/https.js";
11
+ import httpstree from "./protocols/httpstree.js";
12
+ import httptree from "./protocols/httptree.js";
13
+ import node from "./protocols/node.js";
14
+ import packageNamespace from "./protocols/package.js";
13
15
  import * as tree from "./tree/tree.js";
14
16
 
15
17
  let builtins;
16
18
 
17
19
  export default function builtinsProgram() {
18
20
  if (!builtins) {
21
+ const Tree = {
22
+ ...tree,
23
+ deepText,
24
+ indent,
25
+ json,
26
+ text,
27
+ };
28
+
29
+ const Protocol = {
30
+ explore,
31
+ files,
32
+ http,
33
+ https,
34
+ httpstree,
35
+ httptree,
36
+ node,
37
+ package: packageNamespace,
38
+ };
39
+
40
+ /** @type {any} */
19
41
  builtins = {
20
- // All JSE builtins
21
- ...builtinsJse(),
42
+ ...jsGlobals,
43
+
44
+ "explore:": explore,
45
+ "files:": files,
46
+ "help:": help,
47
+ "http:": http,
48
+ "https:": https,
49
+ "httpstree:": httpstree,
50
+ "httptree:": httptree,
51
+ "node:": node,
52
+ "package:": packageNamespace,
22
53
 
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."),
54
+ Dev: dev,
55
+ Tree,
56
+ Origami: origami,
57
+ Protocol,
38
58
 
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."),
59
+ // Handlers need to be exposed at top level
60
+ ...handlerBuiltins(),
46
61
  };
47
62
  }
48
63
 
49
64
  return builtins;
50
65
  }
51
-
52
- function deprecateFunctions(fns, oldPrefix, newPrefix) {
53
- const wrappedEntries = Object.entries(fns).map(([key, value]) => {
54
- const wrappedFn =
55
- /** @this {import("@weborigami/types").AsyncTree} */
56
- async function (...args) {
57
- const oldKey = key === "indent" ? key : `${oldPrefix}${key}()`;
58
- const newKey =
59
- key === "indent"
60
- ? `Tree.indent`
61
- : key === "json"
62
- ? `Tree.json`
63
- : `${newPrefix}${key}()`;
64
- const result =
65
- value instanceof Function
66
- ? await value.apply(this, args)
67
- : await Tree.traverseOrThrow.call(this, value, ...args);
68
- return attachWarning(
69
- result,
70
- `${oldKey} is deprecated, use ${newKey} instead.`
71
- );
72
- };
73
- Object.assign(wrappedFn, value);
74
- return [key, wrappedFn];
75
- });
76
- return Object.fromEntries(wrappedEntries);
77
- }
78
-
79
- // Handle cases where a builtin name conflicts with a JS reserved word
80
- function adjustReservedWords(obj) {
81
- const result = {};
82
- for (const [key, value] of Object.entries(obj)) {
83
- const name = value.key ?? key;
84
- result[name] = value;
85
- }
86
- return result;
87
- }
@@ -1,61 +1,16 @@
1
- import { text as treeText } from "@weborigami/async-tree";
2
- import builtinsJse from "./builtinsJse.js";
1
+ import builtinsProgram from "./builtinsProgram.js";
3
2
  import * as dev from "./dev/dev.js";
4
- import * as image from "./image/image.js";
5
- import * as origami from "./origami/origami.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";
14
- import * as site from "./site/site.js";
15
- import * as text from "./text/text.js";
16
- import * as tree from "./tree/tree.js";
17
3
 
18
4
  let builtins;
19
5
 
20
6
  export default function builtinsShell() {
21
7
  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
-
48
8
  builtins = {
49
- // All JSE builtins
50
- ...builtinsJse(),
9
+ // All program builtins
10
+ ...builtinsProgram(),
51
11
 
52
12
  // Dev builtins exposed at the top level in shell
53
13
  ...dev,
54
-
55
- Dev: dev,
56
- Origami,
57
- Protocol,
58
- Tree,
59
14
  };
60
15
  }
61
16
 
@@ -1,10 +1,8 @@
1
1
  import { isPlainObject, isUnpackable, toString } from "@weborigami/async-tree";
2
- import { attachWarning } from "@weborigami/language";
3
2
 
4
3
  /**
5
- * In Origami, a text document object is any object with a `@text` property and
6
- * a pack() method that formats that object as text with YAML front matter. This
7
- * function is a helper for constructing such text document objects.
4
+ * In Origami, a text document object is any object with a `_body` property.
5
+ * This function is a helper for constructing such text document objects.
8
6
  *
9
7
  * @typedef {import("@weborigami/async-tree").StringLike} StringLike
10
8
  * @typedef {import("@weborigami/async-tree").PlainObject} PlainObject
@@ -22,7 +20,7 @@ export default async function documentObject(input, data) {
22
20
  }
23
21
 
24
22
  if (isPlainObject(input)) {
25
- text = input._body ?? input["@text"];
23
+ text = input._body;
26
24
  inputData = input;
27
25
  } else {
28
26
  text = toString(input);
@@ -37,23 +35,13 @@ export default async function documentObject(input, data) {
37
35
  // };
38
36
  // const result = Object.create(base);
39
37
  const result = {};
40
- // TODO: Deprecate @text
41
38
  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
- });
52
39
  Object.defineProperty(result, "_body", {
53
40
  configurable: true,
54
41
  enumerable: true,
55
42
  value: text,
56
43
  writable: true,
57
44
  });
45
+
58
46
  return result;
59
47
  }
@@ -87,15 +87,15 @@ export function toFunction(obj) {
87
87
  }
88
88
 
89
89
  /**
90
- * Extend the async-tree toString method: objects that have a `@text` property
90
+ * Extend the async-tree toString method: objects that have a `_body` property
91
91
  * will return the value of that property as a string.
92
92
  *
93
93
  * @param {any} object
94
94
  * @returns {string|null}
95
95
  */
96
96
  export function toString(object) {
97
- if (isPlainObject(object) && ("@text" in object || "_body" in object)) {
98
- object = object._body ?? object["@text"];
97
+ if (isPlainObject(object) && "_body" in object) {
98
+ object = object._body;
99
99
  }
100
100
  return asyncTreeToString(object);
101
101
  }
@@ -1,6 +1,6 @@
1
1
  import { Tree, jsonKeys } from "@weborigami/async-tree";
2
2
  import { isTransformApplied, transformObject } from "../common/utilities.js";
3
- import indexPage from "../site/indexPage.js";
3
+ import indexPage from "../origami/indexPage.js";
4
4
 
5
5
  /**
6
6
  * Wraps a tree (typically a SiteTree) to turn a standard site into an
package/src/dev/code.js CHANGED
@@ -1,21 +1,23 @@
1
- import { symbols } from "@weborigami/language";
1
+ import { toString } from "@weborigami/async-tree";
2
+ import { compile } from "@weborigami/language";
2
3
  import getTreeArgument from "../common/getTreeArgument.js";
3
4
 
4
5
  /**
5
6
  * @typedef {import("@weborigami/types").AsyncTree} AsyncTree
6
7
  *
7
8
  * @this {AsyncTree|null}
8
- * @param {any} value
9
+ * @param {import("@weborigami/async-tree").StringLike} input
9
10
  */
10
- export default async function code(value) {
11
- if (value === undefined) {
12
- value = await getTreeArgument(this, arguments, value, "dev:code");
11
+ export default async function code(input) {
12
+ if (input === undefined) {
13
+ input = await getTreeArgument(this, arguments, input, "code");
13
14
  }
14
- if (value === undefined) {
15
+ if (input === undefined) {
15
16
  return undefined;
16
17
  }
17
- const code = value.code ?? value[symbols.codeSymbol];
18
- return code ? functionNames(code) : undefined;
18
+ const text = toString(input);
19
+ const fn = compile.program(text);
20
+ return functionNames(fn.code);
19
21
  }
20
22
 
21
23
  function functionNames(code) {
@@ -15,7 +15,7 @@ import { getBaseUrl } from "./utilities.js";
15
15
  * @param {string} [baseHref]
16
16
  */
17
17
  export default async function audit(treelike, baseHref) {
18
- const tree = await getTreeArgument(this, arguments, treelike, "site:audit");
18
+ const tree = await getTreeArgument(this, arguments, treelike, "audit");
19
19
  const baseUrl = getBaseUrl(baseHref, treelike);
20
20
 
21
21
  let errors = {};
@@ -26,7 +26,7 @@ import { addValueToObject, getBaseUrl } from "./utilities.js";
26
26
  * @returns {Promise<AsyncTree>}
27
27
  */
28
28
  export default async function crawlBuiltin(treelike, baseHref) {
29
- const tree = await getTreeArgument(this, arguments, treelike, "site:crawl");
29
+ const tree = await getTreeArgument(this, arguments, treelike, "crawl");
30
30
  const baseUrl = getBaseUrl(baseHref, treelike);
31
31
 
32
32
  const cache = {};
package/src/dev/debug.js CHANGED
@@ -16,7 +16,7 @@ import OriCommandTransform from "./OriCommandTransform.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, "dev:debug");
19
+ let tree = await getTreeArgument(this, arguments, treelike, "debug");
20
20
 
21
21
  if (!isTransformApplied(DebugTransform, tree)) {
22
22
  tree = transformObject(DebugTransform, tree);
package/src/dev/dev.js CHANGED
@@ -1,5 +1,5 @@
1
+ export { default as indexPage } from "../origami/indexPage.js";
1
2
  export { default as yaml } from "../origami/yaml.js";
2
- export { default as indexPage } from "../site/indexPage.js";
3
3
  export { default as clear } from "../tree/clear.js";
4
4
  export { default as keys } from "../tree/keys.js";
5
5
  export { default as breakpoint } from "./breakpoint.js";
@@ -3,13 +3,13 @@
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1" />
6
- <title>Web Origami Explorer</title>
6
+ <title>Origami Explorer</title>
7
7
  <style>${ <explore.css> }</style>
8
8
  <script>${ <explore.inline.js> }</script>
9
9
  </head>
10
10
  <body>
11
11
  <nav>
12
- <div id="label">Web Origami Explorer</div>
12
+ <div id="label">Origami Explorer</div>
13
13
  <div id="scopeToolbar">
14
14
  <button id="buttonContent">Content</button>
15
15
  <button id="buttonIndex">Index</button>
package/src/dev/help.yaml CHANGED
@@ -65,6 +65,9 @@ Origami:
65
65
  description: Create a document object with the text and data
66
66
  extension:
67
67
  description: Helpers for working with file extensions
68
+ fetch:
69
+ args: (url, options)
70
+ description: Fetch a resource from a URL with support for extensions
68
71
  image:
69
72
  description: Collection of functions for working with images
70
73
  indexPage:
@@ -73,6 +76,9 @@ Origami:
73
76
  inline:
74
77
  args: (text)
75
78
  description: Inline Origami expressions found in the text
79
+ json:
80
+ args: (obj)
81
+ description: Render the object in JSON format
76
82
  jsonKeys:
77
83
  args: (tree)
78
84
  description: Add .keys.json files to a tree
@@ -187,6 +193,9 @@ Tree:
187
193
  deepTake:
188
194
  args: (tree, n)
189
195
  description: The first n values from the deep tree
196
+ deepText:
197
+ args: (tree)
198
+ description: The text values of the deep tree
190
199
  deepValues:
191
200
  args: (tree)
192
201
  description: The in-order leaf values of the tree
@@ -238,8 +247,8 @@ Tree:
238
247
  args: (object)
239
248
  description: True if object can be coerced to a tree
240
249
  json:
241
- args: (obj)
242
- description: Render the object in JSON format
250
+ args: (tree)
251
+ description: Render the tree in JSON format
243
252
  keys:
244
253
  args: (tree)
245
254
  description: The keys of the tree
package/src/dev/serve.js CHANGED
@@ -29,10 +29,12 @@ export default async function serve(treelike, port) {
29
29
  if (!isTransformApplied(ExplorableSiteTransform, tree)) {
30
30
  tree = transformObject(ExplorableSiteTransform, tree);
31
31
  }
32
- } else {
32
+ } else if (arguments.length === 0) {
33
33
  // By default, watch the default tree and add default pages.
34
34
  const withDefaults = await debug.call(this);
35
35
  tree = await watch.call(this, withDefaults);
36
+ } else {
37
+ throw new Error("serve: no tree was provided to serve");
36
38
  }
37
39
 
38
40
  if (port === undefined) {
package/src/dev/svg.js CHANGED
@@ -20,13 +20,7 @@ export default async function svg(treelike, options = {}) {
20
20
  await graphviz.loadWASM();
21
21
  graphvizLoaded = true;
22
22
  }
23
- const tree = await getTreeArgument(
24
- this,
25
- arguments,
26
- treelike,
27
- "dev:svg",
28
- true
29
- );
23
+ const tree = await getTreeArgument(this, arguments, treelike, "svg", true);
30
24
  const dotText = await dot.call(this, tree, options);
31
25
  if (dotText === undefined) {
32
26
  return undefined;
package/src/dev/watch.js CHANGED
@@ -16,12 +16,7 @@ import getTreeArgument from "../common/getTreeArgument.js";
16
16
  */
17
17
  export default async function watch(treelike, fn) {
18
18
  /** @type {any} */
19
- const container = await getTreeArgument(
20
- this,
21
- arguments,
22
- treelike,
23
- "dev:watch"
24
- );
19
+ const container = await getTreeArgument(this, arguments, treelike, "watch");
25
20
 
26
21
  // Watch the indicated tree.
27
22
  await /** @type {any} */ (container).watch?.();
@@ -9,8 +9,9 @@ export default function handlerBuiltins() {
9
9
  "jpeg.handler": handlers.jpegHandler,
10
10
  "jpg.handler": handlers.jpgHandler,
11
11
  "js.handler": handlers.jsHandler,
12
- "jse.handler": handlers.jseHandler,
13
- "jsedocument.handler": handlers.jsedocumentHandler,
12
+ // TODO: Remove deprecated JSE extensions
13
+ "jse.handler": handlers.oriHandler,
14
+ "jsedocument.handler": handlers.oridocumentHandler,
14
15
  "json.handler": handlers.jsonHandler,
15
16
  "md.handler": handlers.mdHandler,
16
17
  "mjs.handler": handlers.mjsHandler,
@@ -14,12 +14,8 @@ export { default as tsHandler } from "./ts.handler.js";
14
14
 
15
15
  export { default as oriHandler } from "./ori.handler.js";
16
16
 
17
- export { default as jseHandler } from "./jse.handler.js";
18
-
19
17
  export { default as oridocumentHandler } from "./oridocument.handler.js";
20
18
 
21
- export { default as jsedocumentHandler } from "./jsedocument.handler.js";
22
-
23
19
  export { default as txtHandler } from "./txt.handler.js";
24
20
 
25
21
  export { default as cssHandler } from "./css.handler.js";
@@ -43,8 +43,10 @@ export default {
43
43
  ...config,
44
44
  };
45
45
 
46
- const mode = options.mode ?? "program";
47
- const fn = compiler(source, { globals, mode });
46
+ const fn = compiler(source, {
47
+ globals,
48
+ mode: "program",
49
+ });
48
50
 
49
51
  let result = await fn.call(parent);
50
52
 
@@ -1,6 +1,7 @@
1
1
  import { extension, trailingSlash } from "@weborigami/async-tree";
2
2
  import { compile } from "@weborigami/language";
3
3
  import builtinsProgram from "../builtinsProgram.js";
4
+ import getConfig from "../cli/getConfig.js";
4
5
  import { toString } from "../common/utilities.js";
5
6
  import getParent from "./getParent.js";
6
7
  import processUnpackedContent from "./processUnpackedContent.js";
@@ -37,17 +38,16 @@ export default {
37
38
  url,
38
39
  };
39
40
 
40
- let globals;
41
- if (options.globals) {
42
- globals = options.globals;
43
- } else {
44
- globals = builtinsProgram();
45
- }
41
+ const config = getConfig(parent) ?? {};
42
+ const globals = {
43
+ ...(options.globals ?? builtinsProgram()),
44
+ ...config,
45
+ };
46
46
 
47
47
  const defineFn = compile.templateDocument(source, {
48
48
  front: options.front,
49
49
  globals,
50
- mode: options.mode ?? "shell",
50
+ mode: "program",
51
51
  });
52
52
 
53
53
  // Invoke the definition to get back the template function
@@ -1,5 +1,5 @@
1
1
  import { isPacked, symbols } from "@weborigami/async-tree";
2
- import { attachWarning, compile } from "@weborigami/language";
2
+ import { compile } from "@weborigami/language";
3
3
  import { parseYaml, toYaml } from "../common/serialize.js";
4
4
  import { toString } from "../common/utilities.js";
5
5
  import parseFrontMatter from "./parseFrontMatter.js";
@@ -17,7 +17,7 @@ import parseFrontMatter from "./parseFrontMatter.js";
17
17
  *
18
18
  * If there is front matter, any Origami expressions in the front matter will be
19
19
  * evaluated. The result will be a plain JavaScript object with the evaluated
20
- * data and a `@text` property containing the document text.
20
+ * data and a `_body` property containing the document text.
21
21
  */
22
22
  export default {
23
23
  mediaType: "text/plain",
@@ -26,7 +26,7 @@ export default {
26
26
  * If the input is already in some packed format, it will be returned as is.
27
27
  *
28
28
  * Otherwise, the properties of the object will be formatted as YAML. If the
29
- * object has a `@text` property, that will be used as the body of the text
29
+ * object has a `_body` property, that will be used as the body of the text
30
30
  * document; otherwise, an empty string will be used.
31
31
  *
32
32
  * @param {any} object
@@ -39,13 +39,11 @@ export default {
39
39
  throw new TypeError("The input to pack must be a JavaScript object.");
40
40
  }
41
41
 
42
- // TODO: Deprecate @text
43
- const text = object._body ?? object["@text"] ?? "";
42
+ const text = object._body ?? "";
44
43
 
45
44
  /** @type {any} */
46
45
  const dataWithoutText = Object.assign({}, object);
47
46
  delete dataWithoutText._body;
48
- delete dataWithoutText["@text"];
49
47
  if (Object.keys(dataWithoutText).length > 0) {
50
48
  const frontMatter = (await toYaml(dataWithoutText)).trimEnd();
51
49
  return `---\n${frontMatter}\n---\n${text}`;
@@ -74,18 +72,7 @@ export default {
74
72
  } else {
75
73
  frontData = parseYaml(frontText);
76
74
  }
77
- // TODO: Deprecate @text
78
75
  unpacked = { ...frontData };
79
- Object.defineProperty(unpacked, "@text", {
80
- configurable: true,
81
- enumerable: true,
82
- get() {
83
- return attachWarning(
84
- body,
85
- "The @text property is deprecated. Use _body instead."
86
- );
87
- },
88
- });
89
76
  Object.defineProperty(unpacked, "_body", {
90
77
  configurable: true,
91
78
  enumerable: true,