@spotpatch/runtime 1.7.1 → 1.9.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/dist/chunk-AXKYJRAM.js +39 -0
- package/dist/chunk-AXKYJRAM.js.map +1 -0
- package/dist/chunk-QY5T4DPA.js +552 -0
- package/dist/chunk-QY5T4DPA.js.map +1 -0
- package/dist/data-flow-panel.cjs +333 -0
- package/dist/data-flow-panel.cjs.map +1 -0
- package/dist/data-flow-panel.d.cts +38 -0
- package/dist/data-flow-panel.d.ts +38 -0
- package/dist/data-flow-panel.js +281 -0
- package/dist/data-flow-panel.js.map +1 -0
- package/dist/data-flow-runtime-B3itbieT.d.cts +67 -0
- package/dist/data-flow-runtime-B3itbieT.d.ts +67 -0
- package/dist/data-flow.cjs +575 -0
- package/dist/data-flow.cjs.map +1 -0
- package/dist/data-flow.d.cts +8 -0
- package/dist/data-flow.d.ts +8 -0
- package/dist/data-flow.js +15 -0
- package/dist/data-flow.js.map +1 -0
- package/dist/index.cjs +778 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +243 -36
- package/dist/index.js.map +1 -1
- package/package.json +33 -3
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createButton,
|
|
3
|
+
createMarkedElement,
|
|
4
|
+
getDataFlowExtension,
|
|
5
|
+
registerDataFlowExtension
|
|
6
|
+
} from "./chunk-AXKYJRAM.js";
|
|
7
|
+
|
|
8
|
+
// src/ui/data-flow-panel.ts
|
|
9
|
+
var LABELS = Object.freeze({
|
|
10
|
+
"zh-CN": Object.freeze({
|
|
11
|
+
bindings: "\u6570\u636E\u53BB\u5411",
|
|
12
|
+
changes: "\u4FEE\u6539\u8BF4\u660E",
|
|
13
|
+
componentEmpty: "\u5F53\u524D\u7EC4\u4EF6\u6CA1\u6709\u627E\u5230\u53EF\u8BC1\u660E\u7684\u63A5\u53E3\u3002\u672A\u627E\u5230\u4E0D\u7B49\u4E8E\u6CA1\u6709\u8BF7\u6C42\u3002",
|
|
14
|
+
componentTab: "\u6570\u636E\u94FE\u8DEF",
|
|
15
|
+
componentTitle: "\u7EC4\u4EF6\u6570\u636E\u94FE\u8DEF",
|
|
16
|
+
consumed: "\u8BFB\u53D6\u5B57\u6BB5",
|
|
17
|
+
declared: "\u4EE3\u7801\u58F0\u660E\uFF0C\u5C1A\u672A\u5728\u672C\u6B21\u9875\u9762\u4F1A\u8BDD\u4E2D\u89C2\u6D4B",
|
|
18
|
+
diagnostics: "\u8BCA\u65AD",
|
|
19
|
+
disabled: "\u6570\u636E\u94FE\u8DEF\u80FD\u529B\u672A\u542F\u7528\uFF0C\u8BF7\u5728\u63D2\u4EF6\u914D\u7F6E\u4E2D\u8BBE\u7F6E dataFlow: {}\u3002",
|
|
20
|
+
error: "\u6570\u636E\u94FE\u8DEF\u62A5\u544A\u52A0\u8F7D\u5931\u8D25",
|
|
21
|
+
evidence: "\u8BC1\u636E",
|
|
22
|
+
loading: "\u6B63\u5728\u5206\u6790\u6E90\u7801\u5E76\u5408\u5E76\u8FD0\u884C\u65F6\u8BC1\u636E\u2026",
|
|
23
|
+
logicalObserved: "\u672C\u6B21\u4F1A\u8BDD\u5DF2\u8FDB\u5165 tRPC \u8C03\u7528\u94FE",
|
|
24
|
+
noParameters: "\u672A\u63D0\u53D6\u5230\u53EF\u8BC1\u660E\u7684\u53C2\u6570\u952E",
|
|
25
|
+
observed: "\u672C\u6B21\u4F1A\u8BDD\u5DF2\u5B9E\u9645\u8BF7\u6C42",
|
|
26
|
+
pageEmpty: "\u5F53\u524D\u5DF2\u9009\u9875\u9762\u8303\u56F4\u5185\u6CA1\u6709\u9759\u6001\u63A5\u53E3\u6216\u8FD0\u884C\u65F6\u7F51\u7EDC\u8BB0\u5F55\u3002",
|
|
27
|
+
pageTab: "\u9875\u9762\u63A5\u53E3",
|
|
28
|
+
pageTitle: "\u9875\u9762\u63A5\u53E3",
|
|
29
|
+
parameters: "\u8BF7\u6C42\u53C2\u6570",
|
|
30
|
+
refresh: "\u5237\u65B0\u8BC1\u636E",
|
|
31
|
+
unknown: "\u672A\u77E5"
|
|
32
|
+
}),
|
|
33
|
+
"en-US": Object.freeze({
|
|
34
|
+
bindings: "Data destinations",
|
|
35
|
+
changes: "Changes",
|
|
36
|
+
componentEmpty: "No proven interface was found for this component. This does not prove that no request exists.",
|
|
37
|
+
componentTab: "Data flow",
|
|
38
|
+
componentTitle: "Component data flow",
|
|
39
|
+
consumed: "Consumed fields",
|
|
40
|
+
declared: "Declared in code, not observed in this page session",
|
|
41
|
+
diagnostics: "Diagnostics",
|
|
42
|
+
disabled: "Data flow is disabled. Set dataFlow: {} in the plugin options.",
|
|
43
|
+
error: "Failed to load the data-flow report",
|
|
44
|
+
evidence: "Evidence",
|
|
45
|
+
loading: "Analyzing source and merging runtime evidence\u2026",
|
|
46
|
+
logicalObserved: "Dispatched through the tRPC link in this session",
|
|
47
|
+
noParameters: "No proven parameter keys were extracted",
|
|
48
|
+
observed: "Actually requested in this session",
|
|
49
|
+
pageEmpty: "No static interface or runtime traffic is available for the selected page scope.",
|
|
50
|
+
pageTab: "Page APIs",
|
|
51
|
+
pageTitle: "Page interfaces",
|
|
52
|
+
parameters: "Request parameters",
|
|
53
|
+
refresh: "Refresh evidence",
|
|
54
|
+
unknown: "Unknown"
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
function badge(document, text, tone) {
|
|
58
|
+
const element = createMarkedElement(document, "span");
|
|
59
|
+
element.className = "spotpatch-data-flow-badge";
|
|
60
|
+
element.dataset.tone = tone;
|
|
61
|
+
element.textContent = text;
|
|
62
|
+
return element;
|
|
63
|
+
}
|
|
64
|
+
function detailRow(document, label, value) {
|
|
65
|
+
const row = createMarkedElement(document, "div");
|
|
66
|
+
row.className = "spotpatch-data-flow-detail";
|
|
67
|
+
const key = createMarkedElement(document, "span");
|
|
68
|
+
key.textContent = label;
|
|
69
|
+
const content = createMarkedElement(document, "code");
|
|
70
|
+
content.textContent = value;
|
|
71
|
+
row.append(key, content);
|
|
72
|
+
return row;
|
|
73
|
+
}
|
|
74
|
+
function renderDependency(document, dependency, labels) {
|
|
75
|
+
const card = createMarkedElement(document, "article");
|
|
76
|
+
card.className = "spotpatch-data-flow-card";
|
|
77
|
+
const header = createMarkedElement(document, "div");
|
|
78
|
+
header.className = "spotpatch-data-flow-card-head";
|
|
79
|
+
const endpoint = createMarkedElement(document, "div");
|
|
80
|
+
endpoint.className = "spotpatch-data-flow-endpoint";
|
|
81
|
+
const method = createMarkedElement(document, "strong");
|
|
82
|
+
method.textContent = dependency.method ?? labels.unknown;
|
|
83
|
+
const path = createMarkedElement(document, "code");
|
|
84
|
+
path.textContent = dependency.url === void 0 ? dependency.operation ?? labels.unknown : `${dependency.url.origin ?? ""}${dependency.url.pathname}`;
|
|
85
|
+
endpoint.append(method, path);
|
|
86
|
+
const states = createMarkedElement(document, "div");
|
|
87
|
+
states.className = "spotpatch-data-flow-badges";
|
|
88
|
+
states.append(
|
|
89
|
+
badge(
|
|
90
|
+
document,
|
|
91
|
+
dependency.execution === "observed" ? dependency.kind === "rpc" ? labels.logicalObserved : labels.observed : labels.declared,
|
|
92
|
+
dependency.execution === "observed" ? "success" : "neutral"
|
|
93
|
+
),
|
|
94
|
+
badge(
|
|
95
|
+
document,
|
|
96
|
+
dependency.proof,
|
|
97
|
+
dependency.proof === "proven" ? "proof" : "warning"
|
|
98
|
+
),
|
|
99
|
+
badge(document, dependency.association, "neutral")
|
|
100
|
+
);
|
|
101
|
+
header.append(endpoint, states);
|
|
102
|
+
const parameters = dependency.parameters.length === 0 ? labels.noParameters : dependency.parameters.map(
|
|
103
|
+
(parameter) => `${parameter.position}.${parameter.path}${parameter.type === void 0 ? "" : `: ${parameter.type}`}${parameter.sensitive ? " [sensitive]" : ""}${parameter.condition === void 0 ? "" : ` [when ${parameter.condition}]`}`
|
|
104
|
+
).join("\n");
|
|
105
|
+
const consumed = dependency.response.consumedFields.length === 0 ? labels.unknown : dependency.response.consumedFields.join(", ");
|
|
106
|
+
const bindings = dependency.suppliedBindings.length === 0 ? labels.unknown : dependency.suppliedBindings.join(", ");
|
|
107
|
+
const body = createMarkedElement(document, "div");
|
|
108
|
+
body.className = "spotpatch-data-flow-card-body";
|
|
109
|
+
const observationIds = new Set(dependency.observationIds);
|
|
110
|
+
const staticEvidenceCount = dependency.evidenceIds.filter(
|
|
111
|
+
(id) => !observationIds.has(id)
|
|
112
|
+
).length;
|
|
113
|
+
body.append(
|
|
114
|
+
detailRow(document, labels.parameters, parameters),
|
|
115
|
+
detailRow(document, labels.consumed, consumed),
|
|
116
|
+
detailRow(document, labels.bindings, bindings),
|
|
117
|
+
detailRow(
|
|
118
|
+
document,
|
|
119
|
+
labels.evidence,
|
|
120
|
+
`${String(staticEvidenceCount)} static \xB7 ${String(dependency.observationIds.length)} runtime`
|
|
121
|
+
)
|
|
122
|
+
);
|
|
123
|
+
card.append(header, body);
|
|
124
|
+
return card;
|
|
125
|
+
}
|
|
126
|
+
function createReportRoot(document, titleText) {
|
|
127
|
+
const root = createMarkedElement(document, "section");
|
|
128
|
+
root.className = "spotpatch-data-flow-panel";
|
|
129
|
+
const title = createMarkedElement(document, "h3");
|
|
130
|
+
title.textContent = titleText;
|
|
131
|
+
const status = createMarkedElement(document, "p");
|
|
132
|
+
status.className = "spotpatch-data-flow-status";
|
|
133
|
+
const list = createMarkedElement(document, "div");
|
|
134
|
+
list.className = "spotpatch-data-flow-list";
|
|
135
|
+
root.append(title, status, list);
|
|
136
|
+
return Object.freeze({ root, status, list });
|
|
137
|
+
}
|
|
138
|
+
function createDataFlowPanel(document, enabled, locale, changesRoot, diagnosticsRoot, onViewChange) {
|
|
139
|
+
let labels = LABELS[locale()];
|
|
140
|
+
const component = createReportRoot(document, labels.componentTitle);
|
|
141
|
+
const page = createReportRoot(document, labels.pageTitle);
|
|
142
|
+
const refreshButton = createButton(document, labels.refresh);
|
|
143
|
+
const styles = document.createElement("style");
|
|
144
|
+
styles.textContent = DATA_FLOW_PANEL_STYLES;
|
|
145
|
+
refreshButton.classList.add("spotpatch-data-flow-refresh");
|
|
146
|
+
component.root.prepend(refreshButton);
|
|
147
|
+
const root = createMarkedElement(document, "div");
|
|
148
|
+
const tabs = createMarkedElement(document, "nav");
|
|
149
|
+
tabs.className = "spotpatch-view-tabs";
|
|
150
|
+
tabs.setAttribute("aria-label", "SpotPatch views");
|
|
151
|
+
tabs.setAttribute("role", "tablist");
|
|
152
|
+
const views = /* @__PURE__ */ new Map([
|
|
153
|
+
["changes", changesRoot],
|
|
154
|
+
["component-data", component.root],
|
|
155
|
+
["page-data", page.root],
|
|
156
|
+
["diagnostics", diagnosticsRoot]
|
|
157
|
+
]);
|
|
158
|
+
const tabButtons = /* @__PURE__ */ new Map();
|
|
159
|
+
let activeView = "changes";
|
|
160
|
+
for (const id of views.keys()) {
|
|
161
|
+
const button = createButton(document, "");
|
|
162
|
+
button.dataset.viewId = id;
|
|
163
|
+
button.id = `spotpatch-view-${id}-tab`;
|
|
164
|
+
button.setAttribute("role", "tab");
|
|
165
|
+
button.setAttribute("aria-selected", String(id === activeView));
|
|
166
|
+
const view = views.get(id);
|
|
167
|
+
view?.setAttribute("aria-labelledby", button.id);
|
|
168
|
+
view?.setAttribute("role", "tabpanel");
|
|
169
|
+
if (!enabled && (id === "component-data" || id === "page-data")) {
|
|
170
|
+
button.hidden = true;
|
|
171
|
+
}
|
|
172
|
+
tabButtons.set(id, button);
|
|
173
|
+
tabs.append(button);
|
|
174
|
+
}
|
|
175
|
+
root.append(tabs, ...views.values());
|
|
176
|
+
function selectView(viewId) {
|
|
177
|
+
if (!views.has(viewId)) return;
|
|
178
|
+
activeView = viewId;
|
|
179
|
+
for (const [id, view] of views) {
|
|
180
|
+
view.hidden = id !== viewId;
|
|
181
|
+
const button = tabButtons.get(id);
|
|
182
|
+
button?.setAttribute("aria-selected", String(id === viewId));
|
|
183
|
+
if (button !== void 0) button.tabIndex = id === viewId ? 0 : -1;
|
|
184
|
+
}
|
|
185
|
+
onViewChange();
|
|
186
|
+
}
|
|
187
|
+
function handleTabClick(event) {
|
|
188
|
+
if (!(event.target instanceof HTMLButtonElement)) return;
|
|
189
|
+
const viewId = event.target.dataset.viewId;
|
|
190
|
+
if (viewId !== void 0) selectView(viewId);
|
|
191
|
+
}
|
|
192
|
+
tabs.addEventListener("click", handleTabClick);
|
|
193
|
+
selectView(activeView);
|
|
194
|
+
function renderSnapshot(target, snapshot, empty) {
|
|
195
|
+
target.list.replaceChildren();
|
|
196
|
+
target.status.dataset.state = snapshot.status;
|
|
197
|
+
if (!enabled || snapshot.status === "disabled") {
|
|
198
|
+
target.status.textContent = labels.disabled;
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if (snapshot.status === "loading") {
|
|
202
|
+
target.status.textContent = labels.loading;
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (snapshot.status === "error") {
|
|
206
|
+
target.status.textContent = snapshot.message ?? labels.error;
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
const report = snapshot.report;
|
|
210
|
+
const diagnosticCodes = report === void 0 ? "" : [...new Set(report.diagnostics.map(({ code }) => code))].join(", ");
|
|
211
|
+
const diagnosticSuffix = diagnosticCodes.length === 0 ? "" : ` \xB7 ${labels.diagnostics}: ${diagnosticCodes}`;
|
|
212
|
+
if (report === void 0 || report.dependencies.length === 0) {
|
|
213
|
+
target.status.textContent = `${empty}${diagnosticSuffix}`;
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
target.status.textContent = `${String(report.dependencies.length)} \xB7 ${report.completeness.complete ? "complete" : "partial"}${diagnosticSuffix}`;
|
|
217
|
+
target.list.append(
|
|
218
|
+
...report.dependencies.map(
|
|
219
|
+
(dependency) => renderDependency(document, dependency, labels)
|
|
220
|
+
)
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
return Object.freeze({
|
|
224
|
+
root,
|
|
225
|
+
refreshButton,
|
|
226
|
+
styles,
|
|
227
|
+
dispose() {
|
|
228
|
+
tabs.removeEventListener("click", handleTabClick);
|
|
229
|
+
},
|
|
230
|
+
render(state) {
|
|
231
|
+
labels = LABELS[locale()];
|
|
232
|
+
const tabLabels = [
|
|
233
|
+
labels.changes,
|
|
234
|
+
labels.componentTab,
|
|
235
|
+
labels.pageTab,
|
|
236
|
+
labels.diagnostics
|
|
237
|
+
];
|
|
238
|
+
[...tabButtons.values()].forEach((button, index) => {
|
|
239
|
+
button.textContent = tabLabels[index] ?? "";
|
|
240
|
+
});
|
|
241
|
+
refreshButton.textContent = `${labels.refresh} \xB7 ${String(state.observationCount)}`;
|
|
242
|
+
refreshButton.disabled = !enabled || state.component.status === "loading";
|
|
243
|
+
renderSnapshot(component, state.component, labels.componentEmpty);
|
|
244
|
+
renderSnapshot(page, state.page, labels.pageEmpty);
|
|
245
|
+
},
|
|
246
|
+
resetView() {
|
|
247
|
+
selectView("changes");
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
var DATA_FLOW_PANEL_STYLES = `
|
|
252
|
+
.spotpatch-view-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin-bottom: 12px; padding: 3px; border: 1px solid rgb(255 255 255 / 7%); border-radius: 9px; background: rgb(3 7 18 / 42%); }
|
|
253
|
+
.spotpatch-view-tabs button { min-width: 0; border: 0; border-radius: 7px; padding: 7px 5px; color: var(--spotpatch-text-muted); background: transparent; cursor: pointer; font-size: 10.5px; }
|
|
254
|
+
.spotpatch-view-tabs button[aria-selected="true"] { color: #f8fafc; background: rgb(139 124 247 / 18%); }
|
|
255
|
+
.spotpatch-data-flow-panel { position: relative; }
|
|
256
|
+
.spotpatch-data-flow-panel > h3 { margin: 0 0 3px; color: #f3f4f6; font-size: 13px; }
|
|
257
|
+
.spotpatch-data-flow-refresh { position: absolute; top: -4px; right: 0; border: 1px solid rgb(139 124 247 / 30%); border-radius: 7px; padding: 4px 8px; color: #c4baff; background: rgb(139 124 247 / 8%); cursor: pointer; font-size: 10.5px; }
|
|
258
|
+
.spotpatch-data-flow-refresh:disabled { cursor: not-allowed; opacity: .45; }
|
|
259
|
+
.spotpatch-data-flow-status { margin: 0 0 10px; color: var(--spotpatch-text-muted); font-size: 10.5px; line-height: 1.5; }
|
|
260
|
+
.spotpatch-data-flow-list { display: grid; gap: 8px; }
|
|
261
|
+
.spotpatch-data-flow-card { overflow: hidden; border: 1px solid rgb(255 255 255 / 8%); border-radius: 9px; background: rgb(255 255 255 / 2.5%); }
|
|
262
|
+
.spotpatch-data-flow-card-head { display: grid; gap: 7px; padding: 10px; border-bottom: 1px solid rgb(255 255 255 / 7%); }
|
|
263
|
+
.spotpatch-data-flow-endpoint { display: flex; min-width: 0; align-items: center; gap: 8px; }
|
|
264
|
+
.spotpatch-data-flow-endpoint strong { color: #79d9e7; font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
|
|
265
|
+
.spotpatch-data-flow-endpoint code { min-width: 0; overflow: hidden; color: #f8fafc; font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
|
|
266
|
+
.spotpatch-data-flow-badges { display: flex; flex-wrap: wrap; gap: 4px; }
|
|
267
|
+
.spotpatch-data-flow-badge { border-radius: 999px; padding: 2px 6px; color: #9ca3af; background: rgb(255 255 255 / 5%); font-size: 9px; }
|
|
268
|
+
.spotpatch-data-flow-badge[data-tone="success"] { color: #6ee7b7; background: rgb(16 185 129 / 10%); }
|
|
269
|
+
.spotpatch-data-flow-badge[data-tone="proof"] { color: #c4b5fd; background: rgb(139 92 246 / 11%); }
|
|
270
|
+
.spotpatch-data-flow-badge[data-tone="warning"] { color: #fcd34d; background: rgb(245 158 11 / 10%); }
|
|
271
|
+
.spotpatch-data-flow-card-body { display: grid; gap: 7px; padding: 10px; }
|
|
272
|
+
.spotpatch-data-flow-detail { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 8px; align-items: start; }
|
|
273
|
+
.spotpatch-data-flow-detail > span { color: var(--spotpatch-text-muted); font-size: 10px; }
|
|
274
|
+
.spotpatch-data-flow-detail > code { overflow-wrap: anywhere; color: #cbd5e1; font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
|
|
275
|
+
`;
|
|
276
|
+
export {
|
|
277
|
+
createDataFlowPanel,
|
|
278
|
+
getDataFlowExtension,
|
|
279
|
+
registerDataFlowExtension
|
|
280
|
+
};
|
|
281
|
+
//# sourceMappingURL=data-flow-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ui/data-flow-panel.ts"],"sourcesContent":["import type { DataDependency, SpotPatchLocale } from \"@spotpatch/shared\";\n\nimport { createButton, createMarkedElement } from \"./dom.js\";\nimport type {\n DataFlowPanel,\n DataFlowPanelSnapshot,\n DataFlowViewState,\n} from \"./data-flow-panel-contract.js\";\n\ninterface Labels {\n readonly bindings: string;\n readonly changes: string;\n readonly componentEmpty: string;\n readonly componentTab: string;\n readonly componentTitle: string;\n readonly consumed: string;\n readonly declared: string;\n readonly diagnostics: string;\n readonly disabled: string;\n readonly error: string;\n readonly evidence: string;\n readonly loading: string;\n readonly logicalObserved: string;\n readonly noParameters: string;\n readonly observed: string;\n readonly pageEmpty: string;\n readonly pageTab: string;\n readonly pageTitle: string;\n readonly parameters: string;\n readonly refresh: string;\n readonly unknown: string;\n}\n\nconst LABELS = Object.freeze({\n \"zh-CN\": Object.freeze({\n bindings: \"数据去向\",\n changes: \"修改说明\",\n componentEmpty: \"当前组件没有找到可证明的接口。未找到不等于没有请求。\",\n componentTab: \"数据链路\",\n componentTitle: \"组件数据链路\",\n consumed: \"读取字段\",\n declared: \"代码声明,尚未在本次页面会话中观测\",\n diagnostics: \"诊断\",\n disabled: \"数据链路能力未启用,请在插件配置中设置 dataFlow: {}。\",\n error: \"数据链路报告加载失败\",\n evidence: \"证据\",\n loading: \"正在分析源码并合并运行时证据…\",\n logicalObserved: \"本次会话已进入 tRPC 调用链\",\n noParameters: \"未提取到可证明的参数键\",\n observed: \"本次会话已实际请求\",\n pageEmpty: \"当前已选页面范围内没有静态接口或运行时网络记录。\",\n pageTab: \"页面接口\",\n pageTitle: \"页面接口\",\n parameters: \"请求参数\",\n refresh: \"刷新证据\",\n unknown: \"未知\",\n }),\n \"en-US\": Object.freeze({\n bindings: \"Data destinations\",\n changes: \"Changes\",\n componentEmpty:\n \"No proven interface was found for this component. This does not prove that no request exists.\",\n componentTab: \"Data flow\",\n componentTitle: \"Component data flow\",\n consumed: \"Consumed fields\",\n declared: \"Declared in code, not observed in this page session\",\n diagnostics: \"Diagnostics\",\n disabled: \"Data flow is disabled. Set dataFlow: {} in the plugin options.\",\n error: \"Failed to load the data-flow report\",\n evidence: \"Evidence\",\n loading: \"Analyzing source and merging runtime evidence…\",\n logicalObserved: \"Dispatched through the tRPC link in this session\",\n noParameters: \"No proven parameter keys were extracted\",\n observed: \"Actually requested in this session\",\n pageEmpty:\n \"No static interface or runtime traffic is available for the selected page scope.\",\n pageTab: \"Page APIs\",\n pageTitle: \"Page interfaces\",\n parameters: \"Request parameters\",\n refresh: \"Refresh evidence\",\n unknown: \"Unknown\",\n }),\n}) satisfies Readonly<Record<SpotPatchLocale, Labels>>;\n\nfunction badge(document: Document, text: string, tone: string): HTMLElement {\n const element = createMarkedElement(document, \"span\");\n element.className = \"spotpatch-data-flow-badge\";\n element.dataset.tone = tone;\n element.textContent = text;\n return element;\n}\n\nfunction detailRow(document: Document, label: string, value: string): HTMLElement {\n const row = createMarkedElement(document, \"div\");\n row.className = \"spotpatch-data-flow-detail\";\n const key = createMarkedElement(document, \"span\");\n key.textContent = label;\n const content = createMarkedElement(document, \"code\");\n content.textContent = value;\n row.append(key, content);\n return row;\n}\n\nfunction renderDependency(\n document: Document,\n dependency: DataDependency,\n labels: Labels,\n): HTMLElement {\n const card = createMarkedElement(document, \"article\");\n card.className = \"spotpatch-data-flow-card\";\n const header = createMarkedElement(document, \"div\");\n header.className = \"spotpatch-data-flow-card-head\";\n const endpoint = createMarkedElement(document, \"div\");\n endpoint.className = \"spotpatch-data-flow-endpoint\";\n const method = createMarkedElement(document, \"strong\");\n method.textContent = dependency.method ?? labels.unknown;\n const path = createMarkedElement(document, \"code\");\n path.textContent =\n dependency.url === undefined\n ? (dependency.operation ?? labels.unknown)\n : `${dependency.url.origin ?? \"\"}${dependency.url.pathname}`;\n endpoint.append(method, path);\n const states = createMarkedElement(document, \"div\");\n states.className = \"spotpatch-data-flow-badges\";\n states.append(\n badge(\n document,\n dependency.execution === \"observed\"\n ? dependency.kind === \"rpc\"\n ? labels.logicalObserved\n : labels.observed\n : labels.declared,\n dependency.execution === \"observed\" ? \"success\" : \"neutral\",\n ),\n badge(\n document,\n dependency.proof,\n dependency.proof === \"proven\" ? \"proof\" : \"warning\",\n ),\n badge(document, dependency.association, \"neutral\"),\n );\n header.append(endpoint, states);\n\n const parameters =\n dependency.parameters.length === 0\n ? labels.noParameters\n : dependency.parameters\n .map(\n (parameter) =>\n `${parameter.position}.${parameter.path}${parameter.type === undefined ? \"\" : `: ${parameter.type}`}${parameter.sensitive ? \" [sensitive]\" : \"\"}${parameter.condition === undefined ? \"\" : ` [when ${parameter.condition}]`}`,\n )\n .join(\"\\n\");\n const consumed =\n dependency.response.consumedFields.length === 0\n ? labels.unknown\n : dependency.response.consumedFields.join(\", \");\n const bindings =\n dependency.suppliedBindings.length === 0\n ? labels.unknown\n : dependency.suppliedBindings.join(\", \");\n const body = createMarkedElement(document, \"div\");\n body.className = \"spotpatch-data-flow-card-body\";\n const observationIds = new Set(dependency.observationIds);\n const staticEvidenceCount = dependency.evidenceIds.filter(\n (id) => !observationIds.has(id),\n ).length;\n body.append(\n detailRow(document, labels.parameters, parameters),\n detailRow(document, labels.consumed, consumed),\n detailRow(document, labels.bindings, bindings),\n detailRow(\n document,\n labels.evidence,\n `${String(staticEvidenceCount)} static · ${String(dependency.observationIds.length)} runtime`,\n ),\n );\n card.append(header, body);\n return card;\n}\n\nfunction createReportRoot(\n document: Document,\n titleText: string,\n): Readonly<{ root: HTMLElement; status: HTMLElement; list: HTMLElement }> {\n const root = createMarkedElement(document, \"section\");\n root.className = \"spotpatch-data-flow-panel\";\n const title = createMarkedElement(document, \"h3\");\n title.textContent = titleText;\n const status = createMarkedElement(document, \"p\");\n status.className = \"spotpatch-data-flow-status\";\n const list = createMarkedElement(document, \"div\");\n list.className = \"spotpatch-data-flow-list\";\n root.append(title, status, list);\n return Object.freeze({ root, status, list });\n}\n\nexport function createDataFlowPanel(\n document: Document,\n enabled: boolean,\n locale: () => SpotPatchLocale,\n changesRoot: HTMLElement,\n diagnosticsRoot: HTMLElement,\n onViewChange: () => void,\n): DataFlowPanel {\n let labels = LABELS[locale()];\n const component = createReportRoot(document, labels.componentTitle);\n const page = createReportRoot(document, labels.pageTitle);\n const refreshButton = createButton(document, labels.refresh);\n const styles = document.createElement(\"style\");\n styles.textContent = DATA_FLOW_PANEL_STYLES;\n refreshButton.classList.add(\"spotpatch-data-flow-refresh\");\n component.root.prepend(refreshButton);\n const root = createMarkedElement(document, \"div\");\n const tabs = createMarkedElement(document, \"nav\");\n tabs.className = \"spotpatch-view-tabs\";\n tabs.setAttribute(\"aria-label\", \"SpotPatch views\");\n tabs.setAttribute(\"role\", \"tablist\");\n const views = new Map([\n [\"changes\", changesRoot],\n [\"component-data\", component.root],\n [\"page-data\", page.root],\n [\"diagnostics\", diagnosticsRoot],\n ]);\n const tabButtons = new Map<string, HTMLButtonElement>();\n let activeView = \"changes\";\n for (const id of views.keys()) {\n const button = createButton(document, \"\");\n button.dataset.viewId = id;\n button.id = `spotpatch-view-${id}-tab`;\n button.setAttribute(\"role\", \"tab\");\n button.setAttribute(\"aria-selected\", String(id === activeView));\n const view = views.get(id);\n view?.setAttribute(\"aria-labelledby\", button.id);\n view?.setAttribute(\"role\", \"tabpanel\");\n if (!enabled && (id === \"component-data\" || id === \"page-data\")) {\n button.hidden = true;\n }\n tabButtons.set(id, button);\n tabs.append(button);\n }\n root.append(tabs, ...views.values());\n\n function selectView(viewId: string): void {\n if (!views.has(viewId)) return;\n activeView = viewId;\n for (const [id, view] of views) {\n view.hidden = id !== viewId;\n const button = tabButtons.get(id);\n button?.setAttribute(\"aria-selected\", String(id === viewId));\n if (button !== undefined) button.tabIndex = id === viewId ? 0 : -1;\n }\n onViewChange();\n }\n\n function handleTabClick(event: Event): void {\n if (!(event.target instanceof HTMLButtonElement)) return;\n const viewId = event.target.dataset.viewId;\n if (viewId !== undefined) selectView(viewId);\n }\n\n tabs.addEventListener(\"click\", handleTabClick);\n selectView(activeView);\n\n function renderSnapshot(\n target: ReturnType<typeof createReportRoot>,\n snapshot: DataFlowPanelSnapshot,\n empty: string,\n ): void {\n target.list.replaceChildren();\n target.status.dataset.state = snapshot.status;\n if (!enabled || snapshot.status === \"disabled\") {\n target.status.textContent = labels.disabled;\n return;\n }\n if (snapshot.status === \"loading\") {\n target.status.textContent = labels.loading;\n return;\n }\n if (snapshot.status === \"error\") {\n target.status.textContent = snapshot.message ?? labels.error;\n return;\n }\n const report = snapshot.report;\n const diagnosticCodes =\n report === undefined\n ? \"\"\n : [...new Set(report.diagnostics.map(({ code }) => code))].join(\", \");\n const diagnosticSuffix =\n diagnosticCodes.length === 0\n ? \"\"\n : ` · ${labels.diagnostics}: ${diagnosticCodes}`;\n if (report === undefined || report.dependencies.length === 0) {\n target.status.textContent = `${empty}${diagnosticSuffix}`;\n return;\n }\n target.status.textContent = `${String(report.dependencies.length)} · ${report.completeness.complete ? \"complete\" : \"partial\"}${diagnosticSuffix}`;\n target.list.append(\n ...report.dependencies.map((dependency) =>\n renderDependency(document, dependency, labels),\n ),\n );\n }\n\n return Object.freeze({\n root,\n refreshButton,\n styles,\n dispose(): void {\n tabs.removeEventListener(\"click\", handleTabClick);\n },\n render(state: DataFlowViewState): void {\n labels = LABELS[locale()];\n const tabLabels = [\n labels.changes,\n labels.componentTab,\n labels.pageTab,\n labels.diagnostics,\n ];\n [...tabButtons.values()].forEach((button, index) => {\n button.textContent = tabLabels[index] ?? \"\";\n });\n refreshButton.textContent = `${labels.refresh} · ${String(state.observationCount)}`;\n refreshButton.disabled = !enabled || state.component.status === \"loading\";\n renderSnapshot(component, state.component, labels.componentEmpty);\n renderSnapshot(page, state.page, labels.pageEmpty);\n },\n resetView(): void {\n selectView(\"changes\");\n },\n });\n}\n\nconst DATA_FLOW_PANEL_STYLES = `\n .spotpatch-view-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin-bottom: 12px; padding: 3px; border: 1px solid rgb(255 255 255 / 7%); border-radius: 9px; background: rgb(3 7 18 / 42%); }\n .spotpatch-view-tabs button { min-width: 0; border: 0; border-radius: 7px; padding: 7px 5px; color: var(--spotpatch-text-muted); background: transparent; cursor: pointer; font-size: 10.5px; }\n .spotpatch-view-tabs button[aria-selected=\"true\"] { color: #f8fafc; background: rgb(139 124 247 / 18%); }\n .spotpatch-data-flow-panel { position: relative; }\n .spotpatch-data-flow-panel > h3 { margin: 0 0 3px; color: #f3f4f6; font-size: 13px; }\n .spotpatch-data-flow-refresh { position: absolute; top: -4px; right: 0; border: 1px solid rgb(139 124 247 / 30%); border-radius: 7px; padding: 4px 8px; color: #c4baff; background: rgb(139 124 247 / 8%); cursor: pointer; font-size: 10.5px; }\n .spotpatch-data-flow-refresh:disabled { cursor: not-allowed; opacity: .45; }\n .spotpatch-data-flow-status { margin: 0 0 10px; color: var(--spotpatch-text-muted); font-size: 10.5px; line-height: 1.5; }\n .spotpatch-data-flow-list { display: grid; gap: 8px; }\n .spotpatch-data-flow-card { overflow: hidden; border: 1px solid rgb(255 255 255 / 8%); border-radius: 9px; background: rgb(255 255 255 / 2.5%); }\n .spotpatch-data-flow-card-head { display: grid; gap: 7px; padding: 10px; border-bottom: 1px solid rgb(255 255 255 / 7%); }\n .spotpatch-data-flow-endpoint { display: flex; min-width: 0; align-items: center; gap: 8px; }\n .spotpatch-data-flow-endpoint strong { color: #79d9e7; font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }\n .spotpatch-data-flow-endpoint code { min-width: 0; overflow: hidden; color: #f8fafc; font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }\n .spotpatch-data-flow-badges { display: flex; flex-wrap: wrap; gap: 4px; }\n .spotpatch-data-flow-badge { border-radius: 999px; padding: 2px 6px; color: #9ca3af; background: rgb(255 255 255 / 5%); font-size: 9px; }\n .spotpatch-data-flow-badge[data-tone=\"success\"] { color: #6ee7b7; background: rgb(16 185 129 / 10%); }\n .spotpatch-data-flow-badge[data-tone=\"proof\"] { color: #c4b5fd; background: rgb(139 92 246 / 11%); }\n .spotpatch-data-flow-badge[data-tone=\"warning\"] { color: #fcd34d; background: rgb(245 158 11 / 10%); }\n .spotpatch-data-flow-card-body { display: grid; gap: 7px; padding: 10px; }\n .spotpatch-data-flow-detail { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 8px; align-items: start; }\n .spotpatch-data-flow-detail > span { color: var(--spotpatch-text-muted); font-size: 10px; }\n .spotpatch-data-flow-detail > code { overflow-wrap: anywhere; color: #cbd5e1; font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }\n`;\n"],"mappings":";;;;;;;;AAiCA,IAAM,SAAS,OAAO,OAAO;AAAA,EAC3B,SAAS,OAAO,OAAO;AAAA,IACrB,UAAU;AAAA,IACV,SAAS;AAAA,IACT,gBAAgB;AAAA,IAChB,cAAc;AAAA,IACd,gBAAgB;AAAA,IAChB,UAAU;AAAA,IACV,UAAU;AAAA,IACV,aAAa;AAAA,IACb,UAAU;AAAA,IACV,OAAO;AAAA,IACP,UAAU;AAAA,IACV,SAAS;AAAA,IACT,iBAAiB;AAAA,IACjB,cAAc;AAAA,IACd,UAAU;AAAA,IACV,WAAW;AAAA,IACX,SAAS;AAAA,IACT,WAAW;AAAA,IACX,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AAO,cAAc,UAAU,KAAK,KAAK;AAAA,MAC3C,CAAC;AACD,oBAAc,cAAc,GAAG,OAAO,OAAO,SAAM,OAAO,MAAM,gBAAgB,CAAC;AACjF,oBAAc,WAAW,CAAC,WAAW,MAAM,UAAU,WAAW;AAChE,qBAAe,WAAW,MAAM,WAAW,OAAO,cAAc;AAChE,qBAAe,MAAM,MAAM,MAAM,OAAO,SAAS;AAAA,IACnD;AAAA,IACA,YAAkB;AAChB,iBAAW,SAAS;AAAA,IACtB;AAAA,EACF,CAAC;AACH;AAEA,IAAM,yBAAyB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":[]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { NetworkObservation, RuntimeDataFlowConfig } from '@spotpatch/shared/data-flow-runtime';
|
|
2
|
+
|
|
3
|
+
interface DataFlowComponentRegistration {
|
|
4
|
+
readonly componentSourceId: string;
|
|
5
|
+
readonly sourceVersion: string;
|
|
6
|
+
}
|
|
7
|
+
interface DataFlowInvocationToken {
|
|
8
|
+
readonly invocationId: string;
|
|
9
|
+
readonly componentSourceId: string;
|
|
10
|
+
readonly triggerCallsiteId: string;
|
|
11
|
+
readonly sourceVersion: string;
|
|
12
|
+
}
|
|
13
|
+
interface DataFlowRequestFrame {
|
|
14
|
+
readonly requestCallsiteId: string;
|
|
15
|
+
readonly sourceVersion: string;
|
|
16
|
+
readonly invocationToken?: DataFlowInvocationToken;
|
|
17
|
+
}
|
|
18
|
+
interface DataFlowTriggerMetadata {
|
|
19
|
+
readonly componentSourceId: string;
|
|
20
|
+
readonly triggerCallsiteId: string;
|
|
21
|
+
readonly sourceVersion: string;
|
|
22
|
+
}
|
|
23
|
+
interface DataFlowRequestMetadata {
|
|
24
|
+
readonly requestCallsiteId: string;
|
|
25
|
+
readonly sourceVersion: string;
|
|
26
|
+
}
|
|
27
|
+
interface DataFlowRuntime {
|
|
28
|
+
readonly beginInvocation: (metadata: DataFlowTriggerMetadata) => DataFlowInvocationToken;
|
|
29
|
+
readonly bindInvocation: <Arguments extends readonly unknown[], Result>(token: DataFlowInvocationToken | undefined, callback: (...args: Arguments) => Result) => (...args: Arguments) => Result;
|
|
30
|
+
readonly bindTrigger: <Callback>(metadata: DataFlowTriggerMetadata, callback: Callback) => Callback;
|
|
31
|
+
readonly captureInvocation: () => DataFlowInvocationToken | undefined;
|
|
32
|
+
readonly clear: () => void;
|
|
33
|
+
readonly createTrpcLink: () => DataFlowTrpcLink;
|
|
34
|
+
readonly dispose: () => void;
|
|
35
|
+
readonly getComponentRegistration: (component: object) => DataFlowComponentRegistration | undefined;
|
|
36
|
+
readonly getCurrentRequestFrame: () => DataFlowRequestFrame | undefined;
|
|
37
|
+
readonly observations: () => readonly NetworkObservation[];
|
|
38
|
+
readonly updateRoute: (routeKey: string) => void;
|
|
39
|
+
readonly registerComponent: (component: object, componentSourceId: string, sourceVersion: string) => void;
|
|
40
|
+
readonly withInvocation: <Result>(token: DataFlowInvocationToken | undefined, callback: () => Result) => Result;
|
|
41
|
+
readonly withRequestFrame: <Result>(token: DataFlowInvocationToken | undefined, metadata: DataFlowRequestMetadata, callback: () => Result) => Result;
|
|
42
|
+
}
|
|
43
|
+
interface DataFlowTrpcOperation {
|
|
44
|
+
readonly path: unknown;
|
|
45
|
+
readonly type: unknown;
|
|
46
|
+
}
|
|
47
|
+
interface DataFlowTrpcLinkOptions<Operation extends DataFlowTrpcOperation, Result> {
|
|
48
|
+
readonly next: (operation: Operation) => Result;
|
|
49
|
+
readonly op: Operation;
|
|
50
|
+
}
|
|
51
|
+
type DataFlowTrpcLink = (runtime: unknown) => <Operation extends DataFlowTrpcOperation, Result>(options: DataFlowTrpcLinkOptions<Operation, Result>) => Result;
|
|
52
|
+
interface DataFlowGlobal {
|
|
53
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
54
|
+
readonly location?: Location;
|
|
55
|
+
readonly performance?: Performance;
|
|
56
|
+
readonly XMLHttpRequest?: typeof globalThis.XMLHttpRequest;
|
|
57
|
+
}
|
|
58
|
+
interface MutableDataFlowGlobal extends DataFlowGlobal {
|
|
59
|
+
fetch?: typeof globalThis.fetch;
|
|
60
|
+
}
|
|
61
|
+
type DataFlowRuntimeStore = Partial<Record<symbol, DataFlowRuntime>>;
|
|
62
|
+
type GlobalWithDataFlow = MutableDataFlowGlobal & DataFlowRuntimeStore;
|
|
63
|
+
declare function createDataFlowRuntime(config: RuntimeDataFlowConfig, target?: MutableDataFlowGlobal): DataFlowRuntime;
|
|
64
|
+
declare function installDataFlowPrelude(config: RuntimeDataFlowConfig, target?: GlobalWithDataFlow): DataFlowRuntime | undefined;
|
|
65
|
+
declare function getDataFlowRuntime(target?: GlobalWithDataFlow): DataFlowRuntime | undefined;
|
|
66
|
+
|
|
67
|
+
export { type DataFlowComponentRegistration as D, type DataFlowInvocationToken as a, type DataFlowRequestFrame as b, type DataFlowRequestMetadata as c, type DataFlowRuntime as d, type DataFlowTriggerMetadata as e, createDataFlowRuntime as f, getDataFlowRuntime as g, type DataFlowTrpcLink as h, installDataFlowPrelude as i, type DataFlowTrpcLinkOptions as j, type DataFlowTrpcOperation as k };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { NetworkObservation, RuntimeDataFlowConfig } from '@spotpatch/shared/data-flow-runtime';
|
|
2
|
+
|
|
3
|
+
interface DataFlowComponentRegistration {
|
|
4
|
+
readonly componentSourceId: string;
|
|
5
|
+
readonly sourceVersion: string;
|
|
6
|
+
}
|
|
7
|
+
interface DataFlowInvocationToken {
|
|
8
|
+
readonly invocationId: string;
|
|
9
|
+
readonly componentSourceId: string;
|
|
10
|
+
readonly triggerCallsiteId: string;
|
|
11
|
+
readonly sourceVersion: string;
|
|
12
|
+
}
|
|
13
|
+
interface DataFlowRequestFrame {
|
|
14
|
+
readonly requestCallsiteId: string;
|
|
15
|
+
readonly sourceVersion: string;
|
|
16
|
+
readonly invocationToken?: DataFlowInvocationToken;
|
|
17
|
+
}
|
|
18
|
+
interface DataFlowTriggerMetadata {
|
|
19
|
+
readonly componentSourceId: string;
|
|
20
|
+
readonly triggerCallsiteId: string;
|
|
21
|
+
readonly sourceVersion: string;
|
|
22
|
+
}
|
|
23
|
+
interface DataFlowRequestMetadata {
|
|
24
|
+
readonly requestCallsiteId: string;
|
|
25
|
+
readonly sourceVersion: string;
|
|
26
|
+
}
|
|
27
|
+
interface DataFlowRuntime {
|
|
28
|
+
readonly beginInvocation: (metadata: DataFlowTriggerMetadata) => DataFlowInvocationToken;
|
|
29
|
+
readonly bindInvocation: <Arguments extends readonly unknown[], Result>(token: DataFlowInvocationToken | undefined, callback: (...args: Arguments) => Result) => (...args: Arguments) => Result;
|
|
30
|
+
readonly bindTrigger: <Callback>(metadata: DataFlowTriggerMetadata, callback: Callback) => Callback;
|
|
31
|
+
readonly captureInvocation: () => DataFlowInvocationToken | undefined;
|
|
32
|
+
readonly clear: () => void;
|
|
33
|
+
readonly createTrpcLink: () => DataFlowTrpcLink;
|
|
34
|
+
readonly dispose: () => void;
|
|
35
|
+
readonly getComponentRegistration: (component: object) => DataFlowComponentRegistration | undefined;
|
|
36
|
+
readonly getCurrentRequestFrame: () => DataFlowRequestFrame | undefined;
|
|
37
|
+
readonly observations: () => readonly NetworkObservation[];
|
|
38
|
+
readonly updateRoute: (routeKey: string) => void;
|
|
39
|
+
readonly registerComponent: (component: object, componentSourceId: string, sourceVersion: string) => void;
|
|
40
|
+
readonly withInvocation: <Result>(token: DataFlowInvocationToken | undefined, callback: () => Result) => Result;
|
|
41
|
+
readonly withRequestFrame: <Result>(token: DataFlowInvocationToken | undefined, metadata: DataFlowRequestMetadata, callback: () => Result) => Result;
|
|
42
|
+
}
|
|
43
|
+
interface DataFlowTrpcOperation {
|
|
44
|
+
readonly path: unknown;
|
|
45
|
+
readonly type: unknown;
|
|
46
|
+
}
|
|
47
|
+
interface DataFlowTrpcLinkOptions<Operation extends DataFlowTrpcOperation, Result> {
|
|
48
|
+
readonly next: (operation: Operation) => Result;
|
|
49
|
+
readonly op: Operation;
|
|
50
|
+
}
|
|
51
|
+
type DataFlowTrpcLink = (runtime: unknown) => <Operation extends DataFlowTrpcOperation, Result>(options: DataFlowTrpcLinkOptions<Operation, Result>) => Result;
|
|
52
|
+
interface DataFlowGlobal {
|
|
53
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
54
|
+
readonly location?: Location;
|
|
55
|
+
readonly performance?: Performance;
|
|
56
|
+
readonly XMLHttpRequest?: typeof globalThis.XMLHttpRequest;
|
|
57
|
+
}
|
|
58
|
+
interface MutableDataFlowGlobal extends DataFlowGlobal {
|
|
59
|
+
fetch?: typeof globalThis.fetch;
|
|
60
|
+
}
|
|
61
|
+
type DataFlowRuntimeStore = Partial<Record<symbol, DataFlowRuntime>>;
|
|
62
|
+
type GlobalWithDataFlow = MutableDataFlowGlobal & DataFlowRuntimeStore;
|
|
63
|
+
declare function createDataFlowRuntime(config: RuntimeDataFlowConfig, target?: MutableDataFlowGlobal): DataFlowRuntime;
|
|
64
|
+
declare function installDataFlowPrelude(config: RuntimeDataFlowConfig, target?: GlobalWithDataFlow): DataFlowRuntime | undefined;
|
|
65
|
+
declare function getDataFlowRuntime(target?: GlobalWithDataFlow): DataFlowRuntime | undefined;
|
|
66
|
+
|
|
67
|
+
export { type DataFlowComponentRegistration as D, type DataFlowInvocationToken as a, type DataFlowRequestFrame as b, type DataFlowRequestMetadata as c, type DataFlowRuntime as d, type DataFlowTriggerMetadata as e, createDataFlowRuntime as f, getDataFlowRuntime as g, type DataFlowTrpcLink as h, installDataFlowPrelude as i, type DataFlowTrpcLinkOptions as j, type DataFlowTrpcOperation as k };
|