@weborigami/origami 0.0.44 → 0.0.45
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/exports/exports.js
CHANGED
|
@@ -49,6 +49,7 @@ export * from "../src/builtins/@loaders/md.js";
|
|
|
49
49
|
export * from "../src/builtins/@loaders/mjs.js";
|
|
50
50
|
export { default as loadersOri } from "../src/builtins/@loaders/ori.js";
|
|
51
51
|
export { default as loadersTxt } from "../src/builtins/@loaders/txt.js";
|
|
52
|
+
export { default as loadersWasm } from "../src/builtins/@loaders/wasm.js";
|
|
52
53
|
export * from "../src/builtins/@loaders/xhtml.js";
|
|
53
54
|
export { default as loadersYaml } from "../src/builtins/@loaders/yaml.js";
|
|
54
55
|
export * from "../src/builtins/@loaders/yml.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weborigami/origami",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.45",
|
|
4
4
|
"description": "Web Origami language, CLI, framework, and server",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"typescript": "5.3.3"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@weborigami/async-tree": "0.0.
|
|
23
|
-
"@weborigami/language": "0.0.
|
|
24
|
-
"@weborigami/types": "0.0.
|
|
22
|
+
"@weborigami/async-tree": "0.0.45",
|
|
23
|
+
"@weborigami/language": "0.0.45",
|
|
24
|
+
"@weborigami/types": "0.0.45",
|
|
25
25
|
"exif-parser": "0.1.12",
|
|
26
26
|
"graphviz-wasm": "3.0.1",
|
|
27
27
|
"highlight.js": "11.9.0",
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import * as utilities from "../../common/utilities.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Load a file as JSON.
|
|
3
5
|
*
|
|
4
6
|
* @type {import("@weborigami/language").FileUnpackFunction}
|
|
5
7
|
*/
|
|
6
8
|
export default function unpackJson(input) {
|
|
7
|
-
|
|
9
|
+
const json = utilities.toString(input);
|
|
10
|
+
if (!json) {
|
|
11
|
+
throw new Error("Tried to parse something as JSON but it wasn't text.");
|
|
12
|
+
}
|
|
13
|
+
return JSON.parse(json);
|
|
8
14
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import TextDocument from "../../common/TextDocument.js";
|
|
2
2
|
import { evaluateYaml } from "../../common/serialize.js";
|
|
3
|
+
import * as utilities from "../../common/utilities.js";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Load a file as text document with possible front matter.
|
|
@@ -16,7 +17,10 @@ import { evaluateYaml } from "../../common/serialize.js";
|
|
|
16
17
|
*/
|
|
17
18
|
export default async function unpackText(input, options = {}) {
|
|
18
19
|
const parent = options.parent ?? null;
|
|
19
|
-
const text =
|
|
20
|
+
const text = utilities.toString(input);
|
|
21
|
+
if (!text) {
|
|
22
|
+
throw new Error("Tried to treat something as text but it wasn't text.");
|
|
23
|
+
}
|
|
20
24
|
const regex =
|
|
21
25
|
/^(---\r?\n(?<frontText>[\s\S]*?\r?\n)---\r?\n)(?<body>[\s\S]*$)/;
|
|
22
26
|
const match = regex.exec(text);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import processUnpackedContent from "../../common/processUnpackedContent.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Load a .js file as module's default export or exports.
|
|
5
|
+
*
|
|
6
|
+
* @type {import("@weborigami/language").FileUnpackFunction}
|
|
7
|
+
*/
|
|
8
|
+
export default async function unpackWasm(buffer, options = {}) {
|
|
9
|
+
const wasmModule = await WebAssembly.instantiate(buffer);
|
|
10
|
+
return processUnpackedContent(wasmModule.instance.exports, options.parent);
|
|
11
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as YAMLModule from "yaml";
|
|
2
2
|
import processUnpackedContent from "../../common/processUnpackedContent.js";
|
|
3
3
|
import { evaluateYaml } from "../../common/serialize.js";
|
|
4
|
+
import * as utilities from "../../common/utilities.js";
|
|
4
5
|
|
|
5
6
|
// See notes at serialize.js
|
|
6
7
|
// @ts-ignore
|
|
@@ -13,6 +14,10 @@ const YAML = YAMLModule.default ?? YAMLModule.YAML;
|
|
|
13
14
|
*/
|
|
14
15
|
export default async function unpackYaml(input, options = {}) {
|
|
15
16
|
const parent = options.parent ?? null;
|
|
16
|
-
const
|
|
17
|
+
const yaml = utilities.toString(input);
|
|
18
|
+
if (!yaml) {
|
|
19
|
+
throw new Error("Tried to parse something as YAML but it wasn't text.");
|
|
20
|
+
}
|
|
21
|
+
const data = await evaluateYaml(yaml, options.parent);
|
|
17
22
|
return processUnpackedContent(data, parent);
|
|
18
23
|
}
|
package/src/builtins/@ori.js
CHANGED
|
@@ -73,13 +73,13 @@ async function formatResult(result) {
|
|
|
73
73
|
text = result;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
// If the result is
|
|
76
|
+
// If the result is treelike, attach it to the text output.
|
|
77
77
|
if (Tree.isTreelike(result)) {
|
|
78
78
|
if (typeof text === "string") {
|
|
79
79
|
// @ts-ignore
|
|
80
80
|
text = new String(text);
|
|
81
81
|
}
|
|
82
|
-
/** @type {any} */ (text).unpack = () =>
|
|
82
|
+
/** @type {any} */ (text).unpack = () => result;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
return text;
|