lighthouse 9.5.0-dev.20230123 → 9.5.0-dev.20230124

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 (109) hide show
  1. package/.codecov.yml +0 -5
  2. package/core/audits/audit.js +1 -1
  3. package/core/audits/byte-efficiency/legacy-javascript.d.ts +1 -0
  4. package/core/audits/byte-efficiency/legacy-javascript.js +7 -3
  5. package/core/audits/dobetterweb/uses-http2.d.ts +5 -2
  6. package/core/audits/dobetterweb/uses-http2.js +12 -7
  7. package/core/audits/third-party-facades.d.ts +3 -2
  8. package/core/audits/third-party-facades.js +12 -9
  9. package/core/audits/third-party-summary.d.ts +7 -6
  10. package/core/audits/third-party-summary.js +16 -14
  11. package/core/audits/valid-source-maps.d.ts +5 -3
  12. package/core/audits/valid-source-maps.js +11 -9
  13. package/core/computed/entity-classification.d.ts +29 -0
  14. package/core/computed/entity-classification.js +102 -0
  15. package/core/computed/resource-summary.d.ts +4 -2
  16. package/core/computed/resource-summary.js +8 -5
  17. package/core/lib/url-utils.js +1 -1
  18. package/core/runner.d.ts +10 -0
  19. package/core/runner.js +48 -0
  20. package/core/util.cjs +1 -1
  21. package/dist/report/bundle.esm.js +724 -687
  22. package/dist/report/flow.js +25 -15
  23. package/dist/report/standalone.js +25 -15
  24. package/flow-report/src/common.tsx +1 -1
  25. package/flow-report/src/i18n/i18n.tsx +17 -16
  26. package/flow-report/src/sidebar/sidebar.tsx +2 -2
  27. package/flow-report/src/summary/category.tsx +6 -6
  28. package/flow-report/src/summary/summary.tsx +2 -2
  29. package/package.json +4 -4
  30. package/report/renderer/category-renderer.js +19 -17
  31. package/report/renderer/crc-details-renderer.js +6 -6
  32. package/report/renderer/details-renderer.js +7 -6
  33. package/report/renderer/dom.js +1 -1
  34. package/report/renderer/element-screenshot-renderer.js +3 -3
  35. package/report/renderer/performance-category-renderer.js +17 -15
  36. package/report/renderer/pwa-category-renderer.js +5 -4
  37. package/report/renderer/report-globals.d.ts +21 -0
  38. package/report/renderer/report-globals.js +49 -0
  39. package/report/renderer/report-renderer.js +22 -20
  40. package/report/renderer/report-ui-features.js +9 -8
  41. package/report/renderer/report-utils.d.ts +116 -0
  42. package/report/renderer/{util.js → report-utils.js} +81 -429
  43. package/report/renderer/snippet-renderer.js +3 -2
  44. package/report/test/renderer/category-renderer-test.js +9 -4
  45. package/report/test/renderer/crc-details-renderer-test.js +7 -3
  46. package/report/test/renderer/details-renderer-test.js +7 -3
  47. package/report/test/renderer/dom-test.js +7 -3
  48. package/report/test/renderer/element-screenshot-renderer-test.js +8 -4
  49. package/report/test/renderer/performance-category-renderer-test.js +14 -9
  50. package/report/test/renderer/pwa-category-renderer-test.js +10 -5
  51. package/report/test/renderer/report-renderer-test.js +2 -2
  52. package/report/test/renderer/report-ui-features-test.js +3 -3
  53. package/report/test/renderer/{util-test.js → report-utils-test.js} +36 -234
  54. package/report/test/renderer/snippet-renderer-test.js +7 -3
  55. package/shared/localization/format.js +5 -2
  56. package/shared/localization/locales/ar-XB.json +50 -50
  57. package/shared/localization/locales/ar.json +50 -50
  58. package/shared/localization/locales/bg.json +50 -50
  59. package/shared/localization/locales/ca.json +50 -50
  60. package/shared/localization/locales/cs.json +50 -50
  61. package/shared/localization/locales/da.json +50 -50
  62. package/shared/localization/locales/de.json +50 -50
  63. package/shared/localization/locales/el.json +50 -50
  64. package/shared/localization/locales/en-GB.json +50 -50
  65. package/shared/localization/locales/en-US.json +54 -54
  66. package/shared/localization/locales/en-XA.json +50 -50
  67. package/shared/localization/locales/en-XL.json +54 -54
  68. package/shared/localization/locales/es-419.json +50 -50
  69. package/shared/localization/locales/es.json +50 -50
  70. package/shared/localization/locales/fi.json +50 -50
  71. package/shared/localization/locales/fil.json +50 -50
  72. package/shared/localization/locales/fr.json +50 -50
  73. package/shared/localization/locales/he.json +50 -50
  74. package/shared/localization/locales/hi.json +50 -50
  75. package/shared/localization/locales/hr.json +50 -50
  76. package/shared/localization/locales/hu.json +50 -50
  77. package/shared/localization/locales/id.json +50 -50
  78. package/shared/localization/locales/it.json +50 -50
  79. package/shared/localization/locales/ja.json +50 -50
  80. package/shared/localization/locales/ko.json +50 -50
  81. package/shared/localization/locales/lt.json +50 -50
  82. package/shared/localization/locales/lv.json +50 -50
  83. package/shared/localization/locales/nl.json +50 -50
  84. package/shared/localization/locales/no.json +50 -50
  85. package/shared/localization/locales/pl.json +50 -50
  86. package/shared/localization/locales/pt-PT.json +50 -50
  87. package/shared/localization/locales/pt.json +50 -50
  88. package/shared/localization/locales/ro.json +50 -50
  89. package/shared/localization/locales/ru.json +50 -50
  90. package/shared/localization/locales/sk.json +50 -50
  91. package/shared/localization/locales/sl.json +50 -50
  92. package/shared/localization/locales/sr-Latn.json +50 -50
  93. package/shared/localization/locales/sr.json +50 -50
  94. package/shared/localization/locales/sv.json +50 -50
  95. package/shared/localization/locales/ta.json +50 -50
  96. package/shared/localization/locales/te.json +50 -50
  97. package/shared/localization/locales/th.json +50 -50
  98. package/shared/localization/locales/tr.json +50 -50
  99. package/shared/localization/locales/uk.json +50 -50
  100. package/shared/localization/locales/vi.json +50 -50
  101. package/shared/localization/locales/zh-HK.json +50 -50
  102. package/shared/localization/locales/zh-TW.json +50 -50
  103. package/shared/localization/locales/zh.json +50 -50
  104. package/shared/test/util-test.js +214 -0
  105. package/shared/util.d.ts +122 -0
  106. package/shared/util.js +332 -0
  107. package/types/artifacts.d.ts +14 -0
  108. package/types/lhr/lhr.d.ts +33 -0
  109. package/report/renderer/util.d.ts +0 -342
@@ -2327,154 +2327,154 @@
2327
2327
  "node_modules/lighthouse-stack-packs/packs/wordpress.js | uses-text-compression": {
2328
2328
  "message": "你可以在網路伺服器設定中啟用文字壓縮功能。"
2329
2329
  },
2330
- "report/renderer/util.js | calculatorLink": {
2330
+ "report/renderer/report-utils.js | calculatorLink": {
2331
2331
  "message": "查看計算機。"
2332
2332
  },
2333
- "report/renderer/util.js | collapseView": {
2333
+ "report/renderer/report-utils.js | collapseView": {
2334
2334
  "message": "收合檢視畫面"
2335
2335
  },
2336
- "report/renderer/util.js | crcInitialNavigation": {
2336
+ "report/renderer/report-utils.js | crcInitialNavigation": {
2337
2337
  "message": "起始導覽"
2338
2338
  },
2339
- "report/renderer/util.js | crcLongestDurationLabel": {
2339
+ "report/renderer/report-utils.js | crcLongestDurationLabel": {
2340
2340
  "message": "關鍵路徑延遲時間上限:"
2341
2341
  },
2342
- "report/renderer/util.js | dropdownCopyJSON": {
2342
+ "report/renderer/report-utils.js | dropdownCopyJSON": {
2343
2343
  "message": "複製 JSON"
2344
2344
  },
2345
- "report/renderer/util.js | dropdownDarkTheme": {
2345
+ "report/renderer/report-utils.js | dropdownDarkTheme": {
2346
2346
  "message": "切換深色主題"
2347
2347
  },
2348
- "report/renderer/util.js | dropdownPrintExpanded": {
2348
+ "report/renderer/report-utils.js | dropdownPrintExpanded": {
2349
2349
  "message": "已展開列印"
2350
2350
  },
2351
- "report/renderer/util.js | dropdownPrintSummary": {
2351
+ "report/renderer/report-utils.js | dropdownPrintSummary": {
2352
2352
  "message": "列印摘要"
2353
2353
  },
2354
- "report/renderer/util.js | dropdownSaveGist": {
2354
+ "report/renderer/report-utils.js | dropdownSaveGist": {
2355
2355
  "message": "另存為 Gist"
2356
2356
  },
2357
- "report/renderer/util.js | dropdownSaveHTML": {
2357
+ "report/renderer/report-utils.js | dropdownSaveHTML": {
2358
2358
  "message": "另存為 HTML"
2359
2359
  },
2360
- "report/renderer/util.js | dropdownSaveJSON": {
2360
+ "report/renderer/report-utils.js | dropdownSaveJSON": {
2361
2361
  "message": "另存為 JSON"
2362
2362
  },
2363
- "report/renderer/util.js | dropdownViewer": {
2363
+ "report/renderer/report-utils.js | dropdownViewer": {
2364
2364
  "message": "在檢視器中開啟"
2365
2365
  },
2366
- "report/renderer/util.js | errorLabel": {
2366
+ "report/renderer/report-utils.js | errorLabel": {
2367
2367
  "message": "發生錯誤!"
2368
2368
  },
2369
- "report/renderer/util.js | errorMissingAuditInfo": {
2369
+ "report/renderer/report-utils.js | errorMissingAuditInfo": {
2370
2370
  "message": "回報錯誤:無稽核資訊"
2371
2371
  },
2372
- "report/renderer/util.js | expandView": {
2372
+ "report/renderer/report-utils.js | expandView": {
2373
2373
  "message": "展開檢視畫面"
2374
2374
  },
2375
- "report/renderer/util.js | footerIssue": {
2375
+ "report/renderer/report-utils.js | footerIssue": {
2376
2376
  "message": "回報問題"
2377
2377
  },
2378
- "report/renderer/util.js | hide": {
2378
+ "report/renderer/report-utils.js | hide": {
2379
2379
  "message": "隱藏"
2380
2380
  },
2381
- "report/renderer/util.js | labDataTitle": {
2381
+ "report/renderer/report-utils.js | labDataTitle": {
2382
2382
  "message": "研究資料"
2383
2383
  },
2384
- "report/renderer/util.js | lsPerformanceCategoryDescription": {
2384
+ "report/renderer/report-utils.js | lsPerformanceCategoryDescription": {
2385
2385
  "message": "[Lighthouse](https://developers.google.com/web/tools/lighthouse/) 在模擬行動網路上對目前網頁進行的分析。此為預估值,可能與實際情況有所不同。"
2386
2386
  },
2387
- "report/renderer/util.js | manualAuditsGroupTitle": {
2387
+ "report/renderer/report-utils.js | manualAuditsGroupTitle": {
2388
2388
  "message": "其他手動檢查項目"
2389
2389
  },
2390
- "report/renderer/util.js | notApplicableAuditsGroupTitle": {
2390
+ "report/renderer/report-utils.js | notApplicableAuditsGroupTitle": {
2391
2391
  "message": "不適用"
2392
2392
  },
2393
- "report/renderer/util.js | opportunityResourceColumnLabel": {
2393
+ "report/renderer/report-utils.js | opportunityResourceColumnLabel": {
2394
2394
  "message": "最佳化建議"
2395
2395
  },
2396
- "report/renderer/util.js | opportunitySavingsColumnLabel": {
2396
+ "report/renderer/report-utils.js | opportunitySavingsColumnLabel": {
2397
2397
  "message": "預估減少量"
2398
2398
  },
2399
- "report/renderer/util.js | passedAuditsGroupTitle": {
2399
+ "report/renderer/report-utils.js | passedAuditsGroupTitle": {
2400
2400
  "message": "通過稽核項目"
2401
2401
  },
2402
- "report/renderer/util.js | runtimeAnalysisWindow": {
2402
+ "report/renderer/report-utils.js | runtimeAnalysisWindow": {
2403
2403
  "message": "初次載入網頁"
2404
2404
  },
2405
- "report/renderer/util.js | runtimeCustom": {
2405
+ "report/renderer/report-utils.js | runtimeCustom": {
2406
2406
  "message": "自訂節流"
2407
2407
  },
2408
- "report/renderer/util.js | runtimeDesktopEmulation": {
2408
+ "report/renderer/report-utils.js | runtimeDesktopEmulation": {
2409
2409
  "message": "模擬電腦"
2410
2410
  },
2411
- "report/renderer/util.js | runtimeMobileEmulation": {
2411
+ "report/renderer/report-utils.js | runtimeMobileEmulation": {
2412
2412
  "message": "模擬 Moto G4"
2413
2413
  },
2414
- "report/renderer/util.js | runtimeNoEmulation": {
2414
+ "report/renderer/report-utils.js | runtimeNoEmulation": {
2415
2415
  "message": "沒有任何模擬的裝置"
2416
2416
  },
2417
- "report/renderer/util.js | runtimeSettingsAxeVersion": {
2417
+ "report/renderer/report-utils.js | runtimeSettingsAxeVersion": {
2418
2418
  "message": "Axe 版本"
2419
2419
  },
2420
- "report/renderer/util.js | runtimeSettingsBenchmark": {
2420
+ "report/renderer/report-utils.js | runtimeSettingsBenchmark": {
2421
2421
  "message": "CPU/記憶體效能"
2422
2422
  },
2423
- "report/renderer/util.js | runtimeSettingsCPUThrottling": {
2423
+ "report/renderer/report-utils.js | runtimeSettingsCPUThrottling": {
2424
2424
  "message": "CPU 溫控降頻"
2425
2425
  },
2426
- "report/renderer/util.js | runtimeSettingsDevice": {
2426
+ "report/renderer/report-utils.js | runtimeSettingsDevice": {
2427
2427
  "message": "裝置"
2428
2428
  },
2429
- "report/renderer/util.js | runtimeSettingsNetworkThrottling": {
2429
+ "report/renderer/report-utils.js | runtimeSettingsNetworkThrottling": {
2430
2430
  "message": "網路節流"
2431
2431
  },
2432
- "report/renderer/util.js | runtimeSettingsUANetwork": {
2432
+ "report/renderer/report-utils.js | runtimeSettingsUANetwork": {
2433
2433
  "message": "使用者代理程式 (網路)"
2434
2434
  },
2435
- "report/renderer/util.js | runtimeSingleLoad": {
2435
+ "report/renderer/report-utils.js | runtimeSingleLoad": {
2436
2436
  "message": "單一網頁載入"
2437
2437
  },
2438
- "report/renderer/util.js | runtimeSingleLoadTooltip": {
2438
+ "report/renderer/report-utils.js | runtimeSingleLoadTooltip": {
2439
2439
  "message": "這項資料取自單一網頁載入作業,而非匯總多個工作階段的現場資料。"
2440
2440
  },
2441
- "report/renderer/util.js | runtimeSlow4g": {
2441
+ "report/renderer/report-utils.js | runtimeSlow4g": {
2442
2442
  "message": "慢速 4G 節流"
2443
2443
  },
2444
- "report/renderer/util.js | runtimeUnknown": {
2444
+ "report/renderer/report-utils.js | runtimeUnknown": {
2445
2445
  "message": "不明"
2446
2446
  },
2447
- "report/renderer/util.js | show": {
2447
+ "report/renderer/report-utils.js | show": {
2448
2448
  "message": "顯示"
2449
2449
  },
2450
- "report/renderer/util.js | showRelevantAudits": {
2450
+ "report/renderer/report-utils.js | showRelevantAudits": {
2451
2451
  "message": "顯示與下列指標相關的稽核項目:"
2452
2452
  },
2453
- "report/renderer/util.js | snippetCollapseButtonLabel": {
2453
+ "report/renderer/report-utils.js | snippetCollapseButtonLabel": {
2454
2454
  "message": "收合程式碼片段"
2455
2455
  },
2456
- "report/renderer/util.js | snippetExpandButtonLabel": {
2456
+ "report/renderer/report-utils.js | snippetExpandButtonLabel": {
2457
2457
  "message": "展開程式碼片段"
2458
2458
  },
2459
- "report/renderer/util.js | thirdPartyResourcesLabel": {
2459
+ "report/renderer/report-utils.js | thirdPartyResourcesLabel": {
2460
2460
  "message": "顯示第三方資源"
2461
2461
  },
2462
- "report/renderer/util.js | throttlingProvided": {
2462
+ "report/renderer/report-utils.js | throttlingProvided": {
2463
2463
  "message": "由執行階段環境提供"
2464
2464
  },
2465
- "report/renderer/util.js | toplevelWarningsMessage": {
2465
+ "report/renderer/report-utils.js | toplevelWarningsMessage": {
2466
2466
  "message": "有問題導致 Lighthouse 無法順利執行這項作業:"
2467
2467
  },
2468
- "report/renderer/util.js | varianceDisclaimer": {
2468
+ "report/renderer/report-utils.js | varianceDisclaimer": {
2469
2469
  "message": "此為預估值,可能與實際情況有所不同。系統會直接根據這些指標[計算效能分數](https://web.dev/performance-scoring/)。"
2470
2470
  },
2471
- "report/renderer/util.js | viewTreemapLabel": {
2471
+ "report/renderer/report-utils.js | viewTreemapLabel": {
2472
2472
  "message": "查看矩形式樹狀結構圖"
2473
2473
  },
2474
- "report/renderer/util.js | warningAuditsGroupTitle": {
2474
+ "report/renderer/report-utils.js | warningAuditsGroupTitle": {
2475
2475
  "message": "通過稽核,但附有警告訊息"
2476
2476
  },
2477
- "report/renderer/util.js | warningHeader": {
2477
+ "report/renderer/report-utils.js | warningHeader": {
2478
2478
  "message": "警告: "
2479
2479
  },
2480
2480
  "treemap/app/src/util.js | allLabel": {
@@ -2327,154 +2327,154 @@
2327
2327
  "node_modules/lighthouse-stack-packs/packs/wordpress.js | uses-text-compression": {
2328
2328
  "message": "您可以在网络服务器配置中启用文本压缩。"
2329
2329
  },
2330
- "report/renderer/util.js | calculatorLink": {
2330
+ "report/renderer/report-utils.js | calculatorLink": {
2331
2331
  "message": "查看计算器。"
2332
2332
  },
2333
- "report/renderer/util.js | collapseView": {
2333
+ "report/renderer/report-utils.js | collapseView": {
2334
2334
  "message": "收起视图"
2335
2335
  },
2336
- "report/renderer/util.js | crcInitialNavigation": {
2336
+ "report/renderer/report-utils.js | crcInitialNavigation": {
2337
2337
  "message": "初始导航"
2338
2338
  },
2339
- "report/renderer/util.js | crcLongestDurationLabel": {
2339
+ "report/renderer/report-utils.js | crcLongestDurationLabel": {
2340
2340
  "message": "关键路径延迟时间上限:"
2341
2341
  },
2342
- "report/renderer/util.js | dropdownCopyJSON": {
2342
+ "report/renderer/report-utils.js | dropdownCopyJSON": {
2343
2343
  "message": "复制 JSON"
2344
2344
  },
2345
- "report/renderer/util.js | dropdownDarkTheme": {
2345
+ "report/renderer/report-utils.js | dropdownDarkTheme": {
2346
2346
  "message": "开启/关闭深色主题"
2347
2347
  },
2348
- "report/renderer/util.js | dropdownPrintExpanded": {
2348
+ "report/renderer/report-utils.js | dropdownPrintExpanded": {
2349
2349
  "message": "展开打印对话框"
2350
2350
  },
2351
- "report/renderer/util.js | dropdownPrintSummary": {
2351
+ "report/renderer/report-utils.js | dropdownPrintSummary": {
2352
2352
  "message": "打印摘要"
2353
2353
  },
2354
- "report/renderer/util.js | dropdownSaveGist": {
2354
+ "report/renderer/report-utils.js | dropdownSaveGist": {
2355
2355
  "message": "另存为 Gist"
2356
2356
  },
2357
- "report/renderer/util.js | dropdownSaveHTML": {
2357
+ "report/renderer/report-utils.js | dropdownSaveHTML": {
2358
2358
  "message": "另存为 HTML"
2359
2359
  },
2360
- "report/renderer/util.js | dropdownSaveJSON": {
2360
+ "report/renderer/report-utils.js | dropdownSaveJSON": {
2361
2361
  "message": "另存为 JSON"
2362
2362
  },
2363
- "report/renderer/util.js | dropdownViewer": {
2363
+ "report/renderer/report-utils.js | dropdownViewer": {
2364
2364
  "message": "在查看器中打开"
2365
2365
  },
2366
- "report/renderer/util.js | errorLabel": {
2366
+ "report/renderer/report-utils.js | errorLabel": {
2367
2367
  "message": "出错了!"
2368
2368
  },
2369
- "report/renderer/util.js | errorMissingAuditInfo": {
2369
+ "report/renderer/report-utils.js | errorMissingAuditInfo": {
2370
2370
  "message": "报告错误:没有任何审核信息"
2371
2371
  },
2372
- "report/renderer/util.js | expandView": {
2372
+ "report/renderer/report-utils.js | expandView": {
2373
2373
  "message": "展开视图"
2374
2374
  },
2375
- "report/renderer/util.js | footerIssue": {
2375
+ "report/renderer/report-utils.js | footerIssue": {
2376
2376
  "message": "提交问题"
2377
2377
  },
2378
- "report/renderer/util.js | hide": {
2378
+ "report/renderer/report-utils.js | hide": {
2379
2379
  "message": "隐藏"
2380
2380
  },
2381
- "report/renderer/util.js | labDataTitle": {
2381
+ "report/renderer/report-utils.js | labDataTitle": {
2382
2382
  "message": "实验室数据"
2383
2383
  },
2384
- "report/renderer/util.js | lsPerformanceCategoryDescription": {
2384
+ "report/renderer/report-utils.js | lsPerformanceCategoryDescription": {
2385
2385
  "message": "[Lighthouse](https://developers.google.com/web/tools/lighthouse/) 使用模拟的移动网络对当前页面进行的分析。这些值都是估算值,且可能会因时而异。"
2386
2386
  },
2387
- "report/renderer/util.js | manualAuditsGroupTitle": {
2387
+ "report/renderer/report-utils.js | manualAuditsGroupTitle": {
2388
2388
  "message": "待手动检查的其他项"
2389
2389
  },
2390
- "report/renderer/util.js | notApplicableAuditsGroupTitle": {
2390
+ "report/renderer/report-utils.js | notApplicableAuditsGroupTitle": {
2391
2391
  "message": "不适用"
2392
2392
  },
2393
- "report/renderer/util.js | opportunityResourceColumnLabel": {
2393
+ "report/renderer/report-utils.js | opportunityResourceColumnLabel": {
2394
2394
  "message": "优化建议"
2395
2395
  },
2396
- "report/renderer/util.js | opportunitySavingsColumnLabel": {
2396
+ "report/renderer/report-utils.js | opportunitySavingsColumnLabel": {
2397
2397
  "message": "有望节省的总时间(估算值)"
2398
2398
  },
2399
- "report/renderer/util.js | passedAuditsGroupTitle": {
2399
+ "report/renderer/report-utils.js | passedAuditsGroupTitle": {
2400
2400
  "message": "已通过的审核"
2401
2401
  },
2402
- "report/renderer/util.js | runtimeAnalysisWindow": {
2402
+ "report/renderer/report-utils.js | runtimeAnalysisWindow": {
2403
2403
  "message": "初始网页加载"
2404
2404
  },
2405
- "report/renderer/util.js | runtimeCustom": {
2405
+ "report/renderer/report-utils.js | runtimeCustom": {
2406
2406
  "message": "自定义节流"
2407
2407
  },
2408
- "report/renderer/util.js | runtimeDesktopEmulation": {
2408
+ "report/renderer/report-utils.js | runtimeDesktopEmulation": {
2409
2409
  "message": "模拟桌面设备"
2410
2410
  },
2411
- "report/renderer/util.js | runtimeMobileEmulation": {
2411
+ "report/renderer/report-utils.js | runtimeMobileEmulation": {
2412
2412
  "message": "模拟 Moto G4"
2413
2413
  },
2414
- "report/renderer/util.js | runtimeNoEmulation": {
2414
+ "report/renderer/report-utils.js | runtimeNoEmulation": {
2415
2415
  "message": "无模拟"
2416
2416
  },
2417
- "report/renderer/util.js | runtimeSettingsAxeVersion": {
2417
+ "report/renderer/report-utils.js | runtimeSettingsAxeVersion": {
2418
2418
  "message": "Axe 版本"
2419
2419
  },
2420
- "report/renderer/util.js | runtimeSettingsBenchmark": {
2420
+ "report/renderer/report-utils.js | runtimeSettingsBenchmark": {
2421
2421
  "message": "CPU/内存能力"
2422
2422
  },
2423
- "report/renderer/util.js | runtimeSettingsCPUThrottling": {
2423
+ "report/renderer/report-utils.js | runtimeSettingsCPUThrottling": {
2424
2424
  "message": "CPU 节流"
2425
2425
  },
2426
- "report/renderer/util.js | runtimeSettingsDevice": {
2426
+ "report/renderer/report-utils.js | runtimeSettingsDevice": {
2427
2427
  "message": "设备"
2428
2428
  },
2429
- "report/renderer/util.js | runtimeSettingsNetworkThrottling": {
2429
+ "report/renderer/report-utils.js | runtimeSettingsNetworkThrottling": {
2430
2430
  "message": "网络节流"
2431
2431
  },
2432
- "report/renderer/util.js | runtimeSettingsUANetwork": {
2432
+ "report/renderer/report-utils.js | runtimeSettingsUANetwork": {
2433
2433
  "message": "用户代理(网络)"
2434
2434
  },
2435
- "report/renderer/util.js | runtimeSingleLoad": {
2435
+ "report/renderer/report-utils.js | runtimeSingleLoad": {
2436
2436
  "message": "单次网页加载"
2437
2437
  },
2438
- "report/renderer/util.js | runtimeSingleLoadTooltip": {
2438
+ "report/renderer/report-utils.js | runtimeSingleLoadTooltip": {
2439
2439
  "message": "此数据是取自单次网页加载,现场数据则是汇总了许多次网页加载。"
2440
2440
  },
2441
- "report/renderer/util.js | runtimeSlow4g": {
2441
+ "report/renderer/report-utils.js | runtimeSlow4g": {
2442
2442
  "message": "低速 4G 节流"
2443
2443
  },
2444
- "report/renderer/util.js | runtimeUnknown": {
2444
+ "report/renderer/report-utils.js | runtimeUnknown": {
2445
2445
  "message": "不明"
2446
2446
  },
2447
- "report/renderer/util.js | show": {
2447
+ "report/renderer/report-utils.js | show": {
2448
2448
  "message": "显示"
2449
2449
  },
2450
- "report/renderer/util.js | showRelevantAudits": {
2450
+ "report/renderer/report-utils.js | showRelevantAudits": {
2451
2451
  "message": "显示与所选指标相关的评估结果:"
2452
2452
  },
2453
- "report/renderer/util.js | snippetCollapseButtonLabel": {
2453
+ "report/renderer/report-utils.js | snippetCollapseButtonLabel": {
2454
2454
  "message": "收起代码段"
2455
2455
  },
2456
- "report/renderer/util.js | snippetExpandButtonLabel": {
2456
+ "report/renderer/report-utils.js | snippetExpandButtonLabel": {
2457
2457
  "message": "展开代码段"
2458
2458
  },
2459
- "report/renderer/util.js | thirdPartyResourcesLabel": {
2459
+ "report/renderer/report-utils.js | thirdPartyResourcesLabel": {
2460
2460
  "message": "显示第三方资源"
2461
2461
  },
2462
- "report/renderer/util.js | throttlingProvided": {
2462
+ "report/renderer/report-utils.js | throttlingProvided": {
2463
2463
  "message": "由环境提供"
2464
2464
  },
2465
- "report/renderer/util.js | toplevelWarningsMessage": {
2465
+ "report/renderer/report-utils.js | toplevelWarningsMessage": {
2466
2466
  "message": "此次 Lighthouse 运行并不顺利,原因如下:"
2467
2467
  },
2468
- "report/renderer/util.js | varianceDisclaimer": {
2468
+ "report/renderer/report-utils.js | varianceDisclaimer": {
2469
2469
  "message": "这些都是估算值,且可能会因时而异。系统会直接基于这些指标来[计算性能得分](https://web.dev/performance-scoring/)。"
2470
2470
  },
2471
- "report/renderer/util.js | viewTreemapLabel": {
2471
+ "report/renderer/report-utils.js | viewTreemapLabel": {
2472
2472
  "message": "查看树状图"
2473
2473
  },
2474
- "report/renderer/util.js | warningAuditsGroupTitle": {
2474
+ "report/renderer/report-utils.js | warningAuditsGroupTitle": {
2475
2475
  "message": "已顺利通过审核,但有警告消息"
2476
2476
  },
2477
- "report/renderer/util.js | warningHeader": {
2477
+ "report/renderer/report-utils.js | warningHeader": {
2478
2478
  "message": "警告: "
2479
2479
  },
2480
2480
  "treemap/app/src/util.js | allLabel": {
@@ -0,0 +1,214 @@
1
+ /**
2
+ * @license Copyright 2017 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
+
7
+ import assert from 'assert/strict';
8
+
9
+ import {Util} from '../util.js';
10
+
11
+ describe('util helpers', () => {
12
+ describe('getTld', () => {
13
+ it('returns the correct tld', () => {
14
+ assert.equal(Util.getTld('example.com'), '.com');
15
+ assert.equal(Util.getTld('example.co.uk'), '.co.uk');
16
+ assert.equal(Util.getTld('example.com.br'), '.com.br');
17
+ assert.equal(Util.getTld('example.tokyo.jp'), '.jp');
18
+ });
19
+ });
20
+
21
+ describe('getRootDomain', () => {
22
+ it('returns the correct rootDomain from a string', () => {
23
+ assert.equal(Util.getRootDomain('https://www.example.com/index.html'), 'example.com');
24
+ assert.equal(Util.getRootDomain('https://example.com'), 'example.com');
25
+ assert.equal(Util.getRootDomain('https://www.example.co.uk'), 'example.co.uk');
26
+ assert.equal(Util.getRootDomain('https://example.com.br/app/'), 'example.com.br');
27
+ assert.equal(Util.getRootDomain('https://example.tokyo.jp'), 'tokyo.jp');
28
+ assert.equal(Util.getRootDomain('https://sub.example.com'), 'example.com');
29
+ assert.equal(Util.getRootDomain('https://sub.example.tokyo.jp'), 'tokyo.jp');
30
+ assert.equal(Util.getRootDomain('http://localhost'), 'localhost');
31
+ assert.equal(Util.getRootDomain('http://localhost:8080'), 'localhost');
32
+ });
33
+
34
+ it('returns the correct rootDomain from an URL object', () => {
35
+ assert.equal(Util.getRootDomain(new URL('https://www.example.com/index.html')), 'example.com');
36
+ assert.equal(Util.getRootDomain(new URL('https://example.com')), 'example.com');
37
+ assert.equal(Util.getRootDomain(new URL('https://www.example.co.uk')), 'example.co.uk');
38
+ assert.equal(Util.getRootDomain(new URL('https://example.com.br/app/')), 'example.com.br');
39
+ assert.equal(Util.getRootDomain(new URL('https://example.tokyo.jp')), 'tokyo.jp');
40
+ assert.equal(Util.getRootDomain(new URL('https://sub.example.com')), 'example.com');
41
+ assert.equal(Util.getRootDomain(new URL('https://sub.example.tokyo.jp')), 'tokyo.jp');
42
+ assert.equal(Util.getRootDomain(new URL('http://localhost')), 'localhost');
43
+ assert.equal(Util.getRootDomain(new URL('http://localhost:8080')), 'localhost');
44
+ });
45
+ });
46
+
47
+ describe('#splitMarkdownCodeSpans', () => {
48
+ it('handles strings with no backticks in them', () => {
49
+ expect(Util.splitMarkdownCodeSpans('regular text')).toEqual([
50
+ {isCode: false, text: 'regular text'},
51
+ ]);
52
+ });
53
+
54
+ it('does not split on a single backtick', () => {
55
+ expect(Util.splitMarkdownCodeSpans('regular `text')).toEqual([
56
+ {isCode: false, text: 'regular `text'},
57
+ ]);
58
+ });
59
+
60
+ it('splits on backticked code', () => {
61
+ expect(Util.splitMarkdownCodeSpans('regular `code` text')).toEqual([
62
+ {isCode: false, text: 'regular '},
63
+ {isCode: true, text: 'code'},
64
+ {isCode: false, text: ' text'},
65
+ ]);
66
+ });
67
+
68
+ it('splits on backticked code at the beginning of the string', () => {
69
+ expect(Util.splitMarkdownCodeSpans('`start code` regular text')).toEqual([
70
+ {isCode: true, text: 'start code'},
71
+ {isCode: false, text: ' regular text'},
72
+ ]);
73
+ });
74
+
75
+ it('splits on backticked code at the end of the string', () => {
76
+ expect(Util.splitMarkdownCodeSpans('regular text `end code`')).toEqual([
77
+ {isCode: false, text: 'regular text '},
78
+ {isCode: true, text: 'end code'},
79
+ ]);
80
+ });
81
+
82
+ it('does not split on a single backtick after split out backticked code', () => {
83
+ expect(Util.splitMarkdownCodeSpans('regular text `code` and more `text')).toEqual([
84
+ {isCode: false, text: 'regular text '},
85
+ {isCode: true, text: 'code'},
86
+ {isCode: false, text: ' and more `text'},
87
+ ]);
88
+ });
89
+
90
+ it('splits on two instances of backticked code', () => {
91
+ expect(Util.splitMarkdownCodeSpans('regular text `code` more text `and more code`')).toEqual([
92
+ {isCode: false, text: 'regular text '},
93
+ {isCode: true, text: 'code'},
94
+ {isCode: false, text: ' more text '},
95
+ {isCode: true, text: 'and more code'},
96
+ ]);
97
+ });
98
+
99
+ it('splits on two directly adjacent instances of backticked code', () => {
100
+ // eslint-disable-next-line max-len
101
+ expect(Util.splitMarkdownCodeSpans('regular text `first code``second code` end text')).toEqual([
102
+ {isCode: false, text: 'regular text '},
103
+ {isCode: true, text: 'first code'},
104
+ {isCode: true, text: 'second code'},
105
+ {isCode: false, text: ' end text'},
106
+ ]);
107
+ });
108
+
109
+ it('handles text only within backticks', () => {
110
+ expect(Util.splitMarkdownCodeSpans('`first code``second code`')).toEqual([
111
+ {isCode: true, text: 'first code'},
112
+ {isCode: true, text: 'second code'},
113
+ ]);
114
+ });
115
+
116
+ it('splits on two instances of backticked code separated by only a space', () => {
117
+ // eslint-disable-next-line max-len
118
+ expect(Util.splitMarkdownCodeSpans('`first code` `second code`')).toEqual([
119
+ {isCode: true, text: 'first code'},
120
+ {isCode: false, text: ' '},
121
+ {isCode: true, text: 'second code'},
122
+ ]);
123
+ });
124
+ });
125
+
126
+ describe('#splitMarkdownLink', () => {
127
+ it('handles strings with no links in them', () => {
128
+ expect(Util.splitMarkdownLink('some text')).toEqual([
129
+ {isLink: false, text: 'some text'},
130
+ ]);
131
+ });
132
+
133
+ it('does not split on an incomplete markdown link', () => {
134
+ expect(Util.splitMarkdownLink('some [not link text](text')).toEqual([
135
+ {isLink: false, text: 'some [not link text](text'},
136
+ ]);
137
+ });
138
+
139
+ it('splits on a markdown link', () => {
140
+ expect(Util.splitMarkdownLink('some [link text](https://example.com) text')).toEqual([
141
+ {isLink: false, text: 'some '},
142
+ {isLink: true, text: 'link text', linkHref: 'https://example.com'},
143
+ {isLink: false, text: ' text'},
144
+ ]);
145
+ });
146
+
147
+ it('splits on an http markdown link', () => {
148
+ expect(Util.splitMarkdownLink('you should [totally click here](http://never-mitm.com) now')).toEqual([
149
+ {isLink: false, text: 'you should '},
150
+ {isLink: true, text: 'totally click here', linkHref: 'http://never-mitm.com'},
151
+ {isLink: false, text: ' now'},
152
+ ]);
153
+ });
154
+
155
+ it('does not split on a non-http/https link', () => {
156
+ expect(Util.splitMarkdownLink('some [link text](ftp://example.com) text')).toEqual([
157
+ {isLink: false, text: 'some [link text](ftp://example.com) text'},
158
+ ]);
159
+ });
160
+
161
+ it('does not split on a malformed markdown link', () => {
162
+ expect(Util.splitMarkdownLink('some [link ]text](https://example.com')).toEqual([
163
+ {isLink: false, text: 'some [link ]text](https://example.com'},
164
+ ]);
165
+
166
+ expect(Util.splitMarkdownLink('some [link text] (https://example.com')).toEqual([
167
+ {isLink: false, text: 'some [link text] (https://example.com'},
168
+ ]);
169
+ });
170
+
171
+ it('does not split on empty link text', () => {
172
+ expect(Util.splitMarkdownLink('some [](https://example.com) empty link')).toEqual([
173
+ {isLink: false, text: 'some [](https://example.com) empty link'},
174
+ ]);
175
+ });
176
+
177
+ it('splits on a markdown link at the beginning of a string', () => {
178
+ expect(Util.splitMarkdownLink('[link text](https://example.com) end text')).toEqual([
179
+ {isLink: true, text: 'link text', linkHref: 'https://example.com'},
180
+ {isLink: false, text: ' end text'},
181
+ ]);
182
+ });
183
+
184
+ it('splits on a markdown link at the end of a string', () => {
185
+ expect(Util.splitMarkdownLink('start text [link text](https://example.com)')).toEqual([
186
+ {isLink: false, text: 'start text '},
187
+ {isLink: true, text: 'link text', linkHref: 'https://example.com'},
188
+ ]);
189
+ });
190
+
191
+ it('handles a string consisting only of a markdown link', () => {
192
+ expect(Util.splitMarkdownLink(`[I'm only a link](https://example.com)`)).toEqual([
193
+ {isLink: true, text: `I'm only a link`, linkHref: 'https://example.com'},
194
+ ]);
195
+ });
196
+
197
+ it('handles a string starting and ending with a markdown link', () => {
198
+ expect(Util.splitMarkdownLink('[first link](https://first.com) other text [second link](https://second.com)')).toEqual([
199
+ {isLink: true, text: 'first link', linkHref: 'https://first.com'},
200
+ {isLink: false, text: ' other text '},
201
+ {isLink: true, text: 'second link', linkHref: 'https://second.com'},
202
+ ]);
203
+ });
204
+
205
+ it('handles a string with adjacent markdown links', () => {
206
+ expect(Util.splitMarkdownLink('start text [first link](https://first.com)[second link](https://second.com) and scene')).toEqual([
207
+ {isLink: false, text: 'start text '},
208
+ {isLink: true, text: 'first link', linkHref: 'https://first.com'},
209
+ {isLink: true, text: 'second link', linkHref: 'https://second.com'},
210
+ {isLink: false, text: ' and scene'},
211
+ ]);
212
+ });
213
+ });
214
+ });