console-vue-query-devtools-sdk
Version:
Lightweight SDK for connecting Vue Query to custom DevTools extensions.
86 lines (85 loc) • 2.58 kB
JavaScript
import { defineComponent as p, onMounted as C } from "vue";
import { useQueryClient as E } from "@tanstack/vue-query";
const h = /* @__PURE__ */ p({
__name: "Devtools",
props: {
client: null
},
setup(o) {
const n = o, s = n.client || E();
return C(() => {
var l;
try {
(l = window.__VUE_QUERY_DEVTOOLS__) == null || l.registerClient(s), console.debug("[Devtools] QueryClient registered from Devtools.vue");
} catch (i) {
console.warn("[Devtools] Failed to register QueryClient:", i);
}
}), { __sfc: !0, props: n, client: s };
}
});
function m(o, n, s, l, i, _, u, d) {
var e = typeof o == "function" ? o.options : o;
n && (e.render = n, e.staticRenderFns = s, e._compiled = !0), l && (e.functional = !0), _ && (e._scopeId = "data-v-" + _);
var t;
if (u ? (t = function(r) {
r = r || // cached call
this.$vnode && this.$vnode.ssrContext || // stateful
this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext, !r && typeof __VUE_SSR_CONTEXT__ < "u" && (r = __VUE_SSR_CONTEXT__), i && i.call(this, r), r && r._registeredComponents && r._registeredComponents.add(u);
}, e._ssrRegister = t) : i && (t = d ? function() {
i.call(
this,
(e.functional ? this.parent : this).$root.$options.shadowRoot
);
} : i), t)
if (e.functional) {
e._injectStyles = t;
var c = e.render;
e.render = function(v, a) {
return t.call(a), c(v, a);
};
} else {
var f = e.beforeCreate;
e.beforeCreate = f ? [].concat(f, t) : [t];
}
return {
exports: o,
options: e
};
}
var w = function() {
var n = this, s = n._self._c;
return n._self._setupProxy, s("div");
}, y = [], g = /* @__PURE__ */ m(
h,
w,
y,
!1,
null,
null,
null,
null
);
const D = g.exports, Q = "vue-query-client-registered";
(function() {
if (typeof window > "u" || window.__VUE_QUERY_DEVTOOLS__)
return;
let o = null;
window.__VUE_QUERY_DEVTOOLS__ = {
registerClient(n) {
if (!n || typeof n.getQueryCache != "function") {
console.warn("[SDK] Invalid QueryClient passed to registerClient.");
return;
}
o = n, console.log("[SDK] QueryClient registered."), window.dispatchEvent(new CustomEvent(Q));
},
getQueryClient() {
return o || (console.warn("[SDK] No query client registered."), null);
}
};
})();
const R = process.env.NODE_ENV === "development" ? D : () => null;
export {
Q as CUSTOM_EVENT_NAME,
R as ConsoleVueQueryDevtools
};
//# sourceMappingURL=index.es.js.map