diff --git a/package-lock.json b/package-lock.json index ac18154d..b750e233 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,6 +40,11 @@ "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", "dev": true }, + "@types/node": { + "version": "12.7.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.8.tgz", + "integrity": "sha512-FMdVn84tJJdV+xe+53sYiZS4R5yn1mAIxfj+DVoNiQjTYz1+OYmjwEZr1ev9nU0axXwda0QDbYl06QHanRVH3A==" + }, "ansi-colors": { "version": "3.2.3", "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-3.2.3.tgz", @@ -469,9 +474,9 @@ }, "dependencies": { "is-buffer": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", - "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", + "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==", "dev": true } } @@ -1544,6 +1549,11 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "typescript": { + "version": "3.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.3.tgz", + "integrity": "sha512-N7bceJL1CtRQ2RiG0AQME13ksR7DiuQh/QehubYcghzv20tnh+MQnQIuJddTmsbqYj+dztchykemz0zFzlvdQw==" + }, "uglify-js": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz", diff --git a/package.json b/package.json index 1d00f77b..de71cf9d 100644 --- a/package.json +++ b/package.json @@ -5,14 +5,17 @@ "repository": "https://github.com/imgix/imgix-core-js", "scripts": { "assert_version": "node assert_version.js", - "compile": "mkdir -p dist && uglifyjs ./src/imgix-core-js.js -o ./dist/imgix-core-js.min.js && cp ./src/imgix-core-js.js ./dist/imgix-core-js.js", + "compile": "mkdir -p dist && uglifyjs ./src/imgix-core-js.js -o ./dist/imgix-core-js.min.js && cp ./src/imgix-core-js.js ./dist/imgix-core-js.js && cp ./src/imgix-core-js.d.ts ./dist/imgix-core-js.d.ts && tsc", "prepublish": "npm run compile && npm run assert_version", "test": "mocha" }, "main": "dist/imgix-core-js.js", + "types": "dist/imgix-core-js.d.ts", "dependencies": { "js-base64": "^2.1.9", - "md5": "^2.2.1" + "md5": "^2.2.1", + "typescript": "^3.6.3", + "@types/node": "^12.7.8" }, "license": "BSD-2-Clause", "devDependencies": { diff --git a/src/imgix-core-js.d.ts b/src/imgix-core-js.d.ts new file mode 100644 index 00000000..61590951 --- /dev/null +++ b/src/imgix-core-js.d.ts @@ -0,0 +1,20 @@ +// Type definitions for imgix-core-js.js + +declare class ImgixClient { + domain: string; + useHTTPS: boolean; + includeLibraryParam: boolean; + secureURLToken: string; + + constructor(opts: {domain: string; secureURLToken?: string; useHTTPS?: boolean; includeLibraryParam?: boolean;}); + + + buildURL(path: string, params?: {}): string; + _sanitizePath(path: string): string; + _buildParams(params: {}): string; + _signParams(path: string, queryParams?: {}): string; + buildSrcSet(path: string, params?: {}): string; + _buildSrcSetPairs(path: string, params?: {}): string; + _buildDPRSrcSet(path: string, params?: {}): string; +} +export = ImgixClient; diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..73d684f2 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "es2015", + "module": "umd", + "types": [ + "node" + ] + }, + "files": [ + "src/imgix-core-js.d.ts" + ] +}