fleuron 0.1.1 → 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.
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * A request is an edit plus, sometimes, a render: inputs travel when
5
5
  * they change rather than once per frame, and the module keeps every
6
- * stage between them. Each request carries a generation, which the
6
+ * stage between them. Each request names a generation, which the
7
7
  * worker echoes back untouched. The host raises it whenever the
8
8
  * input goes stale, and a reply that comes back behind the current
9
9
  * one is dropped rather than painted.
@@ -15,13 +15,20 @@ export interface Source {
15
15
  /** Its markdown. */
16
16
  text: string;
17
17
  }
18
+ /** One stylesheet: what warnings call it, and its CSS. */
19
+ export interface Sheet {
20
+ /** The name a warning in this sheet is reported under, as `preset.css:12:3`. */
21
+ name: string;
22
+ /** Its CSS. */
23
+ css: string;
24
+ }
18
25
  /** What names a book: its title, its author, and whatever else. */
19
26
  export interface Metadata {
20
27
  /** Title, for the half-title and running heads. */
21
28
  title?: string;
22
29
  /** Author, for the title page. */
23
30
  author?: string;
24
- /** Anything else a frontend carries, such as `language`. */
31
+ /** Anything else a frontend read, such as `language`. */
25
32
  extra?: Record<string, string>;
26
33
  }
27
34
  /** One input reaching the engine. */
@@ -83,10 +90,14 @@ export type Op =
83
90
  op: 'content';
84
91
  json: string;
85
92
  }
86
- /** The author stylesheet, as CSS text. */
93
+ /**
94
+ * The author styling, as named sheets in cascade order. Later
95
+ * sheets win, and a warning names the sheet its declaration was
96
+ * written in.
97
+ */
87
98
  | {
88
99
  op: 'style';
89
- css: string;
100
+ sheets: Sheet[];
90
101
  };
91
102
  /**
92
103
  * What a request wants back, if anything: a display structure, a PDF, or
@@ -108,6 +119,19 @@ export interface Request {
108
119
  want?: Want;
109
120
  /** Which face `want: 'font'` is asking for. */
110
121
  font?: number;
122
+ /**
123
+ * With `count`, which pages of `want: 'preview'`'s answer to send:
124
+ * `first` pages counting from 0, `count` of them. Leaving either
125
+ * out asks for the whole book.
126
+ *
127
+ * A ranged preview is a question rather than a render: it answers
128
+ * "what is on this page" of whatever the book already is, not "what
129
+ * did this edit produce", so it neither overtakes nor is overtaken
130
+ * by another render or range in the same batch.
131
+ */
132
+ first?: number;
133
+ /** See {@link Request.first}. */
134
+ count?: number;
111
135
  }
112
136
  /** The bytes a request produced: a display structure, a PDF, or a font file. */
113
137
  export interface Rendered {
@@ -146,8 +170,14 @@ export interface Failed {
146
170
  }
147
171
  /** What comes back for a request. */
148
172
  export type Response = Rendered | Applied | Superseded | Failed;
149
- /** Whether a reply carries bytes. */
173
+ /** Whether a reply came back with bytes. */
150
174
  export declare function isRendered(response: Response): response is Rendered;
151
175
  /** Whether a reply is the engine reporting trouble. */
152
176
  export declare function isFailed(response: Response): response is Failed;
177
+ /**
178
+ * The style op, written either way: one sheet as CSS text, which the
179
+ * engine calls `author.css`, or the layers a host built its styling
180
+ * out of, in cascade order.
181
+ */
182
+ export declare function styleOp(css: string | Sheet[]): Op;
153
183
  //# sourceMappingURL=protocol.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,iEAAiE;AACjE,MAAM,WAAW,MAAM;IACrB,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,mEAAmE;AACnE,MAAM,WAAW,QAAQ;IACvB,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED,qCAAqC;AACrC,MAAM,MAAM,EAAE;AACZ,mEAAmE;AACjE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE;AACnC;;;;GAIG;G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X,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,IAAI,CAAC;CAClB;AAED,sDAAsD;AACtD,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qCAAqC;AACrC,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,UAAU,GAAG,MAAM,CAAC;AAEhE,4CAA4C;AAC5C,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,IAAI,QAAQ,CAEnE;AAED,uDAAuD;AACvD,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,IAAI,MAAM,CAE/D;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,EAAE,GAAG,EAAE,CAEjD"}
package/dist/protocol.js CHANGED
@@ -3,12 +3,12 @@
3
3
  *
4
4
  * A request is an edit plus, sometimes, a render: inputs travel when
5
5
  * they change rather than once per frame, and the module keeps every
6
- * stage between them. Each request carries a generation, which the
6
+ * stage between them. Each request names a generation, which the
7
7
  * worker echoes back untouched. The host raises it whenever the
8
8
  * input goes stale, and a reply that comes back behind the current
9
9
  * one is dropped rather than painted.
10
10
  */
11
- /** Whether a reply carries bytes. */
11
+ /** Whether a reply came back with bytes. */
12
12
  export function isRendered(response) {
13
13
  return 'bytes' in response;
14
14
  }
@@ -16,4 +16,12 @@ export function isRendered(response) {
16
16
  export function isFailed(response) {
17
17
  return 'error' in response;
18
18
  }
19
+ /**
20
+ * The style op, written either way: one sheet as CSS text, which the
21
+ * engine calls `author.css`, or the layers a host built its styling
22
+ * out of, in cascade order.
23
+ */
24
+ export function styleOp(css) {
25
+ return { op: 'style', sheets: typeof css === 'string' ? [{ name: 'author.css', css }] : css };
26
+ }
19
27
  //# sourceMappingURL=protocol.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAkHH,qCAAqC;AACrC,MAAM,UAAU,UAAU,CAAC,QAAkB;IAC3C,OAAO,OAAO,IAAI,QAAQ,CAAC;AAC7B,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,QAAQ,CAAC,QAAkB;IACzC,OAAO,OAAO,IAAI,QAAQ,CAAC;AAC7B,CAAC"}
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA2IH,4CAA4C;AAC5C,MAAM,UAAU,UAAU,CAAC,QAAkB;IAC3C,OAAO,OAAO,IAAI,QAAQ,CAAC;AAC7B,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,QAAQ,CAAC,QAAkB;IACzC,OAAO,OAAO,IAAI,QAAQ,CAAC;AAC7B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAAC,GAAqB;IAC3C,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;AAChG,CAAC"}
package/dist/svg.d.ts CHANGED
@@ -2,9 +2,9 @@
2
2
  * The preview painter: one page of the display structure, as SVG.
3
3
  *
4
4
  * The engine has already shaped and broken the text, so the browser
5
- * is given no room to do either. Every run is one `<text>` carrying
6
- * an x for each character it holds, taken from the glyph the shaper
7
- * put there, and the face is the file the engine shaped with, pinned
5
+ * is given no room to do either. Every run is one `<text>` with an x
6
+ * for each of its characters, taken from the glyph the shaper put
7
+ * there, and the face is the file the engine shaped with, pinned
8
8
  * to the instance it shaped at. A preview that disagrees with the
9
9
  * export about where a glyph sits therefore has a bug here, and
10
10
  * nowhere else.
@@ -12,6 +12,15 @@
12
12
  * The coordinate system is the display structure's: points, origin top
13
13
  * left, on a `viewBox` the size of the trim. Zoom is the width and
14
14
  * height the element is given, and moves nothing inside it.
15
+ *
16
+ * A second, invisible layer sits over the glyphs: one `<text>` per
17
+ * line, in the manuscript's own casing rather than what a
18
+ * `text-transform` or small capitals drew, and marked so a host can
19
+ * find it and read it back. It is what a drag actually selects — the
20
+ * glyph layer below takes no pointer events — so what native
21
+ * selection highlights lines up with what is on screen, and what
22
+ * copy yields is what the author wrote, in reading order, the pdf.js
23
+ * pattern over glyphs rather than a canvas.
15
24
  */
16
25
  import type { Asset, FontRefEntry, Page } from './wire.js';
17
26
  /** How a page is painted. */
@@ -24,7 +33,7 @@ export interface PaintOptions {
24
33
  zoom?: number;
25
34
  /** What the page is printed on; `null` leaves it transparent. */
26
35
  paper?: string | null;
27
- /** What it is printed in. */
36
+ /** What a run or a rule the sheet left black is printed in. */
28
37
  ink?: string;
29
38
  /**
30
39
  * Where an image's pixels come from: any url an `<img>` would
package/dist/svg.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../src/svg.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAY,YAAY,EAAa,IAAI,EAAsB,MAAM,WAAW,CAAC;AAEpG,6BAA6B;AAC7B,MAAM,WAAW,YAAY;IAC3B,kDAAkD;IAClD,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;IACvB,oDAAoD;IACpD,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,6BAA6B;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACpE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,YAAiB,GAAG,MAAM,CAgBxE"}
1
+ {"version":3,"file":"svg.d.ts","sourceRoot":"","sources":["../src/svg.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAY,YAAY,EAAa,IAAI,EAAsB,MAAM,WAAW,CAAC;AAEpG,6BAA6B;AAC7B,MAAM,WAAW,YAAY;IAC3B,kDAAkD;IAClD,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;IACvB,oDAAoD;IACpD,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC;IACjB,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,+DAA+D;IAC/D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACpE;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEjD;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,YAAiB,GAAG,MAAM,CAiBxE"}
package/dist/svg.js CHANGED
@@ -2,9 +2,9 @@
2
2
  * The preview painter: one page of the display structure, as SVG.
3
3
  *
4
4
  * The engine has already shaped and broken the text, so the browser
5
- * is given no room to do either. Every run is one `<text>` carrying
6
- * an x for each character it holds, taken from the glyph the shaper
7
- * put there, and the face is the file the engine shaped with, pinned
5
+ * is given no room to do either. Every run is one `<text>` with an x
6
+ * for each of its characters, taken from the glyph the shaper put
7
+ * there, and the face is the file the engine shaped with, pinned
8
8
  * to the instance it shaped at. A preview that disagrees with the
9
9
  * export about where a glyph sits therefore has a bug here, and
10
10
  * nowhere else.
@@ -12,6 +12,15 @@
12
12
  * The coordinate system is the display structure's: points, origin top
13
13
  * left, on a `viewBox` the size of the trim. Zoom is the width and
14
14
  * height the element is given, and moves nothing inside it.
15
+ *
16
+ * A second, invisible layer sits over the glyphs: one `<text>` per
17
+ * line, in the manuscript's own casing rather than what a
18
+ * `text-transform` or small capitals drew, and marked so a host can
19
+ * find it and read it back. It is what a drag actually selects — the
20
+ * glyph layer below takes no pointer events — so what native
21
+ * selection highlights lines up with what is on screen, and what
22
+ * copy yields is what the author wrote, in reading order, the pdf.js
23
+ * pattern over glyphs rather than a canvas.
15
24
  */
16
25
  /**
17
26
  * What a face is registered as, so a painter and whoever loaded the
@@ -34,6 +43,7 @@ export function paintPage(page, options = {}) {
34
43
  const zoom = options.zoom ?? 1;
35
44
  const paper = options.paper === undefined ? '#ffffff' : options.paper;
36
45
  const body = page.items.map((item) => paint(item, options)).join('');
46
+ const overlay = selectionOverlay(page.items);
37
47
  const ground = paper === null
38
48
  ? ''
39
49
  : `<rect x="0" y="0" width="${num(page.width)}" height="${num(page.height)}" fill="${escape(paper)}"/>`;
@@ -42,7 +52,7 @@ export function paintPage(page, options = {}) {
42
52
  ` width="${num(page.width * zoom)}" height="${num(page.height * zoom)}"` +
43
53
  ` fill="${escape(options.ink ?? '#000000')}"` +
44
54
  ` data-page="${page.number}" data-side="${page.side}">` +
45
- `${ground}${body}</svg>`);
55
+ `${ground}${body}${overlay}</svg>`);
46
56
  }
47
57
  function paint(item, options) {
48
58
  switch (item.kind) {
@@ -66,12 +76,22 @@ function text(item, options) {
66
76
  ` font-size="${num(item.size)}"` +
67
77
  ` font-weight="${entry?.attributes.weight ?? 400}"` +
68
78
  ` font-style="${entry?.attributes.italic === true ? 'italic' : 'normal'}"` +
69
- ` style="${escape(style(entry))}" xml:space="preserve"` +
79
+ ` style="${escape(style(entry, item))}" xml:space="preserve"` +
80
+ filled(item.color) +
70
81
  (entry === undefined ? ` data-missing-font="${item.fontId}"` : '') +
71
82
  `>${escape(item.text)}</text>`);
72
83
  }
73
84
  function rect(item) {
74
- return `<rect x="${num(item.x)}" y="${num(item.y)}" width="${num(item.w)}" height="${num(item.h)}"/>`;
85
+ return (`<rect x="${num(item.x)}" y="${num(item.y)}"` +
86
+ ` width="${num(item.w)}" height="${num(item.h)}"${filled(item.color)}/>`);
87
+ }
88
+ /**
89
+ * An item's own fill, where it has one. A sheet that names no colour
90
+ * leaves the item black, and the page's ink draws those, so a host
91
+ * printing in grey still gets grey.
92
+ */
93
+ function filled(color) {
94
+ return color === '#000000' ? '' : ` fill="${escape(color)}"`;
75
95
  }
76
96
  /**
77
97
  * A placed image. The pixels are the host's, and one it cannot
@@ -101,21 +121,37 @@ function stack(fontId, entry) {
101
121
  * location on that file, not a file of its own, so a painter that
102
122
  * does not pin it draws the default weight for every one of them.
103
123
  */
104
- function style(entry) {
124
+ function style(entry, item) {
105
125
  const settings = (entry?.variations ?? [])
106
126
  .map((axis) => `"${axis.tag}" ${num(axis.value)}`)
107
127
  .join(', ');
108
- // Runs carry the spaces the line was justified around, and SVG
128
+ // A run includes the spaces the line was justified around, and SVG
109
129
  // collapses them by default, which would slide every character
110
130
  // after the first space one position along the x list.
111
- return `white-space: pre` + (settings === '' ? '' : `; font-variation-settings: ${settings}`);
131
+ //
132
+ // The selection overlay is what a drag is meant to hit, not this:
133
+ // its own glyphs take no pointer events, so a click always reaches
134
+ // the overlay's line rather than a glyph.
135
+ const rules = ['white-space: pre', 'pointer-events: none'];
136
+ if (settings !== '') {
137
+ rules.push(`font-variation-settings: ${settings}`);
138
+ }
139
+ // The engine shaped the run with the face's own small capitals, so
140
+ // the browser is asked for the same feature rather than left to
141
+ // draw the lowercase the characters spell. `font-feature-settings`
142
+ // rather than `font-variant-caps`, which synthesises where the
143
+ // face has nothing and would draw a size the engine never measured.
144
+ if (item.features.smallCaps) {
145
+ rules.push('font-feature-settings: "smcp" 1');
146
+ }
147
+ return rules.join('; ');
112
148
  }
113
149
  /**
114
150
  * An x for each character of a run, from the glyph the shaper placed
115
151
  * there.
116
152
  *
117
153
  * SVG positions characters, and the display structure positions glyphs,
118
- * so the run's text is the join between them: each glyph carries the
154
+ * so the run's text is the join between them: each glyph names the
119
155
  * byte range it stands for, and its x lands on the character that
120
156
  * range starts at. A character inside a ligature's range has no
121
157
  * glyph of its own and is spaced evenly across it, which is what the
@@ -131,8 +167,8 @@ function positions(item) {
131
167
  if (at === undefined) {
132
168
  continue;
133
169
  }
134
- const held = xs[at];
135
- if (held === undefined || glyph.x < held) {
170
+ const seen = xs[at];
171
+ if (seen === undefined || glyph.x < seen) {
136
172
  xs[at] = glyph.x;
137
173
  }
138
174
  }
@@ -174,15 +210,106 @@ function fill(xs, left) {
174
210
  return [left];
175
211
  }
176
212
  const out = [];
177
- let held = left;
213
+ let previous = left;
178
214
  for (let at = 0; at <= last; at += 1) {
179
215
  const x = xs[at];
180
216
  const to = ahead[at] ?? -1;
181
- held = x ?? held + ((xs[to] ?? held) - held) / (to - at + 1);
182
- out.push(held);
217
+ previous = x ?? previous + ((xs[to] ?? previous) - previous) / (to - at + 1);
218
+ out.push(previous);
183
219
  }
184
220
  return out;
185
221
  }
222
+ /**
223
+ * What a run reads back as, over what it was shaped from: the
224
+ * manuscript's own casing where `text-transform` or small capitals
225
+ * drew something else, the shaped text where they drew nothing
226
+ * different. Mirrors the PDF writer's own `extracted`, since the two
227
+ * painters draw from the same run and neither is the one the other
228
+ * corrects against.
229
+ */
230
+ function readText(item) {
231
+ return item.sourceMap.length > 0 ? item.source : item.text;
232
+ }
233
+ /**
234
+ * An x for each character of {@link readText}, the same technique as
235
+ * {@link positions} but through {@link TextItem.sourceMap}: a glyph's
236
+ * range is in the shaped text's bytes, and the map carries a byte
237
+ * there to the source's own, which is the string this positions.
238
+ */
239
+ function readPositions(item) {
240
+ const transformed = item.sourceMap.length > 0;
241
+ const read = readText(item);
242
+ const starts = characters(read);
243
+ const index = new Map(starts.map((byte, at) => [byte, at]));
244
+ const xs = new Array(starts.length);
245
+ for (const glyph of item.glyphs) {
246
+ const mapped = transformed ? (item.sourceMap[glyph.range[0]] ?? byteLength(read)) : glyph.range[0];
247
+ const at = index.get(mapped);
248
+ if (at === undefined) {
249
+ continue;
250
+ }
251
+ const seen = xs[at];
252
+ if (seen === undefined || glyph.x < seen) {
253
+ xs[at] = glyph.x;
254
+ }
255
+ }
256
+ return fill(xs, item.x);
257
+ }
258
+ /** How many UTF-8 bytes a string is, the unit {@link TextItem.sourceMap} counts in. */
259
+ function byteLength(text) {
260
+ let bytes = 0;
261
+ for (const character of text) {
262
+ const code = character.codePointAt(0) ?? 0;
263
+ bytes += code < 0x80 ? 1 : code < 0x800 ? 2 : code < 0x10000 ? 3 : 4;
264
+ }
265
+ return bytes;
266
+ }
267
+ /**
268
+ * The page's text runs, grouped into the lines a reader thinks in:
269
+ * consecutive runs sharing one baseline. What breaks a run in two —
270
+ * a mid-line style change — does not break a line, so a selection
271
+ * dragged across it still reads as one.
272
+ */
273
+ function lineGroups(items) {
274
+ const lines = [];
275
+ for (const item of items) {
276
+ if (item.kind !== 'text') {
277
+ continue;
278
+ }
279
+ const last = lines[lines.length - 1]?.[0];
280
+ if (last !== undefined && Math.abs(last.y - item.y) < 0.01) {
281
+ lines[lines.length - 1]?.push(item);
282
+ }
283
+ else {
284
+ lines.push([item]);
285
+ }
286
+ }
287
+ return lines;
288
+ }
289
+ /**
290
+ * The invisible layer a selection actually drags over: one `<text>`
291
+ * per line, in reading order, holding what {@link readText} reads
292
+ * back for every run on it. Transparent, but not `display: none` —
293
+ * the browser selects and copies from what is on screen, not what is
294
+ * painted, so hiding it this way would hide it from that too.
295
+ */
296
+ function selectionOverlay(items) {
297
+ const body = lineGroups(items)
298
+ .map((runs) => selectionLine(runs))
299
+ .join('');
300
+ return body === '' ? '' : `<g data-selection-layer="true">${body}</g>`;
301
+ }
302
+ function selectionLine(runs) {
303
+ const y = runs[0]?.y ?? 0;
304
+ const text = runs.map((run) => readText(run)).join('');
305
+ const xs = runs.flatMap((run) => readPositions(run));
306
+ if (text === '') {
307
+ return '';
308
+ }
309
+ return (`<text x="${xs.map(num).join(' ')}" y="${num(y)}"` +
310
+ ` fill="transparent" style="pointer-events: all; white-space: pre" xml:space="preserve"` +
311
+ ` data-selection-line="true">${escape(text)}</text>`);
312
+ }
186
313
  /**
187
314
  * The shortest decimal that reads back as the same 32-bit float.
188
315
  *
package/dist/svg.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"svg.js","sourceRoot":"","sources":["../src/svg.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA6BH;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,MAAc;IACvC,OAAO,gBAAgB,MAAM,EAAE,CAAC;AAClC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,IAAU,EAAE,UAAwB,EAAE;IAC9D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC;IAC/B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC;IACtE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrE,MAAM,MAAM,GACV,KAAK,KAAK,IAAI;QACZ,CAAC,CAAC,EAAE;QACJ,CAAC,CAAC,4BAA4B,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,CAAC,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,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACnC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACrD,OAAO,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED,SAAS,MAAM,CAAC,IAAY;IAC1B,OAAO,IAAI;SACR,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AAC7B,CAAC"}
package/dist/version.d.ts CHANGED
@@ -4,5 +4,5 @@
4
4
  * module was built from as well: the workspace and both packages
5
5
  * release together.
6
6
  */
7
- export declare const VERSION = "0.1.1";
7
+ export declare const VERSION = "0.2.0";
8
8
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -4,5 +4,5 @@
4
4
  * module was built from as well: the workspace and both packages
5
5
  * release together.
6
6
  */
7
- export const VERSION = '0.1.1';
7
+ export const VERSION = '0.2.0';
8
8
  //# sourceMappingURL=version.js.map
package/dist/wire.d.ts CHANGED
@@ -7,10 +7,15 @@
7
7
  * engine wrote them, and the version in front of the bytes is what
8
8
  * catches the day those two stop agreeing.
9
9
  */
10
- /** The encoding this reader understands. */
11
- export declare const WIRE_VERSION = 4;
10
+ /** The encoding this reader reads. */
11
+ export declare const WIRE_VERSION = 8;
12
12
  /** Which side of the spread a page falls on. */
13
13
  export type Side = 'recto' | 'verso';
14
+ /** The features beyond the default set a run was shaped with. */
15
+ export interface Features {
16
+ /** `smcp`: the face's own small capitals. */
17
+ smallCaps: boolean;
18
+ }
14
19
  /** One glyph: an id in its font, an absolute x, and the text it stands for. */
15
20
  export interface Glyph {
16
21
  /** Glyph id in the run's font. */
@@ -32,12 +37,35 @@ export interface TextItem {
32
37
  /** Em size in points. */
33
38
  size: number;
34
39
  /**
35
- * The text the glyphs were shaped from. Only the shaper knew which
36
- * glyph came from which character, so the correspondence travels
37
- * with them: selection, copy-and-paste and accessible text read it
38
- * through each glyph's range.
40
+ * The text the glyphs were shaped from, which each glyph's range
41
+ * indexes. A painter that draws characters rather than glyphs
42
+ * draws these.
39
43
  */
40
44
  text: string;
45
+ /**
46
+ * What the author wrote, where `text-transform` or small capitals
47
+ * made that differ from what was shaped, and empty where the two
48
+ * are the same. Selection, copy-and-paste and accessible text read
49
+ * this rather than {@link TextItem.text}.
50
+ */
51
+ source: string;
52
+ /**
53
+ * The offset in {@link TextItem.source} of every byte boundary of
54
+ * {@link TextItem.text}, so a glyph's range taken through it is
55
+ * the source that glyph stands for. Empty alongside `source`.
56
+ */
57
+ sourceMap: number[];
58
+ /**
59
+ * The OpenType features the run was shaped with. A painter that
60
+ * draws characters asks the face for these, or the browser picks
61
+ * its own glyphs and sets them at positions measured for others.
62
+ */
63
+ features: Features;
64
+ /**
65
+ * The `#rrggbb` the run is painted in. A sheet that names no
66
+ * colour leaves it black.
67
+ */
68
+ color: string;
41
69
  /** The glyphs, in visual order. */
42
70
  glyphs: Glyph[];
43
71
  }
@@ -52,6 +80,8 @@ export interface RectItem {
52
80
  w: number;
53
81
  /** Height in points. */
54
82
  h: number;
83
+ /** The `#rrggbb` the rectangle is filled with. */
84
+ color: string;
55
85
  }
56
86
  /** An image's own idea of its size, from its header. */
57
87
  export interface Intrinsic {
@@ -104,8 +134,8 @@ export interface Page {
104
134
  /** Trimmed page height in points. */
105
135
  height: number;
106
136
  /**
107
- * The content-tree node ids of the sections this page holds content
108
- * from, in the order their content appears on it. A chapter that
137
+ * The content-tree node ids of the sections whose content appears on
138
+ * this page, in the order their content appears on it. A chapter that
109
139
  * ends mid-page is followed there by the next one opening, so the
110
140
  * page names both. A blank leaf names none.
111
141
  */
@@ -127,7 +157,7 @@ export interface FaceAttributes {
127
157
  /** Weight on the CSS 1–1000 scale. */
128
158
  weight: number;
129
159
  }
130
- /** A font's identity, as the display structure indexes it. */
160
+ /** A font's identity in the display structure. */
131
161
  export interface FontRefEntry {
132
162
  /** Family for matching, lowercase. */
133
163
  family: string;
@@ -149,13 +179,26 @@ export interface FontRefEntry {
149
179
  export interface Warning {
150
180
  /** What went wrong, in one line. */
151
181
  message: string;
152
- /** Where it was written, when the engine knows. */
182
+ /** Where it was written, when a position was recorded. */
153
183
  origin: string | null;
154
184
  }
155
- /** Everything one run produced: pages, the fonts they index, diagnostics. */
185
+ /**
186
+ * What one reply carried, and where it falls in the book.
187
+ *
188
+ * `pages` need not be the whole book: a request that named a range
189
+ * gets back that slice alone, `first` says where it begins (counting
190
+ * from 0), and `bookPages` is how many pages the book has, so a reply
191
+ * carrying page 12 alone still answers "page 12 of 337". `fonts`,
192
+ * `assets` and `warnings` are never sliced, since none of them is per
193
+ * page.
194
+ */
156
195
  export interface LayoutOutput {
157
- /** The typeset pages, in reading order. */
196
+ /** The pages this reply carries, in reading order. */
158
197
  pages: Page[];
198
+ /** The index of `pages[0]` in the book. Zero for a whole-book reply. */
199
+ first: number;
200
+ /** How many pages the book has. */
201
+ bookPages: number;
159
202
  /** The fonts this run used, indexed by `fontId`. */
160
203
  fonts: FontRefEntry[];
161
204
  /** The images this run placed, indexed by `ImageItem.asset`. */
@@ -1 +1 @@
1
- {"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,4CAA4C;AAC5C,eAAO,MAAM,YAAY,IAAI,CAAC;AAE9B,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