{"version":3,"file":"dispatch.test-helpers.d.ts","sourceRoot":"","sources":["../../../../src/core/canvas/sdk-shim/dispatch.test-helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,2DAA2D;AAC3D,qBAAa,eAAe;IAC3B,OAAO,CAAC,QAAQ,CAAwC;IAExD,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAEnC;IAED,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAG1D;IAED,qDAAqD;IACrD,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAExB;CACD;AAED,6DAA6D;AAC7D,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC3D,KAAK,EAAE,eAAe,CAAC;IACvB,8CAA8C;IAC9C,OAAO,EAAE,OAAO,EAAE,CAAC;CACnB;AAED,qFAAqF;AACrF,wBAAgB,iBAAiB,CAAC,WAAW,SAAmB,GAAG,iBAAiB,CAYnF","sourcesContent":["/**\n * Test doubles for the shim's stdio streams, so dispatch can be exercised without\n * forking a child process. Kept beside the shim rather than under `test/` because\n * what these implement is the shim's own stream contract.\n */\n\nimport type { CanvasShimStreams } from \"./index.js\";\n\n/** A readable side whose chunks are pushed by the test. */\nexport class FakeCanvasInput {\n\tprivate listener: ((chunk: string) => void) | undefined;\n\n\tsetEncoding(_encoding: \"utf8\"): this {\n\t\treturn this;\n\t}\n\n\ton(_event: \"data\", listener: (chunk: string) => void): this {\n\t\tthis.listener = listener;\n\t\treturn this;\n\t}\n\n\t/** Deliver a chunk as if the host had written it. */\n\tfeed(chunk: string): void {\n\t\tthis.listener?.(chunk);\n\t}\n}\n\n/** Streams plus the lines the shim wrote, for assertions. */\nexport interface FakeCanvasStreams extends CanvasShimStreams {\n\tinput: FakeCanvasInput;\n\t/** Every line written by the shim, parsed. */\n\twritten: unknown[];\n}\n\n/** Build injectable streams whose writes are collected instead of sent to stdout. */\nexport function fakeCanvasStreams(extensionId = \"test-extension\"): FakeCanvasStreams {\n\tconst written: unknown[] = [];\n\treturn {\n\t\tinput: new FakeCanvasInput(),\n\t\twrite: (chunk: string) => {\n\t\t\tfor (const line of chunk.split(\"\\n\")) {\n\t\t\t\tif (line.trim().length > 0) written.push(JSON.parse(line));\n\t\t\t}\n\t\t},\n\t\textensionId,\n\t\twritten,\n\t};\n}\n"]}