Create a new reader instance for loading workspaces and file paths.
N.B. After creation you must either call withFS() or loadFileSystem() to provide access to the file system before attempting to read files in a Node environment.
ProtectedremoveProtectedreadProtectedreadProtectedisProtectedisProtectedisThis method is intended for use in the browser where File System access is not supported. In a node environment, use readFromFile() or readFromFiles().
The content of the file to parse.
The result of parsing, including the successfully parsed constants, functions, types, rules, and any errors encountered.
Attempt to read a file from a specified path and load its content into the workspace. The reader will determine the type of the file based on its name and extension, and use the appropriate parsing method.
the path of the file to read.
the result of parsing, including the successfully parsed workspaces and any errors encountered.
Ensure a workspace with the specified name and options exists in the engine, then attempt to read and load the specified files into that workspace.
The configuration for the workspace, including its name, options, and files to load.
The mode for loading the workspace, including how to handle existing workspaces and file reading options.
true if the workspace was successfully loaded, otherwise false. Errors will be logged using the Logger.
Load all workspaces from the given configuration.
The configuration containing all workspaces to load.
The mode for loading the workspaces, including how to handle existing workspaces and file reading options.
true if all workspaces were successfully loaded, otherwise false. Errors will be logged using the Logger.
Provide a node file system module to be used for reading files.
This method or the equivalent loadFileSystem() must be called before attempting to read files in a Node environment.
the node fs module to use.
the current instance for chaining.
Dynamically import the Node.js file system module in a Node environment.
This method or the equivalent withFS() must be called before attempting to read files in a Node environment.
In a browser environment, this method will log an error since file system access is not supported.
the imported fs module if successful, otherwise undefined.
ProtectedvalidatedValidate the parsed content of the configuration file.
the raw parsed content from the configuration file to validate.
the validated content.
ProtectedlogProtectedlog
Helper class to safely read workspace configurations from files and load them into a workspace. It supports reading from strings or a configuration file in JSON5 format.
N.B. File paths should be absolute or relative to the current working directory.
The reader will determine the type of each file based on these naming conventions and use the appropriate parsing method to load its content into the workspace.
NB: This class relies on Node's 'fs' module for file system access, so it is intended for use in Node.js environments. In browser environments, file reading should be handled differently; this class will report errors in a browser environment.