wasm-idle 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +250 -146
  2. package/dist/container/clang-runtime.js +32 -8
  3. package/dist/container/runtime-adapter.d.ts +2 -0
  4. package/dist/container/runtime-adapter.js +37 -8
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.js +1 -0
  7. package/dist/playground/assetBridge.js +10 -8
  8. package/dist/playground/assets.d.ts +4 -0
  9. package/dist/playground/assets.js +9 -4
  10. package/dist/playground/c3.js +1 -1
  11. package/dist/playground/compiledLldb.d.ts +2 -0
  12. package/dist/playground/compiledLldb.js +37 -2
  13. package/dist/playground/d.d.ts +1 -0
  14. package/dist/playground/d.js +18 -8
  15. package/dist/playground/index.d.ts +1 -1
  16. package/dist/playground/index.js +7 -0
  17. package/dist/playground/{java-debug-FMHDKUN6.js → java-debug-64JGCLTC.js} +1 -1
  18. package/dist/playground/java-debug-notices.txt +26 -1
  19. package/dist/playground/java.js +3 -2
  20. package/dist/playground/javaDebugBridge.js +42 -7
  21. package/dist/playground/javaDebugSource.js +4 -4
  22. package/dist/playground/javaMain.d.ts +3 -0
  23. package/dist/playground/javaMain.js +2 -0
  24. package/dist/playground/javaRuntimeErrors.d.ts +2 -1
  25. package/dist/playground/javaRuntimeErrors.js +9 -2
  26. package/dist/playground/javaSource.d.ts +1 -1
  27. package/dist/playground/javaSource.js +7 -2
  28. package/dist/playground/lldbSession.d.ts +2 -0
  29. package/dist/playground/lldbSession.js +60 -4
  30. package/dist/playground/objectivec.d.ts +1 -1
  31. package/dist/playground/objectivec.js +2 -1
  32. package/dist/playground/options.d.ts +1 -1
  33. package/dist/playground/python.d.ts +3 -0
  34. package/dist/playground/python.js +122 -2
  35. package/dist/playground/pythonCompileOptions.d.ts +52 -0
  36. package/dist/playground/pythonCompileOptions.js +40 -0
  37. package/dist/playground/scala.d.ts +34 -0
  38. package/dist/playground/scala.js +397 -0
  39. package/dist/playground/scalaAssets.d.ts +16 -0
  40. package/dist/playground/scalaAssets.js +51 -0
  41. package/dist/playground/scalaDiagnostics.d.ts +3 -0
  42. package/dist/playground/scalaDiagnostics.js +29 -0
  43. package/dist/playground/staticRuntimeModuleVersion.d.ts +1 -1
  44. package/dist/playground/staticRuntimeModuleVersion.js +1 -1
  45. package/dist/playground/staticWorkerRuntime.d.ts +2 -0
  46. package/dist/playground/staticWorkerRuntime.js +85 -11
  47. package/dist/playground/tinygo.js +21 -8
  48. package/dist/playground/tinygoExecutableGraph.js +1 -1
  49. package/dist/playground/v.d.ts +1 -0
  50. package/dist/playground/v.js +17 -7
  51. package/dist/playground/wasmC3Version.d.ts +8 -8
  52. package/dist/playground/wasmC3Version.js +8 -8
  53. package/dist/playground/wasmDebugVersion.d.ts +1 -1
  54. package/dist/playground/wasmDebugVersion.js +1 -1
  55. package/dist/playground/wasmDotnetVersion.d.ts +1 -1
  56. package/dist/playground/wasmDotnetVersion.js +1 -1
  57. package/dist/playground/wasmGoVersion.d.ts +1 -1
  58. package/dist/playground/wasmGoVersion.js +1 -1
  59. package/dist/playground/wasmLispVersion.d.ts +5 -0
  60. package/dist/playground/wasmLispVersion.js +5 -0
  61. package/dist/playground/wasmOcamlVersion.d.ts +4 -4
  62. package/dist/playground/wasmOcamlVersion.js +3 -3
  63. package/dist/playground/wasmPrologVersion.d.ts +17 -17
  64. package/dist/playground/wasmPrologVersion.js +16 -16
  65. package/dist/playground/wasmTinyGoVersion.d.ts +57 -57
  66. package/dist/playground/wasmTinyGoVersion.js +57 -57
  67. package/dist/playground/wasmTypeScriptVersion.d.ts +3 -3
  68. package/dist/playground/wasmTypeScriptVersion.js +3 -3
  69. package/dist/playground/wasmZigVersion.d.ts +7 -7
  70. package/dist/playground/wasmZigVersion.js +7 -7
  71. package/dist/playground/worker/java.js +18 -4
  72. package/dist/playground/worker/javaDebugEvaluator.js +2 -2
  73. package/dist/playground/worker/javaDebugRuntime.js +8 -1
  74. package/dist/playground/worker/javaStreaming.js +4 -2
  75. package/dist/playground/worker/ocaml.js +11 -10
  76. package/dist/playground/worker/python.js +45 -165
  77. package/dist/playground/worker/pythonCompile.d.ts +4 -0
  78. package/dist/playground/worker/pythonCompile.js +127 -0
  79. package/dist/playground/worker/pythonDebug.d.ts +20 -0
  80. package/dist/playground/worker/pythonDebug.js +205 -0
  81. package/dist/playground/worker/scala/UPSTREAM-LICENSE.txt +201 -0
  82. package/dist/playground/worker/scala/UPSTREAM-NOTICE.txt +108 -0
  83. package/dist/playground/worker/scala/asset-bootstrap.d.ts +6 -0
  84. package/dist/playground/worker/scala/asset-bootstrap.js +58 -0
  85. package/dist/playground/worker/scala/asset-receipts.d.ts +7 -0
  86. package/dist/playground/worker/scala/asset-receipts.js +58 -0
  87. package/dist/playground/worker/scala/compiler.worker.d.ts +1 -0
  88. package/dist/playground/worker/scala/compiler.worker.js +204 -0
  89. package/dist/playground/worker/scala/execution.worker.d.ts +1 -0
  90. package/dist/playground/worker/scala/execution.worker.js +89 -0
  91. package/dist/playground/worker/scala/memory-fs.d.ts +29 -0
  92. package/dist/playground/worker/scala/memory-fs.js +333 -0
  93. package/dist/playground/worker/scala/runner.d.ts +1 -0
  94. package/dist/playground/worker/scala/runner.js +36 -0
  95. package/dist/playground/worker/zig.d.ts +2 -1
  96. package/dist/playground/worker/zig.js +212 -86
  97. package/dist/playground/worker/zigDebug.d.ts +39 -0
  98. package/dist/playground/worker/zigDebug.js +156 -0
  99. package/dist/playground/zig.d.ts +27 -4
  100. package/dist/playground/zig.js +266 -23
  101. package/dist/playground/zigDebugValues.d.ts +20 -0
  102. package/dist/playground/zigDebugValues.js +248 -0
  103. package/dist/pythonCompiler.d.ts +8 -0
  104. package/dist/pythonCompiler.js +52 -0
  105. package/package.json +37 -26
@@ -566,10 +566,11 @@ class Java {
566
566
  return Promise.reject(this.releaseBeforeSession(activeOperation, 'Java execution cancelled'));
567
567
  }
568
568
  programArgs = resolveSandboxExecutionArgs('JAVA', args, options).programArgs;
569
- const { sourcePath } = resolveJavaSourceIdentity(code);
569
+ const requestedActivePath = options.activePath;
570
+ const { sourcePath } = resolveJavaSourceIdentity(code, requestedActivePath);
570
571
  limits = resolveExecutionLimits(options.limits);
571
572
  const workspaceFiles = options.workspaceFiles ?? [];
572
- const activePath = options.activePath ?? sourcePath;
573
+ const activePath = requestedActivePath ?? sourcePath;
573
574
  const workspaceLimitsSource = options.workspaceLimits;
574
575
  const workspaceLimits = workspaceLimitsSource
575
576
  ? {
@@ -19,6 +19,19 @@ import java.lang.Throwable;
19
19
  import java.lang.StackTraceElement;
20
20
 
21
21
  public final class ${className} {
22
+ public interface Inspectable {
23
+ Class<?> ${className}_fieldOwner();
24
+ int ${className}_fieldCount();
25
+ Field ${className}_field(int index);
26
+ }
27
+ public static final class Field {
28
+ final String name;
29
+ final String type;
30
+ final Object value;
31
+ public Field(String name, String type, Object value) {
32
+ this.name = name; this.type = type; this.value = value;
33
+ }
34
+ }
22
35
  private static final class Captured {
23
36
  final String kind;
24
37
  final Object value;
@@ -147,6 +160,18 @@ public final class ${className} {
147
160
  if (value instanceof double[]) return ((double[]) value).length;
148
161
  return -1;
149
162
  }
163
+ Inspectable fields(Object value) {
164
+ if (!(value instanceof Inspectable)) return null;
165
+ // A proxy can discover the generated interface at runtime and dispatch
166
+ // its methods into a user InvocationHandler. Proxy classes extend Proxy
167
+ // directly; test trusted class metadata before dispatch, without linking
168
+ // java.lang.reflect.Proxy (absent from the pinned browser SDK).
169
+ Class<?> parent = value.getClass().getSuperclass();
170
+ if (parent != null && parent.getName().equals("java.lang.reflect.Proxy")) return null;
171
+ Inspectable fields = (Inspectable) value;
172
+ // An uninstrumented anonymous subclass must not inherit a partial inspector.
173
+ return fields.${className}_fieldOwner() == value.getClass() ? fields : null;
174
+ }
150
175
  Object element(Object value, int index) {
151
176
  if (value instanceof Object[]) return ((Object[]) value)[index];
152
177
  if (value instanceof int[]) return ((int[]) value)[index];
@@ -188,6 +213,7 @@ public final class ${className} {
188
213
  String display;
189
214
  int reference = 0;
190
215
  int size = length(value);
216
+ Inspectable fields = fields(value);
191
217
  if (value == null) display = "null";
192
218
  else if (value instanceof String) {
193
219
  String text = (String) value;
@@ -200,17 +226,23 @@ public final class ${className} {
200
226
  else if (size >= 0) {
201
227
  reference = handle(value);
202
228
  display = value.getClass().getName() + " (" + size + ")";
203
- } else display = value.getClass().getName() + "@" + handle(value);
229
+ } else {
230
+ int identity = handle(value);
231
+ if (fields != null) reference = identity;
232
+ display = value.getClass().getName() + "@" + identity;
233
+ }
204
234
  return "{\"name\":" + quote(name) + ",\"type\":" + quote(type)
205
235
  + ",\"value\":" + quote(display) + ",\"variablesReference\":" + reference
206
- + (size >= 0 ? ",\"indexedVariables\":" + size : "") + "}";
236
+ + (size >= 0 ? ",\"indexedVariables\":" + size : "")
237
+ + (fields != null ? ",\"namedVariables\":" + fields.${className}_fieldCount() : "") + "}";
207
238
  }
208
239
  String variables(int reference, int start, int count) {
209
240
  if (start < 0 || count < 0 || count > 1000 || reference < 0 || reference > handles.size())
210
241
  throw new IllegalArgumentException("Invalid Java variable page");
211
- Object array = reference == 0 ? null : handles.get(reference - 1);
212
- int size = reference == 0 ? names.length : length(array);
213
- if (size < 0) throw new IllegalArgumentException("Java object has no indexed children");
242
+ Object target = reference == 0 ? null : handles.get(reference - 1);
243
+ Inspectable fields = fields(target);
244
+ int size = reference == 0 ? names.length : fields == null ? length(target) : fields.${className}_fieldCount();
245
+ if (size < 0) throw new IllegalArgumentException("Java object has no inspectable children");
214
246
  StringBuilder result = new StringBuilder("[");
215
247
  int end = start >= size ? size : start + Math.min(count, size - start);
216
248
  for (int i = start; i < end; i++) {
@@ -218,8 +250,11 @@ public final class ${className} {
218
250
  String type = reference == 0 && types[i].equals("var")
219
251
  ? (kinds[i].equals("reference") ? (values[i] == null ? "null" : values[i].getClass().getName()) : kinds[i])
220
252
  : reference == 0 ? types[i] : "";
221
- result.append(reference == 0 ? describe(names[i], type, values[i])
222
- : describe("[" + i + "]", "", element(array, i)));
253
+ if (reference == 0) result.append(describe(names[i], type, values[i]));
254
+ else if (fields != null) {
255
+ Field field = fields.${className}_field(i);
256
+ result.append(describe(field.name, field.type, field.value));
257
+ } else result.append(describe("[" + i + "]", "", element(target, i)));
223
258
  }
224
259
  return result.append(']').toString();
225
260
  }
@@ -1,4 +1,4 @@
1
- // Third-party license texts: java-debug-notices.txt beside the shared parser.
2
- import{a as l,c as B}from"./java-debug-FMHDKUN6.js";var I=new Set(["methodDeclaration","interfaceMethodDeclaration","constructorDeclaration","compactConstructorDeclaration","lambdaExpression","staticInitializer","instanceInitializer"]);function k(c,u){return Object.values(u?{[u]:c.children[u]??[]}:c.children).flat().filter(s=>"children"in s)}l(k,"nodes");function i(c,u){return k(c,u)[0]}l(i,"firstNode");function $(c,u){let s=c.children[u]?.[0];return s&&!("children"in s)?s:void 0}l($,"firstToken");function J(c,u){let s=new Map,g=[],v=l(e=>{g.push(e);for(let n of k(e))s.set(n,e),v(n)},"index");v(c);let m=l(e=>e?u.slice(e.location.startOffset,e.location.endOffset+1):"","text"),y=l((e,n)=>{for(let t=e;t;t=s.get(t))if(n(t))return t},"nearest"),S=new Set(["classBody","interfaceBody","enumBody","recordBody"]),w=l(e=>{for(let n=e;n;n=s.get(n)){if(I.has(n.name))return n;if(S.has(n.name))return}},"contextOf"),b=l((e,n)=>n.has(e.name)?[e]:k(e).flatMap(t=>b(t,n)),"descendants"),D=l((e,n)=>Object.entries(e.children).some(([t,a])=>t.endsWith("Modifier")&&a.some(r=>"children"in r&&$(r,n)!==void 0)),"hasModifier"),C=new Set(g.filter(e=>e.name==="methodDeclaration"&&m(i(i(e,"methodHeader"),"result")).trim()==="record")),O=new Set(["normalClassDeclaration","normalInterfaceDeclaration","enumDeclaration","recordDeclaration"]),N=[],o=l((e,n,t,a,r=a.location.startOffset)=>{let d=i(e,"variableDeclaratorId"),h=$(d??e,"Identifier")?.image;!h||h==="_"||N.push({name:h,type:n+m(d?i(d,"dims"):void 0),context:t,scope:a,availableFrom:r})},"add");for(let e of g.filter(n=>I.has(n.name))){if(C.has(e))continue;let n,t;if(e.name==="methodDeclaration"||e.name==="interfaceMethodDeclaration"){let a=i(e,"methodHeader");n=a?i(a,"methodDeclarator"):void 0,t=i(e,"methodBody")}else if(e.name==="constructorDeclaration")n=i(e,"constructorDeclarator"),t=i(e,"constructorBody");else if(e.name==="compactConstructorDeclaration"){let a=y(s.get(e),r=>r.name==="recordDeclaration");n=a?i(a,"recordHeader"):void 0,t=i(e,"constructorBody")}else e.name==="lambdaExpression"?(n=i(e,"lambdaParameters"),t=i(e,"lambdaBody")):t=i(e,"block");if(t){if(n){let a=new Set(["variableParaRegularParameter","variableArityParameter","regularLambdaParameter","conciseLambdaParameter","recordComponent"]);for(let r of b(n,a)){let d=m(i(r,"unannType")??i(r,"lambdaParameterType"));o(r,(d||"var")+(r.children.DotDotDot?"[]":""),e,t)}e.name==="lambdaExpression"&&n.children.Identifier&&o(n,"var",e,t)}if(e.name!=="lambdaExpression"&&e.name!=="staticInitializer"&&!D(e,"Static")){let a=y(s.get(e),h=>S.has(h.name)),r=a?s.get(a):void 0,d=r&&O.has(r.name)?m(i(r,"typeIdentifier")):"this";N.push({name:"this",type:d,context:e,scope:t,availableFrom:(i(t,"explicitConstructorInvocation")?.location.endOffset??t.location.startOffset-1)+1})}}}for(let e of g){let n=w(e);if(!n||C.has(n))continue;let t=s.get(e);if(e.name==="catchFormalParameter"&&t?.name==="catchClause"){let f=i(t,"block");f&&o(e,m(i(e,"catchType")),n,f);continue}if(e.name!=="localVariableDeclaration")continue;let a,r,d=!1;if(t?.name==="enhancedForStatement")a=i(t,"statement"),d=!0;else if(t?.name==="forInit"){let f=s.get(t);a=f?i(f,"statement"):void 0}else if(t?.name==="resource"){let f=y(t,p=>p.name==="tryWithResourcesStatement");a=f?i(f,"block"):void 0}else if(t?.name==="localVariableDeclarationStatement")a=y(t,f=>["block","constructorBody","switchBlockStatementGroup"].includes(f.name));else continue;if(!a)continue;r=Math.max(a.location.startOffset,e.location.endOffset+1);let h=i(e,"variableDeclaratorList"),x=m(i(e,"localVariableType"));for(let f of h?k(h,"variableDeclarator"):[])(d||f.children.variableInitializer)&&o(f,x,n,a,r)}return{recordLikeMethods:C,at(e,n){let t=w(e);return N.filter(a=>a.context===t&&n>=a.availableFrom&&n>=a.scope.location.startOffset&&n<=a.scope.location.endOffset)}}}l(J,"collectDebugBindings");var E=new Set(["ifStatement","whileStatement","doStatement","basicForStatement","enhancedForStatement"]);function j(c,u,s){if(s.trim()!==s||!/^[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(s))throw new Error("Invalid Java debugger helper name");if(/[\u0000-\u001f\u007f]/.test(u))throw new Error("Unsupported Java debug source path");if(/\\u+[0-9a-fA-F]{4}/.test(c))throw new Error("Java Debug does not support Unicode preprocessing escapes; use Run for this source.");let g;try{g=B(c)}catch(o){throw new Error(`Java Debug parser cannot safely instrument this syntax; use Run for this source. ${o instanceof Error?o.message:String(o)}`)}let v=J(g,c),m=[0];for(let o=0;o<c.length;o++)c[o]==="\r"?(c[o+1]===`
3
- `&&o++,m.push(o+1)):c[o]===`
4
- `&&m.push(o+1);let y=[],S=new Set,w=new Map,b=l((o,e,n=!1)=>{let t=w.get(o)??[];t.push({text:e,closing:n}),w.set(o,t)},"insert"),D=l((o,e)=>{if(S.has(e))return"";S.add(e);let n=0,t=m.length;for(;n+1<t;){let p=n+t>>>1;m[p]<=e?n=p:t=p}let a={line:n+1,column:e-m[n]+1};y.push(a);let r=v.at(o,e),d=`${JSON.stringify(u)},${a.line},${a.column}`,h=r.map(p=>JSON.stringify(p.name)).join(","),x=r.map(p=>JSON.stringify(p.type)).join(","),f=r.map(p=>`${s}.capture(${p.name})`).join(",");return`if(${s}.poll(${d}))${s}.hit(${d},new java.lang.String[]{${h}},new java.lang.String[]{${x}},new java.lang.Object[]{${f}});`},"hook"),C=l((o,e)=>{let n=o.children.LCurly?.[0];if(!n)throw new Error("Java Debug parser returned a block without its opening token");let t=e??n.endOffset+1;b(t,D(o,t))},"blockEntry"),O=l((o,e)=>{if(v.recordLikeMethods.has(o))return;let n=e[e.length-1];if(o.name==="constructorBody"){let t=o.children.explicitConstructorInvocation?.[0];C(o,t?t.location.endOffset+1:void 0)}else if(o.name==="block"&&(n?.name==="methodBody"||n?.name==="lambdaBody"||n?.name==="switchRule"))C(o);else if(o.name==="blockStatement"&&(o.children.statement||o.children.localVariableDeclarationStatement))b(o.location.startOffset,D(o,o.location.startOffset));else if(o.name==="statement"&&E.has(n?.name??"")){let a=o.children.statementWithoutTrailingSubstatement?.[0]?.children.block?.[0];a?C(a):(b(o.location.startOffset,`{${D(o,o.location.startOffset)}`),b(o.location.endOffset+1,"}",!0))}else if(o.name==="switchRule"){let t=o.children.expression?.[0],a=o.children.throwStatement?.[0],r=t??a;if(r){let d=e.findLastIndex(x=>x.name==="switchStatement"),h=e[d-1]?.name==="primaryPrefix";b(r.location.startOffset,`{${D(r,r.location.startOffset)}${t&&h?"yield ":""}`),b(o.location.endOffset+1,"}",!0)}}for(let t of Object.values(o.children))for(let a of t)"children"in a&&O(a,[...e,o])},"visit");O(g,[]);let N=c;for(let[o,e]of[...w].sort(([n],[t])=>t-n)){let n=e.sort((t,a)=>Number(a.closing)-Number(t.closing)).map(t=>t.text).join("");N=N.slice(0,o)+n+N.slice(o)}return{code:N,locations:y}}l(j,"instrumentJavaDebugSource");export{j as instrumentJavaDebugSource};
1
+ // Third-party license texts: java-debug-notices.txt beside the Java helpers.
2
+ import{a as l,c as B}from"./java-debug-64JGCLTC.js";var k=new Set(["methodDeclaration","interfaceMethodDeclaration","constructorDeclaration","compactConstructorDeclaration","lambdaExpression","staticInitializer","instanceInitializer"]);function $(c,f){return Object.values(f?{[f]:c.children[f]??[]}:c.children).flat().filter(r=>"children"in r)}l($,"nodes");function i(c,f){return $(c,f)[0]}l(i,"firstNode");function I(c,f){let r=c.children[f]?.[0];return r&&!("children"in r)?r:void 0}l(I,"firstToken");function J(c,f){let r=new Map,g=[],v=l(e=>{g.push(e);for(let n of $(e))r.set(n,e),v(n)},"index");v(c);let u=l(e=>e?f.slice(e.location.startOffset,e.location.endOffset+1):"","text"),x=l((e,n)=>{for(let t=e;t;t=r.get(t))if(n(t))return t},"nearest"),m=new Set(["classBody","interfaceBody","enumBody","recordBody"]),y=l(e=>{for(let n=e;n;n=r.get(n)){if(k.has(n.name))return n;if(m.has(n.name))return}},"contextOf"),d=l((e,n)=>n.has(e.name)?[e]:$(e).flatMap(t=>d(t,n)),"descendants"),N=l((e,n)=>Object.entries(e.children).some(([t,o])=>t.endsWith("Modifier")&&o.some(s=>"children"in s&&I(s,n)!==void 0)),"hasModifier"),w=new Set(g.filter(e=>e.name==="methodDeclaration"&&u(i(i(e,"methodHeader"),"result")).trim()==="record")),C=new Set(["normalClassDeclaration","normalInterfaceDeclaration","enumDeclaration","recordDeclaration"]),b=[],a=l((e,n,t,o,s=o.location.startOffset)=>{let h=i(e,"variableDeclaratorId"),D=I(h??e,"Identifier")?.image;!D||D==="_"||b.push({name:D,type:n+u(h?i(h,"dims"):void 0),context:t,scope:o,availableFrom:s})},"add");for(let e of g.filter(n=>k.has(n.name))){if(w.has(e))continue;let n,t;if(e.name==="methodDeclaration"||e.name==="interfaceMethodDeclaration"){let o=i(e,"methodHeader");n=o?i(o,"methodDeclarator"):void 0,t=i(e,"methodBody")}else if(e.name==="constructorDeclaration")n=i(e,"constructorDeclarator"),t=i(e,"constructorBody");else if(e.name==="compactConstructorDeclaration"){let o=x(r.get(e),s=>s.name==="recordDeclaration");n=o?i(o,"recordHeader"):void 0,t=i(e,"constructorBody")}else e.name==="lambdaExpression"?(n=i(e,"lambdaParameters"),t=i(e,"lambdaBody")):t=i(e,"block");if(t){if(n){let o=new Set(["variableParaRegularParameter","variableArityParameter","regularLambdaParameter","conciseLambdaParameter","recordComponent"]);for(let s of d(n,o)){let h=u(i(s,"unannType")??i(s,"lambdaParameterType"));a(s,(h||"var")+(s.children.DotDotDot?"[]":""),e,t)}e.name==="lambdaExpression"&&n.children.Identifier&&a(n,"var",e,t)}if(e.name!=="lambdaExpression"&&e.name!=="staticInitializer"&&!N(e,"Static")){let o=x(r.get(e),D=>m.has(D.name)),s=o?r.get(o):void 0,h=s&&C.has(s.name)?u(i(s,"typeIdentifier")):"this";b.push({name:"this",type:h,context:e,scope:t,availableFrom:(i(t,"explicitConstructorInvocation")?.location.endOffset??t.location.startOffset-1)+1})}}}for(let e of g){let n=y(e);if(!n||w.has(n))continue;let t=r.get(e);if(e.name==="catchFormalParameter"&&t?.name==="catchClause"){let p=i(t,"block");p&&a(e,u(i(e,"catchType")),n,p);continue}if(e.name!=="localVariableDeclaration")continue;let o,s,h=!1;if(t?.name==="enhancedForStatement")o=i(t,"statement"),h=!0;else if(t?.name==="forInit"){let p=r.get(t);o=p?i(p,"statement"):void 0}else if(t?.name==="resource"){let p=x(t,O=>O.name==="tryWithResourcesStatement");o=p?i(p,"block"):void 0}else if(t?.name==="localVariableDeclarationStatement")o=x(t,p=>["block","constructorBody","switchBlockStatementGroup"].includes(p.name));else continue;if(!o)continue;s=Math.max(o.location.startOffset,e.location.endOffset+1);let D=i(e,"variableDeclaratorList"),S=u(i(e,"localVariableType"));for(let p of D?$(D,"variableDeclarator"):[])(h||p.children.variableInitializer)&&a(p,S,n,o,s)}return{recordLikeMethods:w,at(e,n){let t=y(e);return b.filter(o=>o.context===t&&n>=o.availableFrom&&n>=o.scope.location.startOffset&&n<=o.scope.location.endOffset)}}}l(J,"collectDebugBindings");var M=new Set(["ifStatement","whileStatement","doStatement","basicForStatement","enhancedForStatement"]);function j(c,f,r,g){let v=`${r.split(".").at(-1)}_`;if(f.includes(v))return;let u=l(m=>m?f.slice(m.location.startOffset,m.location.endOffset+1):"","text"),x=l(m=>{if(m.name==="normalClassDeclaration"){let y=i(m,"classBody"),d=$(y,"classBodyDeclaration").flatMap(N=>{let w=i(N,"classMemberDeclaration"),C=w&&i(w,"fieldDeclaration");if(!C||$(C,"fieldModifier").some(e=>I(e,"Static")))return[];let b=u(i(C,"unannType")),a=i(C,"variableDeclaratorList");return $(a,"variableDeclarator").flatMap(e=>{let n=i(e,"variableDeclaratorId"),t=I(n,"Identifier")?.image;return t&&t!=="_"?[{name:t,type:b+u(i(n,"dims"))}]:[]})});if(d.length){let N=i(m,"classImplements"),w=i(m,"classPermits")??y;g(N?N.location.endOffset+1:w.location.startOffset,`${N?",":" implements "}${r}.Inspectable `);let C=d.slice(0,256).map((a,e)=>`case ${e}:return new ${r}.Field(${JSON.stringify(a.name)},${JSON.stringify(a.type)},this.${a.name});`);d.length>256&&C.push(`case 256:return new ${r}.Field("[remaining fields]","unavailable","${d.length-256} fields omitted (256-field inspection limit)");`);let b=`${v}Owner`;g(I(y,"RCurly").startOffset,`private static final class ${b}{}public java.lang.Class<?> ${v}fieldOwner(){return ${b}.class.getDeclaringClass();}public int ${v}fieldCount(){return ${Math.min(d.length,257)};}public ${r}.Field ${v}field(int index){switch(index){${C.join("")}default:throw new java.lang.IndexOutOfBoundsException();}}`)}}for(let y of $(m))x(y)},"visit");x(c)}l(j,"instrumentDebugFields");function T(c,f,r){if(r.trim()!==r||!/^[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*$/.test(r))throw new Error("Invalid Java debugger helper name");if(/[\u0000-\u001f\u007f]/.test(f))throw new Error("Unsupported Java debug source path");if(/\\u+[0-9a-fA-F]{4}/.test(c))throw new Error("Java Debug does not support Unicode preprocessing escapes; use Run for this source.");let g;try{g=B(c)}catch(a){throw new Error(`Java Debug parser cannot safely instrument this syntax; use Run for this source. ${a instanceof Error?a.message:String(a)}`)}let v=J(g,c),u=[0];for(let a=0;a<c.length;a++)c[a]==="\r"?(c[a+1]===`
3
+ `&&a++,u.push(a+1)):c[a]===`
4
+ `&&u.push(a+1);let x=[],m=new Set,y=new Map,d=l((a,e,n=!1)=>{let t=y.get(a)??[];t.push({text:e,closing:n}),y.set(a,t)},"insert"),N=l((a,e)=>{if(m.has(e))return"";m.add(e);let n=0,t=u.length;for(;n+1<t;){let O=n+t>>>1;u[O]<=e?n=O:t=O}let o={line:n+1,column:e-u[n]+1};x.push(o);let s=v.at(a,e),h=`${JSON.stringify(f)},${o.line},${o.column}`,D=s.map(O=>JSON.stringify(O.name)).join(","),S=s.map(O=>JSON.stringify(O.type)).join(","),p=s.map(O=>`${r}.capture(${O.name})`).join(",");return`if(${r}.poll(${h}))${r}.hit(${h},new java.lang.String[]{${D}},new java.lang.String[]{${S}},new java.lang.Object[]{${p}});`},"hook"),w=l((a,e)=>{let n=a.children.LCurly?.[0];if(!n)throw new Error("Java Debug parser returned a block without its opening token");let t=e??n.endOffset+1;d(t,N(a,t))},"blockEntry"),C=l((a,e)=>{if(v.recordLikeMethods.has(a))return;let n=e[e.length-1];if(a.name==="constructorBody"){let t=a.children.explicitConstructorInvocation?.[0];w(a,t?t.location.endOffset+1:void 0)}else if(a.name==="block"&&(n?.name==="methodBody"||n?.name==="lambdaBody"||n?.name==="switchRule"))w(a);else if(a.name==="blockStatement"&&(a.children.statement||a.children.localVariableDeclarationStatement))d(a.location.startOffset,N(a,a.location.startOffset));else if(a.name==="statement"&&M.has(n?.name??"")){let o=a.children.statementWithoutTrailingSubstatement?.[0]?.children.block?.[0];o?w(o):(d(a.location.startOffset,`{${N(a,a.location.startOffset)}`),d(a.location.endOffset+1,"}",!0))}else if(a.name==="switchRule"){let t=a.children.expression?.[0],o=a.children.throwStatement?.[0],s=t??o;if(s){let h=e.findLastIndex(S=>S.name==="switchStatement"),D=e[h-1]?.name==="primaryPrefix";d(s.location.startOffset,`{${N(s,s.location.startOffset)}${t&&D?"yield ":""}`),d(a.location.endOffset+1,"}",!0)}}for(let t of Object.values(a.children))for(let o of t)"children"in o&&C(o,[...e,a])},"visit");C(g,[]),j(g,c,r,d);let b=c;for(let[a,e]of[...y].sort(([n],[t])=>t-n)){let n=e.sort((t,o)=>Number(o.closing)-Number(t.closing)).map(t=>t.text).join("");b=b.slice(0,a)+n+b.slice(a)}return{code:b,locations:x}}l(T,"instrumentJavaDebugSource");export{T as instrumentJavaDebugSource};
@@ -0,0 +1,3 @@
1
+ export type JavaMainInvocation = 'static-args' | 'instance-args' | 'static-noargs' | 'instance-noargs';
2
+ /** Inspect actual javac output: a compatible method reference can also accept Object overloads. */
3
+ export declare function selectJavaMainInvocation(classFile: Uint8Array): JavaMainInvocation;
@@ -0,0 +1,2 @@
1
+ // Third-party license texts: java-debug-notices.txt beside the Java helpers.
2
+ var e;(function(t){t[t.AALOAD=50]="AALOAD",t[t.AASTORE=83]="AASTORE",t[t.ACONST_NULL=1]="ACONST_NULL",t[t.ALOAD=25]="ALOAD",t[t.ALOAD_0=42]="ALOAD_0",t[t.ALOAD_1=43]="ALOAD_1",t[t.ALOAD_2=44]="ALOAD_2",t[t.ALOAD_3=45]="ALOAD_3",t[t.ANEWARRAY=189]="ANEWARRAY",t[t.ARETURN=176]="ARETURN",t[t.ARRAYLENGTH=190]="ARRAYLENGTH",t[t.ASTORE=58]="ASTORE",t[t.ASTORE_0=75]="ASTORE_0",t[t.ASTORE_1=76]="ASTORE_1",t[t.ASTORE_2=77]="ASTORE_2",t[t.ASTORE_3=78]="ASTORE_3",t[t.ATHROW=191]="ATHROW",t[t.BALOAD=51]="BALOAD",t[t.BASTORE=84]="BASTORE",t[t.BIPUSH=16]="BIPUSH",t[t.CALOAD=52]="CALOAD",t[t.CASTORE=85]="CASTORE",t[t.CHECKCAST=192]="CHECKCAST",t[t.D2F=144]="D2F",t[t.D2I=142]="D2I",t[t.D2L=143]="D2L",t[t.DADD=99]="DADD",t[t.DALOAD=49]="DALOAD",t[t.DASTORE=82]="DASTORE",t[t.DCMPG=152]="DCMPG",t[t.DCMPL=151]="DCMPL",t[t.DCONST_0=14]="DCONST_0",t[t.DCONST_1=15]="DCONST_1",t[t.DDIV=111]="DDIV",t[t.DLOAD=24]="DLOAD",t[t.DLOAD_0=38]="DLOAD_0",t[t.DLOAD_1=39]="DLOAD_1",t[t.DLOAD_2=40]="DLOAD_2",t[t.DLOAD_3=41]="DLOAD_3",t[t.DMUL=107]="DMUL",t[t.DNEG=119]="DNEG",t[t.DREM=115]="DREM",t[t.DRETURN=175]="DRETURN",t[t.DSTORE=57]="DSTORE",t[t.DSTORE_0=71]="DSTORE_0",t[t.DSTORE_1=72]="DSTORE_1",t[t.DSTORE_2=73]="DSTORE_2",t[t.DSTORE_3=74]="DSTORE_3",t[t.DSUB=103]="DSUB",t[t.DUP=89]="DUP",t[t.DUP_X1=90]="DUP_X1",t[t.DUP_X2=91]="DUP_X2",t[t.DUP2=92]="DUP2",t[t.DUP2_X1=93]="DUP2_X1",t[t.DUP2_X2=94]="DUP2_X2",t[t.F2D=141]="F2D",t[t.F2I=139]="F2I",t[t.F2L=140]="F2L",t[t.FADD=98]="FADD",t[t.FALOAD=48]="FALOAD",t[t.FASTORE=81]="FASTORE",t[t.FCMPG=150]="FCMPG",t[t.FCMPL=149]="FCMPL",t[t.FCONST_0=11]="FCONST_0",t[t.FCONST_1=12]="FCONST_1",t[t.FCONST_2=13]="FCONST_2",t[t.FDIV=110]="FDIV",t[t.FLOAD=23]="FLOAD",t[t.FLOAD_0=34]="FLOAD_0",t[t.FLOAD_1=35]="FLOAD_1",t[t.FLOAD_2=36]="FLOAD_2",t[t.FLOAD_3=37]="FLOAD_3",t[t.FMUL=106]="FMUL",t[t.FNEG=118]="FNEG",t[t.FREM=114]="FREM",t[t.FRETURN=174]="FRETURN",t[t.FSTORE=56]="FSTORE",t[t.FSTORE_0=67]="FSTORE_0",t[t.FSTORE_1=68]="FSTORE_1",t[t.FSTORE_2=69]="FSTORE_2",t[t.FSTORE_3=70]="FSTORE_3",t[t.FSUB=102]="FSUB",t[t.GETFIELD=180]="GETFIELD",t[t.GETSTATIC=178]="GETSTATIC",t[t.GOTO=167]="GOTO",t[t.GOTO_W=200]="GOTO_W",t[t.I2B=145]="I2B",t[t.I2C=146]="I2C",t[t.I2D=135]="I2D",t[t.I2F=134]="I2F",t[t.I2L=133]="I2L",t[t.I2S=147]="I2S",t[t.IADD=96]="IADD",t[t.IALOAD=46]="IALOAD",t[t.IAND=126]="IAND",t[t.IASTORE=79]="IASTORE",t[t.ICONST_M1=2]="ICONST_M1",t[t.ICONST_0=3]="ICONST_0",t[t.ICONST_1=4]="ICONST_1",t[t.ICONST_2=5]="ICONST_2",t[t.ICONST_3=6]="ICONST_3",t[t.ICONST_4=7]="ICONST_4",t[t.ICONST_5=8]="ICONST_5",t[t.IDIV=108]="IDIV",t[t.IF_ACMPEQ=165]="IF_ACMPEQ",t[t.IF_ACMPNE=166]="IF_ACMPNE",t[t.IF_ICMPEQ=159]="IF_ICMPEQ",t[t.IF_ICMPNE=160]="IF_ICMPNE",t[t.IF_ICMPLT=161]="IF_ICMPLT",t[t.IF_ICMPGE=162]="IF_ICMPGE",t[t.IF_ICMPGT=163]="IF_ICMPGT",t[t.IF_ICMPLE=164]="IF_ICMPLE",t[t.IFEQ=153]="IFEQ",t[t.IFNE=154]="IFNE",t[t.IFLT=155]="IFLT",t[t.IFGE=156]="IFGE",t[t.IFGT=157]="IFGT",t[t.IFLE=158]="IFLE",t[t.IFNONNULL=199]="IFNONNULL",t[t.IFNULL=198]="IFNULL",t[t.IINC=132]="IINC",t[t.ILOAD=21]="ILOAD",t[t.ILOAD_0=26]="ILOAD_0",t[t.ILOAD_1=27]="ILOAD_1",t[t.ILOAD_2=28]="ILOAD_2",t[t.ILOAD_3=29]="ILOAD_3",t[t.IMUL=104]="IMUL",t[t.INEG=116]="INEG",t[t.INSTANCEOF=193]="INSTANCEOF",t[t.INVOKEDYNAMIC=186]="INVOKEDYNAMIC",t[t.INVOKEINTERFACE=185]="INVOKEINTERFACE",t[t.INVOKESPECIAL=183]="INVOKESPECIAL",t[t.INVOKESTATIC=184]="INVOKESTATIC",t[t.INVOKEVIRTUAL=182]="INVOKEVIRTUAL",t[t.IOR=128]="IOR",t[t.IREM=112]="IREM",t[t.IRETURN=172]="IRETURN",t[t.ISHL=120]="ISHL",t[t.ISHR=122]="ISHR",t[t.ISTORE=54]="ISTORE",t[t.ISTORE_0=59]="ISTORE_0",t[t.ISTORE_1=60]="ISTORE_1",t[t.ISTORE_2=61]="ISTORE_2",t[t.ISTORE_3=62]="ISTORE_3",t[t.ISUB=100]="ISUB",t[t.IUSHR=124]="IUSHR",t[t.IXOR=130]="IXOR",t[t.JSR=168]="JSR",t[t.JSR_W=201]="JSR_W",t[t.L2D=138]="L2D",t[t.L2F=137]="L2F",t[t.L2I=136]="L2I",t[t.LADD=97]="LADD",t[t.LALOAD=47]="LALOAD",t[t.LAND=127]="LAND",t[t.LASTORE=80]="LASTORE",t[t.LCMP=148]="LCMP",t[t.LCONST_0=9]="LCONST_0",t[t.LCONST_1=10]="LCONST_1",t[t.LDC=18]="LDC",t[t.LDC_W=19]="LDC_W",t[t.LDC2_W=20]="LDC2_W",t[t.LDIV=109]="LDIV",t[t.LLOAD=22]="LLOAD",t[t.LLOAD_0=30]="LLOAD_0",t[t.LLOAD_1=31]="LLOAD_1",t[t.LLOAD_2=32]="LLOAD_2",t[t.LLOAD_3=33]="LLOAD_3",t[t.LMUL=105]="LMUL",t[t.LNEG=117]="LNEG",t[t.LOOKUPSWITCH=171]="LOOKUPSWITCH",t[t.LOR=129]="LOR",t[t.LREM=113]="LREM",t[t.LRETURN=173]="LRETURN",t[t.LSHL=121]="LSHL",t[t.LSHR=123]="LSHR",t[t.LSTORE=55]="LSTORE",t[t.LSTORE_0=63]="LSTORE_0",t[t.LSTORE_1=64]="LSTORE_1",t[t.LSTORE_2=65]="LSTORE_2",t[t.LSTORE_3=66]="LSTORE_3",t[t.LSUB=101]="LSUB",t[t.LUSHR=125]="LUSHR",t[t.LXOR=131]="LXOR",t[t.MONITORENTER=194]="MONITORENTER",t[t.MONITOREXIT=195]="MONITOREXIT",t[t.MULTIANEWARRAY=197]="MULTIANEWARRAY",t[t.NEW=187]="NEW",t[t.NEWARRAY=188]="NEWARRAY",t[t.NOP=0]="NOP",t[t.POP=87]="POP",t[t.POP2=88]="POP2",t[t.PUTFIELD=181]="PUTFIELD",t[t.PUTSTATIC=179]="PUTSTATIC",t[t.RET=169]="RET",t[t.RETURN=177]="RETURN",t[t.SALOAD=53]="SALOAD",t[t.SASTORE=86]="SASTORE",t[t.SIPUSH=17]="SIPUSH",t[t.SWAP=95]="SWAP",t[t.TABLESWITCH=170]="TABLESWITCH",t[t.WIDE=196]="WIDE"})(e||(e={}));var _;(function(t){t[t.PUBLIC=1]="PUBLIC",t[t.PRIVATE=2]="PRIVATE",t[t.PROTECTED=4]="PROTECTED",t[t.STATIC=8]="STATIC",t[t.FINAL=16]="FINAL",t[t.OPEN=32]="OPEN",t[t.TRANSITIVE=32]="TRANSITIVE",t[t.SUPER=32]="SUPER",t[t.SYNCHRONIZED=32]="SYNCHRONIZED",t[t.STATIC_PHASE=64]="STATIC_PHASE",t[t.VOLATILE=64]="VOLATILE",t[t.BRIDGE=64]="BRIDGE",t[t.TRANSIENT=128]="TRANSIENT",t[t.VARARGS=128]="VARARGS",t[t.NATIVE=256]="NATIVE",t[t.INTERFACE=512]="INTERFACE",t[t.ABSTRACT=1024]="ABSTRACT",t[t.STRICT=2048]="STRICT",t[t.SYNTHETIC=4096]="SYNTHETIC",t[t.ANNOTATION=8192]="ANNOTATION",t[t.ENUM=16384]="ENUM",t[t.MANDATED=32768]="MANDATED",t[t.MODULE=32768]="MODULE"})(_||(_={}));var o;(function(t){t.CONSTANT_VALUE="ConstantValue",t.CODE="Code",t.STACK_MAP_TABLE="StackMapTable",t.EXCEPTIONS="Exceptions",t.INNER_CLASSES="InnerClasses",t.ENCLOSING_METHOD="EnclosingMethod",t.SYNTHETIC="Synthetic",t.SIGNATURE="Signature",t.SOURCE_FILE="SourceFile",t.SOURCE_DEBUG_EXTENSION="SourceDebugExtension",t.LINE_NUMBER_TABLE="LineNumberTable",t.LOCAL_VARIABLE_TABLE="LocalVariableTable",t.LOCAL_VARIABLE_TYPE_TABLE="LocalVariableTypeTable",t.DEPRECATED="Deprecated",t.RUNTIME_VISIBLE_ANNOTATIONS="RuntimeVisibleAnnotations",t.RUNTIME_INVISIBLE_ANNOTATIONS="RuntimeInvisibleAnnotations",t.RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS="RuntimeVisibleParameterAnnotations",t.RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS="RuntimeInvisibleParameterAnnotations",t.RUNTIME_VISIBLE_TYPE_ANNOTATIONS="RuntimeVisibleTypeAnnotations",t.RUNTIME_INVISIBLE_TYPE_ANNOTATIONS="RuntimeInvisibleTypeAnnotations",t.ANNOTATION_DEFAULT="AnnotationDefault",t.BOOTSTRAP_METHODS="BootstrapMethods",t.METHOD_PARAMETERS="MethodParameters",t.MODULE="Module",t.MODULE_PACKAGES="ModulePackages",t.MODULE_MAIN_CLASS="ModuleMainClass",t.NEST_HOST="NestHost",t.NEST_MEMBERS="NestMembers",t.RECORD="Record",t.PERMITTED_SUBCLASSES="PermittedSubclasses"})(o||(o={}));var A;(function(t){t[t.UTF8=1]="UTF8",t[t.INTEGER=3]="INTEGER",t[t.FLOAT=4]="FLOAT",t[t.LONG=5]="LONG",t[t.DOUBLE=6]="DOUBLE",t[t.CLASS=7]="CLASS",t[t.STRING=8]="STRING",t[t.FIELDREF=9]="FIELDREF",t[t.METHODREF=10]="METHODREF",t[t.INTERFACE_METHODREF=11]="INTERFACE_METHODREF",t[t.NAME_AND_TYPE=12]="NAME_AND_TYPE",t[t.METHOD_HANDLE=15]="METHOD_HANDLE",t[t.METHOD_TYPE=16]="METHOD_TYPE",t[t.DYNAMIC=17]="DYNAMIC",t[t.INVOKE_DYNAMIC=18]="INVOKE_DYNAMIC",t[t.MODULE=19]="MODULE",t[t.PACKAGE=20]="PACKAGE"})(A||(A={}));var x;(function(t){t[t.GET_FIELD=1]="GET_FIELD",t[t.GET_STATIC=2]="GET_STATIC",t[t.PUT_FIELD=3]="PUT_FIELD",t[t.PUT_STATIC=4]="PUT_STATIC",t[t.INVOKE_VIRTUAL=5]="INVOKE_VIRTUAL",t[t.INVOKE_STATIC=6]="INVOKE_STATIC",t[t.INVOKE_SPECIAL=7]="INVOKE_SPECIAL",t[t.NEW_INVOKE_SPECIAL=8]="NEW_INVOKE_SPECIAL",t[t.INVOKE_INTERFACE=9]="INVOKE_INTERFACE"})(x||(x={}));var M;(function(t){t[t.BOOLEAN=4]="BOOLEAN",t[t.CHAR=5]="CHAR",t[t.FLOAT=6]="FLOAT",t[t.DOUBLE=7]="DOUBLE",t[t.BYTE=8]="BYTE",t[t.SHORT=9]="SHORT",t[t.INT=10]="INT",t[t.LONG=11]="LONG"})(M||(M={}));var N;(function(t){t.BYTE="B",t.CHAR="C",t.DOUBLE="D",t.FLOAT="F",t.INT="I",t.LONG="J",t.SHORT="S",t.BOOLEAN="Z",t.STRING="s",t.ENUM="e",t.CLASS="c",t.ANNOTATION="@",t.ARRAY="["})(N||(N={}));var k=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength),m=(t,r)=>{if(r<=0)return;let n=t.offset+r;if(n>t.view.buffer.byteLength){let s=new ArrayBuffer(n+32);new Uint8Array(s,0,t.view.byteLength).set(k(t.view)),t.view=new DataView(s,0,n)}else t.view=new DataView(t.view.buffer,t.view.byteOffset,n)},I=(t,r=!1)=>({view:new DataView(t.buffer,t.byteOffset,t.byteLength),offset:0,littleEndian:r,get arrayView(){return k(this.view)},get(n,s=!1){if(this.offset+n>this.view.byteLength)throw new Error(`Wanted ${n} byte(s), ${this.view.byteLength-this.offset} remaining`);let i=this.view.byteOffset+this.offset,E=s?new Uint8Array(this.view.buffer.slice(i,i+n)):new Uint8Array(this.view.buffer,i,n);return this.offset+=n,E},getBigInt64(){let n=this.view.getBigInt64(this.offset,this.littleEndian);return this.offset+=8,n},getBigUint64(){let n=this.view.getBigUint64(this.offset,this.littleEndian);return this.offset+=8,n},getFloat32(){let n=this.view.getFloat32(this.offset,this.littleEndian);return this.offset+=4,n},getFloat64(){let n=this.view.getFloat64(this.offset,this.littleEndian);return this.offset+=8,n},getInt16(){let n=this.view.getInt16(this.offset,this.littleEndian);return this.offset+=2,n},getInt32(){let n=this.view.getInt32(this.offset,this.littleEndian);return this.offset+=4,n},getInt8(){let n=this.view.getInt8(this.offset);return this.offset+=1,n},getUint16(){let n=this.view.getUint16(this.offset,this.littleEndian);return this.offset+=2,n},getUint32(){let n=this.view.getUint32(this.offset,this.littleEndian);return this.offset+=4,n},getUint8(){let n=this.view.getUint8(this.offset);return this.offset+=1,n},set(n){m(this,n.length),new Uint8Array(this.view.buffer,this.view.byteOffset+this.offset,n.length).set(n),this.offset+=n.length},setBigInt64(n){m(this,8),this.view.setBigInt64(this.offset,n,this.littleEndian),this.offset+=8},setBigUint64(n){m(this,8),this.view.setBigUint64(this.offset,n,this.littleEndian),this.offset+=8},setFloat32(n){m(this,4),this.view.setFloat32(this.offset,n,this.littleEndian),this.offset+=4},setFloat64(n){m(this,8),this.view.setFloat64(this.offset,n,this.littleEndian),this.offset+=8},setInt16(n){m(this,2),this.view.setInt16(this.offset,n,this.littleEndian),this.offset+=2},setInt32(n){m(this,4),this.view.setInt32(this.offset,n,this.littleEndian),this.offset+=4},setInt8(n){m(this,1),this.view.setInt8(this.offset,n),this.offset+=1},setUint16(n){m(this,2),this.view.setUint16(this.offset,n,this.littleEndian),this.offset+=2},setUint32(n){m(this,4),this.view.setUint32(this.offset,n,this.littleEndian),this.offset+=4},setUint8(n){m(this,1),this.view.setUint8(this.offset,n),this.offset+=1}});var l;(function(t){t[t.OBJECT=0]="OBJECT",t[t.PRIMITIVE=1]="PRIMITIVE",t[t.METHOD=2]="METHOD",t[t.ARRAY=3]="ARRAY",t[t.TYPE_VARIABLE=4]="TYPE_VARIABLE",t[t.TYPE_PARAMETER=5]="TYPE_PARAMETER",t[t.PARAMETERIZED=6]="PARAMETERIZED",t[t.WILDCARD=7]="WILDCARD",t[t.CLASS=8]="CLASS"})(l||(l={}));var U={VOID:{kind:l.PRIMITIVE,get value(){return"V"},get name(){return"void"}},BOOLEAN:{kind:l.PRIMITIVE,get value(){return"Z"},get name(){return"boolean"}},BYTE:{kind:l.PRIMITIVE,get value(){return"B"},get name(){return"byte"}},CHAR:{kind:l.PRIMITIVE,get value(){return"C"},get name(){return"char"}},SHORT:{kind:l.PRIMITIVE,get value(){return"S"},get name(){return"short"}},INT:{kind:l.PRIMITIVE,get value(){return"I"},get name(){return"int"}},LONG:{kind:l.PRIMITIVE,get value(){return"J"},get name(){return"long"}},FLOAT:{kind:l.PRIMITIVE,get value(){return"F"},get name(){return"float"}},DOUBLE:{kind:l.PRIMITIVE,get value(){return"D"},get name(){return"double"}}},v;(function(t){t[t.UNBOUNDED=0]="UNBOUNDED",t[t.EXTENDS=1]="EXTENDS",t[t.SUPER=2]="SUPER"})(v||(v={}));var Zt=new Map([["B",U.BYTE],["C",U.CHAR],["D",U.DOUBLE],["F",U.FLOAT],["I",U.INT],["J",U.LONG],["S",U.SHORT],["Z",U.BOOLEAN],["V",U.VOID]]);var ut=(t,r,n)=>{let s=r.getUint16();return{tag:t,value:s,valueEntry:n[s]}},_t=(t,r)=>{let n=t.getUint16(),s=t.getUint16();return{tag:N.ENUM,typeName:n,constName:s,typeNameEntry:r[n],constNameEntry:r[s]}},gt=(t,r)=>{let n=t.getUint16();return{tag:N.CLASS,classInfo:n,classInfoEntry:r[n]}},ht=(t,r)=>{let n=b(t,r);return{tag:N.ANNOTATION,annotation:n}},Ct=(t,r)=>{let n=t.getUint16(),s=new Array(n);for(let i=0;i<n;i++)s[i]=V(t,r);return{tag:N.ARRAY,values:s}},V=(t,r)=>{let n=String.fromCharCode(t.getUint8());switch(n){case N.BYTE:case N.CHAR:case N.DOUBLE:case N.FLOAT:case N.INT:case N.LONG:case N.SHORT:case N.BOOLEAN:case N.STRING:return ut(n,t,r);case N.ENUM:return _t(t,r);case N.CLASS:return gt(t,r);case N.ANNOTATION:return ht(t,r);case N.ARRAY:return Ct(t,r);default:throw new Error(`Unknown element value tag ${n}`)}},b=(t,r)=>{let n=t.getUint16(),s=t.getUint16(),i=new Array(s);for(let E=0;E<s;E++){let a=t.getUint16(),T=V(t,r);i[E]={name:a,nameEntry:r[a],value:T}}return{type:n,typeEntry:r[n],values:i}},p=(t,r)=>{let n=I(t.data),s=n.getUint16(),i=new Array(s);for(let E=0;E<s;E++)i[E]=b(n,r);return{...t,type:t.name.string,annotations:i}},G=(t,r)=>{let n=I(t.data),s=n.getUint8(),i=new Array(s);for(let E=0;E<s;E++){let a=n.getUint16(),T=new Array(a);for(let c=0;c<a;c++)T[c]=b(n,r);i[E]=T}return{...t,type:t.name.string,parameters:i}},d=(t,r)=>{let n=I(t.data),s=V(n,r);return{...t,type:o.ANNOTATION_DEFAULT,defaultValue:s}};var H=(t,r)=>{let n=I(t.data),s=n.getUint16(),i=new Array(s);for(let E=0;E<s;E++){let a=n.getUint16(),T=n.getUint16(),c=new Array(T);for(let S=0;S<T;S++){let D=n.getUint16();c[S]={index:D,entry:r[D]}}i[E]={ref:a,refEntry:r[a],args:c}}return{...t,type:o.BOOTSTRAP_METHODS,methods:i}};var Y=t=>{let r=I(t.operands);return{...t,type:t.opcode===e.NEWARRAY?r.getUint8():r.getUint16(),dimensions:t.opcode===e.MULTIANEWARRAY?r.getUint8():1}};var W=t=>{let r=I(t.operands),n=t.opcode===e.GOTO_W||t.opcode===e.JSR_W;return{...t,wide:n,branchOffset:n?r.getInt32():r.getInt16()}};var C=t=>{let r=I(t.operands),n=t.operands.length>2;return{...t,wide:n,index:n?r.getUint16():r.getUint8(),const:n?r.getInt16():r.getInt8()}};var $=t=>{let r=I(t.operands),n={...t,ref:r.getUint16()};if(t.opcode===e.INVOKEINTERFACE){let s=n;s.count=r.getUint8()}return n};var K=t=>{let r=I(t.operands),n=t.operands.length>1;return{...t,wide:n,index:n?r.getUint16():r.getUint8()}};var w=t=>{let r=I(t.operands),n=t.operands.length>1;return{...t,wide:n,index:n?r.getUint16():r.getUint8()}};var j=t=>{let r=I(t.operands);return{...t,value:t.opcode===e.SIPUSH?r.getUint16():r.getUint8()}};var X=t=>{let r=I(t.operands),n={...t,defaultOffset:r.getInt32()};if(t.opcode===e.TABLESWITCH){let s=n;s.lowCase=r.getInt32(),s.highCase=r.getInt32();let i=s.highCase-s.lowCase+1;n.jumpOffsets=new Array(i);for(let E=0;E<i;E++)n.jumpOffsets[E]=r.getInt32()}else if(t.opcode===e.LOOKUPSWITCH){let s=n,i=r.getInt32();s.cases=new Array(i),s.jumpOffsets=new Array(i);for(let E=0;E<i;E++)s.cases[E]=r.getInt32(),s.jumpOffsets[E]=r.getInt32()}else throw new Error(`Unrecognized switch opcode ${t.opcode}`);return n};var J=t=>{let r=I(t.operands);return{...t,index:r.getUint16()}};var Q=t=>{let r=I(t.operands),n={opcode:r.getUint8(),operands:r.arrayView.subarray(1),offset:t.offset+1,length:t.length-1,dirty:!1},s;switch(n.opcode){case e.ALOAD:case e.ASTORE:case e.DLOAD:case e.DSTORE:case e.FLOAD:case e.FSTORE:case e.ILOAD:case e.ISTORE:case e.LLOAD:case e.LSTORE:case e.RET:s=w(n);break;case e.IINC:s=C(n);break;default:throw new Error(`Unrecognized wide opcode ${n.opcode}`)}return{...t,insn:s}};var Ot={[e.NOP]:0,[e.ACONST_NULL]:0,[e.ICONST_M1]:0,[e.ICONST_0]:0,[e.ICONST_1]:0,[e.ICONST_2]:0,[e.ICONST_3]:0,[e.ICONST_4]:0,[e.ICONST_5]:0,[e.LCONST_0]:0,[e.LCONST_1]:0,[e.FCONST_0]:0,[e.FCONST_1]:0,[e.FCONST_2]:0,[e.DCONST_0]:0,[e.DCONST_1]:0,[e.BIPUSH]:1,[e.SIPUSH]:2,[e.LDC]:1,[e.LDC_W]:2,[e.LDC2_W]:2,[e.ILOAD]:1,[e.LLOAD]:1,[e.FLOAD]:1,[e.DLOAD]:1,[e.ALOAD]:1,[e.ILOAD_0]:0,[e.ILOAD_1]:0,[e.ILOAD_2]:0,[e.ILOAD_3]:0,[e.LLOAD_0]:0,[e.LLOAD_1]:0,[e.LLOAD_2]:0,[e.LLOAD_3]:0,[e.FLOAD_0]:0,[e.FLOAD_1]:0,[e.FLOAD_2]:0,[e.FLOAD_3]:0,[e.DLOAD_0]:0,[e.DLOAD_1]:0,[e.DLOAD_2]:0,[e.DLOAD_3]:0,[e.ALOAD_0]:0,[e.ALOAD_1]:0,[e.ALOAD_2]:0,[e.ALOAD_3]:0,[e.IALOAD]:0,[e.LALOAD]:0,[e.FALOAD]:0,[e.DALOAD]:0,[e.AALOAD]:0,[e.BALOAD]:0,[e.CALOAD]:0,[e.SALOAD]:0,[e.ISTORE]:1,[e.LSTORE]:1,[e.FSTORE]:1,[e.DSTORE]:1,[e.ASTORE]:1,[e.ISTORE_0]:0,[e.ISTORE_1]:0,[e.ISTORE_2]:0,[e.ISTORE_3]:0,[e.LSTORE_0]:0,[e.LSTORE_1]:0,[e.LSTORE_2]:0,[e.LSTORE_3]:0,[e.FSTORE_0]:0,[e.FSTORE_1]:0,[e.FSTORE_2]:0,[e.FSTORE_3]:0,[e.DSTORE_0]:0,[e.DSTORE_1]:0,[e.DSTORE_2]:0,[e.DSTORE_3]:0,[e.ASTORE_0]:0,[e.ASTORE_1]:0,[e.ASTORE_2]:0,[e.ASTORE_3]:0,[e.IASTORE]:0,[e.LASTORE]:0,[e.FASTORE]:0,[e.DASTORE]:0,[e.AASTORE]:0,[e.BASTORE]:0,[e.CASTORE]:0,[e.SASTORE]:0,[e.POP]:0,[e.POP2]:0,[e.DUP]:0,[e.DUP_X1]:0,[e.DUP_X2]:0,[e.DUP2]:0,[e.DUP2_X1]:0,[e.DUP2_X2]:0,[e.SWAP]:0,[e.IADD]:0,[e.LADD]:0,[e.FADD]:0,[e.DADD]:0,[e.ISUB]:0,[e.LSUB]:0,[e.FSUB]:0,[e.DSUB]:0,[e.IMUL]:0,[e.LMUL]:0,[e.FMUL]:0,[e.DMUL]:0,[e.IDIV]:0,[e.LDIV]:0,[e.FDIV]:0,[e.DDIV]:0,[e.IREM]:0,[e.LREM]:0,[e.FREM]:0,[e.DREM]:0,[e.INEG]:0,[e.LNEG]:0,[e.FNEG]:0,[e.DNEG]:0,[e.ISHL]:0,[e.LSHL]:0,[e.ISHR]:0,[e.LSHR]:0,[e.IUSHR]:0,[e.LUSHR]:0,[e.IAND]:0,[e.LAND]:0,[e.IOR]:0,[e.LOR]:0,[e.IXOR]:0,[e.LXOR]:0,[e.IINC]:2,[e.I2L]:0,[e.I2F]:0,[e.I2D]:0,[e.L2I]:0,[e.L2F]:0,[e.L2D]:0,[e.F2I]:0,[e.F2L]:0,[e.F2D]:0,[e.D2I]:0,[e.D2L]:0,[e.D2F]:0,[e.I2B]:0,[e.I2C]:0,[e.I2S]:0,[e.LCMP]:0,[e.FCMPL]:0,[e.FCMPG]:0,[e.DCMPL]:0,[e.DCMPG]:0,[e.IFEQ]:2,[e.IFNE]:2,[e.IFLT]:2,[e.IFGE]:2,[e.IFGT]:2,[e.IFLE]:2,[e.IF_ICMPEQ]:2,[e.IF_ICMPNE]:2,[e.IF_ICMPLT]:2,[e.IF_ICMPGE]:2,[e.IF_ICMPGT]:2,[e.IF_ICMPLE]:2,[e.IF_ACMPEQ]:2,[e.IF_ACMPNE]:2,[e.GOTO]:2,[e.JSR]:2,[e.RET]:1,[e.TABLESWITCH]:-1,[e.LOOKUPSWITCH]:-1,[e.IRETURN]:0,[e.LRETURN]:0,[e.FRETURN]:0,[e.DRETURN]:0,[e.ARETURN]:0,[e.RETURN]:0,[e.GETSTATIC]:2,[e.PUTSTATIC]:2,[e.GETFIELD]:2,[e.PUTFIELD]:2,[e.INVOKEVIRTUAL]:2,[e.INVOKESPECIAL]:2,[e.INVOKESTATIC]:2,[e.INVOKEINTERFACE]:4,[e.INVOKEDYNAMIC]:4,[e.NEW]:2,[e.NEWARRAY]:1,[e.ANEWARRAY]:2,[e.ARRAYLENGTH]:0,[e.ATHROW]:0,[e.CHECKCAST]:2,[e.INSTANCEOF]:2,[e.MONITORENTER]:0,[e.MONITOREXIT]:0,[e.WIDE]:-1,[e.MULTIANEWARRAY]:3,[e.IFNULL]:2,[e.IFNONNULL]:2,[e.GOTO_W]:4,[e.JSR_W]:4},Z=t=>{let r=[],n=0;for(;n<t.length;){let s=n,i=t[n++],E;switch(i){case e.LOOKUPSWITCH:case e.TABLESWITCH:{if(n+=n%4?4-n%4:0,i===e.TABLESWITCH){let T=t[n+4]<<24|t[n+5]<<16|t[n+6]<<8|t[n+7];E=12+((t[n+8]<<24|t[n+9]<<16|t[n+10]<<8|t[n+11])-T+1)*4}else E=8+(t[n+4]<<24|t[n+5]<<16|t[n+6]<<8|t[n+7])*8;break}case e.WIDE:E=t[n]===e.IINC?5:3;break;default:let a=Ot[i];if(a===void 0)throw new Error(`Unrecognized opcode ${i} at position ${s}`);E=a;break}n+=E,r.push({opcode:i,operands:t.subarray(n-E,n),offset:s,length:n-s,dirty:!1})}for(let s=0;s<r.length;s++){let i=r[s];switch(i.opcode){case e.IFEQ:case e.IFNE:case e.IFLT:case e.IFGE:case e.IFGT:case e.IFLE:case e.IF_ICMPEQ:case e.IF_ICMPNE:case e.IF_ICMPLT:case e.IF_ICMPGE:case e.IF_ICMPGT:case e.IF_ICMPLE:case e.IF_ACMPEQ:case e.IF_ACMPNE:case e.GOTO:case e.GOTO_W:case e.JSR:case e.JSR_W:case e.IFNULL:case e.IFNONNULL:r[s]=W(i);break;case e.TABLESWITCH:case e.LOOKUPSWITCH:r[s]=X(i);break;case e.ALOAD:case e.ASTORE:case e.DLOAD:case e.DSTORE:case e.FLOAD:case e.FSTORE:case e.ILOAD:case e.ISTORE:case e.LLOAD:case e.LSTORE:case e.RET:case e.GETFIELD:case e.GETSTATIC:case e.PUTFIELD:case e.PUTSTATIC:r[s]=w(i);break;case e.IINC:r[s]=C(i);break;case e.WIDE:r[s]=Q(i);break;case e.INVOKEDYNAMIC:case e.INVOKEINTERFACE:case e.INVOKESPECIAL:case e.INVOKESTATIC:case e.INVOKEVIRTUAL:r[s]=$(i);break;case e.LDC:case e.LDC_W:case e.LDC2_W:r[s]=K(i);break;case e.CHECKCAST:case e.INSTANCEOF:case e.NEW:r[s]=J(i);break;case e.BIPUSH:case e.SIPUSH:r[s]=j(i);break;case e.ANEWARRAY:case e.NEWARRAY:case e.MULTIANEWARRAY:r[s]=Y(i);break}}return r};var z=(t,r,n=0)=>{let s=I(t.data),i={...t,type:o.CODE,maxStack:s.getUint16(),maxLocals:s.getUint16()},E=s.getUint32();i.insns=Z(s.get(E));let a=s.getUint16();i.exceptionTable=new Array(a);for(let T=0;T<a;T++)i.exceptionTable[T]={startPC:s.getUint16(),endPC:s.getUint16(),handlerPC:s.getUint16(),catchType:s.getUint16()};return i.attrs=u(s,r,n),i};var tt=(t,r)=>{let s=I(t.data).getUint16();return{...t,type:o.CONSTANT_VALUE,constIndex:s,constEntry:r[s]}};var et=(t,r)=>{let n=I(t.data),s=n.getUint16(),i=n.getUint16();return{...t,type:o.ENCLOSING_METHOD,classIndex:s,methodIndex:i,classEntry:r[s],methodEntry:r[i]}};var nt=(t,r)=>{let n=I(t.data),s=n.getUint16(),i=new Array(s);for(let E=0;E<s;E++){let a=n.getUint16();i[E]={index:a,entry:r[a]}}return{...t,type:o.EXCEPTIONS,entries:i}};var rt=(t,r)=>{let n=I(t.data),s=n.getUint16(),i=new Array(s);for(let E=0;E<s;E++){let a=n.getUint16(),T=n.getUint16(),c=n.getUint16();i[E]={innerIndex:a,innerEntry:r[a],outerIndex:T,outerEntry:r[T],innerNameIndex:c,innerNameEntry:r[c],innerAccess:n.getUint16()}}return{...t,type:o.INNER_CLASSES,classes:i}};var st=t=>{let r=I(t.data),n=r.getUint16(),s=new Array(n);for(let i=0;i<n;i++)s[i]={startPC:r.getUint16(),lineNumber:r.getUint16()};return{...t,type:o.LINE_NUMBER_TABLE,entries:s}};var at=(t,r)=>{let n=I(t.data),s=n.getUint16(),i=new Array(s);for(let E=0;E<s;E++){let a={startPC:n.getUint16(),length:n.getUint16(),nameIndex:n.getUint16(),descriptorIndex:n.getUint16(),index:n.getUint16()};a.nameEntry=r[a.nameIndex],a.descriptorEntry=r[a.descriptorIndex],i[E]=a}return{...t,type:t.name.string,entries:i}};var it=(t,r)=>{let n=I(t.data),s=n.getUint8(),i=new Array(s);for(let E=0;E<s;E++){let a=n.getUint16(),T=n.getUint16();i[E]={nameIndex:a,accessFlags:T,nameEntry:r[a]}}return{...t,type:o.METHOD_PARAMETERS,parameters:i}};var B=(t,r)=>{let n=t.getUint16(),s=new Array(n);for(let i=0;i<n;i++){let E=t.getUint16();s[i]={index:E,entry:r[E]}}return s},Et=(t,r)=>{let n=t.getUint16(),s=new Array(n);for(let i=0;i<n;i++){let E=t.getUint16(),a=t.getUint16(),T=B(t,r);s[i]={index:E,flags:a,to:T,entry:r[E]}}return s},ot=(t,r)=>{let n=I(t.data),s=n.getUint16(),i=n.getUint16(),E=n.getUint16(),a=n.getUint16(),T=new Array(a);for(let R=0;R<a;R++){let f=n.getUint16(),F=n.getUint16(),P=n.getUint16();T[R]={index:f,flags:F,versionIndex:P,entry:r[f],versionEntry:P>0?r[P]:void 0}}let c=Et(n,r),S=Et(n,r),D=B(n,r),g=n.getUint16(),h=new Array(g);for(let R=0;R<g;R++){let f=n.getUint16(),F=B(n,r);h[R]={index:f,with:F,entry:r[f]}}return{...t,type:o.MODULE,moduleNameIndex:s,moduleFlags:i,moduleVersionIndex:E,moduleNameEntry:r[s],moduleVersionEntry:E>0?r[E]:void 0,requires:T,exports:c,opens:S,uses:D,provides:h}};var It=(t,r)=>{let n=I(t.data),s=n.getUint16(),i=new Array(s);for(let E=0;E<s;E++){let a=n.getUint16();i[E]={index:a,entry:r[a]}}return{...t,type:o.MODULE_PACKAGES,packages:i}};var At=(t,r)=>{let s=I(t.data).getUint16();return{...t,type:o.MODULE_MAIN_CLASS,mainClassIndex:s,mainClassEntry:r[s]}};var Tt=(t,r)=>{let s=I(t.data).getUint16();return{...t,type:o.NEST_HOST,hostClass:s,hostClassEntry:r[s]}};var ct=(t,r)=>{let n=I(t.data),s=n.getUint16(),i=new Array(s);for(let E=0;E<s;E++){let a=n.getUint16();i[E]={index:a,entry:r[a]}}return{...t,type:o.NEST_MEMBERS,classes:i}};var Lt=(t,r)=>{let n=I(t.data),s=n.getUint16(),i=new Array(s);for(let E=0;E<s;E++){let a=n.getUint16();i[E]={index:a,entry:r[a]}}return{...t,type:o.PERMITTED_SUBCLASSES,classes:i}};var Nt=(t,r,n=0)=>{let s=I(t.data),i=s.getUint16(),E=new Array(i);for(let a=0;a<i;a++){let T=s.getUint16(),c=s.getUint16();E[a]={name:T,nameEntry:r[T],descriptor:c,descriptorEntry:r[c],attrs:u(s,r,n)}}return{...t,type:o.RECORD,components:E}};var St=(t,r)=>{let s=I(t.data).getUint16();return{...t,type:o.SIGNATURE,signatureIndex:s,signatureEntry:r[s]}};var Ft=new TextDecoder("utf-8"),mt=t=>({...t,type:o.SOURCE_DEBUG_EXTENSION,debugExtension:Ft.decode(t.data)}),jn=new TextEncoder;var lt=(t,r)=>{let s=I(t.data).getUint16();return{...t,type:o.SOURCE_FILE,sourceFileIndex:s,sourceFileEntry:r[s]}};var Pt=(t,r,n)=>{let s=t.getUint16(),i=r[s],E=t.get(t.getInt32(),(n&O)!==0),a={dirty:!1,nameIndex:s,data:E,name:i};if((n&Rt)===0)try{switch(i?.string){case o.CODE:a=z(a,r,n);break;case o.SOURCE_FILE:a=lt(a,r);break;case o.SIGNATURE:a=St(a,r);break;case o.LOCAL_VARIABLE_TABLE:case o.LOCAL_VARIABLE_TYPE_TABLE:a=at(a,r);break;case o.EXCEPTIONS:a=nt(a,r);break;case o.CONSTANT_VALUE:a=tt(a,r);break;case o.BOOTSTRAP_METHODS:a=H(a,r);break;case o.RECORD:a=Nt(a,r,n);break;case o.PERMITTED_SUBCLASSES:a=Lt(a,r);break;case o.NEST_HOST:a=Tt(a,r);break;case o.NEST_MEMBERS:a=ct(a,r);break;case o.INNER_CLASSES:a=rt(a,r);break;case o.ENCLOSING_METHOD:a=et(a,r);break;case o.SOURCE_DEBUG_EXTENSION:a=mt(a);break;case o.LINE_NUMBER_TABLE:a=st(a);break;case o.METHOD_PARAMETERS:a=it(a,r);break;case o.MODULE:a=ot(a,r);break;case o.MODULE_MAIN_CLASS:a=At(a,r);break;case o.MODULE_PACKAGES:a=It(a,r);break;case o.RUNTIME_VISIBLE_ANNOTATIONS:case o.RUNTIME_INVISIBLE_ANNOTATIONS:a=p(a,r);break;case o.RUNTIME_VISIBLE_PARAMETER_ANNOTATIONS:case o.RUNTIME_INVISIBLE_PARAMETER_ANNOTATIONS:a=G(a,r);break;case o.ANNOTATION_DEFAULT:a=d(a,r);break;case o.DEPRECATED:case o.SYNTHETIC:a.type=a.name.string;break}}catch(T){console.warn(`failed to parse ${i?.string||"unknown"} attribute, data length ${E.length}`),console.error(T)}return a},u=(t,r,n=0)=>{let s=t.getUint16(),i=[];if((n&y)===0){i=new Array(s);for(let E=0;E<s;E++)i[E]=Pt(t,r,n)}else for(let E=0;E<s;E++){t.offset+=2;let a=t.getInt32();t.offset+=a}return i};var xt=new TextDecoder,Mt=(t,r)=>{let n=t.getUint8();switch(n){case A.UTF8:let s=t.getUint16(),i=t.get(s);return{type:n,index:r,string:xt.decode(i),bytes:i,dirty:!1};case A.INTEGER:return{type:n,index:r,value:t.getInt32()};case A.FLOAT:return{type:n,index:r,value:t.getFloat32()};case A.LONG:return{type:n,index:r,value:t.getBigInt64()};case A.DOUBLE:return{type:n,index:r,value:t.getFloat64()};case A.CLASS:return{type:n,index:r,name:t.getUint16()};case A.STRING:return{type:n,index:r,data:t.getUint16()};case A.METHOD_TYPE:return{type:n,index:r,descriptor:t.getUint16()};case A.MODULE:case A.PACKAGE:return{type:n,index:r,name:t.getUint16()};case A.FIELDREF:case A.METHODREF:case A.INTERFACE_METHODREF:return{type:n,index:r,ref:t.getUint16(),nameType:t.getUint16()};case A.NAME_AND_TYPE:return{type:n,index:r,name:t.getUint16(),type_:t.getUint16()};case A.DYNAMIC:case A.INVOKE_DYNAMIC:return{type:n,index:r,bsmIndex:t.getUint16(),nameType:t.getUint16()};case A.METHOD_HANDLE:return{type:n,index:r,kind:t.getUint8(),ref:t.getUint16()};default:throw new Error("Unrecognized constant pool tag "+n+" at position "+r)}},Vt=(t,r)=>{let n=0;for(let s=1;s<r;s++){let i=t.getUint8();switch(n+=1,i){case A.UTF8:let E=t.getUint16();t.offset+=E,n+=2+E;break;case A.INTEGER:case A.FLOAT:case A.FIELDREF:case A.METHODREF:case A.INTERFACE_METHODREF:case A.NAME_AND_TYPE:case A.DYNAMIC:case A.INVOKE_DYNAMIC:t.offset+=4,n+=4;break;case A.LONG:case A.DOUBLE:s++,t.offset+=8,n+=8;break;case A.CLASS:case A.STRING:case A.METHOD_TYPE:case A.MODULE:case A.PACKAGE:t.offset+=2,n+=2;break;case A.METHOD_HANDLE:t.offset+=3,n+=3;break;default:throw new Error("Unrecognized constant pool tag "+i+" at position "+s)}}return t.offset-=n,n},Ut=(t,r=0)=>{let n=t.getUint16(),s=new Array(n);s.fill(null);let i=(r&O)===0?t:I(t.get(Vt(t,n),!0));for(let E=1;E<n;E++){let a=Mt(i,E);s[E]=a,(a.type===A.DOUBLE||a.type===A.LONG)&&E++}for(let E=1;E<n;E++){let a=s[E];if(a)switch(a.type){case A.CLASS:let T=a;T.nameEntry=s[T.name];break;case A.STRING:let c=a;c.dataEntry=s[c.data];break;case A.NAME_AND_TYPE:let S=a;S.nameEntry=s[S.name],S.typeEntry=s[S.type_];break;case A.FIELDREF:case A.METHODREF:case A.INTERFACE_METHODREF:let D=a;D.refEntry=s[D.ref],D.nameTypeEntry=s[D.nameType];break;case A.MODULE:case A.PACKAGE:let g=a;g.nameEntry=s[g.name];break;case A.DYNAMIC:case A.INVOKE_DYNAMIC:let h=a;h.nameTypeEntry=s[h.nameType];break;case A.METHOD_HANDLE:let R=a;R.refEntry=s[R.ref];break;case A.METHOD_TYPE:let f=a;f.descriptorEntry=s[f.descriptor];break}}return s},Yr=new TextEncoder;var Dt=(t,r,n)=>({access:t.getUint16(),name:r[t.getUint16()],type:r[t.getUint16()],attrs:u(t,r,n)}),y=1,Rt=2,O=4,ft=(t,r=0)=>{let n=I(t),s={magic:n.getUint32(),minor:n.getUint16(),major:n.getUint16(),pool:Ut(n,r),access:n.getUint16()};s.thisClass=s.pool[n.getUint16()];let i=n.getUint16();i!==0&&(s.superClass=s.pool[i]);let E=n.getUint16();s.interfaces=new Array(E);for(let c=0;c<E;c++)s.interfaces[c]=s.pool[n.getUint16()];let a=n.getUint16();s.fields=new Array(a);for(let c=0;c<a;c++)s.fields[c]=Dt(n,s.pool,r);let T=n.getUint16();s.methods=new Array(T);for(let c=0;c<T;c++)s.methods[c]=Dt(n,s.pool,r);return s.attrs=u(n,s.pool,r),s};function zr(t){let r=ft(t,y);if(r.magic!==3405691582)throw new Error("Invalid Java entry class");for(let[n,s]of[["([Ljava/lang/String;)V","args"],["()V","noargs"]]){let i=r.methods.find(E=>E.name.string==="main"&&E.type.string===n&&(E.access&_.PRIVATE)===0);if(i)return`${(i.access&_.STATIC)!==0?"static":"instance"}-${s}`}throw new Error("Main method not found")}export{zr as selectJavaMainInvocation};
@@ -1,5 +1,6 @@
1
+ import type { JavaMainInvocation } from './javaMain';
1
2
  /** A real Java entry point keeps exception formatting inside the Java class library. */
2
- export declare function prepareJavaExceptionBridge(mainClass: string, sourceTexts: readonly string[], classFiles: readonly string[]): {
3
+ export declare function prepareJavaExceptionBridge(mainClass: string, sourceTexts: readonly string[], classFiles: readonly string[], invocation?: JavaMainInvocation): {
3
4
  mainClass: string;
4
5
  sourceFileName: string;
5
6
  formatterSourceFileName: string;
@@ -1,5 +1,5 @@
1
1
  /** A real Java entry point keeps exception formatting inside the Java class library. */
2
- export function prepareJavaExceptionBridge(mainClass, sourceTexts, classFiles) {
2
+ export function prepareJavaExceptionBridge(mainClass, sourceTexts, classFiles, invocation = 'static-args') {
3
3
  const packageName = mainClass.slice(0, Math.max(0, mainClass.lastIndexOf('.')));
4
4
  const packagePath = packageName ? `${packageName.replaceAll('.', '/')}/` : '';
5
5
  const entryClass = mainClass.slice(mainClass.lastIndexOf('.') + 1);
@@ -17,6 +17,13 @@ export function prepareJavaExceptionBridge(mainClass, sourceTexts, classFiles) {
17
17
  let formatExport = 'wasmIdleFormatJavaException';
18
18
  while (decodedSources.some((source) => source.includes(formatExport)))
19
19
  formatExport += '_';
20
+ const argumentsName = entryClass === 'args' ? 'args_' : 'args';
21
+ const entryCall = {
22
+ 'static-args': `${entryClass}::main`,
23
+ 'instance-args': `${argumentsName} -> new ${entryClass}().main(${argumentsName})`,
24
+ 'static-noargs': `${argumentsName} -> ${entryClass}.main()`,
25
+ 'instance-noargs': `${argumentsName} -> new ${entryClass}().main()`
26
+ }[invocation];
20
27
  return {
21
28
  mainClass: packageName ? `${packageName}.${formatterClass}` : formatterClass,
22
29
  sourceFileName: `${className}.java`,
@@ -25,7 +32,7 @@ export function prepareJavaExceptionBridge(mainClass, sourceTexts, classFiles) {
25
32
  // No imported types can hide the user entry class, even when it is named String.
26
33
  source: `${sourcePrefix}final class ${className} {
27
34
  static ${formatterClass}.Program program() {
28
- return ${entryClass}::main;
35
+ return ${entryCall};
29
36
  }
30
37
  }
31
38
  `,
@@ -2,4 +2,4 @@ export interface JavaSourceIdentity {
2
2
  mainClass: string;
3
3
  sourcePath: string;
4
4
  }
5
- export declare function resolveJavaSourceIdentity(code: string): JavaSourceIdentity;
5
+ export declare function resolveJavaSourceIdentity(code: string, activePath?: string): JavaSourceIdentity;
@@ -1,10 +1,15 @@
1
- export function resolveJavaSourceIdentity(code) {
1
+ export function resolveJavaSourceIdentity(code, activePath) {
2
2
  const packageMatch = code.match(/^\s*package\s+([A-Za-z_][\w.]*)\s*;/m);
3
3
  const typeMatch = code.match(/^\s*public\s+(?:final\s+|abstract\s+)?(?:class|record|enum|interface)\s+([A-Za-z_]\w*)\b/m) ||
4
4
  code.match(/^\s*(?:final\s+|abstract\s+)?(?:class|record|enum|interface)\s+([A-Za-z_]\w*)\b/m);
5
5
  const className = typeMatch?.[1];
6
6
  if (!className) {
7
- throw new Error('Java source must define a top-level class, record, enum, or interface');
7
+ // javac, rather than this filename helper, validates compact source syntax.
8
+ const sourcePath = activePath || 'Main.java';
9
+ return {
10
+ sourcePath,
11
+ mainClass: (sourcePath.split('/').pop() || sourcePath).replace(/\.java$/, '')
12
+ };
8
13
  }
9
14
  const packageName = packageMatch?.[1] || '';
10
15
  return {
@@ -64,6 +64,7 @@ export declare class LldbSandboxSession {
64
64
  private supportsValueFormatting;
65
65
  private command;
66
66
  private pauseRequested;
67
+ private wasiExitResumed;
67
68
  private pauseRequestVersion;
68
69
  private targetStopped;
69
70
  private entryPhase;
@@ -127,6 +128,7 @@ export declare class LldbSandboxSession {
127
128
  private finish;
128
129
  private fail;
129
130
  private publishStop;
131
+ private publishDebuggerOutput;
130
132
  private publishActiveDebugEvent;
131
133
  private trackSessionDisposal;
132
134
  private requireSession;
@@ -133,6 +133,7 @@ export class LldbSandboxSession {
133
133
  supportsValueFormatting = false;
134
134
  command = null;
135
135
  pauseRequested = false;
136
+ wasiExitResumed = false;
136
137
  pauseRequestVersion = 0;
137
138
  targetStopped = false;
138
139
  entryPhase = 'done';
@@ -189,6 +190,7 @@ export class LldbSandboxSession {
189
190
  this.entryPhase =
190
191
  this.options.pauseOnEntry && this.options.pauseAtMain ? 'initial' : 'done';
191
192
  this.pauseRequested = false;
193
+ this.wasiExitResumed = false;
192
194
  this.initialized = false;
193
195
  this.dapExitCode = null;
194
196
  let rejectCompletion;
@@ -290,6 +292,15 @@ export class LldbSandboxSession {
290
292
  },
291
293
  fetchImpl: this.options.fetchImpl,
292
294
  onOutput: (_channel, output) => this.options.onOutput(output),
295
+ onDebuggerOutput: (channel, output) => {
296
+ if (lifecycleVersion !== this.lifecycleVersion || this.session !== session)
297
+ return;
298
+ this.publishDebuggerOutput({
299
+ type: 'output',
300
+ category: channel === 'stderr' ? 'important' : 'console',
301
+ output
302
+ });
303
+ },
293
304
  onLifecycle: (event) => {
294
305
  if (lifecycleVersion !== this.lifecycleVersion || this.session !== session) {
295
306
  return;
@@ -1061,8 +1072,28 @@ export class LldbSandboxSession {
1061
1072
  handleDapEvent(event) {
1062
1073
  if (event.event === 'output') {
1063
1074
  const body = event.body;
1064
- if (typeof body?.output === 'string')
1075
+ if (typeof body?.output !== 'string')
1076
+ return;
1077
+ if (body.category === 'stdout' || body.category === 'stderr') {
1065
1078
  this.options.onOutput(body.output);
1079
+ }
1080
+ else if (body.category !== 'telemetry') {
1081
+ // DAP defaults missing or unknown categories to debugger console output.
1082
+ // Keep console logpoints and their source location available to host UIs.
1083
+ this.publishDebuggerOutput({
1084
+ type: 'output',
1085
+ category: body.category === 'important' ? 'important' : 'console',
1086
+ output: body.output,
1087
+ ...(typeof body.source?.path === 'string'
1088
+ ? { sourcePath: body.source.path }
1089
+ : {}),
1090
+ ...(typeof body.line === 'number' &&
1091
+ Number.isSafeInteger(body.line) &&
1092
+ body.line > 0
1093
+ ? { line: body.line }
1094
+ : {})
1095
+ });
1096
+ }
1066
1097
  return;
1067
1098
  }
1068
1099
  if (event.event === 'stopped') {
@@ -1092,7 +1123,8 @@ export class LldbSandboxSession {
1092
1123
  this.pauseRequested = false;
1093
1124
  const session = this.requireSession();
1094
1125
  const version = ++this.stateVersion;
1095
- void this.resolveStoppedState(threadId, reason, version).catch((error) => {
1126
+ const wasiExit = body.reason === 'exception' && body.description === 'Exception: wasi proc exit';
1127
+ void this.resolveStoppedState(threadId, reason, version, wasiExit).catch((error) => {
1096
1128
  if (version !== this.stateVersion || this.session !== session)
1097
1129
  return;
1098
1130
  this.fail(error instanceof Error ? error : new Error('Unable to read LLDB stopped state.'));
@@ -1198,7 +1230,7 @@ export class LldbSandboxSession {
1198
1230
  };
1199
1231
  });
1200
1232
  }
1201
- async resolveStoppedState(requestedThreadId, reason, version) {
1233
+ async resolveStoppedState(requestedThreadId, reason, version, wasiExit = false) {
1202
1234
  const session = this.requireSession();
1203
1235
  let threadId = requestedThreadId;
1204
1236
  if (threadId === undefined) {
@@ -1214,6 +1246,16 @@ export class LldbSandboxSession {
1214
1246
  }
1215
1247
  if (!threadId)
1216
1248
  throw new Error('LLDB stopped without a WebAssembly thread.');
1249
+ if (!this.isCurrentValueRequest(session, version))
1250
+ return;
1251
+ if (wasiExit && !this.wasiExitResumed) {
1252
+ // WAMR uses an internal exception to unwind WASI proc_exit. Resume that
1253
+ // unwind once; only the target lifecycle may decide its actual exit status.
1254
+ this.wasiExitResumed = true;
1255
+ this.activeThreadId = threadId;
1256
+ await this.debugCommand('continue');
1257
+ return;
1258
+ }
1217
1259
  const { frames, totalFrames } = await this.requestStackPage(session, threadId, 0, 1);
1218
1260
  const selectedFrame = frames[0];
1219
1261
  if (!selectedFrame)
@@ -1249,7 +1291,11 @@ export class LldbSandboxSession {
1249
1291
  reason = 'pause';
1250
1292
  }
1251
1293
  else {
1252
- this.options.onOutput(`LLDB could not resolve ${this.options.entryFunctionName ?? 'main'}; paused at runtime entry.\n`);
1294
+ this.publishDebuggerOutput({
1295
+ type: 'output',
1296
+ category: 'important',
1297
+ output: `LLDB could not resolve ${this.options.entryFunctionName ?? 'main'}; paused at runtime entry.\n`
1298
+ });
1253
1299
  }
1254
1300
  }
1255
1301
  }
@@ -1487,6 +1533,16 @@ export class LldbSandboxSession {
1487
1533
  // Consumer callbacks cannot interrupt target teardown or completion settlement.
1488
1534
  }
1489
1535
  }
1536
+ publishDebuggerOutput(event) {
1537
+ if (!event.output)
1538
+ return;
1539
+ try {
1540
+ this.options.onDebugEvent(event);
1541
+ }
1542
+ catch {
1543
+ // A diagnostics consumer must not interrupt target execution or teardown.
1544
+ }
1545
+ }
1490
1546
  publishActiveDebugEvent(event) {
1491
1547
  try {
1492
1548
  this.options.onDebugEvent(event);
@@ -36,7 +36,7 @@ declare class ObjectiveC extends CompiledLldbSandbox implements Sandbox {
36
36
  run(code: string, prepare: boolean, log?: boolean, prog?: SandboxProgress, args?: string[], options?: SandboxExecutionOptions): Promise<boolean | string>;
37
37
  debugCommand(command: DebugCommand): Promise<void> | undefined;
38
38
  setBreakpoints(lines: number[], sourcePath?: string): Promise<void> | undefined;
39
- setSourceBreakpoints(breakpoints: DebugSourceBreakpoint[], sourcePath?: string): Promise<any>;
39
+ setSourceBreakpoints(breakpoints: DebugSourceBreakpoint[], sourcePath?: string): Promise<void>;
40
40
  debugEvaluate(expression: string): Promise<string>;
41
41
  kill(): void;
42
42
  terminate(): void;
@@ -341,7 +341,6 @@ class ObjectiveC extends CompiledLldbSandbox {
341
341
  this.terminate();
342
342
  }
343
343
  terminate() {
344
- void this.stopLldb();
345
344
  this.waitingForInput = false;
346
345
  this.pendingEof = false;
347
346
  this.uid += 1;
@@ -351,6 +350,8 @@ class ObjectiveC extends CompiledLldbSandbox {
351
350
  Atomics.notify(control, 0);
352
351
  this.workerSession.terminate();
353
352
  this.exit = true;
353
+ // A stop listener may start a replacement; finish the old operation first.
354
+ void this.stopLldb();
354
355
  }
355
356
  async clear() {
356
357
  this.terminate();
@@ -16,7 +16,7 @@ export type GoTarget = 'wasip1/wasm' | 'wasip2/wasm' | 'wasip3/wasm' | 'js/wasm'
16
16
  export type TinyGoTarget = 'wasm' | 'wasip1' | 'wasip2' | 'wasip3';
17
17
  export type OcamlBackend = 'js' | 'wasm';
18
18
  export type OcamlWasmBinaryenMode = 'fast' | 'full';
19
- export type ZigTargetTriple = 'wasm64-wasi';
19
+ export type ZigTargetTriple = 'wasm32-wasi';
20
20
  export interface SandboxWorkspaceFile {
21
21
  path: string;
22
22
  content: string;
@@ -3,6 +3,7 @@ import { WorkerAssetBridge } from './assetBridge';
3
3
  import { RuntimeAssetCache } from './runtimeAssetCache';
4
4
  import { type PlaygroundRuntimeAssets } from './assets';
5
5
  import type { Sandbox, SandboxProgress } from './sandbox';
6
+ import { type PythonCompileOptions, type PythonCompileResult } from './pythonCompileOptions';
6
7
  declare class Python implements Sandbox {
7
8
  ts: number;
8
9
  output: any;
@@ -56,6 +57,8 @@ declare class Python implements Sandbox {
56
57
  load(runtimeAssets?: string | PlaygroundRuntimeAssets, code?: string, log?: boolean, _args?: string[], options?: SandboxExecutionOptions, progress?: SandboxProgress): Promise<void>;
57
58
  write(input: string): void;
58
59
  eof(): void;
60
+ /** Used by compilePython's dedicated instance; never runs source or resolves its imports. */
61
+ compile(code: string, options?: PythonCompileOptions): Promise<PythonCompileResult>;
59
62
  private flushPendingInput;
60
63
  run(code: string, prepare: boolean, _log?: boolean, _prog?: SandboxProgress, _args?: string[], options?: SandboxExecutionOptions): Promise<boolean | string>;
61
64
  debugCommand(command: DebugCommand): void;