diff --git a/packages/app/src/components/workbench.ts b/packages/app/src/components/workbench.ts index 19bb870..f8c390f 100644 --- a/packages/app/src/components/workbench.ts +++ b/packages/app/src/components/workbench.ts @@ -142,7 +142,7 @@ export class DevtoolsWorkbench extends Element { ${!this.#toolbarCollapsed ? this.#dragVertical.getSlider('z-[999] -mt-[5px] pointer-events-auto') : nothing} - + diff --git a/packages/app/src/components/workbench/logs.ts b/packages/app/src/components/workbench/logs.ts index 945f2db..aa483e2 100644 --- a/packages/app/src/components/workbench/logs.ts +++ b/packages/app/src/components/workbench/logs.ts @@ -30,7 +30,6 @@ export class DevtoolsSource extends Element { connectedCallback(): void { super.connectedCallback() window.addEventListener('show-command', async (ev: CustomEvent) => { - this.closest('wdio-devtools-tabs')?.activateTab('Log') const command = ev.detail.command this.elapsedTime = ev.detail.elapsedTime @@ -49,6 +48,11 @@ export class DevtoolsSource extends Element { }, {} as Record) this.#commandDefinition = endpoints[command.command] this.command = command + + window.dispatchEvent(new CustomEvent('app-source-highlight', { + detail: this.command?.callSource + })) + this.closest('wdio-devtools-tabs')?.activateTab('Log') }) } diff --git a/packages/app/src/components/workbench/source.ts b/packages/app/src/components/workbench/source.ts index 457cdcf..78dd53e 100644 --- a/packages/app/src/components/workbench/source.ts +++ b/packages/app/src/components/workbench/source.ts @@ -41,19 +41,12 @@ export class DevtoolsSource extends Element { } #renderEditor (filePath: string, highlightLine?: number) { - if (!this.sources) { - return - } - + if (!this.sources) return const source = this.sources[filePath] - if (!source) { - return - } + if (!source) return const container = this.shadowRoot?.querySelector('section') || this.shadowRoot?.querySelector('.cm-editor') - if (!container) { - return - } + if (!container) return const opts: EditorViewConfig = { root: this.shadowRoot!, @@ -64,14 +57,13 @@ export class DevtoolsSource extends Element { const editorView = new EditorView(opts) container.replaceWith(editorView.dom) - // Use CodeMirror API to select and scroll to the target line (1-based index) if (highlightLine && highlightLine > 0) { try { - const lineInfo = editorView.state.doc.line(highlightLine) // 1-based + const lineInfo = editorView.state.doc.line(highlightLine) requestAnimationFrame(() => { editorView.dispatch({ selection: { anchor: lineInfo.from }, - effects: EditorView.scrollIntoView(lineInfo.from, { y: 'center' }) // center the line + effects: EditorView.scrollIntoView(lineInfo.from, { y: 'center' }) }) }) } catch { /* ignore */ } diff --git a/packages/app/src/controller/DataManager.ts b/packages/app/src/controller/DataManager.ts index 2e611c2..541eab2 100644 --- a/packages/app/src/controller/DataManager.ts +++ b/packages/app/src/controller/DataManager.ts @@ -141,6 +141,14 @@ export class DataManagerController implements ReactiveController { ...this.consoleLogsContextProvider.value, ...data as string[] ]) + } + else if (scope === 'sources') { + const merged = { + ...(this.sourcesContextProvider.value || {}), + ...(data as Record) + } + this.sourcesContextProvider.setValue(merged) + console.debug('Merged sources keys', Object.keys(merged)) } else { const provider = this[`${scope}ContextProvider`] provider.setValue(data as any)