bippy 0.3.34 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bippy",
3
- "version": "0.3.34",
3
+ "version": "0.5.0",
4
4
  "description": "hack into react internals",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -40,14 +40,14 @@
40
40
  "default": "./dist/index.cjs"
41
41
  }
42
42
  },
43
- "./core": {
43
+ "./lite": {
44
44
  "import": {
45
- "types": "./dist/core.d.ts",
46
- "default": "./dist/core.js"
45
+ "types": "./dist/lite.d.ts",
46
+ "default": "./dist/lite.js"
47
47
  },
48
48
  "require": {
49
- "types": "./dist/core.d.cts",
50
- "default": "./dist/core.cjs"
49
+ "types": "./dist/lite.d.cts",
50
+ "default": "./dist/lite.cjs"
51
51
  }
52
52
  },
53
53
  "./source": {
@@ -60,16 +60,6 @@
60
60
  "default": "./dist/source.cjs"
61
61
  }
62
62
  },
63
- "./experiments/inspect": {
64
- "import": {
65
- "types": "./dist/experiments/inspect.d.ts",
66
- "default": "./dist/experiments/inspect.js"
67
- },
68
- "require": {
69
- "types": "./dist/experiments/inspect.d.cts",
70
- "default": "./dist/experiments/inspect.cjs"
71
- }
72
- },
73
63
  "./dist/*": "./dist/*.js",
74
64
  "./dist/*.js": "./dist/*.js",
75
65
  "./dist/*.cjs": "./dist/*.cjs"
@@ -86,13 +76,13 @@
86
76
  "LICENSE"
87
77
  ],
88
78
  "devDependencies": {
79
+ "@jridgewell/sourcemap-codec": "^1.5.0",
89
80
  "@testing-library/dom": "^10.4.0",
90
81
  "@testing-library/react": "^16.1.0",
91
82
  "@types/node": "^20",
92
83
  "@types/react": "^19.0.4",
93
84
  "@types/react-dom": "^19.0.2",
94
85
  "@vitest/coverage-istanbul": "2.1.8",
95
- "error-stack-parser-es": "^1.0.5",
96
86
  "esbuild": "^0.24.2",
97
87
  "happy-dom": "^15.11.7",
98
88
  "publint": "^0.2.12",
@@ -101,7 +91,6 @@
101
91
  "react-dom": "19.0.0",
102
92
  "react-reconciler": "^0.31.0",
103
93
  "react-refresh": "^0.16.0",
104
- "source-map-js": "^1.2.1",
105
94
  "terser": "^5.36.0",
106
95
  "tsdown": "^0.12.3",
107
96
  "vitest": "^2.1.8"
@@ -1,292 +0,0 @@
1
- /**
2
- * @license bippy
3
- *
4
- * Copyright (c) Aiden Bai
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- */
9
- Object.defineProperty(exports, '__esModule', { value: true });
10
- const require_source = require('../source-BAPwFAwe.cjs');
11
- const require_src = require('../src-J3uOnLH2.cjs');
12
- const react = require_source.__toESM(require("react"));
13
- const react_dom = require_source.__toESM(require("react-dom"));
14
- const react_inspector = require_source.__toESM(require("react-inspector"));
15
- const react_jsx_runtime = require_source.__toESM(require("react/jsx-runtime"));
16
-
17
- //#region src/experiments/inspect.tsx
18
- const useImperativeHandlePolyfill = (ref, init, deps) => {
19
- (0, react.useEffect)(() => {
20
- if (ref) {
21
- if (typeof ref === "function") ref(init());
22
- else if (typeof ref === "object" && "current" in ref) ref.current = init();
23
- }
24
- }, deps);
25
- };
26
- const useImperativeHandle = react.useImperativeHandle || useImperativeHandlePolyfill;
27
- const throttle = (fn, wait) => {
28
- let timeout = null;
29
- return function(...args) {
30
- if (!timeout) timeout = setTimeout(() => {
31
- fn.apply(this, args);
32
- timeout = null;
33
- }, wait);
34
- };
35
- };
36
- const theme = {
37
- ARROW_ANIMATION_DURATION: "0",
38
- ARROW_COLOR: "#A0A0A0",
39
- ARROW_FONT_SIZE: 12,
40
- ARROW_MARGIN_RIGHT: 3,
41
- BASE_BACKGROUND_COLOR: "none",
42
- BASE_COLOR: "#FFF",
43
- BASE_FONT_FAMILY: "Menlo, monospace",
44
- BASE_FONT_SIZE: "12px",
45
- BASE_LINE_HEIGHT: 1.2,
46
- HTML_ATTRIBUTE_NAME_COLOR: "#A0A0A0",
47
- HTML_ATTRIBUTE_VALUE_COLOR: "#99FFE4",
48
- HTML_COMMENT_COLOR: "#8b8b8b94",
49
- HTML_DOCTYPE_COLOR: "#A0A0A0",
50
- HTML_TAG_COLOR: "#FFC799",
51
- HTML_TAGNAME_COLOR: "#FFC799",
52
- HTML_TAGNAME_TEXT_TRANSFORM: "lowercase",
53
- OBJECT_NAME_COLOR: "#FFC799",
54
- OBJECT_PREVIEW_ARRAY_MAX_PROPERTIES: 10,
55
- OBJECT_PREVIEW_OBJECT_MAX_PROPERTIES: 5,
56
- OBJECT_VALUE_BOOLEAN_COLOR: "#FFC799",
57
- OBJECT_VALUE_FUNCTION_PREFIX_COLOR: "#FFC799",
58
- OBJECT_VALUE_NULL_COLOR: "#A0A0A0",
59
- OBJECT_VALUE_NUMBER_COLOR: "#FFC799",
60
- OBJECT_VALUE_REGEXP_COLOR: "#FF8080",
61
- OBJECT_VALUE_STRING_COLOR: "#99FFE4",
62
- OBJECT_VALUE_SYMBOL_COLOR: "#FFC799",
63
- OBJECT_VALUE_UNDEFINED_COLOR: "#A0A0A0",
64
- TABLE_BORDER_COLOR: "#282828",
65
- TABLE_DATA_BACKGROUND_IMAGE: "none",
66
- TABLE_DATA_BACKGROUND_SIZE: "0",
67
- TABLE_SORT_ICON_COLOR: "#A0A0A0",
68
- TABLE_TH_BACKGROUND_COLOR: "#161616",
69
- TABLE_TH_HOVER_COLOR: "#232323",
70
- TREENODE_FONT_FAMILY: "Menlo, monospace",
71
- TREENODE_FONT_SIZE: "11px",
72
- TREENODE_LINE_HEIGHT: 1.2,
73
- TREENODE_PADDING_LEFT: 12
74
- };
75
- const RawInspector = (0, react.forwardRef)(({ dangerouslyRunInProduction = false, enabled = true }, ref) => {
76
- const [element, setElement] = (0, react.useState)(null);
77
- const [currentFiber, setCurrentFiber] = (0, react.useState)(null);
78
- const [currentFiberSource, setCurrentFiberSource] = (0, react.useState)(null);
79
- const [rect, setRect] = (0, react.useState)(null);
80
- const [isActive, setIsActive] = (0, react.useState)(true);
81
- const [isEnabled, setIsEnabled] = (0, react.useState)(enabled);
82
- const [position, setPosition] = (0, react.useState)({
83
- left: 0,
84
- top: 0
85
- });
86
- const currentCleanedFiber = (0, react.useMemo)(() => {
87
- if (!currentFiber) return null;
88
- const clonedFiber = { ...currentFiber };
89
- for (const key in clonedFiber) {
90
- const value = clonedFiber[key];
91
- if (!value) delete clonedFiber[key];
92
- }
93
- return clonedFiber;
94
- }, [currentFiber]);
95
- useImperativeHandle(ref, () => ({
96
- disable: () => {
97
- setIsEnabled(false);
98
- setElement(null);
99
- setRect(null);
100
- },
101
- enable: () => setIsEnabled(true),
102
- inspectElement: (element$1) => {
103
- if (!isEnabled) return;
104
- setElement(element$1);
105
- setRect(element$1.getBoundingClientRect());
106
- }
107
- }));
108
- (0, react.useEffect)(() => {
109
- (async () => {
110
- if (!element) return;
111
- const fiber = require_src.getFiberFromHostInstance(element);
112
- if (!fiber) return;
113
- const latestFiber = require_src.getLatestFiber(fiber);
114
- const source = await require_source.getFiberSource(latestFiber);
115
- setCurrentFiber(latestFiber);
116
- if (source) setCurrentFiberSource(source);
117
- })();
118
- }, [element]);
119
- (0, react.useEffect)(() => {
120
- const handleMouseMove = (event) => {
121
- const isActive$1 = require_src.isInstrumentationActive() || require_src.hasRDTHook();
122
- if (!isActive$1) {
123
- setIsActive(false);
124
- return;
125
- }
126
- if (!dangerouslyRunInProduction) {
127
- const rdtHook = require_src.getRDTHook();
128
- for (const renderer of rdtHook.renderers.values()) {
129
- const buildType = require_src.detectReactBuildType(renderer);
130
- if (buildType === "production") {
131
- setIsActive(false);
132
- return;
133
- }
134
- }
135
- }
136
- if (!isEnabled) {
137
- setElement(null);
138
- setRect(null);
139
- return;
140
- }
141
- const element$1 = document.elementFromPoint(event.clientX, event.clientY);
142
- if (!element$1) return;
143
- setElement(element$1);
144
- setRect(element$1.getBoundingClientRect());
145
- };
146
- const throttledMouseMove = throttle(handleMouseMove, 16);
147
- document.addEventListener("mousemove", throttledMouseMove);
148
- return () => document.removeEventListener("mousemove", throttledMouseMove);
149
- }, [isEnabled, dangerouslyRunInProduction]);
150
- (0, react.useEffect)(() => {
151
- if (!rect) return;
152
- const padding = 10;
153
- const inspectorWidth = 400;
154
- const inspectorHeight = 320;
155
- let left = rect.left + rect.width + padding;
156
- let top = rect.top;
157
- if (left + inspectorWidth > window.innerWidth) left = Math.max(padding, rect.left - inspectorWidth - padding);
158
- if (top >= rect.top && top <= rect.bottom) if (rect.bottom + inspectorHeight + padding <= window.innerHeight) top = rect.bottom + padding;
159
- else if (rect.top - inspectorHeight - padding >= 0) top = rect.top - inspectorHeight - padding;
160
- else top = window.innerHeight - inspectorHeight - padding;
161
- top = Math.max(padding, Math.min(top, window.innerHeight - inspectorHeight - padding));
162
- left = Math.max(padding, Math.min(left, window.innerWidth - inspectorWidth - padding));
163
- setPosition({
164
- left,
165
- top
166
- });
167
- }, [rect]);
168
- if (!rect || !isActive || !isEnabled) return null;
169
- if (!currentFiber) return null;
170
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
171
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
172
- className: "inspector-container",
173
- style: {
174
- backgroundColor: "#101010",
175
- border: "1px solid #444",
176
- borderRadius: "8px",
177
- boxShadow: "0 4px 8px rgba(0, 0, 0, 0.5)",
178
- color: "#FFF",
179
- height: "25ch",
180
- left: position.left,
181
- opacity: rect ? 1 : 0,
182
- overflow: "auto",
183
- padding: "1rem",
184
- pointerEvents: rect ? "auto" : "none",
185
- position: "fixed",
186
- top: position.top,
187
- transform: rect ? "translateY(0)" : "translateY(10px)",
188
- transition: "all 150ms ease-in-out",
189
- width: "30ch",
190
- zIndex: 50
191
- },
192
- children: [currentFiber && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_inspector.Inspector, {
193
- data: currentCleanedFiber,
194
- expandLevel: 1,
195
- table: false,
196
- theme
197
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
198
- style: {
199
- alignItems: "center",
200
- backgroundColor: "#101010",
201
- borderBottomLeftRadius: "8px",
202
- borderBottomRightRadius: "8px",
203
- borderTop: "1px solid #555",
204
- bottom: "0",
205
- display: "flex",
206
- gap: "1rem",
207
- left: "0",
208
- padding: "0.75rem 1rem",
209
- position: "absolute",
210
- right: "0",
211
- zIndex: 1e3
212
- },
213
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
214
- style: {
215
- backgroundColor: "#3a3a3a",
216
- borderRadius: "4px",
217
- color: "#FFF",
218
- fontSize: "0.875rem",
219
- padding: "0.25rem 0.5rem"
220
- },
221
- children: `<${require_src.getDisplayName(currentFiber.type) || "unknown"}>`
222
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
223
- style: {
224
- color: "#CCC",
225
- fontSize: "0.75rem"
226
- },
227
- children: currentFiberSource ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
228
- currentFiberSource.fileName.split("/").slice(-2).join("/"),
229
- " ",
230
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("br", {}),
231
- "@ line ",
232
- currentFiberSource.lineNumber,
233
- ", column",
234
- " ",
235
- currentFiberSource.columnNumber
236
- ] }) : null
237
- })]
238
- })]
239
- }),
240
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("style", { children: `
241
- .inspector-container::-webkit-scrollbar {
242
- width: 8px;
243
- }
244
- .inspector-container::-webkit-scrollbar-track {
245
- background: #1E1E1E;
246
- border-radius: 8px;
247
- }
248
- .inspector-container::-webkit-scrollbar-thumb {
249
- background: #444;
250
- border-radius: 8px;
251
- }
252
- .inspector-container::-webkit-scrollbar-thumb:hover {
253
- background: #555;
254
- }
255
- ` }),
256
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { style: {
257
- border: "1px dashed #505050",
258
- height: rect.height,
259
- left: rect.left,
260
- opacity: rect ? 1 : 0,
261
- pointerEvents: "none",
262
- position: "fixed",
263
- top: rect.top,
264
- transition: "all 150ms",
265
- width: rect.width,
266
- zIndex: 40
267
- } })
268
- ] });
269
- });
270
- const Inspector = (0, react.forwardRef)((props, ref) => {
271
- const [root, setRoot] = (0, react.useState)(null);
272
- (0, react.useEffect)(() => {
273
- const div = document.createElement("div");
274
- document.documentElement.appendChild(div);
275
- const shadowRoot = div.attachShadow({ mode: "open" });
276
- setRoot(shadowRoot);
277
- return () => {
278
- document.documentElement.removeChild(div);
279
- };
280
- }, []);
281
- if (!root) return null;
282
- return react_dom.default.createPortal(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RawInspector, {
283
- ref,
284
- ...props
285
- }), root);
286
- });
287
- var inspect_default = Inspector;
288
-
289
- //#endregion
290
- exports.Inspector = Inspector;
291
- exports.RawInspector = RawInspector;
292
- exports.default = inspect_default;
@@ -1,18 +0,0 @@
1
- import React from "react";
2
-
3
- //#region src/experiments/inspect.d.ts
4
- interface InspectorHandle {
5
- disable: () => void;
6
- enable: () => void;
7
- inspectElement: (element: Element) => void;
8
- }
9
- interface InspectorProps {
10
- children?: React.ReactNode;
11
- dangerouslyRunInProduction?: boolean;
12
- enabled?: boolean;
13
- }
14
- declare const RawInspector: React.ForwardRefExoticComponent<InspectorProps & React.RefAttributes<InspectorHandle>>;
15
- declare const Inspector: React.ForwardRefExoticComponent<InspectorProps & React.RefAttributes<InspectorHandle>>;
16
-
17
- //#endregion
18
- export { Inspector, Inspector as default, InspectorHandle, InspectorProps, RawInspector };
@@ -1,18 +0,0 @@
1
- import React from "react";
2
-
3
- //#region src/experiments/inspect.d.ts
4
- interface InspectorHandle {
5
- disable: () => void;
6
- enable: () => void;
7
- inspectElement: (element: Element) => void;
8
- }
9
- interface InspectorProps {
10
- children?: React.ReactNode;
11
- dangerouslyRunInProduction?: boolean;
12
- enabled?: boolean;
13
- }
14
- declare const RawInspector: React.ForwardRefExoticComponent<InspectorProps & React.RefAttributes<InspectorHandle>>;
15
- declare const Inspector: React.ForwardRefExoticComponent<InspectorProps & React.RefAttributes<InspectorHandle>>;
16
-
17
- //#endregion
18
- export { Inspector, Inspector as default, InspectorHandle, InspectorProps, RawInspector };
@@ -1,289 +0,0 @@
1
- /**
2
- * @license bippy
3
- *
4
- * Copyright (c) Aiden Bai
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE file in the root directory of this source tree.
8
- */
9
- import { getFiberSource } from "../source-D2grjLFe.js";
10
- import { detectReactBuildType, getDisplayName, getFiberFromHostInstance, getLatestFiber, getRDTHook, hasRDTHook, isInstrumentationActive } from "../src-DnJsD_Sy.js";
11
- import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useState } from "react";
12
- import ReactDOM from "react-dom";
13
- import { Inspector as Inspector$1 } from "react-inspector";
14
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
15
-
16
- //#region src/experiments/inspect.tsx
17
- const useImperativeHandlePolyfill = (ref, init, deps) => {
18
- useEffect(() => {
19
- if (ref) {
20
- if (typeof ref === "function") ref(init());
21
- else if (typeof ref === "object" && "current" in ref) ref.current = init();
22
- }
23
- }, deps);
24
- };
25
- const useImperativeHandle$1 = useImperativeHandle || useImperativeHandlePolyfill;
26
- const throttle = (fn, wait) => {
27
- let timeout = null;
28
- return function(...args) {
29
- if (!timeout) timeout = setTimeout(() => {
30
- fn.apply(this, args);
31
- timeout = null;
32
- }, wait);
33
- };
34
- };
35
- const theme = {
36
- ARROW_ANIMATION_DURATION: "0",
37
- ARROW_COLOR: "#A0A0A0",
38
- ARROW_FONT_SIZE: 12,
39
- ARROW_MARGIN_RIGHT: 3,
40
- BASE_BACKGROUND_COLOR: "none",
41
- BASE_COLOR: "#FFF",
42
- BASE_FONT_FAMILY: "Menlo, monospace",
43
- BASE_FONT_SIZE: "12px",
44
- BASE_LINE_HEIGHT: 1.2,
45
- HTML_ATTRIBUTE_NAME_COLOR: "#A0A0A0",
46
- HTML_ATTRIBUTE_VALUE_COLOR: "#99FFE4",
47
- HTML_COMMENT_COLOR: "#8b8b8b94",
48
- HTML_DOCTYPE_COLOR: "#A0A0A0",
49
- HTML_TAG_COLOR: "#FFC799",
50
- HTML_TAGNAME_COLOR: "#FFC799",
51
- HTML_TAGNAME_TEXT_TRANSFORM: "lowercase",
52
- OBJECT_NAME_COLOR: "#FFC799",
53
- OBJECT_PREVIEW_ARRAY_MAX_PROPERTIES: 10,
54
- OBJECT_PREVIEW_OBJECT_MAX_PROPERTIES: 5,
55
- OBJECT_VALUE_BOOLEAN_COLOR: "#FFC799",
56
- OBJECT_VALUE_FUNCTION_PREFIX_COLOR: "#FFC799",
57
- OBJECT_VALUE_NULL_COLOR: "#A0A0A0",
58
- OBJECT_VALUE_NUMBER_COLOR: "#FFC799",
59
- OBJECT_VALUE_REGEXP_COLOR: "#FF8080",
60
- OBJECT_VALUE_STRING_COLOR: "#99FFE4",
61
- OBJECT_VALUE_SYMBOL_COLOR: "#FFC799",
62
- OBJECT_VALUE_UNDEFINED_COLOR: "#A0A0A0",
63
- TABLE_BORDER_COLOR: "#282828",
64
- TABLE_DATA_BACKGROUND_IMAGE: "none",
65
- TABLE_DATA_BACKGROUND_SIZE: "0",
66
- TABLE_SORT_ICON_COLOR: "#A0A0A0",
67
- TABLE_TH_BACKGROUND_COLOR: "#161616",
68
- TABLE_TH_HOVER_COLOR: "#232323",
69
- TREENODE_FONT_FAMILY: "Menlo, monospace",
70
- TREENODE_FONT_SIZE: "11px",
71
- TREENODE_LINE_HEIGHT: 1.2,
72
- TREENODE_PADDING_LEFT: 12
73
- };
74
- const RawInspector = forwardRef(({ dangerouslyRunInProduction = false, enabled = true }, ref) => {
75
- const [element, setElement] = useState(null);
76
- const [currentFiber, setCurrentFiber] = useState(null);
77
- const [currentFiberSource, setCurrentFiberSource] = useState(null);
78
- const [rect, setRect] = useState(null);
79
- const [isActive, setIsActive] = useState(true);
80
- const [isEnabled, setIsEnabled] = useState(enabled);
81
- const [position, setPosition] = useState({
82
- left: 0,
83
- top: 0
84
- });
85
- const currentCleanedFiber = useMemo(() => {
86
- if (!currentFiber) return null;
87
- const clonedFiber = { ...currentFiber };
88
- for (const key in clonedFiber) {
89
- const value = clonedFiber[key];
90
- if (!value) delete clonedFiber[key];
91
- }
92
- return clonedFiber;
93
- }, [currentFiber]);
94
- useImperativeHandle$1(ref, () => ({
95
- disable: () => {
96
- setIsEnabled(false);
97
- setElement(null);
98
- setRect(null);
99
- },
100
- enable: () => setIsEnabled(true),
101
- inspectElement: (element$1) => {
102
- if (!isEnabled) return;
103
- setElement(element$1);
104
- setRect(element$1.getBoundingClientRect());
105
- }
106
- }));
107
- useEffect(() => {
108
- (async () => {
109
- if (!element) return;
110
- const fiber = getFiberFromHostInstance(element);
111
- if (!fiber) return;
112
- const latestFiber = getLatestFiber(fiber);
113
- const source = await getFiberSource(latestFiber);
114
- setCurrentFiber(latestFiber);
115
- if (source) setCurrentFiberSource(source);
116
- })();
117
- }, [element]);
118
- useEffect(() => {
119
- const handleMouseMove = (event) => {
120
- const isActive$1 = isInstrumentationActive() || hasRDTHook();
121
- if (!isActive$1) {
122
- setIsActive(false);
123
- return;
124
- }
125
- if (!dangerouslyRunInProduction) {
126
- const rdtHook = getRDTHook();
127
- for (const renderer of rdtHook.renderers.values()) {
128
- const buildType = detectReactBuildType(renderer);
129
- if (buildType === "production") {
130
- setIsActive(false);
131
- return;
132
- }
133
- }
134
- }
135
- if (!isEnabled) {
136
- setElement(null);
137
- setRect(null);
138
- return;
139
- }
140
- const element$1 = document.elementFromPoint(event.clientX, event.clientY);
141
- if (!element$1) return;
142
- setElement(element$1);
143
- setRect(element$1.getBoundingClientRect());
144
- };
145
- const throttledMouseMove = throttle(handleMouseMove, 16);
146
- document.addEventListener("mousemove", throttledMouseMove);
147
- return () => document.removeEventListener("mousemove", throttledMouseMove);
148
- }, [isEnabled, dangerouslyRunInProduction]);
149
- useEffect(() => {
150
- if (!rect) return;
151
- const padding = 10;
152
- const inspectorWidth = 400;
153
- const inspectorHeight = 320;
154
- let left = rect.left + rect.width + padding;
155
- let top = rect.top;
156
- if (left + inspectorWidth > window.innerWidth) left = Math.max(padding, rect.left - inspectorWidth - padding);
157
- if (top >= rect.top && top <= rect.bottom) if (rect.bottom + inspectorHeight + padding <= window.innerHeight) top = rect.bottom + padding;
158
- else if (rect.top - inspectorHeight - padding >= 0) top = rect.top - inspectorHeight - padding;
159
- else top = window.innerHeight - inspectorHeight - padding;
160
- top = Math.max(padding, Math.min(top, window.innerHeight - inspectorHeight - padding));
161
- left = Math.max(padding, Math.min(left, window.innerWidth - inspectorWidth - padding));
162
- setPosition({
163
- left,
164
- top
165
- });
166
- }, [rect]);
167
- if (!rect || !isActive || !isEnabled) return null;
168
- if (!currentFiber) return null;
169
- return /* @__PURE__ */ jsxs(Fragment, { children: [
170
- /* @__PURE__ */ jsxs("div", {
171
- className: "inspector-container",
172
- style: {
173
- backgroundColor: "#101010",
174
- border: "1px solid #444",
175
- borderRadius: "8px",
176
- boxShadow: "0 4px 8px rgba(0, 0, 0, 0.5)",
177
- color: "#FFF",
178
- height: "25ch",
179
- left: position.left,
180
- opacity: rect ? 1 : 0,
181
- overflow: "auto",
182
- padding: "1rem",
183
- pointerEvents: rect ? "auto" : "none",
184
- position: "fixed",
185
- top: position.top,
186
- transform: rect ? "translateY(0)" : "translateY(10px)",
187
- transition: "all 150ms ease-in-out",
188
- width: "30ch",
189
- zIndex: 50
190
- },
191
- children: [currentFiber && /* @__PURE__ */ jsx(Inspector$1, {
192
- data: currentCleanedFiber,
193
- expandLevel: 1,
194
- table: false,
195
- theme
196
- }), /* @__PURE__ */ jsxs("div", {
197
- style: {
198
- alignItems: "center",
199
- backgroundColor: "#101010",
200
- borderBottomLeftRadius: "8px",
201
- borderBottomRightRadius: "8px",
202
- borderTop: "1px solid #555",
203
- bottom: "0",
204
- display: "flex",
205
- gap: "1rem",
206
- left: "0",
207
- padding: "0.75rem 1rem",
208
- position: "absolute",
209
- right: "0",
210
- zIndex: 1e3
211
- },
212
- children: [/* @__PURE__ */ jsx("div", {
213
- style: {
214
- backgroundColor: "#3a3a3a",
215
- borderRadius: "4px",
216
- color: "#FFF",
217
- fontSize: "0.875rem",
218
- padding: "0.25rem 0.5rem"
219
- },
220
- children: `<${getDisplayName(currentFiber.type) || "unknown"}>`
221
- }), /* @__PURE__ */ jsx("div", {
222
- style: {
223
- color: "#CCC",
224
- fontSize: "0.75rem"
225
- },
226
- children: currentFiberSource ? /* @__PURE__ */ jsxs(Fragment, { children: [
227
- currentFiberSource.fileName.split("/").slice(-2).join("/"),
228
- " ",
229
- /* @__PURE__ */ jsx("br", {}),
230
- "@ line ",
231
- currentFiberSource.lineNumber,
232
- ", column",
233
- " ",
234
- currentFiberSource.columnNumber
235
- ] }) : null
236
- })]
237
- })]
238
- }),
239
- /* @__PURE__ */ jsx("style", { children: `
240
- .inspector-container::-webkit-scrollbar {
241
- width: 8px;
242
- }
243
- .inspector-container::-webkit-scrollbar-track {
244
- background: #1E1E1E;
245
- border-radius: 8px;
246
- }
247
- .inspector-container::-webkit-scrollbar-thumb {
248
- background: #444;
249
- border-radius: 8px;
250
- }
251
- .inspector-container::-webkit-scrollbar-thumb:hover {
252
- background: #555;
253
- }
254
- ` }),
255
- /* @__PURE__ */ jsx("div", { style: {
256
- border: "1px dashed #505050",
257
- height: rect.height,
258
- left: rect.left,
259
- opacity: rect ? 1 : 0,
260
- pointerEvents: "none",
261
- position: "fixed",
262
- top: rect.top,
263
- transition: "all 150ms",
264
- width: rect.width,
265
- zIndex: 40
266
- } })
267
- ] });
268
- });
269
- const Inspector = forwardRef((props, ref) => {
270
- const [root, setRoot] = useState(null);
271
- useEffect(() => {
272
- const div = document.createElement("div");
273
- document.documentElement.appendChild(div);
274
- const shadowRoot = div.attachShadow({ mode: "open" });
275
- setRoot(shadowRoot);
276
- return () => {
277
- document.documentElement.removeChild(div);
278
- };
279
- }, []);
280
- if (!root) return null;
281
- return ReactDOM.createPortal(/* @__PURE__ */ jsx(RawInspector, {
282
- ref,
283
- ...props
284
- }), root);
285
- });
286
- var inspect_default = Inspector;
287
-
288
- //#endregion
289
- export { Inspector, RawInspector, inspect_default as default };