import { appendRpcMeta } from '../utils/rpcMeta.js'; import { instrumentFetcher } from './worker/instrumentFetcher.js'; const STUB_NON_RPC_METHODS = /* @__PURE__ */ new Set(["fetch", "connect", "dup"]); function instrumentDurableObjectNamespace(namespace) { return new Proxy(namespace, { get(target, prop, _receiver) { const value = Reflect.get(target, prop); if (typeof value !== "function") { return value; } if (prop === "get" || prop === "getByName") { return function(...args) { const stub = Reflect.apply(value, target, args); return instrumentDurableObjectStub(stub); }; } return value.bind(target); } }); } function instrumentDurableObjectStub(stub) { return new Proxy(stub, { get(target, prop) { const value = Reflect.get(target, prop); if (prop === "fetch" && typeof value === "function") { return instrumentFetcher((...args) => Reflect.apply(value, target, args)); } if (typeof value === "function" && typeof prop === "string" && !STUB_NON_RPC_METHODS.has(prop)) { return (...args) => Reflect.apply(value, target, appendRpcMeta(args)); } return value; } }); } export { STUB_NON_RPC_METHODS, instrumentDurableObjectNamespace }; //# sourceMappingURL=instrumentDurableObjectNamespace.js.map