3
3
* iclient-classic.(https://iclient.supermap.io)
4
4
* Copyright© 2000 - 2020 SuperMap Software Co.Ltd
5
5
* license: Apache-2.0
6
- * version: v10.0.1
6
+ * version: v10.1.0-alpha
7
7
*
8
8
*/
9
9
/******/ ( function ( modules ) { // webpackBootstrap
@@ -4706,7 +4706,10 @@ var fetch_jsonp_default = /*#__PURE__*/__webpack_require__.n(fetch_jsonp);
4706
4706
4707
4707
4708
4708
4709
- const FetchRequest_fetch = window . fetch ;
4709
+ let FetchRequest_fetch = window . fetch ;
4710
+ var setFetch = function ( newFetch ) {
4711
+ FetchRequest_fetch = newFetch ;
4712
+ }
4710
4713
/**
4711
4714
* @function SuperMap.setCORS
4712
4715
* @description 设置是否允许跨域请求,全局配置,优先级低于 service 下的 crossOring 参数。
@@ -4759,12 +4762,13 @@ var FetchRequest = SuperMap.FetchRequest = {
4759
4762
}
4760
4763
} ,
4761
4764
supportDirectRequest : function ( url , options ) {
4762
- if ( Util . isInTheSameDomain ( url ) ) {
4763
- return true ;
4764
- } if ( options . crossOrigin != undefined ) {
4765
- return options . crossOrigin ;
4766
- } else {
4767
- return isCORS ( ) || options . proxy
4765
+ if ( Util . isInTheSameDomain ( url ) ) {
4766
+ return true ;
4767
+ }
4768
+ if ( options . crossOrigin != undefined ) {
4769
+ return options . crossOrigin ;
4770
+ } else {
4771
+ return isCORS ( ) || options . proxy ;
4768
4772
}
4769
4773
} ,
4770
4774
get : function ( url , params , options ) {
@@ -4785,7 +4789,6 @@ var FetchRequest = SuperMap.FetchRequest = {
4785
4789
} else {
4786
4790
return this . _postSimulatie ( type , url . substring ( 0 , url . indexOf ( '?' ) - 1 ) , params , options ) ;
4787
4791
}
4788
-
4789
4792
} ,
4790
4793
4791
4794
delete : function ( url , params , options ) {
@@ -4805,7 +4808,6 @@ var FetchRequest = SuperMap.FetchRequest = {
4805
4808
return this . _postSimulatie ( type , url . substring ( 0 , url . indexOf ( '?' ) - 1 ) , params , options ) ;
4806
4809
}
4807
4810
return this . _fetch ( url , params , options , type ) ;
4808
-
4809
4811
} ,
4810
4812
post : function ( url , params , options ) {
4811
4813
options = options || { } ;
@@ -4818,7 +4820,6 @@ var FetchRequest = SuperMap.FetchRequest = {
4818
4820
return SuperMap . Util . RequestJSONPPromise . POST ( config ) ;
4819
4821
}
4820
4822
return this . _fetch ( this . _processUrl ( url , options ) , params , options , 'POST' ) ;
4821
-
4822
4823
} ,
4823
4824
4824
4825
put : function ( url , params , options ) {
@@ -4831,10 +4832,8 @@ var FetchRequest = SuperMap.FetchRequest = {
4831
4832
data : params
4832
4833
} ;
4833
4834
return SuperMap . Util . RequestJSONPPromise . PUT ( config ) ;
4834
-
4835
4835
}
4836
4836
return this . _fetch ( url , params , options , 'PUT' ) ;
4837
-
4838
4837
} ,
4839
4838
urlIsLong : function ( url ) {
4840
4839
//当前url的字节长度。
@@ -4851,10 +4850,10 @@ var FetchRequest = SuperMap.FetchRequest = {
4851
4850
totalLength += 3 ;
4852
4851
}
4853
4852
}
4854
- return ( totalLength < 2000 ) ? false : true ;
4853
+ return totalLength < 2000 ? false : true ;
4855
4854
} ,
4856
4855
_postSimulatie : function ( type , url , params , options ) {
4857
- var separator = url . indexOf ( "?" ) > - 1 ? "&" : "?" ;
4856
+ var separator = url . indexOf ( '?' ) > - 1 ? '&' : '?' ;
4858
4857
url += separator + '_method=' + type ;
4859
4858
if ( typeof params !== 'string' ) {
4860
4859
params = JSON . stringify ( params ) ;
@@ -4868,17 +4867,17 @@ var FetchRequest = SuperMap.FetchRequest = {
4868
4867
}
4869
4868
4870
4869
if ( url . indexOf ( '.json' ) === - 1 && ! options . withoutFormatSuffix ) {
4871
- if ( url . indexOf ( "?" ) < 0 ) {
4872
- url += '.json'
4870
+ if ( url . indexOf ( '?' ) < 0 ) {
4871
+ url += '.json' ;
4873
4872
} else {
4874
- var urlArrays = url . split ( "?" ) ;
4873
+ var urlArrays = url . split ( '?' ) ;
4875
4874
if ( urlArrays . length === 2 ) {
4876
- url = urlArrays [ 0 ] + " .json?" + urlArrays [ 1 ]
4875
+ url = urlArrays [ 0 ] + ' .json?' + urlArrays [ 1 ] ;
4877
4876
}
4878
4877
}
4879
4878
}
4880
4879
if ( options && options . proxy ) {
4881
- if ( typeof options . proxy === " function" ) {
4880
+ if ( typeof options . proxy === ' function' ) {
4882
4881
url = options . proxy ( url ) ;
4883
4882
} else {
4884
4883
url = decodeURIComponent ( url ) ;
@@ -4895,70 +4894,82 @@ var FetchRequest = SuperMap.FetchRequest = {
4895
4894
options . headers [ 'Content-Type' ] = 'application/x-www-form-urlencoded;charset=UTF-8' ;
4896
4895
}
4897
4896
if ( options . timeout ) {
4898
- return this . _timeout ( options . timeout , FetchRequest_fetch ( url , {
4899
- method : type ,
4900
- headers : options . headers ,
4901
- body : type === 'PUT' || type === 'POST' ? params : undefined ,
4902
- credentials : options . withCredentials ? 'include' : 'omit' ,
4903
- mode : 'cors' ,
4904
- timeout : getRequestTimeout ( )
4905
- } ) . then ( function ( response ) {
4906
- return response ;
4907
- } ) ) ;
4897
+ return this . _timeout (
4898
+ options . timeout ,
4899
+ FetchRequest_fetch ( url , {
4900
+ method : type ,
4901
+ headers : options . headers ,
4902
+ body : type === 'PUT' || type === 'POST' ? params : undefined ,
4903
+ credentials : this . _getWithCredentials ( options ) ,
4904
+ mode : 'cors' ,
4905
+ timeout : getRequestTimeout ( )
4906
+ } ) . then ( function ( response ) {
4907
+ return response ;
4908
+ } )
4909
+ ) ;
4908
4910
}
4909
4911
return FetchRequest_fetch ( url , {
4910
4912
method : type ,
4911
4913
body : type === 'PUT' || type === 'POST' ? params : undefined ,
4912
4914
headers : options . headers ,
4913
- credentials : options . withCredentials ? 'include' : 'omit' ,
4915
+ credentials : this . _getWithCredentials ( options ) ,
4914
4916
mode : 'cors' ,
4915
4917
timeout : getRequestTimeout ( )
4916
4918
} ) . then ( function ( response ) {
4917
4919
return response ;
4918
4920
} ) ;
4919
4921
} ,
4920
4922
4923
+ _getWithCredentials : function ( options ) {
4924
+ if ( options . withCredentials === true ) {
4925
+ return 'include' ;
4926
+ }
4927
+ if ( options . withCredentials === false ) {
4928
+ return 'omit' ;
4929
+ }
4930
+ return 'same-origin' ;
4931
+ } ,
4932
+
4921
4933
_fetchJsonp : function ( url , options ) {
4922
4934
options = options || { } ;
4923
4935
return fetch_jsonp_default ( ) ( url , {
4924
- method : 'GET' ,
4925
- timeout : options . timeout
4926
- } )
4927
- . then ( function ( response ) {
4928
- return response ;
4929
- } ) ;
4936
+ method : 'GET' ,
4937
+ timeout : options . timeout
4938
+ } ) . then ( function ( response ) {
4939
+ return response ;
4940
+ } ) ;
4930
4941
} ,
4931
4942
4932
4943
_timeout : function ( seconds , promise ) {
4933
4944
return new Promise ( function ( resolve , reject ) {
4934
4945
setTimeout ( function ( ) {
4935
- reject ( new Error ( " timeout" ) )
4936
- } , seconds )
4937
- promise . then ( resolve , reject )
4938
- } )
4946
+ reject ( new Error ( ' timeout' ) ) ;
4947
+ } , seconds ) ;
4948
+ promise . then ( resolve , reject ) ;
4949
+ } ) ;
4939
4950
} ,
4940
4951
4941
4952
_getParameterString : function ( params ) {
4942
4953
var paramsArray = [ ] ;
4943
4954
for ( var key in params ) {
4944
4955
var value = params [ key ] ;
4945
- if ( ( value != null ) && ( typeof value !== 'function' ) ) {
4956
+ if ( value != null && typeof value !== 'function' ) {
4946
4957
var encodedValue ;
4947
4958
if ( Array . isArray ( value ) || value . toString ( ) === '[object Object]' ) {
4948
4959
encodedValue = encodeURIComponent ( JSON . stringify ( value ) ) ;
4949
4960
} else {
4950
4961
encodedValue = encodeURIComponent ( value ) ;
4951
4962
}
4952
- paramsArray . push ( encodeURIComponent ( key ) + "=" + encodedValue ) ;
4963
+ paramsArray . push ( encodeURIComponent ( key ) + '=' + encodedValue ) ;
4953
4964
}
4954
4965
}
4955
- return paramsArray . join ( "&" ) ;
4966
+ return paramsArray . join ( '&' ) ;
4956
4967
} ,
4957
4968
4958
4969
_isMVTRequest : function ( url ) {
4959
- return ( url . indexOf ( '.mvt' ) > - 1 || url . indexOf ( '.pbf' ) > - 1 ) ;
4970
+ return url . indexOf ( '.mvt' ) > - 1 || url . indexOf ( '.pbf' ) > - 1 ;
4960
4971
}
4961
- } ;
4972
+ }
4962
4973
SuperMap . Util . RequestJSONPPromise = {
4963
4974
limitLength : 1500 ,
4964
4975
queryKeys : [ ] ,
@@ -4968,7 +4979,7 @@ SuperMap.Util.RequestJSONPPromise = {
4968
4979
var me = this ;
4969
4980
for ( var key in values ) {
4970
4981
me . queryKeys . push ( key ) ;
4971
- if ( typeof values [ key ] !== " string" ) {
4982
+ if ( typeof values [ key ] !== ' string' ) {
4972
4983
values [ key ] = SuperMap . Util . toJSON ( values [ key ] ) ;
4973
4984
}
4974
4985
var tempValue = encodeURIComponent ( values [ key ] ) ;
@@ -4994,7 +5005,8 @@ SuperMap.Util.RequestJSONPPromise = {
4994
5005
keysCount = 0 ; //此次sectionURL中有多少个key
4995
5006
var length = me . queryKeys ? me . queryKeys . length : 0 ;
4996
5007
for ( var i = 0 ; i < length ; i ++ ) {
4997
- if ( sectionURL . length + me . queryKeys [ i ] . length + 2 >= me . limitLength ) { //+2 for ("&"or"?")and"="
5008
+ if ( sectionURL . length + me . queryKeys [ i ] . length + 2 >= me . limitLength ) {
5009
+ //+2 for ("&"or"?")and"="
4998
5010
if ( keysCount == 0 ) {
4999
5011
return false ;
5000
5012
}
@@ -5007,22 +5019,22 @@ SuperMap.Util.RequestJSONPPromise = {
5007
5019
var leftValue = me . queryValues [ i ] ;
5008
5020
while ( leftValue . length > 0 ) {
5009
5021
var leftLength = me . limitLength - sectionURL . length - me . queryKeys [ i ] . length - 2 ; //+2 for ("&"or"?")and"="
5010
- if ( sectionURL . indexOf ( "?" ) > - 1 ) {
5011
- sectionURL += "&" ;
5022
+ if ( sectionURL . indexOf ( '?' ) > - 1 ) {
5023
+ sectionURL += '&' ;
5012
5024
} else {
5013
- sectionURL += "?" ;
5025
+ sectionURL += '?' ;
5014
5026
}
5015
5027
var tempLeftValue = leftValue . substring ( 0 , leftLength ) ;
5016
5028
//避免 截断sectionURL时,将类似于%22这样的符号截成两半,从而导致服务端组装sectionURL时发生错误
5017
- if ( tempLeftValue . substring ( leftLength - 1 , leftLength ) === "%" ) {
5029
+ if ( tempLeftValue . substring ( leftLength - 1 , leftLength ) === '%' ) {
5018
5030
leftLength -= 1 ;
5019
5031
tempLeftValue = leftValue . substring ( 0 , leftLength ) ;
5020
- } else if ( tempLeftValue . substring ( leftLength - 2 , leftLength - 1 ) === "%" ) {
5032
+ } else if ( tempLeftValue . substring ( leftLength - 2 , leftLength - 1 ) === '%' ) {
5021
5033
leftLength -= 2 ;
5022
5034
tempLeftValue = leftValue . substring ( 0 , leftLength ) ;
5023
5035
}
5024
5036
5025
- sectionURL += me . queryKeys [ i ] + "=" + tempLeftValue ;
5037
+ sectionURL += me . queryKeys [ i ] + '=' + tempLeftValue ;
5026
5038
leftValue = leftValue . substring ( leftLength ) ;
5027
5039
if ( tempLeftValue . length > 0 ) {
5028
5040
splitQuestUrl . push ( sectionURL ) ;
@@ -5032,21 +5044,24 @@ SuperMap.Util.RequestJSONPPromise = {
5032
5044
}
5033
5045
} else {
5034
5046
keysCount ++ ;
5035
- if ( sectionURL . indexOf ( "?" ) > - 1 ) {
5036
- sectionURL += "&" ;
5047
+ if ( sectionURL . indexOf ( '?' ) > - 1 ) {
5048
+ sectionURL += '&' ;
5037
5049
} else {
5038
- sectionURL += "?" ;
5050
+ sectionURL += '?' ;
5039
5051
}
5040
- sectionURL += me . queryKeys [ i ] + "=" + me . queryValues [ i ] ;
5052
+ sectionURL += me . queryKeys [ i ] + '=' + me . queryValues [ i ] ;
5041
5053
}
5042
5054
}
5043
5055
}
5044
5056
splitQuestUrl . push ( sectionURL ) ;
5045
- me . send ( splitQuestUrl , "SuperMap.Util.RequestJSONPPromise.supermap_callbacks[" + uid + "]" , config && config . proxy ) ;
5057
+ me . send (
5058
+ splitQuestUrl ,
5059
+ 'SuperMap.Util.RequestJSONPPromise.supermap_callbacks[' + uid + ']' ,
5060
+ config && config . proxy
5061
+ ) ;
5046
5062
return p ;
5047
5063
} ,
5048
5064
5049
-
5050
5065
getUid : function ( ) {
5051
5066
var uid = new Date ( ) . getTime ( ) ,
5052
5067
random = Math . floor ( Math . random ( ) * 1e17 ) ;
@@ -5059,22 +5074,22 @@ SuperMap.Util.RequestJSONPPromise = {
5059
5074
var jsonpUserID = new Date ( ) . getTime ( ) ;
5060
5075
for ( var i = 0 ; i < len ; i ++ ) {
5061
5076
var url = splitQuestUrl [ i ] ;
5062
- if ( url . indexOf ( "?" ) > - 1 ) {
5063
- url += "&" ;
5077
+ if ( url . indexOf ( '?' ) > - 1 ) {
5078
+ url += '&' ;
5064
5079
} else {
5065
- url += "?" ;
5080
+ url += '?' ;
5066
5081
}
5067
- url += " sectionCount=" + len ;
5068
- url += " §ionIndex=" + i ;
5069
- url += " &jsonpUserID=" + jsonpUserID ;
5082
+ url += ' sectionCount=' + len ;
5083
+ url += ' §ionIndex=' + i ;
5084
+ url += ' &jsonpUserID=' + jsonpUserID ;
5070
5085
if ( proxy ) {
5071
5086
url = decodeURIComponent ( url ) ;
5072
5087
url = proxy + encodeURIComponent ( url ) ;
5073
5088
}
5074
5089
fetch_jsonp_default ( ) ( url , {
5075
5090
jsonpCallbackFunction : callback ,
5076
5091
timeout : 30000
5077
- } )
5092
+ } ) ;
5078
5093
}
5079
5094
}
5080
5095
} ,
0 commit comments