@makoojs/cli 0.4.1 → 0.5.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.CN.md +93 -351
- package/README.md +93 -351
- package/dist/bin.js +516 -1152
- package/dist/cli/commands/build.d.ts +2 -0
- package/dist/cli/commands/dev/DevTerminal.d.ts +51 -0
- package/dist/cli/commands/dev/dev.d.ts +2 -0
- package/dist/cli/commands/preview.d.ts +2 -0
- package/dist/cli/tasks/renderTasks.d.ts +2 -0
- package/dist/{shared → cli}/terminalColor.d.ts +2 -0
- package/dist/cli/version.d.ts +1 -0
- package/dist/config/defaults.d.ts +3 -24
- package/dist/config/errors.d.ts +14 -0
- package/dist/config/resolve.d.ts +6 -18
- package/dist/config/types.d.ts +8 -106
- package/dist/config/validation.d.ts +4 -7
- package/dist/index.cjs +121 -38
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1036 -3243
- package/dist/session/DevSession.d.ts +13 -0
- package/dist/session/types.d.ts +22 -0
- package/dist/vite/makoo.d.ts +3 -0
- package/dist/vite/makooDev.d.ts +7 -0
- package/package.json +8 -13
- package/dist/command/_util.d.ts +0 -8
- package/dist/command/add.d.ts +0 -1
- package/dist/command/build.d.ts +0 -1
- package/dist/command/dev.d.ts +0 -1
- package/dist/command/inspect.d.ts +0 -35
- package/dist/config/config.d.ts +0 -3
- package/dist/error/MakooCliError.d.ts +0 -58
- package/dist/generator/generator.d.ts +0 -3
- package/dist/generator/render/import/importAdapter.d.ts +0 -3
- package/dist/generator/render/import/importComp.d.ts +0 -3
- package/dist/generator/render/import/importMakooRuntime.d.ts +0 -1
- package/dist/generator/render/import/importManifest.d.ts +0 -3
- package/dist/generator/render/import/importRuntimeSetup.d.ts +0 -1
- package/dist/generator/render/init/initMakooRuntime.d.ts +0 -4
- package/dist/generator/render/init/registerComp.d.ts +0 -3
- package/dist/generator/render/init/registerListener.d.ts +0 -4
- package/dist/generator/render/run/renderMakooStart.d.ts +0 -1
- package/dist/generator/render/util/match.d.ts +0 -1
- package/dist/generator/render/util/value.d.ts +0 -1
- package/dist/generator/types.d.ts +0 -27
- package/dist/manifest/index.cjs +0 -1
- package/dist/manifest/index.d.ts +0 -2
- package/dist/manifest/index.js +0 -7
- package/dist/scanner/collectDependenics.d.ts +0 -2
- package/dist/scanner/load/loadManifes.d.ts +0 -3
- package/dist/scanner/load/loadMeta.d.ts +0 -2
- package/dist/scanner/manifestBinding.d.ts +0 -14
- package/dist/scanner/scanner.d.ts +0 -3
- package/dist/scanner/types.d.ts +0 -50
- package/dist/scanner/util.d.ts +0 -2
- package/dist/scanner/validation.d.ts +0 -190
- package/dist/vitePlugin/hmrController.d.ts +0 -6
- package/dist/vitePlugin/makoo.d.ts +0 -3
- package/dist/vitePlugin/makooMonkey.d.ts +0 -3
- package/dist/vitePlugin/types.d.ts +0 -18
- package/dist/vitePlugin/virtualModule.d.ts +0 -2
- package/dist/vitePlugin/watchList.d.ts +0 -5
- /package/dist/{command → cli}/bin.d.ts +0 -0
package/README.CN.md
CHANGED
|
@@ -1,59 +1,50 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @makoojs/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@makoojs/cli` 提供 Makoo 的 Vite 插件和 CLI 命令,并通过 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) 提供 userscript 的开发与构建能力。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
应用代码通过 `@makoojs/core` 的 `createMakoo()`、`inject()` 和 `listen()` 编排运行时行为;`@makoojs/cli` 负责 Vite 和 userscript 构建部分。
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- [`cdn`](#cdn):生成外部依赖的 CDN 配置
|
|
9
|
-
- [配置类型](#配置类型):`MakooOptions`、`CliConfig` 和 monkey 配置
|
|
7
|
+
## 适用场景
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
- 使用 Vite 开发 Makoo userscript 项目。
|
|
10
|
+
- 通过 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) 生成 userscript 元信息、开发入口和构建产物。
|
|
11
|
+
- 使用 `makoo dev` 和 `makoo build` 命令。
|
|
12
|
+
- 通过 `@makoojs/cli/monkey` 使用 GM API 的 Makoo 稳定入口。
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
- [`defineInjection()`](#defineinjection):声明模块 manifest
|
|
15
|
-
- [Manifest 类型](#manifest-类型)
|
|
14
|
+
## 安装
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
### 命令行
|
|
23
|
-
|
|
24
|
-
- [CLI 命令](#cli-命令)
|
|
25
|
-
|
|
26
|
-
## `makoo()`
|
|
27
|
-
|
|
28
|
-
根据 Makoo 配置创建 Vite plugins。
|
|
29
|
-
|
|
30
|
-
### Type
|
|
31
|
-
|
|
32
|
-
```ts
|
|
33
|
-
function makoo(options: MakooOptions): Plugin[];
|
|
16
|
+
```bash
|
|
17
|
+
# npm install @makoojs/cli
|
|
18
|
+
# yarn add @makoojs/cli
|
|
19
|
+
pnpm add @makoojs/cli
|
|
34
20
|
```
|
|
35
21
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
`options` 使用 `MakooOptions`,其中 `app` 为必填字段。
|
|
22
|
+
如果你使用 `@makoojs/create-makoo` 创建项目,通常会自动配置好 `@makoojs/cli`。
|
|
39
23
|
|
|
40
|
-
|
|
24
|
+
## 最小 Vite 配置
|
|
41
25
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
### Example
|
|
26
|
+
在 Vite 配置中使用 `makoo()`:
|
|
45
27
|
|
|
46
28
|
```ts
|
|
29
|
+
import { defineConfig } from 'vite';
|
|
30
|
+
import { makoo } from '@makoojs/cli';
|
|
31
|
+
import vue from '@vitejs/plugin-vue';
|
|
32
|
+
|
|
47
33
|
export default defineConfig({
|
|
48
34
|
plugins: [
|
|
49
|
-
|
|
35
|
+
vue(),
|
|
36
|
+
makoo({
|
|
37
|
+
entry: './src/app.ts',
|
|
50
38
|
app: {
|
|
51
|
-
name: 'my-
|
|
52
|
-
version: '0.0.1'
|
|
39
|
+
name: 'my-userscript',
|
|
40
|
+
version: '0.0.1',
|
|
41
|
+
description: 'My first Makoo script'
|
|
53
42
|
},
|
|
54
43
|
monkey: {
|
|
55
44
|
userscript: {
|
|
56
|
-
|
|
45
|
+
namespace: 'https://example.com',
|
|
46
|
+
// 这里只是示例,请替换为 userscript 实际支持的页面。
|
|
47
|
+
match: ['https://www.google.com/']
|
|
57
48
|
}
|
|
58
49
|
}
|
|
59
50
|
})
|
|
@@ -61,352 +52,103 @@ export default defineConfig({
|
|
|
61
52
|
});
|
|
62
53
|
```
|
|
63
54
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
从 `vite-plugin-monkey` 重新导出的 CDN 配置生成器。
|
|
67
|
-
|
|
68
|
-
### Type
|
|
69
|
-
|
|
70
|
-
```ts
|
|
71
|
-
type CdnFactory = (
|
|
72
|
-
exportVarName?: string,
|
|
73
|
-
pathname?: string
|
|
74
|
-
) => [string, ModuleToUrlFc];
|
|
75
|
-
|
|
76
|
-
const cdn: {
|
|
77
|
-
jsdelivr: CdnFactory;
|
|
78
|
-
jsdelivrFastly: CdnFactory;
|
|
79
|
-
unpkg: CdnFactory;
|
|
80
|
-
cdnjs: CdnFactory;
|
|
81
|
-
zhimg: CdnFactory;
|
|
82
|
-
elemecdn: CdnFactory;
|
|
83
|
-
bdstatic: CdnFactory;
|
|
84
|
-
npmmirror: CdnFactory;
|
|
85
|
-
bootcdn: CdnFactory;
|
|
86
|
-
staticfile: CdnFactory;
|
|
87
|
-
};
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
`bootcdn` 和 `staticfile` 由 `vite-plugin-monkey` 标记为 deprecated。
|
|
91
|
-
|
|
92
|
-
## 配置类型
|
|
93
|
-
|
|
94
|
-
### `MakooOptions`
|
|
95
|
-
|
|
96
|
-
```ts
|
|
97
|
-
type MakooOptions = CliConfig & {
|
|
98
|
-
root?: string;
|
|
99
|
-
};
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### `CliConfig`
|
|
103
|
-
|
|
104
|
-
```ts
|
|
105
|
-
type CliConfig = {
|
|
106
|
-
app: AppConfig;
|
|
107
|
-
monkey?: MonkeyConfig;
|
|
108
|
-
source?: SourceConfig;
|
|
109
|
-
runtime?: {
|
|
110
|
-
setup?: string | string[];
|
|
111
|
-
};
|
|
112
|
-
};
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### `AppConfig`
|
|
116
|
-
|
|
117
|
-
```ts
|
|
118
|
-
type AppConfig = {
|
|
119
|
-
name: string;
|
|
120
|
-
version: string;
|
|
121
|
-
description?: string;
|
|
122
|
-
};
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### `SourceConfig`
|
|
126
|
-
|
|
127
|
-
```ts
|
|
128
|
-
type SourceConfig = {
|
|
129
|
-
include?: string[];
|
|
130
|
-
exclude?: string[];
|
|
131
|
-
};
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
`include` 和 `exclude` 匹配 injection 模块目录名。
|
|
135
|
-
|
|
136
|
-
### `MonkeyConfig`
|
|
137
|
-
|
|
138
|
-
```ts
|
|
139
|
-
type MonkeyConfig = {
|
|
140
|
-
userscript?: MonkeyUserScript;
|
|
141
|
-
align?: number | false;
|
|
142
|
-
generate?: (options: {
|
|
143
|
-
userscript: string;
|
|
144
|
-
mode: 'serve' | 'build' | 'meta';
|
|
145
|
-
}) => string | Promise<string>;
|
|
146
|
-
styleImport?: boolean;
|
|
147
|
-
server?: MonkeyServerConfig;
|
|
148
|
-
build?: MonkeyBuildConfig;
|
|
149
|
-
};
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
### `MonkeyServerConfig`
|
|
153
|
-
|
|
154
|
-
```ts
|
|
155
|
-
type MonkeyServerConfig = {
|
|
156
|
-
open?: boolean;
|
|
157
|
-
prefix?: string | ((name: string) => string) | false;
|
|
158
|
-
};
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### `MonkeyBuildConfig`
|
|
162
|
-
|
|
163
|
-
```ts
|
|
164
|
-
type MonkeyBuildConfig = {
|
|
165
|
-
fileName?: string;
|
|
166
|
-
metaFileName?: string | boolean | ((fileName: string) => string);
|
|
167
|
-
externalGlobals?: ExternalGlobals;
|
|
168
|
-
autoGrant?: boolean;
|
|
169
|
-
externalResource?: ExternalResource;
|
|
170
|
-
systemjs?: 'inline' | ((
|
|
171
|
-
version: string,
|
|
172
|
-
packageName: string,
|
|
173
|
-
importName?: string,
|
|
174
|
-
resolveName?: string
|
|
175
|
-
) => string);
|
|
176
|
-
cssSideEffects?: string | ((css: string) => void);
|
|
177
|
-
};
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
## `defineInjections()`
|
|
181
|
-
|
|
182
|
-
声明顶层 `InjectionManifest`,并保留传入对象的具体类型。
|
|
183
|
-
|
|
184
|
-
### Type
|
|
185
|
-
|
|
186
|
-
```ts
|
|
187
|
-
function defineInjections<T extends InjectionManifest>(
|
|
188
|
-
manifest: StrictShape<InjectionManifest, T>
|
|
189
|
-
): T;
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
### Returns
|
|
55
|
+
`makoo()` 将配置交给 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) 完成 userscript 的开发与构建。
|
|
193
56
|
|
|
194
|
-
|
|
57
|
+
## 配置概览
|
|
195
58
|
|
|
196
|
-
|
|
59
|
+
`makoo()` 的主要配置分为三块:
|
|
197
60
|
|
|
198
61
|
```ts
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
62
|
+
makoo({
|
|
63
|
+
entry: './src/app.ts',
|
|
64
|
+
app: {
|
|
65
|
+
name: 'my-script',
|
|
66
|
+
version: '0.0.1',
|
|
67
|
+
description: 'demo script'
|
|
202
68
|
},
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
component: './panel/App.vue'
|
|
207
|
-
}
|
|
208
|
-
},
|
|
209
|
-
listeners: {
|
|
210
|
-
escape: {
|
|
211
|
-
listenAt: 'body',
|
|
212
|
-
type: 'keydown',
|
|
213
|
-
capture: true,
|
|
214
|
-
callback: onEscape
|
|
69
|
+
monkey: {
|
|
70
|
+
userscript: {
|
|
71
|
+
match: ['https://www.google.com/']
|
|
215
72
|
}
|
|
216
73
|
}
|
|
217
74
|
});
|
|
218
75
|
```
|
|
219
76
|
|
|
220
|
-
|
|
77
|
+
| 配置 | 说明 |
|
|
78
|
+
| --- | --- |
|
|
79
|
+
| `entry` | 交给 Vite 构建的应用模块 |
|
|
80
|
+
| `app` | 用于生成 userscript 的 `name`、`version`、`description` |
|
|
81
|
+
| `monkey` | 大多数配置会透传给 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) |
|
|
221
82
|
|
|
222
|
-
|
|
83
|
+
默认情况下,`monkey.build.autoGrant` 为 `true`,[lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) 会根据最终代码生成 `@grant`。
|
|
223
84
|
|
|
224
|
-
|
|
85
|
+
## CLI 命令
|
|
225
86
|
|
|
226
|
-
|
|
227
|
-
function defineInjection<T extends InjectionModuleConfig>(
|
|
228
|
-
config: StrictShape<InjectionModuleConfig, T>
|
|
229
|
-
): T;
|
|
230
|
-
```
|
|
87
|
+
安装后可以使用 `makoo` 命令:
|
|
231
88
|
|
|
232
|
-
|
|
89
|
+
| 命令 | 说明 |
|
|
90
|
+
| --- | --- |
|
|
91
|
+
| `makoo dev` | 启动 Vite dev server,并打印本地访问地址 |
|
|
92
|
+
| `makoo build` | 执行 Vite build,生成 userscript 构建产物 |
|
|
93
|
+
| `makoo preview` | 使用 Vite preview server 预览构建后的 userscript |
|
|
233
94
|
|
|
234
|
-
|
|
95
|
+
## 使用 GM API
|
|
235
96
|
|
|
236
|
-
|
|
97
|
+
`@makoojs/cli` 提供 `@makoojs/cli/monkey` 子入口,作为 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) GM API 的 Makoo 稳定封装。
|
|
237
98
|
|
|
238
99
|
```ts
|
|
239
|
-
|
|
240
|
-
name: 'panel',
|
|
241
|
-
injectAt: 'body',
|
|
242
|
-
component: './App.vue',
|
|
243
|
-
hooks: {
|
|
244
|
-
'artifact:mountSuccess': onMounted
|
|
245
|
-
},
|
|
246
|
-
on: {
|
|
247
|
-
listenAt: 'body',
|
|
248
|
-
type: 'click',
|
|
249
|
-
capture: true,
|
|
250
|
-
callback: onClick
|
|
251
|
-
}
|
|
252
|
-
});
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
## Manifest 类型
|
|
100
|
+
import { gmStorage, gmStyle } from '@makoojs/cli/monkey';
|
|
256
101
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
```ts
|
|
260
|
-
type InjectionManifest = {
|
|
261
|
-
injectionDefaults?: InjectionDefaults;
|
|
262
|
-
injections?: InjectionModuleConfig[] | Record<
|
|
263
|
-
string,
|
|
264
|
-
Omit<InjectionModuleConfig, 'name'>
|
|
265
|
-
>;
|
|
266
|
-
listeners?: InjectionListenerConfig[] | Record<
|
|
267
|
-
string,
|
|
268
|
-
Omit<InjectionListenerConfig, 'name'>
|
|
269
|
-
>;
|
|
270
|
-
};
|
|
102
|
+
gmStyle.add('.makoo-panel { z-index: 999999; }');
|
|
103
|
+
gmStorage.set('enabled', true);
|
|
271
104
|
```
|
|
272
105
|
|
|
273
|
-
|
|
106
|
+
也可以使用聚合入口:
|
|
274
107
|
|
|
275
108
|
```ts
|
|
276
|
-
|
|
277
|
-
alive?: boolean;
|
|
278
|
-
scope?: 'local' | 'global';
|
|
279
|
-
timeout?: number;
|
|
280
|
-
hooks?: LifecycleHookMap;
|
|
281
|
-
};
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
### `InjectionModuleConfig`
|
|
109
|
+
import { GMapi } from '@makoojs/cli/monkey';
|
|
285
110
|
|
|
286
|
-
|
|
287
|
-
type InjectionModuleConfig = {
|
|
288
|
-
name?: string;
|
|
289
|
-
injectAt: string;
|
|
290
|
-
component: string;
|
|
291
|
-
framework?: InjectionFramework;
|
|
292
|
-
enabled?: boolean;
|
|
293
|
-
match?: InjectionMatchConfig;
|
|
294
|
-
alive?: boolean;
|
|
295
|
-
scope?: 'local' | 'global';
|
|
296
|
-
timeout?: number;
|
|
297
|
-
hooks?: LifecycleHookMap;
|
|
298
|
-
on?: InjectionModuleListenerConfig;
|
|
299
|
-
};
|
|
111
|
+
GMapi.storage.set('enabled', true);
|
|
300
112
|
```
|
|
301
113
|
|
|
302
|
-
|
|
114
|
+
如果希望生成的 `@grant` 范围尽量小,可以按能力导入。完整 GM API 见 CLI API 文档。
|
|
303
115
|
|
|
304
|
-
|
|
305
|
-
type InjectionModuleListenerConfig = {
|
|
306
|
-
listenAt: string;
|
|
307
|
-
type: string;
|
|
308
|
-
callback: EventListener;
|
|
309
|
-
capture?: boolean;
|
|
310
|
-
activitySignal?: () => ActivitySignalSource<boolean>;
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
type InjectionListenerConfig = InjectionModuleListenerConfig & {
|
|
314
|
-
name?: string;
|
|
315
|
-
enabled?: boolean;
|
|
316
|
-
match?: InjectionMatchConfig;
|
|
317
|
-
};
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
设置 `capture: true` 后,listener 会在 DOM 捕获阶段处理事件。该字段默认为 `false`,
|
|
321
|
-
未配置时使用冒泡阶段。事件 listener 的 signal 仍由 Makoo 内部管理。
|
|
116
|
+
## 减小构建体积
|
|
322
117
|
|
|
323
|
-
|
|
118
|
+
`@makoojs/cli` 重新导出了 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) 的 `cdn`。可以配合 `monkey.build.externalGlobals` 使用 CDN 外部依赖,减小 userscript 构建体积。
|
|
324
119
|
|
|
325
120
|
```ts
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
### `InjectionMatchConfig`
|
|
121
|
+
import { defineConfig } from 'vite';
|
|
122
|
+
import { cdn, makoo } from '@makoojs/cli';
|
|
330
123
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
124
|
+
export default defineConfig({
|
|
125
|
+
plugins: [
|
|
126
|
+
makoo({
|
|
127
|
+
entry: './src/app.ts',
|
|
128
|
+
app: {
|
|
129
|
+
name: 'my-script',
|
|
130
|
+
version: '0.0.1'
|
|
131
|
+
},
|
|
132
|
+
monkey: {
|
|
133
|
+
build: {
|
|
134
|
+
externalGlobals: {
|
|
135
|
+
vue: cdn.jsdelivr('Vue', 'dist/vue.global.prod.js')
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
})
|
|
140
|
+
]
|
|
141
|
+
});
|
|
338
142
|
```
|
|
339
143
|
|
|
340
|
-
##
|
|
341
|
-
|
|
342
|
-
以下值从 `@makoojs/cli/monkey` 导出。
|
|
144
|
+
## 与其他包的关系
|
|
343
145
|
|
|
344
|
-
|
|
|
146
|
+
| 包 | 职责 |
|
|
345
147
|
| --- | --- |
|
|
346
|
-
| `
|
|
347
|
-
| `
|
|
348
|
-
| `
|
|
349
|
-
| `
|
|
350
|
-
| `
|
|
351
|
-
| `unsafeWindow` | 页面 window |
|
|
352
|
-
| `gmClipboard` | `set(data, type?, callback?)` |
|
|
353
|
-
| `gmDownload` | `start` |
|
|
354
|
-
| `gmMenu` | `register`、`unregister` |
|
|
355
|
-
| `gmNotification` | `show` |
|
|
356
|
-
| `gmRequest` | `send`、`get`、`post` |
|
|
357
|
-
| `gmResource` | `text`、`url` |
|
|
358
|
-
| `gmStorage` | `get`、`getMany`、`set`、`setMany`、`remove`、`removeMany`、`keys`、`watch`、`unwatch` |
|
|
359
|
-
| `gmStyle` | `add`、`element` |
|
|
360
|
-
| `gmTab` | `open`、`get`、`getAll`、`save` |
|
|
361
|
-
|
|
362
|
-
### `gmRequest.get()` / `gmRequest.post()`
|
|
148
|
+
| `@makoojs/cli` | Vite 插件、CLI 命令和 userscript 构建接入 |
|
|
149
|
+
| `@makoojs/core` | 框架无关的注入运行时内核 |
|
|
150
|
+
| `@makoojs/vue` | Vue adapter 与 Vue 插件注册 |
|
|
151
|
+
| `@makoojs/react` | React adapter |
|
|
152
|
+
| `@makoojs/create-makoo` | 项目脚手架 |
|
|
363
153
|
|
|
364
|
-
|
|
365
|
-
gmRequest.get<R extends GmResponseType = 'text', C = unknown>(
|
|
366
|
-
url: string,
|
|
367
|
-
options?: GmRequestOptions<R, C>
|
|
368
|
-
): GmAbortHandle;
|
|
369
|
-
|
|
370
|
-
gmRequest.post<R extends GmResponseType = 'text', C = unknown>(
|
|
371
|
-
url: string,
|
|
372
|
-
options?: GmRequestOptions<R, C>
|
|
373
|
-
): GmAbortHandle;
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
`get()` 和 `post()` 分别固定请求方法为 `GET` 和 `POST`。
|
|
377
|
-
|
|
378
|
-
## GM 类型
|
|
379
|
-
|
|
380
|
-
```ts
|
|
381
|
-
type GmRequestOptions<R extends GmResponseType = 'text', C = unknown> = Omit<
|
|
382
|
-
GmXmlhttpRequestOption<R, C>,
|
|
383
|
-
'url' | 'method'
|
|
384
|
-
>;
|
|
385
|
-
```
|
|
386
|
-
|
|
387
|
-
`@makoojs/cli/monkey` 还重新导出以下 `vite-plugin-monkey` 类型:
|
|
388
|
-
|
|
389
|
-
- `GmAbortHandle`
|
|
390
|
-
- `GmAddElementAttributes`
|
|
391
|
-
- `GmDownloadOptions`
|
|
392
|
-
- `GmInfoType`
|
|
393
|
-
- `GmMenuCommandOptions`
|
|
394
|
-
- `GmNotificationOptions`
|
|
395
|
-
- `GmOpenInTabOptions`
|
|
396
|
-
- `GmResponseEvent`
|
|
397
|
-
- `GmResponseType`
|
|
398
|
-
- `GmTabControl`
|
|
399
|
-
- `GmType`
|
|
400
|
-
- `GmValueListenerId`
|
|
401
|
-
- `GmXmlhttpRequestOption`
|
|
402
|
-
- `MonkeyWindow`
|
|
403
|
-
|
|
404
|
-
## CLI 命令
|
|
405
|
-
|
|
406
|
-
| 命令 | 说明 |
|
|
407
|
-
| --- | --- |
|
|
408
|
-
| `makoo dev` | 启动 Vite 开发服务器 |
|
|
409
|
-
| `makoo build` | 执行 Vite 构建 |
|
|
410
|
-
| `makoo add <name>` | 创建 React injection 模块并更新 manifest |
|
|
411
|
-
| `makoo add <name> --framework Vue` | 创建 Vue injection 模块并更新 manifest |
|
|
412
|
-
| `makoo inspect` | 输出解析后的配置、扫描结果和 framework 信息 |
|
|
154
|
+
运行时行为由应用代码通过 `@makoojs/core` 进行编排。
|