@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.
- package/README.md +7 -6
- package/dist/seam/client.d.ts +12 -4
- package/dist/seam/client.js +57 -21
- package/dist/seam/facsimile.d.ts +13 -5
- package/dist/seam/facsimile.js +28 -12
- package/dist/seam/index.js +1 -1
- package/dist/seam/rewrite.js +7 -1
- package/dist/seam/rim.d.ts +6 -2
- package/dist/seam/rim.js +54 -11
- package/dist/src/capture.d.ts +28 -0
- package/dist/src/capture.js +121 -45
- package/dist/src/compose-dom.d.ts +8 -0
- package/dist/src/compose-dom.js +62 -8
- package/dist/src/compositor.d.ts +11 -2
- package/dist/src/compositor.js +47 -15
- package/dist/src/data-beltype.d.ts +11 -1
- package/dist/src/data-beltype.js +20 -1
- package/dist/src/document-state.d.ts +6 -2
- package/dist/src/document-state.js +87 -11
- package/dist/src/driver.d.ts +6 -0
- package/dist/src/driver.js +36 -46
- package/dist/src/forcing-memo.d.ts +10 -0
- package/dist/src/forcing-memo.js +22 -0
- package/dist/src/fragmentation.d.ts +3 -3
- package/dist/src/fragmentation.js +3 -3
- package/dist/src/fragments.d.ts +1 -1
- package/dist/src/fragments.js +47 -16
- package/dist/src/gauge.d.ts +0 -4
- package/dist/src/gauge.js +16 -30
- package/dist/src/gcpm-encoding.d.ts +2 -0
- package/dist/src/gcpm-encoding.js +2 -0
- package/dist/src/measure.d.ts +17 -12
- package/dist/src/measure.js +30 -16
- package/dist/src/positions.js +21 -9
- package/dist/src/reads.d.ts +4 -2
- package/dist/src/reads.js +10 -4
- package/dist/src/root.d.ts +18 -1
- package/dist/src/root.js +29 -3
- package/dist/src/stonehand.js +2 -6
- package/dist/src/word-space.d.ts +10 -8
- package/dist/src/word-space.js +44 -16
- package/package.json +5 -1
package/dist/src/word-space.js
CHANGED
|
@@ -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
|
-
* **
|
|
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
|
-
*
|
|
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
|
|
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
|
|
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
|
|
491
|
-
if (sourceStyle(
|
|
492
|
-
return
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
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
|
|
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
|
|
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
|
|
506
|
-
if (sourceStyle(el)?.display !== 'table-
|
|
533
|
+
export function footerBeforeRows(el) {
|
|
534
|
+
if (sourceStyle(el)?.display !== 'table-footer-group')
|
|
507
535
|
return false;
|
|
508
|
-
for (let s = el.
|
|
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.
|
|
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"
|