@grafctory/mime-xml 0.0.0-stage → 0.5.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 (63) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +56 -2
  3. package/dist/denoise.core.d.ts +12 -0
  4. package/dist/denoise.core.d.ts.map +1 -0
  5. package/dist/denoise.core.js +78 -0
  6. package/dist/denoise.core.js.map +1 -0
  7. package/dist/denoise.d.ts +45 -0
  8. package/dist/denoise.d.ts.map +1 -0
  9. package/dist/denoise.js +63 -0
  10. package/dist/denoise.js.map +1 -0
  11. package/dist/focus.core.d.ts +9 -0
  12. package/dist/focus.core.d.ts.map +1 -0
  13. package/dist/focus.core.js +305 -0
  14. package/dist/focus.core.js.map +1 -0
  15. package/dist/focus.d.ts +64 -0
  16. package/dist/focus.d.ts.map +1 -0
  17. package/dist/focus.js +88 -0
  18. package/dist/focus.js.map +1 -0
  19. package/dist/html.core.d.ts +9 -0
  20. package/dist/html.core.d.ts.map +1 -0
  21. package/dist/html.core.js +229 -0
  22. package/dist/html.core.js.map +1 -0
  23. package/dist/html.d.ts +76 -0
  24. package/dist/html.d.ts.map +1 -0
  25. package/dist/html.js +104 -0
  26. package/dist/html.js.map +1 -0
  27. package/dist/index.core.d.ts +74 -0
  28. package/dist/index.core.d.ts.map +1 -0
  29. package/dist/index.core.js +117 -0
  30. package/dist/index.core.js.map +1 -0
  31. package/dist/index.d.ts +67 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +116 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/untag.core.d.ts +9 -0
  36. package/dist/untag.core.d.ts.map +1 -0
  37. package/dist/untag.core.js +216 -0
  38. package/dist/untag.core.js.map +1 -0
  39. package/dist/untag.d.ts +86 -0
  40. package/dist/untag.d.ts.map +1 -0
  41. package/dist/untag.js +102 -0
  42. package/dist/untag.js.map +1 -0
  43. package/dist/unwrap.d.ts +37 -0
  44. package/dist/unwrap.d.ts.map +1 -0
  45. package/dist/unwrap.js +69 -0
  46. package/dist/unwrap.js.map +1 -0
  47. package/dist/xml.core.d.ts +9 -0
  48. package/dist/xml.core.d.ts.map +1 -0
  49. package/dist/xml.core.js +86 -0
  50. package/dist/xml.core.js.map +1 -0
  51. package/dist/xml.d.ts +69 -0
  52. package/dist/xml.d.ts.map +1 -0
  53. package/dist/xml.js +97 -0
  54. package/dist/xml.js.map +1 -0
  55. package/dist/xpath.core.d.ts +100 -0
  56. package/dist/xpath.core.d.ts.map +1 -0
  57. package/dist/xpath.core.js +279 -0
  58. package/dist/xpath.core.js.map +1 -0
  59. package/dist/xpath.d.ts +128 -0
  60. package/dist/xpath.d.ts.map +1 -0
  61. package/dist/xpath.js +33 -0
  62. package/dist/xpath.js.map +1 -0
  63. package/package.json +62 -4
@@ -0,0 +1,279 @@
1
+ /*
2
+ * Copyright © 2026 Metreeca srl
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { hasChildren, isCDATA, isComment, isDirective, isDocument, isTag, isText } from "domhandler";
17
+ import { createEvaluator, XPathResult } from "xpathway";
18
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
19
+ /**
20
+ * The namespace the `xml` prefix stands for, bound by definition rather than by declaration.
21
+ */
22
+ const XMLNamespace = "http://www.w3.org/XML/1998/namespace";
23
+ /**
24
+ * The attribute recording the URL relative references resolve against.
25
+ */
26
+ const XMLBase = "xml:base";
27
+ /**
28
+ * The attributes projected for an element.
29
+ *
30
+ * Attributes are held by a tree as a plain record rather than as nodes, so a node-set holding one holds a handle
31
+ * projected for it; projecting a fresh handle on every step would break the identity a selection is deduplicated and
32
+ * ordered by, so the handles of an element are projected once and kept.
33
+ */
34
+ const handles = new WeakMap();
35
+ /**
36
+ * The children a node states, less the directives.
37
+ *
38
+ * Kept alongside the handles, and for the same reason: a step reads the children of a node many times over, and a tree
39
+ * is not modified while it is selected from.
40
+ */
41
+ const contents = new WeakMap();
42
+ /**
43
+ * Binds every prefix to itself, so that a prefixed name test is matched as the tree holds it.
44
+ */
45
+ const resolver = { lookupNamespaceURI: prefix => prefix };
46
+ /**
47
+ * Reports a parsed tree to the engine, which imports no node type of its own.
48
+ */
49
+ const adapter = {
50
+ nodeType: node => isAttribute(node) ? 2
51
+ : isTag(node) ? 1
52
+ : isText(node) || isCDATA(node) ? 3
53
+ : isComment(node) ? 8
54
+ : isDocument(node) ? 9
55
+ : 0, // a directive, reachable only as the node a selection is evaluated against
56
+ parent: node => node.parent,
57
+ childNodes: node => isAttribute(node) ? [] : stated(node),
58
+ ownerDocument: node => owner(node),
59
+ localName: node => local(qualified(node)),
60
+ namespaceURI: node => namespace(prefixed(qualified(node))),
61
+ nodeName: node => qualified(node),
62
+ attributes: node => isAttribute(node) ? [] : isTag(node) ? projected(node) : [],
63
+ getAttribute: (node, uri, name) => isAttribute(node) || !isTag(node) ? null
64
+ : node.attribs[qualify(uri, name)] ?? null,
65
+ stringValue: node => content(node),
66
+ compareDocumentPosition: (x, y) => order(x, y),
67
+ getElementById: (root, id) => isAttribute(root) ? null : identified(root, id) ?? null,
68
+ isHtmlDocument: () => false, // names are matched as the tree holds them, whatever the format
69
+ nextSibling: node => isAttribute(node) ? null : following(node),
70
+ previousSibling: node => isAttribute(node) ? null : preceding(node)
71
+ };
72
+ /**
73
+ * Parses every expression once and keeps it, so that an expression repeated across the nodes of a feed is read as a
74
+ * lookup rather than as a parse.
75
+ */
76
+ const evaluator = createEvaluator(adapter);
77
+ function kept(cache, key, project) {
78
+ const cached = cache.get(key);
79
+ if (cached === undefined) {
80
+ const value = project(key);
81
+ cache.set(key, value);
82
+ return value;
83
+ }
84
+ else {
85
+ return cached;
86
+ }
87
+ }
88
+ function stated(node) {
89
+ // a CDATA section stands for the text it wraps, whose nodes the tree doesn't hold; the XML declaration, the
90
+ // document type declaration and the processing instructions are no nodes
91
+ return isCDATA(node) || !hasChildren(node) ? []
92
+ : kept(contents, node, parent => parent.children.filter(child => !isDirective(child)));
93
+ }
94
+ function projected(element) {
95
+ return kept(handles, element, stating => Object.entries(stating.attribs)
96
+ .map(([name, value]) => Object.freeze({ name, value, parent: stating })));
97
+ }
98
+ function following(node) {
99
+ const next = node.next;
100
+ return next === null ? null : isDirective(next) ? following(next) : next;
101
+ }
102
+ function preceding(node) {
103
+ const previous = node.prev;
104
+ return previous === null ? null : isDirective(previous) ? preceding(previous) : previous;
105
+ }
106
+ function outermost(node) {
107
+ return node.parent === null ? node : outermost(node.parent);
108
+ }
109
+ function owner(node) {
110
+ const root = outermost(node);
111
+ return !isAttribute(root) && isDocument(root) ? root : null;
112
+ }
113
+ function identified(node, id) {
114
+ return stated(node).filter(isTag).reduce((found, element) => found ?? (element.attribs["id"] === id ? element : identified(element, id)), undefined);
115
+ }
116
+ function qualified(node) {
117
+ return isAttribute(node) || isTag(node) ? node.name : "";
118
+ }
119
+ function local(name) {
120
+ return name.slice(name.lastIndexOf(":") + 1);
121
+ }
122
+ function prefixed(name) {
123
+ const colon = name.lastIndexOf(":");
124
+ return colon < 0 ? undefined : name.slice(0, colon);
125
+ }
126
+ function namespace(prefix) {
127
+ return prefix === undefined ? null : prefix === "xml" ? XMLNamespace : prefix;
128
+ }
129
+ function qualify(namespace, name) {
130
+ return namespace === null ? name
131
+ : namespace === XMLNamespace ? `xml:${name}`
132
+ : `${namespace}:${name}`;
133
+ }
134
+ function text(node) {
135
+ return node.children
136
+ .map(child => isText(child) ? child.data : hasChildren(child) ? text(child) : "")
137
+ .join("");
138
+ }
139
+ function order(x, y) {
140
+ return compare(chain(x), chain(y));
141
+ function chain(node) {
142
+ return node.parent === null ? [node] : [...chain(node.parent), node];
143
+ }
144
+ function compare(xs, ys) {
145
+ const [x, ...xt] = xs;
146
+ const [y, ...yt] = ys;
147
+ return x === undefined || y === undefined ? xs.length - ys.length // one node holds the other
148
+ : x === y ? compare(xt, yt)
149
+ : position(x) - position(y);
150
+ }
151
+ function position(node) {
152
+ if (isAttribute(node)) {
153
+ // attributes precede the children of their element, in the order the element states them
154
+ const attributes = projected(node.parent);
155
+ return attributes.indexOf(node) - attributes.length;
156
+ }
157
+ else if (node.parent === null) {
158
+ return 0; // a root, or a node of a tree the other node doesn't belong to
159
+ }
160
+ else {
161
+ return stated(node.parent).indexOf(node);
162
+ }
163
+ }
164
+ }
165
+ ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
166
+ /**
167
+ * Checks whether a value is a node.
168
+ *
169
+ * @param value The value to check
170
+ *
171
+ * @returns `true` if `value` is a node held by a tree, or an attribute of one; `false` if it is a value an expression
172
+ * computed
173
+ */
174
+ export function isNode(value) {
175
+ return typeof value === "object";
176
+ }
177
+ /**
178
+ * Checks whether a value is an attribute.
179
+ *
180
+ * @param value The value to check
181
+ *
182
+ * @returns `true` if `value` is an attribute of an element; `false` otherwise
183
+ */
184
+ export function isAttribute(value) {
185
+ return isNode(value) && "value" in value; // no node a tree holds carries a value of its own
186
+ }
187
+ /**
188
+ * Checks whether a value is an element.
189
+ *
190
+ * @param value The value to check
191
+ *
192
+ * @returns `true` if `value` is an element; `false` otherwise
193
+ */
194
+ export function isElement(value) {
195
+ return isNode(value) && !isAttribute(value) && isTag(value);
196
+ }
197
+ /**
198
+ * Reads the text a value holds.
199
+ *
200
+ * @param value The value to read
201
+ *
202
+ * @returns The text `value` is written as, as the XPath `string()` function converts it: the value of an attribute, the
203
+ * text a comment carries, the character data held by the tree rooted at any other node, the comments and
204
+ * directives within it contributing none, and the written form of a computed string, number or boolean
205
+ *
206
+ * @see {@link https://www.w3.org/TR/1999/REC-xpath-19991116/#function-string XML Path Language (XPath) 1.0 - string()}
207
+ */
208
+ export function content(value) {
209
+ return !isNode(value) ? String(value)
210
+ : isAttribute(value) ? value.value
211
+ : isText(value) || isComment(value) ? value.data
212
+ : hasChildren(value) ? text(value)
213
+ : "";
214
+ }
215
+ /**
216
+ * Draws the URL the relative references held by a value resolve against.
217
+ *
218
+ * Reads the base URL a tree records as it is parsed, so that a reference is resolved by the standard rules wherever it
219
+ * sits in the tree, without the request the tree was drawn from being tracked alongside it.
220
+ *
221
+ * The base is the one stated by the nearest `xml:base` attribute in scope of the value, that is on the value itself, if
222
+ * it is an element, or on its closest ancestor stating one, each value resolved against the ones stated further up. A
223
+ * tree that states none, as one parsed from text under no stated base does, and one whose outermost `xml:base` is
224
+ * itself a relative reference state no base, as does a value an expression computed, which holds no tree.
225
+ *
226
+ * @param value The value whose base URL is to be drawn
227
+ *
228
+ * @returns The absolute URL relative references held by `value` resolve against; `undefined` if the tree holding
229
+ * `value` states none
230
+ *
231
+ * @see {@link https://www.w3.org/TR/xmlbase/ XML Base}
232
+ */
233
+ export function base(value) {
234
+ return isNode(value)
235
+ ? scoped(value).reduce((base, stated) => located(stated, base), undefined)
236
+ : undefined;
237
+ function scoped(node) {
238
+ const outer = node.parent === null ? [] : scoped(node.parent);
239
+ const stated = isElement(node) ? node.attribs[XMLBase] : undefined;
240
+ return stated === undefined ? outer : [...outer, stated];
241
+ }
242
+ function located(value, base) {
243
+ try {
244
+ return new URL(value, base);
245
+ }
246
+ catch { // a relative reference resolving against no base locates nothing
247
+ return undefined;
248
+ }
249
+ }
250
+ }
251
+ /**
252
+ * Selects values from a value.
253
+ *
254
+ * Helper backing the `XPath` selector, which states the selection contract.
255
+ */
256
+ export function select(value, path) {
257
+ if (!isNode(value)) {
258
+ return []; // a computed value holds no tree to select from
259
+ }
260
+ else {
261
+ const selection = evaluator.evaluate(path, value, resolver);
262
+ return selection.resultType === XPathResult.NUMBER_TYPE ? [selection.numberValue]
263
+ : selection.resultType === XPathResult.STRING_TYPE ? [selection.stringValue]
264
+ : selection.resultType === XPathResult.BOOLEAN_TYPE ? [selection.booleanValue]
265
+ : [...drawn(selection)];
266
+ }
267
+ /**
268
+ * Draws the nodes of a selection.
269
+ *
270
+ * The engine reports a set of nodes as a cursor stating no length, so they are drawn one at a time; recursion would
271
+ * grow the stack with the size of the set, which a page places no bound on.
272
+ */
273
+ function* drawn(selection) {
274
+ for (let node = selection.iterateNext(); node !== null; node = selection.iterateNext()) {
275
+ yield node;
276
+ }
277
+ }
278
+ }
279
+ //# sourceMappingURL=xpath.core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xpath.core.js","sourceRoot":"","sources":["../src/xpath.core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACrG,OAAO,EAAgB,eAAe,EAA8B,WAAW,EAAE,MAAM,UAAU,CAAC;AA8ClG,wHAAwH;AAExH;;GAEG;AACH,MAAM,YAAY,GAAG,sCAAsC,CAAC;AAE5D;;GAEG;AACH,MAAM,OAAO,GAAG,UAAU,CAAC;AAG3B;;;;;;GAMG;AACH,MAAM,OAAO,GAAG,IAAI,OAAO,EAAiC,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAoC,CAAC;AAEjE;;GAEG;AACH,MAAM,QAAQ,GAAa,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC;AAGpE;;GAEG;AACH,MAAM,OAAO,GAAkB;IAE9B,QAAQ,EAAE,IAAI,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;YAChB,CAAC,CAAC,MAAM,CAAC,IAAI,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,IAAI,CAAC;YAEJ,OAAO,IAAI,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAE7B,CAAC;QAAC,MAAM,CAAC,CAAC,iEAAiE;YAE1E,OAAO,SAAS,CAAC;QAElB,CAAC;IAEF,CAAC;AAEF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,KAAa,EAAE,IAAY;IAEjD,IAAK,CAAC,MAAM,CAAC,KAAK,CAAC,EAAG,CAAC;QAEtB,OAAO,EAAE,CAAC,CAAC,gDAAgD;IAE5D,CAAC;SAAM,CAAC;QAEP,MAAM,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAE5D,OAAO,SAAS,CAAC,UAAU,KAAK,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC;YAChF,CAAC,CAAC,SAAS,CAAC,UAAU,KAAK,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,CAAC;gBAC3E,CAAC,CAAC,SAAS,CAAC,UAAU,KAAK,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,YAAY,CAAC;oBAC7E,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IAE5B,CAAC;IAGD;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,KAAK,CAAC,SAAuB;QACtC,KAAK,IAAI,IAAI,GAAG,SAAS,CAAC,WAAW,EAAE,EAAE,IAAI,KAAK,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC,WAAW,EAAE,EAAE,CAAC;YACxF,MAAM,IAAI,CAAC;QACZ,CAAC;IACF,CAAC;AAEF,CAAC"}
@@ -0,0 +1,128 @@
1
+ import type { Task } from "@grafctory/flow";
2
+ import type { AnyNode } from "domhandler";
3
+ import { type Target } from "./xpath.core.js";
4
+ export type { Attribute, Target } from "./xpath.core.js";
5
+ /**
6
+ * XPath selector over parsed X/HTML trees.
7
+ *
8
+ * Selects nodes and computed values from a set of {@link Target} nodes, using XPath 1.0 expressions. The target set is
9
+ * fixed when the selector is created.
10
+ *
11
+ * @see {@link https://www.w3.org/TR/1999/REC-xpath-19991116/ XML Path Language (XPath) 1.0}
12
+ */
13
+ export type XPath = {
14
+ /**
15
+ * Selects values.
16
+ *
17
+ * Each selection spans the whole target set: the expression is evaluated with each target as context node, and the
18
+ * results are merged into a single list. All XPath 1.0 axes, node tests, predicates, operators and core functions
19
+ * are supported.
20
+ *
21
+ * Expressions computing a string, a number or a boolean, such as `count(//item)`, return the computed value for
22
+ * each target. Computed values have no tree, so selecting from them returns nothing.
23
+ *
24
+ * Names are matched case-sensitively, exactly as stored in the tree, and namespaces are not resolved. The same
25
+ * expressions therefore work on both XML and HTML trees, whose names are folded to lowercase while parsing:
26
+ *
27
+ * - an unprefixed name test matches unprefixed names only, so `item` matches `<item>` even under a default
28
+ * namespace, but not `<d:item>`
29
+ * - a prefixed name test matches the prefix as written, so `d:b` matches `<d:b>` whatever namespace URI `d` is
30
+ * bound to, but not the same element written with a different prefix
31
+ * - `local-name()` returns a name without its prefix and `name()` returns it in full, so `<d:b>` matches both
32
+ * `local-name()='b'` and `name()='d:b'`
33
+ * - `namespace-uri()` returns the prefix of a name rather than a namespace URI; the `xml` prefix is the exception,
34
+ * bound to its standard URI, so `@xml:base` and `lang()` work as specified
35
+ * - `xmlns` declarations are ordinary attributes, selected by attribute steps like any other
36
+ *
37
+ * XML declarations, document type declarations and processing instructions are not part of the tree, so
38
+ * `processing-instruction()` selects nothing. Namespace nodes are not supported either, so `namespace::` selects
39
+ * nothing. `CDATA` sections are read as text nodes.
40
+ *
41
+ * @param path The selection expression
42
+ *
43
+ * @returns An immutable list of the values selected by `path`, ordered by target and, within each target, in
44
+ * document order, without duplicate nodes; empty if `path` selects no value
45
+ *
46
+ * @throws {@link !SyntaxError SyntaxError} If `path` is malformed
47
+ */
48
+ (path: string): readonly Target[];
49
+ };
50
+ /**
51
+ * Creates an XPath selector task.
52
+ *
53
+ * The task converts a feed of parsed X/HTML trees into a feed of {@link XPath} selectors, one selector per tree, so
54
+ * that downstream tasks select nodes by expression rather than walking the tree.
55
+ *
56
+ * > [!NOTE]
57
+ * >
58
+ * > - **Incremental**: each selector is emitted as soon as its tree is drawn, so endless sources are processed for as
59
+ * > long as the feed is consumed.
60
+ * > - **Streaming**: trees are processed one at a time and none is retained, so memory use doesn't grow with the
61
+ * > length of the feed; each selector keeps its target tree alive for as long as it is referenced.
62
+ * > - **Stateless**: each tree is processed independently, so the result doesn't depend on how the feed is split
63
+ * > across nested feeds or runs.
64
+ *
65
+ * @returns A task converting a feed of parsed X/HTML trees into a feed of XPath selectors
66
+ *
67
+ * @throws {@link !Error Error} While the feed is consumed, if the source feed fails
68
+ *
69
+ * @group Factories
70
+ */
71
+ export declare function xpath(): Task<AnyNode, XPath>;
72
+ /**
73
+ * Creates an XPath mapping task.
74
+ *
75
+ * The task converts a feed of parsed X/HTML trees into a feed of mapped results, one result per tree, so that
76
+ * downstream tasks work on the shape they need rather than on the markup.
77
+ *
78
+ * > [!NOTE]
79
+ * >
80
+ * > - **Incremental**: each result is emitted as soon as its tree is drawn, so endless sources are processed for as
81
+ * > long as the feed is consumed.
82
+ * > - **Streaming**: trees are processed one at a time and released once mapped, so memory use doesn't grow with the
83
+ * > length of the feed.
84
+ * > - **Stateless**: each tree is mapped independently, so the result doesn't depend on how the feed is split across
85
+ * > nested feeds or runs.
86
+ *
87
+ * @typeParam V The type of the results mapped from incoming trees
88
+ *
89
+ * @param mapper The mapping function, applied to an {@link XPath} selector targeting the tree being processed
90
+ *
91
+ * @returns A task converting a feed of parsed X/HTML trees into a feed of mapped results
92
+ *
93
+ * @throws {@link !Error Error} While the feed is consumed, if the source feed fails or `mapper` throws, including a
94
+ * {@link !SyntaxError SyntaxError} for a malformed expression
95
+ *
96
+ * @example
97
+ *
98
+ * ```typescript
99
+ * const events = xpath(path => ({
100
+ *
101
+ * title: path("//h1").map(string),
102
+ * links: path("//a/@href").map(link)
103
+ *
104
+ * }));
105
+ * ```
106
+ *
107
+ * @group Factories
108
+ */
109
+ export declare function xpath<V>(mapper: (path: XPath) => V): Task<AnyNode, V>;
110
+ /**
111
+ * Creates an XPath selector over given nodes.
112
+ *
113
+ * Targets nodes already at hand, outside a feed, with the same selection semantics as the selectors emitted by the
114
+ * feed tasks.
115
+ *
116
+ * > [!IMPORTANT]
117
+ * >
118
+ * > A call without nodes, including one spreading an empty list, creates a selector task over a feed rather than a
119
+ * > selector with an empty target set.
120
+ *
121
+ * @param nodes The target nodes, in selection order
122
+ *
123
+ * @returns An immutable selector targeting `nodes`
124
+ *
125
+ * @group Factories
126
+ */
127
+ export declare function xpath(...nodes: readonly Target[]): XPath;
128
+ //# sourceMappingURL=xpath.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xpath.d.ts","sourceRoot":"","sources":["../src/xpath.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAU,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEtD,YAAY,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzD;;;;;;;GAOG;AACH,MAAM,MAAM,KAAK,GAAG;IAEnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACH,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;CAElC,CAAA;AAKD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,KAAK,IAAI,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;AAEvE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,KAAK,CAAC,GAAG,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,KAAK,CAAC"}
package/dist/xpath.js ADDED
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright © 2026 Metreeca srl
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { isFunction } from "@grafctory/core";
17
+ import { map } from "@grafctory/flow/tasks";
18
+ import { select } from "./xpath.core.js";
19
+ /**
20
+ * Creates an XPath selector.
21
+ */
22
+ export function xpath(...args) {
23
+ return isMapper(args) ? map(node => args[0](selector([node])))
24
+ : args.length === 0 ? map(node => selector([node]))
25
+ : selector(args);
26
+ function isMapper(args) {
27
+ return isFunction(args[0]);
28
+ }
29
+ function selector(nodes) {
30
+ return Object.freeze((path) => nodes.flatMap(node => select(node, path)));
31
+ }
32
+ }
33
+ //# sourceMappingURL=xpath.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xpath.js","sourceRoot":"","sources":["../src/xpath.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAe,MAAM,iBAAiB,CAAC;AAyItD;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,GAAG,IAAqE;IAE7F,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAmB,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC/E,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAiB,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YAClE,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAGnB,SAAS,QAAQ,CAAC,IAAwB;QACzC,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5B,CAAC;IAED,SAAS,QAAQ,CAAC,KAAwB;QACzC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACnF,CAAC;AAEF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,64 @@
1
1
  {
2
2
  "name": "@grafctory/mime-xml",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.5.1",
4
+ "description": "XML and HTML processing tasks for @grafctory/mime.",
5
+ "keywords": [
6
+ "typescript",
7
+ "pipeline",
8
+ "etl",
9
+ "extraction",
10
+ "xml",
11
+ "html"
12
+ ],
13
+ "homepage": "https://grafctory.github.io/mime/",
14
+ "bugs": {
15
+ "url": "https://github.com/grafctory/mime/issues",
16
+ "email": "info@metreeca.com"
17
+ },
18
+ "license": "Apache-2.0",
19
+ "author": {
20
+ "name": "Metreeca",
21
+ "email": "info@metreeca.com",
22
+ "url": "https://www.metreeca.com/"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/grafctory/mime.git",
27
+ "directory": "packages/mime-xml"
28
+ },
29
+ "type": "module",
30
+ "sideEffects": false,
31
+ "exports": {
32
+ ".": {
33
+ "@grafctory/source": "./src/index.ts",
34
+ "default": "./dist/index.js"
35
+ }
36
+ },
37
+ "files": [
38
+ "README.md",
39
+ "LICENSE",
40
+ "dist"
41
+ ],
42
+ "engines": {
43
+ "node": ">=22.22.0"
44
+ },
45
+ "scripts": {
46
+ "clean": "ush rm dist docs node_modules",
47
+ "build": "ush rm dist && tsc -p tsconfig.build.json",
48
+ "check": "npx vitest --typecheck run"
49
+ },
50
+ "dependencies": {
51
+ "@grafctory/core": "^0.14.0",
52
+ "@grafctory/flow": "^0.13.0",
53
+ "@grafctory/http": "^0.6.0",
54
+ "@grafctory/tape": "^0.13.0",
55
+ "domhandler": "^6.0.1",
56
+ "htmlparser2": "^12.0.0",
57
+ "xpathway": "^1.0.4"
58
+ },
59
+ "devDependencies": {
60
+ "@types/node": "^25.9.3",
61
+ "typescript": "^6.0.3",
62
+ "vitest": "^4.1.12"
63
+ }
64
+ }