@tarojs/service 3.3.9 → 3.3.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.
package/dist/Kernel.d.ts CHANGED
@@ -21,7 +21,7 @@ export default class Kernel extends EventEmitter {
21
21
  config: Config;
22
22
  initialConfig: IProjectConfig;
23
23
  hooks: Map<string, IHook[]>;
24
- methods: Map<string, (...args: any[]) => void>;
24
+ methods: Map<string, ((...args: any[]) => void)[]>;
25
25
  commands: Map<string, ICommand>;
26
26
  platforms: Map<string, IPlatform>;
27
27
  helper: any;
package/dist/Kernel.js CHANGED
@@ -158,8 +158,17 @@ class Kernel extends events_1.EventEmitter {
158
158
  });
159
159
  return new Proxy(pluginCtx, {
160
160
  get: (target, name) => {
161
- if (this.methods.has(name))
162
- return this.methods.get(name);
161
+ if (this.methods.has(name)) {
162
+ const method = this.methods.get(name);
163
+ if (Array.isArray(method)) {
164
+ return (...arg) => {
165
+ method.forEach(item => {
166
+ item.apply(this, arg);
167
+ });
168
+ };
169
+ }
170
+ return method;
171
+ }
163
172
  if (kernelApis.includes(name)) {
164
173
  return typeof this[name] === 'function' ? this[name].bind(this) : this[name];
165
174
  }
package/dist/Plugin.js CHANGED
@@ -35,15 +35,14 @@ class Plugin {
35
35
  }
36
36
  registerMethod(...args) {
37
37
  const { name, fn } = processArgs(args);
38
- if (this.ctx.methods.has(name)) {
39
- throw new Error(`已存在方法 ${name}`);
40
- }
41
- this.ctx.methods.set(name, fn || function (fn) {
38
+ const methods = this.ctx.methods.get(name) || [];
39
+ methods.push(fn || function (fn) {
42
40
  this.register({
43
41
  name,
44
42
  fn
45
43
  });
46
44
  }.bind(this));
45
+ this.ctx.methods.set(name, methods);
47
46
  }
48
47
  addPluginOptsSchema(schema) {
49
48
  this.optsSchema = schema;
@@ -59,6 +59,8 @@ class TaroPlatformBase {
59
59
  this.emptyOutputDir();
60
60
  }
61
61
  this.printDevelopmentTip(this.platform);
62
+ const { printLog, processTypeEnum } = this.ctx.helper;
63
+ printLog("start" /* START */, '开发者工具-项目目录', `${this.ctx.paths.outputPath}`);
62
64
  if (this.projectConfigJson) {
63
65
  this.generateProjectConfig(this.projectConfigJson);
64
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/service",
3
- "version": "3.3.9",
3
+ "version": "3.3.13",
4
4
  "description": "Taro Service",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",
@@ -34,13 +34,13 @@
34
34
  "homepage": "https://github.com/NervJS/taro#readme",
35
35
  "dependencies": {
36
36
  "@hapi/joi": "17.1.1",
37
- "@tarojs/helper": "3.3.9",
38
- "@tarojs/shared": "3.3.9",
39
- "@tarojs/taro": "3.3.9",
37
+ "@tarojs/helper": "3.3.13",
38
+ "@tarojs/shared": "3.3.13",
39
+ "@tarojs/taro": "3.3.13",
40
40
  "fs-extra": "8.1.0",
41
41
  "lodash": "4.17.21",
42
42
  "resolve": "1.15.1",
43
43
  "tapable": "1.1.3"
44
44
  },
45
- "gitHead": "dfea7ab7ac6f5abb8bb344595eadc0993d752eae"
45
+ "gitHead": "d84177a97cc27c01ca63c9dd07e5ab5bbaa91d8a"
46
46
  }
package/src/Kernel.ts CHANGED
@@ -48,7 +48,7 @@ export default class Kernel extends EventEmitter {
48
48
  config: Config
49
49
  initialConfig: IProjectConfig
50
50
  hooks: Map<string, IHook[]>
51
- methods: Map<string, (...args: any[]) => void>
51
+ methods: Map<string, ((...args: any[]) => void)[]>
52
52
  commands: Map<string, ICommand>
53
53
  platforms: Map<string, IPlatform>
54
54
  helper: any
@@ -203,7 +203,17 @@ export default class Kernel extends EventEmitter {
203
203
  })
204
204
  return new Proxy(pluginCtx, {
205
205
  get: (target, name: string) => {
206
- if (this.methods.has(name)) return this.methods.get(name)
206
+ if (this.methods.has(name)) {
207
+ const method = this.methods.get(name)
208
+ if (Array.isArray(method)) {
209
+ return (...arg) => {
210
+ method.forEach(item => {
211
+ item.apply(this, arg)
212
+ })
213
+ }
214
+ }
215
+ return method
216
+ }
207
217
  if (kernelApis.includes(name)) {
208
218
  return typeof this[name] === 'function' ? this[name].bind(this) : this[name]
209
219
  }
package/src/Plugin.ts CHANGED
@@ -46,15 +46,14 @@ export default class Plugin {
46
46
 
47
47
  registerMethod (...args) {
48
48
  const { name, fn } = processArgs(args)
49
- if (this.ctx.methods.has(name)) {
50
- throw new Error(`已存在方法 ${name}`)
51
- }
52
- this.ctx.methods.set(name, fn || function (fn: (...args: any[]) => void) {
49
+ const methods = this.ctx.methods.get(name) || []
50
+ methods.push(fn || function (fn: (...args: any[]) => void) {
53
51
  this.register({
54
52
  name,
55
53
  fn
56
54
  })
57
55
  }.bind(this))
56
+ this.ctx.methods.set(name, methods)
58
57
  }
59
58
 
60
59
  addPluginOptsSchema (schema) {
@@ -76,6 +76,8 @@ export abstract class TaroPlatformBase {
76
76
  this.emptyOutputDir()
77
77
  }
78
78
  this.printDevelopmentTip(this.platform)
79
+ const { printLog, processTypeEnum } = this.ctx.helper
80
+ printLog(processTypeEnum.START, '开发者工具-项目目录', `${this.ctx.paths.outputPath}`)
79
81
  if (this.projectConfigJson) {
80
82
  this.generateProjectConfig(this.projectConfigJson)
81
83
  }
package/types/index.d.ts CHANGED
@@ -62,9 +62,13 @@ export declare interface IPluginContext {
62
62
  */
63
63
  onBuildStart: (fn: Function) => void
64
64
  /**
65
- * 编译结束
65
+ * 编译结束(保存代码每次编译结束后都会触发)
66
66
  */
67
67
  onBuildFinish: (fn: Function) => void
68
+ /**
69
+ * 编译完成(启动项目后首次编译结束后会触发一次)
70
+ */
71
+ onBuildComplete: (fn: Function) => void
68
72
  /**
69
73
  * 编译中修改 webpack 配置,在这个钩子中,你可以对 webpackChain 作出想要的调整,等同于配置 [`webpackChain`](./config-detail.md#miniwebpackchain)
70
74
  */