chrome-devtools-frontend 1.0.947377 → 1.0.948916

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 (124) hide show
  1. package/config/gni/all_devtools_files.gni +1 -6
  2. package/config/gni/devtools_grd_files.gni +5 -12
  3. package/config/gni/devtools_image_files.gni +1 -0
  4. package/front_end/.eslintrc.js +1 -0
  5. package/front_end/Images/src/circled_backslash_icon.svg +3 -0
  6. package/front_end/core/host/UserMetrics.ts +1 -1
  7. package/front_end/core/i18n/locales/en-US.json +32 -44
  8. package/front_end/core/i18n/locales/en-XL.json +32 -44
  9. package/front_end/core/platform/platform.ts +0 -2
  10. package/front_end/core/platform/string-utilities.ts +14 -1
  11. package/front_end/core/platform/utilities.ts +0 -29
  12. package/front_end/core/root/Runtime.ts +4 -207
  13. package/front_end/core/sdk/Cookie.ts +0 -21
  14. package/front_end/core/sdk/RemoteObject.ts +15 -1
  15. package/front_end/core/sdk/sdk-legacy.ts +0 -3
  16. package/front_end/entrypoints/devtools_app/{devtools_app-meta-files.ts → devtools_app.ts} +9 -3
  17. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts +2 -1
  18. package/front_end/entrypoints/js_app/{JsMain.ts → js_app.ts} +5 -1
  19. package/front_end/entrypoints/main/MainImpl.ts +0 -1
  20. package/front_end/entrypoints/ndb_app/{ndb_app.js → ndb_app.ts} +0 -2
  21. package/front_end/entrypoints/node_app/node_app.ts +1 -3
  22. package/front_end/entrypoints/shell/{shell.js → shell.ts} +0 -2
  23. package/front_end/entrypoints/visibility.gni +3 -1
  24. package/front_end/entrypoints/worker_app/worker_app.ts +1 -4
  25. package/front_end/generated/InspectorBackendCommands.js +8 -1
  26. package/front_end/generated/protocol-mapping.d.ts +4 -0
  27. package/front_end/generated/protocol-proxy-api.d.ts +6 -0
  28. package/front_end/generated/protocol.d.ts +9 -0
  29. package/front_end/legacy/legacy-defs.d.ts +0 -4
  30. package/front_end/legacy_test_runner/test_runner/TestRunner.js +35 -59
  31. package/front_end/models/issues_manager/AttributionReportingIssue.ts +27 -2
  32. package/front_end/models/issues_manager/CorsIssue.ts +15 -15
  33. package/front_end/models/issues_manager/descriptions/{corsInsecurePrivateNetworkPreflight.md → corsPreflightAllowPrivateNetworkError.md} +1 -1
  34. package/front_end/panels/accessibility/AccessibilitySidebarView.ts +3 -1
  35. package/front_end/panels/application/BackForwardCacheStrings.ts +1 -5
  36. package/front_end/panels/application/BackForwardCacheView.ts +150 -58
  37. package/front_end/panels/application/ResourcesPanel.ts +0 -42
  38. package/front_end/panels/application/application-legacy.ts +0 -3
  39. package/front_end/panels/application/application-meta.ts +0 -13
  40. package/front_end/panels/application/backForwardCacheView.css +44 -6
  41. package/front_end/panels/application/components/FrameDetailsView.ts +3 -3
  42. package/front_end/panels/application/components/OriginTrialTreeView.ts +3 -3
  43. package/front_end/panels/application/components/StackTrace.ts +1 -1
  44. package/front_end/panels/console/ConsolePrompt.ts +0 -4
  45. package/front_end/panels/coverage/CoverageView.ts +1 -1
  46. package/front_end/panels/css_overview/components/cssOverviewStartView.css +1 -0
  47. package/front_end/panels/css_overview/cssOverviewCompletedView.css +1 -1
  48. package/front_end/panels/developer_resources/DeveloperResourcesView.ts +2 -1
  49. package/front_end/panels/elements/AccessibilityTreeUtils.ts +1 -7
  50. package/front_end/panels/elements/ElementsPanel.ts +9 -1
  51. package/front_end/panels/elements/ElementsTreeElement.ts +1 -1
  52. package/front_end/panels/elements/PropertiesWidget.ts +109 -4
  53. package/front_end/panels/elements/components/ElementsBreadcrumbs.ts +1 -1
  54. package/front_end/panels/elements/propertiesWidget.css +34 -0
  55. package/front_end/panels/emulation/DeviceModeToolbar.ts +5 -1
  56. package/front_end/panels/issues/CorsIssueDetailsView.ts +20 -8
  57. package/front_end/panels/network/NetworkWaterfallColumn.ts +2 -0
  58. package/front_end/panels/profiler/CPUProfileFlameChart.ts +3 -1
  59. package/front_end/panels/profiler/ProfileDataGrid.ts +2 -1
  60. package/front_end/panels/settings/components/SyncSection.ts +2 -2
  61. package/front_end/panels/settings/emulation/components/UserAgentClientHintsForm.ts +46 -46
  62. package/front_end/panels/timeline/TimelineTreeView.ts +2 -1
  63. package/front_end/ui/components/diff_view/DiffView.ts +4 -4
  64. package/front_end/ui/components/helpers/component-server-setup.ts +1 -12
  65. package/front_end/ui/components/helpers/helpers.ts +0 -2
  66. package/front_end/ui/components/icon_button/IconButton.ts +1 -1
  67. package/front_end/ui/components/issue_counter/IssueCounter.ts +2 -2
  68. package/front_end/ui/components/linear_memory_inspector/LinearMemoryViewer.ts +3 -3
  69. package/front_end/ui/components/markdown_view/MarkdownView.ts +4 -4
  70. package/front_end/ui/components/panel_feedback/PreviewToggle.ts +98 -0
  71. package/front_end/ui/components/panel_feedback/panel_feedback.ts +1 -0
  72. package/front_end/ui/components/panel_feedback/previewToggle.css +24 -0
  73. package/front_end/ui/components/report_view/ReportView.ts +22 -0
  74. package/front_end/ui/components/report_view/reportSection.css +20 -0
  75. package/front_end/ui/components/request_link_icon/RequestLinkIcon.ts +1 -1
  76. package/front_end/ui/components/settings/SettingCheckbox.ts +2 -2
  77. package/front_end/ui/components/text_editor/config.ts +4 -3
  78. package/front_end/ui/components/text_editor/javascript.ts +8 -4
  79. package/front_end/ui/components/text_prompt/TextPrompt.ts +2 -2
  80. package/front_end/ui/legacy/GlassPane.ts +1 -1
  81. package/front_end/ui/legacy/SearchableView.ts +2 -1
  82. package/front_end/ui/legacy/Treeoutline.ts +1 -1
  83. package/front_end/ui/legacy/Widget.ts +1 -1
  84. package/front_end/ui/legacy/XWidget.ts +0 -5
  85. package/front_end/ui/legacy/components/inline_editor/CSSVarSwatch.ts +2 -2
  86. package/front_end/ui/legacy/components/inline_editor/ColorSwatch.ts +1 -1
  87. package/front_end/ui/legacy/utils/append-style.ts +2 -13
  88. package/front_end/ui/legacy/utils/create-shadow-root-with-core-styles.ts +7 -5
  89. package/package.json +2 -4
  90. package/scripts/build/build_inspector_overlay.py +15 -1
  91. package/scripts/build/rjsmin.py +84 -115
  92. package/scripts/eslint_rules/lib/ban_a_tags_in_lit_html.js +2 -11
  93. package/scripts/eslint_rules/lib/ban_literal_devtools_component_tag_names.js +2 -11
  94. package/scripts/eslint_rules/lib/ban_self_closing_custom_element_tagnames.js +2 -11
  95. package/scripts/eslint_rules/lib/ban_style_tags_in_lit_html.js +2 -11
  96. package/scripts/eslint_rules/lib/lit_html_data_as_type.js +2 -11
  97. package/scripts/eslint_rules/lib/lit_html_no_attribute_quotes.js +89 -0
  98. package/scripts/eslint_rules/lib/lit_no_style_interpolation.js +2 -11
  99. package/scripts/eslint_rules/lib/no_only_eslint_tests.js +53 -0
  100. package/scripts/eslint_rules/lib/static_tag_must_be_static_property.js +2 -11
  101. package/scripts/eslint_rules/lib/utils.js +29 -0
  102. package/scripts/eslint_rules/tests/.eslintrc.js +18 -0
  103. package/scripts/eslint_rules/tests/lit_html_no_attribute_quotes_test.js +45 -0
  104. package/scripts/eslint_rules/tests/no_only_eslint_tests_test.js +94 -0
  105. package/scripts/eslint_rules/tests/utils_test.js +40 -0
  106. package/front_end/entrypoints/devtools_app/devtools_app.js +0 -11
  107. package/front_end/entrypoints/devtools_app/devtools_app.json +0 -4
  108. package/front_end/entrypoints/js_app/js_app.js +0 -12
  109. package/front_end/entrypoints/js_app/js_app.json +0 -3
  110. package/front_end/entrypoints/ndb_app/ndb_app.json +0 -4
  111. package/front_end/entrypoints/startup/RuntimeInstantiator.ts +0 -95
  112. package/front_end/entrypoints/startup/startup.ts +0 -9
  113. package/front_end/panels/help/HelpImpl.ts +0 -141
  114. package/front_end/panels/help/ReleaseNoteText.ts +0 -1496
  115. package/front_end/panels/help/ReleaseNoteView.ts +0 -107
  116. package/front_end/panels/help/help-meta.ts +0 -145
  117. package/front_end/panels/help/help.ts +0 -13
  118. package/front_end/panels/help/releaseNote.css +0 -115
  119. package/front_end/ui/components/helpers/get-stylesheet.ts +0 -45
  120. package/scripts/build/build_release_applications.py +0 -216
  121. package/scripts/build/modular_build.py +0 -184
  122. package/scripts/check_gn.js +0 -119
  123. package/scripts/json_validator/module.schema.json +0 -19
  124. package/scripts/json_validator/validate_module_json.js +0 -44
@@ -1,107 +0,0 @@
1
- // Copyright 2017 The Chromium Authors. All rights reserved.
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 Host from '../../core/host/host.js';
6
- import * as i18n from '../../core/i18n/i18n.js';
7
- import * as UI from '../../ui/legacy/legacy.js';
8
-
9
- import {latestReleaseNote, releaseNoteViewId} from './HelpImpl.js';
10
- import releaseNoteStyles from './releaseNote.css.js';
11
-
12
- import type {ReleaseNote} from './HelpImpl.js';
13
-
14
- const UIStrings = {
15
- /**
16
- *@description Text that is usually a hyperlink to more documentation
17
- */
18
- learnMore: 'Learn more',
19
- /**
20
- *@description Text to close something
21
- */
22
- close: 'Close',
23
- };
24
- const str_ = i18n.i18n.registerUIStrings('panels/help/ReleaseNoteView.ts', UIStrings);
25
- const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
26
- let releaseNoteViewInstance: ReleaseNoteView;
27
-
28
- export class ReleaseNoteView extends UI.Widget.VBox {
29
- private readonly releaseNoteElement: Element;
30
- constructor() {
31
- super(true);
32
-
33
- this.releaseNoteElement = this.createReleaseNoteElement(latestReleaseNote());
34
- const topSection = this.contentElement.createChild('div', 'release-note-top-section');
35
- topSection.textContent = latestReleaseNote().header;
36
- this.contentElement.appendChild(this.releaseNoteElement);
37
- }
38
-
39
- static instance(opts: {forceNew: boolean|null} = {forceNew: null}): ReleaseNoteView {
40
- const {forceNew} = opts;
41
- if (!releaseNoteViewInstance || forceNew) {
42
- releaseNoteViewInstance = new ReleaseNoteView();
43
- }
44
- return releaseNoteViewInstance;
45
- }
46
-
47
- elementsToRestoreScrollPositionsFor(): Element[] {
48
- return [this.releaseNoteElement];
49
- }
50
-
51
- private createReleaseNoteElement(releaseNote: ReleaseNote): Element {
52
- const hbox = document.createElement('div');
53
- hbox.classList.add('hbox');
54
- const container = hbox.createChild('div', 'release-note-container');
55
- const contentContainer = container.createChild('ul');
56
- UI.ARIAUtils.setAccessibleName(contentContainer, latestReleaseNote().header);
57
-
58
- let linkNumber = 1;
59
- for (const highlight of releaseNote.highlights) {
60
- const listItem = contentContainer.createChild('li');
61
- const linkWrapper = UI.XLink.XLink.create(highlight.link, '', 'release-note-link');
62
- linkWrapper.textContent = '';
63
- UI.ARIAUtils.markAsLink(linkWrapper);
64
- UI.ARIAUtils.setAccessibleName(
65
- linkWrapper, `${highlight.title}: ${highlight.subtitle} ${linkNumber} of ${releaseNote.highlights.length}`);
66
-
67
- const title = linkWrapper.createChild('div', 'release-note-title');
68
- title.textContent = highlight.title;
69
-
70
- const subtitle = linkWrapper.createChild('div', 'release-note-subtitle');
71
- subtitle.textContent = highlight.subtitle;
72
-
73
- listItem.appendChild(linkWrapper);
74
- linkNumber++;
75
- }
76
-
77
- const actionContainer = container.createChild('div', 'release-note-action-container');
78
- const learnMore = UI.UIUtils.createTextButton(i18nString(UIStrings.learnMore), event => {
79
- event.consume(true);
80
- Host.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab(releaseNote.link);
81
- });
82
- UI.ARIAUtils.markAsLink(learnMore);
83
- actionContainer.appendChild(learnMore);
84
-
85
- actionContainer.appendChild(UI.UIUtils.createTextButton(i18nString(UIStrings.close), event => {
86
- event.consume(true);
87
- UI.InspectorView.InspectorView.instance().closeDrawerTab(releaseNoteViewId, true);
88
- }, 'close-release-note'));
89
-
90
- const imageLink = UI.XLink.XLink.create(releaseNote.link, ' ') as HTMLElement;
91
- imageLink.classList.add('release-note-image');
92
- const tooltipText = latestReleaseNote().header;
93
- UI.Tooltip.Tooltip.install(imageLink, tooltipText);
94
-
95
- hbox.appendChild(imageLink);
96
- const image = imageLink.createChild('img') as HTMLImageElement;
97
- image.src = new URL('../../Images/whatsnew.avif', import.meta.url).toString();
98
- UI.Tooltip.Tooltip.install(image, tooltipText);
99
- image.alt = tooltipText;
100
-
101
- return hbox;
102
- }
103
- wasShown(): void {
104
- super.wasShown();
105
- this.registerCSSFiles([releaseNoteStyles]);
106
- }
107
- }
@@ -1,145 +0,0 @@
1
- // Copyright 2020 The Chromium Authors. All rights reserved.
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 Common from '../../core/common/common.js';
6
- import * as i18n from '../../core/i18n/i18n.js';
7
- import * as UI from '../../ui/legacy/legacy.js';
8
-
9
- import type * as Help from './help.js';
10
-
11
- const UIStrings = {
12
- /**
13
- *@description Title of the 'What's New' tool in the bottom drawer
14
- */
15
- whatsNew: 'What\'s New',
16
- /**
17
- *@description Command for showing the 'What's New' tool in the bottom drawer
18
- */
19
- showWhatsNew: 'Show What\'s New',
20
- /**
21
- *@description Title of an action in the help tool to release notes
22
- */
23
- releaseNotes: 'Release notes',
24
- /**
25
- *@description Title of an action in the help tool to file an issue
26
- */
27
- reportADevtoolsIssue: 'Report a DevTools issue',
28
- /**
29
- *@description Title of an action in the help tool to file a translation issue
30
- */
31
- reportTranslationIssue: 'Report a translation issue',
32
- /**
33
- *@description A search term referring to a software defect (i.e. bug) that can be entered in the command menu
34
- */
35
- bug: 'bug',
36
- /**
37
- *@description Title of a setting under the Appearance category that can be invoked through the Command Menu
38
- */
39
- showWhatsNewAfterEachUpdate: 'Show What\'s New after each update',
40
- /**
41
- *@description Title of a setting under the Appearance category that can be invoked through the Command Menu
42
- */
43
- doNotShowWhatsNewAfterEachUpdate: 'Do not show What\'s New after each update',
44
- };
45
- const str_ = i18n.i18n.registerUIStrings('panels/help/help-meta.ts', UIStrings);
46
- const i18nLazyString = i18n.i18n.getLazilyComputedLocalizedString.bind(undefined, str_);
47
-
48
- let loadedHelpModule: (typeof Help|undefined);
49
-
50
- async function loadHelpModule(): Promise<typeof Help> {
51
- if (!loadedHelpModule) {
52
- loadedHelpModule = await import('./help.js');
53
- }
54
- return loadedHelpModule;
55
- }
56
-
57
- UI.ViewManager.registerViewExtension({
58
- location: UI.ViewManager.ViewLocationValues.DRAWER_VIEW,
59
- id: 'release-note',
60
- title: i18nLazyString(UIStrings.whatsNew),
61
- commandPrompt: i18nLazyString(UIStrings.showWhatsNew),
62
- persistence: UI.ViewManager.ViewPersistence.CLOSEABLE,
63
- order: 1,
64
- async loadView() {
65
- const Help = await loadHelpModule();
66
- return Help.ReleaseNoteView.ReleaseNoteView.instance();
67
- },
68
- });
69
-
70
- UI.ActionRegistration.registerActionExtension({
71
- category: UI.ActionRegistration.ActionCategory.HELP,
72
- actionId: 'help.release-notes',
73
- title: i18nLazyString(UIStrings.releaseNotes),
74
- async loadActionDelegate() {
75
- const Help = await loadHelpModule();
76
- return Help.Help.ReleaseNotesActionDelegate.instance();
77
- },
78
- });
79
-
80
- UI.ActionRegistration.registerActionExtension({
81
- category: UI.ActionRegistration.ActionCategory.HELP,
82
- actionId: 'help.report-issue',
83
- title: i18nLazyString(UIStrings.reportADevtoolsIssue),
84
- async loadActionDelegate() {
85
- const Help = await loadHelpModule();
86
- return Help.Help.ReportIssueActionDelegate.instance();
87
- },
88
- tags: [i18nLazyString(UIStrings.bug)],
89
- });
90
-
91
- UI.ActionRegistration.registerActionExtension({
92
- category: UI.ActionRegistration.ActionCategory.HELP,
93
- actionId: 'help.report-translation-issue',
94
- title: i18nLazyString(UIStrings.reportTranslationIssue),
95
- async loadActionDelegate() {
96
- const Help = await loadHelpModule();
97
- return Help.Help.ReportTranslationIssueActionDelegate.instance();
98
- },
99
- tags: [i18nLazyString(UIStrings.bug)],
100
- });
101
-
102
- Common.Settings.registerSettingExtension({
103
- category: Common.Settings.SettingCategory.APPEARANCE,
104
- storageType: Common.Settings.SettingStorageType.Synced,
105
- title: i18nLazyString(UIStrings.showWhatsNewAfterEachUpdate),
106
- settingName: 'help.show-release-note',
107
- settingType: Common.Settings.SettingType.BOOLEAN,
108
- defaultValue: true,
109
- options: [
110
- {
111
- value: true,
112
- title: i18nLazyString(UIStrings.showWhatsNewAfterEachUpdate),
113
- },
114
- {
115
- value: false,
116
- title: i18nLazyString(UIStrings.doNotShowWhatsNewAfterEachUpdate),
117
- },
118
- ],
119
- });
120
-
121
- UI.ContextMenu.registerItem({
122
- location: UI.ContextMenu.ItemLocation.MAIN_MENU_HELP_DEFAULT,
123
- actionId: 'help.release-notes',
124
- order: 10,
125
- });
126
-
127
- UI.ContextMenu.registerItem({
128
- location: UI.ContextMenu.ItemLocation.MAIN_MENU_HELP_DEFAULT,
129
- actionId: 'help.report-issue',
130
- order: 11,
131
- });
132
-
133
- UI.ContextMenu.registerItem({
134
- location: UI.ContextMenu.ItemLocation.MAIN_MENU_HELP_DEFAULT,
135
- actionId: 'help.report-translation-issue',
136
- order: 12,
137
- });
138
-
139
- Common.Runnable.registerLateInitializationRunnable({
140
- id: 'whats-new',
141
- async loadRunnable() {
142
- const Help = await loadHelpModule();
143
- return Help.Help.HelpLateInitialization.instance();
144
- },
145
- });
@@ -1,13 +0,0 @@
1
- // Copyright 2019 The Chromium Authors. All rights reserved.
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 Help from './HelpImpl.js';
6
- import * as ReleaseNoteText from './ReleaseNoteText.js';
7
- import * as ReleaseNoteView from './ReleaseNoteView.js';
8
-
9
- export {
10
- Help,
11
- ReleaseNoteText,
12
- ReleaseNoteView,
13
- };
@@ -1,115 +0,0 @@
1
- /*
2
- * Copyright 2017 The Chromium Authors. All rights reserved.
3
- * Use of this source code is governed by a BSD-style license that can be
4
- * found in the LICENSE file.
5
- */
6
-
7
- .hbox {
8
- overflow-y: auto;
9
- overflow-x: hidden;
10
- }
11
-
12
- .release-note-top-section {
13
- height: 27px;
14
- line-height: 27px;
15
- padding: 0 15px;
16
- flex: none;
17
- color: var(--color-text-primary);
18
- background-color: var(--color-background-elevation-1);
19
- border-bottom: var(--legacy-divider-border);
20
- overflow: hidden;
21
- white-space: nowrap;
22
- text-overflow: ellipsis;
23
- }
24
-
25
- .release-note-container {
26
- display: flex;
27
- flex-direction: column;
28
- }
29
-
30
- .release-note-container ul {
31
- display: flex;
32
- padding: 10px 16px;
33
- flex-direction: column;
34
- flex: none;
35
- margin: 4px 12px 0 2px;
36
- max-width: 600px;
37
- }
38
-
39
- .release-note-container li {
40
- display: flex;
41
- flex-direction: column;
42
- flex: none;
43
- line-height: 24px;
44
- font-size: 14px;
45
- }
46
-
47
- .release-note-container .release-note-link {
48
- border: 1px solid var(--color-details-hairline-light);
49
- padding-left: 8px;
50
- padding-right: 8px;
51
- margin-bottom: 4px;
52
- text-decoration: none;
53
- }
54
-
55
- .release-note-container .release-note-link:hover {
56
- border-color: var(--color-details-hairline);
57
- }
58
-
59
- .release-note-title,
60
- .release-note-subtitle {
61
- color: inherit;
62
- text-decoration: none;
63
- }
64
-
65
- .release-note-subtitle {
66
- font-size: 13px;
67
- line-height: 13px;
68
- padding-bottom: 8px;
69
- }
70
-
71
- .release-note-container li:not(:hover) .release-note-subtitle {
72
- color: var(--color-text-secondary);
73
- }
74
-
75
- .release-note-action-container > button {
76
- margin: 10px 0 20px 20px;
77
- color: var(--color-text-secondary);
78
- }
79
-
80
- .release-note-action-container {
81
- flex: none;
82
- }
83
-
84
- .release-note-image {
85
- flex-shrink: 2;
86
- }
87
-
88
- img {
89
- margin: 20px;
90
- width: 260px;
91
- height: 200px;
92
- flex: none;
93
- box-shadow: var(--drop-shadow-depth-1);
94
- }
95
-
96
- img:hover {
97
- box-shadow: var(--drop-shadow-depth-4);
98
- }
99
-
100
- @media (forced-colors: active) {
101
- .release-note-container .release-note-link {
102
- border-color: ButtonText;
103
- }
104
-
105
- .release-note-container .release-note-link:hover {
106
- forced-color-adjust: none;
107
- border-color: Highlight;
108
- }
109
-
110
- .release-note-container li .release-note-title,
111
- .release-note-container li:not(:hover) .release-note-subtitle {
112
- forced-color-adjust: none;
113
- color: linktext;
114
- }
115
- }
@@ -1,45 +0,0 @@
1
- // Copyright 2020 The Chromium Authors. All rights reserved.
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 Root from '../../../core/root/root.js';
6
-
7
- const sheetsCache = new Map<string, {sheets: CSSStyleSheet[]}>();
8
-
9
- /**
10
- * Helper for importing a legacy stylesheet into a component.
11
- *
12
- * Given a path to a stylesheet, it returns a CSSStyleSheet that can then be
13
- * adopted by your component.
14
- */
15
- export function legacyGetStyleSheets(path: string): CSSStyleSheet[] {
16
- const cachedResult = sheetsCache.get(path);
17
- if (cachedResult) {
18
- return cachedResult.sheets;
19
- }
20
-
21
- const content = Root.Runtime.cachedResources.get(path) || '';
22
- if (!content) {
23
- throw new Error(`${path} not preloaded.`);
24
- }
25
- const originalStylesheet = new CSSStyleSheet();
26
- originalStylesheet.replaceSync(content);
27
- sheetsCache.set(path, {sheets: [originalStylesheet]});
28
- return [originalStylesheet];
29
- }
30
-
31
- /*
32
- * This is now legacy. Please do not add any more CSS Files to this list. Refer to
33
- * https://crbug.com/1106746 for the new way of implementing CSS in DevTools.
34
- *
35
- * The legacyGetStylesheet helper in components reads styles out of the runtime cache.
36
- * In a proper build this is populated but in test runs because we don't load
37
- * all of DevTools it's not. Therefore we fetch the required CSS files and populate
38
- * the cache before any tests are run.
39
- *
40
- * The out/Release/gen/front_end URL is prepended so within the Karma config we can proxy
41
- * them through to the right place, respecting Karma's ROOT_DIRECTORY setting.
42
- */
43
- export const CSS_RESOURCES_TO_LOAD_INTO_RUNTIME = [
44
- 'panels/application/serviceWorkerUpdateCycleView.css',
45
- ];
@@ -1,216 +0,0 @@
1
- #!/usr/bin/env vpython
2
- # -*- coding: utf-8 -*-
3
- #
4
- # Copyright 2016 The Chromium Authors. All rights reserved.
5
- # Use of this source code is governed by a BSD-style license that can be
6
- # found in the LICENSE file.
7
- """
8
- Builds applications in release mode:
9
- - Concatenates autostart modules, application modules' module.json descriptors,
10
- and the application loader into a single script.
11
- """
12
-
13
- from io import StringIO
14
- from os import path
15
- from os.path import join
16
- import copy
17
- import os
18
- import re
19
- import shutil
20
- import sys
21
- import subprocess
22
-
23
- from modular_build import read_file, write_file, bail_error
24
- import modular_build
25
- import rjsmin
26
-
27
- try:
28
- import simplejson as json
29
- except ImportError:
30
- import json
31
-
32
- try:
33
- original_sys_path = sys.path
34
- sys.path = sys.path + [path.join(os.path.dirname(os.path.realpath(__file__)), '..')]
35
- import devtools_paths
36
- finally:
37
- sys.path = original_sys_path
38
-
39
- FRONT_END_DIRECTORY = path.join(os.path.dirname(path.abspath(__file__)), '..', '..', 'front_end')
40
-
41
-
42
- def main(argv):
43
- try:
44
- input_path_flag_index = argv.index('--input_path')
45
- input_path = argv[input_path_flag_index + 1]
46
- output_path_gen_flag_index = argv.index('--output_path_gen')
47
- output_path_gen = argv[output_path_gen_flag_index + 1]
48
- application_names = argv[1:input_path_flag_index]
49
- use_rollup = '--rollup' in argv
50
- except:
51
- print('Usage: %s app_1 app_2 ... app_N --input_path <input_path> --output_path <output_path> --rollup true' % argv[0])
52
- raise
53
-
54
- loader = modular_build.DescriptorLoader(input_path)
55
- for app in application_names:
56
- descriptors = loader.load_application(app)
57
- builder = ReleaseBuilder(app, descriptors, input_path, output_path_gen,
58
- use_rollup)
59
- builder.build_app()
60
-
61
-
62
- def resource_source_url(url):
63
- return '\n/*# sourceURL=' + url + ' */'
64
-
65
-
66
- def minify_js(javascript):
67
- return rjsmin.jsmin(javascript)
68
-
69
-
70
- def concatenated_module_filename(module_name, output_dir):
71
- return join(output_dir,
72
- module_name + '/' + path.basename(module_name) + '_module.js')
73
-
74
-
75
- # Outputs:
76
- # <app_name>.js
77
- # <module_name>_module.js
78
- class ReleaseBuilder(object):
79
-
80
- def __init__(self, application_name, descriptors, application_dir,
81
- output_path_gen_dir, use_rollup):
82
- self.application_name = application_name
83
- self.descriptors = descriptors
84
- self.application_dir = application_dir
85
- self.output_path_gen_dir = output_path_gen_dir
86
- self.use_rollup = use_rollup
87
-
88
- def app_file(self, extension):
89
- return path.join('entrypoints', self.application_name,
90
- self.application_name + '.' + extension)
91
-
92
- def autorun_resource_names(self):
93
- result = []
94
- for module in self.descriptors.sorted_modules():
95
- if self.descriptors.application[module].get('type') != 'autostart':
96
- continue
97
-
98
- resources = self.descriptors.modules[module].get('resources')
99
- if not resources:
100
- continue
101
- for resource_name in resources:
102
- result.append(path.join(module, resource_name))
103
- return result
104
-
105
- def build_app(self):
106
- self._build_app_script()
107
- for module in filter(lambda desc: (not desc.get('type')),
108
- self.descriptors.application.values()):
109
- self._concatenate_dynamic_module(module['name'])
110
-
111
- def _build_app_script(self):
112
- script_name = self.app_file('js')
113
- output = StringIO()
114
- self._concatenate_application_script(output)
115
- minified_content = minify_js(output.getvalue())
116
- write_file(join(self.output_path_gen_dir, script_name),
117
- minified_content)
118
- output.close()
119
-
120
- def _release_module_descriptors(self):
121
- module_descriptors = self.descriptors.modules
122
- result = []
123
- for name in module_descriptors:
124
- module = copy.copy(module_descriptors[name])
125
- module_type = self.descriptors.application[name].get('type')
126
- resources = module.get('resources', None)
127
- if resources:
128
- # Resources are already baked into _module.
129
- del module['resources']
130
- if not module_type == 'autostart':
131
- # We load the entrypoint of a module no matter what.
132
- # Therefore, we don't need to declare any files for
133
- # the default case. However, if a module still has
134
- # a legacy file, the Runtime performs an array
135
- # contains check and will load that instead.
136
- module_files_to_load = []
137
- declared_module_files = module.get('modules', [])
138
- legacyFileName = path.basename(name) + '-legacy.js'
139
- if legacyFileName in declared_module_files:
140
- module_files_to_load += [legacyFileName]
141
- # Non-autostart modules are vulcanized.
142
- module['modules'] = [path.basename(name) + '_module.js'
143
- ] + module_files_to_load
144
- result.append(module)
145
- return json.dumps(result)
146
-
147
- def _write_module_resources(self, resource_names, output):
148
- for resource_name in resource_names:
149
- resource_name = path.normpath(resource_name).replace('\\', '/')
150
- output.write('RootModule.Runtime.cachedResources.set("%s", "' %
151
- resource_name)
152
- resource_content = read_file(path.join(self.application_dir, resource_name))
153
- if not (resource_name.endswith('.html')
154
- or resource_name.endswith('md')):
155
- resource_content += resource_source_url(resource_name)
156
- resource_content = resource_content.replace('\\', '\\\\')
157
- resource_content = resource_content.replace('\n', '\\n')
158
- resource_content = resource_content.replace('"', '\\"')
159
- output.write(resource_content)
160
- output.write('");\n')
161
-
162
- def _concatenate_autostart_modules(self, output):
163
- non_autostart = set()
164
- sorted_module_names = self.descriptors.sorted_modules()
165
- for name in sorted_module_names:
166
- desc = self.descriptors.modules[name]
167
- name = desc['name']
168
- type = self.descriptors.application[name].get('type')
169
- if type == 'autostart':
170
- deps = set(desc.get('dependencies', []))
171
- non_autostart_deps = deps & non_autostart
172
- if len(non_autostart_deps):
173
- bail_error(
174
- 'Non-autostart dependencies specified for the autostarted module "%s": %s' % (name, non_autostart_deps))
175
- else:
176
- non_autostart.add(name)
177
-
178
- def _concatenate_application_script(self, output):
179
- output.write('Root.allDescriptors.push(...%s);' % self._release_module_descriptors())
180
- if self.descriptors.extends:
181
- output.write(
182
- 'Root.applicationDescriptor.modules.push(...%s);' %
183
- json.dumps(list(self.descriptors.application.values())))
184
- else:
185
- output.write('Root.applicationDescriptor = %s;' % self.descriptors.application_json())
186
-
187
- output.write("import * as RootModule from '../../core/root/root.js';")
188
- self._write_module_resources(self.autorun_resource_names(), output)
189
-
190
- output.write(minify_js(read_file(join(self.application_dir, self.app_file('js')))))
191
- self._concatenate_autostart_modules(output)
192
-
193
- def _concatenate_dynamic_module(self, module_name):
194
- module = self.descriptors.modules[module_name]
195
- modules = module.get('modules')
196
- resources = self.descriptors.module_resources(module_name)
197
- module_dir = join(self.application_dir, module_name)
198
- output = StringIO()
199
- if resources:
200
- relative_file_name = '../core/root/root.js'
201
- if "/" in module_name:
202
- relative_file_name = (
203
- '../' * module_name.count('/')) + relative_file_name
204
- output.write("import * as RootModule from '%s';" %
205
- relative_file_name)
206
- self._write_module_resources(resources, output)
207
- minified_content = minify_js(output.getvalue())
208
- write_file(
209
- concatenated_module_filename(module_name,
210
- self.output_path_gen_dir),
211
- minified_content)
212
- output.close()
213
-
214
-
215
- if __name__ == '__main__':
216
- sys.exit(main(sys.argv))