Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
159 commits
Select commit Hold shift + click to select a range
aa71bf7
remove redundant state variable
raltunel Jul 9, 2025
18ac613
add liq chart ob liq section
zcelbirPlabs Jul 10, 2025
06688b7
add resolution combo, fix sizing, add loader
raltunel Jul 14, 2025
ba79697
move dep
raltunel Jul 14, 2025
39e0493
add interpolate method for liq chart
raltunel Jul 15, 2025
1750279
fix negative num issue while generating mid-slots
raltunel Jul 16, 2025
8a743a7
merge
raltunel Jul 16, 2025
4053ce7
animate chart
raltunel Jul 16, 2025
fbeb572
fix redundant anim calls
raltunel Jul 16, 2025
10643e3
add liq lines, fix coloring, add animation for liq
raltunel Jul 18, 2025
fa47c5f
Merge branch 'ob-liq-chart-animation' into ob-liq-chart-changes
raltunel Jul 18, 2025
50c2b1b
Merge branch 'ob-liq-chart-changes' into ob-liquidity-chart
raltunel Jul 18, 2025
8c3d88e
animate liq lines
raltunel Jul 18, 2025
0714d5b
resolve conflicts
raltunel Jul 23, 2025
de4e346
fix btn render
raltunel Jul 23, 2025
eba9ac7
remove statemanagement from liqChart component
raltunel Jul 25, 2025
f3885ff
change liqLines drawing
raltunel Jul 25, 2025
e910933
move random data gen to component, add gap
raltunel Jul 25, 2025
6dc0eda
add width height to useEffect deps
raltunel Jul 25, 2025
20916ad
merge
raltunel Jul 25, 2025
ebaa376
fix alignment with orderbook section
raltunel Jul 25, 2025
d6bf6a9
change mid gap
raltunel Jul 25, 2025
165c7d5
change start gap
raltunel Jul 25, 2025
0da6276
merge
raltunel Jul 25, 2025
cc86c40
fix height of chart
raltunel Jul 28, 2025
f743628
show liq line prices
raltunel Jul 28, 2025
ed6cac6
fix alignment
raltunel Jul 28, 2025
ec4b1de
fix redraw issue on liq, add pause action for anim
raltunel Jul 29, 2025
dfd07a4
fix interpolation method, add min length for liq lines
raltunel Jul 29, 2025
2b443bb
add midline, handle color change
raltunel Jul 29, 2025
9a485a3
remove redundant useEffect dep
raltunel Jul 29, 2025
fb53df9
Merge branch 'ob-liq-fixes' into ob-liquidity-chart
raltunel Jul 29, 2025
213d9a1
reduce mid gap
raltunel Jul 29, 2025
9cfed5f
fix resolution change bug once array sizes are not eq
raltunel Jul 29, 2025
b848a0b
Merge branch 'develop' into ob-liquidity-chart
benwolski Jul 29, 2025
a164dcf
Merge branch 'develop' into ob-liquidity-chart
benwolski Jul 29, 2025
ed86a99
bugfix/ liq line alignment
zcelbirPlabs Jul 30, 2025
e174491
Merge branch 'pb-liquidity-chart' into ob-liquidity-chart
raltunel Jul 30, 2025
cd4b204
Merge branch 'develop' into ob-liquidity-chart
benwolski Jul 30, 2025
961c5d2
recalculate with orderCount instead of rowHeight
zcelbirPlabs Jul 31, 2025
ab84163
Merge branch 'pb-liquidity-chart' into ob-liquidity-chart
raltunel Jul 31, 2025
4484498
add hover effect on liq chart
zcelbirPlabs Aug 8, 2025
922a9d7
tooltip placement
zcelbirPlabs Aug 13, 2025
4c45d64
snapped price for tooltip
zcelbirPlabs Aug 13, 2025
725ca40
Merge branch 'ob-liq-chart-hover' into ob-liquidity-chart
raltunel Aug 13, 2025
53438f0
merge1
raltunel Aug 13, 2025
5146474
move lines to antoher canvas and change clipping to darken hovered area
zcelbirPlabs Aug 14, 2025
0aa38b7
bugfix/ liq lines dissappers on trade tab
zcelbirPlabs Aug 14, 2025
2557238
Merge branch 'ob-liquidity-chart-darker-hover' into ob-liquidity-chart
raltunel Aug 14, 2025
7ed3bdc
add exclusive menu items for liq chart mode
zcelbirPlabs Aug 15, 2025
83030e1
add number formating and dynamic percentage for tooltip
zcelbirPlabs Aug 15, 2025
959d352
Merge branch 'ob-liq-chart-mode-selections' into ob-liquidity-chart
raltunel Aug 15, 2025
1e806be
change coloring logic for hovering on liq chart
raltunel Aug 20, 2025
6657e4d
merge
raltunel Aug 21, 2025
356f8e9
fix coloring issue which triggered once selected theme has been changed
raltunel Aug 21, 2025
791ed60
Merge branch 'develop' into ob-liquidity-chart
benwolski Aug 21, 2025
6a8cc1b
implement liquidation lines with mock data
tncoskun Aug 25, 2025
2868f77
fix hoveing bug for closest snap value
zcelbirPlabs Aug 26, 2025
2037b37
Change the color of the area opposite the selected area
zcelbirPlabs Aug 26, 2025
147c0f8
improved liq lines rendering while zoom
tncoskun Aug 26, 2025
eb5fbca
Merge branch 'ob-liq-chart-mode-selections' into ob-liquidity-chart
raltunel Aug 26, 2025
68b7733
liqudation lines use useOrderBookStore data
tncoskun Aug 26, 2025
84f5cd4
Merge branch 'liquidation-lines' into ob-liquidity-chart
raltunel Aug 26, 2025
527d626
Merge branch 'develop' into ob-liquidity-chart
benwolski Aug 26, 2025
e427f68
bugfix/ fix line size on canvas size change
zcelbirPlabs Aug 28, 2025
9740628
Merge branch 'ob-liq-line-resize' into ob-liquidity-chart
raltunel Aug 28, 2025
0407dcb
user order lines moved to the top of all canvases
tncoskun Sep 2, 2025
4511d45
add tooltip to chart overlay pane
zcelbirPlabs Sep 3, 2025
ca014ed
Merge branch 'ob-liquidity-chart' into user-order-lines-canvas-move-t…
tncoskun Sep 3, 2025
c928b8e
Change tooltip css
zcelbirPlabs Sep 3, 2025
2c2fb36
Merge branch 'ob-liq-chart-tooltip' into ob-liquidity-chart
raltunel Sep 3, 2025
1c8c61a
fixed: correct order line rendering on log scale
tncoskun Sep 4, 2025
93997f1
fixed: correct liq lines rendering on log scale
tncoskun Sep 4, 2025
7895121
Merge branch 'ob-liquidity-chart' into user-order-lines-canvas-move-t…
tncoskun Sep 4, 2025
0aecef3
fixed: liq lines not following zoom
tncoskun Sep 4, 2025
7beb251
fixed : label location rendering on log scale
tncoskun Sep 4, 2025
3687306
fixed : liq lines tooltip location
tncoskun Sep 4, 2025
68aa2cf
removed unnecessary codes
tncoskun Sep 4, 2025
ad57724
Merge branch 'user-order-lines-canvas-move-to-top' into ob-liquidity-…
raltunel Sep 5, 2025
184ab99
adjust tooltip placement when line precision changes
zcelbirPlabs Sep 5, 2025
4b9bbc0
fixed: order lines rendering for macbook
tncoskun Sep 5, 2025
eb21157
Merge branch 'user-order-lines-canvas-move-to-top' into ob-liquidity-…
raltunel Sep 5, 2025
b228ac1
Merge branch 'ob-liquidity-chart' of https://github.com/raltunel/perp…
zcelbirPlabs Sep 5, 2025
63fbab8
reduced opacity of liq lines
tncoskun Sep 9, 2025
300c65a
Merge branch 'liq-lines-opacity' into ob-liquidity-chart
raltunel Sep 9, 2025
69cd5e0
Merge branch 'develop' into fix/conflict-liq
tncoskun Sep 10, 2025
80765de
Merge branch 'fix/conflict-ob-liq-chart' into ob-liquidity-chart
raltunel Sep 10, 2025
b2766a9
Merge branch 'develop' into fix-merge-conflict-ob
tncoskun Sep 10, 2025
f8948e1
Merge branch 'fix-merge-conflict-ob' into ob-liquidity-chart
raltunel Sep 10, 2025
d1ea740
Merge branch 'ob-liquidity-chart' of https://github.com/raltunel/perp…
zcelbirPlabs Sep 10, 2025
94b4577
Merge remote-tracking branch 'zek_cengiz/ob-liq-chart-tooltip' into o…
raltunel Sep 10, 2025
faedd06
fixed : chart not showing on mobile
tncoskun Sep 10, 2025
9755ae8
Merge remote-tracking branch 'tugce/fix-conflict-for-ob-liq-mobile' i…
raltunel Sep 10, 2025
2a2c21b
reload basic menu with liquidations preferance
zcelbirPlabs Sep 11, 2025
40bbbd9
Merge branch 'develop' into ob-liquidity-chart
benwolski Sep 11, 2025
52e070c
unsubscribe chart event when liq is not active
zcelbirPlabs Sep 12, 2025
a5d4eb9
adjust liq chart padding
zcelbirPlabs Sep 17, 2025
4116b60
add limit line label tooltip
zcelbirPlabs Sep 18, 2025
b2fee1c
Merge branch 'ob-liq-chart-tooltip' into ob-liquidity-chart
raltunel Sep 18, 2025
dc64de2
Merge branch 'develop' into ob-liquidity-chart
benwolski Sep 25, 2025
9a936c1
remove duplicate ref
benwolski Sep 25, 2025
0a0d470
fix duplicate const
benwolski Sep 25, 2025
8a5be21
add lazy loading for d3 and d3fc
tncoskun Sep 26, 2025
b7a0b47
Merge branch 'd3-d3fc-lazy-loading' into ob-liquidity-chart
raltunel Sep 26, 2025
b1e34cc
Merge branch 'develop' into ob-liquidity-chart
benwolski Sep 26, 2025
14bf655
Merge branch 'ob-liquidity-chart' into liq-conflict
tncoskun Sep 30, 2025
82281eb
Merge remote-tracking branch 'tugce/liq-conflict' into ob-liquidity-c…
raltunel Sep 30, 2025
de78d82
Merge pull request #713 from tncoskun/liq-conflict
benwolski Sep 30, 2025
969cbfd
Merge branch 'develop' into ob-liquidity-chart
benwolski Oct 1, 2025
ee161f7
Merge branch 'develop' into ob-liquidity-chart
benwolski Oct 1, 2025
c85cec8
Merge branch 'develop' into change-liquidity-line-thickness
tncoskun Oct 2, 2025
0b904a0
all liq lines use same thickness
tncoskun Oct 2, 2025
f884b3f
reduced liquidation line thickness
tncoskun Oct 2, 2025
b308401
liq toolitp should close when candle tooltip opened
zcelbirPlabs Oct 2, 2025
a291210
Merge pull request #720 from tncoskun/change-liquidity-line-thickness
benwolski Oct 2, 2025
71e1cd0
Merge branch 'ob-liquidity-chart' of https://github.com/CrocSwap/perp…
zcelbirPlabs Oct 3, 2025
ae5cf10
LiqLineTooltip: include system default number format
zcelbirPlabs Oct 3, 2025
89afaf5
add dynamic grouping (100 rows) for liquidation lines
tncoskun Oct 3, 2025
e622670
Merge branch 'ob-liquidity-chart' into liq-lines-zoom-binning
tncoskun Oct 3, 2025
00f1c89
removed dash from liquidation lines
tncoskun Oct 6, 2025
361448c
fixed : liq tooltip not showing
tncoskun Oct 6, 2025
eab3e44
added liqValue to HorizontalLineData type
tncoskun Oct 6, 2025
69cc2f2
fix : order book / liquidity chart resizable
tncoskun Oct 6, 2025
d76e5a8
Merge pull request #725 from tncoskun/fix-order-book-resizable
benwolski Oct 6, 2025
885f8b5
Merge branch 'ob-liquidity-chart' into liq-lines-zoom-binning
benwolski Oct 6, 2025
b4d227f
Merge pull request #724 from tncoskun/liq-lines-zoom-binning
benwolski Oct 7, 2025
9e11ee0
remove liq line tooltip on chart tooltip
zcelbirPlabs Oct 7, 2025
dba232e
Merge pull request #721 from zcelbirPlabs/liq-line-tooltip-close-on-c…
benwolski Oct 7, 2025
dc30be8
make liquidation lines more opaque from left to right
tncoskun Oct 8, 2025
775a2f6
lines should be recalculated for tooltip after zoom event
zcelbirPlabs Oct 8, 2025
8006d4e
Merge pull request #733 from zcelbirPlabs/ob-liq-chart-liq-line-zoom-…
benwolski Oct 8, 2025
28be434
Merge pull request #731 from tncoskun/liq-lines-gradient
benwolski Oct 8, 2025
862554a
liq line tooltip should be over order lines
zcelbirPlabs Oct 9, 2025
2252f48
Merge pull request #738 from zcelbirPlabs/ob-liq-tooltip-stack-over
benwolski Oct 9, 2025
f812a10
Merge branch 'develop' into ob-liquidity-chart
benwolski Oct 9, 2025
cf1654d
liq tooltip should be hidden when user leave canvas
zcelbirPlabs Oct 10, 2025
ad35a6f
tooltip should be removed when user leaves canvas
zcelbirPlabs Oct 13, 2025
e21ce13
Merge pull request #745 from zcelbirPlabs/ob-liq-tooltip-stack-over
benwolski Oct 13, 2025
0ad5fa1
Merge branch 'develop' into check-liq-tooltip-values
tncoskun Oct 14, 2025
a3f5f05
added required type declarations for liq lines branch
tncoskun Oct 14, 2025
8dc1378
show real liquidation value in tooltip
tncoskun Oct 14, 2025
76abe47
Merge branch 'develop' into ob-liquidity-chart
benwolski Oct 14, 2025
e2762a6
Merge branch 'ob-liquidity-chart' into liq-tooltip-use-real-value
benwolski Oct 14, 2025
ca89406
added Long/Short type value to liquidation lines data
tncoskun Oct 14, 2025
cdbaf2c
Merge remote-tracking branch 'origin/liq-tooltip-use-real-value' into…
tncoskun Oct 14, 2025
5d9badb
Merge pull request #747 from tncoskun/liq-tooltip-use-real-value
benwolski Oct 14, 2025
2a58da1
bugfix/ fix the bug when main pane changes layers tooltip is misplaced
zcelbirPlabs Oct 15, 2025
41af018
Merge pull request #750 from zcelbirPlabs/ob-liq-tooltip-pane-switch
benwolski Oct 15, 2025
9f81250
Merge branch 'develop' into fix-conflict-ob-liq-chart
tncoskun Oct 17, 2025
3bc4468
Merge pull request #755 from tncoskun/fix-conflict-ob-liq-chart
benwolski Oct 17, 2025
db530af
add tooltio vertical placement fix
zcelbirPlabs Oct 22, 2025
cbd0a14
Recalculat Line positions with css variables
zcelbirPlabs Oct 24, 2025
c04b94e
change top gap for liq lines
zcelbirPlabs Oct 30, 2025
7907c82
recalculate line placement for ob liq chart
zcelbirPlabs Oct 30, 2025
6476570
adjust middle header gap
zcelbirPlabs Oct 30, 2025
c0b99e2
adjust middle line placement
zcelbirPlabs Oct 30, 2025
2997368
Merge pull request #785 from zcelbirPlabs/ob-liq-chart-toolitp-placement
benwolski Oct 31, 2025
be212c2
Merge branch 'develop' into ob-liquidity-chart
benwolski Nov 3, 2025
fcd9262
Merge branch 'develop' of https://github.com/CrocSwap/perps-app into …
benwolski Nov 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions packages/frontend/app/components/BasicMenu/BasicMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import styles from './BasicMenu.module.css';
export interface BasicMenuItemIF {
label: string;
listener: () => void;
exclude?: boolean;
}

interface BasicMenuProps {
Expand Down Expand Up @@ -41,18 +42,21 @@ const BasicMenu: React.FC<BasicMenuProps> = ({
<div
className={`${styles.menuContainer} ${styles[positionVertical]} ${styles[positionHorizontal]}`}
>
{items.map((item, index) => (
<div
key={index}
className={styles.menuItem}
onClick={() => {
item.listener();
setIsOpen(false);
}}
>
{item.label}
</div>
))}
{items.map(
(item, index) =>
!item.exclude && (
<div
key={index}
className={styles.menuItem}
onClick={() => {
item.listener();
setIsOpen(false);
}}
>
{item.label}
</div>
),
)}
</div>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export default function ComboBoxContainer() {
setUseMockLeverage,
mockMinimumLeverage,
setMockMinimumLeverage,
pauseLiqAnimation,
setPauseLiqAnimation,
} = useDebugStore();

const currencies = ['USD', 'BTC', 'ETH'];
Expand Down Expand Up @@ -143,7 +145,6 @@ export default function ComboBoxContainer() {
</div>
<div className={styles.divider} />
</div>

<HorizontalScrollable
excludes={['debug-wallet-static-area']}
wrapperId='trade-page-left-section'
Expand Down Expand Up @@ -277,7 +278,10 @@ export default function ComboBoxContainer() {
target: userWalletKey,
},
);
console.log({ ix, sessionState });
console.log({
ix,
sessionState,
});
const result =
await sessionState.sendTransaction(
[ix],
Expand All @@ -291,6 +295,42 @@ export default function ComboBoxContainer() {
</button>
</div>
)}
<div className={styles.subInfo}>{userAddress}</div>
<div className={styles.divider} />
{isEstablished(sessionState) && (
<button
onClick={() => {
(async () => {
if (isEstablished(sessionState)) {
console.log('established');
const userWalletKey =
sessionState.walletPublicKey ||
sessionState.sessionPublicKey;
const ix = instructions.pingIx(42n, {
actor: sessionState.sessionPublicKey,
target: userWalletKey,
});
console.log({ ix, sessionState });
const result =
await sessionState.sendTransaction([
ix,
]);
console.log({ result });
}
})();
}}
>
Ping
</button>
)}
<div
className={`${styles.wsToggle} ${pauseLiqAnimation ? styles.wsToggleRunning : styles.wsTogglePaused}`}
onClick={() => setPauseLiqAnimation(!pauseLiqAnimation)}
>
<div className={styles.wsToggleButton}>
{pauseLiqAnimation ? 'Pause Liq' : 'Pause Liq'}
</div>
</div>
</div>
</HorizontalScrollable>
</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ import React, { useEffect, useState } from 'react';
import { TradingViewProvider } from '~/contexts/TradingviewContext';
import TradingViewChart from '~/routes/chart/chart';
import { loadTradingViewLibrary } from '~/routes/chart/lazyLoading/useLazyTradingview';
import OverlayCanvas from '~/routes/chart/overlayCanvas/overlayCanvas';
import LiquidationOverlayCanvas from '~/routes/chart/overlayCanvas/LiqudationOverlayCanvas';
import OrderLinesOverlayCanvas from '~/routes/chart/overlayCanvas/OrderLinesOverlayCanvas';
import { useAppStateStore } from '~/stores/AppStateStore';
import styles from './chartLoading.module.css';

const TradingViewWrapper: React.FC = () => {
const { liquidationsActive } = useAppStateStore();

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const [tvLib, setTvLib] = useState<any>(null);
const [chartLoadingStatus, setChartLoadingStatus] = useState<
Expand Down Expand Up @@ -56,7 +60,8 @@ const TradingViewWrapper: React.FC = () => {
setChartLoadingStatus={setChartLoadingStatus}
>
<TradingViewChart />
<OverlayCanvas />
{liquidationsActive && <LiquidationOverlayCanvas />}
<OrderLinesOverlayCanvas />
</TradingViewProvider>
)}
</div>
Expand Down
122 changes: 59 additions & 63 deletions packages/frontend/app/contexts/TradingviewContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
getChartDefaultColors,
getChartThemeColors,
mapI18nToTvLocale,
getLiquidationsSvgIcon,
priceFormatterFactory,
type ChartLayout,
} from '~/routes/chart/data/utils/utils';
Expand Down Expand Up @@ -120,6 +121,8 @@ export const TradingViewProvider: React.FC<{
setChartState(res);
}, [i18n.language]);

const { liquidationsActive, setLiquidationsActive } = useAppStateStore();

const defaultProps: Omit<ChartContainerProps, 'container'> = {
symbolName: 'BTC',
libraryPath: '/tv/charting_library/',
Expand Down Expand Up @@ -286,70 +289,63 @@ export const TradingViewProvider: React.FC<{

tvWidget.headerReady().then(() => {
setChartLoadingStatus('ready');
const liquidationsButton = tvWidget.createButton();

let isToggled = liquidationsActive;

const updateButtonStyle = () => {
const svg = getLiquidationsSvgIcon(
isToggled ? '#7371fc' : '#cbcaca',
);
liquidationsButton.style.color = isToggled
? '#7371fc'
: '#cbcaca';

liquidationsButton.innerHTML = `
<span class="liquidations-wrapper" style="display: flex; align-items: center;border-radius:4px;padding:5px">
${svg}
<span style="padding-left:3px"> Liquidations
</span>`;
};

updateButtonStyle();

const onClick = () => {
isToggled = !isToggled;
setLiquidationsActive(isToggled);
updateButtonStyle();
};
const onMouseEnter = () => {
const wrapper = liquidationsButton.querySelector(
'.liquidations-wrapper',
) as HTMLDivElement;
if (wrapper) {
wrapper.style.backgroundColor = '#313030';
}
};
const onMouseLeave = () => {
const wrapper = liquidationsButton.querySelector(
'.liquidations-wrapper',
) as HTMLDivElement;
if (wrapper) wrapper.style.backgroundColor = 'transparent';
};

liquidationsButton.addEventListener('click', onClick);
liquidationsButton.addEventListener('mouseenter', onMouseEnter);
liquidationsButton.addEventListener('mouseleave', onMouseLeave);

return () => {
liquidationsButton.removeEventListener('click', onClick);
liquidationsButton.removeEventListener(
'mouseenter',
onMouseEnter,
);
liquidationsButton.removeEventListener(
'mouseleave',
onMouseLeave,
);
};
});
// tvWidget.headerReady().then(() => {
// const liquidationsButton = tvWidget.createButton();

// let isToggled = false;

// const updateButtonStyle = () => {
// const svg = getLiquidationsSvgIcon(
// isToggled ? '#7371fc' : '#cbcaca',
// );
// liquidationsButton.style.color = isToggled
// ? '#7371fc'
// : '#cbcaca';

// liquidationsButton.innerHTML = `
// <span class="liquidations-wrapper" style="display: flex; align-items: center;border-radius:4px;padding:5px">
// ${svg}
// <span style="padding-left:3px"> Liquidations
// </span>`;
// };

// updateButtonStyle();

// const onClick = () => {
// isToggled = !isToggled;
// updateButtonStyle();

// if (isToggled) {
// console.log('Open');
// } else {
// console.log('Close');
// }
// };
// const onMouseEnter = () => {
// const wrapper = liquidationsButton.querySelector(
// '.liquidations-wrapper',
// ) as HTMLDivElement;
// if (wrapper) {
// wrapper.style.backgroundColor = '#313030';
// }
// };
// const onMouseLeave = () => {
// const wrapper = liquidationsButton.querySelector(
// '.liquidations-wrapper',
// ) as HTMLDivElement;
// if (wrapper) wrapper.style.backgroundColor = 'transparent';
// };

// liquidationsButton.addEventListener('click', onClick);
// liquidationsButton.addEventListener('mouseenter', onMouseEnter);
// liquidationsButton.addEventListener('mouseleave', onMouseLeave);

// return () => {
// liquidationsButton.removeEventListener('click', onClick);
// liquidationsButton.removeEventListener(
// 'mouseenter',
// onMouseEnter,
// );
// liquidationsButton.removeEventListener(
// 'mouseleave',
// onMouseLeave,
// );
// };
// });

tvWidget.onChartReady(() => {
/**
Expand Down
21 changes: 21 additions & 0 deletions packages/frontend/app/routes/chart/data/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { DetailedHTMLProps, HTMLAttributes } from 'react';
import { bsColorSets, type colorSetIF } from '~/stores/AppSettingsStore';
import type { ResolutionString } from '~/tv/charting_library';

Expand All @@ -8,6 +9,26 @@ import type {
LibrarySymbolInfo,
} from '~/tv/charting_library';

declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace JSX {
interface IntrinsicElements {
'd3fc-group': DetailedHTMLProps<
HTMLAttributes<HTMLDivElement>,
HTMLDivElement
>;
'd3fc-svg': DetailedHTMLProps<
HTMLAttributes<HTMLDivElement>,
HTMLDivElement
>;
'd3fc-canvas': DetailedHTMLProps<
HTMLAttributes<HTMLCanvasElement | HTMLDivElement>,
HTMLCanvasElement | HTMLDivElement
>;
}
}
}

export type ChartLayout = {
chartLayout: object;
interval: string;
Expand Down
34 changes: 34 additions & 0 deletions packages/frontend/app/routes/chart/hooks/useLazyD3.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { useEffect, useState } from 'react';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
let cachedLibs: { d3: any; d3fc: any } | null = null;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
let loadingPromise: Promise<{ d3: any; d3fc: any }> | null = null;

export function useLazyD3() {
const [libs, setLibs] = useState<typeof cachedLibs>(cachedLibs);

useEffect(() => {
if (cachedLibs) {
setLibs(cachedLibs);
return;
}

if (!loadingPromise) {
loadingPromise = (async () => {
const [d3, d3fc] = await Promise.all([
import('d3'),
import('d3fc'),
]);
cachedLibs = { d3, d3fc };
return cachedLibs;
})();
}

loadingPromise.then((libs) => {
setLibs(libs);
});
}, []);

return libs;
}
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,33 @@ declare module '~/tv/charting_library' {
export interface CustomThemes {
[name: string]: CustomThemeColors;
}

export interface MouseEventParams {
clientX: number;
clientY: number;
pageX: number;
pageY: number;
screenX: number;
screenY: number;
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export interface ISubscription<TFunc extends (...args: any[]) => void> {
subscribe(
obj: object | null,
member: TFunc,
singleshot?: boolean,
): void;
unsubscribe(obj: object | null, member: TFunc): void;
unsubscribeAll(obj: object | null): void;
}

export interface CrossHairMovedEventParams {
time: number;
price: number;
userTime?: number;
entityValues?: Record<EntityId, CrossHairMovedEventSource>;
offsetX?: number;
offsetY?: number;
}
}
Loading