@@ -62,6 +62,8 @@ export interface PackageConfig {
6262 failed ?: PackageFailed ; // Function to call when package fails to load
6363 checkReady ?: ( ) => Promise < void > ; // Function called to see if package is fully loaded
6464 // (may cause additional packages to load, for example)
65+ extraLoads ?: string [ ] ; // Extra packages to load after this one
66+ rendererExtensions ?: string [ ] ; // Font extensions to load when renderer changes
6567}
6668
6769/**
@@ -143,6 +145,16 @@ export class Package {
143145 return this . dependencyCount === 0 && ! this . noLoad && ! this . isLoading && ! this . hasFailed ;
144146 }
145147
148+ /**
149+ * @param {string } name A promise for when extra files and checkReady have been fulfilled
150+ */
151+ public static loadPromise ( name : string ) : Promise < void > {
152+ const config = ( CONFIG [ name ] || { } ) as PackageConfig ;
153+ const promise = Promise . all ( ( config . extraLoads || [ ] ) . map ( ( name ) => Loader . load ( name ) ) ) ;
154+ const checkReady = config . checkReady || ( ( ) => Promise . resolve ( ) ) ;
155+ return promise . then ( ( ) => checkReady ( ) ) as Promise < void > ;
156+ }
157+
146158 /**
147159 * Compute the path for a package using the loader's path filters
148160 *
@@ -344,18 +356,16 @@ export class Package {
344356 /**
345357 * Check if a package is really ready to be marked as loaded
346358 * (When it is loaded, it may set its own checkReady() function
347- * as a means of loading additional packages. E.g., an output
348- * jax may load a font package, dependent on its configuration.)
359+ * or extraLoads array as a means of loading additional packages.
360+ * E.g., an output jax may load a font package, dependent on its
361+ * configuration.)
349362 *
350363 * The configuration's checkReady() function returns a promise
351364 * that allows the loader to wait for addition actions to finish
352365 * before marking the file as loaded (or failing to load).
353366 */
354367 protected checkLoad ( ) {
355- const config = ( CONFIG [ this . name ] || { } ) as PackageConfig ;
356- const checkReady = config . checkReady || ( ( ) => Promise . resolve ( ) ) ;
357- checkReady ( ) . then ( ( ) => this . loaded ( ) )
358- . catch ( ( message ) => this . failed ( message ) ) ;
368+ Package . loadPromise ( this . name ) . then ( ( ) => this . loaded ( ) ) . catch ( ( message ) => this . failed ( message ) ) ;
359369 }
360370
361371 /**
0 commit comments