@adviser/cement 0.2.17 → 0.2.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. package/{sys_abstraction-CmSCeK7b.d.cts → base-sys-abstraction-C9WW3w57.d.cts} +79 -2
  2. package/{sys_abstraction-CmSCeK7b.d.ts → base-sys-abstraction-C9WW3w57.d.ts} +79 -2
  3. package/{chunk-XJF7FQUN.js → chunk-2L33RPFJ.js} +3 -3
  4. package/{chunk-XJF7FQUN.js.map → chunk-2L33RPFJ.js.map} +1 -1
  5. package/chunk-AO7BGISE.js +353 -0
  6. package/chunk-AO7BGISE.js.map +1 -0
  7. package/{chunk-J2IM7FHM.js → chunk-I4NUGWZ6.js} +6 -1
  8. package/{chunk-O4F5AURC.js → chunk-JYUQZNDZ.js} +187 -179
  9. package/chunk-JYUQZNDZ.js.map +1 -0
  10. package/index-_GuS2IT4.d.cts +93 -0
  11. package/index-_GuS2IT4.d.ts +93 -0
  12. package/index.cjs +515 -183
  13. package/index.cjs.map +1 -1
  14. package/index.d.cts +32 -33
  15. package/index.d.ts +32 -33
  16. package/index.js +178 -174
  17. package/index.js.map +1 -1
  18. package/node/index.cjs +12 -10
  19. package/node/index.cjs.map +1 -1
  20. package/node/index.d.cts +1 -2
  21. package/node/index.d.ts +1 -2
  22. package/node/index.js +5 -5
  23. package/node/index.js.map +1 -1
  24. package/package.json +7 -3
  25. package/utils/index.cjs +98 -2
  26. package/utils/index.cjs.map +1 -1
  27. package/utils/index.d.cts +2 -36
  28. package/utils/index.d.ts +2 -36
  29. package/utils/index.js +21 -221
  30. package/utils/index.js.map +1 -1
  31. package/web/index.cjs +10 -8
  32. package/web/index.cjs.map +1 -1
  33. package/web/index.d.cts +1 -2
  34. package/web/index.d.ts +1 -2
  35. package/web/index.js +3 -3
  36. package/base_sys_abstraction-CJqRmTui.d.ts +0 -21
  37. package/base_sys_abstraction-nsNTl07w.d.cts +0 -21
  38. package/chunk-O4F5AURC.js.map +0 -1
  39. /package/{chunk-J2IM7FHM.js.map → chunk-I4NUGWZ6.js.map} +0 -0
package/node/index.js CHANGED
@@ -2,10 +2,10 @@ import {
2
2
  BaseSysAbstraction,
3
3
  WrapperSysAbstraction,
4
4
  envFactory
5
- } from "../chunk-O4F5AURC.js";
6
- import "../chunk-J2IM7FHM.js";
5
+ } from "../chunk-JYUQZNDZ.js";
6
+ import "../chunk-I4NUGWZ6.js";
7
7
 
8
- // src/node/node_file_service.ts
8
+ // src/node/node-file-service.ts
9
9
  import path from "node:path";
10
10
  import fs from "node:fs";
11
11
  var NodeFileService = class {
@@ -81,7 +81,7 @@ var NodeFileService = class {
81
81
  }
82
82
  };
83
83
 
84
- // src/node/node_sys_abstraction.ts
84
+ // src/node/node-sys-abstraction.ts
85
85
  var ExitServiceImpl = class {
86
86
  constructor() {
87
87
  this._exitHandlers = [];
@@ -173,7 +173,7 @@ function NodeSysAbstraction(param) {
173
173
  return new WrapperSysAbstraction(my, param);
174
174
  }
175
175
 
176
- // src/node/mock_file_service.ts
176
+ // src/node/mock-file-service.ts
177
177
  var MockFileService = class extends NodeFileService {
178
178
  constructor() {
179
179
  super(...arguments);
package/node/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/node/node_file_service.ts","../../../src/node/node_sys_abstraction.ts","../../../src/node/mock_file_service.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport { FileService, NamedWritableStream } from \"../file_service\";\n\nexport class NodeFileService implements FileService {\n readonly baseDir: string;\n constructor(baseDir: string = process.cwd()) {\n this.baseDir = this.abs(baseDir);\n }\n\n nodeImport(fname: string): string {\n // console.log('nodeImport:'+ fname);\n if (path.isAbsolute(fname)) {\n return fname;\n } else {\n return \"./\" + path.normalize(fname);\n }\n }\n\n readFileString(fname: string): Promise<string> {\n return fs.promises.readFile(fname, { encoding: \"utf-8\" });\n }\n\n dirname(fname: string): string {\n return path.dirname(fname);\n }\n basename(fname: string): string {\n return path.basename(fname);\n }\n\n join(...paths: string[]): string {\n return path.join(...paths);\n }\n\n relative(from: string, to?: string): string {\n if (to === undefined) {\n to = from;\n from = process.cwd();\n }\n const ret = path.relative(from, to);\n // console.log('relative:'+ from + \" -> \" + to + \"= \" + ret);\n return ret;\n }\n\n abs(fname: string): string {\n if (path.isAbsolute(fname)) {\n return fname;\n } else {\n const cwd = process.cwd();\n return path.resolve(cwd, fname);\n }\n }\n\n isAbsolute(fname: string): boolean {\n return path.isAbsolute(fname);\n }\n\n async writeFileString(fname: string, content: string): Promise<void> {\n const o = await this.create(fname);\n const wr = o.stream.getWriter();\n await wr.write(new TextEncoder().encode(content));\n await wr.close();\n }\n\n async create(fname: string): Promise<NamedWritableStream> {\n let oName = fname;\n if (!path.isAbsolute(fname)) {\n oName = this.abs(fname);\n }\n\n const base = path.dirname(oName);\n await fs.promises.mkdir(base, { recursive: true });\n const out = fs.createWriteStream(oName);\n return {\n name: oName,\n stream: new WritableStream<Uint8Array>({\n write(chunk) {\n out.write(chunk);\n },\n close() {\n out.close();\n },\n abort() {\n throw new Error(\"not implemented\");\n },\n }),\n };\n }\n}\n","import { SysAbstraction, SystemService, VoidFunc } from \"../sys_abstraction\";\nimport {\n BaseSysAbstraction,\n ExitHandler,\n ExitService,\n WrapperSysAbstraction,\n WrapperSysAbstractionParams,\n} from \"../base_sys_abstraction\";\nimport { NodeFileService } from \"./node_file_service\";\nimport { envFactory } from \"../sys_env\";\n\nexport class ExitServiceImpl implements ExitService {\n constructor() {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n process.on(\"unhandledRejection\", (reason: string, p: Promise<unknown>) => {\n this.exit(19);\n });\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n process.on(\"uncaughtException\", (error: Error) => {\n this.exit(18);\n });\n process.on(\"close\", () => {\n this.exit(0);\n });\n process.on(\"exit\", () => {\n this.exit(0);\n });\n process.on(\"SIGQUIT\", () => {\n this.exit(3);\n });\n process.on(\"SIGINT\", () => {\n this.exit(2);\n });\n process.on(\"SIGTERM\", () => {\n this.exit(9);\n });\n }\n _exitHandlers: ExitHandler[] = [];\n injectExitHandlers(hdls: ExitHandler[]): void {\n // console.log(\"ExitService: injecting exit handlers\", hdls)\n this._exitHandlers = hdls;\n }\n invoked = false;\n readonly _handleExit = async (): Promise<void> => {\n if (this.invoked) {\n // console.error(\"ExitService: already invoked\");\n return;\n }\n this.invoked = true;\n for (const h of this._exitHandlers) {\n try {\n // console.log(`ExitService: calling handler ${h.id}`)\n const ret = h.hdl();\n // console.log(`ExitService: called handler ${h.id}`, ret)\n if (typeof (ret as Promise<void>).then === \"function\") {\n await ret;\n }\n } finally {\n // ignore\n }\n }\n };\n\n exit(code: number): void {\n // console.log(\"ExitService: exit called\", code)\n this._handleExit()\n .then(() => {\n process.exit(code);\n })\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error(\"ExitService: failed to handle exit\", err);\n process.exit(code);\n });\n }\n}\n\nexport class NodeSystemService implements SystemService {\n static readonly _exitHandlers: ExitHandler[] = [];\n readonly _exitService: ExitService = new ExitServiceImpl();\n constructor() {\n this._exitService.injectExitHandlers(NodeSystemService._exitHandlers);\n }\n\n Env() {\n return envFactory();\n }\n\n Args() {\n return process.argv;\n }\n\n OnExit(hdl: VoidFunc): VoidFunc {\n const id = crypto.randomUUID();\n NodeSystemService._exitHandlers.push({ hdl, id });\n return () => {\n const idx = NodeSystemService._exitHandlers.findIndex((h) => h.id === id);\n if (idx >= 0) {\n NodeSystemService._exitHandlers.splice(idx, 1);\n }\n };\n }\n\n Exit(code: number): void {\n this._exitService.exit(code);\n }\n}\n\nlet my: BaseSysAbstraction | undefined = undefined;\nexport function NodeSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction {\n if (!my) {\n my = new BaseSysAbstraction({\n FileSystem: new NodeFileService(),\n SystemService: new NodeSystemService(),\n });\n }\n return new WrapperSysAbstraction(my, param);\n}\n","import { NamedWritableStream } from \"../file_service\";\nimport { NodeFileService } from \"./node_file_service\";\n\nexport interface FileCollector {\n readonly name: string;\n content: string;\n}\n\nexport class MockFileService extends NodeFileService {\n readonly files = {} as Record<string, FileCollector>;\n\n // override abs(fname: string): string {\n // return this.join(\"/mock/\", fname);\n // }\n\n override async create(fname: string): Promise<NamedWritableStream> {\n let oName = fname;\n if (!this.isAbsolute(fname)) {\n oName = await this.abs(fname);\n }\n\n const fc = {\n name: oName,\n content: \"\",\n };\n this.files[oName] = fc;\n this.files[fname] = fc;\n const decoder = new TextDecoder();\n\n return {\n name: oName,\n stream: new WritableStream<Uint8Array>({\n write(chunk) {\n fc.content = fc.content + decoder.decode(chunk);\n },\n close() {\n // do nothing\n },\n abort() {\n throw new Error(\"not implemented\");\n },\n }),\n };\n }\n}\n"],"mappings":";;;;;;;;AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AAGR,IAAM,kBAAN,MAA6C;AAAA,EAElD,YAAY,UAAkB,QAAQ,IAAI,GAAG;AAC3C,SAAK,UAAU,KAAK,IAAI,OAAO;AAAA,EACjC;AAAA,EAEA,WAAW,OAAuB;AAEhC,QAAI,KAAK,WAAW,KAAK,GAAG;AAC1B,aAAO;AAAA,IACT,OAAO;AACL,aAAO,OAAO,KAAK,UAAU,KAAK;AAAA,IACpC;AAAA,EACF;AAAA,EAEA,eAAe,OAAgC;AAC7C,WAAO,GAAG,SAAS,SAAS,OAAO,EAAE,UAAU,QAAQ,CAAC;AAAA,EAC1D;AAAA,EAEA,QAAQ,OAAuB;AAC7B,WAAO,KAAK,QAAQ,KAAK;AAAA,EAC3B;AAAA,EACA,SAAS,OAAuB;AAC9B,WAAO,KAAK,SAAS,KAAK;AAAA,EAC5B;AAAA,EAEA,QAAQ,OAAyB;AAC/B,WAAO,KAAK,KAAK,GAAG,KAAK;AAAA,EAC3B;AAAA,EAEA,SAAS,MAAc,IAAqB;AAC1C,QAAI,OAAO,QAAW;AACpB,WAAK;AACL,aAAO,QAAQ,IAAI;AAAA,IACrB;AACA,UAAM,MAAM,KAAK,SAAS,MAAM,EAAE;AAElC,WAAO;AAAA,EACT;AAAA,EAE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AA,QACnC;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/node/node-file-service.ts","../../../src/node/node-sys-abstraction.ts","../../../src/node/mock-file-service.ts"],"sourcesContent":["import path from \"node:path\";\nimport fs from \"node:fs\";\nimport { FileService, NamedWritableStream } from \"../file-service\";\n\nexport class NodeFileService implements FileService {\n readonly baseDir: string;\n constructor(baseDir: string = process.cwd()) {\n this.baseDir = this.abs(baseDir);\n }\n\n nodeImport(fname: string): string {\n // console.log('nodeImport:'+ fname);\n if (path.isAbsolute(fname)) {\n return fname;\n } else {\n return \"./\" + path.normalize(fname);\n }\n }\n\n readFileString(fname: string): Promise<string> {\n return fs.promises.readFile(fname, { encoding: \"utf-8\" });\n }\n\n dirname(fname: string): string {\n return path.dirname(fname);\n }\n basename(fname: string): string {\n return path.basename(fname);\n }\n\n join(...paths: string[]): string {\n return path.join(...paths);\n }\n\n relative(from: string, to?: string): string {\n if (to === undefined) {\n to = from;\n from = process.cwd();\n }\n const ret = path.relative(from, to);\n // console.log('relative:'+ from + \" -> \" + to + \"= \" + ret);\n return ret;\n }\n\n abs(fname: string): string {\n if (path.isAbsolute(fname)) {\n return fname;\n } else {\n const cwd = process.cwd();\n return path.resolve(cwd, fname);\n }\n }\n\n isAbsolute(fname: string): boolean {\n return path.isAbsolute(fname);\n }\n\n async writeFileString(fname: string, content: string): Promise<void> {\n const o = await this.create(fname);\n const wr = o.stream.getWriter();\n await wr.write(new TextEncoder().encode(content));\n await wr.close();\n }\n\n async create(fname: string): Promise<NamedWritableStream> {\n let oName = fname;\n if (!path.isAbsolute(fname)) {\n oName = this.abs(fname);\n }\n\n const base = path.dirname(oName);\n await fs.promises.mkdir(base, { recursive: true });\n const out = fs.createWriteStream(oName);\n return {\n name: oName,\n stream: new WritableStream<Uint8Array>({\n write(chunk) {\n out.write(chunk);\n },\n close() {\n out.close();\n },\n abort() {\n throw new Error(\"not implemented\");\n },\n }),\n };\n }\n}\n","import { SysAbstraction, SystemService, VoidFunc } from \"../sys-abstraction\";\nimport {\n BaseSysAbstraction,\n ExitHandler,\n ExitService,\n WrapperSysAbstraction,\n WrapperSysAbstractionParams,\n} from \"../base-sys-abstraction\";\nimport { NodeFileService } from \"./node-file-service\";\nimport { envFactory } from \"../sys-env\";\n\nexport class ExitServiceImpl implements ExitService {\n constructor() {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n process.on(\"unhandledRejection\", (reason: string, p: Promise<unknown>) => {\n this.exit(19);\n });\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n process.on(\"uncaughtException\", (error: Error) => {\n this.exit(18);\n });\n process.on(\"close\", () => {\n this.exit(0);\n });\n process.on(\"exit\", () => {\n this.exit(0);\n });\n process.on(\"SIGQUIT\", () => {\n this.exit(3);\n });\n process.on(\"SIGINT\", () => {\n this.exit(2);\n });\n process.on(\"SIGTERM\", () => {\n this.exit(9);\n });\n }\n _exitHandlers: ExitHandler[] = [];\n injectExitHandlers(hdls: ExitHandler[]): void {\n // console.log(\"ExitService: injecting exit handlers\", hdls)\n this._exitHandlers = hdls;\n }\n invoked = false;\n readonly _handleExit = async (): Promise<void> => {\n if (this.invoked) {\n // console.error(\"ExitService: already invoked\");\n return;\n }\n this.invoked = true;\n for (const h of this._exitHandlers) {\n try {\n // console.log(`ExitService: calling handler ${h.id}`)\n const ret = h.hdl();\n // console.log(`ExitService: called handler ${h.id}`, ret)\n if (typeof (ret as Promise<void>).then === \"function\") {\n await ret;\n }\n } finally {\n // ignore\n }\n }\n };\n\n exit(code: number): void {\n // console.log(\"ExitService: exit called\", code)\n this._handleExit()\n .then(() => {\n process.exit(code);\n })\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error(\"ExitService: failed to handle exit\", err);\n process.exit(code);\n });\n }\n}\n\nexport class NodeSystemService implements SystemService {\n static readonly _exitHandlers: ExitHandler[] = [];\n readonly _exitService: ExitService = new ExitServiceImpl();\n constructor() {\n this._exitService.injectExitHandlers(NodeSystemService._exitHandlers);\n }\n\n Env() {\n return envFactory();\n }\n\n Args() {\n return process.argv;\n }\n\n OnExit(hdl: VoidFunc): VoidFunc {\n const id = crypto.randomUUID();\n NodeSystemService._exitHandlers.push({ hdl, id });\n return () => {\n const idx = NodeSystemService._exitHandlers.findIndex((h) => h.id === id);\n if (idx >= 0) {\n NodeSystemService._exitHandlers.splice(idx, 1);\n }\n };\n }\n\n Exit(code: number): void {\n this._exitService.exit(code);\n }\n}\n\nlet my: BaseSysAbstraction | undefined = undefined;\nexport function NodeSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction {\n if (!my) {\n my = new BaseSysAbstraction({\n FileSystem: new NodeFileService(),\n SystemService: new NodeSystemService(),\n });\n }\n return new WrapperSysAbstraction(my, param);\n}\n","import { NamedWritableStream } from \"../file-service\";\nimport { NodeFileService } from \"./node-file-service\";\n\nexport interface FileCollector {\n readonly name: string;\n content: string;\n}\n\nexport class MockFileService extends NodeFileService {\n readonly files = {} as Record<string, FileCollector>;\n\n // override abs(fname: string): string {\n // return this.join(\"/mock/\", fname);\n // }\n\n override async create(fname: string): Promise<NamedWritableStream> {\n let oName = fname;\n if (!this.isAbsolute(fname)) {\n oName = await this.abs(fname);\n }\n\n const fc = {\n name: oName,\n content: \"\",\n };\n this.files[oName] = fc;\n this.files[fname] = fc;\n const decoder = new TextDecoder();\n\n return {\n name: oName,\n stream: new WritableStream<Uint8Array>({\n write(chunk) {\n fc.content = fc.content + decoder.decode(chunk);\n },\n close() {\n // do nothing\n },\n abort() {\n throw new Error(\"not implemented\");\n },\n }),\n };\n }\n}\n"],"mappings":";;;;;;;;AAAA,OAAO,UAAU;AACjB,OAAO,QAAQ;AAGR,IAAM,kBAAN,MAA6C;AAAA,EAElD,YAAY,UAAkB,QAAQ,IAAI,GAAG;AAC3C,SAAK,UAAU,KAAK,IAAI,OAAO;AAAA,EACjC;AAAA,EAEA,WAAW,OAAuB;AAEhC,QAAI,KAAK,WAAW,KAAK,GAAG;AAC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C;AAAA;AACL,SAAS,QAAQ,CAAC;AAAA;AAAA;AAAA;AAAA;AAAA,EAMlB,MAAe,OAAO,OAA6C;AACjE,QAAI,QAAQ;AACZ,QAAI,CAAC,KAAK,WAAW,KAAK,GAAG;AAC3B,cAAQ,MAAM,KAAK,IAAI,KAAK;AAAA,IAC9B;AAEA,UAAM,KAAK;AAAA,MACT,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AACA,SAAK,MAAM,KAAK,IAAI;AACpB,SAAK,MAAM,KAAK,IAAI;AACpB,UAAM,UAAU,IAAI,YAAY;AAEhC,WAAO;AAAA,MACL,MAAM;AAAA,MACN,QAAQ,IAAI,eAA2B;AAAA,QACrC,MAAM,OAAO;AACX,aAAG,UAAU,GAAG,UAAU,QAAQ,OAAO,KAAK;AAAA,QAChD;AAAA,QACA,QAAQ;AAAA,QAER;AAAA,QACA,QAAQ;AACN,gBAAM,IAAI,MAAM,iBAAiB;AAAA,QACnC;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adviser/cement",
3
- "version": "0.2.17",
3
+ "version": "0.2.19",
4
4
  "description": "better try/catch/finally handling",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -44,13 +44,17 @@
44
44
  "tsx": "^4.16.0",
45
45
  "typescript": "^5.5.0",
46
46
  "typescript-eslint": "^8.2.0",
47
- "vite-tsconfig-paths": "^4.3.2",
47
+ "vite-tsconfig-paths": "^5.0.1",
48
48
  "vitest": "^2.0.5",
49
- "webdriverio": "^8.39.1"
49
+ "wdio-safaridriver-service": "^2.1.1",
50
+ "webdriverio": "^9.0.7"
50
51
  },
51
52
  "engines": {
52
53
  "node": ">=16"
53
54
  },
55
+ "dependencies": {
56
+ "ts-essentials": "^10.0.2"
57
+ },
54
58
  "scripts": {
55
59
  "clean": "rm -rf dist node_modules",
56
60
  "build": "pnpm run build:tsc; pnpm run build:js",
package/utils/index.cjs CHANGED
@@ -20,6 +20,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/utils/index.ts
21
21
  var utils_exports = {};
22
22
  __export(utils_exports, {
23
+ ConsoleWriterStream: () => ConsoleWriterStream,
24
+ ConsoleWriterStreamDefaultWriter: () => ConsoleWriterStreamDefaultWriter,
25
+ FanoutWriteStream: () => FanoutWriteStream,
23
26
  array2stream: () => array2stream,
24
27
  devnull: () => devnull,
25
28
  rebuffer: () => rebuffer,
@@ -35,7 +38,7 @@ __export(utils_exports, {
35
38
  });
36
39
  module.exports = __toCommonJS(utils_exports);
37
40
 
38
- // src/utils/stream_map.ts
41
+ // src/utils/stream-map.ts
39
42
  function streamMap(s, sm) {
40
43
  const state = { reader: s.getReader(), streamMap: sm, idx: 0 };
41
44
  return new ReadableStream({
@@ -203,7 +206,7 @@ async function stream2uint8array(stream) {
203
206
  return Promise.resolve(res);
204
207
  }
205
208
 
206
- // src/utils/stream_test_helper.ts
209
+ // src/utils/stream-test-helper.ts
207
210
  async function receiveFromStream(reb, state) {
208
211
  return new Promise((resolve) => {
209
212
  let reBufferCalls = 0;
@@ -254,8 +257,101 @@ function uint8array2stream(str) {
254
257
  }
255
258
  });
256
259
  }
260
+
261
+ // src/utils/console-write-stream.ts
262
+ var ConsoleWriterStreamDefaultWriter = class {
263
+ constructor(stream) {
264
+ this.stream = stream;
265
+ this.desiredSize = null;
266
+ this.decoder = new TextDecoder();
267
+ this._stream = stream;
268
+ this.ready = Promise.resolve(void 0);
269
+ this.closed = Promise.resolve(void 0);
270
+ }
271
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
272
+ abort(reason) {
273
+ throw new Error("Method not implemented.");
274
+ }
275
+ async close() {
276
+ }
277
+ releaseLock() {
278
+ this._stream.locked = false;
279
+ this.ready = Promise.resolve(void 0);
280
+ this.closed = Promise.resolve(void 0);
281
+ }
282
+ async write(chunk) {
283
+ const str = this.decoder.decode(chunk).trimEnd();
284
+ let output = "log";
285
+ try {
286
+ const decode = JSON.parse(str);
287
+ output = decode.level;
288
+ } catch (e) {
289
+ }
290
+ switch (output) {
291
+ case "error":
292
+ console.error(str);
293
+ break;
294
+ case "warn":
295
+ console.warn(str);
296
+ break;
297
+ default:
298
+ console.log(str);
299
+ }
300
+ }
301
+ };
302
+ var ConsoleWriterStream = class {
303
+ constructor() {
304
+ this.locked = false;
305
+ }
306
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars
307
+ abort(reason) {
308
+ throw new Error("Method not implemented.");
309
+ }
310
+ async close() {
311
+ return;
312
+ }
313
+ getWriter() {
314
+ if (this.locked) {
315
+ throw new Error("Stream is locked");
316
+ }
317
+ this.locked = true;
318
+ if (!this._writer) {
319
+ this._writer = new ConsoleWriterStreamDefaultWriter(this);
320
+ }
321
+ return this._writer;
322
+ }
323
+ };
324
+
325
+ // src/utils/fanout-write-stream.ts
326
+ var FanoutWriteStream = class {
327
+ constructor(writers) {
328
+ this.desiredSize = null;
329
+ this._writers = writers;
330
+ this.ready = Promise.all(this._writers.map((w) => w.ready)).then(() => void 0);
331
+ this.closed = Promise.all(this._writers.map((w) => w.closed)).then(() => void 0);
332
+ }
333
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
334
+ abort(reason) {
335
+ return Promise.all(this._writers.map((w) => w.abort(reason))).then(() => {
336
+ });
337
+ }
338
+ close() {
339
+ return Promise.all(this._writers.map((w) => w.close())).then(() => {
340
+ });
341
+ }
342
+ releaseLock() {
343
+ this._writers.map((w) => w.releaseLock());
344
+ }
345
+ write(chunk) {
346
+ return Promise.all(this._writers.map((w) => w.write(chunk))).then(() => {
347
+ });
348
+ }
349
+ };
257
350
  // Annotate the CommonJS export names for ESM import in node:
258
351
  0 && (module.exports = {
352
+ ConsoleWriterStream,
353
+ ConsoleWriterStreamDefaultWriter,
354
+ FanoutWriteStream,
259
355
  array2stream,
260
356
  devnull,
261
357
  rebuffer,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utils/index.ts","../../../src/utils/stream_map.ts","../../../src/utils/rebuffer.ts","../../../src/utils/stream2string.ts","../../../src/utils/stream_test_helper.ts","../../../src/utils/string2stream.ts"],"sourcesContent":["export * from \"./rebuffer\";\nexport * from \"./stream_map\";\nexport * from \"./stream2string\";\nexport * from \"./stream_test_helper\";\nexport * from \"./string2stream\";\n","export interface StreamMap<T, U> {\n Map(s: T, idx: number): U | Promise<U>;\n readonly Close?: () => void;\n}\nexport function streamMap<T, U>(s: ReadableStream<T>, sm: StreamMap<T, U>): ReadableStream<U> {\n const state = { reader: s.getReader(), streamMap: sm, idx: 0 };\n return new ReadableStream<U>({\n async pull(controller) {\n const { done, value } = await state.reader.read();\n if (done) {\n if (state.streamMap.Close) {\n state.streamMap.Close();\n }\n controller.close();\n return;\n }\n const promiseOrU = state.streamMap.Map(value, state.idx++);\n let mapped: U;\n if (promiseOrU instanceof Promise || typeof (promiseOrU as { then: () => void }).then === \"function\") {\n mapped = await promiseOrU;\n } else {\n mapped = promiseOrU;\n }\n controller.enqueue(mapped);\n },\n });\n}\n\nexport async function devnull<T>(a: ReadableStream<T>): Promise<number> {\n const reader = a.getReader();\n let cnt = 0;\n while (true) {\n const { done } = await reader.read();\n if (done) {\n break;\n }\n cnt++;\n }\n return cnt;\n}\n\nexport function array2stream<T>(a: T[]): ReadableStream<T> {\n let i = 0;\n return new ReadableStream<T>({\n pull(controller) {\n if (i >= a.length) {\n controller.close();\n return;\n }\n controller.enqueue(a[i]);\n i++;\n },\n });\n}\n\nexport async function stream2array<T>(a: ReadableStream<T>): Promise<T[]> {\n const ret: T[] = [];\n const reader = a.getReader();\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n ret.push(value);\n }\n return ret;\n}\n","import { array2stream, stream2array } from \"./stream_map\";\n\ninterface ReChunkResult {\n readonly rest: Uint8Array;\n readonly chunk: Uint8Array;\n}\n\nexport async function rebufferArray(a: Uint8Array[], chunkSize: number): Promise<Uint8Array[]> {\n return stream2array(rebuffer(array2stream(a), chunkSize));\n}\n\nfunction reChunk(cs: Uint8Array[], chunkSize: number): ReChunkResult {\n const len = cs.reduce((acc, v) => acc + v.length, 0);\n const last = cs[cs.length - 1];\n const lastOfs = len - last.length;\n // console.log(\"reChunk\", len, lastOfs, last.length, chunkSize, chunkSize - lastOfs)\n const rest = last.subarray(chunkSize - lastOfs);\n cs[cs.length - 1] = last.subarray(0, chunkSize - lastOfs);\n const chunk = new Uint8Array(chunkSize);\n let ofs = 0;\n for (const c of cs) {\n chunk.set(c, ofs);\n ofs += c.length;\n }\n return { rest, chunk };\n}\n\ninterface pumpState {\n readonly reader: ReadableStreamDefaultReader<Uint8Array>;\n tmp: Uint8Array[];\n tmpLen: number;\n readonly chunkSize: number;\n}\n\nfunction pump(ps: pumpState, controller: ReadableStreamDefaultController<Uint8Array>, next: () => void): void {\n ps.reader.read().then(({ done, value }) => {\n if (done) {\n if (ps.tmpLen > 0) {\n controller.enqueue(reChunk(ps.tmp, ps.tmpLen).chunk);\n }\n controller.close();\n next();\n return;\n }\n if (ps.tmpLen + value.length > ps.chunkSize) {\n ps.tmp.push(value);\n const res = reChunk(ps.tmp, ps.chunkSize);\n controller.enqueue(res.chunk);\n ps.tmp = [res.rest];\n ps.tmpLen = res.rest.length;\n next();\n return;\n } else if (value.length) {\n ps.tmp.push(value);\n ps.tmpLen += value.length;\n }\n pump(ps, controller, next);\n });\n}\n\nexport function rebuffer(a: ReadableStream<Uint8Array>, chunkSize: number): ReadableStream<Uint8Array> {\n const state: pumpState = {\n reader: a.getReader(),\n tmp: [],\n tmpLen: 0,\n chunkSize,\n };\n return new ReadableStream<Uint8Array>({\n async pull(controller) {\n return new Promise<void>((resolve) => {\n pump(state, controller, resolve);\n });\n },\n });\n}\n","export async function stream2string(stream?: ReadableStream<Uint8Array> | null, maxSize?: number): Promise<string> {\n if (!stream) {\n return Promise.resolve(\"\");\n }\n const reader = stream.getReader();\n let res = \"\";\n const decoder = new TextDecoder();\n let rSize = 0;\n while (typeof maxSize === \"undefined\" || rSize < maxSize) {\n try {\n const read = await reader.read();\n if (read.done) {\n break;\n }\n if (maxSize && rSize + read.value.length > maxSize) {\n read.value = read.value.slice(0, maxSize - rSize);\n }\n const block = decoder.decode(read.value, { stream: true });\n rSize += read.value.length;\n res += block;\n } catch (err) {\n return Promise.reject(err);\n }\n }\n return Promise.resolve(res);\n}\n\nexport async function stream2uint8array(stream?: ReadableStream<Uint8Array> | null): Promise<Uint8Array> {\n if (!stream) {\n return Promise.resolve(new Uint8Array());\n }\n const reader = stream.getReader();\n let res = new Uint8Array();\n // eslint-disable-next-line no-constant-condition\n while (1) {\n try {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n res = new Uint8Array([...res, ...value]);\n } catch (err) {\n return Promise.reject(err);\n }\n }\n return Promise.resolve(res);\n}\n","import { Mock } from \"vitest\";\n\ninterface mockValue {\n done: boolean;\n value: Uint8Array | undefined;\n fillCalls: number;\n reBufferCalls: number;\n}\nexport interface streamingTestState {\n readonly sendChunks: number;\n readonly sendChunkSize: number;\n fillCalls: number;\n CollectorFn: Mock<(mv: mockValue) => void>;\n}\n\nexport async function receiveFromStream(reb: ReadableStream<Uint8Array>, state: streamingTestState) {\n return new Promise<void>((resolve) => {\n let reBufferCalls = 0;\n const reader = reb.getReader();\n function pump() {\n reader.read().then(({ done, value }) => {\n state.CollectorFn({ done, value, fillCalls: state.fillCalls, reBufferCalls });\n reBufferCalls++;\n if (done) {\n resolve();\n return;\n }\n pump();\n });\n }\n pump();\n });\n}\n\nexport async function sendToStream(reb: WritableStream<Uint8Array>, state: streamingTestState) {\n return new Promise<void>((resolve) => {\n const writer = reb.getWriter();\n function pump(i: number) {\n if (i >= state.sendChunks) {\n writer.close();\n resolve();\n return;\n }\n writer.ready.then(() => {\n state.fillCalls++;\n writer.write(new Uint8Array(Array(state.sendChunkSize).fill(i)));\n pump(i + 1);\n });\n }\n pump(0);\n });\n}\n\n// it(\"does nothing\", () => {});\n","export function string2stream(str: string): ReadableStream<Uint8Array> {\n const encoder = new TextEncoder();\n return uint8array2stream(encoder.encode(str));\n}\n\nexport function uint8array2stream(str: Uint8Array): ReadableStream<Uint8Array> {\n return new ReadableStream<Uint8Array>({\n start(controller) {\n controller.enqueue(str);\n controller.close();\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIO,SAAS,UAAgB,GAAsB,IAAwC;AAC5F,QAAM,QAAQ,EAAE,QAAQ,EAAE,UAAU,GAAG,WAAW,IAAI,KAAK,EAAE;AAC7D,SAAO,IAAI,eAAkB;AAAA,IAC3B,MAAM,KAAK,YAAY;AACrB,YAAM,EAAE,MAAM,MAAM,IAAI,MAAM,MAAM,OAAO,KAAK;AAChD,UAAI,MAAM;AACR,YAAI,MAAM,UAAU,OAAO;AACzB,gBAAM,UAAU,MAAM;AAAA,QACxB;AACA,mBAAW,MAAM;AACjB;AAAA,MACF;AACA,YAAM,aAAa,MAAM,UAAU,IAAI,OAAO,MAAM,KAAK;AACzD,UAAI;AACJ,UAAI,sBAAsB,WAAW,OAAQ,WAAoC,SAAS,YAAY;AACpG,iBAAS,MAAM;AAAA,MACjB,OAAO;AACL,iBAAS;AAAA,MACX;AACA,iBAAW,QAAQ,MAAM;AAAA,IAC3B;AAAA,EACF,CAAC;AACH;AAEA,eAAsB,QAAW,GAAuC;AACtE,QAAM,SAAS,EAAE,UAAU;AAC3B,MAAI,MAAM;AACV,SAAO,MAAM;AACX,UAAM,EAAE,KAAK,IAAI,MAAM,OAAO,KAAK;AACnC,QAAI,MAAM;AACR;AAAA,IACF;AACA;AAAA,EACF;AACA,SAAO;AACT;AAEO,SAAS,aAAgB,GAA2B;AACzD,MAAI,IAAI;AACR,SAAO,IAAI,eAAkB;AAAA,IAC3B,KAAK,YAAY;AACf,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M;AACtB,cAAM;AACN,eAAO,MAAM,IAAI,WAAW,MAAM,MAAM,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC;AAC/D,QAAAA,MAAK,IAAI,CAAC;AAAA,MACZ,CAAC;AAAA,IACH;AACA,IAAAA,MAAK,CAAC;AAAA,EACR,CAAC;AACH;;;ACnDO,SAAS,cAAc,KAAyC;AACrE,QAAM,UAAU,IAAI,YAAY;AAChC,SAAO,kBAAkB,QAAQ,OAAO,GAAG,CAAC;AAC9C;AAEO,SAAS,kBAAkB,KAA6C;AAC7E,SAAO,IAAI,eAA2B;AAAA,IACpC,MAAM,YAAY;AAChB,iBAAW,QAAQ,GAAG;AACtB,iBAAW,MAAM;AAAA,IACnB;AAAA,EACF,CAAC;AACH;","names":["pump"]}
1
+ {"version":3,"sources":["../../../src/utils/index.ts","../../../src/utils/stream-map.ts","../../../src/utils/rebuffer.ts","../../../src/utils/stream2string.ts","../../../src/utils/stream-test-helper.ts","../../../src/utils/string2stream.ts","../../../src/utils/console-write-stream.ts","../../../src/utils/fanout-write-stream.ts"],"sourcesContent":["export * from \"./rebuffer\";\nexport * from \"./stream-map\";\nexport * from \"./stream2string\";\nexport * from \"./stream-test-helper\";\nexport * from \"./string2stream\";\nexport * from \"./console-write-stream\";\nexport * from \"./fanout-write-stream\";\n","export interface StreamMap<T, U> {\n Map(s: T, idx: number): U | Promise<U>;\n readonly Close?: () => void;\n}\nexport function streamMap<T, U>(s: ReadableStream<T>, sm: StreamMap<T, U>): ReadableStream<U> {\n const state = { reader: s.getReader(), streamMap: sm, idx: 0 };\n return new ReadableStream<U>({\n async pull(controller) {\n const { done, value } = await state.reader.read();\n if (done) {\n if (state.streamMap.Close) {\n state.streamMap.Close();\n }\n controller.close();\n return;\n }\n const promiseOrU = state.streamMap.Map(value, state.idx++);\n let mapped: U;\n if (promiseOrU instanceof Promise || typeof (promiseOrU as { then: () => void }).then === \"function\") {\n mapped = await promiseOrU;\n } else {\n mapped = promiseOrU;\n }\n controller.enqueue(mapped);\n },\n });\n}\n\nexport async function devnull<T>(a: ReadableStream<T>): Promise<number> {\n const reader = a.getReader();\n let cnt = 0;\n while (true) {\n const { done } = await reader.read();\n if (done) {\n break;\n }\n cnt++;\n }\n return cnt;\n}\n\nexport function array2stream<T>(a: T[]): ReadableStream<T> {\n let i = 0;\n return new ReadableStream<T>({\n pull(controller) {\n if (i >= a.length) {\n controller.close();\n return;\n }\n controller.enqueue(a[i]);\n i++;\n },\n });\n}\n\nexport async function stream2array<T>(a: ReadableStream<T>): Promise<T[]> {\n const ret: T[] = [];\n const reader = a.getReader();\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n ret.push(value);\n }\n return ret;\n}\n","import { array2stream, stream2array } from \"./stream-map\";\n\ninterface ReChunkResult {\n readonly rest: Uint8Array;\n readonly chunk: Uint8Array;\n}\n\nexport async function rebufferArray(a: Uint8Array[], chunkSize: number): Promise<Uint8Array[]> {\n return stream2array(rebuffer(array2stream(a), chunkSize));\n}\n\nfunction reChunk(cs: Uint8Array[], chunkSize: number): ReChunkResult {\n const len = cs.reduce((acc, v) => acc + v.length, 0);\n const last = cs[cs.length - 1];\n const lastOfs = len - last.length;\n // console.log(\"reChunk\", len, lastOfs, last.length, chunkSize, chunkSize - lastOfs)\n const rest = last.subarray(chunkSize - lastOfs);\n cs[cs.length - 1] = last.subarray(0, chunkSize - lastOfs);\n const chunk = new Uint8Array(chunkSize);\n let ofs = 0;\n for (const c of cs) {\n chunk.set(c, ofs);\n ofs += c.length;\n }\n return { rest, chunk };\n}\n\ninterface pumpState {\n readonly reader: ReadableStreamDefaultReader<Uint8Array>;\n tmp: Uint8Array[];\n tmpLen: number;\n readonly chunkSize: number;\n}\n\nfunction pump(ps: pumpState, controller: ReadableStreamDefaultController<Uint8Array>, next: () => void): void {\n ps.reader.read().then(({ done, value }) => {\n if (done) {\n if (ps.tmpLen > 0) {\n controller.enqueue(reChunk(ps.tmp, ps.tmpLen).chunk);\n }\n controller.close();\n next();\n return;\n }\n if (ps.tmpLen + value.length > ps.chunkSize) {\n ps.tmp.push(value);\n const res = reChunk(ps.tmp, ps.chunkSize);\n controller.enqueue(res.chunk);\n ps.tmp = [res.rest];\n ps.tmpLen = res.rest.length;\n next();\n return;\n } else if (value.length) {\n ps.tmp.push(value);\n ps.tmpLen += value.length;\n }\n pump(ps, controller, next);\n });\n}\n\nexport function rebuffer(a: ReadableStream<Uint8Array>, chunkSize: number): ReadableStream<Uint8Array> {\n const state: pumpState = {\n reader: a.getReader(),\n tmp: [],\n tmpLen: 0,\n chunkSize,\n };\n return new ReadableStream<Uint8Array>({\n async pull(controller) {\n return new Promise<void>((resolve) => {\n pump(state, controller, resolve);\n });\n },\n });\n}\n","export async function stream2string(stream?: ReadableStream<Uint8Array> | null, maxSize?: number): Promise<string> {\n if (!stream) {\n return Promise.resolve(\"\");\n }\n const reader = stream.getReader();\n let res = \"\";\n const decoder = new TextDecoder();\n let rSize = 0;\n while (typeof maxSize === \"undefined\" || rSize < maxSize) {\n try {\n const read = await reader.read();\n if (read.done) {\n break;\n }\n if (maxSize && rSize + read.value.length > maxSize) {\n read.value = read.value.slice(0, maxSize - rSize);\n }\n const block = decoder.decode(read.value, { stream: true });\n rSize += read.value.length;\n res += block;\n } catch (err) {\n return Promise.reject(err);\n }\n }\n return Promise.resolve(res);\n}\n\nexport async function stream2uint8array(stream?: ReadableStream<Uint8Array> | null): Promise<Uint8Array> {\n if (!stream) {\n return Promise.resolve(new Uint8Array());\n }\n const reader = stream.getReader();\n let res = new Uint8Array();\n // eslint-disable-next-line no-constant-condition\n while (1) {\n try {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n res = new Uint8Array([...res, ...value]);\n } catch (err) {\n return Promise.reject(err);\n }\n }\n return Promise.resolve(res);\n}\n","import { Mock } from \"vitest\";\n\ninterface mockValue {\n done: boolean;\n value: Uint8Array | undefined;\n fillCalls: number;\n reBufferCalls: number;\n}\nexport interface streamingTestState {\n readonly sendChunks: number;\n readonly sendChunkSize: number;\n fillCalls: number;\n CollectorFn: Mock<(mv: mockValue) => void>;\n}\n\nexport async function receiveFromStream(reb: ReadableStream<Uint8Array>, state: streamingTestState) {\n return new Promise<void>((resolve) => {\n let reBufferCalls = 0;\n const reader = reb.getReader();\n function pump() {\n reader.read().then(({ done, value }) => {\n state.CollectorFn({ done, value, fillCalls: state.fillCalls, reBufferCalls });\n reBufferCalls++;\n if (done) {\n resolve();\n return;\n }\n pump();\n });\n }\n pump();\n });\n}\n\nexport async function sendToStream(reb: WritableStream<Uint8Array>, state: streamingTestState) {\n return new Promise<void>((resolve) => {\n const writer = reb.getWriter();\n function pump(i: number) {\n if (i >= state.sendChunks) {\n writer.close();\n resolve();\n return;\n }\n writer.ready.then(() => {\n state.fillCalls++;\n writer.write(new Uint8Array(Array(state.sendChunkSize).fill(i)));\n pump(i + 1);\n });\n }\n pump(0);\n });\n}\n\n// it(\"does nothing\", () => {});\n","export function string2stream(str: string): ReadableStream<Uint8Array> {\n const encoder = new TextEncoder();\n return uint8array2stream(encoder.encode(str));\n}\n\nexport function uint8array2stream(str: Uint8Array): ReadableStream<Uint8Array> {\n return new ReadableStream<Uint8Array>({\n start(controller) {\n controller.enqueue(str);\n controller.close();\n },\n });\n}\n","export class ConsoleWriterStreamDefaultWriter implements WritableStreamDefaultWriter<Uint8Array> {\n readonly desiredSize: number | null = null;\n readonly decoder = new TextDecoder();\n\n closed: Promise<undefined>;\n ready: Promise<undefined>;\n readonly _stream: ConsoleWriterStream;\n\n constructor(private stream: ConsoleWriterStream) {\n this._stream = stream;\n this.ready = Promise.resolve(undefined);\n this.closed = Promise.resolve(undefined);\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any\n abort(reason?: any): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n async close(): Promise<void> {\n // noop\n }\n releaseLock(): void {\n this._stream.locked = false;\n this.ready = Promise.resolve(undefined);\n this.closed = Promise.resolve(undefined);\n }\n async write(chunk?: Uint8Array | undefined): Promise<void> {\n const str = this.decoder.decode(chunk).trimEnd();\n let output = \"log\";\n try {\n const decode = JSON.parse(str);\n output = decode.level;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n } catch (e) {\n /* noop */\n }\n switch (output) {\n case \"error\":\n // eslint-disable-next-line no-console\n console.error(str);\n break;\n case \"warn\":\n // eslint-disable-next-line no-console\n console.warn(str);\n break;\n default:\n // eslint-disable-next-line no-console\n console.log(str);\n }\n }\n}\n\nexport class ConsoleWriterStream implements WritableStream<Uint8Array> {\n locked = false;\n _writer?: WritableStreamDefaultWriter<Uint8Array>;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars\n abort(reason?: any): Promise<void> {\n throw new Error(\"Method not implemented.\");\n }\n async close(): Promise<void> {\n return;\n }\n getWriter(): WritableStreamDefaultWriter<Uint8Array> {\n if (this.locked) {\n throw new Error(\"Stream is locked\");\n }\n this.locked = true;\n if (!this._writer) {\n this._writer = new ConsoleWriterStreamDefaultWriter(this);\n }\n return this._writer;\n }\n}\n","export class FanoutWriteStream implements WritableStreamDefaultWriter<Uint8Array> {\n readonly _writers: WritableStreamDefaultWriter<Uint8Array>[];\n readonly ready: Promise<undefined>;\n readonly closed: Promise<undefined>;\n readonly desiredSize: number | null = null;\n constructor(writers: WritableStreamDefaultWriter<Uint8Array>[]) {\n this._writers = writers;\n this.ready = Promise.all(this._writers.map((w) => w.ready)).then(() => undefined);\n this.closed = Promise.all(this._writers.map((w) => w.closed)).then(() => undefined);\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abort(reason?: any): Promise<void> {\n return Promise.all(this._writers.map((w) => w.abort(reason))).then(() => {\n /* do nothing */\n });\n }\n close(): Promise<void> {\n return Promise.all(this._writers.map((w) => w.close())).then(() => {\n /* do nothing */\n });\n }\n releaseLock(): void {\n this._writers.map((w) => w.releaseLock());\n }\n\n write(chunk?: Uint8Array | undefined): Promise<void> {\n return Promise.all(this._writers.map((w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index.d.cts CHANGED
@@ -1,36 +1,2 @@
1
- import { Mock } from 'vitest';
2
-
3
- declare function rebufferArray(a: Uint8Array[], chunkSize: number): Promise<Uint8Array[]>;
4
- declare function rebuffer(a: ReadableStream<Uint8Array>, chunkSize: number): ReadableStream<Uint8Array>;
5
-
6
- interface StreamMap<T, U> {
7
- Map(s: T, idx: number): U | Promise<U>;
8
- readonly Close?: () => void;
9
- }
10
- declare function streamMap<T, U>(s: ReadableStream<T>, sm: StreamMap<T, U>): ReadableStream<U>;
11
- declare function devnull<T>(a: ReadableStream<T>): Promise<number>;
12
- declare function array2stream<T>(a: T[]): ReadableStream<T>;
13
- declare function stream2array<T>(a: ReadableStream<T>): Promise<T[]>;
14
-
15
- declare function stream2string(stream?: ReadableStream<Uint8Array> | null, maxSize?: number): Promise<string>;
16
- declare function stream2uint8array(stream?: ReadableStream<Uint8Array> | null): Promise<Uint8Array>;
17
-
18
- interface mockValue {
19
- done: boolean;
20
- value: Uint8Array | undefined;
21
- fillCalls: number;
22
- reBufferCalls: number;
23
- }
24
- interface streamingTestState {
25
- readonly sendChunks: number;
26
- readonly sendChunkSize: number;
27
- fillCalls: number;
28
- CollectorFn: Mock<(mv: mockValue) => void>;
29
- }
30
- declare function receiveFromStream(reb: ReadableStream<Uint8Array>, state: streamingTestState): Promise<void>;
31
- declare function sendToStream(reb: WritableStream<Uint8Array>, state: streamingTestState): Promise<void>;
32
-
33
- declare function string2stream(str: string): ReadableStream<Uint8Array>;
34
- declare function uint8array2stream(str: Uint8Array): ReadableStream<Uint8Array>;
35
-
36
- export { type StreamMap, array2stream, devnull, rebuffer, rebufferArray, receiveFromStream, sendToStream, stream2array, stream2string, stream2uint8array, streamMap, type streamingTestState, string2stream, uint8array2stream };
1
+ export { l as ConsoleWriterStream, C as ConsoleWriterStreamDefaultWriter, F as FanoutWriteStream, S as StreamMap, b as array2stream, d as devnull, a as rebuffer, r as rebufferArray, h as receiveFromStream, j as sendToStream, c as stream2array, e as stream2string, f as stream2uint8array, s as streamMap, g as streamingTestState, k as string2stream, u as uint8array2stream } from '../index-_GuS2IT4.cjs';
2
+ import 'vitest';
package/utils/index.d.ts CHANGED
@@ -1,36 +1,2 @@
1
- import { Mock } from 'vitest';
2
-
3
- declare function rebufferArray(a: Uint8Array[], chunkSize: number): Promise<Uint8Array[]>;
4
- declare function rebuffer(a: ReadableStream<Uint8Array>, chunkSize: number): ReadableStream<Uint8Array>;
5
-
6
- interface StreamMap<T, U> {
7
- Map(s: T, idx: number): U | Promise<U>;
8
- readonly Close?: () => void;
9
- }
10
- declare function streamMap<T, U>(s: ReadableStream<T>, sm: StreamMap<T, U>): ReadableStream<U>;
11
- declare function devnull<T>(a: ReadableStream<T>): Promise<number>;
12
- declare function array2stream<T>(a: T[]): ReadableStream<T>;
13
- declare function stream2array<T>(a: ReadableStream<T>): Promise<T[]>;
14
-
15
- declare function stream2string(stream?: ReadableStream<Uint8Array> | null, maxSize?: number): Promise<string>;
16
- declare function stream2uint8array(stream?: ReadableStream<Uint8Array> | null): Promise<Uint8Array>;
17
-
18
- interface mockValue {
19
- done: boolean;
20
- value: Uint8Array | undefined;
21
- fillCalls: number;
22
- reBufferCalls: number;
23
- }
24
- interface streamingTestState {
25
- readonly sendChunks: number;
26
- readonly sendChunkSize: number;
27
- fillCalls: number;
28
- CollectorFn: Mock<(mv: mockValue) => void>;
29
- }
30
- declare function receiveFromStream(reb: ReadableStream<Uint8Array>, state: streamingTestState): Promise<void>;
31
- declare function sendToStream(reb: WritableStream<Uint8Array>, state: streamingTestState): Promise<void>;
32
-
33
- declare function string2stream(str: string): ReadableStream<Uint8Array>;
34
- declare function uint8array2stream(str: Uint8Array): ReadableStream<Uint8Array>;
35
-
36
- export { type StreamMap, array2stream, devnull, rebuffer, rebufferArray, receiveFromStream, sendToStream, stream2array, stream2string, stream2uint8array, streamMap, type streamingTestState, string2stream, uint8array2stream };
1
+ export { l as ConsoleWriterStream, C as ConsoleWriterStreamDefaultWriter, F as FanoutWriteStream, S as StreamMap, b as array2stream, d as devnull, a as rebuffer, r as rebufferArray, h as receiveFromStream, j as sendToStream, c as stream2array, e as stream2string, f as stream2uint8array, s as streamMap, g as streamingTestState, k as string2stream, u as uint8array2stream } from '../index-_GuS2IT4.js';
2
+ import 'vitest';
package/utils/index.js CHANGED
@@ -1,225 +1,25 @@
1
- import "../chunk-J2IM7FHM.js";
2
-
3
- // src/utils/stream_map.ts
4
- function streamMap(s, sm) {
5
- const state = { reader: s.getReader(), streamMap: sm, idx: 0 };
6
- return new ReadableStream({
7
- async pull(controller) {
8
- const { done, value } = await state.reader.read();
9
- if (done) {
10
- if (state.streamMap.Close) {
11
- state.streamMap.Close();
12
- }
13
- controller.close();
14
- return;
15
- }
16
- const promiseOrU = state.streamMap.Map(value, state.idx++);
17
- let mapped;
18
- if (promiseOrU instanceof Promise || typeof promiseOrU.then === "function") {
19
- mapped = await promiseOrU;
20
- } else {
21
- mapped = promiseOrU;
22
- }
23
- controller.enqueue(mapped);
24
- }
25
- });
26
- }
27
- async function devnull(a) {
28
- const reader = a.getReader();
29
- let cnt = 0;
30
- while (true) {
31
- const { done } = await reader.read();
32
- if (done) {
33
- break;
34
- }
35
- cnt++;
36
- }
37
- return cnt;
38
- }
39
- function array2stream(a) {
40
- let i = 0;
41
- return new ReadableStream({
42
- pull(controller) {
43
- if (i >= a.length) {
44
- controller.close();
45
- return;
46
- }
47
- controller.enqueue(a[i]);
48
- i++;
49
- }
50
- });
51
- }
52
- async function stream2array(a) {
53
- const ret = [];
54
- const reader = a.getReader();
55
- while (true) {
56
- const { done, value } = await reader.read();
57
- if (done) {
58
- break;
59
- }
60
- ret.push(value);
61
- }
62
- return ret;
63
- }
64
-
65
- // src/utils/rebuffer.ts
66
- async function rebufferArray(a, chunkSize) {
67
- return stream2array(rebuffer(array2stream(a), chunkSize));
68
- }
69
- function reChunk(cs, chunkSize) {
70
- const len = cs.reduce((acc, v) => acc + v.length, 0);
71
- const last = cs[cs.length - 1];
72
- const lastOfs = len - last.length;
73
- const rest = last.subarray(chunkSize - lastOfs);
74
- cs[cs.length - 1] = last.subarray(0, chunkSize - lastOfs);
75
- const chunk = new Uint8Array(chunkSize);
76
- let ofs = 0;
77
- for (const c of cs) {
78
- chunk.set(c, ofs);
79
- ofs += c.length;
80
- }
81
- return { rest, chunk };
82
- }
83
- function pump(ps, controller, next) {
84
- ps.reader.read().then(({ done, value }) => {
85
- if (done) {
86
- if (ps.tmpLen > 0) {
87
- controller.enqueue(reChunk(ps.tmp, ps.tmpLen).chunk);
88
- }
89
- controller.close();
90
- next();
91
- return;
92
- }
93
- if (ps.tmpLen + value.length > ps.chunkSize) {
94
- ps.tmp.push(value);
95
- const res = reChunk(ps.tmp, ps.chunkSize);
96
- controller.enqueue(res.chunk);
97
- ps.tmp = [res.rest];
98
- ps.tmpLen = res.rest.length;
99
- next();
100
- return;
101
- } else if (value.length) {
102
- ps.tmp.push(value);
103
- ps.tmpLen += value.length;
104
- }
105
- pump(ps, controller, next);
106
- });
107
- }
108
- function rebuffer(a, chunkSize) {
109
- const state = {
110
- reader: a.getReader(),
111
- tmp: [],
112
- tmpLen: 0,
113
- chunkSize
114
- };
115
- return new ReadableStream({
116
- async pull(controller) {
117
- return new Promise((resolve) => {
118
- pump(state, controller, resolve);
119
- });
120
- }
121
- });
122
- }
123
-
124
- // src/utils/stream2string.ts
125
- async function stream2string(stream, maxSize) {
126
- if (!stream) {
127
- return Promise.resolve("");
128
- }
129
- const reader = stream.getReader();
130
- let res = "";
131
- const decoder = new TextDecoder();
132
- let rSize = 0;
133
- while (typeof maxSize === "undefined" || rSize < maxSize) {
134
- try {
135
- const read = await reader.read();
136
- if (read.done) {
137
- break;
138
- }
139
- if (maxSize && rSize + read.value.length > maxSize) {
140
- read.value = read.value.slice(0, maxSize - rSize);
141
- }
142
- const block = decoder.decode(read.value, { stream: true });
143
- rSize += read.value.length;
144
- res += block;
145
- } catch (err) {
146
- return Promise.reject(err);
147
- }
148
- }
149
- return Promise.resolve(res);
150
- }
151
- async function stream2uint8array(stream) {
152
- if (!stream) {
153
- return Promise.resolve(new Uint8Array());
154
- }
155
- const reader = stream.getReader();
156
- let res = new Uint8Array();
157
- while (1) {
158
- try {
159
- const { done, value } = await reader.read();
160
- if (done) {
161
- break;
162
- }
163
- res = new Uint8Array([...res, ...value]);
164
- } catch (err) {
165
- return Promise.reject(err);
166
- }
167
- }
168
- return Promise.resolve(res);
169
- }
170
-
171
- // src/utils/stream_test_helper.ts
172
- async function receiveFromStream(reb, state) {
173
- return new Promise((resolve) => {
174
- let reBufferCalls = 0;
175
- const reader = reb.getReader();
176
- function pump2() {
177
- reader.read().then(({ done, value }) => {
178
- state.CollectorFn({ done, value, fillCalls: state.fillCalls, reBufferCalls });
179
- reBufferCalls++;
180
- if (done) {
181
- resolve();
182
- return;
183
- }
184
- pump2();
185
- });
186
- }
187
- pump2();
188
- });
189
- }
190
- async function sendToStream(reb, state) {
191
- return new Promise((resolve) => {
192
- const writer = reb.getWriter();
193
- function pump2(i) {
194
- if (i >= state.sendChunks) {
195
- writer.close();
196
- resolve();
197
- return;
198
- }
199
- writer.ready.then(() => {
200
- state.fillCalls++;
201
- writer.write(new Uint8Array(Array(state.sendChunkSize).fill(i)));
202
- pump2(i + 1);
203
- });
204
- }
205
- pump2(0);
206
- });
207
- }
208
-
209
- // src/utils/string2stream.ts
210
- function string2stream(str) {
211
- const encoder = new TextEncoder();
212
- return uint8array2stream(encoder.encode(str));
213
- }
214
- function uint8array2stream(str) {
215
- return new ReadableStream({
216
- start(controller) {
217
- controller.enqueue(str);
218
- controller.close();
219
- }
220
- });
221
- }
1
+ import {
2
+ ConsoleWriterStream,
3
+ ConsoleWriterStreamDefaultWriter,
4
+ FanoutWriteStream,
5
+ array2stream,
6
+ devnull,
7
+ rebuffer,
8
+ rebufferArray,
9
+ receiveFromStream,
10
+ sendToStream,
11
+ stream2array,
12
+ stream2string,
13
+ stream2uint8array,
14
+ streamMap,
15
+ string2stream,
16
+ uint8array2stream
17
+ } from "../chunk-AO7BGISE.js";
18
+ import "../chunk-I4NUGWZ6.js";
222
19
  export {
20
+ ConsoleWriterStream,
21
+ ConsoleWriterStreamDefaultWriter,
22
+ FanoutWriteStream,
223
23
  array2stream,
224
24
  devnull,
225
25
  rebuffer,