UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.37 kB
import{i as getLegacyPluginSdkResourceHost}from"./legacy-sdk-resource-host-9HMZFK01.mjs";import{i as getPluginInstance}from"./plugin-instance-scope-Bx-frH07.mjs";import{n as getPluginRegistryInspectionResources}from"./registry-inspection-resources-5ksQH_Ac.mjs"; //!src/plugins/legacy-sdk-provider-projection.ts function createLegacyPluginSdkProviderProjection(){let e;const t=/* @__PURE__ */ new Map;const n=/* @__PURE__ */ new Map;return{select(r){const i=r&&getPluginRegistryInspectionResources(r);if(!r||!i)return;e??=getLegacyPluginSdkResourceHost();e.assertOpen();let a=t.get(i);if(!a){const r=i.retain();const o=e;a=o.getProviderProjection(i,()=>{const e=/* @__PURE__ */ new Map;let t=0;const n={retain(r){t++;let a;return{release:()=>{if(!a){if(--t===0){e.forEach(e=>e.release());e.clear();o.forgetProviderProjection(i,n)}a=r.release()}return a}}},project(t,n){o.assertOpen();if(!n)return t;let r=e.get(n);if(!r){r=n.retainConsumer(e=>o.invoke(e));e.set(n,r)}const i=r;return i.run(()=>i.wrap(t))}};return n});n.set(i,a.retain(r));t.set(i,a)}const o=a;return(e,t)=>{const n=r.plugins.find(e=>e.id===t);return o.project(e,n&&getPluginInstance(n))}},adopt(){e?.assertOpen();for(const[t,r]of n){e.adopt(t,r);n.delete(t)}},[Symbol.dispose](){const t=[...n.values()];n.clear();for(const n of t)e.releaseClaim(n)}}}export{createLegacyPluginSdkProviderProjection as t};