@tarojs/service 4.0.0-alpha.0 → 4.0.0-alpha.10
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/LICENSE +11 -4
- package/dist/Config.js +6 -6
- package/dist/Config.js.map +1 -1
- package/dist/Kernel.js +4 -4
- package/dist/Kernel.js.map +1 -1
- package/dist/Plugin.js.map +1 -1
- package/dist/platform-plugin-base/mini.js +13 -23
- package/dist/platform-plugin-base/mini.js.map +1 -1
- package/dist/platform-plugin-base/platform.js.map +1 -1
- package/dist/platform-plugin-base/web.js +8 -18
- package/dist/platform-plugin-base/web.js.map +1 -1
- package/dist/platform-plugin-base/webpack/hmr-plugin.js +1 -1
- package/dist/platform-plugin-base/webpack/hmr-plugin.js.map +1 -1
- package/dist/utils/constants.js +1 -1
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/package.js +1 -1
- package/dist/utils/package.js.map +1 -1
- package/package.json +26 -27
- package/types/Config.d.ts +1 -2
- package/types/Kernel.d.ts +3 -3
- package/types/Plugin.d.ts +2 -1
- package/types/platform-plugin-base/mini.d.ts +5 -5
- package/types/platform-plugin-base/platform.d.ts +2 -1
- package/types/platform-plugin-base/webpack/hmr-plugin.d.ts +2 -1
- package/types/utils/types.d.ts +8 -2
- package/src/Config.ts +0 -125
- package/src/Kernel.ts +0 -394
- package/src/Plugin.ts +0 -80
- package/src/index.ts +0 -9
- package/src/platform-plugin-base/index.ts +0 -3
- package/src/platform-plugin-base/mini.ts +0 -215
- package/src/platform-plugin-base/platform.ts +0 -75
- package/src/platform-plugin-base/web.ts +0 -136
- package/src/platform-plugin-base/webpack/hmr-plugin.ts +0 -37
- package/src/utils/constants.ts +0 -21
- package/src/utils/index.ts +0 -118
- package/src/utils/package.ts +0 -15
- package/src/utils/types.ts +0 -167
package/src/utils/types.ts
DELETED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import type helper from '@tarojs/helper'
|
|
2
|
-
import type runnerUtils from '@tarojs/runner-utils'
|
|
3
|
-
import type { IMiniFilesConfig, IProjectConfig } from '@tarojs/taro/types/compile'
|
|
4
|
-
import type { IModifyChainData } from '@tarojs/taro/types/compile/hooks'
|
|
5
|
-
import type joi from 'joi'
|
|
6
|
-
import type Webpack from 'webpack'
|
|
7
|
-
import type Chain from 'webpack-chain'
|
|
8
|
-
import type { PluginType } from './constants'
|
|
9
|
-
|
|
10
|
-
export interface IPaths {
|
|
11
|
-
/**
|
|
12
|
-
* 当前命令执行的目录,如果是 build 命令则为当前项目路径
|
|
13
|
-
*/
|
|
14
|
-
appPath: string
|
|
15
|
-
/**
|
|
16
|
-
* 当前项目配置目录,如果 init 命令,则没有此路径
|
|
17
|
-
*/
|
|
18
|
-
configPath: string
|
|
19
|
-
/**
|
|
20
|
-
* 当前项目源码路径
|
|
21
|
-
*/
|
|
22
|
-
sourcePath: string
|
|
23
|
-
/**
|
|
24
|
-
* 当前项目输出代码路径
|
|
25
|
-
*/
|
|
26
|
-
outputPath: string
|
|
27
|
-
/**
|
|
28
|
-
* 当前项目所用的 node_modules 路径
|
|
29
|
-
*/
|
|
30
|
-
nodeModulesPath: string
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export type Func = (...args: any[]) => any
|
|
34
|
-
|
|
35
|
-
export type IPluginsObject = Record<string, Record<any, any> | null>
|
|
36
|
-
|
|
37
|
-
export interface IPlugin {
|
|
38
|
-
id: string
|
|
39
|
-
path: string
|
|
40
|
-
opts: any
|
|
41
|
-
type: PluginType
|
|
42
|
-
apply: Func
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export type IPreset = IPlugin
|
|
46
|
-
|
|
47
|
-
export interface IHook {
|
|
48
|
-
name: string
|
|
49
|
-
plugin?: string
|
|
50
|
-
fn: Func
|
|
51
|
-
before?: string
|
|
52
|
-
stage?: number
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface ICommand extends IHook {
|
|
56
|
-
alias?: string
|
|
57
|
-
optionsMap?: {
|
|
58
|
-
[key: string]: string
|
|
59
|
-
}
|
|
60
|
-
synopsisList?: string[]
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export interface IFileType {
|
|
64
|
-
templ: string
|
|
65
|
-
style: string
|
|
66
|
-
script: string
|
|
67
|
-
config: string
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface IPlatform extends IHook {
|
|
71
|
-
useConfigName?: string
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export declare interface IPluginContext {
|
|
75
|
-
/**
|
|
76
|
-
* 获取当前所有挂载的插件
|
|
77
|
-
*/
|
|
78
|
-
plugins: Map<string, IPlugin>
|
|
79
|
-
/**
|
|
80
|
-
* 获取当前所有挂载的平台
|
|
81
|
-
*/
|
|
82
|
-
platforms: Map<string, IPlatform>
|
|
83
|
-
/**
|
|
84
|
-
* 包含当前执行命令的相关路径集合
|
|
85
|
-
*/
|
|
86
|
-
paths: IPaths
|
|
87
|
-
/**
|
|
88
|
-
* 获取当前执行命令所带的参数
|
|
89
|
-
*/
|
|
90
|
-
runOpts: any
|
|
91
|
-
/**
|
|
92
|
-
* 为包 @tarojs/helper 的快捷使用方式,包含其所有 API
|
|
93
|
-
*/
|
|
94
|
-
helper: typeof helper
|
|
95
|
-
/**
|
|
96
|
-
* 为包 @tarojs/runner-utils 的快捷使用方式,包含其所有 API
|
|
97
|
-
*/
|
|
98
|
-
runnerUtils: typeof runnerUtils
|
|
99
|
-
/**
|
|
100
|
-
* 项目配置
|
|
101
|
-
*/
|
|
102
|
-
initialConfig: IProjectConfig
|
|
103
|
-
/**
|
|
104
|
-
* 注册一个可供其他插件调用的钩子,接收一个参数,即 Hook 对象
|
|
105
|
-
*/
|
|
106
|
-
register: (hook: IHook) => void
|
|
107
|
-
/**
|
|
108
|
-
* 向 ctx 上挂载一个方法可供其他插件直接调用
|
|
109
|
-
*/
|
|
110
|
-
registerMethod: (arg: (string | { name: string, fn?: Func }), fn?: Func) => void
|
|
111
|
-
/**
|
|
112
|
-
* 注册一个自定义命令
|
|
113
|
-
*/
|
|
114
|
-
registerCommand: (command: ICommand) => void
|
|
115
|
-
/**
|
|
116
|
-
* 注册一个自定义编译平台
|
|
117
|
-
*/
|
|
118
|
-
registerPlatform: (platform: IPlatform) => void
|
|
119
|
-
/**
|
|
120
|
-
* 触发注册的钩子(使用`ctx.register`方法注册的钩子),传入钩子名和钩子所需参数
|
|
121
|
-
*/
|
|
122
|
-
applyPlugins: (args: string | { name: string, initialVal?: any, opts?: any }) => Promise<any>
|
|
123
|
-
/**
|
|
124
|
-
* 为插件添加入参校验
|
|
125
|
-
*/
|
|
126
|
-
addPluginOptsSchema: (fn: (joi: joi.Root) => void) => void
|
|
127
|
-
/**
|
|
128
|
-
* 编译开始
|
|
129
|
-
*/
|
|
130
|
-
onBuildStart: (fn: Func) => void
|
|
131
|
-
/**
|
|
132
|
-
* 编译结束(保存代码每次编译结束后都会触发)
|
|
133
|
-
*/
|
|
134
|
-
onBuildFinish: (fn: Func) => void
|
|
135
|
-
/**
|
|
136
|
-
* 编译完成(启动项目后首次编译结束后会触发一次)
|
|
137
|
-
*/
|
|
138
|
-
onBuildComplete: (fn: Func) => void
|
|
139
|
-
/**
|
|
140
|
-
* 修改编译过程中的页面组件配置
|
|
141
|
-
*/
|
|
142
|
-
onCompilerMake: (fn: (args: { compilation: Webpack.Compilation, compiler: Webpack.Compiler, plugin: any }) => void) => void
|
|
143
|
-
/**
|
|
144
|
-
* 编译中修改 webpack 配置,在这个钩子中,你可以对 webpackChain 作出想要的调整,等同于配置 [`webpackChain`](./config-detail.md#miniwebpackchain)
|
|
145
|
-
*/
|
|
146
|
-
modifyWebpackChain: (fn: (args: { chain: Chain, webpack: typeof Webpack, data?: IModifyChainData }) => void) => void
|
|
147
|
-
/**
|
|
148
|
-
* 编译中修改 vite 配置
|
|
149
|
-
*/
|
|
150
|
-
modifyViteConfig: (fn: (args: { viteConfig: any, data?: IModifyChainData }) => void) => void
|
|
151
|
-
/**
|
|
152
|
-
* 修改编译后的结果
|
|
153
|
-
*/
|
|
154
|
-
modifyBuildAssets: (fn: (args: { assets: any, miniPlugin: any }) => void) => void
|
|
155
|
-
/**
|
|
156
|
-
* 修改编译过程中的页面组件配置
|
|
157
|
-
*/
|
|
158
|
-
modifyMiniConfigs: (fn: (args: { configMap: IMiniFilesConfig }) => void) => void
|
|
159
|
-
/**
|
|
160
|
-
* 修改 Taro 编译配置
|
|
161
|
-
*/
|
|
162
|
-
modifyRunnerOpts: (fn: (args: { opts: any }) => void) => void
|
|
163
|
-
|
|
164
|
-
[key: string]: any
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export declare type TConfig = Record<string, any>
|