app-bundler 0.2.7 → 0.2.9
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 +1421 -1408
- package/lib/cli.js +1421 -1408
- package/package.json +1 -1
package/lib/cli.js
CHANGED
|
@@ -2377,7 +2377,10 @@ exports.FileActions = {
|
|
|
2377
2377
|
if (/^https?:/.test(path)) {
|
|
2378
2378
|
return HttpLoader.load(path, opts);
|
|
2379
2379
|
}
|
|
2380
|
-
return global_1.io.File.readAsync(path,
|
|
2380
|
+
return global_1.io.File.readAsync(path, {
|
|
2381
|
+
...(opts !== null && opts !== void 0 ? opts : {}),
|
|
2382
|
+
cached: false
|
|
2383
|
+
});
|
|
2381
2384
|
},
|
|
2382
2385
|
async readDirectory(path, opts) {
|
|
2383
2386
|
let i = path.indexOf('*');
|
|
@@ -4989,8 +4992,9 @@ var __register, __require, require;
|
|
|
4989
4992
|
// source ./ESM.js
|
|
4990
4993
|
$CUSTOM_IMPORTS_CODE$
|
|
4991
4994
|
|
|
4995
|
+
var exports = {};
|
|
4992
4996
|
var module = {
|
|
4993
|
-
exports:
|
|
4997
|
+
exports: exports
|
|
4994
4998
|
};
|
|
4995
4999
|
|
|
4996
5000
|
$MODULE$
|
|
@@ -5239,115 +5243,89 @@ exports.template_stringifyContent = template_stringifyContent;
|
|
|
5239
5243
|
|
|
5240
5244
|
|
|
5241
5245
|
// source ./ModuleSimplified.js
|
|
5242
|
-
var
|
|
5246
|
+
var _src_handlers_script_import_js_utils;
|
|
5243
5247
|
(function () {
|
|
5244
5248
|
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
5245
5249
|
var define = null;
|
|
5246
|
-
var exports =
|
|
5250
|
+
var exports = _src_handlers_script_import_js_utils != null ? _src_handlers_script_import_js_utils : {};
|
|
5247
5251
|
var module = { exports: exports };
|
|
5248
5252
|
|
|
5249
5253
|
"use strict";
|
|
5250
5254
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5251
|
-
exports.
|
|
5252
|
-
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5265
|
-
|
|
5266
|
-
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
wrapSimple(body) {
|
|
5281
|
-
return Templates_1.Templates
|
|
5282
|
-
.RootModule
|
|
5283
|
-
.replace('%BUNDLE%', () => body);
|
|
5284
|
-
}
|
|
5285
|
-
wrapWithIIF(body) {
|
|
5286
|
-
return Templates_1.Templates
|
|
5287
|
-
.RootModuleWrapped
|
|
5288
|
-
.replace('%BUNDLE%', () => body);
|
|
5289
|
-
}
|
|
5290
|
-
wrapWithUMD(body) {
|
|
5291
|
-
let opts = this.solution.opts.package;
|
|
5292
|
-
let name = opts.moduleName || '';
|
|
5293
|
-
return Templates_1.Templates
|
|
5294
|
-
.UMD
|
|
5295
|
-
.replace('%MODULE%', () => body)
|
|
5296
|
-
.replace('%NAME%', () => name);
|
|
5255
|
+
exports.u_asString = exports.u_readFile = exports.u_getFilesFromPath = exports.u_makeIndent = exports.u_getIndent = exports.u_getNewLine = void 0;
|
|
5256
|
+
function u_getNewLine(str, io) {
|
|
5257
|
+
var match = /(\r\n)|(\r)|(\n)/.exec(str);
|
|
5258
|
+
return (match && match[0]) || io.env.newLine;
|
|
5259
|
+
}
|
|
5260
|
+
exports.u_getNewLine = u_getNewLine;
|
|
5261
|
+
;
|
|
5262
|
+
function u_getIndent(str) {
|
|
5263
|
+
var match = /^[ \t]+/.exec(str);
|
|
5264
|
+
return match && match[0] || '';
|
|
5265
|
+
}
|
|
5266
|
+
exports.u_getIndent = u_getIndent;
|
|
5267
|
+
;
|
|
5268
|
+
function u_makeIndent(str, indent, io) {
|
|
5269
|
+
if (!indent || !str)
|
|
5270
|
+
return str;
|
|
5271
|
+
let newline = u_getNewLine(str, io);
|
|
5272
|
+
return str
|
|
5273
|
+
.split(newline)
|
|
5274
|
+
.map(line => indent + line)
|
|
5275
|
+
.join(newline);
|
|
5276
|
+
}
|
|
5277
|
+
exports.u_makeIndent = u_makeIndent;
|
|
5278
|
+
;
|
|
5279
|
+
function u_getFilesFromPath(path, io) {
|
|
5280
|
+
var file = new io.File(path);
|
|
5281
|
+
if (file.exists() === false) {
|
|
5282
|
+
console.error('File not found', file.uri.toLocalFile());
|
|
5283
|
+
return [];
|
|
5297
5284
|
}
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
});
|
|
5311
|
-
let strImports = arr.map(item => `import ${item.key} from '${item.url}';`).join('\n');
|
|
5312
|
-
let strCollection = `const bundlerDynamicRepository = {};\n`
|
|
5313
|
-
+ arr.map(item => `bundlerDynamicRepository['${item.url}'] = ${item.key};`)
|
|
5314
|
-
.join('\n');
|
|
5315
|
-
let strRequire = [
|
|
5316
|
-
`var bundlerOriginalRequire = require || function (url) { throw new Error('Not found: ' + url); };`,
|
|
5317
|
-
`var require = function (url) { return bundlerDynamicRepository[url] || bundlerOriginalRequire(url); };`
|
|
5318
|
-
].join('\n');
|
|
5319
|
-
importsCode = [
|
|
5320
|
-
strImports,
|
|
5321
|
-
strCollection,
|
|
5322
|
-
strRequire
|
|
5323
|
-
].join('\n');
|
|
5324
|
-
}
|
|
5325
|
-
return Templates_1.Templates
|
|
5326
|
-
.ESM
|
|
5327
|
-
.replace('$CUSTOM_IMPORTS_CODE$', () => importsCode)
|
|
5328
|
-
.replace('$CUSTOM_EXPORTS_CODE$', () => exportsCode)
|
|
5329
|
-
.replace('$MODULE$', () => body);
|
|
5285
|
+
return [file];
|
|
5286
|
+
}
|
|
5287
|
+
exports.u_getFilesFromPath = u_getFilesFromPath;
|
|
5288
|
+
;
|
|
5289
|
+
function u_readFile(io, file, indent, insertFileName) {
|
|
5290
|
+
var content = file.read().toString();
|
|
5291
|
+
var newline = u_getNewLine(content, io);
|
|
5292
|
+
if (indent) {
|
|
5293
|
+
content = content
|
|
5294
|
+
.split(newline)
|
|
5295
|
+
.map(line => indent + line)
|
|
5296
|
+
.join(newline);
|
|
5330
5297
|
}
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
5334
|
-
|
|
5335
|
-
|
|
5298
|
+
if (insertFileName) {
|
|
5299
|
+
content = indent
|
|
5300
|
+
+ '// source '
|
|
5301
|
+
+ file.uri.file
|
|
5302
|
+
+ newline
|
|
5303
|
+
+ content;
|
|
5336
5304
|
}
|
|
5305
|
+
return content;
|
|
5337
5306
|
}
|
|
5338
|
-
exports.
|
|
5339
|
-
|
|
5340
|
-
|
|
5307
|
+
exports.u_readFile = u_readFile;
|
|
5308
|
+
;
|
|
5309
|
+
function u_asString(str) {
|
|
5310
|
+
str = str
|
|
5311
|
+
.replace(/[\n\r]/g, '\\n')
|
|
5312
|
+
.replace(/"/g, '\\"');
|
|
5313
|
+
return `"${str}"`;
|
|
5314
|
+
}
|
|
5315
|
+
exports.u_asString = u_asString;
|
|
5316
|
+
;
|
|
5317
|
+
//# sourceMappingURL=utils.js.map
|
|
5318
|
+
//# sourceMappingURL=utils.ts.map;
|
|
5341
5319
|
|
|
5342
5320
|
function __isObj(x) {
|
|
5343
5321
|
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
5344
5322
|
}
|
|
5345
|
-
if (
|
|
5323
|
+
if (_src_handlers_script_import_js_utils === module.exports) {
|
|
5346
5324
|
// do nothing if
|
|
5347
|
-
} else if (__isObj(
|
|
5348
|
-
Object.assign(
|
|
5325
|
+
} else if (__isObj(_src_handlers_script_import_js_utils) && __isObj(module.exports)) {
|
|
5326
|
+
Object.assign(_src_handlers_script_import_js_utils, module.exports);
|
|
5349
5327
|
} else {
|
|
5350
|
-
|
|
5328
|
+
_src_handlers_script_import_js_utils = module.exports;
|
|
5351
5329
|
}
|
|
5352
5330
|
|
|
5353
5331
|
;
|
|
@@ -5357,215 +5335,107 @@ exports.ModuleWrapper = ModuleWrapper;
|
|
|
5357
5335
|
|
|
5358
5336
|
|
|
5359
5337
|
// source ./ModuleSimplified.js
|
|
5360
|
-
var
|
|
5338
|
+
var _src_handlers_script_import_js_Dictionary;
|
|
5361
5339
|
(function () {
|
|
5362
5340
|
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
5363
5341
|
var define = null;
|
|
5364
|
-
var exports =
|
|
5342
|
+
var exports = _src_handlers_script_import_js_Dictionary != null ? _src_handlers_script_import_js_Dictionary : {};
|
|
5365
5343
|
var module = { exports: exports };
|
|
5366
5344
|
|
|
5367
5345
|
"use strict";
|
|
5368
5346
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5369
|
-
exports.
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
|
|
5374
|
-
const ModuleWrapper_1 = _src_handlers_script_common_js_ModuleWrapper;
|
|
5375
|
-
class CommonJsBuilder extends BaseScriptBuilder_1.BaseScriptBuilder {
|
|
5376
|
-
constructor(solution, handler) {
|
|
5377
|
-
super(solution, handler);
|
|
5378
|
-
this.solution = solution;
|
|
5379
|
-
this.handler = handler;
|
|
5380
|
-
var opts = this.solution.opts.package.commonjs;
|
|
5381
|
-
if (opts && opts.output === 'simplified') {
|
|
5382
|
-
this.wrapModule = CommonJsBuilderSimplified_1.CommonJsBuilderSimplified.wrapModule;
|
|
5383
|
-
this.getRootContent = CommonJsBuilderSimplified_1.CommonJsBuilderSimplified.getRootContent;
|
|
5384
|
-
this.getHeaderContent = CommonJsBuilderSimplified_1.CommonJsBuilderSimplified.getHeaderContent;
|
|
5385
|
-
}
|
|
5347
|
+
exports.Dictionary = void 0;
|
|
5348
|
+
class Dictionary {
|
|
5349
|
+
constructor() {
|
|
5350
|
+
this.hash = {};
|
|
5351
|
+
this.arr = [];
|
|
5386
5352
|
}
|
|
5387
|
-
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5353
|
+
add(...arr) {
|
|
5354
|
+
for (let i = 0; i < arr.length; i++) {
|
|
5355
|
+
let x = arr[i];
|
|
5356
|
+
if (this.hash[x.id] != null) {
|
|
5357
|
+
continue;
|
|
5358
|
+
}
|
|
5359
|
+
this.hash[x.id] = x;
|
|
5360
|
+
this.arr.push(x);
|
|
5394
5361
|
}
|
|
5395
|
-
return module === 'commonjs';
|
|
5396
5362
|
}
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5400
|
-
opts.commonjs = {
|
|
5401
|
-
addHeading: true,
|
|
5402
|
-
hasHeading: false
|
|
5403
|
-
};
|
|
5404
|
-
}
|
|
5405
|
-
;
|
|
5406
|
-
var body = '';
|
|
5407
|
-
if (opts.commonjs.hasHeading === false && opts.commonjs.addHeading === true) {
|
|
5408
|
-
opts.commonjs.hasHeading = true;
|
|
5409
|
-
body = this.getHeaderContent();
|
|
5363
|
+
insert(x, i) {
|
|
5364
|
+
if (this.hash[x.id] != null) {
|
|
5365
|
+
this.remove(x);
|
|
5410
5366
|
}
|
|
5411
|
-
|
|
5412
|
-
|
|
5413
|
-
.Module
|
|
5414
|
-
.replace('%MODULE_PATH%', () => url)
|
|
5415
|
-
.replace('%MODULE%', () => content)
|
|
5416
|
-
.replace('%FOOTER%', () => { var _a, _b; return ((_b = (_a = setts === null || setts === void 0 ? void 0 : setts.partials) === null || _a === void 0 ? void 0 : _a.footer) !== null && _b !== void 0 ? _b : ''); });
|
|
5417
|
-
return body + module;
|
|
5367
|
+
this.hash[x.id] = x;
|
|
5368
|
+
this.arr.splice(i, 0, x);
|
|
5418
5369
|
}
|
|
5419
|
-
|
|
5420
|
-
|
|
5421
|
-
return Templates_1.Templates
|
|
5422
|
-
.Header
|
|
5423
|
-
.replace('%ROOT_DIR%', () => mainUrl);
|
|
5370
|
+
has(x) {
|
|
5371
|
+
return this.hash[x.id] != null;
|
|
5424
5372
|
}
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
|
|
5429
|
-
.map(x => {
|
|
5430
|
-
let content = x.content;
|
|
5431
|
-
if (x.type === 'css') {
|
|
5432
|
-
content = (0, template_1.template_interpolate)(Templates_1.Templates.Style, { body: (0, template_1.template_stringifyContent)(content), url: x.url });
|
|
5433
|
-
}
|
|
5434
|
-
if (x.type === 'mask') {
|
|
5435
|
-
content = (0, template_1.template_interpolate)(Templates_1.Templates.Mask, { body: (0, template_1.template_stringifyContent)(content), url: x.url });
|
|
5373
|
+
indexOf(x) {
|
|
5374
|
+
for (let i = 0; i < this.arr.length; i++) {
|
|
5375
|
+
if (this.arr[i].id === x.id) {
|
|
5376
|
+
return i;
|
|
5436
5377
|
}
|
|
5437
|
-
|
|
5438
|
-
|
|
5439
|
-
.concat([content])
|
|
5440
|
-
.join('\n');
|
|
5441
|
-
var wrapper = new ModuleWrapper_1.ModuleWrapper(this.solution);
|
|
5442
|
-
root.content = wrapper.wrap(body);
|
|
5378
|
+
}
|
|
5379
|
+
return -1;
|
|
5443
5380
|
}
|
|
5444
|
-
|
|
5445
|
-
|
|
5446
|
-
|
|
5447
|
-
|
|
5448
|
-
exports.CommonJsBuilder = CommonJsBuilder;
|
|
5449
|
-
;
|
|
5450
|
-
//# sourceMappingURL=CommonJsBuilder.js.map
|
|
5451
|
-
//# sourceMappingURL=CommonJsBuilder.ts.map;
|
|
5452
|
-
|
|
5453
|
-
function __isObj(x) {
|
|
5454
|
-
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
5455
|
-
}
|
|
5456
|
-
if (_src_handlers_script_common_js_CommonJsBuilder === module.exports) {
|
|
5457
|
-
// do nothing if
|
|
5458
|
-
} else if (__isObj(_src_handlers_script_common_js_CommonJsBuilder) && __isObj(module.exports)) {
|
|
5459
|
-
Object.assign(_src_handlers_script_common_js_CommonJsBuilder, module.exports);
|
|
5460
|
-
} else {
|
|
5461
|
-
_src_handlers_script_common_js_CommonJsBuilder = module.exports;
|
|
5462
|
-
}
|
|
5463
|
-
|
|
5464
|
-
;
|
|
5465
|
-
}());
|
|
5466
|
-
|
|
5467
|
-
// end:source ./ModuleSimplified.js
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
// source ./ModuleSimplified.js
|
|
5471
|
-
var _src_handlers_script_common_js_CommonJsPathResolver;
|
|
5472
|
-
(function () {
|
|
5473
|
-
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
5474
|
-
var define = null;
|
|
5475
|
-
var exports = _src_handlers_script_common_js_CommonJsPathResolver != null ? _src_handlers_script_common_js_CommonJsPathResolver : {};
|
|
5476
|
-
var module = { exports: exports };
|
|
5477
|
-
|
|
5478
|
-
"use strict";
|
|
5479
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5480
|
-
exports.CommonJsPathResolver = void 0;
|
|
5481
|
-
const BasePathResolver_1 = _src_handlers_base_BasePathResolver;
|
|
5482
|
-
const path_1 = _src_utils_path;
|
|
5483
|
-
const global_1 = _src_global;
|
|
5484
|
-
class CommonJsPathResolver extends BasePathResolver_1.BasePathResolver {
|
|
5485
|
-
accepts(includeData) {
|
|
5486
|
-
if (includeData.type !== 'js' || includeData.module !== 'commonjs') {
|
|
5487
|
-
return false;
|
|
5488
|
-
}
|
|
5489
|
-
if (!/^[\w\-/]+$/.test(includeData.url)) {
|
|
5490
|
-
return false;
|
|
5491
|
-
}
|
|
5492
|
-
if (nodeCoreModules.indexOf(includeData.url) !== -1) {
|
|
5493
|
-
return false;
|
|
5494
|
-
}
|
|
5495
|
-
return true;
|
|
5496
|
-
}
|
|
5497
|
-
resolve(includeData, parentResource) {
|
|
5498
|
-
let filename = nodeModuleResolve(includeData.url, parentResource.directory);
|
|
5499
|
-
if (filename) {
|
|
5500
|
-
let url = this.solution.opts.toAppUrl(filename);
|
|
5501
|
-
this.solution.opts.mappings[includeData.url] = url;
|
|
5502
|
-
}
|
|
5503
|
-
return filename;
|
|
5381
|
+
remove(x) {
|
|
5382
|
+
delete this.hash[x.id];
|
|
5383
|
+
let i = this.arr.findIndex(module => module.id === x.id);
|
|
5384
|
+
this.arr.splice(i, 1);
|
|
5504
5385
|
}
|
|
5505
|
-
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
|
|
5512
|
-
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
if (global_1.io.File.exists(pckg) === false) {
|
|
5524
|
-
let next = current.replace(/[^\/\\]+[\/\\]?$/, '');
|
|
5525
|
-
if (next === current) {
|
|
5526
|
-
return root_ + 'package.json';
|
|
5386
|
+
removeByFn(fn) {
|
|
5387
|
+
let handled = new Dictionary();
|
|
5388
|
+
while (true) {
|
|
5389
|
+
let i = -1, length = this.arr.length;
|
|
5390
|
+
while (++i < length) {
|
|
5391
|
+
let x = this.arr[i];
|
|
5392
|
+
if (handled.has(x)) {
|
|
5393
|
+
continue;
|
|
5394
|
+
}
|
|
5395
|
+
handled.add(x);
|
|
5396
|
+
if (fn(x)) {
|
|
5397
|
+
this.arr.splice(i, 1);
|
|
5398
|
+
delete this.hash[x.id];
|
|
5399
|
+
}
|
|
5400
|
+
break;
|
|
5401
|
+
}
|
|
5402
|
+
if (i === length) {
|
|
5403
|
+
break;
|
|
5527
5404
|
}
|
|
5528
|
-
current = next;
|
|
5529
|
-
continue;
|
|
5530
5405
|
}
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5406
|
+
}
|
|
5407
|
+
forEach(fn) {
|
|
5408
|
+
let handled = new Dictionary();
|
|
5409
|
+
while (true) {
|
|
5410
|
+
let i = -1, length = this.arr.length;
|
|
5411
|
+
while (++i < length) {
|
|
5412
|
+
let x = this.arr[i];
|
|
5413
|
+
if (handled.has(x)) {
|
|
5414
|
+
continue;
|
|
5539
5415
|
}
|
|
5540
|
-
|
|
5416
|
+
handled.add(x);
|
|
5417
|
+
fn(x, i);
|
|
5418
|
+
break;
|
|
5419
|
+
}
|
|
5420
|
+
if (i === length) {
|
|
5421
|
+
break;
|
|
5541
5422
|
}
|
|
5542
|
-
return path;
|
|
5543
|
-
}
|
|
5544
|
-
let json = global_1.io.File.read(pckg);
|
|
5545
|
-
if (typeof json === 'string') {
|
|
5546
|
-
json = JSON.parse(json);
|
|
5547
|
-
}
|
|
5548
|
-
if (json.main) {
|
|
5549
|
-
return (0, path_1.path_combine)(nodeModules, json.main);
|
|
5550
5423
|
}
|
|
5551
|
-
return nodeModules + 'index.js';
|
|
5552
5424
|
}
|
|
5553
5425
|
}
|
|
5554
|
-
|
|
5555
|
-
|
|
5556
|
-
|
|
5557
|
-
//# sourceMappingURL=CommonJsPathResolver.js.map
|
|
5558
|
-
//# sourceMappingURL=CommonJsPathResolver.ts.map;
|
|
5426
|
+
exports.Dictionary = Dictionary;
|
|
5427
|
+
//# sourceMappingURL=Dictionary.js.map
|
|
5428
|
+
//# sourceMappingURL=Dictionary.ts.map;
|
|
5559
5429
|
|
|
5560
5430
|
function __isObj(x) {
|
|
5561
5431
|
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
5562
5432
|
}
|
|
5563
|
-
if (
|
|
5433
|
+
if (_src_handlers_script_import_js_Dictionary === module.exports) {
|
|
5564
5434
|
// do nothing if
|
|
5565
|
-
} else if (__isObj(
|
|
5566
|
-
Object.assign(
|
|
5435
|
+
} else if (__isObj(_src_handlers_script_import_js_Dictionary) && __isObj(module.exports)) {
|
|
5436
|
+
Object.assign(_src_handlers_script_import_js_Dictionary, module.exports);
|
|
5567
5437
|
} else {
|
|
5568
|
-
|
|
5438
|
+
_src_handlers_script_import_js_Dictionary = module.exports;
|
|
5569
5439
|
}
|
|
5570
5440
|
|
|
5571
5441
|
;
|
|
@@ -5575,41 +5445,35 @@ function hasExt(path) {
|
|
|
5575
5445
|
|
|
5576
5446
|
|
|
5577
5447
|
// source ./ModuleSimplified.js
|
|
5578
|
-
var
|
|
5448
|
+
var _src_handlers_script_import_js_String;
|
|
5579
5449
|
(function () {
|
|
5580
5450
|
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
5581
5451
|
var define = null;
|
|
5582
|
-
var exports =
|
|
5452
|
+
var exports = _src_handlers_script_import_js_String != null ? _src_handlers_script_import_js_String : {};
|
|
5583
5453
|
var module = { exports: exports };
|
|
5584
5454
|
|
|
5585
5455
|
"use strict";
|
|
5586
5456
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5587
|
-
exports.
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
}
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
CommonJsHandler.Rewriter = CommonJsRewriter_1.CommonJsRewriter;
|
|
5598
|
-
CommonJsHandler.Builder = CommonJsBuilder_1.CommonJsBuilder;
|
|
5599
|
-
CommonJsHandler.PathResolver = CommonJsPathResolver_1.CommonJsPathResolver;
|
|
5600
|
-
;
|
|
5601
|
-
//# sourceMappingURL=CommonJsHandler.js.map
|
|
5602
|
-
//# sourceMappingURL=CommonJsHandler.ts.map;
|
|
5457
|
+
exports.String = void 0;
|
|
5458
|
+
var String;
|
|
5459
|
+
(function (String) {
|
|
5460
|
+
function replace(str, i, length, ins = '') {
|
|
5461
|
+
return str.substring(0, i) + ins + str.substring(i + length);
|
|
5462
|
+
}
|
|
5463
|
+
String.replace = replace;
|
|
5464
|
+
})(String = exports.String || (exports.String = {}));
|
|
5465
|
+
//# sourceMappingURL=String.js.map
|
|
5466
|
+
//# sourceMappingURL=String.ts.map;
|
|
5603
5467
|
|
|
5604
5468
|
function __isObj(x) {
|
|
5605
5469
|
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
5606
5470
|
}
|
|
5607
|
-
if (
|
|
5471
|
+
if (_src_handlers_script_import_js_String === module.exports) {
|
|
5608
5472
|
// do nothing if
|
|
5609
|
-
} else if (__isObj(
|
|
5610
|
-
Object.assign(
|
|
5473
|
+
} else if (__isObj(_src_handlers_script_import_js_String) && __isObj(module.exports)) {
|
|
5474
|
+
Object.assign(_src_handlers_script_import_js_String, module.exports);
|
|
5611
5475
|
} else {
|
|
5612
|
-
|
|
5476
|
+
_src_handlers_script_import_js_String = module.exports;
|
|
5613
5477
|
}
|
|
5614
5478
|
|
|
5615
5479
|
;
|
|
@@ -5619,112 +5483,255 @@ CommonJsHandler.PathResolver = CommonJsPathResolver_1.CommonJsPathResolver;
|
|
|
5619
5483
|
|
|
5620
5484
|
|
|
5621
5485
|
// source ./ModuleSimplified.js
|
|
5622
|
-
var
|
|
5486
|
+
var _src_handlers_script_import_js_ModuleFile;
|
|
5623
5487
|
(function () {
|
|
5624
5488
|
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
5625
5489
|
var define = null;
|
|
5626
|
-
var exports =
|
|
5490
|
+
var exports = _src_handlers_script_import_js_ModuleFile != null ? _src_handlers_script_import_js_ModuleFile : {};
|
|
5627
5491
|
var module = { exports: exports };
|
|
5628
5492
|
|
|
5629
5493
|
"use strict";
|
|
5630
5494
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5631
|
-
exports.
|
|
5632
|
-
const
|
|
5633
|
-
const
|
|
5634
|
-
const
|
|
5635
|
-
const
|
|
5636
|
-
class
|
|
5637
|
-
|
|
5638
|
-
|
|
5639
|
-
|
|
5640
|
-
|
|
5641
|
-
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
|
|
5645
|
-
|
|
5495
|
+
exports.ModuleFile = exports.IImporterOptions = void 0;
|
|
5496
|
+
const io = require("atma-io");
|
|
5497
|
+
const utils_1 = _src_handlers_script_import_js_utils;
|
|
5498
|
+
const Dictionary_1 = _src_handlers_script_import_js_Dictionary;
|
|
5499
|
+
const String_1 = _src_handlers_script_import_js_String;
|
|
5500
|
+
class IImporterOptions {
|
|
5501
|
+
constructor() {
|
|
5502
|
+
this.removeUnusedExports = true;
|
|
5503
|
+
this.wrapper = 'iif';
|
|
5504
|
+
this.lazy = null;
|
|
5505
|
+
}
|
|
5506
|
+
}
|
|
5507
|
+
exports.IImporterOptions = IImporterOptions;
|
|
5508
|
+
class ModuleFile {
|
|
5509
|
+
constructor(content, file) {
|
|
5510
|
+
this.content = content;
|
|
5511
|
+
this.file = file;
|
|
5512
|
+
this.outer = new Dictionary_1.Dictionary();
|
|
5513
|
+
this.scoped = new Dictionary_1.Dictionary();
|
|
5514
|
+
this.imports = [];
|
|
5515
|
+
this.exports = [];
|
|
5516
|
+
this.scopedVars = [];
|
|
5517
|
+
this.id = file.uri.toLocalFile();
|
|
5518
|
+
this.path = file.uri.toRelativeString(io.env.currentDir);
|
|
5519
|
+
}
|
|
5520
|
+
hasDeep(x, ignore, hash = new Dictionary_1.Dictionary()) {
|
|
5521
|
+
function check(arr) {
|
|
5522
|
+
for (let i = 0; i < arr.length; i++) {
|
|
5523
|
+
let module = arr[i];
|
|
5524
|
+
if (module == ignore || hash.has(module)) {
|
|
5525
|
+
continue;
|
|
5526
|
+
}
|
|
5527
|
+
hash.add(module);
|
|
5528
|
+
let has = module.hasDeep(x, ignore, hash);
|
|
5529
|
+
if (has) {
|
|
5530
|
+
return true;
|
|
5531
|
+
}
|
|
5646
5532
|
}
|
|
5533
|
+
return false;
|
|
5534
|
+
}
|
|
5535
|
+
if (this.id === x.id) {
|
|
5647
5536
|
return true;
|
|
5648
|
-
}
|
|
5649
|
-
return
|
|
5537
|
+
}
|
|
5538
|
+
return check(this.outer.arr) || check(this.scoped.arr);
|
|
5650
5539
|
}
|
|
5651
|
-
|
|
5652
|
-
|
|
5653
|
-
|
|
5540
|
+
getAllModules() {
|
|
5541
|
+
let dict = new Dictionary_1.Dictionary();
|
|
5542
|
+
function add(module) {
|
|
5543
|
+
if (dict.has(module)) {
|
|
5544
|
+
return;
|
|
5545
|
+
}
|
|
5546
|
+
dict.add(module);
|
|
5547
|
+
module.outer.forEach(add);
|
|
5548
|
+
module.scoped.forEach(add);
|
|
5654
5549
|
}
|
|
5655
|
-
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
5659
|
-
|
|
5550
|
+
add(this);
|
|
5551
|
+
return dict.arr;
|
|
5552
|
+
}
|
|
5553
|
+
static getAllImports(modules) {
|
|
5554
|
+
let arr = [];
|
|
5555
|
+
modules.filter(x => x.imports != null).forEach(x => arr.push(...x.imports));
|
|
5556
|
+
return arr;
|
|
5557
|
+
// function read (module: ModuleFile, stack: ModuleFile[] = []): ImportNode[] {
|
|
5558
|
+
// if (stack.includes(module) || module.imports == null) {
|
|
5559
|
+
// return [];
|
|
5560
|
+
// }
|
|
5561
|
+
// stack.push(module);
|
|
5562
|
+
// let arr = [...module.imports];
|
|
5563
|
+
// module.imports.forEach(x => arr.push(...read(x.module, stack)));
|
|
5564
|
+
// return arr;
|
|
5565
|
+
// }
|
|
5566
|
+
// return read(this);
|
|
5567
|
+
}
|
|
5568
|
+
toScript(parents = [], options, indent = '') {
|
|
5569
|
+
let newLine = (0, utils_1.u_getNewLine)(this.content, io);
|
|
5570
|
+
let outerContent = this
|
|
5571
|
+
.outer
|
|
5572
|
+
.arr
|
|
5573
|
+
.map(x => x.toScript([...parents, this], options))
|
|
5574
|
+
.map(x => x.replace(/[\s]*$/, ''))
|
|
5575
|
+
.join(newLine);
|
|
5576
|
+
let scopedContent = this
|
|
5577
|
+
.scoped
|
|
5578
|
+
.arr
|
|
5579
|
+
.map(x => x.toScript([...parents, this], options))
|
|
5580
|
+
.map(x => x.replace(/[\s]*$/, ''))
|
|
5581
|
+
.join(newLine);
|
|
5582
|
+
let scopedRefs = this
|
|
5583
|
+
.scopedVars
|
|
5584
|
+
.filter(x => !options.removeUnusedExports || x.dependents.length > 0)
|
|
5585
|
+
.map(x => ` ${x.ref}`)
|
|
5586
|
+
.join(`,${newLine}`);
|
|
5587
|
+
if (scopedRefs) {
|
|
5588
|
+
scopedRefs = String_1.String.replace(scopedRefs, 0, 3, 'var');
|
|
5589
|
+
scopedRefs += ';';
|
|
5590
|
+
scopedContent = scopedRefs + newLine + scopedContent;
|
|
5660
5591
|
}
|
|
5661
|
-
let
|
|
5662
|
-
|
|
5663
|
-
|
|
5592
|
+
let content = this.content;
|
|
5593
|
+
// normalize exports
|
|
5594
|
+
this.exports.reverse().forEach(x => {
|
|
5595
|
+
if (options.removeUnusedExports && x.dependents.length === 0) {
|
|
5596
|
+
let str = content.substring(x.position, x.position + x.length);
|
|
5597
|
+
str = str.replace(/\s*export\s*/g, '');
|
|
5598
|
+
content = String_1.String.replace(content, x.position, x.length, str);
|
|
5599
|
+
return;
|
|
5600
|
+
}
|
|
5601
|
+
switch (x.type) {
|
|
5602
|
+
case 'ref':
|
|
5603
|
+
content = String_1.String.replace(content, x.position, x.length, x.ref);
|
|
5604
|
+
break;
|
|
5605
|
+
case 'function':
|
|
5606
|
+
content = String_1.String.replace(content, x.position, x.length, `${x.ref} = function `);
|
|
5607
|
+
break;
|
|
5608
|
+
case 'named':
|
|
5609
|
+
content = String_1.String.replace(content, x.position, x.length, '');
|
|
5610
|
+
break;
|
|
5611
|
+
case 'scoped':
|
|
5612
|
+
if (x.length > 0) {
|
|
5613
|
+
content = String_1.String.replace(content, x.position, x.length, '');
|
|
5614
|
+
}
|
|
5615
|
+
break;
|
|
5616
|
+
}
|
|
5617
|
+
});
|
|
5618
|
+
// remove imports
|
|
5619
|
+
this.imports.reverse().forEach(x => {
|
|
5620
|
+
content = String_1.String.replace(content, x.position, x.length, '');
|
|
5621
|
+
});
|
|
5622
|
+
// create var declaration
|
|
5623
|
+
let externalRefs = '';
|
|
5624
|
+
if (this.exports.length > 0) {
|
|
5625
|
+
this
|
|
5626
|
+
.exports
|
|
5627
|
+
.filter(x => {
|
|
5628
|
+
return x.dependents.length > 0 || options.removeUnusedExports === false;
|
|
5629
|
+
})
|
|
5630
|
+
.forEach(x => {
|
|
5631
|
+
/** Remove local scoped var declaration and make it global scoped */
|
|
5632
|
+
if (x.type === 'scoped') {
|
|
5633
|
+
let rgx = new RegExp(`\\b(var|let|const|function)\\s+${x.ref}`);
|
|
5634
|
+
content = content.replace(rgx, x.ref);
|
|
5635
|
+
}
|
|
5636
|
+
return x;
|
|
5637
|
+
});
|
|
5638
|
+
externalRefs = this
|
|
5639
|
+
.exports
|
|
5640
|
+
.reverse()
|
|
5641
|
+
.filter(x => {
|
|
5642
|
+
if (x.builder.movedToOuter) {
|
|
5643
|
+
return false;
|
|
5644
|
+
}
|
|
5645
|
+
if (options.removeUnusedExports === false) {
|
|
5646
|
+
return true;
|
|
5647
|
+
}
|
|
5648
|
+
if (x.dependents.length === 0) {
|
|
5649
|
+
console.warn(`Module ${this.id} has unused export ${x.ref}`);
|
|
5650
|
+
return false;
|
|
5651
|
+
}
|
|
5652
|
+
return true;
|
|
5653
|
+
})
|
|
5654
|
+
.filter(x => {
|
|
5655
|
+
let exportInOuter = parents
|
|
5656
|
+
.some(p => {
|
|
5657
|
+
let parentsExport = p.exports.find(e => e.hasExport(x.ref));
|
|
5658
|
+
if (parentsExport == null) {
|
|
5659
|
+
return false;
|
|
5660
|
+
}
|
|
5661
|
+
if (options.removeUnusedExports && parentsExport.dependents.length === 0) {
|
|
5662
|
+
return false;
|
|
5663
|
+
}
|
|
5664
|
+
return true;
|
|
5665
|
+
});
|
|
5666
|
+
return exportInOuter === false;
|
|
5667
|
+
})
|
|
5668
|
+
.map(x => ` ${x.ref}`)
|
|
5669
|
+
.join(`,${newLine}`);
|
|
5670
|
+
if (externalRefs.length > 0) {
|
|
5671
|
+
externalRefs = String_1.String.replace(externalRefs, 0, 3, 'var');
|
|
5672
|
+
externalRefs += ';';
|
|
5673
|
+
}
|
|
5664
5674
|
}
|
|
5665
|
-
|
|
5666
|
-
let
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
|
|
5670
|
-
}
|
|
5671
|
-
|
|
5672
|
-
|
|
5673
|
-
|
|
5674
|
-
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
// do nothing if
|
|
5681
|
-
} else if (__isObj(_src_handlers_script_amd_js_AmdJsParser) && __isObj(module.exports)) {
|
|
5682
|
-
Object.assign(_src_handlers_script_amd_js_AmdJsParser, module.exports);
|
|
5683
|
-
} else {
|
|
5684
|
-
_src_handlers_script_amd_js_AmdJsParser = module.exports;
|
|
5685
|
-
}
|
|
5686
|
-
|
|
5687
|
-
;
|
|
5688
|
-
}());
|
|
5689
|
-
|
|
5690
|
-
// end:source ./ModuleSimplified.js
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
// source ./ModuleSimplified.js
|
|
5694
|
-
var _src_handlers_script_amd_js_AmdJsRewriter;
|
|
5695
|
-
(function () {
|
|
5696
|
-
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
5697
|
-
var define = null;
|
|
5698
|
-
var exports = _src_handlers_script_amd_js_AmdJsRewriter != null ? _src_handlers_script_amd_js_AmdJsRewriter : {};
|
|
5699
|
-
var module = { exports: exports };
|
|
5700
|
-
|
|
5701
|
-
"use strict";
|
|
5702
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5703
|
-
exports.AmdJsRewriter = void 0;
|
|
5704
|
-
const BaseRewriter_1 = _src_handlers_base_BaseRewriter;
|
|
5705
|
-
class AmdJsRewriter extends BaseRewriter_1.BaseRewriter {
|
|
5706
|
-
rewritePartial(content, ownerResource) {
|
|
5675
|
+
const SPACE = '\t';
|
|
5676
|
+
let indentScopedContent = `${(0, utils_1.u_makeIndent)(scopedContent || '', SPACE, io)}`;
|
|
5677
|
+
let indentContent = `${(0, utils_1.u_makeIndent)(content, SPACE, io)}`;
|
|
5678
|
+
let scopeLess = parents.length === 0 && options.wrapper !== 'iif';
|
|
5679
|
+
content = [
|
|
5680
|
+
`${outerContent}` || '',
|
|
5681
|
+
`${externalRefs}` || '',
|
|
5682
|
+
!scopeLess && (indentScopedContent || indentContent) ? `(function(){` : '',
|
|
5683
|
+
indentScopedContent,
|
|
5684
|
+
indentContent,
|
|
5685
|
+
!scopeLess && (indentScopedContent || indentContent) ? `}());` : ''
|
|
5686
|
+
]
|
|
5687
|
+
.filter(x => !!x)
|
|
5688
|
+
.join(newLine);
|
|
5689
|
+
return (0, utils_1.u_makeIndent)(content, indent, io);
|
|
5707
5690
|
}
|
|
5708
|
-
|
|
5691
|
+
toImportsJson() {
|
|
5692
|
+
function toJSON(module) {
|
|
5693
|
+
var json = {
|
|
5694
|
+
id: module.id,
|
|
5695
|
+
imports: null
|
|
5696
|
+
};
|
|
5697
|
+
if (module.imports) {
|
|
5698
|
+
json.imports = module.imports.map(x => toJSON(x.module));
|
|
5699
|
+
}
|
|
5700
|
+
return json;
|
|
5701
|
+
}
|
|
5702
|
+
return toJSON(this);
|
|
5709
5703
|
}
|
|
5710
|
-
|
|
5711
|
-
|
|
5704
|
+
toModulesJson() {
|
|
5705
|
+
function toJSON(module) {
|
|
5706
|
+
let json = {
|
|
5707
|
+
id: module.id,
|
|
5708
|
+
outer: module.outer.arr.map(x => toJSON(x)),
|
|
5709
|
+
scoped: module.scoped.arr.map(x => toJSON(x))
|
|
5710
|
+
};
|
|
5711
|
+
if (json.outer.length === 0) {
|
|
5712
|
+
delete json.outer;
|
|
5713
|
+
}
|
|
5714
|
+
if (json.scoped.length === 0) {
|
|
5715
|
+
delete json.scoped;
|
|
5716
|
+
}
|
|
5717
|
+
return json;
|
|
5718
|
+
}
|
|
5719
|
+
return toJSON(this);
|
|
5712
5720
|
}
|
|
5713
5721
|
}
|
|
5714
|
-
exports.
|
|
5715
|
-
|
|
5716
|
-
//# sourceMappingURL=
|
|
5717
|
-
//# sourceMappingURL=AmdJsRewriter.ts.map;
|
|
5722
|
+
exports.ModuleFile = ModuleFile;
|
|
5723
|
+
//# sourceMappingURL=ModuleFile.js.map
|
|
5724
|
+
//# sourceMappingURL=ModuleFile.ts.map;
|
|
5718
5725
|
|
|
5719
5726
|
function __isObj(x) {
|
|
5720
5727
|
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
5721
5728
|
}
|
|
5722
|
-
if (
|
|
5729
|
+
if (_src_handlers_script_import_js_ModuleFile === module.exports) {
|
|
5723
5730
|
// do nothing if
|
|
5724
|
-
} else if (__isObj(
|
|
5725
|
-
Object.assign(
|
|
5731
|
+
} else if (__isObj(_src_handlers_script_import_js_ModuleFile) && __isObj(module.exports)) {
|
|
5732
|
+
Object.assign(_src_handlers_script_import_js_ModuleFile, module.exports);
|
|
5726
5733
|
} else {
|
|
5727
|
-
|
|
5734
|
+
_src_handlers_script_import_js_ModuleFile = module.exports;
|
|
5728
5735
|
}
|
|
5729
5736
|
|
|
5730
5737
|
;
|
|
@@ -5734,91 +5741,208 @@ exports.AmdJsRewriter = AmdJsRewriter;
|
|
|
5734
5741
|
|
|
5735
5742
|
|
|
5736
5743
|
// source ./ModuleSimplified.js
|
|
5737
|
-
var
|
|
5744
|
+
var _src_handlers_script_import_js_Parser;
|
|
5738
5745
|
(function () {
|
|
5739
5746
|
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
5740
5747
|
var define = null;
|
|
5741
|
-
var exports =
|
|
5748
|
+
var exports = _src_handlers_script_import_js_Parser != null ? _src_handlers_script_import_js_Parser : {};
|
|
5742
5749
|
var module = { exports: exports };
|
|
5743
5750
|
|
|
5744
5751
|
"use strict";
|
|
5745
5752
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5746
|
-
exports.
|
|
5747
|
-
const
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
+
exports.Parser = void 0;
|
|
5754
|
+
const ModuleFile_1 = _src_handlers_script_import_js_ModuleFile;
|
|
5755
|
+
const ResourceInfo_1 = _src_class_ResourceInfo;
|
|
5756
|
+
let Rgx = {
|
|
5757
|
+
Imports: {
|
|
5758
|
+
full: {
|
|
5759
|
+
rgx: /^[ \t]*import\s*(\*\s+as\s+\w+\s+from\s+)?['"](?<path>[^'"]+)['"][\t ;]*[\r\n]{0,2}/gm,
|
|
5760
|
+
map(match) {
|
|
5761
|
+
let $import = new ResourceInfo_1.ImportNode();
|
|
5762
|
+
$import.position = match.index;
|
|
5763
|
+
$import.length = match[0].length;
|
|
5764
|
+
$import.type = 'full';
|
|
5765
|
+
$import.path = match.groups.path;
|
|
5766
|
+
return $import;
|
|
5767
|
+
}
|
|
5768
|
+
},
|
|
5769
|
+
refs: {
|
|
5770
|
+
rgx: /^[ \t]*import\s*\{([^}]+)}\s*from\s*['"]([^'"]+)['"][\t ;]*[\r\n]{0,2}/gm,
|
|
5771
|
+
map(match) {
|
|
5772
|
+
let $import = new ResourceInfo_1.ImportNode();
|
|
5773
|
+
$import.position = match.index;
|
|
5774
|
+
$import.length = match[0].length;
|
|
5775
|
+
$import.type = 'refs';
|
|
5776
|
+
$import.path = match[2];
|
|
5777
|
+
$import.refs = match[1].split(',').map(x => x.trim());
|
|
5778
|
+
return $import;
|
|
5779
|
+
}
|
|
5780
|
+
},
|
|
5781
|
+
defaults: {
|
|
5782
|
+
rgx: /^[ \t]*import\s+(?<def>\w+)\s+from\s*['"](?<path>[^'"]+)['"][\t ;]*[\r\n]{0,2}/gm,
|
|
5783
|
+
map(match) {
|
|
5784
|
+
let $import = new ResourceInfo_1.ImportNode();
|
|
5785
|
+
$import.position = match.index;
|
|
5786
|
+
$import.length = match[0].length;
|
|
5787
|
+
$import.type = 'full';
|
|
5788
|
+
$import.path = match.groups.path;
|
|
5789
|
+
return $import;
|
|
5790
|
+
}
|
|
5791
|
+
},
|
|
5792
|
+
exportAll: {
|
|
5793
|
+
rgx: /^[ \t]*export\s+\*\s+from\s*['"]([^'"]+)['"][\t ;]*[\r\n]{0,2}/gm,
|
|
5794
|
+
map(match) {
|
|
5795
|
+
let $import = new ResourceInfo_1.ImportNode();
|
|
5796
|
+
$import.position = match.index;
|
|
5797
|
+
$import.length = match[0].length;
|
|
5798
|
+
$import.type = 'exportAll';
|
|
5799
|
+
$import.path = match[1];
|
|
5800
|
+
$import.exportAll = true;
|
|
5801
|
+
return $import;
|
|
5802
|
+
}
|
|
5803
|
+
},
|
|
5804
|
+
exportRefs: {
|
|
5805
|
+
rgx: /^[ \t]*export\s*\{([^}]+)}\s*from\s*['"]([^'"]+)['"][\t ;]*[\r\n]{0,2}/gm,
|
|
5806
|
+
map(match) {
|
|
5807
|
+
let $import = new ResourceInfo_1.ImportNode();
|
|
5808
|
+
$import.position = match.index;
|
|
5809
|
+
$import.length = match[0].length;
|
|
5810
|
+
$import.type = 'exportRefs';
|
|
5811
|
+
$import.path = match[2];
|
|
5812
|
+
$import.refs = match[1].split(',').map(x => x.trim());
|
|
5813
|
+
$import.exportRefs = true;
|
|
5814
|
+
return $import;
|
|
5815
|
+
}
|
|
5816
|
+
}
|
|
5817
|
+
},
|
|
5818
|
+
Exports: {
|
|
5819
|
+
ref: {
|
|
5820
|
+
rgx: /^[ \t]*export\s*(const|let|var)\s+([\w\d_$]+)(?=\s*[^\w\d_$;])/gm,
|
|
5821
|
+
map(match) {
|
|
5822
|
+
let $export = new ResourceInfo_1.ExportNode();
|
|
5823
|
+
$export.position = match.index;
|
|
5824
|
+
$export.length = match[0].length;
|
|
5825
|
+
$export.type = 'ref';
|
|
5826
|
+
$export.ref = match[2];
|
|
5827
|
+
return $export;
|
|
5828
|
+
}
|
|
5829
|
+
},
|
|
5830
|
+
named: {
|
|
5831
|
+
rgx: /^[ \t]*export\s*(const|let|var)\s+([\w\d_$]+)(?=\s*[;])/gm,
|
|
5832
|
+
map(match) {
|
|
5833
|
+
let $export = new ResourceInfo_1.ExportNode();
|
|
5834
|
+
$export.position = match.index;
|
|
5835
|
+
$export.length = match[0].length;
|
|
5836
|
+
$export.type = 'named';
|
|
5837
|
+
$export.ref = match[2];
|
|
5838
|
+
return $export;
|
|
5839
|
+
}
|
|
5840
|
+
},
|
|
5841
|
+
scoped: {
|
|
5842
|
+
rgx: /^[ \t]*export\s*\{([^}]+)}\s*;?(?!\s*from)/gm,
|
|
5843
|
+
map(match) {
|
|
5844
|
+
let refs = match[1].split(',').map(x => x.trim());
|
|
5845
|
+
let $export = new ResourceInfo_1.ExportNode();
|
|
5846
|
+
$export.position = match.index;
|
|
5847
|
+
$export.length = match[0].length;
|
|
5848
|
+
$export.type = 'scoped';
|
|
5849
|
+
$export.ref = refs[0];
|
|
5850
|
+
let other = refs.slice(1).map(ref => {
|
|
5851
|
+
let $export = new ResourceInfo_1.ExportNode();
|
|
5852
|
+
$export.position = match.index;
|
|
5853
|
+
$export.length = 0;
|
|
5854
|
+
$export.type = 'scoped';
|
|
5855
|
+
$export.ref = ref;
|
|
5856
|
+
return $export;
|
|
5857
|
+
});
|
|
5858
|
+
return [$export, ...other];
|
|
5859
|
+
}
|
|
5860
|
+
},
|
|
5861
|
+
function: {
|
|
5862
|
+
rgx: /^[ \t]*export\s*function\s+([\w\d_$]+)/gm,
|
|
5863
|
+
map(match) {
|
|
5864
|
+
let $export = new ResourceInfo_1.ExportNode();
|
|
5865
|
+
$export.position = match.index;
|
|
5866
|
+
$export.length = match[0].length;
|
|
5867
|
+
$export.type = 'function';
|
|
5868
|
+
$export.ref = match[1];
|
|
5869
|
+
return $export;
|
|
5870
|
+
}
|
|
5871
|
+
}
|
|
5753
5872
|
}
|
|
5754
|
-
|
|
5755
|
-
|
|
5756
|
-
|
|
5873
|
+
};
|
|
5874
|
+
class Parser {
|
|
5875
|
+
static supports(content) {
|
|
5876
|
+
for (let type in Rgx) {
|
|
5877
|
+
for (let key in Rgx[type]) {
|
|
5878
|
+
let rgx = Rgx[type][key].rgx;
|
|
5879
|
+
rgx.lastIndex = 0;
|
|
5880
|
+
if (rgx.test(content)) {
|
|
5881
|
+
return true;
|
|
5882
|
+
}
|
|
5883
|
+
}
|
|
5757
5884
|
}
|
|
5758
|
-
|
|
5759
|
-
|
|
5760
|
-
|
|
5885
|
+
return false;
|
|
5886
|
+
}
|
|
5887
|
+
static parse(content, file) {
|
|
5888
|
+
let module = new ModuleFile_1.ModuleFile(content, file);
|
|
5889
|
+
if (Parser.supports(content) === false) {
|
|
5890
|
+
return module;
|
|
5761
5891
|
}
|
|
5762
|
-
|
|
5892
|
+
for (let key in Rgx.Imports) {
|
|
5893
|
+
let x = Rgx.Imports[key];
|
|
5894
|
+
x.rgx.lastIndex = 0;
|
|
5895
|
+
for (let match = x.rgx.exec(content); match != null; match = x.rgx.exec(content)) {
|
|
5896
|
+
let result = x.map(match, content);
|
|
5897
|
+
if (Array.isArray(result)) {
|
|
5898
|
+
module.imports.push(...result);
|
|
5899
|
+
}
|
|
5900
|
+
else {
|
|
5901
|
+
module.imports.push(result);
|
|
5902
|
+
}
|
|
5903
|
+
}
|
|
5904
|
+
}
|
|
5905
|
+
for (let key in Rgx.Exports) {
|
|
5906
|
+
let x = Rgx.Exports[key];
|
|
5907
|
+
x.rgx.lastIndex = 0;
|
|
5908
|
+
for (let match = x.rgx.exec(content); match != null; match = x.rgx.exec(content)) {
|
|
5909
|
+
let result = x.map(match, content);
|
|
5910
|
+
if (Array.isArray(result)) {
|
|
5911
|
+
module.exports.push(...result);
|
|
5912
|
+
}
|
|
5913
|
+
else {
|
|
5914
|
+
module.exports.push(result);
|
|
5915
|
+
}
|
|
5916
|
+
}
|
|
5917
|
+
}
|
|
5918
|
+
module.imports.forEach(m => m.parent = module);
|
|
5919
|
+
module.imports.filter(x => x.type === 'exportRefs').forEach(imp => {
|
|
5920
|
+
imp.refs.forEach(ref => {
|
|
5921
|
+
let exp = new ResourceInfo_1.ExportNode();
|
|
5922
|
+
exp.position = 0;
|
|
5923
|
+
exp.length = 0;
|
|
5924
|
+
exp.ref = ref;
|
|
5925
|
+
module.exports.push(exp);
|
|
5926
|
+
});
|
|
5927
|
+
});
|
|
5928
|
+
module.imports.sort((a, b) => a.position < b.position ? -1 : 1);
|
|
5929
|
+
module.exports.sort((a, b) => a.position < b.position ? -1 : 1);
|
|
5930
|
+
return module;
|
|
5763
5931
|
}
|
|
5764
5932
|
}
|
|
5765
|
-
exports.
|
|
5766
|
-
|
|
5767
|
-
//# sourceMappingURL=
|
|
5768
|
-
//# sourceMappingURL=AmdJsBuilder.ts.map;
|
|
5769
|
-
|
|
5770
|
-
function __isObj(x) {
|
|
5771
|
-
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
5772
|
-
}
|
|
5773
|
-
if (_src_handlers_script_amd_js_AmdJsBuilder === module.exports) {
|
|
5774
|
-
// do nothing if
|
|
5775
|
-
} else if (__isObj(_src_handlers_script_amd_js_AmdJsBuilder) && __isObj(module.exports)) {
|
|
5776
|
-
Object.assign(_src_handlers_script_amd_js_AmdJsBuilder, module.exports);
|
|
5777
|
-
} else {
|
|
5778
|
-
_src_handlers_script_amd_js_AmdJsBuilder = module.exports;
|
|
5779
|
-
}
|
|
5780
|
-
|
|
5781
|
-
;
|
|
5782
|
-
}());
|
|
5783
|
-
|
|
5784
|
-
// end:source ./ModuleSimplified.js
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
// source ./ModuleSimplified.js
|
|
5788
|
-
var _src_handlers_script_amd_js_AmdJsHandler;
|
|
5789
|
-
(function () {
|
|
5790
|
-
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
5791
|
-
var define = null;
|
|
5792
|
-
var exports = _src_handlers_script_amd_js_AmdJsHandler != null ? _src_handlers_script_amd_js_AmdJsHandler : {};
|
|
5793
|
-
var module = { exports: exports };
|
|
5794
|
-
|
|
5795
|
-
"use strict";
|
|
5796
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5797
|
-
exports.AmdJsHandler = void 0;
|
|
5798
|
-
const AmdJsParser_1 = _src_handlers_script_amd_js_AmdJsParser;
|
|
5799
|
-
const AmdJsRewriter_1 = _src_handlers_script_amd_js_AmdJsRewriter;
|
|
5800
|
-
const AmdJsBuilder_1 = _src_handlers_script_amd_js_AmdJsBuilder;
|
|
5801
|
-
const BaseHandler_1 = _src_handlers_base_BaseHandler;
|
|
5802
|
-
class AmdJsHandler extends BaseHandler_1.BaseHandler {
|
|
5803
|
-
}
|
|
5804
|
-
exports.AmdJsHandler = AmdJsHandler;
|
|
5805
|
-
AmdJsHandler.Parser = AmdJsParser_1.AmdJsParser;
|
|
5806
|
-
AmdJsHandler.Rewriter = AmdJsRewriter_1.AmdJsRewriter;
|
|
5807
|
-
AmdJsHandler.Builder = AmdJsBuilder_1.AmdJsBuilder;
|
|
5808
|
-
AmdJsHandler.PathResolver = null;
|
|
5809
|
-
;
|
|
5810
|
-
//# sourceMappingURL=AmdJsHandler.js.map
|
|
5811
|
-
//# sourceMappingURL=AmdJsHandler.ts.map;
|
|
5933
|
+
exports.Parser = Parser;
|
|
5934
|
+
//# sourceMappingURL=Parser.js.map
|
|
5935
|
+
//# sourceMappingURL=Parser.ts.map;
|
|
5812
5936
|
|
|
5813
5937
|
function __isObj(x) {
|
|
5814
5938
|
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
5815
5939
|
}
|
|
5816
|
-
if (
|
|
5940
|
+
if (_src_handlers_script_import_js_Parser === module.exports) {
|
|
5817
5941
|
// do nothing if
|
|
5818
|
-
} else if (__isObj(
|
|
5819
|
-
Object.assign(
|
|
5942
|
+
} else if (__isObj(_src_handlers_script_import_js_Parser) && __isObj(module.exports)) {
|
|
5943
|
+
Object.assign(_src_handlers_script_import_js_Parser, module.exports);
|
|
5820
5944
|
} else {
|
|
5821
|
-
|
|
5945
|
+
_src_handlers_script_import_js_Parser = module.exports;
|
|
5822
5946
|
}
|
|
5823
5947
|
|
|
5824
5948
|
;
|
|
@@ -5828,70 +5952,124 @@ AmdJsHandler.PathResolver = null;
|
|
|
5828
5952
|
|
|
5829
5953
|
|
|
5830
5954
|
// source ./ModuleSimplified.js
|
|
5831
|
-
var
|
|
5955
|
+
var _src_handlers_script_common_js_ModuleWrapper;
|
|
5832
5956
|
(function () {
|
|
5833
5957
|
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
5834
5958
|
var define = null;
|
|
5835
|
-
var exports =
|
|
5959
|
+
var exports = _src_handlers_script_common_js_ModuleWrapper != null ? _src_handlers_script_common_js_ModuleWrapper : {};
|
|
5836
5960
|
var module = { exports: exports };
|
|
5837
5961
|
|
|
5838
5962
|
"use strict";
|
|
5839
5963
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5840
|
-
exports.
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5851
|
-
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5964
|
+
exports.ModuleWrapper = void 0;
|
|
5965
|
+
const global_1 = _src_global;
|
|
5966
|
+
const Templates_1 = _src_handlers_script_common_js_templates_Templates;
|
|
5967
|
+
const Parser_1 = _src_handlers_script_import_js_Parser;
|
|
5968
|
+
class ModuleWrapper {
|
|
5969
|
+
constructor(solution) {
|
|
5970
|
+
this.solution = solution;
|
|
5971
|
+
}
|
|
5972
|
+
wrap(body) {
|
|
5973
|
+
let wrapper = this.solution.opts.package.moduleWrapper;
|
|
5974
|
+
switch (wrapper) {
|
|
5975
|
+
case 'script':
|
|
5976
|
+
body = this.wrapSimple(body);
|
|
5977
|
+
break;
|
|
5978
|
+
case 'iif':
|
|
5979
|
+
body = this.wrapWithIIF(body);
|
|
5980
|
+
break;
|
|
5981
|
+
case 'umd':
|
|
5982
|
+
body = this.wrapWithUMD(body);
|
|
5983
|
+
break;
|
|
5984
|
+
case 'esm':
|
|
5985
|
+
body = this.wrapWithESM(body);
|
|
5986
|
+
break;
|
|
5987
|
+
case 'custom':
|
|
5988
|
+
body = this.wrapWithCustom(body);
|
|
5989
|
+
break;
|
|
5990
|
+
default:
|
|
5991
|
+
throw new Error('Uknown module wrapper: ' + wrapper);
|
|
5865
5992
|
}
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5993
|
+
return body;
|
|
5994
|
+
}
|
|
5995
|
+
wrapSimple(body) {
|
|
5996
|
+
return Templates_1.Templates
|
|
5997
|
+
.RootModule
|
|
5998
|
+
.replace('%BUNDLE%', () => body);
|
|
5999
|
+
}
|
|
6000
|
+
wrapWithIIF(body) {
|
|
6001
|
+
return Templates_1.Templates
|
|
6002
|
+
.RootModuleWrapped
|
|
6003
|
+
.replace('%BUNDLE%', () => body);
|
|
6004
|
+
}
|
|
6005
|
+
wrapWithUMD(body) {
|
|
6006
|
+
let opts = this.solution.opts.package;
|
|
6007
|
+
let name = opts.moduleName || '';
|
|
6008
|
+
return Templates_1.Templates
|
|
6009
|
+
.UMD
|
|
6010
|
+
.replace('%MODULE%', () => body)
|
|
6011
|
+
.replace('%NAME%', () => name);
|
|
6012
|
+
}
|
|
6013
|
+
wrapWithESM(body) {
|
|
6014
|
+
let opts = this.solution.opts.package;
|
|
6015
|
+
let exportsCode = opts.moduleExportsCode || '';
|
|
6016
|
+
let importsCode = opts.moduleImportsCode || '';
|
|
6017
|
+
let deps = this.solution.outputResources.dynamicDependencies;
|
|
6018
|
+
if (deps.length > 0) {
|
|
6019
|
+
let arr = deps.map(dep => {
|
|
6020
|
+
let key = `bundlerDynamic_${dep.url.replace(/[^\w]/g, '_')}`;
|
|
6021
|
+
return {
|
|
6022
|
+
url: dep.url,
|
|
6023
|
+
key
|
|
6024
|
+
};
|
|
6025
|
+
});
|
|
6026
|
+
let strImports = arr.map(item => `import ${item.key} from '${item.url}';`).join('\n');
|
|
6027
|
+
let strCollection = `const bundlerDynamicRepository = {};\n`
|
|
6028
|
+
+ arr.map(item => `bundlerDynamicRepository['${item.url}'] = ${item.key};`)
|
|
6029
|
+
.join('\n');
|
|
6030
|
+
let strRequire = [
|
|
6031
|
+
`var bundlerOriginalRequire = require || function (url) { throw new Error('Not found: ' + url); };`,
|
|
6032
|
+
`var require = function (url) { return bundlerDynamicRepository[url] || bundlerOriginalRequire(url); };`
|
|
6033
|
+
].join('\n');
|
|
6034
|
+
importsCode = [
|
|
6035
|
+
strImports,
|
|
6036
|
+
strCollection,
|
|
6037
|
+
strRequire
|
|
6038
|
+
].join('\n');
|
|
5878
6039
|
}
|
|
5879
|
-
|
|
6040
|
+
let rootPath = this.solution.path;
|
|
6041
|
+
let rootContentRaw = global_1.io.File.read(rootPath, { cached: false, skipHooks: true, encoding: 'utf8' });
|
|
6042
|
+
let module = Parser_1.Parser.parse(rootContentRaw, new global_1.io.File(this.solution.path));
|
|
6043
|
+
let exportsBefore = module.exports.map(x => {
|
|
6044
|
+
return `export const ${x.ref} = module.exports.${x.ref};`;
|
|
6045
|
+
}).join('\n');
|
|
6046
|
+
exportsCode = `${exportsBefore}\n${exportsCode}`;
|
|
6047
|
+
return Templates_1.Templates
|
|
6048
|
+
.ESM
|
|
6049
|
+
.replace('$CUSTOM_IMPORTS_CODE$', () => importsCode)
|
|
6050
|
+
.replace('$CUSTOM_EXPORTS_CODE$', () => exportsCode)
|
|
6051
|
+
.replace('$MODULE$', () => body);
|
|
6052
|
+
}
|
|
6053
|
+
wrapWithCustom(body) {
|
|
6054
|
+
let opts = this.solution.opts.package;
|
|
6055
|
+
let template = Templates_1.Templates.load(opts.moduleWrapperCustomPath);
|
|
6056
|
+
return template
|
|
6057
|
+
.replace('/**MODULE**/', () => body);
|
|
5880
6058
|
}
|
|
5881
6059
|
}
|
|
5882
|
-
exports.
|
|
5883
|
-
//# sourceMappingURL=
|
|
5884
|
-
//# sourceMappingURL=
|
|
6060
|
+
exports.ModuleWrapper = ModuleWrapper;
|
|
6061
|
+
//# sourceMappingURL=ModuleWrapper.js.map
|
|
6062
|
+
//# sourceMappingURL=ModuleWrapper.ts.map;
|
|
5885
6063
|
|
|
5886
6064
|
function __isObj(x) {
|
|
5887
6065
|
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
5888
6066
|
}
|
|
5889
|
-
if (
|
|
6067
|
+
if (_src_handlers_script_common_js_ModuleWrapper === module.exports) {
|
|
5890
6068
|
// do nothing if
|
|
5891
|
-
} else if (__isObj(
|
|
5892
|
-
Object.assign(
|
|
6069
|
+
} else if (__isObj(_src_handlers_script_common_js_ModuleWrapper) && __isObj(module.exports)) {
|
|
6070
|
+
Object.assign(_src_handlers_script_common_js_ModuleWrapper, module.exports);
|
|
5893
6071
|
} else {
|
|
5894
|
-
|
|
6072
|
+
_src_handlers_script_common_js_ModuleWrapper = module.exports;
|
|
5895
6073
|
}
|
|
5896
6074
|
|
|
5897
6075
|
;
|
|
@@ -5901,200 +6079,108 @@ exports.ResourcePropMapping = ResourcePropMapping;
|
|
|
5901
6079
|
|
|
5902
6080
|
|
|
5903
6081
|
// source ./ModuleSimplified.js
|
|
5904
|
-
var
|
|
6082
|
+
var _src_handlers_script_common_js_CommonJsBuilder;
|
|
5905
6083
|
(function () {
|
|
5906
6084
|
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
5907
6085
|
var define = null;
|
|
5908
|
-
var exports =
|
|
6086
|
+
var exports = _src_handlers_script_common_js_CommonJsBuilder != null ? _src_handlers_script_common_js_CommonJsBuilder : {};
|
|
5909
6087
|
var module = { exports: exports };
|
|
5910
6088
|
|
|
5911
6089
|
"use strict";
|
|
5912
6090
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5913
|
-
exports.
|
|
5914
|
-
const
|
|
5915
|
-
const
|
|
5916
|
-
const
|
|
5917
|
-
const
|
|
5918
|
-
const
|
|
5919
|
-
class
|
|
6091
|
+
exports.CommonJsBuilder = void 0;
|
|
6092
|
+
const CommonJsBuilderSimplified_1 = _src_handlers_script_common_js_CommonJsBuilderSimplified;
|
|
6093
|
+
const Templates_1 = _src_handlers_script_common_js_templates_Templates;
|
|
6094
|
+
const BaseScriptBuilder_1 = _src_handlers_script_base_BaseScriptBuilder;
|
|
6095
|
+
const template_1 = _src_utils_template;
|
|
6096
|
+
const ModuleWrapper_1 = _src_handlers_script_common_js_ModuleWrapper;
|
|
6097
|
+
class CommonJsBuilder extends BaseScriptBuilder_1.BaseScriptBuilder {
|
|
5920
6098
|
constructor(solution, handler) {
|
|
5921
6099
|
super(solution, handler);
|
|
5922
|
-
|
|
5923
|
-
|
|
6100
|
+
this.solution = solution;
|
|
6101
|
+
this.handler = handler;
|
|
6102
|
+
var opts = this.solution.opts.package.commonjs;
|
|
6103
|
+
if (opts && opts.output === 'simplified') {
|
|
6104
|
+
this.wrapModule = CommonJsBuilderSimplified_1.CommonJsBuilderSimplified.wrapModule;
|
|
6105
|
+
this.getRootContent = CommonJsBuilderSimplified_1.CommonJsBuilderSimplified.getRootContent;
|
|
6106
|
+
this.getHeaderContent = CommonJsBuilderSimplified_1.CommonJsBuilderSimplified.getHeaderContent;
|
|
5924
6107
|
}
|
|
5925
6108
|
}
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
url: null,
|
|
5930
|
-
dependencies: [],
|
|
5931
|
-
meta: {
|
|
5932
|
-
includejs: {
|
|
5933
|
-
hasIncludes: false,
|
|
5934
|
-
hasExports: false,
|
|
5935
|
-
hasResponseObject: false,
|
|
5936
|
-
responseAccessors: null,
|
|
5937
|
-
}
|
|
5938
|
-
}
|
|
5939
|
-
};
|
|
5940
|
-
AstUtil_1.AstUtil.each(ast, AstUtil_1.AstUtil.is.includeFunction, (node, descend) => {
|
|
5941
|
-
function isIncludeSymbolRef(node) {
|
|
5942
|
-
return AstUtil_1.AstUtil.is.type(node, 'AST_SymbolRef') && node.name == 'include';
|
|
5943
|
-
}
|
|
5944
|
-
let scope = AstUtil_1.AstUtil.findNode(node, isIncludeSymbolRef).scope || ast;
|
|
5945
|
-
this._process(info, node, scope);
|
|
5946
|
-
return true;
|
|
5947
|
-
});
|
|
5948
|
-
if (this._getPropertySetter('exports', ast) != null) {
|
|
5949
|
-
info.meta.includejs.hasExports = true;
|
|
6109
|
+
accepts(resource) {
|
|
6110
|
+
if (resource.type !== 'js') {
|
|
6111
|
+
return false;
|
|
5950
6112
|
}
|
|
5951
|
-
|
|
6113
|
+
let module = resource.getModule();
|
|
6114
|
+
if (module == null || module === 'root') {
|
|
6115
|
+
module = this.solution.opts.package.module;
|
|
6116
|
+
}
|
|
6117
|
+
return module === 'commonjs';
|
|
5952
6118
|
}
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
6119
|
+
wrapModule(resource, outputItem, outputItems, setts) {
|
|
6120
|
+
var opts = this.solution.iteration;
|
|
6121
|
+
if (opts.commonjs == null) {
|
|
6122
|
+
opts.commonjs = {
|
|
6123
|
+
addHeading: true,
|
|
6124
|
+
hasHeading: false
|
|
6125
|
+
};
|
|
5957
6126
|
}
|
|
5958
6127
|
;
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
case 'load':
|
|
5964
|
-
case 'lazy':
|
|
5965
|
-
case 'mask':
|
|
5966
|
-
case 'routes':
|
|
5967
|
-
case 'setBase':
|
|
5968
|
-
case 'cfg':
|
|
5969
|
-
let pckg = {
|
|
5970
|
-
type: node.expression.property,
|
|
5971
|
-
args: AstUtil_1.AstUtil.getArguments(node.args, scope),
|
|
5972
|
-
};
|
|
5973
|
-
if (pckg.args.length > 0) {
|
|
5974
|
-
arr.unshift(pckg);
|
|
5975
|
-
}
|
|
5976
|
-
info.meta.includejs.hasIncludes = true;
|
|
5977
|
-
break;
|
|
5978
|
-
case 'done':
|
|
5979
|
-
case 'ready':
|
|
5980
|
-
this._processIncludeCallback(info, node.args && node.args[0]);
|
|
5981
|
-
break;
|
|
5982
|
-
case 'instance':
|
|
5983
|
-
case 'embed':
|
|
5984
|
-
case 'plugin':
|
|
5985
|
-
case 'ajax':
|
|
5986
|
-
case 'promise':
|
|
5987
|
-
case 'client':
|
|
5988
|
-
case 'server':
|
|
5989
|
-
case 'use':
|
|
5990
|
-
case 'getPending':
|
|
5991
|
-
case 'getResource':
|
|
5992
|
-
case 'getResourceById':
|
|
5993
|
-
case 'getResources':
|
|
5994
|
-
case 'apply':
|
|
5995
|
-
break;
|
|
5996
|
-
default:
|
|
5997
|
-
this.solution.reporter.warn('getIncludes: Unknown function call', node.expression);
|
|
5998
|
-
break;
|
|
5999
|
-
}
|
|
6000
|
-
});
|
|
6001
|
-
let include = new Include_1.Include();
|
|
6002
|
-
arr.forEach(function (x) {
|
|
6003
|
-
include[x.type].apply(include, x.args);
|
|
6004
|
-
});
|
|
6005
|
-
info.dependencies.push(...include.includes);
|
|
6006
|
-
}
|
|
6007
|
-
_processIncludeCallback(info, CallbackNode) {
|
|
6008
|
-
if (AstUtil_1.AstUtil.is.type(CallbackNode, 'AST_Function') == false) {
|
|
6009
|
-
return;
|
|
6010
|
-
}
|
|
6011
|
-
let meta = info.meta.includejs, args = CallbackNode.argnames, responseObjectName = args.length > 0
|
|
6012
|
-
? args[args.length - 1].name
|
|
6013
|
-
: null;
|
|
6014
|
-
if (responseObjectName) {
|
|
6015
|
-
meta.hasResponseObject = true;
|
|
6016
|
-
let names = this._getPropertyAccessors(responseObjectName, CallbackNode);
|
|
6017
|
-
if (names) {
|
|
6018
|
-
meta.responseAccessors = (meta.responseAccessors || []).concat(names);
|
|
6019
|
-
}
|
|
6128
|
+
var body = '';
|
|
6129
|
+
if (opts.commonjs.hasHeading === false && opts.commonjs.addHeading === true) {
|
|
6130
|
+
opts.commonjs.hasHeading = true;
|
|
6131
|
+
body = this.getHeaderContent();
|
|
6020
6132
|
}
|
|
6133
|
+
var { url, content } = resource;
|
|
6134
|
+
var module = Templates_1.Templates
|
|
6135
|
+
.Module
|
|
6136
|
+
.replace('%MODULE_PATH%', () => url)
|
|
6137
|
+
.replace('%MODULE%', () => content)
|
|
6138
|
+
.replace('%FOOTER%', () => { var _a, _b; return ((_b = (_a = setts === null || setts === void 0 ? void 0 : setts.partials) === null || _a === void 0 ? void 0 : _a.footer) !== null && _b !== void 0 ? _b : ''); });
|
|
6139
|
+
return body + module;
|
|
6021
6140
|
}
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
Fn.body.forEach(function (x) {
|
|
6028
|
-
function isSymbolName(node) {
|
|
6029
|
-
return AstUtil_1.AstUtil.is.type(node, 'AST_SymbolRef') && node.name === name;
|
|
6030
|
-
}
|
|
6031
|
-
AstUtil_1.AstUtil.each(x, isSymbolName, function (node) {
|
|
6032
|
-
let chain = AstUtil_1.AstUtil.getPropertyChain(node, this.stack);
|
|
6033
|
-
if (chain) {
|
|
6034
|
-
references.push(chain);
|
|
6035
|
-
}
|
|
6036
|
-
});
|
|
6037
|
-
});
|
|
6038
|
-
return references;
|
|
6141
|
+
getHeaderContent() {
|
|
6142
|
+
var mainUrl = this.solution.outputResources.rootInput.url;
|
|
6143
|
+
return Templates_1.Templates
|
|
6144
|
+
.Header
|
|
6145
|
+
.replace('%ROOT_DIR%', () => mainUrl);
|
|
6039
6146
|
}
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6147
|
+
buildRoot(root, outputDependencies) {
|
|
6148
|
+
outputDependencies.forEach(x => x.embed = true);
|
|
6149
|
+
let content = this.getRootContent(root, outputDependencies);
|
|
6150
|
+
let body = outputDependencies
|
|
6151
|
+
.map(x => {
|
|
6152
|
+
let content = x.content;
|
|
6153
|
+
if (x.type === 'css') {
|
|
6154
|
+
content = (0, template_1.template_interpolate)(Templates_1.Templates.Style, { body: (0, template_1.template_stringifyContent)(content), url: x.url });
|
|
6048
6155
|
}
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6156
|
+
if (x.type === 'mask') {
|
|
6157
|
+
content = (0, template_1.template_interpolate)(Templates_1.Templates.Mask, { body: (0, template_1.template_stringifyContent)(content), url: x.url });
|
|
6158
|
+
}
|
|
6159
|
+
return content;
|
|
6160
|
+
})
|
|
6161
|
+
.concat([content])
|
|
6162
|
+
.join('\n');
|
|
6163
|
+
var wrapper = new ModuleWrapper_1.ModuleWrapper(this.solution);
|
|
6164
|
+
root.content = wrapper.wrap(body);
|
|
6165
|
+
}
|
|
6166
|
+
getRootContent(root, outputDependencies) {
|
|
6167
|
+
return root.content;
|
|
6057
6168
|
}
|
|
6058
6169
|
}
|
|
6059
|
-
exports.
|
|
6170
|
+
exports.CommonJsBuilder = CommonJsBuilder;
|
|
6060
6171
|
;
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
asModules: (arr) => arr.indexOf('mask') > -1
|
|
6064
|
-
}, {
|
|
6065
|
-
asModules: (arr) => {
|
|
6066
|
-
let i = arr.indexOf('mask');
|
|
6067
|
-
arr[i] = 'includejs';
|
|
6068
|
-
return arr;
|
|
6069
|
-
}
|
|
6070
|
-
}),
|
|
6071
|
-
new ResourcePropMapping_1.ResourcePropMapping({
|
|
6072
|
-
asModules: (arr) => arr.indexOf('amd') > -1
|
|
6073
|
-
}, {
|
|
6074
|
-
asModules: (arr) => {
|
|
6075
|
-
let i = arr.indexOf('amd');
|
|
6076
|
-
arr[i] = 'includejs';
|
|
6077
|
-
return arr;
|
|
6078
|
-
}
|
|
6079
|
-
}),
|
|
6080
|
-
new ResourcePropMapping_1.ResourcePropMapping({
|
|
6081
|
-
type: 'mask'
|
|
6082
|
-
}, {
|
|
6083
|
-
type: 'load'
|
|
6084
|
-
})
|
|
6085
|
-
];
|
|
6086
|
-
//# sourceMappingURL=IncludeJsParser.js.map
|
|
6087
|
-
//# sourceMappingURL=IncludeJsParser.ts.map;
|
|
6172
|
+
//# sourceMappingURL=CommonJsBuilder.js.map
|
|
6173
|
+
//# sourceMappingURL=CommonJsBuilder.ts.map;
|
|
6088
6174
|
|
|
6089
6175
|
function __isObj(x) {
|
|
6090
6176
|
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
6091
6177
|
}
|
|
6092
|
-
if (
|
|
6178
|
+
if (_src_handlers_script_common_js_CommonJsBuilder === module.exports) {
|
|
6093
6179
|
// do nothing if
|
|
6094
|
-
} else if (__isObj(
|
|
6095
|
-
Object.assign(
|
|
6180
|
+
} else if (__isObj(_src_handlers_script_common_js_CommonJsBuilder) && __isObj(module.exports)) {
|
|
6181
|
+
Object.assign(_src_handlers_script_common_js_CommonJsBuilder, module.exports);
|
|
6096
6182
|
} else {
|
|
6097
|
-
|
|
6183
|
+
_src_handlers_script_common_js_CommonJsBuilder = module.exports;
|
|
6098
6184
|
}
|
|
6099
6185
|
|
|
6100
6186
|
;
|
|
@@ -6104,147 +6190,104 @@ let IncludeJsMappings = [
|
|
|
6104
6190
|
|
|
6105
6191
|
|
|
6106
6192
|
// source ./ModuleSimplified.js
|
|
6107
|
-
var
|
|
6193
|
+
var _src_handlers_script_common_js_CommonJsPathResolver;
|
|
6108
6194
|
(function () {
|
|
6109
6195
|
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
6110
6196
|
var define = null;
|
|
6111
|
-
var exports =
|
|
6197
|
+
var exports = _src_handlers_script_common_js_CommonJsPathResolver != null ? _src_handlers_script_common_js_CommonJsPathResolver : {};
|
|
6112
6198
|
var module = { exports: exports };
|
|
6113
6199
|
|
|
6114
6200
|
"use strict";
|
|
6115
6201
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6116
|
-
exports.
|
|
6117
|
-
const
|
|
6118
|
-
const
|
|
6119
|
-
const
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
var jsResources = allResources.filter(x => this.accepts(x));
|
|
6125
|
-
var cssResources = allResources.filter(x => x.type === 'css');
|
|
6126
|
-
var loadResources = allResources.filter(x => x.type === 'load');
|
|
6127
|
-
var jsRegister = this._serializeRegister(jsResources, 'js');
|
|
6128
|
-
var cssRegister = this._serializeRegister(cssResources, 'css');
|
|
6129
|
-
var loadRegister = this._serializeRegister(loadResources, 'load');
|
|
6130
|
-
return `
|
|
6131
|
-
${jsRegister}
|
|
6132
|
-
${cssRegister}
|
|
6133
|
-
${loadRegister}
|
|
6134
|
-
`;
|
|
6135
|
-
}
|
|
6136
|
-
isMainBuilder(solution) {
|
|
6137
|
-
const KEY = 'includejs';
|
|
6138
|
-
const packageInfo = solution.opts.package;
|
|
6139
|
-
return packageInfo.module === KEY || packageInfo.moduleName === KEY;
|
|
6140
|
-
}
|
|
6141
|
-
wrapModule(resource, outputItem, otherOutputItems) {
|
|
6142
|
-
var opts = this.solution.opts;
|
|
6143
|
-
var page = (0, res_1.res_getPage)(resource, opts);
|
|
6144
|
-
var iteration = this.solution.iteration;
|
|
6145
|
-
if (iteration.includejs == null) {
|
|
6146
|
-
iteration.includejs = {};
|
|
6147
|
-
}
|
|
6148
|
-
if (iteration.includejs[page] == null) {
|
|
6149
|
-
iteration.includejs[page] = {
|
|
6150
|
-
addHeading: true,
|
|
6151
|
-
hasHeading: false,
|
|
6152
|
-
lastItem: null
|
|
6153
|
-
};
|
|
6154
|
-
}
|
|
6155
|
-
var builderOpts = iteration.includejs[page];
|
|
6156
|
-
var body = '';
|
|
6157
|
-
if (builderOpts.hasHeading === false && builderOpts.addHeading === true) {
|
|
6158
|
-
builderOpts.hasHeading = true;
|
|
6159
|
-
body = this._createHeading(builderOpts, resource, outputItem, otherOutputItems);
|
|
6202
|
+
exports.CommonJsPathResolver = void 0;
|
|
6203
|
+
const BasePathResolver_1 = _src_handlers_base_BasePathResolver;
|
|
6204
|
+
const path_1 = _src_utils_path;
|
|
6205
|
+
const global_1 = _src_global;
|
|
6206
|
+
class CommonJsPathResolver extends BasePathResolver_1.BasePathResolver {
|
|
6207
|
+
accepts(includeData) {
|
|
6208
|
+
if (includeData.type !== 'js' || includeData.module !== 'commonjs') {
|
|
6209
|
+
return false;
|
|
6160
6210
|
}
|
|
6161
|
-
|
|
6162
|
-
|
|
6163
|
-
let aliases = resource.aliases == null ? 'null' : '[' + resource.aliases.map(x => `'${x}'`).join(',') + ']';
|
|
6164
|
-
body += `include.setCurrent({ url: '${url}', aliases: ${aliases} });\n`;
|
|
6165
|
-
body += content;
|
|
6166
|
-
body += `\ninclude.getResourceById('${url}', 'js').readystatechanged(3);`;
|
|
6167
|
-
if (builderOpts.hasHeading && builderOpts.lastItem === resource) {
|
|
6168
|
-
body += `\ninclude.resumeStack();`;
|
|
6211
|
+
if (!/^[\w\-/]+$/.test(includeData.url)) {
|
|
6212
|
+
return false;
|
|
6169
6213
|
}
|
|
6170
|
-
|
|
6171
|
-
}
|
|
6172
|
-
accepts(resource) {
|
|
6173
|
-
if (resource.type !== 'js') {
|
|
6214
|
+
if (nodeCoreModules.indexOf(includeData.url) !== -1) {
|
|
6174
6215
|
return false;
|
|
6175
6216
|
}
|
|
6176
|
-
|
|
6177
|
-
return module === 'includejs';
|
|
6178
|
-
}
|
|
6179
|
-
_createHeading(builderOpts, resource, outputItem, otherOutputItems) {
|
|
6180
|
-
var outputItems = [outputItem, ...otherOutputItems];
|
|
6181
|
-
var allResources = (0, arr_1.arr_flattern)(outputItems.map(x => x.resources));
|
|
6182
|
-
var jsResources = allResources.filter(x => this.accepts(x));
|
|
6183
|
-
var cssResources = allResources.filter(x => x.type === 'css');
|
|
6184
|
-
var loadResources = allResources.filter(x => x.type === 'load');
|
|
6185
|
-
builderOpts.lastItem = jsResources[jsResources.length - 1];
|
|
6186
|
-
var jsRegister = this._serializeRegister(jsResources, 'js');
|
|
6187
|
-
var cssRegister = this._serializeRegister(cssResources, 'css');
|
|
6188
|
-
var loadRegister = this._serializeRegister(loadResources, 'load');
|
|
6189
|
-
var version = this._serializeVersion();
|
|
6190
|
-
var config = this._serializeConfig();
|
|
6191
|
-
var heading = `
|
|
6192
|
-
${version}
|
|
6193
|
-
${config}
|
|
6194
|
-
include.pauseStack();
|
|
6195
|
-
${jsRegister}
|
|
6196
|
-
${cssRegister}
|
|
6197
|
-
${loadRegister}
|
|
6198
|
-
`;
|
|
6199
|
-
return heading;
|
|
6200
|
-
}
|
|
6201
|
-
_serializeVersion() {
|
|
6202
|
-
var v = this.solution.opts.version;
|
|
6203
|
-
if (!v)
|
|
6204
|
-
return '';
|
|
6205
|
-
return `include.cfg('version', '${v}');`;
|
|
6206
|
-
}
|
|
6207
|
-
_serializeConfig() {
|
|
6208
|
-
var opts = Include_1.Include.getConfig();
|
|
6209
|
-
var json = JSON.stringify(opts);
|
|
6210
|
-
if (json === '{}')
|
|
6211
|
-
return '';
|
|
6212
|
-
return `include.cfg(${json});`;
|
|
6217
|
+
return true;
|
|
6213
6218
|
}
|
|
6214
|
-
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
.
|
|
6218
|
-
|
|
6219
|
-
type: type,
|
|
6220
|
-
url: x.toTargetUrl(this.solution)
|
|
6221
|
-
};
|
|
6222
|
-
});
|
|
6223
|
-
if (paths.length === 0) {
|
|
6224
|
-
return '';
|
|
6219
|
+
resolve(includeData, parentResource) {
|
|
6220
|
+
let filename = nodeModuleResolve(includeData.url, parentResource.directory);
|
|
6221
|
+
if (filename) {
|
|
6222
|
+
let url = this.solution.opts.toAppUrl(filename);
|
|
6223
|
+
this.solution.opts.mappings[includeData.url] = url;
|
|
6225
6224
|
}
|
|
6226
|
-
|
|
6227
|
-
[type]: paths
|
|
6228
|
-
});
|
|
6229
|
-
return `
|
|
6230
|
-
include.register(${json});
|
|
6231
|
-
`;
|
|
6225
|
+
return filename;
|
|
6232
6226
|
}
|
|
6233
6227
|
}
|
|
6234
|
-
exports.
|
|
6228
|
+
exports.CommonJsPathResolver = CommonJsPathResolver;
|
|
6235
6229
|
;
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
6230
|
+
const nodeCoreModules = [
|
|
6231
|
+
'assert', 'buffer', 'child_process', 'cluster', 'console', 'constants',
|
|
6232
|
+
'crypto', 'dgram', 'dns', 'domain', 'events', 'fs', 'http', 'https', 'module', 'net', 'os', 'path',
|
|
6233
|
+
'process', 'punycode', 'querystring', 'readline', 'repl', 'stream', 'string_decoder', 'sys', 'timers',
|
|
6234
|
+
'tls', 'tty', 'url', 'util', 'vm', 'zlib'
|
|
6235
|
+
];
|
|
6236
|
+
function nodeModuleResolve(path, location_) {
|
|
6237
|
+
let location = location_.replace(/[\\\/]+$/, '');
|
|
6238
|
+
let name = /^([\w\-]+)/.exec(path)[0];
|
|
6239
|
+
let resource = path.substring(name.length + 1);
|
|
6240
|
+
let current = location;
|
|
6241
|
+
let root_ = current + '/node_modules/' + name + '/';
|
|
6242
|
+
while (true) {
|
|
6243
|
+
let nodeModules = (0, path_1.path_combine)(current, '/node_modules/' + name + '/');
|
|
6244
|
+
let pckg = nodeModules + 'package.json';
|
|
6245
|
+
if (global_1.io.File.exists(pckg) === false) {
|
|
6246
|
+
let next = current.replace(/[^\/\\]+[\/\\]?$/, '');
|
|
6247
|
+
if (next === current) {
|
|
6248
|
+
return root_ + 'package.json';
|
|
6249
|
+
}
|
|
6250
|
+
current = next;
|
|
6251
|
+
continue;
|
|
6252
|
+
}
|
|
6253
|
+
if (resource) {
|
|
6254
|
+
let path = nodeModules + resource;
|
|
6255
|
+
if (hasExt(path) === false) {
|
|
6256
|
+
let likelyTs = path.includes('/src/');
|
|
6257
|
+
if (likelyTs) {
|
|
6258
|
+
if (global_1.io.File.exists(path + '.ts')) {
|
|
6259
|
+
return path + '.ts';
|
|
6260
|
+
}
|
|
6261
|
+
}
|
|
6262
|
+
return path + '.js';
|
|
6263
|
+
}
|
|
6264
|
+
return path;
|
|
6265
|
+
}
|
|
6266
|
+
let json = global_1.io.File.read(pckg);
|
|
6267
|
+
if (typeof json === 'string') {
|
|
6268
|
+
json = JSON.parse(json);
|
|
6269
|
+
}
|
|
6270
|
+
if (json.main) {
|
|
6271
|
+
return (0, path_1.path_combine)(nodeModules, json.main);
|
|
6272
|
+
}
|
|
6273
|
+
return nodeModules + 'index.js';
|
|
6274
|
+
}
|
|
6275
|
+
}
|
|
6276
|
+
function hasExt(path) {
|
|
6277
|
+
return /\.[\w]{1,8}($|\?)/.test(path);
|
|
6278
|
+
}
|
|
6279
|
+
//# sourceMappingURL=CommonJsPathResolver.js.map
|
|
6280
|
+
//# sourceMappingURL=CommonJsPathResolver.ts.map;
|
|
6281
|
+
|
|
6282
|
+
function __isObj(x) {
|
|
6283
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
6284
|
+
}
|
|
6285
|
+
if (_src_handlers_script_common_js_CommonJsPathResolver === module.exports) {
|
|
6286
|
+
// do nothing if
|
|
6287
|
+
} else if (__isObj(_src_handlers_script_common_js_CommonJsPathResolver) && __isObj(module.exports)) {
|
|
6288
|
+
Object.assign(_src_handlers_script_common_js_CommonJsPathResolver, module.exports);
|
|
6289
|
+
} else {
|
|
6290
|
+
_src_handlers_script_common_js_CommonJsPathResolver = module.exports;
|
|
6248
6291
|
}
|
|
6249
6292
|
|
|
6250
6293
|
;
|
|
@@ -6254,43 +6297,41 @@ exports.IncludeJsBuilder = IncludeJsBuilder;
|
|
|
6254
6297
|
|
|
6255
6298
|
|
|
6256
6299
|
// source ./ModuleSimplified.js
|
|
6257
|
-
var
|
|
6300
|
+
var _src_handlers_script_common_js_CommonJsHandler;
|
|
6258
6301
|
(function () {
|
|
6259
6302
|
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
6260
6303
|
var define = null;
|
|
6261
|
-
var exports =
|
|
6304
|
+
var exports = _src_handlers_script_common_js_CommonJsHandler != null ? _src_handlers_script_common_js_CommonJsHandler : {};
|
|
6262
6305
|
var module = { exports: exports };
|
|
6263
6306
|
|
|
6264
6307
|
"use strict";
|
|
6265
6308
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6266
|
-
exports.
|
|
6267
|
-
const
|
|
6268
|
-
|
|
6269
|
-
|
|
6270
|
-
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
resource.asModules = ['includejs'];
|
|
6274
|
-
}
|
|
6275
|
-
}
|
|
6276
|
-
accepts(type) {
|
|
6277
|
-
return type === 'js';
|
|
6278
|
-
}
|
|
6309
|
+
exports.CommonJsHandler = void 0;
|
|
6310
|
+
const CommonJsParser_1 = _src_handlers_script_common_js_CommonJsParser;
|
|
6311
|
+
const CommonJsRewriter_1 = _src_handlers_script_common_js_CommonJsRewriter;
|
|
6312
|
+
const CommonJsBuilder_1 = _src_handlers_script_common_js_CommonJsBuilder;
|
|
6313
|
+
const CommonJsPathResolver_1 = _src_handlers_script_common_js_CommonJsPathResolver;
|
|
6314
|
+
const BaseHandler_1 = _src_handlers_base_BaseHandler;
|
|
6315
|
+
class CommonJsHandler extends BaseHandler_1.BaseHandler {
|
|
6279
6316
|
}
|
|
6280
|
-
exports.
|
|
6317
|
+
exports.CommonJsHandler = CommonJsHandler;
|
|
6318
|
+
CommonJsHandler.Parser = CommonJsParser_1.CommonJsParser;
|
|
6319
|
+
CommonJsHandler.Rewriter = CommonJsRewriter_1.CommonJsRewriter;
|
|
6320
|
+
CommonJsHandler.Builder = CommonJsBuilder_1.CommonJsBuilder;
|
|
6321
|
+
CommonJsHandler.PathResolver = CommonJsPathResolver_1.CommonJsPathResolver;
|
|
6281
6322
|
;
|
|
6282
|
-
//# sourceMappingURL=
|
|
6283
|
-
//# sourceMappingURL=
|
|
6323
|
+
//# sourceMappingURL=CommonJsHandler.js.map
|
|
6324
|
+
//# sourceMappingURL=CommonJsHandler.ts.map;
|
|
6284
6325
|
|
|
6285
6326
|
function __isObj(x) {
|
|
6286
6327
|
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
6287
6328
|
}
|
|
6288
|
-
if (
|
|
6329
|
+
if (_src_handlers_script_common_js_CommonJsHandler === module.exports) {
|
|
6289
6330
|
// do nothing if
|
|
6290
|
-
} else if (__isObj(
|
|
6291
|
-
Object.assign(
|
|
6331
|
+
} else if (__isObj(_src_handlers_script_common_js_CommonJsHandler) && __isObj(module.exports)) {
|
|
6332
|
+
Object.assign(_src_handlers_script_common_js_CommonJsHandler, module.exports);
|
|
6292
6333
|
} else {
|
|
6293
|
-
|
|
6334
|
+
_src_handlers_script_common_js_CommonJsHandler = module.exports;
|
|
6294
6335
|
}
|
|
6295
6336
|
|
|
6296
6337
|
;
|
|
@@ -6300,71 +6341,69 @@ exports.IncludeJsRewriter = IncludeJsRewriter;
|
|
|
6300
6341
|
|
|
6301
6342
|
|
|
6302
6343
|
// source ./ModuleSimplified.js
|
|
6303
|
-
var
|
|
6344
|
+
var _src_handlers_script_amd_js_AmdJsParser;
|
|
6304
6345
|
(function () {
|
|
6305
6346
|
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
6306
6347
|
var define = null;
|
|
6307
|
-
var exports =
|
|
6348
|
+
var exports = _src_handlers_script_amd_js_AmdJsParser != null ? _src_handlers_script_amd_js_AmdJsParser : {};
|
|
6308
6349
|
var module = { exports: exports };
|
|
6309
6350
|
|
|
6310
6351
|
"use strict";
|
|
6311
6352
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6312
|
-
exports.
|
|
6313
|
-
const
|
|
6353
|
+
exports.AmdJsParser = void 0;
|
|
6354
|
+
const BaseParser_1 = _src_handlers_base_BaseParser;
|
|
6355
|
+
const AstUtil_1 = _src_handlers_script_utils_AstUtil;
|
|
6356
|
+
const atma_utils_1 = require("atma-utils");
|
|
6314
6357
|
const Include_1 = _src_class_Include;
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
6324
|
-
|
|
6358
|
+
class AmdJsParser extends BaseParser_1.BaseParser {
|
|
6359
|
+
getDependencies(ast, ownerResource) {
|
|
6360
|
+
let info = {
|
|
6361
|
+
dependencies: []
|
|
6362
|
+
};
|
|
6363
|
+
AstUtil_1.AstUtil.each(ast, AstUtil_1.AstUtil.is.amdFunction, (node, descend) => {
|
|
6364
|
+
let scope = node.scope || ast;
|
|
6365
|
+
let deps = this._process(node, scope);
|
|
6366
|
+
if (deps) {
|
|
6367
|
+
info.dependencies.push(...deps);
|
|
6368
|
+
}
|
|
6369
|
+
return true;
|
|
6370
|
+
});
|
|
6371
|
+
return new atma_utils_1.class_Dfr().resolve(info);
|
|
6325
6372
|
}
|
|
6326
|
-
|
|
6327
|
-
if (
|
|
6328
|
-
return
|
|
6373
|
+
_process(node, scope) {
|
|
6374
|
+
if (node.args.length < 2) {
|
|
6375
|
+
return;
|
|
6329
6376
|
}
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
.
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
resolvePath(includeData, parent) {
|
|
6345
|
-
return Include_1.Include
|
|
6346
|
-
.PathResolver
|
|
6347
|
-
.resolveBasic(includeData.url, includeData.type, parent);
|
|
6377
|
+
let args = AstUtil_1.AstUtil.getArguments(node.args, scope);
|
|
6378
|
+
let res = new Include_1.Include();
|
|
6379
|
+
let dependencies = args.find(x => Array.isArray(x));
|
|
6380
|
+
if (dependencies == null) {
|
|
6381
|
+
return;
|
|
6382
|
+
}
|
|
6383
|
+
let groups = Include_1.Include.groupByType(dependencies, this.solution.opts);
|
|
6384
|
+
for (let type in groups) {
|
|
6385
|
+
res[type].apply(res, groups[type]);
|
|
6386
|
+
}
|
|
6387
|
+
res.includes.forEach(x => x.module = 'amd');
|
|
6388
|
+
let ignore = ['exports', 'require'];
|
|
6389
|
+
res.includes = res.includes.filter(x => ignore.indexOf(x.url) === -1);
|
|
6390
|
+
return res.includes;
|
|
6348
6391
|
}
|
|
6349
6392
|
}
|
|
6350
|
-
exports.
|
|
6351
|
-
IncludeJsHandler.Parser = IncludeJsParser_1.IncludeJsParser;
|
|
6352
|
-
IncludeJsHandler.Rewriter = IncludeJsRewriter_1.IncludeJsRewriter;
|
|
6353
|
-
IncludeJsHandler.Builder = IncludeJsBuilder_1.IncludeJsBuilder;
|
|
6354
|
-
IncludeJsHandler.PathResolver = null;
|
|
6393
|
+
exports.AmdJsParser = AmdJsParser;
|
|
6355
6394
|
;
|
|
6356
|
-
//# sourceMappingURL=
|
|
6357
|
-
//# sourceMappingURL=
|
|
6395
|
+
//# sourceMappingURL=AmdJsParser.js.map
|
|
6396
|
+
//# sourceMappingURL=AmdJsParser.ts.map;
|
|
6358
6397
|
|
|
6359
6398
|
function __isObj(x) {
|
|
6360
6399
|
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
6361
6400
|
}
|
|
6362
|
-
if (
|
|
6401
|
+
if (_src_handlers_script_amd_js_AmdJsParser === module.exports) {
|
|
6363
6402
|
// do nothing if
|
|
6364
|
-
} else if (__isObj(
|
|
6365
|
-
Object.assign(
|
|
6403
|
+
} else if (__isObj(_src_handlers_script_amd_js_AmdJsParser) && __isObj(module.exports)) {
|
|
6404
|
+
Object.assign(_src_handlers_script_amd_js_AmdJsParser, module.exports);
|
|
6366
6405
|
} else {
|
|
6367
|
-
|
|
6406
|
+
_src_handlers_script_amd_js_AmdJsParser = module.exports;
|
|
6368
6407
|
}
|
|
6369
6408
|
|
|
6370
6409
|
;
|
|
@@ -6374,89 +6413,40 @@ IncludeJsHandler.PathResolver = null;
|
|
|
6374
6413
|
|
|
6375
6414
|
|
|
6376
6415
|
// source ./ModuleSimplified.js
|
|
6377
|
-
var
|
|
6416
|
+
var _src_handlers_script_amd_js_AmdJsRewriter;
|
|
6378
6417
|
(function () {
|
|
6379
6418
|
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
6380
6419
|
var define = null;
|
|
6381
|
-
var exports =
|
|
6420
|
+
var exports = _src_handlers_script_amd_js_AmdJsRewriter != null ? _src_handlers_script_amd_js_AmdJsRewriter : {};
|
|
6382
6421
|
var module = { exports: exports };
|
|
6383
6422
|
|
|
6384
6423
|
"use strict";
|
|
6385
6424
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6386
|
-
exports.
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
}
|
|
6391
|
-
exports.u_getNewLine = u_getNewLine;
|
|
6392
|
-
;
|
|
6393
|
-
function u_getIndent(str) {
|
|
6394
|
-
var match = /^[ \t]+/.exec(str);
|
|
6395
|
-
return match && match[0] || '';
|
|
6396
|
-
}
|
|
6397
|
-
exports.u_getIndent = u_getIndent;
|
|
6398
|
-
;
|
|
6399
|
-
function u_makeIndent(str, indent, io) {
|
|
6400
|
-
if (!indent || !str)
|
|
6401
|
-
return str;
|
|
6402
|
-
let newline = u_getNewLine(str, io);
|
|
6403
|
-
return str
|
|
6404
|
-
.split(newline)
|
|
6405
|
-
.map(line => indent + line)
|
|
6406
|
-
.join(newline);
|
|
6407
|
-
}
|
|
6408
|
-
exports.u_makeIndent = u_makeIndent;
|
|
6409
|
-
;
|
|
6410
|
-
function u_getFilesFromPath(path, io) {
|
|
6411
|
-
var file = new io.File(path);
|
|
6412
|
-
if (file.exists() === false) {
|
|
6413
|
-
console.error('File not found', file.uri.toLocalFile());
|
|
6414
|
-
return [];
|
|
6425
|
+
exports.AmdJsRewriter = void 0;
|
|
6426
|
+
const BaseRewriter_1 = _src_handlers_base_BaseRewriter;
|
|
6427
|
+
class AmdJsRewriter extends BaseRewriter_1.BaseRewriter {
|
|
6428
|
+
rewritePartial(content, ownerResource) {
|
|
6415
6429
|
}
|
|
6416
|
-
|
|
6417
|
-
}
|
|
6418
|
-
exports.u_getFilesFromPath = u_getFilesFromPath;
|
|
6419
|
-
;
|
|
6420
|
-
function u_readFile(io, file, indent, insertFileName) {
|
|
6421
|
-
var content = file.read().toString();
|
|
6422
|
-
var newline = u_getNewLine(content, io);
|
|
6423
|
-
if (indent) {
|
|
6424
|
-
content = content
|
|
6425
|
-
.split(newline)
|
|
6426
|
-
.map(line => indent + line)
|
|
6427
|
-
.join(newline);
|
|
6430
|
+
rewriteResource(resource) {
|
|
6428
6431
|
}
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
+ '// source '
|
|
6432
|
-
+ file.uri.file
|
|
6433
|
-
+ newline
|
|
6434
|
-
+ content;
|
|
6432
|
+
accepts(type) {
|
|
6433
|
+
return type === 'mask';
|
|
6435
6434
|
}
|
|
6436
|
-
return content;
|
|
6437
6435
|
}
|
|
6438
|
-
exports.
|
|
6436
|
+
exports.AmdJsRewriter = AmdJsRewriter;
|
|
6439
6437
|
;
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
.replace(/[\n\r]/g, '\\n')
|
|
6443
|
-
.replace(/"/g, '\\"');
|
|
6444
|
-
return `"${str}"`;
|
|
6445
|
-
}
|
|
6446
|
-
exports.u_asString = u_asString;
|
|
6447
|
-
;
|
|
6448
|
-
//# sourceMappingURL=utils.js.map
|
|
6449
|
-
//# sourceMappingURL=utils.ts.map;
|
|
6438
|
+
//# sourceMappingURL=AmdJsRewriter.js.map
|
|
6439
|
+
//# sourceMappingURL=AmdJsRewriter.ts.map;
|
|
6450
6440
|
|
|
6451
6441
|
function __isObj(x) {
|
|
6452
6442
|
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
6453
6443
|
}
|
|
6454
|
-
if (
|
|
6444
|
+
if (_src_handlers_script_amd_js_AmdJsRewriter === module.exports) {
|
|
6455
6445
|
// do nothing if
|
|
6456
|
-
} else if (__isObj(
|
|
6457
|
-
Object.assign(
|
|
6446
|
+
} else if (__isObj(_src_handlers_script_amd_js_AmdJsRewriter) && __isObj(module.exports)) {
|
|
6447
|
+
Object.assign(_src_handlers_script_amd_js_AmdJsRewriter, module.exports);
|
|
6458
6448
|
} else {
|
|
6459
|
-
|
|
6449
|
+
_src_handlers_script_amd_js_AmdJsRewriter = module.exports;
|
|
6460
6450
|
}
|
|
6461
6451
|
|
|
6462
6452
|
;
|
|
@@ -6466,107 +6456,48 @@ exports.u_asString = u_asString;
|
|
|
6466
6456
|
|
|
6467
6457
|
|
|
6468
6458
|
// source ./ModuleSimplified.js
|
|
6469
|
-
var
|
|
6459
|
+
var _src_handlers_script_amd_js_AmdJsBuilder;
|
|
6470
6460
|
(function () {
|
|
6471
6461
|
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
6472
6462
|
var define = null;
|
|
6473
|
-
var exports =
|
|
6463
|
+
var exports = _src_handlers_script_amd_js_AmdJsBuilder != null ? _src_handlers_script_amd_js_AmdJsBuilder : {};
|
|
6474
6464
|
var module = { exports: exports };
|
|
6475
6465
|
|
|
6476
6466
|
"use strict";
|
|
6477
6467
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6478
|
-
exports.
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
this.arr = [];
|
|
6483
|
-
}
|
|
6484
|
-
add(...arr) {
|
|
6485
|
-
for (let i = 0; i < arr.length; i++) {
|
|
6486
|
-
let x = arr[i];
|
|
6487
|
-
if (this.hash[x.id] != null) {
|
|
6488
|
-
continue;
|
|
6489
|
-
}
|
|
6490
|
-
this.hash[x.id] = x;
|
|
6491
|
-
this.arr.push(x);
|
|
6492
|
-
}
|
|
6493
|
-
}
|
|
6494
|
-
insert(x, i) {
|
|
6495
|
-
if (this.hash[x.id] != null) {
|
|
6496
|
-
this.remove(x);
|
|
6497
|
-
}
|
|
6498
|
-
this.hash[x.id] = x;
|
|
6499
|
-
this.arr.splice(i, 0, x);
|
|
6500
|
-
}
|
|
6501
|
-
has(x) {
|
|
6502
|
-
return this.hash[x.id] != null;
|
|
6503
|
-
}
|
|
6504
|
-
indexOf(x) {
|
|
6505
|
-
for (let i = 0; i < this.arr.length; i++) {
|
|
6506
|
-
if (this.arr[i].id === x.id) {
|
|
6507
|
-
return i;
|
|
6508
|
-
}
|
|
6509
|
-
}
|
|
6510
|
-
return -1;
|
|
6468
|
+
exports.AmdJsBuilder = void 0;
|
|
6469
|
+
const BaseScriptBuilder_1 = _src_handlers_script_base_BaseScriptBuilder;
|
|
6470
|
+
class AmdJsBuilder extends BaseScriptBuilder_1.BaseScriptBuilder {
|
|
6471
|
+
buildRoot(resource, dependencies) {
|
|
6511
6472
|
}
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
let i = this.arr.findIndex(module => module.id === x.id);
|
|
6515
|
-
this.arr.splice(i, 1);
|
|
6473
|
+
wrapModule(resource, outputItem) {
|
|
6474
|
+
return resource.content;
|
|
6516
6475
|
}
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
let i = -1, length = this.arr.length;
|
|
6521
|
-
while (++i < length) {
|
|
6522
|
-
let x = this.arr[i];
|
|
6523
|
-
if (handled.has(x)) {
|
|
6524
|
-
continue;
|
|
6525
|
-
}
|
|
6526
|
-
handled.add(x);
|
|
6527
|
-
if (fn(x)) {
|
|
6528
|
-
this.arr.splice(i, 1);
|
|
6529
|
-
delete this.hash[x.id];
|
|
6530
|
-
}
|
|
6531
|
-
break;
|
|
6532
|
-
}
|
|
6533
|
-
if (i === length) {
|
|
6534
|
-
break;
|
|
6535
|
-
}
|
|
6476
|
+
accepts(resource) {
|
|
6477
|
+
if (resource.type !== 'js') {
|
|
6478
|
+
return false;
|
|
6536
6479
|
}
|
|
6537
|
-
|
|
6538
|
-
|
|
6539
|
-
|
|
6540
|
-
while (true) {
|
|
6541
|
-
let i = -1, length = this.arr.length;
|
|
6542
|
-
while (++i < length) {
|
|
6543
|
-
let x = this.arr[i];
|
|
6544
|
-
if (handled.has(x)) {
|
|
6545
|
-
continue;
|
|
6546
|
-
}
|
|
6547
|
-
handled.add(x);
|
|
6548
|
-
fn(x, i);
|
|
6549
|
-
break;
|
|
6550
|
-
}
|
|
6551
|
-
if (i === length) {
|
|
6552
|
-
break;
|
|
6553
|
-
}
|
|
6480
|
+
let module = resource.getModule();
|
|
6481
|
+
if (module === 'root' && resource.solution.opts.package.module === 'amd') {
|
|
6482
|
+
module = 'amd';
|
|
6554
6483
|
}
|
|
6484
|
+
return module === 'amd';
|
|
6555
6485
|
}
|
|
6556
6486
|
}
|
|
6557
|
-
exports.
|
|
6558
|
-
|
|
6559
|
-
//# sourceMappingURL=
|
|
6487
|
+
exports.AmdJsBuilder = AmdJsBuilder;
|
|
6488
|
+
;
|
|
6489
|
+
//# sourceMappingURL=AmdJsBuilder.js.map
|
|
6490
|
+
//# sourceMappingURL=AmdJsBuilder.ts.map;
|
|
6560
6491
|
|
|
6561
6492
|
function __isObj(x) {
|
|
6562
6493
|
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
6563
6494
|
}
|
|
6564
|
-
if (
|
|
6495
|
+
if (_src_handlers_script_amd_js_AmdJsBuilder === module.exports) {
|
|
6565
6496
|
// do nothing if
|
|
6566
|
-
} else if (__isObj(
|
|
6567
|
-
Object.assign(
|
|
6497
|
+
} else if (__isObj(_src_handlers_script_amd_js_AmdJsBuilder) && __isObj(module.exports)) {
|
|
6498
|
+
Object.assign(_src_handlers_script_amd_js_AmdJsBuilder, module.exports);
|
|
6568
6499
|
} else {
|
|
6569
|
-
|
|
6500
|
+
_src_handlers_script_amd_js_AmdJsBuilder = module.exports;
|
|
6570
6501
|
}
|
|
6571
6502
|
|
|
6572
6503
|
;
|
|
@@ -6576,35 +6507,40 @@ exports.Dictionary = Dictionary;
|
|
|
6576
6507
|
|
|
6577
6508
|
|
|
6578
6509
|
// source ./ModuleSimplified.js
|
|
6579
|
-
var
|
|
6510
|
+
var _src_handlers_script_amd_js_AmdJsHandler;
|
|
6580
6511
|
(function () {
|
|
6581
6512
|
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
6582
6513
|
var define = null;
|
|
6583
|
-
var exports =
|
|
6514
|
+
var exports = _src_handlers_script_amd_js_AmdJsHandler != null ? _src_handlers_script_amd_js_AmdJsHandler : {};
|
|
6584
6515
|
var module = { exports: exports };
|
|
6585
6516
|
|
|
6586
6517
|
"use strict";
|
|
6587
6518
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6588
|
-
exports.
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6519
|
+
exports.AmdJsHandler = void 0;
|
|
6520
|
+
const AmdJsParser_1 = _src_handlers_script_amd_js_AmdJsParser;
|
|
6521
|
+
const AmdJsRewriter_1 = _src_handlers_script_amd_js_AmdJsRewriter;
|
|
6522
|
+
const AmdJsBuilder_1 = _src_handlers_script_amd_js_AmdJsBuilder;
|
|
6523
|
+
const BaseHandler_1 = _src_handlers_base_BaseHandler;
|
|
6524
|
+
class AmdJsHandler extends BaseHandler_1.BaseHandler {
|
|
6525
|
+
}
|
|
6526
|
+
exports.AmdJsHandler = AmdJsHandler;
|
|
6527
|
+
AmdJsHandler.Parser = AmdJsParser_1.AmdJsParser;
|
|
6528
|
+
AmdJsHandler.Rewriter = AmdJsRewriter_1.AmdJsRewriter;
|
|
6529
|
+
AmdJsHandler.Builder = AmdJsBuilder_1.AmdJsBuilder;
|
|
6530
|
+
AmdJsHandler.PathResolver = null;
|
|
6531
|
+
;
|
|
6532
|
+
//# sourceMappingURL=AmdJsHandler.js.map
|
|
6533
|
+
//# sourceMappingURL=AmdJsHandler.ts.map;
|
|
6598
6534
|
|
|
6599
6535
|
function __isObj(x) {
|
|
6600
6536
|
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
6601
6537
|
}
|
|
6602
|
-
if (
|
|
6538
|
+
if (_src_handlers_script_amd_js_AmdJsHandler === module.exports) {
|
|
6603
6539
|
// do nothing if
|
|
6604
|
-
} else if (__isObj(
|
|
6605
|
-
Object.assign(
|
|
6540
|
+
} else if (__isObj(_src_handlers_script_amd_js_AmdJsHandler) && __isObj(module.exports)) {
|
|
6541
|
+
Object.assign(_src_handlers_script_amd_js_AmdJsHandler, module.exports);
|
|
6606
6542
|
} else {
|
|
6607
|
-
|
|
6543
|
+
_src_handlers_script_amd_js_AmdJsHandler = module.exports;
|
|
6608
6544
|
}
|
|
6609
6545
|
|
|
6610
6546
|
;
|
|
@@ -6614,255 +6550,469 @@ var String;
|
|
|
6614
6550
|
|
|
6615
6551
|
|
|
6616
6552
|
// source ./ModuleSimplified.js
|
|
6617
|
-
var
|
|
6553
|
+
var _src_class_ResourcePropMapping;
|
|
6618
6554
|
(function () {
|
|
6619
6555
|
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
6620
6556
|
var define = null;
|
|
6621
|
-
var exports =
|
|
6557
|
+
var exports = _src_class_ResourcePropMapping != null ? _src_class_ResourcePropMapping : {};
|
|
6622
6558
|
var module = { exports: exports };
|
|
6623
6559
|
|
|
6624
6560
|
"use strict";
|
|
6625
6561
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6626
|
-
exports.
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
class IImporterOptions {
|
|
6632
|
-
constructor() {
|
|
6633
|
-
this.removeUnusedExports = true;
|
|
6634
|
-
this.wrapper = 'iif';
|
|
6635
|
-
this.lazy = null;
|
|
6636
|
-
}
|
|
6637
|
-
}
|
|
6638
|
-
exports.IImporterOptions = IImporterOptions;
|
|
6639
|
-
class ModuleFile {
|
|
6640
|
-
constructor(content, file) {
|
|
6641
|
-
this.content = content;
|
|
6642
|
-
this.file = file;
|
|
6643
|
-
this.outer = new Dictionary_1.Dictionary();
|
|
6644
|
-
this.scoped = new Dictionary_1.Dictionary();
|
|
6645
|
-
this.imports = [];
|
|
6646
|
-
this.exports = [];
|
|
6647
|
-
this.scopedVars = [];
|
|
6648
|
-
this.id = file.uri.toLocalFile();
|
|
6649
|
-
this.path = file.uri.toRelativeString(io.env.currentDir);
|
|
6562
|
+
exports.ResourcePropMapping = void 0;
|
|
6563
|
+
class ResourcePropMapping {
|
|
6564
|
+
constructor(resA, resB) {
|
|
6565
|
+
this.resA = resA;
|
|
6566
|
+
this.resB = resB;
|
|
6650
6567
|
}
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6658
|
-
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6568
|
+
map(resource) {
|
|
6569
|
+
let match = true;
|
|
6570
|
+
for (let key in this.resA) {
|
|
6571
|
+
let val = this.resA[key];
|
|
6572
|
+
if (val == null)
|
|
6573
|
+
continue;
|
|
6574
|
+
let currentVal = resource[key];
|
|
6575
|
+
if (typeof val === 'function') {
|
|
6576
|
+
match = val(currentVal);
|
|
6577
|
+
}
|
|
6578
|
+
if (val instanceof RegExp) {
|
|
6579
|
+
match = val.exec(currentVal) != null;
|
|
6580
|
+
}
|
|
6581
|
+
if (typeof val === 'string' || typeof val === 'number') {
|
|
6582
|
+
match = val === currentVal;
|
|
6583
|
+
}
|
|
6584
|
+
if (match == false) {
|
|
6585
|
+
return resource;
|
|
6663
6586
|
}
|
|
6664
|
-
return false;
|
|
6665
|
-
}
|
|
6666
|
-
if (this.id === x.id) {
|
|
6667
|
-
return true;
|
|
6668
6587
|
}
|
|
6669
|
-
|
|
6670
|
-
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
|
|
6674
|
-
|
|
6675
|
-
|
|
6588
|
+
let clone = resource.clone();
|
|
6589
|
+
for (let key in this.resB) {
|
|
6590
|
+
let val = this.resB[key];
|
|
6591
|
+
let currentVal = resource[key];
|
|
6592
|
+
if (typeof val === 'function') {
|
|
6593
|
+
clone[key] = val(currentVal, resource);
|
|
6594
|
+
continue;
|
|
6595
|
+
}
|
|
6596
|
+
if (typeof val === 'string' || typeof val === 'boolean') {
|
|
6597
|
+
clone[key] = val;
|
|
6598
|
+
continue;
|
|
6676
6599
|
}
|
|
6677
|
-
dict.add(module);
|
|
6678
|
-
module.outer.forEach(add);
|
|
6679
|
-
module.scoped.forEach(add);
|
|
6680
6600
|
}
|
|
6681
|
-
|
|
6682
|
-
return dict.arr;
|
|
6601
|
+
return clone;
|
|
6683
6602
|
}
|
|
6684
|
-
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
|
|
6688
|
-
|
|
6689
|
-
|
|
6690
|
-
|
|
6691
|
-
|
|
6692
|
-
|
|
6693
|
-
//
|
|
6694
|
-
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
}
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
|
|
6703
|
-
|
|
6704
|
-
|
|
6705
|
-
|
|
6706
|
-
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6603
|
+
}
|
|
6604
|
+
exports.ResourcePropMapping = ResourcePropMapping;
|
|
6605
|
+
//# sourceMappingURL=ResourcePropMapping.js.map
|
|
6606
|
+
//# sourceMappingURL=ResourcePropMapping.ts.map;
|
|
6607
|
+
|
|
6608
|
+
function __isObj(x) {
|
|
6609
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
6610
|
+
}
|
|
6611
|
+
if (_src_class_ResourcePropMapping === module.exports) {
|
|
6612
|
+
// do nothing if
|
|
6613
|
+
} else if (__isObj(_src_class_ResourcePropMapping) && __isObj(module.exports)) {
|
|
6614
|
+
Object.assign(_src_class_ResourcePropMapping, module.exports);
|
|
6615
|
+
} else {
|
|
6616
|
+
_src_class_ResourcePropMapping = module.exports;
|
|
6617
|
+
}
|
|
6618
|
+
|
|
6619
|
+
;
|
|
6620
|
+
}());
|
|
6621
|
+
|
|
6622
|
+
// end:source ./ModuleSimplified.js
|
|
6623
|
+
|
|
6624
|
+
|
|
6625
|
+
// source ./ModuleSimplified.js
|
|
6626
|
+
var _src_handlers_script_include_js_IncludeJsParser;
|
|
6627
|
+
(function () {
|
|
6628
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
6629
|
+
var define = null;
|
|
6630
|
+
var exports = _src_handlers_script_include_js_IncludeJsParser != null ? _src_handlers_script_include_js_IncludeJsParser : {};
|
|
6631
|
+
var module = { exports: exports };
|
|
6632
|
+
|
|
6633
|
+
"use strict";
|
|
6634
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6635
|
+
exports.IncludeJsParser = void 0;
|
|
6636
|
+
const AstUtil_1 = _src_handlers_script_utils_AstUtil;
|
|
6637
|
+
const Include_1 = _src_class_Include;
|
|
6638
|
+
const ResourcePropMapping_1 = _src_class_ResourcePropMapping;
|
|
6639
|
+
const BaseParser_1 = _src_handlers_base_BaseParser;
|
|
6640
|
+
const atma_utils_1 = require("atma-utils");
|
|
6641
|
+
class IncludeJsParser extends BaseParser_1.BaseParser {
|
|
6642
|
+
constructor(solution, handler) {
|
|
6643
|
+
super(solution, handler);
|
|
6644
|
+
if (this.solution.opts.package.module === 'includejs') {
|
|
6645
|
+
this.solution.opts.mappers.push(...IncludeJsMappings);
|
|
6722
6646
|
}
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
|
|
6727
|
-
|
|
6728
|
-
|
|
6729
|
-
|
|
6730
|
-
|
|
6647
|
+
}
|
|
6648
|
+
getDependencies(ast, ownerResource) {
|
|
6649
|
+
let info = {
|
|
6650
|
+
type: null,
|
|
6651
|
+
url: null,
|
|
6652
|
+
dependencies: [],
|
|
6653
|
+
meta: {
|
|
6654
|
+
includejs: {
|
|
6655
|
+
hasIncludes: false,
|
|
6656
|
+
hasExports: false,
|
|
6657
|
+
hasResponseObject: false,
|
|
6658
|
+
responseAccessors: null,
|
|
6659
|
+
}
|
|
6731
6660
|
}
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
|
|
6661
|
+
};
|
|
6662
|
+
AstUtil_1.AstUtil.each(ast, AstUtil_1.AstUtil.is.includeFunction, (node, descend) => {
|
|
6663
|
+
function isIncludeSymbolRef(node) {
|
|
6664
|
+
return AstUtil_1.AstUtil.is.type(node, 'AST_SymbolRef') && node.name == 'include';
|
|
6665
|
+
}
|
|
6666
|
+
let scope = AstUtil_1.AstUtil.findNode(node, isIncludeSymbolRef).scope || ast;
|
|
6667
|
+
this._process(info, node, scope);
|
|
6668
|
+
return true;
|
|
6669
|
+
});
|
|
6670
|
+
if (this._getPropertySetter('exports', ast) != null) {
|
|
6671
|
+
info.meta.includejs.hasExports = true;
|
|
6672
|
+
}
|
|
6673
|
+
return new atma_utils_1.class_Dfr().resolve(info);
|
|
6674
|
+
}
|
|
6675
|
+
_process(info, node, scope) {
|
|
6676
|
+
let arr = [];
|
|
6677
|
+
function isIncludeMethodCall(node) {
|
|
6678
|
+
return AstUtil_1.AstUtil.is.type(node, 'AST_Call') && node.start.value == 'include';
|
|
6679
|
+
}
|
|
6680
|
+
;
|
|
6681
|
+
AstUtil_1.AstUtil.each(node, isIncludeMethodCall, (node) => {
|
|
6682
|
+
switch (node.expression && node.expression.property) {
|
|
6683
|
+
case 'js':
|
|
6684
|
+
case 'css':
|
|
6685
|
+
case 'load':
|
|
6686
|
+
case 'lazy':
|
|
6687
|
+
case 'mask':
|
|
6688
|
+
case 'routes':
|
|
6689
|
+
case 'setBase':
|
|
6690
|
+
case 'cfg':
|
|
6691
|
+
let pckg = {
|
|
6692
|
+
type: node.expression.property,
|
|
6693
|
+
args: AstUtil_1.AstUtil.getArguments(node.args, scope),
|
|
6694
|
+
};
|
|
6695
|
+
if (pckg.args.length > 0) {
|
|
6696
|
+
arr.unshift(pckg);
|
|
6697
|
+
}
|
|
6698
|
+
info.meta.includejs.hasIncludes = true;
|
|
6735
6699
|
break;
|
|
6736
|
-
case '
|
|
6737
|
-
|
|
6700
|
+
case 'done':
|
|
6701
|
+
case 'ready':
|
|
6702
|
+
this._processIncludeCallback(info, node.args && node.args[0]);
|
|
6738
6703
|
break;
|
|
6739
|
-
case '
|
|
6740
|
-
|
|
6704
|
+
case 'instance':
|
|
6705
|
+
case 'embed':
|
|
6706
|
+
case 'plugin':
|
|
6707
|
+
case 'ajax':
|
|
6708
|
+
case 'promise':
|
|
6709
|
+
case 'client':
|
|
6710
|
+
case 'server':
|
|
6711
|
+
case 'use':
|
|
6712
|
+
case 'getPending':
|
|
6713
|
+
case 'getResource':
|
|
6714
|
+
case 'getResourceById':
|
|
6715
|
+
case 'getResources':
|
|
6716
|
+
case 'apply':
|
|
6741
6717
|
break;
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
content = String_1.String.replace(content, x.position, x.length, '');
|
|
6745
|
-
}
|
|
6718
|
+
default:
|
|
6719
|
+
this.solution.reporter.warn('getIncludes: Unknown function call', node.expression);
|
|
6746
6720
|
break;
|
|
6747
6721
|
}
|
|
6748
6722
|
});
|
|
6749
|
-
|
|
6750
|
-
|
|
6751
|
-
|
|
6723
|
+
let include = new Include_1.Include();
|
|
6724
|
+
arr.forEach(function (x) {
|
|
6725
|
+
include[x.type].apply(include, x.args);
|
|
6752
6726
|
});
|
|
6753
|
-
|
|
6754
|
-
|
|
6755
|
-
|
|
6756
|
-
|
|
6757
|
-
|
|
6758
|
-
|
|
6759
|
-
|
|
6760
|
-
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6727
|
+
info.dependencies.push(...include.includes);
|
|
6728
|
+
}
|
|
6729
|
+
_processIncludeCallback(info, CallbackNode) {
|
|
6730
|
+
if (AstUtil_1.AstUtil.is.type(CallbackNode, 'AST_Function') == false) {
|
|
6731
|
+
return;
|
|
6732
|
+
}
|
|
6733
|
+
let meta = info.meta.includejs, args = CallbackNode.argnames, responseObjectName = args.length > 0
|
|
6734
|
+
? args[args.length - 1].name
|
|
6735
|
+
: null;
|
|
6736
|
+
if (responseObjectName) {
|
|
6737
|
+
meta.hasResponseObject = true;
|
|
6738
|
+
let names = this._getPropertyAccessors(responseObjectName, CallbackNode);
|
|
6739
|
+
if (names) {
|
|
6740
|
+
meta.responseAccessors = (meta.responseAccessors || []).concat(names);
|
|
6741
|
+
}
|
|
6742
|
+
}
|
|
6743
|
+
}
|
|
6744
|
+
/**
|
|
6745
|
+
* resolve %name%.propertyAccessor
|
|
6746
|
+
*/
|
|
6747
|
+
_getPropertyAccessors(name, Fn) {
|
|
6748
|
+
let references = [];
|
|
6749
|
+
Fn.body.forEach(function (x) {
|
|
6750
|
+
function isSymbolName(node) {
|
|
6751
|
+
return AstUtil_1.AstUtil.is.type(node, 'AST_SymbolRef') && node.name === name;
|
|
6752
|
+
}
|
|
6753
|
+
AstUtil_1.AstUtil.each(x, isSymbolName, function (node) {
|
|
6754
|
+
let chain = AstUtil_1.AstUtil.getPropertyChain(node, this.stack);
|
|
6755
|
+
if (chain) {
|
|
6756
|
+
references.push(chain);
|
|
6766
6757
|
}
|
|
6767
|
-
return x;
|
|
6768
6758
|
});
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6776
|
-
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
console.warn(`Module ${this.id} has unused export ${x.ref}`);
|
|
6781
|
-
return false;
|
|
6782
|
-
}
|
|
6783
|
-
return true;
|
|
6784
|
-
})
|
|
6785
|
-
.filter(x => {
|
|
6786
|
-
let exportInOuter = parents
|
|
6787
|
-
.some(p => {
|
|
6788
|
-
let parentsExport = p.exports.find(e => e.hasExport(x.ref));
|
|
6789
|
-
if (parentsExport == null) {
|
|
6790
|
-
return false;
|
|
6791
|
-
}
|
|
6792
|
-
if (options.removeUnusedExports && parentsExport.dependents.length === 0) {
|
|
6793
|
-
return false;
|
|
6794
|
-
}
|
|
6795
|
-
return true;
|
|
6796
|
-
});
|
|
6797
|
-
return exportInOuter === false;
|
|
6798
|
-
})
|
|
6799
|
-
.map(x => ` ${x.ref}`)
|
|
6800
|
-
.join(`,${newLine}`);
|
|
6801
|
-
if (externalRefs.length > 0) {
|
|
6802
|
-
externalRefs = String_1.String.replace(externalRefs, 0, 3, 'var');
|
|
6803
|
-
externalRefs += ';';
|
|
6759
|
+
});
|
|
6760
|
+
return references;
|
|
6761
|
+
}
|
|
6762
|
+
/**
|
|
6763
|
+
* aim to find all **.exports = X
|
|
6764
|
+
*/
|
|
6765
|
+
_getPropertySetter(name, Fn) {
|
|
6766
|
+
let result = null;
|
|
6767
|
+
Fn.body.forEach(function (x) {
|
|
6768
|
+
function isPropertyName(node) {
|
|
6769
|
+
AstUtil_1.AstUtil.is.type(node, 'AST_Assign') && node.left.property === name;
|
|
6804
6770
|
}
|
|
6771
|
+
AstUtil_1.AstUtil.each(x, isPropertyName, function (node) {
|
|
6772
|
+
let arr = ['include', 'module', 'exports'];
|
|
6773
|
+
if (arr.indexOf(node.start.value) > -1) {
|
|
6774
|
+
result = node;
|
|
6775
|
+
}
|
|
6776
|
+
});
|
|
6777
|
+
});
|
|
6778
|
+
return result;
|
|
6779
|
+
}
|
|
6780
|
+
}
|
|
6781
|
+
exports.IncludeJsParser = IncludeJsParser;
|
|
6782
|
+
;
|
|
6783
|
+
let IncludeJsMappings = [
|
|
6784
|
+
new ResourcePropMapping_1.ResourcePropMapping({
|
|
6785
|
+
asModules: (arr) => arr.indexOf('mask') > -1
|
|
6786
|
+
}, {
|
|
6787
|
+
asModules: (arr) => {
|
|
6788
|
+
let i = arr.indexOf('mask');
|
|
6789
|
+
arr[i] = 'includejs';
|
|
6790
|
+
return arr;
|
|
6805
6791
|
}
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6792
|
+
}),
|
|
6793
|
+
new ResourcePropMapping_1.ResourcePropMapping({
|
|
6794
|
+
asModules: (arr) => arr.indexOf('amd') > -1
|
|
6795
|
+
}, {
|
|
6796
|
+
asModules: (arr) => {
|
|
6797
|
+
let i = arr.indexOf('amd');
|
|
6798
|
+
arr[i] = 'includejs';
|
|
6799
|
+
return arr;
|
|
6800
|
+
}
|
|
6801
|
+
}),
|
|
6802
|
+
new ResourcePropMapping_1.ResourcePropMapping({
|
|
6803
|
+
type: 'mask'
|
|
6804
|
+
}, {
|
|
6805
|
+
type: 'load'
|
|
6806
|
+
})
|
|
6807
|
+
];
|
|
6808
|
+
//# sourceMappingURL=IncludeJsParser.js.map
|
|
6809
|
+
//# sourceMappingURL=IncludeJsParser.ts.map;
|
|
6810
|
+
|
|
6811
|
+
function __isObj(x) {
|
|
6812
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
6813
|
+
}
|
|
6814
|
+
if (_src_handlers_script_include_js_IncludeJsParser === module.exports) {
|
|
6815
|
+
// do nothing if
|
|
6816
|
+
} else if (__isObj(_src_handlers_script_include_js_IncludeJsParser) && __isObj(module.exports)) {
|
|
6817
|
+
Object.assign(_src_handlers_script_include_js_IncludeJsParser, module.exports);
|
|
6818
|
+
} else {
|
|
6819
|
+
_src_handlers_script_include_js_IncludeJsParser = module.exports;
|
|
6820
|
+
}
|
|
6821
|
+
|
|
6822
|
+
;
|
|
6823
|
+
}());
|
|
6824
|
+
|
|
6825
|
+
// end:source ./ModuleSimplified.js
|
|
6826
|
+
|
|
6827
|
+
|
|
6828
|
+
// source ./ModuleSimplified.js
|
|
6829
|
+
var _src_handlers_script_include_js_IncludeJsBuilder;
|
|
6830
|
+
(function () {
|
|
6831
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
6832
|
+
var define = null;
|
|
6833
|
+
var exports = _src_handlers_script_include_js_IncludeJsBuilder != null ? _src_handlers_script_include_js_IncludeJsBuilder : {};
|
|
6834
|
+
var module = { exports: exports };
|
|
6835
|
+
|
|
6836
|
+
"use strict";
|
|
6837
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6838
|
+
exports.IncludeJsBuilder = void 0;
|
|
6839
|
+
const arr_1 = _src_utils_arr;
|
|
6840
|
+
const Include_1 = _src_class_Include;
|
|
6841
|
+
const res_1 = _src_utils_res;
|
|
6842
|
+
const BaseScriptBuilder_1 = _src_handlers_script_base_BaseScriptBuilder;
|
|
6843
|
+
class IncludeJsBuilder extends BaseScriptBuilder_1.BaseScriptBuilder {
|
|
6844
|
+
wrapScriptlessModule(otherOutputItems) {
|
|
6845
|
+
var allResources = (0, arr_1.arr_flattern)(otherOutputItems.map(x => x.resources));
|
|
6846
|
+
var jsResources = allResources.filter(x => this.accepts(x));
|
|
6847
|
+
var cssResources = allResources.filter(x => x.type === 'css');
|
|
6848
|
+
var loadResources = allResources.filter(x => x.type === 'load');
|
|
6849
|
+
var jsRegister = this._serializeRegister(jsResources, 'js');
|
|
6850
|
+
var cssRegister = this._serializeRegister(cssResources, 'css');
|
|
6851
|
+
var loadRegister = this._serializeRegister(loadResources, 'load');
|
|
6852
|
+
return `
|
|
6853
|
+
${jsRegister}
|
|
6854
|
+
${cssRegister}
|
|
6855
|
+
${loadRegister}
|
|
6856
|
+
`;
|
|
6821
6857
|
}
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6858
|
+
isMainBuilder(solution) {
|
|
6859
|
+
const KEY = 'includejs';
|
|
6860
|
+
const packageInfo = solution.opts.package;
|
|
6861
|
+
return packageInfo.module === KEY || packageInfo.moduleName === KEY;
|
|
6862
|
+
}
|
|
6863
|
+
wrapModule(resource, outputItem, otherOutputItems) {
|
|
6864
|
+
var opts = this.solution.opts;
|
|
6865
|
+
var page = (0, res_1.res_getPage)(resource, opts);
|
|
6866
|
+
var iteration = this.solution.iteration;
|
|
6867
|
+
if (iteration.includejs == null) {
|
|
6868
|
+
iteration.includejs = {};
|
|
6869
|
+
}
|
|
6870
|
+
if (iteration.includejs[page] == null) {
|
|
6871
|
+
iteration.includejs[page] = {
|
|
6872
|
+
addHeading: true,
|
|
6873
|
+
hasHeading: false,
|
|
6874
|
+
lastItem: null
|
|
6827
6875
|
};
|
|
6828
|
-
if (module.imports) {
|
|
6829
|
-
json.imports = module.imports.map(x => toJSON(x.module));
|
|
6830
|
-
}
|
|
6831
|
-
return json;
|
|
6832
6876
|
}
|
|
6833
|
-
|
|
6877
|
+
var builderOpts = iteration.includejs[page];
|
|
6878
|
+
var body = '';
|
|
6879
|
+
if (builderOpts.hasHeading === false && builderOpts.addHeading === true) {
|
|
6880
|
+
builderOpts.hasHeading = true;
|
|
6881
|
+
body = this._createHeading(builderOpts, resource, outputItem, otherOutputItems);
|
|
6882
|
+
}
|
|
6883
|
+
let content = resource.content;
|
|
6884
|
+
let url = resource.toTargetUrl(this.solution);
|
|
6885
|
+
let aliases = resource.aliases == null ? 'null' : '[' + resource.aliases.map(x => `'${x}'`).join(',') + ']';
|
|
6886
|
+
body += `include.setCurrent({ url: '${url}', aliases: ${aliases} });\n`;
|
|
6887
|
+
body += content;
|
|
6888
|
+
body += `\ninclude.getResourceById('${url}', 'js').readystatechanged(3);`;
|
|
6889
|
+
if (builderOpts.hasHeading && builderOpts.lastItem === resource) {
|
|
6890
|
+
body += `\ninclude.resumeStack();`;
|
|
6891
|
+
}
|
|
6892
|
+
return body;
|
|
6834
6893
|
}
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6894
|
+
accepts(resource) {
|
|
6895
|
+
if (resource.type !== 'js') {
|
|
6896
|
+
return false;
|
|
6897
|
+
}
|
|
6898
|
+
const module = resource.getModule();
|
|
6899
|
+
return module === 'includejs';
|
|
6900
|
+
}
|
|
6901
|
+
_createHeading(builderOpts, resource, outputItem, otherOutputItems) {
|
|
6902
|
+
var outputItems = [outputItem, ...otherOutputItems];
|
|
6903
|
+
var allResources = (0, arr_1.arr_flattern)(outputItems.map(x => x.resources));
|
|
6904
|
+
var jsResources = allResources.filter(x => this.accepts(x));
|
|
6905
|
+
var cssResources = allResources.filter(x => x.type === 'css');
|
|
6906
|
+
var loadResources = allResources.filter(x => x.type === 'load');
|
|
6907
|
+
builderOpts.lastItem = jsResources[jsResources.length - 1];
|
|
6908
|
+
var jsRegister = this._serializeRegister(jsResources, 'js');
|
|
6909
|
+
var cssRegister = this._serializeRegister(cssResources, 'css');
|
|
6910
|
+
var loadRegister = this._serializeRegister(loadResources, 'load');
|
|
6911
|
+
var version = this._serializeVersion();
|
|
6912
|
+
var config = this._serializeConfig();
|
|
6913
|
+
var heading = `
|
|
6914
|
+
${version}
|
|
6915
|
+
${config}
|
|
6916
|
+
include.pauseStack();
|
|
6917
|
+
${jsRegister}
|
|
6918
|
+
${cssRegister}
|
|
6919
|
+
${loadRegister}
|
|
6920
|
+
`;
|
|
6921
|
+
return heading;
|
|
6922
|
+
}
|
|
6923
|
+
_serializeVersion() {
|
|
6924
|
+
var v = this.solution.opts.version;
|
|
6925
|
+
if (!v)
|
|
6926
|
+
return '';
|
|
6927
|
+
return `include.cfg('version', '${v}');`;
|
|
6928
|
+
}
|
|
6929
|
+
_serializeConfig() {
|
|
6930
|
+
var opts = Include_1.Include.getConfig();
|
|
6931
|
+
var json = JSON.stringify(opts);
|
|
6932
|
+
if (json === '{}')
|
|
6933
|
+
return '';
|
|
6934
|
+
return `include.cfg(${json});`;
|
|
6935
|
+
}
|
|
6936
|
+
_serializeRegister(resources, type) {
|
|
6937
|
+
var paths = resources
|
|
6938
|
+
.filter(x => x.type === type)
|
|
6939
|
+
.map(x => {
|
|
6940
|
+
return {
|
|
6941
|
+
type: type,
|
|
6942
|
+
url: x.toTargetUrl(this.solution)
|
|
6841
6943
|
};
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6944
|
+
});
|
|
6945
|
+
if (paths.length === 0) {
|
|
6946
|
+
return '';
|
|
6947
|
+
}
|
|
6948
|
+
var json = JSON.stringify({
|
|
6949
|
+
[type]: paths
|
|
6950
|
+
});
|
|
6951
|
+
return `
|
|
6952
|
+
include.register(${json});
|
|
6953
|
+
`;
|
|
6954
|
+
}
|
|
6955
|
+
}
|
|
6956
|
+
exports.IncludeJsBuilder = IncludeJsBuilder;
|
|
6957
|
+
;
|
|
6958
|
+
//# sourceMappingURL=IncludeJsBuilder.js.map
|
|
6959
|
+
//# sourceMappingURL=IncludeJsBuilder.ts.map;
|
|
6960
|
+
|
|
6961
|
+
function __isObj(x) {
|
|
6962
|
+
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
6963
|
+
}
|
|
6964
|
+
if (_src_handlers_script_include_js_IncludeJsBuilder === module.exports) {
|
|
6965
|
+
// do nothing if
|
|
6966
|
+
} else if (__isObj(_src_handlers_script_include_js_IncludeJsBuilder) && __isObj(module.exports)) {
|
|
6967
|
+
Object.assign(_src_handlers_script_include_js_IncludeJsBuilder, module.exports);
|
|
6968
|
+
} else {
|
|
6969
|
+
_src_handlers_script_include_js_IncludeJsBuilder = module.exports;
|
|
6970
|
+
}
|
|
6971
|
+
|
|
6972
|
+
;
|
|
6973
|
+
}());
|
|
6974
|
+
|
|
6975
|
+
// end:source ./ModuleSimplified.js
|
|
6976
|
+
|
|
6977
|
+
|
|
6978
|
+
// source ./ModuleSimplified.js
|
|
6979
|
+
var _src_handlers_script_include_js_IncludeJsRewriter;
|
|
6980
|
+
(function () {
|
|
6981
|
+
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
6982
|
+
var define = null;
|
|
6983
|
+
var exports = _src_handlers_script_include_js_IncludeJsRewriter != null ? _src_handlers_script_include_js_IncludeJsRewriter : {};
|
|
6984
|
+
var module = { exports: exports };
|
|
6985
|
+
|
|
6986
|
+
"use strict";
|
|
6987
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6988
|
+
exports.IncludeJsRewriter = void 0;
|
|
6989
|
+
const BaseRewriter_1 = _src_handlers_base_BaseRewriter;
|
|
6990
|
+
class IncludeJsRewriter extends BaseRewriter_1.BaseRewriter {
|
|
6991
|
+
rewritePartial(content, ownerResource) {
|
|
6992
|
+
}
|
|
6993
|
+
rewriteResource(resource) {
|
|
6994
|
+
if (resource.getModule() === 'global' && resource && resource.meta && resource.meta.includejs && resource.meta.includejs.hasIncludes) {
|
|
6995
|
+
resource.asModules = ['includejs'];
|
|
6849
6996
|
}
|
|
6850
|
-
|
|
6997
|
+
}
|
|
6998
|
+
accepts(type) {
|
|
6999
|
+
return type === 'js';
|
|
6851
7000
|
}
|
|
6852
7001
|
}
|
|
6853
|
-
exports.
|
|
6854
|
-
|
|
6855
|
-
//# sourceMappingURL=
|
|
7002
|
+
exports.IncludeJsRewriter = IncludeJsRewriter;
|
|
7003
|
+
;
|
|
7004
|
+
//# sourceMappingURL=IncludeJsRewriter.js.map
|
|
7005
|
+
//# sourceMappingURL=IncludeJsRewriter.ts.map;
|
|
6856
7006
|
|
|
6857
7007
|
function __isObj(x) {
|
|
6858
7008
|
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
6859
7009
|
}
|
|
6860
|
-
if (
|
|
7010
|
+
if (_src_handlers_script_include_js_IncludeJsRewriter === module.exports) {
|
|
6861
7011
|
// do nothing if
|
|
6862
|
-
} else if (__isObj(
|
|
6863
|
-
Object.assign(
|
|
7012
|
+
} else if (__isObj(_src_handlers_script_include_js_IncludeJsRewriter) && __isObj(module.exports)) {
|
|
7013
|
+
Object.assign(_src_handlers_script_include_js_IncludeJsRewriter, module.exports);
|
|
6864
7014
|
} else {
|
|
6865
|
-
|
|
7015
|
+
_src_handlers_script_include_js_IncludeJsRewriter = module.exports;
|
|
6866
7016
|
}
|
|
6867
7017
|
|
|
6868
7018
|
;
|
|
@@ -6872,208 +7022,71 @@ exports.ModuleFile = ModuleFile;
|
|
|
6872
7022
|
|
|
6873
7023
|
|
|
6874
7024
|
// source ./ModuleSimplified.js
|
|
6875
|
-
var
|
|
7025
|
+
var _src_handlers_script_include_js_IncludeJsHandler;
|
|
6876
7026
|
(function () {
|
|
6877
7027
|
// ensure AMD is not active for the model, so that any UMD exports as commonjs
|
|
6878
7028
|
var define = null;
|
|
6879
|
-
var exports =
|
|
7029
|
+
var exports = _src_handlers_script_include_js_IncludeJsHandler != null ? _src_handlers_script_include_js_IncludeJsHandler : {};
|
|
6880
7030
|
var module = { exports: exports };
|
|
6881
7031
|
|
|
6882
7032
|
"use strict";
|
|
6883
7033
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6884
|
-
exports.
|
|
6885
|
-
const
|
|
6886
|
-
const
|
|
6887
|
-
|
|
6888
|
-
|
|
6889
|
-
|
|
6890
|
-
|
|
6891
|
-
|
|
6892
|
-
|
|
6893
|
-
|
|
6894
|
-
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
return $import;
|
|
6898
|
-
}
|
|
6899
|
-
},
|
|
6900
|
-
refs: {
|
|
6901
|
-
rgx: /^[ \t]*import\s*\{([^}]+)}\s*from\s*['"]([^'"]+)['"][\t ;]*[\r\n]{0,2}/gm,
|
|
6902
|
-
map(match) {
|
|
6903
|
-
let $import = new ResourceInfo_1.ImportNode();
|
|
6904
|
-
$import.position = match.index;
|
|
6905
|
-
$import.length = match[0].length;
|
|
6906
|
-
$import.type = 'refs';
|
|
6907
|
-
$import.path = match[2];
|
|
6908
|
-
$import.refs = match[1].split(',').map(x => x.trim());
|
|
6909
|
-
return $import;
|
|
6910
|
-
}
|
|
6911
|
-
},
|
|
6912
|
-
defaults: {
|
|
6913
|
-
rgx: /^[ \t]*import\s+(?<def>\w+)\s+from\s*['"](?<path>[^'"]+)['"][\t ;]*[\r\n]{0,2}/gm,
|
|
6914
|
-
map(match) {
|
|
6915
|
-
let $import = new ResourceInfo_1.ImportNode();
|
|
6916
|
-
$import.position = match.index;
|
|
6917
|
-
$import.length = match[0].length;
|
|
6918
|
-
$import.type = 'full';
|
|
6919
|
-
$import.path = match.groups.path;
|
|
6920
|
-
return $import;
|
|
6921
|
-
}
|
|
6922
|
-
},
|
|
6923
|
-
exportAll: {
|
|
6924
|
-
rgx: /^[ \t]*export\s+\*\s+from\s*['"]([^'"]+)['"][\t ;]*[\r\n]{0,2}/gm,
|
|
6925
|
-
map(match) {
|
|
6926
|
-
let $import = new ResourceInfo_1.ImportNode();
|
|
6927
|
-
$import.position = match.index;
|
|
6928
|
-
$import.length = match[0].length;
|
|
6929
|
-
$import.type = 'exportAll';
|
|
6930
|
-
$import.path = match[1];
|
|
6931
|
-
$import.exportAll = true;
|
|
6932
|
-
return $import;
|
|
6933
|
-
}
|
|
6934
|
-
},
|
|
6935
|
-
exportRefs: {
|
|
6936
|
-
rgx: /^[ \t]*export\s*\{([^}]+)}\s*from\s*['"]([^'"]+)['"][\t ;]*[\r\n]{0,2}/gm,
|
|
6937
|
-
map(match) {
|
|
6938
|
-
let $import = new ResourceInfo_1.ImportNode();
|
|
6939
|
-
$import.position = match.index;
|
|
6940
|
-
$import.length = match[0].length;
|
|
6941
|
-
$import.type = 'exportRefs';
|
|
6942
|
-
$import.path = match[2];
|
|
6943
|
-
$import.refs = match[1].split(',').map(x => x.trim());
|
|
6944
|
-
$import.exportRefs = true;
|
|
6945
|
-
return $import;
|
|
6946
|
-
}
|
|
6947
|
-
}
|
|
6948
|
-
},
|
|
6949
|
-
Exports: {
|
|
6950
|
-
ref: {
|
|
6951
|
-
rgx: /^[ \t]*export\s*(const|let|var)\s+([\w\d_$]+)(?=\s*[^\w\d_$;])/gm,
|
|
6952
|
-
map(match) {
|
|
6953
|
-
let $export = new ResourceInfo_1.ExportNode();
|
|
6954
|
-
$export.position = match.index;
|
|
6955
|
-
$export.length = match[0].length;
|
|
6956
|
-
$export.type = 'ref';
|
|
6957
|
-
$export.ref = match[2];
|
|
6958
|
-
return $export;
|
|
6959
|
-
}
|
|
6960
|
-
},
|
|
6961
|
-
named: {
|
|
6962
|
-
rgx: /^[ \t]*export\s*(const|let|var)\s+([\w\d_$]+)(?=\s*[;])/gm,
|
|
6963
|
-
map(match) {
|
|
6964
|
-
let $export = new ResourceInfo_1.ExportNode();
|
|
6965
|
-
$export.position = match.index;
|
|
6966
|
-
$export.length = match[0].length;
|
|
6967
|
-
$export.type = 'named';
|
|
6968
|
-
$export.ref = match[2];
|
|
6969
|
-
return $export;
|
|
6970
|
-
}
|
|
6971
|
-
},
|
|
6972
|
-
scoped: {
|
|
6973
|
-
rgx: /^[ \t]*export\s*\{([^}]+)}\s*;?(?!\s*from)/gm,
|
|
6974
|
-
map(match) {
|
|
6975
|
-
let refs = match[1].split(',').map(x => x.trim());
|
|
6976
|
-
let $export = new ResourceInfo_1.ExportNode();
|
|
6977
|
-
$export.position = match.index;
|
|
6978
|
-
$export.length = match[0].length;
|
|
6979
|
-
$export.type = 'scoped';
|
|
6980
|
-
$export.ref = refs[0];
|
|
6981
|
-
let other = refs.slice(1).map(ref => {
|
|
6982
|
-
let $export = new ResourceInfo_1.ExportNode();
|
|
6983
|
-
$export.position = match.index;
|
|
6984
|
-
$export.length = 0;
|
|
6985
|
-
$export.type = 'scoped';
|
|
6986
|
-
$export.ref = ref;
|
|
6987
|
-
return $export;
|
|
6988
|
-
});
|
|
6989
|
-
return [$export, ...other];
|
|
6990
|
-
}
|
|
6991
|
-
},
|
|
6992
|
-
function: {
|
|
6993
|
-
rgx: /^[ \t]*export\s*function\s+([\w\d_$]+)/gm,
|
|
6994
|
-
map(match) {
|
|
6995
|
-
let $export = new ResourceInfo_1.ExportNode();
|
|
6996
|
-
$export.position = match.index;
|
|
6997
|
-
$export.length = match[0].length;
|
|
6998
|
-
$export.type = 'function';
|
|
6999
|
-
$export.ref = match[1];
|
|
7000
|
-
return $export;
|
|
7001
|
-
}
|
|
7002
|
-
}
|
|
7034
|
+
exports.IncludeJsHandler = void 0;
|
|
7035
|
+
const Templates_1 = _src_handlers_script_common_js_templates_Templates;
|
|
7036
|
+
const Include_1 = _src_class_Include;
|
|
7037
|
+
const IncludeJsParser_1 = _src_handlers_script_include_js_IncludeJsParser;
|
|
7038
|
+
const IncludeJsBuilder_1 = _src_handlers_script_include_js_IncludeJsBuilder;
|
|
7039
|
+
const BaseHandler_1 = _src_handlers_base_BaseHandler;
|
|
7040
|
+
const IncludeJsRewriter_1 = _src_handlers_script_include_js_IncludeJsRewriter;
|
|
7041
|
+
class IncludeJsHandler extends BaseHandler_1.BaseHandler {
|
|
7042
|
+
constructor(solution) {
|
|
7043
|
+
super(solution);
|
|
7044
|
+
// if (this.solution.opts.package.module === 'includejs') {
|
|
7045
|
+
// this.registerMappings_();
|
|
7046
|
+
// }
|
|
7003
7047
|
}
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
for (let type in Rgx) {
|
|
7008
|
-
for (let key in Rgx[type]) {
|
|
7009
|
-
let rgx = Rgx[type][key].rgx;
|
|
7010
|
-
rgx.lastIndex = 0;
|
|
7011
|
-
if (rgx.test(content)) {
|
|
7012
|
-
return true;
|
|
7013
|
-
}
|
|
7014
|
-
}
|
|
7048
|
+
accepts(resource) {
|
|
7049
|
+
if (resource.type !== 'js') {
|
|
7050
|
+
return false;
|
|
7015
7051
|
}
|
|
7016
|
-
|
|
7052
|
+
var module = resource.getModule();
|
|
7053
|
+
if (module == null || module === 'root')
|
|
7054
|
+
module = this.solution.opts.package.module;
|
|
7055
|
+
return module === 'includejs';
|
|
7017
7056
|
}
|
|
7018
|
-
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7028
|
-
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
else {
|
|
7032
|
-
module.imports.push(result);
|
|
7033
|
-
}
|
|
7034
|
-
}
|
|
7035
|
-
}
|
|
7036
|
-
for (let key in Rgx.Exports) {
|
|
7037
|
-
let x = Rgx.Exports[key];
|
|
7038
|
-
x.rgx.lastIndex = 0;
|
|
7039
|
-
for (let match = x.rgx.exec(content); match != null; match = x.rgx.exec(content)) {
|
|
7040
|
-
let result = x.map(match, content);
|
|
7041
|
-
if (Array.isArray(result)) {
|
|
7042
|
-
module.exports.push(...result);
|
|
7043
|
-
}
|
|
7044
|
-
else {
|
|
7045
|
-
module.exports.push(result);
|
|
7046
|
-
}
|
|
7047
|
-
}
|
|
7048
|
-
}
|
|
7049
|
-
module.imports.forEach(m => m.parent = module);
|
|
7050
|
-
module.imports.filter(x => x.type === 'exportRefs').forEach(imp => {
|
|
7051
|
-
imp.refs.forEach(ref => {
|
|
7052
|
-
let exp = new ResourceInfo_1.ExportNode();
|
|
7053
|
-
exp.position = 0;
|
|
7054
|
-
exp.length = 0;
|
|
7055
|
-
exp.ref = ref;
|
|
7056
|
-
module.exports.push(exp);
|
|
7057
|
-
});
|
|
7058
|
-
});
|
|
7059
|
-
module.imports.sort((a, b) => a.position < b.position ? -1 : 1);
|
|
7060
|
-
module.exports.sort((a, b) => a.position < b.position ? -1 : 1);
|
|
7061
|
-
return module;
|
|
7057
|
+
rewriteRoot(root, dependencies) {
|
|
7058
|
+
dependencies.forEach(x => x.embed = true);
|
|
7059
|
+
var body = dependencies
|
|
7060
|
+
.map(x => x.content)
|
|
7061
|
+
.concat([root.content])
|
|
7062
|
+
.join('\n');
|
|
7063
|
+
body = Templates_1.Templates.RootModule.replace('%BUNDLE%', () => body);
|
|
7064
|
+
root.content = body;
|
|
7065
|
+
}
|
|
7066
|
+
resolvePath(includeData, parent) {
|
|
7067
|
+
return Include_1.Include
|
|
7068
|
+
.PathResolver
|
|
7069
|
+
.resolveBasic(includeData.url, includeData.type, parent);
|
|
7062
7070
|
}
|
|
7063
7071
|
}
|
|
7064
|
-
exports.
|
|
7065
|
-
|
|
7066
|
-
|
|
7072
|
+
exports.IncludeJsHandler = IncludeJsHandler;
|
|
7073
|
+
IncludeJsHandler.Parser = IncludeJsParser_1.IncludeJsParser;
|
|
7074
|
+
IncludeJsHandler.Rewriter = IncludeJsRewriter_1.IncludeJsRewriter;
|
|
7075
|
+
IncludeJsHandler.Builder = IncludeJsBuilder_1.IncludeJsBuilder;
|
|
7076
|
+
IncludeJsHandler.PathResolver = null;
|
|
7077
|
+
;
|
|
7078
|
+
//# sourceMappingURL=IncludeJsHandler.js.map
|
|
7079
|
+
//# sourceMappingURL=IncludeJsHandler.ts.map;
|
|
7067
7080
|
|
|
7068
7081
|
function __isObj(x) {
|
|
7069
7082
|
return x != null && typeof x === 'object' && x.constructor === Object;
|
|
7070
7083
|
}
|
|
7071
|
-
if (
|
|
7084
|
+
if (_src_handlers_script_include_js_IncludeJsHandler === module.exports) {
|
|
7072
7085
|
// do nothing if
|
|
7073
|
-
} else if (__isObj(
|
|
7074
|
-
Object.assign(
|
|
7086
|
+
} else if (__isObj(_src_handlers_script_include_js_IncludeJsHandler) && __isObj(module.exports)) {
|
|
7087
|
+
Object.assign(_src_handlers_script_include_js_IncludeJsHandler, module.exports);
|
|
7075
7088
|
} else {
|
|
7076
|
-
|
|
7089
|
+
_src_handlers_script_include_js_IncludeJsHandler = module.exports;
|
|
7077
7090
|
}
|
|
7078
7091
|
|
|
7079
7092
|
;
|