@bbearai/react 0.1.1 → 0.1.3
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/dist/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +37 -27
- package/dist/index.mjs +43 -33
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -16,13 +16,21 @@ interface BugBearContextValue {
|
|
|
16
16
|
isLoading: boolean;
|
|
17
17
|
/** Navigate to a route/screen (for deep linking from test cases) */
|
|
18
18
|
onNavigate?: (route: string) => void;
|
|
19
|
+
/** Re-check tester status (call after auth state changes) */
|
|
20
|
+
refreshTesterStatus: () => Promise<void>;
|
|
19
21
|
}
|
|
20
22
|
declare function useBugBear(): BugBearContextValue;
|
|
21
23
|
interface BugBearProviderProps {
|
|
22
24
|
config: BugBearConfig;
|
|
23
25
|
children: ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* Set to false to delay initialization until auth is ready.
|
|
28
|
+
* When enabled changes from false to true, BugBear will initialize.
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
enabled?: boolean;
|
|
24
32
|
}
|
|
25
|
-
declare function BugBearProvider({ config, children }: BugBearProviderProps): react_jsx_runtime.JSX.Element;
|
|
33
|
+
declare function BugBearProvider({ config, children, enabled }: BugBearProviderProps): react_jsx_runtime.JSX.Element;
|
|
26
34
|
|
|
27
35
|
interface BugBearPanelProps {
|
|
28
36
|
/** Get current app context */
|
package/dist/index.d.ts
CHANGED
|
@@ -16,13 +16,21 @@ interface BugBearContextValue {
|
|
|
16
16
|
isLoading: boolean;
|
|
17
17
|
/** Navigate to a route/screen (for deep linking from test cases) */
|
|
18
18
|
onNavigate?: (route: string) => void;
|
|
19
|
+
/** Re-check tester status (call after auth state changes) */
|
|
20
|
+
refreshTesterStatus: () => Promise<void>;
|
|
19
21
|
}
|
|
20
22
|
declare function useBugBear(): BugBearContextValue;
|
|
21
23
|
interface BugBearProviderProps {
|
|
22
24
|
config: BugBearConfig;
|
|
23
25
|
children: ReactNode;
|
|
26
|
+
/**
|
|
27
|
+
* Set to false to delay initialization until auth is ready.
|
|
28
|
+
* When enabled changes from false to true, BugBear will initialize.
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
enabled?: boolean;
|
|
24
32
|
}
|
|
25
|
-
declare function BugBearProvider({ config, children }: BugBearProviderProps): react_jsx_runtime.JSX.Element;
|
|
33
|
+
declare function BugBearProvider({ config, children, enabled }: BugBearProviderProps): react_jsx_runtime.JSX.Element;
|
|
26
34
|
|
|
27
35
|
interface BugBearPanelProps {
|
|
28
36
|
/** Get current app context */
|
package/dist/index.js
CHANGED
|
@@ -45,45 +45,54 @@ var BugBearContext = (0, import_react.createContext)({
|
|
|
45
45
|
refreshAssignments: async () => {
|
|
46
46
|
},
|
|
47
47
|
isLoading: true,
|
|
48
|
-
onNavigate: void 0
|
|
48
|
+
onNavigate: void 0,
|
|
49
|
+
refreshTesterStatus: async () => {
|
|
50
|
+
}
|
|
49
51
|
});
|
|
50
52
|
function useBugBear() {
|
|
51
53
|
return (0, import_react.useContext)(BugBearContext);
|
|
52
54
|
}
|
|
53
|
-
function BugBearProvider({ config, children }) {
|
|
55
|
+
function BugBearProvider({ config, children, enabled = true }) {
|
|
54
56
|
const [client] = (0, import_react.useState)(() => (0, import_core.createBugBear)(config));
|
|
55
57
|
const [isTester, setIsTester] = (0, import_react.useState)(false);
|
|
56
58
|
const [isQAEnabled, setIsQAEnabled] = (0, import_react.useState)(false);
|
|
57
59
|
const [testerInfo, setTesterInfo] = (0, import_react.useState)(null);
|
|
58
60
|
const [assignments, setAssignments] = (0, import_react.useState)([]);
|
|
59
61
|
const [isLoading, setIsLoading] = (0, import_react.useState)(true);
|
|
60
|
-
const
|
|
62
|
+
const hasInitialized = (0, import_react.useRef)(false);
|
|
63
|
+
const refreshAssignments = (0, import_react.useCallback)(async () => {
|
|
61
64
|
const newAssignments = await client.getAssignedTests();
|
|
62
65
|
setAssignments(newAssignments);
|
|
63
|
-
};
|
|
64
|
-
(0, import_react.useEffect)(() => {
|
|
65
|
-
const init = async () => {
|
|
66
|
-
setIsLoading(true);
|
|
67
|
-
try {
|
|
68
|
-
const [qaEnabled, info] = await Promise.all([
|
|
69
|
-
client.isQAEnabled(),
|
|
70
|
-
client.getTesterInfo()
|
|
71
|
-
]);
|
|
72
|
-
console.log("BugBear: Init complete", { qaEnabled, testerInfo: info });
|
|
73
|
-
setIsQAEnabled(qaEnabled);
|
|
74
|
-
setTesterInfo(info);
|
|
75
|
-
setIsTester(!!info);
|
|
76
|
-
if (info && qaEnabled) {
|
|
77
|
-
await refreshAssignments();
|
|
78
|
-
}
|
|
79
|
-
} catch (err) {
|
|
80
|
-
console.error("BugBear: Init error", err);
|
|
81
|
-
} finally {
|
|
82
|
-
setIsLoading(false);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
init();
|
|
86
66
|
}, [client]);
|
|
67
|
+
const initializeBugBear = (0, import_react.useCallback)(async () => {
|
|
68
|
+
setIsLoading(true);
|
|
69
|
+
try {
|
|
70
|
+
const [qaEnabled, info] = await Promise.all([
|
|
71
|
+
client.isQAEnabled(),
|
|
72
|
+
client.getTesterInfo()
|
|
73
|
+
]);
|
|
74
|
+
console.log("BugBear: Init complete", { qaEnabled, testerInfo: info });
|
|
75
|
+
setIsQAEnabled(qaEnabled);
|
|
76
|
+
setTesterInfo(info);
|
|
77
|
+
setIsTester(!!info);
|
|
78
|
+
if (info && qaEnabled) {
|
|
79
|
+
await refreshAssignments();
|
|
80
|
+
}
|
|
81
|
+
} catch (err) {
|
|
82
|
+
console.error("BugBear: Init error", err);
|
|
83
|
+
} finally {
|
|
84
|
+
setIsLoading(false);
|
|
85
|
+
}
|
|
86
|
+
}, [client, refreshAssignments]);
|
|
87
|
+
const refreshTesterStatus = (0, import_react.useCallback)(async () => {
|
|
88
|
+
await initializeBugBear();
|
|
89
|
+
}, [initializeBugBear]);
|
|
90
|
+
(0, import_react.useEffect)(() => {
|
|
91
|
+
if (enabled && !hasInitialized.current) {
|
|
92
|
+
hasInitialized.current = true;
|
|
93
|
+
initializeBugBear();
|
|
94
|
+
}
|
|
95
|
+
}, [enabled, initializeBugBear]);
|
|
87
96
|
const currentAssignment = assignments.find(
|
|
88
97
|
(a) => a.status === "in_progress"
|
|
89
98
|
) || assignments[0] || null;
|
|
@@ -101,7 +110,8 @@ function BugBearProvider({ config, children }) {
|
|
|
101
110
|
currentAssignment,
|
|
102
111
|
refreshAssignments,
|
|
103
112
|
isLoading,
|
|
104
|
-
onNavigate: config.onNavigate
|
|
113
|
+
onNavigate: config.onNavigate,
|
|
114
|
+
refreshTesterStatus
|
|
105
115
|
},
|
|
106
116
|
children
|
|
107
117
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/BugBearProvider.tsx
|
|
2
|
-
import { createContext, useContext, useEffect, useState } from "react";
|
|
2
|
+
import { createContext, useContext, useEffect, useState, useCallback, useRef } from "react";
|
|
3
3
|
import {
|
|
4
4
|
createBugBear
|
|
5
5
|
} from "@bbearai/core";
|
|
@@ -15,45 +15,54 @@ var BugBearContext = createContext({
|
|
|
15
15
|
refreshAssignments: async () => {
|
|
16
16
|
},
|
|
17
17
|
isLoading: true,
|
|
18
|
-
onNavigate: void 0
|
|
18
|
+
onNavigate: void 0,
|
|
19
|
+
refreshTesterStatus: async () => {
|
|
20
|
+
}
|
|
19
21
|
});
|
|
20
22
|
function useBugBear() {
|
|
21
23
|
return useContext(BugBearContext);
|
|
22
24
|
}
|
|
23
|
-
function BugBearProvider({ config, children }) {
|
|
25
|
+
function BugBearProvider({ config, children, enabled = true }) {
|
|
24
26
|
const [client] = useState(() => createBugBear(config));
|
|
25
27
|
const [isTester, setIsTester] = useState(false);
|
|
26
28
|
const [isQAEnabled, setIsQAEnabled] = useState(false);
|
|
27
29
|
const [testerInfo, setTesterInfo] = useState(null);
|
|
28
30
|
const [assignments, setAssignments] = useState([]);
|
|
29
31
|
const [isLoading, setIsLoading] = useState(true);
|
|
30
|
-
const
|
|
32
|
+
const hasInitialized = useRef(false);
|
|
33
|
+
const refreshAssignments = useCallback(async () => {
|
|
31
34
|
const newAssignments = await client.getAssignedTests();
|
|
32
35
|
setAssignments(newAssignments);
|
|
33
|
-
};
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
const init = async () => {
|
|
36
|
-
setIsLoading(true);
|
|
37
|
-
try {
|
|
38
|
-
const [qaEnabled, info] = await Promise.all([
|
|
39
|
-
client.isQAEnabled(),
|
|
40
|
-
client.getTesterInfo()
|
|
41
|
-
]);
|
|
42
|
-
console.log("BugBear: Init complete", { qaEnabled, testerInfo: info });
|
|
43
|
-
setIsQAEnabled(qaEnabled);
|
|
44
|
-
setTesterInfo(info);
|
|
45
|
-
setIsTester(!!info);
|
|
46
|
-
if (info && qaEnabled) {
|
|
47
|
-
await refreshAssignments();
|
|
48
|
-
}
|
|
49
|
-
} catch (err) {
|
|
50
|
-
console.error("BugBear: Init error", err);
|
|
51
|
-
} finally {
|
|
52
|
-
setIsLoading(false);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
init();
|
|
56
36
|
}, [client]);
|
|
37
|
+
const initializeBugBear = useCallback(async () => {
|
|
38
|
+
setIsLoading(true);
|
|
39
|
+
try {
|
|
40
|
+
const [qaEnabled, info] = await Promise.all([
|
|
41
|
+
client.isQAEnabled(),
|
|
42
|
+
client.getTesterInfo()
|
|
43
|
+
]);
|
|
44
|
+
console.log("BugBear: Init complete", { qaEnabled, testerInfo: info });
|
|
45
|
+
setIsQAEnabled(qaEnabled);
|
|
46
|
+
setTesterInfo(info);
|
|
47
|
+
setIsTester(!!info);
|
|
48
|
+
if (info && qaEnabled) {
|
|
49
|
+
await refreshAssignments();
|
|
50
|
+
}
|
|
51
|
+
} catch (err) {
|
|
52
|
+
console.error("BugBear: Init error", err);
|
|
53
|
+
} finally {
|
|
54
|
+
setIsLoading(false);
|
|
55
|
+
}
|
|
56
|
+
}, [client, refreshAssignments]);
|
|
57
|
+
const refreshTesterStatus = useCallback(async () => {
|
|
58
|
+
await initializeBugBear();
|
|
59
|
+
}, [initializeBugBear]);
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (enabled && !hasInitialized.current) {
|
|
62
|
+
hasInitialized.current = true;
|
|
63
|
+
initializeBugBear();
|
|
64
|
+
}
|
|
65
|
+
}, [enabled, initializeBugBear]);
|
|
57
66
|
const currentAssignment = assignments.find(
|
|
58
67
|
(a) => a.status === "in_progress"
|
|
59
68
|
) || assignments[0] || null;
|
|
@@ -71,7 +80,8 @@ function BugBearProvider({ config, children }) {
|
|
|
71
80
|
currentAssignment,
|
|
72
81
|
refreshAssignments,
|
|
73
82
|
isLoading,
|
|
74
|
-
onNavigate: config.onNavigate
|
|
83
|
+
onNavigate: config.onNavigate,
|
|
84
|
+
refreshTesterStatus
|
|
75
85
|
},
|
|
76
86
|
children
|
|
77
87
|
}
|
|
@@ -79,7 +89,7 @@ function BugBearProvider({ config, children }) {
|
|
|
79
89
|
}
|
|
80
90
|
|
|
81
91
|
// src/BugBearPanel.tsx
|
|
82
|
-
import { useState as useState2, useRef, useEffect as useEffect2, useCallback } from "react";
|
|
92
|
+
import { useState as useState2, useRef as useRef2, useEffect as useEffect2, useCallback as useCallback2 } from "react";
|
|
83
93
|
import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
84
94
|
function BugBearIcon({ size = 24, className = "" }) {
|
|
85
95
|
return /* @__PURE__ */ jsxs(
|
|
@@ -159,8 +169,8 @@ function BugBearPanel({
|
|
|
159
169
|
const displayedAssignment = selectedTestId ? assignments.find((a) => a.id === selectedTestId) || currentAssignment : currentAssignment;
|
|
160
170
|
const [panelPosition, setPanelPosition] = useState2(null);
|
|
161
171
|
const [isDragging, setIsDragging] = useState2(false);
|
|
162
|
-
const dragStartRef =
|
|
163
|
-
const panelRef =
|
|
172
|
+
const dragStartRef = useRef2(null);
|
|
173
|
+
const panelRef = useRef2(null);
|
|
164
174
|
const [reportType, setReportType] = useState2("bug");
|
|
165
175
|
const [description, setDescription] = useState2("");
|
|
166
176
|
const [severity, setSeverity] = useState2("medium");
|
|
@@ -202,7 +212,7 @@ function BugBearPanel({
|
|
|
202
212
|
setCriteriaResults({});
|
|
203
213
|
setShowSteps(false);
|
|
204
214
|
}, [displayedAssignment?.id]);
|
|
205
|
-
const handleMouseDown =
|
|
215
|
+
const handleMouseDown = useCallback2((e) => {
|
|
206
216
|
if (!draggable || !panelPosition) return;
|
|
207
217
|
const target = e.target;
|
|
208
218
|
if (!target.closest("[data-drag-handle]")) return;
|
|
@@ -237,7 +247,7 @@ function BugBearPanel({
|
|
|
237
247
|
document.removeEventListener("mouseup", handleMouseUp);
|
|
238
248
|
};
|
|
239
249
|
}, [isDragging]);
|
|
240
|
-
const handleDoubleClick =
|
|
250
|
+
const handleDoubleClick = useCallback2(() => {
|
|
241
251
|
if (!draggable) return;
|
|
242
252
|
setPanelPosition(getDefaultPosition(position));
|
|
243
253
|
try {
|