@luxonis/visualizer-protobuf 2.56.0 → 2.57.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/{index-BVK70iCH.js → index-APJLEG3F.js} +1 -1
- package/dist/{index-Bp2fW9nD.js → index-BEytZkov.js} +1 -1
- package/dist/{index-CLA1BzlL.js → index-BFLpoF0o.js} +866 -50
- package/dist/{index-BrolwJ2j.js → index-BJKCsj7L.js} +1 -1
- package/dist/{index-CBAQP1IT.js → index-BQTr3SzH.js} +1 -1
- package/dist/{index-CHSRc5Gu.js → index-BSkbbsBs.js} +1 -1
- package/dist/{index-EGVrBQAC.js → index-B_v4vYFq.js} +1 -1
- package/dist/{index-CN1Qa_CW.js → index-BkD-h35E.js} +1 -1
- package/dist/{index-BNHKjcMm.js → index-BwcYZrXk.js} +1 -1
- package/dist/{index-CM5imVCh.js → index-CJKBGyqg.js} +1 -1
- package/dist/{index-DN65j_zn.js → index-CSdP9WuF.js} +1 -1
- package/dist/{index-DO5kkDW9.js → index-Chj4qsE1.js} +1 -1
- package/dist/{index-DPKWgVvs.js → index-D5NVzgfB.js} +39 -29
- package/dist/{index-DSdLdxLk.js → index-DT1L2GJv.js} +1 -1
- package/dist/{index-wJdzpNZD.js → index-DUahEwlc.js} +1 -1
- package/dist/{index-fz5Wd5GH.js → index-DhMY6_f0.js} +1 -1
- package/dist/{index-D_a5hMKe.js → index-DszCF1JN.js} +2 -2
- package/dist/{index-yaio5kyg.js → index-NeXqwiF7.js} +1 -1
- package/dist/{index-Bn0Tak9t.js → index-xOnGLFPm.js} +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/src/components/PanelToolbar.d.ts.map +1 -1
- package/dist/lib/src/components/PanelToolbar.js +7 -7
- package/dist/lib/src/components/PanelToolbar.js.map +1 -1
- package/dist/lib/src/output.css +2 -5
- package/dist/lib/src/panels/ImagePanel.d.ts +7 -0
- package/dist/lib/src/panels/ImagePanel.d.ts.map +1 -1
- package/dist/lib/src/panels/ImagePanel.js +3 -3
- package/dist/lib/src/panels/ImagePanel.js.map +1 -1
- package/dist/lib/src/panels/PointCloudPanel.d.ts +7 -0
- package/dist/lib/src/panels/PointCloudPanel.d.ts.map +1 -1
- package/dist/lib/src/panels/PointCloudPanel.js +4 -4
- package/dist/lib/src/panels/PointCloudPanel.js.map +1 -1
- package/dist/packages/studio-base/src/hooks/debounced-cursor-position.d.ts +7 -0
- package/dist/packages/studio-base/src/hooks/debounced-cursor-position.d.ts.map +1 -0
- package/dist/packages/studio-base/src/hooks/debounced-cursor-position.js +30 -0
- package/dist/packages/studio-base/src/hooks/debounced-cursor-position.js.map +1 -0
- package/dist/packages/studio-base/src/panels/ThreeDeeRender/IRenderer.d.ts +4 -2
- package/dist/packages/studio-base/src/panels/ThreeDeeRender/IRenderer.d.ts.map +1 -1
- package/dist/packages/studio-base/src/panels/ThreeDeeRender/IRenderer.js.map +1 -1
- package/dist/packages/studio-base/src/panels/ThreeDeeRender/Renderer.d.ts +4 -1
- package/dist/packages/studio-base/src/panels/ThreeDeeRender/Renderer.d.ts.map +1 -1
- package/dist/packages/studio-base/src/panels/ThreeDeeRender/Renderer.js +3 -3
- package/dist/packages/studio-base/src/panels/ThreeDeeRender/Renderer.js.map +1 -1
- package/dist/packages/studio-base/src/panels/ThreeDeeRender/ThreeDeeRender.d.ts +7 -0
- package/dist/packages/studio-base/src/panels/ThreeDeeRender/ThreeDeeRender.d.ts.map +1 -1
- package/dist/packages/studio-base/src/panels/ThreeDeeRender/ThreeDeeRender.js +16 -5
- package/dist/packages/studio-base/src/panels/ThreeDeeRender/ThreeDeeRender.js.map +1 -1
- package/dist/packages/studio-base/src/panels/ThreeDeeRender/index.d.ts +7 -0
- package/dist/packages/studio-base/src/panels/ThreeDeeRender/index.d.ts.map +1 -1
- package/dist/packages/studio-base/src/panels/ThreeDeeRender/index.js +3 -2
- package/dist/packages/studio-base/src/panels/ThreeDeeRender/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,7 +3,7 @@ import React__default, { useReducer, useRef, useCallback, useLayoutEffect, Compo
|
|
|
3
3
|
import ReactDOM__default from 'react-dom';
|
|
4
4
|
import { Z as isSymbol, $ as toString, a0 as keys, a1 as getSymbols$1, a2 as stubArray, a3 as arrayPush, a4 as baseGetAllKeys, g as getTag, a5 as getAllKeys, k as baseGet, c as baseIteratee, j as castPath, t as toKey, a6 as arrayMap$1, a7 as baseUniq, b as baseFlatten, a8 as useMustNotChange, a9 as useCurrentLayoutActions, aa as useCurrentLayoutSelector, r as reportError, A as AppError, L as Logger, u as useGuaranteedContext, ab as usePanelMosaicId, ac as useSelectedPanels, ad as PANEL_TITLE_CONFIG_KEY, ae as noop$4, o as getPanelTypeFromId, M as useShallowMemo, T as TAB_PANEL_TYPE, J as filterMap, d as dist$2, af as useAppConfiguration, ag as useValueChangedDebugLog, V as typescript, ah as useJsonTreeTheme } from './depth-CJRDcPfJ.js';
|
|
5
5
|
import { createStore, useStore } from 'zustand';
|
|
6
|
-
import { g as generateUtilityClass, c as createAggregator, f as flatRest, b as baseSet, A as AnalyticsContext, P as PropTypes, E as ErrorDisplay, S as Stack$1, m as makeStyles$1, _ as _extends$1, W as WorkspaceContext, u as useAnalytics, a as AppEvent, L as LeftSidebarItemKeys, R as RightSidebarItemKeys, d as useTranslation, e as usePanelCatalog, h as EmptyState, i as isEmpty, j as PanelContext, k as PanelCatalogContext, l as usePanelStateStore, n as useDefaultPanelTitle, o as useWorkspaceStore, p as WorkspaceStoreSelectors, q as difference, r as usePanelContext, s as useMessagePipeline, v as v4, t as useHoverValue, w as useSetHoverValue, x as useClearHoverValue, y as useMessagePipelineGetter, z as usePanelSettingsTreeUpdate, B as PlayerCapabilities, C as assertNever, D as PlayerPresence, F as isEqual, G as isDesktopApp, H as createTheme, I as propTypesExports, J as DEFAULT_CAMERA_STATE$1 } from './index-
|
|
6
|
+
import { g as generateUtilityClass, c as createAggregator, f as flatRest, b as baseSet, A as AnalyticsContext, P as PropTypes, E as ErrorDisplay, S as Stack$1, m as makeStyles$1, _ as _extends$1, W as WorkspaceContext, u as useAnalytics, a as AppEvent, L as LeftSidebarItemKeys, R as RightSidebarItemKeys, d as useTranslation, e as usePanelCatalog, h as EmptyState, i as isEmpty, j as PanelContext, k as PanelCatalogContext, l as usePanelStateStore, n as useDefaultPanelTitle, o as useWorkspaceStore, p as WorkspaceStoreSelectors, q as difference, r as usePanelContext, s as useMessagePipeline, v as v4, t as useHoverValue, w as useSetHoverValue, x as useClearHoverValue, y as useMessagePipelineGetter, z as usePanelSettingsTreeUpdate, B as PlayerCapabilities, C as assertNever, D as PlayerPresence, F as isEqual, G as isDesktopApp, H as createTheme, I as propTypesExports, J as DEFAULT_CAMERA_STATE$1, K as format$1, M as z, N as serializeError, O as stringify$1, Q as createIntl, T as createIntlCache } from './index-D5NVzgfB.js';
|
|
7
7
|
import { MosaicDragType, MosaicContext, MosaicWindowContext, getOtherBranch, getNodeAtPath } from 'react-mosaic-component';
|
|
8
8
|
import { g as getDefaultExportFromCjs, c as commonjsGlobal, d as getAugmentedNamespace } from './protobuf-B55JS-Px.js';
|
|
9
9
|
import { Link, Button, alpha, IconButton, Card, CardActionArea, CardMedia, CardContent, Typography, Container, Tooltip, Fade, ListItem, ListItemButton, ListItemText, List, TextField, InputAdornment, Popper, Grow, Paper, ClickAwayListener, Menu, MenuItem, Divider, buttonClasses, Backdrop, Chip, useTheme, alertClasses, darken, lighten, inputBaseClasses, autocompleteClasses, inputClasses, Checkbox, dialogActionsClasses, filledInputClasses, inputAdornmentClasses, listSubheaderClasses, selectClasses, tableCellClasses, ThemeProvider as ThemeProvider$1, SvgIcon, tabsClasses as tabsClasses$1, tabClasses, Tabs, Tab, ListItemIcon } from '@mui/material';
|
|
@@ -7514,7 +7514,7 @@ var useSnackbar = (function () {
|
|
|
7514
7514
|
// License, v2.0. If a copy of the MPL was not distributed with this
|
|
7515
7515
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/
|
|
7516
7516
|
|
|
7517
|
-
const log$
|
|
7517
|
+
const log$8 = Logger.getLogger("src/index.ts");
|
|
7518
7518
|
|
|
7519
7519
|
/**
|
|
7520
7520
|
* A version of React.useCallback() displaying any errors thrown from the function as toast notifications.
|
|
@@ -7528,7 +7528,7 @@ function useCallbackWithToast(callback, deps) {
|
|
|
7528
7528
|
await callback(...args);
|
|
7529
7529
|
return;
|
|
7530
7530
|
} catch (error) {
|
|
7531
|
-
log$
|
|
7531
|
+
log$8.error(error);
|
|
7532
7532
|
enqueueSnackbar(error.toString(), {
|
|
7533
7533
|
variant: "error"
|
|
7534
7534
|
});
|
|
@@ -29726,7 +29726,7 @@ class STLLoader extends Loader {
|
|
|
29726
29726
|
// License, v2.0. If a copy of the MPL was not distributed with this
|
|
29727
29727
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/
|
|
29728
29728
|
|
|
29729
|
-
const log$
|
|
29729
|
+
const log$7 = Logger.getLogger("src/index.ts");
|
|
29730
29730
|
const DEFAULT_MESH_UP_AXIS = "y_up";
|
|
29731
29731
|
const DEFAULT_COLOR$4 = new Color(0x248eff);
|
|
29732
29732
|
const GLTF_MIME_TYPES = ["model/gltf", "model/gltf-binary", "model/gltf+json"];
|
|
@@ -29799,7 +29799,7 @@ class ModelCache {
|
|
|
29799
29799
|
async #loadGltf(url, reportError) {
|
|
29800
29800
|
const onError = assetUrl => {
|
|
29801
29801
|
const originalUrl = unrewriteUrl(assetUrl);
|
|
29802
|
-
log$
|
|
29802
|
+
log$7.error(`Failed to load GLTF asset "${originalUrl}" for "${url}"`);
|
|
29803
29803
|
reportError(new Error(`Failed to load GLTF asset "${originalUrl}"`));
|
|
29804
29804
|
};
|
|
29805
29805
|
const manager = new LoadingManager(undefined, undefined, onError);
|
|
@@ -29820,7 +29820,7 @@ class ModelCache {
|
|
|
29820
29820
|
// STL files do not reference any external assets, no LoadingManager needed
|
|
29821
29821
|
const stlLoader = new STLLoader();
|
|
29822
29822
|
const bufferGeometry = stlLoader.parse(buffer);
|
|
29823
|
-
log$
|
|
29823
|
+
log$7.debug(`Finished loading STL from ${url}`);
|
|
29824
29824
|
const material = new MeshStandardMaterial({
|
|
29825
29825
|
name: url.slice(-32),
|
|
29826
29826
|
// truncate to 32 characters
|
|
@@ -29845,7 +29845,7 @@ class ModelCache {
|
|
|
29845
29845
|
ignoreUpAxis, reportError) {
|
|
29846
29846
|
const onError = assetUrl => {
|
|
29847
29847
|
const originalUrl = unrewriteUrl(assetUrl);
|
|
29848
|
-
log$
|
|
29848
|
+
log$7.error(`Failed to load COLLADA asset "${originalUrl}" for "${url}"`);
|
|
29849
29849
|
reportError(new Error(`Failed to load COLLADA asset "${originalUrl}"`));
|
|
29850
29850
|
};
|
|
29851
29851
|
|
|
@@ -29877,7 +29877,7 @@ class ModelCache {
|
|
|
29877
29877
|
}));
|
|
29878
29878
|
this.#colladaTextureObjectUrls.set(textureUrl, objectUrl);
|
|
29879
29879
|
} catch (e) {
|
|
29880
|
-
log$
|
|
29880
|
+
log$7.error(e);
|
|
29881
29881
|
onError(node.textContent);
|
|
29882
29882
|
}
|
|
29883
29883
|
}
|
|
@@ -29898,7 +29898,7 @@ class ModelCache {
|
|
|
29898
29898
|
async #loadOBJ(url, text, meshUpAxis, reportError) {
|
|
29899
29899
|
const onError = assetUrl => {
|
|
29900
29900
|
const originalUrl = unrewriteUrl(assetUrl);
|
|
29901
|
-
log$
|
|
29901
|
+
log$7.error(`Failed to load OBJ asset "${originalUrl}" for "${url}"`);
|
|
29902
29902
|
reportError(new Error(`Failed to load OBJ asset "${originalUrl}"`));
|
|
29903
29903
|
};
|
|
29904
29904
|
const manager = new LoadingManager(undefined, undefined, onError);
|
|
@@ -30722,7 +30722,7 @@ function getOffset(maybeOffset) {
|
|
|
30722
30722
|
// License, v2.0. If a copy of the MPL was not distributed with this
|
|
30723
30723
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/
|
|
30724
30724
|
|
|
30725
|
-
const log$
|
|
30725
|
+
const log$6 = Logger.getLogger("src/index.ts");
|
|
30726
30726
|
const LAYER_ID$1 = "foxglove.Grid";
|
|
30727
30727
|
const DEFAULT_SIZE = 10;
|
|
30728
30728
|
const DEFAULT_DIVISIONS = 10;
|
|
@@ -30910,7 +30910,7 @@ class Grids extends SceneExtension {
|
|
|
30910
30910
|
this.#updateGrid(instanceId, settings);
|
|
30911
30911
|
};
|
|
30912
30912
|
#handleAddGrid = instanceId => {
|
|
30913
|
-
log$
|
|
30913
|
+
log$6.info(`Creating ${LAYER_ID$1} layer ${instanceId}`);
|
|
30914
30914
|
const config = {
|
|
30915
30915
|
...DEFAULT_SETTINGS$9,
|
|
30916
30916
|
instanceId
|
|
@@ -31558,7 +31558,7 @@ class WorkerImageDecoder {
|
|
|
31558
31558
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/
|
|
31559
31559
|
|
|
31560
31560
|
const WORKER_COUNT = 4;
|
|
31561
|
-
const log$
|
|
31561
|
+
const log$5 = Logger.getLogger("src/index.ts");
|
|
31562
31562
|
const DEFAULT_DISTANCE = 1;
|
|
31563
31563
|
const DEFAULT_PLANAR_PROJECTION_FACTOR = 0;
|
|
31564
31564
|
const IMAGE_RENDERABLE_DEFAULT_SETTINGS = {
|
|
@@ -31682,7 +31682,7 @@ class ImageRenderable extends Renderable {
|
|
|
31682
31682
|
this.removeError(DECODE_IMAGE_ERR_KEY);
|
|
31683
31683
|
this.renderer.queueAnimationFrame();
|
|
31684
31684
|
}).catch(err => {
|
|
31685
|
-
log$
|
|
31685
|
+
log$5.error(err);
|
|
31686
31686
|
if (this.isDisposed()) {
|
|
31687
31687
|
return;
|
|
31688
31688
|
}
|
|
@@ -33912,7 +33912,7 @@ class ImageAnnotations extends Object3D {
|
|
|
33912
33912
|
// License, v2.0. If a copy of the MPL was not distributed with this
|
|
33913
33913
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/
|
|
33914
33914
|
|
|
33915
|
-
const log$
|
|
33915
|
+
const log$4 = Logger.getLogger("src/index.ts");
|
|
33916
33916
|
const CALIBRATION_TOPIC_PATH = ["imageMode", "calibrationTopic"];
|
|
33917
33917
|
const IMAGE_TOPIC_UNAVAILABLE = "IMAGE_TOPIC_UNAVAILABLE";
|
|
33918
33918
|
const CALIBRATION_TOPIC_UNAVAILABLE = "CALIBRATION_TOPIC_UNAVAILABLE";
|
|
@@ -34713,7 +34713,7 @@ class ImageMode extends SceneExtension {
|
|
|
34713
34713
|
}]);
|
|
34714
34714
|
}
|
|
34715
34715
|
} catch (error) {
|
|
34716
|
-
log$
|
|
34716
|
+
log$4.error(error);
|
|
34717
34717
|
if (this.renderer.displayTemporaryError) {
|
|
34718
34718
|
this.renderer.displayTemporaryError(error.toString());
|
|
34719
34719
|
}
|
|
@@ -45004,7 +45004,7 @@ class RenderableMeshResource extends RenderableMarker {
|
|
|
45004
45004
|
// License, v2.0. If a copy of the MPL was not distributed with this
|
|
45005
45005
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/
|
|
45006
45006
|
|
|
45007
|
-
const log$
|
|
45007
|
+
const log$3 = Logger.getLogger("src/index.ts");
|
|
45008
45008
|
const LAYER_ID = "foxglove.Urdf";
|
|
45009
45009
|
const TOPIC_NAME = "/robot_description";
|
|
45010
45010
|
|
|
@@ -45575,7 +45575,7 @@ class Urdfs extends SceneExtension {
|
|
|
45575
45575
|
}
|
|
45576
45576
|
};
|
|
45577
45577
|
#handleAddUrdf = instanceId => {
|
|
45578
|
-
log$
|
|
45578
|
+
log$3.info(`Creating ${LAYER_ID} layer ${instanceId}`);
|
|
45579
45579
|
const config = {
|
|
45580
45580
|
...DEFAULT_CUSTOM_SETTINGS,
|
|
45581
45581
|
instanceId
|
|
@@ -45622,7 +45622,7 @@ class Urdfs extends SceneExtension {
|
|
|
45622
45622
|
// Cancel the previous fetch
|
|
45623
45623
|
renderable.userData.fetching.control.abort();
|
|
45624
45624
|
}
|
|
45625
|
-
log$
|
|
45625
|
+
log$3.debug(`Fetching URDF from ${url}`);
|
|
45626
45626
|
renderable.userData.fetching = {
|
|
45627
45627
|
url,
|
|
45628
45628
|
control: new AbortController()
|
|
@@ -45630,7 +45630,7 @@ class Urdfs extends SceneExtension {
|
|
|
45630
45630
|
this.renderer.fetchAsset(url, {
|
|
45631
45631
|
signal: renderable.userData.fetching.control.signal
|
|
45632
45632
|
}).then(urdf => {
|
|
45633
|
-
log$
|
|
45633
|
+
log$3.debug(`Fetched ${urdf.data.length} byte URDF from ${url}`);
|
|
45634
45634
|
this.renderer.settings.errors.remove(["layers", instanceId], FETCH_URDF_ERR);
|
|
45635
45635
|
this.#loadUrdf({
|
|
45636
45636
|
instanceId,
|
|
@@ -45766,7 +45766,7 @@ class Urdfs extends SceneExtension {
|
|
|
45766
45766
|
this.renderer.queueAnimationFrame();
|
|
45767
45767
|
}).catch(unknown => {
|
|
45768
45768
|
const err = unknown;
|
|
45769
|
-
log$
|
|
45769
|
+
log$3.error(`Failed to parse URDF: ${err.message}`);
|
|
45770
45770
|
this.renderer.settings.errors.add(settingsPath, PARSE_URDF_ERR, `Failed to parse URDF: ${err.message}`);
|
|
45771
45771
|
});
|
|
45772
45772
|
}
|
|
@@ -45845,7 +45845,7 @@ class Urdfs extends SceneExtension {
|
|
|
45845
45845
|
}
|
|
45846
45846
|
async #getFileFetch(url, referenceUrl) {
|
|
45847
45847
|
try {
|
|
45848
|
-
log$
|
|
45848
|
+
log$3.debug(`fetch(${url}) requested`);
|
|
45849
45849
|
const asset = await this.renderer.fetchAsset(url, {
|
|
45850
45850
|
referenceUrl
|
|
45851
45851
|
});
|
|
@@ -45858,7 +45858,7 @@ class Urdfs extends SceneExtension {
|
|
|
45858
45858
|
async function parseUrdf(text, getFileContents, framePrefix) {
|
|
45859
45859
|
const applyFramePrefix = name => `${framePrefix}${name}`;
|
|
45860
45860
|
try {
|
|
45861
|
-
log$
|
|
45861
|
+
log$3.debug(`Parsing ${text.length} byte URDF`);
|
|
45862
45862
|
const robot = await parseRobot(text, getFileContents);
|
|
45863
45863
|
if (framePrefix) {
|
|
45864
45864
|
robot.links = new Map([...robot.links].map(([name, link]) => [applyFramePrefix(name), {
|
|
@@ -60896,7 +60896,7 @@ var bright = {exports: {}};
|
|
|
60896
60896
|
|
|
60897
60897
|
var brightExports = bright.exports;
|
|
60898
60898
|
|
|
60899
|
-
var chalk = {exports: {}};
|
|
60899
|
+
var chalk$1 = {exports: {}};
|
|
60900
60900
|
|
|
60901
60901
|
(function (module, exports) {
|
|
60902
60902
|
|
|
@@ -60922,9 +60922,9 @@ var chalk = {exports: {}};
|
|
|
60922
60922
|
base0F: '#deaf8f'
|
|
60923
60923
|
};
|
|
60924
60924
|
module.exports = exports['default'];
|
|
60925
|
-
} (chalk, chalk.exports));
|
|
60925
|
+
} (chalk$1, chalk$1.exports));
|
|
60926
60926
|
|
|
60927
|
-
var chalkExports = chalk.exports;
|
|
60927
|
+
var chalkExports = chalk$1.exports;
|
|
60928
60928
|
|
|
60929
60929
|
var codeschool = {exports: {}};
|
|
60930
60930
|
|
|
@@ -71788,9 +71788,9 @@ var moment$1 = /*@__PURE__*/getDefaultExportFromCjs(momentTimezoneExports);
|
|
|
71788
71788
|
// There is some miss-match between the moment we import and the one the type declarations expect
|
|
71789
71789
|
momentDurationFormatSetup(moment$1);
|
|
71790
71790
|
function format(stamp, timezone) {
|
|
71791
|
-
return `${formatDate(stamp, timezone)} ${formatTime(stamp, timezone)}`;
|
|
71791
|
+
return `${formatDate$1(stamp, timezone)} ${formatTime(stamp, timezone)}`;
|
|
71792
71792
|
}
|
|
71793
|
-
function formatDate(stamp, timezone) {
|
|
71793
|
+
function formatDate$1(stamp, timezone) {
|
|
71794
71794
|
if (stamp.sec < 0 || stamp.nsec < 0) {
|
|
71795
71795
|
console.error("Times are not allowed to be negative");
|
|
71796
71796
|
return "(invalid negative time)";
|
|
@@ -73620,7 +73620,7 @@ class MarkerPool {
|
|
|
73620
73620
|
// License, v2.0. If a copy of the MPL was not distributed with this
|
|
73621
73621
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/
|
|
73622
73622
|
|
|
73623
|
-
const log$
|
|
73623
|
+
const log$2 = Logger.getLogger("src/index.ts");
|
|
73624
73624
|
|
|
73625
73625
|
/** Menu item entry and callback for the "Custom Layers" menu */
|
|
73626
73626
|
|
|
@@ -73826,7 +73826,7 @@ class Renderer extends EventEmitter {
|
|
|
73826
73826
|
this.#selectionBackdropScene.add(this.#selectionBackdrop);
|
|
73827
73827
|
const samples = msaaSamples(this.gl.capabilities);
|
|
73828
73828
|
const renderSize = this.gl.getDrawingBufferSize(tempVec2);
|
|
73829
|
-
log$
|
|
73829
|
+
log$2.debug(`Initialized ${renderSize.width}x${renderSize.height} renderer (${samples}x MSAA)`);
|
|
73830
73830
|
const {
|
|
73831
73831
|
reserved
|
|
73832
73832
|
} = args.sceneExtensionConfig;
|
|
@@ -73867,7 +73867,7 @@ class Renderer extends EventEmitter {
|
|
|
73867
73867
|
this.#addSceneExtension(extensionItem.init(this));
|
|
73868
73868
|
}
|
|
73869
73869
|
}
|
|
73870
|
-
log$
|
|
73870
|
+
log$2.debug(`Renderer initialized with scene extensions ${Array.from(this.sceneExtensions.keys()).join(", ")}`);
|
|
73871
73871
|
if (interfaceMode === "image" && config.imageMode.calibrationTopic == undefined) {
|
|
73872
73872
|
this.enableImageOnlySubscriptionMode();
|
|
73873
73873
|
} else {
|
|
@@ -73883,7 +73883,7 @@ class Renderer extends EventEmitter {
|
|
|
73883
73883
|
this.emit("hudItemsChanged", this);
|
|
73884
73884
|
};
|
|
73885
73885
|
#onDevicePixelRatioChange = () => {
|
|
73886
|
-
log$
|
|
73886
|
+
log$2.debug(`devicePixelRatio changed to ${window.devicePixelRatio}`);
|
|
73887
73887
|
this.#resizeHandler(this.input.canvasSize);
|
|
73888
73888
|
this.#watchDevicePixelRatio();
|
|
73889
73889
|
};
|
|
@@ -73894,7 +73894,7 @@ class Renderer extends EventEmitter {
|
|
|
73894
73894
|
});
|
|
73895
73895
|
}
|
|
73896
73896
|
dispose() {
|
|
73897
|
-
log$
|
|
73897
|
+
log$2.warn(`Disposing renderer`);
|
|
73898
73898
|
this.#devicePixelRatioMediaQuery?.removeEventListener("change", this.#onDevicePixelRatioChange);
|
|
73899
73899
|
this.removeAllListeners();
|
|
73900
73900
|
this.settings.removeAllListeners();
|
|
@@ -74348,13 +74348,13 @@ class Renderer extends EventEmitter {
|
|
|
74348
74348
|
if (prevSelected) {
|
|
74349
74349
|
// Deselect the previously selected renderable
|
|
74350
74350
|
deselectObject(prevSelected.renderable);
|
|
74351
|
-
log$
|
|
74351
|
+
log$2.debug(`Deselected ${prevSelected.renderable.id} (${prevSelected.renderable.name})`);
|
|
74352
74352
|
}
|
|
74353
74353
|
this.#selectedRenderable = selection;
|
|
74354
74354
|
if (selection) {
|
|
74355
74355
|
// Select the newly selected renderable
|
|
74356
74356
|
selectObject(selection.renderable);
|
|
74357
|
-
log$
|
|
74357
|
+
log$2.debug(`Selected ${selection.renderable.id} (${selection.renderable.name}) (instance=${selection.instanceIndex})`, selection.renderable);
|
|
74358
74358
|
}
|
|
74359
74359
|
this.emit("selectedRenderable", selection, this);
|
|
74360
74360
|
if (!this.debugPicking) {
|
|
@@ -74499,7 +74499,7 @@ class Renderer extends EventEmitter {
|
|
|
74499
74499
|
}
|
|
74500
74500
|
setFollowFrameId(frameId) {
|
|
74501
74501
|
if (this.followFrameId !== frameId) {
|
|
74502
|
-
log$
|
|
74502
|
+
log$2.debug(`Setting followFrameId to ${frameId}`);
|
|
74503
74503
|
}
|
|
74504
74504
|
this.followFrameId = frameId;
|
|
74505
74505
|
}
|
|
@@ -74580,9 +74580,9 @@ class Renderer extends EventEmitter {
|
|
|
74580
74580
|
const fixedFrameId = fixedFrame.id;
|
|
74581
74581
|
if (this.fixedFrameId !== fixedFrameId) {
|
|
74582
74582
|
if (this.fixedFrameId == undefined) {
|
|
74583
|
-
log$
|
|
74583
|
+
log$2.debug(`Setting fixed frame to ${fixedFrameId}`);
|
|
74584
74584
|
} else {
|
|
74585
|
-
log$
|
|
74585
|
+
log$2.debug(`Changing fixed frame from "${this.fixedFrameId}" to "${fixedFrameId}"`);
|
|
74586
74586
|
}
|
|
74587
74587
|
this.fixedFrameId = fixedFrameId;
|
|
74588
74588
|
}
|
|
@@ -74592,7 +74592,7 @@ class Renderer extends EventEmitter {
|
|
|
74592
74592
|
this.gl.setSize(size.width, size.height);
|
|
74593
74593
|
this.cameraHandler.handleResize(size.width, size.height, window.devicePixelRatio);
|
|
74594
74594
|
const renderSize = this.gl.getDrawingBufferSize(tempVec2);
|
|
74595
|
-
log$
|
|
74595
|
+
log$2.debug(`Resized renderer to ${renderSize.width}x${renderSize.height}`);
|
|
74596
74596
|
this.animationFrame();
|
|
74597
74597
|
};
|
|
74598
74598
|
#clickHandler = cursorCoords => {
|
|
@@ -74632,7 +74632,7 @@ class Renderer extends EventEmitter {
|
|
|
74632
74632
|
if (!this.debugPicking) {
|
|
74633
74633
|
this.animationFrame();
|
|
74634
74634
|
}
|
|
74635
|
-
log$
|
|
74635
|
+
log$2.debug(`Clicked ${selections.length} renderable(s)`);
|
|
74636
74636
|
this.emit("renderablesClicked", selections, cursorCoords, this);
|
|
74637
74637
|
};
|
|
74638
74638
|
handleClickEvent = cursorCoords => {
|
|
@@ -74697,7 +74697,7 @@ class Renderer extends EventEmitter {
|
|
|
74697
74697
|
if (action.action !== "perform-node-action" || path.length !== 1 || path[0] !== "topics") {
|
|
74698
74698
|
return;
|
|
74699
74699
|
}
|
|
74700
|
-
log$
|
|
74700
|
+
log$2.debug(`handleTopicsAction(${action.payload.id})`);
|
|
74701
74701
|
|
|
74702
74702
|
// eslint-disable-next-line @foxglove/no-boolean-parameters
|
|
74703
74703
|
const toggleTopicVisibility = value => {
|
|
@@ -74729,7 +74729,7 @@ class Renderer extends EventEmitter {
|
|
|
74729
74729
|
if (action.action !== "perform-node-action" || path.length !== 1 || path[0] !== "layers") {
|
|
74730
74730
|
return;
|
|
74731
74731
|
}
|
|
74732
|
-
log$
|
|
74732
|
+
log$2.debug(`handleCustomLayersAction(${action.payload.id})`);
|
|
74733
74733
|
|
|
74734
74734
|
// Remove `-{uuid}` from the actionId to get the layerId
|
|
74735
74735
|
const actionId = action.payload.id;
|
|
@@ -74784,7 +74784,7 @@ class Renderer extends EventEmitter {
|
|
|
74784
74784
|
maybeRenderable = maybeRenderable.parent ?? undefined;
|
|
74785
74785
|
}
|
|
74786
74786
|
if (!renderable) {
|
|
74787
|
-
log$
|
|
74787
|
+
log$2.warn(`No Renderable found for objectId ${objectId} (name="${pickedObject?.name}" uuid=${pickedObject?.uuid})`);
|
|
74788
74788
|
return undefined;
|
|
74789
74789
|
}
|
|
74790
74790
|
|
|
@@ -74884,11 +74884,11 @@ class Renderer extends EventEmitter {
|
|
|
74884
74884
|
setAnalytics(analytics) {
|
|
74885
74885
|
this.analytics = analytics;
|
|
74886
74886
|
}
|
|
74887
|
-
|
|
74887
|
+
getCursorRelativeCoords(cursorPosition, picked) {
|
|
74888
74888
|
// 1. Get canvas-relative coordinates
|
|
74889
74889
|
const rect = this.#canvas.getBoundingClientRect();
|
|
74890
|
-
const x = (
|
|
74891
|
-
const y = -((
|
|
74890
|
+
const x = (cursorPosition.x - rect.left) / rect.width * 2 - 1;
|
|
74891
|
+
const y = -((cursorPosition.y - rect.top) / rect.height) * 2 + 1;
|
|
74892
74892
|
|
|
74893
74893
|
// 2. Create a ray from the camera through the click point
|
|
74894
74894
|
const ndc = new Vector2(x, y);
|
|
@@ -78131,6 +78131,807 @@ function makePoseEstimateMessage(pose, frameId, xDev, yDev, thetaDev) {
|
|
|
78131
78131
|
};
|
|
78132
78132
|
}
|
|
78133
78133
|
|
|
78134
|
+
function formatDate(date, format) {
|
|
78135
|
+
switch (format) {
|
|
78136
|
+
case 'iso':
|
|
78137
|
+
return date.toISOString();
|
|
78138
|
+
case 'time-dayofyear':
|
|
78139
|
+
return format$1(date, 'D HH:mm:ss', { useAdditionalDayOfYearTokens: true });
|
|
78140
|
+
case 'full':
|
|
78141
|
+
return format$1(date, 'yyyy/MM/dd, hh:mm a');
|
|
78142
|
+
}
|
|
78143
|
+
}
|
|
78144
|
+
|
|
78145
|
+
z.string().min(6);
|
|
78146
|
+
z
|
|
78147
|
+
.string()
|
|
78148
|
+
.regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?$/, { message: 'Version must be in the format X.Y or X.Y.Z' });
|
|
78149
|
+
|
|
78150
|
+
const ANSI_BACKGROUND_OFFSET = 10;
|
|
78151
|
+
|
|
78152
|
+
const wrapAnsi16 = (offset = 0) => code => `\u001B[${code + offset}m`;
|
|
78153
|
+
|
|
78154
|
+
const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
|
|
78155
|
+
|
|
78156
|
+
const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
|
|
78157
|
+
|
|
78158
|
+
const styles$1 = {
|
|
78159
|
+
modifier: {
|
|
78160
|
+
reset: [0, 0],
|
|
78161
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
78162
|
+
bold: [1, 22],
|
|
78163
|
+
dim: [2, 22],
|
|
78164
|
+
italic: [3, 23],
|
|
78165
|
+
underline: [4, 24],
|
|
78166
|
+
overline: [53, 55],
|
|
78167
|
+
inverse: [7, 27],
|
|
78168
|
+
hidden: [8, 28],
|
|
78169
|
+
strikethrough: [9, 29],
|
|
78170
|
+
},
|
|
78171
|
+
color: {
|
|
78172
|
+
black: [30, 39],
|
|
78173
|
+
red: [31, 39],
|
|
78174
|
+
green: [32, 39],
|
|
78175
|
+
yellow: [33, 39],
|
|
78176
|
+
blue: [34, 39],
|
|
78177
|
+
magenta: [35, 39],
|
|
78178
|
+
cyan: [36, 39],
|
|
78179
|
+
white: [37, 39],
|
|
78180
|
+
|
|
78181
|
+
// Bright color
|
|
78182
|
+
blackBright: [90, 39],
|
|
78183
|
+
gray: [90, 39], // Alias of `blackBright`
|
|
78184
|
+
grey: [90, 39], // Alias of `blackBright`
|
|
78185
|
+
redBright: [91, 39],
|
|
78186
|
+
greenBright: [92, 39],
|
|
78187
|
+
yellowBright: [93, 39],
|
|
78188
|
+
blueBright: [94, 39],
|
|
78189
|
+
magentaBright: [95, 39],
|
|
78190
|
+
cyanBright: [96, 39],
|
|
78191
|
+
whiteBright: [97, 39],
|
|
78192
|
+
},
|
|
78193
|
+
bgColor: {
|
|
78194
|
+
bgBlack: [40, 49],
|
|
78195
|
+
bgRed: [41, 49],
|
|
78196
|
+
bgGreen: [42, 49],
|
|
78197
|
+
bgYellow: [43, 49],
|
|
78198
|
+
bgBlue: [44, 49],
|
|
78199
|
+
bgMagenta: [45, 49],
|
|
78200
|
+
bgCyan: [46, 49],
|
|
78201
|
+
bgWhite: [47, 49],
|
|
78202
|
+
|
|
78203
|
+
// Bright color
|
|
78204
|
+
bgBlackBright: [100, 49],
|
|
78205
|
+
bgGray: [100, 49], // Alias of `bgBlackBright`
|
|
78206
|
+
bgGrey: [100, 49], // Alias of `bgBlackBright`
|
|
78207
|
+
bgRedBright: [101, 49],
|
|
78208
|
+
bgGreenBright: [102, 49],
|
|
78209
|
+
bgYellowBright: [103, 49],
|
|
78210
|
+
bgBlueBright: [104, 49],
|
|
78211
|
+
bgMagentaBright: [105, 49],
|
|
78212
|
+
bgCyanBright: [106, 49],
|
|
78213
|
+
bgWhiteBright: [107, 49],
|
|
78214
|
+
},
|
|
78215
|
+
};
|
|
78216
|
+
|
|
78217
|
+
Object.keys(styles$1.modifier);
|
|
78218
|
+
const foregroundColorNames = Object.keys(styles$1.color);
|
|
78219
|
+
const backgroundColorNames = Object.keys(styles$1.bgColor);
|
|
78220
|
+
[...foregroundColorNames, ...backgroundColorNames];
|
|
78221
|
+
|
|
78222
|
+
function assembleStyles() {
|
|
78223
|
+
const codes = new Map();
|
|
78224
|
+
|
|
78225
|
+
for (const [groupName, group] of Object.entries(styles$1)) {
|
|
78226
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
78227
|
+
styles$1[styleName] = {
|
|
78228
|
+
open: `\u001B[${style[0]}m`,
|
|
78229
|
+
close: `\u001B[${style[1]}m`,
|
|
78230
|
+
};
|
|
78231
|
+
|
|
78232
|
+
group[styleName] = styles$1[styleName];
|
|
78233
|
+
|
|
78234
|
+
codes.set(style[0], style[1]);
|
|
78235
|
+
}
|
|
78236
|
+
|
|
78237
|
+
Object.defineProperty(styles$1, groupName, {
|
|
78238
|
+
value: group,
|
|
78239
|
+
enumerable: false,
|
|
78240
|
+
});
|
|
78241
|
+
}
|
|
78242
|
+
|
|
78243
|
+
Object.defineProperty(styles$1, 'codes', {
|
|
78244
|
+
value: codes,
|
|
78245
|
+
enumerable: false,
|
|
78246
|
+
});
|
|
78247
|
+
|
|
78248
|
+
styles$1.color.close = '\u001B[39m';
|
|
78249
|
+
styles$1.bgColor.close = '\u001B[49m';
|
|
78250
|
+
|
|
78251
|
+
styles$1.color.ansi = wrapAnsi16();
|
|
78252
|
+
styles$1.color.ansi256 = wrapAnsi256();
|
|
78253
|
+
styles$1.color.ansi16m = wrapAnsi16m();
|
|
78254
|
+
styles$1.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
78255
|
+
styles$1.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
78256
|
+
styles$1.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
78257
|
+
|
|
78258
|
+
// From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
|
|
78259
|
+
Object.defineProperties(styles$1, {
|
|
78260
|
+
rgbToAnsi256: {
|
|
78261
|
+
value(red, green, blue) {
|
|
78262
|
+
// We use the extended greyscale palette here, with the exception of
|
|
78263
|
+
// black and white. normal palette only has 4 greyscale shades.
|
|
78264
|
+
if (red === green && green === blue) {
|
|
78265
|
+
if (red < 8) {
|
|
78266
|
+
return 16;
|
|
78267
|
+
}
|
|
78268
|
+
|
|
78269
|
+
if (red > 248) {
|
|
78270
|
+
return 231;
|
|
78271
|
+
}
|
|
78272
|
+
|
|
78273
|
+
return Math.round(((red - 8) / 247) * 24) + 232;
|
|
78274
|
+
}
|
|
78275
|
+
|
|
78276
|
+
return 16
|
|
78277
|
+
+ (36 * Math.round(red / 255 * 5))
|
|
78278
|
+
+ (6 * Math.round(green / 255 * 5))
|
|
78279
|
+
+ Math.round(blue / 255 * 5);
|
|
78280
|
+
},
|
|
78281
|
+
enumerable: false,
|
|
78282
|
+
},
|
|
78283
|
+
hexToRgb: {
|
|
78284
|
+
value(hex) {
|
|
78285
|
+
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
78286
|
+
if (!matches) {
|
|
78287
|
+
return [0, 0, 0];
|
|
78288
|
+
}
|
|
78289
|
+
|
|
78290
|
+
let [colorString] = matches;
|
|
78291
|
+
|
|
78292
|
+
if (colorString.length === 3) {
|
|
78293
|
+
colorString = [...colorString].map(character => character + character).join('');
|
|
78294
|
+
}
|
|
78295
|
+
|
|
78296
|
+
const integer = Number.parseInt(colorString, 16);
|
|
78297
|
+
|
|
78298
|
+
return [
|
|
78299
|
+
/* eslint-disable no-bitwise */
|
|
78300
|
+
(integer >> 16) & 0xFF,
|
|
78301
|
+
(integer >> 8) & 0xFF,
|
|
78302
|
+
integer & 0xFF,
|
|
78303
|
+
/* eslint-enable no-bitwise */
|
|
78304
|
+
];
|
|
78305
|
+
},
|
|
78306
|
+
enumerable: false,
|
|
78307
|
+
},
|
|
78308
|
+
hexToAnsi256: {
|
|
78309
|
+
value: hex => styles$1.rgbToAnsi256(...styles$1.hexToRgb(hex)),
|
|
78310
|
+
enumerable: false,
|
|
78311
|
+
},
|
|
78312
|
+
ansi256ToAnsi: {
|
|
78313
|
+
value(code) {
|
|
78314
|
+
if (code < 8) {
|
|
78315
|
+
return 30 + code;
|
|
78316
|
+
}
|
|
78317
|
+
|
|
78318
|
+
if (code < 16) {
|
|
78319
|
+
return 90 + (code - 8);
|
|
78320
|
+
}
|
|
78321
|
+
|
|
78322
|
+
let red;
|
|
78323
|
+
let green;
|
|
78324
|
+
let blue;
|
|
78325
|
+
|
|
78326
|
+
if (code >= 232) {
|
|
78327
|
+
red = (((code - 232) * 10) + 8) / 255;
|
|
78328
|
+
green = red;
|
|
78329
|
+
blue = red;
|
|
78330
|
+
} else {
|
|
78331
|
+
code -= 16;
|
|
78332
|
+
|
|
78333
|
+
const remainder = code % 36;
|
|
78334
|
+
|
|
78335
|
+
red = Math.floor(code / 36) / 5;
|
|
78336
|
+
green = Math.floor(remainder / 6) / 5;
|
|
78337
|
+
blue = (remainder % 6) / 5;
|
|
78338
|
+
}
|
|
78339
|
+
|
|
78340
|
+
const value = Math.max(red, green, blue) * 2;
|
|
78341
|
+
|
|
78342
|
+
if (value === 0) {
|
|
78343
|
+
return 30;
|
|
78344
|
+
}
|
|
78345
|
+
|
|
78346
|
+
// eslint-disable-next-line no-bitwise
|
|
78347
|
+
let result = 30 + ((Math.round(blue) << 2) | (Math.round(green) << 1) | Math.round(red));
|
|
78348
|
+
|
|
78349
|
+
if (value === 2) {
|
|
78350
|
+
result += 60;
|
|
78351
|
+
}
|
|
78352
|
+
|
|
78353
|
+
return result;
|
|
78354
|
+
},
|
|
78355
|
+
enumerable: false,
|
|
78356
|
+
},
|
|
78357
|
+
rgbToAnsi: {
|
|
78358
|
+
value: (red, green, blue) => styles$1.ansi256ToAnsi(styles$1.rgbToAnsi256(red, green, blue)),
|
|
78359
|
+
enumerable: false,
|
|
78360
|
+
},
|
|
78361
|
+
hexToAnsi: {
|
|
78362
|
+
value: hex => styles$1.ansi256ToAnsi(styles$1.hexToAnsi256(hex)),
|
|
78363
|
+
enumerable: false,
|
|
78364
|
+
},
|
|
78365
|
+
});
|
|
78366
|
+
|
|
78367
|
+
return styles$1;
|
|
78368
|
+
}
|
|
78369
|
+
|
|
78370
|
+
const ansiStyles = assembleStyles();
|
|
78371
|
+
|
|
78372
|
+
/* eslint-env browser */
|
|
78373
|
+
|
|
78374
|
+
const level = (() => {
|
|
78375
|
+
if (navigator.userAgentData) {
|
|
78376
|
+
const brand = navigator.userAgentData.brands.find(({brand}) => brand === 'Chromium');
|
|
78377
|
+
if (brand && brand.version > 93) {
|
|
78378
|
+
return 3;
|
|
78379
|
+
}
|
|
78380
|
+
}
|
|
78381
|
+
|
|
78382
|
+
if (/\b(Chrome|Chromium)\//.test(navigator.userAgent)) {
|
|
78383
|
+
return 1;
|
|
78384
|
+
}
|
|
78385
|
+
|
|
78386
|
+
return 0;
|
|
78387
|
+
})();
|
|
78388
|
+
|
|
78389
|
+
const colorSupport = level !== 0 && {
|
|
78390
|
+
level,
|
|
78391
|
+
hasBasic: true,
|
|
78392
|
+
has256: level >= 2,
|
|
78393
|
+
has16m: level >= 3,
|
|
78394
|
+
};
|
|
78395
|
+
|
|
78396
|
+
const supportsColor = {
|
|
78397
|
+
stdout: colorSupport,
|
|
78398
|
+
stderr: colorSupport,
|
|
78399
|
+
};
|
|
78400
|
+
|
|
78401
|
+
// TODO: When targeting Node.js 16, use `String.prototype.replaceAll`.
|
|
78402
|
+
function stringReplaceAll(string, substring, replacer) {
|
|
78403
|
+
let index = string.indexOf(substring);
|
|
78404
|
+
if (index === -1) {
|
|
78405
|
+
return string;
|
|
78406
|
+
}
|
|
78407
|
+
|
|
78408
|
+
const substringLength = substring.length;
|
|
78409
|
+
let endIndex = 0;
|
|
78410
|
+
let returnValue = '';
|
|
78411
|
+
do {
|
|
78412
|
+
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
78413
|
+
endIndex = index + substringLength;
|
|
78414
|
+
index = string.indexOf(substring, endIndex);
|
|
78415
|
+
} while (index !== -1);
|
|
78416
|
+
|
|
78417
|
+
returnValue += string.slice(endIndex);
|
|
78418
|
+
return returnValue;
|
|
78419
|
+
}
|
|
78420
|
+
|
|
78421
|
+
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
78422
|
+
let endIndex = 0;
|
|
78423
|
+
let returnValue = '';
|
|
78424
|
+
do {
|
|
78425
|
+
const gotCR = string[index - 1] === '\r';
|
|
78426
|
+
returnValue += string.slice(endIndex, (gotCR ? index - 1 : index)) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
|
|
78427
|
+
endIndex = index + 1;
|
|
78428
|
+
index = string.indexOf('\n', endIndex);
|
|
78429
|
+
} while (index !== -1);
|
|
78430
|
+
|
|
78431
|
+
returnValue += string.slice(endIndex);
|
|
78432
|
+
return returnValue;
|
|
78433
|
+
}
|
|
78434
|
+
|
|
78435
|
+
const {stdout: stdoutColor, stderr: stderrColor} = supportsColor;
|
|
78436
|
+
|
|
78437
|
+
const GENERATOR = Symbol('GENERATOR');
|
|
78438
|
+
const STYLER = Symbol('STYLER');
|
|
78439
|
+
const IS_EMPTY = Symbol('IS_EMPTY');
|
|
78440
|
+
|
|
78441
|
+
// `supportsColor.level` → `ansiStyles.color[name]` mapping
|
|
78442
|
+
const levelMapping = [
|
|
78443
|
+
'ansi',
|
|
78444
|
+
'ansi',
|
|
78445
|
+
'ansi256',
|
|
78446
|
+
'ansi16m',
|
|
78447
|
+
];
|
|
78448
|
+
|
|
78449
|
+
const styles = Object.create(null);
|
|
78450
|
+
|
|
78451
|
+
const applyOptions = (object, options = {}) => {
|
|
78452
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
78453
|
+
throw new Error('The `level` option should be an integer from 0 to 3');
|
|
78454
|
+
}
|
|
78455
|
+
|
|
78456
|
+
// Detect level if not set manually
|
|
78457
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
78458
|
+
object.level = options.level === undefined ? colorLevel : options.level;
|
|
78459
|
+
};
|
|
78460
|
+
|
|
78461
|
+
const chalkFactory = options => {
|
|
78462
|
+
const chalk = (...strings) => strings.join(' ');
|
|
78463
|
+
applyOptions(chalk, options);
|
|
78464
|
+
|
|
78465
|
+
Object.setPrototypeOf(chalk, createChalk.prototype);
|
|
78466
|
+
|
|
78467
|
+
return chalk;
|
|
78468
|
+
};
|
|
78469
|
+
|
|
78470
|
+
function createChalk(options) {
|
|
78471
|
+
return chalkFactory(options);
|
|
78472
|
+
}
|
|
78473
|
+
|
|
78474
|
+
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
78475
|
+
|
|
78476
|
+
for (const [styleName, style] of Object.entries(ansiStyles)) {
|
|
78477
|
+
styles[styleName] = {
|
|
78478
|
+
get() {
|
|
78479
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
78480
|
+
Object.defineProperty(this, styleName, {value: builder});
|
|
78481
|
+
return builder;
|
|
78482
|
+
},
|
|
78483
|
+
};
|
|
78484
|
+
}
|
|
78485
|
+
|
|
78486
|
+
styles.visible = {
|
|
78487
|
+
get() {
|
|
78488
|
+
const builder = createBuilder(this, this[STYLER], true);
|
|
78489
|
+
Object.defineProperty(this, 'visible', {value: builder});
|
|
78490
|
+
return builder;
|
|
78491
|
+
},
|
|
78492
|
+
};
|
|
78493
|
+
|
|
78494
|
+
const getModelAnsi = (model, level, type, ...arguments_) => {
|
|
78495
|
+
if (model === 'rgb') {
|
|
78496
|
+
if (level === 'ansi16m') {
|
|
78497
|
+
return ansiStyles[type].ansi16m(...arguments_);
|
|
78498
|
+
}
|
|
78499
|
+
|
|
78500
|
+
if (level === 'ansi256') {
|
|
78501
|
+
return ansiStyles[type].ansi256(ansiStyles.rgbToAnsi256(...arguments_));
|
|
78502
|
+
}
|
|
78503
|
+
|
|
78504
|
+
return ansiStyles[type].ansi(ansiStyles.rgbToAnsi(...arguments_));
|
|
78505
|
+
}
|
|
78506
|
+
|
|
78507
|
+
if (model === 'hex') {
|
|
78508
|
+
return getModelAnsi('rgb', level, type, ...ansiStyles.hexToRgb(...arguments_));
|
|
78509
|
+
}
|
|
78510
|
+
|
|
78511
|
+
return ansiStyles[type][model](...arguments_);
|
|
78512
|
+
};
|
|
78513
|
+
|
|
78514
|
+
const usedModels = ['rgb', 'hex', 'ansi256'];
|
|
78515
|
+
|
|
78516
|
+
for (const model of usedModels) {
|
|
78517
|
+
styles[model] = {
|
|
78518
|
+
get() {
|
|
78519
|
+
const {level} = this;
|
|
78520
|
+
return function (...arguments_) {
|
|
78521
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], 'color', ...arguments_), ansiStyles.color.close, this[STYLER]);
|
|
78522
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
78523
|
+
};
|
|
78524
|
+
},
|
|
78525
|
+
};
|
|
78526
|
+
|
|
78527
|
+
const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
|
|
78528
|
+
styles[bgModel] = {
|
|
78529
|
+
get() {
|
|
78530
|
+
const {level} = this;
|
|
78531
|
+
return function (...arguments_) {
|
|
78532
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], 'bgColor', ...arguments_), ansiStyles.bgColor.close, this[STYLER]);
|
|
78533
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
78534
|
+
};
|
|
78535
|
+
},
|
|
78536
|
+
};
|
|
78537
|
+
}
|
|
78538
|
+
|
|
78539
|
+
const proto = Object.defineProperties(() => {}, {
|
|
78540
|
+
...styles,
|
|
78541
|
+
level: {
|
|
78542
|
+
enumerable: true,
|
|
78543
|
+
get() {
|
|
78544
|
+
return this[GENERATOR].level;
|
|
78545
|
+
},
|
|
78546
|
+
set(level) {
|
|
78547
|
+
this[GENERATOR].level = level;
|
|
78548
|
+
},
|
|
78549
|
+
},
|
|
78550
|
+
});
|
|
78551
|
+
|
|
78552
|
+
const createStyler = (open, close, parent) => {
|
|
78553
|
+
let openAll;
|
|
78554
|
+
let closeAll;
|
|
78555
|
+
if (parent === undefined) {
|
|
78556
|
+
openAll = open;
|
|
78557
|
+
closeAll = close;
|
|
78558
|
+
} else {
|
|
78559
|
+
openAll = parent.openAll + open;
|
|
78560
|
+
closeAll = close + parent.closeAll;
|
|
78561
|
+
}
|
|
78562
|
+
|
|
78563
|
+
return {
|
|
78564
|
+
open,
|
|
78565
|
+
close,
|
|
78566
|
+
openAll,
|
|
78567
|
+
closeAll,
|
|
78568
|
+
parent,
|
|
78569
|
+
};
|
|
78570
|
+
};
|
|
78571
|
+
|
|
78572
|
+
const createBuilder = (self, _styler, _isEmpty) => {
|
|
78573
|
+
// Single argument is hot path, implicit coercion is faster than anything
|
|
78574
|
+
// eslint-disable-next-line no-implicit-coercion
|
|
78575
|
+
const builder = (...arguments_) => applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' '));
|
|
78576
|
+
|
|
78577
|
+
// We alter the prototype because we must return a function, but there is
|
|
78578
|
+
// no way to create a function with a different prototype
|
|
78579
|
+
Object.setPrototypeOf(builder, proto);
|
|
78580
|
+
|
|
78581
|
+
builder[GENERATOR] = self;
|
|
78582
|
+
builder[STYLER] = _styler;
|
|
78583
|
+
builder[IS_EMPTY] = _isEmpty;
|
|
78584
|
+
|
|
78585
|
+
return builder;
|
|
78586
|
+
};
|
|
78587
|
+
|
|
78588
|
+
const applyStyle = (self, string) => {
|
|
78589
|
+
if (self.level <= 0 || !string) {
|
|
78590
|
+
return self[IS_EMPTY] ? '' : string;
|
|
78591
|
+
}
|
|
78592
|
+
|
|
78593
|
+
let styler = self[STYLER];
|
|
78594
|
+
|
|
78595
|
+
if (styler === undefined) {
|
|
78596
|
+
return string;
|
|
78597
|
+
}
|
|
78598
|
+
|
|
78599
|
+
const {openAll, closeAll} = styler;
|
|
78600
|
+
if (string.includes('\u001B')) {
|
|
78601
|
+
while (styler !== undefined) {
|
|
78602
|
+
// Replace any instances already present with a re-opening code
|
|
78603
|
+
// otherwise only the part of the string until said closing code
|
|
78604
|
+
// will be colored, and the rest will simply be 'plain'.
|
|
78605
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
78606
|
+
|
|
78607
|
+
styler = styler.parent;
|
|
78608
|
+
}
|
|
78609
|
+
}
|
|
78610
|
+
|
|
78611
|
+
// We can move both next actions out of loop, because remaining actions in loop won't have
|
|
78612
|
+
// any/visible effect on parts we add here. Close the styling before a linebreak and reopen
|
|
78613
|
+
// after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92
|
|
78614
|
+
const lfIndex = string.indexOf('\n');
|
|
78615
|
+
if (lfIndex !== -1) {
|
|
78616
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
78617
|
+
}
|
|
78618
|
+
|
|
78619
|
+
return openAll + string + closeAll;
|
|
78620
|
+
};
|
|
78621
|
+
|
|
78622
|
+
Object.defineProperties(createChalk.prototype, styles);
|
|
78623
|
+
|
|
78624
|
+
const chalk = createChalk();
|
|
78625
|
+
createChalk({level: stderrColor ? stderrColor.level : 0});
|
|
78626
|
+
|
|
78627
|
+
/* eslint-disable no-var */
|
|
78628
|
+
var LogLevel;
|
|
78629
|
+
(function (LogLevel) {
|
|
78630
|
+
LogLevel[LogLevel["trace"] = 10] = "trace";
|
|
78631
|
+
LogLevel[LogLevel["debug"] = 20] = "debug";
|
|
78632
|
+
LogLevel[LogLevel["info"] = 30] = "info";
|
|
78633
|
+
LogLevel[LogLevel["warn"] = 40] = "warn";
|
|
78634
|
+
LogLevel[LogLevel["error"] = 50] = "error";
|
|
78635
|
+
LogLevel[LogLevel["fatal"] = 60] = "fatal";
|
|
78636
|
+
})(LogLevel || (LogLevel = {}));
|
|
78637
|
+
function isLogFnParamsCtx(params) {
|
|
78638
|
+
return typeof params[0] !== 'string' && typeof params[1] !== 'undefined';
|
|
78639
|
+
}
|
|
78640
|
+
function parseLogFormat(value) {
|
|
78641
|
+
switch (value) {
|
|
78642
|
+
case 'pretty':
|
|
78643
|
+
case 'plain':
|
|
78644
|
+
case 'json':
|
|
78645
|
+
return value;
|
|
78646
|
+
default:
|
|
78647
|
+
return 'json';
|
|
78648
|
+
}
|
|
78649
|
+
}
|
|
78650
|
+
function logLevelName(level) {
|
|
78651
|
+
switch (level) {
|
|
78652
|
+
case 10:
|
|
78653
|
+
return ' T ';
|
|
78654
|
+
case 20:
|
|
78655
|
+
return ' D ';
|
|
78656
|
+
case 30:
|
|
78657
|
+
return ' I ';
|
|
78658
|
+
case 40:
|
|
78659
|
+
return ' W ';
|
|
78660
|
+
case 50:
|
|
78661
|
+
return ' E ';
|
|
78662
|
+
case 60:
|
|
78663
|
+
return ' F ';
|
|
78664
|
+
}
|
|
78665
|
+
return '?????';
|
|
78666
|
+
}
|
|
78667
|
+
function colorize(level) {
|
|
78668
|
+
switch (level) {
|
|
78669
|
+
case 10:
|
|
78670
|
+
return { color: chalk.gray, bgcolor: chalk.bgGray.black };
|
|
78671
|
+
case 20:
|
|
78672
|
+
return { color: chalk.gray, bgcolor: chalk.bgGray.black };
|
|
78673
|
+
case 30:
|
|
78674
|
+
return { color: chalk.white, bgcolor: chalk.bgWhite.black };
|
|
78675
|
+
case 40:
|
|
78676
|
+
return { color: chalk.yellow, bgcolor: chalk.bgYellow.black };
|
|
78677
|
+
case 50:
|
|
78678
|
+
return { color: chalk.red, bgcolor: chalk.bgRed.black };
|
|
78679
|
+
case 60:
|
|
78680
|
+
return { color: chalk.red, bgcolor: chalk.bgRed.black };
|
|
78681
|
+
}
|
|
78682
|
+
return { color: chalk.gray, bgcolor: chalk.bgGray.black };
|
|
78683
|
+
}
|
|
78684
|
+
function customStringify(data, useSpaces = true) {
|
|
78685
|
+
return (stringify$1(data, (_key, value) => {
|
|
78686
|
+
if (typeof Buffer !== 'undefined' && value instanceof Buffer) {
|
|
78687
|
+
return value.toString('base64');
|
|
78688
|
+
}
|
|
78689
|
+
return value;
|
|
78690
|
+
}, useSpaces ? 2 : undefined) ?? '');
|
|
78691
|
+
}
|
|
78692
|
+
function prettyMessage(message) {
|
|
78693
|
+
const logLevel = message.level ?? 30;
|
|
78694
|
+
const { color, bgcolor } = colorize(logLevel);
|
|
78695
|
+
const component = message.component ? `/${message.component}` : '';
|
|
78696
|
+
const baseMsg = [
|
|
78697
|
+
chalk.gray(formatDate(new Date(message.when), 'time-dayofyear')),
|
|
78698
|
+
bgcolor(logLevelName(logLevel)),
|
|
78699
|
+
color(`${message.logger.name}${component}`),
|
|
78700
|
+
color(':'),
|
|
78701
|
+
color(message.message),
|
|
78702
|
+
];
|
|
78703
|
+
if (Object.keys(message.context).length > 0) {
|
|
78704
|
+
for (const [key, value] of Object.entries(message.context)) {
|
|
78705
|
+
if (value instanceof Error) {
|
|
78706
|
+
try {
|
|
78707
|
+
baseMsg.push(`\n\n[key = ${key} contains Error]\n\n${customStringify(serializeError(value))}`);
|
|
78708
|
+
}
|
|
78709
|
+
catch {
|
|
78710
|
+
baseMsg.push(`\n\n[key = ${key} contains Error]\n\n${value.name}\n${value.message}`);
|
|
78711
|
+
}
|
|
78712
|
+
delete message.context[key];
|
|
78713
|
+
}
|
|
78714
|
+
}
|
|
78715
|
+
baseMsg.push(chalk.gray(`\n${customStringify(message.context)}`));
|
|
78716
|
+
}
|
|
78717
|
+
return baseMsg.join(' ');
|
|
78718
|
+
}
|
|
78719
|
+
function buildSerializeMessage(config) {
|
|
78720
|
+
if (config.format === 'pretty' || config.runtime === 'development') {
|
|
78721
|
+
chalk.level = typeof document !== 'undefined' ? 0 : 3;
|
|
78722
|
+
return prettyMessage;
|
|
78723
|
+
}
|
|
78724
|
+
else if (config.format === 'json') {
|
|
78725
|
+
return (message) => customStringify({ ...message, when: formatDate(message.when, 'iso') }, false);
|
|
78726
|
+
}
|
|
78727
|
+
else if (config.format === 'plain') {
|
|
78728
|
+
return (message) => {
|
|
78729
|
+
const logLevel = message.context.logLevel ?? 30;
|
|
78730
|
+
const component = message.context.component ? `/${JSON.stringify(message.context.component)}` : '';
|
|
78731
|
+
const baseMsg = [
|
|
78732
|
+
formatDate(message.when, 'time-dayofyear'),
|
|
78733
|
+
logLevelName(logLevel),
|
|
78734
|
+
`${message.logger.name}${component}`,
|
|
78735
|
+
':',
|
|
78736
|
+
message.message,
|
|
78737
|
+
];
|
|
78738
|
+
if (Object.keys(message.context).length > 0) {
|
|
78739
|
+
baseMsg.push(`\n${customStringify(message.context)}`);
|
|
78740
|
+
}
|
|
78741
|
+
return baseMsg.join(' ');
|
|
78742
|
+
};
|
|
78743
|
+
}
|
|
78744
|
+
else {
|
|
78745
|
+
throw new Error(`invalid configuration provided ${JSON.stringify(config, undefined, 2)}`);
|
|
78746
|
+
}
|
|
78747
|
+
}
|
|
78748
|
+
const writeMessage = (msg) => {
|
|
78749
|
+
if (msg.level < msg.logger.config.level)
|
|
78750
|
+
return;
|
|
78751
|
+
const message = msg.logger.serializeMessage(msg);
|
|
78752
|
+
if (typeof document !== 'undefined') {
|
|
78753
|
+
// eslint-disable-next-line no-console
|
|
78754
|
+
console.log(message);
|
|
78755
|
+
}
|
|
78756
|
+
else if (typeof process !== 'undefined') {
|
|
78757
|
+
process.stdout.write(`${message}\n`);
|
|
78758
|
+
}
|
|
78759
|
+
else {
|
|
78760
|
+
// eslint-disable-next-line no-console
|
|
78761
|
+
console.log(message);
|
|
78762
|
+
}
|
|
78763
|
+
};
|
|
78764
|
+
const buildLogger = (name, initialConfig) => {
|
|
78765
|
+
const _config = { ...initialConfig };
|
|
78766
|
+
let serializeMessage = buildSerializeMessage(_config);
|
|
78767
|
+
const configure = (config) => {
|
|
78768
|
+
Object.assign(_config, config);
|
|
78769
|
+
// logger.trace({ config: logger.config }, `reconfigured logger: ${name}`);
|
|
78770
|
+
serializeMessage = buildSerializeMessage(_config);
|
|
78771
|
+
};
|
|
78772
|
+
const buildBoundFns = (opts) => {
|
|
78773
|
+
const { component } = opts;
|
|
78774
|
+
return {
|
|
78775
|
+
trace: log.bind({ level: LogLevel.trace, component }),
|
|
78776
|
+
debug: log.bind({ level: LogLevel.debug, component }),
|
|
78777
|
+
info: log.bind({ level: LogLevel.info, component }),
|
|
78778
|
+
warn: log.bind({ level: LogLevel.warn, component }),
|
|
78779
|
+
error: log.bind({ level: LogLevel.error, component }),
|
|
78780
|
+
fatal: log.bind({ level: LogLevel.fatal, component }),
|
|
78781
|
+
};
|
|
78782
|
+
};
|
|
78783
|
+
function log(...params) {
|
|
78784
|
+
const ctxIndex = isLogFnParamsCtx(params) ? 0 : -1;
|
|
78785
|
+
const message = params.slice(ctxIndex + 1).join(' ');
|
|
78786
|
+
writeMessage({
|
|
78787
|
+
logger,
|
|
78788
|
+
when: new Date(),
|
|
78789
|
+
level: this.level,
|
|
78790
|
+
context: ctxIndex !== -1 ? params[ctxIndex] : {},
|
|
78791
|
+
component: this.component,
|
|
78792
|
+
message,
|
|
78793
|
+
});
|
|
78794
|
+
}
|
|
78795
|
+
const child = (component) => {
|
|
78796
|
+
const parent = logger;
|
|
78797
|
+
return {
|
|
78798
|
+
...parent,
|
|
78799
|
+
...buildBoundFns({ component }),
|
|
78800
|
+
};
|
|
78801
|
+
};
|
|
78802
|
+
const canLogLevel = (level) => {
|
|
78803
|
+
return _config.level <= level;
|
|
78804
|
+
};
|
|
78805
|
+
const logger = {
|
|
78806
|
+
get config() {
|
|
78807
|
+
return _config;
|
|
78808
|
+
},
|
|
78809
|
+
get name() {
|
|
78810
|
+
return _config.rootComponent;
|
|
78811
|
+
},
|
|
78812
|
+
serializeMessage: msg => {
|
|
78813
|
+
if (_config.format !== 'pretty') {
|
|
78814
|
+
const newContext = { ...msg.context };
|
|
78815
|
+
for (const entry of Object.entries(msg.context)) {
|
|
78816
|
+
let value = msg.context[entry[0]];
|
|
78817
|
+
if (value instanceof Error) {
|
|
78818
|
+
try {
|
|
78819
|
+
value = serializeError(value, {
|
|
78820
|
+
maxDepth: 3,
|
|
78821
|
+
});
|
|
78822
|
+
}
|
|
78823
|
+
catch (e) {
|
|
78824
|
+
logger.warn({ error: e }, `serialize of error failed`);
|
|
78825
|
+
// serialize failed, keep original value
|
|
78826
|
+
}
|
|
78827
|
+
}
|
|
78828
|
+
newContext[entry[0]] = value;
|
|
78829
|
+
}
|
|
78830
|
+
Object.assign(msg, { context: newContext });
|
|
78831
|
+
}
|
|
78832
|
+
return serializeMessage(msg);
|
|
78833
|
+
},
|
|
78834
|
+
child,
|
|
78835
|
+
configure,
|
|
78836
|
+
canLogLevel,
|
|
78837
|
+
...buildBoundFns({ component: null }),
|
|
78838
|
+
};
|
|
78839
|
+
// logger.trace({ config: logger.config }, `built logger: ${name}`);
|
|
78840
|
+
return logger;
|
|
78841
|
+
};
|
|
78842
|
+
const LOG_LEVEL_ENV = globalThis.ENV?.LOG_LEVEL ?? 'info';
|
|
78843
|
+
const defaultLogger = buildLogger('default', {
|
|
78844
|
+
level: (typeof LOG_LEVEL_ENV === 'string' ? parseInt(LOG_LEVEL_ENV) : LOG_LEVEL_ENV) ?? 10,
|
|
78845
|
+
rootComponent: globalThis.ENV?.LOG_ROOT_COMPONENT ?? 'logger',
|
|
78846
|
+
format: parseLogFormat(globalThis.ENV?.LOG_FORMAT),
|
|
78847
|
+
runtime: globalThis.ENV?.RUNTIME ?? 'development',
|
|
78848
|
+
});
|
|
78849
|
+
const log$1 = defaultLogger;
|
|
78850
|
+
globalThis.log = defaultLogger;
|
|
78851
|
+
|
|
78852
|
+
const customFormats = {
|
|
78853
|
+
number: {
|
|
78854
|
+
bytes: {
|
|
78855
|
+
style: 'decimal',
|
|
78856
|
+
maximumFractionDigits: 1,
|
|
78857
|
+
},
|
|
78858
|
+
temperature: {
|
|
78859
|
+
style: 'decimal',
|
|
78860
|
+
maximumFractionDigits: 0,
|
|
78861
|
+
},
|
|
78862
|
+
},
|
|
78863
|
+
date: {
|
|
78864
|
+
log: {
|
|
78865
|
+
dateStyle: undefined,
|
|
78866
|
+
timeStyle: 'medium',
|
|
78867
|
+
hourCycle: 'h24',
|
|
78868
|
+
},
|
|
78869
|
+
short: {
|
|
78870
|
+
dateStyle: 'short',
|
|
78871
|
+
timeStyle: 'short',
|
|
78872
|
+
},
|
|
78873
|
+
long: {
|
|
78874
|
+
dateStyle: 'long',
|
|
78875
|
+
timeStyle: 'long',
|
|
78876
|
+
},
|
|
78877
|
+
},
|
|
78878
|
+
};
|
|
78879
|
+
const onIntlError = (error) => {
|
|
78880
|
+
if (typeof window !== 'undefined') {
|
|
78881
|
+
log$1.fatal(error);
|
|
78882
|
+
}
|
|
78883
|
+
};
|
|
78884
|
+
const cache = createIntlCache();
|
|
78885
|
+
createIntl({
|
|
78886
|
+
locale: 'en-US',
|
|
78887
|
+
defaultLocale: 'en-US',
|
|
78888
|
+
formats: customFormats,
|
|
78889
|
+
onError: onIntlError,
|
|
78890
|
+
}, cache);
|
|
78891
|
+
|
|
78892
|
+
const useDebounce = (props) => {
|
|
78893
|
+
const { effect, dependencies, debounceDelay } = props;
|
|
78894
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
78895
|
+
const callback = React__default.useCallback(effect, dependencies);
|
|
78896
|
+
React__default.useEffect(() => {
|
|
78897
|
+
const timeout = setTimeout(callback, debounceDelay);
|
|
78898
|
+
return () => clearTimeout(timeout);
|
|
78899
|
+
}, [callback, debounceDelay]);
|
|
78900
|
+
};
|
|
78901
|
+
|
|
78902
|
+
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
78903
|
+
// License, v2.0. If a copy of the MPL was not distributed with this
|
|
78904
|
+
// file, You can obtain one at http://mozilla.org/MPL/2.0/
|
|
78905
|
+
|
|
78906
|
+
const DEBOUNCE_DELAY = 100; // milliseconds
|
|
78907
|
+
|
|
78908
|
+
function useDebouncedCursorPosition() {
|
|
78909
|
+
const [cursorPosition, setCursorPosition] = React__default.useState(null);
|
|
78910
|
+
const [rawPosition, setRawPosition] = React__default.useState(null);
|
|
78911
|
+
useDebounce({
|
|
78912
|
+
effect: () => {
|
|
78913
|
+
setCursorPosition(rawPosition);
|
|
78914
|
+
},
|
|
78915
|
+
dependencies: [rawPosition],
|
|
78916
|
+
debounceDelay: DEBOUNCE_DELAY
|
|
78917
|
+
});
|
|
78918
|
+
React__default.useEffect(() => {
|
|
78919
|
+
const handleMouseMove = e => {
|
|
78920
|
+
setRawPosition({
|
|
78921
|
+
x: e.clientX,
|
|
78922
|
+
y: e.clientY
|
|
78923
|
+
});
|
|
78924
|
+
};
|
|
78925
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
78926
|
+
return () => {
|
|
78927
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
78928
|
+
};
|
|
78929
|
+
}, []);
|
|
78930
|
+
return {
|
|
78931
|
+
cursorPosition
|
|
78932
|
+
};
|
|
78933
|
+
}
|
|
78934
|
+
|
|
78134
78935
|
const log = Logger.getLogger("src/index.ts");
|
|
78135
78936
|
const PANEL_STYLE = {
|
|
78136
78937
|
width: "100%",
|
|
@@ -78196,6 +78997,9 @@ function ThreeDeeRender(props) {
|
|
|
78196
78997
|
const backgroundColor = config.scene.backgroundColor;
|
|
78197
78998
|
const [canvas, setCanvas] = useState(null);
|
|
78198
78999
|
const [renderer, setRenderer] = useState(undefined);
|
|
79000
|
+
const {
|
|
79001
|
+
cursorPosition
|
|
79002
|
+
} = useDebouncedCursorPosition();
|
|
78199
79003
|
const rendererRef = useRef(undefined);
|
|
78200
79004
|
const {
|
|
78201
79005
|
enqueueSnackbar
|
|
@@ -78239,6 +79043,12 @@ function ThreeDeeRender(props) {
|
|
|
78239
79043
|
handleDrop: renderer.handleDrop
|
|
78240
79044
|
} : undefined);
|
|
78241
79045
|
}, [setMessagePathDropConfig, renderer]);
|
|
79046
|
+
useEffect(() => {
|
|
79047
|
+
if (props.handleCursorPositionUpdate && cursorPosition) {
|
|
79048
|
+
const offsetCoordinates = cursorPositionToRenderableOffsetPosition(cursorPosition);
|
|
79049
|
+
props.handleCursorPositionUpdate(cursorPosition, offsetCoordinates);
|
|
79050
|
+
}
|
|
79051
|
+
}, [cursorPosition]);
|
|
78242
79052
|
const [colorScheme, setColorScheme] = useState();
|
|
78243
79053
|
const [timezone, setTimezone] = useState();
|
|
78244
79054
|
const [topics, setTopics] = useState();
|
|
@@ -78753,15 +79563,15 @@ function ThreeDeeRender(props) {
|
|
|
78753
79563
|
// The 3d panel only supports publishing to ros1 and ros2 data sources
|
|
78754
79564
|
const isRosDataSource = context.dataSourceProfile === "ros1" || context.dataSourceProfile === "ros2";
|
|
78755
79565
|
const canPublish = context.publish != undefined && isRosDataSource;
|
|
78756
|
-
const
|
|
79566
|
+
const cursorPositionToRenderableOffsetPosition = useCallback(cursorCoordinates => {
|
|
78757
79567
|
if (!canvas || !renderer) return;
|
|
78758
79568
|
|
|
78759
79569
|
// Get the canvas bounding rectangle
|
|
78760
79570
|
const canvasRect = canvas.getBoundingClientRect();
|
|
78761
79571
|
|
|
78762
79572
|
// Convert click position to canvas-relative coordinates
|
|
78763
|
-
const offsetX =
|
|
78764
|
-
const offsetY =
|
|
79573
|
+
const offsetX = cursorCoordinates.x - canvasRect.left;
|
|
79574
|
+
const offsetY = cursorCoordinates.y - canvasRect.top;
|
|
78765
79575
|
|
|
78766
79576
|
// Get Three.js clicked object (This should be the background for depth stream)
|
|
78767
79577
|
const selectedObject = renderer.handleClickEvent(new Vector2(offsetX, offsetY)).at(0);
|
|
@@ -78772,7 +79582,7 @@ function ThreeDeeRender(props) {
|
|
|
78772
79582
|
|
|
78773
79583
|
// Calculate the percentage offset coordinates relative to the renderable
|
|
78774
79584
|
// This is number from <0, 1> range and can be used to map click position to depth data
|
|
78775
|
-
const percentageOffsetCoordinates = renderer.
|
|
79585
|
+
const percentageOffsetCoordinates = renderer.getCursorRelativeCoords(cursorCoordinates, selectedObject.renderable);
|
|
78776
79586
|
if (!percentageOffsetCoordinates) {
|
|
78777
79587
|
console.error("Failed to calculate relative click coordinates");
|
|
78778
79588
|
return;
|
|
@@ -78799,7 +79609,10 @@ function ThreeDeeRender(props) {
|
|
|
78799
79609
|
},
|
|
78800
79610
|
onClick: event => {
|
|
78801
79611
|
if (props.handleOnClick) {
|
|
78802
|
-
const clickOffsetCoords =
|
|
79612
|
+
const clickOffsetCoords = cursorPositionToRenderableOffsetPosition({
|
|
79613
|
+
x: event.clientX,
|
|
79614
|
+
y: event.clientY
|
|
79615
|
+
});
|
|
78803
79616
|
props.handleOnClick(event, clickOffsetCoords);
|
|
78804
79617
|
}
|
|
78805
79618
|
}
|
|
@@ -78841,6 +79654,7 @@ function initPanel(args, context) {
|
|
|
78841
79654
|
frameRenderedEvent,
|
|
78842
79655
|
annotationReceivedEventHandler,
|
|
78843
79656
|
handleOnClick,
|
|
79657
|
+
handleCursorPositionUpdate,
|
|
78844
79658
|
registerRendered,
|
|
78845
79659
|
unregisterRendered,
|
|
78846
79660
|
customOverlay
|
|
@@ -78858,6 +79672,7 @@ function initPanel(args, context) {
|
|
|
78858
79672
|
frameRenderedEvent: frameRenderedEvent ? () => frameRenderedEvent(0) : undefined,
|
|
78859
79673
|
annotationReceivedEventHandler: annotationReceivedEventHandler,
|
|
78860
79674
|
handleOnClick: handleOnClick,
|
|
79675
|
+
handleCursorPositionUpdate: handleCursorPositionUpdate,
|
|
78861
79676
|
registerRendered: registerRendered,
|
|
78862
79677
|
unregisterRendered: unregisterRendered,
|
|
78863
79678
|
customOverlay: customOverlay
|
|
@@ -78892,6 +79707,7 @@ function ThreeDeeRenderAdapter(interfaceMode, props) {
|
|
|
78892
79707
|
frameRenderedEvent: props.frameRenderedEvent,
|
|
78893
79708
|
annotationReceivedEventHandler: props.annotationReceivedEventHandler,
|
|
78894
79709
|
handleOnClick: props.handleOnClick,
|
|
79710
|
+
handleCursorPositionUpdate: props.handleCursorPositionUpdate,
|
|
78895
79711
|
registerRendered: props.registerRendered,
|
|
78896
79712
|
unregisterRendered: props.unregisterRendered,
|
|
78897
79713
|
customOverlay: props.customOverlay
|