functionalscript 0.13.0 → 0.13.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/html/module.f.d.ts +14 -0
- package/html/module.f.js +21 -2
- package/package.json +1 -1
- package/website/module.f.d.ts +2 -2
- package/website/module.f.js +7 -11
package/html/module.f.d.ts
CHANGED
|
@@ -29,5 +29,19 @@ export declare const html: (_: Element) => List<string>;
|
|
|
29
29
|
* Renders an HTML element tree to a final string.
|
|
30
30
|
*/
|
|
31
31
|
export declare const htmlToString: (_: Element) => string;
|
|
32
|
+
/**
|
|
33
|
+
* Renders a complete UTF-8 encoded HTML document as a `Vec`.
|
|
34
|
+
*
|
|
35
|
+
* Produces a full page with `<!DOCTYPE html>`, a `<head>` containing a UTF-8
|
|
36
|
+
* `<meta charset>` and a responsive-viewport `<meta>` followed by any extra
|
|
37
|
+
* `head` nodes, and a `<body>` containing the provided `body` nodes.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* htmlUtf8(['title', 'My Page'])(['h1', 'Hello'])
|
|
42
|
+
* // Vec of UTF-8 bytes for:
|
|
43
|
+
* // <!DOCTYPE html><html><head><meta charset="UTF-8">...<title>My Page</title></head><body><h1>Hello</h1></body></html>
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
32
46
|
export declare const htmlUtf8: (...head: readonly Node[]) => (...body: readonly Node[]) => Vec;
|
|
33
47
|
export {};
|
package/html/module.f.js
CHANGED
|
@@ -89,5 +89,24 @@ export const html = compose(element)(listConcat(['<!DOCTYPE html>']));
|
|
|
89
89
|
* Renders an HTML element tree to a final string.
|
|
90
90
|
*/
|
|
91
91
|
export const htmlToString = compose(html)(stringConcat);
|
|
92
|
-
const
|
|
93
|
-
|
|
92
|
+
const commonHead = [
|
|
93
|
+
['meta', { charset: 'UTF-8' }],
|
|
94
|
+
['meta', { name: 'viewport', content: 'width=device-width,initial-scale=1.0' }],
|
|
95
|
+
];
|
|
96
|
+
/**
|
|
97
|
+
* Renders a complete UTF-8 encoded HTML document as a `Vec`.
|
|
98
|
+
*
|
|
99
|
+
* Produces a full page with `<!DOCTYPE html>`, a `<head>` containing a UTF-8
|
|
100
|
+
* `<meta charset>` and a responsive-viewport `<meta>` followed by any extra
|
|
101
|
+
* `head` nodes, and a `<body>` containing the provided `body` nodes.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* htmlUtf8(['title', 'My Page'])(['h1', 'Hello'])
|
|
106
|
+
* // Vec of UTF-8 bytes for:
|
|
107
|
+
* // <!DOCTYPE html><html><head><meta charset="UTF-8">...<title>My Page</title></head><body><h1>Hello</h1></body></html>
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export const htmlUtf8 = (...head) => (...body) => utf8(htmlToString(['html',
|
|
111
|
+
['head', ...commonHead, ...head],
|
|
112
|
+
['body', ...body]]));
|
package/package.json
CHANGED
package/website/module.f.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type WriteFile } from '../types/effects/node/module.f.ts';
|
|
2
2
|
import { type Effect } from '../types/effects/module.f.ts';
|
|
3
|
-
declare const _default: () => Effect<
|
|
3
|
+
declare const _default: () => Effect<WriteFile, number>;
|
|
4
4
|
export default _default;
|
package/website/module.f.js
CHANGED
|
@@ -3,17 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { htmlUtf8 } from "../html/module.f.js";
|
|
7
7
|
import { writeFile } from "../types/effects/node/module.f.js";
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
]
|
|
15
|
-
]));
|
|
16
|
-
const program = begin
|
|
17
|
-
.step(() => writeFile('index.html', html))
|
|
8
|
+
import { pure } from "../types/effects/module.f.js";
|
|
9
|
+
const html = htmlUtf8()(['a',
|
|
10
|
+
{ href: 'https://github.com/functionalscript/functionalscript' },
|
|
11
|
+
'GitHub Repository'
|
|
12
|
+
]);
|
|
13
|
+
const program = writeFile('index.html', html)
|
|
18
14
|
.step(() => pure(0));
|
|
19
15
|
export default () => program;
|