@beltype/cicero 0.1.9 → 0.1.11

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 (42) hide show
  1. package/README.md +7 -6
  2. package/dist/seam/client.d.ts +12 -4
  3. package/dist/seam/client.js +57 -21
  4. package/dist/seam/facsimile.d.ts +13 -5
  5. package/dist/seam/facsimile.js +28 -12
  6. package/dist/seam/index.js +1 -1
  7. package/dist/seam/rewrite.js +7 -1
  8. package/dist/seam/rim.d.ts +6 -2
  9. package/dist/seam/rim.js +54 -11
  10. package/dist/src/capture.d.ts +28 -0
  11. package/dist/src/capture.js +121 -45
  12. package/dist/src/compose-dom.d.ts +8 -0
  13. package/dist/src/compose-dom.js +62 -8
  14. package/dist/src/compositor.d.ts +11 -2
  15. package/dist/src/compositor.js +47 -15
  16. package/dist/src/data-beltype.d.ts +11 -1
  17. package/dist/src/data-beltype.js +20 -1
  18. package/dist/src/document-state.d.ts +6 -2
  19. package/dist/src/document-state.js +87 -11
  20. package/dist/src/driver.d.ts +6 -0
  21. package/dist/src/driver.js +36 -46
  22. package/dist/src/forcing-memo.d.ts +10 -0
  23. package/dist/src/forcing-memo.js +22 -0
  24. package/dist/src/fragmentation.d.ts +3 -3
  25. package/dist/src/fragmentation.js +3 -3
  26. package/dist/src/fragments.d.ts +1 -1
  27. package/dist/src/fragments.js +47 -16
  28. package/dist/src/gauge.d.ts +0 -4
  29. package/dist/src/gauge.js +16 -30
  30. package/dist/src/gcpm-encoding.d.ts +2 -0
  31. package/dist/src/gcpm-encoding.js +2 -0
  32. package/dist/src/measure.d.ts +17 -12
  33. package/dist/src/measure.js +30 -16
  34. package/dist/src/positions.js +21 -9
  35. package/dist/src/reads.d.ts +4 -2
  36. package/dist/src/reads.js +10 -4
  37. package/dist/src/root.d.ts +18 -1
  38. package/dist/src/root.js +29 -3
  39. package/dist/src/stonehand.js +2 -6
  40. package/dist/src/word-space.d.ts +10 -8
  41. package/dist/src/word-space.js +44 -16
  42. package/package.json +5 -1
@@ -29,7 +29,7 @@ export const UNSPACED_SCRIPT = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Kata
29
29
  /**
30
30
  * Could the browser have drawn a hyphen at a line boundary between these two characters that the source does not carry? The one question that decides whether a line inside a word may be a cut the fragment can write: a silent break needs nothing at the cut, and a break after U+00AD needs the soft hyphen the source holds written as the hyphenation character (`fragments.js`, *the hyphen is written at the cut*). What is left is a hyphen the browser drew between two letters under `hyphens: auto`, where no character of the source says where.
31
31
  *
32
- * **Refuses where it cannot tell.** Under `hyphens: auto` the browser may hyphenate between any two letters of a script that hyphenates, and nothing in the DOM says whether it did — so that break is refused, the word stays whole, and the page ends a line early rather than print half a word with no hyphen. (The browser does leave its drawing in the range rects, an inked rect for the hyphen on the line it ends, so the question is answerable by measurement; what an address would say for it is its own round.) `hyphens: none` and `manual` draw one only at a soft hyphen.
32
+ * **Answered by measurement, read by the source on both sides.** Under `hyphens: auto` the browser may hyphenate between any two letters of a script that hyphenates, and nothing in the DOM says whether it did; the range rects do, an inked rect for the hyphen on the line the break ends. So the Gauge opens a piece at such a break only where it measured that hyphen (`gauge.js`, `drewHyphen`), and refuses one that drew none, where the page ends a line early rather than print a hyphen the browser did not draw; the fragment writer asks this same predicate of the same characters and adds the hyphenation character after the last kept letter (`fragments.js`). The address carries no mark: the measurement decides which breaks are cuts, and the source decides what the cut writes. `hyphens: none` and `manual` draw one only at a soft hyphen.
33
33
  *
34
34
  * @param before - the character before the break
35
35
  * @param after - the character after it
@@ -481,31 +481,59 @@ export function blockChildrenOf(el, isInline = isInlineBox) {
481
481
  return out;
482
482
  }
483
483
  /**
484
- * Is this a table's footer group written before a row or row group of its table — HTML 4's order, still legal — which CSS 2.1 §17.2 lays out after them all the same (*"always displayed after all other rows and row groups"*)?
484
+ * A table's children in CSS 2.1 §17.2's display order: its header group before every other row and row group, its footer group after them, and everything else as written. Any other element's children are returned as they are, the same array.
485
485
  *
486
- * @remarks The one place the order and the layout disagree inside a table's procession (*the footer before the rows*, 2026-10-15): the Gauge walks such a footer last, the Stonehand offers no place before it or inside it, and the footer's reservation is made where it stands. Read by computed display, so a clone answers for its source.
486
+ * @remarks THE WORD SPACE follows this order inside a table (*the-word-space-follows-the-table-display-order*, 2026-11-07), and so does every reader of it: the position index numbers a table's words in it, a path's indices count a table's children in it, the Gauge walks a table's procession in it, and a fragment's two cuts put away the children standing before or after them in it. §17.2 lays a `table-header-group` out *"before all other rows and row groups"* and a `table-footer-group` *"after all other rows and row groups"*, wherever each is written, and Chromium paints them so; numbered in the order written, a header after its rows had its words last and its box first, which lost rows with no message (*thead-after-rows-and-tall-footer-lose-rows*). Only the first group of each kind moves, because §17.2 renders any later one as a row group. A move only ever goes toward the rows, so a table written in HTML's order is returned unchanged. Read by computed display, so a clone answers for its source, and a tree that cannot be asked (the DOM-free suites) keeps the order written.
487
487
  *
488
- * @param el - a clone or a source element.
488
+ * @param parent - the element whose children these are.
489
+ * @param items - its children, or what stands for them (the Gauge's boxes), in the order written.
490
+ * @param elOf - the element an item stands for; `null` for a text node, which stays where it is.
489
491
  */
490
- export function footerBeforeRows(el) {
491
- if (sourceStyle(el)?.display !== 'table-footer-group')
492
- return false;
493
- for (let s = el.nextElementSibling; s; s = s.nextElementSibling)
494
- if (/^table-row(-group)?$/.test(sourceStyle(s)?.display ?? ''))
495
- return true;
496
- return false;
492
+ export function inDisplayOrder(parent, items, elOf = (item) => item) {
493
+ if (items.length < 2 || !/^(inline-)?table$/.test(sourceStyle(parent)?.display ?? ''))
494
+ return items;
495
+ const displays = items.map((item) => {
496
+ const el = elOf(item);
497
+ return el?.nodeType === 1 ? sourceStyle(el)?.display ?? '' : '';
498
+ });
499
+ const h = displays.indexOf('table-header-group');
500
+ const f = displays.indexOf('table-footer-group');
501
+ const body = (i) => i !== h && i !== f && /^table-(row|row-group|header-group|footer-group)$/.test(displays[i]);
502
+ let first = -1;
503
+ let last = -1;
504
+ displays.forEach((_, i) => {
505
+ if (!body(i))
506
+ return;
507
+ if (first < 0)
508
+ first = i;
509
+ last = i;
510
+ });
511
+ const early = h >= 0 && first >= 0 && h > first;
512
+ const late = f >= 0 && last >= 0 && f < last;
513
+ if (!early && !late)
514
+ return items;
515
+ const out = [];
516
+ items.forEach((item, i) => {
517
+ if (early && i === first)
518
+ out.push(items[h]);
519
+ if (!((early && i === h) || (late && i === f)))
520
+ out.push(item);
521
+ if (late && i === last)
522
+ out.push(items[f]);
523
+ });
524
+ return out;
497
525
  }
498
526
  /**
499
- * Is this a table's header group written after a row or row group of its table, which CSS 2.1 §17.2 lays out before them all the same (*"always displayed before all other rows and row groups"*)?
527
+ * Is this a table's footer group written before a row or row group of its table — HTML 4's order, still legal — which CSS 2.1 §17.2 lays out after them all the same?
500
528
  *
501
- * @remarks The mirror of {@link footerBeforeRows} (*thead-after-rows-and-tall-footer-lose-rows*, 2026-11-07): the Gauge walks such a header first, the Stonehand offers no place inside it or right after it, and its words stand after the rows in the word space, so a page before its words shows it by its repeated copy alone. One that does not repeat, in a divided table, is refused by the driver. Read by computed display, so a clone answers for its source.
529
+ * @remarks Asked by the driver alone, for the one shape that stays refused: such a footer taller than the page area (*the footer before the rows*, 2026-10-15). Its words follow the rows in the word space ({@link inDisplayOrder}), so everywhere else it is a footer like any other. Read by computed display, so a clone answers for its source.
502
530
  *
503
531
  * @param el - a clone or a source element.
504
532
  */
505
- export function headerAfterRows(el) {
506
- if (sourceStyle(el)?.display !== 'table-header-group')
533
+ export function footerBeforeRows(el) {
534
+ if (sourceStyle(el)?.display !== 'table-footer-group')
507
535
  return false;
508
- for (let s = el.previousElementSibling; s; s = s.previousElementSibling)
536
+ for (let s = el.nextElementSibling; s; s = s.nextElementSibling)
509
537
  if (/^table-row(-group)?$/.test(sourceStyle(s)?.display ?? ''))
510
538
  return true;
511
539
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beltype/cicero",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Cicero, a paged-media engine for the live browser: it cuts a document into pages under CSS Paged Media and presents them as real frames. Beta.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -40,6 +40,10 @@
40
40
  "types": "./dist/seam/client.d.ts",
41
41
  "import": "./dist/seam/client.js"
42
42
  },
43
+ "./rim": {
44
+ "types": "./dist/seam/rim.d.ts",
45
+ "import": "./dist/seam/rim.js"
46
+ },
43
47
  "./fragmentation": {
44
48
  "types": "./dist/src/fragmentation.d.ts",
45
49
  "import": "./dist/src/fragmentation.js"