@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
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { SpotPatchRuntimeConfig } from '@spotpatch/shared';
|
|
2
|
+
export { D as DataFlowComponentRegistration, a as DataFlowInvocationToken, b as DataFlowRequestFrame, c as DataFlowRequestMetadata, d as DataFlowRuntime, e as DataFlowTriggerMetadata, f as createDataFlowRuntime, g as getDataFlowRuntime, i as installDataFlowPrelude } from './data-flow-runtime-B3itbieT.cjs';
|
|
3
|
+
export { mergeComponentDataFlowReport, mergePageDataFlowReport } from './data-flow.cjs';
|
|
4
|
+
import '@spotpatch/shared/data-flow-runtime';
|
|
2
5
|
|
|
3
6
|
type RuntimeConfig = SpotPatchRuntimeConfig;
|
|
4
7
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { SpotPatchRuntimeConfig } from '@spotpatch/shared';
|
|
2
|
+
export { D as DataFlowComponentRegistration, a as DataFlowInvocationToken, b as DataFlowRequestFrame, c as DataFlowRequestMetadata, d as DataFlowRuntime, e as DataFlowTriggerMetadata, f as createDataFlowRuntime, g as getDataFlowRuntime, i as installDataFlowPrelude } from './data-flow-runtime-B3itbieT.js';
|
|
3
|
+
export { mergeComponentDataFlowReport, mergePageDataFlowReport } from './data-flow.js';
|
|
4
|
+
import '@spotpatch/shared/data-flow-runtime';
|
|
2
5
|
|
|
3
6
|
type RuntimeConfig = SpotPatchRuntimeConfig;
|
|
4
7
|
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createDataFlowRuntime,
|
|
3
|
+
getDataFlowRuntime,
|
|
4
|
+
installDataFlowPrelude,
|
|
5
|
+
mergeComponentDataFlowReport,
|
|
6
|
+
mergePageDataFlowReport
|
|
7
|
+
} from "./chunk-QY5T4DPA.js";
|
|
8
|
+
import {
|
|
9
|
+
UI_MARKER_ATTRIBUTE,
|
|
10
|
+
UI_Z_INDEX,
|
|
11
|
+
createButton,
|
|
12
|
+
createMarkedElement,
|
|
13
|
+
getDataFlowExtension
|
|
14
|
+
} from "./chunk-AXKYJRAM.js";
|
|
15
|
+
|
|
1
16
|
// src/controller/runtime-controller.ts
|
|
2
17
|
import { createReact18Adapter } from "@spotpatch/react-adapter";
|
|
3
18
|
import {
|
|
19
|
+
DATA_FLOW_SCHEMA_VERSION as DATA_FLOW_SCHEMA_VERSION2,
|
|
4
20
|
MAX_ANNOTATION_INSTRUCTION_CHARACTERS as MAX_ANNOTATION_INSTRUCTION_CHARACTERS3
|
|
5
21
|
} from "@spotpatch/shared";
|
|
6
22
|
|
|
@@ -76,6 +92,7 @@ function createAnnotation(input) {
|
|
|
76
92
|
|
|
77
93
|
// src/api/runtime-api.ts
|
|
78
94
|
import {
|
|
95
|
+
DATA_FLOW_SCHEMA_VERSION,
|
|
79
96
|
SPOTPATCH_ENDPOINTS,
|
|
80
97
|
SPOTPATCH_TOKEN_HEADER,
|
|
81
98
|
getAgentJobEndpoint
|
|
@@ -337,15 +354,36 @@ function parseJson(text2) {
|
|
|
337
354
|
throw new RuntimeApiError();
|
|
338
355
|
}
|
|
339
356
|
}
|
|
340
|
-
async function readJsonEnvelope(response) {
|
|
357
|
+
async function readJsonEnvelope(response, maximumBytes = MAX_JSON_RESPONSE_BYTES) {
|
|
341
358
|
const payload = parseJson(
|
|
342
|
-
await readBoundedText(response,
|
|
359
|
+
await readBoundedText(response, maximumBytes)
|
|
343
360
|
);
|
|
344
361
|
if (!response.ok) {
|
|
345
362
|
throw new RuntimeApiError(readFailureCode(payload));
|
|
346
363
|
}
|
|
347
364
|
return readSuccessData(payload);
|
|
348
365
|
}
|
|
366
|
+
function isStringArray(value) {
|
|
367
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
368
|
+
}
|
|
369
|
+
function isReportCompleteness(value) {
|
|
370
|
+
return isRecord2(value) && typeof value.complete === "boolean" && typeof value.visitedModules === "number" && typeof value.visitedCallsites === "number" && typeof value.frontierCount === "number";
|
|
371
|
+
}
|
|
372
|
+
function isDataFlowCapability(value) {
|
|
373
|
+
return isRecord2(value) && typeof value.enabled === "boolean" && (value.staticAnalysis === "available" || value.staticAnalysis === "partial" || value.staticAnalysis === "unavailable") && value.runtimeObservation === "dispatch-only" && value.responseShape === "consumed-fields-only" && value.aiAssistance === "disabled" && Array.isArray(value.reasons);
|
|
374
|
+
}
|
|
375
|
+
function isDataFlowDependency(value) {
|
|
376
|
+
return isRecord2(value) && typeof value.id === "string" && typeof value.kind === "string" && typeof value.direction === "string" && typeof value.execution === "string" && typeof value.proof === "string" && typeof value.association === "string" && Array.isArray(value.parameters) && isRecord2(value.response) && isStringArray(value.response.consumedFields) && isStringArray(value.evidenceIds) && isStringArray(value.observationIds);
|
|
377
|
+
}
|
|
378
|
+
function isDataFlowReportBase(value) {
|
|
379
|
+
return isRecord2(value) && value.schemaVersion === DATA_FLOW_SCHEMA_VERSION && typeof value.reportId === "string" && isRecord2(value.baseline) && typeof value.baseline.registryEpoch === "string" && typeof value.baseline.analyzerVersion === "string" && isStringArray(value.baseline.analyzedSourceVersions) && isDataFlowCapability(value.capability) && Array.isArray(value.dependencies) && value.dependencies.every(isDataFlowDependency) && Array.isArray(value.evidence) && Array.isArray(value.diagnostics) && isReportCompleteness(value.completeness);
|
|
380
|
+
}
|
|
381
|
+
function isComponentDataFlowReport(value) {
|
|
382
|
+
return isDataFlowReportBase(value) && isRecord2(value) && isRecord2(value.component) && isRecord2(value.component.source) && typeof value.component.source.fileId === "string" && typeof value.component.source.sourceVersion === "string";
|
|
383
|
+
}
|
|
384
|
+
function isPageDataFlowReport(value) {
|
|
385
|
+
return isDataFlowReportBase(value);
|
|
386
|
+
}
|
|
349
387
|
function parseCapability(value, expected) {
|
|
350
388
|
if (!isAgentCapabilitySnapshot(value) || value.providerProfileId !== expected.providerProfileId || value.modelProfileId !== expected.modelProfileId) {
|
|
351
389
|
throw new RuntimeApiError();
|
|
@@ -397,7 +435,7 @@ function createRuntimeApi(options) {
|
|
|
397
435
|
}
|
|
398
436
|
pendingRequests.clear();
|
|
399
437
|
}
|
|
400
|
-
async function requestJson(endpoint, method, body) {
|
|
438
|
+
async function requestJson(endpoint, method, body, maximumResponseBytes = MAX_JSON_RESPONSE_BYTES) {
|
|
401
439
|
const abortController = new AbortController();
|
|
402
440
|
pendingRequests.add(abortController);
|
|
403
441
|
try {
|
|
@@ -410,7 +448,7 @@ function createRuntimeApi(options) {
|
|
|
410
448
|
...body === void 0 ? {} : { body: JSON.stringify(body) },
|
|
411
449
|
signal: abortController.signal
|
|
412
450
|
});
|
|
413
|
-
return await readJsonEnvelope(response);
|
|
451
|
+
return await readJsonEnvelope(response, maximumResponseBytes);
|
|
414
452
|
} finally {
|
|
415
453
|
pendingRequests.delete(abortController);
|
|
416
454
|
}
|
|
@@ -504,6 +542,30 @@ function createRuntimeApi(options) {
|
|
|
504
542
|
}
|
|
505
543
|
return Object.freeze({ ...data });
|
|
506
544
|
},
|
|
545
|
+
async componentDataFlowReport(request) {
|
|
546
|
+
const data = await requestJson(
|
|
547
|
+
SPOTPATCH_ENDPOINTS.dataFlowComponentReport,
|
|
548
|
+
"POST",
|
|
549
|
+
request,
|
|
550
|
+
options.dataFlowReportMaxBytes
|
|
551
|
+
);
|
|
552
|
+
if (!isComponentDataFlowReport(data)) {
|
|
553
|
+
throw new RuntimeApiError();
|
|
554
|
+
}
|
|
555
|
+
return deepFreeze(data);
|
|
556
|
+
},
|
|
557
|
+
async pageDataFlowReport(request) {
|
|
558
|
+
const data = await requestJson(
|
|
559
|
+
SPOTPATCH_ENDPOINTS.dataFlowPageReport,
|
|
560
|
+
"POST",
|
|
561
|
+
request,
|
|
562
|
+
options.dataFlowReportMaxBytes
|
|
563
|
+
);
|
|
564
|
+
if (!isPageDataFlowReport(data)) {
|
|
565
|
+
throw new RuntimeApiError();
|
|
566
|
+
}
|
|
567
|
+
return deepFreeze(data);
|
|
568
|
+
},
|
|
507
569
|
async openEditor(request) {
|
|
508
570
|
const data = await requestJson(SPOTPATCH_ENDPOINTS.openEditor, "POST", request);
|
|
509
571
|
if (!isRecord2(data) || data.editor !== "auto" && data.editor !== "vscode" && data.editor !== "cursor") {
|
|
@@ -1071,13 +1133,6 @@ function getVisibleElementRect(element2, view) {
|
|
|
1071
1133
|
return rect.width > 0 && rect.height > 0 ? rect : void 0;
|
|
1072
1134
|
}
|
|
1073
1135
|
|
|
1074
|
-
// src/ui/ui-constants.ts
|
|
1075
|
-
var UI_MARKER_ATTRIBUTE = "data-spotpatch-ui";
|
|
1076
|
-
var UI_Z_INDEX = Object.freeze({
|
|
1077
|
-
highlight: 2147483646,
|
|
1078
|
-
controls: 2147483647
|
|
1079
|
-
});
|
|
1080
|
-
|
|
1081
1136
|
// src/picker/hit-test.ts
|
|
1082
1137
|
function isInsideSpotPatchUI(element2) {
|
|
1083
1138
|
if (element2.closest(`[${UI_MARKER_ATTRIBUTE}]`) !== null) {
|
|
@@ -1683,20 +1738,6 @@ import {
|
|
|
1683
1738
|
SPOTPATCH_REPOSITORY_URL
|
|
1684
1739
|
} from "@spotpatch/shared";
|
|
1685
1740
|
|
|
1686
|
-
// src/ui/dom.ts
|
|
1687
|
-
function createMarkedElement(document, tagName) {
|
|
1688
|
-
const element2 = document.createElement(tagName);
|
|
1689
|
-
element2.setAttribute(UI_MARKER_ATTRIBUTE, "");
|
|
1690
|
-
return element2;
|
|
1691
|
-
}
|
|
1692
|
-
function createButton(document, label, className = "") {
|
|
1693
|
-
const button = createMarkedElement(document, "button");
|
|
1694
|
-
button.type = "button";
|
|
1695
|
-
button.className = className;
|
|
1696
|
-
button.textContent = label;
|
|
1697
|
-
return button;
|
|
1698
|
-
}
|
|
1699
|
-
|
|
1700
1741
|
// src/ui/agent-panel.ts
|
|
1701
1742
|
var AGENT_PANEL_STYLES = `
|
|
1702
1743
|
.spotpatch-agent {
|
|
@@ -2560,6 +2601,9 @@ var ERROR_MESSAGES_EN = Object.freeze({
|
|
|
2560
2601
|
[ERROR_CODES2.SOURCE_OUTSIDE_ROOT]: "The selected source is outside the project.",
|
|
2561
2602
|
[ERROR_CODES2.SOURCE_TOO_LARGE]: "The selected source exceeds the safety limit.",
|
|
2562
2603
|
[ERROR_CODES2.EDITOR_OPEN_FAILED]: "The editor request failed.",
|
|
2604
|
+
[ERROR_CODES2.DATA_FLOW_DISABLED]: "Component data-flow analysis is disabled.",
|
|
2605
|
+
[ERROR_CODES2.DATA_FLOW_SOURCE_STALE]: "The selected source changed. Select the component again.",
|
|
2606
|
+
[ERROR_CODES2.DATA_FLOW_ANALYSIS_CANCELLED]: "Component data-flow analysis was cancelled.",
|
|
2563
2607
|
[ERROR_CODES2.AI_DISABLED]: "AI execution is disabled in Vite configuration.",
|
|
2564
2608
|
[ERROR_CODES2.PROVIDER_NOT_CONFIGURED]: "The provider Key environment variable is missing on the Vite process.",
|
|
2565
2609
|
[ERROR_CODES2.PROVIDER_AUTH_FAILED]: "The provider rejected authentication. Check the server-side Key.",
|
|
@@ -2595,6 +2639,9 @@ var ERROR_MESSAGES_ZH = Object.freeze({
|
|
|
2595
2639
|
[ERROR_CODES2.SOURCE_OUTSIDE_ROOT]: "\u9009\u4E2D\u6E90\u7801\u4F4D\u4E8E\u9879\u76EE\u6839\u76EE\u5F55\u4E4B\u5916\u3002",
|
|
2596
2640
|
[ERROR_CODES2.SOURCE_TOO_LARGE]: "\u9009\u4E2D\u6E90\u7801\u8D85\u8FC7\u5B89\u5168\u5927\u5C0F\u9650\u5236\u3002",
|
|
2597
2641
|
[ERROR_CODES2.EDITOR_OPEN_FAILED]: "\u7F16\u8F91\u5668\u6253\u5F00\u8BF7\u6C42\u5931\u8D25\u3002",
|
|
2642
|
+
[ERROR_CODES2.DATA_FLOW_DISABLED]: "\u7EC4\u4EF6\u6570\u636E\u94FE\u8DEF\u5206\u6790\u672A\u542F\u7528\u3002",
|
|
2643
|
+
[ERROR_CODES2.DATA_FLOW_SOURCE_STALE]: "\u9009\u4E2D\u6E90\u7801\u5DF2\u7ECF\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u7EC4\u4EF6\u3002",
|
|
2644
|
+
[ERROR_CODES2.DATA_FLOW_ANALYSIS_CANCELLED]: "\u7EC4\u4EF6\u6570\u636E\u94FE\u8DEF\u5206\u6790\u5DF2\u53D6\u6D88\u3002",
|
|
2598
2645
|
[ERROR_CODES2.AI_DISABLED]: "Vite \u914D\u7F6E\u672A\u542F\u7528 AI \u6267\u884C\u3002",
|
|
2599
2646
|
[ERROR_CODES2.PROVIDER_NOT_CONFIGURED]: "\u542F\u52A8 Vite \u7684\u8FDB\u7A0B\u4E2D\u7F3A\u5C11\u6A21\u578B\u670D\u52A1 Key \u73AF\u5883\u53D8\u91CF\u3002",
|
|
2600
2647
|
[ERROR_CODES2.PROVIDER_AUTH_FAILED]: "\u6A21\u578B\u670D\u52A1\u9274\u6743\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u670D\u52A1\u7AEF Key\u3002",
|
|
@@ -2775,14 +2822,14 @@ var UI_MESSAGES = Object.freeze({
|
|
|
2775
2822
|
mode: "Execution mode",
|
|
2776
2823
|
review: "Review",
|
|
2777
2824
|
autoGated: "Auto gated",
|
|
2778
|
-
trustedFast: "Trusted
|
|
2825
|
+
trustedFast: "Trusted direct",
|
|
2779
2826
|
provider: "Provider",
|
|
2780
2827
|
model: "Model",
|
|
2781
2828
|
providerAriaLabel: "AI provider",
|
|
2782
2829
|
modelAriaLabel: "AI model",
|
|
2783
2830
|
providerUnavailable: "Provider configuration is unavailable.",
|
|
2784
2831
|
consent: (provider) => `I understand selected context and allowed source may be sent to ${provider}; its data policy is my responsibility.`,
|
|
2785
|
-
trustedFastConsent: (provider) => `Enable trusted
|
|
2832
|
+
trustedFastConsent: (provider) => `Enable trusted direct mode for ${provider}: send allowed project context, include current local changes, skip project validation checks, and immediately apply AI changes, including file deletions and configuration changes.`,
|
|
2786
2833
|
connectionNotTested: "Optional connection check not run",
|
|
2787
2834
|
workspaceNotChecked: "Local workspace not checked",
|
|
2788
2835
|
checkingWorkspace: "Checking Git workspace and isolated execution\u2026",
|
|
@@ -2794,7 +2841,7 @@ var UI_MESSAGES = Object.freeze({
|
|
|
2794
2841
|
capabilityVerified: "Agent capability verified",
|
|
2795
2842
|
capabilityVerifiedAnnouncement: "AI provider capability verified.",
|
|
2796
2843
|
testingCapability: "Testing authentication, tools, continuation, and streaming\u2026",
|
|
2797
|
-
applying: "Applying
|
|
2844
|
+
applying: "Applying changes to the project.",
|
|
2798
2845
|
cancelling: "Cancelling Agent job.",
|
|
2799
2846
|
reverting: "Reverting the applied Agent change.",
|
|
2800
2847
|
consentRequired: "Confirm remote provider data transmission before running AI.",
|
|
@@ -2913,14 +2960,14 @@ var UI_MESSAGES = Object.freeze({
|
|
|
2913
2960
|
mode: "\u6267\u884C\u65B9\u5F0F",
|
|
2914
2961
|
review: "\u5BA1\u9605\u6A21\u5F0F",
|
|
2915
2962
|
autoGated: "\u53D7\u63A7\u81EA\u52A8\u6A21\u5F0F",
|
|
2916
|
-
trustedFast: "\u53EF\u4FE1\
|
|
2963
|
+
trustedFast: "\u53EF\u4FE1\u6781\u901F\u6A21\u5F0F",
|
|
2917
2964
|
provider: "\u6A21\u578B\u670D\u52A1",
|
|
2918
2965
|
model: "\u6A21\u578B",
|
|
2919
2966
|
providerAriaLabel: "AI \u6A21\u578B\u670D\u52A1",
|
|
2920
2967
|
modelAriaLabel: "AI \u6A21\u578B",
|
|
2921
2968
|
providerUnavailable: "\u6A21\u578B\u670D\u52A1\u914D\u7F6E\u4E0D\u53EF\u7528\u3002",
|
|
2922
2969
|
consent: (provider) => `\u6211\u4E86\u89E3\u9009\u4E2D\u4E0A\u4E0B\u6587\u4E0E\u83B7\u51C6\u6E90\u7801\u53EF\u80FD\u53D1\u9001\u5230 ${provider}\uFF0C\u5E76\u81EA\u884C\u8D1F\u8D23\u5176\u6570\u636E\u7B56\u7565\u3002`,
|
|
2923
|
-
trustedFastConsent: (provider) => `\u4E3A ${provider} \u542F\u7528\u53EF\u4FE1\
|
|
2970
|
+
trustedFastConsent: (provider) => `\u4E3A ${provider} \u542F\u7528\u53EF\u4FE1\u6781\u901F\u6A21\u5F0F\uFF1A\u53D1\u9001\u83B7\u51C6\u7684\u9879\u76EE\u4E0A\u4E0B\u6587\u3001\u7EB3\u5165\u5F53\u524D\u672C\u5730\u4FEE\u6539\u3001\u8DF3\u8FC7\u9879\u76EE\u9A8C\u8BC1\u68C0\u67E5\uFF0C\u5E76\u7ACB\u5373\u5E94\u7528 AI \u53D8\u66F4\uFF0C\u5305\u62EC\u5220\u9664\u6587\u4EF6\u4E0E\u914D\u7F6E\u53D8\u66F4\u3002`,
|
|
2924
2971
|
connectionNotTested: "\u5C1A\u672A\u6267\u884C\u53EF\u9009\u8FDE\u63A5\u68C0\u67E5",
|
|
2925
2972
|
workspaceNotChecked: "\u5C1A\u672A\u68C0\u67E5\u672C\u5730\u5DE5\u4F5C\u533A",
|
|
2926
2973
|
checkingWorkspace: "\u6B63\u5728\u68C0\u67E5 Git \u5DE5\u4F5C\u533A\u4E0E\u9694\u79BB\u6267\u884C\u73AF\u5883\u2026\u2026",
|
|
@@ -2932,7 +2979,7 @@ var UI_MESSAGES = Object.freeze({
|
|
|
2932
2979
|
capabilityVerified: "Agent \u80FD\u529B\u9A8C\u8BC1\u901A\u8FC7",
|
|
2933
2980
|
capabilityVerifiedAnnouncement: "AI \u6A21\u578B\u670D\u52A1\u80FD\u529B\u9A8C\u8BC1\u901A\u8FC7\u3002",
|
|
2934
2981
|
testingCapability: "\u6B63\u5728\u9A8C\u8BC1\u9274\u6743\u3001\u5DE5\u5177\u8C03\u7528\u3001\u8FDE\u7EED\u8C03\u7528\u4E0E\u6D41\u5F0F\u54CD\u5E94\u2026\u2026",
|
|
2935
|
-
applying: "\u6B63\u5728\u5C06\
|
|
2982
|
+
applying: "\u6B63\u5728\u5C06\u53D8\u66F4\u5E94\u7528\u5230\u9879\u76EE\u3002",
|
|
2936
2983
|
cancelling: "\u6B63\u5728\u53D6\u6D88 Agent \u4EFB\u52A1\u3002",
|
|
2937
2984
|
reverting: "\u6B63\u5728\u64A4\u9500\u5DF2\u5E94\u7528\u7684 Agent \u53D8\u66F4\u3002",
|
|
2938
2985
|
consentRequired: "\u8FD0\u884C AI \u524D\uFF0C\u8BF7\u5148\u786E\u8BA4\u5141\u8BB8\u5411\u8FDC\u7A0B\u6A21\u578B\u670D\u52A1\u4F20\u8F93\u6570\u636E\u3002",
|
|
@@ -3739,7 +3786,18 @@ function summaryLine(summary, prefix) {
|
|
|
3739
3786
|
const line = summary.split("\n").find((candidate) => candidate.startsWith(`${prefix}: `));
|
|
3740
3787
|
return line?.slice(prefix.length + 2).trim();
|
|
3741
3788
|
}
|
|
3742
|
-
function
|
|
3789
|
+
function createUnavailableDataFlowPanel(document, changesRoot, diagnosticsRoot) {
|
|
3790
|
+
changesRoot.append(diagnosticsRoot);
|
|
3791
|
+
return Object.freeze({
|
|
3792
|
+
root: changesRoot,
|
|
3793
|
+
refreshButton: createButton(document, ""),
|
|
3794
|
+
styles: document.createElement("style"),
|
|
3795
|
+
dispose: () => void 0,
|
|
3796
|
+
render: () => void 0,
|
|
3797
|
+
resetView: () => void 0
|
|
3798
|
+
});
|
|
3799
|
+
}
|
|
3800
|
+
function createRuntimeView(document, shortcut, ai = Object.freeze({ enabled: false }), localePreference = "auto", dataFlowEnabled = false) {
|
|
3743
3801
|
const localizer = createUiLocalizer(document, localePreference);
|
|
3744
3802
|
let messages = localizer.messages();
|
|
3745
3803
|
const host = document.createElement("spotpatch-root");
|
|
@@ -3855,7 +3913,17 @@ function createRuntimeView(document, shortcut, ai = Object.freeze({ enabled: fal
|
|
|
3855
3913
|
summary.className = "spotpatch-summary";
|
|
3856
3914
|
diagnostics.append(diagnosticsLabel, summary);
|
|
3857
3915
|
const agentPanel = createAgentPanel(document, ai, localizer);
|
|
3858
|
-
|
|
3916
|
+
const changesPanel = createMarkedElement(document, "div");
|
|
3917
|
+
changesPanel.append(targetsPanel, agentPanel.root);
|
|
3918
|
+
const dataFlowPanel = getDataFlowExtension()?.createPanel(
|
|
3919
|
+
document,
|
|
3920
|
+
dataFlowEnabled,
|
|
3921
|
+
localizer.locale,
|
|
3922
|
+
changesPanel,
|
|
3923
|
+
diagnostics,
|
|
3924
|
+
placeDialog
|
|
3925
|
+
) ?? createUnavailableDataFlowPanel(document, changesPanel, diagnostics);
|
|
3926
|
+
selectionPanel.append(dataFlowPanel.root);
|
|
3859
3927
|
const previewPanel = createMarkedElement(document, "div");
|
|
3860
3928
|
previewPanel.className = "spotpatch-preview-panel";
|
|
3861
3929
|
previewPanel.hidden = true;
|
|
@@ -3915,6 +3983,7 @@ function createRuntimeView(document, shortcut, ai = Object.freeze({ enabled: fal
|
|
|
3915
3983
|
liveRegion.setAttribute("aria-atomic", "true");
|
|
3916
3984
|
shadowRoot.append(
|
|
3917
3985
|
createStyles(document),
|
|
3986
|
+
dataFlowPanel.styles,
|
|
3918
3987
|
selectionHighlights,
|
|
3919
3988
|
highlight,
|
|
3920
3989
|
dialog,
|
|
@@ -3932,6 +4001,13 @@ function createRuntimeView(document, shortcut, ai = Object.freeze({ enabled: fal
|
|
|
3932
4001
|
let currentTargets = [];
|
|
3933
4002
|
let currentMaximum = 0;
|
|
3934
4003
|
let currentEditorFeedbackState = "idle";
|
|
4004
|
+
let currentDataFlowState = Object.freeze({
|
|
4005
|
+
component: Object.freeze({
|
|
4006
|
+
status: dataFlowEnabled ? "idle" : "disabled"
|
|
4007
|
+
}),
|
|
4008
|
+
page: Object.freeze({ status: dataFlowEnabled ? "idle" : "disabled" }),
|
|
4009
|
+
observationCount: 0
|
|
4010
|
+
});
|
|
3935
4011
|
function renderEditorStatus(state) {
|
|
3936
4012
|
currentEditorFeedbackState = state;
|
|
3937
4013
|
editorFeedback.dataset.state = state;
|
|
@@ -4233,6 +4309,7 @@ function createRuntimeView(document, shortcut, ai = Object.freeze({ enabled: fal
|
|
|
4233
4309
|
previewButton.textContent = messages.actions.preview;
|
|
4234
4310
|
copyButton.textContent = messages.actions.copy;
|
|
4235
4311
|
backButton.textContent = messages.actions.back;
|
|
4312
|
+
dataFlowPanel.render(currentDataFlowState);
|
|
4236
4313
|
triggerButton.title = messages.trigger.title(shortcut);
|
|
4237
4314
|
triggerButton.textContent = currentStatus === "inspecting" ? messages.trigger.stop : messages.trigger.select;
|
|
4238
4315
|
renderPanelStatus(currentStatus);
|
|
@@ -4271,6 +4348,7 @@ function createRuntimeView(document, shortcut, ai = Object.freeze({ enabled: fal
|
|
|
4271
4348
|
repositoryLink,
|
|
4272
4349
|
previewButton,
|
|
4273
4350
|
copyButton,
|
|
4351
|
+
dataFlowRefreshButton: dataFlowPanel.refreshButton,
|
|
4274
4352
|
backButton,
|
|
4275
4353
|
closeButton,
|
|
4276
4354
|
agentProviderSelect: agentPanel.providerSelect,
|
|
@@ -4291,6 +4369,11 @@ function createRuntimeView(document, shortcut, ai = Object.freeze({ enabled: fal
|
|
|
4291
4369
|
renderPanelStatus(status);
|
|
4292
4370
|
},
|
|
4293
4371
|
renderEditorStatus,
|
|
4372
|
+
renderDataFlow(state) {
|
|
4373
|
+
currentDataFlowState = state;
|
|
4374
|
+
dataFlowPanel.render(state);
|
|
4375
|
+
placeDialog();
|
|
4376
|
+
},
|
|
4294
4377
|
showHighlight(rect, label) {
|
|
4295
4378
|
currentRect = rect;
|
|
4296
4379
|
highlight.hidden = false;
|
|
@@ -4353,6 +4436,7 @@ function createRuntimeView(document, shortcut, ai = Object.freeze({ enabled: fal
|
|
|
4353
4436
|
agentPanel.setSelectionVisible(false);
|
|
4354
4437
|
agentPanel.setEditingEnabled(true);
|
|
4355
4438
|
agentPanel.resetJob();
|
|
4439
|
+
dataFlowPanel.resetView();
|
|
4356
4440
|
},
|
|
4357
4441
|
hideSelectionTemporarily() {
|
|
4358
4442
|
dialog.hidden = true;
|
|
@@ -4421,6 +4505,7 @@ function createRuntimeView(document, shortcut, ai = Object.freeze({ enabled: fal
|
|
|
4421
4505
|
diagnostics.removeEventListener("toggle", placeDialog);
|
|
4422
4506
|
localeButton.removeEventListener("click", localizer.toggle);
|
|
4423
4507
|
unsubscribeLocale();
|
|
4508
|
+
dataFlowPanel.dispose();
|
|
4424
4509
|
agentPanel.dispose();
|
|
4425
4510
|
host.remove();
|
|
4426
4511
|
}
|
|
@@ -4913,9 +4998,16 @@ function resolveBrowserDependencies(dependencies) {
|
|
|
4913
4998
|
}
|
|
4914
4999
|
function createController(config, dependencies = {}) {
|
|
4915
5000
|
const browser = resolveBrowserDependencies(dependencies);
|
|
4916
|
-
const view = dependencies.view ?? createRuntimeView(
|
|
5001
|
+
const view = dependencies.view ?? createRuntimeView(
|
|
5002
|
+
browser.document,
|
|
5003
|
+
config.shortcut,
|
|
5004
|
+
config.ai,
|
|
5005
|
+
config.locale,
|
|
5006
|
+
config.dataFlow.enabled
|
|
5007
|
+
);
|
|
4917
5008
|
const api = dependencies.api ?? createRuntimeApi({
|
|
4918
5009
|
apiBase: config.apiBase,
|
|
5010
|
+
dataFlowReportMaxBytes: config.dataFlow.limits.reportMaxBytes,
|
|
4919
5011
|
fetch: browser.window.fetch.bind(browser.window),
|
|
4920
5012
|
sessionToken: config.sessionToken
|
|
4921
5013
|
});
|
|
@@ -4927,6 +5019,9 @@ function createController(config, dependencies = {}) {
|
|
|
4927
5019
|
const restoredSelection = selectionSession.load();
|
|
4928
5020
|
const sourceResolver = createSourceResolver({
|
|
4929
5021
|
adapter: dependencies.reactAdapter ?? createReact18Adapter({
|
|
5022
|
+
...config.dataFlow.enabled ? {
|
|
5023
|
+
getComponentRegistration: (component) => getDataFlowExtension()?.getComponentRegistration(component)
|
|
5024
|
+
} : {},
|
|
4930
5025
|
maxComponentDepth: config.budget.maxComponentDepth
|
|
4931
5026
|
}),
|
|
4932
5027
|
onAdapterError() {
|
|
@@ -4950,6 +5045,8 @@ function createController(config, dependencies = {}) {
|
|
|
4950
5045
|
apiStatus: marker === void 0 ? "not-required" : target2.code === void 0 ? "failed" : "connected",
|
|
4951
5046
|
code: target2.code,
|
|
4952
5047
|
collectionStatus: "ready",
|
|
5048
|
+
dataFlowReport: void 0,
|
|
5049
|
+
dataFlowStatus: "idle",
|
|
4953
5050
|
element: void 0,
|
|
4954
5051
|
elementContext: target2.element,
|
|
4955
5052
|
instruction: target2.instruction,
|
|
@@ -4964,6 +5061,9 @@ function createController(config, dependencies = {}) {
|
|
|
4964
5061
|
let workflowSelectionActive = false;
|
|
4965
5062
|
let sessionRevision = 0;
|
|
4966
5063
|
let editorRequestRevision = 0;
|
|
5064
|
+
let dataFlowRequestRevision = 0;
|
|
5065
|
+
let pageDataFlowReport;
|
|
5066
|
+
let pageDataFlowStatus = "idle";
|
|
4967
5067
|
let addingTarget = false;
|
|
4968
5068
|
let previewPrompt = "";
|
|
4969
5069
|
let previousFocus;
|
|
@@ -4978,6 +5078,90 @@ function createController(config, dependencies = {}) {
|
|
|
4978
5078
|
function activeTarget() {
|
|
4979
5079
|
return targets.find((target2) => target2.id === activeTargetId) ?? targets.at(-1);
|
|
4980
5080
|
}
|
|
5081
|
+
function dataFlowRequest(target2) {
|
|
5082
|
+
const react2 = target2.resolution.react;
|
|
5083
|
+
if (react2.componentSourceId !== void 0 && react2.sourceVersion !== void 0) {
|
|
5084
|
+
return Object.freeze({
|
|
5085
|
+
schemaVersion: DATA_FLOW_SCHEMA_VERSION2,
|
|
5086
|
+
componentSourceId: react2.componentSourceId,
|
|
5087
|
+
sourceVersion: react2.sourceVersion
|
|
5088
|
+
});
|
|
5089
|
+
}
|
|
5090
|
+
const marker = target2.marker;
|
|
5091
|
+
return marker === void 0 ? void 0 : Object.freeze({
|
|
5092
|
+
schemaVersion: DATA_FLOW_SCHEMA_VERSION2,
|
|
5093
|
+
fileId: marker.fileId,
|
|
5094
|
+
line: marker.line,
|
|
5095
|
+
column: marker.column
|
|
5096
|
+
});
|
|
5097
|
+
}
|
|
5098
|
+
function renderDataFlowView() {
|
|
5099
|
+
const dataFlowClient = getDataFlowExtension();
|
|
5100
|
+
const observations = dataFlowClient?.observations(browser.window.location.pathname) ?? [];
|
|
5101
|
+
const current = activeTarget();
|
|
5102
|
+
view.renderDataFlow({
|
|
5103
|
+
component: Object.freeze({
|
|
5104
|
+
status: config.dataFlow.enabled ? current?.dataFlowStatus ?? "idle" : "disabled",
|
|
5105
|
+
...current?.dataFlowReport === void 0 ? {} : {
|
|
5106
|
+
report: dataFlowClient?.mergeComponentReport(
|
|
5107
|
+
current.dataFlowReport,
|
|
5108
|
+
observations
|
|
5109
|
+
) ?? current.dataFlowReport
|
|
5110
|
+
}
|
|
5111
|
+
}),
|
|
5112
|
+
page: Object.freeze({
|
|
5113
|
+
status: config.dataFlow.enabled ? pageDataFlowStatus : "disabled",
|
|
5114
|
+
...pageDataFlowReport === void 0 ? {} : {
|
|
5115
|
+
report: dataFlowClient?.mergePageReport(pageDataFlowReport, observations) ?? pageDataFlowReport
|
|
5116
|
+
}
|
|
5117
|
+
}),
|
|
5118
|
+
observationCount: observations.length
|
|
5119
|
+
});
|
|
5120
|
+
}
|
|
5121
|
+
async function loadDataFlowReports() {
|
|
5122
|
+
if (!config.dataFlow.enabled) {
|
|
5123
|
+
renderDataFlowView();
|
|
5124
|
+
return;
|
|
5125
|
+
}
|
|
5126
|
+
const current = activeTarget();
|
|
5127
|
+
const currentRequest = current === void 0 ? void 0 : dataFlowRequest(current);
|
|
5128
|
+
const pageTargets = targets.flatMap((target2) => {
|
|
5129
|
+
const request = dataFlowRequest(target2);
|
|
5130
|
+
return request === void 0 ? [] : [request];
|
|
5131
|
+
});
|
|
5132
|
+
const revision = ++dataFlowRequestRevision;
|
|
5133
|
+
const selectionRevision = sessionRevision;
|
|
5134
|
+
if (current !== void 0) current.dataFlowStatus = "loading";
|
|
5135
|
+
pageDataFlowStatus = pageTargets.length === 0 ? "idle" : "loading";
|
|
5136
|
+
renderDataFlowView();
|
|
5137
|
+
const [componentResult, pageResult] = await Promise.allSettled([
|
|
5138
|
+
currentRequest === void 0 ? Promise.resolve(void 0) : api.componentDataFlowReport(currentRequest),
|
|
5139
|
+
pageTargets.length === 0 ? Promise.resolve(void 0) : api.pageDataFlowReport({
|
|
5140
|
+
schemaVersion: DATA_FLOW_SCHEMA_VERSION2,
|
|
5141
|
+
targets: pageTargets
|
|
5142
|
+
})
|
|
5143
|
+
]);
|
|
5144
|
+
if (!mounted || revision !== dataFlowRequestRevision || selectionRevision !== sessionRevision) {
|
|
5145
|
+
return;
|
|
5146
|
+
}
|
|
5147
|
+
if (current !== void 0 && targets.includes(current)) {
|
|
5148
|
+
if (componentResult.status === "fulfilled") {
|
|
5149
|
+
current.dataFlowReport = componentResult.value;
|
|
5150
|
+
current.dataFlowStatus = componentResult.value === void 0 ? "idle" : "ready";
|
|
5151
|
+
} else {
|
|
5152
|
+
current.dataFlowReport = void 0;
|
|
5153
|
+
current.dataFlowStatus = "error";
|
|
5154
|
+
}
|
|
5155
|
+
}
|
|
5156
|
+
if (pageResult.status === "fulfilled") {
|
|
5157
|
+
pageDataFlowReport = pageResult.value;
|
|
5158
|
+
pageDataFlowStatus = pageResult.value === void 0 ? "idle" : "ready";
|
|
5159
|
+
} else {
|
|
5160
|
+
pageDataFlowReport = void 0;
|
|
5161
|
+
pageDataFlowStatus = "error";
|
|
5162
|
+
}
|
|
5163
|
+
renderDataFlowView();
|
|
5164
|
+
}
|
|
4981
5165
|
function snapshotTarget(target2) {
|
|
4982
5166
|
if (target2.elementContext === void 0 || target2.styles === void 0) {
|
|
4983
5167
|
return void 0;
|
|
@@ -5146,6 +5330,9 @@ ${summary}`;
|
|
|
5146
5330
|
resizeObserver?.disconnect();
|
|
5147
5331
|
targets = [];
|
|
5148
5332
|
activeTargetId = void 0;
|
|
5333
|
+
dataFlowRequestRevision += 1;
|
|
5334
|
+
pageDataFlowReport = void 0;
|
|
5335
|
+
pageDataFlowStatus = "idle";
|
|
5149
5336
|
selectionOpen = false;
|
|
5150
5337
|
workflowSelectionActive = false;
|
|
5151
5338
|
addingTarget = false;
|
|
@@ -5200,6 +5387,7 @@ ${summary}`;
|
|
|
5200
5387
|
workflowSelectionActive = true;
|
|
5201
5388
|
}
|
|
5202
5389
|
refreshSelectionView(true);
|
|
5390
|
+
void loadDataFlowReports();
|
|
5203
5391
|
view.focusTargetInstruction(activeTargetId);
|
|
5204
5392
|
persistSelection();
|
|
5205
5393
|
return;
|
|
@@ -5350,6 +5538,7 @@ ${summary}`;
|
|
|
5350
5538
|
transition({ type: "SELECT" });
|
|
5351
5539
|
view.hideHighlight();
|
|
5352
5540
|
refreshSelectionView(true);
|
|
5541
|
+
void loadDataFlowReports();
|
|
5353
5542
|
view.focusTargetInstruction(duplicate.id);
|
|
5354
5543
|
view.announce(view.messages().announcements.duplicate);
|
|
5355
5544
|
return;
|
|
@@ -5381,7 +5570,9 @@ ${summary}`;
|
|
|
5381
5570
|
styles: void 0,
|
|
5382
5571
|
instruction: "",
|
|
5383
5572
|
apiStatus: marker === void 0 ? "not-required" : "loading",
|
|
5384
|
-
collectionStatus: "loading"
|
|
5573
|
+
collectionStatus: "loading",
|
|
5574
|
+
dataFlowReport: void 0,
|
|
5575
|
+
dataFlowStatus: "idle"
|
|
5385
5576
|
};
|
|
5386
5577
|
targets.push(target2);
|
|
5387
5578
|
activeTargetId = target2.id;
|
|
@@ -5391,6 +5582,7 @@ ${summary}`;
|
|
|
5391
5582
|
view.hideHighlight();
|
|
5392
5583
|
resizeObserver?.observe(element2);
|
|
5393
5584
|
refreshSelectionView(true);
|
|
5585
|
+
void loadDataFlowReports();
|
|
5394
5586
|
selectionOpen = true;
|
|
5395
5587
|
view.focusTargetInstruction(target2.id);
|
|
5396
5588
|
scheduleBrowserContextCollection(target2, revision);
|
|
@@ -5495,11 +5687,15 @@ ${summary}`;
|
|
|
5495
5687
|
}
|
|
5496
5688
|
view.hideSelectionTemporarily();
|
|
5497
5689
|
view.hideSelectionHighlights();
|
|
5690
|
+
pageDataFlowReport = void 0;
|
|
5691
|
+
pageDataFlowStatus = "idle";
|
|
5692
|
+
renderDataFlowView();
|
|
5498
5693
|
selectionSession.clear();
|
|
5499
5694
|
view.announce(view.messages().announcements.allTargetsRemoved);
|
|
5500
5695
|
return;
|
|
5501
5696
|
}
|
|
5502
5697
|
refreshSelectionView();
|
|
5698
|
+
void loadDataFlowReports();
|
|
5503
5699
|
persistSelection();
|
|
5504
5700
|
view.announce(view.messages().announcements.targetRemoved);
|
|
5505
5701
|
}
|
|
@@ -5662,11 +5858,15 @@ ${summary}`;
|
|
|
5662
5858
|
}
|
|
5663
5859
|
activeTargetId = targetId;
|
|
5664
5860
|
refreshSelectionView();
|
|
5861
|
+
void loadDataFlowReports();
|
|
5665
5862
|
view.focusTargetInstruction(targetId);
|
|
5666
5863
|
}
|
|
5667
5864
|
function handleReselect() {
|
|
5668
5865
|
beginReselect();
|
|
5669
5866
|
}
|
|
5867
|
+
function handleDataFlowRefresh() {
|
|
5868
|
+
void loadDataFlowReports();
|
|
5869
|
+
}
|
|
5670
5870
|
function mount() {
|
|
5671
5871
|
if (mounted) {
|
|
5672
5872
|
return;
|
|
@@ -5685,6 +5885,7 @@ ${summary}`;
|
|
|
5685
5885
|
view.targetList.addEventListener("input", handleTargetListInput);
|
|
5686
5886
|
view.targetList.addEventListener("keydown", handleTargetListKeydown);
|
|
5687
5887
|
view.openEditorButton.addEventListener("click", handleOpenEditorButtonClick);
|
|
5888
|
+
view.dataFlowRefreshButton.addEventListener("click", handleDataFlowRefresh);
|
|
5688
5889
|
view.previewButton.addEventListener("click", handlePreview);
|
|
5689
5890
|
view.copyButton.addEventListener("click", handleCopy);
|
|
5690
5891
|
view.backButton.addEventListener("click", handleBack);
|
|
@@ -5755,6 +5956,7 @@ ${summary}`;
|
|
|
5755
5956
|
view.targetList.removeEventListener("input", handleTargetListInput);
|
|
5756
5957
|
view.targetList.removeEventListener("keydown", handleTargetListKeydown);
|
|
5757
5958
|
view.openEditorButton.removeEventListener("click", handleOpenEditorButtonClick);
|
|
5959
|
+
view.dataFlowRefreshButton.removeEventListener("click", handleDataFlowRefresh);
|
|
5758
5960
|
view.previewButton.removeEventListener("click", handlePreview);
|
|
5759
5961
|
view.copyButton.removeEventListener("click", handleCopy);
|
|
5760
5962
|
view.backButton.removeEventListener("click", handleBack);
|
|
@@ -5817,6 +6019,11 @@ function bootstrapSpotPatch(config) {
|
|
|
5817
6019
|
}
|
|
5818
6020
|
export {
|
|
5819
6021
|
UI_MARKER_ATTRIBUTE,
|
|
5820
|
-
bootstrapSpotPatch
|
|
6022
|
+
bootstrapSpotPatch,
|
|
6023
|
+
createDataFlowRuntime,
|
|
6024
|
+
getDataFlowRuntime,
|
|
6025
|
+
installDataFlowPrelude,
|
|
6026
|
+
mergeComponentDataFlowReport,
|
|
6027
|
+
mergePageDataFlowReport
|
|
5821
6028
|
};
|
|
5822
6029
|
//# sourceMappingURL=index.js.map
|