@moneko/core 3.0.0-beta.15 → 3.0.0-beta.151
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/lib/app-entry.d.ts +2 -0
- package/lib/app-entry.js +1 -0
- package/lib/app.d.ts +29 -0
- package/lib/app.js +1 -0
- package/lib/cleanup.js +1 -0
- package/{build → lib}/common.d.ts +2 -1
- package/lib/common.js +1 -0
- package/{build → lib}/coverage.d.ts +1 -1
- package/{build → lib}/coverage.js +1 -1
- package/lib/define.d.ts +4 -0
- package/lib/define.js +1 -0
- package/lib/docs.d.ts +4 -0
- package/lib/docs.js +1 -0
- package/{build → lib}/done.d.ts +2 -7
- package/lib/done.js +1 -0
- package/lib/esm.d.ts +1 -0
- package/lib/esm.js +1 -0
- package/lib/fallback.d.ts +2 -0
- package/lib/fallback.js +1 -0
- package/lib/generate-api.d.ts +1 -0
- package/lib/generate-api.js +1 -0
- package/lib/html-add-entry-attr.js +1 -0
- package/{build → lib}/html-plugin-option.d.ts +1 -1
- package/lib/html-plugin-option.js +1 -0
- package/lib/index.d.ts +3 -36
- package/lib/index.js +1 -8
- package/lib/loader/css-unicode.cjs +10 -0
- package/lib/loader/frontmatter.cjs +7 -0
- package/lib/locales.d.ts +10 -0
- package/lib/locales.js +2 -0
- package/lib/merge-router.d.ts +2 -0
- package/lib/merge-router.js +1 -0
- package/lib/modifyVars.d.ts +7 -0
- package/lib/modifyVars.js +1 -0
- package/lib/module-federation.js +1 -0
- package/lib/module.config.js +1 -0
- package/lib/net.d.ts +3 -0
- package/lib/net.js +1 -0
- package/lib/normalize-css.d.ts +2 -0
- package/lib/normalize-css.js +1 -0
- package/lib/object-listener.d.ts +4 -0
- package/lib/object-listener.js +1 -0
- package/lib/prefix-router.d.ts +2 -0
- package/lib/prefix-router.js +1 -0
- package/{build → lib}/process-env.d.ts +11 -3
- package/lib/process-env.js +1 -0
- package/lib/rem.d.ts +2 -0
- package/lib/rem.js +1 -0
- package/lib/routes.d.ts +31 -0
- package/lib/routes.js +1 -0
- package/lib/seo.js +1 -0
- package/{build → lib}/swcrc.d.ts +1 -1
- package/lib/swcrc.js +1 -0
- package/{build → lib}/tsloader.config.d.ts +1 -1
- package/lib/tsloader.config.js +1 -0
- package/{build → lib}/utils.d.ts +14 -4
- package/lib/utils.js +1 -0
- package/lib/virtual-module-plugin.d.ts +10 -0
- package/lib/virtual-module-plugin.js +1 -0
- package/lib/virtual-modules.d.ts +2 -0
- package/lib/virtual-modules.js +1 -0
- package/{build → lib}/webpack.common.d.ts +2 -2
- package/lib/webpack.common.js +1 -0
- package/lib/webpack.dev.d.ts +3 -0
- package/lib/webpack.dev.js +4 -0
- package/{build → lib}/webpack.prod.d.ts +1 -1
- package/lib/webpack.prod.js +1 -0
- package/package.json +31 -49
- package/template/index.html +5 -1
- package/typings/global.d.ts +81 -40
- package/build/common.js +0 -12
- package/build/done.js +0 -1
- package/build/envFlags.d.ts +0 -17
- package/build/envFlags.js +0 -1
- package/build/esm.d.ts +0 -1
- package/build/esm.js +0 -1
- package/build/html-add-entry-attr.js +0 -1
- package/build/html-plugin-option.js +0 -1
- package/build/index.d.ts +0 -2
- package/build/index.js +0 -1
- package/build/modifyVars.d.ts +0 -2
- package/build/modifyVars.js +0 -1
- package/build/module-federation.js +0 -1
- package/build/module.config.js +0 -1
- package/build/process-env.js +0 -1
- package/build/seo.js +0 -1
- package/build/swcrc.js +0 -1
- package/build/tsloader.config.js +0 -1
- package/build/utils.js +0 -1
- package/build/webpack.common.js +0 -1
- package/build/webpack.dev.d.ts +0 -2
- package/build/webpack.dev.js +0 -4
- package/build/webpack.prod.js +0 -1
- package/lib/normalize.css +0 -254
- package/lib/packages/library/bootstrap.jsx +0 -28
- package/lib/packages/library/index.d.ts +0 -4
- package/lib/packages/library/index.js +0 -4
- package/lib/refresh-rem.d.ts +0 -0
- package/lib/refresh-rem.js +0 -49
- package/lib/router/index.d.ts +0 -52
- package/lib/router/index.js +0 -277
- /package/lib/{packages/library/bootstrap.d.ts → cleanup.d.ts} +0 -0
- /package/{build → lib}/has-pkg.d.ts +0 -0
- /package/{build → lib}/has-pkg.js +0 -0
- /package/{build → lib}/html-add-entry-attr.d.ts +0 -0
- /package/{build → lib}/minify.d.ts +0 -0
- /package/{build → lib}/minify.js +0 -0
- /package/{build → lib}/module-federation.d.ts +0 -0
- /package/{build → lib}/module.config.d.ts +0 -0
- /package/{build → lib}/resolver-sync.d.ts +0 -0
- /package/{build → lib}/resolver-sync.js +0 -0
- /package/{build → lib}/seo.d.ts +0 -0
- /package/{build → lib}/yarn-argv.d.ts +0 -0
- /package/{build → lib}/yarn-argv.js +0 -0
package/lib/normalize.css
DELETED
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
/* @import url('tailwindcss/utilities'); */
|
|
2
|
-
|
|
3
|
-
html,
|
|
4
|
-
body {
|
|
5
|
-
margin: 0;
|
|
6
|
-
padding: 0;
|
|
7
|
-
inline-size: 100vi;
|
|
8
|
-
font-size: var(--font-size, 14px);
|
|
9
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
|
|
10
|
-
Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
|
|
11
|
-
'Noto Color Emoji', Helvetica, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans';
|
|
12
|
-
color: var(--text-color, rgb(0 0 0 / 65%));
|
|
13
|
-
line-height: 1.8;
|
|
14
|
-
transition-duration: var(--transition-duration, 0.3s);
|
|
15
|
-
transition-property: background-color, color;
|
|
16
|
-
transition-timing-function: var(--transition-timing-function, cubic-bezier(0.94, -0.1, 0.1, 1.2));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
#root {
|
|
20
|
-
display: flex;
|
|
21
|
-
-webkit-overflow-scrolling: touch;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
#root > main {
|
|
25
|
-
animation: route-in var(--transition-duration, 0.3s);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
input,
|
|
29
|
-
textarea {
|
|
30
|
-
caret-color: inherit;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
h1 {
|
|
34
|
-
margin: 0.67em 0;
|
|
35
|
-
font-size: 2em;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
hr {
|
|
39
|
-
overflow: visible;
|
|
40
|
-
block-size: 0;
|
|
41
|
-
box-sizing: content-box;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
pre {
|
|
45
|
-
font-size: 1em;
|
|
46
|
-
font-family: monospace;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
a {
|
|
50
|
-
text-decoration: none;
|
|
51
|
-
background-color: transparent;
|
|
52
|
-
cursor: pointer;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
abbr[title] {
|
|
56
|
-
border-block-end: none;
|
|
57
|
-
text-decoration: underline;
|
|
58
|
-
text-decoration: underline dotted;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
b,
|
|
62
|
-
strong {
|
|
63
|
-
font-weight: bolder;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
code,
|
|
67
|
-
kbd,
|
|
68
|
-
samp {
|
|
69
|
-
font-size: 1em;
|
|
70
|
-
font-family: monospace;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
small {
|
|
74
|
-
font-size: 80%;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
sub,
|
|
78
|
-
sup {
|
|
79
|
-
position: relative;
|
|
80
|
-
font-size: 75%;
|
|
81
|
-
line-height: 0;
|
|
82
|
-
vertical-align: baseline;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
sub {
|
|
86
|
-
inset-block-end: -0.25em;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
sup {
|
|
90
|
-
inset-block-start: -0.5em;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
img {
|
|
94
|
-
border-style: none;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
img,
|
|
98
|
-
button {
|
|
99
|
-
outline: 1px solid transparent;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
button,
|
|
103
|
-
input,
|
|
104
|
-
optgroup,
|
|
105
|
-
select,
|
|
106
|
-
textarea {
|
|
107
|
-
margin: 0;
|
|
108
|
-
font-size: 100%;
|
|
109
|
-
font-family: inherit;
|
|
110
|
-
line-height: 1.15;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
button,
|
|
114
|
-
input {
|
|
115
|
-
overflow: visible;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
button,
|
|
119
|
-
select {
|
|
120
|
-
text-transform: none;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
button,
|
|
124
|
-
[type='button'],
|
|
125
|
-
[type='reset'],
|
|
126
|
-
[type='submit'] {
|
|
127
|
-
appearance: button;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
button::-moz-focus-inner,
|
|
131
|
-
[type='button']::-moz-focus-inner,
|
|
132
|
-
[type='reset']::-moz-focus-inner,
|
|
133
|
-
[type='submit']::-moz-focus-inner {
|
|
134
|
-
border-style: none;
|
|
135
|
-
padding: 0;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
button:-moz-focusring,
|
|
139
|
-
[type='button']:-moz-focusring,
|
|
140
|
-
[type='reset']:-moz-focusring,
|
|
141
|
-
[type='submit']:-moz-focusring {
|
|
142
|
-
outline: 1px dotted var(--primary-outline);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
fieldset {
|
|
146
|
-
padding: 0.35em 0.75em 0.625em;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
legend {
|
|
150
|
-
display: table;
|
|
151
|
-
padding: 0;
|
|
152
|
-
max-inline-size: 100%;
|
|
153
|
-
white-space: normal;
|
|
154
|
-
color: inherit;
|
|
155
|
-
box-sizing: border-box;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
progress {
|
|
159
|
-
vertical-align: baseline;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
textarea {
|
|
163
|
-
overflow: auto;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
details {
|
|
167
|
-
display: block;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
summary {
|
|
171
|
-
display: list-item;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
template,
|
|
175
|
-
[hidden] {
|
|
176
|
-
display: none;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
[type='checkbox'],
|
|
180
|
-
[type='radio'] {
|
|
181
|
-
box-sizing: border-box;
|
|
182
|
-
padding: 0;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
[type='number']::-webkit-inner-spin-button,
|
|
186
|
-
[type='number']::-webkit-outer-spin-button {
|
|
187
|
-
block-size: auto;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
[type='search'] {
|
|
191
|
-
appearance: textfield;
|
|
192
|
-
outline-offset: -2px;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
[type='search']::-webkit-search-decoration {
|
|
196
|
-
appearance: none;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
::-webkit-file-upload-button {
|
|
200
|
-
appearance: button;
|
|
201
|
-
font: inherit;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
::-webkit-scrollbar {
|
|
205
|
-
inline-size: 4px;
|
|
206
|
-
block-size: 4px;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
::-webkit-scrollbar-track,
|
|
210
|
-
::-webkit-scrollbar-thumb {
|
|
211
|
-
border-radius: 5px;
|
|
212
|
-
background-color: transparent;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
:hover::-webkit-scrollbar-thumb {
|
|
216
|
-
background-color: var(--primary-selection);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
::-webkit-scrollbar-thumb:hover {
|
|
220
|
-
background-color: var(--primary-hover);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
::-webkit-scrollbar-thumb:active {
|
|
224
|
-
background-color: var(--primary-active);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
::-webkit-scrollbar-button {
|
|
228
|
-
display: none;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
@keyframes route-in {
|
|
232
|
-
from {
|
|
233
|
-
transform: translate3d(0, 16px, 0);
|
|
234
|
-
opacity: 0;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
to {
|
|
238
|
-
transform: translate3d(0, 0, 0);
|
|
239
|
-
opacity: 1;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
@keyframes route-out {
|
|
244
|
-
from {
|
|
245
|
-
transform: translate3d(0, 0, 0);
|
|
246
|
-
opacity: 1;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
to {
|
|
250
|
-
z-index: -1;
|
|
251
|
-
transform: translate3d(0, 1rem, 0);
|
|
252
|
-
opacity: 0;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
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.d.ts
DELETED
|
File without changes
|
package/lib/refresh-rem.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
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.d.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
type Any = any;
|
|
2
|
-
type MDXComponents = Record<string, Any>;
|
|
3
|
-
export interface RouterProps {
|
|
4
|
-
/** 菜单id */
|
|
5
|
-
key: string;
|
|
6
|
-
alive?: boolean;
|
|
7
|
-
/** 菜单图标 */
|
|
8
|
-
icon?: string;
|
|
9
|
-
dynamicTitle?: string;
|
|
10
|
-
/** 菜单名 */
|
|
11
|
-
i18n?: string | null;
|
|
12
|
-
hideMenu?: boolean;
|
|
13
|
-
hideTabs?: boolean;
|
|
14
|
-
onlyLogin?: boolean;
|
|
15
|
-
/** 菜单父id */
|
|
16
|
-
parentId?: string;
|
|
17
|
-
root?: boolean;
|
|
18
|
-
path?: string;
|
|
19
|
-
element?: Any;
|
|
20
|
-
fallback?: Any;
|
|
21
|
-
/** 可否关闭标签 */
|
|
22
|
-
closable?: boolean;
|
|
23
|
-
/** 子菜单 */
|
|
24
|
-
children?: RouterProps[];
|
|
25
|
-
props?: {
|
|
26
|
-
path: string;
|
|
27
|
-
components?: MDXComponents;
|
|
28
|
-
[key: string]: Any;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export declare function lazyImport(filePath: string): Promise<unknown>;
|
|
32
|
-
export interface ExampleModule {
|
|
33
|
-
code: string;
|
|
34
|
-
title?: string;
|
|
35
|
-
description?: string | null;
|
|
36
|
-
noInline: boolean;
|
|
37
|
-
language: never;
|
|
38
|
-
}
|
|
39
|
-
export type MyPkg = RouterProps & {
|
|
40
|
-
type: string;
|
|
41
|
-
title: string;
|
|
42
|
-
path: string;
|
|
43
|
-
subtitle?: string;
|
|
44
|
-
icon?: string;
|
|
45
|
-
};
|
|
46
|
-
export declare const myPkgs: MyPkg[];
|
|
47
|
-
export declare const myDemoKv: Record<string, ExampleModule[]>;
|
|
48
|
-
export declare const mdxComponents: MDXComponents;
|
|
49
|
-
export declare const onlyLoginRouter: RouterProps[];
|
|
50
|
-
export declare const router: RouterProps[];
|
|
51
|
-
export declare function matchUtil(pathname: string): RouterProps;
|
|
52
|
-
export {};
|
package/lib/router/index.js
DELETED
|
@@ -1,277 +0,0 @@
|
|
|
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
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{build → lib}/minify.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{build → lib}/seo.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|