@weborigami/origami 0.3.4-jse.8 → 0.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weborigami/origami",
3
- "version": "0.3.4-jse.8",
3
+ "version": "0.4.0",
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.8",
20
+ "@weborigami/async-tree": "0.4.0",
21
21
  "@weborigami/json-feed-to-rss": "1.0.0",
22
- "@weborigami/language": "0.3.4-jse.8",
23
- "@weborigami/types": "0.3.4-jse.8",
22
+ "@weborigami/language": "0.4.0",
23
+ "@weborigami/types": "0.4.0",
24
24
  "css-tree": "3.1.0",
25
25
  "exif-parser": "0.1.12",
26
26
  "graphviz-wasm": "3.0.2",
@@ -51,19 +51,25 @@ export default function builtinsProgram() {
51
51
 
52
52
  function deprecateFunctions(fns, oldPrefix, newPrefix) {
53
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
- };
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
+ };
67
73
  Object.assign(wrappedFn, value);
68
74
  return [key, wrappedFn];
69
75
  });
@@ -5,6 +5,7 @@ export default function getConfig(tree) {
5
5
  if (!tree) {
6
6
  return null;
7
7
  }
8
+ /** @type {any} */
8
9
  const root = Tree.root(tree);
9
10
  return root.config;
10
11
  }
package/src/dev/dev.js CHANGED
@@ -1,3 +1,5 @@
1
+ export { default as yaml } from "../origami/yaml.js";
2
+ export { default as indexPage } from "../site/indexPage.js";
1
3
  export { default as clear } from "../tree/clear.js";
2
4
  export { default as keys } from "../tree/keys.js";
3
5
  export { default as breakpoint } from "./breakpoint.js";
@@ -38,7 +38,11 @@ function removeDocumentPath(path) {
38
38
  function selectMode(newMode) {
39
39
  const currentMode = getModeFromLocation();
40
40
  if (newMode !== currentMode) {
41
- let newPath = removeDocumentPath(frame.contentDocument.location.pathname);
41
+ const location = frame.contentDocument.location;
42
+ let newPath =
43
+ location.href === "about:blank"
44
+ ? ""
45
+ : removeDocumentPath(location.pathname);
42
46
  const currentExtension = modes[currentMode];
43
47
  if (currentExtension && newPath.endsWith(currentExtension)) {
44
48
  // Remove the current extension.
@@ -5,7 +5,7 @@
5
5
  <meta name="viewport" content="width=device-width,initial-scale=1" />
6
6
  <title>Web Origami Explorer</title>
7
7
  <style>${ <explore.css> }</style>
8
- <script>${ <explore.js.inline> }</script>
8
+ <script>${ <explore.inline.js> }</script>
9
9
  </head>
10
10
  <body>
11
11
  <nav>
@@ -43,7 +43,7 @@ export default {
43
43
  ...config,
44
44
  };
45
45
 
46
- const mode = options.mode ?? "shell";
46
+ const mode = options.mode ?? "program";
47
47
  const fn = compiler(source, { globals, mode });
48
48
 
49
49
  let result = await fn.call(parent);
@@ -26,6 +26,6 @@ export default async function files(...keys) {
26
26
  const resolved = path.resolve(basePath, relativePath);
27
27
 
28
28
  const result = new OrigamiFiles(resolved);
29
- result.handlers = getHandlers(this);
29
+ /** @type {any} */ (result).handlers = getHandlers(this);
30
30
  return result;
31
31
  }
@@ -1,6 +1,9 @@
1
1
  import { Tree } from "@weborigami/async-tree";
2
2
  import { attachWarning, jsGlobals } from "@weborigami/language";
3
3
 
4
+ /**
5
+ * @this {import("@weborigami/types").AsyncTree}
6
+ */
4
7
  export default async function js(...keys) {
5
8
  const result = await Tree.traverseOrThrow.call(this, jsGlobals, ...keys);
6
9
  return attachWarning(
@@ -1,5 +1,6 @@
1
1
  import { Tree, scope as scopeFn } from "@weborigami/async-tree";
2
2
  import { attachWarning } from "@weborigami/language";
3
+ import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
3
4
 
4
5
  /**
5
6
  * @typedef {import("@weborigami/types").AsyncTree} AsyncTree
@@ -8,6 +9,7 @@ import { attachWarning } from "@weborigami/language";
8
9
  * @param {string[]} keys
9
10
  */
10
11
  export default async function scope(...keys) {
12
+ assertTreeIsDefined(this, "scope");
11
13
  const key = keys.shift();
12
14
  let value;
13
15
  try {
@@ -11,7 +11,7 @@ import { jsedocumentHandler } from "../handlers/handlers.js";
11
11
  * @typedef {import("@weborigami/async-tree").StringLike} StringLike
12
12
  *
13
13
  * @this {AsyncTree|null}
14
- * @param {StringLike} input
14
+ * @param {StringLike & {_body?: StringLike}} input
15
15
  */
16
16
  export default async function inline(input) {
17
17
  assertTreeIsDefined(this, "inline");