@dcloudio/vue-cli-plugin-uni 2.0.0-32920210927001 → 2.0.0-32920211119001
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/commands/build.js +51 -9
- package/generator.js +4 -0
- package/lib/check-update.js +56 -0
- package/lib/configure-webpack.js +19 -4
- package/lib/env.js +8 -5
- package/lib/mp/index.js +9 -10
- package/package.json +3 -3
- package/packages/uni-cloud/dist/index.js +1 -1
package/commands/build.js
CHANGED
|
@@ -3,7 +3,9 @@ const path = require('path')
|
|
|
3
3
|
const {
|
|
4
4
|
runByHBuilderX,
|
|
5
5
|
isInHBuilderX,
|
|
6
|
-
parseJson
|
|
6
|
+
parseJson,
|
|
7
|
+
parsePagesJson,
|
|
8
|
+
parseManifestJson
|
|
7
9
|
} = require('@dcloudio/uni-cli-shared')
|
|
8
10
|
|
|
9
11
|
const uniI18n = require('@dcloudio/uni-cli-i18n')
|
|
@@ -32,7 +34,8 @@ module.exports = (api, options) => {
|
|
|
32
34
|
'--auto-host': 'specify automator host',
|
|
33
35
|
'--auto-port': 'specify automator port',
|
|
34
36
|
'--subpackage': 'specify subpackage',
|
|
35
|
-
'--plugin': 'specify plugin'
|
|
37
|
+
'--plugin': 'specify plugin',
|
|
38
|
+
'--manifest': 'build manifest.json'
|
|
36
39
|
}
|
|
37
40
|
}, async (args) => {
|
|
38
41
|
for (const key in defaults) {
|
|
@@ -41,7 +44,11 @@ module.exports = (api, options) => {
|
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
|
|
47
|
+
if (args.manifest && process.env.UNI_PLATFORM === 'app-plus') {
|
|
48
|
+
return buildManifestJson()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const platforms = ['mp-weixin', 'mp-qq', 'mp-baidu', 'mp-alipay', 'mp-toutiao', 'mp-lark']
|
|
45
52
|
if (args.subpackage && platforms.includes(process.env.UNI_PLATFORM)) {
|
|
46
53
|
process.env.UNI_SUBPACKGE = args.subpackage
|
|
47
54
|
}
|
|
@@ -135,7 +142,10 @@ async function build (args, api, options) {
|
|
|
135
142
|
log()
|
|
136
143
|
|
|
137
144
|
if (!runByHBuilderX && !runByAliIde) {
|
|
138
|
-
logWithSpinner(uniI18n.__('pluginUni.startCompileProjectToPlatform', {
|
|
145
|
+
logWithSpinner(uniI18n.__('pluginUni.startCompileProjectToPlatform', {
|
|
146
|
+
0: process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM,
|
|
147
|
+
1: process.env.UNI_MP_PLUGIN ? uniI18n.__('plugin') : uniI18n.__('platform')
|
|
148
|
+
}))
|
|
139
149
|
}
|
|
140
150
|
|
|
141
151
|
const targetDir = api.resolve(options.outputDir)
|
|
@@ -161,7 +171,8 @@ async function build (args, api, options) {
|
|
|
161
171
|
process.env.UNI_USING_V3_NATIVE ||
|
|
162
172
|
(process.UNI_NVUE_ENTRY && Object.keys(process.UNI_NVUE_ENTRY).length)
|
|
163
173
|
) {
|
|
164
|
-
webpackConfigs.push(require('@dcloudio/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js')(process
|
|
174
|
+
webpackConfigs.push(require('@dcloudio/vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js')(process
|
|
175
|
+
.UNI_NVUE_ENTRY))
|
|
165
176
|
}
|
|
166
177
|
|
|
167
178
|
return new Promise((resolve, reject) => {
|
|
@@ -178,7 +189,8 @@ async function build (args, api, options) {
|
|
|
178
189
|
return reject('Build failed with errors.')
|
|
179
190
|
}
|
|
180
191
|
|
|
181
|
-
if (!args.silent && (process.env.UNI_PLATFORM !== 'app-plus' || process.env
|
|
192
|
+
if (!args.silent && (process.env.UNI_PLATFORM !== 'app-plus' || process.env
|
|
193
|
+
.UNI_AUTOMATOR_WS_ENDPOINT)) {
|
|
182
194
|
const targetDirShort = path.relative(
|
|
183
195
|
api.service.context,
|
|
184
196
|
process.env.UNI_OUTPUT_DIR
|
|
@@ -195,7 +207,8 @@ async function build (args, api, options) {
|
|
|
195
207
|
console.log('https://uniapp.dcloud.io/uniCloud/hosting')
|
|
196
208
|
}
|
|
197
209
|
} else {
|
|
198
|
-
const dirMsg = runByHBuilderX ? ''
|
|
210
|
+
const dirMsg = runByHBuilderX ? ''
|
|
211
|
+
: `The ${chalk.cyan(targetDirShort)} directory is ready. `
|
|
199
212
|
done(`Build complete. ${dirMsg}Watching for changes...`)
|
|
200
213
|
}
|
|
201
214
|
}
|
|
@@ -221,7 +234,9 @@ function analysisPluginDir () {
|
|
|
221
234
|
|
|
222
235
|
if (!fs.pathExistsSync(pluginJsonPath)) {
|
|
223
236
|
console.log()
|
|
224
|
-
console.error(uniI18n.__('pluginUni.fileNoExistsCheckAfterRetry', {
|
|
237
|
+
console.error(uniI18n.__('pluginUni.fileNoExistsCheckAfterRetry', {
|
|
238
|
+
0: pluginJsonName
|
|
239
|
+
}))
|
|
225
240
|
console.log()
|
|
226
241
|
process.exit(0)
|
|
227
242
|
}
|
|
@@ -235,8 +250,35 @@ function analysisPluginDir () {
|
|
|
235
250
|
|
|
236
251
|
if (UNI_MP_PLUGIN_MAIN && !fs.pathExistsSync(mainFilePath)) {
|
|
237
252
|
console.log()
|
|
238
|
-
console.error(uniI18n.__('pluginUni.entryDileNoExistsCheckAfterRetry', {
|
|
253
|
+
console.error(uniI18n.__('pluginUni.entryDileNoExistsCheckAfterRetry', {
|
|
254
|
+
0: UNI_MP_PLUGIN_MAIN
|
|
255
|
+
}))
|
|
239
256
|
console.log()
|
|
240
257
|
process.exit(0)
|
|
241
258
|
}
|
|
242
259
|
}
|
|
260
|
+
|
|
261
|
+
function buildManifestJson () {
|
|
262
|
+
const fs = require('fs-extra')
|
|
263
|
+
const inputDir = process.env.UNI_INPUT_DIR
|
|
264
|
+
const outputDir = process.env.UNI_OUTPUT_DIR
|
|
265
|
+
const pagesJsonPath = path.resolve(inputDir, 'pages.json')
|
|
266
|
+
const manifestJsonPath = path.resolve(inputDir, 'manifest.json')
|
|
267
|
+
|
|
268
|
+
const pagesJson = parsePagesJson(fs.readFileSync(pagesJsonPath, 'utf8'))
|
|
269
|
+
const manifestJson = parseManifestJson(fs.readFileSync(manifestJsonPath, 'utf8'))
|
|
270
|
+
|
|
271
|
+
const res = require('@dcloudio/webpack-uni-pages-loader/lib/platforms/app-plus/index.js')(pagesJson,
|
|
272
|
+
manifestJson,
|
|
273
|
+
false)
|
|
274
|
+
if (res && res[0]) {
|
|
275
|
+
fs.outputFileSync(
|
|
276
|
+
path.resolve(outputDir, 'manifest.json'),
|
|
277
|
+
res[0].content
|
|
278
|
+
)
|
|
279
|
+
}
|
|
280
|
+
const {
|
|
281
|
+
done
|
|
282
|
+
} = require('@vue/cli-shared-utils')
|
|
283
|
+
done('Build complete.')
|
|
284
|
+
}
|
package/generator.js
CHANGED
|
@@ -17,6 +17,7 @@ module.exports = (api, options, rootOptions) => {
|
|
|
17
17
|
'dev:mp-alipay': 'cross-env NODE_ENV=development UNI_PLATFORM=mp-alipay vue-cli-service uni-build --watch',
|
|
18
18
|
'dev:mp-toutiao': 'cross-env NODE_ENV=development UNI_PLATFORM=mp-toutiao vue-cli-service uni-build --watch',
|
|
19
19
|
'dev:mp-kuaishou': 'cross-env NODE_ENV=development UNI_PLATFORM=mp-kuaishou vue-cli-service uni-build --watch',
|
|
20
|
+
'dev:mp-lark': 'cross-env NODE_ENV=development UNI_PLATFORM=mp-lark vue-cli-service uni-build --watch',
|
|
20
21
|
'dev:quickapp-native': 'cross-env NODE_ENV=development UNI_PLATFORM=quickapp-native vue-cli-service uni-build --watch',
|
|
21
22
|
'dev:quickapp-webview': 'cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview vue-cli-service uni-build --watch',
|
|
22
23
|
'dev:quickapp-webview-huawei': 'cross-env NODE_ENV=development UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build --watch',
|
|
@@ -28,6 +29,7 @@ module.exports = (api, options, rootOptions) => {
|
|
|
28
29
|
'build:mp-alipay': 'cross-env NODE_ENV=production UNI_PLATFORM=mp-alipay vue-cli-service uni-build',
|
|
29
30
|
'build:mp-toutiao': 'cross-env NODE_ENV=production UNI_PLATFORM=mp-toutiao vue-cli-service uni-build',
|
|
30
31
|
'build:mp-kuaishou': 'cross-env NODE_ENV=production UNI_PLATFORM=mp-kuaishou vue-cli-service uni-build',
|
|
32
|
+
'build:mp-lark': 'cross-env NODE_ENV=production UNI_PLATFORM=mp-lark vue-cli-service uni-build',
|
|
31
33
|
'build:quickapp-native': 'cross-env NODE_ENV=production UNI_PLATFORM=quickapp-native vue-cli-service uni-build',
|
|
32
34
|
'build:quickapp-webview': 'cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview vue-cli-service uni-build',
|
|
33
35
|
'build:quickapp-webview-huawei': 'cross-env NODE_ENV=production UNI_PLATFORM=quickapp-webview-huawei vue-cli-service uni-build',
|
|
@@ -54,6 +56,7 @@ module.exports = (api, options, rootOptions) => {
|
|
|
54
56
|
'@dcloudio/uni-mp-baidu': version,
|
|
55
57
|
'@dcloudio/uni-mp-alipay': version,
|
|
56
58
|
'@dcloudio/uni-mp-toutiao': version,
|
|
59
|
+
'@dcloudio/uni-mp-lark': version,
|
|
57
60
|
'@dcloudio/uni-mp-360': version,
|
|
58
61
|
'@dcloudio/uni-mp-kuaishou': version,
|
|
59
62
|
'@dcloudio/uni-quickapp-native': version,
|
|
@@ -66,6 +69,7 @@ module.exports = (api, options, rootOptions) => {
|
|
|
66
69
|
},
|
|
67
70
|
devDependencies: {
|
|
68
71
|
'@dcloudio/uni-automator': version,
|
|
72
|
+
'@dcloudio/uni-cli-i18n': version,
|
|
69
73
|
'@dcloudio/uni-cli-shared': version,
|
|
70
74
|
'@dcloudio/uni-migration': version,
|
|
71
75
|
'@dcloudio/uni-template-compiler': version,
|
package/lib/check-update.js
CHANGED
|
@@ -13,6 +13,9 @@ class Upate {
|
|
|
13
13
|
this._isAlpha = false
|
|
14
14
|
this._uniId = ''
|
|
15
15
|
this._appId = ''
|
|
16
|
+
this._wt = 0
|
|
17
|
+
this._lc = ''
|
|
18
|
+
this._lcin = []
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
get uniId () {
|
|
@@ -47,6 +50,30 @@ class Upate {
|
|
|
47
50
|
this._isAlpha = value
|
|
48
51
|
}
|
|
49
52
|
|
|
53
|
+
get wt () {
|
|
54
|
+
return this._wt
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
set wt (value) {
|
|
58
|
+
this._wt = value
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get lc () {
|
|
62
|
+
return this._lc
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
set lc (value) {
|
|
66
|
+
this._lc = value
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get lcin () {
|
|
70
|
+
return this._lcin
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
set lcin (value) {
|
|
74
|
+
this._lcin = value
|
|
75
|
+
}
|
|
76
|
+
|
|
50
77
|
get versionType () {
|
|
51
78
|
return (this.isAlpha ? 'a' : 'r')
|
|
52
79
|
}
|
|
@@ -156,6 +183,9 @@ class Upate {
|
|
|
156
183
|
data.appid = this.uniId
|
|
157
184
|
data.vtype = this.versionType
|
|
158
185
|
data.vcode = this.compilerVersion
|
|
186
|
+
data.wt = this._wt
|
|
187
|
+
data.lc = this._lc
|
|
188
|
+
data.in = this._lcin
|
|
159
189
|
|
|
160
190
|
delete data.lastCheck
|
|
161
191
|
|
|
@@ -234,6 +264,28 @@ Object.assign(Upate.prototype, {
|
|
|
234
264
|
DEFAULT_INTERVAL: 1000 * 60 * 60 * 24
|
|
235
265
|
})
|
|
236
266
|
|
|
267
|
+
function getLc () {
|
|
268
|
+
const result = []
|
|
269
|
+
const localeDir = path.join(process.env.UNI_CLI_CONTEXT, 'src/locale')
|
|
270
|
+
if (!fs.existsSync(localeDir)) {
|
|
271
|
+
return result
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
const files = fs.readdirSync(localeDir)
|
|
275
|
+
for (let i = files.length - 1; i >= 0; i--) {
|
|
276
|
+
const filePath = files[i]
|
|
277
|
+
const extName = filePath.substring(filePath.lastIndexOf('.') + 1).toLowerCase()
|
|
278
|
+
if (extName !== 'json') {
|
|
279
|
+
continue
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (files[i].indexOf('uni-app.') < 0) {
|
|
283
|
+
result.push(filePath.substring(0, filePath.lastIndexOf('.')))
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return result
|
|
287
|
+
}
|
|
288
|
+
|
|
237
289
|
module.exports = async function checkUpdate () {
|
|
238
290
|
const {
|
|
239
291
|
isInHBuilderX,
|
|
@@ -255,6 +307,10 @@ module.exports = async function checkUpdate () {
|
|
|
255
307
|
update.uniId = manifest.appid
|
|
256
308
|
const appIdKey = process.env.UNI_PLATFORM.includes('quickapp') ? 'package' : 'appid'
|
|
257
309
|
update.appId = manifest[process.env.UNI_PLATFORM] ? (manifest[process.env.UNI_PLATFORM][appIdKey] || '') : ''
|
|
310
|
+
const cf = manifest['mp-weixin'] ? manifest['mp-weixin'].cloudfunctionRoot : ''
|
|
311
|
+
update.wt = (cf && cf.length) ? 1 : 0
|
|
312
|
+
update.lc = manifest.locale ? manifest.locale : ''
|
|
313
|
+
update.lcin = getLc().join(',')
|
|
258
314
|
update.check()
|
|
259
315
|
} catch (e) {
|
|
260
316
|
}
|
package/lib/configure-webpack.js
CHANGED
|
@@ -15,7 +15,7 @@ function resolve (dir) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
function resolveModule (dir) {
|
|
18
|
-
return path.resolve(
|
|
18
|
+
return path.resolve(process.env.UNI_CLI_CONTEXT, './node_modules', dir)
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
module.exports = function configureWebpack (platformOptions, manifestPlatformOptions, vueOptions, api) {
|
|
@@ -184,8 +184,9 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
|
|
|
184
184
|
platformWebpackConfig = platformWebpackConfig(webpackConfig, vueOptions, api)
|
|
185
185
|
}
|
|
186
186
|
// 移除 node_modules 目录,避免受路径上的 node_modules 影响
|
|
187
|
-
|
|
188
|
-
'node_modules')
|
|
187
|
+
if (require('@dcloudio/uni-cli-shared/lib/util').isInHBuilderX) {
|
|
188
|
+
webpackConfig.resolve.modules = webpackConfig.resolve.modules.filter(module => module !== 'node_modules')
|
|
189
|
+
}
|
|
189
190
|
|
|
190
191
|
const plugins = []
|
|
191
192
|
|
|
@@ -298,6 +299,17 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
|
|
|
298
299
|
}
|
|
299
300
|
} catch (e) {}
|
|
300
301
|
|
|
302
|
+
const resolveLoaderAlias = {}
|
|
303
|
+
const modules = ['@vue/cli-plugin-babel', '@vue/cli-service']
|
|
304
|
+
modules.forEach(m => {
|
|
305
|
+
const { dependencies } = require(`${m}/package.json`)
|
|
306
|
+
Object.keys(dependencies).forEach(key => {
|
|
307
|
+
if (/-loader$/.test(key)) {
|
|
308
|
+
resolveLoaderAlias[key] = require.resolve(key)
|
|
309
|
+
}
|
|
310
|
+
})
|
|
311
|
+
})
|
|
312
|
+
|
|
301
313
|
return merge({
|
|
302
314
|
devtool: false,
|
|
303
315
|
resolve: {
|
|
@@ -325,6 +337,9 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
|
|
|
325
337
|
noParse: /^(vue|vue-router|vuex|vuex-router-sync)$/,
|
|
326
338
|
rules
|
|
327
339
|
},
|
|
340
|
+
resolveLoader: {
|
|
341
|
+
alias: resolveLoaderAlias
|
|
342
|
+
},
|
|
328
343
|
plugins,
|
|
329
344
|
performance: {
|
|
330
345
|
assetFilter (assetFilename) {
|
|
@@ -334,4 +349,4 @@ module.exports = function configureWebpack (platformOptions, manifestPlatformOpt
|
|
|
334
349
|
watchOptions: require('./util').getWatchOptions()
|
|
335
350
|
}, platformWebpackConfig)
|
|
336
351
|
}
|
|
337
|
-
}
|
|
352
|
+
}
|
package/lib/env.js
CHANGED
|
@@ -49,6 +49,9 @@ process.env.UNI_USING_V3_SCOPED = true
|
|
|
49
49
|
|
|
50
50
|
process.env.UNI_CLOUD_PROVIDER = JSON.stringify([])
|
|
51
51
|
|
|
52
|
+
// 导出到小程序插件
|
|
53
|
+
process.env.UNI_MP_PLUGIN_EXPORT = JSON.stringify(Object.keys(platformOptions.plugins || {}).map(pluginName => platformOptions.plugins[pluginName].export))
|
|
54
|
+
|
|
52
55
|
const isH5 = !process.env.UNI_SUB_PLATFORM && process.env.UNI_PLATFORM === 'h5'
|
|
53
56
|
const isProduction = process.env.NODE_ENV === 'production'
|
|
54
57
|
|
|
@@ -104,11 +107,13 @@ if (process.env.UNI_CLOUD_SPACES) {
|
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
// 初始化环境变量
|
|
107
|
-
|
|
110
|
+
process.env.UNI_CLI_CONTEXT = require('@dcloudio/uni-cli-shared/lib/util').getCLIContext()
|
|
111
|
+
|
|
112
|
+
const defaultOutputDir = './dist/' +
|
|
108
113
|
(process.env.NODE_ENV === 'production' ? 'build' : 'dev') + '/' +
|
|
109
114
|
(process.env.UNI_SUB_PLATFORM || process.env.UNI_PLATFORM)
|
|
110
115
|
|
|
111
|
-
process.env.UNI_OUTPUT_DEFAULT_DIR = path.resolve(
|
|
116
|
+
process.env.UNI_OUTPUT_DEFAULT_DIR = path.resolve(process.env.UNI_CLI_CONTEXT, defaultOutputDir)
|
|
112
117
|
if (process.env.UNI_OUTPUT_DIR && process.env.UNI_OUTPUT_DIR.indexOf('./') === 0) {
|
|
113
118
|
process.env.UNI_OUTPUT_DIR = path.resolve(process.cwd(), process.env.UNI_OUTPUT_DIR)
|
|
114
119
|
}
|
|
@@ -121,8 +126,6 @@ if (process.env.UNI_PLATFORM === 'app-plus') {
|
|
|
121
126
|
process.env.UNI_OUTPUT_TMP_DIR = path.resolve(process.env.UNI_OUTPUT_DIR, '../.tmp/app-plus')
|
|
122
127
|
}
|
|
123
128
|
|
|
124
|
-
process.env.UNI_CLI_CONTEXT = path.resolve(__dirname, '../../../../')
|
|
125
|
-
|
|
126
129
|
process.UNI_LIBRARIES = process.UNI_LIBRARIES || ['@dcloudio/uni-ui']
|
|
127
130
|
|
|
128
131
|
if (process.env.NODE_ENV === 'production') { // 发行模式,不启用 cache
|
|
@@ -410,7 +413,7 @@ if (process.env.UNI_PLATFORM === 'h5') {
|
|
|
410
413
|
moduleAlias.addAlias('vue-style-loader', '@dcloudio/vue-cli-plugin-uni/packages/h5-vue-style-loader')
|
|
411
414
|
}
|
|
412
415
|
|
|
413
|
-
if (process.env.UNI_PLATFORM === 'mp-toutiao') {
|
|
416
|
+
if (process.env.UNI_PLATFORM === 'mp-toutiao' || process.env.UNI_PLATFORM === 'mp-lark') {
|
|
414
417
|
// !important 始终带有一个空格
|
|
415
418
|
moduleAlias.addAlias(
|
|
416
419
|
'postcss-normalize-whitespace',
|
package/lib/mp/index.js
CHANGED
|
@@ -138,6 +138,10 @@ function initSubpackageConfig (webpackConfig, vueOptions) {
|
|
|
138
138
|
webpackConfig.output.jsonpFunction('webpackJsonp_' + (process.env.UNI_SUBPACKGE || process.env.UNI_MP_PLUGIN))
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
+
function addToUniEntry (fileName) {
|
|
142
|
+
fileName && (process.UNI_ENTRY[fileName.split('.')[0]] = path.resolve(process.env.UNI_INPUT_DIR, fileName))
|
|
143
|
+
}
|
|
144
|
+
|
|
141
145
|
module.exports = {
|
|
142
146
|
vueConfig: {
|
|
143
147
|
parallel: false
|
|
@@ -171,16 +175,11 @@ module.exports = {
|
|
|
171
175
|
plugins.push(new PreprocessAssetsPlugin())
|
|
172
176
|
}
|
|
173
177
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
const UNI_MP_PLUGIN_MAIN = process.env.UNI_MP_PLUGIN_MAIN
|
|
180
|
-
if (UNI_MP_PLUGIN_MAIN) {
|
|
181
|
-
process.UNI_ENTRY[UNI_MP_PLUGIN_MAIN.split('.')[0]] = path.resolve(process.env.UNI_INPUT_DIR,
|
|
182
|
-
UNI_MP_PLUGIN_MAIN)
|
|
183
|
-
}
|
|
178
|
+
{
|
|
179
|
+
const globalEnv = process.env.UNI_PLATFORM === 'mp-alipay' ? 'my' : 'wx'
|
|
180
|
+
;[].concat(process.env.UNI_MP_PLUGIN ? process.env.UNI_MP_PLUGIN_MAIN : JSON.parse(process.env.UNI_MP_PLUGIN_EXPORT))
|
|
181
|
+
.forEach(fileName => addToUniEntry(fileName))
|
|
182
|
+
beforeCode += `${globalEnv}.__webpack_require_${(process.env.UNI_MP_PLUGIN || 'UNI_MP_PLUGIN').replace(/-/g, '_')}__ = __webpack_require__;`
|
|
184
183
|
}
|
|
185
184
|
|
|
186
185
|
const alias = { // 仅 mp-weixin
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dcloudio/vue-cli-plugin-uni",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-32920211119001",
|
|
4
4
|
"description": "uni-app plugin for vue-cli 3",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"author": "fxy060608",
|
|
18
18
|
"license": "Apache-2.0",
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@dcloudio/uni-stat": "^2.0.0-
|
|
20
|
+
"@dcloudio/uni-stat": "^2.0.0-32920211119001",
|
|
21
21
|
"buffer-json": "^2.0.0",
|
|
22
22
|
"copy-webpack-plugin": "^5.1.1",
|
|
23
23
|
"cross-env": "^5.2.0",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"wrap-loader": "^0.2.0",
|
|
38
38
|
"xregexp": "4.0.0"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "330826b26bcda49d88f01d8da04ab470a0772d45"
|
|
41
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{initVueI18n as e}from"@dcloudio/uni-i18n";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function n(e,t,n){return e(n={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&n.path)}},n.exports),n.exports}var s=n((function(e,t){var n;e.exports=(n=n||function(e,t){var n=Object.create||function(){function e(){}return function(t){var n;return e.prototype=t,n=new e,e.prototype=null,n}}(),s={},r=s.lib={},o=r.Base={extend:function(e){var t=n(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},i=r.WordArray=o.extend({init:function(e,n){e=this.words=e||[],this.sigBytes=n!=t?n:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,s=this.sigBytes,r=e.sigBytes;if(this.clamp(),s%4)for(var o=0;o<r;o++){var i=n[o>>>2]>>>24-o%4*8&255;t[s+o>>>2]|=i<<24-(s+o)%4*8}else for(o=0;o<r;o+=4)t[s+o>>>2]=n[o>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,n=this.sigBytes;t[n>>>2]&=4294967295<<32-n%4*8,t.length=e.ceil(n/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,s=[],r=function(t){t=t;var n=987654321,s=4294967295;return function(){var r=((n=36969*(65535&n)+(n>>16)&s)<<16)+(t=18e3*(65535&t)+(t>>16)&s)&s;return r/=4294967296,(r+=.5)*(e.random()>.5?1:-1)}},o=0;o<t;o+=4){var a=r(4294967296*(n||e.random()));n=987654071*a(),s.push(4294967296*a()|0)}return new i.init(s,t)}}),a=s.enc={},c=a.Hex={stringify:function(e){for(var t=e.words,n=e.sigBytes,s=[],r=0;r<n;r++){var o=t[r>>>2]>>>24-r%4*8&255;s.push((o>>>4).toString(16)),s.push((15&o).toString(16))}return s.join("")},parse:function(e){for(var t=e.length,n=[],s=0;s<t;s+=2)n[s>>>3]|=parseInt(e.substr(s,2),16)<<24-s%8*4;return new i.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,s=[],r=0;r<n;r++){var o=t[r>>>2]>>>24-r%4*8&255;s.push(String.fromCharCode(o))}return s.join("")},parse:function(e){for(var t=e.length,n=[],s=0;s<t;s++)n[s>>>2]|=(255&e.charCodeAt(s))<<24-s%4*8;return new i.init(n,t)}},h=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},l=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new i.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,s=n.words,r=n.sigBytes,o=this.blockSize,a=r/(4*o),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,u=e.min(4*c,r);if(c){for(var h=0;h<c;h+=o)this._doProcessBlock(s,h);var l=s.splice(0,c);n.sigBytes-=u}return new i.init(l,u)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),d=(r.Hasher=l.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,n){return new e.init(n).finalize(t)}},_createHmacHelper:function(e){return function(t,n){return new d.HMAC.init(e,n).finalize(t)}}}),s.algo={});return s}(Math),n)})),r=(n((function(e,t){var n;e.exports=(n=s,function(e){var t=n,s=t.lib,r=s.WordArray,o=s.Hasher,i=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=i.MD5=o.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var n=0;n<16;n++){var s=t+n,r=e[s];e[s]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}var o=this._hash.words,i=e[t+0],c=e[t+1],f=e[t+2],p=e[t+3],g=e[t+4],m=e[t+5],y=e[t+6],_=e[t+7],w=e[t+8],v=e[t+9],S=e[t+10],k=e[t+11],T=e[t+12],P=e[t+13],I=e[t+14],A=e[t+15],E=o[0],b=o[1],O=o[2],U=o[3];E=u(E,b,O,U,i,7,a[0]),U=u(U,E,b,O,c,12,a[1]),O=u(O,U,E,b,f,17,a[2]),b=u(b,O,U,E,p,22,a[3]),E=u(E,b,O,U,g,7,a[4]),U=u(U,E,b,O,m,12,a[5]),O=u(O,U,E,b,y,17,a[6]),b=u(b,O,U,E,_,22,a[7]),E=u(E,b,O,U,w,7,a[8]),U=u(U,E,b,O,v,12,a[9]),O=u(O,U,E,b,S,17,a[10]),b=u(b,O,U,E,k,22,a[11]),E=u(E,b,O,U,T,7,a[12]),U=u(U,E,b,O,P,12,a[13]),O=u(O,U,E,b,I,17,a[14]),E=h(E,b=u(b,O,U,E,A,22,a[15]),O,U,c,5,a[16]),U=h(U,E,b,O,y,9,a[17]),O=h(O,U,E,b,k,14,a[18]),b=h(b,O,U,E,i,20,a[19]),E=h(E,b,O,U,m,5,a[20]),U=h(U,E,b,O,S,9,a[21]),O=h(O,U,E,b,A,14,a[22]),b=h(b,O,U,E,g,20,a[23]),E=h(E,b,O,U,v,5,a[24]),U=h(U,E,b,O,I,9,a[25]),O=h(O,U,E,b,p,14,a[26]),b=h(b,O,U,E,w,20,a[27]),E=h(E,b,O,U,P,5,a[28]),U=h(U,E,b,O,f,9,a[29]),O=h(O,U,E,b,_,14,a[30]),E=l(E,b=h(b,O,U,E,T,20,a[31]),O,U,m,4,a[32]),U=l(U,E,b,O,w,11,a[33]),O=l(O,U,E,b,k,16,a[34]),b=l(b,O,U,E,I,23,a[35]),E=l(E,b,O,U,c,4,a[36]),U=l(U,E,b,O,g,11,a[37]),O=l(O,U,E,b,_,16,a[38]),b=l(b,O,U,E,S,23,a[39]),E=l(E,b,O,U,P,4,a[40]),U=l(U,E,b,O,i,11,a[41]),O=l(O,U,E,b,p,16,a[42]),b=l(b,O,U,E,y,23,a[43]),E=l(E,b,O,U,v,4,a[44]),U=l(U,E,b,O,T,11,a[45]),O=l(O,U,E,b,A,16,a[46]),E=d(E,b=l(b,O,U,E,f,23,a[47]),O,U,i,6,a[48]),U=d(U,E,b,O,_,10,a[49]),O=d(O,U,E,b,I,15,a[50]),b=d(b,O,U,E,m,21,a[51]),E=d(E,b,O,U,T,6,a[52]),U=d(U,E,b,O,p,10,a[53]),O=d(O,U,E,b,S,15,a[54]),b=d(b,O,U,E,c,21,a[55]),E=d(E,b,O,U,w,6,a[56]),U=d(U,E,b,O,A,10,a[57]),O=d(O,U,E,b,y,15,a[58]),b=d(b,O,U,E,P,21,a[59]),E=d(E,b,O,U,g,6,a[60]),U=d(U,E,b,O,k,10,a[61]),O=d(O,U,E,b,f,15,a[62]),b=d(b,O,U,E,v,21,a[63]),o[0]=o[0]+E|0,o[1]=o[1]+b|0,o[2]=o[2]+O|0,o[3]=o[3]+U|0},_doFinalize:function(){var t=this._data,n=t.words,s=8*this._nDataBytes,r=8*t.sigBytes;n[r>>>5]|=128<<24-r%32;var o=e.floor(s/4294967296),i=s;n[15+(r+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),n[14+(r+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var h=c[u];c[u]=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8)}return a},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,s,r,o,i){var a=e+(t&n|~t&s)+r+i;return(a<<o|a>>>32-o)+t}function h(e,t,n,s,r,o,i){var a=e+(t&s|n&~s)+r+i;return(a<<o|a>>>32-o)+t}function l(e,t,n,s,r,o,i){var a=e+(t^n^s)+r+i;return(a<<o|a>>>32-o)+t}function d(e,t,n,s,r,o,i){var a=e+(n^(t|~s))+r+i;return(a<<o|a>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),n.MD5)})),n((function(e,t){var n,r,o;e.exports=(r=(n=s).lib.Base,o=n.enc.Utf8,void(n.algo.HMAC=r.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=o.parse(t));var n=e.blockSize,s=4*n;t.sigBytes>s&&(t=e.finalize(t)),t.clamp();for(var r=this._oKey=t.clone(),i=this._iKey=t.clone(),a=r.words,c=i.words,u=0;u<n;u++)a[u]^=1549556828,c[u]^=909522486;r.sigBytes=i.sigBytes=s,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,n=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(n))}})))})),n((function(e,t){e.exports=s.HmacMD5})));function o(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function i(e){return"object"===o(e)}class a extends Error{constructor(e,t){super(e),this.code=t}}function c(e){return e&&"string"==typeof e?JSON.parse(e):e}const u="development"===process.env.NODE_ENV,h=process.env.VUE_APP_PLATFORM,l=c(process.env.UNICLOUD_DEBUG),d=c(process.env.UNI_CLOUD_PROVIDER),f=process.env.RUN_BY_HBUILDERX;let p="";try{{const e=require("uni-stat-config").default||require("uni-stat-config");p=e.appid}}catch(e){}let g={};function m(e,t={}){var n,s;return n=g,s=e,Object.prototype.hasOwnProperty.call(n,s)||(g[e]=t),g[e]}"app-plus"===h&&(g=uni._globalUniCloudObj?uni._globalUniCloudObj:uni._globalUniCloudObj={});const y=["invoke","success","fail","complete"],_=m("_globalUniCloudInterceptor");function w(e,t){_[e]||(_[e]={}),i(t)&&Object.keys(t).forEach((n=>{y.indexOf(n)>-1&&function(e,t,n){let s=_[e][t];s||(s=_[e][t]=[]),-1===s.indexOf(n)&&"function"==typeof n&&s.push(n)}(e,n,t[n])}))}function v(e,t){_[e]||(_[e]={}),i(t)?Object.keys(t).forEach((n=>{y.indexOf(n)>-1&&function(e,t,n){const s=_[e][t];if(!s)return;const r=s.indexOf(n);r>-1&&s.splice(r,1)}(e,n,t[n])})):delete _[e]}function S(e,t){return e&&0!==e.length?e.reduce(((e,n)=>e.then((()=>n(t)))),Promise.resolve()):Promise.resolve()}function k(e,t){return _[e]&&_[e][t]||[]}function T(e,t){return t?function(n){const s="callFunction"===t&&"DCloud-clientDB"===(n&&n.name);let r;r=this.isReady?Promise.resolve():this.initUniCloud,n=n||{};const o=r.then((()=>s?Promise.resolve():S(k(t,"invoke"),n))).then((()=>e.call(this,n))).then((e=>s?Promise.resolve(e):S(k(t,"success"),e).then((()=>S(k(t,"complete"),e))).then((()=>Promise.resolve(e)))),(e=>s?Promise.reject(e):S(k(t,"fail"),e).then((()=>S(k(t,"complete"),e))).then((()=>Promise.reject(e)))));if(!(n.success||n.fail||n.complete))return o;o.then((e=>{n.success&&n.success(e),n.complete&&n.complete(e)})).catch((e=>{n.fail&&n.fail(e),n.complete&&n.complete(e)}))}:function(t){if(!((t=t||{}).success||t.fail||t.complete))return e.call(this,t);e.call(this,t).then((e=>{t.success&&t.success(e),t.complete&&t.complete(e)}),(e=>{t.fail&&t.fail(e),t.complete&&t.complete(e)}))}}class P extends Error{constructor(e){super(e.message),this.errMsg=e.message||"",Object.defineProperties(this,{code:{get:()=>e.code},requestId:{get:()=>e.requestId},message:{get(){return this.errMsg},set(e){this.errMsg=e}}})}}const{t:I,setLocale:A,getLocale:E}=e({"zh-Hans":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},"zh-Hant":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},en:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"},fr:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"},es:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"}},"zh-Hans");let b,O;function U(e=8){let t="";for(;t.length<e;)t+=Math.random().toString(32).substring(2);return t.substring(0,e)}function C(){const{deviceId:e}=uni.getSystemInfoSync();return{PLATFORM:h,OS:O,APPID:p,LOCALE:E(),DEVICEID:e,CLIENT_SDK_VERSION:"1.0.9"}}function D(){if("n"===x()){try{b=plus.runtime.getDCloudId()}catch(e){b=""}return b}return b||(b=U(32),uni.setStorage({key:"__DC_CLOUD_UUID",data:b})),b}function x(){return{"app-plus":"n",h5:"h5","mp-weixin":"wx",[["y","a","p","mp-ali"].reverse().join("")]:"ali","mp-baidu":"bd","mp-toutiao":"tt","mp-qq":"qq","quickapp-native":"qn"}[h]}var R={sign:function(e,t){let n="";return Object.keys(e).sort().forEach((function(t){e[t]&&(n=n+"&"+t+"="+e[t])})),n=n.slice(1),r(n,t).toString()},wrappedRequest:function(e,t){return new Promise(((n,s)=>{t(Object.assign(e,{complete(e){e||(e={}),u&&"h5"===h&&e.errMsg&&0===e.errMsg.indexOf("request:fail")&&console.warn("发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5");const t=e.data&&e.data.header&&e.data.header["x-serverless-request-id"]||e.header&&e.header["request-id"];if(!e.statusCode||e.statusCode>=400)return s(new P({code:"SYS_ERR",message:e.errMsg||"request:fail",requestId:t}));const r=e.data;if(r.error)return s(new P({code:r.error.code,message:r.error.message,requestId:t}));r.result=r.data,r.requestId=t,delete r.data,n(r)}}))}))}};const q={request:e=>uni.request(e),uploadFile:e=>uni.uploadFile(e),setStorageSync:(e,t)=>uni.setStorageSync(e,t),getStorageSync:e=>uni.getStorageSync(e),removeStorageSync:e=>uni.removeStorageSync(e),clearStorageSync:()=>uni.clearStorageSync()};class F{constructor(e){["spaceId","clientSecret"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(I("uniCloud.init.paramRequired",{param:t}))})),this.config=Object.assign({},{endpoint:"https://api.bspapp.com"},e),this.config.provider="aliyun",this.config.requestUrl=this.config.endpoint+"/client",this.config.envType=this.config.envType||"public",this.config.accessTokenKey="access_token_"+this.config.spaceId,this.adapter=q,this._getAccessTokenPromise=null,this._getAccessTokenPromiseStatus=null}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){return R.wrappedRequest(e,this.adapter.request)}requestAuth(e){return this.requestWrapped(e)}request(e,t){return Promise.resolve().then((()=>this.hasAccessToken?t?this.requestWrapped(e):this.requestWrapped(e).catch((t=>new Promise(((e,n)=>{!t||"GATEWAY_INVALID_TOKEN"!==t.code&&"InvalidParameter.InvalidToken"!==t.code?n(t):e()})).then((()=>this.getAccessToken())).then((()=>{const t=this.rebuildRequest(e);return this.request(t,!0)})))):this.getAccessToken().then((()=>{const t=this.rebuildRequest(e);return this.request(t,!0)}))))}rebuildRequest(e){const t=Object.assign({},e);return t.data.token=this.accessToken,t.header["x-basement-token"]=this.accessToken,t.header["x-serverless-sign"]=R.sign(t.data,this.config.clientSecret),t}setupRequest(e,t){const n=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};return"auth"!==t&&(n.token=this.accessToken,s["x-basement-token"]=this.accessToken),s["x-serverless-sign"]=R.sign(n,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:s}}getAccessToken(){if("pending"===this._getAccessTokenPromiseStatus)return this._getAccessTokenPromise;this._getAccessTokenPromiseStatus="pending";return this._getAccessTokenPromise=this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then((e=>new Promise(((t,n)=>{e.result&&e.result.accessToken?(this.setAccessToken(e.result.accessToken),this._getAccessTokenPromiseStatus="fulfilled",t(this.accessToken)):(this._getAccessTokenPromiseStatus="rejected",n(new P({code:"AUTH_FAILED",message:"获取accessToken失败"})))}))),(e=>(this._getAccessTokenPromiseStatus="rejected",Promise.reject(e)))),this._getAccessTokenPromise}authorize(){this.getAccessToken()}callFunction(e){const t={method:"serverless.function.runtime.invoke",params:JSON.stringify({functionTarget:e.name,functionArgs:e.data||{}})};return this.request(this.setupRequest(t))}getOSSUploadOptionsFromPath(e){const t={method:"serverless.file.resource.generateProximalSign",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFileToOSS({url:e,formData:t,name:n,filePath:s,fileType:r,onUploadProgress:o}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:r,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?i(e):a(new P({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new P({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof o&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{o({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}reportOSSUpload(e){const t={method:"serverless.file.resource.report",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s,config:r}){if("string"!==o(t))throw new P({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new P({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new P({code:"INVALID_PARAM",message:"cloudPath不合法"});const i=r&&r.envType||this.config.envType;let a,c;return this.getOSSUploadOptionsFromPath({env:i,filename:t}).then((t=>{const r=t.result;a=r.id,c="https://"+r.cdnDomain+"/"+r.ossPath;const o={url:"https://"+r.host,formData:{"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:r.accessKeyId,Signature:r.signature,host:r.host,id:a,key:r.ossPath,policy:r.policy,success_action_status:200},fileName:"file",name:"file",filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},o,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({id:a}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:c}):s(new P({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({id:e[0]})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){return new Promise(((t,n)=>{Array.isArray(e)&&0!==e.length||n(new P({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"})),t({fileList:e.map((e=>({fileID:e,tempFileURL:e})))})}))}}const L={init(e){const t=new F(e),n={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}},N="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";var M;!function(e){e.local="local",e.none="none",e.session="session"}(M||(M={}));var $=function(){};const j=()=>{let e;if(!Promise){e=()=>{},e.promise={};const t=()=>{throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}const t=new Promise(((t,n)=>{e=(e,s)=>e?n(e):t(s)}));return e.promise=t,e};function K(e){return void 0===e}function B(e){return"[object Null]"===Object.prototype.toString.call(e)}var H;function W(e){const t=(n=e,"[object Array]"===Object.prototype.toString.call(n)?e:[e]);var n;for(const e of t){const{isMatch:t,genAdapter:n,runtime:s}=e;if(t())return{adapter:n(),runtime:s}}}!function(e){e.WEB="web",e.WX_MP="wx_mp"}(H||(H={}));const z={adapter:null,runtime:void 0},V=["anonymousUuidKey"];class J extends ${constructor(){super(),z.adapter.root.tcbObject||(z.adapter.root.tcbObject={})}setItem(e,t){z.adapter.root.tcbObject[e]=t}getItem(e){return z.adapter.root.tcbObject[e]}removeItem(e){delete z.adapter.root.tcbObject[e]}clear(){delete z.adapter.root.tcbObject}}function Y(e,t){switch(e){case"local":return t.localStorage||new J;case"none":return new J;default:return t.sessionStorage||new J}}class X{constructor(e){if(!this._storage){this._persistence=z.adapter.primaryStorage||e.persistence,this._storage=Y(this._persistence,z.adapter);const t=`access_token_${e.env}`,n=`access_token_expire_${e.env}`,s=`refresh_token_${e.env}`,r=`anonymous_uuid_${e.env}`,o=`login_type_${e.env}`,i=`user_info_${e.env}`;this.keys={accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s,anonymousUuidKey:r,loginTypeKey:o,userInfoKey:i}}}updatePersistence(e){if(e===this._persistence)return;const t="local"===this._persistence;this._persistence=e;const n=Y(e,z.adapter);for(const e in this.keys){const s=this.keys[e];if(t&&V.includes(e))continue;const r=this._storage.getItem(s);K(r)||B(r)||(n.setItem(s,r),this._storage.removeItem(s))}this._storage=n}setStore(e,t,n){if(!this._storage)return;const s={version:n||"localCachev1",content:t},r=JSON.stringify(s);try{this._storage.setItem(e,r)}catch(e){throw e}}getStore(e,t){try{if(!this._storage)return}catch(e){return""}t=t||"localCachev1";const n=this._storage.getItem(e);if(!n)return"";if(n.indexOf(t)>=0){return JSON.parse(n).content}return""}removeStore(e){this._storage.removeItem(e)}}const G={},Q={};function Z(e){return G[e]}class ee{constructor(e,t){this.data=t||null,this.name=e}}class te extends ee{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}const ne=new class{constructor(){this._listeners={}}on(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this._listeners),this}off(e,t){return function(e,t,n){if(n&&n[e]){const s=n[e].indexOf(t);-1!==s&&n[e].splice(s,1)}}(e,t,this._listeners),this}fire(e,t){if(e instanceof te)return console.error(e.error),this;const n="string"==typeof e?new ee(e,t||{}):e;const s=n.name;if(this._listens(s)){n.target=this;const e=this._listeners[s]?[...this._listeners[s]]:[];for(const t of e)t.call(this,n)}return this}_listens(e){return this._listeners[e]&&this._listeners[e].length>0}};function se(e,t){ne.on(e,t)}function re(e,t={}){ne.fire(e,t)}function oe(e,t){ne.off(e,t)}const ie="loginStateChanged",ae="loginStateExpire",ce="loginTypeChanged",ue="anonymousConverted",he="refreshAccessToken";var le;!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.WECHAT_PUBLIC="WECHAT-PUBLIC",e.WECHAT_OPEN="WECHAT-OPEN",e.CUSTOM="CUSTOM",e.EMAIL="EMAIL",e.USERNAME="USERNAME",e.NULL="NULL"}(le||(le={}));const de=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],fe={"X-SDK-Version":"1.3.5"};function pe(e,t,n){const s=e[t];e[t]=function(t){const r={},o={};n.forEach((n=>{const{data:s,headers:i}=n.call(e,t);Object.assign(r,s),Object.assign(o,i)}));const i=t.data;return i&&(()=>{var e;if(e=i,"[object FormData]"!==Object.prototype.toString.call(e))t.data={...i,...r};else for(const e in r)i.append(e,r[e])})(),t.headers={...t.headers||{},...o},s.call(e,t)}}function ge(){const e=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...fe,"x-seqid":e}}}class me{constructor(e={}){var t;this.config=e,this._reqClass=new z.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]}),this._cache=Z(this.config.env),this._localCache=(t=this.config.env,Q[t]),pe(this._reqClass,"post",[ge]),pe(this._reqClass,"upload",[ge]),pe(this._reqClass,"download",[ge])}async post(e){return await this._reqClass.post(e)}async upload(e){return await this._reqClass.upload(e)}async download(e){return await this._reqClass.download(e)}async refreshAccessToken(){let e,t;this._refreshAccessTokenPromise||(this._refreshAccessTokenPromise=this._refreshAccessToken());try{e=await this._refreshAccessTokenPromise}catch(e){t=e}if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return e}async _refreshAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n,loginTypeKey:s,anonymousUuidKey:r}=this._cache.keys;this._cache.removeStore(e),this._cache.removeStore(t);let o=this._cache.getStore(n);if(!o)throw new Error("未登录CloudBase");const i={refresh_token:o},a=await this.request("auth.fetchAccessTokenWithRefreshToken",i);if(a.data.code){const{code:e}=a.data;if("SIGN_PARAM_INVALID"===e||"REFRESH_TOKEN_EXPIRED"===e||"INVALID_REFRESH_TOKEN"===e){if(this._cache.getStore(s)===le.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===e){const e=this._cache.getStore(r),t=this._cache.getStore(n),s=await this.send("auth.signInAnonymously",{anonymous_uuid:e,refresh_token:t});return this.setRefreshToken(s.refresh_token),this._refreshAccessToken()}re(ae),this._cache.removeStore(n)}throw new Error(`刷新access token失败:${a.data.code}`)}if(a.data.access_token)return re(he),this._cache.setStore(e,a.data.access_token),this._cache.setStore(t,a.data.access_token_expire+Date.now()),{accessToken:a.data.access_token,accessTokenExpire:a.data.access_token_expire};a.data.refresh_token&&(this._cache.removeStore(n),this._cache.setStore(n,a.data.refresh_token),this._refreshAccessToken())}async getAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:n}=this._cache.keys;if(!this._cache.getStore(n))throw new Error("refresh token不存在,登录状态异常");let s=this._cache.getStore(e),r=this._cache.getStore(t),o=!0;return this._shouldRefreshAccessTokenHook&&!await this._shouldRefreshAccessTokenHook(s,r)&&(o=!1),(!s||!r||r<Date.now())&&o?this.refreshAccessToken():{accessToken:s,accessTokenExpire:r}}async request(e,t,n){const s=`x-tcb-trace_${this.config.env}`;let r="application/x-www-form-urlencoded";const o={action:e,env:this.config.env,dataVersion:"2019-08-16",...t};if(-1===de.indexOf(e)){const{refreshTokenKey:e}=this._cache.keys;this._cache.getStore(e)&&(o.access_token=(await this.getAccessToken()).accessToken)}let i;if("storage.uploadFile"===e){i=new FormData;for(let e in i)i.hasOwnProperty(e)&&void 0!==i[e]&&i.append(e,o[e]);r="multipart/form-data"}else{r="application/json;charset=UTF-8",i={};for(let e in o)void 0!==o[e]&&(i[e]=o[e])}let a={headers:{"content-type":r}};n&&n.onUploadProgress&&(a.onUploadProgress=n.onUploadProgress);const c=this._localCache.getStore(s);c&&(a.headers["X-TCB-Trace"]=c);const{parse:u,inQuery:h,search:l}=t;let d={env:this.config.env};u&&(d.parse=!0),h&&(d={...h,...d});let f=function(e,t,n={}){const s=/\?/.test(t);let r="";for(let e in n)""===r?!s&&(t+="?"):r+="&",r+=`${e}=${encodeURIComponent(n[e])}`;return/^http(s)?\:\/\//.test(t+=r)?t:`${e}${t}`}(N,"//tcb-api.tencentcloudapi.com/web",d);l&&(f+=l);const p=await this.post({url:f,data:i,...a}),g=p.header&&p.header["x-tcb-trace"];if(g&&this._localCache.setStore(s,g),200!==Number(p.status)&&200!==Number(p.statusCode)||!p.data)throw new Error("network request error");return p}async send(e,t={}){const n=await this.request(e,t,{onUploadProgress:t.onUploadProgress});if("ACCESS_TOKEN_EXPIRED"===n.data.code&&-1===de.indexOf(e)){await this.refreshAccessToken();const n=await this.request(e,t,{onUploadProgress:t.onUploadProgress});if(n.data.code)throw new Error(`[${n.data.code}] ${n.data.message}`);return n.data}if(n.data.code)throw new Error(`[${n.data.code}] ${n.data.message}`);return n.data}setRefreshToken(e){const{accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s}=this._cache.keys;this._cache.removeStore(t),this._cache.removeStore(n),this._cache.setStore(s,e)}}const ye={};function _e(e){return ye[e]}class we{constructor(e){this.config=e,this._cache=Z(e.env),this._request=_e(e.env)}setRefreshToken(e){const{accessTokenKey:t,accessTokenExpireKey:n,refreshTokenKey:s}=this._cache.keys;this._cache.removeStore(t),this._cache.removeStore(n),this._cache.setStore(s,e)}setAccessToken(e,t){const{accessTokenKey:n,accessTokenExpireKey:s}=this._cache.keys;this._cache.setStore(n,e),this._cache.setStore(s,t)}async refreshUserInfo(){const{data:e}=await this._request.send("auth.getUserInfo",{});return this.setLocalUserInfo(e),e}setLocalUserInfo(e){const{userInfoKey:t}=this._cache.keys;this._cache.setStore(t,e)}}class ve{constructor(e){if(!e)throw new Error("envId is not defined");this._envId=e,this._cache=Z(this._envId),this._request=_e(this._envId),this.setUserInfo()}linkWithTicket(e){if("string"!=typeof e)throw new Error("ticket must be string");return this._request.send("auth.linkWithTicket",{ticket:e})}linkWithRedirect(e){e.signInWithRedirect()}updatePassword(e,t){return this._request.send("auth.updatePassword",{oldPassword:t,newPassword:e})}updateEmail(e){return this._request.send("auth.updateEmail",{newEmail:e})}updateUsername(e){if("string"!=typeof e)throw new Error("username must be a string");return this._request.send("auth.updateUsername",{username:e})}async getLinkedUidList(){const{data:e}=await this._request.send("auth.getLinkedUidList",{});let t=!1;const{users:n}=e;return n.forEach((e=>{e.wxOpenId&&e.wxPublicId&&(t=!0)})),{users:n,hasPrimaryUid:t}}setPrimaryUid(e){return this._request.send("auth.setPrimaryUid",{uid:e})}unlink(e){return this._request.send("auth.unlink",{platform:e})}async update(e){const{nickName:t,gender:n,avatarUrl:s,province:r,country:o,city:i}=e,{data:a}=await this._request.send("auth.updateUserInfo",{nickName:t,gender:n,avatarUrl:s,province:r,country:o,city:i});this.setLocalUserInfo(a)}async refresh(){const{data:e}=await this._request.send("auth.getUserInfo",{});return this.setLocalUserInfo(e),e}setUserInfo(){const{userInfoKey:e}=this._cache.keys,t=this._cache.getStore(e);["uid","loginType","openid","wxOpenId","wxPublicId","unionId","qqMiniOpenId","email","hasPassword","customUserId","nickName","gender","avatarUrl"].forEach((e=>{this[e]=t[e]})),this.location={country:t.country,province:t.province,city:t.city}}setLocalUserInfo(e){const{userInfoKey:t}=this._cache.keys;this._cache.setStore(t,e),this.setUserInfo()}}class Se{constructor(e){if(!e)throw new Error("envId is not defined");this._cache=Z(e);const{refreshTokenKey:t,accessTokenKey:n,accessTokenExpireKey:s}=this._cache.keys,r=this._cache.getStore(t),o=this._cache.getStore(n),i=this._cache.getStore(s);this.credential={refreshToken:r,accessToken:o,accessTokenExpire:i},this.user=new ve(e)}get isAnonymousAuth(){return this.loginType===le.ANONYMOUS}get isCustomAuth(){return this.loginType===le.CUSTOM}get isWeixinAuth(){return this.loginType===le.WECHAT||this.loginType===le.WECHAT_OPEN||this.loginType===le.WECHAT_PUBLIC}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}}class ke extends we{async signIn(){this._cache.updatePersistence("local");const{anonymousUuidKey:e,refreshTokenKey:t}=this._cache.keys,n=this._cache.getStore(e)||void 0,s=this._cache.getStore(t)||void 0,r=await this._request.send("auth.signInAnonymously",{anonymous_uuid:n,refresh_token:s});if(r.uuid&&r.refresh_token){this._setAnonymousUUID(r.uuid),this.setRefreshToken(r.refresh_token),await this._request.refreshAccessToken(),re(ie),re(ce,{env:this.config.env,loginType:le.ANONYMOUS,persistence:"local"});const e=new Se(this.config.env);return await e.user.refresh(),e}throw new Error("匿名登录失败")}async linkAndRetrieveDataWithTicket(e){const{anonymousUuidKey:t,refreshTokenKey:n}=this._cache.keys,s=this._cache.getStore(t),r=this._cache.getStore(n),o=await this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:s,refresh_token:r,ticket:e});if(o.refresh_token)return this._clearAnonymousUUID(),this.setRefreshToken(o.refresh_token),await this._request.refreshAccessToken(),re(ue,{env:this.config.env}),re(ce,{loginType:le.CUSTOM,persistence:"local"}),{credential:{refreshToken:o.refresh_token}};throw new Error("匿名转化失败")}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(n,le.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}class Te extends we{async signIn(e){if("string"!=typeof e)throw new Error("ticket must be a string");const{refreshTokenKey:t}=this._cache.keys,n=await this._request.send("auth.signInWithTicket",{ticket:e,refresh_token:this._cache.getStore(t)||""});if(n.refresh_token)return this.setRefreshToken(n.refresh_token),await this._request.refreshAccessToken(),re(ie),re(ce,{env:this.config.env,loginType:le.CUSTOM,persistence:this.config.persistence}),await this.refreshUserInfo(),new Se(this.config.env);throw new Error("自定义登录失败")}}class Pe extends we{async signIn(e,t){if("string"!=typeof e)throw new Error("email must be a string");const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:"EMAIL",email:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:r,access_token:o,access_token_expire:i}=s;if(r)return this.setRefreshToken(r),o&&i?this.setAccessToken(o,i):await this._request.refreshAccessToken(),await this.refreshUserInfo(),re(ie),re(ce,{env:this.config.env,loginType:le.EMAIL,persistence:this.config.persistence}),new Se(this.config.env);throw s.code?new Error(`邮箱登录失败: [${s.code}] ${s.message}`):new Error("邮箱登录失败")}async activate(e){return this._request.send("auth.activateEndUserMail",{token:e})}async resetPasswordWithToken(e,t){return this._request.send("auth.resetPasswordWithToken",{token:e,newPassword:t})}}class Ie extends we{async signIn(e,t){if("string"!=typeof e)throw new Error("username must be a string");"string"!=typeof t&&(t="",console.warn("password is empty"));const{refreshTokenKey:n}=this._cache.keys,s=await this._request.send("auth.signIn",{loginType:le.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(n)||""}),{refresh_token:r,access_token_expire:o,access_token:i}=s;if(r)return this.setRefreshToken(r),i&&o?this.setAccessToken(i,o):await this._request.refreshAccessToken(),await this.refreshUserInfo(),re(ie),re(ce,{env:this.config.env,loginType:le.USERNAME,persistence:this.config.persistence}),new Se(this.config.env);throw s.code?new Error(`用户名密码登录失败: [${s.code}] ${s.message}`):new Error("用户名密码登录失败")}}class Ae{constructor(e){this.config=e,this._cache=Z(e.env),this._request=_e(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),se(ce,this._onLoginTypeChanged)}get currentUser(){const e=this.hasLoginState();return e&&e.user||null}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}anonymousAuthProvider(){return new ke(this.config)}customAuthProvider(){return new Te(this.config)}emailAuthProvider(){return new Pe(this.config)}usernameAuthProvider(){return new Ie(this.config)}async signInAnonymously(){return new ke(this.config).signIn()}async signInWithEmailAndPassword(e,t){return new Pe(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){return new Ie(this.config).signIn(e,t)}async linkAndRetrieveDataWithTicket(e){this._anonymousAuthProvider||(this._anonymousAuthProvider=new ke(this.config)),se(ue,this._onAnonymousConverted);return await this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}async signOut(){if(this.loginType===le.ANONYMOUS)throw new Error("匿名用户不支持登出操作");const{refreshTokenKey:e,accessTokenKey:t,accessTokenExpireKey:n}=this._cache.keys,s=this._cache.getStore(e);if(!s)return;const r=await this._request.send("auth.logout",{refresh_token:s});return this._cache.removeStore(e),this._cache.removeStore(t),this._cache.removeStore(n),re(ie),re(ce,{env:this.config.env,loginType:le.NULL,persistence:this.config.persistence}),r}async signUpWithEmailAndPassword(e,t){return this._request.send("auth.signUpWithEmailAndPassword",{email:e,password:t})}async sendPasswordResetEmail(e){return this._request.send("auth.sendPasswordResetEmail",{email:e})}onLoginStateChanged(e){se(ie,(()=>{const t=this.hasLoginState();e.call(this,t)}));const t=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){se(ae,e.bind(this))}onAccessTokenRefreshed(e){se(he,e.bind(this))}onAnonymousConverted(e){se(ue,e.bind(this))}onLoginTypeChanged(e){se(ce,(()=>{const t=this.hasLoginState();e.call(this,t)}))}async getAccessToken(){return{accessToken:(await this._request.getAccessToken()).accessToken,env:this.config.env}}hasLoginState(){const{refreshTokenKey:e}=this._cache.keys;return this._cache.getStore(e)?new Se(this.config.env):null}async isUsernameRegistered(e){if("string"!=typeof e)throw new Error("username must be a string");const{data:t}=await this._request.send("auth.isUsernameRegistered",{username:e});return t&&t.isRegistered}getLoginState(){return Promise.resolve(this.hasLoginState())}async signInWithTicket(e){return new Te(this.config).signIn(e)}shouldRefreshAccessToken(e){this._request._shouldRefreshAccessTokenHook=e.bind(this)}getUserInfo(){return this._request.send("auth.getUserInfo",{}).then((e=>e.code?e:{...e.data,requestId:e.seqId}))}getAuthHeader(){const{refreshTokenKey:e,accessTokenKey:t}=this._cache.keys,n=this._cache.getStore(e);return{"x-cloudbase-credentials":this._cache.getStore(t)+"/@@/"+n}}_onAnonymousConverted(e){const{env:t}=e.data;t===this.config.env&&this._cache.updatePersistence(this.config.persistence)}_onLoginTypeChanged(e){const{loginType:t,persistence:n,env:s}=e.data;s===this.config.env&&(this._cache.updatePersistence(n),this._cache.setStore(this._cache.keys.loginTypeKey,t))}}const Ee=function(e,t){t=t||j();const n=_e(this.config.env),{cloudPath:s,filePath:r,onUploadProgress:o,fileType:i="image"}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{const{data:{url:a,authorization:c,token:u,fileId:h,cosFileId:l},requestId:d}=e,f={key:s,signature:c,"x-cos-meta-fileid":l,success_action_status:"201","x-cos-security-token":u};n.upload({url:a,data:f,file:r,name:s,fileType:i,onUploadProgress:o}).then((e=>{201===e.statusCode?t(null,{fileID:h,requestId:d}):t(new Error(`STORAGE_REQUEST_FAIL: ${e.data}`))})).catch((e=>{t(e)}))})).catch((e=>{t(e)})),t.promise},be=function(e,t){t=t||j();const n=_e(this.config.env),{cloudPath:s}=e;return n.send("storage.getUploadMetadata",{path:s}).then((e=>{t(null,e)})).catch((e=>{t(e)})),t.promise},Oe=function({fileList:e},t){if(t=t||j(),!e||!Array.isArray(e))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(let t of e)if(!t||"string"!=typeof t)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"};const n={fileid_list:e};return _e(this.config.env).send("storage.batchDeleteFile",n).then((e=>{e.code?t(null,e):t(null,{fileList:e.data.delete_list,requestId:e.requestId})})).catch((e=>{t(e)})),t.promise},Ue=function({fileList:e},t){t=t||j(),e&&Array.isArray(e)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});let n=[];for(let s of e)"object"==typeof s?(s.hasOwnProperty("fileID")&&s.hasOwnProperty("maxAge")||t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是包含fileID和maxAge的对象"}),n.push({fileid:s.fileID,max_age:s.maxAge})):"string"==typeof s?n.push({fileid:s}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"});const s={file_list:n};return _e(this.config.env).send("storage.batchGetDownloadUrl",s).then((e=>{e.code?t(null,e):t(null,{fileList:e.data.download_list,requestId:e.requestId})})).catch((e=>{t(e)})),t.promise},Ce=async function({fileID:e},t){const n=(await Ue.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==n.code)return t?t(n):new Promise((e=>{e(n)}));const s=_e(this.config.env);let r=n.download_url;if(r=encodeURI(r),!t)return s.download({url:r});t(await s.download({url:r}))},De=function({name:e,data:t,query:n,parse:s,search:r},o){const i=o||j();let a;try{a=t?JSON.stringify(t):""}catch(e){return Promise.reject(e)}if(!e)return Promise.reject(new Error("函数名不能为空"));const c={inQuery:n,parse:s,search:r,function_name:e,request_data:a};return _e(this.config.env).send("functions.invokeFunction",c).then((e=>{if(e.code)i(null,e);else{let t=e.data.response_data;if(s)i(null,{result:t,requestId:e.requestId});else try{t=JSON.parse(e.data.response_data),i(null,{result:t,requestId:e.requestId})}catch(e){i(new Error("response data must be json"))}}return i.promise})).catch((e=>{i(e)})),i.promise},xe={timeout:15e3,persistence:"session"},Re={};class qe{constructor(e){this.config=e||this.config,this.authObj=void 0}init(e){switch(z.adapter||(this.requestClient=new z.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成,已中断`})),this.config={...xe,...e},!0){case this.config.timeout>6e5:console.warn("timeout大于可配置上限[10分钟],已重置为上限数值"),this.config.timeout=6e5;break;case this.config.timeout<100:console.warn("timeout小于可配置下限[100ms],已重置为下限数值"),this.config.timeout=100}return new qe(this.config)}auth({persistence:e}={}){if(this.authObj)return this.authObj;const t=e||z.adapter.primaryStorage||xe.persistence;var n;return t!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;G[t]=new X(e),Q[t]=new X({...e,persistence:"local"})}(this.config),n=this.config,ye[n.env]=new me(n),this.authObj=new Ae(this.config),this.authObj}on(e,t){return se.apply(this,[e,t])}off(e,t){return oe.apply(this,[e,t])}callFunction(e,t){return De.apply(this,[e,t])}deleteFile(e,t){return Oe.apply(this,[e,t])}getTempFileURL(e,t){return Ue.apply(this,[e,t])}downloadFile(e,t){return Ce.apply(this,[e,t])}uploadFile(e,t){return Ee.apply(this,[e,t])}getUploadMetadata(e,t){return be.apply(this,[e,t])}registerExtension(e){Re[e.name]=e}async invokeExtension(e,t){const n=Re[e];if(!n)throw Error(`扩展${e} 必须先注册`);return await n.invoke(t,this)}useAdapters(e){const{adapter:t,runtime:n}=W(e)||{};t&&(z.adapter=t),n&&(z.runtime=n)}}const Fe=new qe;function Le(e,t,n){void 0===n&&(n={});var s=/\?/.test(t),r="";for(var o in n)""===r?!s&&(t+="?"):r+="&",r+=o+"="+encodeURIComponent(n[o]);return/^http(s)?:\/\//.test(t+=r)?t:""+e+t}class Ne{post(e){const{url:t,data:n,headers:s}=e;return new Promise(((e,r)=>{q.request({url:Le("https:",t),data:n,method:"POST",header:s,success(t){e(t)},fail(e){r(e)}})}))}upload(e){return new Promise(((t,n)=>{const{url:s,file:r,data:o,headers:i,fileType:a}=e,c=q.uploadFile({url:Le("https:",s),name:"file",formData:Object.assign({},o),filePath:r,fileType:a,header:i,success(e){const n={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&o.success_action_status&&(n.statusCode=parseInt(o.success_action_status,10)),t(n)},fail(e){u&&"mp-alipay"===h&&console.warn("支付宝小程序开发工具上传腾讯云时无法准确判断是否上传成功,请使用真机测试"),n(new Error(e.errMsg||"uploadFile:fail"))}});"function"==typeof e.onUploadProgress&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((t=>{e.onUploadProgress({loaded:t.totalBytesSent,total:t.totalBytesExpectedToSend})}))}))}}const Me={setItem(e,t){q.setStorageSync(e,t)},getItem:e=>q.getStorageSync(e),removeItem(e){q.removeStorageSync(e)},clear(){q.clearStorageSync()}};const $e={genAdapter:function(){return{root:{},reqClass:Ne,localStorage:Me,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};Fe.useAdapters($e);const je=Fe,Ke=je.init;je.init=function(e){e.env=e.spaceId;const t=Ke.call(this,e);t.config.provider="tencent",t.config.spaceId=e.spaceId;const n=t.auth;return t.auth=function(e){const t=n.call(this,e);return["linkAndRetrieveDataWithTicket","signInAnonymously","signOut","getAccessToken","getLoginState","signInWithTicket","getUserInfo"].forEach((e=>{t[e]=T(t[e]).bind(t)})),t},t.customAuth=t.auth,t};class Be extends F{getAccessToken(){return new Promise(((e,t)=>{const n="Anonymous_Access_token";this.setAccessToken(n),e(n)}))}setupRequest(e,t){const n=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),s={"Content-Type":"application/json"};"auth"!==t&&(n.token=this.accessToken,s["x-basement-token"]=this.accessToken),s["x-serverless-sign"]=R.sign(n,this.config.clientSecret);const r=C(),{APPID:o,PLATFORM:i,DEVICEID:a,CLIENT_SDK_VERSION:c}=r;return s["x-client-platform"]=i,s["x-client-appid"]=o,s["x-client-device-id"]=a,s["x-client-version"]=c,s["x-client-token"]=q.getStorageSync("uni_id_token"),{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:JSON.parse(JSON.stringify(s))}}uploadFileToOSS({url:e,formData:t,name:n,filePath:s,fileType:r,onUploadProgress:o}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:n,filePath:s,fileType:r,success(e){e&&e.statusCode<400?i(e):a(new P({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new P({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof o&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{o({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}uploadFile({filePath:e,cloudPath:t,fileType:n="image",onUploadProgress:s}){if(!t)throw new P({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});let r;return this.getOSSUploadOptionsFromPath({cloudPath:t}).then((t=>{const{url:o,formData:i,name:a,fileUrl:c}=t.result;r=c;const u={url:o,formData:i,name:a,filePath:e,fileType:n};return this.uploadFileToOSS(Object.assign({},u,{onUploadProgress:s}))})).then((()=>this.reportOSSUpload({cloudPath:t}))).then((t=>new Promise(((n,s)=>{t.success?n({success:!0,filePath:e,fileID:r}):s(new P({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}}const He={init(e){const t=new Be(e),n={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return n},t.customAuth=t.auth,t}};let We,ze;function Ve({name:e,data:t,spaceId:n,provider:s}){We||(We=C(),ze={ak:p,p:"android"===O?"a":"i",ut:x(),uuid:D()});const r=JSON.parse(JSON.stringify(t||{})),o=e,i=n,a={tencent:"t",aliyun:"a"}[s];{const e=Object.assign({},ze,{fn:o,sid:i,pvd:a});Object.assign(r,{clientInfo:We,uniCloudClientInfo:encodeURIComponent(JSON.stringify(e))});const{deviceId:t}=uni.getSystemInfoSync();r.uniCloudDeviceId=t}if(!r.uniIdToken){const e=q.getStorageSync("uni_id_token")||q.getStorageSync("uniIdToken");e&&(r.uniIdToken=e)}return r}function Je({name:e,data:t}){const{localAddress:n,localPort:s}=this,r={aliyun:"aliyun",tencent:"tcb"}[this.config.provider],o=this.config.spaceId,i=`http://${n}:${s}/system/check-function`,a=`http://${n}:${s}/cloudfunctions/${e}`;return new Promise(((t,n)=>{q.request({method:"POST",url:i,data:{name:e,platform:h,provider:r,spaceId:o},timeout:3e3,success(e){t(e)},fail(){t({data:{code:"NETWORK_ERROR",message:"连接本地调试服务失败,请检查客户端是否和主机在同一局域网下,自动切换为已部署的云函数。"}})}})})).then((({data:e}={})=>{const{code:t,message:n}=e||{};return{code:0===t?0:t||"SYS_ERR",message:n||"SYS_ERR"}})).then((({code:n,message:s})=>{if(0!==n){switch(n){case"MODULE_ENCRYPTED":console.error(`此云函数(${e})依赖加密公共模块不可本地调试,自动切换为云端已部署的云函数`);break;case"FUNCTION_ENCRYPTED":console.error(`此云函数(${e})已加密不可本地调试,自动切换为云端已部署的云函数`);break;case"ACTION_ENCRYPTED":console.error(s||"需要访问加密的uni-clientDB-action,自动切换为云端环境");break;case"NETWORK_ERROR":{const e="连接本地调试服务失败,请检查客户端是否和主机在同一局域网下";throw console.error(e),new Error(e)}case"SWITCH_TO_CLOUD":break;default:{const e=`检测本地调试服务出现错误:${s},请检查网络环境或重启客户端再试`;throw console.error(e),new Error(e)}}return this._originCallFunction({name:e,data:t})}return new Promise(((n,s)=>{const i=Ve({name:e,data:t,provider:this.config.provider,spaceId:o});q.request({method:"POST",url:a,data:{provider:r,platform:h,param:i},success:({statusCode:e,data:t}={})=>!e||e>=400?s(new P({code:t.code||"SYS_ERR",message:t.message||"request:fail"})):n({result:t}),fail(e){s(new P({code:e.code||e.errCode||"SYS_ERR",message:e.message||e.errMsg||"request:fail"}))}})}))}))}const Ye=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];var Xe=/[\\^$.*+?()[\]{}|]/g,Ge=RegExp(Xe.source);function Qe(e,t,n){return e.replace(new RegExp((s=t)&&Ge.test(s)?s.replace(Xe,"\\$&"):s,"g"),n);var s}function Ze({functionName:e,result:t,logPvd:n}){if(this.config.useDebugFunction&&t&&t.requestId){const s=JSON.stringify({spaceId:this.config.spaceId,functionName:e,requestId:t.requestId});console.log(`[${n}-request]${s}[/${n}-request]`)}}function et(e){const t=e.callFunction,n=function(e){const n=e.name;e.data=Ve({name:n,data:e.data,provider:this.config.provider,spaceId:this.config.spaceId});const s={aliyun:"aliyun",tencent:"tcb"}[this.config.provider];return t.call(this,e).then((e=>(Ze.call(this,{functionName:n,result:e,logPvd:s}),Promise.resolve(e))),(t=>(Ze.call(this,{functionName:n,result:t,logPvd:s}),t&&t.message&&(t.message=function({message:e="",extraInfo:t={},formatter:n=[]}={}){for(let s=0;s<n.length;s++){const{rule:r,content:o,mode:i}=n[s],a=e.match(r);if(!a)continue;let c=o;for(let e=1;e<a.length;e++)c=Qe(c,`{$${e}}`,a[e]);for(const e in t)c=Qe(c,`{${e}}`,t[e]);switch(i){case"replace":return c;case"append":default:return e+c}}return e}({message:`[${e.name}]: ${t.message}`,formatter:Ye,extraInfo:{functionName:n}})),Promise.reject(t))))};e.callFunction=function(t){let s;return u&&e.debugInfo&&!e.debugInfo.forceRemote&&d?(e._originCallFunction||(e._originCallFunction=n),s=Je.call(this,t)):s=n.call(this,t),Object.defineProperty(s,"result",{get:()=>(console.warn("当前返回结果为Promise类型,不可直接访问其result属性,详情请参考:https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),s}}const tt=Symbol("CLIENT_DB_INTERNAL");function nt(e,t){return e.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=tt,e.__ob__=void 0,new Proxy(e,{get:(e,n,s)=>n in e||"string"!=typeof n?e[n]:t.get(e,n,s)})}function st(e){switch(o(e)){case"array":return e.map((e=>st(e)));case"object":return e._internalType===tt||Object.keys(e).forEach((t=>{e[t]=st(e[t])})),e;case"regexp":return{$regexp:{source:e.source,flags:e.flags}};case"date":return{$date:e.toISOString()};default:return e}}function rt(){const e=q.getStorageSync("uni_id_token")||"",t=e.split(".");if(!e||3!==t.length)return{uid:null,role:[],permission:[],tokenExpired:0};let n;try{n=JSON.parse((s=t[1],decodeURIComponent(atob(s).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))))}catch(e){throw new Error("获取当前用户信息出错,详细错误信息为:"+e.message)}var s;return n.tokenExpired=1e3*n.exp,delete n.exp,delete n.iat,n}var ot=t(n((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const n="chooseAndUploadFile:ok",s="chooseAndUploadFile:fail";function r(e,t){return e.tempFiles.forEach(((e,n)=>{e.name||(e.name=e.path.substring(e.path.lastIndexOf("/")+1)),t&&(e.fileType=t),e.cloudPath=Date.now()+"_"+n+e.name.substring(e.name.lastIndexOf("."))})),e.tempFilePaths||(e.tempFilePaths=e.tempFiles.map((e=>e.path))),e}function o(e,t,{onChooseFile:s,onUploadProgress:r}){return t.then((e=>{if(s){const t=s(e);if(void 0!==t)return Promise.resolve(t).then((t=>void 0===t?e:t))}return e})).then((t=>!1===t?{errMsg:n,tempFilePaths:[],tempFiles:[]}:function(e,t,s=5,r){(t=Object.assign({},t)).errMsg=n;const o=t.tempFiles,i=o.length;let a=0;return new Promise((n=>{for(;a<s;)c();function c(){const s=a++;if(s>=i)return void(!o.find((e=>!e.url&&!e.errMsg))&&n(t));const u=o[s];e.uploadFile({filePath:u.path,cloudPath:u.cloudPath,fileType:u.fileType,onUploadProgress(e){e.index=s,e.tempFile=u,e.tempFilePath=u.path,r&&r(e)}}).then((e=>{u.url=e.fileID,s<i&&c()})).catch((e=>{u.errMsg=e.errMsg||e.message,s<i&&c()}))}}))}(e,t,5,r)))}t.initChooseAndUploadFile=function(e){return function(t={type:"all"}){return"image"===t.type?o(e,function(e){const{count:t,sizeType:n,sourceType:o=["album","camera"],extension:i}=e;return new Promise(((e,a)=>{uni.chooseImage({count:t,sizeType:n,sourceType:o,extension:i,success(t){e(r(t,"image"))},fail(e){a({errMsg:e.errMsg.replace("chooseImage:fail",s)})}})}))}(t),t):"video"===t.type?o(e,function(e){const{camera:t,compressed:n,maxDuration:o,sourceType:i=["album","camera"],extension:a}=e;return new Promise(((e,c)=>{uni.chooseVideo({camera:t,compressed:n,maxDuration:o,sourceType:i,extension:a,success(t){const{tempFilePath:n,duration:s,size:o,height:i,width:a}=t;e(r({errMsg:"chooseVideo:ok",tempFilePaths:[n],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:n,size:o,type:t.tempFile&&t.tempFile.type||"",width:a,height:i,duration:s,fileType:"video",cloudPath:""}]},"video"))},fail(e){c({errMsg:e.errMsg.replace("chooseVideo:fail",s)})}})}))}(t),t):o(e,function(e){const{count:t,extension:n}=e;return new Promise(((e,o)=>{let i=uni.chooseFile;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(i=wx.chooseMessageFile),"function"!=typeof i)return o({errMsg:s+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});i({type:"all",count:t,extension:n,success(t){e(r(t))},fail(e){o({errMsg:e.errMsg.replace("chooseFile:fail",s)})}})}))}(t),t)}}})));const it="manual";function at(e){return{props:{localdata:{type:Array,default:()=>[]},options:{type:[Object,Array],default:()=>({})},collection:{type:[String,Array],default:""},action:{type:String,default:""},field:{type:String,default:""},orderby:{type:String,default:""},where:{type:[String,Object],default:""},pageData:{type:String,default:"add"},pageCurrent:{type:Number,default:1},pageSize:{type:Number,default:20},getcount:{type:[Boolean,String],default:!1},gettree:{type:[Boolean,String],default:!1},gettreepath:{type:[Boolean,String],default:!1},startwith:{type:String,default:""},limitlevel:{type:Number,default:10},groupby:{type:String,default:""},groupField:{type:String,default:""},distinct:{type:[Boolean,String],default:!1},foreignKey:{type:String,default:""},loadtime:{type:String,default:"auto"},manual:{type:Boolean,default:!1}},data:()=>({mixinDatacomLoading:!1,mixinDatacomHasMore:!1,mixinDatacomResData:[],mixinDatacomErrorMessage:"",mixinDatacomPage:{}}),created(){this.mixinDatacomPage={current:this.pageCurrent,size:this.pageSize,count:0},this.$watch((()=>{var e=[];return["pageCurrent","pageSize","localdata","collection","action","field","orderby","where","getont","getcount","gettree","groupby","groupField","distinct"].forEach((t=>{e.push(this[t])})),e}),((e,t)=>{if(this.loadtime===it)return;let n=!1;const s=[];for(let r=2;r<e.length;r++)e[r]!==t[r]&&(s.push(e[r]),n=!0);e[0]!==t[0]&&(this.mixinDatacomPage.current=this.pageCurrent),this.mixinDatacomPage.size=this.pageSize,this.onMixinDatacomPropsChange(n,s)}))},methods:{onMixinDatacomPropsChange(e,t){},mixinDatacomEasyGet({getone:e=!1,success:t,fail:n}={}){this.mixinDatacomLoading||(this.mixinDatacomLoading=!0,this.mixinDatacomErrorMessage="",this.mixinDatacomGet().then((n=>{this.mixinDatacomLoading=!1;const{data:s,count:r}=n.result;this.getcount&&(this.mixinDatacomPage.count=r),this.mixinDatacomHasMore=s.length<this.pageSize;const o=e?s.length?s[0]:void 0:s;this.mixinDatacomResData=o,t&&t(o)})).catch((e=>{this.mixinDatacomLoading=!1,this.mixinDatacomErrorMessage=e,n&&n(e)})))},mixinDatacomGet(t={}){let n=e.database();const s=t.action||this.action;s&&(n=n.action(s));const r=t.collection||this.collection;n=Array.isArray(r)?n.collection(...r):n.collection(r);const o=t.where||this.where;o&&Object.keys(o).length&&(n=n.where(o));const i=t.field||this.field;i&&(n=n.field(i));const a=t.foreignKey||this.foreignKey;a&&(n=n.foreignKey(a));const c=t.groupby||this.groupby;c&&(n=n.groupBy(c));const u=t.groupField||this.groupField;u&&(n=n.groupField(u));!0===(void 0!==t.distinct?t.distinct:this.distinct)&&(n=n.distinct());const h=t.orderby||this.orderby;h&&(n=n.orderBy(h));const l=void 0!==t.pageCurrent?t.pageCurrent:this.mixinDatacomPage.current,d=void 0!==t.pageSize?t.pageSize:this.mixinDatacomPage.size,f=void 0!==t.getcount?t.getcount:this.getcount,p=void 0!==t.gettree?t.gettree:this.gettree,g=void 0!==t.gettreepath?t.gettreepath:this.gettreepath,m={getCount:f},y={limitLevel:void 0!==t.limitlevel?t.limitlevel:this.limitlevel,startWith:void 0!==t.startwith?t.startwith:this.startwith};return p&&(m.getTree=y),g&&(m.getTreePath=y),n=n.skip(d*(l-1)).limit(d).get(m),n}}}}async function ct(e,t){const n=`http://${e}:${t}/system/ping`;try{const e=await(s={url:n,timeout:500},new Promise(((e,t)=>{q.request({...s,success(t){e(t)},fail(e){t(e)}})})));return!(!e.data||0!==e.data.code)}catch(e){return!1}var s}let ut=new class{init(e){let t={};const n=!1!==e.debugFunction&&u&&("h5"===h&&navigator.userAgent.indexOf("HBuilderX")>0||"app-plus"===h);switch(e.provider){case"tencent":t=je.init(Object.assign(e,{useDebugFunction:n}));break;case"aliyun":t=L.init(Object.assign(e,{useDebugFunction:n}));break;case"private":t=He.init(Object.assign(e,{useDebugFunction:n}));break;default:throw new Error("未提供正确的provider参数")}const s=l;u&&s&&!s.code&&(t.debugInfo=s);let r=Promise.resolve();var o;o=1,r=new Promise(((e,t)=>{setTimeout((()=>{e()}),o)})),t.isReady=!1,t.isDefault=!1;const i=t.auth();t.initUniCloud=r.then((()=>i.getLoginState())).then((e=>e?Promise.resolve():i.signInAnonymously())).then((()=>{if(u&&t.debugInfo){const{address:e,servePort:n}=t.debugInfo;return async function(e,t){let n;for(let s=0;s<e.length;s++){const r=e[s];if(await ct(r,t)){n=r;break}}return{address:n,port:t}}(e,n)}return Promise.resolve()})).then((({address:e,port:n}={})=>{if(!u)return Promise.resolve();if(e)t.localAddress=e,t.localPort=n;else if(t.debugInfo){const e=console["app-plus"===h?"error":"warn"];"remote"===t.debugInfo.initialLaunchType?(t.debugInfo.forceRemote=!0,e("当前客户端和HBuilderX不在同一局域网下(或其他网络原因无法连接HBuilderX),uniCloud本地调试服务不对当前客户端生效。\n- 如果不使用uniCloud本地调试服务,请直接忽略此信息。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs")):e("无法连接uniCloud本地调试服务,请检查当前客户端是否与主机在同一局域网下。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs")}})).then((()=>(function(){if(!u||"h5"!==h)return;if(uni.getStorageSync("__LAST_DCLOUD_APPID")===p)return;uni.setStorageSync("__LAST_DCLOUD_APPID",p),uni.removeStorageSync("uni_id_token")&&(console.warn("检测到当前项目与上次运行到此端口的项目不一致,自动清理uni-id保存的token信息(仅开发调试时生效)"),uni.removeStorageSync("uni_id_token"),uni.removeStorageSync("uni_id_token_expired"))}(),new Promise((e=>{"quickapp-native"===h?(O="android",uni.getStorage({key:"__DC_CLOUD_UUID",success(t){b=t.data?t.data:U(32),e()}})):setTimeout((()=>{O=uni.getSystemInfoSync().platform,b=uni.getStorageSync("__DC_CLOUD_UUID")||U(32),e()}),0)}))))).then((()=>{t.isReady=!0})),et(t),function(e){const t=e.uploadFile;e.uploadFile=function(e){let n;return n=this.isReady?Promise.resolve():this.initUniCloud,n.then((()=>t.call(this,e)))}}(t),function(e){e.database=function(){if(this._database)return this._database;const t={};let n={};function s({action:s,command:r,multiCommand:o}){return S(k("database","invoke")).then((()=>e.callFunction({name:"DCloud-clientDB",data:{action:s,command:r,multiCommand:o}}))).then((e=>{const{code:s,message:r,token:o,tokenExpired:i,systemInfo:c=[]}=e.result;if(c)for(let e=0;e<c.length;e++){const{level:t,message:n,detail:s}=c[e],r=console["app-plus"===h&&"warn"===t?"error":t]||console.log;let o="[System Info]"+n;s&&(o=`${o}\n详细信息:${s}`),r(o)}if(s){const e=new a(r,s);return n.error&&n.error.forEach((t=>{t(e)})),Promise.reject(e)}o&&i&&(t.refreshToken&&t.refreshToken.forEach((e=>{e({token:o,tokenExpired:i})})),n.refreshToken&&n.refreshToken.forEach((e=>{e({token:o,tokenExpired:i})})));const u=e.result.affectedDocs;return"number"==typeof u&&Object.defineProperty(e.result,"affectedDocs",{get:()=>(console.warn("affectedDocs不再推荐使用,请使用inserted/deleted/updated/data.length替代"),u)}),S(k("database","success"),e).then((()=>S(k("database","complete"),e))).then((()=>Promise.resolve(e)))}),(e=>{const t=new a(e.message,e.code||"SYSTEM_ERROR");return n.error&&n.error.forEach((e=>{e(t)})),/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message)&&console.warn("clientDB未初始化,请在web控制台保存一次schema以开启clientDB"),S(k("database","fail"),e).then((()=>S(k("database","complete"),e))).then((()=>Promise.reject(e)))}))}this.isDefault&&(n=m("_globalUniCloudDatabaseCallback"));class r{constructor(e,t){this.content=e,this.prevStage=t,this.udb=null}toJSON(){let e=this;const t=[e.content];for(;e.prevStage;)e=e.prevStage,t.push(e.content);return{$db:t.reverse().map((e=>({$method:e.$method,$param:st(e.$param)})))}}getAction(){const e=this.toJSON().$db.find((e=>"action"===e.$method));return e&&e.$param&&e.$param[0]}getCommand(){return{$db:this.toJSON().$db.filter((e=>"action"!==e.$method))}}get useAggregate(){let e=this,t=!1;for(;e.prevStage;){e=e.prevStage;const n=e.content.$method;if("aggregate"===n||"pipeline"===n){t=!0;break}}return t}get count(){if(!this.useAggregate)return function(){return this._send("count",Array.from(arguments))};const e=this;return function(){return c({$method:"count",$param:st(Array.from(arguments))},e)}}get(){return this._send("get",Array.from(arguments))}add(){return this._send("add",Array.from(arguments))}remove(){return this._send("remove",Array.from(arguments))}update(){return this._send("update",Array.from(arguments))}end(){return this._send("end",Array.from(arguments))}set(){throw new Error("clientDB禁止使用set方法")}get multiSend(){}_send(e,t){const n=this.getAction(),r=this.getCommand();return r.$db.push({$method:e,$param:st(t)}),s({action:n,command:r})}}const o=["db.Geo","db.command","command.aggregate"];function i(e,t){return o.indexOf(`${e}.${t}`)>-1}function c(e,t){return nt(new r(e,t),{get(e,t){let n="db";return e&&e.content&&(n=e.content.$method),i(n,t)?c({$method:t},e):function(){return c({$method:t,$param:st(Array.from(arguments))},e)}}})}function u({path:e,method:t}){return class{constructor(){this.param=Array.from(arguments)}toJSON(){return{$newDb:[...e.map((e=>({$method:e}))),{$method:t,$param:this.param}]}}}}const l={auth:{on:(e,n)=>{t[e]=t[e]||[],t[e].indexOf(n)>-1||t[e].push(n)},off:(e,n)=>{t[e]=t[e]||[];const s=t[e].indexOf(n);-1!==s&&t[e].splice(s,1)}},on:(e,t)=>{n[e]=n[e]||[],n[e].indexOf(t)>-1||n[e].push(t)},off:(e,t)=>{n[e]=n[e]||[];const s=n[e].indexOf(t);-1!==s&&n[e].splice(s,1)},env:nt({},{get:(e,t)=>({$env:t})}),Geo:nt({},{get:(e,t)=>u({path:["Geo"],method:t})}),getCloudEnv:function(e){if("string"!=typeof e||!e.trim())throw new Error("getCloudEnv参数错误");return{$env:e.replace("$cloudEnv_","")}},multiSend(){const e=Array.from(arguments);return s({multiCommand:e.map((e=>{const t=e.getAction(),n=e.getCommand();if("getTemp"!==n.$db[n.$db.length-1].$method)throw new Error("multiSend只支持子命令内使用getTemp");return{action:t,command:n}}))}).then((t=>{for(let n=0;n<e.length;n++){const s=e[n];s.udb&&"function"==typeof s.udb.setResult&&s.udb.setResult(t.result.dataList[n])}return Promise.resolve(t)}),(t=>{for(let n=0;n<e.length;n++){const s=e[n];s.udb&&"function"==typeof s.udb.setResult&&s.udb.setResult(t)}return Promise.reject(t)}))},get serverDate(){return u({path:[],method:"serverDate"})},get RegExp(){return u({path:[],method:"RegExp"})}},d=nt(l,{get:(e,t)=>i("db",t)?c({$method:t}):function(){return c({$method:t,$param:st(Array.from(arguments))})}});return this._database=d,d}}(t),function(e){e.getCurrentUserInfo=rt,e.chooseAndUploadFile=ot.initChooseAndUploadFile(e),Object.assign(e,{get mixinDatacom(){return at(e)}})}(t);return["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","chooseAndUploadFile"].forEach((e=>{t[e]&&(t[e]=T(t[e],e))})),t.init=this.init,t}};(()=>{{const e=d;let t={};if(1===e.length)t=e[0],ut=ut.init(t),ut.isDefault=!0;else{const t=["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","database","getCurrentUSerInfo"];let n;n=e&&e.length>0?"应用有多个服务空间,请通过uniCloud.init方法指定要使用的服务空间":f?"应用未关联服务空间,请在uniCloud目录右键关联服务空间":"uni-app cli项目内使用uniCloud需要使用HBuilderX的运行菜单运行项目,且需要在uniCloud目录关联服务空间",t.forEach((e=>{ut[e]=function(){return console.error(n),Promise.reject(new P({code:"SYS_ERR",message:n}))}}))}Object.assign(ut,{get mixinDatacom(){return at(ut)}}),ut.addInterceptor=w,ut.removeInterceptor=v,u&&"h5"===h&&(window.uniCloud=ut)}})();var ht=ut;export default ht;
|
|
1
|
+
import{initVueI18n as e}from"@dcloudio/uni-i18n";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function t(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function s(e,t,s){return e(s={path:t,exports:{},require:function(e,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&s.path)}},s.exports),s.exports}var n=s((function(e,t){var s;e.exports=(s=s||function(e,t){var s=Object.create||function(){function e(){}return function(t){var s;return e.prototype=t,s=new e,e.prototype=null,s}}(),n={},r=n.lib={},o=r.Base={extend:function(e){var t=s(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},i=r.WordArray=o.extend({init:function(e,s){e=this.words=e||[],this.sigBytes=s!=t?s:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,s=e.words,n=this.sigBytes,r=e.sigBytes;if(this.clamp(),n%4)for(var o=0;o<r;o++){var i=s[o>>>2]>>>24-o%4*8&255;t[n+o>>>2]|=i<<24-(n+o)%4*8}else for(o=0;o<r;o+=4)t[n+o>>>2]=s[o>>>2];return this.sigBytes+=r,this},clamp:function(){var t=this.words,s=this.sigBytes;t[s>>>2]&=4294967295<<32-s%4*8,t.length=e.ceil(s/4)},clone:function(){var e=o.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var s,n=[],r=function(t){t=t;var s=987654321,n=4294967295;return function(){var r=((s=36969*(65535&s)+(s>>16)&n)<<16)+(t=18e3*(65535&t)+(t>>16)&n)&n;return r/=4294967296,(r+=.5)*(e.random()>.5?1:-1)}},o=0;o<t;o+=4){var a=r(4294967296*(s||e.random()));s=987654071*a(),n.push(4294967296*a()|0)}return new i.init(n,t)}}),a=n.enc={},c=a.Hex={stringify:function(e){for(var t=e.words,s=e.sigBytes,n=[],r=0;r<s;r++){var o=t[r>>>2]>>>24-r%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,s=[],n=0;n<t;n+=2)s[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new i.init(s,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,s=e.sigBytes,n=[],r=0;r<s;r++){var o=t[r>>>2]>>>24-r%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(e){for(var t=e.length,s=[],n=0;n<t;n++)s[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new i.init(s,t)}},h=a.Utf8={stringify:function(e){try{return decodeURIComponent(escape(u.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return u.parse(unescape(encodeURIComponent(e)))}},l=r.BufferedBlockAlgorithm=o.extend({reset:function(){this._data=new i.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=h.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var s=this._data,n=s.words,r=s.sigBytes,o=this.blockSize,a=r/(4*o),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,u=e.min(4*c,r);if(c){for(var h=0;h<c;h+=o)this._doProcessBlock(n,h);var l=n.splice(0,c);s.sigBytes-=u}return new i.init(l,u)},clone:function(){var e=o.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),d=(r.Hasher=l.extend({cfg:o.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){l.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,s){return new e.init(s).finalize(t)}},_createHmacHelper:function(e){return function(t,s){return new d.HMAC.init(e,s).finalize(t)}}}),n.algo={});return n}(Math),s)})),r=(s((function(e,t){var s;e.exports=(s=n,function(e){var t=s,n=t.lib,r=n.WordArray,o=n.Hasher,i=t.algo,a=[];!function(){for(var t=0;t<64;t++)a[t]=4294967296*e.abs(e.sin(t+1))|0}();var c=i.MD5=o.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(e,t){for(var s=0;s<16;s++){var n=t+s,r=e[n];e[n]=16711935&(r<<8|r>>>24)|4278255360&(r<<24|r>>>8)}var o=this._hash.words,i=e[t+0],c=e[t+1],f=e[t+2],p=e[t+3],g=e[t+4],m=e[t+5],y=e[t+6],_=e[t+7],w=e[t+8],k=e[t+9],S=e[t+10],v=e[t+11],T=e[t+12],P=e[t+13],A=e[t+14],I=e[t+15],b=o[0],E=o[1],O=o[2],U=o[3];b=u(b,E,O,U,i,7,a[0]),U=u(U,b,E,O,c,12,a[1]),O=u(O,U,b,E,f,17,a[2]),E=u(E,O,U,b,p,22,a[3]),b=u(b,E,O,U,g,7,a[4]),U=u(U,b,E,O,m,12,a[5]),O=u(O,U,b,E,y,17,a[6]),E=u(E,O,U,b,_,22,a[7]),b=u(b,E,O,U,w,7,a[8]),U=u(U,b,E,O,k,12,a[9]),O=u(O,U,b,E,S,17,a[10]),E=u(E,O,U,b,v,22,a[11]),b=u(b,E,O,U,T,7,a[12]),U=u(U,b,E,O,P,12,a[13]),O=u(O,U,b,E,A,17,a[14]),b=h(b,E=u(E,O,U,b,I,22,a[15]),O,U,c,5,a[16]),U=h(U,b,E,O,y,9,a[17]),O=h(O,U,b,E,v,14,a[18]),E=h(E,O,U,b,i,20,a[19]),b=h(b,E,O,U,m,5,a[20]),U=h(U,b,E,O,S,9,a[21]),O=h(O,U,b,E,I,14,a[22]),E=h(E,O,U,b,g,20,a[23]),b=h(b,E,O,U,k,5,a[24]),U=h(U,b,E,O,A,9,a[25]),O=h(O,U,b,E,p,14,a[26]),E=h(E,O,U,b,w,20,a[27]),b=h(b,E,O,U,P,5,a[28]),U=h(U,b,E,O,f,9,a[29]),O=h(O,U,b,E,_,14,a[30]),b=l(b,E=h(E,O,U,b,T,20,a[31]),O,U,m,4,a[32]),U=l(U,b,E,O,w,11,a[33]),O=l(O,U,b,E,v,16,a[34]),E=l(E,O,U,b,A,23,a[35]),b=l(b,E,O,U,c,4,a[36]),U=l(U,b,E,O,g,11,a[37]),O=l(O,U,b,E,_,16,a[38]),E=l(E,O,U,b,S,23,a[39]),b=l(b,E,O,U,P,4,a[40]),U=l(U,b,E,O,i,11,a[41]),O=l(O,U,b,E,p,16,a[42]),E=l(E,O,U,b,y,23,a[43]),b=l(b,E,O,U,k,4,a[44]),U=l(U,b,E,O,T,11,a[45]),O=l(O,U,b,E,I,16,a[46]),b=d(b,E=l(E,O,U,b,f,23,a[47]),O,U,i,6,a[48]),U=d(U,b,E,O,_,10,a[49]),O=d(O,U,b,E,A,15,a[50]),E=d(E,O,U,b,m,21,a[51]),b=d(b,E,O,U,T,6,a[52]),U=d(U,b,E,O,p,10,a[53]),O=d(O,U,b,E,S,15,a[54]),E=d(E,O,U,b,c,21,a[55]),b=d(b,E,O,U,w,6,a[56]),U=d(U,b,E,O,I,10,a[57]),O=d(O,U,b,E,y,15,a[58]),E=d(E,O,U,b,P,21,a[59]),b=d(b,E,O,U,g,6,a[60]),U=d(U,b,E,O,v,10,a[61]),O=d(O,U,b,E,f,15,a[62]),E=d(E,O,U,b,k,21,a[63]),o[0]=o[0]+b|0,o[1]=o[1]+E|0,o[2]=o[2]+O|0,o[3]=o[3]+U|0},_doFinalize:function(){var t=this._data,s=t.words,n=8*this._nDataBytes,r=8*t.sigBytes;s[r>>>5]|=128<<24-r%32;var o=e.floor(n/4294967296),i=n;s[15+(r+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),s[14+(r+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),t.sigBytes=4*(s.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var h=c[u];c[u]=16711935&(h<<8|h>>>24)|4278255360&(h<<24|h>>>8)}return a},clone:function(){var e=o.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,s,n,r,o,i){var a=e+(t&s|~t&n)+r+i;return(a<<o|a>>>32-o)+t}function h(e,t,s,n,r,o,i){var a=e+(t&n|s&~n)+r+i;return(a<<o|a>>>32-o)+t}function l(e,t,s,n,r,o,i){var a=e+(t^s^n)+r+i;return(a<<o|a>>>32-o)+t}function d(e,t,s,n,r,o,i){var a=e+(s^(t|~n))+r+i;return(a<<o|a>>>32-o)+t}t.MD5=o._createHelper(c),t.HmacMD5=o._createHmacHelper(c)}(Math),s.MD5)})),s((function(e,t){var s,r,o;e.exports=(r=(s=n).lib.Base,o=s.enc.Utf8,void(s.algo.HMAC=r.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=o.parse(t));var s=e.blockSize,n=4*s;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var r=this._oKey=t.clone(),i=this._iKey=t.clone(),a=r.words,c=i.words,u=0;u<s;u++)a[u]^=1549556828,c[u]^=909522486;r.sigBytes=i.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,s=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(s))}})))})),s((function(e,t){e.exports=n.HmacMD5})));function o(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function i(e){return"object"===o(e)}class a extends Error{constructor(e,t){super(e),this.code=t}}function c(e){return e&&"string"==typeof e?JSON.parse(e):e}const u="development"===process.env.NODE_ENV,h=process.env.VUE_APP_PLATFORM,l=c(process.env.UNICLOUD_DEBUG),d=c(process.env.UNI_CLOUD_PROVIDER),f=process.env.RUN_BY_HBUILDERX;let p="";try{{const e=require("uni-stat-config").default||require("uni-stat-config");p=e.appid}}catch(e){}let g={};function m(e,t={}){var s,n;return s=g,n=e,Object.prototype.hasOwnProperty.call(s,n)||(g[e]=t),g[e]}"app-plus"===h&&(g=uni._globalUniCloudObj?uni._globalUniCloudObj:uni._globalUniCloudObj={});const y=["invoke","success","fail","complete"],_=m("_globalUniCloudInterceptor");function w(e,t){_[e]||(_[e]={}),i(t)&&Object.keys(t).forEach((s=>{y.indexOf(s)>-1&&function(e,t,s){let n=_[e][t];n||(n=_[e][t]=[]),-1===n.indexOf(s)&&"function"==typeof s&&n.push(s)}(e,s,t[s])}))}function k(e,t){_[e]||(_[e]={}),i(t)?Object.keys(t).forEach((s=>{y.indexOf(s)>-1&&function(e,t,s){const n=_[e][t];if(!n)return;const r=n.indexOf(s);r>-1&&n.splice(r,1)}(e,s,t[s])})):delete _[e]}function S(e,t){return e&&0!==e.length?e.reduce(((e,s)=>e.then((()=>s(t)))),Promise.resolve()):Promise.resolve()}function v(e,t){return _[e]&&_[e][t]||[]}function T(e,t){return t?function(s){const n="callFunction"===t&&"DCloud-clientDB"===(s&&s.name);let r;r=this.isReady?Promise.resolve():this.initUniCloud,s=s||{};const o=r.then((()=>n?Promise.resolve():S(v(t,"invoke"),s))).then((()=>e.call(this,s))).then((e=>n?Promise.resolve(e):S(v(t,"success"),e).then((()=>S(v(t,"complete"),e))).then((()=>Promise.resolve(e)))),(e=>n?Promise.reject(e):S(v(t,"fail"),e).then((()=>S(v(t,"complete"),e))).then((()=>Promise.reject(e)))));if(!(s.success||s.fail||s.complete))return o;o.then((e=>{s.success&&s.success(e),s.complete&&s.complete(e)}),(e=>{s.fail&&s.fail(e),s.complete&&s.complete(e)}))}:function(t){if(!((t=t||{}).success||t.fail||t.complete))return e.call(this,t);e.call(this,t).then((e=>{t.success&&t.success(e),t.complete&&t.complete(e)}),(e=>{t.fail&&t.fail(e),t.complete&&t.complete(e)}))}}class P extends Error{constructor(e){super(e.message),this.errMsg=e.message||"",Object.defineProperties(this,{code:{get:()=>e.code},requestId:{get:()=>e.requestId},message:{get(){return this.errMsg},set(e){this.errMsg=e}}})}}const{t:A,setLocale:I,getLocale:b}=e({"zh-Hans":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},"zh-Hant":{"uniCloud.init.paramRequired":"缺少参数:{param}","uniCloud.uploadFile.fileError":"filePath应为File对象"},en:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"},fr:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"},es:{"uniCloud.init.paramRequired":"{param} required","uniCloud.uploadFile.fileError":"filePath should be instance of File"}},"zh-Hans");function E(){const{deviceId:e,platform:t}=uni.getSystemInfoSync();return{PLATFORM:h,OS:t,APPID:p,LOCALE:b(),DEVICEID:e,CLIENT_SDK_VERSION:"1.0.14"}}var O={sign:function(e,t){let s="";return Object.keys(e).sort().forEach((function(t){e[t]&&(s=s+"&"+t+"="+e[t])})),s=s.slice(1),r(s,t).toString()},wrappedRequest:function(e,t){return new Promise(((s,n)=>{t(Object.assign(e,{complete(e){e||(e={}),u&&"h5"===h&&e.errMsg&&0===e.errMsg.indexOf("request:fail")&&console.warn("发布H5,需要在uniCloud后台操作,绑定安全域名,否则会因为跨域问题而无法访问。教程参考:https://uniapp.dcloud.io/uniCloud/quickstart?id=useinh5");const t=e.data&&e.data.header&&e.data.header["x-serverless-request-id"]||e.header&&e.header["request-id"];if(!e.statusCode||e.statusCode>=400)return n(new P({code:"SYS_ERR",message:e.errMsg||"request:fail",requestId:t}));const r=e.data;if(r.error)return n(new P({code:r.error.code,message:r.error.message,requestId:t}));r.result=r.data,r.requestId=t,delete r.data,s(r)}}))}))}};const U={request:e=>uni.request(e),uploadFile:e=>uni.uploadFile(e),setStorageSync:(e,t)=>uni.setStorageSync(e,t),getStorageSync:e=>uni.getStorageSync(e),removeStorageSync:e=>uni.removeStorageSync(e),clearStorageSync:()=>uni.clearStorageSync()};class C{constructor(e){["spaceId","clientSecret"].forEach((t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(A("uniCloud.init.paramRequired",{param:t}))})),this.config=Object.assign({},{endpoint:"https://api.bspapp.com"},e),this.config.provider="aliyun",this.config.requestUrl=this.config.endpoint+"/client",this.config.envType=this.config.envType||"public",this.config.accessTokenKey="access_token_"+this.config.spaceId,this.adapter=U,this._getAccessTokenPromise=null,this._getAccessTokenPromiseStatus=null}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){this.accessToken=e}requestWrapped(e){return O.wrappedRequest(e,this.adapter.request)}requestAuth(e){return this.requestWrapped(e)}request(e,t){return Promise.resolve().then((()=>this.hasAccessToken?t?this.requestWrapped(e):this.requestWrapped(e).catch((t=>new Promise(((e,s)=>{!t||"GATEWAY_INVALID_TOKEN"!==t.code&&"InvalidParameter.InvalidToken"!==t.code?s(t):e()})).then((()=>this.getAccessToken())).then((()=>{const t=this.rebuildRequest(e);return this.request(t,!0)})))):this.getAccessToken().then((()=>{const t=this.rebuildRequest(e);return this.request(t,!0)}))))}rebuildRequest(e){const t=Object.assign({},e);return t.data.token=this.accessToken,t.header["x-basement-token"]=this.accessToken,t.header["x-serverless-sign"]=O.sign(t.data,this.config.clientSecret),t}setupRequest(e,t){const s=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),n={"Content-Type":"application/json"};return"auth"!==t&&(s.token=this.accessToken,n["x-basement-token"]=this.accessToken),n["x-serverless-sign"]=O.sign(s,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:s,dataType:"json",header:n}}getAccessToken(){if("pending"===this._getAccessTokenPromiseStatus)return this._getAccessTokenPromise;this._getAccessTokenPromiseStatus="pending";return this._getAccessTokenPromise=this.requestAuth(this.setupRequest({method:"serverless.auth.user.anonymousAuthorize",params:"{}"},"auth")).then((e=>new Promise(((t,s)=>{e.result&&e.result.accessToken?(this.setAccessToken(e.result.accessToken),this._getAccessTokenPromiseStatus="fulfilled",t(this.accessToken)):(this._getAccessTokenPromiseStatus="rejected",s(new P({code:"AUTH_FAILED",message:"获取accessToken失败"})))}))),(e=>(this._getAccessTokenPromiseStatus="rejected",Promise.reject(e)))),this._getAccessTokenPromise}authorize(){this.getAccessToken()}callFunction(e){const t={method:"serverless.function.runtime.invoke",params:JSON.stringify({functionTarget:e.name,functionArgs:e.data||{}})};return this.request(this.setupRequest(t))}getOSSUploadOptionsFromPath(e){const t={method:"serverless.file.resource.generateProximalSign",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFileToOSS({url:e,formData:t,name:s,filePath:n,fileType:r,onUploadProgress:o}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:s,filePath:n,fileType:r,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?i(e):a(new P({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new P({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof o&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{o({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}reportOSSUpload(e){const t={method:"serverless.file.resource.report",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFile({filePath:e,cloudPath:t,fileType:s="image",onUploadProgress:n,config:r}){if("string"!==o(t))throw new P({code:"INVALID_PARAM",message:"cloudPath必须为字符串类型"});if(!(t=t.trim()))throw new P({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});if(/:\/\//.test(t))throw new P({code:"INVALID_PARAM",message:"cloudPath不合法"});const i=r&&r.envType||this.config.envType;let a,c;return this.getOSSUploadOptionsFromPath({env:i,filename:t}).then((t=>{const r=t.result;a=r.id,c="https://"+r.cdnDomain+"/"+r.ossPath;const o={url:"https://"+r.host,formData:{"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:r.accessKeyId,Signature:r.signature,host:r.host,id:a,key:r.ossPath,policy:r.policy,success_action_status:200},fileName:"file",name:"file",filePath:e,fileType:s};return this.uploadFileToOSS(Object.assign({},o,{onUploadProgress:n}))})).then((()=>this.reportOSSUpload({id:a}))).then((t=>new Promise(((s,n)=>{t.success?s({success:!0,filePath:e,fileID:c}):n(new P({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({id:e[0]})};return this.request(this.setupRequest(t))}getTempFileURL({fileList:e}={}){return new Promise(((t,s)=>{Array.isArray(e)&&0!==e.length||s(new P({code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"})),t({fileList:e.map((e=>({fileID:e,tempFileURL:e})))})}))}}const x={init(e){const t=new C(e),s={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return s},t.customAuth=t.auth,t}},D="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:";var R;!function(e){e.local="local",e.none="none",e.session="session"}(R||(R={}));var q=function(){};const F=()=>{let e;if(!Promise){e=()=>{},e.promise={};const t=()=>{throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}const t=new Promise(((t,s)=>{e=(e,n)=>e?s(e):t(n)}));return e.promise=t,e};function L(e){return void 0===e}function N(e){return"[object Null]"===Object.prototype.toString.call(e)}var M;function $(e){const t=(s=e,"[object Array]"===Object.prototype.toString.call(s)?e:[e]);var s;for(const e of t){const{isMatch:t,genAdapter:s,runtime:n}=e;if(t())return{adapter:s(),runtime:n}}}!function(e){e.WEB="web",e.WX_MP="wx_mp"}(M||(M={}));const j={adapter:null,runtime:void 0},K=["anonymousUuidKey"];class B extends q{constructor(){super(),j.adapter.root.tcbObject||(j.adapter.root.tcbObject={})}setItem(e,t){j.adapter.root.tcbObject[e]=t}getItem(e){return j.adapter.root.tcbObject[e]}removeItem(e){delete j.adapter.root.tcbObject[e]}clear(){delete j.adapter.root.tcbObject}}function H(e,t){switch(e){case"local":return t.localStorage||new B;case"none":return new B;default:return t.sessionStorage||new B}}class W{constructor(e){if(!this._storage){this._persistence=j.adapter.primaryStorage||e.persistence,this._storage=H(this._persistence,j.adapter);const t=`access_token_${e.env}`,s=`access_token_expire_${e.env}`,n=`refresh_token_${e.env}`,r=`anonymous_uuid_${e.env}`,o=`login_type_${e.env}`,i=`user_info_${e.env}`;this.keys={accessTokenKey:t,accessTokenExpireKey:s,refreshTokenKey:n,anonymousUuidKey:r,loginTypeKey:o,userInfoKey:i}}}updatePersistence(e){if(e===this._persistence)return;const t="local"===this._persistence;this._persistence=e;const s=H(e,j.adapter);for(const e in this.keys){const n=this.keys[e];if(t&&K.includes(e))continue;const r=this._storage.getItem(n);L(r)||N(r)||(s.setItem(n,r),this._storage.removeItem(n))}this._storage=s}setStore(e,t,s){if(!this._storage)return;const n={version:s||"localCachev1",content:t},r=JSON.stringify(n);try{this._storage.setItem(e,r)}catch(e){throw e}}getStore(e,t){try{if(!this._storage)return}catch(e){return""}t=t||"localCachev1";const s=this._storage.getItem(e);if(!s)return"";if(s.indexOf(t)>=0){return JSON.parse(s).content}return""}removeStore(e){this._storage.removeItem(e)}}const z={},V={};function J(e){return z[e]}class Y{constructor(e,t){this.data=t||null,this.name=e}}class X extends Y{constructor(e,t){super("error",{error:e,data:t}),this.error=e}}const G=new class{constructor(){this._listeners={}}on(e,t){return function(e,t,s){s[e]=s[e]||[],s[e].push(t)}(e,t,this._listeners),this}off(e,t){return function(e,t,s){if(s&&s[e]){const n=s[e].indexOf(t);-1!==n&&s[e].splice(n,1)}}(e,t,this._listeners),this}fire(e,t){if(e instanceof X)return console.error(e.error),this;const s="string"==typeof e?new Y(e,t||{}):e;const n=s.name;if(this._listens(n)){s.target=this;const e=this._listeners[n]?[...this._listeners[n]]:[];for(const t of e)t.call(this,s)}return this}_listens(e){return this._listeners[e]&&this._listeners[e].length>0}};function Q(e,t){G.on(e,t)}function Z(e,t={}){G.fire(e,t)}function ee(e,t){G.off(e,t)}const te="loginStateChanged",se="loginStateExpire",ne="loginTypeChanged",re="anonymousConverted",oe="refreshAccessToken";var ie;!function(e){e.ANONYMOUS="ANONYMOUS",e.WECHAT="WECHAT",e.WECHAT_PUBLIC="WECHAT-PUBLIC",e.WECHAT_OPEN="WECHAT-OPEN",e.CUSTOM="CUSTOM",e.EMAIL="EMAIL",e.USERNAME="USERNAME",e.NULL="NULL"}(ie||(ie={}));const ae=["auth.getJwt","auth.logout","auth.signInWithTicket","auth.signInAnonymously","auth.signIn","auth.fetchAccessTokenWithRefreshToken","auth.signUpWithEmailAndPassword","auth.activateEndUserMail","auth.sendPasswordResetEmail","auth.resetPasswordWithToken","auth.isUsernameRegistered"],ce={"X-SDK-Version":"1.3.5"};function ue(e,t,s){const n=e[t];e[t]=function(t){const r={},o={};s.forEach((s=>{const{data:n,headers:i}=s.call(e,t);Object.assign(r,n),Object.assign(o,i)}));const i=t.data;return i&&(()=>{var e;if(e=i,"[object FormData]"!==Object.prototype.toString.call(e))t.data={...i,...r};else for(const e in r)i.append(e,r[e])})(),t.headers={...t.headers||{},...o},n.call(e,t)}}function he(){const e=Math.random().toString(16).slice(2);return{data:{seqId:e},headers:{...ce,"x-seqid":e}}}class le{constructor(e={}){var t;this.config=e,this._reqClass=new j.adapter.reqClass({timeout:this.config.timeout,timeoutMsg:`请求在${this.config.timeout/1e3}s内未完成,已中断`,restrictedMethods:["post"]}),this._cache=J(this.config.env),this._localCache=(t=this.config.env,V[t]),ue(this._reqClass,"post",[he]),ue(this._reqClass,"upload",[he]),ue(this._reqClass,"download",[he])}async post(e){return await this._reqClass.post(e)}async upload(e){return await this._reqClass.upload(e)}async download(e){return await this._reqClass.download(e)}async refreshAccessToken(){let e,t;this._refreshAccessTokenPromise||(this._refreshAccessTokenPromise=this._refreshAccessToken());try{e=await this._refreshAccessTokenPromise}catch(e){t=e}if(this._refreshAccessTokenPromise=null,this._shouldRefreshAccessTokenHook=null,t)throw t;return e}async _refreshAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:s,loginTypeKey:n,anonymousUuidKey:r}=this._cache.keys;this._cache.removeStore(e),this._cache.removeStore(t);let o=this._cache.getStore(s);if(!o)throw new Error("未登录CloudBase");const i={refresh_token:o},a=await this.request("auth.fetchAccessTokenWithRefreshToken",i);if(a.data.code){const{code:e}=a.data;if("SIGN_PARAM_INVALID"===e||"REFRESH_TOKEN_EXPIRED"===e||"INVALID_REFRESH_TOKEN"===e){if(this._cache.getStore(n)===ie.ANONYMOUS&&"INVALID_REFRESH_TOKEN"===e){const e=this._cache.getStore(r),t=this._cache.getStore(s),n=await this.send("auth.signInAnonymously",{anonymous_uuid:e,refresh_token:t});return this.setRefreshToken(n.refresh_token),this._refreshAccessToken()}Z(se),this._cache.removeStore(s)}throw new Error(`刷新access token失败:${a.data.code}`)}if(a.data.access_token)return Z(oe),this._cache.setStore(e,a.data.access_token),this._cache.setStore(t,a.data.access_token_expire+Date.now()),{accessToken:a.data.access_token,accessTokenExpire:a.data.access_token_expire};a.data.refresh_token&&(this._cache.removeStore(s),this._cache.setStore(s,a.data.refresh_token),this._refreshAccessToken())}async getAccessToken(){const{accessTokenKey:e,accessTokenExpireKey:t,refreshTokenKey:s}=this._cache.keys;if(!this._cache.getStore(s))throw new Error("refresh token不存在,登录状态异常");let n=this._cache.getStore(e),r=this._cache.getStore(t),o=!0;return this._shouldRefreshAccessTokenHook&&!await this._shouldRefreshAccessTokenHook(n,r)&&(o=!1),(!n||!r||r<Date.now())&&o?this.refreshAccessToken():{accessToken:n,accessTokenExpire:r}}async request(e,t,s){const n=`x-tcb-trace_${this.config.env}`;let r="application/x-www-form-urlencoded";const o={action:e,env:this.config.env,dataVersion:"2019-08-16",...t};if(-1===ae.indexOf(e)){const{refreshTokenKey:e}=this._cache.keys;this._cache.getStore(e)&&(o.access_token=(await this.getAccessToken()).accessToken)}let i;if("storage.uploadFile"===e){i=new FormData;for(let e in i)i.hasOwnProperty(e)&&void 0!==i[e]&&i.append(e,o[e]);r="multipart/form-data"}else{r="application/json",i={};for(let e in o)void 0!==o[e]&&(i[e]=o[e])}let a={headers:{"content-type":r}};s&&s.onUploadProgress&&(a.onUploadProgress=s.onUploadProgress);const c=this._localCache.getStore(n);c&&(a.headers["X-TCB-Trace"]=c);const{parse:u,inQuery:h,search:l}=t;let d={env:this.config.env};u&&(d.parse=!0),h&&(d={...h,...d});let f=function(e,t,s={}){const n=/\?/.test(t);let r="";for(let e in s)""===r?!n&&(t+="?"):r+="&",r+=`${e}=${encodeURIComponent(s[e])}`;return/^http(s)?\:\/\//.test(t+=r)?t:`${e}${t}`}(D,"//tcb-api.tencentcloudapi.com/web",d);l&&(f+=l);const p=await this.post({url:f,data:i,...a}),g=p.header&&p.header["x-tcb-trace"];if(g&&this._localCache.setStore(n,g),200!==Number(p.status)&&200!==Number(p.statusCode)||!p.data)throw new Error("network request error");return p}async send(e,t={}){const s=await this.request(e,t,{onUploadProgress:t.onUploadProgress});if("ACCESS_TOKEN_EXPIRED"===s.data.code&&-1===ae.indexOf(e)){await this.refreshAccessToken();const s=await this.request(e,t,{onUploadProgress:t.onUploadProgress});if(s.data.code)throw new Error(`[${s.data.code}] ${s.data.message}`);return s.data}if(s.data.code)throw new Error(`[${s.data.code}] ${s.data.message}`);return s.data}setRefreshToken(e){const{accessTokenKey:t,accessTokenExpireKey:s,refreshTokenKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.removeStore(s),this._cache.setStore(n,e)}}const de={};function fe(e){return de[e]}class pe{constructor(e){this.config=e,this._cache=J(e.env),this._request=fe(e.env)}setRefreshToken(e){const{accessTokenKey:t,accessTokenExpireKey:s,refreshTokenKey:n}=this._cache.keys;this._cache.removeStore(t),this._cache.removeStore(s),this._cache.setStore(n,e)}setAccessToken(e,t){const{accessTokenKey:s,accessTokenExpireKey:n}=this._cache.keys;this._cache.setStore(s,e),this._cache.setStore(n,t)}async refreshUserInfo(){const{data:e}=await this._request.send("auth.getUserInfo",{});return this.setLocalUserInfo(e),e}setLocalUserInfo(e){const{userInfoKey:t}=this._cache.keys;this._cache.setStore(t,e)}}class ge{constructor(e){if(!e)throw new Error("envId is not defined");this._envId=e,this._cache=J(this._envId),this._request=fe(this._envId),this.setUserInfo()}linkWithTicket(e){if("string"!=typeof e)throw new Error("ticket must be string");return this._request.send("auth.linkWithTicket",{ticket:e})}linkWithRedirect(e){e.signInWithRedirect()}updatePassword(e,t){return this._request.send("auth.updatePassword",{oldPassword:t,newPassword:e})}updateEmail(e){return this._request.send("auth.updateEmail",{newEmail:e})}updateUsername(e){if("string"!=typeof e)throw new Error("username must be a string");return this._request.send("auth.updateUsername",{username:e})}async getLinkedUidList(){const{data:e}=await this._request.send("auth.getLinkedUidList",{});let t=!1;const{users:s}=e;return s.forEach((e=>{e.wxOpenId&&e.wxPublicId&&(t=!0)})),{users:s,hasPrimaryUid:t}}setPrimaryUid(e){return this._request.send("auth.setPrimaryUid",{uid:e})}unlink(e){return this._request.send("auth.unlink",{platform:e})}async update(e){const{nickName:t,gender:s,avatarUrl:n,province:r,country:o,city:i}=e,{data:a}=await this._request.send("auth.updateUserInfo",{nickName:t,gender:s,avatarUrl:n,province:r,country:o,city:i});this.setLocalUserInfo(a)}async refresh(){const{data:e}=await this._request.send("auth.getUserInfo",{});return this.setLocalUserInfo(e),e}setUserInfo(){const{userInfoKey:e}=this._cache.keys,t=this._cache.getStore(e);["uid","loginType","openid","wxOpenId","wxPublicId","unionId","qqMiniOpenId","email","hasPassword","customUserId","nickName","gender","avatarUrl"].forEach((e=>{this[e]=t[e]})),this.location={country:t.country,province:t.province,city:t.city}}setLocalUserInfo(e){const{userInfoKey:t}=this._cache.keys;this._cache.setStore(t,e),this.setUserInfo()}}class me{constructor(e){if(!e)throw new Error("envId is not defined");this._cache=J(e);const{refreshTokenKey:t,accessTokenKey:s,accessTokenExpireKey:n}=this._cache.keys,r=this._cache.getStore(t),o=this._cache.getStore(s),i=this._cache.getStore(n);this.credential={refreshToken:r,accessToken:o,accessTokenExpire:i},this.user=new ge(e)}get isAnonymousAuth(){return this.loginType===ie.ANONYMOUS}get isCustomAuth(){return this.loginType===ie.CUSTOM}get isWeixinAuth(){return this.loginType===ie.WECHAT||this.loginType===ie.WECHAT_OPEN||this.loginType===ie.WECHAT_PUBLIC}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}}class ye extends pe{async signIn(){this._cache.updatePersistence("local");const{anonymousUuidKey:e,refreshTokenKey:t}=this._cache.keys,s=this._cache.getStore(e)||void 0,n=this._cache.getStore(t)||void 0,r=await this._request.send("auth.signInAnonymously",{anonymous_uuid:s,refresh_token:n});if(r.uuid&&r.refresh_token){this._setAnonymousUUID(r.uuid),this.setRefreshToken(r.refresh_token),await this._request.refreshAccessToken(),Z(te),Z(ne,{env:this.config.env,loginType:ie.ANONYMOUS,persistence:"local"});const e=new me(this.config.env);return await e.user.refresh(),e}throw new Error("匿名登录失败")}async linkAndRetrieveDataWithTicket(e){const{anonymousUuidKey:t,refreshTokenKey:s}=this._cache.keys,n=this._cache.getStore(t),r=this._cache.getStore(s),o=await this._request.send("auth.linkAndRetrieveDataWithTicket",{anonymous_uuid:n,refresh_token:r,ticket:e});if(o.refresh_token)return this._clearAnonymousUUID(),this.setRefreshToken(o.refresh_token),await this._request.refreshAccessToken(),Z(re,{env:this.config.env}),Z(ne,{loginType:ie.CUSTOM,persistence:"local"}),{credential:{refreshToken:o.refresh_token}};throw new Error("匿名转化失败")}_setAnonymousUUID(e){const{anonymousUuidKey:t,loginTypeKey:s}=this._cache.keys;this._cache.removeStore(t),this._cache.setStore(t,e),this._cache.setStore(s,ie.ANONYMOUS)}_clearAnonymousUUID(){this._cache.removeStore(this._cache.keys.anonymousUuidKey)}}class _e extends pe{async signIn(e){if("string"!=typeof e)throw new Error("ticket must be a string");const{refreshTokenKey:t}=this._cache.keys,s=await this._request.send("auth.signInWithTicket",{ticket:e,refresh_token:this._cache.getStore(t)||""});if(s.refresh_token)return this.setRefreshToken(s.refresh_token),await this._request.refreshAccessToken(),Z(te),Z(ne,{env:this.config.env,loginType:ie.CUSTOM,persistence:this.config.persistence}),await this.refreshUserInfo(),new me(this.config.env);throw new Error("自定义登录失败")}}class we extends pe{async signIn(e,t){if("string"!=typeof e)throw new Error("email must be a string");const{refreshTokenKey:s}=this._cache.keys,n=await this._request.send("auth.signIn",{loginType:"EMAIL",email:e,password:t,refresh_token:this._cache.getStore(s)||""}),{refresh_token:r,access_token:o,access_token_expire:i}=n;if(r)return this.setRefreshToken(r),o&&i?this.setAccessToken(o,i):await this._request.refreshAccessToken(),await this.refreshUserInfo(),Z(te),Z(ne,{env:this.config.env,loginType:ie.EMAIL,persistence:this.config.persistence}),new me(this.config.env);throw n.code?new Error(`邮箱登录失败: [${n.code}] ${n.message}`):new Error("邮箱登录失败")}async activate(e){return this._request.send("auth.activateEndUserMail",{token:e})}async resetPasswordWithToken(e,t){return this._request.send("auth.resetPasswordWithToken",{token:e,newPassword:t})}}class ke extends pe{async signIn(e,t){if("string"!=typeof e)throw new Error("username must be a string");"string"!=typeof t&&(t="",console.warn("password is empty"));const{refreshTokenKey:s}=this._cache.keys,n=await this._request.send("auth.signIn",{loginType:ie.USERNAME,username:e,password:t,refresh_token:this._cache.getStore(s)||""}),{refresh_token:r,access_token_expire:o,access_token:i}=n;if(r)return this.setRefreshToken(r),i&&o?this.setAccessToken(i,o):await this._request.refreshAccessToken(),await this.refreshUserInfo(),Z(te),Z(ne,{env:this.config.env,loginType:ie.USERNAME,persistence:this.config.persistence}),new me(this.config.env);throw n.code?new Error(`用户名密码登录失败: [${n.code}] ${n.message}`):new Error("用户名密码登录失败")}}class Se{constructor(e){this.config=e,this._cache=J(e.env),this._request=fe(e.env),this._onAnonymousConverted=this._onAnonymousConverted.bind(this),this._onLoginTypeChanged=this._onLoginTypeChanged.bind(this),Q(ne,this._onLoginTypeChanged)}get currentUser(){const e=this.hasLoginState();return e&&e.user||null}get loginType(){return this._cache.getStore(this._cache.keys.loginTypeKey)}anonymousAuthProvider(){return new ye(this.config)}customAuthProvider(){return new _e(this.config)}emailAuthProvider(){return new we(this.config)}usernameAuthProvider(){return new ke(this.config)}async signInAnonymously(){return new ye(this.config).signIn()}async signInWithEmailAndPassword(e,t){return new we(this.config).signIn(e,t)}signInWithUsernameAndPassword(e,t){return new ke(this.config).signIn(e,t)}async linkAndRetrieveDataWithTicket(e){this._anonymousAuthProvider||(this._anonymousAuthProvider=new ye(this.config)),Q(re,this._onAnonymousConverted);return await this._anonymousAuthProvider.linkAndRetrieveDataWithTicket(e)}async signOut(){if(this.loginType===ie.ANONYMOUS)throw new Error("匿名用户不支持登出操作");const{refreshTokenKey:e,accessTokenKey:t,accessTokenExpireKey:s}=this._cache.keys,n=this._cache.getStore(e);if(!n)return;const r=await this._request.send("auth.logout",{refresh_token:n});return this._cache.removeStore(e),this._cache.removeStore(t),this._cache.removeStore(s),Z(te),Z(ne,{env:this.config.env,loginType:ie.NULL,persistence:this.config.persistence}),r}async signUpWithEmailAndPassword(e,t){return this._request.send("auth.signUpWithEmailAndPassword",{email:e,password:t})}async sendPasswordResetEmail(e){return this._request.send("auth.sendPasswordResetEmail",{email:e})}onLoginStateChanged(e){Q(te,(()=>{const t=this.hasLoginState();e.call(this,t)}));const t=this.hasLoginState();e.call(this,t)}onLoginStateExpired(e){Q(se,e.bind(this))}onAccessTokenRefreshed(e){Q(oe,e.bind(this))}onAnonymousConverted(e){Q(re,e.bind(this))}onLoginTypeChanged(e){Q(ne,(()=>{const t=this.hasLoginState();e.call(this,t)}))}async getAccessToken(){return{accessToken:(await this._request.getAccessToken()).accessToken,env:this.config.env}}hasLoginState(){const{refreshTokenKey:e}=this._cache.keys;return this._cache.getStore(e)?new me(this.config.env):null}async isUsernameRegistered(e){if("string"!=typeof e)throw new Error("username must be a string");const{data:t}=await this._request.send("auth.isUsernameRegistered",{username:e});return t&&t.isRegistered}getLoginState(){return Promise.resolve(this.hasLoginState())}async signInWithTicket(e){return new _e(this.config).signIn(e)}shouldRefreshAccessToken(e){this._request._shouldRefreshAccessTokenHook=e.bind(this)}getUserInfo(){return this._request.send("auth.getUserInfo",{}).then((e=>e.code?e:{...e.data,requestId:e.seqId}))}getAuthHeader(){const{refreshTokenKey:e,accessTokenKey:t}=this._cache.keys,s=this._cache.getStore(e);return{"x-cloudbase-credentials":this._cache.getStore(t)+"/@@/"+s}}_onAnonymousConverted(e){const{env:t}=e.data;t===this.config.env&&this._cache.updatePersistence(this.config.persistence)}_onLoginTypeChanged(e){const{loginType:t,persistence:s,env:n}=e.data;n===this.config.env&&(this._cache.updatePersistence(s),this._cache.setStore(this._cache.keys.loginTypeKey,t))}}const ve=function(e,t){t=t||F();const s=fe(this.config.env),{cloudPath:n,filePath:r,onUploadProgress:o,fileType:i="image"}=e;return s.send("storage.getUploadMetadata",{path:n}).then((e=>{const{data:{url:a,authorization:c,token:u,fileId:h,cosFileId:l},requestId:d}=e,f={key:n,signature:c,"x-cos-meta-fileid":l,success_action_status:"201","x-cos-security-token":u};s.upload({url:a,data:f,file:r,name:n,fileType:i,onUploadProgress:o}).then((e=>{201===e.statusCode?t(null,{fileID:h,requestId:d}):t(new Error(`STORAGE_REQUEST_FAIL: ${e.data}`))})).catch((e=>{t(e)}))})).catch((e=>{t(e)})),t.promise},Te=function(e,t){t=t||F();const s=fe(this.config.env),{cloudPath:n}=e;return s.send("storage.getUploadMetadata",{path:n}).then((e=>{t(null,e)})).catch((e=>{t(e)})),t.promise},Pe=function({fileList:e},t){if(t=t||F(),!e||!Array.isArray(e))return{code:"INVALID_PARAM",message:"fileList必须是非空的数组"};for(let t of e)if(!t||"string"!=typeof t)return{code:"INVALID_PARAM",message:"fileList的元素必须是非空的字符串"};const s={fileid_list:e};return fe(this.config.env).send("storage.batchDeleteFile",s).then((e=>{e.code?t(null,e):t(null,{fileList:e.data.delete_list,requestId:e.requestId})})).catch((e=>{t(e)})),t.promise},Ae=function({fileList:e},t){t=t||F(),e&&Array.isArray(e)||t(null,{code:"INVALID_PARAM",message:"fileList必须是非空的数组"});let s=[];for(let n of e)"object"==typeof n?(n.hasOwnProperty("fileID")&&n.hasOwnProperty("maxAge")||t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是包含fileID和maxAge的对象"}),s.push({fileid:n.fileID,max_age:n.maxAge})):"string"==typeof n?s.push({fileid:n}):t(null,{code:"INVALID_PARAM",message:"fileList的元素必须是字符串"});const n={file_list:s};return fe(this.config.env).send("storage.batchGetDownloadUrl",n).then((e=>{e.code?t(null,e):t(null,{fileList:e.data.download_list,requestId:e.requestId})})).catch((e=>{t(e)})),t.promise},Ie=async function({fileID:e},t){const s=(await Ae.call(this,{fileList:[{fileID:e,maxAge:600}]})).fileList[0];if("SUCCESS"!==s.code)return t?t(s):new Promise((e=>{e(s)}));const n=fe(this.config.env);let r=s.download_url;if(r=encodeURI(r),!t)return n.download({url:r});t(await n.download({url:r}))},be=function({name:e,data:t,query:s,parse:n,search:r},o){const i=o||F();let a;try{a=t?JSON.stringify(t):""}catch(e){return Promise.reject(e)}if(!e)return Promise.reject(new Error("函数名不能为空"));const c={inQuery:s,parse:n,search:r,function_name:e,request_data:a};return fe(this.config.env).send("functions.invokeFunction",c).then((e=>{if(e.code)i(null,e);else{let t=e.data.response_data;if(n)i(null,{result:t,requestId:e.requestId});else try{t=JSON.parse(e.data.response_data),i(null,{result:t,requestId:e.requestId})}catch(e){i(new Error("response data must be json"))}}return i.promise})).catch((e=>{i(e)})),i.promise},Ee={timeout:15e3,persistence:"session"},Oe={};class Ue{constructor(e){this.config=e||this.config,this.authObj=void 0}init(e){switch(j.adapter||(this.requestClient=new j.adapter.reqClass({timeout:e.timeout||5e3,timeoutMsg:`请求在${(e.timeout||5e3)/1e3}s内未完成,已中断`})),this.config={...Ee,...e},!0){case this.config.timeout>6e5:console.warn("timeout大于可配置上限[10分钟],已重置为上限数值"),this.config.timeout=6e5;break;case this.config.timeout<100:console.warn("timeout小于可配置下限[100ms],已重置为下限数值"),this.config.timeout=100}return new Ue(this.config)}auth({persistence:e}={}){if(this.authObj)return this.authObj;const t=e||j.adapter.primaryStorage||Ee.persistence;var s;return t!==this.config.persistence&&(this.config.persistence=t),function(e){const{env:t}=e;z[t]=new W(e),V[t]=new W({...e,persistence:"local"})}(this.config),s=this.config,de[s.env]=new le(s),this.authObj=new Se(this.config),this.authObj}on(e,t){return Q.apply(this,[e,t])}off(e,t){return ee.apply(this,[e,t])}callFunction(e,t){return be.apply(this,[e,t])}deleteFile(e,t){return Pe.apply(this,[e,t])}getTempFileURL(e,t){return Ae.apply(this,[e,t])}downloadFile(e,t){return Ie.apply(this,[e,t])}uploadFile(e,t){return ve.apply(this,[e,t])}getUploadMetadata(e,t){return Te.apply(this,[e,t])}registerExtension(e){Oe[e.name]=e}async invokeExtension(e,t){const s=Oe[e];if(!s)throw Error(`扩展${e} 必须先注册`);return await s.invoke(t,this)}useAdapters(e){const{adapter:t,runtime:s}=$(e)||{};t&&(j.adapter=t),s&&(j.runtime=s)}}const Ce=new Ue;function xe(e,t,s){void 0===s&&(s={});var n=/\?/.test(t),r="";for(var o in s)""===r?!n&&(t+="?"):r+="&",r+=o+"="+encodeURIComponent(s[o]);return/^http(s)?:\/\//.test(t+=r)?t:""+e+t}class De{post(e){const{url:t,data:s,headers:n}=e;return new Promise(((e,r)=>{U.request({url:xe("https:",t),data:s,method:"POST",header:n,success(t){e(t)},fail(e){r(e)}})}))}upload(e){return new Promise(((t,s)=>{const{url:n,file:r,data:o,headers:i,fileType:a}=e,c=U.uploadFile({url:xe("https:",n),name:"file",formData:Object.assign({},o),filePath:r,fileType:a,header:i,success(e){const s={statusCode:e.statusCode,data:e.data||{}};200===e.statusCode&&o.success_action_status&&(s.statusCode=parseInt(o.success_action_status,10)),t(s)},fail(e){u&&"mp-alipay"===h&&console.warn("支付宝小程序开发工具上传腾讯云时无法准确判断是否上传成功,请使用真机测试"),s(new Error(e.errMsg||"uploadFile:fail"))}});"function"==typeof e.onUploadProgress&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((t=>{e.onUploadProgress({loaded:t.totalBytesSent,total:t.totalBytesExpectedToSend})}))}))}}const Re={setItem(e,t){U.setStorageSync(e,t)},getItem:e=>U.getStorageSync(e),removeItem(e){U.removeStorageSync(e)},clear(){U.clearStorageSync()}};const qe={genAdapter:function(){return{root:{},reqClass:De,localStorage:Re,primaryStorage:"local"}},isMatch:function(){return!0},runtime:"uni_app"};Ce.useAdapters(qe);const Fe=Ce,Le=Fe.init;function Ne(){return{token:U.getStorageSync("uni_id_token")||U.getStorageSync("uniIdToken"),tokenExpired:U.getStorageSync("uni_id_token_expired")}}function Me(){if(!u||"h5"!==h)return;uni.getStorageSync("__LAST_DCLOUD_APPID")!==p&&(uni.setStorageSync("__LAST_DCLOUD_APPID",p),console.warn("检测到当前项目与上次运行到此端口的项目不一致,自动清理uni-id保存的token信息(仅开发调试时生效)"),U.removeStorageSync("uni_id_token"),U.removeStorageSync("uniIdToken"),U.removeStorageSync("uni_id_token_expired"))}Fe.init=function(e){e.env=e.spaceId;const t=Le.call(this,e);t.config.provider="tencent",t.config.spaceId=e.spaceId;const s=t.auth;return t.auth=function(e){const t=s.call(this,e);return["linkAndRetrieveDataWithTicket","signInAnonymously","signOut","getAccessToken","getLoginState","signInWithTicket","getUserInfo"].forEach((e=>{t[e]=T(t[e]).bind(t)})),t},t.customAuth=t.auth,t};class $e extends C{getAccessToken(){return new Promise(((e,t)=>{const s="Anonymous_Access_token";this.setAccessToken(s),e(s)}))}setupRequest(e,t){const s=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),n={"Content-Type":"application/json"};"auth"!==t&&(s.token=this.accessToken,n["x-basement-token"]=this.accessToken),n["x-serverless-sign"]=O.sign(s,this.config.clientSecret);const r=E();n["x-client-info"]=JSON.stringify(r);const{token:o}=Ne();return n["x-client-token"]=o,{url:this.config.requestUrl,method:"POST",data:s,dataType:"json",header:JSON.parse(JSON.stringify(n))}}uploadFileToOSS({url:e,formData:t,name:s,filePath:n,fileType:r,onUploadProgress:o}){return new Promise(((i,a)=>{const c=this.adapter.uploadFile({url:e,formData:t,name:s,filePath:n,fileType:r,success(e){e&&e.statusCode<400?i(e):a(new P({code:"UPLOAD_FAILED",message:"文件上传失败"}))},fail(e){a(new P({code:e.code||"UPLOAD_FAILED",message:e.message||e.errMsg||"文件上传失败"}))}});"function"==typeof o&&c&&"function"==typeof c.onProgressUpdate&&c.onProgressUpdate((e=>{o({loaded:e.totalBytesSent,total:e.totalBytesExpectedToSend})}))}))}uploadFile({filePath:e,cloudPath:t,fileType:s="image",onUploadProgress:n}){if(!t)throw new P({code:"CLOUDPATH_REQUIRED",message:"cloudPath不可为空"});let r;return this.getOSSUploadOptionsFromPath({cloudPath:t}).then((t=>{const{url:o,formData:i,name:a}=t.result;r=t.result.fileUrl;const c={url:o,formData:i,name:a,filePath:e,fileType:s};return this.uploadFileToOSS(Object.assign({},c,{onUploadProgress:n}))})).then((()=>this.reportOSSUpload({cloudPath:t}))).then((t=>new Promise(((s,n)=>{t.success?s({success:!0,filePath:e,fileID:r}):n(new P({code:"UPLOAD_FAILED",message:"文件上传失败"}))}))))}}const je={init(e){const t=new $e(e),s={signInAnonymously:function(){return t.authorize()},getLoginState:function(){return Promise.resolve(!1)}};return t.auth=function(){return s},t.customAuth=t.auth,t}};let Ke;function Be({data:e}){Ke||(Ke=E());const t=JSON.parse(JSON.stringify(e||{}));if(Object.assign(t,{clientInfo:Ke}),!t.uniIdToken){const{token:e}=Ne();e&&(t.uniIdToken=e)}return t}function He({name:e,data:t}){const{localAddress:s,localPort:n}=this,r={aliyun:"aliyun",tencent:"tcb"}[this.config.provider],o=this.config.spaceId,i=`http://${s}:${n}/system/check-function`,a=`http://${s}:${n}/cloudfunctions/${e}`;return new Promise(((t,s)=>{U.request({method:"POST",url:i,data:{name:e,platform:h,provider:r,spaceId:o},timeout:3e3,success(e){t(e)},fail(){t({data:{code:"NETWORK_ERROR",message:"连接本地调试服务失败,请检查客户端是否和主机在同一局域网下,自动切换为已部署的云函数。"}})}})})).then((({data:e}={})=>{const{code:t,message:s}=e||{};return{code:0===t?0:t||"SYS_ERR",message:s||"SYS_ERR"}})).then((({code:s,message:n})=>{if(0!==s){switch(s){case"MODULE_ENCRYPTED":console.error(`此云函数(${e})依赖加密公共模块不可本地调试,自动切换为云端已部署的云函数`);break;case"FUNCTION_ENCRYPTED":console.error(`此云函数(${e})已加密不可本地调试,自动切换为云端已部署的云函数`);break;case"ACTION_ENCRYPTED":console.error(n||"需要访问加密的uni-clientDB-action,自动切换为云端环境");break;case"NETWORK_ERROR":{const e="连接本地调试服务失败,请检查客户端是否和主机在同一局域网下";throw console.error(e),new Error(e)}case"SWITCH_TO_CLOUD":break;default:{const e=`检测本地调试服务出现错误:${n},请检查网络环境或重启客户端再试`;throw console.error(e),new Error(e)}}return this._originCallFunction({name:e,data:t})}return new Promise(((e,s)=>{const n=Be.call(this,{data:t});U.request({method:"POST",url:a,data:{provider:r,platform:h,param:n},success:({statusCode:t,data:n}={})=>!t||t>=400?s(new P({code:n.code||"SYS_ERR",message:n.message||"request:fail"})):e({result:n}),fail(e){s(new P({code:e.code||e.errCode||"SYS_ERR",message:e.message||e.errMsg||"request:fail"}))}})}))}))}const We=[{rule:/fc_function_not_found|FUNCTION_NOT_FOUND/,content:",云函数[{functionName}]在云端不存在,请检查此云函数名称是否正确以及该云函数是否已上传到服务空间",mode:"append"}];var ze=/[\\^$.*+?()[\]{}|]/g,Ve=RegExp(ze.source);function Je(e,t,s){return e.replace(new RegExp((n=t)&&Ve.test(n)?n.replace(ze,"\\$&"):n,"g"),s);var n}function Ye({functionName:e,result:t,logPvd:s}){if(this.config.useDebugFunction&&t&&t.requestId){const n=JSON.stringify({spaceId:this.config.spaceId,functionName:e,requestId:t.requestId});console.log(`[${s}-request]${n}[/${s}-request]`)}}function Xe(e){const t=e.callFunction,s=function(s){const n=s.name;s.data=Be.call(e,{data:s.data});const r={aliyun:"aliyun",tencent:"tcb"}[this.config.provider];return t.call(this,s).then((e=>(Ye.call(this,{functionName:n,result:e,logPvd:r}),Promise.resolve(e))),(e=>(Ye.call(this,{functionName:n,result:e,logPvd:r}),e&&e.message&&(e.message=function({message:e="",extraInfo:t={},formatter:s=[]}={}){for(let n=0;n<s.length;n++){const{rule:r,content:o,mode:i}=s[n],a=e.match(r);if(!a)continue;let c=o;for(let e=1;e<a.length;e++)c=Je(c,`{$${e}}`,a[e]);for(const e in t)c=Je(c,`{${e}}`,t[e]);switch(i){case"replace":return c;case"append":default:return e+c}}return e}({message:`[${s.name}]: ${e.message}`,formatter:We,extraInfo:{functionName:n}})),Promise.reject(e))))};e.callFunction=function(t){let n;return u&&e.debugInfo&&!e.debugInfo.forceRemote&&d?(e._originCallFunction||(e._originCallFunction=s),n=He.call(this,t)):n=s.call(this,t),Object.defineProperty(n,"result",{get:()=>(console.warn("当前返回结果为Promise类型,不可直接访问其result属性,详情请参考:https://uniapp.dcloud.net.cn/uniCloud/faq?id=promise"),{})}),n}}const Ge=Symbol("CLIENT_DB_INTERNAL");function Qe(e,t){return e.then="DoNotReturnProxyWithAFunctionNamedThen",e._internalType=Ge,e.__ob__=void 0,new Proxy(e,{get:(e,s,n)=>s in e||"string"!=typeof s?e[s]:t.get(e,s,n)})}function Ze(e){switch(o(e)){case"array":return e.map((e=>Ze(e)));case"object":return e._internalType===Ge||Object.keys(e).forEach((t=>{e[t]=Ze(e[t])})),e;case"regexp":return{$regexp:{source:e.source,flags:e.flags}};case"date":return{$date:e.toISOString()};default:return e}}function et(e){e.database=function(t){if(t&&Object.keys(t).length>0)return e.init(t).database();if(this._database)return this._database;const s={};let n={};function r({action:t,command:r,multiCommand:o}){return S(v("database","invoke")).then((()=>e.callFunction({name:"DCloud-clientDB",data:{action:t,command:r,multiCommand:o}}))).then((e=>{const{code:t,message:r,token:o,tokenExpired:i,systemInfo:c=[]}=e.result;if(c)for(let e=0;e<c.length;e++){const{level:t,message:s,detail:n}=c[e],r=console["app-plus"===h&&"warn"===t?"error":t]||console.log;let o="[System Info]"+s;n&&(o=`${o}\n详细信息:${n}`),r(o)}if(t){const e=new a(r,t);return n.error&&n.error.forEach((t=>{t(e)})),Promise.reject(e)}o&&i&&(!function({token:e,tokenExpired:t}={}){e&&U.setStorageSync("uni_id_token",e),t&&U.setStorageSync("uni_id_token_expired",t)}({token:o,tokenExpired:i}),s.refreshToken&&s.refreshToken.forEach((e=>{e({token:o,tokenExpired:i})})),n.refreshToken&&n.refreshToken.forEach((e=>{e({token:o,tokenExpired:i})})));const u=e.result.affectedDocs;return"number"==typeof u&&Object.defineProperty(e.result,"affectedDocs",{get:()=>(console.warn("affectedDocs不再推荐使用,请使用inserted/deleted/updated/data.length替代"),u)}),S(v("database","success"),e).then((()=>S(v("database","complete"),e))).then((()=>Promise.resolve(e)))}),(e=>{const t=new a(e.message,e.code||"SYSTEM_ERROR");return n.error&&n.error.forEach((e=>{e(t)})),/fc_function_not_found|FUNCTION_NOT_FOUND/g.test(e.message)&&console.warn("clientDB未初始化,请在web控制台保存一次schema以开启clientDB"),S(v("database","fail"),e).then((()=>S(v("database","complete"),e))).then((()=>Promise.reject(e)))}))}this.isDefault&&(n=m("_globalUniCloudDatabaseCallback"));class o{constructor(e,t){this.content=e,this.prevStage=t,this.udb=null}toJSON(){let e=this;const t=[e.content];for(;e.prevStage;)e=e.prevStage,t.push(e.content);return{$db:t.reverse().map((e=>({$method:e.$method,$param:Ze(e.$param)})))}}getAction(){const e=this.toJSON().$db.find((e=>"action"===e.$method));return e&&e.$param&&e.$param[0]}getCommand(){return{$db:this.toJSON().$db.filter((e=>"action"!==e.$method))}}get useAggregate(){let e=this,t=!1;for(;e.prevStage;){e=e.prevStage;const s=e.content.$method;if("aggregate"===s||"pipeline"===s){t=!0;break}}return t}get count(){if(!this.useAggregate)return function(){return this._send("count",Array.from(arguments))};const e=this;return function(){return u({$method:"count",$param:Ze(Array.from(arguments))},e)}}get(){return this._send("get",Array.from(arguments))}add(){return this._send("add",Array.from(arguments))}remove(){return this._send("remove",Array.from(arguments))}update(){return this._send("update",Array.from(arguments))}end(){return this._send("end",Array.from(arguments))}set(){throw new Error("clientDB禁止使用set方法")}get multiSend(){}_send(e,t){const s=this.getAction(),n=this.getCommand();return n.$db.push({$method:e,$param:Ze(t)}),r({action:s,command:n})}}const i=["db.Geo","db.command","command.aggregate"];function c(e,t){return i.indexOf(`${e}.${t}`)>-1}function u(e,t){return Qe(new o(e,t),{get(e,t){let s="db";return e&&e.content&&(s=e.content.$method),c(s,t)?u({$method:t},e):function(){return u({$method:t,$param:Ze(Array.from(arguments))},e)}}})}function l({path:e,method:t}){return class{constructor(){this.param=Array.from(arguments)}toJSON(){return{$newDb:[...e.map((e=>({$method:e}))),{$method:t,$param:this.param}]}}}}const d={auth:{on:(e,t)=>{s[e]=s[e]||[],s[e].indexOf(t)>-1||s[e].push(t)},off:(e,t)=>{s[e]=s[e]||[];const n=s[e].indexOf(t);-1!==n&&s[e].splice(n,1)}},on:(e,t)=>{n[e]=n[e]||[],n[e].indexOf(t)>-1||n[e].push(t)},off:(e,t)=>{n[e]=n[e]||[];const s=n[e].indexOf(t);-1!==s&&n[e].splice(s,1)},env:Qe({},{get:(e,t)=>({$env:t})}),Geo:Qe({},{get:(e,t)=>l({path:["Geo"],method:t})}),getCloudEnv:function(e){if("string"!=typeof e||!e.trim())throw new Error("getCloudEnv参数错误");return{$env:e.replace("$cloudEnv_","")}},multiSend(){const e=Array.from(arguments);return r({multiCommand:e.map((e=>{const t=e.getAction(),s=e.getCommand();if("getTemp"!==s.$db[s.$db.length-1].$method)throw new Error("multiSend只支持子命令内使用getTemp");return{action:t,command:s}}))}).then((t=>{for(let s=0;s<e.length;s++){const n=e[s];n.udb&&"function"==typeof n.udb.setResult&&n.udb.setResult(t.result.dataList[s])}return Promise.resolve(t)}),(t=>{for(let s=0;s<e.length;s++){const n=e[s];n.udb&&"function"==typeof n.udb.setResult&&n.udb.setResult(t)}return Promise.reject(t)}))},get serverDate(){return l({path:[],method:"serverDate"})},get RegExp(){return l({path:[],method:"RegExp"})}},f=Qe(d,{get:(e,t)=>c("db",t)?u({$method:t}):function(){return u({$method:t,$param:Ze(Array.from(arguments))})}});return this._database=f,f}}let tt;const st="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",nt=/^(?:[A-Za-z\d+/]{4})*?(?:[A-Za-z\d+/]{2}(?:==)?|[A-Za-z\d+/]{3}=?)?$/;function rt(){const e=Ne().token||"",t=e.split(".");if(!e||3!==t.length)return{uid:null,role:[],permission:[],tokenExpired:0};let s;try{s=JSON.parse((n=t[1],decodeURIComponent(tt(n).split("").map((function(e){return"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)})).join(""))))}catch(e){throw new Error("获取当前用户信息出错,详细错误信息为:"+e.message)}var n;return s.tokenExpired=1e3*s.exp,delete s.exp,delete s.iat,s}tt="function"!=typeof atob?function(e){if(e=String(e).replace(/[\t\n\f\r ]+/g,""),!nt.test(e))throw new Error("Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.");var t;e+="==".slice(2-(3&e.length));for(var s,n,r="",o=0;o<e.length;)t=st.indexOf(e.charAt(o++))<<18|st.indexOf(e.charAt(o++))<<12|(s=st.indexOf(e.charAt(o++)))<<6|(n=st.indexOf(e.charAt(o++))),r+=64===s?String.fromCharCode(t>>16&255):64===n?String.fromCharCode(t>>16&255,t>>8&255):String.fromCharCode(t>>16&255,t>>8&255,255&t);return r}:atob;var ot=t(s((function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const s="chooseAndUploadFile:ok",n="chooseAndUploadFile:fail";function r(e,t){return e.tempFiles.forEach(((e,s)=>{e.name||(e.name=e.path.substring(e.path.lastIndexOf("/")+1)),t&&(e.fileType=t),e.cloudPath=Date.now()+"_"+s+e.name.substring(e.name.lastIndexOf("."))})),e.tempFilePaths||(e.tempFilePaths=e.tempFiles.map((e=>e.path))),e}function o(e,t,{onChooseFile:n,onUploadProgress:r}){return t.then((e=>{if(n){const t=n(e);if(void 0!==t)return Promise.resolve(t).then((t=>void 0===t?e:t))}return e})).then((t=>!1===t?{errMsg:s,tempFilePaths:[],tempFiles:[]}:function(e,t,n=5,r){(t=Object.assign({},t)).errMsg=s;const o=t.tempFiles,i=o.length;let a=0;return new Promise((s=>{for(;a<n;)c();function c(){const n=a++;if(n>=i)return void(!o.find((e=>!e.url&&!e.errMsg))&&s(t));const u=o[n];e.uploadFile({filePath:u.path,cloudPath:u.cloudPath,fileType:u.fileType,onUploadProgress(e){e.index=n,e.tempFile=u,e.tempFilePath=u.path,r&&r(e)}}).then((e=>{u.url=e.fileID,n<i&&c()})).catch((e=>{u.errMsg=e.errMsg||e.message,n<i&&c()}))}}))}(e,t,5,r)))}t.initChooseAndUploadFile=function(e){return function(t={type:"all"}){return"image"===t.type?o(e,function(e){const{count:t,sizeType:s,sourceType:o=["album","camera"],extension:i}=e;return new Promise(((e,a)=>{uni.chooseImage({count:t,sizeType:s,sourceType:o,extension:i,success(t){e(r(t,"image"))},fail(e){a({errMsg:e.errMsg.replace("chooseImage:fail",n)})}})}))}(t),t):"video"===t.type?o(e,function(e){const{camera:t,compressed:s,maxDuration:o,sourceType:i=["album","camera"],extension:a}=e;return new Promise(((e,c)=>{uni.chooseVideo({camera:t,compressed:s,maxDuration:o,sourceType:i,extension:a,success(t){const{tempFilePath:s,duration:n,size:o,height:i,width:a}=t;e(r({errMsg:"chooseVideo:ok",tempFilePaths:[s],tempFiles:[{name:t.tempFile&&t.tempFile.name||"",path:s,size:o,type:t.tempFile&&t.tempFile.type||"",width:a,height:i,duration:n,fileType:"video",cloudPath:""}]},"video"))},fail(e){c({errMsg:e.errMsg.replace("chooseVideo:fail",n)})}})}))}(t),t):o(e,function(e){const{count:t,extension:s}=e;return new Promise(((e,o)=>{let i=uni.chooseFile;if("undefined"!=typeof wx&&"function"==typeof wx.chooseMessageFile&&(i=wx.chooseMessageFile),"function"!=typeof i)return o({errMsg:n+" 请指定 type 类型,该平台仅支持选择 image 或 video。"});i({type:"all",count:t,extension:s,success(t){e(r(t))},fail(e){o({errMsg:e.errMsg.replace("chooseFile:fail",n)})}})}))}(t),t)}}})));const it="manual";function at(e){return{props:{localdata:{type:Array,default:()=>[]},options:{type:[Object,Array],default:()=>({})},spaceInfo:{type:Object,default:()=>({})},collection:{type:[String,Array],default:""},action:{type:String,default:""},field:{type:String,default:""},orderby:{type:String,default:""},where:{type:[String,Object],default:""},pageData:{type:String,default:"add"},pageCurrent:{type:Number,default:1},pageSize:{type:Number,default:20},getcount:{type:[Boolean,String],default:!1},gettree:{type:[Boolean,String],default:!1},gettreepath:{type:[Boolean,String],default:!1},startwith:{type:String,default:""},limitlevel:{type:Number,default:10},groupby:{type:String,default:""},groupField:{type:String,default:""},distinct:{type:[Boolean,String],default:!1},foreignKey:{type:String,default:""},loadtime:{type:String,default:"auto"},manual:{type:Boolean,default:!1}},data:()=>({mixinDatacomLoading:!1,mixinDatacomHasMore:!1,mixinDatacomResData:[],mixinDatacomErrorMessage:"",mixinDatacomPage:{}}),created(){this.mixinDatacomPage={current:this.pageCurrent,size:this.pageSize,count:0},this.$watch((()=>{var e=[];return["pageCurrent","pageSize","localdata","collection","action","field","orderby","where","getont","getcount","gettree","groupby","groupField","distinct"].forEach((t=>{e.push(this[t])})),e}),((e,t)=>{if(this.loadtime===it)return;let s=!1;const n=[];for(let r=2;r<e.length;r++)e[r]!==t[r]&&(n.push(e[r]),s=!0);e[0]!==t[0]&&(this.mixinDatacomPage.current=this.pageCurrent),this.mixinDatacomPage.size=this.pageSize,this.onMixinDatacomPropsChange(s,n)}))},methods:{onMixinDatacomPropsChange(e,t){},mixinDatacomEasyGet({getone:e=!1,success:t,fail:s}={}){this.mixinDatacomLoading||(this.mixinDatacomLoading=!0,this.mixinDatacomErrorMessage="",this.mixinDatacomGet().then((s=>{this.mixinDatacomLoading=!1;const{data:n,count:r}=s.result;this.getcount&&(this.mixinDatacomPage.count=r),this.mixinDatacomHasMore=n.length<this.pageSize;const o=e?n.length?n[0]:void 0:n;this.mixinDatacomResData=o,t&&t(o)})).catch((e=>{this.mixinDatacomLoading=!1,this.mixinDatacomErrorMessage=e,s&&s(e)})))},mixinDatacomGet(t={}){let s=e.database(this.spaceInfo);const n=t.action||this.action;n&&(s=s.action(n));const r=t.collection||this.collection;s=Array.isArray(r)?s.collection(...r):s.collection(r);const o=t.where||this.where;o&&Object.keys(o).length&&(s=s.where(o));const i=t.field||this.field;i&&(s=s.field(i));const a=t.foreignKey||this.foreignKey;a&&(s=s.foreignKey(a));const c=t.groupby||this.groupby;c&&(s=s.groupBy(c));const u=t.groupField||this.groupField;u&&(s=s.groupField(u));!0===(void 0!==t.distinct?t.distinct:this.distinct)&&(s=s.distinct());const h=t.orderby||this.orderby;h&&(s=s.orderBy(h));const l=void 0!==t.pageCurrent?t.pageCurrent:this.mixinDatacomPage.current,d=void 0!==t.pageSize?t.pageSize:this.mixinDatacomPage.size,f=void 0!==t.getcount?t.getcount:this.getcount,p=void 0!==t.gettree?t.gettree:this.gettree,g=void 0!==t.gettreepath?t.gettreepath:this.gettreepath,m={getCount:f},y={limitLevel:void 0!==t.limitlevel?t.limitlevel:this.limitlevel,startWith:void 0!==t.startwith?t.startwith:this.startwith};return p&&(m.getTree=y),g&&(m.getTreePath=y),s=s.skip(d*(l-1)).limit(d).get(m),s}}}}async function ct(e,t){const s=`http://${e}:${t}/system/ping`;try{const e=await(n={url:s,timeout:500},new Promise(((e,t)=>{U.request({...n,success(t){e(t)},fail(e){t(e)}})})));return!(!e.data||0!==e.data.code)}catch(e){return!1}var n}let ut=new class{init(e){let t={};const s=!1!==e.debugFunction&&u&&("h5"===h&&navigator.userAgent.indexOf("HBuilderX")>0||"app-plus"===h);switch(e.provider){case"tencent":t=Fe.init(Object.assign(e,{useDebugFunction:s}));break;case"aliyun":t=x.init(Object.assign(e,{useDebugFunction:s}));break;case"private":t=je.init(Object.assign(e,{useDebugFunction:s}));break;default:throw new Error("未提供正确的provider参数")}const n=l;u&&n&&!n.code&&(t.debugInfo=n);let r=Promise.resolve();var o;o=1,r=new Promise(((e,t)=>{setTimeout((()=>{e()}),o)})),t.isReady=!1,t.isDefault=!1;const i=t.auth();t.initUniCloud=r.then((()=>i.getLoginState())).then((e=>e?Promise.resolve():i.signInAnonymously())).then((()=>{if(!u)return Promise.resolve();if(u&&t.debugInfo){const{address:e,servePort:s}=t.debugInfo;return async function(e,t){let s;for(let n=0;n<e.length;n++){const r=e[n];if(await ct(r,t)){s=r;break}}return{address:s,port:t}}(e,s)}})).then((({address:e,port:s}={})=>{if(!u)return Promise.resolve();if(e)t.localAddress=e,t.localPort=s;else if(t.debugInfo){const e=console["app-plus"===h?"error":"warn"];let s="";"remote"===t.debugInfo.initialLaunchType?(t.debugInfo.forceRemote=!0,s="当前客户端和HBuilderX不在同一局域网下(或其他网络原因无法连接HBuilderX),uniCloud本地调试服务不对当前客户端生效。\n- 如果不使用uniCloud本地调试服务,请直接忽略此信息。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs"):s="无法连接uniCloud本地调试服务,请检查当前客户端是否与主机在同一局域网下。\n- 如需使用uniCloud本地调试服务,请将客户端与主机连接到同一局域网下并重新运行到客户端。\n- 如果在HBuilderX开启的状态下切换过网络环境,请重启HBuilderX后再试\n- 检查系统防火墙是否拦截了HBuilderX自带的nodejs","h5"===h&&(s+="\n- 部分浏览器开启节流模式之后访问本地地址受限,请检查是否启用了节流模式"),e(s)}})).then((()=>{Me(),t.isReady=!0})),Xe(t),function(e){const t=e.uploadFile;e.uploadFile=function(e){let s;return s=this.isReady?Promise.resolve():this.initUniCloud,s.then((()=>t.call(this,e)))}}(t),et(t),function(e){e.getCurrentUserInfo=rt,e.chooseAndUploadFile=ot.initChooseAndUploadFile(e),Object.assign(e,{get mixinDatacom(){return at(e)}})}(t);return["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","chooseAndUploadFile"].forEach((e=>{t[e]&&(t[e]=T(t[e],e))})),t.init=this.init,t}};(()=>{{const e=d;let t={};if(1===e.length)t=e[0],ut=ut.init(t),ut.isDefault=!0;else{const t=["auth","callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile","database","getCurrentUSerInfo"];let s;s=e&&e.length>0?"应用有多个服务空间,请通过uniCloud.init方法指定要使用的服务空间":f?"应用未关联服务空间,请在uniCloud目录右键关联服务空间":"uni-app cli项目内使用uniCloud需要使用HBuilderX的运行菜单运行项目,且需要在uniCloud目录关联服务空间",t.forEach((e=>{ut[e]=function(){return console.error(s),Promise.reject(new P({code:"SYS_ERR",message:s}))}}))}Object.assign(ut,{get mixinDatacom(){return at(ut)}}),ut.addInterceptor=w,ut.removeInterceptor=k,u&&"h5"===h&&(window.uniCloud=ut)}})();var ht=ut;export default ht;
|