fleuron 0.1.2 → 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/dist/wire.js CHANGED
@@ -7,8 +7,8 @@
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 const WIRE_VERSION = 4;
10
+ /** The encoding this reader reads. */
11
+ export const WIRE_VERSION = 8;
12
12
  /** A buffer this reader will not read, and why. */
13
13
  export class WireError extends Error {
14
14
  constructor(message) {
@@ -70,6 +70,21 @@ class Reader {
70
70
  }
71
71
  return out;
72
72
  }
73
+ /** One byte. A `u8` is written as itself, not as a varint. */
74
+ byte() {
75
+ const value = this.bytes[this.at++];
76
+ if (value === undefined) {
77
+ throw new WireError('the buffer ended mid-byte');
78
+ }
79
+ return value;
80
+ }
81
+ /** Three bytes, one per channel, read back as `#rrggbb`. */
82
+ color() {
83
+ const digits = [this.byte(), this.byte(), this.byte()]
84
+ .map((channel) => channel.toString(16).padStart(2, '0'))
85
+ .join('');
86
+ return `#${digits}`;
87
+ }
73
88
  /** An `Option<T>`: present or not, and the value when it is. */
74
89
  option(item) {
75
90
  return this.varint() === 0 ? null : item();
@@ -94,10 +109,21 @@ function item(r) {
94
109
  fontId: r.varint(),
95
110
  size: r.f32(),
96
111
  text: r.string(),
112
+ source: r.string(),
113
+ sourceMap: r.seq(() => r.varint()),
114
+ features: { smallCaps: r.bool() },
115
+ color: r.color(),
97
116
  glyphs: r.seq(() => glyph(r)),
98
117
  };
99
118
  case 1:
100
- return { kind: 'rect', x: r.f32(), y: r.f32(), w: r.f32(), h: r.f32() };
119
+ return {
120
+ kind: 'rect',
121
+ x: r.f32(),
122
+ y: r.f32(),
123
+ w: r.f32(),
124
+ h: r.f32(),
125
+ color: r.color(),
126
+ };
101
127
  case 2:
102
128
  return {
103
129
  kind: 'image',
@@ -108,7 +134,7 @@ function item(r) {
108
134
  asset: r.varint(),
109
135
  };
110
136
  default:
111
- throw new WireError(`draw item ${variant} is not one this reader knows`);
137
+ throw new WireError(`draw item ${variant} is not one this reader reads`);
112
138
  }
113
139
  }
114
140
  function page(r) {
@@ -160,14 +186,18 @@ export function decodeDisplayList(bytes) {
160
186
  if (version !== WIRE_VERSION) {
161
187
  throw new WireError(`wire version ${version}, expected ${WIRE_VERSION}`);
162
188
  }
189
+ const first = r.varint();
190
+ const bookPages = r.varint();
163
191
  const output = {
164
- pages: r.seq(() => page(r)),
192
+ first,
193
+ bookPages,
165
194
  fonts: r.seq(() => font(r)),
166
195
  assets: r.seq(() => asset(r)),
167
196
  warnings: r.seq(() => warning(r)),
197
+ pages: r.seq(() => page(r)),
168
198
  };
169
199
  if (!r.done()) {
170
- throw new WireError('the buffer holds more than one display structure');
200
+ throw new WireError('the buffer is more than one display structure');
171
201
  }
172
202
  return output;
173
203
  }
package/dist/wire.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"wire.js","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,4CAA4C;AAC5C,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC;AA0K9B,mDAAmD;AACnD,MAAM,OAAO,SAAU,SAAQ,KAAK;IAClC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AAED,oDAAoD;AACpD,MAAM,MAAM;IACO,IAAI,CAAW;IACf,KAAK,CAAa;IAC3B,EAAE,GAAG,CAAC,CAAC;IAEf,YAAY,KAAiB;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC7E,CAAC;IAED,gEAAgE;IAChE,MAAM;QACJ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,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC7C,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAiB;IACjD,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;IAC3B,IAAI,OAAO,KAAK,YAAY,EAAE,CAAC;QAC7B,MAAM,IAAI,SAAS,CAAC,gBAAgB,OAAO,cAAc,YAAY,EAAE,CAAC,CAAC;IAC3E,CAAC;IACD,MAAM,KAAK,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;IACzB,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAiB;QAC3B,KAAK;QACL,SAAS;QACT,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3B,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7B,QAAQ,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACjC,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KAC5B,CAAC;IACF,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QACd,MAAM,IAAI,SAAS,CAAC,+CAA+C,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleuron",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Paged-media layout in a worker: markdown and CSS in, a display structure or PDF bytes out",
5
5
  "license": "MIT OR Apache-2.0",
6
6
  "repository": {
package/wasm/fleuron.d.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  /* eslint-disable */
3
3
 
4
4
  /**
5
- * A retained pipeline, held in the module between calls.
5
+ * A retained pipeline, kept in the module between calls.
6
6
  *
7
7
  * The session keeps the content tree, the styling and every stage
8
8
  * between them and the page, so a second render pays for what
@@ -23,12 +23,12 @@ export class Session {
23
23
  addFont(bytes: Uint8Array): Uint16Array;
24
24
  /**
25
25
  * Registers one image by the url the content tree names it by,
26
- * and returns the index `DrawItem::Image.asset` will carry.
26
+ * and returns the index `DrawItem::Image.asset` gets for it.
27
27
  * `undefined` for bytes no probe recognises, which is a
28
28
  * diagnostic on the next display structure and no image.
29
29
  *
30
30
  * The engine opens nothing, and a worker has nothing to open:
31
- * the host fetches the file and hands the bytes over, as it does
31
+ * the host fetches the file and hands the bytes over, the same as
32
32
  * with a face. The bytes stay in the module, so an image crosses
33
33
  * once rather than once per render.
34
34
  */
@@ -57,8 +57,12 @@ export class Session {
57
57
  constructor();
58
58
  /**
59
59
  * The display structure, postcard-encoded, version first.
60
+ *
61
+ * `first` and `count` ask for a slice of the book's pages rather
62
+ * than all of them; leaving either out answers with the whole
63
+ * book, same as before ranges existed.
60
64
  */
61
- preview(): Uint8Array;
65
+ preview(first?: number | null, count?: number | null): Uint8Array;
62
66
  /**
63
67
  * Drops every section that came from one source, and the
64
68
  * complaints reading it raised.
@@ -88,13 +92,14 @@ export class Session {
88
92
  setMarkdown(name: string, text: string): void;
89
93
  /**
90
94
  * Names the book, from JSON: `title`, `author`, and an `extra`
91
- * object for whatever else a frontend carries.
95
+ * object for whatever else a frontend read.
92
96
  *
93
97
  * A book read from several sources has no frontmatter of its
94
- * own, so this is how it gets a title. Nothing between the
95
- * content tree and the page reads metadata, so a book renamed
96
- * between renders re-runs no stage; the PDF writer is the one
97
- * thing that reads it.
98
+ * own, so this is how it gets a title. A book renamed between
99
+ * renders re-runs no stage: the PDF writer reads the name, and
100
+ * the one field layout reads is `extra.language`, which chooses
101
+ * the hyphenation patterns. A book that declares a different
102
+ * language is broken into lines again.
98
103
  */
99
104
  setMetadata(json: string): void;
100
105
  /**
@@ -118,15 +123,19 @@ export class Session {
118
123
  */
119
124
  setSplit(level: number): void;
120
125
  /**
121
- * Sets the author styling from CSS text, cascading over the
122
- * built-in sheet.
126
+ * Sets the author styling from named sheets, in cascade order,
127
+ * over the built-in one. Later sheets win, and a warning names
128
+ * the sheet its declaration was written in.
129
+ *
130
+ * A host that builds its styling out of layers hands over the
131
+ * layers.
123
132
  *
124
133
  * Which stages this costs is the change's own business: a
125
134
  * colour repaints nothing, page geometry re-fragments over the
126
135
  * lines already broken, and only the measure or the face breaks
127
136
  * them again.
128
137
  */
129
- setStyle(css: string): void;
138
+ setStyle(names: string[], texts: string[]): void;
130
139
  /**
131
140
  * How many times each stage has run since the session was made,
132
141
  * as `[style, lines, flow, paint]`.
@@ -138,8 +147,9 @@ export class Session {
138
147
  stages(): Uint32Array;
139
148
  /**
140
149
  * Replaces every section that came from one source, reparsing
141
- * that source alone. A name the book does not carry appends
142
- * instead, which is how a file it has not seen before arrives.
150
+ * that source alone. A name the book does not already have
151
+ * appends instead, which is how a file it has not seen before
152
+ * arrives.
143
153
  *
144
154
  * This is the keystroke path: one file crosses, one file is
145
155
  * read, and every other section keeps the lines it already has.
@@ -177,7 +187,7 @@ export interface InitOutput {
177
187
  readonly session_exportPdf: (a: number) => [number, number, number, number];
178
188
  readonly session_fontBytes: (a: number, b: number) => [number, number, number, number];
179
189
  readonly session_new: () => [number, number, number];
180
- readonly session_preview: (a: number) => [number, number, number, number];
190
+ readonly session_preview: (a: number, b: number, c: number) => [number, number, number, number];
181
191
  readonly session_removeMarkdown: (a: number, b: number, c: number) => void;
182
192
  readonly session_setContent: (a: number, b: number, c: number) => [number, number];
183
193
  readonly session_setDialect: (a: number, b: number, c: number) => [number, number];
@@ -185,7 +195,7 @@ export interface InitOutput {
185
195
  readonly session_setMetadata: (a: number, b: number, c: number) => [number, number];
186
196
  readonly session_setSources: (a: number, b: number, c: number, d: number, e: number) => [number, number];
187
197
  readonly session_setSplit: (a: number, b: number) => [number, number];
188
- readonly session_setStyle: (a: number, b: number, c: number) => void;
198
+ readonly session_setStyle: (a: number, b: number, c: number, d: number, e: number) => [number, number];
189
199
  readonly session_stages: (a: number) => [number, number];
190
200
  readonly session_updateMarkdown: (a: number, b: number, c: number, d: number, e: number) => void;
191
201
  readonly wireVersion: () => number;
package/wasm/fleuron.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /* @ts-self-types="./fleuron.d.ts" */
2
2
 
3
3
  /**
4
- * A retained pipeline, held in the module between calls.
4
+ * A retained pipeline, kept in the module between calls.
5
5
  *
6
6
  * The session keeps the content tree, the styling and every stage
7
7
  * between them and the page, so a second render pays for what
@@ -42,12 +42,12 @@ export class Session {
42
42
  }
43
43
  /**
44
44
  * Registers one image by the url the content tree names it by,
45
- * and returns the index `DrawItem::Image.asset` will carry.
45
+ * and returns the index `DrawItem::Image.asset` gets for it.
46
46
  * `undefined` for bytes no probe recognises, which is a
47
47
  * diagnostic on the next display structure and no image.
48
48
  *
49
49
  * The engine opens nothing, and a worker has nothing to open:
50
- * the host fetches the file and hands the bytes over, as it does
50
+ * the host fetches the file and hands the bytes over, the same as
51
51
  * with a face. The bytes stay in the module, so an image crosses
52
52
  * once rather than once per render.
53
53
  * @param {string} url
@@ -116,10 +116,16 @@ export class Session {
116
116
  }
117
117
  /**
118
118
  * The display structure, postcard-encoded, version first.
119
+ *
120
+ * `first` and `count` ask for a slice of the book's pages rather
121
+ * than all of them; leaving either out answers with the whole
122
+ * book, same as before ranges existed.
123
+ * @param {number | null} [first]
124
+ * @param {number | null} [count]
119
125
  * @returns {Uint8Array}
120
126
  */
121
- preview() {
122
- const ret = wasm.session_preview(this.__wbg_ptr);
127
+ preview(first, count) {
128
+ const ret = wasm.session_preview(this.__wbg_ptr, isLikeNone(first) ? Number.MAX_SAFE_INTEGER : (first) >>> 0, isLikeNone(count) ? Number.MAX_SAFE_INTEGER : (count) >>> 0);
123
129
  if (ret[3]) {
124
130
  throw takeFromExternrefTable0(ret[2]);
125
131
  }
@@ -185,13 +191,14 @@ export class Session {
185
191
  }
186
192
  /**
187
193
  * Names the book, from JSON: `title`, `author`, and an `extra`
188
- * object for whatever else a frontend carries.
194
+ * object for whatever else a frontend read.
189
195
  *
190
196
  * A book read from several sources has no frontmatter of its
191
- * own, so this is how it gets a title. Nothing between the
192
- * content tree and the page reads metadata, so a book renamed
193
- * between renders re-runs no stage; the PDF writer is the one
194
- * thing that reads it.
197
+ * own, so this is how it gets a title. A book renamed between
198
+ * renders re-runs no stage: the PDF writer reads the name, and
199
+ * the one field layout reads is `extra.language`, which chooses
200
+ * the hyphenation patterns. A book that declares a different
201
+ * language is broken into lines again.
195
202
  * @param {string} json
196
203
  */
197
204
  setMetadata(json) {
@@ -240,19 +247,29 @@ export class Session {
240
247
  }
241
248
  }
242
249
  /**
243
- * Sets the author styling from CSS text, cascading over the
244
- * built-in sheet.
250
+ * Sets the author styling from named sheets, in cascade order,
251
+ * over the built-in one. Later sheets win, and a warning names
252
+ * the sheet its declaration was written in.
253
+ *
254
+ * A host that builds its styling out of layers hands over the
255
+ * layers.
245
256
  *
246
257
  * Which stages this costs is the change's own business: a
247
258
  * colour repaints nothing, page geometry re-fragments over the
248
259
  * lines already broken, and only the measure or the face breaks
249
260
  * them again.
250
- * @param {string} css
261
+ * @param {string[]} names
262
+ * @param {string[]} texts
251
263
  */
252
- setStyle(css) {
253
- const ptr0 = passStringToWasm0(css, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
264
+ setStyle(names, texts) {
265
+ const ptr0 = passArrayJsValueToWasm0(names, wasm.__wbindgen_malloc);
254
266
  const len0 = WASM_VECTOR_LEN;
255
- wasm.session_setStyle(this.__wbg_ptr, ptr0, len0);
267
+ const ptr1 = passArrayJsValueToWasm0(texts, wasm.__wbindgen_malloc);
268
+ const len1 = WASM_VECTOR_LEN;
269
+ const ret = wasm.session_setStyle(this.__wbg_ptr, ptr0, len0, ptr1, len1);
270
+ if (ret[1]) {
271
+ throw takeFromExternrefTable0(ret[0]);
272
+ }
256
273
  }
257
274
  /**
258
275
  * How many times each stage has run since the session was made,
@@ -271,8 +288,9 @@ export class Session {
271
288
  }
272
289
  /**
273
290
  * Replaces every section that came from one source, reparsing
274
- * that source alone. A name the book does not carry appends
275
- * instead, which is how a file it has not seen before arrives.
291
+ * that source alone. A name the book does not already have
292
+ * appends instead, which is how a file it has not seen before
293
+ * arrives.
276
294
  *
277
295
  * This is the keystroke path: one file crosses, one file is
278
296
  * read, and every other section keeps the lines it already has.
Binary file
@@ -9,7 +9,7 @@ export const session_addImage: (a: number, b: number, c: number, d: number, e: n
9
9
  export const session_exportPdf: (a: number) => [number, number, number, number];
10
10
  export const session_fontBytes: (a: number, b: number) => [number, number, number, number];
11
11
  export const session_new: () => [number, number, number];
12
- export const session_preview: (a: number) => [number, number, number, number];
12
+ export const session_preview: (a: number, b: number, c: number) => [number, number, number, number];
13
13
  export const session_removeMarkdown: (a: number, b: number, c: number) => void;
14
14
  export const session_setContent: (a: number, b: number, c: number) => [number, number];
15
15
  export const session_setDialect: (a: number, b: number, c: number) => [number, number];
@@ -17,7 +17,7 @@ export const session_setMarkdown: (a: number, b: number, c: number, d: number, e
17
17
  export const session_setMetadata: (a: number, b: number, c: number) => [number, number];
18
18
  export const session_setSources: (a: number, b: number, c: number, d: number, e: number) => [number, number];
19
19
  export const session_setSplit: (a: number, b: number) => [number, number];
20
- export const session_setStyle: (a: number, b: number, c: number) => void;
20
+ export const session_setStyle: (a: number, b: number, c: number, d: number, e: number) => [number, number];
21
21
  export const session_stages: (a: number) => [number, number];
22
22
  export const session_updateMarkdown: (a: number, b: number, c: number, d: number, e: number) => void;
23
23
  export const wireVersion: () => number;