@makoojs/cli 0.3.2 → 0.4.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 CHANGED
@@ -1,49 +1,58 @@
1
- # @makoojs/cli
1
+ # CLI API
2
2
 
3
- `@makoojs/cli` 是 Makoo 项目的主要入口。它提供 Vite 插件、CLI 命令、manifest 类型辅助、injection 扫描、虚拟入口生成,并把 userscript 的开发、构建和安装流程接到 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey)。
3
+ ## API 索引
4
4
 
5
- 如果你在开发普通 Makoo userscript 项目,通常应该从这个包开始。`@makoojs/core` 负责底层注入运行时,`@makoojs/vue` 和 `@makoojs/react` 负责组件挂载适配器,而 `@makoojs/cli` 负责把它们组织进 Vite 和 userscript 构建流程。
5
+ ### `@makoojs/cli`
6
6
 
7
- ## 适用场景
7
+ - [`makoo()`](#makoo):创建 Makoo 与 userscript Vite plugins
8
+ - [`cdn`](#cdn):生成外部依赖的 CDN 配置
9
+ - [配置类型](#配置类型):`MakooOptions`、`CliConfig` 和 monkey 配置
8
10
 
9
- - 使用 Vite 开发 Makoo userscript 项目。
10
- - 从 `injections` 目录扫描注入模块并生成运行时代码。
11
- - 编写 `injections/manifest.ts` 和模块级 `manifest.ts`。
12
- - 通过 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) 生成 userscript 元信息、开发入口和构建产物。
13
- - 使用 `makoo dev`、`makoo build`、`makoo add`、`makoo inspect` 等命令。
14
- - 通过 `@makoojs/cli/monkey` 使用 GM API 的 Makoo 稳定入口。
11
+ ### `@makoojs/cli/manifest`
15
12
 
16
- ## 安装
13
+ - [`defineInjections()`](#defineinjections):声明顶层 manifest
14
+ - [`defineInjection()`](#defineinjection):声明模块 manifest
15
+ - [Manifest 类型](#manifest-类型)
17
16
 
18
- ```bash
19
- // npm install @makoojs/cli
20
- // yarn add @makoojs/cli
21
- pnpm add @makoojs/cli
22
- ```
17
+ ### `@makoojs/cli/monkey`
18
+
19
+ - [GM API](#gm-api):userscript API 封装
20
+ - [GM 类型](#gm-类型)
21
+
22
+ ### 命令行
23
+
24
+ - [CLI 命令](#cli-命令)
23
25
 
24
- 如果你使用 `@makoojs/create-makoo` 创建项目,通常会自动配置好 `@makoojs/cli`。
26
+ ## `makoo()`
25
27
 
26
- ## 最小 Vite 配置
28
+ 根据 Makoo 配置创建 Vite plugins。
27
29
 
28
- `makoo()` 返回一个 Vite plugin 数组,因此在 `plugins` 中通常使用 `...makoo(...)`。
30
+ ### Type
29
31
 
30
32
  ```ts
31
- import { defineConfig } from 'vite';
32
- import { makoo } from '@makoojs/cli';
33
- import vue from '@vitejs/plugin-vue';
33
+ function makoo(options: MakooOptions): Plugin[];
34
+ ```
35
+
36
+ ### Parameters
37
+
38
+ `options` 使用 `MakooOptions`,其中 `app` 为必填字段。
34
39
 
40
+ ### Returns
41
+
42
+ 返回一个 `Plugin[]`。在 Vite 配置中需要使用展开语法。
43
+
44
+ ### Example
45
+
46
+ ```ts
35
47
  export default defineConfig({
36
48
  plugins: [
37
- vue(),
38
49
  ...makoo({
39
50
  app: {
40
- name: 'my-userscript',
41
- version: '0.0.1',
42
- description: 'My first Makoo script'
51
+ name: 'my-script',
52
+ version: '0.0.1'
43
53
  },
44
54
  monkey: {
45
55
  userscript: {
46
- namespace: 'https://example.com',
47
56
  match: ['https://example.com/*']
48
57
  }
49
58
  }
@@ -52,318 +61,346 @@ export default defineConfig({
52
61
  });
53
62
  ```
54
63
 
55
- `makoo()` 会先注入 Makoo 自己的扫描和虚拟入口插件,再接入 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) 负责 userscript 开发与构建。
64
+ ## `cdn`
56
65
 
57
- ## 推荐项目结构
66
+ 从 `vite-plugin-monkey` 重新导出的 CDN 配置生成器。
58
67
 
59
- Makoo 默认扫描项目根目录下的 `injections` 目录。
68
+ ### Type
60
69
 
61
- ```txt
62
- .
63
- ├─ vite.config.ts
64
- └─ injections
65
- ├─ manifest.ts
66
- ├─ profile-card
67
- │ ├─ app.vue
68
- │ └─ manifest.ts
69
- └─ react-badge
70
- ├─ app.tsx
71
- └─ manifest.ts
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
+ };
72
88
  ```
73
89
 
74
- 顶层 `injections/manifest.ts` 用来声明 manifest 级的注入默认值和模块列表。模块级 `injections/<module>/manifest.ts` 可以覆盖或补充单个模块的配置,适合让模块自己维护 `injectAt`、`component`、`framework`、`match` 或生命周期 hooks。
90
+ `bootcdn` 和 `staticfile` 由 `vite-plugin-monkey` 标记为 deprecated。
75
91
 
76
- ## Manifest 基础
92
+ ## 配置类型
77
93
 
78
- `@makoojs/cli` 导出 `defineInjections()` 和 `defineInjection()`,用于给 manifest 提供类型约束。
94
+ ### `MakooOptions`
79
95
 
80
- `injectionDefaults` 用来定义当前 manifest 下共享的注入运行时默认值。模块没有显式配置时,会继承这里的 `alive`、`scope`、`timeout` 和 `hooks`;模块自己写了这些字段时,则以模块配置为准。
96
+ ```ts
97
+ type MakooOptions = CliConfig & {
98
+ root?: string;
99
+ };
100
+ ```
81
101
 
82
- 对象形式适合多数项目:
102
+ ### `CliConfig`
83
103
 
84
104
  ```ts
85
- import { defineInjections } from '@makoojs/cli';
86
-
87
- export default defineInjections({
88
- injectionDefaults: {
89
- alive: false,
90
- scope: 'local',
91
- timeout: 5000
92
- },
93
- injections: {
94
- profile: {
95
- injectAt: '#app',
96
- component: './profile-card/app.vue',
97
- framework: 'Vue',
98
- match: {
99
- include: ['https://example.com/users/*'],
100
- exclude: ['https://example.com/users/settings']
101
- }
102
- },
103
- badge: {
104
- injectAt: 'body',
105
- component: './react-badge/app.tsx',
106
- framework: 'React'
107
- }
108
- }
109
- });
105
+ type CliConfig = {
106
+ app: AppConfig;
107
+ monkey?: MonkeyConfig;
108
+ source?: SourceConfig;
109
+ runtime?: {
110
+ setup?: string | string[];
111
+ };
112
+ };
110
113
  ```
111
114
 
112
- 数组形式适合动态生成,或需要显式声明 `name` 的场景:
115
+ ### `AppConfig`
113
116
 
114
117
  ```ts
115
- import { defineInjections } from '@makoojs/cli';
116
-
117
- export default defineInjections({
118
- injections: [
119
- {
120
- name: 'profile',
121
- injectAt: '#app',
122
- component: './profile-card/app.vue',
123
- framework: 'Vue'
124
- }
125
- ]
126
- });
118
+ type AppConfig = {
119
+ name: string;
120
+ version: string;
121
+ description?: string;
122
+ };
127
123
  ```
128
124
 
129
- 模块级 manifest 可以使用 `defineInjection()`:
125
+ ### `SourceConfig`
130
126
 
131
127
  ```ts
132
- import { defineInjection } from '@makoojs/cli';
133
-
134
- export default defineInjection({
135
- injectAt: '#app',
136
- component: './app.vue',
137
- framework: 'Vue',
138
- alive: true
139
- });
128
+ type SourceConfig = {
129
+ include?: string[];
130
+ exclude?: string[];
131
+ };
140
132
  ```
141
133
 
142
- 常用字段:
134
+ `include` 和 `exclude` 匹配 injection 模块目录名。
143
135
 
144
- | 字段 | 说明 |
145
- | --- | --- |
146
- | `injectAt` | 目标 DOM 选择器 |
147
- | `component` | 组件路径,相对于顶层 manifest 或模块目录 |
148
- | `framework` | `Vue`、`React` 或 `auto`;省略时根据文件扩展名推断 |
149
- | `enabled` | 是否启用该模块,默认 `true` |
150
- | `match` | 模块级 URL 匹配规则 |
151
- | `alive` | 目标 DOM 被移除后是否尝试重注入 |
152
- | `scope` | alive 观察范围,支持 `local` 和 `global` |
153
- | `timeout` | 等待目标 DOM 的超时时间 |
154
- | `hooks` | 传给 `@makoojs/core` 的生命周期观察 hooks |
155
-
156
- `match` 支持数组简写:
136
+ ### `MonkeyConfig`
157
137
 
158
138
  ```ts
159
- match: ['https://example.com/*']
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
+ };
160
150
  ```
161
151
 
162
- 也支持 include/exclude 对象:
152
+ ### `MonkeyServerConfig`
163
153
 
164
154
  ```ts
165
- match: {
166
- include: ['https://example.com/*'],
167
- exclude: ['https://example.com/admin/*']
168
- }
155
+ type MonkeyServerConfig = {
156
+ open?: boolean;
157
+ prefix?: string | ((name: string) => string) | false;
158
+ };
169
159
  ```
170
160
 
171
- `match` 是模块级过滤。userscript 本身在哪些页面运行,仍由 `monkey.userscript.match` 等 userscript 元信息决定。
172
-
173
- ## 配置概览
174
-
175
- `makoo()` 的主要配置分为四块:
161
+ ### `MonkeyBuildConfig`
176
162
 
177
163
  ```ts
178
- makoo({
179
- app: {
180
- name: 'my-script',
181
- version: '0.0.1',
182
- description: 'demo script'
183
- },
184
- source: {
185
- include: ['*'],
186
- exclude: []
187
- },
188
- runtime: {
189
- setup: ['./injections/vue-setup.ts']
190
- },
191
- monkey: {
192
- userscript: {
193
- match: ['https://example.com/*']
194
- }
195
- }
196
- });
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
+ };
197
178
  ```
198
179
 
199
- | 配置 | 说明 |
200
- | --- | --- |
201
- | `app` | 用于生成 userscript 的 `name`、`version`、`description` |
202
- | `source` | 控制扫描哪些 injection 模块目录 |
203
- | `runtime` | 控制 Makoo 生成入口里的运行时前置 setup import |
204
- | `monkey` | 大多数配置会透传给 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) |
180
+ ## `defineInjections()`
205
181
 
206
- `source.include` 和 `source.exclude` 过滤的是 `injections` 下的模块目录名,不是页面 URL。默认 include 是 `['*']`,exclude 是 `[]`。
182
+ 声明顶层 `InjectionManifest`,并保留传入对象的具体类型。
207
183
 
208
- 大多数 `monkey` 配置会透传给 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey),用于 userscript 元信息、开发服务和构建行为。但 Makoo 会内部管理以下字段:
184
+ ### Type
209
185
 
210
- - `entry`:固定为 Makoo 生成的虚拟入口。
211
- - `clientAlias`:固定为 Makoo 内部使用的 GM API alias。
212
- - `server.mountGmApi`:固定由 Makoo 管理,不支持用户配置。
186
+ ```ts
187
+ function defineInjections<T extends InjectionManifest>(
188
+ manifest: StrictShape<InjectionManifest, T>
189
+ ): T;
190
+ ```
213
191
 
214
- 默认情况下,`monkey.build.autoGrant` 为 `true`,[lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) 会根据最终代码生成 `@grant`。
192
+ ### Returns
215
193
 
216
- ## CLI 命令
194
+ 原样返回 `manifest`。
217
195
 
218
- 安装后可以使用 `makoo` 命令:
196
+ ### Example
219
197
 
220
- | 命令 | 说明 |
221
- | --- | --- |
222
- | `makoo dev` | 启动 Vite dev server,并打印本地访问地址 |
223
- | `makoo build` | 执行 Vite build,生成 userscript 构建产物 |
224
- | `makoo add <name>` | 创建新的 injection 模块并更新 manifest |
225
- | `makoo add <name> --framework Vue` | 创建 Vue injection 模块 |
226
- | `makoo add <name> --framework React` | 创建 React injection 模块 |
227
- | `makoo inspect` | 打印解析后的 Makoo 配置和扫描结果 |
228
-
229
- `makoo add` 默认使用 React。它会在 `injections/<name>` 下创建组件文件,并把模块记录写入 `injections/manifest.ts`。
230
-
231
- ## 扫描与生成流程
198
+ ```ts
199
+ export default defineInjections({
200
+ injectionDefaults: {
201
+ alive: true
202
+ },
203
+ injections: {
204
+ panel: {
205
+ injectAt: 'body',
206
+ component: './panel/App.vue'
207
+ }
208
+ },
209
+ listeners: {
210
+ escape: {
211
+ listenAt: 'body',
212
+ type: 'keydown',
213
+ callback: onEscape
214
+ }
215
+ }
216
+ });
217
+ ```
232
218
 
233
- Makoo 的 Vite 插件会在启动和构建时执行以下流程:
219
+ ## `defineInjection()`
234
220
 
235
- 1. 加载 `injections/manifest.ts`。
236
- 2. 扫描 `injections` 下符合 `source.include` / `source.exclude` 的模块目录。
237
- 3. 读取模块级 `manifest.ts`,并与顶层 manifest 合并。
238
- 4. 解析组件路径、模块 ID、framework、match、alive、scope、timeout 等配置。
239
- 5. 根据实际使用到的 framework 生成 adapter import。
240
- 6. 生成虚拟入口,创建 Makoo runtime,声明任务并执行 `start()`。
241
- 7. 把虚拟入口交给 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) 打包成 userscript。
221
+ 声明单个 `InjectionModuleConfig`,并保留传入对象的具体类型。
242
222
 
243
- 如果没有找到顶层 manifest、没有可用注入模块,或无法推断 framework,CLI 会抛出 Makoo 自己的错误类型,方便定位问题。
223
+ ### Type
244
224
 
245
- ## HMR 行为
225
+ ```ts
226
+ function defineInjection<T extends InjectionModuleConfig>(
227
+ config: StrictShape<InjectionModuleConfig, T>
228
+ ): T;
229
+ ```
246
230
 
247
- 开发模式下,Makoo 会区分结构变化和普通组件更新。
231
+ ### Returns
248
232
 
249
- | 变化 | 行为 |
250
- | --- | --- |
251
- | 顶层 `injections/manifest.ts` 修改 | 重新扫描并更新虚拟入口 |
252
- | 模块级 `injections/<module>/manifest.ts` 修改 | 重新扫描并更新虚拟入口 |
253
- | manifest 静态导入的本地 helper 修改 | 追踪依赖并重新扫描更新虚拟入口 |
254
- | 模块目录新增或删除 | 重新扫描并更新虚拟入口 |
255
- | 普通组件文件修改 | 交给 Vite 原生 HMR 处理 |
256
- | 第三方依赖变化 | 不作为 Makoo 结构扫描依赖 |
233
+ 原样返回 `config`。
257
234
 
258
- 结构变化会触发虚拟入口更新。普通组件内部变化则保持 Vite 自己的热更新体验。
235
+ ### Example
259
236
 
260
- ## Runtime Setup
237
+ ```ts
238
+ export default defineInjection({
239
+ name: 'panel',
240
+ injectAt: 'body',
241
+ component: './App.vue',
242
+ hooks: {
243
+ 'artifact:mountSuccess': onMounted
244
+ },
245
+ on: {
246
+ listenAt: 'body',
247
+ type: 'click',
248
+ callback: onClick
249
+ }
250
+ });
251
+ ```
261
252
 
262
- `runtime.setup` 用来导入一批只负责副作用初始化的运行时文件。它们会在 Makoo 初始化 adapter、声明 injection、执行 `makoo.start(...)` 前进入最终 userscript bundle。
253
+ ## Manifest 类型
263
254
 
264
- 这个能力适合注册 Vue 插件、初始化 GM helper、导入全局样式或执行埋点初始化。
255
+ ### `InjectionManifest`
265
256
 
266
257
  ```ts
267
- // vite.config.ts
268
- import { defineConfig } from 'vite';
269
- import { makoo } from '@makoojs/cli';
270
-
271
- export default defineConfig({
272
- plugins: [
273
- ...makoo({
274
- app: {
275
- name: 'my-script',
276
- version: '0.0.1'
277
- },
278
- runtime: {
279
- setup: ['./injections/vue-setup.ts']
280
- },
281
- monkey: {
282
- userscript: {
283
- match: ['https://example.com/*']
284
- }
285
- }
286
- })
287
- ]
288
- });
258
+ type InjectionManifest = {
259
+ injectionDefaults?: InjectionDefaults;
260
+ injections?: InjectionModuleConfig[] | Record<
261
+ string,
262
+ Omit<InjectionModuleConfig, 'name'>
263
+ >;
264
+ listeners?: InjectionListenerConfig[] | Record<
265
+ string,
266
+ Omit<InjectionListenerConfig, 'name'>
267
+ >;
268
+ };
289
269
  ```
290
270
 
291
- ```ts
292
- // injections/vue-setup.ts
293
- import { VuePlugin } from '@makoojs/vue';
294
- import router from './router';
295
- import i18n from './i18n';
271
+ ### `InjectionDefaults`
296
272
 
297
- VuePlugin.usePlugins(router, i18n);
273
+ ```ts
274
+ type InjectionDefaults = {
275
+ alive?: boolean;
276
+ scope?: 'local' | 'global';
277
+ timeout?: number;
278
+ hooks?: LifecycleHookMap;
279
+ };
298
280
  ```
299
281
 
300
- `runtime.setup` 支持字符串和字符串数组。相对路径会基于项目根目录解析:
282
+ ### `InjectionModuleConfig`
301
283
 
302
284
  ```ts
303
- runtime: {
304
- setup: [
305
- './injections/vue-setup.ts',
306
- './injections/gm-setup.ts'
307
- ]
308
- }
285
+ type InjectionModuleConfig = {
286
+ name?: string;
287
+ injectAt: string;
288
+ component: string;
289
+ framework?: InjectionFramework;
290
+ enabled?: boolean;
291
+ match?: InjectionMatchConfig;
292
+ alive?: boolean;
293
+ scope?: 'local' | 'global';
294
+ timeout?: number;
295
+ hooks?: LifecycleHookMap;
296
+ on?: InjectionModuleListenerConfig;
297
+ };
309
298
  ```
310
299
 
311
- 开发模式下,setup 文件和它静态导入的本地依赖会参与结构更新。修改这些文件时,Makoo 会重新扫描并更新虚拟入口。
300
+ ### `InjectionListenerConfig`
312
301
 
313
- ## 使用 GM API
302
+ ```ts
303
+ type InjectionModuleListenerConfig = {
304
+ listenAt: string;
305
+ type: string;
306
+ callback: EventListener;
307
+ activitySignal?: () => ActivitySignalSource<boolean>;
308
+ };
309
+
310
+ type InjectionListenerConfig = InjectionModuleListenerConfig & {
311
+ name?: string;
312
+ enabled?: boolean;
313
+ match?: InjectionMatchConfig;
314
+ };
315
+ ```
314
316
 
315
- `@makoojs/cli` 提供 `@makoojs/cli/monkey` 子入口,作为 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) GM API 的 Makoo 稳定封装。
317
+ ### `InjectionFramework`
316
318
 
317
319
  ```ts
318
- import { gmStorage, gmStyle } from '@makoojs/cli/monkey';
319
-
320
- gmStyle.add('.makoo-panel { z-index: 999999; }');
321
- gmStorage.set('enabled', true);
320
+ type InjectionFramework = 'auto' | 'Vue' | 'React';
322
321
  ```
323
322
 
324
- 也可以使用聚合入口:
323
+ ### `InjectionMatchConfig`
325
324
 
326
325
  ```ts
327
- import { GMapi } from '@makoojs/cli/monkey';
328
-
329
- GMapi.storage.set('enabled', true);
326
+ type InjectionMatchConfig =
327
+ | string[]
328
+ | {
329
+ include?: string[];
330
+ exclude?: string[];
331
+ };
330
332
  ```
331
333
 
332
- 如果希望生成的 `@grant` 范围尽量小,优先使用按能力导入;`GMapi` 更适合作为共享代码或探索阶段的便利入口。完整 GM API 参考后续会放到独立文档站中。
334
+ ## GM API
333
335
 
334
- ## 减小构建体积
336
+ 以下值从 `@makoojs/cli/monkey` 导出。
335
337
 
336
- `@makoojs/cli` 重新导出了 [lisonge/vite-plugin-monkey](https://github.com/lisonge/vite-plugin-monkey) 的 `cdn` 辅助方法。你可以配合 `monkey.build.externalGlobals` 使用 CDN 外部依赖,减小 userscript 构建体积。
338
+ | 导出 | 方法或值 |
339
+ | --- | --- |
340
+ | `GMapi` | 包含 `raw`、`info`、`log`、`storage`、`style`、`request`、`menu`、`clipboard`、`notification`、`tab`、`download` 和 `resource` |
341
+ | `gm` | 原始 `GM` 对象 |
342
+ | `gmInfo` | `GM_info` |
343
+ | `gmLog` | `GM_log` |
344
+ | `monkeyWindow` | userscript window |
345
+ | `unsafeWindow` | 页面 window |
346
+ | `gmClipboard` | `set(data, type?, callback?)` |
347
+ | `gmDownload` | `start` |
348
+ | `gmMenu` | `register`、`unregister` |
349
+ | `gmNotification` | `show` |
350
+ | `gmRequest` | `send`、`get`、`post` |
351
+ | `gmResource` | `text`、`url` |
352
+ | `gmStorage` | `get`、`getMany`、`set`、`setMany`、`remove`、`removeMany`、`keys`、`watch`、`unwatch` |
353
+ | `gmStyle` | `add`、`element` |
354
+ | `gmTab` | `open`、`get`、`getAll`、`save` |
355
+
356
+ ### `gmRequest.get()` / `gmRequest.post()`
337
357
 
338
358
  ```ts
339
- import { defineConfig } from 'vite';
340
- import { cdn, makoo } from '@makoojs/cli';
359
+ gmRequest.get<R extends GmResponseType = 'text', C = unknown>(
360
+ url: string,
361
+ options?: GmRequestOptions<R, C>
362
+ ): GmAbortHandle;
363
+
364
+ gmRequest.post<R extends GmResponseType = 'text', C = unknown>(
365
+ url: string,
366
+ options?: GmRequestOptions<R, C>
367
+ ): GmAbortHandle;
368
+ ```
341
369
 
342
- export default defineConfig({
343
- plugins: makoo({
344
- app: {
345
- name: 'my-script',
346
- version: '0.0.1'
347
- },
348
- monkey: {
349
- build: {
350
- externalGlobals: {
351
- vue: cdn.jsdelivr('Vue', 'dist/vue.global.prod.js')
352
- }
353
- }
354
- }
355
- })
356
- });
370
+ `get()` 和 `post()` 分别固定请求方法为 `GET` 和 `POST`。
371
+
372
+ ## GM 类型
373
+
374
+ ```ts
375
+ type GmRequestOptions<R extends GmResponseType = 'text', C = unknown> = Omit<
376
+ GmXmlhttpRequestOption<R, C>,
377
+ 'url' | 'method'
378
+ >;
357
379
  ```
358
380
 
359
- ## 与其他包的关系
381
+ `@makoojs/cli/monkey` 还重新导出以下 `vite-plugin-monkey` 类型:
382
+
383
+ - `GmAbortHandle`
384
+ - `GmAddElementAttributes`
385
+ - `GmDownloadOptions`
386
+ - `GmInfoType`
387
+ - `GmMenuCommandOptions`
388
+ - `GmNotificationOptions`
389
+ - `GmOpenInTabOptions`
390
+ - `GmResponseEvent`
391
+ - `GmResponseType`
392
+ - `GmTabControl`
393
+ - `GmType`
394
+ - `GmValueListenerId`
395
+ - `GmXmlhttpRequestOption`
396
+ - `MonkeyWindow`
360
397
 
361
- | 包 | 职责 |
362
- | --- | --- |
363
- | `@makoojs/cli` | Vite 插件、CLI 命令、扫描、代码生成和 userscript 构建接入 |
364
- | `@makoojs/core` | 框架无关的注入运行时内核 |
365
- | `@makoojs/vue` | Vue adapter 与 Vue 插件注册辅助 |
366
- | `@makoojs/react` | React adapter |
367
- | `@makoojs/create-makoo` | 项目脚手架 |
398
+ ## CLI 命令
368
399
 
369
- `@makoojs/cli` 本身并不是完整的运行时实现,很多功能无法单独存在,需要依赖 `@makoojs/core` 提供的注入调度能力才能真正工作。
400
+ | 命令 | 说明 |
401
+ | --- | --- |
402
+ | `makoo dev` | 启动 Vite 开发服务器 |
403
+ | `makoo build` | 执行 Vite 构建 |
404
+ | `makoo add <name>` | 创建 React injection 模块并更新 manifest |
405
+ | `makoo add <name> --framework Vue` | 创建 Vue injection 模块并更新 manifest |
406
+ | `makoo inspect` | 输出解析后的配置、扫描结果和 framework 信息 |