postext 1.34.1 → 1.35.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.
Files changed (94) hide show
  1. package/dist/__tests__/composed/fixtures/page8.d.ts.map +1 -1
  2. package/dist/__tests__/composed/fixtures/page8.js +6 -3
  3. package/dist/__tests__/composed/fixtures/page8.js.map +1 -1
  4. package/dist/__tests__/composed/fixtures/timeline.d.ts +26 -0
  5. package/dist/__tests__/composed/fixtures/timeline.d.ts.map +1 -0
  6. package/dist/__tests__/composed/fixtures/timeline.js +153 -0
  7. package/dist/__tests__/composed/fixtures/timeline.js.map +1 -0
  8. package/dist/__tests__/composed/groups.test.d.ts +2 -0
  9. package/dist/__tests__/composed/groups.test.d.ts.map +1 -0
  10. package/dist/__tests__/composed/groups.test.js +361 -0
  11. package/dist/__tests__/composed/groups.test.js.map +1 -0
  12. package/dist/__tests__/composed/outsidePrint.test.d.ts +2 -0
  13. package/dist/__tests__/composed/outsidePrint.test.d.ts.map +1 -0
  14. package/dist/__tests__/composed/outsidePrint.test.js +116 -0
  15. package/dist/__tests__/composed/outsidePrint.test.js.map +1 -0
  16. package/dist/__tests__/composed/spread.test.d.ts +2 -0
  17. package/dist/__tests__/composed/spread.test.d.ts.map +1 -0
  18. package/dist/__tests__/composed/spread.test.js +475 -0
  19. package/dist/__tests__/composed/spread.test.js.map +1 -0
  20. package/dist/__tests__/composedPaint.test.js +10 -2
  21. package/dist/__tests__/composedPaint.test.js.map +1 -1
  22. package/dist/__tests__/exports.test.js +13 -0
  23. package/dist/__tests__/exports.test.js.map +1 -1
  24. package/dist/canvas-backend/composed.d.ts +5 -1
  25. package/dist/canvas-backend/composed.d.ts.map +1 -1
  26. package/dist/canvas-backend/composed.js +28 -1
  27. package/dist/canvas-backend/composed.js.map +1 -1
  28. package/dist/canvas-backend/index.js +2 -2
  29. package/dist/canvas-backend/index.js.map +1 -1
  30. package/dist/composed/groups.d.ts +95 -0
  31. package/dist/composed/groups.d.ts.map +1 -0
  32. package/dist/composed/groups.js +359 -0
  33. package/dist/composed/groups.js.map +1 -0
  34. package/dist/composed/labelText.d.ts +15 -0
  35. package/dist/composed/labelText.d.ts.map +1 -0
  36. package/dist/composed/labelText.js +16 -0
  37. package/dist/composed/labelText.js.map +1 -0
  38. package/dist/composed/paint.d.ts +25 -2
  39. package/dist/composed/paint.d.ts.map +1 -1
  40. package/dist/composed/paint.js +46 -1
  41. package/dist/composed/paint.js.map +1 -1
  42. package/dist/composed/reflowLog.d.ts +39 -0
  43. package/dist/composed/reflowLog.d.ts.map +1 -0
  44. package/dist/composed/reflowLog.js +123 -0
  45. package/dist/composed/reflowLog.js.map +1 -0
  46. package/dist/composed/slotChecks.d.ts +7 -2
  47. package/dist/composed/slotChecks.d.ts.map +1 -1
  48. package/dist/composed/slotChecks.js +21 -0
  49. package/dist/composed/slotChecks.js.map +1 -1
  50. package/dist/composed/spread.d.ts +106 -0
  51. package/dist/composed/spread.d.ts.map +1 -0
  52. package/dist/composed/spread.js +178 -0
  53. package/dist/composed/spread.js.map +1 -0
  54. package/dist/defaults/headerFooter.d.ts.map +1 -1
  55. package/dist/defaults/headerFooter.js +4 -0
  56. package/dist/defaults/headerFooter.js.map +1 -1
  57. package/dist/design/layout.d.ts +9 -0
  58. package/dist/design/layout.d.ts.map +1 -1
  59. package/dist/design/layout.js +1 -1
  60. package/dist/design/layout.js.map +1 -1
  61. package/dist/html-backend.d.ts.map +1 -1
  62. package/dist/html-backend.js +56 -26
  63. package/dist/html-backend.js.map +1 -1
  64. package/dist/index.d.ts +9 -2
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +9 -1
  67. package/dist/index.js.map +1 -1
  68. package/dist/pipeline/build.d.ts.map +1 -1
  69. package/dist/pipeline/build.js +76 -20
  70. package/dist/pipeline/build.js.map +1 -1
  71. package/dist/pipeline/buildMeasurement.d.ts +4 -1
  72. package/dist/pipeline/buildMeasurement.d.ts.map +1 -1
  73. package/dist/pipeline/buildMeasurement.js +19 -1
  74. package/dist/pipeline/buildMeasurement.js.map +1 -1
  75. package/dist/pipeline/calloutLayout.d.ts +3 -1
  76. package/dist/pipeline/calloutLayout.d.ts.map +1 -1
  77. package/dist/pipeline/calloutLayout.js +2 -1
  78. package/dist/pipeline/calloutLayout.js.map +1 -1
  79. package/dist/pipeline/composedLayout.d.ts +6 -1
  80. package/dist/pipeline/composedLayout.d.ts.map +1 -1
  81. package/dist/pipeline/composedLayout.js +223 -23
  82. package/dist/pipeline/composedLayout.js.map +1 -1
  83. package/dist/pipeline/contentWarnings.d.ts.map +1 -1
  84. package/dist/pipeline/contentWarnings.js +7 -1
  85. package/dist/pipeline/contentWarnings.js.map +1 -1
  86. package/dist/pipeline/headerFooter.d.ts.map +1 -1
  87. package/dist/pipeline/headerFooter.js +55 -7
  88. package/dist/pipeline/headerFooter.js.map +1 -1
  89. package/dist/types.d.ts +20 -0
  90. package/dist/types.d.ts.map +1 -1
  91. package/dist/vdt.d.ts +83 -5
  92. package/dist/vdt.d.ts.map +1 -1
  93. package/dist/vdt.js.map +1 -1
  94. package/package.json +1 -1
@@ -24,7 +24,8 @@ import { playMarkTriangle, qrModuleRuns } from './pipeline/videoOverlay';
24
24
  import { isHlsMimeType, mediaFragment, videoElementAttributes, videoEmbedAllow } from './video/url';
25
25
  import { renderComicHtml } from './htmlComic';
26
26
  import { comicBlockOnSheet, pageComics } from './comics/transform';
27
- import { composedFrameBlockIds, composedPaintOrder, frameClips, frameMatrix } from './composed/paint';
27
+ import { altWithLabels } from './composed/labelText';
28
+ import { composedFrameBlockIds, composedPaintOrder, composedReadingOrder, composedSheetClip, frameClips, frameMatrix } from './composed/paint';
28
29
  import { taskBoxSvgBody, taskBoxText } from './taskBox';
29
30
  /**
30
31
  * Declarations of every box of CJK text measured with no punctuation
@@ -2489,7 +2490,8 @@ function renderResourceBlockHtml(block, paint) {
2489
2490
  else if (rb.kind === 'bitmap' || rb.kind === 'svg') {
2490
2491
  const url = rb.fileId ? imageUrl(options, rb.fileId, rb.resource.id) : undefined;
2491
2492
  // `<img>`, or a neutral placeholder matching the canvas backend's colours.
2492
- parts.push(renderFittedImage(url, rb.resource.altText ?? '', rb.kind === 'svg' ? 'SVG' : 'Image', bx, by, bw, bh, options, rb.kind === 'svg', rb.bodySource));
2493
+ // A `:::figure`'s labels follow its alternative text (#862).
2494
+ parts.push(renderFittedImage(url, altWithLabels(rb.resource.altText ?? '', rb.labels), rb.kind === 'svg' ? 'SVG' : 'Image', bx, by, bw, bh, options, rb.kind === 'svg', rb.bodySource));
2493
2495
  }
2494
2496
  else if (rb.kind === 'table') {
2495
2497
  parts.push(renderResourceTable(rb, bx, by, options));
@@ -2917,34 +2919,58 @@ verticalRegion, verticalDigits) {
2917
2919
  continue;
2918
2920
  blocks.push({ id: fb.id, html: renderBlock(fb, options, stripInBlock(fb)) });
2919
2921
  }
2920
- // The frames in layer order, each in a box of its own that turns it and
2921
- // clips it, the template's decoration at layer 0; through a flow frame
2922
- // the decoration stands on the sheet, after the flow.
2922
+ // The frames, each in a box of its own that turns it and clips it, in
2923
+ // reading order (Markdown order, #862: what a screen reader and a
2924
+ // fixed-layout EPUB read), painted in layer order by their `z-index`
2925
+ // inside one stacking context, the template's decoration at layer 0;
2926
+ // through a flow frame the decoration stands on the sheet, after the flow.
2923
2927
  const composedFlow = page.composed !== undefined && !plainFlow;
2924
- const composedDecorationHtml = page.composed?.decoration ? renderDesignSlot(page.composed.decoration, composedFlow ? { ...options, vertical: undefined } : options) : '';
2928
+ // On a page of a spread (#861) the frames and the decoration show the
2929
+ // page's share of the sheet only.
2930
+ const sheetClip = composedSheetClip(page);
2931
+ const sheetClipped = (html) => {
2932
+ if (!sheetClip || html === '')
2933
+ return html;
2934
+ const [l, t, r, b] = [sheetClip.x, sheetClip.y, sheetClip.x + sheetClip.width, sheetClip.y + sheetClip.height].map(frameNum);
2935
+ return `<div class="pt-sheet-clip" style="position:absolute;left:0;top:0;width:0;height:0;overflow:visible;clip-path:polygon(${l}px ${t}px,${r}px ${t}px,${r}px ${b}px,${l}px ${b}px);">${html}</div>`;
2936
+ };
2937
+ const composedDecorationHtml = page.composed?.decoration ? sheetClipped(renderDesignSlot(page.composed.decoration, composedFlow ? { ...options, vertical: undefined } : options)) : '';
2925
2938
  const composedParts = [];
2926
2939
  /** The frames' boxes and the decoration: what a patcher of blocks must
2927
2940
  * also compare (`decorationHtml`). */
2928
2941
  const composedShape = [];
2929
- for (const item of composedPaintOrder(page)) {
2930
- if (item.kind === 'decoration') {
2931
- if (!composedFlow)
2932
- composedParts.push(composedDecorationHtml);
2933
- continue;
2942
+ if (page.composed) {
2943
+ const paint = composedPaintOrder(page);
2944
+ for (const item of composedReadingOrder(paint)) {
2945
+ const z = paint.indexOf(item) + 1;
2946
+ if (item.kind === 'decoration') {
2947
+ if (!composedFlow && composedDecorationHtml)
2948
+ composedParts.push(`<div class="pt-frame-decoration" style="position:absolute;left:0;top:0;width:0;height:0;z-index:${z};">${composedDecorationHtml}</div>`);
2949
+ continue;
2950
+ }
2951
+ if (item.blocks.length === 0)
2952
+ continue;
2953
+ const open = composedFrameOpen(item.frame, z, item.facing);
2954
+ composedShape.push(open);
2955
+ composedParts.push(open);
2956
+ for (const b of item.blocks) {
2957
+ const html = renderBlock(b, options, stripInBlock(b));
2958
+ // The facing page's half of a frame across a spread's spine is
2959
+ // painted only: no block of the page's to patch or select.
2960
+ if (item.facing)
2961
+ composedShape.push(html);
2962
+ else
2963
+ blocks.push({ id: b.id, html });
2964
+ composedParts.push(html);
2965
+ }
2966
+ composedParts.push('</div>');
2934
2967
  }
2935
- if (item.blocks.length === 0)
2936
- continue;
2937
- const open = composedFrameOpen(item.frame);
2938
- composedShape.push(open);
2939
- composedParts.push(open);
2940
- for (const b of item.blocks) {
2941
- const html = renderBlock(b, options, stripInBlock(b));
2942
- blocks.push({ id: b.id, html });
2943
- composedParts.push(html);
2968
+ if (composedParts.length > 0) {
2969
+ composedParts.unshift('<div class="pt-composed" style="position:absolute;left:0;top:0;width:0;height:0;z-index:0;">');
2970
+ composedParts.push('</div>');
2944
2971
  }
2945
- composedParts.push('</div>');
2946
2972
  }
2947
- const blocksHtml = blocks.filter((b) => !frameIds.has(b.id)).map((b) => b.html).join('') + composedParts.join('');
2973
+ const blocksHtml = blocks.filter((b) => !frameIds.has(b.id)).map((b) => b.html).join('') + sheetClipped(composedParts.join(''));
2948
2974
  // Same paint order as the canvas backend: the opener / part band goes
2949
2975
  // under the body (a part page's full-bleed background must not cover its
2950
2976
  // chapter list); header and footer paint on top.
@@ -3013,9 +3039,13 @@ function frameNum(v) {
3013
3039
  /** The opening tag of a composed page's frame (#855): an empty box at the
3014
3040
  * page's origin, so the frame's blocks keep their page coordinates, turned
3015
3041
  * about the frame's centre (`frameMatrix`) and, when the frame's content
3016
- * overflows it, clipped to the frame's box (`frameClips`). */
3017
- function composedFrameOpen(frame) {
3018
- const decls = ['position:absolute', 'left:0', 'top:0', 'width:0', 'height:0'];
3042
+ * overflows it, clipped to the frame's box (`frameClips`). `z`: its place
3043
+ * in the paint order (`composedPaintOrder`), as the frames are written
3044
+ * in reading order. The facing page's half of a frame across a spread's
3045
+ * spine (#861) is hidden from assistive technology: the text is read on
3046
+ * the other page. */
3047
+ function composedFrameOpen(frame, z, facing = false) {
3048
+ const decls = ['position:absolute', 'left:0', 'top:0', 'width:0', 'height:0', `z-index:${z}`];
3019
3049
  const m = frameMatrix(frame);
3020
3050
  if (m)
3021
3051
  decls.push('transform-origin:0 0', `transform:matrix(${m.map(frameNum).join(',')})`);
@@ -3024,7 +3054,7 @@ function composedFrameOpen(frame) {
3024
3054
  const [l, t, r, b] = [x, y, x + width, y + height].map(frameNum);
3025
3055
  decls.push(`clip-path:polygon(${l}px ${t}px,${r}px ${t}px,${r}px ${b}px,${l}px ${b}px)`);
3026
3056
  }
3027
- return `<div class="pt-frame" data-frame-id="${esc(frame.id)}" data-layer="${frame.layer}" style="${decls.join(';')};">`;
3057
+ return `<div class="pt-frame" data-frame-id="${esc(frame.id)}" data-layer="${frame.layer}"${facing ? ' data-facing="true" aria-hidden="true"' : ''} style="${decls.join(';')};">`;
3028
3058
  }
3029
3059
  /** The markup of a comic on a page (its comic page, a half of a spread or
3030
3060
  * a strip, on the sheet; #565): see `renderComicHtml`. Its pictures come