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/
9 changes: 4 additions & 5 deletions lib/utils/streams.js
achou11 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { Readable, Writable, Transform } from 'readable-stream'

/** @import { TransformOptions } from 'readable-stream' */

/**
* Create a writable stream from an async function. Default concurrecy is 16 -
* this is the number of parallel functions that will be pending before
Expand Down Expand Up @@ -134,10 +132,10 @@ export class ProgressStream extends Transform {
#byteLength = 0

/**
* @param {TransformOptions & { onprogress?: ProgressCallback }} [opts]
* @param {{ onprogress?: ProgressCallback}} [opts]
*/
constructor({ onprogress, ...opts } = {}) {
super(opts)
constructor({ onprogress } = {}) {
super()
this.#onprogress = onprogress
}

Expand All @@ -147,6 +145,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.js": {
"types": "./dist/reader.d.ts",
"import": "./lib/reader.js"
},
"./writer.js": {
"types": "./dist/writer.d.ts",
"import": "./lib/writer.js"
},
"./server.js": {
"types": "./dist/server.d.ts",
"import": "./lib/server.js"
},
"./style-downloader.js": {
"types": "./dist/style-downloader.d.ts",
"import": "./lib/style-downloader.js"
},
"./tile-downloader.js": {
"types": "./dist/tile-downloader.d.ts",
"import": "./lib/tile-downloader.js"
},
"./download.js": {
"types": "./dist/download.d.ts",
"import": "./lib/download.js"
}
achou11 marked this conversation as resolved.
Show resolved Hide resolved
},
"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
18 changes: 11 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
{
"compilerOptions": {
"target": "ES2021",
"lib": ["ES2022", "dom"],
"strict": true,
"allowSyntheticDefaultImports": true,
"resolveJsonModule": true,
"module": "ES2022",
"moduleResolution": "node",
"target": "es2022",
"lib": ["es2022"],

"allowJs": true,
"checkJs": true,
"module": "NodeNext",
"moduleDetection": "force",
"resolveJsonModule": true,
"verbatimModuleSyntax": true,
"noEmit": true,

"strict": true,
"noImplicitOverride": true,

"skipLibCheck": true,
"typeRoots": ["types", "node_modules/@types"]
},
Expand Down
Loading