@modern-js/plugin-v2 2.65.2-alpha.1 → 2.65.3
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/cjs/hooks.js +0 -29
- package/dist/cjs/index.js +0 -2
- package/dist/esm/hooks.js +0 -129
- package/dist/esm/index.js +1 -2
- package/dist/esm-node/hooks.js +0 -28
- package/dist/esm-node/index.js +1 -2
- package/dist/types/hooks.d.ts +1 -2
- package/dist/types/index.d.ts +2 -3
- package/dist/types/types/hooks.d.ts +1 -5
- package/package.json +10 -21
- package/dist/cjs/server/api.js +0 -94
- package/dist/cjs/server/context.js +0 -64
- package/dist/cjs/server/hooks.js +0 -35
- package/dist/cjs/server/index.js +0 -41
- package/dist/cjs/server/run/create.js +0 -75
- package/dist/cjs/server/run/index.js +0 -31
- package/dist/cjs/server/run/types.js +0 -16
- package/dist/cjs/types/server/api.js +0 -16
- package/dist/cjs/types/server/context.js +0 -16
- package/dist/cjs/types/server/hooks.js +0 -16
- package/dist/cjs/types/server/index.js +0 -16
- package/dist/cjs/types/server/plugin.js +0 -16
- package/dist/esm/server/api.js +0 -76
- package/dist/esm/server/context.js +0 -38
- package/dist/esm/server/hooks.js +0 -11
- package/dist/esm/server/index.js +0 -12
- package/dist/esm/server/run/create.js +0 -95
- package/dist/esm/server/run/index.js +0 -6
- package/dist/esm/server/run/types.js +0 -0
- package/dist/esm/types/server/api.js +0 -0
- package/dist/esm/types/server/context.js +0 -0
- package/dist/esm/types/server/hooks.js +0 -0
- package/dist/esm/types/server/index.js +0 -0
- package/dist/esm/types/server/plugin.js +0 -0
- package/dist/esm-node/server/api.js +0 -69
- package/dist/esm-node/server/context.js +0 -39
- package/dist/esm-node/server/hooks.js +0 -11
- package/dist/esm-node/server/index.js +0 -12
- package/dist/esm-node/server/run/create.js +0 -51
- package/dist/esm-node/server/run/index.js +0 -6
- package/dist/esm-node/server/run/types.js +0 -0
- package/dist/esm-node/types/server/api.js +0 -0
- package/dist/esm-node/types/server/context.js +0 -0
- package/dist/esm-node/types/server/hooks.js +0 -0
- package/dist/esm-node/types/server/index.js +0 -0
- package/dist/esm-node/types/server/plugin.js +0 -0
- package/dist/types/server/api.d.ts +0 -9
- package/dist/types/server/context.d.ts +0 -13
- package/dist/types/server/hooks.d.ts +0 -9
- package/dist/types/server/index.d.ts +0 -4
- package/dist/types/server/run/create.d.ts +0 -7
- package/dist/types/server/run/index.d.ts +0 -8
- package/dist/types/server/run/types.d.ts +0 -21
- package/dist/types/types/server/api.d.ts +0 -16
- package/dist/types/types/server/context.d.ts +0 -28
- package/dist/types/types/server/hooks.d.ts +0 -24
- package/dist/types/types/server/index.d.ts +0 -4
- package/dist/types/types/server/plugin.d.ts +0 -14
package/dist/cjs/hooks.js
CHANGED
|
@@ -20,7 +20,6 @@ var hooks_exports = {};
|
|
|
20
20
|
__export(hooks_exports, {
|
|
21
21
|
createAsyncHook: () => createAsyncHook,
|
|
22
22
|
createAsyncInterruptHook: () => createAsyncInterruptHook,
|
|
23
|
-
createAsyncPipelineHook: () => createAsyncPipelineHook,
|
|
24
23
|
createCollectAsyncHook: () => createCollectAsyncHook,
|
|
25
24
|
createCollectSyncHook: () => createCollectSyncHook,
|
|
26
25
|
createSyncHook: () => createSyncHook
|
|
@@ -131,38 +130,10 @@ function createCollectSyncHook() {
|
|
|
131
130
|
call
|
|
132
131
|
};
|
|
133
132
|
}
|
|
134
|
-
function createAsyncPipelineHook() {
|
|
135
|
-
const callbacks = [];
|
|
136
|
-
const tap = (cb) => {
|
|
137
|
-
callbacks.push(cb);
|
|
138
|
-
};
|
|
139
|
-
const call = async (...params) => {
|
|
140
|
-
for (const callback of callbacks) {
|
|
141
|
-
let runNext = false;
|
|
142
|
-
const next = (info) => {
|
|
143
|
-
runNext = true;
|
|
144
|
-
if (info) {
|
|
145
|
-
params[0] = info;
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
const result = await callback(...params, next);
|
|
149
|
-
if (!runNext) {
|
|
150
|
-
params[0] = result;
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return params[0] || [];
|
|
155
|
-
};
|
|
156
|
-
return {
|
|
157
|
-
tap,
|
|
158
|
-
call
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
133
|
// Annotate the CommonJS export names for ESM import in node:
|
|
162
134
|
0 && (module.exports = {
|
|
163
135
|
createAsyncHook,
|
|
164
136
|
createAsyncInterruptHook,
|
|
165
|
-
createAsyncPipelineHook,
|
|
166
137
|
createCollectAsyncHook,
|
|
167
138
|
createCollectSyncHook,
|
|
168
139
|
createSyncHook
|
package/dist/cjs/index.js
CHANGED
|
@@ -20,7 +20,6 @@ var src_exports = {};
|
|
|
20
20
|
__export(src_exports, {
|
|
21
21
|
createAsyncHook: () => import_hooks.createAsyncHook,
|
|
22
22
|
createAsyncInterruptHook: () => import_hooks.createAsyncInterruptHook,
|
|
23
|
-
createAsyncPipelineHook: () => import_hooks.createAsyncPipelineHook,
|
|
24
23
|
createCollectAsyncHook: () => import_hooks.createCollectAsyncHook,
|
|
25
24
|
createCollectSyncHook: () => import_hooks.createCollectSyncHook,
|
|
26
25
|
createPluginManager: () => import_manager.createPluginManager,
|
|
@@ -33,7 +32,6 @@ var import_hooks = require("./hooks");
|
|
|
33
32
|
0 && (module.exports = {
|
|
34
33
|
createAsyncHook,
|
|
35
34
|
createAsyncInterruptHook,
|
|
36
|
-
createAsyncPipelineHook,
|
|
37
35
|
createCollectAsyncHook,
|
|
38
36
|
createCollectSyncHook,
|
|
39
37
|
createPluginManager,
|
package/dist/esm/hooks.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
3
3
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
4
|
-
import { _ as _ts_values } from "@swc/helpers/_/_ts_values";
|
|
5
4
|
function createAsyncInterruptHook() {
|
|
6
5
|
var callbacks = [];
|
|
7
6
|
var tap = function(cb) {
|
|
@@ -370,137 +369,9 @@ function createCollectSyncHook() {
|
|
|
370
369
|
call
|
|
371
370
|
};
|
|
372
371
|
}
|
|
373
|
-
function createAsyncPipelineHook() {
|
|
374
|
-
var callbacks = [];
|
|
375
|
-
var tap = function(cb) {
|
|
376
|
-
callbacks.push(cb);
|
|
377
|
-
};
|
|
378
|
-
var call = function() {
|
|
379
|
-
var _ref = _async_to_generator(function() {
|
|
380
|
-
var _len, params, _key, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _loop, _iterator, _step, _ret, err;
|
|
381
|
-
var _arguments = arguments;
|
|
382
|
-
return _ts_generator(this, function(_state) {
|
|
383
|
-
switch (_state.label) {
|
|
384
|
-
case 0:
|
|
385
|
-
for (_len = _arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
386
|
-
params[_key] = _arguments[_key];
|
|
387
|
-
}
|
|
388
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
389
|
-
_state.label = 1;
|
|
390
|
-
case 1:
|
|
391
|
-
_state.trys.push([
|
|
392
|
-
1,
|
|
393
|
-
6,
|
|
394
|
-
7,
|
|
395
|
-
8
|
|
396
|
-
]);
|
|
397
|
-
_loop = function() {
|
|
398
|
-
var callback, runNext, next, result;
|
|
399
|
-
return _ts_generator(this, function(_state2) {
|
|
400
|
-
switch (_state2.label) {
|
|
401
|
-
case 0:
|
|
402
|
-
callback = _step.value;
|
|
403
|
-
runNext = false;
|
|
404
|
-
next = function(info) {
|
|
405
|
-
runNext = true;
|
|
406
|
-
if (info) {
|
|
407
|
-
params[0] = info;
|
|
408
|
-
}
|
|
409
|
-
};
|
|
410
|
-
return [
|
|
411
|
-
4,
|
|
412
|
-
callback.apply(void 0, _to_consumable_array(params).concat([
|
|
413
|
-
next
|
|
414
|
-
]))
|
|
415
|
-
];
|
|
416
|
-
case 1:
|
|
417
|
-
result = _state2.sent();
|
|
418
|
-
if (!runNext) {
|
|
419
|
-
params[0] = result;
|
|
420
|
-
return [
|
|
421
|
-
2,
|
|
422
|
-
"break"
|
|
423
|
-
];
|
|
424
|
-
}
|
|
425
|
-
return [
|
|
426
|
-
2
|
|
427
|
-
];
|
|
428
|
-
}
|
|
429
|
-
});
|
|
430
|
-
};
|
|
431
|
-
_iterator = callbacks[Symbol.iterator]();
|
|
432
|
-
_state.label = 2;
|
|
433
|
-
case 2:
|
|
434
|
-
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done))
|
|
435
|
-
return [
|
|
436
|
-
3,
|
|
437
|
-
5
|
|
438
|
-
];
|
|
439
|
-
return [
|
|
440
|
-
5,
|
|
441
|
-
_ts_values(_loop())
|
|
442
|
-
];
|
|
443
|
-
case 3:
|
|
444
|
-
_ret = _state.sent();
|
|
445
|
-
if (_ret === "break")
|
|
446
|
-
return [
|
|
447
|
-
3,
|
|
448
|
-
5
|
|
449
|
-
];
|
|
450
|
-
_state.label = 4;
|
|
451
|
-
case 4:
|
|
452
|
-
_iteratorNormalCompletion = true;
|
|
453
|
-
return [
|
|
454
|
-
3,
|
|
455
|
-
2
|
|
456
|
-
];
|
|
457
|
-
case 5:
|
|
458
|
-
return [
|
|
459
|
-
3,
|
|
460
|
-
8
|
|
461
|
-
];
|
|
462
|
-
case 6:
|
|
463
|
-
err = _state.sent();
|
|
464
|
-
_didIteratorError = true;
|
|
465
|
-
_iteratorError = err;
|
|
466
|
-
return [
|
|
467
|
-
3,
|
|
468
|
-
8
|
|
469
|
-
];
|
|
470
|
-
case 7:
|
|
471
|
-
try {
|
|
472
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
473
|
-
_iterator.return();
|
|
474
|
-
}
|
|
475
|
-
} finally {
|
|
476
|
-
if (_didIteratorError) {
|
|
477
|
-
throw _iteratorError;
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
return [
|
|
481
|
-
7
|
|
482
|
-
];
|
|
483
|
-
case 8:
|
|
484
|
-
return [
|
|
485
|
-
2,
|
|
486
|
-
params[0] || []
|
|
487
|
-
];
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
|
-
});
|
|
491
|
-
return function call2() {
|
|
492
|
-
return _ref.apply(this, arguments);
|
|
493
|
-
};
|
|
494
|
-
}();
|
|
495
|
-
return {
|
|
496
|
-
tap,
|
|
497
|
-
call
|
|
498
|
-
};
|
|
499
|
-
}
|
|
500
372
|
export {
|
|
501
373
|
createAsyncHook,
|
|
502
374
|
createAsyncInterruptHook,
|
|
503
|
-
createAsyncPipelineHook,
|
|
504
375
|
createCollectAsyncHook,
|
|
505
376
|
createCollectSyncHook,
|
|
506
377
|
createSyncHook
|
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { createPluginManager } from "./manager";
|
|
2
|
-
import { createSyncHook, createAsyncHook, createCollectSyncHook, createCollectAsyncHook, createAsyncInterruptHook
|
|
2
|
+
import { createSyncHook, createAsyncHook, createCollectSyncHook, createCollectAsyncHook, createAsyncInterruptHook } from "./hooks";
|
|
3
3
|
export {
|
|
4
4
|
createAsyncHook,
|
|
5
5
|
createAsyncInterruptHook,
|
|
6
|
-
createAsyncPipelineHook,
|
|
7
6
|
createCollectAsyncHook,
|
|
8
7
|
createCollectSyncHook,
|
|
9
8
|
createPluginManager,
|
package/dist/esm-node/hooks.js
CHANGED
|
@@ -103,37 +103,9 @@ function createCollectSyncHook() {
|
|
|
103
103
|
call
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
|
-
function createAsyncPipelineHook() {
|
|
107
|
-
const callbacks = [];
|
|
108
|
-
const tap = (cb) => {
|
|
109
|
-
callbacks.push(cb);
|
|
110
|
-
};
|
|
111
|
-
const call = async (...params) => {
|
|
112
|
-
for (const callback of callbacks) {
|
|
113
|
-
let runNext = false;
|
|
114
|
-
const next = (info) => {
|
|
115
|
-
runNext = true;
|
|
116
|
-
if (info) {
|
|
117
|
-
params[0] = info;
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
const result = await callback(...params, next);
|
|
121
|
-
if (!runNext) {
|
|
122
|
-
params[0] = result;
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return params[0] || [];
|
|
127
|
-
};
|
|
128
|
-
return {
|
|
129
|
-
tap,
|
|
130
|
-
call
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
106
|
export {
|
|
134
107
|
createAsyncHook,
|
|
135
108
|
createAsyncInterruptHook,
|
|
136
|
-
createAsyncPipelineHook,
|
|
137
109
|
createCollectAsyncHook,
|
|
138
110
|
createCollectSyncHook,
|
|
139
111
|
createSyncHook
|
package/dist/esm-node/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { createPluginManager } from "./manager";
|
|
2
|
-
import { createSyncHook, createAsyncHook, createCollectSyncHook, createCollectAsyncHook, createAsyncInterruptHook
|
|
2
|
+
import { createSyncHook, createAsyncHook, createCollectSyncHook, createCollectAsyncHook, createAsyncInterruptHook } from "./hooks";
|
|
3
3
|
export {
|
|
4
4
|
createAsyncHook,
|
|
5
5
|
createAsyncInterruptHook,
|
|
6
|
-
createAsyncPipelineHook,
|
|
7
6
|
createCollectAsyncHook,
|
|
8
7
|
createCollectSyncHook,
|
|
9
8
|
createPluginManager,
|
package/dist/types/hooks.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { AsyncHook, AsyncInterruptHook,
|
|
1
|
+
import type { AsyncHook, AsyncInterruptHook, CollectAsyncHook, CollectSyncHook, SyncHook } from './types/hooks';
|
|
2
2
|
export declare function createAsyncInterruptHook<Callback extends (...args: any[]) => any>(): AsyncInterruptHook<Callback>;
|
|
3
3
|
export declare function createSyncHook<Callback extends (...args: any[]) => any>(): SyncHook<Callback>;
|
|
4
4
|
export declare function createAsyncHook<Callback extends (...args: any[]) => any>(): AsyncHook<Callback>;
|
|
5
5
|
export declare function createCollectAsyncHook<Callback extends (...params: any[]) => any>(): CollectAsyncHook<Callback>;
|
|
6
6
|
export declare function createCollectSyncHook<Callback extends (...params: any[]) => any>(): CollectSyncHook<Callback>;
|
|
7
|
-
export declare function createAsyncPipelineHook<Callback extends (...args: any[]) => any>(): AsyncPipelineHook<Callback>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export { createPluginManager } from './manager';
|
|
2
|
-
export { createSyncHook, createAsyncHook, createCollectSyncHook, createCollectAsyncHook, createAsyncInterruptHook,
|
|
2
|
+
export { createSyncHook, createAsyncHook, createCollectSyncHook, createCollectAsyncHook, createAsyncInterruptHook, } from './hooks';
|
|
3
3
|
export type { Plugin, PluginManager, TransformFunction, } from './types/plugin';
|
|
4
4
|
export type { CLIPluginAPI, AppContext, InternalContext, Entrypoint, CLIPlugin, CLIPluginExtends, RuntimePluginConfig, ServerPluginConfig, } from './types/cli';
|
|
5
5
|
export type { RuntimePluginAPI, RuntimeContext, InternalRuntimeContext, RuntimePlugin, RuntimePluginExtends, } from './types/runtime';
|
|
6
|
-
export type {
|
|
7
|
-
export type { SyncHook, AsyncHook, AsyncInterruptHook, CollectAsyncHook, CollectSyncHook, PluginHook, PluginHookTap, AsyncPipelineHook, } from './types/hooks';
|
|
6
|
+
export type { AsyncHook, CollectAsyncHook, PluginHook, PluginHookTap, } from './types/hooks';
|
|
@@ -11,10 +11,6 @@ export type AsyncInterruptHook<Callback extends (...args: any[]) => any> = {
|
|
|
11
11
|
tap: (cb: Callback) => void;
|
|
12
12
|
call: (...args: Tail<Parameters<Callback>>) => Promise<UnwrapPromise<ReturnType<Callback>>>;
|
|
13
13
|
};
|
|
14
|
-
export type AsyncPipelineHook<Callback extends (...args: any[]) => any> = {
|
|
15
|
-
tap: (cb: Callback) => void;
|
|
16
|
-
call: (...args: Parameters<Callback>) => Promise<UnwrapPromise<ReturnType<Callback>>>;
|
|
17
|
-
};
|
|
18
14
|
export type CollectAsyncHook<Callback extends (...params: any[]) => any> = {
|
|
19
15
|
tap: (cb: Callback) => void;
|
|
20
16
|
call: (...params: Parameters<Callback>) => Promise<UnwrapPromise<ReturnType<Callback>>[]>;
|
|
@@ -23,5 +19,5 @@ export type CollectSyncHook<Callback extends (...params: any[]) => any> = {
|
|
|
23
19
|
tap: (cb: Callback) => void;
|
|
24
20
|
call: (...params: Parameters<Callback>) => ReturnType<Callback>[];
|
|
25
21
|
};
|
|
26
|
-
export type PluginHook<Callback extends (...args: any[]) => any> = SyncHook<Callback> | AsyncHook<Callback> | CollectSyncHook<Callback> | CollectAsyncHook<Callback> | AsyncInterruptHook<Callback
|
|
22
|
+
export type PluginHook<Callback extends (...args: any[]) => any> = SyncHook<Callback> | AsyncHook<Callback> | CollectSyncHook<Callback> | CollectAsyncHook<Callback> | AsyncInterruptHook<Callback>;
|
|
27
23
|
export type PluginHookTap<T extends (...args: any[]) => any> = (options: T) => void;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.65.
|
|
18
|
+
"version": "2.65.3",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -48,15 +48,6 @@
|
|
|
48
48
|
"require": "./dist/cjs/runtime/index.js"
|
|
49
49
|
},
|
|
50
50
|
"default": "./dist/esm/runtime/index.js"
|
|
51
|
-
},
|
|
52
|
-
"./server": {
|
|
53
|
-
"types": "./dist/types/server/index.d.ts",
|
|
54
|
-
"jsnext:source": "./src/server/index.ts",
|
|
55
|
-
"node": {
|
|
56
|
-
"import": "./dist/esm-node/server/index.js",
|
|
57
|
-
"require": "./dist/cjs/server/index.js"
|
|
58
|
-
},
|
|
59
|
-
"default": "./dist/esm/server/index.js"
|
|
60
51
|
}
|
|
61
52
|
},
|
|
62
53
|
"typesVersions": {
|
|
@@ -72,34 +63,32 @@
|
|
|
72
63
|
],
|
|
73
64
|
"runtime": [
|
|
74
65
|
"./dist/types/runtime/index.d.ts"
|
|
75
|
-
],
|
|
76
|
-
"server": [
|
|
77
|
-
"./dist/types/server/index.d.ts"
|
|
78
66
|
]
|
|
79
67
|
}
|
|
80
68
|
},
|
|
81
69
|
"dependencies": {
|
|
82
70
|
"@swc/helpers": "0.5.13",
|
|
83
71
|
"jiti": "1.21.7",
|
|
84
|
-
"@modern-js/runtime-utils": "2.65.
|
|
85
|
-
"@modern-js/utils": "2.65.
|
|
72
|
+
"@modern-js/runtime-utils": "2.65.3",
|
|
73
|
+
"@modern-js/utils": "2.65.3"
|
|
86
74
|
},
|
|
87
75
|
"devDependencies": {
|
|
88
|
-
"@rsbuild/core": "1.2.
|
|
76
|
+
"@rsbuild/core": "1.2.15",
|
|
89
77
|
"@types/jest": "^29",
|
|
90
78
|
"@types/node": "^14",
|
|
91
79
|
"@types/react": "^18.3.11",
|
|
92
80
|
"jest": "^29",
|
|
93
81
|
"typescript": "^5",
|
|
94
|
-
"@modern-js/types": "2.65.
|
|
95
|
-
"@modern-js/uni-builder": "2.65.
|
|
96
|
-
"@scripts/build": "2.65.
|
|
97
|
-
"@scripts/jest-config": "2.65.
|
|
82
|
+
"@modern-js/types": "2.65.3",
|
|
83
|
+
"@modern-js/uni-builder": "2.65.3",
|
|
84
|
+
"@scripts/build": "2.65.3",
|
|
85
|
+
"@scripts/jest-config": "2.65.3"
|
|
98
86
|
},
|
|
99
87
|
"sideEffects": false,
|
|
100
88
|
"publishConfig": {
|
|
101
89
|
"registry": "https://registry.npmjs.org/",
|
|
102
|
-
"access": "public"
|
|
90
|
+
"access": "public",
|
|
91
|
+
"provenance": true
|
|
103
92
|
},
|
|
104
93
|
"scripts": {
|
|
105
94
|
"new": "modern-lib new",
|
package/dist/cjs/server/api.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var api_exports = {};
|
|
20
|
-
__export(api_exports, {
|
|
21
|
-
debug: () => debug,
|
|
22
|
-
initPluginAPI: () => initPluginAPI
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(api_exports);
|
|
25
|
-
var import_utils = require("@modern-js/utils");
|
|
26
|
-
var import_lodash = require("@modern-js/utils/lodash");
|
|
27
|
-
const debug = (0, import_utils.createDebugger)("plugin-server-v2");
|
|
28
|
-
function initPluginAPI({ context, pluginManager }) {
|
|
29
|
-
const { hooks, extendsHooks, plugins } = context;
|
|
30
|
-
function getServerContext() {
|
|
31
|
-
if (context) {
|
|
32
|
-
const { hooks: hooks2, extendsHooks: extendsHooks2, config, pluginAPI: pluginAPI2, ...serverContext } = context;
|
|
33
|
-
serverContext._internalContext = context;
|
|
34
|
-
return serverContext;
|
|
35
|
-
}
|
|
36
|
-
throw new Error("Cannot access context");
|
|
37
|
-
}
|
|
38
|
-
function getConfig() {
|
|
39
|
-
if (context.config) {
|
|
40
|
-
return context.config;
|
|
41
|
-
}
|
|
42
|
-
throw new Error("Cannot access config");
|
|
43
|
-
}
|
|
44
|
-
function getHooks() {
|
|
45
|
-
return context.hooks;
|
|
46
|
-
}
|
|
47
|
-
const extendsPluginApi = {};
|
|
48
|
-
plugins.forEach((plugin) => {
|
|
49
|
-
const { _registryApi } = plugin;
|
|
50
|
-
if (_registryApi) {
|
|
51
|
-
const apis = _registryApi(getServerContext, updateServerContext);
|
|
52
|
-
Object.keys(apis).forEach((apiName) => {
|
|
53
|
-
extendsPluginApi[apiName] = apis[apiName];
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
if (extendsHooks) {
|
|
58
|
-
Object.keys(extendsHooks).forEach((hookName) => {
|
|
59
|
-
extendsPluginApi[hookName] = extendsHooks[hookName].tap;
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
function updateServerContext(updateContext) {
|
|
63
|
-
context = (0, import_lodash.assign)(context, updateContext);
|
|
64
|
-
}
|
|
65
|
-
const pluginAPI = {
|
|
66
|
-
isPluginExists: pluginManager.isPluginExists,
|
|
67
|
-
getServerContext,
|
|
68
|
-
getConfig,
|
|
69
|
-
getHooks,
|
|
70
|
-
updateServerContext,
|
|
71
|
-
modifyConfig: hooks.modifyConfig.tap,
|
|
72
|
-
onPrepare: hooks.onPrepare.tap,
|
|
73
|
-
onReset: hooks.onReset.tap,
|
|
74
|
-
...extendsPluginApi
|
|
75
|
-
};
|
|
76
|
-
return new Proxy(pluginAPI, {
|
|
77
|
-
get(target, prop) {
|
|
78
|
-
if (prop === "then") {
|
|
79
|
-
return void 0;
|
|
80
|
-
}
|
|
81
|
-
if (prop in target) {
|
|
82
|
-
return target[prop];
|
|
83
|
-
}
|
|
84
|
-
return () => {
|
|
85
|
-
debug(`api.${prop.toString()} not exist`);
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
91
|
-
0 && (module.exports = {
|
|
92
|
-
debug,
|
|
93
|
-
initPluginAPI
|
|
94
|
-
});
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var context_exports = {};
|
|
20
|
-
__export(context_exports, {
|
|
21
|
-
createServerContext: () => createServerContext,
|
|
22
|
-
initServerContext: () => initServerContext
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(context_exports);
|
|
25
|
-
var import_hooks = require("./hooks");
|
|
26
|
-
function initServerContext(params) {
|
|
27
|
-
const { options, plugins } = params;
|
|
28
|
-
return {
|
|
29
|
-
routes: options.routes || [],
|
|
30
|
-
appDirectory: options.appContext.appDirectory || "",
|
|
31
|
-
apiDirectory: options.appContext.apiDirectory,
|
|
32
|
-
lambdaDirectory: options.appContext.lambdaDirectory,
|
|
33
|
-
internalDirectory: options.appContext.internalDirectory || "",
|
|
34
|
-
sharedDirectory: options.appContext.sharedDirectory || "",
|
|
35
|
-
distDirectory: options.pwd,
|
|
36
|
-
metaName: options.metaName || "modern-js",
|
|
37
|
-
plugins,
|
|
38
|
-
middlewares: []
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function createServerContext({ serverContext, config }) {
|
|
42
|
-
const { plugins } = serverContext;
|
|
43
|
-
const extendsHooks = {};
|
|
44
|
-
plugins.forEach((plugin) => {
|
|
45
|
-
const { registryHooks = {} } = plugin;
|
|
46
|
-
Object.keys(registryHooks).forEach((hookName) => {
|
|
47
|
-
extendsHooks[hookName] = registryHooks[hookName];
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
return {
|
|
51
|
-
...serverContext,
|
|
52
|
-
hooks: {
|
|
53
|
-
...(0, import_hooks.initHooks)(),
|
|
54
|
-
...extendsHooks
|
|
55
|
-
},
|
|
56
|
-
extendsHooks,
|
|
57
|
-
config
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
-
0 && (module.exports = {
|
|
62
|
-
createServerContext,
|
|
63
|
-
initServerContext
|
|
64
|
-
});
|
package/dist/cjs/server/hooks.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var hooks_exports = {};
|
|
20
|
-
__export(hooks_exports, {
|
|
21
|
-
initHooks: () => initHooks
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(hooks_exports);
|
|
24
|
-
var import_hooks = require("../hooks");
|
|
25
|
-
function initHooks() {
|
|
26
|
-
return {
|
|
27
|
-
modifyConfig: (0, import_hooks.createAsyncHook)(),
|
|
28
|
-
onPrepare: (0, import_hooks.createAsyncHook)(),
|
|
29
|
-
onReset: (0, import_hooks.createAsyncHook)()
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
-
0 && (module.exports = {
|
|
34
|
-
initHooks
|
|
35
|
-
});
|
package/dist/cjs/server/index.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var server_exports = {};
|
|
20
|
-
__export(server_exports, {
|
|
21
|
-
createServer: () => import_run.createServer,
|
|
22
|
-
createServerContext: () => import_context.createServerContext,
|
|
23
|
-
initHooks: () => import_hooks.initHooks,
|
|
24
|
-
initPluginAPI: () => import_api.initPluginAPI,
|
|
25
|
-
initServerContext: () => import_context.initServerContext,
|
|
26
|
-
server: () => import_run.server
|
|
27
|
-
});
|
|
28
|
-
module.exports = __toCommonJS(server_exports);
|
|
29
|
-
var import_api = require("./api");
|
|
30
|
-
var import_context = require("./context");
|
|
31
|
-
var import_hooks = require("./hooks");
|
|
32
|
-
var import_run = require("./run");
|
|
33
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
-
0 && (module.exports = {
|
|
35
|
-
createServer,
|
|
36
|
-
createServerContext,
|
|
37
|
-
initHooks,
|
|
38
|
-
initPluginAPI,
|
|
39
|
-
initServerContext,
|
|
40
|
-
server
|
|
41
|
-
});
|