openalgo-charts 2.7.2 → 2.7.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.
- package/README.md +27 -27
- package/dist/draw/index.d.ts +109 -8
- package/dist/index.d.ts +122 -10
- package/dist/indicators/index.d.ts +8 -1
- package/dist/openalgo-charts.draw.mjs +1 -1
- package/dist/openalgo-charts.draw.mjs.map +1 -1
- package/dist/openalgo-charts.draw.standalone.js +1 -1
- package/dist/openalgo-charts.indicators.mjs +1 -1
- package/dist/openalgo-charts.indicators.mjs.map +1 -1
- package/dist/openalgo-charts.indicators.standalone.js +1 -1
- package/dist/openalgo-charts.mjs +1 -1
- package/dist/openalgo-charts.mjs.map +1 -1
- package/dist/openalgo-charts.profile.mjs +1 -1
- package/dist/openalgo-charts.profile.mjs.map +1 -1
- package/dist/openalgo-charts.profile.standalone.js +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.trade.standalone.js +1 -1
- package/dist/openalgo-charts.transform.mjs +1 -1
- package/dist/openalgo-charts.transform.mjs.map +1 -1
- package/dist/openalgo-charts.transform.standalone.js +1 -1
- package/dist/{openalgo-charts.widget.chart-data-export-dialog-CX6h5-cp.mjs → openalgo-charts.widget.chart-data-export-dialog-we0VDywF.mjs} +2 -2
- package/dist/{openalgo-charts.widget.chart-data-export-dialog-CX6h5-cp.mjs.map → openalgo-charts.widget.chart-data-export-dialog-we0VDywF.mjs.map} +1 -1
- package/dist/{openalgo-charts.widget.chart-type-settings-Bu7g-LFB.mjs → openalgo-charts.widget.chart-type-settings-DYCCD4Ax.mjs} +2 -2
- package/dist/{openalgo-charts.widget.chart-type-settings-Bu7g-LFB.mjs.map → openalgo-charts.widget.chart-type-settings-DYCCD4Ax.mjs.map} +1 -1
- package/dist/openalgo-charts.widget.grid-bar-CWfujvFQ.mjs +2 -0
- package/dist/openalgo-charts.widget.grid-bar-CWfujvFQ.mjs.map +1 -0
- package/dist/{openalgo-charts.widget.grid-menus-CPZWEiD3.mjs → openalgo-charts.widget.grid-menus-Ujc8dpxO.mjs} +2 -2
- package/dist/{openalgo-charts.widget.grid-menus-CPZWEiD3.mjs.map → openalgo-charts.widget.grid-menus-Ujc8dpxO.mjs.map} +1 -1
- package/dist/{openalgo-charts.widget.layouts-templates-menu-CFf0bR9J.mjs → openalgo-charts.widget.layouts-templates-menu-DPPa9Cn1.mjs} +2 -2
- package/dist/{openalgo-charts.widget.layouts-templates-menu-CFf0bR9J.mjs.map → openalgo-charts.widget.layouts-templates-menu-DPPa9Cn1.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.widget.standalone.js +1 -1
- package/dist/openalgo-charts.widget.storage-idb-JzCQh1Se.mjs +2 -0
- package/dist/openalgo-charts.widget.storage-idb-JzCQh1Se.mjs.map +1 -0
- package/dist/openalgo-charts.workspace.mjs +1 -1
- package/dist/openalgo-charts.workspace.mjs.map +1 -1
- package/dist/openalgo-charts.workspace.standalone.js +1 -1
- package/dist/profile/index.d.ts +63 -59
- package/dist/trade/index.d.ts +69 -9
- package/dist/transform/index.d.ts +20 -4
- package/dist/widget/index.d.ts +112 -5
- package/dist/workspace/index.d.ts +22 -5
- package/package.json +1 -1
- package/dist/openalgo-charts.widget.grid-bar-Cm_CyA2j.mjs +0 -2
- package/dist/openalgo-charts.widget.grid-bar-Cm_CyA2j.mjs.map +0 -1
- package/dist/openalgo-charts.widget.storage-idb-WH_o01Wj.mjs +0 -2
- package/dist/openalgo-charts.widget.storage-idb-WH_o01Wj.mjs.map +0 -1
package/dist/widget/index.d.ts
CHANGED
|
@@ -19,6 +19,14 @@ interface StorageLike {
|
|
|
19
19
|
interface AsyncStorageLike {
|
|
20
20
|
/** Every stored key that starts with `prefix`, with its value. */
|
|
21
21
|
entries(prefix: string): Promise<ReadonlyArray<readonly [key: string, value: string]>>;
|
|
22
|
+
/**
|
|
23
|
+
* What the store holds under one key now, or null. Optional: without it
|
|
24
|
+
* the widget reads that key through `entries`. The widget reads a key
|
|
25
|
+
* again just before it writes a value another tab may be changing too
|
|
26
|
+
* (each instrument's drawings), to merge its change into what is there.
|
|
27
|
+
* Since 2.7.3.
|
|
28
|
+
*/
|
|
29
|
+
getItem?(key: string): Promise<string | null>;
|
|
22
30
|
setItem(key: string, value: string): Promise<void>;
|
|
23
31
|
removeItem(key: string): Promise<void>;
|
|
24
32
|
/**
|
|
@@ -69,7 +77,9 @@ declare const STORAGE_PREFIX = "oac-widget:";
|
|
|
69
77
|
* made before `load` settles waits for it and wins over the stored value,
|
|
70
78
|
* because it is the newer of the two. A store that can say so (`subscribe`)
|
|
71
79
|
* keeps the copy current with the writes other tabs land, as a synchronous
|
|
72
|
-
* store's reads always were, until `close`.
|
|
80
|
+
* store's reads always were, until `close`. A name its owner merges
|
|
81
|
+
* (`mergeOnCommit`) is merged into what the store holds as it is written,
|
|
82
|
+
* rather than written over it.
|
|
73
83
|
*/
|
|
74
84
|
declare class WidgetStorage {
|
|
75
85
|
private readonly _store;
|
|
@@ -85,6 +95,23 @@ declare class WidgetStorage {
|
|
|
85
95
|
private readonly _sending;
|
|
86
96
|
/** Changes the store refused, sent again with the next change or flush. */
|
|
87
97
|
private readonly _refused;
|
|
98
|
+
/**
|
|
99
|
+
* For each key with a change that has not landed, what the store held
|
|
100
|
+
* before it as far as this copy knows (null for nothing): the base a merge
|
|
101
|
+
* tells this copy's change from another writer's by, and what the journal
|
|
102
|
+
* records, so the next page can tell whether the store moved on since.
|
|
103
|
+
* Over a synchronous store, for a merged name, what this copy last read or
|
|
104
|
+
* wrote.
|
|
105
|
+
*/
|
|
106
|
+
private readonly _base;
|
|
107
|
+
/**
|
|
108
|
+
* For a merged key with a change of this copy's out, what another writer
|
|
109
|
+
* landed meanwhile, which reads do not answer with: a change written at
|
|
110
|
+
* once as the page goes away is merged into it.
|
|
111
|
+
*/
|
|
112
|
+
private readonly _theirs;
|
|
113
|
+
/** How many times each key was written at once since (`_leave`): a merged write waiting for its lock then writes nothing. */
|
|
114
|
+
private readonly _overtaken;
|
|
88
115
|
private _loading;
|
|
89
116
|
private _loaded;
|
|
90
117
|
private _memoryOnly;
|
|
@@ -95,12 +122,20 @@ declare class WidgetStorage {
|
|
|
95
122
|
private readonly _heard;
|
|
96
123
|
private _unsubscribe;
|
|
97
124
|
private _closed;
|
|
125
|
+
private readonly _listeners;
|
|
126
|
+
/** Stops hearing the page's storage events, over a synchronous store someone subscribed to. */
|
|
127
|
+
private _offPage;
|
|
98
128
|
constructor(namespace: string, store: StorageLike | AsyncStorageLike | null, options?: WidgetStorageOptions);
|
|
99
129
|
key(name: string): string;
|
|
100
130
|
get(name: string): unknown;
|
|
101
131
|
/** True when the write landed; over an asynchronous store, when it was taken to be sent. */
|
|
102
132
|
set(name: string, value: unknown): boolean;
|
|
103
|
-
|
|
133
|
+
/**
|
|
134
|
+
* True when the removal landed; over an asynchronous store, when it was
|
|
135
|
+
* taken to be sent. A refused removal reads as false, as a refused write
|
|
136
|
+
* does, so the caller can keep what it deleted rather than see it return.
|
|
137
|
+
*/
|
|
138
|
+
remove(name: string): boolean;
|
|
104
139
|
/** Whether writes can land at all. */
|
|
105
140
|
get enabled(): boolean;
|
|
106
141
|
/** Whether reads answer from what is stored: always over a synchronous store, once `load` has settled over an asynchronous one. */
|
|
@@ -118,12 +153,32 @@ declare class WidgetStorage {
|
|
|
118
153
|
* destroyed; a copy nobody reads again need not follow the store.
|
|
119
154
|
*/
|
|
120
155
|
close(): void;
|
|
156
|
+
/**
|
|
157
|
+
* Hear each change another user of the store makes to a key of this
|
|
158
|
+
* namespace, by the key's name, once reads answer with it, for a caller
|
|
159
|
+
* that keeps a state of its own read from the store: what the copy of an
|
|
160
|
+
* asynchronous store follows (`AsyncStorageLike.subscribe`), or the storage
|
|
161
|
+
* event the page fires when its own `localStorage` is the store. A key this
|
|
162
|
+
* copy has changed and not seen land is not heard, since its own value goes
|
|
163
|
+
* out after. Returns the call that stops listening; `close` stops every
|
|
164
|
+
* listener. Since 2.7.3.
|
|
165
|
+
*/
|
|
166
|
+
subscribe(listener: (name: string) => void): () => void;
|
|
121
167
|
/**
|
|
122
168
|
* Send every change made so far now, and settle once each has landed or
|
|
123
|
-
* failed. Before the sends it copies them to the store's journal, which
|
|
124
|
-
*
|
|
169
|
+
* failed. Before the sends it copies them to the store's journal, which
|
|
170
|
+
* keeps them for the next page when this one goes before they land. Never
|
|
171
|
+
* rejects. A merged name (`mergeOnCommit`) waits for its key's lock and a
|
|
172
|
+
* fresh read; the widget's own leaving sends everything at once instead.
|
|
125
173
|
*/
|
|
126
174
|
flush(): Promise<void>;
|
|
175
|
+
/**
|
|
176
|
+
* `text` into a synchronous store: for a merged name another writer
|
|
177
|
+
* changed since this copy last read or wrote it, merged into what it holds,
|
|
178
|
+
* and then told as another writer's change is, so a caller that keeps a
|
|
179
|
+
* state of its own takes the other writer's part.
|
|
180
|
+
*/
|
|
181
|
+
private _write;
|
|
127
182
|
private _queue;
|
|
128
183
|
private _requeue;
|
|
129
184
|
private _read;
|
|
@@ -133,13 +188,65 @@ declare class WidgetStorage {
|
|
|
133
188
|
* journal goes once everything it held has landed.
|
|
134
189
|
*/
|
|
135
190
|
private _send;
|
|
191
|
+
/**
|
|
192
|
+
* Send one change, settling with the text written. A name another writer
|
|
193
|
+
* may change too (`mergeOnCommit`) is read again and this copy's change
|
|
194
|
+
* merged into what the store holds, holding the key's lock from the read
|
|
195
|
+
* to the write, so a second writer reads what the first wrote: two changes
|
|
196
|
+
* made before either landed both stay. Once the write has landed it is no
|
|
197
|
+
* longer out: another writer's heard from then on is the newer (`_hear`).
|
|
198
|
+
*/
|
|
199
|
+
private _commit;
|
|
200
|
+
/** `text` of `key` has landed: no longer out, unless a newer change of it is (`_hear`). */
|
|
201
|
+
private _out;
|
|
202
|
+
/** The changes `batch` sent, settled: landed, or refused and kept to send again. */
|
|
203
|
+
private _settled;
|
|
204
|
+
/**
|
|
205
|
+
* Everything not landed, journaled, then written in this call (`flushLeaving`):
|
|
206
|
+
* a merged name into what another writer was heard to land meanwhile
|
|
207
|
+
* (`_theirs`), since there is no time to read the store again. A merged
|
|
208
|
+
* write still waiting for its lock then writes nothing, so an older value
|
|
209
|
+
* never lands over this one. Before the namespace is read nothing is sent,
|
|
210
|
+
* and the journal keeps it.
|
|
211
|
+
*/
|
|
212
|
+
private _leave;
|
|
213
|
+
/**
|
|
214
|
+
* A change landed as `written`. With nothing newer to send, the key's base
|
|
215
|
+
* goes, and a merge that brought another writer's changes in is what reads
|
|
216
|
+
* answer from now, and is told as theirs is, unless a newer write another
|
|
217
|
+
* writer landed since has taken its place already.
|
|
218
|
+
*/
|
|
219
|
+
private _landed;
|
|
220
|
+
private _mergeFor;
|
|
221
|
+
/**
|
|
222
|
+
* A journaled change the store moved past since the journal was written:
|
|
223
|
+
* the store already holds it, or another writer's newer value, which
|
|
224
|
+
* stays, or for a merged name both, merged. Undefined for nothing to replay.
|
|
225
|
+
*/
|
|
226
|
+
private _replayOver;
|
|
136
227
|
/**
|
|
137
228
|
* A change another user of the store made, once it landed. A key this copy
|
|
138
229
|
* has changed and not seen land keeps its own value: that write goes out
|
|
139
|
-
* after, so it is the one the store keeps
|
|
230
|
+
* after, so it is the one the store keeps, or for a merged name the one
|
|
231
|
+
* merged into it.
|
|
140
232
|
*/
|
|
141
233
|
private _hear;
|
|
234
|
+
private _tell;
|
|
235
|
+
/**
|
|
236
|
+
* Each change with what the store may hold without another writer having
|
|
237
|
+
* moved it on (`was`), where this copy knows: what it held before, and each
|
|
238
|
+
* value of this copy's that is out. A journal whose writes landed, and that
|
|
239
|
+
* could be neither removed nor emptied after, is then not replayed over the
|
|
240
|
+
* newer values another writer stored since (`_replayOver`).
|
|
241
|
+
*/
|
|
142
242
|
private _writeJournal;
|
|
243
|
+
/**
|
|
244
|
+
* Everything the journal held has landed. One that cannot be removed is
|
|
245
|
+
* emptied instead: left whole, the next page would replay its values over
|
|
246
|
+
* every newer write that landed since. One that can be neither is tried
|
|
247
|
+
* again when the next send settles.
|
|
248
|
+
*/
|
|
249
|
+
private _dropJournal;
|
|
143
250
|
private _report;
|
|
144
251
|
}
|
|
145
252
|
/** The page's `localStorage` when it exists and works, else null. */
|
|
@@ -108,6 +108,18 @@ interface DocumentMetadata {
|
|
|
108
108
|
interface WorkspaceDocument extends DocumentMetadata, WorkspacePayload {
|
|
109
109
|
kind: 'workspace';
|
|
110
110
|
}
|
|
111
|
+
/** How `parseWorkspaceDocument` and `parseWorkspacePayload` read a document. */
|
|
112
|
+
interface WorkspaceParseOptions {
|
|
113
|
+
/**
|
|
114
|
+
* False drops each drawing's and each study's `policy`. A policy is how a
|
|
115
|
+
* host keeps its own objects from the user (read-only, unselectable,
|
|
116
|
+
* unlisted), so a document from a file, a link or another account, which
|
|
117
|
+
* is anyone's, should arrive without one: pass false for it, as
|
|
118
|
+
* `importDocument` does. The default keeps them, because hosts read their
|
|
119
|
+
* own saved state through these parsers too. Since 2.7.3.
|
|
120
|
+
*/
|
|
121
|
+
keepPolicy?: boolean;
|
|
122
|
+
}
|
|
111
123
|
interface IndicatorTemplatePlotBinding {
|
|
112
124
|
instanceId: string;
|
|
113
125
|
plotKey: string;
|
|
@@ -139,11 +151,11 @@ declare function parseIndicatorStates(input: unknown): IndicatorState[];
|
|
|
139
151
|
|
|
140
152
|
/** Validate and detach portable study settings and optional pane/scale relationships. */
|
|
141
153
|
declare function parseIndicatorTemplatePayload(input: unknown): IndicatorTemplatePayload;
|
|
142
|
-
/** Validate, detach and project a portable chart-only workspace. */
|
|
143
|
-
declare function parseWorkspaceDocument(input: unknown): WorkspaceDocument;
|
|
144
|
-
declare function parseWorkspacePayload(input: unknown): WorkspacePayload;
|
|
154
|
+
/** Validate, detach and project a portable chart-only workspace. Policies are kept unless `options.keepPolicy` is false. */
|
|
155
|
+
declare function parseWorkspaceDocument(input: unknown, options?: WorkspaceParseOptions): WorkspaceDocument;
|
|
156
|
+
declare function parseWorkspacePayload(input: unknown, options?: WorkspaceParseOptions): WorkspacePayload;
|
|
145
157
|
declare function parseIndicatorTemplate(input: unknown): IndicatorTemplateDocument;
|
|
146
|
-
/** Explicit migration of the existing single-widget state; no input is modified. */
|
|
158
|
+
/** Explicit migration of the existing single-widget state, the host's own, so policies are kept; no input is modified. */
|
|
147
159
|
declare function migrateWidgetWorkspace(input: unknown, meta: {
|
|
148
160
|
id: string;
|
|
149
161
|
name: string;
|
|
@@ -304,6 +316,11 @@ declare class WorkspaceRepository implements WorkspaceStore {
|
|
|
304
316
|
remove(kind: WorkspaceKind, id: string, options?: WorkspaceOperationOptions): Promise<void>;
|
|
305
317
|
openWorkspace(id: string, options?: WorkspaceOpenOptions): Promise<WorkspaceDocument>;
|
|
306
318
|
setAutosave(enabled: boolean, options?: WorkspaceOperationOptions): Promise<void>;
|
|
319
|
+
/**
|
|
320
|
+
* Store a document from outside the catalog: a file, a link, another
|
|
321
|
+
* account. Each drawing's and study's policy is dropped (since 2.7.3), so
|
|
322
|
+
* what it places is the user's own to select, change or delete.
|
|
323
|
+
*/
|
|
307
324
|
importDocument(input: unknown, options?: WorkspaceOperationOptions): Promise<WorkspaceDocument | IndicatorTemplateDocument>;
|
|
308
325
|
/** `captureIndicatorTemplate`, as the store member a widget reaches it through. */
|
|
309
326
|
captureIndicatorTemplate(chart: Chart): IndicatorTemplatePayload;
|
|
@@ -563,4 +580,4 @@ type IndexedDbDrawingTemplateStorage = IndexedDbCatalogStorage<DrawingTemplateCa
|
|
|
563
580
|
*/
|
|
564
581
|
declare function createIndexedDbDrawingTemplateStorage(factory: IDBFactory, databaseName?: string): IndexedDbDrawingTemplateStorage;
|
|
565
582
|
|
|
566
|
-
export { type DrawingTemplate, type DrawingTemplateCatalog, DrawingTemplateConflictError, type DrawingTemplateLevel, type DrawingTemplateOperationOptions, DrawingTemplateRepository, type DrawingTemplateRepositoryOptions, type DrawingTemplateStorage, type DrawingTemplateStore, type DrawingTemplateValue, type DrawingTemplateValues, type DrawingToolDefault, type IndexedDbCatalogStorage, type IndexedDbDrawingTemplateStorage, type IndexedDbWatchlistStorage, type IndexedDbWorkspaceStorage, type IndicatorTemplateApplyOptions, type IndicatorTemplateDocument, type IndicatorTemplateInput, type IndicatorTemplateLayout, type IndicatorTemplateMode, type IndicatorTemplatePayload, type IndicatorTemplatePlan, type IndicatorTemplatePlotBinding, WORKSPACE_VERSION, type Watchlist, type WatchlistCatalog, WatchlistConflictError, type WatchlistEntry, type WatchlistOperationOptions, WatchlistRepository, type WatchlistRepositoryOptions, type WatchlistStorage, type WatchlistStore, type WorkspaceCatalog, type WorkspaceChartState, type WorkspaceComparison, WorkspaceConflictError, type WorkspaceDocument, WorkspaceDocumentError, type WorkspaceKind, type WorkspaceLinkChannels, type WorkspaceLinkGroup, type WorkspaceOpenOptions, type WorkspaceOperationOptions, type WorkspacePane, type WorkspacePayload, WorkspaceRepository, type WorkspaceRepositoryOptions, type WorkspaceSettings, type WorkspaceSlot, type WorkspaceStorage, type WorkspaceStore, type WorkspaceSync, captureIndicatorTemplate, createIndexedDbDrawingTemplateStorage, createIndexedDbWatchlistStorage, createIndexedDbWorkspaceStorage, createMemoryDrawingTemplateStorage, createMemoryWatchlistStorage, createMemoryWorkspaceStorage, migrateWidgetWorkspace, parseDrawingTemplateCatalog, parseDrawingTemplateValues, parseIndicatorStates, parseIndicatorTemplate, parseIndicatorTemplatePayload, parseWatchlistCatalog, parseWorkspaceCatalog, parseWorkspaceDocument, parseWorkspacePayload, planIndicatorTemplate, planIndicatorTemplateState, watchlistKey };
|
|
583
|
+
export { type DrawingTemplate, type DrawingTemplateCatalog, DrawingTemplateConflictError, type DrawingTemplateLevel, type DrawingTemplateOperationOptions, DrawingTemplateRepository, type DrawingTemplateRepositoryOptions, type DrawingTemplateStorage, type DrawingTemplateStore, type DrawingTemplateValue, type DrawingTemplateValues, type DrawingToolDefault, type IndexedDbCatalogStorage, type IndexedDbDrawingTemplateStorage, type IndexedDbWatchlistStorage, type IndexedDbWorkspaceStorage, type IndicatorTemplateApplyOptions, type IndicatorTemplateDocument, type IndicatorTemplateInput, type IndicatorTemplateLayout, type IndicatorTemplateMode, type IndicatorTemplatePayload, type IndicatorTemplatePlan, type IndicatorTemplatePlotBinding, WORKSPACE_VERSION, type Watchlist, type WatchlistCatalog, WatchlistConflictError, type WatchlistEntry, type WatchlistOperationOptions, WatchlistRepository, type WatchlistRepositoryOptions, type WatchlistStorage, type WatchlistStore, type WorkspaceCatalog, type WorkspaceChartState, type WorkspaceComparison, WorkspaceConflictError, type WorkspaceDocument, WorkspaceDocumentError, type WorkspaceKind, type WorkspaceLinkChannels, type WorkspaceLinkGroup, type WorkspaceOpenOptions, type WorkspaceOperationOptions, type WorkspacePane, type WorkspaceParseOptions, type WorkspacePayload, WorkspaceRepository, type WorkspaceRepositoryOptions, type WorkspaceSettings, type WorkspaceSlot, type WorkspaceStorage, type WorkspaceStore, type WorkspaceSync, captureIndicatorTemplate, createIndexedDbDrawingTemplateStorage, createIndexedDbWatchlistStorage, createIndexedDbWorkspaceStorage, createMemoryDrawingTemplateStorage, createMemoryWatchlistStorage, createMemoryWorkspaceStorage, migrateWidgetWorkspace, parseDrawingTemplateCatalog, parseDrawingTemplateValues, parseIndicatorStates, parseIndicatorTemplate, parseIndicatorTemplatePayload, parseWatchlistCatalog, parseWorkspaceCatalog, parseWorkspaceDocument, parseWorkspacePayload, planIndicatorTemplate, planIndicatorTemplateState, watchlistKey };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openalgo-charts",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.3",
|
|
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",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{layoutIconPath as t,chromeIconSvg as e}from"./openalgo-charts.draw.mjs";import{createLayoutsController as a,s as n,e as o,b as r,d as s,f as i,widgetText as c,widgetLayoutTarget as l,h as d,CHART_GRID_LAYOUTS as u,j as p,a as h,i as m,l as g,k as b,r as f,g as y}from"./openalgo-charts.widget.mjs";import{isReplaying as x}from"./openalgo-charts.mjs";function k(t){const{grid:e}=t,d=!1===t.layouts?null:t.layouts??null;if(!1===t.layouts||null===d&&void 0===t.workspaces)return null;const u=(e,a,n={})=>c(t.context(),`schema.ui.layouts.${e}`,n,a),p=a=>{e.isDestroyed||t.context().status(a,"error")};let h=null,m=[];const g=()=>{for(const t of m.splice(0))t();const t=h;null!==t&&(m=e.cells().map(e=>l(e.widget).subscribe(t)))},b={capture(){const t=e.getWorkspace();return{...t,activePaneId:t.panes[0].id,panes:t.panes.map(t=>({...t,chart:i(t.chart)}))}},apply:t=>e.applyWorkspace(t),subscribe(t){h=t,g();const a=[e.on("layout",({reason:e})=>{"preset"!==e&&"workspace"!==e||g(),t()}),e.on("links",t)];return()=>{h=null,g();for(const t of a)t()}},suspended:()=>e.cells().some(t=>x(t.widget.chart))},f=null===d?a(t.workspaces,b):null,y=d??f,k={handle:null,waiting:null};let _=!1;return null!==f&&(n(f,u,p),t.ready.then(()=>_?null:f.reload()).then(async e=>{if(_||null==e||null===e.activeWorkspaceId||t.opened())return;const a=await f.open(e.activeWorkspaceId);a.applied||_||p(u("notReopened","The last layout could not open here: {error}",{error:a.reason??""}))}).catch(e=>{_||p(u("notLoaded","Saved layouts could not be read: {error}",{error:o(t.context(),e)}))})),{controller:y,open(a){_||s(t.context(),y,a,k,()=>!_&&!e.isDestroyed)},status:()=>r(t.context(),y.state()),flush(){_||f?.flush()},destroy(){_||(_=!0,f?.destroy())}}}function _(e){const a=u[e];return p(t(a.rows,a.columns,a.slots))}const v=(t,e)=>{const a=d(t,"span","oac-glyph oac-glyph--chrome",{"aria-hidden":"true"});return a.innerHTML=e,a};function w(t,a){const n=t.doc,o=(t=>t.text)(t);h(n,L);const r=(t,e)=>d(n,"button",`oac-btn ${t}`,{type:"button","aria-label":e}),s=()=>{const t=d(n,"span","oac-chev",{"aria-hidden":"true"});return t.innerHTML=e("chevron-down"),t},i=r("oac-grid__layout",c(o,"Arrange charts"));i.setAttribute("aria-haspopup","menu");const l=v(n,e("layout")),u=d(n,"span","oac-grid__bar-text");i.append(l,u,s()),t.tips.attach(i,()=>{const e=t.layout();return{title:m(e)?c(o,"Arrange charts: {name}",{name:g(o,e)}):c(o,"Arrange charts"),side:"bottom"}}),i.addEventListener("click",()=>t.openMenu("layouts",i)),i.hidden=0===t.layouts.length;const p=r("oac-btn--icon oac-grid__max",c(o,"Maximize the chart")),x=v(n,e("maximize"));p.appendChild(x);t.tips.attach(p,()=>({title:c(o,t.maximized()?"Restore the grid":"Maximize the chart"),sub:t.maximizeBlocked()??void 0,side:"bottom"})),p.addEventListener("click",()=>{null===t.maximizeBlocked()&&t.toggleMaximize()});const k=r("oac-grid__link",c(o,"Link"));k.setAttribute("aria-haspopup","menu");const w=d(n,"span","oac-grid__bar-text");w.textContent=c(o,"Link");const A=d(n,"span","oac-grid__bar-mark");k.append(v(n,e("link")),w,A,s()),t.tips.attach(k,()=>{const e=t.links.current();return{title:c(o,"Link: {name}",{name:null===e?c(o,"Not linked"):e.name}),side:"bottom"}}),k.addEventListener("click",()=>t.openMenu("link",k));const z=r("oac-btn--icon oac-grid__capture",c(o,"Capture every chart"));z.setAttribute("aria-haspopup","menu"),z.appendChild(v(n,e("capture-grid"))),t.tips.attach(z,()=>({title:c(o,"Capture every chart"),sub:t.capture.blocked()??void 0,side:"bottom"})),z.addEventListener("click",()=>t.openMenu("capture",z));const M=()=>d(n,"span","oac-sep",{role:"separator"});a.append(i,p,M(),k,M(),z);let C=null,E=null;if(void 0!==t.saved){const{controller:s}=t.saved,i=c(o,"schema.ui.layouts.title",{},"Layouts"),l=()=>{const t=s.state();return t.catalog?.workspaces.find(e=>e.id===t.layoutId)?.name??null},u=C=r("oac-grid__saved",i);u.setAttribute("aria-haspopup","dialog");const p=d(n,"span","oac-grid__bar-text");u.append(v(n,e("folder")),p),t.tips.attach(u,()=>{const e=l(),a=null===e?i:`${i}: ${e}`,n=t.saved?.status();return{title:a,label:b(s.state())?`${a}, ${n??""}`:void 0,sub:n,side:"bottom"}});const h=()=>{p.textContent=l()??i,u.dataset.attention=String(b(s.state())),t.tips.refreshLabel(u)};E=s.subscribe(h),h(),u.addEventListener("click",()=>t.saved?.open(u)),a.append(d(n,"span","oac-grid__spacer"),u)}const $=[i,p,k,z,C].filter(t=>null!==t&&!t.hidden);a.addEventListener("keydown",t=>{const e=$.indexOf(n.activeElement),a=f(t.key,e,$.length,["ArrowLeft","ArrowRight"]);a<0||(t.preventDefault(),t.stopPropagation(),$[a].focus())});const T=()=>{const a=t.layout(),r=m(a);l.innerHTML=r?_(a):e("layout"),u.textContent=r?g(o,a):"",u.hidden=!r;const s=t.maximized();x.innerHTML=e(s?"restore":"maximize");const c=t.maximizeBlocked();p.classList.toggle("is-off",null!==c),p.setAttribute("aria-disabled",String(null!==c));const d=t.links.current();A.replaceChildren(y(n,d)),z.classList.toggle("is-off",null!==t.capture.blocked());for(const e of[i,p,k,z])t.tips.refreshLabel(e);const h=t.tips.target();h!==i&&h!==p&&h!==k&&h!==z||t.tips.show(h)};return T(),{el:a,refresh:T,destroy:()=>{E?.(),a.textContent=""}}}const L="\n.oac-grid__bar .oac-grid__bar-text { max-width: 22ch; overflow: hidden; text-overflow: ellipsis; }\n.oac-grid__bar-mark { display: inline-flex; }\n.oac-grid__spacer { flex: 1 1 auto; }\n.oac-grid__saved { min-width: 0; }\n.oac-grid__saved[data-attention=\"true\"]::after { content: ''; width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--oac-amber); }\n/* A phone's bar keeps the glyph and the mark; the held layout's name stays in the tip and the accessible name. */\n@container oac-grid-bar (max-width: 520px) { .oac-grid__saved > .oac-grid__bar-text { display: none; } }\n";export{k as attachGridSaved,v as chrome,_ as layoutTileSvg,w as mountGridBar};
|
|
2
|
-
//# sourceMappingURL=openalgo-charts.widget.grid-bar-Cm_CyA2j.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openalgo-charts.widget.grid-bar-Cm_CyA2j.mjs","sources":["../src/widget/grid-saved.ts","../src/widget/grid-bar.ts"],"sourcesContent":[null,null],"names":["attachGridSaved","host","grid","given","layouts","undefined","workspaces","text","key","fallback","values","widgetText","context","report","message","isDestroyed","status","heard","chartOffs","wire","off","splice","listener","cells","map","cell","widgetLayoutTarget","widget","subscribe","target","capture","payload","getWorkspace","activePaneId","panes","id","pane","chart","layoutChartState","apply","applyWorkspace","offs","on","reason","suspended","some","isReplaying","own","createLayoutsController","controller","menu","handle","waiting","destroyed","sayLayoutFailures","ready","then","reload","async","catalog","activeWorkspaceId","opened","open","applied","error","catch","errorText","anchor","showLayoutsMenu","layoutStatusText","state","flush","destroy","layoutTileSvg","spec","CHART_GRID_LAYOUTS","glyphSvg","layoutIconPath","rows","columns","slots","chrome","doc","svg","span","h","innerHTML","mountGridBar","el","t","txt","addWidgetStyles","GRID_BAR_CSS","button","className","label","type","chev","s","chromeIconSvg","layout","setAttribute","layoutGlyph","layoutText","append","tips","attach","title","isChartGridLayout","name","layoutName","side","addEventListener","openMenu","hidden","length","max","maxGlyph","appendChild","maximized","sub","maximizeBlocked","toggleMaximize","link","linkText","textContent","linkMark","group","links","current","blocked","sep","role","saved","offSaved","held","find","layoutId","b","at","said","layoutNeedsAttention","paint","dataset","attention","String","refreshLabel","controls","filter","control","e","indexOf","activeElement","to","rovingIndex","preventDefault","stopPropagation","focus","refresh","known","maxed","classList","toggle","replaceChildren","groupMark","up","show"],"mappings":"qWA6DM,SAAUA,EAAgBC,GAC9B,MAAMC,KAAEA,GAASD,EACXE,GAA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C,GAC/Bd,EAAIf,aAAa,gBAAiB4C,OAAmB,OAAZf,IACzC,MAAMH,EAAQ9H,EAAK+H,MAAMC,UACzBH,EAASqC,gBAAgBC,EAAUlF,EAAK6C,IACxCjG,EAAQmI,UAAUC,OAAO,SAAqC,OAA3BjK,EAAK6B,QAAQoG,WAChD,IAAK,MAAMmB,IAAW,CAACjD,EAAQgB,EAAKO,EAAM7F,GAAU7B,EAAKwG,KAAKyC,aAAaG,GAG3E,MAAMgB,EAAKpK,EAAKwG,KAAK5E,SACjBwI,IAAOjE,GAAUiE,IAAOjD,GAAOiD,IAAO1C,GAAQ0C,IAAOvI,GAAS7B,EAAKwG,KAAK6D,KAAKD,IAGnF,OADAP,IACO,CACLtE,KACAsE,UACAtF,QAAS,KAAQ8D,MAAc9C,EAAGqC,YAAc,IAEpD,CAGA,MAAMjC,EAAe"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./openalgo-charts.draw.mjs";import{defaultStorage as e,D as t,STORAGE_PREFIX as n}from"./openalgo-charts.widget.mjs";import"./openalgo-charts.mjs";const r="entries",o="copied:",s="oac-widget-store:";function l(t,n,l){const i=void 0===l.journal?e():l.journal,g=void 0===l.migrateFrom?a():l.migrateFrom;let d=null,h=!1;const m=new Set;let p=null;const f=(e,t)=>{for(const n of[...m])try{n(e,t)}catch{}},y=(e,t)=>{f(e,t);const r=u();if(null!==r)try{if(null!==p)return void p.postMessage({key:e,value:t});const o=new r(s+n);o.postMessage({key:e,value:t}),o.close()}catch{}},w=()=>{null!==p&&(p.onmessage=null,p.close(),p=null)},v=async(e,o)=>{const s=await(()=>{if(h)return Promise.reject(new Error("The widget storage is closed"));if(null!==d)return d;const e=new Promise((o,s)=>{const l=t.open(n,1);l.onupgradeneeded=()=>{l.result.objectStoreNames.contains(r)||l.result.createObjectStore(r)},l.onblocked=()=>s(new Error("The widget storage is held open by another tab")),l.onerror=()=>s(l.error??new Error("The widget storage could not be opened")),l.onsuccess=()=>{const t=l.result;if(h)return t.close(),void s(new Error("The widget storage is closed"));t.onversionchange=()=>{t.close(),d===e&&(d=null)},t.onclose=()=>{d===e&&(d=null)},o(t)}}).catch(t=>{throw d===e&&(d=null),t});return d=e,e})();return new Promise((t,n)=>{const l=s.transaction(r,e);let u;l.oncomplete=()=>t(u),l.onabort=()=>n(l.error??new Error("The widget storage transaction was aborted")),o(l.objectStore(r),e=>{u=e})})};return{journal:i,entries:e=>v("readwrite",(t,n)=>{const r=[];n(r);const s=function(e){const t=globalThis.IDBKeyRange;try{return void 0===t?null:t.bound(e,e+"")}catch{return null}}(e),l=null===s?t.openCursor():t.openCursor(s);l.onsuccess=()=>{const n=l.result;if(null!==n)return"string"==typeof n.key&&n.key.startsWith(e)&&"string"==typeof n.value&&r.push([n.key,n.value]),void n.continue();if(r.length>0||null===g)return;const s=t.get(o+e);s.onsuccess=()=>{if(void 0!==s.result)return;const n=c(g,e);if(0!==n.length){for(const[e,o]of n)t.put(o,e),r.push([e,o]);t.put((new Date).toISOString(),o+e)}}}}),setItem:(e,t)=>v("readwrite",n=>{n.put(t,e)}).then(()=>y(e,t)),removeItem:e=>v("readwrite",t=>{t.delete(e)}).then(()=>y(e,null)),subscribe:e=>(m.add(e),(()=>{const e=u();if(null===p&&null!==e&&!h)try{p=new e(s+n),p.onmessage=e=>{const t=e.data;"string"!=typeof t?.key||"string"!=typeof t.value&&null!==t.value||f(t.key,t.value)}}catch{p=null}})(),()=>{m.delete(e),0===m.size&&w()}),close:()=>{h=!0,m.clear(),w();const e=d;d=null,e?.then(e=>e.close(),()=>{})}}}function u(){const e=globalThis.BroadcastChannel;return"function"==typeof e?e:null}function c(e,t){const n=[];try{for(let r=0;r<e.length;r++){const o=e.key(r);if(null===o||!o.startsWith(t))continue;const s=e.getItem(o);null!==s&&n.push([o,s])}}catch{return[]}return n}function a(){const t=e();return null!==t&&"function"==typeof t.key&&"number"==typeof t.length?t:null}function i(e){return function(e){const t=a();if(null===t)return e;let r=null;const o=e=>{try{return e(),Promise.resolve()}catch(e){return Promise.reject(e)}};return{journal:e.journal,subscribe:o=>{const s=e.subscribe((e,t)=>{"page"!==r&&o(e,t)}),l=globalThis,u=e=>{"page"===r&&e.storageArea===t&&!0===e.key?.startsWith(n)&&o(e.key,e.newValue)};try{l.addEventListener?.("storage",u)}catch{}return()=>{s();try{l.removeEventListener?.("storage",u)}catch{}}},entries:n=>"page"===r?Promise.resolve(c(t,n)):e.entries(n).then(e=>(r="idb",e),e=>{if("idb"===r)throw e;return r="page",c(t,n)}),setItem:(n,s)=>"page"===r?o(()=>t.setItem(n,s)):e.setItem(n,s),removeItem:n=>"page"===r?o(()=>t.removeItem(n)):e.removeItem(n)}}(l(e,t,{}))}export{l as openIndexedDbStore,i as openPageDefault};
|
|
2
|
-
//# sourceMappingURL=openalgo-charts.widget.storage-idb-WH_o01Wj.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openalgo-charts.widget.storage-idb-WH_o01Wj.mjs","sources":["../src/widget/storage-idb.ts"],"sourcesContent":[null],"names":["STORE","COPIED","CHANNEL","openIndexedDbStore","factory","name","options","journal","undefined","defaultStorage","legacy","migrateFrom","pageStorage","opening","closed","listeners","Set","channel","tell","key","value","listener","announce","Channel","broadcastChannel","postMessage","once","close","stopListening","onmessage","run","async","mode","body","db","Promise","reject","Error","attempt","resolve","request","open","onupgradeneeded","result","objectStoreNames","contains","createObjectStore","onblocked","onerror","error","onsuccess","onversionchange","onclose","catch","tx","transaction","oncomplete","onabort","objectStore","entries","prefix","store","done","rows","range","Range","globalThis","IDBKeyRange","bound","keyRange","cursor","openCursor","at","startsWith","push","continue","length","marker","get","copied","legacyEntries","put","Date","toISOString","setItem","then","removeItem","delete","subscribe","add","event","data","listen","size","clear","pending","BroadcastChannel","storage","out","i","getItem","openPageDefault","idb","page","use","onPage","write","off","win","changed","storageArea","STORAGE_PREFIX","newValue","addEventListener","removeEventListener","orPageStorage","DATABASE"],"mappings":"0JAwCA,MAAMA,EAAQ,UA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