@modern-js/bff-core 2.69.5 → 3.0.0-alpha.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/dist/cjs/api.js +82 -78
- package/dist/cjs/client/generateClient.js +90 -76
- package/dist/cjs/client/index.js +55 -19
- package/dist/cjs/client/result.js +51 -42
- package/dist/cjs/compatible.js +17 -15
- package/dist/cjs/errors/http.js +43 -34
- package/dist/cjs/index.js +169 -54
- package/dist/cjs/operators/http.js +213 -212
- package/dist/cjs/router/constants.js +63 -57
- package/dist/cjs/router/index.js +271 -291
- package/dist/cjs/router/types.js +17 -15
- package/dist/cjs/router/utils.js +90 -92
- package/dist/cjs/types.js +84 -71
- package/dist/cjs/utils/alias.js +100 -103
- package/dist/cjs/utils/debug.js +34 -26
- package/dist/cjs/utils/index.js +98 -34
- package/dist/cjs/utils/meta.js +45 -38
- package/dist/cjs/utils/storage.js +58 -68
- package/dist/cjs/utils/validate.js +73 -72
- package/dist/esm/api.mjs +44 -0
- package/dist/esm/client/generateClient.mjs +60 -0
- package/dist/esm/client/result.mjs +19 -0
- package/dist/esm/compatible.mjs +0 -0
- package/dist/esm/errors/http.mjs +13 -0
- package/dist/esm/index.mjs +8 -0
- package/dist/esm/operators/http.mjs +135 -0
- package/dist/esm/router/constants.mjs +19 -0
- package/dist/esm/router/index.mjs +186 -0
- package/dist/esm/router/types.mjs +0 -0
- package/dist/esm/router/utils.mjs +42 -0
- package/dist/esm/types.mjs +39 -0
- package/dist/esm/utils/alias.mjs +57 -0
- package/dist/esm/utils/debug.mjs +3 -0
- package/dist/esm/utils/{index.js → index.mjs} +2 -4
- package/dist/esm/utils/meta.mjs +5 -0
- package/dist/esm/utils/storage.mjs +30 -0
- package/dist/esm/utils/validate.mjs +32 -0
- package/dist/esm-node/api.mjs +44 -0
- package/dist/esm-node/client/generateClient.mjs +60 -0
- package/dist/esm-node/client/index.mjs +1 -0
- package/dist/esm-node/client/result.mjs +19 -0
- package/dist/esm-node/errors/http.mjs +13 -0
- package/dist/esm-node/index.mjs +8 -0
- package/dist/esm-node/operators/http.mjs +135 -0
- package/dist/esm-node/router/constants.mjs +19 -0
- package/dist/esm-node/router/index.mjs +186 -0
- package/dist/esm-node/router/utils.mjs +42 -0
- package/dist/esm-node/types.mjs +39 -0
- package/dist/esm-node/utils/alias.mjs +57 -0
- package/dist/esm-node/utils/debug.mjs +3 -0
- package/dist/esm-node/utils/index.mjs +6 -0
- package/dist/esm-node/utils/meta.mjs +5 -0
- package/dist/esm-node/utils/storage.mjs +30 -0
- package/dist/esm-node/utils/validate.mjs +32 -0
- package/dist/types/client/generateClient.d.ts +1 -1
- package/dist/types/router/constants.d.ts +0 -10
- package/dist/types/router/index.d.ts +0 -5
- package/package.json +18 -18
- package/rslib.config.mts +4 -0
- package/dist/esm/api.js +0 -50
- package/dist/esm/client/generateClient.js +0 -60
- package/dist/esm/client/result.js +0 -22
- package/dist/esm/errors/http.js +0 -16
- package/dist/esm/index.js +0 -19
- package/dist/esm/operators/http.js +0 -178
- package/dist/esm/router/constants.js +0 -32
- package/dist/esm/router/index.js +0 -261
- package/dist/esm/router/utils.js +0 -62
- package/dist/esm/types.js +0 -46
- package/dist/esm/utils/alias.js +0 -75
- package/dist/esm/utils/debug.js +0 -5
- package/dist/esm/utils/meta.js +0 -14
- package/dist/esm/utils/storage.js +0 -40
- package/dist/esm/utils/validate.js +0 -45
- /package/dist/esm/client/{index.js → index.mjs} +0 -0
- /package/dist/{esm/compatible.js → esm-node/compatible.mjs} +0 -0
- /package/dist/{esm/router/types.js → esm-node/router/types.mjs} +0 -0
package/dist/cjs/router/utils.js
CHANGED
|
@@ -1,100 +1,98 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
getPathFromFilename: ()=>getPathFromFilename,
|
|
37
|
+
isHandler: ()=>isHandler,
|
|
38
|
+
sortRoutes: ()=>sortRoutes,
|
|
39
|
+
getFiles: ()=>getFiles,
|
|
40
|
+
requireHandlerModule: ()=>requireHandlerModule
|
|
36
41
|
});
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const getFiles = (lambdaDir, rules)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}).map((file)
|
|
45
|
-
const getPathFromFilename = (baseDir, filename)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const finalName = name.endsWith(import_constants.INDEX_SUFFIX) ? name.substring(0, name.length - import_constants.INDEX_SUFFIX.length) : name;
|
|
58
|
-
return clearRouteName(finalName);
|
|
42
|
+
const external_path_namespaceObject = require("path");
|
|
43
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
44
|
+
const utils_namespaceObject = require("@modern-js/utils");
|
|
45
|
+
const external_constants_js_namespaceObject = require("./constants.js");
|
|
46
|
+
const getFiles = (lambdaDir, rules)=>utils_namespaceObject.globby.sync(rules, {
|
|
47
|
+
cwd: lambdaDir,
|
|
48
|
+
gitignore: true
|
|
49
|
+
}).map((file)=>external_path_default().resolve(lambdaDir, file));
|
|
50
|
+
const getPathFromFilename = (baseDir, filename)=>{
|
|
51
|
+
const relativeName = filename.substring(baseDir.length);
|
|
52
|
+
const relativePath = relativeName.split('.').slice(0, -1).join('.');
|
|
53
|
+
const nameSplit = relativePath.split(external_path_default().sep).map((item)=>{
|
|
54
|
+
if (item.length > 2) {
|
|
55
|
+
if (item.startsWith('[') && item.endsWith(']')) return `:${item.substring(1, item.length - 1)}`;
|
|
56
|
+
}
|
|
57
|
+
return item;
|
|
58
|
+
});
|
|
59
|
+
const name = nameSplit.join('/');
|
|
60
|
+
const finalName = name.endsWith(external_constants_js_namespaceObject.INDEX_SUFFIX) ? name.substring(0, name.length - external_constants_js_namespaceObject.INDEX_SUFFIX.length) : name;
|
|
61
|
+
return clearRouteName(finalName);
|
|
59
62
|
};
|
|
60
|
-
const clearRouteName = (routeName)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
finalRouteName =
|
|
64
|
-
|
|
65
|
-
if (finalRouteName.length > 1 && finalRouteName.endsWith("/")) {
|
|
66
|
-
finalRouteName = finalRouteName.substring(0, finalRouteName.length - 1);
|
|
67
|
-
}
|
|
68
|
-
return finalRouteName;
|
|
63
|
+
const clearRouteName = (routeName)=>{
|
|
64
|
+
let finalRouteName = routeName.trim();
|
|
65
|
+
if (!finalRouteName.startsWith('/')) finalRouteName = `/${finalRouteName}`;
|
|
66
|
+
if (finalRouteName.length > 1 && finalRouteName.endsWith('/')) finalRouteName = finalRouteName.substring(0, finalRouteName.length - 1);
|
|
67
|
+
return finalRouteName;
|
|
69
68
|
};
|
|
70
|
-
const isHandler = (input)
|
|
71
|
-
const isFunction = (input)
|
|
72
|
-
const requireHandlerModule = async (modulePath)
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
default: module2
|
|
69
|
+
const isHandler = (input)=>input && 'function' == typeof input;
|
|
70
|
+
const isFunction = (input)=>input && '[object Function]' === ({}).toString.call(input);
|
|
71
|
+
const requireHandlerModule = async (modulePath)=>{
|
|
72
|
+
const originRequire = 'test' === process.env.NODE_ENV ? jest.requireActual : utils_namespaceObject.compatibleRequire;
|
|
73
|
+
const module = await originRequire(modulePath, false);
|
|
74
|
+
if (isFunction(module)) return {
|
|
75
|
+
default: module
|
|
78
76
|
};
|
|
79
|
-
|
|
80
|
-
return module2;
|
|
81
|
-
};
|
|
82
|
-
const routeValue = (routePath) => {
|
|
83
|
-
if (routePath.includes(":")) {
|
|
84
|
-
return 11;
|
|
85
|
-
}
|
|
86
|
-
return 1;
|
|
77
|
+
return module;
|
|
87
78
|
};
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
return
|
|
91
|
-
});
|
|
79
|
+
const routeValue = (routePath)=>{
|
|
80
|
+
if (routePath.includes(':')) return 11;
|
|
81
|
+
return 1;
|
|
92
82
|
};
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
83
|
+
const sortRoutes = (apiHandlers)=>apiHandlers.sort((handlerA, handlerB)=>routeValue(handlerA.routeName) - routeValue(handlerB.routeName));
|
|
84
|
+
exports.getFiles = __webpack_exports__.getFiles;
|
|
85
|
+
exports.getPathFromFilename = __webpack_exports__.getPathFromFilename;
|
|
86
|
+
exports.isHandler = __webpack_exports__.isHandler;
|
|
87
|
+
exports.requireHandlerModule = __webpack_exports__.requireHandlerModule;
|
|
88
|
+
exports.sortRoutes = __webpack_exports__.sortRoutes;
|
|
89
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
90
|
+
"getFiles",
|
|
91
|
+
"getPathFromFilename",
|
|
92
|
+
"isHandler",
|
|
93
|
+
"requireHandlerModule",
|
|
94
|
+
"sortRoutes"
|
|
95
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
96
|
+
Object.defineProperty(exports, '__esModule', {
|
|
97
|
+
value: true
|
|
100
98
|
});
|
package/dist/cjs/types.js
CHANGED
|
@@ -1,75 +1,88 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
HttpMetadata: ()=>HttpMetadata,
|
|
28
|
+
HttpMethod: ()=>HttpMethod,
|
|
29
|
+
OperatorType: ()=>OperatorType,
|
|
30
|
+
ResponseMetaType: ()=>ResponseMetaType,
|
|
31
|
+
TriggerType: ()=>TriggerType,
|
|
32
|
+
httpMethods: ()=>httpMethods
|
|
27
33
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
})(HttpMethod || (HttpMethod = {}));
|
|
34
|
+
var OperatorType = /*#__PURE__*/ function(OperatorType) {
|
|
35
|
+
OperatorType[OperatorType["Trigger"] = 0] = "Trigger";
|
|
36
|
+
OperatorType[OperatorType["Middleware"] = 1] = "Middleware";
|
|
37
|
+
return OperatorType;
|
|
38
|
+
}({});
|
|
39
|
+
var TriggerType = /*#__PURE__*/ function(TriggerType) {
|
|
40
|
+
TriggerType[TriggerType["Http"] = 0] = "Http";
|
|
41
|
+
return TriggerType;
|
|
42
|
+
}({});
|
|
43
|
+
var HttpMetadata = /*#__PURE__*/ function(HttpMetadata) {
|
|
44
|
+
HttpMetadata["Method"] = "METHOD";
|
|
45
|
+
HttpMetadata["Data"] = "DATA";
|
|
46
|
+
HttpMetadata["Query"] = "QUERY";
|
|
47
|
+
HttpMetadata["Params"] = "PARAMS";
|
|
48
|
+
HttpMetadata["Headers"] = "HEADERS";
|
|
49
|
+
HttpMetadata["Response"] = "RESPONSE";
|
|
50
|
+
HttpMetadata["Files"] = "Files";
|
|
51
|
+
return HttpMetadata;
|
|
52
|
+
}({});
|
|
53
|
+
var ResponseMetaType = /*#__PURE__*/ function(ResponseMetaType) {
|
|
54
|
+
ResponseMetaType[ResponseMetaType["StatusCode"] = 0] = "StatusCode";
|
|
55
|
+
ResponseMetaType[ResponseMetaType["Redirect"] = 1] = "Redirect";
|
|
56
|
+
ResponseMetaType[ResponseMetaType["Headers"] = 2] = "Headers";
|
|
57
|
+
return ResponseMetaType;
|
|
58
|
+
}({});
|
|
59
|
+
var HttpMethod = /*#__PURE__*/ function(HttpMethod) {
|
|
60
|
+
HttpMethod["Get"] = "GET";
|
|
61
|
+
HttpMethod["Post"] = "POST";
|
|
62
|
+
HttpMethod["Put"] = "PUT";
|
|
63
|
+
HttpMethod["Delete"] = "DELETE";
|
|
64
|
+
HttpMethod["Connect"] = "CONNECT";
|
|
65
|
+
HttpMethod["Trace"] = "TRACE";
|
|
66
|
+
HttpMethod["Patch"] = "PATCH";
|
|
67
|
+
HttpMethod["Options"] = "OPTIONS";
|
|
68
|
+
HttpMethod["Head"] = "HEAD";
|
|
69
|
+
return HttpMethod;
|
|
70
|
+
}({});
|
|
66
71
|
const httpMethods = Object.values(HttpMethod);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
exports.HttpMetadata = __webpack_exports__.HttpMetadata;
|
|
73
|
+
exports.HttpMethod = __webpack_exports__.HttpMethod;
|
|
74
|
+
exports.OperatorType = __webpack_exports__.OperatorType;
|
|
75
|
+
exports.ResponseMetaType = __webpack_exports__.ResponseMetaType;
|
|
76
|
+
exports.TriggerType = __webpack_exports__.TriggerType;
|
|
77
|
+
exports.httpMethods = __webpack_exports__.httpMethods;
|
|
78
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
79
|
+
"HttpMetadata",
|
|
80
|
+
"HttpMethod",
|
|
81
|
+
"OperatorType",
|
|
82
|
+
"ResponseMetaType",
|
|
83
|
+
"TriggerType",
|
|
84
|
+
"httpMethods"
|
|
85
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
86
|
+
Object.defineProperty(exports, '__esModule', {
|
|
87
|
+
value: true
|
|
75
88
|
});
|
package/dist/cjs/utils/alias.js
CHANGED
|
@@ -1,111 +1,108 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
getRelativeRuntimePath: ()=>getRelativeRuntimePath,
|
|
37
|
+
createMatchPath: ()=>createMatchPath,
|
|
38
|
+
registerPaths: ()=>registerPaths
|
|
34
39
|
});
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
relativeRuntimePath = `../${
|
|
44
|
-
|
|
45
|
-
relativeRuntimePath
|
|
46
|
-
}
|
|
47
|
-
if (process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test") {
|
|
48
|
-
relativeRuntimePath = `./${path.relative(appDirectory, serverRuntimePath)}`;
|
|
49
|
-
}
|
|
50
|
-
return relativeRuntimePath;
|
|
40
|
+
const external_fs_namespaceObject = require("fs");
|
|
41
|
+
var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
|
|
42
|
+
const external_module_namespaceObject = require("module");
|
|
43
|
+
var external_module_default = /*#__PURE__*/ __webpack_require__.n(external_module_namespaceObject);
|
|
44
|
+
const external_os_namespaceObject = require("os");
|
|
45
|
+
const external_path_namespaceObject = require("path");
|
|
46
|
+
const getRelativeRuntimePath = (appDirectory, serverRuntimePath)=>{
|
|
47
|
+
let relativeRuntimePath = '';
|
|
48
|
+
relativeRuntimePath = 'win32' === external_os_namespaceObject.platform() ? `../${external_path_namespaceObject.relative(appDirectory, serverRuntimePath)}` : external_path_namespaceObject.join('../', external_path_namespaceObject.relative(appDirectory, serverRuntimePath));
|
|
49
|
+
if ('development' === process.env.NODE_ENV || 'test' === process.env.NODE_ENV) relativeRuntimePath = `./${external_path_namespaceObject.relative(appDirectory, serverRuntimePath)}`;
|
|
50
|
+
return relativeRuntimePath;
|
|
51
51
|
};
|
|
52
|
-
const sortByLongestPrefix = (arr) =>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
sortedKeys.forEach((key) => {
|
|
59
|
-
sortedPaths[key] = paths[key];
|
|
60
|
-
});
|
|
61
|
-
return (request) => {
|
|
62
|
-
const found = Object.keys(sortedPaths).find((key) => {
|
|
63
|
-
return request.startsWith(key);
|
|
52
|
+
const sortByLongestPrefix = (arr)=>arr.concat().sort((a, b)=>b.length - a.length);
|
|
53
|
+
const createMatchPath = (paths)=>{
|
|
54
|
+
const sortedKeys = sortByLongestPrefix(Object.keys(paths));
|
|
55
|
+
const sortedPaths = {};
|
|
56
|
+
sortedKeys.forEach((key)=>{
|
|
57
|
+
sortedPaths[key] = paths[key];
|
|
64
58
|
});
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
59
|
+
return (request)=>{
|
|
60
|
+
const found = Object.keys(sortedPaths).find((key)=>request.startsWith(key));
|
|
61
|
+
if (found) {
|
|
62
|
+
let foundPaths = sortedPaths[found];
|
|
63
|
+
if (!Array.isArray(foundPaths)) foundPaths = [
|
|
64
|
+
foundPaths
|
|
65
|
+
];
|
|
66
|
+
foundPaths = foundPaths.filter((foundPath)=>external_path_namespaceObject.isAbsolute(foundPath));
|
|
67
|
+
for (const p of foundPaths){
|
|
68
|
+
const foundPath = request.replace(found, p);
|
|
69
|
+
if (external_fs_default().existsSync(foundPath)) return foundPath;
|
|
70
|
+
}
|
|
71
|
+
return request.replace(found, foundPaths[0]);
|
|
77
72
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
return null;
|
|
82
|
-
};
|
|
73
|
+
return null;
|
|
74
|
+
};
|
|
83
75
|
};
|
|
84
|
-
const registerPaths = (paths)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
76
|
+
const registerPaths = (paths)=>{
|
|
77
|
+
const originalResolveFilename = external_module_default()._resolveFilename;
|
|
78
|
+
const { builtinModules } = external_module_default();
|
|
79
|
+
const matchPath = createMatchPath(paths);
|
|
80
|
+
external_module_default()._resolveFilename = function(request, _parent) {
|
|
81
|
+
const isCoreModule = builtinModules.includes(request);
|
|
82
|
+
if (!isCoreModule) {
|
|
83
|
+
const matched = matchPath(request);
|
|
84
|
+
if (matched) {
|
|
85
|
+
const modifiedArguments = [
|
|
86
|
+
matched,
|
|
87
|
+
...[].slice.call(arguments, 1)
|
|
88
|
+
];
|
|
89
|
+
return originalResolveFilename.apply(this, modifiedArguments);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return originalResolveFilename.apply(this, arguments);
|
|
93
|
+
};
|
|
94
|
+
return ()=>{
|
|
95
|
+
external_module_default()._resolveFilename = originalResolveFilename;
|
|
96
|
+
};
|
|
105
97
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
98
|
+
exports.createMatchPath = __webpack_exports__.createMatchPath;
|
|
99
|
+
exports.getRelativeRuntimePath = __webpack_exports__.getRelativeRuntimePath;
|
|
100
|
+
exports.registerPaths = __webpack_exports__.registerPaths;
|
|
101
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
102
|
+
"createMatchPath",
|
|
103
|
+
"getRelativeRuntimePath",
|
|
104
|
+
"registerPaths"
|
|
105
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
106
|
+
Object.defineProperty(exports, '__esModule', {
|
|
107
|
+
value: true
|
|
111
108
|
});
|
package/dist/cjs/utils/debug.js
CHANGED
|
@@ -1,29 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
debug: ()=>debug
|
|
22
28
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
const utils_namespaceObject = require("@modern-js/utils");
|
|
30
|
+
const debug = (0, utils_namespaceObject.createDebugger)('bff');
|
|
31
|
+
exports.debug = __webpack_exports__.debug;
|
|
32
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
33
|
+
"debug"
|
|
34
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
35
|
+
Object.defineProperty(exports, '__esModule', {
|
|
36
|
+
value: true
|
|
29
37
|
});
|