vite-uni-dev-tool 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/const.d.ts +133 -0
- package/dist/const.d.ts.map +1 -0
- package/dist/const.js +36 -0
- package/dist/core.d.ts +52 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +80 -0
- package/dist/devConsole/index.d.ts +169 -0
- package/dist/devConsole/index.d.ts.map +1 -0
- package/dist/devConsole/index.js +270 -0
- package/dist/devEvent/index.d.ts +286 -0
- package/dist/devEvent/index.d.ts.map +1 -0
- package/dist/devEvent/index.js +435 -0
- package/dist/devEventBus/index.d.ts +42 -0
- package/dist/devEventBus/index.d.ts.map +1 -0
- package/dist/devEventBus/index.js +70 -0
- package/dist/devIntercept/index.d.ts +119 -0
- package/dist/devIntercept/index.d.ts.map +1 -0
- package/dist/devIntercept/index.js +582 -0
- package/dist/devRunJS/index.d.ts +67 -0
- package/dist/devRunJS/index.d.ts.map +1 -0
- package/dist/devStore/index.d.ts +178 -0
- package/dist/devStore/index.d.ts.map +1 -0
- package/dist/devStore/index.js +395 -0
- package/dist/devToolInfo/index.d.ts +17 -0
- package/dist/devToolInfo/index.d.ts.map +1 -0
- package/dist/devToolInfo/index.js +15 -0
- package/{dev → dist}/plugins/uniDevTool/uniDevTool.d.ts +7 -1
- package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -0
- package/dist/plugins/uniDevTool/uniDevTool.js +35 -0
- package/{dev → dist}/plugins/utils/index.d.ts +3 -0
- package/{dev → dist}/plugins/utils/index.d.ts.map +1 -1
- package/dist/plugins/utils/index.js +1 -0
- package/dist/type.d.ts +264 -0
- package/dist/type.d.ts.map +1 -0
- package/dist/utils/array.d.ts +2 -0
- package/dist/utils/array.d.ts.map +1 -0
- package/dist/utils/array.js +12 -0
- package/dist/utils/date.d.ts +19 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/date.js +40 -0
- package/dist/utils/file.d.ts +11 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +87 -0
- package/dist/utils/function.d.ts +28 -0
- package/dist/utils/function.d.ts.map +1 -0
- package/dist/utils/function.js +46 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +55 -0
- package/dist/utils/ip.d.ts +5 -0
- package/dist/utils/ip.d.ts.map +1 -0
- package/dist/utils/ip.js +21 -0
- package/dist/utils/language.d.ts +29 -0
- package/dist/utils/language.d.ts.map +1 -0
- package/dist/utils/language.js +50 -0
- package/dist/utils/object.d.ts +49 -0
- package/dist/utils/object.d.ts.map +1 -0
- package/dist/utils/object.js +118 -0
- package/dist/utils/page.d.ts +7 -0
- package/dist/utils/page.d.ts.map +1 -0
- package/dist/utils/page.js +7 -0
- package/dist/utils/platform.d.ts +4 -0
- package/dist/utils/platform.d.ts.map +1 -0
- package/dist/utils/platform.js +14 -0
- package/dist/utils/string.d.ts +45 -0
- package/dist/utils/string.d.ts.map +1 -0
- package/dist/utils/string.js +88 -0
- package/dist/utils/utils.d.ts +16 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/v2/AutoSizer/utils.d.ts +5 -0
- package/dist/v2/AutoSizer/utils.d.ts.map +1 -0
- package/dist/v2/JsonPretty/hooks/useClipboard.d.ts +4 -0
- package/dist/v2/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
- package/dist/v2/JsonPretty/hooks/useError.d.ts +8 -0
- package/dist/v2/JsonPretty/hooks/useError.d.ts.map +1 -0
- package/dist/v2/JsonPretty/type.d.ts +93 -0
- package/dist/v2/JsonPretty/type.d.ts.map +1 -0
- package/dist/v3/AutoSizer/utils.d.ts +5 -0
- package/dist/v3/AutoSizer/utils.d.ts.map +1 -0
- package/dist/v3/ConsoleList/staticTips.d.ts +13 -0
- package/dist/v3/ConsoleList/staticTips.d.ts.map +1 -0
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts +4 -0
- package/dist/v3/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
- package/dist/v3/JsonPretty/hooks/useError.d.ts +8 -0
- package/dist/v3/JsonPretty/hooks/useError.d.ts.map +1 -0
- package/dist/v3/JsonPretty/type.d.ts +93 -0
- package/dist/v3/JsonPretty/type.d.ts.map +1 -0
- package/dist/v3/JsonPretty/utils/index.d.ts +10 -0
- package/dist/v3/JsonPretty/utils/index.d.ts.map +1 -0
- package/package.json +5 -5
- package/dev/components/AppInfo/index.vue +0 -36
- package/dev/components/AutoSizer/index.vue +0 -193
- package/dev/components/AutoSizer/index1.vue +0 -186
- package/dev/components/AutoSizer/utils.ts +0 -49
- package/dev/components/Button/index.vue +0 -34
- package/dev/components/CaptureScreen/index.vue +0 -62
- package/dev/components/Checkbox/index.vue +0 -40
- package/dev/components/CloseButton/index.vue +0 -26
- package/dev/components/Code/index.vue +0 -230
- package/dev/components/Connection/index.vue +0 -88
- package/dev/components/ConsoleList/Code.vue +0 -227
- package/dev/components/ConsoleList/ConsoleItem.vue +0 -207
- package/dev/components/ConsoleList/RunJSInput.vue +0 -237
- package/dev/components/ConsoleList/index.vue +0 -139
- package/dev/components/ConsoleList/staticTips.ts +0 -1145
- package/dev/components/DevTool/index.vue +0 -188
- package/dev/components/DevToolButton/index.vue +0 -210
- package/dev/components/DevToolTitle/index.vue +0 -21
- package/dev/components/DevToolWindow/index.vue +0 -1053
- package/dev/components/DeviceInfo/index.vue +0 -32
- package/dev/components/Empty/empty.png +0 -0
- package/dev/components/Empty/index.vue +0 -28
- package/dev/components/FilterInput/index.vue +0 -86
- package/dev/components/JsonPretty/components/Brackets/index.vue +0 -23
- package/dev/components/JsonPretty/components/Carets/index.vue +0 -59
- package/dev/components/JsonPretty/components/CheckController/index.vue +0 -125
- package/dev/components/JsonPretty/components/TreeNode/index.vue +0 -349
- package/dev/components/JsonPretty/hooks/useClipboard.ts +0 -21
- package/dev/components/JsonPretty/hooks/useError.ts +0 -21
- package/dev/components/JsonPretty/index.vue +0 -476
- package/dev/components/JsonPretty/type.ts +0 -125
- package/dev/components/JsonPretty/utils/index.ts +0 -172
- package/dev/components/NetworkList/NetworkDetail.vue +0 -194
- package/dev/components/NetworkList/NetworkItem.vue +0 -119
- package/dev/components/NetworkList/index.vue +0 -128
- package/dev/components/PiniaList/index.vue +0 -64
- package/dev/components/RouteList/index.vue +0 -121
- package/dev/components/RunJS/index.vue +0 -128
- package/dev/components/SettingList/index.vue +0 -222
- package/dev/components/SourceCode/index.vue +0 -231
- package/dev/components/StorageList/index.vue +0 -170
- package/dev/components/SystemInfo/index.vue +0 -34
- package/dev/components/Tabs/index.vue +0 -123
- package/dev/components/Tag/index.vue +0 -89
- package/dev/components/UniEvent/UniEventItem.vue +0 -126
- package/dev/components/UniEvent/index.vue +0 -98
- package/dev/components/UploadList/UploadDetail.vue +0 -204
- package/dev/components/UploadList/UploadItem.vue +0 -117
- package/dev/components/UploadList/index.vue +0 -117
- package/dev/components/VirtualList/index.vue +0 -112
- package/dev/components/VirtualListPro/AutoSize.vue +0 -43
- package/dev/components/VirtualListPro/index.vue +0 -238
- package/dev/components/VirtualListPro/readme.md +0 -40
- package/dev/components/VuexList/index.vue +0 -54
- package/dev/components/WebSocket/WebSocketItem.vue +0 -103
- package/dev/components/WebSocket/WebSocketList.vue +0 -173
- package/dev/components/WebSocket/index.vue +0 -124
- package/dev/components/WindowInfo/index.vue +0 -33
- package/dev/const.ts +0 -164
- package/dev/core.ts +0 -118
- package/dev/devConsole/index.ts +0 -350
- package/dev/devEvent/index.ts +0 -810
- package/dev/devEventBus/index.ts +0 -94
- package/dev/devIntercept/index.ts +0 -745
- package/dev/devRunJS/index.ts +0 -170
- package/dev/devStore/index.ts +0 -732
- package/dev/devToolInfo/index.ts +0 -26
- package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +0 -1
- package/dev/plugins/uniDevTool/uniDevTool.js +0 -36
- package/dev/plugins/utils/index.js +0 -1
- package/dev/shims-uni.d.ts +0 -43
- package/dev/type.ts +0 -291
- package/dev/utils/array.ts +0 -15
- package/dev/utils/date.ts +0 -75
- package/dev/utils/file.ts +0 -121
- package/dev/utils/function.ts +0 -192
- package/dev/utils/index.d.ts +0 -6
- package/dev/utils/index.ts +0 -51
- package/dev/utils/ip.ts +0 -79
- package/dev/utils/language.ts +0 -77
- package/dev/utils/object.ts +0 -306
- package/dev/utils/page.ts +0 -13
- package/dev/utils/platform.ts +0 -14
- package/dev/utils/string.ts +0 -133
- package/dev/utils/utils.ts +0 -198
- /package/{dev → dist}/index.d.ts +0 -0
- /package/{dev → dist}/index.d.ts.map +0 -0
- /package/{dev → dist}/index.js +0 -0
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +0 -0
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +0 -0
- /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.js +0 -0
package/dev/devToolInfo/index.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { DEV_TOOL_INFO } from '../const';
|
|
2
|
-
import type { DevTool } from '../type';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 缓存调试工具信息到本地
|
|
6
|
-
*
|
|
7
|
-
* @export
|
|
8
|
-
* @param {DevTool.DevToolInfo} info
|
|
9
|
-
*/
|
|
10
|
-
export function setDevToolInfo(info: DevTool.DevToolInfo) {
|
|
11
|
-
const devInfo = uni.getStorageSync(DEV_TOOL_INFO);
|
|
12
|
-
uni.setStorageSync(DEV_TOOL_INFO, {
|
|
13
|
-
...devInfo,
|
|
14
|
-
...info,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* 获取本地缓存信息
|
|
20
|
-
*
|
|
21
|
-
* @export
|
|
22
|
-
* @return {*}
|
|
23
|
-
*/
|
|
24
|
-
export function getDevToolInfo() {
|
|
25
|
-
return uni.getStorageSync(DEV_TOOL_INFO) as DevTool.DevToolInfo;
|
|
26
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uniDevTool.d.ts","sourceRoot":"","sources":["../../../../plugins/src/plugins/uniDevTool/uniDevTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAqBnC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,KAAK,EACL,iBAAiB,EACjB,aAAa,EACb,GAAG,KAAK,EACT,EAAE;IACD,qCAAqC;IACrC,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,gBAAgB;IAChB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,mBAAmB;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,gBAAgB;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,iBAAiB;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,qBAAqB;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe;IACf,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,WAAW;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,aAAa;IACb,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,wBAAwB;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,oBAAoB;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,6CAA6C;IAC7C,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,kBAAkB;IAClB,KAAK,EAAE;QACL,KAAK,EAAE;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC1B,WAAW,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAA;aAAE,EAAE,CAAA;SAAE,EAAE,CAAC;KAC7D,CAAC;CACH,GAAG,MAAM,CAyNT"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";const I=require("path"),C=require("fs"),u=require("../utils/index.js");function $(a){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const l in a)if(l!=="default"){const f=Object.getOwnPropertyDescriptor(a,l);Object.defineProperty(d,l,f.get?f:{enumerable:!0,get:()=>a[l]})}}return d.default=a,Object.freeze(d)}const S=$(I),D=$(C),g=/<script[^>]*>([\s\S]*?)<\/script>/,_={isReady:!1,urls:[]};function y({pages:a,sourceFileServers:d,importConsole:l,...f}){return{name:"vite-uni-dev-tool",enforce:"pre",configureServer(e){var p;e.middlewares.use((s,n,t)=>{const{originalUrl:r}=s;if(f.useDevSource&&(r!=null&&r.includes("__dev_sourcefile__"))){const i=r.replace("/__dev_sourcefile__","");try{const c=e.config.root,v=S.join(c,i),o=D.readFileSync(v,"utf-8");n.setHeader("Content-Type",u.getContentType(v)),n.end(o)}catch{t()}}else t()}),(p=e.httpServer)==null||p.once("listening",()=>{var t;const s=(t=e.httpServer)==null?void 0:t.address(),n=u.getLocalIPs();if(s&&!Array.isArray(s)&&typeof s!="string"){const r=n.map(i=>`http://${i}:${s.port}/__dev_sourcefile__`);_.isReady=!0,_.urls=r,console.warn(`
|
|
2
|
-
⚡️ vite-uni-dev-tool source file server running at:
|
|
3
|
-
${n.map(i=>`➜ Source File Network: http://${i}:${s==null?void 0:s.port}/__dev_sourcefile__`).join(`
|
|
4
|
-
`)}
|
|
5
|
-
`)}})},transform(e,p){var s;if(p.endsWith("/src/main.ts"))try{const n=e.split(`
|
|
6
|
-
`);let t=[...n];const r=u.findInsertionIndex(t,c=>c.trim().startsWith("import")||c.trim().startsWith("export"));r!==-1&&t.splice(r,0,"import DevTool from 'vite-uni-dev-tool/dev/components/DevTool/index.vue';");const i=u.findInsertionIndex(t,c=>c.includes(".mount(")||c.includes("createApp("));if(i!==-1&&t.splice(i+1,0," app.component('DevTool', DevTool);"),t.length!==n.length)return{code:t.join(`
|
|
7
|
-
`),map:null}}catch(n){return console.error("[DevTool] 转换 main 文件时出错:",n),{code:e,map:null}}if(p.endsWith("/src/App.vue")){const n=e.match(g);if(n&&n[1]){const t=n[1].trim(),r=u.hasImportCurrentInstance(t),i=u.hasImportOnLaunch(t),c=r?"":"import { getCurrentInstance } from 'vue'",v=i?"":"import { onLaunch } from '@dcloudio/uni-app'",o=`
|
|
8
|
-
import { initDevTool${l?", console":""} } from 'vite-uni-dev-tool/dev/core';
|
|
9
|
-
import pagesJson from './pages.json';
|
|
10
|
-
${t}
|
|
11
|
-
onLaunch(() => {
|
|
12
|
-
const vue3instance = getCurrentInstance();
|
|
13
|
-
initDevTool({
|
|
14
|
-
pagesJson,
|
|
15
|
-
vue3instance,
|
|
16
|
-
mode: import.meta.env.MODE,
|
|
17
|
-
sourceFileServers: [
|
|
18
|
-
${[..._.urls??[],...d??[]].map(h=>`'${h}'`)}
|
|
19
|
-
],
|
|
20
|
-
useDevSource: ${f.useDevSource},
|
|
21
|
-
...${JSON.stringify(f)},
|
|
22
|
-
});
|
|
23
|
-
});`;return{code:e.replace(g,`
|
|
24
|
-
<script lang="ts" setup>
|
|
25
|
-
${c}
|
|
26
|
-
${v}
|
|
27
|
-
${o}
|
|
28
|
-
<\/script>`),map:null}}return{code:e,map:null}}if(p.endsWith(".vue")){const n=e.includes("<template>"),t=a.pages.some(o=>p.includes(o.path)),r=(s=a.subPackages)==null?void 0:s.some(o=>o.pages.some(m=>p.includes(`${o.root}/${m.path}`))),i=["<DevTool />"],c=u.hasImportConsole(e),v=u.hasUseConsole(e);if(!c&&v&&!p.endsWith("/src/App.vue")){const o=e.match(g);if(o&&o[1]){const m=o[1],h=`
|
|
29
|
-
${l?"import { console } from 'vite-uni-dev-tool/dev/core';":""}
|
|
30
|
-
${m}
|
|
31
|
-
`;e=e.replace(g,`
|
|
32
|
-
<script lang="ts" setup>
|
|
33
|
-
${h}
|
|
34
|
-
<\/script>`)}}if((t||r)&&n){const o=u.getTemplateContent(e);let m=e;if(o){const h=`<view>${o}
|
|
35
|
-
${i.join(`
|
|
36
|
-
`)}</view>`;m=e.replace(o,h)}return{code:m,map:null}}}return{code:e,map:null}}}}module.exports=y;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("path"),f=require("os");function i(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,o.get?o:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const m=i(g),h=i(f);function d(t,n){for(let e=0;e<t.length;e++)if(n(t[e]))return e+1;return-1}function x(t){const n=m.extname(t).toLowerCase();return{".html":"text/html",".js":"text/javascript",".css":"text/css",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".woff":"font/woff",".woff2":"font/woff2"}[n]||"text/plain"}function I(){const t=h.networkInterfaces(),n=[];return Object.keys(t).forEach(e=>{var o;t!=null&&t[e]&&Array.isArray(t==null?void 0:t[e])&&((o=t==null?void 0:t[e])==null||o.forEach(r=>{r.family==="IPv4"&&!r.internal&&n.push(r.address)}))}),n.push("localhost"),n}const y=/import\s*\{[^}]*onLaunch[^}]*\}\s*from\s+['"]@dcloudio\/uni-app['"];?/;function C(t){return y.test(t)}const j=/import\s*\{[^}]*getCurrentInstance[^}]*\}\s*from\s+['"]vue['"];?/;function b(t){return j.test(t)}const w=/import\s*\{[^}]*console[^}]*\}\s*from\s+['"]vite-uni-dev-tool['"];?/;function v(t){return w.test(t)}const O=/console\.\w+\(/;function T(t){return O.test(t)}function L(t){let n=0,e=-1,o=-1,r="";const l=/<template(\s[^>]*)?>/g,p=/<\/template>/g,c=[];let a;for(;(a=l.exec(t))!==null;)c.push({index:a.index,type:"start",length:a[0].length});for(;(a=p.exec(t))!==null;)c.push({index:a.index,type:"end",length:a[0].length});c.sort((s,u)=>s.index-u.index);for(const s of c)if(s.type==="start")n===0&&(e=s.index+s.length),n++;else if(s.type==="end"&&(n--,n===0)){o=s.index,r=t.substring(e,o);break}return r.trim()}exports.findInsertionIndex=d;exports.getContentType=x;exports.getLocalIPs=I;exports.getTemplateContent=L;exports.hasImportConsole=v;exports.hasImportCurrentInstance=b;exports.hasImportOnLaunch=C;exports.hasUseConsole=T;
|
package/dev/shims-uni.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/// <reference types='@dcloudio/types' />
|
|
2
|
-
import 'vue';
|
|
3
|
-
|
|
4
|
-
declare module 'vue' {
|
|
5
|
-
type Hooks = App.AppInstance & Page.PageInstance;
|
|
6
|
-
interface ComponentCustomOptions extends Hooks {}
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
declare global {
|
|
11
|
-
interface Uni {
|
|
12
|
-
/**
|
|
13
|
-
* 小程序下拥有的环境变量
|
|
14
|
-
* 目前微信小程序下支持
|
|
15
|
-
*/
|
|
16
|
-
env: {
|
|
17
|
-
USER_DATA_PATH: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
__dev__console: {
|
|
22
|
-
log: Function;
|
|
23
|
-
error: Function;
|
|
24
|
-
warn: Function;
|
|
25
|
-
info: Function;
|
|
26
|
-
time: Function;
|
|
27
|
-
timeEnd: Function;
|
|
28
|
-
clear: Function;
|
|
29
|
-
count: Function;
|
|
30
|
-
countReset: Function;
|
|
31
|
-
assert: Function;
|
|
32
|
-
debug: Function;
|
|
33
|
-
dir: Function;
|
|
34
|
-
dirxml: Function;
|
|
35
|
-
group: Function;
|
|
36
|
-
groupCollapsed: Function;
|
|
37
|
-
groupEnd: Function;
|
|
38
|
-
table: Function;
|
|
39
|
-
timeStamp: Function;
|
|
40
|
-
trace: Function;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
package/dev/type.ts
DELETED
|
@@ -1,291 +0,0 @@
|
|
|
1
|
-
import { DevEvent } from './devEvent';
|
|
2
|
-
export declare namespace DevTool {
|
|
3
|
-
type Page = {
|
|
4
|
-
index?: number;
|
|
5
|
-
path: string;
|
|
6
|
-
sort?: number;
|
|
7
|
-
name?: string;
|
|
8
|
-
type?: string;
|
|
9
|
-
style: {
|
|
10
|
-
navigationBarTitleText?: string;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
type Message = {
|
|
15
|
-
type: 'success' | 'error';
|
|
16
|
-
data: string;
|
|
17
|
-
time: number;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
type WS = {
|
|
21
|
-
url: string;
|
|
22
|
-
/**
|
|
23
|
-
* -1: error
|
|
24
|
-
* 0:connecting
|
|
25
|
-
* 1:open
|
|
26
|
-
* 2:closing
|
|
27
|
-
* 3:closed
|
|
28
|
-
*/
|
|
29
|
-
readyState?: string;
|
|
30
|
-
headers?: { key: string; value: string }[];
|
|
31
|
-
method?: string;
|
|
32
|
-
protocols?: string[];
|
|
33
|
-
message: Message[];
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
type Nav = {
|
|
37
|
-
pagePath: string;
|
|
38
|
-
text: string;
|
|
39
|
-
};
|
|
40
|
-
type PagesJSON = {
|
|
41
|
-
pages: Page[];
|
|
42
|
-
subPackages?: { root: string; pages: Page[] }[];
|
|
43
|
-
tabBar: {
|
|
44
|
-
list: Nav[];
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
type DevToolOptions = {
|
|
49
|
-
/** 是否拦截Promise.reject 最好不要拦截 默认禁用 */
|
|
50
|
-
enableInterceptPromiseReject?: boolean;
|
|
51
|
-
/** 打开窗口时隐藏按钮 */
|
|
52
|
-
openWindowHideButton?: boolean;
|
|
53
|
-
/** 最大的console条数 */
|
|
54
|
-
consoleMaxSize?: number;
|
|
55
|
-
/** 最大的网络请求条数 */
|
|
56
|
-
networkMaxSize?: number;
|
|
57
|
-
/** 最大的上传文件条数 */
|
|
58
|
-
uploadMaxSize?: number;
|
|
59
|
-
/** 最大的套接字消息条数 */
|
|
60
|
-
wsDataMaxSize?: number;
|
|
61
|
-
/** 最大的时间列表条数 */
|
|
62
|
-
eventListMaxSize?: number;
|
|
63
|
-
/** 最大截屏记录条数 */
|
|
64
|
-
captureScreenMaxSize?: number;
|
|
65
|
-
/** 最大占用缓存空间 */
|
|
66
|
-
cacheMaxSize?: number;
|
|
67
|
-
/** 所有路由信息 */
|
|
68
|
-
pagesJson?: PagesJSON;
|
|
69
|
-
/** 源文件服务地址 */
|
|
70
|
-
sourceFileServers?: string[];
|
|
71
|
-
/** 用于区分生产环境和开发环境,开发环境下,为了获取 Android 异常栈源码会获取本地源码进行展示 */
|
|
72
|
-
mode: string;
|
|
73
|
-
/** 用于捕获 vue3 抛出的错误和警告 */
|
|
74
|
-
vue3instance?: any;
|
|
75
|
-
/**
|
|
76
|
-
* 该属性处于实验当中,谨慎使用
|
|
77
|
-
* 读取开发环境 source file,source map,默认 禁用
|
|
78
|
-
*/
|
|
79
|
-
useDevSource?: boolean;
|
|
80
|
-
/** 层级默认 1000 */
|
|
81
|
-
zIndex?: number;
|
|
82
|
-
} & ButtonOptions;
|
|
83
|
-
|
|
84
|
-
type ButtonOptions = Partial<{
|
|
85
|
-
/** 按钮大小 */
|
|
86
|
-
buttonSize: number;
|
|
87
|
-
/** 按钮文本 */
|
|
88
|
-
buttonText: string;
|
|
89
|
-
/** 按钮文本颜色 */
|
|
90
|
-
buttonColor: string;
|
|
91
|
-
/** 按钮字体大小 */
|
|
92
|
-
buttonFontSize: string;
|
|
93
|
-
/** 按钮背景颜色 */
|
|
94
|
-
buttonBackgroundColor: string;
|
|
95
|
-
/** 初始化时是否显示调试按钮,默认显示 */
|
|
96
|
-
initShowDevTool: boolean;
|
|
97
|
-
}>;
|
|
98
|
-
|
|
99
|
-
type NetworkItem = {
|
|
100
|
-
index: number;
|
|
101
|
-
url: string;
|
|
102
|
-
name: string;
|
|
103
|
-
method: string;
|
|
104
|
-
status: number | string;
|
|
105
|
-
time: string;
|
|
106
|
-
startTime: number;
|
|
107
|
-
endTime: number;
|
|
108
|
-
size: string;
|
|
109
|
-
headers: {
|
|
110
|
-
requestHeader: { key: string; value: any }[];
|
|
111
|
-
responseHeader: { key: string; value: any }[];
|
|
112
|
-
};
|
|
113
|
-
response: string;
|
|
114
|
-
payload: any;
|
|
115
|
-
};
|
|
116
|
-
type StorageItem = {
|
|
117
|
-
key: string;
|
|
118
|
-
_oldKey: string;
|
|
119
|
-
value: string;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
/** 调试工具目前支持处理的console类型 */
|
|
123
|
-
type ConsoleType =
|
|
124
|
-
| 'log'
|
|
125
|
-
| 'info'
|
|
126
|
-
| 'warn'
|
|
127
|
-
| 'error'
|
|
128
|
-
| 'timeEnd'
|
|
129
|
-
| 'time'
|
|
130
|
-
| 'clear'
|
|
131
|
-
| 'count';
|
|
132
|
-
|
|
133
|
-
/** 不支持处理的console类型 */
|
|
134
|
-
type OriginalConsoleType =
|
|
135
|
-
| 'assert'
|
|
136
|
-
| 'count'
|
|
137
|
-
| 'countReset'
|
|
138
|
-
| 'debug'
|
|
139
|
-
| 'dir'
|
|
140
|
-
| 'dirxml'
|
|
141
|
-
| 'group'
|
|
142
|
-
| 'groupCollapsed'
|
|
143
|
-
| 'groupEnd'
|
|
144
|
-
| 'table'
|
|
145
|
-
| 'trace'
|
|
146
|
-
| 'profile'
|
|
147
|
-
| 'profileEnd'
|
|
148
|
-
| 'timeStamp';
|
|
149
|
-
|
|
150
|
-
type ValueType =
|
|
151
|
-
| 'number'
|
|
152
|
-
| 'string'
|
|
153
|
-
| 'boolean'
|
|
154
|
-
| 'null'
|
|
155
|
-
| 'undefined'
|
|
156
|
-
| 'symbol'
|
|
157
|
-
| 'array'
|
|
158
|
-
| 'object';
|
|
159
|
-
|
|
160
|
-
type Arg = {
|
|
161
|
-
type: ValueType;
|
|
162
|
-
value: any;
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
type ConsoleItem = {
|
|
166
|
-
type: string;
|
|
167
|
-
args: Arg[];
|
|
168
|
-
position: string;
|
|
169
|
-
time: string;
|
|
170
|
-
stack?: string;
|
|
171
|
-
/**
|
|
172
|
-
* input 输入
|
|
173
|
-
* output 输出
|
|
174
|
-
*/
|
|
175
|
-
mode?: 'input' | 'output';
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
type UploadItem = {
|
|
179
|
-
index: number;
|
|
180
|
-
url?: string;
|
|
181
|
-
filePath?: string;
|
|
182
|
-
formData?: Record<string, any>;
|
|
183
|
-
method?: string;
|
|
184
|
-
headers?: {
|
|
185
|
-
requestHeader?: { key: string; value: unknown }[];
|
|
186
|
-
responseHeader?: { key: string; value: unknown }[];
|
|
187
|
-
};
|
|
188
|
-
response?: Record<string, any>;
|
|
189
|
-
files?: any[];
|
|
190
|
-
fileType?: string;
|
|
191
|
-
name?: string;
|
|
192
|
-
status: number | string;
|
|
193
|
-
timeout?: number;
|
|
194
|
-
startTime?: number;
|
|
195
|
-
endTime?: number;
|
|
196
|
-
/** 上传进度 */
|
|
197
|
-
progress?: number;
|
|
198
|
-
/** 已上传长度 */
|
|
199
|
-
totalBytesSent?: number;
|
|
200
|
-
/** 预计上传总长度 */
|
|
201
|
-
totalBytesExpectedToSend?: number;
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
type EventCount = {
|
|
205
|
-
on: number;
|
|
206
|
-
once: number;
|
|
207
|
-
emit: number;
|
|
208
|
-
off: number;
|
|
209
|
-
};
|
|
210
|
-
type EventCountKey = keyof EventCount;
|
|
211
|
-
|
|
212
|
-
type EventItem = {
|
|
213
|
-
/** 事件名称 */
|
|
214
|
-
eventName?: string;
|
|
215
|
-
/** 触发事件 */
|
|
216
|
-
timer?: string;
|
|
217
|
-
/** 调用位置 */
|
|
218
|
-
stack?: string;
|
|
219
|
-
/** 事件类型 */
|
|
220
|
-
type?: string;
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
type RunJSItem = {
|
|
224
|
-
/** 代码 */
|
|
225
|
-
code?: string;
|
|
226
|
-
/** 结果 */
|
|
227
|
-
result?: any;
|
|
228
|
-
/** 开始时间 */
|
|
229
|
-
timer?: string;
|
|
230
|
-
/** 执行用时 */
|
|
231
|
-
duration?: number;
|
|
232
|
-
/** 执行状态 */
|
|
233
|
-
type?: string;
|
|
234
|
-
mode?: 'input' | 'output';
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
type CaptureScreenItem = {
|
|
238
|
-
position: string;
|
|
239
|
-
timer: string;
|
|
240
|
-
};
|
|
241
|
-
|
|
242
|
-
type WindowData = {
|
|
243
|
-
devToolVisible?: boolean;
|
|
244
|
-
consoleList?: ConsoleItem[];
|
|
245
|
-
networkList?: NetworkItem[];
|
|
246
|
-
storageList?: StorageItem[];
|
|
247
|
-
routeList?: Page[];
|
|
248
|
-
vuexList?: Record<string, any>;
|
|
249
|
-
piniaList?: Record<string, any>;
|
|
250
|
-
systemInfo?: Record<string, any>;
|
|
251
|
-
deviceInfo?: Record<string, any>;
|
|
252
|
-
windowInfo?: Record<string, any>;
|
|
253
|
-
netWorkStatus?: Record<string, any>;
|
|
254
|
-
appInfo?: Record<string, any>;
|
|
255
|
-
wsList?: WS[];
|
|
256
|
-
size?: number;
|
|
257
|
-
sizeFormat?: string;
|
|
258
|
-
uploadList?: UploadItem[];
|
|
259
|
-
eventCount?: EventCount;
|
|
260
|
-
eventList?: EventItem[];
|
|
261
|
-
captureScreenList?: CaptureScreenItem[];
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
type DevInterceptOptions = {
|
|
265
|
-
event: DevEvent;
|
|
266
|
-
enableInterceptPromiseReject?: boolean;
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
type DevToolInfo = {
|
|
270
|
-
/** 是否销毁 */
|
|
271
|
-
devToolDestroy?: boolean;
|
|
272
|
-
/** 按钮状态 */
|
|
273
|
-
devToolButtonVisible?: boolean;
|
|
274
|
-
/** 窗口状态 */
|
|
275
|
-
devToolWindowVisible?: boolean;
|
|
276
|
-
/** 按钮位置 */
|
|
277
|
-
top?: string;
|
|
278
|
-
/** 按钮位置 */
|
|
279
|
-
left?: string;
|
|
280
|
-
/** 当前活动tab */
|
|
281
|
-
activeTab?: number;
|
|
282
|
-
/** 当前console类型 */
|
|
283
|
-
currentConsoleType?: string;
|
|
284
|
-
/** 当前network类型 */
|
|
285
|
-
currentNetworkType?: string;
|
|
286
|
-
/** 当前websocket类型 */
|
|
287
|
-
currentWebSocketType?: string;
|
|
288
|
-
/** table滚动位置 */
|
|
289
|
-
tabScrollLeft?: number;
|
|
290
|
-
};
|
|
291
|
-
}
|
package/dev/utils/array.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export function chunk<T>(array: T[], size = 1): T[][] {
|
|
2
|
-
if (!Array.isArray(array) || size <= 0) {
|
|
3
|
-
return [];
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
const result: T[][] = [];
|
|
7
|
-
let index = 0;
|
|
8
|
-
|
|
9
|
-
while (index < array.length) {
|
|
10
|
-
result.push(array.slice(index, index + size));
|
|
11
|
-
index += size;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return result;
|
|
15
|
-
}
|
package/dev/utils/date.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
export function getCurrentDate() {
|
|
2
|
-
const date = new Date();
|
|
3
|
-
const year = date.getFullYear();
|
|
4
|
-
const month = date.getMonth() + 1;
|
|
5
|
-
const day = date.getDate();
|
|
6
|
-
const hour = date.getHours();
|
|
7
|
-
const minute = date.getMinutes();
|
|
8
|
-
const second = date.getSeconds();
|
|
9
|
-
return `${year}-${month.toString().padStart(2, '0')}-${day
|
|
10
|
-
.toString()
|
|
11
|
-
.padStart(2, '0')} ${hour.toString().padStart(2, '0')}:${minute
|
|
12
|
-
.toString()
|
|
13
|
-
.padStart(2, '0')}:${second?.toString().padStart(2, '0')}`;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 格式化时间
|
|
18
|
-
*
|
|
19
|
-
* @export
|
|
20
|
-
* @param {(Date | string | number)} date
|
|
21
|
-
* @param {string} format
|
|
22
|
-
* @return {*} {string}
|
|
23
|
-
*/
|
|
24
|
-
export function formatDate(
|
|
25
|
-
date: Date | string | number,
|
|
26
|
-
format: string,
|
|
27
|
-
): string {
|
|
28
|
-
let dateObj: Date;
|
|
29
|
-
|
|
30
|
-
if (date instanceof Date) {
|
|
31
|
-
dateObj = date;
|
|
32
|
-
} else {
|
|
33
|
-
dateObj = new Date(date);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (isNaN(dateObj.getTime())) {
|
|
37
|
-
throw new Error('Invalid date');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const formatMap: Record<string, string | number> = {
|
|
41
|
-
YYYY: dateObj.getFullYear(),
|
|
42
|
-
MM: String(dateObj.getMonth() + 1).padStart(2, '0'),
|
|
43
|
-
M: dateObj.getMonth() + 1,
|
|
44
|
-
DD: String(dateObj.getDate()).padStart(2, '0'),
|
|
45
|
-
D: dateObj.getDate(),
|
|
46
|
-
HH: String(dateObj.getHours()).padStart(2, '0'),
|
|
47
|
-
H: dateObj.getHours(),
|
|
48
|
-
hh: String(dateObj.getHours() % 12 || 12).padStart(2, '0'),
|
|
49
|
-
h: dateObj.getHours() % 12 || 12,
|
|
50
|
-
mm: String(dateObj.getMinutes()).padStart(2, '0'),
|
|
51
|
-
m: dateObj.getMinutes(),
|
|
52
|
-
ss: String(dateObj.getSeconds()).padStart(2, '0'),
|
|
53
|
-
s: dateObj.getSeconds(),
|
|
54
|
-
SS: String(dateObj.getMilliseconds()).padStart(3, '0'),
|
|
55
|
-
S: dateObj.getMilliseconds(),
|
|
56
|
-
A: dateObj.getHours() >= 12 ? 'PM' : 'AM',
|
|
57
|
-
a: dateObj.getHours() >= 12 ? 'pm' : 'am',
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
return format.replace(
|
|
61
|
-
/YYYY|MM|DD|HH|hh|mm|ss|SS|A|a|M|D|H|h|m|s|S/g,
|
|
62
|
-
(match) => formatMap[match].toString(),
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* 休眠
|
|
68
|
-
*
|
|
69
|
-
* @export
|
|
70
|
-
* @param {number} ms
|
|
71
|
-
* @return {*}
|
|
72
|
-
*/
|
|
73
|
-
export function sleep(ms: number) {
|
|
74
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
75
|
-
}
|
package/dev/utils/file.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 获取文件路径
|
|
3
|
-
*
|
|
4
|
-
* @export
|
|
5
|
-
* @return {*}
|
|
6
|
-
*/
|
|
7
|
-
export function getFilePath() {
|
|
8
|
-
return new Promise((resolve, reject) => {
|
|
9
|
-
if (plus) {
|
|
10
|
-
plus.io.resolveLocalFileSystemURL('_downloads', function (dirEntry) {
|
|
11
|
-
resolve(dirEntry.fullPath);
|
|
12
|
-
});
|
|
13
|
-
} else {
|
|
14
|
-
reject();
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 写入文件
|
|
21
|
-
*
|
|
22
|
-
* @param {string} filePath
|
|
23
|
-
* @param {string} content
|
|
24
|
-
*/
|
|
25
|
-
function writeContentToFile(filePath: string, content: string) {
|
|
26
|
-
plus.io.requestFileSystem(
|
|
27
|
-
plus.io.PUBLIC_DOCUMENTS,
|
|
28
|
-
function (fs) {
|
|
29
|
-
fs.root?.getFile(
|
|
30
|
-
filePath,
|
|
31
|
-
{ create: true },
|
|
32
|
-
function (fileEntry) {
|
|
33
|
-
fileEntry.createWriter(function (writer) {
|
|
34
|
-
writer.onwriteend = function () {
|
|
35
|
-
console.log('[DevTool] 写入文件成功' + filePath);
|
|
36
|
-
uni.showToast({
|
|
37
|
-
icon: 'none',
|
|
38
|
-
title: '写入文件成功' + filePath,
|
|
39
|
-
duration: 10 * 1000,
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
writer.onerror = function (e) {
|
|
43
|
-
console.log('[DevTool] 写入文件失败' + JSON.stringify(e));
|
|
44
|
-
uni.showToast({
|
|
45
|
-
icon: 'none',
|
|
46
|
-
title: '写入文件失败',
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
writer.write(content);
|
|
50
|
-
});
|
|
51
|
-
},
|
|
52
|
-
function (e) {
|
|
53
|
-
uni.showToast({
|
|
54
|
-
icon: 'none',
|
|
55
|
-
title: '获取文件失败',
|
|
56
|
-
});
|
|
57
|
-
console.log('[DevTool] 获取文件失败' + JSON.stringify(e));
|
|
58
|
-
},
|
|
59
|
-
);
|
|
60
|
-
},
|
|
61
|
-
function (e) {
|
|
62
|
-
uni.showToast({
|
|
63
|
-
icon: 'none',
|
|
64
|
-
title: '获取文件系统失败',
|
|
65
|
-
});
|
|
66
|
-
console.log('[DevTool] 获取文件系统失败' + JSON.stringify(e));
|
|
67
|
-
},
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export async function saveTxtFileApp(data: string, fileName: string) {
|
|
72
|
-
try {
|
|
73
|
-
const filePath = (await getFilePath()) + `${Date.now()}_${fileName}.txt`;
|
|
74
|
-
writeContentToFile(filePath, data);
|
|
75
|
-
} catch (error) {
|
|
76
|
-
console.log('[DevTool] ' + JSON.stringify(error));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export async function saveTextFileH5(data: string, fileName: string) {
|
|
81
|
-
// 创建 Blob 对象
|
|
82
|
-
const blob = new Blob([data], { type: 'text/plain' });
|
|
83
|
-
|
|
84
|
-
// 生成临时 URL
|
|
85
|
-
const url = URL.createObjectURL(blob);
|
|
86
|
-
|
|
87
|
-
// 创建下载链接
|
|
88
|
-
const link = document.createElement('a');
|
|
89
|
-
link.href = url;
|
|
90
|
-
link.download = fileName;
|
|
91
|
-
|
|
92
|
-
// 触发点击下载
|
|
93
|
-
link.click();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export async function saveTextFileMicro(data: string, fileName: string) {
|
|
97
|
-
const fs = uni.getFileSystemManager();
|
|
98
|
-
const fileNameDate = `${fileName}_${Date.now()}.txt`;
|
|
99
|
-
const filePath = `${uni?.env?.USER_DATA_PATH ?? 'Download'}/${fileNameDate}`;
|
|
100
|
-
fs.writeFile({
|
|
101
|
-
data,
|
|
102
|
-
filePath,
|
|
103
|
-
success: (res) => {
|
|
104
|
-
console.log('[DevTool] 写入文件成功' + filePath);
|
|
105
|
-
console.log(
|
|
106
|
-
`[DevTool] 文件位置:内部存储/Android/data/comm.tencent.mm/MicroMsg/wxanewfiles/手动查找最新文件夹/${fileNameDate}`,
|
|
107
|
-
);
|
|
108
|
-
uni.showToast({
|
|
109
|
-
title: '写入文件成功' + filePath,
|
|
110
|
-
icon: 'none',
|
|
111
|
-
});
|
|
112
|
-
},
|
|
113
|
-
fail: (error) => {
|
|
114
|
-
console.log('[DevTool] 写入文件失败' + JSON.stringify(error));
|
|
115
|
-
uni.showToast({
|
|
116
|
-
title: '写入文件失败' + JSON.stringify(error),
|
|
117
|
-
icon: 'none',
|
|
118
|
-
});
|
|
119
|
-
},
|
|
120
|
-
});
|
|
121
|
-
}
|