@orangecharts/wrun-chart-host 0.15.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/constants/economic.constants.d.ts +2 -0
- package/dist/constants/economic.constants.js +2 -0
- package/dist/constants/feature-flags.constants.d.ts +13 -5
- package/dist/constants/feature-flags.constants.js +76 -35
- package/dist/constants/feature-limits.constants.d.ts +72 -4
- package/dist/constants/feature-limits.constants.js +104 -24
- package/dist/constants/interval.constants.js +5 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.d.ts +12 -0
- package/dist/constants/kscript-data-interval-restrictions.constants.js +14 -0
- package/dist/constants/marketCapabilities.constants.d.ts +9 -0
- package/dist/constants/marketCapabilities.constants.js +39 -11
- package/dist/constants/typed-indicator-source.leaf.d.ts +7 -0
- package/dist/constants/typed-indicator-source.leaf.js +47 -0
- package/dist/constants/typed-session-history-venue.leaf.d.ts +7 -0
- package/dist/constants/typed-session-history-venue.leaf.js +9 -0
- package/dist/constants/typed-width-fold.leaf.d.ts +52 -0
- package/dist/constants/typed-width-fold.leaf.js +101 -0
- package/dist/constants/typed-width-source.leaf.d.ts +24 -0
- package/dist/constants/typed-width-source.leaf.js +126 -0
- package/dist/constants/typed-width.leaf.d.ts +57 -0
- package/dist/constants/typed-width.leaf.js +78 -0
- package/dist/host-env.d.ts +10 -0
- package/dist/host-env.js +7 -0
- package/dist/host-ports.types.d.ts +23 -17
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/interfaces/kscript-diagnostics.interface.d.ts +35 -0
- package/dist/interfaces/wrun-runtime.interface.d.ts +66 -3
- package/dist/interfaces/wrun-runtime.interface.js +11 -0
- package/dist/kscript-data/controls/live-trades-merge.util.d.ts +13 -0
- package/dist/kscript-data/controls/live-trades-merge.util.js +16 -1
- package/dist/market-data/billing.interface.d.ts +12 -45
- package/dist/market-data/billing.interface.js +2 -2
- package/dist/replay/replayLadder.js +7 -4
- package/dist/settings-templates/footprint-rows.d.ts +6 -0
- package/dist/settings-templates/footprint-rows.js +6 -0
- package/dist/settings-templates/frvp-fields.js +14 -0
- package/dist/settings-templates/indicator-fields.js +36 -0
- package/dist/settings-templates/tool-tables.generated.js +19 -1
- package/dist/utility/chart/__fixtures__/live-bucket-regular-golden.json +1706 -0
- package/dist/utility/chart/cache-alignment.util.d.ts +42 -0
- package/dist/utility/chart/cache-alignment.util.js +88 -18
- package/dist/utility/chart/calendar-interval.util.d.ts +83 -1
- package/dist/utility/chart/calendar-interval.util.js +152 -4
- package/dist/utility/chart/candle-bar-end.util.d.ts +11 -4
- package/dist/utility/chart/candle-bar-end.util.js +17 -6
- package/dist/utility/chart/chart-time-domain.util.d.ts +3 -0
- package/dist/utility/chart/chart-time-domain.util.js +13 -4
- package/dist/utility/chart/feed-interval.util.d.ts +4 -2
- package/dist/utility/chart/feed-interval.util.js +5 -2
- package/dist/utility/chart/fetch-dedupe-policy.util.d.ts +3 -1
- package/dist/utility/chart/fetch-dedupe-policy.util.js +19 -1
- package/dist/utility/chart/footprint-display-mode.util.d.ts +2 -0
- package/dist/utility/chart/footprint-display-mode.util.js +5 -0
- package/dist/utility/chart/governed-lanes-gate.util.d.ts +46 -0
- package/dist/utility/chart/governed-lanes-gate.util.js +71 -0
- package/dist/utility/chart/governed-lanes-reader-seat.d.ts +14 -0
- package/dist/utility/chart/governed-lanes-reader-seat.js +14 -0
- package/dist/utility/chart/history-wall.util.d.ts +13 -2
- package/dist/utility/chart/history-wall.util.js +11 -4
- package/dist/utility/chart/index-mode-admission.util.js +9 -1
- package/dist/utility/chart/index-mode.util.d.ts +2 -2
- package/dist/utility/chart/index-mode.util.js +12 -6
- package/dist/utility/chart/index-otc.leaf.d.ts +37 -0
- package/dist/utility/chart/index-otc.leaf.js +68 -0
- package/dist/utility/chart/interval-ladder.util.d.ts +5 -2
- package/dist/utility/chart/interval-ladder.util.js +44 -4
- package/dist/utility/chart/interval-registry.util.d.ts +22 -1
- package/dist/utility/chart/interval-registry.util.js +50 -2
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.d.ts +32 -4
- package/dist/utility/chart/kscript-data-interval-restriction.leaf.js +22 -5
- package/dist/utility/chart/kscript-drawing-safe-area.util.d.ts +10 -0
- package/dist/utility/chart/kscript-drawing-safe-area.util.js +30 -3
- package/dist/utility/chart/kscript-legend-entries.util.d.ts +21 -4
- package/dist/utility/chart/kscript-legend-entries.util.js +27 -5
- package/dist/utility/chart/kscript-main-grid-stages.util.js +74 -24
- package/dist/utility/chart/kscript-provenance-keys.util.js +6 -0
- package/dist/utility/chart/kscript-row-name.leaf.d.ts +13 -0
- package/dist/utility/chart/kscript-row-name.leaf.js +18 -0
- package/dist/utility/chart/kscript-venue-policy.util.d.ts +61 -26
- package/dist/utility/chart/kscript-venue-policy.util.js +138 -37
- package/dist/utility/chart/live-bucket.util.d.ts +29 -4
- package/dist/utility/chart/live-bucket.util.js +45 -12
- package/dist/utility/chart/market-session-schedule.util.d.ts +19 -0
- package/dist/utility/chart/market-session-schedule.util.js +2 -1
- package/dist/utility/chart/market-session.util.d.ts +62 -10
- package/dist/utility/chart/market-session.util.js +93 -13
- package/dist/utility/chart/marketKind.util.d.ts +11 -12
- package/dist/utility/chart/marketKind.util.js +45 -13
- package/dist/utility/chart/mixed-mode.util.d.ts +18 -0
- package/dist/utility/chart/om-target.util.js +6 -4
- package/dist/utility/chart/price-precision.util.d.ts +20 -6
- package/dist/utility/chart/price-precision.util.js +34 -7
- package/dist/utility/chart/profile-frame-window.util.d.ts +15 -0
- package/dist/utility/chart/profile-frame-window.util.js +12 -0
- package/dist/utility/chart/rth-session.util.d.ts +3 -1
- package/dist/utility/chart/rth-session.util.js +3 -1
- package/dist/utility/chart/script-source-session.util.d.ts +43 -0
- package/dist/utility/chart/script-source-session.util.js +61 -0
- package/dist/utility/chart/typed-width-grid.util.d.ts +23 -0
- package/dist/utility/chart/typed-width-grid.util.js +203 -0
- package/dist/utility/common/transformations.util.d.ts +6 -0
- package/dist/utility/common/transformations.util.js +28 -4
- package/dist/utility/market-events/market-events.util.js +3 -0
- package/dist/utility/number-format.util.d.ts +14 -1
- package/dist/utility/number-format.util.js +22 -4
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.d.ts +24 -1
- package/dist/utility/scriptEditor/wrun-runtime-diagnostics.leaf.js +115 -0
- package/dist/utility/v2/v2-enums.leaf.js +5 -0
- package/dist/utility/wrun/sources/row-lanes/dark_pool.d.ts +2 -1
- package/dist/utility/wrun/sources/row-lanes/dark_pool.js +4 -3
- package/dist/utility/wrun/wrun-batched-marks.util.d.ts +13 -3
- package/dist/utility/wrun/wrun-batched-marks.util.js +96 -17
- package/dist/utility/wrun/wrun-canvases.util.d.ts +4 -2
- package/dist/utility/wrun/wrun-canvases.util.js +7 -12
- package/dist/utility/wrun/wrun-cap-notice.util.d.ts +5 -0
- package/dist/utility/wrun/wrun-cap-notice.util.js +23 -0
- package/dist/utility/wrun/wrun-card-style.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-card-style.util.js +2 -2
- package/dist/utility/wrun/wrun-chart-market-facts.util.d.ts +23 -8
- package/dist/utility/wrun/wrun-chart-market-facts.util.js +24 -9
- package/dist/utility/wrun/wrun-child-overlay-id.util.d.ts +10 -0
- package/dist/utility/wrun/wrun-child-overlay-id.util.js +24 -0
- package/dist/utility/wrun/wrun-cloud-cme-stamp.util.d.ts +72 -0
- package/dist/utility/wrun/wrun-cloud-cme-stamp.util.js +151 -0
- package/dist/utility/wrun/wrun-cme-root-specs.util.d.ts +10 -6
- package/dist/utility/wrun/wrun-cme-root-specs.util.js +19 -13
- package/dist/utility/wrun/wrun-color-facts.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-color-facts.util.js +8 -5
- package/dist/utility/wrun/wrun-colour-tone.lazy.d.ts +20 -0
- package/dist/utility/wrun/wrun-colour-tone.lazy.js +23 -0
- package/dist/utility/wrun/wrun-colour-tone.util.d.ts +14 -0
- package/dist/utility/wrun/wrun-colour-tone.util.js +119 -0
- package/dist/utility/wrun/wrun-dark-pool.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-dark-pool.util.js +5 -4
- package/dist/utility/wrun/wrun-frames.d.ts +1 -1
- package/dist/utility/wrun/wrun-frames.js +2 -2
- package/dist/utility/wrun/wrun-handles.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-handles.util.js +1 -1
- package/dist/utility/wrun/wrun-host.service.d.ts +32 -2
- package/dist/utility/wrun/wrun-host.service.js +44 -2
- package/dist/utility/wrun/wrun-hosted-wire-caps.d.ts +20 -0
- package/dist/utility/wrun/wrun-hosted-wire-caps.js +85 -2
- package/dist/utility/wrun/wrun-hosted-wire.util.d.ts +37 -0
- package/dist/utility/wrun/wrun-hosted-wire.util.js +54 -0
- package/dist/utility/wrun/wrun-hud-looks.util.d.ts +1 -0
- package/dist/utility/wrun/wrun-hud-looks.util.js +6 -11
- package/dist/utility/wrun/wrun-integration-route.util.d.ts +24 -0
- package/dist/utility/wrun/wrun-integration-route.util.js +19 -0
- package/dist/utility/wrun/wrun-live-intake.util.js +17 -1
- package/dist/utility/wrun/wrun-live-patch.util.d.ts +6 -1
- package/dist/utility/wrun/wrun-live-patch.util.js +10 -4
- package/dist/utility/wrun/wrun-live-tick.util.js +64 -5
- package/dist/utility/wrun/wrun-market-size-defaults.leaf.js +40 -6
- package/dist/utility/wrun/wrun-market-size-defaults.util.d.ts +2 -2
- package/dist/utility/wrun/wrun-market-size-defaults.util.js +10 -8
- package/dist/utility/wrun/wrun-overlay-drivers.util.d.ts +3 -0
- package/dist/utility/wrun/wrun-overlay-drivers.util.js +3 -0
- package/dist/utility/wrun/wrun-overlay-run.util.d.ts +17 -0
- package/dist/utility/wrun/wrun-overlay-run.util.js +318 -55
- package/dist/utility/wrun/wrun-panel-mount.util.d.ts +1 -1
- package/dist/utility/wrun/wrun-panel-mount.util.js +42 -13
- package/dist/utility/wrun/wrun-pin-venues.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-pin-venues.util.js +11 -4
- package/dist/utility/wrun/wrun-refusal.util.d.ts +4 -0
- package/dist/utility/wrun/wrun-refusal.util.js +102 -13
- package/dist/utility/wrun/wrun-registry-errors.util.d.ts +5 -3
- package/dist/utility/wrun/wrun-registry-errors.util.js +5 -3
- package/dist/utility/wrun/wrun-row-source-factory.js +17 -1
- package/dist/utility/wrun/wrun-row-source.d.ts +8 -1
- package/dist/utility/wrun/wrun-run-health.util.js +1 -1
- package/dist/utility/wrun/wrun-sandbox-row-source.d.ts +1 -1
- package/dist/utility/wrun/wrun-sandbox-row-source.js +9 -0
- package/dist/utility/wrun/wrun-session-composition.util.d.ts +3 -2
- package/dist/utility/wrun/wrun-session-composition.util.js +3 -2
- package/dist/utility/wrun/wrun-setting-words.util.d.ts +12 -5
- package/dist/utility/wrun/wrun-setting-words.util.js +25 -8
- package/dist/utility/wrun/wrun-socket-row-source.d.ts +26 -1
- package/dist/utility/wrun/wrun-socket-row-source.js +125 -12
- package/dist/utility/wrun/wrun-source-rows.util.d.ts +3 -3
- package/dist/utility/wrun/wrun-source-rows.util.js +8 -7
- package/dist/utility/wrun/wrun-style-words.util.d.ts +31 -9
- package/dist/utility/wrun/wrun-style-words.util.js +46 -15
- package/dist/utility/wrun/wrun-trades-lane.util.js +2 -1
- package/dist/utility/wrun/wrun-trap-replay.util.d.ts +42 -0
- package/dist/utility/wrun/wrun-trap-replay.util.js +63 -0
- package/dist/utility/wrun/wrun-volume-profile.util.js +6 -5
- package/dist/utility/wrun-display-name.util.d.ts +10 -0
- package/dist/utility/wrun-display-name.util.js +21 -0
- package/dist/utils/replay/replay-buffer-math.d.ts +2 -0
- package/dist/utils/replay/replay-buffer-math.js +2 -0
- package/dist/workers/constants/socket-slots.d.ts +1 -1
- package/dist/workers/utils/time.worker.util.js +2 -2
- package/dist/workers/utils/volume-profile.worker.util.d.ts +9 -0
- package/dist/workers/utils/volume-profile.worker.util.js +20 -0
- package/dist/workers/wrun/wrun-abi-host.d.ts +3 -0
- package/dist/workers/wrun/wrun-abi-host.js +82 -5
- package/dist/workers/wrun/wrun-engine-handler.js +53 -4
- package/dist/workers/wrun/wrun-trap-frames.leaf.d.ts +28 -0
- package/dist/workers/wrun/wrun-trap-frames.leaf.js +108 -0
- package/package.json +11 -11
|
@@ -44,9 +44,10 @@
|
|
|
44
44
|
*/
|
|
45
45
|
import { ensureWrunChartHostSharedHost, wrunChartHostEnv } from '../../host-env.js';
|
|
46
46
|
import { createWrunAbiSession, runWrunPackedRequest, WrunLiveOrderError, wrunModuleImportList, } from './wrun-abi-host.js';
|
|
47
|
-
import { wrunModuleKey, } from '../../interfaces/wrun-runtime.interface.js';
|
|
47
|
+
import { attachWrunTrap, wrunModuleKey, wrunTrapOf, } from '../../interfaces/wrun-runtime.interface.js';
|
|
48
48
|
import { clampWrunModuleMemory } from '../../utility/wrun/wrun-memory-clamp.util.js';
|
|
49
49
|
import { wrunSha256Hex } from '../../utility/wrun/wrun-sha256.leaf.js';
|
|
50
|
+
import { parseWrunTrapFrames, WRUN_TRAP_STACK_LIMIT, wrunCodeSectionStart } from './wrun-trap-frames.leaf.js';
|
|
50
51
|
/** How many compiled modules one engine worker keeps by `${sha256}|${abi}`: every package version, draft Run and REPL
|
|
51
52
|
* compile mints a key, and a compiled module is mostly native memory the heap never shows. The client keeps its
|
|
52
53
|
* handles in an LRU of the same size under the same name (wrun-host.service.ts); this one is the worker's own, and
|
|
@@ -73,12 +74,54 @@ class WrunModulePinMismatch extends Error {
|
|
|
73
74
|
* change. Exported for the ABI drive specs that run a module exactly as the worker compiles it.
|
|
74
75
|
*/
|
|
75
76
|
export async function compileWrunModuleBytes(bytes, abi) {
|
|
77
|
+
return WebAssembly.compile((await prepareWrunModuleBytes(bytes, abi)));
|
|
78
|
+
}
|
|
79
|
+
/** The bytes `compileWrunModuleBytes` compiles: clamped, then prepared for the ABI. */
|
|
80
|
+
async function prepareWrunModuleBytes(bytes, abi) {
|
|
76
81
|
const bounded = clampWrunModuleMemory(bytes);
|
|
77
82
|
const hostLoading = ensureWrunChartHostSharedHost();
|
|
78
83
|
if (hostLoading)
|
|
79
84
|
await hostLoading;
|
|
80
85
|
const { prepareModuleBytes } = wrunChartHostEnv().sharedHost();
|
|
81
|
-
return
|
|
86
|
+
return prepareModuleBytes(bounded, abi);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The editor's trap replay (`trace-run`): the trace build's own bytes, checked against their own sha256 (never a
|
|
90
|
+
* sheet pin, never the module cache, never a live session), prepared exactly as a release module is prepared, run
|
|
91
|
+
* once over all rows. The stack limit is raised before the guest runs. A failure's trap record gains its call frames
|
|
92
|
+
* (`trap.frames`), each offset moved from the prepared bytes to the trace build's own by the code section delta (the
|
|
93
|
+
* clamp and the export rewrite both precede the code section and add no function, so one constant moves every code
|
|
94
|
+
* offset and function indexes hold). Answers like a full run.
|
|
95
|
+
*/
|
|
96
|
+
async function runWrunTraceRequest(request, onInstantiated) {
|
|
97
|
+
const sha256 = wrunSha256Hex(request.traceBytes);
|
|
98
|
+
if (sha256 !== request.traceSha256) {
|
|
99
|
+
throw new WrunModulePinMismatch(`WRUN trace bytes (sha256 ${sha256}) do not match the trace build's sha256 ${request.traceSha256}`, sha256);
|
|
100
|
+
}
|
|
101
|
+
const prepared = await prepareWrunModuleBytes(request.traceBytes, request.abi);
|
|
102
|
+
const originalStart = wrunCodeSectionStart(request.traceBytes);
|
|
103
|
+
const preparedStart = wrunCodeSectionStart(prepared);
|
|
104
|
+
const delta = originalStart >= 0 && preparedStart >= 0 ? preparedStart - originalStart : null;
|
|
105
|
+
const module = await WebAssembly.compile(prepared);
|
|
106
|
+
const { kind: _kind, traceBytes: _traceBytes, traceSha256: _traceSha256, ...fields } = request;
|
|
107
|
+
// V8's stack depth knob (absent from the DOM types; an engine without it ignores the write).
|
|
108
|
+
const errorType = Error;
|
|
109
|
+
const previousLimit = errorType.stackTraceLimit;
|
|
110
|
+
errorType.stackTraceLimit = Math.max(previousLimit ?? 0, WRUN_TRAP_STACK_LIMIT);
|
|
111
|
+
try {
|
|
112
|
+
return await runWrunPackedRequest({ ...fields, module }, { onInstantiated });
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
const trap = wrunTrapOf(error);
|
|
116
|
+
if (trap !== undefined && error instanceof Error) {
|
|
117
|
+
const frames = parseWrunTrapFrames(error.stack).map(({ offset, ...frame }) => offset !== undefined && delta !== null ? { ...frame, offset: offset - delta } : frame);
|
|
118
|
+
attachWrunTrap(error, { ...trap, frames });
|
|
119
|
+
}
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
errorType.stackTraceLimit = previousLimit;
|
|
124
|
+
}
|
|
82
125
|
}
|
|
83
126
|
/** A full run as the ABI host runs it: the request's module key and bytes turned into the compiled module. */
|
|
84
127
|
function resolvedRunRequest(request, module) {
|
|
@@ -86,7 +129,8 @@ function resolvedRunRequest(request, module) {
|
|
|
86
129
|
return { ...fields, module };
|
|
87
130
|
}
|
|
88
131
|
/** A failure as the client reads it: the error's words, and the module codes (a pin mismatch with the digest found,
|
|
89
|
-
* an engine compile refusal) the client maps back to today's error class and words
|
|
132
|
+
* an engine compile refusal) the client maps back to today's error class and words; a guest trap's record (the ABI
|
|
133
|
+
* host's, `wrunTrapOf`) rides beside the words as `trap`. */
|
|
90
134
|
function failureOf(id, error) {
|
|
91
135
|
const message = error instanceof Error ? error.message : String(error);
|
|
92
136
|
if (error instanceof WrunModulePinMismatch) {
|
|
@@ -94,7 +138,8 @@ function failureOf(id, error) {
|
|
|
94
138
|
}
|
|
95
139
|
if (error instanceof WebAssembly.CompileError)
|
|
96
140
|
return { id, ok: false, error: message, code: 'module-compile-failed' };
|
|
97
|
-
|
|
141
|
+
const trap = wrunTrapOf(error);
|
|
142
|
+
return trap !== undefined ? { id, ok: false, error: message, trap } : { id, ok: false, error: message };
|
|
98
143
|
}
|
|
99
144
|
/** The engine worker's request handler, answering through `post`. The worker's entry makes one, after its env. */
|
|
100
145
|
export function createWrunEngineHandler(post) {
|
|
@@ -205,6 +250,10 @@ export function createWrunEngineHandler(post) {
|
|
|
205
250
|
await loadModule(request);
|
|
206
251
|
return;
|
|
207
252
|
}
|
|
253
|
+
if (request.kind === 'trace-run') {
|
|
254
|
+
postOutput(request.id, await runWrunTraceRequest(request, () => post({ id: request.id, running: true })));
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
208
257
|
if (request.kind === 'live-end') {
|
|
209
258
|
const gate = liveEpochFor(request.sessionKey);
|
|
210
259
|
if (request.epoch === undefined) {
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
/** One wasm frame: each field only when the engine printed it. */
|
|
17
|
+
export interface WrunParsedTrapFrame {
|
|
18
|
+
index?: number;
|
|
19
|
+
name?: string;
|
|
20
|
+
offset?: number;
|
|
21
|
+
}
|
|
22
|
+
/** The deepest stack the trace replay asks for (raised before guest execution, never at the abort). */
|
|
23
|
+
export declare const WRUN_TRAP_STACK_LIMIT = 64;
|
|
24
|
+
/** The wasm frames of a stack, innermost first: leading host frames skipped, the first host frame after a wasm
|
|
25
|
+
* frame ends the list. Empty for a stack with none. */
|
|
26
|
+
export declare function parseWrunTrapFrames(stack: string | undefined): WrunParsedTrapFrame[];
|
|
27
|
+
/** The code section's payload start (a module byte offset), or -1 for bytes that are not a module or have none. */
|
|
28
|
+
export declare function wrunCodeSectionStart(bytes: Uint8Array): number;
|
|
@@ -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.
|
|
3
|
+
"version": "0.17.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.
|
|
32
|
-
"@orangecharts/orange-v2-pb-common": "12.
|
|
26
|
+
"@orangecharts/indicator-kit": "0.121.0",
|
|
27
|
+
"@orangecharts/orange-v2-pb-common": "12.86.0",
|
|
33
28
|
"dayjs": "1.11.23",
|
|
34
29
|
"lodash-es": "4.18.1"
|
|
35
30
|
},
|
|
36
31
|
"devDependencies": {
|
|
37
|
-
"@orangecharts/indicator-kit": "0.
|
|
38
|
-
"@orangecharts/orange-v2-pb-common": "12.
|
|
32
|
+
"@orangecharts/indicator-kit": "0.121.0",
|
|
33
|
+
"@orangecharts/orange-v2-pb-common": "12.86.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
|
+
}
|