UNPKG

@sentry/remix

Version:
64 lines (61 loc) • 1.76 kB
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } }); const EVENTS = ["start", "end", "asyncStart", "asyncEnd", "error"]; function createChannel() { const handlers = /* @__PURE__ */ new Set(); return { get hasSubscribers() { return handlers.size > 0; }, publish(context) { for (const handler of Array.from(handlers)) { try { handler(context); } catch { } } }, runStores(context, fn, thisArg, ...args) { this.publish(context); return fn.apply(thisArg, args); }, subscribe(handler) { handlers.add(handler); }, unsubscribe(handler) { handlers.delete(handler); } }; } const registry = globalThis.__SENTRY_REMIX_DC_REGISTRY__ ?? (globalThis.__SENTRY_REMIX_DC_REGISTRY__ = /* @__PURE__ */ new Map()); function tracingChannel(name) { const existing = registry.get(name); if (existing) { return existing; } const channels = Object.fromEntries(EVENTS.map((event) => [event, createChannel()])); const channel = { ...channels, subscribe(subscribers) { for (const event of EVENTS) { const handler = subscribers[event]; if (handler) { channels[event].subscribe(handler); } } }, unsubscribe(subscribers) { for (const event of EVENTS) { const handler = subscribers[event]; if (handler) { channels[event].unsubscribe(handler); } } } }; registry.set(name, channel); return channel; } const diagnosticsChannelShim = { tracingChannel }; exports.default = diagnosticsChannelShim; exports.tracingChannel = tracingChannel; //# sourceMappingURL=diagnosticsChannelShim.js.map