oakscriptjs 0.15.3 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/check/format.d.ts.map +1 -1
- package/dist/cjs/check/format.js +5 -0
- package/dist/cjs/check/format.js.map +2 -2
- package/dist/cjs/check/harness.d.ts +24 -0
- package/dist/cjs/check/harness.d.ts.map +1 -1
- package/dist/cjs/check/harness.js +33 -0
- package/dist/cjs/check/harness.js.map +2 -2
- package/dist/cjs/check/index.d.ts +9 -0
- package/dist/cjs/check/index.d.ts.map +1 -1
- package/dist/cjs/check/index.js +7 -0
- package/dist/cjs/check/index.js.map +2 -2
- package/dist/cjs/color/index.d.ts.map +1 -1
- package/dist/cjs/color/index.js +19 -2
- package/dist/cjs/color/index.js.map +2 -2
- package/dist/cjs/color/parse.d.ts +8 -6
- package/dist/cjs/color/parse.d.ts.map +1 -1
- package/dist/cjs/color/parse.js +15 -2
- package/dist/cjs/color/parse.js.map +2 -2
- package/dist/cjs/drawing/registry.d.ts +68 -0
- package/dist/cjs/drawing/registry.d.ts.map +1 -1
- package/dist/cjs/drawing/registry.js +99 -9
- package/dist/cjs/drawing/registry.js.map +2 -2
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/runtime/series.d.ts +16 -0
- package/dist/cjs/runtime/series.d.ts.map +1 -1
- package/dist/cjs/runtime/series.js +19 -2
- package/dist/cjs/runtime/series.js.map +2 -2
- package/dist/cjs/script/closure-writes.d.ts +16 -0
- package/dist/cjs/script/closure-writes.d.ts.map +1 -0
- package/dist/cjs/script/closure-writes.js +435 -0
- package/dist/cjs/script/closure-writes.js.map +7 -0
- package/dist/cjs/script/globals.d.ts +2 -0
- package/dist/cjs/script/globals.d.ts.map +1 -1
- package/dist/cjs/script/globals.js.map +1 -1
- package/dist/cjs/script/incremental.d.ts +140 -0
- package/dist/cjs/script/incremental.d.ts.map +1 -0
- package/dist/cjs/script/incremental.js +142 -0
- package/dist/cjs/script/incremental.js.map +7 -0
- package/dist/cjs/script/index.d.ts +116 -31
- package/dist/cjs/script/index.d.ts.map +1 -1
- package/dist/cjs/script/index.js +471 -25
- package/dist/cjs/script/index.js.map +3 -3
- package/dist/cjs/str/numberformat.d.ts.map +1 -1
- package/dist/cjs/str/numberformat.js +23 -0
- package/dist/cjs/str/numberformat.js.map +2 -2
- package/dist/cjs/strategy/index.d.ts +8 -0
- package/dist/cjs/strategy/index.d.ts.map +1 -1
- package/dist/cjs/strategy/index.js.map +1 -1
- package/dist/cjs/ta/running-sum.d.ts.map +1 -1
- package/dist/cjs/ta/running-sum.js +72 -3
- package/dist/cjs/ta/running-sum.js.map +2 -2
- package/dist/cjs/ta/step.d.ts +476 -0
- package/dist/cjs/ta/step.d.ts.map +1 -0
- package/dist/cjs/ta/step.js +1000 -0
- package/dist/cjs/ta/step.js.map +7 -0
- package/dist/cjs/ta-series.d.ts +1 -1
- package/dist/cjs/ta-series.js +3 -3
- package/dist/cjs/ta-series.js.map +1 -1
- package/dist/esm/check/format.d.ts.map +1 -1
- package/dist/esm/check/format.js +5 -0
- package/dist/esm/check/format.js.map +1 -1
- package/dist/esm/check/harness.d.ts +24 -0
- package/dist/esm/check/harness.d.ts.map +1 -1
- package/dist/esm/check/harness.js +40 -6
- package/dist/esm/check/harness.js.map +1 -1
- package/dist/esm/check/index.d.ts +9 -0
- package/dist/esm/check/index.d.ts.map +1 -1
- package/dist/esm/check/index.js +11 -1
- package/dist/esm/check/index.js.map +1 -1
- package/dist/esm/color/index.d.ts.map +1 -1
- package/dist/esm/color/index.js +23 -3
- package/dist/esm/color/index.js.map +1 -1
- package/dist/esm/color/parse.d.ts +8 -6
- package/dist/esm/color/parse.d.ts.map +1 -1
- package/dist/esm/color/parse.js +19 -2
- package/dist/esm/color/parse.js.map +1 -1
- package/dist/esm/drawing/registry.d.ts +68 -0
- package/dist/esm/drawing/registry.d.ts.map +1 -1
- package/dist/esm/drawing/registry.js +156 -10
- package/dist/esm/drawing/registry.js.map +1 -1
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +6 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/runtime/series.d.ts +16 -0
- package/dist/esm/runtime/series.d.ts.map +1 -1
- package/dist/esm/runtime/series.js +21 -1
- package/dist/esm/runtime/series.js.map +1 -1
- package/dist/esm/script/closure-writes.d.ts +16 -0
- package/dist/esm/script/closure-writes.d.ts.map +1 -0
- package/dist/esm/script/closure-writes.js +323 -0
- package/dist/esm/script/closure-writes.js.map +1 -0
- package/dist/esm/script/globals.d.ts +2 -0
- package/dist/esm/script/globals.d.ts.map +1 -1
- package/dist/esm/script/globals.js.map +1 -1
- package/dist/esm/script/incremental.d.ts +140 -0
- package/dist/esm/script/incremental.d.ts.map +1 -0
- package/dist/esm/script/incremental.js +173 -0
- package/dist/esm/script/incremental.js.map +1 -0
- package/dist/esm/script/index.d.ts +116 -31
- package/dist/esm/script/index.d.ts.map +1 -1
- package/dist/esm/script/index.js +561 -24
- package/dist/esm/script/index.js.map +1 -1
- package/dist/esm/str/numberformat.d.ts.map +1 -1
- package/dist/esm/str/numberformat.js +30 -0
- package/dist/esm/str/numberformat.js.map +1 -1
- package/dist/esm/strategy/index.d.ts +8 -0
- package/dist/esm/strategy/index.d.ts.map +1 -1
- package/dist/esm/ta/running-sum.d.ts.map +1 -1
- package/dist/esm/ta/running-sum.js +79 -4
- package/dist/esm/ta/running-sum.js.map +1 -1
- package/dist/esm/ta/step.d.ts +476 -0
- package/dist/esm/ta/step.d.ts.map +1 -0
- package/dist/esm/ta/step.js +1089 -0
- package/dist/esm/ta/step.js.map +1 -0
- package/dist/esm/ta-series.d.ts +1 -1
- package/dist/esm/ta-series.js +4 -4
- package/package.json +1 -1
- package/skills/oakscript/SKILL.md +2 -2
- package/skills/oakscript/reference/check.md +5 -0
- package/skills/oakscript/reference/errors.md +0 -1
- package/skills/oakscript/reference/pine-differences.md +1 -2
- package/skills/oakscript/reference/plotting.md +5 -7
- package/skills/oakscript/reference/script-structure.md +6 -0
- package/src/check/format.ts +7 -0
- package/src/check/harness.ts +57 -0
- package/src/check/index.ts +16 -0
- package/src/color/index.ts +22 -3
- package/src/color/parse.ts +28 -3
- package/src/drawing/registry.ts +172 -10
- package/src/index.ts +9 -2
- package/src/runtime/series.ts +33 -1
- package/src/script/closure-writes.ts +279 -0
- package/src/script/globals.ts +2 -0
- package/src/script/incremental.ts +246 -0
- package/src/script/index.ts +695 -26
- package/src/str/numberformat.ts +29 -0
- package/src/strategy/index.ts +8 -0
- package/src/ta/running-sum.ts +78 -3
- package/src/ta/step.ts +1145 -0
- package/src/ta-series.ts +4 -4
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/script/closure-writes.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * The variables of the script that an eachBar() callback changes outside itself (#196): an incremental run cannot put\n * them back to their value at the last confirmed bar, so a script with such a write is calculated in full.\n *\n * Read from the callback's source text (`fn.toString()`), with a tokenizer (strings, template literals, comments and\n * regular expressions skipped). A write is an assignment (`x = `, `x += `, `x++`...) or a change of a member\n * (`x.y = `, `x[i] = `, `x.push(...)` and the other mutating methods) whose root name is not declared inside the\n * callback. The `.value` of a persist() box (`dir.value = 1`) is not a write. Conservative: a name declared anywhere\n * inside the callback counts as its own (a shadowed outer write is missed); functions called by the callback are not\n * read.\n *\n * @internal\n */\n\nconst MUTATORS = new Set([\n 'push', 'pop', 'shift', 'unshift', 'splice', 'sort', 'reverse', 'fill', 'copyWithin',\n 'set', 'delete', 'clear', 'add',\n]);\n\nconst KEYWORDS = new Set([\n 'break', 'case', 'catch', 'class', 'const', 'continue', 'debugger', 'default', 'delete', 'do', 'else', 'export',\n 'extends', 'finally', 'for', 'function', 'if', 'import', 'in', 'instanceof', 'let', 'new', 'return', 'super',\n 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'yield', 'await', 'of', 'true', 'false',\n 'null', 'undefined', 'async', 'static', 'get',\n]);\n\ntype Token = { kind: 'id' | 'punct' | 'num' | 'str'; text: string };\n\n/** Tokens of a JavaScript source: names, numbers, punctuators; strings, template literals, comments and regexes skipped. */\nfunction tokenize(src: string): Token[] {\n const out: Token[] = [];\n let i = 0;\n const n = src.length;\n const regexAllowed = (): boolean => {\n const last = out[out.length - 1];\n if (!last) return true;\n if (last.kind === 'num' || last.kind === 'str') return false;\n if (last.kind === 'id') return KEYWORDS.has(last.text) && !['this', 'super', 'true', 'false', 'null', 'undefined'].includes(last.text);\n return ![')', ']', '}'].includes(last.text);\n };\n while (i < n) {\n const ch = src[i]!;\n if (/\\s/.test(ch)) {\n i++;\n } else if (ch === '/' && src[i + 1] === '/') {\n while (i < n && src[i] !== '\\n') i++;\n } else if (ch === '/' && src[i + 1] === '*') {\n i = src.indexOf('*/', i + 2);\n i = i < 0 ? n : i + 2;\n } else if (ch === '\"' || ch === \"'\") {\n i++;\n while (i < n && src[i] !== ch) i += src[i] === '\\\\' ? 2 : 1;\n i++;\n out.push({ kind: 'str', text: '' });\n } else if (ch === '`') {\n // a template literal: its ${...} parts are tokenized as code\n i++;\n let depth = 0;\n const inner: string[] = [];\n let part = '';\n while (i < n) {\n if (depth === 0 && src[i] === '\\\\') {\n i += 2;\n continue;\n }\n if (depth === 0 && src[i] === '`') break;\n if (depth === 0 && src[i] === '$' && src[i + 1] === '{') {\n depth = 1;\n i += 2;\n continue;\n }\n if (depth > 0) {\n if (src[i] === '{') depth++;\n if (src[i] === '}' && --depth === 0) {\n inner.push(part);\n part = '';\n i++;\n continue;\n }\n part += src[i];\n }\n i++;\n }\n i++;\n out.push({ kind: 'str', text: '' });\n for (const code of inner) {\n out.push({ kind: 'punct', text: '(' });\n out.push(...tokenize(code));\n out.push({ kind: 'punct', text: ')' });\n }\n } else if (ch === '/' && regexAllowed()) {\n i++;\n let inClass = false;\n while (i < n && (src[i] !== '/' || inClass)) {\n if (src[i] === '\\\\') i++;\n else if (src[i] === '[') inClass = true;\n else if (src[i] === ']') inClass = false;\n i++;\n }\n i++;\n while (i < n && /[a-z]/i.test(src[i]!)) i++;\n out.push({ kind: 'str', text: '' });\n } else if (/[A-Za-z_$]/.test(ch)) {\n let j = i + 1;\n while (j < n && /[\\w$]/.test(src[j]!)) j++;\n out.push({ kind: 'id', text: src.slice(i, j) });\n i = j;\n } else if (/[0-9]/.test(ch) || (ch === '.' && /[0-9]/.test(src[i + 1] ?? ''))) {\n let j = i + 1;\n while (j < n && /[\\w.]/.test(src[j]!)) j++;\n out.push({ kind: 'num', text: src.slice(i, j) });\n i = j;\n } else {\n const three = src.slice(i, i + 4);\n const op = ['>>>=', '...', '===', '!==', '**=', '<<=', '>>=', '&&=', '||=', '??=', '>>>', '=>', '==', '!=', '<=', '>=',\n '&&', '||', '??', '?.', '++', '--', '+=', '-=', '*=', '/=', '%=', '&=', '|=', '^=', '**', '<<', '>>']\n .find((o) => three.startsWith(o));\n const text = op ?? ch;\n out.push({ kind: 'punct', text });\n i += text.length;\n }\n }\n return out;\n}\n\nconst ASSIGN = new Set(['=', '+=', '-=', '*=', '/=', '%=', '**=', '<<=', '>>=', '>>>=', '&=', '|=', '^=', '&&=', '||=', '??=']);\n\n/** Names declared inside the tokens: let / const / var / function / class / catch, and parameters of functions. */\nfunction declaredNames(t: Token[]): Set<string> {\n const names = new Set<string>();\n const addUntil = (start: number, stop: (tok: Token, depth: number) => boolean): void => {\n let depth = 0;\n for (let k = start; k < t.length; k++) {\n const tok = t[k]!;\n if (tok.kind === 'punct' && ['(', '[', '{'].includes(tok.text)) depth++;\n if (tok.kind === 'punct' && [')', ']', '}'].includes(tok.text)) {\n if (depth === 0) return;\n depth--;\n }\n if (stop(tok, depth)) return;\n // a default value or a computed key is not a name: skip to the next , at this depth\n if (tok.kind === 'id' && !KEYWORDS.has(tok.text) && t[k - 1]?.text !== '.' && t[k + 1]?.text !== ':') names.add(tok.text);\n }\n };\n for (let k = 0; k < t.length; k++) {\n const tok = t[k]!;\n if (tok.kind !== 'id') continue;\n if (tok.text === 'let' || tok.text === 'const' || tok.text === 'var') {\n // up to the end of the declaration: an = at depth 0 ends a name, a , starts the next one\n let depth = 0;\n let naming = true;\n for (let j = k + 1; j < t.length; j++) {\n const x = t[j]!;\n if (x.kind === 'punct' && ['(', '[', '{'].includes(x.text)) depth++;\n else if (x.kind === 'punct' && [')', ']', '}'].includes(x.text)) {\n if (depth === 0) break;\n depth--;\n } else if (depth === 0 && x.text === ';') break;\n else if (depth === 0 && x.text === '=') naming = false;\n else if (depth === 0 && x.text === ',') naming = true;\n else if (depth === 0 && (x.text === 'of' || x.text === 'in')) break;\n if (naming && x.kind === 'id' && !KEYWORDS.has(x.text) && t[j + 1]?.text !== ':') names.add(x.text);\n if (!naming && depth === 0 && x.kind === 'punct' && x.text === '=>' ) break;\n }\n } else if ((tok.text === 'function' || tok.text === 'class') && t[k + 1]?.kind === 'id') {\n names.add(t[k + 1]!.text);\n } else if (tok.text === 'catch' && t[k + 1]?.text === '(') {\n addUntil(k + 2, () => false);\n }\n }\n // parameters: ( ... ) => or function name ( ... ), and a single name before =>\n for (let k = 0; k < t.length; k++) {\n const tok = t[k]!;\n if (tok.text === '=>' && t[k - 1]?.kind === 'id') names.add(t[k - 1]!.text);\n if (tok.text === '=>' && t[k - 1]?.text === ')') {\n let depth = 0;\n let j = k - 1;\n for (; j >= 0; j--) {\n if (t[j]!.text === ')') depth++;\n else if (t[j]!.text === '(' && --depth === 0) break;\n }\n addUntil(j + 1, () => false);\n }\n if (tok.text === 'function') {\n let j = k + 1;\n if (t[j]?.kind === 'id') j++;\n if (t[j]?.text === '(') addUntil(j + 1, () => false);\n }\n }\n return names;\n}\n\n/** The names outside the function source `src` that it assigns or changes (empty: none found). */\nexport function outerWrites(src: string): string[] {\n const t = tokenize(src);\n const inside = declaredNames(t);\n const found = new Set<string>();\n for (let k = 0; k < t.length; k++) {\n const tok = t[k]!;\n if (tok.kind !== 'id' || KEYWORDS.has(tok.text) || inside.has(tok.text)) continue;\n const before = t[k - 1];\n if (before && (before.text === '.' || before.text === '?.')) continue; // a member, not a root name\n if (t[k + 1]?.text === ':' && (before?.text === '{' || before?.text === ',')) continue; // an object key\n // the member chain after the name: .a.b / [x] / ?.a\n let j = k + 1;\n let members = 0;\n let firstMember = '';\n let lastMember = '';\n const memberList: string[] = [];\n while (j < t.length) {\n if ((t[j]!.text === '.' || t[j]!.text === '?.') && t[j + 1]?.kind === 'id') {\n lastMember = t[j + 1]!.text;\n memberList.push(lastMember);\n if (members === 0) firstMember = lastMember;\n j += 2;\n members++;\n } else if (t[j]!.text === '[') {\n if (members === 0) firstMember = '[]';\n let depth = 0;\n for (; j < t.length; j++) {\n if (t[j]!.text === '[') depth++;\n else if (t[j]!.text === ']' && --depth === 0) break;\n }\n j++;\n members++;\n lastMember = '[]';\n memberList.push('[]');\n } else break;\n }\n const next = t[j];\n // a call of a PineScript namespace (label.delete(l), array.push(zones, x); also through a module object of compiled\n // code, script_1.label.delete(l)): not a change of the namespace; array / map / matrix functions change their first\n // argument\n const ns = members === 1 ? tok.text : members >= 2 ? memberList[members - 2]! : '';\n if (next?.text === '(' && PINE_NAMESPACES.has(ns) && (members === 1 || members >= 2)) {\n if (NAMESPACES.has(ns) && !READS.has(lastMember)) {\n const arg = t[j + 1];\n if (arg?.kind === 'id' && !inside.has(arg.text) && !KEYWORDS.has(arg.text)) {\n const box = t[j + 2]?.text === '.' && t[j + 3]?.text === 'value';\n if (!box) found.add(arg.text);\n }\n }\n continue;\n }\n // the content of a persist() box (dir.value = 1, zones.value.push(x)) is put back by the runtime\n if (firstMember === 'value') continue;\n const written =\n (next && ASSIGN.has(next.text)) ||\n (next && (next.text === '++' || next.text === '--')) ||\n before?.text === '++' ||\n before?.text === '--' ||\n (members > 0 && MUTATORS.has(lastMember) && next?.text === '(');\n if (written) found.add(tok.text);\n }\n return [...found];\n}\n\n/** Namespaces of the PineScript API (their functions do not change the namespace object) */\nconst PINE_NAMESPACES = new Set([\n 'array', 'matrix', 'map', 'label', 'line', 'box', 'table', 'polyline', 'linefill', 'chart', 'str', 'math', 'ta', 'color',\n 'request', 'strategy', 'input', 'timeframe', 'syminfo', 'barstate', 'session', 'callsite', 'taCore', 'taStep',\n 'compare', 'plot', 'time', 'text', 'ticker', 'runtime', 'log', 'alert', 'chartPoint',\n]);\n\n/** PineScript namespaces whose functions change their first argument */\nconst NAMESPACES = new Set(['array', 'matrix', 'map']);\n\n/** Functions of those namespaces that only read their first argument */\nconst READS = new Set([\n 'get', 'size', 'includes', 'indexof', 'lastindexof', 'sum', 'avg', 'max', 'min', 'median', 'mode', 'stdev',\n 'variance', 'range', 'first', 'last', 'slice', 'copy', 'join', 'every', 'some', 'abs', 'binary_search',\n 'binary_search_leftmost', 'binary_search_rightmost', 'covariance', 'percentile_linear_interpolation',\n 'percentile_nearest_rank', 'percentrank', 'standardize', 'sort_indices', 'from', 'new', 'new_float', 'new_int',\n 'new_bool', 'new_string', 'new_color', 'new_line', 'new_label', 'new_box', 'new_table', 'new_linefill',\n 'contains', 'keys', 'values', 'rows', 'columns', 'elements_count', 'row', 'col', 'det', 'inv', 'pinv', 'rank',\n 'trace', 'transpose', 'mult', 'diff', 'pow', 'eigenvalues', 'eigenvectors', 'kron', 'is_square', 'is_zero',\n 'is_binary', 'is_symmetric', 'is_antisymmetric', 'is_diagonal', 'is_antidiagonal', 'is_identity', 'is_triangular',\n 'is_stochastic',\n]);\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA,MAAM,WAAW,oBAAI,IAAI;AAAA,EACvB;AAAA,EAAQ;AAAA,EAAO;AAAA,EAAS;AAAA,EAAW;AAAA,EAAU;AAAA,EAAQ;AAAA,EAAW;AAAA,EAAQ;AAAA,EACxE;AAAA,EAAO;AAAA,EA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AA,EAAO;AAAA,EAAO;AAAA,EAAQ;AAAA,EACvG;AAAA,EAAS;AAAA,EAAa;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAO;AAAA,EAAe;AAAA,EAAgB;AAAA,EAAQ;AAAA,EAAa;AAAA,EACjG;AAAA,EAAa;AAAA,EAAgB;AAAA,EAAoB;AAAA,EAAe;AAAA,EAAmB;AAAA,EAAe;AAAA,EAClG;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -27,7 +27,9 @@
|
|
|
27
27
|
import type * as S from './index.js';
|
|
28
28
|
declare global {
|
|
29
29
|
const executeIntrabar: typeof S.executeIntrabar;
|
|
30
|
+
const createScriptRun: typeof S.createScriptRun;
|
|
30
31
|
const varip: typeof S.varip;
|
|
32
|
+
const persist: typeof S.persist;
|
|
31
33
|
const indicator: typeof S.indicator;
|
|
32
34
|
const fixnan: typeof S.fixnan;
|
|
33
35
|
const fill: typeof S.fill;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.d.ts","sourceRoot":"","sources":["../../../src/script/globals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,KAAK,CAAC,MAAM,YAAY,CAAC;AAErC,OAAO,CAAC,MAAM,CAAC;IACb,MAAM,eAAe,EAAE,OAAO,CAAC,CAAC,eAAe,CAAC;IAChD,MAAM,KAAK,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC;IAC5B,MAAM,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC;IACpC,MAAM,MAAM,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC;IAC9B,MAAM,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;IAC1B,MAAM,SAAS,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC;IACpC,MAAM,QAAQ,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC;IAClC,MAAM,SAAS,EAAE,OAA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AE,OAAO,CAAC,CAAC,IAAI,CAAC;IAC1B,MAAM,KAAK,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC;IAC5B,MAAM,KAAK,EAAE,OAAO,CAAC,CAAC,KAAK,CAAC;IAC5B,MAAM,QAAQ,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC;IAClC,MAAM,UAAU,EAAE,OAAO,CAAC,CAAC,UAAU,CAAC;IACtC,MAAM,OAAO,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC;IAChC,MAAM,aAAa,EAAE,OAAO,CAAC,CAAC,aAAa,CAAC;IAC5C,oGAAoG;IACpG,KAAK,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;IACvB,kEAAkE;IAClE,KAAK,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC;CAChC;AAED,OAAO,EAAE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/script/globals.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * @fileoverview Type declarations of the script globals, for type-checking a script source (plain JavaScript)\n * before it runs. A script body uses every value export of `oakscriptjs/script` but `executeScript` (the host\n * entry) as a global; these declarations give each global its type, so the TypeScript checker reports the\n * mistakes of a script with their line: `close - open` (operators on a Series), a misspelt name (`ta.smaa`), a\n * wrong argument or option, a bad shape or style string.\n *\n * In a project that runs scripts, a `tsconfig.json` next to the scripts, then `npx tsc -p .`:\n *\n * ```json\n * {\n * \"compilerOptions\": {\n * \"allowJs\": true, \"checkJs\": true, \"noEmit\": true, \"strict\": true, \"noImplicitAny\": false,\n * \"target\": \"ES2022\", \"module\": \"ESNext\", \"moduleResolution\": \"bundler\", \"moduleDetection\": \"force\",\n * \"lib\": [\"ES2022\"], \"types\": [\"oakscriptjs/script/globals\"]\n * },\n * \"include\": [\"*.js\"]\n * }\n * ```\n *\n * - `lib` leaves out `DOM`: its `open`, `close` and `alert` are other globals.\n * - `moduleDetection: \"force\"`: each script has its own top-level names (a script has no import or export).\n * - `noImplicitAny: false`: the parameters of a script's own functions have no types (plain JavaScript).\n *\n * @module script/globals\n */\n\nimport type * as S from './index.js';\n\ndeclare global {\n const executeIntrabar: typeof S.executeIntrabar;\n const varip: typeof S.varip;\n const indicator: typeof S.indicator;\n const fixnan: typeof S.fixnan;\n const fill: typeof S.fill;\n const plotshape: typeof S.plotshape;\n const plotchar: typeof S.plotchar;\n const plotarrow: typeof S.plotarrow;\n const bgcolor: typeof S.bgcolor;\n const barcolor: typeof S.barcolor;\n const plotcandle: typeof S.plotcandle;\n const plotbar: typeof S.plotbar;\n const eachBar: typeof S.eachBar;\n const timestamp: typeof S.timestamp;\n const inSession: typeof S.inSession;\n const seriesOf: typeof S.seriesOf;\n const alertcondition: typeof S.alertcondition;\n const holdDrawing: typeof S.holdDrawing;\n const releaseDrawing: typeof S.releaseDrawing;\n const varDrawing: typeof S.varDrawing;\n const StrategyRecorder: typeof S.StrategyRecorder;\n const input: typeof S.input;\n const open: typeof S.open;\n const high: typeof S.high;\n const low: typeof S.low;\n const close: typeof S.close;\n const volume: typeof S.volume;\n const hl2: typeof S.hl2;\n const hlc3: typeof S.hlc3;\n const ohlc4: typeof S.ohlc4;\n const hlcc4: typeof S.hlcc4;\n const ta: typeof S.ta;\n const color: typeof S.color;\n const DEFAULT_OUTPUT_TITLES: typeof S.DEFAULT_OUTPUT_TITLES;\n const plot: typeof S.plot;\n const hline: typeof S.hline;\n const DEFAULT_CANDLE_COLORS: typeof S.DEFAULT_CANDLE_COLORS;\n const strategy: typeof S.strategy;\n const MissingSymbolDataError: typeof S.MissingSymbolDataError;\n const timeframe: typeof S.timeframe;\n const syminfo: typeof S.syminfo;\n const year: typeof S.year;\n const month: typeof S.month;\n const weekofyear: typeof S.weekofyear;\n const dayofmonth: typeof S.dayofmonth;\n const dayofweek: typeof S.dayofweek;\n const hour: typeof S.hour;\n const minute: typeof S.minute;\n const second: typeof S.second;\n const str: typeof S.str;\n const timenow: typeof S.timenow;\n const time: typeof S.time;\n const time_close: typeof S.time_close;\n const time_tradingday: typeof S.time_tradingday;\n const barstate: typeof S.barstate;\n const session: typeof S.session;\n const barmerge: typeof S.barmerge;\n const ticker: typeof S.ticker;\n const request: typeof S.request;\n const line: typeof S.line;\n const label: typeof S.label;\n const box: typeof S.box;\n const linefill: typeof S.linefill;\n const polyline: typeof S.polyline;\n const table: typeof S.table;\n const position: typeof S.position;\n const text: typeof S.text;\n const chart: typeof S.chart;\n const alert: typeof S.alert;\n const Series: typeof S.Series;\n const BarData: typeof S.BarData;\n const na: typeof S.na;\n const nz: typeof S.nz;\n const STRATEGY_DEFAULTS: typeof S.STRATEGY_DEFAULTS;\n const math: typeof S.math;\n const bar_index: typeof S.bar_index;\n const last_bar_index: typeof S.last_bar_index;\n const shape: typeof S.shape;\n const location: typeof S.location;\n const size: typeof S.size;\n const xloc: typeof S.xloc;\n const yloc: typeof S.yloc;\n const extend: typeof S.extend;\n const display: typeof S.display;\n const format: typeof S.format;\n const font: typeof S.font;\n const scale: typeof S.scale;\n const order: typeof S.order;\n const currency: typeof S.currency;\n const adjustment: typeof S.adjustment;\n const compare: typeof S.compare;\n const isInputActive: typeof S.isInputActive;\n /** A Series of the script (`close`, the result of `ta.*`...), for JSDoc types: `@type {Series}`. */\n type Series = S.Series;\n /** The bar handed to an `eachBar()` callback, for JSDoc types. */\n type BarContext = S.BarContext;\n}\n\nexport {};\n"],
|
|
4
|
+
"sourcesContent": ["/**\n * @fileoverview Type declarations of the script globals, for type-checking a script source (plain JavaScript)\n * before it runs. A script body uses every value export of `oakscriptjs/script` but `executeScript` (the host\n * entry) as a global; these declarations give each global its type, so the TypeScript checker reports the\n * mistakes of a script with their line: `close - open` (operators on a Series), a misspelt name (`ta.smaa`), a\n * wrong argument or option, a bad shape or style string.\n *\n * In a project that runs scripts, a `tsconfig.json` next to the scripts, then `npx tsc -p .`:\n *\n * ```json\n * {\n * \"compilerOptions\": {\n * \"allowJs\": true, \"checkJs\": true, \"noEmit\": true, \"strict\": true, \"noImplicitAny\": false,\n * \"target\": \"ES2022\", \"module\": \"ESNext\", \"moduleResolution\": \"bundler\", \"moduleDetection\": \"force\",\n * \"lib\": [\"ES2022\"], \"types\": [\"oakscriptjs/script/globals\"]\n * },\n * \"include\": [\"*.js\"]\n * }\n * ```\n *\n * - `lib` leaves out `DOM`: its `open`, `close` and `alert` are other globals.\n * - `moduleDetection: \"force\"`: each script has its own top-level names (a script has no import or export).\n * - `noImplicitAny: false`: the parameters of a script's own functions have no types (plain JavaScript).\n *\n * @module script/globals\n */\n\nimport type * as S from './index.js';\n\ndeclare global {\n const executeIntrabar: typeof S.executeIntrabar;\n const createScriptRun: typeof S.createScriptRun;\n const varip: typeof S.varip;\n const persist: typeof S.persist;\n const indicator: typeof S.indicator;\n const fixnan: typeof S.fixnan;\n const fill: typeof S.fill;\n const plotshape: typeof S.plotshape;\n const plotchar: typeof S.plotchar;\n const plotarrow: typeof S.plotarrow;\n const bgcolor: typeof S.bgcolor;\n const barcolor: typeof S.barcolor;\n const plotcandle: typeof S.plotcandle;\n const plotbar: typeof S.plotbar;\n const eachBar: typeof S.eachBar;\n const timestamp: typeof S.timestamp;\n const inSession: typeof S.inSession;\n const seriesOf: typeof S.seriesOf;\n const alertcondition: typeof S.alertcondition;\n const holdDrawing: typeof S.holdDrawing;\n const releaseDrawing: typeof S.releaseDrawing;\n const varDrawing: typeof S.varDrawing;\n const StrategyRecorder: typeof S.StrategyRecorder;\n const input: typeof S.input;\n const open: typeof S.open;\n const high: typeof S.high;\n const low: typeof S.low;\n const close: typeof S.close;\n const volume: typeof S.volume;\n const hl2: typeof S.hl2;\n const hlc3: typeof S.hlc3;\n const ohlc4: typeof S.ohlc4;\n const hlcc4: typeof S.hlcc4;\n const ta: typeof S.ta;\n const color: typeof S.color;\n const DEFAULT_OUTPUT_TITLES: typeof S.DEFAULT_OUTPUT_TITLES;\n const plot: typeof S.plot;\n const hline: typeof S.hline;\n const DEFAULT_CANDLE_COLORS: typeof S.DEFAULT_CANDLE_COLORS;\n const strategy: typeof S.strategy;\n const MissingSymbolDataError: typeof S.MissingSymbolDataError;\n const timeframe: typeof S.timeframe;\n const syminfo: typeof S.syminfo;\n const year: typeof S.year;\n const month: typeof S.month;\n const weekofyear: typeof S.weekofyear;\n const dayofmonth: typeof S.dayofmonth;\n const dayofweek: typeof S.dayofweek;\n const hour: typeof S.hour;\n const minute: typeof S.minute;\n const second: typeof S.second;\n const str: typeof S.str;\n const timenow: typeof S.timenow;\n const time: typeof S.time;\n const time_close: typeof S.time_close;\n const time_tradingday: typeof S.time_tradingday;\n const barstate: typeof S.barstate;\n const session: typeof S.session;\n const barmerge: typeof S.barmerge;\n const ticker: typeof S.ticker;\n const request: typeof S.request;\n const line: typeof S.line;\n const label: typeof S.label;\n const box: typeof S.box;\n const linefill: typeof S.linefill;\n const polyline: typeof S.polyline;\n const table: typeof S.table;\n const position: typeof S.position;\n const text: typeof S.text;\n const chart: typeof S.chart;\n const alert: typeof S.alert;\n const Series: typeof S.Series;\n const BarData: typeof S.BarData;\n const na: typeof S.na;\n const nz: typeof S.nz;\n const STRATEGY_DEFAULTS: typeof S.STRATEGY_DEFAULTS;\n const math: typeof S.math;\n const bar_index: typeof S.bar_index;\n const last_bar_index: typeof S.last_bar_index;\n const shape: typeof S.shape;\n const location: typeof S.location;\n const size: typeof S.size;\n const xloc: typeof S.xloc;\n const yloc: typeof S.yloc;\n const extend: typeof S.extend;\n const display: typeof S.display;\n const format: typeof S.format;\n const font: typeof S.font;\n const scale: typeof S.scale;\n const order: typeof S.order;\n const currency: typeof S.currency;\n const adjustment: typeof S.adjustment;\n const compare: typeof S.compare;\n const isInputActive: typeof S.isInputActive;\n /** A Series of the script (`close`, the result of `ta.*`...), for JSDoc types: `@type {Series}`. */\n type Series = S.Series;\n /** The bar handed to an `eachBar()` callback, for JSDoc types. */\n type BarContext = S.BarContext;\n}\n\nexport {};\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State of an incremental script run (#196, createScriptRun).
|
|
3
|
+
*
|
|
4
|
+
* A run executes the script body again on each update, but what the body creates (Series, ta.* calls, eachBar()
|
|
5
|
+
* blocks, plots, persist() boxes) is matched by creation order with the previous run, and keeps the values of the bars
|
|
6
|
+
* before the first bar to calculate (`from`, the forming bar of the previous run). Only the bars from `from` on are
|
|
7
|
+
* calculated:
|
|
8
|
+
* - a Series: its values before `from` are those of the previous run, the others are computed
|
|
9
|
+
* - a ta.* call with a {@link taStep} machine: the machine holds the state of the last confirmed bar and steps the newest
|
|
10
|
+
* bars only
|
|
11
|
+
* - an eachBar() block: its callback runs from `from` on, its persist() boxes and history buffers put back to their
|
|
12
|
+
* state at the end of the last confirmed bar
|
|
13
|
+
* - a plot: the points of the bars before `from` are kept
|
|
14
|
+
*
|
|
15
|
+
* A feature that is not resumed (drawings, other symbols, strategies, varip, values that depend on the bar count)
|
|
16
|
+
* calls {@link nonIncremental}: a recorded (full) run marks the run so that the next updates are full runs, a resumed
|
|
17
|
+
* run stops ({@link ResumeAborted}) and the host runs it in full.
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
import { Series } from '../runtime/series.js';
|
|
22
|
+
import type { Bar } from '../types/index.js';
|
|
23
|
+
import type { BarStep } from '../ta/step.js';
|
|
24
|
+
import { type DrawingCheckpoint, type DrawingKind } from '../drawing/registry.js';
|
|
25
|
+
/** A resumed run met a feature it does not resume: the update is calculated by a full run. */
|
|
26
|
+
export declare class ResumeAborted extends Error {
|
|
27
|
+
readonly reason: string;
|
|
28
|
+
constructor(reason: string);
|
|
29
|
+
}
|
|
30
|
+
/** History buffer state of one source of an eachBar() block (RE10008). */
|
|
31
|
+
export interface BufferState {
|
|
32
|
+
size: number;
|
|
33
|
+
previous: number;
|
|
34
|
+
barMax: number;
|
|
35
|
+
}
|
|
36
|
+
/** State of an eachBar() block at the end of the last confirmed bar. */
|
|
37
|
+
export interface BlockCheckpoint {
|
|
38
|
+
/** Values of the persist() boxes the block owns, by box slot */
|
|
39
|
+
boxes: Map<number, unknown>;
|
|
40
|
+
/** History buffers by source key (Series slot, or the Series of the chart) */
|
|
41
|
+
buffers: Map<unknown, BufferState>;
|
|
42
|
+
pendingError: {
|
|
43
|
+
bar: number;
|
|
44
|
+
barsBack: number;
|
|
45
|
+
} | null;
|
|
46
|
+
/** The drawing registry and its objects (the block that draws puts it back) */
|
|
47
|
+
drawings: DrawingCheckpoint | null;
|
|
48
|
+
/** State the block keeps besides the script's (the strategy engine of strategy.eachBar()) */
|
|
49
|
+
extra?: unknown;
|
|
50
|
+
}
|
|
51
|
+
export interface BlockMemory {
|
|
52
|
+
out: number[];
|
|
53
|
+
checkpoint: BlockCheckpoint;
|
|
54
|
+
}
|
|
55
|
+
/** A ta.* call with a machine: its machines (state of the last confirmed bar) and output values. */
|
|
56
|
+
export interface TaMemory {
|
|
57
|
+
kind: string;
|
|
58
|
+
machine: BarStep<unknown[], unknown>;
|
|
59
|
+
outs: number[][];
|
|
60
|
+
}
|
|
61
|
+
/** A plot's points and, for each bar j, the number of points before it. */
|
|
62
|
+
export interface PlotMemory {
|
|
63
|
+
data: Array<{
|
|
64
|
+
time: number;
|
|
65
|
+
value: number;
|
|
66
|
+
color?: string;
|
|
67
|
+
}>;
|
|
68
|
+
pos: number[];
|
|
69
|
+
/** Offset and colour kind of the plot: the points are kept only for the same */
|
|
70
|
+
sig: string;
|
|
71
|
+
}
|
|
72
|
+
/** What a run keeps for the next update. */
|
|
73
|
+
export interface RunMemory {
|
|
74
|
+
/** Bars of that run */
|
|
75
|
+
n: number;
|
|
76
|
+
/** Values of the Series the script created, by slot */
|
|
77
|
+
series: Array<number[] | undefined>;
|
|
78
|
+
/** Values of the Series that live across runs (the chart's open, close, bar_index...) */
|
|
79
|
+
kept: WeakMap<Series, number[]>;
|
|
80
|
+
ta: Array<TaMemory | undefined>;
|
|
81
|
+
blocks: Array<BlockMemory | undefined>;
|
|
82
|
+
plots: Array<PlotMemory | undefined>;
|
|
83
|
+
/** Block slot that owns each persist() box */
|
|
84
|
+
boxOwner: Array<number | undefined>;
|
|
85
|
+
/** Drawing objects created in the script body (outside the callbacks), by creation order */
|
|
86
|
+
bodyDrawings: Array<{
|
|
87
|
+
kind: DrawingKind;
|
|
88
|
+
obj: object;
|
|
89
|
+
} | undefined>;
|
|
90
|
+
/** The eachBar() block that uses the drawings (one per script), undefined when none */
|
|
91
|
+
drawingBlock: number | undefined;
|
|
92
|
+
}
|
|
93
|
+
export declare function emptyMemory(n: number): RunMemory;
|
|
94
|
+
export interface ActiveRun {
|
|
95
|
+
mode: 'record' | 'resume';
|
|
96
|
+
/** First bar calculated (0 when recording) */
|
|
97
|
+
from: number;
|
|
98
|
+
bars: readonly Bar[];
|
|
99
|
+
prev: RunMemory | null;
|
|
100
|
+
next: RunMemory;
|
|
101
|
+
seriesSlot: number;
|
|
102
|
+
taSlot: number;
|
|
103
|
+
blockSlot: number;
|
|
104
|
+
plotSlot: number;
|
|
105
|
+
boxSlot: number;
|
|
106
|
+
drawSlot: number;
|
|
107
|
+
/** The eachBar() block running (its slot), -1 outside */
|
|
108
|
+
block: number;
|
|
109
|
+
/** Getters and setters of the persist() boxes of this run, by slot */
|
|
110
|
+
boxes: Array<{
|
|
111
|
+
get(): unknown;
|
|
112
|
+
set(v: unknown): void;
|
|
113
|
+
}>;
|
|
114
|
+
/** Why the next updates are full runs (null: they can be resumed) */
|
|
115
|
+
blocked: string | null;
|
|
116
|
+
}
|
|
117
|
+
/** The incremental run being executed (null outside createScriptRun or in a plain executeScript). */
|
|
118
|
+
export declare let active: ActiveRun | null;
|
|
119
|
+
/** Slot of a Series created by the script in this run, or undefined (a chart Series, or one made inside eachBar) */
|
|
120
|
+
export declare function slotOf(series: Series): number | undefined;
|
|
121
|
+
/** Starts an incremental run (the script body runs next); returns the run to give to {@link endRun}. */
|
|
122
|
+
export declare function beginRun(run: ActiveRun): ActiveRun | null;
|
|
123
|
+
/** Ends the run started by {@link beginRun}, putting back the outer one (a nested run) or none. */
|
|
124
|
+
export declare function endRun(outer: ActiveRun | null): void;
|
|
125
|
+
/** The script body has run: the run builds its outputs (they read the drawings without being part of the script). */
|
|
126
|
+
export declare function bodyDone(): void;
|
|
127
|
+
/** No incremental run inside (a nested executeScript, e.g. other symbols): the outer one is put back by endRun(). */
|
|
128
|
+
export declare function suspendRun(): ActiveRun | null;
|
|
129
|
+
/**
|
|
130
|
+
* A copy of a persist() value for a checkpoint: the forming bar may change an array or an object in place after it was
|
|
131
|
+
* taken. Plain data is copied (structuredClone); a value that cannot be copied (a function, a class instance such as
|
|
132
|
+
* a drawing) is kept as it is and marks the run as not resumable.
|
|
133
|
+
*/
|
|
134
|
+
export declare function copyValue(value: unknown): unknown;
|
|
135
|
+
/**
|
|
136
|
+
* A feature an incremental run does not resume: a recorded run keeps its result (it is a full run) and marks the next
|
|
137
|
+
* updates as full runs; a resumed run stops.
|
|
138
|
+
*/
|
|
139
|
+
export declare function nonIncremental(reason: string): void;
|
|
140
|
+
//# sourceMappingURL=incremental.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"incremental.d.ts","sourceRoot":"","sources":["../../../src/script/incremental.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,MAAM,EAA0C,MAAM,sBAAsB,CAAC;AACtF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAuC,KAAK,iBAAiB,EAAE,KAAK,WAAW,EAAwB,MAAM,wBAAwB,CAAC;AAE7I,8FAA8F;AAC9F,qBAAa,aAAc,SAAQ,KAAK;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM;gBAAd,MAAM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,CAAC,CAAC;IACxD,qEAAqE;IACrE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB;AAED,qGAAqG;AACrG,eAAO,IAAI,MAAM,EAAE,SAAS,GAAG,IAAW,CAAC;AAI3C,oHAAoH;AACpH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEzD;AAyDD,wGAAwG;AACxG,wBAAgB,QAAQ,CAAC,GAAG,EAAE,SAAS,GAAG,SAAS,GAAG,IAAI,CAMzD;AAED,mGAAmG;AACnG,wBAAgB,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI,CAIpD;AAED,qHAAqH;AACrH,wBAAgB,QAAQ,IAAI,IAAI,CAE/B;AAED,qHAAqH;AACrH,wBAAgB,UAAU,IAAI,SAAS,GAAG,IAAI,CAM7C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAkBjD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAKnD"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var incremental_exports = {};
|
|
20
|
+
__export(incremental_exports, {
|
|
21
|
+
ResumeAborted: () => ResumeAborted,
|
|
22
|
+
active: () => active,
|
|
23
|
+
beginRun: () => beginRun,
|
|
24
|
+
bodyDone: () => bodyDone,
|
|
25
|
+
copyValue: () => copyValue,
|
|
26
|
+
emptyMemory: () => emptyMemory,
|
|
27
|
+
endRun: () => endRun,
|
|
28
|
+
nonIncremental: () => nonIncremental,
|
|
29
|
+
slotOf: () => slotOf,
|
|
30
|
+
suspendRun: () => suspendRun
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(incremental_exports);
|
|
33
|
+
var import_series = require("../runtime/series.js");
|
|
34
|
+
var import_registry = require("../drawing/registry.js");
|
|
35
|
+
class ResumeAborted extends Error {
|
|
36
|
+
constructor(reason) {
|
|
37
|
+
super(`incremental run stopped: ${reason}`);
|
|
38
|
+
this.reason = reason;
|
|
39
|
+
}
|
|
40
|
+
reason;
|
|
41
|
+
}
|
|
42
|
+
function emptyMemory(n) {
|
|
43
|
+
return { n, series: [], kept: /* @__PURE__ */ new WeakMap(), ta: [], blocks: [], plots: [], boxOwner: [], bodyDrawings: [], drawingBlock: void 0 };
|
|
44
|
+
}
|
|
45
|
+
let active = null;
|
|
46
|
+
const SLOT = /* @__PURE__ */ Symbol("series slot");
|
|
47
|
+
function slotOf(series) {
|
|
48
|
+
return series[SLOT];
|
|
49
|
+
}
|
|
50
|
+
const hooks = {
|
|
51
|
+
created(series) {
|
|
52
|
+
const run = active;
|
|
53
|
+
if (!run || run.block >= 0) return;
|
|
54
|
+
series[SLOT] = run.seriesSlot++;
|
|
55
|
+
},
|
|
56
|
+
prefix(series, bars) {
|
|
57
|
+
const run = active;
|
|
58
|
+
if (!run || run.mode !== "resume" || bars !== run.bars || !run.prev) return null;
|
|
59
|
+
const slot = slotOf(series);
|
|
60
|
+
const values = slot !== void 0 ? run.prev.series[slot] : run.prev.kept.get(series);
|
|
61
|
+
return values && values.length >= run.from ? { values, from: run.from } : null;
|
|
62
|
+
},
|
|
63
|
+
computed(series, values) {
|
|
64
|
+
const run = active;
|
|
65
|
+
if (!run || run.block >= 0) return;
|
|
66
|
+
const slot = slotOf(series);
|
|
67
|
+
if (slot !== void 0) run.next.series[slot] = values;
|
|
68
|
+
else run.next.kept.set(series, values);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
const drawingHooks = {
|
|
72
|
+
access() {
|
|
73
|
+
const run = active;
|
|
74
|
+
if (!run) return;
|
|
75
|
+
if (run.block < 0) {
|
|
76
|
+
if (run.blockSlot > 0) nonIncremental("drawings in the script body after an eachBar() block");
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (run.next.drawingBlock === void 0) run.next.drawingBlock = run.block;
|
|
80
|
+
else if (run.next.drawingBlock !== run.block) nonIncremental("drawings in two eachBar() blocks");
|
|
81
|
+
},
|
|
82
|
+
reuse(kind, obj) {
|
|
83
|
+
const run = active;
|
|
84
|
+
if (!run || run.block >= 0) return null;
|
|
85
|
+
const slot = run.drawSlot++;
|
|
86
|
+
if (run.mode === "record") {
|
|
87
|
+
run.next.bodyDrawings[slot] = { kind, obj };
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
const old = run.prev?.bodyDrawings[slot];
|
|
91
|
+
if (!old || old.kind !== kind) nonIncremental("a new drawing in the script body");
|
|
92
|
+
run.next.bodyDrawings[slot] = old;
|
|
93
|
+
return old.obj;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
function beginRun(run) {
|
|
97
|
+
const outer = active;
|
|
98
|
+
active = run;
|
|
99
|
+
(0, import_series.setSeriesRunHooks)(hooks);
|
|
100
|
+
(0, import_registry.setDrawingRunHooks)(drawingHooks);
|
|
101
|
+
return outer;
|
|
102
|
+
}
|
|
103
|
+
function endRun(outer) {
|
|
104
|
+
active = outer;
|
|
105
|
+
(0, import_series.setSeriesRunHooks)(outer ? hooks : null);
|
|
106
|
+
(0, import_registry.setDrawingRunHooks)(outer ? drawingHooks : null);
|
|
107
|
+
}
|
|
108
|
+
function bodyDone() {
|
|
109
|
+
(0, import_registry.setDrawingRunHooks)(null);
|
|
110
|
+
}
|
|
111
|
+
function suspendRun() {
|
|
112
|
+
const outer = active;
|
|
113
|
+
active = null;
|
|
114
|
+
(0, import_series.setSeriesRunHooks)(null);
|
|
115
|
+
(0, import_registry.setDrawingRunHooks)(null);
|
|
116
|
+
return outer;
|
|
117
|
+
}
|
|
118
|
+
function copyValue(value) {
|
|
119
|
+
if ((0, import_registry.isDrawingObject)(value)) return value;
|
|
120
|
+
if (value === null || typeof value !== "object") {
|
|
121
|
+
if (typeof value === "function") nonIncremental("a function in persist()");
|
|
122
|
+
return value;
|
|
123
|
+
}
|
|
124
|
+
if (Array.isArray(value)) return value.map(copyValue);
|
|
125
|
+
if (value instanceof Map) return new Map([...value].map(([k, v]) => [copyValue(k), copyValue(v)]));
|
|
126
|
+
if (value instanceof Set) return new Set([...value].map(copyValue));
|
|
127
|
+
const proto = Object.getPrototypeOf(value);
|
|
128
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
129
|
+
nonIncremental("a class instance in persist()");
|
|
130
|
+
return value;
|
|
131
|
+
}
|
|
132
|
+
const out = {};
|
|
133
|
+
for (const [k, v] of Object.entries(value)) out[k] = copyValue(v);
|
|
134
|
+
return out;
|
|
135
|
+
}
|
|
136
|
+
function nonIncremental(reason) {
|
|
137
|
+
const run = active;
|
|
138
|
+
if (!run) return;
|
|
139
|
+
if (run.mode === "resume") throw new ResumeAborted(reason);
|
|
140
|
+
run.blocked ??= reason;
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=incremental.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/script/incremental.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * State of an incremental script run (#196, createScriptRun).\n *\n * A run executes the script body again on each update, but what the body creates (Series, ta.* calls, eachBar()\n * blocks, plots, persist() boxes) is matched by creation order with the previous run, and keeps the values of the bars\n * before the first bar to calculate (`from`, the forming bar of the previous run). Only the bars from `from` on are\n * calculated:\n * - a Series: its values before `from` are those of the previous run, the others are computed\n * - a ta.* call with a {@link taStep} machine: the machine holds the state of the last confirmed bar and steps the newest\n * bars only\n * - an eachBar() block: its callback runs from `from` on, its persist() boxes and history buffers put back to their\n * state at the end of the last confirmed bar\n * - a plot: the points of the bars before `from` are kept\n *\n * A feature that is not resumed (drawings, other symbols, strategies, varip, values that depend on the bar count)\n * calls {@link nonIncremental}: a recorded (full) run marks the run so that the next updates are full runs, a resumed\n * run stops ({@link ResumeAborted}) and the host runs it in full.\n *\n * @internal\n */\nimport { Series, setSeriesRunHooks, type SeriesRunHooks } from '../runtime/series.js';\nimport type { Bar } from '../types/index.js';\nimport type { BarStep } from '../ta/step.js';\nimport { isDrawingObject, setDrawingRunHooks, type DrawingCheckpoint, type DrawingKind, type DrawingRunHooks } from '../drawing/registry.js';\n\n/** A resumed run met a feature it does not resume: the update is calculated by a full run. */\nexport class ResumeAborted extends Error {\n constructor(readonly reason: string) {\n super(`incremental run stopped: ${reason}`);\n }\n}\n\n/** History buffer state of one source of an eachBar() block (RE10008). */\nexport interface BufferState {\n size: number;\n previous: number;\n barMax: number;\n}\n\n/** State of an eachBar() block at the end of the last confirmed bar. */\nexport interface BlockCheckpoint {\n /** Values of the persist() boxes the block owns, by box slot */\n boxes: Map<number, unknown>;\n /** History buffers by source key (Series slot, or the Series of the chart) */\n buffers: Map<unknown, BufferState>;\n pendingError: { bar: number; barsBack: number } | null;\n /** The drawing registry and its objects (the block that draws puts it back) */\n drawings: DrawingCheckpoint | null;\n /** State the block keeps besides the script's (the strategy engine of strategy.eachBar()) */\n extra?: unknown;\n}\n\nexport interface BlockMemory {\n out: number[];\n checkpoint: BlockCheckpoint;\n}\n\n/** A ta.* call with a machine: its machines (state of the last confirmed bar) and output values. */\nexport interface TaMemory {\n kind: string;\n machine: BarStep<unknown[], unknown>;\n outs: number[][];\n}\n\n/** A plot's points and, for each bar j, the number of points before it. */\nexport interface PlotMemory {\n data: Array<{ time: number; value: number; color?: string }>;\n pos: number[];\n /** Offset and colour kind of the plot: the points are kept only for the same */\n sig: string;\n}\n\n/** What a run keeps for the next update. */\nexport interface RunMemory {\n /** Bars of that run */\n n: number;\n /** Values of the Series the script created, by slot */\n series: Array<number[] | undefined>;\n /** Values of the Series that live across runs (the chart's open, close, bar_index...) */\n kept: WeakMap<Series, number[]>;\n ta: Array<TaMemory | undefined>;\n blocks: Array<BlockMemory | undefined>;\n plots: Array<PlotMemory | undefined>;\n /** Block slot that owns each persist() box */\n boxOwner: Array<number | undefined>;\n /** Drawing objects created in the script body (outside the callbacks), by creation order */\n bodyDrawings: Array<{ kind: DrawingKind; obj: object } | undefined>;\n /** The eachBar() block that uses the drawings (one per script), undefined when none */\n drawingBlock: number | undefined;\n}\n\nexport function emptyMemory(n: number): RunMemory {\n return { n, series: [], kept: new WeakMap(), ta: [], blocks: [], plots: [], boxOwner: [], bodyDrawings: [], drawingBlock: undefined };\n}\n\nexport interface ActiveRun {\n mode: 'record' | 'resume';\n /** First bar calculated (0 when recording) */\n from: number;\n bars: readonly Bar[];\n prev: RunMemory | null;\n next: RunMemory;\n seriesSlot: number;\n taSlot: number;\n blockSlot: number;\n plotSlot: number;\n boxSlot: number;\n drawSlot: number;\n /** The eachBar() block running (its slot), -1 outside */\n block: number;\n /** Getters and setters of the persist() boxes of this run, by slot */\n boxes: Array<{ get(): unknown; set(v: unknown): void }>;\n /** Why the next updates are full runs (null: they can be resumed) */\n blocked: string | null;\n}\n\n/** The incremental run being executed (null outside createScriptRun or in a plain executeScript). */\nexport let active: ActiveRun | null = null;\n\nconst SLOT = Symbol('series slot');\n\n/** Slot of a Series created by the script in this run, or undefined (a chart Series, or one made inside eachBar) */\nexport function slotOf(series: Series): number | undefined {\n return (series as unknown as Record<symbol, number | undefined>)[SLOT];\n}\n\nconst hooks: SeriesRunHooks = {\n created(series) {\n const run = active;\n // A Series made in an eachBar() callback is made again on each bar: it is not matched with the previous run.\n if (!run || run.block >= 0) return;\n (series as unknown as Record<symbol, number>)[SLOT] = run.seriesSlot++;\n },\n prefix(series, bars) {\n const run = active;\n if (!run || run.mode !== 'resume' || bars !== run.bars || !run.prev) return null;\n const slot = slotOf(series);\n const values = slot !== undefined ? run.prev.series[slot] : run.prev.kept.get(series);\n return values && values.length >= run.from ? { values, from: run.from } : null;\n },\n computed(series, values) {\n const run = active;\n if (!run || run.block >= 0) return;\n const slot = slotOf(series);\n if (slot !== undefined) run.next.series[slot] = values;\n else run.next.kept.set(series, values);\n },\n};\n\n/**\n * Drawings in an incremental run: one eachBar() block uses them (its checkpoint holds the registry and the state of\n * the objects); the objects created in the script body before the blocks are the same objects on each run (matched by\n * creation order), set again to their new state. Drawings used by two blocks, or in the body after a block, are not\n * resumed.\n */\nconst drawingHooks: DrawingRunHooks = {\n access() {\n const run = active;\n if (!run) return;\n if (run.block < 0) {\n if (run.blockSlot > 0) nonIncremental('drawings in the script body after an eachBar() block');\n return;\n }\n if (run.next.drawingBlock === undefined) run.next.drawingBlock = run.block;\n else if (run.next.drawingBlock !== run.block) nonIncremental('drawings in two eachBar() blocks');\n },\n reuse(kind, obj) {\n const run = active;\n if (!run || run.block >= 0) return null;\n const slot = run.drawSlot++;\n if (run.mode === 'record') {\n run.next.bodyDrawings[slot] = { kind, obj };\n return null;\n }\n const old = run.prev?.bodyDrawings[slot];\n if (!old || old.kind !== kind) nonIncremental('a new drawing in the script body');\n run.next.bodyDrawings[slot] = old;\n return old!.obj;\n },\n};\n\n/** Starts an incremental run (the script body runs next); returns the run to give to {@link endRun}. */\nexport function beginRun(run: ActiveRun): ActiveRun | null {\n const outer = active;\n active = run;\n setSeriesRunHooks(hooks);\n setDrawingRunHooks(drawingHooks);\n return outer;\n}\n\n/** Ends the run started by {@link beginRun}, putting back the outer one (a nested run) or none. */\nexport function endRun(outer: ActiveRun | null): void {\n active = outer;\n setSeriesRunHooks(outer ? hooks : null);\n setDrawingRunHooks(outer ? drawingHooks : null);\n}\n\n/** The script body has run: the run builds its outputs (they read the drawings without being part of the script). */\nexport function bodyDone(): void {\n setDrawingRunHooks(null);\n}\n\n/** No incremental run inside (a nested executeScript, e.g. other symbols): the outer one is put back by endRun(). */\nexport function suspendRun(): ActiveRun | null {\n const outer = active;\n active = null;\n setSeriesRunHooks(null);\n setDrawingRunHooks(null);\n return outer;\n}\n\n/**\n * A copy of a persist() value for a checkpoint: the forming bar may change an array or an object in place after it was\n * taken. Plain data is copied (structuredClone); a value that cannot be copied (a function, a class instance such as\n * a drawing) is kept as it is and marks the run as not resumable.\n */\nexport function copyValue(value: unknown): unknown {\n // a drawing object is shared: the checkpoint of the registry puts its state back\n if (isDrawingObject(value)) return value;\n if (value === null || typeof value !== 'object') {\n if (typeof value === 'function') nonIncremental('a function in persist()');\n return value;\n }\n if (Array.isArray(value)) return value.map(copyValue);\n if (value instanceof Map) return new Map([...value].map(([k, v]) => [copyValue(k), copyValue(v)]));\n if (value instanceof Set) return new Set([...value].map(copyValue));\n const proto = Object.getPrototypeOf(value);\n if (proto !== Object.prototype && proto !== null) {\n nonIncremental('a class instance in persist()');\n return value;\n }\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) out[k] = copyValue(v);\n return out;\n}\n\n/**\n * A feature an incremental run does not resume: a recorded run keeps its result (it is a full run) and marks the next\n * updates as full runs; a resumed run stops.\n */\nexport function nonIncremental(reason: string): void {\n const run = active;\n if (!run) return;\n if (run.mode === 'resume') throw new ResumeAborted(reason);\n run.blocked ??= reason;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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