@githolon/testing 0.15.0 → 0.16.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.
@@ -1,4 +1,8 @@
1
- // AUTO-SYNCED from cloud/holon-host/src/git-fs.mjs by testing/build.mjs — DO NOT EDIT HERE.
1
+ // AUTO-SYNCED from adapter/git-fs.mjs by testing/build.mjs — DO NOT EDIT HERE.
2
+ // CANONICAL SHARED ADAPTER PRIMITIVE (OFFER_KERNEL_ARCHITECTURE.dot — the one adapter). Imported by
3
+ // BOTH the client (cloud/web-client) and the cloud shell (cloud/cloudflare-shell); deploy.sh syncs it into the
4
+ // container build context. Do NOT fork a per-platform copy — drift here is exactly the platform-specific
5
+ // surface the one-adapter consolidation removes.
2
6
  // An isomorphic-git fs adapter over a @bjorn3/browser_wasi_shim PreopenDirectory tree.
3
7
  //
4
8
  // This is what lets the DO push/fetch the EXACT same in-memory git repo that the holon's gix
@@ -1,8 +1,13 @@
1
- // AUTO-SYNCED from cloud/holon-host/src/tree.mjs by testing/build.mjs — DO NOT EDIT HERE.
2
- // /work tree flat manifest bytes — the decoupled twin of opfs_tree.mjs (serialize/deserialize
3
- // only, no OPFS I/O). On the edge the manifest bytes round-trip through R2 instead of an OPFS
4
- // SyncAccessHandle. Byte format is identical to opfs_tree.mjs so a snapshot is portable between
5
- // the browser holon and the edge holon:
1
+ // AUTO-SYNCED from adapter/tree.mjs by testing/build.mjs — DO NOT EDIT HERE.
2
+ // CANONICAL SHARED ADAPTER PRIMITIVE (OFFER_KERNEL_ARCHITECTURE.dot — the one adapter). Imported by
3
+ // BOTH the client (cloud/web-client) and the cloud shell (cloud/cloudflare-shell); deploy.sh syncs it into the
4
+ // container build context. Do NOT fork a per-platform copy drift here is exactly the platform-specific
5
+ // surface the one-adapter consolidation removes.
6
+ // /work tree ⇄ flat manifest bytes — the client twin of cloud/cloudflare-shell/src/tree.mjs.
7
+ // Used by holon.export() / connect({ restoreFrom }) to persist the workspace directory
8
+ // (the bare nomos.git + manifests) across page loads / devices. Byte format is IDENTICAL
9
+ // to the edge serializer, so a snapshot is portable between the browser holon and the
10
+ // edge holon:
6
11
  // [u32 count] then per entry: [u8 isDir][u32 pathLen][path][u32 byteLen][bytes]
7
12
  const enc = new TextEncoder();
8
13
  const dec = new TextDecoder();
@@ -44,8 +49,10 @@ export function serializeTree(workTree) {
44
49
  return out;
45
50
  }
46
51
 
52
+ /** Returns a `Map<name, File|Directory>` — the `contents` of the deserialized root. */
47
53
  export function deserializeTree(bytes, { File, Directory }) {
48
- const dv = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
54
+ const u8 = bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes);
55
+ const dv = new DataView(u8.buffer, u8.byteOffset, u8.byteLength);
49
56
  let off = 0;
50
57
  const count = dv.getUint32(off, true); off += 4;
51
58
  const root = new Directory(new Map());
@@ -53,8 +60,8 @@ export function deserializeTree(bytes, { File, Directory }) {
53
60
  const isDir = dv.getUint8(off); off += 1;
54
61
  const pathLen = dv.getUint32(off, true); off += 4;
55
62
  const byteLen = dv.getUint32(off, true); off += 4;
56
- const path = dec.decode(bytes.subarray(off, off + pathLen)); off += pathLen;
57
- const body = bytes.subarray(off, off + byteLen); off += byteLen;
63
+ const path = dec.decode(u8.subarray(off, off + pathLen)); off += pathLen;
64
+ const body = u8.subarray(off, off + byteLen); off += byteLen;
58
65
  const parts = path.split("/");
59
66
  let cur = root;
60
67
  for (let p = 0; p < parts.length - 1; p++) {