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
@@ -10,36 +10,36 @@ import {AbortTokenization, createTokenizer} from './FormatterWorker.js';
10
10
  import {JavaScriptFormatter} from './JavaScriptFormatter.js';
11
11
 
12
12
  export class HTMLFormatter {
13
- private readonly builder: FormattedContentBuilder;
14
- private readonly jsFormatter: JavaScriptFormatter;
15
- private readonly cssFormatter: CSSFormatter;
16
- private text?: string;
17
- private lineEndings?: number[];
18
- private model?: HTMLModel;
13
+ readonly #builder: FormattedContentBuilder;
14
+ readonly #jsFormatter: JavaScriptFormatter;
15
+ readonly #cssFormatter: CSSFormatter;
16
+ #text?: string;
17
+ #lineEndings?: number[];
18
+ #model?: HTMLModel;
19
19
 
20
20
  constructor(builder: FormattedContentBuilder) {
21
- this.builder = builder;
22
- this.jsFormatter = new JavaScriptFormatter(builder);
23
- this.cssFormatter = new CSSFormatter(builder);
21
+ this.#builder = builder;
22
+ this.#jsFormatter = new JavaScriptFormatter(builder);
23
+ this.#cssFormatter = new CSSFormatter(builder);
24
24
  }
25
25
 
26
26
  format(text: string, lineEndings: number[]): void {
27
- this.text = text;
28
- this.lineEndings = lineEndings;
29
- this.model = new HTMLModel(text);
30
- this.walk(this.model.document());
27
+ this.#text = text;
28
+ this.#lineEndings = lineEndings;
29
+ this.#model = new HTMLModel(text);
30
+ this.walk(this.#model.document());
31
31
  }
32
32
 
33
33
  private formatTokensTill(element: FormatterElement, offset: number): void {
34
- if (!this.model) {
34
+ if (!this.#model) {
35
35
  return;
36
36
  }
37
37
 
38
- let nextToken = this.model.peekToken();
38
+ let nextToken = this.#model.peekToken();
39
39
  while (nextToken && nextToken.startOffset < offset) {
40
- const token = (this.model.nextToken() as Token);
40
+ const token = (this.#model.nextToken() as Token);
41
41
  this.formatToken(element, token);
42
- nextToken = this.model.peekToken();
42
+ nextToken = this.#model.peekToken();
43
43
  }
44
44
  }
45
45
 
@@ -65,42 +65,42 @@ export class HTMLFormatter {
65
65
  }
66
66
 
67
67
  private beforeOpenTag(element: FormatterElement): void {
68
- if (!this.model) {
68
+ if (!this.#model) {
69
69
  return;
70
70
  }
71
71
 
72
- if (!element.children.length || element === this.model.document()) {
72
+ if (!element.children.length || element === this.#model.document()) {
73
73
  return;
74
74
  }
75
- this.builder.addNewLine();
75
+ this.#builder.addNewLine();
76
76
  }
77
77
 
78
78
  private afterOpenTag(element: FormatterElement): void {
79
- if (!this.model) {
79
+ if (!this.#model) {
80
80
  return;
81
81
  }
82
82
 
83
- if (!element.children.length || element === this.model.document()) {
83
+ if (!element.children.length || element === this.#model.document()) {
84
84
  return;
85
85
  }
86
- this.builder.increaseNestingLevel();
87
- this.builder.addNewLine();
86
+ this.#builder.increaseNestingLevel();
87
+ this.#builder.addNewLine();
88
88
  }
89
89
 
90
90
  private beforeCloseTag(element: FormatterElement): void {
91
- if (!this.model) {
91
+ if (!this.#model) {
92
92
  return;
93
93
  }
94
94
 
95
- if (!element.children.length || element === this.model.document()) {
95
+ if (!element.children.length || element === this.#model.document()) {
96
96
  return;
97
97
  }
98
- this.builder.decreaseNestingLevel();
99
- this.builder.addNewLine();
98
+ this.#builder.decreaseNestingLevel();
99
+ this.#builder.addNewLine();
100
100
  }
101
101
 
102
102
  private afterCloseTag(_element: FormatterElement): void {
103
- this.builder.addNewLine();
103
+ this.#builder.addNewLine();
104
104
  }
105
105
 
106
106
  private formatToken(element: FormatterElement, token: Token): void {
@@ -108,9 +108,9 @@ export class HTMLFormatter {
108
108
  return;
109
109
  }
110
110
  if (hasTokenInSet(token.type, 'comment') || hasTokenInSet(token.type, 'meta')) {
111
- this.builder.addNewLine();
112
- this.builder.addToken(token.value.trim(), token.startOffset);
113
- this.builder.addNewLine();
111
+ this.#builder.addNewLine();
112
+ this.#builder.addToken(token.value.trim(), token.startOffset);
113
+ this.#builder.addNewLine();
114
114
  return;
115
115
  }
116
116
 
@@ -121,30 +121,30 @@ export class HTMLFormatter {
121
121
  const isBodyToken =
122
122
  element.openTag.endOffset <= token.startOffset && token.startOffset < element.closeTag.startOffset;
123
123
  if (isBodyToken && element.name === 'style') {
124
- this.builder.addNewLine();
125
- this.builder.increaseNestingLevel();
126
- this.cssFormatter.format(this.text || '', this.lineEndings || [], token.startOffset, token.endOffset);
127
- this.builder.decreaseNestingLevel();
124
+ this.#builder.addNewLine();
125
+ this.#builder.increaseNestingLevel();
126
+ this.#cssFormatter.format(this.#text || '', this.#lineEndings || [], token.startOffset, token.endOffset);
127
+ this.#builder.decreaseNestingLevel();
128
128
  return;
129
129
  }
130
130
  if (isBodyToken && element.name === 'script') {
131
- this.builder.addNewLine();
132
- this.builder.increaseNestingLevel();
131
+ this.#builder.addNewLine();
132
+ this.#builder.increaseNestingLevel();
133
133
  if (this.scriptTagIsJavaScript(element)) {
134
- this.jsFormatter.format(this.text || '', this.lineEndings || [], token.startOffset, token.endOffset);
134
+ this.#jsFormatter.format(this.#text || '', this.#lineEndings || [], token.startOffset, token.endOffset);
135
135
  } else {
136
- this.builder.addToken(token.value, token.startOffset);
137
- this.builder.addNewLine();
136
+ this.#builder.addToken(token.value, token.startOffset);
137
+ this.#builder.addNewLine();
138
138
  }
139
- this.builder.decreaseNestingLevel();
139
+ this.#builder.decreaseNestingLevel();
140
140
  return;
141
141
  }
142
142
 
143
143
  if (!isBodyToken && hasTokenInSet(token.type, 'attribute')) {
144
- this.builder.addSoftSpace();
144
+ this.#builder.addSoftSpace();
145
145
  }
146
146
 
147
- this.builder.addToken(token.value, token.startOffset);
147
+ this.#builder.addToken(token.value, token.startOffset);
148
148
  }
149
149
 
150
150
  private scriptTagIsJavaScript(element: FormatterElement): boolean {
@@ -200,34 +200,34 @@ function hasTokenInSet(tokenTypes: Set<string>, type: string): boolean {
200
200
  }
201
201
 
202
202
  export class HTMLModel {
203
- private state: ParseState;
204
- private readonly documentInternal: FormatterElement;
205
- private stack: FormatterElement[];
206
- private readonly tokens: Token[];
207
- private tokenIndex: number;
208
- private attributes: Map<string, string>;
209
- private attributeName: string;
210
- private tagName: string;
211
- private isOpenTag: boolean;
212
- private tagStartOffset?: number|null;
213
- private tagEndOffset?: number|null;
203
+ #state: ParseState;
204
+ readonly #documentInternal: FormatterElement;
205
+ #stack: FormatterElement[];
206
+ readonly #tokens: Token[];
207
+ #tokenIndex: number;
208
+ #attributes: Map<string, string>;
209
+ #attributeName: string;
210
+ #tagName: string;
211
+ #isOpenTag: boolean;
212
+ #tagStartOffset?: number|null;
213
+ #tagEndOffset?: number|null;
214
214
 
215
215
  constructor(text: string) {
216
- this.state = ParseState.Initial;
217
- this.documentInternal = new FormatterElement('document');
218
- this.documentInternal.openTag = new Tag('document', 0, 0, new Map(), true, false);
219
- this.documentInternal.closeTag = new Tag('document', text.length, text.length, new Map(), false, false);
216
+ this.#state = ParseState.Initial;
217
+ this.#documentInternal = new FormatterElement('document');
218
+ this.#documentInternal.openTag = new Tag('document', 0, 0, new Map(), true, false);
219
+ this.#documentInternal.closeTag = new Tag('document', text.length, text.length, new Map(), false, false);
220
220
 
221
- this.stack = [this.documentInternal];
221
+ this.#stack = [this.#documentInternal];
222
222
 
223
- this.tokens = [];
224
- this.tokenIndex = 0;
223
+ this.#tokens = [];
224
+ this.#tokenIndex = 0;
225
225
  this.build(text);
226
226
 
227
- this.attributes = new Map();
228
- this.attributeName = '';
229
- this.tagName = '';
230
- this.isOpenTag = false;
227
+ this.#attributes = new Map();
228
+ this.#attributeName = '';
229
+ this.#tagName = '';
230
+ this.#isOpenTag = false;
231
231
  }
232
232
 
233
233
  private build(text: string): void {
@@ -240,7 +240,7 @@ export class HTMLModel {
240
240
  if (lastOffset >= text.length) {
241
241
  break;
242
242
  }
243
- const element = this.stack[this.stack.length - 1];
243
+ const element = this.#stack[this.#stack.length - 1];
244
244
  if (!element) {
245
245
  break;
246
246
  }
@@ -257,11 +257,11 @@ export class HTMLModel {
257
257
  const tokenStart = element.openTag.endOffset;
258
258
  const tokenEnd = lastOffset;
259
259
  const tokenValue = text.substring(tokenStart, tokenEnd);
260
- this.tokens.push(new Token(tokenValue, new Set(), tokenStart, tokenEnd));
260
+ this.#tokens.push(new Token(tokenValue, new Set(), tokenStart, tokenEnd));
261
261
  }
262
262
 
263
- while (this.stack.length > 1) {
264
- const element = this.stack[this.stack.length - 1];
263
+ while (this.#stack.length > 1) {
264
+ const element = this.#stack[this.#stack.length - 1];
265
265
  if (!element) {
266
266
  break;
267
267
  }
@@ -278,10 +278,10 @@ export class HTMLModel {
278
278
 
279
279
  const tokenType = type ? new Set<string>(type.split(' ')) : new Set<string>();
280
280
  const token = new Token(tokenValue, tokenType, tokenStart, tokenEnd);
281
- this.tokens.push(token);
281
+ this.#tokens.push(token);
282
282
  this.updateDOM(token);
283
283
 
284
- const element = this.stack[this.stack.length - 1];
284
+ const element = this.#stack[this.#stack.length - 1];
285
285
  if (element && (element.name === 'script' || element.name === 'style') && element.openTag &&
286
286
  element.openTag.endOffset === lastOffset) {
287
287
  return AbortTokenization;
@@ -294,68 +294,69 @@ export class HTMLModel {
294
294
  private updateDOM(token: Token): void {
295
295
  const value = token.value;
296
296
  const type = token.type;
297
- switch (this.state) {
297
+ switch (this.#state) {
298
298
  case ParseState.Initial:
299
299
  if (hasTokenInSet(type, 'bracket') && (value === '<' || value === '</')) {
300
300
  this.onStartTag(token);
301
- this.state = ParseState.Tag;
301
+ this.#state = ParseState.Tag;
302
302
  }
303
303
  return;
304
304
  case ParseState.Tag:
305
305
  if (hasTokenInSet(type, 'tag') && !hasTokenInSet(type, 'bracket')) {
306
- this.tagName = value.trim().toLowerCase();
306
+ this.#tagName = value.trim().toLowerCase();
307
307
  } else if (hasTokenInSet(type, 'attribute')) {
308
- this.attributeName = value.trim().toLowerCase();
309
- this.attributes.set(this.attributeName, '');
310
- this.state = ParseState.AttributeName;
308
+ this.#attributeName = value.trim().toLowerCase();
309
+ this.#attributes.set(this.#attributeName, '');
310
+ this.#state = ParseState.AttributeName;
311
311
  } else if (hasTokenInSet(type, 'bracket') && (value === '>' || value === '/>')) {
312
312
  this.onEndTag(token);
313
- this.state = ParseState.Initial;
313
+ this.#state = ParseState.Initial;
314
314
  }
315
315
  return;
316
316
  case ParseState.AttributeName:
317
317
  if (!type.size && value === '=') {
318
- this.state = ParseState.AttributeValue;
318
+ this.#state = ParseState.AttributeValue;
319
319
  } else if (hasTokenInSet(type, 'bracket') && (value === '>' || value === '/>')) {
320
320
  this.onEndTag(token);
321
- this.state = ParseState.Initial;
321
+ this.#state = ParseState.Initial;
322
322
  }
323
323
  return;
324
324
  case ParseState.AttributeValue:
325
325
  if (hasTokenInSet(type, 'string')) {
326
- this.attributes.set(this.attributeName, value);
327
- this.state = ParseState.Tag;
326
+ this.#attributes.set(this.#attributeName, value);
327
+ this.#state = ParseState.Tag;
328
328
  } else if (hasTokenInSet(type, 'bracket') && (value === '>' || value === '/>')) {
329
329
  this.onEndTag(token);
330
- this.state = ParseState.Initial;
330
+ this.#state = ParseState.Initial;
331
331
  }
332
332
  return;
333
333
  }
334
334
  }
335
335
 
336
336
  private onStartTag(token: Token): void {
337
- this.tagName = '';
338
- this.tagStartOffset = token.startOffset;
339
- this.tagEndOffset = null;
340
- this.attributes = new Map();
341
- this.attributeName = '';
342
- this.isOpenTag = token.value === '<';
337
+ this.#tagName = '';
338
+ this.#tagStartOffset = token.startOffset;
339
+ this.#tagEndOffset = null;
340
+ this.#attributes = new Map();
341
+ this.#attributeName = '';
342
+ this.#isOpenTag = token.value === '<';
343
343
  }
344
344
 
345
345
  private onEndTag(token: Token): void {
346
- this.tagEndOffset = token.endOffset;
347
- const selfClosingTag = token.value === '/>' || SelfClosingTags.has(this.tagName);
346
+ this.#tagEndOffset = token.endOffset;
347
+ const selfClosingTag = token.value === '/>' || SelfClosingTags.has(this.#tagName);
348
348
  const tag = new Tag(
349
- this.tagName, this.tagStartOffset || 0, this.tagEndOffset, this.attributes, this.isOpenTag, selfClosingTag);
349
+ this.#tagName, this.#tagStartOffset || 0, this.#tagEndOffset, this.#attributes, this.#isOpenTag,
350
+ selfClosingTag);
350
351
  this.onTagComplete(tag);
351
352
  }
352
353
 
353
354
  private onTagComplete(tag: Tag): void {
354
355
  if (tag.isOpenTag) {
355
- const topElement = this.stack[this.stack.length - 1];
356
+ const topElement = this.#stack[this.#stack.length - 1];
356
357
  if (topElement) {
357
358
  const tagSet = AutoClosingTags.get(topElement.name);
358
- if (topElement !== this.documentInternal && topElement.openTag && topElement.openTag.selfClosingTag) {
359
+ if (topElement !== this.#documentInternal && topElement.openTag && topElement.openTag.selfClosingTag) {
359
360
  this.popElement(autocloseTag(topElement, topElement.openTag.endOffset));
360
361
  } else if (tagSet && tagSet.has(tag.name)) {
361
362
  this.popElement(autocloseTag(topElement, tag.startOffset));
@@ -365,12 +366,12 @@ export class HTMLModel {
365
366
  return;
366
367
  }
367
368
 
368
- let lastTag = this.stack[this.stack.length - 1];
369
- while (this.stack.length > 1 && lastTag && lastTag.name !== tag.name) {
369
+ let lastTag = this.#stack[this.#stack.length - 1];
370
+ while (this.#stack.length > 1 && lastTag && lastTag.name !== tag.name) {
370
371
  this.popElement(autocloseTag(lastTag, tag.startOffset));
371
- lastTag = this.stack[this.stack.length - 1];
372
+ lastTag = this.#stack[this.#stack.length - 1];
372
373
  }
373
- if (this.stack.length === 1) {
374
+ if (this.#stack.length === 1) {
374
375
  return;
375
376
  }
376
377
  this.popElement(tag);
@@ -381,7 +382,7 @@ export class HTMLModel {
381
382
  }
382
383
 
383
384
  private popElement(closeTag: Tag): void {
384
- const element = this.stack.pop();
385
+ const element = this.#stack.pop();
385
386
  if (!element) {
386
387
  return;
387
388
  }
@@ -389,26 +390,26 @@ export class HTMLModel {
389
390
  }
390
391
 
391
392
  private pushElement(openTag: Tag): void {
392
- const topElement = this.stack[this.stack.length - 1];
393
+ const topElement = this.#stack[this.#stack.length - 1];
393
394
  const newElement = new FormatterElement(openTag.name);
394
395
  if (topElement) {
395
396
  newElement.parent = topElement;
396
397
  topElement.children.push(newElement);
397
398
  }
398
399
  newElement.openTag = openTag;
399
- this.stack.push(newElement);
400
+ this.#stack.push(newElement);
400
401
  }
401
402
 
402
403
  peekToken(): Token|null {
403
- return this.tokenIndex < this.tokens.length ? this.tokens[this.tokenIndex] : null;
404
+ return this.#tokenIndex < this.#tokens.length ? this.#tokens[this.#tokenIndex] : null;
404
405
  }
405
406
 
406
407
  nextToken(): Token|null {
407
- return this.tokens[this.tokenIndex++];
408
+ return this.#tokens[this.#tokenIndex++];
408
409
  }
409
410
 
410
411
  document(): FormatterElement {
411
- return this.documentInternal;
412
+ return this.#documentInternal;
412
413
  }
413
414
  }
414
415
 
@@ -36,23 +36,23 @@ import {ESTreeWalker} from './ESTreeWalker.js';
36
36
  import type {FormattedContentBuilder} from './FormattedContentBuilder.js';
37
37
 
38
38
  export class JavaScriptFormatter {
39
- private readonly builder: FormattedContentBuilder;
40
- private tokenizer!: AcornTokenizer;
41
- private content!: string;
42
- private fromOffset!: number;
43
- private lastLineNumber!: number;
44
- private toOffset?: number;
39
+ readonly #builder: FormattedContentBuilder;
40
+ #tokenizer!: AcornTokenizer;
41
+ #content!: string;
42
+ #fromOffset!: number;
43
+ #lastLineNumber!: number;
44
+ #toOffset?: number;
45
45
  constructor(builder: FormattedContentBuilder) {
46
- this.builder = builder;
46
+ this.#builder = builder;
47
47
  }
48
48
 
49
49
  format(text: string, lineEndings: number[], fromOffset: number, toOffset: number): void {
50
- this.fromOffset = fromOffset;
51
- this.toOffset = toOffset;
52
- this.content = text.substring(this.fromOffset, this.toOffset);
53
- this.lastLineNumber = 0;
54
- this.tokenizer = new AcornTokenizer(this.content);
55
- const ast = Acorn.parse(this.content, {
50
+ this.#fromOffset = fromOffset;
51
+ this.#toOffset = toOffset;
52
+ this.#content = text.substring(this.#fromOffset, this.#toOffset);
53
+ this.#lastLineNumber = 0;
54
+ this.#tokenizer = new AcornTokenizer(this.#content);
55
+ const ast = Acorn.parse(this.#content, {
56
56
  ranges: false,
57
57
  preserveParens: true,
58
58
  allowImportExportEverywhere: true,
@@ -70,22 +70,22 @@ export class JavaScriptFormatter {
70
70
  private push(token: Acorn.Token|Acorn.Comment|null, format: string): void {
71
71
  for (let i = 0; i < format.length; ++i) {
72
72
  if (format[i] === 's') {
73
- this.builder.addSoftSpace();
73
+ this.#builder.addSoftSpace();
74
74
  } else if (format[i] === 'S') {
75
- this.builder.addHardSpace();
75
+ this.#builder.addHardSpace();
76
76
  } else if (format[i] === 'n') {
77
- this.builder.addNewLine();
77
+ this.#builder.addNewLine();
78
78
  } else if (format[i] === '>') {
79
- this.builder.increaseNestingLevel();
79
+ this.#builder.increaseNestingLevel();
80
80
  } else if (format[i] === '<') {
81
- this.builder.decreaseNestingLevel();
81
+ this.#builder.decreaseNestingLevel();
82
82
  } else if (format[i] === 't') {
83
- if (this.tokenizer.tokenLineStart() - this.lastLineNumber > 1) {
84
- this.builder.addNewLine(true);
83
+ if (this.#tokenizer.tokenLineStart() - this.#lastLineNumber > 1) {
84
+ this.#builder.addNewLine(true);
85
85
  }
86
- this.lastLineNumber = this.tokenizer.tokenLineEnd();
86
+ this.#lastLineNumber = this.#tokenizer.tokenLineEnd();
87
87
  if (token) {
88
- this.builder.addToken(this.content.substring(token.start, token.end), this.fromOffset + token.start);
88
+ this.#builder.addToken(this.#content.substring(token.start, token.end), this.#fromOffset + token.start);
89
89
  }
90
90
  }
91
91
  }
@@ -96,8 +96,8 @@ export class JavaScriptFormatter {
96
96
  return;
97
97
  }
98
98
  let token;
99
- while ((token = this.tokenizer.peekToken()) && token.start < node.start) {
100
- const token = (this.tokenizer.nextToken() as TokenOrComment);
99
+ while ((token = this.#tokenizer.peekToken()) && token.start < node.start) {
100
+ const token = (this.#tokenizer.nextToken() as TokenOrComment);
101
101
  // @ts-ignore Same reason as above about Acorn types and ESTree types
102
102
  const format = this.formatToken(node.parent, token);
103
103
  this.push(token, format);
@@ -107,8 +107,8 @@ export class JavaScriptFormatter {
107
107
 
108
108
  private afterVisit(node: Acorn.ESTree.Node): void {
109
109
  let token;
110
- while ((token = this.tokenizer.peekToken()) && token.start < node.end) {
111
- const token = (this.tokenizer.nextToken() as TokenOrComment);
110
+ while ((token = this.#tokenizer.peekToken()) && token.start < node.end) {
111
+ const token = (this.#tokenizer.nextToken() as TokenOrComment);
112
112
  const format = this.formatToken(node, token);
113
113
  this.push(token, format);
114
114
  }