| 68 | |
| 69 | // eslint-disable-next-line no-redeclare |
| 70 | export class Editor extends EventEmitter implements IEditor { |
| 71 | |
| 72 | /** |
| 73 | * Ioc Container |
| 74 | */ |
| 75 | @obx.shallow private context = new Map<IPublicTypeEditorValueKey, any>(); |
| 76 | |
| 77 | get locale() { |
| 78 | return globalLocale.getLocale(); |
| 79 | } |
| 80 | |
| 81 | config?: EditorConfig; |
| 82 | |
| 83 | eventBus: EventBus; |
| 84 | |
| 85 | components?: PluginClassSet; |
| 86 | |
| 87 | // readonly utils = utils; |
| 88 | |
| 89 | private hooks: HookConfig[] = []; |
| 90 | |
| 91 | private waits = new Map< |
| 92 | IPublicTypeEditorValueKey, |
| 93 | Array<{ |
| 94 | once?: boolean; |
| 95 | resolve: (data: any) => void; |
| 96 | }> |
| 97 | >(); |
| 98 | |
| 99 | constructor(readonly viewName: string = 'global', readonly workspaceMode: boolean = false) { |
| 100 | // eslint-disable-next-line constructor-super |
| 101 | super(); |
| 102 | // set global emitter maxListeners |
| 103 | this.setMaxListeners(200); |
| 104 | this.eventBus = new EventBus(this); |
| 105 | } |
| 106 | |
| 107 | get<T = undefined, KeyOrType = any>( |
| 108 | keyOrType: KeyOrType, |
| 109 | ): IPublicTypeEditorGetResult<T, KeyOrType> | undefined { |
| 110 | return this.context.get(keyOrType as any); |
| 111 | } |
| 112 | |
| 113 | has(keyOrType: IPublicTypeEditorValueKey): boolean { |
| 114 | return this.context.has(keyOrType); |
| 115 | } |
| 116 | |
| 117 | set(key: IPublicTypeEditorValueKey, data: any): void | Promise<void> { |
| 118 | if (key === 'assets') { |
| 119 | return this.setAssets(data); |
| 120 | } |
| 121 | // store the data to engineConfig while invoking editor.set() |
| 122 | if (!keyBlacklist.includes(key as string)) { |
| 123 | engineConfig.set(key as any, data); |
| 124 | } |
| 125 | this.context.set(key, data); |
| 126 | this.notifyGot(key); |
| 127 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…