@weborigami/origami 0.4.2 → 0.5.1
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 +3 -6
- package/package.json +12 -12
- package/src/builtinsProgram.js +49 -71
- package/src/builtinsShell.js +3 -48
- package/src/common/documentObject.js +4 -16
- package/src/common/utilities.js +3 -3
- package/src/dev/ExplorableSiteTransform.js +1 -1
- package/src/dev/code.js +10 -8
- package/src/dev/crawler/audit.js +1 -1
- package/src/dev/crawler/crawl.js +1 -1
- package/src/dev/debug.js +1 -1
- package/src/dev/dev.js +1 -1
- package/src/dev/explore.ori +2 -2
- package/src/dev/help.yaml +11 -2
- package/src/dev/serve.js +3 -1
- package/src/dev/svg.js +1 -7
- package/src/dev/watch.js +1 -6
- package/src/handlers/handlerBuiltins.js +3 -2
- package/src/handlers/handlers.js +0 -4
- package/src/handlers/ori.handler.js +4 -2
- package/src/handlers/oridocument.handler.js +7 -7
- package/src/handlers/txt.handler.js +4 -17
- package/src/origami/fetch.js +22 -0
- package/src/{image → origami/image}/format.js +5 -3
- package/src/{image → origami/image}/resize.js +1 -1
- package/src/{site → origami}/indexPage.js +1 -1
- package/src/{text → origami}/inline.js +5 -10
- package/src/{site → origami}/jsonKeys.js +11 -12
- package/src/{text → origami}/mdHtml.js +1 -2
- package/src/origami/origami.js +15 -2
- package/src/{text → origami}/origamiHighlightDefinition.js +5 -20
- package/src/origami/project.js +2 -0
- package/src/{site → origami}/sitemap.js +1 -1
- package/src/{site → origami}/static.js +11 -12
- package/src/tree/addNextPrevious.js +1 -1
- package/src/tree/clear.js +1 -1
- package/src/tree/deepMap.js +1 -1
- package/src/tree/deepReverse.js +1 -1
- package/src/tree/deepTake.js +1 -1
- package/src/tree/deepValues.js +1 -1
- package/src/tree/defineds.js +1 -6
- package/src/tree/first.js +1 -1
- package/src/tree/group.js +1 -1
- package/src/tree/inners.js +1 -1
- package/src/tree/keys.js +1 -1
- package/src/tree/length.js +1 -1
- package/src/tree/map.js +6 -1
- package/src/tree/paginate.js +1 -6
- package/src/tree/parent.js +1 -1
- package/src/tree/plain.js +1 -1
- package/src/tree/reverse.js +1 -1
- package/src/tree/shuffle.js +1 -1
- package/src/tree/sort.js +1 -1
- package/src/tree/take.js +1 -1
- package/src/tree/values.js +1 -1
- package/src/builtinsJse.js +0 -77
- package/src/handlers/jse.handler.js +0 -17
- package/src/handlers/jsedocument.handler.js +0 -17
- package/src/image/formatFn.js +0 -18
- package/src/origami/regexMatch.js +0 -16
- package/src/protocols/inherited.js +0 -26
- package/src/protocols/new.js +0 -51
- package/src/protocols/scope.js +0 -31
- package/src/site/site.js +0 -7
- package/src/text/text.js +0 -5
- /package/src/{text → origami}/document.js +0 -0
- /package/src/{text → origami}/htmlDom.js +0 -0
- /package/src/{image → origami/image}/image.js +0 -0
- /package/src/{site → origami}/redirect.js +0 -0
- /package/src/{site → origami}/rss.js +0 -0
- /package/src/{site → origami}/slug.js +0 -0
package/src/image/formatFn.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import sharp from "sharp";
|
|
2
|
-
import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Return a function that transforms an input image to a different format.
|
|
6
|
-
*
|
|
7
|
-
* @this {import("@weborigami/types").AsyncTree|null}
|
|
8
|
-
* @param {keyof import("sharp").FormatEnum|import("sharp").AvailableFormatInfo}
|
|
9
|
-
* format
|
|
10
|
-
* @param {any} options
|
|
11
|
-
*/
|
|
12
|
-
export default function imageFormatFn(format, options) {
|
|
13
|
-
assertTreeIsDefined(this, "image/formatFn");
|
|
14
|
-
return (buffer) =>
|
|
15
|
-
buffer instanceof Uint8Array || buffer instanceof ArrayBuffer
|
|
16
|
-
? sharp(buffer).toFormat(format, options).toBuffer()
|
|
17
|
-
: undefined;
|
|
18
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { attachWarning } from "@weborigami/language";
|
|
2
|
-
|
|
3
|
-
const parsers = {};
|
|
4
|
-
|
|
5
|
-
// TODO: Remove this deprecated function
|
|
6
|
-
export default function regexMatch(text, regex) {
|
|
7
|
-
if (!parsers[regex]) {
|
|
8
|
-
const regexp = new RegExp(regex);
|
|
9
|
-
parsers[regex] = (input) => input.match(regexp)?.groups;
|
|
10
|
-
}
|
|
11
|
-
const match = parsers[regex](text);
|
|
12
|
-
return attachWarning(
|
|
13
|
-
match,
|
|
14
|
-
"The regexMatch function is deprecated. Use a JavaScript regular expression instead."
|
|
15
|
-
);
|
|
16
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { scope, Tree } from "@weborigami/async-tree";
|
|
2
|
-
import { attachWarning } from "@weborigami/language";
|
|
3
|
-
import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Return the inherited value (if any) for the indicated key.
|
|
7
|
-
*
|
|
8
|
-
* @typedef {import("@weborigami/types").AsyncTree} AsyncTree
|
|
9
|
-
*
|
|
10
|
-
* @this {AsyncTree|null}
|
|
11
|
-
* @param {string[]} keys
|
|
12
|
-
*/
|
|
13
|
-
export default async function inherited(...keys) {
|
|
14
|
-
assertTreeIsDefined(this, "inherited");
|
|
15
|
-
const key = keys.shift();
|
|
16
|
-
if (!this?.parent) {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
const parentScope = scope(this.parent);
|
|
20
|
-
const value = await parentScope.get(key);
|
|
21
|
-
const result = keys.length > 0 ? await Tree.traverse(value, ...keys) : value;
|
|
22
|
-
return attachWarning(
|
|
23
|
-
result,
|
|
24
|
-
"The inherited protocol is deprecated. In most cases it can be dropped."
|
|
25
|
-
);
|
|
26
|
-
}
|
package/src/protocols/new.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { isUnpackable, scope as scopeFn, Tree } from "@weborigami/async-tree";
|
|
2
|
-
import { attachWarning } from "@weborigami/language";
|
|
3
|
-
import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Find the indicated class constructor in scope, then return a function which
|
|
7
|
-
* invokes it with `new`.
|
|
8
|
-
*
|
|
9
|
-
* This can also take a single argument that is a class.
|
|
10
|
-
*
|
|
11
|
-
* @this {import("@weborigami/types").AsyncTree|null}
|
|
12
|
-
* @param {...any} keys
|
|
13
|
-
*/
|
|
14
|
-
export default async function instantiate(...keys) {
|
|
15
|
-
assertTreeIsDefined(this, "new");
|
|
16
|
-
let constructor;
|
|
17
|
-
|
|
18
|
-
const scope = this ? scopeFn(this) : null;
|
|
19
|
-
if (
|
|
20
|
-
keys.length === 1 &&
|
|
21
|
-
(typeof keys[0] === "object" || typeof keys[0] === "function")
|
|
22
|
-
) {
|
|
23
|
-
constructor = keys[0];
|
|
24
|
-
} else if (globalThis[keys[0]]) {
|
|
25
|
-
// Backward compat
|
|
26
|
-
constructor = globalThis[keys[0]];
|
|
27
|
-
} else if (scope) {
|
|
28
|
-
constructor = await Tree.traverseOrThrow(scope, ...keys);
|
|
29
|
-
} else {
|
|
30
|
-
throw new TypeError(`new: The scope isn't defined.`);
|
|
31
|
-
}
|
|
32
|
-
if (isUnpackable(constructor)) {
|
|
33
|
-
constructor = await constructor.unpack();
|
|
34
|
-
}
|
|
35
|
-
// Origami may pass `undefined` as the first argument to the constructor. We
|
|
36
|
-
// don't pass that along, because constructors like `Date` don't like it.
|
|
37
|
-
const result = (...args) => {
|
|
38
|
-
const object =
|
|
39
|
-
args.length === 1 && args[0] === undefined
|
|
40
|
-
? new constructor()
|
|
41
|
-
: new constructor(...args);
|
|
42
|
-
if (Tree.isAsyncTree(object)) {
|
|
43
|
-
object.parent = scope;
|
|
44
|
-
}
|
|
45
|
-
return object;
|
|
46
|
-
};
|
|
47
|
-
return attachWarning(
|
|
48
|
-
result,
|
|
49
|
-
"The new:Class() syntax is deprecated. Use `new Class()` instead."
|
|
50
|
-
);
|
|
51
|
-
}
|
package/src/protocols/scope.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Tree, scope as scopeFn } from "@weborigami/async-tree";
|
|
2
|
-
import { attachWarning } from "@weborigami/language";
|
|
3
|
-
import assertTreeIsDefined from "../common/assertTreeIsDefined.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {import("@weborigami/types").AsyncTree} AsyncTree
|
|
7
|
-
*
|
|
8
|
-
* @this {AsyncTree|null}
|
|
9
|
-
* @param {string[]} keys
|
|
10
|
-
*/
|
|
11
|
-
export default async function scope(...keys) {
|
|
12
|
-
assertTreeIsDefined(this, "scope");
|
|
13
|
-
const key = keys.shift();
|
|
14
|
-
let value;
|
|
15
|
-
try {
|
|
16
|
-
// Look up key in scope but don't throw if it's undefined
|
|
17
|
-
const thisScope = scopeFn(this);
|
|
18
|
-
value = await thisScope.get(key);
|
|
19
|
-
} catch (error) {
|
|
20
|
-
if (error instanceof ReferenceError) {
|
|
21
|
-
value = undefined;
|
|
22
|
-
} else {
|
|
23
|
-
throw error;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
const result = keys.length > 0 ? await Tree.traverse(value, ...keys) : value;
|
|
27
|
-
return attachWarning(
|
|
28
|
-
result,
|
|
29
|
-
"The scope protocol is deprecated. In most cases it can be dropped."
|
|
30
|
-
);
|
|
31
|
-
}
|
package/src/site/site.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { default as indexPage } from "./indexPage.js";
|
|
2
|
-
export { default as jsonKeys } from "./jsonKeys.js";
|
|
3
|
-
export { default as redirect } from "./redirect.js";
|
|
4
|
-
export { default as rss } from "./rss.js";
|
|
5
|
-
export { default as sitemap } from "./sitemap.js";
|
|
6
|
-
export { default as slug } from "./slug.js";
|
|
7
|
-
export { default as staticBuiltin } from "./static.js";
|
package/src/text/text.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { taggedTemplateIndent as indent } from "@weborigami/language";
|
|
2
|
-
export { default as document } from "./document.js";
|
|
3
|
-
export { default as htmlDom } from "./htmlDom.js";
|
|
4
|
-
export { default as inline } from "./inline.js";
|
|
5
|
-
export { default as mdHtml } from "./mdHtml.js";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|