Skip to content

Commit 828b2f4

Browse files
committed
将大量私有的方法标记为 deprecated & 更新文档
1 parent c87faf6 commit 828b2f4

File tree

6 files changed

+57
-28
lines changed

6 files changed

+57
-28
lines changed

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,12 @@ Qiniu-JavaScript-SDK 的示例 [Demo](http://jssdk-v2.demo.qiniu.io) 中的服
8080

8181
支持以下几种安装方式
8282

83-
* 直接使用静态文件地址:
84-
85-
```
86-
https://cdnjs.cloudflare.com/ajax/libs/qiniu-js/<version>/qiniu.min.js
87-
88-
// 当上方资源链接访问不稳定时,可选使用下方资源链接
89-
https://cdn.staticfile.org/qiniu-js/<version>/qiniu.min.js
90-
```
91-
92-
通过 script 标签引入该文件,会在全局生成名为 `qiniu` 的对象
93-
94-
9583
* 使用 NPM 安装
9684

9785
NPM 的全称是 Node Package Manager,是一个 [NodeJS](https://nodejs.org) 包管理和分发工具,已经成为了非官方的发布 Node 模块(包)的标准。如果需要更详细的关于 NPM 的使用说明,您可以访问 [NPM 官方网站](https://www.npmjs.com),或对应的 [中文网站](http://www.npmjs.com.cn/)
9886

9987
```shell
100-
npm install qiniu-js
88+
$ npm install qiniu-js
10189
```
10290

10391
```Javascript
@@ -106,9 +94,22 @@ Qiniu-JavaScript-SDK 的示例 [Demo](http://jssdk-v2.demo.qiniu.io) 中的服
10694
import * as qiniu from 'qiniu-js'
10795
```
10896

109-
* 通过源码编译
97+
* 直接通过 `script` 标签引入,通过这种方式将会在全局生成名为 `qiniu` 的对象
98+
99+
```html
100+
<script src="https://cdnjs.cloudflare.com/ajax/libs/qiniu-js/<version>/qiniu.min.js"></script>
101+
// 当上方资源链接访问不稳定时,可选用下方资源链接
102+
<script src="https://cdn.staticfile.org/qiniu-js/<version>/qiniu.min.js"></script>
103+
```
110104

111-
`git clone [email protected]:qiniu/js-sdk.git`,进入项目根目录执行 `npm install` ,执行 `npm run build`,即可在dist 目录生成 `qiniu.min.js`
105+
* 通过源码编译,依次执行以下命令即可在本地构建
106+
107+
``` bash
108+
$ git clone [email protected]:qiniu/js-sdk.git
109+
$ cd js-sdk
110+
$ npm install
111+
$ npm run build
112+
```
112113

113114
<a id="usage"></a>
114115

packages/qiniu-js/src/api/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ export function uploadComplete(
120120
* @param token 上传鉴权凭证
121121
* @param key 目标文件名
122122
* @param uploadInfo 上传信息
123-
* @deprecated 请勿使用内部接口,下一个大版本将会取消导出
123+
* @deprecated 请直接通过官网文档使用该接口,而不是使用当前 SDK 包装版本。
124124
*/
125125
export function deleteUploadedChunks(
126126
token: string,
@@ -164,7 +164,7 @@ export type UploadUrlConfig = Partial<Pick<Config, 'upprotocol' | 'uphost' | 're
164164
* @param {string} token
165165
* @returns Promise
166166
* @description 获取上传 url
167-
* @deprecated 请勿使用内部接口,下一个大版本将会取消导出
167+
* @deprecated 请直接通过官网文档使用该接口,而不是使用当前 SDK 包装版本。
168168
*/
169169
export async function getUploadUrl(_config: UploadUrlConfig, token: string): Promise<string> {
170170
const config = utils.normalizeUploadConfig(_config)

packages/qiniu-js/src/index.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
export type { QiniuErrorName, QiniuError, QiniuRequestError, QiniuNetworkError } from './errors'
2-
export { imageMogr2, watermark, imageInfo, exif, pipeline } from './image'
3-
export { deleteUploadedChunks, getUploadUrl } from './api'
4-
5-
export {
6-
upload
7-
} from './upload'
81
export type {
92
UploadKey,
103
UploadError,
@@ -13,8 +6,21 @@ export type {
136
UploadObservable
147
} from './upload'
158

9+
export type {
10+
QiniuError,
11+
QiniuErrorName,
12+
QiniuRequestError,
13+
QiniuNetworkError
14+
} from './errors'
15+
16+
export { upload } from './upload'
1617
export { region } from './config'
1718

19+
export {
20+
getUploadUrl,
21+
deleteUploadedChunks
22+
} from './api'
23+
1824
export {
1925
compressImage,
2026
urlSafeBase64Encode,
@@ -24,3 +30,5 @@ export {
2430
} from './utils'
2531

2632
export type { CompressResult } from './utils'
33+
34+
export { imageMogr2, watermark, imageInfo, exif, pipeline } from './image'

packages/qiniu-js/src/utils/base64.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ function utf8Decode(strData: string) {
137137
return tmpArr.join('')
138138
}
139139

140-
function base64Encode(data: any) {
140+
function base64Encode(data: string) {
141141
// http://kevin.vanzonneveld.net
142142
// + original by: Tyler Akins (http://rumkin.com)
143143
// + improved by: Bayron Guevara
@@ -261,14 +261,22 @@ function base64Decode(data: string) {
261261
return utf8Decode(dec)
262262
}
263263

264-
export function urlSafeBase64Encode(v: any) {
264+
/**
265+
* @param {string} v
266+
* @deprecated 内部实现接口,请勿使用,下个版本将会移除导出
267+
*/
268+
export function urlSafeBase64Encode(v: string) {
265269
v = base64Encode(v)
266270

267271
// 参考 https://tools.ietf.org/html/rfc4648#section-5
268272
return v.replace(/\//g, '_').replace(/\+/g, '-')
269273
}
270274

271-
export function urlSafeBase64Decode(v: any) {
275+
/**
276+
* @param {string} v
277+
* @deprecated 内部实现接口,请勿使用,下个版本将会移除导出
278+
*/
279+
export function urlSafeBase64Decode(v: string) {
272280
v = v.replace(/_/g, '/').replace(/-/g, '+')
273281
return base64Decode(v)
274282
}

packages/qiniu-js/src/utils/compress.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,11 @@ class Compress {
209209
return blob
210210
}
211211
}
212-
212+
/**
213+
* @param {File} file
214+
* @param {CompressOptions} options
215+
* @deprecated 不推荐使用,建议使用其他更专业包替代
216+
*/
213217
const compressImage = (file: File, options: CompressOptions) => new Compress(file, options).process()
214218

215219
export default compressImage

packages/qiniu-js/src/utils/helper.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ export function getAuthHeaders(token: string) {
109109
return { Authorization: auth }
110110
}
111111

112+
/**
113+
* @param {string} token
114+
* @deprecated 内部实现接口,请勿使用,下个版本将会移除导出
115+
*/
112116
export function getHeadersForChunkUpload(token: string) {
113117
const header = getAuthHeaders(token)
114118
return {
@@ -117,6 +121,10 @@ export function getHeadersForChunkUpload(token: string) {
117121
}
118122
}
119123

124+
/**
125+
* @param {string} token
126+
* @deprecated 内部实现接口,请勿使用,下个版本将会移除导出
127+
*/
120128
export function getHeadersForMkFile(token: string) {
121129
const header = getAuthHeaders(token)
122130
return {

0 commit comments

Comments
 (0)