@orangecharts/wrun-chart-host 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/README.md +72 -0
  2. package/dist/constants/governed-exchanges.constants.d.ts +11 -0
  3. package/dist/constants/governed-exchanges.constants.js +11 -0
  4. package/dist/constants/indicator-sets.constants.d.ts +8 -0
  5. package/dist/constants/indicator-sets.constants.js +8 -0
  6. package/dist/constants/interval.constants.d.ts +34 -0
  7. package/dist/constants/interval.constants.js +121 -0
  8. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.d.ts +28 -0
  9. package/dist/constants/scriptEditor/technicalIndicatorScriptKeys.constants.js +65 -0
  10. package/dist/constants/tpo-color-schemes.constants.d.ts +30 -0
  11. package/dist/constants/tpo-color-schemes.constants.js +32 -0
  12. package/dist/host-env.d.ts +102 -0
  13. package/dist/host-env.js +26 -0
  14. package/dist/index.d.ts +93 -0
  15. package/dist/index.js +96 -0
  16. package/dist/indicators/controls/tpo-letter.util.d.ts +2 -0
  17. package/dist/indicators/controls/tpo-letter.util.js +13 -0
  18. package/dist/indicators/controls/tpo-session.util.d.ts +99 -0
  19. package/dist/indicators/controls/tpo-session.util.js +389 -0
  20. package/dist/interfaces/kscript-diagnostics.interface.d.ts +64 -0
  21. package/dist/interfaces/kscript-diagnostics.interface.js +1 -0
  22. package/dist/interfaces/om-panel-data.interface.d.ts +103 -0
  23. package/dist/interfaces/om-panel-data.interface.js +7 -0
  24. package/dist/interfaces/wrun-runtime.interface.d.ts +2659 -0
  25. package/dist/interfaces/wrun-runtime.interface.js +55 -0
  26. package/dist/utility/chart/calendar-interval.util.d.ts +24 -0
  27. package/dist/utility/chart/calendar-interval.util.js +81 -0
  28. package/dist/utility/chart/candle-bar-end.util.d.ts +15 -0
  29. package/dist/utility/chart/candle-bar-end.util.js +23 -0
  30. package/dist/utility/chart/cme-realtime.util.d.ts +24 -0
  31. package/dist/utility/chart/cme-realtime.util.js +53 -0
  32. package/dist/utility/chart/interval-ladder.util.d.ts +27 -0
  33. package/dist/utility/chart/interval-ladder.util.js +92 -0
  34. package/dist/utility/chart/kscript-drawing-prep.util.d.ts +40 -0
  35. package/dist/utility/chart/kscript-drawing-prep.util.js +184 -0
  36. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +95 -0
  37. package/dist/utility/chart/kscript-drawing-safe-area.util.js +805 -0
  38. package/dist/utility/chart/kscript-legend-entries.util.d.ts +166 -0
  39. package/dist/utility/chart/kscript-legend-entries.util.js +538 -0
  40. package/dist/utility/chart/kscript-output-role.util.d.ts +32 -0
  41. package/dist/utility/chart/kscript-output-role.util.js +215 -0
  42. package/dist/utility/chart/kscript-provenance-keys.util.d.ts +22 -0
  43. package/dist/utility/chart/kscript-provenance-keys.util.js +56 -0
  44. package/dist/utility/chart/kscript-run-result-normalize.util.d.ts +53 -0
  45. package/dist/utility/chart/kscript-run-result-normalize.util.js +476 -0
  46. package/dist/utility/chart/kscript-run-result-shape.util.d.ts +14 -0
  47. package/dist/utility/chart/kscript-run-result-shape.util.js +66 -0
  48. package/dist/utility/chart/kscript-titancharts-container.util.d.ts +29 -0
  49. package/dist/utility/chart/kscript-titancharts-container.util.js +151 -0
  50. package/dist/utility/chart/kscript-viewport-overlays.util.d.ts +83 -0
  51. package/dist/utility/chart/kscript-viewport-overlays.util.js +443 -0
  52. package/dist/utility/chart/om-panel-push-style.util.d.ts +78 -0
  53. package/dist/utility/chart/om-panel-push-style.util.js +301 -0
  54. package/dist/utility/chart/om-panel.util.d.ts +166 -0
  55. package/dist/utility/chart/om-panel.util.js +815 -0
  56. package/dist/utility/chart/om-series.util.d.ts +42 -0
  57. package/dist/utility/chart/om-series.util.js +330 -0
  58. package/dist/utility/chart/om-target.util.d.ts +11 -0
  59. package/dist/utility/chart/om-target.util.js +24 -0
  60. package/dist/utility/chart/om-widget.util.d.ts +148 -0
  61. package/dist/utility/chart/om-widget.util.js +413 -0
  62. package/dist/utility/chart/overlay-output-budget.util.d.ts +16 -0
  63. package/dist/utility/chart/overlay-output-budget.util.js +109 -0
  64. package/dist/utility/chart/overlay-paint-flags.util.d.ts +24 -0
  65. package/dist/utility/chart/overlay-paint-flags.util.js +55 -0
  66. package/dist/utility/chart/profile-row-height.util.d.ts +21 -0
  67. package/dist/utility/chart/profile-row-height.util.js +110 -0
  68. package/dist/utility/chart/session-interval.util.d.ts +1 -0
  69. package/dist/utility/chart/session-interval.util.js +35 -0
  70. package/dist/utility/chart/technical-script-legend-value.util.d.ts +18 -0
  71. package/dist/utility/chart/technical-script-legend-value.util.js +53 -0
  72. package/dist/utility/chart/trading-day.util.d.ts +70 -0
  73. package/dist/utility/chart/trading-day.util.js +238 -0
  74. package/dist/utility/chart/wrun-legend-name.util.d.ts +25 -0
  75. package/dist/utility/chart/wrun-legend-name.util.js +87 -0
  76. package/dist/utility/chart/wrun-run-result.util.d.ts +977 -0
  77. package/dist/utility/chart/wrun-run-result.util.js +5179 -0
  78. package/dist/utility/chart/wrun-visibility-chart.util.d.ts +25 -0
  79. package/dist/utility/chart/wrun-visibility-chart.util.js +22 -0
  80. package/dist/utility/indicators/heatmap-sensitivity.util.d.ts +62 -0
  81. package/dist/utility/indicators/heatmap-sensitivity.util.js +82 -0
  82. package/dist/utility/number-format.util.d.ts +68 -0
  83. package/dist/utility/number-format.util.js +188 -0
  84. package/dist/utility/v2/opra-governed.util.d.ts +1 -0
  85. package/dist/utility/v2/opra-governed.util.js +13 -0
  86. package/dist/utility/wrun/wrun-auto-row.util.d.ts +54 -0
  87. package/dist/utility/wrun/wrun-auto-row.util.js +96 -0
  88. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +341 -0
  89. package/dist/utility/wrun/wrun-batched-marks.util.js +938 -0
  90. package/dist/utility/wrun/wrun-batched-readout.util.d.ts +75 -0
  91. package/dist/utility/wrun/wrun-batched-readout.util.js +171 -0
  92. package/dist/utility/wrun/wrun-box-segment.util.d.ts +185 -0
  93. package/dist/utility/wrun/wrun-box-segment.util.js +570 -0
  94. package/dist/utility/wrun/wrun-build-memo.util.d.ts +133 -0
  95. package/dist/utility/wrun/wrun-build-memo.util.js +301 -0
  96. package/dist/utility/wrun/wrun-builtin-twin-ports.util.d.ts +25 -0
  97. package/dist/utility/wrun/wrun-builtin-twin-ports.util.js +75 -0
  98. package/dist/utility/wrun/wrun-builtin-twin.util.d.ts +9 -0
  99. package/dist/utility/wrun/wrun-builtin-twin.util.js +40 -0
  100. package/dist/utility/wrun/wrun-canvas-cache.util.d.ts +28 -0
  101. package/dist/utility/wrun/wrun-canvas-cache.util.js +56 -0
  102. package/dist/utility/wrun/wrun-canvas-readout.util.d.ts +69 -0
  103. package/dist/utility/wrun/wrun-canvas-readout.util.js +53 -0
  104. package/dist/utility/wrun/wrun-canvases.util.d.ts +295 -0
  105. package/dist/utility/wrun/wrun-canvases.util.js +1432 -0
  106. package/dist/utility/wrun/wrun-cap-notice.util.d.ts +77 -0
  107. package/dist/utility/wrun/wrun-cap-notice.util.js +296 -0
  108. package/dist/utility/wrun/wrun-card-style.util.d.ts +154 -0
  109. package/dist/utility/wrun/wrun-card-style.util.js +539 -0
  110. package/dist/utility/wrun/wrun-chart-context.util.d.ts +89 -0
  111. package/dist/utility/wrun/wrun-chart-context.util.js +213 -0
  112. package/dist/utility/wrun/wrun-chart-names.util.d.ts +23 -0
  113. package/dist/utility/wrun/wrun-chart-names.util.js +33 -0
  114. package/dist/utility/wrun/wrun-chart-time.util.d.ts +12 -0
  115. package/dist/utility/wrun/wrun-chart-time.util.js +23 -0
  116. package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +13 -0
  117. package/dist/utility/wrun/wrun-child-overlay-id.util.js +44 -0
  118. package/dist/utility/wrun/wrun-color-facts.util.d.ts +40 -0
  119. package/dist/utility/wrun/wrun-color-facts.util.js +88 -0
  120. package/dist/utility/wrun/wrun-color-settings.lazy.d.ts +26 -0
  121. package/dist/utility/wrun/wrun-color-settings.lazy.js +9 -0
  122. package/dist/utility/wrun/wrun-color-settings.util.d.ts +351 -0
  123. package/dist/utility/wrun/wrun-color-settings.util.js +1363 -0
  124. package/dist/utility/wrun/wrun-footprint-modes.util.d.ts +23 -0
  125. package/dist/utility/wrun/wrun-footprint-modes.util.js +24 -0
  126. package/dist/utility/wrun/wrun-frames.d.ts +217 -0
  127. package/dist/utility/wrun/wrun-frames.js +1021 -0
  128. package/dist/utility/wrun/wrun-handles.util.d.ts +792 -0
  129. package/dist/utility/wrun/wrun-handles.util.js +2050 -0
  130. package/dist/utility/wrun/wrun-heatmap-cell-budget.util.d.ts +156 -0
  131. package/dist/utility/wrun/wrun-heatmap-cell-budget.util.js +342 -0
  132. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +218 -0
  133. package/dist/utility/wrun/wrun-hosted-wire-caps.js +667 -0
  134. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +40 -0
  135. package/dist/utility/wrun/wrun-hosted-wire.util.js +27 -0
  136. package/dist/utility/wrun/wrun-hover.util.d.ts +182 -0
  137. package/dist/utility/wrun/wrun-hover.util.js +534 -0
  138. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +246 -0
  139. package/dist/utility/wrun/wrun-hud-looks.util.js +587 -0
  140. package/dist/utility/wrun/wrun-integration-budget.util.d.ts +47 -0
  141. package/dist/utility/wrun/wrun-integration-budget.util.js +122 -0
  142. package/dist/utility/wrun/wrun-latest-snapshot.d.ts +19 -0
  143. package/dist/utility/wrun/wrun-latest-snapshot.js +7 -0
  144. package/dist/utility/wrun/wrun-levels-child.util.d.ts +131 -0
  145. package/dist/utility/wrun/wrun-levels-child.util.js +514 -0
  146. package/dist/utility/wrun/wrun-lifecycle.contract.d.ts +75 -0
  147. package/dist/utility/wrun/wrun-lifecycle.contract.js +9 -0
  148. package/dist/utility/wrun/wrun-market-facts.util.d.ts +116 -0
  149. package/dist/utility/wrun/wrun-market-facts.util.js +238 -0
  150. package/dist/utility/wrun/wrun-output-style.util.d.ts +344 -0
  151. package/dist/utility/wrun/wrun-output-style.util.js +1239 -0
  152. package/dist/utility/wrun/wrun-overlay-identity.util.d.ts +84 -0
  153. package/dist/utility/wrun/wrun-overlay-identity.util.js +142 -0
  154. package/dist/utility/wrun/wrun-overlay-result.util.d.ts +120 -0
  155. package/dist/utility/wrun/wrun-overlay-result.util.js +219 -0
  156. package/dist/utility/wrun/wrun-pack.util.d.ts +70 -0
  157. package/dist/utility/wrun/wrun-pack.util.js +301 -0
  158. package/dist/utility/wrun/wrun-pane-format.util.d.ts +180 -0
  159. package/dist/utility/wrun/wrun-pane-format.util.js +299 -0
  160. package/dist/utility/wrun/wrun-panel-style.lazy.d.ts +25 -0
  161. package/dist/utility/wrun/wrun-panel-style.lazy.js +15 -0
  162. package/dist/utility/wrun/wrun-panel-style.util.d.ts +174 -0
  163. package/dist/utility/wrun/wrun-panel-style.util.js +726 -0
  164. package/dist/utility/wrun/wrun-param-values.util.d.ts +69 -0
  165. package/dist/utility/wrun/wrun-param-values.util.js +230 -0
  166. package/dist/utility/wrun/wrun-refusal.util.d.ts +263 -0
  167. package/dist/utility/wrun/wrun-refusal.util.js +1259 -0
  168. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +199 -0
  169. package/dist/utility/wrun/wrun-registry-errors.util.js +257 -0
  170. package/dist/utility/wrun/wrun-render-select.util.d.ts +336 -0
  171. package/dist/utility/wrun/wrun-render-select.util.js +1157 -0
  172. package/dist/utility/wrun/wrun-script-inputs.util.d.ts +434 -0
  173. package/dist/utility/wrun/wrun-script-inputs.util.js +1971 -0
  174. package/dist/utility/wrun/wrun-setting-words.lazy.d.ts +20 -0
  175. package/dist/utility/wrun/wrun-setting-words.lazy.js +9 -0
  176. package/dist/utility/wrun/wrun-setting-words.util.d.ts +79 -0
  177. package/dist/utility/wrun/wrun-setting-words.util.js +176 -0
  178. package/dist/utility/wrun/wrun-socket-row-store.d.ts +98 -0
  179. package/dist/utility/wrun/wrun-socket-row-store.js +417 -0
  180. package/dist/utility/wrun/wrun-style-flags.util.d.ts +18 -0
  181. package/dist/utility/wrun/wrun-style-flags.util.js +21 -0
  182. package/dist/utility/wrun/wrun-style-words.util.d.ts +148 -0
  183. package/dist/utility/wrun/wrun-style-words.util.js +439 -0
  184. package/dist/utility/wrun/wrun-table-look.util.d.ts +125 -0
  185. package/dist/utility/wrun/wrun-table-look.util.js +225 -0
  186. package/dist/utility/wrun/wrun-text-look.util.d.ts +51 -0
  187. package/dist/utility/wrun/wrun-text-look.util.js +227 -0
  188. package/dist/utility/wrun/wrun-text-params.util.d.ts +106 -0
  189. package/dist/utility/wrun/wrun-text-params.util.js +171 -0
  190. package/dist/utility/wrun/wrun-tpo-rows.util.d.ts +71 -0
  191. package/dist/utility/wrun/wrun-tpo-rows.util.js +438 -0
  192. package/dist/utility/wrun/wrun-twin-compute-inputs.util.d.ts +14 -0
  193. package/dist/utility/wrun/wrun-twin-compute-inputs.util.js +58 -0
  194. package/dist/utility/wrun/wrun-visibility-table.d.ts +437 -0
  195. package/dist/utility/wrun/wrun-visibility-table.js +237 -0
  196. package/dist/utility/wrun/wrun-volume-profile.util.d.ts +37 -0
  197. package/dist/utility/wrun/wrun-volume-profile.util.js +278 -0
  198. package/package.json +38 -0
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Overlay-settings predicates for the package-backed Indicator lanes. Leaf
3
+ * module (no imports): the alert resolver, the store's add lane, the
4
+ * analytics envelope and the boot seam read ONE definition of "this
5
+ * TECHNICAL_SCRIPT record is a package, not a script".
6
+ *
7
+ * Identities, by settings key:
8
+ * - `wrunRegistryRef` ({package, version, position}): a registry package the
9
+ * chart's wrun driver computes, on the row source the record's
10
+ * `wrunRunTarget` selects (`'cloud'`: the socket source, else the sandbox;
11
+ * WRUN-PARITY-PLAN C7, `wrunRowSourceKindOf`).
12
+ * - `wrunDraftRef`: the draft lane's identity; accepted by shape (any object).
13
+ * - `wrunRef` ({package, version}): a record persisted before lane parity
14
+ * wave 3 for the protected pipeline (a marketplace mount, a Cloud target),
15
+ * read as a cloud record at add and restore (wrun-cloud-record.util
16
+ * `wrunCloudRecordOf`). During the rollout every persisted cloud row carries
17
+ * it beside `wrunRunTarget` for the builds from before wave 3
18
+ * (wrun-cloud-row-compat.util); the record a driver runs never does.
19
+ */
20
+ /** A record persisted for the protected pipeline (`wrunRef`): the add and
21
+ * restore route hands it to the registry loader, which reads it as the cloud
22
+ * record it is (see the header). Never a lane test: a record carries it only
23
+ * until its first read re-persists it. */
24
+ export declare function isWrunHostedOverlaySettings(settings: unknown): boolean;
25
+ /** A registry Indicator identity (`wrunRegistryRef`) or an editor draft,
26
+ * WHATEVER lane runs it: the alert resolver's question. */
27
+ export declare function isWrunIndicatorOverlaySettings(settings: unknown): boolean;
28
+ /** An editor draft on the chart (`wrunDraftRef`): the author's own Run, session-only. The
29
+ * run seam raises its health warnings for these alone (wrun-run-health.util). */
30
+ export declare function isWrunDraftOverlaySettings(settings: unknown): boolean;
31
+ /** A package overlay the chart's wrun driver computes (the registry lane on
32
+ * either row source, or the draft lane): an Indicator identity no record
33
+ * persisted for the protected pipeline (`wrunRef`, migrated at its first
34
+ * read) carries. */
35
+ export declare function isWrunBrowserOverlaySettings(settings: unknown): boolean;
36
+ /** Any package-backed overlay: the lanes above, or a record persisted for the
37
+ * protected pipeline (`wrunRef`) before its first read migrates it. */
38
+ export declare function isWrunPackageOverlaySettings(settings: unknown): boolean;
39
+ /** A package overlay the WORKSPACE DOCUMENT saves: a registry or a hosted
40
+ * Indicator, never an editor draft (session-only, mounted on the engine
41
+ * alone, skipped by the document append). The window doors
42
+ * (wrun-window-open.util) and every document-based window read accept
43
+ * exactly these: a draft has no row to flag, copy or convert. */
44
+ export declare function isWrunSavedPackageOverlaySettings(settings: unknown): boolean;
45
+ /** The row source a package overlay runs on (WRUN-PARITY-PLAN C7): the
46
+ * record's `wrunRunTarget: 'cloud'` (the author's publishing choice, stamped
47
+ * at mount) selects the socket source, every other record the sandbox. The
48
+ * one read of the field; the row-source factory chooses by it. */
49
+ export declare function wrunRowSourceKindOf(settings: unknown): 'sandbox' | 'socket';
50
+ /** The persisted run target of a cloud Indicator (`'cloud'`), else undefined. */
51
+ export declare function wrunRunTargetOf(settings: unknown): 'cloud' | undefined;
52
+ /** The registry package name an Indicator overlay carries (either lane), or undefined. */
53
+ export declare function wrunRegistryPackageNameOf(settings: unknown): string | undefined;
54
+ /** The registry identity ({package, version}) an Indicator overlay carries
55
+ * (browser lane, or a hosted Indicator on the Cloud target), or undefined
56
+ * (draft overlays, marketplace overlays, scripts). A ref with no version
57
+ * string is treated as unpinned (''): the alerts wire requires a version,
58
+ * so callers must refuse such an overlay. */
59
+ export declare function wrunRegistryRefOf(settings: unknown): {
60
+ package: string;
61
+ version: string;
62
+ } | undefined;
63
+ /** The browser registry lane's version-encoded overlay id (`customScriptId`),
64
+ * like the marketplace wrunSlugFor: an upgrade changes the slug, so
65
+ * recreation plumbing treats it as a new instance. */
66
+ export declare function wrunRegistrySlugFor(packageName: string, version: string): string;
67
+ /** The package an Indicator overlay mounts, whatever row source runs it: the
68
+ * registry identity (the one record both lanes mount), else the wire
69
+ * identity of a record persisted for the protected pipeline (a marketplace
70
+ * mount) before its first read migrates it. Undefined for a draft, a kScript
71
+ * or a built-in. A layout's Indicators are listed, counted, checked and
72
+ * removed by this name. */
73
+ export declare function wrunPackageNameOf(settings: unknown): string | undefined;
74
+ /** A package overlay's synthetic `customScriptId` (`wrun-registry-…`,
75
+ * `wrun-…`, `wrun-draft-…`). It names no script-service doc, so it never
76
+ * goes to a scripts read or into a layout's script refs, even on a stale
77
+ * row whose identity keys were lost. */
78
+ export declare function isWrunScriptSlug(scriptId: unknown): boolean;
79
+ /** The title a package overlay carries for itself, or undefined: its
80
+ * `customName` (the Indicator's display name, stamped at mount and kept by
81
+ * the save), else the plot name both lanes stamp at mount (`meta.plots[0]`).
82
+ * A candidate shaped like a slug or a package address is skipped: a reader
83
+ * falls back to its own generic label instead of showing either. */
84
+ export declare function wrunOverlayTitleOf(settings: unknown): string | undefined;
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Overlay-settings predicates for the package-backed Indicator lanes. Leaf
3
+ * module (no imports): the alert resolver, the store's add lane, the
4
+ * analytics envelope and the boot seam read ONE definition of "this
5
+ * TECHNICAL_SCRIPT record is a package, not a script".
6
+ *
7
+ * Identities, by settings key:
8
+ * - `wrunRegistryRef` ({package, version, position}): a registry package the
9
+ * chart's wrun driver computes, on the row source the record's
10
+ * `wrunRunTarget` selects (`'cloud'`: the socket source, else the sandbox;
11
+ * WRUN-PARITY-PLAN C7, `wrunRowSourceKindOf`).
12
+ * - `wrunDraftRef`: the draft lane's identity; accepted by shape (any object).
13
+ * - `wrunRef` ({package, version}): a record persisted before lane parity
14
+ * wave 3 for the protected pipeline (a marketplace mount, a Cloud target),
15
+ * read as a cloud record at add and restore (wrun-cloud-record.util
16
+ * `wrunCloudRecordOf`). During the rollout every persisted cloud row carries
17
+ * it beside `wrunRunTarget` for the builds from before wave 3
18
+ * (wrun-cloud-row-compat.util); the record a driver runs never does.
19
+ */
20
+ function hasPackageName(ref) {
21
+ if (!ref || typeof ref !== 'object')
22
+ return false;
23
+ const packageName = ref.package;
24
+ return typeof packageName === 'string' && packageName.length > 0;
25
+ }
26
+ function isRefObject(ref) {
27
+ return !!ref && typeof ref === 'object';
28
+ }
29
+ /** The package a record persisted for the protected pipeline names in its wire identity
30
+ * (`wrunRef.package`), or undefined: what the migration on read turns into the registry identity. */
31
+ function persistedWireRefPackageOf(settings) {
32
+ const ref = settings?.wrunRef;
33
+ return hasPackageName(ref) ? ref.package : undefined;
34
+ }
35
+ /** A record persisted for the protected pipeline (`wrunRef`): the add and
36
+ * restore route hands it to the registry loader, which reads it as the cloud
37
+ * record it is (see the header). Never a lane test: a record carries it only
38
+ * until its first read re-persists it. */
39
+ export function isWrunHostedOverlaySettings(settings) {
40
+ return persistedWireRefPackageOf(settings) !== undefined;
41
+ }
42
+ /** A registry Indicator identity (`wrunRegistryRef`) or an editor draft,
43
+ * WHATEVER lane runs it: the alert resolver's question. */
44
+ export function isWrunIndicatorOverlaySettings(settings) {
45
+ const candidate = settings;
46
+ return hasPackageName(candidate?.wrunRegistryRef) || isRefObject(candidate?.wrunDraftRef);
47
+ }
48
+ /** An editor draft on the chart (`wrunDraftRef`): the author's own Run, session-only. The
49
+ * run seam raises its health warnings for these alone (wrun-run-health.util). */
50
+ export function isWrunDraftOverlaySettings(settings) {
51
+ const candidate = settings;
52
+ return isRefObject(candidate?.wrunDraftRef);
53
+ }
54
+ /** A package overlay the chart's wrun driver computes (the registry lane on
55
+ * either row source, or the draft lane): an Indicator identity no record
56
+ * persisted for the protected pipeline (`wrunRef`, migrated at its first
57
+ * read) carries. */
58
+ export function isWrunBrowserOverlaySettings(settings) {
59
+ return isWrunIndicatorOverlaySettings(settings) && persistedWireRefPackageOf(settings) === undefined;
60
+ }
61
+ /** Any package-backed overlay: the lanes above, or a record persisted for the
62
+ * protected pipeline (`wrunRef`) before its first read migrates it. */
63
+ export function isWrunPackageOverlaySettings(settings) {
64
+ return isWrunIndicatorOverlaySettings(settings) || persistedWireRefPackageOf(settings) !== undefined;
65
+ }
66
+ /** A package overlay the WORKSPACE DOCUMENT saves: a registry or a hosted
67
+ * Indicator, never an editor draft (session-only, mounted on the engine
68
+ * alone, skipped by the document append). The window doors
69
+ * (wrun-window-open.util) and every document-based window read accept
70
+ * exactly these: a draft has no row to flag, copy or convert. */
71
+ export function isWrunSavedPackageOverlaySettings(settings) {
72
+ return isWrunPackageOverlaySettings(settings) && !isWrunDraftOverlaySettings(settings);
73
+ }
74
+ /** The row source a package overlay runs on (WRUN-PARITY-PLAN C7): the
75
+ * record's `wrunRunTarget: 'cloud'` (the author's publishing choice, stamped
76
+ * at mount) selects the socket source, every other record the sandbox. The
77
+ * one read of the field; the row-source factory chooses by it. */
78
+ export function wrunRowSourceKindOf(settings) {
79
+ return settings?.wrunRunTarget === 'cloud' ? 'socket' : 'sandbox';
80
+ }
81
+ /** The persisted run target of a cloud Indicator (`'cloud'`), else undefined. */
82
+ export function wrunRunTargetOf(settings) {
83
+ return wrunRowSourceKindOf(settings) === 'socket' ? 'cloud' : undefined;
84
+ }
85
+ /** The registry package name an Indicator overlay carries (either lane), or undefined. */
86
+ export function wrunRegistryPackageNameOf(settings) {
87
+ return wrunRegistryRefOf(settings)?.package;
88
+ }
89
+ /** The registry identity ({package, version}) an Indicator overlay carries
90
+ * (browser lane, or a hosted Indicator on the Cloud target), or undefined
91
+ * (draft overlays, marketplace overlays, scripts). A ref with no version
92
+ * string is treated as unpinned (''): the alerts wire requires a version,
93
+ * so callers must refuse such an overlay. */
94
+ export function wrunRegistryRefOf(settings) {
95
+ const ref = settings?.wrunRegistryRef;
96
+ if (!hasPackageName(ref))
97
+ return undefined;
98
+ const version = ref.version;
99
+ return { package: ref.package, version: typeof version === 'string' ? version : '' };
100
+ }
101
+ /** The browser registry lane's version-encoded overlay id (`customScriptId`),
102
+ * like the marketplace wrunSlugFor: an upgrade changes the slug, so
103
+ * recreation plumbing treats it as a new instance. */
104
+ export function wrunRegistrySlugFor(packageName, version) {
105
+ return `wrun-registry-${`${packageName}-${version}`.replace(/[^a-zA-Z0-9]+/g, '-')}`;
106
+ }
107
+ /** The package an Indicator overlay mounts, whatever row source runs it: the
108
+ * registry identity (the one record both lanes mount), else the wire
109
+ * identity of a record persisted for the protected pipeline (a marketplace
110
+ * mount) before its first read migrates it. Undefined for a draft, a kScript
111
+ * or a built-in. A layout's Indicators are listed, counted, checked and
112
+ * removed by this name. */
113
+ export function wrunPackageNameOf(settings) {
114
+ return wrunRegistryPackageNameOf(settings) ?? persistedWireRefPackageOf(settings);
115
+ }
116
+ /** A package overlay's synthetic `customScriptId` (`wrun-registry-…`,
117
+ * `wrun-…`, `wrun-draft-…`). It names no script-service doc, so it never
118
+ * goes to a scripts read or into a layout's script refs, even on a stale
119
+ * row whose identity keys were lost. */
120
+ export function isWrunScriptSlug(scriptId) {
121
+ return typeof scriptId === 'string' && scriptId.startsWith('wrun-');
122
+ }
123
+ /** A package address (`@scope/name`): a fallback some reads put where a
124
+ * display name belongs, never a title to show. */
125
+ const PACKAGE_ADDRESS_RE = /^@[^\s/]+\/\S+$/;
126
+ /** The title a package overlay carries for itself, or undefined: its
127
+ * `customName` (the Indicator's display name, stamped at mount and kept by
128
+ * the save), else the plot name both lanes stamp at mount (`meta.plots[0]`).
129
+ * A candidate shaped like a slug or a package address is skipped: a reader
130
+ * falls back to its own generic label instead of showing either. */
131
+ export function wrunOverlayTitleOf(settings) {
132
+ const candidate = settings;
133
+ const plots = candidate?.meta?.plots;
134
+ for (const value of [candidate?.customName, Array.isArray(plots) ? plots[0] : undefined]) {
135
+ if (typeof value !== 'string')
136
+ continue;
137
+ const title = value.trim();
138
+ if (title && !isWrunScriptSlug(title) && !PACKAGE_ADDRESS_RE.test(title))
139
+ return title;
140
+ }
141
+ return undefined;
142
+ }
@@ -0,0 +1,120 @@
1
+ /**
2
+ * The canonical wrun result build: the selection lifecycle and the run result over full-range output rows
3
+ * (the shape every integration route consumes), with the chart-name placeholders substituted once for every
4
+ * route. Split out of the run executor (wrun-overlay-run.util, which re-exports it) so the result reader core
5
+ * imports nothing from the chart instance or the stores: it rides the `@orangecharts/wrun-chart-host`
6
+ * package (docs/features/kscript/wrun/wrun-chart-host.md).
7
+ */
8
+ import type { WrunIndicatorMetadata, WrunOutputRow } from '../../interfaces/wrun-runtime.interface.js';
9
+ import { type WrunCandleGroup, type WrunFillPair, type WrunRunResult } from '../chart/wrun-run-result.util.js';
10
+ import { wrunStrategyOf } from './wrun-box-segment.util.js';
11
+ import type { WrunBuildMemo } from './wrun-build-memo.util.js';
12
+ import type { WrunCellRows } from './wrun-canvases.util.js';
13
+ import { type WrunChartNames } from './wrun-chart-context.util.js';
14
+ import { wrunHandlesOf } from './wrun-handles.util.js';
15
+ import { wrunFramesOf } from './wrun-pack.util.js';
16
+ export interface WrunOverlayResultOptions {
17
+ metadata: WrunIndicatorMetadata;
18
+ outputRows: WrunOutputRow[];
19
+ title: string;
20
+ /** The param values the rows were computed with (the sheet's
21
+ * `custom_title` resolves against them; absent = the declared defaults). */
22
+ params?: Readonly<Record<string, number>>;
23
+ /** The text settings the rows were computed with (wrun-5; the legend
24
+ * templates insert the plain words; absent = derived from the settings). */
25
+ texts?: Readonly<Record<string, string>>;
26
+ position: 'onchart' | 'offchart';
27
+ axis: boolean;
28
+ colors?: Record<string, string>;
29
+ fills?: WrunFillPair[];
30
+ candles?: WrunCandleGroup[];
31
+ /** The chart names the run text's `{{symbol}}` / `{{exchange}}` /
32
+ * `{{timeframe}}` placeholders read (wrun-chart-context.util); absent
33
+ * leaves the text as the module wrote it. */
34
+ chartNames?: WrunChartNames;
35
+ /** The rows ran at another interval than the chart's: their timeline is
36
+ * stamped as the result's `combinedTimes` (wrun-run-result.util). */
37
+ runTimeline?: boolean;
38
+ /** WRUN-STYLE (X7, DW23, OT29): the chart's price digits, the legend's
39
+ * rule (`calculatePricePrecision`), handed to the selection's card and
40
+ * widget text and to every child builder that prints a price. */
41
+ priceDigits?: number;
42
+ /** The chart market's size unit (wrunChartSizeUnit): an output whose
43
+ * `visible_by` does not list it mounts nothing, nor the stats rows drawn
44
+ * from it (wrunRowVisibleHere). Absent reads 0, the unknown unit. */
45
+ sizeUnit?: number;
46
+ /** WRUN-STYLE (g6): the run's celled source rows the price canvases
47
+ * (heatmaps, footprints, TPO letters, time-anchored profiles) draw from. */
48
+ cellRows?: WrunCellRows;
49
+ /** A live tick: the heatmaps build from the newest this-many rows only
50
+ * (wrun-run-result.util `canvasTailRows`); full runs never pass it. */
51
+ canvasTailRows?: number;
52
+ /** A live tick: the batched children build the rows at or after this timestamp only, the tick's
53
+ * changed tail (wrun-run-result.util `batchedTailFromTs`); full runs never pass it. */
54
+ batchedTailFromTs?: number;
55
+ /** WRUN-STYLE (g6): the run clock's interval, the chart's exchange and
56
+ * instrument tick for the profile children; the mounted overlay id the
57
+ * levels children name their `beside` partners with. */
58
+ intervalMs?: number;
59
+ exchange?: string;
60
+ priceTick?: number;
61
+ overlayId?: string;
62
+ /** WRUN guardrails G1: the served TPO block for the chart market
63
+ * (WrunCanvasHostFill), only when known. */
64
+ tpoBlockSize?: number;
65
+ /** The legend's note after the args (wrun-run-result.util `legendNote`): an editor draft's
66
+ * "draft · only in this browser" (wrun-draft-legend-note.util), nothing for every other overlay. */
67
+ legendNote?: string;
68
+ /** A live tick's build memo (wrun-build-memo.util); full runs, reseeds and pans leave it absent. */
69
+ buildMemo?: WrunBuildMemo;
70
+ }
71
+ /**
72
+ * The price canvases' host fill (WRUN guardrails G1, read by the auto row
73
+ * resolver): `tpoBlockSize` = the served TPO block for the chart market
74
+ * (`peekTpoBlockSize`: TPO_AGG, else VOLUME_PROFILE_AGG, clamped for the
75
+ * venue; absent on a mirror miss).
76
+ */
77
+ export interface WrunCanvasHostFill {
78
+ tpoBlockSize?: number;
79
+ }
80
+ /** The fill's known fields only (the `priceTick` option's neighbour). */
81
+ export declare function withCanvasHostFill(fill: WrunCanvasHostFill | undefined): WrunCanvasHostFill;
82
+ /** Selection lifecycle + canonical run-result over full-range output rows
83
+ * (the shape every integration route consumes). The chart-name placeholders
84
+ * are substituted here, once, for every route (string slots, label handle
85
+ * text, frame JSON). */
86
+ export declare function buildWrunOverlayRunResult(options: WrunOverlayResultOptions): WrunRunResult;
87
+ /** The attachments a build reads off the rows (the WeakMap carriers a copy does not follow), made plain. */
88
+ export interface WrunResultCaptureAttachments {
89
+ handles: ReturnType<typeof wrunHandlesOf>;
90
+ frames: ReturnType<typeof wrunFramesOf>;
91
+ strategy: ReturnType<typeof wrunStrategyOf>;
92
+ }
93
+ /** One recorded build: the options as the executor passed them (the build memo left out: a cache, not an input),
94
+ * with the rows' attachments made plain, and the result the build produced. Both are copies taken at the build. */
95
+ export interface WrunResultCaptureEntry {
96
+ options: Omit<WrunOverlayResultOptions, 'buildMemo'> & {
97
+ attachments: WrunResultCaptureAttachments;
98
+ };
99
+ result: WrunRunResult;
100
+ }
101
+ /** The newest builds a key keeps (a live session builds on every tick). */
102
+ export declare const WRUN_RESULT_CAPTURE_LIMIT = 8;
103
+ /**
104
+ * The option keys the capture copies: every declared key but the build memo. An executor hands the reader a wider
105
+ * live object (web's integrate options carry the engine instance under `tc`, the mounted meta, the window and the
106
+ * integration facts), and the reader never reads those; a copy of the engine is megabytes per build and, with a lane
107
+ * of trades behind it, more than a rig's process holds (2026-10-17: the TIP corpus run died at 4 GB on the eighth
108
+ * package). A key added to the options must be added here, or the type below fails to compile.
109
+ */
110
+ export declare const WRUN_OVERLAY_RESULT_OPTION_KEYS: readonly ["metadata", "outputRows", "title", "params", "texts", "position", "axis", "colors", "fills", "candles", "chartNames", "runTimeline", "priceDigits", "sizeUnit", "cellRows", "canvasTailRows", "batchedTailFromTs", "intervalMs", "exchange", "priceTick", "overlayId", "tpoBlockSize", "legendNote"];
111
+ /**
112
+ * Record one build on a corpus lane's page (`globalThis.__omRig === true` and the store `__wrunResultCapture` the lane
113
+ * created before the app loaded) under `__wrunResultCapture[<overlay id, else the title>]`, newest last, the last
114
+ * WRUN_RESULT_CAPTURE_LIMIT kept:
115
+ * the declared options the executor passed (WRUN_OVERLAY_RESULT_OPTION_KEYS: the rows with their handles, frames and
116
+ * strategy, nothing an executor rides along that the reader never reads) and the result, which a host's adapter
117
+ * replays to prove the shared reader paints what web paints. Off a rig page it is never called; it never throws into
118
+ * the build.
119
+ */
120
+ export declare function captureWrunOverlayResult(options: WrunOverlayResultOptions, result: WrunRunResult): void;
@@ -0,0 +1,219 @@
1
+ import { buildWrunRunResult, wrunSelectionSheet, } from '../chart/wrun-run-result.util.js';
2
+ import { wrunStrategyOf } from './wrun-box-segment.util.js';
3
+ import { substituteWrunRunText } from './wrun-chart-context.util.js';
4
+ import { wrunHandlesOf } from './wrun-handles.util.js';
5
+ import { wrunFramesOf } from './wrun-pack.util.js';
6
+ /** The fill's known fields only (the `priceTick` option's neighbour). */
7
+ export function withCanvasHostFill(fill) {
8
+ return fill?.tpoBlockSize !== undefined ? { tpoBlockSize: fill.tpoBlockSize } : {};
9
+ }
10
+ /** Selection lifecycle + canonical run-result over full-range output rows
11
+ * (the shape every integration route consumes). The chart-name placeholders
12
+ * are substituted here, once, for every route (string slots, label handle
13
+ * text, frame JSON). */
14
+ export function buildWrunOverlayRunResult(options) {
15
+ // wrun-3 / wrun-4: the handle set, the frames and the strategy output the
16
+ // host hung on these rows (absent under wrun-1 and wrun-2, and for rows no
17
+ // run answered) are read off the host's rows BEFORE the substitution: a
18
+ // substituted rows array is a new array the WeakMap attachments do not
19
+ // follow, so they are passed explicitly.
20
+ const host = { rows: options.outputRows, handles: wrunHandlesOf(options.outputRows) };
21
+ let text = host;
22
+ if (options.chartNames !== undefined) {
23
+ // Names are cosmetic: a substitution that fails for any reason (a frame
24
+ // attachment a spec's partial mock cannot answer, a malformed record)
25
+ // degrades to the host's own text, never to a failed run.
26
+ try {
27
+ // The frame guard judges a frame by the consumers the selection reads (wrunSelectionSheet): a declaration
28
+ // switched off consumes nothing, and none carries the FE-only `visible` a strict frame parser refuses.
29
+ text = substituteWrunRunText({ ...host, frames: wrunFramesOf(options.outputRows) }, options.chartNames, wrunSelectionSheet(options.metadata));
30
+ }
31
+ catch (error) {
32
+ console.warn(`[wrun] chart-name substitution skipped for '${options.metadata.id}':`, error);
33
+ text = host;
34
+ }
35
+ }
36
+ const result = buildWrunRunResult({
37
+ metadata: options.metadata,
38
+ rows: text.rows,
39
+ handles: text.handles,
40
+ ...(text.frames !== undefined ? { frames: text.frames } : {}),
41
+ strategy: wrunStrategyOf(options.outputRows),
42
+ title: options.title,
43
+ ...(options.params !== undefined ? { params: options.params } : {}),
44
+ ...(options.texts !== undefined ? { texts: options.texts } : {}),
45
+ ...(options.legendNote !== undefined ? { legendNote: options.legendNote } : {}),
46
+ ...(options.runTimeline === true ? { runTimeline: true } : {}),
47
+ position: options.position,
48
+ axis: options.axis,
49
+ colors: options.colors,
50
+ fills: options.fills,
51
+ candles: options.candles,
52
+ // WRUN-STYLE: the selection context (DW14 chart names, DW23 / OT29 price
53
+ // digits, the market's size unit for `visible_by`) and the price
54
+ // canvases' inputs (g6), each only when known.
55
+ ...(options.chartNames !== undefined || options.priceDigits !== undefined || options.sizeUnit !== undefined
56
+ ? {
57
+ selectContext: {
58
+ ...(options.chartNames !== undefined ? { chartNames: options.chartNames } : {}),
59
+ ...(options.priceDigits !== undefined ? { priceDigits: options.priceDigits } : {}),
60
+ ...(options.sizeUnit !== undefined ? { sizeUnit: options.sizeUnit } : {}),
61
+ },
62
+ }
63
+ : {}),
64
+ ...(options.cellRows !== undefined ? { cellRows: options.cellRows } : {}),
65
+ ...(options.canvasTailRows !== undefined ? { canvasTailRows: options.canvasTailRows } : {}),
66
+ ...(options.batchedTailFromTs !== undefined ? { batchedTailFromTs: options.batchedTailFromTs } : {}),
67
+ ...(options.intervalMs !== undefined ? { intervalMs: options.intervalMs } : {}),
68
+ ...(options.exchange !== undefined ? { exchange: options.exchange } : {}),
69
+ ...(options.priceTick !== undefined ? { priceTick: options.priceTick } : {}),
70
+ ...(options.overlayId !== undefined ? { overlayId: options.overlayId } : {}),
71
+ // G1: the served TPO block, only when known.
72
+ ...withCanvasHostFill(options),
73
+ ...(options.buildMemo !== undefined ? { buildMemo: options.buildMemo } : {}),
74
+ });
75
+ if (wrunResultCaptureStore() !== undefined)
76
+ captureWrunOverlayResult(options, result);
77
+ return result;
78
+ }
79
+ /** The newest builds a key keeps (a live session builds on every tick). */
80
+ export const WRUN_RESULT_CAPTURE_LIMIT = 8;
81
+ /**
82
+ * The capture store a corpus lane created before the app loaded (`globalThis.__wrunResultCapture = {}` beside
83
+ * `__omRig = true`), else undefined: a perf rig sets `__omRig` for its hooks and creates no store, so its builds
84
+ * copy nothing (2026-10-17: a copy per build cost a 4x-throttled phone rig up to 156 ms on structure-trend-panel,
85
+ * work the BASE build never did). The build never creates the store.
86
+ */
87
+ function wrunResultCaptureStore() {
88
+ const realm = globalThis;
89
+ if (realm.__omRig !== true)
90
+ return undefined;
91
+ const store = realm.__wrunResultCapture;
92
+ return store !== null && typeof store === 'object' ? store : undefined;
93
+ }
94
+ /**
95
+ * A copy a page can hand out as JSON, never the value itself: typed arrays as plain arrays, a function as
96
+ * `{ $fn: name }` (a batched readout formatter rides in a result), a map, a set and a date as plain copies, a shared
97
+ * or circular reference as the one copy, any other object as its own enumerable fields. A copy that fell back to the
98
+ * live value recorded what the integration did to the result afterwards (2026-10-17: big-trades' corpus entries
99
+ * carried `drawingsBudget`, the drawing trim's stamp, because its readout formatter made structured cloning throw).
100
+ */
101
+ function plainCopy(value) {
102
+ const copies = new WeakMap();
103
+ const visit = (node) => {
104
+ if (typeof node === 'function')
105
+ return { $fn: node.name || 'anonymous' };
106
+ if (node === null || typeof node !== 'object')
107
+ return node;
108
+ const known = copies.get(node);
109
+ if (known !== undefined)
110
+ return known;
111
+ if (ArrayBuffer.isView(node) && !(node instanceof DataView)) {
112
+ const out = Array.from(node);
113
+ copies.set(node, out);
114
+ return out;
115
+ }
116
+ if (node instanceof Date)
117
+ return new Date(node.getTime());
118
+ if (node instanceof Map) {
119
+ const out = new Map();
120
+ copies.set(node, out);
121
+ for (const [key, entry] of node)
122
+ out.set(visit(key), visit(entry));
123
+ return out;
124
+ }
125
+ if (node instanceof Set) {
126
+ const out = new Set();
127
+ copies.set(node, out);
128
+ for (const entry of node)
129
+ out.add(visit(entry));
130
+ return out;
131
+ }
132
+ if (Array.isArray(node)) {
133
+ const out = [];
134
+ copies.set(node, out);
135
+ for (const entry of node)
136
+ out.push(visit(entry));
137
+ return out;
138
+ }
139
+ const out = {};
140
+ copies.set(node, out);
141
+ for (const [key, entry] of Object.entries(node))
142
+ out[key] = visit(entry);
143
+ return out;
144
+ };
145
+ return visit(value);
146
+ }
147
+ /**
148
+ * The option keys the capture copies: every declared key but the build memo. An executor hands the reader a wider
149
+ * live object (web's integrate options carry the engine instance under `tc`, the mounted meta, the window and the
150
+ * integration facts), and the reader never reads those; a copy of the engine is megabytes per build and, with a lane
151
+ * of trades behind it, more than a rig's process holds (2026-10-17: the TIP corpus run died at 4 GB on the eighth
152
+ * package). A key added to the options must be added here, or the type below fails to compile.
153
+ */
154
+ export const WRUN_OVERLAY_RESULT_OPTION_KEYS = [
155
+ 'metadata',
156
+ 'outputRows',
157
+ 'title',
158
+ 'params',
159
+ 'texts',
160
+ 'position',
161
+ 'axis',
162
+ 'colors',
163
+ 'fills',
164
+ 'candles',
165
+ 'chartNames',
166
+ 'runTimeline',
167
+ 'priceDigits',
168
+ 'sizeUnit',
169
+ 'cellRows',
170
+ 'canvasTailRows',
171
+ 'batchedTailFromTs',
172
+ 'intervalMs',
173
+ 'exchange',
174
+ 'priceTick',
175
+ 'overlayId',
176
+ 'tpoBlockSize',
177
+ 'legendNote',
178
+ ];
179
+ const WRUN_OPTION_KEYS_COMPLETE = true;
180
+ /**
181
+ * Record one build on a corpus lane's page (`globalThis.__omRig === true` and the store `__wrunResultCapture` the lane
182
+ * created before the app loaded) under `__wrunResultCapture[<overlay id, else the title>]`, newest last, the last
183
+ * WRUN_RESULT_CAPTURE_LIMIT kept:
184
+ * the declared options the executor passed (WRUN_OVERLAY_RESULT_OPTION_KEYS: the rows with their handles, frames and
185
+ * strategy, nothing an executor rides along that the reader never reads) and the result, which a host's adapter
186
+ * replays to prove the shared reader paints what web paints. Off a rig page it is never called; it never throws into
187
+ * the build.
188
+ */
189
+ export function captureWrunOverlayResult(options, result) {
190
+ try {
191
+ if (!WRUN_OPTION_KEYS_COMPLETE)
192
+ return;
193
+ const store = wrunResultCaptureStore();
194
+ if (store === undefined)
195
+ return;
196
+ const key = options.overlayId ?? options.title;
197
+ const list = (store[key] ??= []);
198
+ const inputs = {};
199
+ for (const name of WRUN_OVERLAY_RESULT_OPTION_KEYS)
200
+ if (name in options)
201
+ inputs[name] = options[name];
202
+ list.push({
203
+ options: plainCopy({
204
+ ...inputs,
205
+ attachments: {
206
+ handles: wrunHandlesOf(options.outputRows),
207
+ frames: wrunFramesOf(options.outputRows),
208
+ strategy: wrunStrategyOf(options.outputRows),
209
+ },
210
+ }),
211
+ result: plainCopy(result),
212
+ });
213
+ if (list.length > WRUN_RESULT_CAPTURE_LIMIT)
214
+ list.splice(0, list.length - WRUN_RESULT_CAPTURE_LIMIT);
215
+ }
216
+ catch {
217
+ // The capture is the rig's: never a failure of the build.
218
+ }
219
+ }
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Packed WRUN row transport: turns runtime rows `{ ts, values, cellBlocks? }`
3
+ * into the transferable request buffers the sandbox worker drives from, and
4
+ * unpacks the packed response back into per-row outputs and strings.
5
+ *
6
+ * The layout mirrors the om daemon's packed protocol byte for byte (see
7
+ * `wrun-runtime.interface.ts`), so absent-slot scalar semantics
8
+ * (`wrun_arg_count`, NaN past a row's original argument count), the -1
9
+ * missing-block convention, and the string table's absent (-1) vs
10
+ * present-empty (0) distinction all survive the worker hop.
11
+ *
12
+ * Cell enforcement runs HERE, during packing and before any worker is
13
+ * involved: a block on an input not declared `cellType: "array"` and a block
14
+ * over the input's `max_cells` (counted in TUPLES) both refuse the whole
15
+ * evaluation by name, never truncate. One exception (frozen authoring
16
+ * contract C1.2b): an input declaring `missing: "empty"` reads an oversize
17
+ * block as a PRESENT EMPTY block (0 cells) on that bar alone and the run
18
+ * goes on, the way the same input reads a lane that answered nothing; the
19
+ * block is still never truncated.
20
+ */
21
+ import type { WrunAbiVersion, WrunIndicatorMetadata, WrunOutputRow, WrunPackedRunRequest, WrunWorkerResponse } from '../../interfaces/wrun-runtime.interface.js';
22
+ /** One runtime input row: `values` is the positional scalar block (celled
23
+ * slots carry NaN placeholders); `cellBlocks` maps a celled input index to
24
+ * that bar's flat f64 cell array. An index with no entry is a missing block
25
+ * (`wrun_arg_len` answers -1); an empty array is a zero-cell bar (0).
26
+ * A block is read, never written: the row builder hands the shared host's
27
+ * own array through uncopied, and `packWrunRows` copying it into the ABI
28
+ * buffer is its one copy. */
29
+ export interface WrunInputRow {
30
+ ts: number;
31
+ values: number[];
32
+ cellBlocks?: Map<number, number[]>;
33
+ }
34
+ /** Cell tuple widths per celled source class (f64 cells per source tuple), the shared host's table
35
+ * (`WRUN_HOST_CELL_TUPLE_WIDTHS`): `volume_profile` = [low, high, buy, sell]; `book` = [price,
36
+ * abs(size), side]; `tape` = [offset_ms, price, size, side]; `trade_volume_by_size` = [bucket,
37
+ * buy_usd, sell_usd, buy_count, sell_count]; `intrabar` and `candles` = [offset_ms, open, high,
38
+ * low, close, volume]; `options_chain` = [strike, expiry_ms, side, oi, gamma, delta, mark_iv,
39
+ * underlying, multiplier, vega]. Read at pack time: a run loaded the host first. `max_cells`
40
+ * counts tuples; the packed byte math counts f64s. */
41
+ export declare function wrunCellTupleWidths(): Readonly<Record<string, number>>;
42
+ /** The frozen refusal for a block over its input's `max_cells` (the om contract's code, every
43
+ * host): the evaluation is refused, the block never truncated. An input declaring
44
+ * `missing: "empty"` (C1.2b) reads that bar as an empty block instead. */
45
+ export declare const WRUN_CELL_BLOCK_TOO_LARGE_CODE = "wrun_cell_block_too_large";
46
+ export declare function wrunAbiVersion(metadata: Pick<WrunIndicatorMetadata, 'abi_version'>): WrunAbiVersion;
47
+ export interface WrunPackRowsResult {
48
+ request: Omit<WrunPackedRunRequest, 'id' | 'module' | 'mode'>;
49
+ transfer: ArrayBuffer[];
50
+ }
51
+ /**
52
+ * Pack the rows (and init()'s argument block) for the sheet's ABI.
53
+ * `textParams` is the wrun-5 text channel (wrun-text-params.util
54
+ * `wrunTextParamsForRun`: every text param's plain UTF-8 bytes by init slot);
55
+ * it rides the request structured-cloned, never transferred, because the
56
+ * live session seed keeps the same buffers for every reseed. A sheet that
57
+ * declares a text param under an older ABI refuses here by name, the way
58
+ * celled inputs and frames do.
59
+ */
60
+ export declare function packWrunRows(metadata: WrunIndicatorMetadata, rows: readonly WrunInputRow[], initArgs: readonly number[], textParams?: Readonly<Record<number, Uint8Array>>): WrunPackRowsResult;
61
+ /** Frames belong to the run, keeping each transported row byte-compatible. */
62
+ export declare function attachWrunFrames(rows: ReadonlyArray<WrunOutputRow>, frames: (string | undefined)[]): void;
63
+ export declare function wrunFramesOf(rows: ReadonlyArray<WrunOutputRow>): (string | undefined)[] | undefined;
64
+ /** Unpack a successful worker response against the request's row axis.
65
+ * Non-ready rows carry `outputs: null` and no strings key; on ready rows a
66
+ * string slot decodes to undefined when ABSENT (-1) and '' when present
67
+ * empty, preserving the ABI distinction. */
68
+ export declare function unpackWrunResponse(response: Extract<WrunWorkerResponse, {
69
+ ok: true;
70
+ }>, ts: ArrayLike<number>, outputCount: number, stringSlotCount: number): WrunOutputRow[];