@ai-ecoverse/slicc-kernel 1.66.0 → 1.67.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.
- package/README.md +2 -2
- package/dist/driver-worker.js +7 -2
- package/dist/driver-worker.js.map +3 -3
- package/dist/driver.js +6 -1
- package/dist/driver.js.map +3 -3
- package/dist/index.js +8 -3
- package/dist/index.js.map +3 -3
- package/dist/kernel-worker.js +307 -59
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-driver-worker.js +7 -2
- package/dist/node-driver-worker.js.map +3 -3
- package/dist/node-process-worker.js +67 -20
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +308 -60
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +149 -102
- package/dist/process-worker.js.map +4 -4
- package/package.json +1 -1
package/dist/driver.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/mount/protocol.ts", "../src/mount/driver.ts"],
|
|
4
|
-
"sourcesContent": ["export const DRIVER_PROTOCOL: readonly [number, number] = [1, 2];\n\nexport interface DriverCapabilities {\n readonly?: boolean;\n symlinks?: boolean;\n links?: boolean;\n chmod?: boolean;\n owners?: boolean;\n linkTimes?: boolean;\n ranges?: boolean;\n sessions?: boolean;\n listingStats?: boolean;\n caseInsensitive?: boolean;\n normalization?: 'none' | 'nfc' | 'nfd-insensitive';\n maxIo?: number;\n maxFile?: number;\n attrTtl?: number;\n entryTtl?: number;\n}\n\nexport interface DriverAttr {\n kind: 'file' | 'directory' | 'symlink';\n size: number;\n mtime: number;\n mode?: number;\n ino?: number;\n nlink?: number;\n etag?: string;\n uid?: number;\n gid?: number;\n}\n\nexport interface DriverOwner {\n uid?: number;\n gid?: number;\n mode?: number;\n}\n\nexport interface DriverEntry {\n name: string;\n kind: DriverAttr['kind'];\n attr?: DriverAttr;\n}\n\nexport interface DriverStatfs {\n bsize: number;\n blocks: number;\n bfree: number;\n}\n\nexport interface MountRequestInfo {\n source: string;\n options: Record<string, string>;\n}\n\nexport type DriverCall =\n | { op: 'getattr'; path: string }\n | { op: 'readdir'; path: string }\n | ({\n op: 'open';\n path: string;\n write: boolean;\n create: boolean;\n truncate: boolean;\n exclusive: boolean;\n ifMatch?: string;\n } & DriverOwner)\n | { op: 'read'; fh: number; offset: number; size: number }\n | { op: 'write'; fh: number; offset: number; bytes: Uint8Array }\n | { op: 'release'; fh: number }\n | ({ op: 'mkdir'; path: string } & DriverOwner)\n | { op: 'rmdir'; path: string }\n | { op: 'unlink'; path: string }\n | { op: 'rename'; from: string; to: string }\n | { op: 'link'; from: string; to: string }\n | ({ op: 'symlink'; target: string; path: string } & DriverOwner)\n | { op: 'readlink'; path: string }\n | {\n op: 'setattr';\n path: string;\n mode?: number;\n mtime?: number;\n size?: number;\n uid?: number;\n gid?: number;\n }\n | { op: 'statfs' };\n\nexport type DriverRequest = DriverCall & { id: number };\n\nexport interface DriverReply {\n id: number;\n result?: unknown;\n errno?: string;\n message?: string;\n}\n\nexport interface KernelDriverHello {\n protocol: readonly [number, number];\n mount: MountRequestInfo;\n}\n\nexport interface DriverHello {\n protocol: readonly [number, number];\n capabilities?: DriverCapabilities;\n error?: string;\n errno?: string;\n}\n\nexport type KernelToDriver = { hello: KernelDriverHello } | DriverRequest;\n\nexport type DriverToKernel = { hello: DriverHello } | DriverReply | { invalidate: string[] | true };\n\nexport function driverVersionError(theirs: unknown): string | undefined {\n const major = Array.isArray(theirs) ? theirs[0] : undefined;\n if (major === DRIVER_PROTOCOL[0]) return undefined;\n const named = typeof major === 'number' ? `${major}.x` : 'without a version';\n return `slicc-kernel driver protocol ${named} is not supported: this side speaks ${DRIVER_PROTOCOL.join('.')}`;\n}\n", "import {\n DRIVER_PROTOCOL,\n type DriverAttr,\n type DriverCapabilities,\n type DriverEntry,\n type DriverOwner,\n type DriverRequest,\n type DriverStatfs,\n driverVersionError,\n type KernelDriverHello,\n type MountRequestInfo,\n} from './protocol.ts';\n\nexport type {\n DriverAttr,\n DriverCapabilities,\n DriverEntry,\n DriverOwner,\n DriverStatfs,\n MountRequestInfo,\n} from './protocol.ts';\n\nexport interface OpenFlags {\n write: boolean;\n create: boolean;\n truncate: boolean;\n exclusive: boolean;\n ifMatch?: string;\n owner?: DriverOwner;\n}\n\nexport interface FilesystemHandlers {\n mount?(\n info: MountRequestInfo\n ): Promise<DriverCapabilities | undefined> | DriverCapabilities | undefined;\n getattr(path: string): Promise<DriverAttr>;\n readdir(path: string): Promise<DriverEntry[]>;\n open(path: string, flags: OpenFlags): Promise<number>;\n read(fh: number, offset: number, size: number): Promise<Uint8Array>;\n write(fh: number, offset: number, bytes: Uint8Array): Promise<void>;\n release(fh: number): Promise<void>;\n mkdir(path: string, owner?: DriverOwner): Promise<void>;\n rmdir(path: string): Promise<void>;\n unlink(path: string): Promise<void>;\n rename(from: string, to: string): Promise<void>;\n link?(from: string, to: string): Promise<void>;\n symlink?(target: string, path: string, owner?: DriverOwner): Promise<void>;\n readlink?(path: string): Promise<string>;\n setattr?(path: string, attr: DriverSetAttr): Promise<void>;\n statfs?(): Promise<DriverStatfs>;\n}\n\nexport interface DriverSetAttr {\n mode?: number;\n mtime?: number;\n size?: number;\n uid?: number;\n gid?: number;\n}\n\nfunction ownerOf(req: DriverOwner): DriverOwner | undefined {\n const owner = {\n ...(req.uid !== undefined ? { uid: req.uid } : {}),\n ...(req.gid !== undefined ? { gid: req.gid } : {}),\n ...(req.mode !== undefined ? { mode: req.mode } : {}),\n };\n return Object.keys(owner).length > 0 ? owner : undefined;\n}\n\nfunction withOwner<T extends object>(base: T, owner: DriverOwner | undefined): T {\n return owner ? { ...base, owner } : base;\n}\n\nexport interface DriverPort {\n postMessage(message: unknown, transfer?: Transferable[]): void;\n addEventListener(type: 'message', handler: (event: MessageEvent) => void): void;\n start?(): void;\n}\n\nexport interface ServedFilesystem {\n invalidate(paths: string[] | true): void;\n}\n\nexport function fsError(code: string, message = code): Error & { code: string } {\n return Object.assign(new Error(message), { code });\n}\n\nasync function dispatch(h: FilesystemHandlers, req: DriverRequest): Promise<unknown> {\n switch (req.op) {\n case 'getattr':\n return h.getattr(req.path);\n case 'readdir':\n return h.readdir(req.path);\n case 'open':\n return h.open(\n req.path,\n withOwner(\n {\n write: req.write,\n create: req.create,\n truncate: req.truncate,\n exclusive: req.exclusive,\n ...(req.ifMatch !== undefined ? { ifMatch: req.ifMatch } : {}),\n },\n ownerOf(req)\n )\n );\n case 'read':\n return h.read(req.fh, req.offset, req.size);\n case 'write':\n return h.write(req.fh, req.offset, req.bytes);\n case 'release':\n return h.release(req.fh);\n case 'mkdir':\n return ownerOf(req) ? h.mkdir(req.path, ownerOf(req)) : h.mkdir(req.path);\n case 'rmdir':\n return h.rmdir(req.path);\n case 'unlink':\n return h.unlink(req.path);\n case 'rename':\n return h.rename(req.from, req.to);\n case 'link':\n if (!h.link) throw fsError('EPERM', 'this file system has no hard links');\n return h.link(req.from, req.to);\n case 'symlink':\n if (!h.symlink) throw fsError('EPERM', 'this file system has no symlinks');\n return ownerOf(req)\n ? h.symlink(req.target, req.path, ownerOf(req))\n : h.symlink(req.target, req.path);\n case 'readlink':\n if (!h.readlink) throw fsError('EINVAL', `${req.path} is not a symlink`);\n return h.readlink(req.path);\n case 'setattr':\n return h.setattr?.(req.path, {\n ...(req.mode !== undefined ? { mode: req.mode } : {}),\n ...(req.mtime !== undefined ? { mtime: req.mtime } : {}),\n ...(req.size !== undefined ? { size: req.size } : {}),\n ...(req.uid !== undefined ? { uid: req.uid } : {}),\n ...(req.gid !== undefined ? { gid: req.gid } : {}),\n });\n case 'statfs':\n return h.statfs?.() ?? null;\n default:\n throw fsError('ENOSYS', `unknown driver op ${(req as { op: string }).op}`);\n }\n}\n\nexport function serveFilesystem(\n port: DriverPort,\n handlers: FilesystemHandlers,\n capabilities: DriverCapabilities = {},\n options: { owned?: boolean } = {}\n): ServedFilesystem {\n let open = false;\n const reply = (message: object, transfer: Transferable[] = []) =>\n port.postMessage(message, transfer);\n async function hello(message: KernelDriverHello): Promise<void> {\n const refused = driverVersionError(message.protocol);\n if (refused) {\n reply({ hello: { protocol: DRIVER_PROTOCOL, error: refused, errno: 'EPROTO' } });\n return;\n }\n try {\n const refined = await handlers.mount?.(message.mount);\n open = true;\n reply({\n hello: { protocol: DRIVER_PROTOCOL, capabilities: { ...capabilities, ...refined } },\n });\n } catch (err) {\n const code = (err as { code?: unknown })?.code;\n reply({\n hello: {\n protocol: DRIVER_PROTOCOL,\n error: err instanceof Error ? err.message : String(err),\n errno: typeof code === 'string' ? code : 'EIO',\n },\n });\n }\n }\n port.addEventListener('message', (event) => {\n const data = event.data as { hello?: KernelDriverHello } & DriverRequest;\n if (data.hello) {\n void hello(data.hello);\n return;\n }\n if (!open) return;\n dispatch(handlers, data).then(\n (result) => {\n if (result instanceof Uint8Array) {\n const whole = result.byteOffset === 0 && result.byteLength === result.buffer.byteLength;\n const bytes = options.owned && whole ? result : result.slice();\n reply({ id: data.id, result: bytes }, [bytes.buffer]);\n } else reply({ id: data.id, result: result ?? null });\n },\n (err: unknown) => {\n const code = (err as { code?: unknown })?.code;\n reply({\n id: data.id,\n errno: typeof code === 'string' ? code : 'EIO',\n message: err instanceof Error ? err.message : String(err),\n });\n }\n );\n });\n port.start?.();\n return { invalidate: (paths) => reply({ invalidate: paths }) };\n}\n"],
|
|
5
|
-
"mappings": ";AAAO,IAAM,kBAA6C,CAAC,GAAG,CAAC;AAiHxD,SAAS,mBAAmB,QAAqC;AACtE,QAAM,QAAQ,MAAM,QAAQ,MAAM,IAAI,OAAO,CAAC,IAAI;AAClD,MAAI,UAAU,gBAAgB,CAAC,EAAG,QAAO;AACzC,QAAM,QAAQ,OAAO,UAAU,WAAW,GAAG,KAAK,OAAO;AACzD,SAAO,gCAAgC,KAAK,uCAAuC,gBAAgB,KAAK,GAAG,CAAC;AAC9G;;;
|
|
3
|
+
"sources": ["../src/mount/protocol.ts", "../src/bytes.ts", "../src/mount/driver.ts"],
|
|
4
|
+
"sourcesContent": ["export const DRIVER_PROTOCOL: readonly [number, number] = [1, 2];\n\nexport interface DriverCapabilities {\n readonly?: boolean;\n symlinks?: boolean;\n links?: boolean;\n chmod?: boolean;\n owners?: boolean;\n linkTimes?: boolean;\n ranges?: boolean;\n sessions?: boolean;\n listingStats?: boolean;\n caseInsensitive?: boolean;\n normalization?: 'none' | 'nfc' | 'nfd-insensitive';\n maxIo?: number;\n maxFile?: number;\n attrTtl?: number;\n entryTtl?: number;\n}\n\nexport interface DriverAttr {\n kind: 'file' | 'directory' | 'symlink';\n size: number;\n mtime: number;\n mode?: number;\n ino?: number;\n nlink?: number;\n etag?: string;\n uid?: number;\n gid?: number;\n}\n\nexport interface DriverOwner {\n uid?: number;\n gid?: number;\n mode?: number;\n}\n\nexport interface DriverEntry {\n name: string;\n kind: DriverAttr['kind'];\n attr?: DriverAttr;\n}\n\nexport interface DriverStatfs {\n bsize: number;\n blocks: number;\n bfree: number;\n}\n\nexport interface MountRequestInfo {\n source: string;\n options: Record<string, string>;\n}\n\nexport type DriverCall =\n | { op: 'getattr'; path: string }\n | { op: 'readdir'; path: string }\n | ({\n op: 'open';\n path: string;\n write: boolean;\n create: boolean;\n truncate: boolean;\n exclusive: boolean;\n ifMatch?: string;\n } & DriverOwner)\n | { op: 'read'; fh: number; offset: number; size: number }\n | { op: 'write'; fh: number; offset: number; bytes: Uint8Array }\n | { op: 'release'; fh: number }\n | ({ op: 'mkdir'; path: string } & DriverOwner)\n | { op: 'rmdir'; path: string }\n | { op: 'unlink'; path: string }\n | { op: 'rename'; from: string; to: string }\n | { op: 'link'; from: string; to: string }\n | ({ op: 'symlink'; target: string; path: string } & DriverOwner)\n | { op: 'readlink'; path: string }\n | {\n op: 'setattr';\n path: string;\n mode?: number;\n mtime?: number;\n size?: number;\n uid?: number;\n gid?: number;\n }\n | { op: 'statfs' };\n\nexport type DriverRequest = DriverCall & { id: number };\n\nexport interface DriverReply {\n id: number;\n result?: unknown;\n errno?: string;\n message?: string;\n}\n\nexport interface KernelDriverHello {\n protocol: readonly [number, number];\n mount: MountRequestInfo;\n}\n\nexport interface DriverHello {\n protocol: readonly [number, number];\n capabilities?: DriverCapabilities;\n error?: string;\n errno?: string;\n}\n\nexport type KernelToDriver = { hello: KernelDriverHello } | DriverRequest;\n\nexport type DriverToKernel = { hello: DriverHello } | DriverReply | { invalidate: string[] | true };\n\nexport function driverVersionError(theirs: unknown): string | undefined {\n const major = Array.isArray(theirs) ? theirs[0] : undefined;\n if (major === DRIVER_PROTOCOL[0]) return undefined;\n const named = typeof major === 'number' ? `${major}.x` : 'without a version';\n return `slicc-kernel driver protocol ${named} is not supported: this side speaks ${DRIVER_PROTOCOL.join('.')}`;\n}\n", "export function fresh(bytes: Uint8Array, start = 0, end = bytes.length): Uint8Array {\n return new Uint8Array(bytes.subarray(start, end));\n}\n", "import {\n DRIVER_PROTOCOL,\n type DriverAttr,\n type DriverCapabilities,\n type DriverEntry,\n type DriverOwner,\n type DriverRequest,\n type DriverStatfs,\n driverVersionError,\n type KernelDriverHello,\n type MountRequestInfo,\n} from './protocol.ts';\n\nexport type {\n DriverAttr,\n DriverCapabilities,\n DriverEntry,\n DriverOwner,\n DriverStatfs,\n MountRequestInfo,\n} from './protocol.ts';\n\nimport { fresh } from '../bytes.ts';\n\nexport interface OpenFlags {\n write: boolean;\n create: boolean;\n truncate: boolean;\n exclusive: boolean;\n ifMatch?: string;\n owner?: DriverOwner;\n}\n\nexport interface FilesystemHandlers {\n mount?(\n info: MountRequestInfo\n ): Promise<DriverCapabilities | undefined> | DriverCapabilities | undefined;\n getattr(path: string): Promise<DriverAttr>;\n readdir(path: string): Promise<DriverEntry[]>;\n open(path: string, flags: OpenFlags): Promise<number>;\n read(fh: number, offset: number, size: number): Promise<Uint8Array>;\n write(fh: number, offset: number, bytes: Uint8Array): Promise<void>;\n release(fh: number): Promise<void>;\n mkdir(path: string, owner?: DriverOwner): Promise<void>;\n rmdir(path: string): Promise<void>;\n unlink(path: string): Promise<void>;\n rename(from: string, to: string): Promise<void>;\n link?(from: string, to: string): Promise<void>;\n symlink?(target: string, path: string, owner?: DriverOwner): Promise<void>;\n readlink?(path: string): Promise<string>;\n setattr?(path: string, attr: DriverSetAttr): Promise<void>;\n statfs?(): Promise<DriverStatfs>;\n}\n\nexport interface DriverSetAttr {\n mode?: number;\n mtime?: number;\n size?: number;\n uid?: number;\n gid?: number;\n}\n\nfunction ownerOf(req: DriverOwner): DriverOwner | undefined {\n const owner = {\n ...(req.uid !== undefined ? { uid: req.uid } : {}),\n ...(req.gid !== undefined ? { gid: req.gid } : {}),\n ...(req.mode !== undefined ? { mode: req.mode } : {}),\n };\n return Object.keys(owner).length > 0 ? owner : undefined;\n}\n\nfunction withOwner<T extends object>(base: T, owner: DriverOwner | undefined): T {\n return owner ? { ...base, owner } : base;\n}\n\nexport interface DriverPort {\n postMessage(message: unknown, transfer?: Transferable[]): void;\n addEventListener(type: 'message', handler: (event: MessageEvent) => void): void;\n start?(): void;\n}\n\nexport interface ServedFilesystem {\n invalidate(paths: string[] | true): void;\n}\n\nexport function fsError(code: string, message = code): Error & { code: string } {\n return Object.assign(new Error(message), { code });\n}\n\nasync function dispatch(h: FilesystemHandlers, req: DriverRequest): Promise<unknown> {\n switch (req.op) {\n case 'getattr':\n return h.getattr(req.path);\n case 'readdir':\n return h.readdir(req.path);\n case 'open':\n return h.open(\n req.path,\n withOwner(\n {\n write: req.write,\n create: req.create,\n truncate: req.truncate,\n exclusive: req.exclusive,\n ...(req.ifMatch !== undefined ? { ifMatch: req.ifMatch } : {}),\n },\n ownerOf(req)\n )\n );\n case 'read':\n return h.read(req.fh, req.offset, req.size);\n case 'write':\n return h.write(req.fh, req.offset, req.bytes);\n case 'release':\n return h.release(req.fh);\n case 'mkdir':\n return ownerOf(req) ? h.mkdir(req.path, ownerOf(req)) : h.mkdir(req.path);\n case 'rmdir':\n return h.rmdir(req.path);\n case 'unlink':\n return h.unlink(req.path);\n case 'rename':\n return h.rename(req.from, req.to);\n case 'link':\n if (!h.link) throw fsError('EPERM', 'this file system has no hard links');\n return h.link(req.from, req.to);\n case 'symlink':\n if (!h.symlink) throw fsError('EPERM', 'this file system has no symlinks');\n return ownerOf(req)\n ? h.symlink(req.target, req.path, ownerOf(req))\n : h.symlink(req.target, req.path);\n case 'readlink':\n if (!h.readlink) throw fsError('EINVAL', `${req.path} is not a symlink`);\n return h.readlink(req.path);\n case 'setattr':\n return h.setattr?.(req.path, {\n ...(req.mode !== undefined ? { mode: req.mode } : {}),\n ...(req.mtime !== undefined ? { mtime: req.mtime } : {}),\n ...(req.size !== undefined ? { size: req.size } : {}),\n ...(req.uid !== undefined ? { uid: req.uid } : {}),\n ...(req.gid !== undefined ? { gid: req.gid } : {}),\n });\n case 'statfs':\n return h.statfs?.() ?? null;\n default:\n throw fsError('ENOSYS', `unknown driver op ${(req as { op: string }).op}`);\n }\n}\n\nexport function serveFilesystem(\n port: DriverPort,\n handlers: FilesystemHandlers,\n capabilities: DriverCapabilities = {},\n options: { owned?: boolean } = {}\n): ServedFilesystem {\n let open = false;\n const reply = (message: object, transfer: Transferable[] = []) =>\n port.postMessage(message, transfer);\n async function hello(message: KernelDriverHello): Promise<void> {\n const refused = driverVersionError(message.protocol);\n if (refused) {\n reply({ hello: { protocol: DRIVER_PROTOCOL, error: refused, errno: 'EPROTO' } });\n return;\n }\n try {\n const refined = await handlers.mount?.(message.mount);\n open = true;\n reply({\n hello: { protocol: DRIVER_PROTOCOL, capabilities: { ...capabilities, ...refined } },\n });\n } catch (err) {\n const code = (err as { code?: unknown })?.code;\n reply({\n hello: {\n protocol: DRIVER_PROTOCOL,\n error: err instanceof Error ? err.message : String(err),\n errno: typeof code === 'string' ? code : 'EIO',\n },\n });\n }\n }\n port.addEventListener('message', (event) => {\n const data = event.data as { hello?: KernelDriverHello } & DriverRequest;\n if (data.hello) {\n void hello(data.hello);\n return;\n }\n if (!open) return;\n dispatch(handlers, data).then(\n (result) => {\n if (result instanceof Uint8Array) {\n const whole = result.byteOffset === 0 && result.byteLength === result.buffer.byteLength;\n const bytes = options.owned && whole ? result : fresh(result);\n reply({ id: data.id, result: bytes }, [bytes.buffer]);\n } else reply({ id: data.id, result: result ?? null });\n },\n (err: unknown) => {\n const code = (err as { code?: unknown })?.code;\n reply({\n id: data.id,\n errno: typeof code === 'string' ? code : 'EIO',\n message: err instanceof Error ? err.message : String(err),\n });\n }\n );\n });\n port.start?.();\n return { invalidate: (paths) => reply({ invalidate: paths }) };\n}\n"],
|
|
5
|
+
"mappings": ";AAAO,IAAM,kBAA6C,CAAC,GAAG,CAAC;AAiHxD,SAAS,mBAAmB,QAAqC;AACtE,QAAM,QAAQ,MAAM,QAAQ,MAAM,IAAI,OAAO,CAAC,IAAI;AAClD,MAAI,UAAU,gBAAgB,CAAC,EAAG,QAAO;AACzC,QAAM,QAAQ,OAAO,UAAU,WAAW,GAAG,KAAK,OAAO;AACzD,SAAO,gCAAgC,KAAK,uCAAuC,gBAAgB,KAAK,GAAG,CAAC;AAC9G;;;ACtHO,SAAS,MAAM,OAAmB,QAAQ,GAAG,MAAM,MAAM,QAAoB;AAClF,SAAO,IAAI,WAAW,MAAM,SAAS,OAAO,GAAG,CAAC;AAClD;;;AC4DA,SAAS,QAAQ,KAA2C;AAC1D,QAAM,QAAQ;AAAA,IACZ,GAAI,IAAI,QAAQ,SAAY,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC;AAAA,IAChD,GAAI,IAAI,QAAQ,SAAY,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC;AAAA,IAChD,GAAI,IAAI,SAAS,SAAY,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;AAAA,EACrD;AACA,SAAO,OAAO,KAAK,KAAK,EAAE,SAAS,IAAI,QAAQ;AACjD;AAEA,SAAS,UAA4B,MAAS,OAAmC;AAC/E,SAAO,QAAQ,EAAE,GAAG,MAAM,MAAM,IAAI;AACtC;AAYO,SAAS,QAAQ,MAAc,UAAU,MAAgC;AAC9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/D;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/index.js
CHANGED
|
@@ -43,6 +43,11 @@ function serveCdpPort(port, hook, request, onDone) {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
// src/bytes.ts
|
|
47
|
+
function fresh(bytes, start = 0, end = bytes.length) {
|
|
48
|
+
return new Uint8Array(bytes.subarray(start, end));
|
|
49
|
+
}
|
|
50
|
+
|
|
46
51
|
// src/client/dial-stream.ts
|
|
47
52
|
function errorWithCode(message) {
|
|
48
53
|
const code = /^E[A-Z]+/.exec(message)?.[0];
|
|
@@ -96,7 +101,7 @@ function dialStream(port, onClose) {
|
|
|
96
101
|
const writable = new WritableStream({
|
|
97
102
|
write(chunk) {
|
|
98
103
|
if (closed) throw errorWithCode("EPIPE: the connection is closed");
|
|
99
|
-
const copy = chunk
|
|
104
|
+
const copy = fresh(chunk);
|
|
100
105
|
const acked = new Promise((resolve, reject) => acks.push({ resolve, reject }));
|
|
101
106
|
port.postMessage(copy, [copy.buffer]);
|
|
102
107
|
return acked;
|
|
@@ -854,7 +859,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS } = {}) {
|
|
|
854
859
|
}
|
|
855
860
|
if (typeof data === "string") peer.postMessage({ net: "ws-message", nid, data });
|
|
856
861
|
else {
|
|
857
|
-
const bytes = data
|
|
862
|
+
const bytes = fresh(data);
|
|
858
863
|
peer.postMessage({ net: "ws-message", nid, data: bytes }, [bytes.buffer]);
|
|
859
864
|
}
|
|
860
865
|
flow.inflight += payloadSize(data);
|
|
@@ -892,7 +897,7 @@ function serveTransport(peer, transport, { closeWaitMs = CLOSE_WAIT_MS } = {}) {
|
|
|
892
897
|
open.delete(nid);
|
|
893
898
|
peer.postMessage({ net: "end", nid });
|
|
894
899
|
} else {
|
|
895
|
-
const bytes = next.value
|
|
900
|
+
const bytes = fresh(next.value);
|
|
896
901
|
peer.postMessage({ net: "chunk", nid, bytes }, [bytes.buffer]);
|
|
897
902
|
}
|
|
898
903
|
} catch (e) {
|