@electron-stagewright/plugin-budget 0.0.0-stage → 0.2.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 (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +214 -2
  3. package/dist/budget.d.ts +143 -0
  4. package/dist/budget.d.ts.map +1 -0
  5. package/dist/budget.js +134 -0
  6. package/dist/budget.js.map +1 -0
  7. package/dist/bundle.d.ts +15 -0
  8. package/dist/bundle.d.ts.map +1 -0
  9. package/dist/bundle.js +64 -0
  10. package/dist/bundle.js.map +1 -0
  11. package/dist/check-api.d.ts +15 -0
  12. package/dist/check-api.d.ts.map +1 -0
  13. package/dist/check-api.js +11 -0
  14. package/dist/check-api.js.map +1 -0
  15. package/dist/check.d.ts +50 -0
  16. package/dist/check.d.ts.map +1 -0
  17. package/dist/check.js +198 -0
  18. package/dist/check.js.map +1 -0
  19. package/dist/cli.d.ts +85 -0
  20. package/dist/cli.d.ts.map +1 -0
  21. package/dist/cli.js +464 -0
  22. package/dist/cli.js.map +1 -0
  23. package/dist/index.d.ts +24 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +17 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/measure.d.ts +81 -0
  28. package/dist/measure.d.ts.map +1 -0
  29. package/dist/measure.js +269 -0
  30. package/dist/measure.js.map +1 -0
  31. package/dist/memory.d.ts +43 -0
  32. package/dist/memory.d.ts.map +1 -0
  33. package/dist/memory.js +159 -0
  34. package/dist/memory.js.map +1 -0
  35. package/dist/plugin.d.ts +13 -0
  36. package/dist/plugin.d.ts.map +1 -0
  37. package/dist/plugin.js +456 -0
  38. package/dist/plugin.js.map +1 -0
  39. package/dist/probe.d.ts +74 -0
  40. package/dist/probe.d.ts.map +1 -0
  41. package/dist/probe.js +181 -0
  42. package/dist/probe.js.map +1 -0
  43. package/dist/render.d.ts +21 -0
  44. package/dist/render.d.ts.map +1 -0
  45. package/dist/render.js +63 -0
  46. package/dist/render.js.map +1 -0
  47. package/dist/run.d.ts +267 -0
  48. package/dist/run.d.ts.map +1 -0
  49. package/dist/run.js +257 -0
  50. package/dist/run.js.map +1 -0
  51. package/dist/session.d.ts +79 -0
  52. package/dist/session.d.ts.map +1 -0
  53. package/dist/session.js +263 -0
  54. package/dist/session.js.map +1 -0
  55. package/package.json +67 -3
package/dist/plugin.js ADDED
@@ -0,0 +1,456 @@
1
+ /**
2
+ * The MCP face of the budget: `budget_start`, `budget_measure`, `budget_check`.
3
+ *
4
+ * Runtime metrics run fixed bodies in the app's main process, so they need the main eval grant;
5
+ * the IPC probe and startup timing also need the renderer. Bundle size needs neither, nor a session.
6
+ *
7
+ * @module
8
+ */
9
+ import { realpath } from 'node:fs/promises';
10
+ import path from 'node:path';
11
+ import { defineTool, fnv1a32, makeError, makePluginError, makeSuccess, readPackageVersion, } from '@electron-stagewright/core';
12
+ import { createPluginConfigState, createSessionCleanup, sessionIdField, } from '@electron-stagewright/core/plugin-sdk';
13
+ import { z } from 'zod';
14
+ import { BudgetFileError, loadBudget } from './budget.js';
15
+ import { measureBundle } from './bundle.js';
16
+ import { checkRun } from './check.js';
17
+ import { DEFAULT_WINDOW_MS } from './probe.js';
18
+ import { createRun, summarizeRun } from './run.js';
19
+ import { MAIN_EVAL_OFF, RENDERER_EVAL_OFF, measureSession, startWindow, } from './session.js';
20
+ const BUDGET_NAMESPACE = 'budget';
21
+ const BUDGET_PLUGIN_VERSION = readPackageVersion(import.meta.url);
22
+ const BUDGET_INTROSPECTION = {
23
+ requirements: {
24
+ evalTargets: ['main', 'renderer'],
25
+ transportCapabilities: ['supportsMainEval', 'supportsRendererEval'],
26
+ },
27
+ config: { safeFields: ['budgetFile', 'root', 'windowMs'] },
28
+ };
29
+ const windowMsSchema = z.number().int().min(250).max(120_000);
30
+ const configSchema = z.object({
31
+ budgetFile: z
32
+ .string()
33
+ .optional()
34
+ .describe('Absolute path of the budget file budget_check reads when budgetPath is omitted.'),
35
+ root: z
36
+ .string()
37
+ .optional()
38
+ .describe('Directory bundle entries resolve from. Defaults to the budget file directory.'),
39
+ windowMs: windowMsSchema
40
+ .default(DEFAULT_WINDOW_MS)
41
+ .describe('Length (ms) of the measurement window when budget_start did not open one.'),
42
+ });
43
+ const DEFAULT_CONFIG = { windowMs: DEFAULT_WINDOW_MS };
44
+ const budgetPathField = {
45
+ budgetPath: z
46
+ .string()
47
+ .min(1)
48
+ .optional()
49
+ .describe('Absolute path of the budget JSON file. Defaults to the configured budgetFile.'),
50
+ };
51
+ export function createBudgetPlugin() {
52
+ const config = createPluginConfigState(DEFAULT_CONFIG);
53
+ const windows = new Map();
54
+ // The in-app sampler is one per process, so one session runs one budget call at a time.
55
+ const queues = new Map();
56
+ function serial(sessionId, work) {
57
+ const next = (queues.get(sessionId) ?? Promise.resolve()).catch(() => undefined).then(work);
58
+ queues.set(sessionId, next);
59
+ void next
60
+ .finally(() => {
61
+ if (queues.get(sessionId) === next)
62
+ queues.delete(sessionId);
63
+ })
64
+ .catch(() => undefined);
65
+ return next;
66
+ }
67
+ const sessionCleanup = createSessionCleanup((sessionId) => windows.delete(sessionId), () => {
68
+ windows.clear();
69
+ config.reset();
70
+ });
71
+ /** Symlinks are resolved first, so a link inside the root cannot point the read outside it. */
72
+ async function escapes(root, target, meta) {
73
+ // A missing file keeps its nearest existing ancestor's canonical prefix, so it compares like
74
+ // its root does (macOS /var vs /private/var) instead of reading as outside it.
75
+ const canonical = async (file) => {
76
+ const resolved = path.resolve(file);
77
+ try {
78
+ return await realpath(resolved);
79
+ }
80
+ catch {
81
+ const parent = path.dirname(resolved);
82
+ return parent === resolved
83
+ ? resolved
84
+ : path.join(await canonical(parent), path.basename(resolved));
85
+ }
86
+ };
87
+ const relative = path.relative(await canonical(root), await canonical(target));
88
+ if (relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative))) {
89
+ return undefined;
90
+ }
91
+ return makeError('BAD_ARGUMENT', {
92
+ ...meta,
93
+ message: `Path must resolve within ${root}; "${target}" is outside it.`,
94
+ details: { root, path: target },
95
+ });
96
+ }
97
+ /** With `--app-root` set, files the tools read must sit inside it. */
98
+ async function outsideAppRoot(ctx, target, meta) {
99
+ return ctx.appRoot === undefined ? undefined : escapes(ctx.appRoot, target, meta);
100
+ }
101
+ /** The IPC probe is caller-supplied renderer code: leave the same audit trail as an eval tool. */
102
+ function auditProbe(ctx, tool, target, ipc) {
103
+ if (ipc === undefined || !target.renderer.allowRenderer)
104
+ return;
105
+ ctx.logger.info('eval invoked', {
106
+ tool,
107
+ target: 'renderer',
108
+ session_id: target.id,
109
+ code_length: ipc.probe.length,
110
+ code_hash: fnv1a32(ipc.probe),
111
+ });
112
+ }
113
+ /** Load the named or configured budget, or return the error envelope. */
114
+ async function resolveBudget(ctx, budgetPath, meta, required) {
115
+ const target = budgetPath ?? config.current.budgetFile;
116
+ if (target === undefined) {
117
+ if (!required)
118
+ return {};
119
+ return {
120
+ error: makePluginError('budget.NO_BUDGET', {
121
+ ...meta,
122
+ message: 'No budget file: pass budgetPath or configure pluginConfigs.budget.budgetFile.',
123
+ }),
124
+ };
125
+ }
126
+ if (!path.isAbsolute(target)) {
127
+ return {
128
+ error: makeError('ABSOLUTE_PATH_REQUIRED', {
129
+ ...meta,
130
+ message: `budgetPath must be absolute, got ${target}`,
131
+ details: { budget_path: target },
132
+ }),
133
+ };
134
+ }
135
+ const outside = await outsideAppRoot(ctx, target, meta);
136
+ if (outside !== undefined)
137
+ return { error: outside };
138
+ try {
139
+ return { budget: await loadBudget(target), budgetPath: target };
140
+ }
141
+ catch (error) {
142
+ if (!(error instanceof BudgetFileError))
143
+ throw error;
144
+ return {
145
+ error: makePluginError(`budget.${error.code}`, {
146
+ ...meta,
147
+ message: error.message,
148
+ details: { budget_path: target },
149
+ }),
150
+ };
151
+ }
152
+ }
153
+ /** The session to measure, or the reason runtime metrics are unavailable. */
154
+ function runtimeSession(ctx, sessionId) {
155
+ if (!ctx.allowEval)
156
+ return { unavailable: MAIN_EVAL_OFF, code: 'budget.EVAL_REQUIRED' };
157
+ const managed = ctx.sessions.resolve(sessionId);
158
+ const capabilities = managed.transport.capabilities;
159
+ if (!capabilities.supportsMainEval) {
160
+ return {
161
+ unavailable: 'this session’s transport cannot evaluate in the main process',
162
+ code: 'budget.MAIN_EVAL_UNSUPPORTED',
163
+ };
164
+ }
165
+ const rendererOff = !ctx.allowEvalRenderer
166
+ ? RENDERER_EVAL_OFF
167
+ : capabilities.supportsRendererEval
168
+ ? undefined
169
+ : 'this session’s transport cannot evaluate in the renderer';
170
+ return {
171
+ session: managed.session,
172
+ id: managed.id,
173
+ renderer: {
174
+ allowRenderer: rendererOff === undefined,
175
+ allowStartup: ctx.allowEvalRenderer,
176
+ ...(rendererOff === undefined ? {} : { rendererOff }),
177
+ },
178
+ };
179
+ }
180
+ function ipcProbe(args, budget) {
181
+ const probe = args.ipcProbe ?? budget?.ipc?.probe;
182
+ const intervalMs = args.ipcIntervalMs ?? budget?.ipc?.intervalMs;
183
+ if (probe === undefined)
184
+ return undefined;
185
+ return { probe, ...(intervalMs === undefined ? {} : { intervalMs }) };
186
+ }
187
+ async function measureLive(ctx, tool, target, options) {
188
+ return serial(target.id, () => {
189
+ // A call that timed out or was cancelled while queued must not run later.
190
+ ctx.signal?.throwIfAborted();
191
+ return measureLiveNow(ctx, tool, target, options);
192
+ });
193
+ }
194
+ async function measureLiveNow(ctx, tool, target, options) {
195
+ const open = windows.get(target.id);
196
+ windows.delete(target.id);
197
+ if (open === undefined)
198
+ auditProbe(ctx, tool, target, options.ipc);
199
+ const measured = await measureSession(target.session, {
200
+ ...target.renderer,
201
+ windowMs: options.windowMs ?? options.budget?.mainThread?.windowMs ?? config.current.windowMs,
202
+ ...(open === undefined ? {} : { open }),
203
+ ...(options.ipc === undefined ? {} : { ipc: options.ipc }),
204
+ });
205
+ const run = createRun({
206
+ rounds: [{ round: 1, phase: 'live', measurement: measured.measurement }],
207
+ ...(measured.electronVersion === undefined
208
+ ? {}
209
+ : { electronVersion: measured.electronVersion }),
210
+ });
211
+ // The app may run on another OS than this server only in theory; trust what it reports.
212
+ return { run: { ...run, platform: measured.platform }, measurement: measured.measurement };
213
+ }
214
+ const runtimeError = (meta, target) => makePluginError(target.code, { ...meta, message: target.unavailable });
215
+ const startTool = defineTool({
216
+ name: 'start',
217
+ title: 'Open a performance measurement window',
218
+ description: [
219
+ 'Start sampling main-thread blocking (and IPC round trips, when a probe is known) on the',
220
+ 'running app, then drive the app with other tools and call budget_measure or budget_check to',
221
+ 'close the window and read it. Without budget_start those tools measure an idle window.',
222
+ 'The IPC probe is the renderer expression in ipcProbe, else the budget file ipc.probe; it',
223
+ 'needs renderer eval. Starting again replaces the open window; an unread window expires after',
224
+ '10 minutes. Budget calls on one session run one at a time.',
225
+ 'Returns: { ok, started, ipc_probe, ipc_unavailable? }. Errors: budget.EVAL_REQUIRED (main',
226
+ 'eval is off), budget.MAIN_EVAL_UNSUPPORTED (transport lacks it), NOT_RUNNING (no session), budget.BUDGET_NOT_FOUND,',
227
+ 'budget.BUDGET_INVALID, ABSOLUTE_PATH_REQUIRED.',
228
+ ].join(' '),
229
+ inputSchema: z.object({
230
+ ...sessionIdField,
231
+ ...budgetPathField,
232
+ ipcProbe: z
233
+ .string()
234
+ .min(1)
235
+ .optional()
236
+ .describe('Renderer expression doing one IPC round trip, e.g. window.api.getVersion().'),
237
+ ipcIntervalMs: z.number().int().min(1).max(1000).optional().describe('Probe spacing in ms.'),
238
+ }),
239
+ operationType: 'command',
240
+ requiresEvalFlag: true,
241
+ evalTarget: 'main',
242
+ handler: async (args, ctx) => {
243
+ const meta = { startedAt: ctx.startedAt, now: ctx.now };
244
+ const target = runtimeSession(ctx, args.sessionId);
245
+ if ('unavailable' in target)
246
+ return runtimeError(meta, target);
247
+ const loaded = await resolveBudget(ctx, args.budgetPath, meta, false);
248
+ if ('error' in loaded)
249
+ return loaded.error;
250
+ const ipc = ipcProbe(args, loaded.budget);
251
+ const open = await serial(target.id, async () => {
252
+ ctx.signal?.throwIfAborted();
253
+ auditProbe(ctx, 'budget_start', target, ipc);
254
+ const started = await startWindow(target.session, {
255
+ ...target.renderer,
256
+ ...(ipc === undefined ? {} : { ipc }),
257
+ });
258
+ if (ctx.sessions.has(target.id))
259
+ windows.set(target.id, started);
260
+ return started;
261
+ });
262
+ return makeSuccess({
263
+ started: true,
264
+ ipc_probe: open.ipc,
265
+ ...(open.ipcUnavailable === undefined ? {} : { ipc_unavailable: open.ipcUnavailable }),
266
+ }, meta);
267
+ },
268
+ });
269
+ const measureTool = defineTool({
270
+ name: 'measure',
271
+ title: 'Measure the running app',
272
+ description: [
273
+ 'Measure the running app without judging it: startup to first window, memory summed per',
274
+ 'process type in the platform metric (footprint on macOS, pss on Linux, privateBytes on',
275
+ 'Windows) plus workingSet, main-thread blocking, and IPC latency when a probe is known.',
276
+ 'Closes the window budget_start opened, or measures an idle window of windowMs.',
277
+ 'Returns: { ok, electron_version?, platform, measured: [{ id, value, unit, metric? }],',
278
+ 'unavailable?: { <metric>: reason } }. Errors: budget.EVAL_REQUIRED,',
279
+ 'budget.MAIN_EVAL_UNSUPPORTED, NOT_RUNNING,',
280
+ 'budget.BUDGET_NOT_FOUND, budget.BUDGET_INVALID, ABSOLUTE_PATH_REQUIRED.',
281
+ ].join(' '),
282
+ inputSchema: z.object({
283
+ ...sessionIdField,
284
+ ...budgetPathField,
285
+ windowMs: windowMsSchema.optional().describe('Idle window length in ms (default 2000).'),
286
+ ipcProbe: z
287
+ .string()
288
+ .min(1)
289
+ .optional()
290
+ .describe('Renderer expression for the IPC probe. Ignored when budget_start opened the window.'),
291
+ }),
292
+ operationType: 'query',
293
+ requiresEvalFlag: true,
294
+ evalTarget: 'main',
295
+ handler: async (args, ctx) => {
296
+ const meta = { startedAt: ctx.startedAt, now: ctx.now };
297
+ const target = runtimeSession(ctx, args.sessionId);
298
+ if ('unavailable' in target)
299
+ return runtimeError(meta, target);
300
+ const loaded = await resolveBudget(ctx, args.budgetPath, meta, false);
301
+ if ('error' in loaded)
302
+ return loaded.error;
303
+ const { run, measurement } = await measureLive(ctx, 'budget_measure', target, {
304
+ windowMs: args.windowMs,
305
+ ipc: ipcProbe(args, loaded.budget),
306
+ ...(loaded.budget === undefined ? {} : { budget: loaded.budget }),
307
+ });
308
+ return makeSuccess({
309
+ ...(run.electron_version === undefined ? {} : { electron_version: run.electron_version }),
310
+ platform: run.platform,
311
+ measured: summarizeRun(run).map(({ id, value, unit, metric }) => ({
312
+ id,
313
+ value,
314
+ unit,
315
+ ...(metric === undefined ? {} : { metric }),
316
+ })),
317
+ ...(measurement.unavailable === undefined
318
+ ? {}
319
+ : { unavailable: measurement.unavailable }),
320
+ }, meta);
321
+ },
322
+ });
323
+ const checkTool = defineTool({
324
+ name: 'check',
325
+ title: 'Check the app against its performance budget',
326
+ description: [
327
+ 'Answer "did my change break a performance budget?": measure the running app and the bundle',
328
+ 'entries, then compare them to the budget file. passed is false when any limit is exceeded',
329
+ 'and when nothing could be measured. Each result is pass, fail, or unmeasured (with the',
330
+ 'reason); requireMeasurement turns unmeasured into a failure, strict removes the tolerance.',
331
+ 'Runtime metrics need a session and main eval; without them only bundle size is checked.',
332
+ 'Returns: { ok, passed, reason?, budget_path, summary: { pass, fail, unmeasured },',
333
+ 'results: [{ id, status, actual?, limit, allowed, unit, metric?, detail? }] }.',
334
+ 'Errors: budget.NO_BUDGET, budget.BUDGET_NOT_FOUND, budget.BUDGET_INVALID,',
335
+ 'ABSOLUTE_PATH_REQUIRED, NOT_RUNNING (unknown sessionId), BAD_ARGUMENT (several sessions',
336
+ 'and no sessionId, or a path outside --app-root).',
337
+ ].join(' '),
338
+ inputSchema: z.object({
339
+ ...sessionIdField,
340
+ ...budgetPathField,
341
+ windowMs: windowMsSchema.optional().describe('Idle window length in ms.'),
342
+ strict: z.boolean().optional().describe('Ignore thresholdPercent.'),
343
+ requireMeasurement: z.boolean().optional().describe('Fail budgeted metrics left unmeasured.'),
344
+ }),
345
+ operationType: 'query',
346
+ handler: async (args, ctx) => {
347
+ const meta = { startedAt: ctx.startedAt, now: ctx.now };
348
+ const loaded = await resolveBudget(ctx, args.budgetPath, meta, true);
349
+ if ('error' in loaded)
350
+ return loaded.error;
351
+ const budget = loaded.budget;
352
+ const budgetPath = loaded.budgetPath;
353
+ const root = config.current.root ?? path.dirname(budgetPath);
354
+ // Before measuring, so a refused entry neither waits out a window nor consumes budget_start's.
355
+ for (const entry of budget.bundle?.entries ?? []) {
356
+ // An agent can name the budget file, so its entries may not climb out of the root.
357
+ const entryPath = path.resolve(root, entry.path);
358
+ const outside = (await escapes(root, entryPath, meta)) ?? (await outsideAppRoot(ctx, entryPath, meta));
359
+ if (outside)
360
+ return outside;
361
+ }
362
+ const noSession = args.sessionId === undefined && ctx.sessions.size === 0;
363
+ const target = noSession
364
+ ? { unavailable: 'no app session is running; launch or attach first' }
365
+ : runtimeSession(ctx, args.sessionId);
366
+ let run;
367
+ if ('unavailable' in target) {
368
+ const reason = target.unavailable;
369
+ const unavailable = { startup: reason, memory: reason, mainThread: reason, ipc: reason };
370
+ run = createRun({ rounds: [{ round: 1, phase: 'live', measurement: { unavailable } }] });
371
+ }
372
+ else {
373
+ run = (await measureLive(ctx, 'budget_check', target, {
374
+ windowMs: args.windowMs,
375
+ ipc: ipcProbe({}, budget),
376
+ budget,
377
+ })).run;
378
+ }
379
+ if (budget.bundle !== undefined) {
380
+ run = { ...run, bundle: await measureBundle(root, budget.bundle.entries) };
381
+ }
382
+ const report = checkRun(run, budget, {
383
+ phase: 'live',
384
+ ignoreThreshold: args.strict === true,
385
+ requireMeasurement: args.requireMeasurement === true,
386
+ });
387
+ return makeSuccess({
388
+ passed: report.passed,
389
+ ...(report.reason === undefined ? {} : { reason: report.reason }),
390
+ budget_path: budgetPath,
391
+ summary: report.summary,
392
+ results: report.results.map(({ phase: _phase, ...result }) => result),
393
+ }, meta);
394
+ },
395
+ });
396
+ return {
397
+ name: BUDGET_NAMESPACE,
398
+ version: BUDGET_PLUGIN_VERSION,
399
+ coreVersionRange: '*',
400
+ configSchema,
401
+ introspection: BUDGET_INTROSPECTION,
402
+ errorCodes: {
403
+ EVAL_REQUIRED: {
404
+ http: 403,
405
+ retryable: false,
406
+ hint: 'Runtime budget metrics run in the main process; start the server with --allow-eval=main (or bare --allow-eval to include the IPC probe and startup timing).',
407
+ },
408
+ MAIN_EVAL_UNSUPPORTED: {
409
+ http: 409,
410
+ retryable: false,
411
+ hint: 'This transport has no main-process eval (CDP attach, or a packaged launch); launch with a main entry or inject to measure runtime metrics.',
412
+ },
413
+ NO_BUDGET: {
414
+ http: 400,
415
+ retryable: false,
416
+ hint: 'Pass budgetPath, or set pluginConfigs.budget.budgetFile to the absolute path of the budget JSON.',
417
+ },
418
+ BUDGET_NOT_FOUND: {
419
+ http: 404,
420
+ retryable: false,
421
+ hint: 'No readable file at budgetPath; pass the absolute path of the budget JSON.',
422
+ },
423
+ BUDGET_INVALID: {
424
+ http: 400,
425
+ retryable: false,
426
+ hint: 'The budget file is not valid JSON or has an unknown or mistyped key; the message names it.',
427
+ },
428
+ },
429
+ tools: [startTool, measureTool, checkTool],
430
+ setup: (raw, context) => {
431
+ config.set(raw);
432
+ sessionCleanup.setup(context);
433
+ },
434
+ teardown: async () => {
435
+ sessionCleanup.teardown();
436
+ },
437
+ };
438
+ }
439
+ /** Load with `--plugin budget` or `createServer({ plugins: [budgetPlugin] })`. */
440
+ export const budgetPlugin = {
441
+ name: BUDGET_NAMESPACE,
442
+ version: BUDGET_PLUGIN_VERSION,
443
+ coreVersionRange: '*',
444
+ get tools() {
445
+ return createBudgetPlugin().tools ?? [];
446
+ },
447
+ get errorCodes() {
448
+ return createBudgetPlugin().errorCodes ?? {};
449
+ },
450
+ get configSchema() {
451
+ return configSchema;
452
+ },
453
+ introspection: BUDGET_INTROSPECTION,
454
+ createInstance: createBudgetPlugin,
455
+ };
456
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../src/plugin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;aACnJ;YACD,SAAS,EAAE;gBACT,IAAI,EAAE,GAAG;gBACT,SAAS,EAAE,KAAK;gBAChB,IAAI,EAAE,kGAAkG;aACzG;YACD,gBAAgB,EAAE;gBAChB,IAAI,EAAE,GAAG;gBACT,SAAS,EAAE,KAAK;gBAChB,IAAI,EAAE,4EAA4E;aACnF;YACD,cAAc,EAAE;gBACd,IAAI,EAAE,GAAG;gBACT,SAAS,EAAE,KAAK;gBAChB,IAAI,EAAE,4FAA4F;aACnG;SACF;QACD,KAAK,EAAE,CAAC,SAAS,EAAE,WAAW,EAAE,SAAS,CAAC;QAC1C,KAAK,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;YACtB,MAAM,CAAC,GAAG,CAAC,GAAmB,CAAC,CAAA;YAC/B,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAC/B,CAAC;QACD,QAAQ,EAAE,KAAK,IAAI,EAAE;YACnB,cAAc,CAAC,QAAQ,EAAE,CAAA;QAC3B,CAAC;KACF,CAAA;AACH,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,MAAM,YAAY,GAAsB;IAC7C,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,qBAAqB;IAC9B,gBAAgB,EAAE,GAAG;IACrB,IAAI,KAAK;QACP,OAAO,kBAAkB,EAAE,CAAC,KAAK,IAAI,EAAE,CAAA;IACzC,CAAC;IACD,IAAI,UAAU;QACZ,OAAO,kBAAkB,EAAE,CAAC,UAAU,IAAI,EAAE,CAAA;IAC9C,CAAC;IACD,IAAI,YAAY;QACd,OAAO,YAAY,CAAA;IACrB,CAAC;IACD,aAAa,EAAE,oBAAoB;IACnC,cAAc,EAAE,kBAAkB;CACnC,CAAA"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Bodies the plugin evaluates inside the app through the transport's `evaluate` seam. Each is a
3
+ * self-contained string: no imports, no closures, JSON-safe results.
4
+ *
5
+ * @module
6
+ */
7
+ import type { StallSummary } from './run.js';
8
+ /** Timer lateness below this is scheduler jitter, not a blocked main thread. */
9
+ export declare const MIN_STALL_MS = 10;
10
+ export declare const SAMPLE_INTERVAL_MS = 10;
11
+ export declare const DEFAULT_IPC_INTERVAL_MS = 25;
12
+ export declare const DEFAULT_WINDOW_MS = 2000;
13
+ /** An unread window stops itself after this, so a detached or abandoned app keeps no timer. */
14
+ export declare const MAX_WINDOW_MS = 600000;
15
+ export interface MainFacts {
16
+ readonly pid: number;
17
+ /** Epoch ms the main process was created, when Electron exposes it. */
18
+ readonly creationTime: number | null;
19
+ readonly electron: string | null;
20
+ readonly platform: string;
21
+ readonly processes: readonly {
22
+ readonly pid: number;
23
+ readonly type: string;
24
+ readonly name: string | null;
25
+ readonly workingSetKb: number;
26
+ readonly privateKb: number | null;
27
+ }[];
28
+ }
29
+ export type MainOp = 'facts' | 'start' | 'read' | 'startup';
30
+ /** What the renderer memory probe body returns. */
31
+ export interface RendererMetrics {
32
+ readonly userAgent: string;
33
+ readonly processes: MainFacts['processes'];
34
+ }
35
+ /**
36
+ * Renderer body for a build whose main process cannot be inspected: `probe` is the app's own
37
+ * expression that resolves to `app.getAppMetrics()`, typically through IPC.
38
+ */
39
+ export declare function buildMemoryProbeBody(probe: string): string;
40
+ /**
41
+ * Main-process body. `facts` reads process metrics. `start` arms a 10 ms timer whose lateness is
42
+ * the blocked time (replacing any earlier window); `read` summarises it and, with `stop`, clears it.
43
+ * `startup` reads the navigation timing of the first window still open.
44
+ */
45
+ export declare const MAIN_BODY: string;
46
+ export type MainReadResult = StallSummary | null;
47
+ export type FirstWindowStartup = {
48
+ /** Epoch ms of the document's time origin. */
49
+ readonly timeOrigin: number;
50
+ /** Ms from the time origin to the end of the load event; 0 while still loading. */
51
+ readonly loadEventEnd: number;
52
+ readonly type: string | null;
53
+ /** The loaded document's URL; in-page pushState and hash changes do not move it. */
54
+ readonly url: string;
55
+ /** The window's first history entry, from Electron 32's navigationHistory. */
56
+ readonly firstUrl: string | null;
57
+ /** History length on older Electron, which has no navigationHistory. */
58
+ readonly historyLength: number | null;
59
+ } | {
60
+ readonly error: string;
61
+ };
62
+ /**
63
+ * Renderer body that starts a background loop timing one round trip of `probe` per interval.
64
+ * The expression is inlined, not evaluated at runtime, so a page CSP without `unsafe-eval` holds.
65
+ */
66
+ export declare function buildIpcStartBody(probe: string): string;
67
+ export interface IpcReadResult {
68
+ readonly samples: readonly number[];
69
+ readonly errors: number;
70
+ readonly lastError: string | null;
71
+ }
72
+ /** Renderer body: read the probe samples and, with `stop`, end the loop. Null when none runs. */
73
+ export declare const IPC_READ_BODY = "\nconst state = window['__swBudgetIpc'];\nif (!state) return null;\nif (arg.stop) {\n state.stop = true;\n delete window['__swBudgetIpc'];\n}\nreturn { samples: state.samples.slice(), errors: state.errors, lastError: state.lastError };\n";
74
+ //# sourceMappingURL=probe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probe.d.ts","sourceRoot":"","sources":["../src/probe.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAE5C,gFAAgF;AAChF,eAAO,MAAM,YAAY,KAAK,CAAA;AAC9B,eAAO,MAAM,kBAAkB,KAAK,CAAA;AACpC,eAAO,MAAM,uBAAuB,KAAK,CAAA;AACzC,eAAO,MAAM,iBAAiB,OAAQ,CAAA;AACtC,+FAA+F;AAC/F,eAAO,MAAM,aAAa,SAAU,CAAA;AAGpC,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,uEAAuE;IACvE,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IAChC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,SAAS;QAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;QACpB,QAAQ,CAAC,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