chrome-devtools-frontend 1.0.951864 → 1.0.952284

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 (144) hide show
  1. package/front_end/.eslintrc.js +6 -0
  2. package/front_end/entrypoints/formatter_worker/AcornTokenizer.ts +36 -36
  3. package/front_end/entrypoints/formatter_worker/CSSFormatter.ts +53 -53
  4. package/front_end/entrypoints/formatter_worker/ESTreeWalker.ts +11 -11
  5. package/front_end/entrypoints/formatter_worker/FormattedContentBuilder.ts +43 -43
  6. package/front_end/entrypoints/formatter_worker/HTMLFormatter.ts +106 -105
  7. package/front_end/entrypoints/formatter_worker/JavaScriptFormatter.ts +26 -26
  8. package/front_end/entrypoints/heap_snapshot_worker/AllocationProfile.ts +50 -55
  9. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshot.ts +200 -200
  10. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshotLoader.ts +84 -83
  11. package/front_end/entrypoints/heap_snapshot_worker/HeapSnapshotWorkerDispatcher.ts +15 -15
  12. package/front_end/entrypoints/inspector_main/InspectorMain.ts +21 -21
  13. package/front_end/entrypoints/main/ExecutionContextSelector.ts +30 -30
  14. package/front_end/entrypoints/main/MainImpl.ts +12 -12
  15. package/front_end/entrypoints/node_app/NodeConnectionsPanel.ts +33 -33
  16. package/front_end/entrypoints/node_app/NodeMain.ts +35 -35
  17. package/front_end/generated/InspectorBackendCommands.js +5 -1
  18. package/front_end/generated/protocol.d.ts +16 -0
  19. package/front_end/models/issues_manager/ContentSecurityPolicyIssue.ts +6 -6
  20. package/front_end/models/issues_manager/ContrastCheckTrigger.ts +15 -15
  21. package/front_end/models/issues_manager/CorsIssue.ts +9 -9
  22. package/front_end/models/issues_manager/CrossOriginEmbedderPolicyIssue.ts +5 -5
  23. package/front_end/models/issues_manager/DeprecationIssue.ts +7 -7
  24. package/front_end/models/issues_manager/GenericIssue.ts +5 -5
  25. package/front_end/models/issues_manager/HeavyAdIssue.ts +5 -5
  26. package/front_end/models/issues_manager/Issue.ts +10 -10
  27. package/front_end/models/issues_manager/IssueResolver.ts +11 -10
  28. package/front_end/models/issues_manager/IssuesManager.ts +56 -56
  29. package/front_end/models/issues_manager/LowTextContrastIssue.ts +4 -4
  30. package/front_end/models/issues_manager/MixedContentIssue.ts +7 -7
  31. package/front_end/models/issues_manager/NavigatorUserAgentIssue.ts +7 -7
  32. package/front_end/models/issues_manager/QuirksModeIssue.ts +4 -4
  33. package/front_end/models/issues_manager/SameSiteCookieIssue.ts +16 -16
  34. package/front_end/models/issues_manager/SharedArrayBufferIssue.ts +5 -5
  35. package/front_end/models/issues_manager/SourceFrameIssuesManager.ts +32 -31
  36. package/front_end/models/issues_manager/TrustedWebActivityIssue.ts +5 -5
  37. package/front_end/models/issues_manager/WasmCrossOriginModuleSharingIssue.ts +5 -5
  38. package/front_end/panels/application/components/BackForwardCacheView.ts +33 -33
  39. package/front_end/panels/application/components/EndpointsGrid.ts +12 -12
  40. package/front_end/panels/application/components/FrameDetailsView.ts +108 -110
  41. package/front_end/panels/application/components/OriginTrialTreeView.ts +45 -45
  42. package/front_end/panels/application/components/PermissionsPolicySection.ts +19 -19
  43. package/front_end/panels/application/components/ReportsGrid.ts +30 -30
  44. package/front_end/panels/application/components/StackTrace.ts +48 -47
  45. package/front_end/panels/application/components/TrustTokensView.ts +31 -31
  46. package/front_end/panels/css_overview/CSSOverviewCompletedView.ts +41 -52
  47. package/front_end/panels/css_overview/CSSOverviewController.ts +2 -2
  48. package/front_end/panels/css_overview/CSSOverviewPanel.ts +18 -27
  49. package/front_end/panels/css_overview/CSSOverviewProcessingView.ts +2 -2
  50. package/front_end/panels/css_overview/CSSOverviewSidebarPanel.ts +6 -6
  51. package/front_end/panels/css_overview/components/CSSOverviewStartView.ts +4 -4
  52. package/front_end/panels/elements/components/AccessibilityTreeNode.ts +17 -17
  53. package/front_end/panels/elements/components/AdornerManager.ts +21 -21
  54. package/front_end/panels/elements/components/AdornerSettingsPane.ts +14 -14
  55. package/front_end/panels/elements/components/CSSQuery.ts +16 -16
  56. package/front_end/panels/elements/components/ComputedStyleProperty.ts +14 -14
  57. package/front_end/panels/elements/components/ComputedStyleTrace.ts +15 -15
  58. package/front_end/panels/elements/components/ElementsBreadcrumbs.ts +78 -78
  59. package/front_end/panels/elements/components/ElementsPanelLink.ts +16 -16
  60. package/front_end/panels/elements/components/LayoutPane.ts +47 -47
  61. package/front_end/panels/elements/components/NodeText.ts +18 -18
  62. package/front_end/panels/elements/components/QueryContainer.ts +40 -40
  63. package/front_end/panels/elements/components/StylePropertyEditor.ts +18 -18
  64. package/front_end/panels/emulation/components/DeviceSizeInputElement.ts +4 -4
  65. package/front_end/panels/issues/AffectedBlockedByResponseView.ts +4 -4
  66. package/front_end/panels/issues/AffectedCookiesView.ts +4 -5
  67. package/front_end/panels/issues/AffectedDirectivesView.ts +19 -19
  68. package/front_end/panels/issues/AffectedDocumentsInQuirksModeView.ts +7 -8
  69. package/front_end/panels/issues/AffectedElementsView.ts +4 -4
  70. package/front_end/panels/issues/AffectedElementsWithLowContrastView.ts +7 -8
  71. package/front_end/panels/issues/AffectedHeavyAdView.ts +8 -8
  72. package/front_end/panels/issues/AffectedResourcesView.ts +25 -26
  73. package/front_end/panels/issues/AffectedSharedArrayBufferIssueDetailsView.ts +8 -8
  74. package/front_end/panels/issues/AffectedSourcesView.ts +4 -4
  75. package/front_end/panels/issues/AffectedTrustedWebActivityIssueDetailsView.ts +4 -4
  76. package/front_end/panels/issues/AttributionReportingIssueDetailsView.ts +17 -17
  77. package/front_end/panels/issues/CSPViolationsListView.ts +22 -23
  78. package/front_end/panels/issues/CSPViolationsView.ts +17 -17
  79. package/front_end/panels/issues/ComboBoxOfCheckBoxes.ts +13 -13
  80. package/front_end/panels/issues/CorsIssueDetailsView.ts +23 -23
  81. package/front_end/panels/issues/GenericIssueDetailsView.ts +4 -4
  82. package/front_end/panels/issues/HiddenIssuesRow.ts +7 -7
  83. package/front_end/panels/issues/IssueAggregator.ts +95 -95
  84. package/front_end/panels/issues/IssueKindView.ts +14 -14
  85. package/front_end/panels/issues/IssueView.ts +98 -98
  86. package/front_end/panels/issues/IssuesPane.ts +102 -102
  87. package/front_end/panels/issues/WasmCrossOriginModuleSharingAffectedResourcesView.ts +5 -5
  88. package/front_end/panels/issues/components/HideIssuesMenu.ts +10 -10
  89. package/front_end/panels/media/PlayerListView.ts +160 -97
  90. package/front_end/panels/media/PlayerMessagesView.ts +1 -0
  91. package/front_end/panels/media/playerListView.css +58 -0
  92. package/front_end/panels/network/NetworkLogView.ts +2 -6
  93. package/front_end/panels/network/NetworkWaterfallColumn.ts +2 -4
  94. package/front_end/panels/network/components/RequestTrustTokensView.ts +40 -40
  95. package/front_end/panels/network/components/WebBundleInfoView.ts +9 -9
  96. package/front_end/panels/performance_monitor/PerformanceMonitor.ts +6 -12
  97. package/front_end/panels/settings/components/SyncSection.ts +14 -14
  98. package/front_end/panels/settings/emulation/components/UserAgentClientHintsForm.ts +96 -96
  99. package/front_end/panels/sources/BreakpointEditDialog.ts +4 -3
  100. package/front_end/panels/timeline/components/WebVitalsLane.ts +77 -76
  101. package/front_end/panels/timeline/components/WebVitalsTimeline.ts +133 -133
  102. package/front_end/panels/timeline/components/WebVitalsTooltip.ts +9 -9
  103. package/front_end/panels/webauthn/WebauthnPane.ts +203 -205
  104. package/front_end/ui/components/adorners/Adorner.ts +2 -2
  105. package/front_end/ui/components/buttons/Button.ts +9 -9
  106. package/front_end/ui/components/data_grid/DataGrid.ts +62 -62
  107. package/front_end/ui/components/data_grid/DataGridController.ts +22 -22
  108. package/front_end/ui/components/diff_view/DiffView.ts +6 -6
  109. package/front_end/ui/components/expandable_list/ExpandableList.ts +5 -5
  110. package/front_end/ui/components/icon_button/Icon.ts +4 -4
  111. package/front_end/ui/components/icon_button/IconButton.ts +4 -4
  112. package/front_end/ui/components/issue_counter/IssueCounter.ts +3 -3
  113. package/front_end/ui/components/issue_counter/IssueLinkIcon.ts +11 -11
  114. package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspector.ts +50 -50
  115. package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspectorController.ts +6 -6
  116. package/front_end/ui/components/linear_memory_inspector/LinearMemoryInspectorPane.ts +4 -4
  117. package/front_end/ui/components/linear_memory_inspector/LinearMemoryNavigator.ts +12 -12
  118. package/front_end/ui/components/linear_memory_inspector/LinearMemoryValueInterpreter.ts +11 -11
  119. package/front_end/ui/components/linear_memory_inspector/LinearMemoryViewer.ts +40 -39
  120. package/front_end/ui/components/linear_memory_inspector/ValueInterpreterDisplay.ts +18 -18
  121. package/front_end/ui/components/linear_memory_inspector/ValueInterpreterSettings.ts +6 -6
  122. package/front_end/ui/components/linkifier/LinkifierImpl.ts +4 -4
  123. package/front_end/ui/components/markdown_view/MarkdownImage.ts +5 -5
  124. package/front_end/ui/components/markdown_view/MarkdownLink.ts +2 -2
  125. package/front_end/ui/components/markdown_view/MarkdownView.ts +4 -4
  126. package/front_end/ui/components/panel_feedback/FeedbackButton.ts +2 -2
  127. package/front_end/ui/components/panel_feedback/PanelFeedback.ts +2 -2
  128. package/front_end/ui/components/panel_feedback/PreviewToggle.ts +4 -4
  129. package/front_end/ui/components/render_coordinator/RenderCoordinator.ts +22 -22
  130. package/front_end/ui/components/report_view/ReportView.ts +16 -16
  131. package/front_end/ui/components/request_link_icon/RequestLinkIcon.ts +14 -14
  132. package/front_end/ui/components/settings/SettingCheckbox.ts +5 -5
  133. package/front_end/ui/components/survey_link/SurveyLink.ts +8 -8
  134. package/front_end/ui/components/text_editor/TextEditor.ts +9 -9
  135. package/front_end/ui/components/text_prompt/TextPrompt.ts +18 -18
  136. package/front_end/ui/components/tree_outline/TreeOutline.ts +69 -70
  137. package/front_end/ui/legacy/themeColors.css +2 -0
  138. package/front_end/ui/legacy/theme_support/theme_support_impl.ts +12 -0
  139. package/package.json +1 -1
  140. package/scripts/eslint_rules/lib/use_private_class_members.js +41 -0
  141. package/scripts/eslint_rules/tests/use_private_class_members_test.js +62 -0
  142. package/scripts/migration/class-fields/migrate.js +2 -3
  143. package/scripts/migration/class-fields/migrate.sh +1 -3
  144. package/scripts/migration/class-fields/package.json +1 -1
@@ -139,6 +139,12 @@ module.exports = {
139
139
  }
140
140
  ]
141
141
  }
142
+ },
143
+ {
144
+ 'files': ['panels/**/components/*.ts', 'ui/components/**/*.ts'],
145
+ 'rules': {
146
+ 'rulesdir/use_private_class_members': 2,
147
+ }
142
148
  }
143
149
  ]
144
150
  };
@@ -34,28 +34,28 @@ export type TokenOrComment = Acorn.Token|Acorn.Comment;
34
34
  * out whether the next token should be the preceding comment or not.
35
35
  */
36
36
  export class AcornTokenizer {
37
- private readonly content: string;
38
- private readonly comments: Acorn.Comment[];
39
- private tokenizer: {
37
+ readonly #content: string;
38
+ readonly #comments: Acorn.Comment[];
39
+ #tokenizer: {
40
40
  getToken(): Acorn.Token,
41
41
  [Symbol.iterator](): Iterator<Acorn.Token>,
42
42
  };
43
- private textCursor: TextUtils.TextCursor.TextCursor;
44
- private tokenLineStartInternal: number;
45
- private tokenLineEndInternal: number;
46
- private tokenColumnStartInternal: number;
47
- private bufferedToken?: TokenOrComment;
43
+ #textCursor: TextUtils.TextCursor.TextCursor;
44
+ #tokenLineStartInternal: number;
45
+ #tokenLineEndInternal: number;
46
+ #tokenColumnStartInternal: number;
47
+ #bufferedToken?: TokenOrComment;
48
48
 
49
49
  constructor(content: string) {
50
- this.content = content;
51
- this.comments = [];
52
- this.tokenizer =
53
- Acorn.tokenizer(this.content, {onComment: this.comments, ecmaVersion: ECMA_VERSION, allowHashBang: true});
54
- const contentLineEndings = Platform.StringUtilities.findLineEndingIndexes(this.content);
55
- this.textCursor = new TextUtils.TextCursor.TextCursor(contentLineEndings);
56
- this.tokenLineStartInternal = 0;
57
- this.tokenLineEndInternal = 0;
58
- this.tokenColumnStartInternal = 0;
50
+ this.#content = content;
51
+ this.#comments = [];
52
+ this.#tokenizer =
53
+ Acorn.tokenizer(this.#content, {onComment: this.#comments, ecmaVersion: ECMA_VERSION, allowHashBang: true});
54
+ const contentLineEndings = Platform.StringUtilities.findLineEndingIndexes(this.#content);
55
+ this.#textCursor = new TextUtils.TextCursor.TextCursor(contentLineEndings);
56
+ this.#tokenLineStartInternal = 0;
57
+ this.#tokenLineEndInternal = 0;
58
+ this.#tokenColumnStartInternal = 0;
59
59
  // If the first "token" should be a comment, we don't want to shift
60
60
  // the comment from the array (which happens in `nextTokenInternal`).
61
61
  // Therefore, we should bail out from retrieving the token if this
@@ -65,7 +65,7 @@ export class AcornTokenizer {
65
65
  // themselves. In that case, we first retrieve the actual token, before
66
66
  // we see the comment itself. In that case, we should proceed and
67
67
  // initialize `bufferedToken` as normal, to allow us to fix the reordering.
68
- if (this.comments.length === 0) {
68
+ if (this.#comments.length === 0) {
69
69
  this.nextTokenInternal();
70
70
  }
71
71
  }
@@ -95,20 +95,20 @@ export class AcornTokenizer {
95
95
  }
96
96
 
97
97
  private nextTokenInternal(): TokenOrComment|undefined {
98
- if (this.comments.length) {
99
- const nextComment = this.comments.shift();
98
+ if (this.#comments.length) {
99
+ const nextComment = this.#comments.shift();
100
100
  // If this was the last comment to process, we need to make
101
101
  // sure to update our `bufferedToken` to become the actual
102
102
  // token. This only happens when we are processing the very
103
103
  // first comment of a file (usually a hashbang comment)
104
104
  // in which case we don't have to fix the reordering of tokens.
105
- if (!this.bufferedToken && this.comments.length === 0) {
106
- this.bufferedToken = this.tokenizer.getToken();
105
+ if (!this.#bufferedToken && this.#comments.length === 0) {
106
+ this.#bufferedToken = this.#tokenizer.getToken();
107
107
  }
108
108
  return nextComment;
109
109
  }
110
- const token = this.bufferedToken;
111
- this.bufferedToken = this.tokenizer.getToken();
110
+ const token = this.#bufferedToken;
111
+ this.#bufferedToken = this.#tokenizer.getToken();
112
112
  return token;
113
113
  }
114
114
 
@@ -118,35 +118,35 @@ export class AcornTokenizer {
118
118
  return null;
119
119
  }
120
120
 
121
- this.textCursor.advance(token.start);
122
- this.tokenLineStartInternal = this.textCursor.lineNumber();
123
- this.tokenColumnStartInternal = this.textCursor.columnNumber();
121
+ this.#textCursor.advance(token.start);
122
+ this.#tokenLineStartInternal = this.#textCursor.lineNumber();
123
+ this.#tokenColumnStartInternal = this.#textCursor.columnNumber();
124
124
 
125
- this.textCursor.advance(token.end);
126
- this.tokenLineEndInternal = this.textCursor.lineNumber();
125
+ this.#textCursor.advance(token.end);
126
+ this.#tokenLineEndInternal = this.#textCursor.lineNumber();
127
127
  return token;
128
128
  }
129
129
 
130
130
  peekToken(): TokenOrComment|null {
131
- if (this.comments.length) {
132
- return this.comments[0];
131
+ if (this.#comments.length) {
132
+ return this.#comments[0];
133
133
  }
134
- if (!this.bufferedToken) {
134
+ if (!this.#bufferedToken) {
135
135
  return null;
136
136
  }
137
- return this.bufferedToken.type !== Acorn.tokTypes.eof ? this.bufferedToken : null;
137
+ return this.#bufferedToken.type !== Acorn.tokTypes.eof ? this.#bufferedToken : null;
138
138
  }
139
139
 
140
140
  tokenLineStart(): number {
141
- return this.tokenLineStartInternal;
141
+ return this.#tokenLineStartInternal;
142
142
  }
143
143
 
144
144
  tokenLineEnd(): number {
145
- return this.tokenLineEndInternal;
145
+ return this.#tokenLineEndInternal;
146
146
  }
147
147
 
148
148
  tokenColumnStart(): number {
149
- return this.tokenColumnStartInternal;
149
+ return this.#tokenColumnStartInternal;
150
150
  }
151
151
  }
152
152
 
@@ -40,21 +40,21 @@ const cssTrimEnd = (tokenValue: string): string => {
40
40
  };
41
41
 
42
42
  export class CSSFormatter {
43
- private readonly builder: FormattedContentBuilder;
44
- private toOffset!: number;
45
- private fromOffset!: number;
46
- private lineEndings!: number[];
47
- private lastLine: number;
48
- private state: {
43
+ readonly #builder: FormattedContentBuilder;
44
+ #toOffset!: number;
45
+ #fromOffset!: number;
46
+ #lineEndings!: number[];
47
+ #lastLine: number;
48
+ #state: {
49
49
  eatWhitespace: (boolean|undefined),
50
50
  seenProperty: (boolean|undefined),
51
51
  inPropertyValue: (boolean|undefined),
52
52
  afterClosingBrace: (boolean|undefined),
53
53
  };
54
54
  constructor(builder: FormattedContentBuilder) {
55
- this.builder = builder;
56
- this.lastLine = -1;
57
- this.state = {
55
+ this.#builder = builder;
56
+ this.#lastLine = -1;
57
+ this.#state = {
58
58
  eatWhitespace: undefined,
59
59
  seenProperty: undefined,
60
60
  inPropertyValue: undefined,
@@ -63,84 +63,84 @@ export class CSSFormatter {
63
63
  }
64
64
 
65
65
  format(text: string, lineEndings: number[], fromOffset: number, toOffset: number): void {
66
- this.lineEndings = lineEndings;
67
- this.fromOffset = fromOffset;
68
- this.toOffset = toOffset;
69
- this.state = {
66
+ this.#lineEndings = lineEndings;
67
+ this.#fromOffset = fromOffset;
68
+ this.#toOffset = toOffset;
69
+ this.#state = {
70
70
  eatWhitespace: undefined,
71
71
  seenProperty: undefined,
72
72
  inPropertyValue: undefined,
73
73
  afterClosingBrace: undefined,
74
74
  };
75
- this.lastLine = -1;
75
+ this.#lastLine = -1;
76
76
  const tokenize = createTokenizer('text/css');
77
- const oldEnforce = this.builder.setEnforceSpaceBetweenWords(false);
78
- tokenize(text.substring(this.fromOffset, this.toOffset), this.tokenCallback.bind(this));
79
- this.builder.setEnforceSpaceBetweenWords(oldEnforce);
77
+ const oldEnforce = this.#builder.setEnforceSpaceBetweenWords(false);
78
+ tokenize(text.substring(this.#fromOffset, this.#toOffset), this.tokenCallback.bind(this));
79
+ this.#builder.setEnforceSpaceBetweenWords(oldEnforce);
80
80
  }
81
81
 
82
82
  private tokenCallback(token: string, type: string|null, startPosition: number): void {
83
- startPosition += this.fromOffset;
84
- const startLine =
85
- Platform.ArrayUtilities.lowerBound(this.lineEndings, startPosition, Platform.ArrayUtilities.DEFAULT_COMPARATOR);
86
- if (startLine !== this.lastLine) {
87
- this.state.eatWhitespace = true;
83
+ startPosition += this.#fromOffset;
84
+ const startLine = Platform.ArrayUtilities.lowerBound(
85
+ this.#lineEndings, startPosition, Platform.ArrayUtilities.DEFAULT_COMPARATOR);
86
+ if (startLine !== this.#lastLine) {
87
+ this.#state.eatWhitespace = true;
88
88
  }
89
- if (type && (/^property/.test(type) || /^variable-2/.test(type)) && !this.state.inPropertyValue) {
90
- this.state.seenProperty = true;
89
+ if (type && (/^property/.test(type) || /^variable-2/.test(type)) && !this.#state.inPropertyValue) {
90
+ this.#state.seenProperty = true;
91
91
  }
92
- this.lastLine = startLine;
92
+ this.#lastLine = startLine;
93
93
  // https://drafts.csswg.org/css-syntax/#whitespace
94
94
  const isWhitespace = /^(?:\r?\n|[\t\f\r ])+$/.test(token);
95
95
  if (isWhitespace) {
96
- if (!this.state.eatWhitespace) {
97
- this.builder.addSoftSpace();
96
+ if (!this.#state.eatWhitespace) {
97
+ this.#builder.addSoftSpace();
98
98
  }
99
99
  return;
100
100
  }
101
- this.state.eatWhitespace = false;
101
+ this.#state.eatWhitespace = false;
102
102
  if (token === '\n') {
103
103
  return;
104
104
  }
105
105
 
106
106
  if (token !== '}') {
107
- if (this.state.afterClosingBrace) {
108
- this.builder.addNewLine(true);
107
+ if (this.#state.afterClosingBrace) {
108
+ this.#builder.addNewLine(true);
109
109
  }
110
- this.state.afterClosingBrace = false;
110
+ this.#state.afterClosingBrace = false;
111
111
  }
112
112
  if (token === '}') {
113
- if (this.state.inPropertyValue) {
114
- this.builder.addNewLine();
113
+ if (this.#state.inPropertyValue) {
114
+ this.#builder.addNewLine();
115
115
  }
116
- this.builder.decreaseNestingLevel();
117
- this.state.afterClosingBrace = true;
118
- this.state.inPropertyValue = false;
119
- } else if (token === ':' && !this.state.inPropertyValue && this.state.seenProperty) {
120
- this.builder.addToken(token, startPosition);
121
- this.builder.addSoftSpace();
122
- this.state.eatWhitespace = true;
123
- this.state.inPropertyValue = true;
124
- this.state.seenProperty = false;
116
+ this.#builder.decreaseNestingLevel();
117
+ this.#state.afterClosingBrace = true;
118
+ this.#state.inPropertyValue = false;
119
+ } else if (token === ':' && !this.#state.inPropertyValue && this.#state.seenProperty) {
120
+ this.#builder.addToken(token, startPosition);
121
+ this.#builder.addSoftSpace();
122
+ this.#state.eatWhitespace = true;
123
+ this.#state.inPropertyValue = true;
124
+ this.#state.seenProperty = false;
125
125
  return;
126
126
  } else if (token === '{') {
127
- this.builder.addSoftSpace();
128
- this.builder.addToken(token, startPosition);
129
- this.builder.addNewLine();
130
- this.builder.increaseNestingLevel();
127
+ this.#builder.addSoftSpace();
128
+ this.#builder.addToken(token, startPosition);
129
+ this.#builder.addNewLine();
130
+ this.#builder.increaseNestingLevel();
131
131
  return;
132
132
  }
133
133
 
134
- this.builder.addToken(cssTrimEnd(token), startPosition);
134
+ this.#builder.addToken(cssTrimEnd(token), startPosition);
135
135
 
136
- if (type === 'comment' && !this.state.inPropertyValue && !this.state.seenProperty) {
137
- this.builder.addNewLine();
136
+ if (type === 'comment' && !this.#state.inPropertyValue && !this.#state.seenProperty) {
137
+ this.#builder.addNewLine();
138
138
  }
139
- if (token === ';' && this.state.inPropertyValue) {
140
- this.state.inPropertyValue = false;
141
- this.builder.addNewLine();
139
+ if (token === ';' && this.#state.inPropertyValue) {
140
+ this.#state.inPropertyValue = false;
141
+ this.#builder.addNewLine();
142
142
  } else if (token === '}') {
143
- this.builder.addNewLine();
143
+ this.#builder.addNewLine();
144
144
  }
145
145
  }
146
146
  }
@@ -7,16 +7,16 @@ import type * as Acorn from '../../third_party/acorn/acorn.js';
7
7
  const SkipSubTreeObject: Object = {};
8
8
 
9
9
  export class ESTreeWalker {
10
- private readonly beforeVisit: (arg0: Acorn.ESTree.Node) => (Object | undefined);
11
- private readonly afterVisit: Function;
12
- private walkNulls: boolean;
10
+ readonly #beforeVisit: (arg0: Acorn.ESTree.Node) => (Object | undefined);
11
+ readonly #afterVisit: Function;
12
+ #walkNulls: boolean;
13
13
 
14
14
  constructor(
15
15
  beforeVisit: (arg0: Acorn.ESTree.Node) => (Object | undefined),
16
16
  afterVisit?: ((arg0: Acorn.ESTree.Node) => void)) {
17
- this.beforeVisit = beforeVisit;
18
- this.afterVisit = afterVisit || function(): void {};
19
- this.walkNulls = false;
17
+ this.#beforeVisit = beforeVisit;
18
+ this.#afterVisit = afterVisit || function(): void {};
19
+ this.#walkNulls = false;
20
20
  }
21
21
 
22
22
  // TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration
@@ -26,7 +26,7 @@ export class ESTreeWalker {
26
26
  }
27
27
 
28
28
  setWalkNulls(value: boolean): void {
29
- this.walkNulls = value;
29
+ this.#walkNulls = value;
30
30
  }
31
31
 
32
32
  walk(ast: Acorn.ESTree.Node): void {
@@ -34,7 +34,7 @@ export class ESTreeWalker {
34
34
  }
35
35
 
36
36
  private innerWalk(node: Acorn.ESTree.Node, parent: Acorn.ESTree.Node|null): void {
37
- if (!node && parent && this.walkNulls) {
37
+ if (!node && parent && this.#walkNulls) {
38
38
  const result = ({raw: 'null', value: null, parent: null} as Acorn.ESTree.SimpleLiteral);
39
39
  // Otherwise Closure can't handle the definition
40
40
  result.type = 'Literal';
@@ -47,8 +47,8 @@ export class ESTreeWalker {
47
47
  }
48
48
  node.parent = parent;
49
49
 
50
- if (this.beforeVisit.call(null, node) === ESTreeWalker.SkipSubtree) {
51
- this.afterVisit.call(null, node);
50
+ if (this.#beforeVisit.call(null, node) === ESTreeWalker.SkipSubtree) {
51
+ this.#afterVisit.call(null, node);
52
52
  return;
53
53
  }
54
54
 
@@ -82,7 +82,7 @@ export class ESTreeWalker {
82
82
  }
83
83
  }
84
84
 
85
- this.afterVisit.call(null, node);
85
+ this.#afterVisit.call(null, node);
86
86
  }
87
87
 
88
88
  private walkArray(nodeArray: Acorn.ESTree.Node[], parentNode: Acorn.ESTree.Node|null): void {
@@ -3,16 +3,16 @@
3
3
  // found in the LICENSE file.
4
4
 
5
5
  export class FormattedContentBuilder {
6
- private lastOriginalPosition = 0;
7
- private formattedContent: string[] = [];
8
- private formattedContentLength = 0;
9
- private lastFormattedPosition = 0;
10
- private nestingLevel = 0;
11
- private newLines = 0;
12
- private enforceSpaceBetweenWords = true;
13
- private softSpace = false;
14
- private hardSpaces = 0;
15
- private cachedIndents = new Map<number, string>();
6
+ #lastOriginalPosition = 0;
7
+ #formattedContent: string[] = [];
8
+ #formattedContentLength = 0;
9
+ #lastFormattedPosition = 0;
10
+ #nestingLevel = 0;
11
+ #newLines = 0;
12
+ #enforceSpaceBetweenWords = true;
13
+ #softSpace = false;
14
+ #hardSpaces = 0;
15
+ #cachedIndents = new Map<number, string>();
16
16
 
17
17
  mapping = {original: [0], formatted: [0]};
18
18
 
@@ -20,14 +20,14 @@ export class FormattedContentBuilder {
20
20
  }
21
21
 
22
22
  setEnforceSpaceBetweenWords(value: boolean): boolean {
23
- const oldValue = this.enforceSpaceBetweenWords;
24
- this.enforceSpaceBetweenWords = value;
23
+ const oldValue = this.#enforceSpaceBetweenWords;
24
+ this.#enforceSpaceBetweenWords = value;
25
25
  return oldValue;
26
26
  }
27
27
 
28
28
  addToken(token: string, offset: number): void {
29
- const last = this.formattedContent[this.formattedContent.length - 1];
30
- if (this.enforceSpaceBetweenWords && last && /\w/.test(last[last.length - 1]) && /\w/.test(token)) {
29
+ const last = this.#formattedContent[this.#formattedContent.length - 1];
30
+ if (this.#enforceSpaceBetweenWords && last && /\w/.test(last[last.length - 1]) && /\w/.test(token)) {
31
31
  this.addSoftSpace();
32
32
  }
33
33
 
@@ -39,91 +39,91 @@ export class FormattedContentBuilder {
39
39
  }
40
40
 
41
41
  addSoftSpace(): void {
42
- if (!this.hardSpaces) {
43
- this.softSpace = true;
42
+ if (!this.#hardSpaces) {
43
+ this.#softSpace = true;
44
44
  }
45
45
  }
46
46
 
47
47
  addHardSpace(): void {
48
- this.softSpace = false;
49
- ++this.hardSpaces;
48
+ this.#softSpace = false;
49
+ ++this.#hardSpaces;
50
50
  }
51
51
 
52
52
  addNewLine(noSquash?: boolean): void {
53
53
  // Avoid leading newlines.
54
- if (!this.formattedContentLength) {
54
+ if (!this.#formattedContentLength) {
55
55
  return;
56
56
  }
57
57
  if (noSquash) {
58
- ++this.newLines;
58
+ ++this.#newLines;
59
59
  } else {
60
- this.newLines = this.newLines || 1;
60
+ this.#newLines = this.#newLines || 1;
61
61
  }
62
62
  }
63
63
 
64
64
  increaseNestingLevel(): void {
65
- this.nestingLevel += 1;
65
+ this.#nestingLevel += 1;
66
66
  }
67
67
 
68
68
  decreaseNestingLevel(): void {
69
- if (this.nestingLevel > 0) {
70
- this.nestingLevel -= 1;
69
+ if (this.#nestingLevel > 0) {
70
+ this.#nestingLevel -= 1;
71
71
  }
72
72
  }
73
73
 
74
74
  content(): string {
75
- return this.formattedContent.join('') + (this.newLines ? '\n' : '');
75
+ return this.#formattedContent.join('') + (this.#newLines ? '\n' : '');
76
76
  }
77
77
 
78
78
  private appendFormatting(): void {
79
- if (this.newLines) {
80
- for (let i = 0; i < this.newLines; ++i) {
79
+ if (this.#newLines) {
80
+ for (let i = 0; i < this.#newLines; ++i) {
81
81
  this.addText('\n');
82
82
  }
83
83
  this.addText(this.indent());
84
- } else if (this.softSpace) {
84
+ } else if (this.#softSpace) {
85
85
  this.addText(' ');
86
86
  }
87
- if (this.hardSpaces) {
88
- for (let i = 0; i < this.hardSpaces; ++i) {
87
+ if (this.#hardSpaces) {
88
+ for (let i = 0; i < this.#hardSpaces; ++i) {
89
89
  this.addText(' ');
90
90
  }
91
91
  }
92
- this.newLines = 0;
93
- this.softSpace = false;
94
- this.hardSpaces = 0;
92
+ this.#newLines = 0;
93
+ this.#softSpace = false;
94
+ this.#hardSpaces = 0;
95
95
  }
96
96
 
97
97
  private indent(): string {
98
- const cachedValue = this.cachedIndents.get(this.nestingLevel);
98
+ const cachedValue = this.#cachedIndents.get(this.#nestingLevel);
99
99
  if (cachedValue) {
100
100
  return cachedValue;
101
101
  }
102
102
 
103
103
  let fullIndent = '';
104
- for (let i = 0; i < this.nestingLevel; ++i) {
104
+ for (let i = 0; i < this.#nestingLevel; ++i) {
105
105
  fullIndent += this.indentString;
106
106
  }
107
107
 
108
108
  // Cache a maximum of 20 nesting level indents.
109
- if (this.nestingLevel <= 20) {
110
- this.cachedIndents.set(this.nestingLevel, fullIndent);
109
+ if (this.#nestingLevel <= 20) {
110
+ this.#cachedIndents.set(this.#nestingLevel, fullIndent);
111
111
  }
112
112
  return fullIndent;
113
113
  }
114
114
 
115
115
  private addText(text: string): void {
116
- this.formattedContent.push(text);
117
- this.formattedContentLength += text.length;
116
+ this.#formattedContent.push(text);
117
+ this.#formattedContentLength += text.length;
118
118
  }
119
119
 
120
120
  private addMappingIfNeeded(originalPosition: number): void {
121
- if (originalPosition - this.lastOriginalPosition === this.formattedContentLength - this.lastFormattedPosition) {
121
+ if (originalPosition - this.#lastOriginalPosition === this.#formattedContentLength - this.#lastFormattedPosition) {
122
122
  return;
123
123
  }
124
124
  this.mapping.original.push(originalPosition);
125
- this.lastOriginalPosition = originalPosition;
126
- this.mapping.formatted.push(this.formattedContentLength);
127
- this.lastFormattedPosition = this.formattedContentLength;
125
+ this.#lastOriginalPosition = originalPosition;
126
+ this.mapping.formatted.push(this.#formattedContentLength);
127
+ this.#lastFormattedPosition = this.#formattedContentLength;
128
128
  }
129
129
  }