@windwalker-io/core 4.2.2 → 4.2.3
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/dist/next.js +6 -3
- package/package.json +1 -1
- package/src/asset-bundler.mjs +114 -114
- package/src/debugger/types/global.d.js +2 -2
- package/src/index.mjs +11 -11
- package/src/legacy/4.0/js-sync.mjs +74 -74
- package/src/next/fusion/index.ts +2 -2
- package/src/next/fusion/plugins/assets.ts +29 -29
- package/src/next/fusion/plugins/index.ts +3 -3
- package/src/next/fusion/plugins/systemjs.ts +66 -66
- package/src/next/fusion/processors/cloneAssets.ts +81 -81
- package/src/next/fusion/processors/cssModulize.ts +127 -127
- package/src/next/fusion/processors/index.ts +4 -4
- package/src/next/fusion/processors/installVendors.ts +178 -178
- package/src/next/fusion/processors/jsModulize.ts +296 -293
- package/src/next/index.ts +2 -2
- package/src/next/utilities/asset-sync.ts +47 -47
- package/src/next/utilities/crypto.ts +11 -11
- package/src/next/utilities/fs.ts +61 -61
- package/src/next/utilities/index.ts +5 -5
- package/src/next/utilities/modules.ts +17 -17
package/LICENSE
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
Copyright (c) 2018 Simon Asika
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
-
in the Software without restriction, including without limitation the rights
|
|
6
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
furnished to do so, subject to the following conditions:
|
|
9
|
-
|
|
10
|
-
The above copyright notice and this permission notice shall be included in all
|
|
11
|
-
copies or substantial portions of the Software.
|
|
12
|
-
|
|
13
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
14
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
15
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
16
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
17
|
-
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
18
|
-
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
19
|
-
OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
Copyright (c) 2018 Simon Asika
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
14
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
15
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
16
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
17
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
18
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
|
|
19
|
+
OR OTHER DEALINGS IN THE SOFTWARE.
|
package/dist/next.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getGlobBaseFromPattern, callback, css, js,
|
|
1
|
+
import { getGlobBaseFromPattern, callback, css, js, plugin, callbackAfterBuild, copyGlob, symlink } from "@windwalker-io/fusion-next";
|
|
2
2
|
import isGlob from "is-glob";
|
|
3
3
|
import micromatch from "micromatch";
|
|
4
4
|
import path, { relative, normalize, resolve } from "node:path";
|
|
@@ -313,6 +313,9 @@ class JsModulizeProcessor {
|
|
|
313
313
|
builder.postBuildCallbacks.push((options, bundle) => {
|
|
314
314
|
fs$1.removeSync(tmpPath);
|
|
315
315
|
});
|
|
316
|
+
builder.serverStopCallbacks.push((options, bundle) => {
|
|
317
|
+
fs$1.removeSync(tmpPath);
|
|
318
|
+
});
|
|
316
319
|
}
|
|
317
320
|
this.ignoreMainImport(task);
|
|
318
321
|
builder.resolveIdCallbacks.push((id) => {
|
|
@@ -327,7 +330,6 @@ class JsModulizeProcessor {
|
|
|
327
330
|
const scripts = {};
|
|
328
331
|
if (normalize(srcFile) === inputFile) {
|
|
329
332
|
const bladeScripts = parseScriptsFromBlades(bladeFiles);
|
|
330
|
-
fs$1.removeSync(tmpPath);
|
|
331
333
|
for (const scriptFile of scriptFiles) {
|
|
332
334
|
let fullpath = scriptFile.fullpath;
|
|
333
335
|
if (fullpath.endsWith(".d.ts")) {
|
|
@@ -346,7 +348,8 @@ class JsModulizeProcessor {
|
|
|
346
348
|
fs$1.ensureDirSync(tmpPath);
|
|
347
349
|
for (const result of bladeScripts) {
|
|
348
350
|
let key = result.as;
|
|
349
|
-
const
|
|
351
|
+
const filename = result.path.replace(/\\|\//g, "_");
|
|
352
|
+
const tmpFile = tmpPath + "/" + filename + ".ts";
|
|
350
353
|
if (!fs$1.existsSync(tmpFile) || fs$1.readFileSync(tmpFile, "utf8") !== result.code) {
|
|
351
354
|
fs$1.writeFileSync(tmpFile, result.code);
|
|
352
355
|
}
|
package/package.json
CHANGED
package/src/asset-bundler.mjs
CHANGED
|
@@ -1,114 +1,114 @@
|
|
|
1
|
-
import { webpackBundle } from '@windwalker-io/fusion';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import { globSync } from 'glob';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
import { findModules } from './asset-sync.mjs';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {string} mainFile
|
|
10
|
-
* @param {string|string[]} source
|
|
11
|
-
* @param {string} dest
|
|
12
|
-
* @param {any} options
|
|
13
|
-
* @returns {Promise<any>}
|
|
14
|
-
*/
|
|
15
|
-
export async function bundleJS(
|
|
16
|
-
mainFile = `./resources/assets/src/app.ts`,
|
|
17
|
-
source = 'src/Module/**/*.ts',
|
|
18
|
-
dest = 'www/assets/js/app/app.js',
|
|
19
|
-
options = {}
|
|
20
|
-
) {
|
|
21
|
-
const workingDir = process.cwd();
|
|
22
|
-
|
|
23
|
-
if (typeof source === 'string') {
|
|
24
|
-
source = [source];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const files = findFilesFromGlobArray([
|
|
28
|
-
...findModules('**/assets/*.ts'),
|
|
29
|
-
...source,
|
|
30
|
-
]);
|
|
31
|
-
|
|
32
|
-
let listJS = "{\n";
|
|
33
|
-
|
|
34
|
-
for (const file of files) {
|
|
35
|
-
if (file.fullpath.endsWith('.d.ts')) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
let key = file.relativePath.replace(/assets$/, '').toLowerCase();
|
|
40
|
-
key = key.substring(0, key.lastIndexOf('.'));
|
|
41
|
-
listJS += `'${key}': () => import('${file.fullpath}'),\n`;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
listJS += "}";
|
|
45
|
-
|
|
46
|
-
let ts = `
|
|
47
|
-
import loader from '@windwalker-io/core/src/loader/core-loader.ts';
|
|
48
|
-
|
|
49
|
-
loader.register(${listJS});
|
|
50
|
-
|
|
51
|
-
export default loader;
|
|
52
|
-
`;
|
|
53
|
-
|
|
54
|
-
// const base64 = Buffer.from(ts).toString('base64');
|
|
55
|
-
// const dataUri = `data:text/javascript;base64,${base64}`;
|
|
56
|
-
const tmpDir = workingDir + '/tmp/fusion';
|
|
57
|
-
fs.mkdirSync(tmpDir, { recursive: true });
|
|
58
|
-
|
|
59
|
-
const tmpFile = tmpDir + '/app.js';
|
|
60
|
-
fs.writeFileSync(tmpFile, ts);
|
|
61
|
-
|
|
62
|
-
const r = await webpackBundle(
|
|
63
|
-
tmpFile,
|
|
64
|
-
dest,
|
|
65
|
-
(config) => {
|
|
66
|
-
config.devtool = false;
|
|
67
|
-
// config.entry = dataUri;
|
|
68
|
-
// config.output.uniqueName = 'app';
|
|
69
|
-
config.output.libraryTarget = 'module';
|
|
70
|
-
config.experiments.outputModule = true;
|
|
71
|
-
config.resolve.modules.push(path.resolve('./'));
|
|
72
|
-
config.context = path.resolve('./');
|
|
73
|
-
config.resolve.alias = {
|
|
74
|
-
'@main': path.resolve(mainFile),
|
|
75
|
-
'@app': path.resolve(mainFile),
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
// fs.unlinkSync(tmpFile);
|
|
81
|
-
|
|
82
|
-
return r;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function findFilesFromGlobArray(sources) {
|
|
86
|
-
let files = [];
|
|
87
|
-
|
|
88
|
-
for (const source of sources) {
|
|
89
|
-
files = [
|
|
90
|
-
...files,
|
|
91
|
-
...findFiles(source)
|
|
92
|
-
];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return files;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* @param {string} src
|
|
100
|
-
*/
|
|
101
|
-
function findFiles(src) {
|
|
102
|
-
const i = src.lastIndexOf('**');
|
|
103
|
-
|
|
104
|
-
const path = src.substring(0, i);
|
|
105
|
-
|
|
106
|
-
return globSync(src).map((file) => {
|
|
107
|
-
file = file.replace(/\\/g, '/');
|
|
108
|
-
|
|
109
|
-
return {
|
|
110
|
-
fullpath: file,
|
|
111
|
-
relativePath: file.substring(path.length)
|
|
112
|
-
};
|
|
113
|
-
});
|
|
114
|
-
}
|
|
1
|
+
import { webpackBundle } from '@windwalker-io/fusion';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { globSync } from 'glob';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { findModules } from './asset-sync.mjs';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param {string} mainFile
|
|
10
|
+
* @param {string|string[]} source
|
|
11
|
+
* @param {string} dest
|
|
12
|
+
* @param {any} options
|
|
13
|
+
* @returns {Promise<any>}
|
|
14
|
+
*/
|
|
15
|
+
export async function bundleJS(
|
|
16
|
+
mainFile = `./resources/assets/src/app.ts`,
|
|
17
|
+
source = 'src/Module/**/*.ts',
|
|
18
|
+
dest = 'www/assets/js/app/app.js',
|
|
19
|
+
options = {}
|
|
20
|
+
) {
|
|
21
|
+
const workingDir = process.cwd();
|
|
22
|
+
|
|
23
|
+
if (typeof source === 'string') {
|
|
24
|
+
source = [source];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const files = findFilesFromGlobArray([
|
|
28
|
+
...findModules('**/assets/*.ts'),
|
|
29
|
+
...source,
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
let listJS = "{\n";
|
|
33
|
+
|
|
34
|
+
for (const file of files) {
|
|
35
|
+
if (file.fullpath.endsWith('.d.ts')) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let key = file.relativePath.replace(/assets$/, '').toLowerCase();
|
|
40
|
+
key = key.substring(0, key.lastIndexOf('.'));
|
|
41
|
+
listJS += `'${key}': () => import('${file.fullpath}'),\n`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
listJS += "}";
|
|
45
|
+
|
|
46
|
+
let ts = `
|
|
47
|
+
import loader from '@windwalker-io/core/src/loader/core-loader.ts';
|
|
48
|
+
|
|
49
|
+
loader.register(${listJS});
|
|
50
|
+
|
|
51
|
+
export default loader;
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
// const base64 = Buffer.from(ts).toString('base64');
|
|
55
|
+
// const dataUri = `data:text/javascript;base64,${base64}`;
|
|
56
|
+
const tmpDir = workingDir + '/tmp/fusion';
|
|
57
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
58
|
+
|
|
59
|
+
const tmpFile = tmpDir + '/app.js';
|
|
60
|
+
fs.writeFileSync(tmpFile, ts);
|
|
61
|
+
|
|
62
|
+
const r = await webpackBundle(
|
|
63
|
+
tmpFile,
|
|
64
|
+
dest,
|
|
65
|
+
(config) => {
|
|
66
|
+
config.devtool = false;
|
|
67
|
+
// config.entry = dataUri;
|
|
68
|
+
// config.output.uniqueName = 'app';
|
|
69
|
+
config.output.libraryTarget = 'module';
|
|
70
|
+
config.experiments.outputModule = true;
|
|
71
|
+
config.resolve.modules.push(path.resolve('./'));
|
|
72
|
+
config.context = path.resolve('./');
|
|
73
|
+
config.resolve.alias = {
|
|
74
|
+
'@main': path.resolve(mainFile),
|
|
75
|
+
'@app': path.resolve(mainFile),
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
// fs.unlinkSync(tmpFile);
|
|
81
|
+
|
|
82
|
+
return r;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function findFilesFromGlobArray(sources) {
|
|
86
|
+
let files = [];
|
|
87
|
+
|
|
88
|
+
for (const source of sources) {
|
|
89
|
+
files = [
|
|
90
|
+
...files,
|
|
91
|
+
...findFiles(source)
|
|
92
|
+
];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return files;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @param {string} src
|
|
100
|
+
*/
|
|
101
|
+
function findFiles(src) {
|
|
102
|
+
const i = src.lastIndexOf('**');
|
|
103
|
+
|
|
104
|
+
const path = src.substring(0, i);
|
|
105
|
+
|
|
106
|
+
return globSync(src).map((file) => {
|
|
107
|
+
file = file.replace(/\\/g, '/');
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
fullpath: file,
|
|
111
|
+
relativePath: file.substring(path.length)
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare module '*.jpg';
|
|
2
|
-
declare module '*.svg';
|
|
1
|
+
declare module '*.jpg';
|
|
2
|
+
declare module '*.svg';
|
package/src/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Part of funclass project.
|
|
3
|
-
*
|
|
4
|
-
* @copyright Copyright (C) 2021 LYRASOFT.
|
|
5
|
-
* @license __LICENSE__
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
export * from './asset-sync.mjs';
|
|
9
|
-
export * from './asset-bundler.mjs';
|
|
10
|
-
export * from './install-vendors.mjs';
|
|
11
|
-
export * from './app.ts';
|
|
1
|
+
/**
|
|
2
|
+
* Part of funclass project.
|
|
3
|
+
*
|
|
4
|
+
* @copyright Copyright (C) 2021 LYRASOFT.
|
|
5
|
+
* @license __LICENSE__
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export * from './asset-sync.mjs';
|
|
9
|
+
export * from './asset-bundler.mjs';
|
|
10
|
+
export * from './install-vendors.mjs';
|
|
11
|
+
export * from './app.ts';
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
import { findModules } from '@windwalker-io/core/src/index.mjs';
|
|
2
|
-
import { dest as toDest, src, ts } from '@windwalker-io/fusion';
|
|
3
|
-
import { postStream, prepareStream } from '@windwalker-io/fusion/src/lifecycles.js';
|
|
4
|
-
import { extractDest } from '@windwalker-io/fusion/src/utilities/utilities.js';
|
|
5
|
-
import { existsSync } from 'fs';
|
|
6
|
-
import rename from 'gulp-rename';
|
|
7
|
-
import path from 'path';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated
|
|
11
|
-
*/
|
|
12
|
-
export function jsSync(source = 'src/Module', dest, options = {}) {
|
|
13
|
-
const tsOptions = options.ts || {};
|
|
14
|
-
|
|
15
|
-
if (!tsOptions.tsconfig) {
|
|
16
|
-
tsOptions.tsconfig = path.resolve('tsconfig.json');
|
|
17
|
-
|
|
18
|
-
if (!existsSync(tsOptions.tsconfig)) {
|
|
19
|
-
tsOptions.tsconfig = path.resolve('node_modules/@windwalker-io/unicorn/tsconfig.js.json');
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const sourceList = [];
|
|
24
|
-
|
|
25
|
-
sourceList.push(...findModules('**/assets/*.{js,mjs}'));
|
|
26
|
-
sourceList.push(source + '**/assets/*.{js,mjs}');
|
|
27
|
-
|
|
28
|
-
let stream = prepareStream(src(sourceList));
|
|
29
|
-
|
|
30
|
-
stream = stream.pipe(rename((path) => {
|
|
31
|
-
path.dirname = path.dirname.replace(/assets$/, '').toLowerCase();
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
const jsDest = extractDest(dest);
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
// // if (dest.merge) {
|
|
38
|
-
// // stream = stream.pipe(rename(path.basename(dest.file)));
|
|
39
|
-
// // }
|
|
40
|
-
//
|
|
41
|
-
stream = stream.pipe(toDest(jsDest.path).on('error', e => console.error(e)));
|
|
42
|
-
|
|
43
|
-
return Promise.all([
|
|
44
|
-
new Promise((resolve) => {
|
|
45
|
-
postStream(stream).on('end', (event) => {
|
|
46
|
-
const data = {
|
|
47
|
-
event,
|
|
48
|
-
src,
|
|
49
|
-
dest: jsDest,
|
|
50
|
-
stream
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
resolve(data);
|
|
54
|
-
});
|
|
55
|
-
}),
|
|
56
|
-
// Legacy mode
|
|
57
|
-
ts(
|
|
58
|
-
[
|
|
59
|
-
...findModules('**/assets/*.ts'),
|
|
60
|
-
'node_modules/@windwalker-io/unicorn/src/types/*.d.ts',
|
|
61
|
-
`${source}/**/*.ts`,
|
|
62
|
-
],
|
|
63
|
-
dest,
|
|
64
|
-
{
|
|
65
|
-
rename: (path) => {
|
|
66
|
-
path.dirname = path.dirname.replace(/assets$/, '').toLowerCase();
|
|
67
|
-
},
|
|
68
|
-
...tsOptions
|
|
69
|
-
}
|
|
70
|
-
)
|
|
71
|
-
]).then((v) => {
|
|
72
|
-
return v[0];
|
|
73
|
-
});
|
|
74
|
-
}
|
|
1
|
+
import { findModules } from '@windwalker-io/core/src/index.mjs';
|
|
2
|
+
import { dest as toDest, src, ts } from '@windwalker-io/fusion';
|
|
3
|
+
import { postStream, prepareStream } from '@windwalker-io/fusion/src/lifecycles.js';
|
|
4
|
+
import { extractDest } from '@windwalker-io/fusion/src/utilities/utilities.js';
|
|
5
|
+
import { existsSync } from 'fs';
|
|
6
|
+
import rename from 'gulp-rename';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated
|
|
11
|
+
*/
|
|
12
|
+
export function jsSync(source = 'src/Module', dest, options = {}) {
|
|
13
|
+
const tsOptions = options.ts || {};
|
|
14
|
+
|
|
15
|
+
if (!tsOptions.tsconfig) {
|
|
16
|
+
tsOptions.tsconfig = path.resolve('tsconfig.json');
|
|
17
|
+
|
|
18
|
+
if (!existsSync(tsOptions.tsconfig)) {
|
|
19
|
+
tsOptions.tsconfig = path.resolve('node_modules/@windwalker-io/unicorn/tsconfig.js.json');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const sourceList = [];
|
|
24
|
+
|
|
25
|
+
sourceList.push(...findModules('**/assets/*.{js,mjs}'));
|
|
26
|
+
sourceList.push(source + '**/assets/*.{js,mjs}');
|
|
27
|
+
|
|
28
|
+
let stream = prepareStream(src(sourceList));
|
|
29
|
+
|
|
30
|
+
stream = stream.pipe(rename((path) => {
|
|
31
|
+
path.dirname = path.dirname.replace(/assets$/, '').toLowerCase();
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
const jsDest = extractDest(dest);
|
|
35
|
+
|
|
36
|
+
//
|
|
37
|
+
// // if (dest.merge) {
|
|
38
|
+
// // stream = stream.pipe(rename(path.basename(dest.file)));
|
|
39
|
+
// // }
|
|
40
|
+
//
|
|
41
|
+
stream = stream.pipe(toDest(jsDest.path).on('error', e => console.error(e)));
|
|
42
|
+
|
|
43
|
+
return Promise.all([
|
|
44
|
+
new Promise((resolve) => {
|
|
45
|
+
postStream(stream).on('end', (event) => {
|
|
46
|
+
const data = {
|
|
47
|
+
event,
|
|
48
|
+
src,
|
|
49
|
+
dest: jsDest,
|
|
50
|
+
stream
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
resolve(data);
|
|
54
|
+
});
|
|
55
|
+
}),
|
|
56
|
+
// Legacy mode
|
|
57
|
+
ts(
|
|
58
|
+
[
|
|
59
|
+
...findModules('**/assets/*.ts'),
|
|
60
|
+
'node_modules/@windwalker-io/unicorn/src/types/*.d.ts',
|
|
61
|
+
`${source}/**/*.ts`,
|
|
62
|
+
],
|
|
63
|
+
dest,
|
|
64
|
+
{
|
|
65
|
+
rename: (path) => {
|
|
66
|
+
path.dirname = path.dirname.replace(/assets$/, '').toLowerCase();
|
|
67
|
+
},
|
|
68
|
+
...tsOptions
|
|
69
|
+
}
|
|
70
|
+
)
|
|
71
|
+
]).then((v) => {
|
|
72
|
+
return v[0];
|
|
73
|
+
});
|
|
74
|
+
}
|
package/src/next/fusion/index.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './plugins';
|
|
2
|
-
export * from './processors';
|
|
1
|
+
export * from './plugins';
|
|
2
|
+
export * from './processors';
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { type FusionPlugin } from '@windwalker-io/fusion-next';
|
|
2
|
-
import { getAvailableForReposition, handleCloneAssets, handleReposition } from '../processors/cloneAssets';
|
|
3
|
-
|
|
4
|
-
export interface WindwalkerAssetsOptions {
|
|
5
|
-
clone?: Record<string, string>;
|
|
6
|
-
reposition?: Record<string, string>;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function globalAssets(options: WindwalkerAssetsOptions): FusionPlugin {
|
|
10
|
-
return {
|
|
11
|
-
name: 'core:global-assets',
|
|
12
|
-
buildConfig(builder) {
|
|
13
|
-
const clone = options.clone || {};
|
|
14
|
-
let reposition = options.reposition || {};
|
|
15
|
-
|
|
16
|
-
reposition = { ...reposition, ...getAvailableForReposition(clone) };
|
|
17
|
-
|
|
18
|
-
// Handle reposition
|
|
19
|
-
handleReposition(builder, reposition);
|
|
20
|
-
|
|
21
|
-
const clonePatterns = Object.keys(clone);
|
|
22
|
-
|
|
23
|
-
// Handle clone
|
|
24
|
-
if (clonePatterns.length > 0) {
|
|
25
|
-
handleCloneAssets(builder, clonePatterns);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}
|
|
1
|
+
import { type FusionPlugin } from '@windwalker-io/fusion-next';
|
|
2
|
+
import { getAvailableForReposition, handleCloneAssets, handleReposition } from '../processors/cloneAssets';
|
|
3
|
+
|
|
4
|
+
export interface WindwalkerAssetsOptions {
|
|
5
|
+
clone?: Record<string, string>;
|
|
6
|
+
reposition?: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function globalAssets(options: WindwalkerAssetsOptions): FusionPlugin {
|
|
10
|
+
return {
|
|
11
|
+
name: 'core:global-assets',
|
|
12
|
+
buildConfig(builder) {
|
|
13
|
+
const clone = options.clone || {};
|
|
14
|
+
let reposition = options.reposition || {};
|
|
15
|
+
|
|
16
|
+
reposition = { ...reposition, ...getAvailableForReposition(clone) };
|
|
17
|
+
|
|
18
|
+
// Handle reposition
|
|
19
|
+
handleReposition(builder, reposition);
|
|
20
|
+
|
|
21
|
+
const clonePatterns = Object.keys(clone);
|
|
22
|
+
|
|
23
|
+
// Handle clone
|
|
24
|
+
if (clonePatterns.length > 0) {
|
|
25
|
+
handleCloneAssets(builder, clonePatterns);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './assets';
|
|
2
|
-
export * from './systemjs';
|
|
3
|
-
|
|
1
|
+
export * from './assets';
|
|
2
|
+
export * from './systemjs';
|
|
3
|
+
|