Skip to content

Commit 1a14fd0

Browse files
committed
fix: pass the documented payload to before/afterExport hooks
beforeExport(ctx, {format, options}) and afterExport(ctx, {format, options, result}) per the plugin spec, instead of the raw result.
1 parent 37d99a5 commit 1a14fd0

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/api/snapdom.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,11 @@ snapdom.capture = async (el, context, _token) => {
184184
if (!work) throw new Error(`[snapdom] Unknown export type: ${type}`)
185185
const nextOpts = normalizeExportOptions(type, opts)
186186
const ctx = { ...context, export: { type, options: nextOpts, url } }
187-
await runHook('beforeExport', ctx)
187+
// Payload shape per the plugin spec: beforeExport(ctx, {format, options}),
188+
// afterExport(ctx, {format, options, result}). `type` is the export name (png/blob/…).
189+
await runHook('beforeExport', ctx, { format: type, options: nextOpts })
188190
const result2 = await work(ctx, nextOpts)
189-
await runHook('afterExport', ctx, result2)
191+
await runHook('afterExport', ctx, { format: type, options: nextOpts, result: result2 })
190192
if (!afterSnapFired) {
191193
afterSnapFired = true
192194
await runHook('afterSnap', context)

0 commit comments

Comments
 (0)