38 lines
1008 B
JavaScript
38 lines
1008 B
JavaScript
/*!
|
|
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
*/
|
|
/**
|
|
* Global VFS manager to avoid passing VFS instances around throughout the package.
|
|
* Initialize once with setVfs() and then use getVfs() throughout the codebase.
|
|
*/
|
|
let vfsInstance = null;
|
|
/**
|
|
* Sets the global VFS instance to be used throughout the package.
|
|
* Should be called once during initialization (e.g., in addDataSourceAsync).
|
|
*/
|
|
export function setVfs(vfs) {
|
|
vfsInstance = vfs;
|
|
}
|
|
/**
|
|
* Gets the global VFS instance.
|
|
* Throws an error if VFS has not been initialized.
|
|
*/
|
|
export function getVfs() {
|
|
if (!vfsInstance) {
|
|
throw new Error('VFS has not been initialized. Call setVfs() first.');
|
|
}
|
|
return vfsInstance;
|
|
}
|
|
/**
|
|
* Checks if VFS has been initialized.
|
|
*/
|
|
export function isVfsInitialized() {
|
|
return vfsInstance !== null;
|
|
}
|
|
/**
|
|
* Clears the VFS instance (useful for testing or cleanup).
|
|
*/
|
|
export function clearVfs() {
|
|
vfsInstance = null;
|
|
}
|
|
//# sourceMappingURL=VfsManager.js.map
|