MCPcopy Create free account
hub / github.com/esengine/esengine / loadAll

Method loadAll

packages/runtime-core/src/PluginLoader.ts:156–195  ·  view source on GitHub ↗

* @zh 加载所有启用的插件 * @en Load all enabled plugins

()

Source from the content-addressed store, hash-verified

154 * @en Load all enabled plugins
155 */
156 async loadAll(): Promise<Map<string, PluginLoadInfo>> {
157 if (this._loading) {
158 throw new Error('Loading already in progress');
159 }
160
161 this._loading = true;
162 const start = Date.now();
163
164 try {
165 const enabled = this._config.plugins.filter(p => p.enabled);
166
167 // 验证依赖
168 const missing = this._validateDependencies(enabled);
169 for (const [id, deps] of missing) {
170 this._loaded.set(id, {
171 packageId: id,
172 state: 'missing',
173 missingDeps: deps,
174 error: `Missing: ${deps.join(', ')}`
175 });
176 }
177
178 // 过滤有效插件并排序
179 const valid = enabled.filter(p => !missing.has(p.packageId));
180 const sorted = this._sortByDependencies(valid);
181
182 // 串行加载
183 for (const plugin of sorted) {
184 await this._loadOne(plugin);
185 }
186
187 const time = Date.now() - start;
188 const loadedCount = this.getLoaded().length;
189 logger.info(`Loaded ${loadedCount}/${enabled.length} plugins in ${time}ms`);
190
191 return this._loaded;
192 } finally {
193 this._loading = false;
194 }
195 }
196
197 /**
198 * @zh 获取已加载插件

Callers 2

loadEnabledPluginsFunction · 0.95
_initializePluginsMethod · 0.95

Calls 10

_validateDependenciesMethod · 0.95
_sortByDependenciesMethod · 0.95
_loadOneMethod · 0.95
getLoadedMethod · 0.95
nowMethod · 0.80
filterMethod · 0.65
setMethod · 0.65
hasMethod · 0.65
joinMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected