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