wasm-idle 1.1.2 → 1.2.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 (121) hide show
  1. package/README.md +134 -82
  2. package/dist/container/bash-profile.d.ts +80 -0
  3. package/dist/container/bash-profile.js +328 -0
  4. package/dist/{playground/container → container}/binding.d.ts +21 -8
  5. package/dist/{playground/container → container}/binding.js +109 -25
  6. package/dist/{playground/container → container}/clang-runtime.d.ts +11 -7
  7. package/dist/container/clang-runtime.js +561 -0
  8. package/dist/container/client.d.ts +14 -0
  9. package/dist/{playground/container → container}/client.js +2 -6
  10. package/dist/{playground/container → container}/explorer.d.ts +1 -1
  11. package/dist/container/index.d.ts +11 -0
  12. package/dist/container/index.js +11 -0
  13. package/dist/container/owner-worker.d.ts +19 -0
  14. package/dist/container/owner-worker.js +464 -0
  15. package/dist/{playground/container → container}/protocol.d.ts +12 -1
  16. package/dist/{playground/container → container}/runtime-adapter.d.ts +13 -11
  17. package/dist/{playground/container → container}/runtime-adapter.js +104 -41
  18. package/dist/{playground/container → container}/shell-control.d.ts +2 -2
  19. package/dist/{playground/container → container}/shell-control.js +93 -36
  20. package/dist/{playground/container → container}/workspace.d.ts +5 -1
  21. package/dist/index.d.ts +1 -1
  22. package/dist/playground/assetBridge.js +5 -2
  23. package/dist/playground/assets.d.ts +8 -0
  24. package/dist/playground/clang.d.ts +5 -1
  25. package/dist/playground/clang.js +61 -5
  26. package/dist/playground/compiledLldb.d.ts +41 -0
  27. package/dist/playground/compiledLldb.js +167 -0
  28. package/dist/playground/d.d.ts +4 -1
  29. package/dist/playground/d.js +78 -9
  30. package/dist/playground/debugDeadline.d.ts +12 -0
  31. package/dist/playground/debugDeadline.js +34 -0
  32. package/dist/playground/debugMailbox.d.ts +12 -0
  33. package/dist/playground/debugMailbox.js +77 -0
  34. package/dist/playground/go.js +9 -4
  35. package/dist/playground/goDebugInstrumentation.js +24 -44
  36. package/dist/playground/java-debug-FMHDKUN6.js +124 -0
  37. package/dist/playground/java-debug-notices.txt +492 -0
  38. package/dist/playground/java.d.ts +17 -1
  39. package/dist/playground/java.js +159 -3
  40. package/dist/playground/javaDebug.d.ts +62 -0
  41. package/dist/playground/javaDebug.js +305 -0
  42. package/dist/playground/javaDebugBridge.d.ts +6 -0
  43. package/dist/playground/javaDebugBridge.js +250 -0
  44. package/dist/playground/javaDebugSource.d.ts +9 -0
  45. package/dist/playground/javaDebugSource.js +4 -0
  46. package/dist/playground/javaRuntimeErrors.js +34 -1
  47. package/dist/playground/lean4Assets.d.ts +1 -25
  48. package/dist/playground/lean4Assets.js +2 -123
  49. package/dist/playground/lfortranAssets.d.ts +2 -2
  50. package/dist/playground/lldbSession.d.ts +23 -2
  51. package/dist/playground/lldbSession.js +278 -58
  52. package/dist/playground/lldbSourcePath.d.ts +2 -0
  53. package/dist/playground/lldbSourcePath.js +9 -0
  54. package/dist/playground/lua.d.ts +20 -1
  55. package/dist/playground/lua.js +190 -8
  56. package/dist/playground/luaDebug.d.ts +1 -0
  57. package/dist/playground/luaDebug.js +1 -0
  58. package/dist/playground/nim.d.ts +1 -0
  59. package/dist/playground/nim.js +8 -0
  60. package/dist/playground/objectivec.d.ts +7 -6
  61. package/dist/playground/objectivec.js +75 -9
  62. package/dist/playground/options.d.ts +10 -4
  63. package/dist/playground/python.d.ts +8 -1
  64. package/dist/playground/python.js +81 -6
  65. package/dist/playground/ruby.d.ts +10 -1
  66. package/dist/playground/ruby.js +66 -1
  67. package/dist/playground/rubyDebug.d.ts +21 -0
  68. package/dist/playground/rubyDebug.js +128 -0
  69. package/dist/playground/rust.d.ts +5 -1
  70. package/dist/playground/rust.js +128 -46
  71. package/dist/playground/sandbox.d.ts +8 -1
  72. package/dist/playground/staticWorkerRuntime.js +8 -2
  73. package/dist/playground/stdinBuffer.d.ts +1 -1
  74. package/dist/playground/stdinBuffer.js +19 -2
  75. package/dist/playground/tinygo.js +7 -0
  76. package/dist/playground/typescript.js +8 -0
  77. package/dist/playground/v.d.ts +3 -2
  78. package/dist/playground/v.js +66 -12
  79. package/dist/playground/wasmC3Version.d.ts +2 -2
  80. package/dist/playground/wasmC3Version.js +2 -2
  81. package/dist/playground/wasmLean4Version.d.ts +1 -110
  82. package/dist/playground/wasmLean4Version.js +2 -111
  83. package/dist/playground/wasmLfortranVersion.d.ts +2 -2
  84. package/dist/playground/wasmLfortranVersion.js +2 -2
  85. package/dist/playground/wasmLuaVersion.d.ts +1 -1
  86. package/dist/playground/wasmLuaVersion.js +1 -1
  87. package/dist/playground/wasmRustVersion.d.ts +26 -38
  88. package/dist/playground/wasmRustVersion.js +25 -40
  89. package/dist/playground/worker/clang.js +1 -1
  90. package/dist/playground/worker/cobol.js +1 -1
  91. package/dist/playground/worker/d.js +51 -2
  92. package/dist/playground/worker/fortran.js +1 -1
  93. package/dist/playground/worker/java.js +188 -35
  94. package/dist/playground/worker/javaDebugEvaluator.d.ts +16 -0
  95. package/dist/playground/worker/javaDebugEvaluator.js +44 -0
  96. package/dist/playground/worker/javaDebugRuntime.d.ts +24 -0
  97. package/dist/playground/worker/javaDebugRuntime.js +315 -0
  98. package/dist/playground/worker/javaOutput.d.ts +11 -0
  99. package/dist/playground/worker/javaOutput.js +54 -0
  100. package/dist/playground/worker/lua.js +13 -0
  101. package/dist/playground/worker/python.js +57 -22
  102. package/dist/playground/worker/ruby.js +13 -0
  103. package/dist/playground/worker/rubyDebugPreview.d.ts +2 -0
  104. package/dist/playground/worker/rubyDebugPreview.js +80 -0
  105. package/dist/playground/worker/rubyTracepoint.d.ts +16 -0
  106. package/dist/playground/worker/rubyTracepoint.js +162 -0
  107. package/dist/playground/worker/rust.js +4 -1
  108. package/dist/playground/worker/v.js +30 -5
  109. package/dist/playground/zig.js +4 -0
  110. package/package.json +55 -11
  111. package/dist/playground/container/ContainerExplorer.svelte +0 -307
  112. package/dist/playground/container/ContainerExplorer.svelte.d.ts +0 -14
  113. package/dist/playground/container/clang-runtime.js +0 -343
  114. package/dist/playground/container/client.d.ts +0 -15
  115. package/dist/playground/container/owner.worker.d.ts +0 -1
  116. package/dist/playground/container/owner.worker.js +0 -390
  117. package/dist/playground/container/release.d.ts +0 -31
  118. package/dist/playground/container/release.js +0 -612
  119. /package/dist/{playground/container → container}/explorer.js +0 -0
  120. /package/dist/{playground/container → container}/protocol.js +0 -0
  121. /package/dist/{playground/container → container}/workspace.js +0 -0
@@ -113,7 +113,7 @@ function followsLiteralType(tokens, braceIndex, closedFrame) {
113
113
  }
114
114
  return open === index - 1 || tokens[open - 1] === 'map';
115
115
  }
116
- function lineTokens(line, state) {
116
+ function lineTokens(line, state, onWord) {
117
117
  const tokens = [];
118
118
  const wordPattern = /[\p{L}_][\p{L}\p{N}_]*|\.?\d[\p{L}\p{N}_.]*/uy;
119
119
  let index = 0;
@@ -160,6 +160,7 @@ function lineTokens(line, state) {
160
160
  if (word) {
161
161
  tokens.push(/^[\p{L}_]/u.test(word) ? word : '0');
162
162
  index += word.length;
163
+ onWord?.(word, index);
163
164
  continue;
164
165
  }
165
166
  const operator = ['++', '--', ':=', '...'].find((candidate) => line.startsWith(candidate, index)) ||
@@ -194,50 +195,27 @@ function shouldInstrumentLine(line) {
194
195
  }
195
196
  function insertDebugImports(source) {
196
197
  const lines = source.split('\n');
197
- const packageIndex = lines.findIndex((line) => /^\s*package\s+\w+/.test(line));
198
- if (packageIndex === -1)
199
- return source;
200
- const importStart = lines.findIndex((line, index) => index > packageIndex && /^\s*import\b/.test(line));
201
- if (importStart === -1) {
202
- lines.splice(packageIndex + 1, 0, '', 'import (', ...debugImports.map((entry) => `\t${entry}`), ')');
203
- return lines.join('\n');
204
- }
205
- const importLine = lines[importStart] || '';
206
- if (/^\s*import\s*\(/.test(importLine)) {
207
- let importEnd = importStart + 1;
208
- for (; importEnd < lines.length; importEnd += 1) {
209
- if (/^\s*\)/.test(lines[importEnd] || ''))
210
- break;
211
- }
212
- lines.splice(importEnd, 0, ...debugImports.map((entry) => `\t${entry}`));
198
+ const state = { rawString: false, blockComment: false };
199
+ let packageKeyword = false;
200
+ for (let index = 0; index < lines.length; index += 1) {
201
+ const line = lines[index];
202
+ let packageNameEnd;
203
+ lineTokens(line, state, (word, end) => {
204
+ if (packageNameEnd !== undefined)
205
+ return;
206
+ if (packageKeyword)
207
+ packageNameEnd = end;
208
+ else if (word === 'package')
209
+ packageKeyword = true;
210
+ });
211
+ if (packageNameEnd === undefined)
212
+ continue;
213
+ // Insert before trailing comments, which may span lines or end beside an import.
214
+ // Keep the suffix on ')' so an explicit package semicolon still terminates a declaration.
215
+ lines.splice(index, 1, line.slice(0, packageNameEnd), '', 'import (', ...debugImports.map((entry) => `\t${entry}`), ')' + line.slice(packageNameEnd));
213
216
  return lines.join('\n');
214
217
  }
215
- const singleImport = importLine.replace(/^\s*import\s+/, '').trim();
216
- lines.splice(importStart, 1, 'import (', `\t${singleImport}`, ...debugImports.map((entry) => `\t${entry}`), ')');
217
- return lines.join('\n');
218
- }
219
- function insertDebugSupport(source) {
220
- const lines = source.split('\n');
221
- let insertIndex = lines.findIndex((line) => /^\s*import\b/.test(line));
222
- if (insertIndex === -1) {
223
- insertIndex = lines.findIndex((line) => /^\s*package\s+\w+/.test(line));
224
- if (insertIndex === -1)
225
- return source;
226
- insertIndex += 1;
227
- }
228
- else if (/^\s*import\s*\(/.test(lines[insertIndex] || '')) {
229
- for (; insertIndex < lines.length; insertIndex += 1) {
230
- if (/^\s*\)/.test(lines[insertIndex] || '')) {
231
- insertIndex += 1;
232
- break;
233
- }
234
- }
235
- }
236
- else {
237
- insertIndex += 1;
238
- }
239
- lines.splice(insertIndex, 0, debugSupportSource.trim());
240
- return lines.join('\n');
218
+ return source;
241
219
  }
242
220
  function instrumentFunctionLines(source) {
243
221
  const lines = source.split('\n');
@@ -355,5 +333,7 @@ function instrumentFunctionLines(source) {
355
333
  export function instrumentGoDebugSource(source) {
356
334
  if (source.includes('__wasmIdleDebugLine'))
357
335
  return source;
358
- return insertDebugSupport(insertDebugImports(instrumentFunctionLines(source)));
336
+ // Declarations may follow user code; placing them here keeps every user import
337
+ // ahead of declarations, including a second import block.
338
+ return `${insertDebugImports(instrumentFunctionLines(source))}\n\n${debugSupportSource.trim()}\n`;
359
339
  }