@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.
- package/CHANGELOG.md +1694 -0
- package/LICENSE +21 -0
- package/README.md +53 -0
- package/dist/alert/alert.d.ts +32 -0
- package/dist/alert/alert.d.ts.map +1 -0
- package/dist/alert/alert.js +19 -0
- package/dist/alert/alert.js.map +1 -0
- package/dist/alert/index.d.ts +2 -0
- package/dist/alert/index.d.ts.map +1 -0
- package/dist/alert/index.js +4 -0
- package/dist/alert/index.js.map +1 -0
- package/dist/color/colorHelpers.d.ts +65 -0
- package/dist/color/colorHelpers.d.ts.map +1 -0
- package/dist/color/colorHelpers.js +137 -0
- package/dist/color/colorHelpers.js.map +1 -0
- package/dist/color/index.d.ts +37 -0
- package/dist/color/index.d.ts.map +1 -0
- package/dist/color/index.js +23 -0
- package/dist/color/index.js.map +1 -0
- package/dist/color/parseColor.d.ts +48 -0
- package/dist/color/parseColor.d.ts.map +1 -0
- package/dist/color/parseColor.js +141 -0
- package/dist/color/parseColor.js.map +1 -0
- package/dist/define/defineAlert.d.ts +43 -0
- package/dist/define/defineAlert.d.ts.map +1 -0
- package/dist/define/defineAlert.js +49 -0
- package/dist/define/defineAlert.js.map +1 -0
- package/dist/define/defineAlertCondition.d.ts +65 -0
- package/dist/define/defineAlertCondition.d.ts.map +1 -0
- package/dist/define/defineAlertCondition.js +64 -0
- package/dist/define/defineAlertCondition.js.map +1 -0
- package/dist/define/defineDrawing.d.ts +62 -0
- package/dist/define/defineDrawing.d.ts.map +1 -0
- package/dist/define/defineDrawing.js +67 -0
- package/dist/define/defineDrawing.js.map +1 -0
- package/dist/define/defineIndicator.d.ts +48 -0
- package/dist/define/defineIndicator.d.ts.map +1 -0
- package/dist/define/defineIndicator.js +54 -0
- package/dist/define/defineIndicator.js.map +1 -0
- package/dist/define/index.d.ts +6 -0
- package/dist/define/index.d.ts.map +1 -0
- package/dist/define/index.js +7 -0
- package/dist/define/index.js.map +1 -0
- package/dist/define/overrides.d.ts +102 -0
- package/dist/define/overrides.d.ts.map +1 -0
- package/dist/define/overrides.js +4 -0
- package/dist/define/overrides.js.map +1 -0
- package/dist/draw/buckets.d.ts +57 -0
- package/dist/draw/buckets.d.ts.map +1 -0
- package/dist/draw/buckets.js +110 -0
- package/dist/draw/buckets.js.map +1 -0
- package/dist/draw/draw.d.ts +128 -0
- package/dist/draw/draw.d.ts.map +1 -0
- package/dist/draw/draw.js +40 -0
- package/dist/draw/draw.js.map +1 -0
- package/dist/draw/drawingKind.d.ts +80 -0
- package/dist/draw/drawingKind.d.ts.map +1 -0
- package/dist/draw/drawingKind.js +177 -0
- package/dist/draw/drawingKind.js.map +1 -0
- package/dist/draw/drawingState.d.ts +1420 -0
- package/dist/draw/drawingState.d.ts.map +1 -0
- package/dist/draw/drawingState.js +4 -0
- package/dist/draw/drawingState.js.map +1 -0
- package/dist/draw/drawingStyle.d.ts +219 -0
- package/dist/draw/drawingStyle.d.ts.map +1 -0
- package/dist/draw/drawingStyle.js +4 -0
- package/dist/draw/drawingStyle.js.map +1 -0
- package/dist/draw/handle.d.ts +32 -0
- package/dist/draw/handle.d.ts.map +1 -0
- package/dist/draw/handle.js +4 -0
- package/dist/draw/handle.js.map +1 -0
- package/dist/draw/index.d.ts +13 -0
- package/dist/draw/index.d.ts.map +1 -0
- package/dist/draw/index.js +7 -0
- package/dist/draw/index.js.map +1 -0
- package/dist/draw/table.d.ts +84 -0
- package/dist/draw/table.d.ts.map +1 -0
- package/dist/draw/table.js +22 -0
- package/dist/draw/table.js.map +1 -0
- package/dist/draw/worldPoint.d.ts +114 -0
- package/dist/draw/worldPoint.d.ts.map +1 -0
- package/dist/draw/worldPoint.js +4 -0
- package/dist/draw/worldPoint.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/input/index.d.ts +3 -0
- package/dist/input/index.d.ts.map +1 -0
- package/dist/input/index.js +4 -0
- package/dist/input/index.js.map +1 -0
- package/dist/input/input.d.ts +174 -0
- package/dist/input/input.d.ts.map +1 -0
- package/dist/input/input.js +174 -0
- package/dist/input/input.js.map +1 -0
- package/dist/input/inputDescriptor.d.ts +204 -0
- package/dist/input/inputDescriptor.d.ts.map +1 -0
- package/dist/input/inputDescriptor.js +4 -0
- package/dist/input/inputDescriptor.js.map +1 -0
- package/dist/interval/intervalToSeconds.d.ts +20 -0
- package/dist/interval/intervalToSeconds.d.ts.map +1 -0
- package/dist/interval/intervalToSeconds.js +50 -0
- package/dist/interval/intervalToSeconds.js.map +1 -0
- package/dist/plot/index.d.ts +2 -0
- package/dist/plot/index.d.ts.map +1 -0
- package/dist/plot/index.js +4 -0
- package/dist/plot/index.js.map +1 -0
- package/dist/plot/plot.d.ts +277 -0
- package/dist/plot/plot.d.ts.map +1 -0
- package/dist/plot/plot.js +37 -0
- package/dist/plot/plot.js.map +1 -0
- package/dist/request/index.d.ts +2 -0
- package/dist/request/index.d.ts.map +1 -0
- package/dist/request/index.js +4 -0
- package/dist/request/index.js.map +1 -0
- package/dist/request/request.d.ts +106 -0
- package/dist/request/request.d.ts.map +1 -0
- package/dist/request/request.js +44 -0
- package/dist/request/request.js.map +1 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +4 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/runtime.d.ts +84 -0
- package/dist/runtime/runtime.d.ts.map +1 -0
- package/dist/runtime/runtime.js +72 -0
- package/dist/runtime/runtime.js.map +1 -0
- package/dist/state/index.d.ts +5 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +4 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/mutableSlot.d.ts +25 -0
- package/dist/state/mutableSlot.d.ts.map +1 -0
- package/dist/state/mutableSlot.js +4 -0
- package/dist/state/mutableSlot.js.map +1 -0
- package/dist/state/snapshot.d.ts +108 -0
- package/dist/state/snapshot.d.ts.map +1 -0
- package/dist/state/snapshot.js +4 -0
- package/dist/state/snapshot.js.map +1 -0
- package/dist/state/state.d.ts +86 -0
- package/dist/state/state.d.ts.map +1 -0
- package/dist/state/state.js +95 -0
- package/dist/state/state.js.map +1 -0
- package/dist/statefulPrimitives.d.ts +71 -0
- package/dist/statefulPrimitives.d.ts.map +1 -0
- package/dist/statefulPrimitives.js +234 -0
- package/dist/statefulPrimitives.js.map +1 -0
- package/dist/ta/index.d.ts +2 -0
- package/dist/ta/index.d.ts.map +1 -0
- package/dist/ta/index.js +4 -0
- package/dist/ta/index.js.map +1 -0
- package/dist/ta/ta.d.ts +2476 -0
- package/dist/ta/ta.d.ts.map +1 -0
- package/dist/ta/ta.js +312 -0
- package/dist/ta/ta.js.map +1 -0
- package/dist/time/_lib/dateTimeFormatCache.d.ts +11 -0
- package/dist/time/_lib/dateTimeFormatCache.d.ts.map +1 -0
- package/dist/time/_lib/dateTimeFormatCache.js +22 -0
- package/dist/time/_lib/dateTimeFormatCache.js.map +1 -0
- package/dist/time/index.d.ts +7 -0
- package/dist/time/index.d.ts.map +1 -0
- package/dist/time/index.js +8 -0
- package/dist/time/index.js.map +1 -0
- package/dist/time/nyDayKey.d.ts +24 -0
- package/dist/time/nyDayKey.d.ts.map +1 -0
- package/dist/time/nyDayKey.js +49 -0
- package/dist/time/nyDayKey.js.map +1 -0
- package/dist/time/session.d.ts +16 -0
- package/dist/time/session.d.ts.map +1 -0
- package/dist/time/session.js +18 -0
- package/dist/time/session.js.map +1 -0
- package/dist/time/sessionBoundaries.d.ts +40 -0
- package/dist/time/sessionBoundaries.d.ts.map +1 -0
- package/dist/time/sessionBoundaries.js +102 -0
- package/dist/time/sessionBoundaries.js.map +1 -0
- package/dist/time/types.d.ts +34 -0
- package/dist/time/types.d.ts.map +1 -0
- package/dist/time/types.js +4 -0
- package/dist/time/types.js.map +1 -0
- package/dist/time/weekKey.d.ts +11 -0
- package/dist/time/weekKey.d.ts.map +1 -0
- package/dist/time/weekKey.js +25 -0
- package/dist/time/weekKey.js.map +1 -0
- package/dist/time/weekday.d.ts +12 -0
- package/dist/time/weekday.d.ts.map +1 -0
- package/dist/time/weekday.js +22 -0
- package/dist/time/weekday.js.map +1 -0
- package/dist/types.d.ts +464 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/views/barstate.d.ts +40 -0
- package/dist/views/barstate.d.ts.map +1 -0
- package/dist/views/barstate.js +22 -0
- package/dist/views/barstate.js.map +1 -0
- package/dist/views/index.d.ts +4 -0
- package/dist/views/index.d.ts.map +1 -0
- package/dist/views/index.js +4 -0
- package/dist/views/index.js.map +1 -0
- package/dist/views/syminfo.d.ts +46 -0
- package/dist/views/syminfo.d.ts.map +1 -0
- package/dist/views/syminfo.js +25 -0
- package/dist/views/syminfo.js.map +1 -0
- package/dist/views/timeframe.d.ts +40 -0
- package/dist/views/timeframe.d.ts.map +1 -0
- package/dist/views/timeframe.js +21 -0
- package/dist/views/timeframe.js.map +1 -0
- 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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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 @@
|
|
|
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"}
|