@cloudbase/app 3.3.4 → 3.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/constants/common.d.ts +1 -1
- package/dist/cjs/constants/common.js +3 -6
- package/dist/cjs/index.js +16 -7
- package/dist/esm/constants/common.d.ts +1 -1
- package/dist/esm/constants/common.js +3 -6
- package/dist/esm/index.js +16 -7
- package/dist/miniprogram/index.js +1 -1
- package/package.json +4 -4
- package/src/constants/common.ts +2 -5
- package/src/index.ts +20 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/app",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.5",
|
|
4
4
|
"description": "cloudbase javascript sdk core",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@cloudbase/adapter-interface": "^0.7.1",
|
|
45
45
|
"@cloudbase/adapter-wx_mp": "^1.3.1",
|
|
46
|
-
"@cloudbase/types": "3.3.
|
|
47
|
-
"@cloudbase/utilities": "3.3.
|
|
46
|
+
"@cloudbase/types": "3.3.5",
|
|
47
|
+
"@cloudbase/utilities": "3.3.5"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"@cloudbase/signature-nodejs": ">=1.0.0",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"optional": true
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "c49e85b029e204845cc7e402aef4ca7af89b7875"
|
|
66
66
|
}
|
package/src/constants/common.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { EndPointKey } from '@cloudbase/types'
|
|
2
2
|
import { constants } from '@cloudbase/utilities'
|
|
3
3
|
|
|
4
|
-
const ZONE_CHINA = ['ap-shanghai', 'ap-guangzhou', 'ap-shenzhen-fsi', 'ap-shanghai-fsi', 'ap-nanjing', 'ap-beijing', 'ap-chengdu', 'ap-chongqing', 'ap-hongkong']
|
|
5
|
-
|
|
6
4
|
// @ts-ignore
|
|
7
5
|
const { setSdkName: setUtilitiesSdkName, setProtocol: setUtilitiesProtocol } = constants
|
|
8
6
|
/**
|
|
@@ -88,11 +86,10 @@ export interface ISetEndPointWithKey {
|
|
|
88
86
|
protocol?: 'http' | 'https'
|
|
89
87
|
}
|
|
90
88
|
|
|
91
|
-
export function setGatewayEndPointWithEnv(env: string, protocol?: Protocol,
|
|
92
|
-
region = region || 'ap-shanghai'
|
|
89
|
+
export function setGatewayEndPointWithEnv(env: string, protocol?: Protocol, init?: boolean) {
|
|
93
90
|
let baseUrl = `//${env}.api.tcloudbasegateway.com/v1`
|
|
94
91
|
|
|
95
|
-
if (
|
|
92
|
+
if (init) {
|
|
96
93
|
baseUrl = `//${env}.api.intl.tcloudbasegateway.com/v1`
|
|
97
94
|
}
|
|
98
95
|
|
package/src/index.ts
CHANGED
|
@@ -101,7 +101,7 @@ class Cloudbase implements ICloudbase {
|
|
|
101
101
|
],
|
|
102
102
|
})
|
|
103
103
|
public init(config: ICloudbaseConfig & { lang?: LANGS } = { env: '' }): Cloudbase {
|
|
104
|
-
config.endPointMode = config.endPointMode || '
|
|
104
|
+
config.endPointMode = config.endPointMode || 'CLOUD_API'
|
|
105
105
|
|
|
106
106
|
// 初始化时若未兼容平台,则使用默认adapter
|
|
107
107
|
if (!Platform.adapter) {
|
|
@@ -144,7 +144,7 @@ class Cloudbase implements ICloudbase {
|
|
|
144
144
|
initCache({ env, persistence, debug, platformInfo: this.platform })
|
|
145
145
|
|
|
146
146
|
setRegionLevelEndpoint(env, config.region || '')
|
|
147
|
-
setGatewayEndPointWithEnv(env, DEFAULT_PROTOCOL, config.
|
|
147
|
+
setGatewayEndPointWithEnv(env, DEFAULT_PROTOCOL, config.intl)
|
|
148
148
|
|
|
149
149
|
const app = new Cloudbase(this.cloudbaseConfig)
|
|
150
150
|
initRequest({
|
|
@@ -252,20 +252,26 @@ class Cloudbase implements ICloudbase {
|
|
|
252
252
|
public isInitialized(config = this.cloudbaseConfig): boolean {
|
|
253
253
|
// 检测常见占位符 env 值,在开发阶段给出友好提示
|
|
254
254
|
const PLACEHOLDER_PATTERNS = [
|
|
255
|
-
'your-env-id',
|
|
256
|
-
'
|
|
257
|
-
'
|
|
255
|
+
'your-env-id',
|
|
256
|
+
'your-envid',
|
|
257
|
+
'your_env_id',
|
|
258
|
+
'xxx-yyy',
|
|
259
|
+
'xxxx-yyy',
|
|
260
|
+
'envId',
|
|
261
|
+
'env-id',
|
|
262
|
+
'your-environment-id',
|
|
263
|
+
'REPLACE_ME',
|
|
258
264
|
]
|
|
259
265
|
if (PLACEHOLDER_PATTERNS.some(p => config.env.toLowerCase() === p.toLowerCase())) {
|
|
260
266
|
printWarn(
|
|
261
267
|
ERRORS.INVALID_PARAMS,
|
|
262
268
|
`[CloudBase] 检测到环境 ID "${config.env}" 可能是占位符,请替换为真实的环境 ID。\n`
|
|
263
|
-
|
|
264
|
-
|
|
269
|
+
+ ' 获取方式:登录腾讯云开发平台 → 环境管理 → 环境设置 → 环境 ID\n'
|
|
270
|
+
+ ' 建议通过环境变量配置:process.env.CLOUDBASE_ENV 或 import.meta.env.VITE_CLOUDBASE_ENV',
|
|
265
271
|
)
|
|
266
272
|
}
|
|
267
273
|
|
|
268
|
-
return !!
|
|
274
|
+
return !!config?.env
|
|
269
275
|
}
|
|
270
276
|
|
|
271
277
|
/** 设置 tcb api 的 endpoint */
|
|
@@ -333,7 +339,12 @@ class Cloudbase implements ICloudbase {
|
|
|
333
339
|
*/
|
|
334
340
|
private dealNodeAdapterConfig(config: ICloudbaseConfig) {
|
|
335
341
|
// node环境可以从adapter获取默认的secretId和secretKey
|
|
336
|
-
if (
|
|
342
|
+
if (
|
|
343
|
+
typeof process !== 'undefined'
|
|
344
|
+
&& typeof process.env !== 'undefined'
|
|
345
|
+
&& !process.env.IS_BROWSER_BUILD
|
|
346
|
+
&& Platform.adapter?.getSecretInfo
|
|
347
|
+
) {
|
|
337
348
|
const secretInfo = Platform.adapter?.getSecretInfo(config)
|
|
338
349
|
// 将 adapter 提供的密钥信息写入 config.auth
|
|
339
350
|
config.auth = {
|