File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ const client = () => {
4646 importPath ,
4747 correctSet ,
4848 vendorSourceMap ,
49- dirnameAndFilenameSupport
49+ dirnameAndFilenameSupport ,
5050 ] ,
5151 external : [ 'fontkit-next' ] ,
5252 } )
@@ -81,7 +81,7 @@ const node = () => {
8181 importPath ,
8282 correctSet ,
8383 vendorSourceMap ,
84- dirnameAndFilenameSupport
84+ dirnameAndFilenameSupport ,
8585 ] ,
8686 external : [ 'fontkit-next' , 'pdfkit' ] , // TODO: Remove external pdfkit
8787 } )
Original file line number Diff line number Diff line change 1- const fs = require ( "fs" ) ;
2- const path = require ( " path" ) ;
1+ const fs = require ( 'fs' )
2+ const path = require ( ' path' )
33
4- const nodeModules = new RegExp ( / ^ (?: .* [ \\ \/ ] ) ? n o d e _ m o d u l e s (?: [ \\ \/ ] .* ) ? $ / ) ;
4+ const nodeModules = new RegExp ( / ^ (?: .* [ \\ \/ ] ) ? n o d e _ m o d u l e s (?: [ \\ \/ ] .* ) ? $ / )
55
66module . exports = {
7- name : " dirname" ,
7+ name : ' dirname' ,
88 setup ( build ) {
99 build . onLoad ( { filter : / .* / } , ( { path : filePath } ) => {
1010 if ( ! filePath . match ( nodeModules ) ) {
11- let contents = fs . readFileSync ( filePath , " utf8" ) ;
12- const loader = path . extname ( filePath ) . substring ( 1 ) ;
13- const dirname = path . dirname ( filePath ) ;
11+ let contents = fs . readFileSync ( filePath , ' utf8' )
12+ const loader = path . extname ( filePath ) . substring ( 1 )
13+ const dirname = path . dirname ( filePath )
1414 contents = contents
15- . replace ( " __dirname" , `"${ dirname } "` )
16- . replace ( " __filename" , `"${ filePath } "` ) ;
15+ . replace ( ' __dirname' , `"${ dirname } "` )
16+ . replace ( ' __filename' , `"${ filePath } "` )
1717 return {
1818 contents,
1919 loader,
20- } ;
20+ }
2121 }
22- } ) ;
22+ } )
2323 } ,
24- } ;
24+ }
Original file line number Diff line number Diff line change @@ -256,6 +256,8 @@ export default class {
256256
257257 const runType = options ?. type || 'client'
258258
259+ this . options ?. plugins ?. forEach ( ( { onBefore } ) => onBefore && onBefore ( ) )
260+
259261 return new Promise ( async ( res , rej ) => {
260262 if ( ! this . pdfkit ) {
261263 this . reset ( )
@@ -286,6 +288,10 @@ export default class {
286288 . then ( async ( ) => {
287289 await runPluginBackground ( this )
288290
291+ this . options ?. plugins ?. forEach (
292+ ( { onAfter } ) => onAfter && onAfter ( )
293+ )
294+
289295 this . pdfkit ?. end ( )
290296
291297 pageHandler ( this ) . then ( ( ) => {
@@ -305,6 +311,10 @@ export default class {
305311 this . pipeline ( )
306312 . then ( ( ) => {
307313 pageHandler ( this ) . then ( ( ) => {
314+ this . options ?. plugins ?. forEach (
315+ ( { onAfter } ) => onAfter && onAfter ( )
316+ )
317+
308318 this . pdfkit ?. end ( )
309319 } )
310320 } )
Original file line number Diff line number Diff line change @@ -146,7 +146,9 @@ export interface PluginGenerate {
146146
147147export interface Plugin {
148148 background ?: PluginBackgroundCallback < string | false >
149- page ?: PluginPageCallback < void > [ ]
149+ page : PluginPageCallback < void > [ ]
150+ onAfter ?: ( ) => void
151+ onBefore ?: ( ) => void
150152}
151153
152154export type PluginBackgroundCallback < T > = ( context : PDFKit . PDFPage ) => T
You can’t perform that action at this time.
0 commit comments