// Copyright 2023 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. import * as i18n from '../../../../core/i18n/i18n.js'; import * as SDK from '../../../../core/sdk/sdk.js'; import type * as Protocol from '../../../../generated/protocol.js'; import * as Formatter from '../../../../models/formatter/formatter.js'; import * as CodeMirror from '../../../../third_party/codemirror.next/codemirror.next.js'; import * as CodeHighlighter from '../../../../ui/components/code_highlighter/code_highlighter.js'; import * as TextEditor from '../../../../ui/components/text_editor/text_editor.js'; import * as UI from '../../../../ui/legacy/legacy.js'; import {html, nothing, render} from '../../../../ui/lit/lit.js'; import ruleSetDetailsViewStyles from './RuleSetDetailsView.css.js'; const UIStrings = { /** * @description Text in RuleSetDetailsView of the Application panel if no element is selected. An element here is an item in a * table of speculation rules. Speculation rules define the rules when and which urls should be prefetched. * https://developer.chrome.com/docs/devtools/application/debugging-speculation-rules */ noElementSelected: 'No element selected', /** * @description Text in RuleSetDetailsView of the Application panel if no element is selected. An element here is an item in a * table of speculation rules. Speculation rules define the rules when and which urls should be prefetched. * https://developer.chrome.com/docs/devtools/application/debugging-speculation-rules */ selectAnElementForMoreDetails: 'Select an element for more details', } as const; const str_ = i18n.i18n.registerUIStrings('panels/application/preloading/components/RuleSetDetailsView.ts', UIStrings); const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_); type RuleSet = Protocol.Preload.RuleSet; const codeMirrorJsonType = await CodeHighlighter.CodeHighlighter.languageFromMIME('application/json'); export interface ViewInput { url: string; errorMessage?: string; editorState: CodeMirror.EditorState; sourceText: string; } export const DEFAULT_VIEW = (input: ViewInput|null, _output: object, target: HTMLElement): void => { // clang-format off render(html` ${input ? html`