@moneko/core 3.0.0-beta.13 → 3.0.0-beta.14
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/build/module.config.js +1 -1
- package/lib/index.js +8 -1
- package/lib/packages/library/bootstrap.jsx +28 -0
- package/lib/packages/library/index.d.ts +1 -1
- package/lib/packages/library/index.js +4 -1
- package/lib/refresh-rem.js +49 -1
- package/lib/router/index.js +277 -1
- package/package.json +5 -2
- package/lib/packages/library/bootstrap.tsx +0 -39
package/build/module.config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"mini-css-extract-plugin";import s from"mini-svg-data-uri";import{CONFIG as
|
|
1
|
+
import e from"mini-css-extract-plugin";import s from"mini-svg-data-uri";import o from"remark-frontmatter";import t from"remark-gfm";import r from"remark-mdx-frontmatter";import{CONFIG as a,PUBLICPATH as l}from"./common.js";import{hasPkg as i}from"./has-pkg.js";import m from"./modifyVars.js";import{APPTYPE as n,DEV as c,pkgName as p}from"./process-env.js";import d from"./swcrc.js";import u from"./tsloader.config.js";import{resolveNodeModulesPath as f,resolveProgramPath as y}from"./utils.js";let x="single-spa"===n?l:"../",g={loader:e.loader,options:{publicPath:"/"!==x?x:"../"}},j=i("@moneko/postcss")&&{loader:"postcss-loader",options:{postcssOptions:await import("@moneko/postcss")}};c&&(g="style-loader");let $=[...a.cssModules,p,"neko-ui"].map(f),b=[f(`${p}/lib/styles/eval/*.less`),...["src/styles/variables/*.less","src/styles/mixins/*.less","site/styles/variables/*.less","site/styles/mixins/*.less"].map(y)],h=["components","example","mock","site","src"].map(y),w=[g,{loader:"css-loader",options:{modules:{auto:e=>{for(let s=0,o=$.length;s<o;s++)if(e&&e?.includes($[s]))return/(.*(?<!\.global\.(le|c)ss)$)/i.test(e);return/(^(?!.*node_modules))(.*(?<!\.global\.(le|c)ss)$)/i.test(e)},localIdentName:"[path][name]__[local]",exportLocalsConvention:"dashesOnly"},importLoaders:2}},j,"css-unicode-loader",{loader:"less-loader",options:{sourceMap:!!a.sourceMap,lessOptions:{modifyVars:m,javascriptEnabled:!0}}},{loader:"style-resources-loader",options:{patterns:b}}].filter(Boolean),k={loader:"tsc"===a.compiler?"ts-loader":"swc-loader",options:"tsc"===a.compiler?u:d(c)},v={rules:[{oneOf:[{resourceQuery:/raw/,type:"asset/source"},{resourceQuery:/\.wasm$/,type:"webassembly/async"},{test:/\.less$/,use:w,include:h.concat(a.rulesInclude?.less?.map(f)||[])},{test:/\.css$/,use:[g,"css-loader",j,"css-unicode-loader"].filter(Boolean),include:h.concat(a.rulesInclude?.css?.map(f)||[])},{test:/\.(gif|png|jpe?g|ico|mp4)$/i,type:"asset",generator:{filename:"assets/images/[name][ext][query]"},include:h.concat(a.rulesInclude?.media?.map(f)||[])},{test:/\.(eot|ttf|otf|woff(|2))$/,type:"asset",generator:{filename:"assets/fonts/[name][ext][query]"},include:h.concat(a.rulesInclude?.fonts?.map(f)||[])},{test:/\.svg$/,type:"asset/inline",generator:{dataUrl:e=>s("string"!=typeof e?e.toString():e)}},{test:/\.txt$/,type:"asset/source"},{test:/\.(cj|mj|t|j)s(|x)$/,use:[...a.prefixJsLoader,k].filter(Boolean),include:h.concat(a.rulesInclude?.js?.map(f)||[])},{test:/\.mdx?$/,use:[...a.prefixJsLoader,k,{loader:"@mdx-js/loader",options:{jsxImportSource:"solid-js/h",rehypePlugins:[[(await import("@mapbox/rehype-prism")).default,{ignore:!0}],(await import("rehype-accessible-emojis")).rehypeAccessibleEmojis,(await import("rehype-figure")).default],remarkPlugins:[o,[r,{name:"matter"}],t]}}].filter(Boolean),include:h,exclude:[/(.+)\/examples\/(.+).mdx?$/i]},{test:/\.mdx?$/,type:"asset/source",include:[/(.+)\/examples\/(.+).mdx?$/i]},{type:"asset/source",include:[/(.+)\/examples\/(.+).*?$/i]}]},...a.moduleRules]};export default v;
|
package/lib/index.js
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
export{pathToRegexp}from
|
|
1
|
+
export { pathToRegexp } from 'path-to-regexp';
|
|
2
|
+
/** 一些项目基本信息 */
|
|
3
|
+
export const projectBasicInfo = {
|
|
4
|
+
projectName,
|
|
5
|
+
providerConfig,
|
|
6
|
+
programInfo,
|
|
7
|
+
coverage: projectCoverage,
|
|
8
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Router } from '@solidjs/router';
|
|
2
|
+
import { render } from 'solid-js/web';
|
|
3
|
+
import App from '@/index';
|
|
4
|
+
function isFunction(target) {
|
|
5
|
+
return [
|
|
6
|
+
'[object Function]',
|
|
7
|
+
'[object AsyncFunction]',
|
|
8
|
+
'[object GeneratorFunction]',
|
|
9
|
+
'[object Proxy]',
|
|
10
|
+
].includes(Object.prototype.toString.call(target));
|
|
11
|
+
}
|
|
12
|
+
const appEntry = APPENTRY ? await import(APPENTRY) : null;
|
|
13
|
+
const container = document.getElementById('root');
|
|
14
|
+
if (appEntry && isFunction(appEntry.bootstrap)) {
|
|
15
|
+
appEntry.bootstrap();
|
|
16
|
+
}
|
|
17
|
+
window.rootInstance = {
|
|
18
|
+
unmount: () => null,
|
|
19
|
+
render() {
|
|
20
|
+
window.rootInstance.unmount = render(() => (<Router>
|
|
21
|
+
<App />
|
|
22
|
+
</Router>), container);
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
window.rootInstance.render();
|
|
26
|
+
if (appEntry && isFunction(appEntry.mount)) {
|
|
27
|
+
appEntry.mount();
|
|
28
|
+
}
|
package/lib/refresh-rem.js
CHANGED
|
@@ -1 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
(function (doc, win) {
|
|
3
|
+
function refreshRem() {
|
|
4
|
+
const docEl = doc.documentElement;
|
|
5
|
+
const clientWidth = docEl.clientWidth || doc.body.clientWidth;
|
|
6
|
+
const _designSize = clientWidth <= 375 ? 375 : programInfo.designSize;
|
|
7
|
+
let unitSize = clientWidth;
|
|
8
|
+
if (clientWidth <= 375) {
|
|
9
|
+
unitSize = clientWidth;
|
|
10
|
+
}
|
|
11
|
+
else if (clientWidth <= programInfo.designSize) {
|
|
12
|
+
unitSize = _designSize;
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
unitSize = clientWidth;
|
|
16
|
+
}
|
|
17
|
+
// 窗口大于设计尺寸的时候,使用窗口大小
|
|
18
|
+
// const unitSize = clientWidth > designSize ? designSize : clientWidth;
|
|
19
|
+
// const rootSize = (16 / designSize) * unitSize + 'px';
|
|
20
|
+
// 保持设计比例
|
|
21
|
+
const rootSize = (16 / _designSize) * unitSize + 'px';
|
|
22
|
+
if (rootSize !== docEl.style.fontSize) {
|
|
23
|
+
docEl.style.fontSize = rootSize;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
refreshRem();
|
|
27
|
+
if ('addEventListener' in doc) {
|
|
28
|
+
const resizeEvt = 'orientationchange' in win ? 'orientationchange' : 'resize';
|
|
29
|
+
win.addEventListener(resizeEvt, refreshRem, false);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 判断 window 及元素节点对象下是否存在 scrollTo 属性,
|
|
33
|
+
* 不存在则自定义,这样就可以解决 IE 下不兼容 scrollTo 的问题
|
|
34
|
+
*/
|
|
35
|
+
if (!window.scrollTo) {
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
window.scrollTo = function (option) {
|
|
38
|
+
window.scrollLeft = option.left;
|
|
39
|
+
window.scrollTop = option.top;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (!document.body.scrollTo) {
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
+
Element.prototype.scrollTo = function (option) {
|
|
45
|
+
this.scrollLeft = option.left;
|
|
46
|
+
this.scrollTop = option.top;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
})(document, window);
|
package/lib/router/index.js
CHANGED
|
@@ -1 +1,277 @@
|
|
|
1
|
-
|
|
1
|
+
import { pathToRegexp } from 'path-to-regexp';
|
|
2
|
+
export function lazyImport(filePath) {
|
|
3
|
+
return new Promise(function (resolve) {
|
|
4
|
+
return import(
|
|
5
|
+
/* webpackChunkName: "[request]" */
|
|
6
|
+
'@/pages/' + filePath.replace(/:/g, '$').replace(/^\//, ''))
|
|
7
|
+
.then(resolve)
|
|
8
|
+
.catch(function () {
|
|
9
|
+
return Promise.resolve({
|
|
10
|
+
default: null,
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export const myPkgs = [];
|
|
16
|
+
export const myDemoKv = {};
|
|
17
|
+
export const mdxComponents = {};
|
|
18
|
+
// function heading(p: Any, level: number) {
|
|
19
|
+
// return createElement(`h${level}`, {
|
|
20
|
+
// 'data-prefix': '# ',
|
|
21
|
+
// role: 'heading',
|
|
22
|
+
// 'aria-level': level,
|
|
23
|
+
// ...p,
|
|
24
|
+
// });
|
|
25
|
+
// }
|
|
26
|
+
// function pre(p: Any) {
|
|
27
|
+
// const c = createElement('code', p);
|
|
28
|
+
// if (p.className) {
|
|
29
|
+
// return createElement(
|
|
30
|
+
// mdxComponents.CodeBlock || 'pre',
|
|
31
|
+
// { lang: p.className.replace('language-', '').replace(/ .*$/, '') },
|
|
32
|
+
// c
|
|
33
|
+
// );
|
|
34
|
+
// }
|
|
35
|
+
// return c;
|
|
36
|
+
// }
|
|
37
|
+
if (APPTYPE === 'library') {
|
|
38
|
+
const models = import.meta.webpackContext?.('@pkg/', {
|
|
39
|
+
recursive: true,
|
|
40
|
+
regExp: /README\.mdx?$/,
|
|
41
|
+
mode: 'sync',
|
|
42
|
+
});
|
|
43
|
+
let overrideComps = {};
|
|
44
|
+
try {
|
|
45
|
+
overrideComps = (await import('@/components/components')).default;
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
/* empty */
|
|
49
|
+
}
|
|
50
|
+
Object.assign(mdxComponents, {
|
|
51
|
+
// h1: function (p: Any) {
|
|
52
|
+
// return heading(p, 1);
|
|
53
|
+
// },
|
|
54
|
+
// h2: function (p: Any) {
|
|
55
|
+
// return heading(p, 2);
|
|
56
|
+
// },
|
|
57
|
+
// h3: function (p: Any) {
|
|
58
|
+
// return heading(p, 3);
|
|
59
|
+
// },
|
|
60
|
+
// h4: function (p: Any) {
|
|
61
|
+
// return heading(p, 4);
|
|
62
|
+
// },
|
|
63
|
+
// h5: function (p: Any) {
|
|
64
|
+
// return heading(p, 5);
|
|
65
|
+
// },
|
|
66
|
+
// h6: function (p: Any) {
|
|
67
|
+
// return heading(p, 6);
|
|
68
|
+
// },
|
|
69
|
+
// pre: pre,
|
|
70
|
+
...overrideComps,
|
|
71
|
+
});
|
|
72
|
+
models?.keys()?.forEach(function (item) {
|
|
73
|
+
const key = item.substring(2).split('/').slice(0, -1).join('/');
|
|
74
|
+
const { basic, default: Child } = models(item);
|
|
75
|
+
myPkgs.push({
|
|
76
|
+
key: key,
|
|
77
|
+
path: key,
|
|
78
|
+
element: Child,
|
|
79
|
+
...basic,
|
|
80
|
+
props: {
|
|
81
|
+
components: mdxComponents,
|
|
82
|
+
path: key,
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
const allDemo = import.meta.webpackContext?.('@pkg/', {
|
|
87
|
+
recursive: true,
|
|
88
|
+
regExp: /\/examples\/(.+)\.mdx$/,
|
|
89
|
+
mode: 'sync',
|
|
90
|
+
});
|
|
91
|
+
allDemo?.keys()?.forEach(function (e) {
|
|
92
|
+
const k = e.substring(2), arr = k.split('/'), name = arr[0];
|
|
93
|
+
if (!Array.isArray(myDemoKv[name])) {
|
|
94
|
+
myDemoKv[name] = [];
|
|
95
|
+
}
|
|
96
|
+
const exampleStr = allDemo(e);
|
|
97
|
+
const m = exampleStr.matchAll(/```([^\r\n]+)?\r?\n([\s\S]*?)\r?\n```/g);
|
|
98
|
+
let code = '', language = '';
|
|
99
|
+
let description = null;
|
|
100
|
+
for (const match of m) {
|
|
101
|
+
language = match[1] || 'tsx';
|
|
102
|
+
code = match[2];
|
|
103
|
+
description = exampleStr.replace(match[0], '');
|
|
104
|
+
}
|
|
105
|
+
myDemoKv[name].push({
|
|
106
|
+
language: language,
|
|
107
|
+
code: code,
|
|
108
|
+
description: description,
|
|
109
|
+
title: arr.pop()?.replace(/\.mdx$/, ''),
|
|
110
|
+
noInline: /render\([^\\)]*\);?(?=\s*$)/.test(code),
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
let list = [];
|
|
115
|
+
try {
|
|
116
|
+
list = (await import('@/router')).default;
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
// eslint-disable-next-line no-console
|
|
120
|
+
console.info('自定义路由请在 router 目录下新建 index.ts, 类型: RouterProps[]', error);
|
|
121
|
+
}
|
|
122
|
+
function prefixKey(path, prev) {
|
|
123
|
+
// eslint-disable-next-line no-undefined
|
|
124
|
+
return [prev === '*' && path !== '*' ? undefined : prev, path].filter(Boolean).join('/');
|
|
125
|
+
}
|
|
126
|
+
const models = import.meta.webpackContext?.('@/pages/', {
|
|
127
|
+
recursive: true,
|
|
128
|
+
regExp: /\.(t|j)sx$/,
|
|
129
|
+
mode: 'lazy',
|
|
130
|
+
});
|
|
131
|
+
function pathToTree(input) {
|
|
132
|
+
const root = [];
|
|
133
|
+
for (let i = 0; i < input.length; i++) {
|
|
134
|
+
const chain = input[i].split('/').slice(0, -1);
|
|
135
|
+
let curr = root;
|
|
136
|
+
for (let j = 0; j < chain.length; j++) {
|
|
137
|
+
let pathRule = chain[j];
|
|
138
|
+
if (pathRule === '') {
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (pathRule === '.') {
|
|
142
|
+
pathRule = '*';
|
|
143
|
+
}
|
|
144
|
+
const lastHierarchy = curr;
|
|
145
|
+
// 遍历root是否已有该层级
|
|
146
|
+
if (Array.isArray(curr)) {
|
|
147
|
+
for (let k = 0; k < curr.length; k++) {
|
|
148
|
+
if (curr[k].path === pathRule) {
|
|
149
|
+
curr = curr[k].children;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
if (lastHierarchy === curr) {
|
|
155
|
+
let key = j === chain.length - 1 ? input[i] : chain.slice(0, j + 1).join('/') + '/';
|
|
156
|
+
// 截取最后一个 / 前面的数据
|
|
157
|
+
key = key.substring(2, key.lastIndexOf('/'));
|
|
158
|
+
const node = {
|
|
159
|
+
key: key,
|
|
160
|
+
path: pathRule,
|
|
161
|
+
i18n: 'route-' + key,
|
|
162
|
+
children: [],
|
|
163
|
+
alive: false,
|
|
164
|
+
element: lazyImport(key),
|
|
165
|
+
hideMenu: key.includes(':'),
|
|
166
|
+
props: { path: key },
|
|
167
|
+
};
|
|
168
|
+
// 文件,最后一个字符不是"/“符号
|
|
169
|
+
// if (j === chain.length - 1) delete node.children;
|
|
170
|
+
if (Array.isArray(curr)) {
|
|
171
|
+
curr.push(node);
|
|
172
|
+
}
|
|
173
|
+
curr = node.children;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return root;
|
|
178
|
+
}
|
|
179
|
+
const routers = pathToTree(models?.keys().map(function (item) {
|
|
180
|
+
return item.replace(/\$/g, ':');
|
|
181
|
+
}) || []);
|
|
182
|
+
function merge(source, child, prev) {
|
|
183
|
+
const _ = source.find(function (item) {
|
|
184
|
+
return item.path === child.path;
|
|
185
|
+
});
|
|
186
|
+
if (!_) {
|
|
187
|
+
source.push(child);
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
// 处理key
|
|
191
|
+
_.key = prefixKey(_.path, prev);
|
|
192
|
+
if (typeof _.i18n === 'undefined') {
|
|
193
|
+
_.i18n = 'route-' + _.key;
|
|
194
|
+
}
|
|
195
|
+
if (typeof _.alive === 'undefined') {
|
|
196
|
+
_.alive = false;
|
|
197
|
+
}
|
|
198
|
+
if (typeof _.element === 'undefined' && child.element) {
|
|
199
|
+
_.element = child.element;
|
|
200
|
+
_.props = child.props;
|
|
201
|
+
}
|
|
202
|
+
if (typeof _.hideMenu === 'undefined') {
|
|
203
|
+
_.hideMenu = _.path === '*' ? true : _.key.includes(':');
|
|
204
|
+
}
|
|
205
|
+
Object.assign(_, {
|
|
206
|
+
...child,
|
|
207
|
+
..._,
|
|
208
|
+
});
|
|
209
|
+
if (child.children) {
|
|
210
|
+
if (!_.children && Array.isArray(child.children)) {
|
|
211
|
+
_.children = child.children;
|
|
212
|
+
}
|
|
213
|
+
child.children?.forEach(function (childData) {
|
|
214
|
+
merge(_?.children, childData, _?.key);
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function findLogin(rs = [], onlyLogin, prevKey) {
|
|
220
|
+
return rs
|
|
221
|
+
.map(function (e) {
|
|
222
|
+
const _ = { ...e };
|
|
223
|
+
if (typeof _.key === 'undefined') {
|
|
224
|
+
_.key = prefixKey(e.path, prevKey);
|
|
225
|
+
}
|
|
226
|
+
if (typeof _.i18n === 'undefined') {
|
|
227
|
+
_.i18n = 'route-' + _.key;
|
|
228
|
+
}
|
|
229
|
+
if (typeof _.alive === 'undefined') {
|
|
230
|
+
_.alive = false;
|
|
231
|
+
}
|
|
232
|
+
if (_.path === '*' && typeof _.hideMenu === 'undefined') {
|
|
233
|
+
_.hideMenu = true;
|
|
234
|
+
}
|
|
235
|
+
if (Array.isArray(_.children)) {
|
|
236
|
+
// eslint-disable-next-line no-undefined
|
|
237
|
+
_.children = _.children.length ? findLogin(_.children, onlyLogin, _.key) : undefined;
|
|
238
|
+
}
|
|
239
|
+
if (!_.element) {
|
|
240
|
+
_.element = lazyImport(_.key);
|
|
241
|
+
_.props = { path: _.key };
|
|
242
|
+
}
|
|
243
|
+
return !!_.onlyLogin === onlyLogin && !_.root ? null : _;
|
|
244
|
+
})
|
|
245
|
+
.filter(Boolean);
|
|
246
|
+
}
|
|
247
|
+
const _router = [...list];
|
|
248
|
+
for (let i = 0, len = routers.length; i < len; i++) {
|
|
249
|
+
merge(_router, routers[i]);
|
|
250
|
+
}
|
|
251
|
+
/* 登录前注册的路由 */
|
|
252
|
+
export const onlyLoginRouter = findLogin(_router, false);
|
|
253
|
+
/* 登录后注册的路由 */
|
|
254
|
+
export const router = findLogin(_router, true);
|
|
255
|
+
export function matchUtil(pathname) {
|
|
256
|
+
let p = { key: '' };
|
|
257
|
+
function findPath(rs) {
|
|
258
|
+
for (let i = 0, len = rs.length; i < len; i++) {
|
|
259
|
+
if (rs[i].path && rs[i].path !== '*' && rs[i].key) {
|
|
260
|
+
try {
|
|
261
|
+
if (pathToRegexp(rs[i].key).exec(pathname.substring(1))) {
|
|
262
|
+
p = rs[i];
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
catch (error) {
|
|
267
|
+
/* empty */
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
if (Array.isArray(rs[i].children)) {
|
|
271
|
+
findPath(rs[i].children);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
findPath(router);
|
|
276
|
+
return p;
|
|
277
|
+
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moneko/core",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.14",
|
|
4
4
|
"description": "core",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"build": "npm run build-conf && npm run build
|
|
8
|
+
"build": "npm run build-conf && npm run build:types",
|
|
9
9
|
"build-conf": "swc config -d build -C module.type=nodenext -C jsc.target=esnext -C jsc.loose=true -C jsc.minify.mangle=true -C jsc.minify.compress=true -C minify=true -D",
|
|
10
10
|
"build-src": "swc src -d lib --extensions=.ts --ignore=src/packages/library/*.tsx -C module.type=es6 -C jsc.loose=true -C jsc.minify.mangle=true -C jsc.minify.compress=true -C minify=true -D",
|
|
11
11
|
"build:types": "tsc && tsc --project cli.json",
|
|
@@ -40,6 +40,9 @@
|
|
|
40
40
|
"portfinder": "1.0.32",
|
|
41
41
|
"rehype-accessible-emojis": "0.3.2",
|
|
42
42
|
"rehype-figure": "1.0.1",
|
|
43
|
+
"remark-frontmatter": "^4.0.1",
|
|
44
|
+
"remark-gfm": "^3.0.1",
|
|
45
|
+
"remark-mdx-frontmatter": "^3.0.0",
|
|
43
46
|
"style-loader": "3.3.2",
|
|
44
47
|
"style-resources-loader": "1.5.0",
|
|
45
48
|
"swc-loader": "0.2.3",
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Router } from '@solidjs/router';
|
|
2
|
-
import { render } from 'solid-js/web';
|
|
3
|
-
import type { JSX } from 'solid-js';
|
|
4
|
-
import App from '@/index';
|
|
5
|
-
|
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, no-unused-vars
|
|
7
|
-
function isFunction(target: any): target is VoidFunction & ((...v: any[]) => any) {
|
|
8
|
-
return [
|
|
9
|
-
'[object Function]',
|
|
10
|
-
'[object AsyncFunction]',
|
|
11
|
-
'[object GeneratorFunction]',
|
|
12
|
-
'[object Proxy]',
|
|
13
|
-
].includes(Object.prototype.toString.call(target));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const appEntry: AppEntryMethods | null = APPENTRY ? await import(APPENTRY) : null;
|
|
17
|
-
const container = document.getElementById('root') as HTMLElement;
|
|
18
|
-
|
|
19
|
-
if (appEntry && isFunction(appEntry.bootstrap)) {
|
|
20
|
-
appEntry.bootstrap?.();
|
|
21
|
-
}
|
|
22
|
-
const Main = () => (
|
|
23
|
-
<Router>
|
|
24
|
-
<App />
|
|
25
|
-
</Router>
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
window.rootInstance = {
|
|
29
|
-
unmount: () => null,
|
|
30
|
-
render(ele: () => JSX.Element) {
|
|
31
|
-
window.rootInstance.unmount = render(ele, container);
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
window.rootInstance.render(Main);
|
|
36
|
-
|
|
37
|
-
if (appEntry && isFunction(appEntry.mount)) {
|
|
38
|
-
appEntry.mount?.();
|
|
39
|
-
}
|