@weborigami/origami 0.6.7 → 0.6.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.
package/main.js CHANGED
@@ -1,7 +1,6 @@
1
1
  export { default as documentObject } from "./src/common/documentObject.js";
2
2
  export * from "./src/common/serialize.js";
3
3
  export * as Dev from "./src/dev/dev.js";
4
- export { default as initializeBuiltins } from "./src/initializeBuiltins.js";
5
4
  export * as Origami from "./src/origami/origami.js";
6
5
  export { default as origamiHighlightDefinition } from "./src/origami/origamiHighlightDefinition.js";
7
6
  export { default as constructResponse } from "./src/server/constructResponse.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weborigami/origami",
3
- "version": "0.6.7",
3
+ "version": "0.6.8",
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.9.3"
18
18
  },
19
19
  "dependencies": {
20
- "@weborigami/async-tree": "0.6.7",
20
+ "@weborigami/async-tree": "0.6.8",
21
21
  "@weborigami/json-feed-to-rss": "1.0.1",
22
- "@weborigami/language": "0.6.7",
22
+ "@weborigami/language": "0.6.8",
23
23
  "css-tree": "3.1.0",
24
24
  "graphviz-wasm": "3.0.2",
25
25
  "highlight.js": "11.11.1",
package/src/cli/cli.js CHANGED
@@ -5,7 +5,6 @@ import { formatError, projectRootFromPath } from "@weborigami/language";
5
5
  import path from "node:path";
6
6
  import process, { stdout } from "node:process";
7
7
  import help from "../dev/help.js";
8
- import initializeBuiltins from "../initializeBuiltins.js";
9
8
  import ori from "../origami/ori.js";
10
9
 
11
10
  const TypedArray = Object.getPrototypeOf(Uint8Array);
@@ -13,10 +12,6 @@ const TypedArray = Object.getPrototypeOf(Uint8Array);
13
12
  async function main(...args) {
14
13
  const expression = args.join(" ");
15
14
 
16
- // Need to initialize builtins before calling projectRoot, which instantiates
17
- // an OrigamiFileMap object that handles extensions, which requires builtins.
18
- initializeBuiltins();
19
-
20
15
  // Find the project root.
21
16
  const currentDirectory = process.cwd();
22
17
  const projectRoot = await projectRootFromPath(currentDirectory);
@@ -39,8 +34,8 @@ async function main(...args) {
39
34
  result instanceof ArrayBuffer
40
35
  ? new Uint8Array(result)
41
36
  : typeof result === "string" || result instanceof TypedArray
42
- ? result
43
- : String(result);
37
+ ? result
38
+ : String(result);
44
39
  await stdout.write(output);
45
40
 
46
41
  // If stdout points to the console, and the result didn't end in a newline,
@@ -28,7 +28,7 @@ export default function OriCommandTransform(Base) {
28
28
  }
29
29
 
30
30
  // Key is an Origami command; invoke it.
31
- const globals = await projectGlobals();
31
+ const globals = await projectGlobals(/** @type {any} */ (this));
32
32
  const commandName = trailingSlash.remove(key.slice(1).trim());
33
33
 
34
34
  // Look for command as a global or Dev command
package/src/dev/help.yaml CHANGED
@@ -105,7 +105,7 @@ Origami:
105
105
  post:
106
106
  args: (url, data)
107
107
  description: POST the given data to the URL
108
- project:
108
+ projectRoot:
109
109
  description: The root folder for the current Origami project
110
110
  redirect:
111
111
  args: (url, options)
package/src/dev/watch.js CHANGED
@@ -16,7 +16,7 @@ export default async function watch(maplike, fn) {
16
16
  const container = await getTreeArgument(maplike, "watch");
17
17
 
18
18
  // Watch the indicated tree.
19
- await /** @type {any} */ (container).watch?.();
19
+ /** @type {any} */ (container).watch?.();
20
20
 
21
21
  if (fn === undefined) {
22
22
  return container;
@@ -4,7 +4,7 @@ import { handleExtension } from "@weborigami/language";
4
4
  * Extend the JavaScript `fetch` function to implicity return an ArrayBuffer
5
5
  * with an unpack() method if the resource has a known file extension.
6
6
  */
7
- export default async function fetchBuiltin(resource, options) {
7
+ export default async function fetchBuiltin(resource, options, state) {
8
8
  const response = await fetch(resource, options);
9
9
  if (!response.ok) {
10
10
  return undefined;
@@ -14,5 +14,7 @@ export default async function fetchBuiltin(resource, options) {
14
14
 
15
15
  const url = new URL(resource);
16
16
  const key = url.pathname;
17
- return handleExtension(value, key);
17
+
18
+ return handleExtension(value, key, state.container);
18
19
  }
20
+ fetchBuiltin.needsState = true;
@@ -30,7 +30,7 @@ export default async function ori(expression, options = {}) {
30
30
 
31
31
  // Add Dev builtins as top-level globals
32
32
  const globals = {
33
- ...(await projectGlobals()),
33
+ ...(await projectGlobals(parent)),
34
34
  ...dev,
35
35
  };
36
36
 
@@ -47,17 +47,6 @@ export default async function ori(expression, options = {}) {
47
47
  // Execute
48
48
  let result = await fn();
49
49
 
50
- // if (result === undefined) {
51
- // // Was the code a path traversal?
52
- // const wasTraversal =
53
- // fn.code[0] === ops.unpack ||
54
- // (fn.code[0] instanceof Array && fn.code[0][0] === ops.scope);
55
- // if (wasTraversal) {
56
- // // Yes, probably an error
57
- // console.warn(`ori: warning: undefined ${highlightError(expression)}`);
58
- // }
59
- // }
60
-
61
50
  // If result was a function, execute it.
62
51
  if (typeof result === "function") {
63
52
  result = await result();
@@ -1,23 +0,0 @@
1
- import { builtins } from "@weborigami/language";
2
- import * as dev from "./dev/dev.js";
3
- import help from "./dev/help.js";
4
- import * as origami from "./origami/origami.js";
5
-
6
- let initialized = false;
7
-
8
- /**
9
- * Pass the Origami builtins to the compiler.
10
- */
11
- export default function initializeBuiltins() {
12
- if (!initialized) {
13
- const origamiBuiltins = {
14
- Dev: dev,
15
- Origami: origami,
16
- "help:": help,
17
- };
18
-
19
- Object.assign(builtins, origamiBuiltins);
20
- }
21
-
22
- initialized = true;
23
- }