@_tc/template-core 0.2.0-bate.0 → 0.2.0-bate.2
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/.skills/tc-component-usage-skills/reference/template-core-frontend.md +8 -1
- package/.skills/tc-generator/SKILL.md +3 -2
- package/.skills/tc-generator/reference/example.md +1 -1
- package/.skills/tc-generator/reference/project-template/index.js +1 -1
- package/.skills/tc-generator/reference/runtime-extensions.md +2 -2
- package/AGENT_README.md +11 -3
- package/README.md +24 -7
- package/cjs/app/controller/view.js +1 -1
- package/cjs/app/{extend → extends}/db.js +1 -1
- package/cjs/app/extends/localCacheHtmlEtag.js +1 -0
- package/cjs/app/extends/render-view.js +1 -0
- package/cjs/app/middleware.js +1 -1
- package/cjs/app/view/entry.tpl +0 -16
- package/cjs/bundler/index.js +1 -1
- package/cjs/bundler/state.js +1 -1
- package/cjs/bundler/utils.js +3 -3
- package/cjs/packages/common/index.js +1 -1
- package/cjs/packages/common/string/index.js +1 -1
- package/cjs/packages/core/index.js +1 -1
- package/cjs/packages/core/loader/controller.js +1 -1
- package/cjs/packages/core/loader/extend.js +1 -1
- package/cjs/packages/core/loader/middleware.js +1 -1
- package/cjs/packages/core/loader/router-schema.js +1 -1
- package/cjs/packages/core/loader/router.js +1 -1
- package/cjs/packages/core/loader/service.js +1 -1
- package/cjs/packages/utils/runFileFn.js +1 -1
- package/esm/app/controller/view.js +28 -15
- package/esm/app/{extend → extends}/$fetch.js +1 -1
- package/esm/app/{extend → extends}/crypto.js +1 -1
- package/esm/app/{extend → extends}/db.js +2 -2
- package/esm/app/{extend → extends}/generateErrorMessage.js +1 -1
- package/esm/app/extends/localCacheHtmlEtag.js +41 -0
- package/esm/app/{extend → extends}/logger.js +1 -1
- package/esm/app/{extend → extends}/parsingParamsOnUrl.js +1 -1
- package/esm/app/extends/render-view.js +18 -0
- package/esm/app/middleware.js +8 -12
- package/esm/app/view/entry.tpl +0 -16
- package/esm/bundler/index.js +6 -6
- package/esm/bundler/state.js +5 -1
- package/esm/bundler/utils.js +129 -104
- package/esm/packages/common/index.js +6 -6
- package/esm/packages/common/string/index.js +11 -2
- package/esm/packages/core/index.js +34 -28
- package/esm/packages/core/loader/controller.js +6 -6
- package/esm/packages/core/loader/extend.js +6 -6
- package/esm/packages/core/loader/middleware.js +6 -6
- package/esm/packages/core/loader/router-schema.js +7 -7
- package/esm/packages/core/loader/router.js +13 -13
- package/esm/packages/core/loader/service.js +6 -6
- package/esm/packages/utils/runFileFn.js +10 -10
- package/fe/frontend/src/common/rafTimer.d.ts +7 -0
- package/fe/frontend/src/common/rafTimer.js +144 -0
- package/fe/frontend/src/index.d.ts +2 -0
- package/fe/frontend/src/index.js +2 -1
- package/fe/packages/common/string/index.d.ts +9 -0
- package/model/packages/common/string/index.d.ts +9 -0
- package/package.json +1 -1
- package/types/app/extends/localCacheHtmlEtag.d.ts +10 -0
- package/types/app/{extend → extends}/render-view.d.ts +1 -1
- package/types/app/service/base.d.ts +1 -1
- package/types/app/service/project.d.ts +1 -1
- package/types/app/type.d.ts +2 -1
- package/types/app/typings.d.ts +10 -8
- package/types/bundler/state.d.ts +4 -0
- package/types/bundler/utils.d.ts +5 -0
- package/types/index.d.ts +3 -3
- package/types/packages/common/string/index.d.ts +16 -0
- package/types/packages/core/loader/extend.d.ts +1 -1
- package/types/packages/core/types.d.ts +4 -0
- package/cjs/app/extend/render-view.js +0 -1
- package/esm/app/extend/render-view.js +0 -25
- /package/cjs/app/{extend → extends}/$fetch.js +0 -0
- /package/cjs/app/{extend → extends}/crypto.js +0 -0
- /package/cjs/app/{extend → extends}/generateErrorMessage.js +0 -0
- /package/cjs/app/{extend → extends}/logger.js +0 -0
- /package/cjs/app/{extend → extends}/parsingParamsOnUrl.js +0 -0
- /package/types/app/{extend → extends}/$fetch.d.ts +0 -0
- /package/types/app/{extend → extends}/crypto.d.ts +0 -0
- /package/types/app/{extend → extends}/db.d.ts +0 -0
- /package/types/app/{extend → extends}/generateErrorMessage.d.ts +0 -0
- /package/types/app/{extend → extends}/logger.d.ts +0 -0
- /package/types/app/{extend → extends}/parsingParamsOnUrl.d.ts +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import e from "node:path";
|
|
2
|
+
import t from "nunjucks";
|
|
3
|
+
//#region app/extends/render-view.ts
|
|
4
|
+
var n = (n) => {
|
|
5
|
+
let r = n.publicsPath.map((t) => e.resolve(t, "./dist"));
|
|
6
|
+
console.log(r);
|
|
7
|
+
let i = t.configure(r, {
|
|
8
|
+
autoescape: !0,
|
|
9
|
+
throwOnUndefined: !1,
|
|
10
|
+
trimBlocks: !1,
|
|
11
|
+
lstripBlocks: !1,
|
|
12
|
+
noCache: n.envs.get() === "local",
|
|
13
|
+
...typeof n.config.nunjucks == "object" ? n.config.nunjucks : {}
|
|
14
|
+
});
|
|
15
|
+
return n.extends.nunjucksEnv = i, (e, t, n) => t.body = i.render(e, Object.assign({}, t.state, n));
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
export { n as default };
|
package/esm/app/middleware.js
CHANGED
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import t from "koa-
|
|
3
|
-
import
|
|
4
|
-
import r from "koa-bodyparser";
|
|
5
|
-
import i from "koa-static";
|
|
1
|
+
import e from "koa-compress";
|
|
2
|
+
import t from "koa-bodyparser";
|
|
3
|
+
import n from "koa-static";
|
|
6
4
|
//#region app/middleware.ts
|
|
7
|
-
var
|
|
5
|
+
var r = t({
|
|
8
6
|
formLimit: "1000mb",
|
|
9
7
|
enableTypes: [
|
|
10
8
|
"form",
|
|
11
9
|
"json",
|
|
12
10
|
"text"
|
|
13
11
|
]
|
|
14
|
-
}),
|
|
15
|
-
let
|
|
12
|
+
}), i = (t) => {
|
|
13
|
+
let i = t.envs.isLocal() ? {
|
|
16
14
|
maxage: 0,
|
|
17
15
|
setHeaders(e) {
|
|
18
16
|
e.setHeader("Cache-Control", "no-store, no-cache, must-revalidate, proxy-revalidate"), e.setHeader("Pragma", "no-cache"), e.setHeader("Expires", "0");
|
|
19
17
|
}
|
|
20
18
|
} : { maxage: 365 * 24 * 60 * 60 * 1e3 };
|
|
21
|
-
|
|
22
|
-
let s = n(e(r, "business"), "./public"), c = n(e(r, "frame"), "./public"), l = r.options.additionalPublicPaths ?? [];
|
|
23
|
-
l = Array.isArray(l) ? l : [l], r.use(i(c, o)), r.use(i(s, o)), l.forEach((e) => r.use(i(e, o))), r.use(a), r.use(r.middlewares.requestParameterParsing), r.use(r.middlewares.projectHandler), !r.envs.isLocal() && r.use(r.middlewares.apiSignVerify), r.use(r.middlewares.apiParamsVerify);
|
|
19
|
+
t.use(t.middlewares.errorHandle), t.use(e({ threshold: 2048 })), t.publicsPath.forEach((e) => t.use(n(e, i))), t.use(r), t.use(t.middlewares.requestParameterParsing), t.use(t.middlewares.projectHandler), !t.envs.isLocal() && t.use(t.middlewares.apiSignVerify), t.use(t.middlewares.apiParamsVerify);
|
|
24
20
|
};
|
|
25
21
|
//#endregion
|
|
26
|
-
export {
|
|
22
|
+
export { i as default };
|
package/esm/app/view/entry.tpl
CHANGED
|
@@ -3,22 +3,6 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<script>
|
|
7
|
-
;(() => {
|
|
8
|
-
const root = document.documentElement
|
|
9
|
-
let theme = root.classList.contains('dark') ? 'dark' : 'light'
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
const storedTheme = window.localStorage.getItem('tc_theme')
|
|
13
|
-
if (storedTheme === 'light' || storedTheme === 'dark') {
|
|
14
|
-
theme = storedTheme
|
|
15
|
-
}
|
|
16
|
-
} catch (_error) {}
|
|
17
|
-
|
|
18
|
-
root.classList.toggle('dark', theme === 'dark')
|
|
19
|
-
root.style.colorScheme = theme
|
|
20
|
-
})()
|
|
21
|
-
</script>
|
|
22
6
|
<link rel="icon" type="image/x-icon" href="/static/logo.png" />
|
|
23
7
|
<title>{{ name }}</title>
|
|
24
8
|
<!-- TC_HEAD_SLOT -->
|
package/esm/bundler/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { logRed as e } from "../packages/common/log/index.js";
|
|
2
|
+
import { buildBE as t } from "./buildBE.js";
|
|
3
3
|
import { setBuildFEOptions as n } from "./state.js";
|
|
4
4
|
import { dev as r } from "./dev.js";
|
|
5
5
|
import { prod as i } from "./prod.js";
|
|
6
6
|
//#region bundler/index.ts
|
|
7
|
-
var a = (
|
|
8
|
-
switch (n(a),
|
|
7
|
+
var a = (t, a) => {
|
|
8
|
+
switch (n(a), t) {
|
|
9
9
|
case "dev": return r();
|
|
10
10
|
case "prod": return i();
|
|
11
|
-
default: return
|
|
11
|
+
default: return e("Usage: npx tsx scripts/index.ts [dev|prod]"), Promise.resolve();
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
//#endregion
|
|
15
|
-
export {
|
|
15
|
+
export { t as buildBE, a as buildFE };
|
package/esm/bundler/state.js
CHANGED
package/esm/bundler/utils.js
CHANGED
|
@@ -1,37 +1,43 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { colorize as e, logJoinColorized as t, logRed as n, logWhite as r, logYellow as i } from "../packages/common/log/index.js";
|
|
2
|
+
import { resolve as a } from "../packages/utils/path.js";
|
|
2
3
|
import "../packages/utils/index.js";
|
|
3
|
-
import { colorize as t, logJoinColorized as n, logRed as r, logWhite as i, logYellow as a } from "../packages/common/log/index.js";
|
|
4
4
|
import { buildFESharedState as o } from "./state.js";
|
|
5
|
-
import s from "
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { build as
|
|
9
|
-
import
|
|
10
|
-
import { createRequire as
|
|
11
|
-
import { fileURLToPath as
|
|
5
|
+
import { existsSync as s, mkdirSync as c, readFileSync as l, readdirSync as u, rmSync as d, rmdirSync as f, unlinkSync as p, writeFileSync as m } from "fs";
|
|
6
|
+
import h from "path";
|
|
7
|
+
import * as g from "glob";
|
|
8
|
+
import { build as _ } from "vite";
|
|
9
|
+
import v from "@tailwindcss/vite";
|
|
10
|
+
import { createRequire as y } from "module";
|
|
11
|
+
import { fileURLToPath as b } from "url";
|
|
12
12
|
//#region bundler/utils.ts
|
|
13
|
-
var
|
|
13
|
+
var x = typeof __filename == "string" ? __filename : b(import.meta.url), S = h.dirname(x), C = process.cwd(), w = y(x), T = h.resolve(S, "../../"), E = h.resolve(S, "../"), D = h.resolve(T, "./fe/frontend"), O = h.resolve(C, "."), k = h.resolve(O, "./frontend"), A = (e) => h.dirname(w.resolve(`${e}/package.json`)), j = h.join(O, ".tc-entry-html"), M = "<!-- {{InsertScript}} -->", N = {
|
|
14
14
|
head: "<!-- TC_HEAD_SLOT -->",
|
|
15
15
|
bodyBeforeRoot: "<!-- TC_BODY_BEFORE_ROOT_SLOT -->",
|
|
16
16
|
bodyAfterRoot: "<!-- TC_BODY_AFTER_ROOT_SLOT -->"
|
|
17
|
-
},
|
|
17
|
+
}, P = [
|
|
18
18
|
"head",
|
|
19
19
|
"body-before-root",
|
|
20
20
|
"body-after-root"
|
|
21
|
-
],
|
|
21
|
+
], F = () => ({
|
|
22
22
|
head: "",
|
|
23
23
|
"body-before-root": "",
|
|
24
24
|
"body-after-root": ""
|
|
25
|
-
}),
|
|
26
|
-
let t =
|
|
25
|
+
}), I = (e) => e.trim().replace(/<!--(?!\s*(?:tc-slot:|\/tc-slot:))[\s\S]*?-->/g, "").replace(/>\s+</g, "><"), L = (e) => {
|
|
26
|
+
let t = [], n = e.replace(/<(script|style|textarea|pre)\b[\s\S]*?<\/\1>/gi, (e) => {
|
|
27
|
+
let n = `__TC_HTML_PRESERVED_${t.length}__`;
|
|
28
|
+
return t.push(e), n;
|
|
29
|
+
}).replace(/<!--(?!\s*(?:tc-slot:|\/tc-slot:|\{\{InsertScript\}\}|TC_))[\s\S]*?-->/g, "").replace(/>\s+</g, "><").trim();
|
|
30
|
+
return t.reduce((e, t, n) => e.replace(`__TC_HTML_PRESERVED_${n}__`, t), n);
|
|
31
|
+
}, R = (e) => e.split(h.sep).join("/"), z = (e) => {
|
|
32
|
+
let t = R(e);
|
|
27
33
|
return t.startsWith(".") || t.startsWith("/") ? t : `./${t}`;
|
|
28
|
-
},
|
|
29
|
-
let t =
|
|
30
|
-
if (n.replace(r, (n, r,
|
|
31
|
-
if (
|
|
32
|
-
return t[r] +=
|
|
34
|
+
}, B = (e) => /<html[\s>]/i.test(e) && e.includes("window['_basePath']") && /<div\s+id=["']root["']\s*><\/div>/i.test(e), V = (e) => {
|
|
35
|
+
let t = F(), n = l(e, "utf-8"), r = /<!--\s*tc-slot:([\w-]+)\s*-->([\s\S]*?)<!--\s*\/tc-slot:\1\s*-->/g, a = !1, o = n;
|
|
36
|
+
if (n.replace(r, (n, r, i) => {
|
|
37
|
+
if (a = !0, !P.includes(r)) throw Error(`Invalid html slot "${r}" in ${e}. Allowed slots: ${P.join(", ")}.`);
|
|
38
|
+
return t[r] += i.trim() ? `${i}\n` : "", o = o.replace(n, ""), n;
|
|
33
39
|
}), o.trim()) {
|
|
34
|
-
if (
|
|
40
|
+
if (B(n)) return i(`ignored legacy generated entry html: ${e}`), F();
|
|
35
41
|
throw Error([
|
|
36
42
|
`Invalid custom entry html: ${e}.`,
|
|
37
43
|
"Custom entry html can only contain tc-slot blocks, for example:",
|
|
@@ -40,99 +46,117 @@ var S = typeof __filename == "string" ? __filename : x(import.meta.url), C = s.d
|
|
|
40
46
|
"<!-- /tc-slot:head -->"
|
|
41
47
|
].join("\n"));
|
|
42
48
|
}
|
|
43
|
-
return
|
|
44
|
-
},
|
|
45
|
-
let
|
|
46
|
-
if (
|
|
47
|
-
if (
|
|
48
|
-
},
|
|
49
|
-
let
|
|
50
|
-
return
|
|
49
|
+
return a && i(`using custom entry html slots: ${e}`), t;
|
|
50
|
+
}, H = (e, t) => {
|
|
51
|
+
let n = h.basename(e), r = [h.join(e, `${t}.html`), h.join(e, `${n}.html`)].find((e) => s(e));
|
|
52
|
+
if (r) return r;
|
|
53
|
+
if (g.sync(a(e, "*.html")).length) throw Error([`Entry html filename is not supported in ${e}.`, `Use ${t}.html or ${n}.html as a tc-slot file.`].join("\n"));
|
|
54
|
+
}, U = (e, t) => e.replace(N.head, I(t.head)).replace(N.bodyBeforeRoot, I(t["body-before-root"])).replace(N.bodyAfterRoot, I(t["body-after-root"])), W = (e = /* @__PURE__ */ new Date()) => {
|
|
55
|
+
let t = (e, t = 2) => e.toString().padStart(t, "0");
|
|
56
|
+
return [
|
|
57
|
+
e.getFullYear(),
|
|
58
|
+
t(e.getMonth() + 1),
|
|
59
|
+
t(e.getDate()),
|
|
60
|
+
t(e.getHours())
|
|
61
|
+
].join("/") + `:${t(e.getMinutes())}:${t(e.getSeconds())}:${t(e.getMilliseconds(), 3)}`;
|
|
62
|
+
}, G = (e, t, n, r) => {
|
|
63
|
+
let i = h.join(j, `${n}.html`), a = z(h.relative(h.dirname(i), t));
|
|
64
|
+
return m(i, U(e, r).replace(M, `<script type="module" src="${a}"><\/script>`)), i;
|
|
51
65
|
};
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
let
|
|
55
|
-
let
|
|
66
|
+
function K() {
|
|
67
|
+
r("frameFEPath: " + D), r("runFEPath: " + k);
|
|
68
|
+
let e = [D, k].reduce((e, t) => {
|
|
69
|
+
let n = [
|
|
56
70
|
"js",
|
|
57
71
|
"jsx",
|
|
58
72
|
"ts",
|
|
59
73
|
"tsx"
|
|
60
|
-
].map((
|
|
61
|
-
return [...
|
|
62
|
-
}, []),
|
|
63
|
-
if (!
|
|
64
|
-
|
|
74
|
+
].map((e) => a(t, "/**", "/*." + e)), r = g.sync(n).filter((e) => e.includes(".entry.")).filter((e) => !e.includes(".d.ts"));
|
|
75
|
+
return [...e, ...r];
|
|
76
|
+
}, []), t = {};
|
|
77
|
+
if (!e.length) return t;
|
|
78
|
+
d(j, {
|
|
65
79
|
recursive: !0,
|
|
66
80
|
force: !0
|
|
67
|
-
}),
|
|
68
|
-
let
|
|
69
|
-
for (let
|
|
70
|
-
let i =
|
|
71
|
-
|
|
81
|
+
}), c(j, { recursive: !0 });
|
|
82
|
+
let n = l(h.resolve(E, "./app/view/entry.tpl"), "utf-8");
|
|
83
|
+
for (let r = 0; r < e.length; r++) {
|
|
84
|
+
let i = e[r], a = h.resolve(i, "../"), o = H(a, h.basename(i).replace(/\.entry\.[^.]+$/, "")), s = o ? h.basename(o, ".html") : a.split(h.sep).at(-1);
|
|
85
|
+
t[s] = G(n, i, s, o ? V(o) : F());
|
|
72
86
|
}
|
|
73
|
-
return
|
|
87
|
+
return t;
|
|
74
88
|
}
|
|
75
|
-
function
|
|
89
|
+
function q() {
|
|
76
90
|
let e = o.options.output ?? "frame";
|
|
77
|
-
return e !== "frame" &&
|
|
91
|
+
return e !== "frame" && n("Please pay attention to the build output."), e === "run" ? h.join(O, "./app/public/dist") : typeof e == "function" ? e() : h.join(E, "./app/public/dist");
|
|
78
92
|
}
|
|
79
|
-
var
|
|
80
|
-
let t = (await import("chokidar")).watch(
|
|
93
|
+
var J = async (e) => {
|
|
94
|
+
let t = (await import("chokidar")).watch(k, {
|
|
81
95
|
ignored: /(^|[\/\\])\../,
|
|
82
96
|
persistent: !0,
|
|
83
97
|
ignoreInitial: !0
|
|
84
|
-
}),
|
|
98
|
+
}), r = !1;
|
|
85
99
|
t.on("change", async (t) => {
|
|
86
|
-
if (!
|
|
87
|
-
|
|
100
|
+
if (!r) {
|
|
101
|
+
r = !0, i(`changed: ${t}`);
|
|
88
102
|
try {
|
|
89
103
|
await e?.();
|
|
90
104
|
} catch (e) {
|
|
91
|
-
|
|
105
|
+
n(e);
|
|
92
106
|
} finally {
|
|
93
|
-
|
|
107
|
+
r = !1;
|
|
94
108
|
}
|
|
95
109
|
}
|
|
96
|
-
}),
|
|
110
|
+
}), i(`watching ${k}/...`);
|
|
97
111
|
};
|
|
98
|
-
function
|
|
112
|
+
function Y() {
|
|
113
|
+
return {
|
|
114
|
+
name: "flatten-html",
|
|
115
|
+
apply: "build",
|
|
116
|
+
closeBundle() {
|
|
117
|
+
let e = q(), t = W();
|
|
118
|
+
m(a(e, "./FEBuildKey"), t);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function X(e = ".html") {
|
|
99
123
|
let t = [...new Set(Array.isArray(e) ? e : [e])];
|
|
100
124
|
return {
|
|
101
125
|
name: "flatten-html",
|
|
102
126
|
apply: "build",
|
|
103
127
|
closeBundle() {
|
|
104
|
-
let e =
|
|
105
|
-
if (!
|
|
106
|
-
let n =
|
|
128
|
+
let e = q();
|
|
129
|
+
if (!s(e)) return;
|
|
130
|
+
let n = o.options.minifyHtml ?? !1, r = g.sync("**/*.html", {
|
|
107
131
|
cwd: e,
|
|
108
132
|
dot: !0
|
|
109
133
|
});
|
|
110
|
-
for (let
|
|
111
|
-
let
|
|
112
|
-
|
|
113
|
-
for (let
|
|
114
|
-
let t =
|
|
115
|
-
|
|
134
|
+
for (let i of r) {
|
|
135
|
+
let r = h.join(e, i), a = l(r, "utf-8"), o = n ? L(a) : a, s = h.basename(i, ".html"), c = ".entry";
|
|
136
|
+
s.indexOf(c) === -1 && (s += c);
|
|
137
|
+
for (let i of t) {
|
|
138
|
+
let t = s + i, a = h.join(e, t);
|
|
139
|
+
r === a ? n && m(a, o) : m(a, o);
|
|
116
140
|
}
|
|
117
|
-
t.some((t) =>
|
|
141
|
+
t.some((t) => r === h.join(e, s + t)) || p(r);
|
|
118
142
|
}
|
|
119
|
-
let
|
|
120
|
-
if (!(
|
|
121
|
-
|
|
122
|
-
let t = e.split(
|
|
123
|
-
t.length &&
|
|
143
|
+
let a = [...new Set(r.map((e) => h.dirname(e)))].sort().reverse(), c = (e) => {
|
|
144
|
+
if (!(s(e) ? u(e) : [1]).length) {
|
|
145
|
+
f(e);
|
|
146
|
+
let t = e.split(h.sep).slice(0, -1);
|
|
147
|
+
t.length && c(t.join(h.sep));
|
|
124
148
|
}
|
|
125
149
|
};
|
|
126
|
-
for (let t of
|
|
127
|
-
let
|
|
150
|
+
for (let t of a) t && t !== "." && c(h.join(e, t));
|
|
151
|
+
let d = t.flatMap((t) => g.sync("**/*" + t, {
|
|
128
152
|
cwd: e,
|
|
129
153
|
dot: !0
|
|
130
154
|
}));
|
|
131
|
-
for (let e of
|
|
155
|
+
for (let e of d) i("final file path -----> " + e);
|
|
132
156
|
}
|
|
133
157
|
};
|
|
134
158
|
}
|
|
135
|
-
function
|
|
159
|
+
function Z(e) {
|
|
136
160
|
let t = [
|
|
137
161
|
"",
|
|
138
162
|
".ts",
|
|
@@ -140,73 +164,74 @@ function J(e) {
|
|
|
140
164
|
".js",
|
|
141
165
|
".jsx"
|
|
142
166
|
];
|
|
143
|
-
return e.reduce((e, [n, r, i =
|
|
144
|
-
let o = t.map((e) =>
|
|
167
|
+
return e.reduce((e, [n, r, i = k, a = "./defaultAlias"]) => {
|
|
168
|
+
let o = t.map((e) => h.resolve(i, r + e)).find((e) => s(e)), c = h.resolve(S, a);
|
|
145
169
|
return o && (c = o), e[n] = c, e;
|
|
146
170
|
}, {});
|
|
147
171
|
}
|
|
148
|
-
var
|
|
172
|
+
var Q = (...e) => new RegExp(e.join("[\\/]")), $ = (e) => `_${e}_tcC`, ee = async (r, i) => {
|
|
149
173
|
try {
|
|
150
|
-
await
|
|
174
|
+
await _({
|
|
151
175
|
configFile: !1,
|
|
152
176
|
base: "/dist",
|
|
153
177
|
plugins: [
|
|
154
178
|
(await import("@vitejs/plugin-react")).default(),
|
|
155
|
-
|
|
156
|
-
|
|
179
|
+
X([".tpl"]),
|
|
180
|
+
Y(),
|
|
181
|
+
v()
|
|
157
182
|
],
|
|
158
183
|
build: {
|
|
159
|
-
outDir:
|
|
184
|
+
outDir: q(),
|
|
160
185
|
emptyOutDir: !0,
|
|
161
186
|
sourcemap: i === "dev" ? "inline" : "hidden",
|
|
162
187
|
rolldownOptions: {
|
|
163
|
-
input:
|
|
188
|
+
input: r,
|
|
164
189
|
output: { codeSplitting: { groups: [
|
|
165
190
|
{
|
|
166
|
-
name:
|
|
167
|
-
test:
|
|
191
|
+
name: $("__nm"),
|
|
192
|
+
test: Q("node_modules"),
|
|
168
193
|
maxSize: 5e5,
|
|
169
194
|
minShareCount: 2,
|
|
170
195
|
priority: 1
|
|
171
196
|
},
|
|
172
197
|
{
|
|
173
|
-
name:
|
|
174
|
-
test:
|
|
198
|
+
name: $("r"),
|
|
199
|
+
test: Q("node_modules", "react"),
|
|
175
200
|
minShareCount: 2,
|
|
176
201
|
maxSize: 5e5,
|
|
177
202
|
priority: 5
|
|
178
203
|
},
|
|
179
204
|
{
|
|
180
|
-
name:
|
|
181
|
-
test:
|
|
205
|
+
name: $("r-d"),
|
|
206
|
+
test: Q("node_modules", "react-dom"),
|
|
182
207
|
minShareCount: 2,
|
|
183
208
|
maxSize: 2e5,
|
|
184
209
|
priority: 10
|
|
185
210
|
},
|
|
186
211
|
{
|
|
187
|
-
name:
|
|
188
|
-
test:
|
|
212
|
+
name: $("r-r-d"),
|
|
213
|
+
test: Q("node_modules", "react-router-dom"),
|
|
189
214
|
minShareCount: 2,
|
|
190
215
|
maxSize: 5e5,
|
|
191
216
|
priority: 10
|
|
192
217
|
},
|
|
193
218
|
{
|
|
194
|
-
name:
|
|
195
|
-
test:
|
|
219
|
+
name: $("ajv"),
|
|
220
|
+
test: Q("node_modules", "ajv"),
|
|
196
221
|
minShareCount: 2,
|
|
197
222
|
maxSize: 2e5,
|
|
198
223
|
priority: 10
|
|
199
224
|
},
|
|
200
225
|
{
|
|
201
|
-
name:
|
|
202
|
-
test:
|
|
226
|
+
name: $("ui-lib"),
|
|
227
|
+
test: Q("components"),
|
|
203
228
|
minShareCount: 2,
|
|
204
229
|
maxSize: 2e5,
|
|
205
230
|
priority: 5
|
|
206
231
|
},
|
|
207
232
|
{
|
|
208
|
-
name:
|
|
209
|
-
test:
|
|
233
|
+
name: $("ui-f-lib"),
|
|
234
|
+
test: Q("components", ".*?[Ff]orm.*?"),
|
|
210
235
|
minShareCount: 2,
|
|
211
236
|
maxSize: 5e4,
|
|
212
237
|
priority: 10
|
|
@@ -215,15 +240,15 @@ var Y = (...e) => new RegExp(e.join("[\\/]")), X = (e) => `_${e}_tcC`, Z = async
|
|
|
215
240
|
}
|
|
216
241
|
},
|
|
217
242
|
resolve: { alias: {
|
|
218
|
-
react:
|
|
219
|
-
"react-dom":
|
|
220
|
-
"@tc/ui-react/hooks":
|
|
221
|
-
"@tc/ui-react":
|
|
222
|
-
...
|
|
243
|
+
react: A("react"),
|
|
244
|
+
"react-dom": A("react-dom"),
|
|
245
|
+
"@tc/ui-react/hooks": h.resolve(S, "../../fe/packages/react/hooks/"),
|
|
246
|
+
"@tc/ui-react": h.resolve(S, "../../fe/packages/react/ui/"),
|
|
247
|
+
...Z([
|
|
223
248
|
[
|
|
224
249
|
"@tc/scalability/SchemaForm/frameData",
|
|
225
250
|
"./extended/SchemaForm/data",
|
|
226
|
-
|
|
251
|
+
D
|
|
227
252
|
],
|
|
228
253
|
["@tc/scalability/SchemaForm/data", "./extended/SchemaForm/data"],
|
|
229
254
|
["@tc/scalability/SchemaPage/CallCom/data", "./extended/SchemaPage/CallCom/data"],
|
|
@@ -238,10 +263,10 @@ var Y = (...e) => new RegExp(e.join("[\\/]")), X = (e) => `_${e}_tcC`, Z = async
|
|
|
238
263
|
]
|
|
239
264
|
])
|
|
240
265
|
} }
|
|
241
|
-
}),
|
|
266
|
+
}), t(e("builded", "green"), e(" -> ", "white"), e("time: ", "cyan"), e(/* @__PURE__ */ new Date(), "pink"));
|
|
242
267
|
} catch (e) {
|
|
243
|
-
if (
|
|
268
|
+
if (n(e), i !== "dev") throw e;
|
|
244
269
|
}
|
|
245
270
|
};
|
|
246
271
|
//#endregion
|
|
247
|
-
export {
|
|
272
|
+
export { ee as VBuildFE, K as entries, Y as generateBuildKeyPlugin, q as outDir, J as watchFiles };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { isBoolean as e, isFunction as t, isNil as n, isNonNullable as r, isNumber as i, isPlainObject as a, isString as o } from "./guards/index.js";
|
|
2
|
+
import { chunk as s, compact as c, groupBy as l, toArray as u, uniqueBy as d } from "./array/index.js";
|
|
3
|
+
import { LRUCache as f } from "./cache/LRUCache.js";
|
|
4
|
+
import { FetchAxios as p, axios as m, createInstance as h } from "./http/index.js";
|
|
5
5
|
import { defaultLanguageResources as g } from "./i18n/default.js";
|
|
6
6
|
import { defaultEnglishResources as _ } from "./i18n/en-US.js";
|
|
7
7
|
import { defaultLanguage as v, languageLocalKey as y, translations as b } from "./i18n/locales.js";
|
|
@@ -10,5 +10,5 @@ import { ANSI_RESET as j, ansiColors as M, colorLog as N, colorize as P, joinCol
|
|
|
10
10
|
import { clamp as W, toFiniteNumber as G } from "./number/index.js";
|
|
11
11
|
import { filterEmpty as K, filtereEmpty as q } from "./object/filterEmpty.js";
|
|
12
12
|
import { mapValues as J, omit as Y, pick as X } from "./object/index.js";
|
|
13
|
-
import { capitalize as Z, isBlank as Q, kebabCase as
|
|
14
|
-
export { j as ANSI_RESET,
|
|
13
|
+
import { capitalize as Z, isBlank as Q, joinStr as $, kebabCase as ee } from "./string/index.js";
|
|
14
|
+
export { j as ANSI_RESET, p as FetchAxios, f as LRUCache, M as ansiColors, m as axios, Z as capitalize, s as chunk, W as clamp, N as colorLog, P as colorize, c as compact, h as createInstance, _ as defaultEnglishResources, v as defaultLanguage, g as defaultLanguageResources, K as filterEmpty, q as filtereEmpty, x as getI18nPathValue, S as getLanguage, l as groupBy, C as i18n, w as i18nStore, T as interpolateI18nMessage, Q as isBlank, e as isBoolean, t as isFunction, n as isNil, r as isNonNullable, i as isNumber, E as isPlainI18nDictionary, a as isPlainObject, o as isString, F as joinColorized, $ as joinStr, ee as kebabCase, y as languageLocalKey, I as logColor, L as logColorized, R as logGreen, z as logJoinColorized, B as logPink, V as logRed, H as logWhite, U as logYellow, J as mapValues, D as mergeI18nDictionary, O as mergeI18nResources, Y as omit, X as pick, k as t, u as toArray, G as toFiniteNumber, A as translate, b as translations, d as uniqueBy };
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
//#region packages/common/string/index.ts
|
|
2
|
-
var e = (e) => e == null || e.trim().length === 0, t = (e) => e.length === 0 ? e : `${e.charAt(0).toUpperCase()}${e.slice(1)}`, n = (e) => e.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").replace(/-+/g, "-").toLowerCase()
|
|
2
|
+
var e = (e) => e == null || e.trim().length === 0, t = (e) => e.length === 0 ? e : `${e.charAt(0).toUpperCase()}${e.slice(1)}`, n = (e) => e.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/[\s_]+/g, "-").replace(/-+/g, "-").toLowerCase(), r = (...e) => {
|
|
3
|
+
let t = e[e.length - 1], n = typeof t == "object" && t && !Array.isArray(t) && "separator" in t ? t : void 0, r = n?.separator ?? " ";
|
|
4
|
+
return (n ? e.slice(0, -1) : e).flatMap((e) => {
|
|
5
|
+
if (Array.isArray(e)) {
|
|
6
|
+
let [t, n] = e;
|
|
7
|
+
return t ? n : void 0;
|
|
8
|
+
}
|
|
9
|
+
return e;
|
|
10
|
+
}).filter((e) => e != null && e !== !1 && e !== "").join(r);
|
|
11
|
+
};
|
|
3
12
|
//#endregion
|
|
4
|
-
export { t as capitalize, e as isBlank, n as kebabCase };
|
|
13
|
+
export { t as capitalize, e as isBlank, r as joinStr, n as kebabCase };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import t from "
|
|
3
|
-
import {
|
|
4
|
-
import { runFileFn as r } from "../utils/runFileFn.js";
|
|
1
|
+
import e from "./env.js";
|
|
2
|
+
import { resolve as t } from "../utils/path.js";
|
|
3
|
+
import { runFileFn as n } from "../utils/runFileFn.js";
|
|
5
4
|
import "../utils/index.js";
|
|
6
|
-
import
|
|
5
|
+
import r from "./loader/config.js";
|
|
6
|
+
import { getAppPath as i } from "./paths.js";
|
|
7
7
|
import a from "./loader/controller.js";
|
|
8
8
|
import o from "./loader/extend.js";
|
|
9
9
|
import s from "./loader/middleware.js";
|
|
@@ -13,39 +13,45 @@ import u from "./loader/router-schema.js";
|
|
|
13
13
|
import d from "./loader/service.js";
|
|
14
14
|
import f from "koa";
|
|
15
15
|
//#region packages/core/index.ts
|
|
16
|
-
var p = c, m = async (
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
let { frameBaseDir:
|
|
20
|
-
|
|
21
|
-
let
|
|
22
|
-
|
|
16
|
+
var p = c, m = async (n = {}) => {
|
|
17
|
+
let c = new f();
|
|
18
|
+
c.hooks = {}, c.hooks.initing?.();
|
|
19
|
+
let { frameBaseDir: p, baseDir: m, ...g } = n;
|
|
20
|
+
c.options = g, c.options.pageBasePage = c.options.pageBasePage ?? "/", c.options.apiPrefix = c.options.apiPrefix || "/api";
|
|
21
|
+
let _ = c.baseDir = m ?? process.cwd(), v = c.frameBaseDir = p ?? t(__dirname, "..");
|
|
22
|
+
c.businessAppPath = t(_, "app"), c.frameAppPath = t(v, "app"), c.paths = [{
|
|
23
23
|
type: "frame",
|
|
24
|
-
path:
|
|
24
|
+
path: c.frameAppPath
|
|
25
25
|
}, {
|
|
26
26
|
type: "business",
|
|
27
|
-
path:
|
|
28
|
-
}]
|
|
27
|
+
path: c.businessAppPath
|
|
28
|
+
}];
|
|
29
|
+
let y = c.options.additionalPublicPaths ?? [];
|
|
30
|
+
y = Array.isArray(y) ? y : [y], c.publicsPath = [
|
|
31
|
+
t(i(c, "business"), "./public"),
|
|
32
|
+
t(i(c, "frame"), "./public"),
|
|
33
|
+
...y
|
|
34
|
+
], c.envs = e(), console.log(`-- [init] env: ${c.envs.get()} --`), r(c), console.log("-- [init] loader config done --"), await o(c), console.log("-- [init] loader extends done --"), u(c), console.log("-- [init] loader routerSchema done --"), d(c), console.log("-- [init] loader service done --"), a(c), console.log("-- [init] loader controller done --"), s(c), console.log("-- [init] loader middleware done --"), h(c), l(c), console.log("-- [init] loader router done --");
|
|
29
35
|
try {
|
|
30
|
-
let
|
|
31
|
-
|
|
36
|
+
let t = c.config.port || process.env.PORT || "8080", n = parseInt(t + "", 10), r = process.env.IP || "0.0.0.0";
|
|
37
|
+
c.listen(n, r), console.log(`Server port: http://localhost:${n}`), console.log(`run env is ${e().get()}`);
|
|
32
38
|
} catch (e) {
|
|
33
39
|
console.error(e);
|
|
34
40
|
}
|
|
35
|
-
return
|
|
36
|
-
}, h = (
|
|
37
|
-
["frame", "business"].map((
|
|
38
|
-
type:
|
|
39
|
-
path: e
|
|
40
|
-
})).forEach((
|
|
41
|
+
return c.hooks.inited?.(), c;
|
|
42
|
+
}, h = (e) => {
|
|
43
|
+
["frame", "business"].map((t) => ({
|
|
44
|
+
type: t,
|
|
45
|
+
path: i(e, t)
|
|
46
|
+
})).forEach((r) => {
|
|
41
47
|
for (let i of ["ts", "js"]) {
|
|
42
|
-
let a = `middleware.${i}`, o =
|
|
48
|
+
let a = `middleware.${i}`, o = t(r.path, a);
|
|
43
49
|
try {
|
|
44
|
-
|
|
50
|
+
n(o)?.(e), console.log(`-- [init] loader ${r.type} appMiddleware ${a} done -- (${r.path})`);
|
|
45
51
|
break;
|
|
46
|
-
} catch (
|
|
47
|
-
let
|
|
48
|
-
if (!(
|
|
52
|
+
} catch (e) {
|
|
53
|
+
let t = e;
|
|
54
|
+
if (!(t?.code === "MODULE_NOT_FOUND" && typeof t?.message == "string" && (t.message.includes(`Cannot find module '${o}'`) || t.message.includes(`Cannot find module "${o}"`)))) throw console.log(`-- [error] loader ${r.type} appMiddleware ${a} error -- (${o})`), e;
|
|
49
55
|
}
|
|
50
56
|
}
|
|
51
57
|
});
|