@invinite-org/chartlang-core 1.0.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 (208) hide show
  1. package/CHANGELOG.md +1694 -0
  2. package/LICENSE +21 -0
  3. package/README.md +53 -0
  4. package/dist/alert/alert.d.ts +32 -0
  5. package/dist/alert/alert.d.ts.map +1 -0
  6. package/dist/alert/alert.js +19 -0
  7. package/dist/alert/alert.js.map +1 -0
  8. package/dist/alert/index.d.ts +2 -0
  9. package/dist/alert/index.d.ts.map +1 -0
  10. package/dist/alert/index.js +4 -0
  11. package/dist/alert/index.js.map +1 -0
  12. package/dist/color/colorHelpers.d.ts +65 -0
  13. package/dist/color/colorHelpers.d.ts.map +1 -0
  14. package/dist/color/colorHelpers.js +137 -0
  15. package/dist/color/colorHelpers.js.map +1 -0
  16. package/dist/color/index.d.ts +37 -0
  17. package/dist/color/index.d.ts.map +1 -0
  18. package/dist/color/index.js +23 -0
  19. package/dist/color/index.js.map +1 -0
  20. package/dist/color/parseColor.d.ts +48 -0
  21. package/dist/color/parseColor.d.ts.map +1 -0
  22. package/dist/color/parseColor.js +141 -0
  23. package/dist/color/parseColor.js.map +1 -0
  24. package/dist/define/defineAlert.d.ts +43 -0
  25. package/dist/define/defineAlert.d.ts.map +1 -0
  26. package/dist/define/defineAlert.js +49 -0
  27. package/dist/define/defineAlert.js.map +1 -0
  28. package/dist/define/defineAlertCondition.d.ts +65 -0
  29. package/dist/define/defineAlertCondition.d.ts.map +1 -0
  30. package/dist/define/defineAlertCondition.js +64 -0
  31. package/dist/define/defineAlertCondition.js.map +1 -0
  32. package/dist/define/defineDrawing.d.ts +62 -0
  33. package/dist/define/defineDrawing.d.ts.map +1 -0
  34. package/dist/define/defineDrawing.js +67 -0
  35. package/dist/define/defineDrawing.js.map +1 -0
  36. package/dist/define/defineIndicator.d.ts +48 -0
  37. package/dist/define/defineIndicator.d.ts.map +1 -0
  38. package/dist/define/defineIndicator.js +54 -0
  39. package/dist/define/defineIndicator.js.map +1 -0
  40. package/dist/define/index.d.ts +6 -0
  41. package/dist/define/index.d.ts.map +1 -0
  42. package/dist/define/index.js +7 -0
  43. package/dist/define/index.js.map +1 -0
  44. package/dist/define/overrides.d.ts +102 -0
  45. package/dist/define/overrides.d.ts.map +1 -0
  46. package/dist/define/overrides.js +4 -0
  47. package/dist/define/overrides.js.map +1 -0
  48. package/dist/draw/buckets.d.ts +57 -0
  49. package/dist/draw/buckets.d.ts.map +1 -0
  50. package/dist/draw/buckets.js +110 -0
  51. package/dist/draw/buckets.js.map +1 -0
  52. package/dist/draw/draw.d.ts +128 -0
  53. package/dist/draw/draw.d.ts.map +1 -0
  54. package/dist/draw/draw.js +40 -0
  55. package/dist/draw/draw.js.map +1 -0
  56. package/dist/draw/drawingKind.d.ts +80 -0
  57. package/dist/draw/drawingKind.d.ts.map +1 -0
  58. package/dist/draw/drawingKind.js +177 -0
  59. package/dist/draw/drawingKind.js.map +1 -0
  60. package/dist/draw/drawingState.d.ts +1420 -0
  61. package/dist/draw/drawingState.d.ts.map +1 -0
  62. package/dist/draw/drawingState.js +4 -0
  63. package/dist/draw/drawingState.js.map +1 -0
  64. package/dist/draw/drawingStyle.d.ts +219 -0
  65. package/dist/draw/drawingStyle.d.ts.map +1 -0
  66. package/dist/draw/drawingStyle.js +4 -0
  67. package/dist/draw/drawingStyle.js.map +1 -0
  68. package/dist/draw/handle.d.ts +32 -0
  69. package/dist/draw/handle.d.ts.map +1 -0
  70. package/dist/draw/handle.js +4 -0
  71. package/dist/draw/handle.js.map +1 -0
  72. package/dist/draw/index.d.ts +13 -0
  73. package/dist/draw/index.d.ts.map +1 -0
  74. package/dist/draw/index.js +7 -0
  75. package/dist/draw/index.js.map +1 -0
  76. package/dist/draw/table.d.ts +84 -0
  77. package/dist/draw/table.d.ts.map +1 -0
  78. package/dist/draw/table.js +22 -0
  79. package/dist/draw/table.js.map +1 -0
  80. package/dist/draw/worldPoint.d.ts +114 -0
  81. package/dist/draw/worldPoint.d.ts.map +1 -0
  82. package/dist/draw/worldPoint.js +4 -0
  83. package/dist/draw/worldPoint.js.map +1 -0
  84. package/dist/index.d.ts +28 -0
  85. package/dist/index.d.ts.map +1 -0
  86. package/dist/index.js +16 -0
  87. package/dist/index.js.map +1 -0
  88. package/dist/input/index.d.ts +3 -0
  89. package/dist/input/index.d.ts.map +1 -0
  90. package/dist/input/index.js +4 -0
  91. package/dist/input/index.js.map +1 -0
  92. package/dist/input/input.d.ts +174 -0
  93. package/dist/input/input.d.ts.map +1 -0
  94. package/dist/input/input.js +174 -0
  95. package/dist/input/input.js.map +1 -0
  96. package/dist/input/inputDescriptor.d.ts +204 -0
  97. package/dist/input/inputDescriptor.d.ts.map +1 -0
  98. package/dist/input/inputDescriptor.js +4 -0
  99. package/dist/input/inputDescriptor.js.map +1 -0
  100. package/dist/interval/intervalToSeconds.d.ts +20 -0
  101. package/dist/interval/intervalToSeconds.d.ts.map +1 -0
  102. package/dist/interval/intervalToSeconds.js +50 -0
  103. package/dist/interval/intervalToSeconds.js.map +1 -0
  104. package/dist/plot/index.d.ts +2 -0
  105. package/dist/plot/index.d.ts.map +1 -0
  106. package/dist/plot/index.js +4 -0
  107. package/dist/plot/index.js.map +1 -0
  108. package/dist/plot/plot.d.ts +277 -0
  109. package/dist/plot/plot.d.ts.map +1 -0
  110. package/dist/plot/plot.js +37 -0
  111. package/dist/plot/plot.js.map +1 -0
  112. package/dist/request/index.d.ts +2 -0
  113. package/dist/request/index.d.ts.map +1 -0
  114. package/dist/request/index.js +4 -0
  115. package/dist/request/index.js.map +1 -0
  116. package/dist/request/request.d.ts +106 -0
  117. package/dist/request/request.d.ts.map +1 -0
  118. package/dist/request/request.js +44 -0
  119. package/dist/request/request.js.map +1 -0
  120. package/dist/runtime/index.d.ts +3 -0
  121. package/dist/runtime/index.d.ts.map +1 -0
  122. package/dist/runtime/index.js +4 -0
  123. package/dist/runtime/index.js.map +1 -0
  124. package/dist/runtime/runtime.d.ts +84 -0
  125. package/dist/runtime/runtime.d.ts.map +1 -0
  126. package/dist/runtime/runtime.js +72 -0
  127. package/dist/runtime/runtime.js.map +1 -0
  128. package/dist/state/index.d.ts +5 -0
  129. package/dist/state/index.d.ts.map +1 -0
  130. package/dist/state/index.js +4 -0
  131. package/dist/state/index.js.map +1 -0
  132. package/dist/state/mutableSlot.d.ts +25 -0
  133. package/dist/state/mutableSlot.d.ts.map +1 -0
  134. package/dist/state/mutableSlot.js +4 -0
  135. package/dist/state/mutableSlot.js.map +1 -0
  136. package/dist/state/snapshot.d.ts +108 -0
  137. package/dist/state/snapshot.d.ts.map +1 -0
  138. package/dist/state/snapshot.js +4 -0
  139. package/dist/state/snapshot.js.map +1 -0
  140. package/dist/state/state.d.ts +86 -0
  141. package/dist/state/state.d.ts.map +1 -0
  142. package/dist/state/state.js +95 -0
  143. package/dist/state/state.js.map +1 -0
  144. package/dist/statefulPrimitives.d.ts +71 -0
  145. package/dist/statefulPrimitives.d.ts.map +1 -0
  146. package/dist/statefulPrimitives.js +234 -0
  147. package/dist/statefulPrimitives.js.map +1 -0
  148. package/dist/ta/index.d.ts +2 -0
  149. package/dist/ta/index.d.ts.map +1 -0
  150. package/dist/ta/index.js +4 -0
  151. package/dist/ta/index.js.map +1 -0
  152. package/dist/ta/ta.d.ts +2476 -0
  153. package/dist/ta/ta.d.ts.map +1 -0
  154. package/dist/ta/ta.js +312 -0
  155. package/dist/ta/ta.js.map +1 -0
  156. package/dist/time/_lib/dateTimeFormatCache.d.ts +11 -0
  157. package/dist/time/_lib/dateTimeFormatCache.d.ts.map +1 -0
  158. package/dist/time/_lib/dateTimeFormatCache.js +22 -0
  159. package/dist/time/_lib/dateTimeFormatCache.js.map +1 -0
  160. package/dist/time/index.d.ts +7 -0
  161. package/dist/time/index.d.ts.map +1 -0
  162. package/dist/time/index.js +8 -0
  163. package/dist/time/index.js.map +1 -0
  164. package/dist/time/nyDayKey.d.ts +24 -0
  165. package/dist/time/nyDayKey.d.ts.map +1 -0
  166. package/dist/time/nyDayKey.js +49 -0
  167. package/dist/time/nyDayKey.js.map +1 -0
  168. package/dist/time/session.d.ts +16 -0
  169. package/dist/time/session.d.ts.map +1 -0
  170. package/dist/time/session.js +18 -0
  171. package/dist/time/session.js.map +1 -0
  172. package/dist/time/sessionBoundaries.d.ts +40 -0
  173. package/dist/time/sessionBoundaries.d.ts.map +1 -0
  174. package/dist/time/sessionBoundaries.js +102 -0
  175. package/dist/time/sessionBoundaries.js.map +1 -0
  176. package/dist/time/types.d.ts +34 -0
  177. package/dist/time/types.d.ts.map +1 -0
  178. package/dist/time/types.js +4 -0
  179. package/dist/time/types.js.map +1 -0
  180. package/dist/time/weekKey.d.ts +11 -0
  181. package/dist/time/weekKey.d.ts.map +1 -0
  182. package/dist/time/weekKey.js +25 -0
  183. package/dist/time/weekKey.js.map +1 -0
  184. package/dist/time/weekday.d.ts +12 -0
  185. package/dist/time/weekday.d.ts.map +1 -0
  186. package/dist/time/weekday.js +22 -0
  187. package/dist/time/weekday.js.map +1 -0
  188. package/dist/types.d.ts +464 -0
  189. package/dist/types.d.ts.map +1 -0
  190. package/dist/types.js +4 -0
  191. package/dist/types.js.map +1 -0
  192. package/dist/views/barstate.d.ts +40 -0
  193. package/dist/views/barstate.d.ts.map +1 -0
  194. package/dist/views/barstate.js +22 -0
  195. package/dist/views/barstate.js.map +1 -0
  196. package/dist/views/index.d.ts +4 -0
  197. package/dist/views/index.d.ts.map +1 -0
  198. package/dist/views/index.js +4 -0
  199. package/dist/views/index.js.map +1 -0
  200. package/dist/views/syminfo.d.ts +46 -0
  201. package/dist/views/syminfo.d.ts.map +1 -0
  202. package/dist/views/syminfo.js +25 -0
  203. package/dist/views/syminfo.js.map +1 -0
  204. package/dist/views/timeframe.d.ts +40 -0
  205. package/dist/views/timeframe.d.ts.map +1 -0
  206. package/dist/views/timeframe.js +21 -0
  207. package/dist/views/timeframe.js.map +1 -0
  208. package/package.json +45 -0
@@ -0,0 +1,84 @@
1
+ import type { JsonValue } from "../types.js";
2
+ /**
3
+ * Runtime log severity emitted by `runtime.log.*`.
4
+ *
5
+ * @since 0.5
6
+ * @stable
7
+ * @example
8
+ * const level: LogLevel = "info";
9
+ * void level;
10
+ */
11
+ export type LogLevel = "info" | "warn" | "error";
12
+ /**
13
+ * Per-step log message. Pine's `runtime.log.*` analogue. Capability-
14
+ * gated by `Capabilities.logs`; silent no-op when false.
15
+ *
16
+ * @since 0.5
17
+ * @stable
18
+ * @example
19
+ * // Inside compute:
20
+ * // runtime.log.info(`ema=${ema.current}`, { ema: ema.current });
21
+ */
22
+ declare function _logInfo(_message: string, _meta?: Readonly<Record<string, JsonValue>>): void;
23
+ /**
24
+ * Per-step warning log message. Capability-gated by `Capabilities.logs`.
25
+ *
26
+ * @since 0.5
27
+ * @stable
28
+ * @example
29
+ * // Inside compute:
30
+ * // runtime.log.warn("warmup incomplete");
31
+ */
32
+ declare function _logWarn(_message: string, _meta?: Readonly<Record<string, JsonValue>>): void;
33
+ /**
34
+ * Per-step error log message. Capability-gated by `Capabilities.logs`.
35
+ *
36
+ * @since 0.5
37
+ * @stable
38
+ * @example
39
+ * // Inside compute:
40
+ * // runtime.log.error("unexpected branch", { branch: "fallback" });
41
+ */
42
+ declare function _logError(_message: string, _meta?: Readonly<Record<string, JsonValue>>): void;
43
+ /**
44
+ * Halt the current bar's compute. Emits a fatal `RuntimeDiagnostic`
45
+ * with code `runtime-error-thrown`. The script stays mounted; the
46
+ * next bar runs normally. Use for invariant violations the script
47
+ * cannot continue past.
48
+ *
49
+ * @since 0.5
50
+ * @stable
51
+ * @example
52
+ * // Inside compute:
53
+ * // if (inputs.length < 1) runtime.error("length must be >= 1");
54
+ */
55
+ declare function _error(_message: string): never;
56
+ /**
57
+ * Pine-style runtime utilities exposed to script `compute` callbacks.
58
+ *
59
+ * @since 0.5
60
+ * @stable
61
+ * @example
62
+ * // Inside compute:
63
+ * // runtime.log.info("close", { value: bar.close });
64
+ */
65
+ export declare const runtime: Readonly<{
66
+ log: Readonly<{
67
+ info: typeof _logInfo;
68
+ warn: typeof _logWarn;
69
+ error: typeof _logError;
70
+ }>;
71
+ error: typeof _error;
72
+ }>;
73
+ /**
74
+ * Script-facing runtime namespace type.
75
+ *
76
+ * @since 0.5
77
+ * @stable
78
+ * @example
79
+ * const ns: RuntimeNamespace = runtime;
80
+ * void ns;
81
+ */
82
+ export type RuntimeNamespace = typeof runtime;
83
+ export {};
84
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime/runtime.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;;GAQG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEjD;;;;;;;;;GASG;AACH,iBAAS,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAErF;AAED;;;;;;;;GAQG;AACH,iBAAS,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAErF;AAED;;;;;;;;GAQG;AACH,iBAAS,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAEtF;AAED;;;;;;;;;;;GAWG;AACH,iBAAS,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,CAEvC;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO;;;;;;;EAOlB,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,OAAO,CAAC"}
@@ -0,0 +1,72 @@
1
+ // Copyright (c) 2026 Invinite. Licensed under the MIT License.
2
+ // See the LICENSE file in the repo root for full license text.
3
+ /**
4
+ * Per-step log message. Pine's `runtime.log.*` analogue. Capability-
5
+ * gated by `Capabilities.logs`; silent no-op when false.
6
+ *
7
+ * @since 0.5
8
+ * @stable
9
+ * @example
10
+ * // Inside compute:
11
+ * // runtime.log.info(`ema=${ema.current}`, { ema: ema.current });
12
+ */
13
+ function _logInfo(_message, _meta) {
14
+ throw new Error("runtime.log.info called outside compiled runtime");
15
+ }
16
+ /**
17
+ * Per-step warning log message. Capability-gated by `Capabilities.logs`.
18
+ *
19
+ * @since 0.5
20
+ * @stable
21
+ * @example
22
+ * // Inside compute:
23
+ * // runtime.log.warn("warmup incomplete");
24
+ */
25
+ function _logWarn(_message, _meta) {
26
+ throw new Error("runtime.log.warn called outside compiled runtime");
27
+ }
28
+ /**
29
+ * Per-step error log message. Capability-gated by `Capabilities.logs`.
30
+ *
31
+ * @since 0.5
32
+ * @stable
33
+ * @example
34
+ * // Inside compute:
35
+ * // runtime.log.error("unexpected branch", { branch: "fallback" });
36
+ */
37
+ function _logError(_message, _meta) {
38
+ throw new Error("runtime.log.error called outside compiled runtime");
39
+ }
40
+ /**
41
+ * Halt the current bar's compute. Emits a fatal `RuntimeDiagnostic`
42
+ * with code `runtime-error-thrown`. The script stays mounted; the
43
+ * next bar runs normally. Use for invariant violations the script
44
+ * cannot continue past.
45
+ *
46
+ * @since 0.5
47
+ * @stable
48
+ * @example
49
+ * // Inside compute:
50
+ * // if (inputs.length < 1) runtime.error("length must be >= 1");
51
+ */
52
+ function _error(_message) {
53
+ throw new Error("runtime.error called outside compiled runtime");
54
+ }
55
+ /**
56
+ * Pine-style runtime utilities exposed to script `compute` callbacks.
57
+ *
58
+ * @since 0.5
59
+ * @stable
60
+ * @example
61
+ * // Inside compute:
62
+ * // runtime.log.info("close", { value: bar.close });
63
+ */
64
+ export const runtime = Object.freeze({
65
+ log: Object.freeze({
66
+ info: _logInfo,
67
+ warn: _logWarn,
68
+ error: _logError,
69
+ }),
70
+ error: _error,
71
+ });
72
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/runtime/runtime.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAe/D;;;;;;;;;GASG;AACH,SAAS,QAAQ,CAAC,QAAgB,EAAE,KAA2C;IAC3E,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;AACxE,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,QAAQ,CAAC,QAAgB,EAAE,KAA2C;IAC3E,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;AACxE,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,SAAS,CAAC,QAAgB,EAAE,KAA2C;IAC5E,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAS,MAAM,CAAC,QAAgB;IAC5B,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;AACrE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;IACjC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC;QACf,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,SAAS;KACnB,CAAC;IACF,KAAK,EAAE,MAAM;CAChB,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { state } from "./state.js";
2
+ export type { StateNamespace } from "./state.js";
3
+ export type { MutableSlot } from "./mutableSlot.js";
4
+ export type { StateSnapshot, StateStoreKey, StreamSnapshot } from "./snapshot.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,YAAY,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) 2026 Invinite. Licensed under the MIT License.
2
+ // See the LICENSE file in the repo root for full license text.
3
+ export { state } from "./state.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAE/D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Script-facing handle on a persistent cross-bar slot, Pine's `var` /
3
+ * `varip` equivalent. Reads return the active step value; writes follow
4
+ * the runtime's committed/tentative slot semantics.
5
+ *
6
+ * Intentionally minimal: no `.history()`, no `.previous()`, no indexing.
7
+ * Scripts that need the previous bar's value store it in a second slot or
8
+ * use `ta.*` series-indexing primitives.
9
+ *
10
+ * @since 0.4
11
+ * @stable
12
+ * @example
13
+ * const slot: MutableSlot<number> = {
14
+ * get value() {
15
+ * return 0;
16
+ * },
17
+ * set value(_next: number) {},
18
+ * };
19
+ * slot.value = 1;
20
+ */
21
+ export type MutableSlot<T> = {
22
+ get value(): T;
23
+ set value(v: T);
24
+ };
25
+ //# sourceMappingURL=mutableSlot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutableSlot.d.ts","sourceRoot":"","sources":["../../src/state/mutableSlot.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI;IACzB,IAAI,KAAK,IAAI,CAAC,CAAC;IACf,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE;CACnB,CAAC"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) 2026 Invinite. Licensed under the MIT License.
2
+ // See the LICENSE file in the repo root for full license text.
3
+ export {};
4
+ //# sourceMappingURL=mutableSlot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutableSlot.js","sourceRoot":"","sources":["../../src/state/mutableSlot.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D"}
@@ -0,0 +1,108 @@
1
+ import type { JsonValue } from "../types.js";
2
+ /**
3
+ * Per-stream snapshot captured during state persistence.
4
+ *
5
+ * Carries everything needed to rehydrate a ring buffer for one timeframe,
6
+ * whether that stream is the main interval or a higher-timeframe secondary
7
+ * stream (PLAN.md §6.1, §6.9).
8
+ *
9
+ * `buffers` is keyed by the canonical OHLCV field names; each value is a
10
+ * JSON-clean array of `number | null`, where `null` preserves NaN holes
11
+ * through `JSON.stringify`. `headIndex` and `filled` mirror the ring-buffer's
12
+ * internal state at snapshot time.
13
+ *
14
+ * @since 0.5
15
+ * @stable
16
+ * @example
17
+ * const s: StreamSnapshot = {
18
+ * interval: "1D",
19
+ * headIndex: 4999,
20
+ * filled: 5000,
21
+ * buffers: { time: [], open: [], high: [], low: [], close: [], volume: [] },
22
+ * };
23
+ * void s;
24
+ */
25
+ export type StreamSnapshot = Readonly<{
26
+ interval: string;
27
+ headIndex: number;
28
+ filled: number;
29
+ buffers: Readonly<{
30
+ time: ReadonlyArray<number | null>;
31
+ open: ReadonlyArray<number | null>;
32
+ high: ReadonlyArray<number | null>;
33
+ low: ReadonlyArray<number | null>;
34
+ close: ReadonlyArray<number | null>;
35
+ volume: ReadonlyArray<number | null>;
36
+ }>;
37
+ }>;
38
+ /**
39
+ * Canonical persistent-store snapshot.
40
+ *
41
+ * Written on `dispose()` and on every `kind: "close"` event when stale for
42
+ * at least 60 seconds (PLAN.md §6.9). `slots` carries every stateful
43
+ * primitive's per-callsite payload keyed by the compiler-injected slot id
44
+ * (PLAN.md §5.5). Each value is `JsonValue`; primitive authors with non-JSON
45
+ * internal state register serialisation hooks in the runtime layer.
46
+ *
47
+ * `snapshotVersion: 1` is the only currently-supported wire version. A future
48
+ * schema change must bump this literal so the runtime can drop snapshots with
49
+ * mismatched versions on load.
50
+ *
51
+ * @since 0.5
52
+ * @stable
53
+ * @example
54
+ * const s: StateSnapshot = {
55
+ * lastBarTime: 1_700_000_000_000,
56
+ * streams: {},
57
+ * slots: {},
58
+ * savedAt: 1_700_000_060_000,
59
+ * snapshotVersion: 1,
60
+ * };
61
+ * void s;
62
+ */
63
+ export type StateSnapshot = Readonly<{
64
+ lastBarTime: number;
65
+ streams: Readonly<Record<string, StreamSnapshot>>;
66
+ slots: Readonly<Record<string, JsonValue>>;
67
+ savedAt: number;
68
+ snapshotVersion: 1;
69
+ }>;
70
+ /**
71
+ * Canonical persistent-store identity tuple.
72
+ *
73
+ * Every field contributes to the cache key; any change invalidates the
74
+ * snapshot (PLAN.md §6.9). Stores treat this tuple opaquely as a string key;
75
+ * the typical implementation is `JSON.stringify(key)` with sorted fields.
76
+ *
77
+ * - `scriptHash` is the SHA-256 digest of the compiled `moduleSource`.
78
+ * - `compilerVersion` is the package version of `@invinite-org/chartlang-compiler`.
79
+ * - `apiVersion` is the script header pin, currently `1`.
80
+ * - `capabilitiesHash` is the SHA-256 digest of normalised adapter capabilities.
81
+ * - `symbol` is the adapter's loaded ticker.
82
+ * - `mainInterval` is the primary stream interval.
83
+ * - `requestedIntervals` is the frozen array of secondary stream intervals.
84
+ *
85
+ * @since 0.5
86
+ * @stable
87
+ * @example
88
+ * const k: StateStoreKey = {
89
+ * scriptHash: "abc",
90
+ * compilerVersion: "0.5.0",
91
+ * apiVersion: 1,
92
+ * capabilitiesHash: "def",
93
+ * symbol: "BTCUSD",
94
+ * mainInterval: "1m",
95
+ * requestedIntervals: [],
96
+ * };
97
+ * void k;
98
+ */
99
+ export type StateStoreKey = Readonly<{
100
+ scriptHash: string;
101
+ compilerVersion: string;
102
+ apiVersion: 1;
103
+ capabilitiesHash: string;
104
+ symbol: string;
105
+ mainInterval: string;
106
+ requestedIntervals: ReadonlyArray<string>;
107
+ }>;
108
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../src/state/snapshot.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,QAAQ,CAAC;QACd,IAAI,EAAE,aAAa,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QACnC,IAAI,EAAE,aAAa,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QACnC,IAAI,EAAE,aAAa,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QACnC,GAAG,EAAE,aAAa,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QAClC,KAAK,EAAE,aAAa,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;QACpC,MAAM,EAAE,aAAa,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;KACxC,CAAC,CAAC;CACN,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;IAClD,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,CAAC,CAAC;CACtB,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,CAAC,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC7C,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) 2026 Invinite. Licensed under the MIT License.
2
+ // See the LICENSE file in the repo root for full license text.
3
+ export {};
4
+ //# sourceMappingURL=snapshot.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../../src/state/snapshot.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D"}
@@ -0,0 +1,86 @@
1
+ import type { MutableSlot } from "./mutableSlot.js";
2
+ /**
3
+ * Persistent state slots, Pine `var` semantics. Writes during a tick are
4
+ * tentative and discarded if a later tick replaces the head bar; on bar
5
+ * close the tentative value commits. Reads return the active tentative
6
+ * value for the current step.
7
+ *
8
+ * The runtime replaces this compile-time callable hole with a slot-aware
9
+ * namespace through `ComputeContext.state`.
10
+ *
11
+ * @since 0.4
12
+ * @stable
13
+ * @example
14
+ * const ns: typeof state = state;
15
+ * void ns;
16
+ */
17
+ export declare const state: Readonly<{
18
+ /**
19
+ * Allocate or read a persistent number slot.
20
+ *
21
+ * @since 0.4
22
+ * @stable
23
+ * @example
24
+ * const fn: typeof state.float = state.float;
25
+ * void fn;
26
+ */
27
+ float(_init: number): MutableSlot<number>;
28
+ /**
29
+ * Allocate or read a persistent integer slot.
30
+ *
31
+ * @since 0.4
32
+ * @stable
33
+ * @example
34
+ * const fn: typeof state.int = state.int;
35
+ * void fn;
36
+ */
37
+ int(_init: number): MutableSlot<number>;
38
+ /**
39
+ * Allocate or read a persistent boolean slot.
40
+ *
41
+ * @since 0.4
42
+ * @stable
43
+ * @example
44
+ * const fn: typeof state.bool = state.bool;
45
+ * void fn;
46
+ */
47
+ bool(_init: boolean): MutableSlot<boolean>;
48
+ /**
49
+ * Allocate or read a persistent string slot.
50
+ *
51
+ * @since 0.4
52
+ * @stable
53
+ * @example
54
+ * const fn: typeof state.string = state.string;
55
+ * void fn;
56
+ */
57
+ string(_init: string): MutableSlot<string>;
58
+ /**
59
+ * Tick-persistent state slots, Pine `varip` semantics. Writes commit
60
+ * immediately, even during a tick.
61
+ *
62
+ * @since 0.4
63
+ * @stable
64
+ * @example
65
+ * const fn: typeof state.tick.float = state.tick.float;
66
+ * void fn;
67
+ */
68
+ tick: Readonly<{
69
+ float(_init: number): MutableSlot<number>;
70
+ int(_init: number): MutableSlot<number>;
71
+ bool(_init: boolean): MutableSlot<boolean>;
72
+ string(_init: string): MutableSlot<string>;
73
+ }>;
74
+ }>;
75
+ /**
76
+ * Static type of the `state` namespace. Runtime implementations satisfy
77
+ * this shape structurally when they are installed on `ComputeContext.state`.
78
+ *
79
+ * @since 0.4
80
+ * @stable
81
+ * @example
82
+ * const ns: StateNamespace = state;
83
+ * void ns;
84
+ */
85
+ export type StateNamespace = typeof state;
86
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/state/state.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAMpD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,KAAK;IACd;;;;;;;;OAQG;iBACU,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;IAIzC;;;;;;;;OAQG;eACQ,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;IAIvC;;;;;;;;OAQG;gBACS,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;IAI1C;;;;;;;;OAQG;kBACW,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;IAI1C;;;;;;;;;OASG;;qBAEc,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;mBAG9B,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;oBAG3B,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC;sBAG5B,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;;EAIhD,CAAC;AAEH;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,KAAK,CAAC"}
@@ -0,0 +1,95 @@
1
+ // Copyright (c) 2026 Invinite. Licensed under the MIT License.
2
+ // See the LICENSE file in the repo root for full license text.
3
+ const sentinel = (name) => {
4
+ throw new Error(`${name} called outside an active script step`);
5
+ };
6
+ /**
7
+ * Persistent state slots, Pine `var` semantics. Writes during a tick are
8
+ * tentative and discarded if a later tick replaces the head bar; on bar
9
+ * close the tentative value commits. Reads return the active tentative
10
+ * value for the current step.
11
+ *
12
+ * The runtime replaces this compile-time callable hole with a slot-aware
13
+ * namespace through `ComputeContext.state`.
14
+ *
15
+ * @since 0.4
16
+ * @stable
17
+ * @example
18
+ * const ns: typeof state = state;
19
+ * void ns;
20
+ */
21
+ export const state = Object.freeze({
22
+ /**
23
+ * Allocate or read a persistent number slot.
24
+ *
25
+ * @since 0.4
26
+ * @stable
27
+ * @example
28
+ * const fn: typeof state.float = state.float;
29
+ * void fn;
30
+ */
31
+ float(_init) {
32
+ return sentinel("state.float");
33
+ },
34
+ /**
35
+ * Allocate or read a persistent integer slot.
36
+ *
37
+ * @since 0.4
38
+ * @stable
39
+ * @example
40
+ * const fn: typeof state.int = state.int;
41
+ * void fn;
42
+ */
43
+ int(_init) {
44
+ return sentinel("state.int");
45
+ },
46
+ /**
47
+ * Allocate or read a persistent boolean slot.
48
+ *
49
+ * @since 0.4
50
+ * @stable
51
+ * @example
52
+ * const fn: typeof state.bool = state.bool;
53
+ * void fn;
54
+ */
55
+ bool(_init) {
56
+ return sentinel("state.bool");
57
+ },
58
+ /**
59
+ * Allocate or read a persistent string slot.
60
+ *
61
+ * @since 0.4
62
+ * @stable
63
+ * @example
64
+ * const fn: typeof state.string = state.string;
65
+ * void fn;
66
+ */
67
+ string(_init) {
68
+ return sentinel("state.string");
69
+ },
70
+ /**
71
+ * Tick-persistent state slots, Pine `varip` semantics. Writes commit
72
+ * immediately, even during a tick.
73
+ *
74
+ * @since 0.4
75
+ * @stable
76
+ * @example
77
+ * const fn: typeof state.tick.float = state.tick.float;
78
+ * void fn;
79
+ */
80
+ tick: Object.freeze({
81
+ float(_init) {
82
+ return sentinel("state.tick.float");
83
+ },
84
+ int(_init) {
85
+ return sentinel("state.tick.int");
86
+ },
87
+ bool(_init) {
88
+ return sentinel("state.tick.bool");
89
+ },
90
+ string(_init) {
91
+ return sentinel("state.tick.string");
92
+ },
93
+ }),
94
+ });
95
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/state/state.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,+DAA+D;AAI/D,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAS,EAAE;IACrC,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,uCAAuC,CAAC,CAAC;AACpE,CAAC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;IAC/B;;;;;;;;OAQG;IACH,KAAK,CAAC,KAAa;QACf,OAAO,QAAQ,CAAC,aAAa,CAAC,CAAC;IACnC,CAAC;IAED;;;;;;;;OAQG;IACH,GAAG,CAAC,KAAa;QACb,OAAO,QAAQ,CAAC,WAAW,CAAC,CAAC;IACjC,CAAC;IAED;;;;;;;;OAQG;IACH,IAAI,CAAC,KAAc;QACf,OAAO,QAAQ,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC;IAED;;;;;;;;OAQG;IACH,MAAM,CAAC,KAAa;QAChB,OAAO,QAAQ,CAAC,cAAc,CAAC,CAAC;IACpC,CAAC;IAED;;;;;;;;;OASG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC;QAChB,KAAK,CAAC,KAAa;YACf,OAAO,QAAQ,CAAC,kBAAkB,CAAC,CAAC;QACxC,CAAC;QACD,GAAG,CAAC,KAAa;YACb,OAAO,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QACtC,CAAC;QACD,IAAI,CAAC,KAAc;YACf,OAAO,QAAQ,CAAC,iBAAiB,CAAC,CAAC;QACvC,CAAC;QACD,MAAM,CAAC,KAAa;YAChB,OAAO,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QACzC,CAAC;KACJ,CAAC;CACL,CAAC,CAAC"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Per-entry shape of {@link STATEFUL_PRIMITIVES}. `name` is the
3
+ * fully-qualified call (`ta.ema`, `plot`, `hline`, `alert`); `slot`
4
+ * is `true` for every primitive whose call site needs a compiler-
5
+ * injected slot id, `false` for the stateless helpers that ride along
6
+ * in the set for in-loop diagnostics (currently only `ta.nz`).
7
+ *
8
+ * @since 0.1
9
+ * @stable
10
+ * @example
11
+ * const entry: StatefulPrimitiveEntry = { name: "ta.nz", slot: false };
12
+ */
13
+ export type StatefulPrimitiveEntry = Readonly<{
14
+ name: string;
15
+ slot: boolean;
16
+ }>;
17
+ /**
18
+ * Frozen set of every fully-qualified call name the compiler tracks for
19
+ * static-analysis (`stateful-call-inside-loop`) and slot-id injection
20
+ * (PLAN.md §5.5). Each entry carries a `slot` flag: `slot: true`
21
+ * primitives allocate per-callsite hidden state and get a string-literal
22
+ * slot id injected as their first argument; `slot: false` primitives are
23
+ * pure helpers that ride along in the set because Pine still forbids
24
+ * them inside loops (e.g. `ta.nz`).
25
+ *
26
+ * Phase 1 shipped 12 `slot: true` entries. Phase 2 widens the shape to
27
+ * `{ name, slot }` so `ta.nz` (the only stateless Phase-2 cross-functional
28
+ * primitive) can opt out of slot-id injection without losing the
29
+ * in-loop diagnostic. Subsequent Phase-2 batch tasks (Tasks 6–28) each
30
+ * append `slot: true` entries; Phase 3 appends 61 `draw.<camelKind>`
31
+ * entries (all `slot: true`), and Phase 4 appends 8 `state.*` /
32
+ * `state.tick.*` entries plus request primitives. Phase 5 appends alert-condition signalling plus runtime
33
+ * logging/error as stateless loop-diagnostic entries plus `draw.table`
34
+ * as a slot-backed viewport drawing.
35
+ *
36
+ * Locked at `apiVersion: 1` (172 entries). Adding, removing, or renaming
37
+ * an entry is a language change and requires `apiVersion: 2` — see
38
+ * `docs/spec/versioning.md`.
39
+ *
40
+ * @since 0.1
41
+ * @stable
42
+ * @example
43
+ * import { STATEFUL_PRIMITIVES } from "@invinite-org/chartlang-core";
44
+ * for (const entry of STATEFUL_PRIMITIVES) {
45
+ * if (entry.name === "ta.ema" && entry.slot) {
46
+ * // compiler injects an id here
47
+ * }
48
+ * }
49
+ */
50
+ export declare const STATEFUL_PRIMITIVES: ReadonlySet<StatefulPrimitiveEntry>;
51
+ /**
52
+ * Name → entry index of {@link STATEFUL_PRIMITIVES}. The compiler's
53
+ * `callsiteIdInjection` and `statefulCallInLoop` passes consult this map
54
+ * by callee name once per call site — O(1) lookup instead of an O(n) scan
55
+ * over the 172-entry set on every visited call. The map is derived from
56
+ * the same canonical entry list as {@link STATEFUL_PRIMITIVES} so adding
57
+ * a primitive to the set adds it here automatically.
58
+ *
59
+ * Locked at `apiVersion: 1` (172 entries). Adding, removing, or renaming
60
+ * an entry is a language change and requires `apiVersion: 2` — see
61
+ * `docs/spec/versioning.md`.
62
+ *
63
+ * @since 0.2
64
+ * @stable
65
+ * @example
66
+ * import { STATEFUL_PRIMITIVES_BY_NAME } from "@invinite-org/chartlang-core";
67
+ * const entry = STATEFUL_PRIMITIVES_BY_NAME.get("ta.ema");
68
+ * // entry is { name: "ta.ema", slot: true } | undefined
69
+ */
70
+ export declare const STATEFUL_PRIMITIVES_BY_NAME: ReadonlyMap<string, StatefulPrimitiveEntry>;
71
+ //# sourceMappingURL=statefulPrimitives.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statefulPrimitives.d.ts","sourceRoot":"","sources":["../src/statefulPrimitives.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAA;CAAE,CAAC,CAAC;AAoL/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,sBAAsB,CAEnE,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,2BAA2B,EAAE,WAAW,CAAC,MAAM,EAAE,sBAAsB,CAGnB,CAAC"}