@modern-js/app-tools 2.62.1 → 2.63.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. package/bin/modern.js +2 -2
  2. package/dist/cjs/index.js +12 -144
  3. package/dist/cjs/new/compat/hooks.js +165 -0
  4. package/dist/cjs/new/compat/index.js +60 -0
  5. package/dist/cjs/new/compat/utils.js +95 -0
  6. package/dist/cjs/new/constants.js +37 -0
  7. package/dist/cjs/new/context.js +64 -0
  8. package/dist/cjs/new/getConfigFile.js +41 -0
  9. package/dist/cjs/new/index.js +79 -0
  10. package/dist/cjs/new/loadPlugins.js +57 -0
  11. package/dist/cjs/new/run.js +67 -0
  12. package/dist/cjs/new/utils/index.js +34 -0
  13. package/dist/cjs/old.js +179 -0
  14. package/dist/cjs/plugins/initialize/index.js +44 -50
  15. package/dist/cjs/types/new.js +16 -0
  16. package/dist/cjs/utils/restart.js +2 -2
  17. package/dist/esm/index.js +7 -249
  18. package/dist/esm/new/compat/hooks.js +452 -0
  19. package/dist/esm/new/compat/index.js +41 -0
  20. package/dist/esm/new/compat/utils.js +69 -0
  21. package/dist/esm/new/constants.js +10 -0
  22. package/dist/esm/new/context.js +31 -0
  23. package/dist/esm/new/getConfigFile.js +11 -0
  24. package/dist/esm/new/index.js +55 -0
  25. package/dist/esm/new/loadPlugins.js +94 -0
  26. package/dist/esm/new/run.js +80 -0
  27. package/dist/esm/new/utils/index.js +33 -0
  28. package/dist/esm/old.js +258 -0
  29. package/dist/esm/plugins/initialize/index.js +61 -64
  30. package/dist/esm/types/new.js +0 -0
  31. package/dist/esm/utils/restart.js +1 -1
  32. package/dist/esm-node/index.js +7 -131
  33. package/dist/esm-node/new/compat/hooks.js +140 -0
  34. package/dist/esm-node/new/compat/index.js +36 -0
  35. package/dist/esm-node/new/compat/utils.js +69 -0
  36. package/dist/esm-node/new/constants.js +10 -0
  37. package/dist/esm-node/new/context.js +30 -0
  38. package/dist/esm-node/new/getConfigFile.js +7 -0
  39. package/dist/esm-node/new/index.js +52 -0
  40. package/dist/esm-node/new/loadPlugins.js +33 -0
  41. package/dist/esm-node/new/run.js +43 -0
  42. package/dist/esm-node/new/utils/index.js +10 -0
  43. package/dist/esm-node/old.js +140 -0
  44. package/dist/esm-node/plugins/initialize/index.js +44 -50
  45. package/dist/esm-node/types/new.js +0 -0
  46. package/dist/esm-node/utils/restart.js +1 -1
  47. package/dist/types/config/default.d.ts +4 -3
  48. package/dist/types/index.d.ts +6 -16
  49. package/dist/types/new/compat/hooks.d.ts +7 -0
  50. package/dist/types/new/compat/index.d.ts +2 -0
  51. package/dist/types/new/compat/utils.d.ts +6 -0
  52. package/dist/types/new/constants.d.ts +4 -0
  53. package/dist/types/new/context.d.ts +33 -0
  54. package/dist/types/new/getConfigFile.d.ts +1 -0
  55. package/dist/types/new/index.d.ts +6 -0
  56. package/dist/types/new/loadPlugins.d.ts +9 -0
  57. package/dist/types/new/run.d.ts +13 -0
  58. package/dist/types/new/utils/index.d.ts +1 -0
  59. package/dist/types/old.d.ts +13 -0
  60. package/dist/types/plugins/initialize/index.d.ts +2 -2
  61. package/dist/types/types/index.d.ts +12 -3
  62. package/dist/types/types/new.d.ts +145 -0
  63. package/dist/types/utils/env.d.ts +2 -2
  64. package/dist/types/utils/restart.d.ts +1 -1
  65. package/lib/types.d.ts +82 -61
  66. package/package.json +27 -18
package/dist/esm/index.js CHANGED
@@ -1,258 +1,16 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
- import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
- import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
5
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
6
- import path from "path";
7
- import { getLocaleLanguage } from "@modern-js/plugin-i18n/language-detector";
8
- import { castArray } from "@modern-js/uni-builder";
9
- import { cleanRequireCache, deprecatedCommands, emptyDir, getArgv, getCommand } from "@modern-js/utils";
10
- import { hooks } from "./hooks";
11
- import { i18n } from "./locale";
12
- import analyzePlugin from "./plugins/analyze";
13
- import deployPlugin from "./plugins/deploy";
14
- import initializePlugin from "./plugins/initialize";
15
- import serverBuildPlugin from "./plugins/serverBuild";
16
- import { buildCommand, deployCommand, devCommand, inspectCommand, newCommand, serverCommand, upgradeCommand } from "./commands";
17
- import { generateWatchFiles } from "./utils/generateWatchFiles";
18
- import { restart } from "./utils/restart";
19
- import { dev } from "./commands/dev";
1
+ import { appTools } from "./new/index";
2
+ import { initAppContext } from "./new/index";
3
+ import { defineConfig, defineLegacyConfig } from "./defineConfig";
20
4
  import { mergeConfig } from "@modern-js/core";
21
- export * from "./defineConfig";
5
+ import { dev } from "./commands/dev";
22
6
  export * from "./types";
23
- var appTools = function() {
24
- var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
25
- // default webpack to be compatible with original projects
26
- bundler: "webpack"
27
- };
28
- return {
29
- name: "@modern-js/app-tools",
30
- post: [
31
- "@modern-js/plugin-initialize",
32
- "@modern-js/plugin-analyze",
33
- "@modern-js/plugin-ssr",
34
- "@modern-js/plugin-document",
35
- "@modern-js/plugin-state",
36
- "@modern-js/plugin-router",
37
- "@modern-js/plugin-router-v5",
38
- "@modern-js/plugin-polyfill"
39
- ],
40
- registerHook: hooks,
41
- usePlugins: [
42
- initializePlugin({
43
- bundler: (options === null || options === void 0 ? void 0 : options.bundler) && [
44
- "rspack",
45
- "experimental-rspack"
46
- ].includes(options.bundler) ? "rspack" : "webpack"
47
- }),
48
- analyzePlugin({
49
- bundler: (options === null || options === void 0 ? void 0 : options.bundler) && [
50
- "rspack",
51
- "experimental-rspack"
52
- ].includes(options.bundler) ? "rspack" : "webpack"
53
- }),
54
- serverBuildPlugin(),
55
- deployPlugin()
56
- ],
57
- setup: function(api) {
58
- var appContext = api.useAppContext();
59
- api.setAppContext(_object_spread_props(_object_spread({}, appContext), {
60
- toolsType: "app-tools"
61
- }));
62
- var locale = getLocaleLanguage();
63
- i18n.changeLanguage({
64
- locale
65
- });
66
- return {
67
- beforeConfig: function beforeConfig() {
68
- return _async_to_generator(function() {
69
- var _userConfig_output, userConfig, appContext2;
70
- return _ts_generator(this, function(_state) {
71
- userConfig = api.useConfigContext();
72
- appContext2 = api.useAppContext();
73
- if ((_userConfig_output = userConfig.output) === null || _userConfig_output === void 0 ? void 0 : _userConfig_output.tempDir) {
74
- api.setAppContext(_object_spread_props(_object_spread({}, appContext2), {
75
- internalDirectory: path.resolve(appContext2.appDirectory, userConfig.output.tempDir)
76
- }));
77
- }
78
- return [
79
- 2
80
- ];
81
- });
82
- })();
83
- },
84
- commands: function commands(param) {
85
- var program = param.program;
86
- return _async_to_generator(function() {
87
- return _ts_generator(this, function(_state) {
88
- switch (_state.label) {
89
- case 0:
90
- return [
91
- 4,
92
- devCommand(program, api)
93
- ];
94
- case 1:
95
- _state.sent();
96
- return [
97
- 4,
98
- buildCommand(program, api)
99
- ];
100
- case 2:
101
- _state.sent();
102
- serverCommand(program, api);
103
- deployCommand(program, api);
104
- newCommand(program, locale);
105
- inspectCommand(program, api);
106
- upgradeCommand(program);
107
- deprecatedCommands(program);
108
- return [
109
- 2
110
- ];
111
- }
112
- });
113
- })();
114
- },
115
- prepare: function prepare() {
116
- return _async_to_generator(function() {
117
- var command, isSkipBuild, resolvedConfig, appContext2;
118
- return _ts_generator(this, function(_state) {
119
- switch (_state.label) {
120
- case 0:
121
- command = getCommand();
122
- if (command === "deploy") {
123
- isSkipBuild = [
124
- "-s",
125
- "--skip-build"
126
- ].some(function(tag) {
127
- return getArgv().includes(tag);
128
- });
129
- if (isSkipBuild) {
130
- return [
131
- 2
132
- ];
133
- }
134
- }
135
- if (!(command === "dev" || command === "start" || command === "build" || command === "deploy"))
136
- return [
137
- 3,
138
- 2
139
- ];
140
- resolvedConfig = api.useResolvedConfigContext();
141
- if (!resolvedConfig.output.cleanDistPath)
142
- return [
143
- 3,
144
- 2
145
- ];
146
- appContext2 = api.useAppContext();
147
- return [
148
- 4,
149
- emptyDir(appContext2.distDirectory)
150
- ];
151
- case 1:
152
- _state.sent();
153
- _state.label = 2;
154
- case 2:
155
- return [
156
- 2
157
- ];
158
- }
159
- });
160
- })();
161
- },
162
- watchFiles: function watchFiles() {
163
- return _async_to_generator(function() {
164
- var appContext2, config, files, watchFiles2;
165
- return _ts_generator(this, function(_state) {
166
- switch (_state.label) {
167
- case 0:
168
- appContext2 = api.useAppContext();
169
- config = api.useResolvedConfigContext();
170
- return [
171
- 4,
172
- generateWatchFiles(appContext2, config.source.configDir)
173
- ];
174
- case 1:
175
- files = _state.sent();
176
- watchFiles2 = castArray(config.dev.watchFiles);
177
- watchFiles2.forEach(function(param) {
178
- var type = param.type, paths = param.paths;
179
- if (type === "reload-server") {
180
- var _files;
181
- (_files = files).push.apply(_files, _to_consumable_array(Array.isArray(paths) ? paths : [
182
- paths
183
- ]));
184
- }
185
- });
186
- return [
187
- 2,
188
- files
189
- ];
190
- }
191
- });
192
- })();
193
- },
194
- fileChange: (
195
- // 这里会被 core/initWatcher 监听的文件变动触发,如果是 src 目录下的文件变动,则不做 restart
196
- function fileChange(e) {
197
- return _async_to_generator(function() {
198
- var filename, eventType, isPrivate, closeServer;
199
- return _ts_generator(this, function(_state) {
200
- switch (_state.label) {
201
- case 0:
202
- filename = e.filename, eventType = e.eventType, isPrivate = e.isPrivate;
203
- if (!(!isPrivate && (eventType === "change" || eventType === "unlink")))
204
- return [
205
- 3,
206
- 4
207
- ];
208
- return [
209
- 4,
210
- import("./utils/createServer.js")
211
- ];
212
- case 1:
213
- closeServer = _state.sent().closeServer;
214
- return [
215
- 4,
216
- closeServer()
217
- ];
218
- case 2:
219
- _state.sent();
220
- return [
221
- 4,
222
- restart(api.useHookRunners(), filename)
223
- ];
224
- case 3:
225
- _state.sent();
226
- _state.label = 4;
227
- case 4:
228
- return [
229
- 2
230
- ];
231
- }
232
- });
233
- })();
234
- }
235
- ),
236
- beforeRestart: function beforeRestart() {
237
- return _async_to_generator(function() {
238
- return _ts_generator(this, function(_state) {
239
- cleanRequireCache([
240
- require.resolve("./plugins/analyze")
241
- ]);
242
- return [
243
- 2
244
- ];
245
- });
246
- })();
247
- }
248
- };
249
- }
250
- };
251
- };
252
7
  var src_default = appTools;
253
8
  export {
254
9
  appTools,
255
10
  src_default as default,
11
+ defineConfig,
12
+ defineLegacyConfig,
256
13
  dev,
14
+ initAppContext,
257
15
  mergeConfig
258
16
  };
@@ -0,0 +1,452 @@
1
+ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
+ import { transformHookParams, transformHookResult, transformHookRunner } from "./utils";
4
+ function getHookRunners(context) {
5
+ var hooks = context.hooks;
6
+ return {
7
+ /**
8
+ * app tools hooks
9
+ */
10
+ beforeConfig: /* @__PURE__ */ _async_to_generator(function() {
11
+ return _ts_generator(this, function(_state) {
12
+ return [
13
+ 2,
14
+ hooks.onBeforeConfig.call()
15
+ ];
16
+ });
17
+ }),
18
+ afterPrepare: /* @__PURE__ */ _async_to_generator(function() {
19
+ return _ts_generator(this, function(_state) {
20
+ return [
21
+ 2,
22
+ hooks.onAfterPrepare.call()
23
+ ];
24
+ });
25
+ }),
26
+ deploy: /* @__PURE__ */ _async_to_generator(function() {
27
+ return _ts_generator(this, function(_state) {
28
+ return [
29
+ 2,
30
+ hooks.deploy.call()
31
+ ];
32
+ });
33
+ }),
34
+ _internalRuntimePlugins: function() {
35
+ var _ref = _async_to_generator(function(params) {
36
+ return _ts_generator(this, function(_state) {
37
+ return [
38
+ 2,
39
+ hooks._internalRuntimePlugins.call(params)
40
+ ];
41
+ });
42
+ });
43
+ return function(params) {
44
+ return _ref.apply(this, arguments);
45
+ };
46
+ }(),
47
+ _internalServerPlugins: function() {
48
+ var _ref = _async_to_generator(function(params) {
49
+ return _ts_generator(this, function(_state) {
50
+ return [
51
+ 2,
52
+ hooks._internalServerPlugins.call(params)
53
+ ];
54
+ });
55
+ });
56
+ return function(params) {
57
+ return _ref.apply(this, arguments);
58
+ };
59
+ }(),
60
+ checkEntryPoint: function() {
61
+ var _ref = _async_to_generator(function(params) {
62
+ return _ts_generator(this, function(_state) {
63
+ return [
64
+ 2,
65
+ hooks.checkEntryPoint.call(params)
66
+ ];
67
+ });
68
+ });
69
+ return function(params) {
70
+ return _ref.apply(this, arguments);
71
+ };
72
+ }(),
73
+ modifyEntrypoints: function() {
74
+ var _ref = _async_to_generator(function(params) {
75
+ return _ts_generator(this, function(_state) {
76
+ return [
77
+ 2,
78
+ hooks.modifyEntrypoints.call(params)
79
+ ];
80
+ });
81
+ });
82
+ return function(params) {
83
+ return _ref.apply(this, arguments);
84
+ };
85
+ }(),
86
+ modifyFileSystemRoutes: function() {
87
+ var _ref = _async_to_generator(function(params) {
88
+ return _ts_generator(this, function(_state) {
89
+ return [
90
+ 2,
91
+ hooks.modifyFileSystemRoutes.call(params)
92
+ ];
93
+ });
94
+ });
95
+ return function(params) {
96
+ return _ref.apply(this, arguments);
97
+ };
98
+ }(),
99
+ modifyServerRoutes: function() {
100
+ var _ref = _async_to_generator(function(params) {
101
+ return _ts_generator(this, function(_state) {
102
+ return [
103
+ 2,
104
+ hooks.modifyServerRoutes.call(params)
105
+ ];
106
+ });
107
+ });
108
+ return function(params) {
109
+ return _ref.apply(this, arguments);
110
+ };
111
+ }(),
112
+ generateEntryCode: function() {
113
+ var _ref = _async_to_generator(function(params) {
114
+ return _ts_generator(this, function(_state) {
115
+ return [
116
+ 2,
117
+ hooks.generateEntryCode.call(params)
118
+ ];
119
+ });
120
+ });
121
+ return function(params) {
122
+ return _ref.apply(this, arguments);
123
+ };
124
+ }(),
125
+ beforeGenerateRoutes: function() {
126
+ var _ref = _async_to_generator(function(params) {
127
+ return _ts_generator(this, function(_state) {
128
+ return [
129
+ 2,
130
+ hooks.onBeforeGenerateRoutes.call(params)
131
+ ];
132
+ });
133
+ });
134
+ return function(params) {
135
+ return _ref.apply(this, arguments);
136
+ };
137
+ }(),
138
+ beforePrintInstructions: function() {
139
+ var _ref = _async_to_generator(function(params) {
140
+ return _ts_generator(this, function(_state) {
141
+ return [
142
+ 2,
143
+ hooks.onBeforePrintInstructions.call(params)
144
+ ];
145
+ });
146
+ });
147
+ return function(params) {
148
+ return _ref.apply(this, arguments);
149
+ };
150
+ }(),
151
+ // garfish plugin hooks
152
+ appendEntryCode: function() {
153
+ var _ref = _async_to_generator(function(params) {
154
+ var result;
155
+ return _ts_generator(this, function(_state) {
156
+ switch (_state.label) {
157
+ case 0:
158
+ return [
159
+ 4,
160
+ hooks === null || hooks === void 0 ? void 0 : hooks.appendEntryCode.call(params)
161
+ ];
162
+ case 1:
163
+ result = _state.sent();
164
+ return [
165
+ 2,
166
+ result
167
+ ];
168
+ }
169
+ });
170
+ });
171
+ return function(params) {
172
+ return _ref.apply(this, arguments);
173
+ };
174
+ }(),
175
+ /**
176
+ * common hooks
177
+ */
178
+ config: /* @__PURE__ */ _async_to_generator(function() {
179
+ return _ts_generator(this, function(_state) {
180
+ return [
181
+ 2,
182
+ hooks.config.call()
183
+ ];
184
+ });
185
+ }),
186
+ resolvedConfig: function(params) {
187
+ return hooks.modifyResolvedConfig.call(params);
188
+ },
189
+ htmlPartials: function() {
190
+ var _ref = _async_to_generator(function(params) {
191
+ return _ts_generator(this, function(_state) {
192
+ return [
193
+ 2,
194
+ hooks.modifyHtmlPartials.call(params)
195
+ ];
196
+ });
197
+ });
198
+ return function(params) {
199
+ return _ref.apply(this, arguments);
200
+ };
201
+ }(),
202
+ commands: function() {
203
+ var _ref = _async_to_generator(function(params) {
204
+ return _ts_generator(this, function(_state) {
205
+ return [
206
+ 2,
207
+ hooks.addCommand.call(params)
208
+ ];
209
+ });
210
+ });
211
+ return function(params) {
212
+ return _ref.apply(this, arguments);
213
+ };
214
+ }(),
215
+ watchFiles: /* @__PURE__ */ _async_to_generator(function() {
216
+ return _ts_generator(this, function(_state) {
217
+ return [
218
+ 2,
219
+ hooks.addWatchFiles.call()
220
+ ];
221
+ });
222
+ }),
223
+ prepare: /* @__PURE__ */ _async_to_generator(function() {
224
+ return _ts_generator(this, function(_state) {
225
+ return [
226
+ 2,
227
+ hooks.onPrepare.call()
228
+ ];
229
+ });
230
+ }),
231
+ filedChange: function() {
232
+ var _ref = _async_to_generator(function(params) {
233
+ return _ts_generator(this, function(_state) {
234
+ return [
235
+ 2,
236
+ hooks.onFileChanged.call(params)
237
+ ];
238
+ });
239
+ });
240
+ return function(params) {
241
+ return _ref.apply(this, arguments);
242
+ };
243
+ }(),
244
+ beforeCreateCompiler: function() {
245
+ var _ref = _async_to_generator(function(params) {
246
+ return _ts_generator(this, function(_state) {
247
+ return [
248
+ 2,
249
+ hooks.onBeforeCreateCompiler.call(params)
250
+ ];
251
+ });
252
+ });
253
+ return function(params) {
254
+ return _ref.apply(this, arguments);
255
+ };
256
+ }(),
257
+ afterCreateCompiler: function() {
258
+ var _ref = _async_to_generator(function(params) {
259
+ return _ts_generator(this, function(_state) {
260
+ return [
261
+ 2,
262
+ hooks.onAfterCreateCompiler.call(params)
263
+ ];
264
+ });
265
+ });
266
+ return function(params) {
267
+ return _ref.apply(this, arguments);
268
+ };
269
+ }(),
270
+ beforeBuild: function() {
271
+ var _ref = _async_to_generator(function(params) {
272
+ return _ts_generator(this, function(_state) {
273
+ return [
274
+ 2,
275
+ hooks.onBeforeBuild.call(params)
276
+ ];
277
+ });
278
+ });
279
+ return function(params) {
280
+ return _ref.apply(this, arguments);
281
+ };
282
+ }(),
283
+ afterBuild: function() {
284
+ var _ref = _async_to_generator(function(params) {
285
+ return _ts_generator(this, function(_state) {
286
+ return [
287
+ 2,
288
+ hooks.onAfterBuild.call(params)
289
+ ];
290
+ });
291
+ });
292
+ return function(params) {
293
+ return _ref.apply(this, arguments);
294
+ };
295
+ }(),
296
+ beforeDev: /* @__PURE__ */ _async_to_generator(function() {
297
+ return _ts_generator(this, function(_state) {
298
+ return [
299
+ 2,
300
+ hooks.onBeforeDev.call()
301
+ ];
302
+ });
303
+ }),
304
+ afterDev: function() {
305
+ var _ref = _async_to_generator(function(params) {
306
+ return _ts_generator(this, function(_state) {
307
+ return [
308
+ 2,
309
+ hooks.onAfterDev.call(params)
310
+ ];
311
+ });
312
+ });
313
+ return function(params) {
314
+ return _ref.apply(this, arguments);
315
+ };
316
+ }(),
317
+ beforeDeploy: function() {
318
+ var _ref = _async_to_generator(function(options) {
319
+ return _ts_generator(this, function(_state) {
320
+ return [
321
+ 2,
322
+ hooks.onBeforeDeploy.call(options)
323
+ ];
324
+ });
325
+ });
326
+ return function(options) {
327
+ return _ref.apply(this, arguments);
328
+ };
329
+ }(),
330
+ afterDeploy: function() {
331
+ var _ref = _async_to_generator(function(options) {
332
+ return _ts_generator(this, function(_state) {
333
+ return [
334
+ 2,
335
+ hooks.onAfterDeploy.call(options)
336
+ ];
337
+ });
338
+ });
339
+ return function(options) {
340
+ return _ref.apply(this, arguments);
341
+ };
342
+ }(),
343
+ beforeExit: /* @__PURE__ */ _async_to_generator(function() {
344
+ return _ts_generator(this, function(_state) {
345
+ return [
346
+ 2,
347
+ hooks.onBeforeExit.call()
348
+ ];
349
+ });
350
+ }),
351
+ beforeRestart: /* @__PURE__ */ _async_to_generator(function() {
352
+ return _ts_generator(this, function(_state) {
353
+ return [
354
+ 2,
355
+ hooks.onBeforeRestart.call()
356
+ ];
357
+ });
358
+ }),
359
+ /**
360
+ * @deprecated
361
+ */
362
+ registerDev: function() {
363
+ var _ref = _async_to_generator(function(params) {
364
+ return _ts_generator(this, function(_state) {
365
+ return [
366
+ 2,
367
+ hooks.registerDev.call(params)
368
+ ];
369
+ });
370
+ });
371
+ return function(params) {
372
+ return _ref.apply(this, arguments);
373
+ };
374
+ }(),
375
+ /**
376
+ * @deprecated
377
+ */
378
+ registerBuildPlatform: function() {
379
+ var _ref = _async_to_generator(function(params) {
380
+ return _ts_generator(this, function(_state) {
381
+ return [
382
+ 2,
383
+ hooks.registerBuildPlatform.call(params)
384
+ ];
385
+ });
386
+ });
387
+ return function(params) {
388
+ return _ref.apply(this, arguments);
389
+ };
390
+ }(),
391
+ /**
392
+ * @deprecated
393
+ */
394
+ addRuntimeExports: function() {
395
+ var _ref = _async_to_generator(function(params) {
396
+ return _ts_generator(this, function(_state) {
397
+ return [
398
+ 2,
399
+ hooks.addRuntimeExports.call(params)
400
+ ];
401
+ });
402
+ });
403
+ return function(params) {
404
+ return _ref.apply(this, arguments);
405
+ };
406
+ }()
407
+ };
408
+ }
409
+ function handleSetupResult(setupResult, api) {
410
+ if (!setupResult) {
411
+ return;
412
+ }
413
+ Object.keys(setupResult).forEach(function(key) {
414
+ var fn = setupResult[key];
415
+ if (typeof fn === "function") {
416
+ var newAPI = transformHookRunner(key);
417
+ if (api[newAPI]) {
418
+ api[newAPI](function() {
419
+ var _ref = _async_to_generator(function(params) {
420
+ var _tmp;
421
+ return _ts_generator(this, function(_state) {
422
+ switch (_state.label) {
423
+ case 0:
424
+ _tmp = [
425
+ key
426
+ ];
427
+ return [
428
+ 4,
429
+ fn(transformHookParams(key, params))
430
+ ];
431
+ case 1:
432
+ return [
433
+ 2,
434
+ transformHookResult.apply(void 0, _tmp.concat([
435
+ _state.sent()
436
+ ]))
437
+ ];
438
+ }
439
+ });
440
+ });
441
+ return function(params) {
442
+ return _ref.apply(this, arguments);
443
+ };
444
+ }());
445
+ }
446
+ }
447
+ });
448
+ }
449
+ export {
450
+ getHookRunners,
451
+ handleSetupResult
452
+ };