@windwalker-io/core 4.1.11 → 4.2.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/LICENSE +19 -19
- package/bin/release.js +3 -3
- package/core/index.d.ts +1 -0
- package/core/index.html +13 -0
- package/core/lib/main.ts +9 -0
- package/core/package.json +26 -0
- package/core/public/vite.svg +1 -0
- package/core/src/main.ts +23 -0
- package/core/src/style.css +95 -0
- package/core/src/typescript.svg +1 -0
- package/core/src/vite-env.d.ts +1 -0
- package/package.json +67 -52
- package/{postcss.config.cjs → postcss.config.js} +1 -1
- package/src/app/app.ts +50 -0
- package/src/app/index.ts +3 -0
- package/src/app/macros/defineJsModules.ts +5 -0
- package/src/app/macros/index.ts +1 -0
- package/src/asset-bundler.mjs +114 -0
- package/src/asset-sync.mjs +4 -1
- package/src/debugger/Store.vue +1 -1
- package/src/debugger/debugger.js +3 -5
- package/src/debugger/types/global.d.js +2 -2
- package/src/index.mjs +11 -9
- package/src/legacy/4.0/js-sync.mjs +74 -74
- package/src/next/fusion/index.ts +2 -0
- package/src/next/fusion/plugins/assets.ts +29 -0
- package/src/next/fusion/plugins/index.ts +3 -0
- package/src/next/fusion/plugins/systemjs.ts +66 -0
- package/src/next/fusion/processors/cloneAssets.ts +81 -0
- package/src/next/fusion/processors/cssModulize.ts +105 -0
- package/src/next/fusion/processors/index.ts +4 -0
- package/src/next/fusion/processors/installVendors.ts +178 -0
- package/src/next/fusion/processors/jsModulize.ts +296 -0
- package/src/next/index.ts +2 -0
- package/src/next/utilities/asset-sync.ts +47 -0
- package/src/next/utilities/crypto.ts +11 -0
- package/src/next/utilities/fs.ts +61 -0
- package/src/next/utilities/index.ts +5 -0
- package/src/next/utilities/modules.ts +17 -0
- package/tailwind/console.tailwind.config.cjs +1 -1
- package/tailwind.config.js +10 -0
- package/vite.config.debugger.ts +94 -0
- package/vite.config.next.ts +75 -0
- package/.gulp.json +0 -7
- package/dist/debugger/100-a64696bac484f689dc7f.js +0 -2
- package/dist/debugger/100.js.map +0 -1
- package/dist/debugger/153-2f3366cb4e48e0749485.js +0 -2
- package/dist/debugger/153.js.map +0 -1
- package/dist/debugger/282-6f9f84a149fc7e52beb5.js +0 -2
- package/dist/debugger/282.js.map +0 -1
- package/dist/debugger/358-bdcf2ec8126fe2a9a049.js +0 -2
- package/dist/debugger/358.js.map +0 -1
- package/dist/debugger/416-ac63d360de6c26cab89a.js +0 -2
- package/dist/debugger/416.js.map +0 -1
- package/dist/debugger/489-e2b77a72f97d9e96f9c0.js +0 -2
- package/dist/debugger/489.js.map +0 -1
- package/dist/debugger/694-f1f22e67d91a57498639.js +0 -2
- package/dist/debugger/694.js.map +0 -1
- package/dist/debugger/941-c22b0704c67ca5058678.js +0 -2
- package/dist/debugger/941.js.map +0 -1
- package/dist/debugger/debugger.js +0 -3
- package/dist/debugger/debugger.js.LICENSE.txt +0 -13
- package/dist/debugger/main.js.map +0 -1
- package/dist/debugger/windwalker-logo-h-w.svg +0 -1
- package/dist/debugger-console.css +0 -2
- package/dist/debugger-console.css.map +0 -1
- package/dist/debugger-console.js +0 -2
- package/dist/debugger-console.js.map +0 -1
- package/dist/images/windwalker-logo-h-w.svg +0 -1
- package/fusionfile.mjs +0 -96
- package/src/debugger/webpack.config.js +0 -9
- package/tailwind.config.cjs +0 -30
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { type FindFileResult, findFilesFromGlobArray, stripUrlQuery } from '@/next';
|
|
2
|
+
import {
|
|
3
|
+
type BuildTask,
|
|
4
|
+
type ConfigBuilder,
|
|
5
|
+
type MaybePromise,
|
|
6
|
+
type ProcessorInterface,
|
|
7
|
+
type ProcessorPreview,
|
|
8
|
+
js,
|
|
9
|
+
shortHash,
|
|
10
|
+
plugin as addPlugin,
|
|
11
|
+
} from '@windwalker-io/fusion-next';
|
|
12
|
+
import { WatchTask } from '@windwalker-io/fusion-next/src/types';
|
|
13
|
+
import fs from 'fs-extra';
|
|
14
|
+
import crypto from 'node:crypto';
|
|
15
|
+
import { parse } from 'node-html-parser';
|
|
16
|
+
import { normalize, resolve } from 'node:path';
|
|
17
|
+
|
|
18
|
+
export interface JsModulizeOptions {
|
|
19
|
+
tmpPath?: string;
|
|
20
|
+
cleanTmp?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function jsModulize(entry: string, dest: string, options: JsModulizeOptions = {}) {
|
|
24
|
+
return new JsModulizeProcessor(js(entry, dest), options);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class JsModulizeProcessor implements ProcessorInterface {
|
|
28
|
+
protected scriptPatterns: string[] = [];
|
|
29
|
+
protected bladePatterns: string[] = [];
|
|
30
|
+
protected stagePrefix: string = '';
|
|
31
|
+
|
|
32
|
+
constructor(protected processor: ReturnType<typeof js>, protected options: JsModulizeOptions = {}) {
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
config(taskName: string, builder: ConfigBuilder) {
|
|
36
|
+
const tasks = this.processor.config(taskName, builder) as BuildTask[];
|
|
37
|
+
const task = tasks[0];
|
|
38
|
+
const inputFile = resolve(task.input);
|
|
39
|
+
const tmpPath = this.options.tmpPath ?? resolve('./tmp/fusion/jsmodules/').replace(/\\/g, '/');
|
|
40
|
+
const clean = this.options.cleanTmp ?? true;
|
|
41
|
+
|
|
42
|
+
// const appFileName = 'js/' + this.stagePrefix + '/app.js';
|
|
43
|
+
// const appSrcFileName = 'resources/assets/src/' + this.stagePrefix + '/app.js';
|
|
44
|
+
// const task = builder.addTask(appFileName);
|
|
45
|
+
|
|
46
|
+
if (clean) {
|
|
47
|
+
builder.postBuildCallbacks.push((options, bundle) => {
|
|
48
|
+
fs.removeSync(tmpPath);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// builder.merge({
|
|
53
|
+
// resolve: {
|
|
54
|
+
// alias: {
|
|
55
|
+
// '@main': task.input
|
|
56
|
+
// }
|
|
57
|
+
// }
|
|
58
|
+
// });
|
|
59
|
+
|
|
60
|
+
// builder.entryFileNamesCallbacks.push((chunkInfo) => {
|
|
61
|
+
// if (chunkInfo.facadeModuleId === appSrcFileName) {
|
|
62
|
+
// return appFileName;
|
|
63
|
+
// }
|
|
64
|
+
// });
|
|
65
|
+
//
|
|
66
|
+
// builder.resolveIdCallbacks.push((id) => {
|
|
67
|
+
// if (id === task.input) {
|
|
68
|
+
// return appSrcFileName;
|
|
69
|
+
// }
|
|
70
|
+
// });
|
|
71
|
+
|
|
72
|
+
this.ignoreMainImport(task);
|
|
73
|
+
|
|
74
|
+
builder.resolveIdCallbacks.push((id) => {
|
|
75
|
+
if (id === '@main') {
|
|
76
|
+
return { id, external: true };
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const scriptFiles = findFilesFromGlobArray(this.scriptPatterns);
|
|
81
|
+
const bladeFiles = parseScriptsFromBlades(this.bladePatterns);
|
|
82
|
+
|
|
83
|
+
// Watches
|
|
84
|
+
// for (const bladeFile of bladeFiles) {
|
|
85
|
+
// builder.watches.push({
|
|
86
|
+
// file: resolve(bladeFile.file.fullpath),
|
|
87
|
+
// moduleFile: inputFile,
|
|
88
|
+
// updateType: 'full-reload',
|
|
89
|
+
// } satisfies WatchTask);
|
|
90
|
+
// }
|
|
91
|
+
|
|
92
|
+
builder.loadCallbacks.push((src, options) => {
|
|
93
|
+
const srcFile = stripUrlQuery(src);
|
|
94
|
+
|
|
95
|
+
// if (src === appSrcFileName) {
|
|
96
|
+
if (normalize(srcFile) === inputFile) {
|
|
97
|
+
let listJS = "{\n";
|
|
98
|
+
|
|
99
|
+
// Merge standalone ts files
|
|
100
|
+
for (const scriptFile of scriptFiles) {
|
|
101
|
+
let fullpath = scriptFile.fullpath;
|
|
102
|
+
|
|
103
|
+
if (fullpath.endsWith('.d.ts')) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let key = scriptFile.relativePath.replace(/assets\//, '').toLowerCase();
|
|
108
|
+
fullpath = resolve(fullpath).replace(/\\/g, '/');
|
|
109
|
+
|
|
110
|
+
key = key.substring(0, key.lastIndexOf('.'));
|
|
111
|
+
|
|
112
|
+
if (this.stagePrefix) {
|
|
113
|
+
key = this.stagePrefix + '/' + key;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// md5
|
|
117
|
+
key = 'view:' + crypto.createHash('md5').update(key).digest('hex');
|
|
118
|
+
|
|
119
|
+
listJS += `'${key}': () => import('${fullpath}'),\n`;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Parse from blades
|
|
123
|
+
const listens: string[] = [];
|
|
124
|
+
|
|
125
|
+
fs.ensureDirSync(tmpPath);
|
|
126
|
+
|
|
127
|
+
for (const result of bladeFiles) {
|
|
128
|
+
let key = result.as;
|
|
129
|
+
const tmpFile = tmpPath + '/' + result.path.replace(/\\|\//g, '_') + '-' + shortHash(result.code) + '.ts';
|
|
130
|
+
|
|
131
|
+
if (!fs.existsSync(tmpFile) || fs.readFileSync(tmpFile, 'utf8') !== result.code) {
|
|
132
|
+
fs.writeFileSync(tmpFile, result.code);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// if (this.stagePrefix) {
|
|
136
|
+
// key = this.stagePrefix + '/' + key;
|
|
137
|
+
// }
|
|
138
|
+
|
|
139
|
+
listJS += `'inline:${key}': () => import('${tmpFile}'),\n`;
|
|
140
|
+
|
|
141
|
+
const fullpath = resolve(result.file.fullpath).replace(/\\/g, '/');
|
|
142
|
+
|
|
143
|
+
if (!listens.includes(fullpath)) {
|
|
144
|
+
listens.push(fullpath);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
listJS += "}";
|
|
149
|
+
|
|
150
|
+
// const loaderPath = resolve('./vendor/windwalker/core/assets/core/src/next/app.ts')
|
|
151
|
+
// .replace(/\\/g, '/');
|
|
152
|
+
//
|
|
153
|
+
// const ts = `
|
|
154
|
+
// import { App } from '${loaderPath}';
|
|
155
|
+
//
|
|
156
|
+
// const app = new App();
|
|
157
|
+
// app.registerRoutes(${listJS});
|
|
158
|
+
//
|
|
159
|
+
// export default app;
|
|
160
|
+
// `;
|
|
161
|
+
|
|
162
|
+
// Listen extra files
|
|
163
|
+
builder.watches.push(...listens);
|
|
164
|
+
|
|
165
|
+
let { code, comments } = stripComments(fs.readFileSync(srcFile, 'utf-8'));
|
|
166
|
+
|
|
167
|
+
// Replace `defineJsModules(...)`
|
|
168
|
+
code = code.replace(/defineJsModules\((.*?)\)/g, listJS);
|
|
169
|
+
|
|
170
|
+
return restoreComments(code, comments);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @see https://github.com/vitejs/vite/issues/6393#issuecomment-1006819717
|
|
179
|
+
* @see https://stackoverflow.com/questions/76259677/vite-dev-server-throws-error-when-resolving-external-path-from-importmap
|
|
180
|
+
*/
|
|
181
|
+
private ignoreMainImport(task: BuildTask) {
|
|
182
|
+
const VALID_ID_PREFIX = `/@id/`;
|
|
183
|
+
const importKeys = ['@main'];
|
|
184
|
+
const reg = new RegExp(
|
|
185
|
+
`${VALID_ID_PREFIX}(${importKeys.join("|")})`,
|
|
186
|
+
"g"
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
addPlugin({
|
|
190
|
+
name: 'keep-main-external-' + task.id,
|
|
191
|
+
transform(code) {
|
|
192
|
+
return reg.test(code) ? code.replace(reg, (m, s1) => s1) : code;
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
preview(): MaybePromise<ProcessorPreview[]> {
|
|
198
|
+
return [];
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
mergeScripts(...patterns: (string | string[])[]) {
|
|
202
|
+
this.scriptPatterns = this.scriptPatterns.concat(patterns.flat());
|
|
203
|
+
|
|
204
|
+
return this;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
parseBlades(...bladePatterns: (string[] | string)[]) {
|
|
208
|
+
this.bladePatterns = this.bladePatterns.concat(bladePatterns.flat());
|
|
209
|
+
|
|
210
|
+
return this;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
stage(stage: string) {
|
|
214
|
+
this.stagePrefix = stage;
|
|
215
|
+
|
|
216
|
+
return this;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
interface ScriptResult {
|
|
221
|
+
as: string;
|
|
222
|
+
file: FindFileResult;
|
|
223
|
+
path: string;
|
|
224
|
+
code: string;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// function parseScriptsFromBlade(file: string, service: Record<string, ParsedModule>): string[] {
|
|
228
|
+
// const bladeText = fs.readFileSync(file, 'utf8');
|
|
229
|
+
//
|
|
230
|
+
// const html = parse(bladeText);
|
|
231
|
+
//
|
|
232
|
+
// return html.querySelectorAll('script[lang]')
|
|
233
|
+
// .filter(
|
|
234
|
+
// (el) => ['ts', 'typescript'].includes(el.getAttribute('lang') || '')
|
|
235
|
+
// )
|
|
236
|
+
// .map((el) => el.innerHTML)
|
|
237
|
+
// .filter((c) => c.trim() !== '');
|
|
238
|
+
// }
|
|
239
|
+
|
|
240
|
+
function parseScriptsFromBlades(patterns: string | string[]): ScriptResult[] {
|
|
241
|
+
let files = findFilesFromGlobArray(Array.isArray(patterns) ? patterns : [patterns]);
|
|
242
|
+
|
|
243
|
+
return files.map((file) => {
|
|
244
|
+
const bladeText = fs.readFileSync(file.fullpath, 'utf8');
|
|
245
|
+
|
|
246
|
+
const html = parse(bladeText);
|
|
247
|
+
// const key = file.relativePath.replace(/.blade.php$/, '').toLowerCase();
|
|
248
|
+
|
|
249
|
+
return html.querySelectorAll('script[lang][data-macro]')
|
|
250
|
+
.filter(
|
|
251
|
+
(el) => ['ts', 'typescript'].includes(el.getAttribute('lang') || '')
|
|
252
|
+
)
|
|
253
|
+
.map((el) => ({
|
|
254
|
+
as: el.getAttribute('data-macro') || '',
|
|
255
|
+
file: file,
|
|
256
|
+
path: file.relativePath.replace(/.blade.php$/, ''),
|
|
257
|
+
code: el.innerHTML
|
|
258
|
+
}))
|
|
259
|
+
.filter((c) => c.code.trim() !== '');
|
|
260
|
+
})
|
|
261
|
+
.flat();
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
type CommentPlaceholder = { key: string; value: string; };
|
|
265
|
+
|
|
266
|
+
function stripComments(code: string): { code: string; comments: CommentPlaceholder[] } {
|
|
267
|
+
const comments: CommentPlaceholder[] = [];
|
|
268
|
+
let i = 0;
|
|
269
|
+
|
|
270
|
+
code = code
|
|
271
|
+
// Multi-line /* */
|
|
272
|
+
.replace(/\/\*[\s\S]*?\*\//g, match => {
|
|
273
|
+
const key = `__COMMENT_BLOCK_${i}__`;
|
|
274
|
+
comments.push({ key, value: match });
|
|
275
|
+
i++;
|
|
276
|
+
return key;
|
|
277
|
+
})
|
|
278
|
+
// Single-line //
|
|
279
|
+
.replace(/\/\/.*$/gm, match => {
|
|
280
|
+
const key = `__COMMENT_LINE_${i}__`;
|
|
281
|
+
comments.push({ key, value: match });
|
|
282
|
+
i++;
|
|
283
|
+
return key;
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
return { code, comments };
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
function restoreComments(code: string, comments: CommentPlaceholder[]): string {
|
|
290
|
+
for (const { key, value } of comments) {
|
|
291
|
+
const re = new RegExp(key, 'g');
|
|
292
|
+
code = code.replace(re, value);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return code;
|
|
296
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import path, { resolve } from 'node:path';
|
|
2
|
+
import { loadJson } from './fs';
|
|
3
|
+
|
|
4
|
+
export function findModules(suffix = '', rootModule: string | null = 'src/Module'): string[] {
|
|
5
|
+
const pkg = path.resolve(process.cwd(), 'composer.json');
|
|
6
|
+
|
|
7
|
+
const pkgJson = loadJson(pkg);
|
|
8
|
+
|
|
9
|
+
const vendors = Object.keys(pkgJson['require'] || {})
|
|
10
|
+
.concat(Object.keys(pkgJson['require-dev'] || {}))
|
|
11
|
+
.map(id => `vendor/${id}/composer.json`)
|
|
12
|
+
.map((file) => loadJson(file))
|
|
13
|
+
.filter(pkgJson => pkgJson?.extra?.windwalker != null)
|
|
14
|
+
.map(pkgJson => {
|
|
15
|
+
return pkgJson?.extra?.windwalker?.modules?.map((module: string) => {
|
|
16
|
+
return `vendor/${pkgJson.name}/${module}/${suffix}`;
|
|
17
|
+
}) || [];
|
|
18
|
+
})
|
|
19
|
+
.flat();
|
|
20
|
+
|
|
21
|
+
if (rootModule) {
|
|
22
|
+
vendors.unshift(rootModule + '/' + suffix);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return [...new Set(vendors)];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function findPackages(suffix = '', withRoot = true): string[] {
|
|
29
|
+
const pkg = path.resolve(process.cwd(), 'composer.json');
|
|
30
|
+
|
|
31
|
+
const pkgJson = loadJson(pkg);
|
|
32
|
+
|
|
33
|
+
const vendors = Object.keys(pkgJson['require'] || {})
|
|
34
|
+
.concat(Object.keys(pkgJson['require-dev'] || {}))
|
|
35
|
+
.map(id => `vendor/${id}/composer.json`)
|
|
36
|
+
.map((file) => loadJson(file))
|
|
37
|
+
.filter((pkgJson) => pkgJson?.extra?.windwalker != null)
|
|
38
|
+
.map((pkgJson) => `vendor/${pkgJson.name}/${suffix}`)
|
|
39
|
+
.flat();
|
|
40
|
+
|
|
41
|
+
if (withRoot) {
|
|
42
|
+
vendors.unshift(suffix);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return [...new Set(vendors)];
|
|
46
|
+
}
|
|
47
|
+
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { getGlobBaseFromPattern } from '@windwalker-io/fusion-next';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import fg from 'fast-glob';
|
|
4
|
+
import isGlob from 'is-glob';
|
|
5
|
+
import { relative } from 'node:path';
|
|
6
|
+
|
|
7
|
+
export function loadJson(file: string) {
|
|
8
|
+
if (!fs.existsSync(file)) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function containsMiddleGlob(str: string) {
|
|
16
|
+
return isGlob(removeLastGlob(str));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function removeLastGlob(str: string) {
|
|
20
|
+
// Remove `/**` `/*` `/**/*` at the end of the string
|
|
21
|
+
return str.replace(/(\/\*|\/\*\*?|\*\*\/\*?)$/, '');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const ds = process.platform === 'win32' ? '\\' : '/';
|
|
25
|
+
|
|
26
|
+
export function ensureDirPath(path: string, slash: '/' | '\\' = ds): string {
|
|
27
|
+
if (!path.endsWith(slash)) {
|
|
28
|
+
return path + slash;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return path;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface FindFileResult {
|
|
35
|
+
fullpath: string;
|
|
36
|
+
relativePath: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function findFilesFromGlobArray(sources: string[]): FindFileResult[] {
|
|
40
|
+
let files: FindFileResult[] = [];
|
|
41
|
+
|
|
42
|
+
for (const source of sources) {
|
|
43
|
+
files = [
|
|
44
|
+
...files,
|
|
45
|
+
...findFiles(source)
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return files;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function findFiles(src: string): FindFileResult[] {
|
|
53
|
+
return fg.globSync(src).map((file: string) => {
|
|
54
|
+
file = file.replace(/\\/g, '/');
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
fullpath: file,
|
|
58
|
+
relativePath: relative(getGlobBaseFromPattern(src), file).replace(/\\/g, '/')
|
|
59
|
+
};
|
|
60
|
+
});
|
|
61
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
|
|
3
|
+
export function resolveModuleRealpath(url: string, module: string) {
|
|
4
|
+
const require = createRequire(url);
|
|
5
|
+
|
|
6
|
+
return require.resolve(module);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function stripUrlQuery(src: string) {
|
|
10
|
+
const qPos = src.indexOf('?');
|
|
11
|
+
|
|
12
|
+
if (qPos !== -1) {
|
|
13
|
+
return src.substring(0, qPos);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return src;
|
|
17
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import vuePlugin from '@vitejs/plugin-vue';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import { rimraf } from 'rimraf';
|
|
5
|
+
import { defineConfig } from 'vite';
|
|
6
|
+
import publicPath from 'vite-plugin-public-path';
|
|
7
|
+
import { injectSystemJS, resolveModuleRealpath, systemCSSFix } from './dist/next';
|
|
8
|
+
|
|
9
|
+
// const dependencies = JSON.parse(readFileSync('./package.json', 'utf8')).dependencies || {};
|
|
10
|
+
|
|
11
|
+
export default defineConfig(({ mode }) => {
|
|
12
|
+
return {
|
|
13
|
+
resolve: {
|
|
14
|
+
alias: {
|
|
15
|
+
'@': resolve('./src')
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
base: '/__vite_base__/',
|
|
19
|
+
build: {
|
|
20
|
+
rollupOptions: {
|
|
21
|
+
input: {
|
|
22
|
+
debugger: './src/debugger/debugger.js',
|
|
23
|
+
console: './scss/debugger-console.scss',
|
|
24
|
+
},
|
|
25
|
+
output: {
|
|
26
|
+
format: 'system',
|
|
27
|
+
inlineDynamicImports: false,
|
|
28
|
+
entryFileNames(chunkInfo) {
|
|
29
|
+
if (chunkInfo.name === 'debugger') {
|
|
30
|
+
return 'debugger.js';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (chunkInfo.name === 'console') {
|
|
34
|
+
return 'debugger-console.css';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return '[name].js';
|
|
38
|
+
},
|
|
39
|
+
chunkFileNames(chunkInfo) {
|
|
40
|
+
return '[name]-[hash].js';
|
|
41
|
+
},
|
|
42
|
+
assetFileNames(assetInfo) {
|
|
43
|
+
if (assetInfo.name === 'console.css') {
|
|
44
|
+
return 'debugger-console.css';
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return '[name][extname]';
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
// preserveEntrySignatures: 'strict',
|
|
51
|
+
// external: []
|
|
52
|
+
},
|
|
53
|
+
outDir: 'dist/debugger',
|
|
54
|
+
emptyOutDir: false,
|
|
55
|
+
minify: mode === 'production',
|
|
56
|
+
},
|
|
57
|
+
css: {
|
|
58
|
+
preprocessorOptions: {
|
|
59
|
+
scss: {
|
|
60
|
+
silenceDeprecations: ['mixed-decls', 'color-functions', 'global-builtin', 'import']
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
plugins: [
|
|
65
|
+
vuePlugin(),
|
|
66
|
+
{
|
|
67
|
+
name: 'custom',
|
|
68
|
+
async buildStart() {
|
|
69
|
+
await rimraf('./dist/debugger');
|
|
70
|
+
},
|
|
71
|
+
writeBundle() {
|
|
72
|
+
fs.moveSync('./dist/debugger/debugger-console.css', './dist/debugger-console.css', { overwrite: true });
|
|
73
|
+
|
|
74
|
+
const systemJSFile = resolveModuleRealpath(import.meta.url, 'systemjs/dist/system.min.js');
|
|
75
|
+
fs.copySync(systemJSFile, './dist/debugger/system.min.js', { overwrite: true });
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
publicPath({
|
|
79
|
+
publicPathExpression: "window.externalPublicPath",
|
|
80
|
+
html: true,
|
|
81
|
+
}),
|
|
82
|
+
systemCSSFix(),
|
|
83
|
+
// injectSystemJS(resolveModuleRealpath(import.meta.url, 'systemjs/dist/system.min.js'))
|
|
84
|
+
// dtsPlugin({
|
|
85
|
+
// outDir: 'dist',
|
|
86
|
+
// // tsconfigPath: './tsconfig.json',
|
|
87
|
+
// insertTypesEntry: true,
|
|
88
|
+
// // merge to 1 file
|
|
89
|
+
// rollupTypes: true,
|
|
90
|
+
// // include: ['./src/next/index.ts'],
|
|
91
|
+
// })
|
|
92
|
+
]
|
|
93
|
+
};
|
|
94
|
+
});
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { defineConfig } from 'vite';
|
|
4
|
+
import dtsPlugin from 'unplugin-dts/vite';
|
|
5
|
+
|
|
6
|
+
const dependencies = JSON.parse(readFileSync('./package.json', 'utf8')).dependencies || {};
|
|
7
|
+
|
|
8
|
+
export default defineConfig(({ mode }) => {
|
|
9
|
+
return {
|
|
10
|
+
resolve: {
|
|
11
|
+
alias: {
|
|
12
|
+
'@': resolve('./src')
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
build: {
|
|
16
|
+
lib: {
|
|
17
|
+
entry: './src/next/index.ts',
|
|
18
|
+
formats: ['es'],
|
|
19
|
+
name: 'next',
|
|
20
|
+
fileName: (format) => `next.js`
|
|
21
|
+
},
|
|
22
|
+
rollupOptions: {
|
|
23
|
+
// input: {
|
|
24
|
+
// next: './src/next/index.ts',
|
|
25
|
+
// },
|
|
26
|
+
output: {
|
|
27
|
+
// format: 'esm',
|
|
28
|
+
// preserveModules: false,
|
|
29
|
+
entryFileNames(chunkInfo) {
|
|
30
|
+
if (chunkInfo.name === 'index') {
|
|
31
|
+
return 'next.js';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return '[name].js';
|
|
35
|
+
},
|
|
36
|
+
assetFileNames(assetInfo) {
|
|
37
|
+
return 'chunks/[name]-[hash].[extname]';
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
preserveEntrySignatures: 'strict',
|
|
41
|
+
external: [
|
|
42
|
+
/^node:/,
|
|
43
|
+
/fusion-next/,
|
|
44
|
+
'rollup',
|
|
45
|
+
'vite',
|
|
46
|
+
'fast-glob',
|
|
47
|
+
'fs-extra',
|
|
48
|
+
'micromatch',
|
|
49
|
+
'is-glob',
|
|
50
|
+
...Object.keys(dependencies),
|
|
51
|
+
// 'util',
|
|
52
|
+
// 'stream',
|
|
53
|
+
// 'fs',
|
|
54
|
+
// 'os',
|
|
55
|
+
// 'path',
|
|
56
|
+
// 'path',
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
outDir: 'dist',
|
|
60
|
+
emptyOutDir: false,
|
|
61
|
+
minify: false,
|
|
62
|
+
},
|
|
63
|
+
plugins: [
|
|
64
|
+
dtsPlugin({
|
|
65
|
+
outDirs: 'dist',
|
|
66
|
+
tsconfigPath: './tsconfig.json',
|
|
67
|
+
insertTypesEntry: true,
|
|
68
|
+
// merge to 1 file
|
|
69
|
+
bundleTypes: true,
|
|
70
|
+
exclude: ['./src/*.mjs']
|
|
71
|
+
// include: ['./src/next/index.ts'],
|
|
72
|
+
}),
|
|
73
|
+
]
|
|
74
|
+
};
|
|
75
|
+
});
|
package/.gulp.json
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(self.webpackChunksrc_debugger_debugger_js=self.webpackChunksrc_debugger_debugger_js||[]).push([[100],{9665:function(t){t.exports=function(){"use strict";var t=6e4,e=36e5,n="millisecond",r="second",s="minute",i="hour",a="day",u="week",c="month",o="quarter",l="year",d="date",f="Invalid Date",h=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,$=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return"["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},_={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),s=n%60;return(e<=0?"+":"-")+m(r,2,"0")+":"+m(s,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),s=e.clone().add(r,c),i=n-s<0,a=e.clone().add(r+(i?-1:1),c);return+(-(r+(n-s)/(i?s-a:a-s))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:c,y:l,w:u,d:a,D:d,h:i,m:s,s:r,ms:n,Q:o}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},v="en",y={};y[v]=g;var M="$isDayjsObject",b=function(t){return t instanceof w||!(!t||!t[M])},D=function t(e,n,r){var s;if(!e)return v;if("string"==typeof e){var i=e.toLowerCase();y[i]&&(s=i),n&&(y[i]=n,s=i);var a=e.split("-");if(!s&&a.length>1)return t(a[0])}else{var u=e.name;y[u]=e,s=u}return!r&&s&&(v=s),s||!r&&v},k=function(t,e){if(b(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new w(n)},p=_;p.l=D,p.i=b,p.w=function(t,e){return k(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var w=function(){function g(t){this.$L=D(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[M]=!0}var m=g.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(p.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match(h);if(r){var s=r[2]-1||0,i=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],s,r[3]||1,r[4]||0,r[5]||0,r[6]||0,i)):new Date(r[1],s,r[3]||1,r[4]||0,r[5]||0,r[6]||0,i)}}return new Date(e)}(t),this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return p},m.isValid=function(){return!(this.$d.toString()===f)},m.isSame=function(t,e){var n=k(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return k(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<k(t)},m.$g=function(t,e,n){return p.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,o=!!p.u(e)||e,f=p.p(t),h=function(t,e){var r=p.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return o?r:r.endOf(a)},$=function(t,e){return p.w(n.toDate()[t].apply(n.toDate("s"),(o?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},g=this.$W,m=this.$M,_=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case l:return o?h(1,0):h(31,11);case c:return o?h(1,m):h(0,m+1);case u:var y=this.$locale().weekStart||0,M=(g<y?g+7:g)-y;return h(o?_-M:_+(6-M),m);case a:case d:return $(v+"Hours",0);case i:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case r:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var u,o=p.p(t),f="set"+(this.$u?"UTC":""),h=(u={},u[a]=f+"Date",u[d]=f+"Date",u[c]=f+"Month",u[l]=f+"FullYear",u[i]=f+"Hours",u[s]=f+"Minutes",u[r]=f+"Seconds",u[n]=f+"Milliseconds",u)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===l){var g=this.clone().set(d,1);g.$d[h]($),g.init(),this.$d=g.set(d,Math.min(this.$D,g.daysInMonth())).$d}else h&&this.$d[h]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[p.p(t)]()},m.add=function(n,o){var d,f=this;n=Number(n);var h=p.p(o),$=function(t){var e=k(f);return p.w(e.date(e.date()+Math.round(t*n)),f)};if(h===c)return this.set(c,this.$M+n);if(h===l)return this.set(l,this.$y+n);if(h===a)return $(1);if(h===u)return $(7);var g=(d={},d[s]=t,d[i]=e,d[r]=1e3,d)[h]||1,m=this.$d.getTime()+n*g;return p.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||f;var r=t||"YYYY-MM-DDTHH:mm:ssZ",s=p.z(this),i=this.$H,a=this.$m,u=this.$M,c=n.weekdays,o=n.months,l=n.meridiem,d=function(t,n,s,i){return t&&(t[n]||t(e,r))||s[n].slice(0,i)},h=function(t){return p.s(i%12||12,t,"0")},g=l||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace($,(function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return p.s(e.$y,4,"0");case"M":return u+1;case"MM":return p.s(u+1,2,"0");case"MMM":return d(n.monthsShort,u,o,3);case"MMMM":return d(o,u);case"D":return e.$D;case"DD":return p.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return d(n.weekdaysMin,e.$W,c,2);case"ddd":return d(n.weekdaysShort,e.$W,c,3);case"dddd":return c[e.$W];case"H":return String(i);case"HH":return p.s(i,2,"0");case"h":return h(1);case"hh":return h(2);case"a":return g(i,a,!0);case"A":return g(i,a,!1);case"m":return String(a);case"mm":return p.s(a,2,"0");case"s":return String(e.$s);case"ss":return p.s(e.$s,2,"0");case"SSS":return p.s(e.$ms,3,"0");case"Z":return s}return null}(t)||s.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(n,d,f){var h,$=this,g=p.p(d),m=k(n),_=(m.utcOffset()-this.utcOffset())*t,v=this-m,y=function(){return p.m($,m)};switch(g){case l:h=y()/12;break;case c:h=y();break;case o:h=y()/3;break;case u:h=(v-_)/6048e5;break;case a:h=(v-_)/864e5;break;case i:h=v/e;break;case s:h=v/t;break;case r:h=v/1e3;break;default:h=v}return f?h:p.a(h)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return y[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=D(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return p.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},g}(),S=w.prototype;return k.prototype=S,[["$ms",n],["$s",r],["$m",s],["$H",i],["$W",a],["$M",c],["$y",l],["$D",d]].forEach((function(t){S[t[1]]=function(e){return this.$g(e,t[0],t[1])}})),k.extend=function(t,e){return t.$i||(t(e,w,k),t.$i=!0),k},k.locale=D,k.isDayjs=b,k.unix=function(t){return k(1e3*t)},k.en=y[v],k.Ls=y,k.p={},k}()},2100:(t,e,n)=>{"use strict";n.r(e),n.d(e,{default:()=>y});var r=n(1525),s=n(1456),i=n(3630),a=n(672),u=n(9665),c=n(8601),o=n(363),l=(n(4545),n(7297));const d={class:"p-4"},f={class:"table table-striped table-bordered"},h=(0,r._)("thead",{class:"table-dark"},[(0,r._)("tr",null,[(0,r._)("th",null,"\r\n ID\r\n "),(0,r.Uk)(),(0,r._)("th",null,"\r\n See\r\n "),(0,r.Uk)(),(0,r._)("th",null,"\r\n IP\r\n "),(0,r.Uk)(),(0,r._)("th",null,"\r\n Method\r\n "),(0,r.Uk)(),(0,r._)("th",null,"\r\n URL\r\n "),(0,r.Uk)(),(0,r._)("th",null,"\r\n Time\r\n "),(0,r.Uk)(),(0,r._)("th",null,"\r\n Info\r\n ")])],-1),$=["onClick"],g=["onClick"],m={key:0,class:"badge bg-danger"},_={style:{"word-break":"break-all"}},v=["href"],y={__name:"Dashboard",setup(t){(0,a.qj)({items:[]});const e=(0,a.iH)([]);function n(t){c.Z.push("/system/"+t)}return(0,r.bv)((async()=>{const t=await o.Z.get("ajax/history");e.value=t.data.data})),(t,c)=>{const o=(0,r.up)("fa-icon");return(0,r.wg)(),(0,r.iD)("div",d,[(0,r._)("table",f,[h,(0,r.Uk)(),(0,r._)("tbody",null,[((0,r.wg)(!0),(0,r.iD)(r.HY,null,(0,r.Ko)(e.value,(t=>{var e,c,d;return(0,r.wg)(),(0,r.iD)("tr",null,[(0,r._)("td",null,[(0,r._)("a",{href:"#",onClick:(0,s.iM)((e=>n(t.id)),["prevent"]),class:""},(0,i.zw)(t.id),9,$)]),(0,r.Uk)(),(0,r._)("td",null,[(0,r._)("button",{class:"btn btn-primary btn-sm",type:"button",onClick:e=>n(t.id)},[(0,r.Wm)(o,{icon:"fa-solid fa-eye"})],8,g)]),(0,r.Uk)(),(0,r._)("td",null,(0,i.zw)(t.ip),1),(0,r.Uk)(),(0,r._)("td",null,[(0,r._)("div",null,(0,i.zw)(t.method),1),(0,r.Uk)(),(0,r._)("div",null,[t.ajax?((0,r.wg)(),(0,r.iD)("span",m,"\r\n AJAX | API\r\n ")):(0,r.kq)("",!0)])]),(0,r.Uk)(),(0,r._)("td",_,[(0,r._)("a",{href:t.url,target:"_blank",class:"link-secondary"},[(0,r.Uk)((0,i.zw)(t.url)+" ",1),(0,r.Wm)(o,{class:"small",icon:"fa-solid fa-external-link"})],8,v)]),(0,r.Uk)(),(0,r._)("td",null,(0,i.zw)((d=t.time,u.unix(d).format("YYYY-MM-DD HH:mm:ssZ"))),1),(0,r.Uk)(),(0,r._)("td",null,[(0,r._)("span",{class:(0,i.C_)(["badge",`bg-${(0,a.SU)(l.e)((null===(e=t.response)||void 0===e?void 0:e.status)||0)}`])},(0,i.zw)(null===(c=t.response)||void 0===c?void 0:c.status),3)])])})),256))])])])}}}},7297:(t,e,n)=>{"use strict";function r(t,e){return t>2*e?"danger":t>1.5*e?"warning":t<e/2?"success":"info"}function s(t){return t>=300&&t<400?"info":t>=400&&t<500?"warning":t>=200&&t<300?"success":"danger"}n.d(e,{G:()=>r,e:()=>s})}}]);
|
|
2
|
-
//# sourceMappingURL=100.js.map
|