@spotpatch/runtime 1.8.0 → 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 +772 -13
- 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 +237 -30
- package/dist/index.js.map +1 -1
- package/package.json +33 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/data-flow/data-flow-runtime.ts","../src/data-flow/report-merger.ts"],"sourcesContent":["import {\n DATA_FLOW_SCHEMA_VERSION,\n DATA_FLOW_URL_QUERY_KEY_LIMIT,\n SPOTPATCH_API_BASE,\n type NetworkObservation,\n type RuntimeDataFlowConfig,\n type RuntimeDataFlowLimits,\n type SanitizedObservedUrl,\n} from \"@spotpatch/shared/data-flow-runtime\";\n\nexport interface DataFlowComponentRegistration {\n readonly componentSourceId: string;\n readonly sourceVersion: string;\n}\n\nexport interface DataFlowInvocationToken {\n readonly invocationId: string;\n readonly componentSourceId: string;\n readonly triggerCallsiteId: string;\n readonly sourceVersion: string;\n}\n\nexport interface DataFlowRequestFrame {\n readonly requestCallsiteId: string;\n readonly sourceVersion: string;\n readonly invocationToken?: DataFlowInvocationToken;\n}\n\nexport interface DataFlowTriggerMetadata {\n readonly componentSourceId: string;\n readonly triggerCallsiteId: string;\n readonly sourceVersion: string;\n}\n\nexport interface DataFlowRequestMetadata {\n readonly requestCallsiteId: string;\n readonly sourceVersion: string;\n}\n\nexport interface DataFlowRuntime {\n readonly beginInvocation: (\n metadata: DataFlowTriggerMetadata,\n ) => DataFlowInvocationToken;\n readonly bindInvocation: <Arguments extends readonly unknown[], Result>(\n token: DataFlowInvocationToken | undefined,\n callback: (...args: Arguments) => Result,\n ) => (...args: Arguments) => Result;\n readonly bindTrigger: <Callback>(\n metadata: DataFlowTriggerMetadata,\n callback: Callback,\n ) => Callback;\n readonly captureInvocation: () => DataFlowInvocationToken | undefined;\n readonly clear: () => void;\n readonly createTrpcLink: () => DataFlowTrpcLink;\n readonly dispose: () => void;\n readonly getComponentRegistration: (\n component: object,\n ) => DataFlowComponentRegistration | undefined;\n readonly getCurrentRequestFrame: () => DataFlowRequestFrame | undefined;\n readonly observations: () => readonly NetworkObservation[];\n readonly updateRoute: (routeKey: string) => void;\n readonly registerComponent: (\n component: object,\n componentSourceId: string,\n sourceVersion: string,\n ) => void;\n readonly withInvocation: <Result>(\n token: DataFlowInvocationToken | undefined,\n callback: () => Result,\n ) => Result;\n readonly withRequestFrame: <Result>(\n token: DataFlowInvocationToken | undefined,\n metadata: DataFlowRequestMetadata,\n callback: () => Result,\n ) => Result;\n}\n\nexport interface DataFlowTrpcOperation {\n readonly path: unknown;\n readonly type: unknown;\n}\n\nexport interface DataFlowTrpcLinkOptions<\n Operation extends DataFlowTrpcOperation,\n Result,\n> {\n readonly next: (operation: Operation) => Result;\n readonly op: Operation;\n}\n\nexport type DataFlowTrpcLink = (\n runtime: unknown,\n) => <Operation extends DataFlowTrpcOperation, Result>(\n options: DataFlowTrpcLinkOptions<Operation, Result>,\n) => Result;\n\ninterface DataFlowGlobal {\n readonly fetch?: typeof globalThis.fetch;\n readonly location?: Location;\n readonly performance?: Performance;\n readonly XMLHttpRequest?: typeof globalThis.XMLHttpRequest;\n}\n\ninterface MutableDataFlowGlobal extends DataFlowGlobal {\n fetch?: typeof globalThis.fetch;\n}\n\ninterface XhrMetadata {\n readonly method: string;\n readonly url: string;\n}\n\ninterface RingEntry {\n readonly bytes: number;\n readonly observation: NetworkObservation;\n readonly recordedAt: number;\n}\n\nconst RUNTIME_KEY: unique symbol = Symbol.for(\n \"spotpatch.data-flow.runtime.v1\",\n) as never;\nconst REACT_MEMO_TYPE = Symbol.for(\"react.memo\");\nconst REACT_FORWARD_REF_TYPE = Symbol.for(\"react.forward_ref\");\n\ntype DataFlowRuntimeStore = Partial<Record<symbol, DataFlowRuntime>>;\ntype GlobalWithDataFlow = MutableDataFlowGlobal & DataFlowRuntimeStore;\n\nfunction positiveNow(target: DataFlowGlobal): number {\n return target.performance?.now() ?? Date.now();\n}\n\nfunction createOpaqueSequence(prefix: string): () => string {\n let sequence = 0;\n const randomPrefix = (() => {\n try {\n const bytes = new Uint8Array(8);\n globalThis.crypto.getRandomValues(bytes);\n return Array.from(bytes, (value) => value.toString(36).padStart(2, \"0\")).join(\"\");\n } catch {\n return \"local\";\n }\n })();\n\n return () => {\n sequence += 1;\n return `${prefix}_${randomPrefix}_${sequence.toString(36)}`;\n };\n}\n\nfunction freezeUrl(value: string, baseUrl: string): SanitizedObservedUrl {\n try {\n const url = new URL(value, baseUrl);\n return Object.freeze({\n origin: url.origin,\n pathname: url.pathname,\n queryKeys: Object.freeze(\n [...new Set(url.searchParams.keys())]\n .sort()\n .slice(0, DATA_FLOW_URL_QUERY_KEY_LIMIT),\n ),\n });\n } catch {\n return Object.freeze({\n pathname: value.split(/[?#]/u, 1)[0] ?? \"{invalid}\",\n queryKeys: Object.freeze([]),\n });\n }\n}\n\nfunction readFetchUrl(input: RequestInfo | URL): string {\n if (typeof input === \"string\") return input;\n if (input instanceof URL) return input.toString();\n return input.url;\n}\n\nfunction readFetchMethod(input: RequestInfo | URL, init?: RequestInit): string {\n if (init?.method !== undefined) return init.method.toUpperCase();\n return typeof Request !== \"undefined\" && input instanceof Request\n ? input.method.toUpperCase()\n : \"GET\";\n}\n\nfunction isSpotPatchInternalUrl(value: string, baseUrl: string): boolean {\n try {\n const pathname = new URL(value, baseUrl).pathname;\n return (\n pathname === SPOTPATCH_API_BASE || pathname.startsWith(`${SPOTPATCH_API_BASE}/`)\n );\n } catch {\n return false;\n }\n}\n\nfunction approximateBytes(value: unknown): number {\n return new TextEncoder().encode(JSON.stringify(value)).byteLength;\n}\n\nfunction createRingStore(\n limits: RuntimeDataFlowLimits,\n target: DataFlowGlobal,\n): Readonly<{\n add: (observation: NetworkObservation) => void;\n clear: () => void;\n values: () => readonly NetworkObservation[];\n}> {\n const entries: RingEntry[] = [];\n let totalBytes = 0;\n\n function removeExpired(now: number): void {\n while (\n entries[0] !== undefined &&\n now - entries[0].recordedAt > limits.observationTtlMs\n ) {\n const removed = entries.shift();\n if (removed !== undefined) totalBytes -= removed.bytes;\n }\n }\n\n return Object.freeze({\n add(observation): void {\n const now = positiveNow(target);\n removeExpired(now);\n const bytes = approximateBytes(observation);\n if (bytes > limits.observationMaxBytes) return;\n entries.push(Object.freeze({ bytes, observation, recordedAt: now }));\n totalBytes += bytes;\n\n while (\n entries.length > limits.observationMaxEntries ||\n totalBytes > limits.observationMaxBytes\n ) {\n const removed = entries.shift();\n if (removed !== undefined) totalBytes -= removed.bytes;\n }\n },\n clear(): void {\n entries.length = 0;\n totalBytes = 0;\n },\n values(): readonly NetworkObservation[] {\n removeExpired(positiveNow(target));\n return Object.freeze(entries.map(({ observation }) => observation));\n },\n });\n}\n\nfunction ownPropertyDescriptor(\n target: object,\n key: PropertyKey,\n): PropertyDescriptor | undefined {\n try {\n return Object.getOwnPropertyDescriptor(target, key);\n } catch {\n return undefined;\n }\n}\n\nfunction nestedReactWrapperComponent(candidate: object): object | undefined {\n const marker: unknown = ownPropertyDescriptor(candidate, \"$$typeof\")?.value;\n const key =\n marker === REACT_MEMO_TYPE\n ? \"type\"\n : marker === REACT_FORWARD_REF_TYPE\n ? \"render\"\n : undefined;\n if (key === undefined) return undefined;\n const nested: unknown = ownPropertyDescriptor(candidate, key)?.value;\n return (typeof nested === \"object\" && nested !== null) || typeof nested === \"function\"\n ? nested\n : undefined;\n}\n\nfunction installWritableDataProperty(\n target: object,\n key: PropertyKey,\n replacement: object,\n original: PropertyDescriptor | undefined = ownPropertyDescriptor(target, key),\n): (() => void) | undefined {\n if (original === undefined || !(\"value\" in original) || !original.writable) {\n return undefined;\n }\n\n try {\n Object.defineProperty(target, key, { ...original, value: replacement });\n } catch {\n return undefined;\n }\n\n return (): void => {\n try {\n if (ownPropertyDescriptor(target, key)?.value === replacement) {\n Object.defineProperty(target, key, original);\n }\n } catch {\n // A host or later wrapper can make the property non-configurable.\n }\n };\n}\n\nfunction recordWithoutAffectingHost(record: () => void): void {\n try {\n record();\n } catch {\n // Observation is optional; the host transport result is authoritative.\n }\n}\n\nexport function createDataFlowRuntime(\n config: RuntimeDataFlowConfig,\n target: MutableDataFlowGlobal = globalThis,\n): DataFlowRuntime {\n const componentRegistry = new WeakMap<object, DataFlowComponentRegistration>();\n const xhrMetadata = new WeakMap<object, XhrMetadata>();\n const store = createRingStore(config.limits, target);\n const nextInvocationId = createOpaqueSequence(\"invocation\");\n const nextObservationId = createOpaqueSequence(\"observation\");\n const pageEpoch = createOpaqueSequence(\"page\")();\n const nextRouteEpoch = createOpaqueSequence(\"route\");\n let routeEpoch = nextRouteEpoch();\n let routeKey: string | undefined;\n let currentInvocation: DataFlowInvocationToken | undefined;\n let currentRequestFrame: DataFlowRequestFrame | undefined;\n let disposed = false;\n\n const originalFetch = (() => {\n try {\n return target.fetch;\n } catch {\n return undefined;\n }\n })();\n function spotPatchFetch(\n this: typeof globalThis,\n input: RequestInfo | URL,\n init?: RequestInit,\n ): Promise<Response> {\n if (originalFetch === undefined) {\n throw new TypeError(\"Fetch is unavailable.\");\n }\n const result = Reflect.apply(originalFetch, this, [input, init]);\n recordWithoutAffectingHost(() => {\n const frame = currentRequestFrame;\n const token = frame?.invocationToken;\n const rawUrl = readFetchUrl(input);\n if (\n isSpotPatchInternalUrl(\n rawUrl,\n target.location?.href ?? \"http://spotpatch.invalid/\",\n )\n ) {\n return;\n }\n store.add(\n Object.freeze({\n schemaVersion: DATA_FLOW_SCHEMA_VERSION,\n id: nextObservationId(),\n pageEpoch,\n routeEpoch,\n ...(frame === undefined\n ? {}\n : {\n requestCallsiteId: frame.requestCallsiteId,\n sourceVersion: frame.sourceVersion,\n }),\n ...(token === undefined\n ? {}\n : {\n invocationId: token.invocationId,\n componentSourceId: token.componentSourceId,\n triggerCallsiteId: token.triggerCallsiteId,\n }),\n transport: \"fetch\",\n method: readFetchMethod(input, init),\n url: freezeUrl(rawUrl, target.location?.href ?? \"http://spotpatch.invalid/\"),\n outcome: \"dispatched\",\n freshness: \"current\",\n diagnosticIds: Object.freeze([]),\n }),\n );\n });\n return result;\n }\n\n const restoreFetch =\n originalFetch === undefined\n ? undefined\n : installWritableDataProperty(target, \"fetch\", spotPatchFetch);\n\n const xhrPrototype = (() => {\n try {\n return target.XMLHttpRequest?.prototype;\n } catch {\n return undefined;\n }\n })();\n const originalOpenDescriptor =\n xhrPrototype === undefined\n ? undefined\n : ownPropertyDescriptor(xhrPrototype, \"open\");\n const originalSendDescriptor =\n xhrPrototype === undefined\n ? undefined\n : ownPropertyDescriptor(xhrPrototype, \"send\");\n\n function spotPatchOpen(\n this: XMLHttpRequest,\n method: string,\n url: string | URL,\n ...rest: readonly unknown[]\n ): void {\n const original: unknown = originalOpenDescriptor?.value;\n if (typeof original === \"function\") {\n Reflect.apply(original, this, [method, url, ...rest]);\n }\n recordWithoutAffectingHost(() => {\n xhrMetadata.set(this, Object.freeze({ method, url: String(url) }));\n });\n }\n\n function spotPatchSend(\n this: XMLHttpRequest,\n body?: Document | XMLHttpRequestBodyInit | null,\n ): void {\n const original: unknown = originalSendDescriptor?.value;\n if (typeof original === \"function\") Reflect.apply(original, this, [body]);\n recordWithoutAffectingHost(() => {\n const metadata = xhrMetadata.get(this);\n if (\n metadata === undefined ||\n isSpotPatchInternalUrl(\n metadata.url,\n target.location?.href ?? \"http://spotpatch.invalid/\",\n )\n ) {\n return;\n }\n const frame = currentRequestFrame;\n const token = frame?.invocationToken;\n store.add(\n Object.freeze({\n schemaVersion: DATA_FLOW_SCHEMA_VERSION,\n id: nextObservationId(),\n pageEpoch,\n routeEpoch,\n ...(frame === undefined\n ? {}\n : {\n requestCallsiteId: frame.requestCallsiteId,\n sourceVersion: frame.sourceVersion,\n }),\n ...(token === undefined\n ? {}\n : {\n invocationId: token.invocationId,\n componentSourceId: token.componentSourceId,\n triggerCallsiteId: token.triggerCallsiteId,\n }),\n transport: \"xhr\",\n method: metadata.method.toUpperCase(),\n url: freezeUrl(\n metadata.url,\n target.location?.href ?? \"http://spotpatch.invalid/\",\n ),\n outcome: \"dispatched\",\n freshness: \"current\",\n diagnosticIds: Object.freeze([]),\n }),\n );\n });\n }\n\n const restoreXhrOpen =\n xhrPrototype === undefined || typeof originalOpenDescriptor?.value !== \"function\"\n ? undefined\n : installWritableDataProperty(\n xhrPrototype,\n \"open\",\n spotPatchOpen,\n originalOpenDescriptor,\n );\n const restoreXhrSend =\n xhrPrototype === undefined || typeof originalSendDescriptor?.value !== \"function\"\n ? undefined\n : installWritableDataProperty(\n xhrPrototype,\n \"send\",\n spotPatchSend,\n originalSendDescriptor,\n );\n\n const runtime: DataFlowRuntime = Object.freeze({\n beginInvocation(metadata: DataFlowTriggerMetadata): DataFlowInvocationToken {\n return Object.freeze({\n invocationId: nextInvocationId(),\n componentSourceId: metadata.componentSourceId,\n triggerCallsiteId: metadata.triggerCallsiteId,\n sourceVersion: metadata.sourceVersion,\n });\n },\n bindInvocation<Arguments extends readonly unknown[], Result>(\n token: DataFlowInvocationToken | undefined,\n callback: (...args: Arguments) => Result,\n ): (...args: Arguments) => Result {\n return function boundInvocation(this: unknown, ...args: Arguments): Result {\n return runtime.withInvocation(token, () => Reflect.apply(callback, this, args));\n };\n },\n bindTrigger<Callback>(\n metadata: DataFlowTriggerMetadata,\n callback: Callback,\n ): Callback {\n if (typeof callback !== \"function\") return callback;\n const callable = callback as (...args: readonly unknown[]) => unknown;\n return function boundTrigger(this: unknown, ...args: readonly unknown[]) {\n const token = runtime.beginInvocation(metadata);\n return runtime.withInvocation(token, () => Reflect.apply(callable, this, args));\n } as Callback;\n },\n captureInvocation: () => currentInvocation,\n clear: store.clear,\n createTrpcLink(): DataFlowTrpcLink {\n return () =>\n <Operation extends DataFlowTrpcOperation, Result>(\n options: DataFlowTrpcLinkOptions<Operation, Result>,\n ): Result => {\n recordWithoutAffectingHost(() => {\n const operation = options.op.path;\n const operationType = options.op.type;\n if (\n typeof operation !== \"string\" ||\n operation.length === 0 ||\n operation.length > 512 ||\n (operationType !== \"query\" &&\n operationType !== \"mutation\" &&\n operationType !== \"subscription\")\n ) {\n return;\n }\n const frame = currentRequestFrame;\n const token = frame?.invocationToken;\n store.add(\n Object.freeze({\n schemaVersion: DATA_FLOW_SCHEMA_VERSION,\n id: nextObservationId(),\n pageEpoch,\n routeEpoch,\n ...(frame === undefined\n ? {}\n : {\n requestCallsiteId: frame.requestCallsiteId,\n sourceVersion: frame.sourceVersion,\n }),\n ...(token === undefined\n ? {}\n : {\n invocationId: token.invocationId,\n componentSourceId: token.componentSourceId,\n triggerCallsiteId: token.triggerCallsiteId,\n }),\n transport: \"trpc\",\n method: operationType.toUpperCase(),\n operation,\n url: Object.freeze({\n pathname: operation,\n queryKeys: Object.freeze([]),\n }),\n outcome: \"dispatched\",\n freshness: \"current\",\n diagnosticIds: Object.freeze([]),\n }),\n );\n });\n return options.next(options.op);\n };\n },\n dispose(): void {\n if (disposed) return;\n disposed = true;\n store.clear();\n restoreFetch?.();\n restoreXhrOpen?.();\n restoreXhrSend?.();\n },\n getComponentRegistration: (component: object) => componentRegistry.get(component),\n getCurrentRequestFrame: () => currentRequestFrame,\n observations: () =>\n Object.freeze(\n store\n .values()\n .map((observation) =>\n observation.routeEpoch === routeEpoch\n ? observation\n : Object.freeze({ ...observation, freshness: \"stale-route\" as const }),\n ),\n ),\n registerComponent(\n component: object,\n componentSourceId: string,\n registeredSourceVersion: string,\n ): void {\n const registration = Object.freeze({\n componentSourceId,\n sourceVersion: registeredSourceVersion,\n });\n const pending = [component];\n const registered = new Set<object>();\n while (pending.length > 0) {\n const candidate = pending.pop();\n if (candidate === undefined || registered.has(candidate)) continue;\n registered.add(candidate);\n componentRegistry.set(candidate, registration);\n\n const nested = nestedReactWrapperComponent(candidate);\n if (nested !== undefined) pending.push(nested);\n }\n },\n updateRoute(nextRouteKey: string): void {\n if (routeKey === undefined) {\n routeKey = nextRouteKey;\n } else if (routeKey !== nextRouteKey) {\n routeKey = nextRouteKey;\n routeEpoch = nextRouteEpoch();\n }\n },\n withInvocation<Result>(\n token: DataFlowInvocationToken | undefined,\n callback: () => Result,\n ): Result {\n const parent = currentInvocation;\n currentInvocation = token;\n try {\n return callback();\n } finally {\n currentInvocation = parent;\n }\n },\n withRequestFrame<Result>(\n token: DataFlowInvocationToken | undefined,\n metadata: DataFlowRequestMetadata,\n callback: () => Result,\n ): Result {\n const parent = currentRequestFrame;\n currentRequestFrame = Object.freeze({\n requestCallsiteId: metadata.requestCallsiteId,\n sourceVersion: metadata.sourceVersion,\n ...(token === undefined ? {} : { invocationToken: token }),\n });\n try {\n return callback();\n } finally {\n currentRequestFrame = parent;\n }\n },\n });\n\n return runtime;\n}\n\nexport function installDataFlowPrelude(\n config: RuntimeDataFlowConfig,\n target: GlobalWithDataFlow = globalThis,\n): DataFlowRuntime | undefined {\n if (!config.enabled) return undefined;\n const runtime = target[RUNTIME_KEY] ?? createDataFlowRuntime(config, target);\n target[RUNTIME_KEY] = runtime;\n return runtime;\n}\n\nexport function getDataFlowRuntime(\n target: GlobalWithDataFlow = globalThis,\n): DataFlowRuntime | undefined {\n return target[RUNTIME_KEY];\n}\n","import {\n isSensitiveName,\n limitDataFlowReportCollections,\n type ComponentDataFlowReport,\n type DataDependency,\n type EvidenceRef,\n type NetworkObservation,\n type PageDataFlowReport,\n} from \"@spotpatch/shared\";\n\nfunction observationMatchesDependency(\n observation: NetworkObservation,\n dependency: DataDependency,\n): boolean {\n const origin = dependency.origin;\n const transportMatches =\n dependency.kind === \"rpc\"\n ? observation.transport === \"trpc\" &&\n dependency.operation !== undefined &&\n observation.operation === dependency.operation\n : dependency.kind === \"http\"\n ? observation.transport === \"fetch\" || observation.transport === \"xhr\"\n : false;\n if (\n !transportMatches ||\n observation.freshness !== \"current\" ||\n origin === undefined ||\n observation.requestCallsiteId !== origin.requestCallsiteId ||\n observation.sourceVersion !== origin.sourceVersion ||\n (dependency.method !== undefined &&\n observation.method.toUpperCase() !== dependency.method.toUpperCase()) ||\n (dependency.url !== undefined &&\n observation.url.pathname !== dependency.url.pathname) ||\n (dependency.url?.origin !== undefined &&\n observation.url.origin !== dependency.url.origin) ||\n (origin.componentSourceId !== undefined &&\n observation.componentSourceId !== undefined &&\n observation.componentSourceId !== origin.componentSourceId) ||\n (origin.triggerCallsiteId !== undefined &&\n observation.triggerCallsiteId !== undefined &&\n observation.triggerCallsiteId !== origin.triggerCallsiteId)\n ) {\n return false;\n }\n\n return (\n dependency.association !== \"transitive\" ||\n (observation.componentSourceId === origin.componentSourceId &&\n observation.triggerCallsiteId === origin.triggerCallsiteId)\n );\n}\n\nfunction runtimeEvidence(observation: NetworkObservation): EvidenceRef {\n return Object.freeze({\n id: observation.id,\n kind: \"runtime-observation\",\n summaryKey: \"dataFlow.evidence.runtimeDispatch\",\n });\n}\n\nfunction mergeDependencies(\n dependencies: readonly DataDependency[],\n observations: readonly NetworkObservation[],\n): Readonly<{\n dependencies: readonly DataDependency[];\n matchedObservationIds: ReadonlySet<string>;\n}> {\n const matchedObservationIds = new Set<string>();\n const merged = dependencies.map((dependency) => {\n const matches = observations.filter((observation) =>\n observationMatchesDependency(observation, dependency),\n );\n for (const observation of matches) matchedObservationIds.add(observation.id);\n if (matches.length === 0) return dependency;\n const observedOrigins = [\n ...new Set(\n matches.flatMap(({ url }) => (url.origin === undefined ? [] : [url.origin])),\n ),\n ];\n const observedOrigin =\n observedOrigins.length === 1 ? observedOrigins[0] : undefined;\n return Object.freeze({\n ...dependency,\n ...(dependency.url === undefined ||\n dependency.url.origin !== undefined ||\n observedOrigin === undefined\n ? {}\n : {\n url: Object.freeze({\n ...dependency.url,\n origin: observedOrigin,\n }),\n }),\n execution: \"observed\" as const,\n observationIds: Object.freeze([\n ...new Set([...dependency.observationIds, ...matches.map(({ id }) => id)]),\n ]),\n evidenceIds: Object.freeze([\n ...new Set([...dependency.evidenceIds, ...matches.map(({ id }) => id)]),\n ]),\n });\n });\n return Object.freeze({\n dependencies: Object.freeze(merged),\n matchedObservationIds,\n });\n}\n\nfunction appendRuntimeEvidence(\n evidence: readonly EvidenceRef[],\n observations: readonly NetworkObservation[],\n matchedIds: ReadonlySet<string>,\n): readonly EvidenceRef[] {\n const existing = new Set(evidence.map(({ id }) => id));\n return Object.freeze([\n ...evidence,\n ...observations.flatMap((observation) =>\n matchedIds.has(observation.id) && !existing.has(observation.id)\n ? [runtimeEvidence(observation)]\n : [],\n ),\n ]);\n}\n\nexport function mergeComponentDataFlowReport(\n report: ComponentDataFlowReport,\n observations: readonly NetworkObservation[],\n): ComponentDataFlowReport {\n const componentObservations = observations.filter(\n (observation) =>\n observation.componentSourceId === undefined ||\n observation.componentSourceId === report.component.componentSourceId,\n );\n const merged = mergeDependencies(report.dependencies, componentObservations);\n return limitDataFlowReportCollections(\n Object.freeze({\n ...report,\n dependencies: merged.dependencies,\n evidence: appendRuntimeEvidence(\n report.evidence,\n componentObservations,\n merged.matchedObservationIds,\n ),\n }),\n { mode: \"observation\" },\n );\n}\n\nfunction unassignedDependency(observation: NetworkObservation): DataDependency {\n const isRpc = observation.transport === \"trpc\";\n return Object.freeze({\n id: observation.id,\n kind: isRpc ? \"rpc\" : \"http\",\n direction:\n observation.method === \"GET\" ||\n observation.method === \"HEAD\" ||\n observation.method === \"QUERY\" ||\n observation.method === \"SUBSCRIPTION\"\n ? \"read\"\n : \"write\",\n execution: \"observed\",\n proof: \"unavailable\",\n association: \"unassigned\",\n method: observation.method,\n ...(isRpc\n ? observation.operation === undefined\n ? {}\n : { operation: observation.operation }\n : { url: observation.url }),\n parameters: Object.freeze(\n (isRpc ? [] : observation.url.queryKeys).map((path) =>\n Object.freeze({\n path,\n position: \"query\" as const,\n sensitive: isSensitiveName(path),\n valueState: \"not-collected\" as const,\n evidenceIds: Object.freeze([observation.id]),\n }),\n ),\n ),\n response: Object.freeze({\n consumedFields: Object.freeze([]),\n }),\n suppliedBindings: Object.freeze([]),\n locationIds: Object.freeze([]),\n evidenceIds: Object.freeze([observation.id]),\n observationIds: Object.freeze([observation.id]),\n });\n}\n\nexport function mergePageDataFlowReport(\n report: PageDataFlowReport,\n observations: readonly NetworkObservation[],\n): PageDataFlowReport {\n const currentObservations = observations.filter(\n ({ freshness }) => freshness === \"current\",\n );\n const merged = mergeDependencies(report.dependencies, currentObservations);\n const unassigned = currentObservations\n .filter(({ id }) => !merged.matchedObservationIds.has(id))\n .map(unassignedDependency);\n const allObservationIds = new Set(currentObservations.map(({ id }) => id));\n return limitDataFlowReportCollections(\n Object.freeze({\n ...report,\n dependencies: Object.freeze([...merged.dependencies, ...unassigned]),\n evidence: appendRuntimeEvidence(\n report.evidence,\n currentObservations,\n allObservationIds,\n ),\n }),\n { mode: \"observation\" },\n );\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AA8GP,IAAM,cAA6B,uBAAO;AAAA,EACxC;AACF;AACA,IAAM,kBAAkB,uBAAO,IAAI,YAAY;AAC/C,IAAM,yBAAyB,uBAAO,IAAI,mBAAmB;AAK7D,SAAS,YAAY,QAAgC;AACnD,SAAO,OAAO,aAAa,IAAI,KA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C;AAAA,IAClC,CAAC;AAAA,IACD,kBAAkB,OAAO,OAAO,CAAC,CAAC;AAAA,IAClC,aAAa,OAAO,OAAO,CAAC,CAAC;AAAA,IAC7B,aAAa,OAAO,OAAO,CAAC,YAAY,EAAE,CAAC;AAAA,IAC3C,gBAAgB,OAAO,OAAO,CAAC,YAAY,EAAE,CAAC;AAAA,EAChD,CAAC;AACH;AAEO,SAAS,wBACd,QACA,cACoB;AACpB,QAAM,sBAAsB,aAAa;AAAA,IACvC,CAAC,EAAE,UAAU,MAAM,cAAc;AAAA,EACnC;AACA,QAAM,SAAS,kBAAkB,OAAO,cAAc,mBAAmB;AACzE,QAAM,aAAa,oBAChB,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,OAAO,sBAAsB,IAAI,EAAE,CAAC,EACxD,IAAI,oBAAoB;AAC3B,QAAM,oBAAoB,IAAI,IAAI,oBAAoB,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC;AACzE,SAAO;AAAA,IACL,OAAO,OAAO;AAAA,MACZ,GAAG;AAAA,MACH,cAAc,OAAO,OAAO,CAAC,GAAG,OAAO,cAAc,GAAG,UAAU,CAAC;AAAA,MACnE,UAAU;AAAA,QACR,OAAO;AAAA,QACP;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AAAA,IACD,EAAE,MAAM,cAAc;AAAA,EACxB;AACF;","names":[]}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/data-flow-panel-entry.ts
|
|
21
|
+
var data_flow_panel_entry_exports = {};
|
|
22
|
+
__export(data_flow_panel_entry_exports, {
|
|
23
|
+
createDataFlowPanel: () => createDataFlowPanel,
|
|
24
|
+
getDataFlowExtension: () => getDataFlowExtension,
|
|
25
|
+
registerDataFlowExtension: () => registerDataFlowExtension
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(data_flow_panel_entry_exports);
|
|
28
|
+
|
|
29
|
+
// src/ui/ui-constants.ts
|
|
30
|
+
var UI_MARKER_ATTRIBUTE = "data-spotpatch-ui";
|
|
31
|
+
var UI_Z_INDEX = Object.freeze({
|
|
32
|
+
highlight: 2147483646,
|
|
33
|
+
controls: 2147483647
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// src/ui/dom.ts
|
|
37
|
+
function createMarkedElement(document, tagName) {
|
|
38
|
+
const element = document.createElement(tagName);
|
|
39
|
+
element.setAttribute(UI_MARKER_ATTRIBUTE, "");
|
|
40
|
+
return element;
|
|
41
|
+
}
|
|
42
|
+
function createButton(document, label, className = "") {
|
|
43
|
+
const button = createMarkedElement(document, "button");
|
|
44
|
+
button.type = "button";
|
|
45
|
+
button.className = className;
|
|
46
|
+
button.textContent = label;
|
|
47
|
+
return button;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/ui/data-flow-panel.ts
|
|
51
|
+
var LABELS = Object.freeze({
|
|
52
|
+
"zh-CN": Object.freeze({
|
|
53
|
+
bindings: "\u6570\u636E\u53BB\u5411",
|
|
54
|
+
changes: "\u4FEE\u6539\u8BF4\u660E",
|
|
55
|
+
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",
|
|
56
|
+
componentTab: "\u6570\u636E\u94FE\u8DEF",
|
|
57
|
+
componentTitle: "\u7EC4\u4EF6\u6570\u636E\u94FE\u8DEF",
|
|
58
|
+
consumed: "\u8BFB\u53D6\u5B57\u6BB5",
|
|
59
|
+
declared: "\u4EE3\u7801\u58F0\u660E\uFF0C\u5C1A\u672A\u5728\u672C\u6B21\u9875\u9762\u4F1A\u8BDD\u4E2D\u89C2\u6D4B",
|
|
60
|
+
diagnostics: "\u8BCA\u65AD",
|
|
61
|
+
disabled: "\u6570\u636E\u94FE\u8DEF\u80FD\u529B\u672A\u542F\u7528\uFF0C\u8BF7\u5728\u63D2\u4EF6\u914D\u7F6E\u4E2D\u8BBE\u7F6E dataFlow: {}\u3002",
|
|
62
|
+
error: "\u6570\u636E\u94FE\u8DEF\u62A5\u544A\u52A0\u8F7D\u5931\u8D25",
|
|
63
|
+
evidence: "\u8BC1\u636E",
|
|
64
|
+
loading: "\u6B63\u5728\u5206\u6790\u6E90\u7801\u5E76\u5408\u5E76\u8FD0\u884C\u65F6\u8BC1\u636E\u2026",
|
|
65
|
+
logicalObserved: "\u672C\u6B21\u4F1A\u8BDD\u5DF2\u8FDB\u5165 tRPC \u8C03\u7528\u94FE",
|
|
66
|
+
noParameters: "\u672A\u63D0\u53D6\u5230\u53EF\u8BC1\u660E\u7684\u53C2\u6570\u952E",
|
|
67
|
+
observed: "\u672C\u6B21\u4F1A\u8BDD\u5DF2\u5B9E\u9645\u8BF7\u6C42",
|
|
68
|
+
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",
|
|
69
|
+
pageTab: "\u9875\u9762\u63A5\u53E3",
|
|
70
|
+
pageTitle: "\u9875\u9762\u63A5\u53E3",
|
|
71
|
+
parameters: "\u8BF7\u6C42\u53C2\u6570",
|
|
72
|
+
refresh: "\u5237\u65B0\u8BC1\u636E",
|
|
73
|
+
unknown: "\u672A\u77E5"
|
|
74
|
+
}),
|
|
75
|
+
"en-US": Object.freeze({
|
|
76
|
+
bindings: "Data destinations",
|
|
77
|
+
changes: "Changes",
|
|
78
|
+
componentEmpty: "No proven interface was found for this component. This does not prove that no request exists.",
|
|
79
|
+
componentTab: "Data flow",
|
|
80
|
+
componentTitle: "Component data flow",
|
|
81
|
+
consumed: "Consumed fields",
|
|
82
|
+
declared: "Declared in code, not observed in this page session",
|
|
83
|
+
diagnostics: "Diagnostics",
|
|
84
|
+
disabled: "Data flow is disabled. Set dataFlow: {} in the plugin options.",
|
|
85
|
+
error: "Failed to load the data-flow report",
|
|
86
|
+
evidence: "Evidence",
|
|
87
|
+
loading: "Analyzing source and merging runtime evidence\u2026",
|
|
88
|
+
logicalObserved: "Dispatched through the tRPC link in this session",
|
|
89
|
+
noParameters: "No proven parameter keys were extracted",
|
|
90
|
+
observed: "Actually requested in this session",
|
|
91
|
+
pageEmpty: "No static interface or runtime traffic is available for the selected page scope.",
|
|
92
|
+
pageTab: "Page APIs",
|
|
93
|
+
pageTitle: "Page interfaces",
|
|
94
|
+
parameters: "Request parameters",
|
|
95
|
+
refresh: "Refresh evidence",
|
|
96
|
+
unknown: "Unknown"
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
function badge(document, text, tone) {
|
|
100
|
+
const element = createMarkedElement(document, "span");
|
|
101
|
+
element.className = "spotpatch-data-flow-badge";
|
|
102
|
+
element.dataset.tone = tone;
|
|
103
|
+
element.textContent = text;
|
|
104
|
+
return element;
|
|
105
|
+
}
|
|
106
|
+
function detailRow(document, label, value) {
|
|
107
|
+
const row = createMarkedElement(document, "div");
|
|
108
|
+
row.className = "spotpatch-data-flow-detail";
|
|
109
|
+
const key = createMarkedElement(document, "span");
|
|
110
|
+
key.textContent = label;
|
|
111
|
+
const content = createMarkedElement(document, "code");
|
|
112
|
+
content.textContent = value;
|
|
113
|
+
row.append(key, content);
|
|
114
|
+
return row;
|
|
115
|
+
}
|
|
116
|
+
function renderDependency(document, dependency, labels) {
|
|
117
|
+
const card = createMarkedElement(document, "article");
|
|
118
|
+
card.className = "spotpatch-data-flow-card";
|
|
119
|
+
const header = createMarkedElement(document, "div");
|
|
120
|
+
header.className = "spotpatch-data-flow-card-head";
|
|
121
|
+
const endpoint = createMarkedElement(document, "div");
|
|
122
|
+
endpoint.className = "spotpatch-data-flow-endpoint";
|
|
123
|
+
const method = createMarkedElement(document, "strong");
|
|
124
|
+
method.textContent = dependency.method ?? labels.unknown;
|
|
125
|
+
const path = createMarkedElement(document, "code");
|
|
126
|
+
path.textContent = dependency.url === void 0 ? dependency.operation ?? labels.unknown : `${dependency.url.origin ?? ""}${dependency.url.pathname}`;
|
|
127
|
+
endpoint.append(method, path);
|
|
128
|
+
const states = createMarkedElement(document, "div");
|
|
129
|
+
states.className = "spotpatch-data-flow-badges";
|
|
130
|
+
states.append(
|
|
131
|
+
badge(
|
|
132
|
+
document,
|
|
133
|
+
dependency.execution === "observed" ? dependency.kind === "rpc" ? labels.logicalObserved : labels.observed : labels.declared,
|
|
134
|
+
dependency.execution === "observed" ? "success" : "neutral"
|
|
135
|
+
),
|
|
136
|
+
badge(
|
|
137
|
+
document,
|
|
138
|
+
dependency.proof,
|
|
139
|
+
dependency.proof === "proven" ? "proof" : "warning"
|
|
140
|
+
),
|
|
141
|
+
badge(document, dependency.association, "neutral")
|
|
142
|
+
);
|
|
143
|
+
header.append(endpoint, states);
|
|
144
|
+
const parameters = dependency.parameters.length === 0 ? labels.noParameters : dependency.parameters.map(
|
|
145
|
+
(parameter) => `${parameter.position}.${parameter.path}${parameter.type === void 0 ? "" : `: ${parameter.type}`}${parameter.sensitive ? " [sensitive]" : ""}${parameter.condition === void 0 ? "" : ` [when ${parameter.condition}]`}`
|
|
146
|
+
).join("\n");
|
|
147
|
+
const consumed = dependency.response.consumedFields.length === 0 ? labels.unknown : dependency.response.consumedFields.join(", ");
|
|
148
|
+
const bindings = dependency.suppliedBindings.length === 0 ? labels.unknown : dependency.suppliedBindings.join(", ");
|
|
149
|
+
const body = createMarkedElement(document, "div");
|
|
150
|
+
body.className = "spotpatch-data-flow-card-body";
|
|
151
|
+
const observationIds = new Set(dependency.observationIds);
|
|
152
|
+
const staticEvidenceCount = dependency.evidenceIds.filter(
|
|
153
|
+
(id) => !observationIds.has(id)
|
|
154
|
+
).length;
|
|
155
|
+
body.append(
|
|
156
|
+
detailRow(document, labels.parameters, parameters),
|
|
157
|
+
detailRow(document, labels.consumed, consumed),
|
|
158
|
+
detailRow(document, labels.bindings, bindings),
|
|
159
|
+
detailRow(
|
|
160
|
+
document,
|
|
161
|
+
labels.evidence,
|
|
162
|
+
`${String(staticEvidenceCount)} static \xB7 ${String(dependency.observationIds.length)} runtime`
|
|
163
|
+
)
|
|
164
|
+
);
|
|
165
|
+
card.append(header, body);
|
|
166
|
+
return card;
|
|
167
|
+
}
|
|
168
|
+
function createReportRoot(document, titleText) {
|
|
169
|
+
const root = createMarkedElement(document, "section");
|
|
170
|
+
root.className = "spotpatch-data-flow-panel";
|
|
171
|
+
const title = createMarkedElement(document, "h3");
|
|
172
|
+
title.textContent = titleText;
|
|
173
|
+
const status = createMarkedElement(document, "p");
|
|
174
|
+
status.className = "spotpatch-data-flow-status";
|
|
175
|
+
const list = createMarkedElement(document, "div");
|
|
176
|
+
list.className = "spotpatch-data-flow-list";
|
|
177
|
+
root.append(title, status, list);
|
|
178
|
+
return Object.freeze({ root, status, list });
|
|
179
|
+
}
|
|
180
|
+
function createDataFlowPanel(document, enabled, locale, changesRoot, diagnosticsRoot, onViewChange) {
|
|
181
|
+
let labels = LABELS[locale()];
|
|
182
|
+
const component = createReportRoot(document, labels.componentTitle);
|
|
183
|
+
const page = createReportRoot(document, labels.pageTitle);
|
|
184
|
+
const refreshButton = createButton(document, labels.refresh);
|
|
185
|
+
const styles = document.createElement("style");
|
|
186
|
+
styles.textContent = DATA_FLOW_PANEL_STYLES;
|
|
187
|
+
refreshButton.classList.add("spotpatch-data-flow-refresh");
|
|
188
|
+
component.root.prepend(refreshButton);
|
|
189
|
+
const root = createMarkedElement(document, "div");
|
|
190
|
+
const tabs = createMarkedElement(document, "nav");
|
|
191
|
+
tabs.className = "spotpatch-view-tabs";
|
|
192
|
+
tabs.setAttribute("aria-label", "SpotPatch views");
|
|
193
|
+
tabs.setAttribute("role", "tablist");
|
|
194
|
+
const views = /* @__PURE__ */ new Map([
|
|
195
|
+
["changes", changesRoot],
|
|
196
|
+
["component-data", component.root],
|
|
197
|
+
["page-data", page.root],
|
|
198
|
+
["diagnostics", diagnosticsRoot]
|
|
199
|
+
]);
|
|
200
|
+
const tabButtons = /* @__PURE__ */ new Map();
|
|
201
|
+
let activeView = "changes";
|
|
202
|
+
for (const id of views.keys()) {
|
|
203
|
+
const button = createButton(document, "");
|
|
204
|
+
button.dataset.viewId = id;
|
|
205
|
+
button.id = `spotpatch-view-${id}-tab`;
|
|
206
|
+
button.setAttribute("role", "tab");
|
|
207
|
+
button.setAttribute("aria-selected", String(id === activeView));
|
|
208
|
+
const view = views.get(id);
|
|
209
|
+
view?.setAttribute("aria-labelledby", button.id);
|
|
210
|
+
view?.setAttribute("role", "tabpanel");
|
|
211
|
+
if (!enabled && (id === "component-data" || id === "page-data")) {
|
|
212
|
+
button.hidden = true;
|
|
213
|
+
}
|
|
214
|
+
tabButtons.set(id, button);
|
|
215
|
+
tabs.append(button);
|
|
216
|
+
}
|
|
217
|
+
root.append(tabs, ...views.values());
|
|
218
|
+
function selectView(viewId) {
|
|
219
|
+
if (!views.has(viewId)) return;
|
|
220
|
+
activeView = viewId;
|
|
221
|
+
for (const [id, view] of views) {
|
|
222
|
+
view.hidden = id !== viewId;
|
|
223
|
+
const button = tabButtons.get(id);
|
|
224
|
+
button?.setAttribute("aria-selected", String(id === viewId));
|
|
225
|
+
if (button !== void 0) button.tabIndex = id === viewId ? 0 : -1;
|
|
226
|
+
}
|
|
227
|
+
onViewChange();
|
|
228
|
+
}
|
|
229
|
+
function handleTabClick(event) {
|
|
230
|
+
if (!(event.target instanceof HTMLButtonElement)) return;
|
|
231
|
+
const viewId = event.target.dataset.viewId;
|
|
232
|
+
if (viewId !== void 0) selectView(viewId);
|
|
233
|
+
}
|
|
234
|
+
tabs.addEventListener("click", handleTabClick);
|
|
235
|
+
selectView(activeView);
|
|
236
|
+
function renderSnapshot(target, snapshot, empty) {
|
|
237
|
+
target.list.replaceChildren();
|
|
238
|
+
target.status.dataset.state = snapshot.status;
|
|
239
|
+
if (!enabled || snapshot.status === "disabled") {
|
|
240
|
+
target.status.textContent = labels.disabled;
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (snapshot.status === "loading") {
|
|
244
|
+
target.status.textContent = labels.loading;
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (snapshot.status === "error") {
|
|
248
|
+
target.status.textContent = snapshot.message ?? labels.error;
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const report = snapshot.report;
|
|
252
|
+
const diagnosticCodes = report === void 0 ? "" : [...new Set(report.diagnostics.map(({ code }) => code))].join(", ");
|
|
253
|
+
const diagnosticSuffix = diagnosticCodes.length === 0 ? "" : ` \xB7 ${labels.diagnostics}: ${diagnosticCodes}`;
|
|
254
|
+
if (report === void 0 || report.dependencies.length === 0) {
|
|
255
|
+
target.status.textContent = `${empty}${diagnosticSuffix}`;
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
target.status.textContent = `${String(report.dependencies.length)} \xB7 ${report.completeness.complete ? "complete" : "partial"}${diagnosticSuffix}`;
|
|
259
|
+
target.list.append(
|
|
260
|
+
...report.dependencies.map(
|
|
261
|
+
(dependency) => renderDependency(document, dependency, labels)
|
|
262
|
+
)
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
return Object.freeze({
|
|
266
|
+
root,
|
|
267
|
+
refreshButton,
|
|
268
|
+
styles,
|
|
269
|
+
dispose() {
|
|
270
|
+
tabs.removeEventListener("click", handleTabClick);
|
|
271
|
+
},
|
|
272
|
+
render(state) {
|
|
273
|
+
labels = LABELS[locale()];
|
|
274
|
+
const tabLabels = [
|
|
275
|
+
labels.changes,
|
|
276
|
+
labels.componentTab,
|
|
277
|
+
labels.pageTab,
|
|
278
|
+
labels.diagnostics
|
|
279
|
+
];
|
|
280
|
+
[...tabButtons.values()].forEach((button, index) => {
|
|
281
|
+
button.textContent = tabLabels[index] ?? "";
|
|
282
|
+
});
|
|
283
|
+
refreshButton.textContent = `${labels.refresh} \xB7 ${String(state.observationCount)}`;
|
|
284
|
+
refreshButton.disabled = !enabled || state.component.status === "loading";
|
|
285
|
+
renderSnapshot(component, state.component, labels.componentEmpty);
|
|
286
|
+
renderSnapshot(page, state.page, labels.pageEmpty);
|
|
287
|
+
},
|
|
288
|
+
resetView() {
|
|
289
|
+
selectView("changes");
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
var DATA_FLOW_PANEL_STYLES = `
|
|
294
|
+
.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%); }
|
|
295
|
+
.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; }
|
|
296
|
+
.spotpatch-view-tabs button[aria-selected="true"] { color: #f8fafc; background: rgb(139 124 247 / 18%); }
|
|
297
|
+
.spotpatch-data-flow-panel { position: relative; }
|
|
298
|
+
.spotpatch-data-flow-panel > h3 { margin: 0 0 3px; color: #f3f4f6; font-size: 13px; }
|
|
299
|
+
.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; }
|
|
300
|
+
.spotpatch-data-flow-refresh:disabled { cursor: not-allowed; opacity: .45; }
|
|
301
|
+
.spotpatch-data-flow-status { margin: 0 0 10px; color: var(--spotpatch-text-muted); font-size: 10.5px; line-height: 1.5; }
|
|
302
|
+
.spotpatch-data-flow-list { display: grid; gap: 8px; }
|
|
303
|
+
.spotpatch-data-flow-card { overflow: hidden; border: 1px solid rgb(255 255 255 / 8%); border-radius: 9px; background: rgb(255 255 255 / 2.5%); }
|
|
304
|
+
.spotpatch-data-flow-card-head { display: grid; gap: 7px; padding: 10px; border-bottom: 1px solid rgb(255 255 255 / 7%); }
|
|
305
|
+
.spotpatch-data-flow-endpoint { display: flex; min-width: 0; align-items: center; gap: 8px; }
|
|
306
|
+
.spotpatch-data-flow-endpoint strong { color: #79d9e7; font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
|
|
307
|
+
.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; }
|
|
308
|
+
.spotpatch-data-flow-badges { display: flex; flex-wrap: wrap; gap: 4px; }
|
|
309
|
+
.spotpatch-data-flow-badge { border-radius: 999px; padding: 2px 6px; color: #9ca3af; background: rgb(255 255 255 / 5%); font-size: 9px; }
|
|
310
|
+
.spotpatch-data-flow-badge[data-tone="success"] { color: #6ee7b7; background: rgb(16 185 129 / 10%); }
|
|
311
|
+
.spotpatch-data-flow-badge[data-tone="proof"] { color: #c4b5fd; background: rgb(139 92 246 / 11%); }
|
|
312
|
+
.spotpatch-data-flow-badge[data-tone="warning"] { color: #fcd34d; background: rgb(245 158 11 / 10%); }
|
|
313
|
+
.spotpatch-data-flow-card-body { display: grid; gap: 7px; padding: 10px; }
|
|
314
|
+
.spotpatch-data-flow-detail { display: grid; grid-template-columns: 82px minmax(0, 1fr); gap: 8px; align-items: start; }
|
|
315
|
+
.spotpatch-data-flow-detail > span { color: var(--spotpatch-text-muted); font-size: 10px; }
|
|
316
|
+
.spotpatch-data-flow-detail > code { overflow-wrap: anywhere; color: #cbd5e1; font: 10px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; }
|
|
317
|
+
`;
|
|
318
|
+
|
|
319
|
+
// src/ui/data-flow-panel-contract.ts
|
|
320
|
+
var DATA_FLOW_EXTENSION_KEY = /* @__PURE__ */ Symbol.for("spotpatch.data-flow.extension.v1");
|
|
321
|
+
function registerDataFlowExtension(extension, target = globalThis) {
|
|
322
|
+
target[DATA_FLOW_EXTENSION_KEY] = extension;
|
|
323
|
+
}
|
|
324
|
+
function getDataFlowExtension(target = globalThis) {
|
|
325
|
+
return target[DATA_FLOW_EXTENSION_KEY];
|
|
326
|
+
}
|
|
327
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
328
|
+
0 && (module.exports = {
|
|
329
|
+
createDataFlowPanel,
|
|
330
|
+
getDataFlowExtension,
|
|
331
|
+
registerDataFlowExtension
|
|
332
|
+
});
|
|
333
|
+
//# sourceMappingURL=data-flow-panel.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/data-flow-panel-entry.ts","../src/ui/ui-constants.ts","../src/ui/dom.ts","../src/ui/data-flow-panel.ts","../src/ui/data-flow-panel-contract.ts"],"sourcesContent":["export { createDataFlowPanel } from \"./ui/data-flow-panel.js\";\nexport {\n getDataFlowExtension,\n registerDataFlowExtension,\n type DataFlowExtension,\n type DataFlowPanel,\n type DataFlowPanelFactory,\n type DataFlowPanelSnapshot,\n type DataFlowPanelStatus,\n type DataFlowViewState,\n} from \"./ui/data-flow-panel-contract.js\";\n","export const UI_MARKER_ATTRIBUTE = \"data-spotpatch-ui\" as const;\n\nexport const UI_Z_INDEX = Object.freeze({\n highlight: 2_147_483_646,\n controls: 2_147_483_647,\n});\n","import { UI_MARKER_ATTRIBUTE } from \"./ui-constants.js\";\n\nexport function createMarkedElement<K extends keyof HTMLElementTagNameMap>(\n document: Document,\n tagName: K,\n): HTMLElementTagNameMap[K] {\n const element = document.createElement(tagName);\n element.setAttribute(UI_MARKER_ATTRIBUTE, \"\");\n return element;\n}\n\nexport function createButton(\n document: Document,\n label: string,\n className = \"\",\n): HTMLButtonElement {\n const button = createMarkedElement(document, \"button\");\n button.type = \"button\";\n button.className = className;\n button.textContent = label;\n return button;\n}\n","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","import type {\n ComponentDataFlowReport,\n NetworkObservation,\n PageDataFlowReport,\n SpotPatchLocale,\n} from \"@spotpatch/shared\";\n\nimport type { DataFlowComponentRegistration } from \"../data-flow/data-flow-runtime.js\";\n\nexport type DataFlowPanelStatus = \"disabled\" | \"idle\" | \"loading\" | \"ready\" | \"error\";\n\nexport interface DataFlowPanelSnapshot {\n readonly status: DataFlowPanelStatus;\n readonly report?: ComponentDataFlowReport | PageDataFlowReport;\n readonly message?: string;\n}\n\nexport interface DataFlowViewState {\n readonly component: DataFlowPanelSnapshot;\n readonly page: DataFlowPanelSnapshot;\n readonly observationCount: number;\n}\n\nexport interface DataFlowPanel {\n readonly root: HTMLElement;\n readonly refreshButton: HTMLButtonElement;\n readonly styles: HTMLStyleElement;\n readonly dispose: () => void;\n readonly render: (state: DataFlowViewState) => void;\n readonly resetView: () => void;\n}\n\nexport type DataFlowPanelFactory = (\n document: Document,\n enabled: boolean,\n locale: () => SpotPatchLocale,\n changesRoot: HTMLElement,\n diagnosticsRoot: HTMLElement,\n onViewChange: () => void,\n) => DataFlowPanel;\n\nexport interface DataFlowExtension {\n readonly createPanel: DataFlowPanelFactory;\n readonly getComponentRegistration: (\n component: object,\n ) => DataFlowComponentRegistration | undefined;\n readonly observations: (routeKey: string) => readonly NetworkObservation[];\n readonly mergeComponentReport: (\n report: ComponentDataFlowReport,\n observations: readonly NetworkObservation[],\n ) => ComponentDataFlowReport;\n readonly mergePageReport: (\n report: PageDataFlowReport,\n observations: readonly NetworkObservation[],\n ) => PageDataFlowReport;\n}\n\nconst DATA_FLOW_EXTENSION_KEY = Symbol.for(\"spotpatch.data-flow.extension.v1\");\ntype ExtensionStore = Partial<Record<symbol, DataFlowExtension>>;\n\nexport function registerDataFlowExtension(\n extension: DataFlowExtension,\n target: ExtensionStore = globalThis,\n): void {\n target[DATA_FLOW_EXTENSION_KEY] = extension;\n}\n\nexport function getDataFlowExtension(\n target: ExtensionStore = globalThis,\n): DataFlowExtension | undefined {\n return target[DATA_FLOW_EXTENSION_KEY];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAO,IAAM,sBAAsB;AAE5B,IAAM,aAAa,OAAO,OAAO;AAAA,EACtC,WAAW;AAAA,EACX,UAAU;AACZ,CAAC;;;ACHM,SAAS,oBACd,UACA,SAC0B;AAC1B,QAAM,UAAU,SAAS,cAAc,OAAO;AAC9C,UAAQ,aAAa,qBAAqB,EAAE;AAC5C,SAAO;AACT;AAEO,SAAS,aACd,UACA,OACA,YAAY,IACO;AACnB,QAAM,SAAS,oBAAoB,UAAU,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port, NetworkObservation } from '@spotpatch/shared';
|
|
2
|
+
import { D as DataFlowComponentRegistration } from './data-flow-runtime-B3itbieT.cjs';
|
|
3
|
+
import '@spotpatch/shared/data-flow-runtime';
|
|
4
|
+
|
|
5
|
+
type DataFlowPanelStatus = "disabled" | "idle" | "loading" | "ready" | "error";
|
|
6
|
+
interface DataFlowPanelSnapshot {
|
|
7
|
+
readonly status: DataFlowPanelStatus;
|
|
8
|
+
readonly report?: ComponentDataFlowReport | PageDataFlowReport;
|
|
9
|
+
readonly message?: string;
|
|
10
|
+
}
|
|
11
|
+
interface DataFlowViewState {
|
|
12
|
+
readonly component: DataFlowPanelSnapshot;
|
|
13
|
+
readonly page: DataFlowPanelSnapshot;
|
|
14
|
+
readonly observationCount: number;
|
|
15
|
+
}
|
|
16
|
+
interface DataFlowPanel {
|
|
17
|
+
readonly root: HTMLElement;
|
|
18
|
+
readonly refreshButton: HTMLButtonElement;
|
|
19
|
+
readonly styles: HTMLStyleElement;
|
|
20
|
+
readonly dispose: () => void;
|
|
21
|
+
readonly render: (state: DataFlowViewState) => void;
|
|
22
|
+
readonly resetView: () => void;
|
|
23
|
+
}
|
|
24
|
+
type DataFlowPanelFactory = (document: Document, enabled: boolean, locale: () => SpotPatchLocale, changesRoot: HTMLElement, diagnosticsRoot: HTMLElement, onViewChange: () => void) => DataFlowPanel;
|
|
25
|
+
interface DataFlowExtension {
|
|
26
|
+
readonly createPanel: DataFlowPanelFactory;
|
|
27
|
+
readonly getComponentRegistration: (component: object) => DataFlowComponentRegistration | undefined;
|
|
28
|
+
readonly observations: (routeKey: string) => readonly NetworkObservation[];
|
|
29
|
+
readonly mergeComponentReport: (report: ComponentDataFlowReport, observations: readonly NetworkObservation[]) => ComponentDataFlowReport;
|
|
30
|
+
readonly mergePageReport: (report: PageDataFlowReport, observations: readonly NetworkObservation[]) => PageDataFlowReport;
|
|
31
|
+
}
|
|
32
|
+
type ExtensionStore = Partial<Record<symbol, DataFlowExtension>>;
|
|
33
|
+
declare function registerDataFlowExtension(extension: DataFlowExtension, target?: ExtensionStore): void;
|
|
34
|
+
declare function getDataFlowExtension(target?: ExtensionStore): DataFlowExtension | undefined;
|
|
35
|
+
|
|
36
|
+
declare function createDataFlowPanel(document: Document, enabled: boolean, locale: () => SpotPatchLocale, changesRoot: HTMLElement, diagnosticsRoot: HTMLElement, onViewChange: () => void): DataFlowPanel;
|
|
37
|
+
|
|
38
|
+
export { type DataFlowExtension, type DataFlowPanel, type DataFlowPanelFactory, type DataFlowPanelSnapshot, type DataFlowPanelStatus, type DataFlowViewState, createDataFlowPanel, getDataFlowExtension, registerDataFlowExtension };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SpotPatchLocale, ComponentDataFlowReport, PageDataFlowReport, NetworkObservation } from '@spotpatch/shared';
|
|
2
|
+
import { D as DataFlowComponentRegistration } from './data-flow-runtime-B3itbieT.js';
|
|
3
|
+
import '@spotpatch/shared/data-flow-runtime';
|
|
4
|
+
|
|
5
|
+
type DataFlowPanelStatus = "disabled" | "idle" | "loading" | "ready" | "error";
|
|
6
|
+
interface DataFlowPanelSnapshot {
|
|
7
|
+
readonly status: DataFlowPanelStatus;
|
|
8
|
+
readonly report?: ComponentDataFlowReport | PageDataFlowReport;
|
|
9
|
+
readonly message?: string;
|
|
10
|
+
}
|
|
11
|
+
interface DataFlowViewState {
|
|
12
|
+
readonly component: DataFlowPanelSnapshot;
|
|
13
|
+
readonly page: DataFlowPanelSnapshot;
|
|
14
|
+
readonly observationCount: number;
|
|
15
|
+
}
|
|
16
|
+
interface DataFlowPanel {
|
|
17
|
+
readonly root: HTMLElement;
|
|
18
|
+
readonly refreshButton: HTMLButtonElement;
|
|
19
|
+
readonly styles: HTMLStyleElement;
|
|
20
|
+
readonly dispose: () => void;
|
|
21
|
+
readonly render: (state: DataFlowViewState) => void;
|
|
22
|
+
readonly resetView: () => void;
|
|
23
|
+
}
|
|
24
|
+
type DataFlowPanelFactory = (document: Document, enabled: boolean, locale: () => SpotPatchLocale, changesRoot: HTMLElement, diagnosticsRoot: HTMLElement, onViewChange: () => void) => DataFlowPanel;
|
|
25
|
+
interface DataFlowExtension {
|
|
26
|
+
readonly createPanel: DataFlowPanelFactory;
|
|
27
|
+
readonly getComponentRegistration: (component: object) => DataFlowComponentRegistration | undefined;
|
|
28
|
+
readonly observations: (routeKey: string) => readonly NetworkObservation[];
|
|
29
|
+
readonly mergeComponentReport: (report: ComponentDataFlowReport, observations: readonly NetworkObservation[]) => ComponentDataFlowReport;
|
|
30
|
+
readonly mergePageReport: (report: PageDataFlowReport, observations: readonly NetworkObservation[]) => PageDataFlowReport;
|
|
31
|
+
}
|
|
32
|
+
type ExtensionStore = Partial<Record<symbol, DataFlowExtension>>;
|
|
33
|
+
declare function registerDataFlowExtension(extension: DataFlowExtension, target?: ExtensionStore): void;
|
|
34
|
+
declare function getDataFlowExtension(target?: ExtensionStore): DataFlowExtension | undefined;
|
|
35
|
+
|
|
36
|
+
declare function createDataFlowPanel(document: Document, enabled: boolean, locale: () => SpotPatchLocale, changesRoot: HTMLElement, diagnosticsRoot: HTMLElement, onViewChange: () => void): DataFlowPanel;
|
|
37
|
+
|
|
38
|
+
export { type DataFlowExtension, type DataFlowPanel, type DataFlowPanelFactory, type DataFlowPanelSnapshot, type DataFlowPanelStatus, type DataFlowViewState, createDataFlowPanel, getDataFlowExtension, registerDataFlowExtension };
|