@fusion.dev/helix-headless 0.199.0 → 0.200.0
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/api.json +1 -1
- package/custom-elements.json +3927 -1
- package/dist/element-events.generated.js +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/log/ansi.d.ts +63 -0
- package/dist/log/ansi.js +163 -0
- package/dist/log/buffer.d.ts +99 -0
- package/dist/log/buffer.js +92 -0
- package/dist/log/group/log-group.d.ts +78 -0
- package/dist/log/group/log-group.js +76 -0
- package/dist/log/index.d.ts +5 -0
- package/dist/log/index.js +4 -0
- package/dist/log/line/log-line.d.ts +108 -0
- package/dist/log/line/log-line.js +145 -0
- package/dist/log/root/log-root.d.ts +415 -0
- package/dist/log/root/log-root.js +772 -0
- package/dist/log/rows.d.ts +60 -0
- package/dist/log/rows.js +91 -0
- package/examples.json +1 -1
- package/lint.json +1 -1
- package/package.json +5 -5
- package/types/jsx.d.ts +1333 -0
- package/types/svelte.d.ts +3 -0
- package/types/vue.d.ts +279 -0
- package/types/words.d.ts +71 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type LogRun } from './ansi.js';
|
|
2
|
+
import type { LogGroup, LogLine } from './buffer.js';
|
|
3
|
+
/** One row of a log drawn from data: a line, or the heading of a group. */
|
|
4
|
+
export type LogRow = {
|
|
5
|
+
/** The group, as `groups` holds it. */
|
|
6
|
+
group: LogGroup;
|
|
7
|
+
kind: 'group';
|
|
8
|
+
/** Whether its lines are shown. */
|
|
9
|
+
open: boolean;
|
|
10
|
+
} | {
|
|
11
|
+
kind: 'line';
|
|
12
|
+
line: LogLine;
|
|
13
|
+
/** Its number, counted from the first line ever written, so a link to it holds. */
|
|
14
|
+
number: number;
|
|
15
|
+
};
|
|
16
|
+
/** What a log drawn from data shows, and how many of its lines a search matched. */
|
|
17
|
+
export interface LogRows {
|
|
18
|
+
/** How many lines match `query`, or every line where there is none. */
|
|
19
|
+
matched: number;
|
|
20
|
+
rows: LogRow[];
|
|
21
|
+
}
|
|
22
|
+
/** What `logRows` reads. */
|
|
23
|
+
export interface LogRowsInput {
|
|
24
|
+
/** The line still being written, shown after the rest. */
|
|
25
|
+
current?: LogLine | undefined;
|
|
26
|
+
/** The groups the lines name. */
|
|
27
|
+
groups: readonly LogGroup[];
|
|
28
|
+
/** The finished lines, oldest first. */
|
|
29
|
+
lines: readonly LogLine[];
|
|
30
|
+
/** Whether a group shows its lines. */
|
|
31
|
+
open: (id: string) => boolean;
|
|
32
|
+
/** Text a line has to hold to be shown, ignoring case. Empty shows every line. */
|
|
33
|
+
query: string;
|
|
34
|
+
/** How many lines were let go before the first, which numbers the rest. */
|
|
35
|
+
start: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Lays the lines out as rows, a group's heading before its first line.
|
|
39
|
+
*
|
|
40
|
+
* **A group stands where its first line is.** A group in `groups` with no line
|
|
41
|
+
* yet stands after every line, in the order `groups` gives, which is the step
|
|
42
|
+
* that has started and written nothing, where it comes after every group that
|
|
43
|
+
* has a line. A line naming a group nobody declared is drawn with no heading.
|
|
44
|
+
*
|
|
45
|
+
* **A search opens every group and shows only what matched.** A group shows
|
|
46
|
+
* its heading while it holds a match, so a match inside a folded step is found
|
|
47
|
+
* where it is rather than hidden by the fold. A group with no match is left
|
|
48
|
+
* out, heading and all.
|
|
49
|
+
*/
|
|
50
|
+
export declare const logRows: ({ current, groups, lines, open, query, start }: LogRowsInput) => LogRows;
|
|
51
|
+
/** A run, and whether it is part of a match. */
|
|
52
|
+
export interface LogPiece extends LogRun {
|
|
53
|
+
/** Whether the text matches the search. */
|
|
54
|
+
match?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Splits runs where the search matches, ignoring case, so each match can be
|
|
58
|
+
* marked. Runs are returned as they are where there is no search.
|
|
59
|
+
*/
|
|
60
|
+
export declare const markMatches: (runs: readonly LogRun[], query: string) => LogPiece[];
|
package/dist/log/rows.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { stripAnsi } from './ansi.js';
|
|
2
|
+
const plain = new WeakMap();
|
|
3
|
+
const holds = (line, needle) => {
|
|
4
|
+
if (needle === '') {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
let text = plain.get(line);
|
|
8
|
+
if (text === undefined) {
|
|
9
|
+
text = stripAnsi(line.text).toLowerCase();
|
|
10
|
+
plain.set(line, text);
|
|
11
|
+
}
|
|
12
|
+
return text.includes(needle);
|
|
13
|
+
};
|
|
14
|
+
export const logRows = ({ current, groups, lines, open, query, start }) => {
|
|
15
|
+
const needle = query.trim().toLowerCase();
|
|
16
|
+
const byId = new Map(groups.map((group) => [group.id, group]));
|
|
17
|
+
const all = current ? [...lines, current] : lines;
|
|
18
|
+
const hits = new Set();
|
|
19
|
+
const matches = needle === '' ? undefined : all.map((line) => holds(line, needle));
|
|
20
|
+
let matched = 0;
|
|
21
|
+
if (matches) {
|
|
22
|
+
all.forEach((line, index) => {
|
|
23
|
+
if (matches[index]) {
|
|
24
|
+
matched += 1;
|
|
25
|
+
if (line.group !== undefined) {
|
|
26
|
+
hits.add(line.group);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
const rows = [];
|
|
32
|
+
const placed = new Set();
|
|
33
|
+
for (let index = 0; index < all.length; index += 1) {
|
|
34
|
+
const line = all[index];
|
|
35
|
+
const group = line.group === undefined ? undefined : byId.get(line.group);
|
|
36
|
+
if (group && !placed.has(group.id)) {
|
|
37
|
+
placed.add(group.id);
|
|
38
|
+
if (needle === '' || hits.has(group.id)) {
|
|
39
|
+
rows.push({ group, kind: 'group', open: needle !== '' || open(group.id) });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const shown = group === undefined || needle !== '' || open(group.id);
|
|
43
|
+
if (shown && (matches?.[index] ?? true)) {
|
|
44
|
+
rows.push({ kind: 'line', line, number: start + index + 1 });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (needle === '') {
|
|
48
|
+
const last = groups.findLastIndex((group) => placed.has(group.id));
|
|
49
|
+
for (const group of groups.slice(last + 1)) {
|
|
50
|
+
rows.push({ group, kind: 'group', open: open(group.id) });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return { matched: needle === '' ? all.length : matched, rows };
|
|
54
|
+
};
|
|
55
|
+
export const markMatches = (runs, query) => {
|
|
56
|
+
const needle = query.trim().toLowerCase();
|
|
57
|
+
if (needle === '') {
|
|
58
|
+
return [...runs];
|
|
59
|
+
}
|
|
60
|
+
const text = runs.map((run) => run.text).join('');
|
|
61
|
+
const lower = text.toLowerCase();
|
|
62
|
+
const ranges = [];
|
|
63
|
+
for (let at = lower.indexOf(needle); at >= 0; at = lower.indexOf(needle, at + needle.length)) {
|
|
64
|
+
ranges.push([at, at + needle.length]);
|
|
65
|
+
}
|
|
66
|
+
if (ranges.length === 0) {
|
|
67
|
+
return [...runs];
|
|
68
|
+
}
|
|
69
|
+
const pieces = [];
|
|
70
|
+
let offset = 0;
|
|
71
|
+
for (const run of runs) {
|
|
72
|
+
const end = offset + run.text.length;
|
|
73
|
+
let from = offset;
|
|
74
|
+
for (const [first, last] of ranges) {
|
|
75
|
+
if (last <= from || first >= end) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (first > from) {
|
|
79
|
+
pieces.push({ ...run, text: text.slice(from, first) });
|
|
80
|
+
}
|
|
81
|
+
const to = Math.min(last, end);
|
|
82
|
+
pieces.push({ ...run, match: true, text: text.slice(Math.max(first, from), to) });
|
|
83
|
+
from = to;
|
|
84
|
+
}
|
|
85
|
+
if (from < end) {
|
|
86
|
+
pieces.push({ ...run, text: text.slice(from, end) });
|
|
87
|
+
}
|
|
88
|
+
offset = end;
|
|
89
|
+
}
|
|
90
|
+
return pieces;
|
|
91
|
+
};
|