@nimbus-sh/core 0.2.0 → 0.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 (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +112 -0
  3. package/dist/_shared/tarball-stream.d.ts +93 -0
  4. package/dist/_shared/tarball-stream.d.ts.map +1 -0
  5. package/dist/_shared/tarball-stream.js +235 -0
  6. package/dist/_shared/tarball.d.ts +17 -0
  7. package/dist/_shared/tarball.d.ts.map +1 -0
  8. package/dist/_shared/tarball.js +39 -0
  9. package/dist/index.d.ts +3 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +1 -0
  12. package/dist/runtime/clang-runner.d.ts +38 -0
  13. package/dist/runtime/clang-runner.d.ts.map +1 -0
  14. package/dist/runtime/clang-runner.js +866 -0
  15. package/dist/runtime/facet-host.d.ts +12 -0
  16. package/dist/runtime/facet-host.d.ts.map +1 -1
  17. package/dist/runtime/local-facet-host.d.ts.map +1 -1
  18. package/dist/runtime/local-facet-host.js +29 -9
  19. package/dist/runtime/ruby-gems.d.ts +30 -0
  20. package/dist/runtime/ruby-gems.d.ts.map +1 -0
  21. package/dist/runtime/ruby-gems.js +636 -0
  22. package/dist/runtime/ruby-runner.d.ts +127 -0
  23. package/dist/runtime/ruby-runner.d.ts.map +1 -0
  24. package/dist/runtime/ruby-runner.js +1357 -0
  25. package/dist/runtime/runtime-package.d.ts +63 -0
  26. package/dist/runtime/runtime-package.d.ts.map +1 -0
  27. package/dist/runtime/runtime-package.js +66 -0
  28. package/dist/runtime/runtime-registry.d.ts +3 -2
  29. package/dist/runtime/runtime-registry.d.ts.map +1 -1
  30. package/dist/runtime/runtime-registry.js +1 -1
  31. package/dist/runtime/session-process-supervisor.d.ts +15 -0
  32. package/dist/runtime/session-process-supervisor.d.ts.map +1 -1
  33. package/dist/runtime/session-process-supervisor.js +30 -0
  34. package/dist/workspace/nimbus-workspace.d.ts +102 -22
  35. package/dist/workspace/nimbus-workspace.d.ts.map +1 -1
  36. package/dist/workspace/nimbus-workspace.js +197 -52
  37. package/package.json +4 -2
  38. package/src/_shared/tarball-stream.ts +263 -0
  39. package/src/_shared/tarball.ts +46 -0
  40. package/src/index.ts +7 -0
  41. package/src/runtime/clang-runner.ts +924 -0
  42. package/src/runtime/facet-host.ts +12 -0
  43. package/src/runtime/local-facet-host.ts +28 -8
  44. package/src/runtime/ruby-gems.ts +682 -0
  45. package/src/runtime/ruby-runner.ts +1484 -0
  46. package/src/runtime/runtime-package.ts +114 -0
  47. package/src/runtime/runtime-registry.ts +4 -3
  48. package/src/runtime/session-process-supervisor.ts +27 -0
  49. package/src/workspace/nimbus-workspace.ts +268 -63
@@ -0,0 +1,46 @@
1
+ /**
2
+ * tarball.ts — a whole tarball, in memory, as a path→bytes map.
3
+ *
4
+ * The streaming primitives it walks with (`parseTarHeader`, `streamTarEntries`,
5
+ * `readableStreamToAsyncIterable`) live in `./tarball-stream.ts` — a
6
+ * dependency-free leaf, because `bundle-facet-workers.mjs` esbuilds that file
7
+ * into a string the loader pool injects into dynamic workers, where an import
8
+ * would not resolve.
9
+ *
10
+ * This half is for a caller that already holds the bytes: `gem install`, which
11
+ * fetches a `.gem` (a tar holding a gzipped tar) and needs both layers open at
12
+ * once. An installer streaming a tarball it is still downloading should drive
13
+ * `streamTarEntries` itself and never hold the whole thing.
14
+ */
15
+
16
+ import {
17
+ streamTarEntries,
18
+ readableStreamToAsyncIterable,
19
+ } from './tarball-stream.js';
20
+
21
+ /** Extract every regular file. Gzipped input is decompressed first. */
22
+ export async function extractTarball(
23
+ tarball: ArrayBuffer,
24
+ ): Promise<Map<string, Uint8Array>> {
25
+ const files = new Map<string, Uint8Array>();
26
+ const raw = new Uint8Array(tarball);
27
+
28
+ // Adapter: wrap the single buffer as an async iterable. If gzipped, pipe
29
+ // through DecompressionStream so the streaming parser still sees tar bytes.
30
+ let source: AsyncIterable<Uint8Array>;
31
+ if (raw[0] === 0x1f && raw[1] === 0x8b) {
32
+ const rs = new Blob([tarball]).stream().pipeThrough(new DecompressionStream('gzip'));
33
+ source = readableStreamToAsyncIterable(rs);
34
+ } else {
35
+ source = (async function* () { yield raw; })();
36
+ }
37
+
38
+ try {
39
+ for await (const entry of streamTarEntries(source)) {
40
+ files.set(entry.name, entry.data);
41
+ }
42
+ } catch {
43
+ return files;
44
+ }
45
+ return files;
46
+ }
package/src/index.ts CHANGED
@@ -20,6 +20,13 @@ export type {
20
20
  SqlValue,
21
21
  TransactionHost,
22
22
  } from './runtime/os-contracts.js';
23
+ export { seedRuntimePackage } from './runtime/runtime-package.js';
24
+ export type { RuntimePackage, SeededRuntime } from './runtime/runtime-package.js';
25
+ export type {
26
+ ManifestEntrypoint,
27
+ ManifestFile,
28
+ RuntimeManifest,
29
+ } from './runtime/runtime-manifest.js';
23
30
  export { localFacetHost } from './runtime/local-facet-host.js';
24
31
  export type {
25
32
  Facet,