vite-uni-dev-tool 0.0.11 → 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.
Files changed (180) hide show
  1. package/README.md +55 -1
  2. package/dist/const.d.ts +133 -0
  3. package/dist/const.d.ts.map +1 -0
  4. package/dist/const.js +36 -0
  5. package/dist/core.d.ts +52 -0
  6. package/dist/core.d.ts.map +1 -0
  7. package/dist/core.js +80 -0
  8. package/dist/devConsole/index.d.ts +169 -0
  9. package/dist/devConsole/index.d.ts.map +1 -0
  10. package/dist/devConsole/index.js +270 -0
  11. package/dist/devEvent/index.d.ts +286 -0
  12. package/dist/devEvent/index.d.ts.map +1 -0
  13. package/dist/devEvent/index.js +435 -0
  14. package/dist/devEventBus/index.d.ts +42 -0
  15. package/dist/devEventBus/index.d.ts.map +1 -0
  16. package/dist/devEventBus/index.js +70 -0
  17. package/dist/devIntercept/index.d.ts +119 -0
  18. package/dist/devIntercept/index.d.ts.map +1 -0
  19. package/dist/devIntercept/index.js +582 -0
  20. package/dist/devRunJS/index.d.ts +67 -0
  21. package/dist/devRunJS/index.d.ts.map +1 -0
  22. package/dist/devStore/index.d.ts +178 -0
  23. package/dist/devStore/index.d.ts.map +1 -0
  24. package/dist/devStore/index.js +395 -0
  25. package/dist/devToolInfo/index.d.ts +17 -0
  26. package/dist/devToolInfo/index.d.ts.map +1 -0
  27. package/dist/devToolInfo/index.js +15 -0
  28. package/{dev → dist}/plugins/uniDevTool/uniDevTool.d.ts +15 -1
  29. package/dist/plugins/uniDevTool/uniDevTool.d.ts.map +1 -0
  30. package/dist/plugins/uniDevTool/uniDevTool.js +35 -0
  31. package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.js +7 -7
  32. package/{dev → dist}/plugins/utils/index.d.ts +3 -0
  33. package/{dev → dist}/plugins/utils/index.d.ts.map +1 -1
  34. package/dist/plugins/utils/index.js +1 -0
  35. package/dist/type.d.ts +264 -0
  36. package/dist/type.d.ts.map +1 -0
  37. package/dist/utils/array.d.ts +2 -0
  38. package/dist/utils/array.d.ts.map +1 -0
  39. package/dist/utils/array.js +12 -0
  40. package/dist/utils/date.d.ts +19 -0
  41. package/dist/utils/date.d.ts.map +1 -0
  42. package/dist/utils/date.js +40 -0
  43. package/dist/utils/file.d.ts +11 -0
  44. package/dist/utils/file.d.ts.map +1 -0
  45. package/dist/utils/file.js +87 -0
  46. package/dist/utils/function.d.ts +28 -0
  47. package/dist/utils/function.d.ts.map +1 -0
  48. package/dist/utils/function.js +46 -0
  49. package/dist/utils/index.d.ts +11 -0
  50. package/dist/utils/index.d.ts.map +1 -0
  51. package/dist/utils/index.js +55 -0
  52. package/dist/utils/ip.d.ts +5 -0
  53. package/dist/utils/ip.d.ts.map +1 -0
  54. package/dist/utils/ip.js +21 -0
  55. package/dist/utils/language.d.ts +29 -0
  56. package/dist/utils/language.d.ts.map +1 -0
  57. package/dist/utils/language.js +50 -0
  58. package/dist/utils/object.d.ts +49 -0
  59. package/dist/utils/object.d.ts.map +1 -0
  60. package/dist/utils/object.js +118 -0
  61. package/dist/utils/page.d.ts +7 -0
  62. package/dist/utils/page.d.ts.map +1 -0
  63. package/dist/utils/page.js +7 -0
  64. package/dist/utils/platform.d.ts +4 -0
  65. package/dist/utils/platform.d.ts.map +1 -0
  66. package/dist/utils/platform.js +14 -0
  67. package/dist/utils/string.d.ts +45 -0
  68. package/dist/utils/string.d.ts.map +1 -0
  69. package/dist/utils/string.js +88 -0
  70. package/dist/utils/utils.d.ts +16 -0
  71. package/dist/utils/utils.d.ts.map +1 -0
  72. package/dist/v2/AutoSizer/utils.d.ts +5 -0
  73. package/dist/v2/AutoSizer/utils.d.ts.map +1 -0
  74. package/dist/v2/JsonPretty/hooks/useClipboard.d.ts +4 -0
  75. package/dist/v2/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
  76. package/dist/v2/JsonPretty/hooks/useError.d.ts +8 -0
  77. package/dist/v2/JsonPretty/hooks/useError.d.ts.map +1 -0
  78. package/dist/v2/JsonPretty/type.d.ts +93 -0
  79. package/dist/v2/JsonPretty/type.d.ts.map +1 -0
  80. package/dist/v3/AutoSizer/utils.d.ts +5 -0
  81. package/dist/v3/AutoSizer/utils.d.ts.map +1 -0
  82. package/dist/v3/ConsoleList/staticTips.d.ts +13 -0
  83. package/dist/v3/ConsoleList/staticTips.d.ts.map +1 -0
  84. package/dist/v3/JsonPretty/hooks/useClipboard.d.ts +4 -0
  85. package/dist/v3/JsonPretty/hooks/useClipboard.d.ts.map +1 -0
  86. package/dist/v3/JsonPretty/hooks/useError.d.ts +8 -0
  87. package/dist/v3/JsonPretty/hooks/useError.d.ts.map +1 -0
  88. package/dist/v3/JsonPretty/type.d.ts +93 -0
  89. package/dist/v3/JsonPretty/type.d.ts.map +1 -0
  90. package/dist/v3/JsonPretty/utils/index.d.ts +10 -0
  91. package/dist/v3/JsonPretty/utils/index.d.ts.map +1 -0
  92. package/package.json +5 -5
  93. package/dev/components/AppInfo/index.vue +0 -36
  94. package/dev/components/AutoSizer/index.vue +0 -193
  95. package/dev/components/AutoSizer/index1.vue +0 -186
  96. package/dev/components/AutoSizer/utils.ts +0 -49
  97. package/dev/components/Button/index.vue +0 -34
  98. package/dev/components/CaptureScreen/index.vue +0 -62
  99. package/dev/components/Checkbox/index.vue +0 -40
  100. package/dev/components/CloseButton/index.vue +0 -26
  101. package/dev/components/Code/index.vue +0 -230
  102. package/dev/components/Connection/index.vue +0 -88
  103. package/dev/components/ConsoleList/Code.vue +0 -227
  104. package/dev/components/ConsoleList/ConsoleItem.vue +0 -186
  105. package/dev/components/ConsoleList/RunJSInput.vue +0 -235
  106. package/dev/components/ConsoleList/index.vue +0 -130
  107. package/dev/components/ConsoleList/staticTips.ts +0 -1145
  108. package/dev/components/DevTool/index.vue +0 -182
  109. package/dev/components/DevToolButton/index.vue +0 -213
  110. package/dev/components/DevToolTitle/index.vue +0 -21
  111. package/dev/components/DevToolWindow/index.vue +0 -1037
  112. package/dev/components/DeviceInfo/index.vue +0 -32
  113. package/dev/components/Empty/empty.png +0 -0
  114. package/dev/components/Empty/index.vue +0 -28
  115. package/dev/components/FilterInput/index.vue +0 -86
  116. package/dev/components/JsonPretty/components/Brackets/index.vue +0 -23
  117. package/dev/components/JsonPretty/components/Carets/index.vue +0 -59
  118. package/dev/components/JsonPretty/components/CheckController/index.vue +0 -125
  119. package/dev/components/JsonPretty/components/TreeNode/index.vue +0 -349
  120. package/dev/components/JsonPretty/hooks/useClipboard.ts +0 -21
  121. package/dev/components/JsonPretty/hooks/useError.ts +0 -21
  122. package/dev/components/JsonPretty/index.vue +0 -474
  123. package/dev/components/JsonPretty/type.ts +0 -125
  124. package/dev/components/JsonPretty/utils/index.ts +0 -172
  125. package/dev/components/NetworkList/NetworkDetail.vue +0 -197
  126. package/dev/components/NetworkList/NetworkItem.vue +0 -106
  127. package/dev/components/NetworkList/index.vue +0 -115
  128. package/dev/components/PiniaList/index.vue +0 -64
  129. package/dev/components/RouteList/index.vue +0 -110
  130. package/dev/components/RunJS/index.vue +0 -128
  131. package/dev/components/SettingList/index.vue +0 -225
  132. package/dev/components/StorageList/index.vue +0 -170
  133. package/dev/components/SystemInfo/index.vue +0 -34
  134. package/dev/components/Tabs/index.vue +0 -123
  135. package/dev/components/Tag/index.vue +0 -89
  136. package/dev/components/UniEvent/UniEventItem.vue +0 -124
  137. package/dev/components/UniEvent/index.vue +0 -94
  138. package/dev/components/UploadList/UploadDetail.vue +0 -208
  139. package/dev/components/UploadList/UploadItem.vue +0 -111
  140. package/dev/components/UploadList/index.vue +0 -104
  141. package/dev/components/VirtualList/index.vue +0 -112
  142. package/dev/components/VirtualListPro/AutoSize.vue +0 -43
  143. package/dev/components/VirtualListPro/index.vue +0 -175
  144. package/dev/components/VirtualListPro/readme.md +0 -40
  145. package/dev/components/VuexList/index.vue +0 -54
  146. package/dev/components/WebSocket/WebSocketItem.vue +0 -98
  147. package/dev/components/WebSocket/WebSocketList.vue +0 -176
  148. package/dev/components/WebSocket/index.vue +0 -111
  149. package/dev/components/WindowInfo/index.vue +0 -33
  150. package/dev/const.ts +0 -166
  151. package/dev/core.ts +0 -118
  152. package/dev/devConsole/index.ts +0 -350
  153. package/dev/devEvent/index.ts +0 -806
  154. package/dev/devEventBus/index.ts +0 -94
  155. package/dev/devIntercept/index.ts +0 -745
  156. package/dev/devRunJS/index.ts +0 -170
  157. package/dev/devStore/index.ts +0 -718
  158. package/dev/plugins/uniDevTool/uniDevTool.d.ts.map +0 -1
  159. package/dev/plugins/uniDevTool/uniDevTool.js +0 -36
  160. package/dev/plugins/utils/index.js +0 -1
  161. package/dev/shims-uni.d.ts +0 -43
  162. package/dev/type.ts +0 -264
  163. package/dev/utils/array.ts +0 -15
  164. package/dev/utils/date.ts +0 -75
  165. package/dev/utils/file.ts +0 -121
  166. package/dev/utils/function.ts +0 -192
  167. package/dev/utils/index.d.ts +0 -6
  168. package/dev/utils/index.ts +0 -46
  169. package/dev/utils/ip.ts +0 -79
  170. package/dev/utils/language.ts +0 -72
  171. package/dev/utils/object.ts +0 -298
  172. package/dev/utils/page.ts +0 -13
  173. package/dev/utils/platform.ts +0 -14
  174. package/dev/utils/string.ts +0 -133
  175. package/dev/utils/utils.ts +0 -198
  176. /package/{dev → dist}/index.d.ts +0 -0
  177. /package/{dev → dist}/index.d.ts.map +0 -0
  178. /package/{dev → dist}/index.js +0 -0
  179. /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts +0 -0
  180. /package/{dev → dist}/plugins/uniGlobalComponents/uniGlobalComponents.d.ts.map +0 -0
@@ -1,36 +0,0 @@
1
- "use strict";const C=require("path"),I=require("fs"),u=require("../utils/index.js");function _(a){const v=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const l in a)if(l!=="default"){const e=Object.getOwnPropertyDescriptor(a,l);Object.defineProperty(v,l,e.get?e:{enumerable:!0,get:()=>a[l]})}}return v.default=a,Object.freeze(v)}const $=_(C),S=_(I),h=/<script[^>]*>([\s\S]*?)<\/script>/,g={isReady:!1,urls:[]};function D({pages:a,sourceFileServers:v,...l}){return{name:"vite-uni-dev-tool",enforce:"pre",configureServer(e){var p;e.middlewares.use((s,n,t)=>{const{originalUrl:r}=s;if(l.useDevSource&&(r!=null&&r.includes("__dev_sourcefile__"))){const i=r.replace("/__dev_sourcefile__","");try{const c=e.config.root,m=$.join(c,i),o=S.readFileSync(m,"utf-8");n.setHeader("Content-Type",u.getContentType(m)),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__`);g.isReady=!0,g.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(h);if(n&&n[1]){const t=n[1].trim(),r=u.hasImportCurrentInstance(t),i=u.hasImportOnLaunch(t),c=r?"":"import { getCurrentInstance } from 'vue'",m=i?"":"import { onLaunch } from '@dcloudio/uni-app'",o=`
8
- import { initDevTool, 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
- ${[...g.urls??[],...v??[]].map(d=>`'${d}'`)}
19
- ],
20
- useDevSource: ${l.useDevSource},
21
- ...${JSON.stringify(l)},
22
- });
23
- });`;return{code:e.replace(h,`
24
- <script lang="ts" setup>
25
- ${c}
26
- ${m}
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(f=>p.includes(`${o.root}/${f.path}`))),i=["<DevTool />"],c=u.hasImportConsole(e),m=u.hasUseConsole(e);if(!c&&m&&!p.endsWith("/src/App.vue")){const o=e.match(h);if(o&&o[1]){const d=`
29
- import { console } from 'vite-uni-dev-tool/dev/core';
30
- ${o[1]}
31
- `;e=e.replace(h,`
32
- <script lang="ts" setup>
33
- ${d}
34
- <\/script>`)}}if((t||r)&&n){const o=u.getTemplateContent(e);let f=e;if(o){const d=`<view>${o}
35
- ${i.join(`
36
- `)}</view>`;f=e.replace(o,d)}return{code:f,map:null}}}return{code:e,map:null}}}}module.exports=D;
@@ -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;
@@ -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,264 +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
- cacheMaxSize?: number;
65
- /** 所有路由信息 */
66
- pagesJson?: PagesJSON;
67
- /** 源文件服务地址 */
68
- sourceFileServers?: string[];
69
- /** 用于区分生产环境和开发环境,开发环境下,为了获取 Android 异常栈源码会获取本地源码进行展示 */
70
- mode: string;
71
- /** 用于捕获 vue3 抛出的错误和警告 */
72
- vue3instance?: any;
73
- /**
74
- * 该属性处于实验当中,谨慎使用
75
- * 读取开发环境 source file,source map,默认 禁用
76
- */
77
- useDevSource?: boolean;
78
- } & ButtonOptions;
79
-
80
- type ButtonOptions = Partial<{
81
- /** 按钮大小 */
82
- buttonSize: number;
83
- /** 按钮文本 */
84
- buttonText: string;
85
- /** 按钮文本颜色 */
86
- buttonColor: string;
87
- /** 按钮字体大小 */
88
- buttonFontSize: string;
89
- /** 按钮背景颜色 */
90
- buttonBackgroundColor: string;
91
- /** 初始化时是否显示调试按钮,默认显示 */
92
- initShowDevTool: boolean;
93
- }>;
94
-
95
- type NetworkItem = {
96
- index: number;
97
- url: string;
98
- name: string;
99
- method: string;
100
- status: number | string;
101
- time: string;
102
- startTime: number;
103
- endTime: number;
104
- size: string;
105
- headers: {
106
- requestHeader: { key: string; value: any }[];
107
- responseHeader: { key: string; value: any }[];
108
- };
109
- response: string;
110
- payload: any;
111
- };
112
- type StorageItem = {
113
- key: string;
114
- _oldKey: string;
115
- value: string;
116
- };
117
-
118
- /** 调试工具目前支持处理的console类型 */
119
- type ConsoleType =
120
- | 'log'
121
- | 'info'
122
- | 'warn'
123
- | 'error'
124
- | 'timeEnd'
125
- | 'time'
126
- | 'clear'
127
- | 'count';
128
-
129
- /** 不支持处理的console类型 */
130
- type OriginalConsoleType =
131
- | 'assert'
132
- | 'count'
133
- | 'countReset'
134
- | 'debug'
135
- | 'dir'
136
- | 'dirxml'
137
- | 'group'
138
- | 'groupCollapsed'
139
- | 'groupEnd'
140
- | 'table'
141
- | 'trace'
142
- | 'profile'
143
- | 'profileEnd'
144
- | 'timeStamp';
145
-
146
- type ValueType =
147
- | 'number'
148
- | 'string'
149
- | 'boolean'
150
- | 'null'
151
- | 'undefined'
152
- | 'symbol'
153
- | 'array'
154
- | 'object';
155
-
156
- type Arg = {
157
- type: ValueType;
158
- value: any;
159
- };
160
-
161
- type ConsoleItem = {
162
- type: string;
163
- args: Arg[];
164
- position: string;
165
- time: string;
166
- stack?: string;
167
- /**
168
- * input 输入
169
- * output 输出
170
- */
171
- mode?: 'input' | 'output';
172
- };
173
-
174
- type UploadItem = {
175
- index: number;
176
- url?: string;
177
- filePath?: string;
178
- formData?: Record<string, any>;
179
- method?: string;
180
- headers?: {
181
- requestHeader?: { key: string; value: unknown }[];
182
- responseHeader?: { key: string; value: unknown }[];
183
- };
184
- response?: Record<string, any>;
185
- files?: any[];
186
- fileType?: string;
187
- name?: string;
188
- status: number | string;
189
- timeout?: number;
190
- startTime?: number;
191
- endTime?: number;
192
- /** 上传进度 */
193
- progress?: number;
194
- /** 已上传长度 */
195
- totalBytesSent?: number;
196
- /** 预计上传总长度 */
197
- totalBytesExpectedToSend?: number;
198
- };
199
-
200
- type EventCount = {
201
- on: number;
202
- once: number;
203
- emit: number;
204
- off: number;
205
- };
206
- type EventCountKey = keyof EventCount;
207
-
208
- type EventItem = {
209
- /** 事件名称 */
210
- eventName?: string;
211
- /** 触发事件 */
212
- timer?: string;
213
- /** 调用位置 */
214
- stack?: string;
215
- /** 事件类型 */
216
- type?: string;
217
- };
218
-
219
- type RunJSItem = {
220
- /** 代码 */
221
- code?: string;
222
- /** 结果 */
223
- result?: any;
224
- /** 开始时间 */
225
- timer?: string;
226
- /** 执行用时 */
227
- duration?: number;
228
- /** 执行状态 */
229
- type?: string;
230
- mode?: 'input' | 'output';
231
- };
232
-
233
- type CaptureScreenItem = {
234
- position: string;
235
- timer: string;
236
- };
237
-
238
- type WindowData = {
239
- devToolVisible?: boolean;
240
- consoleList?: ConsoleItem[];
241
- networkList?: NetworkItem[];
242
- storageList?: StorageItem[];
243
- routeList?: Page[];
244
- vuexList?: Record<string, any>;
245
- piniaList?: Record<string, any>;
246
- systemInfo?: Record<string, any>;
247
- deviceInfo?: Record<string, any>;
248
- windowInfo?: Record<string, any>;
249
- netWorkStatus?: Record<string, any>;
250
- appInfo?: Record<string, any>;
251
- wsList?: WS[];
252
- size?: number;
253
- sizeFormat?: string;
254
- uploadList?: UploadItem[];
255
- eventCount?: EventCount;
256
- eventList?: EventItem[];
257
- captureScreenList?: CaptureScreenItem[];
258
- };
259
-
260
- type DevInterceptOptions = {
261
- event: DevEvent;
262
- enableInterceptPromiseReject?: boolean;
263
- };
264
- }
@@ -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
- }