@l-comedy/core 0.1.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/bin/lcomedy.js +1 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +34 -0
- package/dist/plugins/app-config/createLComedyPluginAppConfig.d.ts +8 -0
- package/dist/plugins/app-config/createLComedyPluginAppConfig.js +161 -0
- package/dist/plugins/app-config/index.d.ts +5 -0
- package/dist/plugins/app-config/index.js +159 -0
- package/dist/plugins/html/createHtmlFile.d.ts +8 -0
- package/dist/plugins/html/createHtmlFile.js +61 -0
- package/dist/plugins/html/createLComedyPluginHtml.d.ts +8 -0
- package/dist/plugins/html/createLComedyPluginHtml.js +147 -0
- package/dist/plugins/html/createTemplateParameters.d.ts +12 -0
- package/dist/plugins/html/createTemplateParameters.js +39 -0
- package/dist/plugins/html/index.d.ts +5 -0
- package/dist/plugins/html/index.js +145 -0
- package/dist/plugins/layout/createLComedyPluginLayout.d.ts +8 -0
- package/dist/plugins/layout/createLComedyPluginLayout.js +69 -0
- package/dist/plugins/layout/index.d.ts +5 -0
- package/dist/plugins/layout/index.js +67 -0
- package/dist/plugins/page-loading/createLComedyPluginPageLoading.d.ts +8 -0
- package/dist/plugins/page-loading/createLComedyPluginPageLoading.js +67 -0
- package/dist/plugins/page-loading/index.d.ts +5 -0
- package/dist/plugins/page-loading/index.js +65 -0
- package/dist/plugins/route/createLComedyPluginRoute.d.ts +8 -0
- package/dist/plugins/route/createLComedyPluginRoute.js +118 -0
- package/dist/plugins/route/index.d.ts +5 -0
- package/dist/plugins/route/index.js +116 -0
- package/dist/plugins/types.d-gldCJl0t.d.ts +83 -0
- package/dist/run.d.ts +2 -0
- package/dist/run.js +634 -0
- package/package.json +66 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var __async = (__this, __arguments, generator) => {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
var fulfilled = (value) => {
|
|
32
|
+
try {
|
|
33
|
+
step(generator.next(value));
|
|
34
|
+
} catch (e) {
|
|
35
|
+
reject(e);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var rejected = (value) => {
|
|
39
|
+
try {
|
|
40
|
+
step(generator.throw(value));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
46
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/plugins/route/index.ts
|
|
51
|
+
var route_exports = {};
|
|
52
|
+
__export(route_exports, {
|
|
53
|
+
default: () => createLComedyPluginRoute
|
|
54
|
+
});
|
|
55
|
+
module.exports = __toCommonJS(route_exports);
|
|
56
|
+
|
|
57
|
+
// src/plugins/route/createLComedyPluginRoute.ts
|
|
58
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
59
|
+
var import_path = __toESM(require("path"));
|
|
60
|
+
function createLComedyPluginRoute() {
|
|
61
|
+
let componentIndex = 0;
|
|
62
|
+
return {
|
|
63
|
+
name: "l-comedy-plugin-route",
|
|
64
|
+
generateFiles(setupConfig) {
|
|
65
|
+
return __async(this, null, function* () {
|
|
66
|
+
var _a2;
|
|
67
|
+
componentIndex = 0;
|
|
68
|
+
const routes = ((_a2 = setupConfig.userConfig.route) == null ? void 0 : _a2.routes) || [];
|
|
69
|
+
const importsCode = [];
|
|
70
|
+
const computeRoutesCode = (routes2) => {
|
|
71
|
+
return ` ${routes2.map((route) => {
|
|
72
|
+
++componentIndex;
|
|
73
|
+
importsCode.push(
|
|
74
|
+
route.lazy ? `const Component${componentIndex} = lazy(() => import('${route.component}'))` : `import Component${componentIndex} from '${route.component}'`
|
|
75
|
+
);
|
|
76
|
+
return `<Route path="${route.path}" element={<Component${componentIndex} />}${route.index ? " index" : ""}${route.children ? `>
|
|
77
|
+
${computeRoutesCode(route.children)}
|
|
78
|
+
</Route>` : " />"}`;
|
|
79
|
+
}).join("\n")}`;
|
|
80
|
+
};
|
|
81
|
+
let routesCode = `<Routes>
|
|
82
|
+
${computeRoutesCode(routes)}
|
|
83
|
+
</Routes>`;
|
|
84
|
+
import_fs_extra.default.outputFileSync(
|
|
85
|
+
import_path.default.posix.join(setupConfig.workDir, "runtimes", "route/AppRoutes.tsx"),
|
|
86
|
+
`import { lazy } from 'react'
|
|
87
|
+
import { Routes, Route } from 'react-router'
|
|
88
|
+
${importsCode.join("\n")}
|
|
89
|
+
|
|
90
|
+
export default function AppRoutes() {
|
|
91
|
+
return (
|
|
92
|
+
${routesCode}
|
|
93
|
+
)
|
|
94
|
+
}`
|
|
95
|
+
);
|
|
96
|
+
});
|
|
97
|
+
},
|
|
98
|
+
modifyEntry(setupConfig) {
|
|
99
|
+
return {
|
|
100
|
+
imports: [
|
|
101
|
+
"import { BrowserRouter } from 'react-router'",
|
|
102
|
+
"import AppRoutes from './runtimes/route/AppRoutes'"
|
|
103
|
+
],
|
|
104
|
+
appWrap(app) {
|
|
105
|
+
var _a2;
|
|
106
|
+
return `<BrowserRouter${((_a2 = setupConfig.userConfig.route) == null ? void 0 : _a2.basename) ? ` basename="${setupConfig.userConfig.route.basename}"` : ""}>
|
|
107
|
+
${app}
|
|
108
|
+
</BrowserRouter>`;
|
|
109
|
+
},
|
|
110
|
+
app() {
|
|
111
|
+
return "<AppRoutes />";
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Configuration } from '@rspack/core';
|
|
2
|
+
import { Options } from 'html-webpack-plugin';
|
|
3
|
+
import { Config } from '@jest/types';
|
|
4
|
+
|
|
5
|
+
interface TestConfig {
|
|
6
|
+
unit?: Config.InitialOptions;
|
|
7
|
+
components?: Config.InitialOptions;
|
|
8
|
+
common?: Config.InitialOptions;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface UserConfig {
|
|
12
|
+
port?: number
|
|
13
|
+
html?: HtmlConfig
|
|
14
|
+
route?: {
|
|
15
|
+
basename?: string
|
|
16
|
+
routes?: RouteConfig[]
|
|
17
|
+
}
|
|
18
|
+
plugins?: Array<'route' | LComedyPlugin>
|
|
19
|
+
rspackConfig?: Configuration
|
|
20
|
+
sourceDir?: string
|
|
21
|
+
output?: string
|
|
22
|
+
publicDir?: string
|
|
23
|
+
test?: TestConfig
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface LComedyPlugin {
|
|
27
|
+
name: string
|
|
28
|
+
generateFiles?: (setupConfig: SetupConfigPlugin) => Promise<void> | viod
|
|
29
|
+
modifyEntry?: (
|
|
30
|
+
setupConfig: SetupConfigPlugin
|
|
31
|
+
) => EntryModifier | Promise<EntryModifier>
|
|
32
|
+
rspackConfig?: (
|
|
33
|
+
rspackConfig: Configuration,
|
|
34
|
+
setupConfig: SetupConfig
|
|
35
|
+
) => Configuration | Promise<Configuration>
|
|
36
|
+
runtimeExports?: string[]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface RouteConfig {
|
|
40
|
+
path: string
|
|
41
|
+
index?: boolean
|
|
42
|
+
component: string
|
|
43
|
+
children?: RouteConfig[]
|
|
44
|
+
lazy?: boolean
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface HtmlConfig {
|
|
48
|
+
title?: string
|
|
49
|
+
rootId?: string
|
|
50
|
+
headTags?: string[]
|
|
51
|
+
bodyBeforeTags?: string[]
|
|
52
|
+
bodyAfterTags?: string[]
|
|
53
|
+
htmlWebpackOptions?: Options
|
|
54
|
+
htmlTemplateParametersData?: Record<string, any>
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface SetupConfig {
|
|
58
|
+
isProd: boolean
|
|
59
|
+
root: string
|
|
60
|
+
userConfig: UserConfig
|
|
61
|
+
plugins: LComedyPlugin[]
|
|
62
|
+
workDir: string
|
|
63
|
+
sourceDir: string
|
|
64
|
+
workPath: string
|
|
65
|
+
sourcePath: string
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
type SetupConfigPlugin = Omit<SetupConfig, 'plugins'>
|
|
69
|
+
|
|
70
|
+
interface EntryModifier {
|
|
71
|
+
imports?: string[]
|
|
72
|
+
reactImports?: string[]
|
|
73
|
+
beforeRender?: string
|
|
74
|
+
afterRender?: string
|
|
75
|
+
devNeedWatchAddPaths?: string[]
|
|
76
|
+
devNeedWatchChangePaths?: string[]
|
|
77
|
+
app?: (app: string) => string
|
|
78
|
+
appWrap?: (app: string) => string
|
|
79
|
+
render?: (render: string) => string
|
|
80
|
+
renderRun?: (renderRun: string) => string
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export type { LComedyPlugin as L, SetupConfigPlugin as S };
|
package/dist/run.d.ts
ADDED