@isopodlabs/vscode_utils 0.0.2 → 0.1.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/assets/codicon.ttf +0 -0
- package/dist/debug.d.ts +130 -0
- package/dist/debug.js +276 -0
- package/dist/jsx-runtime.d.ts +57 -0
- package/dist/jsx-runtime.js +618 -0
- package/package.json +8 -2
- package/dist/utils.d.ts +0 -91
- package/dist/utils.js +0 -430
|
Binary file
|
package/dist/debug.d.ts
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import * as vscode from 'vscode';
|
|
2
|
+
import * as fs from './fs';
|
|
3
|
+
import { DebugProtocol } from '@vscode/debugprotocol';
|
|
4
|
+
type Response<T extends DebugProtocol.Response> = Promise<T['body']>;
|
|
5
|
+
export declare function request(session: vscode.DebugSession, command: 'cancel', args: DebugProtocol.CancelArguments): Response<DebugProtocol.CancelResponse>;
|
|
6
|
+
export declare function request(session: vscode.DebugSession, command: 'runInTerminal', args: DebugProtocol.RunInTerminalRequestArguments): Response<DebugProtocol.RunInTerminalResponse>;
|
|
7
|
+
export declare function request(session: vscode.DebugSession, command: 'startDebugging', args: DebugProtocol.StartDebuggingRequestArguments): Response<DebugProtocol.StartDebuggingResponse>;
|
|
8
|
+
export declare function request(session: vscode.DebugSession, command: 'initialize', args: DebugProtocol.InitializeRequestArguments): Response<DebugProtocol.InitializeResponse>;
|
|
9
|
+
export declare function request(session: vscode.DebugSession, command: 'configurationDone', args: DebugProtocol.ConfigurationDoneArguments): Response<DebugProtocol.ConfigurationDoneResponse>;
|
|
10
|
+
export declare function request(session: vscode.DebugSession, command: 'launch', args: DebugProtocol.LaunchRequestArguments): Response<DebugProtocol.LaunchResponse>;
|
|
11
|
+
export declare function request(session: vscode.DebugSession, command: 'attach', args: DebugProtocol.AttachRequestArguments): Response<DebugProtocol.AttachResponse>;
|
|
12
|
+
export declare function request(session: vscode.DebugSession, command: 'restart', args: DebugProtocol.RestartArguments): Response<DebugProtocol.RestartResponse>;
|
|
13
|
+
export declare function request(session: vscode.DebugSession, command: 'disconnect', args: DebugProtocol.DisconnectArguments): Response<DebugProtocol.DisconnectResponse>;
|
|
14
|
+
export declare function request(session: vscode.DebugSession, command: 'terminate', args: DebugProtocol.TerminateArguments): Response<DebugProtocol.TerminateResponse>;
|
|
15
|
+
export declare function request(session: vscode.DebugSession, command: 'breakpointLocations', args: DebugProtocol.BreakpointLocationsArguments): Response<DebugProtocol.BreakpointLocationsResponse>;
|
|
16
|
+
export declare function request(session: vscode.DebugSession, command: 'setBreakpoints', args: DebugProtocol.SetBreakpointsArguments): Response<DebugProtocol.SetBreakpointsResponse>;
|
|
17
|
+
export declare function request(session: vscode.DebugSession, command: 'setFunctionBreakpoints', args: DebugProtocol.SetFunctionBreakpointsArguments): Response<DebugProtocol.SetFunctionBreakpointsResponse>;
|
|
18
|
+
export declare function request(session: vscode.DebugSession, command: 'setExceptionBreakpoints', args: DebugProtocol.SetExceptionBreakpointsArguments): Response<DebugProtocol.SetExceptionBreakpointsResponse>;
|
|
19
|
+
export declare function request(session: vscode.DebugSession, command: 'dataBreakpointInfo', args: DebugProtocol.DataBreakpointInfoArguments): Response<DebugProtocol.DataBreakpointInfoResponse>;
|
|
20
|
+
export declare function request(session: vscode.DebugSession, command: 'setDataBreakpoints', args: DebugProtocol.SetDataBreakpointsArguments): Response<DebugProtocol.SetDataBreakpointsResponse>;
|
|
21
|
+
export declare function request(session: vscode.DebugSession, command: 'setInstructionBreakpoints', args: DebugProtocol.SetInstructionBreakpointsArguments): Response<DebugProtocol.SetInstructionBreakpointsResponse>;
|
|
22
|
+
export declare function request(session: vscode.DebugSession, command: 'continue', args: DebugProtocol.ContinueArguments): Response<DebugProtocol.ContinueResponse>;
|
|
23
|
+
export declare function request(session: vscode.DebugSession, command: 'next', args: DebugProtocol.NextArguments): Response<DebugProtocol.NextResponse>;
|
|
24
|
+
export declare function request(session: vscode.DebugSession, command: 'stepIn', args: DebugProtocol.StepInArguments): Response<DebugProtocol.StepInResponse>;
|
|
25
|
+
export declare function request(session: vscode.DebugSession, command: 'stepOut', args: DebugProtocol.StepOutArguments): Response<DebugProtocol.StepOutResponse>;
|
|
26
|
+
export declare function request(session: vscode.DebugSession, command: 'stepBack', args: DebugProtocol.StepBackArguments): Response<DebugProtocol.StepBackResponse>;
|
|
27
|
+
export declare function request(session: vscode.DebugSession, command: 'reverseContinue', args: DebugProtocol.ReverseContinueArguments): Response<DebugProtocol.ReverseContinueResponse>;
|
|
28
|
+
export declare function request(session: vscode.DebugSession, command: 'restartFrame', args: DebugProtocol.RestartFrameArguments): Response<DebugProtocol.RestartFrameResponse>;
|
|
29
|
+
export declare function request(session: vscode.DebugSession, command: 'goto', args: DebugProtocol.GotoArguments): Response<DebugProtocol.GotoResponse>;
|
|
30
|
+
export declare function request(session: vscode.DebugSession, command: 'pause', args: DebugProtocol.PauseArguments): Response<DebugProtocol.PauseResponse>;
|
|
31
|
+
export declare function request(session: vscode.DebugSession, command: 'stackTrace', args: DebugProtocol.StackTraceArguments): Response<DebugProtocol.StackTraceResponse>;
|
|
32
|
+
export declare function request(session: vscode.DebugSession, command: 'scopes', args: DebugProtocol.ScopesArguments): Response<DebugProtocol.ScopesResponse>;
|
|
33
|
+
export declare function request(session: vscode.DebugSession, command: 'variables', args: DebugProtocol.VariablesArguments): Response<DebugProtocol.VariablesResponse>;
|
|
34
|
+
export declare function request(session: vscode.DebugSession, command: 'setVariable', args: DebugProtocol.SetVariableArguments): Response<DebugProtocol.SetVariableResponse>;
|
|
35
|
+
export declare function request(session: vscode.DebugSession, command: 'source', args: DebugProtocol.SourceArguments): Response<DebugProtocol.SourceResponse>;
|
|
36
|
+
export declare function request(session: vscode.DebugSession, command: 'threads'): Response<DebugProtocol.ThreadsResponse>;
|
|
37
|
+
export declare function request(session: vscode.DebugSession, command: 'terminateThreads', args: DebugProtocol.TerminateThreadsArguments): Response<DebugProtocol.TerminateThreadsResponse>;
|
|
38
|
+
export declare function request(session: vscode.DebugSession, command: 'modules', args: DebugProtocol.ModulesArguments): Response<DebugProtocol.ModulesResponse>;
|
|
39
|
+
export declare function request(session: vscode.DebugSession, command: 'loadedSources', args: DebugProtocol.LoadedSourcesArguments): Response<DebugProtocol.LoadedSourcesResponse>;
|
|
40
|
+
export declare function request(session: vscode.DebugSession, command: 'evaluate', args: DebugProtocol.EvaluateArguments): Response<DebugProtocol.EvaluateResponse>;
|
|
41
|
+
export declare function request(session: vscode.DebugSession, command: 'setExpression', args: DebugProtocol.SetExpressionArguments): Response<DebugProtocol.SetExpressionResponse>;
|
|
42
|
+
export declare function request(session: vscode.DebugSession, command: 'stepInTargets', args: DebugProtocol.StepInTargetsArguments): Response<DebugProtocol.StepInTargetsResponse>;
|
|
43
|
+
export declare function request(session: vscode.DebugSession, command: 'gotoTargets', args: DebugProtocol.GotoTargetsArguments): Response<DebugProtocol.GotoTargetsResponse>;
|
|
44
|
+
export declare function request(session: vscode.DebugSession, command: 'completions', args: DebugProtocol.CompletionsArguments): Response<DebugProtocol.CompletionsResponse>;
|
|
45
|
+
export declare function request(session: vscode.DebugSession, command: 'exceptionInfo', args: DebugProtocol.ExceptionInfoArguments): Response<DebugProtocol.ExceptionInfoResponse>;
|
|
46
|
+
export declare function request(session: vscode.DebugSession, command: 'readMemory', args: DebugProtocol.ReadMemoryArguments): Response<DebugProtocol.ReadMemoryResponse>;
|
|
47
|
+
export declare function request(session: vscode.DebugSession, command: 'writeMemory', args: DebugProtocol.WriteMemoryArguments): Response<DebugProtocol.WriteMemoryResponse>;
|
|
48
|
+
export declare function request(session: vscode.DebugSession, command: 'disassemble', args: DebugProtocol.DisassembleArguments): Response<DebugProtocol.DisassembleResponse>;
|
|
49
|
+
export declare function request(session: vscode.DebugSession, command: 'locations', args: DebugProtocol.LocationsArguments): Response<DebugProtocol.LocationsResponse>;
|
|
50
|
+
export declare const enum State {
|
|
51
|
+
Inactive = 0,
|
|
52
|
+
Initializing = 1,
|
|
53
|
+
Stopped = 2,
|
|
54
|
+
Running = 3
|
|
55
|
+
}
|
|
56
|
+
export declare class Session implements vscode.DebugAdapterTracker {
|
|
57
|
+
session: vscode.DebugSession;
|
|
58
|
+
static sessions: Record<string, Session>;
|
|
59
|
+
private static _onCreate;
|
|
60
|
+
private static bpchange;
|
|
61
|
+
static get onCreate(): vscode.Event<Session>;
|
|
62
|
+
static get_wrapper(id: string): Session;
|
|
63
|
+
static get(id: string): vscode.DebugSession;
|
|
64
|
+
static get_caps(id: string): DebugProtocol.Capabilities | undefined;
|
|
65
|
+
private _onMessage;
|
|
66
|
+
private _onDidChangeState;
|
|
67
|
+
private _onDidInvalidateMemory;
|
|
68
|
+
_state: number;
|
|
69
|
+
threadId?: number;
|
|
70
|
+
frameId?: Promise<number>;
|
|
71
|
+
capabilities?: DebugProtocol.Capabilities;
|
|
72
|
+
static register(context: vscode.ExtensionContext): void;
|
|
73
|
+
constructor(session: vscode.DebugSession);
|
|
74
|
+
set state(value: number);
|
|
75
|
+
get onMessage(): vscode.Event<any>;
|
|
76
|
+
get onDidChangeState(): vscode.Event<number>;
|
|
77
|
+
get onDidInvalidateMemory(): vscode.Event<DebugProtocol.MemoryEvent>;
|
|
78
|
+
onExit(_code: number | undefined, _signal: string | undefined): void;
|
|
79
|
+
onWillStartSession(): void;
|
|
80
|
+
onWillStopSession?(): void;
|
|
81
|
+
onDidSendMessage(message: DebugProtocol.ProtocolMessage): void;
|
|
82
|
+
}
|
|
83
|
+
export declare function getTopStackFrameId(session: vscode.DebugSession): Promise<number> | undefined;
|
|
84
|
+
declare class MemoryFile implements fs.File {
|
|
85
|
+
session: vscode.DebugSession;
|
|
86
|
+
memoryReference: string;
|
|
87
|
+
constructor(session: vscode.DebugSession, memoryReference: string);
|
|
88
|
+
dispose(): void;
|
|
89
|
+
read(pos: number, length: number): Promise<Uint8Array>;
|
|
90
|
+
write(pos: number, data: Uint8Array): Promise<number>;
|
|
91
|
+
}
|
|
92
|
+
export declare class MemoryFileSystem extends fs.BaseFileSystem {
|
|
93
|
+
static SCHEME: string;
|
|
94
|
+
static makeUri(session: vscode.DebugSession, memoryReference: string, range?: fs.FileRange, displayName?: string): vscode.Uri;
|
|
95
|
+
static parseUri(uri: vscode.Uri): {
|
|
96
|
+
session: Session;
|
|
97
|
+
offset: {
|
|
98
|
+
fromOffset: number;
|
|
99
|
+
toOffset: number;
|
|
100
|
+
} | undefined;
|
|
101
|
+
readOnly: boolean | undefined;
|
|
102
|
+
memoryReference: string;
|
|
103
|
+
};
|
|
104
|
+
constructor(context: vscode.ExtensionContext);
|
|
105
|
+
openFile(uri: vscode.Uri): MemoryFile;
|
|
106
|
+
watch(uri: vscode.Uri, options: {
|
|
107
|
+
readonly recursive: boolean;
|
|
108
|
+
readonly excludes: readonly string[];
|
|
109
|
+
}): vscode.Disposable;
|
|
110
|
+
stat(uri: vscode.Uri): Promise<{
|
|
111
|
+
type: vscode.FileType;
|
|
112
|
+
mtime: number;
|
|
113
|
+
ctime: number;
|
|
114
|
+
size: number;
|
|
115
|
+
permissions: vscode.FilePermission | undefined;
|
|
116
|
+
}>;
|
|
117
|
+
readFile(uri: vscode.Uri): Promise<Uint8Array<ArrayBufferLike>>;
|
|
118
|
+
writeFile(uri: vscode.Uri, content: Uint8Array): Promise<void>;
|
|
119
|
+
}
|
|
120
|
+
export declare class MemorySchema {
|
|
121
|
+
static SCHEME: string;
|
|
122
|
+
static makeUri(session: vscode.DebugSession, memoryReference: string, range?: fs.FileRange, displayName?: string): vscode.Uri;
|
|
123
|
+
}
|
|
124
|
+
export declare class SourceProvider implements vscode.TextDocumentContentProvider {
|
|
125
|
+
static SCHEME: string;
|
|
126
|
+
static makeUri(session: vscode.DebugSession, sourceReference: number, displayName?: string): vscode.Uri;
|
|
127
|
+
constructor(context: vscode.ExtensionContext);
|
|
128
|
+
provideTextDocumentContent(uri: vscode.Uri): Promise<string>;
|
|
129
|
+
}
|
|
130
|
+
export {};
|
package/dist/debug.js
ADDED
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.SourceProvider = exports.MemorySchema = exports.MemoryFileSystem = exports.Session = void 0;
|
|
37
|
+
exports.request = request;
|
|
38
|
+
exports.getTopStackFrameId = getTopStackFrameId;
|
|
39
|
+
const vscode = __importStar(require("vscode"));
|
|
40
|
+
const fs = __importStar(require("./fs"));
|
|
41
|
+
async function request(session, command, args) {
|
|
42
|
+
return session.customRequest(command, args);
|
|
43
|
+
}
|
|
44
|
+
class Session {
|
|
45
|
+
session;
|
|
46
|
+
static sessions = {};
|
|
47
|
+
static _onCreate = new vscode.EventEmitter();
|
|
48
|
+
static bpchange = vscode.debug.onDidChangeBreakpoints(event => {
|
|
49
|
+
console.log(event);
|
|
50
|
+
});
|
|
51
|
+
static get onCreate() { return this._onCreate.event; }
|
|
52
|
+
static get_wrapper(id) { return this.sessions[id]; }
|
|
53
|
+
static get(id) { return this.sessions[id]?.session; }
|
|
54
|
+
static get_caps(id) { return this.sessions[id]?.capabilities; }
|
|
55
|
+
_onMessage = new vscode.EventEmitter();
|
|
56
|
+
_onDidChangeState = new vscode.EventEmitter();
|
|
57
|
+
_onDidInvalidateMemory = new vscode.EventEmitter();
|
|
58
|
+
_state = 0 /* State.Inactive */;
|
|
59
|
+
threadId;
|
|
60
|
+
frameId;
|
|
61
|
+
capabilities;
|
|
62
|
+
static register(context) {
|
|
63
|
+
context.subscriptions.push(vscode.debug.registerDebugAdapterTrackerFactory('*', {
|
|
64
|
+
createDebugAdapterTracker: (session) => new Session(session)
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
constructor(session) {
|
|
68
|
+
this.session = session;
|
|
69
|
+
Session.sessions[session.id] = this;
|
|
70
|
+
Session._onCreate.fire(this);
|
|
71
|
+
}
|
|
72
|
+
set state(value) {
|
|
73
|
+
//if (this._state !== value)
|
|
74
|
+
this._onDidChangeState.fire((this._state = value));
|
|
75
|
+
}
|
|
76
|
+
get onMessage() { return this._onMessage.event; }
|
|
77
|
+
get onDidChangeState() { return this._onDidChangeState.event; }
|
|
78
|
+
get onDidInvalidateMemory() { return this._onDidInvalidateMemory.event; }
|
|
79
|
+
onExit(_code, _signal) {
|
|
80
|
+
delete Session.sessions[this.session.id];
|
|
81
|
+
}
|
|
82
|
+
onWillStartSession() {
|
|
83
|
+
this.state = 1 /* State.Initializing */;
|
|
84
|
+
}
|
|
85
|
+
onWillStopSession() {
|
|
86
|
+
this.state = 0 /* State.Inactive */;
|
|
87
|
+
}
|
|
88
|
+
// onWillReceiveMessage?(message: any): void;
|
|
89
|
+
onDidSendMessage(message) {
|
|
90
|
+
this._onMessage.fire(message);
|
|
91
|
+
switch (message.type) {
|
|
92
|
+
case "response": {
|
|
93
|
+
const response = message;
|
|
94
|
+
switch (response.command) {
|
|
95
|
+
case "initialize":
|
|
96
|
+
this.capabilities = response.body;
|
|
97
|
+
break;
|
|
98
|
+
//case "stackTrace":
|
|
99
|
+
// this.frameId = ((response as DebugProtocol.StackTraceResponse).body).stackFrames[0].id;
|
|
100
|
+
// break;
|
|
101
|
+
}
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
case "event": {
|
|
105
|
+
const event = message;
|
|
106
|
+
switch (event.event) {
|
|
107
|
+
case "initialized":
|
|
108
|
+
//this.state = State.Inactive;
|
|
109
|
+
break;
|
|
110
|
+
case "stopped":
|
|
111
|
+
this.threadId = event.body.threadId;
|
|
112
|
+
this.frameId = request(this.session, 'stackTrace', { threadId: this.threadId ?? 0 }).then(resp => resp.stackFrames[0].id);
|
|
113
|
+
this.state = 2 /* State.Stopped */;
|
|
114
|
+
break;
|
|
115
|
+
case "continued":
|
|
116
|
+
this.state = 3 /* State.Running */;
|
|
117
|
+
break;
|
|
118
|
+
case "memory":
|
|
119
|
+
this._onDidInvalidateMemory.fire(event);
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.Session = Session;
|
|
128
|
+
function getTopStackFrameId(session) {
|
|
129
|
+
return Session.get_wrapper(session.id).frameId;
|
|
130
|
+
// const resp = await request(session, 'stackTrace', { threadId: 0 });
|
|
131
|
+
// return resp.stackFrames[0].id;
|
|
132
|
+
}
|
|
133
|
+
//-----------------------------------------------------------------------------
|
|
134
|
+
// FileSystems
|
|
135
|
+
//-----------------------------------------------------------------------------
|
|
136
|
+
class MemoryFile {
|
|
137
|
+
session;
|
|
138
|
+
memoryReference;
|
|
139
|
+
constructor(session, memoryReference) {
|
|
140
|
+
this.session = session;
|
|
141
|
+
this.memoryReference = memoryReference;
|
|
142
|
+
}
|
|
143
|
+
dispose() { }
|
|
144
|
+
async read(pos, length) {
|
|
145
|
+
const resp = await request(this.session, 'readMemory', {
|
|
146
|
+
memoryReference: this.memoryReference,
|
|
147
|
+
offset: pos,
|
|
148
|
+
count: length,
|
|
149
|
+
});
|
|
150
|
+
return resp?.data
|
|
151
|
+
? new Uint8Array(Buffer.from(resp.data, 'base64'))
|
|
152
|
+
: new Uint8Array(0);
|
|
153
|
+
}
|
|
154
|
+
async write(pos, data) {
|
|
155
|
+
const resp = await request(this.session, 'writeMemory', {
|
|
156
|
+
memoryReference: this.memoryReference,
|
|
157
|
+
offset: pos,
|
|
158
|
+
data: Buffer.from(data).toString('base64')
|
|
159
|
+
});
|
|
160
|
+
return resp?.bytesWritten ?? 0;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
class MemoryFileSystem extends fs.BaseFileSystem {
|
|
164
|
+
static SCHEME = 'modules-debug-memory';
|
|
165
|
+
static makeUri(session, memoryReference, range, displayName = 'memory') {
|
|
166
|
+
return vscode.Uri.from({
|
|
167
|
+
scheme: this.SCHEME,
|
|
168
|
+
authority: session.id,
|
|
169
|
+
path: `/${encodeURIComponent(memoryReference)}/${encodeURIComponent(displayName)}`,
|
|
170
|
+
query: range ? `?range=${range.fromOffset}:${range.toOffset}` : undefined,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
static parseUri(uri) {
|
|
174
|
+
const session = Session.get_wrapper(uri.authority);
|
|
175
|
+
if (!session)
|
|
176
|
+
throw 'Debug session not found';
|
|
177
|
+
const rangeMatch = /range=([0-9]+):([0-9]+)/.exec(uri.query);
|
|
178
|
+
const offset = rangeMatch ? { fromOffset: Number(rangeMatch[1]), toOffset: Number(rangeMatch[2]) } : undefined;
|
|
179
|
+
const memoryReference = decodeURIComponent(uri.path.split('/')[1]);
|
|
180
|
+
return {
|
|
181
|
+
session,
|
|
182
|
+
offset,
|
|
183
|
+
readOnly: Session.get_caps(uri.authority)?.supportsWriteMemoryRequest,
|
|
184
|
+
memoryReference,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
constructor(context) {
|
|
188
|
+
super(context, MemoryFileSystem.SCHEME);
|
|
189
|
+
}
|
|
190
|
+
openFile(uri) {
|
|
191
|
+
const { session, memoryReference } = MemoryFileSystem.parseUri(uri);
|
|
192
|
+
return new MemoryFile(session.session, memoryReference);
|
|
193
|
+
}
|
|
194
|
+
watch(uri, options) {
|
|
195
|
+
if (options.recursive)
|
|
196
|
+
return new vscode.Disposable(() => { });
|
|
197
|
+
const { session, memoryReference, offset } = MemoryFileSystem.parseUri(uri);
|
|
198
|
+
return vscode.Disposable.from(session.onDidChangeState(state => {
|
|
199
|
+
if (state === 3 /* State.Running */ || state === 0 /* State.Inactive */)
|
|
200
|
+
this._onDidChangeFile.fire([{ type: vscode.FileChangeType.Deleted, uri }]);
|
|
201
|
+
}), session.onDidInvalidateMemory(e => {
|
|
202
|
+
if (e.body.memoryReference === memoryReference && (!offset || (e.body.offset < offset.toOffset && e.body.offset + e.body.count >= offset.fromOffset)))
|
|
203
|
+
this._onDidChangeFile.fire([{ type: vscode.FileChangeType.Changed, uri }]);
|
|
204
|
+
}));
|
|
205
|
+
}
|
|
206
|
+
stat(uri) {
|
|
207
|
+
const { readOnly, offset } = MemoryFileSystem.parseUri(uri);
|
|
208
|
+
return Promise.resolve({
|
|
209
|
+
type: vscode.FileType.File,
|
|
210
|
+
mtime: 0,
|
|
211
|
+
ctime: 0,
|
|
212
|
+
size: offset ? offset.toOffset - offset.fromOffset : 0x10000,
|
|
213
|
+
permissions: readOnly ? vscode.FilePermission.Readonly : undefined,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
async readFile(uri) {
|
|
217
|
+
const { session, memoryReference, offset } = MemoryFileSystem.parseUri(uri);
|
|
218
|
+
if (!offset)
|
|
219
|
+
throw `Range must be present to read a file`;
|
|
220
|
+
const file = new MemoryFile(session.session, memoryReference);
|
|
221
|
+
try {
|
|
222
|
+
return await file.read(offset.fromOffset, offset.toOffset - offset.fromOffset);
|
|
223
|
+
}
|
|
224
|
+
finally {
|
|
225
|
+
file.dispose();
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
async writeFile(uri, content) {
|
|
229
|
+
const { session, memoryReference, offset } = MemoryFileSystem.parseUri(uri);
|
|
230
|
+
if (!offset)
|
|
231
|
+
throw `Range must be present to read a file`;
|
|
232
|
+
const file = new MemoryFile(session.session, memoryReference);
|
|
233
|
+
try {
|
|
234
|
+
await file.write(offset.fromOffset, content);
|
|
235
|
+
}
|
|
236
|
+
finally {
|
|
237
|
+
file.dispose();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
exports.MemoryFileSystem = MemoryFileSystem;
|
|
242
|
+
//-----------------------------------------------------------------------------
|
|
243
|
+
// uri schema
|
|
244
|
+
//-----------------------------------------------------------------------------
|
|
245
|
+
class MemorySchema {
|
|
246
|
+
static SCHEME = 'vscode-debug-memory';
|
|
247
|
+
static makeUri(session, memoryReference, range, displayName = 'memory') {
|
|
248
|
+
return vscode.Uri.from({
|
|
249
|
+
scheme: MemorySchema.SCHEME,
|
|
250
|
+
authority: session.id,
|
|
251
|
+
path: `/${encodeURIComponent(memoryReference)}/${encodeURIComponent(displayName)}`,
|
|
252
|
+
query: range ? `?range=${range.fromOffset}:${range.toOffset}` : undefined,
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
exports.MemorySchema = MemorySchema;
|
|
257
|
+
class SourceProvider {
|
|
258
|
+
static SCHEME = 'vscode-debug-source';
|
|
259
|
+
static makeUri(session, sourceReference, displayName = 'memory') {
|
|
260
|
+
return vscode.Uri.from({
|
|
261
|
+
scheme: this.SCHEME,
|
|
262
|
+
authority: session.id,
|
|
263
|
+
path: `/${sourceReference}/${encodeURIComponent(displayName)}`,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
constructor(context) {
|
|
267
|
+
context.subscriptions.push(vscode.workspace.registerTextDocumentContentProvider(SourceProvider.SCHEME, this));
|
|
268
|
+
}
|
|
269
|
+
async provideTextDocumentContent(uri) {
|
|
270
|
+
const parts = uri.path.split('/');
|
|
271
|
+
const sourceReference = +parts[1];
|
|
272
|
+
const session = Session.get(uri.authority);
|
|
273
|
+
return session && (await request(session, 'source', { sourceReference })).content;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
exports.SourceProvider = SourceProvider;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/** @jsxImportSource . */
|
|
2
|
+
import * as vscode from 'vscode';
|
|
3
|
+
export declare function jsx(type: any, props: any): any;
|
|
4
|
+
export declare function jsxs(type: any, props: any): any;
|
|
5
|
+
export declare function jsxFrag(props: any): {
|
|
6
|
+
props: any;
|
|
7
|
+
};
|
|
8
|
+
export declare namespace JSX {
|
|
9
|
+
interface Element {
|
|
10
|
+
type: string;
|
|
11
|
+
props: any;
|
|
12
|
+
}
|
|
13
|
+
interface IntrinsicElements {
|
|
14
|
+
[elemName: string]: any;
|
|
15
|
+
}
|
|
16
|
+
function render(element: any): string;
|
|
17
|
+
}
|
|
18
|
+
export declare function id_selector(id: string | number): string;
|
|
19
|
+
export declare const codicons: Record<string, string>;
|
|
20
|
+
type IconType0 = string | vscode.Uri;
|
|
21
|
+
export type IconType = IconType0 | vscode.ThemeIcon | {
|
|
22
|
+
light: IconType0;
|
|
23
|
+
dark: IconType0;
|
|
24
|
+
};
|
|
25
|
+
export declare function iconAttribute(icon: IconType0): string;
|
|
26
|
+
export declare function iconAttributes(icon?: IconType): {
|
|
27
|
+
icon: string;
|
|
28
|
+
color?: undefined;
|
|
29
|
+
} | {
|
|
30
|
+
icon: string;
|
|
31
|
+
color: string;
|
|
32
|
+
} | undefined;
|
|
33
|
+
export declare function Label({ id, display }: {
|
|
34
|
+
id: string;
|
|
35
|
+
display: string;
|
|
36
|
+
}): JSX.Element;
|
|
37
|
+
export declare class Hash {
|
|
38
|
+
algorithm: string;
|
|
39
|
+
value: string;
|
|
40
|
+
constructor(algorithm: string, value: string);
|
|
41
|
+
toString(): string;
|
|
42
|
+
}
|
|
43
|
+
export declare function Nonce(): Hash;
|
|
44
|
+
type Source = Hash | string | "'self'" | "'unsafe-inline'" | "'unsafe-eval'" | "'wasm-unsafe-eval'" | "'unsafe-hashes'" | "'inline-speculation-rules'" | "'strict-dynamic'";
|
|
45
|
+
export declare function CSP({ csp, ...others }: {
|
|
46
|
+
csp: string;
|
|
47
|
+
script?: Source;
|
|
48
|
+
script_elem?: Source;
|
|
49
|
+
script_attr?: Source;
|
|
50
|
+
style?: Source;
|
|
51
|
+
stype_elem?: Source;
|
|
52
|
+
style_attr?: Source;
|
|
53
|
+
font?: Source;
|
|
54
|
+
img?: Source;
|
|
55
|
+
media?: Source;
|
|
56
|
+
}): JSX.Element;
|
|
57
|
+
export {};
|