Skip to content

Commit a0ffee3

Browse files
committed
y
1 parent 3d1794b commit a0ffee3

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

index.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ import {
1414
loadLocalModules,
1515
loadRemoteModules,
1616
} from "./module.js";
17+
// @deno-types="./util.ts"
18+
import { registerReactDevtoolsHook } from "./util.js";
19+
20+
registerReactDevtoolsHook();
1721

1822
await Promise.all([mixin(INTERNAL_TRANSFORMER), loadLocalModules()]);
1923
console.time("onSpotifyPreInit");
@@ -22,9 +26,7 @@ console.timeEnd("onSpotifyPreInit");
2226

2327
console.time("onSpotifyInit");
2428
await Promise.all(
25-
["/vendor~xpui.js", "/xpui.js"].map(applyTransforms).map(async (p) =>
26-
import(await p)
27-
),
29+
["/vendor~xpui.js", "/xpui.js"].map(applyTransforms).map(async (p) => import(await p)),
2830
);
2931
console.timeEnd("onSpotifyInit");
3032

util.ts

+21-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export const matchLast = (str: string, pattern: RegExp) => {
4646
return Array.from(matches).at(-1)!;
4747
};
4848

49-
5049
export function stringifyUrlSearchParams(
5150
params: Record<string, string | string[]>,
5251
) {
@@ -62,3 +61,24 @@ export function stringifyUrlSearchParams(
6261
}
6362
return searchParams.toString();
6463
}
64+
65+
declare global {
66+
var __REACT_DEVTOOLS_GLOBAL_HOOK__: {
67+
isDisabled: boolean;
68+
supportsFiber: boolean;
69+
inject: ($: any) => void;
70+
};
71+
var findHostInstanceByFiber: (fiber: any) => any;
72+
var findFiberByHostInstance: (hostInstance: any) => any;
73+
}
74+
75+
export function registerReactDevtoolsHook() {
76+
globalThis["__REACT_DEVTOOLS_GLOBAL_HOOK__"] = {
77+
isDisabled: false,
78+
supportsFiber: true,
79+
inject($) {
80+
globalThis["findHostInstanceByFiber"] = $.findHostInstanceByFiber;
81+
globalThis["findFiberByHostInstance"] = $.findFiberByHostInstance;
82+
},
83+
};
84+
}

0 commit comments

Comments
 (0)