message: chore: update testing schema manager host
diff: @@ -6,27 +6,51 @@ export type CreateTestingSchemaManagerHostOptions = SchemaConfig & {
  fileName: string;
  content: string;
  }[];
  + log?: (msg: string) => void;
  };
  -export function createTestingSchemaManagerHost(config: CreateTestingSchemaManagerHostOptions): SchemaManagerHost {
  - const files = config.files || [];
  - return {
  +class TestingSchemaManagerHost implements SchemaManagerHost {
  + private _files: { fileName: string; content: string }[];
  +
  + private _watchers: { path: string; cb: (fileName: string) => void }[] = [];
  +
  + constructor(private _config: CreateTestingSchemaManagerHostOptions) {
  + this._files = _config.files || [];
  + }
  +
  getConfig() {
  - return config;
  - },
  + return this._config;
  + }
  +
  getProjectRootPath() {
  - return config.prjRootPath || '/';
  - },
  - readFile(path) {
  - const found = files.find(f => f.fileName === path);
  + return this._config.prjRootPath || '/';
  + }
  +
  + readFile(path: string) {
  + const found = this._files.find(f => f.fileName === path);
  if (found) return found.content;
  - },
  - fileExists(path) {
  - return !!files.find(f => f.fileName === path);
  - },
  - watchFile() {
  + }
  +
  + fileExists(path: string) {
  + return !!this._files.find(f => f.fileName === path);
  + }
  +
  + watchFile(path: string, cb: (fileName: string) => void) {
  + this._watchers.push({ path, cb });
  return { close() {} };
  - },
  - log() {},
  - };
  + }
  +
  + log(msg: string) {
  + if (this._config.log) {
  + this._config.log(msg);
  + }
  + }
  +
  + updateFile(path: string, content: string) {
  + this._files = this._files.map(f => (f.fileName === path ? { ...f, content } : f));
  + }
  +}
  +
  +export function createTestingSchemaManagerHost(config: CreateTestingSchemaManagerHostOptions) {
  + return new TestingSchemaManagerHost(config);
  }
  