@windwalker-io/core 4.2.1 → 4.2.2

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.
Files changed (34) hide show
  1. package/LICENSE +19 -19
  2. package/dist/debugger/{Dashboard-CQHU0d2H.js → Dashboard-Bm7ihi81.js} +1 -1
  3. package/dist/debugger/{Database-VIM7Qa1v.js → Database-BGuRRq-L.js} +1 -1
  4. package/dist/debugger/{DefaultLayout-B32TQLQX.js → DefaultLayout-DviqbPNR.js} +1 -1
  5. package/dist/debugger/{Events-CUBbmkGz.js → Events-CNF6gvg0.js} +1 -1
  6. package/dist/debugger/{KeyValueTable-CQHDOoM1.js → KeyValueTable-BfTkP1Rg.js} +1 -1
  7. package/dist/debugger/{Request-aNwJ2Iha.js → Request-yQA1-Fkb.js} +1 -1
  8. package/dist/debugger/{Routing-D8BolD7h.js → Routing-C5mAPB17.js} +1 -1
  9. package/dist/debugger/{System-DGIjiMcw.js → System-JFuNpoZY.js} +1 -1
  10. package/dist/debugger/{Timeline-Bj8IvPmS.js → Timeline-Uii-K9v_.js} +1 -1
  11. package/dist/debugger/debugger.js +10 -10
  12. package/dist/next.d.ts +15 -1
  13. package/dist/next.js +50 -11
  14. package/package.json +4 -4
  15. package/src/app/app.ts +43 -0
  16. package/src/asset-bundler.mjs +114 -114
  17. package/src/debugger/types/global.d.js +2 -2
  18. package/src/index.mjs +11 -11
  19. package/src/legacy/4.0/js-sync.mjs +74 -74
  20. package/src/next/fusion/index.ts +2 -2
  21. package/src/next/fusion/plugins/assets.ts +29 -29
  22. package/src/next/fusion/plugins/index.ts +3 -3
  23. package/src/next/fusion/plugins/systemjs.ts +66 -66
  24. package/src/next/fusion/processors/cloneAssets.ts +81 -81
  25. package/src/next/fusion/processors/cssModulize.ts +127 -105
  26. package/src/next/fusion/processors/index.ts +4 -4
  27. package/src/next/fusion/processors/installVendors.ts +178 -178
  28. package/src/next/fusion/processors/jsModulize.ts +293 -296
  29. package/src/next/index.ts +2 -2
  30. package/src/next/utilities/asset-sync.ts +47 -47
  31. package/src/next/utilities/crypto.ts +11 -11
  32. package/src/next/utilities/fs.ts +61 -61
  33. package/src/next/utilities/index.ts +5 -5
  34. package/src/next/utilities/modules.ts +17 -17
@@ -1,178 +1,178 @@
1
- import { callbackAfterBuild, copyGlob, symlink } from '@windwalker-io/fusion-next';
2
- import fs from 'fs-extra';
3
- import path from 'node:path';
4
- import { loadJson } from '../../utilities';
5
-
6
- export function installVendors(
7
- npmVendors: string[] = [],
8
- to: string = 'www/assets/vendor',
9
- ) {
10
- return callbackAfterBuild(() => findAndInstall(npmVendors, to));
11
- }
12
-
13
- enum InstallAction {
14
- LINK = 'Link',
15
- COPY = 'Copy',
16
- }
17
-
18
- export async function findAndInstall(npmVendors: string[] = [], to = 'www/assets/vendor') {
19
- const root = to;
20
- let vendors = npmVendors;
21
- const action = process.env.INSTALL_VENDOR === 'hard' ? InstallAction.COPY : InstallAction.LINK;
22
-
23
- console.log("");
24
-
25
- if (!fs.existsSync(root)) {
26
- fs.mkdirSync(root);
27
- }
28
-
29
- const dirs = fs.readdirSync(root, { withFileTypes: true })
30
- .filter(d => d.isDirectory())
31
- .map(dir => path.join(root, dir.name));
32
-
33
- dirs.unshift(root);
34
-
35
- dirs.forEach((dir) => {
36
- deleteExists(dir);
37
- });
38
-
39
- const composerJsons = getInstalledComposerVendors()
40
- .map((cv) => `vendor/${cv}/composer.json`)
41
- .map((file) => loadJson(file))
42
- .filter((composerJson) => composerJson?.extra?.windwalker != null);
43
-
44
- // Install npm vendors
45
- vendors = findNpmVendors(composerJsons).concat(vendors);
46
- vendors = [...new Set(vendors)];
47
-
48
- for (const vendor of vendors) {
49
- const source = `node_modules/${vendor}/`;
50
- if (fs.existsSync(source)) {
51
- console.log(`[${action} NPM] node_modules/${vendor}/ => ${root}/${vendor}/`);
52
- doInstall(source, `${root}/${vendor}/`);
53
- }
54
- }
55
-
56
- // Install composer packages assets
57
- for (const composerJson of composerJsons) {
58
- const vendorName = composerJson.name;
59
-
60
- let assets = composerJson?.extra?.windwalker?.assets?.link;
61
-
62
- if (!assets) {
63
- continue;
64
- }
65
-
66
- if (!assets.endsWith('/')) {
67
- assets += '/';
68
- }
69
-
70
- if (fs.existsSync(`vendor/${vendorName}/${assets}`)) {
71
- console.log(`[${action} Composer] vendor/${vendorName}/${assets} => ${root}/${vendorName}/`);
72
- doInstall(`vendor/${vendorName}/${assets}`, `${root}/${vendorName}/`);
73
- }
74
- }
75
-
76
- // Install legacy packages assets
77
- // legacyComposerVendors.forEach((vendorName) => {
78
- // console.log(vendorName, fs.existsSync(`vendor/${vendorName}/assets`));
79
- // if (fs.existsSync(`vendor/${vendorName}/assets`)) {
80
- // console.log(`[${action} Composer] vendor/${vendorName}/assets/ => ${root}/${vendorName}/`);
81
- // doInstall(`vendor/${vendorName}/assets/`, `${root}/${vendorName}/`);
82
- // }
83
- // });
84
-
85
- // Install local saved vendors
86
- const staticVendorDir = 'resources/assets/vendor/';
87
-
88
- if (fs.existsSync(staticVendorDir)) {
89
- const staticVendors = fs.readdirSync(staticVendorDir);
90
-
91
- for (const staticVendor of staticVendors) {
92
- if (staticVendor.startsWith('@')) {
93
- const subVendors = fs.readdirSync(staticVendorDir + staticVendor);
94
-
95
- for (const subVendor of subVendors) {
96
- const subVendorName = staticVendor + '/' + subVendor;
97
- const source = staticVendorDir + subVendorName + '/';
98
-
99
- if (fs.existsSync(source)) {
100
- console.log(`[${action} Local] resources/assets/vendor/${subVendorName}/ => ${root}/${subVendorName}/`);
101
- doInstall(source, `${root}/${subVendorName}/`);
102
- }
103
- }
104
- } else {
105
- let source = staticVendorDir + staticVendor;
106
-
107
- if (fs.existsSync(source)) {
108
- console.log(`[${action} Local] resources/assets/vendor/${staticVendor}/ => ${root}/${staticVendor}/`);
109
- doInstall(source, `${root}/${staticVendor}/`);
110
- }
111
- }
112
- }
113
- }
114
- }
115
-
116
- async function doInstall(source: string, dest: string) {
117
- if (process.env.INSTALL_VENDOR === 'hard') {
118
- await copyGlob(source + '/**/*', dest);
119
- } else {
120
- await symlink(source, dest);
121
- }
122
- }
123
-
124
- function findNpmVendors(composerJsons: any[] = []) {
125
- const pkg = path.resolve(process.cwd(), 'package.json');
126
- const pkgJson = loadJson(pkg);
127
-
128
- let vendors = Object.keys(pkgJson.devDependencies || {})
129
- .concat(Object.keys(pkgJson.dependencies || {}))
130
- .map(id => `node_modules/${id}/package.json`)
131
- .map((file) => loadJson(file))
132
- .filter(pkgJson => pkgJson?.windwalker != null)
133
- .map(pkgJson => pkgJson?.windwalker.vendors || [])
134
- .flat();
135
-
136
- const vendorsFromComposer = composerJsons
137
- .map((composerJson) => {
138
- return [
139
- ...composerJson?.extra?.windwalker?.asset_vendors || [],
140
- ...composerJson?.extra?.windwalker?.assets?.exposes || [],
141
- ...Object.keys(composerJson?.extra?.windwalker?.assets?.vendors || {})
142
- ];
143
- })
144
- .flat();
145
-
146
- return [...new Set(vendors.concat(vendorsFromComposer))];
147
- }
148
-
149
- function getInstalledComposerVendors() {
150
- const composerFile = path.resolve(process.cwd(), 'composer.json');
151
- const composerJson = loadJson(composerFile);
152
-
153
- return [
154
- ...new Set(
155
- Object.keys(composerJson['require'] || {})
156
- .concat(Object.keys(composerJson['require-dev'] || {}))
157
- )
158
- ];
159
- }
160
-
161
- function deleteExists(dir: string) {
162
- if (!fs.existsSync(dir)) {
163
- return;
164
- }
165
-
166
- const subDirs = fs.readdirSync(dir, { withFileTypes: true });
167
-
168
- for (const subDir of subDirs) {
169
- if (subDir.isSymbolicLink() || subDir.isFile()) {
170
- fs.unlinkSync(path.join(dir, subDir.name));
171
- } else if (subDir.isDirectory()) {
172
- deleteExists(path.join(dir, subDir.name));
173
- }
174
- }
175
-
176
- fs.rmdirSync(dir);
177
- }
178
-
1
+ import { callbackAfterBuild, copyGlob, symlink } from '@windwalker-io/fusion-next';
2
+ import fs from 'fs-extra';
3
+ import path from 'node:path';
4
+ import { loadJson } from '../../utilities';
5
+
6
+ export function installVendors(
7
+ npmVendors: string[] = [],
8
+ to: string = 'www/assets/vendor',
9
+ ) {
10
+ return callbackAfterBuild(() => findAndInstall(npmVendors, to));
11
+ }
12
+
13
+ enum InstallAction {
14
+ LINK = 'Link',
15
+ COPY = 'Copy',
16
+ }
17
+
18
+ export async function findAndInstall(npmVendors: string[] = [], to = 'www/assets/vendor') {
19
+ const root = to;
20
+ let vendors = npmVendors;
21
+ const action = process.env.INSTALL_VENDOR === 'hard' ? InstallAction.COPY : InstallAction.LINK;
22
+
23
+ console.log("");
24
+
25
+ if (!fs.existsSync(root)) {
26
+ fs.mkdirSync(root);
27
+ }
28
+
29
+ const dirs = fs.readdirSync(root, { withFileTypes: true })
30
+ .filter(d => d.isDirectory())
31
+ .map(dir => path.join(root, dir.name));
32
+
33
+ dirs.unshift(root);
34
+
35
+ dirs.forEach((dir) => {
36
+ deleteExists(dir);
37
+ });
38
+
39
+ const composerJsons = getInstalledComposerVendors()
40
+ .map((cv) => `vendor/${cv}/composer.json`)
41
+ .map((file) => loadJson(file))
42
+ .filter((composerJson) => composerJson?.extra?.windwalker != null);
43
+
44
+ // Install npm vendors
45
+ vendors = findNpmVendors(composerJsons).concat(vendors);
46
+ vendors = [...new Set(vendors)];
47
+
48
+ for (const vendor of vendors) {
49
+ const source = `node_modules/${vendor}/`;
50
+ if (fs.existsSync(source)) {
51
+ console.log(`[${action} NPM] node_modules/${vendor}/ => ${root}/${vendor}/`);
52
+ doInstall(source, `${root}/${vendor}/`);
53
+ }
54
+ }
55
+
56
+ // Install composer packages assets
57
+ for (const composerJson of composerJsons) {
58
+ const vendorName = composerJson.name;
59
+
60
+ let assets = composerJson?.extra?.windwalker?.assets?.link;
61
+
62
+ if (!assets) {
63
+ continue;
64
+ }
65
+
66
+ if (!assets.endsWith('/')) {
67
+ assets += '/';
68
+ }
69
+
70
+ if (fs.existsSync(`vendor/${vendorName}/${assets}`)) {
71
+ console.log(`[${action} Composer] vendor/${vendorName}/${assets} => ${root}/${vendorName}/`);
72
+ doInstall(`vendor/${vendorName}/${assets}`, `${root}/${vendorName}/`);
73
+ }
74
+ }
75
+
76
+ // Install legacy packages assets
77
+ // legacyComposerVendors.forEach((vendorName) => {
78
+ // console.log(vendorName, fs.existsSync(`vendor/${vendorName}/assets`));
79
+ // if (fs.existsSync(`vendor/${vendorName}/assets`)) {
80
+ // console.log(`[${action} Composer] vendor/${vendorName}/assets/ => ${root}/${vendorName}/`);
81
+ // doInstall(`vendor/${vendorName}/assets/`, `${root}/${vendorName}/`);
82
+ // }
83
+ // });
84
+
85
+ // Install local saved vendors
86
+ const staticVendorDir = 'resources/assets/vendor/';
87
+
88
+ if (fs.existsSync(staticVendorDir)) {
89
+ const staticVendors = fs.readdirSync(staticVendorDir);
90
+
91
+ for (const staticVendor of staticVendors) {
92
+ if (staticVendor.startsWith('@')) {
93
+ const subVendors = fs.readdirSync(staticVendorDir + staticVendor);
94
+
95
+ for (const subVendor of subVendors) {
96
+ const subVendorName = staticVendor + '/' + subVendor;
97
+ const source = staticVendorDir + subVendorName + '/';
98
+
99
+ if (fs.existsSync(source)) {
100
+ console.log(`[${action} Local] resources/assets/vendor/${subVendorName}/ => ${root}/${subVendorName}/`);
101
+ doInstall(source, `${root}/${subVendorName}/`);
102
+ }
103
+ }
104
+ } else {
105
+ let source = staticVendorDir + staticVendor;
106
+
107
+ if (fs.existsSync(source)) {
108
+ console.log(`[${action} Local] resources/assets/vendor/${staticVendor}/ => ${root}/${staticVendor}/`);
109
+ doInstall(source, `${root}/${staticVendor}/`);
110
+ }
111
+ }
112
+ }
113
+ }
114
+ }
115
+
116
+ async function doInstall(source: string, dest: string) {
117
+ if (process.env.INSTALL_VENDOR === 'hard') {
118
+ await copyGlob(source + '/**/*', dest);
119
+ } else {
120
+ await symlink(source, dest);
121
+ }
122
+ }
123
+
124
+ function findNpmVendors(composerJsons: any[] = []) {
125
+ const pkg = path.resolve(process.cwd(), 'package.json');
126
+ const pkgJson = loadJson(pkg);
127
+
128
+ let vendors = Object.keys(pkgJson.devDependencies || {})
129
+ .concat(Object.keys(pkgJson.dependencies || {}))
130
+ .map(id => `node_modules/${id}/package.json`)
131
+ .map((file) => loadJson(file))
132
+ .filter(pkgJson => pkgJson?.windwalker != null)
133
+ .map(pkgJson => pkgJson?.windwalker.vendors || [])
134
+ .flat();
135
+
136
+ const vendorsFromComposer = composerJsons
137
+ .map((composerJson) => {
138
+ return [
139
+ ...composerJson?.extra?.windwalker?.asset_vendors || [],
140
+ ...composerJson?.extra?.windwalker?.assets?.exposes || [],
141
+ ...Object.keys(composerJson?.extra?.windwalker?.assets?.vendors || {})
142
+ ];
143
+ })
144
+ .flat();
145
+
146
+ return [...new Set(vendors.concat(vendorsFromComposer))];
147
+ }
148
+
149
+ function getInstalledComposerVendors() {
150
+ const composerFile = path.resolve(process.cwd(), 'composer.json');
151
+ const composerJson = loadJson(composerFile);
152
+
153
+ return [
154
+ ...new Set(
155
+ Object.keys(composerJson['require'] || {})
156
+ .concat(Object.keys(composerJson['require-dev'] || {}))
157
+ )
158
+ ];
159
+ }
160
+
161
+ function deleteExists(dir: string) {
162
+ if (!fs.existsSync(dir)) {
163
+ return;
164
+ }
165
+
166
+ const subDirs = fs.readdirSync(dir, { withFileTypes: true });
167
+
168
+ for (const subDir of subDirs) {
169
+ if (subDir.isSymbolicLink() || subDir.isFile()) {
170
+ fs.unlinkSync(path.join(dir, subDir.name));
171
+ } else if (subDir.isDirectory()) {
172
+ deleteExists(path.join(dir, subDir.name));
173
+ }
174
+ }
175
+
176
+ fs.rmdirSync(dir);
177
+ }
178
+