diff --git a/packages/uni-app-plus/dist/index.js b/packages/uni-app-plus/dist/index.js
index b7e6b6352ca0412e9a44fc6630441e92ca3c5c91..c0631e1b2d9d889d78825dda68a85116fe764ebd 100644
--- a/packages/uni-app-plus/dist/index.js
+++ b/packages/uni-app-plus/dist/index.js
@@ -1359,7 +1359,7 @@ function parseBaseComponent (vueComponentOptions, {
}
},
detached () {
- this.$vm.$destroy();
+ this.$vm && this.$vm.$destroy();
}
},
pageLifetimes: {
diff --git a/packages/uni-app-plus/dist/service.runtime.esm.js b/packages/uni-app-plus/dist/service.runtime.esm.js
index 569e529b581e66e9ccc6971db5419190f5c7a04c..e79e649e2f7d9216471e86afa8d2d8cffa30e497 100644
--- a/packages/uni-app-plus/dist/service.runtime.esm.js
+++ b/packages/uni-app-plus/dist/service.runtime.esm.js
@@ -5639,8 +5639,10 @@ function insertBefore() {
}
-function removeChild() {
-
+function removeChild(node, child) {
+ if (child && child._$vd) {
+ child._$vd.removeElement(child);
+ }
}
function appendChild() {
diff --git a/packages/uni-mp-baidu/dist/index.js b/packages/uni-mp-baidu/dist/index.js
index e84bf9e13e36ee79e6032eda5d72727543de0818..8a0c8464a1e5af74fbead9fffee48989c4dd6e13 100644
--- a/packages/uni-mp-baidu/dist/index.js
+++ b/packages/uni-mp-baidu/dist/index.js
@@ -1493,7 +1493,7 @@ function parseBaseComponent (vueComponentOptions, {
}
},
detached () {
- this.$vm.$destroy();
+ this.$vm && this.$vm.$destroy();
}
},
pageLifetimes: {
diff --git a/packages/uni-mp-qq/dist/index.js b/packages/uni-mp-qq/dist/index.js
index 2c5778c9ab8e881ec87b646c9228032df7779af4..5e8389121e58523a62389773a576784409296d9e 100644
--- a/packages/uni-mp-qq/dist/index.js
+++ b/packages/uni-mp-qq/dist/index.js
@@ -1418,7 +1418,7 @@ function parseBaseComponent (vueComponentOptions, {
}
},
detached () {
- this.$vm.$destroy();
+ this.$vm && this.$vm.$destroy();
}
},
pageLifetimes: {
diff --git a/packages/uni-mp-toutiao/dist/index.js b/packages/uni-mp-toutiao/dist/index.js
index b63dcc32135b9355c07e0430db6b9eecf1293b30..7a9b2565a1dbcc3253092d7c0f392be48e5efbe7 100644
--- a/packages/uni-mp-toutiao/dist/index.js
+++ b/packages/uni-mp-toutiao/dist/index.js
@@ -1583,7 +1583,7 @@ function parseBaseComponent (vueComponentOptions, {
}
},
detached () {
- this.$vm.$destroy();
+ this.$vm && this.$vm.$destroy();
}
},
pageLifetimes: {
diff --git a/packages/uni-mp-weixin/dist/index.js b/packages/uni-mp-weixin/dist/index.js
index 2e0e5d62e43d72b64ca9a19d0ddcda5bc4c66324..2aac3bf6dc66ba1777f697e86ef4c8c29932a4d8 100644
--- a/packages/uni-mp-weixin/dist/index.js
+++ b/packages/uni-mp-weixin/dist/index.js
@@ -1371,7 +1371,7 @@ function parseBaseComponent (vueComponentOptions, {
}
},
detached () {
- this.$vm.$destroy();
+ this.$vm && this.$vm.$destroy();
}
},
pageLifetimes: {
diff --git a/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js b/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js
index 9260cfe7a83b6f204a835a92523c3d00e0f3487f..00e7dbfe705d0af113792d66977afea500b4e3b1 100644
--- a/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-app-plus-extra.view.spec.js
@@ -16,29 +16,29 @@ describe('codegen', () => {
it('generate directive', () => {
assertCodegen(
'
',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}})}`
+ `with(this){return _c('p',{attrs:{"_i":0}})}`
)
})
it('generate v-for directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_l((_$g(1,'f')),function(item,$10,$20,$30){return [_c('v-uni-view',{key:item['k0'],attrs:{"_i":("2-"+$30)}}),_c('v-uni-view',{key:item['k1'],attrs:{"_i":("3-"+$30)}})]})],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_l((_$g(1,'f')),function(item,$10,$20,$30){return [_c('div',{key:item['k0'],attrs:{"_i":("2-"+$30)}}),_c('div',{key:item['k1'],attrs:{"_i":("3-"+$30)}})]})],2)}`
)
assertCodegen(
'
',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_l((_$g(1,'f')),function(item,$10,$20,$30){return [(_$g(("2-"+$30),'i'))?_c('v-uni-label',{key:item['k0'],attrs:{"_i":("2-"+$30)}}):_e()]})],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_l((_$g(1,'f')),function(item,$10,$20,$30){return [(_$g(("2-"+$30),'i'))?_c('span',{key:item['k0'],attrs:{"_i":("2-"+$30)}}):_e()]})],2)}`
)
})
it('generate events with multiple statements', () => {
assertCodegen(
'A{{ d | e | f }}B{{text}}C
',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_v("A"+(_$g(0,'t0'))+"B"+(_$g(0,'t1'))+"C")])}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_v("A"+(_$g(0,'t0'))+"B"+(_$g(0,'t1'))+"C")])}`
)
})
it('generate slot fallback content', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_t("default",[_c('v-uni-view',{attrs:{"_i":2}},[_v((_$g(2,'t0')))])],{"_i":1})],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_t("default",[_c('div',{attrs:{"_i":2}},[_v((_$g(2,'t0')))])],{"_i":1})],2)}`
)
})
it('generate v-slot', () => {
@@ -60,14 +60,14 @@ describe('codegen', () => {
it('generate wxs props', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{wxsProps:{"change:prop":"pos"},attrs:{"change:prop":swipe.sizeReady,"prop":_$gc(0,'change:pos'),"_i":0},on:{"touchstart":function($event){$event = $handleWxsEvent($event);swipe.touchstart($event, $getComponentDescriptor())},"touchmove":function($event){$event = $handleWxsEvent($event);swipe.touchmove($event, $getComponentDescriptor())},"touchend":function($event){$event = $handleWxsEvent($event);swipe.touchend($event, $getComponentDescriptor())},"change":function($event){return $handleViewEvent($event)}}})}`
+ `with(this){return _c('p',{wxsProps:{"change:prop":"pos"},attrs:{"change:prop":swipe.sizeReady,"prop":_$gc(0,'change:pos'),"_i":0},on:{"touchstart":function($event){$event = $handleWxsEvent($event);swipe.touchstart($event, $getComponentDescriptor())},"touchmove":function($event){$event = $handleWxsEvent($event);swipe.touchmove($event, $getComponentDescriptor())},"touchend":function($event){$event = $handleWxsEvent($event);swipe.touchend($event, $getComponentDescriptor())},"change":function($event){return $handleViewEvent($event)}}})}`
)
})
// TODO 后续优化dataset
// it('generate dataset', () => {
// assertCodegen(
// '',
- // `with(this){return _c('v-uni-view',{attrs:{"_i":0}})}`
+ // `with(this){return _c('div',{attrs:{"_i":0}})}`
// )
// })
it('generate dataset', () => {
diff --git a/packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js b/packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js
index e5a068fe526d4929d6a9bfbfb66c67b897945867..a5a238df2e5dde3a2e27a0ee8c1e10c2fdf02964 100644
--- a/packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js
+++ b/packages/uni-template-compiler/__tests__/compiler-app-plus.view.spec.js
@@ -15,140 +15,140 @@ describe('codegen', () => {
it('generate directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}})}`
+ `with(this){return _c('p',{attrs:{"_i":0}})}`
)
// extra
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}})}`
+ `with(this){return _c('p',{attrs:{"_i":0}})}`
)
})
it('generate filters', () => {
assertCodegen(
'{{ d | e | f }}
',
- `with(this){return _c('v-uni-view',{attrs:{"id":_$g(0,'a-id'),"_i":0}},[_v((_$g(0,'t0')))])}`
+ `with(this){return _c('div',{attrs:{"id":_$g(0,'a-id'),"_i":0}},[_v((_$g(0,'t0')))])}`
)
})
it('generate filters with no arguments', () => {
assertCodegen(
'{{ d | e() }}
',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_v((_$g(0,'t0')))])}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_v((_$g(0,'t0')))])}`
)
})
it('generate v-for directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,$10,$20,$30){return _c('v-uni-view',{key:item,attrs:{"_i":("1-"+$30)}})}),1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,$10,$20,$30){return _c('li',{key:item,attrs:{"_i":("1-"+$30)}})}),1)}`
)
// iterator syntax
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,i,$20,$30){return _c('v-uni-view',{key:item,attrs:{"_i":("1-"+$30)}})}),1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,i,$20,$30){return _c('li',{key:item,attrs:{"_i":("1-"+$30)}})}),1)}`
)
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,key,index,$30){return _c('v-uni-view',{key:item,attrs:{"_i":("1-"+$30)}})}),1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,key,index,$30){return _c('li',{key:item,attrs:{"_i":("1-"+$30)}})}),1)}`
)
// destructuring
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},_l((_$g(1,'f')),function($item,$10,$20,$30){return _c('v-uni-view',{key:$item,attrs:{"_i":("1-"+$30)}})}),1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},_l((_$g(1,'f')),function($item,$10,$20,$30){return _c('li',{key:$item,attrs:{"_i":("1-"+$30)}})}),1)}`
)
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},_l((_$g(1,'f')),function($item,key,index,$30){return _c('v-uni-view',{key:$item,attrs:{"_i":("1-"+$30)}})}),1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},_l((_$g(1,'f')),function($item,key,index,$30){return _c('li',{key:$item,attrs:{"_i":("1-"+$30)}})}),1)}`
)
// v-for with extra element
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_c('v-uni-view',{attrs:{"_i":1}}),_l((_$g(2,'f')),function(item,$10,$20,$30){return _c('v-uni-view',{key:item,attrs:{"_i":("2-"+$30)}})})],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_c('p',{attrs:{"_i":1}}),_l((_$g(2,'f')),function(item,$10,$20,$30){return _c('li',{key:item,attrs:{"_i":("2-"+$30)}})})],2)}`
)
})
it('generate v-if directive', () => {
assertCodegen(
'hello
',
- `with(this){return (_$g(0,'i'))?_c('v-uni-view',{attrs:{"_i":0}},[_v("hello")]):_e()}`
+ `with(this){return (_$g(0,'i'))?_c('p',{attrs:{"_i":0}},[_v("hello")]):_e()}`
)
})
it('generate v-else directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('v-uni-view',{attrs:{"_i":1}},[_v("hello")]):_c('v-uni-view',{attrs:{"_i":2}},[_v("world")])],1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('p',{attrs:{"_i":1}},[_v("hello")]):_c('p',{attrs:{"_i":2}},[_v("world")])],1)}`
)
})
it('generate v-else-if directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('v-uni-view',{attrs:{"_i":1}},[_v("hello")]):(_$g(2,'e'))?_c('v-uni-view',{attrs:{"_i":2}},[_v("world")]):_e()],1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('p',{attrs:{"_i":1}},[_v("hello")]):(_$g(2,'e'))?_c('p',{attrs:{"_i":2}},[_v("world")]):_e()],1)}`
)
})
it('generate v-else-if with v-else directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('v-uni-view',{attrs:{"_i":1}},[_v("hello")]):(_$g(2,'e'))?_c('v-uni-view',{attrs:{"_i":2}},[_v("world")]):_c('v-uni-view',{attrs:{"_i":3}},[_v("bye")])],1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('p',{attrs:{"_i":1}},[_v("hello")]):(_$g(2,'e'))?_c('p',{attrs:{"_i":2}},[_v("world")]):_c('p',{attrs:{"_i":3}},[_v("bye")])],1)}`
)
})
it('generate multi v-else-if with v-else directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('v-uni-view',{attrs:{"_i":1}},[_v("hello")]):(_$g(2,'e'))?_c('v-uni-view',{attrs:{"_i":2}},[_v("world")]):(3)?_c('v-uni-view',{attrs:{"_i":3}},[_v("elseif")]):_c('v-uni-view',{attrs:{"_i":4}},[_v("bye")])],1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[(_$g(1,'i'))?_c('p',{attrs:{"_i":1}},[_v("hello")]):(_$g(2,'e'))?_c('p',{attrs:{"_i":2}},[_v("world")]):(3)?_c('p',{attrs:{"_i":3}},[_v("elseif")]):_c('p',{attrs:{"_i":4}},[_v("bye")])],1)}`
)
})
it('generate ref', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{ref:"component1",attrs:{"_i":0}})}`
+ `with(this){return _c('p',{ref:"component1",attrs:{"_i":0}})}`
)
})
it('generate ref on v-for', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,$10,$20,$30){return _c('v-uni-view',{key:item,ref:"component1",refInFor:true,attrs:{"_i":("1-"+$30)}})}),1)}`
+ `with(this){return _c('ul',{attrs:{"_i":0}},_l((_$g(1,'f')),function(item,$10,$20,$30){return _c('li',{key:item,ref:"component1",refInFor:true,attrs:{"_i":("1-"+$30)}})}),1)}`
)
})
it('generate v-bind directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',_b({attrs:{"_i":0}},'v-uni-view',_$g(0,'v-bind'),false))}`
+ `with(this){return _c('p',_b({attrs:{"_i":0}},'p',_$g(0,'v-bind'),false))}`
)
})
it('generate v-bind with prop directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',_b({attrs:{"_i":0}},'v-uni-view',_$g(0,'v-bind'),true))}`
+ `with(this){return _c('p',_b({attrs:{"_i":0}},'p',_$g(0,'v-bind'),true))}`
)
})
it('generate v-bind directive with sync modifier', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',_b({attrs:{"_i":0}},'v-uni-view',_$g(0,'v-bind'),false,true))}`
+ `with(this){return _c('p',_b({attrs:{"_i":0}},'p',_$g(0,'v-bind'),false,true))}`
)
})
it('generate v-model directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-input',{attrs:{"_i":0},model:{value:_$g(0,'v-model'),callback:function($$v){$handleVModelEvent(0,$$v)},expression:"test"}})}`
+ `with(this){return _c('v-uni-input',{attrs:{"_i":0},model:{value:_$g(0,'v-model'),callback:function(){},expression:"test"}})}`
)
})
it('generate multiline v-model directive', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-input',{attrs:{"_i":0},model:{value:_$g(0,'v-model'),callback:function($$v){$handleVModelEvent(0,$$v)},expression:"\\n test \\n"}})}`
+ `with(this){return _c('v-uni-input',{attrs:{"_i":0},model:{value:_$g(0,'v-model'),callback:function(){},expression:"\\n test \\n"}})}`
)
})
@@ -162,35 +162,35 @@ describe('codegen', () => {
it('generate template tag', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[[_c('v-uni-view',{attrs:{"_i":2}},[_v((_$g(2,'t0')))])]],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[[_c('p',{attrs:{"_i":2}},[_v((_$g(2,'t0')))])]],2)}`
)
})
it('generate single slot', () => {
assertCodegen(
'
',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_t("default",null,{"_i":1})],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_t("default",null,{"_i":1})],2)}`
)
})
it('generate named slot', () => {
assertCodegen(
'
',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_t("one",null,{"_i":1})],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_t("one",null,{"_i":1})],2)}`
)
})
it('generate slot fallback content', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_t("default",[_c('v-uni-view',{attrs:{"_i":2}},[_v("hi")])],{"_i":1})],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_t("default",[_c('div',{attrs:{"_i":2}},[_v("hi")])],{"_i":1})],2)}`
)
})
it('generate slot target', () => {
assertCodegen(
'hello world
',
- `with(this){return _c('v-uni-view',{attrs:{"slot":"one","_i":0},slot:"one"},[_v("hello world")])}`
+ `with(this){return _c('p',{attrs:{"slot":"one","_i":0},slot:"one"},[_v("hello world")])}`
)
})
@@ -201,7 +201,7 @@ describe('codegen', () => {
)
assertCodegen(
'{{ bar }}
',
- `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:"default",fn:function(bar, _svm, _si){return _c('v-uni-view',{attrs:{"_i":("1-"+_si)}},[_v((_svm._$g(("1-"+_si),'t0')))])}}])})}`
+ `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:"default",fn:function(bar, _svm, _si){return _c('div',{attrs:{"_i":("1-"+_si)}},[_v((_svm._$g(("1-"+_si),'t0')))])}}])})}`
)
})
@@ -212,7 +212,7 @@ describe('codegen', () => {
)
assertCodegen(
'{{ bar }}
',
- `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:"foo",fn:function(bar, _svm, _si){return _c('v-uni-view',{attrs:{"_i":("1-"+_si)}},[_v((_svm._$g(("1-"+_si),'t0')))])}}])})}`
+ `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:"foo",fn:function(bar, _svm, _si){return _c('div',{attrs:{"_i":("1-"+_si)}},[_v((_svm._$g(("1-"+_si),'t0')))])}}])})}`
)
})
@@ -230,7 +230,7 @@ describe('codegen', () => {
)
assertCodegen(
'{{ bar }}
',
- `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:"foo",fn:function(bar, _svm, _si){return (_svm._$g(("1-"+_si),'i'))?_c('v-uni-view',{attrs:{"_i":("1-"+_si)}},[_v((_svm._$g(("1-"+_si),'t0')))]):_e()}}],null,true)})}`
+ `with(this){return _c('foo',{attrs:{"_i":0},scopedSlots:_u([{key:"foo",fn:function(bar, _svm, _si){return (_svm._$g(("1-"+_si),'i'))?_c('div',{attrs:{"_i":("1-"+_si)}},[_v((_svm._$g(("1-"+_si),'t0')))]):_e()}}],null,true)})}`
)
})
@@ -245,26 +245,26 @@ describe('codegen', () => {
// static
assertCodegen(
'hello world
',
- `with(this){return _c('v-uni-view',{staticClass:_$g(0,'sc'),attrs:{"_i":0}},[_v("hello world")])}`
+ `with(this){return _c('p',{staticClass:_$g(0,'sc'),attrs:{"_i":0}},[_v("hello world")])}`
)
// dynamic
assertCodegen(
'hello world
',
- `with(this){return _c('v-uni-view',{class:_$g(0,'c'),attrs:{"_i":0}},[_v("hello world")])}`
+ `with(this){return _c('p',{class:_$g(0,'c'),attrs:{"_i":0}},[_v("hello world")])}`
)
})
it('generate style binding', () => {
assertCodegen(
'hello world
',
- `with(this){return _c('v-uni-view',{style:(_$g(0,'s')),attrs:{"_i":0}},[_v("hello world")])}`
+ `with(this){return _c('p',{style:(_$g(0,'s')),attrs:{"_i":0}},[_v("hello world")])}`
)
})
it('generate v-show directive', () => {
assertCodegen(
'hello world
',
- `with(this){return _c('v-uni-view',{directives:[{name:"show",rawName:"v-show",value:(_$g(0,'v-show')),expression:"_$g(0,'v-show')"}],attrs:{"_i":0}},[_v("hello world")])}`
+ `with(this){return _c('p',{directives:[{name:"show",rawName:"v-show",value:(_$g(0,'v-show')),expression:"_$g(0,'v-show')"}],attrs:{"_i":0}},[_v("hello world")])}`
)
})
@@ -277,7 +277,7 @@ describe('codegen', () => {
// non input
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"value":_$g(0,'a-value'),"_i":0}})}`
+ `with(this){return _c('p',{attrs:{"value":_$g(0,'a-value'),"_i":0}})}`
)
})
@@ -558,7 +558,7 @@ describe('codegen', () => {
it('generate component', () => {
assertCodegen(
'hi
',
- `with(this){return _c('my-component',{attrs:{"_i":0},on:{"notify":function($event){return $handleViewEvent($event)}}},[_c('v-uni-view',{attrs:{"_i":1}},[_v("hi")])],1)}`
+ `with(this){return _c('my-component',{attrs:{"_i":0},on:{"notify":function($event){return $handleViewEvent($event)}}},[_c('div',{attrs:{"_i":1}},[_v("hi")])],1)}`
)
})
@@ -572,16 +572,16 @@ describe('codegen', () => {
it('generate is attribute', () => {
assertCodegen(
'',
- `with(this){return _c("component1",{tag:"v-uni-view",attrs:{"_i":0}})}`
+ `with(this){return _c("component1",{tag:"div",attrs:{"_i":0}})}`
)
assertCodegen(
'',
- `with(this){return _c(_$g(0,'is'),{tag:"v-uni-view",attrs:{"_i":0}})}`
+ `with(this){return _c(_$g(0,'is'),{tag:"div",attrs:{"_i":0}})}`
)
// maybe a component and normalize type should be 1
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_c("component1",{tag:"v-uni-view",attrs:{"_i":1}})],1)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_c("component1",{tag:"div",attrs:{"_i":1}})],1)}`
)
})
@@ -589,12 +589,12 @@ describe('codegen', () => {
// have "inline-template'"
assertCodegen(
'hello world
',
- `with(this){return _c('my-component',{attrs:{"_i":0},inlineTemplate:{render:function(){with(this){return _c('v-uni-view',{attrs:{"_i":1}},[_c('v-uni-label',{attrs:{"_i":2}},[_v("hello world")])],1)}},staticRenderFns:[]}})}`
+ `with(this){return _c('my-component',{attrs:{"_i":0},inlineTemplate:{render:function(){with(this){return _c('p',{attrs:{"_i":1}},[_c('span',{attrs:{"_i":2}},[_v("hello world")])],1)}},staticRenderFns:[]}})}`
)
// "have inline-template attrs, but not having exactly one child element
assertCodegen(
'
',
- `with(this){return _c('my-component',{attrs:{"_i":0},inlineTemplate:{render:function(){with(this){return _c('v-uni-view',{attrs:{"_i":1}})}},staticRenderFns:[]}})}`
+ `with(this){return _c('my-component',{attrs:{"_i":0},inlineTemplate:{render:function(){with(this){return _c('hr',{attrs:{"_i":1}})}},staticRenderFns:[]}})}`
)
assertCodegen(
'',
@@ -603,11 +603,11 @@ describe('codegen', () => {
// have "is" attribute
assertCodegen(
'',
- `with(this){return _c("myComponent",{tag:"v-uni-view",attrs:{"_i":0},inlineTemplate:{render:function(){with(this){return _c('v-uni-view',{attrs:{"_i":1}})}},staticRenderFns:[]}})}`
+ `with(this){return _c("myComponent",{tag:"div",attrs:{"_i":0},inlineTemplate:{render:function(){with(this){return _c('div',{attrs:{"_i":1}})}},staticRenderFns:[]}})}`
)
assertCodegen(
'',
- `with(this){return _c("myComponent",{tag:"v-uni-view",attrs:{"_i":0}})}`
+ `with(this){return _c("myComponent",{tag:"div",attrs:{"_i":0}})}`
)
// expect('Inline-template components must have exactly one child element.').toHaveBeenWarned()
// expect(console.error.calls.count()).toBe(3)
@@ -616,8 +616,8 @@ describe('codegen', () => {
it('generate static trees inside v-for', () => {
assertCodegen(
``,
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},_l((10),function(i,$10,$20,$30){return _c('v-uni-view',{attrs:{"_i":("1-"+$30)}},[_c('v-uni-view',{attrs:{"_i":("2-"+$30)}},[_c('v-uni-label',{attrs:{"_i":("3-"+$30)}})],1)],1)}),1)}`
- // [`with(this){return _c('v-uni-view',{attrs:{"_i":("2-"+$i)}},[_c('v-uni-view',{attrs:{"_i":("3-"+$i)}})])}`]
+ `with(this){return _c('div',{attrs:{"_i":0}},_l((10),function(i,$10,$20,$30){return _c('div',{attrs:{"_i":("1-"+$30)}},[_c('p',{attrs:{"_i":("2-"+$30)}},[_c('span',{attrs:{"_i":("3-"+$30)}})],1)],1)}),1)}`
+ // [`with(this){return _c('p',{attrs:{"_i":("2-"+$i)}},[_c('p',{attrs:{"_i":("3-"+$i)}})])}`]
)
})
@@ -625,7 +625,7 @@ describe('codegen', () => {
// normalize type: 2
assertCodegen(
'{{ item }}
',
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[_c('child',{attrs:{"_i":1}}),_l((_$g(2,'f')),function(item,$10,$20,$30){return [_v((_$g(("2-"+$30),'t0')))]})],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[_c('child',{attrs:{"_i":1}}),_l((_$g(2,'f')),function(item,$10,$20,$30){return [_v((_$g(("2-"+$30),'t0')))]})],2)}`
)
})
@@ -634,7 +634,7 @@ describe('codegen', () => {
// comments: true
// }, baseOptions)
// const template = ''
- // const generatedCode = `with(this){return _c('v-uni-view',{attrs:{"_i":0}})}`
+ // const generatedCode = `with(this){return _c('p',{attrs:{"_i":0}})}`
// const ast = parse(template, options)
// optimize(ast, options)
@@ -648,7 +648,7 @@ describe('codegen', () => {
// comments: true
// }, baseOptions)
// const template = ''
- // const generatedCode = `with(this){return _c('v-uni-view',{attrs:{"_i":0}})}`
+ // const generatedCode = `with(this){return _c('p',{attrs:{"_i":0}})}`
// const ast = parse(template, options)
// optimize(ast, options)
@@ -660,11 +660,11 @@ describe('codegen', () => {
it('does not squash templates inside v-pre', () => {
assertCodegen(
'',
- `with(this){return _c('v-uni-view',{pre:true,attrs:{"_i":0}},[[_c('v-uni-view',{pre:true,attrs:{"_i":2}},[_v("{{msg}}")])]],2)}`
+ `with(this){return _c('div',{pre:true,attrs:{"_i":0}},[[_c('p',{pre:true,attrs:{"_i":2}},[_v("{{msg}}")])]],2)}`
)
// const template = ''
// const generatedCode = `with(this){return _m(0)}`
- // // const renderFn = `with(this){return _c('v-uni-view',{pre:true},[_c('template',[_c('v-uni-view',[_v("{{msg}}")])])],2)}`
+ // // const renderFn = `with(this){return _c('p',{pre:true},[_c('template',[_c('p',[_v("{{msg}}")])])],2)}`
// const ast = parse(template, baseOptions)
// optimize(ast, baseOptions)
// const res = generate(ast, baseOptions)
@@ -678,14 +678,14 @@ describe('codegen', () => {
`with(this){return _c("div")}`
)
// const res = generate(null, baseOptions)
- // expect(res.render).toBe(`with(this){return _c("v-uni-view")}`)
+ // expect(res.render).toBe(`with(this){return _c("p")}`)
// expect(res.staticRenderFns).toEqual([])
})
it('not specified directives option', () => {
assertCodegen(
'hello world
',
- `with(this){return (_$g(0,'i'))?_c('v-uni-view',{attrs:{"_i":0}},[_v("hello world")]):_e()}`, {
+ `with(this){return (_$g(0,'i'))?_c('p',{attrs:{"_i":0}},[_v("hello world")]):_e()}`, {
// isReservedTag
}
)
@@ -695,7 +695,7 @@ describe('codegen', () => {
it('should compile single v-for component inside template', () => {
assertCodegen(
`
`,
- `with(this){return _c('v-uni-view',{attrs:{"_i":0}},[(_$g(1,'i'))?_l((1),function(i,$10,$20,$30){return _c('foo',{key:i,attrs:{"_i":("2-"+$30)}})}):_e()],2)}`
+ `with(this){return _c('div',{attrs:{"_i":0}},[(_$g(1,'i'))?_l((1),function(i,$10,$20,$30){return _c('foo',{key:i,attrs:{"_i":("2-"+$30)}})}):_e()],2)}`
)
})
})
diff --git a/packages/uni-template-compiler/lib/app/view.js b/packages/uni-template-compiler/lib/app/view.js
index 1360374d8a25f3b9e7f1a435ac5c5c0b5bc4aca7..ab6fa4a0b55b3620da33a15cf163619a7a11adc8 100644
--- a/packages/uni-template-compiler/lib/app/view.js
+++ b/packages/uni-template-compiler/lib/app/view.js
@@ -209,11 +209,11 @@ function handleViewEvents (events) {
function genVModel (el, isScopedSlot) {
if (el.model) {
el.model.value = createGenVar(el.attrsMap[ID], isScopedSlot)('v-model', el.model.value)
- if (el.tag === 'v-uni-input' || el.tag === 'v-uni-textarea') {
- el.model.callback = `function($$v){$handleVModelEvent(${el.attrsMap[ID]},$$v)}`
- } else {
- el.model.callback = `function(){}`
- }
+ // if (el.tag === 'v-uni-input' || el.tag === 'v-uni-textarea') {
+ // el.model.callback = `function($$v){$handleVModelEvent(${el.attrsMap[ID]},$$v)}`
+ // } else {
+ el.model.callback = `function(){}`
+ // }
}
}
diff --git a/packages/vue-cli-plugin-uni/lib/app-plus/index.js b/packages/vue-cli-plugin-uni/lib/app-plus/index.js
index 2be242be23c98f76895c96974b88ef6125677f03..ae0f24351340d439d73de59b2127cf9deb050546 100644
--- a/packages/vue-cli-plugin-uni/lib/app-plus/index.js
+++ b/packages/vue-cli-plugin-uni/lib/app-plus/index.js
@@ -110,6 +110,15 @@ const v3 = {
}]
})
+ if (isAppService) {
+ rules.push({
+ test: [/\.css$/, /\.p(ost)?css$/, /\.scss$/, /\.sass$/, /\.less$/, /\.styl(us)?$/],
+ use: [{
+ loader: path.resolve(__dirname, '../../packages/webpack-uni-app-loader/service/style.js')
+ }]
+ })
+ }
+
const entry = {}
if (isAppService) {
entry['app-service'] = path.resolve(process.env.UNI_INPUT_DIR, getMainEntry())
@@ -281,6 +290,12 @@ const v3 = {
}
}
+ if (isAppService) { // service 层移除 css 相关
+ ['css', 'postcss', 'scss', 'sass', 'less', 'stylus'].forEach(cssLang => {
+ webpackConfig.module.rules.delete(cssLang)
+ })
+ }
+
webpackConfig.plugins.delete('hmr')
webpackConfig.plugins.delete('html')
webpackConfig.plugins.delete('copy')
diff --git a/packages/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js b/packages/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js
index de874268986c5d8845054417767942c8de740731..ef6db5bba329cc88dc7b9c825a4ae318106a2fd1 100644
--- a/packages/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js
+++ b/packages/vue-cli-plugin-uni/packages/uni-cloud/dist/index.js
@@ -1 +1 @@
-var e="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){return e(t={exports:{}},t.exports),t.exports}var r=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}}(),r={},o=r.lib={},i=o.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)}},s=o.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,o=e.sigBytes;if(this.clamp(),r%4)for(var i=0;i>>2]>>>24-i%4*8&255;t[r+i>>>2]|=s<<24-(r+i)%4*8}else for(i=0;i>>2]=n[i>>>2];return this.sigBytes+=o,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=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,r=[],o=function(t){t=t;var n=987654321,r=4294967295;return function(){var o=((n=36969*(65535&n)+(n>>16)&r)<<16)+(t=18e3*(65535&t)+(t>>16)&r)&r;return o/=4294967296,(o+=.5)*(e.random()>.5?1:-1)}},i=0;i>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=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)))}},f=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,a=o/(4*i),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*i,u=e.min(4*c,o);if(c){for(var l=0;l>>24)|4278255360&(o<<24|o>>>8)}var i=this._hash.words,s=e[t+0],c=e[t+1],h=e[t+2],d=e[t+3],y=e[t+4],v=e[t+5],_=e[t+6],g=e[t+7],m=e[t+8],w=e[t+9],b=e[t+10],E=e[t+11],S=e[t+12],T=e[t+13],k=e[t+14],O=e[t+15],A=i[0],P=i[1],N=i[2],I=i[3];A=u(A,P,N,I,s,7,a[0]),I=u(I,A,P,N,c,12,a[1]),N=u(N,I,A,P,h,17,a[2]),P=u(P,N,I,A,d,22,a[3]),A=u(A,P,N,I,y,7,a[4]),I=u(I,A,P,N,v,12,a[5]),N=u(N,I,A,P,_,17,a[6]),P=u(P,N,I,A,g,22,a[7]),A=u(A,P,N,I,m,7,a[8]),I=u(I,A,P,N,w,12,a[9]),N=u(N,I,A,P,b,17,a[10]),P=u(P,N,I,A,E,22,a[11]),A=u(A,P,N,I,S,7,a[12]),I=u(I,A,P,N,T,12,a[13]),N=u(N,I,A,P,k,17,a[14]),A=l(A,P=u(P,N,I,A,O,22,a[15]),N,I,c,5,a[16]),I=l(I,A,P,N,_,9,a[17]),N=l(N,I,A,P,E,14,a[18]),P=l(P,N,I,A,s,20,a[19]),A=l(A,P,N,I,v,5,a[20]),I=l(I,A,P,N,b,9,a[21]),N=l(N,I,A,P,O,14,a[22]),P=l(P,N,I,A,y,20,a[23]),A=l(A,P,N,I,w,5,a[24]),I=l(I,A,P,N,k,9,a[25]),N=l(N,I,A,P,d,14,a[26]),P=l(P,N,I,A,m,20,a[27]),A=l(A,P,N,I,T,5,a[28]),I=l(I,A,P,N,h,9,a[29]),N=l(N,I,A,P,g,14,a[30]),A=f(A,P=l(P,N,I,A,S,20,a[31]),N,I,v,4,a[32]),I=f(I,A,P,N,m,11,a[33]),N=f(N,I,A,P,E,16,a[34]),P=f(P,N,I,A,k,23,a[35]),A=f(A,P,N,I,c,4,a[36]),I=f(I,A,P,N,y,11,a[37]),N=f(N,I,A,P,g,16,a[38]),P=f(P,N,I,A,b,23,a[39]),A=f(A,P,N,I,T,4,a[40]),I=f(I,A,P,N,s,11,a[41]),N=f(N,I,A,P,d,16,a[42]),P=f(P,N,I,A,_,23,a[43]),A=f(A,P,N,I,w,4,a[44]),I=f(I,A,P,N,S,11,a[45]),N=f(N,I,A,P,O,16,a[46]),A=p(A,P=f(P,N,I,A,h,23,a[47]),N,I,s,6,a[48]),I=p(I,A,P,N,g,10,a[49]),N=p(N,I,A,P,k,15,a[50]),P=p(P,N,I,A,v,21,a[51]),A=p(A,P,N,I,S,6,a[52]),I=p(I,A,P,N,d,10,a[53]),N=p(N,I,A,P,b,15,a[54]),P=p(P,N,I,A,c,21,a[55]),A=p(A,P,N,I,m,6,a[56]),I=p(I,A,P,N,O,10,a[57]),N=p(N,I,A,P,_,15,a[58]),P=p(P,N,I,A,T,21,a[59]),A=p(A,P,N,I,y,6,a[60]),I=p(I,A,P,N,E,10,a[61]),N=p(N,I,A,P,h,15,a[62]),P=p(P,N,I,A,w,21,a[63]),i[0]=i[0]+A|0,i[1]=i[1]+P|0,i[2]=i[2]+N|0,i[3]=i[3]+I|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296),s=r;n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,r,o,i,s){var a=e+(t&n|~t&r)+o+s;return(a<>>32-i)+t}function l(e,t,n,r,o,i,s){var a=e+(t&r|n&~r)+o+s;return(a<>>32-i)+t}function f(e,t,n,r,o,i,s){var a=e+(t^n^r)+o+s;return(a<>>32-i)+t}function p(e,t,n,r,o,i,s){var a=e+(n^(t|~r))+o+s;return(a<>>32-i)+t}t.MD5=i._createHelper(c),t.HmacMD5=i._createHmacHelper(c)}(Math),n.MD5)})),n((function(e,t){var n,o,i;e.exports=(o=(n=r).lib.Base,i=n.enc.Utf8,void(n.algo.HMAC=o.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=i.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),s=this._iKey=t.clone(),a=o.words,c=s.words,u=0;u{uni.request(Object.assign(e,{complete(e){e||(e={}),(!e.statusCode||e.statusCode>=400)&&n(e.data||{error:{code:"Request Error",message:"请求出错"},success:!1});const r=e.data;r.error&&n(r),r.result=r.data,delete r.data,t(r)}}))})}};const s={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",mp3:"audio/mpeg",mp4:"video/mp4",ogg:"audio/ogg",webm:"video/webm"};function a(e){return s[e]}class c{constructor(e){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.env,this.setAccessToken(uni.getStorageSync(this.config.accessTokenKey)||"")}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){uni.setStorageSync(this.config.accessTokenKey,e),this.accessToken=e}requestAuth(e){return i.wrappedRequest(e)}request(e,t){return this.hasAccessToken?t?i.wrappedRequest(e):i.wrappedRequest(e).catch(t=>new Promise((e,n)=>{t&&t.error&&("GATEWAY_INVALID_TOKEN"===t.error.code||"InvalidParameter.InvalidToken"===t.error.code)?e():n(t)}).then(()=>{return 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"]=i.sign(t.data,this.config.clientSecret),t}setupRequest(e,t){const n=Object.assign({},e,{spaceId:this.config.env,timestamp:Date.now()}),r={"Content-Type":"application/json"};return"auth"!==t&&(n.token=this.accessToken,r["x-basement-token"]=this.accessToken),r["x-serverless-sign"]=i.sign(n,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:r}}getAccessToken(){return 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),t(this.accessToken)):n(new Error("获取accessToken失败"))}))}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,fileName:n,name:r,filePath:o,fileType:i,contentType:s}){return new Promise((s,a)=>{uni.uploadFile({url:e,formData:t,fileName:n,name:r,filePath:o,fileType:i,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?s(e):a(new Error("Upload Fail"))},fail(e){a(e)}})})}reportOSSUpload(e){const t={method:"serverless.file.resource.report",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFile({filePath:e,config:t}){const n=t&&t.envType||this.config.envType;let r,o,i,c,u,l=e.split("/").pop();return(r="h5"===process.env.VUE_APP_PLATFORM?new Promise((t,n)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="blob",r.onload=function(){(o=function(e){let t;return Object.keys(s).forEach(n=>{s[n]===e&&(t=n)}),t}(this.response.type))||n(new Error("Unsupported File Type")),l+="."+o,t()},r.send()}):a(o=e.split(".").pop())?Promise.resolve():Promise.reject(new Error("Unsupported File Type"))).then(()=>this.getOSSUploadOptionsFromPath({env:n,filename:l})).then(t=>{const n=t.result;i=a(o),c=n.id,u="https://"+n.host+"/"+n.ossPath;const r={url:"https://"+n.host,formData:{"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:n.accessKeyId,Signature:n.signature,host:n.host,id:c,key:n.ossPath,policy:n.policy,success_action_status:200},fileName:"file",name:"file",filePath:e,fileType:"image",contentType:i};return this.uploadFileToOSS(r)}).then(()=>this.reportOSSUpload({id:c,contentType:i})).then(t=>new Promise((n,r)=>{t.success?n({success:!0,filePath:e,fileUrl:u}):r(new Error("Upload Fail"))}))}deleteFile({url:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({id:e})};return this.request(this.setupRequest(t))}}const u=require("uni-stat-config").default||require("uni-stat-config"),l="__DC_STAT_UUID",f="__DC_UUID_VALUE",p="https://ide.dcloud.net.cn/serverless/function/invoke";function h(){return{"app-plus":"n",h5:"h5","mp-weixin":"wx","mp-alipay":"ali","mp-baidu":"bd","mp-toutiao":"tt","mp-qq":"qq"}[process.env.VUE_APP_PLATFORM]}function d(e){return 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)}).catch(e=>{t.fail&&t.fail(e),t.complete&&t.complete(e)})}}const y=uni.getSystemInfoSync(),v={platform:process.env.VUE_APP_PLATFORM,os:y.platform},_={ak:u.appid,p:"android"===y.platform?"a":"i",ut:h(),uuid:function(){let e="";if("n"===h()){try{e=plus.runtime.getDCloudId()}catch(t){e=""}return e}try{e=uni.getStorageSync(l)}catch(t){e=f}if(!e){e=Date.now()+""+Math.floor(1e7*Math.random());try{uni.setStorageSync(l,e)}catch(e){uni.setStorageSync(l,f)}}return e}()},g={init(e){const t=new c(e);t.authorize();return["callFunction","uploadFile","deleteFile"].forEach(e=>{t[e]=d(t[e]).bind(t)}),t}};var m;!function(e){e.local="local",e.none="none",e.session="session"}(m||(m={}));var w=function(){},b=function(){};function E(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";for(var i in n)""===o?!r&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}var S,T=Object.freeze({__proto__:null,get StorageType(){return m},AbstractSDKRequest:w,AbstractStorage:b,formatUrl:E}),k=(S=function(e,t){return(S=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}S(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),O=function(){return(O=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=0;i-=1)r[i].split("=")[0]===e&&r.splice(i,1);n=n+"?"+r.join("&")}return n},t.createPromiseCallback=function(){var e;if(!Promise){(e=function(){}).promise={};var t=function(){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}var n=new Promise((function(t,n){e=function(e,r){return e?n(e):t(r)}}));return e.promise=n,e},t.getWeixinCode=function(){return t.getQuery("code")||t.getHash("code")},t.getMiniAppCode=function(){return new Promise((function(e,t){wx.login({success:function(t){e(t.code)},fail:function(e){t(e)}})}))},t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.getArgNames=function(e){var t=e.toString();return t.slice(t.indexOf("(")+1,t.indexOf(")")).match(/([^\s,]+)/g)},t.formatUrl=function(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";for(var i in n)""===o?!r&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}}));t(R);R.getQuery,R.getHash,R.removeParam,R.createPromiseCallback,R.getWeixinCode,R.getMiniAppCode,R.isArray,R.isString,R.isUndefined,R.isInstanceOf,R.isFormData,R.genSeqId,R.getArgNames,R.formatUrl;var j,U="dist/index.js",q="./dist/index.d.ts",L={build:"npm run tsc && webpack",tsc:"tsc -p tsconfig.json","tsc:w":"tsc -p tsconfig.json -w",test:"jest --verbose false -i",e2e:'NODE_ENV=e2e webpack && jest --config="./jest.e2e.config.js" --verbose false -i "e2e"',start:"webpack-dev-server --hot --open",eslint:'eslint "./**/*.js" "./**/*.ts"',"eslint-fix":'eslint --fix "./**/*.js" "./**/*.ts"',test_web:"npm run tsc && webpack-dev-server --devtool eval-source-map --progress --colors --hot --inline --content-base ./dist --host jimmytest-088bef.tcb.qcloud.la --port 80 --disableHostCheck true --mode development --config webpack.test.js"},K={type:"git",url:"https://github.com/TencentCloudBase/tcb-js-sdk"},D=["tcb","js-sdk"],M={"@cloudbase/adapter-interface":"^0.2.0","@cloudbase/adapter-wx_mp":"^0.2.1","@cloudbase/database":"^0.9.8"},F={"@babel/core":"^7.6.2","@babel/plugin-proposal-class-properties":"^7.5.5","@babel/plugin-proposal-object-rest-spread":"^7.6.2","@babel/plugin-transform-runtime":"^7.6.2","@babel/preset-env":"^7.6.2","@babel/preset-typescript":"^7.6.0","@babel/runtime":"^7.6.2","@types/jest":"^23.1.4","@types/node":"^10.14.4","@types/superagent":"^4.1.4",axios:"^0.19.0","babel-eslint":"^10.0.1","babel-loader":"^8.0.6","babel-polyfill":"^6.26.0",eslint:"^5.16.0","eslint-config-alloy":"^1.4.2","eslint-config-prettier":"^4.1.0","eslint-plugin-prettier":"^3.0.1","eslint-plugin-typescript":"^1.0.0-rc.3",express:"^4.17.1",husky:"^3.1.0",jest:"^24.7.1","jest-puppeteer":"^4.3.0","lint-staged":"^9.5.0","power-assert":"^1.6.1",puppeteer:"^1.20.0","serve-static":"^1.14.1","ts-jest":"^23.10.4","ts-loader":"^6.2.1",typescript:"^3.4.3","typescript-eslint-parser":"^22.0.0",webpack:"^4.41.3","webpack-bundle-analyzer":"^3.4.1","webpack-cli":"^3.3.0","webpack-dev-server":"^3.3.1","webpack-merge":"^4.2.2","webpack-visualizer-plugin":"^0.1.11"},G={hooks:{"pre-commit":"lint-staged"}},H={name:"tcb-js-sdk",version:"1.3.5",description:"js sdk for tcb",main:U,types:q,scripts:L,repository:K,keywords:D,author:"jimmyjzhang",license:"ISC",dependencies:M,devDependencies:F,husky:G,"lint-staged":{"*.{js,ts}":["eslint --fix","git add"]}},Y=(j=Object.freeze({__proto__:null,name:"tcb-js-sdk",version:"1.3.5",description:"js sdk for tcb",main:U,types:q,scripts:L,repository:K,keywords:D,author:"jimmyjzhang",license:"ISC",dependencies:M,devDependencies:F,husky:G,default:H}))&&j.default||j,V=n((function(t,n){var r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(n,"__esModule",{value:!0});var o=r(Y);n.SDK_VERISON=o.version,n.ACCESS_TOKEN="access_token",n.ACCESS_TOKEN_Expire="access_token_expire",n.REFRESH_TOKEN="refresh_token",n.ANONYMOUS_UUID="anonymous_uuid",n.LOGIN_TYPE_KEY="login_type",n.protocol="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:",n.BASE_URL="e2e"===process.env.NODE_ENV&&"pre"===process.env.END_POINT?"//tcb-pre.tencentcloudapi.com/web":"//tcb-api.tencentcloudapi.com/web"}));t(V);V.SDK_VERISON,V.ACCESS_TOKEN,V.ACCESS_TOKEN_Expire,V.REFRESH_TOKEN,V.ANONYMOUS_UUID,V.LOGIN_TYPE_KEY,V.protocol,V.BASE_URL;var B=n((function(t,n){var r=e&&e.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),o=e&&e.__assign||function(){return(o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=0?JSON.parse(n).content:""},e.prototype.removeStore=function(e){this.storageClass.removeItem(e)},e}();n.Cache=o;var i=function(e){function t(){var t=e.call(this)||this;return W.Adapter.adapter.root.tcbObject||(W.Adapter.adapter.root.tcbObject={}),t}return r(t,e),t.prototype.setItem=function(e,t){W.Adapter.adapter.root.tcbObject[e]=t},t.prototype.getItem=function(e){return W.Adapter.adapter.root.tcbObject[e]},t.prototype.removeItem=function(e){delete W.Adapter.adapter.root.tcbObject[e]},t.prototype.clear=function(){delete W.Adapter.adapter.root.tcbObject},t}(T.AbstractStorage)}));t(z);z.Cache;var J=n((function(t,n){var r=e&&e.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),o=e&&e.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t0},e}();n.IEventEmitter=a;var c=new a;n.addEventListener=function(e,t){c.on(e,t)},n.activateEvent=function(e,t){void 0===t&&(t={}),c.fire(e,t)},n.removeEventListener=function(e,t){c.off(e,t)},n.EVENTS={LOGIN_STATE_CHANGED:"loginStateChanged",LOGIN_STATE_EXPIRE:"loginStateExpire",LOGIN_TYPE_CHANGE:"loginTypeChanged",ANONYMOUS_CONVERTED:"anonymousConverted",REFRESH_ACCESS_TOKEN:"refreshAccessToken"}}));t(J);J.IEvent,J.IErrorEvent,J.IEventEmitter,J.addEventListener,J.activateEvent,J.removeEventListener,J.EVENTS;var X=n((function(t,n){var r=e&&e.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]Date.now())return[2,{credential:{accessToken:e,refreshToken:this.cache.getStore(this.refreshTokenKey)}}];this.cache.removeStore(this.accessTokenKey),this.cache.removeStore(this.accessTokenExpireKey)}if(!1===Object.values(a).includes(a[this.scope]))throw new Error("错误的scope类型");return W.Adapter.runtime!==W.RUNTIME.WX_MP?[3,2]:[4,u.getMiniAppCode()];case 1:return n=i.sent(),[3,4];case 2:return[4,u.getWeixinCode()];case 3:if(!(n=i.sent()))return[2,this.redirect()];i.label=4;case 4:return r=function(e){switch(e){case a.snsapi_login:return"WECHAT-OPEN";default:return"WECHAT-PUBLIC"}}(this.scope),[4,this.getRefreshTokenByWXCode(this.appid,r,n)];case 5:return o=i.sent(),s=o.refreshToken,this.cache.setStore(this.refreshTokenKey,s),o.accessToken&&this.cache.setStore(this.accessTokenKey,o.accessToken),o.accessTokenExpire&&this.cache.setStore(this.accessTokenExpireKey,o.accessTokenExpire+Date.now()),J.activateEvent(J.EVENTS.LOGIN_STATE_CHANGED),J.activateEvent(J.EVENTS.LOGIN_TYPE_CHANGE,l.LOGINTYPE.WECHAT),[2,{credential:{refreshToken:s}}]}}))}))},t.prototype.redirect=function(){var e=u.removeParam("code",location.href);e=u.removeParam("state",e),e=encodeURIComponent(e);var t="//open.weixin.qq.com/connect/oauth2/authorize";"snsapi_login"===this.scope&&(t="//open.weixin.qq.com/connect/qrconnect"),"redirect"===c[this.loginMode]&&(location.href=t+"?appid="+this.appid+"&redirect_uri="+e+"&response_type=code&scope="+this.scope+"&state="+this.state+"#wechat_redirect")},t}(l.default);n.default=p}));t(Q);var Z=n((function(t,n){var r=e&&e.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),o=e&&e.__assign||function(){return(o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]{uni.request({url:p,data:{provider:n,appid:r,spaceId:o,functionName:s,run_params:i},header:{token:process.env.USER_TOKEN},complete(n){n||(n={});const r=n.body;r||t(new Error(`[FUNCTIONS_EXECUTE_FAIL] Request Fail: [${s}]`)),console.log(`[uniCloud]${r.log}[/uniCloud]`),0===r.invokeResult&&"0"===r.invokeResult||t(new Error(r.errorMsg));const o=r.requestId;let i={};try{i=JSON.parse(r.result)}catch(e){i=r.result}e({requestId:o,result:i})}})})}le.init=function(e){const t=fe.call(this,e);t.config.provider="tencent";const n=t.auth;t.auth=function(e){const t=n.call(this,e);return["linkAndRetrieveDataWithTicket","signInAnonymously","signOut","getAccessToken","getLoginState","signInWithTicket","getUserInfo"].forEach(e=>{t[e]=d(t[e]).bind(t)}),t};if(["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile"].forEach(e=>{t[e]=d(t[e]).bind(t)}),!1!==e.autoSignIn){const e=t.auth();e.getLoginState().then(t=>{t||e.signInAnonymously()})}return t};const de={init(e){let t={};switch(e.provider){case"tencent":t=le.init(e);break;case"aliyun":t=g.init(e);break;default:throw new Error("未提供正确的provider参数")}if(!1!==e.debugFunction&&"development"===process.env.NODE_ENV&&("app-plus"===process.env.VUE_APP_PLATFORM||"h5"===process.env.VUE_APP_PLATFORM)&&process.env.USER_TOKEN)t.callFunction=function(e){d(he).call(this,e)};else{const e=t.callFunction;t.callFunction=function(t){const n=pe.call(this,t);return e.call(this,n)}}return t.init=this.init,t}};let ye=de;if(process.env.UNI_CLOUD_PROVIDER)try{ye=de.init(JSON.parse(process.env.UNI_CLOUD_PROVIDER))}catch(e){}var ve=ye;export default ve;
+var e="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){return e(t={exports:{}},t.exports),t.exports}var r=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}}(),r={},o=r.lib={},i=o.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)}},s=o.WordArray=i.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||c).stringify(this)},concat:function(e){var t=this.words,n=e.words,r=this.sigBytes,o=e.sigBytes;if(this.clamp(),r%4)for(var i=0;i>>2]>>>24-i%4*8&255;t[r+i>>>2]|=s<<24-(r+i)%4*8}else for(i=0;i>>2]=n[i>>>2];return this.sigBytes+=o,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=i.clone.call(this);return e.words=this.words.slice(0),e},random:function(t){for(var n,r=[],o=function(t){t=t;var n=987654321,r=4294967295;return function(){var o=((n=36969*(65535&n)+(n>>16)&r)<<16)+(t=18e3*(65535&t)+(t>>16)&r)&r;return o/=4294967296,(o+=.5)*(e.random()>.5?1:-1)}},i=0;i>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>3]|=parseInt(e.substr(r,2),16)<<24-r%8*4;return new s.init(n,t/2)}},u=a.Latin1={stringify:function(e){for(var t=e.words,n=e.sigBytes,r=[],o=0;o>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(e){for(var t=e.length,n=[],r=0;r>>2]|=(255&e.charCodeAt(r))<<24-r%4*8;return new s.init(n,t)}},l=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)))}},f=o.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=l.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var n=this._data,r=n.words,o=n.sigBytes,i=this.blockSize,a=o/(4*i),c=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*i,u=e.min(4*c,o);if(c){for(var l=0;l>>24)|4278255360&(o<<24|o>>>8)}var i=this._hash.words,s=e[t+0],c=e[t+1],h=e[t+2],d=e[t+3],y=e[t+4],v=e[t+5],_=e[t+6],g=e[t+7],m=e[t+8],w=e[t+9],b=e[t+10],E=e[t+11],S=e[t+12],T=e[t+13],k=e[t+14],O=e[t+15],A=i[0],P=i[1],N=i[2],I=i[3];A=u(A,P,N,I,s,7,a[0]),I=u(I,A,P,N,c,12,a[1]),N=u(N,I,A,P,h,17,a[2]),P=u(P,N,I,A,d,22,a[3]),A=u(A,P,N,I,y,7,a[4]),I=u(I,A,P,N,v,12,a[5]),N=u(N,I,A,P,_,17,a[6]),P=u(P,N,I,A,g,22,a[7]),A=u(A,P,N,I,m,7,a[8]),I=u(I,A,P,N,w,12,a[9]),N=u(N,I,A,P,b,17,a[10]),P=u(P,N,I,A,E,22,a[11]),A=u(A,P,N,I,S,7,a[12]),I=u(I,A,P,N,T,12,a[13]),N=u(N,I,A,P,k,17,a[14]),A=l(A,P=u(P,N,I,A,O,22,a[15]),N,I,c,5,a[16]),I=l(I,A,P,N,_,9,a[17]),N=l(N,I,A,P,E,14,a[18]),P=l(P,N,I,A,s,20,a[19]),A=l(A,P,N,I,v,5,a[20]),I=l(I,A,P,N,b,9,a[21]),N=l(N,I,A,P,O,14,a[22]),P=l(P,N,I,A,y,20,a[23]),A=l(A,P,N,I,w,5,a[24]),I=l(I,A,P,N,k,9,a[25]),N=l(N,I,A,P,d,14,a[26]),P=l(P,N,I,A,m,20,a[27]),A=l(A,P,N,I,T,5,a[28]),I=l(I,A,P,N,h,9,a[29]),N=l(N,I,A,P,g,14,a[30]),A=f(A,P=l(P,N,I,A,S,20,a[31]),N,I,v,4,a[32]),I=f(I,A,P,N,m,11,a[33]),N=f(N,I,A,P,E,16,a[34]),P=f(P,N,I,A,k,23,a[35]),A=f(A,P,N,I,c,4,a[36]),I=f(I,A,P,N,y,11,a[37]),N=f(N,I,A,P,g,16,a[38]),P=f(P,N,I,A,b,23,a[39]),A=f(A,P,N,I,T,4,a[40]),I=f(I,A,P,N,s,11,a[41]),N=f(N,I,A,P,d,16,a[42]),P=f(P,N,I,A,_,23,a[43]),A=f(A,P,N,I,w,4,a[44]),I=f(I,A,P,N,S,11,a[45]),N=f(N,I,A,P,O,16,a[46]),A=p(A,P=f(P,N,I,A,h,23,a[47]),N,I,s,6,a[48]),I=p(I,A,P,N,g,10,a[49]),N=p(N,I,A,P,k,15,a[50]),P=p(P,N,I,A,v,21,a[51]),A=p(A,P,N,I,S,6,a[52]),I=p(I,A,P,N,d,10,a[53]),N=p(N,I,A,P,b,15,a[54]),P=p(P,N,I,A,c,21,a[55]),A=p(A,P,N,I,m,6,a[56]),I=p(I,A,P,N,O,10,a[57]),N=p(N,I,A,P,_,15,a[58]),P=p(P,N,I,A,T,21,a[59]),A=p(A,P,N,I,y,6,a[60]),I=p(I,A,P,N,E,10,a[61]),N=p(N,I,A,P,h,15,a[62]),P=p(P,N,I,A,w,21,a[63]),i[0]=i[0]+A|0,i[1]=i[1]+P|0,i[2]=i[2]+N|0,i[3]=i[3]+I|0},_doFinalize:function(){var t=this._data,n=t.words,r=8*this._nDataBytes,o=8*t.sigBytes;n[o>>>5]|=128<<24-o%32;var i=e.floor(r/4294967296),s=r;n[15+(o+64>>>9<<4)]=16711935&(i<<8|i>>>24)|4278255360&(i<<24|i>>>8),n[14+(o+64>>>9<<4)]=16711935&(s<<8|s>>>24)|4278255360&(s<<24|s>>>8),t.sigBytes=4*(n.length+1),this._process();for(var a=this._hash,c=a.words,u=0;u<4;u++){var l=c[u];c[u]=16711935&(l<<8|l>>>24)|4278255360&(l<<24|l>>>8)}return a},clone:function(){var e=i.clone.call(this);return e._hash=this._hash.clone(),e}});function u(e,t,n,r,o,i,s){var a=e+(t&n|~t&r)+o+s;return(a<>>32-i)+t}function l(e,t,n,r,o,i,s){var a=e+(t&r|n&~r)+o+s;return(a<>>32-i)+t}function f(e,t,n,r,o,i,s){var a=e+(t^n^r)+o+s;return(a<>>32-i)+t}function p(e,t,n,r,o,i,s){var a=e+(n^(t|~r))+o+s;return(a<>>32-i)+t}t.MD5=i._createHelper(c),t.HmacMD5=i._createHmacHelper(c)}(Math),n.MD5)})),n((function(e,t){var n,o,i;e.exports=(o=(n=r).lib.Base,i=n.enc.Utf8,void(n.algo.HMAC=o.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=i.parse(t));var n=e.blockSize,r=4*n;t.sigBytes>r&&(t=e.finalize(t)),t.clamp();for(var o=this._oKey=t.clone(),s=this._iKey=t.clone(),a=o.words,c=s.words,u=0;u{uni.request(Object.assign(e,{complete(e){e||(e={}),(!e.statusCode||e.statusCode>=400)&&n(e.data||{error:{code:"Request Error",message:"请求出错"},success:!1});const r=e.data;r.error&&n(r),r.result=r.data,delete r.data,t(r)}}))})}};const s={jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",webp:"image/webp",svg:"image/svg+xml",mp3:"audio/mpeg",mp4:"video/mp4",ogg:"audio/ogg",webm:"video/webm"};function a(e){return s[e]}class c{constructor(e){["spaceId","clientSecret"].forEach(t=>{if(!Object.prototype.hasOwnProperty.call(e,t))throw new Error(`缺少参数${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.setAccessToken(uni.getStorageSync(this.config.accessTokenKey)||"")}get hasAccessToken(){return!!this.accessToken}setAccessToken(e){uni.setStorageSync(this.config.accessTokenKey,e),this.accessToken=e}requestAuth(e){return i.wrappedRequest(e)}request(e,t){return this.hasAccessToken?t?i.wrappedRequest(e):i.wrappedRequest(e).catch(t=>new Promise((e,n)=>{t&&t.error&&("GATEWAY_INVALID_TOKEN"===t.error.code||"InvalidParameter.InvalidToken"===t.error.code)?e():n(t)}).then(()=>{return 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"]=i.sign(t.data,this.config.clientSecret),t}setupRequest(e,t){const n=Object.assign({},e,{spaceId:this.config.spaceId,timestamp:Date.now()}),r={"Content-Type":"application/json"};return"auth"!==t&&(n.token=this.accessToken,r["x-basement-token"]=this.accessToken),r["x-serverless-sign"]=i.sign(n,this.config.clientSecret),{url:this.config.requestUrl,method:"POST",data:n,dataType:"json",header:r}}getAccessToken(){return 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),t(this.accessToken)):n(new Error("获取accessToken失败"))}))}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,fileName:n,name:r,filePath:o,fileType:i,contentType:s}){return new Promise((s,a)=>{uni.uploadFile({url:e,formData:t,fileName:n,name:r,filePath:o,fileType:i,header:{"X-OSS-server-side-encrpytion":"AES256"},success(e){e&&e.statusCode<400?s(e):a(new Error("Upload Fail"))},fail(e){a(e)}})})}reportOSSUpload(e){const t={method:"serverless.file.resource.report",params:JSON.stringify(e)};return this.request(this.setupRequest(t))}uploadFile({filePath:e,config:t}){const n=t&&t.envType||this.config.envType;let r,o,i,c,u,l=e.split("/").pop();return(r="h5"===process.env.VUE_APP_PLATFORM?new Promise((t,n)=>{var r=new XMLHttpRequest;r.open("GET",e,!0),r.responseType="blob",r.onload=function(){(o=function(e){let t;return Object.keys(s).forEach(n=>{s[n]===e&&(t=n)}),t}(this.response.type))||n(new Error("Unsupported File Type")),l+="."+o,t()},r.send()}):a(o=e.split(".").pop())?Promise.resolve():Promise.reject(new Error("Unsupported File Type"))).then(()=>this.getOSSUploadOptionsFromPath({env:n,filename:l})).then(t=>{const n=t.result;i=a(o),c=n.id,u="https://"+n.host+"/"+n.ossPath;const r={url:"https://"+n.host,formData:{"Cache-Control":"max-age=2592000","Content-Disposition":"attachment",OSSAccessKeyId:n.accessKeyId,Signature:n.signature,host:n.host,id:c,key:n.ossPath,policy:n.policy,success_action_status:200},fileName:"file",name:"file",filePath:e,fileType:"image",contentType:i};return this.uploadFileToOSS(r)}).then(()=>this.reportOSSUpload({id:c,contentType:i})).then(t=>new Promise((n,r)=>{t.success?n({success:!0,filePath:e,fileID:u}):r(new Error("Upload Fail"))}))}deleteFile({fileList:e}){const t={method:"serverless.file.resource.delete",params:JSON.stringify({id:e[0]})};return this.request(this.setupRequest(t))}}const u=require("uni-stat-config").default||require("uni-stat-config"),l="__DC_STAT_UUID",f="__DC_UUID_VALUE",p="https://ide.dcloud.net.cn/serverless/function/invoke";function h(){return{"app-plus":"n",h5:"h5","mp-weixin":"wx","mp-alipay":"ali","mp-baidu":"bd","mp-toutiao":"tt","mp-qq":"qq"}[process.env.VUE_APP_PLATFORM]}function d(e){return 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)}).catch(e=>{t.fail&&t.fail(e),t.complete&&t.complete(e)})}}const y=uni.getSystemInfoSync(),v={platform:process.env.VUE_APP_PLATFORM,os:y.platform},_={ak:u.appid,p:"android"===y.platform?"a":"i",ut:h(),uuid:function(){let e="";if("n"===h()){try{e=plus.runtime.getDCloudId()}catch(t){e=""}return e}try{e=uni.getStorageSync(l)}catch(t){e=f}if(!e){e=Date.now()+""+Math.floor(1e7*Math.random());try{uni.setStorageSync(l,e)}catch(e){uni.setStorageSync(l,f)}}return e}()},g={init(e){const t=new c(e);t.authorize();return["callFunction","uploadFile","deleteFile"].forEach(e=>{t[e]=d(t[e]).bind(t)}),t}};var m;!function(e){e.local="local",e.none="none",e.session="session"}(m||(m={}));var w=function(){},b=function(){};function E(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";for(var i in n)""===o?!r&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}var S,T=Object.freeze({__proto__:null,get StorageType(){return m},AbstractSDKRequest:w,AbstractStorage:b,formatUrl:E}),k=(S=function(e,t){return(S=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}S(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),O=function(){return(O=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=0;i-=1)r[i].split("=")[0]===e&&r.splice(i,1);n=n+"?"+r.join("&")}return n},t.createPromiseCallback=function(){var e;if(!Promise){(e=function(){}).promise={};var t=function(){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}var n=new Promise((function(t,n){e=function(e,r){return e?n(e):t(r)}}));return e.promise=n,e},t.getWeixinCode=function(){return t.getQuery("code")||t.getHash("code")},t.getMiniAppCode=function(){return new Promise((function(e,t){wx.login({success:function(t){e(t.code)},fail:function(e){t(e)}})}))},t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.getArgNames=function(e){var t=e.toString();return t.slice(t.indexOf("(")+1,t.indexOf(")")).match(/([^\s,]+)/g)},t.formatUrl=function(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";for(var i in n)""===o?!r&&(t+="?"):o+="&",o+=i+"="+encodeURIComponent(n[i]);return/^http(s)?\:\/\//.test(t+=o)?t:""+e+t}}));t(R);R.getQuery,R.getHash,R.removeParam,R.createPromiseCallback,R.getWeixinCode,R.getMiniAppCode,R.isArray,R.isString,R.isUndefined,R.isInstanceOf,R.isFormData,R.genSeqId,R.getArgNames,R.formatUrl;var j,U="dist/index.js",q="./dist/index.d.ts",L={build:"npm run tsc && webpack",tsc:"tsc -p tsconfig.json","tsc:w":"tsc -p tsconfig.json -w",test:"jest --verbose false -i",e2e:'NODE_ENV=e2e webpack && jest --config="./jest.e2e.config.js" --verbose false -i "e2e"',start:"webpack-dev-server --hot --open",eslint:'eslint "./**/*.js" "./**/*.ts"',"eslint-fix":'eslint --fix "./**/*.js" "./**/*.ts"',test_web:"npm run tsc && webpack-dev-server --devtool eval-source-map --progress --colors --hot --inline --content-base ./dist --host jimmytest-088bef.tcb.qcloud.la --port 80 --disableHostCheck true --mode development --config webpack.test.js"},K={type:"git",url:"https://github.com/TencentCloudBase/tcb-js-sdk"},D=["tcb","js-sdk"],M={"@cloudbase/adapter-interface":"^0.2.0","@cloudbase/adapter-wx_mp":"^0.2.1","@cloudbase/database":"^0.9.8"},F={"@babel/core":"^7.6.2","@babel/plugin-proposal-class-properties":"^7.5.5","@babel/plugin-proposal-object-rest-spread":"^7.6.2","@babel/plugin-transform-runtime":"^7.6.2","@babel/preset-env":"^7.6.2","@babel/preset-typescript":"^7.6.0","@babel/runtime":"^7.6.2","@types/jest":"^23.1.4","@types/node":"^10.14.4","@types/superagent":"^4.1.4",axios:"^0.19.0","babel-eslint":"^10.0.1","babel-loader":"^8.0.6","babel-polyfill":"^6.26.0",eslint:"^5.16.0","eslint-config-alloy":"^1.4.2","eslint-config-prettier":"^4.1.0","eslint-plugin-prettier":"^3.0.1","eslint-plugin-typescript":"^1.0.0-rc.3",express:"^4.17.1",husky:"^3.1.0",jest:"^24.7.1","jest-puppeteer":"^4.3.0","lint-staged":"^9.5.0","power-assert":"^1.6.1",puppeteer:"^1.20.0","serve-static":"^1.14.1","ts-jest":"^23.10.4","ts-loader":"^6.2.1",typescript:"^3.4.3","typescript-eslint-parser":"^22.0.0",webpack:"^4.41.3","webpack-bundle-analyzer":"^3.4.1","webpack-cli":"^3.3.0","webpack-dev-server":"^3.3.1","webpack-merge":"^4.2.2","webpack-visualizer-plugin":"^0.1.11"},G={hooks:{"pre-commit":"lint-staged"}},H={name:"tcb-js-sdk",version:"1.3.5",description:"js sdk for tcb",main:U,types:q,scripts:L,repository:K,keywords:D,author:"jimmyjzhang",license:"ISC",dependencies:M,devDependencies:F,husky:G,"lint-staged":{"*.{js,ts}":["eslint --fix","git add"]}},Y=(j=Object.freeze({__proto__:null,name:"tcb-js-sdk",version:"1.3.5",description:"js sdk for tcb",main:U,types:q,scripts:L,repository:K,keywords:D,author:"jimmyjzhang",license:"ISC",dependencies:M,devDependencies:F,husky:G,default:H}))&&j.default||j,V=n((function(t,n){var r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t};Object.defineProperty(n,"__esModule",{value:!0});var o=r(Y);n.SDK_VERISON=o.version,n.ACCESS_TOKEN="access_token",n.ACCESS_TOKEN_Expire="access_token_expire",n.REFRESH_TOKEN="refresh_token",n.ANONYMOUS_UUID="anonymous_uuid",n.LOGIN_TYPE_KEY="login_type",n.protocol="undefined"!=typeof location&&"http:"===location.protocol?"http:":"https:",n.BASE_URL="e2e"===process.env.NODE_ENV&&"pre"===process.env.END_POINT?"//tcb-pre.tencentcloudapi.com/web":"//tcb-api.tencentcloudapi.com/web"}));t(V);V.SDK_VERISON,V.ACCESS_TOKEN,V.ACCESS_TOKEN_Expire,V.REFRESH_TOKEN,V.ANONYMOUS_UUID,V.LOGIN_TYPE_KEY,V.protocol,V.BASE_URL;var B=n((function(t,n){var r=e&&e.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),o=e&&e.__assign||function(){return(o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]=0?JSON.parse(n).content:""},e.prototype.removeStore=function(e){this.storageClass.removeItem(e)},e}();n.Cache=o;var i=function(e){function t(){var t=e.call(this)||this;return W.Adapter.adapter.root.tcbObject||(W.Adapter.adapter.root.tcbObject={}),t}return r(t,e),t.prototype.setItem=function(e,t){W.Adapter.adapter.root.tcbObject[e]=t},t.prototype.getItem=function(e){return W.Adapter.adapter.root.tcbObject[e]},t.prototype.removeItem=function(e){delete W.Adapter.adapter.root.tcbObject[e]},t.prototype.clear=function(){delete W.Adapter.adapter.root.tcbObject},t}(T.AbstractStorage)}));t(z);z.Cache;var J=n((function(t,n){var r=e&&e.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),o=e&&e.__spreadArrays||function(){for(var e=0,t=0,n=arguments.length;t0},e}();n.IEventEmitter=a;var c=new a;n.addEventListener=function(e,t){c.on(e,t)},n.activateEvent=function(e,t){void 0===t&&(t={}),c.fire(e,t)},n.removeEventListener=function(e,t){c.off(e,t)},n.EVENTS={LOGIN_STATE_CHANGED:"loginStateChanged",LOGIN_STATE_EXPIRE:"loginStateExpire",LOGIN_TYPE_CHANGE:"loginTypeChanged",ANONYMOUS_CONVERTED:"anonymousConverted",REFRESH_ACCESS_TOKEN:"refreshAccessToken"}}));t(J);J.IEvent,J.IErrorEvent,J.IEventEmitter,J.addEventListener,J.activateEvent,J.removeEventListener,J.EVENTS;var X=n((function(t,n){var r=e&&e.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]Date.now())return[2,{credential:{accessToken:e,refreshToken:this.cache.getStore(this.refreshTokenKey)}}];this.cache.removeStore(this.accessTokenKey),this.cache.removeStore(this.accessTokenExpireKey)}if(!1===Object.values(a).includes(a[this.scope]))throw new Error("错误的scope类型");return W.Adapter.runtime!==W.RUNTIME.WX_MP?[3,2]:[4,u.getMiniAppCode()];case 1:return n=i.sent(),[3,4];case 2:return[4,u.getWeixinCode()];case 3:if(!(n=i.sent()))return[2,this.redirect()];i.label=4;case 4:return r=function(e){switch(e){case a.snsapi_login:return"WECHAT-OPEN";default:return"WECHAT-PUBLIC"}}(this.scope),[4,this.getRefreshTokenByWXCode(this.appid,r,n)];case 5:return o=i.sent(),s=o.refreshToken,this.cache.setStore(this.refreshTokenKey,s),o.accessToken&&this.cache.setStore(this.accessTokenKey,o.accessToken),o.accessTokenExpire&&this.cache.setStore(this.accessTokenExpireKey,o.accessTokenExpire+Date.now()),J.activateEvent(J.EVENTS.LOGIN_STATE_CHANGED),J.activateEvent(J.EVENTS.LOGIN_TYPE_CHANGE,l.LOGINTYPE.WECHAT),[2,{credential:{refreshToken:s}}]}}))}))},t.prototype.redirect=function(){var e=u.removeParam("code",location.href);e=u.removeParam("state",e),e=encodeURIComponent(e);var t="//open.weixin.qq.com/connect/oauth2/authorize";"snsapi_login"===this.scope&&(t="//open.weixin.qq.com/connect/qrconnect"),"redirect"===c[this.loginMode]&&(location.href=t+"?appid="+this.appid+"&redirect_uri="+e+"&response_type=code&scope="+this.scope+"&state="+this.state+"#wechat_redirect")},t}(l.default);n.default=p}));t(Q);var Z=n((function(t,n){var r=e&&e.__extends||function(){var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(t,n)};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),o=e&&e.__assign||function(){return(o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]{uni.request({url:p,data:{provider:n,appid:r,spaceId:o,functionName:s,run_params:i},header:{token:process.env.HBX_USER_TOKEN},complete(n){n||(n={});const r=n.body;r||t(new Error(`[FUNCTIONS_EXECUTE_FAIL] Request Fail: [${s}]`)),console.log(`[uniCloud]${r.log}[/uniCloud]`),0===r.invokeResult&&"0"===r.invokeResult||t(new Error(r.errorMsg));const o=r.requestId;let i={};try{i=JSON.parse(r.result)}catch(e){i=r.result}e({requestId:o,result:i})}})})}le.init=function(e){e.env=e.spaceId;const t=fe.call(this,e);t.config.provider="tencent",t.config.spaceId=e.spaceId;const n=t.auth;t.auth=function(e){const t=n.call(this,e);return["linkAndRetrieveDataWithTicket","signInAnonymously","signOut","getAccessToken","getLoginState","signInWithTicket","getUserInfo"].forEach(e=>{t[e]=d(t[e]).bind(t)}),t};if(["callFunction","uploadFile","deleteFile","getTempFileURL","downloadFile"].forEach(e=>{t[e]=d(t[e]).bind(t)}),!1!==e.autoSignIn){const e=t.auth();e.getLoginState().then(t=>{t||e.signInAnonymously()})}return t};const de={init(e){let t={};switch(e.provider){case"tencent":t=le.init(e);break;case"aliyun":t=g.init(e);break;default:throw new Error("未提供正确的provider参数")}if(!1!==e.debugFunction&&"development"===process.env.NODE_ENV&&("app-plus"===process.env.VUE_APP_PLATFORM||"h5"===process.env.VUE_APP_PLATFORM)&&process.env.HBX_USER_TOKEN)t.callFunction=function(e){d(he).call(this,e)};else{const e=t.callFunction;t.callFunction=function(t){const n=pe.call(this,t);return e.call(this,n)}}return t.init=this.init,t}};let ye=de;try{ye=de.init(process.env.UNI_CLOUD_PROVIDER)}catch(e){}var ve=ye;export default ve;
diff --git a/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/service/style.js b/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/service/style.js
new file mode 100644
index 0000000000000000000000000000000000000000..9e0897e5b9f64a069c082375b7f347c4a35eb83e
--- /dev/null
+++ b/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/service/style.js
@@ -0,0 +1,6 @@
+module.exports = function(source, map) {
+ console.warn(
+ `App平台 v3 模式暂不支持在 js 文件中引用"${this._module && this._module.rawRequest || this.resourcePath}"`
+ )
+ return ''
+}
diff --git a/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/main.js b/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/main.js
index a2ee5fe0c79585302930a0e2acb2eda09cc0ccff..1e1abc1d32368375e292c3e2ba8312afc34f57a6 100644
--- a/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/main.js
+++ b/packages/vue-cli-plugin-uni/packages/webpack-uni-app-loader/view/main.js
@@ -103,7 +103,7 @@ module.exports = function(source, map) {
import 'uni-pages?${JSON.stringify({type:'view'})}'
function initView(){
${getStylesCode(this)}
- injectStyles()
+ typeof injectStyles ==='function' && injectStyles()
${getDefineComponents(parseComponents(source, traverse)).join('\n')}
UniViewJSBridge.publishHandler('webviewReady')
}
diff --git a/src/core/view/bridge/subscribe/api/request-component-info.js b/src/core/view/bridge/subscribe/api/request-component-info.js
index 0ca86a2eaf06bd932bd438edbe8b0b369a5f45e3..d99c272e60c98e9adcfe6c637f3b060e7c48818f 100644
--- a/src/core/view/bridge/subscribe/api/request-component-info.js
+++ b/src/core/view/bridge/subscribe/api/request-component-info.js
@@ -50,7 +50,7 @@ function getNodeInfo (el, fields) {
info.left = rect.left
info.right = rect.right
info.top = rect.top - top
- info.bottom = rect.bottom
+ info.bottom = rect.bottom - top
}
if (fields.size) {
info.width = rect.width
diff --git a/src/platforms/mp-weixin/runtime/wrapper/component-base-parser.js b/src/platforms/mp-weixin/runtime/wrapper/component-base-parser.js
index e560022d5807cd484e4b1428a5b9e37f36a158ba..b088f3cac65afbc4dce2e0cd3295e4e51053fb78 100644
--- a/src/platforms/mp-weixin/runtime/wrapper/component-base-parser.js
+++ b/src/platforms/mp-weixin/runtime/wrapper/component-base-parser.js
@@ -77,7 +77,7 @@ export default function parseBaseComponent (vueComponentOptions, {
}
},
detached () {
- this.$vm.$destroy()
+ this.$vm && this.$vm.$destroy()
}
},
pageLifetimes: {