@rm-graph/core 0.1.10 → 0.1.12
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/README.md +3 -52
- package/dist/{chunk-KATRK3C3.js → chunk-4JQVY6S5.js} +2 -10
- package/dist/chunk-4JQVY6S5.js.map +1 -0
- package/dist/{chunk-Q2ZHY445.mjs → chunk-7GF5X23V.mjs} +3 -10
- package/dist/chunk-7GF5X23V.mjs.map +1 -0
- package/dist/chunk-BJTO5JO5.mjs +10 -0
- package/dist/chunk-BJTO5JO5.mjs.map +1 -0
- package/dist/chunk-DGUM43GV.js +12 -0
- package/dist/chunk-DGUM43GV.js.map +1 -0
- package/dist/chunk-PKJHVSFI.mjs +199 -0
- package/dist/chunk-PKJHVSFI.mjs.map +1 -0
- package/dist/chunk-RLQMHQEV.js +218 -0
- package/dist/chunk-RLQMHQEV.js.map +1 -0
- package/dist/index.d.mts +208 -17
- package/dist/index.d.ts +208 -17
- package/dist/index.js +135 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -27
- package/dist/index.mjs.map +1 -1
- package/dist/license-MTK7WNNA.mjs +4 -0
- package/dist/license-MTK7WNNA.mjs.map +1 -0
- package/dist/license-U7ZNTU6D.js +81 -0
- package/dist/license-U7ZNTU6D.js.map +1 -0
- package/dist/themes/index.js +8 -7
- package/dist/themes/index.mjs +2 -1
- package/package.json +14 -12
- package/dist/chunk-KATRK3C3.js.map +0 -1
- package/dist/chunk-Q2ZHY445.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -36,58 +36,9 @@ chart.destroy();
|
|
|
36
36
|
|
|
37
37
|
## Chart Types
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
import { createColumn3DChart } from '@rm-graph/core';
|
|
45
|
-
import type { Column3DDataPoint, Column3DChartStats } from '@rm-graph/core';
|
|
46
|
-
|
|
47
|
-
const chart = await createColumn3DChart('container-id', {
|
|
48
|
-
data: [[45, 1500, 1], [90, 2200, 2], [180, 1800, 3]],
|
|
49
|
-
xAxisTitle: 'Phase Angle (°)',
|
|
50
|
-
yAxisTitle: 'Amplitude (mVp)',
|
|
51
|
-
zAxisTitle: 'Cycle',
|
|
52
|
-
xRange: { min: 0, max: 360 },
|
|
53
|
-
yRange: { min: 0, max: 5000 },
|
|
54
|
-
zRange: { min: 0, max: 50 },
|
|
55
|
-
barFill: '#52aaf2',
|
|
56
|
-
barOpacity: 0.95,
|
|
57
|
-
showSineWave: true,
|
|
58
|
-
enableCameraClamping: true,
|
|
59
|
-
onStatsChange: (stats: Column3DChartStats) => {
|
|
60
|
-
console.log('Pulse Count:', stats.pulseCount, 'Peak:', stats.peakValue);
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
// Update data
|
|
65
|
-
chart.setData([[50, 1600, 1], [95, 2300, 2]]);
|
|
66
|
-
|
|
67
|
-
// Change camera preset
|
|
68
|
-
chart.setCameraPreset(0); // Top view
|
|
69
|
-
|
|
70
|
-
// Reset camera
|
|
71
|
-
chart.resetCamera();
|
|
72
|
-
|
|
73
|
-
// Take screenshot
|
|
74
|
-
chart.captureScreenshot('chart-screenshot');
|
|
75
|
-
|
|
76
|
-
// Cleanup
|
|
77
|
-
chart.destroy();
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
**Data format**: `[phaseAngle, amplitude, cycle]` - each tuple represents a 3D column bar.
|
|
81
|
-
|
|
82
|
-
**Key features**: Camera presets, orbit rotation with clamping, sine wave overlay, zoom control, screenshot export, statistics tracking.
|
|
83
|
-
|
|
84
|
-
### `createPRPDChart`
|
|
85
|
-
|
|
86
|
-
Phase Resolved Partial Discharge heatmap visualization.
|
|
87
|
-
|
|
88
|
-
**Data format**: `[phaseAngle, amplitude, count]` - each tuple represents pulse density at a given position.
|
|
89
|
-
|
|
90
|
-
**Key features**: Heatmap color coding, sine wave overlay, resolution modes, windowing support, screenshot export.
|
|
39
|
+
- `createColumn3DChart` - 3D column charts for phase-resolved data
|
|
40
|
+
- `createPRPDChart` - Phase Resolved Partial Discharge heatmaps
|
|
41
|
+
- `createSurface3DChart` - 3D surface visualization
|
|
91
42
|
|
|
92
43
|
## Theming
|
|
93
44
|
|
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
4
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
5
|
-
}) : x)(function(x) {
|
|
6
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
7
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
|
-
});
|
|
9
|
-
|
|
10
3
|
// src/themes/defaultTheme.ts
|
|
11
4
|
var lightTheme = {
|
|
12
5
|
name: "light",
|
|
@@ -326,11 +319,10 @@ var ThemeManager = class _ThemeManager {
|
|
|
326
319
|
var getThemeManager = () => ThemeManager.getInstance();
|
|
327
320
|
|
|
328
321
|
exports.ThemeManager = ThemeManager;
|
|
329
|
-
exports.__require = __require;
|
|
330
322
|
exports.darkTheme = darkTheme;
|
|
331
323
|
exports.getThemeManager = getThemeManager;
|
|
332
324
|
exports.lightTheme = lightTheme;
|
|
333
325
|
exports.midnightTheme = midnightTheme;
|
|
334
326
|
exports.modernTheme = modernTheme;
|
|
335
|
-
//# sourceMappingURL=chunk-
|
|
336
|
-
//# sourceMappingURL=chunk-
|
|
327
|
+
//# sourceMappingURL=chunk-4JQVY6S5.js.map
|
|
328
|
+
//# sourceMappingURL=chunk-4JQVY6S5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/themes/defaultTheme.ts","../src/themes/ThemeManager.ts"],"names":[],"mappings":";;;AAKO,IAAM,UAAA,GAA0B;AAAA,EACrC,IAAA,EAAM,OAAA;AAAA,EACN,eAAA,EA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AA,QACN,GAAG,IAAA,CAAK,MAAA;AAAA,QACR,GAAG,QAAA,CAAS;AAAA,OACd;AAAA,MACA,KAAA,EAAO;AAAA,QACL,GAAG,IAAA,CAAK,KAAA;AAAA,QACR,GAAG,QAAA,CAAS;AAAA,OACd;AAAA,MACA,YAAA,EAAc,QAAA,CAAS,YAAA,IAAgB,IAAA,CAAK;AAAA,KAC9C;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKO,mBAAA,CAAoB,OAAoB,KAAA,EAAuB;AACpE,IAAA,MAAM,OAAA,GAAU,KAAA,CAAM,YAAA,IAAgB,UAAA,CAAW,YAAA;AACjD,IAAA,OAAO,OAAA,CAAQ,KAAA,GAAQ,OAAA,CAAQ,MAAM,CAAA;AAAA,EACvC;AACF;AAGO,IAAM,eAAA,GAAkB,MAAoB,YAAA,CAAa,WAAA","file":"chunk-4JQVY6S5.js","sourcesContent":["import type { ThemeConfig } from \"../types\";\r\n\r\n/**\r\n * Default light theme - clean white background with subtle grid\r\n */\r\nexport const lightTheme: ThemeConfig = {\r\n name: \"light\",\r\n backgroundColor: \"#f8f9fa\",\r\n textColor: \"#495057\",\r\n fontFamily:\r\n 'system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif',\r\n colorPalette: [\r\n \"#4285f4\", // Blue (Channel 1)\r\n \"#34a853\", // Green (Channel 2)\r\n \"#fbbc04\", // Orange/Yellow (Channel 3)\r\n \"#ea4335\", // Red (Channel 4)\r\n \"#9c27b0\", // Purple\r\n \"#00bcd4\", // Cyan\r\n \"#ff9800\", // Orange\r\n \"#8bc34a\", // Light Green\r\n \"#e91e63\", // Pink\r\n \"#607d8b\", // Blue Grey\r\n ],\r\n axis: {\r\n lineColor: \"#dee2e6\",\r\n labelColor: \"#6c757d\",\r\n titleColor: \"#495057\",\r\n gridLineColor: \"#e9ecef\",\r\n },\r\n tooltip: {\r\n backgroundColor: \"#212529\",\r\n textColor: \"#ffffff\",\r\n borderColor: \"#495057\",\r\n borderRadius: 6,\r\n },\r\n legend: {\r\n textColor: \"#495057\",\r\n backgroundColor: \"transparent\",\r\n },\r\n title: {\r\n color: \"#212529\",\r\n fontSize: 18,\r\n fontWeight: \"600\",\r\n },\r\n};\r\n\r\n/**\r\n * Default dark theme\r\n */\r\nexport const darkTheme: ThemeConfig = {\r\n name: \"dark\",\r\n backgroundColor: \"#0f172a\",\r\n textColor: \"#e2e8f0\",\r\n fontFamily:\r\n 'system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif',\r\n colorPalette: [\r\n \"#818cf8\", // Indigo (lighter)\r\n \"#fbbf24\", // Amber (lighter)\r\n \"#34d399\", // Emerald (lighter)\r\n \"#f87171\", // Red (lighter)\r\n \"#a78bfa\", // Violet (lighter)\r\n \"#22d3ee\", // Cyan (lighter)\r\n \"#fb923c\", // Orange (lighter)\r\n \"#a3e635\", // Lime (lighter)\r\n \"#f472b6\", // Pink (lighter)\r\n \"#2dd4bf\", // Teal (lighter)\r\n ],\r\n axis: {\r\n lineColor: \"#334155\",\r\n labelColor: \"#94a3b8\",\r\n titleColor: \"#cbd5e1\",\r\n gridLineColor: \"#1e293b\",\r\n },\r\n tooltip: {\r\n backgroundColor: \"#1e293b\",\r\n textColor: \"#f1f5f9\",\r\n borderColor: \"#475569\",\r\n borderRadius: 8,\r\n },\r\n legend: {\r\n textColor: \"#cbd5e1\",\r\n backgroundColor: \"transparent\",\r\n },\r\n title: {\r\n color: \"#f8fafc\",\r\n fontSize: 18,\r\n fontWeight: \"600\",\r\n },\r\n};\r\n\r\n/**\r\n * Modern gradient theme with vibrant colors\r\n */\r\nexport const modernTheme: ThemeConfig = {\r\n name: \"modern\",\r\n backgroundColor: \"#fafafa\",\r\n textColor: \"#18181b\",\r\n fontFamily: '\"Inter\", system-ui, sans-serif',\r\n colorPalette: [\r\n \"#7c3aed\", // Violet\r\n \"#2563eb\", // Blue\r\n \"#059669\", // Green\r\n \"#dc2626\", // Red\r\n \"#d97706\", // Amber\r\n \"#0891b2\", // Cyan\r\n \"#c026d3\", // Fuchsia\r\n \"#4f46e5\", // Indigo\r\n \"#16a34a\", // Green\r\n \"#9333ea\", // Purple\r\n ],\r\n axis: {\r\n lineColor: \"#e4e4e7\",\r\n labelColor: \"#71717a\",\r\n titleColor: \"#3f3f46\",\r\n gridLineColor: \"#f4f4f5\",\r\n },\r\n tooltip: {\r\n backgroundColor: \"#18181b\",\r\n textColor: \"#fafafa\",\r\n borderColor: \"#27272a\",\r\n borderRadius: 12,\r\n },\r\n legend: {\r\n textColor: \"#3f3f46\",\r\n backgroundColor: \"transparent\",\r\n },\r\n title: {\r\n color: \"#09090b\",\r\n fontSize: 20,\r\n fontWeight: \"700\",\r\n },\r\n};\r\n\r\n/**\r\n * Midnight theme - deep dark with neon accents\r\n */\r\nexport const midnightTheme: ThemeConfig = {\r\n name: \"midnight\",\r\n backgroundColor: \"#030712\",\r\n textColor: \"#d1d5db\",\r\n fontFamily: '\"JetBrains Mono\", monospace',\r\n colorPalette: [\r\n \"#22d3ee\", // Cyan\r\n \"#a855f7\", // Purple\r\n \"#4ade80\", // Green\r\n \"#fb7185\", // Pink\r\n \"#facc15\", // Yellow\r\n \"#38bdf8\", // Sky\r\n \"#f472b6\", // Pink\r\n \"#2dd4bf\", // Teal\r\n \"#c084fc\", // Purple\r\n \"#fbbf24\", // Amber\r\n ],\r\n axis: {\r\n lineColor: \"#1f2937\",\r\n labelColor: \"#6b7280\",\r\n titleColor: \"#9ca3af\",\r\n gridLineColor: \"#111827\",\r\n },\r\n tooltip: {\r\n backgroundColor: \"#111827\",\r\n textColor: \"#f9fafb\",\r\n borderColor: \"#22d3ee\",\r\n borderRadius: 4,\r\n },\r\n legend: {\r\n textColor: \"#9ca3af\",\r\n backgroundColor: \"transparent\",\r\n },\r\n title: {\r\n color: \"#f3f4f6\",\r\n fontSize: 18,\r\n fontWeight: \"500\",\r\n },\r\n};\r\n\r\n","import type { ThemeConfig } from \"../types\";\r\nimport { lightTheme, darkTheme, modernTheme, midnightTheme } from \"./defaultTheme\";\r\n\r\n/**\r\n * ThemeManager - Manages chart themes and provides theme resolution\r\n */\r\nexport class ThemeManager {\r\n private static instance: ThemeManager;\r\n private themes: Map<string, ThemeConfig> = new Map();\r\n private currentTheme: string = \"light\";\r\n\r\n private constructor() {\r\n // Register built-in themes\r\n this.registerTheme(lightTheme);\r\n this.registerTheme(darkTheme);\r\n this.registerTheme(modernTheme);\r\n this.registerTheme(midnightTheme);\r\n }\r\n\r\n /**\r\n * Get the singleton instance of ThemeManager\r\n */\r\n public static getInstance(): ThemeManager {\r\n if (!ThemeManager.instance) {\r\n ThemeManager.instance = new ThemeManager();\r\n }\r\n return ThemeManager.instance;\r\n }\r\n\r\n /**\r\n * Register a custom theme\r\n */\r\n public registerTheme(theme: ThemeConfig): void {\r\n if (!theme.name) {\r\n throw new Error(\"Theme must have a name\");\r\n }\r\n this.themes.set(theme.name, theme);\r\n }\r\n\r\n /**\r\n * Get a theme by name\r\n */\r\n public getTheme(name: string): ThemeConfig {\r\n const theme = this.themes.get(name);\r\n if (!theme) {\r\n console.warn(`Theme \"${name}\" not found, falling back to light theme`);\r\n return this.themes.get(\"light\")!;\r\n }\r\n return theme;\r\n }\r\n\r\n /**\r\n * Set the global default theme\r\n */\r\n public setDefaultTheme(name: string): void {\r\n if (!this.themes.has(name)) {\r\n throw new Error(`Theme \"${name}\" is not registered`);\r\n }\r\n this.currentTheme = name;\r\n }\r\n\r\n /**\r\n * Get the current default theme name\r\n */\r\n public getDefaultThemeName(): string {\r\n return this.currentTheme;\r\n }\r\n\r\n /**\r\n * Get the current default theme configuration\r\n */\r\n public getDefaultTheme(): ThemeConfig {\r\n return this.themes.get(this.currentTheme)!;\r\n }\r\n\r\n /**\r\n * Get all registered theme names\r\n */\r\n public getAvailableThemes(): string[] {\r\n return Array.from(this.themes.keys());\r\n }\r\n\r\n /**\r\n * Check if a theme is registered\r\n */\r\n public hasTheme(name: string): boolean {\r\n return this.themes.has(name);\r\n }\r\n\r\n /**\r\n * Resolve theme from string name or ThemeConfig object\r\n */\r\n public resolveTheme(theme?: ThemeConfig | string): ThemeConfig {\r\n if (!theme) {\r\n return this.getDefaultTheme();\r\n }\r\n if (typeof theme === \"string\") {\r\n return this.getTheme(theme);\r\n }\r\n // Merge with default theme for any missing properties\r\n return this.mergeThemes(this.getDefaultTheme(), theme);\r\n }\r\n\r\n /**\r\n * Merge two themes, with override taking precedence\r\n */\r\n public mergeThemes(base: ThemeConfig, override: Partial<ThemeConfig>): ThemeConfig {\r\n return {\r\n ...base,\r\n ...override,\r\n axis: {\r\n ...base.axis,\r\n ...override.axis,\r\n },\r\n tooltip: {\r\n ...base.tooltip,\r\n ...override.tooltip,\r\n },\r\n legend: {\r\n ...base.legend,\r\n ...override.legend,\r\n },\r\n title: {\r\n ...base.title,\r\n ...override.title,\r\n },\r\n colorPalette: override.colorPalette ?? base.colorPalette,\r\n };\r\n }\r\n\r\n /**\r\n * Get color from palette by index (cycles through palette)\r\n */\r\n public getColorFromPalette(theme: ThemeConfig, index: number): string {\r\n const palette = theme.colorPalette ?? lightTheme.colorPalette!;\r\n return palette[index % palette.length];\r\n }\r\n}\r\n\r\n// Export singleton getter for convenience\r\nexport const getThemeManager = (): ThemeManager => ThemeManager.getInstance();\r\n\r\n"]}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
1
|
// src/themes/defaultTheme.ts
|
|
9
2
|
var lightTheme = {
|
|
10
3
|
name: "light",
|
|
@@ -323,6 +316,6 @@ var ThemeManager = class _ThemeManager {
|
|
|
323
316
|
};
|
|
324
317
|
var getThemeManager = () => ThemeManager.getInstance();
|
|
325
318
|
|
|
326
|
-
export { ThemeManager,
|
|
327
|
-
//# sourceMappingURL=chunk-
|
|
328
|
-
//# sourceMappingURL=chunk-
|
|
319
|
+
export { ThemeManager, darkTheme, getThemeManager, lightTheme, midnightTheme, modernTheme };
|
|
320
|
+
//# sourceMappingURL=chunk-7GF5X23V.mjs.map
|
|
321
|
+
//# sourceMappingURL=chunk-7GF5X23V.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/themes/defaultTheme.ts","../src/themes/ThemeManager.ts"],"names":[],"mappings":";AAKO,IAAM,UAAA,GAA0B;AAAA,EACrC,IAAA,EAAM,OAAA;AAAA,EACN,eAAA,EAAiB,SAAA;AAAA,EACjB,SAAA,EAAW,SAAA;AAAA,EACX,UAAA,EACE,8EAAA;AAAA,EACF,YAAA,EAAc;AAAA,IACZ,SAAA;AAAA;AAAA,IACA,SAAA;AAAA;AAAA,IACA,SAAA;AAAA;AAAA,IACA,SAAA;AAAA;AAAA,IACA,SAAA;AAAA;AAAA,IACA,SAAA;AAAA;AAAA,IACA,SAAA;AAAA;AAAA,IACA,SAAA;AAAA;AAAA,IACA,SAAA;AAAA;AAAA,IACA;AAAA;AAAA,GACF;AAAA,EACA,IAAA,EAAM;AAAA,IACJ,SAAA,EAAW,SAAA;AAAA,IACX,UAAA,EAAY,SAAA;AAAA,IACZ,UAAA,EAAY,SAAA;AAAA,IACZ,aAAA,EAAe;AAAA,GACjB;AAAA,EACA,OAAA,EAAS;AAAA,IACP,eAAA,EAAiB,SAAA;AAAA,IACjB,SAAA,EAAW,SAAA;AAAA,IACX,WAAA,EAAa,SAAA;AAAA,IACb,YAAA,EAAc;AAAA,GAChB;AAAA,EACA,MAAA,EAAQ;AAAA,IACN,SAAA,EAAW,SAAA;AAAA,IACX,eAAA,EAAiB;AAAA,GACnB;AAAA,EACA,KAAA,EAAO;AAAA,IACL,KAAA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AAA,CAAK,SAAS,KAAK,CAAA;AAAA,IAC5B;AAEA,IAAA,OAAO,IAAA,CAAK,WAAA,CAAY,IAAA,CAAK,eAAA,IAAmB,KAAK,CAAA;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA,EAKO,WAAA,CAAY,MAAmB,QAAA,EAA6C;AACjF,IAAA,OAAO;AAAA,MACL,GAAG,IAAA;AAAA,MACH,GAAG,QAAA;AAAA,MACH,IAAA,EAAM;AAAA,QACJ,GAAG,IAAA,CAAK,IAAA;AAAA,QACR,GAAG,QAAA,CAAS;AAAA,OACd;AAAA,MACA,OAAA,EAAS;AAAA,QACP,GAAG,IAAA,CAAK,OAAA;AAAA,QACR,GAAG,QAAA,CAAS;AAAA,OACd;AAAA,MACA,MAAA,EAAQ;AAAA,QACN,GAAG,IAAA,CAAK,MAAA;AAAA,QACR,GAAG,QAAA,CAAS;AAAA,OACd;AAAA,MACA,KAAA,EAAO;AAAA,QACL,GAAG,IAAA,CAAK,KAAA;AAAA,QACR,GAAG,QAAA,CAAS;AAAA,OACd;AAAA,MACA,YAAA,EAAc,QAAA,CAAS,YAAA,IAAgB,IAAA,CAAK;AAAA,KAC9C;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKO,mBAAA,CAAoB,OAAoB,KAAA,EAAuB;AACpE,IAAA,MAAM,OAAA,GAAU,KAAA,CAAM,YAAA,IAAgB,UAAA,CAAW,YAAA;AACjD,IAAA,OAAO,OAAA,CAAQ,KAAA,GAAQ,OAAA,CAAQ,MAAM,CAAA;AAAA,EACvC;AACF;AAGO,IAAM,eAAA,GAAkB,MAAoB,YAAA,CAAa,WAAA","file":"chunk-7GF5X23V.mjs","sourcesContent":["import type { ThemeConfig } from \"../types\";\r\n\r\n/**\r\n * Default light theme - clean white background with subtle grid\r\n */\r\nexport const lightTheme: ThemeConfig = {\r\n name: \"light\",\r\n backgroundColor: \"#f8f9fa\",\r\n textColor: \"#495057\",\r\n fontFamily:\r\n 'system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif',\r\n colorPalette: [\r\n \"#4285f4\", // Blue (Channel 1)\r\n \"#34a853\", // Green (Channel 2)\r\n \"#fbbc04\", // Orange/Yellow (Channel 3)\r\n \"#ea4335\", // Red (Channel 4)\r\n \"#9c27b0\", // Purple\r\n \"#00bcd4\", // Cyan\r\n \"#ff9800\", // Orange\r\n \"#8bc34a\", // Light Green\r\n \"#e91e63\", // Pink\r\n \"#607d8b\", // Blue Grey\r\n ],\r\n axis: {\r\n lineColor: \"#dee2e6\",\r\n labelColor: \"#6c757d\",\r\n titleColor: \"#495057\",\r\n gridLineColor: \"#e9ecef\",\r\n },\r\n tooltip: {\r\n backgroundColor: \"#212529\",\r\n textColor: \"#ffffff\",\r\n borderColor: \"#495057\",\r\n borderRadius: 6,\r\n },\r\n legend: {\r\n textColor: \"#495057\",\r\n backgroundColor: \"transparent\",\r\n },\r\n title: {\r\n color: \"#212529\",\r\n fontSize: 18,\r\n fontWeight: \"600\",\r\n },\r\n};\r\n\r\n/**\r\n * Default dark theme\r\n */\r\nexport const darkTheme: ThemeConfig = {\r\n name: \"dark\",\r\n backgroundColor: \"#0f172a\",\r\n textColor: \"#e2e8f0\",\r\n fontFamily:\r\n 'system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif',\r\n colorPalette: [\r\n \"#818cf8\", // Indigo (lighter)\r\n \"#fbbf24\", // Amber (lighter)\r\n \"#34d399\", // Emerald (lighter)\r\n \"#f87171\", // Red (lighter)\r\n \"#a78bfa\", // Violet (lighter)\r\n \"#22d3ee\", // Cyan (lighter)\r\n \"#fb923c\", // Orange (lighter)\r\n \"#a3e635\", // Lime (lighter)\r\n \"#f472b6\", // Pink (lighter)\r\n \"#2dd4bf\", // Teal (lighter)\r\n ],\r\n axis: {\r\n lineColor: \"#334155\",\r\n labelColor: \"#94a3b8\",\r\n titleColor: \"#cbd5e1\",\r\n gridLineColor: \"#1e293b\",\r\n },\r\n tooltip: {\r\n backgroundColor: \"#1e293b\",\r\n textColor: \"#f1f5f9\",\r\n borderColor: \"#475569\",\r\n borderRadius: 8,\r\n },\r\n legend: {\r\n textColor: \"#cbd5e1\",\r\n backgroundColor: \"transparent\",\r\n },\r\n title: {\r\n color: \"#f8fafc\",\r\n fontSize: 18,\r\n fontWeight: \"600\",\r\n },\r\n};\r\n\r\n/**\r\n * Modern gradient theme with vibrant colors\r\n */\r\nexport const modernTheme: ThemeConfig = {\r\n name: \"modern\",\r\n backgroundColor: \"#fafafa\",\r\n textColor: \"#18181b\",\r\n fontFamily: '\"Inter\", system-ui, sans-serif',\r\n colorPalette: [\r\n \"#7c3aed\", // Violet\r\n \"#2563eb\", // Blue\r\n \"#059669\", // Green\r\n \"#dc2626\", // Red\r\n \"#d97706\", // Amber\r\n \"#0891b2\", // Cyan\r\n \"#c026d3\", // Fuchsia\r\n \"#4f46e5\", // Indigo\r\n \"#16a34a\", // Green\r\n \"#9333ea\", // Purple\r\n ],\r\n axis: {\r\n lineColor: \"#e4e4e7\",\r\n labelColor: \"#71717a\",\r\n titleColor: \"#3f3f46\",\r\n gridLineColor: \"#f4f4f5\",\r\n },\r\n tooltip: {\r\n backgroundColor: \"#18181b\",\r\n textColor: \"#fafafa\",\r\n borderColor: \"#27272a\",\r\n borderRadius: 12,\r\n },\r\n legend: {\r\n textColor: \"#3f3f46\",\r\n backgroundColor: \"transparent\",\r\n },\r\n title: {\r\n color: \"#09090b\",\r\n fontSize: 20,\r\n fontWeight: \"700\",\r\n },\r\n};\r\n\r\n/**\r\n * Midnight theme - deep dark with neon accents\r\n */\r\nexport const midnightTheme: ThemeConfig = {\r\n name: \"midnight\",\r\n backgroundColor: \"#030712\",\r\n textColor: \"#d1d5db\",\r\n fontFamily: '\"JetBrains Mono\", monospace',\r\n colorPalette: [\r\n \"#22d3ee\", // Cyan\r\n \"#a855f7\", // Purple\r\n \"#4ade80\", // Green\r\n \"#fb7185\", // Pink\r\n \"#facc15\", // Yellow\r\n \"#38bdf8\", // Sky\r\n \"#f472b6\", // Pink\r\n \"#2dd4bf\", // Teal\r\n \"#c084fc\", // Purple\r\n \"#fbbf24\", // Amber\r\n ],\r\n axis: {\r\n lineColor: \"#1f2937\",\r\n labelColor: \"#6b7280\",\r\n titleColor: \"#9ca3af\",\r\n gridLineColor: \"#111827\",\r\n },\r\n tooltip: {\r\n backgroundColor: \"#111827\",\r\n textColor: \"#f9fafb\",\r\n borderColor: \"#22d3ee\",\r\n borderRadius: 4,\r\n },\r\n legend: {\r\n textColor: \"#9ca3af\",\r\n backgroundColor: \"transparent\",\r\n },\r\n title: {\r\n color: \"#f3f4f6\",\r\n fontSize: 18,\r\n fontWeight: \"500\",\r\n },\r\n};\r\n\r\n","import type { ThemeConfig } from \"../types\";\r\nimport { lightTheme, darkTheme, modernTheme, midnightTheme } from \"./defaultTheme\";\r\n\r\n/**\r\n * ThemeManager - Manages chart themes and provides theme resolution\r\n */\r\nexport class ThemeManager {\r\n private static instance: ThemeManager;\r\n private themes: Map<string, ThemeConfig> = new Map();\r\n private currentTheme: string = \"light\";\r\n\r\n private constructor() {\r\n // Register built-in themes\r\n this.registerTheme(lightTheme);\r\n this.registerTheme(darkTheme);\r\n this.registerTheme(modernTheme);\r\n this.registerTheme(midnightTheme);\r\n }\r\n\r\n /**\r\n * Get the singleton instance of ThemeManager\r\n */\r\n public static getInstance(): ThemeManager {\r\n if (!ThemeManager.instance) {\r\n ThemeManager.instance = new ThemeManager();\r\n }\r\n return ThemeManager.instance;\r\n }\r\n\r\n /**\r\n * Register a custom theme\r\n */\r\n public registerTheme(theme: ThemeConfig): void {\r\n if (!theme.name) {\r\n throw new Error(\"Theme must have a name\");\r\n }\r\n this.themes.set(theme.name, theme);\r\n }\r\n\r\n /**\r\n * Get a theme by name\r\n */\r\n public getTheme(name: string): ThemeConfig {\r\n const theme = this.themes.get(name);\r\n if (!theme) {\r\n console.warn(`Theme \"${name}\" not found, falling back to light theme`);\r\n return this.themes.get(\"light\")!;\r\n }\r\n return theme;\r\n }\r\n\r\n /**\r\n * Set the global default theme\r\n */\r\n public setDefaultTheme(name: string): void {\r\n if (!this.themes.has(name)) {\r\n throw new Error(`Theme \"${name}\" is not registered`);\r\n }\r\n this.currentTheme = name;\r\n }\r\n\r\n /**\r\n * Get the current default theme name\r\n */\r\n public getDefaultThemeName(): string {\r\n return this.currentTheme;\r\n }\r\n\r\n /**\r\n * Get the current default theme configuration\r\n */\r\n public getDefaultTheme(): ThemeConfig {\r\n return this.themes.get(this.currentTheme)!;\r\n }\r\n\r\n /**\r\n * Get all registered theme names\r\n */\r\n public getAvailableThemes(): string[] {\r\n return Array.from(this.themes.keys());\r\n }\r\n\r\n /**\r\n * Check if a theme is registered\r\n */\r\n public hasTheme(name: string): boolean {\r\n return this.themes.has(name);\r\n }\r\n\r\n /**\r\n * Resolve theme from string name or ThemeConfig object\r\n */\r\n public resolveTheme(theme?: ThemeConfig | string): ThemeConfig {\r\n if (!theme) {\r\n return this.getDefaultTheme();\r\n }\r\n if (typeof theme === \"string\") {\r\n return this.getTheme(theme);\r\n }\r\n // Merge with default theme for any missing properties\r\n return this.mergeThemes(this.getDefaultTheme(), theme);\r\n }\r\n\r\n /**\r\n * Merge two themes, with override taking precedence\r\n */\r\n public mergeThemes(base: ThemeConfig, override: Partial<ThemeConfig>): ThemeConfig {\r\n return {\r\n ...base,\r\n ...override,\r\n axis: {\r\n ...base.axis,\r\n ...override.axis,\r\n },\r\n tooltip: {\r\n ...base.tooltip,\r\n ...override.tooltip,\r\n },\r\n legend: {\r\n ...base.legend,\r\n ...override.legend,\r\n },\r\n title: {\r\n ...base.title,\r\n ...override.title,\r\n },\r\n colorPalette: override.colorPalette ?? base.colorPalette,\r\n };\r\n }\r\n\r\n /**\r\n * Get color from palette by index (cycles through palette)\r\n */\r\n public getColorFromPalette(theme: ThemeConfig, index: number): string {\r\n const palette = theme.colorPalette ?? lightTheme.colorPalette!;\r\n return palette[index % palette.length];\r\n }\r\n}\r\n\r\n// Export singleton getter for convenience\r\nexport const getThemeManager = (): ThemeManager => ThemeManager.getInstance();\r\n\r\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
+
}) : x)(function(x) {
|
|
4
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export { __require };
|
|
9
|
+
//# sourceMappingURL=chunk-BJTO5JO5.mjs.map
|
|
10
|
+
//# sourceMappingURL=chunk-BJTO5JO5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-BJTO5JO5.mjs"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
4
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
5
|
+
}) : x)(function(x) {
|
|
6
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
7
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
exports.__require = __require;
|
|
11
|
+
//# sourceMappingURL=chunk-DGUM43GV.js.map
|
|
12
|
+
//# sourceMappingURL=chunk-DGUM43GV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-DGUM43GV.js"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { SciChartSurface } from 'scichart';
|
|
2
|
+
|
|
3
|
+
// src/license/index.ts
|
|
4
|
+
|
|
5
|
+
// src/license/crypto.ts
|
|
6
|
+
var ALGORITHM = "AES-GCM";
|
|
7
|
+
var KEY_LENGTH = 256;
|
|
8
|
+
var STORAGE_KEY = "RMGRAPH_LICENSE_DATA";
|
|
9
|
+
function isCryptoAvailable() {
|
|
10
|
+
return typeof window !== "undefined" && typeof crypto !== "undefined" && crypto.subtle !== void 0;
|
|
11
|
+
}
|
|
12
|
+
function simpleEncode(data) {
|
|
13
|
+
const obfuscated = `rmgraph:${data}`;
|
|
14
|
+
return btoa(obfuscated);
|
|
15
|
+
}
|
|
16
|
+
function simpleDecode(encoded) {
|
|
17
|
+
try {
|
|
18
|
+
const decoded = atob(encoded);
|
|
19
|
+
if (decoded.startsWith("rmgraph:")) {
|
|
20
|
+
return decoded.substring(8);
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
} catch {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async function deriveKey(passphrase) {
|
|
28
|
+
if (!isCryptoAvailable()) {
|
|
29
|
+
throw new Error("Web Crypto API is not available. Requires HTTPS or localhost.");
|
|
30
|
+
}
|
|
31
|
+
const encoder = new TextEncoder();
|
|
32
|
+
const keyMaterial = await crypto.subtle.importKey(
|
|
33
|
+
"raw",
|
|
34
|
+
encoder.encode(passphrase),
|
|
35
|
+
"PBKDF2",
|
|
36
|
+
false,
|
|
37
|
+
["deriveKey"]
|
|
38
|
+
);
|
|
39
|
+
const salt = encoder.encode("rmgraph-license-salt-v1");
|
|
40
|
+
return crypto.subtle.deriveKey(
|
|
41
|
+
{
|
|
42
|
+
name: "PBKDF2",
|
|
43
|
+
salt,
|
|
44
|
+
iterations: 1e5,
|
|
45
|
+
hash: "SHA-256"
|
|
46
|
+
},
|
|
47
|
+
keyMaterial,
|
|
48
|
+
{ name: ALGORITHM, length: KEY_LENGTH },
|
|
49
|
+
false,
|
|
50
|
+
["encrypt", "decrypt"]
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
async function encryptLicense(licenseKey, passphrase) {
|
|
54
|
+
if (!isCryptoAvailable()) {
|
|
55
|
+
return simpleEncode(licenseKey);
|
|
56
|
+
}
|
|
57
|
+
const key = await deriveKey(passphrase);
|
|
58
|
+
const encoder = new TextEncoder();
|
|
59
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
60
|
+
const encrypted = await crypto.subtle.encrypt(
|
|
61
|
+
{ name: ALGORITHM, iv },
|
|
62
|
+
key,
|
|
63
|
+
encoder.encode(licenseKey)
|
|
64
|
+
);
|
|
65
|
+
const combined = new Uint8Array(iv.length + encrypted.byteLength);
|
|
66
|
+
combined.set(iv);
|
|
67
|
+
combined.set(new Uint8Array(encrypted), iv.length);
|
|
68
|
+
return btoa(String.fromCharCode(...combined));
|
|
69
|
+
}
|
|
70
|
+
async function decryptLicense(encryptedData, passphrase) {
|
|
71
|
+
try {
|
|
72
|
+
const simpleDecoded = simpleDecode(encryptedData);
|
|
73
|
+
if (simpleDecoded !== null) {
|
|
74
|
+
return simpleDecoded;
|
|
75
|
+
}
|
|
76
|
+
if (!isCryptoAvailable()) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
const key = await deriveKey(passphrase);
|
|
80
|
+
const combined = Uint8Array.from(atob(encryptedData), (c) => c.charCodeAt(0));
|
|
81
|
+
const iv = combined.slice(0, 12);
|
|
82
|
+
const data = combined.slice(12);
|
|
83
|
+
const decrypted = await crypto.subtle.decrypt(
|
|
84
|
+
{ name: ALGORITHM, iv },
|
|
85
|
+
key,
|
|
86
|
+
data
|
|
87
|
+
);
|
|
88
|
+
return new TextDecoder().decode(decrypted);
|
|
89
|
+
} catch {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function saveEncryptedLicense(licenseKey, passphrase) {
|
|
94
|
+
if (typeof window === "undefined" || !window.localStorage) {
|
|
95
|
+
throw new Error("localStorage is not available");
|
|
96
|
+
}
|
|
97
|
+
const encrypted = await encryptLicense(licenseKey, passphrase);
|
|
98
|
+
localStorage.setItem(STORAGE_KEY, encrypted);
|
|
99
|
+
}
|
|
100
|
+
async function loadEncryptedLicense(passphrase) {
|
|
101
|
+
if (typeof window === "undefined" || !window.localStorage) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const encrypted = localStorage.getItem(STORAGE_KEY);
|
|
105
|
+
if (!encrypted) return null;
|
|
106
|
+
return decryptLicense(encrypted, passphrase);
|
|
107
|
+
}
|
|
108
|
+
function hasEncryptedLicense() {
|
|
109
|
+
if (typeof window === "undefined" || !window.localStorage) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
return localStorage.getItem(STORAGE_KEY) !== null;
|
|
113
|
+
}
|
|
114
|
+
function clearStoredLicense() {
|
|
115
|
+
if (typeof window === "undefined" || !window.localStorage) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
localStorage.removeItem(STORAGE_KEY);
|
|
119
|
+
}
|
|
120
|
+
function getLicenseStorageKey() {
|
|
121
|
+
return STORAGE_KEY;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/license/index.ts
|
|
125
|
+
var DEFAULT_PASSPHRASE = "rmgraph-default-key-2024";
|
|
126
|
+
var currentPassphrase = DEFAULT_PASSPHRASE;
|
|
127
|
+
var licenseApplied = false;
|
|
128
|
+
function configureLicenseEncryption(config) {
|
|
129
|
+
if (config.passphrase) {
|
|
130
|
+
currentPassphrase = config.passphrase;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function getCurrentPassphrase() {
|
|
134
|
+
return currentPassphrase;
|
|
135
|
+
}
|
|
136
|
+
function resetPassphrase() {
|
|
137
|
+
currentPassphrase = DEFAULT_PASSPHRASE;
|
|
138
|
+
}
|
|
139
|
+
async function setLicense(licenseKey) {
|
|
140
|
+
try {
|
|
141
|
+
if (!licenseKey || typeof licenseKey !== "string") {
|
|
142
|
+
throw new Error("Invalid license key");
|
|
143
|
+
}
|
|
144
|
+
await saveEncryptedLicense(licenseKey.trim(), currentPassphrase);
|
|
145
|
+
SciChartSurface.setRuntimeLicenseKey(licenseKey.trim());
|
|
146
|
+
licenseApplied = true;
|
|
147
|
+
return true;
|
|
148
|
+
} catch (error) {
|
|
149
|
+
console.error("Failed to set license:", error);
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async function loadLicense() {
|
|
154
|
+
try {
|
|
155
|
+
const licenseKey = await loadEncryptedLicense(currentPassphrase);
|
|
156
|
+
if (licenseKey) {
|
|
157
|
+
SciChartSurface.setRuntimeLicenseKey(licenseKey);
|
|
158
|
+
licenseApplied = true;
|
|
159
|
+
return true;
|
|
160
|
+
}
|
|
161
|
+
return false;
|
|
162
|
+
} catch (error) {
|
|
163
|
+
console.error("Failed to load license:", error);
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
function hasStoredLicense() {
|
|
168
|
+
return hasEncryptedLicense();
|
|
169
|
+
}
|
|
170
|
+
function isLicenseApplied() {
|
|
171
|
+
return licenseApplied;
|
|
172
|
+
}
|
|
173
|
+
function removeLicense() {
|
|
174
|
+
clearStoredLicense();
|
|
175
|
+
licenseApplied = false;
|
|
176
|
+
}
|
|
177
|
+
function applyLicenseKey(licenseKey) {
|
|
178
|
+
if (licenseKey && typeof licenseKey === "string") {
|
|
179
|
+
SciChartSurface.setRuntimeLicenseKey(licenseKey.trim());
|
|
180
|
+
licenseApplied = true;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function getLicenseStatus() {
|
|
184
|
+
return {
|
|
185
|
+
hasLicense: hasStoredLicense(),
|
|
186
|
+
isApplied: licenseApplied
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
function validateLicenseFormat(licenseKey) {
|
|
190
|
+
if (!licenseKey || typeof licenseKey !== "string") {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
193
|
+
const trimmed = licenseKey.trim();
|
|
194
|
+
return trimmed.length >= 10 && trimmed.length <= 5e3;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export { applyLicenseKey, clearStoredLicense, configureLicenseEncryption, decryptLicense, encryptLicense, getCurrentPassphrase, getLicenseStatus, getLicenseStorageKey, hasEncryptedLicense, hasStoredLicense, isLicenseApplied, loadEncryptedLicense, loadLicense, removeLicense, resetPassphrase, saveEncryptedLicense, setLicense, validateLicenseFormat };
|
|
198
|
+
//# sourceMappingURL=chunk-PKJHVSFI.mjs.map
|
|
199
|
+
//# sourceMappingURL=chunk-PKJHVSFI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/license/crypto.ts","../src/license/index.ts"],"names":[],"mappings":";;;;;AASA,IAAM,SAAA,GAAY,SAAA;AAClB,IAAM,UAAA,GAAa,GAAA;AACnB,IAAM,WAAA,GAAc,sBAAA;AAMpB,SAAS,iBAAA,GAA6B;AACpC,EAAA,OACE,OAAO,MAAA,KAAW,WAAA,IAClB,OAAO,MAAA,KAAW,WAAA,IAClB,OAAO,MAAA,KAAW,MAAA;AAEtB;AAMA,SAAS,aAAa,IAAA,EAAsB;AAE1C,EAAA,MAAM,UAAA,GAAa,WAAW,IAAI,CAAA,CAAA;AAClC,EAAA,OAAO,KAAK,UAAU,CAAA;AACxB;AAKA,SAAS,aAAa,OAAA,EAAgC;AACpD,EAAA,IAAI;AACF,IAAA,MAAM,OAAA,GAAU,KAAK,OAAO,CAAA;AAC5B,IAAA,IAAI,OAAA,CAAQ,UAAA,CAAW,UAAU,CAAA,EAAG;AAClC,MAAA,OAAO,OAAA,CAAQ,UAAU,CAAC,CAAA;AAAA,IAC5B;AACA,IAAA,OAAO,IAAA;AAAA,EACT,CAAA,CAAA,MAAQ;AACN,IAAA,OAAO,IAAA;AAAA,EACT;AACF;AAKA,eAAe,UAAU,UAAA,EAAwC;AAC/D,EAAA,IAAI,CAAC,mBAAkB,EAAG;AACxB,IAAA,MAAM,IAAI,MAAM,+DAA+D,CAAA;AAAA,EACjF;AAEA,EAAA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,KAAe,QAAA,EAAU;AAChD,IAAA,eAAA,CAAgB,oBAAA,CAAqB,UAAA,CAAW,IAAA,EAAM,CAAA;AACtD,IAAA,cAAA,GAAiB,IAAA;AAAA,EACnB;AACF;AAOO,SAAS,gBAAA,GAAkC;AAChD,EAAA,OAAO;AAAA,IACL,YAAY,gBAAA,EAAiB;AAAA,IAC7B,SAAA,EAAW;AAAA,GACb;AACF;AASO,SAAS,sBAAsB,UAAA,EAA6B;AACjE,EAAA,IAAI,CAAC,UAAA,IAAc,OAAO,UAAA,KAAe,QAAA,EAAU;AACjD,IAAA,OAAO,KAAA;AAAA,EACT;AAEA,EAAA,MAAM,OAAA,GAAU,WAAW,IAAA,EAAK;AAGhC,EAAA,OAAO,OAAA,CAAQ,MAAA,IAAU,EAAA,IAAM,OAAA,CAAQ,MAAA,IAAU,GAAA;AACnD","file":"chunk-PKJHVSFI.mjs","sourcesContent":["/**\r\n * Generic encryption/decryption utilities using Web Crypto API\r\n * Provides obfuscation for license keys stored in localStorage\r\n * \r\n * Note: This provides obfuscation, not true security.\r\n * The decryption key is in client code, so determined attackers can still decrypt.\r\n * For production, combine with SciChart's domain-locking for real protection.\r\n */\r\n\r\nconst ALGORITHM = 'AES-GCM';\r\nconst KEY_LENGTH = 256;\r\nconst STORAGE_KEY = 'RMGRAPH_LICENSE_DATA';\r\n\r\n/**\r\n * Check if Web Crypto API is available\r\n * Web Crypto API requires HTTPS or localhost (secure context)\r\n */\r\nfunction isCryptoAvailable(): boolean {\r\n return (\r\n typeof window !== 'undefined' &&\r\n typeof crypto !== 'undefined' &&\r\n crypto.subtle !== undefined\r\n );\r\n}\r\n\r\n/**\r\n * Simple base64 encoding fallback when Web Crypto is not available\r\n * This provides basic obfuscation (not encryption)\r\n */\r\nfunction simpleEncode(data: string): string {\r\n // Add a simple obfuscation prefix to distinguish from plain text\r\n const obfuscated = `rmgraph:${data}`;\r\n return btoa(obfuscated);\r\n}\r\n\r\n/**\r\n * Simple base64 decoding fallback\r\n */\r\nfunction simpleDecode(encoded: string): string | null {\r\n try {\r\n const decoded = atob(encoded);\r\n if (decoded.startsWith('rmgraph:')) {\r\n return decoded.substring(8); // Remove prefix\r\n }\r\n return null;\r\n } catch {\r\n return null;\r\n }\r\n}\r\n\r\n/**\r\n * Derive a consistent cryptographic key from a passphrase\r\n */\r\nasync function deriveKey(passphrase: string): Promise<CryptoKey> {\r\n if (!isCryptoAvailable()) {\r\n throw new Error('Web Crypto API is not available. Requires HTTPS or localhost.');\r\n }\r\n\r\n const encoder = new TextEncoder();\r\n const keyMaterial = await crypto.subtle!.importKey(\r\n 'raw',\r\n encoder.encode(passphrase),\r\n 'PBKDF2',\r\n false,\r\n ['deriveKey']\r\n );\r\n\r\n // Use a fixed salt for consistency across encrypt/decrypt\r\n const salt = encoder.encode('rmgraph-license-salt-v1');\r\n\r\n return crypto.subtle!.deriveKey(\r\n {\r\n name: 'PBKDF2',\r\n salt,\r\n iterations: 100000,\r\n hash: 'SHA-256',\r\n },\r\n keyMaterial,\r\n { name: ALGORITHM, length: KEY_LENGTH },\r\n false,\r\n ['encrypt', 'decrypt']\r\n );\r\n}\r\n\r\n/**\r\n * Encrypt a license key string\r\n * @param licenseKey - The plain text license key\r\n * @param passphrase - The passphrase to derive encryption key from\r\n * @returns Base64 encoded encrypted data\r\n */\r\nexport async function encryptLicense(\r\n licenseKey: string,\r\n passphrase: string\r\n): Promise<string> {\r\n // Fallback to simple encoding if Web Crypto is not available\r\n if (!isCryptoAvailable()) {\r\n return simpleEncode(licenseKey);\r\n }\r\n\r\n const key = await deriveKey(passphrase);\r\n const encoder = new TextEncoder();\r\n const iv = crypto.getRandomValues(new Uint8Array(12));\r\n\r\n const encrypted = await crypto.subtle!.encrypt(\r\n { name: ALGORITHM, iv },\r\n key,\r\n encoder.encode(licenseKey)\r\n );\r\n\r\n // Combine IV + encrypted data and encode as base64\r\n const combined = new Uint8Array(iv.length + encrypted.byteLength);\r\n combined.set(iv);\r\n combined.set(new Uint8Array(encrypted), iv.length);\r\n\r\n return btoa(String.fromCharCode(...combined));\r\n}\r\n\r\n/**\r\n * Decrypt an encrypted license key\r\n * @param encryptedData - Base64 encoded encrypted data\r\n * @param passphrase - The passphrase to derive decryption key from\r\n * @returns The decrypted license key or null if decryption fails\r\n */\r\nexport async function decryptLicense(\r\n encryptedData: string,\r\n passphrase: string\r\n): Promise<string | null> {\r\n try {\r\n // Try simple decode first (for fallback encoding)\r\n const simpleDecoded = simpleDecode(encryptedData);\r\n if (simpleDecoded !== null) {\r\n return simpleDecoded;\r\n }\r\n\r\n // If Web Crypto is not available, we can't decrypt AES-encrypted data\r\n if (!isCryptoAvailable()) {\r\n return null;\r\n }\r\n\r\n // Try AES decryption\r\n const key = await deriveKey(passphrase);\r\n const combined = Uint8Array.from(atob(encryptedData), (c) => c.charCodeAt(0));\r\n\r\n const iv = combined.slice(0, 12);\r\n const data = combined.slice(12);\r\n\r\n const decrypted = await crypto.subtle!.decrypt(\r\n { name: ALGORITHM, iv },\r\n key,\r\n data\r\n );\r\n\r\n return new TextDecoder().decode(decrypted);\r\n } catch {\r\n return null;\r\n }\r\n}\r\n\r\n/**\r\n * Save encrypted license to localStorage\r\n * @param licenseKey - The plain text license key\r\n * @param passphrase - The passphrase for encryption\r\n */\r\nexport async function saveEncryptedLicense(\r\n licenseKey: string,\r\n passphrase: string\r\n): Promise<void> {\r\n if (typeof window === 'undefined' || !window.localStorage) {\r\n throw new Error('localStorage is not available');\r\n }\r\n const encrypted = await encryptLicense(licenseKey, passphrase);\r\n localStorage.setItem(STORAGE_KEY, encrypted);\r\n}\r\n\r\n/**\r\n * Load and decrypt license from localStorage\r\n * @param passphrase - The passphrase for decryption\r\n * @returns The decrypted license key or null if not found/decryption fails\r\n */\r\nexport async function loadEncryptedLicense(\r\n passphrase: string\r\n): Promise<string | null> {\r\n if (typeof window === 'undefined' || !window.localStorage) {\r\n return null;\r\n }\r\n const encrypted = localStorage.getItem(STORAGE_KEY);\r\n if (!encrypted) return null;\r\n return decryptLicense(encrypted, passphrase);\r\n}\r\n\r\n/**\r\n * Check if an encrypted license exists in localStorage\r\n */\r\nexport function hasEncryptedLicense(): boolean {\r\n if (typeof window === 'undefined' || !window.localStorage) {\r\n return false;\r\n }\r\n return localStorage.getItem(STORAGE_KEY) !== null;\r\n}\r\n\r\n/**\r\n * Clear stored license from localStorage\r\n */\r\nexport function clearStoredLicense(): void {\r\n if (typeof window === 'undefined' || !window.localStorage) {\r\n return;\r\n }\r\n localStorage.removeItem(STORAGE_KEY);\r\n}\r\n\r\n/**\r\n * Get the storage key used for license data\r\n */\r\nexport function getLicenseStorageKey(): string {\r\n return STORAGE_KEY;\r\n}\r\n","/**\r\n * License management module for @rm-graph packages\r\n * \r\n * Provides encrypted storage and retrieval of SciChart license keys.\r\n * License keys are encrypted using AES-256-GCM before storing in localStorage.\r\n * \r\n * @example\r\n * ```typescript\r\n * import { setLicense, loadLicense, configureLicenseEncryption } from '@rm-graph/core';\r\n * \r\n * // Optional: Configure custom passphrase\r\n * configureLicenseEncryption({ passphrase: 'your-app-secret' });\r\n * \r\n * // Save a license (encrypts and stores in localStorage)\r\n * await setLicense('your-scichart-license-key');\r\n * \r\n * // Load license on app startup\r\n * await loadLicense();\r\n * ```\r\n */\r\n\r\nimport { SciChartSurface } from 'scichart';\r\nimport {\r\n encryptLicense,\r\n decryptLicense,\r\n saveEncryptedLicense,\r\n loadEncryptedLicense,\r\n hasEncryptedLicense,\r\n clearStoredLicense,\r\n getLicenseStorageKey,\r\n} from './crypto';\r\n\r\n// Re-export crypto utilities for advanced usage\r\nexport {\r\n encryptLicense,\r\n decryptLicense,\r\n saveEncryptedLicense,\r\n loadEncryptedLicense,\r\n hasEncryptedLicense,\r\n clearStoredLicense,\r\n getLicenseStorageKey,\r\n};\r\n\r\n/**\r\n * Configuration options for license encryption\r\n */\r\nexport interface LicenseConfig {\r\n /** Custom passphrase for encryption/decryption (optional) */\r\n passphrase?: string;\r\n}\r\n\r\n/**\r\n * License status information\r\n */\r\nexport interface LicenseStatus {\r\n /** Whether a license is stored */\r\n hasLicense: boolean;\r\n /** Whether the license was successfully loaded and applied */\r\n isApplied: boolean;\r\n /** Error message if any */\r\n error?: string;\r\n}\r\n\r\n// Default passphrase (can be overridden by the application)\r\nconst DEFAULT_PASSPHRASE = 'rmgraph-default-key-2024';\r\n\r\n// Current passphrase (mutable)\r\nlet currentPassphrase = DEFAULT_PASSPHRASE;\r\n\r\n// Track if license has been applied\r\nlet licenseApplied = false;\r\n\r\n/**\r\n * Configure the license encryption passphrase\r\n * Call this before saving or loading licenses if you want to use a custom passphrase\r\n * \r\n * @param config - Configuration options\r\n * \r\n * @example\r\n * ```typescript\r\n * configureLicenseEncryption({ passphrase: 'my-app-secret-key' });\r\n * ```\r\n */\r\nexport function configureLicenseEncryption(config: LicenseConfig): void {\r\n if (config.passphrase) {\r\n currentPassphrase = config.passphrase;\r\n }\r\n}\r\n\r\n/**\r\n * Get the current passphrase (for internal use)\r\n */\r\nexport function getCurrentPassphrase(): string {\r\n return currentPassphrase;\r\n}\r\n\r\n/**\r\n * Reset passphrase to default\r\n */\r\nexport function resetPassphrase(): void {\r\n currentPassphrase = DEFAULT_PASSPHRASE;\r\n}\r\n\r\n/**\r\n * Save and apply a SciChart license key\r\n * Encrypts the key and stores it in localStorage, then applies it to SciChart\r\n * \r\n * @param licenseKey - The SciChart license key to save\r\n * @returns Promise resolving to true if successful, false otherwise\r\n * \r\n * @example\r\n * ```typescript\r\n * const success = await setLicense('your-scichart-license-key');\r\n * if (success) {\r\n * console.log('License saved and applied!');\r\n * }\r\n * ```\r\n */\r\nexport async function setLicense(licenseKey: string): Promise<boolean> {\r\n try {\r\n if (!licenseKey || typeof licenseKey !== 'string') {\r\n throw new Error('Invalid license key');\r\n }\r\n\r\n // Save encrypted to localStorage\r\n await saveEncryptedLicense(licenseKey.trim(), currentPassphrase);\r\n\r\n // Apply to SciChart\r\n SciChartSurface.setRuntimeLicenseKey(licenseKey.trim());\r\n licenseApplied = true;\r\n\r\n return true;\r\n } catch (error) {\r\n console.error('Failed to set license:', error);\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * Load license from localStorage and apply to SciChart\r\n * \r\n * @returns Promise resolving to true if license was found and applied, false otherwise\r\n * \r\n * @example\r\n * ```typescript\r\n * // Call on app startup\r\n * const loaded = await loadLicense();\r\n * if (loaded) {\r\n * console.log('License loaded from storage');\r\n * } else {\r\n * console.log('No license found - charts will show watermark');\r\n * }\r\n * ```\r\n */\r\nexport async function loadLicense(): Promise<boolean> {\r\n try {\r\n const licenseKey = await loadEncryptedLicense(currentPassphrase);\r\n\r\n if (licenseKey) {\r\n SciChartSurface.setRuntimeLicenseKey(licenseKey);\r\n licenseApplied = true;\r\n return true;\r\n }\r\n\r\n return false;\r\n } catch (error) {\r\n console.error('Failed to load license:', error);\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * Check if a license is stored in localStorage\r\n * \r\n * @returns true if a license exists in storage\r\n */\r\nexport function hasStoredLicense(): boolean {\r\n return hasEncryptedLicense();\r\n}\r\n\r\n/**\r\n * Check if a license has been applied to SciChart in this session\r\n * \r\n * @returns true if a license has been applied\r\n */\r\nexport function isLicenseApplied(): boolean {\r\n return licenseApplied;\r\n}\r\n\r\n/**\r\n * Remove stored license from localStorage\r\n * Note: This doesn't remove the license from SciChart (requires page reload)\r\n */\r\nexport function removeLicense(): void {\r\n clearStoredLicense();\r\n licenseApplied = false;\r\n}\r\n\r\n/**\r\n * Apply a license key directly without storing it\r\n * Useful for temporary/session-only license application\r\n * \r\n * @param licenseKey - The SciChart license key\r\n */\r\nexport function applyLicenseKey(licenseKey: string): void {\r\n if (licenseKey && typeof licenseKey === 'string') {\r\n SciChartSurface.setRuntimeLicenseKey(licenseKey.trim());\r\n licenseApplied = true;\r\n }\r\n}\r\n\r\n/**\r\n * Get current license status\r\n * \r\n * @returns License status information\r\n */\r\nexport function getLicenseStatus(): LicenseStatus {\r\n return {\r\n hasLicense: hasStoredLicense(),\r\n isApplied: licenseApplied,\r\n };\r\n}\r\n\r\n/**\r\n * Validate a license key format (basic validation)\r\n * Note: This doesn't validate if the license is actually valid with SciChart\r\n * \r\n * @param licenseKey - The license key to validate\r\n * @returns true if the format appears valid\r\n */\r\nexport function validateLicenseFormat(licenseKey: string): boolean {\r\n if (!licenseKey || typeof licenseKey !== 'string') {\r\n return false;\r\n }\r\n \r\n const trimmed = licenseKey.trim();\r\n \r\n // Basic validation: must be non-empty and have reasonable length\r\n return trimmed.length >= 10 && trimmed.length <= 5000;\r\n}\r\n"]}
|