@forgecharts/sdk 1.5.11 → 1.5.13
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.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -1
- package/dist/internal.js +59 -0
- package/dist/internal.js.map +1 -1
- package/dist/licensing/LicenseManager.d.ts +26 -0
- package/dist/licensing/LicenseManager.d.ts.map +1 -1
- package/dist/react/canvas/ChartCanvas.d.ts.map +1 -1
- package/dist/react/hooks/useHostLicense.d.ts +17 -0
- package/dist/react/hooks/useHostLicense.d.ts.map +1 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +63 -20
- package/dist/react/index.js.map +1 -1
- package/dist/react/internal.js +63 -20
- package/dist/react/internal.js.map +1 -1
- package/dist/react/workspace/ChartWorkspace.d.ts +13 -1
- package/dist/react/workspace/ChartWorkspace.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/react/internal.js
CHANGED
|
@@ -10735,6 +10735,7 @@ var LicenseManager = class _LicenseManager {
|
|
|
10735
10735
|
payload = null;
|
|
10736
10736
|
status = "idle";
|
|
10737
10737
|
failureKind = null;
|
|
10738
|
+
hostState = "unknown";
|
|
10738
10739
|
subscribers = /* @__PURE__ */ new Set();
|
|
10739
10740
|
constructor() {
|
|
10740
10741
|
}
|
|
@@ -10864,8 +10865,26 @@ var LicenseManager = class _LicenseManager {
|
|
|
10864
10865
|
* unmanaged SDK path) keeps working exactly as before.
|
|
10865
10866
|
*/
|
|
10866
10867
|
isDataBlocked() {
|
|
10868
|
+
if (this.hostState === "unlicensed") return true;
|
|
10869
|
+
if (this.hostState === "licensed") return false;
|
|
10867
10870
|
return this.status === "failed" && this.failureKind === "invalid";
|
|
10868
10871
|
}
|
|
10872
|
+
/** What the host deployment reports about its own licence. */
|
|
10873
|
+
getHostLicenseState() {
|
|
10874
|
+
return this.hostState;
|
|
10875
|
+
}
|
|
10876
|
+
/**
|
|
10877
|
+
* Record the host deployment's answer from GET /api/license.
|
|
10878
|
+
*
|
|
10879
|
+
* Pass 'unlicensed' ONLY when the host answered and said it has no licence.
|
|
10880
|
+
* A network failure, missing apiUrl, or non-OK response must pass 'unknown',
|
|
10881
|
+
* otherwise an outage would blank every chart the deployment serves.
|
|
10882
|
+
*/
|
|
10883
|
+
setHostLicenseState(state) {
|
|
10884
|
+
if (this.hostState === state) return;
|
|
10885
|
+
this.hostState = state;
|
|
10886
|
+
this.notify();
|
|
10887
|
+
}
|
|
10869
10888
|
/**
|
|
10870
10889
|
* Runs a raw/legacy/partial payload through `migrateLegacyPayload` (fills
|
|
10871
10890
|
* missing productTier/capabilities/schemaVersion, deterministically, with
|
|
@@ -10925,6 +10944,7 @@ var LicenseManager = class _LicenseManager {
|
|
|
10925
10944
|
this.payload = null;
|
|
10926
10945
|
this.status = "idle";
|
|
10927
10946
|
this.failureKind = null;
|
|
10947
|
+
this.hostState = "unknown";
|
|
10928
10948
|
this.notify();
|
|
10929
10949
|
}
|
|
10930
10950
|
};
|
|
@@ -18096,6 +18116,44 @@ function useLicenseDataBlocked() {
|
|
|
18096
18116
|
}, []);
|
|
18097
18117
|
return blocked;
|
|
18098
18118
|
}
|
|
18119
|
+
function useHostLicense(apiUrl, getAuthToken) {
|
|
18120
|
+
useEffect(() => {
|
|
18121
|
+
if (!apiUrl) return;
|
|
18122
|
+
let cancelled = false;
|
|
18123
|
+
const lm = LicenseManager.getInstance();
|
|
18124
|
+
void (async () => {
|
|
18125
|
+
try {
|
|
18126
|
+
const headers = {};
|
|
18127
|
+
if (getAuthToken) {
|
|
18128
|
+
try {
|
|
18129
|
+
const tok = await getAuthToken();
|
|
18130
|
+
if (tok) headers["Authorization"] = `Bearer ${tok}`;
|
|
18131
|
+
} catch {
|
|
18132
|
+
}
|
|
18133
|
+
}
|
|
18134
|
+
const res = await fetch(`${apiUrl.replace(/\/+$/, "")}/api/license`, { headers });
|
|
18135
|
+
if (cancelled) return;
|
|
18136
|
+
if (!res.ok) {
|
|
18137
|
+
lm.setHostLicenseState("unknown");
|
|
18138
|
+
return;
|
|
18139
|
+
}
|
|
18140
|
+
const data = await res.json();
|
|
18141
|
+
if (cancelled) return;
|
|
18142
|
+
if (data.licensePayload && typeof data.licensePayload === "object") {
|
|
18143
|
+
lm.loadLicense(data.licensePayload);
|
|
18144
|
+
lm.setHostLicenseState("licensed");
|
|
18145
|
+
} else {
|
|
18146
|
+
lm.setHostLicenseState("unlicensed");
|
|
18147
|
+
}
|
|
18148
|
+
} catch {
|
|
18149
|
+
if (!cancelled) lm.setHostLicenseState("unknown");
|
|
18150
|
+
}
|
|
18151
|
+
})();
|
|
18152
|
+
return () => {
|
|
18153
|
+
cancelled = true;
|
|
18154
|
+
};
|
|
18155
|
+
}, [apiUrl, getAuthToken]);
|
|
18156
|
+
}
|
|
18099
18157
|
function LicenseRequiredOverlay({
|
|
18100
18158
|
reason,
|
|
18101
18159
|
onOpenLicenseSettings
|
|
@@ -22811,6 +22869,7 @@ var ChartCanvas = forwardRef(
|
|
|
22811
22869
|
const [panes, setPanes] = useState([]);
|
|
22812
22870
|
const capabilities = useChartCapabilities();
|
|
22813
22871
|
const dataBlocked = useLicenseDataBlocked();
|
|
22872
|
+
useHostLicense(apiUrl, getAuthToken);
|
|
22814
22873
|
const [indicators, setIndicators] = useState([]);
|
|
22815
22874
|
const [totalHeight, setTotalHeight] = useState(600);
|
|
22816
22875
|
const [activeTool, setActiveTool] = useState(initialActiveTool ?? "cursor");
|
|
@@ -31091,6 +31150,8 @@ function ChartWorkspace({
|
|
|
31091
31150
|
tradingOverlayStore
|
|
31092
31151
|
}) {
|
|
31093
31152
|
const capabilities = useChartCapabilities();
|
|
31153
|
+
const dataBlocked = useLicenseDataBlocked();
|
|
31154
|
+
useHostLicense(hostApiUrl, getAuthToken);
|
|
31094
31155
|
const autoTrading = tradingBridge !== void 0;
|
|
31095
31156
|
const [autoOrderEntryOpen, setAutoOrderEntryOpen] = React11.useState(false);
|
|
31096
31157
|
const [autoTradingPanelOpen, setAutoTradingPanelOpen] = React11.useState(false);
|
|
@@ -31240,25 +31301,7 @@ function ChartWorkspace({
|
|
|
31240
31301
|
}
|
|
31241
31302
|
),
|
|
31242
31303
|
/* @__PURE__ */ jsx("div", { style: { flex: 1, display: "flex", gap: 4, minHeight: 0, overflow: "hidden" }, children: /* @__PURE__ */ jsxs("div", { style: { position: "relative", flex: 1, display: "flex", gap: 4, minWidth: 0, minHeight: 0 }, children: [
|
|
31243
|
-
|
|
31244
|
-
position: "absolute",
|
|
31245
|
-
inset: 0,
|
|
31246
|
-
zIndex: 100,
|
|
31247
|
-
background: "rgba(0,0,0,0.6)",
|
|
31248
|
-
backdropFilter: "blur(4px)",
|
|
31249
|
-
display: "flex",
|
|
31250
|
-
flexDirection: "column",
|
|
31251
|
-
alignItems: "center",
|
|
31252
|
-
justifyContent: "center",
|
|
31253
|
-
gap: 12
|
|
31254
|
-
}, children: [
|
|
31255
|
-
/* @__PURE__ */ jsxs("svg", { viewBox: "0 0 24 24", width: "40", height: "40", fill: "none", stroke: "rgba(255,255,255,0.7)", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
31256
|
-
/* @__PURE__ */ jsx("rect", { x: "3", y: "11", width: "18", height: "11", rx: "2" }),
|
|
31257
|
-
/* @__PURE__ */ jsx("path", { d: "M7 11V7a5 5 0 0110 0v4" })
|
|
31258
|
-
] }),
|
|
31259
|
-
/* @__PURE__ */ jsx("div", { style: { color: "#fff", fontWeight: 700, fontSize: 18, letterSpacing: "0.01em" }, children: "Unlicensed" }),
|
|
31260
|
-
/* @__PURE__ */ jsx("div", { style: { color: "rgba(255,255,255,0.65)", fontSize: 13 }, children: "Please activate your license in the admin studio" })
|
|
31261
|
-
] }),
|
|
31304
|
+
(dataBlocked || isLicensed === false) && /* @__PURE__ */ jsx(LicenseRequiredOverlay, {}),
|
|
31262
31305
|
/* @__PURE__ */ jsx("div", { style: { position: "relative", flex: 1, minWidth: 0, minHeight: 0 }, children: chartSlots }),
|
|
31263
31306
|
autoTrading && !onToggleOrderEntry && effOrderEntryOpen && capabilities.orderEntry && tradingBridge && /* @__PURE__ */ jsx(
|
|
31264
31307
|
OrderTicket,
|
|
@@ -37460,6 +37503,6 @@ function IndicatorPane({
|
|
|
37460
37503
|
] });
|
|
37461
37504
|
}
|
|
37462
37505
|
|
|
37463
|
-
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, useLicenseDataBlocked };
|
|
37506
|
+
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 };
|
|
37464
37507
|
//# sourceMappingURL=internal.js.map
|
|
37465
37508
|
//# sourceMappingURL=internal.js.map
|