@scelar/nodepod 1.0.3 → 1.0.4

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 (41) hide show
  1. package/dist/__sw__.js +642 -642
  2. package/dist/{child_process-D6oDN2MX.js → child_process-53fMkug_.js} +4 -4
  3. package/dist/child_process-53fMkug_.js.map +1 -0
  4. package/dist/{child_process-hmVqFcF7.cjs → child_process-lxSKECHq.cjs} +5 -5
  5. package/dist/child_process-lxSKECHq.cjs.map +1 -0
  6. package/dist/{index-Ale2oba_.js → index-B8lyh_ti.js} +1081 -428
  7. package/dist/index-B8lyh_ti.js.map +1 -0
  8. package/dist/{index-BO1i013L.cjs → index-C-TQIrdG.cjs} +1195 -430
  9. package/dist/index-C-TQIrdG.cjs.map +1 -0
  10. package/dist/index.cjs +1 -1
  11. package/dist/index.mjs +1 -1
  12. package/dist/memory-volume.d.ts +1 -1
  13. package/dist/polyfills/wasi.d.ts +45 -4
  14. package/dist/sdk/nodepod.d.ts +4 -3
  15. package/dist/sdk/types.d.ts +6 -0
  16. package/dist/threading/process-manager.d.ts +1 -1
  17. package/dist/threading/worker-protocol.d.ts +1 -1
  18. package/package.json +97 -97
  19. package/src/index.ts +192 -192
  20. package/src/memory-volume.ts +10 -4
  21. package/src/packages/version-resolver.ts +12 -2
  22. package/src/polyfills/child_process.ts +2288 -2288
  23. package/src/polyfills/fs.ts +2888 -2888
  24. package/src/polyfills/http.ts +1450 -1449
  25. package/src/polyfills/process.ts +27 -1
  26. package/src/polyfills/stream.ts +1620 -1620
  27. package/src/polyfills/wasi.ts +1284 -22
  28. package/src/request-proxy.ts +716 -716
  29. package/src/script-engine.ts +3694 -3396
  30. package/src/sdk/nodepod.ts +525 -509
  31. package/src/sdk/types.ts +7 -0
  32. package/src/syntax-transforms.ts +2 -2
  33. package/src/threading/offload-worker.ts +383 -383
  34. package/src/threading/offload.ts +271 -271
  35. package/src/threading/process-manager.ts +956 -956
  36. package/src/threading/process-worker-entry.ts +858 -854
  37. package/src/threading/worker-protocol.ts +1 -1
  38. package/dist/child_process-D6oDN2MX.js.map +0 -1
  39. package/dist/child_process-hmVqFcF7.cjs.map +0 -1
  40. package/dist/index-Ale2oba_.js.map +0 -1
  41. package/dist/index-BO1i013L.cjs.map +0 -1
package/src/sdk/types.ts CHANGED
@@ -61,6 +61,13 @@ export interface StatResult {
61
61
 
62
62
  export type Snapshot = VolumeSnapshot;
63
63
 
64
+ export interface SnapshotOptions {
65
+ /** Exclude node_modules and other auto-installable dirs. Default: true */
66
+ shallow?: boolean;
67
+ /** Auto-install deps from package.json after restoring a shallow snapshot. Default: true */
68
+ autoInstall?: boolean;
69
+ }
70
+
64
71
  /* ---- Spawn ---- */
65
72
 
66
73
  export interface SpawnOptions {
@@ -237,7 +237,7 @@ function esmToCjsViaAst(code: string): string {
237
237
  collectEsmCjsPatches(ast as any, code, patches);
238
238
 
239
239
  let output = code;
240
- patches.sort((a, b) => b[0] - a[0]);
240
+ patches.sort((a, b) => b[0] - a[0] || b[1] - a[1]);
241
241
  for (const [s, e, r] of patches)
242
242
  output = output.slice(0, s) + r + output.slice(e);
243
243
  return output;
@@ -439,7 +439,7 @@ export function stripTopLevelAwait(
439
439
  if (patches.length === 0) return code;
440
440
 
441
441
  let output = code;
442
- patches.sort((a, b) => b[0] - a[0]);
442
+ patches.sort((a, b) => b[0] - a[0] || b[1] - a[1]);
443
443
  for (const [start, end, replacement] of patches) {
444
444
  output = output.slice(0, start) + replacement + output.slice(end);
445
445
  }