@nimblesite/lsp-profiler-ui 0.0.0-stage → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/out/src/bind-host.d.ts +3 -0
- package/out/src/bind-host.js +52 -0
- package/out/src/bind-host.js.map +1 -0
- package/out/src/context-keys.d.ts +4 -0
- package/out/src/context-keys.js +54 -0
- package/out/src/context-keys.js.map +1 -0
- package/out/src/dap-evaluate.d.ts +84 -0
- package/out/src/dap-evaluate.js +442 -0
- package/out/src/dap-evaluate.js.map +1 -0
- package/out/src/dap-output.d.ts +50 -0
- package/out/src/dap-output.js +177 -0
- package/out/src/dap-output.js.map +1 -0
- package/out/src/debug/adapter-resolution.d.ts +56 -0
- package/out/src/debug/adapter-resolution.js +112 -0
- package/out/src/debug/adapter-resolution.js.map +1 -0
- package/out/src/debug/dap-messages.d.ts +18 -0
- package/out/src/debug/dap-messages.js +71 -0
- package/out/src/debug/dap-messages.js.map +1 -0
- package/out/src/debug/index.d.ts +7 -0
- package/out/src/debug/index.js +27 -0
- package/out/src/debug/index.js.map +1 -0
- package/out/src/debug/launch-config.d.ts +42 -0
- package/out/src/debug/launch-config.js +73 -0
- package/out/src/debug/launch-config.js.map +1 -0
- package/out/src/debug/launch-lifecycle.d.ts +29 -0
- package/out/src/debug/launch-lifecycle.js +40 -0
- package/out/src/debug/launch-lifecycle.js.map +1 -0
- package/out/src/debug/poll.d.ts +25 -0
- package/out/src/debug/poll.js +70 -0
- package/out/src/debug/poll.js.map +1 -0
- package/out/src/debug/profiling.d.ts +34 -0
- package/out/src/debug/profiling.js +81 -0
- package/out/src/debug/profiling.js.map +1 -0
- package/out/src/debug/testing/assertions.d.ts +27 -0
- package/out/src/debug/testing/assertions.js +111 -0
- package/out/src/debug/testing/assertions.js.map +1 -0
- package/out/src/debug/testing/dap-client.d.ts +86 -0
- package/out/src/debug/testing/dap-client.js +204 -0
- package/out/src/debug/testing/dap-client.js.map +1 -0
- package/out/src/debug/testing/index.d.ts +7 -0
- package/out/src/debug/testing/index.js +31 -0
- package/out/src/debug/testing/index.js.map +1 -0
- package/out/src/debug/testing/vscode-harness.d.ts +44 -0
- package/out/src/debug/testing/vscode-harness.js +81 -0
- package/out/src/debug/testing/vscode-harness.js.map +1 -0
- package/out/src/debug/ui-stubs.d.ts +26 -0
- package/out/src/debug/ui-stubs.js +88 -0
- package/out/src/debug/ui-stubs.js.map +1 -0
- package/out/src/debug-link-setup.d.ts +4 -0
- package/out/src/debug-link-setup.js +19 -0
- package/out/src/debug-link-setup.js.map +1 -0
- package/out/src/debug-link-view.d.ts +4 -0
- package/out/src/debug-link-view.js +49 -0
- package/out/src/debug-link-view.js.map +1 -0
- package/out/src/debug-link.d.ts +6 -0
- package/out/src/debug-link.js +95 -0
- package/out/src/debug-link.js.map +1 -0
- package/out/src/debug-selection.d.ts +14 -0
- package/out/src/debug-selection.js +33 -0
- package/out/src/debug-selection.js.map +1 -0
- package/out/src/debuggee-pause.d.ts +11 -0
- package/out/src/debuggee-pause.js +109 -0
- package/out/src/debuggee-pause.js.map +1 -0
- package/out/src/editor-path-key.d.ts +52 -0
- package/out/src/editor-path-key.js +105 -0
- package/out/src/editor-path-key.js.map +1 -0
- package/out/src/failure.d.ts +5 -0
- package/out/src/failure.js +53 -0
- package/out/src/failure.js.map +1 -0
- package/out/src/file-log-sink.d.ts +20 -0
- package/out/src/file-log-sink.js +74 -0
- package/out/src/file-log-sink.js.map +1 -0
- package/out/src/flame-html.d.ts +8 -0
- package/out/src/flame-html.js +104 -0
- package/out/src/flame-html.js.map +1 -0
- package/out/src/flame-model.d.ts +93 -0
- package/out/src/flame-model.js +242 -0
- package/out/src/flame-model.js.map +1 -0
- package/out/src/flame-script-helpers.d.ts +26 -0
- package/out/src/flame-script-helpers.js +71 -0
- package/out/src/flame-script-helpers.js.map +1 -0
- package/out/src/flame-script.d.ts +1 -0
- package/out/src/flame-script.js +332 -0
- package/out/src/flame-script.js.map +1 -0
- package/out/src/flame-time-order.d.ts +14 -0
- package/out/src/flame-time-order.js +112 -0
- package/out/src/flame-time-order.js.map +1 -0
- package/out/src/flamegraph-artifact.d.ts +9 -0
- package/out/src/flamegraph-artifact.js +45 -0
- package/out/src/flamegraph-artifact.js.map +1 -0
- package/out/src/host.d.ts +31 -0
- package/out/src/host.js +6 -0
- package/out/src/host.js.map +1 -0
- package/out/src/ids.d.ts +27 -0
- package/out/src/ids.js +63 -0
- package/out/src/ids.js.map +1 -0
- package/out/src/index.d.ts +42 -0
- package/out/src/index.js +98 -0
- package/out/src/index.js.map +1 -0
- package/out/src/logger.d.ts +50 -0
- package/out/src/logger.js +86 -0
- package/out/src/logger.js.map +1 -0
- package/out/src/memory-autopilot.d.ts +64 -0
- package/out/src/memory-autopilot.js +306 -0
- package/out/src/memory-autopilot.js.map +1 -0
- package/out/src/memory-capture-ids.d.ts +17 -0
- package/out/src/memory-capture-ids.js +45 -0
- package/out/src/memory-capture-ids.js.map +1 -0
- package/out/src/memory-capture-ingest.d.ts +15 -0
- package/out/src/memory-capture-ingest.js +84 -0
- package/out/src/memory-capture-ingest.js.map +1 -0
- package/out/src/memory-capture-legs.d.ts +4 -0
- package/out/src/memory-capture-legs.js +55 -0
- package/out/src/memory-capture-legs.js.map +1 -0
- package/out/src/memory-capture-present.d.ts +32 -0
- package/out/src/memory-capture-present.js +71 -0
- package/out/src/memory-capture-present.js.map +1 -0
- package/out/src/memory-capture-roundtrip.d.ts +17 -0
- package/out/src/memory-capture-roundtrip.js +75 -0
- package/out/src/memory-capture-roundtrip.js.map +1 -0
- package/out/src/memory-capture-state.d.ts +23 -0
- package/out/src/memory-capture-state.js +89 -0
- package/out/src/memory-capture-state.js.map +1 -0
- package/out/src/memory-capture-types.d.ts +28 -0
- package/out/src/memory-capture-types.js +70 -0
- package/out/src/memory-capture-types.js.map +1 -0
- package/out/src/memory-capture.d.ts +24 -0
- package/out/src/memory-capture.js +51 -0
- package/out/src/memory-capture.js.map +1 -0
- package/out/src/memory-dashboard-html.d.ts +3 -0
- package/out/src/memory-dashboard-html.js +327 -0
- package/out/src/memory-dashboard-html.js.map +1 -0
- package/out/src/memory-dashboard-mapping.d.ts +34 -0
- package/out/src/memory-dashboard-mapping.js +135 -0
- package/out/src/memory-dashboard-mapping.js.map +1 -0
- package/out/src/memory-dashboard.d.ts +82 -0
- package/out/src/memory-dashboard.js +142 -0
- package/out/src/memory-dashboard.js.map +1 -0
- package/out/src/memory-decorations.d.ts +61 -0
- package/out/src/memory-decorations.js +247 -0
- package/out/src/memory-decorations.js.map +1 -0
- package/out/src/memory-finalize.d.ts +25 -0
- package/out/src/memory-finalize.js +207 -0
- package/out/src/memory-finalize.js.map +1 -0
- package/out/src/memory-guidance.d.ts +14 -0
- package/out/src/memory-guidance.js +36 -0
- package/out/src/memory-guidance.js.map +1 -0
- package/out/src/memory-inspect-commands.d.ts +20 -0
- package/out/src/memory-inspect-commands.js +114 -0
- package/out/src/memory-inspect-commands.js.map +1 -0
- package/out/src/memory-launch-direct.d.ts +12 -0
- package/out/src/memory-launch-direct.js +74 -0
- package/out/src/memory-launch-direct.js.map +1 -0
- package/out/src/memory-launch.d.ts +4 -0
- package/out/src/memory-launch.js +92 -0
- package/out/src/memory-launch.js.map +1 -0
- package/out/src/memory-leak-offer.d.ts +18 -0
- package/out/src/memory-leak-offer.js +51 -0
- package/out/src/memory-leak-offer.js.map +1 -0
- package/out/src/memory-profiler.d.ts +27 -0
- package/out/src/memory-profiler.js +71 -0
- package/out/src/memory-profiler.js.map +1 -0
- package/out/src/memory-ref-graph.d.ts +62 -0
- package/out/src/memory-ref-graph.js +248 -0
- package/out/src/memory-ref-graph.js.map +1 -0
- package/out/src/memory-ref-picker.d.ts +21 -0
- package/out/src/memory-ref-picker.js +103 -0
- package/out/src/memory-ref-picker.js.map +1 -0
- package/out/src/memory-registration.d.ts +4 -0
- package/out/src/memory-registration.js +63 -0
- package/out/src/memory-registration.js.map +1 -0
- package/out/src/memory-start-core.d.ts +8 -0
- package/out/src/memory-start-core.js +165 -0
- package/out/src/memory-start-core.js.map +1 -0
- package/out/src/memory-start-stop-commands.d.ts +10 -0
- package/out/src/memory-start-stop-commands.js +75 -0
- package/out/src/memory-start-stop-commands.js.map +1 -0
- package/out/src/memory-start.d.ts +6 -0
- package/out/src/memory-start.js +13 -0
- package/out/src/memory-start.js.map +1 -0
- package/out/src/memory-status.d.ts +24 -0
- package/out/src/memory-status.js +135 -0
- package/out/src/memory-status.js.map +1 -0
- package/out/src/palette-vscode.d.ts +2 -0
- package/out/src/palette-vscode.js +50 -0
- package/out/src/palette-vscode.js.map +1 -0
- package/out/src/palette.d.ts +70 -0
- package/out/src/palette.js +150 -0
- package/out/src/palette.js.map +1 -0
- package/out/src/process-bind-panel.d.ts +11 -0
- package/out/src/process-bind-panel.js +65 -0
- package/out/src/process-bind-panel.js.map +1 -0
- package/out/src/process-commands.d.ts +5 -0
- package/out/src/process-commands.js +112 -0
- package/out/src/process-commands.js.map +1 -0
- package/out/src/process-context-keys.d.ts +11 -0
- package/out/src/process-context-keys.js +48 -0
- package/out/src/process-context-keys.js.map +1 -0
- package/out/src/process-decoration.d.ts +18 -0
- package/out/src/process-decoration.js +76 -0
- package/out/src/process-decoration.js.map +1 -0
- package/out/src/process-explorer-rows.d.ts +59 -0
- package/out/src/process-explorer-rows.js +47 -0
- package/out/src/process-explorer-rows.js.map +1 -0
- package/out/src/process-explorer.d.ts +66 -0
- package/out/src/process-explorer.js +241 -0
- package/out/src/process-explorer.js.map +1 -0
- package/out/src/process-group-item.d.ts +8 -0
- package/out/src/process-group-item.js +55 -0
- package/out/src/process-group-item.js.map +1 -0
- package/out/src/process-launch-item.d.ts +12 -0
- package/out/src/process-launch-item.js +57 -0
- package/out/src/process-launch-item.js.map +1 -0
- package/out/src/process-launch.d.ts +47 -0
- package/out/src/process-launch.js +205 -0
- package/out/src/process-launch.js.map +1 -0
- package/out/src/process-message-item.d.ts +10 -0
- package/out/src/process-message-item.js +53 -0
- package/out/src/process-message-item.js.map +1 -0
- package/out/src/process-poll.d.ts +26 -0
- package/out/src/process-poll.js +125 -0
- package/out/src/process-poll.js.map +1 -0
- package/out/src/process-reactivity.d.ts +55 -0
- package/out/src/process-reactivity.js +188 -0
- package/out/src/process-reactivity.js.map +1 -0
- package/out/src/process-registration.d.ts +11 -0
- package/out/src/process-registration.js +55 -0
- package/out/src/process-registration.js.map +1 -0
- package/out/src/process-tree-item.d.ts +18 -0
- package/out/src/process-tree-item.js +219 -0
- package/out/src/process-tree-item.js.map +1 -0
- package/out/src/processes-state.d.ts +75 -0
- package/out/src/processes-state.js +76 -0
- package/out/src/processes-state.js.map +1 -0
- package/out/src/profile-on-launch.d.ts +4 -0
- package/out/src/profile-on-launch.js +16 -0
- package/out/src/profile-on-launch.js.map +1 -0
- package/out/src/profile-server.d.ts +24 -0
- package/out/src/profile-server.js +170 -0
- package/out/src/profile-server.js.map +1 -0
- package/out/src/profiler-attach.d.ts +19 -0
- package/out/src/profiler-attach.js +129 -0
- package/out/src/profiler-attach.js.map +1 -0
- package/out/src/profiler-commands.d.ts +8 -0
- package/out/src/profiler-commands.js +110 -0
- package/out/src/profiler-commands.js.map +1 -0
- package/out/src/profiler-decorations.d.ts +74 -0
- package/out/src/profiler-decorations.js +237 -0
- package/out/src/profiler-decorations.js.map +1 -0
- package/out/src/profiler-dispose.d.ts +6 -0
- package/out/src/profiler-dispose.js +20 -0
- package/out/src/profiler-dispose.js.map +1 -0
- package/out/src/profiler-flamegraph-html.d.ts +61 -0
- package/out/src/profiler-flamegraph-html.js +366 -0
- package/out/src/profiler-flamegraph-html.js.map +1 -0
- package/out/src/profiler-format.d.ts +10 -0
- package/out/src/profiler-format.js +28 -0
- package/out/src/profiler-format.js.map +1 -0
- package/out/src/profiler-launch-cooperative.d.ts +16 -0
- package/out/src/profiler-launch-cooperative.js +167 -0
- package/out/src/profiler-launch-cooperative.js.map +1 -0
- package/out/src/profiler-launch.d.ts +29 -0
- package/out/src/profiler-launch.js +123 -0
- package/out/src/profiler-launch.js.map +1 -0
- package/out/src/profiler-results.d.ts +22 -0
- package/out/src/profiler-results.js +104 -0
- package/out/src/profiler-results.js.map +1 -0
- package/out/src/profiler-session-core.d.ts +42 -0
- package/out/src/profiler-session-core.js +116 -0
- package/out/src/profiler-session-core.js.map +1 -0
- package/out/src/profiler-state.d.ts +87 -0
- package/out/src/profiler-state.js +83 -0
- package/out/src/profiler-state.js.map +1 -0
- package/out/src/profiler-status.d.ts +38 -0
- package/out/src/profiler-status.js +163 -0
- package/out/src/profiler-status.js.map +1 -0
- package/out/src/profiler-styles.d.ts +21 -0
- package/out/src/profiler-styles.js +160 -0
- package/out/src/profiler-styles.js.map +1 -0
- package/out/src/profiler-webview.d.ts +95 -0
- package/out/src/profiler-webview.js +243 -0
- package/out/src/profiler-webview.js.map +1 -0
- package/out/src/profiler.d.ts +23 -0
- package/out/src/profiler.js +113 -0
- package/out/src/profiler.js.map +1 -0
- package/out/src/progress-ops.d.ts +24 -0
- package/out/src/progress-ops.js +135 -0
- package/out/src/progress-ops.js.map +1 -0
- package/out/src/reactive-refresh.d.ts +24 -0
- package/out/src/reactive-refresh.js +33 -0
- package/out/src/reactive-refresh.js.map +1 -0
- package/out/src/sample-summary.d.ts +39 -0
- package/out/src/sample-summary.js +32 -0
- package/out/src/sample-summary.js.map +1 -0
- package/out/src/sampled-view.d.ts +15 -0
- package/out/src/sampled-view.js +56 -0
- package/out/src/sampled-view.js.map +1 -0
- package/out/src/server-command.d.ts +4 -0
- package/out/src/server-command.js +14 -0
- package/out/src/server-command.js.map +1 -0
- package/out/src/settings.d.ts +1 -0
- package/out/src/settings.js +22 -0
- package/out/src/settings.js.map +1 -0
- package/out/src/store.d.ts +34 -0
- package/out/src/store.js +64 -0
- package/out/src/store.js.map +1 -0
- package/out/src/testing/cpu-capture-assertions.d.ts +8 -0
- package/out/src/testing/cpu-capture-assertions.js +71 -0
- package/out/src/testing/cpu-capture-assertions.js.map +1 -0
- package/out/src/testing/cpu-capture-contract.d.ts +8 -0
- package/out/src/testing/cpu-capture-contract.js +123 -0
- package/out/src/testing/cpu-capture-contract.js.map +1 -0
- package/out/src/testing/webview-contract-helpers.d.ts +24 -0
- package/out/src/testing/webview-contract-helpers.js +125 -0
- package/out/src/testing/webview-contract-helpers.js.map +1 -0
- package/out/src/testing/webview-contract-leak.d.ts +2 -0
- package/out/src/testing/webview-contract-leak.js +80 -0
- package/out/src/testing/webview-contract-leak.js.map +1 -0
- package/out/src/testing/webview-contract-memory.d.ts +5 -0
- package/out/src/testing/webview-contract-memory.js +221 -0
- package/out/src/testing/webview-contract-memory.js.map +1 -0
- package/out/src/testing/webview-contract-palette.d.ts +6 -0
- package/out/src/testing/webview-contract-palette.js +121 -0
- package/out/src/testing/webview-contract-palette.js.map +1 -0
- package/out/src/testing/webview-contract-panel.d.ts +7 -0
- package/out/src/testing/webview-contract-panel.js +100 -0
- package/out/src/testing/webview-contract-panel.js.map +1 -0
- package/out/src/testing/webview-contract-results.d.ts +6 -0
- package/out/src/testing/webview-contract-results.js +136 -0
- package/out/src/testing/webview-contract-results.js.map +1 -0
- package/out/src/testing/webview-contract.d.ts +18 -0
- package/out/src/testing/webview-contract.js +23 -0
- package/out/src/testing/webview-contract.js.map +1 -0
- package/out/src/timeouts.d.ts +21 -0
- package/out/src/timeouts.js +30 -0
- package/out/src/timeouts.js.map +1 -0
- package/out/src/trace-actions.d.ts +33 -0
- package/out/src/trace-actions.js +135 -0
- package/out/src/trace-actions.js.map +1 -0
- package/out/src/unknown-shape.d.ts +58 -0
- package/out/src/unknown-shape.js +110 -0
- package/out/src/unknown-shape.js.map +1 -0
- package/out/src/wire-adapters.d.ts +18 -0
- package/out/src/wire-adapters.js +160 -0
- package/out/src/wire-adapters.js.map +1 -0
- package/out/src/wire-generated.d.ts +760 -0
- package/out/src/wire-generated.js +38 -0
- package/out/src/wire-generated.js.map +1 -0
- package/package.json +53 -4
- package/scripts/contributions.mjs +187 -0
- package/README.md +0 -3
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Implements [PROF-UI-STATE] + [PROF-UI-STATE].
|
|
3
|
+
// See docs/specs/LSP-PROFILER-SPEC.md
|
|
4
|
+
/**
|
|
5
|
+
* Profiler status-bar lifecycle: hidden → starting spinner → live flame
|
|
6
|
+
* counter. A CPU-profiling start is never silent — between the click and the
|
|
7
|
+
* first sample batch the item shows `$(loading~spin)`, then the LSP's progress
|
|
8
|
+
* notifications drive the live counter.
|
|
9
|
+
*
|
|
10
|
+
* The item renders purely from the store's reactive `profiler` signal
|
|
11
|
+
* ([PROF-UI-PROCESSES]): one `effect` repaints it whenever the session
|
|
12
|
+
* state changes, so there is no imperative "set status" call to forget. Owned
|
|
13
|
+
* here so profiler.ts stays focused on session flow.
|
|
14
|
+
*/
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
+
var ownKeys = function(o) {
|
|
33
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
+
var ar = [];
|
|
35
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
+
return ar;
|
|
37
|
+
};
|
|
38
|
+
return ownKeys(o);
|
|
39
|
+
};
|
|
40
|
+
return function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.bindProfilerStatusBar = bindProfilerStatusBar;
|
|
50
|
+
exports.profilerStatusText = profilerStatusText;
|
|
51
|
+
exports.registerProgressListener = registerProgressListener;
|
|
52
|
+
const vscode = __importStar(require("vscode"));
|
|
53
|
+
const ids_1 = require("./ids");
|
|
54
|
+
const wire_generated_1 = require("./wire-generated");
|
|
55
|
+
const signals_core_1 = require("@preact/signals-core");
|
|
56
|
+
const profiler_format_1 = require("./profiler-format");
|
|
57
|
+
/** LSP notification carrying live profiling progress. */
|
|
58
|
+
const PROFILER_PROGRESS_NOTIFICATION = wire_generated_1.METHODS.CPU_PROGRESS;
|
|
59
|
+
/** Status bar priority — slightly lower than the host's main item. */
|
|
60
|
+
const PROFILER_STATUS_BAR_PRIORITY = 99;
|
|
61
|
+
let statusBarItem = null;
|
|
62
|
+
/** Last-rendered CPU activity, so the e2e seam knows when the item is hidden. */
|
|
63
|
+
let renderedActivity = "idle";
|
|
64
|
+
/**
|
|
65
|
+
* Create the profiler status-bar item (click = stop) and bind it to the store's
|
|
66
|
+
* `profiler` signal. Returns a disposable that tears down both the effect and
|
|
67
|
+
* the item.
|
|
68
|
+
*/
|
|
69
|
+
function bindProfilerStatusBar(store) {
|
|
70
|
+
const item = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, PROFILER_STATUS_BAR_PRIORITY);
|
|
71
|
+
item.command = (0, ids_1.cmd)("profileStop");
|
|
72
|
+
statusBarItem = item;
|
|
73
|
+
renderStatusBar(item, store.profiler.value);
|
|
74
|
+
const disposeEffect = (0, signals_core_1.effect)(() => { renderStatusBar(item, store.profiler.value); });
|
|
75
|
+
return {
|
|
76
|
+
dispose() {
|
|
77
|
+
disposeEffect();
|
|
78
|
+
item.dispose();
|
|
79
|
+
statusBarItem = null;
|
|
80
|
+
renderedActivity = "idle";
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/** Repaint the item to match the current CPU session state. */
|
|
85
|
+
function renderStatusBar(item, session) {
|
|
86
|
+
renderedActivity = session.cpu;
|
|
87
|
+
if (session.cpu === "idle") {
|
|
88
|
+
item.hide();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (session.cpu === "starting") {
|
|
92
|
+
renderStarting(item);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
renderActive(item, session);
|
|
96
|
+
item.show();
|
|
97
|
+
}
|
|
98
|
+
/** [PROF-UI-STATE] Click → spinner, never click → silence. */
|
|
99
|
+
function renderStarting(item) {
|
|
100
|
+
item.text = "$(loading~spin) Profiler starting…";
|
|
101
|
+
item.tooltip = `${(0, ids_1.brand)()} is setting up CPU profiling for the program`;
|
|
102
|
+
item.backgroundColor = undefined;
|
|
103
|
+
item.show();
|
|
104
|
+
}
|
|
105
|
+
/** Active: the live flame counter, warning-tinted so it reads as "running". */
|
|
106
|
+
function renderActive(item, session) {
|
|
107
|
+
item.backgroundColor = new vscode.ThemeColor("statusBarItem.warningBackground");
|
|
108
|
+
if (session.sampleCount === 0) {
|
|
109
|
+
item.text = "$(flame) Profiling...";
|
|
110
|
+
item.tooltip = `Profiling PID ${String(session.cpuPid ?? "?")} — click to stop`;
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const samples = (0, profiler_format_1.formatSampleCount)(session.sampleCount);
|
|
114
|
+
const duration = (0, profiler_format_1.formatProfileDuration)(session.durationSecs);
|
|
115
|
+
item.text = `$(flame) ${samples} samples (${duration})`;
|
|
116
|
+
item.tooltip = `PID ${String(session.cpuPid ?? "?")} — ${samples} samples, ${duration}\nTop: ${session.topFunction ?? "—"}\nClick to stop`;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The profiler status-bar text, or undefined when idle/hidden. E2e seam for
|
|
120
|
+
* [PROF-UI-STATE]/[PROF-UI-STATE]: the lifecycle
|
|
121
|
+
* (starting spinner → live samples) lands here and StatusBarItem state is not
|
|
122
|
+
* readable via the public API.
|
|
123
|
+
*/
|
|
124
|
+
function profilerStatusText() {
|
|
125
|
+
if (renderedActivity === "idle") {
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
return statusBarItem?.text;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Bind the `lspProfiler/cpu/progress` handler to whichever LanguageClient the
|
|
132
|
+
* store currently holds — reactively, so the live sample counter never goes
|
|
133
|
+
* silently dead. The runtime can be re-created within one session (store reset
|
|
134
|
+
* → a brand-new client), and a slow cold start can outlast any fixed timeout,
|
|
135
|
+
* so a one-shot registration is wrong ([PROF-UI-STATE]).
|
|
136
|
+
*
|
|
137
|
+
* `onNotification` may be called before the client connects (the handler is
|
|
138
|
+
* queued), and vscode-languageclient replays it across restarts of the same
|
|
139
|
+
* instance — so registering once per client *instance* is sufficient.
|
|
140
|
+
*/
|
|
141
|
+
function registerProgressListener(store) {
|
|
142
|
+
let boundClient = undefined;
|
|
143
|
+
let registration = undefined;
|
|
144
|
+
const disposeEffect = (0, signals_core_1.effect)(() => {
|
|
145
|
+
const client = store.client.value;
|
|
146
|
+
if (client === undefined || client === boundClient) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
registration?.dispose();
|
|
150
|
+
boundClient = client;
|
|
151
|
+
registration = onProgress(store, client);
|
|
152
|
+
});
|
|
153
|
+
return { dispose() { disposeEffect(); registration?.dispose(); registration = undefined; boundClient = undefined; } };
|
|
154
|
+
}
|
|
155
|
+
/** Feed `client`'s progress for the active CPU session into the store. */
|
|
156
|
+
function onProgress(store, client) {
|
|
157
|
+
return client.onNotification(PROFILER_PROGRESS_NOTIFICATION, (params) => {
|
|
158
|
+
if (params.session_id === store.profiler.value.cpuSessionId) {
|
|
159
|
+
store.profilerProgress(params.sample_count, params.duration_secs, params.top_function ?? "");
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=profiler-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiler-status.js","sourceRoot":"","sources":["../../src/profiler-status.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared CSS and utility functions for profiler webviews.
|
|
3
|
+
*
|
|
4
|
+
* Centralises the theme variables, typography, and common UI component
|
|
5
|
+
* styles used by the flamegraph, reference graph, and memory dashboard.
|
|
6
|
+
*/
|
|
7
|
+
export declare const PROFILER_CSS_VARS = "\n :root {\n --prof-cool: var(--vscode-descriptionForeground, #4a5468);\n --prof-idle: var(--vscode-editorWidget-border, #1a1f2e);\n --prof-info: #60a5fa;\n --prof-bg: var(--vscode-editor-background, #0a0c12);\n --prof-surface: var(--vscode-editorWidget-background, #141820);\n --prof-border: var(--vscode-editorWidget-border, #1a1f2e);\n --prof-text: var(--vscode-editor-foreground, #f0f2f7);\n --prof-text-secondary: var(--vscode-descriptionForeground, #8892a4);\n }";
|
|
8
|
+
export declare const PROFILER_CSS_RESET = "\n * { margin: 0; padding: 0; box-sizing: border-box; }\n body {\n background: var(--prof-bg);\n color: var(--prof-text);\n font-family: 'Space Grotesk', -apple-system, sans-serif;\n }";
|
|
9
|
+
export declare const PROFILER_CSS_CARDS = "\n .summary-cards {\n display: flex;\n gap: 12px;\n margin-bottom: 20px;\n flex-wrap: wrap;\n }\n .card {\n background: var(--prof-surface);\n border: 1px solid var(--prof-border);\n border-radius: 8px;\n padding: 12px 16px;\n min-width: 120px;\n }\n .card .label {\n font-size: 11px;\n color: var(--prof-text-secondary);\n text-transform: uppercase;\n letter-spacing: 0.05em;\n }\n .card .value {\n font-size: 24px;\n font-weight: 600;\n font-family: 'JetBrains Mono', monospace;\n margin-top: 4px;\n }";
|
|
10
|
+
export declare const PROFILER_CSS_TABLE = "\n .data-table {\n width: 100%;\n border-collapse: collapse;\n }\n .data-table th {\n text-align: left;\n font-size: 11px;\n color: var(--prof-text-secondary);\n text-transform: uppercase;\n letter-spacing: 0.05em;\n padding: 6px 8px;\n border-bottom: 1px solid var(--prof-border);\n }\n .data-table td {\n padding: 8px;\n font-family: 'JetBrains Mono', monospace;\n font-size: 13px;\n border-bottom: 1px solid var(--prof-border);\n cursor: pointer;\n }\n .data-table tr:hover td { background: var(--prof-surface); }\n .bar-cell { position: relative; width: 160px; }\n .bar {\n height: 20px;\n border-radius: 3px;\n transition: width 200ms ease;\n }";
|
|
11
|
+
export declare const PROFILER_CSS_HEADING = "\n h1 {\n font-size: 18px;\n font-weight: 600;\n margin-bottom: 16px;\n display: flex;\n align-items: center;\n gap: 8px;\n }\n h2 {\n font-size: 14px;\n font-weight: 600;\n color: var(--prof-text-secondary);\n text-transform: uppercase;\n letter-spacing: 0.05em;\n margin: 16px 0 8px;\n }";
|
|
12
|
+
/** Escape text for an HTML text node or a double-quoted attribute. */
|
|
13
|
+
export declare function escapeHtml(text: string): string;
|
|
14
|
+
/** The webview heading: the host's brand (escaped) as the accent, then `what`. */
|
|
15
|
+
export declare function brandHeading(brandName: string, what: string): string;
|
|
16
|
+
export declare const BYTES_PER_KB = 1024;
|
|
17
|
+
export declare const BYTES_PER_MB = 1048576;
|
|
18
|
+
export declare const BYTES_PER_GB = 1073741824;
|
|
19
|
+
/** Format a byte count as a human-readable string (e.g. "24.5 MB"). */
|
|
20
|
+
export declare function formatBytes(bytes: number): string;
|
|
21
|
+
export declare const PROFILER_JS_UTILS = "\n function cssVar(name) {\n return getComputedStyle(document.documentElement).getPropertyValue(name).trim();\n }\n function formatBytes(bytes) {\n if (bytes >= 1073741824) return (bytes / 1073741824).toFixed(1) + ' GB';\n if (bytes >= 1048576) return (bytes / 1048576).toFixed(1) + ' MB';\n if (bytes >= 1024) return (bytes / 1024).toFixed(1) + ' KB';\n return bytes + ' B';\n }\n function basename(filePath) {\n return filePath.split(/[\\/\\\\]/).pop() || filePath;\n }\n function escapeHtml(str) {\n return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');\n }";
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Implements [PROF-UI]. See docs/specs/LSP-PROFILER-SPEC.md
|
|
3
|
+
/**
|
|
4
|
+
* Shared CSS and utility functions for profiler webviews.
|
|
5
|
+
*
|
|
6
|
+
* Centralises the theme variables, typography, and common UI component
|
|
7
|
+
* styles used by the flamegraph, reference graph, and memory dashboard.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.PROFILER_JS_UTILS = exports.BYTES_PER_GB = exports.BYTES_PER_MB = exports.BYTES_PER_KB = exports.PROFILER_CSS_HEADING = exports.PROFILER_CSS_TABLE = exports.PROFILER_CSS_CARDS = exports.PROFILER_CSS_RESET = exports.PROFILER_CSS_VARS = void 0;
|
|
11
|
+
exports.escapeHtml = escapeHtml;
|
|
12
|
+
exports.brandHeading = brandHeading;
|
|
13
|
+
exports.formatBytes = formatBytes;
|
|
14
|
+
// ── Theme CSS custom properties ──────────────────────────────────────────
|
|
15
|
+
//
|
|
16
|
+
// Heat, memory, leak and success accents are the host palette, which every
|
|
17
|
+
// document gets from paletteCss ([PROF-UI-PALETTE], profiler-webview.ts). Every
|
|
18
|
+
// surface/text color follows the active VS Code theme via the `--vscode-*`
|
|
19
|
+
// variables the webview host injects — a light-theme user gets a light panel,
|
|
20
|
+
// not a jarring hardcoded dark one. The hex fallbacks (the original brand dark
|
|
21
|
+
// palette) only apply outside a VS Code webview (e2e HTML snapshots).
|
|
22
|
+
exports.PROFILER_CSS_VARS = `
|
|
23
|
+
:root {
|
|
24
|
+
--prof-cool: var(--vscode-descriptionForeground, #4a5468);
|
|
25
|
+
--prof-idle: var(--vscode-editorWidget-border, #1a1f2e);
|
|
26
|
+
--prof-info: #60a5fa;
|
|
27
|
+
--prof-bg: var(--vscode-editor-background, #0a0c12);
|
|
28
|
+
--prof-surface: var(--vscode-editorWidget-background, #141820);
|
|
29
|
+
--prof-border: var(--vscode-editorWidget-border, #1a1f2e);
|
|
30
|
+
--prof-text: var(--vscode-editor-foreground, #f0f2f7);
|
|
31
|
+
--prof-text-secondary: var(--vscode-descriptionForeground, #8892a4);
|
|
32
|
+
}`;
|
|
33
|
+
// ── Base reset and body styles ───────────────────────────────────────────
|
|
34
|
+
exports.PROFILER_CSS_RESET = `
|
|
35
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
36
|
+
body {
|
|
37
|
+
background: var(--prof-bg);
|
|
38
|
+
color: var(--prof-text);
|
|
39
|
+
font-family: 'Space Grotesk', -apple-system, sans-serif;
|
|
40
|
+
}`;
|
|
41
|
+
// ── Shared component styles (cards, tables, bars) ────────────────────────
|
|
42
|
+
exports.PROFILER_CSS_CARDS = `
|
|
43
|
+
.summary-cards {
|
|
44
|
+
display: flex;
|
|
45
|
+
gap: 12px;
|
|
46
|
+
margin-bottom: 20px;
|
|
47
|
+
flex-wrap: wrap;
|
|
48
|
+
}
|
|
49
|
+
.card {
|
|
50
|
+
background: var(--prof-surface);
|
|
51
|
+
border: 1px solid var(--prof-border);
|
|
52
|
+
border-radius: 8px;
|
|
53
|
+
padding: 12px 16px;
|
|
54
|
+
min-width: 120px;
|
|
55
|
+
}
|
|
56
|
+
.card .label {
|
|
57
|
+
font-size: 11px;
|
|
58
|
+
color: var(--prof-text-secondary);
|
|
59
|
+
text-transform: uppercase;
|
|
60
|
+
letter-spacing: 0.05em;
|
|
61
|
+
}
|
|
62
|
+
.card .value {
|
|
63
|
+
font-size: 24px;
|
|
64
|
+
font-weight: 600;
|
|
65
|
+
font-family: 'JetBrains Mono', monospace;
|
|
66
|
+
margin-top: 4px;
|
|
67
|
+
}`;
|
|
68
|
+
exports.PROFILER_CSS_TABLE = `
|
|
69
|
+
.data-table {
|
|
70
|
+
width: 100%;
|
|
71
|
+
border-collapse: collapse;
|
|
72
|
+
}
|
|
73
|
+
.data-table th {
|
|
74
|
+
text-align: left;
|
|
75
|
+
font-size: 11px;
|
|
76
|
+
color: var(--prof-text-secondary);
|
|
77
|
+
text-transform: uppercase;
|
|
78
|
+
letter-spacing: 0.05em;
|
|
79
|
+
padding: 6px 8px;
|
|
80
|
+
border-bottom: 1px solid var(--prof-border);
|
|
81
|
+
}
|
|
82
|
+
.data-table td {
|
|
83
|
+
padding: 8px;
|
|
84
|
+
font-family: 'JetBrains Mono', monospace;
|
|
85
|
+
font-size: 13px;
|
|
86
|
+
border-bottom: 1px solid var(--prof-border);
|
|
87
|
+
cursor: pointer;
|
|
88
|
+
}
|
|
89
|
+
.data-table tr:hover td { background: var(--prof-surface); }
|
|
90
|
+
.bar-cell { position: relative; width: 160px; }
|
|
91
|
+
.bar {
|
|
92
|
+
height: 20px;
|
|
93
|
+
border-radius: 3px;
|
|
94
|
+
transition: width 200ms ease;
|
|
95
|
+
}`;
|
|
96
|
+
exports.PROFILER_CSS_HEADING = `
|
|
97
|
+
h1 {
|
|
98
|
+
font-size: 18px;
|
|
99
|
+
font-weight: 600;
|
|
100
|
+
margin-bottom: 16px;
|
|
101
|
+
display: flex;
|
|
102
|
+
align-items: center;
|
|
103
|
+
gap: 8px;
|
|
104
|
+
}
|
|
105
|
+
h2 {
|
|
106
|
+
font-size: 14px;
|
|
107
|
+
font-weight: 600;
|
|
108
|
+
color: var(--prof-text-secondary);
|
|
109
|
+
text-transform: uppercase;
|
|
110
|
+
letter-spacing: 0.05em;
|
|
111
|
+
margin: 16px 0 8px;
|
|
112
|
+
}`;
|
|
113
|
+
/** Escape text for an HTML text node or a double-quoted attribute. */
|
|
114
|
+
function escapeHtml(text) {
|
|
115
|
+
return text
|
|
116
|
+
.replaceAll("&", "&")
|
|
117
|
+
.replaceAll("<", "<")
|
|
118
|
+
.replaceAll(">", ">")
|
|
119
|
+
.replaceAll('"', """)
|
|
120
|
+
.replaceAll("'", "'");
|
|
121
|
+
}
|
|
122
|
+
/** The webview heading: the host's brand (escaped) as the accent, then `what`. */
|
|
123
|
+
function brandHeading(brandName, what) {
|
|
124
|
+
return `<h1><span class="accent">${escapeHtml(brandName.toUpperCase())}</span> ${what}</h1>`;
|
|
125
|
+
}
|
|
126
|
+
// ── Byte size constants ──────────────────────────────────────────────────
|
|
127
|
+
exports.BYTES_PER_KB = 1024;
|
|
128
|
+
exports.BYTES_PER_MB = 1_048_576;
|
|
129
|
+
exports.BYTES_PER_GB = 1_073_741_824;
|
|
130
|
+
/** Format a byte count as a human-readable string (e.g. "24.5 MB"). */
|
|
131
|
+
function formatBytes(bytes) {
|
|
132
|
+
if (bytes >= exports.BYTES_PER_GB) {
|
|
133
|
+
return `${(bytes / exports.BYTES_PER_GB).toFixed(1)} GB`;
|
|
134
|
+
}
|
|
135
|
+
if (bytes >= exports.BYTES_PER_MB) {
|
|
136
|
+
return `${(bytes / exports.BYTES_PER_MB).toFixed(1)} MB`;
|
|
137
|
+
}
|
|
138
|
+
if (bytes >= exports.BYTES_PER_KB) {
|
|
139
|
+
return `${(bytes / exports.BYTES_PER_KB).toFixed(1)} KB`;
|
|
140
|
+
}
|
|
141
|
+
return `${String(bytes)} B`;
|
|
142
|
+
}
|
|
143
|
+
// ── Shared inline JS utilities ───────────────────────────────────────────
|
|
144
|
+
exports.PROFILER_JS_UTILS = `
|
|
145
|
+
function cssVar(name) {
|
|
146
|
+
return getComputedStyle(document.documentElement).getPropertyValue(name).trim();
|
|
147
|
+
}
|
|
148
|
+
function formatBytes(bytes) {
|
|
149
|
+
if (bytes >= 1073741824) return (bytes / 1073741824).toFixed(1) + ' GB';
|
|
150
|
+
if (bytes >= 1048576) return (bytes / 1048576).toFixed(1) + ' MB';
|
|
151
|
+
if (bytes >= 1024) return (bytes / 1024).toFixed(1) + ' KB';
|
|
152
|
+
return bytes + ' B';
|
|
153
|
+
}
|
|
154
|
+
function basename(filePath) {
|
|
155
|
+
return filePath.split(/[\\/\\\\]/).pop() || filePath;
|
|
156
|
+
}
|
|
157
|
+
function escapeHtml(str) {
|
|
158
|
+
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
159
|
+
}`;
|
|
160
|
+
//# sourceMappingURL=profiler-styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profiler-styles.js","sourceRoot":"","sources":["../../src/profiler-styles.ts"],"names":[],"mappings":";AAAA,4DAA4D;AAC5D;;;;;GAKG;;;;;;AAEH,4EAA4E;AAC5E,EAAE;AACF,2EAA2E;AAC3E,gFAAgF;AAChF,2EAA2E;AAC3E,8EAA8E;AAC9E,+EAA+E;AAC/E,sEAAsE;AAEzD,QAAA,iBAAiB,GAAG;;;;;;;;;;MAU3B,CAAC;AAEP,4EAA4E;AAE/D,QAAA,kBAAkB,GAAG;;;;;;MAM5B,CAAC;AAEP,4EAA4E;AAE/D,QAAA,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;MAyB5B,CAAC;AAEM,QAAA,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;MA2B5B,CAAC;AAEM,QAAA,oBAAoB,GAAG;;;;;;;;;;;;;;;;MAgB9B,CAAC;AAEP,sEAAsE;AACtE,oBAA2B,IAAY;IACrC,OAAO,IAAI;SACR,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC;SACxB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC;SACvB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC;SACzB,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;AAC9B,CAAC;AAED,kFAAkF;AAClF,sBAA6B,SAAiB,EAAE,IAAY;IAC1D,OAAO,4BAA4B,UAAU,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,WAAW,IAAI,OAAO,CAAC;AAC/F,CAAC;AAED,4EAA4E;AAE/D,QAAA,YAAY,GAAG,IAAI,CAAC;AACpB,QAAA,YAAY,GAAG,SAAS,CAAC;AACzB,QAAA,YAAY,GAAG,aAAa,CAAC;AAE1C,uEAAuE;AACvE,qBAA4B,KAAa;IACvC,IAAI,KAAK,IAAI,QAAA,YAAY,EAAE,CAAC;QAAC,OAAO,GAAG,CAAC,KAAK,GAAG,QAAA,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAAC,CAAC;IAChF,IAAI,KAAK,IAAI,QAAA,YAAY,EAAE,CAAC;QAAC,OAAO,GAAG,CAAC,KAAK,GAAG,QAAA,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAAC,CAAC;IAChF,IAAI,KAAK,IAAI,QAAA,YAAY,EAAE,CAAC;QAAC,OAAO,GAAG,CAAC,KAAK,GAAG,QAAA,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;IAAC,CAAC;IAChF,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;AAC9B,CAAC;AAED,4EAA4E;AAE/D,QAAA,iBAAiB,GAAG;;;;;;;;;;;;;;;MAe3B,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared webview host for every profiler results panel (flamegraph, memory
|
|
3
|
+
* dashboard, retention graph).
|
|
4
|
+
*
|
|
5
|
+
* All three panels share the same lifecycle needs — a singleton panel that is
|
|
6
|
+
* created once and re-revealed after, a message handler that must be registered
|
|
7
|
+
* exactly ONCE per panel instance, a nonce-gated CSP, and safe embedding of
|
|
8
|
+
* profiled-program data into inline scripts. Before this module each panel
|
|
9
|
+
* hand-rolled that stack and two of them re-registered their message handler on
|
|
10
|
+
* every open (so after N snapshots one click navigated N times) and shipped no
|
|
11
|
+
* CSP at all. Hosting the primitives once makes those bugs unrepresentable.
|
|
12
|
+
*/
|
|
13
|
+
import * as vscode from "vscode";
|
|
14
|
+
/**
|
|
15
|
+
* Serialize a value for embedding inside an inline `<script>`. `JSON.stringify`
|
|
16
|
+
* does not escape `<`, so profiled-program data containing `</script>` would
|
|
17
|
+
* close the script element early; escaping `<` keeps it an opaque JS string.
|
|
18
|
+
*/
|
|
19
|
+
export declare function embedJson(value: unknown): string;
|
|
20
|
+
/** The parts every profiler webview document is assembled from. */
|
|
21
|
+
export interface WebviewDocument {
|
|
22
|
+
readonly title: string;
|
|
23
|
+
readonly css: string;
|
|
24
|
+
readonly body: string;
|
|
25
|
+
readonly script: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Build a complete, CSP-locked webview HTML document. A fresh nonce gates the
|
|
29
|
+
* (self-generated) inline script; `default-src 'none'` blocks every external
|
|
30
|
+
* resource; `img-src data:` admits only inline data URIs (the embedded flame
|
|
31
|
+
* graph SVG). Even if profiled-program data slipped an escape, the browser
|
|
32
|
+
* refuses to run any inline script without the nonce.
|
|
33
|
+
*/
|
|
34
|
+
export declare function buildWebviewDocument(doc: WebviewDocument): string;
|
|
35
|
+
/** A message posted from a profiler webview back to the extension. */
|
|
36
|
+
export interface WebviewMessage {
|
|
37
|
+
readonly type: string;
|
|
38
|
+
readonly file?: string;
|
|
39
|
+
readonly line?: number;
|
|
40
|
+
}
|
|
41
|
+
/** A posted value as a profiler message: an object with a string `type`, a string `file` and a numeric `line` when present. */
|
|
42
|
+
export declare function webviewMessage(raw: unknown): WebviewMessage | undefined;
|
|
43
|
+
/** Lifecycle options for a singleton editor-area webview. */
|
|
44
|
+
export interface SingletonWebviewPanelOptions {
|
|
45
|
+
readonly viewColumn?: vscode.ViewColumn;
|
|
46
|
+
readonly retainContextWhenHidden?: boolean;
|
|
47
|
+
readonly enableFindWidget?: boolean;
|
|
48
|
+
readonly onDidReveal?: () => void;
|
|
49
|
+
readonly onDidDispose?: () => void;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Route the message every profiler panel shares: a click on a source location
|
|
53
|
+
* opens that file beside the panel. Returns whether the message was handled so
|
|
54
|
+
* panels can layer their own message types on top.
|
|
55
|
+
*/
|
|
56
|
+
export declare function handleSourceNavigation(msg: WebviewMessage): boolean;
|
|
57
|
+
/** Open a measured source line, clamped to the current document (source may have changed). */
|
|
58
|
+
export declare function revealProfileSource(location: {
|
|
59
|
+
file: string;
|
|
60
|
+
line: number;
|
|
61
|
+
type?: string;
|
|
62
|
+
}): Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* A create-once / reveal-after webview panel whose message handler is bound
|
|
65
|
+
* exactly once per panel instance — re-opening with fresh data re-renders the
|
|
66
|
+
* HTML but never stacks a second handler.
|
|
67
|
+
*/
|
|
68
|
+
export declare class SingletonWebviewPanel {
|
|
69
|
+
private panel;
|
|
70
|
+
private visible;
|
|
71
|
+
private readonly viewType;
|
|
72
|
+
private readonly onMessage;
|
|
73
|
+
private readonly options;
|
|
74
|
+
/** `viewType` is read when the panel is created, so it follows the host prefix installed later. */
|
|
75
|
+
constructor(viewType: () => string, onMessage: (msg: WebviewMessage) => void, options?: SingletonWebviewPanelOptions);
|
|
76
|
+
/** Open the panel (or reveal the existing one) and swap in the new document. */
|
|
77
|
+
show(title: string, html: string): void;
|
|
78
|
+
private create;
|
|
79
|
+
private bindLifecycle;
|
|
80
|
+
/** Post data to the open panel; false when no panel exists. */
|
|
81
|
+
postMessage(message: unknown): Thenable<boolean>;
|
|
82
|
+
/** Whether the panel is currently open (e2e seam). */
|
|
83
|
+
isOpen(): boolean;
|
|
84
|
+
/** The panel's view type and title, when open (e2e seam). */
|
|
85
|
+
describe(): {
|
|
86
|
+
readonly viewType: string;
|
|
87
|
+
readonly title: string;
|
|
88
|
+
} | undefined;
|
|
89
|
+
/** The HTML currently rendered, when open (e2e seam). */
|
|
90
|
+
html(): string | undefined;
|
|
91
|
+
/** Whether the live panel is already frontmost in an editor group. */
|
|
92
|
+
isVisible(): boolean;
|
|
93
|
+
/** Close and forget the panel (extension teardown). */
|
|
94
|
+
dispose(): void;
|
|
95
|
+
}
|