@simplysf/simply-utam-core 0.2.0 → 0.3.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.
- package/README.md +72 -16
- package/lib/forceignore/forceignore-manager.d.ts +30 -0
- package/lib/forceignore/forceignore-manager.js +28 -10
- package/lib/forceignore/forceignore-manager.js.map +1 -1
- package/lib/forceignore/index.d.ts +1 -1
- package/lib/forceignore/index.js +1 -1
- package/lib/forceignore/index.js.map +1 -1
- package/lib/gitignore/gitignore-manager.d.ts +64 -0
- package/lib/gitignore/gitignore-manager.js +96 -0
- package/lib/gitignore/gitignore-manager.js.map +1 -0
- package/lib/gitignore/index.d.ts +1 -0
- package/lib/gitignore/index.js +17 -0
- package/lib/gitignore/index.js.map +1 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/lib/namespaces/namespace-map.d.ts +18 -0
- package/lib/namespaces/namespace-map.js +75 -0
- package/lib/namespaces/namespace-map.js.map +1 -0
- package/lib/namespaces/namespace-rewriter.js +2 -47
- package/lib/namespaces/namespace-rewriter.js.map +1 -1
- package/lib/scaffold/project-scaffolder.d.ts +26 -1
- package/lib/scaffold/project-scaffolder.js +81 -11
- package/lib/scaffold/project-scaffolder.js.map +1 -1
- package/lib/snapshot/capture.d.ts +56 -0
- package/lib/snapshot/capture.js +115 -0
- package/lib/snapshot/capture.js.map +1 -0
- package/lib/snapshot/console.d.ts +25 -0
- package/lib/snapshot/console.js +74 -0
- package/lib/snapshot/console.js.map +1 -0
- package/lib/snapshot/describe.d.ts +27 -0
- package/lib/snapshot/describe.js +76 -0
- package/lib/snapshot/describe.js.map +1 -0
- package/lib/snapshot/files.d.ts +85 -0
- package/lib/snapshot/files.js +185 -0
- package/lib/snapshot/files.js.map +1 -0
- package/lib/snapshot/find.d.ts +36 -0
- package/lib/snapshot/find.js +186 -0
- package/lib/snapshot/find.js.map +1 -0
- package/lib/snapshot/format.d.ts +96 -0
- package/lib/snapshot/format.js +100 -0
- package/lib/snapshot/format.js.map +1 -0
- package/lib/snapshot/header.d.ts +38 -0
- package/lib/snapshot/header.js +120 -0
- package/lib/snapshot/header.js.map +1 -0
- package/lib/snapshot/index.d.ts +13 -0
- package/lib/snapshot/index.js +28 -0
- package/lib/snapshot/index.js.map +1 -0
- package/lib/snapshot/locate.d.ts +61 -0
- package/lib/snapshot/locate.js +110 -0
- package/lib/snapshot/locate.js.map +1 -0
- package/lib/snapshot/lookup.d.ts +53 -0
- package/lib/snapshot/lookup.js +188 -0
- package/lib/snapshot/lookup.js.map +1 -0
- package/lib/snapshot/page-object-index.d.ts +149 -0
- package/lib/snapshot/page-object-index.js +806 -0
- package/lib/snapshot/page-object-index.js.map +1 -0
- package/lib/snapshot/page-object-packages.d.ts +41 -0
- package/lib/snapshot/page-object-packages.js +115 -0
- package/lib/snapshot/page-object-packages.js.map +1 -0
- package/lib/snapshot/path.d.ts +102 -0
- package/lib/snapshot/path.js +381 -0
- package/lib/snapshot/path.js.map +1 -0
- package/lib/snapshot/query-result.d.ts +20 -0
- package/lib/snapshot/query-result.js +32 -0
- package/lib/snapshot/query-result.js.map +1 -0
- package/lib/snapshot/selector.d.ts +103 -0
- package/lib/snapshot/selector.js +280 -0
- package/lib/snapshot/selector.js.map +1 -0
- package/lib/snapshot/tree.d.ts +76 -0
- package/lib/snapshot/tree.js +201 -0
- package/lib/snapshot/tree.js.map +1 -0
- package/lib/snapshot/walker.js +532 -0
- package/package.json +12 -4
- package/templates/dom-snapshot.steps.mjs +34 -0
- package/templates/wdio.conf.mjs +81 -4
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type DomSnapshot } from './format.js';
|
|
2
|
+
import { type FoundNode } from './locate.js';
|
|
3
|
+
import { type QueryOutputOptions, type QueryResult } from './query-result.js';
|
|
4
|
+
export type FindOptions = QueryOutputOptions & {
|
|
5
|
+
/** Case-insensitive substring of a node's text, shadow text or any attribute value except `class`. */
|
|
6
|
+
text?: string;
|
|
7
|
+
/** `name` (present) or `name=value` (case-insensitive substring of the value). */
|
|
8
|
+
attr?: string;
|
|
9
|
+
tag?: string;
|
|
10
|
+
/** A whole class token, as `.name` matches it (case-sensitive). */
|
|
11
|
+
class?: string;
|
|
12
|
+
/**
|
|
13
|
+
* A CSS selector, matched as UTAM's `findElement` would: every match in document order, the first
|
|
14
|
+
* marked. Used alone; the other filters don't apply.
|
|
15
|
+
*/
|
|
16
|
+
css?: string;
|
|
17
|
+
/** With `css`: search under this node instead of the document. */
|
|
18
|
+
within?: string;
|
|
19
|
+
/** With `css` and `within`: search the node's shadow root rather than its light descendants. */
|
|
20
|
+
shadow?: boolean;
|
|
21
|
+
/** List hidden matches in full rather than as a count. */
|
|
22
|
+
all?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type FindResult = {
|
|
25
|
+
visible: FoundNode[];
|
|
26
|
+
hidden: FoundNode[];
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Nodes matching text, an attribute, a tag or a class, or with `css`, a CSS selector as UTAM's
|
|
30
|
+
* `findElement` runs it. Visible matches come first, in document order, then hidden ones; when there
|
|
31
|
+
* are hidden matches, a last line names the first in the document's own tree, which a root selector finds.
|
|
32
|
+
*
|
|
33
|
+
* @param snapshot The snapshot.
|
|
34
|
+
* @param options What to match.
|
|
35
|
+
*/
|
|
36
|
+
export declare function findNodes(snapshot: DomSnapshot, options: FindOptions): QueryResult<FindResult>;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, SimplySF.
|
|
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 { clip, describeNode, describePlain } from './describe.js';
|
|
17
|
+
import { DomSnapshotError } from './format.js';
|
|
18
|
+
import { getNode, isUnder, locate, toFound, treeHost } from './locate.js';
|
|
19
|
+
import { DEFAULT_OUTPUT_LIMIT, limitLines } from './query-result.js';
|
|
20
|
+
import { attribute, matchSelector, nodeMatchesSelector, prepareSelector, recaptureForNames, unseenNames, } from './selector.js';
|
|
21
|
+
function matches(node, options) {
|
|
22
|
+
if (options.tag && node.tag !== options.tag.toLowerCase())
|
|
23
|
+
return false;
|
|
24
|
+
const attrs = node.attrs ?? {};
|
|
25
|
+
if (options.attr) {
|
|
26
|
+
const [name, ...rest] = options.attr.split('=');
|
|
27
|
+
const value = rest.join('=').replace(/^["']|["']$/g, '');
|
|
28
|
+
const actual = attribute(attrs, name);
|
|
29
|
+
if (actual === undefined)
|
|
30
|
+
return false;
|
|
31
|
+
if (rest.length > 0 && !actual.toLowerCase().includes(value.toLowerCase()))
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (options.class && !(attribute(attrs, 'class') ?? '').split(/\s+/).includes(options.class))
|
|
35
|
+
return false;
|
|
36
|
+
if (options.text) {
|
|
37
|
+
const needle = options.text.toLowerCase();
|
|
38
|
+
const values = [
|
|
39
|
+
node.text,
|
|
40
|
+
node.shadow?.text,
|
|
41
|
+
...Object.entries(attrs)
|
|
42
|
+
.filter(([name]) => name !== 'class')
|
|
43
|
+
.map(([, value]) => value),
|
|
44
|
+
];
|
|
45
|
+
if (!values.some((value) => value?.toLowerCase().includes(needle)))
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
function hiddenNote(entry) {
|
|
51
|
+
const top = entry.hiddenTop;
|
|
52
|
+
if (!top)
|
|
53
|
+
return '';
|
|
54
|
+
return top === entry ? ' (hidden)' : ` (hidden, under ${top.node.id} ${describePlain(top.node)})`;
|
|
55
|
+
}
|
|
56
|
+
function describeQuery(options) {
|
|
57
|
+
return ([
|
|
58
|
+
options.text !== undefined ? `text "${options.text}"` : '',
|
|
59
|
+
options.attr !== undefined ? `attr ${options.attr}` : '',
|
|
60
|
+
options.tag !== undefined ? `tag ${options.tag}` : '',
|
|
61
|
+
options.class !== undefined ? `class ${options.class}` : '',
|
|
62
|
+
]
|
|
63
|
+
.filter(Boolean)
|
|
64
|
+
.join(', ') || 'everything');
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Nodes matching text, an attribute, a tag or a class, or with `css`, a CSS selector as UTAM's
|
|
68
|
+
* `findElement` runs it. Visible matches come first, in document order, then hidden ones; when there
|
|
69
|
+
* are hidden matches, a last line names the first in the document's own tree, which a root selector finds.
|
|
70
|
+
*
|
|
71
|
+
* @param snapshot The snapshot.
|
|
72
|
+
* @param options What to match.
|
|
73
|
+
*/
|
|
74
|
+
export function findNodes(snapshot, options) {
|
|
75
|
+
if (options.css !== undefined)
|
|
76
|
+
return findByCss(snapshot, options);
|
|
77
|
+
const all = [...locate(snapshot).values()].filter((entry) => matches(entry.node, options));
|
|
78
|
+
const visible = all.filter((entry) => !entry.hiddenTop);
|
|
79
|
+
const hidden = all.filter((entry) => entry.hiddenTop);
|
|
80
|
+
const lines = [`${visible.length} visible, ${hidden.length} hidden matches for ${describeQuery(options)}`];
|
|
81
|
+
for (const entry of visible)
|
|
82
|
+
lines.push(`${entry.node.id.padEnd(8)} ${describeNode(entry.node)}`);
|
|
83
|
+
if (hidden.length > 0) {
|
|
84
|
+
if (options.all) {
|
|
85
|
+
for (const entry of hidden)
|
|
86
|
+
lines.push(`${entry.node.id.padEnd(8)} ${describeNode(entry.node)}${hiddenNote(entry)}`);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
lines.push(`${hidden.length} hidden matches not listed; add --all to list them.`);
|
|
90
|
+
}
|
|
91
|
+
// Visible matches are listed first; say which a root selector reaches first. utam.load searches
|
|
92
|
+
// only the document's own tree, not inside shadow roots.
|
|
93
|
+
const first = all.find((entry) => treeHost(entry) === undefined);
|
|
94
|
+
lines.push(first
|
|
95
|
+
? `First in the document's own tree, which a root selector reaches first: ${first.node.id}${first.hiddenTop ? ' (hidden)' : ''}. utam.load takes a root selector's first match; test a selector with find --css.`
|
|
96
|
+
: "Every match is inside a shadow root, so a root selector can't reach them; test a selector with find --css.");
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
lines: limitLines(lines, options.limit ?? DEFAULT_OUTPUT_LIMIT, 'Narrow the query, or raise --limit.'),
|
|
100
|
+
json: { visible: visible.map(toFound), hidden: hidden.map(toFound) },
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function scopeLabel(scope) {
|
|
104
|
+
if (scope.kind === 'document')
|
|
105
|
+
return 'in the document';
|
|
106
|
+
return scope.kind === 'shadow' ? `in ${scope.within}'s shadow root` : `in ${scope.within}'s light DOM`;
|
|
107
|
+
}
|
|
108
|
+
/** Where a match the search didn't cover is, and the search that would find it. */
|
|
109
|
+
function whereElse(entry, scope, snapshot) {
|
|
110
|
+
const host = treeHost(entry);
|
|
111
|
+
const inShadowOf = (located) => located ? `in ${located.node.id}'s shadow root` : "in the document's tree";
|
|
112
|
+
const commandFor = (located) => located ? `--within ${located.node.id} --shadow` : 'no --within (the document)';
|
|
113
|
+
if (scope.kind === 'document')
|
|
114
|
+
return { reason: inShadowOf(host), command: commandFor(host) };
|
|
115
|
+
const within = getNode(snapshot, scope.within);
|
|
116
|
+
const searchedTree = scope.kind === 'shadow' ? within : treeHost(within);
|
|
117
|
+
if (host !== searchedTree && !(scope.kind === 'shadow' && host === treeHost(within)))
|
|
118
|
+
return { reason: inShadowOf(host), command: commandFor(host) };
|
|
119
|
+
if (scope.kind === 'shadow' && isUnder(entry, within))
|
|
120
|
+
return { reason: `in ${within.node.id}'s light DOM`, command: `--within ${within.node.id}` };
|
|
121
|
+
// The same tree as the search, but not under the node it searched from.
|
|
122
|
+
return { reason: `outside ${within.node.id}, in the same tree`, command: commandFor(host) };
|
|
123
|
+
}
|
|
124
|
+
/** For a selector with no match in its scope: where it does match, and the scope that would find each. */
|
|
125
|
+
function elsewhere(snapshot, css, scope) {
|
|
126
|
+
const { selector } = prepareSelector(css);
|
|
127
|
+
const all = [...locate(snapshot).values()].filter((entry) => nodeMatchesSelector(entry, selector));
|
|
128
|
+
if (all.length === 0) {
|
|
129
|
+
if (unseenNames(snapshot, selector).length > 0)
|
|
130
|
+
return [
|
|
131
|
+
'It matches nothing in this snapshot, in any shadow root, but it names something no node here has, which the live page may have on a pruned wrapper (see below).',
|
|
132
|
+
];
|
|
133
|
+
return ['It matches nothing anywhere in this snapshot, in any shadow root.'];
|
|
134
|
+
}
|
|
135
|
+
const shown = 5;
|
|
136
|
+
const lines = [`It matches ${all.length} node${all.length === 1 ? '' : 's'} this search doesn't cover:`];
|
|
137
|
+
let crossesShadow = false;
|
|
138
|
+
for (const entry of all.slice(0, shown)) {
|
|
139
|
+
const { reason, command } = whereElse(entry, scope, snapshot);
|
|
140
|
+
if (reason.endsWith('shadow root'))
|
|
141
|
+
crossesShadow = true;
|
|
142
|
+
lines.push(` ${entry.node.id.padEnd(8)} ${clip(describeNode(entry.node), 90)}${hiddenNote(entry)} ${reason} → ${command}`);
|
|
143
|
+
}
|
|
144
|
+
if (all.length > shown)
|
|
145
|
+
lines.push(` … ${all.length - shown} more`);
|
|
146
|
+
if (crossesShadow)
|
|
147
|
+
lines.push("A selector doesn't cross a shadow root, synthetic ones included.");
|
|
148
|
+
lines.push('In a page object, each element is searched from the one above it: shadow.elements for its shadow root, elements for its light DOM.');
|
|
149
|
+
return lines;
|
|
150
|
+
}
|
|
151
|
+
function findByCss(snapshot, options) {
|
|
152
|
+
const css = options.css;
|
|
153
|
+
if (options.shadow && !options.within)
|
|
154
|
+
throw new DomSnapshotError('--shadow needs --within <node>.');
|
|
155
|
+
const scope = options.within
|
|
156
|
+
? { kind: options.shadow ? 'shadow' : 'light', within: options.within }
|
|
157
|
+
: { kind: 'document' };
|
|
158
|
+
const { matches: found, notes, maskedAttributes } = matchSelector(snapshot, css, scope);
|
|
159
|
+
const lines = [`${found.length} matches for css "${css}" ${scopeLabel(scope)}, in document order:`];
|
|
160
|
+
for (const [i, entry] of found.entries()) {
|
|
161
|
+
const mark = i === 0 ? ' ← findElement / utam.load takes this one' : '';
|
|
162
|
+
lines.push(`${entry.node.id.padEnd(8)} ${describeNode(entry.node)}${hiddenNote(entry)}${mark}`);
|
|
163
|
+
}
|
|
164
|
+
const visible = found.find((entry) => !entry.hiddenTop);
|
|
165
|
+
if (found[0]?.hiddenTop) {
|
|
166
|
+
lines.push(visible
|
|
167
|
+
? `Warning: the first match is hidden, so UTAM gets the hidden copy, not ${visible.node.id}. Scope the selector to a container only the visible copy is in.`
|
|
168
|
+
: 'Warning: every match is hidden.');
|
|
169
|
+
}
|
|
170
|
+
if (found.length === 0)
|
|
171
|
+
lines.push(...elsewhere(snapshot, css, scope));
|
|
172
|
+
for (const name of maskedAttributes)
|
|
173
|
+
lines.push(`Can't check [${name}=…] values: they're masked in this snapshot, so a masked node may not be listed.`);
|
|
174
|
+
const recapture = recaptureForNames(snapshot, maskedAttributes);
|
|
175
|
+
if (recapture)
|
|
176
|
+
lines.push(recapture);
|
|
177
|
+
lines.push(...notes);
|
|
178
|
+
return {
|
|
179
|
+
lines: limitLines(lines, options.limit ?? DEFAULT_OUTPUT_LIMIT, 'Narrow the selector, or raise --limit.'),
|
|
180
|
+
json: {
|
|
181
|
+
visible: found.filter((entry) => !entry.hiddenTop).map(toFound),
|
|
182
|
+
hidden: found.filter((entry) => entry.hiddenTop).map(toFound),
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
//# sourceMappingURL=find.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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AkF,CAAC,CAAC;IACrH,MAAM,SAAS,GAAG,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;IAChE,IAAI,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACrC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;IACrB,OAAO;QACL,KAAK,EAAE,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,oBAAoB,EAAE,wCAAwC,CAAC;QACzG,IAAI,EAAE;YACJ,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC;YAC/D,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC;SAC9D;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export declare const DOM_SNAPSHOT_FORMAT = "simply-utam-dom-snapshot";
|
|
2
|
+
export declare const DOM_SNAPSHOT_VERSION = 1;
|
|
3
|
+
/** What took a snapshot: a failed step, a capture step, or the `browser.domSnapshot` command. */
|
|
4
|
+
export type SnapshotTrigger = 'failure' | 'step' | 'manual';
|
|
5
|
+
/**
|
|
6
|
+
* How much text a snapshot keeps, from least to most: `structure`, `labels` (the default), `aria`
|
|
7
|
+
* (adds controls' accessible names), `full`.
|
|
8
|
+
*/
|
|
9
|
+
export type SnapshotMask = 'structure' | 'labels' | 'aria' | 'full';
|
|
10
|
+
/**
|
|
11
|
+
* How a shadow root was recorded. `unreadable` marks a custom element that most likely renders into
|
|
12
|
+
* a closed shadow root, which neither the walker nor UTAM can see into.
|
|
13
|
+
*/
|
|
14
|
+
export type ShadowMode = 'native' | 'synthetic' | 'unknown' | 'unreadable';
|
|
15
|
+
/** One element in a snapshot. */
|
|
16
|
+
export type DomNode = {
|
|
17
|
+
/**
|
|
18
|
+
* The node's handle, `n1`, `n2`, …: what commands take. Not stored in the file; added when a
|
|
19
|
+
* snapshot is read, numbered in the order `tree` prints nodes.
|
|
20
|
+
*/
|
|
21
|
+
id: string;
|
|
22
|
+
/** Child positions from the page root, with `s` for a step into a shadow root, such as `0.1.4.s.2`. */
|
|
23
|
+
address: string;
|
|
24
|
+
tag: string;
|
|
25
|
+
attrs?: Record<string, string>;
|
|
26
|
+
text?: string;
|
|
27
|
+
children?: DomNode[];
|
|
28
|
+
shadow?: {
|
|
29
|
+
mode: ShadowMode;
|
|
30
|
+
children: DomNode[];
|
|
31
|
+
text?: string;
|
|
32
|
+
};
|
|
33
|
+
/** The top node of a hidden subtree. */
|
|
34
|
+
hidden?: true;
|
|
35
|
+
/** `[x, y, width, height]`, for visible elements. */
|
|
36
|
+
rect?: [number, number, number, number];
|
|
37
|
+
/** An `iframe`'s source, query string removed. */
|
|
38
|
+
src?: string;
|
|
39
|
+
/** An `iframe` whose content isn't in the snapshot. */
|
|
40
|
+
notCaptured?: true;
|
|
41
|
+
};
|
|
42
|
+
export type DomSnapshotMeta = {
|
|
43
|
+
capturedAt: string;
|
|
44
|
+
trigger: SnapshotTrigger;
|
|
45
|
+
url: string;
|
|
46
|
+
title: string;
|
|
47
|
+
viewport: [number, number];
|
|
48
|
+
label?: string;
|
|
49
|
+
scenario?: string;
|
|
50
|
+
step?: string;
|
|
51
|
+
error?: string;
|
|
52
|
+
mask: SnapshotMask;
|
|
53
|
+
truncated: {
|
|
54
|
+
reasons: Array<'nodes' | 'hiddenNodes' | 'time'>;
|
|
55
|
+
} | null;
|
|
56
|
+
/** The focus element's address, when a focus was found. */
|
|
57
|
+
focus?: string;
|
|
58
|
+
/** The installed version of each page-object package, when written inside a project. */
|
|
59
|
+
pageObjectPackages?: Record<string, string>;
|
|
60
|
+
};
|
|
61
|
+
export type DomSnapshot = {
|
|
62
|
+
format: typeof DOM_SNAPSHOT_FORMAT;
|
|
63
|
+
version: number;
|
|
64
|
+
meta: DomSnapshotMeta;
|
|
65
|
+
root: DomNode;
|
|
66
|
+
};
|
|
67
|
+
/** Thrown for input that isn't a snapshot this version can read. The CLI exits with code 2 on it. */
|
|
68
|
+
export declare class DomSnapshotError extends Error {
|
|
69
|
+
constructor(message: string);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Give every node a short handle (`n1`, `n2`, …) as its `id`, numbered in the order `tree` prints
|
|
73
|
+
* them: a node's shadow root children first, then its light children. Within one tree scope, a
|
|
74
|
+
* smaller handle comes earlier in document order.
|
|
75
|
+
*
|
|
76
|
+
* @param snapshot The snapshot; changed in place.
|
|
77
|
+
*/
|
|
78
|
+
export declare function numberNodes(snapshot: DomSnapshot): DomSnapshot;
|
|
79
|
+
/**
|
|
80
|
+
* Parse snapshot JSON, check its `format` and `version`, and number its handles.
|
|
81
|
+
*
|
|
82
|
+
* @param json The snapshot's JSON text.
|
|
83
|
+
*/
|
|
84
|
+
export declare function parseDomSnapshot(json: string): DomSnapshot;
|
|
85
|
+
/**
|
|
86
|
+
* A snapshot as JSON text for a file: everything but the handles, which are added on read.
|
|
87
|
+
*
|
|
88
|
+
* @param snapshot The snapshot.
|
|
89
|
+
*/
|
|
90
|
+
export declare function serializeDomSnapshot(snapshot: DomSnapshot): string;
|
|
91
|
+
/**
|
|
92
|
+
* Read a snapshot file, check it, and number its handles.
|
|
93
|
+
*
|
|
94
|
+
* @param file The snapshot file.
|
|
95
|
+
*/
|
|
96
|
+
export declare function readDomSnapshot(file: string): Promise<DomSnapshot>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, SimplySF.
|
|
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 { readFile } from 'node:fs/promises';
|
|
17
|
+
export const DOM_SNAPSHOT_FORMAT = 'simply-utam-dom-snapshot';
|
|
18
|
+
export const DOM_SNAPSHOT_VERSION = 1;
|
|
19
|
+
/** Thrown for input that isn't a snapshot this version can read. The CLI exits with code 2 on it. */
|
|
20
|
+
export class DomSnapshotError extends Error {
|
|
21
|
+
constructor(message) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = 'DomSnapshotError';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Give every node a short handle (`n1`, `n2`, …) as its `id`, numbered in the order `tree` prints
|
|
28
|
+
* them: a node's shadow root children first, then its light children. Within one tree scope, a
|
|
29
|
+
* smaller handle comes earlier in document order.
|
|
30
|
+
*
|
|
31
|
+
* @param snapshot The snapshot; changed in place.
|
|
32
|
+
*/
|
|
33
|
+
export function numberNodes(snapshot) {
|
|
34
|
+
let next = 1;
|
|
35
|
+
const visit = (node) => {
|
|
36
|
+
node.id = `n${next++}`;
|
|
37
|
+
for (const child of node.shadow?.children ?? [])
|
|
38
|
+
visit(child);
|
|
39
|
+
for (const child of node.children ?? [])
|
|
40
|
+
visit(child);
|
|
41
|
+
};
|
|
42
|
+
visit(snapshot.root);
|
|
43
|
+
return snapshot;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Parse snapshot JSON, check its `format` and `version`, and number its handles.
|
|
47
|
+
*
|
|
48
|
+
* @param json The snapshot's JSON text.
|
|
49
|
+
*/
|
|
50
|
+
export function parseDomSnapshot(json) {
|
|
51
|
+
let value;
|
|
52
|
+
try {
|
|
53
|
+
value = JSON.parse(json);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
throw new DomSnapshotError(`Not JSON: ${error.message}`);
|
|
57
|
+
}
|
|
58
|
+
const candidate = value;
|
|
59
|
+
if (!candidate || typeof candidate !== 'object' || candidate.format !== DOM_SNAPSHOT_FORMAT) {
|
|
60
|
+
throw new DomSnapshotError(`Not a DOM snapshot: format is ${JSON.stringify(candidate?.format)}, expected "${DOM_SNAPSHOT_FORMAT}"`);
|
|
61
|
+
}
|
|
62
|
+
if (typeof candidate.version !== 'number' || !Number.isInteger(candidate.version) || candidate.version < 1) {
|
|
63
|
+
throw new DomSnapshotError(`Not a DOM snapshot: version is ${JSON.stringify(candidate.version)}, expected a whole number from 1`);
|
|
64
|
+
}
|
|
65
|
+
if (candidate.version > DOM_SNAPSHOT_VERSION) {
|
|
66
|
+
throw new DomSnapshotError(`${DOM_SNAPSHOT_FORMAT} version ${String(candidate.version)} is newer than this reader understands (${DOM_SNAPSHOT_VERSION})`);
|
|
67
|
+
}
|
|
68
|
+
if (!candidate.meta || typeof candidate.root?.address !== 'string') {
|
|
69
|
+
throw new DomSnapshotError('Not a DOM snapshot: no meta, or no root node with an address');
|
|
70
|
+
}
|
|
71
|
+
return numberNodes(candidate);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A snapshot as JSON text for a file: everything but the handles, which are added on read.
|
|
75
|
+
*
|
|
76
|
+
* @param snapshot The snapshot.
|
|
77
|
+
*/
|
|
78
|
+
export function serializeDomSnapshot(snapshot) {
|
|
79
|
+
return JSON.stringify(snapshot, function (key, value) {
|
|
80
|
+
// A node's handle; `attrs.id` sits under `attrs`, which has no `address`.
|
|
81
|
+
const isHandle = key === 'id' && typeof this === 'object' && this !== null && 'address' in this;
|
|
82
|
+
return isHandle ? undefined : value;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Read a snapshot file, check it, and number its handles.
|
|
87
|
+
*
|
|
88
|
+
* @param file The snapshot file.
|
|
89
|
+
*/
|
|
90
|
+
export async function readDomSnapshot(file) {
|
|
91
|
+
let json;
|
|
92
|
+
try {
|
|
93
|
+
json = await readFile(file, 'utf8');
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
throw new DomSnapshotError(`Cannot read ${file}: ${error.message}`);
|
|
97
|
+
}
|
|
98
|
+
return parseDomSnapshot(json);
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../../src/snapshot/format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,CAAC,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAC9D,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAgEtC,qGAAqG;AACrG,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,YAAmB,OAAe;QAChC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,QAAqB;IAC/C,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,MAAM,KAAK,GAAG,CAAC,IAAa,EAAQ,EAAE;QACpC,IAAI,CAAC,EAAE,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC;QACvB,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE,QAAQ,IAAI,EAAE;YAAE,KAAK,CAAC,KAAK,CAAC,CAAC;QAC9D,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,IAAI,EAAE;YAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACxD,CAAC,CAAC;IACF,KAAK,CAAC,QAAQ,CA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D,CAAC,CAAC;IAC7F,CAAC;IACD,OAAO,WAAW,CAAC,SAAwB,CAAC,CAAC;AAC/C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAqB;IACxD,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,UAAyB,GAAW,EAAE,KAAc;QAClF,0EAA0E;QAC1E,MAAM,QAAQ,GAAG,GAAG,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,SAAS,IAAI,IAAI,CAAC;QAChG,OAAO,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC;IACtC,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAY;IAChD,IAAI,IAAY,CAAC;IACjB,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,gBAAgB,CAAC,eAAe,IAAI,KAAM,KAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { DomSnapshot } from './format.js';
|
|
2
|
+
import { type PageObjectIndex } from './page-object-index.js';
|
|
3
|
+
import type { QueryResult } from './query-result.js';
|
|
4
|
+
/** Where UTAM searched, from its not-found error, and the elements that may have declared it. */
|
|
5
|
+
export type UtamErrorHint = {
|
|
6
|
+
selector: string;
|
|
7
|
+
scope: 'light' | 'shadow';
|
|
8
|
+
/** Root page objects' elements with that selector and scope, whose parent resolves in the snapshot. */
|
|
9
|
+
candidates: Array<{
|
|
10
|
+
pageObject: string;
|
|
11
|
+
element: string;
|
|
12
|
+
parent: string;
|
|
13
|
+
}>;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* For a snapshot whose error is UTAM's "Can't find element(s) with locator '…' inside its scope …":
|
|
17
|
+
* the `find --css` that repeats UTAM's search, with `--within` the element it searched from when the
|
|
18
|
+
* page-object index can identify it. Undefined for any other error.
|
|
19
|
+
*
|
|
20
|
+
* @param snapshot The snapshot.
|
|
21
|
+
* @param index The page-object index, to identify the element UTAM searched from.
|
|
22
|
+
*/
|
|
23
|
+
export declare function utamErrorHint(snapshot: DomSnapshot, index?: PageObjectIndex): QueryResult<UtamErrorHint> | undefined;
|
|
24
|
+
export type SnapshotHeaderOptions = {
|
|
25
|
+
/** The snapshot's file, as the reader should see it named. */
|
|
26
|
+
file?: string;
|
|
27
|
+
/** The page-object index, or a way to build it; only used when the error is UTAM's not-found one. */
|
|
28
|
+
index?: PageObjectIndex | (() => PageObjectIndex);
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The lines every snapshot command prints first: which snapshot it read, where it came from, and,
|
|
32
|
+
* for a failure, the scenario, the step and the error, with a failed assertion's expected and
|
|
33
|
+
* received values, and for UTAM's not-found error, the `find --css` that repeats UTAM's search.
|
|
34
|
+
*
|
|
35
|
+
* @param snapshot The snapshot.
|
|
36
|
+
* @param options Its file name, and the page-object index for UTAM's error.
|
|
37
|
+
*/
|
|
38
|
+
export declare function snapshotHeader(snapshot: DomSnapshot, options?: SnapshotHeaderOptions): string[];
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026, SimplySF.
|
|
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 { clip, shellQuote } from './describe.js';
|
|
17
|
+
import { displayName, } from './page-object-index.js';
|
|
18
|
+
import { recaptureForNames, scopeMatches, testedAttributes } from './selector.js';
|
|
19
|
+
// Lazy and anchored on the text after it, so a selector with a quote in it, like `[title='Save']`, is kept whole.
|
|
20
|
+
const UTAM_NOT_FOUND = /Can't find elements? with locator '(.+?)' inside its scope (element|shadow root)/;
|
|
21
|
+
function firstMatch(snapshot, selector, scope) {
|
|
22
|
+
return scopeMatches(snapshot, selector, scope)[0];
|
|
23
|
+
}
|
|
24
|
+
/** A root page object's element's parent node, found as UTAM finds it: the first match at each level. */
|
|
25
|
+
function resolveParent(snapshot, entry, element) {
|
|
26
|
+
if (!entry.selector)
|
|
27
|
+
return undefined;
|
|
28
|
+
let current = firstMatch(snapshot, entry.selector, { kind: 'document' });
|
|
29
|
+
const byName = new Map([...entry.publicElements, ...entry.privateElements].map((e) => [e.name, e]));
|
|
30
|
+
const parts = element.name.split('.');
|
|
31
|
+
for (let i = 1; current && i < parts.length; i++) {
|
|
32
|
+
const step = byName.get(parts.slice(0, i).join('.'));
|
|
33
|
+
if (!step)
|
|
34
|
+
return undefined;
|
|
35
|
+
current = firstMatch(snapshot, step.selector, { kind: step.scope, within: current.node.id });
|
|
36
|
+
}
|
|
37
|
+
return current;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* For a snapshot whose error is UTAM's "Can't find element(s) with locator '…' inside its scope …":
|
|
41
|
+
* the `find --css` that repeats UTAM's search, with `--within` the element it searched from when the
|
|
42
|
+
* page-object index can identify it. Undefined for any other error.
|
|
43
|
+
*
|
|
44
|
+
* @param snapshot The snapshot.
|
|
45
|
+
* @param index The page-object index, to identify the element UTAM searched from.
|
|
46
|
+
*/
|
|
47
|
+
export function utamErrorHint(snapshot, index) {
|
|
48
|
+
const match = UTAM_NOT_FOUND.exec(snapshot.meta.error ?? '');
|
|
49
|
+
if (!match)
|
|
50
|
+
return undefined;
|
|
51
|
+
const [, selector, where] = match;
|
|
52
|
+
const scope = where === 'element' ? 'light' : 'shadow';
|
|
53
|
+
const candidates = [];
|
|
54
|
+
for (const entry of index?.entries.values() ?? []) {
|
|
55
|
+
if (!entry.root)
|
|
56
|
+
continue;
|
|
57
|
+
for (const element of [...entry.publicElements, ...entry.privateElements]) {
|
|
58
|
+
if (element.selector !== selector || element.scope !== scope)
|
|
59
|
+
continue;
|
|
60
|
+
const parent = resolveParent(snapshot, entry, element);
|
|
61
|
+
if (parent)
|
|
62
|
+
candidates.push({ pageObject: displayName(index, entry.name), element: element.name, parent: parent.node.id });
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const searched = scope === 'light'
|
|
66
|
+
? "its scope element's light DOM (elements)"
|
|
67
|
+
: "its scope element's shadow root (shadow.elements)";
|
|
68
|
+
const command = (within) => `npx simply-utam snapshot find --css ${shellQuote(selector)}${within ? ` --within ${within}${scope === 'shadow' ? ' --shadow' : ''}` : ''}`;
|
|
69
|
+
const lines = [` UTAM searched ${searched} for "${selector}". To repeat its search here:`];
|
|
70
|
+
if (candidates.length > 0) {
|
|
71
|
+
for (const c of candidates.slice(0, 3))
|
|
72
|
+
lines.push(` ${command(c.parent)} (${c.pageObject}, element "${clip(c.element, 60)}")`);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
lines.push(` ${command()}`, " This snapshot doesn't say which element it searched from. Check the selector in both scopes: --within <handle>, with and without --shadow.");
|
|
76
|
+
}
|
|
77
|
+
const recapture = recaptureForNames(snapshot, testedAttributes(selector));
|
|
78
|
+
if (recapture)
|
|
79
|
+
lines.push(` ${recapture}`);
|
|
80
|
+
return { lines, json: { selector, scope, candidates } };
|
|
81
|
+
}
|
|
82
|
+
/** An error's first line, and any lines an assertion reports the expected and received values on. */
|
|
83
|
+
function errorLines(error) {
|
|
84
|
+
const lines = error
|
|
85
|
+
.split('\n')
|
|
86
|
+
.map((line) => line.trim())
|
|
87
|
+
.filter(Boolean);
|
|
88
|
+
const kept = [lines[0], ...lines.slice(1).filter((line) => /^(expected|received)\b/i.test(line))];
|
|
89
|
+
return kept.map((line) => clip(line, 300));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The lines every snapshot command prints first: which snapshot it read, where it came from, and,
|
|
93
|
+
* for a failure, the scenario, the step and the error, with a failed assertion's expected and
|
|
94
|
+
* received values, and for UTAM's not-found error, the `find --css` that repeats UTAM's search.
|
|
95
|
+
*
|
|
96
|
+
* @param snapshot The snapshot.
|
|
97
|
+
* @param options Its file name, and the page-object index for UTAM's error.
|
|
98
|
+
*/
|
|
99
|
+
export function snapshotHeader(snapshot, options = {}) {
|
|
100
|
+
const { meta } = snapshot;
|
|
101
|
+
const truncated = meta.truncated ? `, TRUNCATED (${meta.truncated.reasons.join(', ')})` : '';
|
|
102
|
+
const lines = [
|
|
103
|
+
`Snapshot ${options.file ?? ''}${options.file ? ': ' : ''}${meta.trigger}${meta.label ? ` "${meta.label}"` : ''}, ${meta.capturedAt}, ${meta.url}, mask ${meta.mask}${truncated}`,
|
|
104
|
+
];
|
|
105
|
+
if (meta.scenario)
|
|
106
|
+
lines.push(` scenario: ${meta.scenario}`);
|
|
107
|
+
if (meta.step)
|
|
108
|
+
lines.push(` step: ${meta.step}`);
|
|
109
|
+
if (meta.error) {
|
|
110
|
+
const [first, ...rest] = errorLines(meta.error);
|
|
111
|
+
lines.push(` error: ${first}`, ...rest.map((line) => ` ${line}`));
|
|
112
|
+
}
|
|
113
|
+
// The index is only built for UTAM's not-found error, which the pattern tells cheaply.
|
|
114
|
+
if (UTAM_NOT_FOUND.test(meta.error ?? '')) {
|
|
115
|
+
const index = typeof options.index === 'function' ? options.index() : options.index;
|
|
116
|
+
lines.push(...(utamErrorHint(snapshot, index)?.lines ?? []));
|
|
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napshot, type DomSnapshotMeta, type ShadowMode, type SnapshotMask, type SnapshotTrigger, } from './format.js';
|
|
2
|
+
export { SNAPSHOT_MASK_ENV, captureDomSnapshot, type CaptureDomSnapshotOptions, type SnapshotBrowser, type SnapshotPage, } from './capture.js';
|
|
3
|
+
export { domSnapshotSnippet, importDomSnapshot, type DomSnapshotSnippetOptions, type ImportDomSnapshotOptions, } from './console.js';
|
|
4
|
+
export { LATEST_SNAPSHOT, MANUAL_RUN_ID, SNAPSHOT_RUN_ID_ENV, pruneDomSnapshots, snapshotRunId, writeDomSnapshot, type PruneDomSnapshotsOptions, type SnapshotFileSystem, type WriteDomSnapshotOptions, } from './files.js';
|
|
5
|
+
export { DEFAULT_OUTPUT_LIMIT, type QueryOutputOptions, type QueryResult } from './query-result.js';
|
|
6
|
+
export { buildPageObjectIndex, type BuildPageObjectIndexOptions, type PageObjectArg, type PageObjectElement, type PageObjectEntry, type PageObjectIndex, type PageObjectMatch, type PageObjectMethod, } from './page-object-index.js';
|
|
7
|
+
export { lookupPageObject, searchPageObjects, type LookupResult, type SearchResult, type SearchResultLine, } from './lookup.js';
|
|
8
|
+
export { findNodes, type FindOptions, type FindResult } from './find.js';
|
|
9
|
+
export type { FoundNode } from './locate.js';
|
|
10
|
+
export { querySnapshot, type SelectorMatches, type SelectorScope } from './selector.js';
|
|
11
|
+
export { componentPath, componentPathByText, type PathAnnotation, type PathByTextResult, type PathOptions, type PathResult, type PathStep, type ReachableThrough, type ScopeMismatch, } from './path.js';
|
|
12
|
+
export { nodeAncestors, nodeDetails, subtree, type AncestorLine, type AncestorsResult, type NodeDetails, type SubtreeOptions, } from './tree.js';
|
|
13
|
+
export { snapshotHeader, utamErrorHint, type SnapshotHeaderOptions, type UtamErrorHint } from './header.js';
|