MCPcopy Create free account
hub / github.com/BoyYangzai/mini-umi / proxyPluginAPI

Method proxyPluginAPI

packages/core/src/pluginAPI.ts:39–64  ·  view source on GitHub ↗
(opts: {
    pluginAPI: PluginAPi;
    service: Core;
    serviceProps: string[];
    staticProps: Record<string, any>;
  })

Source from the content-addressed store, hash-verified

37 }
38
39 static proxyPluginAPI(opts: {
40 pluginAPI: PluginAPi;
41 service: Core;
42 serviceProps: string[];
43 staticProps: Record<string, any>;
44 }) {
45 return new Proxy(opts.pluginAPI, {
46 get: (target, prop: string) => {
47 if (opts.service.pluginMethods[prop]) {
48 return opts.service.pluginMethods[prop].fn;
49 }
50 if (opts.serviceProps.includes(prop)) {
51 // @ts-ignore
52 const serviceProp = opts.service[prop];
53 return typeof serviceProp === 'function'
54 ? serviceProp.bind(opts.service)
55 : serviceProp;
56 }
57 if (prop in opts.staticProps) {
58 return opts.staticProps[prop];
59 }
60 // @ts-ignore
61 return target[prop];
62 },
63 });
64 }
65}

Callers 1

initPluginMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected