@mui/internal-bundle-size-checker 1.0.9-canary.71 → 1.0.9-canary.72

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.
package/build/cli.d.ts CHANGED
@@ -1,5 +1,3 @@
1
1
  export type CommandLineArgs = import('./types.js').CommandLineArgs;
2
2
  export type NormalizedBundleSizeCheckerConfig = import('./types.js').NormalizedBundleSizeCheckerConfig;
3
3
  export type SizeSnapshotEntry = import('./types.js').SizeSnapshotEntry;
4
- export type ReportCommandArgs = import('./types.js').ReportCommandArgs;
5
- export type SizeSnapshot = import('./sizeDiff.js').SizeSnapshot;
package/build/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  import defineConfig from './defineConfig.js';
2
2
  import { loadConfig } from './configLoader.js';
3
- import { renderMarkdownReport } from './renderMarkdownReport.js';
4
- export { defineConfig, loadConfig, renderMarkdownReport };
3
+ export { defineConfig, loadConfig };
@@ -0,0 +1,14 @@
1
+ export type SyncPrCommentResult = {
2
+ success: boolean;
3
+ skipped?: boolean;
4
+ };
5
+ /**
6
+ * @typedef {{ success: boolean, skipped?: boolean }} SyncPrCommentResult
7
+ */
8
+ /**
9
+ * Syncs a PR comment via the dashboard API.
10
+ * @param {string} repo - Repository in owner/repo format
11
+ * @param {Record<string, object>} sections - Section-specific parameters
12
+ * @returns {Promise<SyncPrCommentResult>}
13
+ */
14
+ export declare function syncPrComment(repo: string, sections: Record<string, object>): Promise<SyncPrCommentResult>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/internal-bundle-size-checker",
3
- "version": "1.0.9-canary.71",
3
+ "version": "1.0.9-canary.72",
4
4
  "description": "Bundle size checker for MUI packages.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,10 +21,6 @@
21
21
  "default": "./src/index.js"
22
22
  },
23
23
  "./package.json": "./package.json",
24
- "./browser": {
25
- "types": "./build/browser.d.ts",
26
- "default": "./src/browser.js"
27
- },
28
24
  "./ciReport": {
29
25
  "types": "./build/ciReport.d.ts",
30
26
  "default": "./src/ciReport.js"
@@ -50,7 +46,7 @@
50
46
  "@types/micromatch": "4.0.10",
51
47
  "@types/yargs": "17.0.35"
52
48
  },
53
- "gitSha": "cddfbe44fdd8895ff4ffcd9eaaa75320b873a893",
49
+ "gitSha": "98e99bf28bdaf246aee9618320f28e440148e844",
54
50
  "scripts": {
55
51
  "build": "tsgo -p tsconfig.build.json",
56
52
  "test": "pnpm -w test --project @mui/internal-bundle-size-checker",
package/src/cli.js CHANGED
@@ -11,33 +11,14 @@ import { pathToFileURL } from 'node:url';
11
11
  import chalk from 'chalk';
12
12
  import { loadConfig } from './configLoader.js';
13
13
  import { uploadSnapshot } from './uploadSnapshot.js';
14
- import { renderMarkdownReport } from './renderMarkdownReport.js';
15
- import { octokit } from './github.js';
16
- import { getCurrentRepoInfo } from './git.js';
17
- import { notifyPr } from './notifyPr.js';
18
- import { DASHBOARD_ORIGIN } from './constants.js';
14
+ import { syncPrComment } from './syncPrComment.js';
19
15
 
20
16
  /**
21
17
  * @typedef {import('./types.js').CommandLineArgs} CommandLineArgs
22
18
  * @typedef {import('./types.js').NormalizedBundleSizeCheckerConfig} NormalizedBundleSizeCheckerConfig
23
19
  * @typedef {import('./types.js').SizeSnapshotEntry} SizeSnapshotEntry
24
- * @typedef {import('./types.js').ReportCommandArgs} ReportCommandArgs
25
20
  */
26
21
 
27
- /**
28
- * @param {string} repo
29
- * @param {number} prNumber
30
- * @param {string} bundleSizeInfo
31
- */
32
- function formatComment(repo, prNumber, bundleSizeInfo) {
33
- return [
34
- '## Bundle size report',
35
- bundleSizeInfo,
36
- '<hr>',
37
- `Check out the [code infra dashboard](${DASHBOARD_ORIGIN}/repository/${repo}/prs/${prNumber}) for more information about this PR.`,
38
- ].join('\n\n');
39
- }
40
-
41
22
  /**
42
23
  */
43
24
  function getCiInfo() {
@@ -53,10 +34,6 @@ function getCiInfo() {
53
34
  }
54
35
  }
55
36
 
56
- /**
57
- * @typedef {import('./sizeDiff.js').SizeSnapshot} SizeSnapshot
58
- */
59
-
60
37
  // Default concurrency is set to the number of available CPU cores
61
38
  const DEFAULT_CONCURRENCY = os.availableParallelism();
62
39
 
@@ -117,98 +94,44 @@ async function getBundleSizes(args, config) {
117
94
  }
118
95
 
119
96
  /**
120
- * Posts initial "in progress" PR comment with CircleCI build information
97
+ * Posts initial "in progress" PR comment via dashboard API.
98
+ * Called for all CI builds — the server resolves the associated PR from
99
+ * OIDC claims. If no PR exists yet (branch pushed before PR created),
100
+ * the server returns a no-op response.
101
+ * @param {NormalizedBundleSizeCheckerConfig} config - The loaded configuration
121
102
  * @returns {Promise<void>}
122
103
  */
123
- async function postInitialPrComment() {
124
- // /** @type {envCi.CircleCiEnv} */
104
+ async function postInitialPrComment(config) {
125
105
  const ciInfo = getCiInfo();
126
106
 
127
- if (!ciInfo || !ciInfo.isPr) {
107
+ if (!ciInfo) {
128
108
  return;
129
109
  }
130
110
 
131
- // In CI PR builds, all required info must be present
132
- if (!ciInfo.slug || !ciInfo.pr) {
133
- throw new Error('PR commenting enabled but repository information missing in CI PR build');
111
+ if (!ciInfo.slug) {
112
+ throw new Error('PR commenting enabled but repository information missing in CI build');
134
113
  }
135
114
 
136
- const prNumber = Number(ciInfo.pr);
137
- const circleBuildNum = process.env.CIRCLE_BUILD_NUM;
138
- const circleBuildUrl = process.env.CIRCLE_BUILD_URL;
139
-
140
- if (!circleBuildNum || !circleBuildUrl) {
141
- throw new Error(
142
- 'PR commenting enabled but CircleCI environment variables missing in CI PR build',
143
- );
115
+ if (!config.upload) {
116
+ throw new Error('PR commenting requires upload configuration to determine the API URL');
144
117
  }
145
118
 
146
119
  try {
147
120
  // eslint-disable-next-line no-console
148
- console.log('Posting initial PR comment...');
149
-
150
- const initialComment = formatComment(
151
- ciInfo.slug,
152
- prNumber,
153
- `Bundle size will be reported once [CircleCI build #${circleBuildNum}](${circleBuildUrl}) finishes.\n\nStatus: 🟠 Processing...`,
154
- );
121
+ console.log('Posting initial PR comment via dashboard API...');
155
122
 
156
- await notifyPr(ciInfo.slug, prNumber, 'bundle-size-report', initialComment);
123
+ const result = await syncPrComment(ciInfo.slug, { bundleSize: { status: 'pending' } });
157
124
 
158
125
  // eslint-disable-next-line no-console
159
- console.log(`Initial PR comment posted for PR #${prNumber}`);
126
+ console.log(
127
+ result.skipped ? 'No open PR found for this branch, skipping.' : 'Initial PR comment posted.',
128
+ );
160
129
  } catch (/** @type {any} */ error) {
161
130
  console.error('Failed to post initial PR comment:', error.message);
162
131
  // Don't fail the build for comment failures
163
132
  }
164
133
  }
165
134
 
166
- /**
167
- * Report command handler
168
- * @param {ReportCommandArgs} argv - Command line arguments
169
- */
170
- async function reportCommand(argv) {
171
- const { pr, owner: argOwner, repo: argRepo } = argv;
172
-
173
- // Get current repo info and coerce with provided arguments
174
- const currentRepo = await getCurrentRepoInfo();
175
- const owner = argOwner ?? currentRepo.owner;
176
- const repo = argRepo ?? currentRepo.name;
177
-
178
- if (typeof pr !== 'number') {
179
- throw new Error('Invalid pull request number. Please provide a valid --pr option.');
180
- }
181
-
182
- // Validate that both owner and repo are available
183
- if (!owner || !repo) {
184
- throw new Error(
185
- 'Repository owner and name are required. Please provide --owner and --repo options, or run this command from within a git repository.',
186
- );
187
- }
188
-
189
- // Fetch PR information
190
- const { data: prInfo } = await octokit.pulls.get({
191
- owner,
192
- repo,
193
- pull_number: pr,
194
- });
195
-
196
- const getMergeBaseFromGithubApi = async (
197
- /** @type {string} */ base,
198
- /** @type {string} */ head,
199
- ) => {
200
- const { data } = await octokit.repos.compareCommits({ owner, repo, base, head });
201
- return data.merge_base_commit.sha;
202
- };
203
-
204
- // Generate and print the markdown report
205
- const report = await renderMarkdownReport(prInfo, {
206
- getMergeBase: getMergeBaseFromGithubApi,
207
- });
208
- // eslint-disable-next-line no-console
209
- console.log(report);
210
- }
211
-
212
135
  /**
213
136
  * Main runner function
214
137
  * @param {CommandLineArgs} argv - Command line arguments
@@ -222,7 +145,7 @@ async function run(argv) {
222
145
 
223
146
  // Post initial PR comment if enabled and in CI environment
224
147
  if (config && config.comment) {
225
- await postInitialPrComment();
148
+ await postInitialPrComment(config);
226
149
  }
227
150
 
228
151
  // eslint-disable-next-line no-console
@@ -249,7 +172,7 @@ async function run(argv) {
249
172
  console.log(
250
173
  config.upload.legacyUpload
251
174
  ? 'Uploading bundle size snapshot directly to S3 (legacy)...'
252
- : `Uploading bundle size snapshot via dashboard API at ${config.upload.apiUrl}...`,
175
+ : 'Uploading bundle size snapshot via dashboard API...',
253
176
  );
254
177
  const { key } = await uploadSnapshot(snapshotDestPath, config.upload);
255
178
  // eslint-disable-next-line no-console
@@ -264,54 +187,45 @@ async function run(argv) {
264
187
  console.log('No upload configuration provided, skipping upload.');
265
188
  }
266
189
 
267
- // Post PR comment if enabled and in CI environment
190
+ // Post final PR comment via dashboard API if enabled and in CI environment.
191
+ // The server resolves the associated PR from OIDC claims — if no PR exists
192
+ // for this branch, the server returns a no-op response.
268
193
  if (config && config.comment) {
269
194
  const ciInfo = getCiInfo();
270
195
 
271
- // Skip silently if not in CI or not a PR
272
- if (!ciInfo || !ciInfo.isPr) {
196
+ if (!ciInfo) {
273
197
  // eslint-disable-next-line no-console
274
- console.log('Not in a CI PR environment, skipping PR comment.');
198
+ console.log('Not in a CI environment, skipping PR comment.');
275
199
  return;
276
200
  }
277
201
 
278
- // In CI PR builds, all required info must be present
279
- if (!ciInfo.slug || !ciInfo.pr) {
280
- throw new Error('PR commenting enabled but repository information missing in CI PR build');
202
+ if (!ciInfo.slug) {
203
+ throw new Error('PR commenting enabled but repository information missing in CI build');
281
204
  }
282
205
 
283
- const prNumber = Number(ciInfo.pr);
206
+ if (!config.upload) {
207
+ throw new Error('PR commenting requires upload configuration to determine the API URL');
208
+ }
284
209
 
285
210
  // eslint-disable-next-line no-console
286
- console.log('Generating PR comment with bundle size changes...');
211
+ console.log('Syncing PR comment via dashboard API...');
287
212
 
288
213
  // Get tracked bundles from config
289
214
  const trackedBundles = config.entrypoints
290
215
  .filter((entry) => entry.track === true)
291
216
  .map((entry) => entry.id);
292
217
 
293
- // Get PR info for renderMarkdownReport
294
- const { data: prInfo } = await octokit.pulls.get({
295
- owner: ciInfo.slug.split('/')[0],
296
- repo: ciInfo.slug.split('/')[1],
297
- pull_number: prNumber,
298
- });
299
-
300
- // Generate markdown report
301
- const report = await renderMarkdownReport(prInfo, {
302
- track: trackedBundles.length > 0 ? trackedBundles : undefined,
218
+ const result = await syncPrComment(ciInfo.slug, {
219
+ bundleSize: {
220
+ status: 'complete',
221
+ trackedBundles: trackedBundles.length > 0 ? trackedBundles : undefined,
222
+ },
303
223
  });
304
224
 
305
- // Post or update PR comment
306
- await notifyPr(
307
- ciInfo.slug,
308
- prNumber,
309
- 'bundle-size-report',
310
- formatComment(ciInfo.slug, prNumber, report),
311
- );
312
-
313
225
  // eslint-disable-next-line no-console
314
- console.log(`PR comment posted/updated for PR #${prNumber}`);
226
+ console.log(
227
+ result.skipped ? 'No open PR found for this branch, skipping.' : 'PR comment synced.',
228
+ );
315
229
  }
316
230
  }
317
231
 
@@ -359,29 +273,6 @@ yargs(process.argv.slice(2))
359
273
  handler: run,
360
274
  }),
361
275
  )
362
- .command(
363
- /** @type {import('yargs').CommandModule<{}, ReportCommandArgs>} */ ({
364
- command: 'report',
365
- describe: 'Generate a markdown report for a pull request',
366
- builder: (cmdYargs) => {
367
- return cmdYargs
368
- .option('pr', {
369
- describe: 'Pull request number',
370
- type: 'number',
371
- demandOption: true,
372
- })
373
- .option('owner', {
374
- describe: 'Repository owner (defaults to current git repo owner)',
375
- type: 'string',
376
- })
377
- .option('repo', {
378
- describe: 'Repository name (defaults to current git repo name)',
379
- type: 'string',
380
- });
381
- },
382
- handler: reportCommand,
383
- }),
384
- )
385
276
  .help()
386
277
  .strict(true)
387
278
  .version(false)
@@ -81,10 +81,6 @@ export function applyUploadConfigDefaults(uploadConfig, ciInfo) {
81
81
  }
82
82
 
83
83
  const legacyUpload = uploadConfig.legacyUpload ?? false;
84
- const apiUrl =
85
- uploadConfig.apiUrl ||
86
- process.env.CI_REPORT_API_URL ||
87
- 'https://code-infra-dashboard.onrender.com';
88
84
 
89
85
  // Return the normalized config
90
86
  /** @type {NormalizedUploadConfig} */
@@ -95,7 +91,6 @@ export function applyUploadConfigDefaults(uploadConfig, ciInfo) {
95
91
  uploadConfig.isPullRequest !== undefined
96
92
  ? Boolean(uploadConfig.isPullRequest)
97
93
  : Boolean(isPr),
98
- apiUrl,
99
94
  legacyUpload,
100
95
  };
101
96
 
package/src/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import defineConfig from './defineConfig.js';
2
2
  import { loadConfig } from './configLoader.js';
3
- import { renderMarkdownReport } from './renderMarkdownReport.js';
4
3
 
5
- export { defineConfig, loadConfig, renderMarkdownReport };
4
+ export { defineConfig, loadConfig };
@@ -0,0 +1,38 @@
1
+ // @ts-check
2
+
3
+ const DEFAULT_API_URL = 'https://code-infra-dashboard.onrender.com';
4
+
5
+ /**
6
+ * @typedef {{ success: boolean, skipped?: boolean }} SyncPrCommentResult
7
+ */
8
+
9
+ /**
10
+ * Syncs a PR comment via the dashboard API.
11
+ * @param {string} repo - Repository in owner/repo format
12
+ * @param {Record<string, object>} sections - Section-specific parameters
13
+ * @returns {Promise<SyncPrCommentResult>}
14
+ */
15
+ export async function syncPrComment(repo, sections) {
16
+ const oidcToken = process.env.CIRCLE_OIDC_TOKEN_V2;
17
+ if (!oidcToken) {
18
+ throw new Error('CIRCLE_OIDC_TOKEN_V2 environment variable is required for PR comment sync');
19
+ }
20
+
21
+ const apiUrl = process.env.CI_REPORT_API_URL || DEFAULT_API_URL;
22
+ const url = new URL('/api/ci-reports/sync-pr-comment', apiUrl);
23
+
24
+ const response = await fetch(url, {
25
+ method: 'POST',
26
+ headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${oidcToken}` },
27
+ body: JSON.stringify({ repo, sections }),
28
+ });
29
+
30
+ if (!response.ok) {
31
+ const responseText = await response.text();
32
+ throw new Error(
33
+ `Sync PR comment API returned ${response.status} ${response.statusText}: ${responseText}`,
34
+ );
35
+ }
36
+
37
+ return response.json();
38
+ }
package/src/types.d.ts CHANGED
@@ -3,7 +3,6 @@ export interface UploadConfig {
3
3
  repo?: string; // The repository name (e.g., "mui/material-ui")
4
4
  branch?: string; // Optional branch name (defaults to current Git branch)
5
5
  isPullRequest?: boolean; // Whether this is a pull request build (defaults to CI detection)
6
- apiUrl?: string; // Dashboard API URL (defaults to https://code-infra-dashboard.onrender.com)
7
6
  legacyUpload?: boolean; // Upload directly to S3 instead of using the dashboard API
8
7
  }
9
8
 
@@ -13,7 +12,6 @@ export interface NormalizedUploadConfig {
13
12
  branch: string; // Branch name
14
13
  isPullRequest: boolean; // Whether this is a pull request build
15
14
  prNumber?: string; // PR number (from CI environment)
16
- apiUrl: string; // Dashboard API URL
17
15
  legacyUpload: boolean; // Whether to use direct S3 upload
18
16
  }
19
17
 
@@ -63,12 +61,6 @@ export interface CommandLineArgs {
63
61
  debug?: boolean;
64
62
  }
65
63
 
66
- export interface ReportCommandArgs {
67
- pr?: number;
68
- owner?: string;
69
- repo?: string;
70
- }
71
-
72
64
  // Diff command argument types
73
65
  export interface DiffCommandArgs {
74
66
  base: string;
@@ -83,21 +75,6 @@ export interface PrCommandArgs {
83
75
  output?: 'json' | 'markdown';
84
76
  }
85
77
 
86
- export interface PrInfo {
87
- number: number;
88
- base: {
89
- ref: string;
90
- sha: string;
91
- repo: {
92
- full_name: string;
93
- };
94
- };
95
- head: {
96
- ref: string;
97
- sha: string;
98
- };
99
- }
100
-
101
78
  export interface SizeSnapshotEntry {
102
79
  parsed: number;
103
80
  gzip: number;
@@ -32,15 +32,13 @@ function sanitizeS3TagString(str) {
32
32
 
33
33
  /**
34
34
  * Uploads the snapshot via the dashboard API (server-side proxied to S3).
35
- * @param {string} apiUrl - Base URL of the CI report API
36
35
  * @param {Buffer} fileContent - The file content to upload
37
36
  * @param {NormalizedUploadConfig} uploadConfig - The normalized upload configuration
38
37
  * @param {string} sha - The commit SHA
39
38
  * @returns {Promise<{key:string}>}
40
39
  */
41
- async function uploadViaApi(apiUrl, fileContent, uploadConfig, sha) {
42
- const { branch, prNumber } = uploadConfig;
43
-
40
+ async function uploadViaApi(fileContent, uploadConfig, sha) {
41
+ const apiUrl = process.env.CI_REPORT_API_URL || 'https://code-infra-dashboard.onrender.com';
44
42
  /** @type {import('./ciReport.js').SizeSnapshotUpload} */
45
43
  const requestBody = {
46
44
  version: 1,
@@ -48,8 +46,7 @@ async function uploadViaApi(apiUrl, fileContent, uploadConfig, sha) {
48
46
  commitSha: sha,
49
47
  repo: uploadConfig.repo,
50
48
  reportType: 'size-snapshot',
51
- branch,
52
- prNumber: prNumber ? Number(prNumber) : undefined,
49
+ branch: uploadConfig.branch,
53
50
  report: JSON.parse(fileContent.toString('utf-8')),
54
51
  };
55
52
 
@@ -146,5 +143,5 @@ export async function uploadSnapshot(snapshotPath, uploadConfig, commitSha) {
146
143
  return uploadDirectToS3(fileContent, uploadConfig, sha);
147
144
  }
148
145
 
149
- return uploadViaApi(uploadConfig.apiUrl, fileContent, uploadConfig, sha);
146
+ return uploadViaApi(fileContent, uploadConfig, sha);
150
147
  }
@@ -1,12 +0,0 @@
1
- export { calculateSizeDiff } from './sizeDiff.js';
2
- export { fetchSnapshot } from './fetchSnapshot.js';
3
- export type Size = import('./types.js').Size;
4
- export type SizeSnapshot = import('./types.js').SizeSnapshot;
5
- export type ComparisonResult = import('./types.js').ComparisonResult;
6
- export type SizeSnapshotEntry = import('./types.js').SizeSnapshotEntry;
7
- /**
8
- * @typedef {import('./types.js').Size} Size
9
- * @typedef {import('./types.js').SizeSnapshot} SizeSnapshot
10
- * @typedef {import('./types.js').ComparisonResult} ComparisonResult
11
- * @typedef {import('./types.js').SizeSnapshotEntry} SizeSnapshotEntry
12
- */
@@ -1 +0,0 @@
1
- export declare const DASHBOARD_ORIGIN = "https://frontend-public.mui.com";
@@ -1,7 +0,0 @@
1
- /**
2
- *
3
- * @param {string} repo - The name of the repository e.g. 'mui/material-ui'
4
- * @param {string} sha - The commit SHA
5
- * @returns {Promise<import('./sizeDiff.js').SizeSnapshot>} - The size snapshot data
6
- */
7
- export declare function fetchSnapshot(repo: string, sha: string): Promise<import('./sizeDiff.js').SizeSnapshot>;
@@ -1,11 +0,0 @@
1
- /**
2
- * Attempts to fetch a snapshot with fallback to parent commits
3
- * @param {string} repo - Repository name
4
- * @param {string} commit - The commit SHA to start from
5
- * @param {number} [fallbackDepth=3] - How many parent commits to try as fallback
6
- * @returns {Promise<{snapshot: import('./sizeDiff.js').SizeSnapshot | null, actualCommit: string | null}>}
7
- */
8
- export declare function fetchSnapshotWithFallback(repo: string, commit: string, fallbackDepth?: number): Promise<{
9
- snapshot: import('./sizeDiff.js').SizeSnapshot | null;
10
- actualCommit: string | null;
11
- }>;
@@ -1,43 +0,0 @@
1
- /**
2
- * @typedef {import('./types.js').Size} Size
3
- * @typedef {import('./types.js').SizeSnapshot} SizeSnapshot
4
- * @typedef {import('./types.js').ComparisonResult} ComparisonResult
5
- * @typedef {import('./types.js').PrInfo} PrInfo
6
- */
7
- export type Size = import('./types.js').Size;
8
- export type SizeSnapshot = import('./types.js').SizeSnapshot;
9
- export type ComparisonResult = import('./types.js').ComparisonResult;
10
- export type PrInfo = import('./types.js').PrInfo;
11
- export type ColumnDefinition = {
12
- field: string;
13
- header?: string;
14
- align?: 'left' | 'center' | 'right';
15
- };
16
- /**
17
- * Generates a Markdown report for bundle size changes
18
- * @param {ComparisonResult} comparison - Comparison result from calculateSizeDiff
19
- * @param {Object} [options] - Additional options
20
- * @param {string[]} [options.track] - Array of bundle IDs to track. If specified, totals will only include tracked bundles and all tracked bundles will be shown prominently
21
- * @param {number} [options.maxDetailsLines=100] - Maximum number of bundles to show in details section
22
- * @returns {string} Markdown report
23
- */
24
- export declare function renderMarkdownReportContent(comparison: ComparisonResult, { track, maxDetailsLines }?: {
25
- track?: string[];
26
- maxDetailsLines?: number;
27
- }): string;
28
- /**
29
- *
30
- * @param {PrInfo} prInfo
31
- * @param {Object} [options] - Additional options
32
- * @param {string[]} [options.track] - Array of bundle IDs to track
33
- * @param {number} [options.fallbackDepth=3] - How many parent commits to try as fallback when base snapshot is missing
34
- * @param {number} [options.maxDetailsLines=100] - Maximum number of bundles to show in details section
35
- * @param {(base: string, head: string) => Promise<string>} [options.getMergeBase] - Custom function to get merge base commit
36
- * @returns {Promise<string>} Markdown report
37
- */
38
- export declare function renderMarkdownReport(prInfo: PrInfo, options?: {
39
- track?: string[];
40
- fallbackDepth?: number;
41
- maxDetailsLines?: number;
42
- getMergeBase?: (base: string, head: string) => Promise<string>;
43
- }): Promise<string>;
@@ -1,18 +0,0 @@
1
- /**
2
- * @typedef {import('./types.js').SizeSnapshotEntry} SizeSnapshotEntry
3
- * @typedef {import('./types.js').Size} Size
4
- * @typedef {import('./types.js').SizeSnapshot} SizeSnapshot
5
- * @typedef {import('./types.js').ComparisonResult} ComparisonResult
6
- */
7
- export type SizeSnapshotEntry = import('./types.js').SizeSnapshotEntry;
8
- export type Size = import('./types.js').Size;
9
- export type SizeSnapshot = import('./types.js').SizeSnapshot;
10
- export type ComparisonResult = import('./types.js').ComparisonResult;
11
- /**
12
- * Calculates size difference between two snapshots
13
- *
14
- * @param {SizeSnapshot} baseSnapshot - Base snapshot (previous)
15
- * @param {SizeSnapshot} targetSnapshot - Target snapshot (current)
16
- * @returns {ComparisonResult} Comparison result with entries, totals, and file counts
17
- */
18
- export declare function calculateSizeDiff(baseSnapshot: SizeSnapshot, targetSnapshot: SizeSnapshot): ComparisonResult;
package/src/browser.js DELETED
@@ -1,10 +0,0 @@
1
- export { calculateSizeDiff } from './sizeDiff.js';
2
- export { fetchSnapshot } from './fetchSnapshot.js';
3
-
4
- // Re-export types for consumers
5
- /**
6
- * @typedef {import('./types.js').Size} Size
7
- * @typedef {import('./types.js').SizeSnapshot} SizeSnapshot
8
- * @typedef {import('./types.js').ComparisonResult} ComparisonResult
9
- * @typedef {import('./types.js').SizeSnapshotEntry} SizeSnapshotEntry
10
- */
package/src/constants.js DELETED
@@ -1 +0,0 @@
1
- export const DASHBOARD_ORIGIN = 'https://frontend-public.mui.com';
@@ -1,38 +0,0 @@
1
- // This file must be importable in the browser
2
-
3
- /**
4
- *
5
- * @param {string} repo - The name of the repository e.g. 'mui/material-ui'
6
- * @param {string} sha - The commit SHA
7
- * @returns {Promise<import('./sizeDiff.js').SizeSnapshot>} - The size snapshot data
8
- */
9
- export async function fetchSnapshot(repo, sha) {
10
- const urlsToTry = [
11
- `https://s3.eu-central-1.amazonaws.com/mui-org-ci/artifacts/${repo}/${sha}/size-snapshot.json`,
12
- ];
13
-
14
- if (repo === 'mui/material-ui') {
15
- urlsToTry.push(
16
- `https://s3.eu-central-1.amazonaws.com/mui-org-ci/artifacts/master/${sha}/size-snapshot.json`,
17
- );
18
- }
19
-
20
- let lastError;
21
- for (const url of urlsToTry) {
22
- try {
23
- // eslint-disable-next-line no-await-in-loop
24
- const response = await fetch(url);
25
- if (!response.ok) {
26
- lastError = new Error(`Failed to fetch "${url}", HTTP ${response.status}`);
27
- continue;
28
- }
29
-
30
- return /** @type {Promise<any>} */ (response.json());
31
- } catch (error) {
32
- lastError = error;
33
- continue;
34
- }
35
- }
36
-
37
- throw new Error(`Failed to fetch snapshot`, { cause: lastError });
38
- }