Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: include type definitions when publishing #21

Merged
merged 17 commits into from
Oct 3, 2024
Merged
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ Thumbs.db

# SMP artifacts from testing
/*.smp

# Published directory for type definitions
dist/
3 changes: 3 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/** @typedef {import('./types.js').SMPSource} SMPSource */
/** @typedef {import('./types.js').SMPStyle} SMPStyle */

export { default as Reader } from './reader.js'
export { default as Writer } from './writer.js'
export { default as Server } from './server.js'
Expand Down
5 changes: 4 additions & 1 deletion lib/utils/streams.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,20 @@ export function isWebReadableStream(obj) {
}

/** @typedef {(opts: { totalBytes: number, chunkBytes: number }) => void} ProgressCallback */
/** @typedef {TransformOptions & { onprogress?: ProgressCallback }} ProgressStreamOptions */

/**
* Passthrough stream that counts the bytes passing through it. Pass an optional
* `onprogress` callback that will be called with the accumulated total byte
* count and the chunk byte count after each chunk.
* @extends {Transform}
*/
export class ProgressStream extends Transform {
#onprogress
#byteLength = 0

/**
* @param {TransformOptions & { onprogress?: ProgressCallback }} [opts]
* @param {ProgressStreamOptions} [opts]
*/
constructor({ onprogress, ...opts } = {}) {
super(opts)
Expand All @@ -147,6 +149,7 @@ export class ProgressStream extends Transform {
}

/**
* @override
* @param {Buffer | Uint8Array} chunk
* @param {Parameters<Transform['_transform']>[1]} encoding
* @param {Parameters<Transform['_transform']>[2]} callback
Expand Down
183 changes: 154 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 42 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,55 @@
"version": "1.0.1",
"description": "",
"exports": {
".": "./lib/index.js",
"./reader": "./lib/reader.js",
"./writer": "./lib/writer.js",
"./server": "./lib/server.js",
"./style-downloader": "./lib/style-downloader.js",
"./tile-downloader": "./lib/tile-downloader.js",
"./download": "./lib/download.js"
".": {
"types": "./dist/index.d.ts",
"import": "./lib/index.js"
},
"./reader": {
"types": "./dist/reader.d.ts",
"import": "./lib/reader.js"
},
"./writer": {
"types": "./dist/writer.d.ts",
"import": "./lib/writer.js"
},
"./server": {
"types": "./dist/server.d.ts",
"import": "./lib/server.js"
},
"./style-downloader": {
"types": "./dist/style-downloader.d.ts",
"import": "./lib/style-downloader.js"
},
"./tile-downloader": {
"types": "./dist/tile-downloader.d.ts",
"import": "./lib/tile-downloader.js"
},
"./download": {
"types": "./dist/download.d.ts",
"import": "./lib/download.js"
}
},
"main": "./lib/index.js",
"types": "./dist/index.d.ts",
"bin": {
"styled-map-package": "./bin/smp.js",
"smp": "./bin/smp.js"
},
"type": "module",
"files": [
"bin",
"dist",
"lib",
"map-viewer"
],
achou11 marked this conversation as resolved.
Show resolved Hide resolved
"scripts": {
"test": "npm run lint && node --test",
"test": "npm run lint && npm run types && node --test",
"prepare": "husky",
"lint": "eslint ."
"lint": "eslint .",
"types": "tsc",
"build:types": "rimraf \"dist/\" && tsc -p tsconfig.publish.json",
"prepack": "npm run build:types"
},
"keywords": [],
"author": "",
Expand Down Expand Up @@ -80,6 +112,7 @@
"png-stream": "^1.0.5",
"prettier": "^3.3.3",
"random-bytes-readable-stream": "^3.0.0",
"rimraf": "^4.4.1",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pinned to v4 since >= v5 removes support for node 18

"type-fest": "^4.26.0",
"typescript": "5.5.4"
},
Expand Down
1 change: 1 addition & 0 deletions test/utils/digest-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class DigestStream extends Transform {
this.#hash = createHash(algorithm)
}
/**
* @override
* @param {*} chunk
* @param {BufferEncoding} encoding
* @param {import('node:stream').TransformCallback} callback
Expand Down
Loading
Loading