···22export { sanitizePath, normalizePath } from './path';
3344// Tree processing
55-export type { UploadedFile, FileUploadResult, ProcessedDirectory } from './tree';
55+export type { UploadedFile, FileUploadResult, ProcessedDirectory, ProcessUploadedFilesOptions, UpdateFileBlobsOptions } from './tree';
66export { processUploadedFiles, updateFileBlobs, countFilesInDirectory, collectFileCidsFromEntries } from './tree';
7788// Manifest creation
99export { createManifest } from './manifest';
10101111// Subfs splitting utilities
1212-export { estimateDirectorySize, findLargeDirectories, replaceDirectoryWithSubfs } from './subfs-split';
1212+export { estimateDirectorySize, findLargeDirectories, replaceDirectoryWithSubfs, splitDirectoryIntoChunks } from './subfs-split';
+39
packages/@wisp/fs-utils/src/subfs-split.ts
···111111 entries: newEntries
112112 };
113113}
114114+115115+/**
116116+ * Split a large directory into multiple smaller chunks that each fit within maxSize
117117+ * Used when a single directory is too large for one subfs record
118118+ */
119119+export function splitDirectoryIntoChunks(directory: Directory, maxSize: number): Directory[] {
120120+ const chunks: Directory[] = [];
121121+ let currentChunkEntries: Directory['entries'] = [];
122122+ let currentChunkSize = 100; // Base size for directory structure overhead
123123+124124+ for (const entry of directory.entries) {
125125+ const entrySize = JSON.stringify(entry).length;
126126+127127+ // If adding this entry would exceed max size, start a new chunk
128128+ if (currentChunkEntries.length > 0 && currentChunkSize + entrySize > maxSize) {
129129+ chunks.push({
130130+ $type: 'place.wisp.fs#directory' as const,
131131+ type: 'directory' as const,
132132+ entries: currentChunkEntries
133133+ });
134134+ currentChunkEntries = [];
135135+ currentChunkSize = 100;
136136+ }
137137+138138+ currentChunkEntries.push(entry);
139139+ currentChunkSize += entrySize;
140140+ }
141141+142142+ // Add the last chunk if it has entries
143143+ if (currentChunkEntries.length > 0) {
144144+ chunks.push({
145145+ $type: 'place.wisp.fs#directory' as const,
146146+ type: 'directory' as const,
147147+ entries: currentChunkEntries
148148+ });
149149+ }
150150+151151+ return chunks;
152152+}