@seayoo-web/request 1.4.1 → 1.5.2
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/README.md +13 -2
- package/dist/inc/config.d.ts +1 -1
- package/dist/inc/main.d.ts +1 -1
- package/dist/inc/type.d.ts +12 -2
- package/dist/index.cjs +2 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.js +171 -1
- package/dist/main-CFU3RpxD.cjs +2 -0
- package/dist/main-DS7dDlqb.js +424 -0
- package/dist/node.cjs +1 -1
- package/dist/node.d.ts +9 -9
- package/dist/node.js +75 -1
- package/dist/wx.cjs +1 -1
- package/dist/wx.d.ts +6 -6
- package/dist/wx.js +57 -1
- package/package.json +15 -15
- package/coverage/base.css +0 -224
- package/coverage/block-navigation.js +0 -87
- package/coverage/clover.xml +0 -482
- package/coverage/favicon.png +0 -0
- package/coverage/prettify.css +0 -1
- package/coverage/prettify.js +0 -2
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +0 -196
package/dist/wx.d.ts
CHANGED
|
@@ -25,9 +25,9 @@ export declare const get: {
|
|
|
25
25
|
* 发送一个 POST 请求,可选 typeGuard 用于检查数据类型
|
|
26
26
|
*/
|
|
27
27
|
export declare const post: {
|
|
28
|
-
(url: string, data: string | object | unknown[] |
|
|
29
|
-
(url: string, data: string | object | unknown[] |
|
|
30
|
-
<T>(url: string, data: string | object | unknown[] |
|
|
28
|
+
(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
|
|
29
|
+
(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: null, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithoutType;
|
|
30
|
+
<T>(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithType<T>;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
33
|
* 发送一个 DELETE 请求,可选 typeGuard 用于检查数据类型
|
|
@@ -41,7 +41,7 @@ export declare const del: {
|
|
|
41
41
|
* 发送一个 PUT 请求,可选 typeGuard 用于检查数据类型
|
|
42
42
|
*/
|
|
43
43
|
export declare const put: {
|
|
44
|
-
(url: string, data: string | object | unknown[] |
|
|
45
|
-
(url: string, data: string | object | unknown[] |
|
|
46
|
-
<T>(url: string, data: string | object | unknown[] |
|
|
44
|
+
(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams): import("./inc/type").ResponseWithoutType;
|
|
45
|
+
(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: null, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithoutType;
|
|
46
|
+
<T>(url: string, data: string | object | unknown[] | ArrayBuffer | Blob | FormData | URLSearchParams, typeGard: import("./inc/type").TypeGuardParam<T>, options?: import("./inc/type").IRequestOptions | undefined): import("./inc/type").ResponseWithType<T>;
|
|
47
47
|
};
|
package/dist/wx.js
CHANGED
|
@@ -1 +1,57 @@
|
|
|
1
|
-
import{isJsonLike as e,parseJSON as t,isStringRecord as r,noop as n,sleep as s,addParamsToString as o,isEmpty as a,getTypeGuard as i,isFullURL as u,getFullURL as c}from"@seayoo-web/utils";function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},l.apply(this,arguments)}function h(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var d="message";function f(e,t){for(var r,n=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return h(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?h(e,t):void 0}}(e))){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(Array.isArray(t)?t:[t]);!(r=n()).done;){var s=r.value;if(s in e)return(o=e[s])?"string"==typeof o?o:JSON.stringify(o):""}var o;return""}var m=/<title>([^<]+)<\/title>/i,g=/<message>([^<]+)<\/message>/i;function v(e){var t=e.match(m);if(t)return t[1];var r=e.match(g);return r?r[1]:""}function y(e){return e>=200&&e<400}var b=function e(t,r,o,a,i){try{var u,c,l,h=i||0,d=Math.max(0,Math.min(10,null!=(u=null!=(c=null==a?void 0:a.maxRetry)?c:o.get("maxRetry"))?u:0)),f=null!=(l=null==a?void 0:a.retryResolve)?l:o.get("retryResolve"),m=o.get("logHandler")||n;m({type:"prepear",url:r,method:(null==a?void 0:a.method)||"GET",retry:h,maxRetry:d,message:0===h?"start":"retry "+h+"/"+d+" start",headers:null==a?void 0:a.headers,options:a});var g=Date.now();return Promise.resolve(t(r,o,a)).then(function(n){var i,u,c=n.status,l=Date.now()-g,v="[cost "+l+"]["+c+"] "+(c<0?n.body:"");m({type:"finished",url:r,method:n.method,retry:h,maxRetry:d,message:0===h?"finish "+v:"retry "+h+"/"+d+" finish "+v,response:n,headers:n.headers,cost:l});var b=y(c);if(!d||"network"===f&&c>0||"status"===f&&b||Array.isArray(f)&&!f.includes(c)||"function"==typeof f&&!0!==f(n,h)||h>=d)return n;var p=null!=(i=null!=(u=null==a?void 0:a.retryInterval)?u:o.get("retryInterval"))?i:1e3;return Promise.resolve(s(Math.max(100,"2EB"===p?1e3*Math.pow(2,h):"function"==typeof p?p(h+1)||0:p))).then(function(){return Promise.resolve(e(t,r,o,a,h+1))})})}catch(e){return Promise.reject(e)}};function p(e,t,r,n,s,o){var a=s.get("message"),i=!1!==a&&!1!==(null==o?void 0:o.message)&&((null==o?void 0:o.message)||a);return!1!==i&&s.showMessage(!e.ok,"function"==typeof i?i(e,r,n,t):t),e}var T=function(n,s,o){try{return Promise.resolve(b(P,n,s,o)).then(function(a){return function(n,s,o,a){var i,u;if(n.status<0)return p({ok:!1,status:n.status,code:n.statusText,headers:{},message:"",data:null},n.method+" "+s+" "+n.statusText,n.method,s,o,a);y(n.status)||null==(u=o.get("errorHandler"))||u(n.status,n.method,s);var c,h,m,g,b,T=l({},(c=n.status,h=n.statusText,m=n.body,g=o.get("responseRule"),b=(null==a?void 0:a.responseRule)||g,y(c)?function(n,s,o,a){var i=n||{resolve:"body"},u={ok:!0,code:o,message:"",data:null};if(202===s||204===s||!a)return u;if("body"===i.resolve)return u.data=e(a)?t(a):a,u;var c=t(a);if(!c||!r(c))return u.ok=!1,u.code="ResponseFormatError",u.message="响应内容无法格式化为 Object",u;var l=i.statusField,h=i.statusOKValue||"",m=i.dataField||"data",g=i.messageField||d,v=i.ignoreMessage||"";if(l&&!(l in c))return u.ok=!1,u.code="ResponseFieldMissing",u.message="响应内容找不到状态字段 "+l,u;var y=l?c[l]+"":"";return u.ok=!l||y===h,u.code=y||o,u.data=!0===m?c:m in c?c[m]:null,u.message=f(c,g),v&&u.message&&(Array.isArray(v)&&v.includes(u.message)||"string"==typeof v&&u.message===v)&&(u.message=""),u}(b.ok||g.ok,c,h,m):function(n,s,o){var a=n||{resolve:"json",messageField:d},i={ok:!1,code:s,message:o,data:null};switch(a.resolve){case"body":i.message=v(o)||o;break;case"json":var u=function(n,s,o){if(void 0===o&&(o=d),!e(n))return{message:""};var a=t(n);return a&&r(a)?{code:s?f(a,s):"",message:f(a,o)||n}:{message:n}}(o,a.statusField,a.messageField),c=u.message;i.code=u.code||s,i.message=v(o)||c}return i}(b.failed||g.failed,h,m)),{status:n.status,headers:Object.fromEntries(Object.entries(n.headers||{}).map(function(e){var t=e[1];return[e[0].toLowerCase(),t]}))});return null==(i=o.get("responseHandler"))||i(l({},T),n.method,s),p(T,T.ok?T.message:n.method+" "+s+" ["+(T.code||n.statusText)+"] "+(T.message||n.statusText),n.method,s,o,a)}(a,n,s,o)})}catch(e){return Promise.reject(e)}},P=function(e,t,r){try{return Promise.resolve(function(e,t,r){try{var n=Object.assign({method:"GET"},r),s="FormData"in globalThis&&n.body instanceof FormData,o=s?"POST":n.method;"GET"!==o&&"HEAD"!==o&&"DELETE"!==o||void 0!==n.body&&(console.warn("request body is invalid with method get, head, delete"),delete n.body);var a=Object.assign(s?{}:{"Content-Type":"Blob"in globalThis&&n.body instanceof Blob?n.body.type||"application/octet-stream":"application/json;charset=utf-8"},n.headers),i=n.params||{},u={};Object.keys(i).forEach(function(e){var t;void 0!==i[e]&&(u[e]="string"==typeof(t=i[e])?t:Array.isArray(t)?t.join(","):t+"")});var c=t.getFullUrl(e),l=function(e){if(e)return"string"==typeof e||e instanceof URLSearchParams||e instanceof ArrayBuffer||"Blob"in globalThis&&e instanceof Blob||"FormData"in globalThis&&e instanceof FormData?e:JSON.stringify(e)}(n.body),h=n.timeout||t.get("timeout");return Promise.resolve(function(r){try{var n=function(n){var s;return r?n:Promise.resolve(null==(s=t.get("requestHandler"))?void 0:s(a,u,o,e))},s=t.get("requestTransformer"),i=function(){if(s)return Promise.resolve(s({headers:a,params:u,method:o,url:c,body:l})).then(function(e){return r=1,e})}();return Promise.resolve(i&&i.then?i.then(n):n(i))}catch(e){return Promise.reject(e)}}()).then(function(e){var r,s="string"==typeof e&&e?e:c;return null==(r=t.get("logHandler"))||r({type:"ready",url:s,method:o,headers:a,timeout:h,body:l}),{url:s,method:o,body:l,params:u,headers:a,timeout:h,abort:n.abort,credentials:n.credentials||t.get("credentials")}})}catch(e){return Promise.reject(e)}}(e,t,r)).then(function(e){var t="PATCH"===e.method?"POST":e.method,r=o(e.url,e.params);return globalThis.wx?new Promise(function(n){wx.request({url:r,data:e.body,header:e.headers,method:t,dataType:"string",responseType:"text",fail:function(){n({url:r,method:t,status:-1,statusText:"NetworkError",body:""})},success:function(s){var o;n({url:r,method:t,status:s.statusCode,statusText:s.statusCode+"",headers:l({},s.header),body:"HEAD"===e.method?"":(o=s.data,"string"==typeof o?o:o instanceof ArrayBuffer&&"TextDecoder"in globalThis?(new TextDecoder).decode(o):JSON.stringify(o))})}})}):{url:r,method:t,status:-1,statusText:"NotSupport",body:"NotFound namespace of wx"}})}catch(e){return Promise.reject(e)}},j=/*#__PURE__*/function(){function e(e){void 0===e&&(e=500),this.ttl=void 0,this.cache=void 0,this.cache={},this.ttl=Math.max(e,0)}var t=e.prototype;return t.getKey=function(e,t){return e+Object.keys(t||{}).sort().map(function(e){return e+"#"+(null==t?void 0:t[e])}).join(",")},t.updateTTL=function(e){this.ttl=Math.max(e,0)},t.get=function(e){if(0===this.ttl)return null;var t=this.cache[e];return t?t.ttl<Date.now()?(delete this.cache[e],null):t.res:null},t.set=function(e,t){0!==this.ttl&&(this.cache[e]={ttl:Date.now()+this.ttl,res:t})},e}(),x=/*#__PURE__*/function(){function e(e){this.config={baseURL:"",maxRetry:0,retryInterval:1e3,retryResolve:"network",timeout:5e3,cacheTTL:500,credentials:"same-origin",responseRule:{ok:{resolve:"body"},failed:{resolve:"json",messageField:"message"}}},e&&this.set(e)}var t=e.prototype;return t.set=function(e){if(e.baseURL&&!/^\/.+/.test(e.baseURL)&&!u(e.baseURL))throw console.warn("baseURL 需要以 / 开头,或者是完整的 url 地址"),new Error("BaseURLError");Object.assign(this.config,e)},t.get=function(e){return this.config[e]},t.getFullUrl=function(e){return e.startsWith("/")?c(e):c(e,this.config.baseURL)},t.showMessage=function(e,t){this.config.messageHandler&&t&&this.config.messageHandler(e,t)},e}(),w=/*#__PURE__*/function(){function e(e,t){this.agent=void 0,this.config=void 0,this.cache=void 0,this.config=new x(t),this.agent=e,this.cache=new j(this.config.get("cacheTTL")),this.setConfig=this.setConfig.bind(this),this.getConfig=this.getConfig.bind(this),this.get=this.get.bind(this),this.post=this.post.bind(this),this.del=this.del.bind(this),this.patch=this.patch.bind(this),this.put=this.put.bind(this),this.head=this.head.bind(this)}var t=e.prototype;return t.exec=function(e,t){try{return Promise.resolve(this.agent(e,this.config,t))}catch(e){return Promise.reject(e)}},t.guard=function(e,t,r){try{return Promise.resolve(function(e,t,r,n){if(t.ok&&!a(t.data)&&n){var s=i(n,"响应数据未能正确识别");return s.guard(t.data)||(console.error("ResponseCheckFaild",e,t.data),r.showMessage(!0,e+" "+s.message),t.data=null),t}return t}(e,t,this.config,r))}catch(e){return Promise.reject(e)}},t.setConfig=function(e){this.config.set(e),this.cache.updateTTL(this.config.get("cacheTTL"))},t.getConfig=function(e){return this.config.get(e)},t.head=function(e,t){try{var r=this,n=Object.assign({},t||null);n.method="HEAD";var s=r.guard;return Promise.resolve(r.exec(e,n)).then(function(t){return s.call(r,e,t,null)})}catch(e){return Promise.reject(e)}},t.get=function(e,t,r){try{var n,s=function(r){if(n)return r;var s=o.exec(e,a);o.cache.set(i,s);var u=o.guard;return Promise.resolve(s).then(function(r){return u.call(o,e,r,t||null)})},o=this,a=Object.assign({},r||null);a.method="GET";var i=o.cache.getKey(e,a.params),u=o.cache.get(i),c=function(){if(u){var r=o.guard;return Promise.resolve(u).then(function(s){var a=r.call(o,e,s,t||null);return n=1,a})}}();return Promise.resolve(c&&c.then?c.then(s):s(c))}catch(e){return Promise.reject(e)}},t.post=function(e,t,r,n){try{var s=this,o=Object.assign({},n||null);o.method="POST",o.body=t;var a=s.guard;return Promise.resolve(s.exec(e,o)).then(function(t){return a.call(s,e,t,r||null)})}catch(e){return Promise.reject(e)}},t.del=function(e,t,r){try{var n=this,s=Object.assign({},r||null);s.method="DELETE";var o=n.guard;return Promise.resolve(n.exec(e,s)).then(function(r){return o.call(n,e,r,t||null)})}catch(e){return Promise.reject(e)}},t.put=function(e,t,r,n){try{var s=this,o=Object.assign({},n||null);o.method="PUT",o.body=t;var a=s.guard;return Promise.resolve(s.exec(e,o)).then(function(t){return a.call(s,e,t,r||null)})}catch(e){return Promise.reject(e)}},t.patch=function(e,t,r,n){try{var s=this,o=Object.assign({},n||null);o.method="PATCH",o.body=t;var a=s.guard;return Promise.resolve(s.exec(e,o)).then(function(t){return a.call(s,e,t,r||null)})}catch(e){return Promise.reject(e)}},e}();function O(e){return new w(T,e)}var R=O(),A=R.setConfig,E=R.head,k=R.get,F=R.post,L=R.del,C=R.put;export{O as NetRequest,L as del,k as get,E as head,F as post,C as put,A as setGlobalConfig};
|
|
1
|
+
import { a as d, b as i, c as l, r as f, N as p } from "./main-DS7dDlqb.js";
|
|
2
|
+
const h = async function(t, o, r) {
|
|
3
|
+
return d(await i(x, t, o, r), t, o, r);
|
|
4
|
+
}, x = async function(t, o, r) {
|
|
5
|
+
const e = await l(t, o, r), n = e.method === "PATCH" ? "POST" : e.method, a = f(e.url, e.params);
|
|
6
|
+
return globalThis.wx ? new Promise((c) => {
|
|
7
|
+
wx.request({
|
|
8
|
+
url: a,
|
|
9
|
+
data: e.body,
|
|
10
|
+
header: e.headers,
|
|
11
|
+
method: n,
|
|
12
|
+
dataType: "string",
|
|
13
|
+
responseType: "text",
|
|
14
|
+
fail() {
|
|
15
|
+
c({
|
|
16
|
+
url: a,
|
|
17
|
+
method: n,
|
|
18
|
+
status: -1,
|
|
19
|
+
statusText: "NetworkError",
|
|
20
|
+
body: ""
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
success(u) {
|
|
24
|
+
c({
|
|
25
|
+
url: a,
|
|
26
|
+
method: n,
|
|
27
|
+
status: u.statusCode,
|
|
28
|
+
statusText: u.statusCode + "",
|
|
29
|
+
headers: { ...u.header },
|
|
30
|
+
body: e.method === "HEAD" ? "" : y(u.data)
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}) : {
|
|
35
|
+
url: a,
|
|
36
|
+
method: n,
|
|
37
|
+
status: -1,
|
|
38
|
+
statusText: "NotSupport",
|
|
39
|
+
body: "NotFound namespace of wx"
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
function y(t) {
|
|
43
|
+
return typeof t == "string" ? t : t instanceof ArrayBuffer && "TextDecoder" in globalThis ? new TextDecoder().decode(t) : JSON.stringify(t);
|
|
44
|
+
}
|
|
45
|
+
function T(t) {
|
|
46
|
+
return new p(h, t);
|
|
47
|
+
}
|
|
48
|
+
const s = T(), m = s.setConfig, w = s.head, b = s.get, q = s.post, N = s.del, R = s.put;
|
|
49
|
+
export {
|
|
50
|
+
T as NetRequest,
|
|
51
|
+
N as del,
|
|
52
|
+
b as get,
|
|
53
|
+
w as head,
|
|
54
|
+
q as post,
|
|
55
|
+
R as put,
|
|
56
|
+
m as setGlobalConfig
|
|
57
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seayoo-web/request",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "requst tools for seayoo web",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -39,16 +39,17 @@
|
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
|
-
"node": ">=
|
|
42
|
+
"node": ">=18"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
|
-
"build": "
|
|
46
|
-
"
|
|
45
|
+
"build": "vite build && tsc --emitDeclarationOnly",
|
|
46
|
+
"emit-types": "tsc --emitDeclarationOnly",
|
|
47
47
|
"clear": "rimraf dist && rimraf node_modules",
|
|
48
|
+
"type-check": "tsc --noEmit",
|
|
48
49
|
"lint": "eslint ./src/**/*.ts",
|
|
49
50
|
"lint:fix": "eslint ./src/**/*.{ts,js} --fix",
|
|
50
51
|
"pub": "pnpm lint:fix && pnpm build && npm publish",
|
|
51
|
-
"test": "vitest --typecheck",
|
|
52
|
+
"test": "vitest --typecheck --dom",
|
|
52
53
|
"coverage": "vitest run --coverage"
|
|
53
54
|
},
|
|
54
55
|
"keywords": [
|
|
@@ -64,24 +65,23 @@
|
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
67
|
"@types/node": "18.19.5",
|
|
67
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
68
|
-
"@typescript-eslint/parser": "^6.
|
|
69
|
-
"@vitest/browser": "^1.
|
|
70
|
-
"@vitest/coverage-istanbul": "^1.
|
|
71
|
-
"eslint": "^8.
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
69
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
70
|
+
"@vitest/browser": "^1.3.1",
|
|
71
|
+
"@vitest/coverage-istanbul": "^1.3.1",
|
|
72
|
+
"eslint": "^8.57.0",
|
|
72
73
|
"eslint-config-prettier": "^9.1.0",
|
|
73
74
|
"eslint-plugin-prettier": "^5.1.3",
|
|
74
75
|
"happy-dom": "^12.10.3",
|
|
75
76
|
"lint-staged": "^14.0.1",
|
|
76
|
-
"
|
|
77
|
-
"msw": "^2.1.4",
|
|
77
|
+
"msw": "^2.2.2",
|
|
78
78
|
"rimraf": "^5.0.5",
|
|
79
79
|
"simple-git-hooks": "^2.9.0",
|
|
80
80
|
"typescript": "~5.2.2",
|
|
81
|
-
"
|
|
82
|
-
"
|
|
81
|
+
"vite": "^5.1.4",
|
|
82
|
+
"vitest": "^1.3.1"
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"@seayoo-web/utils": "^1.
|
|
85
|
+
"@seayoo-web/utils": "^1.14.1"
|
|
86
86
|
}
|
|
87
87
|
}
|
package/coverage/base.css
DELETED
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
body, html {
|
|
2
|
-
margin:0; padding: 0;
|
|
3
|
-
height: 100%;
|
|
4
|
-
}
|
|
5
|
-
body {
|
|
6
|
-
font-family: Helvetica Neue, Helvetica, Arial;
|
|
7
|
-
font-size: 14px;
|
|
8
|
-
color:#333;
|
|
9
|
-
}
|
|
10
|
-
.small { font-size: 12px; }
|
|
11
|
-
*, *:after, *:before {
|
|
12
|
-
-webkit-box-sizing:border-box;
|
|
13
|
-
-moz-box-sizing:border-box;
|
|
14
|
-
box-sizing:border-box;
|
|
15
|
-
}
|
|
16
|
-
h1 { font-size: 20px; margin: 0;}
|
|
17
|
-
h2 { font-size: 14px; }
|
|
18
|
-
pre {
|
|
19
|
-
font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
|
20
|
-
margin: 0;
|
|
21
|
-
padding: 0;
|
|
22
|
-
-moz-tab-size: 2;
|
|
23
|
-
-o-tab-size: 2;
|
|
24
|
-
tab-size: 2;
|
|
25
|
-
}
|
|
26
|
-
a { color:#0074D9; text-decoration:none; }
|
|
27
|
-
a:hover { text-decoration:underline; }
|
|
28
|
-
.strong { font-weight: bold; }
|
|
29
|
-
.space-top1 { padding: 10px 0 0 0; }
|
|
30
|
-
.pad2y { padding: 20px 0; }
|
|
31
|
-
.pad1y { padding: 10px 0; }
|
|
32
|
-
.pad2x { padding: 0 20px; }
|
|
33
|
-
.pad2 { padding: 20px; }
|
|
34
|
-
.pad1 { padding: 10px; }
|
|
35
|
-
.space-left2 { padding-left:55px; }
|
|
36
|
-
.space-right2 { padding-right:20px; }
|
|
37
|
-
.center { text-align:center; }
|
|
38
|
-
.clearfix { display:block; }
|
|
39
|
-
.clearfix:after {
|
|
40
|
-
content:'';
|
|
41
|
-
display:block;
|
|
42
|
-
height:0;
|
|
43
|
-
clear:both;
|
|
44
|
-
visibility:hidden;
|
|
45
|
-
}
|
|
46
|
-
.fl { float: left; }
|
|
47
|
-
@media only screen and (max-width:640px) {
|
|
48
|
-
.col3 { width:100%; max-width:100%; }
|
|
49
|
-
.hide-mobile { display:none!important; }
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.quiet {
|
|
53
|
-
color: #7f7f7f;
|
|
54
|
-
color: rgba(0,0,0,0.5);
|
|
55
|
-
}
|
|
56
|
-
.quiet a { opacity: 0.7; }
|
|
57
|
-
|
|
58
|
-
.fraction {
|
|
59
|
-
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
|
|
60
|
-
font-size: 10px;
|
|
61
|
-
color: #555;
|
|
62
|
-
background: #E8E8E8;
|
|
63
|
-
padding: 4px 5px;
|
|
64
|
-
border-radius: 3px;
|
|
65
|
-
vertical-align: middle;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
div.path a:link, div.path a:visited { color: #333; }
|
|
69
|
-
table.coverage {
|
|
70
|
-
border-collapse: collapse;
|
|
71
|
-
margin: 10px 0 0 0;
|
|
72
|
-
padding: 0;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
table.coverage td {
|
|
76
|
-
margin: 0;
|
|
77
|
-
padding: 0;
|
|
78
|
-
vertical-align: top;
|
|
79
|
-
}
|
|
80
|
-
table.coverage td.line-count {
|
|
81
|
-
text-align: right;
|
|
82
|
-
padding: 0 5px 0 20px;
|
|
83
|
-
}
|
|
84
|
-
table.coverage td.line-coverage {
|
|
85
|
-
text-align: right;
|
|
86
|
-
padding-right: 10px;
|
|
87
|
-
min-width:20px;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
table.coverage td span.cline-any {
|
|
91
|
-
display: inline-block;
|
|
92
|
-
padding: 0 5px;
|
|
93
|
-
width: 100%;
|
|
94
|
-
}
|
|
95
|
-
.missing-if-branch {
|
|
96
|
-
display: inline-block;
|
|
97
|
-
margin-right: 5px;
|
|
98
|
-
border-radius: 3px;
|
|
99
|
-
position: relative;
|
|
100
|
-
padding: 0 4px;
|
|
101
|
-
background: #333;
|
|
102
|
-
color: yellow;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
.skip-if-branch {
|
|
106
|
-
display: none;
|
|
107
|
-
margin-right: 10px;
|
|
108
|
-
position: relative;
|
|
109
|
-
padding: 0 4px;
|
|
110
|
-
background: #ccc;
|
|
111
|
-
color: white;
|
|
112
|
-
}
|
|
113
|
-
.missing-if-branch .typ, .skip-if-branch .typ {
|
|
114
|
-
color: inherit !important;
|
|
115
|
-
}
|
|
116
|
-
.coverage-summary {
|
|
117
|
-
border-collapse: collapse;
|
|
118
|
-
width: 100%;
|
|
119
|
-
}
|
|
120
|
-
.coverage-summary tr { border-bottom: 1px solid #bbb; }
|
|
121
|
-
.keyline-all { border: 1px solid #ddd; }
|
|
122
|
-
.coverage-summary td, .coverage-summary th { padding: 10px; }
|
|
123
|
-
.coverage-summary tbody { border: 1px solid #bbb; }
|
|
124
|
-
.coverage-summary td { border-right: 1px solid #bbb; }
|
|
125
|
-
.coverage-summary td:last-child { border-right: none; }
|
|
126
|
-
.coverage-summary th {
|
|
127
|
-
text-align: left;
|
|
128
|
-
font-weight: normal;
|
|
129
|
-
white-space: nowrap;
|
|
130
|
-
}
|
|
131
|
-
.coverage-summary th.file { border-right: none !important; }
|
|
132
|
-
.coverage-summary th.pct { }
|
|
133
|
-
.coverage-summary th.pic,
|
|
134
|
-
.coverage-summary th.abs,
|
|
135
|
-
.coverage-summary td.pct,
|
|
136
|
-
.coverage-summary td.abs { text-align: right; }
|
|
137
|
-
.coverage-summary td.file { white-space: nowrap; }
|
|
138
|
-
.coverage-summary td.pic { min-width: 120px !important; }
|
|
139
|
-
.coverage-summary tfoot td { }
|
|
140
|
-
|
|
141
|
-
.coverage-summary .sorter {
|
|
142
|
-
height: 10px;
|
|
143
|
-
width: 7px;
|
|
144
|
-
display: inline-block;
|
|
145
|
-
margin-left: 0.5em;
|
|
146
|
-
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
|
|
147
|
-
}
|
|
148
|
-
.coverage-summary .sorted .sorter {
|
|
149
|
-
background-position: 0 -20px;
|
|
150
|
-
}
|
|
151
|
-
.coverage-summary .sorted-desc .sorter {
|
|
152
|
-
background-position: 0 -10px;
|
|
153
|
-
}
|
|
154
|
-
.status-line { height: 10px; }
|
|
155
|
-
/* yellow */
|
|
156
|
-
.cbranch-no { background: yellow !important; color: #111; }
|
|
157
|
-
/* dark red */
|
|
158
|
-
.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
|
|
159
|
-
.low .chart { border:1px solid #C21F39 }
|
|
160
|
-
.highlighted,
|
|
161
|
-
.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{
|
|
162
|
-
background: #C21F39 !important;
|
|
163
|
-
}
|
|
164
|
-
/* medium red */
|
|
165
|
-
.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
|
|
166
|
-
/* light red */
|
|
167
|
-
.low, .cline-no { background:#FCE1E5 }
|
|
168
|
-
/* light green */
|
|
169
|
-
.high, .cline-yes { background:rgb(230,245,208) }
|
|
170
|
-
/* medium green */
|
|
171
|
-
.cstat-yes { background:rgb(161,215,106) }
|
|
172
|
-
/* dark green */
|
|
173
|
-
.status-line.high, .high .cover-fill { background:rgb(77,146,33) }
|
|
174
|
-
.high .chart { border:1px solid rgb(77,146,33) }
|
|
175
|
-
/* dark yellow (gold) */
|
|
176
|
-
.status-line.medium, .medium .cover-fill { background: #f9cd0b; }
|
|
177
|
-
.medium .chart { border:1px solid #f9cd0b; }
|
|
178
|
-
/* light yellow */
|
|
179
|
-
.medium { background: #fff4c2; }
|
|
180
|
-
|
|
181
|
-
.cstat-skip { background: #ddd; color: #111; }
|
|
182
|
-
.fstat-skip { background: #ddd; color: #111 !important; }
|
|
183
|
-
.cbranch-skip { background: #ddd !important; color: #111; }
|
|
184
|
-
|
|
185
|
-
span.cline-neutral { background: #eaeaea; }
|
|
186
|
-
|
|
187
|
-
.coverage-summary td.empty {
|
|
188
|
-
opacity: .5;
|
|
189
|
-
padding-top: 4px;
|
|
190
|
-
padding-bottom: 4px;
|
|
191
|
-
line-height: 1;
|
|
192
|
-
color: #888;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
.cover-fill, .cover-empty {
|
|
196
|
-
display:inline-block;
|
|
197
|
-
height: 12px;
|
|
198
|
-
}
|
|
199
|
-
.chart {
|
|
200
|
-
line-height: 0;
|
|
201
|
-
}
|
|
202
|
-
.cover-empty {
|
|
203
|
-
background: white;
|
|
204
|
-
}
|
|
205
|
-
.cover-full {
|
|
206
|
-
border-right: none !important;
|
|
207
|
-
}
|
|
208
|
-
pre.prettyprint {
|
|
209
|
-
border: none !important;
|
|
210
|
-
padding: 0 !important;
|
|
211
|
-
margin: 0 !important;
|
|
212
|
-
}
|
|
213
|
-
.com { color: #999 !important; }
|
|
214
|
-
.ignore-none { color: #999; font-weight: normal; }
|
|
215
|
-
|
|
216
|
-
.wrapper {
|
|
217
|
-
min-height: 100%;
|
|
218
|
-
height: auto !important;
|
|
219
|
-
height: 100%;
|
|
220
|
-
margin: 0 auto -48px;
|
|
221
|
-
}
|
|
222
|
-
.footer, .push {
|
|
223
|
-
height: 48px;
|
|
224
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
var jumpToCode = (function init() {
|
|
3
|
-
// Classes of code we would like to highlight in the file view
|
|
4
|
-
var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];
|
|
5
|
-
|
|
6
|
-
// Elements to highlight in the file listing view
|
|
7
|
-
var fileListingElements = ['td.pct.low'];
|
|
8
|
-
|
|
9
|
-
// We don't want to select elements that are direct descendants of another match
|
|
10
|
-
var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `
|
|
11
|
-
|
|
12
|
-
// Selecter that finds elements on the page to which we can jump
|
|
13
|
-
var selector =
|
|
14
|
-
fileListingElements.join(', ') +
|
|
15
|
-
', ' +
|
|
16
|
-
notSelector +
|
|
17
|
-
missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
|
|
18
|
-
|
|
19
|
-
// The NodeList of matching elements
|
|
20
|
-
var missingCoverageElements = document.querySelectorAll(selector);
|
|
21
|
-
|
|
22
|
-
var currentIndex;
|
|
23
|
-
|
|
24
|
-
function toggleClass(index) {
|
|
25
|
-
missingCoverageElements
|
|
26
|
-
.item(currentIndex)
|
|
27
|
-
.classList.remove('highlighted');
|
|
28
|
-
missingCoverageElements.item(index).classList.add('highlighted');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function makeCurrent(index) {
|
|
32
|
-
toggleClass(index);
|
|
33
|
-
currentIndex = index;
|
|
34
|
-
missingCoverageElements.item(index).scrollIntoView({
|
|
35
|
-
behavior: 'smooth',
|
|
36
|
-
block: 'center',
|
|
37
|
-
inline: 'center'
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function goToPrevious() {
|
|
42
|
-
var nextIndex = 0;
|
|
43
|
-
if (typeof currentIndex !== 'number' || currentIndex === 0) {
|
|
44
|
-
nextIndex = missingCoverageElements.length - 1;
|
|
45
|
-
} else if (missingCoverageElements.length > 1) {
|
|
46
|
-
nextIndex = currentIndex - 1;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
makeCurrent(nextIndex);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function goToNext() {
|
|
53
|
-
var nextIndex = 0;
|
|
54
|
-
|
|
55
|
-
if (
|
|
56
|
-
typeof currentIndex === 'number' &&
|
|
57
|
-
currentIndex < missingCoverageElements.length - 1
|
|
58
|
-
) {
|
|
59
|
-
nextIndex = currentIndex + 1;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
makeCurrent(nextIndex);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return function jump(event) {
|
|
66
|
-
if (
|
|
67
|
-
document.getElementById('fileSearch') === document.activeElement &&
|
|
68
|
-
document.activeElement != null
|
|
69
|
-
) {
|
|
70
|
-
// if we're currently focused on the search input, we don't want to navigate
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
switch (event.which) {
|
|
75
|
-
case 78: // n
|
|
76
|
-
case 74: // j
|
|
77
|
-
goToNext();
|
|
78
|
-
break;
|
|
79
|
-
case 66: // b
|
|
80
|
-
case 75: // k
|
|
81
|
-
case 80: // p
|
|
82
|
-
goToPrevious();
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
})();
|
|
87
|
-
window.addEventListener('keydown', jumpToCode);
|