@ac-kit/model-markup 0.0.0-stage → 0.1.1

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 (48) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/LICENSE +28 -0
  3. package/README.md +199 -2
  4. package/dist/_text-run.d.ts +26 -0
  5. package/dist/_text-run.d.ts.map +1 -0
  6. package/dist/_text-run.js +56 -0
  7. package/dist/_text-run.js.map +1 -0
  8. package/dist/index-markup-tree.d.ts +37 -0
  9. package/dist/index-markup-tree.d.ts.map +1 -0
  10. package/dist/index-markup-tree.js +200 -0
  11. package/dist/index-markup-tree.js.map +1 -0
  12. package/dist/index.d.ts +7 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +7 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/markup-namespace-scope.d.ts +24 -0
  17. package/dist/markup-namespace-scope.d.ts.map +1 -0
  18. package/dist/markup-namespace-scope.js +63 -0
  19. package/dist/markup-namespace-scope.js.map +1 -0
  20. package/dist/markup-navigation.d.ts +38 -0
  21. package/dist/markup-navigation.d.ts.map +1 -0
  22. package/dist/markup-navigation.js +55 -0
  23. package/dist/markup-navigation.js.map +1 -0
  24. package/dist/markup-tree-shape.d.ts +186 -0
  25. package/dist/markup-tree-shape.d.ts.map +1 -0
  26. package/dist/markup-tree-shape.js +2 -0
  27. package/dist/markup-tree-shape.js.map +1 -0
  28. package/dist/markup-values.d.ts +90 -0
  29. package/dist/markup-values.d.ts.map +1 -0
  30. package/dist/markup-values.js +169 -0
  31. package/dist/markup-values.js.map +1 -0
  32. package/dist/namespaces.d.ts +16 -0
  33. package/dist/namespaces.d.ts.map +1 -0
  34. package/dist/namespaces.js +16 -0
  35. package/dist/namespaces.js.map +1 -0
  36. package/dist/parse5/index.d.ts +99 -0
  37. package/dist/parse5/index.d.ts.map +1 -0
  38. package/dist/parse5/index.js +84 -0
  39. package/dist/parse5/index.js.map +1 -0
  40. package/dist/testing/index.d.ts +2 -0
  41. package/dist/testing/index.d.ts.map +1 -0
  42. package/dist/testing/index.js +2 -0
  43. package/dist/testing/index.js.map +1 -0
  44. package/dist/testing/record-tree.d.ts +102 -0
  45. package/dist/testing/record-tree.d.ts.map +1 -0
  46. package/dist/testing/record-tree.js +212 -0
  47. package/dist/testing/record-tree.js.map +1 -0
  48. package/package.json +68 -3
package/CHANGELOG.md ADDED
@@ -0,0 +1,69 @@
1
+ # @ac-kit/model-markup
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [065cf8d]
8
+ - Updated dependencies [065cf8d]
9
+ - Updated dependencies [065cf8d]
10
+ - @ac-kit/core@0.11.0
11
+ - @ac-kit/algo@0.4.1
12
+
13
+ ## 0.1.0
14
+
15
+ ### Minor Changes
16
+
17
+ - 5152230: New package: markup trees read through a shape, so one selector or path engine
18
+ reads XML trees, HTML parser trees and, later, the DOM without converting them.
19
+
20
+ - `MarkupTreeShape<TNode, TAttribute>`: `kindOf`, `parentOf`, `childrenOf`,
21
+ `documentModeOf` (`"xml"`, `"html"` or `"html-quirks"`), names, namespaces,
22
+ attributes, `dataOf`, `targetOf`. Optional members: `siblingIndexOf`,
23
+ `elementSiblingsOf`/`elementSiblingsWithin`,
24
+ `namespacesInScopeOf`/`namespacesInScopeWithin`, `compareDocumentOrder`,
25
+ `elementByIdOf`, `documentModeIsUniform` (an adapter's assertion that
26
+ `documentModeOf` is O(1) and gives the root's mode for every node). Every
27
+ member is O(1) unless documented otherwise, and members are called unbound.
28
+ `MarkupTreeDownShape` leaves out the upward and positional members.
29
+ - `indexMarkupTree(shape, root)`: one iterative pass that gives parents, sibling
30
+ positions, element-sibling records, document order and ids. It throws
31
+ `TypeError` on a node met twice, and `RangeError` for a node outside the tree.
32
+ - `markupStringValue(shape, node, { budget, maxLength })`: the XPath 1.0
33
+ string-value, a text node standing for its whole run. `maxLength` defaults to
34
+ and is capped at `DEFAULT_MARKUP_STRING_VALUE_MAX_LENGTH` (2²⁸ − 16 code
35
+ units); exceeding it throws `MarkupStringValueLengthError`.
36
+ - `markupTextRunStart`, `markupAttributeValue` and
37
+ `markupNamespacesFromAttributes` each take an optional shared `WorkBudget`,
38
+ and `markupStringValue` takes one through its options. `markupSiblingIndex`
39
+ takes none. A no-namespace attribute lookup (the id index included) never
40
+ matches a prefixed attribute that an adapter reports as unbound.
41
+ - `HTML_NAMESPACE`, `SVG_NAMESPACE`, `MATHML_NAMESPACE`, `XLINK_NAMESPACE`,
42
+ `XML_NAMESPACE` and `XMLNS_NAMESPACE`; `./testing` (record-tree fixtures, no
43
+ test framework).
44
+ - `./parse5` (`parse5MarkupShape`) over parse5's default tree adapter: a
45
+ template's content is not a child, the document's `mode` gives the document
46
+ mode, and SVG/MathML `xmlns` declarations are reported in scope.
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies [2a0fe74]
51
+ - Updated dependencies [5152230]
52
+ - Updated dependencies [5152230]
53
+ - Updated dependencies [2a0fe74]
54
+ - Updated dependencies [5152230]
55
+ - Updated dependencies [2a0fe74]
56
+ - Updated dependencies [5152230]
57
+ - Updated dependencies [5152230]
58
+ - Updated dependencies [2a0fe74]
59
+ - Updated dependencies [2a0fe74]
60
+ - Updated dependencies [5152230]
61
+ - Updated dependencies [5152230]
62
+ - Updated dependencies [5152230]
63
+ - Updated dependencies [5152230]
64
+ - Updated dependencies [5152230]
65
+ - Updated dependencies [5152230]
66
+ - Updated dependencies [5152230]
67
+ - Updated dependencies [5152230]
68
+ - @ac-kit/algo@0.4.0
69
+ - @ac-kit/core@0.10.0
package/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2024-2026 Anthony Champagne and contributors
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md CHANGED
@@ -1,3 +1,200 @@
1
- # Temporary Holding Version
1
+ # @ac-kit/model-markup
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Markup trees as a shape: elements, attributes, text and namespaces read through
4
+ accessors, for XML and HTML trees alike.
5
+
6
+ A CSS selector engine, an XPath evaluator and an extractor all need to walk a
7
+ markup tree, but every parser builds its own: parse5 has `childNodes` and
8
+ `parentNode`, an XML parser may have children only, a browser has the DOM.
9
+ Converting every tree to one node type costs a copy of the document and loses
10
+ the identity of the nodes the caller holds. This package instead defines
11
+ **`MarkupTreeShape`**, a record of accessor functions — `kindOf`, `parentOf`,
12
+ `childrenOf`, `localNameOf`, `namespaceOf`, `attributesOf`, `dataOf`, … — that
13
+ any tree can be read through, plus the few definitions every engine has to
14
+ share: what a node's string-value is, where a run of text starts, how ids and
15
+ document order are indexed, and the namespace URIs.
16
+
17
+ It is portable (no host APIs) and builds on `@ac-kit/algo` and `@ac-kit/core`. API reference:
18
+ <https://anthochamp.pages.grenadine.io/node-essentials/api/model-markup/>.
19
+
20
+ ## Reading a parse5 tree
21
+
22
+ The `./parse5` subpath is a ready shape over parse5's default tree adapter
23
+ (parse5 8). It is typed structurally, so this package does not depend on parse5;
24
+ install parse5 yourself.
25
+
26
+ ```ts
27
+ import { parse } from "parse5";
28
+ import { markupAttributeValue, markupStringValue } from "@ac-kit/model-markup";
29
+ import { parse5MarkupShape } from "@ac-kit/model-markup/parse5";
30
+
31
+ const document = parse('<!doctype html><p id="intro">Hello <b>world</b></p>');
32
+ const shape = parse5MarkupShape;
33
+
34
+ const html = shape.childrenOf(document)[1]!;
35
+ const body = shape.childrenOf(html)[1]!;
36
+ const paragraph = shape.childrenOf(body)[0]!;
37
+
38
+ shape.kindOf(paragraph); // "element"
39
+ shape.localNameOf(paragraph); // "p"
40
+ markupAttributeValue(shape, paragraph, "id"); // "intro"
41
+ markupStringValue(shape, paragraph); // "Hello world"
42
+ shape.documentModeOf(paragraph); // "html" — "html-quirks" without the doctype
43
+ ```
44
+
45
+ A template's content is not among its children, as in the DOM, and parse5's
46
+ `mode` gives the document mode. `namespacesInScopeOf` reports the namespace
47
+ declarations the parser placed on SVG and MathML elements (`xmlns`,
48
+ `xmlns:xlink`), inherited and shadowed down the tree, plus the implicit `xml`
49
+ binding; it walks the ancestors on each call.
50
+
51
+ ## Indexing a tree read many times
52
+
53
+ parse5 stores no sibling positions, no document order and no id table, and a
54
+ tree without parent pointers cannot be read upwards at all. `indexMarkupTree`
55
+ walks the tree once — O(n + a) for `n` nodes and `a` attributes, plus one
56
+ `documentModeOf(root)`, which for parse5 walks up to the document — and returns
57
+ a shape answering `parentOf`, `siblingIndexOf`, `documentModeOf` and
58
+ `compareDocumentOrder` in O(1) and `elementByIdOf` in O(log k) for `k` elements
59
+ sharing the id. It needs only the downward accessors, so it
60
+ also gives parents to a tree that has none.
61
+
62
+ It also answers `elementSiblingsOf(element)`: the previous and next element
63
+ siblings, the element's index and count among its element siblings, and the
64
+ same among siblings of its expanded name — what `:nth-child()`, `:nth-of-type()`
65
+ and the sibling combinators need. A parent's records are built on the first
66
+ question about one of its children, then answered in O(1).
67
+
68
+ ```ts
69
+ import { indexMarkupTree } from "@ac-kit/model-markup";
70
+ import { parse5MarkupShape } from "@ac-kit/model-markup/parse5";
71
+ import { parse } from "parse5";
72
+
73
+ const document = parse('<ul><li id="a">one</li><li id="b">two</li></ul>');
74
+ const indexed = indexMarkupTree(parse5MarkupShape, document);
75
+
76
+ const second = indexed.elementByIdOf?.(document, "b"); // the second <li>
77
+ indexed.siblingIndexOf?.(second!); // 1
78
+ ```
79
+
80
+ The index is a snapshot: a tree mutated afterwards needs a new one. It throws a
81
+ `TypeError` if the walk meets a node twice (shared children or a cycle), and the
82
+ indexed members throw a `RangeError` for a node outside the indexed tree.
83
+
84
+ ## Writing a shape for your own tree
85
+
86
+ A shape is a plain record of functions; the members are called unbound, and
87
+ nodes and attributes are compared by identity.
88
+
89
+ ```ts
90
+ import {
91
+ type MarkupTreeShape,
92
+ markupStringValue,
93
+ } from "@ac-kit/model-markup";
94
+
95
+ type Item = {
96
+ readonly tag: string;
97
+ readonly text?: string;
98
+ readonly parent: Item | null;
99
+ readonly items: Item[];
100
+ };
101
+ type Field = { readonly key: string; readonly value: string };
102
+
103
+ const itemShape: MarkupTreeShape<Item, Field> = {
104
+ kindOf: (item) => (item.text === undefined ? "element" : "text"),
105
+ parentOf: (item) => item.parent,
106
+ childrenOf: (item) => item.items,
107
+ documentModeOf: () => "xml",
108
+ localNameOf: (item) => item.tag,
109
+ namespaceOf: () => null,
110
+ prefixOf: () => null,
111
+ attributesOf: () => [],
112
+ attributeLocalNameOf: (field) => field.key,
113
+ attributeNamespaceOf: () => null,
114
+ attributePrefixOf: () => null,
115
+ attributeValueOf: (field) => field.value,
116
+ dataOf: (item) => item.text ?? "",
117
+ targetOf: () => "",
118
+ };
119
+
120
+ const root: Item = { tag: "note", parent: null, items: [] };
121
+ root.items.push({ tag: "", text: "remember", parent: root, items: [] });
122
+ markupStringValue(itemShape, root); // "remember"
123
+ ```
124
+
125
+ Every member must be O(1) unless its documentation allows more —
126
+ `documentModeOf` and `namespacesInScopeOf` may walk the ancestors,
127
+ `elementByIdOf` may be O(log k) — because the engines' complexity
128
+ statements assume it. The optional members (`siblingIndexOf`,
129
+ `namespacesInScopeOf`, `compareDocumentOrder`, `elementByIdOf`) are for trees
130
+ that can answer them cheaply; engines fall back without them.
131
+
132
+ ## Testing an engine over a plain tree
133
+
134
+ The `./testing` subpath is a fixture for tests of code that reads a markup
135
+ shape: an in-memory tree of plain records, with its shape. It imports no test
136
+ framework and is not part of the runtime surface of `.`; it is typed and
137
+ documented like the rest.
138
+
139
+ ```ts
140
+ import { markupStringValue } from "@ac-kit/model-markup";
141
+ import {
142
+ documentOf,
143
+ element,
144
+ recordShape,
145
+ text,
146
+ } from "@ac-kit/model-markup/testing";
147
+
148
+ const paragraph = element("p", { id: "intro" }, [
149
+ text("Hello "),
150
+ element("b", {}, [text("world")]),
151
+ ]);
152
+ const document = documentOf(paragraph);
153
+
154
+ markupStringValue(recordShape(), document); // "Hello world"
155
+ ```
156
+
157
+ A `RecordNode` holds `kind`, `local`, `prefix`, `namespace`, `data`, `target`,
158
+ `attributes`, `children` and `parent`; `node` builds any kind and sets the
159
+ parents of its children, so a node belongs to one parent. `element`, `text`,
160
+ `comment`, `processingInstruction`, `documentOf` and `firstElement` are the
161
+ short builders. Three shapes read it: `recordDownShape` (no `parentOf`, as a
162
+ parser without parent pointers), `recordShape` (every required member, no
163
+ optional one) and `recordNamespaceShape` (also the namespaces in scope, from the
164
+ `xmlns` attributes). `deepChain(depth)` builds a chain `depth` elements deep
165
+ without recursion, ending in a text node, and returns its outermost element;
166
+ `deepDocument(depth)` builds a chain of `depth` elements under a document and
167
+ returns `{ document, leaf }`. `wideElement(count)` returns a document whose one
168
+ element has `count` children, `randomDocument(random, size)` a seeded random
169
+ one, and `preOrder` and `elementsUnder` list nodes in document order as a
170
+ reference; every walker is iterative.
171
+
172
+ ## The model
173
+
174
+ - **Kinds**: `document`, `fragment`, `element`, `text`, `comment`,
175
+ `processingInstruction`, `doctype`. A CDATA section is `text`.
176
+ - **Document mode**: `"xml"` compares names and values exactly, `"html"` applies
177
+ the HTML Standard's case rules, `"html-quirks"` also compares `class` and `id`
178
+ case-insensitively.
179
+ - **Namespaces**: `null` means no namespace everywhere. `xmlns` and `xmlns:p`
180
+ attributes are in `XMLNS_NAMESPACE`, as in the DOM. The constants
181
+ `HTML_NAMESPACE`, `SVG_NAMESPACE`, `MATHML_NAMESPACE`, `XLINK_NAMESPACE`,
182
+ `XML_NAMESPACE` and `XMLNS_NAMESPACE` are exported, and
183
+ `markupNamespacesFromAttributes` derives the bindings in scope from those
184
+ declaration attributes, for a shape whose tree keeps them that way.
185
+ - **Text runs**: adjacent text siblings form one run, represented by its first
186
+ node (`markupTextRunStart`); a comment, a processing instruction or an element
187
+ ends a run, and an empty text node belongs to it.
188
+ - **String-value** (`markupStringValue`), as XPath 1.0 defines it: the text
189
+ descendants of a document, fragment or element; the whole run for any text
190
+ node of the run; the data of a comment or processing instruction; `""` for a
191
+ doctype; nested fragments are descended into. Iterative, so a deep tree costs
192
+ heap, never stack. Pass `{ budget }` (a `WorkBudget` from `@ac-kit/core`,
193
+ charged per node visited, per sibling inspected for a text-run boundary,
194
+ per UTF-16 code unit appended, and for the full sibling count when locating
195
+ a text node without `siblingIndexOf`). Use `{ maxLength }` to set a lower
196
+ length limit; its default and hard ceiling are 2²⁸ − 16 UTF-16 code units
197
+ (`DEFAULT_MARKUP_STRING_VALUE_MAX_LENGTH`). Exceeding the effective limit
198
+ or hitting an engine string-length limit throws `MarkupStringValueLengthError`.
199
+ - **Attributes** (`markupAttributeValue(shape, element, localName, namespace)`):
200
+ exact names, `namespace` defaulting to `null`.
@@ -0,0 +1,26 @@
1
+ import type { Callable, WorkBudget } from "@ac-kit/core";
2
+ import type { MarkupNodeKind, MarkupTreeShape } from "./markup-tree-shape.js";
3
+ /**
4
+ * The index of the first text sibling of the run holding `siblings[index]`.
5
+ * O(run); charges each sibling inspection before it happens if given a budget.
6
+ */
7
+ export declare function textRunStartIndex<TNode>(kindOf: Callable<[node: TNode], MarkupNodeKind>, siblings: ArrayLike<TNode>, index: number, budget?: WorkBudget): number;
8
+ /**
9
+ * The index just past the last text sibling of the run holding
10
+ * `siblings[index]`. O(run); charges each sibling inspection before it happens
11
+ * if given a budget.
12
+ */
13
+ export declare function textRunEndIndex<TNode>(kindOf: Callable<[node: TNode], MarkupNodeKind>, siblings: ArrayLike<TNode>, index: number, budget?: WorkBudget): number;
14
+ /** Where a node sits among its siblings; `null` for a node without a parent. */
15
+ export type SiblingPosition<TNode> = {
16
+ readonly siblings: ArrayLike<TNode>;
17
+ readonly index: number;
18
+ };
19
+ /**
20
+ * Locates `node` among its parent's children, through `siblingIndexOf` when the
21
+ * shape has it and by a scan otherwise, charging the scan to `budget`.
22
+ *
23
+ * @throws {TypeError} When the parent does not hold `node`.
24
+ */
25
+ export declare function siblingPosition<TNode, TAttribute>(shape: MarkupTreeShape<TNode, TAttribute>, node: TNode, budget: WorkBudget | undefined): SiblingPosition<TNode> | null;
26
+ //# sourceMappingURL=_text-run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_text-run.d.ts","sourceRoot":"","sources":["../src/_text-run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAE9E;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EACtC,MAAM,EAAE,QAAQ,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,cAAc,CAAC,EAC/C,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,UAAU,GACjB,MAAM,CAUR;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EACpC,MAAM,EAAE,QAAQ,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,cAAc,CAAC,EAC/C,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC,EAC1B,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,UAAU,GACjB,MAAM,CAUR;AAED,gFAAgF;AAChF,MAAM,MAAM,eAAe,CAAC,KAAK,IAAI;IACpC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,EAChD,KAAK,EAAE,eAAe,CAAC,KAAK,EAAE,UAAU,CAAC,EACzC,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,UAAU,GAAG,SAAS,GAC5B,eAAe,CAAC,KAAK,CAAC,GAAG,IAAI,CAmB/B"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * The index of the first text sibling of the run holding `siblings[index]`.
3
+ * O(run); charges each sibling inspection before it happens if given a budget.
4
+ */
5
+ export function textRunStartIndex(kindOf, siblings, index, budget) {
6
+ let start = index;
7
+ while (start > 0) {
8
+ budget?.spend(1);
9
+ if (kindOf(siblings[start - 1]) !== "text") {
10
+ break;
11
+ }
12
+ start--;
13
+ }
14
+ return start;
15
+ }
16
+ /**
17
+ * The index just past the last text sibling of the run holding
18
+ * `siblings[index]`. O(run); charges each sibling inspection before it happens
19
+ * if given a budget.
20
+ */
21
+ export function textRunEndIndex(kindOf, siblings, index, budget) {
22
+ let end = index;
23
+ while (end < siblings.length) {
24
+ budget?.spend(1);
25
+ if (kindOf(siblings[end]) !== "text") {
26
+ break;
27
+ }
28
+ end++;
29
+ }
30
+ return end;
31
+ }
32
+ /**
33
+ * Locates `node` among its parent's children, through `siblingIndexOf` when the
34
+ * shape has it and by a scan otherwise, charging the scan to `budget`.
35
+ *
36
+ * @throws {TypeError} When the parent does not hold `node`.
37
+ */
38
+ export function siblingPosition(shape, node, budget) {
39
+ const { parentOf, childrenOf, siblingIndexOf } = shape;
40
+ const parent = parentOf(node);
41
+ if (parent === null) {
42
+ return null;
43
+ }
44
+ const siblings = childrenOf(parent);
45
+ if (siblingIndexOf !== undefined) {
46
+ return { siblings, index: siblingIndexOf(node) };
47
+ }
48
+ budget?.spend(siblings.length);
49
+ for (let index = 0; index < siblings.length; index++) {
50
+ if (siblings[index] === node) {
51
+ return { siblings, index };
52
+ }
53
+ }
54
+ throw new TypeError("The shape's parentOf names a parent whose childrenOf does not hold the node");
55
+ }
56
+ //# sourceMappingURL=_text-run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_text-run.js","sourceRoot":"","sources":["../src/_text-run.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAChC,MAA+C,EAC/C,QAA0B,EAC1B,KAAa,EACb,MAAmB;IAEnB,IAAI,KAAK,GAAG,KAAK,CAAC;IAClB,OAAO,KAAK,GAAG,CAAC,EAAE,CAAC;QAClB,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAE,CAAC,KAAK,MAAM,EAAE,CAAC;YAC7C,MAAM;QACP,CAAC;QACD,KAAK,EAAE,CAAC;IACT,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC9B,MAA+C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ape, MarkupTreeShape } from "./markup-tree-shape.js";
2
+ /**
3
+ * Index the tree under `root` once, for every later read of it.
4
+ *
5
+ * The returned shape answers `parentOf`, `siblingIndexOf`, `documentModeOf` and
6
+ * `compareDocumentOrder` in O(1), `elementByIdOf` in O(log k) for `k` elements
7
+ * sharing the id — O(1) for an id used once — and `elementSiblingsOf` in
8
+ * amortised O(1): the first question about a child builds the records of all
9
+ * its parent's element children and keeps them. Cold construction takes
10
+ * O(children + name lengths) time and O(children) additional records and
11
+ * scratch space. `elementSiblingsWithin` charges that preparation before
12
+ * scanning or hashing and never caches a partial group on budget exhaustion.
13
+ * Other accessors are `shape`'s own, called unbound. That is what an engine
14
+ * reading a tree many times — one selector after another over one page — wants,
15
+ * and what a tree without parent pointers needs before it can be read at all.
16
+ *
17
+ * `root` is the root of the indexed tree: its `parentOf` is `null` and its
18
+ * `siblingIndexOf` is `0`, whatever is above it in `shape`. The document mode
19
+ * is read once, from `root`, and answered for every node
20
+ * (`documentModeIsUniform`). `elementByIdOf` reads the no-namespace `id`
21
+ * attribute of every element as it is at indexing time.
22
+ *
23
+ * A snapshot: a tree mutated after indexing needs a new index. Time O(n + a)
24
+ * for `n` nodes and `a` attributes, plus one `shape.documentModeOf(root)` —
25
+ * O(depth of `root` in its document) for a shape such as parse5's that walks up
26
+ * to the document; memory O(n). Built iteratively, so the tree's depth costs
27
+ * heap, never stack.
28
+ *
29
+ * @throws {TypeError} When the walk reaches a node a second time — `shape`
30
+ * describes a graph with shared children or a cycle, not a tree. The returned
31
+ * shape's `parentOf`, `siblingIndexOf`, `documentModeOf`,
32
+ * `compareDocumentOrder`, `elementByIdOf` and element sibling lookups throw a
33
+ * `RangeError` for a node outside the indexed tree. Both element sibling
34
+ * lookups throw a `TypeError` for a node that is not an element.
35
+ */
36
+ export declare function indexMarkupTree<TNode, TAttribute>(shape: MarkupTreeDownShape<TNode, TAttribute>, root: TNode): MarkupTreeShape<TNode, TAttribute>;
37
+ //# sourceMappingURL=index-markup-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-markup-tree.d.ts","sourceRoot":"","sources":["../src/index-markup-tree.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEX,mBAAmB,EACnB,eAAe,EACf,MAAM,wBAAwB,CAAC;AAGhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,EAChD,KAAK,EAAE,mBAAmB,CAAC,KAAK,EAAE,UAAU,CAAC,EAC7C,IAAI,EAAE,KAAK,GACT,eAAe,CAAC,KAAK,EAAE,UAAU,CAAC,CA0LpC"}
@@ -0,0 +1,200 @@
1
+ import { bisectLeft, walkTree } from "@ac-kit/algo";
2
+ import { markupAttributeValue } from "./markup-values.js";
3
+ /**
4
+ * Index the tree under `root` once, for every later read of it.
5
+ *
6
+ * The returned shape answers `parentOf`, `siblingIndexOf`, `documentModeOf` and
7
+ * `compareDocumentOrder` in O(1), `elementByIdOf` in O(log k) for `k` elements
8
+ * sharing the id — O(1) for an id used once — and `elementSiblingsOf` in
9
+ * amortised O(1): the first question about a child builds the records of all
10
+ * its parent's element children and keeps them. Cold construction takes
11
+ * O(children + name lengths) time and O(children) additional records and
12
+ * scratch space. `elementSiblingsWithin` charges that preparation before
13
+ * scanning or hashing and never caches a partial group on budget exhaustion.
14
+ * Other accessors are `shape`'s own, called unbound. That is what an engine
15
+ * reading a tree many times — one selector after another over one page — wants,
16
+ * and what a tree without parent pointers needs before it can be read at all.
17
+ *
18
+ * `root` is the root of the indexed tree: its `parentOf` is `null` and its
19
+ * `siblingIndexOf` is `0`, whatever is above it in `shape`. The document mode
20
+ * is read once, from `root`, and answered for every node
21
+ * (`documentModeIsUniform`). `elementByIdOf` reads the no-namespace `id`
22
+ * attribute of every element as it is at indexing time.
23
+ *
24
+ * A snapshot: a tree mutated after indexing needs a new index. Time O(n + a)
25
+ * for `n` nodes and `a` attributes, plus one `shape.documentModeOf(root)` —
26
+ * O(depth of `root` in its document) for a shape such as parse5's that walks up
27
+ * to the document; memory O(n). Built iteratively, so the tree's depth costs
28
+ * heap, never stack.
29
+ *
30
+ * @throws {TypeError} When the walk reaches a node a second time — `shape`
31
+ * describes a graph with shared children or a cycle, not a tree. The returned
32
+ * shape's `parentOf`, `siblingIndexOf`, `documentModeOf`,
33
+ * `compareDocumentOrder`, `elementByIdOf` and element sibling lookups throw a
34
+ * `RangeError` for a node outside the indexed tree. Both element sibling
35
+ * lookups throw a `TypeError` for a node that is not an element.
36
+ */
37
+ export function indexMarkupTree(shape, root) {
38
+ const { kindOf, childrenOf, documentModeOf, localNameOf, namespaceOf, namespacesInScopeOf, namespacesInScopeWithin, } = shape;
39
+ const orders = new Map();
40
+ const nodes = [];
41
+ const parentOrders = [];
42
+ const siblingIndices = [];
43
+ const elementOrdersById = new Map();
44
+ const ancestorOrders = [];
45
+ walkTree(root, childrenOf, (node, _parent, siblingIndex, depth) => {
46
+ if (orders.has(node)) {
47
+ throw new TypeError("indexMarkupTree reached a node twice: the shape does not describe a tree");
48
+ }
49
+ const order = nodes.length;
50
+ orders.set(node, order);
51
+ nodes.push(node);
52
+ parentOrders.push(depth === 0 ? -1 : ancestorOrders[depth - 1]);
53
+ siblingIndices.push(siblingIndex);
54
+ ancestorOrders[depth] = order;
55
+ if (kindOf(node) === "element") {
56
+ const id = markupAttributeValue(shape, node, "id");
57
+ if (id !== null && id !== "") {
58
+ const sameId = elementOrdersById.get(id);
59
+ if (sameId === undefined) {
60
+ elementOrdersById.set(id, [order]);
61
+ }
62
+ else {
63
+ sameId.push(order);
64
+ }
65
+ }
66
+ }
67
+ return undefined;
68
+ });
69
+ // The last pre-order position inside each node's subtree, filled from the
70
+ // leaves up: every descendant sits after its ancestor in pre-order.
71
+ const subtreeEnds = Array.from(nodes, (_node, order) => order);
72
+ for (let order = nodes.length - 1; order > 0; order--) {
73
+ const parentOrder = parentOrders[order];
74
+ if (subtreeEnds[order] > subtreeEnds[parentOrder]) {
75
+ subtreeEnds[parentOrder] = subtreeEnds[order];
76
+ }
77
+ }
78
+ const documentMode = documentModeOf(root);
79
+ const siblingRecords = [];
80
+ /** Builds the records of every element child of the parent at `parentOrder`. */
81
+ const recordSiblings = (parentOrder, budget) => {
82
+ const children = childrenOf(nodes[parentOrder]);
83
+ // Account for the passes, scratch columns, and cached records up front.
84
+ budget?.spend(children.length * 16);
85
+ const elements = [];
86
+ for (let index = 0; index < children.length; index++) {
87
+ const child = children[index];
88
+ if (kindOf(child) === "element") {
89
+ elements.push(child);
90
+ }
91
+ }
92
+ const typeTotals = new Map();
93
+ const typeIndices = [];
94
+ const typeCounters = [];
95
+ const localNames = [];
96
+ for (const element of elements) {
97
+ const namespace = namespaceOf(element);
98
+ const localName = localNameOf(element);
99
+ budget?.spend(localName.length + (namespace?.length ?? 0));
100
+ let byName = typeTotals.get(namespace);
101
+ if (byName === undefined) {
102
+ byName = new Map();
103
+ typeTotals.set(namespace, byName);
104
+ }
105
+ const typeIndex = byName.get(localName) ?? 0;
106
+ byName.set(localName, typeIndex + 1);
107
+ typeIndices.push(typeIndex);
108
+ typeCounters.push(byName);
109
+ localNames.push(localName);
110
+ }
111
+ for (const [index, element] of elements.entries()) {
112
+ siblingRecords[orders.get(element)] = {
113
+ previous: index > 0 ? elements[index - 1] : null,
114
+ next: index + 1 < elements.length ? elements[index + 1] : null,
115
+ index,
116
+ count: elements.length,
117
+ typeIndex: typeIndices[index],
118
+ typeCount: typeCounters[index].get(localNames[index]),
119
+ };
120
+ }
121
+ };
122
+ const orderOf = (node) => {
123
+ const order = orders.get(node);
124
+ if (order === undefined) {
125
+ throw new RangeError("The node is not in the indexed tree");
126
+ }
127
+ return order;
128
+ };
129
+ const siblingsOf = (element, budget) => {
130
+ const order = orderOf(element);
131
+ const cached = siblingRecords[order];
132
+ if (cached !== undefined) {
133
+ return cached;
134
+ }
135
+ if (kindOf(element) !== "element") {
136
+ throw new TypeError("An element sibling lookup takes an element");
137
+ }
138
+ const parentOrder = parentOrders[order];
139
+ if (parentOrder < 0) {
140
+ siblingRecords[order] = {
141
+ previous: null,
142
+ next: null,
143
+ index: 0,
144
+ count: 1,
145
+ typeIndex: 0,
146
+ typeCount: 1,
147
+ };
148
+ }
149
+ else {
150
+ recordSiblings(parentOrder, budget);
151
+ }
152
+ return siblingRecords[order];
153
+ };
154
+ const indexed = {
155
+ kindOf,
156
+ parentOf: (node) => {
157
+ const parentOrder = parentOrders[orderOf(node)];
158
+ return parentOrder < 0 ? null : nodes[parentOrder];
159
+ },
160
+ childrenOf,
161
+ siblingIndexOf: (node) => siblingIndices[orderOf(node)],
162
+ documentModeIsUniform: true,
163
+ documentModeOf: (node) => {
164
+ orderOf(node);
165
+ return documentMode;
166
+ },
167
+ localNameOf,
168
+ namespaceOf,
169
+ prefixOf: shape.prefixOf,
170
+ attributesOf: shape.attributesOf,
171
+ attributeLocalNameOf: shape.attributeLocalNameOf,
172
+ attributeNamespaceOf: shape.attributeNamespaceOf,
173
+ attributePrefixOf: shape.attributePrefixOf,
174
+ attributeValueOf: shape.attributeValueOf,
175
+ dataOf: shape.dataOf,
176
+ targetOf: shape.targetOf,
177
+ compareDocumentOrder: (a, b) => orderOf(a) - orderOf(b),
178
+ elementSiblingsOf: (element) => siblingsOf(element),
179
+ elementSiblingsWithin: siblingsOf,
180
+ elementByIdOf: (scope, id) => {
181
+ const scopeOrder = orderOf(scope);
182
+ const candidates = elementOrdersById.get(id);
183
+ if (candidates === undefined) {
184
+ return null;
185
+ }
186
+ const first = bisectLeft(candidates, scopeOrder, (candidate, bound) => candidate - bound);
187
+ if (first === candidates.length) {
188
+ return null;
189
+ }
190
+ const order = candidates[first];
191
+ return order <= subtreeEnds[scopeOrder] ? nodes[order] : null;
192
+ },
193
+ ...(namespacesInScopeOf === undefined ? {} : { namespacesInScopeOf }),
194
+ ...(namespacesInScopeWithin === undefined
195
+ ? {}
196
+ : { namespacesInScopeWithin }),
197
+ };
198
+ return indexed;
199
+ }
200
+ //# sourceMappingUR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,CAAC;QACjE,CAAC;QACD,GAAG,CAAC,mBAAmB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,mBAAmB,EAAE,CAAC;QACrE,GAAG,CAAC,uBAAuB,KAAK,SAAS;YACxC,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,EAAE,uBAAuB,EAAE,CAAC;KAC/B,CAAC;IACF,OAAO,OAAO,CAAC;AAChB,CAAC"}
@@ -0,0 +1,7 @@
1
+ export * from "./index-markup-tree.js";
2
+ export * from "./markup-namespace-scope.js";
3
+ export * from "./markup-navigation.js";
4
+ export * from "./markup-tree-shape.js";
5
+ export * from "./markup-values.js";
6
+ export * from "./namespaces.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}