oakscriptjs 0.11.7 → 0.12.1

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 (40) hide show
  1. package/dist/cjs/drawing/registry.d.ts +2 -0
  2. package/dist/cjs/drawing/registry.d.ts.map +1 -1
  3. package/dist/cjs/drawing/registry.js +7 -0
  4. package/dist/cjs/drawing/registry.js.map +2 -2
  5. package/dist/cjs/index.d.ts +3 -3
  6. package/dist/cjs/index.d.ts.map +1 -1
  7. package/dist/cjs/index.js +2 -1
  8. package/dist/cjs/index.js.map +2 -2
  9. package/dist/cjs/runtime/types.d.ts +69 -0
  10. package/dist/cjs/runtime/types.d.ts.map +1 -1
  11. package/dist/cjs/runtime/types.js.map +1 -1
  12. package/dist/cjs/script/index.d.ts +41 -2
  13. package/dist/cjs/script/index.d.ts.map +1 -1
  14. package/dist/cjs/script/index.js +74 -24
  15. package/dist/cjs/script/index.js.map +2 -2
  16. package/dist/cjs/types/metadata.d.ts +8 -0
  17. package/dist/cjs/types/metadata.d.ts.map +1 -1
  18. package/dist/cjs/types/metadata.js.map +1 -1
  19. package/dist/esm/drawing/registry.d.ts +2 -0
  20. package/dist/esm/drawing/registry.d.ts.map +1 -1
  21. package/dist/esm/drawing/registry.js +8 -0
  22. package/dist/esm/drawing/registry.js.map +1 -1
  23. package/dist/esm/index.d.ts +3 -3
  24. package/dist/esm/index.d.ts.map +1 -1
  25. package/dist/esm/index.js +2 -2
  26. package/dist/esm/index.js.map +1 -1
  27. package/dist/esm/runtime/types.d.ts +69 -0
  28. package/dist/esm/runtime/types.d.ts.map +1 -1
  29. package/dist/esm/script/index.d.ts +41 -2
  30. package/dist/esm/script/index.d.ts.map +1 -1
  31. package/dist/esm/script/index.js +73 -18
  32. package/dist/esm/script/index.js.map +1 -1
  33. package/dist/esm/types/metadata.d.ts +8 -0
  34. package/dist/esm/types/metadata.d.ts.map +1 -1
  35. package/package.json +1 -1
  36. package/src/drawing/registry.ts +10 -0
  37. package/src/index.ts +5 -1
  38. package/src/runtime/types.ts +65 -0
  39. package/src/script/index.ts +99 -24
  40. package/src/types/metadata.ts +8 -0
@@ -111,6 +111,8 @@ export declare function setDrawingBar(barIndex: number | null, last?: boolean, l
111
111
  * #176).
112
112
  */
113
113
  export declare function checkBarIndex(method: string, variable: string, x: number, xloc: string | undefined): number;
114
+ /** The kinds of drawing objects created since the last {@link resetDrawings}, even when none is alive any more. */
115
+ export declare function createdDrawingKinds(): DrawingKind[];
114
116
  /** Records a new object and deletes the oldest objects of its kind when the count is too high. */
115
117
  export declare function register<K extends DrawingKind>(kind: K, obj: DrawingTypes[K]): DrawingTypes[K];
116
118
  /** Deletes an object (no effect when it is already deleted). */
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/drawing/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAErF,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,GAAG,OAAO,CAAC;AAEvF,UAAU,YAAY;IACpB,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;IACb,GAAG,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,QAAQ,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;CACd;AAED,+FAA+F;AAC/F,eAAO,MAAM,iBAAiB,KAAK,CAAC;AAIpC,MAAM,MAAM,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,GAAG,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAkChG;;;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B,GAAG,CAAC,CAAC,SAAS,WAAW,EAAE,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAE1E;AAED,4FAA4F;AAC5F,wBAAgB,aAAa,CAAC,SAAS,GAAE,aAAkB,GAAG,IAAI,CAgBjE;AAED,uGAAuG;AACvG,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI,CAE/D"}
@@ -23,6 +23,7 @@ __export(registry_exports, {
23
23
  MAX_DRAWING_BARS_FORWARD: () => MAX_DRAWING_BARS_FORWARD,
24
24
  all: () => all,
25
25
  checkBarIndex: () => checkBarIndex,
26
+ createdDrawingKinds: () => createdDrawingKinds,
26
27
  holdDrawing: () => holdDrawing,
27
28
  isDeleted: () => isDeleted,
28
29
  register: () => register,
@@ -171,8 +172,13 @@ function cutOldest(kind, list, obj, only) {
171
172
  list.push(...kept);
172
173
  return cut;
173
174
  }
175
+ const created = /* @__PURE__ */ new Set();
176
+ function createdDrawingKinds() {
177
+ return [...created];
178
+ }
174
179
  function register(kind, obj) {
175
180
  const list = live[kind];
181
+ created.add(kind);
176
182
  if (lastBar && isCounted(kind)) return registerLast(lastBar, kind, obj);
177
183
  if (isCounted(kind) && pending[kind] >= PENDING_RESET[kind]) pending[kind] = 0;
178
184
  list.push(obj);
@@ -223,6 +229,7 @@ function all(kind) {
223
229
  }
224
230
  function resetDrawings(newLimits = {}) {
225
231
  for (const kind of Object.keys(live)) live[kind].length = 0;
232
+ created.clear();
226
233
  held = /* @__PURE__ */ new WeakMap();
227
234
  releasedAt = /* @__PURE__ */ new WeakMap();
228
235
  heldAt = /* @__PURE__ */ new WeakMap();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/drawing/registry.ts"],
4
- "sourcesContent": ["/**\n * Registry of the live drawing objects (lines, labels, boxes, polylines, linefills, tables), as PineScript\n * keeps them. PineScript rules:\n *\n * - `line.all`, `label.all`, ... list the live objects in creation order (a copy of the list)\n * - `delete` removes an object; the object becomes `na`: its getters return NaN and its setters\n * do nothing. Deleting a line with `line.delete` also deletes the linefills that use it\n * - when a creation brings the count above `max_*_count + 5`, the oldest objects are deleted until\n * `max_*_count` remain (default 50). Copies count as creations. Linefills follow the same rule with\n * `max_lines_count`; lines deleted by this rule do not delete their linefills\n * - the object that was just created is never deleted by this rule\n * - an object that a `var` variable of the drawing type refers to is never deleted by this rule, and it still counts\n * (measured for lines, labels and boxes: with 9 held boxes and a maximum of 50, 9 held + 46 others stay; with 8\n * held lines and a maximum of 5, the 8 and the newest line stay). The protection starts on the bar after the\n * assignment: 12 `var` lines created on the first bar with a maximum of 5 lose the first 6. Only\n * the variable itself protects: an object in a `var` array, in a field of a user type or in a variable that got\n * another object or `na` later is deleted like any other. JavaScript has no `var` declaration to observe, so the\n * script says it: {@link varDrawing} (a variable), or {@link holdDrawing} / {@link releaseDrawing}\n * - linefills have the limit of `max_lines_count` with another rule for the held ones (measured on one script, two\n * long runs): a fill is skipped when a `var` variable holds it or released it less than 5,000 bars ago (the bar\n * of {@link setDrawingBar}); when the count is still above the maximum + 5 after that, the oldest fills are\n * deleted until the maximum remain, the held ones too\n * - the script deletes count (`line.delete`, `label.delete`, ...): each kind has a number `P` of deleted objects. A\n * delete adds 1; a creation first sets `P` to 0 when it is 5 or more (3 or more for polylines)\n * - polylines use `P` on every bar: a creation cuts when the count is above `max_polylines_count + 5 + P`, down to\n * the maximum + `P`, and the polylines of the cut are added to `P`. A script that deletes and creates one polyline\n * per bar therefore sees the cut 0, 1 or 2 bars late\n * - lines, labels and boxes use `P` on the last bar only, with its value at the start of that bar: there the cut is\n * above the maximum + 5 + `P`, down to the maximum + `P` (up to 4 more objects)\n * - the last bar has rules of its own (measured from the count after each creation, on a closed and on an open last\n * bar): a cut deletes the objects of the bars before first, at most those (a line takes its linefills with it);\n * once none is left, a cut deletes objects of the last bar as on any bar. With 10 lines and a maximum of 10, 13\n * lines on the last bar leave these 13: the cut at the 16th line deletes the 10 old ones only. Lines, labels and\n * boxes: equal to PineScript, count after every operation and objects alive at the end, on 72 of 72 runs checked\n * after the rule was written (and 218 of 218 end states before)\n * - polylines on the last bar: the `P` carried from the bar before is counted twice (the first creation adds it once\n * more, unless it sets `P` to 0), later creations do not set `P` to 0, and the polylines of the bars before that a\n * cut deletes are added to `P`. Once none is\n * left, `P` is at least the number of polylines of the bars before deleted on the last bar (by the count or by\n * the script) and a cut deletes polylines of the last bar: a script that deletes its 100 polylines and creates 200\n * on the last bar keeps them all (#176). Equal to PineScript for the polylines alive at the end on 271 of\n * 281 probe runs; the count inside the bar can differ when the script deletes polylines of the last bar\n *\n * - a bar index (`xloc.bar_index`) more than 10,000 bars before the current bar stops the script (runtime error\n * RE10026) in `line.new`, `box.new`, `label.new`, `polyline.new` and the setters of x. The current bar is the one\n * of `eachBar` in a script run; a port with its own bar loop gives it with {@link setDrawingBar}\n *\n * The script API (`executeScript`) resets the registry at the start of every run and applies the\n * `max_*_count` values of `indicator()`. Outside a script run the registry is global to the module.\n *\n * @module drawing/registry\n */\n\nimport type { Box, Label, Line, Linefill, Polyline, Table } from '../types/index.js';\n\nexport type DrawingKind = 'line' | 'label' | 'box' | 'polyline' | 'linefill' | 'table';\n\ninterface DrawingTypes {\n line: Line;\n label: Label;\n box: Box;\n polyline: Polyline;\n linefill: Linefill;\n table: Table;\n}\n\n/** Default `max_lines_count`, `max_labels_count`, `max_boxes_count`, `max_polylines_count`. */\nexport const DEFAULT_MAX_COUNT = 50;\n/** Objects above the maximum that PineScript keeps before it deletes the oldest ones. */\nconst SLACK = 5;\n\nexport type DrawingLimits = Partial<Record<Exclude<DrawingKind, 'linefill' | 'table'>, number>>;\n\nconst live: { [K in DrawingKind]: Array<DrawingTypes[K]> } = {\n line: [],\n label: [],\n box: [],\n polyline: [],\n linefill: [],\n table: [],\n};\nlet limits: Required<DrawingLimits> = {\n line: DEFAULT_MAX_COUNT,\n label: DEFAULT_MAX_COUNT,\n box: DEFAULT_MAX_COUNT,\n polyline: DEFAULT_MAX_COUNT,\n};\nconst deleted = new WeakSet<object>();\n/** Objects held by a `var` variable, with the number of variables that hold them. */\nlet held = new WeakMap<object, number>();\n/** Bar on which the last `var` variable released an object (linefill rule). */\nlet releasedAt = new WeakMap<object, number>();\n/** Bars during which a released linefill is still skipped by the maximum count. */\nconst LINEFILL_RELEASE_BARS = 5000;\n/** Bar on which a `var` variable got an object: the maximum count skips it from the next bar on. */\nlet heldAt = new WeakMap<object, number>();\n/** Kinds with a maximum count of their own. */\ntype CountedKind = 'line' | 'label' | 'box' | 'polyline';\nconst COUNTED_KINDS: readonly CountedKind[] = ['line', 'label', 'box', 'polyline'];\nconst isCounted = (kind: DrawingKind): kind is CountedKind => (COUNTED_KINDS as readonly DrawingKind[]).includes(kind);\n/** `P` of the module notes: objects deleted by the script (for polylines also by the maximum count). */\nlet pending: Record<CountedKind, number> = { line: 0, label: 0, box: 0, polyline: 0 };\n/** A creation sets `P` to 0 from this value on. */\nconst PENDING_RESET: Record<CountedKind, number> = { line: 5, label: 5, box: 5, polyline: 3 };\n\n/**\n * Marks an object as held by a `var` variable (PineScript `var line l = ...` or `l := line.new(...)` on a `var`\n * variable): the maximum count never deletes it, and it still counts. Returns the object.\n */\nexport function holdDrawing<T extends object>(obj: T): T {\n if (!held.has(obj)) {\n if (currentBar === null) heldAt.delete(obj);\n else heldAt.set(obj, currentBar);\n }\n held.set(obj, (held.get(obj) ?? 0) + 1);\n return obj;\n}\n\n/** The `var` variable no longer refers to the object (it got another object or `na`). */\nexport function releaseDrawing(obj: object | null | undefined): void {\n if (!obj) return;\n const count = held.get(obj) ?? 0;\n if (count > 1) held.set(obj, count - 1);\n else if (held.delete(obj) && currentBar !== null) releasedAt.set(obj, currentBar);\n}\n\n/** Held by a `var` variable since a bar before the current one (or outside a bar loop). */\nfunction heldBefore(obj: object): boolean {\n if (!held.has(obj)) return false;\n const bar = heldAt.get(obj);\n return bar === undefined || currentBar === null || bar < currentBar;\n}\n\n/** Linefill rule: held, or released less than 5,000 bars ago. */\nfunction fillProtected(obj: object): boolean {\n if (held.has(obj)) return true;\n const bar = releasedAt.get(obj);\n return bar !== undefined && currentBar !== null && currentBar - bar < LINEFILL_RELEASE_BARS;\n}\n\n/** A `var` variable of a drawing type: see {@link varDrawing}. */\nexport interface DrawingVariable<T extends object> {\n /** The object of the variable; setting it holds the new object and releases the one before */\n value: T | undefined;\n}\n\n/**\n * A PineScript `var` variable of a drawing type (`var line l = na`). The object it refers to is not deleted by the\n * maximum count; assigning another object (or `undefined` for `na`) releases the one before.\n *\n * @example\n * ```typescript\n * // Pine: var line level = na\n * // level := line.new(bar_index, close, bar_index + 1, close)\n * const level = varDrawing<Line>();\n * level.value = line.new(i, close, i + 1, close);\n * ```\n */\nexport function varDrawing<T extends object>(initial?: T): DrawingVariable<T> {\n let current: T | undefined = initial ? holdDrawing(initial) : undefined;\n return {\n get value() {\n return current;\n },\n set value(next: T | undefined) {\n if (next === current) return;\n releaseDrawing(current);\n current = next ? holdDrawing(next) : undefined;\n },\n };\n}\n\n/** Largest distance, in bars, of a bar index before the current bar (PineScript runtime error RE10026 above it). */\nexport const MAX_DRAWING_BARS_BACK = 10000;\n/** Largest distance, in bars, of a bar index after the last bar of the data (PineScript runtime error RE10020 above it). */\nexport const MAX_DRAWING_BARS_FORWARD = 500;\nlet currentBar: number | null = null;\nlet lastBarIndex: number | null = null;\n\n/** Kinds whose allowance on the last bar is the `P` they had when the bar started. */\ntype AllowanceKind = 'line' | 'label' | 'box';\nconst isAllowanceKind = (kind: DrawingKind): kind is AllowanceKind => kind === 'line' || kind === 'label' || kind === 'box';\n\n/** State of the last bar (see the module notes). */\ninterface LastBar {\n bar: number;\n /** The objects alive when the bar started (the objects of the bars before) */\n old: Set<object>;\n /** `P` of lines, labels and boxes when the bar started: their allowance for the whole bar */\n allowance: Record<AllowanceKind, number>;\n /** `P` of polylines when the bar started */\n carried: number;\n /** A polyline was created on this bar */\n polyline: boolean;\n /** Polylines of the bars before deleted on this bar (by the count or by the script) */\n oldPolylinesGone: number;\n}\nlet lastBar: LastBar | null = null;\n\n/**\n * Tells the drawing functions which bar is being calculated (`bar_index`), so that a bar index more than 10,000\n * bars back throws as in PineScript; `null` turns the check off. `eachBar` of the script API calls it.\n *\n * The bar also dates the objects held by a `var` variable (protected from the next bar on). `last` says that it is\n * the last bar of the data, which has rules of its own for the maximum count. `lastIndex` is the bar index of the\n * last bar of the data (PineScript `last_bar_index`): with it, a bar index more than 500 bars after it throws, also\n * on the bars before the last one (RE10020).\n */\nexport function setDrawingBar(barIndex: number | null, last: boolean = false, lastIndex?: number): void {\n if (lastBar && !(last && barIndex === lastBar.bar)) lastBar = null;\n currentBar = barIndex;\n lastBarIndex = barIndex === null ? null : (lastIndex ?? (last ? barIndex : null));\n if (barIndex !== null && last && !lastBar) {\n const start = (kind: AllowanceKind): number => (pending[kind] >= PENDING_RESET[kind] ? 0 : pending[kind]);\n lastBar = {\n bar: barIndex,\n old: new Set<object>([...live.line, ...live.label, ...live.box, ...live.polyline]),\n allowance: { line: start('line'), label: start('label'), box: start('box') },\n carried: pending.polyline,\n polyline: false,\n oldPolylinesGone: 0,\n };\n }\n}\n\n/**\n * Throws the PineScript runtime error RE10026 when `x` is a bar index more than 10,000 bars before the current bar,\n * and RE10020 when it is more than 500 bars after the last bar of the data (when {@link setDrawingBar} knows it).\n * `method` and `variable` are the names of the PineScript message (\"line.new\", \"x1\").\n *\n * Returns `x`, truncated when it is a bar index: PineScript's x is an int (a box from 5537.94 starts on bar 5537,\n * #176).\n */\nexport function checkBarIndex(method: string, variable: string, x: number, xloc: string | undefined): number {\n if ((xloc ?? 'bar_index') !== 'bar_index') return x;\n x = Math.trunc(x);\n if (currentBar === null) return x;\n if (lastBarIndex !== null && x - lastBarIndex > MAX_DRAWING_BARS_FORWARD) {\n throw new Error(\n `Error on bar ${currentBar}: Objects positioned using xloc.bar_index cannot be drawn further than ` +\n `${MAX_DRAWING_BARS_FORWARD} bars into the future.`\n );\n }\n if (currentBar - x > MAX_DRAWING_BARS_BACK) {\n throw new Error(\n `Error on bar ${currentBar}: Bar index value of the \\`${variable}\\` argument (${x}) in \\`${method}()\\` is too far ` +\n 'from the current bar index. Try using `time` instead.'\n );\n }\n return x;\n}\n\n/** Numeric fields that become NaN when an object is deleted, so that its getters return `na`. */\nconst COORDINATES: { [K in DrawingKind]: Array<keyof DrawingTypes[K]> } = {\n line: ['x1', 'y1', 'x2', 'y2'],\n label: ['x', 'y'],\n box: ['left', 'top', 'right', 'bottom'],\n polyline: [],\n linefill: [],\n table: [],\n};\n\nfunction markDeleted<K extends DrawingKind>(kind: K, obj: DrawingTypes[K], explicit: boolean): void {\n deleted.add(obj);\n for (const field of COORDINATES[kind]) (obj as unknown as Record<string, unknown>)[field as string] = NaN;\n if (kind === 'line' && explicit) {\n for (const fill of live.linefill.filter((f) => f.line1 === obj || f.line2 === obj)) remove('linefill', fill);\n }\n}\n\n/** Objects above the maximum that the rule allows for, besides the 5: `P` of the module notes. */\nfunction allowance(kind: DrawingKind): number {\n if (kind === 'polyline') return pending.polyline;\n return lastBar && isAllowanceKind(kind) ? lastBar.allowance[kind] : 0;\n}\n\n/**\n * The maximum count after the creation of `obj`: removes the objects to delete from `list` (the oldest first; the new\n * object and an object held by a `var` variable are skipped and still count) and returns them.\n */\nfunction cutOldest<K extends DrawingKind>(\n kind: K,\n list: Array<DrawingTypes[K]>,\n obj: DrawingTypes[K],\n only?: (old: object) => boolean\n): Array<DrawingTypes[K]> {\n if (kind === 'table') return []; // tables have no maximum count\n const max = limits[kind === 'linefill' ? 'line' : (kind as keyof DrawingLimits)] + allowance(kind);\n if (list.length <= max + SLACK) return [];\n const kept: Array<DrawingTypes[K]> = [];\n const cut: Array<DrawingTypes[K]> = [];\n let excess = list.length - max;\n for (const old of list) {\n if (excess > 0 && old !== obj && (!only || only(old)) && !(kind === 'linefill' ? fillProtected(old) : heldBefore(old))) {\n excess--;\n cut.push(old);\n } else kept.push(old);\n }\n // linefills: still above the maximum + 5, the oldest go, the held ones too\n if (kind === 'linefill' && kept.length > max + SLACK) cut.push(...kept.splice(0, kept.length - max));\n list.length = 0;\n list.push(...kept);\n return cut;\n}\n\n/** Records a new object and deletes the oldest objects of its kind when the count is too high. */\nexport function register<K extends DrawingKind>(kind: K, obj: DrawingTypes[K]): DrawingTypes[K] {\n const list = live[kind];\n if (lastBar && isCounted(kind)) return registerLast(lastBar, kind, obj);\n if (isCounted(kind) && pending[kind] >= PENDING_RESET[kind]) pending[kind] = 0;\n list.push(obj);\n const cut = cutOldest(kind, list, obj);\n if (kind === 'polyline') pending.polyline += cut.length;\n for (const old of cut) markDeleted(kind, old, false);\n return obj;\n}\n\n/** An object created on the last bar (see the module notes). */\nfunction registerLast<K extends DrawingKind>(bar: LastBar, kind: K, obj: DrawingTypes[K]): DrawingTypes[K] {\n if (kind === 'polyline' && !bar.polyline) {\n bar.polyline = true;\n if (pending.polyline >= PENDING_RESET.polyline) pending.polyline = 0;\n else pending.polyline += bar.carried; // counted twice\n }\n const list = live[kind];\n list.push(obj);\n const isOld = (old: object): boolean => bar.old.has(old);\n if (list.some((old) => old !== obj && isOld(old) && !heldBefore(old))) {\n // the objects of the bars before only; a line takes its linefills with it\n const cut = cutOldest(kind, list, obj, isOld);\n if (kind === 'polyline') {\n pending.polyline += cut.length;\n bar.oldPolylinesGone += cut.length;\n }\n for (const old of cut) markDeleted(kind, old, true);\n } else {\n // the polylines of the bars before deleted on this bar count before the cut (#176)\n if (kind === 'polyline' && pending.polyline < bar.oldPolylinesGone) pending.polyline = bar.oldPolylinesGone;\n const cut = cutOldest(kind, list, obj);\n if (kind === 'polyline' && cut.length > 0) pending.polyline = bar.oldPolylinesGone;\n for (const old of cut) markDeleted(kind, old, false);\n }\n return obj;\n}\n\n/** Deletes an object (no effect when it is already deleted). */\nexport function remove<K extends DrawingKind>(kind: K, obj: DrawingTypes[K]): void {\n const list = live[kind];\n const index = list.indexOf(obj);\n if (index !== -1) {\n list.splice(index, 1);\n if (isCounted(kind)) pending[kind]++;\n if (kind === 'polyline' && lastBar?.old.has(obj)) lastBar.oldPolylinesGone++;\n }\n if (!deleted.has(obj)) markDeleted(kind, obj, true);\n}\n\n/** True when the object was deleted (by `delete` or by the maximum count). */\nexport function isDeleted(obj: unknown): boolean {\n return typeof obj === 'object' && obj !== null && deleted.has(obj);\n}\n\n/** The live objects of a kind, in creation order (a new array). */\nexport function all<K extends DrawingKind>(kind: K): Array<DrawingTypes[K]> {\n return [...live[kind]] as Array<DrawingTypes[K]>;\n}\n\n/** Forgets all objects (without deleting them) and sets the maximum counts (default 50). */\nexport function resetDrawings(newLimits: DrawingLimits = {}): void {\n for (const kind of Object.keys(live) as DrawingKind[]) live[kind].length = 0;\n held = new WeakMap();\n releasedAt = new WeakMap();\n heldAt = new WeakMap();\n pending = { line: 0, label: 0, box: 0, polyline: 0 };\n currentBar = null;\n lastBarIndex = null;\n lastBar = null;\n limits = {\n line: newLimits.line ?? DEFAULT_MAX_COUNT,\n label: newLimits.label ?? DEFAULT_MAX_COUNT,\n box: newLimits.box ?? DEFAULT_MAX_COUNT,\n polyline: newLimits.polyline ?? DEFAULT_MAX_COUNT,\n };\n}\n\n/** Changes the maximum counts without forgetting the objects (PineScript `indicator(max_*_count)`). */\nexport function setDrawingLimits(newLimits: DrawingLimits): void {\n limits = { ...limits, ...Object.fromEntries(Object.entries(newLimits).filter(([, v]) => v !== undefined)) };\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmEO,MAAM,oBAAoB;AAEjC,MAAM,QAAQ;AAId,MAAM,OAAuD;AAAA,EAC3D,MAAM,CAAC;AAAA,EACP,OAAO,CAAC;AAAA,EACR,KAAK,CAAC;AAAA,EACN,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,OAAO,CAAC;AACV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YAAU;AACV,WAAS;AAAA,IACP,MAAM,UAAU,QAAQ;AAAA,IACxB,OAAO,UAAU,SAAS;AAAA,IAC1B,KAAK,UAAU,OAAO;AAAA,IACtB,UAAU,UAAU,YAAY;AAAA,EAClC;AACF;AAGO,SAAS,iBAAiB,WAAgC;AAC/D,WAAS,EAAE,GAAG,QAAQ,GAAG,OAAO,YAAY,OAAO,QAAQ,SAAS,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,MAAM,MAAS,CAAC,EAAE;AAC5G;",
4
+ "sourcesContent": ["/**\n * Registry of the live drawing objects (lines, labels, boxes, polylines, linefills, tables), as PineScript\n * keeps them. PineScript rules:\n *\n * - `line.all`, `label.all`, ... list the live objects in creation order (a copy of the list)\n * - `delete` removes an object; the object becomes `na`: its getters return NaN and its setters\n * do nothing. Deleting a line with `line.delete` also deletes the linefills that use it\n * - when a creation brings the count above `max_*_count + 5`, the oldest objects are deleted until\n * `max_*_count` remain (default 50). Copies count as creations. Linefills follow the same rule with\n * `max_lines_count`; lines deleted by this rule do not delete their linefills\n * - the object that was just created is never deleted by this rule\n * - an object that a `var` variable of the drawing type refers to is never deleted by this rule, and it still counts\n * (measured for lines, labels and boxes: with 9 held boxes and a maximum of 50, 9 held + 46 others stay; with 8\n * held lines and a maximum of 5, the 8 and the newest line stay). The protection starts on the bar after the\n * assignment: 12 `var` lines created on the first bar with a maximum of 5 lose the first 6. Only\n * the variable itself protects: an object in a `var` array, in a field of a user type or in a variable that got\n * another object or `na` later is deleted like any other. JavaScript has no `var` declaration to observe, so the\n * script says it: {@link varDrawing} (a variable), or {@link holdDrawing} / {@link releaseDrawing}\n * - linefills have the limit of `max_lines_count` with another rule for the held ones (measured on one script, two\n * long runs): a fill is skipped when a `var` variable holds it or released it less than 5,000 bars ago (the bar\n * of {@link setDrawingBar}); when the count is still above the maximum + 5 after that, the oldest fills are\n * deleted until the maximum remain, the held ones too\n * - the script deletes count (`line.delete`, `label.delete`, ...): each kind has a number `P` of deleted objects. A\n * delete adds 1; a creation first sets `P` to 0 when it is 5 or more (3 or more for polylines)\n * - polylines use `P` on every bar: a creation cuts when the count is above `max_polylines_count + 5 + P`, down to\n * the maximum + `P`, and the polylines of the cut are added to `P`. A script that deletes and creates one polyline\n * per bar therefore sees the cut 0, 1 or 2 bars late\n * - lines, labels and boxes use `P` on the last bar only, with its value at the start of that bar: there the cut is\n * above the maximum + 5 + `P`, down to the maximum + `P` (up to 4 more objects)\n * - the last bar has rules of its own (measured from the count after each creation, on a closed and on an open last\n * bar): a cut deletes the objects of the bars before first, at most those (a line takes its linefills with it);\n * once none is left, a cut deletes objects of the last bar as on any bar. With 10 lines and a maximum of 10, 13\n * lines on the last bar leave these 13: the cut at the 16th line deletes the 10 old ones only. Lines, labels and\n * boxes: equal to PineScript, count after every operation and objects alive at the end, on 72 of 72 runs checked\n * after the rule was written (and 218 of 218 end states before)\n * - polylines on the last bar: the `P` carried from the bar before is counted twice (the first creation adds it once\n * more, unless it sets `P` to 0), later creations do not set `P` to 0, and the polylines of the bars before that a\n * cut deletes are added to `P`. Once none is\n * left, `P` is at least the number of polylines of the bars before deleted on the last bar (by the count or by\n * the script) and a cut deletes polylines of the last bar: a script that deletes its 100 polylines and creates 200\n * on the last bar keeps them all (#176). Equal to PineScript for the polylines alive at the end on 271 of\n * 281 probe runs; the count inside the bar can differ when the script deletes polylines of the last bar\n *\n * - a bar index (`xloc.bar_index`) more than 10,000 bars before the current bar stops the script (runtime error\n * RE10026) in `line.new`, `box.new`, `label.new`, `polyline.new` and the setters of x. The current bar is the one\n * of `eachBar` in a script run; a port with its own bar loop gives it with {@link setDrawingBar}\n *\n * The script API (`executeScript`) resets the registry at the start of every run and applies the\n * `max_*_count` values of `indicator()`. Outside a script run the registry is global to the module.\n *\n * @module drawing/registry\n */\n\nimport type { Box, Label, Line, Linefill, Polyline, Table } from '../types/index.js';\n\nexport type DrawingKind = 'line' | 'label' | 'box' | 'polyline' | 'linefill' | 'table';\n\ninterface DrawingTypes {\n line: Line;\n label: Label;\n box: Box;\n polyline: Polyline;\n linefill: Linefill;\n table: Table;\n}\n\n/** Default `max_lines_count`, `max_labels_count`, `max_boxes_count`, `max_polylines_count`. */\nexport const DEFAULT_MAX_COUNT = 50;\n/** Objects above the maximum that PineScript keeps before it deletes the oldest ones. */\nconst SLACK = 5;\n\nexport type DrawingLimits = Partial<Record<Exclude<DrawingKind, 'linefill' | 'table'>, number>>;\n\nconst live: { [K in DrawingKind]: Array<DrawingTypes[K]> } = {\n line: [],\n label: [],\n box: [],\n polyline: [],\n linefill: [],\n table: [],\n};\nlet limits: Required<DrawingLimits> = {\n line: DEFAULT_MAX_COUNT,\n label: DEFAULT_MAX_COUNT,\n box: DEFAULT_MAX_COUNT,\n polyline: DEFAULT_MAX_COUNT,\n};\nconst deleted = new WeakSet<object>();\n/** Objects held by a `var` variable, with the number of variables that hold them. */\nlet held = new WeakMap<object, number>();\n/** Bar on which the last `var` variable released an object (linefill rule). */\nlet releasedAt = new WeakMap<object, number>();\n/** Bars during which a released linefill is still skipped by the maximum count. */\nconst LINEFILL_RELEASE_BARS = 5000;\n/** Bar on which a `var` variable got an object: the maximum count skips it from the next bar on. */\nlet heldAt = new WeakMap<object, number>();\n/** Kinds with a maximum count of their own. */\ntype CountedKind = 'line' | 'label' | 'box' | 'polyline';\nconst COUNTED_KINDS: readonly CountedKind[] = ['line', 'label', 'box', 'polyline'];\nconst isCounted = (kind: DrawingKind): kind is CountedKind => (COUNTED_KINDS as readonly DrawingKind[]).includes(kind);\n/** `P` of the module notes: objects deleted by the script (for polylines also by the maximum count). */\nlet pending: Record<CountedKind, number> = { line: 0, label: 0, box: 0, polyline: 0 };\n/** A creation sets `P` to 0 from this value on. */\nconst PENDING_RESET: Record<CountedKind, number> = { line: 5, label: 5, box: 5, polyline: 3 };\n\n/**\n * Marks an object as held by a `var` variable (PineScript `var line l = ...` or `l := line.new(...)` on a `var`\n * variable): the maximum count never deletes it, and it still counts. Returns the object.\n */\nexport function holdDrawing<T extends object>(obj: T): T {\n if (!held.has(obj)) {\n if (currentBar === null) heldAt.delete(obj);\n else heldAt.set(obj, currentBar);\n }\n held.set(obj, (held.get(obj) ?? 0) + 1);\n return obj;\n}\n\n/** The `var` variable no longer refers to the object (it got another object or `na`). */\nexport function releaseDrawing(obj: object | null | undefined): void {\n if (!obj) return;\n const count = held.get(obj) ?? 0;\n if (count > 1) held.set(obj, count - 1);\n else if (held.delete(obj) && currentBar !== null) releasedAt.set(obj, currentBar);\n}\n\n/** Held by a `var` variable since a bar before the current one (or outside a bar loop). */\nfunction heldBefore(obj: object): boolean {\n if (!held.has(obj)) return false;\n const bar = heldAt.get(obj);\n return bar === undefined || currentBar === null || bar < currentBar;\n}\n\n/** Linefill rule: held, or released less than 5,000 bars ago. */\nfunction fillProtected(obj: object): boolean {\n if (held.has(obj)) return true;\n const bar = releasedAt.get(obj);\n return bar !== undefined && currentBar !== null && currentBar - bar < LINEFILL_RELEASE_BARS;\n}\n\n/** A `var` variable of a drawing type: see {@link varDrawing}. */\nexport interface DrawingVariable<T extends object> {\n /** The object of the variable; setting it holds the new object and releases the one before */\n value: T | undefined;\n}\n\n/**\n * A PineScript `var` variable of a drawing type (`var line l = na`). The object it refers to is not deleted by the\n * maximum count; assigning another object (or `undefined` for `na`) releases the one before.\n *\n * @example\n * ```typescript\n * // Pine: var line level = na\n * // level := line.new(bar_index, close, bar_index + 1, close)\n * const level = varDrawing<Line>();\n * level.value = line.new(i, close, i + 1, close);\n * ```\n */\nexport function varDrawing<T extends object>(initial?: T): DrawingVariable<T> {\n let current: T | undefined = initial ? holdDrawing(initial) : undefined;\n return {\n get value() {\n return current;\n },\n set value(next: T | undefined) {\n if (next === current) return;\n releaseDrawing(current);\n current = next ? holdDrawing(next) : undefined;\n },\n };\n}\n\n/** Largest distance, in bars, of a bar index before the current bar (PineScript runtime error RE10026 above it). */\nexport const MAX_DRAWING_BARS_BACK = 10000;\n/** Largest distance, in bars, of a bar index after the last bar of the data (PineScript runtime error RE10020 above it). */\nexport const MAX_DRAWING_BARS_FORWARD = 500;\nlet currentBar: number | null = null;\nlet lastBarIndex: number | null = null;\n\n/** Kinds whose allowance on the last bar is the `P` they had when the bar started. */\ntype AllowanceKind = 'line' | 'label' | 'box';\nconst isAllowanceKind = (kind: DrawingKind): kind is AllowanceKind => kind === 'line' || kind === 'label' || kind === 'box';\n\n/** State of the last bar (see the module notes). */\ninterface LastBar {\n bar: number;\n /** The objects alive when the bar started (the objects of the bars before) */\n old: Set<object>;\n /** `P` of lines, labels and boxes when the bar started: their allowance for the whole bar */\n allowance: Record<AllowanceKind, number>;\n /** `P` of polylines when the bar started */\n carried: number;\n /** A polyline was created on this bar */\n polyline: boolean;\n /** Polylines of the bars before deleted on this bar (by the count or by the script) */\n oldPolylinesGone: number;\n}\nlet lastBar: LastBar | null = null;\n\n/**\n * Tells the drawing functions which bar is being calculated (`bar_index`), so that a bar index more than 10,000\n * bars back throws as in PineScript; `null` turns the check off. `eachBar` of the script API calls it.\n *\n * The bar also dates the objects held by a `var` variable (protected from the next bar on). `last` says that it is\n * the last bar of the data, which has rules of its own for the maximum count. `lastIndex` is the bar index of the\n * last bar of the data (PineScript `last_bar_index`): with it, a bar index more than 500 bars after it throws, also\n * on the bars before the last one (RE10020).\n */\nexport function setDrawingBar(barIndex: number | null, last: boolean = false, lastIndex?: number): void {\n if (lastBar && !(last && barIndex === lastBar.bar)) lastBar = null;\n currentBar = barIndex;\n lastBarIndex = barIndex === null ? null : (lastIndex ?? (last ? barIndex : null));\n if (barIndex !== null && last && !lastBar) {\n const start = (kind: AllowanceKind): number => (pending[kind] >= PENDING_RESET[kind] ? 0 : pending[kind]);\n lastBar = {\n bar: barIndex,\n old: new Set<object>([...live.line, ...live.label, ...live.box, ...live.polyline]),\n allowance: { line: start('line'), label: start('label'), box: start('box') },\n carried: pending.polyline,\n polyline: false,\n oldPolylinesGone: 0,\n };\n }\n}\n\n/**\n * Throws the PineScript runtime error RE10026 when `x` is a bar index more than 10,000 bars before the current bar,\n * and RE10020 when it is more than 500 bars after the last bar of the data (when {@link setDrawingBar} knows it).\n * `method` and `variable` are the names of the PineScript message (\"line.new\", \"x1\").\n *\n * Returns `x`, truncated when it is a bar index: PineScript's x is an int (a box from 5537.94 starts on bar 5537,\n * #176).\n */\nexport function checkBarIndex(method: string, variable: string, x: number, xloc: string | undefined): number {\n if ((xloc ?? 'bar_index') !== 'bar_index') return x;\n x = Math.trunc(x);\n if (currentBar === null) return x;\n if (lastBarIndex !== null && x - lastBarIndex > MAX_DRAWING_BARS_FORWARD) {\n throw new Error(\n `Error on bar ${currentBar}: Objects positioned using xloc.bar_index cannot be drawn further than ` +\n `${MAX_DRAWING_BARS_FORWARD} bars into the future.`\n );\n }\n if (currentBar - x > MAX_DRAWING_BARS_BACK) {\n throw new Error(\n `Error on bar ${currentBar}: Bar index value of the \\`${variable}\\` argument (${x}) in \\`${method}()\\` is too far ` +\n 'from the current bar index. Try using `time` instead.'\n );\n }\n return x;\n}\n\n/** Numeric fields that become NaN when an object is deleted, so that its getters return `na`. */\nconst COORDINATES: { [K in DrawingKind]: Array<keyof DrawingTypes[K]> } = {\n line: ['x1', 'y1', 'x2', 'y2'],\n label: ['x', 'y'],\n box: ['left', 'top', 'right', 'bottom'],\n polyline: [],\n linefill: [],\n table: [],\n};\n\nfunction markDeleted<K extends DrawingKind>(kind: K, obj: DrawingTypes[K], explicit: boolean): void {\n deleted.add(obj);\n for (const field of COORDINATES[kind]) (obj as unknown as Record<string, unknown>)[field as string] = NaN;\n if (kind === 'line' && explicit) {\n for (const fill of live.linefill.filter((f) => f.line1 === obj || f.line2 === obj)) remove('linefill', fill);\n }\n}\n\n/** Objects above the maximum that the rule allows for, besides the 5: `P` of the module notes. */\nfunction allowance(kind: DrawingKind): number {\n if (kind === 'polyline') return pending.polyline;\n return lastBar && isAllowanceKind(kind) ? lastBar.allowance[kind] : 0;\n}\n\n/**\n * The maximum count after the creation of `obj`: removes the objects to delete from `list` (the oldest first; the new\n * object and an object held by a `var` variable are skipped and still count) and returns them.\n */\nfunction cutOldest<K extends DrawingKind>(\n kind: K,\n list: Array<DrawingTypes[K]>,\n obj: DrawingTypes[K],\n only?: (old: object) => boolean\n): Array<DrawingTypes[K]> {\n if (kind === 'table') return []; // tables have no maximum count\n const max = limits[kind === 'linefill' ? 'line' : (kind as keyof DrawingLimits)] + allowance(kind);\n if (list.length <= max + SLACK) return [];\n const kept: Array<DrawingTypes[K]> = [];\n const cut: Array<DrawingTypes[K]> = [];\n let excess = list.length - max;\n for (const old of list) {\n if (excess > 0 && old !== obj && (!only || only(old)) && !(kind === 'linefill' ? fillProtected(old) : heldBefore(old))) {\n excess--;\n cut.push(old);\n } else kept.push(old);\n }\n // linefills: still above the maximum + 5, the oldest go, the held ones too\n if (kind === 'linefill' && kept.length > max + SLACK) cut.push(...kept.splice(0, kept.length - max));\n list.length = 0;\n list.push(...kept);\n return cut;\n}\n\n/** Kinds of the objects created since the last reset (a table counts too), in no order. */\nconst created = new Set<DrawingKind>();\n\n/** The kinds of drawing objects created since the last {@link resetDrawings}, even when none is alive any more. */\nexport function createdDrawingKinds(): DrawingKind[] {\n return [...created];\n}\n\n/** Records a new object and deletes the oldest objects of its kind when the count is too high. */\nexport function register<K extends DrawingKind>(kind: K, obj: DrawingTypes[K]): DrawingTypes[K] {\n const list = live[kind];\n created.add(kind);\n if (lastBar && isCounted(kind)) return registerLast(lastBar, kind, obj);\n if (isCounted(kind) && pending[kind] >= PENDING_RESET[kind]) pending[kind] = 0;\n list.push(obj);\n const cut = cutOldest(kind, list, obj);\n if (kind === 'polyline') pending.polyline += cut.length;\n for (const old of cut) markDeleted(kind, old, false);\n return obj;\n}\n\n/** An object created on the last bar (see the module notes). */\nfunction registerLast<K extends DrawingKind>(bar: LastBar, kind: K, obj: DrawingTypes[K]): DrawingTypes[K] {\n if (kind === 'polyline' && !bar.polyline) {\n bar.polyline = true;\n if (pending.polyline >= PENDING_RESET.polyline) pending.polyline = 0;\n else pending.polyline += bar.carried; // counted twice\n }\n const list = live[kind];\n list.push(obj);\n const isOld = (old: object): boolean => bar.old.has(old);\n if (list.some((old) => old !== obj && isOld(old) && !heldBefore(old))) {\n // the objects of the bars before only; a line takes its linefills with it\n const cut = cutOldest(kind, list, obj, isOld);\n if (kind === 'polyline') {\n pending.polyline += cut.length;\n bar.oldPolylinesGone += cut.length;\n }\n for (const old of cut) markDeleted(kind, old, true);\n } else {\n // the polylines of the bars before deleted on this bar count before the cut (#176)\n if (kind === 'polyline' && pending.polyline < bar.oldPolylinesGone) pending.polyline = bar.oldPolylinesGone;\n const cut = cutOldest(kind, list, obj);\n if (kind === 'polyline' && cut.length > 0) pending.polyline = bar.oldPolylinesGone;\n for (const old of cut) markDeleted(kind, old, false);\n }\n return obj;\n}\n\n/** Deletes an object (no effect when it is already deleted). */\nexport function remove<K extends DrawingKind>(kind: K, obj: DrawingTypes[K]): void {\n const list = live[kind];\n const index = list.indexOf(obj);\n if (index !== -1) {\n list.splice(index, 1);\n if (isCounted(kind)) pending[kind]++;\n if (kind === 'polyline' && lastBar?.old.has(obj)) lastBar.oldPolylinesGone++;\n }\n if (!deleted.has(obj)) markDeleted(kind, obj, true);\n}\n\n/** True when the object was deleted (by `delete` or by the maximum count). */\nexport function isDeleted(obj: unknown): boolean {\n return typeof obj === 'object' && obj !== null && deleted.has(obj);\n}\n\n/** The live objects of a kind, in creation order (a new array). */\nexport function all<K extends DrawingKind>(kind: K): Array<DrawingTypes[K]> {\n return [...live[kind]] as Array<DrawingTypes[K]>;\n}\n\n/** Forgets all objects (without deleting them) and sets the maximum counts (default 50). */\nexport function resetDrawings(newLimits: DrawingLimits = {}): void {\n for (const kind of Object.keys(live) as DrawingKind[]) live[kind].length = 0;\n created.clear();\n held = new WeakMap();\n releasedAt = new WeakMap();\n heldAt = new WeakMap();\n pending = { line: 0, label: 0, box: 0, polyline: 0 };\n currentBar = null;\n lastBarIndex = null;\n lastBar = null;\n limits = {\n line: newLimits.line ?? DEFAULT_MAX_COUNT,\n label: newLimits.label ?? DEFAULT_MAX_COUNT,\n box: newLimits.box ?? DEFAULT_MAX_COUNT,\n polyline: newLimits.polyline ?? DEFAULT_MAX_COUNT,\n };\n}\n\n/** Changes the maximum counts without forgetting the objects (PineScript `indicator(max_*_count)`). */\nexport function setDrawingLimits(newLimits: DrawingLimits): void {\n limits = { ...limits, ...Object.fromEntries(Object.entries(newLimits).filter(([, v]) => v !== undefined)) };\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmEO,MAAM,oBAAoB;AAEjC,MAAM,QAAQ;AAId,MAAM,OAAuD;AAAA,EAC3D,MAAM,CAAC;AAAA,EACP,OAAO,CAAC;AAAA,EACR,KAAK,CAAC;AAAA,EACN,UAAU,CAAC;AAAA,EACX,UAAU,CAAC;AAAA,EACX,OAAO,CAAC;AACV;AACA,IAAI,SAAkC;AAAA,EACpC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,KAAK;AAAA,EACL,UAAU;AACZ;AACA,MAAM,UAAU,oBAAI,QAAgB;AAEpC,IAAI,OAAO,oBAAI,QAAwB;AAEvC,IAAI,aAAa,oBAAI,QAAwB;AAE7C,MAAM,wBAAwB;AAE9B,IAAI,SAAS,oBAAI,QAAwB;AAGzC,MAAM,gBAAwC,CAAC,QAAQ,SAAS,OAAO,UAAU;AACjF,MAAM,YAAY,CAAC,SAA4C,cAAyC,SAAS,IAAI;AAErH,IAAI,UAAuC,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,EAAE;AAEpF,MAAM,gBAA6C,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,EAAE;AAMrF,SAAS,YAA8B,KAAW;AACvD,MAAI,CAAC,KAAK,IAAI,GAAG,GAAG;AAClB,QAAI,eAAe,KAAM,QAAO,OAAO,GA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;AACtB,QAAM,QAAQ,KAAK,QAAQ,GAAG;AAC9B,MAAI,UAAU,IAAI;AAChB,SAAK,OAAO,OAAO,CAAC;AACpB,QAAI,UAAU,IAAI,EAAG,SAAQ,IAAI;AACjC,QAAI,SAAS,cAAc,SAAS,IAAI,IAAI,GAAG,EAAG,SAAQ;AAAA,EAC5D;AACA,MAAI,CAAC,QAAQ,IAAI,GAAG,EAAG,aAAY,MAAM,KAAK,IAAI;AACpD;AAGO,SAAS,UAAU,KAAuB;AAC/C,SAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,QAAQ,IAAI,GAAG;AACnE;AAGO,SAAS,IAA2B,MAAiC;AAC1E,SAAO,CAAC,GAAG,KAAK,IAAI,CAAC;AACvB;AAGO,SAAS,cAAc,YAA2B,CAAC,GAAS;AACjE,aAAW,QAAQ,OAAO,KAAK,IAAI,EAAoB,MAAK,IAAI,EAAE,SAAS;AAC3E,UAAQ,MAAM;AACd,SAAO,oBAAI,QAAQ;AACnB,eAAa,oBAAI,QAAQ;AACzB,WAAS,oBAAI,QAAQ;AACrB,YAAU,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,UAAU,EAAE;AACnD,eAAa;AACb,iBAAe;AACf,YAAU;AACV,WAAS;AAAA,IACP,MAAM,UAAU,QAAQ;AAAA,IACxB,OAAO,UAAU,SAAS;AAAA,IAC1B,KAAK,UAAU,OAAO;AAAA,IACtB,UAAU,UAAU,YAAY;AAAA,EAClC;AACF;AAGO,SAAS,iBAAiB,WAAgC;AAC/D,WAAS,EAAE,GAAG,QAAQ,GAAG,OAAO,YAAY,OAAO,QAAQ,SAAS,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,MAAM,MAAM,MAAS,CAAC,EAAE;AAC5G;",
6
6
  "names": []
7
7
  }
@@ -35,7 +35,7 @@ import * as callsite from './callsite/index.js';
35
35
  export { taCore, math, array, map, str, color, time, timeframe, matrix, line, box, label, linefill, chartPoint, polyline, table, text, compare, callsite };
36
36
  export { drawingOutputs, type DrawingOutputs } from './drawing/output.js';
37
37
  export { barInterval, barTime } from './drawing/bar-time.js';
38
- export { resetDrawings, setDrawingLimits, setDrawingBar, holdDrawing, releaseDrawing, varDrawing, type DrawingLimits, type DrawingVariable, } from './drawing/registry.js';
38
+ export { resetDrawings, setDrawingLimits, setDrawingBar, holdDrawing, releaseDrawing, varDrawing, createdDrawingKinds, type DrawingKind, type DrawingLimits, type DrawingVariable, } from './drawing/registry.js';
39
39
  export { chartSessions, sessionPeriods, periodTime, periodClose, tradingDayTime, chartSessionFlags, resampleSession, barTimeAfter, barsUntil, type SessionContext, type ChartSessions, type SessionPeriods, type SessionResample, } from './session/context.js';
40
40
  export { TradingCalendar, type SessionSpec } from './session/calendar.js';
41
41
  export { SessionBars, sessionFlags, type SessionFlags } from './session/bars.js';
@@ -59,13 +59,13 @@ export { plot as plotHelper, createPlot, type Time, type TimeValuePair, type Plo
59
59
  export { setContext, clearContext, getContext, registerCalculate, recalculate, plot, hline, clearPlots, } from './runtime/runtime.js';
60
60
  export { input_int, input_float, input_bool, input_string, input_text_area, input_source, input_timeframe, input_session, input_symbol, input_time, } from './runtime/inputs.js';
61
61
  export { isInputActive } from './runtime/input-active.js';
62
- export type { OakScriptContext, ChartAdapter, InputAdapter, SeriesHandle, SeriesOptions, InputConfig, InputCondition, InputOptions, OhlcvData, PlotConfig, HLineConfig, FillConfig, ArrowConfig, CandleConfig, } from './runtime/types.js';
62
+ export type { OakScriptContext, ChartAdapter, InputAdapter, SeriesHandle, SeriesOptions, InputConfig, InputCondition, InputOptions, OhlcvData, PlotConfig, HLineConfig, FillConfig, ArrowConfig, CandleConfig, ShapeConfig, BarColorConfig, } from './runtime/types.js';
63
63
  export { STRATEGY_CONSTANTS, STRATEGY_DEFAULTS, STRATEGY_NUMBER_VARIABLES, STRATEGY_TEXT_VARIABLES, } from './strategy/index.js';
64
64
  export type * from './strategy/index.js';
65
65
  export { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter.js';
66
66
  export type { LightweightSeriesDefinitions } from './runtime/adapters/LightweightChartsAdapter.js';
67
67
  export { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';
68
- export declare const VERSION = "0.11.7";
68
+ export declare const VERSION = "0.12.1";
69
69
  /**
70
70
  * Library information
71
71
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AAGpC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,UAAU,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAChD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,MAAM,EAAE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CAAC;AAC7B,mBAAmB,qBAAqB,CAAC;AAEzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gDAAgD,CAAC;AAC1F,YAAY,EAAE,4BAA4B,EAAE,MAAM,gDAAgD,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,MAAM,0CAA0C,CAAC;AAG9E,eAAO,MAAM,OAAO,WAAW,CAAC;AAEhC;;GAEG;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;CAiBhB,CAAC;AAKF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAE5F"}
package/dist/cjs/index.js CHANGED
@@ -67,6 +67,7 @@ __export(index_exports, {
67
67
  compare: () => compare,
68
68
  cos: () => import_math.cos,
69
69
  createPlot: () => import_plot.createPlot,
70
+ createdDrawingKinds: () => import_registry.createdDrawingKinds,
70
71
  crossover: () => import_ta_series.crossover,
71
72
  crossunder: () => import_ta_series.crossunder,
72
73
  cum: () => import_ta_series.cum,
@@ -207,7 +208,7 @@ var import_input_active = require("./runtime/input-active.js");
207
208
  var import_strategy = require("./strategy/index.js");
208
209
  var import_LightweightChartsAdapter = require("./runtime/adapters/LightweightChartsAdapter.js");
209
210
  var import_SimpleInputAdapter = require("./runtime/adapters/SimpleInputAdapter.js");
210
- const VERSION = "0.11.7";
211
+ const VERSION = "0.12.1";
211
212
  const info = {
212
213
  name: "OakScriptJS",
213
214
  version: VERSION,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["/**\n * OakScriptJS - Simplified PineScript-like library for JavaScript\n *\n * This library provides Series-based lazy evaluation and technical analysis functions\n * for building trading indicators. The PineScript-style script API is in `oakscriptjs/script`.\n *\n * Key features:\n * - Series class for lazy evaluation and method chaining\n * - Core TA functions (array-based)\n * - TA-Series wrappers (Series-based)\n *\n * @packageDocumentation\n */\n\n// Export all types\nexport * from './types/index.js';\nexport * from './types/metadata.js';\n\n// Export core namespaces (array-based functions)\nimport * as taCore from './ta/index.js';\nimport * as math from './math/index.js';\nimport * as array from './array/index.js';\nimport * as map from './map/index.js';\nimport * as str from './str/index.js';\nimport * as color from './color/index.js';\nimport * as time from './time/index.js';\nimport * as timeframe from './timeframe/index.js';\nimport * as matrix from './matrix/index.js';\nimport * as line from './line/index.js';\nimport * as box from './box/index.js';\nimport * as label from './label/index.js';\nimport * as linefill from './linefill/index.js';\nimport * as chartPoint from './chartpoint/index.js';\nimport * as polyline from './polyline/index.js';\nimport * as table from './table/index.js';\nimport * as text from './text/index.js';\nimport * as compare from './compare/index.js';\nimport * as callsite from './callsite/index.js';\n\nexport { taCore, math, array, map, str, color, time, timeframe, matrix, line, box, label, linefill, chartPoint, polyline, table, text, compare, callsite };\n\n// Renderable drawings (IndicatorResult labels, lines, boxes, linefills, polylines, tables) and future bar times\nexport { drawingOutputs, type DrawingOutputs } from './drawing/output.js';\nexport { barInterval, barTime } from './drawing/bar-time.js';\n\n// Drawing registry limits (PineScript indicator(max_lines_count / max_labels_count / max_boxes_count / max_polylines_count))\nexport {\n resetDrawings,\n setDrawingLimits,\n setDrawingBar,\n holdDrawing,\n releaseDrawing,\n varDrawing,\n type DrawingLimits,\n type DrawingVariable,\n} from './drawing/registry.js';\n\n// The session of a chart context without a script run: time(tf, session, timezone), time_close(...), time_tradingday,\n// session.* flags, request.security periods with the session and holidays, and bars after the last bar on the trading\n// calendar\nexport {\n chartSessions,\n sessionPeriods,\n periodTime,\n periodClose,\n tradingDayTime,\n chartSessionFlags,\n resampleSession,\n barTimeAfter,\n barsUntil,\n type SessionContext,\n type ChartSessions,\n type SessionPeriods,\n type SessionResample,\n} from './session/context.js';\nexport { TradingCalendar, type SessionSpec } from './session/calendar.js';\nexport { SessionBars, sessionFlags, type SessionFlags } from './session/bars.js';\n\n// Same-symbol request.security on a higher timeframe (completion and lookahead rules) and ticker.heikinashi\nexport { resample, periodsOf, afterCompletion, mapToChart, heikinAshi, type Resampled } from './security/resample.js';\n// request.security of another symbol: which bar of the other symbol each chart bar shows (#179)\nexport {\n securityOther,\n securityOtherValues,\n securityLowerTf,\n type OtherSymbolChart,\n type OtherSymbolOptions,\n type SymbolCalendar,\n} from './security/other.js';\n\n// Export Series class (self-contained, no context)\nexport { Series, BarData } from './runtime/series.js';\nexport type { SeriesExtractor } from './runtime/series.js';\n\n// Export TA-Series namespace (Series-based wrappers)\nimport * as ta from './ta-series.js';\nexport { ta };\n\n// Export metadata types for indicator return values\nexport type {\n PlotOptions,\n HLineOptions,\n FillOptions,\n InputMetadata,\n PlotMetadata,\n IndicatorMetadata,\n TimeValue,\n PlotData,\n HLineData,\n FillData,\n FillGradient,\n IndicatorResult,\n IndicatorFactory,\n PlotStyle,\n LineStyle,\n PlotDisplay,\n InputType\n} from './types/metadata.js';\n\n// Re-export commonly used functions for convenience\nexport { sma, ema, rsi, macd, bb, stdev, crossover, crossunder, change, tr, atr, cum, vwap } from './ta-series.js';\nexport { abs, ceil, floor, round, max, min, avg, sum, sqrt, pow, exp, log, sin, cos, tan } from './math/index.js';\nexport { rgb, from_hex as color_from_hex, new_color } from './color/index.js';\n\n// Export chart data utilities\nexport { ohlcFromBars, getClose, getHigh, getLow, getOpen, getSource, getSourceSeries, at, div } from './utils/index.js';\nexport { setSourceResolver, externalSource, BUILTIN_SOURCES, type SourceResolver } from './utils/source-resolver.js';\n\n// Export libraries (ZigZag, etc.)\nexport * from './lib/index.js';\n\n// Export helper functions for generated indicators (PineScript compatibility)\nexport {isNA as na, nz, fixnan} from './utils/index.js';\n\n// Export indicator infrastructure\nexport {\n indicator,\n type IndicatorMetadataConfig,\n type InputDefinition,\n type IndicatorContext,\n type IndicatorInstance,\n type IndicatorConstructor,\n} from './indicator.js';\n\nexport {\n input,\n type InputValue,\n type IntInputOptions,\n type FloatInputOptions,\n type SourceInputOptions,\n type BoolInputOptions,\n type StringInputOptions,\n type TimeInputOptions,\n type SourceType,\n} from './input.js';\n\nexport {\n plot as plotHelper,\n createPlot,\n type Time,\n type TimeValuePair,\n type PlotOptions as PlotHelperOptions,\n type PlotResult,\n} from './plot.js';\n\n// Runtime exports - global context runtime (setContext, plot, hline) drawing through a ChartAdapter\nexport {\n setContext,\n clearContext,\n getContext,\n registerCalculate,\n recalculate,\n plot,\n hline,\n clearPlots,\n} from './runtime/runtime.js';\n\nexport {\n input_int,\n input_float,\n input_bool,\n input_string,\n input_text_area,\n input_source,\n input_timeframe,\n input_session,\n input_symbol,\n input_time,\n} from './runtime/inputs.js';\nexport { isInputActive } from './runtime/input-active.js';\n\nexport type {\n OakScriptContext,\n ChartAdapter,\n InputAdapter,\n SeriesHandle,\n SeriesOptions,\n InputConfig,\n InputCondition,\n InputOptions,\n OhlcvData,\n PlotConfig,\n HLineConfig,\n FillConfig,\n ArrowConfig,\n CandleConfig,\n} from './runtime/types.js';\n\n// Strategy types and constants (the script API forwards strategy.* calls to a host engine)\nexport {\n STRATEGY_CONSTANTS,\n STRATEGY_DEFAULTS,\n STRATEGY_NUMBER_VARIABLES,\n STRATEGY_TEXT_VARIABLES,\n} from './strategy/index.js';\nexport type * from './strategy/index.js';\n\nexport { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter.js';\nexport type { LightweightSeriesDefinitions } from './runtime/adapters/LightweightChartsAdapter.js';\nexport { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';\n\n// Version\nexport const VERSION = '0.11.7';\n\n/**\n * Library information\n */\nexport const info = {\n name: 'OakScriptJS',\n version: VERSION,\n description: 'Simplified PineScript-like library - Series + TA functions',\n features: {\n series: 'Lazy evaluation with Series class',\n ta: 'Technical analysis functions (Series and array-based)',\n script: 'PineScript-style script API (oakscriptjs/script): indicator, strategy, inputs, plots, request.security',\n runtime: 'Global context runtime drawing through a ChartAdapter',\n indicator: 'Indicator function with automatic pane management'\n },\n namespaces: {\n core: ['ta', 'math', 'array', 'map', 'str', 'color', 'time', 'timeframe', 'matrix'],\n drawing: ['line', 'box', 'label', 'linefill', 'chartPoint', 'polyline', 'table', 'text'],\n runtime: ['setContext', 'plot', 'hline', 'input_*'],\n indicator: ['indicator', 'input', 'plotHelper', 'createPlot']\n }\n};\n\n// PineScript compatibility stubs - functions that have no runtime effect\n// These are no-ops so that PineScript-style code runs without modification\n\n/**\n * alertcondition() - Stub for PineScript alert configuration\n * In PineScript, this registers an alert condition. In oakscriptjs, it's a no-op\n * since alert configuration is handled by the host application.\n */\nexport function alertcondition(_condition: unknown, _title?: string, _message?: string): void {\n // No-op: Alert conditions are handled by the host application\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;A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,UAAyB;AAE9F;",
4
+ "sourcesContent": ["/**\n * OakScriptJS - Simplified PineScript-like library for JavaScript\n *\n * This library provides Series-based lazy evaluation and technical analysis functions\n * for building trading indicators. The PineScript-style script API is in `oakscriptjs/script`.\n *\n * Key features:\n * - Series class for lazy evaluation and method chaining\n * - Core TA functions (array-based)\n * - TA-Series wrappers (Series-based)\n *\n * @packageDocumentation\n */\n\n// Export all types\nexport * from './types/index.js';\nexport * from './types/metadata.js';\n\n// Export core namespaces (array-based functions)\nimport * as taCore from './ta/index.js';\nimport * as math from './math/index.js';\nimport * as array from './array/index.js';\nimport * as map from './map/index.js';\nimport * as str from './str/index.js';\nimport * as color from './color/index.js';\nimport * as time from './time/index.js';\nimport * as timeframe from './timeframe/index.js';\nimport * as matrix from './matrix/index.js';\nimport * as line from './line/index.js';\nimport * as box from './box/index.js';\nimport * as label from './label/index.js';\nimport * as linefill from './linefill/index.js';\nimport * as chartPoint from './chartpoint/index.js';\nimport * as polyline from './polyline/index.js';\nimport * as table from './table/index.js';\nimport * as text from './text/index.js';\nimport * as compare from './compare/index.js';\nimport * as callsite from './callsite/index.js';\n\nexport { taCore, math, array, map, str, color, time, timeframe, matrix, line, box, label, linefill, chartPoint, polyline, table, text, compare, callsite };\n\n// Renderable drawings (IndicatorResult labels, lines, boxes, linefills, polylines, tables) and future bar times\nexport { drawingOutputs, type DrawingOutputs } from './drawing/output.js';\nexport { barInterval, barTime } from './drawing/bar-time.js';\n\n// Drawing registry limits (PineScript indicator(max_lines_count / max_labels_count / max_boxes_count / max_polylines_count))\nexport {\n resetDrawings,\n setDrawingLimits,\n setDrawingBar,\n holdDrawing,\n releaseDrawing,\n varDrawing,\n createdDrawingKinds,\n type DrawingKind,\n type DrawingLimits,\n type DrawingVariable,\n} from './drawing/registry.js';\n\n// The session of a chart context without a script run: time(tf, session, timezone), time_close(...), time_tradingday,\n// session.* flags, request.security periods with the session and holidays, and bars after the last bar on the trading\n// calendar\nexport {\n chartSessions,\n sessionPeriods,\n periodTime,\n periodClose,\n tradingDayTime,\n chartSessionFlags,\n resampleSession,\n barTimeAfter,\n barsUntil,\n type SessionContext,\n type ChartSessions,\n type SessionPeriods,\n type SessionResample,\n} from './session/context.js';\nexport { TradingCalendar, type SessionSpec } from './session/calendar.js';\nexport { SessionBars, sessionFlags, type SessionFlags } from './session/bars.js';\n\n// Same-symbol request.security on a higher timeframe (completion and lookahead rules) and ticker.heikinashi\nexport { resample, periodsOf, afterCompletion, mapToChart, heikinAshi, type Resampled } from './security/resample.js';\n// request.security of another symbol: which bar of the other symbol each chart bar shows (#179)\nexport {\n securityOther,\n securityOtherValues,\n securityLowerTf,\n type OtherSymbolChart,\n type OtherSymbolOptions,\n type SymbolCalendar,\n} from './security/other.js';\n\n// Export Series class (self-contained, no context)\nexport { Series, BarData } from './runtime/series.js';\nexport type { SeriesExtractor } from './runtime/series.js';\n\n// Export TA-Series namespace (Series-based wrappers)\nimport * as ta from './ta-series.js';\nexport { ta };\n\n// Export metadata types for indicator return values\nexport type {\n PlotOptions,\n HLineOptions,\n FillOptions,\n InputMetadata,\n PlotMetadata,\n IndicatorMetadata,\n TimeValue,\n PlotData,\n HLineData,\n FillData,\n FillGradient,\n IndicatorResult,\n IndicatorFactory,\n PlotStyle,\n LineStyle,\n PlotDisplay,\n InputType\n} from './types/metadata.js';\n\n// Re-export commonly used functions for convenience\nexport { sma, ema, rsi, macd, bb, stdev, crossover, crossunder, change, tr, atr, cum, vwap } from './ta-series.js';\nexport { abs, ceil, floor, round, max, min, avg, sum, sqrt, pow, exp, log, sin, cos, tan } from './math/index.js';\nexport { rgb, from_hex as color_from_hex, new_color } from './color/index.js';\n\n// Export chart data utilities\nexport { ohlcFromBars, getClose, getHigh, getLow, getOpen, getSource, getSourceSeries, at, div } from './utils/index.js';\nexport { setSourceResolver, externalSource, BUILTIN_SOURCES, type SourceResolver } from './utils/source-resolver.js';\n\n// Export libraries (ZigZag, etc.)\nexport * from './lib/index.js';\n\n// Export helper functions for generated indicators (PineScript compatibility)\nexport {isNA as na, nz, fixnan} from './utils/index.js';\n\n// Export indicator infrastructure\nexport {\n indicator,\n type IndicatorMetadataConfig,\n type InputDefinition,\n type IndicatorContext,\n type IndicatorInstance,\n type IndicatorConstructor,\n} from './indicator.js';\n\nexport {\n input,\n type InputValue,\n type IntInputOptions,\n type FloatInputOptions,\n type SourceInputOptions,\n type BoolInputOptions,\n type StringInputOptions,\n type TimeInputOptions,\n type SourceType,\n} from './input.js';\n\nexport {\n plot as plotHelper,\n createPlot,\n type Time,\n type TimeValuePair,\n type PlotOptions as PlotHelperOptions,\n type PlotResult,\n} from './plot.js';\n\n// Runtime exports - global context runtime (setContext, plot, hline) drawing through a ChartAdapter\nexport {\n setContext,\n clearContext,\n getContext,\n registerCalculate,\n recalculate,\n plot,\n hline,\n clearPlots,\n} from './runtime/runtime.js';\n\nexport {\n input_int,\n input_float,\n input_bool,\n input_string,\n input_text_area,\n input_source,\n input_timeframe,\n input_session,\n input_symbol,\n input_time,\n} from './runtime/inputs.js';\nexport { isInputActive } from './runtime/input-active.js';\n\nexport type {\n OakScriptContext,\n ChartAdapter,\n InputAdapter,\n SeriesHandle,\n SeriesOptions,\n InputConfig,\n InputCondition,\n InputOptions,\n OhlcvData,\n PlotConfig,\n HLineConfig,\n FillConfig,\n ArrowConfig,\n CandleConfig,\n ShapeConfig,\n BarColorConfig,\n} from './runtime/types.js';\n\n// Strategy types and constants (the script API forwards strategy.* calls to a host engine)\nexport {\n STRATEGY_CONSTANTS,\n STRATEGY_DEFAULTS,\n STRATEGY_NUMBER_VARIABLES,\n STRATEGY_TEXT_VARIABLES,\n} from './strategy/index.js';\nexport type * from './strategy/index.js';\n\nexport { LightweightChartsAdapter } from './runtime/adapters/LightweightChartsAdapter.js';\nexport type { LightweightSeriesDefinitions } from './runtime/adapters/LightweightChartsAdapter.js';\nexport { SimpleInputAdapter } from './runtime/adapters/SimpleInputAdapter.js';\n\n// Version\nexport const VERSION = '0.12.1';\n\n/**\n * Library information\n */\nexport const info = {\n name: 'OakScriptJS',\n version: VERSION,\n description: 'Simplified PineScript-like library - Series + TA functions',\n features: {\n series: 'Lazy evaluation with Series class',\n ta: 'Technical analysis functions (Series and array-based)',\n script: 'PineScript-style script API (oakscriptjs/script): indicator, strategy, inputs, plots, request.security',\n runtime: 'Global context runtime drawing through a ChartAdapter',\n indicator: 'Indicator function with automatic pane management'\n },\n namespaces: {\n core: ['ta', 'math', 'array', 'map', 'str', 'color', 'time', 'timeframe', 'matrix'],\n drawing: ['line', 'box', 'label', 'linefill', 'chartPoint', 'polyline', 'table', 'text'],\n runtime: ['setContext', 'plot', 'hline', 'input_*'],\n indicator: ['indicator', 'input', 'plotHelper', 'createPlot']\n }\n};\n\n// PineScript compatibility stubs - functions that have no runtime effect\n// These are no-ops so that PineScript-style code runs without modification\n\n/**\n * alertcondition() - Stub for PineScript alert configuration\n * In PineScript, this registers an alert condition. In oakscriptjs, it's a no-op\n * since alert configuration is handled by the host application.\n */\nexport function alertcondition(_condition: unknown, _title?: string, _message?: string): void {\n // No-op: Alert conditions are handled by the host application\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AC,MAAM,QAAQ,SAAS,OAAO,OAAO,SAAS,QAAQ,aAAa,QAAQ;AAAA,IAClF,SAAS,CAAC,QAAQ,OAAO,SAAS,YAAY,cAAc,YAAY,SAAS,MAAM;AAAA,IACvF,SAAS,CAAC,cAAc,QAAQ,SAAS,SAAS;AAAA,IAClD,WAAW,CAAC,aAAa,SAAS,cAAc,YAAY;AAAA,EAC9D;AACF;AAUO,SAAS,eAAe,YAAqB,QAAiB,UAAyB;AAE9F;",
6
6
  "names": ["import_utils"]
7
7
  }
@@ -136,6 +136,11 @@ export interface PlotConfig {
136
136
  linestyle?: 'solid' | 'dashed' | 'dotted';
137
137
  /** Drawn on the main chart pane even when the script is not an overlay (PineScript `force_overlay`); default false */
138
138
  forceOverlay?: boolean;
139
+ /**
140
+ * False: the output is not listed in the Style settings of the study (PineScript `editable = false`); it is still
141
+ * drawn. Default true
142
+ */
143
+ editable?: boolean;
139
144
  }
140
145
  /**
141
146
  * Configuration of a PineScript `plotarrow()` declaration: an up arrow (below the bar) for a positive value, a down
@@ -161,6 +166,11 @@ export interface ArrowConfig {
161
166
  display?: 'all' | 'none' | 'data_window' | 'status_line' | 'pane';
162
167
  /** Drawn on the main chart pane even when the script is not an overlay (PineScript `force_overlay`); default false */
163
168
  forceOverlay?: boolean;
169
+ /**
170
+ * False: the output is not listed in the Style settings of the study (PineScript `editable = false`); it is still
171
+ * drawn. Default true
172
+ */
173
+ editable?: boolean;
164
174
  }
165
175
  /**
166
176
  * Configuration of a PineScript `plotcandle()` (kind 'candle') or `plotbar()` (kind 'bar') declaration. The candles
@@ -183,6 +193,21 @@ export interface CandleConfig {
183
193
  display?: 'all' | 'none' | 'data_window' | 'status_line' | 'pane';
184
194
  /** Drawn on the main chart pane even when the script is not an overlay (PineScript `force_overlay`); default false */
185
195
  forceOverlay?: boolean;
196
+ /**
197
+ * False: the output is not listed in the Style settings of the study (PineScript `editable = false`); it is still
198
+ * drawn. Default true
199
+ */
200
+ editable?: boolean;
201
+ /**
202
+ * The colours the study chooses from per bar (the PineScript palette of the body / wick / border colour), when they
203
+ * are a fixed set: a user can change each of them. Unset: a single colour (`color` / `wickColor` / `borderColor`)
204
+ * or colours computed per bar
205
+ */
206
+ palettes?: {
207
+ color?: string[];
208
+ wickColor?: string[];
209
+ borderColor?: string[];
210
+ };
186
211
  }
187
212
  /**
188
213
  * Configuration for horizontal line outputs in generated indicators
@@ -203,6 +228,11 @@ export interface HLineConfig {
203
228
  linewidth?: number;
204
229
  /** Display mode */
205
230
  display?: 'all' | 'none' | 'data_window' | 'status_line' | 'pane';
231
+ /**
232
+ * False: the output is not listed in the Style settings of the study (PineScript `editable = false`); it is still
233
+ * drawn. Default true
234
+ */
235
+ editable?: boolean;
206
236
  }
207
237
  /**
208
238
  * Configuration for fill between plots or hlines in generated indicators
@@ -225,6 +255,20 @@ export interface FillConfig {
225
255
  title?: string;
226
256
  /** Whether the fill is visible (can be boolean or expression string for dynamic visibility) */
227
257
  visible?: boolean | string;
258
+ /**
259
+ * False: the output is not listed in the Style settings of the study (PineScript `editable = false`); it is still
260
+ * drawn. Default true
261
+ */
262
+ editable?: boolean;
263
+ /** Gradient fill: its colour at the top value when it is the same on every bar */
264
+ topColor?: string;
265
+ /** Gradient fill: its colour at the bottom value when it is the same on every bar */
266
+ bottomColor?: string;
267
+ /**
268
+ * The colours the fill chooses from per bar when they are a fixed set (PineScript palette): a user can change each
269
+ * of them. Unset: `color` (one colour) or colours computed per bar
270
+ */
271
+ palette?: string[];
228
272
  }
229
273
  /**
230
274
  * Configuration for plotshape/plotchar outputs in generated indicators
@@ -255,6 +299,16 @@ export interface ShapeConfig {
255
299
  offset?: number;
256
300
  /** Drawn on the main chart pane even when the script is not an overlay (PineScript `force_overlay`); default false */
257
301
  forceOverlay?: boolean;
302
+ /**
303
+ * False: the output is not listed in the Style settings of the study (PineScript `editable = false`); it is still
304
+ * drawn. Default true
305
+ */
306
+ editable?: boolean;
307
+ /**
308
+ * The colours the output chooses from per bar when they are a fixed set (PineScript palette): a user can change
309
+ * each of them. Unset: `color` (one colour) or colours computed per bar
310
+ */
311
+ palette?: string[];
258
312
  }
259
313
  /**
260
314
  * Configuration for bgcolor/barcolor outputs in generated indicators
@@ -271,6 +325,21 @@ export interface BarColorConfig {
271
325
  /** bgcolor only: drawn on the main chart pane even when the script is not an overlay (PineScript
272
326
  * `force_overlay`); default false */
273
327
  forceOverlay?: boolean;
328
+ /**
329
+ * False: the output is not listed in the Style settings of the study (PineScript `editable = false`); it is still
330
+ * drawn. Default true
331
+ */
332
+ editable?: boolean;
333
+ /**
334
+ * The colours the output chooses from per bar (PineScript palette): a user can change each of them. A colour given
335
+ * as a constant is a palette of one colour. Unset: colours computed per bar
336
+ */
337
+ palette?: string[];
338
+ /**
339
+ * Where the output comes among the plot / shape / character / arrow / candle outputs (`outputs` of the script): it
340
+ * was declared after the first `outputIndex` of them. The Style settings list it there. Unset: after all of them
341
+ */
342
+ outputIndex?: number;
274
343
  }
275
344
  /**
276
345
  * Options for numeric inputs
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/runtime/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;CAC7E;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,mBAAmB;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2DAA2D;IAC3D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qBAAqB;IACrB,YAAY,CAAC,E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AE,MAAM,CAAC;CACnB"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/runtime/types.ts"],
4
- "sourcesContent": ["/**\n * @fileoverview Type definitions for OakScriptJS runtime\n * These types define the adapter interfaces and context structure for the runtime system\n * @module runtime/types\n */\n\nimport type { FillGradient } from '../types/metadata.js';\n\n/**\n * Handle returned by ChartAdapter.addSeries\n * Represents a series on the chart with ability to update data\n */\nexport interface SeriesHandle {\n /** Set the data for this series */\n setData(data: Array<{ time: number; value: number; color?: string }>): void;\n}\n\n/**\n * Options for creating a series on the chart\n */\nexport interface SeriesOptions {\n /** Series color */\n color?: string;\n /** Line width */\n lineWidth?: number;\n /** Line style (0 = solid, 1 = dotted, 2 = dashed, etc.) */\n lineStyle?: number;\n /** Price scale ID */\n priceScaleId?: string;\n /** Pane index */\n pane?: number;\n}\n\n/**\n * Chart adapter interface\n * Implementations translate library calls into chart library operations\n */\nexport interface ChartAdapter {\n /** Add a new series to the chart */\n addSeries(type: string, options?: SeriesOptions): SeriesHandle;\n /** Remove a series from the chart */\n removeSeries(series: SeriesHandle): void;\n /** Get the main price series (optional, may return undefined) */\n getMainSeries?(): SeriesHandle | undefined;\n /** Create a new pane and return its index (optional) */\n createPane?(): number;\n}\n\n/**\n * Condition on other inputs, as plain data (PineScript `active = <expression>`):\n * - `'showMa'`: the bool input `showMa` is true\n * - `{ input: 'maType', eq: 'SMA' }` / `{ input: 'maType', ne: 'None' }`: the value of an input is / is not a value\n * (strict equality; without `eq` and `ne`: the input is true)\n * - `{ not: c }`, `{ any: [c1, c2] }` (or), `{ all: [c1, c2] }` (and)\n *\n * Evaluated by `isInputActive()`.\n */\nexport type InputCondition =\n | string\n | { input: string; eq?: unknown; ne?: unknown }\n | { not: InputCondition }\n | { any: InputCondition[] }\n | { all: InputCondition[] };\n\n/**\n * Configuration for registering an input\n */\nexport interface InputConfig {\n /** Unique identifier for the input */\n id: string;\n /**\n * Type of input. `timeframe` and `session` values are strings (\"60\", \"1D\", \"0930-1600:23456\";\n * an empty timeframe means the chart timeframe), `time` values are UNIX times in milliseconds. A `text_area`\n * value is a string that can hold several lines.\n */\n type: 'int' | 'float' | 'bool' | 'string' | 'text_area' | 'source' | 'color' | 'timeframe' | 'session' | 'time' | 'symbol';\n /** Default value */\n defval: unknown;\n /** Display title */\n title?: string;\n /** Minimum value (for numeric inputs) */\n min?: number;\n /** Maximum value (for numeric inputs) */\n max?: number;\n /** Step size (for numeric inputs) */\n step?: number;\n /** Options for dropdown selection (for string, timeframe and session inputs) */\n options?: string[];\n /** Settings group header (PineScript `group`) */\n group?: string;\n /** Inputs with the same `inline` id are shown on one line (PineScript `inline`) */\n inline?: string;\n /** Info tooltip of the input (PineScript `tooltip`) */\n tooltip?: string;\n /** Ask for the value when the script is added to a chart (PineScript `confirm`) */\n confirm?: boolean;\n /**\n * Where the input value is shown (PineScript `display`); not set means the PineScript default: 'none' for\n * bool, color, time and text_area inputs, 'all' for the others\n */\n display?: 'all' | 'none' | 'data_window' | 'status_line';\n /**\n * Whether the input can be edited (PineScript `active`): an inactive input is shown greyed out in the settings.\n * UI only: an inactive input still gives its value to the script. Not set means always active. A boolean is the\n * value for the current inputs; an `InputCondition` names the inputs it depends on, so a host can apply it\n * without running the script (see `isInputActive()`)\n */\n active?: boolean | InputCondition;\n}\n\n/**\n * Configuration for plot outputs in generated indicators\n */\nexport interface PlotConfig {\n /** Unique identifier for the plot */\n id: string;\n /** Display title */\n title: string;\n /** Plot color */\n color: string;\n /** Line width in pixels */\n lineWidth?: number;\n /** Plot style */\n style?: 'line' | 'stepline' | 'histogram' | 'area' | 'circles' | 'columns' | 'cross' | 'areabr' | 'steplinebr' | 'linebr' | 'stepline_diamond';\n /** Whether the plot is visible (can be boolean or expression string for dynamic visibility) */\n visible?: boolean | string;\n /** Display mode: 'all', 'none', 'data_window', 'status_line', 'pane' */\n display?: 'all' | 'none' | 'data_window' | 'status_line' | 'pane';\n /** Offset in bars (positive = future, negative = past) */\n offset?: number;\n /** Histogram base value */\n histbase?: number;\n /** Line style (PineScript `linestyle`); default solid. A constant or an input value, not per bar */\n linestyle?: 'solid' | 'dashed' | 'dotted';\n /** Drawn on the main chart pane even when the script is not an overlay (PineScript `force_overlay`); default false */\n forceOverlay?: boolean;\n}\n\n/**\n * Configuration of a PineScript `plotarrow()` declaration: an up arrow (below the bar) for a positive value, a down\n * arrow (above the bar) for a negative value, nothing for 0 / na. The arrow height scales with the absolute value\n * between `minheight` and `maxheight` pixels (drawn by the renderer).\n */\nexport interface ArrowConfig {\n /** Unique identifier (key of the arrow data in the result) */\n id: string;\n /** Display title */\n title?: string;\n /** Color of the up arrows (PineScript default #00FF00) */\n colorup: string;\n /** Color of the down arrows (PineScript default #FF0000) */\n colordown: string;\n /** Minimal arrow height in pixels (PineScript default 5) */\n minheight: number;\n /** Maximal arrow height in pixels (PineScript default 100) */\n maxheight: number;\n /** Offset in bars (applied to the emitted arrow times) */\n offset?: number;\n /** Display mode */\n display?: 'all' | 'none' | 'data_window' | 'status_line' | 'pane';\n /** Drawn on the main chart pane even when the script is not an overlay (PineScript `force_overlay`); default false */\n forceOverlay?: boolean;\n}\n\n/**\n * Configuration of a PineScript `plotcandle()` (kind 'candle') or `plotbar()` (kind 'bar') declaration. The candles\n * are in `result.plotCandles[id]`, the bars in `result.plotBars[id]`.\n */\nexport interface CandleConfig {\n /** Unique identifier (key of the data in the result) */\n id: string;\n /** 'candle' for plotcandle, 'bar' for plotbar */\n kind: 'candle' | 'bar';\n /** Display title */\n title?: string;\n /** Static body colour (plotcandle) or bar colour (plotbar) */\n color?: string;\n /** Static wick colour (plotcandle only) */\n wickColor?: string;\n /** Static border colour (plotcandle only) */\n borderColor?: string;\n /** Display mode */\n display?: 'all' | 'none' | 'data_window' | 'status_line' | 'pane';\n /** Drawn on the main chart pane even when the script is not an overlay (PineScript `force_overlay`); default false */\n forceOverlay?: boolean;\n}\n\n/**\n * Configuration for horizontal line outputs in generated indicators\n * Matches PineScript hline() function parameters\n */\nexport interface HLineConfig {\n /** Unique identifier for the hline */\n id: string;\n /** Price level for the horizontal line */\n price: number;\n /** Display title */\n title?: string;\n /** Line color */\n color?: string;\n /** Line style: solid, dashed, or dotted (PineScript default: dashed) */\n linestyle?: 'solid' | 'dashed' | 'dotted';\n /** Line width in pixels */\n linewidth?: number;\n /** Display mode */\n display?: 'all' | 'none' | 'data_window' | 'status_line' | 'pane';\n}\n\n/**\n * Configuration for fill between plots or hlines in generated indicators\n * Matches PineScript fill() function parameters\n */\nexport interface FillConfig {\n /** Unique identifier for the fill */\n id: string;\n /** ID of the first plot or hline */\n plot1: string;\n /** ID of the second plot or hline */\n plot2: string;\n /** Fill color */\n color?: string;\n /** Per-bar fill colors (overrides static color) */\n colors?: string[];\n /** Gradient fill (PineScript `fill(hline1, hline2, top_value, bottom_value, top_color, bottom_color)`) */\n gradient?: FillGradient;\n /** Display title */\n title?: string;\n /** Whether the fill is visible (can be boolean or expression string for dynamic visibility) */\n visible?: boolean | string;\n}\n\n/**\n * Configuration for plotshape/plotchar outputs in generated indicators\n * Matches PineScript plotshape()/plotchar() declarative parameters\n */\nexport interface ShapeConfig {\n /** Unique identifier for the shape declaration */\n id: string;\n /** 'shape' for plotshape, 'char' for plotchar */\n kind: 'shape' | 'char';\n /** Display title */\n title?: string;\n /** Shape style (plotshape only) */\n style?: 'xcross' | 'cross' | 'triangleup' | 'triangledown' | 'flag' | 'circle' | 'arrowup' | 'arrowdown' | 'labelup' | 'labeldown' | 'square' | 'diamond';\n /** Character (plotchar only) */\n char?: string;\n /** Marker location relative to the bar */\n location: 'abovebar' | 'belowbar' | 'top' | 'bottom' | 'absolute';\n /** Marker color */\n color?: string;\n /** Text shown near the marker */\n text?: string;\n /** Text color */\n textcolor?: string;\n /** Marker size */\n size?: 'auto' | 'tiny' | 'small' | 'normal' | 'large' | 'huge';\n /** Offset in bars (applied to the emitted marker times) */\n offset?: number;\n /** Drawn on the main chart pane even when the script is not an overlay (PineScript `force_overlay`); default false */\n forceOverlay?: boolean;\n}\n\n/**\n * Configuration for bgcolor/barcolor outputs in generated indicators\n */\nexport interface BarColorConfig {\n /** Unique identifier */\n id: string;\n /** 'bgcolor' or 'barcolor' */\n kind: 'bgcolor' | 'barcolor';\n /** Display title */\n title?: string;\n /** Offset in bars (bgcolor only, already baked into emitted data) */\n offset?: number;\n /** bgcolor only: drawn on the main chart pane even when the script is not an overlay (PineScript\n * `force_overlay`); default false */\n forceOverlay?: boolean;\n}\n\n/**\n * Options for numeric inputs\n */\nexport interface InputOptions {\n /** Minimum value */\n min?: number;\n /** Maximum value */\n max?: number;\n /** Step size */\n step?: number;\n}\n\n/**\n * Input adapter interface\n * Implementations handle input registration and value management\n */\nexport interface InputAdapter {\n /** Register an input, returns current value (possibly user-updated) */\n registerInput(config: InputConfig): unknown;\n /** Get current value of an input */\n getValue(id: string): unknown;\n /** Set value of an input */\n setValue(id: string, value: unknown): void;\n /** Register callback for input changes */\n onInputChange(callback: (id: string, value: unknown) => void): void;\n}\n\n/**\n * OHLCV data structure\n * Provides access to price and volume time series\n */\nexport interface OhlcvData {\n /** Timestamps for each bar */\n time: number[];\n /** Open prices */\n open: number[];\n /** High prices */\n high: number[];\n /** Low prices */\n low: number[];\n /** Close prices */\n close: number[];\n /** Volume data */\n volume: number[];\n}\n\n/**\n * Global context object for OakScriptJS runtime\n * Must be set by host application before calling any indicator calculate function\n */\nexport interface OakScriptContext {\n /** Chart adapter for plot operations */\n chart: ChartAdapter;\n /** Input adapter for managing indicator inputs */\n inputs: InputAdapter;\n /** OHLCV data for the current symbol/timeframe */\n ohlcv: OhlcvData;\n /** Current bar index (typically the last bar) */\n bar_index: number;\n}\n"],
4
+ "sourcesContent": ["/**\n * @fileoverview Type definitions for OakScriptJS runtime\n * These types define the adapter interfaces and context structure for the runtime system\n * @module runtime/types\n */\n\nimport type { FillGradient } from '../types/metadata.js';\n\n/**\n * Handle returned by ChartAdapter.addSeries\n * Represents a series on the chart with ability to update data\n */\nexport interface SeriesHandle {\n /** Set the data for this series */\n setData(data: Array<{ time: number; value: number; color?: string }>): void;\n}\n\n/**\n * Options for creating a series on the chart\n */\nexport interface SeriesOptions {\n /** Series color */\n color?: string;\n /** Line width */\n lineWidth?: number;\n /** Line style (0 = solid, 1 = dotted, 2 = dashed, etc.) */\n lineStyle?: number;\n /** Price scale ID */\n priceScaleId?: string;\n /** Pane index */\n pane?: number;\n}\n\n/**\n * Chart adapter interface\n * Implementations translate library calls into chart library operations\n */\nexport interface ChartAdapter {\n /** Add a new series to the chart */\n addSeries(type: string, options?: SeriesOptions): SeriesHandle;\n /** Remove a series from the chart */\n removeSeries(series: SeriesHandle): void;\n /** Get the main price series (optional, may return undefined) */\n getMainSeries?(): SeriesHandle | undefined;\n /** Create a new pane and return its index (optional) */\n createPane?(): number;\n}\n\n/**\n * Condition on other inputs, as plain data (PineScript `active = <expression>`):\n * - `'showMa'`: the bool input `showMa` is true\n * - `{ input: 'maType', eq: 'SMA' }` / `{ input: 'maType', ne: 'None' }`: the value of an input is / is not a value\n * (strict equality; without `eq` and `ne`: the input is true)\n * - `{ not: c }`, `{ any: [c1, c2] }` (or), `{ all: [c1, c2] }` (and)\n *\n * Evaluated by `isInputActive()`.\n */\nexport type InputCondition =\n | string\n | { input: string; eq?: unknown; ne?: unknown }\n | { not: InputCondition }\n | { any: InputCondition[] }\n | { all: InputCondition[] };\n\n/**\n * Configuration for registering an input\n */\nexport interface InputConfig {\n /** Unique identifier for the input */\n id: string;\n /**\n * Type of input. `timeframe` and `session` values are strings (\"60\", \"1D\", \"0930-1600:23456\";\n * an empty timeframe means the chart timeframe), `time` values are UNIX times in milliseconds. A `text_area`\n * value is a string that can hold several lines.\n */\n type: 'int' | 'float' | 'bool' | 'string' | 'text_area' | 'source' | 'color' | 'timeframe' | 'session' | 'time' | 'symbol';\n /** Default value */\n defval: unknown;\n /** Display title */\n title?: string;\n /** Minimum value (for numeric inputs) */\n min?: number;\n /** Maximum value (for numeric inputs) */\n max?: number;\n /** Step size (for numeric inputs) */\n step?: number;\n /** Options for dropdown selection (for string, timeframe and session inputs) */\n options?: string[];\n /** Settings group header (PineScript `group`) */\n group?: string;\n /** Inputs with the same `inline` id are shown on one line (PineScript `inline`) */\n inline?: string;\n /** Info tooltip of the input (PineScript `tooltip`) */\n tooltip?: string;\n /** Ask for the value when the script is added to a chart (PineScript `confirm`) */\n confirm?: boolean;\n /**\n * Where the input value is shown (PineScript `display`); not set means the PineScript default: 'none' for\n * bool, color, time and text_area inputs, 'all' for the others\n */\n display?: 'all' | 'none' | 'data_window' | 'status_line';\n /**\n * Whether the input can be edited (PineScript `active`): an inactive input is shown greyed out in the settings.\n * UI only: an inactive input still gives its value to the script. Not set means always active. A boolean is the\n * value for the current inputs; an `InputCondition` names the inputs it depends on, so a host can apply it\n * without running the script (see `isInputActive()`)\n */\n active?: boolean | InputCondition;\n}\n\n/**\n * Configuration for plot outputs in generated indicators\n */\nexport interface PlotConfig {\n /** Unique identifier for the plot */\n id: string;\n /** Display title */\n title: string;\n /** Plot color */\n color: string;\n /** Line width in pixels */\n lineWidth?: number;\n /** Plot style */\n style?: 'line' | 'stepline' | 'histogram' | 'area' | 'circles' | 'columns' | 'cross' | 'areabr' | 'steplinebr' | 'linebr' | 'stepline_diamond';\n /** Whether the plot is visible (can be boolean or expression string for dynamic visibility) */\n visible?: boolean | string;\n /** Display mode: 'all', 'none', 'data_window', 'status_line', 'pane' */\n display?: 'all' | 'none' | 'data_window' | 'status_line' | 'pane';\n /** Offset in bars (positive = future, negative = past) */\n offset?: number;\n /** Histogram base value */\n histbase?: number;\n /** Line style (PineScript `linestyle`); default solid. A constant or an input value, not per bar */\n linestyle?: 'solid' | 'dashed' | 'dotted';\n /** Drawn on the main chart pane even when the script is not an overlay (PineScript `force_overlay`); default false */\n forceOverlay?: boolean;\n /**\n * False: the output is not listed in the Style settings of the study (PineScript `editable = false`); it is still\n * drawn. Default true\n */\n editable?: boolean;\n}\n\n/**\n * Configuration of a PineScript `plotarrow()` declaration: an up arrow (below the bar) for a positive value, a down\n * arrow (above the bar) for a negative value, nothing for 0 / na. The arrow height scales with the absolute value\n * between `minheight` and `maxheight` pixels (drawn by the renderer).\n */\nexport interface ArrowConfig {\n /** Unique identifier (key of the arrow data in the result) */\n id: string;\n /** Display title */\n title?: string;\n /** Color of the up arrows (PineScript default #00FF00) */\n colorup: string;\n /** Color of the down arrows (PineScript default #FF0000) */\n colordown: string;\n /** Minimal arrow height in pixels (PineScript default 5) */\n minheight: number;\n /** Maximal arrow height in pixels (PineScript default 100) */\n maxheight: number;\n /** Offset in bars (applied to the emitted arrow times) */\n offset?: number;\n /** Display mode */\n display?: 'all' | 'none' | 'data_window' | 'status_line' | 'pane';\n /** Drawn on the main chart pane even when the script is not an overlay (PineScript `force_overlay`); default false */\n forceOverlay?: boolean;\n /**\n * False: the output is not listed in the Style settings of the study (PineScript `editable = false`); it is still\n * drawn. Default true\n */\n editable?: boolean;\n}\n\n/**\n * Configuration of a PineScript `plotcandle()` (kind 'candle') or `plotbar()` (kind 'bar') declaration. The candles\n * are in `result.plotCandles[id]`, the bars in `result.plotBars[id]`.\n */\nexport interface CandleConfig {\n /** Unique identifier (key of the data in the result) */\n id: string;\n /** 'candle' for plotcandle, 'bar' for plotbar */\n kind: 'candle' | 'bar';\n /** Display title */\n title?: string;\n /** Static body colour (plotcandle) or bar colour (plotbar) */\n color?: string;\n /** Static wick colour (plotcandle only) */\n wickColor?: string;\n /** Static border colour (plotcandle only) */\n borderColor?: string;\n /** Display mode */\n display?: 'all' | 'none' | 'data_window' | 'status_line' | 'pane';\n /** Drawn on the main chart pane even when the script is not an overlay (PineScript `force_overlay`); default false */\n forceOverlay?: boolean;\n /**\n * False: the output is not listed in the Style settings of the study (PineScript `editable = false`); it is still\n * drawn. Default true\n */\n editable?: boolean;\n /**\n * The colours the study chooses from per bar (the PineScript palette of the body / wick / border colour), when they\n * are a fixed set: a user can change each of them. Unset: a single colour (`color` / `wickColor` / `borderColor`)\n * or colours computed per bar\n */\n palettes?: { color?: string[]; wickColor?: string[]; borderColor?: string[] };\n}\n\n/**\n * Configuration for horizontal line outputs in generated indicators\n * Matches PineScript hline() function parameters\n */\nexport interface HLineConfig {\n /** Unique identifier for the hline */\n id: string;\n /** Price level for the horizontal line */\n price: number;\n /** Display title */\n title?: string;\n /** Line color */\n color?: string;\n /** Line style: solid, dashed, or dotted (PineScript default: dashed) */\n linestyle?: 'solid' | 'dashed' | 'dotted';\n /** Line width in pixels */\n linewidth?: number;\n /** Display mode */\n display?: 'all' | 'none' | 'data_window' | 'status_line' | 'pane';\n /**\n * False: the output is not listed in the Style settings of the study (PineScript `editable = false`); it is still\n * drawn. Default true\n */\n editable?: boolean;\n}\n\n/**\n * Configuration for fill between plots or hlines in generated indicators\n * Matches PineScript fill() function parameters\n */\nexport interface FillConfig {\n /** Unique identifier for the fill */\n id: string;\n /** ID of the first plot or hline */\n plot1: string;\n /** ID of the second plot or hline */\n plot2: string;\n /** Fill color */\n color?: string;\n /** Per-bar fill colors (overrides static color) */\n colors?: string[];\n /** Gradient fill (PineScript `fill(hline1, hline2, top_value, bottom_value, top_color, bottom_color)`) */\n gradient?: FillGradient;\n /** Display title */\n title?: string;\n /** Whether the fill is visible (can be boolean or expression string for dynamic visibility) */\n visible?: boolean | string;\n /**\n * False: the output is not listed in the Style settings of the study (PineScript `editable = false`); it is still\n * drawn. Default true\n */\n editable?: boolean;\n /** Gradient fill: its colour at the top value when it is the same on every bar */\n topColor?: string;\n /** Gradient fill: its colour at the bottom value when it is the same on every bar */\n bottomColor?: string;\n /**\n * The colours the fill chooses from per bar when they are a fixed set (PineScript palette): a user can change each\n * of them. Unset: `color` (one colour) or colours computed per bar\n */\n palette?: string[];\n}\n\n/**\n * Configuration for plotshape/plotchar outputs in generated indicators\n * Matches PineScript plotshape()/plotchar() declarative parameters\n */\nexport interface ShapeConfig {\n /** Unique identifier for the shape declaration */\n id: string;\n /** 'shape' for plotshape, 'char' for plotchar */\n kind: 'shape' | 'char';\n /** Display title */\n title?: string;\n /** Shape style (plotshape only) */\n style?: 'xcross' | 'cross' | 'triangleup' | 'triangledown' | 'flag' | 'circle' | 'arrowup' | 'arrowdown' | 'labelup' | 'labeldown' | 'square' | 'diamond';\n /** Character (plotchar only) */\n char?: string;\n /** Marker location relative to the bar */\n location: 'abovebar' | 'belowbar' | 'top' | 'bottom' | 'absolute';\n /** Marker color */\n color?: string;\n /** Text shown near the marker */\n text?: string;\n /** Text color */\n textcolor?: string;\n /** Marker size */\n size?: 'auto' | 'tiny' | 'small' | 'normal' | 'large' | 'huge';\n /** Offset in bars (applied to the emitted marker times) */\n offset?: number;\n /** Drawn on the main chart pane even when the script is not an overlay (PineScript `force_overlay`); default false */\n forceOverlay?: boolean;\n /**\n * False: the output is not listed in the Style settings of the study (PineScript `editable = false`); it is still\n * drawn. Default true\n */\n editable?: boolean;\n /**\n * The colours the output chooses from per bar when they are a fixed set (PineScript palette): a user can change\n * each of them. Unset: `color` (one colour) or colours computed per bar\n */\n palette?: string[];\n}\n\n/**\n * Configuration for bgcolor/barcolor outputs in generated indicators\n */\nexport interface BarColorConfig {\n /** Unique identifier */\n id: string;\n /** 'bgcolor' or 'barcolor' */\n kind: 'bgcolor' | 'barcolor';\n /** Display title */\n title?: string;\n /** Offset in bars (bgcolor only, already baked into emitted data) */\n offset?: number;\n /** bgcolor only: drawn on the main chart pane even when the script is not an overlay (PineScript\n * `force_overlay`); default false */\n forceOverlay?: boolean;\n /**\n * False: the output is not listed in the Style settings of the study (PineScript `editable = false`); it is still\n * drawn. Default true\n */\n editable?: boolean;\n /**\n * The colours the output chooses from per bar (PineScript palette): a user can change each of them. A colour given\n * as a constant is a palette of one colour. Unset: colours computed per bar\n */\n palette?: string[];\n /**\n * Where the output comes among the plot / shape / character / arrow / candle outputs (`outputs` of the script): it\n * was declared after the first `outputIndex` of them. The Style settings list it there. Unset: after all of them\n */\n outputIndex?: number;\n}\n\n/**\n * Options for numeric inputs\n */\nexport interface InputOptions {\n /** Minimum value */\n min?: number;\n /** Maximum value */\n max?: number;\n /** Step size */\n step?: number;\n}\n\n/**\n * Input adapter interface\n * Implementations handle input registration and value management\n */\nexport interface InputAdapter {\n /** Register an input, returns current value (possibly user-updated) */\n registerInput(config: InputConfig): unknown;\n /** Get current value of an input */\n getValue(id: string): unknown;\n /** Set value of an input */\n setValue(id: string, value: unknown): void;\n /** Register callback for input changes */\n onInputChange(callback: (id: string, value: unknown) => void): void;\n}\n\n/**\n * OHLCV data structure\n * Provides access to price and volume time series\n */\nexport interface OhlcvData {\n /** Timestamps for each bar */\n time: number[];\n /** Open prices */\n open: number[];\n /** High prices */\n high: number[];\n /** Low prices */\n low: number[];\n /** Close prices */\n close: number[];\n /** Volume data */\n volume: number[];\n}\n\n/**\n * Global context object for OakScriptJS runtime\n * Must be set by host application before calling any indicator calculate function\n */\nexport interface OakScriptContext {\n /** Chart adapter for plot operations */\n chart: ChartAdapter;\n /** Input adapter for managing indicator inputs */\n inputs: InputAdapter;\n /** OHLCV data for the current symbol/timeframe */\n ohlcv: OhlcvData;\n /** Current bar index (typically the last bar) */\n bar_index: number;\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }