@cocos/ccbuild 1.0.0-alpha.6 → 1.0.0-alpha.8

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 (100) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +14 -14
  3. package/lib/api-builder.d.ts +1 -0
  4. package/lib/api-builder.d.ts.map +1 -0
  5. package/lib/api-builder.js +1 -1
  6. package/lib/build-engine/engine-js/index.d.ts +3 -0
  7. package/lib/build-engine/engine-js/index.d.ts.map +1 -0
  8. package/lib/build-engine/engine-js/index.js +460 -0
  9. package/lib/build-engine/engine-js/index.js.map +1 -0
  10. package/lib/build-engine/engine-js/rollup-plugins/asset-ref.d.ts +37 -0
  11. package/lib/build-engine/engine-js/rollup-plugins/asset-ref.d.ts.map +1 -0
  12. package/lib/build-engine/engine-js/rollup-plugins/asset-ref.js +88 -0
  13. package/lib/build-engine/engine-js/rollup-plugins/asset-ref.js.map +1 -0
  14. package/lib/build-engine/engine-js/rollup-plugins/asset-url.d.ts +8 -0
  15. package/lib/build-engine/engine-js/rollup-plugins/asset-url.d.ts.map +1 -0
  16. package/lib/build-engine/engine-js/rollup-plugins/asset-url.js +93 -0
  17. package/lib/build-engine/engine-js/rollup-plugins/asset-url.js.map +1 -0
  18. package/lib/build-engine/engine-js/rollup-plugins/code-asset.d.ts +29 -0
  19. package/lib/build-engine/engine-js/rollup-plugins/code-asset.d.ts.map +1 -0
  20. package/lib/build-engine/engine-js/rollup-plugins/code-asset.js +136 -0
  21. package/lib/build-engine/engine-js/rollup-plugins/code-asset.js.map +1 -0
  22. package/lib/build-engine/engine-js/rollup-plugins/remove-deprecated-features.d.ts +3 -0
  23. package/lib/build-engine/engine-js/rollup-plugins/remove-deprecated-features.d.ts.map +1 -0
  24. package/lib/build-engine/engine-js/rollup-plugins/remove-deprecated-features.js +38 -0
  25. package/lib/build-engine/engine-js/rollup-plugins/remove-deprecated-features.js.map +1 -0
  26. package/lib/build-engine/engine-js/rollup-plugins/ts-paths.d.ts +5 -0
  27. package/lib/build-engine/engine-js/rollup-plugins/ts-paths.d.ts.map +1 -0
  28. package/lib/build-engine/engine-js/rollup-plugins/ts-paths.js +43 -0
  29. package/lib/build-engine/engine-js/rollup-plugins/ts-paths.js.map +1 -0
  30. package/lib/build-engine/index.d.ts +119 -0
  31. package/lib/build-engine/index.d.ts.map +1 -0
  32. package/lib/build-engine/index.js +125 -0
  33. package/lib/build-engine/index.js.map +1 -0
  34. package/lib/engine-builder.d.ts +54 -46
  35. package/lib/engine-builder.d.ts.map +1 -0
  36. package/lib/engine-builder.js +549 -547
  37. package/lib/engine-builder.js.map +1 -1
  38. package/lib/index.d.ts +5 -1
  39. package/lib/index.d.ts.map +1 -0
  40. package/lib/index.js +34 -5
  41. package/lib/index.js.map +1 -1
  42. package/lib/module-resolver.d.ts +8 -7
  43. package/lib/module-resolver.d.ts.map +1 -0
  44. package/lib/module-resolver.js +28 -28
  45. package/lib/stats-query/config-interface.d.ts +130 -129
  46. package/lib/stats-query/config-interface.d.ts.map +1 -0
  47. package/lib/stats-query/config-interface.js +3 -3
  48. package/lib/stats-query/constant-manager.d.ts +67 -67
  49. package/lib/stats-query/constant-manager.d.ts.map +1 -0
  50. package/lib/stats-query/constant-manager.js +262 -262
  51. package/lib/stats-query/index.d.ts +162 -91
  52. package/lib/stats-query/index.d.ts.map +1 -0
  53. package/lib/stats-query/index.js +527 -263
  54. package/lib/stats-query/index.js.map +1 -1
  55. package/lib/stats-query/path-utils.d.ts +3 -2
  56. package/lib/stats-query/path-utils.d.ts.map +1 -0
  57. package/lib/stats-query/path-utils.js +35 -35
  58. package/lib/transformer/babel.d.ts +6 -0
  59. package/lib/transformer/babel.d.ts.map +1 -0
  60. package/lib/{config-parser.js → transformer/babel.js} +35 -34
  61. package/lib/transformer/babel.js.map +1 -0
  62. package/lib/transformer/index.d.ts +3 -0
  63. package/lib/transformer/index.d.ts.map +1 -0
  64. package/lib/{config-paerser/config-parser.js → transformer/index.js} +29 -34
  65. package/lib/transformer/index.js.map +1 -0
  66. package/lib/transformer.js +6 -6
  67. package/lib/tsdoc-metadata.json +11 -0
  68. package/lib/utils.d.ts +3 -0
  69. package/lib/utils.d.ts.map +1 -0
  70. package/lib/utils.js +15 -0
  71. package/lib/utils.js.map +1 -0
  72. package/package.json +70 -51
  73. package/static/helper-dynamic-constants.txt +12 -12
  74. package/static/helper-global-exporter.txt +8 -8
  75. package/static/lib.dom.d.ts +20227 -20227
  76. package/lib/babel-plugins/transform-virtual-specifier.js +0 -71
  77. package/lib/babel-plugins/transform-virtual-specifier.js.map +0 -1
  78. package/lib/config-interface.js +0 -3
  79. package/lib/config-interface.js.map +0 -1
  80. package/lib/config-paerser/config-interface.js +0 -3
  81. package/lib/config-paerser/config-interface.js.map +0 -1
  82. package/lib/config-paerser/config-parser.js.map +0 -1
  83. package/lib/config-parser/config-interface.js +0 -4
  84. package/lib/config-parser/config-interface.js.map +0 -1
  85. package/lib/config-parser/config-parser.js +0 -37
  86. package/lib/config-parser/config-parser.js.map +0 -1
  87. package/lib/config-parser/constant-interface.js +0 -3
  88. package/lib/config-parser/constant-interface.js.map +0 -1
  89. package/lib/config-parser/constant-manager.js +0 -263
  90. package/lib/config-parser/constant-manager.js.map +0 -1
  91. package/lib/config-parser/index.js +0 -286
  92. package/lib/config-parser/index.js.map +0 -1
  93. package/lib/config-parser/stats-query.js +0 -248
  94. package/lib/config-parser/stats-query.js.map +0 -1
  95. package/lib/config-parser.js.map +0 -1
  96. package/lib/stats-query/constant-interface.js +0 -3
  97. package/lib/stats-query/constant-interface.js.map +0 -1
  98. package/lib/stats-query/stats-query.js +0 -248
  99. package/lib/stats-query/stats-query.js.map +0 -1
  100. package/lib/transformer.d.ts +0 -2
@@ -1,263 +1,263 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ConstantManager = void 0;
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const path_1 = __importDefault(require("path"));
9
- class ConstantManager {
10
- constructor(engineRoot) {
11
- this._engineRoot = engineRoot;
12
- }
13
- //#region export string
14
- exportDynamicConstants({ mode, platform, flags, }) {
15
- const config = this._getConfig();
16
- // init helper
17
- let result = '';
18
- if (this._hasCCGlobal(config)) {
19
- result += fs_extra_1.default.readFileSync(path_1.default.join(__dirname, '../../static/helper-global-exporter.txt'), 'utf8') + '\n';
20
- }
21
- if (this._hasDynamic(config)) {
22
- result += fs_extra_1.default.readFileSync(path_1.default.join(__dirname, '../../static/helper-dynamic-constants.txt'), 'utf8') + '\n';
23
- }
24
- // update value
25
- if (config[mode]) {
26
- config[mode].value = true;
27
- }
28
- else {
29
- console.warn(`Unknown mode: ${mode}`);
30
- }
31
- if (config[platform]) {
32
- config[platform].value = true;
33
- }
34
- else {
35
- console.warn(`Unknown platform: ${platform}`);
36
- }
37
- for (const key in flags) {
38
- const value = flags[key];
39
- if (config[key]) {
40
- config[key].value = value;
41
- }
42
- else {
43
- console.warn(`Unknown flag: ${key}`);
44
- }
45
- }
46
- // eval value
47
- for (const key in config) {
48
- const info = config[key];
49
- if (typeof info.value === 'string') {
50
- info.value = this._evalExpression(info.value, config);
51
- }
52
- }
53
- // generate export content
54
- for (const key in config) {
55
- const info = config[key];
56
- const value = info.value;
57
- if (info.dynamic || info.internal) {
58
- continue;
59
- }
60
- result += `export const ${key} = ${value};\n`;
61
- if (info.ccGlobal) {
62
- result += `tryDefineGlobal('CC_${key}', ${value});\n`;
63
- }
64
- result += '\n';
65
- }
66
- return result;
67
- }
68
- genBuildTimeConstants(options) {
69
- const config = this._getConfig();
70
- this._applyOptionsToConfig(config, options);
71
- // generate json object
72
- const jsonObj = {};
73
- for (const key in config) {
74
- const info = config[key];
75
- jsonObj[key] = info.value;
76
- }
77
- return jsonObj;
78
- }
79
- genCCEnvConstants(options) {
80
- const config = this._getConfig();
81
- this._applyOptionsToConfig(config, options);
82
- // generate json object
83
- const jsonObj = {};
84
- for (const key in config) {
85
- const info = config[key];
86
- if (!info.internal) {
87
- jsonObj[key] = info.value;
88
- }
89
- }
90
- return jsonObj;
91
- }
92
- exportStaticConstants({ mode, platform, flags, }) {
93
- const config = this._getConfig();
94
- // init helper
95
- let result = '';
96
- if (this._hasCCGlobal(config)) {
97
- result += fs_extra_1.default.readFileSync(path_1.default.join(__dirname, '../../static/helper-global-exporter.txt'), 'utf8') + '\n';
98
- }
99
- // update value
100
- if (config[mode]) {
101
- config[mode].value = true;
102
- }
103
- else {
104
- console.warn(`Unknown mode: ${mode}`);
105
- }
106
- if (config[platform]) {
107
- config[platform].value = true;
108
- }
109
- else {
110
- console.warn(`Unknown platform: ${platform}`);
111
- }
112
- for (const key in flags) {
113
- const value = flags[key];
114
- if (config[key]) {
115
- config[key].value = value;
116
- }
117
- else {
118
- console.warn(`Unknown flag: ${key}`);
119
- }
120
- }
121
- // eval value
122
- for (const key in config) {
123
- const info = config[key];
124
- if (typeof info.value === 'string') {
125
- info.value = this._evalExpression(info.value, config);
126
- }
127
- }
128
- // generate export content
129
- for (const key in config) {
130
- const info = config[key];
131
- const value = info.value;
132
- result += `export const ${key} = ${value};\n`;
133
- if (info.ccGlobal) {
134
- result += `tryDefineGlobal('CC_${key}', ${value});\n`;
135
- }
136
- result += '\n';
137
- }
138
- return result;
139
- }
140
- //#endregion export string
141
- //#region declaration
142
- genInternalConstants() {
143
- const config = this._getConfig();
144
- let result = `declare module 'internal:constants'{\n`;
145
- for (const name in config) {
146
- const info = config[name];
147
- result += this._genConstantDeclaration(name, info);
148
- }
149
- result += '}\n';
150
- return result;
151
- }
152
- genCCEnv() {
153
- const config = this._getConfig();
154
- let result = `declare module 'cc/env'{\n`;
155
- for (const name in config) {
156
- const info = config[name];
157
- if (info.internal) {
158
- continue;
159
- }
160
- result += this._genConstantDeclaration(name, info);
161
- }
162
- result += '}\n';
163
- return result;
164
- }
165
- _genConstantDeclaration(name, info) {
166
- let result = '\t/**\n';
167
- let comments = info.comment.split('\n');
168
- for (const comment of comments) {
169
- result += `\t * ${comment}\n`;
170
- }
171
- result += '\t */\n';
172
- result += `\texport const ${name}: ${info.type};\n\n`;
173
- return result;
174
- }
175
- //#endregion declaration
176
- //#region utils
177
- _getConfig() {
178
- const engineConfig = fs_extra_1.default.readJsonSync(path_1.default.join(this._engineRoot, './cc.config.json').replace(/\\/g, '/'));
179
- const config = engineConfig.constants;
180
- // init default value
181
- for (const key in config) {
182
- const info = config[key];
183
- if (typeof info.ccGlobal === 'undefined') {
184
- info.ccGlobal = false;
185
- }
186
- if (typeof info.dynamic === 'undefined') {
187
- info.dynamic = false;
188
- }
189
- }
190
- return config;
191
- }
192
- _hasCCGlobal(config) {
193
- for (let key in config) {
194
- const info = config[key];
195
- if (info.ccGlobal) {
196
- return true;
197
- }
198
- }
199
- return false;
200
- }
201
- _hasDynamic(config) {
202
- for (let key in config) {
203
- const info = config[key];
204
- if (info.dynamic) {
205
- return true;
206
- }
207
- }
208
- return false;
209
- }
210
- _evalExpression(expression, config) {
211
- // eval sub expression
212
- const matchResult = expression.match(/(?<=\$)\w+/g);
213
- if (matchResult) {
214
- for (let name of matchResult) {
215
- const value = config[name].value;
216
- if (typeof value === 'string') {
217
- config[name].value = this._evalExpression(value, config);
218
- }
219
- }
220
- }
221
- // $EDITOR to $EDITOR.value
222
- expression = expression.replace(/(?<=\$)(\w+)/g, '$1.value');
223
- // $EDITOR to $.EDITOR.value
224
- expression = expression.replace(/\$/g, '$.');
225
- // do eval
226
- const evalFn = new Function('$', `return ${expression}`);
227
- return evalFn(config);
228
- }
229
- _applyOptionsToConfig(config, options) {
230
- const { mode, platform, flags } = options;
231
- // update value
232
- if (config[mode]) {
233
- config[mode].value = true;
234
- }
235
- else {
236
- console.warn(`Unknown mode: ${mode}`);
237
- }
238
- if (config[platform]) {
239
- config[platform].value = true;
240
- }
241
- else {
242
- console.warn(`Unknown platform: ${platform}`);
243
- }
244
- for (const key in flags) {
245
- const value = flags[key];
246
- if (config[key]) {
247
- config[key].value = value;
248
- }
249
- else {
250
- console.warn(`Unknown flag: ${key}`);
251
- }
252
- }
253
- // eval value
254
- for (const key in config) {
255
- const info = config[key];
256
- if (typeof info.value === 'string') {
257
- info.value = this._evalExpression(info.value, config);
258
- }
259
- }
260
- }
261
- }
262
- exports.ConstantManager = ConstantManager;
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ConstantManager = void 0;
7
+ const fs_extra_1 = __importDefault(require("fs-extra"));
8
+ const path_1 = __importDefault(require("path"));
9
+ class ConstantManager {
10
+ constructor(engineRoot) {
11
+ this._engineRoot = engineRoot;
12
+ }
13
+ //#region export string
14
+ exportDynamicConstants({ mode, platform, flags, }) {
15
+ const config = this._getConfig();
16
+ // init helper
17
+ let result = '';
18
+ if (this._hasCCGlobal(config)) {
19
+ result += fs_extra_1.default.readFileSync(path_1.default.join(__dirname, '../../static/helper-global-exporter.txt'), 'utf8') + '\n';
20
+ }
21
+ if (this._hasDynamic(config)) {
22
+ result += fs_extra_1.default.readFileSync(path_1.default.join(__dirname, '../../static/helper-dynamic-constants.txt'), 'utf8') + '\n';
23
+ }
24
+ // update value
25
+ if (config[mode]) {
26
+ config[mode].value = true;
27
+ }
28
+ else {
29
+ console.warn(`Unknown mode: ${mode}`);
30
+ }
31
+ if (config[platform]) {
32
+ config[platform].value = true;
33
+ }
34
+ else {
35
+ console.warn(`Unknown platform: ${platform}`);
36
+ }
37
+ for (const key in flags) {
38
+ const value = flags[key];
39
+ if (config[key]) {
40
+ config[key].value = value;
41
+ }
42
+ else {
43
+ console.warn(`Unknown flag: ${key}`);
44
+ }
45
+ }
46
+ // eval value
47
+ for (const key in config) {
48
+ const info = config[key];
49
+ if (typeof info.value === 'string') {
50
+ info.value = this._evalExpression(info.value, config);
51
+ }
52
+ }
53
+ // generate export content
54
+ for (const key in config) {
55
+ const info = config[key];
56
+ const value = info.value;
57
+ if (info.dynamic || info.internal) {
58
+ continue;
59
+ }
60
+ result += `export const ${key} = ${value};\n`;
61
+ if (info.ccGlobal) {
62
+ result += `tryDefineGlobal('CC_${key}', ${value});\n`;
63
+ }
64
+ result += '\n';
65
+ }
66
+ return result;
67
+ }
68
+ genBuildTimeConstants(options) {
69
+ const config = this._getConfig();
70
+ this._applyOptionsToConfig(config, options);
71
+ // generate json object
72
+ const jsonObj = {};
73
+ for (const key in config) {
74
+ const info = config[key];
75
+ jsonObj[key] = info.value;
76
+ }
77
+ return jsonObj;
78
+ }
79
+ genCCEnvConstants(options) {
80
+ const config = this._getConfig();
81
+ this._applyOptionsToConfig(config, options);
82
+ // generate json object
83
+ const jsonObj = {};
84
+ for (const key in config) {
85
+ const info = config[key];
86
+ if (!info.internal) {
87
+ jsonObj[key] = info.value;
88
+ }
89
+ }
90
+ return jsonObj;
91
+ }
92
+ exportStaticConstants({ mode, platform, flags, }) {
93
+ const config = this._getConfig();
94
+ // init helper
95
+ let result = '';
96
+ if (this._hasCCGlobal(config)) {
97
+ result += fs_extra_1.default.readFileSync(path_1.default.join(__dirname, '../../static/helper-global-exporter.txt'), 'utf8') + '\n';
98
+ }
99
+ // update value
100
+ if (config[mode]) {
101
+ config[mode].value = true;
102
+ }
103
+ else {
104
+ console.warn(`Unknown mode: ${mode}`);
105
+ }
106
+ if (config[platform]) {
107
+ config[platform].value = true;
108
+ }
109
+ else {
110
+ console.warn(`Unknown platform: ${platform}`);
111
+ }
112
+ for (const key in flags) {
113
+ const value = flags[key];
114
+ if (config[key]) {
115
+ config[key].value = value;
116
+ }
117
+ else {
118
+ console.warn(`Unknown flag: ${key}`);
119
+ }
120
+ }
121
+ // eval value
122
+ for (const key in config) {
123
+ const info = config[key];
124
+ if (typeof info.value === 'string') {
125
+ info.value = this._evalExpression(info.value, config);
126
+ }
127
+ }
128
+ // generate export content
129
+ for (const key in config) {
130
+ const info = config[key];
131
+ const value = info.value;
132
+ result += `export const ${key} = ${value};\n`;
133
+ if (info.ccGlobal) {
134
+ result += `tryDefineGlobal('CC_${key}', ${value});\n`;
135
+ }
136
+ result += '\n';
137
+ }
138
+ return result;
139
+ }
140
+ //#endregion export string
141
+ //#region declaration
142
+ genInternalConstants() {
143
+ const config = this._getConfig();
144
+ let result = `declare module 'internal:constants'{\n`;
145
+ for (const name in config) {
146
+ const info = config[name];
147
+ result += this._genConstantDeclaration(name, info);
148
+ }
149
+ result += '}\n';
150
+ return result;
151
+ }
152
+ genCCEnv() {
153
+ const config = this._getConfig();
154
+ let result = `declare module 'cc/env'{\n`;
155
+ for (const name in config) {
156
+ const info = config[name];
157
+ if (info.internal) {
158
+ continue;
159
+ }
160
+ result += this._genConstantDeclaration(name, info);
161
+ }
162
+ result += '}\n';
163
+ return result;
164
+ }
165
+ _genConstantDeclaration(name, info) {
166
+ let result = '\t/**\n';
167
+ let comments = info.comment.split('\n');
168
+ for (const comment of comments) {
169
+ result += `\t * ${comment}\n`;
170
+ }
171
+ result += '\t */\n';
172
+ result += `\texport const ${name}: ${info.type};\n\n`;
173
+ return result;
174
+ }
175
+ //#endregion declaration
176
+ //#region utils
177
+ _getConfig() {
178
+ const engineConfig = fs_extra_1.default.readJsonSync(path_1.default.join(this._engineRoot, './cc.config.json').replace(/\\/g, '/'));
179
+ const config = engineConfig.constants;
180
+ // init default value
181
+ for (const key in config) {
182
+ const info = config[key];
183
+ if (typeof info.ccGlobal === 'undefined') {
184
+ info.ccGlobal = false;
185
+ }
186
+ if (typeof info.dynamic === 'undefined') {
187
+ info.dynamic = false;
188
+ }
189
+ }
190
+ return config;
191
+ }
192
+ _hasCCGlobal(config) {
193
+ for (let key in config) {
194
+ const info = config[key];
195
+ if (info.ccGlobal) {
196
+ return true;
197
+ }
198
+ }
199
+ return false;
200
+ }
201
+ _hasDynamic(config) {
202
+ for (let key in config) {
203
+ const info = config[key];
204
+ if (info.dynamic) {
205
+ return true;
206
+ }
207
+ }
208
+ return false;
209
+ }
210
+ _evalExpression(expression, config) {
211
+ // eval sub expression
212
+ const matchResult = expression.match(/(?<=\$)\w+/g);
213
+ if (matchResult) {
214
+ for (let name of matchResult) {
215
+ const value = config[name].value;
216
+ if (typeof value === 'string') {
217
+ config[name].value = this._evalExpression(value, config);
218
+ }
219
+ }
220
+ }
221
+ // $EDITOR to $EDITOR.value
222
+ expression = expression.replace(/(?<=\$)(\w+)/g, '$1.value');
223
+ // $EDITOR to $.EDITOR.value
224
+ expression = expression.replace(/\$/g, '$.');
225
+ // do eval
226
+ const evalFn = new Function('$', `return ${expression}`);
227
+ return evalFn(config);
228
+ }
229
+ _applyOptionsToConfig(config, options) {
230
+ const { mode, platform, flags } = options;
231
+ // update value
232
+ if (config[mode]) {
233
+ config[mode].value = true;
234
+ }
235
+ else {
236
+ console.warn(`Unknown mode: ${mode}`);
237
+ }
238
+ if (config[platform]) {
239
+ config[platform].value = true;
240
+ }
241
+ else {
242
+ console.warn(`Unknown platform: ${platform}`);
243
+ }
244
+ for (const key in flags) {
245
+ const value = flags[key];
246
+ if (config[key]) {
247
+ config[key].value = value;
248
+ }
249
+ else {
250
+ console.warn(`Unknown flag: ${key}`);
251
+ }
252
+ }
253
+ // eval value
254
+ for (const key in config) {
255
+ const info = config[key];
256
+ if (typeof info.value === 'string') {
257
+ info.value = this._evalExpression(info.value, config);
258
+ }
259
+ }
260
+ }
261
+ }
262
+ exports.ConstantManager = ConstantManager;
263
263
  //# sourceMappingURL=constant-manager.js.map