From 0ea96f3c2dca9f36cec626c9410d4d5308545a4a Mon Sep 17 00:00:00 2001 From: fallenoak Date: Mon, 27 Nov 2023 16:45:02 -0600 Subject: [PATCH] fix(types): ensure common types are visible in published package --- src/lib/index.ts | 1 + src/lib/stream/ArrayBufferStream.ts | 1 + src/lib/stream/FsStream.ts | 1 + src/lib/stream/util.ts | 1 + src/lib/type/ArrayIo.ts | 1 + src/lib/type/StringIo.ts | 1 + src/lib/type/StructIo.ts | 1 + src/lib/type/TlvIo.ts | 1 + src/lib/{types.d.ts => types.ts} | 2 ++ src/lib/util.ts | 2 ++ 10 files changed, 12 insertions(+) rename src/lib/{types.d.ts => types.ts} (97%) diff --git a/src/lib/index.ts b/src/lib/index.ts index 9ec5b98..65227e7 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -4,6 +4,7 @@ import StructIo, { StructFields, StructOptions } from './type/StructIo.js'; import TlvIo, { TlvValueCallback } from './type/TlvIo.js'; import { validateType } from './util.js'; import { openStream } from './stream/util.js'; +import { IoStream, IoType } from './types.js'; const array = (type: IoType, options: ArrayOptions) => new ArrayIo(type, options); diff --git a/src/lib/stream/ArrayBufferStream.ts b/src/lib/stream/ArrayBufferStream.ts index ecc79ab..acf28a4 100644 --- a/src/lib/stream/ArrayBufferStream.ts +++ b/src/lib/stream/ArrayBufferStream.ts @@ -1,4 +1,5 @@ import { Endianness } from '../util.js'; +import { IoStream } from '../types.js'; class ArrayBufferStream implements IoStream { #buffer: ArrayBuffer; diff --git a/src/lib/stream/FsStream.ts b/src/lib/stream/FsStream.ts index 3ea7c4a..370ae79 100644 --- a/src/lib/stream/FsStream.ts +++ b/src/lib/stream/FsStream.ts @@ -1,5 +1,6 @@ import fs from '../shim/fs.cjs'; import { Endianness } from '../util.js'; +import { IoStream } from '../types.js'; class FsStream implements IoStream { #fd: number; diff --git a/src/lib/stream/util.ts b/src/lib/stream/util.ts index d52e79b..337e6c0 100644 --- a/src/lib/stream/util.ts +++ b/src/lib/stream/util.ts @@ -1,6 +1,7 @@ import ArrayBufferStream from './ArrayBufferStream.js'; import FsStream from './FsStream.js'; import { Endianness } from '../util.js'; +import { IoSource, IoStream } from '../types.js'; const isStream = (ref: any) => { if (ref instanceof ArrayBufferStream) { diff --git a/src/lib/type/ArrayIo.ts b/src/lib/type/ArrayIo.ts index 76bfd0d..72c272e 100644 --- a/src/lib/type/ArrayIo.ts +++ b/src/lib/type/ArrayIo.ts @@ -1,5 +1,6 @@ import { validateType } from '../util.js'; import { openStream } from '../stream/util.js'; +import { IoContext, IoSource, IoType } from '../types.js'; type ArrayOptions = { size?: number; diff --git a/src/lib/type/StringIo.ts b/src/lib/type/StringIo.ts index f713a3d..57cbe1f 100644 --- a/src/lib/type/StringIo.ts +++ b/src/lib/type/StringIo.ts @@ -1,5 +1,6 @@ import { resolveValue } from '../util.js'; import { openStream } from '../stream/util.js'; +import { IoContext, IoSource, IoStream, IoType } from '../types.js'; const STRING_TERMINATOR = 0x00; const DEFAULT_ENCODING = 'utf-8'; diff --git a/src/lib/type/StructIo.ts b/src/lib/type/StructIo.ts index 924b1b6..0df21a9 100644 --- a/src/lib/type/StructIo.ts +++ b/src/lib/type/StructIo.ts @@ -1,5 +1,6 @@ import { Endianness, validateType } from '../util.js'; import { openStream } from '../stream/util.js'; +import { IoContext, IoSource, IoType } from '../types.js'; type StructFields = Record; diff --git a/src/lib/type/TlvIo.ts b/src/lib/type/TlvIo.ts index 790f7c6..a628ecc 100644 --- a/src/lib/type/TlvIo.ts +++ b/src/lib/type/TlvIo.ts @@ -1,5 +1,6 @@ import { Endianness } from '../util.js'; import { openStream } from '../stream/util.js'; +import { IoContext, IoSource, IoType } from '../types.js'; type TlvValueCallback = ( type: string | number, diff --git a/src/lib/types.d.ts b/src/lib/types.ts similarity index 97% rename from src/lib/types.d.ts rename to src/lib/types.ts index 89e2fdb..3836f97 100644 --- a/src/lib/types.d.ts +++ b/src/lib/types.ts @@ -74,3 +74,5 @@ type IoType = { read: (source: IoSource, context: IoContext) => any; write?: (source: IoSource, value: any, context: IoContext) => any; }; + +export { IoContext, IoSource, IoStream, IoType }; diff --git a/src/lib/util.ts b/src/lib/util.ts index 8d625d7..396db7a 100644 --- a/src/lib/util.ts +++ b/src/lib/util.ts @@ -1,3 +1,5 @@ +import { IoType } from './types.js'; + enum Endianness { Little = 1, Big = 2,