app-bundler 0.1.17 → 0.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/lib/bundler.js +526 -124
- package/lib/cli.js +526 -124
- package/package.json +6 -5
- package/tsconfig.json +5 -0
package/lib/cli.js
CHANGED
|
@@ -78,6 +78,10 @@ var _src_handlers_script_common_js_CommonJsPathResolver = {};
|
|
|
78
78
|
var _src_handlers_script_common_js_CommonJsRewriter = {};
|
|
79
79
|
var _src_handlers_script_common_js_ModuleWrapper = {};
|
|
80
80
|
var _src_handlers_script_common_js_templates_Templates = {};
|
|
81
|
+
var _src_handlers_script_copy_js_CopyJsBuilder = {};
|
|
82
|
+
var _src_handlers_script_copy_js_CopyJsHandler = {};
|
|
83
|
+
var _src_handlers_script_copy_js_CopyJsParser = {};
|
|
84
|
+
var _src_handlers_script_copy_js_CopyJsRewriter = {};
|
|
81
85
|
var _src_handlers_script_global_js_GlobalJsBuilder = {};
|
|
82
86
|
var _src_handlers_script_global_js_GlobalJsHandler = {};
|
|
83
87
|
var _src_handlers_script_global_js_GlobalJsParser = {};
|
|
@@ -132,7 +136,7 @@ let assert = require('assert');
|
|
|
132
136
|
exports.assert = assert;
|
|
133
137
|
let logger = require('atma-logger');
|
|
134
138
|
exports.logger = logger;
|
|
135
|
-
let io = g.io || require('atma-io');
|
|
139
|
+
let io = (g.io || require('atma-io'));
|
|
136
140
|
exports.io = io;
|
|
137
141
|
/* Make compatible with previous atma-loaders */
|
|
138
142
|
g.Class = require('atma-class');
|
|
@@ -166,8 +170,8 @@ var _src_utils_path;
|
|
|
166
170
|
|
|
167
171
|
"use strict";
|
|
168
172
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
169
|
-
exports.path_toAbsolute = exports.path_removeQuery = exports.path_sliceQuery = exports.path_sliceHash = exports.path_combine = exports.path_toRelative = exports.path_isRelative = exports.path_resolveUrl = exports.path_normalize = exports.path_resolveCurrent = exports.path_withProtocol = exports.path_appendQuery = exports.path_getExtension = exports.path_getFile = exports.path_getDir = void 0;
|
|
170
|
-
|
|
173
|
+
exports.path_toAbsolute = exports.path_changeExtension = exports.path_removeQuery = exports.path_sliceQuery = exports.path_sliceHash = exports.path_combine = exports.path_toRelative = exports.path_isRelative = exports.path_resolveUrl = exports.path_normalize = exports.path_resolveCurrent = exports.path_withProtocol = exports.path_appendQuery = exports.path_getExtension = exports.path_getFile = exports.path_getDir = void 0;
|
|
174
|
+
let isWeb = true;
|
|
171
175
|
function path_getDir(path) {
|
|
172
176
|
return path.substring(0, path.lastIndexOf('/') + 1);
|
|
173
177
|
}
|
|
@@ -187,17 +191,17 @@ function path_getFile(path) {
|
|
|
187
191
|
exports.path_getFile = path_getFile;
|
|
188
192
|
;
|
|
189
193
|
function path_getExtension(path) {
|
|
190
|
-
|
|
194
|
+
let query = path.indexOf('?');
|
|
191
195
|
if (query !== -1) {
|
|
192
196
|
path = path.substring(0, query);
|
|
193
197
|
}
|
|
194
|
-
|
|
198
|
+
let match = rgx_EXT.exec(path);
|
|
195
199
|
return match == null ? '' : match[1];
|
|
196
200
|
}
|
|
197
201
|
exports.path_getExtension = path_getExtension;
|
|
198
202
|
;
|
|
199
203
|
function path_appendQuery(path, key, val) {
|
|
200
|
-
|
|
204
|
+
let conjunctor = path.indexOf('?') === -1 ? '?' : '&';
|
|
201
205
|
return path + conjunctor + key + '=' + val;
|
|
202
206
|
}
|
|
203
207
|
exports.path_appendQuery = path_appendQuery;
|
|
@@ -207,7 +211,7 @@ function path_withProtocol(path) {
|
|
|
207
211
|
}
|
|
208
212
|
exports.path_withProtocol = path_withProtocol;
|
|
209
213
|
;
|
|
210
|
-
|
|
214
|
+
let current_;
|
|
211
215
|
function path_resolveCurrent() {
|
|
212
216
|
if (current_ != null)
|
|
213
217
|
return current_;
|
|
@@ -216,7 +220,7 @@ function path_resolveCurrent() {
|
|
|
216
220
|
exports.path_resolveCurrent = path_resolveCurrent;
|
|
217
221
|
;
|
|
218
222
|
function path_normalize(path) {
|
|
219
|
-
|
|
223
|
+
let path_ = path
|
|
220
224
|
.replace(/\\/g, '/')
|
|
221
225
|
// remove double slashes, but not near protocol
|
|
222
226
|
.replace(/([^:\/])\/{2,}/g, '$1/')
|
|
@@ -233,7 +237,7 @@ function path_normalize(path) {
|
|
|
233
237
|
exports.path_normalize = path_normalize;
|
|
234
238
|
;
|
|
235
239
|
function path_resolveUrl(path, base) {
|
|
236
|
-
|
|
240
|
+
let url = path_normalize(path);
|
|
237
241
|
if (path_isRelative(url)) {
|
|
238
242
|
return path_normalize(path_combine(base || path_resolveCurrent(), url));
|
|
239
243
|
}
|
|
@@ -264,9 +268,9 @@ function path_toRelative(path, anchor, base) {
|
|
|
264
268
|
return path_.substring(absolute_.length);
|
|
265
269
|
}
|
|
266
270
|
else {
|
|
267
|
-
|
|
271
|
+
let sub = '../';
|
|
268
272
|
while (true) {
|
|
269
|
-
|
|
273
|
+
let folder = absolute_.replace(/[^\/]+\/?$/, '');
|
|
270
274
|
if (folder === '' || folder === absolute_) {
|
|
271
275
|
break;
|
|
272
276
|
}
|
|
@@ -282,7 +286,9 @@ function path_toRelative(path, anchor, base) {
|
|
|
282
286
|
exports.path_toRelative = path_toRelative;
|
|
283
287
|
;
|
|
284
288
|
function path_combine(...args) {
|
|
285
|
-
|
|
289
|
+
let out = '';
|
|
290
|
+
let imax = args.length;
|
|
291
|
+
let i = -1, x;
|
|
286
292
|
while (++i < imax) {
|
|
287
293
|
x = args[i];
|
|
288
294
|
if (!x)
|
|
@@ -305,38 +311,54 @@ function path_combine(...args) {
|
|
|
305
311
|
exports.path_combine = path_combine;
|
|
306
312
|
;
|
|
307
313
|
function path_sliceHash(url) {
|
|
308
|
-
if (url == null)
|
|
314
|
+
if (url == null) {
|
|
309
315
|
return null;
|
|
310
|
-
|
|
311
|
-
|
|
316
|
+
}
|
|
317
|
+
let i = url.indexOf('#');
|
|
318
|
+
if (i === -1) {
|
|
312
319
|
return null;
|
|
320
|
+
}
|
|
313
321
|
return url.substring(i);
|
|
314
322
|
}
|
|
315
323
|
exports.path_sliceHash = path_sliceHash;
|
|
316
324
|
;
|
|
317
325
|
function path_sliceQuery(url) {
|
|
318
|
-
if (url == null)
|
|
326
|
+
if (url == null) {
|
|
319
327
|
return null;
|
|
320
|
-
|
|
321
|
-
|
|
328
|
+
}
|
|
329
|
+
let i = url.indexOf('?');
|
|
330
|
+
if (i === -1) {
|
|
322
331
|
return null;
|
|
332
|
+
}
|
|
323
333
|
return url.substring(i);
|
|
324
334
|
}
|
|
325
335
|
exports.path_sliceQuery = path_sliceQuery;
|
|
326
336
|
;
|
|
327
337
|
function path_removeQuery(url) {
|
|
328
|
-
if (url == null)
|
|
338
|
+
if (url == null) {
|
|
329
339
|
return null;
|
|
330
|
-
|
|
331
|
-
|
|
340
|
+
}
|
|
341
|
+
let i = url.indexOf('#');
|
|
342
|
+
if (i !== -1) {
|
|
332
343
|
url = url.substring(0, i);
|
|
333
|
-
|
|
334
|
-
|
|
344
|
+
}
|
|
345
|
+
i = url.indexOf('?');
|
|
346
|
+
if (i !== -1) {
|
|
335
347
|
url = url.substring(0, i);
|
|
348
|
+
}
|
|
336
349
|
return url;
|
|
337
350
|
}
|
|
338
351
|
exports.path_removeQuery = path_removeQuery;
|
|
339
352
|
;
|
|
353
|
+
function path_changeExtension(path, ext) {
|
|
354
|
+
let str = ext ? '.' + ext : '';
|
|
355
|
+
let i = path.indexOf('.');
|
|
356
|
+
if (i === -1) {
|
|
357
|
+
return path + str;
|
|
358
|
+
}
|
|
359
|
+
return path.substring(0, i) + str;
|
|
360
|
+
}
|
|
361
|
+
exports.path_changeExtension = path_changeExtension;
|
|
340
362
|
function path_toAbsolute(path, parentLocation, rootLocation) {
|
|
341
363
|
path = path_normalize(path);
|
|
342
364
|
if (path_isRelative(path) === false) {
|
|
@@ -355,11 +377,11 @@ function path_toAbsolute(path, parentLocation, rootLocation) {
|
|
|
355
377
|
}
|
|
356
378
|
exports.path_toAbsolute = path_toAbsolute;
|
|
357
379
|
;
|
|
358
|
-
|
|
380
|
+
let _cwd;
|
|
359
381
|
function cwd() {
|
|
360
382
|
return _cwd || (_cwd = path_normalize(process.cwd()));
|
|
361
383
|
}
|
|
362
|
-
|
|
384
|
+
let rgx_PROTOCOL = /^(file|https?):/i, rgx_SUB_DIR = /[^\/\.]+\/\.\.\//, rgx_FILENAME = /\/[^\/]+\.\w+(\?.*)?(#.*)?$/, rgx_EXT = /\.(\w+)$/, rgx_win32Drive = /(^\/?\w{1}:)(\/|$)/;
|
|
363
385
|
function path_win32Normalize(path) {
|
|
364
386
|
path = path_normalize(path);
|
|
365
387
|
if (path.substring(0, 5) === 'file:')
|
|
@@ -367,7 +389,7 @@ function path_win32Normalize(path) {
|
|
|
367
389
|
return 'file://' + path;
|
|
368
390
|
}
|
|
369
391
|
function path_collapse(url_) {
|
|
370
|
-
|
|
392
|
+
let url = url_;
|
|
371
393
|
while (rgx_SUB_DIR.test(url)) {
|
|
372
394
|
url = url.replace(rgx_SUB_DIR, '');
|
|
373
395
|
}
|
|
@@ -1410,6 +1432,8 @@ class Resource {
|
|
|
1410
1432
|
this.inPages = null;
|
|
1411
1433
|
this.isCyclic = false;
|
|
1412
1434
|
this.isMapped = false;
|
|
1435
|
+
// when the path is like "/foo/bar/**.ts"
|
|
1436
|
+
this.isGlob = false;
|
|
1413
1437
|
this.meta = null;
|
|
1414
1438
|
this.aliases = [];
|
|
1415
1439
|
if (arguments.length === 0)
|
|
@@ -1436,6 +1460,7 @@ class Resource {
|
|
|
1436
1460
|
this.asModules = [];
|
|
1437
1461
|
this.inPages = [];
|
|
1438
1462
|
this.source = null;
|
|
1463
|
+
this.isGlob = /\*+\.\w+$/.test(includeData.url);
|
|
1439
1464
|
if (includeData.bundle) {
|
|
1440
1465
|
this.bundle = includeData.bundle;
|
|
1441
1466
|
}
|
|
@@ -1488,7 +1513,11 @@ class Resource {
|
|
|
1488
1513
|
}
|
|
1489
1514
|
if (Include_1.Include.PathResolver.isNpm(includeData.url)) {
|
|
1490
1515
|
this.aliases.push(includeData.url);
|
|
1491
|
-
|
|
1516
|
+
let byNpmResolver = npm_1.Npm.resolveAppUrl(includeData.url, parent && parent.location, solution.opts.base);
|
|
1517
|
+
if (byNpmResolver != null) {
|
|
1518
|
+
// otherwise "url" could be previously resolved with pathResolver.resolve
|
|
1519
|
+
url = byNpmResolver;
|
|
1520
|
+
}
|
|
1492
1521
|
if (url == null) {
|
|
1493
1522
|
// Fix. `resolveAppUrl` returns undefined on native nodejs modules
|
|
1494
1523
|
url = includeData.url;
|
|
@@ -1546,6 +1575,8 @@ class Resource {
|
|
|
1546
1575
|
res.source = this.source;
|
|
1547
1576
|
res.isCyclic = this.isCyclic;
|
|
1548
1577
|
res.aliases = this.aliases;
|
|
1578
|
+
res.isGlob = this.isGlob;
|
|
1579
|
+
res.dependencies = this.dependencies;
|
|
1549
1580
|
return res;
|
|
1550
1581
|
}
|
|
1551
1582
|
toTarget(solution, settings) {
|
|
@@ -1558,6 +1589,7 @@ class Resource {
|
|
|
1558
1589
|
resource.inPages = this.inPages;
|
|
1559
1590
|
resource.bundle = this.bundle;
|
|
1560
1591
|
resource.aliases = this.aliases;
|
|
1592
|
+
resource.isGlob = this.isGlob;
|
|
1561
1593
|
if (solution.opts.version && ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.type) !== 'load') {
|
|
1562
1594
|
resource.url += '?v=' + solution.opts.version;
|
|
1563
1595
|
}
|
|
@@ -1642,7 +1674,7 @@ class Resource {
|
|
|
1642
1674
|
if (modules.length === 1) {
|
|
1643
1675
|
return modules[0];
|
|
1644
1676
|
}
|
|
1645
|
-
let arr = ['global', 'commonjs', 'amd', 'includejs', 'import'];
|
|
1677
|
+
let arr = ['global', 'commonjs', 'amd', 'includejs', 'import', 'esm'];
|
|
1646
1678
|
let name = arr.find(name => modules.indexOf(name) !== -1);
|
|
1647
1679
|
if (name == null) {
|
|
1648
1680
|
name = modules[0];
|
|
@@ -2343,6 +2375,18 @@ exports.FileActions = {
|
|
|
2343
2375
|
}
|
|
2344
2376
|
return global_1.io.File.readAsync(path, opts);
|
|
2345
2377
|
},
|
|
2378
|
+
async readDirectory(path, opts) {
|
|
2379
|
+
let i = path.indexOf('*');
|
|
2380
|
+
let patternI = path.lastIndexOf('/', i);
|
|
2381
|
+
if (patternI === -1) {
|
|
2382
|
+
throw new Error(`Invalid glob pattern: ${path}`);
|
|
2383
|
+
}
|
|
2384
|
+
let pattern = path.substring(patternI + 1);
|
|
2385
|
+
let directory = path.substring(0, patternI + 1);
|
|
2386
|
+
let files = await global_1.io.Directory.readFiles(directory, pattern);
|
|
2387
|
+
let paths = files.map(x => x.uri.toString());
|
|
2388
|
+
return paths;
|
|
2389
|
+
},
|
|
2346
2390
|
writeFile(path, content, opts) {
|
|
2347
2391
|
return global_1.io.File.writeAsync(path, content, opts);
|
|
2348
2392
|
},
|
|
@@ -2418,7 +2462,7 @@ class Configuration {
|
|
|
2418
2462
|
}
|
|
2419
2463
|
}
|
|
2420
2464
|
defineMany(options) {
|
|
2421
|
-
for (
|
|
2465
|
+
for (let key in options) {
|
|
2422
2466
|
this.define(key, options[key]);
|
|
2423
2467
|
}
|
|
2424
2468
|
}
|
|
@@ -2968,13 +3012,17 @@ class OutputResources {
|
|
|
2968
3012
|
this.resources = [];
|
|
2969
3013
|
this.pagesInput = {};
|
|
2970
3014
|
}
|
|
2971
|
-
|
|
3015
|
+
prepare(resources) {
|
|
2972
3016
|
this.resources = [];
|
|
2973
3017
|
this.pagesInput = {};
|
|
2974
3018
|
this.items = [];
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
3019
|
+
let root = resources.pop();
|
|
3020
|
+
let isGlob = root.isGlob;
|
|
3021
|
+
if (isGlob !== true) {
|
|
3022
|
+
this.rootOutput = root.toTarget(this.solution);
|
|
3023
|
+
this.rootOutput.content = root.content;
|
|
3024
|
+
}
|
|
3025
|
+
this.rootInput = root;
|
|
2978
3026
|
this.pagesInput = (0, res_1.res_groupByPageAndBundles)(resources, this.solution.opts);
|
|
2979
3027
|
Object.keys(this.pagesInput).forEach(page => {
|
|
2980
3028
|
Object.keys(this.pagesInput[page]).forEach(bundle => {
|
|
@@ -2987,20 +3035,22 @@ class OutputResources {
|
|
|
2987
3035
|
bundle,
|
|
2988
3036
|
type,
|
|
2989
3037
|
solution: this.solution,
|
|
2990
|
-
resources: arr
|
|
3038
|
+
resources: arr,
|
|
3039
|
+
isGlob: isGlob,
|
|
2991
3040
|
});
|
|
2992
3041
|
this.items.push(item);
|
|
2993
3042
|
});
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3043
|
+
// @TODO: Do we need empty output item?
|
|
3044
|
+
// if (byType['js'] == null) {
|
|
3045
|
+
// let item = new OutputItem({
|
|
3046
|
+
// page,
|
|
3047
|
+
// bundle,
|
|
3048
|
+
// type: 'js',
|
|
3049
|
+
// solution: this.solution,
|
|
3050
|
+
// resources: []
|
|
3051
|
+
// });
|
|
3052
|
+
// this.items.push(item);
|
|
3053
|
+
// }
|
|
3004
3054
|
});
|
|
3005
3055
|
});
|
|
3006
3056
|
}
|
|
@@ -3008,7 +3058,7 @@ class OutputResources {
|
|
|
3008
3058
|
return this.items.filter(x => x.page === page).map(x => x.resource);
|
|
3009
3059
|
}
|
|
3010
3060
|
getAll() {
|
|
3011
|
-
|
|
3061
|
+
let all = this
|
|
3012
3062
|
.items
|
|
3013
3063
|
.map(x => x.resource)
|
|
3014
3064
|
.filter(x => x.embed !== true)
|
|
@@ -3021,19 +3071,27 @@ class OutputResources {
|
|
|
3021
3071
|
}
|
|
3022
3072
|
exports.OutputResources = OutputResources;
|
|
3023
3073
|
class OutputItem {
|
|
3024
|
-
constructor(
|
|
3074
|
+
constructor(params) {
|
|
3075
|
+
let { page, bundle, type, solution, resources, isGlob } = params;
|
|
3025
3076
|
this.page = page;
|
|
3026
3077
|
this.bundle = bundle;
|
|
3027
3078
|
this.type = type;
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3079
|
+
this.resource = params.resource;
|
|
3080
|
+
this.resources = resources !== null && resources !== void 0 ? resources : [];
|
|
3081
|
+
if (this.resource == null) {
|
|
3082
|
+
let ext = solution.opts.getExtForType(type);
|
|
3083
|
+
let sfx = '';
|
|
3084
|
+
if (isGlob === true) {
|
|
3085
|
+
sfx = '_*';
|
|
3086
|
+
}
|
|
3087
|
+
let filename = `${page}_${bundle}${sfx}.${ext}`;
|
|
3088
|
+
let resource = new Resource_1.Resource({
|
|
3089
|
+
type: type,
|
|
3090
|
+
url: filename,
|
|
3091
|
+
bundle: bundle
|
|
3092
|
+
}, null, solution);
|
|
3093
|
+
this.resource = resource.toTarget(solution);
|
|
3094
|
+
}
|
|
3037
3095
|
}
|
|
3038
3096
|
}
|
|
3039
3097
|
exports.OutputItem = OutputItem;
|
|
@@ -3907,7 +3965,7 @@ class MaskParser extends BaseParser_1.BaseParser {
|
|
|
3907
3965
|
// @NextIteration base will be handled in mask.Module.resolvePath
|
|
3908
3966
|
// var base = mask.Module.cfg('base');
|
|
3909
3967
|
// if (base) {
|
|
3910
|
-
//
|
|
3968
|
+
// path = path_combine(base, path);
|
|
3911
3969
|
// }
|
|
3912
3970
|
}
|
|
3913
3971
|
return [this._createDependency(path, type, page)];
|
|
@@ -5613,8 +5671,18 @@ const BaseScriptBuilder_1 = _src_handlers_script_base_BaseScriptBuilder;
|
|
|
5613
5671
|
class AmdJsBuilder extends BaseScriptBuilder_1.BaseScriptBuilder {
|
|
5614
5672
|
buildRoot(resource, dependencies) {
|
|
5615
5673
|
}
|
|
5616
|
-
|
|
5617
|
-
return
|
|
5674
|
+
wrapModule(resource, outputItem) {
|
|
5675
|
+
return resource.content;
|
|
5676
|
+
}
|
|
5677
|
+
accepts(resource) {
|
|
5678
|
+
if (resource.type !== 'js') {
|
|
5679
|
+
return false;
|
|
5680
|
+
}
|
|
5681
|
+
let module = resource.getModule();
|
|
5682
|
+
if (module === 'root' && resource.solution.opts.package.module === 'amd') {
|
|
5683
|
+
module = 'amd';
|
|
5684
|
+
}
|
|
5685
|
+
return module === 'amd';
|
|
5618
5686
|
}
|
|
5619
5687
|
}
|
|
5620
5688
|
exports.AmdJsBuilder = AmdJsBuilder;
|
|
@@ -5699,12 +5767,12 @@ class ResourcePropMapping {
|
|
|
5699
5767
|
this.resB = resB;
|
|
5700
5768
|
}
|
|
5701
5769
|
map(resource) {
|
|
5702
|
-
|
|
5703
|
-
for (
|
|
5704
|
-
|
|
5770
|
+
let match = true;
|
|
5771
|
+
for (let key in this.resA) {
|
|
5772
|
+
let val = this.resA[key];
|
|
5705
5773
|
if (val == null)
|
|
5706
5774
|
continue;
|
|
5707
|
-
|
|
5775
|
+
let currentVal = resource[key];
|
|
5708
5776
|
if (typeof val === 'function') {
|
|
5709
5777
|
match = val(currentVal);
|
|
5710
5778
|
}
|
|
@@ -5714,13 +5782,14 @@ class ResourcePropMapping {
|
|
|
5714
5782
|
if (typeof val === 'string' || typeof val === 'number') {
|
|
5715
5783
|
match = val === currentVal;
|
|
5716
5784
|
}
|
|
5717
|
-
if (match == false)
|
|
5785
|
+
if (match == false) {
|
|
5718
5786
|
return resource;
|
|
5787
|
+
}
|
|
5719
5788
|
}
|
|
5720
|
-
|
|
5721
|
-
for (
|
|
5722
|
-
|
|
5723
|
-
|
|
5789
|
+
let clone = resource.clone();
|
|
5790
|
+
for (let key in this.resB) {
|
|
5791
|
+
let val = this.resB[key];
|
|
5792
|
+
let currentVal = resource[key];
|
|
5724
5793
|
if (typeof val === 'function') {
|
|
5725
5794
|
clone[key] = val(currentVal, resource);
|
|
5726
5795
|
continue;
|
|
@@ -5778,7 +5847,7 @@ class IncludeJsParser extends BaseParser_1.BaseParser {
|
|
|
5778
5847
|
}
|
|
5779
5848
|
}
|
|
5780
5849
|
getDependencies(ast, ownerResource) {
|
|
5781
|
-
|
|
5850
|
+
let info = {
|
|
5782
5851
|
type: null,
|
|
5783
5852
|
url: null,
|
|
5784
5853
|
dependencies: [],
|
|
@@ -5795,7 +5864,7 @@ class IncludeJsParser extends BaseParser_1.BaseParser {
|
|
|
5795
5864
|
function isIncludeSymbolRef(node) {
|
|
5796
5865
|
return AstUtil_1.AstUtil.is.type(node, 'AST_SymbolRef') && node.name == 'include';
|
|
5797
5866
|
}
|
|
5798
|
-
|
|
5867
|
+
let scope = AstUtil_1.AstUtil.findNode(node, isIncludeSymbolRef).scope || ast;
|
|
5799
5868
|
this._process(info, node, scope);
|
|
5800
5869
|
return true;
|
|
5801
5870
|
});
|
|
@@ -5805,7 +5874,7 @@ class IncludeJsParser extends BaseParser_1.BaseParser {
|
|
|
5805
5874
|
return new atma_utils_1.class_Dfr().resolve(info);
|
|
5806
5875
|
}
|
|
5807
5876
|
_process(info, node, scope) {
|
|
5808
|
-
|
|
5877
|
+
let arr = [];
|
|
5809
5878
|
function isIncludeMethodCall(node) {
|
|
5810
5879
|
return AstUtil_1.AstUtil.is.type(node, 'AST_Call') && node.start.value == 'include';
|
|
5811
5880
|
}
|
|
@@ -5820,7 +5889,7 @@ class IncludeJsParser extends BaseParser_1.BaseParser {
|
|
|
5820
5889
|
case 'routes':
|
|
5821
5890
|
case 'setBase':
|
|
5822
5891
|
case 'cfg':
|
|
5823
|
-
|
|
5892
|
+
let pckg = {
|
|
5824
5893
|
type: node.expression.property,
|
|
5825
5894
|
args: AstUtil_1.AstUtil.getArguments(node.args, scope),
|
|
5826
5895
|
};
|
|
@@ -5852,7 +5921,7 @@ class IncludeJsParser extends BaseParser_1.BaseParser {
|
|
|
5852
5921
|
break;
|
|
5853
5922
|
}
|
|
5854
5923
|
});
|
|
5855
|
-
|
|
5924
|
+
let include = new Include_1.Include();
|
|
5856
5925
|
arr.forEach(function (x) {
|
|
5857
5926
|
include[x.type].apply(include, x.args);
|
|
5858
5927
|
});
|
|
@@ -5862,28 +5931,28 @@ class IncludeJsParser extends BaseParser_1.BaseParser {
|
|
|
5862
5931
|
if (AstUtil_1.AstUtil.is.type(CallbackNode, 'AST_Function') == false) {
|
|
5863
5932
|
return;
|
|
5864
5933
|
}
|
|
5865
|
-
|
|
5934
|
+
let meta = info.meta.includejs, args = CallbackNode.argnames, responseObjectName = args.length > 0
|
|
5866
5935
|
? args[args.length - 1].name
|
|
5867
5936
|
: null;
|
|
5868
5937
|
if (responseObjectName) {
|
|
5869
5938
|
meta.hasResponseObject = true;
|
|
5870
|
-
|
|
5939
|
+
let names = this._getPropertyAccessors(responseObjectName, CallbackNode);
|
|
5871
5940
|
if (names) {
|
|
5872
5941
|
meta.responseAccessors = (meta.responseAccessors || []).concat(names);
|
|
5873
5942
|
}
|
|
5874
5943
|
}
|
|
5875
5944
|
}
|
|
5876
5945
|
/**
|
|
5877
|
-
*
|
|
5946
|
+
* resolve %name%.propertyAccessor
|
|
5878
5947
|
*/
|
|
5879
5948
|
_getPropertyAccessors(name, Fn) {
|
|
5880
|
-
|
|
5949
|
+
let references = [];
|
|
5881
5950
|
Fn.body.forEach(function (x) {
|
|
5882
5951
|
function isSymbolName(node) {
|
|
5883
5952
|
return AstUtil_1.AstUtil.is.type(node, 'AST_SymbolRef') && node.name === name;
|
|
5884
5953
|
}
|
|
5885
5954
|
AstUtil_1.AstUtil.each(x, isSymbolName, function (node) {
|
|
5886
|
-
|
|
5955
|
+
let chain = AstUtil_1.AstUtil.getPropertyChain(node, this.stack);
|
|
5887
5956
|
if (chain) {
|
|
5888
5957
|
references.push(chain);
|
|
5889
5958
|
}
|
|
@@ -5892,16 +5961,16 @@ class IncludeJsParser extends BaseParser_1.BaseParser {
|
|
|
5892
5961
|
return references;
|
|
5893
5962
|
}
|
|
5894
5963
|
/**
|
|
5895
|
-
*
|
|
5964
|
+
* aim to find all **.exports = X
|
|
5896
5965
|
*/
|
|
5897
5966
|
_getPropertySetter(name, Fn) {
|
|
5898
|
-
|
|
5967
|
+
let result = null;
|
|
5899
5968
|
Fn.body.forEach(function (x) {
|
|
5900
5969
|
function isPropertyName(node) {
|
|
5901
5970
|
AstUtil_1.AstUtil.is.type(node, 'AST_Assign') && node.left.property === name;
|
|
5902
5971
|
}
|
|
5903
5972
|
AstUtil_1.AstUtil.each(x, isPropertyName, function (node) {
|
|
5904
|
-
|
|
5973
|
+
let arr = ['include', 'module', 'exports'];
|
|
5905
5974
|
if (arr.indexOf(node.start.value) > -1) {
|
|
5906
5975
|
result = node;
|
|
5907
5976
|
}
|
|
@@ -5912,12 +5981,12 @@ class IncludeJsParser extends BaseParser_1.BaseParser {
|
|
|
5912
5981
|
}
|
|
5913
5982
|
exports.IncludeJsParser = IncludeJsParser;
|
|
5914
5983
|
;
|
|
5915
|
-
|
|
5984
|
+
let IncludeJsMappings = [
|
|
5916
5985
|
new ResourcePropMapping_1.ResourcePropMapping({
|
|
5917
5986
|
asModules: (arr) => arr.indexOf('mask') > -1
|
|
5918
5987
|
}, {
|
|
5919
5988
|
asModules: (arr) => {
|
|
5920
|
-
|
|
5989
|
+
let i = arr.indexOf('mask');
|
|
5921
5990
|
arr[i] = 'includejs';
|
|
5922
5991
|
return arr;
|
|
5923
5992
|
}
|
|
@@ -5926,7 +5995,7 @@ var IncludeJsMappings = [
|
|
|
5926
5995
|
asModules: (arr) => arr.indexOf('amd') > -1
|
|
5927
5996
|
}, {
|
|
5928
5997
|
asModules: (arr) => {
|
|
5929
|
-
|
|
5998
|
+
let i = arr.indexOf('amd');
|
|
5930
5999
|
arr[i] = 'includejs';
|
|
5931
6000
|
return arr;
|
|
5932
6001
|
}
|
|
@@ -7644,7 +7713,8 @@ class ScriptParser extends BaseParser_1.BaseParser {
|
|
|
7644
7713
|
dfrs.unshift(...asTextDfrs);
|
|
7645
7714
|
return (0, async_1.async_whenAll)(dfrs).then(results => {
|
|
7646
7715
|
let arr = (0, arr_1.arr_flattern)(results);
|
|
7647
|
-
|
|
7716
|
+
let merged = ResourceInfo_1.ResourceInfo.merge(...arr);
|
|
7717
|
+
return merged;
|
|
7648
7718
|
});
|
|
7649
7719
|
}
|
|
7650
7720
|
accepts(type) {
|
|
@@ -8142,6 +8212,297 @@ MaskJsHandler.PathResolver = null;
|
|
|
8142
8212
|
// end:source ./ModuleSimplified.js
|
|
8143
8213
|
|
|
8144
8214
|
|
|
8215
|
+
// source ./ModuleSimplified.js
|
|
8216
|
+
var _src_handlers_script_copy_js_CopyJsParser;
|
|
8217
|
+
(function () {
|
|
8218
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
8219
|
+
var define = null;
|
|
8220
|
+
var exports = _src_handlers_script_copy_js_CopyJsParser != null ? _src_handlers_script_copy_js_CopyJsParser : {};
|
|
8221
|
+
var module = { exports: exports };
|
|
8222
|
+
|
|
8223
|
+
"use strict";
|
|
8224
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8225
|
+
exports.CopyJsParser = void 0;
|
|
8226
|
+
const BaseParser_1 = _src_handlers_base_BaseParser;
|
|
8227
|
+
class CopyJsParser extends BaseParser_1.BaseParser {
|
|
8228
|
+
getDependencies(ast, ownerResource) {
|
|
8229
|
+
return null;
|
|
8230
|
+
}
|
|
8231
|
+
}
|
|
8232
|
+
exports.CopyJsParser = CopyJsParser;
|
|
8233
|
+
;
|
|
8234
|
+
//# sourceMappingURL=CopyJsParser.js.map
|
|
8235
|
+
//# sourceMappingURL=CopyJsParser.ts.map;
|
|
8236
|
+
|
|
8237
|
+
function __isObj(x) {
|
|
8238
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
8239
|
+
}
|
|
8240
|
+
if (_src_handlers_script_copy_js_CopyJsParser === module.exports) {
|
|
8241
|
+
// do nothing if
|
|
8242
|
+
} else if (__isObj(_src_handlers_script_copy_js_CopyJsParser) && __isObj(module.exports)) {
|
|
8243
|
+
Object.assign(_src_handlers_script_copy_js_CopyJsParser, module.exports);
|
|
8244
|
+
} else {
|
|
8245
|
+
_src_handlers_script_copy_js_CopyJsParser = module.exports;
|
|
8246
|
+
}
|
|
8247
|
+
|
|
8248
|
+
;
|
|
8249
|
+
}());
|
|
8250
|
+
|
|
8251
|
+
// end:source ./ModuleSimplified.js
|
|
8252
|
+
|
|
8253
|
+
|
|
8254
|
+
// source ./ModuleSimplified.js
|
|
8255
|
+
var _src_handlers_script_copy_js_CopyJsRewriter;
|
|
8256
|
+
(function () {
|
|
8257
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
8258
|
+
var define = null;
|
|
8259
|
+
var exports = _src_handlers_script_copy_js_CopyJsRewriter != null ? _src_handlers_script_copy_js_CopyJsRewriter : {};
|
|
8260
|
+
var module = { exports: exports };
|
|
8261
|
+
|
|
8262
|
+
"use strict";
|
|
8263
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8264
|
+
exports.CopyJsRewriter = void 0;
|
|
8265
|
+
const BaseRewriter_1 = _src_handlers_base_BaseRewriter;
|
|
8266
|
+
class CopyJsRewriter extends BaseRewriter_1.BaseRewriter {
|
|
8267
|
+
rewritePartial(content, ownerResource) {
|
|
8268
|
+
}
|
|
8269
|
+
rewriteResource(resource) {
|
|
8270
|
+
}
|
|
8271
|
+
accepts(type) {
|
|
8272
|
+
return type === 'mask';
|
|
8273
|
+
}
|
|
8274
|
+
}
|
|
8275
|
+
exports.CopyJsRewriter = CopyJsRewriter;
|
|
8276
|
+
;
|
|
8277
|
+
//# sourceMappingURL=CopyJsRewriter.js.map
|
|
8278
|
+
//# sourceMappingURL=CopyJsRewriter.ts.map;
|
|
8279
|
+
|
|
8280
|
+
function __isObj(x) {
|
|
8281
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
8282
|
+
}
|
|
8283
|
+
if (_src_handlers_script_copy_js_CopyJsRewriter === module.exports) {
|
|
8284
|
+
// do nothing if
|
|
8285
|
+
} else if (__isObj(_src_handlers_script_copy_js_CopyJsRewriter) && __isObj(module.exports)) {
|
|
8286
|
+
Object.assign(_src_handlers_script_copy_js_CopyJsRewriter, module.exports);
|
|
8287
|
+
} else {
|
|
8288
|
+
_src_handlers_script_copy_js_CopyJsRewriter = module.exports;
|
|
8289
|
+
}
|
|
8290
|
+
|
|
8291
|
+
;
|
|
8292
|
+
}());
|
|
8293
|
+
|
|
8294
|
+
// end:source ./ModuleSimplified.js
|
|
8295
|
+
|
|
8296
|
+
|
|
8297
|
+
// source ./ModuleSimplified.js
|
|
8298
|
+
var _src_handlers_script_copy_js_CopyJsBuilder;
|
|
8299
|
+
(function () {
|
|
8300
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
8301
|
+
var define = null;
|
|
8302
|
+
var exports = _src_handlers_script_copy_js_CopyJsBuilder != null ? _src_handlers_script_copy_js_CopyJsBuilder : {};
|
|
8303
|
+
var module = { exports: exports };
|
|
8304
|
+
|
|
8305
|
+
"use strict";
|
|
8306
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8307
|
+
exports.CopyJsBuilder = void 0;
|
|
8308
|
+
const alot_1 = require("alot");
|
|
8309
|
+
const BaseScriptBuilder_1 = _src_handlers_script_base_BaseScriptBuilder;
|
|
8310
|
+
const OutputResources_1 = _src_class_OutputResources;
|
|
8311
|
+
const atma_utils_1 = require("atma-utils");
|
|
8312
|
+
const path_1 = _src_utils_path;
|
|
8313
|
+
const Configuration_1 = _src_config_Configuration;
|
|
8314
|
+
/**
|
|
8315
|
+
* Primary purpose of this builder is to copy source files to the output folder.
|
|
8316
|
+
* Atma IO middlewares are used to compile/transpile the files.
|
|
8317
|
+
*
|
|
8318
|
+
* For now the accent is made for Typescript files.
|
|
8319
|
+
*/
|
|
8320
|
+
class CopyJsBuilder extends BaseScriptBuilder_1.BaseScriptBuilder {
|
|
8321
|
+
wrapModule(resource, outputItem) {
|
|
8322
|
+
let { content, dependencies } = resource;
|
|
8323
|
+
let offset = 0;
|
|
8324
|
+
dependencies && dependencies.filter(x => x.pos != null && (0, path_1.path_isRelative)(x.url)).forEach(dep => {
|
|
8325
|
+
let resUrl = new atma_utils_1.class_Uri(resource.url);
|
|
8326
|
+
let resDep = new atma_utils_1.class_Uri(dep.url);
|
|
8327
|
+
let url = resUrl.combine(resDep).toLocalFile();
|
|
8328
|
+
let start = dep.pos + offset + 1;
|
|
8329
|
+
let c = content[start - 1];
|
|
8330
|
+
let end = content.indexOf(c, start);
|
|
8331
|
+
let oldLength = end - start;
|
|
8332
|
+
let newLength = url.length;
|
|
8333
|
+
content = content.substring(0, start) + url + content.substring(end);
|
|
8334
|
+
offset += newLength - oldLength;
|
|
8335
|
+
});
|
|
8336
|
+
return content;
|
|
8337
|
+
}
|
|
8338
|
+
async buildRoot(root, outputDependencies) {
|
|
8339
|
+
let outputResources = this.solution.outputResources;
|
|
8340
|
+
outputResources.items = await (0, alot_1.default)(outputResources.items)
|
|
8341
|
+
.mapManyAsync(async (item) => {
|
|
8342
|
+
if (item.resource.isGlob !== true) {
|
|
8343
|
+
return [item];
|
|
8344
|
+
}
|
|
8345
|
+
// Normal output
|
|
8346
|
+
let copyItems = await (0, alot_1.default)(item.resources)
|
|
8347
|
+
.mapMany(resource => {
|
|
8348
|
+
return this.createOutputItems(item, resource);
|
|
8349
|
+
})
|
|
8350
|
+
.toArrayAsync();
|
|
8351
|
+
return copyItems;
|
|
8352
|
+
}).toArrayAsync();
|
|
8353
|
+
}
|
|
8354
|
+
getRootContent(root, outputDependencies) {
|
|
8355
|
+
return root.content;
|
|
8356
|
+
}
|
|
8357
|
+
accepts(resource) {
|
|
8358
|
+
if (resource.type !== 'js') {
|
|
8359
|
+
return false;
|
|
8360
|
+
}
|
|
8361
|
+
return resource.isGlob === true;
|
|
8362
|
+
}
|
|
8363
|
+
async createOutputItems(parent, resource) {
|
|
8364
|
+
var _a;
|
|
8365
|
+
let solution = this.solution;
|
|
8366
|
+
let rewriteToRelativeUrls = {};
|
|
8367
|
+
if (((_a = resource.dependencies) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
8368
|
+
let appBase = this.solution.opts.base;
|
|
8369
|
+
(0, alot_1.default)(resource.dependencies)
|
|
8370
|
+
.forEach(dep => {
|
|
8371
|
+
if (dep.resource == null) {
|
|
8372
|
+
return;
|
|
8373
|
+
}
|
|
8374
|
+
if (dep.resource.filename.startsWith(appBase) === false) {
|
|
8375
|
+
// is project dependency
|
|
8376
|
+
return;
|
|
8377
|
+
}
|
|
8378
|
+
let relativePath = (0, path_1.path_toRelative)(dep.resource.filename, resource.filename);
|
|
8379
|
+
if (relativePath == null || /(..\/)*?\/?node_modules/.test(relativePath)) {
|
|
8380
|
+
return;
|
|
8381
|
+
}
|
|
8382
|
+
relativePath = (0, path_1.path_changeExtension)(relativePath, null);
|
|
8383
|
+
relativePath = relativePath.startsWith('.')
|
|
8384
|
+
? relativePath
|
|
8385
|
+
: './' + relativePath;
|
|
8386
|
+
rewriteToRelativeUrls[dep.url] = relativePath;
|
|
8387
|
+
})
|
|
8388
|
+
.toArray();
|
|
8389
|
+
resource.content = rewriteUrls(resource.content, rewriteToRelativeUrls);
|
|
8390
|
+
}
|
|
8391
|
+
let result = [
|
|
8392
|
+
createOutputItem(cloneWithExtension(resource, 'js'))
|
|
8393
|
+
];
|
|
8394
|
+
let extra = [{
|
|
8395
|
+
ext: 'ts.map',
|
|
8396
|
+
output: 'js.map',
|
|
8397
|
+
}, {
|
|
8398
|
+
ext: 'd.ts',
|
|
8399
|
+
output: 'd.ts',
|
|
8400
|
+
}];
|
|
8401
|
+
let readFile = Configuration_1.Configuration.Instance.get('readFile');
|
|
8402
|
+
await (0, alot_1.default)(extra).forEachAsync(async (x) => {
|
|
8403
|
+
let cloned = cloneWithExtension(resource, x.ext);
|
|
8404
|
+
cloned.content = await readFile(cloned.filename);
|
|
8405
|
+
cloned.content = rewriteUrls(cloned.content, rewriteToRelativeUrls);
|
|
8406
|
+
result.push(createOutputItem(cloneWithExtension(cloned, x.output)));
|
|
8407
|
+
if (x.ext === 'ts.map' && cloned.content != null) {
|
|
8408
|
+
let outputItem = result[result.length - 1];
|
|
8409
|
+
let source = resource.filename;
|
|
8410
|
+
let target = outputItem.resource.filename;
|
|
8411
|
+
let rel = (0, path_1.path_toRelative)(source, target);
|
|
8412
|
+
outputItem.resource.content = outputItem.resource.content.replace(/"sources":\["[^"]+"\]/, `"sources":["${rel}"]`);
|
|
8413
|
+
}
|
|
8414
|
+
}).toArrayAsync({ threads: 1 });
|
|
8415
|
+
function createOutputItem(resource) {
|
|
8416
|
+
return new OutputResources_1.OutputItem({
|
|
8417
|
+
page: parent.page,
|
|
8418
|
+
bundle: parent.bundle,
|
|
8419
|
+
type: parent.type,
|
|
8420
|
+
solution: solution,
|
|
8421
|
+
resources: [resource],
|
|
8422
|
+
isGlob: false,
|
|
8423
|
+
resource: resource.toTarget(solution)
|
|
8424
|
+
});
|
|
8425
|
+
}
|
|
8426
|
+
function cloneWithExtension(resource, ext) {
|
|
8427
|
+
let cloned = resource.clone();
|
|
8428
|
+
cloned.filename = (0, path_1.path_changeExtension)(cloned.filename, ext);
|
|
8429
|
+
cloned.url = (0, path_1.path_changeExtension)(cloned.url, ext);
|
|
8430
|
+
return cloned;
|
|
8431
|
+
}
|
|
8432
|
+
function rewriteUrls(content, rewriteToRelativeUrls) {
|
|
8433
|
+
for (let key in rewriteToRelativeUrls) {
|
|
8434
|
+
content = content.replaceAll(key, rewriteToRelativeUrls[key]);
|
|
8435
|
+
}
|
|
8436
|
+
return content;
|
|
8437
|
+
}
|
|
8438
|
+
return result;
|
|
8439
|
+
}
|
|
8440
|
+
}
|
|
8441
|
+
exports.CopyJsBuilder = CopyJsBuilder;
|
|
8442
|
+
;
|
|
8443
|
+
//# sourceMappingURL=CopyJsBuilder.js.map
|
|
8444
|
+
//# sourceMappingURL=CopyJsBuilder.ts.map;
|
|
8445
|
+
|
|
8446
|
+
function __isObj(x) {
|
|
8447
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
8448
|
+
}
|
|
8449
|
+
if (_src_handlers_script_copy_js_CopyJsBuilder === module.exports) {
|
|
8450
|
+
// do nothing if
|
|
8451
|
+
} else if (__isObj(_src_handlers_script_copy_js_CopyJsBuilder) && __isObj(module.exports)) {
|
|
8452
|
+
Object.assign(_src_handlers_script_copy_js_CopyJsBuilder, module.exports);
|
|
8453
|
+
} else {
|
|
8454
|
+
_src_handlers_script_copy_js_CopyJsBuilder = module.exports;
|
|
8455
|
+
}
|
|
8456
|
+
|
|
8457
|
+
;
|
|
8458
|
+
}());
|
|
8459
|
+
|
|
8460
|
+
// end:source ./ModuleSimplified.js
|
|
8461
|
+
|
|
8462
|
+
|
|
8463
|
+
// source ./ModuleSimplified.js
|
|
8464
|
+
var _src_handlers_script_copy_js_CopyJsHandler;
|
|
8465
|
+
(function () {
|
|
8466
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
8467
|
+
var define = null;
|
|
8468
|
+
var exports = _src_handlers_script_copy_js_CopyJsHandler != null ? _src_handlers_script_copy_js_CopyJsHandler : {};
|
|
8469
|
+
var module = { exports: exports };
|
|
8470
|
+
|
|
8471
|
+
"use strict";
|
|
8472
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8473
|
+
exports.CopyJsHandler = void 0;
|
|
8474
|
+
const BaseHandler_1 = _src_handlers_base_BaseHandler;
|
|
8475
|
+
const CopyJsParser_1 = _src_handlers_script_copy_js_CopyJsParser;
|
|
8476
|
+
const CopyJsRewriter_1 = _src_handlers_script_copy_js_CopyJsRewriter;
|
|
8477
|
+
const CopyJsBuilder_1 = _src_handlers_script_copy_js_CopyJsBuilder;
|
|
8478
|
+
class CopyJsHandler extends BaseHandler_1.BaseHandler {
|
|
8479
|
+
}
|
|
8480
|
+
exports.CopyJsHandler = CopyJsHandler;
|
|
8481
|
+
CopyJsHandler.Parser = CopyJsParser_1.CopyJsParser;
|
|
8482
|
+
CopyJsHandler.Rewriter = CopyJsRewriter_1.CopyJsRewriter;
|
|
8483
|
+
CopyJsHandler.Builder = CopyJsBuilder_1.CopyJsBuilder;
|
|
8484
|
+
CopyJsHandler.PathResolver = null;
|
|
8485
|
+
;
|
|
8486
|
+
//# sourceMappingURL=CopyJsHandler.js.map
|
|
8487
|
+
//# sourceMappingURL=CopyJsHandler.ts.map;
|
|
8488
|
+
|
|
8489
|
+
function __isObj(x) {
|
|
8490
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
8491
|
+
}
|
|
8492
|
+
if (_src_handlers_script_copy_js_CopyJsHandler === module.exports) {
|
|
8493
|
+
// do nothing if
|
|
8494
|
+
} else if (__isObj(_src_handlers_script_copy_js_CopyJsHandler) && __isObj(module.exports)) {
|
|
8495
|
+
Object.assign(_src_handlers_script_copy_js_CopyJsHandler, module.exports);
|
|
8496
|
+
} else {
|
|
8497
|
+
_src_handlers_script_copy_js_CopyJsHandler = module.exports;
|
|
8498
|
+
}
|
|
8499
|
+
|
|
8500
|
+
;
|
|
8501
|
+
}());
|
|
8502
|
+
|
|
8503
|
+
// end:source ./ModuleSimplified.js
|
|
8504
|
+
|
|
8505
|
+
|
|
8145
8506
|
// source ./ModuleSimplified.js
|
|
8146
8507
|
var _src_handlers_script_ScriptBuilder;
|
|
8147
8508
|
(function () {
|
|
@@ -8160,10 +8521,12 @@ const AmdJsHandler_1 = _src_handlers_script_amd_js_AmdJsHandler;
|
|
|
8160
8521
|
const IncludeJsHandler_1 = _src_handlers_script_include_js_IncludeJsHandler;
|
|
8161
8522
|
const MaskJsHandler_1 = _src_handlers_script_mask_js_MaskJsHandler;
|
|
8162
8523
|
const ImportJsHandler_1 = _src_handlers_script_import_js_ImportJsHandler;
|
|
8524
|
+
const CopyJsHandler_1 = _src_handlers_script_copy_js_CopyJsHandler;
|
|
8163
8525
|
class ScriptBuilder extends BaseBuilder_1.BaseBuilder {
|
|
8164
8526
|
constructor() {
|
|
8165
8527
|
super(...arguments);
|
|
8166
8528
|
this.builders = [
|
|
8529
|
+
new CopyJsHandler_1.CopyJsHandler.Builder(this.solution, this.handler),
|
|
8167
8530
|
new GlobalJsHandler_1.GlobalJsHandler.Builder(this.solution, this.handler),
|
|
8168
8531
|
new CommonJsHandler_1.CommonJsHandler.Builder(this.solution, this.handler),
|
|
8169
8532
|
new AmdJsHandler_1.AmdJsHandler.Builder(this.solution, this.handler),
|
|
@@ -8184,8 +8547,9 @@ class ScriptBuilder extends BaseBuilder_1.BaseBuilder {
|
|
|
8184
8547
|
else {
|
|
8185
8548
|
const out = resArr.map(res => {
|
|
8186
8549
|
let builder = this.builders.find(x => x.accepts(res));
|
|
8187
|
-
if (builder == null)
|
|
8550
|
+
if (builder == null) {
|
|
8188
8551
|
throw new Error('Module Builder not found for ' + res.url);
|
|
8552
|
+
}
|
|
8189
8553
|
return builder.wrapModule(res, outputItem, otherOutputItems);
|
|
8190
8554
|
});
|
|
8191
8555
|
code = out.join('\n');
|
|
@@ -11003,6 +11367,19 @@ exports.Parser = {
|
|
|
11003
11367
|
};
|
|
11004
11368
|
function getDependenciesInternal(resource, solution) {
|
|
11005
11369
|
assert(typeof resource.url === 'string', 'Path is expected');
|
|
11370
|
+
if (resource.isGlob) {
|
|
11371
|
+
let paths = resource.content;
|
|
11372
|
+
let resInfos = paths.map(path => {
|
|
11373
|
+
return {
|
|
11374
|
+
type: resource.type,
|
|
11375
|
+
url: path,
|
|
11376
|
+
module: resource.module,
|
|
11377
|
+
page: resource.page
|
|
11378
|
+
};
|
|
11379
|
+
});
|
|
11380
|
+
let result = { dependencies: resInfos };
|
|
11381
|
+
return (0, async_1.async_resolve)(result);
|
|
11382
|
+
}
|
|
11006
11383
|
let ext = (0, path_1.path_getExtension)(resource.url);
|
|
11007
11384
|
let handler = solution.handlers.find(x => x.parser.accepts(resource.type) || x.parser.accepts(ext));
|
|
11008
11385
|
if (handler == null) {
|
|
@@ -11226,17 +11603,20 @@ var ResourceLoader;
|
|
|
11226
11603
|
}
|
|
11227
11604
|
try {
|
|
11228
11605
|
let start = Date.now();
|
|
11229
|
-
let reader =
|
|
11606
|
+
let reader = this.resource.isGlob
|
|
11607
|
+
? Configuration_1.Configuration.Instance.get('readDirectory')
|
|
11608
|
+
: Configuration_1.Configuration.Instance.get('readFile');
|
|
11230
11609
|
let content = await reader(this.resource.filename, this.opts);
|
|
11231
11610
|
let handler = this.solution.handlers.find(x => x.parser.accepts(this.resource.type));
|
|
11232
|
-
if (((_a = handler === null || handler === void 0 ? void 0 : handler.parser) === null || _a === void 0 ? void 0 : _a.transpile)
|
|
11611
|
+
if (((_a = handler === null || handler === void 0 ? void 0 : handler.parser) === null || _a === void 0 ? void 0 : _a.transpile) != null) {
|
|
11233
11612
|
let result = await handler.parser.transpile(content, this.resource);
|
|
11234
11613
|
content = (_b = result === null || result === void 0 ? void 0 : result.content) !== null && _b !== void 0 ? _b : content;
|
|
11235
11614
|
}
|
|
11236
11615
|
let end = Date.now();
|
|
11237
|
-
this.solution.reporter.print((0, color_1.color)(` cyan<${end - start}> ms
|
|
11616
|
+
this.solution.reporter.print((0, color_1.color)(` cyan<${end - start}> ms`));
|
|
11238
11617
|
this.resource.content = content;
|
|
11239
|
-
if (this.resource.type === 'data'
|
|
11618
|
+
if (this.resource.type === 'data') {
|
|
11619
|
+
this.solution.reporter.print('\n');
|
|
11240
11620
|
this.promise.resolve(this);
|
|
11241
11621
|
return;
|
|
11242
11622
|
}
|
|
@@ -11248,12 +11628,15 @@ var ResourceLoader;
|
|
|
11248
11628
|
}
|
|
11249
11629
|
processChildren() {
|
|
11250
11630
|
if (this.shouldSkipChildren()) {
|
|
11631
|
+
this.solution.reporter.print(` (skip deps)`);
|
|
11251
11632
|
this.promise.resolve(this);
|
|
11252
11633
|
return;
|
|
11253
11634
|
}
|
|
11254
11635
|
Parser_1.Parser
|
|
11255
11636
|
.getDependencies(this.resource, this.solution)
|
|
11256
11637
|
.then(result => {
|
|
11638
|
+
var _a;
|
|
11639
|
+
this.solution.reporter.print((0, color_1.color)(` cyan<${(_a = result.dependencies) === null || _a === void 0 ? void 0 : _a.length}> dep\n`));
|
|
11257
11640
|
this.loadChildren(result).catch(err => {
|
|
11258
11641
|
this.promise.reject(err);
|
|
11259
11642
|
});
|
|
@@ -11499,14 +11882,14 @@ exports.Builder = void 0;
|
|
|
11499
11882
|
const Middlewares_1 = _src_class_Middlewares;
|
|
11500
11883
|
const path_1 = _src_utils_path;
|
|
11501
11884
|
const async_1 = _src_utils_async;
|
|
11502
|
-
const
|
|
11885
|
+
const alot_1 = require("alot");
|
|
11503
11886
|
exports.Builder = {
|
|
11504
11887
|
build(resources, solution) {
|
|
11505
11888
|
return Middlewares_1._middlewares
|
|
11506
11889
|
.run('buildResources', resources, solution)
|
|
11507
11890
|
.then(arr => {
|
|
11508
|
-
resources = arr
|
|
11509
|
-
solution.outputResources.
|
|
11891
|
+
resources = arr !== null && arr !== void 0 ? arr : resources;
|
|
11892
|
+
solution.outputResources.prepare(resources);
|
|
11510
11893
|
return Middlewares_1._middlewares
|
|
11511
11894
|
.run('rewriteDependencies', resources, solution)
|
|
11512
11895
|
.then(() => rewriteDependenciesInternal(resources))
|
|
@@ -11516,9 +11899,9 @@ exports.Builder = {
|
|
|
11516
11899
|
.then(() => solution.outputResources.getAll());
|
|
11517
11900
|
});
|
|
11518
11901
|
function rewriteDependenciesInternal(resources) {
|
|
11519
|
-
|
|
11520
|
-
|
|
11521
|
-
|
|
11902
|
+
let promises = resources.map(resource => {
|
|
11903
|
+
let ext = (0, path_1.path_getExtension)(resource.url);
|
|
11904
|
+
let handler = solution.handlers.find(x => x.rewriter.accepts(ext));
|
|
11522
11905
|
if (handler == null) {
|
|
11523
11906
|
handler = solution.handlers.find(x => x.rewriter.accepts(resource.type));
|
|
11524
11907
|
}
|
|
@@ -11527,12 +11910,14 @@ exports.Builder = {
|
|
|
11527
11910
|
}
|
|
11528
11911
|
return handler.rewriter.rewriteResource(resource);
|
|
11529
11912
|
});
|
|
11530
|
-
return (0, async_1.async_whenAll)(
|
|
11913
|
+
return (0, async_1.async_whenAll)(promises);
|
|
11531
11914
|
}
|
|
11532
11915
|
function rewriteRoot() {
|
|
11533
11916
|
return (0, async_1.async_run)(() => {
|
|
11534
|
-
|
|
11535
|
-
|
|
11917
|
+
let input = solution.outputResources.rootInput;
|
|
11918
|
+
let output = solution.outputResources.rootOutput;
|
|
11919
|
+
let ext = (0, path_1.path_getExtension)(input.url);
|
|
11920
|
+
let handler = solution.handlers.find(x => x.rewriter.accepts(input.type) || x.rewriter.accepts(ext));
|
|
11536
11921
|
if (handler == null || handler.rewriter.rewriteRoot == null) {
|
|
11537
11922
|
//throw new Error(`RootRewriter is not found for a resource ${input.url} and type ${input.type}`);
|
|
11538
11923
|
return;
|
|
@@ -11541,9 +11926,9 @@ exports.Builder = {
|
|
|
11541
11926
|
});
|
|
11542
11927
|
}
|
|
11543
11928
|
function buildOutputItems() {
|
|
11544
|
-
|
|
11545
|
-
return
|
|
11546
|
-
|
|
11929
|
+
let items = solution.outputResources.items;
|
|
11930
|
+
return (0, alot_1.default)(items).mapAsync(item => {
|
|
11931
|
+
let otherOutputItems = items.filter(x => {
|
|
11547
11932
|
if (x === item)
|
|
11548
11933
|
return false;
|
|
11549
11934
|
if (x.page != item.page)
|
|
@@ -11564,8 +11949,8 @@ exports.Builder = {
|
|
|
11564
11949
|
if (outputItem.resource.content) {
|
|
11565
11950
|
return;
|
|
11566
11951
|
}
|
|
11567
|
-
|
|
11568
|
-
|
|
11952
|
+
let ext = (0, path_1.path_getExtension)(outputItem.resource.url);
|
|
11953
|
+
let handler = solution.handlers.find(x => x.builder.accepts(outputItem.type));
|
|
11569
11954
|
if (handler == null) {
|
|
11570
11955
|
handler = solution.handlers.find(x => x.builder.accepts(ext));
|
|
11571
11956
|
}
|
|
@@ -11575,10 +11960,11 @@ exports.Builder = {
|
|
|
11575
11960
|
return handler.builder.createModule(outputItem, otherOutputItems);
|
|
11576
11961
|
}
|
|
11577
11962
|
function buildRoot() {
|
|
11578
|
-
var
|
|
11579
|
-
|
|
11580
|
-
|
|
11581
|
-
|
|
11963
|
+
var _a;
|
|
11964
|
+
let main = (_a = solution.outputResources.rootOutput) !== null && _a !== void 0 ? _a : solution.outputResources.rootInput;
|
|
11965
|
+
let dependencies = solution.outputResources.getForPage(solution.opts.mainPage);
|
|
11966
|
+
let ext = (0, path_1.path_getExtension)(main.url);
|
|
11967
|
+
let handler = solution.handlers.find(x => x.builder.accepts(main.type) || x.builder.accepts(ext));
|
|
11582
11968
|
if (handler == null || handler.builder.buildRoot == null) {
|
|
11583
11969
|
throw new Error(`RootBuilder is not found for a resource ${main.url} and type ${main.type}`);
|
|
11584
11970
|
}
|
|
@@ -11632,11 +12018,6 @@ const tree_1 = _src_utils_tree;
|
|
|
11632
12018
|
const Builder_1 = _src_builder_Builder;
|
|
11633
12019
|
const color_1 = _src_utils_color;
|
|
11634
12020
|
class Bundler extends atma_utils_1.class_EventEmitter {
|
|
11635
|
-
constructor(path, opts) {
|
|
11636
|
-
super();
|
|
11637
|
-
global.__$bundler = this;
|
|
11638
|
-
this.solution = new Solution_1.Solution(path, opts);
|
|
11639
|
-
}
|
|
11640
12021
|
static clearCache() {
|
|
11641
12022
|
Loader_1.Loader.clearCache();
|
|
11642
12023
|
if (global_1.io.File.middleware) {
|
|
@@ -11652,8 +12033,15 @@ class Bundler extends atma_utils_1.class_EventEmitter {
|
|
|
11652
12033
|
static get Config() {
|
|
11653
12034
|
return Configuration_1.Configuration.Instance;
|
|
11654
12035
|
}
|
|
12036
|
+
constructor(path, opts) {
|
|
12037
|
+
super();
|
|
12038
|
+
global.__$bundler = this;
|
|
12039
|
+
this.solution = new Solution_1.Solution(path, opts);
|
|
12040
|
+
}
|
|
11655
12041
|
getResourceTree(opts) {
|
|
11656
|
-
|
|
12042
|
+
let solution = this.solution;
|
|
12043
|
+
let type = solution.opts.type;
|
|
12044
|
+
let path = solution.path;
|
|
11657
12045
|
return Loader_1.Loader
|
|
11658
12046
|
.load(type, path, opts, solution)
|
|
11659
12047
|
.then(x => x.toJSON());
|
|
@@ -11662,7 +12050,9 @@ class Bundler extends atma_utils_1.class_EventEmitter {
|
|
|
11662
12050
|
return new Bundler(path, opts).getResourceTree();
|
|
11663
12051
|
}
|
|
11664
12052
|
getResources(opts) {
|
|
11665
|
-
|
|
12053
|
+
let solution = this.solution;
|
|
12054
|
+
let type = solution.opts.type;
|
|
12055
|
+
let path = solution.path;
|
|
11666
12056
|
return Loader_1.Loader.load(type, path, opts, solution).then(resource => {
|
|
11667
12057
|
return (0, res_1.res_flattern)(resource, solution.opts.dependencies).map(x => x);
|
|
11668
12058
|
});
|
|
@@ -11671,16 +12061,28 @@ class Bundler extends atma_utils_1.class_EventEmitter {
|
|
|
11671
12061
|
return new Bundler(path, opts).getResources();
|
|
11672
12062
|
}
|
|
11673
12063
|
build(opts) {
|
|
11674
|
-
|
|
12064
|
+
let solution = this.solution;
|
|
12065
|
+
let type = solution.opts.type;
|
|
12066
|
+
let path = solution.path;
|
|
12067
|
+
let shouldRebuild = false;
|
|
12068
|
+
let isBuilding = false;
|
|
12069
|
+
let isRebuilding = false;
|
|
12070
|
+
let rootResource = null;
|
|
12071
|
+
let self = this;
|
|
11675
12072
|
function build(resource) {
|
|
11676
12073
|
isBuilding = true;
|
|
11677
|
-
|
|
12074
|
+
let resources = (0, res_1.res_flattern)(resource, solution.opts.dependencies);
|
|
11678
12075
|
return (0, tree_1.tree_async)({
|
|
11679
|
-
resources,
|
|
11680
12076
|
reporter: solution.reporter,
|
|
11681
|
-
action: () =>
|
|
11682
|
-
|
|
11683
|
-
|
|
12077
|
+
action: () => {
|
|
12078
|
+
return Builder_1.Builder.build(resources, solution);
|
|
12079
|
+
},
|
|
12080
|
+
message: (treeInfo, seconds) => {
|
|
12081
|
+
return (0, color_1.color)(`Created bold<yellow<${treeInfo.count}>> files in bold<yellow<${seconds}>> sec.`);
|
|
12082
|
+
}
|
|
12083
|
+
})
|
|
12084
|
+
.done(buildComplete)
|
|
12085
|
+
.fail(buildFailed);
|
|
11684
12086
|
}
|
|
11685
12087
|
function buildComplete(resources) {
|
|
11686
12088
|
isBuilding = false;
|
|
@@ -11740,8 +12142,8 @@ class Bundler extends atma_utils_1.class_EventEmitter {
|
|
|
11740
12142
|
return new Bundler(path, opts).build(opts);
|
|
11741
12143
|
}
|
|
11742
12144
|
static process(path, opts) {
|
|
11743
|
-
|
|
11744
|
-
|
|
12145
|
+
let bundler = new Bundler(path, opts);
|
|
12146
|
+
let solution = bundler.solution;
|
|
11745
12147
|
function builderComplete(resources) {
|
|
11746
12148
|
resources.forEach(res => {
|
|
11747
12149
|
global_1.io.File.write(res.filename, res.content);
|
|
@@ -11772,8 +12174,8 @@ class Bundler extends atma_utils_1.class_EventEmitter {
|
|
|
11772
12174
|
getDependencies(content, opts = { type: 'js' }) {
|
|
11773
12175
|
if (typeof opts === 'string')
|
|
11774
12176
|
opts = { type: opts };
|
|
11775
|
-
|
|
11776
|
-
|
|
12177
|
+
let solution = new Solution_1.Solution('', opts);
|
|
12178
|
+
let resource = new Resource_1.Resource({ type: opts.type, content: content }, null, solution);
|
|
11777
12179
|
return Parser_1.Parser.getDependencies(resource, solution);
|
|
11778
12180
|
}
|
|
11779
12181
|
};
|