wasm-idle 0.4.0 → 0.5.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 +111 -2
- package/dist/clang/app.d.ts +4 -0
- package/dist/clang/app.js +330 -15
- package/dist/clang/index.d.ts +10 -0
- package/dist/clang/index.js +284 -25
- package/dist/debug/controller.svelte.d.ts +43 -0
- package/dist/debug/controller.svelte.js +268 -0
- package/dist/debug/editor/index.d.ts +2 -1
- package/dist/debug/editor/index.js +1 -1
- package/dist/debug/editor/monaco.d.ts +8 -0
- package/dist/debug/editor/monaco.js +23 -0
- package/dist/debug/expression.d.ts +24 -0
- package/dist/debug/expression.js +307 -138
- package/dist/debug/index.d.ts +4 -1
- package/dist/debug/index.js +2 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.js +3 -3
- package/dist/playground/assetBridge.d.ts +20 -0
- package/dist/playground/assetBridge.js +192 -0
- package/dist/playground/assets.d.ts +37 -0
- package/dist/playground/assets.js +105 -0
- package/dist/playground/clang.d.ts +11 -1
- package/dist/playground/clang.js +58 -4
- package/dist/playground/index.d.ts +5 -5
- package/dist/playground/index.js +48 -6
- package/dist/playground/java.d.ts +7 -2
- package/dist/playground/java.js +31 -5
- package/dist/playground/javaStdin.js +235 -2
- package/dist/playground/options.d.ts +18 -0
- package/dist/playground/options.js +15 -1
- package/dist/playground/python.d.ts +7 -1
- package/dist/playground/python.js +50 -5
- package/dist/playground/rust.d.ts +32 -0
- package/dist/playground/rust.js +175 -0
- package/dist/playground/sandbox.d.ts +19 -4
- package/dist/playground/wasmRustVersion.d.ts +1 -0
- package/dist/playground/wasmRustVersion.js +1 -0
- package/dist/playground/worker/assets.d.ts +12 -0
- package/dist/playground/worker/assets.js +257 -0
- package/dist/playground/worker/clang.js +22 -6
- package/dist/playground/worker/java.js +15 -35
- package/dist/playground/worker/python.js +13 -33
- package/dist/playground/worker/rust.d.ts +1 -0
- package/dist/playground/worker/rust.js +159 -0
- package/dist/terminal/Terminal.svelte +121 -18
- package/dist/terminal/Terminal.svelte.d.ts +4 -0
- package/dist/terminal/theme.js +2 -2
- package/dist/terminal/types.d.ts +4 -0
- package/package.json +19 -13
package/dist/debug/expression.js
CHANGED
|
@@ -1,45 +1,46 @@
|
|
|
1
1
|
const operators = ['&&', '||', '==', '!=', '<=', '>=', '+', '-', '*', '/', '%', '<', '>', '!'];
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
if (character === quote)
|
|
37
|
-
return { value, next: index + 1 };
|
|
38
|
-
value += character;
|
|
39
|
-
index += 1;
|
|
2
|
+
const isDebugExpressionIndexedValue = (value) => !!value &&
|
|
3
|
+
typeof value === 'object' &&
|
|
4
|
+
!Array.isArray(value) &&
|
|
5
|
+
value.__debugExpressionKind === 'array';
|
|
6
|
+
const isDebugExpressionObjectValue = (value) => !!value &&
|
|
7
|
+
typeof value === 'object' &&
|
|
8
|
+
!Array.isArray(value) &&
|
|
9
|
+
value.__debugExpressionKind === 'object';
|
|
10
|
+
const parseQuotedValue = (text, start) => {
|
|
11
|
+
const quote = text[start];
|
|
12
|
+
if (quote !== "'" && quote !== '"')
|
|
13
|
+
throw new Error('expected quoted string');
|
|
14
|
+
let index = start + 1;
|
|
15
|
+
let value = '';
|
|
16
|
+
while (index < text.length) {
|
|
17
|
+
const character = text[index];
|
|
18
|
+
if (!character)
|
|
19
|
+
break;
|
|
20
|
+
if (character === '\\') {
|
|
21
|
+
const escaped = text[index + 1];
|
|
22
|
+
if (!escaped)
|
|
23
|
+
throw new Error('unterminated string literal');
|
|
24
|
+
if (escaped === 'n')
|
|
25
|
+
value += '\n';
|
|
26
|
+
else if (escaped === 'r')
|
|
27
|
+
value += '\r';
|
|
28
|
+
else if (escaped === 't')
|
|
29
|
+
value += '\t';
|
|
30
|
+
else
|
|
31
|
+
value += escaped;
|
|
32
|
+
index += 2;
|
|
33
|
+
continue;
|
|
40
34
|
}
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
if (character === quote)
|
|
36
|
+
return { value, next: index + 1 };
|
|
37
|
+
value += character;
|
|
38
|
+
index += 1;
|
|
39
|
+
}
|
|
40
|
+
throw new Error('unterminated string literal');
|
|
41
|
+
};
|
|
42
|
+
const tokenizeDebugExpression = (source) => {
|
|
43
|
+
const tokens = [];
|
|
43
44
|
for (let index = 0; index < source.length;) {
|
|
44
45
|
const character = source[index];
|
|
45
46
|
if (!character)
|
|
@@ -58,6 +59,11 @@ export function evaluateDebugExpression(expression, variables) {
|
|
|
58
59
|
index += 1;
|
|
59
60
|
continue;
|
|
60
61
|
}
|
|
62
|
+
if (character === '.') {
|
|
63
|
+
tokens.push({ type: 'dot' });
|
|
64
|
+
index += 1;
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
61
67
|
const operator = operators.find((candidate) => source.startsWith(candidate, index));
|
|
62
68
|
if (operator) {
|
|
63
69
|
tokens.push({ type: 'operator', value: operator });
|
|
@@ -107,109 +113,253 @@ export function evaluateDebugExpression(expression, variables) {
|
|
|
107
113
|
}
|
|
108
114
|
throw new Error(`unsupported token near "${source.slice(index)}"`);
|
|
109
115
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
index = item.next;
|
|
116
|
+
return tokens;
|
|
117
|
+
};
|
|
118
|
+
const parseDebugPreviewValueAt = (text, start = 0) => {
|
|
119
|
+
let index = start;
|
|
120
|
+
while (/\s/.test(text[index] || ''))
|
|
121
|
+
index += 1;
|
|
122
|
+
const character = text[index];
|
|
123
|
+
if (character === '[') {
|
|
124
|
+
index += 1;
|
|
125
|
+
const items = [];
|
|
126
|
+
while (true) {
|
|
127
|
+
while (/\s/.test(text[index] || ''))
|
|
128
|
+
index += 1;
|
|
129
|
+
if (text[index] === ']')
|
|
130
|
+
return { value: items, next: index + 1 };
|
|
131
|
+
if (text.startsWith('...', index)) {
|
|
132
|
+
items.truncated = true;
|
|
133
|
+
index += 3;
|
|
129
134
|
while (/\s/.test(text[index] || ''))
|
|
130
135
|
index += 1;
|
|
131
|
-
if (text[index] === ',') {
|
|
132
|
-
index += 1;
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
136
|
if (text[index] === ']')
|
|
136
137
|
return { value: items, next: index + 1 };
|
|
137
138
|
throw new Error('unsupported array preview');
|
|
138
139
|
}
|
|
140
|
+
const item = parseDebugPreviewValueAt(text, index);
|
|
141
|
+
items.push(item.value);
|
|
142
|
+
index = item.next;
|
|
143
|
+
while (/\s/.test(text[index] || ''))
|
|
144
|
+
index += 1;
|
|
145
|
+
if (text[index] === ',') {
|
|
146
|
+
index += 1;
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (text[index] === ']')
|
|
150
|
+
return { value: items, next: index + 1 };
|
|
151
|
+
throw new Error('unsupported array preview');
|
|
139
152
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
153
|
+
}
|
|
154
|
+
if (character === '(') {
|
|
155
|
+
index += 1;
|
|
156
|
+
const items = [];
|
|
157
|
+
while (true) {
|
|
158
|
+
while (/\s/.test(text[index] || ''))
|
|
159
|
+
index += 1;
|
|
160
|
+
if (text[index] === ')')
|
|
161
|
+
return { value: items, next: index + 1 };
|
|
162
|
+
if (text.startsWith('...', index)) {
|
|
163
|
+
items.truncated = true;
|
|
164
|
+
index += 3;
|
|
144
165
|
while (/\s/.test(text[index] || ''))
|
|
145
166
|
index += 1;
|
|
146
|
-
if (text[index] === ')')
|
|
147
|
-
return { value: items, next: index + 1 };
|
|
148
|
-
if (text.startsWith('...', index))
|
|
149
|
-
throw new Error('unavailable');
|
|
150
|
-
const item = parsePreviewValue(text, index);
|
|
151
|
-
items.push(item.value);
|
|
152
|
-
index = item.next;
|
|
153
|
-
while (/\s/.test(text[index] || ''))
|
|
154
|
-
index += 1;
|
|
155
|
-
if (text[index] === ',') {
|
|
156
|
-
index += 1;
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
167
|
if (text[index] === ')')
|
|
160
168
|
return { value: items, next: index + 1 };
|
|
161
169
|
throw new Error('unsupported tuple preview');
|
|
162
170
|
}
|
|
171
|
+
const item = parseDebugPreviewValueAt(text, index);
|
|
172
|
+
items.push(item.value);
|
|
173
|
+
index = item.next;
|
|
174
|
+
while (/\s/.test(text[index] || ''))
|
|
175
|
+
index += 1;
|
|
176
|
+
if (text[index] === ',') {
|
|
177
|
+
index += 1;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (text[index] === ')')
|
|
181
|
+
return { value: items, next: index + 1 };
|
|
182
|
+
throw new Error('unsupported tuple preview');
|
|
163
183
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
184
|
+
}
|
|
185
|
+
if (character === '{') {
|
|
186
|
+
index += 1;
|
|
187
|
+
const entries = {};
|
|
188
|
+
while (true) {
|
|
189
|
+
while (/\s/.test(text[index] || ''))
|
|
190
|
+
index += 1;
|
|
191
|
+
if (text[index] === '}')
|
|
192
|
+
return { value: entries, next: index + 1 };
|
|
193
|
+
if (text.startsWith('...', index))
|
|
194
|
+
throw new Error('unavailable');
|
|
195
|
+
let key = '';
|
|
196
|
+
if (text[index] === "'" || text[index] === '"') {
|
|
197
|
+
const parsedKey = parseQuotedValue(text, index);
|
|
198
|
+
key = parsedKey.value;
|
|
199
|
+
index = parsedKey.next;
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
const identifier = text.slice(index).match(/^[A-Za-z_]\w*/)?.[0];
|
|
203
|
+
if (!identifier)
|
|
204
|
+
throw new Error('unsupported object preview');
|
|
205
|
+
key = identifier;
|
|
206
|
+
index += identifier.length;
|
|
207
|
+
}
|
|
208
|
+
while (/\s/.test(text[index] || ''))
|
|
209
|
+
index += 1;
|
|
210
|
+
if (text[index] !== ':')
|
|
211
|
+
throw new Error('unsupported object preview');
|
|
212
|
+
index += 1;
|
|
213
|
+
const entry = parseDebugPreviewValueAt(text, index);
|
|
214
|
+
entries[key] = entry.value;
|
|
215
|
+
index = entry.next;
|
|
216
|
+
while (/\s/.test(text[index] || ''))
|
|
217
|
+
index += 1;
|
|
218
|
+
if (text[index] === ',') {
|
|
219
|
+
index += 1;
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
if (text[index] === '}')
|
|
223
|
+
return { value: entries, next: index + 1 };
|
|
224
|
+
throw new Error('unsupported object preview');
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (character === "'" || character === '"')
|
|
228
|
+
return parseQuotedValue(text, index);
|
|
229
|
+
if (text.startsWith('true', index))
|
|
230
|
+
return { value: true, next: index + 4 };
|
|
231
|
+
if (text.startsWith('false', index))
|
|
232
|
+
return { value: false, next: index + 5 };
|
|
233
|
+
if (text.startsWith('True', index))
|
|
234
|
+
return { value: true, next: index + 4 };
|
|
235
|
+
if (text.startsWith('False', index))
|
|
236
|
+
return { value: false, next: index + 5 };
|
|
237
|
+
if (text.startsWith('null', index))
|
|
238
|
+
return { value: null, next: index + 4 };
|
|
239
|
+
if (text.startsWith('None', index))
|
|
240
|
+
return { value: null, next: index + 4 };
|
|
241
|
+
const number = text.slice(index).match(/^-?\d+(?:\.\d+)?/);
|
|
242
|
+
if (number?.[0])
|
|
243
|
+
return { value: Number(number[0]), next: index + number[0].length };
|
|
244
|
+
throw new Error('unsupported preview');
|
|
245
|
+
};
|
|
246
|
+
export const parseStoredDebugValue = (value) => {
|
|
247
|
+
const source = value.trim();
|
|
248
|
+
if (!source || source === '?')
|
|
249
|
+
throw new Error('unavailable');
|
|
250
|
+
if (source === 'true' || source === 'false' || source === 'True' || source === 'False') {
|
|
251
|
+
return source === 'true' || source === 'True';
|
|
252
|
+
}
|
|
253
|
+
if (source === 'null' || source === 'None')
|
|
254
|
+
return null;
|
|
255
|
+
const numeric = Number(source);
|
|
256
|
+
if (!Number.isNaN(numeric))
|
|
257
|
+
return numeric;
|
|
258
|
+
if (source.startsWith('[') ||
|
|
259
|
+
source.startsWith('(') ||
|
|
260
|
+
source.startsWith('{') ||
|
|
261
|
+
source.startsWith("'") ||
|
|
262
|
+
source.startsWith('"')) {
|
|
263
|
+
const parsed = parseDebugPreviewValueAt(source);
|
|
264
|
+
const trailing = source.slice(parsed.next).trim();
|
|
265
|
+
if (trailing)
|
|
266
|
+
throw new Error('unsupported preview');
|
|
267
|
+
return parsed.value;
|
|
268
|
+
}
|
|
269
|
+
throw new Error('unsupported preview');
|
|
270
|
+
};
|
|
271
|
+
const quoteDebugString = (value) => `'${value
|
|
272
|
+
.replaceAll('\\', '\\\\')
|
|
273
|
+
.replaceAll("'", "\\'")
|
|
274
|
+
.replaceAll('\n', '\\n')
|
|
275
|
+
.replaceAll('\r', '\\r')
|
|
276
|
+
.replaceAll('\t', '\\t')}'`;
|
|
277
|
+
const formatDebugExpressionValueInternal = (value, nested, depth) => {
|
|
278
|
+
if (value === null)
|
|
279
|
+
return 'null';
|
|
280
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
281
|
+
return `${value}`;
|
|
282
|
+
if (typeof value === 'string')
|
|
283
|
+
return nested ? quoteDebugString(value) : value;
|
|
284
|
+
if (depth >= 4)
|
|
285
|
+
return '...';
|
|
286
|
+
if (Array.isArray(value)) {
|
|
287
|
+
const previewLength = Math.min(value.length, 8);
|
|
288
|
+
const items = value
|
|
289
|
+
.slice(0, previewLength)
|
|
290
|
+
.map((entry) => formatDebugExpressionValueInternal(entry, true, depth + 1));
|
|
291
|
+
return `[${items.join(', ')}${value.truncated || value.length > previewLength ? ', ...' : ''}]`;
|
|
292
|
+
}
|
|
293
|
+
if (isDebugExpressionIndexedValue(value)) {
|
|
294
|
+
const indexes = value.keys?.() || [];
|
|
295
|
+
const previewLength = Math.min(indexes.length || value.length || 0, 8);
|
|
296
|
+
const items = [];
|
|
297
|
+
for (let index = 0; index < previewLength; index += 1) {
|
|
298
|
+
const resolvedIndex = indexes[index] ?? index;
|
|
299
|
+
items.push(formatDebugExpressionValueInternal(value.get(resolvedIndex), true, depth + 1));
|
|
300
|
+
}
|
|
301
|
+
const isTruncated = value.truncated || (value.length != null && value.length > previewLength);
|
|
302
|
+
return `[${items.join(', ')}${isTruncated ? ', ...' : ''}]`;
|
|
303
|
+
}
|
|
304
|
+
if (isDebugExpressionObjectValue(value)) {
|
|
305
|
+
const keys = value.keys?.() || [];
|
|
306
|
+
const previewLength = Math.min(keys.length, 8);
|
|
307
|
+
const entries = keys.slice(0, previewLength).map((key) => {
|
|
308
|
+
return `${key}: ${formatDebugExpressionValueInternal(value.get(key), true, depth + 1)}`;
|
|
309
|
+
});
|
|
310
|
+
return `{${entries.join(', ')}${keys.length > previewLength ? ', ...' : ''}}`;
|
|
311
|
+
}
|
|
312
|
+
const keys = Object.keys(value);
|
|
313
|
+
const previewLength = Math.min(keys.length, 8);
|
|
314
|
+
const entries = keys.slice(0, previewLength).map((key) => {
|
|
315
|
+
return `${key}: ${formatDebugExpressionValueInternal(value[key], true, depth + 1)}`;
|
|
316
|
+
});
|
|
317
|
+
return `{${entries.join(', ')}${keys.length > previewLength ? ', ...' : ''}}`;
|
|
318
|
+
};
|
|
319
|
+
export const formatDebugExpressionValue = (value) => formatDebugExpressionValueInternal(value, false, 0);
|
|
320
|
+
export const evaluateDebugExpressionWithResolver = (expression, resolveIdentifier) => {
|
|
321
|
+
const source = expression.trim();
|
|
322
|
+
if (!source)
|
|
323
|
+
throw new Error('empty expression');
|
|
324
|
+
const tokens = tokenizeDebugExpression(source);
|
|
325
|
+
const parsedValues = new Map();
|
|
183
326
|
const resolveIdentifierValue = (name) => {
|
|
184
327
|
if (parsedValues.has(name))
|
|
185
328
|
return parsedValues.get(name);
|
|
186
|
-
const value =
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
329
|
+
const value = resolveIdentifier(name);
|
|
330
|
+
parsedValues.set(name, value);
|
|
331
|
+
return value;
|
|
332
|
+
};
|
|
333
|
+
const readIndexedValue = (value, index) => {
|
|
334
|
+
if (!Number.isInteger(index))
|
|
335
|
+
throw new Error('unsupported index access');
|
|
336
|
+
if (Array.isArray(value)) {
|
|
337
|
+
if (index < 0 || index >= value.length)
|
|
338
|
+
throw new Error('unavailable');
|
|
339
|
+
return value[index];
|
|
193
340
|
}
|
|
194
|
-
if (value
|
|
195
|
-
|
|
196
|
-
|
|
341
|
+
if (isDebugExpressionIndexedValue(value)) {
|
|
342
|
+
if (value.length != null && (index < 0 || index >= value.length)) {
|
|
343
|
+
throw new Error('unavailable');
|
|
344
|
+
}
|
|
345
|
+
return value.get(index);
|
|
197
346
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
347
|
+
throw new Error('unsupported index access');
|
|
348
|
+
};
|
|
349
|
+
const readMemberValue = (value, name) => {
|
|
350
|
+
if (Array.isArray(value) || isDebugExpressionIndexedValue(value) || !value) {
|
|
351
|
+
throw new Error('unsupported member access');
|
|
202
352
|
}
|
|
203
|
-
if (value
|
|
204
|
-
value.
|
|
205
|
-
|
|
206
|
-
value.
|
|
207
|
-
const parsed = parsePreviewValue(value).value;
|
|
208
|
-
parsedValues.set(name, parsed);
|
|
209
|
-
return parsed;
|
|
353
|
+
if (isDebugExpressionObjectValue(value)) {
|
|
354
|
+
if (!value.has(name))
|
|
355
|
+
throw new Error('unavailable');
|
|
356
|
+
return value.get(name);
|
|
210
357
|
}
|
|
211
|
-
|
|
358
|
+
if (typeof value !== 'object' || !Object.hasOwn(value, name))
|
|
359
|
+
throw new Error('unavailable');
|
|
360
|
+
return value[name];
|
|
212
361
|
};
|
|
362
|
+
let cursor = 0;
|
|
213
363
|
const parsePrimary = () => {
|
|
214
364
|
const token = tokens[cursor];
|
|
215
365
|
if (!token)
|
|
@@ -235,20 +385,26 @@ export function evaluateDebugExpression(expression, variables) {
|
|
|
235
385
|
let resolved = resolveIdentifierValue(token.value);
|
|
236
386
|
while (true) {
|
|
237
387
|
const bracket = tokens[cursor];
|
|
238
|
-
if (
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
388
|
+
if (bracket?.type === 'bracket' && bracket.value === '[') {
|
|
389
|
+
cursor += 1;
|
|
390
|
+
const index = Number(parseOr());
|
|
391
|
+
const closing = tokens[cursor];
|
|
392
|
+
if (!closing || closing.type !== 'bracket' || closing.value !== ']')
|
|
393
|
+
throw new Error('missing closing bracket');
|
|
394
|
+
cursor += 1;
|
|
395
|
+
resolved = readIndexedValue(resolved, index);
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
if (bracket?.type === 'dot') {
|
|
399
|
+
cursor += 1;
|
|
400
|
+
const property = tokens[cursor];
|
|
401
|
+
if (!property || property.type !== 'identifier')
|
|
402
|
+
throw new Error('missing property name');
|
|
403
|
+
cursor += 1;
|
|
404
|
+
resolved = readMemberValue(resolved, property.value);
|
|
405
|
+
continue;
|
|
406
|
+
}
|
|
407
|
+
break;
|
|
252
408
|
}
|
|
253
409
|
return resolved;
|
|
254
410
|
}
|
|
@@ -283,8 +439,9 @@ export function evaluateDebugExpression(expression, variables) {
|
|
|
283
439
|
let left = parseUnary();
|
|
284
440
|
while (true) {
|
|
285
441
|
const operator = tokens[cursor];
|
|
286
|
-
if (operator?.type !== 'operator' || !['*', '/', '%'].includes(operator.value))
|
|
442
|
+
if (operator?.type !== 'operator' || !['*', '/', '%'].includes(operator.value)) {
|
|
287
443
|
return left;
|
|
444
|
+
}
|
|
288
445
|
cursor += 1;
|
|
289
446
|
const right = parseUnary();
|
|
290
447
|
if (operator.value === '*')
|
|
@@ -319,8 +476,9 @@ export function evaluateDebugExpression(expression, variables) {
|
|
|
319
476
|
let left = parseAdd();
|
|
320
477
|
while (true) {
|
|
321
478
|
const operator = tokens[cursor];
|
|
322
|
-
if (operator?.type !== 'operator' || !['<', '<=', '>', '>='].includes(operator.value))
|
|
479
|
+
if (operator?.type !== 'operator' || !['<', '<=', '>', '>='].includes(operator.value)) {
|
|
323
480
|
return left;
|
|
481
|
+
}
|
|
324
482
|
cursor += 1;
|
|
325
483
|
const right = parseAdd();
|
|
326
484
|
const leftValue = typeof left === 'string' && typeof right === 'string' ? left : Number(left);
|
|
@@ -374,5 +532,16 @@ export function evaluateDebugExpression(expression, variables) {
|
|
|
374
532
|
const result = parseOr();
|
|
375
533
|
if (cursor !== tokens.length)
|
|
376
534
|
throw new Error('unexpected trailing tokens');
|
|
377
|
-
return
|
|
535
|
+
return formatDebugExpressionValue(result);
|
|
536
|
+
};
|
|
537
|
+
export function evaluateDebugExpression(expression, variables) {
|
|
538
|
+
const values = new Map();
|
|
539
|
+
for (const variable of variables)
|
|
540
|
+
values.set(variable.name, variable.value);
|
|
541
|
+
return evaluateDebugExpressionWithResolver(expression, (name) => {
|
|
542
|
+
const value = values.get(name);
|
|
543
|
+
if (value == null || value === '?')
|
|
544
|
+
throw new Error('unavailable');
|
|
545
|
+
return parseStoredDebugValue(value);
|
|
546
|
+
});
|
|
378
547
|
}
|
package/dist/debug/index.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
export { evaluateDebugExpression } from './expression';
|
|
2
2
|
export { selectInlineDebugLocals } from './locals';
|
|
3
3
|
export { cppDebugLanguageAdapter, pythonDebugLanguageAdapter } from './language';
|
|
4
|
-
export {
|
|
4
|
+
export { createDebugSessionController } from './controller.svelte';
|
|
5
|
+
export { MonacoDebugView, attachMonacoDebugActions } from './editor';
|
|
5
6
|
export type { DebugLanguageAdapter } from './language';
|
|
7
|
+
export type { DebugSessionController, DebugSessionControllerOptions, DebugWatchValue } from './controller.svelte';
|
|
8
|
+
export type { MonacoDebugActionsOptions } from './editor';
|
package/dist/debug/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { evaluateDebugExpression } from './expression';
|
|
2
2
|
export { selectInlineDebugLocals } from './locals';
|
|
3
3
|
export { cppDebugLanguageAdapter, pythonDebugLanguageAdapter } from './language';
|
|
4
|
-
export {
|
|
4
|
+
export { createDebugSessionController } from './controller.svelte';
|
|
5
|
+
export { MonacoDebugView, attachMonacoDebugActions } from './editor';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import Terminal from './terminal';
|
|
2
|
-
export { cppDebugLanguageAdapter, pythonDebugLanguageAdapter, evaluateDebugExpression, MonacoDebugView, selectInlineDebugLocals } from './debug';
|
|
3
|
-
import playground from './playground';
|
|
2
|
+
export { cppDebugLanguageAdapter, pythonDebugLanguageAdapter, evaluateDebugExpression, createDebugSessionController, MonacoDebugView, attachMonacoDebugActions, selectInlineDebugLocals } from './debug';
|
|
3
|
+
import playground, { createPlaygroundBinding } from './playground';
|
|
4
4
|
export default Terminal;
|
|
5
|
-
export { playground };
|
|
5
|
+
export { createPlaygroundBinding, playground };
|
|
6
6
|
export type { DebugCommand, DebugFrame, DebugSessionEvent, DebugVariable, SandboxExecutionOptions, TerminalControl } from './terminal';
|
|
7
7
|
export type { CompilerDiagnostic } from './playground/options';
|
|
8
|
+
export type { DebugSessionController, DebugSessionControllerOptions, DebugWatchValue, MonacoDebugActionsOptions } from './debug';
|
|
9
|
+
export type { PlaygroundRuntimeAssets, RuntimeAssetConfig, RuntimeAssetLoadRequest, RuntimeAssetLoader, RuntimeAssetLoaderResult } from './playground/assets';
|
|
10
|
+
export type { BoundSandbox, PlaygroundBinding, PlaygroundTerminalProps, SandboxProgress, SandboxRuntimeAssets } from './playground/sandbox';
|
|
8
11
|
export type { DebugLanguageAdapter } from './debug';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Terminal from './terminal';
|
|
2
|
-
export { cppDebugLanguageAdapter, pythonDebugLanguageAdapter, evaluateDebugExpression, MonacoDebugView, selectInlineDebugLocals } from './debug';
|
|
3
|
-
import playground from './playground';
|
|
2
|
+
export { cppDebugLanguageAdapter, pythonDebugLanguageAdapter, evaluateDebugExpression, createDebugSessionController, MonacoDebugView, attachMonacoDebugActions, selectInlineDebugLocals } from './debug';
|
|
3
|
+
import playground, { createPlaygroundBinding } from './playground';
|
|
4
4
|
export default Terminal;
|
|
5
|
-
export { playground };
|
|
5
|
+
export { createPlaygroundBinding, playground };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type ResolvedRuntimeAssetConfig, type RuntimeAssetRuntime } from './assets';
|
|
2
|
+
type ProgressLike = {
|
|
3
|
+
set?: (value: number) => void;
|
|
4
|
+
};
|
|
5
|
+
export declare class WorkerAssetBridge {
|
|
6
|
+
private worker;
|
|
7
|
+
private readonly runtime;
|
|
8
|
+
private config;
|
|
9
|
+
private readonly progress;
|
|
10
|
+
constructor(worker: Worker, runtime: RuntimeAssetRuntime, config: ResolvedRuntimeAssetConfig, progress?: ProgressLike);
|
|
11
|
+
matches(config: ResolvedRuntimeAssetConfig): boolean;
|
|
12
|
+
rebind(worker: Worker, config: ResolvedRuntimeAssetConfig, progress?: ProgressLike): void;
|
|
13
|
+
resetProgress(progress?: ProgressLike): void;
|
|
14
|
+
handleMessage(event: MessageEvent<any>): boolean;
|
|
15
|
+
private respond;
|
|
16
|
+
private loadAsset;
|
|
17
|
+
private normalizeLoaderResult;
|
|
18
|
+
private fetchAsset;
|
|
19
|
+
}
|
|
20
|
+
export {};
|