diff --git a/packages/core/src/Source.ts b/packages/core/src/Source.ts index 259f0c748..f30071d1d 100644 --- a/packages/core/src/Source.ts +++ b/packages/core/src/Source.ts @@ -135,6 +135,7 @@ export default class Source { } async requestNamespaceSourceUpdate( + namespaceSourceDesc: string, updatedSourceFilesystem: IVolumeImmutable, sharedFilesystem: IVolumeImmutable, globalConfig: MutableData @@ -158,6 +159,9 @@ export default class Source { ); } if (shouldInvokeAfterUpdate === true) { + console.log( + `[Mosaic][Source] namespace source ${namespaceSourceDesc} updated. Triggering 'afterNamespaceSourceUpdate for ${this.id.description}` + ); this.filesystem.unfreeze(); await this.invokeAfterUpdate(sharedFilesystem, globalConfig, 'afterNamespaceSourceUpdate'); this.filesystem.freeze(); diff --git a/packages/core/src/SourceManager.ts b/packages/core/src/SourceManager.ts index 363ef29c4..910c7319d 100644 --- a/packages/core/src/SourceManager.ts +++ b/packages/core/src/SourceManager.ts @@ -247,20 +247,21 @@ export default class SourceManager { #updateNamespaceSources(immutableSourceFilesystem: IVolumeImmutable, source: Source) { // Notify other frozen sources that share this sources namespace that something has changed. + const sourcesToUpdate = Array.from(this.#sources.values()).filter( + existingSource => + existingSource !== source && + existingSource.filesystem.frozen && + existingSource.namespace === source.namespace + ); + return Promise.all( - Array.from(this.#sources.values()).map(existingSource => { - if ( - existingSource !== source && - existingSource.filesystem.frozen && - existingSource.namespace === source.namespace - ) { - return existingSource.requestNamespaceSourceUpdate( - immutableSourceFilesystem, - this.#sharedFilesystem, - this.#globalConfig - ); - } - return existingSource; + sourcesToUpdate.map(async sourceToUpdate => { + await sourceToUpdate.requestNamespaceSourceUpdate( + source.id.description, + immutableSourceFilesystem, + this.#sharedFilesystem, + this.#globalConfig + ); }) ); } diff --git a/packages/core/src/WorkerSubscription.ts b/packages/core/src/WorkerSubscription.ts index 70f547839..81e001beb 100644 --- a/packages/core/src/WorkerSubscription.ts +++ b/packages/core/src/WorkerSubscription.ts @@ -59,10 +59,12 @@ export default class WorkerSubscription { } else if (type === 'track') { this.#emitter.emit(EVENT.TRACK, { data: JSON.parse(textDecoder.decode(data)) }); } else if (type === 'init') { - this.#emitter.emit(EVENT.START); if (data) { - // We receive a file buffer for 'init', not an object - this.#emitter.emit(EVENT.UPDATE, { data: JSON.parse(textDecoder.decode(data)) }); + // We receive a file buffer (cached fs) for 'init', not an object + this.#emitter.emit(EVENT.START, { data: JSON.parse(textDecoder.decode(data)) }); + } else { + // started with no cached fs + this.#emitter.emit(EVENT.START); } } else { this.#onError( diff --git a/packages/plugins/src/BreadcrumbsPlugin.ts b/packages/plugins/src/BreadcrumbsPlugin.ts index 047bc09fc..94e3ffd7b 100644 --- a/packages/plugins/src/BreadcrumbsPlugin.ts +++ b/packages/plugins/src/BreadcrumbsPlugin.ts @@ -123,8 +123,21 @@ const BreadcrumbsPlugin: PluginType `**/${ignore}`), + cwd: '/' + })) as string[]; + + // the root namespace has updated + return namespaceDirFiles.length > 0; } };