@foxglove/embed-react 0.67.0 → 0.69.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/dist/FoxgloveViewer.d.ts +5 -1
- package/dist/FoxgloveViewer.d.ts.map +1 -1
- package/dist/FoxgloveViewer.js +13 -1
- package/dist/FoxgloveViewer.js.map +1 -1
- package/dist/useShouldNotChangeOften.d.ts.map +1 -1
- package/dist/useShouldNotChangeOften.js +8 -1
- package/dist/useShouldNotChangeOften.js.map +1 -1
- package/package.json +2 -2
- package/src/FoxgloveViewer.tsx +23 -1
- package/src/useShouldNotChangeOften.ts +6 -0
package/dist/FoxgloveViewer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DataSource, type Keybinding, type OpaqueLayoutData, type SelectLayoutParams, type Time } from "@foxglove/embed";
|
|
1
|
+
import { type DataSource, type FoxgloveViewerCapabilities, type Keybinding, type OpaqueLayoutData, type SelectLayoutParams, type Time } from "@foxglove/embed";
|
|
2
2
|
type Props = {
|
|
3
3
|
/** The URL where the Foxglove app is hosted. Defaults to `https://embed.foxglove.dev/`. */
|
|
4
4
|
src?: string;
|
|
@@ -74,8 +74,12 @@ type Props = {
|
|
|
74
74
|
* update the data source, layout, or extensions.
|
|
75
75
|
* */
|
|
76
76
|
onError?: (errorMsg: string) => void;
|
|
77
|
+
/** Called when the iframe resolves its host-visible feature availability. */
|
|
78
|
+
onCapabilities?: (capabilities: FoxgloveViewerCapabilities) => void;
|
|
77
79
|
};
|
|
78
80
|
export interface FoxgloveViewerInterface {
|
|
81
|
+
/** Features the current iframe makes available to this embedding host. */
|
|
82
|
+
getCapabilities(): FoxgloveViewerCapabilities;
|
|
79
83
|
/**
|
|
80
84
|
* Retrieve the currently configured layout from the embedded viewer.
|
|
81
85
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FoxgloveViewer.d.ts","sourceRoot":"","sources":["../src/FoxgloveViewer.t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AG,IAAI,CAAC;CACtC;AAED;;;;;GAKG;AACH,eAAO,MAAM,cAAc,2GAkL1B,CAAC"}
|
package/dist/FoxgloveViewer.js
CHANGED
|
@@ -16,6 +16,7 @@ export const FoxgloveViewer = forwardRef(function FoxgloveViewer(props, ref) {
|
|
|
16
16
|
// Store the callbacks in refs to avoid re-rendering the component when the callbacks change.
|
|
17
17
|
const onReady = useRef(props.onReady ?? undefined);
|
|
18
18
|
const onError = useRef(props.onError ?? undefined);
|
|
19
|
+
const onCapabilities = useRef(props.onCapabilities ?? undefined);
|
|
19
20
|
useShouldNotChangeOften(data, () => {
|
|
20
21
|
console.warn(`[FoxgloveViewer] "data" is changing too frequently. This may cause performance issues, consider memoizing this value.`);
|
|
21
22
|
});
|
|
@@ -31,13 +32,16 @@ export const FoxgloveViewer = forwardRef(function FoxgloveViewer(props, ref) {
|
|
|
31
32
|
useShouldNotChangeOften(keybindings, () => {
|
|
32
33
|
console.warn(`[FoxgloveViewer] "keybindings" is changing too frequently. This may cause performance issues, consider memoizing this value.`);
|
|
33
34
|
});
|
|
34
|
-
// Update
|
|
35
|
+
// Update callback refs when the props change.
|
|
35
36
|
useEffect(() => {
|
|
36
37
|
onReady.current = props.onReady;
|
|
37
38
|
}, [props.onReady]);
|
|
38
39
|
useEffect(() => {
|
|
39
40
|
onError.current = props.onError;
|
|
40
41
|
}, [props.onError]);
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
onCapabilities.current = props.onCapabilities;
|
|
44
|
+
}, [props.onCapabilities]);
|
|
41
45
|
useEffect(() => {
|
|
42
46
|
if (!elem.current) {
|
|
43
47
|
return;
|
|
@@ -48,6 +52,9 @@ export const FoxgloveViewer = forwardRef(function FoxgloveViewer(props, ref) {
|
|
|
48
52
|
const handleError = (errorMsg) => {
|
|
49
53
|
onError.current?.(errorMsg.detail);
|
|
50
54
|
};
|
|
55
|
+
const handleCapabilities = (event) => {
|
|
56
|
+
onCapabilities.current?.(event.detail);
|
|
57
|
+
};
|
|
51
58
|
frame.current = new FoxgloveViewerClass({
|
|
52
59
|
parent: elem.current,
|
|
53
60
|
src,
|
|
@@ -56,9 +63,11 @@ export const FoxgloveViewer = forwardRef(function FoxgloveViewer(props, ref) {
|
|
|
56
63
|
});
|
|
57
64
|
frame.current.addEventListener("ready", handleReady);
|
|
58
65
|
frame.current.addEventListener("error", handleError);
|
|
66
|
+
frame.current.addEventListener("capabilities", handleCapabilities);
|
|
59
67
|
return () => {
|
|
60
68
|
frame.current?.removeEventListener("ready", handleReady);
|
|
61
69
|
frame.current?.removeEventListener("error", handleError);
|
|
70
|
+
frame.current?.removeEventListener("capabilities", handleCapabilities);
|
|
62
71
|
frame.current?.destroy();
|
|
63
72
|
};
|
|
64
73
|
}, [src, orgSlug]);
|
|
@@ -100,6 +109,9 @@ export const FoxgloveViewer = forwardRef(function FoxgloveViewer(props, ref) {
|
|
|
100
109
|
frame.current.setKeybindings(keybindings ?? []);
|
|
101
110
|
}, [keybindings]);
|
|
102
111
|
useImperativeHandle(ref, () => ({
|
|
112
|
+
getCapabilities() {
|
|
113
|
+
return (frame.current?.getCapabilities() ?? { parentOwnedLiveTransport: "pending" });
|
|
114
|
+
},
|
|
103
115
|
async getLayout() {
|
|
104
116
|
return await frame.current?.getLayout();
|
|
105
117
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FoxgloveViewer.js","sourceRoot":"","sources":["../src/FoxgloveViewer.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE3E,OAAO,EAEL,cAAc,IAAI,mBAAmB,
|
|
1
|
+
{"version":3,"file":"FoxgloveViewer.js","sourceRoot":"","sources":["../src/FoxgloveViewer.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE3E,OAAO,EAEL,cAAc,IA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AAE,aAAa,EAAE,CAAC;QACjC,CAAC;QACD,SAAS,CAAC,IAAmB;YAC3B,KAAK,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;KACF,CAAC,EACF,EAAE,CACH,CAAC;IAEF,OAAO,cAAK,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,GAAI,CAAC;AAChE,CAAC,CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useShouldNotChangeOften.d.ts","sourceRoot":"","sources":["../src/useShouldNotChangeOften.ts"],"names":[],"mappings":"AAKA,+DAA+D;AAC/D,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"useShouldNotChangeOften.d.ts","sourceRoot":"","sources":["../src/useShouldNotChangeOften.ts"],"names":[],"mappings":"AAKA,+DAA+D;AAC/D,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,IAAI,GAAG,CAAC,CAqBxE"}
|
|
@@ -6,13 +6,20 @@ export function useShouldNotChangeOften(value, warn) {
|
|
|
6
6
|
const prev = useRef(value);
|
|
7
7
|
const prevPrev = useRef(value);
|
|
8
8
|
const lastTime = useRef(Date.now());
|
|
9
|
-
if (
|
|
9
|
+
if (
|
|
10
|
+
// eslint-disable-next-line react-hooks/refs -- Pre-existing violation, not yet migrated.
|
|
11
|
+
value !== prev.current &&
|
|
12
|
+
// eslint-disable-next-line react-hooks/refs -- Pre-existing violation, not yet migrated.
|
|
10
13
|
prev.current !== prevPrev.current &&
|
|
14
|
+
// eslint-disable-next-line react-hooks/refs -- Pre-existing violation, not yet migrated.
|
|
11
15
|
Date.now() - lastTime.current < 200) {
|
|
12
16
|
warn();
|
|
13
17
|
}
|
|
18
|
+
// eslint-disable-next-line react-hooks/refs -- Pre-existing violation, not yet migrated.
|
|
14
19
|
prevPrev.current = prev.current;
|
|
20
|
+
// eslint-disable-next-line react-hooks/refs -- Pre-existing violation, not yet migrated.
|
|
15
21
|
prev.current = value;
|
|
22
|
+
// eslint-disable-next-line react-hooks/refs -- Pre-existing violation, not yet migrated.
|
|
16
23
|
lastTime.current = Date.now();
|
|
17
24
|
return value;
|
|
18
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useShouldNotChangeOften.js","sourceRoot":"","sources":["../src/useShouldNotChangeOften.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,0DAA0D;AAE1D,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,+DAA+D;AAC/D,MAAM,UAAU,uBAAuB,CAAI,KAAQ,EAAE,IAAgB;IACnE,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,QAAQ,GAAG,MAAM,CAAS,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAC5C
|
|
1
|
+
{"version":3,"file":"useShouldNotChangeOften.js","sourceRoot":"","sources":["../src/useShouldNotChangeOften.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,0DAA0D;AAE1D,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,+DAA+D;AAC/D,MAAM,UAAU,uBAAuB,CAAI,KAAQ,EAAE,IAAgB;IACnE,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3B,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,QAAQ,GAAG,MAAM,CAAS,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IAC5C;IACE,yFAAyF;IACzF,KAAK,KAAK,IAAI,CAAC,OAAO;QACtB,yFAAyF;QACzF,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,OAAO;QACjC,yFAAyF;QACzF,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC,OAAO,GAAG,GAAG,EACnC,CAAC;QACD,IAAI,EAAE,CAAC;IACT,CAAC;IACD,yFAAyF;IACzF,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;IAChC,yFAAyF;IACzF,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;IACrB,yFAAyF;IACzF,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC9B,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@foxglove/embed-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.69.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"foxglove",
|
|
6
6
|
"react",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"prepack": "yarn build"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@foxglove/embed": "0.
|
|
34
|
+
"@foxglove/embed": "0.69.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/react": "19.2.18",
|
package/src/FoxgloveViewer.tsx
CHANGED
|
@@ -4,6 +4,7 @@ import { forwardRef, useEffect, useImperativeHandle, useRef } from "react";
|
|
|
4
4
|
import {
|
|
5
5
|
type DataSource,
|
|
6
6
|
FoxgloveViewer as FoxgloveViewerClass,
|
|
7
|
+
type FoxgloveViewerCapabilities,
|
|
7
8
|
type Keybinding,
|
|
8
9
|
type OpaqueLayoutData,
|
|
9
10
|
type SelectLayoutParams,
|
|
@@ -87,9 +88,14 @@ type Props = {
|
|
|
87
88
|
* update the data source, layout, or extensions.
|
|
88
89
|
* */
|
|
89
90
|
onError?: (errorMsg: string) => void;
|
|
91
|
+
/** Called when the iframe resolves its host-visible feature availability. */
|
|
92
|
+
onCapabilities?: (capabilities: FoxgloveViewerCapabilities) => void;
|
|
90
93
|
};
|
|
91
94
|
|
|
92
95
|
export interface FoxgloveViewerInterface {
|
|
96
|
+
/** Features the current iframe makes available to this embedding host. */
|
|
97
|
+
getCapabilities(): FoxgloveViewerCapabilities;
|
|
98
|
+
|
|
93
99
|
/**
|
|
94
100
|
* Retrieve the currently configured layout from the embedded viewer.
|
|
95
101
|
*
|
|
@@ -175,6 +181,9 @@ export const FoxgloveViewer = forwardRef<FoxgloveViewerInterface, Props>(
|
|
|
175
181
|
// Store the callbacks in refs to avoid re-rendering the component when the callbacks change.
|
|
176
182
|
const onReady = useRef<(() => void) | undefined>(props.onReady ?? undefined);
|
|
177
183
|
const onError = useRef<((errorMsg: string) => void) | undefined>(props.onError ?? undefined);
|
|
184
|
+
const onCapabilities = useRef<((capabilities: FoxgloveViewerCapabilities) => void) | undefined>(
|
|
185
|
+
props.onCapabilities ?? undefined,
|
|
186
|
+
);
|
|
178
187
|
|
|
179
188
|
useShouldNotChangeOften(data, () => {
|
|
180
189
|
console.warn(
|
|
@@ -206,13 +215,16 @@ export const FoxgloveViewer = forwardRef<FoxgloveViewerInterface, Props>(
|
|
|
206
215
|
);
|
|
207
216
|
});
|
|
208
217
|
|
|
209
|
-
// Update
|
|
218
|
+
// Update callback refs when the props change.
|
|
210
219
|
useEffect(() => {
|
|
211
220
|
onReady.current = props.onReady;
|
|
212
221
|
}, [props.onReady]);
|
|
213
222
|
useEffect(() => {
|
|
214
223
|
onError.current = props.onError;
|
|
215
224
|
}, [props.onError]);
|
|
225
|
+
useEffect(() => {
|
|
226
|
+
onCapabilities.current = props.onCapabilities;
|
|
227
|
+
}, [props.onCapabilities]);
|
|
216
228
|
|
|
217
229
|
useEffect(() => {
|
|
218
230
|
if (!elem.current) {
|
|
@@ -225,6 +237,9 @@ export const FoxgloveViewer = forwardRef<FoxgloveViewerInterface, Props>(
|
|
|
225
237
|
const handleError = (errorMsg: CustomEvent<string>) => {
|
|
226
238
|
onError.current?.(errorMsg.detail);
|
|
227
239
|
};
|
|
240
|
+
const handleCapabilities = (event: CustomEvent<FoxgloveViewerCapabilities>) => {
|
|
241
|
+
onCapabilities.current?.(event.detail);
|
|
242
|
+
};
|
|
228
243
|
|
|
229
244
|
frame.current = new FoxgloveViewerClass({
|
|
230
245
|
parent: elem.current,
|
|
@@ -234,10 +249,12 @@ export const FoxgloveViewer = forwardRef<FoxgloveViewerInterface, Props>(
|
|
|
234
249
|
});
|
|
235
250
|
frame.current.addEventListener("ready", handleReady);
|
|
236
251
|
frame.current.addEventListener("error", handleError);
|
|
252
|
+
frame.current.addEventListener("capabilities", handleCapabilities);
|
|
237
253
|
|
|
238
254
|
return () => {
|
|
239
255
|
frame.current?.removeEventListener("ready", handleReady);
|
|
240
256
|
frame.current?.removeEventListener("error", handleError);
|
|
257
|
+
frame.current?.removeEventListener("capabilities", handleCapabilities);
|
|
241
258
|
frame.current?.destroy();
|
|
242
259
|
};
|
|
243
260
|
}, [src, orgSlug]);
|
|
@@ -294,6 +311,11 @@ export const FoxgloveViewer = forwardRef<FoxgloveViewerInterface, Props>(
|
|
|
294
311
|
useImperativeHandle(
|
|
295
312
|
ref,
|
|
296
313
|
(): FoxgloveViewerInterface => ({
|
|
314
|
+
getCapabilities() {
|
|
315
|
+
return (
|
|
316
|
+
frame.current?.getCapabilities() ?? { parentOwnedLiveTransport: "pending" as const }
|
|
317
|
+
);
|
|
318
|
+
},
|
|
297
319
|
async getLayout() {
|
|
298
320
|
return await frame.current?.getLayout();
|
|
299
321
|
},
|
|
@@ -9,14 +9,20 @@ export function useShouldNotChangeOften<T>(value: T, warn: () => void): T {
|
|
|
9
9
|
const prevPrev = useRef(value);
|
|
10
10
|
const lastTime = useRef<number>(Date.now());
|
|
11
11
|
if (
|
|
12
|
+
// eslint-disable-next-line react-hooks/refs -- Pre-existing violation, not yet migrated.
|
|
12
13
|
value !== prev.current &&
|
|
14
|
+
// eslint-disable-next-line react-hooks/refs -- Pre-existing violation, not yet migrated.
|
|
13
15
|
prev.current !== prevPrev.current &&
|
|
16
|
+
// eslint-disable-next-line react-hooks/refs -- Pre-existing violation, not yet migrated.
|
|
14
17
|
Date.now() - lastTime.current < 200
|
|
15
18
|
) {
|
|
16
19
|
warn();
|
|
17
20
|
}
|
|
21
|
+
// eslint-disable-next-line react-hooks/refs -- Pre-existing violation, not yet migrated.
|
|
18
22
|
prevPrev.current = prev.current;
|
|
23
|
+
// eslint-disable-next-line react-hooks/refs -- Pre-existing violation, not yet migrated.
|
|
19
24
|
prev.current = value;
|
|
25
|
+
// eslint-disable-next-line react-hooks/refs -- Pre-existing violation, not yet migrated.
|
|
20
26
|
lastTime.current = Date.now();
|
|
21
27
|
return value;
|
|
22
28
|
}
|