@forgecharts/sdk 1.5.70 → 1.5.72

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.
@@ -3,7 +3,32 @@ import { TextStyle, Application, Container, Graphics, Text, FillGradient, Canvas
3
3
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
4
4
  import ReactDOM, { createPortal } from 'react-dom';
5
5
 
6
- // src/react/canvas/ChartCanvas.tsx
6
+ // src/react/persistence/kitPreferencesApi.ts
7
+ function createKitPreferencesApi(cfg) {
8
+ const base = cfg.apiUrl.replace(/\/$/, "");
9
+ const authed = async () => {
10
+ const token = await cfg.getAuthToken();
11
+ return {
12
+ "Content-Type": "application/json",
13
+ ...token ? { Authorization: `Bearer ${token}` } : {}
14
+ };
15
+ };
16
+ return {
17
+ async get() {
18
+ const res = await fetch(`${base}/api/preferences`, { headers: await authed() });
19
+ if (!res.ok) throw new Error(`preferences load failed (${res.status})`);
20
+ return await res.json();
21
+ },
22
+ async put(data) {
23
+ const res = await fetch(`${base}/api/preferences`, {
24
+ method: "PUT",
25
+ headers: await authed(),
26
+ body: JSON.stringify(data)
27
+ });
28
+ if (!res.ok) throw new Error(`preferences save failed (${res.status})`);
29
+ }
30
+ };
31
+ }
7
32
 
8
33
  // ../shared/src/time/timeframeRegistry.ts
9
34
  function isCalendarTimeframe(key) {
@@ -18342,7 +18367,7 @@ var DEMONSTRATION_STROKE = "rgba(255, 200, 50, 0.7)";
18342
18367
  var DEMONSTRATION_COLOR = "var(--crosshair-overlay, rgba(255,255,255,0.75))";
18343
18368
 
18344
18369
  // src/version.ts
18345
- var FORGECHARTS_VERSION = "1.5.70" ;
18370
+ var FORGECHARTS_VERSION = "1.5.72" ;
18346
18371
  function applyRuntimeConfig(caps, config) {
18347
18372
  if (!config) return caps;
18348
18373
  const orderEntry = config.enableOrderEntry === false ? false : caps.orderEntry;
@@ -18569,11 +18594,19 @@ var _listeners = /* @__PURE__ */ new Set();
18569
18594
  var _subscribed = /* @__PURE__ */ new Set();
18570
18595
  var _reconnectTimer = null;
18571
18596
  var _authToken = null;
18597
+ var _baseUrl = null;
18572
18598
  function setWsAuthToken(token) {
18573
18599
  _authToken = token;
18574
18600
  }
18601
+ function setWsBaseUrl(url) {
18602
+ if (!url) {
18603
+ _baseUrl = null;
18604
+ return;
18605
+ }
18606
+ _baseUrl = url.replace(/\/$/, "").replace(/^http/, "ws");
18607
+ }
18575
18608
  function _wsUrl() {
18576
- const base = typeof window === "undefined" ? "ws://localhost:4001/ws" : `${window.location.protocol === "https:" ? "wss" : "ws"}://${window.location.host}/ws`;
18609
+ const base = _baseUrl ?? (typeof window === "undefined" ? "ws://localhost:4001/ws" : `${window.location.protocol === "https:" ? "wss" : "ws"}://${window.location.host}/ws`);
18577
18610
  return _authToken ? `${base}?token=${encodeURIComponent(_authToken)}` : base;
18578
18611
  }
18579
18612
  function _send(msg) {
@@ -23177,6 +23210,7 @@ var ChartCanvas = forwardRef(
23177
23210
  providerKey,
23178
23211
  initialActiveTool,
23179
23212
  onPointerToolChange,
23213
+ initialPointerTool,
23180
23214
  initialMagnetMode,
23181
23215
  onMagnetModeChange,
23182
23216
  drawingFavorites: drawingFavoritesProp,
@@ -24313,6 +24347,12 @@ var ChartCanvas = forwardRef(
24313
24347
  const handleToolSelectRef = useRef(handleToolSelect);
24314
24348
  handleToolSelectRef.current = handleToolSelect;
24315
24349
  selectPointerToolRef.current = handleToolSelect;
24350
+ const initialPointerAppliedRef = useRef(false);
24351
+ useEffect(() => {
24352
+ if (initialPointerAppliedRef.current || !initialPointerTool) return;
24353
+ initialPointerAppliedRef.current = true;
24354
+ selectPointerToolRef.current(initialPointerTool);
24355
+ }, [initialPointerTool]);
24316
24356
  const handleMagnetModeChange = useCallback((mode) => {
24317
24357
  setMagnetMode(mode);
24318
24358
  chartRef.current?.setMagnetMode(mode);
@@ -31486,6 +31526,8 @@ function ChartWorkspace({
31486
31526
  symbolResolver,
31487
31527
  rollRule,
31488
31528
  onRollRuleChange,
31529
+ quotesWsUrl,
31530
+ getQuotesAuthToken,
31489
31531
  extraTfGroups,
31490
31532
  // RightToolbar
31491
31533
  watchlistOpen,
@@ -31542,6 +31584,27 @@ function ChartWorkspace({
31542
31584
  tradingBridge,
31543
31585
  tradingOverlayStore
31544
31586
  }) {
31587
+ const [quotesReady, setQuotesReady] = React11.useState(false);
31588
+ React11.useEffect(() => {
31589
+ let cancelled = false;
31590
+ if (!quotesWsUrl || !getQuotesAuthToken) {
31591
+ setQuotesReady(false);
31592
+ return void 0;
31593
+ }
31594
+ void (async () => {
31595
+ try {
31596
+ const token = await getQuotesAuthToken();
31597
+ if (cancelled) return;
31598
+ setWsAuthToken(token || null);
31599
+ setWsBaseUrl(quotesWsUrl);
31600
+ setQuotesReady(true);
31601
+ } catch {
31602
+ }
31603
+ })();
31604
+ return () => {
31605
+ cancelled = true;
31606
+ };
31607
+ }, [quotesWsUrl, getQuotesAuthToken]);
31545
31608
  const capabilities = useChartCapabilities();
31546
31609
  const dataBlocked = useLicenseDataBlocked();
31547
31610
  useHostLicense(hostApiUrl, getAuthToken);
@@ -31722,7 +31785,7 @@ function ChartWorkspace({
31722
31785
  onClose: closeWatchlist,
31723
31786
  onSelectSymbol: onSymbolChange,
31724
31787
  symbolResolver,
31725
- liveQuotes: false,
31788
+ liveQuotes: quotesReady,
31726
31789
  ...hostApiUrl !== void 0 ? { apiUrl: hostApiUrl } : {},
31727
31790
  ...getAuthToken !== void 0 ? { getAuthToken } : {}
31728
31791
  }
@@ -37897,6 +37960,6 @@ function IndicatorPane({
37897
37960
  ] });
37898
37961
  }
37899
37962
 
37900
- export { AgentFAB, AgentProvider, AssistantPanel, BottomToolbar, ChartCanvas, ChartContextMenu, ChartSettingsDialog, ChartWorkspace, CommandDispatcher, DEFAULT_FAVORITES, FloatingPanel, IndicatorLabel, IndicatorPane, IndicatorsDialog, LayoutMenu, LeftToolbar, LicenseRequiredOverlay, ManagedAppShell, MultiPaneChart, OrderTicket, PointerOverlay, RightToolbar, SymbolSearchDialog, TabBar, TopToolbar, VoiceInput, createTradingBridgeLogger, useAgent, useChartCapabilities, useHostLicense, useLicenseDataBlocked, useUserPackage };
37963
+ export { AgentFAB, AgentProvider, AssistantPanel, BottomToolbar, ChartCanvas, ChartContextMenu, ChartSettingsDialog, ChartWorkspace, CommandDispatcher, DEFAULT_FAVORITES, FloatingPanel, IndicatorLabel, IndicatorPane, IndicatorsDialog, LayoutMenu, LeftToolbar, LicenseRequiredOverlay, ManagedAppShell, MultiPaneChart, OrderTicket, PointerOverlay, RightToolbar, SymbolSearchDialog, TabBar, TopToolbar, VoiceInput, createKitPreferencesApi, createTradingBridgeLogger, useAgent, useChartCapabilities, useHostLicense, useLicenseDataBlocked, useUserPackage };
37901
37964
  //# sourceMappingURL=internal.js.map
37902
37965
  //# sourceMappingURL=internal.js.map