MCPcopy
hub / github.com/vercel/hyper / loadModules

Function loadModules

lib/utils/plugins.ts:233–388  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

231};
232
233const loadModules = () => {
234 console.log('(re)loading renderer plugins');
235 const paths = plugins.getPaths();
236
237 // initialize cache that we populate with extension methods
238 connectors = {
239 Terms: {state: [], dispatch: []},
240 Header: {state: [], dispatch: []},
241 Hyper: {state: [], dispatch: []},
242 Notifications: {state: [], dispatch: []}
243 };
244 uiReducers = [];
245 middlewares = [];
246 sessionsReducers = [];
247 termGroupsReducers = [];
248 tabPropsDecorators = [];
249 tabsPropsDecorators = [];
250 termPropsDecorators = [];
251 termGroupPropsDecorators = [];
252
253 propsDecorators = {
254 getTermProps: termPropsDecorators,
255 getTabProps: tabPropsDecorators,
256 getTabsProps: tabsPropsDecorators,
257 getTermGroupProps: termGroupPropsDecorators
258 };
259
260 reducersDecorators = {
261 reduceUI: uiReducers,
262 reduceSessions: sessionsReducers,
263 reduceTermGroups: termGroupsReducers
264 };
265
266 const loadedPlugins = plugins.getLoadedPluginVersions().map((plugin: any) => plugin.name);
267 modules = paths.plugins
268 .concat(paths.localPlugins)
269 .filter((plugin) => loadedPlugins.indexOf(basename(plugin)) !== -1)
270 .map((path) => {
271 let mod: hyperPlugin;
272 const pluginName = getPluginName(path);
273 const pluginVersion = getPluginVersion(path);
274
275 // window.require allows us to ensure this doesn't get
276 // in the way of our build
277 try {
278 mod = window.require(path);
279 } catch (err) {
280 notify(
281 'Plugin load error',
282 `"${pluginName}" failed to load in the renderer process. Check Developer Tools for details.`,
283 {error: err}
284 );
285 return undefined;
286 }
287
288 ObjectTypedKeys(mod).forEach((i) => {
289 if (Object.hasOwnProperty.call(mod, i)) {
290 mod[i]._pluginName = pluginName;

Callers 2

plugins.tsFile · 0.85
reloadFunction · 0.85

Calls 12

ObjectTypedKeysFunction · 0.90
getPluginNameFunction · 0.85
getPluginVersionFunction · 0.85
filterMethod · 0.80
concatMethod · 0.80
indexOfMethod · 0.80
notifyFunction · 0.70
logMethod · 0.45
forEachMethod · 0.45
errorMethod · 0.45
pushMethod · 0.45
warnMethod · 0.45

Tested by

no test coverage detected