chrome-devtools-frontend 1.0.1541552 → 1.0.1543082

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.
Files changed (66) hide show
  1. package/docs/get_the_code.md +9 -0
  2. package/front_end/Tests.js +1 -0
  3. package/front_end/core/common/Settings.ts +38 -15
  4. package/front_end/core/host/InspectorFrontendHost.ts +0 -3
  5. package/front_end/core/host/UserMetrics.ts +5 -0
  6. package/front_end/core/root/Runtime.ts +0 -10
  7. package/front_end/core/sdk/IOModel.ts +1 -4
  8. package/front_end/core/sdk/NetworkManager.ts +0 -7
  9. package/front_end/core/sdk/NetworkRequest.ts +0 -10
  10. package/front_end/core/sdk/ServerSentEventsProtocol.ts +4 -0
  11. package/front_end/entrypoints/inspector_main/RenderingOptions.ts +5 -5
  12. package/front_end/entrypoints/main/MainImpl.ts +6 -3
  13. package/front_end/entrypoints/main/main-meta.ts +1 -5
  14. package/front_end/foundation/Universe.ts +2 -10
  15. package/front_end/generated/Deprecation.ts +0 -14
  16. package/front_end/generated/InspectorBackendCommands.ts +1 -1
  17. package/front_end/generated/SupportedCSSProperties.js +42 -42
  18. package/front_end/generated/protocol.ts +0 -1
  19. package/front_end/models/ai_assistance/BuiltInAi.ts +13 -7
  20. package/front_end/models/ai_code_completion/AiCodeCompletion.ts +72 -31
  21. package/front_end/models/bindings/CompilerScriptMapping.ts +3 -2
  22. package/front_end/models/bindings/DebuggerWorkspaceBinding.ts +3 -1
  23. package/front_end/models/har/Importer.ts +14 -0
  24. package/front_end/models/issues_manager/IssuesManager.ts +0 -5
  25. package/front_end/models/javascript_metadata/NativeFunctions.js +0 -4
  26. package/front_end/models/trace/handlers/ScriptsHandler.ts +26 -0
  27. package/front_end/models/trace/types/TraceEvents.ts +1 -1
  28. package/front_end/panels/ai_assistance/AiAssistancePanel.ts +117 -103
  29. package/front_end/panels/ai_assistance/components/ChatView.ts +7 -31
  30. package/front_end/panels/ai_assistance/components/chatView.css +1 -1
  31. package/front_end/panels/application/components/BackForwardCacheView.ts +12 -9
  32. package/front_end/panels/console/ConsoleInsightTeaser.ts +5 -0
  33. package/front_end/panels/console/ConsolePrompt.ts +9 -2
  34. package/front_end/panels/console/ConsoleView.ts +3 -0
  35. package/front_end/panels/network/NetworkDataGridNode.ts +0 -7
  36. package/front_end/panels/network/NetworkLogView.ts +1 -45
  37. package/front_end/panels/security/SecurityPanel.ts +0 -2
  38. package/front_end/panels/security/SecurityPanelSidebar.ts +0 -16
  39. package/front_end/panels/security/security.ts +0 -2
  40. package/front_end/panels/sources/AiCodeCompletionPlugin.ts +17 -1
  41. package/front_end/third_party/chromium/README.chromium +1 -1
  42. package/front_end/ui/components/expandable_list/ExpandableList.docs.ts +30 -0
  43. package/front_end/ui/components/markdown_view/MarkdownLinksMap.ts +0 -4
  44. package/front_end/ui/components/markdown_view/MarkdownView.docs.ts +95 -0
  45. package/front_end/ui/components/text_editor/AiCodeCompletionProvider.ts +246 -13
  46. package/front_end/ui/components/text_editor/config.ts +1 -1
  47. package/front_end/ui/legacy/Widget.ts +13 -4
  48. package/front_end/ui/legacy/components/utils/Linkifier.ts +45 -1
  49. package/front_end/ui/visual_logging/KnownContextValues.ts +11 -0
  50. package/package.json +1 -1
  51. package/front_end/models/issues_manager/UserReidentificationIssue.ts +0 -72
  52. package/front_end/models/issues_manager/descriptions/userReidentificationBlocked.md +0 -5
  53. package/front_end/panels/security/IPProtectionTreeElement.ts +0 -21
  54. package/front_end/panels/security/IPProtectionView.ts +0 -287
  55. package/front_end/ui/components/docs/expandable_list/basic.html +0 -24
  56. package/front_end/ui/components/docs/expandable_list/basic.ts +0 -30
  57. package/front_end/ui/components/docs/markdown_image/basic.html +0 -19
  58. package/front_end/ui/components/docs/markdown_image/basic.ts +0 -38
  59. package/front_end/ui/components/docs/markdown_link/basic.html +0 -17
  60. package/front_end/ui/components/docs/markdown_link/basic.ts +0 -19
  61. package/front_end/ui/components/docs/markdown_view/basic.html +0 -25
  62. package/front_end/ui/components/docs/markdown_view/basic.ts +0 -67
  63. package/front_end/ui/components/docs/markdown_view/code-block.html +0 -30
  64. package/front_end/ui/components/docs/markdown_view/code-block.ts +0 -71
  65. package/front_end/ui/components/docs/text_prompt/basic.html +0 -35
  66. package/front_end/ui/components/docs/text_prompt/basic.ts +0 -19
@@ -128,14 +128,6 @@ const UIStrings = {
128
128
  * @description Tooltip for a filter in the Network panel
129
129
  */
130
130
  onlyShowThirdPartyRequests: 'Show only requests with origin different from page origin',
131
- /**
132
- * @description Label for a filter in the Network panel
133
- */
134
- ippRequests: 'IP Protected requests',
135
- /**
136
- * @description Tooltip for a filter in the Network panel
137
- */
138
- onlyShowIPProtectedRequests: 'Show only requests sent to IP Protection proxies. Has no effect in regular browsing.',
139
131
  /**
140
132
  * @description Text that appears when user drag and drop something (for example, a file) in Network Log View of the Network panel
141
133
  */
@@ -530,7 +522,6 @@ export class NetworkLogView extends Common.ObjectWrapper.eventMixin<EventTypes,
530
522
  private readonly networkOnlyThirdPartySetting: Common.Settings.Setting<boolean>;
531
523
  private readonly networkResourceTypeFiltersSetting: Common.Settings.Setting<Record<string, boolean>>;
532
524
  private readonly networkShowOptionsToGenerateHarWithSensitiveData: Common.Settings.Setting<boolean>;
533
- private readonly networkOnlyIPProtectedRequestsSetting: Common.Settings.Setting<boolean>;
534
525
  private readonly progressBarContainer: Element;
535
526
  private readonly networkLogLargeRowsSetting: Common.Settings.Setting<boolean>;
536
527
  private rowHeightInternal: number;
@@ -586,8 +577,6 @@ export class NetworkLogView extends Common.ObjectWrapper.eventMixin<EventTypes,
586
577
  Common.Settings.Settings.instance().createSetting('network-only-blocked-requests', false);
587
578
  this.networkOnlyThirdPartySetting =
588
579
  Common.Settings.Settings.instance().createSetting('network-only-third-party-setting', false);
589
- this.networkOnlyIPProtectedRequestsSetting =
590
- Common.Settings.Settings.instance().createSetting('network-only-ip-protected-requests', false);
591
580
  this.networkResourceTypeFiltersSetting =
592
581
  Common.Settings.Settings.instance().createSetting('network-resource-type-filters', {});
593
582
  this.networkShowOptionsToGenerateHarWithSensitiveData = Common.Settings.Settings.instance().createSetting(
@@ -1603,7 +1592,6 @@ export class NetworkLogView extends Common.ObjectWrapper.eventMixin<EventTypes,
1603
1592
  this.networkOnlyBlockedRequestsSetting.set(false);
1604
1593
  this.networkOnlyThirdPartySetting.set(false);
1605
1594
  this.networkHideChromeExtensions.set(false);
1606
- this.networkOnlyIPProtectedRequestsSetting.set(false);
1607
1595
  this.resourceCategoryFilterUI.reset();
1608
1596
  }
1609
1597
 
@@ -2108,16 +2096,12 @@ export class NetworkLogView extends Common.ObjectWrapper.eventMixin<EventTypes,
2108
2096
  if (!this.resourceCategoryFilterUI.accept(categoryName)) {
2109
2097
  return false;
2110
2098
  }
2111
- const [hideDataURL, blockedCookies, blockedRequests, thirdParty, hideExtensionURL, ippRequests] = [
2099
+ const [hideDataURL, blockedCookies, blockedRequests, thirdParty, hideExtensionURL] = [
2112
2100
  this.networkHideDataURLSetting.get(),
2113
2101
  this.networkShowBlockedCookiesOnlySetting.get(),
2114
2102
  this.networkOnlyBlockedRequestsSetting.get(),
2115
2103
  this.networkOnlyThirdPartySetting.get(),
2116
2104
  this.networkHideChromeExtensions.get(),
2117
- // TODO(crbug.com/425645896): Remove this guard once IP Protection is fully launched.
2118
- Root.Runtime.hostConfig.devToolsIpProtectionInDevTools?.enabled ?
2119
- this.networkOnlyIPProtectedRequestsSetting.get() :
2120
- false,
2121
2105
  ];
2122
2106
 
2123
2107
  if (hideDataURL && (request.parsedURL.isDataURL() || request.parsedURL.isBlobURL())) {
@@ -2135,12 +2119,6 @@ export class NetworkLogView extends Common.ObjectWrapper.eventMixin<EventTypes,
2135
2119
  if (hideExtensionURL && request.scheme === 'chrome-extension') {
2136
2120
  return false;
2137
2121
  }
2138
- // TODO(crbug.com/425645896): Remove this guard once IP Protection is fully launched.
2139
- if (Root.Runtime.hostConfig.devToolsIpProtectionInDevTools?.enabled) {
2140
- if (ippRequests && !request.isIpProtectionUsed()) {
2141
- return false;
2142
- }
2143
- }
2144
2122
  for (let i = 0; i < this.filters.length; ++i) {
2145
2123
  if (!this.filters[i](request)) {
2146
2124
  return false;
@@ -2756,7 +2734,6 @@ export class MoreFiltersDropDownUI extends Common.ObjectWrapper.ObjectWrapper<UI
2756
2734
  private networkShowBlockedCookiesOnlySetting: Common.Settings.Setting<boolean>;
2757
2735
  private networkOnlyBlockedRequestsSetting: Common.Settings.Setting<boolean>;
2758
2736
  private networkOnlyThirdPartySetting: Common.Settings.Setting<boolean>;
2759
- private networkOnlyIPProtectedRequestsSetting: Common.Settings.Setting<boolean>;
2760
2737
  private activeFiltersCount: HTMLElement;
2761
2738
  private activeFiltersCountAdorner: Adorners.Adorner.Adorner;
2762
2739
 
@@ -2772,8 +2749,6 @@ export class MoreFiltersDropDownUI extends Common.ObjectWrapper.ObjectWrapper<UI
2772
2749
  Common.Settings.Settings.instance().createSetting('network-only-blocked-requests', false);
2773
2750
  this.networkOnlyThirdPartySetting =
2774
2751
  Common.Settings.Settings.instance().createSetting('network-only-third-party-setting', false);
2775
- this.networkOnlyIPProtectedRequestsSetting =
2776
- Common.Settings.Settings.instance().createSetting('network-only-ip-protected-requests', false);
2777
2752
 
2778
2753
  this.filterElement = document.createElement('div');
2779
2754
  this.filterElement.setAttribute('aria-label', 'Show only/hide requests dropdown');
@@ -2810,10 +2785,6 @@ export class MoreFiltersDropDownUI extends Common.ObjectWrapper.ObjectWrapper<UI
2810
2785
  this.networkShowBlockedCookiesOnlySetting.addChangeListener(this.#onSettingChanged.bind(this));
2811
2786
  this.networkOnlyBlockedRequestsSetting.addChangeListener(this.#onSettingChanged.bind(this));
2812
2787
  this.networkOnlyThirdPartySetting.addChangeListener(this.#onSettingChanged.bind(this));
2813
- // TODO(crbug.com/425645896): Remove this guard once IP Protection is fully launched.
2814
- if (Root.Runtime.hostConfig.devToolsIpProtectionInDevTools?.enabled) {
2815
- this.networkOnlyIPProtectedRequestsSetting.addChangeListener(this.#onSettingChanged.bind(this));
2816
- }
2817
2788
 
2818
2789
  contextMenu.defaultSection().appendCheckboxItem(
2819
2790
  i18nString(UIStrings.hideDataUrls),
@@ -2845,17 +2816,6 @@ export class MoreFiltersDropDownUI extends Common.ObjectWrapper.ObjectWrapper<UI
2845
2816
  tooltip: i18nString(UIStrings.onlyShowBlockedRequests),
2846
2817
  jslogContext: 'only-blocked-requests',
2847
2818
  });
2848
- // Disable this filter if in regular browsing, as IP Protection is only available in incognito mode.
2849
- // TODO(crbug.com/425645896): Remove this guard once IP Protection is fully launched.
2850
- if (Root.Runtime.hostConfig.devToolsIpProtectionInDevTools?.enabled) {
2851
- contextMenu.defaultSection().appendCheckboxItem(
2852
- i18nString(UIStrings.ippRequests),
2853
- () => this.networkOnlyIPProtectedRequestsSetting.set(!this.networkOnlyIPProtectedRequestsSetting.get()), {
2854
- checked: this.networkOnlyIPProtectedRequestsSetting.get(),
2855
- tooltip: i18nString(UIStrings.onlyShowIPProtectedRequests),
2856
- jslogContext: 'only-ip-protected-requests',
2857
- });
2858
- }
2859
2819
  contextMenu.defaultSection().appendCheckboxItem(
2860
2820
  i18nString(UIStrings.thirdParty),
2861
2821
  () => this.networkOnlyThirdPartySetting.set(!this.networkOnlyThirdPartySetting.get()), {
@@ -2872,10 +2832,6 @@ export class MoreFiltersDropDownUI extends Common.ObjectWrapper.ObjectWrapper<UI
2872
2832
  ...this.networkShowBlockedCookiesOnlySetting.get() ? [i18nString(UIStrings.hasBlockedCookies)] : [],
2873
2833
  ...this.networkOnlyBlockedRequestsSetting.get() ? [i18nString(UIStrings.blockedRequests)] : [],
2874
2834
  ...this.networkOnlyThirdPartySetting.get() ? [i18nString(UIStrings.thirdParty)] : [],
2875
- ...Root.Runtime.hostConfig.devToolsIpProtectionInDevTools?.enabled &&
2876
- this.networkOnlyIPProtectedRequestsSetting.get() ?
2877
- [i18nString(UIStrings.ippRequests)] :
2878
- [],
2879
2835
  ];
2880
2836
  return filters;
2881
2837
  }
@@ -17,7 +17,6 @@ import * as VisualLogging from '../../ui/visual_logging/visual_logging.js';
17
17
 
18
18
  import {CookieControlsView} from './CookieControlsView.js';
19
19
  import {CookieReportView} from './CookieReportView.js';
20
- import {IPProtectionView} from './IPProtectionView.js';
21
20
  import lockIconStyles from './lockIcon.css.js';
22
21
  import mainViewStyles from './mainView.css.js';
23
22
  import {ShowOriginEvent} from './OriginTreeElement.js';
@@ -556,7 +555,6 @@ const DEFAULT_VIEW: View = (input: ViewInput, output: ViewOutput, target: HTMLEl
556
555
  <devtools-widget
557
556
  slot="sidebar"
558
557
  .widgetConfig=${widgetConfig(SecurityPanelSidebar)}
559
- @showIPProtection=${() => output.setVisibleView(new IPProtectionView())}
560
558
  @showCookieReport=${()=>output.setVisibleView(new CookieReportView())}
561
559
  @showFlagControls=${() => output.setVisibleView(new CookieControlsView())}
562
560
  ${UI.Widget.widgetRef(SecurityPanelSidebar, e => {output.sidebar = e;})}>
@@ -13,7 +13,6 @@ import * as UI from '../../ui/legacy/legacy.js';
13
13
 
14
14
  import {CookieControlsTreeElement} from './CookieControlsTreeElement.js';
15
15
  import {CookieReportTreeElement} from './CookieReportTreeElement.js';
16
- import {IPProtectionTreeElement} from './IPProtectionTreeElement.js';
17
16
  import lockIconStyles from './lockIcon.css.js';
18
17
  import {OriginTreeElement} from './OriginTreeElement.js';
19
18
  import {
@@ -42,10 +41,6 @@ const UIStrings = {
42
41
  * @description Sidebar element text in the Security panel
43
42
  */
44
43
  flagControls: 'Controls',
45
- /**
46
- * @description Sidebar element text in the Security panel
47
- */
48
- ipProtection: 'IP Protection',
49
44
  /**
50
45
  * @description Text in Security Panel of the Security panel
51
46
  */
@@ -83,7 +78,6 @@ export class SecurityPanelSidebar extends UI.Widget.VBox {
83
78
  securityOverviewElement: OriginTreeElement;
84
79
  readonly #cookieControlsTreeElement: CookieControlsTreeElement|undefined;
85
80
  readonly cookieReportTreeElement: CookieReportTreeElement|undefined;
86
- readonly ipProtectionTreeElement: IPProtectionTreeElement|undefined;
87
81
  readonly #elementsByOrigin: Map<string, OriginTreeElement>;
88
82
  readonly #mainViewReloadMessage: UI.TreeOutline.TreeElement;
89
83
  #mainOrigin: string|null;
@@ -108,11 +102,6 @@ export class SecurityPanelSidebar extends UI.Widget.VBox {
108
102
  this.cookieReportTreeElement = new CookieReportTreeElement(i18nString(UIStrings.cookieReport), 'cookie-report');
109
103
  privacyTreeSection.appendChild(this.cookieReportTreeElement);
110
104
 
111
- if (Root.Runtime.hostConfig.devToolsIpProtectionPanelInDevTools?.enabled) {
112
- this.ipProtectionTreeElement = new IPProtectionTreeElement(i18nString(UIStrings.ipProtection), 'ip-protection');
113
- privacyTreeSection.appendChild(this.ipProtectionTreeElement);
114
- }
115
-
116
105
  // If this if the first time this setting is set, go to the controls tool
117
106
  if (this.#securitySidebarLastItemSetting.get() === '') {
118
107
  this.#securitySidebarLastItemSetting.set(this.#cookieControlsTreeElement.elemId);
@@ -192,11 +181,6 @@ export class SecurityPanelSidebar extends UI.Widget.VBox {
192
181
  this.#securitySidebarLastItemSetting.get() === this.cookieReportTreeElement.elemId) {
193
182
  this.cookieReportTreeElement.select();
194
183
  this.cookieReportTreeElement.showElement();
195
- } else if (
196
- this.ipProtectionTreeElement &&
197
- this.#securitySidebarLastItemSetting.get() === this.ipProtectionTreeElement.elemId) {
198
- this.ipProtectionTreeElement.select();
199
- this.ipProtectionTreeElement.showElement();
200
184
  } else {
201
185
  this.securityOverviewElement.select();
202
186
  this.securityOverviewElement.showElement();
@@ -4,14 +4,12 @@
4
4
 
5
5
  import * as CookieControlsView from './CookieControlsView.js';
6
6
  import * as CookieReportView from './CookieReportView.js';
7
- import * as IPProtectionView from './IPProtectionView.js';
8
7
  import * as SecurityModel from './SecurityModel.js';
9
8
  import * as SecurityPanel from './SecurityPanel.js';
10
9
 
11
10
  export {
12
11
  CookieControlsView,
13
12
  CookieReportView,
14
- IPProtectionView,
15
13
  SecurityModel,
16
14
  SecurityPanel,
17
15
  };
@@ -22,6 +22,22 @@ const DISCLAIMER_TOOLTIP_ID = 'sources-ai-code-completion-disclaimer-tooltip';
22
22
  const SPINNER_TOOLTIP_ID = 'sources-ai-code-completion-spinner-tooltip';
23
23
  const CITATIONS_TOOLTIP_ID = 'sources-ai-code-completion-citations-tooltip';
24
24
 
25
+ function createCallbacks(editor: TextEditor.TextEditor.TextEditor): AiCodeCompletion.AiCodeCompletion.Callbacks {
26
+ return {
27
+ getSelectionHead: () => editor.editor.state.selection.main.head,
28
+ getCompletionHint: () => editor.editor.plugin(TextEditor.Config.showCompletionHint)?.currentHint,
29
+ setAiAutoCompletion: (args: {
30
+ text: string,
31
+ from: number,
32
+ startTime: number,
33
+ onImpression: (rpcGlobalId: Host.AidaClient.RpcGlobalId, latency: number, sampleId?: number) => void,
34
+ clearCachedRequest: () => void,
35
+ rpcGlobalId?: Host.AidaClient.RpcGlobalId,
36
+ sampleId?: number,
37
+ }|null) => editor.editor.dispatch({effects: TextEditor.Config.setAiAutoCompleteSuggestion.of(args)}),
38
+ };
39
+ }
40
+
25
41
  export class AiCodeCompletionPlugin extends Plugin {
26
42
  #aidaClient?: Host.AidaClient.AidaClient;
27
43
  #aidaAvailability?: Host.AidaClient.AidaAccessPreconditions;
@@ -215,7 +231,7 @@ export class AiCodeCompletionPlugin extends Plugin {
215
231
  AiCodeCompletion.AiCodeCompletion.ContextFlavor.CONSOLE :
216
232
  AiCodeCompletion.AiCodeCompletion.ContextFlavor.SOURCES;
217
233
  this.#aiCodeCompletion = new AiCodeCompletion.AiCodeCompletion.AiCodeCompletion(
218
- {aidaClient: this.#aidaClient}, this.#editor, contextFlavor);
234
+ {aidaClient: this.#aidaClient}, contextFlavor, createCallbacks(this.#editor));
219
235
  this.#aiCodeCompletion.addEventListener(
220
236
  AiCodeCompletion.AiCodeCompletion.Events.REQUEST_TRIGGERED, this.#onAiRequestTriggered, this);
221
237
  this.#aiCodeCompletion.addEventListener(
@@ -1,7 +1,7 @@
1
1
  Name: Dependencies sourced from the upstream `chromium` repository
2
2
  URL: https://chromium.googlesource.com/chromium/src
3
3
  Version: N/A
4
- Revision: 33096dd334d53eb095e196b5663cc1921f646cae
4
+ Revision: 3e8720c1c3a43f134e2008e1764e70380a5b8bc1
5
5
  Update Mechanism: Manual (https://crbug.com/428069060)
6
6
  License: BSD-3-Clause
7
7
  License File: LICENSE
@@ -0,0 +1,30 @@
1
+ // Copyright 2021 The Chromium Authors
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ import * as Lit from '../../lit/lit.js';
6
+
7
+ import {ExpandableList} from './expandable_list.js';
8
+
9
+ const {html} = Lit;
10
+
11
+ export function render(container: HTMLElement): void {
12
+ const component = new ExpandableList.ExpandableList();
13
+
14
+ const rows = [];
15
+ rows.push(html`
16
+ <div>This is row 1. Click on the triangle icon to expand.</div>
17
+ `);
18
+
19
+ for (let rowNumber = 2; rowNumber < 11; rowNumber++) {
20
+ rows.push(html`
21
+ <div>This is row ${rowNumber}.</div>
22
+ `);
23
+ }
24
+
25
+ component.data = {
26
+ rows,
27
+ };
28
+
29
+ container.appendChild(component);
30
+ }
@@ -69,10 +69,6 @@ export const markdownLinks = new Map<string, string>([
69
69
  ],
70
70
  ['storagePartitioningExplainer', 'https://developers.google.com/privacy-sandbox/cookies/storage-partitioning'],
71
71
  ['storageAccessAPI', 'https://developer.mozilla.org/en-US/docs/Web/API/StorageAccessHandle/createObjectURL'],
72
- [
73
- 'userReidentificationBugReports',
74
- 'https://issues.chromium.org/issues?q=status:open%20componentid:1456351&s=created_time:desc)'
75
- ],
76
72
  ]);
77
73
 
78
74
  export const getMarkdownLink = (key: string): string => {
@@ -0,0 +1,95 @@
1
+ // Copyright 2025 The Chromium Authors
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ import * as Marked from '../../../third_party/marked/marked.js';
6
+ import * as Lit from '../../lit/lit.js';
7
+
8
+ import {MarkdownImagesMap, MarkdownLinksMap, type MarkdownView} from './markdown_view.js';
9
+
10
+ const {html} = Lit;
11
+
12
+ export function render(container: HTMLElement): void {
13
+ // Register images in the markdown image map.
14
+ MarkdownImagesMap.markdownImages.set('gear', {
15
+ src: 'gear',
16
+ width: 'var(--sys-size-8)',
17
+ height: 'var(--sys-size-8)',
18
+ isIcon: true,
19
+ });
20
+ MarkdownImagesMap.markdownImages.set('baseline', {
21
+ // Path is relative to served component doc html
22
+ src: './front_end/Images/src/align-items-baseline.svg',
23
+ width: 'var(--sys-size-26)',
24
+ height: 'var(--sys-size-26)',
25
+ isIcon: false,
26
+ });
27
+
28
+ // Register a link in the markdown link map.
29
+ MarkdownLinksMap.markdownLinks.set('test-link', 'https://exampleLink.com/');
30
+
31
+ const codeForCodeBlock = `
32
+ MarkdownView.MarkdownImagesMap.markdownImages.set('gear', {
33
+ src: 'gear',
34
+ width: 'var(--sys-size-8)',
35
+ height: 'var(--sys-size-8)',
36
+ isIcon: true,
37
+ });
38
+ MarkdownView.MarkdownImagesMap.markdownImages.set('baseline', {
39
+ src: './front_end/Images/src/align-items-baseline.svg',
40
+ width: 'var(--sys-size-26)',
41
+ height: 'var(--sys-size-26)',
42
+ isIcon: false,
43
+ });
44
+ `;
45
+
46
+ const markdownAst = Marked.Marked.lexer(`
47
+ Lorem ipsum dolor sit amet, ![icon](gear) consectetur adipiscing elit. [Phasellus tristique](test-link) metus velit, a laoreet sapien ultricies eu. Fusce facilisis, felis id ullamcorper placerat, enim magna porta justo, nec aliquet orci arcu eu velit. Ut quis maximus dolor. Morbi congue tempus porttitor. Duis ut lorem gravida, vehicula mi et, suscipit risus.
48
+
49
+ * Cras varius cursus eros.
50
+ * Mauris non blandit turpis.
51
+
52
+ Proin posuere varius risus, nec tristique urna elementum ut.
53
+
54
+ \`\`\`js
55
+ console.log('test')
56
+ \`\`\`
57
+
58
+ \`\`\`js
59
+ ${codeForCodeBlock}
60
+ \`\`\`
61
+
62
+ ![Image](baseline)
63
+
64
+ \`Cras id elit at erat porttitor elementum\`. Donec purus nulla, suscipit eu hendrerit in, auctor eu erat. Proin ut accumsan mi, rhoncus interdum odio. Etiam dapibus posuere lorem.
65
+ `);
66
+
67
+ const codeBlockConfigs = [
68
+ {displayNotice: true, header: ''},
69
+ {displayNotice: false, header: ''},
70
+ {displayNotice: true, header: 'Code executed', showCopyButton: false},
71
+ {displayNotice: false, header: 'Code executed', showCopyButton: false},
72
+ {displayNotice: true, header: 'Code executed', showCopyButton: true},
73
+ {displayNotice: false, header: 'Code executed', showCopyButton: true},
74
+ ];
75
+
76
+ Lit.render(
77
+ html`
78
+ <h2>Basic Markdown View</h2>
79
+ <p>This example shows a basic rendering of Markdown, including custom image and link resolution.</p>
80
+ <devtools-markdown-view .data=${{tokens: markdownAst} as MarkdownView.MarkdownViewData}></devtools-markdown-view>
81
+
82
+ <h2>Code Block Examples</h2>
83
+ ${codeBlockConfigs.map(config => html`
84
+ <h3>Configuration: <code>${JSON.stringify(config)}</code></h3>
85
+ <devtools-code-block
86
+ .code=${codeForCodeBlock}
87
+ .codeLang=${'js'}
88
+ .displayNotice=${config.displayNotice}
89
+ .header=${config.header}
90
+ .showCopyButton=${Boolean(config.showCopyButton)}
91
+ ></devtools-code-block>
92
+ `)}
93
+ `,
94
+ container);
95
+ }