@orangecharts/wrun-chart-host 0.15.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +1 -0
  2. package/dist/constants/economic.constants.d.ts +2 -0
  3. package/dist/constants/economic.constants.js +2 -0
  4. package/dist/constants/feature-flags.constants.d.ts +10 -0
  5. package/dist/constants/feature-flags.constants.js +52 -4
  6. package/dist/constants/feature-limits.constants.d.ts +72 -4
  7. package/dist/constants/feature-limits.constants.js +98 -20
  8. package/dist/constants/interval.constants.js +5 -0
  9. package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +12 -0
  10. package/dist/constants/kscript-data-interval-restrictions.constants.js +14 -0
  11. package/dist/constants/typed-width-fold.leaf.d.ts +50 -0
  12. package/dist/constants/typed-width-fold.leaf.js +99 -0
  13. package/dist/constants/typed-width-source.leaf.d.ts +24 -0
  14. package/dist/constants/typed-width-source.leaf.js +126 -0
  15. package/dist/constants/typed-width.leaf.d.ts +57 -0
  16. package/dist/constants/typed-width.leaf.js +78 -0
  17. package/dist/host-env.d.ts +10 -0
  18. package/dist/host-env.js +7 -0
  19. package/dist/host-ports.types.d.ts +11 -0
  20. package/dist/index.d.ts +3 -0
  21. package/dist/index.js +3 -0
  22. package/dist/interfaces/kscript-diagnostics.interface.d.ts +28 -0
  23. package/dist/interfaces/wrun-runtime.interface.d.ts +63 -3
  24. package/dist/interfaces/wrun-runtime.interface.js +11 -0
  25. package/dist/kscript-data/controls/live-trades-merge.util.d.ts +13 -0
  26. package/dist/kscript-data/controls/live-trades-merge.util.js +16 -1
  27. package/dist/market-data/billing.interface.d.ts +12 -45
  28. package/dist/market-data/billing.interface.js +2 -2
  29. package/dist/replay/replayLadder.js +7 -4
  30. package/dist/settings-templates/footprint-rows.d.ts +6 -0
  31. package/dist/settings-templates/footprint-rows.js +6 -0
  32. package/dist/settings-templates/frvp-fields.js +14 -0
  33. package/dist/settings-templates/indicator-fields.js +31 -0
  34. package/dist/settings-templates/tool-tables.generated.js +19 -1
  35. package/dist/utility/chart/__fixtures__/live-bucket-regular-golden.json +1706 -0
  36. package/dist/utility/chart/cache-alignment.util.d.ts +42 -0
  37. package/dist/utility/chart/cache-alignment.util.js +88 -18
  38. package/dist/utility/chart/calendar-interval.util.d.ts +83 -1
  39. package/dist/utility/chart/calendar-interval.util.js +152 -4
  40. package/dist/utility/chart/candle-bar-end.util.d.ts +11 -4
  41. package/dist/utility/chart/candle-bar-end.util.js +17 -6
  42. package/dist/utility/chart/chart-time-domain.util.d.ts +3 -0
  43. package/dist/utility/chart/chart-time-domain.util.js +13 -4
  44. package/dist/utility/chart/feed-interval.util.d.ts +4 -2
  45. package/dist/utility/chart/feed-interval.util.js +5 -2
  46. package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +3 -1
  47. package/dist/utility/chart/fetch-dedupe-policy.util.js +19 -1
  48. package/dist/utility/chart/footprint-display-mode.util.d.ts +2 -0
  49. package/dist/utility/chart/footprint-display-mode.util.js +5 -0
  50. package/dist/utility/chart/governed-lanes-gate.util.d.ts +46 -0
  51. package/dist/utility/chart/governed-lanes-gate.util.js +71 -0
  52. package/dist/utility/chart/governed-lanes-reader-seat.d.ts +14 -0
  53. package/dist/utility/chart/governed-lanes-reader-seat.js +14 -0
  54. package/dist/utility/chart/history-wall.util.d.ts +13 -2
  55. package/dist/utility/chart/history-wall.util.js +11 -4
  56. package/dist/utility/chart/interval-ladder.util.d.ts +5 -2
  57. package/dist/utility/chart/interval-ladder.util.js +44 -4
  58. package/dist/utility/chart/interval-registry.util.d.ts +22 -1
  59. package/dist/utility/chart/interval-registry.util.js +50 -2
  60. package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +32 -4
  61. package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +22 -5
  62. package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +10 -0
  63. package/dist/utility/chart/kscript-drawing-safe-area.util.js +30 -3
  64. package/dist/utility/chart/kscript-legend-entries.util.d.ts +21 -4
  65. package/dist/utility/chart/kscript-legend-entries.util.js +27 -5
  66. package/dist/utility/chart/kscript-main-grid-stages.util.js +74 -24
  67. package/dist/utility/chart/kscript-row-name.leaf.d.ts +13 -0
  68. package/dist/utility/chart/kscript-row-name.leaf.js +18 -0
  69. package/dist/utility/chart/kscript-venue-policy.util.d.ts +61 -26
  70. package/dist/utility/chart/kscript-venue-policy.util.js +138 -37
  71. package/dist/utility/chart/live-bucket.util.d.ts +29 -4
  72. package/dist/utility/chart/live-bucket.util.js +45 -12
  73. package/dist/utility/chart/market-session.util.d.ts +62 -10
  74. package/dist/utility/chart/market-session.util.js +93 -13
  75. package/dist/utility/chart/marketKind.util.d.ts +1 -7
  76. package/dist/utility/chart/marketKind.util.js +6 -8
  77. package/dist/utility/chart/mixed-mode.util.d.ts +17 -0
  78. package/dist/utility/chart/om-target.util.js +6 -4
  79. package/dist/utility/chart/price-precision.util.d.ts +20 -6
  80. package/dist/utility/chart/price-precision.util.js +34 -7
  81. package/dist/utility/chart/profile-frame-window.util.d.ts +15 -0
  82. package/dist/utility/chart/profile-frame-window.util.js +12 -0
  83. package/dist/utility/chart/rth-session.util.d.ts +3 -1
  84. package/dist/utility/chart/rth-session.util.js +3 -1
  85. package/dist/utility/chart/script-source-session.util.d.ts +43 -0
  86. package/dist/utility/chart/script-source-session.util.js +61 -0
  87. package/dist/utility/chart/typed-width-grid.util.d.ts +23 -0
  88. package/dist/utility/chart/typed-width-grid.util.js +203 -0
  89. package/dist/utility/common/transformations.util.d.ts +6 -0
  90. package/dist/utility/common/transformations.util.js +28 -4
  91. package/dist/utility/number-format.util.d.ts +14 -1
  92. package/dist/utility/number-format.util.js +22 -4
  93. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +24 -1
  94. package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +113 -0
  95. package/dist/utility/v2/v2-enums.leaf.js +3 -0
  96. package/dist/utility/wrun/wrun-batched-marks.util.d.ts +9 -3
  97. package/dist/utility/wrun/wrun-batched-marks.util.js +65 -17
  98. package/dist/utility/wrun/wrun-canvases.util.d.ts +4 -2
  99. package/dist/utility/wrun/wrun-canvases.util.js +7 -12
  100. package/dist/utility/wrun/wrun-cap-notice.util.d.ts +5 -0
  101. package/dist/utility/wrun/wrun-cap-notice.util.js +23 -0
  102. package/dist/utility/wrun/wrun-card-style.util.d.ts +1 -1
  103. package/dist/utility/wrun/wrun-card-style.util.js +2 -2
  104. package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +8 -0
  105. package/dist/utility/wrun/wrun-chart-market-facts.util.js +13 -1
  106. package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +10 -0
  107. package/dist/utility/wrun/wrun-child-overlay-id.util.js +24 -0
  108. package/dist/utility/wrun/wrun-cloud-cme-stamp.util.d.ts +72 -0
  109. package/dist/utility/wrun/wrun-cloud-cme-stamp.util.js +151 -0
  110. package/dist/utility/wrun/wrun-color-facts.util.d.ts +3 -3
  111. package/dist/utility/wrun/wrun-color-facts.util.js +8 -5
  112. package/dist/utility/wrun/wrun-colour-tone.lazy.d.ts +20 -0
  113. package/dist/utility/wrun/wrun-colour-tone.lazy.js +23 -0
  114. package/dist/utility/wrun/wrun-colour-tone.util.d.ts +14 -0
  115. package/dist/utility/wrun/wrun-colour-tone.util.js +119 -0
  116. package/dist/utility/wrun/wrun-dark-pool.util.d.ts +3 -2
  117. package/dist/utility/wrun/wrun-dark-pool.util.js +5 -4
  118. package/dist/utility/wrun/wrun-frames.d.ts +1 -1
  119. package/dist/utility/wrun/wrun-frames.js +2 -2
  120. package/dist/utility/wrun/wrun-handles.util.d.ts +1 -1
  121. package/dist/utility/wrun/wrun-handles.util.js +1 -1
  122. package/dist/utility/wrun/wrun-host.service.d.ts +32 -2
  123. package/dist/utility/wrun/wrun-host.service.js +44 -2
  124. package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +20 -0
  125. package/dist/utility/wrun/wrun-hosted-wire-caps.js +85 -2
  126. package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +37 -0
  127. package/dist/utility/wrun/wrun-hosted-wire.util.js +54 -0
  128. package/dist/utility/wrun/wrun-hud-looks.util.d.ts +1 -0
  129. package/dist/utility/wrun/wrun-hud-looks.util.js +6 -11
  130. package/dist/utility/wrun/wrun-integration-route.util.d.ts +24 -0
  131. package/dist/utility/wrun/wrun-integration-route.util.js +19 -0
  132. package/dist/utility/wrun/wrun-live-intake.util.js +17 -1
  133. package/dist/utility/wrun/wrun-live-patch.util.d.ts +6 -1
  134. package/dist/utility/wrun/wrun-live-patch.util.js +10 -4
  135. package/dist/utility/wrun/wrun-live-tick.util.js +59 -4
  136. package/dist/utility/wrun/wrun-overlay-drivers.util.js +3 -0
  137. package/dist/utility/wrun/wrun-overlay-run.util.d.ts +15 -0
  138. package/dist/utility/wrun/wrun-overlay-run.util.js +274 -47
  139. package/dist/utility/wrun/wrun-panel-mount.util.d.ts +1 -1
  140. package/dist/utility/wrun/wrun-panel-mount.util.js +42 -13
  141. package/dist/utility/wrun/wrun-pin-venues.util.js +5 -1
  142. package/dist/utility/wrun/wrun-refusal.util.d.ts +4 -0
  143. package/dist/utility/wrun/wrun-refusal.util.js +102 -13
  144. package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
  145. package/dist/utility/wrun/wrun-registry-errors.util.js +5 -3
  146. package/dist/utility/wrun/wrun-row-source-factory.js +17 -1
  147. package/dist/utility/wrun/wrun-row-source.d.ts +8 -1
  148. package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +1 -1
  149. package/dist/utility/wrun/wrun-sandbox-row-source.js +9 -0
  150. package/dist/utility/wrun/wrun-setting-words.util.d.ts +12 -5
  151. package/dist/utility/wrun/wrun-setting-words.util.js +25 -8
  152. package/dist/utility/wrun/wrun-socket-row-source.d.ts +26 -1
  153. package/dist/utility/wrun/wrun-socket-row-source.js +125 -12
  154. package/dist/utility/wrun/wrun-source-rows.util.d.ts +3 -3
  155. package/dist/utility/wrun/wrun-source-rows.util.js +8 -7
  156. package/dist/utility/wrun/wrun-style-words.util.d.ts +31 -9
  157. package/dist/utility/wrun/wrun-style-words.util.js +46 -15
  158. package/dist/utility/wrun/wrun-trades-lane.util.js +2 -1
  159. package/dist/utility/wrun/wrun-trap-replay.util.d.ts +42 -0
  160. package/dist/utility/wrun/wrun-trap-replay.util.js +63 -0
  161. package/dist/utility/wrun/wrun-volume-profile.util.js +6 -5
  162. package/dist/utility/wrun-display-name.util.d.ts +10 -0
  163. package/dist/utility/wrun-display-name.util.js +21 -0
  164. package/dist/utils/replay/replay-buffer-math.d.ts +2 -0
  165. package/dist/utils/replay/replay-buffer-math.js +2 -0
  166. package/dist/workers/constants/socket-slots.d.ts +1 -1
  167. package/dist/workers/utils/time.worker.util.js +2 -2
  168. package/dist/workers/utils/volume-profile.worker.util.d.ts +9 -0
  169. package/dist/workers/utils/volume-profile.worker.util.js +20 -0
  170. package/dist/workers/wrun/wrun-abi-host.d.ts +3 -0
  171. package/dist/workers/wrun/wrun-abi-host.js +82 -5
  172. package/dist/workers/wrun/wrun-engine-handler.js +53 -4
  173. package/dist/workers/wrun/wrun-trap-frames.leaf.d.ts +28 -0
  174. package/dist/workers/wrun/wrun-trap-frames.leaf.js +108 -0
  175. package/package.json +11 -11
@@ -0,0 +1,108 @@
1
+ /**
2
+ * The wasm call frames of a trap's `error.stack`, in each engine's own words, and the code section start of a module
3
+ * (what the trace replay subtracts to move an engine offset from the prepared bytes to the trace build's own). An
4
+ * import-free leaf: the engine worker's handler parses with it, the specs read it directly.
5
+ *
6
+ * - V8 (Chrome): ` at src/indicator/lowestOf (wasm://wasm/7a6b2c1e:wasm-function[105]:0x1d5a)`, the hex being the
7
+ * module byte offset; Node prints the same frame as `(wasm://wasm/7a6b2c1e:1:7514)`, the column being the module
8
+ * byte offset plus 1. An unnamed function reads `at null.<anonymous> (...)` or `at <anonymous> (...)`.
9
+ * - SpiderMonkey (Firefox): `src/indicator/lowestOf@https://host/a.js line 2 > WebAssembly.instantiate:wasm-function[105]:0x1d5a`.
10
+ * - JavaScriptCore (Safari): `src/indicator/lowestOf@[wasm code]` or `<?>.wasm-function[105]@[wasm code]`: a name or
11
+ * an index, never an offset.
12
+ *
13
+ * `env.abort` builds its Error inside host code, so its stack starts with host frames: the leading host frames are
14
+ * skipped, the wasm frames that follow are collected, and the next host frame ends the list.
15
+ */
16
+ /** The deepest stack the trace replay asks for (raised before guest execution, never at the abort). */
17
+ export const WRUN_TRAP_STACK_LIMIT = 64;
18
+ const V8_FRAME = /^\s*at (?:(?<name>.*?) )?\(?(?<location>wasm:\/\/[^\s()]*)\)?\s*$/;
19
+ const V8_HEX = /:wasm-function\[(?<index>\d+)\]:0x(?<hex>[0-9a-fA-F]+)$/;
20
+ const V8_COLUMN = /:(?<line>\d+):(?<column>\d+)$/;
21
+ const SPIDERMONKEY_FRAME = /^(?<name>[^@]*)@.*:wasm-function\[(?<index>\d+)\]:0x(?<hex>[0-9a-fA-F]+)\s*$/;
22
+ const WEBKIT_FRAME = /^(?<name>[^@]*)@\[wasm code\]\s*$/;
23
+ const WEBKIT_INDEX_NAME = /^(?:<\?>\.)?wasm-function\[(?<index>\d+)\]$/;
24
+ /** A printed name, or none for the engines' placeholders. */
25
+ function frameName(raw) {
26
+ const name = raw?.trim();
27
+ if (!name || name === 'null.<anonymous>' || name === '<anonymous>' || name === 'Object.<anonymous>')
28
+ return undefined;
29
+ return name;
30
+ }
31
+ /** One stack line as a wasm frame, or null when it is a host frame (or no frame at all). */
32
+ function parseFrameLine(line) {
33
+ const v8 = V8_FRAME.exec(line);
34
+ if (v8?.groups) {
35
+ const location = v8.groups.location;
36
+ const name = frameName(v8.groups.name);
37
+ const hex = V8_HEX.exec(location);
38
+ if (hex?.groups) {
39
+ return { index: Number(hex.groups.index), ...(name ? { name } : {}), offset: parseInt(hex.groups.hex, 16) };
40
+ }
41
+ const column = V8_COLUMN.exec(location);
42
+ if (column?.groups && column.groups.line === '1') {
43
+ return { ...(name ? { name } : {}), offset: Number(column.groups.column) - 1 };
44
+ }
45
+ return name ? { name } : {};
46
+ }
47
+ const spider = SPIDERMONKEY_FRAME.exec(line);
48
+ if (spider?.groups) {
49
+ const name = frameName(spider.groups.name);
50
+ return { index: Number(spider.groups.index), ...(name ? { name } : {}), offset: parseInt(spider.groups.hex, 16) };
51
+ }
52
+ const webkit = WEBKIT_FRAME.exec(line);
53
+ if (webkit?.groups) {
54
+ const raw = webkit.groups.name.trim();
55
+ const indexed = WEBKIT_INDEX_NAME.exec(raw);
56
+ if (indexed?.groups)
57
+ return { index: Number(indexed.groups.index) };
58
+ const name = frameName(raw);
59
+ return name ? { name } : {};
60
+ }
61
+ return null;
62
+ }
63
+ /** The wasm frames of a stack, innermost first: leading host frames skipped, the first host frame after a wasm
64
+ * frame ends the list. Empty for a stack with none. */
65
+ export function parseWrunTrapFrames(stack) {
66
+ if (!stack)
67
+ return [];
68
+ const frames = [];
69
+ for (const line of stack.split('\n')) {
70
+ const frame = parseFrameLine(line);
71
+ if (frame === null) {
72
+ // A line that is no frame (the message, a blank) never ends the list; a host frame after wasm frames does.
73
+ if (frames.length > 0 && isHostFrameLine(line))
74
+ break;
75
+ continue;
76
+ }
77
+ frames.push(frame);
78
+ }
79
+ return frames;
80
+ }
81
+ /** A line that is a frame, but not a wasm one. */
82
+ function isHostFrameLine(line) {
83
+ return /^\s*at /.test(line) || /^[^\s@]*@\S/.test(line.trim());
84
+ }
85
+ /** The code section's payload start (a module byte offset), or -1 for bytes that are not a module or have none. */
86
+ export function wrunCodeSectionStart(bytes) {
87
+ if (bytes.length < 8 || bytes[0] !== 0x00 || bytes[1] !== 0x61 || bytes[2] !== 0x73 || bytes[3] !== 0x6d)
88
+ return -1;
89
+ let at = 8;
90
+ while (at < bytes.length) {
91
+ const id = bytes[at++];
92
+ let size = 0;
93
+ let shift = 0;
94
+ for (;;) {
95
+ if (at >= bytes.length || shift > 35)
96
+ return -1;
97
+ const byte = bytes[at++];
98
+ size += (byte & 0x7f) * 2 ** shift;
99
+ if ((byte & 0x80) === 0)
100
+ break;
101
+ shift += 7;
102
+ }
103
+ if (id === 10)
104
+ return at;
105
+ at += size;
106
+ }
107
+ return -1;
108
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orangecharts/wrun-chart-host",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "The wrun chart-host layer shared by the kiyotaka web app and the mobile app: the wrun result reader and painter model, cut from the web app (its reference implementation).",
5
5
  "type": "module",
6
6
  "files": [
@@ -22,23 +22,23 @@
22
22
  "default": "./dist/*.js"
23
23
  }
24
24
  },
25
- "scripts": {
26
- "build": "node scripts/generate-tool-tables.mjs && rm -rf dist && tsc -p tsconfig.build.json && node scripts/esm-dist.mjs dist",
27
- "consumer-check": "node scripts/consumer-check.mjs",
28
- "typecheck": "tsc -p tsconfig.json --noEmit"
29
- },
30
25
  "peerDependencies": {
31
- "@orangecharts/indicator-kit": "0.116.1",
32
- "@orangecharts/orange-v2-pb-common": "12.82.0",
26
+ "@orangecharts/indicator-kit": "0.119.0",
27
+ "@orangecharts/orange-v2-pb-common": "12.84.0",
33
28
  "dayjs": "1.11.23",
34
29
  "lodash-es": "4.18.1"
35
30
  },
36
31
  "devDependencies": {
37
- "@orangecharts/indicator-kit": "0.116.1",
38
- "@orangecharts/orange-v2-pb-common": "12.82.0",
32
+ "@orangecharts/indicator-kit": "0.119.0",
33
+ "@orangecharts/orange-v2-pb-common": "12.84.0",
39
34
  "@types/lodash-es": "4.17.12",
40
35
  "dayjs": "1.11.23",
41
36
  "lodash-es": "4.18.1",
42
37
  "typescript": "5.9.3"
38
+ },
39
+ "scripts": {
40
+ "build": "node scripts/generate-tool-tables.mjs && rm -rf dist && tsc -p tsconfig.build.json && node scripts/esm-dist.mjs dist",
41
+ "consumer-check": "node scripts/consumer-check.mjs",
42
+ "typecheck": "tsc -p tsconfig.json --noEmit"
43
43
  }
44
- }
44
+ }