openalgo-charts 2.3.2 → 2.4.5
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 +68 -39
- package/dist/draw/index.d.ts +18 -2
- package/dist/index.d.ts +2541 -1758
- package/dist/indicators/index.d.ts +103 -8
- package/dist/openalgo-charts.draw.mjs +1 -1
- package/dist/openalgo-charts.draw.mjs.map +1 -1
- package/dist/openalgo-charts.indicators.mjs +1 -1
- package/dist/openalgo-charts.indicators.mjs.map +1 -1
- package/dist/openalgo-charts.mjs +1 -1
- package/dist/openalgo-charts.mjs.map +1 -1
- package/dist/openalgo-charts.standalone.js +1 -1
- package/dist/openalgo-charts.standalone.js.map +1 -1
- package/dist/openalgo-charts.trade.mjs +1 -1
- package/dist/openalgo-charts.trade.mjs.map +1 -1
- package/dist/openalgo-charts.transform.mjs +1 -1
- package/dist/openalgo-charts.transform.mjs.map +1 -1
- package/dist/openalgo-charts.webgl.mjs +1 -1
- package/dist/openalgo-charts.webgl.mjs.map +1 -1
- package/dist/openalgo-charts.widget.mjs +1 -1
- package/dist/openalgo-charts.widget.mjs.map +1 -1
- package/dist/openalgo-charts.workspace.mjs +2 -0
- package/dist/openalgo-charts.workspace.mjs.map +1 -0
- package/dist/profile/index.d.ts +31 -0
- package/dist/trade/index.d.ts +15 -4
- package/dist/transform/index.d.ts +41 -2
- package/dist/webgl/index.d.ts +39 -0
- package/dist/widget/index.d.ts +96 -8
- package/dist/workspace/index.d.ts +170 -0
- package/package.json +8 -2
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { ChartState, ChartSettingsState, IndicatorState } from 'openalgo-charts';
|
|
2
|
+
|
|
3
|
+
declare class WorkspaceDocumentError extends Error {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
declare const WORKSPACE_VERSION = 1;
|
|
8
|
+
type WorkspaceKind = 'workspace' | 'indicator-template';
|
|
9
|
+
type WorkspaceSettings = Record<string, string | number | boolean>;
|
|
10
|
+
type WorkspaceChartState = ChartState & ChartSettingsState & {
|
|
11
|
+
timezone?: string;
|
|
12
|
+
};
|
|
13
|
+
interface WorkspaceComparison {
|
|
14
|
+
id: string;
|
|
15
|
+
symbol: string;
|
|
16
|
+
exchange: string;
|
|
17
|
+
color?: string;
|
|
18
|
+
visible: boolean;
|
|
19
|
+
}
|
|
20
|
+
interface WorkspaceSlot {
|
|
21
|
+
paneId: string;
|
|
22
|
+
row: number;
|
|
23
|
+
column: number;
|
|
24
|
+
rowSpan: number;
|
|
25
|
+
columnSpan: number;
|
|
26
|
+
}
|
|
27
|
+
interface WorkspacePane {
|
|
28
|
+
id: string;
|
|
29
|
+
symbol: string;
|
|
30
|
+
exchange: string;
|
|
31
|
+
interval: string;
|
|
32
|
+
chartType: string;
|
|
33
|
+
chart: WorkspaceChartState;
|
|
34
|
+
settings: WorkspaceSettings;
|
|
35
|
+
volume: boolean;
|
|
36
|
+
magnet: 'off' | 'weak' | 'strong';
|
|
37
|
+
stay: boolean;
|
|
38
|
+
comparisons: WorkspaceComparison[];
|
|
39
|
+
comparisonMode: 'price' | 'percent';
|
|
40
|
+
historyPeriod?: string;
|
|
41
|
+
}
|
|
42
|
+
interface WorkspacePayload {
|
|
43
|
+
layout: {
|
|
44
|
+
rows: number;
|
|
45
|
+
columns: number;
|
|
46
|
+
slots: WorkspaceSlot[];
|
|
47
|
+
preset?: string;
|
|
48
|
+
rowWeights?: number[];
|
|
49
|
+
columnWeights?: number[];
|
|
50
|
+
};
|
|
51
|
+
panes: WorkspacePane[];
|
|
52
|
+
activePaneId: string;
|
|
53
|
+
sync: {
|
|
54
|
+
crosshair: boolean;
|
|
55
|
+
viewport: boolean;
|
|
56
|
+
symbol: boolean;
|
|
57
|
+
interval: boolean;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
interface DocumentMetadata {
|
|
61
|
+
version: 1;
|
|
62
|
+
id: string;
|
|
63
|
+
name: string;
|
|
64
|
+
createdAt: number;
|
|
65
|
+
updatedAt: number;
|
|
66
|
+
}
|
|
67
|
+
interface WorkspaceDocument extends DocumentMetadata, WorkspacePayload {
|
|
68
|
+
kind: 'workspace';
|
|
69
|
+
}
|
|
70
|
+
interface IndicatorTemplateDocument extends DocumentMetadata {
|
|
71
|
+
kind: 'indicator-template';
|
|
72
|
+
indicators: IndicatorState[];
|
|
73
|
+
}
|
|
74
|
+
/** Keep repeated/custom descriptor IDs; availability is checked by the applying host. */
|
|
75
|
+
declare function parseIndicatorStates(input: unknown): IndicatorState[];
|
|
76
|
+
/** Validate, detach and project a portable chart-only workspace. */
|
|
77
|
+
declare function parseWorkspaceDocument(input: unknown): WorkspaceDocument;
|
|
78
|
+
declare function parseWorkspacePayload(input: unknown): WorkspacePayload;
|
|
79
|
+
declare function parseIndicatorTemplate(input: unknown): IndicatorTemplateDocument;
|
|
80
|
+
/** Explicit migration of the existing single-widget state; no input is modified. */
|
|
81
|
+
declare function migrateWidgetWorkspace(input: unknown, meta: {
|
|
82
|
+
id: string;
|
|
83
|
+
name: string;
|
|
84
|
+
now: number;
|
|
85
|
+
}): WorkspaceDocument;
|
|
86
|
+
|
|
87
|
+
interface WorkspaceCatalog {
|
|
88
|
+
version: 1;
|
|
89
|
+
revision: number;
|
|
90
|
+
workspaces: WorkspaceDocument[];
|
|
91
|
+
templates: IndicatorTemplateDocument[];
|
|
92
|
+
recentWorkspaceIds: string[];
|
|
93
|
+
activeWorkspaceId: string | null;
|
|
94
|
+
autosave: boolean;
|
|
95
|
+
}
|
|
96
|
+
/** Cancellation is effective until the storage transaction commits. */
|
|
97
|
+
interface WorkspaceOperationOptions {
|
|
98
|
+
signal?: AbortSignal;
|
|
99
|
+
}
|
|
100
|
+
interface WorkspaceOpenOptions extends WorkspaceOperationOptions {
|
|
101
|
+
/** Reject if a grid was prepared from a catalog that has since changed. */
|
|
102
|
+
expectedRevision?: number;
|
|
103
|
+
}
|
|
104
|
+
/** The host must atomically reject writes whose expectedRevision is stale. */
|
|
105
|
+
interface WorkspaceStorage {
|
|
106
|
+
read(namespace: string): Promise<unknown | null>;
|
|
107
|
+
write(namespace: string, catalog: WorkspaceCatalog, expectedRevision: number, options?: WorkspaceOperationOptions): Promise<void>;
|
|
108
|
+
}
|
|
109
|
+
interface WorkspaceRepositoryOptions {
|
|
110
|
+
now?: () => number;
|
|
111
|
+
id?: () => string;
|
|
112
|
+
}
|
|
113
|
+
declare class WorkspaceConflictError extends Error {
|
|
114
|
+
constructor();
|
|
115
|
+
}
|
|
116
|
+
/** Parse the complete catalog before any mutation; corrupt storage is never replaced. */
|
|
117
|
+
declare function parseWorkspaceCatalog(input: unknown): WorkspaceCatalog;
|
|
118
|
+
/**
|
|
119
|
+
* Named configuration with serialized, revision-checked writes. Create a new
|
|
120
|
+
* repository when the account changes; an in-flight operation keeps its owner.
|
|
121
|
+
*/
|
|
122
|
+
declare class WorkspaceRepository {
|
|
123
|
+
private readonly _storage;
|
|
124
|
+
private readonly _namespace;
|
|
125
|
+
private readonly _now;
|
|
126
|
+
private readonly _id;
|
|
127
|
+
private _queue;
|
|
128
|
+
constructor(storage: WorkspaceStorage, namespace: string, options?: WorkspaceRepositoryOptions);
|
|
129
|
+
get namespace(): string;
|
|
130
|
+
load(): Promise<WorkspaceCatalog>;
|
|
131
|
+
createWorkspace(name: string, input: WorkspacePayload): Promise<WorkspaceDocument>;
|
|
132
|
+
saveWorkspace(id: string, input: WorkspacePayload): Promise<WorkspaceDocument>;
|
|
133
|
+
createTemplate(name: string, input: IndicatorState[]): Promise<IndicatorTemplateDocument>;
|
|
134
|
+
/** Update reusable study settings without changing the saved template identity. */
|
|
135
|
+
saveTemplate(id: string, input: IndicatorState[]): Promise<IndicatorTemplateDocument>;
|
|
136
|
+
rename(kind: WorkspaceKind, id: string, name: string): Promise<void>;
|
|
137
|
+
duplicate(kind: WorkspaceKind, id: string, name: string): Promise<WorkspaceDocument | IndicatorTemplateDocument>;
|
|
138
|
+
remove(kind: WorkspaceKind, id: string): Promise<void>;
|
|
139
|
+
openWorkspace(id: string, options?: WorkspaceOpenOptions): Promise<WorkspaceDocument>;
|
|
140
|
+
setAutosave(enabled: boolean): Promise<void>;
|
|
141
|
+
importDocument(input: unknown): Promise<WorkspaceDocument | IndicatorTemplateDocument>;
|
|
142
|
+
exportDocument(kind: WorkspaceKind, id: string): Promise<string>;
|
|
143
|
+
private _read;
|
|
144
|
+
private _transact;
|
|
145
|
+
private _find;
|
|
146
|
+
private _updatedAt;
|
|
147
|
+
private _newId;
|
|
148
|
+
private _insert;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
interface IndexedDbWorkspaceStorage extends WorkspaceStorage {
|
|
152
|
+
/** Release the connection. Existing transactions may finish; new calls reject. */
|
|
153
|
+
close(): Promise<void>;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Browser persistence with one atomic compare-and-write transaction per catalog.
|
|
157
|
+
* Pass the host's indexedDB explicitly; importing this module needs no browser.
|
|
158
|
+
*/
|
|
159
|
+
declare function createIndexedDbWorkspaceStorage(factory: IDBFactory, databaseName?: string): IndexedDbWorkspaceStorage;
|
|
160
|
+
|
|
161
|
+
type IndicatorTemplateMode = 'replace' | 'append';
|
|
162
|
+
/**
|
|
163
|
+
* Validate and detach a study plan before the host changes a chart. Append keeps
|
|
164
|
+
* current instance identities and places positive incoming pane groups after the
|
|
165
|
+
* existing panes; pane zero remains the price pane. Copied studies have no identity.
|
|
166
|
+
* Pass the chart's pane count as nextPaneIndex. This function creates no chart or UI.
|
|
167
|
+
*/
|
|
168
|
+
declare function planIndicatorTemplate(current: IndicatorState[], incoming: IndicatorState[], mode: IndicatorTemplateMode, available: ReadonlySet<string>, nextPaneIndex: number): IndicatorState[];
|
|
169
|
+
|
|
170
|
+
export { type IndexedDbWorkspaceStorage, type IndicatorTemplateDocument, type IndicatorTemplateMode, WORKSPACE_VERSION, type WorkspaceCatalog, type WorkspaceChartState, type WorkspaceComparison, WorkspaceConflictError, type WorkspaceDocument, WorkspaceDocumentError, type WorkspaceKind, type WorkspaceOpenOptions, type WorkspaceOperationOptions, type WorkspacePane, type WorkspacePayload, WorkspaceRepository, type WorkspaceRepositoryOptions, type WorkspaceSettings, type WorkspaceSlot, type WorkspaceStorage, createIndexedDbWorkspaceStorage, migrateWidgetWorkspace, parseIndicatorStates, parseIndicatorTemplate, parseWorkspaceCatalog, parseWorkspaceDocument, parseWorkspacePayload, planIndicatorTemplate };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openalgo-charts",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.5",
|
|
4
4
|
"description": "From-scratch, dependency-free canvas charting engine for OpenAlgo: professional-grade interactive rendering, advanced on-chart trading, and a one-call widget tier that adds the toolbar, drawing rail, dialogs and shortcuts.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "marketcalls",
|
|
@@ -63,6 +63,10 @@
|
|
|
63
63
|
"types": "./dist/webgl/index.d.ts",
|
|
64
64
|
"import": "./dist/openalgo-charts.webgl.mjs"
|
|
65
65
|
},
|
|
66
|
+
"./workspace": {
|
|
67
|
+
"types": "./dist/workspace/index.d.ts",
|
|
68
|
+
"import": "./dist/openalgo-charts.workspace.mjs"
|
|
69
|
+
},
|
|
66
70
|
"./widget": {
|
|
67
71
|
"types": "./dist/widget/index.d.ts",
|
|
68
72
|
"import": "./dist/openalgo-charts.widget.mjs"
|
|
@@ -99,10 +103,12 @@
|
|
|
99
103
|
"size": "size-limit",
|
|
100
104
|
"bench": "node scripts/bench-indicators.mjs",
|
|
101
105
|
"soak": "node --expose-gc scripts/soak.mjs",
|
|
106
|
+
"endurance:browser": "node scripts/browser-endurance.mjs",
|
|
107
|
+
"test:endurance": "node --test scripts/browser-endurance.test.mjs",
|
|
102
108
|
"skills:coverage": "node scripts/check-skills-coverage.mjs",
|
|
103
109
|
"docs": "typedoc",
|
|
104
110
|
"test:demo": "vitest run --config examples/yfinance/vitest.config.ts",
|
|
105
|
-
"verify": "npm run lint && npm run typecheck && npm run test && npm run build && npm run test:demo && npm run check:dts && npm run size && npm run shake",
|
|
111
|
+
"verify": "npm run lint && npm run typecheck && npm run test && npm run test:endurance && npm run build && npm run test:demo && npm run check:dts && npm run size && npm run shake",
|
|
106
112
|
"prepublishOnly": "npm run verify",
|
|
107
113
|
"check:dts": "node scripts/check-dts.mjs",
|
|
108
114
|
"shake": "node scripts/check-shake.mjs"
|