mikser-io 9.40.1 → 9.40.2

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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/explain.js +26 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mikser-io",
3
- "version": "9.40.1",
3
+ "version": "9.40.2",
4
4
  "description": "<p align=\"center\"> <img src=\"mikser-lockup-stacked.svg\" alt=\"mikser\" width=\"198\" /> </p>",
5
5
  "main": "index.js",
6
6
  "exports": {
package/src/explain.js CHANGED
@@ -228,6 +228,16 @@ export async function explain(reference) {
228
228
  : 'unknown',
229
229
  outputHash: snap.outputHash ?? null,
230
230
  parent: snap.parent ?? null,
231
+ // Which keys of its OWN meta the render read, and which keys it
232
+ // read off OTHER entities.
233
+ //
234
+ // refClosure answers "what would re-render this". These answer
235
+ // "what does it actually use", which is the question behind a
236
+ // document that renders to a hole: a key the layout never touches
237
+ // is either a typo or dead weight, and nothing else on this report
238
+ // distinguishes them. Empty when the catalog predates the record.
239
+ metaReads: snap.metaReads ?? [],
240
+ consumedReads: (snap.consumedReads ?? []).map(([id, keys]) => ({ entity: id, keys })),
231
241
  refClosure: (snap.refClosure ?? []).map(entry =>
232
242
  entry.kind === 'query'
233
243
  ? {
@@ -383,6 +393,22 @@ export function formatExplain(report) {
383
393
  const gone = e.gone?.length ? ' [TARGET DELETED SINCE]' : ''
384
394
  out.push(` ${e.kind.padEnd(10)} ${e.target}${bound}${e.hash ? ` ${e.hash}` : ''}${gone}`)
385
395
  }
396
+
397
+ // What the render actually READ, as against what would re-render it.
398
+ // Capped, because a large page reads a lot and a wall of keys buries
399
+ // the rest of the report — the full list is in --json.
400
+ const SHOWN = 12
401
+ const shown = (keys) => keys.length > SHOWN
402
+ ? `${keys.slice(0, SHOWN).join(', ')} … +${keys.length - SHOWN} more`
403
+ : keys.join(', ')
404
+ if (r.metaReads?.length) {
405
+ row('metaReads', `${r.metaReads.length} key${r.metaReads.length === 1 ? '' : 's'} of its own meta`)
406
+ out.push(` ${shown(r.metaReads)}`)
407
+ }
408
+ for (const c of r.consumedReads ?? []) {
409
+ row('consumed', `${c.entity} (${c.keys.length})`)
410
+ out.push(` ${shown(c.keys)}`)
411
+ }
386
412
  }
387
413
 
388
414
  out.push('')