@windwalker-io/core 4.1.12 → 4.2.1
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/dist/debugger/Dashboard-CQHU0d2H.js +1 -0
- package/dist/debugger/Database-VIM7Qa1v.js +36 -0
- package/dist/debugger/DefaultLayout-B32TQLQX.js +1 -0
- package/dist/debugger/Events-CUBbmkGz.js +1 -0
- package/dist/debugger/KeyValueTable-CQHDOoM1.js +1 -0
- package/dist/debugger/Request-aNwJ2Iha.js +1 -0
- package/dist/debugger/Routing-D8BolD7h.js +1 -0
- package/dist/debugger/System-DGIjiMcw.js +1 -0
- package/dist/debugger/Timeline-Bj8IvPmS.js +1 -0
- package/dist/debugger/debugger-ChQADeB6.js +2 -0
- package/dist/debugger/debugger.js +564 -3
- package/dist/debugger/system.min.js +5 -0
- package/dist/debugger/utilities-jMzguz3m.js +1 -0
- package/dist/debugger/vue-animate.min-BkEL-t1R.js +9 -0
- package/dist/debugger-console.css +6 -2
- package/dist/next.d.ts +98 -0
- package/dist/next.js +537 -0
- package/package.json +74 -56
- 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/debugger/Store.vue +1 -1
- package/src/debugger/debugger.js +3 -5
- package/src/index.mjs +2 -0
- 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/.gulp.json +0 -7
- package/bin/release.js +0 -47
- 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.LICENSE.txt +0 -13
- package/dist/debugger/main.js.map +0 -1
- 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/postcss.config.cjs +0 -12
- package/src/debugger/webpack.config.js +0 -9
- package/tailwind/console.tailwind.config.cjs +0 -32
- package/tailwind.config.cjs +0 -30
package/dist/next.js
ADDED
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
import { getGlobBaseFromPattern, callback, css, js, shortHash, plugin, callbackAfterBuild, copyGlob, symlink } from "@windwalker-io/fusion-next";
|
|
2
|
+
import isGlob from "is-glob";
|
|
3
|
+
import micromatch from "micromatch";
|
|
4
|
+
import path, { relative, normalize, resolve } from "node:path";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import fg from "fast-glob";
|
|
7
|
+
import crypto, { randomBytes } from "node:crypto";
|
|
8
|
+
import { createRequire } from "node:module";
|
|
9
|
+
import fs$1 from "fs-extra";
|
|
10
|
+
import { parse } from "node-html-parser";
|
|
11
|
+
function loadJson(file) {
|
|
12
|
+
if (!fs.existsSync(file)) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return JSON.parse(fs.readFileSync(file, "utf8"));
|
|
16
|
+
}
|
|
17
|
+
function containsMiddleGlob(str) {
|
|
18
|
+
return isGlob(removeLastGlob(str));
|
|
19
|
+
}
|
|
20
|
+
function removeLastGlob(str) {
|
|
21
|
+
return str.replace(/(\/\*|\/\*\*?|\*\*\/\*?)$/, "");
|
|
22
|
+
}
|
|
23
|
+
const ds = process.platform === "win32" ? "\\" : "/";
|
|
24
|
+
function ensureDirPath(path2, slash = ds) {
|
|
25
|
+
if (!path2.endsWith(slash)) {
|
|
26
|
+
return path2 + slash;
|
|
27
|
+
}
|
|
28
|
+
return path2;
|
|
29
|
+
}
|
|
30
|
+
function findFilesFromGlobArray(sources) {
|
|
31
|
+
let files = [];
|
|
32
|
+
for (const source of sources) {
|
|
33
|
+
files = [
|
|
34
|
+
...files,
|
|
35
|
+
...findFiles(source)
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
return files;
|
|
39
|
+
}
|
|
40
|
+
function findFiles(src) {
|
|
41
|
+
return fg.globSync(src).map((file) => {
|
|
42
|
+
file = file.replace(/\\/g, "/");
|
|
43
|
+
return {
|
|
44
|
+
fullpath: file,
|
|
45
|
+
relativePath: relative(getGlobBaseFromPattern(src), file).replace(/\\/g, "/")
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function findModules(suffix = "", rootModule = "src/Module") {
|
|
50
|
+
const pkg = path.resolve(process.cwd(), "composer.json");
|
|
51
|
+
const pkgJson = loadJson(pkg);
|
|
52
|
+
const vendors = Object.keys(pkgJson["require"] || {}).concat(Object.keys(pkgJson["require-dev"] || {})).map((id) => `vendor/${id}/composer.json`).map((file) => loadJson(file)).filter((pkgJson2) => pkgJson2?.extra?.windwalker != null).map((pkgJson2) => {
|
|
53
|
+
return pkgJson2?.extra?.windwalker?.modules?.map((module) => {
|
|
54
|
+
return `vendor/${pkgJson2.name}/${module}/${suffix}`;
|
|
55
|
+
}) || [];
|
|
56
|
+
}).flat();
|
|
57
|
+
if (rootModule) {
|
|
58
|
+
vendors.unshift(rootModule + "/" + suffix);
|
|
59
|
+
}
|
|
60
|
+
return [...new Set(vendors)];
|
|
61
|
+
}
|
|
62
|
+
function findPackages(suffix = "", withRoot = true) {
|
|
63
|
+
const pkg = path.resolve(process.cwd(), "composer.json");
|
|
64
|
+
const pkgJson = loadJson(pkg);
|
|
65
|
+
const vendors = Object.keys(pkgJson["require"] || {}).concat(Object.keys(pkgJson["require-dev"] || {})).map((id) => `vendor/${id}/composer.json`).map((file) => loadJson(file)).filter((pkgJson2) => pkgJson2?.extra?.windwalker != null).map((pkgJson2) => `vendor/${pkgJson2.name}/${suffix}`).flat();
|
|
66
|
+
if (withRoot) {
|
|
67
|
+
vendors.unshift(suffix);
|
|
68
|
+
}
|
|
69
|
+
return [...new Set(vendors)];
|
|
70
|
+
}
|
|
71
|
+
function uniqId(prefix = "", size = 16) {
|
|
72
|
+
let id = randomBytes(size).toString("hex");
|
|
73
|
+
if (prefix) {
|
|
74
|
+
id = prefix + id;
|
|
75
|
+
}
|
|
76
|
+
return id;
|
|
77
|
+
}
|
|
78
|
+
function resolveModuleRealpath(url, module) {
|
|
79
|
+
const require2 = createRequire(url);
|
|
80
|
+
return require2.resolve(module);
|
|
81
|
+
}
|
|
82
|
+
function stripUrlQuery(src) {
|
|
83
|
+
const qPos = src.indexOf("?");
|
|
84
|
+
if (qPos !== -1) {
|
|
85
|
+
return src.substring(0, qPos);
|
|
86
|
+
}
|
|
87
|
+
return src;
|
|
88
|
+
}
|
|
89
|
+
function cloneAssets(patterns) {
|
|
90
|
+
return callback((taskName, builder) => {
|
|
91
|
+
const reposition = getAvailableForReposition(patterns);
|
|
92
|
+
handleReposition(builder, reposition);
|
|
93
|
+
handleCloneAssets(builder, Object.keys(patterns));
|
|
94
|
+
return null;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function getAvailableForReposition(patterns) {
|
|
98
|
+
const reposition = {};
|
|
99
|
+
for (const from in patterns) {
|
|
100
|
+
if (!containsMiddleGlob(from)) {
|
|
101
|
+
reposition[from] = patterns[from];
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return reposition;
|
|
105
|
+
}
|
|
106
|
+
function handleCloneAssets(builder, clonePatterns) {
|
|
107
|
+
const id = uniqId("hidden:clone-asset-") + ".js";
|
|
108
|
+
builder.addTask(id);
|
|
109
|
+
builder.resolveIdCallbacks.push((src) => {
|
|
110
|
+
if (src === id) {
|
|
111
|
+
return id;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
builder.loadCallbacks.push((src) => {
|
|
115
|
+
if (src === id) {
|
|
116
|
+
const glob = clonePatterns.map((v) => v.replace(/\\/g, "/")).map((v) => v.startsWith("./") || !v.startsWith("/") ? `/${v}` : v).map((v) => `'${v}'`).join(", ");
|
|
117
|
+
return `import.meta.glob(${glob});
|
|
118
|
+
`;
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function handleReposition(builder, reposition) {
|
|
123
|
+
builder.assetFileNamesCallbacks.push((assetInfo) => {
|
|
124
|
+
const fileName = assetInfo.originalFileName;
|
|
125
|
+
for (const base in reposition) {
|
|
126
|
+
if (match(fileName, base)) {
|
|
127
|
+
return normalize(reposition[base] + relative(removeLastGlob(base), fileName)).replace(/\\/g, "/");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function match(str, pattern) {
|
|
133
|
+
if (isGlob(pattern)) {
|
|
134
|
+
return micromatch.isMatch(str, pattern);
|
|
135
|
+
}
|
|
136
|
+
return str.startsWith(pattern);
|
|
137
|
+
}
|
|
138
|
+
function globalAssets(options) {
|
|
139
|
+
return {
|
|
140
|
+
name: "core:global-assets",
|
|
141
|
+
buildConfig(builder) {
|
|
142
|
+
const clone = options.clone || {};
|
|
143
|
+
let reposition = options.reposition || {};
|
|
144
|
+
reposition = { ...reposition, ...getAvailableForReposition(clone) };
|
|
145
|
+
handleReposition(builder, reposition);
|
|
146
|
+
const clonePatterns = Object.keys(clone);
|
|
147
|
+
if (clonePatterns.length > 0) {
|
|
148
|
+
handleCloneAssets(builder, clonePatterns);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function injectSystemJS(systemPath, filter) {
|
|
154
|
+
systemPath ??= resolve("node_modules/systemjs/dist/system.min.js");
|
|
155
|
+
return {
|
|
156
|
+
name: "core:inject-systemjs",
|
|
157
|
+
async generateBundle(options, bundle) {
|
|
158
|
+
if (options.format !== "system") {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const systemjsCode = fs$1.readFileSync(
|
|
162
|
+
resolve(systemPath),
|
|
163
|
+
"utf-8"
|
|
164
|
+
);
|
|
165
|
+
for (const file of Object.values(bundle)) {
|
|
166
|
+
if (filter && !filter(file)) {
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
if (file.type === "chunk" && file.isEntry && file.fileName.endsWith(".js")) {
|
|
170
|
+
file.code = systemjsCode + "\n" + file.code;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function systemCSSFix() {
|
|
177
|
+
return {
|
|
178
|
+
name: "core:systemjs-css-fix",
|
|
179
|
+
async generateBundle(options, bundle) {
|
|
180
|
+
if (options.format !== "system") {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
for (const [fileName, chunk] of Object.entries(bundle)) {
|
|
184
|
+
if (fileName.endsWith(".css") && "code" in chunk) {
|
|
185
|
+
const regex = /__vite_style__\.textContent\s*=\s*"([\s\S]*?)";/;
|
|
186
|
+
let match2 = chunk.code.match(regex);
|
|
187
|
+
if (!match2) {
|
|
188
|
+
const regex2 = /\.textContent\s*=\s*`([\s\S]*?)`/;
|
|
189
|
+
match2 = chunk.code.match(regex2);
|
|
190
|
+
}
|
|
191
|
+
if (match2 && match2[1]) {
|
|
192
|
+
chunk.code = match2[1].replace(/\\"/g, '"').replace(/\\n/g, "\n").replace(/\\t/g, " ").replace(/\\\\/g, "\\").replace(/\/\*\$vite\$:\d+\*\/$/, "");
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
function cssModulize(entry, dest) {
|
|
200
|
+
return new CssModulizeProcessor(css(entry, dest));
|
|
201
|
+
}
|
|
202
|
+
class CssModulizeProcessor {
|
|
203
|
+
constructor(processor, bladePatterns = [], cssPatterns = []) {
|
|
204
|
+
this.processor = processor;
|
|
205
|
+
this.bladePatterns = bladePatterns;
|
|
206
|
+
this.cssPatterns = cssPatterns;
|
|
207
|
+
}
|
|
208
|
+
parseBlades(...bladePatterns) {
|
|
209
|
+
this.bladePatterns = this.bladePatterns.concat(bladePatterns.flat());
|
|
210
|
+
return this;
|
|
211
|
+
}
|
|
212
|
+
mergeCss(...css2) {
|
|
213
|
+
this.cssPatterns = this.cssPatterns.concat(css2.flat());
|
|
214
|
+
return this;
|
|
215
|
+
}
|
|
216
|
+
config(taskName, builder) {
|
|
217
|
+
const tasks = this.processor.config(taskName, builder);
|
|
218
|
+
const task = tasks[0];
|
|
219
|
+
const inputFile = resolve(task.input);
|
|
220
|
+
const bladeFiles = fg.globSync(this.bladePatterns);
|
|
221
|
+
for (const file of bladeFiles) {
|
|
222
|
+
builder.watches.push({
|
|
223
|
+
file,
|
|
224
|
+
moduleFile: inputFile,
|
|
225
|
+
updateType: "css-update"
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
builder.loadCallbacks.push((src, options) => {
|
|
229
|
+
const file = stripUrlQuery(src);
|
|
230
|
+
if (normalize(file) === inputFile) {
|
|
231
|
+
const patterns = fg.globSync(
|
|
232
|
+
this.cssPatterns.map((v) => resolve(v)).map((v) => v.replace(/\\/g, "/"))
|
|
233
|
+
);
|
|
234
|
+
const imports = patterns.map((pattern) => `@import "${pattern}";`).concat(this.parseStylesFromBlades(bladeFiles)).join("\n");
|
|
235
|
+
let main = fs$1.readFileSync(file, "utf-8");
|
|
236
|
+
main += `
|
|
237
|
+
|
|
238
|
+
${imports}
|
|
239
|
+
`;
|
|
240
|
+
return main;
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
return void 0;
|
|
244
|
+
}
|
|
245
|
+
parseStylesFromBlades(files) {
|
|
246
|
+
return files.map((file) => {
|
|
247
|
+
const bladeText = fs$1.readFileSync(file, "utf8");
|
|
248
|
+
const html = parse(bladeText);
|
|
249
|
+
return html.querySelectorAll("style[type][data-macro],script[type][data-macro]").filter(
|
|
250
|
+
(el) => ["text/scss", "text/css"].includes(el.getAttribute("type") || "")
|
|
251
|
+
).map((el) => {
|
|
252
|
+
const scope = el.getAttribute("data-scope");
|
|
253
|
+
if (scope) {
|
|
254
|
+
return `${scope} {
|
|
255
|
+
${el.innerHTML}
|
|
256
|
+
}`;
|
|
257
|
+
} else {
|
|
258
|
+
return el.innerHTML;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
}).filter((c) => c.length > 0).flat();
|
|
262
|
+
}
|
|
263
|
+
preview() {
|
|
264
|
+
return [];
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
function jsModulize(entry, dest, options = {}) {
|
|
268
|
+
return new JsModulizeProcessor(js(entry, dest), options);
|
|
269
|
+
}
|
|
270
|
+
class JsModulizeProcessor {
|
|
271
|
+
constructor(processor, options = {}) {
|
|
272
|
+
this.processor = processor;
|
|
273
|
+
this.options = options;
|
|
274
|
+
}
|
|
275
|
+
scriptPatterns = [];
|
|
276
|
+
bladePatterns = [];
|
|
277
|
+
stagePrefix = "";
|
|
278
|
+
config(taskName, builder) {
|
|
279
|
+
const tasks = this.processor.config(taskName, builder);
|
|
280
|
+
const task = tasks[0];
|
|
281
|
+
const inputFile = resolve(task.input);
|
|
282
|
+
const tmpPath = this.options.tmpPath ?? resolve("./tmp/fusion/jsmodules/").replace(/\\/g, "/");
|
|
283
|
+
const clean = this.options.cleanTmp ?? true;
|
|
284
|
+
if (clean) {
|
|
285
|
+
builder.postBuildCallbacks.push((options, bundle) => {
|
|
286
|
+
fs$1.removeSync(tmpPath);
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
this.ignoreMainImport(task);
|
|
290
|
+
builder.resolveIdCallbacks.push((id) => {
|
|
291
|
+
if (id === "@main") {
|
|
292
|
+
return { id, external: true };
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
const scriptFiles = findFilesFromGlobArray(this.scriptPatterns);
|
|
296
|
+
const bladeFiles = parseScriptsFromBlades(this.bladePatterns);
|
|
297
|
+
builder.loadCallbacks.push((src, options) => {
|
|
298
|
+
const srcFile = stripUrlQuery(src);
|
|
299
|
+
if (normalize(srcFile) === inputFile) {
|
|
300
|
+
let listJS = "{\n";
|
|
301
|
+
for (const scriptFile of scriptFiles) {
|
|
302
|
+
let fullpath = scriptFile.fullpath;
|
|
303
|
+
if (fullpath.endsWith(".d.ts")) {
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
let key = scriptFile.relativePath.replace(/assets\//, "").toLowerCase();
|
|
307
|
+
fullpath = resolve(fullpath).replace(/\\/g, "/");
|
|
308
|
+
key = key.substring(0, key.lastIndexOf("."));
|
|
309
|
+
if (this.stagePrefix) {
|
|
310
|
+
key = this.stagePrefix + "/" + key;
|
|
311
|
+
}
|
|
312
|
+
key = "view:" + crypto.createHash("md5").update(key).digest("hex");
|
|
313
|
+
listJS += `'${key}': () => import('${fullpath}'),
|
|
314
|
+
`;
|
|
315
|
+
}
|
|
316
|
+
const listens = [];
|
|
317
|
+
fs$1.ensureDirSync(tmpPath);
|
|
318
|
+
for (const result of bladeFiles) {
|
|
319
|
+
let key = result.as;
|
|
320
|
+
const tmpFile = tmpPath + "/" + result.path.replace(/\\|\//g, "_") + "-" + shortHash(result.code) + ".ts";
|
|
321
|
+
if (!fs$1.existsSync(tmpFile) || fs$1.readFileSync(tmpFile, "utf8") !== result.code) {
|
|
322
|
+
fs$1.writeFileSync(tmpFile, result.code);
|
|
323
|
+
}
|
|
324
|
+
listJS += `'inline:${key}': () => import('${tmpFile}'),
|
|
325
|
+
`;
|
|
326
|
+
const fullpath = resolve(result.file.fullpath).replace(/\\/g, "/");
|
|
327
|
+
if (!listens.includes(fullpath)) {
|
|
328
|
+
listens.push(fullpath);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
listJS += "}";
|
|
332
|
+
builder.watches.push(...listens);
|
|
333
|
+
let { code, comments } = stripComments(fs$1.readFileSync(srcFile, "utf-8"));
|
|
334
|
+
code = code.replace(/defineJsModules\((.*?)\)/g, listJS);
|
|
335
|
+
return restoreComments(code, comments);
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
return void 0;
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* @see https://github.com/vitejs/vite/issues/6393#issuecomment-1006819717
|
|
342
|
+
* @see https://stackoverflow.com/questions/76259677/vite-dev-server-throws-error-when-resolving-external-path-from-importmap
|
|
343
|
+
*/
|
|
344
|
+
ignoreMainImport(task) {
|
|
345
|
+
const VALID_ID_PREFIX = `/@id/`;
|
|
346
|
+
const importKeys = ["@main"];
|
|
347
|
+
const reg = new RegExp(
|
|
348
|
+
`${VALID_ID_PREFIX}(${importKeys.join("|")})`,
|
|
349
|
+
"g"
|
|
350
|
+
);
|
|
351
|
+
plugin({
|
|
352
|
+
name: "keep-main-external-" + task.id,
|
|
353
|
+
transform(code) {
|
|
354
|
+
return reg.test(code) ? code.replace(reg, (m, s1) => s1) : code;
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
preview() {
|
|
359
|
+
return [];
|
|
360
|
+
}
|
|
361
|
+
mergeScripts(...patterns) {
|
|
362
|
+
this.scriptPatterns = this.scriptPatterns.concat(patterns.flat());
|
|
363
|
+
return this;
|
|
364
|
+
}
|
|
365
|
+
parseBlades(...bladePatterns) {
|
|
366
|
+
this.bladePatterns = this.bladePatterns.concat(bladePatterns.flat());
|
|
367
|
+
return this;
|
|
368
|
+
}
|
|
369
|
+
stage(stage) {
|
|
370
|
+
this.stagePrefix = stage;
|
|
371
|
+
return this;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function parseScriptsFromBlades(patterns) {
|
|
375
|
+
let files = findFilesFromGlobArray(Array.isArray(patterns) ? patterns : [patterns]);
|
|
376
|
+
return files.map((file) => {
|
|
377
|
+
const bladeText = fs$1.readFileSync(file.fullpath, "utf8");
|
|
378
|
+
const html = parse(bladeText);
|
|
379
|
+
return html.querySelectorAll("script[lang][data-macro]").filter(
|
|
380
|
+
(el) => ["ts", "typescript"].includes(el.getAttribute("lang") || "")
|
|
381
|
+
).map((el) => ({
|
|
382
|
+
as: el.getAttribute("data-macro") || "",
|
|
383
|
+
file,
|
|
384
|
+
path: file.relativePath.replace(/.blade.php$/, ""),
|
|
385
|
+
code: el.innerHTML
|
|
386
|
+
})).filter((c) => c.code.trim() !== "");
|
|
387
|
+
}).flat();
|
|
388
|
+
}
|
|
389
|
+
function stripComments(code) {
|
|
390
|
+
const comments = [];
|
|
391
|
+
let i = 0;
|
|
392
|
+
code = code.replace(/\/\*[\s\S]*?\*\//g, (match2) => {
|
|
393
|
+
const key = `__COMMENT_BLOCK_${i}__`;
|
|
394
|
+
comments.push({ key, value: match2 });
|
|
395
|
+
i++;
|
|
396
|
+
return key;
|
|
397
|
+
}).replace(/\/\/.*$/gm, (match2) => {
|
|
398
|
+
const key = `__COMMENT_LINE_${i}__`;
|
|
399
|
+
comments.push({ key, value: match2 });
|
|
400
|
+
i++;
|
|
401
|
+
return key;
|
|
402
|
+
});
|
|
403
|
+
return { code, comments };
|
|
404
|
+
}
|
|
405
|
+
function restoreComments(code, comments) {
|
|
406
|
+
for (const { key, value } of comments) {
|
|
407
|
+
const re = new RegExp(key, "g");
|
|
408
|
+
code = code.replace(re, value);
|
|
409
|
+
}
|
|
410
|
+
return code;
|
|
411
|
+
}
|
|
412
|
+
function installVendors(npmVendors = [], to = "www/assets/vendor") {
|
|
413
|
+
return callbackAfterBuild(() => findAndInstall(npmVendors, to));
|
|
414
|
+
}
|
|
415
|
+
async function findAndInstall(npmVendors = [], to = "www/assets/vendor") {
|
|
416
|
+
const root = to;
|
|
417
|
+
let vendors = npmVendors;
|
|
418
|
+
const action = process.env.INSTALL_VENDOR === "hard" ? "Copy" : "Link";
|
|
419
|
+
console.log("");
|
|
420
|
+
if (!fs$1.existsSync(root)) {
|
|
421
|
+
fs$1.mkdirSync(root);
|
|
422
|
+
}
|
|
423
|
+
const dirs = fs$1.readdirSync(root, { withFileTypes: true }).filter((d) => d.isDirectory()).map((dir) => path.join(root, dir.name));
|
|
424
|
+
dirs.unshift(root);
|
|
425
|
+
dirs.forEach((dir) => {
|
|
426
|
+
deleteExists(dir);
|
|
427
|
+
});
|
|
428
|
+
const composerJsons = getInstalledComposerVendors().map((cv) => `vendor/${cv}/composer.json`).map((file) => loadJson(file)).filter((composerJson) => composerJson?.extra?.windwalker != null);
|
|
429
|
+
vendors = findNpmVendors(composerJsons).concat(vendors);
|
|
430
|
+
vendors = [...new Set(vendors)];
|
|
431
|
+
for (const vendor of vendors) {
|
|
432
|
+
const source = `node_modules/${vendor}/`;
|
|
433
|
+
if (fs$1.existsSync(source)) {
|
|
434
|
+
console.log(`[${action} NPM] node_modules/${vendor}/ => ${root}/${vendor}/`);
|
|
435
|
+
doInstall(source, `${root}/${vendor}/`);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
for (const composerJson of composerJsons) {
|
|
439
|
+
const vendorName = composerJson.name;
|
|
440
|
+
let assets = composerJson?.extra?.windwalker?.assets?.link;
|
|
441
|
+
if (!assets) {
|
|
442
|
+
continue;
|
|
443
|
+
}
|
|
444
|
+
if (!assets.endsWith("/")) {
|
|
445
|
+
assets += "/";
|
|
446
|
+
}
|
|
447
|
+
if (fs$1.existsSync(`vendor/${vendorName}/${assets}`)) {
|
|
448
|
+
console.log(`[${action} Composer] vendor/${vendorName}/${assets} => ${root}/${vendorName}/`);
|
|
449
|
+
doInstall(`vendor/${vendorName}/${assets}`, `${root}/${vendorName}/`);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
const staticVendorDir = "resources/assets/vendor/";
|
|
453
|
+
if (fs$1.existsSync(staticVendorDir)) {
|
|
454
|
+
const staticVendors = fs$1.readdirSync(staticVendorDir);
|
|
455
|
+
for (const staticVendor of staticVendors) {
|
|
456
|
+
if (staticVendor.startsWith("@")) {
|
|
457
|
+
const subVendors = fs$1.readdirSync(staticVendorDir + staticVendor);
|
|
458
|
+
for (const subVendor of subVendors) {
|
|
459
|
+
const subVendorName = staticVendor + "/" + subVendor;
|
|
460
|
+
const source = staticVendorDir + subVendorName + "/";
|
|
461
|
+
if (fs$1.existsSync(source)) {
|
|
462
|
+
console.log(`[${action} Local] resources/assets/vendor/${subVendorName}/ => ${root}/${subVendorName}/`);
|
|
463
|
+
doInstall(source, `${root}/${subVendorName}/`);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
} else {
|
|
467
|
+
let source = staticVendorDir + staticVendor;
|
|
468
|
+
if (fs$1.existsSync(source)) {
|
|
469
|
+
console.log(`[${action} Local] resources/assets/vendor/${staticVendor}/ => ${root}/${staticVendor}/`);
|
|
470
|
+
doInstall(source, `${root}/${staticVendor}/`);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
async function doInstall(source, dest) {
|
|
477
|
+
if (process.env.INSTALL_VENDOR === "hard") {
|
|
478
|
+
await copyGlob(source + "/**/*", dest);
|
|
479
|
+
} else {
|
|
480
|
+
await symlink(source, dest);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
function findNpmVendors(composerJsons = []) {
|
|
484
|
+
const pkg = path.resolve(process.cwd(), "package.json");
|
|
485
|
+
const pkgJson = loadJson(pkg);
|
|
486
|
+
let vendors = Object.keys(pkgJson.devDependencies || {}).concat(Object.keys(pkgJson.dependencies || {})).map((id) => `node_modules/${id}/package.json`).map((file) => loadJson(file)).filter((pkgJson2) => pkgJson2?.windwalker != null).map((pkgJson2) => pkgJson2?.windwalker.vendors || []).flat();
|
|
487
|
+
const vendorsFromComposer = composerJsons.map((composerJson) => {
|
|
488
|
+
return [
|
|
489
|
+
...composerJson?.extra?.windwalker?.asset_vendors || [],
|
|
490
|
+
...composerJson?.extra?.windwalker?.assets?.exposes || [],
|
|
491
|
+
...Object.keys(composerJson?.extra?.windwalker?.assets?.vendors || {})
|
|
492
|
+
];
|
|
493
|
+
}).flat();
|
|
494
|
+
return [...new Set(vendors.concat(vendorsFromComposer))];
|
|
495
|
+
}
|
|
496
|
+
function getInstalledComposerVendors() {
|
|
497
|
+
const composerFile = path.resolve(process.cwd(), "composer.json");
|
|
498
|
+
const composerJson = loadJson(composerFile);
|
|
499
|
+
return [
|
|
500
|
+
...new Set(
|
|
501
|
+
Object.keys(composerJson["require"] || {}).concat(Object.keys(composerJson["require-dev"] || {}))
|
|
502
|
+
)
|
|
503
|
+
];
|
|
504
|
+
}
|
|
505
|
+
function deleteExists(dir) {
|
|
506
|
+
if (!fs$1.existsSync(dir)) {
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
const subDirs = fs$1.readdirSync(dir, { withFileTypes: true });
|
|
510
|
+
for (const subDir of subDirs) {
|
|
511
|
+
if (subDir.isSymbolicLink() || subDir.isFile()) {
|
|
512
|
+
fs$1.unlinkSync(path.join(dir, subDir.name));
|
|
513
|
+
} else if (subDir.isDirectory()) {
|
|
514
|
+
deleteExists(path.join(dir, subDir.name));
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
fs$1.rmdirSync(dir);
|
|
518
|
+
}
|
|
519
|
+
export {
|
|
520
|
+
cloneAssets,
|
|
521
|
+
containsMiddleGlob,
|
|
522
|
+
cssModulize,
|
|
523
|
+
ensureDirPath,
|
|
524
|
+
findFilesFromGlobArray,
|
|
525
|
+
findModules,
|
|
526
|
+
findPackages,
|
|
527
|
+
globalAssets,
|
|
528
|
+
injectSystemJS,
|
|
529
|
+
installVendors,
|
|
530
|
+
jsModulize,
|
|
531
|
+
loadJson,
|
|
532
|
+
removeLastGlob,
|
|
533
|
+
resolveModuleRealpath,
|
|
534
|
+
stripUrlQuery,
|
|
535
|
+
systemCSSFix,
|
|
536
|
+
uniqId
|
|
537
|
+
};
|
package/package.json
CHANGED
|
@@ -1,60 +1,78 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
"name": "@windwalker-io/core",
|
|
3
|
+
"version": "4.2.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Windwalker Core JS package",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "yarn build:next && yarn build:debugger",
|
|
8
|
+
"dev": "yarn dev:debugger",
|
|
9
|
+
"build:next": "vite build --config vite.config.next.ts",
|
|
10
|
+
"dev:next": "yarn build:next --watch",
|
|
11
|
+
"build:debugger": "vite build --config vite.config.debugger.ts",
|
|
12
|
+
"dev:debugger": "vite --config vite.config.debugger.ts"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": "./src/index.js",
|
|
16
|
+
"./next": {
|
|
17
|
+
"types": "./dist/next.d.ts",
|
|
18
|
+
"require": "./dist/next.js",
|
|
19
|
+
"import": "./dist/next.js"
|
|
12
20
|
},
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"license": "MIT",
|
|
17
|
-
"devDependencies": {
|
|
18
|
-
"@asika32764/vue-animate": "^3.0.2",
|
|
19
|
-
"@fortawesome/fontawesome-svg-core": "^6.2.0",
|
|
20
|
-
"@fortawesome/free-solid-svg-icons": "^6.2.0",
|
|
21
|
-
"@fortawesome/vue-fontawesome": "^3.0.1",
|
|
22
|
-
"@tailwindcss/custom-forms": "^0.2.1",
|
|
23
|
-
"@tailwindcss/ui": "^0.7.2",
|
|
24
|
-
"@types/gulp-rename": "^2",
|
|
25
|
-
"@vue/reactivity": "^3.3.7",
|
|
26
|
-
"@vue/tsconfig": "^0.4.0",
|
|
27
|
-
"@windwalker-io/fusion": "^1.0",
|
|
28
|
-
"autoprefixer": "^10.2.6",
|
|
29
|
-
"axios": "^1.0",
|
|
30
|
-
"bootstrap": "^5.0",
|
|
31
|
-
"dayjs": "^1.11.5",
|
|
32
|
-
"file-loader": "^6.2.0",
|
|
33
|
-
"gulp": "^4.0.2",
|
|
34
|
-
"gulp-postcss": "~9.0.0",
|
|
35
|
-
"postcss-import": "^14.0.2",
|
|
36
|
-
"postcss-loader": "^4.0.0",
|
|
37
|
-
"postcss-nested": "^5.0.5",
|
|
38
|
-
"regenerator-runtime": "^0.13.7",
|
|
39
|
-
"sql-formatter": "^10.6.0",
|
|
40
|
-
"tailwindcss": "^2.1.4",
|
|
41
|
-
"ts-loader": "^9.4.4",
|
|
42
|
-
"typescript": "^5.1.6",
|
|
43
|
-
"vue": "^3.0.11",
|
|
44
|
-
"vue-loader": "^16.0",
|
|
45
|
-
"vue-router": "^4.2.4",
|
|
46
|
-
"vue-style-loader": "^4.1.3",
|
|
47
|
-
"vue-tsc": "^1.8.8",
|
|
48
|
-
"vuedraggable": "^3.0||^4.0.3",
|
|
49
|
-
"webpack": "^5.0",
|
|
50
|
-
"webpack-bundle-analyzer": "^4.6.1"
|
|
51
|
-
},
|
|
52
|
-
"windwalker": {
|
|
53
|
-
"vendors": [
|
|
54
|
-
"@windwalker-io/core"
|
|
55
|
-
]
|
|
56
|
-
},
|
|
57
|
-
"dependencies": {
|
|
58
|
-
"gulp-rename": "^2.0.0"
|
|
21
|
+
"./app": {
|
|
22
|
+
"require": "./src/app/index.ts",
|
|
23
|
+
"import": "./src/app/index.ts"
|
|
59
24
|
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"images",
|
|
29
|
+
"scss",
|
|
30
|
+
"src",
|
|
31
|
+
"package.json"
|
|
32
|
+
],
|
|
33
|
+
"repository": "https://github.com/ventoviro/windwalker-core",
|
|
34
|
+
"author": "Simon Asika",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@windwalker-io/fusion-next": "*",
|
|
38
|
+
"fast-glob": "^3.3.3",
|
|
39
|
+
"is-glob": "^4.0.3",
|
|
40
|
+
"micromatch": "^4.0.8",
|
|
41
|
+
"node-html-parser": "^7.0.1"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@asika32764/vue-animate": "^3.0.2",
|
|
45
|
+
"@fortawesome/fontawesome-svg-core": "^6.2.0",
|
|
46
|
+
"@fortawesome/free-solid-svg-icons": "^6.2.0",
|
|
47
|
+
"@fortawesome/vue-fontawesome": "^3.0.1",
|
|
48
|
+
"@types/gulp-rename": "^2",
|
|
49
|
+
"@types/is-glob": "^4",
|
|
50
|
+
"@types/micromatch": "^4.0.9",
|
|
51
|
+
"@types/systemjs": "^6",
|
|
52
|
+
"@vitejs/plugin-vue": "^6.0.1",
|
|
53
|
+
"@vue/reactivity": "^3.3.7",
|
|
54
|
+
"@vue/tsconfig": "^0.4.0",
|
|
55
|
+
"axios": "^1.0",
|
|
56
|
+
"bootstrap": "^5.0",
|
|
57
|
+
"dayjs": "^1.11.5",
|
|
58
|
+
"file-loader": "^6.2.0",
|
|
59
|
+
"gulp-rename": "^2.0.0",
|
|
60
|
+
"rimraf": "^6.0.1",
|
|
61
|
+
"sql-formatter": "^10.6.0",
|
|
62
|
+
"systemjs": "^6.15.1",
|
|
63
|
+
"tailwindcss": "^3.0",
|
|
64
|
+
"typescript": "^5.1.6",
|
|
65
|
+
"unplugin-dts": "^1.0.0-beta.6",
|
|
66
|
+
"vite": "^7.1.6",
|
|
67
|
+
"vite-plugin-dts": "^4.5.4",
|
|
68
|
+
"vite-plugin-public-path": "^1.1.0",
|
|
69
|
+
"vue": "^3.0.11",
|
|
70
|
+
"vue-router": "^4.2.4",
|
|
71
|
+
"vuedraggable": "^3.0||^4.0.3"
|
|
72
|
+
},
|
|
73
|
+
"windwalker": {
|
|
74
|
+
"vendors": [
|
|
75
|
+
"@windwalker-io/core"
|
|
76
|
+
]
|
|
77
|
+
}
|
|
60
78
|
}
|