lighthouse 8.5.1 → 8.6.0-dev.20211016

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 (173) hide show
  1. package/changelog.md +5490 -0
  2. package/dist/report/flow.js +35 -12
  3. package/dist/report/standalone.js +20 -21
  4. package/flow-report/.eslintrc.cjs +49 -0
  5. package/flow-report/assets/styles.css +272 -9
  6. package/flow-report/jest.config.js +1 -1
  7. package/flow-report/package.json +4 -0
  8. package/flow-report/src/app.tsx +31 -9
  9. package/flow-report/src/common.tsx +86 -7
  10. package/flow-report/src/header.tsx +88 -0
  11. package/flow-report/src/help-dialog.tsx +120 -0
  12. package/flow-report/src/i18n/i18n.tsx +52 -0
  13. package/flow-report/src/i18n/localized-strings.js +11 -0
  14. package/flow-report/src/i18n/ui-strings.js +134 -0
  15. package/flow-report/src/icons.tsx +20 -3
  16. package/flow-report/src/sidebar/sidebar.tsx +11 -16
  17. package/flow-report/src/summary/category.tsx +39 -24
  18. package/flow-report/src/summary/summary.tsx +35 -32
  19. package/flow-report/src/topbar.tsx +54 -4
  20. package/flow-report/src/util.ts +26 -1
  21. package/flow-report/src/wrappers/report-renderer.tsx +1 -1
  22. package/flow-report/src/wrappers/report.tsx +6 -21
  23. package/flow-report/test/app-test.tsx +17 -13
  24. package/flow-report/test/common-test.tsx +89 -0
  25. package/flow-report/test/header-test.tsx +55 -0
  26. package/flow-report/test/sample-flow.ts +17 -0
  27. package/flow-report/test/setup/env-setup.ts +1 -0
  28. package/flow-report/test/sidebar/flow-test.tsx +6 -12
  29. package/flow-report/test/sidebar/sidebar-test.tsx +7 -13
  30. package/flow-report/test/summary/category-test.tsx +83 -34
  31. package/flow-report/test/summary/summary-test.tsx +12 -18
  32. package/flow-report/test/topbar-test.tsx +68 -0
  33. package/flow-report/test/util-test.tsx +1 -12
  34. package/flow-report/tsconfig.json +2 -0
  35. package/flow-report/types/flow-report.d.ts +2 -1
  36. package/jest.config.js +1 -15
  37. package/lighthouse-cli/bin.js +5 -0
  38. package/lighthouse-cli/cli-flags.js +10 -3
  39. package/lighthouse-cli/commands/commands.js +1 -0
  40. package/lighthouse-cli/commands/list-locales.js +16 -0
  41. package/lighthouse-cli/run.js +2 -2
  42. package/lighthouse-cli/test/smokehouse/frontends/smokehouse-bin.js +0 -0
  43. package/lighthouse-cli/test/smokehouse/report-assert.js +20 -4
  44. package/lighthouse-core/audits/byte-efficiency/byte-efficiency-audit.js +2 -1
  45. package/lighthouse-core/audits/byte-efficiency/unused-javascript.js +1 -1
  46. package/lighthouse-core/audits/seo/crawlable-anchors.js +10 -12
  47. package/lighthouse-core/computed/js-bundles.js +1 -2
  48. package/lighthouse-core/computed/unused-javascript-summary.js +3 -3
  49. package/lighthouse-core/config/config-helpers.js +1 -0
  50. package/lighthouse-core/config/config.js +2 -2
  51. package/lighthouse-core/config/default-config.js +5 -0
  52. package/lighthouse-core/fraggle-rock/api.js +10 -0
  53. package/lighthouse-core/fraggle-rock/config/filters.js +22 -3
  54. package/lighthouse-core/fraggle-rock/gather/driver.js +4 -0
  55. package/lighthouse-core/fraggle-rock/gather/navigation-runner.js +2 -2
  56. package/lighthouse-core/fraggle-rock/user-flow.js +35 -6
  57. package/lighthouse-core/gather/driver/navigation.js +5 -0
  58. package/lighthouse-core/gather/driver/prepare.js +14 -0
  59. package/lighthouse-core/gather/driver/storage.js +5 -0
  60. package/lighthouse-core/gather/gather-runner.js +2 -2
  61. package/lighthouse-core/gather/gatherers/dobetterweb/response-compression.js +5 -1
  62. package/lighthouse-core/gather/gatherers/full-page-screenshot.js +30 -24
  63. package/lighthouse-core/lib/cdt/Platform.js +55 -0
  64. package/lighthouse-core/lib/cdt/SDK.js +3 -123
  65. package/lighthouse-core/lib/cdt/generated/SourceMap.js +148 -312
  66. package/lighthouse-core/lib/csp-evaluator.js +2 -1
  67. package/lighthouse-core/lib/i18n/README.md +6 -6
  68. package/lighthouse-core/lib/i18n/i18n.js +26 -348
  69. package/lighthouse-core/lib/page-functions.js +4 -4
  70. package/lighthouse-core/lib/stack-packs.js +1 -13
  71. package/lighthouse-core/runner.js +6 -6
  72. package/lighthouse-core/scripts/manual-chrome-launcher.js +4 -1
  73. package/lighthouse-core/scripts/package.json +4 -0
  74. package/lighthouse-core/util-commonjs.js +20 -4
  75. package/package.json +19 -16
  76. package/readme.md +1 -1
  77. package/report/assets/standalone-template.html +0 -1
  78. package/report/assets/styles.css +16 -41
  79. package/report/assets/templates.html +42 -4
  80. package/report/clients/psi.js +1 -0
  81. package/report/clients/standalone.js +1 -2
  82. package/report/generator/file-namer.js +17 -8
  83. package/report/generator/report-generator.js +0 -1
  84. package/report/renderer/category-renderer.js +4 -16
  85. package/report/renderer/components.js +107 -71
  86. package/report/renderer/dom.js +19 -0
  87. package/report/renderer/logger.js +35 -2
  88. package/report/renderer/performance-category-renderer.js +23 -21
  89. package/report/renderer/pwa-category-renderer.js +1 -2
  90. package/report/renderer/report-renderer.js +21 -0
  91. package/report/renderer/report-ui-features.js +7 -19
  92. package/report/renderer/swap-locale-feature.js +82 -0
  93. package/report/renderer/util.js +20 -4
  94. package/report/test/clients/psi-test.js +0 -4
  95. package/report/test/generator/file-namer-test.js +2 -2
  96. package/report/test/renderer/category-renderer-test.js +1 -1
  97. package/report/test/renderer/performance-category-renderer-test.js +12 -0
  98. package/report/test/renderer/report-renderer-axe-test.js +86 -0
  99. package/report/test/renderer/report-renderer-test.js +0 -55
  100. package/report/test/renderer/util-test.js +68 -8
  101. package/report/test-assets/faux-psi-template.html +0 -1
  102. package/report/tsconfig.json +2 -1
  103. package/report/types/html-renderer.d.ts +2 -1
  104. package/root.js +18 -0
  105. package/shared/localization/format.js +455 -0
  106. package/{lighthouse-core/lib/cdt/Common.js → shared/localization/i18n-module.js} +3 -8
  107. package/{lighthouse-core/lib/i18n → shared/localization}/locales/ar-XB.json +139 -4
  108. package/{lighthouse-core/lib/i18n → shared/localization}/locales/ar.json +141 -6
  109. package/{lighthouse-core/lib/i18n → shared/localization}/locales/bg.json +139 -4
  110. package/{lighthouse-core/lib/i18n → shared/localization}/locales/ca.json +140 -5
  111. package/{lighthouse-core/lib/i18n → shared/localization}/locales/cs.json +139 -4
  112. package/{lighthouse-core/lib/i18n → shared/localization}/locales/da.json +139 -4
  113. package/{lighthouse-core/lib/i18n → shared/localization}/locales/de.json +139 -4
  114. package/{lighthouse-core/lib/i18n → shared/localization}/locales/el.json +141 -6
  115. package/{lighthouse-core/lib/i18n → shared/localization}/locales/en-GB.json +139 -4
  116. package/{lighthouse-core/lib/i18n → shared/localization}/locales/en-US.json +129 -0
  117. package/{lighthouse-core/lib/i18n → shared/localization}/locales/en-XA.json +139 -4
  118. package/{lighthouse-core/lib/i18n → shared/localization}/locales/en-XL.json +129 -0
  119. package/{lighthouse-core/lib/i18n → shared/localization}/locales/es-419.json +139 -4
  120. package/{lighthouse-core/lib/i18n → shared/localization}/locales/es.json +139 -4
  121. package/{lighthouse-core/lib/i18n → shared/localization}/locales/fi.json +139 -4
  122. package/{lighthouse-core/lib/i18n → shared/localization}/locales/fil.json +139 -4
  123. package/{lighthouse-core/lib/i18n → shared/localization}/locales/fr.json +139 -4
  124. package/{lighthouse-core/lib/i18n → shared/localization}/locales/he.json +139 -4
  125. package/{lighthouse-core/lib/i18n → shared/localization}/locales/hi.json +142 -7
  126. package/{lighthouse-core/lib/i18n → shared/localization}/locales/hr.json +139 -4
  127. package/{lighthouse-core/lib/i18n → shared/localization}/locales/hu.json +139 -4
  128. package/{lighthouse-core/lib/i18n → shared/localization}/locales/id.json +139 -4
  129. package/{lighthouse-core/lib/i18n → shared/localization}/locales/it.json +139 -4
  130. package/{lighthouse-core/lib/i18n → shared/localization}/locales/ja.json +139 -4
  131. package/{lighthouse-core/lib/i18n → shared/localization}/locales/ko.json +139 -4
  132. package/{lighthouse-core/lib/i18n → shared/localization}/locales/lt.json +139 -4
  133. package/{lighthouse-core/lib/i18n → shared/localization}/locales/lv.json +139 -4
  134. package/{lighthouse-core/lib/i18n → shared/localization}/locales/nl.json +139 -4
  135. package/{lighthouse-core/lib/i18n → shared/localization}/locales/no.json +139 -4
  136. package/{lighthouse-core/lib/i18n → shared/localization}/locales/pl.json +139 -4
  137. package/{lighthouse-core/lib/i18n → shared/localization}/locales/pt-PT.json +139 -4
  138. package/{lighthouse-core/lib/i18n → shared/localization}/locales/pt.json +139 -4
  139. package/{lighthouse-core/lib/i18n → shared/localization}/locales/ro.json +139 -4
  140. package/{lighthouse-core/lib/i18n → shared/localization}/locales/ru.json +139 -4
  141. package/{lighthouse-core/lib/i18n → shared/localization}/locales/sk.json +139 -4
  142. package/{lighthouse-core/lib/i18n → shared/localization}/locales/sl.json +139 -4
  143. package/{lighthouse-core/lib/i18n → shared/localization}/locales/sr-Latn.json +139 -4
  144. package/{lighthouse-core/lib/i18n → shared/localization}/locales/sr.json +139 -4
  145. package/{lighthouse-core/lib/i18n → shared/localization}/locales/sv.json +139 -4
  146. package/{lighthouse-core/lib/i18n → shared/localization}/locales/ta.json +146 -11
  147. package/{lighthouse-core/lib/i18n → shared/localization}/locales/te.json +179 -44
  148. package/{lighthouse-core/lib/i18n → shared/localization}/locales/th.json +139 -4
  149. package/{lighthouse-core/lib/i18n → shared/localization}/locales/tr.json +139 -4
  150. package/{lighthouse-core/lib/i18n → shared/localization}/locales/uk.json +139 -4
  151. package/{lighthouse-core/lib/i18n → shared/localization}/locales/vi.json +139 -4
  152. package/{lighthouse-core/lib/i18n → shared/localization}/locales/zh-HK.json +139 -4
  153. package/{lighthouse-core/lib/i18n → shared/localization}/locales/zh-TW.json +139 -4
  154. package/{lighthouse-core/lib/i18n → shared/localization}/locales/zh.json +139 -4
  155. package/{lighthouse-core/lib/i18n → shared/localization}/locales.js +8 -1
  156. package/shared/localization/swap-flow-locale.js +20 -0
  157. package/{lighthouse-core/lib/i18n → shared/localization}/swap-locale.js +9 -7
  158. package/shared/test/localization/format-test.js +421 -0
  159. package/shared/test/localization/locales-test.js +47 -0
  160. package/shared/test/localization/swap-locale-test.js +140 -0
  161. package/shared/tsconfig.json +22 -0
  162. package/{lighthouse-core/lib → shared}/type-verifiers.js +0 -0
  163. package/shared/types/shared.d.ts +24 -0
  164. package/third-party/chromium-synchronization/inspector-issueAdded-types-test.js +5 -3
  165. package/third-party/chromium-synchronization/installability-errors-test.js +2 -1
  166. package/tsconfig-all.json +1 -0
  167. package/tsconfig-base.json +1 -1
  168. package/tsconfig.json +2 -3
  169. package/types/config.d.ts +1 -0
  170. package/types/es-main.d.ts +18 -0
  171. package/types/externs.d.ts +2 -0
  172. package/types/lhr/flow.d.ts +7 -0
  173. package/types/lhr/i18n.d.ts +0 -3
@@ -1,4 +1,115 @@
1
1
  {
2
+ "flow-report/src/i18n/ui-strings.js | allReports": {
3
+ "message": "所有报告"
4
+ },
5
+ "flow-report/src/i18n/ui-strings.js | categories": {
6
+ "message": "Categories"
7
+ },
8
+ "flow-report/src/i18n/ui-strings.js | categoryAccessibility": {
9
+ "message": "无障碍"
10
+ },
11
+ "flow-report/src/i18n/ui-strings.js | categoryBestPractices": {
12
+ "message": "最佳做法"
13
+ },
14
+ "flow-report/src/i18n/ui-strings.js | categoryPerformance": {
15
+ "message": "性能"
16
+ },
17
+ "flow-report/src/i18n/ui-strings.js | categoryProgressiveWebApp": {
18
+ "message": "渐进式 Web 应用"
19
+ },
20
+ "flow-report/src/i18n/ui-strings.js | categorySeo": {
21
+ "message": "SEO"
22
+ },
23
+ "flow-report/src/i18n/ui-strings.js | desktop": {
24
+ "message": "桌面版"
25
+ },
26
+ "flow-report/src/i18n/ui-strings.js | helpDialogTitle": {
27
+ "message": "Understanding the Lighthouse Flow Report"
28
+ },
29
+ "flow-report/src/i18n/ui-strings.js | helpLabel": {
30
+ "message": "Understanding Flows"
31
+ },
32
+ "flow-report/src/i18n/ui-strings.js | helpUseCaseInstructionNavigation": {
33
+ "message": "Use Navigation reports to..."
34
+ },
35
+ "flow-report/src/i18n/ui-strings.js | helpUseCaseInstructionSnapshot": {
36
+ "message": "Use Snapshot reports to..."
37
+ },
38
+ "flow-report/src/i18n/ui-strings.js | helpUseCaseInstructionTimespan": {
39
+ "message": "Use Timespan reports to..."
40
+ },
41
+ "flow-report/src/i18n/ui-strings.js | helpUseCaseNavigation1": {
42
+ "message": "Obtain a Lighthouse Performance score."
43
+ },
44
+ "flow-report/src/i18n/ui-strings.js | helpUseCaseNavigation2": {
45
+ "message": "Measure page load Performance metrics such as Largest Contentful Paint and Speed Index."
46
+ },
47
+ "flow-report/src/i18n/ui-strings.js | helpUseCaseNavigation3": {
48
+ "message": "Assess Progressive Web App capabilities."
49
+ },
50
+ "flow-report/src/i18n/ui-strings.js | helpUseCaseSnapshot1": {
51
+ "message": "Find accessibility issues in single page applications or complex forms."
52
+ },
53
+ "flow-report/src/i18n/ui-strings.js | helpUseCaseSnapshot2": {
54
+ "message": "Evaluate best practices of menus and UI elements hidden behind interaction."
55
+ },
56
+ "flow-report/src/i18n/ui-strings.js | helpUseCaseTimespan1": {
57
+ "message": "Measure layout shifts and JavaScript execution time on a series of interactions."
58
+ },
59
+ "flow-report/src/i18n/ui-strings.js | helpUseCaseTimespan2": {
60
+ "message": "Discover performance opportunities to improve the experience for long-lived pages and single-page applications."
61
+ },
62
+ "flow-report/src/i18n/ui-strings.js | mobile": {
63
+ "message": "移动版"
64
+ },
65
+ "flow-report/src/i18n/ui-strings.js | navigationDescription": {
66
+ "message": "网页加载"
67
+ },
68
+ "flow-report/src/i18n/ui-strings.js | navigationLongDescription": {
69
+ "message": "Navigation reports analyze a single page load, exactly like the original Lighthouse reports."
70
+ },
71
+ "flow-report/src/i18n/ui-strings.js | navigationReport": {
72
+ "message": "导航报告"
73
+ },
74
+ "flow-report/src/i18n/ui-strings.js | ratingAverage": {
75
+ "message": "一般"
76
+ },
77
+ "flow-report/src/i18n/ui-strings.js | ratingError": {
78
+ "message": "出错了"
79
+ },
80
+ "flow-report/src/i18n/ui-strings.js | ratingFail": {
81
+ "message": "较差"
82
+ },
83
+ "flow-report/src/i18n/ui-strings.js | ratingPass": {
84
+ "message": "良好"
85
+ },
86
+ "flow-report/src/i18n/ui-strings.js | save": {
87
+ "message": "Save"
88
+ },
89
+ "flow-report/src/i18n/ui-strings.js | snapshotDescription": {
90
+ "message": "捕获到的网页状态"
91
+ },
92
+ "flow-report/src/i18n/ui-strings.js | snapshotLongDescription": {
93
+ "message": "Snapshot reports analyze the page in a particular state, typically after user interactions."
94
+ },
95
+ "flow-report/src/i18n/ui-strings.js | snapshotReport": {
96
+ "message": "快照报告"
97
+ },
98
+ "flow-report/src/i18n/ui-strings.js | summary": {
99
+ "message": "摘要"
100
+ },
101
+ "flow-report/src/i18n/ui-strings.js | timespanDescription": {
102
+ "message": "用户互动"
103
+ },
104
+ "flow-report/src/i18n/ui-strings.js | timespanLongDescription": {
105
+ "message": "Timespan reports analyze an arbitrary period of time, typically containing user interactions."
106
+ },
107
+ "flow-report/src/i18n/ui-strings.js | timespanReport": {
108
+ "message": "时间跨度报告"
109
+ },
110
+ "flow-report/src/i18n/ui-strings.js | title": {
111
+ "message": "Lighthouse 用户流报告"
112
+ },
2
113
  "lighthouse-core/audits/accessibility/accesskeys.js | description": {
3
114
  "message": "快捷键可让用户快速转到页面的某个部分。为确保正确进行导航,每个快捷键都必须是独一无二的。[了解详情](https://web.dev/accesskeys/)。"
4
115
  },
@@ -554,6 +665,12 @@
554
665
  "lighthouse-core/audits/byte-efficiency/uses-responsive-images-snapshot.js | columnDisplayedDimensions": {
555
666
  "message": "显示时的尺寸"
556
667
  },
668
+ "lighthouse-core/audits/byte-efficiency/uses-responsive-images-snapshot.js | failureTitle": {
669
+ "message": "图片大于其显示时的尺寸"
670
+ },
671
+ "lighthouse-core/audits/byte-efficiency/uses-responsive-images-snapshot.js | title": {
672
+ "message": "图片适合其显示时的尺寸"
673
+ },
557
674
  "lighthouse-core/audits/byte-efficiency/uses-responsive-images.js | description": {
558
675
  "message": "提供大小合适的图片可节省移动数据网络流量并缩短加载用时。[了解详情](https://web.dev/uses-responsive-images/)。"
559
676
  },
@@ -1007,6 +1124,15 @@
1007
1124
  "lighthouse-core/audits/layout-shift-elements.js | title": {
1008
1125
  "message": "请避免出现大幅度的布局偏移"
1009
1126
  },
1127
+ "lighthouse-core/audits/lcp-lazy-loaded.js | description": {
1128
+ "message": "被延迟加载的首屏图片会在页面生命周期内的较晚时间呈现,这可能会致使系统延迟渲染最大内容元素。[了解详情](https://web.dev/lcp-lazy-loading/)。"
1129
+ },
1130
+ "lighthouse-core/audits/lcp-lazy-loaded.js | failureTitle": {
1131
+ "message": "Largest Contentful Paint 所对应的图片被延迟加载了"
1132
+ },
1133
+ "lighthouse-core/audits/lcp-lazy-loaded.js | title": {
1134
+ "message": "Largest Contentful Paint 所对应的图片未被延迟加载"
1135
+ },
1010
1136
  "lighthouse-core/audits/long-tasks.js | description": {
1011
1137
  "message": "列出了主线程中运行时间最长的任务,有助于识别出导致输入延迟的最主要原因。[了解详情](https://web.dev/long-tasks-devtools/)"
1012
1138
  },
@@ -1524,7 +1650,7 @@
1524
1650
  "message": "页面包含有效的源代码映射"
1525
1651
  },
1526
1652
  "lighthouse-core/audits/viewport.js | description": {
1527
- "message": "添加 `<meta name=\"viewport\">` 标记以针对移动设备屏幕优化您的应用。[了解详情](https://web.dev/viewport/)。"
1653
+ "message": "`<meta name=\"viewport\">` 不仅会针对移动设备屏幕尺寸优化您的应用,还会阻止[系统在响应用户输入前出现 300 毫秒的延迟](https://developers.google.com/web/updates/2013/12/300ms-tap-delay-gone-away)。[了解详情](https://web.dev/viewport/)。"
1528
1654
  },
1529
1655
  "lighthouse-core/audits/viewport.js | explanationNoTag": {
1530
1656
  "message": "未找到任何 `<meta name=\"viewport\">` 标记"
@@ -1659,7 +1785,7 @@
1659
1785
  "message": "优化 PWA"
1660
1786
  },
1661
1787
  "lighthouse-core/config/default-config.js | seoCategoryDescription": {
1662
- "message": "这些检查可确保您的页面已经过优化,有利于其在搜索引擎结果中的排名。不在 Lighthouse 检查范围内的其他因素可能会影响您的搜索排名。[了解详情](https://support.google.com/webmasters/answer/35769)。"
1788
+ "message": "这些检查可确保您的网页遵循了基本的搜索引擎优化建议。还有很多其他因素可能会影响您的网页在搜索引擎结果中的排名,但未被 Lighthouse 纳入此处的评估范围,其中包括[核心网页指标](https://web.dev/learn-web-vitals/)衡量结果。[了解详情](https://support.google.com/webmasters/answer/35769)。"
1663
1789
  },
1664
1790
  "lighthouse-core/config/default-config.js | seoCategoryManualDescription": {
1665
1791
  "message": "请在您的网站上运行这些额外的验证程序,以检查其他 SEO 最佳做法。"
@@ -1713,7 +1839,7 @@
1713
1839
  "message": "缺少 base-uri 意味着允许使用注入的 <base> 标记将所有相对网址(例如脚本)的基准网址设为一个受攻击者控制的网域。建议您将 base-uri 设为“none”或“self”。"
1714
1840
  },
1715
1841
  "lighthouse-core/lib/csp-evaluator.js | missingObjectSrc": {
1716
- "message": " object-src 控制的元素会被视为旧版功能。建议您将 object-src 设为“none”,以防止不良之徒注入会执行不安全脚本的插件。"
1842
+ "message": "如果缺少 object-src,便无法防止不良之徒注入会执行不安全脚本的插件。建议您将 object-src 设为“none”(如果可以的话)。"
1717
1843
  },
1718
1844
  "lighthouse-core/lib/csp-evaluator.js | missingScriptSrc": {
1719
1845
  "message": "缺少 script-src 指令。这意味着允许执行不安全的脚本。"
@@ -1727,6 +1853,12 @@
1727
1853
  "lighthouse-core/lib/csp-evaluator.js | nonceLength": {
1728
1854
  "message": "Nonces 应包含至少 8 个字符。"
1729
1855
  },
1856
+ "lighthouse-core/lib/csp-evaluator.js | plainUrlScheme": {
1857
+ "message": "请避免在这条指令中仅仅使用网址架构 ({keyword})。如果仅仅使用网址架构,便无法防止脚本来自不安全的网域。"
1858
+ },
1859
+ "lighthouse-core/lib/csp-evaluator.js | plainWildcards": {
1860
+ "message": "请避免在这条指令中仅仅使用通配符 ({keyword})。如果仅仅使用通配符,便无法防止脚本来自不安全的网域。"
1861
+ },
1730
1862
  "lighthouse-core/lib/csp-evaluator.js | reportToOnly": {
1731
1863
  "message": "报告目的地只能通过 report-to 指令进行配置。此指令仅适用于基于 Chromium 的浏览器,因此我们建议您同时也使用 report-uri 指令。"
1732
1864
  },
@@ -1734,7 +1866,7 @@
1734
1866
  "message": "任何 CSP 都未配置报告目的地。这会导致系统很难持续维护 CSP 以及监控故障。"
1735
1867
  },
1736
1868
  "lighthouse-core/lib/csp-evaluator.js | strictDynamic": {
1737
- "message": "主机许可名单经常会被绕过。建议您将“strict-dynamic”与 CSP nonces 或 hashes 结合使用。"
1869
+ "message": "主机许可名单经常会被绕过。建议您改用 CSP nonces 或 hashes(以及“strict-dynamic”,若有必要)。"
1738
1870
  },
1739
1871
  "lighthouse-core/lib/csp-evaluator.js | unknownDirective": {
1740
1872
  "message": "CSP 指令不明。"
@@ -1742,6 +1874,9 @@
1742
1874
  "lighthouse-core/lib/csp-evaluator.js | unknownKeyword": {
1743
1875
  "message": "{keyword}似乎是无效关键字。"
1744
1876
  },
1877
+ "lighthouse-core/lib/csp-evaluator.js | unsafeInline": {
1878
+ "message": "“unsafe-inline”允许执行不安全的页内脚本和事件处理脚本。建议您使用 CSP nonces 或 hashes 来逐一允许各个脚本。"
1879
+ },
1745
1880
  "lighthouse-core/lib/csp-evaluator.js | unsafeInlineFallback": {
1746
1881
  "message": "建议您添加“unsafe-inline”(会被支持 nonces/hashes 的浏览器忽略),以便向后兼容旧版浏览器。"
1747
1882
  },
@@ -12,10 +12,17 @@
12
12
  * Google locale inheritance rules: https://goto.google.com/ccssm
13
13
  * CLDR language aliases: https://www.unicode.org/cldr/charts/latest/supplemental/aliases.html
14
14
  * CLDR locale inheritance: https://github.com/unicode-cldr/cldr-core/blob/master/supplemental/parentLocales.json
15
+ *
16
+ * For Lighthouse bundles that shouldn't include locale data, the recommended pattern
17
+ * is to replace the default export of this file with `{}` so that no locale messages
18
+ * are included. Strings will work normally through the IcuMessage.formattedDefault
19
+ * fallback, and locale messages can be added on demand (e.g. dynamically fetched)
20
+ * through `format.registerLocaleData()`.
15
21
  */
16
22
 
17
23
  // TODO(paulirish): Centralize locale inheritance (combining this & i18n.lookupLocale()), adopt cldr parentLocale rules.
18
24
 
25
+ /** @typedef {import('../../types/lhr/settings').Locale} Locale */
19
26
  /** @typedef {Record<string, {message: string}>} LhlMessages */
20
27
 
21
28
  const fs = require('fs');
@@ -73,7 +80,7 @@ const files = {
73
80
  };
74
81
 
75
82
  // The keys within this const must exactly match the LH.Locale type in externs.d.ts
76
- /** @type {Record<LH.Locale, LhlMessages>} */
83
+ /** @type {Record<Locale, LhlMessages>} */
77
84
  const locales = {
78
85
  'en-US': files['en-US'], // The 'source' strings, with descriptions
79
86
  'en': files['en-US'], // According to CLDR/ICU, 'en' == 'en-US' dates/numbers (Why?!)
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
3
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
4
+ * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
5
+ */
6
+ 'use strict';
7
+
8
+ const swapLocale = require('./swap-locale.js');
9
+
10
+ /**
11
+ * @param {LH.FlowResult} flowResult
12
+ * @param {LH.Locale} locale
13
+ */
14
+ module.exports = function swapFlowLocale(flowResult, locale) {
15
+ const localizedFlowResult = JSON.parse(JSON.stringify(flowResult));
16
+ localizedFlowResult.steps = flowResult.steps.map(step => {
17
+ return {...step, lhr: swapLocale(step.lhr, locale).lhr};
18
+ });
19
+ return localizedFlowResult;
20
+ };
@@ -8,7 +8,7 @@
8
8
  const _set = require('lodash.set');
9
9
  const _get = require('lodash.get');
10
10
 
11
- const i18n = require('./i18n.js');
11
+ const format = require('./format.js');
12
12
 
13
13
  /**
14
14
  * @fileoverview Use the lhr.i18n.icuMessagePaths object to change locales.
@@ -16,7 +16,7 @@ const i18n = require('./i18n.js');
16
16
  * `icuMessagePaths` is an object keyed by `LH.IcuMessage['i18nId']`s. Within each is either
17
17
  * 1) an array of strings, which are just object paths to where that message is used in the LHR
18
18
  * 2) an array of `LH.IcuMessagePath`s which include both a `path` and a `values` object
19
- * which will be used in the replacement within `i18n.getFormatted()`
19
+ * which will be used in the replacement within `format.getFormatted()`
20
20
  *
21
21
  * An example:
22
22
  "icuMessagePaths": {
@@ -49,7 +49,9 @@ function swapLocale(lhr, requestedLocale) {
49
49
  // Copy LHR to avoid mutating provided LHR.
50
50
  lhr = JSON.parse(JSON.stringify(lhr));
51
51
 
52
- const locale = i18n.lookupLocale(requestedLocale);
52
+ if (!format.hasLocale(requestedLocale)) {
53
+ throw new Error(`Unsupported locale '${requestedLocale}'`);
54
+ }
53
55
  const originalLocale = lhr.configSettings.locale;
54
56
  const {icuMessagePaths} = lhr.i18n;
55
57
  const missingIcuMessageIds = [];
@@ -83,11 +85,11 @@ function swapLocale(lhr, requestedLocale) {
83
85
  formattedDefault: originalString,
84
86
  };
85
87
  // Get new formatted strings in revised locale.
86
- const relocalizedString = i18n.getFormatted(icuMessage, locale);
88
+ const relocalizedString = format.getFormatted(icuMessage, requestedLocale);
87
89
 
88
90
  // If we couldn't find a new replacement message, keep things as is.
89
91
  if (relocalizedString === originalString) {
90
- if (locale !== originalLocale) {
92
+ if (requestedLocale !== originalLocale) {
91
93
  // If the string remained the same while the locale changed, there may have been an issue.
92
94
  missingIcuMessageIds.push(i18nId);
93
95
  }
@@ -99,9 +101,9 @@ function swapLocale(lhr, requestedLocale) {
99
101
  }
100
102
  }
101
103
 
102
- lhr.i18n.rendererFormattedStrings = i18n.getRendererFormattedStrings(locale);
104
+ lhr.i18n.rendererFormattedStrings = format.getRendererFormattedStrings(requestedLocale);
103
105
  // Tweak the config locale
104
- lhr.configSettings.locale = locale;
106
+ lhr.configSettings.locale = requestedLocale;
105
107
  return {
106
108
  lhr,
107
109
  missingIcuMessageIds,