@code-inspector/core 1.1.0
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 +393 -0
- package/dist/client.umd.js +1 -0
- package/dist/index.js +15 -0
- package/dist/index.mjs +195174 -0
- package/package.json +74 -0
- package/types/client/index.d.ts +163 -0
- package/types/index.d.ts +4 -0
- package/types/server/index.d.ts +3 -0
- package/types/server/server.d.ts +8 -0
- package/types/server/transform/index.d.ts +11 -0
- package/types/server/transform/transform-jsx.d.ts +2 -0
- package/types/server/transform/transform-svelte.d.ts +2 -0
- package/types/server/transform/transform-vue.d.ts +2 -0
- package/types/server/use-client.d.ts +14 -0
- package/types/shared/constant.d.ts +7 -0
- package/types/shared/index.d.ts +3 -0
- package/types/shared/type.d.ts +160 -0
- package/types/shared/utils.d.ts +17 -0
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@code-inspector/core",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"module": "./dist/index.mjs",
|
|
6
|
+
"types": "types/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"types"
|
|
10
|
+
],
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": {
|
|
14
|
+
"types": "./types/index.d.ts",
|
|
15
|
+
"default": "./dist/index.mjs"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"types": "./types/index.d.ts",
|
|
19
|
+
"default": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"repository": "git@github.com:zh-lx/code-inspector.git",
|
|
24
|
+
"author": "zh-lx <18366276315@163.com>",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"homepage": "https://inspector.fe-dev.cn/en",
|
|
27
|
+
"description": "Click the dom on the page, it will open your IDE and position the cursor to the source code location of the dom.",
|
|
28
|
+
"keywords": [
|
|
29
|
+
"webpack",
|
|
30
|
+
"vite",
|
|
31
|
+
"plugin",
|
|
32
|
+
"vue",
|
|
33
|
+
"vscode",
|
|
34
|
+
"inspector",
|
|
35
|
+
"inspect"
|
|
36
|
+
],
|
|
37
|
+
"bugs": {
|
|
38
|
+
"url": "https://github.com/zh-lx/code-inspector/issues"
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"dev": "vite",
|
|
42
|
+
"build:server": "vite build",
|
|
43
|
+
"build:client": " vite build --config ./vite.client.config.ts",
|
|
44
|
+
"build:client:watch": " vite build --config ./vite.client.config.ts --watch",
|
|
45
|
+
"clear": "rimraf ./dist && rimraf ./types",
|
|
46
|
+
"build": "pnpm clear && tsc && pnpm build:server && pnpm build:client",
|
|
47
|
+
"pub": "pnpm publish",
|
|
48
|
+
"pub:beta": "pnpm publish --tag beta"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@vue/compiler-dom": "^3.5.13",
|
|
52
|
+
"chalk": "^4.1.1",
|
|
53
|
+
"dotenv": "^16.1.4",
|
|
54
|
+
"launch-ide": "1.1.1",
|
|
55
|
+
"portfinder": "^1.0.28"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@babel/core": "^7.21.3",
|
|
59
|
+
"@babel/plugin-proposal-decorators": "^7.22.7",
|
|
60
|
+
"@babel/plugin-syntax-import-meta": "^7.10.4",
|
|
61
|
+
"@babel/plugin-transform-typescript": "^7.21.3",
|
|
62
|
+
"@types/node": "^18.14.1",
|
|
63
|
+
"@vue/babel-plugin-jsx": "^1.1.1",
|
|
64
|
+
"@vue/compiler-sfc": "^3.3.4",
|
|
65
|
+
"lit": "^2.6.1",
|
|
66
|
+
"magic-string": "^0.30.0",
|
|
67
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
68
|
+
"svelte": "^4.2.7",
|
|
69
|
+
"typescript": "^4.9.3",
|
|
70
|
+
"vite": "^4.3.9",
|
|
71
|
+
"vite-plugin-node-stdlib-browser": "^0.2.1",
|
|
72
|
+
"volar-service-pug": "^0.0.63"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
2
|
+
interface Position {
|
|
3
|
+
left?: string;
|
|
4
|
+
right?: string;
|
|
5
|
+
top?: string;
|
|
6
|
+
bottom?: string;
|
|
7
|
+
transform?: string;
|
|
8
|
+
maxHeight?: string;
|
|
9
|
+
}
|
|
10
|
+
interface SourceInfo {
|
|
11
|
+
name: string;
|
|
12
|
+
path: string;
|
|
13
|
+
line: number;
|
|
14
|
+
column: number;
|
|
15
|
+
}
|
|
16
|
+
interface ElementTipStyle {
|
|
17
|
+
vertical: string;
|
|
18
|
+
horizon: string;
|
|
19
|
+
visibility: string;
|
|
20
|
+
additionStyle?: {
|
|
21
|
+
transform: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
interface TreeNode extends SourceInfo {
|
|
25
|
+
children: TreeNode[];
|
|
26
|
+
element: HTMLElement;
|
|
27
|
+
depth: number;
|
|
28
|
+
}
|
|
29
|
+
interface ActiveNode {
|
|
30
|
+
top?: string;
|
|
31
|
+
bottom?: string;
|
|
32
|
+
left?: string;
|
|
33
|
+
width?: string;
|
|
34
|
+
content?: string;
|
|
35
|
+
visibility?: 'visible' | 'hidden';
|
|
36
|
+
class?: 'tooltip-top' | 'tooltip-bottom';
|
|
37
|
+
}
|
|
38
|
+
export declare class CodeInspectorComponent extends LitElement {
|
|
39
|
+
hotKeys: string;
|
|
40
|
+
port: number;
|
|
41
|
+
showSwitch: boolean;
|
|
42
|
+
autoToggle: boolean;
|
|
43
|
+
hideConsole: boolean;
|
|
44
|
+
locate: boolean;
|
|
45
|
+
copy: boolean | string;
|
|
46
|
+
target: string;
|
|
47
|
+
ip: string;
|
|
48
|
+
position: {
|
|
49
|
+
top: number;
|
|
50
|
+
right: number;
|
|
51
|
+
bottom: number;
|
|
52
|
+
left: number;
|
|
53
|
+
padding: {
|
|
54
|
+
top: number;
|
|
55
|
+
right: number;
|
|
56
|
+
bottom: number;
|
|
57
|
+
left: number;
|
|
58
|
+
};
|
|
59
|
+
border: {
|
|
60
|
+
top: number;
|
|
61
|
+
right: number;
|
|
62
|
+
bottom: number;
|
|
63
|
+
left: number;
|
|
64
|
+
};
|
|
65
|
+
margin: {
|
|
66
|
+
top: number;
|
|
67
|
+
right: number;
|
|
68
|
+
bottom: number;
|
|
69
|
+
left: number;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
element: {
|
|
73
|
+
name: string;
|
|
74
|
+
line: number;
|
|
75
|
+
column: number;
|
|
76
|
+
path: string;
|
|
77
|
+
};
|
|
78
|
+
elementTipStyle: ElementTipStyle;
|
|
79
|
+
show: boolean;
|
|
80
|
+
showNodeTree: boolean;
|
|
81
|
+
nodeTreePosition: Position;
|
|
82
|
+
nodeTree: TreeNode | null;
|
|
83
|
+
dragging: boolean;
|
|
84
|
+
mousePosition: {
|
|
85
|
+
baseX: number;
|
|
86
|
+
baseY: number;
|
|
87
|
+
moveX: number;
|
|
88
|
+
moveY: number;
|
|
89
|
+
};
|
|
90
|
+
draggingTarget: 'switch' | 'nodeTree';
|
|
91
|
+
open: boolean;
|
|
92
|
+
moved: boolean;
|
|
93
|
+
hoverSwitch: boolean;
|
|
94
|
+
preUserSelect: string;
|
|
95
|
+
sendType: 'xhr' | 'img';
|
|
96
|
+
activeNode: ActiveNode;
|
|
97
|
+
inspectorSwitchRef: HTMLDivElement;
|
|
98
|
+
codeInspectorContainerRef: HTMLDivElement;
|
|
99
|
+
elementInfoRef: HTMLDivElement;
|
|
100
|
+
nodeTreeRef: HTMLDivElement;
|
|
101
|
+
nodeTreeTitleRef: HTMLDivElement;
|
|
102
|
+
nodeTreeTooltipRef: HTMLDivElement;
|
|
103
|
+
isTracking: (e: any) => boolean | "";
|
|
104
|
+
getDomPropertyValue: (target: HTMLElement, property: string) => number;
|
|
105
|
+
calculateElementInfoPosition: (target: HTMLElement) => Promise<{
|
|
106
|
+
vertical: string;
|
|
107
|
+
horizon: string;
|
|
108
|
+
top: number;
|
|
109
|
+
left: number;
|
|
110
|
+
isExternal: boolean;
|
|
111
|
+
additionStyle?: undefined;
|
|
112
|
+
} | {
|
|
113
|
+
vertical: string;
|
|
114
|
+
horizon: string;
|
|
115
|
+
top: number;
|
|
116
|
+
left: number;
|
|
117
|
+
isExternal: boolean;
|
|
118
|
+
additionStyle: {
|
|
119
|
+
transform: string;
|
|
120
|
+
};
|
|
121
|
+
}>;
|
|
122
|
+
renderCover: (target: HTMLElement) => Promise<void>;
|
|
123
|
+
getAstroFilePath: (target: HTMLElement) => string;
|
|
124
|
+
getSourceInfo: (target: HTMLElement) => SourceInfo | null;
|
|
125
|
+
removeCover: (force?: boolean | MouseEvent) => void;
|
|
126
|
+
renderLayerPanel: (nodeTree: TreeNode, { x, y }: {
|
|
127
|
+
x: number;
|
|
128
|
+
y: number;
|
|
129
|
+
}) => void;
|
|
130
|
+
removeLayerPanel: () => void;
|
|
131
|
+
addGlobalCursorStyle: () => void;
|
|
132
|
+
removeGlobalCursorStyle: () => void;
|
|
133
|
+
sendXHR: () => void;
|
|
134
|
+
sendImg: () => void;
|
|
135
|
+
buildTargetUrl: () => string;
|
|
136
|
+
trackCode: () => void;
|
|
137
|
+
copyToClipboard(text: string): void;
|
|
138
|
+
handleDrag: (e: MouseEvent | TouchEvent) => void;
|
|
139
|
+
isSamePositionNode: (node1: HTMLElement, node2: HTMLElement) => boolean;
|
|
140
|
+
handleMouseMove: (e: MouseEvent | TouchEvent) => Promise<void>;
|
|
141
|
+
handleMouseClick: (e: MouseEvent | TouchEvent) => void;
|
|
142
|
+
handleContextMenu: (e: MouseEvent) => void;
|
|
143
|
+
generateNodeTree: (nodePath: HTMLElement[]) => TreeNode;
|
|
144
|
+
handlePointerDown: (e: PointerEvent) => void;
|
|
145
|
+
handleKeyUp: (e: KeyboardEvent) => void;
|
|
146
|
+
printTip: () => void;
|
|
147
|
+
getMousePosition: (e: MouseEvent | TouchEvent) => {
|
|
148
|
+
x: number;
|
|
149
|
+
y: number;
|
|
150
|
+
};
|
|
151
|
+
recordMousePosition: (e: MouseEvent | TouchEvent, target: 'switch' | 'nodeTree') => void;
|
|
152
|
+
handleMouseUp: (e: MouseEvent | TouchEvent) => void;
|
|
153
|
+
switch: (e: Event) => void;
|
|
154
|
+
handleClickTreeNode: (node: TreeNode) => void;
|
|
155
|
+
handleMouseEnterNode: (e: MouseEvent, node: TreeNode) => Promise<void>;
|
|
156
|
+
handleMouseLeaveNode: () => void;
|
|
157
|
+
protected firstUpdated(): void;
|
|
158
|
+
disconnectedCallback(): void;
|
|
159
|
+
renderNodeTree: (node: TreeNode) => TemplateResult;
|
|
160
|
+
render(): TemplateResult<1>;
|
|
161
|
+
static styles: import("lit").CSSResult;
|
|
162
|
+
}
|
|
163
|
+
export {};
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import http from 'http';
|
|
3
|
+
import type { PathType, CodeOptions, RecordInfo } from '../shared';
|
|
4
|
+
export declare const ProjectRootPath: string;
|
|
5
|
+
export declare function getRelativePath(filePath: string): string;
|
|
6
|
+
export declare function getRelativeOrAbsolutePath(filePath: string, pathType?: PathType): string;
|
|
7
|
+
export declare function createServer(callback: (port: number) => any, options?: CodeOptions, record?: RecordInfo): http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
8
|
+
export declare function startServer(options: CodeOptions, record: RecordInfo): Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EscapeTags, PathType } from '../../shared';
|
|
2
|
+
type FileType = 'vue' | 'jsx' | 'svelte' | unknown;
|
|
3
|
+
type TransformCodeParams = {
|
|
4
|
+
content: string;
|
|
5
|
+
filePath: string;
|
|
6
|
+
fileType: FileType;
|
|
7
|
+
escapeTags: EscapeTags;
|
|
8
|
+
pathType: PathType;
|
|
9
|
+
};
|
|
10
|
+
export declare function transformCode(params: TransformCodeParams): string;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CodeOptions, RecordInfo } from '../shared';
|
|
2
|
+
export declare const clientJsPath: string;
|
|
3
|
+
export declare function getInjectedCode(options: CodeOptions, port: number, isNextjs: boolean): string;
|
|
4
|
+
export declare function getWebComponentCode(options: CodeOptions, port: number): string;
|
|
5
|
+
export declare function getEliminateWarningCode(): string;
|
|
6
|
+
export declare function getHidePathAttrCode(): string;
|
|
7
|
+
export declare function getCodeWithWebComponent({ options, record, file, code, inject, }: {
|
|
8
|
+
options: CodeOptions;
|
|
9
|
+
record: RecordInfo;
|
|
10
|
+
file: string;
|
|
11
|
+
code: string;
|
|
12
|
+
inject?: boolean;
|
|
13
|
+
}): Promise<string>;
|
|
14
|
+
export declare function isNextjsProject(): boolean;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const LineName = "data-insp-row";
|
|
2
|
+
export declare const ColumnName = "data-insp-col";
|
|
3
|
+
export declare const PathName = "data-insp-path";
|
|
4
|
+
export declare const NodeName = "data-insp-node";
|
|
5
|
+
export declare const DefaultPort = 5678;
|
|
6
|
+
export declare const JsFileExtList: string[];
|
|
7
|
+
export declare const AstroToolbarFile = "\0astro:dev-toolbar";
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { Editor } from 'launch-ide';
|
|
2
|
+
export type HotKey = 'ctrlKey' | 'altKey' | 'metaKey' | 'shiftKey';
|
|
3
|
+
export type Behavior = {
|
|
4
|
+
locate?: boolean;
|
|
5
|
+
copy?: boolean | string;
|
|
6
|
+
target?: string;
|
|
7
|
+
};
|
|
8
|
+
export type RecordInfo = {
|
|
9
|
+
port: number;
|
|
10
|
+
entry: string;
|
|
11
|
+
output: string;
|
|
12
|
+
findPort?: Promise<number>;
|
|
13
|
+
inputs?: Promise<string[]>;
|
|
14
|
+
injectTo?: string[];
|
|
15
|
+
envDir?: string;
|
|
16
|
+
};
|
|
17
|
+
export type IDEOpenMethod = 'reuse' | 'new' | 'auto';
|
|
18
|
+
export type ImportClientWay = 'file' | 'code';
|
|
19
|
+
export type PathType = 'relative' | 'absolute';
|
|
20
|
+
type SourceInfo = {
|
|
21
|
+
file: string;
|
|
22
|
+
line: number;
|
|
23
|
+
column: number;
|
|
24
|
+
};
|
|
25
|
+
export type EscapeTags = (string | RegExp)[];
|
|
26
|
+
export type Hooks = {
|
|
27
|
+
/**
|
|
28
|
+
* @zh server 端接收到 DOM 源代码定位请求后的钩子函数
|
|
29
|
+
* @en The hook triggered when the server receives a request to locate the DOM source code.
|
|
30
|
+
*/
|
|
31
|
+
afterInspectRequest?: (options: CodeOptions, source: SourceInfo) => void;
|
|
32
|
+
};
|
|
33
|
+
export type Condition = string | RegExp | (string | RegExp)[];
|
|
34
|
+
export type CodeOptions = {
|
|
35
|
+
/**
|
|
36
|
+
* @zh 指定项目的打包器
|
|
37
|
+
* @en specify the bundler of the project
|
|
38
|
+
*/
|
|
39
|
+
bundler: 'vite' | 'webpack' | 'rspack' | 'esbuild' | 'turbopack' | 'mako';
|
|
40
|
+
/**
|
|
41
|
+
* @cn 触发 DOM 定位功能的组合键,ctrlKey/altKey/metaKey/shiftKey 中一个或多个组成的数组,默认值为 ['altKey', 'shiftKey]。即 Mac 系统默认是 Option + Shift;Window 默认是 Alt + Shift。
|
|
42
|
+
* @en The combination keys that triggers the DOM positioning function, it is an array of one or more from ctrlKey/altKey/metaKey/shiftKey, with default values of ['altKey', 'shiftKey']. The default for Mac systems is Option+Shift; and for Window is Alt+Shift.
|
|
43
|
+
*/
|
|
44
|
+
hotKeys?: HotKey[] | false;
|
|
45
|
+
/**
|
|
46
|
+
* @cn 是否在页面展示功能开关按钮
|
|
47
|
+
* @en Whether show the switch button of this function on the page
|
|
48
|
+
*/
|
|
49
|
+
showSwitch?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* @cn 是否隐藏在控制台的按键提示
|
|
52
|
+
* @en Whether hide the tips of combination keys on console.
|
|
53
|
+
*/
|
|
54
|
+
hideConsole?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* @cn 打开功能开关的情况下,点击触发跳转编辑器时是否自动关闭开关
|
|
57
|
+
* @en When opening the function switch, whether automatically close the switch when triggering the jump editor function.
|
|
58
|
+
*/
|
|
59
|
+
autoToggle?: boolean;
|
|
60
|
+
editor?: Editor;
|
|
61
|
+
/**
|
|
62
|
+
* @cn 用于注入DOM 筛选和点击跳转vscode的相关代码的文件。必须为绝对路径且以 `.js/.ts/.mjs/.mts/.jsx/.tsx` 为结尾的文件
|
|
63
|
+
* @en The file to inject the relevant code for DOM filtering and click navigation in VSCode. Must be an absolute path and end with `.js/.ts/.mjs/.mts/.jsx/.tsx`.
|
|
64
|
+
*/
|
|
65
|
+
injectTo?: string | string[];
|
|
66
|
+
/**
|
|
67
|
+
* @cn 是否在转换时添加 `enforce: 'pre'`,默认值为 `true`。(若因该插件引起了 `eslint-plugin` 校验错误,需要此项设置为 `false`)
|
|
68
|
+
* @en Whether to add `enforce: 'pre'` during the transformation, default value is `true`. (If this plugin causes `eslint-plugin` validation errors, set this option to `false`)
|
|
69
|
+
*/
|
|
70
|
+
enforcePre?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* @cn 自定义 development 环境的判断
|
|
73
|
+
* @en Custom determination of the development environment.
|
|
74
|
+
*/
|
|
75
|
+
dev?: boolean | (() => boolean);
|
|
76
|
+
/**
|
|
77
|
+
* @cn 对于 webpack/rspack 是否应用缓存策略,默认值为 `false`。(使用 cache 可能会导致)
|
|
78
|
+
* @en Whether to apply the caching strategy for webpack/rspack, the default value is `false`
|
|
79
|
+
*/
|
|
80
|
+
cache?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* @cn 仅对符合 match 正则表达式的文件会进行源码定位编译(精确匹配文件类型以减少无用文件参与编译,提升性能),默认为 /\.(vue|jsx|tsx|js|ts|mjs|mts)$/
|
|
83
|
+
* @en Only files that match the regular expression specified by `match` will undergo source code location compilation (precise matching of file types to reduce unnecessary files participating in compilation, improving performance); the default is /\.(vue|jsx|tsx|js|ts|mjs|mts)$/
|
|
84
|
+
*/
|
|
85
|
+
match?: RegExp;
|
|
86
|
+
/**
|
|
87
|
+
* @cn 功能触发时的行为
|
|
88
|
+
* @en The behavior
|
|
89
|
+
*/
|
|
90
|
+
behavior?: Behavior;
|
|
91
|
+
/**
|
|
92
|
+
* @cn 打开 IDE 窗口的方式: 不传或者 `auto` 为自动寻找窗口;`reuse` 将复用当前窗口;`new` 为打开新窗口
|
|
93
|
+
* @en The way to open the IDE window: Use `auto` or `undefined` to automatically find the window; Use `reuse` to reuse the current window; Use `new` to open a new window.
|
|
94
|
+
*/
|
|
95
|
+
openIn?: IDEOpenMethod;
|
|
96
|
+
/**
|
|
97
|
+
* @cn 自定义跳转 IDE 时的打开路径,默认 "{file}:{line}:{column}",其中 {xx} 为模版字符
|
|
98
|
+
* @en Customize the path when open the IDE. Default value is "{file}:{line}:{column}", where {xx} represents template characters.
|
|
99
|
+
*/
|
|
100
|
+
pathFormat?: string | string[];
|
|
101
|
+
/**
|
|
102
|
+
* @zh 钩子函数
|
|
103
|
+
* @en hooks
|
|
104
|
+
*/
|
|
105
|
+
hooks?: Hooks;
|
|
106
|
+
/**
|
|
107
|
+
* @zh 不注入 `data-insp-path` 的标签
|
|
108
|
+
* @en tags without injecting data-insp-path
|
|
109
|
+
*/
|
|
110
|
+
escapeTags?: EscapeTags;
|
|
111
|
+
/**
|
|
112
|
+
* @zh 是否隐藏控制台中 dom 的 `data-insp-path` 属性
|
|
113
|
+
* @en Whether to hide the `data-insp-path` attribute of DOM in the console
|
|
114
|
+
*/
|
|
115
|
+
hideDomPathAttr?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* @zh 点击 DOM 向 node server 发送请求时,是否使用 ip 代替 localhost。默认为 `false`
|
|
118
|
+
* @en When sending request node server by clicking on the DOM, whether to use IP instead of localhost. Default value is `false`
|
|
119
|
+
*/
|
|
120
|
+
ip?: boolean | string;
|
|
121
|
+
/**
|
|
122
|
+
* @zh 引入客户端交互代码的方式: file 为通过文件引入交互代码; code 为直接将交互代码注入页面。`0.16.x` 及之后的版本值默认为 `code`, `0.15.x` 之前的版本默认值为 `file`.
|
|
123
|
+
* @en How to import client interaction code: `file` means import interaction code through a file; `code` means directly injecting the interaction code into the page. The default value for versions `0.16.x` and later is `code`, while for versions before `0.15.x`, the default value is `file`.
|
|
124
|
+
*/
|
|
125
|
+
importClient?: ImportClientWay;
|
|
126
|
+
/**
|
|
127
|
+
* @zh 额外要参与编译的文件(用于让 node_modules 中的部分文件参与编译以注入 path 信息)
|
|
128
|
+
* @en Additional files to be compiled (used to make some files in `node_modules` participate in compilation to inject path information)
|
|
129
|
+
*/
|
|
130
|
+
include?: Condition;
|
|
131
|
+
/**
|
|
132
|
+
* @zh 不参与编译的文件
|
|
133
|
+
* @en Files not to be compiled
|
|
134
|
+
*/
|
|
135
|
+
exclude?: Condition;
|
|
136
|
+
/**
|
|
137
|
+
* @zh 用于映射文件路径,多用于将 node_modules 中的文件路径映射为项目中的文件路径
|
|
138
|
+
* @en Used to map file paths, often used to map the file path in `node_modules` to the file path in the project
|
|
139
|
+
*/
|
|
140
|
+
mappings?: Record<string, string> | Array<{
|
|
141
|
+
find: string | RegExp;
|
|
142
|
+
replacement: string;
|
|
143
|
+
}>;
|
|
144
|
+
/**
|
|
145
|
+
* @zh 支持从指定端口开始寻找可用端口(默认从 5678 开始)
|
|
146
|
+
* @en Supports finding available ports starting from a specified port (default starts from 5678).
|
|
147
|
+
*/
|
|
148
|
+
port?: number;
|
|
149
|
+
/**
|
|
150
|
+
* @zh 是否在控制台中打印 server 的启动信息
|
|
151
|
+
* @en Whether to print the server startup information in the console
|
|
152
|
+
*/
|
|
153
|
+
printServer?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* @zh 注入在 DOM 上的路径类型,默认值为 `absolute`,即绝对路径
|
|
156
|
+
* @en The type of path injected into the DOM, the default value is `absolute`, which means the path is relative to the project root directory
|
|
157
|
+
*/
|
|
158
|
+
pathType?: PathType;
|
|
159
|
+
};
|
|
160
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { CodeOptions, Condition, EscapeTags } from './type';
|
|
2
|
+
export declare function getIP(ip: boolean | string): string;
|
|
3
|
+
export declare function fileURLToPath(fileURL: string): string;
|
|
4
|
+
export declare function isJsTypeFile(file: string): boolean;
|
|
5
|
+
export declare function getFilePathWithoutExt(filePath: string): string;
|
|
6
|
+
export declare function normalizePath(filepath: string): string;
|
|
7
|
+
export declare function isEscapeTags(escapeTags: EscapeTags, tag: string): boolean;
|
|
8
|
+
export declare function getDenpendencies(): string[];
|
|
9
|
+
type BooleanFunction = () => boolean;
|
|
10
|
+
export declare function isDev(userDev: boolean | BooleanFunction | undefined, systemDev: boolean): boolean;
|
|
11
|
+
export declare function matchCondition(condition: Condition, file: string): boolean;
|
|
12
|
+
export declare function getMappingFilePath(file: string, mappings?: Record<string, string> | Array<{
|
|
13
|
+
find: string | RegExp;
|
|
14
|
+
replacement: string;
|
|
15
|
+
}>): string;
|
|
16
|
+
export declare function isExcludedFile(file: string, options: CodeOptions): boolean;
|
|
17
|
+
export {};
|