@@ -31,6 +31,9 @@ export {
3131 untracked ,
3232} ;
3333
34+ const DEVTOOLS_ENABLED =
35+ typeof window !== "undefined" && ! ! window . __PREACT_SIGNALS_DEVTOOLS__ ;
36+
3437const HAS_PENDING_UPDATE = 1 << 0 ;
3538const HAS_HOOK_STATE = 1 << 1 ;
3639const HAS_COMPUTEDS = 1 << 2 ;
@@ -172,11 +175,7 @@ Object.defineProperties(Signal.prototype, {
172175
173176/** Inject low-level property/attribute bindings for Signals into Preact's diff */
174177hook ( OptionsTypes . DIFF , ( old , vnode ) => {
175- if (
176- typeof vnode . type === "function" &&
177- typeof window !== "undefined" &&
178- window . __PREACT_SIGNALS_DEVTOOLS__
179- ) {
178+ if ( DEVTOOLS_ENABLED && typeof vnode . type === "function" ) {
180179 window . __PREACT_SIGNALS_DEVTOOLS__ . exitComponent ( ) ;
181180 }
182181
@@ -201,11 +200,7 @@ hook(OptionsTypes.DIFF, (old, vnode) => {
201200
202201/** Set up Updater before rendering a component */
203202hook ( OptionsTypes . RENDER , ( old , vnode ) => {
204- if (
205- typeof vnode . type === "function" &&
206- typeof window !== "undefined" &&
207- window . __PREACT_SIGNALS_DEVTOOLS__
208- ) {
203+ if ( DEVTOOLS_ENABLED && typeof vnode . type === "function" ) {
209204 window . __PREACT_SIGNALS_DEVTOOLS__ . enterComponent ( vnode ) ;
210205 }
211206
@@ -237,7 +232,7 @@ hook(OptionsTypes.RENDER, (old, vnode) => {
237232
238233/** Finish current updater if a component errors */
239234hook ( OptionsTypes . CATCH_ERROR , ( old , error , vnode , oldVNode ) => {
240- if ( typeof window !== "undefined" && window . __PREACT_SIGNALS_DEVTOOLS__ ) {
235+ if ( DEVTOOLS_ENABLED ) {
241236 window . __PREACT_SIGNALS_DEVTOOLS__ . exitComponent ( ) ;
242237 }
243238
@@ -248,11 +243,7 @@ hook(OptionsTypes.CATCH_ERROR, (old, error, vnode, oldVNode) => {
248243
249244/** Finish current updater after rendering any VNode */
250245hook ( OptionsTypes . DIFFED , ( old , vnode ) => {
251- if (
252- typeof vnode . type === "function" &&
253- typeof window !== "undefined" &&
254- window . __PREACT_SIGNALS_DEVTOOLS__
255- ) {
246+ if ( DEVTOOLS_ENABLED && typeof vnode . type === "function" ) {
256247 window . __PREACT_SIGNALS_DEVTOOLS__ . exitComponent ( ) ;
257248 }
258249
0 commit comments