quario 0.1.0 → 0.2.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/CHANGELOG.md +138 -0
- package/README.md +19 -4
- package/lib/index.d.ts +154 -10
- package/lib/index.js +109 -67
- package/lib/license.js +1 -1
- package/lib/locate.js +43 -56
- package/lib/plan.js +328 -136
- package/lib/scope.js +4 -10
- package/lib/stream.js +6 -6
- package/lib/style.js +23 -8
- package/package.json +5 -5
package/lib/scope.js
CHANGED
|
@@ -119,12 +119,6 @@ let RUNNERS = {
|
|
|
119
119
|
};
|
|
120
120
|
},
|
|
121
121
|
};
|
|
122
|
-
/** @type {(fold: Fold) => Eval} */
|
|
123
|
-
let startRunner = ({ fn, per }) => {
|
|
124
|
-
let step = RUNNERS[fn]();
|
|
125
|
-
return (scope) => step(per ? per(scope) : 1);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
122
|
// The runner set as a value, and the two things a band does with it. `extend`
|
|
129
123
|
// is the whole of persist-vs-reset: a group's own runners are fresh per
|
|
130
124
|
// instance, the outer ones fold on unchanged.
|
|
@@ -136,10 +130,10 @@ let runnerSet = (runners) => {
|
|
|
136
130
|
// Declaring no runners is not a change of set, so a band whose `run`
|
|
137
131
|
// block is absent renders under this very value rather than a copy.
|
|
138
132
|
if (!folds.length) return value;
|
|
139
|
-
let started = folds.map(([name,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
133
|
+
let started = folds.map(([name, { fn, per }]) => {
|
|
134
|
+
let step = RUNNERS[fn]();
|
|
135
|
+
return /** @type {[string, Eval]} */ ([name, (scope) => step(per ? per(scope) : 1)]);
|
|
136
|
+
});
|
|
143
137
|
return runnerSet([...runners, ...started]);
|
|
144
138
|
},
|
|
145
139
|
// The per-row detail scope: `@` bound to the row, its running values folded
|
package/lib/stream.js
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
* loop back is a stream rule — the two are independent, and a target breathes
|
|
9
9
|
* while stamping finished pages, which is no walk at all (CONTEXT.md).
|
|
10
10
|
*/
|
|
11
|
-
// The token-join sjabloon renders with
|
|
12
|
-
// `
|
|
13
|
-
// from a cell's tokens without hand-rolling the join.
|
|
14
|
-
export { text } from "sjabloon";
|
|
11
|
+
// The token-join sjabloon renders with — literals verbatim, values through
|
|
12
|
+
// the scalar `display()` rule — re-exported together so event consumers
|
|
13
|
+
// derive display text from a cell's tokens without hand-rolling the join.
|
|
14
|
+
export { display, text } from "sjabloon";
|
|
15
15
|
|
|
16
16
|
/** @type {(value: any) => boolean} */
|
|
17
17
|
let finiteNum = (value) => typeof value === "number" && Number.isFinite(value);
|
|
@@ -42,7 +42,7 @@ export function typed(tokens) {
|
|
|
42
42
|
|
|
43
43
|
// The report's own bands, by the role their items wear (CONTEXT.md, "Band").
|
|
44
44
|
// The page ones are in it although no walk emits them: the question is whose
|
|
45
|
-
// band a role names, not what a walk hands over (ADR
|
|
45
|
+
// band a role names, not what a walk hands over (ADR 0028).
|
|
46
46
|
let REPORT_BANDS = new Set([
|
|
47
47
|
"report-header",
|
|
48
48
|
"report-footer",
|
|
@@ -55,7 +55,7 @@ let REPORT_BANDS = new Set([
|
|
|
55
55
|
* Whether a band item's `role` names one of the report's own bands rather than
|
|
56
56
|
* a group instance's. This says whose band it is, never how to lay one out —
|
|
57
57
|
* what a consumer does with the answer is its own. See SCHEMA.md ("Event
|
|
58
|
-
* stream") for the contract and ADR
|
|
58
|
+
* stream") for the contract and ADR 0028 for why the engine classifies rather
|
|
59
59
|
* than carrying a verdict on the events themselves.
|
|
60
60
|
*
|
|
61
61
|
* @param {string} role An item or image event's `role`.
|
package/lib/style.js
CHANGED
|
@@ -25,6 +25,12 @@ let ALIGNMENTS = ["left", "center", "right"];
|
|
|
25
25
|
// beside the vocabulary it narrows, and `checkImageStyle` below is how the
|
|
26
26
|
// traversal asks for it -- it keeps no second list of its own.
|
|
27
27
|
let IMAGE_STYLES = ["align", "background"];
|
|
28
|
+
// The declarations a report default accepts. A report default states what the
|
|
29
|
+
// document is set in, so it carries only the two declarations that describe a
|
|
30
|
+
// typeface -- and, unlike the rest of the vocabulary, only the two no band-role
|
|
31
|
+
// default has to argue with. Anything else is a definition error rather than a
|
|
32
|
+
// silent no-op, exactly as on an image (SCHEMA.md, "Report default").
|
|
33
|
+
let REPORT_STYLES = ["family", "size"];
|
|
28
34
|
/** @type {Record<string, StyleSpec>} */
|
|
29
35
|
let STYLES = {
|
|
30
36
|
family: spec(
|
|
@@ -36,6 +42,7 @@ let STYLES = {
|
|
|
36
42
|
italic: FLAG,
|
|
37
43
|
underline: FLAG,
|
|
38
44
|
strikethrough: FLAG,
|
|
45
|
+
uppercase: FLAG,
|
|
39
46
|
color: COLOR,
|
|
40
47
|
background: COLOR,
|
|
41
48
|
align: spec("expected left, center, or right", (value) => ALIGNMENTS.includes(value)),
|
|
@@ -55,12 +62,20 @@ export let checkStyle = (name, value) => {
|
|
|
55
62
|
return rule.ok(value) ? null : rule.msg;
|
|
56
63
|
};
|
|
57
64
|
|
|
58
|
-
// The same check narrowed to
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
// The same check narrowed to a subset of the vocabulary, so a declaration a
|
|
66
|
+
// node cannot wear is refused as pointedly as an unknown name rather than
|
|
67
|
+
// silently doing nothing. A node that takes part of the vocabulary names the
|
|
68
|
+
// checker this makes rather than passing a flag, which is what keeps each
|
|
69
|
+
// subset and its wording together, here.
|
|
70
|
+
//
|
|
71
|
+
// `subject` completes "does not apply to ___", so it carries its own article.
|
|
72
|
+
/** @type {(allowed: string[], subject: string) => (name: string, value: any) => string | null} */
|
|
73
|
+
let narrowed = (allowed, subject) => (name, value) =>
|
|
74
|
+
Object.hasOwn(STYLES, name) && !allowed.includes(name)
|
|
75
|
+
? 'style "' + name + '" does not apply to ' + subject
|
|
66
76
|
: checkStyle(name, value);
|
|
77
|
+
|
|
78
|
+
export let checkImageStyle = narrowed(IMAGE_STYLES, "an image");
|
|
79
|
+
// "a report default" rather than the key's name: the key is `style` like every
|
|
80
|
+
// other one, so the message has to say which `style` refused it.
|
|
81
|
+
export let checkReportStyle = narrowed(REPORT_STYLES, "a report default");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "quario",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "A tiny, runtime-neutral report engine — in the makings, not yet released",
|
|
5
5
|
"homepage": "https://getquario.com",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"postpack": "node -e \"require('fs').rmSync('LICENSE',{force:true})\""
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"padvinder": "^0.
|
|
37
|
-
"sjabloon": "^0.
|
|
38
|
-
"xprsn": "^0.
|
|
36
|
+
"padvinder": "^0.9.0",
|
|
37
|
+
"sjabloon": "^0.12.0",
|
|
38
|
+
"xprsn": "^0.11.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@arethetypeswrong/cli": "^0.18.3",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"sjabloon",
|
|
52
52
|
"padvinder"
|
|
53
53
|
],
|
|
54
|
-
"limit": "
|
|
54
|
+
"limit": "9 kB"
|
|
55
55
|
}
|
|
56
56
|
],
|
|
57
57
|
"engines": {
|