@4399ywkf/core 4.0.61
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/README.md +3 -0
- package/compiled/dotenv/LICENSE +23 -0
- package/compiled/dotenv/index.js +1 -0
- package/compiled/dotenv/lib/main.d.ts +73 -0
- package/compiled/dotenv/package.json +1 -0
- package/compiled/dotenv/types/index.d.ts +59 -0
- package/compiled/dotenv-expand/LICENSE +24 -0
- package/compiled/dotenv-expand/index.js +1 -0
- package/compiled/dotenv-expand/lib/main.d.ts +29 -0
- package/compiled/dotenv-expand/package.json +1 -0
- package/compiled/just-diff/LICENSE +21 -0
- package/compiled/just-diff/index.d.ts +20 -0
- package/compiled/just-diff/index.js +1 -0
- package/compiled/just-diff/package.json +1 -0
- package/dist/config/config.d.ts +62 -0
- package/dist/config/config.js +240 -0
- package/dist/config/utils.d.ts +8 -0
- package/dist/config/utils.js +40 -0
- package/dist/constants.d.ts +9 -0
- package/dist/constants.js +45 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +51 -0
- package/dist/route/defineRoutes.d.ts +1 -0
- package/dist/route/defineRoutes.js +61 -0
- package/dist/route/route.d.ts +3 -0
- package/dist/route/route.js +27 -0
- package/dist/route/routeUtils.d.ts +8 -0
- package/dist/route/routeUtils.js +46 -0
- package/dist/route/routesConfig.d.ts +6 -0
- package/dist/route/routesConfig.js +125 -0
- package/dist/route/routesConvention.d.ts +5 -0
- package/dist/route/routesConvention.js +88 -0
- package/dist/route/utils.d.ts +8 -0
- package/dist/route/utils.js +59 -0
- package/dist/service/command.d.ts +30 -0
- package/dist/service/command.js +46 -0
- package/dist/service/env.d.ts +4 -0
- package/dist/service/env.js +46 -0
- package/dist/service/generatePlugin.d.ts +4 -0
- package/dist/service/generatePlugin.js +102 -0
- package/dist/service/generator.d.ts +71 -0
- package/dist/service/generator.js +40 -0
- package/dist/service/hook.d.ts +16 -0
- package/dist/service/hook.js +57 -0
- package/dist/service/path.d.ts +15 -0
- package/dist/service/path.js +55 -0
- package/dist/service/plugin.d.ts +61 -0
- package/dist/service/plugin.js +177 -0
- package/dist/service/pluginAPI.d.ts +49 -0
- package/dist/service/pluginAPI.js +237 -0
- package/dist/service/service.d.ts +147 -0
- package/dist/service/service.js +538 -0
- package/dist/service/servicePlugin.d.ts +3 -0
- package/dist/service/servicePlugin.js +37 -0
- package/dist/service/telemetry.d.ts +32 -0
- package/dist/service/telemetry.js +127 -0
- package/dist/service/utils.d.ts +2 -0
- package/dist/service/utils.js +36 -0
- package/dist/types.d.ts +116 -0
- package/dist/types.js +77 -0
- package/package.json +49 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/constants.ts
|
|
20
|
+
var constants_exports = {};
|
|
21
|
+
__export(constants_exports, {
|
|
22
|
+
DEFAULT_CONFIG_FILES: () => DEFAULT_CONFIG_FILES,
|
|
23
|
+
DEFAULT_FRAMEWORK_NAME: () => DEFAULT_FRAMEWORK_NAME,
|
|
24
|
+
LOCAL_EXT: () => LOCAL_EXT,
|
|
25
|
+
SHORT_ENV: () => SHORT_ENV,
|
|
26
|
+
WATCH_DEBOUNCE_STEP: () => WATCH_DEBOUNCE_STEP
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(constants_exports);
|
|
29
|
+
var DEFAULT_CONFIG_FILES = ["config.ts", "config.js"];
|
|
30
|
+
var SHORT_ENV = {
|
|
31
|
+
development: "dev",
|
|
32
|
+
production: "prod",
|
|
33
|
+
test: "test"
|
|
34
|
+
};
|
|
35
|
+
var LOCAL_EXT = ".local";
|
|
36
|
+
var WATCH_DEBOUNCE_STEP = 300;
|
|
37
|
+
var DEFAULT_FRAMEWORK_NAME = "umi";
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
DEFAULT_CONFIG_FILES,
|
|
41
|
+
DEFAULT_FRAMEWORK_NAME,
|
|
42
|
+
LOCAL_EXT,
|
|
43
|
+
SHORT_ENV,
|
|
44
|
+
WATCH_DEBOUNCE_STEP
|
|
45
|
+
});
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './config/config';
|
|
2
|
+
export * from './route/route';
|
|
3
|
+
export { Generator, GeneratorType } from './service/generator';
|
|
4
|
+
export * from './service/pluginAPI';
|
|
5
|
+
export * from './service/service';
|
|
6
|
+
export { Env, IAdd, IEvent, IModify, IRoute } from './types';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
Env: () => import_types.Env,
|
|
24
|
+
Generator: () => import_generator.Generator,
|
|
25
|
+
GeneratorType: () => import_generator.GeneratorType,
|
|
26
|
+
IAdd: () => import_types.IAdd,
|
|
27
|
+
IEvent: () => import_types.IEvent,
|
|
28
|
+
IModify: () => import_types.IModify,
|
|
29
|
+
IRoute: () => import_types.IRoute
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(src_exports);
|
|
32
|
+
__reExport(src_exports, require("./config/config"), module.exports);
|
|
33
|
+
__reExport(src_exports, require("./route/route"), module.exports);
|
|
34
|
+
var import_generator = require("./service/generator");
|
|
35
|
+
__reExport(src_exports, require("./service/pluginAPI"), module.exports);
|
|
36
|
+
__reExport(src_exports, require("./service/service"), module.exports);
|
|
37
|
+
var import_types = require("./types");
|
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
39
|
+
0 && (module.exports = {
|
|
40
|
+
Env,
|
|
41
|
+
Generator,
|
|
42
|
+
GeneratorType,
|
|
43
|
+
IAdd,
|
|
44
|
+
IEvent,
|
|
45
|
+
IModify,
|
|
46
|
+
IRoute,
|
|
47
|
+
...require("./config/config"),
|
|
48
|
+
...require("./route/route"),
|
|
49
|
+
...require("./service/pluginAPI"),
|
|
50
|
+
...require("./service/service")
|
|
51
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function defineRoutes(callback: (defineRoute: Function) => void): any;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/route/defineRoutes.ts
|
|
20
|
+
var defineRoutes_exports = {};
|
|
21
|
+
__export(defineRoutes_exports, {
|
|
22
|
+
defineRoutes: () => defineRoutes
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(defineRoutes_exports);
|
|
25
|
+
var import_utils = require("./utils");
|
|
26
|
+
function defineRoutes(callback) {
|
|
27
|
+
const routes = /* @__PURE__ */ Object.create(null);
|
|
28
|
+
const parentRoutes = [];
|
|
29
|
+
const defineRoute = (opts) => {
|
|
30
|
+
opts.options = opts.options || {};
|
|
31
|
+
const parentRoute = parentRoutes.length > 0 ? parentRoutes[parentRoutes.length - 1] : null;
|
|
32
|
+
const parentId = parentRoute == null ? void 0 : parentRoute.id;
|
|
33
|
+
const parentAbsPath = parentRoute == null ? void 0 : parentRoute.absPath;
|
|
34
|
+
const absPath = [parentAbsPath, opts.path].join("/");
|
|
35
|
+
const route = {
|
|
36
|
+
// 1. root index route path: '/'
|
|
37
|
+
// 2. nested children route path
|
|
38
|
+
// - dir
|
|
39
|
+
// - some.ts -> 'some'
|
|
40
|
+
// - index.ts -> ''
|
|
41
|
+
// - dir.tsx -> '/dir'
|
|
42
|
+
path: absPath === "/" ? "/" : opts.path,
|
|
43
|
+
id: (0, import_utils.createRouteId)(opts.file),
|
|
44
|
+
parentId,
|
|
45
|
+
file: opts.file,
|
|
46
|
+
absPath
|
|
47
|
+
};
|
|
48
|
+
routes[route.id] = route;
|
|
49
|
+
if (opts.children) {
|
|
50
|
+
parentRoutes.push(route);
|
|
51
|
+
opts.children();
|
|
52
|
+
parentRoutes.pop();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
callback(defineRoute);
|
|
56
|
+
return routes;
|
|
57
|
+
}
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
defineRoutes
|
|
61
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/route/route.ts
|
|
17
|
+
var route_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(route_exports);
|
|
19
|
+
__reExport(route_exports, require("./routesConfig"), module.exports);
|
|
20
|
+
__reExport(route_exports, require("./routesConvention"), module.exports);
|
|
21
|
+
__reExport(route_exports, require("./routeUtils"), module.exports);
|
|
22
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
23
|
+
0 && (module.exports = {
|
|
24
|
+
...require("./routesConfig"),
|
|
25
|
+
...require("./routesConvention"),
|
|
26
|
+
...require("./routeUtils")
|
|
27
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/route/routeUtils.ts
|
|
20
|
+
var routeUtils_exports = {};
|
|
21
|
+
__export(routeUtils_exports, {
|
|
22
|
+
addParentRoute: () => addParentRoute
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(routeUtils_exports);
|
|
25
|
+
function addParentRoute(opts) {
|
|
26
|
+
if (opts.addToAll) {
|
|
27
|
+
for (const id of Object.keys(opts.routes)) {
|
|
28
|
+
if (opts.routes[id].parentId === void 0 && (!opts.test || opts.test(opts.routes[id]))) {
|
|
29
|
+
opts.routes[id].parentId = opts.target.id;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
} else if (opts.id) {
|
|
33
|
+
if (!opts.test || opts.test(opts.routes[opts.id])) {
|
|
34
|
+
opts.routes[opts.id].parentId = opts.target.id;
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
throw new Error(
|
|
38
|
+
`addParentRoute failed, opts.addToAll or opts.id must be supplied.`
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
opts.routes[opts.target.id] = opts.target;
|
|
42
|
+
}
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
addParentRoute
|
|
46
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/route/routesConfig.ts
|
|
30
|
+
var routesConfig_exports = {};
|
|
31
|
+
__export(routesConfig_exports, {
|
|
32
|
+
getConfigRoutes: () => getConfigRoutes
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(routesConfig_exports);
|
|
35
|
+
var import_assert = __toESM(require("assert"));
|
|
36
|
+
function getConfigRoutes(opts) {
|
|
37
|
+
const memo = { ret: {}, id: 1 };
|
|
38
|
+
transformRoutes({
|
|
39
|
+
routes: opts.routes,
|
|
40
|
+
parentId: void 0,
|
|
41
|
+
memo,
|
|
42
|
+
onResolveComponent: opts.onResolveComponent
|
|
43
|
+
});
|
|
44
|
+
return memo.ret;
|
|
45
|
+
}
|
|
46
|
+
function transformRoutes(opts) {
|
|
47
|
+
opts.routes.forEach((route) => {
|
|
48
|
+
transformRoute({
|
|
49
|
+
route,
|
|
50
|
+
parentId: opts.parentId,
|
|
51
|
+
memo: opts.memo,
|
|
52
|
+
onResolveComponent: opts.onResolveComponent
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function transformRoute(opts) {
|
|
57
|
+
(0, import_assert.default)(
|
|
58
|
+
!opts.route.children,
|
|
59
|
+
"children is not allowed in route props, use routes instead."
|
|
60
|
+
);
|
|
61
|
+
const id = String(opts.memo.id++);
|
|
62
|
+
const { routes, component, wrappers, ...routeProps } = opts.route;
|
|
63
|
+
let absPath = opts.route.path;
|
|
64
|
+
if ((absPath == null ? void 0 : absPath.charAt(0)) !== "/") {
|
|
65
|
+
const parentAbsPath = opts.parentId ? opts.memo.ret[opts.parentId].absPath.replace(/\/+$/, "/") : "/";
|
|
66
|
+
absPath = endsWithStar(parentAbsPath) ? parentAbsPath : ensureWithSlash(parentAbsPath, absPath);
|
|
67
|
+
}
|
|
68
|
+
opts.memo.ret[id] = {
|
|
69
|
+
...routeProps,
|
|
70
|
+
path: opts.route.path,
|
|
71
|
+
...component ? {
|
|
72
|
+
file: opts.onResolveComponent ? opts.onResolveComponent(component) : component
|
|
73
|
+
} : {},
|
|
74
|
+
parentId: opts.parentId,
|
|
75
|
+
id
|
|
76
|
+
};
|
|
77
|
+
if (absPath) {
|
|
78
|
+
opts.memo.ret[id].absPath = absPath;
|
|
79
|
+
}
|
|
80
|
+
if (wrappers == null ? void 0 : wrappers.length) {
|
|
81
|
+
let parentId = opts.parentId;
|
|
82
|
+
let path = opts.route.path;
|
|
83
|
+
let layout = opts.route.layout;
|
|
84
|
+
wrappers.forEach((wrapper) => {
|
|
85
|
+
const { id: id2 } = transformRoute({
|
|
86
|
+
route: {
|
|
87
|
+
path,
|
|
88
|
+
component: wrapper,
|
|
89
|
+
isWrapper: true,
|
|
90
|
+
...layout === false ? { layout: false } : {}
|
|
91
|
+
},
|
|
92
|
+
parentId,
|
|
93
|
+
memo: opts.memo,
|
|
94
|
+
onResolveComponent: opts.onResolveComponent
|
|
95
|
+
});
|
|
96
|
+
parentId = id2;
|
|
97
|
+
path = endsWithStar(path) ? "*" : "";
|
|
98
|
+
});
|
|
99
|
+
opts.memo.ret[id].parentId = parentId;
|
|
100
|
+
opts.memo.ret[id].path = path;
|
|
101
|
+
opts.memo.ret[id].originPath = opts.route.path;
|
|
102
|
+
}
|
|
103
|
+
if (opts.route.routes) {
|
|
104
|
+
transformRoutes({
|
|
105
|
+
routes: opts.route.routes,
|
|
106
|
+
parentId: id,
|
|
107
|
+
memo: opts.memo,
|
|
108
|
+
onResolveComponent: opts.onResolveComponent
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return { id };
|
|
112
|
+
}
|
|
113
|
+
function endsWithStar(str) {
|
|
114
|
+
return str.endsWith("*");
|
|
115
|
+
}
|
|
116
|
+
function ensureWithSlash(left, right) {
|
|
117
|
+
if (!(right == null ? void 0 : right.length) || right === "/") {
|
|
118
|
+
return left;
|
|
119
|
+
}
|
|
120
|
+
return `${left.replace(/\/+$/, "")}/${right.replace(/^\/+/, "")}`;
|
|
121
|
+
}
|
|
122
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
123
|
+
0 && (module.exports = {
|
|
124
|
+
getConfigRoutes
|
|
125
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/route/routesConvention.ts
|
|
20
|
+
var routesConvention_exports = {};
|
|
21
|
+
__export(routesConvention_exports, {
|
|
22
|
+
getConventionRoutes: () => getConventionRoutes
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(routesConvention_exports);
|
|
25
|
+
var import_utils = require("@4399ywkf/utils");
|
|
26
|
+
var import_fs = require("fs");
|
|
27
|
+
var import_path = require("path");
|
|
28
|
+
var import_defineRoutes = require("./defineRoutes");
|
|
29
|
+
var import_utils2 = require("./utils");
|
|
30
|
+
function getConventionRoutes(opts) {
|
|
31
|
+
const files = {};
|
|
32
|
+
if (!((0, import_fs.existsSync)(opts.base) && (0, import_fs.statSync)(opts.base).isDirectory())) {
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
visitFiles({
|
|
36
|
+
dir: opts.base,
|
|
37
|
+
visitor: (file) => {
|
|
38
|
+
const routeId = (0, import_utils2.createRouteId)(file);
|
|
39
|
+
if ((0, import_utils2.isRouteModuleFile)({ file: (0, import_utils.winPath)(file), exclude: opts.exclude })) {
|
|
40
|
+
files[routeId] = (0, import_utils.winPath)(file);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const routeIds = Object.keys(files).sort(import_utils2.byLongestFirst);
|
|
45
|
+
function defineNestedRoutes(defineRoute, parentId) {
|
|
46
|
+
const childRouteIds = routeIds.filter(
|
|
47
|
+
(id) => (0, import_utils2.findParentRouteId)(routeIds, id) === parentId
|
|
48
|
+
);
|
|
49
|
+
for (let routeId of childRouteIds) {
|
|
50
|
+
let routePath = createRoutePath(
|
|
51
|
+
parentId ? routeId.slice(parentId.length + 1) : routeId
|
|
52
|
+
);
|
|
53
|
+
defineRoute({
|
|
54
|
+
path: routePath,
|
|
55
|
+
file: `${opts.prefix || ""}${files[routeId]}`,
|
|
56
|
+
children() {
|
|
57
|
+
defineNestedRoutes(defineRoute, routeId);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return (0, import_defineRoutes.defineRoutes)(defineNestedRoutes);
|
|
63
|
+
}
|
|
64
|
+
function visitFiles(opts) {
|
|
65
|
+
opts.baseDir = opts.baseDir || opts.dir;
|
|
66
|
+
for (let filename of (0, import_fs.readdirSync)(opts.dir)) {
|
|
67
|
+
let file = (0, import_path.resolve)(opts.dir, filename);
|
|
68
|
+
let stat = (0, import_fs.lstatSync)(file);
|
|
69
|
+
if (stat.isDirectory()) {
|
|
70
|
+
visitFiles({ ...opts, dir: file });
|
|
71
|
+
} else if (stat.isFile() && [".tsx", ".ts", ".js", ".jsx", ".md", ".mdx", ".vue"].includes(
|
|
72
|
+
(0, import_path.extname)(file)
|
|
73
|
+
)) {
|
|
74
|
+
opts.visitor((0, import_path.relative)(opts.baseDir, file));
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function createRoutePath(routeId) {
|
|
79
|
+
let path = routeId.replace(/^\$$/, "*").replace(/(\/|\.)\$$/, "/*").replace(/\$/g, ":").replace(/\./g, "/");
|
|
80
|
+
path = /(^|\/)index\/index$/.test(path) ? path.replace(/\/index$/, "") : path;
|
|
81
|
+
path = /\b\/?(?<!:)index$/.test(path) ? path.replace(/\/?index$/, "") : path;
|
|
82
|
+
path = /\b\/?README$/.test(path) ? path.replace(/\/?README$/, "") : path;
|
|
83
|
+
return path;
|
|
84
|
+
}
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {
|
|
87
|
+
getConventionRoutes
|
|
88
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function createRouteId(file: string): string;
|
|
2
|
+
export declare function stripFileExtension(file: string): string;
|
|
3
|
+
export declare function byLongestFirst(a: string, b: string): number;
|
|
4
|
+
export declare function findParentRouteId(routeIds: string[], childRouteId: string): string | undefined;
|
|
5
|
+
export declare function isRouteModuleFile(opts: {
|
|
6
|
+
file: string;
|
|
7
|
+
exclude?: RegExp[];
|
|
8
|
+
}): boolean;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/route/utils.ts
|
|
20
|
+
var utils_exports = {};
|
|
21
|
+
__export(utils_exports, {
|
|
22
|
+
byLongestFirst: () => byLongestFirst,
|
|
23
|
+
createRouteId: () => createRouteId,
|
|
24
|
+
findParentRouteId: () => findParentRouteId,
|
|
25
|
+
isRouteModuleFile: () => isRouteModuleFile,
|
|
26
|
+
stripFileExtension: () => stripFileExtension
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(utils_exports);
|
|
29
|
+
var import_utils = require("@4399ywkf/utils");
|
|
30
|
+
var import_path = require("path");
|
|
31
|
+
function createRouteId(file) {
|
|
32
|
+
return (0, import_utils.winPath)(stripFileExtension(file));
|
|
33
|
+
}
|
|
34
|
+
function stripFileExtension(file) {
|
|
35
|
+
return file.replace(/\.[a-z0-9]+$/i, "");
|
|
36
|
+
}
|
|
37
|
+
function byLongestFirst(a, b) {
|
|
38
|
+
return b.length - a.length;
|
|
39
|
+
}
|
|
40
|
+
function findParentRouteId(routeIds, childRouteId) {
|
|
41
|
+
return routeIds.find((id) => childRouteId.startsWith(`${id}/`));
|
|
42
|
+
}
|
|
43
|
+
var routeModuleExts = [".js", ".jsx", ".ts", ".tsx", ".md", ".mdx", ".vue"];
|
|
44
|
+
function isRouteModuleFile(opts) {
|
|
45
|
+
for (const excludeRegExp of opts.exclude || []) {
|
|
46
|
+
if (opts.file && excludeRegExp instanceof RegExp && excludeRegExp.test(opts.file)) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return routeModuleExts.includes((0, import_path.extname)(opts.file));
|
|
51
|
+
}
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
byLongestFirst,
|
|
55
|
+
createRouteId,
|
|
56
|
+
findParentRouteId,
|
|
57
|
+
isRouteModuleFile,
|
|
58
|
+
stripFileExtension
|
|
59
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { yParser } from '@4399ywkf/utils';
|
|
2
|
+
import { Plugin } from './plugin';
|
|
3
|
+
import { ResolveConfigMode } from './pluginAPI';
|
|
4
|
+
export interface IOpts {
|
|
5
|
+
name: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
options?: string;
|
|
8
|
+
details?: string;
|
|
9
|
+
fn: {
|
|
10
|
+
({ args }: {
|
|
11
|
+
args: yParser.Arguments;
|
|
12
|
+
}): void;
|
|
13
|
+
};
|
|
14
|
+
plugin: Plugin;
|
|
15
|
+
configResolveMode?: ResolveConfigMode;
|
|
16
|
+
}
|
|
17
|
+
export declare class Command {
|
|
18
|
+
name: string;
|
|
19
|
+
description?: string;
|
|
20
|
+
options?: string;
|
|
21
|
+
details?: string;
|
|
22
|
+
configResolveMode: ResolveConfigMode;
|
|
23
|
+
fn: {
|
|
24
|
+
({ args }: {
|
|
25
|
+
args: yParser.Arguments;
|
|
26
|
+
}): void;
|
|
27
|
+
};
|
|
28
|
+
plugin: Plugin;
|
|
29
|
+
constructor(opts: IOpts);
|
|
30
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/service/command.ts
|
|
20
|
+
var command_exports = {};
|
|
21
|
+
__export(command_exports, {
|
|
22
|
+
Command: () => Command
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(command_exports);
|
|
25
|
+
var Command = class {
|
|
26
|
+
name;
|
|
27
|
+
description;
|
|
28
|
+
options;
|
|
29
|
+
details;
|
|
30
|
+
configResolveMode;
|
|
31
|
+
fn;
|
|
32
|
+
plugin;
|
|
33
|
+
constructor(opts) {
|
|
34
|
+
this.name = opts.name;
|
|
35
|
+
this.description = opts.description;
|
|
36
|
+
this.options = opts.options;
|
|
37
|
+
this.details = opts.details;
|
|
38
|
+
this.fn = opts.fn;
|
|
39
|
+
this.plugin = opts.plugin;
|
|
40
|
+
this.configResolveMode = opts.configResolveMode || "strict";
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
44
|
+
0 && (module.exports = {
|
|
45
|
+
Command
|
|
46
|
+
});
|