@quario/viewer 0.3.0 → 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/CHANGELOG.md +43 -0
- package/README.md +76 -70
- package/lib/check.js +18 -59
- package/lib/chrome.js +3 -4
- package/lib/index.d.ts +34 -26
- package/lib/index.js +57 -38
- package/lib/menu.js +3 -3
- package/lib/stage.js +272 -234
- package/package.json +5 -3
- package/lib/mark.js +0 -40
- package/lib/style.js +0 -123
package/lib/mark.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Unlicensed watermark layout for the continuous sheet: stamp centres along
|
|
3
|
-
* the sheet height, and PDF-like face geometry from the full page box (same
|
|
4
|
-
* atan2 / 75%-diagonal / size-at-54pt proportions as the PDF stamp). Pure
|
|
5
|
-
* numbers — the stage owns the DOM. Appearance is best-effort (ADR 0017).
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/** Reference face size in points — matches the PDF target's stamp probe. */
|
|
9
|
-
export let FACE = 54;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Centre Y of each stamp band covering `[0, sheetHeight)`. Bands are
|
|
13
|
-
* `pageHeight` tall; the last may be short. A short sheet still gets one stamp.
|
|
14
|
-
*
|
|
15
|
-
* @param {number} sheetHeight
|
|
16
|
-
* @param {number} pageHeight
|
|
17
|
-
* @returns {number[]}
|
|
18
|
-
*/
|
|
19
|
-
export let centres = (sheetHeight, pageHeight) => {
|
|
20
|
-
if (!(sheetHeight > 0) || !(pageHeight > 0)) return [];
|
|
21
|
-
let n = Math.max(1, Math.ceil(sheetHeight / pageHeight));
|
|
22
|
-
/** @type {number[]} */
|
|
23
|
-
let out = [];
|
|
24
|
-
for (let i = 0; i < n; i++) {
|
|
25
|
-
let top = i * pageHeight;
|
|
26
|
-
let bottom = Math.min((i + 1) * pageHeight, sheetHeight);
|
|
27
|
-
out.push((top + bottom) / 2);
|
|
28
|
-
}
|
|
29
|
-
return out;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
/** @type {(width: number, height: number) => number} */
|
|
33
|
-
export let angle = (width, height) => (Math.atan2(height, width) * 180) / Math.PI;
|
|
34
|
-
|
|
35
|
-
/** @type {(width: number, height: number) => number} */
|
|
36
|
-
export let span = (width, height) => Math.hypot(width, height) * 0.75;
|
|
37
|
-
|
|
38
|
-
/** @type {(spanLength: number, textWidth: number, at?: number) => number} */
|
|
39
|
-
export let size = (spanLength, textWidth, at = FACE) =>
|
|
40
|
-
textWidth > 0 ? (at * spanLength) / textWidth : at;
|
package/lib/style.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The canonical `q-*` report stylesheet the viewer adopts into its shadow
|
|
3
|
-
* root: how a quario HTML fragment looks on the sheet. The selector contract
|
|
4
|
-
* is the html target's stable markup (SCHEMA.md, "The HTML target"): every
|
|
5
|
-
* item is `.q-item.q-<role>`, every group instance `.q-group[data-group]`,
|
|
6
|
-
* every table `.q-table`, and a keyless render opens with `.q-unlicensed`.
|
|
7
|
-
*
|
|
8
|
-
* `@quario/html` ships the same look as a real stylesheet its consumers can
|
|
9
|
-
* link (`@quario/html/style.css`, and see ADR 0016). This file cannot import
|
|
10
|
-
* it -- the viewer depends on no target package at runtime, and Lit wants a
|
|
11
|
-
* `css` template rather than a file -- so the block between the `shared:`
|
|
12
|
-
* markers below is byte-identical to the one there, and
|
|
13
|
-
* `test/stylesheet.test.js` at the repo root fails when they drift. Edit one,
|
|
14
|
-
* edit the other.
|
|
15
|
-
*
|
|
16
|
-
* Two things stay outside that block, in each direction. The html sheet adds
|
|
17
|
-
* pagination rules a sheet has no use for: it can be printed, this cannot.
|
|
18
|
-
* And the marking diverges on mechanism rather than on result -- a plain host
|
|
19
|
-
* document scales nothing, so there `.q-unlicensed` can carry a watermark
|
|
20
|
-
* itself; here it cannot, and `stage.js` says why.
|
|
21
|
-
*/
|
|
22
|
-
import { css } from "lit";
|
|
23
|
-
|
|
24
|
-
export let REPORT = css`
|
|
25
|
-
/* shared:start */
|
|
26
|
-
|
|
27
|
-
/*
|
|
28
|
-
* The baseline face hangs off the report root rather than off .q-item and
|
|
29
|
-
* .q-table: a direct rule beats an inherited one, so a rule on the items
|
|
30
|
-
* themselves would override the report default an author writes on the
|
|
31
|
-
* document, which the root carries as an inline font-family. The marking is
|
|
32
|
-
* outside the root and keeps its own rule for that reason.
|
|
33
|
-
*/
|
|
34
|
-
.q-report,
|
|
35
|
-
.q-unlicensed {
|
|
36
|
-
font-family: sans-serif;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.q-report,
|
|
40
|
-
.q-group {
|
|
41
|
-
display: flex;
|
|
42
|
-
flex-direction: column;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.q-table {
|
|
46
|
-
width: 100%;
|
|
47
|
-
border-collapse: collapse;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/* A visible text item occupies a line, and a literal newline is a break.
|
|
51
|
-
The class is the hook; a host overrides these the ordinary way, as with
|
|
52
|
-
.q-break. Empty table cells stay contentless, so they take only the
|
|
53
|
-
newline mapping. */
|
|
54
|
-
.q-item {
|
|
55
|
-
min-height: 1lh;
|
|
56
|
-
white-space: pre-line;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.q-table th,
|
|
60
|
-
.q-table td {
|
|
61
|
-
padding: 2pt 6pt;
|
|
62
|
-
text-align: left;
|
|
63
|
-
white-space: pre-line;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.q-table thead th {
|
|
67
|
-
border-bottom: 0.5pt solid #000;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.q-table tfoot td {
|
|
71
|
-
border-top: 0.5pt solid #000;
|
|
72
|
-
font-weight: bold;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.q-item.q-report-header {
|
|
76
|
-
font-size: 14pt;
|
|
77
|
-
font-weight: bold;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.q-item.q-group-header {
|
|
81
|
-
margin-top: 8pt;
|
|
82
|
-
font-weight: bold;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.q-item.q-group-footer {
|
|
86
|
-
margin-bottom: 8pt;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.q-item.q-report-footer {
|
|
90
|
-
margin-top: 10pt;
|
|
91
|
-
border-top: 1pt solid #000;
|
|
92
|
-
padding-top: 4pt;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/* A columned container is a fragmentation context on screen, not only in
|
|
96
|
-
print, so this is what keeps a label whole in one page column -- the rule
|
|
97
|
-
SCHEMA.md's "Page columns" leans on. Scoped to a columned region, so an
|
|
98
|
-
uncolumned report pays nothing. Inside the shared block because both sheets
|
|
99
|
-
need it: a sheet has no pages, but it can have columns. */
|
|
100
|
-
.q-columns .q-group {
|
|
101
|
-
break-inside: avoid;
|
|
102
|
-
}
|
|
103
|
-
/* shared:end */
|
|
104
|
-
|
|
105
|
-
/* The unlicensed-evaluation badge (LICENSE section 6). The viewer presents the
|
|
106
|
-
marking as on-sheet watermark stamps instead -- \`.qv-mark\`, in stage.js
|
|
107
|
-
(ADR 0017) -- so the badge itself is hidden from sight but kept in the
|
|
108
|
-
accessibility tree: the document is what states the marking, and the
|
|
109
|
-
watermark is decoration announcing nothing. Hiding it with \`display: none\`
|
|
110
|
-
would take the statement away from the readers least able to see the
|
|
111
|
-
watermark. */
|
|
112
|
-
.q-unlicensed {
|
|
113
|
-
position: absolute;
|
|
114
|
-
width: 1px;
|
|
115
|
-
height: 1px;
|
|
116
|
-
margin: -1px;
|
|
117
|
-
padding: 0;
|
|
118
|
-
border: 0;
|
|
119
|
-
overflow: hidden;
|
|
120
|
-
clip-path: inset(50%);
|
|
121
|
-
white-space: nowrap;
|
|
122
|
-
}
|
|
123
|
-
`;
|