@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
@@ -0,0 +1,169 @@
1
+ import { walkTree } from "@ac-kit/algo";
2
+ import { MAX_PORTABLE_STRING_LENGTH, } from "@ac-kit/core";
3
+ import { siblingPosition, textRunEndIndex, textRunStartIndex, } from "./_text-run.js";
4
+ /**
5
+ * The default and hard ceiling for {@link markupStringValue}: core's
6
+ * `MAX_PORTABLE_STRING_LENGTH`, 2²⁸ − 16 UTF-16 code units.
7
+ */
8
+ export const DEFAULT_MARKUP_STRING_VALUE_MAX_LENGTH = MAX_PORTABLE_STRING_LENGTH;
9
+ /**
10
+ * Thrown by {@link markupStringValue} when the string-value would exceed the
11
+ * effective `maxLength` or the engine cannot represent it.
12
+ */
13
+ export class MarkupStringValueLengthError extends Error {
14
+ limit;
15
+ /**
16
+ * @param limit The effective maximum, or an upper bound on the engine's
17
+ * maximum if concatenation fails below that limit.
18
+ */
19
+ constructor(limit) {
20
+ super(`Markup string-value longer than ${limit} code units`);
21
+ this.limit = limit;
22
+ this.name = "MarkupStringValueLengthError";
23
+ }
24
+ }
25
+ /**
26
+ * The string-value of a node, as XPath 1.0 defines it — the one definition
27
+ * every engine reading a {@link MarkupTreeShape} shares.
28
+ *
29
+ * - **document, fragment, element**: the data of every text descendant,
30
+ * concatenated in document order, descending through nested fragments too.
31
+ * Comments and processing instructions contribute nothing, and neither does
32
+ * anything the shape keeps out of `childrenOf`, such as a template's
33
+ * content.
34
+ * - **text**: the data of the whole text run the node belongs to (see
35
+ * {@link markupTextRunStart}), whichever member of the run is passed. Empty
36
+ * text nodes contribute `""`, so a run of empty text nodes has the empty
37
+ * string-value; an engine following the XPath data model, which has no empty
38
+ * text nodes, skips such a run rather than asking.
39
+ * - **comment, processing instruction**: its data.
40
+ * - **doctype**: `""`.
41
+ *
42
+ * O(subtree) for a document, fragment or element, plus the length of the
43
+ * result; for text, O(siblings) to locate the run without `siblingIndexOf`,
44
+ * O(run) with it, plus the length. Iterative: the tree's depth costs heap,
45
+ * never stack.
46
+ *
47
+ * @throws {MarkupStringValueLengthError} When the result would be longer than
48
+ * the effective `options.maxLength` or the engine cannot represent it.
49
+ * @throws {RangeError} When `options.maxLength` is not a non-negative safe
50
+ * integer.
51
+ * @throws {TypeError} As {@link markupSiblingIndex} does, for a text node.
52
+ * @throws Whatever `options.budget.spend` throws once it is spent.
53
+ */
54
+ export function markupStringValue(shape, node, options = {}) {
55
+ const { budget, maxLength = DEFAULT_MARKUP_STRING_VALUE_MAX_LENGTH } = options;
56
+ if (!Number.isSafeInteger(maxLength) || maxLength < 0) {
57
+ throw new RangeError("maxLength must be a non-negative safe integer");
58
+ }
59
+ const { kindOf, dataOf } = shape;
60
+ const appender = createAppender(dataOf, budget, Math.min(maxLength, DEFAULT_MARKUP_STRING_VALUE_MAX_LENGTH));
61
+ switch (kindOf(node)) {
62
+ case "text":
63
+ budget?.spend(1);
64
+ return textRunValue(shape, node, budget, appender);
65
+ case "comment":
66
+ case "processingInstruction":
67
+ budget?.spend(1);
68
+ return appender.append("", node);
69
+ case "doctype":
70
+ budget?.spend(1);
71
+ return "";
72
+ case "document":
73
+ case "fragment":
74
+ case "element":
75
+ return descendantText(shape, node, budget, appender);
76
+ }
77
+ }
78
+ /**
79
+ * The value of `element`'s attribute named `localName` in `namespace`, or
80
+ * `null` when it has none.
81
+ *
82
+ * `namespace` defaults to `null`, matching only unprefixed attributes with no
83
+ * namespace, not ones with an unbound prefix. Names compare exactly: an engine
84
+ * applying HTML's case rules folds the name first. The first match in source
85
+ * order wins, for a tree that tolerates duplicates. Takes O(attributes
86
+ * inspected plus code units compared) time and O(1) extra space.
87
+ *
88
+ * @param shape Accessors for the element's attributes.
89
+ * @param element The owner of the attributes to search.
90
+ * @param localName The exact local name to match.
91
+ * @param namespace The exact namespace URI, or `null` for no namespace.
92
+ * @param budget Optional work allowance. Charged before inspecting each entry,
93
+ * plus one unit per UTF-16 code unit of each equal-length name or URI pair
94
+ * compared. Reading the matching value does not scan or charge its contents.
95
+ * @throws Whatever `budget.spend` throws, unchanged.
96
+ */
97
+ export function markupAttributeValue(shape, element, localName, namespace = null, budget) {
98
+ const { attributesOf, attributeLocalNameOf, attributeNamespaceOf, attributePrefixOf, attributeValueOf, } = shape;
99
+ const attributes = attributesOf(element);
100
+ for (let index = 0; index < attributes.length; index++) {
101
+ budget?.spend(1);
102
+ const attribute = attributes[index];
103
+ const name = attributeLocalNameOf(attribute);
104
+ if (name.length !== localName.length) {
105
+ continue;
106
+ }
107
+ budget?.spend(localName.length);
108
+ if (name !== localName) {
109
+ continue;
110
+ }
111
+ const uri = attributeNamespaceOf(attribute);
112
+ if (uri !== null && namespace !== null && uri.length === namespace.length) {
113
+ budget?.spend(namespace.length);
114
+ }
115
+ if (uri === namespace &&
116
+ (namespace !== null || attributePrefixOf(attribute) === null)) {
117
+ return attributeValueOf(attribute);
118
+ }
119
+ }
120
+ return null;
121
+ }
122
+ function createAppender(dataOf, budget, maxLength) {
123
+ return {
124
+ append: (value, node) => {
125
+ const data = dataOf(node);
126
+ budget?.spend(data.length);
127
+ const length = value.length + data.length;
128
+ if (length > maxLength) {
129
+ throw new MarkupStringValueLengthError(maxLength);
130
+ }
131
+ try {
132
+ return value + data;
133
+ }
134
+ catch (error) {
135
+ if (error instanceof RangeError) {
136
+ throw new MarkupStringValueLengthError(length - 1);
137
+ }
138
+ throw error;
139
+ }
140
+ },
141
+ };
142
+ }
143
+ function textRunValue(shape, node, budget, appender) {
144
+ const { kindOf } = shape;
145
+ const position = siblingPosition(shape, node, budget);
146
+ if (position === null) {
147
+ return appender.append("", node);
148
+ }
149
+ const { siblings, index } = position;
150
+ const start = textRunStartIndex(kindOf, siblings, index, budget);
151
+ const end = textRunEndIndex(kindOf, siblings, index, budget);
152
+ let value = "";
153
+ for (let member = start; member < end; member++) {
154
+ value = appender.append(value, siblings[member]);
155
+ }
156
+ return value;
157
+ }
158
+ function descendantText(shape, node, budget, appender) {
159
+ const { kindOf, childrenOf } = shape;
160
+ let value = "";
161
+ walkTree(node, childrenOf, (visited) => {
162
+ if (kindOf(visited) === "text") {
163
+ value = appender.append(value, visited);
164
+ }
165
+ return undefined;
166
+ }, budget === undefined ? {} : { budget });
167
+ return value;
168
+ }
169
+ //# sourceMappingURL=markup-values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"markup-values.js","sourceRoot":"","sources":["../src/markup-values.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EACN,0BAA0B,GAG1B,MAAM,cAAc,CAAC;AAEtB,OAAO,EACN,eAAe,EACf,eAAe,EACf,iBAAiB,GACjB,MAAM,gBAAgB,CAAC;AAMxB;;;GAGG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAClD,0BAA0B,CAAC;AAwB5B;;;GAGG;AACH,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IAKjC,KAAK;IAJ1B;;;OAGG;IACH,YAAqB,KAAa;QACjC,KAAK,CAAC,mCAAmC,KAAK,aAAa,CAAC,CAAC;qBADzC,KAAK;QAEzB,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;IAC5C,CAAC;CACD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,iBAAiB,CAChC,KAAyC,EACzC,IAAW,EACX,OAAO,GAA6B,EAAE;IAEtC,MAAM,EAAE,MAAM,EAAE,SAAS,GAAG,sCAAsC,EAAE,GACnE,OAAO,CAAC;IACT,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,UAAU,CAAC,+CA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,EAAE,GAAG,KAAK,CAAC;IACrC,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,QAAQ,CACP,IAAI,EACJ,UAAU,EACV,CAAC,OAAO,EAAE,EAAE;QACX,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC;YAChC,KAAK,GAAG,QAAQ,CAAC,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;QACD,OAAO,SAAS,CAAC;IAClB,CAAC,EACD,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CACtC,CAAC;IACF,OAAO,KAAK,CAAC;AACd,CAAC"}
@@ -0,0 +1,16 @@
1
+ /** The HTML namespace, which the HTML parser puts every HTML element in. */
2
+ export declare const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
3
+ /** The SVG namespace. */
4
+ export declare const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
5
+ /** The MathML namespace. */
6
+ export declare const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
7
+ /** The XLink namespace, of `xlink:href` and its siblings. */
8
+ export declare const XLINK_NAMESPACE = "http://www.w3.org/1999/xlink";
9
+ /**
10
+ * The namespace the `xml` prefix is bound to in every document, without a
11
+ * declaration — the namespace of `xml:lang` and `xml:space`.
12
+ */
13
+ export declare const XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
14
+ /** The namespace of `xmlns` and `xmlns:p` attributes, as the DOM places them. */
15
+ export declare const XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/";
16
+ //# sourceMappingURL=namespaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespaces.d.ts","sourceRoot":"","sources":["../src/namespaces.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,eAAO,MAAM,cAAc,iCAAiC,CAAC;AAE7D,yBAAyB;AACzB,eAAO,MAAM,aAAa,+BAA+B,CAAC;AAE1D,4BAA4B;AAC5B,eAAO,MAAM,gBAAgB,uCAAuC,CAAC;AAErE,6DAA6D;AAC7D,eAAO,MAAM,eAAe,iCAAiC,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,aAAa,yCAAyC,CAAC;AAEpE,iFAAiF;AACjF,eAAO,MAAM,eAAe,kCAAkC,CAAC"}
@@ -0,0 +1,16 @@
1
+ /** The HTML namespace, which the HTML parser puts every HTML element in. */
2
+ export const HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
3
+ /** The SVG namespace. */
4
+ export const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
5
+ /** The MathML namespace. */
6
+ export const MATHML_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
7
+ /** The XLink namespace, of `xlink:href` and its siblings. */
8
+ export const XLINK_NAMESPACE = "http://www.w3.org/1999/xlink";
9
+ /**
10
+ * The namespace the `xml` prefix is bound to in every document, without a
11
+ * declaration — the namespace of `xml:lang` and `xml:space`.
12
+ */
13
+ export const XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace";
14
+ /** The namespace of `xmlns` and `xmlns:p` attributes, as the DOM places them. */
15
+ export const XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/";
16
+ //# sourceMappingURL=namespaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"namespaces.js","sourceRoot":"","sources":["../src/namespaces.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,MAAM,CAAC,MAAM,cAAc,GAAG,8BAA8B,CAAC;AAE7D,yBAAyB;AACzB,MAAM,CAAC,MAAM,aAAa,GAAG,4BAA4B,CAAC;AAE1D,4BAA4B;AAC5B,MAAM,CAAC,MAAM,gBAAgB,GAAG,oCAAoC,CAAC;AAErE,6DAA6D;AAC7D,MAAM,CAAC,MAAM,eAAe,GAAG,8BAA8B,CAAC;AAE9D;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,sCAAsC,CAAC;AAEpE,iFAAiF;AACjF,MAAM,CAAC,MAAM,eAAe,GAAG,+BAA+B,CAAC"}
@@ -0,0 +1,99 @@
1
+ import type { MarkupTreeShape } from "../markup-tree-shape.js";
2
+ /**
3
+ * An attribute of parse5's default tree adapter, declared structurally.
4
+ *
5
+ * `namespace` and `prefix` are set only on the foreign attributes the HTML
6
+ * parser adjusts (`xlink:href`, `xml:lang`, `xmlns`, …); parse5 writes an
7
+ * absent prefix as `""`.
8
+ */
9
+ export type Parse5AttributeLike = {
10
+ readonly name: string;
11
+ readonly value: string;
12
+ readonly namespace?: string;
13
+ readonly prefix?: string;
14
+ };
15
+ /**
16
+ * Parse5's `#document`; `mode` is `"no-quirks"`, `"quirks"` or
17
+ * `"limited-quirks"`.
18
+ */
19
+ export type Parse5DocumentLike = {
20
+ readonly nodeName: "#document";
21
+ readonly mode: string;
22
+ readonly childNodes: readonly Parse5ChildNodeLike[];
23
+ };
24
+ /**
25
+ * Parse5's `#document-fragment`: what `parseFragment` returns, and a template's
26
+ * content.
27
+ */
28
+ export type Parse5DocumentFragmentLike = {
29
+ readonly nodeName: "#document-fragment";
30
+ readonly childNodes: readonly Parse5ChildNodeLike[];
31
+ };
32
+ /** A parse5 element, a template included; `tagName` is its local name. */
33
+ export type Parse5ElementLike = {
34
+ readonly nodeName: string;
35
+ readonly tagName: string;
36
+ readonly namespaceURI: string;
37
+ readonly attrs: readonly Parse5AttributeLike[];
38
+ readonly parentNode: Parse5ParentNodeLike | null;
39
+ readonly childNodes: readonly Parse5ChildNodeLike[];
40
+ };
41
+ /** Parse5's `#text`. */
42
+ export type Parse5TextNodeLike = {
43
+ readonly nodeName: "#text";
44
+ readonly value: string;
45
+ readonly parentNode: Parse5ParentNodeLike | null;
46
+ };
47
+ /** Parse5's `#comment`. */
48
+ export type Parse5CommentNodeLike = {
49
+ readonly nodeName: "#comment";
50
+ readonly data: string;
51
+ readonly parentNode: Parse5ParentNodeLike | null;
52
+ };
53
+ /** Parse5's `#documentType`. */
54
+ export type Parse5DocumentTypeLike = {
55
+ readonly nodeName: "#documentType";
56
+ readonly name: string;
57
+ readonly publicId: string;
58
+ readonly systemId: string;
59
+ readonly parentNode: Parse5ParentNodeLike | null;
60
+ };
61
+ /** A parse5 node that can hold children. */
62
+ export type Parse5ParentNodeLike = Parse5DocumentLike | Parse5DocumentFragmentLike | Parse5ElementLike;
63
+ /** A parse5 node that can be a child. */
64
+ export type Parse5ChildNodeLike = Parse5ElementLike | Parse5TextNodeLike | Parse5CommentNodeLike | Parse5DocumentTypeLike;
65
+ /**
66
+ * Any node of parse5's default tree adapter (parse5 8), declared structurally
67
+ * so this package does not depend on parse5: parse5's own node types are
68
+ * assignable to it.
69
+ */
70
+ export type Parse5NodeLike = Parse5ParentNodeLike | Parse5ChildNodeLike;
71
+ /**
72
+ * A {@link MarkupTreeShape} over the trees parse5's default tree adapter builds
73
+ * — `parse` and `parseFragment` without a `treeAdapter` option.
74
+ *
75
+ * - A document's `mode` gives the document mode: `"quirks"` is `"html-quirks"`,
76
+ * the other two `"html"`. A node under a fragment, or detached from any
77
+ * document, is in `"html"` mode.
78
+ * - A template's `content` is not among its children, as in the DOM; pass the
79
+ * content fragment itself to read it.
80
+ * - The HTML parser never writes an element prefix, so `prefixOf` is always
81
+ * `null`, and a name such as `foo:bar` is a local name, as in the DOM. An
82
+ * attribute's absent or empty namespace and prefix are `null`.
83
+ * - Parse5 builds no processing instruction — its parser turns `<?…>` into a
84
+ * comment — so `targetOf` is always `""`.
85
+ * - `namespacesInScopeOf` (or `namespacesInScopeWithin` with a work budget) reads
86
+ * the declarations the parser placed in `XMLNS_NAMESPACE` — `xmlns` and
87
+ * `xmlns:xlink` on SVG and MathML elements; on an HTML element an `xmlns`
88
+ * attribute is an ordinary attribute, as in the DOM. See
89
+ * `markupNamespacesFromAttributes`.
90
+ *
91
+ * Every member is O(1) but `documentModeOf`, which walks to the root in
92
+ * O(depth), and `namespacesInScopeOf`, O(depth + attributes on the ancestor
93
+ * chain), uncached. There is no `siblingIndexOf`, `compareDocumentOrder` or
94
+ * `elementByIdOf`, since parse5 stores none of them: index the tree with
95
+ * `indexMarkupTree` when it is read more than once. Without an index the tree
96
+ * is read as it is at each call.
97
+ */
98
+ export declare const parse5MarkupShape: MarkupTreeShape<Parse5NodeLike, Parse5AttributeLike>;
99
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parse5/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGX,eAAe,EACf,MAAM,yBAAyB,CAAC;AAEjC;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAChC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,SAAS,mBAAmB,EAAE,CAAC;CACpD,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACxC,QAAQ,CAAC,QAAQ,EAAE,oBAAoB,CAAC;IACxC,QAAQ,CAAC,UAAU,EAAE,SAAS,mBAAmB,EAAE,CAAC;CACpD,CAAC;AAEF,0EAA0E;AAC1E,MAAM,MAAM,iBAAiB,GAAG;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAC/C,QAAQ,CAAC,UAAU,EAAE,oBAAoB,GAAG,I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} from "../markup-namespace-scope.js";
2
+ const NO_NODES = [];
3
+ const NO_ATTRIBUTES = [];
4
+ function kindOf(node) {
5
+ switch (node.nodeName) {
6
+ case "#document":
7
+ return "document";
8
+ case "#document-fragment":
9
+ return "fragment";
10
+ case "#text":
11
+ return "text";
12
+ case "#comment":
13
+ return "comment";
14
+ case "#documentType":
15
+ return "doctype";
16
+ default:
17
+ return "element";
18
+ }
19
+ }
20
+ function parentOf(node) {
21
+ return "parentNode" in node ? node.parentNode : null;
22
+ }
23
+ function documentModeOf(node) {
24
+ let root = node;
25
+ while ("parentNode" in root && root.parentNode !== null) {
26
+ root = root.parentNode;
27
+ }
28
+ return "mode" in root && root.mode === "quirks" ? "html-quirks" : "html";
29
+ }
30
+ function dataOf(node) {
31
+ if ("value" in node) {
32
+ return node.value;
33
+ }
34
+ return "data" in node ? node.data : "";
35
+ }
36
+ function emptyToNull(value) {
37
+ return value === undefined || value === "" ? null : value;
38
+ }
39
+ /**
40
+ * A {@link MarkupTreeShape} over the trees parse5's default tree adapter builds
41
+ * — `parse` and `parseFragment` without a `treeAdapter` option.
42
+ *
43
+ * - A document's `mode` gives the document mode: `"quirks"` is `"html-quirks"`,
44
+ * the other two `"html"`. A node under a fragment, or detached from any
45
+ * document, is in `"html"` mode.
46
+ * - A template's `content` is not among its children, as in the DOM; pass the
47
+ * content fragment itself to read it.
48
+ * - The HTML parser never writes an element prefix, so `prefixOf` is always
49
+ * `null`, and a name such as `foo:bar` is a local name, as in the DOM. An
50
+ * attribute's absent or empty namespace and prefix are `null`.
51
+ * - Parse5 builds no processing instruction — its parser turns `<?…>` into a
52
+ * comment — so `targetOf` is always `""`.
53
+ * - `namespacesInScopeOf` (or `namespacesInScopeWithin` with a work budget) reads
54
+ * the declarations the parser placed in `XMLNS_NAMESPACE` — `xmlns` and
55
+ * `xmlns:xlink` on SVG and MathML elements; on an HTML element an `xmlns`
56
+ * attribute is an ordinary attribute, as in the DOM. See
57
+ * `markupNamespacesFromAttributes`.
58
+ *
59
+ * Every member is O(1) but `documentModeOf`, which walks to the root in
60
+ * O(depth), and `namespacesInScopeOf`, O(depth + attributes on the ancestor
61
+ * chain), uncached. There is no `siblingIndexOf`, `compareDocumentOrder` or
62
+ * `elementByIdOf`, since parse5 stores none of them: index the tree with
63
+ * `indexMarkupTree` when it is read more than once. Without an index the tree
64
+ * is read as it is at each call.
65
+ */
66
+ export const parse5MarkupShape = {
67
+ kindOf,
68
+ parentOf,
69
+ childrenOf: (node) => ("childNodes" in node ? node.childNodes : NO_NODES),
70
+ documentModeOf,
71
+ localNameOf: (element) => ("tagName" in element ? element.tagName : ""),
72
+ namespaceOf: (element) => "namespaceURI" in element ? emptyToNull(element.namespaceURI) : null,
73
+ prefixOf: () => null,
74
+ attributesOf: (element) => "attrs" in element ? element.attrs : NO_ATTRIBUTES,
75
+ attributeLocalNameOf: (attribute) => attribute.name,
76
+ attributeNamespaceOf: (attribute) => emptyToNull(attribute.namespace),
77
+ attributePrefixOf: (attribute) => emptyToNull(attribute.prefix),
78
+ attributeValueOf: (attribute) => attribute.value,
79
+ dataOf,
80
+ targetOf: () => "",
81
+ namespacesInScopeOf: (element) => markupNamespacesFromAttributes(parse5MarkupShape, element),
82
+ namespacesInScopeWithin: (element, budget) => markupNamespacesFromAttributes(parse5MarkupShape, element, budget),
83
+ };
84
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/parse5/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AA6F9E,MAAM,QAAQ,GAAmC,EAAE,CAAC;AACpD,MAAM,aAAa,GAAmC,EAAE,CAAC;AAEzD,SAAS,MAAM,CAAC,IAAoB;IACnC,QAAQ,IAAI,CAAC,QAAQ,EAAE,CAAC;QACvB,KAAK,WAAW;YACf,OAAO,UAAU,CAAC;QACnB,KAAK,oBAAoB;YACxB,OAAO,UAAU,CAAC;QACnB,KAAK,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CAAC,CAAC,QAAQ,CAAC;IACzE,cAAc;IACd,WAAW,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,SAAS,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IACvE,WAAW,EAAE,CAAC,OAAO,EAAE,EAAE,CACxB,cAAc,IAAI,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI;IACrE,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI;IACpB,YAAY,EAAE,CAAC,OAAO,EAAE,EAAE,CACzB,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa;IACnD,oBAAoB,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI;IACnD,oBAAoB,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,SAAS,CAAC;IACrE,iBAAiB,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC,MAAM,CAAC;IAC/D,gBAAgB,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK;IAChD,MAAM;IACN,QAAQ,EAAE,GAAG,EAAE,CAAC,EAAE;IAClB,mBAAmB,EAAE,CAAC,OAAO,EAAE,EAAE,CAChC,8BAA8B,CAAC,iBAAiB,EAAE,OAAO,CAAC;IAC3D,uBAAuB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE,CAC5C,8BAA8B,CAAC,iBAAiB,EAAE,OAAO,EAAE,MAAM,CAAC;CACnE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./record-tree.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./record-tree.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,102 @@
1
+ import type { MarkupDocumentMode, MarkupNodeKind, MarkupTreeDownShape, MarkupTreeShape } from "../markup-tree-shape.js";
2
+ /** An attribute of a {@link RecordNode}, names already resolved. */
3
+ export type RecordAttribute = {
4
+ readonly local: string;
5
+ readonly namespace: string | null;
6
+ readonly prefix: string | null;
7
+ readonly value: string;
8
+ };
9
+ /**
10
+ * A node of a plain in-memory markup tree: children only, the parent recorded
11
+ * beside them by {@link node}. Names are resolved: `namespace` is the URI, and
12
+ * `xmlns` declarations are ordinary attributes, as an XML parser would give.
13
+ */
14
+ export type RecordNode = {
15
+ readonly kind: MarkupNodeKind;
16
+ readonly local: string;
17
+ readonly prefix: string | null;
18
+ readonly namespace: string | null;
19
+ readonly data: string;
20
+ readonly target: string;
21
+ readonly attributes: RecordAttribute[];
22
+ readonly children: RecordNode[];
23
+ parent: RecordNode | null;
24
+ };
25
+ /**
26
+ * A node of any `kind`; every field defaults to empty (`null` for the namespace
27
+ * and the prefix). Sets `parent` on each of `options.children`, so a node must
28
+ * be given to one parent only. O(children).
29
+ */
30
+ export declare function node(kind: MarkupNodeKind, options?: {
31
+ readonly local?: string;
32
+ readonly prefix?: string | null;
33
+ readonly namespace?: string | null;
34
+ readonly data?: string;
35
+ readonly target?: string;
36
+ readonly attributes?: RecordAttribute[];
37
+ readonly children?: RecordNode[];
38
+ }): RecordNode;
39
+ /**
40
+ * An element whose attributes are in no namespace and unprefixed, in
41
+ * `namespace` (none by default). `children` are adopted as by {@link node}.
42
+ */
43
+ export declare function element(local: string, attributes?: Readonly<Record<string, string>>, children?: RecordNode[], namespace?: string | null): RecordNode;
44
+ /** A text node. */
45
+ export declare function text(data: string): RecordNode;
46
+ /** A comment node. */
47
+ export declare function comment(data: string): RecordNode;
48
+ /** A processing instruction. */
49
+ export declare function processingInstruction(target: string, data: string): RecordNode;
50
+ /** A document node over `children`. */
51
+ export declare function documentOf(...children: RecordNode[]): RecordNode;
52
+ /**
53
+ * The first element child of `parent`.
54
+ *
55
+ * @throws TypeError when `parent` has no element child.
56
+ */
57
+ export declare function firstElement(parent: RecordNode): RecordNode;
58
+ /**
59
+ * A shape over {@link RecordNode} without `parentOf`, as a parser without parent
60
+ * pointers would give.
61
+ */
62
+ export declare function recordDownShape(documentMode?: MarkupDocumentMode): MarkupTreeDownShape<RecordNode, RecordAttribute>;
63
+ /** A full shape over {@link RecordNode}, with no other optional member. */
64
+ export declare function recordShape(documentMode?: MarkupDocumentMode): MarkupTreeShape<RecordNode, RecordAttribute>;
65
+ /**
66
+ * {@link recordShape} plus `namespacesInScopeOf` and `namespacesInScopeWithin`,
67
+ * derived from the `xmlns` attributes by `markupNamespacesFromAttributes`.
68
+ */
69
+ export declare function recordNamespaceShape(documentMode?: MarkupDocumentMode): MarkupTreeShape<RecordNode, RecordAttribute>;
70
+ /**
71
+ * A random document of `size` nodes under the document node, with repeated ids
72
+ * and adjacent text. O(size) time and memory.
73
+ */
74
+ export declare function randomDocument(random: () => number, size: number): RecordNode;
75
+ /**
76
+ * Every node under `root`, `root` included, in document order, by an iterative
77
+ * walk (`walkTree`): the reference the indexes are checked against. O(n) time
78
+ * and result memory, O(depth) for the walk.
79
+ */
80
+ export declare function preOrder(root: RecordNode): RecordNode[];
81
+ /**
82
+ * A chain `depth` elements deep ending in one text node, built without
83
+ * recursion; returns its outermost element. O(depth) time and memory.
84
+ */
85
+ export declare function deepChain(depth: number, data?: string): RecordNode;
86
+ /**
87
+ * A document holding a chain of `depth` nested `e` elements, built without
88
+ * recursion; returns the document and the innermost element. O(depth) time and
89
+ * memory.
90
+ */
91
+ export declare function deepDocument(depth: number): {
92
+ readonly document: RecordNode;
93
+ readonly leaf: RecordNode;
94
+ };
95
+ /** A document holding one element `p` with `count` children `c`. O(count). */
96
+ export declare function wideElement(count: number): RecordNode;
97
+ /**
98
+ * Every element under `root`, `root` excluded, in document order, iteratively.
99
+ * O(n) time and result memory, plus a stack of the pending siblings.
100
+ */
101
+ export declare function elementsUnder(root: RecordNode): RecordNode[];
102
+ //# sourceMappingURL=record-tree.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-tree.d.ts","sourceRoot":"","sources":["../../src/testing/record-tree.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACX,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,MAAM,yBAAyB,CAAC;AAEjC,oEAAoE;AACpE,MAAM,MAAM,eAAe,GAAG;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG;IACxB,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,eAAe,EAAE,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,UAAU,EAAE,CAAC;IAChC,MAAM,EAAE,UAAU,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,IAAI,CACnB,IAAI,EAAE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