@holistics/anfra-sdk 0.13.5 → 0.14.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/README.md +1 -1
- package/dist/app.d.ts +4 -3
- package/dist/app.js +17 -7
- package/dist/{bootstrap-BbsNvZ8s.d.ts → bootstrap-MhTSkiA1.d.ts} +96 -3
- package/dist/build.d.ts +2 -0
- package/dist/chunk-7IHICYVH.js +10 -0
- package/dist/chunk-CYZQ7ZTJ.js +237 -0
- package/dist/chunk-DITKCHFQ.js +166 -0
- package/dist/chunk-F6MRA7J4.js +65 -0
- package/dist/chunk-GBXK7F2V.js +431 -0
- package/dist/chunk-GOUDXWG4.js +750 -0
- package/dist/chunk-GV7SVWEK.js +84 -0
- package/dist/chunk-H52PO7MP.js +105 -0
- package/dist/chunk-HI3ZAXJK.js +8 -0
- package/dist/{chunk-KI5CAVAR.js → chunk-HZEECB6R.js} +477 -25
- package/dist/chunk-K633QHGO.js +51 -0
- package/dist/chunk-KFD6CHLI.js +38 -0
- package/dist/{chunk-OJ5WIKWE.js → chunk-NOFPRSSI.js} +1 -1
- package/dist/{chunk-ADWBOQW2.js → chunk-S6XLP6U4.js} +31 -1
- package/dist/{chunk-TQ7S5DRE.js → chunk-WI5VJ2Z6.js} +1 -1
- package/dist/common.d.ts +1 -1
- package/dist/common.js +14 -4
- package/dist/data-UCCW2VWH.js +233 -0
- package/dist/declaration-GVDOGQY6.js +218 -0
- package/dist/host.d.ts +42 -4
- package/dist/host.js +412 -9
- package/dist/menu-CdGVKc4_.d.ts +151 -0
- package/dist/overview-3DNXEQNY.js +358 -0
- package/dist/plugin-BmIDirTx.d.ts +303 -0
- package/dist/plugins.d.ts +6 -8
- package/dist/plugins.js +98 -69
- package/dist/queries-2OHKMTPC.js +661 -0
- package/dist/structure-WRDUXHD4.js +256 -0
- package/dist/tab-HMQOITVM.js +932 -0
- package/dist/testing.js +4 -4
- package/package.json +1 -1
- package/dist/bridge-WC7GliCH.d.ts +0 -73
- package/dist/chunk-33B2D4U5.js +0 -6
- package/dist/plugin-056-SKwd.d.ts +0 -132
- /package/dist/{chunk-52LXBYQM.js → chunk-UUKXJSE4.js} +0 -0
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import {
|
|
2
|
+
stateOf
|
|
3
|
+
} from "./chunk-CYZQ7ZTJ.js";
|
|
4
|
+
import {
|
|
5
|
+
copyIcon,
|
|
6
|
+
drawTab,
|
|
7
|
+
fields,
|
|
8
|
+
h,
|
|
9
|
+
icon,
|
|
10
|
+
link,
|
|
11
|
+
note,
|
|
12
|
+
replace
|
|
13
|
+
} from "./chunk-GOUDXWG4.js";
|
|
14
|
+
import {
|
|
15
|
+
LINEAGE_TAB,
|
|
16
|
+
attributeFor,
|
|
17
|
+
countProblems,
|
|
18
|
+
findNode,
|
|
19
|
+
handleFor,
|
|
20
|
+
plural
|
|
21
|
+
} from "./chunk-H52PO7MP.js";
|
|
22
|
+
import "./chunk-PKBMQBKP.js";
|
|
23
|
+
|
|
24
|
+
// src/plugins/inspect/tabs/structure.ts
|
|
25
|
+
var boxed = (node) => node.kind === "container" || node.kind === "block";
|
|
26
|
+
var renderable = (node) => boxed(node) && !!node.id && !node.problems.length;
|
|
27
|
+
var idOf = (node) => boxed(node) ? node.id ?? "" : node.app ? `${node.app}/${node.name ?? ""}` : node.name ?? "";
|
|
28
|
+
function ancestorsOf(nodes, key, trail = []) {
|
|
29
|
+
for (const node of nodes) {
|
|
30
|
+
if (node.key === key) return trail;
|
|
31
|
+
const found = ancestorsOf(node.children, key, [...trail, node.key]);
|
|
32
|
+
if (found) return found;
|
|
33
|
+
}
|
|
34
|
+
return void 0;
|
|
35
|
+
}
|
|
36
|
+
function structureTab(root, context) {
|
|
37
|
+
const doc = context.document;
|
|
38
|
+
const { panel } = context;
|
|
39
|
+
const state = stateOf(context.mount);
|
|
40
|
+
const canRender = context.plugins.some((plugin) => plugin.name === "render");
|
|
41
|
+
const hasLineage = context.plugins.some((plugin) => plugin.name === "lineage");
|
|
42
|
+
const collapsed = /* @__PURE__ */ new Set();
|
|
43
|
+
let status;
|
|
44
|
+
let revealed = null;
|
|
45
|
+
async function render(node, format) {
|
|
46
|
+
if (!node.id) return;
|
|
47
|
+
const request = node.kind === "block" ? { block: node.id, format } : { container: node.id, format };
|
|
48
|
+
try {
|
|
49
|
+
const { omitted } = await context.call("render.draw", request);
|
|
50
|
+
status = omitted.length ? `Saved, with ${omitted.join(", ")} left blank: ${omitted.length === 1 ? "it sends" : "they send"} no CORS headers.` : void 0;
|
|
51
|
+
} catch (err) {
|
|
52
|
+
status = `Couldn't render: ${err.message}`;
|
|
53
|
+
}
|
|
54
|
+
tab.redraw();
|
|
55
|
+
}
|
|
56
|
+
const appOf = (node) => panel.snapshot?.apps[node.app ?? 0];
|
|
57
|
+
const declared = (node) => {
|
|
58
|
+
if (node.kind !== "query" && node.kind !== "control" || node.problems.length) return false;
|
|
59
|
+
const app = appOf(node);
|
|
60
|
+
const name = node.name ?? "";
|
|
61
|
+
return !!app && (node.kind === "query" ? name in app.queries : name in app.controls);
|
|
62
|
+
};
|
|
63
|
+
const showInQueries = (node) => state.reveal(panel, { entity: node.kind, app: node.app ?? 0, name: node.name ?? "" });
|
|
64
|
+
const showData = (node) => state.reveal(panel, { table: node.name ?? "", app: node.app ?? 0 });
|
|
65
|
+
const showInLineage = (node) => panel.show(LINEAGE_TAB, node.key);
|
|
66
|
+
const select = (node) => {
|
|
67
|
+
panel.select(node.key);
|
|
68
|
+
panel.locate({ node: node.key });
|
|
69
|
+
};
|
|
70
|
+
function rows(nodes, depth) {
|
|
71
|
+
return h(doc, "ul", { class: "tree", role: depth === 0 ? "tree" : "group" }, nodes.map((node) => {
|
|
72
|
+
const open = !collapsed.has(node.key);
|
|
73
|
+
const selected = node.key === panel.selection;
|
|
74
|
+
const id = idOf(node);
|
|
75
|
+
return h(
|
|
76
|
+
doc,
|
|
77
|
+
"li",
|
|
78
|
+
{ role: "none" },
|
|
79
|
+
h(
|
|
80
|
+
doc,
|
|
81
|
+
"div",
|
|
82
|
+
{
|
|
83
|
+
class: `node${selected ? " selected" : ""}${node.problems.length ? " problem" : ""}`,
|
|
84
|
+
role: "treeitem",
|
|
85
|
+
tabindex: "0",
|
|
86
|
+
"aria-selected": String(selected),
|
|
87
|
+
"aria-expanded": node.children.length ? String(open) : void 0,
|
|
88
|
+
style: `padding-left:${4 + depth * 14}px`,
|
|
89
|
+
"data-tip": node.problems.length ? node.problems.join("\n") : void 0,
|
|
90
|
+
"data-key": `node:${node.key}`,
|
|
91
|
+
"data-testid": `node-${node.key}`,
|
|
92
|
+
onmouseenter: () => panel.highlight(node.key),
|
|
93
|
+
onclick: () => select(node),
|
|
94
|
+
onkeydown: (event) => {
|
|
95
|
+
const key = event.key;
|
|
96
|
+
if (key === "Enter") select(node);
|
|
97
|
+
if (!node.children.length || key === "ArrowRight" === open || key !== "ArrowRight" && key !== "ArrowLeft") return;
|
|
98
|
+
if (open) collapsed.add(node.key);
|
|
99
|
+
else collapsed.delete(node.key);
|
|
100
|
+
tab.redraw();
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
node.children.length ? h(doc, "button", {
|
|
104
|
+
type: "button",
|
|
105
|
+
class: `row-action twist${open ? " open" : ""}`,
|
|
106
|
+
"aria-label": open ? "Collapse" : "Expand",
|
|
107
|
+
tabindex: "-1",
|
|
108
|
+
onclick: (event) => {
|
|
109
|
+
event.stopPropagation();
|
|
110
|
+
if (open) collapsed.add(node.key);
|
|
111
|
+
else collapsed.delete(node.key);
|
|
112
|
+
tab.redraw();
|
|
113
|
+
}
|
|
114
|
+
}, icon(doc, "chevron")) : h(doc, "span", { class: "twist-space" }),
|
|
115
|
+
h(doc, "span", { class: `kind ${node.kind}` }, node.kind),
|
|
116
|
+
id && h(doc, "span", { class: "name" }, id),
|
|
117
|
+
node.label && node.label !== id && h(doc, "span", { class: "label" }, node.label),
|
|
118
|
+
node.problems.length > 0 && h(doc, "span", { class: "pill error", "aria-label": "Problems" }, "!"),
|
|
119
|
+
h(
|
|
120
|
+
doc,
|
|
121
|
+
"span",
|
|
122
|
+
{ class: "actions" },
|
|
123
|
+
declared(node) && h(doc, "button", {
|
|
124
|
+
type: "button",
|
|
125
|
+
class: "row-action",
|
|
126
|
+
"data-tip": "Show in Queries",
|
|
127
|
+
"aria-label": "Show in Queries",
|
|
128
|
+
"data-testid": "show-in-queries",
|
|
129
|
+
onclick: (event) => {
|
|
130
|
+
event.stopPropagation();
|
|
131
|
+
showInQueries(node);
|
|
132
|
+
}
|
|
133
|
+
}, icon(doc, "query")),
|
|
134
|
+
hasLineage && (node.kind === "block" || declared(node)) && h(doc, "button", {
|
|
135
|
+
type: "button",
|
|
136
|
+
class: "row-action",
|
|
137
|
+
"data-tip": "Show in Lineage",
|
|
138
|
+
"aria-label": "Show in Lineage",
|
|
139
|
+
"data-testid": "show-in-lineage",
|
|
140
|
+
onclick: (event) => {
|
|
141
|
+
event.stopPropagation();
|
|
142
|
+
showInLineage(node);
|
|
143
|
+
}
|
|
144
|
+
}, icon(doc, "lineage")),
|
|
145
|
+
canRender && renderable(node) && h(doc, "button", {
|
|
146
|
+
type: "button",
|
|
147
|
+
class: "row-action",
|
|
148
|
+
"data-tip": "Download PNG",
|
|
149
|
+
"aria-label": "Download PNG",
|
|
150
|
+
"data-testid": "download-node",
|
|
151
|
+
onclick: (event) => {
|
|
152
|
+
event.stopPropagation();
|
|
153
|
+
void render(node, "png");
|
|
154
|
+
}
|
|
155
|
+
}, icon(doc, "download")),
|
|
156
|
+
copyIcon(doc, "Copy handle", () => handleFor(node), { "data-testid": "copy-handle" })
|
|
157
|
+
)
|
|
158
|
+
),
|
|
159
|
+
node.children.length > 0 && open && rows(node.children, depth + 1)
|
|
160
|
+
);
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
function detail(node) {
|
|
164
|
+
const query = node.kind === "query" && declared(node);
|
|
165
|
+
return h(
|
|
166
|
+
doc,
|
|
167
|
+
"section",
|
|
168
|
+
{ class: "detail", "data-testid": "node-detail" },
|
|
169
|
+
h(doc, "h5", {}, node.kind),
|
|
170
|
+
fields(doc, [
|
|
171
|
+
[boxed(node) ? "Id" : "Name", (boxed(node) ? node.id : node.name) ?? ""],
|
|
172
|
+
!!node.label && ["Label", node.label],
|
|
173
|
+
!!node.app && ["App", `App ${node.app}`],
|
|
174
|
+
["Handle", h(doc, "code", { class: "wrap" }, handleFor(node))],
|
|
175
|
+
node.children.length > 0 && ["Holds", plural(node.children.length, "node")]
|
|
176
|
+
]),
|
|
177
|
+
node.problems.map((problem) => h(doc, "p", { class: "error-text", role: "alert" }, problem)),
|
|
178
|
+
h(
|
|
179
|
+
doc,
|
|
180
|
+
"div",
|
|
181
|
+
{ class: "detail-actions" },
|
|
182
|
+
declared(node) && link(doc, [icon(doc, "query"), "Show in Queries"], () => showInQueries(node), { "data-testid": "detail-show-in-queries" }),
|
|
183
|
+
query && link(doc, [icon(doc, "table"), "Show data"], () => showData(node), { "data-testid": "view-data" }),
|
|
184
|
+
hasLineage && link(doc, [icon(doc, "lineage"), "Show in Lineage"], () => showInLineage(node), { "data-testid": "detail-show-in-lineage" }),
|
|
185
|
+
copyIcon(doc, "Copy the attribute", () => attributeFor(node)),
|
|
186
|
+
canRender && renderable(node) && ["png", "pdf"].map((format) => h(doc, "button", {
|
|
187
|
+
type: "button",
|
|
188
|
+
class: "tool",
|
|
189
|
+
"data-testid": `download-${format}`,
|
|
190
|
+
onclick: () => {
|
|
191
|
+
void render(node, format);
|
|
192
|
+
}
|
|
193
|
+
}, icon(doc, "download"), format.toUpperCase()))
|
|
194
|
+
),
|
|
195
|
+
status && h(doc, "p", { class: "status", role: "status" }, status)
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
const head = h(doc, "div", { class: "toolbar" });
|
|
199
|
+
const tab = drawTab(root, context, () => {
|
|
200
|
+
const structure = panel.snapshot?.structure;
|
|
201
|
+
const selected = structure && panel.selection !== null ? findNode(structure.nodes, panel.selection) : void 0;
|
|
202
|
+
const problems = structure ? countProblems(structure.nodes) : 0;
|
|
203
|
+
replace(
|
|
204
|
+
doc,
|
|
205
|
+
head,
|
|
206
|
+
h(doc, "button", {
|
|
207
|
+
type: "button",
|
|
208
|
+
class: "tool",
|
|
209
|
+
"aria-pressed": String(panel.picking),
|
|
210
|
+
"data-tip": "Click a part of the page to select it here. Esc stops.",
|
|
211
|
+
"data-testid": "pick",
|
|
212
|
+
onclick: () => panel.pick(!panel.picking)
|
|
213
|
+
}, icon(doc, "pick"), "Pick"),
|
|
214
|
+
problems > 0 && h(doc, "span", { class: "pill error", "data-tip": "Problems in the markup" }, plural(problems, "problem"))
|
|
215
|
+
);
|
|
216
|
+
if (structure && panel.selection !== null && panel.selection !== revealed) {
|
|
217
|
+
ancestorsOf(structure.nodes, panel.selection)?.forEach((key) => collapsed.delete(key));
|
|
218
|
+
}
|
|
219
|
+
return [
|
|
220
|
+
h(
|
|
221
|
+
doc,
|
|
222
|
+
"div",
|
|
223
|
+
{ class: "scroll", onmouseleave: () => panel.highlight(null) },
|
|
224
|
+
!structure ? note(doc, "Waiting for the Data App\u2026", { "data-testid": "inspect-waiting" }) : structure.nodes.length === 0 ? note(doc, [
|
|
225
|
+
"Nothing is marked yet. Add ",
|
|
226
|
+
h(doc, "code", {}, "data-anfra-container"),
|
|
227
|
+
", ",
|
|
228
|
+
h(doc, "code", {}, "data-anfra-block"),
|
|
229
|
+
", ",
|
|
230
|
+
h(doc, "code", {}, "data-anfra-query"),
|
|
231
|
+
" and ",
|
|
232
|
+
h(doc, "code", {}, "data-anfra-control"),
|
|
233
|
+
" to the page's elements and they show up here."
|
|
234
|
+
], { "data-testid": "structure-none" }) : rows(structure.nodes, 0)
|
|
235
|
+
),
|
|
236
|
+
selected && detail(selected)
|
|
237
|
+
];
|
|
238
|
+
}, { head, split: true });
|
|
239
|
+
const reveal = () => {
|
|
240
|
+
if (panel.selection === null || panel.selection === revealed) return;
|
|
241
|
+
const row = [...root.querySelectorAll("[data-key]")].find((element) => element.dataset.key === `node:${panel.selection}`);
|
|
242
|
+
if (!row) return;
|
|
243
|
+
revealed = panel.selection;
|
|
244
|
+
row.scrollIntoView?.({ block: "nearest" });
|
|
245
|
+
};
|
|
246
|
+
reveal();
|
|
247
|
+
const stop = panel.subscribe(reveal);
|
|
248
|
+
return () => {
|
|
249
|
+
stop();
|
|
250
|
+
tab.dispose();
|
|
251
|
+
panel.highlight(null);
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
export {
|
|
255
|
+
structureTab as default
|
|
256
|
+
};
|