@forgecharts/sdk 1.3.2 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/api/TChart.d.ts +11 -2
  2. package/dist/api/TChart.d.ts.map +1 -1
  3. package/dist/index.js +187 -39
  4. package/dist/index.js.map +1 -1
  5. package/dist/internal.js +187 -39
  6. package/dist/internal.js.map +1 -1
  7. package/dist/licensing/ChartRuntimeResolver.d.ts +22 -0
  8. package/dist/licensing/ChartRuntimeResolver.d.ts.map +1 -1
  9. package/dist/licensing/__tests__/chartFeatureParity.test.d.ts +2 -0
  10. package/dist/licensing/__tests__/chartFeatureParity.test.d.ts.map +1 -0
  11. package/dist/licensing/licenseTypes.d.ts +9 -1
  12. package/dist/licensing/licenseTypes.d.ts.map +1 -1
  13. package/dist/react/canvas/ChartCanvas.d.ts.map +1 -1
  14. package/dist/react/canvas/toolbars/LeftToolbar.d.ts +3 -1
  15. package/dist/react/canvas/toolbars/LeftToolbar.d.ts.map +1 -1
  16. package/dist/react/index.d.ts +2 -0
  17. package/dist/react/index.d.ts.map +1 -1
  18. package/dist/react/index.js +1437 -117
  19. package/dist/react/index.js.map +1 -1
  20. package/dist/react/internal.js +6615 -6304
  21. package/dist/react/internal.js.map +1 -1
  22. package/dist/react/shell/OrderEntryPanel.d.ts +5 -1
  23. package/dist/react/shell/OrderEntryPanel.d.ts.map +1 -1
  24. package/dist/react/trading/OrderTicket.d.ts +38 -0
  25. package/dist/react/trading/OrderTicket.d.ts.map +1 -0
  26. package/dist/react/workspace/BottomTradingPanel.d.ts +14 -3
  27. package/dist/react/workspace/BottomTradingPanel.d.ts.map +1 -1
  28. package/dist/react/workspace/ChartWorkspace.d.ts +24 -1
  29. package/dist/react/workspace/ChartWorkspace.d.ts.map +1 -1
  30. package/dist/react/workspace/IndicatorsDialog.d.ts.map +1 -1
  31. package/dist/react/workspace/toolbars/BottomToolbar.d.ts +3 -1
  32. package/dist/react/workspace/toolbars/BottomToolbar.d.ts.map +1 -1
  33. package/package.json +1 -1
package/dist/internal.js CHANGED
@@ -10678,7 +10678,9 @@ var TRADING_FEATURE_KEYS = /* @__PURE__ */ new Set([
10678
10678
  "draggableOrders",
10679
10679
  "bracketOrders",
10680
10680
  "trailingStops",
10681
- "positionsOverlay"
10681
+ "positionsOverlay",
10682
+ "depthOfMarket",
10683
+ "tradingPanel"
10682
10684
  ]);
10683
10685
 
10684
10686
  // src/licensing/capabilityMatrix.ts
@@ -11031,6 +11033,14 @@ var ChartRuntimeResolver = class _ChartRuntimeResolver {
11031
11033
  canUseDataExport() {
11032
11034
  return this.#featureOrDefault("dataExport", true);
11033
11035
  }
11036
+ /** Continuous futures roll rules + contract-switch handling. */
11037
+ canUseContinuousContracts() {
11038
+ return this.#featureOrDefault("continuousContracts", true);
11039
+ }
11040
+ /** Regular/Extended trading-hours session filtering. */
11041
+ canUseSessionHours() {
11042
+ return this.#featureOrDefault("sessionHours", true);
11043
+ }
11034
11044
  // ── Trading capability queries (managed-only by default) ────────────────────
11035
11045
  /**
11036
11046
  * Built-in order entry UI hooks.
@@ -11107,6 +11117,23 @@ var ChartRuntimeResolver = class _ChartRuntimeResolver {
11107
11117
  if (this.#isCoreTier()) return false;
11108
11118
  return this.#featureOrDefault("positionsOverlay", true);
11109
11119
  }
11120
+ /**
11121
+ * DOM price ladder. Managed deployments only — there is no unmanaged
11122
+ * depth-feed contract, so this is additionally vetoed off-managed.
11123
+ */
11124
+ canUseDepthOfMarket() {
11125
+ if (!this.isManagedMode()) return false;
11126
+ if (this.#isCoreTier()) return false;
11127
+ return this.#featureOrDefault("depthOfMarket", true);
11128
+ }
11129
+ /**
11130
+ * Built-in positions/orders/history journal panel. Trading-tier feature,
11131
+ * gated on productTier (not deploymentMode).
11132
+ */
11133
+ canUseTradingPanel() {
11134
+ if (this.#isCoreTier()) return false;
11135
+ return this.#featureOrDefault("tradingPanel", true);
11136
+ }
11110
11137
  // ── Scripting capability queries ────────────────────────────────────────────
11111
11138
  /** ForgeScript scripting engine. */
11112
11139
  canUseForgeScript() {
@@ -11230,6 +11257,8 @@ var ChartRuntimeResolver = class _ChartRuntimeResolver {
11230
11257
  realtimeData: this.canUseRealtimeData(),
11231
11258
  multipleProviders: this.canUseMultipleProviders(),
11232
11259
  dataExport: this.canUseDataExport(),
11260
+ continuousContracts: this.canUseContinuousContracts(),
11261
+ sessionHours: this.canUseSessionHours(),
11233
11262
  // ── Trading features ────────────────────────────────────────────────
11234
11263
  orderEntry: this.canUseOrderEntry(),
11235
11264
  managedTrading: this.canUseManagedTrading(),
@@ -11237,6 +11266,8 @@ var ChartRuntimeResolver = class _ChartRuntimeResolver {
11237
11266
  bracketOrders: this.canUseBracketOrders(),
11238
11267
  trailingStops: this.canUseTrailingStops(),
11239
11268
  positionsOverlay: this.canUsePositionsOverlay(),
11269
+ depthOfMarket: this.canUseDepthOfMarket(),
11270
+ tradingPanel: this.canUseTradingPanel(),
11240
11271
  // ── Scripting features ──────────────────────────────────────────────
11241
11272
  forgeScript: this.canUseForgeScript(),
11242
11273
  customIndicators: this.canUseCustomIndicators(),
@@ -12002,7 +12033,16 @@ var TChart = class _TChart {
12002
12033
  static OVERLAY_ONLY = /* @__PURE__ */ new Set(["bbands", "vwap", "sma", "ema", "wma"]);
12003
12034
  addIndicator(config) {
12004
12035
  this._assertAlive();
12005
- const finalConfig = _TChart.OVERLAY_ONLY.has(config.type) && config.overlay !== true ? { ...config, overlay: true } : config;
12036
+ if (config.type === "script" && !canUseForgeScript()) {
12037
+ throw new Error(
12038
+ "[ForgeCharts] ForgeScript indicators are not enabled on the active license. Contact your license provider to enable the forgeScript feature."
12039
+ );
12040
+ }
12041
+ let finalConfig = _TChart.OVERLAY_ONLY.has(config.type) && config.overlay !== true ? { ...config, overlay: true } : config;
12042
+ if (finalConfig.overlay !== true && !canUseMultiPane()) {
12043
+ console.warn("[ForgeCharts] multiPane is not enabled on the active license \u2014 indicator added as a price-pane overlay instead.");
12044
+ finalConfig = { ...finalConfig, overlay: true };
12045
+ }
12006
12046
  const id = this._indicators.add(finalConfig);
12007
12047
  if (finalConfig.overlay !== true) {
12008
12048
  const label = _indicatorTypeLabel(finalConfig.type);
@@ -12062,6 +12102,10 @@ var TChart = class _TChart {
12062
12102
  */
12063
12103
  moveIndicatorToPane(id, targetPaneId) {
12064
12104
  this._assertAlive();
12105
+ if (!canUseMultiPane()) {
12106
+ console.warn("[ForgeCharts] multiPane is not enabled on the active license \u2014 indicator stays on the price pane.");
12107
+ return;
12108
+ }
12065
12109
  const inst = this._indicators.get(id);
12066
12110
  if (!inst) return;
12067
12111
  const oldPaneId = this._panes.getPanes().find((p) => p.indicatorIds.includes(id))?.id;
@@ -12133,12 +12177,49 @@ var TChart = class _TChart {
12133
12177
  this._core.setDrawings(this._drawings.all());
12134
12178
  this._core.markDirty();
12135
12179
  }
12180
+ /**
12181
+ * Drawing tools in the "extended" library — gated by the `extendedDrawings`
12182
+ * plan feature. Basic tools (trend lines, rays, channels, h/v lines, text,
12183
+ * shapes) are covered by `drawingTools` alone; the catalog's description of
12184
+ * extendedDrawings is "Gann, Fibonacci, pitchforks, spirals, arcs" plus the
12185
+ * forecasting/measurement tools.
12186
+ */
12187
+ static EXTENDED_DRAWING_TOOLS = /* @__PURE__ */ new Set([
12188
+ "fibRetracement",
12189
+ "trendBasedFibExtension",
12190
+ "fibChannel",
12191
+ "fibTimeZone",
12192
+ "fibSpeedResistanceFan",
12193
+ "trendBasedFibTime",
12194
+ "fibCircles",
12195
+ "fibSpiral",
12196
+ "fibSpeedResistanceArcs",
12197
+ "fibWedge",
12198
+ "pitchfan",
12199
+ "pitchfork",
12200
+ "schiffPitchfork",
12201
+ "modifiedSchiffPitchfork",
12202
+ "insidePitchfork",
12203
+ "gannBox",
12204
+ "gannSquareFixed",
12205
+ "gannSquare",
12206
+ "gannFan",
12207
+ "longPosition",
12208
+ "shortPosition",
12209
+ "priceRange",
12210
+ "dateRange"
12211
+ ]);
12136
12212
  /**
12137
12213
  * Activates a drawing tool. Clicks will place anchors on the chart.
12138
12214
  * The tool remains active after each commit (auto-repeat). Press Escape to cancel.
12215
+ * Extended-library tools require the `extendedDrawings` plan feature.
12139
12216
  */
12140
12217
  startDrawingTool(type) {
12141
12218
  this._assertAlive();
12219
+ if (_TChart.EXTENDED_DRAWING_TOOLS.has(type) && !canUseExtendedDrawings()) {
12220
+ console.warn(`[ForgeCharts] Drawing tool '${type}' requires the extendedDrawings feature, which is not enabled on the active license.`);
12221
+ return;
12222
+ }
12142
12223
  this._core.startDrawingTool(type);
12143
12224
  }
12144
12225
  /** Cancels an active drawing tool and returns to cursor mode. */
@@ -12487,15 +12568,23 @@ var TChart = class _TChart {
12487
12568
  this._core.markDirty();
12488
12569
  }
12489
12570
  // ─ Positions ──
12490
- /** Replace the entire position set on the chart overlay. */
12571
+ /** Replace the entire position set on the chart overlay. Requires the `positionsOverlay` plan feature. */
12491
12572
  setPositions(positions) {
12492
12573
  this._assertAlive();
12574
+ if (!canUsePositionsOverlay()) {
12575
+ console.warn("[ForgeCharts] positionsOverlay is not enabled on the active license \u2014 positions not rendered.");
12576
+ return;
12577
+ }
12493
12578
  this._overlayStore.setPositions(positions);
12494
12579
  this._core.markDirty();
12495
12580
  }
12496
- /** Insert or update a single position (matched by `position.id`). */
12581
+ /** Insert or update a single position (matched by `position.id`). Requires the `positionsOverlay` plan feature. */
12497
12582
  upsertPosition(position) {
12498
12583
  this._assertAlive();
12584
+ if (!canUsePositionsOverlay()) {
12585
+ console.warn("[ForgeCharts] positionsOverlay is not enabled on the active license \u2014 position not rendered.");
12586
+ return;
12587
+ }
12499
12588
  this._overlayStore.upsertPosition(position);
12500
12589
  this._core.markDirty();
12501
12590
  }
@@ -18119,6 +18208,19 @@ function lineStyleToDash(style) {
18119
18208
  return [];
18120
18209
  }
18121
18210
  }
18211
+ function applyRuntimeConfig(caps, config) {
18212
+ return caps;
18213
+ }
18214
+ function useChartCapabilities(config) {
18215
+ const [licCaps, setLicCaps] = useState(() => getCapabilities());
18216
+ useEffect(() => {
18217
+ const unsub = LicenseManager.getInstance().subscribe(() => {
18218
+ setLicCaps(getCapabilities());
18219
+ });
18220
+ return unsub;
18221
+ }, []);
18222
+ return useMemo(() => applyRuntimeConfig(licCaps), [licCaps, config]);
18223
+ }
18122
18224
 
18123
18225
  // src/react/assets/logo_dark.png
18124
18226
  var logo_dark_default = "./logo_dark-B2KCSRPJ.png";
@@ -19192,7 +19294,7 @@ function nextRenewalDate(subscribedAt) {
19192
19294
  const periods = Math.floor((now - start) / MS_30D);
19193
19295
  return new Date(start + (periods + 1) * MS_30D);
19194
19296
  }
19195
- function LeftToolbar({ activeTool, onSelectTool, drawingFavorites, onDrawingFavoritesChange, onVisibilityAction, visibilityActiveAction, onVisibilityDeactivate, onLinkClick, onDeleteClick, onLogout, magnetMode, onMagnetModeChange, user, getAuthToken, apiUrl, containerRef, showDrawingTools }) {
19297
+ function LeftToolbar({ activeTool, onSelectTool, drawingFavorites, onDrawingFavoritesChange, onVisibilityAction, visibilityActiveAction, onVisibilityDeactivate, onLinkClick, onDeleteClick, onLogout, magnetMode, onMagnetModeChange, user, getAuthToken, apiUrl, containerRef, showDrawingTools, showExtendedDrawings }) {
19196
19298
  const [favorites, setFavorites] = useState(drawingFavorites ?? []);
19197
19299
  const [profileOpen, setProfileOpen] = useState(false);
19198
19300
  const [profileTab, setProfileTab] = useState("profile");
@@ -19530,7 +19632,7 @@ function LeftToolbar({ activeTool, onSelectTool, drawingFavorites, onDrawingFavo
19530
19632
  onFavoritesChange: handleFavoritesChange
19531
19633
  }
19532
19634
  ),
19533
- /* @__PURE__ */ jsx(
19635
+ showExtendedDrawings !== false && /* @__PURE__ */ jsx(
19534
19636
  FibGannGroup,
19535
19637
  {
19536
19638
  activeTool,
@@ -19567,34 +19669,36 @@ function LeftToolbar({ activeTool, onSelectTool, drawingFavorites, onDrawingFavo
19567
19669
  onFavoritesChange: handleFavoritesChange
19568
19670
  }
19569
19671
  ),
19570
- /* @__PURE__ */ jsx(
19571
- ToolFlyoutGroup,
19572
- {
19573
- items: FORECAST_ITEMS,
19574
- toolSet: FORECAST_TOOLS,
19575
- itemMap: FORECAST_ITEM_MAP,
19576
- defaultTool: "longPosition",
19577
- groupTitle: "Forecasting",
19578
- activeTool,
19579
- favorites,
19580
- onSelectTool,
19581
- onFavoritesChange: handleFavoritesChange
19582
- }
19583
- ),
19584
- /* @__PURE__ */ jsx(
19585
- ToolFlyoutGroup,
19586
- {
19587
- items: MEASURER_ITEMS,
19588
- toolSet: MEASURER_TOOLS,
19589
- itemMap: MEASURER_ITEM_MAP,
19590
- defaultTool: "priceRange",
19591
- groupTitle: "Measurers",
19592
- activeTool,
19593
- favorites,
19594
- onSelectTool,
19595
- onFavoritesChange: handleFavoritesChange
19596
- }
19597
- ),
19672
+ showExtendedDrawings !== false && /* @__PURE__ */ jsxs(Fragment, { children: [
19673
+ /* @__PURE__ */ jsx(
19674
+ ToolFlyoutGroup,
19675
+ {
19676
+ items: FORECAST_ITEMS,
19677
+ toolSet: FORECAST_TOOLS,
19678
+ itemMap: FORECAST_ITEM_MAP,
19679
+ defaultTool: "longPosition",
19680
+ groupTitle: "Forecasting",
19681
+ activeTool,
19682
+ favorites,
19683
+ onSelectTool,
19684
+ onFavoritesChange: handleFavoritesChange
19685
+ }
19686
+ ),
19687
+ /* @__PURE__ */ jsx(
19688
+ ToolFlyoutGroup,
19689
+ {
19690
+ items: MEASURER_ITEMS,
19691
+ toolSet: MEASURER_TOOLS,
19692
+ itemMap: MEASURER_ITEM_MAP,
19693
+ defaultTool: "priceRange",
19694
+ groupTitle: "Measurers",
19695
+ activeTool,
19696
+ favorites,
19697
+ onSelectTool,
19698
+ onFavoritesChange: handleFavoritesChange
19699
+ }
19700
+ )
19701
+ ] }),
19598
19702
  /* @__PURE__ */ jsx(
19599
19703
  MagnetTool,
19600
19704
  {
@@ -22623,6 +22727,7 @@ var ChartCanvas = forwardRef(
22623
22727
  const [error, setError] = useState(null);
22624
22728
  const [bars, setBars] = useState([]);
22625
22729
  const [panes, setPanes] = useState([]);
22730
+ const capabilities = useChartCapabilities();
22626
22731
  const [indicators, setIndicators] = useState([]);
22627
22732
  const [totalHeight, setTotalHeight] = useState(600);
22628
22733
  const [activeTool, setActiveTool] = useState(initialActiveTool ?? "cursor");
@@ -22679,6 +22784,10 @@ var ChartCanvas = forwardRef(
22679
22784
  onOrderDragEndRef.current = onOrderDragEnd;
22680
22785
  const onTpSlCreateRef = useRef(onTpSlCreate);
22681
22786
  onTpSlCreateRef.current = onTpSlCreate;
22787
+ const tradingBridgeRef = useRef(tradingBridge);
22788
+ tradingBridgeRef.current = tradingBridge;
22789
+ const symbolRef = useRef(symbol);
22790
+ symbolRef.current = symbol;
22682
22791
  const dagRef = useRef(null);
22683
22792
  const [computedResults, setComputedResults] = useState(
22684
22793
  () => /* @__PURE__ */ new Map()
@@ -22811,10 +22920,48 @@ var ChartCanvas = forwardRef(
22811
22920
  onPositionClickRef.current?.(positionId);
22812
22921
  });
22813
22922
  chart.on("orderDragEnd", ({ orderId, newPrice }) => {
22814
- onOrderDragEndRef.current?.(orderId, newPrice);
22923
+ if (onOrderDragEndRef.current) {
22924
+ onOrderDragEndRef.current(orderId, newPrice);
22925
+ return;
22926
+ }
22927
+ const bridge = tradingBridgeRef.current;
22928
+ if (!bridge) return;
22929
+ const order = chart.getTradingOverlayStore()?.getOrders().find((o) => o.id === orderId);
22930
+ const isBracketLeg = order?.role === "take_profit" || order?.role === "stop_loss";
22931
+ if (isBracketLeg) {
22932
+ if (!canUseBracketOrders()) return;
22933
+ void bridge.onBracketAdjustIntent?.({
22934
+ type: "bracket_adjust",
22935
+ entryOrderId: order?.groupId ?? orderId,
22936
+ symbol: symbolRef.current,
22937
+ ...order?.role === "stop_loss" ? { stopLossPrice: newPrice } : { takeProfitPrice: newPrice },
22938
+ timestamp: Date.now()
22939
+ });
22940
+ } else {
22941
+ if (!canUseDraggableOrders()) return;
22942
+ void bridge.onModifyOrderIntent?.({
22943
+ type: "modify",
22944
+ orderId,
22945
+ symbol: symbolRef.current,
22946
+ limitPrice: newPrice,
22947
+ timestamp: Date.now()
22948
+ });
22949
+ }
22815
22950
  });
22816
22951
  chart.on("tpSlCreate", ({ entryOrderId, kind, price }) => {
22817
- onTpSlCreateRef.current?.(entryOrderId, kind, price);
22952
+ if (onTpSlCreateRef.current) {
22953
+ onTpSlCreateRef.current(entryOrderId, kind, price);
22954
+ return;
22955
+ }
22956
+ const bridge = tradingBridgeRef.current;
22957
+ if (!bridge || !canUseBracketOrders()) return;
22958
+ void bridge.onBracketAdjustIntent?.({
22959
+ type: "bracket_adjust",
22960
+ entryOrderId,
22961
+ symbol: symbolRef.current,
22962
+ ...kind === "sl" ? { stopLossPrice: price } : { takeProfitPrice: price },
22963
+ timestamp: Date.now()
22964
+ });
22818
22965
  });
22819
22966
  if (layoutToRestore) {
22820
22967
  try {
@@ -22937,7 +23084,7 @@ var ChartCanvas = forwardRef(
22937
23084
  }, [initialCanvasSettings]);
22938
23085
  useEffect(() => {
22939
23086
  const chart = chartRef.current;
22940
- if (!chart || !canvasSettings.showContractSwitches) {
23087
+ if (!chart || !canvasSettings.showContractSwitches || !capabilities.continuousContracts) {
22941
23088
  chart?.setContractSwitches([]);
22942
23089
  contractSwitchesRef.current = [];
22943
23090
  return;
@@ -22974,7 +23121,7 @@ var ChartCanvas = forwardRef(
22974
23121
  return () => {
22975
23122
  cancelled = true;
22976
23123
  };
22977
- }, [symbol, apiUrl, canvasSettings.showContractSwitches, providerKey]);
23124
+ }, [symbol, apiUrl, canvasSettings.showContractSwitches, providerKey, capabilities.continuousContracts]);
22978
23125
  useEffect(() => {
22979
23126
  if (!dagRef.current) dagRef.current = new IndicatorDAG();
22980
23127
  const dag = dagRef.current;
@@ -23713,7 +23860,8 @@ var ChartCanvas = forwardRef(
23713
23860
  onDrawingFavoritesChange?.(favs);
23714
23861
  },
23715
23862
  containerRef: outerRef,
23716
- showDrawingTools,
23863
+ showDrawingTools: showDrawingTools !== false && capabilities.drawingTools,
23864
+ showExtendedDrawings: capabilities.extendedDrawings,
23717
23865
  ...onLogout ? { onLogout } : {},
23718
23866
  ...user ? { user } : {},
23719
23867
  ...getAuthToken ? { getAuthToken } : {},