app-bundler 0.2.7 → 0.2.8

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