@trdrs/quickcharts 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +18 -0
  4. package/README.md +2325 -0
  5. package/THIRD-PARTY-NOTICES.md +263 -0
  6. package/dist/adapters/rest.d.ts +143 -0
  7. package/dist/adapters/rest.js +214 -0
  8. package/dist/adapters/rest.js.map +1 -0
  9. package/dist/ar-G7MVXRE4.js +1028 -0
  10. package/dist/ar-G7MVXRE4.js.map +1 -0
  11. package/dist/assets-C1GQvm0w.d.ts +1452 -0
  12. package/dist/ca_ES-EUSRU4VG.js +1028 -0
  13. package/dist/ca_ES-EUSRU4VG.js.map +1 -0
  14. package/dist/chunk-AKXIFHQN.js +172 -0
  15. package/dist/chunk-AKXIFHQN.js.map +1 -0
  16. package/dist/chunk-KFBQSPNA.js +107 -0
  17. package/dist/chunk-KFBQSPNA.js.map +1 -0
  18. package/dist/chunk-PD3DEWMQ.js +6959 -0
  19. package/dist/chunk-PD3DEWMQ.js.map +1 -0
  20. package/dist/de-2SVTG25S.js +1028 -0
  21. package/dist/de-2SVTG25S.js.map +1 -0
  22. package/dist/drawings.d.ts +237 -0
  23. package/dist/drawings.js +199 -0
  24. package/dist/drawings.js.map +1 -0
  25. package/dist/es-UDHZM4W7.js +1028 -0
  26. package/dist/es-UDHZM4W7.js.map +1 -0
  27. package/dist/feature-manifest.json +3453 -0
  28. package/dist/fr-35VN4G4S.js +1028 -0
  29. package/dist/fr-35VN4G4S.js.map +1 -0
  30. package/dist/he_IL-JPZMCURP.js +1028 -0
  31. package/dist/he_IL-JPZMCURP.js.map +1 -0
  32. package/dist/id_ID-XSTFHHJQ.js +1028 -0
  33. package/dist/id_ID-XSTFHHJQ.js.map +1 -0
  34. package/dist/index.d.ts +5487 -0
  35. package/dist/index.js +24040 -0
  36. package/dist/index.js.map +1 -0
  37. package/dist/it-EIY6JESQ.js +1028 -0
  38. package/dist/it-EIY6JESQ.js.map +1 -0
  39. package/dist/ja-42N4XRCW.js +1028 -0
  40. package/dist/ja-42N4XRCW.js.map +1 -0
  41. package/dist/ko-3VRPTIP3.js +1028 -0
  42. package/dist/ko-3VRPTIP3.js.map +1 -0
  43. package/dist/ms_MY-SKN7O6M5.js +1028 -0
  44. package/dist/ms_MY-SKN7O6M5.js.map +1 -0
  45. package/dist/pl-TYARHCLT.js +1028 -0
  46. package/dist/pl-TYARHCLT.js.map +1 -0
  47. package/dist/pt-72IIFLL4.js +1028 -0
  48. package/dist/pt-72IIFLL4.js.map +1 -0
  49. package/dist/quickcharts.css +6217 -0
  50. package/dist/resources-Ch8eA1Mw.d.ts +228 -0
  51. package/dist/rest-openapi.json +1664 -0
  52. package/dist/ru-TPH4F7IB.js +1028 -0
  53. package/dist/ru-TPH4F7IB.js.map +1 -0
  54. package/dist/sv-DC5RS67Z.js +1028 -0
  55. package/dist/sv-DC5RS67Z.js.map +1 -0
  56. package/dist/th-I6H6AOZ3.js +1028 -0
  57. package/dist/th-I6H6AOZ3.js.map +1 -0
  58. package/dist/theme-manifest.json +1246 -0
  59. package/dist/tr-7FSUVCNW.js +1028 -0
  60. package/dist/tr-7FSUVCNW.js.map +1 -0
  61. package/dist/vi-DLRPHLLH.js +1028 -0
  62. package/dist/vi-DLRPHLLH.js.map +1 -0
  63. package/dist/zh-ZXIQBBEP.js +1028 -0
  64. package/dist/zh-ZXIQBBEP.js.map +1 -0
  65. package/dist/zh_TW-TYNUJU7U.js +1028 -0
  66. package/dist/zh_TW-TYNUJU7U.js.map +1 -0
  67. package/package.json +100 -0
@@ -0,0 +1,228 @@
1
+ declare const DRAWING_CONTEXT_VERSION = 1;
2
+ type DrawingContextKind = 'chart-local' | 'layout-shared' | 'symbol-global';
3
+ /** One chart of one layout, on one symbol. */
4
+ interface ChartLocalDrawingContext {
5
+ version: typeof DRAWING_CONTEXT_VERSION;
6
+ kind: 'chart-local';
7
+ /** The host's stable identity for the layout the chart is tiled in. */
8
+ layoutId: string;
9
+ /** The chart's stable identity WITHIN that layout, so the document is found again after a
10
+ * reload; a per-mount instance id would key a document nothing could ever read back. */
11
+ chartId: string;
12
+ symbol: string;
13
+ }
14
+ /** Every chart of one layout, on one symbol. */
15
+ interface LayoutSharedDrawingContext {
16
+ version: typeof DRAWING_CONTEXT_VERSION;
17
+ kind: 'layout-shared';
18
+ layoutId: string;
19
+ symbol: string;
20
+ }
21
+ /** Every chart the host mounts, on one symbol. */
22
+ interface SymbolGlobalDrawingContext {
23
+ version: typeof DRAWING_CONTEXT_VERSION;
24
+ kind: 'symbol-global';
25
+ symbol: string;
26
+ }
27
+ type DrawingResourceContext = ChartLocalDrawingContext | LayoutSharedDrawingContext | SymbolGlobalDrawingContext;
28
+ /** The drawings document format. Bumping this is the only reason a reader ever branches. */
29
+ declare const DRAWING_DOCUMENT_VERSION = 1;
30
+ /** One drawing in a document. The ENVELOPE is structured so a restore is validated without parsing
31
+ * the drawing itself: the id is stable for the drawing's life, `source` names what owns it (the
32
+ * main series, or an indicator's own source), `pane` names where it is drawn, and `type` is its
33
+ * tool. `state` is the drawing's own serialized form and is opaque to the document, the store and
34
+ * the transport. */
35
+ interface DrawingEntry {
36
+ id: string;
37
+ /** The owning source: `main` for the chart's main series, else an indicator instance's id. */
38
+ source: string;
39
+ /** The pane the drawing is drawn in: `main` for the price pane, else the pane owner's id. */
40
+ pane: string;
41
+ type: string;
42
+ /** Opaque: nothing between the layer and the backend reads it. */
43
+ state: unknown;
44
+ /** The group this drawing belongs to, when it belongs to one. */
45
+ group?: string;
46
+ }
47
+ /** A group of drawings. Membership is ORDERED and holds drawing ids, so a group survives a round
48
+ * trip with its order intact rather than being rebuilt from however a document happened to list
49
+ * its entries. */
50
+ interface DrawingGroup {
51
+ id: string;
52
+ name?: string;
53
+ members: readonly string[];
54
+ }
55
+ /** A deletion, kept. A document that listed only what survives lets a concurrent save, a reconnect
56
+ * or a reload resurrect what the trader deleted: the other side still holds the row and a merge
57
+ * takes it back. A tombstone says the deletion happened, and at which document revision, so the
58
+ * merge drops it instead. */
59
+ interface DrawingTombstone {
60
+ kind: 'drawing' | 'group';
61
+ id: string;
62
+ /** The document revision the deletion was stamped at. */
63
+ at: number;
64
+ }
65
+ /** One context's drawings document. `revision` is the DOCUMENT's own counter, which orders
66
+ * tombstones and detects a stale apply; it is not the store's `ResourceRef.revision`, which stays
67
+ * opaque and is the store's alone. */
68
+ interface DrawingsBody {
69
+ version: typeof DRAWING_DOCUMENT_VERSION;
70
+ context: DrawingResourceContext;
71
+ revision: number;
72
+ entries: readonly DrawingEntry[];
73
+ groups: readonly DrawingGroup[];
74
+ tombstones: readonly DrawingTombstone[];
75
+ }
76
+ /** The canonical key for a drawing-resource context: equal contexts key equally, and no two
77
+ * different contexts collide. The parts join on an escaped null, which no symbol, layout id or
78
+ * chart id carries, so a symbol ending in a separator cannot spell another context's key. The
79
+ * kind and version lead, so a later kind is a different key rather than a widened old one. */
80
+ declare function drawingContextKey(context: DrawingResourceContext): string;
81
+ /** Whether two contexts name the same document. */
82
+ declare const sameDrawingContext: (a: DrawingResourceContext, b: DrawingResourceContext) => boolean;
83
+ /** A document with nothing in it, at revision 0: what a context that has never been written reads
84
+ * as, so every caller works over a document rather than over a null. */
85
+ declare function emptyDrawingDocument(context: DrawingResourceContext): DrawingsBody;
86
+ /** The entries a document actually holds: nothing buried, no duplicate id, and no membership of a
87
+ * group that is gone (the drawing survives, its grouping does not). */
88
+ declare function liveDrawingEntries(document: DrawingsBody): DrawingEntry[];
89
+ /** The groups a document actually holds: nothing buried, no duplicate id, and no member that is
90
+ * buried or absent, so a group never names a drawing that is not there. */
91
+ declare function liveDrawingGroups(document: DrawingsBody): DrawingGroup[];
92
+ /** Replace what a document holds and stamp the difference. Every id the document held and the next
93
+ * state does not is buried at the new revision; every id that arrives is kept in the order it
94
+ * arrives in. One verb, one revision bump, so a save can never write entries at one revision and
95
+ * groups at another. */
96
+ declare function reviseDrawingDocument(document: DrawingsBody, next: {
97
+ entries?: readonly DrawingEntry[];
98
+ groups?: readonly DrawingGroup[];
99
+ }): DrawingsBody;
100
+ /** Merge the document another surface wrote first with this surface's own. The stored rows win by
101
+ * identity and keep the stored order, because they are what everyone else can already see; rows
102
+ * only this surface holds follow, because they are work the other surface never saw. Every
103
+ * deletion either side made survives the merge. The result's revision is past both, so the write
104
+ * that carries it is the newer document by either side's counter. */
105
+ declare function mergeDrawingDocuments(stored: DrawingsBody, mine: DrawingsBody): DrawingsBody;
106
+ /** Read whatever a transport handed back as a document for this context. TOTAL: a null, a string, a
107
+ * wrong version, a junk row or a whole junk body reads as the empty document, never a throw, so a
108
+ * host can hand the chart what its backend returned without guarding it first. The context is the
109
+ * caller's, not the payload's: a document is identified by where it was read from, and a body
110
+ * claiming another context is not merged into this one. */
111
+ declare function parseDrawingDocument(value: unknown, context: DrawingResourceContext): DrawingsBody;
112
+
113
+ /** A resource's identity plus the exact version this reader saw. A write quotes it back. */
114
+ interface ResourceRef {
115
+ id: string;
116
+ /** Opaque to the chart: minted by the store, compared only for equality. */
117
+ revision: string;
118
+ }
119
+ /** What a write did. `ok` carries the ref the store now holds (and, where the store computes one,
120
+ * the resulting metadata); `conflict` carries the ref that beat this write, so a caller can reload
121
+ * and re-decide; `not-found` means the id is gone. */
122
+ type WriteOutcome<T = void> = {
123
+ kind: 'ok';
124
+ ref: ResourceRef;
125
+ value?: T;
126
+ } | {
127
+ kind: 'conflict';
128
+ current: ResourceRef;
129
+ } | {
130
+ kind: 'not-found';
131
+ };
132
+ /** One family of resources. `Meta` is the listing row a picker shows without fetching content
133
+ * (it carries the row's ref, so a picker can delete or open a row without a second read); `Body`
134
+ * is the stored document. */
135
+ interface ResourceStore<Meta, Body> {
136
+ /** Listing rows, metadata only. */
137
+ list(signal?: AbortSignal): Promise<Meta[]>;
138
+ /** The stored document and the revision it was read at, or null when the id is unknown. */
139
+ load(id: string, signal?: AbortSignal): Promise<{
140
+ ref: ResourceRef;
141
+ body: Body;
142
+ } | null>;
143
+ /** Store a new document. The store mints the id; a create conflicts only where the store keys a
144
+ * document by identity and one already stands there (a drawings context that holds a document, a
145
+ * name already taken), and then it answers the ref that stands. */
146
+ create(body: Body, signal?: AbortSignal): Promise<WriteOutcome<Meta>>;
147
+ /** Replace the document at `ref.id`, but only while it still stands at `ref.revision`. */
148
+ update(ref: ResourceRef, body: Body, signal?: AbortSignal): Promise<WriteOutcome<Meta>>;
149
+ /** Delete the document at `ref.id`, but only while it still stands at `ref.revision`. */
150
+ remove(ref: ResourceRef, signal?: AbortSignal): Promise<WriteOutcome<void>>;
151
+ }
152
+ /** A saved chart's listing row. */
153
+ interface ChartMeta extends ResourceRef {
154
+ name: string;
155
+ symbol: string;
156
+ timeframe: string;
157
+ /** Last save, ms since epoch (server-stamped by real backends). */
158
+ updatedAt: number;
159
+ }
160
+ /** A saved chart. `content` is the chart's own serialized state, opaque to the store. */
161
+ interface ChartBody {
162
+ name: string;
163
+ symbol: string;
164
+ timeframe: string;
165
+ content: string;
166
+ }
167
+ /** A saved multi-chart layout's listing row. `symbol` is the active chart's market as the chart
168
+ * writes it (`symbolNames(...).mark`, such as `BTCUSDC`) and `timeframe` its timeframe token, both
169
+ * as they stood at the last save, so a listing can say what each layout shows without opening it. A
170
+ * store that does not keep them, or a layout saved before they were stated, leaves them out. */
171
+ interface LayoutMeta extends ResourceRef {
172
+ name: string;
173
+ symbol?: string;
174
+ timeframe?: string;
175
+ updatedAt: number;
176
+ }
177
+ /** A saved multi-chart layout. `content` is the arrangement's serialized state, opaque to the store.
178
+ * The widget states the listing's `symbol` and `timeframe` on every save; they are display text and
179
+ * play no part in restoring the layout. */
180
+ interface LayoutBody {
181
+ name: string;
182
+ symbol?: string;
183
+ timeframe?: string;
184
+ content: string;
185
+ }
186
+ /** A drawings document's listing row. A context holds at most one, so `list` returns zero rows or
187
+ * one, and the ref is the store's handle on it. */
188
+ interface DrawingsMeta extends ResourceRef {
189
+ updatedAt: number;
190
+ }
191
+ type TemplateKind = 'study' | 'drawing' | 'palette';
192
+ /** A named template's listing row. `tool` scopes DRAWING templates to their tool (a trend-line
193
+ * template is meaningless on a rectangle); study and palette templates carry no tool. */
194
+ interface TemplateMeta extends ResourceRef {
195
+ name: string;
196
+ tool?: string;
197
+ updatedAt: number;
198
+ }
199
+ interface TemplateBody {
200
+ name: string;
201
+ tool?: string;
202
+ content: string;
203
+ }
204
+ /** The adapter a host implements: four resource families over one revisioned contract. Viewer
205
+ * settings are deliberately absent; they belong to `ChartStorage`. */
206
+ interface ChartSaveLoadAdapter {
207
+ charts: ResourceStore<ChartMeta, ChartBody>;
208
+ layouts: ResourceStore<LayoutMeta, LayoutBody>;
209
+ /** The store for one drawing-resource context. Calling with an equal context returns an
210
+ * equivalent store; `drawingContextKey` is the canonical way to compare two. */
211
+ drawings(context: DrawingResourceContext): ResourceStore<DrawingsMeta, DrawingsBody>;
212
+ templates(kind: TemplateKind): ResourceStore<TemplateMeta, TemplateBody>;
213
+ }
214
+ /** The error every store rejects with when its signal aborts. `name` is 'AbortError', which is what
215
+ * callers branch on, and what `DOMException` uses, so a host may reject with either. */
216
+ declare class ResourceAbortError extends Error {
217
+ readonly name = "AbortError";
218
+ constructor(message?: string);
219
+ }
220
+ /** Options for {@link memorySaveLoadAdapter}: a clock, so a test can pin `updatedAt`. */
221
+ interface MemoryResourcesOptions {
222
+ now?: () => number;
223
+ }
224
+ /** An in-memory {@link ChartSaveLoadAdapter}. Each drawing context and each template kind gets its
225
+ * own store, created on first ask and kept, so two calls for one context see the same document. */
226
+ declare function memorySaveLoadAdapter(options?: MemoryResourcesOptions): ChartSaveLoadAdapter;
227
+
228
+ export { type ChartSaveLoadAdapter as C, DRAWING_CONTEXT_VERSION as D, type LayoutSharedDrawingContext as L, type MemoryResourcesOptions as M, type ResourceRef as R, type SymbolGlobalDrawingContext as S, type TemplateBody as T, type WriteOutcome as W, type ChartLocalDrawingContext as a, DRAWING_DOCUMENT_VERSION as b, type DrawingContextKind as c, type DrawingEntry as d, type DrawingGroup as e, type DrawingResourceContext as f, type DrawingTombstone as g, type DrawingsBody as h, type ResourceStore as i, type TemplateMeta as j, drawingContextKey as k, emptyDrawingDocument as l, liveDrawingEntries as m, liveDrawingGroups as n, mergeDrawingDocuments as o, parseDrawingDocument as p, type ChartMeta as q, reviseDrawingDocument as r, sameDrawingContext as s, type ChartBody as t, type DrawingsMeta as u, type LayoutMeta as v, type LayoutBody as w, ResourceAbortError as x, type TemplateKind as y, memorySaveLoadAdapter as z };