@bymaksym/loadline 0.1.0 → 1.1.0

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 (115) hide show
  1. package/README.md +272 -45
  2. package/dist/cli/cli/args.js +97 -116
  3. package/dist/cli/cli/gates.js +80 -14
  4. package/dist/cli/cli/main.js +275 -31
  5. package/dist/cli/cli/memory.js +114 -0
  6. package/dist/cli/cli/read/declared.js +52 -0
  7. package/dist/cli/cli/read/locate.js +214 -0
  8. package/dist/cli/cli/{read-build.js → read/read-build.js} +156 -87
  9. package/dist/cli/cli/read/read-config.js +120 -0
  10. package/dist/cli/cli/render/html-report.js +111 -0
  11. package/dist/cli/cli/render/render-agent.js +114 -0
  12. package/dist/cli/cli/render/render-asked.js +104 -0
  13. package/dist/cli/cli/render/render-badge.js +140 -0
  14. package/dist/cli/cli/{render-json.js → render/render-json.js} +26 -10
  15. package/dist/cli/cli/{render-markdown.js → render/render-markdown.js} +6 -6
  16. package/dist/cli/cli/{render-pr.js → render/render-pr.js} +37 -15
  17. package/dist/cli/cli/{render-sarif.js → render/render-sarif.js} +11 -6
  18. package/dist/cli/cli/{render-text.js → render/render-text.js} +169 -127
  19. package/dist/cli/cli/render/terminal.js +55 -0
  20. package/dist/cli/cli/report.js +76 -29
  21. package/dist/cli/cli/self-check.js +19 -23
  22. package/dist/cli/cli/since-last.js +45 -0
  23. package/dist/cli/cli/text/text-errors.js +124 -0
  24. package/dist/cli/cli/text/text.js +343 -0
  25. package/dist/cli/cli/text/usage.js +240 -0
  26. package/dist/cli/src/app/core/analysis/analysis.js +68 -24
  27. package/dist/cli/src/app/core/analysis/{barrels.js → graph/barrels.js} +10 -3
  28. package/dist/cli/src/app/core/analysis/{blast.js → graph/blast.js} +56 -17
  29. package/dist/cli/src/app/core/analysis/{cycles.js → graph/cycles.js} +1 -1
  30. package/dist/cli/src/app/core/analysis/{importers.js → graph/importers.js} +1 -1
  31. package/dist/cli/src/app/core/analysis/{insights.js → graph/insights.js} +10 -4
  32. package/dist/cli/src/app/core/analysis/invariant.js +1 -1
  33. package/dist/cli/src/app/core/analysis/metafile.types.js +21 -7
  34. package/dist/cli/src/app/core/analysis/{delivery.js → screens/delivery.js} +1 -1
  35. package/dist/cli/src/app/core/analysis/{entries.js → screens/entries.js} +87 -11
  36. package/dist/cli/src/app/core/analysis/screens/marks.js +32 -0
  37. package/dist/cli/src/app/core/analysis/screens/route-files.js +116 -0
  38. package/dist/cli/src/app/core/analysis/{sourcemap.js → sourcemap/sourcemap.js} +106 -7
  39. package/dist/cli/src/app/core/analysis/{split-drift.js → sourcemap/split-drift.js} +13 -7
  40. package/dist/cli/src/app/core/analysis/tool.js +83 -0
  41. package/dist/cli/src/app/core/assets/assets.js +137 -16
  42. package/dist/cli/src/app/core/baseline/baseline.js +0 -0
  43. package/dist/cli/src/app/core/{intake → build-text}/index-html.js +234 -29
  44. package/dist/cli/src/app/core/build-text/route-table.js +178 -0
  45. package/dist/cli/src/app/core/build-text/tool-marks.js +54 -0
  46. package/dist/cli/src/app/core/caching/caching.js +123 -45
  47. package/dist/cli/src/app/core/caching/from-analysis.js +20 -4
  48. package/dist/cli/src/app/core/config/config-text.js +90 -0
  49. package/dist/cli/src/app/core/config/config-values.js +358 -0
  50. package/dist/cli/src/app/core/config/loadline-config.js +81 -16
  51. package/dist/cli/src/app/core/config/merge-config.js +98 -0
  52. package/dist/cli/src/app/core/deps/deps.js +141 -23
  53. package/dist/cli/src/app/core/deps/pins.js +63 -0
  54. package/dist/cli/src/app/core/export/summary.js +54 -12
  55. package/dist/cli/src/app/core/findings/actions.js +65 -6
  56. package/dist/cli/src/app/core/findings/bundle/boot-single.js +76 -0
  57. package/dist/cli/src/app/core/findings/bundle/dupes.js +68 -0
  58. package/dist/cli/src/app/core/findings/{graph.js → bundle/graph.js} +32 -20
  59. package/dist/cli/src/app/core/findings/{own-in-boot.js → bundle/own-in-boot.js} +9 -5
  60. package/dist/cli/src/app/core/findings/{requests.js → bundle/requests.js} +3 -3
  61. package/dist/cli/src/app/core/findings/{shipped.js → bundle/shipped.js} +30 -18
  62. package/dist/cli/src/app/core/findings/compose.js +6 -1
  63. package/dist/cli/src/app/core/findings/effort.js +4 -0
  64. package/dist/cli/src/app/core/findings/finding.types.js +2 -0
  65. package/dist/cli/src/app/core/findings/findings.js +68 -55
  66. package/dist/cli/src/app/core/findings/{assets.js → folder/assets.js} +65 -16
  67. package/dist/cli/src/app/core/findings/{caching.js → folder/caching.js} +17 -10
  68. package/dist/cli/src/app/core/findings/{page.js → folder/page.js} +6 -2
  69. package/dist/cli/src/app/core/findings/{scan.js → folder/scan.js} +37 -13
  70. package/dist/cli/src/app/core/findings/kind-names.js +163 -0
  71. package/dist/cli/src/app/core/findings/{deps.js → supplied/deps.js} +13 -8
  72. package/dist/cli/src/app/core/findings/supplied/forbidden.js +71 -0
  73. package/dist/cli/src/app/core/findings/{situation.js → supplied/situation.js} +2 -2
  74. package/dist/cli/src/app/core/findings/text/causes.js +39 -0
  75. package/dist/cli/src/app/core/findings/text/finding-html.js +33 -0
  76. package/dist/cli/src/app/core/findings/{finding-text.js → text/finding-text.js} +307 -103
  77. package/dist/cli/src/app/core/findings/text/tool-advice.js +97 -0
  78. package/dist/cli/src/app/core/format/format.utils.js +172 -18
  79. package/dist/cli/src/app/core/format/ownership.js +93 -0
  80. package/dist/cli/src/app/core/i18n/en.js +180 -61
  81. package/dist/cli/src/app/core/i18n/es.js +192 -68
  82. package/dist/cli/src/app/core/intake/bundle-graph.js +285 -46
  83. package/dist/cli/src/app/core/intake/dist-files.js +87 -16
  84. package/dist/cli/src/app/core/intake/embedded.js +56 -0
  85. package/dist/cli/src/app/core/intake/unreached.js +139 -0
  86. package/dist/cli/src/app/core/intake/webpack-modules.js +185 -0
  87. package/dist/cli/src/app/core/intake/webpack-stats.js +298 -0
  88. package/dist/cli/src/app/core/project/budget-advice.js +14 -10
  89. package/dist/cli/src/app/core/project/project-context.js +89 -19
  90. package/dist/cli/src/app/core/project/project-name.js +36 -0
  91. package/dist/cli/src/app/core/scan/scan.js +116 -39
  92. package/dist/cli/src/app/core/scan/secrets.js +0 -0
  93. package/dist/cli/src/app/core/situation/situation-text.js +23 -0
  94. package/dist/cli/src/app/core/situation/situation.js +9 -8
  95. package/dist/cli/src/app/core/timing/timing.js +5 -2
  96. package/dist/cli/src/app/core/whatif/defer.js +29 -4
  97. package/dist/cli/src/app/core/whatif/source-importers.js +58 -0
  98. package/dist/cli/src/app/core/whatif/why.js +102 -0
  99. package/dist/cli/src/app/state/report-messages.utils.js +1 -4
  100. package/docs/CONFIG-REFERENCE.md +230 -0
  101. package/docs/CONFIG.md +511 -0
  102. package/docs/HOW-IT-WORKS.md +286 -25
  103. package/loadline.html +26 -24
  104. package/loadline.schema.json +1209 -0
  105. package/package.json +71 -35
  106. package/dist/cli/cli/text.js +0 -180
  107. package/dist/cli/src/app/core/findings/finding-html.js +0 -13
  108. /package/dist/cli/cli/{read-build.types.js → read/read-build.types.js} +0 -0
  109. /package/dist/cli/cli/{render-json.types.js → render/render-json.types.js} +0 -0
  110. /package/dist/cli/cli/{text.types.js → text/text.types.js} +0 -0
  111. /package/dist/cli/src/app/core/analysis/{exclusive.js → graph/exclusive.js} +0 -0
  112. /package/dist/cli/src/app/core/analysis/{insights.types.js → graph/insights.types.js} +0 -0
  113. /package/dist/cli/src/app/core/analysis/{module-graph.js → graph/module-graph.js} +0 -0
  114. /package/dist/cli/src/app/core/analysis/{sourcemap.types.js → sourcemap/sourcemap.types.js} +0 -0
  115. /package/dist/cli/src/app/core/findings/{finding-plain.js → text/finding-plain.js} +0 -0
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+ /**
3
+ * What each signal is, in the words its card uses, in both languages.
4
+ *
5
+ * A `Record` over every kind, so a signal added without a name here does not compile. The schema
6
+ * of `loadline.json` describes what `accepted` can name with the English half. The report uses
7
+ * both halves wherever it names a signal without its card at hand: one that went away since the
8
+ * baseline has no card any more, and "No longer raised: `cycles`, `dupes`" named two identifiers
9
+ * where it meant two problems.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.signalList = exports.KIND_NAMES = void 0;
13
+ const finding_html_1 = require("./text/finding-html");
14
+ exports.KIND_NAMES = {
15
+ en: {
16
+ shared: 'common code marked as lazy',
17
+ bootLazy: 'bootstrap for a lazy screen',
18
+ bootSingle: 'bootstrap package with a single importer',
19
+ bigFile: 'large source file',
20
+ dupes: 'duplicate copies of a package',
21
+ heavy: 'expensive screen',
22
+ clean: 'no signals',
23
+ commonJs: 'CommonJS package',
24
+ ownInBoot: 'your own code in the bootstrap for a lazy screen',
25
+ locales: 'every language of a library',
26
+ dataAsCode: 'data shipped as code',
27
+ sourceMaps: 'source maps in the folder',
28
+ noSourceMaps: 'folder without source maps',
29
+ splitDrift: 'the breakdown does not add up to the file',
30
+ prefetched: 'screens fetched before anybody asks',
31
+ unreachable: 'chunks this report cannot reach',
32
+ mixedImport: 'imported both statically and dynamically',
33
+ ownBarrel: 'barrel file of your own in the bootstrap',
34
+ packageBarrel: 'package that comes in whole',
35
+ cycles: 'import cycles',
36
+ paidTwice: 'bytes paid for twice',
37
+ twinScreens: 'twin screens',
38
+ theirs: 'whose first load this is',
39
+ fonts: 'fonts',
40
+ media: 'images and video',
41
+ duplicateAssets: 'the same file under two names',
42
+ unreferencedAssets: 'files nothing reaches',
43
+ inlinedData: 'files embedded as data URIs',
44
+ updateWeight: 'weight of the update',
45
+ unstableChunk: 'chunk mixing what changes with what does not',
46
+ unhashable: 'names that cannot be cached',
47
+ secrets: 'secrets or internal addresses in the bundle',
48
+ devLeftovers: 'development leftovers in production',
49
+ sourceExposed: 'your source code is published',
50
+ thirdParty: 'third-party services',
51
+ licences: 'licences with conditions',
52
+ vulnerable: 'vulnerabilities that actually ship',
53
+ transitive: 'packages you did not ask for',
54
+ forbidden: 'forbidden in loadline.json',
55
+ bootWaves: 'bootstrap in several round trips',
56
+ slowScreens: 'discovery depth',
57
+ manyRequests: 'granularity of the split',
58
+ bootGrew: 'bootstrap has grown',
59
+ bootNewPackages: 'new package in the bootstrap',
60
+ sharedGrew: 'shared chunk has grown',
61
+ signalsChanged: 'signals fixed and new',
62
+ screensGrew: 'screen has grown',
63
+ budgetNone: 'no size budget',
64
+ budgetNotBuilt: 'budget the pipeline never applies',
65
+ budgetWarnOnly: 'budget that only warns',
66
+ budgetTooHigh: 'budget too high',
67
+ zoneless: 'no zone.js',
68
+ assetOrigin: 'assets served from another host',
69
+ cascadeShape: 'hash cascade',
70
+ servedUncompressed: 'JavaScript served uncompressed',
71
+ measuredWaves: 'more batches than computed',
72
+ poolExhausted: 'the connection pool ran out',
73
+ thirdPartyLoad: 'third-party requests in the same load',
74
+ revalidated: 'hashed files being revalidated',
75
+ swControlling: 'a service worker controls this load',
76
+ measuredOrigin: 'the code came from another host',
77
+ observedChannel: 'observed environment',
78
+ measuredEager: 'the router loads an area the guard then rejects',
79
+ measuredExtra: 'measured above computed',
80
+ measuredShort: 'measured below computed',
81
+ measuredMatch: 'computed and measured agree',
82
+ situationAsked: 'the situation, answered',
83
+ situationPriority: 'which wait the team would rather pay',
84
+ situationMissing: 'questions that would change this report',
85
+ },
86
+ es: {
87
+ shared: 'código común marcado como lazy',
88
+ bootLazy: 'bootstrap para una pantalla lazy',
89
+ bootSingle: 'paquete del arranque con un solo importador',
90
+ bigFile: 'fichero propio grande',
91
+ dupes: 'copias duplicadas',
92
+ heavy: 'pantalla cara',
93
+ clean: 'sin señales',
94
+ commonJs: 'paquete en CommonJS',
95
+ ownInBoot: 'código tuyo en el bootstrap para una pantalla lazy',
96
+ locales: 'todos los idiomas de una librería',
97
+ dataAsCode: 'datos incluidos como código',
98
+ sourceMaps: 'source maps en la carpeta',
99
+ noSourceMaps: 'carpeta sin source maps',
100
+ splitDrift: 'el desglose no cuadra con el fichero',
101
+ prefetched: 'pantallas que se piden antes de que nadie las abra',
102
+ unreachable: 'chunks que el informe no alcanza',
103
+ mixedImport: 'import estático y dinámico a la vez',
104
+ ownBarrel: 'barrel file propio en el bootstrap',
105
+ packageBarrel: 'paquete que entra entero',
106
+ cycles: 'ciclos de importación',
107
+ paidTwice: 'bytes pagados dos veces',
108
+ twinScreens: 'pantallas gemelas',
109
+ theirs: 'de quién es la primera carga',
110
+ fonts: 'tipografías',
111
+ media: 'imágenes y vídeo',
112
+ duplicateAssets: 'el mismo fichero con dos nombres',
113
+ unreferencedAssets: 'ficheros que no alcanza nadie',
114
+ inlinedData: 'ficheros incrustados como data URI',
115
+ updateWeight: 'peso de la actualización',
116
+ unstableChunk: 'chunk que mezcla lo que cambia con lo que no',
117
+ unhashable: 'nombres que no se pueden cachear',
118
+ secrets: 'secretos o direcciones internas en el bundle',
119
+ devLeftovers: 'restos de desarrollo en producción',
120
+ sourceExposed: 'tu código fuente está publicado',
121
+ thirdParty: 'servicios de terceros',
122
+ licences: 'licencias con condiciones',
123
+ vulnerable: 'vulnerabilidades que sí viajan',
124
+ transitive: 'paquetes que no pides tú',
125
+ forbidden: 'prohibido en loadline.json',
126
+ bootWaves: 'el arranque en varias idas y vueltas',
127
+ slowScreens: 'profundidad de descubrimiento',
128
+ manyRequests: 'granularidad del troceado',
129
+ bootGrew: 'el bootstrap ha crecido',
130
+ bootNewPackages: 'paquete nuevo en el bootstrap',
131
+ sharedGrew: 'chunk compartido que ha crecido',
132
+ signalsChanged: 'señales nuevas y resueltas',
133
+ screensGrew: 'pantalla que ha crecido',
134
+ budgetNone: 'sin budget de tamaño',
135
+ budgetNotBuilt: 'budget que el pipeline no aplica',
136
+ budgetWarnOnly: 'budget que solo avisa',
137
+ budgetTooHigh: 'budget demasiado alto',
138
+ zoneless: 'sin zone.js',
139
+ assetOrigin: 'los assets salen de otro host',
140
+ cascadeShape: 'cascada de hashes',
141
+ servedUncompressed: 'JavaScript servido sin comprimir',
142
+ measuredWaves: 'más tandas de las calculadas',
143
+ poolExhausted: 'se agotó el pool de conexiones',
144
+ thirdPartyLoad: 'peticiones a terceros en la misma carga',
145
+ revalidated: 'ficheros con hash que se revalidan',
146
+ swControlling: 'un service worker controla esta carga',
147
+ measuredOrigin: 'el código vino de otro host',
148
+ observedChannel: 'entorno observado',
149
+ measuredEager: 'el router carga una zona antes de que el guard la rechace',
150
+ measuredExtra: 'medido por encima de lo calculado',
151
+ measuredShort: 'medido por debajo de lo calculado',
152
+ measuredMatch: 'calculado y medido coinciden',
153
+ situationAsked: 'la situación, contestada',
154
+ situationPriority: 'qué espera prefiere pagar el equipo',
155
+ situationMissing: 'preguntas que cambiarían este informe',
156
+ },
157
+ };
158
+ /**
159
+ * Signals named by what each one is, with what it was about: "import cycles, duplicate copies of a
160
+ * package (`lodash`)". A signal that went away has no card left to take its chip from.
161
+ */
162
+ const signalList = (lang, list) => list.map(item => `${exports.KIND_NAMES[lang][item.kind]}${item.key ? ` (${(0, finding_html_1.mono)(item.key)})` : ''}`).join(', ');
163
+ exports.signalList = signalList;
@@ -12,10 +12,15 @@
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.buildDepsFindings = void 0;
15
- const format_utils_1 = require("../format/format.utils");
16
- const finding_html_1 = require("./finding-html");
17
- const finding_text_1 = require("./finding-text");
18
- const buildDepsFindings = (deps, lang, c) => {
15
+ const actions_1 = require("../actions");
16
+ const finding_html_1 = require("../text/finding-html");
17
+ const finding_text_1 = require("../text/finding-text");
18
+ /**
19
+ * @param scale how the raw weights of packages are said in the report's unit: `unitScale` of the
20
+ * analysis. Raw by default.
21
+ */
22
+ const buildDepsFindings = (deps, lang, c, scale = actions_1.RAW_SCALE) => {
23
+ const sized = (bytes) => (0, actions_1.formatSaving)(bytes, scale);
19
24
  const text = finding_text_1.TEXT[lang];
20
25
  const findings = [];
21
26
  // 1 · The advisories that actually ship. Everything else is real and is not what a browser
@@ -35,7 +40,7 @@ const buildDepsFindings = (deps, lang, c) => {
35
40
  inBoot: inBoot.length,
36
41
  worst: first.package,
37
42
  list: shipped
38
- .map(advisory => `${(0, finding_html_1.mono)(advisory.package)} ${advisory.severity}${advisory.inBoot ? ', bootstrap' : ''} (${(0, format_utils_1.formatBytes)(advisory.bytes)}) — ${advisory.title}`)
43
+ .map(advisory => `${(0, finding_html_1.mono)(advisory.package)} ${advisory.severity}${advisory.inBoot ? ', bootstrap' : ''} (${sized(advisory.bytes)}) — ${advisory.title}`)
39
44
  .join(' · '),
40
45
  elsewhere: deps.notShipped.map(advisory => (0, finding_html_1.mono)(advisory.package)).join(', '),
41
46
  }),
@@ -52,11 +57,11 @@ const buildDepsFindings = (deps, lang, c) => {
52
57
  kind: 'transitive',
53
58
  ...text.transitive({
54
59
  count: transitive.length,
55
- size: (0, format_utils_1.formatBytes)(bytes),
60
+ size: sized(bytes),
56
61
  worst: heaviest.name,
57
- worstSize: (0, format_utils_1.formatBytes)(heaviest.bytes),
62
+ worstSize: sized(heaviest.bytes),
58
63
  list: transitive
59
- .map(entry => `${(0, finding_html_1.mono)(entry.name)} (${(0, format_utils_1.formatBytes)(entry.bytes)}${entry.inBoot ? ', bootstrap' : ''})${entry.chain.length > 0 ? ` — via ${entry.chain.join(' › ')}` : ''}`)
64
+ .map(entry => `${(0, finding_html_1.mono)(entry.name)} (${sized(entry.bytes)}${entry.inBoot ? ', bootstrap' : ''})${entry.chain.length > 0 ? ` — via ${entry.chain.join(' › ')}` : ''}`)
60
65
  .join(' · '),
61
66
  }),
62
67
  });
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ /**
3
+ * What `loadline.json` forbids, found in the build: one signal per rule that matches.
4
+ *
5
+ * Every other signal is this tool's opinion about a build. This one is the team's, written down in
6
+ * `forbidden`, and the tool only says where the rule is broken and which import breaks it. That is
7
+ * why it is high whatever the size: the team already decided it matters, and a 2 kB `moment` locale
8
+ * breaks "no moment" exactly as much as the whole library does.
9
+ *
10
+ * The key of each signal is the rule as written — `moment`, `src/app/admin/*` — rather than what it
11
+ * matched, so an acceptance names the same text the rule does.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.buildForbiddenFindings = void 0;
15
+ const format_utils_1 = require("../../format/format.utils");
16
+ const finding_html_1 = require("../text/finding-html");
17
+ const finding_text_1 = require("../text/finding-text");
18
+ /** Names listed on the card before "and N more": enough to recognise the rule, not a dump. */
19
+ const LISTED = 5;
20
+ const matches = (rule, module) => rule.package === undefined
21
+ ? !module.pkg && (0, format_utils_1.namedBy)(rule.path ?? '', module.path)
22
+ : !!module.pkg && (0, format_utils_1.matchesStars)(rule.package, module.pkg);
23
+ const buildForbiddenFindings = (analysis, rules, lang) => {
24
+ if (!rules || rules.length === 0) {
25
+ return [];
26
+ }
27
+ const insights = analysis.insights();
28
+ return rules.flatMap(rule => {
29
+ const inBoot = rule.in === 'bootstrap';
30
+ const hits = analysis.modules
31
+ .filter(module => matches(rule, module))
32
+ .map(module => ({
33
+ module,
34
+ bytes: module.places
35
+ .filter(place => !inBoot || place.zone === 'boot')
36
+ .reduce((sum, place) => sum + place.bytes, 0),
37
+ }))
38
+ .filter(hit => hit.bytes > 0)
39
+ .toSorted((a, b) => b.bytes - a.bytes);
40
+ const first = hits[0];
41
+ if (!first) {
42
+ return [];
43
+ }
44
+ const key = rule.package ?? rule.path ?? '';
45
+ const files = hits.map(hit => hit.module.path);
46
+ const bytes = hits.reduce((sum, hit) => sum + hit.bytes, 0);
47
+ const names = [...new Set(hits.map(hit => hit.module.pkg ?? hit.module.label))];
48
+ const chain = analysis.chainTo(first.module.path);
49
+ return [
50
+ {
51
+ severity: 'high',
52
+ target: { tab: 'search', key },
53
+ kind: 'forbidden',
54
+ size: bytes,
55
+ ...(inBoot && { saving: insights.exclusiveOf(files) }),
56
+ sources: files,
57
+ ...finding_text_1.TEXT[lang].forbidden({
58
+ rule: key,
59
+ ruleHtml: (0, finding_html_1.mono)((0, finding_html_1.escapeHtml)(key)),
60
+ inBoot,
61
+ why: (0, finding_html_1.escapeHtml)(rule.why),
62
+ size: (0, format_utils_1.formatBytes)(bytes),
63
+ names: names.slice(0, LISTED).map(name => (0, finding_html_1.mono)(name)),
64
+ more: Math.max(0, names.length - LISTED),
65
+ chain: chain && chain.length > 1 ? (0, finding_html_1.chainHtml)((0, format_utils_1.chainSteps)(chain)) : null,
66
+ }),
67
+ },
68
+ ];
69
+ });
70
+ };
71
+ exports.buildForbiddenFindings = buildForbiddenFindings;
@@ -22,8 +22,8 @@
22
22
  */
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.buildSituationFindings = void 0;
25
- const situation_1 = require("../situation/situation");
26
- const finding_text_1 = require("./finding-text");
25
+ const situation_1 = require("../../situation/situation");
26
+ const finding_text_1 = require("../text/finding-text");
27
27
  /**
28
28
  * Which signal being on the report makes which question worth asking.
29
29
  *
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /**
3
+ * What a change against the baseline is made of, as the growth signals print it: "`xlsx` ≈+118 kB
4
+ * (new)". The delta alone answers "how much"; the question on a merge request is "what did I add".
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.screenCausesText = exports.bootCausesText = void 0;
8
+ const format_utils_1 = require("../../format/format.utils");
9
+ const finding_html_1 = require("./finding-html");
10
+ const finding_text_1 = require("./finding-text");
11
+ /** How many causes the bootstrap's growth names: the ones that explain it, not the whole tail. */
12
+ const BOOT_CAUSES_SHOWN = 5;
13
+ /**
14
+ * The same for each screen that grew. Lower, because that signal lists several screens in one
15
+ * sentence and each brings its own: three is enough to say where the growth is.
16
+ */
17
+ const SCREEN_CAUSES_SHOWN = 3;
18
+ /**
19
+ * One entry per cause: "`@microsoft/teams-js` ≈+19 kB (new)", "`src/app/rooms` ≈+2 kB (your code)".
20
+ * In the report's unit, with `≈` when that is an estimate.
21
+ */
22
+ const causesText = (causes, unit, lang, shown) => {
23
+ const text = finding_text_1.TEXT[lang];
24
+ const mark = unit.estimated ? '≈' : '';
25
+ return causes.slice(0, shown).map(cause => {
26
+ const notes = [text.bootCauseChange[cause.change], cause.own ? text.bootCauseOwn : ''].filter(Boolean);
27
+ const figure = `${mark}${(0, format_utils_1.formatDelta)(Math.round(cause.diff * unit.ratio))}`;
28
+ return `${(0, finding_html_1.mono)(cause.name)} ${figure}${notes.length > 0 ? ` (${notes.join(', ')})` : ''}`;
29
+ });
30
+ };
31
+ /** What the bootstrap's change is made of, as one line. Empty when nothing moved enough to name. */
32
+ const bootCausesText = (comparison, lang) => causesText(comparison.bootCauses, { ratio: comparison.causesRatio, estimated: comparison.causesEstimated }, lang, BOOT_CAUSES_SHOWN).join(' · ');
33
+ exports.bootCausesText = bootCausesText;
34
+ /**
35
+ * What one screen's change is made of, one entry per cause. Empty when either snapshot lacked the
36
+ * screen's breakdown, so the text claims none rather than an invented one.
37
+ */
38
+ const screenCausesText = (screen, lang) => causesText(screen.causes ?? [], { ratio: screen.causesRatio, estimated: screen.causesEstimated }, lang, SCREEN_CAUSES_SHOWN);
39
+ exports.screenCausesText = screenCausesText;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /**
3
+ * The two bits of markup every signal is written with. Signal text carries HTML on purpose: a file
4
+ * name or a version number set apart from the sentence is what makes it findable at a glance.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.escapeHtml = exports.fewNamed = exports.chainHtml = exports.mono = void 0;
8
+ /** A name as code: a file, a package, a configuration key. */
9
+ const mono = (text) => `<span class="mono">${text}</span>`;
10
+ exports.mono = mono;
11
+ /** An import chain as HTML: each step in monospace, joined by a separator. */
12
+ const chainHtml = (steps) => steps.map(step => (0, exports.mono)(step)).join(' › ');
13
+ exports.chainHtml = chainHtml;
14
+ /**
15
+ * A list of names cut to the first few, with how many were left out. For the lists that grow with
16
+ * the project rather than with the problem: the hundred files importing `@angular/core` pasted into
17
+ * one paragraph said nothing the first five did not.
18
+ */
19
+ const fewNamed = (items, more, max = 5) => {
20
+ const shown = items
21
+ .slice(0, max)
22
+ .map(item => (0, exports.mono)(item))
23
+ .join(', ');
24
+ return items.length > max ? `${shown} ${more(items.length - max)}` : shown;
25
+ };
26
+ exports.fewNamed = fewNamed;
27
+ /**
28
+ * Text somebody wrote in `loadline.json`, made safe to put into a signal's HTML. Every other piece
29
+ * of a signal is written here or read from a build; this one is free text from a person, and a
30
+ * `<` in a reason would otherwise open a tag on the page and vanish from the terminal.
31
+ */
32
+ const escapeHtml = (text) => text.replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('"', '&quot;');
33
+ exports.escapeHtml = escapeHtml;