1(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ 2'use strict'; 3 4exports.__esModule = true; 5// istanbul ignore next 6 7function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 8 9var _handlebarsRuntime = require('./handlebars.runtime'); 10 11var _handlebarsRuntime2 = _interopRequireDefault(_handlebarsRuntime); 12 13// Compiler imports 14 15var _handlebarsCompilerAst = require('./handlebars/compiler/ast'); 16 17var _handlebarsCompilerAst2 = _interopRequireDefault(_handlebarsCompilerAst); 18 19var _handlebarsCompilerBase = require('./handlebars/compiler/base'); 20 21var _handlebarsCompilerCompiler = require('./handlebars/compiler/compiler'); 22 23var _handlebarsCompilerJavascriptCompiler = require('./handlebars/compiler/javascript-compiler'); 24 25var _handlebarsCompilerJavascriptCompiler2 = _interopRequireDefault(_handlebarsCompilerJavascriptCompiler); 26 27var _handlebarsCompilerVisitor = require('./handlebars/compiler/visitor'); 28 29var _handlebarsCompilerVisitor2 = _interopRequireDefault(_handlebarsCompilerVisitor); 30 31var _handlebarsNoConflict = require('./handlebars/no-conflict'); 32 33var _handlebarsNoConflict2 = _interopRequireDefault(_handlebarsNoConflict); 34 35var _create = _handlebarsRuntime2['default'].create; 36function create() { 37 var hb = _create(); 38 39 hb.compile = function (input, options) { 40 return _handlebarsCompilerCompiler.compile(input, options, hb); 41 }; 42 hb.precompile = function (input, options) { 43 return _handlebarsCompilerCompiler.precompile(input, options, hb); 44 }; 45 46 hb.AST = _handlebarsCompilerAst2['default']; 47 hb.Compiler = _handlebarsCompilerCompiler.Compiler; 48 hb.JavaScriptCompiler = _handlebarsCompilerJavascriptCompiler2['default']; 49 hb.Parser = _handlebarsCompilerBase.parser; 50 hb.parse = _handlebarsCompilerBase.parse; 51 hb.parseWithoutProcessing = _handlebarsCompilerBase.parseWithoutProcessing; 52 53 return hb; 54} 55 56var inst = create(); 57inst.create = create; 58 59_handlebarsNoConflict2['default'](inst); 60 61inst.Visitor = _handlebarsCompilerVisitor2['default']; 62 63inst['default'] = inst; 64 65exports['default'] = inst; 66module.exports = exports['default']; 67 68 69},{"./handlebars.runtime":2,"./handlebars/compiler/ast":4,"./handlebars/compiler/base":5,"./handlebars/compiler/compiler":7,"./handlebars/compiler/javascript-compiler":9,"./handlebars/compiler/visitor":11,"./handlebars/no-conflict":27}],2:[function(require,module,exports){ 70'use strict'; 71 72exports.__esModule = true; 73// istanbul ignore next 74 75function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 76 77// istanbul ignore next 78 79function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } 80 81var _handlebarsBase = require('./handlebars/base'); 82 83var base = _interopRequireWildcard(_handlebarsBase); 84 85// Each of these augment the Handlebars object. No need to setup here. 86// (This is done to easily share code between commonjs and browse envs) 87 88var _handlebarsSafeString = require('./handlebars/safe-string'); 89 90var _handlebarsSafeString2 = _interopRequireDefault(_handlebarsSafeString); 91 92var _handlebarsException = require('./handlebars/exception'); 93 94var _handlebarsException2 = _interopRequireDefault(_handlebarsException); 95 96var _handlebarsUtils = require('./handlebars/utils'); 97 98var Utils = _interopRequireWildcard(_handlebarsUtils); 99 100var _handlebarsRuntime = require('./handlebars/runtime'); 101 102var runtime = _interopRequireWildcard(_handlebarsRuntime); 103 104var _handlebarsNoConflict = require('./handlebars/no-conflict'); 105 106var _handlebarsNoConflict2 = _interopRequireDefault(_handlebarsNoConflict); 107 108// For compatibility and usage outside of module systems, make the Handlebars object a namespace 109function create() { 110 var hb = new base.HandlebarsEnvironment(); 111 112 Utils.extend(hb, base); 113 hb.SafeString = _handlebarsSafeString2['default']; 114 hb.Exception = _handlebarsException2['default']; 115 hb.Utils = Utils; 116 hb.escapeExpression = Utils.escapeExpression; 117 118 hb.VM = runtime; 119 hb.template = function (spec) { 120 return runtime.template(spec, hb); 121 }; 122 123 return hb; 124} 125 126var inst = create(); 127inst.create = create; 128 129_handlebarsNoConflict2['default'](inst); 130 131inst['default'] = inst; 132 133exports['default'] = inst; 134module.exports = exports['default']; 135 136 137},{"./handlebars/base":3,"./handlebars/exception":15,"./handlebars/no-conflict":27,"./handlebars/runtime":28,"./handlebars/safe-string":29,"./handlebars/utils":30}],3:[function(require,module,exports){ 138'use strict'; 139 140exports.__esModule = true; 141exports.HandlebarsEnvironment = HandlebarsEnvironment; 142// istanbul ignore next 143 144function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 145 146var _utils = require('./utils'); 147 148var _exception = require('./exception'); 149 150var _exception2 = _interopRequireDefault(_exception); 151 152var _helpers = require('./helpers'); 153 154var _decorators = require('./decorators'); 155 156var _logger = require('./logger'); 157 158var _logger2 = _interopRequireDefault(_logger); 159 160var _internalProtoAccess = require('./internal/proto-access'); 161 162var VERSION = '4.7.9'; 163exports.VERSION = VERSION; 164var COMPILER_REVISION = 8; 165exports.COMPILER_REVISION = COMPILER_REVISION; 166var LAST_COMPATIBLE_COMPILER_REVISION = 7; 167 168exports.LAST_COMPATIBLE_COMPILER_REVISION = LAST_COMPATIBLE_COMPILER_REVISION; 169var REVISION_CHANGES = { 170 1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it 171 2: '== 1.0.0-rc.3', 172 3: '== 1.0.0-rc.4', 173 4: '== 1.x.x', 174 5: '== 2.0.0-alpha.x', 175 6: '>
vendor: 6,926 bytes, lines 175-406
175= 2.0.0-beta.1', 176 7: '>= 4.0.0 <4.3.0', 177 8: '>= 4.3.0' 178}; 179 180exports.REVISION_CHANGES = REVISION_CHANGES; 181var objectType = '[object Object]'; 182 183function HandlebarsEnvironment(helpers, partials, decorators) { 184 this.helpers = helpers || {}; 185 this.partials = partials || {}; 186 this.decorators = decorators || {}; 187 188 _helpers.registerDefaultHelpers(this); 189 _decorators.registerDefaultDecorators(this); 190} 191 192HandlebarsEnvironment.prototype = { 193 constructor: HandlebarsEnvironment, 194 195 logger: _logger2['default'], 196 log: _logger2['default'].log, 197 198 registerHelper: function registerHelper(name, fn) { 199 if (_utils.toString.call(name) === objectType) { 200 if (fn) { 201 throw new _exception2['default']('Arg not supported with multiple helpers'); 202 } 203 _utils.extend(this.helpers, name); 204 } else { 205 this.helpers[name] = fn; 206 } 207 }, 208 unregisterHelper: function unregisterHelper(name) { 209 delete this.helpers[name]; 210 }, 211 212 registerPartial: function registerPartial(name, partial) { 213 if (_utils.toString.call(name) === objectType) { 214 _utils.extend(this.partials, name); 215 } else { 216 if (typeof partial === 'undefined') { 217 throw new _exception2['default']('Attempting to register a partial called "' + name + '" as undefined'); 218 } 219 this.partials[name] = partial; 220 } 221 }, 222 unregisterPartial: function unregisterPartial(name) { 223 delete this.partials[name]; 224 }, 225 226 registerDecorator: function registerDecorator(name, fn) { 227 if (_utils.toString.call(name) === objectType) { 228 if (fn) { 229 throw new _exception2['default']('Arg not supported with multiple decorators'); 230 } 231 _utils.extend(this.decorators, name); 232 } else { 233 this.decorators[name] = fn; 234 } 235 }, 236 unregisterDecorator: function unregisterDecorator(name) { 237 delete this.decorators[name]; 238 }, 239 /** 240 * Reset the memory of illegal property accesses that have already been logged. 241 * @deprecated should only be used in handlebars test-cases 242 */ 243 resetLoggedPropertyAccesses: function resetLoggedPropertyAccesses() { 244 _internalProtoAccess.resetLoggedProperties(); 245 } 246}; 247 248var log = _logger2['default'].log; 249 250exports.log = log; 251exports.createFrame = _utils.createFrame; 252exports.logger = _logger2['default']; 253 254 255},{"./decorators":13,"./exception":15,"./helpers":16,"./internal/proto-access":24,"./logger":26,"./utils":30}],4:[function(require,module,exports){ 256'use strict'; 257 258exports.__esModule = true; 259var AST = { 260 // Public API used to evaluate derived attributes regarding AST nodes 261 helpers: { 262 // a mustache is definitely a helper if: 263 // * it is an eligible helper, and 264 // * it has at least one parameter or hash segment 265 helperExpression: function helperExpression(node) { 266 return node.type === 'SubExpression' || (node.type === 'MustacheStatement' || node.type === 'BlockStatement') && !!(node.params && node.params.length || node.hash); 267 }, 268 269 scopedId: function scopedId(path) { 270 return (/^\.|this\b/.test(path.original) 271 ); 272 }, 273 274 // an ID is simple if it only has one part, and that part is not 275 // `..` or `this`. 276 simpleId: function simpleId(path) { 277 return path.parts.length === 1 && !AST.helpers.scopedId(path) && !path.depth; 278 } 279 } 280}; 281 282// Must be exported as an object rather than the root of the module as the jison lexer 283// must modify the object to operate properly. 284exports['default'] = AST; 285module.exports = exports['default']; 286 287 288},{}],5:[function(require,module,exports){ 289'use strict'; 290 291exports.__esModule = true; 292exports.parseWithoutProcessing = parseWithoutProcessing; 293exports.parse = parse; 294// istanbul ignore next 295 296function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } 297 298// istanbul ignore next 299 300function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 301 302var _parser = require('./parser'); 303 304var _parser2 = _interopRequireDefault(_parser); 305 306var _whitespaceControl = require('./whitespace-control'); 307 308var _whitespaceControl2 = _interopRequireDefault(_whitespaceControl); 309 310var _helpers = require('./helpers'); 311 312var Helpers = _interopRequireWildcard(_helpers); 313 314var _exception = require('../exception'); 315 316var _exception2 = _interopRequireDefault(_exception); 317 318var _utils = require('../utils'); 319 320exports.parser = _parser2['default']; 321 322var yy = {}; 323_utils.extend(yy, Helpers); 324 325function parseWithoutProcessing(input, options) { 326 // Just return if an already-compiled AST was passed in. 327 if (input.type === 'Program') { 328 // When a pre-parsed AST is passed in, validate all node values to prevent 329 // code injection via type-confused literals. 330 validateInputAst(input); 331 return input; 332 } 333 334 _parser2['default'].yy = yy; 335 336 // Altering the shared object here, but this is ok as parser is a sync operation 337 yy.locInfo = function (locInfo) { 338 return new yy.SourceLocation(options && options.srcName, locInfo); 339 }; 340 341 var ast = _parser2['default'].parse(input); 342 343 return ast; 344} 345 346function parse(input, options) { 347 var ast = parseWithoutProcessing(input, options); 348 var strip = new _whitespaceControl2['default'](options); 349 350 return strip.accept(ast); 351} 352 353function validateInputAst(ast) { 354 validateAstNode(ast); 355} 356 357function validateAstNode(node) { 358 if (node == null) { 359 return; 360 } 361 362 if (Array.isArray(node)) { 363 node.forEach(validateAstNode); 364 return; 365 } 366 367 if (typeof node !== 'object') { 368 return; 369 } 370 371 if (node.type === 'PathExpression') { 372 if (!isValidDepth(node.depth)) { 373 throw new _exception2['default']('Invalid AST: PathExpression.depth must be an integer'); 374 } 375 if (!Array.isArray(node.parts)) { 376 throw new _exception2['default']('Invalid AST: PathExpression.parts must be an array'); 377 } 378 for (var i = 0; i < node.parts.length; i++) { 379 if (typeof node.parts[i] !== 'string') { 380 throw new _exception2['default']('Invalid AST: PathExpression.parts must only contain strings'); 381 } 382 } 383 } else if (node.type === 'NumberLiteral') { 384 if (typeof node.value !== 'number' || !isFinite(node.value)) { 385 throw new _exception2['default']('Invalid AST: NumberLiteral.value must be a number'); 386 } 387 } else if (node.type === 'BooleanLiteral') { 388 if (typeof node.value !== 'boolean') { 389 throw new _exception2['default']('Invalid AST: BooleanLiteral.value must be a boolean'); 390 } 391 } 392 393 Object.keys(node).forEach(function (propertyName) { 394 if (propertyName === 'loc') { 395 return; 396 } 397 validateAstNode(node[propertyName]); 398 }); 399} 400 401function isValidDepth(depth) { 402 return typeof depth === 'number' && isFinite(depth) && Math.floor(depth) === depth && depth >= 0; 403} 404 405 406},{"../exception":15,"../utils":30,"./helpers":8,"./parser":10,"./w
vendor: 5,356 bytes, lines 406-614
406hitespace-control":12}],6:[function(require,module,exports){ 407/* global define, require */ 408'use strict'; 409 410exports.__esModule = true; 411 412var _utils = require('../utils'); 413 414var SourceNode = undefined; 415 416try { 417 /* istanbul ignore next */ 418 if (typeof define !== 'function' || !define.amd) { 419 // We don't support this in AMD environments. For these environments, we assume that 420 // they are running on the browser and thus have no need for the source-map library. 421 var SourceMap = require('source-map'); 422 SourceNode = SourceMap.SourceNode; 423 } 424} catch (err) {} 425/* NOP */ 426 427/* istanbul ignore if: tested but not covered in istanbul due to dist build */ 428if (!SourceNode) { 429 SourceNode = function (line, column, srcFile, chunks) { 430 this.src = ''; 431 if (chunks) { 432 this.add(chunks); 433 } 434 }; 435 /* istanbul ignore next */ 436 SourceNode.prototype = { 437 add: function add(chunks) { 438 if (_utils.isArray(chunks)) { 439 chunks = chunks.join(''); 440 } 441 this.src += chunks; 442 }, 443 prepend: function prepend(chunks) { 444 if (_utils.isArray(chunks)) { 445 chunks = chunks.join(''); 446 } 447 this.src = chunks + this.src; 448 }, 449 toStringWithSourceMap: function toStringWithSourceMap() { 450 return { code: this.toString() }; 451 }, 452 toString: function toString() { 453 return this.src; 454 } 455 }; 456} 457 458function castChunk(chunk, codeGen, loc) { 459 if (_utils.isArray(chunk)) { 460 var ret = []; 461 462 for (var i = 0, len = chunk.length; i < len; i++) { 463 ret.push(codeGen.wrap(chunk[i], loc)); 464 } 465 return ret; 466 } else if (typeof chunk === 'boolean' || typeof chunk === 'number') { 467 // Handle primitives that the SourceNode will throw up on 468 return chunk + ''; 469 } 470 return chunk; 471} 472 473function CodeGen(srcFile) { 474 this.srcFile = srcFile; 475 this.source = []; 476} 477 478CodeGen.prototype = { 479 isEmpty: function isEmpty() { 480 return !this.source.length; 481 }, 482 prepend: function prepend(source, loc) { 483 this.source.unshift(this.wrap(source, loc)); 484 }, 485 push: function push(source, loc) { 486 this.source.push(this.wrap(source, loc)); 487 }, 488 489 merge: function merge() { 490 var source = this.empty(); 491 this.each(function (line) { 492 source.add([' ', line, '\n']); 493 }); 494 return source; 495 }, 496 497 each: function each(iter) { 498 for (var i = 0, len = this.source.length; i < len; i++) { 499 iter(this.source[i]); 500 } 501 }, 502 503 empty: function empty() { 504 var loc = this.currentLocation || { start: {} }; 505 return new SourceNode(loc.start.line, loc.start.column, this.srcFile); 506 }, 507 wrap: function wrap(chunk) { 508 var loc = arguments.length <= 1 || arguments[1] === undefined ? this.currentLocation || { start: {} } : arguments[1]; 509 510 if (chunk instanceof SourceNode) { 511 return chunk; 512 } 513 514 chunk = castChunk(chunk, this, loc); 515 516 return new SourceNode(loc.start.line, loc.start.column, this.srcFile, chunk); 517 }, 518 519 functionCall: function functionCall(fn, type, params) { 520 params = this.generateList(params); 521 return this.wrap([fn, type ? '.' + type + '(' : '(', params, ')']); 522 }, 523 524 quotedString: function quotedString(str) { 525 return '"' + (str + '').replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/\u2028/g, '\\u2028') // Per Ecma-262 7.3 + 7.8.4 526 .replace(/\u2029/g, '\\u2029') + '"'; 527 }, 528 529 objectLiteral: function objectLiteral(obj) { 530 // istanbul ignore next 531 532 var _this = this; 533 534 var pairs = []; 535 536 Object.keys(obj).forEach(function (key) { 537 var value = castChunk(obj[key], _this); 538 if (value !== 'undefined') { 539 pairs.push([_this.quotedString(key), ':', value]); 540 } 541 }); 542 543 var ret = this.generateList(pairs); 544 ret.prepend('{'); 545 ret.add('}'); 546 return ret; 547 }, 548 549 generateList: function generateList(entries) { 550 var ret = this.empty(); 551 552 for (var i = 0, len = entries.length; i < len; i++) { 553 if (i) { 554 ret.add(','); 555 } 556 557 ret.add(castChunk(entries[i], this)); 558 } 559 560 return ret; 561 }, 562 563 generateArray: function generateArray(entries) { 564 var ret = this.generateList(entries); 565 ret.prepend('['); 566 ret.add(']'); 567 568 return ret; 569 } 570}; 571 572exports['default'] = CodeGen; 573module.exports = exports['default']; 574 575 576},{"../utils":30,"source-map":41}],7:[function(require,module,exports){ 577/* eslint-disable new-cap */ 578 579'use strict'; 580 581exports.__esModule = true; 582exports.Compiler = Compiler; 583exports.precompile = precompile; 584exports.compile = compile; 585// istanbul ignore next 586 587function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 588 589var _exception = require('../exception'); 590 591var _exception2 = _interopRequireDefault(_exception); 592 593var _utils = require('../utils'); 594 595var _ast = require('./ast'); 596 597var _ast2 = _interopRequireDefault(_ast); 598 599var slice = [].slice; 600 601function Compiler() {} 602 603// the foundHelper register will disambiguate helper lookup from finding a 604// function in a context. This is necessary for mustache compatibility, which 605// requires that context functions in blocks are evaluated by blockHelperMissing, 606// and then proceed as if the resulting value was provided to blockHelperMissing. 607 608Compiler.prototype = { 609 compiler: Compiler, 610 611 equals: function equals(other) { 612 var len = this.opcodes.length; 613 if (other.opcodes.length !== len) { 614 return false;
vendor: 13,958 bytes, lines 615-1102
615 } 616 617 for (var i = 0; i < len; i++) { 618 var opcode = this.opcodes[i], 619 otherOpcode = other.opcodes[i]; 620 if (opcode.opcode !== otherOpcode.opcode || !argEquals(opcode.args, otherOpcode.args)) { 621 return false; 622 } 623 } 624 625 // We know that length is the same between the two arrays because they are directly tied 626 // to the opcode behavior above. 627 len = this.children.length; 628 for (var i = 0; i < len; i++) { 629 if (!this.children[i].equals(other.children[i])) { 630 return false; 631 } 632 } 633 634 return true; 635 }, 636 637 guid: 0, 638 639 compile: function compile(program, options) { 640 this.sourceNode = []; 641 this.opcodes = []; 642 this.children = []; 643 this.options = options; 644 this.stringParams = options.stringParams; 645 this.trackIds = options.trackIds; 646 647 options.blockParams = options.blockParams || []; 648 649 options.knownHelpers = _utils.extend(Object.create(null), { 650 helperMissing: true, 651 blockHelperMissing: true, 652 each: true, 653 'if': true, 654 unless: true, 655 'with': true, 656 log: true, 657 lookup: true 658 }, options.knownHelpers); 659 660 return this.accept(program); 661 }, 662 663 compileProgram: function compileProgram(program) { 664 var childCompiler = new this.compiler(), 665 // eslint-disable-line new-cap 666 result = childCompiler.compile(program, this.options), 667 guid = this.guid++; 668 669 this.usePartial = this.usePartial || result.usePartial; 670 671 this.children[guid] = result; 672 this.useDepths = this.useDepths || result.useDepths; 673 674 return guid; 675 }, 676 677 accept: function accept(node) { 678 /* istanbul ignore next: Sanity code */ 679 if (!this[node.type]) { 680 throw new _exception2['default']('Unknown type: ' + node.type, node); 681 } 682 683 this.sourceNode.unshift(node); 684 var ret = this[node.type](node); 685 this.sourceNode.shift(); 686 return ret; 687 }, 688 689 Program: function Program(program) { 690 this.options.blockParams.unshift(program.blockParams); 691 692 var body = program.body, 693 bodyLength = body.length; 694 for (var i = 0; i < bodyLength; i++) { 695 this.accept(body[i]); 696 } 697 698 this.options.blockParams.shift(); 699 700 this.isSimple = bodyLength === 1; 701 this.blockParams = program.blockParams ? program.blockParams.length : 0; 702 703 return this; 704 }, 705 706 BlockStatement: function BlockStatement(block) { 707 transformLiteralToPath(block); 708 709 var program = block.program, 710 inverse = block.inverse; 711 712 program = program && this.compileProgram(program); 713 inverse = inverse && this.compileProgram(inverse); 714 715 var type = this.classifySexpr(block); 716 717 if (type === 'helper') { 718 this.helperSexpr(block, program, inverse); 719 } else if (type === 'simple') { 720 this.simpleSexpr(block); 721 722 // now that the simple mustache is resolved, we need to 723 // evaluate it by executing `blockHelperMissing` 724 this.opcode('pushProgram', program); 725 this.opcode('pushProgram', inverse); 726 this.opcode('emptyHash'); 727 this.opcode('blockValue', block.path.original); 728 } else { 729 this.ambiguousSexpr(block, program, inverse); 730 731 // now that the simple mustache is resolved, we need to 732 // evaluate it by executing `blockHelperMissing` 733 this.opcode('pushProgram', program); 734 this.opcode('pushProgram', inverse); 735 this.opcode('emptyHash'); 736 this.opcode('ambiguousBlockValue'); 737 } 738 739 this.opcode('append'); 740 }, 741 742 DecoratorBlock: function DecoratorBlock(decorator) { 743 var program = decorator.program && this.compileProgram(decorator.program); 744 var params = this.setupFullMustacheParams(decorator, program, undefined), 745 path = decorator.path; 746 747 this.useDecorators = true; 748 this.opcode('registerDecorator', params.length, path.original); 749 }, 750 751 PartialStatement: function PartialStatement(partial) { 752 this.usePartial = true; 753 754 var program = partial.program; 755 if (program) { 756 program = this.compileProgram(partial.program); 757 } 758 759 var params = partial.params; 760 if (params.length > 1) { 761 throw new _exception2['default']('Unsupported number of partial arguments: ' + params.length, partial); 762 } else if (!params.length) { 763 if (this.options.explicitPartialContext) { 764 this.opcode('pushLiteral', 'undefined'); 765 } else { 766 params.push({ type: 'PathExpression', parts: [], depth: 0 }); 767 } 768 } 769 770 var partialName = partial.name.original, 771 isDynamic = partial.name.type === 'SubExpression'; 772 if (isDynamic) { 773 this.accept(partial.name); 774 } 775 776 this.setupFullMustacheParams(partial, program, undefined, true); 777 778 var indent = partial.indent || ''; 779 if (this.options.preventIndent && indent) { 780 this.opcode('appendContent', indent); 781 indent = ''; 782 } 783 784 this.opcode('invokePartial', isDynamic, partialName, indent); 785 this.opcode('append'); 786 }, 787 PartialBlockStatement: function PartialBlockStatement(partialBlock) { 788 this.PartialStatement(partialBlock); 789 }, 790 791 MustacheStatement: function MustacheStatement(mustache) { 792 this.SubExpression(mustache); 793 794 if (mustache.escaped && !this.options.noEscape) { 795 this.opcode('appendEscaped'); 796 } else { 797 this.opcode('append'); 798 } 799 }, 800 Decorator: function Decorator(decorator) { 801 this.DecoratorBlock(decorator); 802 }, 803 804 ContentStatement: function ContentStatement(content) { 805 if (content.value) { 806 this.opcode('appendContent', content.value); 807 } 808 }, 809 810 CommentStatement: function CommentStatement() {}, 811 812 SubExpression: function SubExpression(sexpr) { 813 transformLiteralToPath(sexpr); 814 var type = this.classifySexpr(sexpr); 815 816 if (type === 'simple') { 817 this.simpleSexpr(sexpr); 818 } else if (type === 'helper') { 819 this.helperSexpr(sexpr); 820 } else { 821 this.ambiguousSexpr(sexpr); 822 } 823 }, 824 ambiguousSexpr: function ambiguousSexpr(sexpr, program, inverse) { 825 var path = sexpr.path, 826 name = path.parts[0], 827 isBlock = program != null || inverse != null; 828 829 this.opcode('getContext', path.depth); 830 831 this.opcode('pushProgram', program); 832 this.opcode('pushProgram', inverse); 833 834 path.strict = true; 835 this.accept(path); 836 837 this.opcode('invokeAmbiguous', name, isBlock); 838 }, 839 840 simpleSexpr: function simpleSexpr(sexpr) { 841 var path = sexpr.path; 842 path.strict = true; 843 this.accept(path); 844 this.opcode('resolvePossibleLambda'); 845 }, 846 847 helperSexpr: function helperSexpr(sexpr, program, inverse) { 848 var params = this.setupFullMustacheParams(sexpr, program, inverse), 849 path = sexpr.path, 850 name = path.parts[0]; 851 852 if (this.options.knownHelpers[name]) { 853 this.opcode('invokeKnownHelper', params.length, name); 854 } else if (this.options.knownHelpersOnly) { 855 throw new _exception2['default']('You specified knownHelpersOnly, but used the unknown helper ' + name, sexpr); 856 } else { 857 path.strict = true; 858 path.falsy = true; 859 860 this.accept(path); 861 this.opcode('invokeHelper', params.length, path.original, _ast2['default'].helpers.simpleId(path)); 862 } 863 }, 864 865 PathExpression: function PathExpression(path) { 866 this.addDepth(path.depth); 867 this.opcode('getContext', path.depth); 868 869 var name = path.parts[0], 870 scoped = _ast2['default'].helpers.scopedId(path), 871 blockParamId = !path.depth && !scoped && this.blockParamIndex(name); 872 873 if (blockParamId) { 874 this.opcode('lookupBlockParam', blockParamId, path.parts); 875 } else if (!name) { 876 // Context reference, i.e. `{{foo .}}` or `{{foo ..}}` 877 this.opcode('pushContext'); 878 } else if (path.data) { 879 this.options.data = true; 880 this.opcode('lookupData', path.depth, path.parts, path.strict); 881 } else { 882 this.opcode('lookupOnContext', path.parts, path.falsy, path.strict, scoped); 883 } 884 }, 885 886 StringLiteral: function StringLiteral(string) { 887 this.opcode('pushString', string.value); 888 }, 889 890 NumberLiteral: function NumberLiteral(number) { 891 this.opcode('pushLiteral', number.value); 892 }, 893 894 BooleanLiteral: function BooleanLiteral(bool) { 895 this.opcode('pushLiteral', bool.value); 896 }, 897 898 UndefinedLiteral: function UndefinedLiteral() { 899 this.opcode('pushLiteral', 'undefined'); 900 }, 901 902 NullLiteral: function NullLiteral() { 903 this.opcode('pushLiteral', 'null'); 904 }, 905 906 Hash: function Hash(hash) { 907 var pairs = hash.pairs, 908 i = 0, 909 l = pairs.length; 910 911 this.opcode('pushHash'); 912 913 for (; i < l; i++) { 914 this.pushParam(pairs[i].value); 915 } 916 while (i--) { 917 this.opcode('assignToHash', pairs[i].key); 918 } 919 this.opcode('popHash'); 920 }, 921 922 // HELPERS 923 opcode: function opcode(name) { 924 this.opcodes.push({ 925 opcode: name, 926 args: slice.call(arguments, 1), 927 loc: this.sourceNode[0].loc 928 }); 929 }, 930 931 addDepth: function addDepth(depth) { 932 if (!depth) { 933 return; 934 } 935 936 this.useDepths = true; 937 }, 938 939 classifySexpr: function classifySexpr(sexpr) { 940 var isSimple = _ast2['default'].helpers.simpleId(sexpr.path); 941 942 var isBlockParam = isSimple && !!this.blockParamIndex(sexpr.path.parts[0]); 943 944 // a mustache is an eligible helper if: 945 // * its id is simple (a single part, not `this` or `..`) 946 var isHelper = !isBlockParam && _ast2['default'].helpers.helperExpression(sexpr); 947 948 // if a mustache is an eligible helper but not a definite 949 // helper, it is ambiguous, and will be resolved in a later 950 // pass or at runtime. 951 var isEligible = !isBlockParam && (isHelper || isSimple); 952 953 // if ambiguous, we can possibly resolve the ambiguity now 954 // An eligible helper is one that does not have a complex path, i.e. `this.foo`, `../foo` etc. 955 if (isEligible && !isHelper) { 956 var _name = sexpr.path.parts[0], 957 options = this.options; 958 if (options.knownHelpers[_name]) { 959 isHelper = true; 960 } else if (options.knownHelpersOnly) { 961 isEligible = false; 962 } 963 } 964 965 if (isHelper) { 966 return 'helper'; 967 } else if (isEligible) { 968 return 'ambiguous'; 969 } else { 970 return 'simple'; 971 } 972 }, 973 974 pushParams: function pushParams(params) { 975 for (var i = 0, l = params.length; i < l; i++) { 976 this.pushParam(params[i]); 977 } 978 }, 979 980 pushParam: function pushParam(val) { 981 var value = val.value != null ? val.value : val.original || ''; 982 983 if (this.stringParams) { 984 if (value.replace) { 985 value = value.replace(/^(\.?\.\/)*/g, '').replace(/\//g, '.'); 986 } 987 988 if (val.depth) { 989 this.addDepth(val.depth); 990 } 991 this.opcode('getContext', val.depth || 0); 992 this.opcode('pushStringParam', value, val.type); 993 994 if (val.type === 'SubExpression') { 995 // SubExpressions get evaluated and passed in 996 // in string params mode. 997 this.accept(val); 998 } 999 } else { 1000 if (this.trackIds) { 1001 var blockParamIndex = undefined; 1002 if (val.parts && !_ast2['default'].helpers.scopedId(val) && !val.depth) { 1003 blockParamIndex = this.blockParamIndex(val.parts[0]); 1004 } 1005 if (blockParamIndex) { 1006 var blockParamChild = val.parts.slice(1).join('.'); 1007 this.opcode('pushId', 'BlockParam', blockParamIndex, blockParamChild); 1008 } else { 1009 value = val.original || value; 1010 if (value.replace) { 1011 value = value.replace(/^this(?:\.|$)/, '').replace(/^\.\//, '').replace(/^\.$/, ''); 1012 } 1013 1014 this.opcode('pushId', val.type, value); 1015 } 1016 } 1017 this.accept(val); 1018 } 1019 }, 1020 1021 setupFullMustacheParams: function setupFullMustacheParams(sexpr, program, inverse, omitEmpty) { 1022 var params = sexpr.params; 1023 this.pushParams(params); 1024 1025 this.opcode('pushProgram', program); 1026 this.opcode('pushProgram', inverse); 1027 1028 if (sexpr.hash) { 1029 this.accept(sexpr.hash); 1030 } else { 1031 this.opcode('emptyHash', omitEmpty); 1032 } 1033 1034 return params; 1035 }, 1036 1037 blockParamIndex: function blockParamIndex(name) { 1038 for (var depth = 0, len = this.options.blockParams.length; depth < len; depth++) { 1039 var blockParams = this.options.blockParams[depth], 1040 param = blockParams && _utils.indexOf(blockParams, name); 1041 if (blockParams && param >= 0) { 1042 return [depth, param]; 1043 } 1044 } 1045 } 1046}; 1047 1048function precompile(input, options, env) { 1049 if (input == null || typeof input !== 'string' && input.type !== 'Program') { 1050 throw new _exception2['default']('You must pass a string or Handlebars AST to Handlebars.precompile. You passed ' + input); 1051 } 1052 1053 options = options || {}; 1054 if (!('data' in options)) { 1055 options.data = true; 1056 } 1057 if (options.compat) { 1058 options.useDepths = true; 1059 } 1060 1061 var ast = env.parse(input, options), 1062 environment = new env.Compiler().compile(ast, options); 1063 return new env.JavaScriptCompiler().compile(environment, options); 1064} 1065 1066function compile(input, options, env) { 1067 if (options === undefined) options = {}; 1068 1069 if (input == null || typeof input !== 'string' && input.type !== 'Program') { 1070 throw new _exception2['default']('You must pass a string or Handlebars AST to Handlebars.compile. You passed ' + input); 1071 } 1072 1073 options = _utils.extend({}, options); 1074 if (!('data' in options)) { 1075 options.data = true; 1076 } 1077 if (options.compat) { 1078 options.useDepths = true; 1079 } 1080 1081 var compiled = undefined; 1082 1083 function compileInput() { 1084 var ast = env.parse(input, options), 1085 environment = new env.Compiler().compile(ast, options), 1086 templateSpec = new env.JavaScriptCompiler().compile(environment, options, undefined, true); 1087 return env.template(templateSpec); 1088 } 1089 1090 // Template is only compiled on first use and cached after that point. 1091 function ret(context, execOptions) { 1092 if (!compiled) { 1093 compiled = compileInput(); 1094 } 1095 return compiled.call(this, context, execOptions); 1096 } 1097 ret._setup = function (setupOptions) { 1098 if (!compiled) { 1099 compiled = compileInput(); 1100 } 1101 return compiled._setup(setupOptions); 1102 };
vendor: 4,491 bytes, lines 1103-1288
1103 ret._child = function (i, data, blockParams, depths) { 1104 if (!compiled) { 1105 compiled = compileInput(); 1106 } 1107 return compiled._child(i, data, blockParams, depths); 1108 }; 1109 return ret; 1110} 1111 1112function argEquals(a, b) { 1113 if (a === b) { 1114 return true; 1115 } 1116 1117 if (_utils.isArray(a) && _utils.isArray(b) && a.length === b.length) { 1118 for (var i = 0; i < a.length; i++) { 1119 if (!argEquals(a[i], b[i])) { 1120 return false; 1121 } 1122 } 1123 return true; 1124 } 1125} 1126 1127function transformLiteralToPath(sexpr) { 1128 if (!sexpr.path.parts) { 1129 var literal = sexpr.path; 1130 // Casting to string here to make false and 0 literal values play nicely with the rest 1131 // of the system. 1132 sexpr.path = { 1133 type: 'PathExpression', 1134 data: false, 1135 depth: 0, 1136 parts: [literal.original + ''], 1137 original: literal.original + '', 1138 loc: literal.loc 1139 }; 1140 } 1141} 1142 1143 1144},{"../exception":15,"../utils":30,"./ast":4}],8:[function(require,module,exports){ 1145'use strict'; 1146 1147exports.__esModule = true; 1148exports.SourceLocation = SourceLocation; 1149exports.id = id; 1150exports.stripFlags = stripFlags; 1151exports.stripComment = stripComment; 1152exports.preparePath = preparePath; 1153exports.prepareMustache = prepareMustache; 1154exports.prepareRawBlock = prepareRawBlock; 1155exports.prepareBlock = prepareBlock; 1156exports.prepareProgram = prepareProgram; 1157exports.preparePartialBlock = preparePartialBlock; 1158// istanbul ignore next 1159 1160function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 1161 1162var _exception = require('../exception'); 1163 1164var _exception2 = _interopRequireDefault(_exception); 1165 1166function validateClose(open, close) { 1167 close = close.path ? close.path.original : close; 1168 1169 if (open.path.original !== close) { 1170 var errorNode = { loc: open.path.loc }; 1171 1172 throw new _exception2['default'](open.path.original + " doesn't match " + close, errorNode); 1173 } 1174} 1175 1176function SourceLocation(source, locInfo) { 1177 this.source = source; 1178 this.start = { 1179 line: locInfo.first_line, 1180 column: locInfo.first_column 1181 }; 1182 this.end = { 1183 line: locInfo.last_line, 1184 column: locInfo.last_column 1185 }; 1186} 1187 1188function id(token) { 1189 if (/^\[.*\]$/.test(token)) { 1190 return token.substring(1, token.length - 1); 1191 } else { 1192 return token; 1193 } 1194} 1195 1196function stripFlags(open, close) { 1197 return { 1198 open: open.charAt(2) === '~', 1199 close: close.charAt(close.length - 3) === '~' 1200 }; 1201} 1202 1203function stripComment(comment) { 1204 return comment.replace(/^\{\{~?!-?-?/, '').replace(/-?-?~?\}\}$/, ''); 1205} 1206 1207function preparePath(data, parts, loc) { 1208 loc = this.locInfo(loc); 1209 1210 var original = data ? '@' : '', 1211 dig = [], 1212 depth = 0; 1213 1214 for (var i = 0, l = parts.length; i < l; i++) { 1215 var part = parts[i].part, 1216 1217 // If we have [] syntax then we do not treat path references as operators, 1218 // i.e. foo.[this] resolves to approximately context.foo['this'] 1219 isLiteral = parts[i].original !== part; 1220 original += (parts[i].separator || '') + part; 1221 1222 if (!isLiteral && (part === '..' || part === '.' || part === 'this')) { 1223 if (dig.length > 0) { 1224 throw new _exception2['default']('Invalid path: ' + original, { loc: loc }); 1225 } else if (part === '..') { 1226 depth++; 1227 } 1228 } else { 1229 dig.push(part); 1230 } 1231 } 1232 1233 return { 1234 type: 'PathExpression', 1235 data: data, 1236 depth: depth, 1237 parts: dig, 1238 original: original, 1239 loc: loc 1240 }; 1241} 1242 1243function prepareMustache(path, params, hash, open, strip, locInfo) { 1244 // Must use charAt to support IE pre-10 1245 var escapeFlag = open.charAt(3) || open.charAt(2), 1246 escaped = escapeFlag !== '{' && escapeFlag !== '&'; 1247 1248 var decorator = /\*/.test(open); 1249 return { 1250 type: decorator ? 'Decorator' : 'MustacheStatement', 1251 path: path, 1252 params: params, 1253 hash: hash, 1254 escaped: escaped, 1255 strip: strip, 1256 loc: this.locInfo(locInfo) 1257 }; 1258} 1259 1260function prepareRawBlock(openRawBlock, contents, close, locInfo) { 1261 validateClose(openRawBlock, close); 1262 1263 locInfo = this.locInfo(locInfo); 1264 var program = { 1265 type: 'Program', 1266 body: contents, 1267 strip: {}, 1268 loc: locInfo 1269 }; 1270 1271 return { 1272 type: 'BlockStatement', 1273 path: openRawBlock.path, 1274 params: openRawBlock.params, 1275 hash: openRawBlock.hash, 1276 program: program, 1277 openStrip: {}, 1278 inverseStrip: {}, 1279 closeStrip: {}, 1280 loc: locInfo 1281 }; 1282} 1283 1284function prepareBlock(openBlock, program, inverseAndProgram, close, inverted, locInfo) { 1285 if (close && close.path) { 1286 validateClose(openBlock, close); 1287 } 1288
vendor: 1,925 bytes, lines 1289-1374
1289 var decorator = /\*/.test(openBlock.open); 1290 1291 program.blockParams = openBlock.blockParams; 1292 1293 var inverse = undefined, 1294 inverseStrip = undefined; 1295 1296 if (inverseAndProgram) { 1297 if (decorator) { 1298 throw new _exception2['default']('Unexpected inverse block on decorator', inverseAndProgram); 1299 } 1300 1301 if (inverseAndProgram.chain) { 1302 inverseAndProgram.program.body[0].closeStrip = close.strip; 1303 } 1304 1305 inverseStrip = inverseAndProgram.strip; 1306 inverse = inverseAndProgram.program; 1307 } 1308 1309 if (inverted) { 1310 inverted = inverse; 1311 inverse = program; 1312 program = inverted; 1313 } 1314 1315 return { 1316 type: decorator ? 'DecoratorBlock' : 'BlockStatement', 1317 path: openBlock.path, 1318 params: openBlock.params, 1319 hash: openBlock.hash, 1320 program: program, 1321 inverse: inverse, 1322 openStrip: openBlock.strip, 1323 inverseStrip: inverseStrip, 1324 closeStrip: close && close.strip, 1325 loc: this.locInfo(locInfo) 1326 }; 1327} 1328 1329function prepareProgram(statements, loc) { 1330 if (!loc && statements.length) { 1331 var firstLoc = statements[0].loc, 1332 lastLoc = statements[statements.length - 1].loc; 1333 1334 /* istanbul ignore else */ 1335 if (firstLoc && lastLoc) { 1336 loc = { 1337 source: firstLoc.source, 1338 start: { 1339 line: firstLoc.start.line, 1340 column: firstLoc.start.column 1341 }, 1342 end: { 1343 line: lastLoc.end.line, 1344 column: lastLoc.end.column 1345 } 1346 }; 1347 } 1348 } 1349 1350 return { 1351 type: 'Program', 1352 body: statements, 1353 strip: {}, 1354 loc: loc 1355 }; 1356} 1357 1358function preparePartialBlock(open, program, close, locInfo) { 1359 validateClose(open, close); 1360 1361 return { 1362 type: 'PartialBlockStatement', 1363 name: open.path, 1364 params: open.params, 1365 hash: open.hash, 1366 program: program, 1367 openStrip: open.strip, 1368 closeStrip: close && close.strip, 1369 loc: this.locInfo(locInfo) 1370 }; 1371} 1372 1373 1374},{"../exception":15}],9:[function(require,module,exports){
vendor: 35,414 bytes, lines 1375-2539
1375'use strict'; 1376 1377exports.__esModule = true; 1378// istanbul ignore next 1379 1380function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 1381 1382var _base = require('../base'); 1383 1384var _exception = require('../exception'); 1385 1386var _exception2 = _interopRequireDefault(_exception); 1387 1388var _utils = require('../utils'); 1389 1390var _codeGen = require('./code-gen'); 1391 1392var _codeGen2 = _interopRequireDefault(_codeGen); 1393 1394function Literal(value) { 1395 this.value = value; 1396} 1397 1398function JavaScriptCompiler() {} 1399 1400JavaScriptCompiler.prototype = { 1401 // PUBLIC API: You can override these methods in a subclass to provide 1402 // alternative compiled forms for name lookup and buffering semantics 1403 nameLookup: function nameLookup(parent, name /*, type */) { 1404 return this.internalNameLookup(parent, name); 1405 }, 1406 depthedLookup: function depthedLookup(name) { 1407 return [this.aliasable('container.lookup'), '(depths, ', JSON.stringify(name), ')']; 1408 }, 1409 1410 compilerInfo: function compilerInfo() { 1411 var revision = _base.COMPILER_REVISION, 1412 versions = _base.REVISION_CHANGES[revision]; 1413 return [revision, versions]; 1414 }, 1415 1416 appendToBuffer: function appendToBuffer(source, location, explicit) { 1417 // Force a source as this simplifies the merge logic. 1418 if (!_utils.isArray(source)) { 1419 source = [source]; 1420 } 1421 source = this.source.wrap(source, location); 1422 1423 if (this.environment.isSimple) { 1424 return ['return ', source, ';']; 1425 } else if (explicit) { 1426 // This is a case where the buffer operation occurs as a child of another 1427 // construct, generally braces. We have to explicitly output these buffer 1428 // operations to ensure that the emitted code goes in the correct location. 1429 return ['buffer += ', source, ';']; 1430 } else { 1431 source.appendToBuffer = true; 1432 return source; 1433 } 1434 }, 1435 1436 initializeBuffer: function initializeBuffer() { 1437 return this.quotedString(''); 1438 }, 1439 // END PUBLIC API 1440 internalNameLookup: function internalNameLookup(parent, name) { 1441 this.lookupPropertyFunctionIsUsed = true; 1442 return ['lookupProperty(', parent, ',', JSON.stringify(name), ')']; 1443 }, 1444 1445 lookupPropertyFunctionIsUsed: false, 1446 1447 compile: function compile(environment, options, context, asObject) { 1448 this.environment = environment; 1449 this.options = options; 1450 this.stringParams = this.options.stringParams; 1451 this.trackIds = this.options.trackIds; 1452 this.precompile = !asObject; 1453 1454 this.name = this.environment.name; 1455 this.isChild = !!context; 1456 this.context = context || { 1457 decorators: [], 1458 programs: [], 1459 environments: [] 1460 }; 1461 1462 this.preamble(); 1463 1464 this.stackSlot = 0; 1465 this.stackVars = []; 1466 this.aliases = {}; 1467 this.registers = { list: [] }; 1468 this.hashes = []; 1469 this.compileStack = []; 1470 this.inlineStack = []; 1471 this.blockParams = []; 1472 1473 this.compileChildren(environment, options); 1474 1475 this.useDepths = this.useDepths || environment.useDepths || environment.useDecorators || this.options.compat; 1476 this.useBlockParams = this.useBlockParams || environment.useBlockParams; 1477 1478 var opcodes = environment.opcodes, 1479 opcode = undefined, 1480 firstLoc = undefined, 1481 i = undefined, 1482 l = undefined; 1483 1484 for (i = 0, l = opcodes.length; i < l; i++) { 1485 opcode = opcodes[i]; 1486 1487 this.source.currentLocation = opcode.loc; 1488 firstLoc = firstLoc || opcode.loc; 1489 this[opcode.opcode].apply(this, opcode.args); 1490 } 1491 1492 // Flush any trailing content that might be pending. 1493 this.source.currentLocation = firstLoc; 1494 this.pushSource(''); 1495 1496 /* istanbul ignore next */ 1497 if (this.stackSlot || this.inlineStack.length || this.compileStack.length) { 1498 throw new _exception2['default']('Compile completed with content left on stack'); 1499 } 1500 1501 if (!this.decorators.isEmpty()) { 1502 this.useDecorators = true; 1503 1504 this.decorators.prepend(['var decorators = container.decorators, ', this.lookupPropertyFunctionVarDeclaration(), ';\n']); 1505 this.decorators.push('return fn;'); 1506 1507 if (asObject) { 1508 this.decorators = Function.apply(this, ['fn', 'props', 'container', 'depth0', 'data', 'blockParams', 'depths', this.decorators.merge()]); 1509 } else { 1510 this.decorators.prepend('function(fn, props, container, depth0, data, blockParams, depths) {\n'); 1511 this.decorators.push('}\n'); 1512 this.decorators = this.decorators.merge(); 1513 } 1514 } else { 1515 this.decorators = undefined; 1516 } 1517 1518 var fn = this.createFunctionContext(asObject); 1519 if (!this.isChild) { 1520 var ret = { 1521 compiler: this.compilerInfo(), 1522 main: fn 1523 }; 1524 1525 if (this.decorators) { 1526 ret.main_d = this.decorators; // eslint-disable-line camelcase 1527 ret.useDecorators = true; 1528 } 1529 1530 var _context = this.context; 1531 var programs = _context.programs; 1532 var decorators = _context.decorators; 1533 1534 for (i = 0, l = programs.length; i < l; i++) { 1535 ret[i] = programs[i]; 1536 if (decorators[i]) { 1537 ret[i + '_d'] = decorators[i]; 1538 ret.useDecorators = true; 1539 } 1540 } 1541 1542 if (this.environment.usePartial) { 1543 ret.usePartial = true; 1544 } 1545 if (this.options.data) { 1546 ret.useData = true; 1547 } 1548 if (this.useDepths) { 1549 ret.useDepths = true; 1550 } 1551 if (this.useBlockParams) { 1552 ret.useBlockParams = true; 1553 } 1554 if (this.options.compat) { 1555 ret.compat = true; 1556 } 1557 1558 if (!asObject) { 1559 ret.compiler = JSON.stringify(ret.compiler); 1560 1561 this.source.currentLocation = { start: { line: 1, column: 0 } }; 1562 ret = this.objectLiteral(ret); 1563 1564 if (options.srcName) { 1565 ret = ret.toStringWithSourceMap({ file: options.destName }); 1566 ret.map = ret.map && ret.map.toString(); 1567 } else { 1568 ret = ret.toString(); 1569 } 1570 } else { 1571 ret.compilerOptions = this.options; 1572 } 1573 1574 return ret; 1575 } else { 1576 return fn; 1577 } 1578 }, 1579 1580 preamble: function preamble() { 1581 // track the last context pushed into place to allow skipping the 1582 // getContext opcode when it would be a noop 1583 this.lastContext = 0; 1584 this.source = new _codeGen2['default'](this.options.srcName); 1585 this.decorators = new _codeGen2['default'](this.options.srcName); 1586 }, 1587 1588 createFunctionContext: function createFunctionContext(asObject) { 1589 // istanbul ignore next 1590 1591 var _this = this; 1592 1593 var varDeclarations = ''; 1594 1595 var locals = this.stackVars.concat(this.registers.list); 1596 if (locals.length > 0) { 1597 varDeclarations += ', ' + locals.join(', '); 1598 } 1599 1600 // Generate minimizer alias mappings 1601 // 1602 // When using true SourceNodes, this will update all references to the given alias 1603 // as the source nodes are reused in situ. For the non-source node compilation mode, 1604 // aliases will not be used, but this case is already being run on the client and 1605 // we aren't concern about minimizing the template size. 1606 var aliasCount = 0; 1607 Object.keys(this.aliases).forEach(function (alias) { 1608 var node = _this.aliases[alias]; 1609 if (node.children && node.referenceCount > 1) { 1610 varDeclarations += ', alias' + ++aliasCount + '=' + alias; 1611 node.children[0] = 'alias' + aliasCount; 1612 } 1613 }); 1614 1615 if (this.lookupPropertyFunctionIsUsed) { 1616 varDeclarations += ', ' + this.lookupPropertyFunctionVarDeclaration(); 1617 } 1618 1619 var params = ['container', 'depth0', 'helpers', 'partials', 'data']; 1620 1621 if (this.useBlockParams || this.useDepths) { 1622 params.push('blockParams'); 1623 } 1624 if (this.useDepths) { 1625 params.push('depths'); 1626 } 1627 1628 // Perform a second pass over the output to merge content when possible 1629 var source = this.mergeSource(varDeclarations); 1630 1631 if (asObject) { 1632 params.push(source); 1633 1634 return Function.apply(this, params); 1635 } else { 1636 return this.source.wrap(['function(', params.join(','), ') {\n ', source, '}']); 1637 } 1638 }, 1639 mergeSource: function mergeSource(varDeclarations) { 1640 var isSimple = this.environment.isSimple, 1641 appendOnly = !this.forceBuffer, 1642 appendFirst = undefined, 1643 sourceSeen = undefined, 1644 bufferStart = undefined, 1645 bufferEnd = undefined; 1646 this.source.each(function (line) { 1647 if (line.appendToBuffer) { 1648 if (bufferStart) { 1649 line.prepend(' + '); 1650 } else { 1651 bufferStart = line; 1652 } 1653 bufferEnd = line; 1654 } else { 1655 if (bufferStart) { 1656 if (!sourceSeen) { 1657 appendFirst = true; 1658 } else { 1659 bufferStart.prepend('buffer += '); 1660 } 1661 bufferEnd.add(';'); 1662 bufferStart = bufferEnd = undefined; 1663 } 1664 1665 sourceSeen = true; 1666 if (!isSimple) { 1667 appendOnly = false; 1668 } 1669 } 1670 }); 1671 1672 if (appendOnly) { 1673 if (bufferStart) { 1674 bufferStart.prepend('return '); 1675 bufferEnd.add(';'); 1676 } else if (!sourceSeen) { 1677 this.source.push('return "";'); 1678 } 1679 } else { 1680 varDeclarations += ', buffer = ' + (appendFirst ? '' : this.initializeBuffer()); 1681 1682 if (bufferStart) { 1683 bufferStart.prepend('return buffer + '); 1684 bufferEnd.add(';'); 1685 } else { 1686 this.source.push('return buffer;'); 1687 } 1688 } 1689 1690 if (varDeclarations) { 1691 this.source.prepend('var ' + varDeclarations.substring(2) + (appendFirst ? '' : ';\n')); 1692 } 1693 1694 return this.source.merge(); 1695 }, 1696 1697 lookupPropertyFunctionVarDeclaration: function lookupPropertyFunctionVarDeclaration() { 1698 return '\n lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n }\n '.trim(); 1699 }, 1700 1701 // [blockValue] 1702 // 1703 // On stack, before: hash, inverse, program, value 1704 // On stack, after: return value of blockHelperMissing 1705 // 1706 // The purpose of this opcode is to take a block of the form 1707 // `{{#this.foo}}...{{/this.foo}}`, resolve the value of `foo`, and 1708 // replace it on the stack with the result of properly 1709 // invoking blockHelperMissing. 1710 blockValue: function blockValue(name) { 1711 var blockHelperMissing = this.aliasable('container.hooks.blockHelperMissing'), 1712 params = [this.contextName(0)]; 1713 this.setupHelperArgs(name, 0, params); 1714 1715 var blockName = this.popStack(); 1716 params.splice(1, 0, blockName); 1717 1718 this.push(this.source.functionCall(blockHelperMissing, 'call', params)); 1719 }, 1720 1721 // [ambiguousBlockValue] 1722 // 1723 // On stack, before: hash, inverse, program, value 1724 // Compiler value, before: lastHelper=value of last found helper, if any 1725 // On stack, after, if no lastHelper: same as [blockValue] 1726 // On stack, after, if lastHelper: value 1727 ambiguousBlockValue: function ambiguousBlockValue() { 1728 // We're being a bit cheeky and reusing the options value from the prior exec 1729 var blockHelperMissing = this.aliasable('container.hooks.blockHelperMissing'), 1730 params = [this.contextName(0)]; 1731 this.setupHelperArgs('', 0, params, true); 1732 1733 this.flushInline(); 1734 1735 var current = this.topStack(); 1736 params.splice(1, 0, current); 1737 1738 this.pushSource(['if (!', this.lastHelper, ') { ', current, ' = ', this.source.functionCall(blockHelperMissing, 'call', params), '}']); 1739 }, 1740 1741 // [appendContent] 1742 // 1743 // On stack, before: ... 1744 // On stack, after: ... 1745 // 1746 // Appends the string value of `content` to the current buffer 1747 appendContent: function appendContent(content) { 1748 if (this.pendingContent) { 1749 content = this.pendingContent + content; 1750 } else { 1751 this.pendingLocation = this.source.currentLocation; 1752 } 1753 1754 this.pendingContent = content; 1755 }, 1756 1757 // [append] 1758 // 1759 // On stack, before: value, ... 1760 // On stack, after: ... 1761 // 1762 // Coerces `value` to a String and appends it to the current buffer. 1763 // 1764 // If `value` is truthy, or 0, it is coerced into a string and appended 1765 // Otherwise, the empty string is appended 1766 append: function append() { 1767 if (this.isInline()) { 1768 this.replaceStack(function (current) { 1769 return [' != null ? ', current, ' : ""']; 1770 }); 1771 1772 this.pushSource(this.appendToBuffer(this.popStack())); 1773 } else { 1774 var local = this.popStack(); 1775 this.pushSource(['if (', local, ' != null) { ', this.appendToBuffer(local, undefined, true), ' }']); 1776 if (this.environment.isSimple) { 1777 this.pushSource(['else { ', this.appendToBuffer("''", undefined, true), ' }']); 1778 } 1779 } 1780 }, 1781 1782 // [appendEscaped] 1783 // 1784 // On stack, before: value, ... 1785 // On stack, after: ... 1786 // 1787 // Escape `value` and append it to the buffer 1788 appendEscaped: function appendEscaped() { 1789 this.pushSource(this.appendToBuffer([this.aliasable('container.escapeExpression'), '(', this.popStack(), ')'])); 1790 }, 1791 1792 // [getContext] 1793 // 1794 // On stack, before: ... 1795 // On stack, after: ... 1796 // Compiler value, after: lastContext=depth 1797 // 1798 // Set the value of the `lastContext` compiler value to the depth 1799 getContext: function getContext(depth) { 1800 this.lastContext = depth; 1801 }, 1802 1803 // [pushContext] 1804 // 1805 // On stack, before: ... 1806 // On stack, after: currentContext, ... 1807 // 1808 // Pushes the value of the current context onto the stack. 1809 pushContext: function pushContext() { 1810 this.pushStackLiteral(this.contextName(this.lastContext)); 1811 }, 1812 1813 // [lookupOnContext] 1814 // 1815 // On stack, before: ... 1816 // On stack, after: currentContext[name], ... 1817 // 1818 // Looks up the value of `name` on the current context and pushes 1819 // it onto the stack. 1820 lookupOnContext: function lookupOnContext(parts, falsy, strict, scoped) { 1821 var i = 0; 1822 1823 if (!scoped && this.options.compat && !this.lastContext) { 1824 // The depthed query is expected to handle the undefined logic for the root level that 1825 // is implemented below, so we evaluate that directly in compat mode 1826 this.push(this.depthedLookup(parts[i++])); 1827 } else { 1828 this.pushContext(); 1829 } 1830 1831 this.resolvePath('context', parts, i, falsy, strict); 1832 }, 1833 1834 // [lookupBlockParam] 1835 // 1836 // On stack, before: ... 1837 // On stack, after: blockParam[name], ... 1838 // 1839 // Looks up the value of `parts` on the given block param and pushes 1840 // it onto the stack. 1841 lookupBlockParam: function lookupBlockParam(blockParamId, parts) { 1842 this.useBlockParams = true; 1843 1844 this.push(['blockParams[', blockParamId[0], '][', blockParamId[1], ']']); 1845 this.resolvePath('context', parts, 1); 1846 }, 1847 1848 // [lookupData] 1849 // 1850 // On stack, before: ... 1851 // On stack, after: data, ... 1852 // 1853 // Push the data lookup operator 1854 lookupData: function lookupData(depth, parts, strict) { 1855 if (!depth) { 1856 this.pushStackLiteral('data'); 1857 } else { 1858 this.pushStackLiteral('container.data(data, ' + depth + ')'); 1859 } 1860 1861 this.resolvePath('data', parts, 0, true, strict); 1862 }, 1863 1864 resolvePath: function resolvePath(type, parts, startPartIndex, falsy, strict) { 1865 // istanbul ignore next 1866 1867 var _this2 = this; 1868 1869 if (this.options.strict || this.options.assumeObjects) { 1870 this.push(strictLookup(this.options.strict && strict, this, parts, startPartIndex, type)); 1871 return; 1872 } 1873 1874 var len = parts.length; 1875 1876 var _loop = function (i) { 1877 /* eslint-disable no-loop-func */ 1878 _this2.replaceStack(function (current) { 1879 var lookup = _this2.nameLookup(current, parts[i], type); 1880 // We want to ensure that zero and false are handled properly if the context (falsy flag) 1881 // needs to have the special handling for these values. 1882 if (!falsy) { 1883 return [' != null ? ', lookup, ' : ', current]; 1884 } else { 1885 // Otherwise we can use generic falsy handling 1886 return [' && ', lookup]; 1887 } 1888 }); 1889 /* eslint-enable no-loop-func */ 1890 }; 1891 1892 for (var i = startPartIndex; i < len; i++) { 1893 _loop(i); 1894 } 1895 }, 1896 1897 // [resolvePossibleLambda] 1898 // 1899 // On stack, before: value, ... 1900 // On stack, after: resolved value, ... 1901 // 1902 // If the `value` is a lambda, replace it on the stack by 1903 // the return value of the lambda 1904 resolvePossibleLambda: function resolvePossibleLambda() { 1905 this.push([this.aliasable('container.lambda'), '(', this.popStack(), ', ', this.contextName(0), ')']); 1906 }, 1907 1908 // [pushStringParam] 1909 // 1910 // On stack, before: ... 1911 // On stack, after: string, currentContext, ... 1912 // 1913 // This opcode is designed for use in string mode, which 1914 // provides the string value of a parameter along with its 1915 // depth rather than resolving it immediately. 1916 pushStringParam: function pushStringParam(string, type) { 1917 this.pushContext(); 1918 this.pushString(type); 1919 1920 // If it's a subexpression, the string result 1921 // will be pushed after this opcode. 1922 if (type !== 'SubExpression') { 1923 if (typeof string === 'string') { 1924 this.pushString(string); 1925 } else { 1926 this.pushStackLiteral(string); 1927 } 1928 } 1929 }, 1930 1931 emptyHash: function emptyHash(omitEmpty) { 1932 if (this.trackIds) { 1933 this.push('{}'); // hashIds 1934 } 1935 if (this.stringParams) { 1936 this.push('{}'); // hashContexts 1937 this.push('{}'); // hashTypes 1938 } 1939 this.pushStackLiteral(omitEmpty ? 'undefined' : '{}'); 1940 }, 1941 pushHash: function pushHash() { 1942 if (this.hash) { 1943 this.hashes.push(this.hash); 1944 } 1945 this.hash = { values: {}, types: [], contexts: [], ids: [] }; 1946 }, 1947 popHash: function popHash() { 1948 var hash = this.hash; 1949 this.hash = this.hashes.pop(); 1950 1951 if (this.trackIds) { 1952 this.push(this.objectLiteral(hash.ids)); 1953 } 1954 if (this.stringParams) { 1955 this.push(this.objectLiteral(hash.contexts)); 1956 this.push(this.objectLiteral(hash.types)); 1957 } 1958 1959 this.push(this.objectLiteral(hash.values)); 1960 }, 1961 1962 // [pushString] 1963 // 1964 // On stack, before: ... 1965 // On stack, after: quotedString(string), ... 1966 // 1967 // Push a quoted version of `string` onto the stack 1968 pushString: function pushString(string) { 1969 this.pushStackLiteral(this.quotedString(string)); 1970 }, 1971 1972 // [pushLiteral] 1973 // 1974 // On stack, before: ... 1975 // On stack, after: value, ... 1976 // 1977 // Pushes a value onto the stack. This operation prevents 1978 // the compiler from creating a temporary variable to hold 1979 // it. 1980 pushLiteral: function pushLiteral(value) { 1981 this.pushStackLiteral(value); 1982 }, 1983 1984 // [pushProgram] 1985 // 1986 // On stack, before: ... 1987 // On stack, after: program(guid), ... 1988 // 1989 // Push a program expression onto the stack. This takes 1990 // a compile-time guid and converts it into a runtime-accessible 1991 // expression. 1992 pushProgram: function pushProgram(guid) { 1993 if (guid != null) { 1994 this.pushStackLiteral(this.programExpression(guid)); 1995 } else { 1996 this.pushStackLiteral(null); 1997 } 1998 }, 1999 2000 // [registerDecorator] 2001 // 2002 // On stack, before: hash, program, params..., ... 2003 // On stack, after: ... 2004 // 2005 // Pops off the decorator's parameters, invokes the decorator, 2006 // and inserts the decorator into the decorators list. 2007 registerDecorator: function registerDecorator(paramSize, name) { 2008 var foundDecorator = this.nameLookup('decorators', name, 'decorator'), 2009 options = this.setupHelperArgs(name, paramSize); 2010 2011 // Store the resolved decorator in a variable and verify it is a function before 2012 // calling it. Without this, unregistered decorators can cause an unhandled TypeError 2013 // (calling undefined), which crashes the process â enabling Denial of Service. 2014 this.decorators.push(['var decorator = ', foundDecorator, ';']); 2015 this.decorators.push(['if (typeof decorator !== "function") { throw new Error(', this.quotedString('Missing decorator: "' + name + '"'), '); }']); 2016 this.decorators.push(['fn = ', this.decorators.functionCall('decorator', '', ['fn', 'props', 'container', options]), ' || fn;']); 2017 }, 2018 2019 // [invokeHelper] 2020 // 2021 // On stack, before: hash, inverse, program, params..., ... 2022 // On stack, after: result of helper invocation 2023 // 2024 // Pops off the helper's parameters, invokes the helper, 2025 // and pushes the helper's return value onto the stack. 2026 // 2027 // If the helper is not found, `helperMissing` is called. 2028 invokeHelper: function invokeHelper(paramSize, name, isSimple) { 2029 var nonHelper = this.popStack(), 2030 helper = this.setupHelper(paramSize, name); 2031 2032 var possibleFunctionCalls = []; 2033 2034 if (isSimple) { 2035 // direct call to helper 2036 possibleFunctionCalls.push(helper.name); 2037 } 2038 // call a function from the input object 2039 possibleFunctionCalls.push(nonHelper); 2040 if (!this.options.strict) { 2041 possibleFunctionCalls.push(this.aliasable('container.hooks.helperMissing')); 2042 } 2043 2044 var functionLookupCode = ['(', this.itemsSeparatedBy(possibleFunctionCalls, '||'), ')']; 2045 var functionCall = this.source.functionCall(functionLookupCode, 'call', helper.callParams); 2046 this.push(functionCall); 2047 }, 2048 2049 itemsSeparatedBy: function itemsSeparatedBy(items, separator) { 2050 var result = []; 2051 result.push(items[0]); 2052 for (var i = 1; i < items.length; i++) { 2053 result.push(separator, items[i]); 2054 } 2055 return result; 2056 }, 2057 // [invokeKnownHelper] 2058 // 2059 // On stack, before: hash, inverse, program, params..., ... 2060 // On stack, after: result of helper invocation 2061 // 2062 // This operation is used when the helper is known to exist, 2063 // so a `helperMissing` fallback is not required. 2064 invokeKnownHelper: function invokeKnownHelper(paramSize, name) { 2065 var helper = this.setupHelper(paramSize, name); 2066 this.push(this.source.functionCall(helper.name, 'call', helper.callParams)); 2067 }, 2068 2069 // [invokeAmbiguous] 2070 // 2071 // On stack, before: hash, inverse, program, params..., ... 2072 // On stack, after: result of disambiguation 2073 // 2074 // This operation is used when an expression like `{{foo}}` 2075 // is provided, but we don't know at compile-time whether it 2076 // is a helper or a path. 2077 // 2078 // This operation emits more code than the other options, 2079 // and can be avoided by passing the `knownHelpers` and 2080 // `knownHelpersOnly` flags at compile-time. 2081 invokeAmbiguous: function invokeAmbiguous(name, helperCall) { 2082 this.useRegister('helper'); 2083 2084 var nonHelper = this.popStack(); 2085 2086 this.emptyHash(); 2087 var helper = this.setupHelper(0, name, helperCall); 2088 2089 var helperName = this.lastHelper = this.nameLookup('helpers', name, 'helper'); 2090 2091 var lookup = ['(', '(helper = ', helperName, ' || ', nonHelper, ')']; 2092 if (!this.options.strict) { 2093 lookup[0] = '(helper = '; 2094 lookup.push(' != null ? helper : ', this.aliasable('container.hooks.helperMissing')); 2095 } 2096 2097 this.push(['(', lookup, helper.paramsInit ? ['),(', helper.paramsInit] : [], '),', '(typeof helper === ', this.aliasable('"function"'), ' ? ', this.source.functionCall('helper', 'call', helper.callParams), ' : helper))']); 2098 }, 2099 2100 // [invokePartial] 2101 // 2102 // On stack, before: context, ... 2103 // On stack after: result of partial invocation 2104 // 2105 // This operation pops off a context, invokes a partial with that context, 2106 // and pushes the result of the invocation back. 2107 invokePartial: function invokePartial(isDynamic, name, indent) { 2108 var params = [], 2109 options = this.setupParams(name, 1, params); 2110 2111 if (isDynamic) { 2112 name = this.popStack(); 2113 delete options.name; 2114 } 2115 2116 if (indent) { 2117 options.indent = JSON.stringify(indent); 2118 } 2119 options.helpers = 'helpers'; 2120 options.partials = 'partials'; 2121 options.decorators = 'container.decorators'; 2122 2123 if (!isDynamic) { 2124 params.unshift(this.nameLookup('partials', name, 'partial')); 2125 } else { 2126 params.unshift(name); 2127 } 2128 2129 if (this.options.compat) { 2130 options.depths = 'depths'; 2131 } 2132 options = this.objectLiteral(options); 2133 params.push(options); 2134 2135 this.push(this.source.functionCall('container.invokePartial', '', params)); 2136 }, 2137 2138 // [assignToHash] 2139 // 2140 // On stack, before: value, ..., hash, ... 2141 // On stack, after: ..., hash, ... 2142 // 2143 // Pops a value off the stack and assigns it to the current hash 2144 assignToHash: function assignToHash(key) { 2145 var value = this.popStack(), 2146 context = undefined, 2147 type = undefined, 2148 id = undefined; 2149 2150 if (this.trackIds) { 2151 id = this.popStack(); 2152 } 2153 if (this.stringParams) { 2154 type = this.popStack(); 2155 context = this.popStack(); 2156 } 2157 2158 var hash = this.hash; 2159 if (context) { 2160 hash.contexts[key] = context; 2161 } 2162 if (type) { 2163 hash.types[key] = type; 2164 } 2165 if (id) { 2166 hash.ids[key] = id; 2167 } 2168 hash.values[key] = value; 2169 }, 2170 2171 pushId: function pushId(type, name, child) { 2172 if (type === 'BlockParam') { 2173 this.pushStackLiteral('blockParams[' + name[0] + '].path[' + name[1] + ']' + (child ? ' + ' + JSON.stringify('.' + child) : '')); 2174 } else if (type === 'PathExpression') { 2175 this.pushString(name); 2176 } else if (type === 'SubExpression') { 2177 this.pushStackLiteral('true'); 2178 } else { 2179 this.pushStackLiteral('null'); 2180 } 2181 }, 2182 2183 // HELPERS 2184 2185 compiler: JavaScriptCompiler, 2186 2187 compileChildren: function compileChildren(environment, options) { 2188 var children = environment.children, 2189 child = undefined, 2190 compiler = undefined; 2191 2192 for (var i = 0, l = children.length; i < l; i++) { 2193 child = children[i]; 2194 compiler = new this.compiler(); // eslint-disable-line new-cap 2195 2196 var existing = this.matchExistingProgram(child); 2197 2198 if (existing == null) { 2199 // Placeholder to prevent name conflicts for nested children 2200 var index = this.context.programs.push('') - 1; 2201 child.index = index; 2202 child.name = 'program' + index; 2203 this.context.programs[index] = compiler.compile(child, options, this.context, !this.precompile); 2204 this.context.decorators[index] = compiler.decorators; 2205 this.context.environments[index] = child; 2206 2207 this.useDepths = this.useDepths || compiler.useDepths; 2208 this.useBlockParams = this.useBlockParams || compiler.useBlockParams; 2209 child.useDepths = this.useDepths; 2210 child.useBlockParams = this.useBlockParams; 2211 } else { 2212 child.index = existing.index; 2213 child.name = 'program' + existing.index; 2214 2215 this.useDepths = this.useDepths || existing.useDepths; 2216 this.useBlockParams = this.useBlockParams || existing.useBlockParams; 2217 } 2218 } 2219 }, 2220 matchExistingProgram: function matchExistingProgram(child) { 2221 for (var i = 0, len = this.context.environments.length; i < len; i++) { 2222 var environment = this.context.environments[i]; 2223 if (environment && environment.equals(child)) { 2224 return environment; 2225 } 2226 } 2227 }, 2228 2229 programExpression: function programExpression(guid) { 2230 var child = this.environment.children[guid], 2231 programParams = [child.index, 'data', child.blockParams]; 2232 2233 if (this.useBlockParams || this.useDepths) { 2234 programParams.push('blockParams'); 2235 } 2236 if (this.useDepths) { 2237 programParams.push('depths'); 2238 } 2239 2240 return 'container.program(' + programParams.join(', ') + ')'; 2241 }, 2242 2243 useRegister: function useRegister(name) { 2244 if (!this.registers[name]) { 2245 this.registers[name] = true; 2246 this.registers.list.push(name); 2247 } 2248 }, 2249 2250 push: function push(expr) { 2251 if (!(expr instanceof Literal)) { 2252 expr = this.source.wrap(expr); 2253 } 2254 2255 this.inlineStack.push(expr); 2256 return expr; 2257 }, 2258 2259 pushStackLiteral: function pushStackLiteral(item) { 2260 this.push(new Literal(item)); 2261 }, 2262 2263 pushSource: function pushSource(source) { 2264 if (this.pendingContent) { 2265 this.source.push(this.appendToBuffer(this.source.quotedString(this.pendingContent), this.pendingLocation)); 2266 this.pendingContent = undefined; 2267 } 2268 2269 if (source) { 2270 this.source.push(source); 2271 } 2272 }, 2273 2274 replaceStack: function replaceStack(callback) { 2275 var prefix = ['('], 2276 stack = undefined, 2277 createdStack = undefined, 2278 usedLiteral = undefined; 2279 2280 /* istanbul ignore next */ 2281 if (!this.isInline()) { 2282 throw new _exception2['default']('replaceStack on non-inline'); 2283 } 2284 2285 // We want to merge the inline statement into the replacement statement via ',' 2286 var top = this.popStack(true); 2287 2288 if (top instanceof Literal) { 2289 // Literals do not need to be inlined 2290 stack = [top.value]; 2291 prefix = ['(', stack]; 2292 usedLiteral = true; 2293 } else { 2294 // Get or create the current stack name for use by the inline 2295 createdStack = true; 2296 var _name = this.incrStack(); 2297 2298 prefix = ['((', this.push(_name), ' = ', top, ')']; 2299 stack = this.topStack(); 2300 } 2301 2302 var item = callback.call(this, stack); 2303 2304 if (!usedLiteral) { 2305 this.popStack(); 2306 } 2307 if (createdStack) { 2308 this.stackSlot--; 2309 } 2310 this.push(prefix.concat(item, ')')); 2311 }, 2312 2313 incrStack: function incrStack() { 2314 this.stackSlot++; 2315 if (this.stackSlot > this.stackVars.length) { 2316 this.stackVars.push('stack' + this.stackSlot); 2317 } 2318 return this.topStackName(); 2319 }, 2320 topStackName: function topStackName() { 2321 return 'stack' + this.stackSlot; 2322 }, 2323 flushInline: function flushInline() { 2324 var inlineStack = this.inlineStack; 2325 this.inlineStack = []; 2326 for (var i = 0, len = inlineStack.length; i < len; i++) { 2327 var entry = inlineStack[i]; 2328 /* istanbul ignore if */ 2329 if (entry instanceof Literal) { 2330 this.compileStack.push(entry); 2331 } else { 2332 var stack = this.incrStack(); 2333 this.pushSource([stack, ' = ', entry, ';']); 2334 this.compileStack.push(stack); 2335 } 2336 } 2337 }, 2338 isInline: function isInline() { 2339 return this.inlineStack.length; 2340 }, 2341 2342 popStack: function popStack(wrapped) { 2343 var inline = this.isInline(), 2344 item = (inline ? this.inlineStack : this.compileStack).pop(); 2345 2346 if (!wrapped && item instanceof Literal) { 2347 return item.value; 2348 } else { 2349 if (!inline) { 2350 /* istanbul ignore next */ 2351 if (!this.stackSlot) { 2352 throw new _exception2['default']('Invalid stack pop'); 2353 } 2354 this.stackSlot--; 2355 } 2356 return item; 2357 } 2358 }, 2359 2360 topStack: function topStack() { 2361 var stack = this.isInline() ? this.inlineStack : this.compileStack, 2362 item = stack[stack.length - 1]; 2363 2364 /* istanbul ignore if */ 2365 if (item instanceof Literal) { 2366 return item.value; 2367 } else { 2368 return item; 2369 } 2370 }, 2371 2372 contextName: function contextName(context) { 2373 if (this.useDepths && context) { 2374 return 'depths[' + context + ']'; 2375 } else { 2376 return 'depth' + context; 2377 } 2378 }, 2379 2380 quotedString: function quotedString(str) { 2381 return this.source.quotedString(str); 2382 }, 2383 2384 objectLiteral: function objectLiteral(obj) { 2385 return this.source.objectLiteral(obj); 2386 }, 2387 2388 aliasable: function aliasable(name) { 2389 var ret = this.aliases[name]; 2390 if (ret) { 2391 ret.referenceCount++; 2392 return ret; 2393 } 2394 2395 ret = this.aliases[name] = this.source.wrap(name); 2396 ret.aliasable = true; 2397 ret.referenceCount = 1; 2398 2399 return ret; 2400 }, 2401 2402 setupHelper: function setupHelper(paramSize, name, blockHelper) { 2403 var params = [], 2404 paramsInit = this.setupHelperArgs(name, paramSize, params, blockHelper); 2405 var foundHelper = this.nameLookup('helpers', name, 'helper'), 2406 callContext = this.aliasable(this.contextName(0) + ' != null ? ' + this.contextName(0) + ' : (container.nullContext || {})'); 2407 2408 return { 2409 params: params, 2410 paramsInit: paramsInit, 2411 name: foundHelper, 2412 callParams: [callContext].concat(params) 2413 }; 2414 }, 2415 2416 setupParams: function setupParams(helper, paramSize, params) { 2417 var options = {}, 2418 contexts = [], 2419 types = [], 2420 ids = [], 2421 objectArgs = !params, 2422 param = undefined; 2423 2424 if (objectArgs) { 2425 params = []; 2426 } 2427 2428 options.name = this.quotedString(helper); 2429 options.hash = this.popStack(); 2430 2431 if (this.trackIds) { 2432 options.hashIds = this.popStack(); 2433 } 2434 if (this.stringParams) { 2435 options.hashTypes = this.popStack(); 2436 options.hashContexts = this.popStack(); 2437 } 2438 2439 var inverse = this.popStack(), 2440 program = this.popStack(); 2441 2442 // Avoid setting fn and inverse if neither are set. This allows 2443 // helpers to do a check for `if (options.fn)` 2444 if (program || inverse) { 2445 options.fn = program || 'container.noop'; 2446 options.inverse = inverse || 'container.noop'; 2447 } 2448 2449 // The parameters go on to the stack in order (making sure that they are evaluated in order) 2450 // so we need to pop them off the stack in reverse order 2451 var i = paramSize; 2452 while (i--) { 2453 param = this.popStack(); 2454 params[i] = param; 2455 2456 if (this.trackIds) { 2457 ids[i] = this.popStack(); 2458 } 2459 if (this.stringParams) { 2460 types[i] = this.popStack(); 2461 contexts[i] = this.popStack(); 2462 } 2463 } 2464 2465 if (objectArgs) { 2466 options.args = this.source.generateArray(params); 2467 } 2468 2469 if (this.trackIds) { 2470 options.ids = this.source.generateArray(ids); 2471 } 2472 if (this.stringParams) { 2473 options.types = this.source.generateArray(types); 2474 options.contexts = this.source.generateArray(contexts); 2475 } 2476 2477 if (this.options.data) { 2478 options.data = 'data'; 2479 } 2480 if (this.useBlockParams) { 2481 options.blockParams = 'blockParams'; 2482 } 2483 return options; 2484 }, 2485 2486 setupHelperArgs: function setupHelperArgs(helper, paramSize, params, useRegister) { 2487 var options = this.setupParams(helper, paramSize, params); 2488 options.loc = JSON.stringify(this.source.currentLocation); 2489 options = this.objectLiteral(options); 2490 if (useRegister) { 2491 this.useRegister('options'); 2492 params.push('options'); 2493 return ['options=', options]; 2494 } else if (params) { 2495 params.push(options); 2496 return ''; 2497 } else { 2498 return options; 2499 } 2500 } 2501}; 2502 2503(function () { 2504 var reservedWords = ('break else new var' + ' case finally return void' + ' catch for switch while' + ' continue function this with' + ' default if throw' + ' delete in try' + ' do instanceof typeof' + ' abstract enum int short' + ' boolean export interface static' + ' byte extends long super' + ' char final native synchronized' + ' class float package throws' + ' const goto private transient' + ' debugger implements protected volatile' + ' double import public let yield await' + ' null true false').split(' '); 2505 2506 var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {}; 2507 2508 for (var i = 0, l = reservedWords.length; i < l; i++) { 2509 compilerWords[reservedWords[i]] = true; 2510 } 2511})(); 2512 2513/** 2514 * @deprecated May be removed in the next major version 2515 */ 2516JavaScriptCompiler.isValidJavaScriptVariableName = function (name) { 2517 return !JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(name); 2518}; 2519 2520function strictLookup(requireTerminal, compiler, parts, startPartIndex, type) { 2521 var stack = compiler.popStack(), 2522 len = parts.length; 2523 if (requireTerminal) { 2524 len--; 2525 } 2526 2527 for (var i = startPartIndex; i < len; i++) { 2528 stack = compiler.nameLookup(stack, parts[i], type); 2529 } 2530 2531 if (requireTerminal) { 2532 return [compiler.aliasable('container.strict'), '(', stack, ', ', compiler.quotedString(parts[len]), ', ', JSON.stringify(compiler.source.currentLocation), ' )']; 2533 } else { 2534 return stack; 2535 } 2536} 2537 2538exports['default'] = JavaScriptCompiler; 2539module.exports = exports['default'];
2540 2541 2542},{"../base":3,"../exception":15,"../utils":30,"./code-gen":6}],10:[function(require,module,exports){ 2543// File ignored in coverage tests via setting in .istanbul.yml 2544/* Jison generated parser */ 2545"use strict"; 2546 2547exports.__esModule = true; 2548var handlebars = (function () { 2549 var parser = { trace: function trace() {}, 2550 yy: {}, 2551 symbols_: { "error": 2, "root": 3, "program": 4, "EOF": 5, "program_repetition0": 6, "statement": 7, "mustache": 8, "block": 9, "rawBlock": 10, "partial": 11, "partialBlock": 12, "content": 13, "COMMENT": 14, "CONTENT": 15, "openRawBlock": 16, "rawBlock_repetition0": 17, "END_RAW_BLOCK": 18, "OPEN_RAW_BLOCK": 19, "helperName": 20, "openRawBlock_repetition0": 21, "openRawBlock_option0": 22, "CLOSE_RAW_BLOCK": 23, "openBlock": 24, "block_option0": 25, "closeBlock": 26, "openInverse": 27, "block_option1": 28, "OPEN_BLOCK": 29, "openBlock_repetition0": 30, "openBlock_option0": 31, "openBlock_option1": 32, "CLOSE": 33, "OPEN_INVERSE": 34, "openInverse_repetition0": 35, "openInverse_option0": 36, "openInverse_option1": 37, "openInverseChain": 38, "OPEN_INVERSE_CHAIN": 39, "openInverseChain_repetition0": 40, "openInverseChain_option0": 41, "openInverseChain_option1": 42, "inverseAndProgram": 43, "INVERSE": 44, "inverseChain": 45, "inverseChain_option0": 46, "OPEN_ENDBLOCK": 47, "OPEN": 48, "mustache_repetition0": 49, "mustache_option0": 50, "OPEN_UNESCAPED": 51, "mustache_repetition1": 52, "mustache_option1": 53, "CLOSE_UNESCAPED": 54, "OPEN_PARTIAL": 55, "partialName": 56, "partial_repetition0": 57, "partial_option0": 58, "openPartialBlock": 59, "OPEN_PARTIAL_BLOCK": 60, "openPartialBlock_repetition0": 61, "openPartialBlock_option0": 62, "param": 63, "sexpr": 64, "OPEN_SEXPR": 65, "sexpr_repetition0": 66, "sexpr_option0": 67, "CLOSE_SEXPR": 68, "hash": 69, "hash_repetition_plus0": 70, "hashSegment": 71, "ID": 72, "EQUALS": 73, "blockParams": 74, "OPEN_BLOCK_PARAMS": 75, "blockParams_repetition_plus0": 76, "CLOSE_BLOCK_PARAMS": 77, "path": 78, "dataName": 79, "STRING": 80, "NUMBER": 81, "BOOLEAN": 82, "UNDEFINED": 83, "NULL": 84, "DATA": 85, "pathSegments": 86, "SEP": 87, "$accept": 0, "$end": 1 }, 2552 terminals_: { 2: "error", 5: "EOF", 14: "COMMENT", 15: "CONTENT", 18: "END_RAW_BLOCK", 19: "OPEN_RAW_BLOCK", 23: "CLOSE_RAW_BLOCK", 29: "OPEN_BLOCK", 33: "CLOSE", 34: "OPEN_INVERSE", 39: "OPEN_INVERSE_CHAIN", 44: "INVERSE", 47: "OPEN_ENDBLOCK", 48: "OPEN", 51: "OPEN_UNESCAPED", 54: "CLOSE_UNESCAPED", 55: "OPEN_PARTIAL", 60: "OPEN_PARTIAL_BLOCK", 65: "OPEN_SEXPR", 68: "CLOSE_SEXPR", 72: "ID", 73: "EQUALS", 75: "OPEN_BLOCK_PARAMS", 77: "CLOSE_BLOCK_PARAMS", 80: "STRING", 81: "NUMBER", 82: "BOOLEAN", 83: "UNDEFINED", 84: "NULL", 85: "DATA", 87: "SEP" }, 2553 productions_: [0, [3, 2], [4, 1], [7, 1], [7, 1], [7, 1], [7, 1], [7, 1], [7, 1], [7, 1], [13, 1], [10, 3], [16, 5], [9, 4], [9, 4], [24, 6], [27, 6], [38, 6], [43, 2], [45, 3], [45, 1], [26, 3], [8, 5], [8, 5], [11, 5], [12, 3], [59, 5], [63, 1], [63, 1], [64, 5], [69, 1], [71, 3], [74, 3], [20, 1], [20, 1], [20, 1], [20, 1], [20, 1], [20, 1], [20, 1], [56, 1], [56, 1], [79, 2], [78, 1], [86, 3], [86, 1], [6, 0], [6, 2], [17, 0], [17, 2], [21, 0], [21, 2], [22, 0], [22, 1], [25, 0], [25, 1], [28, 0], [28, 1], [30, 0], [30, 2], [31, 0], [31, 1], [32, 0], [32, 1], [35, 0], [35, 2], [36, 0], [36, 1], [37, 0], [37, 1], [40, 0], [40, 2], [41, 0], [41, 1], [42, 0], [42,
vendor: 9,979 bytes, lines 2553-2806
25531], [46, 0], [46, 1], [49, 0], [49, 2], [50, 0], [50, 1], [52, 0], [52, 2], [53, 0], [53, 1], [57, 0], [57, 2], [58, 0], [58, 1], [61, 0], [61, 2], [62, 0], [62, 1], [66, 0], [66, 2], [67, 0], [67, 1], [70, 1], [70, 2], [76, 1], [76, 2]], 2554 performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { 2555 2556 var $0 = $$.length - 1; 2557 switch (yystate) { 2558 case 1: 2559 return $$[$0 - 1]; 2560 break; 2561 case 2: 2562 this.$ = yy.prepareProgram($$[$0]); 2563 break; 2564 case 3: 2565 this.$ = $$[$0]; 2566 break; 2567 case 4: 2568 this.$ = $$[$0]; 2569 break; 2570 case 5: 2571 this.$ = $$[$0]; 2572 break; 2573 case 6: 2574 this.$ = $$[$0]; 2575 break; 2576 case 7: 2577 this.$ = $$[$0]; 2578 break; 2579 case 8: 2580 this.$ = $$[$0]; 2581 break; 2582 case 9: 2583 this.$ = { 2584 type: 'CommentStatement', 2585 value: yy.stripComment($$[$0]), 2586 strip: yy.stripFlags($$[$0], $$[$0]), 2587 loc: yy.locInfo(this._$) 2588 }; 2589 2590 break; 2591 case 10: 2592 this.$ = { 2593 type: 'ContentStatement', 2594 original: $$[$0], 2595 value: $$[$0], 2596 loc: yy.locInfo(this._$) 2597 }; 2598 2599 break; 2600 case 11: 2601 this.$ = yy.prepareRawBlock($$[$0 - 2], $$[$0 - 1], $$[$0], this._$); 2602 break; 2603 case 12: 2604 this.$ = { path: $$[$0 - 3], params: $$[$0 - 2], hash: $$[$0 - 1] }; 2605 break; 2606 case 13: 2607 this.$ = yy.prepareBlock($$[$0 - 3], $$[$0 - 2], $$[$0 - 1], $$[$0], false, this._$); 2608 break; 2609 case 14: 2610 this.$ = yy.prepareBlock($$[$0 - 3], $$[$0 - 2], $$[$0 - 1], $$[$0], true, this._$); 2611 break; 2612 case 15: 2613 this.$ = { open: $$[$0 - 5], path: $$[$0 - 4], params: $$[$0 - 3], hash: $$[$0 - 2], blockParams: $$[$0 - 1], strip: yy.stripFlags($$[$0 - 5], $$[$0]) }; 2614 break; 2615 case 16: 2616 this.$ = { path: $$[$0 - 4], params: $$[$0 - 3], hash: $$[$0 - 2], blockParams: $$[$0 - 1], strip: yy.stripFlags($$[$0 - 5], $$[$0]) }; 2617 break; 2618 case 17: 2619 this.$ = { path: $$[$0 - 4], params: $$[$0 - 3], hash: $$[$0 - 2], blockParams: $$[$0 - 1], strip: yy.stripFlags($$[$0 - 5], $$[$0]) }; 2620 break; 2621 case 18: 2622 this.$ = { strip: yy.stripFlags($$[$0 - 1], $$[$0 - 1]), program: $$[$0] }; 2623 break; 2624 case 19: 2625 var inverse = yy.prepareBlock($$[$0 - 2], $$[$0 - 1], $$[$0], $$[$0], false, this._$), 2626 program = yy.prepareProgram([inverse], $$[$0 - 1].loc); 2627 program.chained = true; 2628 2629 this.$ = { strip: $$[$0 - 2].strip, program: program, chain: true }; 2630 2631 break; 2632 case 20: 2633 this.$ = $$[$0]; 2634 break; 2635 case 21: 2636 this.$ = { path: $$[$0 - 1], strip: yy.stripFlags($$[$0 - 2], $$[$0]) }; 2637 break; 2638 case 22: 2639 this.$ = yy.prepareMustache($$[$0 - 3], $$[$0 - 2], $$[$0 - 1], $$[$0 - 4], yy.stripFlags($$[$0 - 4], $$[$0]), this._$); 2640 break; 2641 case 23: 2642 this.$ = yy.prepareMustache($$[$0 - 3], $$[$0 - 2], $$[$0 - 1], $$[$0 - 4], yy.stripFlags($$[$0 - 4], $$[$0]), this._$); 2643 break; 2644 case 24: 2645 this.$ = { 2646 type: 'PartialStatement', 2647 name: $$[$0 - 3], 2648 params: $$[$0 - 2], 2649 hash: $$[$0 - 1], 2650 indent: '', 2651 strip: yy.stripFlags($$[$0 - 4], $$[$0]), 2652 loc: yy.locInfo(this._$) 2653 }; 2654 2655 break; 2656 case 25: 2657 this.$ = yy.preparePartialBlock($$[$0 - 2], $$[$0 - 1], $$[$0], this._$); 2658 break; 2659 case 26: 2660 this.$ = { path: $$[$0 - 3], params: $$[$0 - 2], hash: $$[$0 - 1], strip: yy.stripFlags($$[$0 - 4], $$[$0]) }; 2661 break; 2662 case 27: 2663 this.$ = $$[$0]; 2664 break; 2665 case 28: 2666 this.$ = $$[$0]; 2667 break; 2668 case 29: 2669 this.$ = { 2670 type: 'SubExpression', 2671 path: $$[$0 - 3], 2672 params: $$[$0 - 2], 2673 hash: $$[$0 - 1], 2674 loc: yy.locInfo(this._$) 2675 }; 2676 2677 break; 2678 case 30: 2679 this.$ = { type: 'Hash', pairs: $$[$0], loc: yy.locInfo(this._$) }; 2680 break; 2681 case 31: 2682 this.$ = { type: 'HashPair', key: yy.id($$[$0 - 2]), value: $$[$0], loc: yy.locInfo(this._$) }; 2683 break; 2684 case 32: 2685 this.$ = yy.id($$[$0 - 1]); 2686 break; 2687 case 33: 2688 this.$ = $$[$0]; 2689 break; 2690 case 34: 2691 this.$ = $$[$0]; 2692 break; 2693 case 35: 2694 this.$ = { type: 'StringLiteral', value: $$[$0], original: $$[$0], loc: yy.locInfo(this._$) }; 2695 break; 2696 case 36: 2697 this.$ = { type: 'NumberLiteral', value: Number($$[$0]), original: Number($$[$0]), loc: yy.locInfo(this._$) }; 2698 break; 2699 case 37: 2700 this.$ = { type: 'BooleanLiteral', value: $$[$0] === 'true', original: $$[$0] === 'true', loc: yy.locInfo(this._$) }; 2701 break; 2702 case 38: 2703 this.$ = { type: 'UndefinedLiteral', original: undefined, value: undefined, loc: yy.locInfo(this._$) }; 2704 break; 2705 case 39: 2706 this.$ = { type: 'NullLiteral', original: null, value: null, loc: yy.locInfo(this._$) }; 2707 break; 2708 case 40: 2709 this.$ = $$[$0]; 2710 break; 2711 case 41: 2712 this.$ = $$[$0]; 2713 break; 2714 case 42: 2715 this.$ = yy.preparePath(true, $$[$0], this._$); 2716 break; 2717 case 43: 2718 this.$ = yy.preparePath(false, $$[$0], this._$); 2719 break; 2720 case 44: 2721 $$[$0 - 2].push({ part: yy.id($$[$0]), original: $$[$0], separator: $$[$0 - 1] });this.$ = $$[$0 - 2]; 2722 break; 2723 case 45: 2724 this.$ = [{ part: yy.id($$[$0]), original: $$[$0] }]; 2725 break; 2726 case 46: 2727 this.$ = []; 2728 break; 2729 case 47: 2730 $$[$0 - 1].push($$[$0]); 2731 break; 2732 case 48: 2733 this.$ = []; 2734 break; 2735 case 49: 2736 $$[$0 - 1].push($$[$0]); 2737 break; 2738 case 50: 2739 this.$ = []; 2740 break; 2741 case 51: 2742 $$[$0 - 1].push($$[$0]); 2743 break; 2744 case 58: 2745 this.$ = []; 2746 break; 2747 case 59: 2748 $$[$0 - 1].push($$[$0]); 2749 break; 2750 case 64: 2751 this.$ = []; 2752 break; 2753 case 65: 2754 $$[$0 - 1].push($$[$0]); 2755 break; 2756 case 70: 2757 this.$ = []; 2758 break; 2759 case 71: 2760 $$[$0 - 1].push($$[$0]); 2761 break; 2762 case 78: 2763 this.$ = []; 2764 break; 2765 case 79: 2766 $$[$0 - 1].push($$[$0]); 2767 break; 2768 case 82: 2769 this.$ = []; 2770 break; 2771 case 83: 2772 $$[$0 - 1].push($$[$0]); 2773 break; 2774 case 86: 2775 this.$ = []; 2776 break; 2777 case 87: 2778 $$[$0 - 1].push($$[$0]); 2779 break; 2780 case 90: 2781 this.$ = []; 2782 break; 2783 case 91: 2784 $$[$0 - 1].push($$[$0]); 2785 break; 2786 case 94: 2787 this.$ = []; 2788 break; 2789 case 95: 2790 $$[$0 - 1].push($$[$0]); 2791 break; 2792 case 98: 2793 this.$ = [$$[$0]]; 2794 break; 2795 case 99: 2796 $$[$0 - 1].push($$[$0]); 2797 break; 2798 case 100: 2799 this.$ = [$$[$0]]; 2800 break; 2801 case 101: 2802 $$[$0 - 1].push($$[$0]); 2803 break; 2804 } 2805 }, 2806
vendor: 11,456 bytes, line 2806
2806 table: [{ 3: 1, 4: 2, 5: [2, 46], 6: 3, 14: [2, 46], 15: [2, 46], 19: [2, 46], 29: [2, 46], 34: [2, 46], 48: [2, 46], 51: [2, 46], 55: [2, 46], 60: [2, 46] }, { 1: [3] }, { 5: [1, 4] }, { 5: [2, 2], 7: 5, 8: 6, 9: 7, 10: 8, 11: 9, 12: 10, 13: 11, 14: [1, 12], 15: [1, 20], 16: 17, 19: [1, 23], 24: 15, 27: 16, 29: [1, 21], 34: [1, 22], 39: [2, 2], 44: [2, 2], 47: [2, 2], 48: [1, 13], 51: [1, 14], 55: [1, 18], 59: 19, 60: [1, 24] }, { 1: [2, 1] }, { 5: [2, 47], 14: [2, 47], 15: [2, 47], 19: [2, 47], 29: [2, 47], 34: [2, 47], 39: [2, 47], 44: [2, 47], 47: [2, 47], 48: [2, 47], 51: [2, 47], 55: [2, 47], 60: [2, 47] }, { 5: [2, 3], 14: [2, 3], 15: [2, 3], 19: [2, 3], 29: [2, 3], 34: [2, 3], 39: [2, 3], 44: [2, 3], 47: [2, 3], 48: [2, 3], 51: [2, 3], 55: [2, 3], 60: [2, 3] }, { 5: [2, 4], 14: [2, 4], 15: [2, 4], 19: [2, 4], 29: [2, 4], 34: [2, 4], 39: [2, 4], 44: [2, 4], 47: [2, 4], 48: [2, 4], 51: [2, 4], 55: [2, 4], 60: [2, 4] }, { 5: [2, 5], 14: [2, 5], 15: [2, 5], 19: [2, 5], 29: [2, 5], 34: [2, 5], 39: [2, 5], 44: [2, 5], 47: [2, 5], 48: [2, 5], 51: [2, 5], 55: [2, 5], 60: [2, 5] }, { 5: [2, 6], 14: [2, 6], 15: [2, 6], 19: [2, 6], 29: [2, 6], 34: [2, 6], 39: [2, 6], 44: [2, 6], 47: [2, 6], 48: [2, 6], 51: [2, 6], 55: [2, 6], 60: [2, 6] }, { 5: [2, 7], 14: [2, 7], 15: [2, 7], 19: [2, 7], 29: [2, 7], 34: [2, 7], 39: [2, 7], 44: [2, 7], 47: [2, 7], 48: [2, 7], 51: [2, 7], 55: [2, 7], 60: [2, 7] }, { 5: [2, 8], 14: [2, 8], 15: [2, 8], 19: [2, 8], 29: [2, 8], 34: [2, 8], 39: [2, 8], 44: [2, 8], 47: [2, 8], 48: [2, 8], 51: [2, 8], 55: [2, 8], 60: [2, 8] }, { 5: [2, 9], 14: [2, 9], 15: [2, 9], 19: [2, 9], 29: [2, 9], 34: [2, 9], 39: [2, 9], 44: [2, 9], 47: [2, 9], 48: [2, 9], 51: [2, 9], 55: [2, 9], 60: [2, 9] }, { 20: 25, 72: [1, 35], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 20: 36, 72: [1, 35], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 4: 37, 6: 3, 14: [2, 46], 15: [2, 46], 19: [2, 46], 29: [2, 46], 34: [2, 46], 39: [2, 46], 44: [2, 46], 47: [2, 46], 48: [2, 46], 51: [2, 46], 55: [2, 46], 60: [2, 46] }, { 4: 38, 6: 3, 14: [2, 46], 15: [2, 46], 19: [2, 46], 29: [2, 46], 34: [2, 46], 44: [2, 46], 47: [2, 46], 48: [2, 46], 51: [2, 46], 55: [2, 46], 60: [2, 46] }, { 15: [2, 48], 17: 39, 18: [2, 48] }, { 20: 41, 56: 40, 64: 42, 65: [1, 43], 72: [1, 35], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 4: 44, 6: 3, 14: [2, 46], 15: [2, 46], 19: [2, 46], 29: [2, 46], 34: [2, 46], 47: [2, 46], 48: [2, 46], 51: [2, 46], 55: [2, 46], 60: [2, 46] }, { 5: [2, 10], 14: [2, 10], 15: [2, 10], 18: [2, 10], 19: [2, 10], 29: [2, 10], 34: [2, 10], 39: [2, 10], 44: [2, 10], 47: [2, 10], 48: [2, 10], 51: [2, 10], 55: [2, 10], 60: [2, 10] }, { 20: 45, 72: [1, 35], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 20: 46, 72: [1, 35], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 20: 47, 72: [1, 35], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 20: 41, 56: 48, 64: 42, 65: [1, 43], 72: [1, 35], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 33: [2, 78], 49: 49, 65: [2, 78], 72: [2, 78], 80: [2, 78], 81: [2, 78], 82: [2, 78], 83: [2, 78], 84: [2, 78], 85: [2, 78] }, { 23: [2, 33], 33: [2, 33], 54: [2, 33], 65: [2, 33], 68: [2, 33], 72: [2, 33], 75: [2, 33], 80: [2, 33], 81: [2, 33], 82: [2, 33], 83: [2, 33], 84: [2, 33], 85: [2, 33] }, { 23: [2, 34], 33: [2, 34], 54: [2, 34], 65: [2, 34], 68: [2, 34], 72: [2, 34], 75: [2, 34], 80: [2, 34], 81: [2, 34], 82: [2, 34], 83: [2, 34], 84: [2, 34], 85: [2, 34] }, { 23: [2, 35], 33: [2, 35], 54: [2, 35], 65: [2, 35], 68: [2, 35], 72: [2, 35], 75: [2, 35], 80: [2, 35], 81: [2, 35], 82: [2, 35], 83: [2, 35], 84: [2, 35], 85: [2, 35] }, { 23: [2, 36], 33: [2, 36], 54: [2, 36], 65: [2, 36], 68: [2, 36], 72: [2, 36], 75: [2, 36], 80: [2, 36], 81: [2, 36], 82: [2, 36], 83: [2, 36], 84: [2, 36], 85: [2, 36] }, { 23: [2, 37], 33: [2, 37], 54: [2, 37], 65: [2, 37], 68: [2, 37], 72: [2, 37], 75: [2, 37], 80: [2, 37], 81: [2, 37], 82: [2, 37], 83: [2, 37], 84: [2, 37], 85: [2, 37] }, { 23: [2, 38], 33: [2, 38], 54: [2, 38], 65: [2, 38], 68: [2, 38], 72: [2, 38], 75: [2, 38], 80: [2, 38], 81: [2, 38], 82: [2, 38], 83: [2, 38], 84: [2, 38], 85: [2, 38] }, { 23: [2, 39], 33: [2, 39], 54: [2, 39], 65: [2, 39], 68: [2, 39], 72: [2, 39], 75: [2, 39], 80: [2, 39], 81: [2, 39], 82: [2, 39], 83: [2, 39], 84: [2, 39], 85: [2, 39] }, { 23: [2, 43], 33: [2, 43], 54: [2, 43], 65: [2, 43], 68: [2, 43], 72: [2, 43], 75: [2, 43], 80: [2, 43], 81: [2, 43], 82: [2, 43], 83: [2, 43], 84: [2, 43], 85: [2, 43], 87: [1, 50] }, { 72: [1, 35], 86: 51 }, { 23: [2, 45], 33: [2, 45], 54: [2, 45], 65: [2, 45], 68: [2, 45], 72: [2, 45], 75: [2, 45], 80: [2, 45], 81: [2, 45], 82: [2, 45], 83: [2, 45], 84: [2, 45], 85: [2, 45], 87: [2, 45] }, { 52: 52, 54: [2, 82], 65: [2, 82], 72: [2, 82], 80: [2, 82], 81: [2, 82], 82: [2, 82], 83: [2, 82], 84: [2, 82], 85: [2, 82] }, { 25: 53, 38: 55, 39: [1, 57], 43: 56, 44: [1, 58], 45: 54, 47: [2, 54] }, { 28: 59, 43: 60, 44: [1, 58], 47: [2, 56] }, { 13: 62, 15: [1, 20], 18: [1, 61] }, { 33: [2, 86], 57: 63, 65: [2, 86], 72: [2, 86], 80: [2, 86], 81: [2, 86], 82: [2, 86], 83: [2, 86], 84: [2, 86], 85: [2, 86] }, { 33: [2, 40], 65: [2, 40], 72: [2, 40], 80: [2, 40], 81: [2, 40], 82: [2, 40], 83: [2, 40], 84: [2, 40], 85: [2, 40] }, { 33: [2, 41], 65: [2, 41], 72: [2, 41], 80: [2, 41], 81: [2, 41], 82: [2, 41], 83: [2, 41], 84: [2, 41], 85: [2, 41] }, { 20: 64, 72: [1, 35], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 26: 65, 47: [1, 66] }, { 30: 67, 33: [2, 58], 65: [2, 58], 72: [2, 58], 75: [2, 58], 80: [2, 58], 81: [2, 58], 82: [2, 58], 83: [2, 58], 84: [2, 58], 85: [2, 58] }, { 33: [2, 64], 35: 68, 65: [2, 64], 72: [2, 64], 75: [2, 64], 80: [2, 64], 81: [2, 64], 82: [2, 64], 83: [2, 64], 84: [2, 64], 85: [2, 64] }, { 21: 69, 23: [2, 50], 65: [2, 50], 72: [2, 50], 80: [2, 50], 81: [2, 50], 82: [2, 50], 83: [2, 50], 84: [2, 50], 85: [2, 50] }, { 33: [2, 90], 61: 70, 65: [2, 90], 72: [2, 90], 80: [2, 90], 81: [2, 90], 82: [2, 90], 83: [2, 90], 84: [2, 90], 85: [2, 90] }, { 20: 74, 33: [2, 80], 50: 71, 63: 72, 64: 75, 65: [1, 43], 69: 73, 70: 76, 71: 77, 72: [1, 78], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 72: [1, 79] }, { 23: [2, 42], 33: [2, 42], 54: [2, 42], 65: [2, 42], 68: [2, 42], 72: [2, 42], 75: [2, 42], 80: [2, 42], 81: [2, 42], 82: [2, 42], 83: [2, 42], 84: [2, 42], 85: [2, 42], 87: [1, 50] }, { 20: 74, 53: 80, 54: [2, 84], 63: 81, 64: 75, 65: [1, 43], 69: 82, 70: 76, 71: 77, 72: [1, 78], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 26: 83, 47: [1, 66] }, { 47: [2, 55] }, { 4: 84, 6: 3, 14: [2, 46], 15: [2, 46], 19: [2, 46], 29: [2, 46], 34: [2, 46], 39: [2, 46], 44: [2, 46], 47: [2, 46], 48: [2, 46], 51: [2, 46], 55: [2, 46], 60: [2, 46] }, { 47: [2, 20] }, { 20: 85, 72: [1, 35], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 4: 86, 6: 3, 14: [2, 46], 15: [2, 46], 19: [2, 46], 29: [2, 46], 34: [2, 46], 47: [2, 46], 48: [2, 46], 51: [2, 46], 55: [2, 46], 60: [2, 46] }, { 26: 87, 47: [1, 66] }, { 47: [2, 57] }, { 5: [2, 11], 14: [2, 11], 15: [2, 11], 19: [2, 11], 29: [2, 11], 34: [2, 11], 39: [2, 11], 44: [2, 11], 47: [2, 11], 48: [2, 11], 51: [2, 11], 55: [2, 11], 60: [2, 11] }, { 15: [2, 49], 18: [2, 49] }, { 20: 74, 33: [2, 88], 58: 88, 63: 89, 64: 75, 65: [1, 43], 69: 90, 70: 76, 71: 77, 72: [1, 78], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 65: [2, 94], 66: 91, 68: [2, 94], 72: [2, 94], 80: [2, 94], 81: [2, 94], 82: [2, 94], 83: [2, 94], 84: [2, 94], 85: [2, 94] }, { 5: [2, 25], 14: [2, 25], 15: [2, 25], 19: [2, 25], 29: [2, 25], 34: [2, 25], 39: [2, 25], 44: [2, 25], 47: [2, 25], 48: [2, 25], 51: [2, 25], 55: [2, 25], 60: [2, 25] }, { 20: 92, 72: [1, 35], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 20: 74, 31: 93, 33: [2, 60], 63: 94, 64: 75, 65: [1, 43], 69: 95, 70: 76, 71: 77, 72: [1, 78], 75: [2, 60], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 20: 74, 33: [2, 66], 36: 96, 63: 97, 64: 75, 65: [1, 43], 69: 98, 70: 76, 71: 77, 72: [1, 78], 75: [2, 66], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 20: 74, 22: 99, 23: [2, 52], 63: 100, 64: 75, 65: [1, 43], 69: 101, 70: 76, 71: 77, 72: [1, 78], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 20: 74, 33: [2, 92], 62: 102, 63: 103, 64: 75, 65: [1, 43], 69: 104, 70: 76, 71: 77, 72: [1, 78], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 33: [1, 105] }, { 33: [2, 79], 65: [2, 79], 72: [2, 79], 80: [2, 79], 81: [2, 79], 82: [2, 79], 83: [2, 79], 84: [2, 79], 85: [2, 79] }, { 33: [2, 81] }, { 23: [2, 27], 33: [2, 27], 54: [2, 27], 65: [2, 27], 68: [2, 27], 72: [2, 27], 75: [2, 27], 80: [2, 27], 81: [2, 27], 82: [2, 27], 83: [2, 27], 84: [2, 27], 85: [2, 27] }, { 23: [2, 28], 33: [2, 28], 54: [2, 28], 65: [2, 28], 68: [2, 28], 72: [2, 28], 75: [2, 28], 80: [2, 28], 81: [2, 28], 82: [2, 28], 83: [2, 28], 84: [2, 28], 85: [2, 28] }, { 23: [2, 30], 33: [2, 30], 54: [2, 30], 68: [2, 30], 71: 106, 72: [1, 107], 75: [2, 30] }, { 23: [2, 98], 33: [2, 98], 54: [2, 98], 68: [2, 98], 72: [2, 98], 75: [2, 98] }, { 23: [2, 45], 33: [2, 45], 54: [2, 45], 65: [2, 45], 68: [2, 45], 72: [2, 45], 73: [1, 108], 75: [2, 45], 80: [2, 45], 81: [2, 45], 82: [2, 45], 83: [2, 45], 84: [2, 45], 85: [2, 45], 87: [2, 45] }, { 23: [2, 44], 33: [2, 44], 54: [2, 44], 65: [2, 44], 68: [2, 44], 72: [2, 44], 75: [2, 44], 80: [2, 44], 81: [2, 44], 82: [2, 44], 83: [2, 44], 84: [2, 44], 85: [2, 44], 87: [2, 44] }, { 54: [1, 109] }, { 54: [2, 83], 65: [2, 83], 72: [2, 83], 80: [2, 83], 81: [2, 83], 82: [2, 83], 83: [2, 83], 84: [2, 83], 85: [2, 83] }, { 54: [2, 85] }, { 5: [2, 13], 14: [2, 13], 15: [2, 13], 19: [2, 13], 29: [2, 13], 34: [2, 13], 39: [2, 13], 44: [2, 13], 47: [2, 13], 48: [2, 13], 51: [2, 13], 55: [2, 13], 60: [2, 13] }, { 38: 55, 39: [1, 57], 43: 56, 44: [1, 58], 45: 111, 46: 110, 47: [2, 76] }, { 33: [2, 70], 40: 112, 65: [2, 70], 72: [2, 70], 75: [2, 70], 80: [2, 70], 81: [2, 70], 82: [2, 70], 83: [2, 70], 84: [2, 70], 85: [2, 70] }, { 47: [2, 18] }, { 5: [2, 14], 14: [2, 14], 15: [2, 14], 19: [2, 14], 29: [2, 14], 34: [2, 14], 39: [2, 14], 44: [2, 14], 47: [2, 14], 48: [2, 14], 51: [2, 14], 55: [2, 14], 60: [2, 14] }, { 33: [1, 113] }, { 33: [2, 87], 65: [2, 87], 72: [2, 87], 80: [2, 87], 81: [2, 87], 82: [2, 87], 83: [2, 87], 84: [2, 87], 85: [2, 87] }, { 33: [2, 89] }, { 20: 74, 63: 115, 64: 75, 65: [1, 43], 67: 114, 68: [2, 96], 69: 116, 70: 76, 71: 77, 72: [1, 78], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }
vendor: 24,015 bytes, lines 2806-3278
2806, { 33: [1, 117] }, { 32: 118, 33: [2, 62], 74: 119, 75: [1, 120] }, { 33: [2, 59], 65: [2, 59], 72: [2, 59], 75: [2, 59], 80: [2, 59], 81: [2, 59], 82: [2, 59], 83: [2, 59], 84: [2, 59], 85: [2, 59] }, { 33: [2, 61], 75: [2, 61] }, { 33: [2, 68], 37: 121, 74: 122, 75: [1, 120] }, { 33: [2, 65], 65: [2, 65], 72: [2, 65], 75: [2, 65], 80: [2, 65], 81: [2, 65], 82: [2, 65], 83: [2, 65], 84: [2, 65], 85: [2, 65] }, { 33: [2, 67], 75: [2, 67] }, { 23: [1, 123] }, { 23: [2, 51], 65: [2, 51], 72: [2, 51], 80: [2, 51], 81: [2, 51], 82: [2, 51], 83: [2, 51], 84: [2, 51], 85: [2, 51] }, { 23: [2, 53] }, { 33: [1, 124] }, { 33: [2, 91], 65: [2, 91], 72: [2, 91], 80: [2, 91], 81: [2, 91], 82: [2, 91], 83: [2, 91], 84: [2, 91], 85: [2, 91] }, { 33: [2, 93] }, { 5: [2, 22], 14: [2, 22], 15: [2, 22], 19: [2, 22], 29: [2, 22], 34: [2, 22], 39: [2, 22], 44: [2, 22], 47: [2, 22], 48: [2, 22], 51: [2, 22], 55: [2, 22], 60: [2, 22] }, { 23: [2, 99], 33: [2, 99], 54: [2, 99], 68: [2, 99], 72: [2, 99], 75: [2, 99] }, { 73: [1, 108] }, { 20: 74, 63: 125, 64: 75, 65: [1, 43], 72: [1, 35], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 5: [2, 23], 14: [2, 23], 15: [2, 23], 19: [2, 23], 29: [2, 23], 34: [2, 23], 39: [2, 23], 44: [2, 23], 47: [2, 23], 48: [2, 23], 51: [2, 23], 55: [2, 23], 60: [2, 23] }, { 47: [2, 19] }, { 47: [2, 77] }, { 20: 74, 33: [2, 72], 41: 126, 63: 127, 64: 75, 65: [1, 43], 69: 128, 70: 76, 71: 77, 72: [1, 78], 75: [2, 72], 78: 26, 79: 27, 80: [1, 28], 81: [1, 29], 82: [1, 30], 83: [1, 31], 84: [1, 32], 85: [1, 34], 86: 33 }, { 5: [2, 24], 14: [2, 24], 15: [2, 24], 19: [2, 24], 29: [2, 24], 34: [2, 24], 39: [2, 24], 44: [2, 24], 47: [2, 24], 48: [2, 24], 51: [2, 24], 55: [2, 24], 60: [2, 24] }, { 68: [1, 129] }, { 65: [2, 95], 68: [2, 95], 72: [2, 95], 80: [2, 95], 81: [2, 95], 82: [2, 95], 83: [2, 95], 84: [2, 95], 85: [2, 95] }, { 68: [2, 97] }, { 5: [2, 21], 14: [2, 21], 15: [2, 21], 19: [2, 21], 29: [2, 21], 34: [2, 21], 39: [2, 21], 44: [2, 21], 47: [2, 21], 48: [2, 21], 51: [2, 21], 55: [2, 21], 60: [2, 21] }, { 33: [1, 130] }, { 33: [2, 63] }, { 72: [1, 132], 76: 131 }, { 33: [1, 133] }, { 33: [2, 69] }, { 15: [2, 12], 18: [2, 12] }, { 14: [2, 26], 15: [2, 26], 19: [2, 26], 29: [2, 26], 34: [2, 26], 47: [2, 26], 48: [2, 26], 51: [2, 26], 55: [2, 26], 60: [2, 26] }, { 23: [2, 31], 33: [2, 31], 54: [2, 31], 68: [2, 31], 72: [2, 31], 75: [2, 31] }, { 33: [2, 74], 42: 134, 74: 135, 75: [1, 120] }, { 33: [2, 71], 65: [2, 71], 72: [2, 71], 75: [2, 71], 80: [2, 71], 81: [2, 71], 82: [2, 71], 83: [2, 71], 84: [2, 71], 85: [2, 71] }, { 33: [2, 73], 75: [2, 73] }, { 23: [2, 29], 33: [2, 29], 54: [2, 29], 65: [2, 29], 68: [2, 29], 72: [2, 29], 75: [2, 29], 80: [2, 29], 81: [2, 29], 82: [2, 29], 83: [2, 29], 84: [2, 29], 85: [2, 29] }, { 14: [2, 15], 15: [2, 15], 19: [2, 15], 29: [2, 15], 34: [2, 15], 39: [2, 15], 44: [2, 15], 47: [2, 15], 48: [2, 15], 51: [2, 15], 55: [2, 15], 60: [2, 15] }, { 72: [1, 137], 77: [1, 136] }, { 72: [2, 100], 77: [2, 100] }, { 14: [2, 16], 15: [2, 16], 19: [2, 16], 29: [2, 16], 34: [2, 16], 44: [2, 16], 47: [2, 16], 48: [2, 16], 51: [2, 16], 55: [2, 16], 60: [2, 16] }, { 33: [1, 138] }, { 33: [2, 75] }, { 33: [2, 32] }, { 72: [2, 101], 77: [2, 101] }, { 14: [2, 17], 15: [2, 17], 19: [2, 17], 29: [2, 17], 34: [2, 17], 39: [2, 17], 44: [2, 17], 47: [2, 17], 48: [2, 17], 51: [2, 17], 55: [2, 17], 60: [2, 17] }], 2807 defaultActions: { 4: [2, 1], 54: [2, 55], 56: [2, 20], 60: [2, 57], 73: [2, 81], 82: [2, 85], 86: [2, 18], 90: [2, 89], 101: [2, 53], 104: [2, 93], 110: [2, 19], 111: [2, 77], 116: [2, 97], 119: [2, 63], 122: [2, 69], 135: [2, 75], 136: [2, 32] }, 2808 parseError: function parseError(str, hash) { 2809 throw new Error(str); 2810 }, 2811 parse: function parse(input) { 2812 var self = this, 2813 stack = [0], 2814 vstack = [null], 2815 lstack = [], 2816 table = this.table, 2817 yytext = "", 2818 yylineno = 0, 2819 yyleng = 0, 2820 recovering = 0, 2821 TERROR = 2, 2822 EOF = 1; 2823 this.lexer.setInput(input); 2824 this.lexer.yy = this.yy; 2825 this.yy.lexer = this.lexer; 2826 this.yy.parser = this; 2827 if (typeof this.lexer.yylloc == "undefined") this.lexer.yylloc = {}; 2828 var yyloc = this.lexer.yylloc; 2829 lstack.push(yyloc); 2830 var ranges = this.lexer.options && this.lexer.options.ranges; 2831 if (typeof this.yy.parseError === "function") this.parseError = this.yy.parseError; 2832 function popStack(n) { 2833 stack.length = stack.length - 2 * n; 2834 vstack.length = vstack.length - n; 2835 lstack.length = lstack.length - n; 2836 } 2837 function lex() { 2838 var token; 2839 token = self.lexer.lex() || 1; 2840 if (typeof token !== "number") { 2841 token = self.symbols_[token] || token; 2842 } 2843 return token; 2844 } 2845 var symbol, 2846 preErrorSymbol, 2847 state, 2848 action, 2849 a, 2850 r, 2851 yyval = {}, 2852 p, 2853 len, 2854 newState, 2855 expected; 2856 while (true) { 2857 state = stack[stack.length - 1]; 2858 if (this.defaultActions[state]) { 2859 action = this.defaultActions[state]; 2860 } else { 2861 if (symbol === null || typeof symbol == "undefined") { 2862 symbol = lex(); 2863 } 2864 action = table[state] && table[state][symbol]; 2865 } 2866 if (typeof action === "undefined" || !action.length || !action[0]) { 2867 var errStr = ""; 2868 if (!recovering) { 2869 expected = []; 2870 for (p in table[state]) if (this.terminals_[p] && p > 2) { 2871 expected.push("'" + this.terminals_[p] + "'"); 2872 } 2873 if (this.lexer.showPosition) { 2874 errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; 2875 } else { 2876 errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1 ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'"); 2877 } 2878 this.parseError(errStr, { text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected }); 2879 } 2880 } 2881 if (action[0] instanceof Array && action.length > 1) { 2882 throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); 2883 } 2884 switch (action[0]) { 2885 case 1: 2886 stack.push(symbol); 2887 vstack.push(this.lexer.yytext); 2888 lstack.push(this.lexer.yylloc); 2889 stack.push(action[1]); 2890 symbol = null; 2891 if (!preErrorSymbol) { 2892 yyleng = this.lexer.yyleng; 2893 yytext = this.lexer.yytext; 2894 yylineno = this.lexer.yylineno; 2895 yyloc = this.lexer.yylloc; 2896 if (recovering > 0) recovering--; 2897 } else { 2898 symbol = preErrorSymbol; 2899 preErrorSymbol = null; 2900 } 2901 break; 2902 case 2: 2903 len = this.productions_[action[1]][1]; 2904 yyval.$ = vstack[vstack.length - len]; 2905 yyval._$ = { first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column }; 2906 if (ranges) { 2907 yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]]; 2908 } 2909 r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack); 2910 if (typeof r !== "undefined") { 2911 return r; 2912 } 2913 if (len) { 2914 stack = stack.slice(0, -1 * len * 2); 2915 vstack = vstack.slice(0, -1 * len); 2916 lstack = lstack.slice(0, -1 * len); 2917 } 2918 stack.push(this.productions_[action[1]][0]); 2919 vstack.push(yyval.$); 2920 lstack.push(yyval._$); 2921 newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; 2922 stack.push(newState); 2923 break; 2924 case 3: 2925 return true; 2926 } 2927 } 2928 return true; 2929 } 2930 }; 2931 /* Jison generated lexer */ 2932 var lexer = (function () { 2933 var lexer = { EOF: 1, 2934 parseError: function parseError(str, hash) { 2935 if (this.yy.parser) { 2936 this.yy.parser.parseError(str, hash); 2937 } else { 2938 throw new Error(str); 2939 } 2940 }, 2941 setInput: function setInput(input) { 2942 this._input = input; 2943 this._more = this._less = this.done = false; 2944 this.yylineno = this.yyleng = 0; 2945 this.yytext = this.matched = this.match = ''; 2946 this.conditionStack = ['INITIAL']; 2947 this.yylloc = { first_line: 1, first_column: 0, last_line: 1, last_column: 0 }; 2948 if (this.options.ranges) this.yylloc.range = [0, 0]; 2949 this.offset = 0; 2950 return this; 2951 }, 2952 input: function input() { 2953 var ch = this._input[0]; 2954 this.yytext += ch; 2955 this.yyleng++; 2956 this.offset++; 2957 this.match += ch; 2958 this.matched += ch; 2959 var lines = ch.match(/(?:\r\n?|\n).*/g); 2960 if (lines) { 2961 this.yylineno++; 2962 this.yylloc.last_line++; 2963 } else { 2964 this.yylloc.last_column++; 2965 } 2966 if (this.options.ranges) this.yylloc.range[1]++; 2967 2968 this._input = this._input.slice(1); 2969 return ch; 2970 }, 2971 unput: function unput(ch) { 2972 var len = ch.length; 2973 var lines = ch.split(/(?:\r\n?|\n)/g); 2974 2975 this._input = ch + this._input; 2976 this.yytext = this.yytext.substr(0, this.yytext.length - len - 1); 2977 //this.yyleng -= len; 2978 this.offset -= len; 2979 var oldLines = this.match.split(/(?:\r\n?|\n)/g); 2980 this.match = this.match.substr(0, this.match.length - 1); 2981 this.matched = this.matched.substr(0, this.matched.length - 1); 2982 2983 if (lines.length - 1) this.yylineno -= lines.length - 1; 2984 var r = this.yylloc.range; 2985 2986 this.yylloc = { first_line: this.yylloc.first_line, 2987 last_line: this.yylineno + 1, 2988 first_column: this.yylloc.first_column, 2989 last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len 2990 }; 2991 2992 if (this.options.ranges) { 2993 this.yylloc.range = [r[0], r[0] + this.yyleng - len]; 2994 } 2995 return this; 2996 }, 2997 more: function more() { 2998 this._more = true; 2999 return this; 3000 }, 3001 less: function less(n) { 3002 this.unput(this.match.slice(n)); 3003 }, 3004 pastInput: function pastInput() { 3005 var past = this.matched.substr(0, this.matched.length - this.match.length); 3006 return (past.length > 20 ? '...' : '') + past.substr(-20).replace(/\n/g, ""); 3007 }, 3008 upcomingInput: function upcomingInput() { 3009 var next = this.match; 3010 if (next.length < 20) { 3011 next += this._input.substr(0, 20 - next.length); 3012 } 3013 return (next.substr(0, 20) + (next.length > 20 ? '...' : '')).replace(/\n/g, ""); 3014 }, 3015 showPosition: function showPosition() { 3016 var pre = this.pastInput(); 3017 var c = new Array(pre.length + 1).join("-"); 3018 return pre + this.upcomingInput() + "\n" + c + "^"; 3019 }, 3020 next: function next() { 3021 if (this.done) { 3022 return this.EOF; 3023 } 3024 if (!this._input) this.done = true; 3025 3026 var token, match, tempMatch, index, col, lines; 3027 if (!this._more) { 3028 this.yytext = ''; 3029 this.match = ''; 3030 } 3031 var rules = this._currentRules(); 3032 for (var i = 0; i < rules.length; i++) { 3033 tempMatch = this._input.match(this.rules[rules[i]]); 3034 if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { 3035 match = tempMatch; 3036 index = i; 3037 if (!this.options.flex) break; 3038 } 3039 } 3040 if (match) { 3041 lines = match[0].match(/(?:\r\n?|\n).*/g); 3042 if (lines) this.yylineno += lines.length; 3043 this.yylloc = { first_line: this.yylloc.last_line, 3044 last_line: this.yylineno + 1, 3045 first_column: this.yylloc.last_column, 3046 last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length }; 3047 this.yytext += match[0]; 3048 this.match += match[0]; 3049 this.matches = match; 3050 this.yyleng = this.yytext.length; 3051 if (this.options.ranges) { 3052 this.yylloc.range = [this.offset, this.offset += this.yyleng]; 3053 } 3054 this._more = false; 3055 this._input = this._input.slice(match[0].length); 3056 this.matched += match[0]; 3057 token = this.performAction.call(this, this.yy, this, rules[index], this.conditionStack[this.conditionStack.length - 1]); 3058 if (this.done && this._input) this.done = false; 3059 if (token) return token;else return; 3060 } 3061 if (this._input === "") { 3062 return this.EOF; 3063 } else { 3064 return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), { text: "", token: null, line: this.yylineno }); 3065 } 3066 }, 3067 lex: function lex() { 3068 var r = this.next(); 3069 if (typeof r !== 'undefined') { 3070 return r; 3071 } else { 3072 return this.lex(); 3073 } 3074 }, 3075 begin: function begin(condition) { 3076 this.conditionStack.push(condition); 3077 }, 3078 popState: function popState() { 3079 return this.conditionStack.pop(); 3080 }, 3081 _currentRules: function _currentRules() { 3082 return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules; 3083 }, 3084 topState: function topState() { 3085 return this.conditionStack[this.conditionStack.length - 2]; 3086 }, 3087 pushState: function begin(condition) { 3088 this.begin(condition); 3089 } }; 3090 lexer.options = {}; 3091 lexer.performAction = function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { 3092 3093 function strip(start, end) { 3094 return yy_.yytext = yy_.yytext.substring(start, yy_.yyleng - end + start); 3095 } 3096 3097 var YYSTATE = YY_START; 3098 switch ($avoiding_name_collisions) { 3099 case 0: 3100 if (yy_.yytext.slice(-2) === "\\\\") { 3101 strip(0, 1); 3102 this.begin("mu"); 3103 } else if (yy_.yytext.slice(-1) === "\\") { 3104 strip(0, 1); 3105 this.begin("emu"); 3106 } else { 3107 this.begin("mu"); 3108 } 3109 if (yy_.yytext) return 15; 3110 3111 break; 3112 case 1: 3113 return 15; 3114 break; 3115 case 2: 3116 this.popState(); 3117 return 15; 3118 3119 break; 3120 case 3: 3121 this.begin('raw');return 15; 3122 break; 3123 case 4: 3124 this.popState(); 3125 // Should be using `this.topState()` below, but it currently 3126 // returns the second top instead of the first top. Opened an 3127 // issue about it at https://github.com/zaach/jison/issues/291 3128 if (this.conditionStack[this.conditionStack.length - 1] === 'raw') { 3129 return 15; 3130 } else { 3131 strip(5, 9); 3132 return 'END_RAW_BLOCK'; 3133 } 3134 3135 break; 3136 case 5: 3137 return 15; 3138 break; 3139 case 6: 3140 this.popState(); 3141 return 14; 3142 3143 break; 3144 case 7: 3145 return 65; 3146 break; 3147 case 8: 3148 return 68; 3149 break; 3150 case 9: 3151 return 19; 3152 break; 3153 case 10: 3154 this.popState(); 3155 this.begin('raw'); 3156 return 23; 3157 3158 break; 3159 case 11: 3160 return 55; 3161 break; 3162 case 12: 3163 return 60; 3164 break; 3165 case 13: 3166 return 29; 3167 break; 3168 case 14: 3169 return 47; 3170 break; 3171 case 15: 3172 this.popState();return 44; 3173 break; 3174 case 16: 3175 this.popState();return 44; 3176 break; 3177 case 17: 3178 return 34; 3179 break; 3180 case 18: 3181 return 39; 3182 break; 3183 case 19: 3184 return 51; 3185 break; 3186 case 20: 3187 return 48; 3188 break; 3189 case 21: 3190 this.unput(yy_.yytext); 3191 this.popState(); 3192 this.begin('com'); 3193 3194 break; 3195 case 22: 3196 this.popState(); 3197 return 14; 3198 3199 break; 3200 case 23: 3201 return 48; 3202 break; 3203 case 24: 3204 return 73; 3205 break; 3206 case 25: 3207 return 72; 3208 break; 3209 case 26: 3210 return 72; 3211 break; 3212 case 27: 3213 return 87; 3214 break; 3215 case 28: 3216 // ignore whitespace 3217 break; 3218 case 29: 3219 this.popState();return 54; 3220 break; 3221 case 30: 3222 this.popState();return 33; 3223 break; 3224 case 31: 3225 yy_.yytext = strip(1, 2).replace(/\\"/g, '"');return 80; 3226 break; 3227 case 32: 3228 yy_.yytext = strip(1, 2).replace(/\\'/g, "'");return 80; 3229 break; 3230 case 33: 3231 return 85; 3232 break; 3233 case 34: 3234 return 82; 3235 break; 3236 case 35: 3237 return 82; 3238 break; 3239 case 36: 3240 return 83; 3241 break; 3242 case 37: 3243 return 84; 3244 break; 3245 case 38: 3246 return 81; 3247 break; 3248 case 39: 3249 return 75; 3250 break; 3251 case 40: 3252 return 77; 3253 break; 3254 case 41: 3255 return 72; 3256 break; 3257 case 42: 3258 yy_.yytext = yy_.yytext.replace(/\\([\\\]])/g, '$1');return 72; 3259 break; 3260 case 43: 3261 return 'INVALID'; 3262 break; 3263 case 44: 3264 return 5; 3265 break; 3266 } 3267 }; 3268 lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/, /^(?:[^\x00]+)/, /^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/, /^(?:\{\{\{\{(?=[^\/]))/, /^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/, /^(?:[^\x00]+?(?=(\{\{\{\{)))/, /^(?:[\s\S]*?--(~)?\}\})/, /^(?:\()/, /^(?:\))/, /^(?:\{\{\{\{)/, /^(?:\}\}\}\})/, /^(?:\{\{(~)?>)/, /^(?:\{\{(~)?#>)/, /^(?:\{\{(~)?#\*?)/, /^(?:\{\{(~)?\/)/, /^(?:\{\{(~)?\^\s*(~)?\}\})/, /^(?:\{\{(~)?\s*else\s*(~)?\}\})/, /^(?:\{\{(~)?\^)/, /^(?:\{\{(~)?\s*else\b)/, /^(?:\{\{(~)?\{)/, /^(?:\{\{(~)?&)/, /^(?:\{\{(~)?!--)/, /^(?:\{\{(~)?![\s\S]*?\}\})/, /^(?:\{\{(~)?\*?)/, /^(?:=)/, /^(?:\.\.)/, /^(?:\.(?=([=~}\s\/.)|])))/, /^(?:[\/.])/, /^(?:\s+)/, /^(?:\}(~)?\}\})/, /^(?:(~)?\}\})/, /^(?:"(\\["]|[^"])*")/, /^(?:'(\\[']|[^'])*')/, /^(?:@)/, /^(?:true(?=([~}\s)])))/, /^(?:false(?=([~}\s)])))/, /^(?:undefined(?=([~}\s)])))/, /^(?:null(?=([~}\s)])))/, /^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/, /^(?:as\s+\|)/, /^(?:\|)/, /^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/, /^(?:\[(\\\]|[^\]])*\])/, /^(?:.)/, /^(?:$)/]; 3269 lexer.conditions = { "mu": { "rules": [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44], "inclusive": false }, "emu": { "rules": [2], "inclusive": false }, "com": { "rules": [6], "inclusive": false }, "raw": { "rules": [3, 4, 5], "inclusive": false }, "INITIAL": { "rules": [0, 1, 44], "inclusive": true } }; 3270 return lexer; 3271 })(); 3272 parser.lexer = lexer; 3273 function Parser() { 3274 this.yy = {}; 3275 }Parser.prototype = parser;parser.Parser = Parser; 3276 return new Parser(); 3277})();exports["default"] = handlebars; 3278module.exports = exports["default"];
vendor: 12,258 bytes, lines 3279-3713
3279 3280 3281},{}],11:[function(require,module,exports){ 3282'use strict'; 3283 3284exports.__esModule = true; 3285// istanbul ignore next 3286 3287function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 3288 3289var _exception = require('../exception'); 3290 3291var _exception2 = _interopRequireDefault(_exception); 3292 3293function Visitor() { 3294 this.parents = []; 3295} 3296 3297Visitor.prototype = { 3298 constructor: Visitor, 3299 mutating: false, 3300 3301 // Visits a given value. If mutating, will replace the value if necessary. 3302 acceptKey: function acceptKey(node, name) { 3303 var value = this.accept(node[name]); 3304 if (this.mutating) { 3305 // Hacky sanity check: This may have a few false positives for type for the helper 3306 // methods but will generally do the right thing without a lot of overhead. 3307 if (value && !Visitor.prototype[value.type]) { 3308 throw new _exception2['default']('Unexpected node type "' + value.type + '" found when accepting ' + name + ' on ' + node.type); 3309 } 3310 node[name] = value; 3311 } 3312 }, 3313 3314 // Performs an accept operation with added sanity check to ensure 3315 // required keys are not removed. 3316 acceptRequired: function acceptRequired(node, name) { 3317 this.acceptKey(node, name); 3318 3319 if (!node[name]) { 3320 throw new _exception2['default'](node.type + ' requires ' + name); 3321 } 3322 }, 3323 3324 // Traverses a given array. If mutating, empty respnses will be removed 3325 // for child elements. 3326 acceptArray: function acceptArray(array) { 3327 for (var i = 0, l = array.length; i < l; i++) { 3328 this.acceptKey(array, i); 3329 3330 if (!array[i]) { 3331 array.splice(i, 1); 3332 i--; 3333 l--; 3334 } 3335 } 3336 }, 3337 3338 accept: function accept(object) { 3339 if (!object) { 3340 return; 3341 } 3342 3343 /* istanbul ignore next: Sanity code */ 3344 if (!this[object.type]) { 3345 throw new _exception2['default']('Unknown type: ' + object.type, object); 3346 } 3347 3348 if (this.current) { 3349 this.parents.unshift(this.current); 3350 } 3351 this.current = object; 3352 3353 var ret = this[object.type](object); 3354 3355 this.current = this.parents.shift(); 3356 3357 if (!this.mutating || ret) { 3358 return ret; 3359 } else if (ret !== false) { 3360 return object; 3361 } 3362 }, 3363 3364 Program: function Program(program) { 3365 this.acceptArray(program.body); 3366 }, 3367 3368 MustacheStatement: visitSubExpression, 3369 Decorator: visitSubExpression, 3370 3371 BlockStatement: visitBlock, 3372 DecoratorBlock: visitBlock, 3373 3374 PartialStatement: visitPartial, 3375 PartialBlockStatement: function PartialBlockStatement(partial) { 3376 visitPartial.call(this, partial); 3377 3378 this.acceptKey(partial, 'program'); 3379 }, 3380 3381 ContentStatement: function ContentStatement() /* content */{}, 3382 CommentStatement: function CommentStatement() /* comment */{}, 3383 3384 SubExpression: visitSubExpression, 3385 3386 PathExpression: function PathExpression() /* path */{}, 3387 3388 StringLiteral: function StringLiteral() /* string */{}, 3389 NumberLiteral: function NumberLiteral() /* number */{}, 3390 BooleanLiteral: function BooleanLiteral() /* bool */{}, 3391 UndefinedLiteral: function UndefinedLiteral() /* literal */{}, 3392 NullLiteral: function NullLiteral() /* literal */{}, 3393 3394 Hash: function Hash(hash) { 3395 this.acceptArray(hash.pairs); 3396 }, 3397 HashPair: function HashPair(pair) { 3398 this.acceptRequired(pair, 'value'); 3399 } 3400}; 3401 3402function visitSubExpression(mustache) { 3403 this.acceptRequired(mustache, 'path'); 3404 this.acceptArray(mustache.params); 3405 this.acceptKey(mustache, 'hash'); 3406} 3407function visitBlock(block) { 3408 visitSubExpression.call(this, block); 3409 3410 this.acceptKey(block, 'program'); 3411 this.acceptKey(block, 'inverse'); 3412} 3413function visitPartial(partial) { 3414 this.acceptRequired(partial, 'name'); 3415 this.acceptArray(partial.params); 3416 this.acceptKey(partial, 'hash'); 3417} 3418 3419exports['default'] = Visitor; 3420module.exports = exports['default']; 3421 3422 3423},{"../exception":15}],12:[function(require,module,exports){ 3424'use strict'; 3425 3426exports.__esModule = true; 3427// istanbul ignore next 3428 3429function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 3430 3431var _visitor = require('./visitor'); 3432 3433var _visitor2 = _interopRequireDefault(_visitor); 3434 3435function WhitespaceControl() { 3436 var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; 3437 3438 this.options = options; 3439} 3440WhitespaceControl.prototype = new _visitor2['default'](); 3441 3442WhitespaceControl.prototype.Program = function (program) { 3443 var doStandalone = !this.options.ignoreStandalone; 3444 3445 var isRoot = !this.isRootSeen; 3446 this.isRootSeen = true; 3447 3448 var body = program.body; 3449 for (var i = 0, l = body.length; i < l; i++) { 3450 var current = body[i], 3451 strip = this.accept(current); 3452 3453 if (!strip) { 3454 continue; 3455 } 3456 3457 var _isPrevWhitespace = isPrevWhitespace(body, i, isRoot), 3458 _isNextWhitespace = isNextWhitespace(body, i, isRoot), 3459 openStandalone = strip.openStandalone && _isPrevWhitespace, 3460 closeStandalone = strip.closeStandalone && _isNextWhitespace, 3461 inlineStandalone = strip.inlineStandalone && _isPrevWhitespace && _isNextWhitespace; 3462 3463 if (strip.close) { 3464 omitRight(body, i, true); 3465 } 3466 if (strip.open) { 3467 omitLeft(body, i, true); 3468 } 3469 3470 if (doStandalone && inlineStandalone) { 3471 omitRight(body, i); 3472 3473 if (omitLeft(body, i)) { 3474 // If we are on a standalone node, save the indent info for partials 3475 if (current.type === 'PartialStatement') { 3476 // Pull out the whitespace from the final line 3477 current.indent = /([ \t]+$)/.exec(body[i - 1].original)[1]; 3478 } 3479 } 3480 } 3481 if (doStandalone && openStandalone) { 3482 omitRight((current.program || current.inverse).body); 3483 3484 // Strip out the previous content node if it's whitespace only 3485 omitLeft(body, i); 3486 } 3487 if (doStandalone && closeStandalone) { 3488 // Always strip the next node 3489 omitRight(body, i); 3490 3491 omitLeft((current.inverse || current.program).body); 3492 } 3493 } 3494 3495 return program; 3496}; 3497 3498WhitespaceControl.prototype.BlockStatement = WhitespaceControl.prototype.DecoratorBlock = WhitespaceControl.prototype.PartialBlockStatement = function (block) { 3499 this.accept(block.program); 3500 this.accept(block.inverse); 3501 3502 // Find the inverse program that is involed with whitespace stripping. 3503 var program = block.program || block.inverse, 3504 inverse = block.program && block.inverse, 3505 firstInverse = inverse, 3506 lastInverse = inverse; 3507 3508 if (inverse && inverse.chained) { 3509 firstInverse = inverse.body[0].program; 3510 3511 // Walk the inverse chain to find the last inverse that is actually in the chain. 3512 while (lastInverse.chained) { 3513 lastInverse = lastInverse.body[lastInverse.body.length - 1].program; 3514 } 3515 } 3516 3517 var strip = { 3518 open: block.openStrip.open, 3519 close: block.closeStrip.close, 3520 3521 // Determine the standalone candiacy. Basically flag our content as being possibly standalone 3522 // so our parent can determine if we actually are standalone 3523 openStandalone: isNextWhitespace(program.body), 3524 closeStandalone: isPrevWhitespace((firstInverse || program).body) 3525 }; 3526 3527 if (block.openStrip.close) { 3528 omitRight(program.body, null, true); 3529 } 3530 3531 if (inverse) { 3532 var inverseStrip = block.inverseStrip; 3533 3534 if (inverseStrip.open) { 3535 omitLeft(program.body, null, true); 3536 } 3537 3538 if (inverseStrip.close) { 3539 omitRight(firstInverse.body, null, true); 3540 } 3541 if (block.closeStrip.open) { 3542 omitLeft(lastInverse.body, null, true); 3543 } 3544 3545 // Find standalone else statments 3546 if (!this.options.ignoreStandalone && isPrevWhitespace(program.body) && isNextWhitespace(firstInverse.body)) { 3547 omitLeft(program.body); 3548 omitRight(firstInverse.body); 3549 } 3550 } else if (block.closeStrip.open) { 3551 omitLeft(program.body, null, true); 3552 } 3553 3554 return strip; 3555}; 3556 3557WhitespaceControl.prototype.Decorator = WhitespaceControl.prototype.MustacheStatement = function (mustache) { 3558 return mustache.strip; 3559}; 3560 3561WhitespaceControl.prototype.PartialStatement = WhitespaceControl.prototype.CommentStatement = function (node) { 3562 /* istanbul ignore next */ 3563 var strip = node.strip || {}; 3564 return { 3565 inlineStandalone: true, 3566 open: strip.open, 3567 close: strip.close 3568 }; 3569}; 3570 3571function isPrevWhitespace(body, i, isRoot) { 3572 if (i === undefined) { 3573 i = body.length; 3574 } 3575 3576 // Nodes that end with newlines are considered whitespace (but are special 3577 // cased for strip operations) 3578 var prev = body[i - 1], 3579 sibling = body[i - 2]; 3580 if (!prev) { 3581 return isRoot; 3582 } 3583 3584 if (prev.type === 'ContentStatement') { 3585 return (sibling || !isRoot ? /\r?\n\s*?$/ : /(^|\r?\n)\s*?$/).test(prev.original); 3586 } 3587} 3588function isNextWhitespace(body, i, isRoot) { 3589 if (i === undefined) { 3590 i = -1; 3591 } 3592 3593 var next = body[i + 1], 3594 sibling = body[i + 2]; 3595 if (!next) { 3596 return isRoot; 3597 } 3598 3599 if (next.type === 'ContentStatement') { 3600 return (sibling || !isRoot ? /^\s*?\r?\n/ : /^\s*?(\r?\n|$)/).test(next.original); 3601 } 3602} 3603 3604// Marks the node to the right of the position as omitted. 3605// I.e. {{foo}}' ' will mark the ' ' node as omitted. 3606// 3607// If i is undefined, then the first child will be marked as such. 3608// 3609// If mulitple is truthy then all whitespace will be stripped out until non-whitespace 3610// content is met. 3611function omitRight(body, i, multiple) { 3612 var current = body[i == null ? 0 : i + 1]; 3613 if (!current || current.type !== 'ContentStatement' || !multiple && current.rightStripped) { 3614 return; 3615 } 3616 3617 var original = current.value; 3618 current.value = current.value.replace(multiple ? /^\s+/ : /^[ \t]*\r?\n?/, ''); 3619 current.rightStripped = current.value !== original; 3620} 3621 3622// Marks the node to the left of the position as omitted. 3623// I.e. ' '{{foo}} will mark the ' ' node as omitted. 3624// 3625// If i is undefined then the last child will be marked as such. 3626// 3627// If mulitple is truthy then all whitespace will be stripped out until non-whitespace 3628// content is met. 3629function omitLeft(body, i, multiple) { 3630 var current = body[i == null ? body.length - 1 : i - 1]; 3631 if (!current || current.type !== 'ContentStatement' || !multiple && current.leftStripped) { 3632 return; 3633 } 3634 3635 // We omit the last node if it's whitespace only and not preceded by a non-content node. 3636 var original = current.value; 3637 current.value = current.value.replace(multiple ? /\s+$/ : /[ \t]+$/, ''); 3638 current.leftStripped = current.value !== original; 3639 return current.leftStripped; 3640} 3641 3642exports['default'] = WhitespaceControl; 3643module.exports = exports['default']; 3644 3645 3646},{"./visitor":11}],13:[function(require,module,exports){ 3647'use strict'; 3648 3649exports.__esModule = true; 3650exports.registerDefaultDecorators = registerDefaultDecorators; 3651// istanbul ignore next 3652 3653function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 3654 3655var _decoratorsInline = require('./decorators/inline'); 3656 3657var _decoratorsInline2 = _interopRequireDefault(_decoratorsInline); 3658 3659function registerDefaultDecorators(instance) { 3660 _decoratorsInline2['default'](instance); 3661} 3662 3663 3664},{"./decorators/inline":14}],14:[function(require,module,exports){ 3665'use strict'; 3666 3667exports.__esModule = true; 3668 3669var _utils = require('../utils'); 3670 3671exports['default'] = function (instance) { 3672 instance.registerDecorator('inline', function (fn, props, container, options) { 3673 var ret = fn; 3674 if (!props.partials) { 3675 props.partials = {}; 3676 ret = function (context, options) { 3677 // Create a new partials stack frame prior to exec. 3678 var original = container.partials; 3679 container.partials = _utils.extend({}, original, props.partials); 3680 var ret = fn(context, options); 3681 container.partials = original; 3682 return ret; 3683 }; 3684 } 3685 3686 props.partials[options.args[0]] = options.fn; 3687 3688 return ret; 3689 }); 3690}; 3691 3692module.exports = exports['default']; 3693 3694 3695},{"../utils":30}],15:[function(require,module,exports){ 3696'use strict'; 3697 3698exports.__esModule = true; 3699var errorProps = ['description', 'fileName', 'lineNumber', 'endLineNumber', 'message', 'name', 'number', 'stack']; 3700 3701function Exception(message, node) { 3702 var loc = node && node.loc, 3703 line = undefined, 3704 endLineNumber = undefined, 3705 column = undefined, 3706 endColumn = undefined; 3707 3708 if (loc) { 3709 line = loc.start.line; 3710 endLineNumber = loc.end.line; 3711 column = loc.start.column; 3712 endColumn = loc.end.column; 3713
3714 message += ' - ' + line + ':' + column; 3715 } 3716 3717 var tmp = Error.prototype.constructor.call(this, message); 3718 3719 // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work. 3720 for (var idx = 0; idx < errorProps.length; idx++) { 3721 this[errorProps[idx]] = tmp[errorProps[idx]]; 3722 } 3723 3724 /* istanbul ignore else */ 3725 if (Error.captureStackTrace) { 3726 Error.captureStackTrace(this, Exception); 3727 } 3728 3729 try { 3730 if (loc) { 3731 this.lineNumber = line; 3732 this.endLineNumber = endLineNumber; 3733 3734 // Work around issue under safari where we can't directly set the column value 3735 /* istanbul ignore next */ 3736 if (Object.defineProperty) { 3737 Object.defineProperty(this, 'column', { 3738 value: column, 3739 enumerable: true 3740 }); 3741 Object.defineProperty(this, 'endColumn', { 3742 value: endColumn, 3743 enumerable: true 3744 }); 3745 } else { 3746 this.column = column; 3747 this.endColumn = endColumn; 3748 } 3749 } 3750 } catch (nop) { 3751 /* Ignore if the browser is very particular */ 3752 } 3753} 3754 3755Exception.prototype = new Error(); 3756 3757exports['default'] = Exception; 3758module.exports = exports['default']; 3759 3760 3761},{}],16:[function(require,module,exports){ 3762'use strict'; 3763 3764exports.__esModule = true; 3765exports.registerDefaultHelpers = registerDefaultHelpers; 3766exports.moveHelperToHooks = moveHelperToHooks; 3767// istanbul ignore next 3768 3769function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 3770 3771var _helpersBlockHelperMissing = require('./helpers/block-helper-missing'); 3772 3773var _helpersBlockHelperMissing2 = _interopRequireDefault(_helpersBlockHelperMissing); 3774 3775var _helpersEach = require('./helpers/each'); 3776 3777var _helpersEach2 = _interopRequireDefault(_helpersEach); 3778 3779var _helpersHelperMissing = require('./helpers/helper-missing'); 3780 3781var _helpersHelperMissing2 = _interopRequireDefault(_helpersHelperMissing); 3782 3783var _helpersIf = require('./helpers/if'); 3784 3785var _helpersIf2 = _interopRequireDefault(_helpersIf); 3786 3787var _helpersLog = require('./helpers/log'); 3788 3789var _helpersLog2 = _interopRequireDefault(_helpersLog); 3790 3791var _helpersLookup = require('./helpers/lookup'); 3792 3793var _helpersLookup2 = _interopRequireDefault(_helpersLookup); 3794 3795var _helpersWith = require('./helpers/with'); 3796 3797var _helpersWith2 = _interopRequireDefault(_helpersWith); 3798 3799function registerDefaultHelpers(instance) { 3800 _helpersBlockHelperMissing2['default'](instance); 3801 _helpersEach2['default'](instance); 3802 _helpersHelperMissing2['default'](instance); 3803 _helpersIf2['default'](instance); 3804 _helpersLog2['default'](instance); 3805 _helpersLookup2['default'](instance); 3806 _helpersWith2['default'](instance); 3807} 3808 3809function moveHelperToHooks(instance, helperName, keepHelper) { 3810 if (instance.helpers[helperName]) { 3811 instance.hooks[helperName] = instance.helpers[helperName]; 3812 if (!keepHelper) { 3813 // Using delete is slow 3814 instance.helpers[helperName] = undefined; 3815 } 3816 } 3817} 3818 3819 3820},{"./helpers/block-helper-missing":17,"./helpers/each":18,"./helpers/helper-missing":19,"./helpers/if":20,"./helpers/log":21,"./helpers/lookup":22,"./helpers/with":23}],17:[function(require,module,exports){ 3821'use strict'; 3822 3823exports.__esModule = true; 3824 3825var _utils = require('../utils'); 3826 3827exports['default'] = function (instance) { 3828 instance.registerHelper('blockHelperMissing', function (context, options) { 3829 var inverse = options.inverse, 3830 fn = options.fn; 3831 3832 if (context === true) { 3833 return fn(this); 3834 } else if (context === false || context == null) { 3835 return inverse(this); 3836 } else if (_utils.isArray(context)) { 3837 if (context.length > 0) { 3838 if (options.ids) { 3839 options.ids = [options.name]; 3840 } 3841 3842 return instance.helpers.each(context, options); 3843 } else { 3844 return inverse(this); 3845 } 3846 } else { 3847 if (options.data && options.ids) { 3848 var data = _utils.createFrame(options.data); 3849 data.contextPath = _utils.appendContextPath(options.data.contextPath, options.name); 3850 options = { data: data }; 3851 } 3852 3853 return fn(context, options); 3854 } 3855 }); 3856}; 3857 3858module.exports = exports['default']; 3859 3860 3861},{"../utils":30}],18:[function(require,module,exports){ 3862'use strict'; 3863 3864exports.__esModule = true; 3865// istanbul ignore next 3866 3867function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 3868 3869var _utils = require('../utils'); 3870 3871var _exception = require('../exception'); 3872 3873var _exception2 = _interopRequireDefault(_exception); 3874 3875exports['default'] = function (instance) { 3876 instance.registerHelper('each', function (context, options) { 3877 if (!options) { 3878 throw new _exception2['default']('Must pass iterator to #each'); 3879 } 3880 3881 var fn = options.fn, 3882 inverse = options.inverse, 3883 i = 0, 3884 ret = '', 3885 data = undefined, 3886 contextPath = undefined; 3887 3888 if (options.data && options.ids) { 3889 contextPath = _utils.appendContextPath(options.data.contextPath, options.ids[0]) + '.'; 3890 } 3891 3892 if (_utils.isFunction(context)) { 3893 context = context.call(this); 3894 } 3895 3896 if (options.data) { 3897 data = _utils.createFrame(options.data); 3898 } 3899 3900 function execIteration(field, index, last) { 3901 if (data) { 3902 data.key = field; 3903 data.index = index; 3904 data.first = index === 0; 3905 data.last = !!last; 3906 3907 if (contextPath) { 3908 data.contextPath = contextPath + field; 3909 } 3910 } 3911 3912 ret = ret + fn(context[field], { 3913 data: data, 3914 blockParams: _utils.blockParams([context[field], field], [contextPath + field, null]) 3915 }); 3916 } 3917 3918 if (context && typeof context === 'object') { 3919 if (_utils.isArray(context)) { 3920 for (var j = context.length; i < j; i++) { 3921 if (i in context) { 3922 execIteration(i, i, i === context.length - 1); 3923 } 3924 } 3925 } else if (typeof Symbol === 'function' && context[Symbol.iterator]) { 3926 var newContext = []; 3927 var iterator = context[Symbol.iterator](); 3928 for (var it = iterator.next(); !it.done; it = iterator.next()) { 3929 newContext.push(it.value); 3930 } 3931 context = newContext; 3932 for (var j = context.length; i < j; i++) { 3933 execIteration(i, i, i === context.length - 1); 3934 } 3935 } else { 3936 (function () { 3937 var priorKey = undefined; 3938 3939 Object.keys(context).forEach(function (key) { 3940 // We're running the iterations one step out of sync so we can detect 3941 // the last iteration without have to scan the object twice and create 3942 // an itermediate keys array.
3943 if (priorKey !== undefined) { 3944 execIteration(priorKey, i - 1); 3945 } 3946 priorKey = key; 3947 i++; 3948 }); 3949 if (priorKey !== undefined) { 3950 execIteration(priorKey, i - 1, true); 3951 } 3952 })(); 3953 } 3954 } 3955 3956 if (i === 0) { 3957 ret = inverse(this); 3958 } 3959 3960 return ret; 3961 }); 3962}; 3963 3964module.exports = exports['default']; 3965 3966 3967},{"../exception":15,"../utils":30}],19:[function(require,module,exports){ 3968'use strict'; 3969 3970exports.__esModule = true; 3971// istanbul ignore next 3972 3973function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 3974 3975var _exception = require('../exception'); 3976 3977var _exception2 = _interopRequireDefault(_exception); 3978 3979exports['default'] = function (instance) { 3980 instance.registerHelper('helperMissing', function () /* [args, ]options */{ 3981 if (arguments.length === 1) { 3982 // A missing field in a {{foo}} construct. 3983 return undefined; 3984 } else { 3985 // Someone is actually trying to call something, blow up. 3986 throw new _exception2['default']('Missing helper: "' + arguments[arguments.length - 1].name + '"'); 3987 } 3988 }); 3989}; 3990 3991module.exports = exports['default']; 3992 3993 3994},{"../exception":15}],20:[function(require,module,exports){ 3995'use strict'; 3996 3997exports.__esModule = true; 3998// istanbul ignore next 3999 4000function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 4001 4002var _utils = require('../utils'); 4003 4004var _exception = require('../exception'); 4005 4006var _exception2 = _interopRequireDefault(_exception); 4007 4008exports['default'] = function (instance) { 4009 instance.registerHelper('if', function (conditional, options) { 4010 if (arguments.length != 2) { 4011 throw new _exception2['default']('#if requires exactly one argument'); 4012 } 4013 if (_utils.isFunction(conditional)) { 4014 conditional = conditional.call(this); 4015 } 4016 4017 // Default behavior is to render the positive path if the value is truthy and not empty. 4018 // The `includeZero` option may be set to treat the condtional as purely not empty based on the 4019 // behavior of isEmpty. Effectively this determines if 0 is handled by the positive path or negative. 4020 if (!options.hash.includeZero && !conditional || _utils.isEmpty(conditional)) { 4021 return options.inverse(this); 4022 } else { 4023 return options.fn(this); 4024 } 4025 }); 4026 4027 instance.registerHelper('unless', function (conditional, options) { 4028 if (arguments.length != 2) { 4029 throw new _exception2['default']('#unless requires exactly one argument'); 4030 } 4031 return instance.helpers['if'].call(this, conditional, { 4032 fn: options.inverse, 4033 inverse: options.fn, 4034 hash: options.hash 4035 }); 4036 }); 4037}; 4038 4039module.exports = exports['default']; 4040 4041 4042},{"../exception":15,"../utils":30}],21:[function(require,module,exports){ 4043'use strict'; 4044 4045exports.__esModule = true; 4046 4047exports['default'] = function (instance) { 4048 instance.registerHelper('log', function () /* message, options */{ 4049 var args = [undefined], 4050 options = arguments[arguments.length - 1]; 4051 for (var i = 0; i < arguments.length - 1; i++) { 4052 args.push(arguments[i]); 4053 } 4054 4055 var level = 1; 4056 if (options.hash.level != null) { 4057 level = options.hash.level; 4058 } else if (options.data && options.data.level != null) { 4059 level = options.data.level; 4060 } 4061 args[0] = level; 4062 4063 instance.log.apply(instance, args); 4064 }); 4065}; 4066 4067module.exports = exports['default']; 4068 4069 4070},{}],22:[function(require,module,exports){ 4071'use strict'; 4072 4073exports.__esModule = true; 4074 4075exports['default'] = function (instance) { 4076 instance.registerHelper('lookup', function (obj, field, options) { 4077 if (!obj) { 4078 // Note for 5.0: Change to "obj == null" in 5.0 4079 return obj; 4080 } 4081 return options.lookupProperty(obj, field); 4082 }); 4083}; 4084 4085module.exports = exports['default']; 4086 4087 4088},{}],23:[function(require,module,exports){ 4089'use strict'; 4090 4091exports.__esModule = true; 4092// istanbul ignore next 4093 4094function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 4095 4096var _utils = require('../utils'); 4097 4098var _exception = require('../exception'); 4099 4100var _exception2 = _interopRequireDefault(_exception); 4101 4102exports['default'] = function (instance) { 4103 instance.registerHelper('with', function (context, options) { 4104 if (arguments.length != 2) { 4105 throw new _exception2['default']('#with requires exactly one argument'); 4106 } 4107 if (_utils.isFunction(context)) { 4108 context = context.call(this); 4109 } 4110 4111 var fn = options.fn; 4112 4113 if (!_utils.isEmpty(context)) { 4114 var data = options.data; 4115 if (options.data && options.ids) { 4116 data = _utils.createFrame(options.data); 4117 data.contextPath = _utils.appendContextPath(options.data.contextPath, options.ids[0]); 4118 } 4119 4120 return fn(context, { 4121 data: data, 4122 blockParams: _utils.blockParams([context], [data && data.contextPath]) 4123 }); 4124 } else { 4125 return options.inverse(this); 4126 } 4127 }); 4128}; 4129 4130module.exports = exports['default']; 4131 4132 4133},{"../exception":15,"../utils":30}],24:[function(require,module,exports){ 4134'use strict'; 4135 4136exports.__esModule = true; 4137exports.createProtoAccessControl = createProtoAccessControl; 4138exports.resultIsAllowed = resultIsAllowed;
4139exports.resetLoggedProperties = resetLoggedProperties; 4140// istanbul ignore next 4141 4142function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 4143 4144var _utils = require('../utils'); 4145 4146var _logger = require('../logger'); 4147 4148var _logger2 = _interopRequireDefault(_logger); 4149 4150var loggedProperties = Object.create(null); 4151 4152function createProtoAccessControl(runtimeOptions) { 4153 // Create an object with "null"-prototype to avoid truthy results on 4154 // prototype properties. 4155 var propertyWhiteList = Object.create(null); 4156 // eslint-disable-next-line no-proto 4157 propertyWhiteList['__proto__'] = false; 4158 _utils.extend(propertyWhiteList, runtimeOptions.allowedProtoProperties); 4159 4160 var methodWhiteList = Object.create(null); 4161 methodWhiteList['constructor'] = false; 4162 methodWhiteList['__defineGetter__'] = false; 4163 methodWhiteList['__defineSetter__'] = false; 4164 methodWhiteList['__lookupGetter__'] = false; 4165 methodWhiteList['__lookupSetter__'] = false; 4166 _utils.extend(methodWhiteList, runtimeOptions.allowedProtoMethods); 4167 4168 return { 4169 properties: { 4170 whitelist: propertyWhiteList, 4171 defaultValue: runtimeOptions.allowProtoPropertiesByDefault 4172 }, 4173 methods: { 4174 whitelist: methodWhiteList, 4175 defaultValue: runtimeOptions.allowProtoMethodsByDefault 4176 } 4177 }; 4178} 4179 4180function resultIsAllowed(result, protoAccessControl, propertyName) { 4181 if (typeof result === 'function') { 4182 return checkWhiteList(protoAccessControl.methods, propertyName); 4183 } else { 4184 return checkWhiteList(protoAccessControl.properties, propertyName); 4185 } 4186} 4187 4188function checkWhiteList(protoAccessControlForType, propertyName) { 4189 if (protoAccessControlForType.whitelist[propertyName] !== undefined) { 4190 return protoAccessControlForType.whitelist[propertyName] === true; 4191 } 4192 if (protoAccessControlForType.defaultValue !== undefined) { 4193 return protoAccessControlForType.defaultValue; 4194 } 4195 logUnexpecedPropertyAccessOnce(propertyName); 4196 return false; 4197} 4198 4199function logUnexpecedPropertyAccessOnce(propertyName) { 4200 if (loggedProperties[propertyName] !== true) { 4201 loggedProperties[propertyName] = true; 4202 _logger2['default'].log('error', 'Handlebars: Access has been denied to resolve the property "' + propertyName + '" because it is not an "own property" of its parent.\n' + 'You can add a runtime option to disable the check or this warning:\n' + 'See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details'); 4203 } 4204} 4205 4206function resetLoggedProperties() { 4207 Object.keys(loggedProperties).forEach(function (propertyName) { 4208 delete loggedProperties[propertyName]; 4209 }); 4210} 4211 4212 4213},{"../logger":26,"../utils":30}],25:[function(require,module,exports){ 4214'use strict'; 4215 4216exports.__esModule = true; 4217exports.wrapHelper = wrapHelper; 4218 4219function wrapHelper(helper, transformOptionsFn) { 4220 if (typeof helper !== 'function') { 4221 // This should not happen, but apparently it does in https://github.com/wycats/handlebars.js/issues/1639 4222 // We try to make the wrapper least-invasive by not wrapping it, if the helper is not a function. 4223 return helper; 4224 } 4225 var wrapper = function wrapper() /* dynamic arguments */{ 4226 var options = arguments[arguments.length - 1]; 4227 arguments[arguments.length - 1] = transformOptionsFn(options); 4228 return helper.apply(this, arguments); 4229 }; 4230 return wrapper; 4231} 4232 4233 4234},{}],26:[function(require,module,exports){ 4235'use strict'; 4236 4237exports.__esModule = true; 4238 4239var _utils = require('./utils'); 4240 4241var logger = { 4242 methodMap: ['debug', 'info', 'warn', 'error'], 4243 level: 'info', 4244 4245 // Maps a given level value to the `methodMap` indexes above. 4246 lookupLevel: function lookupLevel(level) { 4247 if (typeof level === 'string') { 4248 var levelMap = _utils.indexOf(logger.methodMap, level.toLowerCase()); 4249 if (levelMap >= 0) { 4250 level = levelMap; 4251 } else { 4252 level = parseInt(level, 10); 4253 } 4254 } 4255 4256 return level; 4257 }, 4258 4259 // Can be overridden in the host environment 4260 log: function log(level) { 4261 level = logger.lookupLevel(level); 4262 4263 if (typeof console !== 'undefined' && logger.lookupLevel(logger.level) <= level) { 4264 var method = logger.methodMap[level]; 4265 // eslint-disable-next-line no-console 4266 if (!console[method]) { 4267 method = 'log'; 4268 } 4269 4270 for (var _len = arguments.length, message = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 4271 message[_key - 1] = arguments[_key]; 4272 } 4273 4274 console[method].apply(console, message); // eslint-disable-line no-console 4275 } 4276 } 4277}; 4278 4279exports['default'] = logger; 4280module.exports = exports['default']; 4281 4282 4283},{"./utils":30}],27:[function(require,module,exports){ 4284/* global globalThis */ 4285'use strict'; 4286 4287exports.__esModule = true; 4288 4289exports['default'] = function (Handlebars) { 4290 /* istanbul ignore next */ 4291 // https://mathiasbynens.be/notes/globalthis 4292 (function () { 4293 if (typeof globalThis === 'object') return;
4294 Object.prototype.__defineGetter__('__magic__', function () { 4295 return this; 4296 }); 4297 __magic__.globalThis = __magic__; // eslint-disable-line no-undef 4298 delete Object.prototype.__magic__; 4299 })(); 4300 4301 var $Handlebars = globalThis.Handlebars; 4302 4303 /* istanbul ignore next */ 4304 Handlebars.noConflict = function () { 4305 if (globalThis.Handlebars === Handlebars) { 4306 globalThis.Handlebars = $Handlebars; 4307 } 4308 return Handlebars; 4309 }; 4310}; 4311 4312module.exports = exports['default']; 4313 4314 4315},{}],28:[function(require,module,exports){
vendor: 13,076 bytes, lines 4316-4693
4316'use strict'; 4317 4318exports.__esModule = true; 4319exports.checkRevision = checkRevision; 4320exports.template = template; 4321exports.wrapProgram = wrapProgram; 4322exports.resolvePartial = resolvePartial; 4323exports.invokePartial = invokePartial; 4324exports.noop = noop; 4325// istanbul ignore next 4326 4327function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } 4328 4329// istanbul ignore next 4330 4331function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } } 4332 4333var _utils = require('./utils'); 4334 4335var Utils = _interopRequireWildcard(_utils); 4336 4337var _exception = require('./exception'); 4338 4339var _exception2 = _interopRequireDefault(_exception); 4340 4341var _base = require('./base'); 4342 4343var _helpers = require('./helpers'); 4344 4345var _internalWrapHelper = require('./internal/wrapHelper'); 4346 4347var _internalProtoAccess = require('./internal/proto-access'); 4348 4349function checkRevision(compilerInfo) { 4350 var compilerRevision = compilerInfo && compilerInfo[0] || 1, 4351 currentRevision = _base.COMPILER_REVISION; 4352 4353 if (compilerRevision >= _base.LAST_COMPATIBLE_COMPILER_REVISION && compilerRevision <= _base.COMPILER_REVISION) { 4354 return; 4355 } 4356 4357 if (compilerRevision < _base.LAST_COMPATIBLE_COMPILER_REVISION) { 4358 var runtimeVersions = _base.REVISION_CHANGES[currentRevision], 4359 compilerVersions = _base.REVISION_CHANGES[compilerRevision]; 4360 throw new _exception2['default']('Template was precompiled with an older version of Handlebars than the current runtime. ' + 'Please update your precompiler to a newer version (' + runtimeVersions + ') or downgrade your runtime to an older version (' + compilerVersions + ').'); 4361 } else { 4362 // Use the embedded version info since the runtime doesn't know about this revision yet 4363 throw new _exception2['default']('Template was precompiled with a newer version of Handlebars than the current runtime. ' + 'Please update your runtime to a newer version (' + compilerInfo[1] + ').'); 4364 } 4365} 4366 4367function template(templateSpec, env) { 4368 /* istanbul ignore next */ 4369 if (!env) { 4370 throw new _exception2['default']('No environment passed to template'); 4371 } 4372 if (!templateSpec || !templateSpec.main) { 4373 throw new _exception2['default']('Unknown template object: ' + typeof templateSpec); 4374 } 4375 4376 templateSpec.main.decorator = templateSpec.main_d; 4377 4378 // Note: Using env.VM references rather than local var references throughout this section to allow 4379 // for external users to override these as pseudo-supported APIs. 4380 env.VM.checkRevision(templateSpec.compiler); 4381 4382 // backwards compatibility for precompiled templates with compiler-version 7 (<4.3.0) 4383 var templateWasPrecompiledWithCompilerV7 = templateSpec.compiler && templateSpec.compiler[0] === 7; 4384 4385 function invokePartialWrapper(partial, context, options) { 4386 if (options.hash) { 4387 context = Utils.extend({}, context, options.hash); 4388 if (options.ids) { 4389 options.ids[0] = true; 4390 } 4391 } 4392 partial = env.VM.resolvePartial.call(this, partial, context, options); 4393 4394 options.hooks = this.hooks; 4395 options.protoAccessControl = this.protoAccessControl; 4396 4397 var result = env.VM.invokePartial.call(this, partial, context, options); 4398 4399 if (result == null && env.compile) { 4400 options.partials[options.name] = env.compile(partial, templateSpec.compilerOptions, env); 4401 result = options.partials[options.name](context, options); 4402 } 4403 if (result != null) { 4404 if (options.indent) { 4405 var lines = result.split('\n'); 4406 for (var i = 0, l = lines.length; i < l; i++) { 4407 if (!lines[i] && i + 1 === l) { 4408 break; 4409 } 4410 4411 lines[i] = options.indent + lines[i]; 4412 } 4413 result = lines.join('\n'); 4414 } 4415 return result; 4416 } else { 4417 throw new _exception2['default']('The partial ' + options.name + ' could not be compiled when running in runtime-only mode'); 4418 } 4419 } 4420 4421 // Just add water 4422 var container = { 4423 strict: function strict(obj, name, loc) { 4424 if (!obj || !(name in obj)) { 4425 throw new _exception2['default']('"' + name + '" not defined in ' + obj, { 4426 loc: loc 4427 }); 4428 } 4429 return container.lookupProperty(obj, name); 4430 }, 4431 lookupProperty: function lookupProperty(parent, propertyName) { 4432 var result = parent[propertyName]; 4433 if (result == null) { 4434 return result; 4435 } 4436 if (Object.prototype.hasOwnProperty.call(parent, propertyName)) { 4437 return result; 4438 } 4439 4440 if (_internalProtoAccess.resultIsAllowed(result, container.protoAccessControl, propertyName)) { 4441 return result; 4442 } 4443 return undefined; 4444 }, 4445 lookup: function lookup(depths, name) { 4446 var len = depths.length; 4447 for (var i = 0; i < len; i++) { 4448 var result = depths[i] && container.lookupProperty(depths[i], name); 4449 if (result != null) { 4450 return result; 4451 } 4452 } 4453 }, 4454 lambda: function lambda(current, context) { 4455 return typeof current === 'function' ? current.call(context) : current; 4456 }, 4457 4458 escapeExpression: Utils.escapeExpression, 4459 invokePartial: invokePartialWrapper, 4460 4461 fn: function fn(i) { 4462 var ret = templateSpec[i]; 4463 ret.decorator = templateSpec[i + '_d']; 4464 return ret; 4465 }, 4466 4467 programs: [], 4468 program: function program(i, data, declaredBlockParams, blockParams, depths) { 4469 var programWrapper = this.programs[i], 4470 fn = this.fn(i); 4471 if (data || depths || blockParams || declaredBlockParams) { 4472 programWrapper = wrapProgram(this, i, fn, data, declaredBlockParams, blockParams, depths); 4473 } else if (!programWrapper) { 4474 programWrapper = this.programs[i] = wrapProgram(this, i, fn); 4475 } 4476 return programWrapper; 4477 }, 4478 4479 data: function data(value, depth) { 4480 while (value && depth--) { 4481 value = value._parent; 4482 } 4483 return value; 4484 }, 4485 mergeIfNeeded: function mergeIfNeeded(param, common) { 4486 var obj = param || common; 4487 4488 if (param && common && param !== common) { 4489 obj = Utils.extend({}, common, param); 4490 } 4491 4492 return obj; 4493 }, 4494 // An empty object to use as replacement for null-contexts 4495 nullContext: Object.seal({}), 4496 4497 noop: env.VM.noop, 4498 compilerInfo: templateSpec.compiler 4499 }; 4500 4501 function ret(context) { 4502 var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; 4503 4504 var data = options.data; 4505 4506 ret._setup(options); 4507 if (!options.partial && templateSpec.useData) { 4508 data = initData(context, data); 4509 } 4510 var depths = undefined, 4511 blockParams = templateSpec.useBlockParams ? [] : undefined; 4512 if (templateSpec.useDepths) { 4513 if (options.depths) { 4514 depths = context != options.depths[0] ? [context].concat(options.depths) : options.depths; 4515 } else { 4516 depths = [context]; 4517 } 4518 } 4519 4520 function main(context /*, options*/) { 4521 return '' + templateSpec.main(container, context, container.helpers, container.partials, data, blockParams, depths); 4522 } 4523 4524 main = executeDecorators(templateSpec.main, main, container, options.depths || [], data, blockParams); 4525 return main(context, options); 4526 } 4527 4528 ret.isTop = true; 4529 4530 ret._setup = function (options) { 4531 if (!options.partial) { 4532 var mergedHelpers = {}; 4533 addHelpers(mergedHelpers, env.helpers, container); 4534 addHelpers(mergedHelpers, options.helpers, container); 4535 container.helpers = mergedHelpers; 4536 4537 if (templateSpec.usePartial) { 4538 // Use mergeIfNeeded here to prevent compiling global partials multiple times 4539 container.partials = container.mergeIfNeeded(options.partials, env.partials); 4540 } 4541 if (templateSpec.usePartial || templateSpec.useDecorators) { 4542 container.decorators = Utils.extend({}, env.decorators, options.decorators); 4543 } 4544 4545 container.hooks = {}; 4546 container.protoAccessControl = _internalProtoAccess.createProtoAccessControl(options); 4547 4548 var keepHelperInHelpers = options.allowCallsToHelperMissing || templateWasPrecompiledWithCompilerV7; 4549 _helpers.moveHelperToHooks(container, 'helperMissing', keepHelperInHelpers); 4550 _helpers.moveHelperToHooks(container, 'blockHelperMissing', keepHelperInHelpers); 4551 } else { 4552 container.protoAccessControl = options.protoAccessControl; // internal option 4553 container.helpers = options.helpers; 4554 container.partials = options.partials; 4555 container.decorators = options.decorators; 4556 container.hooks = options.hooks; 4557 } 4558 }; 4559 4560 ret._child = function (i, data, blockParams, depths) { 4561 if (templateSpec.useBlockParams && !blockParams) { 4562 throw new _exception2['default']('must pass block params'); 4563 } 4564 if (templateSpec.useDepths && !depths) { 4565 throw new _exception2['default']('must pass parent depths'); 4566 } 4567 4568 return wrapProgram(container, i, templateSpec[i], data, 0, blockParams, depths); 4569 }; 4570 return ret; 4571} 4572 4573function wrapProgram(container, i, fn, data, declaredBlockParams, blockParams, depths) { 4574 function prog(context) { 4575 var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; 4576 4577 var currentDepths = depths; 4578 if (depths && context != depths[0] && !(context === container.nullContext && depths[0] === null)) { 4579 currentDepths = [context].concat(depths); 4580 } 4581 4582 return fn(container, context, container.helpers, container.partials, options.data || data, blockParams && [options.blockParams].concat(blockParams), currentDepths); 4583 } 4584 4585 prog = executeDecorators(fn, prog, container, depths, data, blockParams); 4586 4587 prog.program = i; 4588 prog.depth = depths ? depths.length : 0; 4589 prog.blockParams = declaredBlockParams || 0; 4590 return prog; 4591} 4592 4593/** 4594 * This is currently part of the official API, therefore implementation details should not be changed. 4595 */ 4596 4597function resolvePartial(partial, context, options) { 4598 if (!partial) { 4599 if (options.name === '@partial-block') { 4600 partial = lookupOwnProperty(options.data, 'partial-block'); 4601 } else { 4602 partial = lookupOwnProperty(options.partials, options.name); 4603 } 4604 } else if (!partial.call && !options.name) { 4605 // This is a dynamic partial that returned a string 4606 options.name = partial; 4607 partial = lookupOwnProperty(options.partials, partial); 4608 } 4609 return partial; 4610} 4611 4612function invokePartial(partial, context, options) { 4613 // Use the current closure context to save the partial-block if this partial 4614 var currentPartialBlock = lookupOwnProperty(options.data, 'partial-block'); 4615 options.partial = true; 4616 if (options.ids) { 4617 options.data.contextPath = options.ids[0] || options.data.contextPath; 4618 } 4619 4620 var partialBlock = undefined; 4621 if (options.fn && options.fn !== noop) { 4622 (function () { 4623 options.data = _base.createFrame(options.data); 4624 // Wrapper function to get access to currentPartialBlock from the closure 4625 var fn = options.fn; 4626 partialBlock = options.data['partial-block'] = function partialBlockWrapper(context) { 4627 var options = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; 4628 4629 // Restore the partial-block from the closure for the execution of the block 4630 // i.e. the part inside the block of the partial call. 4631 options.data = _base.createFrame(options.data); 4632 options.data['partial-block'] = currentPartialBlock; 4633 return fn(context, options); 4634 }; 4635 if (fn.partials) { 4636 options.partials = Utils.extend({}, options.partials, fn.partials); 4637 } 4638 })(); 4639 } 4640 4641 if (partial === undefined && partialBlock) { 4642 partial = partialBlock; 4643 } 4644 4645 if (partial === undefined) { 4646 throw new _exception2['default']('The partial ' + options.name + ' could not be found'); 4647 } else if (partial instanceof Function) { 4648 return partial(context, options); 4649 } 4650} 4651 4652function noop() { 4653 return ''; 4654} 4655 4656function lookupOwnProperty(obj, name) { 4657 if (obj && Object.prototype.hasOwnProperty.call(obj, name)) { 4658 return obj[name]; 4659 } 4660} 4661 4662function initData(context, data) { 4663 if (!data || !('root' in data)) { 4664 data = data ? _base.createFrame(data) : {}; 4665 data.root = context; 4666 } 4667 return data; 4668} 4669 4670function executeDecorators(fn, prog, container, depths, data, blockParams) { 4671 if (fn.decorator) { 4672 var props = {}; 4673 prog = fn.decorator(prog, props, container, depths && depths[0], data, blockParams, depths); 4674 Utils.extend(prog, props); 4675 } 4676 return prog; 4677} 4678 4679function addHelpers(mergedHelpers, helpers, container) { 4680 if (!helpers) return; 4681 Object.keys(helpers).forEach(function (helperName) { 4682 var helper = helpers[helperName]; 4683 mergedHelpers[helperName] = passLookupPropertyOption(helper, container); 4684 }); 4685} 4686 4687function passLookupPropertyOption(helper, container) { 4688 var lookupProperty = container.lookupProperty; 4689 return _internalWrapHelper.wrapHelper(helper, function (options) { 4690 options.lookupProperty = lookupProperty; 4691 return options; 4692 }); 4693}
vendor: 7,003 bytes, lines 4694-4968
4694 4695 4696},{"./base":3,"./exception":15,"./helpers":16,"./internal/proto-access":24,"./internal/wrapHelper":25,"./utils":30}],29:[function(require,module,exports){ 4697// Build out our basic SafeString type 4698'use strict'; 4699 4700exports.__esModule = true; 4701function SafeString(string) { 4702 this.string = string; 4703} 4704 4705SafeString.prototype.toString = SafeString.prototype.toHTML = function () { 4706 return '' + this.string; 4707}; 4708 4709exports['default'] = SafeString; 4710module.exports = exports['default']; 4711 4712 4713},{}],30:[function(require,module,exports){ 4714'use strict'; 4715 4716exports.__esModule = true; 4717exports.extend = extend; 4718exports.indexOf = indexOf; 4719exports.escapeExpression = escapeExpression; 4720exports.isEmpty = isEmpty; 4721exports.createFrame = createFrame; 4722exports.blockParams = blockParams; 4723exports.appendContextPath = appendContextPath; 4724var escape = { 4725 '&': '&', 4726 '<': '<', 4727 '>': '>', 4728 '"': '"', 4729 "'": ''', 4730 '`': '`', 4731 '=': '=' 4732}; 4733 4734var badChars = /[&<>"'`=]/g, 4735 possible = /[&<>"'`=]/; 4736 4737function escapeChar(chr) { 4738 return escape[chr]; 4739} 4740 4741function extend(obj /* , ...source */) { 4742 for (var i = 1; i < arguments.length; i++) { 4743 for (var key in arguments[i]) { 4744 if (Object.prototype.hasOwnProperty.call(arguments[i], key)) { 4745 obj[key] = arguments[i][key]; 4746 } 4747 } 4748 } 4749 4750 return obj; 4751} 4752 4753var toString = Object.prototype.toString; 4754 4755exports.toString = toString; 4756// Sourced from lodash 4757// https://github.com/bestiejs/lodash/blob/master/LICENSE.txt 4758/* eslint-disable func-style */ 4759var isFunction = function isFunction(value) { 4760 return typeof value === 'function'; 4761}; 4762// fallback for older versions of Chrome and Safari 4763/* istanbul ignore next */ 4764if (isFunction(/x/)) { 4765 exports.isFunction = isFunction = function (value) { 4766 return typeof value === 'function' && toString.call(value) === '[object Function]'; 4767 }; 4768} 4769exports.isFunction = isFunction; 4770 4771/* eslint-enable func-style */ 4772 4773/* istanbul ignore next */ 4774var isArray = Array.isArray || function (value) { 4775 return value && typeof value === 'object' ? toString.call(value) === '[object Array]' : false; 4776}; 4777 4778exports.isArray = isArray; 4779// Older IE versions do not directly support indexOf so we must implement our own, sadly. 4780 4781function indexOf(array, value) { 4782 for (var i = 0, len = array.length; i < len; i++) { 4783 if (array[i] === value) { 4784 return i; 4785 } 4786 } 4787 return -1; 4788} 4789 4790function escapeExpression(string) { 4791 if (typeof string !== 'string') { 4792 // don't escape SafeStrings, since they're already safe 4793 if (string && string.toHTML) { 4794 return string.toHTML(); 4795 } else if (string == null) { 4796 return ''; 4797 } else if (!string) { 4798 return string + ''; 4799 } 4800 4801 // Force a string conversion as this will be done by the append regardless and 4802 // the regex test will do this transparently behind the scenes, causing issues if 4803 // an object's to string has escaped characters in it. 4804 string = '' + string; 4805 } 4806 4807 if (!possible.test(string)) { 4808 return string; 4809 } 4810 return string.replace(badChars, escapeChar); 4811} 4812 4813function isEmpty(value) { 4814 if (!value && value !== 0) { 4815 return true; 4816 } else if (isArray(value) && value.length === 0) { 4817 return true; 4818 } else { 4819 return false; 4820 } 4821} 4822 4823function createFrame(object) { 4824 var frame = extend({}, object); 4825 frame._parent = object; 4826 return frame; 4827} 4828 4829function blockParams(params, ids) { 4830 params.path = ids; 4831 return params; 4832} 4833 4834function appendContextPath(contextPath, id) { 4835 return (contextPath ? contextPath + '.' : '') + id; 4836} 4837 4838 4839},{}],31:[function(require,module,exports){ 4840/* -*- Mode: js; js-indent-level: 2; -*- */ 4841/* 4842 * Copyright 2011 Mozilla Foundation and contributors 4843 * Licensed under the New BSD license. See LICENSE or: 4844 * http://opensource.org/licenses/BSD-3-Clause 4845 */ 4846 4847var util = require('./util'); 4848var has = Object.prototype.hasOwnProperty; 4849var hasNativeMap = typeof Map !== "undefined"; 4850 4851/** 4852 * A data structure which is a combination of an array and a set. Adding a new 4853 * member is O(1), testing for membership is O(1), and finding the index of an 4854 * element is O(1). Removing elements from the set is not supported. Only 4855 * strings are supported for membership. 4856 */ 4857function ArraySet() { 4858 this._array = []; 4859 this._set = hasNativeMap ? new Map() : Object.create(null); 4860} 4861 4862/** 4863 * Static method for creating ArraySet instances from an existing array. 4864 */ 4865ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) { 4866 var set = new ArraySet(); 4867 for (var i = 0, len = aArray.length; i < len; i++) { 4868 set.add(aArray[i], aAllowDuplicates); 4869 } 4870 return set; 4871}; 4872 4873/** 4874 * Return how many unique items are in this ArraySet. If duplicates have been 4875 * added, than those do not count towards the size. 4876 * 4877 * @returns Number 4878 */ 4879ArraySet.prototype.size = function ArraySet_size() { 4880 return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length; 4881}; 4882 4883/** 4884 * Add the given string to this set. 4885 * 4886 * @param String aStr 4887 */ 4888ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) { 4889 var sStr = hasNativeMap ? aStr : util.toSetString(aStr); 4890 var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr); 4891 var idx = this._array.length; 4892 if (!isDuplicate || aAllowDuplicates) { 4893 this._array.push(aStr); 4894 } 4895 if (!isDuplicate) { 4896 if (hasNativeMap) { 4897 this._set.set(aStr, idx); 4898 } else { 4899 this._set[sStr] = idx; 4900 } 4901 } 4902}; 4903 4904/** 4905 * Is the given string a member of this set? 4906 * 4907 * @param String aStr 4908 */ 4909ArraySet.prototype.has = function ArraySet_has(aStr) { 4910 if (hasNativeMap) { 4911 return this._set.has(aStr); 4912 } else { 4913 var sStr = util.toSetString(aStr); 4914 return has.call(this._set, sStr); 4915 } 4916}; 4917 4918/** 4919 * What is the index of the given string in the array? 4920 * 4921 * @param String aStr 4922 */ 4923ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) { 4924 if (hasNativeMap) { 4925 var idx = this._set.get(aStr); 4926 if (idx >= 0) { 4927 return idx; 4928 } 4929 } else { 4930 var sStr = util.toSetString(aStr); 4931 if (has.call(this._set, sStr)) { 4932 return this._set[sStr]; 4933 } 4934 } 4935 4936 throw new Error('"' + aStr + '" is not in the set.'); 4937}; 4938 4939/** 4940 * What is the element at the given index? 4941 * 4942 * @param Number aIdx 4943 */ 4944ArraySet.prototype.at = function ArraySet_at(aIdx) { 4945 if (aIdx >= 0 && aIdx < this._array.length) { 4946 return this._array[aIdx]; 4947 } 4948 throw new Error('No element indexed by ' + aIdx); 4949}; 4950 4951/** 4952 * Returns the array representation of this set (which has the proper indices 4953 * indicated by indexOf). Note that this is a copy of the internal array used 4954 * for storing the members so that no one can mess with internal state. 4955 */ 4956ArraySet.prototype.toArray = function ArraySet_toArray() { 4957 return this._array.slice(); 4958}; 4959 4960exports.ArraySet = ArraySet; 4961 4962},{"./util":40}],32:[function(require,module,exports){ 4963/* -*- Mode: js; js-indent-level: 2; -*- */ 4964/* 4965 * Copyright 2011 Mozilla Foundation and contributors 4966 * Licensed under the New BSD license. See LICENSE or: 4967 * http://opensource.org/licenses/BSD-3-Clause 4968 *
4969 * Based on the Base 64 VLQ implementation in Closure Compiler: 4970 * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java 4971 * 4972 * Copyright 2011 The Closure Compiler Authors. All rights reserved. 4973 * Redistribution and use in source and binary forms, with or without 4974 * modification, are permitted provided that the following conditions are 4975 * met: 4976 * 4977 * * Redistributions of source code must retain the above copyright 4978 * notice, this list of conditions and the following disclaimer. 4979 * * Redistributions in binary form must reproduce the above 4980 * copyright notice, this list of conditions and the following 4981 * disclaimer in the documentation and/or other materials provided 4982 * with the distribution. 4983 * * Neither the name of Google Inc. nor the names of its 4984 * contributors may be used to endorse or promote products derived 4985 * from this software without specific prior written permission. 4986 * 4987 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 4988 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 4989 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 4990 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 4991 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 4992 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 4993 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 4994 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 4995 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 4996 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 4997 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 4998 */ 4999 5000var base64 = require('./base64'); 5001 5002// A single base 64 digit can contain 6 bits of data. For the base 64 variable 5003// length quantities we use in the source map spec, the first bit is the sign, 5004// the next four bits are the actual value, and the 6th bit is the 5005// continuation bit. The continuation bit tells us whether there are more 5006// digits in this value following this digit. 5007// 5008// Continuation 5009// | Sign 5010// | | 5011// V V 5012// 101011 5013 5014var VLQ_BASE_SHIFT = 5; 5015 5016// binary: 100000 5017var VLQ_BASE = 1 << VLQ_BASE_SHIFT; 5018 5019// binary: 011111 5020var VLQ_BASE_MASK = VLQ_BASE - 1; 5021 5022// binary: 100000 5023var VLQ_CONTINUATION_BIT = VLQ_BASE; 5024 5025/** 5026 * Converts from a two-complement value to a value where the sign bit is 5027 * placed in the least significant bit. For example, as decimals: 5028 * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary) 5029 * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary) 5030 */ 5031function toVLQSigned(aValue) { 5032 return aValue < 0 5033 ? ((-aValue) << 1) + 1 5034 : (aValue << 1) + 0; 5035} 5036 5037/** 5038 * Converts to a two-complement value from a value where the sign bit is 5039 * placed in the least significant bit. For example, as decimals: 5040 * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1 5041 * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2 5042 */ 5043function fromVLQSigned(aValue) { 5044 var isNegative = (aValue & 1) === 1; 5045 var shifted = aValue >> 1; 5046 return isNegative 5047 ? -shifted 5048 : shifted; 5049} 5050 5051/** 5052 * Returns the base 64 VLQ encoded value. 5053 */ 5054exports.encode = function base64VLQ_encode(aValue) { 5055 var encoded = ""; 5056 var digit; 5057 5058 var vlq = toVLQSigned(aValue); 5059 5060 do { 5061 digit = vlq & VLQ_BASE_MASK; 5062 vlq >>>= VLQ_BASE_SHIFT; 5063 if (vlq > 0) { 5064 // There are still more digits in this value, so we must make sure the 5065 // continuation bit is marked. 5066 digit |= VLQ_CONTINUATION_BIT; 5067 } 5068 encoded += base64.encode(digit); 5069 } while (vlq > 0); 5070 5071 return encoded; 5072}; 5073 5074/** 5075 * Decodes the next base 64 VLQ value from the given string and returns the 5076 * value and the rest of the string via the out parameter. 5077 */ 5078exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) { 5079 var strLen = aStr.length; 5080 var result = 0; 5081 var shift = 0; 5082 var continuation, digit; 5083 5084 do { 5085 if (aIndex >= strLen) { 5086 throw new Error("Expected more digits in base 64 VLQ value."); 5087 } 5088 5089 digit = base64.decode(aStr.charCodeAt(aIndex++)); 5090 if (digit === -1) { 5091 throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1)); 5092 } 5093 5094 continuation = !!(digit & VLQ_CONTINUATION_BIT); 5095 digit &= VLQ_BASE_MASK; 5096 result = result + (digit << shift); 5097 shift += VLQ_BASE_SHIFT; 5098 } while (continuation); 5099 5100 aOutParam.value = fromVLQSigned(result); 5101 aOutParam.rest = aIndex; 5102}; 5103 5104},{"./base64":33}],33:[function(require,module,exports){ 5105/* -*- Mode: js; js-indent-level: 2; -*- */ 5106/* 5107 * Copyright 2011 Mozilla Foundation and contributors 5108 * Licensed under the New BSD license. See LICENSE or: 5109 * http://opensource.org/licenses/BSD-3-Clause 5110 */ 5111 5112var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
vendor: 4,136 bytes, lines 5112-5248
5112+/'.split(''); 5113 5114/** 5115 * Encode an integer in the range of 0 to 63 to a single base 64 digit. 5116 */ 5117exports.encode = function (number) { 5118 if (0 <= number && number < intToCharMap.length) { 5119 return intToCharMap[number]; 5120 } 5121 throw new TypeError("Must be between 0 and 63: " + number); 5122}; 5123 5124/** 5125 * Decode a single base 64 character code digit to an integer. Returns -1 on 5126 * failure. 5127 */ 5128exports.decode = function (charCode) { 5129 var bigA = 65; // 'A' 5130 var bigZ = 90; // 'Z' 5131 5132 var littleA = 97; // 'a' 5133 var littleZ = 122; // 'z' 5134 5135 var zero = 48; // '0' 5136 var nine = 57; // '9' 5137 5138 var plus = 43; // '+' 5139 var slash = 47; // '/' 5140 5141 var littleOffset = 26; 5142 var numberOffset = 52; 5143 5144 // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ 5145 if (bigA <= charCode && charCode <= bigZ) { 5146 return (charCode - bigA); 5147 } 5148 5149 // 26 - 51: abcdefghijklmnopqrstuvwxyz 5150 if (littleA <= charCode && charCode <= littleZ) { 5151 return (charCode - littleA + littleOffset); 5152 } 5153 5154 // 52 - 61: 0123456789 5155 if (zero <= charCode && charCode <= nine) { 5156 return (charCode - zero + numberOffset); 5157 } 5158 5159 // 62: + 5160 if (charCode == plus) { 5161 return 62; 5162 } 5163 5164 // 63: / 5165 if (charCode == slash) { 5166 return 63; 5167 } 5168 5169 // Invalid base64 digit. 5170 return -1; 5171}; 5172 5173},{}],34:[function(require,module,exports){ 5174/* -*- Mode: js; js-indent-level: 2; -*- */ 5175/* 5176 * Copyright 2011 Mozilla Foundation and contributors 5177 * Licensed under the New BSD license. See LICENSE or: 5178 * http://opensource.org/licenses/BSD-3-Clause 5179 */ 5180 5181exports.GREATEST_LOWER_BOUND = 1; 5182exports.LEAST_UPPER_BOUND = 2; 5183 5184/** 5185 * Recursive implementation of binary search. 5186 * 5187 * @param aLow Indices here and lower do not contain the needle. 5188 * @param aHigh Indices here and higher do not contain the needle. 5189 * @param aNeedle The element being searched for. 5190 * @param aHaystack The non-empty array being searched. 5191 * @param aCompare Function which takes two elements and returns -1, 0, or 1. 5192 * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or 5193 * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the 5194 * closest element that is smaller than or greater than the one we are 5195 * searching for, respectively, if the exact element cannot be found. 5196 */ 5197function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) { 5198 // This function terminates when one of the following is true: 5199 // 5200 // 1. We find the exact element we are looking for. 5201 // 5202 // 2. We did not find the exact element, but we can return the index of 5203 // the next-closest element. 5204 // 5205 // 3. We did not find the exact element, and there is no next-closest 5206 // element than the one we are searching for, so we return -1. 5207 var mid = Math.floor((aHigh - aLow) / 2) + aLow; 5208 var cmp = aCompare(aNeedle, aHaystack[mid], true); 5209 if (cmp === 0) { 5210 // Found the element we are looking for. 5211 return mid; 5212 } 5213 else if (cmp > 0) { 5214 // Our needle is greater than aHaystack[mid]. 5215 if (aHigh - mid > 1) { 5216 // The element is in the upper half. 5217 return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias); 5218 } 5219 5220 // The exact needle element was not found in this haystack. Determine if 5221 // we are in termination case (3) or (2) and return the appropriate thing. 5222 if (aBias == exports.LEAST_UPPER_BOUND) { 5223 return aHigh < aHaystack.length ? aHigh : -1; 5224 } else { 5225 return mid; 5226 } 5227 } 5228 else { 5229 // Our needle is less than aHaystack[mid]. 5230 if (mid - aLow > 1) { 5231 // The element is in the lower half. 5232 return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias); 5233 } 5234 5235 // we are in termination case (3) or (2) and return the appropriate thing. 5236 if (aBias == exports.LEAST_UPPER_BOUND) { 5237 return mid; 5238 } else { 5239 return aLow < 0 ? -1 : aLow; 5240 } 5241 } 5242} 5243 5244/** 5245 * This is an implementation of binary search which will always try and return 5246 * the index of the closest element if there is no exact hit. This is because 5247 * mappings between original and generated line/col pairs are single points, 5248 * and there is an implicit region between each of them, so a miss just means
5249 * that you aren't on the very start of a region. 5250 * 5251 * @param aNeedle The element you are looking for. 5252 * @param aHaystack The array that is being searched. 5253 * @param aCompare A function which takes the needle and an element in the 5254 * array and returns -1, 0, or 1 depending on whether the needle is less 5255 * than, equal to, or greater than the element, respectively. 5256 * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or 5257 * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the 5258 * closest element that is smaller than or greater than the one we are 5259 * searching for, respectively, if the exact element cannot be found. 5260 * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'. 5261 */ 5262exports.search = function search(aNeedle, aHaystack, aCompare, aBias) { 5263 if (aHaystack.length === 0) { 5264 return -1; 5265 } 5266 5267 var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, 5268 aCompare, aBias || exports.GREATEST_LOWER_BOUND); 5269 if (index < 0) { 5270 return -1; 5271 } 5272 5273 // We have found either the exact element, or the next-closest element than 5274 // the one we are searching for. However, there may be more than one such 5275 // element. Make sure we always return the smallest of these. 5276 while (index - 1 >= 0) { 5277 if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) { 5278 break; 5279 } 5280 --index; 5281 } 5282 5283 return index; 5284}; 5285 5286},{}],35:[function(require,module,exports){ 5287/* -*- Mode: js; js-indent-level: 2; -*- */ 5288/* 5289 * Copyright 2014 Mozilla Foundation and contributors 5290 * Licensed under the New BSD license. See LICENSE or: 5291 * http://opensource.org/licenses/BSD-3-Clause 5292 */ 5293 5294var util = require('./util'); 5295 5296/** 5297 * Determine whether mappingB is after mappingA with respect to generated 5298 * position. 5299 */ 5300function generatedPositionAfter(mappingA, mappingB) { 5301 // Optimized for most common case 5302 var lineA = mappingA.generatedLine; 5303 var lineB = mappingB.generatedLine; 5304 var columnA = mappingA.generatedColumn; 5305 var columnB = mappingB.generatedColumn; 5306 return lineB > lineA || lineB == lineA && columnB >= columnA || 5307 util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0; 5308} 5309 5310/** 5311 * A data structure to provide a sorted view of accumulated mappings in a 5312 * performance conscious manner. It trades a neglibable overhead in general 5313 * case for a large speedup in case of mappings being added in order. 5314 */ 5315function MappingList() { 5316 this._array = []; 5317 this._sorted = true; 5318 // Serves as infimum 5319 this._last = {generatedLine: -1, generatedColumn: 0}; 5320} 5321 5322/** 5323 * Iterate through internal items. This method takes the same arguments that 5324 * `Array.prototype.forEach` takes. 5325 * 5326 * NOTE: The order of the mappings is NOT guaranteed. 5327 */ 5328MappingList.prototype.unsortedForEach = 5329 function MappingList_forEach(aCallback, aThisArg) { 5330 this._array.forEach(aCallback, aThisArg); 5331 }; 5332 5333/** 5334 * Add the given source mapping. 5335 * 5336 * @param Object aMapping 5337 */ 5338MappingList.prototype.add = function MappingList_add(aMapping) { 5339 if (generatedPositionAfter(this._last, aMapping)) { 5340 this._last = aMapping; 5341 this._array.push(aMapping); 5342 } else { 5343 this._sorted = false; 5344 this._array.push(aMapping); 5345 } 5346}; 5347 5348/** 5349 * Returns the flat, sorted array of mappings. The mappings are sorted by 5350 * generated position. 5351 * 5352 * WARNING: This method returns internal data without copying, for 5353 * performance. The return value must NOT be mutated, and should be treated as 5354 * an immutable borrow. If you want to take ownership, you must make your own 5355 * copy. 5356 */ 5357MappingList.prototype.toArray = function MappingList_toArray() { 5358 if (!this._sorted) { 5359 this._array.sort(util.compareByGeneratedPositionsInflated); 5360 this._sorted = true; 5361 } 5362 return this._array; 5363}; 5364 5365exports.MappingList = MappingList; 5366 5367},{"./util":40}],36:[function(require,module,exports){ 5368/* -*- Mode: js; js-indent-level: 2; -*- */ 5369/* 5370 * Copyright 2011 Mozilla Foundation and contributors 5371 * Licensed under the New BSD license. See LICENSE or: 5372 * http://opensource.org/licenses/BSD-3-Clause 5373 */ 5374 5375// It turns out that some (most?) JavaScript engines don't self-host 5376// `Array.prototype.sort`. This makes sense because C++ will likely remain 5377// faster than JS when doing raw CPU-intensive sorting. However, when using a 5378// custom comparator function, calling back and forth between the VM's C++ and 5379// JIT'd JS is rather slow *and* loses JIT type information, resulting in
vendor: 3,501 bytes, lines 5380-5495
5380// worse generated code for the comparator function than would be optimal. In 5381// fact, when sorting with a comparator, these costs outweigh the benefits of 5382// sorting in C++. By using our own JS-implemented Quick Sort (below), we get 5383// a ~3500ms mean speed-up in `bench/bench.html`. 5384 5385/** 5386 * Swap the elements indexed by `x` and `y` in the array `ary`. 5387 * 5388 * @param {Array} ary 5389 * The array. 5390 * @param {Number} x 5391 * The index of the first item. 5392 * @param {Number} y 5393 * The index of the second item. 5394 */ 5395function swap(ary, x, y) { 5396 var temp = ary[x]; 5397 ary[x] = ary[y]; 5398 ary[y] = temp; 5399} 5400 5401/** 5402 * Returns a random integer within the range `low .. high` inclusive. 5403 * 5404 * @param {Number} low 5405 * The lower bound on the range. 5406 * @param {Number} high 5407 * The upper bound on the range. 5408 */ 5409function randomIntInRange(low, high) { 5410 return Math.round(low + (Math.random() * (high - low))); 5411} 5412 5413/** 5414 * The Quick Sort algorithm. 5415 * 5416 * @param {Array} ary 5417 * An array to sort. 5418 * @param {function} comparator 5419 * Function to use to compare two items. 5420 * @param {Number} p 5421 * Start index of the array 5422 * @param {Number} r 5423 * End index of the array 5424 */ 5425function doQuickSort(ary, comparator, p, r) { 5426 // If our lower bound is less than our upper bound, we (1) partition the 5427 // array into two pieces and (2) recurse on each half. If it is not, this is 5428 // the empty array and our base case. 5429 5430 if (p < r) { 5431 // (1) Partitioning. 5432 // 5433 // The partitioning chooses a pivot between `p` and `r` and moves all 5434 // elements that are less than or equal to the pivot to the before it, and 5435 // all the elements that are greater than it after it. The effect is that 5436 // once partition is done, the pivot is in the exact place it will be when 5437 // the array is put in sorted order, and it will not need to be moved 5438 // again. This runs in O(n) time. 5439 5440 // Always choose a random pivot so that an input array which is reverse 5441 // sorted does not cause O(n^2) running time. 5442 var pivotIndex = randomIntInRange(p, r); 5443 var i = p - 1; 5444 5445 swap(ary, pivotIndex, r); 5446 var pivot = ary[r]; 5447 5448 // Immediately after `j` is incremented in this loop, the following hold 5449 // true: 5450 // 5451 // * Every element in `ary[p .. i]` is less than or equal to the pivot. 5452 // 5453 // * Every element in `ary[i+1 .. j-1]` is greater than the pivot. 5454 for (var j = p; j < r; j++) { 5455 if (comparator(ary[j], pivot) <= 0) { 5456 i += 1; 5457 swap(ary, i, j); 5458 } 5459 } 5460 5461 swap(ary, i + 1, j); 5462 var q = i + 1; 5463 5464 // (2) Recurse on each half. 5465 5466 doQuickSort(ary, comparator, p, q - 1); 5467 doQuickSort(ary, comparator, q + 1, r); 5468 } 5469} 5470 5471/** 5472 * Sort the given array in-place with the given comparator function. 5473 * 5474 * @param {Array} ary 5475 * An array to sort. 5476 * @param {function} comparator 5477 * Function to use to compare two items. 5478 */ 5479exports.quickSort = function (ary, comparator) { 5480 doQuickSort(ary, comparator, 0, ary.length - 1); 5481}; 5482 5483},{}],37:[function(require,module,exports){ 5484/* -*- Mode: js; js-indent-level: 2; -*- */ 5485/* 5486 * Copyright 2011 Mozilla Foundation and contributors 5487 * Licensed under the New BSD license. See LICENSE or: 5488 * http://opensource.org/licenses/BSD-3-Clause 5489 */ 5490 5491var util = require('./util'); 5492var binarySearch = require('./binary-search'); 5493var ArraySet = require('./array-set').ArraySet; 5494var base64VLQ = require('./base64-vlq'); 5495var quickSort = require('./quick-sort').quickSort
vendor: 9,892 bytes, lines 5495-5751
5495; 5496 5497function SourceMapConsumer(aSourceMap, aSourceMapURL) { 5498 var sourceMap = aSourceMap; 5499 if (typeof aSourceMap === 'string') { 5500 sourceMap = util.parseSourceMapInput(aSourceMap); 5501 } 5502 5503 return sourceMap.sections != null 5504 ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL) 5505 : new BasicSourceMapConsumer(sourceMap, aSourceMapURL); 5506} 5507 5508SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) { 5509 return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL); 5510} 5511 5512/** 5513 * The version of the source mapping spec that we are consuming. 5514 */ 5515SourceMapConsumer.prototype._version = 3; 5516 5517// `__generatedMappings` and `__originalMappings` are arrays that hold the 5518// parsed mapping coordinates from the source map's "mappings" attribute. They 5519// are lazily instantiated, accessed via the `_generatedMappings` and 5520// `_originalMappings` getters respectively, and we only parse the mappings 5521// and create these arrays once queried for a source location. We jump through 5522// these hoops because there can be many thousands of mappings, and parsing 5523// them is expensive, so we only want to do it if we must. 5524// 5525// Each object in the arrays is of the form: 5526// 5527// { 5528// generatedLine: The line number in the generated code, 5529// generatedColumn: The column number in the generated code, 5530// source: The path to the original source file that generated this 5531// chunk of code, 5532// originalLine: The line number in the original source that 5533// corresponds to this chunk of generated code, 5534// originalColumn: The column number in the original source that 5535// corresponds to this chunk of generated code, 5536// name: The name of the original symbol which generated this chunk of 5537// code. 5538// } 5539// 5540// All properties except for `generatedLine` and `generatedColumn` can be 5541// `null`. 5542// 5543// `_generatedMappings` is ordered by the generated positions. 5544// 5545// `_originalMappings` is ordered by the original positions. 5546 5547SourceMapConsumer.prototype.__generatedMappings = null; 5548Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', { 5549 configurable: true, 5550 enumerable: true, 5551 get: function () { 5552 if (!this.__generatedMappings) { 5553 this._parseMappings(this._mappings, this.sourceRoot); 5554 } 5555 5556 return this.__generatedMappings; 5557 } 5558}); 5559 5560SourceMapConsumer.prototype.__originalMappings = null; 5561Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', { 5562 configurable: true, 5563 enumerable: true, 5564 get: function () { 5565 if (!this.__originalMappings) { 5566 this._parseMappings(this._mappings, this.sourceRoot); 5567 } 5568 5569 return this.__originalMappings; 5570 } 5571}); 5572 5573SourceMapConsumer.prototype._charIsMappingSeparator = 5574 function SourceMapConsumer_charIsMappingSeparator(aStr, index) { 5575 var c = aStr.charAt(index); 5576 return c === ";" || c === ","; 5577 }; 5578 5579/** 5580 * Parse the mappings in a string in to a data structure which we can easily 5581 * query (the ordered arrays in the `this.__generatedMappings` and 5582 * `this.__originalMappings` properties). 5583 */ 5584SourceMapConsumer.prototype._parseMappings = 5585 function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { 5586 throw new Error("Subclasses must implement _parseMappings"); 5587 }; 5588 5589SourceMapConsumer.GENERATED_ORDER = 1; 5590SourceMapConsumer.ORIGINAL_ORDER = 2; 5591 5592SourceMapConsumer.GREATEST_LOWER_BOUND = 1; 5593SourceMapConsumer.LEAST_UPPER_BOUND = 2; 5594 5595/** 5596 * Iterate over each mapping between an original source/line/column and a 5597 * generated line/column in this source map. 5598 * 5599 * @param Function aCallback 5600 * The function that is called with each mapping. 5601 * @param Object aContext 5602 * Optional. If specified, this object will be the value of `this` every 5603 * time that `aCallback` is called. 5604 * @param aOrder 5605 * Either `SourceMapConsumer.GENERATED_ORDER` or 5606 * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to 5607 * iterate over the mappings sorted by the generated file's line/column 5608 * order or the original's source/line/column order, respectively. Defaults to 5609 * `SourceMapConsumer.GENERATED_ORDER`. 5610 */ 5611SourceMapConsumer.prototype.eachMapping = 5612 function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) { 5613 var context = aContext || null; 5614 var order = aOrder || SourceMapConsumer.GENERATED_ORDER; 5615 5616 var mappings; 5617 switch (order) { 5618 case SourceMapConsumer.GENERATED_ORDER: 5619 mappings = this._generatedMappings; 5620 break; 5621 case SourceMapConsumer.ORIGINAL_ORDER: 5622 mappings = this._originalMappings; 5623 break; 5624 default: 5625 throw new Error("Unknown order of iteration."); 5626 } 5627 5628 var sourceRoot = this.sourceRoot; 5629 mappings.map(function (mapping) { 5630 var source = mapping.source === null ? null : this._sources.at(mapping.source); 5631 source = util.computeSourceURL(sourceRoot, source, this._sourceMapURL); 5632 return { 5633 source: source, 5634 generatedLine: mapping.generatedLine, 5635 generatedColumn: mapping.generatedColumn, 5636 originalLine: mapping.originalLine, 5637 originalColumn: mapping.originalColumn, 5638 name: mapping.name === null ? null : this._names.at(mapping.name) 5639 }; 5640 }, this).forEach(aCallback, context); 5641 }; 5642 5643/** 5644 * Returns all generated line and column information for the original source, 5645 * line, and column provided. If no column is provided, returns all mappings 5646 * corresponding to a either the line we are searching for or the next 5647 * closest line that has any mappings. Otherwise, returns all mappings 5648 * corresponding to the given line and either the column we are searching for 5649 * or the next closest column that has any offsets. 5650 * 5651 * The only argument is an object with the following properties: 5652 * 5653 * - source: The filename of the original source. 5654 * - line: The line number in the original source. The line number is 1-based. 5655 * - column: Optional. the column number in the original source. 5656 * The column number is 0-based. 5657 * 5658 * and an array of objects is returned, each with the following properties: 5659 * 5660 * - line: The line number in the generated source, or null. The 5661 * line number is 1-based. 5662 * - column: The column number in the generated source, or null. 5663 * The column number is 0-based. 5664 */ 5665SourceMapConsumer.prototype.allGeneratedPositionsFor = 5666 function SourceMapConsumer_allGeneratedPositionsFor(aArgs) { 5667 var line = util.getArg(aArgs, 'line'); 5668 5669 // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping 5670 // returns the index of the closest mapping less than the needle. By 5671 // setting needle.originalColumn to 0, we thus find the last mapping for 5672 // the given line, provided such a mapping exists. 5673 var needle = { 5674 source: util.getArg(aArgs, 'source'), 5675 originalLine: line, 5676 originalColumn: util.getArg(aArgs, 'column', 0) 5677 }; 5678 5679 needle.source = this._findSourceIndex(needle.source); 5680 if (needle.source < 0) { 5681 return []; 5682 } 5683 5684 var mappings = []; 5685 5686 var index = this._findMapping(needle, 5687 this._originalMappings, 5688 "originalLine", 5689 "originalColumn", 5690 util.compareByOriginalPositions, 5691 binarySearch.LEAST_UPPER_BOUND); 5692 if (index >= 0) { 5693 var mapping = this._originalMappings[index]; 5694 5695 if (aArgs.column === undefined) { 5696 var originalLine = mapping.originalLine; 5697 5698 // Iterate until either we run out of mappings, or we run into 5699 // a mapping for a different line than the one we found. Since 5700 // mappings are sorted, this is guaranteed to find all mappings for 5701 // the line we found. 5702 while (mapping && mapping.originalLine === originalLine) { 5703 mappings.push({ 5704 line: util.getArg(mapping, 'generatedLine', null), 5705 column: util.getArg(mapping, 'generatedColumn', null), 5706 lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) 5707 }); 5708 5709 mapping = this._originalMappings[++index]; 5710 } 5711 } else { 5712 var originalColumn = mapping.originalColumn; 5713 5714 // Iterate until either we run out of mappings, or we run into 5715 // a mapping for a different line than the one we were searching for. 5716 // Since mappings are sorted, this is guaranteed to find all mappings for 5717 // the line we are searching for. 5718 while (mapping && 5719 mapping.originalLine === line && 5720 mapping.originalColumn == originalColumn) { 5721 mappings.push({ 5722 line: util.getArg(mapping, 'generatedLine', null), 5723 column: util.getArg(mapping, 'generatedColumn', null), 5724 lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) 5725 }); 5726 5727 mapping = this._originalMappings[++index]; 5728 } 5729 } 5730 } 5731 5732 return mappings; 5733 }; 5734 5735exports.SourceMapConsumer = SourceMapConsumer; 5736 5737/** 5738 * A BasicSourceMapConsumer instance represents a parsed source map which we can 5739 * query for information about the original file positions by giving it a file 5740 * position in the generated source. 5741 * 5742 * The first parameter is the raw source map (either as a JSON string, or 5743 * already parsed to an object). According to the spec, source maps have the 5744 * following attributes: 5745 * 5746 * - version: Which version of the source map spec this map is following. 5747 * - sources: An array of URLs to the original source files. 5748 * - names: An array of identifiers which can be referrenced by individual mappings. 5749 * - sourceRoot: Optional. The URL root from which all sources are relative. 5750 * - sourcesContent: Optional. An array of contents of the original source files. 5751 * - mappings: A string of base64 VLQs which contain the actual mappings.
vendor: 19,195 bytes, lines 5752-6308
5752 * - file: Optional. The generated file this source map is associated with. 5753 * 5754 * Here is an example source map, taken from the source map spec[0]: 5755 * 5756 * { 5757 * version : 3, 5758 * file: "out.js", 5759 * sourceRoot : "", 5760 * sources: ["foo.js", "bar.js"], 5761 * names: ["src", "maps", "are", "fun"], 5762 * mappings: "AA,AB;;ABCDE;" 5763 * } 5764 * 5765 * The second parameter, if given, is a string whose value is the URL 5766 * at which the source map was found. This URL is used to compute the 5767 * sources array. 5768 * 5769 * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1# 5770 */ 5771function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) { 5772 var sourceMap = aSourceMap; 5773 if (typeof aSourceMap === 'string') { 5774 sourceMap = util.parseSourceMapInput(aSourceMap); 5775 } 5776 5777 var version = util.getArg(sourceMap, 'version'); 5778 var sources = util.getArg(sourceMap, 'sources'); 5779 // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which 5780 // requires the array) to play nice here. 5781 var names = util.getArg(sourceMap, 'names', []); 5782 var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null); 5783 var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null); 5784 var mappings = util.getArg(sourceMap, 'mappings'); 5785 var file = util.getArg(sourceMap, 'file', null); 5786 5787 // Once again, Sass deviates from the spec and supplies the version as a 5788 // string rather than a number, so we use loose equality checking here. 5789 if (version != this._version) { 5790 throw new Error('Unsupported version: ' + version); 5791 } 5792 5793 if (sourceRoot) { 5794 sourceRoot = util.normalize(sourceRoot); 5795 } 5796 5797 sources = sources 5798 .map(String) 5799 // Some source maps produce relative source paths like "./foo.js" instead of 5800 // "foo.js". Normalize these first so that future comparisons will succeed. 5801 // See bugzil.la/1090768. 5802 .map(util.normalize) 5803 // Always ensure that absolute sources are internally stored relative to 5804 // the source root, if the source root is absolute. Not doing this would 5805 // be particularly problematic when the source root is a prefix of the 5806 // source (valid, but why??). See github issue #199 and bugzil.la/1188982. 5807 .map(function (source) { 5808 return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source) 5809 ? util.relative(sourceRoot, source) 5810 : source; 5811 }); 5812 5813 // Pass `true` below to allow duplicate names and sources. While source maps 5814 // are intended to be compressed and deduplicated, the TypeScript compiler 5815 // sometimes generates source maps with duplicates in them. See Github issue 5816 // #72 and bugzil.la/889492. 5817 this._names = ArraySet.fromArray(names.map(String), true); 5818 this._sources = ArraySet.fromArray(sources, true); 5819 5820 this._absoluteSources = this._sources.toArray().map(function (s) { 5821 return util.computeSourceURL(sourceRoot, s, aSourceMapURL); 5822 }); 5823 5824 this.sourceRoot = sourceRoot; 5825 this.sourcesContent = sourcesContent; 5826 this._mappings = mappings; 5827 this._sourceMapURL = aSourceMapURL; 5828 this.file = file; 5829} 5830 5831BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype); 5832BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer; 5833 5834/** 5835 * Utility function to find the index of a source. Returns -1 if not 5836 * found. 5837 */ 5838BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) { 5839 var relativeSource = aSource; 5840 if (this.sourceRoot != null) { 5841 relativeSource = util.relative(this.sourceRoot, relativeSource); 5842 } 5843 5844 if (this._sources.has(relativeSource)) { 5845 return this._sources.indexOf(relativeSource); 5846 } 5847 5848 // Maybe aSource is an absolute URL as returned by |sources|. In 5849 // this case we can't simply undo the transform. 5850 var i; 5851 for (i = 0; i < this._absoluteSources.length; ++i) { 5852 if (this._absoluteSources[i] == aSource) { 5853 return i; 5854 } 5855 } 5856 5857 return -1; 5858}; 5859 5860/** 5861 * Create a BasicSourceMapConsumer from a SourceMapGenerator. 5862 * 5863 * @param SourceMapGenerator aSourceMap 5864 * The source map that will be consumed. 5865 * @param String aSourceMapURL 5866 * The URL at which the source map can be found (optional) 5867 * @returns BasicSourceMapConsumer 5868 */ 5869BasicSourceMapConsumer.fromSourceMap = 5870 function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) { 5871 var smc = Object.create(BasicSourceMapConsumer.prototype); 5872 5873 var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true); 5874 var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true); 5875 smc.sourceRoot = aSourceMap._sourceRoot; 5876 smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(), 5877 smc.sourceRoot); 5878 smc.file = aSourceMap._file; 5879 smc._sourceMapURL = aSourceMapURL; 5880 smc._absoluteSources = smc._sources.toArray().map(function (s) { 5881 return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL); 5882 }); 5883 5884 // Because we are modifying the entries (by converting string sources and 5885 // names to indices into the sources and names ArraySets), we have to make 5886 // a copy of the entry or else bad things happen. Shared mutable state 5887 // strikes again! See github issue #191. 5888 5889 var generatedMappings = aSourceMap._mappings.toArray().slice(); 5890 var destGeneratedMappings = smc.__generatedMappings = []; 5891 var destOriginalMappings = smc.__originalMappings = []; 5892 5893 for (var i = 0, length = generatedMappings.length; i < length; i++) { 5894 var srcMapping = generatedMappings[i]; 5895 var destMapping = new Mapping; 5896 destMapping.generatedLine = srcMapping.generatedLine; 5897 destMapping.generatedColumn = srcMapping.generatedColumn; 5898 5899 if (srcMapping.source) { 5900 destMapping.source = sources.indexOf(srcMapping.source); 5901 destMapping.originalLine = srcMapping.originalLine; 5902 destMapping.originalColumn = srcMapping.originalColumn; 5903 5904 if (srcMapping.name) { 5905 destMapping.name = names.indexOf(srcMapping.name); 5906 } 5907 5908 destOriginalMappings.push(destMapping); 5909 } 5910 5911 destGeneratedMappings.push(destMapping); 5912 } 5913 5914 quickSort(smc.__originalMappings, util.compareByOriginalPositions); 5915 5916 return smc; 5917 }; 5918 5919/** 5920 * The version of the source mapping spec that we are consuming. 5921 */ 5922BasicSourceMapConsumer.prototype._version = 3; 5923 5924/** 5925 * The list of original sources. 5926 */ 5927Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', { 5928 get: function () { 5929 return this._absoluteSources.slice(); 5930 } 5931}); 5932 5933/** 5934 * Provide the JIT with a nice shape / hidden class. 5935 */ 5936function Mapping() { 5937 this.generatedLine = 0; 5938 this.generatedColumn = 0; 5939 this.source = null; 5940 this.originalLine = null; 5941 this.originalColumn = null; 5942 this.name = null; 5943} 5944 5945/** 5946 * Parse the mappings in a string in to a data structure which we can easily 5947 * query (the ordered arrays in the `this.__generatedMappings` and 5948 * `this.__originalMappings` properties). 5949 */ 5950BasicSourceMapConsumer.prototype._parseMappings = 5951 function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { 5952 var generatedLine = 1; 5953 var previousGeneratedColumn = 0; 5954 var previousOriginalLine = 0; 5955 var previousOriginalColumn = 0; 5956 var previousSource = 0; 5957 var previousName = 0; 5958 var length = aStr.length; 5959 var index = 0; 5960 var cachedSegments = {}; 5961 var temp = {}; 5962 var originalMappings = []; 5963 var generatedMappings = []; 5964 var mapping, str, segment, end, value; 5965 5966 while (index < length) { 5967 if (aStr.charAt(index) === ';') { 5968 generatedLine++; 5969 index++; 5970 previousGeneratedColumn = 0; 5971 } 5972 else if (aStr.charAt(index) === ',') { 5973 index++; 5974 } 5975 else { 5976 mapping = new Mapping(); 5977 mapping.generatedLine = generatedLine; 5978 5979 // Because each offset is encoded relative to the previous one, 5980 // many segments often have the same encoding. We can exploit this 5981 // fact by caching the parsed variable length fields of each segment, 5982 // allowing us to avoid a second parse if we encounter the same 5983 // segment again. 5984 for (end = index; end < length; end++) { 5985 if (this._charIsMappingSeparator(aStr, end)) { 5986 break; 5987 } 5988 } 5989 str = aStr.slice(index, end); 5990 5991 segment = cachedSegments[str]; 5992 if (segment) { 5993 index += str.length; 5994 } else { 5995 segment = []; 5996 while (index < end) { 5997 base64VLQ.decode(aStr, index, temp); 5998 value = temp.value; 5999 index = temp.rest; 6000 segment.push(value); 6001 } 6002 6003 if (segment.length === 2) { 6004 throw new Error('Found a source, but no line and column'); 6005 } 6006 6007 if (segment.length === 3) { 6008 throw new Error('Found a source and line, but no column'); 6009 } 6010 6011 cachedSegments[str] = segment; 6012 } 6013 6014 // Generated column. 6015 mapping.generatedColumn = previousGeneratedColumn + segment[0]; 6016 previousGeneratedColumn = mapping.generatedColumn; 6017 6018 if (segment.length > 1) { 6019 // Original source. 6020 mapping.source = previousSource + segment[1]; 6021 previousSource += segment[1]; 6022 6023 // Original line. 6024 mapping.originalLine = previousOriginalLine + segment[2]; 6025 previousOriginalLine = mapping.originalLine; 6026 // Lines are stored 0-based 6027 mapping.originalLine += 1; 6028 6029 // Original column. 6030 mapping.originalColumn = previousOriginalColumn + segment[3]; 6031 previousOriginalColumn = mapping.originalColumn; 6032 6033 if (segment.length > 4) { 6034 // Original name. 6035 mapping.name = previousName + segment[4]; 6036 previousName += segment[4]; 6037 } 6038 } 6039 6040 generatedMappings.push(mapping); 6041 if (typeof mapping.originalLine === 'number') { 6042 originalMappings.push(mapping); 6043 } 6044 } 6045 } 6046 6047 quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated); 6048 this.__generatedMappings = generatedMappings; 6049 6050 quickSort(originalMappings, util.compareByOriginalPositions); 6051 this.__originalMappings = originalMappings; 6052 }; 6053 6054/** 6055 * Find the mapping that best matches the hypothetical "needle" mapping that 6056 * we are searching for in the given "haystack" of mappings. 6057 */ 6058BasicSourceMapConsumer.prototype._findMapping = 6059 function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName, 6060 aColumnName, aComparator, aBias) { 6061 // To return the position we are searching for, we must first find the 6062 // mapping for the given position and then return the opposite position it 6063 // points to. Because the mappings are sorted, we can use binary search to 6064 // find the best mapping. 6065 6066 if (aNeedle[aLineName] <= 0) { 6067 throw new TypeError('Line must be greater than or equal to 1, got ' 6068 + aNeedle[aLineName]); 6069 } 6070 if (aNeedle[aColumnName] < 0) { 6071 throw new TypeError('Column must be greater than or equal to 0, got ' 6072 + aNeedle[aColumnName]); 6073 } 6074 6075 return binarySearch.search(aNeedle, aMappings, aComparator, aBias); 6076 }; 6077 6078/** 6079 * Compute the last column for each generated mapping. The last column is 6080 * inclusive. 6081 */ 6082BasicSourceMapConsumer.prototype.computeColumnSpans = 6083 function SourceMapConsumer_computeColumnSpans() { 6084 for (var index = 0; index < this._generatedMappings.length; ++index) { 6085 var mapping = this._generatedMappings[index]; 6086 6087 // Mappings do not contain a field for the last generated columnt. We 6088 // can come up with an optimistic estimate, however, by assuming that 6089 // mappings are contiguous (i.e. given two consecutive mappings, the 6090 // first mapping ends where the second one starts). 6091 if (index + 1 < this._generatedMappings.length) { 6092 var nextMapping = this._generatedMappings[index + 1]; 6093 6094 if (mapping.generatedLine === nextMapping.generatedLine) { 6095 mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1; 6096 continue; 6097 } 6098 } 6099 6100 // The last mapping for each line spans the entire line. 6101 mapping.lastGeneratedColumn = Infinity; 6102 } 6103 }; 6104 6105/** 6106 * Returns the original source, line, and column information for the generated 6107 * source's line and column positions provided. The only argument is an object 6108 * with the following properties: 6109 * 6110 * - line: The line number in the generated source. The line number 6111 * is 1-based. 6112 * - column: The column number in the generated source. The column 6113 * number is 0-based. 6114 * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or 6115 * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the 6116 * closest element that is smaller than or greater than the one we are 6117 * searching for, respectively, if the exact element cannot be found. 6118 * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'. 6119 * 6120 * and an object is returned with the following properties: 6121 * 6122 * - source: The original source file, or null. 6123 * - line: The line number in the original source, or null. The 6124 * line number is 1-based. 6125 * - column: The column number in the original source, or null. The 6126 * column number is 0-based. 6127 * - name: The original identifier, or null. 6128 */ 6129BasicSourceMapConsumer.prototype.originalPositionFor = 6130 function SourceMapConsumer_originalPositionFor(aArgs) { 6131 var needle = { 6132 generatedLine: util.getArg(aArgs, 'line'), 6133 generatedColumn: util.getArg(aArgs, 'column') 6134 }; 6135 6136 var index = this._findMapping( 6137 needle, 6138 this._generatedMappings, 6139 "generatedLine", 6140 "generatedColumn", 6141 util.compareByGeneratedPositionsDeflated, 6142 util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND) 6143 ); 6144 6145 if (index >= 0) { 6146 var mapping = this._generatedMappings[index]; 6147 6148 if (mapping.generatedLine === needle.generatedLine) { 6149 var source = util.getArg(mapping, 'source', null); 6150 if (source !== null) { 6151 source = this._sources.at(source); 6152 source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL); 6153 } 6154 var name = util.getArg(mapping, 'name', null); 6155 if (name !== null) { 6156 name = this._names.at(name); 6157 } 6158 return { 6159 source: source, 6160 line: util.getArg(mapping, 'originalLine', null), 6161 column: util.getArg(mapping, 'originalColumn', null), 6162 name: name 6163 }; 6164 } 6165 } 6166 6167 return { 6168 source: null, 6169 line: null, 6170 column: null, 6171 name: null 6172 }; 6173 }; 6174 6175/** 6176 * Return true if we have the source content for every source in the source 6177 * map, false otherwise. 6178 */ 6179BasicSourceMapConsumer.prototype.hasContentsOfAllSources = 6180 function BasicSourceMapConsumer_hasContentsOfAllSources() { 6181 if (!this.sourcesContent) { 6182 return false; 6183 } 6184 return this.sourcesContent.length >= this._sources.size() && 6185 !this.sourcesContent.some(function (sc) { return sc == null; }); 6186 }; 6187 6188/** 6189 * Returns the original source content. The only argument is the url of the 6190 * original source file. Returns null if no original source content is 6191 * available. 6192 */ 6193BasicSourceMapConsumer.prototype.sourceContentFor = 6194 function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) { 6195 if (!this.sourcesContent) { 6196 return null; 6197 } 6198 6199 var index = this._findSourceIndex(aSource); 6200 if (index >= 0) { 6201 return this.sourcesContent[index]; 6202 } 6203 6204 var relativeSource = aSource; 6205 if (this.sourceRoot != null) { 6206 relativeSource = util.relative(this.sourceRoot, relativeSource); 6207 } 6208 6209 var url; 6210 if (this.sourceRoot != null 6211 && (url = util.urlParse(this.sourceRoot))) { 6212 // XXX: file:// URIs and absolute paths lead to unexpected behavior for 6213 // many users. We can help them out when they expect file:// URIs to 6214 // behave like it would if they were running a local HTTP server. See 6215 // https://bugzilla.mozilla.org/show_bug.cgi?id=885597. 6216 var fileUriAbsPath = relativeSource.replace(/^file:\/\//, ""); 6217 if (url.scheme == "file" 6218 && this._sources.has(fileUriAbsPath)) { 6219 return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)] 6220 } 6221 6222 if ((!url.path || url.path == "/") 6223 && this._sources.has("/" + relativeSource)) { 6224 return this.sourcesContent[this._sources.indexOf("/" + relativeSource)]; 6225 } 6226 } 6227 6228 // This function is used recursively from 6229 // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we 6230 // don't want to throw if we can't find the source - we just want to 6231 // return null, so we provide a flag to exit gracefully. 6232 if (nullOnMissing) { 6233 return null; 6234 } 6235 else { 6236 throw new Error('"' + relativeSource + '" is not in the SourceMap.'); 6237 } 6238 }; 6239 6240/** 6241 * Returns the generated line and column information for the original source, 6242 * line, and column positions provided. The only argument is an object with 6243 * the following properties: 6244 * 6245 * - source: The filename of the original source. 6246 * - line: The line number in the original source. The line number 6247 * is 1-based. 6248 * - column: The column number in the original source. The column 6249 * number is 0-based. 6250 * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or 6251 * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the 6252 * closest element that is smaller than or greater than the one we are 6253 * searching for, respectively, if the exact element cannot be found. 6254 * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'. 6255 * 6256 * and an object is returned with the following properties: 6257 * 6258 * - line: The line number in the generated source, or null. The 6259 * line number is 1-based. 6260 * - column: The column number in the generated source, or null. 6261 * The column number is 0-based. 6262 */ 6263BasicSourceMapConsumer.prototype.generatedPositionFor = 6264 function SourceMapConsumer_generatedPositionFor(aArgs) { 6265 var source = util.getArg(aArgs, 'source'); 6266 source = this._findSourceIndex(source); 6267 if (source < 0) { 6268 return { 6269 line: null, 6270 column: null, 6271 lastColumn: null 6272 }; 6273 } 6274 6275 var needle = { 6276 source: source, 6277 originalLine: util.getArg(aArgs, 'line'), 6278 originalColumn: util.getArg(aArgs, 'column') 6279 }; 6280 6281 var index = this._findMapping( 6282 needle, 6283 this._originalMappings, 6284 "originalLine", 6285 "originalColumn", 6286 util.compareByOriginalPositions, 6287 util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND) 6288 ); 6289 6290 if (index >= 0) { 6291 var mapping = this._originalMappings[index]; 6292 6293 if (mapping.source === needle.source) { 6294 return { 6295 line: util.getArg(mapping, 'generatedLine', null), 6296 column: util.getArg(mapping, 'generatedColumn', null), 6297 lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) 6298 }; 6299 } 6300 } 6301 6302 return { 6303 line: null, 6304 column: null, 6305 lastColumn: null 6306 }; 6307 }; 6308
vendor: 4,914 bytes, lines 6309-6450
6309exports.BasicSourceMapConsumer = BasicSourceMapConsumer; 6310 6311/** 6312 * An IndexedSourceMapConsumer instance represents a parsed source map which 6313 * we can query for information. It differs from BasicSourceMapConsumer in 6314 * that it takes "indexed" source maps (i.e. ones with a "sections" field) as 6315 * input. 6316 * 6317 * The first parameter is a raw source map (either as a JSON string, or already 6318 * parsed to an object). According to the spec for indexed source maps, they 6319 * have the following attributes: 6320 * 6321 * - version: Which version of the source map spec this map is following. 6322 * - file: Optional. The generated file this source map is associated with. 6323 * - sections: A list of section definitions. 6324 * 6325 * Each value under the "sections" field has two fields: 6326 * - offset: The offset into the original specified at which this section 6327 * begins to apply, defined as an object with a "line" and "column" 6328 * field. 6329 * - map: A source map definition. This source map could also be indexed, 6330 * but doesn't have to be. 6331 * 6332 * Instead of the "map" field, it's also possible to have a "url" field 6333 * specifying a URL to retrieve a source map from, but that's currently 6334 * unsupported. 6335 * 6336 * Here's an example source map, taken from the source map spec[0], but 6337 * modified to omit a section which uses the "url" field. 6338 * 6339 * { 6340 * version : 3, 6341 * file: "app.js", 6342 * sections: [{ 6343 * offset: {line:100, column:10}, 6344 * map: { 6345 * version : 3, 6346 * file: "section.js", 6347 * sources: ["foo.js", "bar.js"], 6348 * names: ["src", "maps", "are", "fun"], 6349 * mappings: "AAAA,E;;ABCDE;" 6350 * } 6351 * }], 6352 * } 6353 * 6354 * The second parameter, if given, is a string whose value is the URL 6355 * at which the source map was found. This URL is used to compute the 6356 * sources array. 6357 * 6358 * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt 6359 */ 6360function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) { 6361 var sourceMap = aSourceMap; 6362 if (typeof aSourceMap === 'string') { 6363 sourceMap = util.parseSourceMapInput(aSourceMap); 6364 } 6365 6366 var version = util.getArg(sourceMap, 'version'); 6367 var sections = util.getArg(sourceMap, 'sections'); 6368 6369 if (version != this._version) { 6370 throw new Error('Unsupported version: ' + version); 6371 } 6372 6373 this._sources = new ArraySet(); 6374 this._names = new ArraySet(); 6375 6376 var lastOffset = { 6377 line: -1, 6378 column: 0 6379 }; 6380 this._sections = sections.map(function (s) { 6381 if (s.url) { 6382 // The url field will require support for asynchronicity. 6383 // See https://github.com/mozilla/source-map/issues/16 6384 throw new Error('Support for url field in sections not implemented.'); 6385 } 6386 var offset = util.getArg(s, 'offset'); 6387 var offsetLine = util.getArg(offset, 'line'); 6388 var offsetColumn = util.getArg(offset, 'column'); 6389 6390 if (offsetLine < lastOffset.line || 6391 (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) { 6392 throw new Error('Section offsets must be ordered and non-overlapping.'); 6393 } 6394 lastOffset = offset; 6395 6396 return { 6397 generatedOffset: { 6398 // The offset fields are 0-based, but we use 1-based indices when 6399 // encoding/decoding from VLQ. 6400 generatedLine: offsetLine + 1, 6401 generatedColumn: offsetColumn + 1 6402 }, 6403 consumer: new SourceMapConsumer(util.getArg(s, 'map'), aSourceMapURL) 6404 } 6405 }); 6406} 6407 6408IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype); 6409IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer; 6410 6411/** 6412 * The version of the source mapping spec that we are consuming. 6413 */ 6414IndexedSourceMapConsumer.prototype._version = 3; 6415 6416/** 6417 * The list of original sources. 6418 */ 6419Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', { 6420 get: function () { 6421 var sources = []; 6422 for (var i = 0; i < this._sections.length; i++) { 6423 for (var j = 0; j < this._sections[i].consumer.sources.length; j++) { 6424 sources.push(this._sections[i].consumer.sources[j]); 6425 } 6426 } 6427 return sources; 6428 } 6429}); 6430 6431/** 6432 * Returns the original source, line, and column information for the generated 6433 * source's line and column positions provided. The only argument is an object 6434 * with the following properties: 6435 * 6436 * - line: The line number in the generated source. The line number 6437 * is 1-based. 6438 * - column: The column number in the generated source. The column 6439 * number is 0-based. 6440 * 6441 * and an object is returned with the following properties: 6442 * 6443 * - source: The original source file, or null. 6444 * - line: The line number in the original source, or null. The 6445 * line number is 1-based. 6446 * - column: The column number in the original source, or null. The 6447 * column number is 0-based. 6448 * - name: The original identifier, or null. 6449 */ 6450IndexedSourceMapConsumer.prototype.originalPositionFor =
vendor: 6,650 bytes, lines 6451-6641
6451 function IndexedSourceMapConsumer_originalPositionFor(aArgs) { 6452 var needle = { 6453 generatedLine: util.getArg(aArgs, 'line'), 6454 generatedColumn: util.getArg(aArgs, 'column') 6455 }; 6456 6457 // Find the section containing the generated position we're trying to map 6458 // to an original position. 6459 var sectionIndex = binarySearch.search(needle, this._sections, 6460 function(needle, section) { 6461 var cmp = needle.generatedLine - section.generatedOffset.generatedLine; 6462 if (cmp) { 6463 return cmp; 6464 } 6465 6466 return (needle.generatedColumn - 6467 section.generatedOffset.generatedColumn); 6468 }); 6469 var section = this._sections[sectionIndex]; 6470 6471 if (!section) { 6472 return { 6473 source: null, 6474 line: null, 6475 column: null, 6476 name: null 6477 }; 6478 } 6479 6480 return section.consumer.originalPositionFor({ 6481 line: needle.generatedLine - 6482 (section.generatedOffset.generatedLine - 1), 6483 column: needle.generatedColumn - 6484 (section.generatedOffset.generatedLine === needle.generatedLine 6485 ? section.generatedOffset.generatedColumn - 1 6486 : 0), 6487 bias: aArgs.bias 6488 }); 6489 }; 6490 6491/** 6492 * Return true if we have the source content for every source in the source 6493 * map, false otherwise. 6494 */ 6495IndexedSourceMapConsumer.prototype.hasContentsOfAllSources = 6496 function IndexedSourceMapConsumer_hasContentsOfAllSources() { 6497 return this._sections.every(function (s) { 6498 return s.consumer.hasContentsOfAllSources(); 6499 }); 6500 }; 6501 6502/** 6503 * Returns the original source content. The only argument is the url of the 6504 * original source file. Returns null if no original source content is 6505 * available. 6506 */ 6507IndexedSourceMapConsumer.prototype.sourceContentFor = 6508 function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) { 6509 for (var i = 0; i < this._sections.length; i++) { 6510 var section = this._sections[i]; 6511 6512 var content = section.consumer.sourceContentFor(aSource, true); 6513 if (content) { 6514 return content; 6515 } 6516 } 6517 if (nullOnMissing) { 6518 return null; 6519 } 6520 else { 6521 throw new Error('"' + aSource + '" is not in the SourceMap.'); 6522 } 6523 }; 6524 6525/** 6526 * Returns the generated line and column information for the original source, 6527 * line, and column positions provided. The only argument is an object with 6528 * the following properties: 6529 * 6530 * - source: The filename of the original source. 6531 * - line: The line number in the original source. The line number 6532 * is 1-based. 6533 * - column: The column number in the original source. The column 6534 * number is 0-based. 6535 * 6536 * and an object is returned with the following properties: 6537 * 6538 * - line: The line number in the generated source, or null. The 6539 * line number is 1-based. 6540 * - column: The column number in the generated source, or null. 6541 * The column number is 0-based. 6542 */ 6543IndexedSourceMapConsumer.prototype.generatedPositionFor = 6544 function IndexedSourceMapConsumer_generatedPositionFor(aArgs) { 6545 for (var i = 0; i < this._sections.length; i++) { 6546 var section = this._sections[i]; 6547 6548 // Only consider this section if the requested source is in the list of 6549 // sources of the consumer. 6550 if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) { 6551 continue; 6552 } 6553 var generatedPosition = section.consumer.generatedPositionFor(aArgs); 6554 if (generatedPosition) { 6555 var ret = { 6556 line: generatedPosition.line + 6557 (section.generatedOffset.generatedLine - 1), 6558 column: generatedPosition.column + 6559 (section.generatedOffset.generatedLine === generatedPosition.line 6560 ? section.generatedOffset.generatedColumn - 1 6561 : 0) 6562 }; 6563 return ret; 6564 } 6565 } 6566 6567 return { 6568 line: null, 6569 column: null 6570 }; 6571 }; 6572 6573/** 6574 * Parse the mappings in a string in to a data structure which we can easily 6575 * query (the ordered arrays in the `this.__generatedMappings` and 6576 * `this.__originalMappings` properties). 6577 */ 6578IndexedSourceMapConsumer.prototype._parseMappings = 6579 function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) { 6580 this.__generatedMappings = []; 6581 this.__originalMappings = []; 6582 for (var i = 0; i < this._sections.length; i++) { 6583 var section = this._sections[i]; 6584 var sectionMappings = section.consumer._generatedMappings; 6585 for (var j = 0; j < sectionMappings.length; j++) { 6586 var mapping = sectionMappings[j]; 6587 6588 var source = section.consumer._sources.at(mapping.source); 6589 source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL); 6590 this._sources.add(source); 6591 source = this._sources.indexOf(source); 6592 6593 var name = null; 6594 if (mapping.name) { 6595 name = section.consumer._names.at(mapping.name); 6596 this._names.add(name); 6597 name = this._names.indexOf(name); 6598 } 6599 6600 // The mappings coming from the consumer for the section have 6601 // generated positions relative to the start of the section, so we 6602 // need to offset them to be relative to the start of the concatenated 6603 // generated file. 6604 var adjustedMapping = { 6605 source: source, 6606 generatedLine: mapping.generatedLine + 6607 (section.generatedOffset.generatedLine - 1), 6608 generatedColumn: mapping.generatedColumn + 6609 (section.generatedOffset.generatedLine === mapping.generatedLine 6610 ? section.generatedOffset.generatedColumn - 1 6611 : 0), 6612 originalLine: mapping.originalLine, 6613 originalColumn: mapping.originalColumn, 6614 name: name 6615 }; 6616 6617 this.__generatedMappings.push(adjustedMapping); 6618 if (typeof adjustedMapping.originalLine === 'number') { 6619 this.__originalMappings.push(adjustedMapping); 6620 } 6621 } 6622 } 6623 6624 quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated); 6625 quickSort(this.__originalMappings, util.compareByOriginalPositions); 6626 }; 6627 6628exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer; 6629 6630},{"./array-set":31,"./base64-vlq":32,"./binary-search":34,"./quick-sort":36,"./util":40}],38:[function(require,module,exports){ 6631/* -*- Mode: js; js-indent-level: 2; -*- */ 6632/* 6633 * Copyright 2011 Mozilla Foundation and contributors 6634 * Licensed under the New BSD license. See LICENSE or: 6635 * http://opensource.org/licenses/BSD-3-Clause 6636 */ 6637 6638var base64VLQ = require('./base64-vlq'); 6639var util = require('./util'); 6640var ArraySet = require('./array-set').ArraySet; 6641var MappingList = require('./mapping-list').MappingList
vendor: 13,933 bytes, lines 6641-7055
6641; 6642 6643/** 6644 * An instance of the SourceMapGenerator represents a source map which is 6645 * being built incrementally. You may pass an object with the following 6646 * properties: 6647 * 6648 * - file: The filename of the generated source. 6649 * - sourceRoot: A root for all relative URLs in this source map. 6650 */ 6651function SourceMapGenerator(aArgs) { 6652 if (!aArgs) { 6653 aArgs = {}; 6654 } 6655 this._file = util.getArg(aArgs, 'file', null); 6656 this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null); 6657 this._skipValidation = util.getArg(aArgs, 'skipValidation', false); 6658 this._sources = new ArraySet(); 6659 this._names = new ArraySet(); 6660 this._mappings = new MappingList(); 6661 this._sourcesContents = null; 6662} 6663 6664SourceMapGenerator.prototype._version = 3; 6665 6666/** 6667 * Creates a new SourceMapGenerator based on a SourceMapConsumer 6668 * 6669 * @param aSourceMapConsumer The SourceMap. 6670 */ 6671SourceMapGenerator.fromSourceMap = 6672 function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) { 6673 var sourceRoot = aSourceMapConsumer.sourceRoot; 6674 var generator = new SourceMapGenerator({ 6675 file: aSourceMapConsumer.file, 6676 sourceRoot: sourceRoot 6677 }); 6678 aSourceMapConsumer.eachMapping(function (mapping) { 6679 var newMapping = { 6680 generated: { 6681 line: mapping.generatedLine, 6682 column: mapping.generatedColumn 6683 } 6684 }; 6685 6686 if (mapping.source != null) { 6687 newMapping.source = mapping.source; 6688 if (sourceRoot != null) { 6689 newMapping.source = util.relative(sourceRoot, newMapping.source); 6690 } 6691 6692 newMapping.original = { 6693 line: mapping.originalLine, 6694 column: mapping.originalColumn 6695 }; 6696 6697 if (mapping.name != null) { 6698 newMapping.name = mapping.name; 6699 } 6700 } 6701 6702 generator.addMapping(newMapping); 6703 }); 6704 aSourceMapConsumer.sources.forEach(function (sourceFile) { 6705 var sourceRelative = sourceFile; 6706 if (sourceRoot !== null) { 6707 sourceRelative = util.relative(sourceRoot, sourceFile); 6708 } 6709 6710 if (!generator._sources.has(sourceRelative)) { 6711 generator._sources.add(sourceRelative); 6712 } 6713 6714 var content = aSourceMapConsumer.sourceContentFor(sourceFile); 6715 if (content != null) { 6716 generator.setSourceContent(sourceFile, content); 6717 } 6718 }); 6719 return generator; 6720 }; 6721 6722/** 6723 * Add a single mapping from original source line and column to the generated 6724 * source's line and column for this source map being created. The mapping 6725 * object should have the following properties: 6726 * 6727 * - generated: An object with the generated line and column positions. 6728 * - original: An object with the original line and column positions. 6729 * - source: The original source file (relative to the sourceRoot). 6730 * - name: An optional original token name for this mapping. 6731 */ 6732SourceMapGenerator.prototype.addMapping = 6733 function SourceMapGenerator_addMapping(aArgs) { 6734 var generated = util.getArg(aArgs, 'generated'); 6735 var original = util.getArg(aArgs, 'original', null); 6736 var source = util.getArg(aArgs, 'source', null); 6737 var name = util.getArg(aArgs, 'name', null); 6738 6739 if (!this._skipValidation) { 6740 this._validateMapping(generated, original, source, name); 6741 } 6742 6743 if (source != null) { 6744 source = String(source); 6745 if (!this._sources.has(source)) { 6746 this._sources.add(source); 6747 } 6748 } 6749 6750 if (name != null) { 6751 name = String(name); 6752 if (!this._names.has(name)) { 6753 this._names.add(name); 6754 } 6755 } 6756 6757 this._mappings.add({ 6758 generatedLine: generated.line, 6759 generatedColumn: generated.column, 6760 originalLine: original != null && original.line, 6761 originalColumn: original != null && original.column, 6762 source: source, 6763 name: name 6764 }); 6765 }; 6766 6767/** 6768 * Set the source content for a source file. 6769 */ 6770SourceMapGenerator.prototype.setSourceContent = 6771 function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) { 6772 var source = aSourceFile; 6773 if (this._sourceRoot != null) { 6774 source = util.relative(this._sourceRoot, source); 6775 } 6776 6777 if (aSourceContent != null) { 6778 // Add the source content to the _sourcesContents map. 6779 // Create a new _sourcesContents map if the property is null. 6780 if (!this._sourcesContents) { 6781 this._sourcesContents = Object.create(null); 6782 } 6783 this._sourcesContents[util.toSetString(source)] = aSourceContent; 6784 } else if (this._sourcesContents) { 6785 // Remove the source file from the _sourcesContents map. 6786 // If the _sourcesContents map is empty, set the property to null. 6787 delete this._sourcesContents[util.toSetString(source)]; 6788 if (Object.keys(this._sourcesContents).length === 0) { 6789 this._sourcesContents = null; 6790 } 6791 } 6792 }; 6793 6794/** 6795 * Applies the mappings of a sub-source-map for a specific source file to the 6796 * source map being generated. Each mapping to the supplied source file is 6797 * rewritten using the supplied source map. Note: The resolution for the 6798 * resulting mappings is the minimium of this map and the supplied map. 6799 * 6800 * @param aSourceMapConsumer The source map to be applied. 6801 * @param aSourceFile Optional. The filename of the source file. 6802 * If omitted, SourceMapConsumer's file property will be used. 6803 * @param aSourceMapPath Optional. The dirname of the path to the source map 6804 * to be applied. If relative, it is relative to the SourceMapConsumer. 6805 * This parameter is needed when the two source maps aren't in the same 6806 * directory, and the source map to be applied contains relative source 6807 * paths. If so, those relative source paths need to be rewritten 6808 * relative to the SourceMapGenerator. 6809 */ 6810SourceMapGenerator.prototype.applySourceMap = 6811 function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) { 6812 var sourceFile = aSourceFile; 6813 // If aSourceFile is omitted, we will use the file property of the SourceMap 6814 if (aSourceFile == null) { 6815 if (aSourceMapConsumer.file == null) { 6816 throw new Error( 6817 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' + 6818 'or the source map\'s "file" property. Both were omitted.' 6819 ); 6820 } 6821 sourceFile = aSourceMapConsumer.file; 6822 } 6823 var sourceRoot = this._sourceRoot; 6824 // Make "sourceFile" relative if an absolute Url is passed. 6825 if (sourceRoot != null) { 6826 sourceFile = util.relative(sourceRoot, sourceFile); 6827 } 6828 // Applying the SourceMap can add and remove items from the sources and 6829 // the names array. 6830 var newSources = new ArraySet(); 6831 var newNames = new ArraySet(); 6832 6833 // Find mappings for the "sourceFile" 6834 this._mappings.unsortedForEach(function (mapping) { 6835 if (mapping.source === sourceFile && mapping.originalLine != null) { 6836 // Check if it can be mapped by the source map, then update the mapping. 6837 var original = aSourceMapConsumer.originalPositionFor({ 6838 line: mapping.originalLine, 6839 column: mapping.originalColumn 6840 }); 6841 if (original.source != null) { 6842 // Copy mapping 6843 mapping.source = original.source; 6844 if (aSourceMapPath != null) { 6845 mapping.source = util.join(aSourceMapPath, mapping.source) 6846 } 6847 if (sourceRoot != null) { 6848 mapping.source = util.relative(sourceRoot, mapping.source); 6849 } 6850 mapping.originalLine = original.line; 6851 mapping.originalColumn = original.column; 6852 if (original.name != null) { 6853 mapping.name = original.name; 6854 } 6855 } 6856 } 6857 6858 var source = mapping.source; 6859 if (source != null && !newSources.has(source)) { 6860 newSources.add(source); 6861 } 6862 6863 var name = mapping.name; 6864 if (name != null && !newNames.has(name)) { 6865 newNames.add(name); 6866 } 6867 6868 }, this); 6869 this._sources = newSources; 6870 this._names = newNames; 6871 6872 // Copy sourcesContents of applied map. 6873 aSourceMapConsumer.sources.forEach(function (sourceFile) { 6874 var content = aSourceMapConsumer.sourceContentFor(sourceFile); 6875 if (content != null) { 6876 if (aSourceMapPath != null) { 6877 sourceFile = util.join(aSourceMapPath, sourceFile); 6878 } 6879 if (sourceRoot != null) { 6880 sourceFile = util.relative(sourceRoot, sourceFile); 6881 } 6882 this.setSourceContent(sourceFile, content); 6883 } 6884 }, this); 6885 }; 6886 6887/** 6888 * A mapping can have one of the three levels of data: 6889 * 6890 * 1. Just the generated position. 6891 * 2. The Generated position, original position, and original source. 6892 * 3. Generated and original position, original source, as well as a name 6893 * token. 6894 * 6895 * To maintain consistency, we validate that any new mapping being added falls 6896 * in to one of these categories. 6897 */ 6898SourceMapGenerator.prototype._validateMapping = 6899 function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, 6900 aName) { 6901 // When aOriginal is truthy but has empty values for .line and .column, 6902 // it is most likely a programmer error. In this case we throw a very 6903 // specific error message to try to guide them the right way. 6904 // For example: https://github.com/Polymer/polymer-bundler/pull/519 6905 if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') { 6906 throw new Error( 6907 'original.line and original.column are not numbers -- you probably meant to omit ' + 6908 'the original mapping entirely and only map the generated position. If so, pass ' + 6909 'null for the original mapping instead of an object with empty or null values.' 6910 ); 6911 } 6912 6913 if (aGenerated && 'line' in aGenerated && 'column' in aGenerated 6914 && aGenerated.line > 0 && aGenerated.column >= 0 6915 && !aOriginal && !aSource && !aName) { 6916 // Case 1. 6917 return; 6918 } 6919 else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated 6920 && aOriginal && 'line' in aOriginal && 'column' in aOriginal 6921 && aGenerated.line > 0 && aGenerated.column >= 0 6922 && aOriginal.line > 0 && aOriginal.column >= 0 6923 && aSource) { 6924 // Cases 2 and 3. 6925 return; 6926 } 6927 else { 6928 throw new Error('Invalid mapping: ' + JSON.stringify({ 6929 generated: aGenerated, 6930 source: aSource, 6931 original: aOriginal, 6932 name: aName 6933 })); 6934 } 6935 }; 6936 6937/** 6938 * Serialize the accumulated mappings in to the stream of base 64 VLQs 6939 * specified by the source map format. 6940 */ 6941SourceMapGenerator.prototype._serializeMappings = 6942 function SourceMapGenerator_serializeMappings() { 6943 var previousGeneratedColumn = 0; 6944 var previousGeneratedLine = 1; 6945 var previousOriginalColumn = 0; 6946 var previousOriginalLine = 0; 6947 var previousName = 0; 6948 var previousSource = 0; 6949 var result = ''; 6950 var next; 6951 var mapping; 6952 var nameIdx; 6953 var sourceIdx; 6954 6955 var mappings = this._mappings.toArray(); 6956 for (var i = 0, len = mappings.length; i < len; i++) { 6957 mapping = mappings[i]; 6958 next = '' 6959 6960 if (mapping.generatedLine !== previousGeneratedLine) { 6961 previousGeneratedColumn = 0; 6962 while (mapping.generatedLine !== previousGeneratedLine) { 6963 next += ';'; 6964 previousGeneratedLine++; 6965 } 6966 } 6967 else { 6968 if (i > 0) { 6969 if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) { 6970 continue; 6971 } 6972 next += ','; 6973 } 6974 } 6975 6976 next += base64VLQ.encode(mapping.generatedColumn 6977 - previousGeneratedColumn); 6978 previousGeneratedColumn = mapping.generatedColumn; 6979 6980 if (mapping.source != null) { 6981 sourceIdx = this._sources.indexOf(mapping.source); 6982 next += base64VLQ.encode(sourceIdx - previousSource); 6983 previousSource = sourceIdx; 6984 6985 // lines are stored 0-based in SourceMap spec version 3 6986 next += base64VLQ.encode(mapping.originalLine - 1 6987 - previousOriginalLine); 6988 previousOriginalLine = mapping.originalLine - 1; 6989 6990 next += base64VLQ.encode(mapping.originalColumn 6991 - previousOriginalColumn); 6992 previousOriginalColumn = mapping.originalColumn; 6993 6994 if (mapping.name != null) { 6995 nameIdx = this._names.indexOf(mapping.name); 6996 next += base64VLQ.encode(nameIdx - previousName); 6997 previousName = nameIdx; 6998 } 6999 } 7000 7001 result += next; 7002 } 7003 7004 return result; 7005 }; 7006 7007SourceMapGenerator.prototype._generateSourcesContent = 7008 function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) { 7009 return aSources.map(function (source) { 7010 if (!this._sourcesContents) { 7011 return null; 7012 } 7013 if (aSourceRoot != null) { 7014 source = util.relative(aSourceRoot, source); 7015 } 7016 var key = util.toSetString(source); 7017 return Object.prototype.hasOwnProperty.call(this._sourcesContents, key) 7018 ? this._sourcesContents[key] 7019 : null; 7020 }, this); 7021 }; 7022 7023/** 7024 * Externalize the source map. 7025 */ 7026SourceMapGenerator.prototype.toJSON = 7027 function SourceMapGenerator_toJSON() { 7028 var map = { 7029 version: this._version, 7030 sources: this._sources.toArray(), 7031 names: this._names.toArray(), 7032 mappings: this._serializeMappings() 7033 }; 7034 if (this._file != null) { 7035 map.file = this._file; 7036 } 7037 if (this._sourceRoot != null) { 7038 map.sourceRoot = this._sourceRoot; 7039 } 7040 if (this._sourcesContents) { 7041 map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot); 7042 } 7043 7044 return map; 7045 }; 7046 7047/** 7048 * Render the source map being generated to a string. 7049 */ 7050SourceMapGenerator.prototype.toString = 7051 function SourceMapGenerator_toString() { 7052 return JSON.stringify(this.toJSON()); 7053 }; 7054 7055exports.
7055SourceMapGenerator = SourceMapGenerator; 7056 7057},{"./array-set":31,"./base64-vlq":32,"./mapping-list":35,"./util":40}],39:[function(require,module,exports){ 7058/* -*- Mode: js; js-indent-level: 2; -*- */ 7059/* 7060 * Copyright 2011 Mozilla Foundation and contributors 7061 * Licensed under the New BSD license. See LICENSE or: 7062 * http://opensource.org/licenses/BSD-3-Clause 7063 */ 7064 7065var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator; 7066var util = require('./util'
vendor: 13,495 bytes, lines 7066-7471
7066); 7067 7068// Matches a Windows-style `\r\n` newline or a `\n` newline used by all other 7069// operating systems these days (capturing the result). 7070var REGEX_NEWLINE = /(\r?\n)/; 7071 7072// Newline character code for charCodeAt() comparisons 7073var NEWLINE_CODE = 10; 7074 7075// Private symbol for identifying `SourceNode`s when multiple versions of 7076// the source-map library are loaded. This MUST NOT CHANGE across 7077// versions! 7078var isSourceNode = "$$$isSourceNode$$$"; 7079 7080/** 7081 * SourceNodes provide a way to abstract over interpolating/concatenating 7082 * snippets of generated JavaScript source code while maintaining the line and 7083 * column information associated with the original source code. 7084 * 7085 * @param aLine The original line number. 7086 * @param aColumn The original column number. 7087 * @param aSource The original source's filename. 7088 * @param aChunks Optional. An array of strings which are snippets of 7089 * generated JS, or other SourceNodes. 7090 * @param aName The original identifier. 7091 */ 7092function SourceNode(aLine, aColumn, aSource, aChunks, aName) { 7093 this.children = []; 7094 this.sourceContents = {}; 7095 this.line = aLine == null ? null : aLine; 7096 this.column = aColumn == null ? null : aColumn; 7097 this.source = aSource == null ? null : aSource; 7098 this.name = aName == null ? null : aName; 7099 this[isSourceNode] = true; 7100 if (aChunks != null) this.add(aChunks); 7101} 7102 7103/** 7104 * Creates a SourceNode from generated code and a SourceMapConsumer. 7105 * 7106 * @param aGeneratedCode The generated code 7107 * @param aSourceMapConsumer The SourceMap for the generated code 7108 * @param aRelativePath Optional. The path that relative sources in the 7109 * SourceMapConsumer should be relative to. 7110 */ 7111SourceNode.fromStringWithSourceMap = 7112 function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) { 7113 // The SourceNode we want to fill with the generated code 7114 // and the SourceMap 7115 var node = new SourceNode(); 7116 7117 // All even indices of this array are one line of the generated code, 7118 // while all odd indices are the newlines between two adjacent lines 7119 // (since `REGEX_NEWLINE` captures its match). 7120 // Processed fragments are accessed by calling `shiftNextLine`. 7121 var remainingLines = aGeneratedCode.split(REGEX_NEWLINE); 7122 var remainingLinesIndex = 0; 7123 var shiftNextLine = function() { 7124 var lineContents = getNextLine(); 7125 // The last line of a file might not have a newline. 7126 var newLine = getNextLine() || ""; 7127 return lineContents + newLine; 7128 7129 function getNextLine() { 7130 return remainingLinesIndex < remainingLines.length ? 7131 remainingLines[remainingLinesIndex++] : undefined; 7132 } 7133 }; 7134 7135 // We need to remember the position of "remainingLines" 7136 var lastGeneratedLine = 1, lastGeneratedColumn = 0; 7137 7138 // The generate SourceNodes we need a code range. 7139 // To extract it current and last mapping is used. 7140 // Here we store the last mapping. 7141 var lastMapping = null; 7142 7143 aSourceMapConsumer.eachMapping(function (mapping) { 7144 if (lastMapping !== null) { 7145 // We add the code from "lastMapping" to "mapping": 7146 // First check if there is a new line in between. 7147 if (lastGeneratedLine < mapping.generatedLine) { 7148 // Associate first line with "lastMapping" 7149 addMappingWithCode(lastMapping, shiftNextLine()); 7150 lastGeneratedLine++; 7151 lastGeneratedColumn = 0; 7152 // The remaining code is added without mapping 7153 } else { 7154 // There is no new line in between. 7155 // Associate the code between "lastGeneratedColumn" and 7156 // "mapping.generatedColumn" with "lastMapping" 7157 var nextLine = remainingLines[remainingLinesIndex] || ''; 7158 var code = nextLine.substr(0, mapping.generatedColumn - 7159 lastGeneratedColumn); 7160 remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn - 7161 lastGeneratedColumn); 7162 lastGeneratedColumn = mapping.generatedColumn; 7163 addMappingWithCode(lastMapping, code); 7164 // No more remaining code, continue 7165 lastMapping = mapping; 7166 return; 7167 } 7168 } 7169 // We add the generated code until the first mapping 7170 // to the SourceNode without any mapping. 7171 // Each line is added as separate string. 7172 while (lastGeneratedLine < mapping.generatedLine) { 7173 node.add(shiftNextLine()); 7174 lastGeneratedLine++; 7175 } 7176 if (lastGeneratedColumn < mapping.generatedColumn) { 7177 var nextLine = remainingLines[remainingLinesIndex] || ''; 7178 node.add(nextLine.substr(0, mapping.generatedColumn)); 7179 remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn); 7180 lastGeneratedColumn = mapping.generatedColumn; 7181 } 7182 lastMapping = mapping; 7183 }, this); 7184 // We have processed all mappings. 7185 if (remainingLinesIndex < remainingLines.length) { 7186 if (lastMapping) { 7187 // Associate the remaining code in the current line with "lastMapping" 7188 addMappingWithCode(lastMapping, shiftNextLine()); 7189 } 7190 // and add the remaining lines without any mapping 7191 node.add(remainingLines.splice(remainingLinesIndex).join("")); 7192 } 7193 7194 // Copy sourcesContent into SourceNode 7195 aSourceMapConsumer.sources.forEach(function (sourceFile) { 7196 var content = aSourceMapConsumer.sourceContentFor(sourceFile); 7197 if (content != null) { 7198 if (aRelativePath != null) { 7199 sourceFile = util.join(aRelativePath, sourceFile); 7200 } 7201 node.setSourceContent(sourceFile, content); 7202 } 7203 }); 7204 7205 return node; 7206 7207 function addMappingWithCode(mapping, code) { 7208 if (mapping === null || mapping.source === undefined) { 7209 node.add(code); 7210 } else { 7211 var source = aRelativePath 7212 ? util.join(aRelativePath, mapping.source) 7213 : mapping.source; 7214 node.add(new SourceNode(mapping.originalLine, 7215 mapping.originalColumn, 7216 source, 7217 code, 7218 mapping.name)); 7219 } 7220 } 7221 }; 7222 7223/** 7224 * Add a chunk of generated JS to this source node. 7225 * 7226 * @param aChunk A string snippet of generated JS code, another instance of 7227 * SourceNode, or an array where each member is one of those things. 7228 */ 7229SourceNode.prototype.add = function SourceNode_add(aChunk) { 7230 if (Array.isArray(aChunk)) { 7231 aChunk.forEach(function (chunk) { 7232 this.add(chunk); 7233 }, this); 7234 } 7235 else if (aChunk[isSourceNode] || typeof aChunk === "string") { 7236 if (aChunk) { 7237 this.children.push(aChunk); 7238 } 7239 } 7240 else { 7241 throw new TypeError( 7242 "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk 7243 ); 7244 } 7245 return this; 7246}; 7247 7248/** 7249 * Add a chunk of generated JS to the beginning of this source node. 7250 * 7251 * @param aChunk A string snippet of generated JS code, another instance of 7252 * SourceNode, or an array where each member is one of those things. 7253 */ 7254SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) { 7255 if (Array.isArray(aChunk)) { 7256 for (var i = aChunk.length-1; i >= 0; i--) { 7257 this.prepend(aChunk[i]); 7258 } 7259 } 7260 else if (aChunk[isSourceNode] || typeof aChunk === "string") { 7261 this.children.unshift(aChunk); 7262 } 7263 else { 7264 throw new TypeError( 7265 "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk 7266 ); 7267 } 7268 return this; 7269}; 7270 7271/** 7272 * Walk over the tree of JS snippets in this node and its children. The 7273 * walking function is called once for each snippet of JS and is passed that 7274 * snippet and the its original associated source's line/column location. 7275 * 7276 * @param aFn The traversal function. 7277 */ 7278SourceNode.prototype.walk = function SourceNode_walk(aFn) { 7279 var chunk; 7280 for (var i = 0, len = this.children.length; i < len; i++) { 7281 chunk = this.children[i]; 7282 if (chunk[isSourceNode]) { 7283 chunk.walk(aFn); 7284 } 7285 else { 7286 if (chunk !== '') { 7287 aFn(chunk, { source: this.source, 7288 line: this.line, 7289 column: this.column, 7290 name: this.name }); 7291 } 7292 } 7293 } 7294}; 7295 7296/** 7297 * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between 7298 * each of `this.children`. 7299 * 7300 * @param aSep The separator. 7301 */ 7302SourceNode.prototype.join = function SourceNode_join(aSep) { 7303 var newChildren; 7304 var i; 7305 var len = this.children.length; 7306 if (len > 0) { 7307 newChildren = []; 7308 for (i = 0; i < len-1; i++) { 7309 newChildren.push(this.children[i]); 7310 newChildren.push(aSep); 7311 } 7312 newChildren.push(this.children[i]); 7313 this.children = newChildren; 7314 } 7315 return this; 7316}; 7317 7318/** 7319 * Call String.prototype.replace on the very right-most source snippet. Useful 7320 * for trimming whitespace from the end of a source node, etc. 7321 * 7322 * @param aPattern The pattern to replace. 7323 * @param aReplacement The thing to replace the pattern with. 7324 */ 7325SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) { 7326 var lastChild = this.children[this.children.length - 1]; 7327 if (lastChild[isSourceNode]) { 7328 lastChild.replaceRight(aPattern, aReplacement); 7329 } 7330 else if (typeof lastChild === 'string') { 7331 this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement); 7332 } 7333 else { 7334 this.children.push(''.replace(aPattern, aReplacement)); 7335 } 7336 return this; 7337}; 7338 7339/** 7340 * Set the source content for a source file. This will be added to the SourceMapGenerator 7341 * in the sourcesContent field. 7342 * 7343 * @param aSourceFile The filename of the source file 7344 * @param aSourceContent The content of the source file 7345 */ 7346SourceNode.prototype.setSourceContent = 7347 function SourceNode_setSourceContent(aSourceFile, aSourceContent) { 7348 this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent; 7349 }; 7350 7351/** 7352 * Walk over the tree of SourceNodes. The walking function is called for each 7353 * source file content and is passed the filename and source content. 7354 * 7355 * @param aFn The traversal function. 7356 */ 7357SourceNode.prototype.walkSourceContents = 7358 function SourceNode_walkSourceContents(aFn) { 7359 for (var i = 0, len = this.children.length; i < len; i++) { 7360 if (this.children[i][isSourceNode]) { 7361 this.children[i].walkSourceContents(aFn); 7362 } 7363 } 7364 7365 var sources = Object.keys(this.sourceContents); 7366 for (var i = 0, len = sources.length; i < len; i++) { 7367 aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]); 7368 } 7369 }; 7370 7371/** 7372 * Return the string representation of this source node. Walks over the tree 7373 * and concatenates all the various snippets together to one string. 7374 */ 7375SourceNode.prototype.toString = function SourceNode_toString() { 7376 var str = ""; 7377 this.walk(function (chunk) { 7378 str += chunk; 7379 }); 7380 return str; 7381}; 7382 7383/** 7384 * Returns the string representation of this source node along with a source 7385 * map. 7386 */ 7387SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) { 7388 var generated = { 7389 code: "", 7390 line: 1, 7391 column: 0 7392 }; 7393 var map = new SourceMapGenerator(aArgs); 7394 var sourceMappingActive = false; 7395 var lastOriginalSource = null; 7396 var lastOriginalLine = null; 7397 var lastOriginalColumn = null; 7398 var lastOriginalName = null; 7399 this.walk(function (chunk, original) { 7400 generated.code += chunk; 7401 if (original.source !== null 7402 && original.line !== null 7403 && original.column !== null) { 7404 if(lastOriginalSource !== original.source 7405 || lastOriginalLine !== original.line 7406 || lastOriginalColumn !== original.column 7407 || lastOriginalName !== original.name) { 7408 map.addMapping({ 7409 source: original.source, 7410 original: { 7411 line: original.line, 7412 column: original.column 7413 }, 7414 generated: { 7415 line: generated.line, 7416 column: generated.column 7417 }, 7418 name: original.name 7419 }); 7420 } 7421 lastOriginalSource = original.source; 7422 lastOriginalLine = original.line; 7423 lastOriginalColumn = original.column; 7424 lastOriginalName = original.name; 7425 sourceMappingActive = true; 7426 } else if (sourceMappingActive) { 7427 map.addMapping({ 7428 generated: { 7429 line: generated.line, 7430 column: generated.column 7431 } 7432 }); 7433 lastOriginalSource = null; 7434 sourceMappingActive = false; 7435 } 7436 for (var idx = 0, length = chunk.length; idx < length; idx++) { 7437 if (chunk.charCodeAt(idx) === NEWLINE_CODE) { 7438 generated.line++; 7439 generated.column = 0; 7440 // Mappings end at eol 7441 if (idx + 1 === length) { 7442 lastOriginalSource = null; 7443 sourceMappingActive = false; 7444 } else if (sourceMappingActive) { 7445 map.addMapping({ 7446 source: original.source, 7447 original: { 7448 line: original.line, 7449 column: original.column 7450 }, 7451 generated: { 7452 line: generated.line, 7453 column: generated.column 7454 }, 7455 name: original.name 7456 }); 7457 } 7458 } else { 7459 generated.column++; 7460 } 7461 } 7462 }); 7463 this.walkSourceContents(function (sourceFile, sourceContent) { 7464 map.setSourceContent(sourceFile, sourceContent); 7465 }); 7466 7467 return { code: generated.code, map: map }; 7468}; 7469 7470exports.SourceNode = SourceNode; 7471
vendor: 13,483 bytes, lines 7472-7970
7472},{"./source-map-generator":38,"./util":40}],40:[function(require,module,exports){ 7473/* -*- Mode: js; js-indent-level: 2; -*- */ 7474/* 7475 * Copyright 2011 Mozilla Foundation and contributors 7476 * Licensed under the New BSD license. See LICENSE or: 7477 * http://opensource.org/licenses/BSD-3-Clause 7478 */ 7479 7480/** 7481 * This is a helper function for getting values from parameter/options 7482 * objects. 7483 * 7484 * @param args The object we are extracting values from 7485 * @param name The name of the property we are getting. 7486 * @param defaultValue An optional value to return if the property is missing 7487 * from the object. If this is not specified and the property is missing, an 7488 * error will be thrown. 7489 */ 7490function getArg(aArgs, aName, aDefaultValue) { 7491 if (aName in aArgs) { 7492 return aArgs[aName]; 7493 } else if (arguments.length === 3) { 7494 return aDefaultValue; 7495 } else { 7496 throw new Error('"' + aName + '" is a required argument.'); 7497 } 7498} 7499exports.getArg = getArg; 7500 7501var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/; 7502var dataUrlRegexp = /^data:.+\,.+$/; 7503 7504function urlParse(aUrl) { 7505 var match = aUrl.match(urlRegexp); 7506 if (!match) { 7507 return null; 7508 } 7509 return { 7510 scheme: match[1], 7511 auth: match[2], 7512 host: match[3], 7513 port: match[4], 7514 path: match[5] 7515 }; 7516} 7517exports.urlParse = urlParse; 7518 7519function urlGenerate(aParsedUrl) { 7520 var url = ''; 7521 if (aParsedUrl.scheme) { 7522 url += aParsedUrl.scheme + ':'; 7523 } 7524 url += '//'; 7525 if (aParsedUrl.auth) { 7526 url += aParsedUrl.auth + '@'; 7527 } 7528 if (aParsedUrl.host) { 7529 url += aParsedUrl.host; 7530 } 7531 if (aParsedUrl.port) { 7532 url += ":" + aParsedUrl.port 7533 } 7534 if (aParsedUrl.path) { 7535 url += aParsedUrl.path; 7536 } 7537 return url; 7538} 7539exports.urlGenerate = urlGenerate; 7540 7541/** 7542 * Normalizes a path, or the path portion of a URL: 7543 * 7544 * - Replaces consecutive slashes with one slash. 7545 * - Removes unnecessary '.' parts. 7546 * - Removes unnecessary '<dir>/..' parts. 7547 * 7548 * Based on code in the Node.js 'path' core module. 7549 * 7550 * @param aPath The path or url to normalize. 7551 */ 7552function normalize(aPath) { 7553 var path = aPath; 7554 var url = urlParse(aPath); 7555 if (url) { 7556 if (!url.path) { 7557 return aPath; 7558 } 7559 path = url.path; 7560 } 7561 var isAbsolute = exports.isAbsolute(path); 7562 7563 var parts = path.split(/\/+/); 7564 for (var part, up = 0, i = parts.length - 1; i >= 0; i--) { 7565 part = parts[i]; 7566 if (part === '.') { 7567 parts.splice(i, 1); 7568 } else if (part === '..') { 7569 up++; 7570 } else if (up > 0) { 7571 if (part === '') { 7572 // The first part is blank if the path is absolute. Trying to go 7573 // above the root is a no-op. Therefore we can remove all '..' parts 7574 // directly after the root. 7575 parts.splice(i + 1, up); 7576 up = 0; 7577 } else { 7578 parts.splice(i, 2); 7579 up--; 7580 } 7581 } 7582 } 7583 path = parts.join('/'); 7584 7585 if (path === '') { 7586 path = isAbsolute ? '/' : '.'; 7587 } 7588 7589 if (url) { 7590 url.path = path; 7591 return urlGenerate(url); 7592 } 7593 return path; 7594} 7595exports.normalize = normalize; 7596 7597/** 7598 * Joins two paths/URLs. 7599 * 7600 * @param aRoot The root path or URL. 7601 * @param aPath The path or URL to be joined with the root. 7602 * 7603 * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a 7604 * scheme-relative URL: Then the scheme of aRoot, if any, is prepended 7605 * first. 7606 * - Otherwise aPath is a path. If aRoot is a URL, then its path portion 7607 * is updated with the result and aRoot is returned. Otherwise the result 7608 * is returned. 7609 * - If aPath is absolute, the result is aPath. 7610 * - Otherwise the two paths are joined with a slash. 7611 * - Joining for example 'http://' and 'www.example.com' is also supported. 7612 */ 7613function join(aRoot, aPath) { 7614 if (aRoot === "") { 7615 aRoot = "."; 7616 } 7617 if (aPath === "") { 7618 aPath = "."; 7619 } 7620 var aPathUrl = urlParse(aPath); 7621 var aRootUrl = urlParse(aRoot); 7622 if (aRootUrl) { 7623 aRoot = aRootUrl.path || '/'; 7624 } 7625 7626 // `join(foo, '//www.example.org')` 7627 if (aPathUrl && !aPathUrl.scheme) { 7628 if (aRootUrl) { 7629 aPathUrl.scheme = aRootUrl.scheme; 7630 } 7631 return urlGenerate(aPathUrl); 7632 } 7633 7634 if (aPathUrl || aPath.match(dataUrlRegexp)) { 7635 return aPath; 7636 } 7637 7638 // `join('http://', 'www.example.com')` 7639 if (aRootUrl && !aRootUrl.host && !aRootUrl.path) { 7640 aRootUrl.host = aPath; 7641 return urlGenerate(aRootUrl); 7642 } 7643 7644 var joined = aPath.charAt(0) === '/' 7645 ? aPath 7646 : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath); 7647 7648 if (aRootUrl) { 7649 aRootUrl.path = joined; 7650 return urlGenerate(aRootUrl); 7651 } 7652 return joined; 7653} 7654exports.join = join; 7655 7656exports.isAbsolute = function (aPath) { 7657 return aPath.charAt(0) === '/' || urlRegexp.test(aPath); 7658}; 7659 7660/** 7661 * Make a path relative to a URL or another path. 7662 * 7663 * @param aRoot The root path or URL. 7664 * @param aPath The path or URL to be made relative to aRoot. 7665 */ 7666function relative(aRoot, aPath) { 7667 if (aRoot === "") { 7668 aRoot = "."; 7669 } 7670 7671 aRoot = aRoot.replace(/\/$/, ''); 7672 7673 // It is possible for the path to be above the root. In this case, simply 7674 // checking whether the root is a prefix of the path won't work. Instead, we 7675 // need to remove components from the root one by one, until either we find 7676 // a prefix that fits, or we run out of components to remove. 7677 var level = 0; 7678 while (aPath.indexOf(aRoot + '/') !== 0) { 7679 var index = aRoot.lastIndexOf("/"); 7680 if (index < 0) { 7681 return aPath; 7682 } 7683 7684 // If the only part of the root that is left is the scheme (i.e. http://, 7685 // file:///, etc.), one or more slashes (/), or simply nothing at all, we 7686 // have exhausted all components, so the path is not relative to the root. 7687 aRoot = aRoot.slice(0, index); 7688 if (aRoot.match(/^([^\/]+:\/)?\/*$/)) { 7689 return aPath; 7690 } 7691 7692 ++level; 7693 } 7694 7695 // Make sure we add a "../" for each component we removed from the root. 7696 return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1); 7697} 7698exports.relative = relative; 7699 7700var supportsNullProto = (function () { 7701 var obj = Object.create(null); 7702 return !('__proto__' in obj); 7703}()); 7704 7705function identity (s) { 7706 return s; 7707} 7708 7709/** 7710 * Because behavior goes wacky when you set `__proto__` on objects, we 7711 * have to prefix all the strings in our set with an arbitrary character. 7712 * 7713 * See https://github.com/mozilla/source-map/pull/31 and 7714 * https://github.com/mozilla/source-map/issues/30 7715 * 7716 * @param String aStr 7717 */ 7718function toSetString(aStr) { 7719 if (isProtoString(aStr)) { 7720 return '$' + aStr; 7721 } 7722 7723 return aStr; 7724} 7725exports.toSetString = supportsNullProto ? identity : toSetString; 7726 7727function fromSetString(aStr) { 7728 if (isProtoString(aStr)) { 7729 return aStr.slice(1); 7730 } 7731 7732 return aStr; 7733} 7734exports.fromSetString = supportsNullProto ? identity : fromSetString; 7735 7736function isProtoString(s) { 7737 if (!s) { 7738 return false; 7739 } 7740 7741 var length = s.length; 7742 7743 if (length < 9 /* "__proto__".length */) { 7744 return false; 7745 } 7746 7747 if (s.charCodeAt(length - 1) !== 95 /* '_' */ || 7748 s.charCodeAt(length - 2) !== 95 /* '_' */ || 7749 s.charCodeAt(length - 3) !== 111 /* 'o' */ || 7750 s.charCodeAt(length - 4) !== 116 /* 't' */ || 7751 s.charCodeAt(length - 5) !== 111 /* 'o' */ || 7752 s.charCodeAt(length - 6) !== 114 /* 'r' */ || 7753 s.charCodeAt(length - 7) !== 112 /* 'p' */ || 7754 s.charCodeAt(length - 8) !== 95 /* '_' */ || 7755 s.charCodeAt(length - 9) !== 95 /* '_' */) { 7756 return false; 7757 } 7758 7759 for (var i = length - 10; i >= 0; i--) { 7760 if (s.charCodeAt(i) !== 36 /* '$' */) { 7761 return false; 7762 } 7763 } 7764 7765 return true; 7766} 7767 7768/** 7769 * Comparator between two mappings where the original positions are compared. 7770 * 7771 * Optionally pass in `true` as `onlyCompareGenerated` to consider two 7772 * mappings with the same original source/line/column, but different generated 7773 * line and column the same. Useful when searching for a mapping with a 7774 * stubbed out mapping. 7775 */ 7776function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) { 7777 var cmp = strcmp(mappingA.source, mappingB.source); 7778 if (cmp !== 0) { 7779 return cmp; 7780 } 7781 7782 cmp = mappingA.originalLine - mappingB.originalLine; 7783 if (cmp !== 0) { 7784 return cmp; 7785 } 7786 7787 cmp = mappingA.originalColumn - mappingB.originalColumn; 7788 if (cmp !== 0 || onlyCompareOriginal) { 7789 return cmp; 7790 } 7791 7792 cmp = mappingA.generatedColumn - mappingB.generatedColumn; 7793 if (cmp !== 0) { 7794 return cmp; 7795 } 7796 7797 cmp = mappingA.generatedLine - mappingB.generatedLine; 7798 if (cmp !== 0) { 7799 return cmp; 7800 } 7801 7802 return strcmp(mappingA.name, mappingB.name); 7803} 7804exports.compareByOriginalPositions = compareByOriginalPositions; 7805 7806/** 7807 * Comparator between two mappings with deflated source and name indices where 7808 * the generated positions are compared. 7809 * 7810 * Optionally pass in `true` as `onlyCompareGenerated` to consider two 7811 * mappings with the same generated line and column, but different 7812 * source/name/original line and column the same. Useful when searching for a 7813 * mapping with a stubbed out mapping. 7814 */ 7815function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) { 7816 var cmp = mappingA.generatedLine - mappingB.generatedLine; 7817 if (cmp !== 0) { 7818 return cmp; 7819 } 7820 7821 cmp = mappingA.generatedColumn - mappingB.generatedColumn; 7822 if (cmp !== 0 || onlyCompareGenerated) { 7823 return cmp; 7824 } 7825 7826 cmp = strcmp(mappingA.source, mappingB.source); 7827 if (cmp !== 0) { 7828 return cmp; 7829 } 7830 7831 cmp = mappingA.originalLine - mappingB.originalLine; 7832 if (cmp !== 0) { 7833 return cmp; 7834 } 7835 7836 cmp = mappingA.originalColumn - mappingB.originalColumn; 7837 if (cmp !== 0) { 7838 return cmp; 7839 } 7840 7841 return strcmp(mappingA.name, mappingB.name); 7842} 7843exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated; 7844 7845function strcmp(aStr1, aStr2) { 7846 if (aStr1 === aStr2) { 7847 return 0; 7848 } 7849 7850 if (aStr1 === null) { 7851 return 1; // aStr2 !== null 7852 } 7853 7854 if (aStr2 === null) { 7855 return -1; // aStr1 !== null 7856 } 7857 7858 if (aStr1 > aStr2) { 7859 return 1; 7860 } 7861 7862 return -1; 7863} 7864 7865/** 7866 * Comparator between two mappings with inflated source and name strings where 7867 * the generated positions are compared. 7868 */ 7869function compareByGeneratedPositionsInflated(mappingA, mappingB) { 7870 var cmp = mappingA.generatedLine - mappingB.generatedLine; 7871 if (cmp !== 0) { 7872 return cmp; 7873 } 7874 7875 cmp = mappingA.generatedColumn - mappingB.generatedColumn; 7876 if (cmp !== 0) { 7877 return cmp; 7878 } 7879 7880 cmp = strcmp(mappingA.source, mappingB.source); 7881 if (cmp !== 0) { 7882 return cmp; 7883 } 7884 7885 cmp = mappingA.originalLine - mappingB.originalLine; 7886 if (cmp !== 0) { 7887 return cmp; 7888 } 7889 7890 cmp = mappingA.originalColumn - mappingB.originalColumn; 7891 if (cmp !== 0) { 7892 return cmp; 7893 } 7894 7895 return strcmp(mappingA.name, mappingB.name); 7896} 7897exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated; 7898 7899/** 7900 * Strip any JSON XSSI avoidance prefix from the string (as documented 7901 * in the source maps specification), and then parse the string as 7902 * JSON. 7903 */ 7904function parseSourceMapInput(str) { 7905 return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, '')); 7906} 7907exports.parseSourceMapInput = parseSourceMapInput; 7908 7909/** 7910 * Compute the URL of a source given the the source root, the source's 7911 * URL, and the source map's URL. 7912 */ 7913function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) { 7914 sourceURL = sourceURL || ''; 7915 7916 if (sourceRoot) { 7917 // This follows what Chrome does. 7918 if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') { 7919 sourceRoot += '/'; 7920 } 7921 // The spec says: 7922 // Line 4: An optional source root, useful for relocating source 7923 // files on a server or removing repeated values in the 7924 // âsourcesâ entry. This value is prepended to the individual 7925 // entries in the âsourceâ field. 7926 sourceURL = sourceRoot + sourceURL; 7927 } 7928 7929 // Historically, SourceMapConsumer did not take the sourceMapURL as 7930 // a parameter. This mode is still somewhat supported, which is why 7931 // this code block is conditional. However, it's preferable to pass 7932 // the source map URL to SourceMapConsumer, so that this function 7933 // can implement the source URL resolution algorithm as outlined in 7934 // the spec. This block is basically the equivalent of: 7935 // new URL(sourceURL, sourceMapURL).toString() 7936 // ... except it avoids using URL, which wasn't available in the 7937 // older releases of node still supported by this library. 7938 // 7939 // The spec says: 7940 // If the sources are not absolute URLs after prepending of the 7941 // âsourceRootâ, the sources are resolved relative to the 7942 // SourceMap (like resolving script src in a html document). 7943 if (sourceMapURL) { 7944 var parsed = urlParse(sourceMapURL); 7945 if (!parsed) { 7946 throw new Error("sourceMapURL could not be parsed"); 7947 } 7948 if (parsed.path) { 7949 // Strip the last path component, but keep the "/". 7950 var index = parsed.path.lastIndexOf('/'); 7951 if (index >= 0) { 7952 parsed.path = parsed.path.substring(0, index + 1); 7953 } 7954 } 7955 sourceURL = join(urlGenerate(parsed), sourceURL); 7956 } 7957 7958 return normalize(sourceURL); 7959} 7960exports.computeSourceURL = computeSourceURL; 7961 7962},{}],41:[function(require,module,exports){ 7963/* 7964 * Copyright 2009-2011 Mozilla Foundation and contributors 7965 * Licensed under the New BSD license. See LICENSE.txt or: 7966 * http://opensource.org/licenses/BSD-3-Clause 7967 */ 7968exports.SourceMapGenerator = require('./lib/source-map-generator').SourceMapGenerator; 7969exports.SourceMapConsumer = require('./lib/source-map-consumer').SourceMapConsumer; 7970exports.SourceNode = require('./lib/source-node').SourceNode;
vendor: 8,677 bytes, lines 7971-8157
7971 7972},{"./lib/source-map-consumer":37,"./lib/source-map-generator":38,"./lib/source-node":39}],42:[function(require,module,exports){ 7973/*! js-cookie v3.0.5 | MIT */ 7974; 7975(function (global, factory) { 7976 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : 7977 typeof define === 'function' && define.amd ? define(factory) : 7978 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, (function () { 7979 var current = global.Cookies; 7980 var exports = global.Cookies = factory(); 7981 exports.noConflict = function () { global.Cookies = current; return exports; }; 7982 })()); 7983})(this, (function () { 'use strict'; 7984 7985 /* eslint-disable no-var */ 7986 function assign (target) { 7987 for (var i = 1; i < arguments.length; i++) { 7988 var source = arguments[i]; 7989 for (var key in source) { 7990 target[key] = source[key]; 7991 } 7992 } 7993 return target 7994 } 7995 /* eslint-enable no-var */ 7996 7997 /* eslint-disable no-var */ 7998 var defaultConverter = { 7999 read: function (value) { 8000 if (value[0] === '"') { 8001 value = value.slice(1, -1); 8002 } 8003 return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent) 8004 }, 8005 write: function (value) { 8006 return encodeURIComponent(value).replace( 8007 /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, 8008 decodeURIComponent 8009 ) 8010 } 8011 }; 8012 /* eslint-enable no-var */ 8013 8014 /* eslint-disable no-var */ 8015 8016 function init (converter, defaultAttributes) { 8017 function set (name, value, attributes) { 8018 if (typeof document === 'undefined') { 8019 return 8020 } 8021 8022 attributes = assign({}, defaultAttributes, attributes); 8023 8024 if (typeof attributes.expires === 'number') { 8025 attributes.expires = new Date(Date.now() + attributes.expires * 864e5); 8026 } 8027 if (attributes.expires) { 8028 attributes.expires = attributes.expires.toUTCString(); 8029 } 8030 8031 name = encodeURIComponent(name) 8032 .replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent) 8033 .replace(/[()]/g, escape); 8034 8035 var stringifiedAttributes = ''; 8036 for (var attributeName in attributes) { 8037 if (!attributes[attributeName]) { 8038 continue 8039 } 8040 8041 stringifiedAttributes += '; ' + attributeName; 8042 8043 if (attributes[attributeName] === true) { 8044 continue 8045 } 8046 8047 // Considers RFC 6265 section 5.2: 8048 // ... 8049 // 3. If the remaining unparsed-attributes contains a %x3B (";") 8050 // character: 8051 // Consume the characters of the unparsed-attributes up to, 8052 // not including, the first %x3B (";") character. 8053 // ... 8054 stringifiedAttributes += '=' + attributes[attributeName].split(';')[0]; 8055 } 8056 8057 return (document.cookie = 8058 name + '=' + converter.write(value, name) + stringifiedAttributes) 8059 } 8060 8061 function get (name) { 8062 if (typeof document === 'undefined' || (arguments.length && !name)) { 8063 return 8064 } 8065 8066 // To prevent the for loop in the first place assign an empty array 8067 // in case there are no cookies at all. 8068 var cookies = document.cookie ? document.cookie.split('; ') : []; 8069 var jar = {}; 8070 for (var i = 0; i < cookies.length; i++) { 8071 var parts = cookies[i].split('='); 8072 var value = parts.slice(1).join('='); 8073 8074 try { 8075 var found = decodeURIComponent(parts[0]); 8076 jar[found] = converter.read(value, found); 8077 8078 if (name === found) { 8079 break 8080 } 8081 } catch (e) {} 8082 } 8083 8084 return name ? jar[name] : jar 8085 } 8086 8087 return Object.create( 8088 { 8089 set, 8090 get, 8091 remove: function (name, attributes) { 8092 set( 8093 name, 8094 '', 8095 assign({}, attributes, { 8096 expires: -1 8097 }) 8098 ); 8099 }, 8100 withAttributes: function (attributes) { 8101 return init(this.converter, assign({}, this.attributes, attributes)) 8102 }, 8103 withConverter: function (converter) { 8104 return init(assign({}, this.converter, converter), this.attributes) 8105 } 8106 }, 8107 { 8108 attributes: { value: Object.freeze(defaultAttributes) }, 8109 converter: { value: Object.freeze(converter) } 8110 } 8111 ) 8112 } 8113 8114 var api = init(defaultConverter, { path: '/' }); 8115 /* eslint-enable no-var */ 8116 8117 return api; 8118 8119})); 8120 8121},{}],43:[function(require,module,exports){ 8122"use strict"; 8123 8124Object.defineProperty(exports, "__esModule", { 8125 value: true 8126}); 8127exports["default"] = void 0; 8128var _handlebars = _interopRequireDefault(require("handlebars")); 8129var _collectionCreateForm = _interopRequireDefault(require("../templates/collection-create-form.hbs")); 8130var _Translations = _interopRequireDefault(require("./Translations")); 8131function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 8132function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } 8133function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } 8134function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } 8135function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } 8136function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 8137function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } 8138function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 8139function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } 8140function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } 8141var collectionCreateFormTemplate = _handlebars["default"].compile(_collectionCreateForm["default"]); 8142_handlebars["default"].registerHelper('trans', function (value1, value2, options) { 8143 return _Translations["default"].get(value1, value2); 8144}); 8145var CollectionCreateForm = /*#__PURE__*/function () { 8146 function CollectionCreateForm() { 8147 _classCallCheck(this, CollectionCreateForm); 8148 // align with application detector 8149 this.appSelector = "[data-comp='myol-collection-create-form']"; 8150 } 8151 return _createClass(CollectionCreateForm, [{ 8152 key: "init", 8153 value: function init(MyOncoLinkAPI) { 8154 // set API connection 8155 if (MyOncoLinkAPI === null) { 8156 this.log('init() [error] missing MyOncoLinkAPI'); 8157 return false;
8158 } 8159 this.MyOncoLinkAPI = MyOncoLinkAPI; // load API into this class 8160 if (this.MyOncoLinkAPI.isEnabled === false) { 8161 this.log("init() [halt] MyOncoLinkAPI.isEnabled == false"); 8162 return false; 8163 } 8164 this.callBackSuccess = null; // override success function for specific use 8165 8166 // Collection edit form selectors 8167 this.collectionKeyDataAttr = "data-collection-key"; // for getting the collection key on a given form 8168 this.collectionCreateToastSelect = ".myol-collection-toast"; 8169 this.collectionCreateFormSelect = ".myol-collection-create-form"; 8170 this.collectionCreateInputSelect = "input.myol-collection-create-input"; 8171 this.collectionCreateSubmitSelect = "button.myol-collection-create-submit"; 8172 this.collectionCreateMessageSelect = ".myol-collection-create-message"; // errors and messages 8173 8174 this.toastCloseSelect = ".btn-close"; // popup close button 8175 this.toastShowClass = "show"; // add to show, remove to hide 8176 8177 this.lang = 'en'; // default 8178 try { 8179 this.lang = document.querySelector('html').getAttribute('lang'); 8180 this.log('Language: ' + this.lang); 8181 } catch (_unused) {} 8182 } 8183 }, { 8184 key: "buildUI", 8185 value: function buildUI() { 8186 this.log("buildUI()"); 8187 // option 1: in page already 8188 this.assignEvents(); 8189 } 8190 }, { 8191 key: "renderTemplate", 8192 value: function renderTemplate(params) { 8193 this.log("renderTemplate()"); 8194 params.lang = this.lang; // append lang 8195 // option 2: not already in page, render html 8196 return collectionCreateFormTemplate(params); 8197 } 8198 }, { 8199 key: "assignEvents", 8200 value: function assignEvents() { 8201 this.log("assignEvents()"); 8202 // option 2: not already in page, assign events to rendered HTML 8203 var widgetEles = document.querySelectorAll(this.appSelector); 8204 // for loop to preserve 'this' 8205 var _iterator = _createForOfIteratorHelper(widgetEles), 8206 _step; 8207 try { 8208 for (_iterator.s(); !(_step = _iterator.n()).done;) { 8209 var widgetEle = _step.value; 8210 // 'this' correctly refers to myObj 8211 var submitEle = widgetEle.querySelector(this.collectionCreateSubmitSelect); 8212 submitEle.addEventListener('click', this.collectionCreateSubmitEvent.bind(this)); 8213 } 8214 } catch (err) { 8215 _iterator.e(err); 8216 } finally { 8217 _iterator.f(); 8218 } 8219 } 8220 }, { 8221 key: "collectionCreateSubmitEvent", 8222 value: function collectionCreateSubmitEvent(e) { 8223 this.log("collectionCreateSubmitEvent()"); 8224 8225 // use relative to e.target to allow for multiple forms on page 8226 var formEle = e.target.closest(this.collectionCreateFormSelect); 8227 if (formEle === null) { 8228 this.log("collectionCreateSubmitEvent() [error] missing form element"); 8229 } 8230 var collectionKey = formEle.getAttribute(this.collectionKeyDataAttr); 8231 if (collectionKey === null) { 8232 this.log("collectionCreateSubmitEvent() [error] missing data-collection-key attribute"); 8233 } 8234 var messageEle = formEle.querySelector(this.collectionCreateMessageSelect); 8235 if (messageEle === null) { 8236 this.log("collectionCreateSubmitEvent() [error] missing message element"); 8237 } 8238 var inputEle = formEle.querySelector(this.collectionCreateInputSelect); 8239 if (inputEle === null) { 8240 this.log("collectionCreateSubmitEvent() [error] missing input name element"); 8241 } 8242 // can be edited 8243 var label = inputEle.value; 8244 8245 // clear message 8246 messageEle.innerHTML = ""; 8247 var createResult = this.MyOncoLinkAPI.createCollection(label); 8248 8249 // detect error 8250 if (createResult.hasOwnProperty('error') && createResult.error.length > 0) { 8251 this.log("collectionCreateSubmitEvent() [error] API"); 8252 messageEle.innerHTML = "<span class='input-error'>" + createResult.error + "</span>"; 8253 return false; 8254 } 8255 var newCollectionKey = null; 8256 if (createResult.hasOwnProperty('collectionKey')) { 8257 newCollectionKey = createResult.collectionKey; 8258 } 8259 this.log("collectionCreateSubmitEvent() updated " + newCollectionKey); 8260 if (newCollectionKey === null || newCollectionKey.length === 0) { 8261 this.log("collectionCreateSubmitEvent() [error] API missing new collection key"); 8262 messageEle.innerHTML = "<span class='input-error'>Missing collection key</span>"; 8263 return false;
8264 } 8265 8266 // VALIDATE that the collection was actually created before resetting form 8267 if (this.MyOncoLinkAPI.isCollection(newCollectionKey) !== true) { 8268 this.log("collectionCreateSubmitEvent() [error] checking new collection check FAILED!"); 8269 messageEle.innerHTML = "<span class='input-error'>Error checking API</span>"; 8270 return false; 8271 } 8272 8273 // assume success 8274 messageEle.innerHTML = _Translations["default"].get(this.lang, "Success!"); 8275 8276 // clear input on success 8277 inputEle.value = ""; 8278 if (typeof this.callBackSuccess === "function") { 8279 this.log('collectionCreateSubmitEvent() callback() ' + newCollectionKey); 8280 this.callBackSuccess(createResult); 8281 } 8282 return true; 8283 } 8284 8285 /***************/ 8286 /*** Utility ***/ 8287 }, { 8288 key: "log", 8289 value: function log(msg) { 8290 // ?debug=1, ?debug=(className), ?debug=(className),(className) 8291 if (console && (window.location.href.indexOf('debug=1') > 0 || window.location.href.indexOf(this.constructor.name) > 0 && window.location.href.indexOf('debug') > 0)) { 8292 if (_typeof(msg) === "object") { 8293 console.log(msg); 8294 } else { 8295 console.log(this.constructor.name + "(): " + msg); 8296 } 8297 } 8298 } 8299 }]); 8300}(); 8301var _default = exports["default"] = new CollectionCreateForm(); 8302 8303},{"../templates/collection-create-form.hbs":57,"./Translations":52,"handlebars":1}],44:[function(require,module,exports){ 8304"use strict"; 8305 8306Object.defineProperty(exports, "__esModule", { 8307 value: true 8308}); 8309exports["default"] = void 0; 8310var _handlebars = _interopRequireDefault(require("handlebars")); 8311var _collectionDeleteForm = _interopRequireDefault(require("../templates/collection-delete-form.hbs")); 8312var _Translations = _interopRequireDefault(require("./Translations")); 8313function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 8314function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } 8315function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } 8316function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } 8317function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } 8318function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 8319function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } 8320function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 8321function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } 8322function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } 8323var collectionDeleteFormTemplate = _handlebars["default"].compile(_collectionDeleteForm["default"]); 8324_handlebars["default"].registerHelper('trans', function (value1, value2, options) { 8325 return _Translations["default"].get(value1, value2); 8326}); 8327var CollectionDeleteForm = /*#__PURE__*/function () { 8328 function CollectionDeleteForm() { 8329 _classCallCheck(this, CollectionDeleteForm); 8330 // align with application detector 8331 this.appSelector = "[data-comp='myol-collection-delete-form']"; 8332 } 8333 return _createClass(CollectionDeleteForm, [{ 8334 key: "init", 8335 value: function init(MyOncoLinkAPI) { 8336 // set API connection 8337 if (MyOncoLinkAPI === null) { 8338 this.log('init() [error] missing MyOncoLinkAPI'); 8339 return false;
8340 } 8341 this.MyOncoLinkAPI = MyOncoLinkAPI; // load API into this class 8342 if (this.MyOncoLinkAPI.isEnabled === false) { 8343 this.log("init() [halt] MyOncoLinkAPI.isEnabled == false"); 8344 return false; 8345 } 8346 this.callBackSuccess = null; // override success function for specific use 8347 8348 // Collection edit form selectors 8349 this.collectionKeyDataAttr = "data-collection-key"; // for getting the collection key on a given form 8350 this.collectionDeleteToastSelect = ".myol-collection-delete-toast"; 8351 this.collectionDeleteFormSelect = ".myol-collection-delete-form"; 8352 this.collectionDeleteInputSelect = "input.myol-collection-delete-input"; 8353 this.collectionDeleteSubmitSelect = "button.myol-collection-delete-submit"; 8354 this.collectionDeleteMessageSelect = ".myol-collection-delete-message"; // errors and messages 8355 8356 this.toastCloseSelect = ".btn-close"; // popup close button 8357 this.toastShowClass = "show"; // add to show, remove to hide 8358 8359 this.lang = 'en'; // default 8360 try { 8361 this.lang = document.querySelector('html').getAttribute('lang'); 8362 this.log('Language: ' + this.lang); 8363 } catch (_unused) {} 8364 } 8365 }, { 8366 key: "buildUI", 8367 value: function buildUI() { 8368 this.log("buildUI()"); 8369 // option 1: in page already 8370 this.assignEvents(); 8371 } 8372 }, { 8373 key: "renderTemplate", 8374 value: function renderTemplate(params) { 8375 this.log("renderTemplate()"); 8376 params.lang = this.lang; // append lang 8377 // option 2: not already in page, render html 8378 return collectionDeleteFormTemplate(params); 8379 } 8380 }, { 8381 key: "assignEvents", 8382 value: function assignEvents() { 8383 this.log("assignEvents()"); 8384 // option 2: not already in page, assign events to rendered HTML 8385 var widgetEles = document.querySelectorAll(this.appSelector); 8386 // for loop to preserve 'this' 8387 var _iterator = _createForOfIteratorHelper(widgetEles), 8388 _step; 8389 try { 8390 for (_iterator.s(); !(_step = _iterator.n()).done;) { 8391 var widgetEle = _step.value; 8392 // 'this' correctly refers to myObj 8393 var submitEle = widgetEle.querySelector(this.collectionDeleteSubmitSelect); 8394 submitEle.addEventListener('click', this.collectionDeleteSubmitEvent.bind(this)); 8395 } 8396 } catch (err) { 8397 _iterator.e(err); 8398 } finally { 8399 _iterator.f(); 8400 } 8401 } 8402 }, { 8403 key: "collectionDeleteSubmitEvent", 8404 value: function collectionDeleteSubmitEvent(e) { 8405 this.log("collectionDeleteSubmitEvent()"); 8406 8407 // use relative to e.target to allow for multiple forms on page 8408 var formEle = e.target.closest(this.collectionDeleteFormSelect); 8409 if (formEle === null) { 8410 this.log("collectionDeleteSubmitEvent() [error] missing form element"); 8411 } 8412 var collectionKey = formEle.getAttribute(this.collectionKeyDataAttr); 8413 if (collectionKey === null) { 8414 this.log("collectionDeleteSubmitEvent() [error] missing data-collection-key attribute"); 8415 } 8416 var messageEle = formEle.querySelector(this.collectionDeleteMessageSelect); 8417 if (messageEle === null) { 8418 this.log("collectionDeleteSubmitEvent() [error] missing message element"); 8419 } 8420 var inputEle = formEle.querySelector(this.collectionDeleteInputSelect); 8421 if (inputEle === null) { 8422 this.log("collectionDeleteSubmitEvent() [error] missing input name element"); 8423 } 8424 8425 // can be edited 8426 var label = inputEle.value; 8427 8428 // clear message 8429 messageEle.innerHTML = ""; 8430 8431 // check confirm label 8432 var currentCollectionInfo = this.MyOncoLinkAPI.getCollectionInfo(collectionKey); 8433 if (!currentCollectionInfo) { 8434 messageEle.innerHTML = "<span class='input-error'>Unable to lookup collection</span>"; 8435 return false; 8436 } 8437 if (currentCollectionInfo.hasOwnProperty('label')) { 8438 if (label !== currentCollectionInfo.label) { 8439 messageEle.innerHTML = "<span class='input-error'>Name does not match</span>"; 8440 return false; 8441 } 8442 } 8443 var deleteResult = this.MyOncoLinkAPI.deleteCollection(collectionKey, label); 8444 8445 // detect error 8446 if (deleteResult.hasOwnProperty('error') && deleteResult.error.length > 0) { 8447 this.log("collectionDeleteSubmitEvent() [error] API"); 8448 messageEle.innerHTML = "<span class='input-error'>" + deleteResult.error + "</span>"; 8449 return false;
8450 } 8451 var confirmCollectionKey = null; 8452 if (deleteResult.hasOwnProperty('collectionKey')) { 8453 confirmCollectionKey = deleteResult.collectionKey; 8454 } 8455 this.log("collectionDeleteSubmitEvent() delete " + confirmCollectionKey); 8456 if (confirmCollectionKey === null || confirmCollectionKey.length === 0) { 8457 this.log("collectionDeleteSubmitEvent() [error] API missing confirmed collection key"); 8458 messageEle.innerHTML = "<span class='input-error'>Missing collection key</span>"; 8459 return false; 8460 } 8461 // 8462 // // VALIDATE that the collection was actually deleted before resetting form 8463 // if (this.MyOncoLinkAPI.isCollection(newCollectionKey) !== true) { 8464 // this.log("collectionDeleteSubmitEvent() [error] checking new collection check FAILED!"); 8465 // messageEle.innerHTML = "<span class='input-error'>Error checking API</span>"; 8466 // return false; 8467 // } 8468 8469 // assume success 8470 messageEle.innerHTML = _Translations["default"].get(this.lang, "Success!"); 8471 setTimeout(function (messageEle) { 8472 messageEle.innerHTML = ""; // DELETE entirely 8473 }, 1500, messageEle); // notify timeout 8474 8475 // clear input on success 8476 inputEle.value = ""; 8477 if (typeof this.callBackSuccess === "function") { 8478 this.log('collectionDeleteSubmitEvent() callback() ' + confirmCollectionKey); 8479 this.callBackSuccess(deleteResult); 8480 } 8481 return true; 8482 } 8483 8484 /***************/ 8485 /*** Utility ***/ 8486 }, { 8487 key: "log", 8488 value: function log(msg) { 8489 // ?debug=1, ?debug=(className), ?debug=(className),(className) 8490 if (console && (window.location.href.indexOf('debug=1') > 0 || window.location.href.indexOf(this.constructor.name) > 0 && window.location.href.indexOf('debug') > 0)) { 8491 if (_typeof(msg) === "object") { 8492 console.log(msg); 8493 } else { 8494 console.log(this.constructor.name + "(): " + msg); 8495 } 8496 } 8497 } 8498 }]); 8499}(); 8500var _default = exports["default"] = new CollectionDeleteForm(); 8501 8502},{"../templates/collection-delete-form.hbs":58,"./Translations":52,"handlebars":1}],45:[function(require,module,exports){ 8503"use strict"; 8504 8505Object.defineProperty(exports, "__esModule", { 8506 value: true 8507}); 8508exports["default"] = void 0; 8509var _handlebars = _interopRequireDefault(require("handlebars")); 8510var _collectionEditForm = _interopRequireDefault(require("../templates/collection-edit-form.hbs")); 8511var _Translations = _interopRequireDefault(require("./Translations")); 8512function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 8513function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } 8514function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } 8515function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } 8516function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } 8517function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 8518function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } 8519function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 8520function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } 8521function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } 8522var collectionEditFormTemplate = _handlebars["default"].compile(_collectionEditForm["default"]); 8523_handlebars["default"].registerHelper('trans', function (value1, value2, options) { 8524 return _Translations["default"].get(value1, value2); 8525}); 8526var CollectionEditForm = /*#__PURE__*/function () { 8527 function CollectionEditForm() { 8528 _classCallCheck(this, CollectionEditForm); 8529 // align with application detector 8530 this.appSelector = "[data-comp='myol-collection-edit-form']"; // can be multiple per page 8531 } 8532 return _createClass(CollectionEditForm, [{ 8533 key: "init", 8534 value: function init(MyOncoLinkAPI) { 8535 // set API connection 8536 if (MyOncoLinkAPI === null) { 8537 this.log('init() [error] missing MyOncoLinkAPI'); 8538 return false;
8539 } 8540 this.MyOncoLinkAPI = MyOncoLinkAPI; // load API into this class 8541 if (this.MyOncoLinkAPI.isEnabled === false) { 8542 this.log("init() [halt] MyOncoLinkAPI.isEnabled == false"); 8543 return false; 8544 } 8545 this.callBackSuccess = null; // override success function for specific use 8546 8547 // Collection edit form selectors 8548 this.collectionKeyDataAttr = "data-collection-key"; // for getting the collection key on a given form 8549 this.collectionEditToastSelect = ".myol-collection-toast"; 8550 this.collectionEditFormSelect = ".myol-collection-edit-form"; 8551 this.collectionEditInputNameSelect = "input.myol-collection-edit-name"; 8552 this.collectionEditSubmitSelect = "button.myol-collection-edit-submit"; 8553 this.collectionEditMessageSelect = ".myol-collection-edit-message"; // errors and messages 8554 8555 this.lang = 'en'; // default 8556 try { 8557 this.lang = document.querySelector('html').getAttribute('lang'); 8558 this.log('Language: ' + this.lang); 8559 } catch (_unused) {} 8560 } 8561 }, { 8562 key: "buildUI", 8563 value: function buildUI() { 8564 this.log("buildUI()"); 8565 8566 // option 1: if already in page 8567 this.assignEvents(); 8568 } 8569 }, { 8570 key: "renderTemplate", 8571 value: function renderTemplate(params) { 8572 this.log("renderTemplate()"); 8573 params.lang = this.lang; // append lang 8574 return collectionEditFormTemplate(params); 8575 } 8576 }, { 8577 key: "assignEvents", 8578 value: function assignEvents() { 8579 this.log("assignEvents()"); 8580 var formEles = document.querySelectorAll(this.appSelector); 8581 // for loop to preserve 'this' 8582 var _iterator = _createForOfIteratorHelper(formEles), 8583 _step; 8584 try { 8585 for (_iterator.s(); !(_step = _iterator.n()).done;) { 8586 var formEle = _step.value; 8587 // 'this' correctly refers to myObj 8588 var submitEle = formEle.querySelector(this.collectionEditSubmitSelect); 8589 submitEle.addEventListener('click', this.collectionEditSubmitEvent.bind(this)); 8590 } 8591 } catch (err) { 8592 _iterator.e(err); 8593 } finally { 8594 _iterator.f(); 8595 } 8596 } 8597 }, { 8598 key: "collectionEditSubmitEvent", 8599 value: function collectionEditSubmitEvent(e) { 8600 this.log("collectionEditSubmitEvent()"); 8601 8602 // use relative to e.target to allow for multiple forms on page 8603 var formEle = e.target.closest(this.collectionEditFormSelect); 8604 if (formEle === null) { 8605 this.log("collectionEditSubmitEvent() [error] missing form element"); 8606 } 8607 var collectionKey = formEle.getAttribute(this.collectionKeyDataAttr); 8608 if (collectionKey === null) { 8609 this.log("collectionEditSubmitEvent() [error] missing data-collection-key attribute"); 8610 } 8611 var messageEle = formEle.querySelector(this.collectionEditMessageSelect); 8612 if (messageEle === null) { 8613 this.log("collectionEditSubmitEvent() [error] missing message element"); 8614 } 8615 var inputNameEle = formEle.querySelector(this.collectionEditInputNameSelect); 8616 if (inputNameEle === null) { 8617 this.log("collectionEditSubmitEvent() [error] missing input name element"); 8618 } 8619 var label = inputNameEle.value; 8620 // check input 8621 if (label.length === 0) { 8622 this.log("collectionEditSubmitEvent() [error] empty new label"); 8623 } 8624 8625 // clear message 8626 messageEle.innerHTML = ""; 8627 8628 // create collection 8629 var editResult = this.MyOncoLinkAPI.renameCollection(collectionKey, label); 8630 8631 // detect error 8632 if (editResult.hasOwnProperty('error') && editResult.error.length > 0) { 8633 this.log("collectionEditSubmitEvent() [error] API"); 8634 messageEle.innerHTML = "<span class='input-error'>" + editResult.error + "</span>"; 8635 return false; 8636 } 8637 var confirmCollectionKey = null; 8638 if (editResult.hasOwnProperty('collectionKey')) { 8639 confirmCollectionKey = editResult.collectionKey; 8640 } 8641 this.log("collectionEditSubmitEvent() edited " + confirmCollectionKey); 8642 if (confirmCollectionKey === null || confirmCollectionKey.length === 0) { 8643 this.log("collectionEditSubmitEvent() [error] API missing new collection key"); 8644 messageEle.innerHTML = "<span class='input-error'>Missing collection key</span>"; 8645 return false;
8646 } 8647 8648 // VALIDATE that the collection was actually created before resetting form 8649 if (this.MyOncoLinkAPI.isCollection(confirmCollectionKey) !== true) { 8650 this.log("collectionEditSubmitEvent() [error] checking new collection check FAILED!"); 8651 messageEle.innerHTML = "<span class='input-error'>Error checking API</span>"; 8652 return false; 8653 } 8654 messageEle.innerHTML = _Translations["default"].get(this.lang, "Success!"); 8655 setTimeout(function (messageEle) { 8656 messageEle.innerHTML = ""; // DELETE entirely 8657 }, 1500, messageEle); // notify timeout 8658 8659 if (typeof this.callBackSuccess === "function") { 8660 this.log('collectionEditSubmitEvent() callback() ' + collectionKey); 8661 this.callBackSuccess(collectionKey, label); 8662 } 8663 } 8664 8665 /***************/ 8666 /*** Utility ***/ 8667 }, { 8668 key: "log", 8669 value: function log(msg) { 8670 // ?debug=1, ?debug=(className), ?debug=(className),(className) 8671 if (console && (window.location.href.indexOf('debug=1') > 0 || window.location.href.indexOf(this.constructor.name) > 0 && window.location.href.indexOf('debug') > 0)) { 8672 if (_typeof(msg) === "object") { 8673 console.log(msg); 8674 } else { 8675 console.log(this.constructor.name + "(): " + msg); 8676 } 8677 } 8678 } 8679 }]); 8680}(); 8681var _default = exports["default"] = new CollectionEditForm(); 8682 8683},{"../templates/collection-edit-form.hbs":59,"./Translations":52,"handlebars":1}],46:[function(require,module,exports){ 8684"use strict"; 8685 8686Object.defineProperty(exports, "__esModule", { 8687 value: true 8688}); 8689exports["default"] = void 0; 8690var _handlebars = _interopRequireDefault(require("handlebars")); 8691var _collectionItemCopyForm = _interopRequireDefault(require("../templates/collection-item-copy-form.hbs")); 8692var _Translations = _interopRequireDefault(require("./Translations")); 8693function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 8694function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } 8695function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } 8696function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } 8697function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } 8698function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 8699function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } 8700function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 8701function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } 8702function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } 8703var collectionItemCopyFormTemplate = _handlebars["default"].compile(_collectionItemCopyForm["default"]); 8704_handlebars["default"].registerHelper('trans', function (value1, value2, options) { 8705 return _Translations["default"].get(value1, value2); 8706}); 8707var CollectionItemCopyForm = /*#__PURE__*/function () { 8708 function CollectionItemCopyForm() { 8709 _classCallCheck(this, CollectionItemCopyForm); 8710 // align with application detector 8711 this.appSelector = "[data-comp='myol-collection-item-copy']"; 8712 } 8713 return _createClass(CollectionItemCopyForm, [{ 8714 key: "init", 8715 value: function init(MyOncoLinkAPI) { 8716 // set API connection 8717 if (MyOncoLinkAPI === null) { 8718 this.log('init() [error] missing MyOncoLinkAPI'); 8719 return false;
8720 } 8721 this.MyOncoLinkAPI = MyOncoLinkAPI; // load API into this class 8722 if (this.MyOncoLinkAPI.isEnabled === false) { 8723 this.log("init() [halt] MyOncoLinkAPI.isEnabled == false"); 8724 return false; 8725 } 8726 this.callBackSuccess = null; // override success function for specific use 8727 8728 // Collection form selectors 8729 this.collectionItemCopySelect = ".myol-collection-item-copy"; // top level widget 8730 this.collectionItemCopyToastSelect = ".myol-collection-item-copy-toast"; 8731 this.collectionItemCopyFormSelect = ".myol-collection-item-copy-form"; 8732 this.collectionItemCopyInputSelect = "select.myol-collection-item-copy-input"; 8733 this.collectionItemCopySubmitSelect = "button.myol-collection-item-copy-submit"; 8734 this.collectionItemCopyMessageSelect = ".myol-collection-item-copy-message"; // errors and messages 8735 8736 this.contentIdAttr = "data-content-id"; 8737 this.collectionKeyAttr = "data-collection-key"; 8738 this.toastCloseSelect = ".btn-close"; 8739 this.toastShowClass = "show"; 8740 this.lang = 'en'; // default 8741 try { 8742 this.lang = document.querySelector('html').getAttribute('lang'); 8743 this.log('Language: ' + this.lang); 8744 } catch (_unused) {} 8745 } 8746 }, { 8747 key: "buildUI", 8748 value: function buildUI() { 8749 this.log("buildUI()"); 8750 // option 1: in page already 8751 this.assignEvents(); 8752 } 8753 }, { 8754 key: "renderTemplate", 8755 value: function renderTemplate(params) { 8756 this.log("renderTemplate()"); 8757 params.lang = this.lang; // append 8758 // option 2: not already in page, render html 8759 return collectionItemCopyFormTemplate(params); 8760 } 8761 }, { 8762 key: "assignEvents", 8763 value: function assignEvents() { 8764 this.log("assignEvents()"); 8765 // option 2: not already in page, assign events to rendered HTML 8766 var widgetEles = document.querySelectorAll(this.appSelector); 8767 // for loop to preserve 'this' 8768 var _iterator = _createForOfIteratorHelper(widgetEles), 8769 _step; 8770 try { 8771 for (_iterator.s(); !(_step = _iterator.n()).done;) { 8772 var widgetEle = _step.value; 8773 // 'this' correctly refers to myObj 8774 var submitEle = widgetEle.querySelector(this.collectionItemCopySubmitSelect); 8775 submitEle.addEventListener('click', this.collectionItemCopySubmitEvent.bind(this)); 8776 8777 // if bootstrap toasts missing 8778 if (typeof bootstrap.Toast === "undefined") { 8779 // Assign 'close' popup event 8780 var popupCloseButtonEle = widgetEle.querySelector(this.toastCloseSelect); 8781 if (popupCloseButtonEle) { 8782 popupCloseButtonEle.addEventListener('click', this.toastCloseEvent.bind(this)); 8783 } else { 8784 this.log("buildWidgetUI() [error] missing popup close element"); 8785 } 8786 } 8787 } 8788 8789 //if bootstrap (HOLD breaks submit) 8790 } catch (err) { 8791 _iterator.e(err); 8792 } finally { 8793 _iterator.f(); 8794 } 8795 if (typeof bootstrap.Toast !== "undefined") { 8796 // toasts 8797 var toastElList = [].slice.call(document.querySelectorAll('.toast')); 8798 var toastList = toastElList.map(function (toastEl) { 8799 return new bootstrap.Toast(toastEl, {}); 8800 }); 8801 } 8802 } 8803 }, { 8804 key: "toastCloseEvent", 8805 value: function toastCloseEvent(e) { 8806 this.log("toastCloseEvent()"); 8807 var toastEle = e.target.closest(this.collectionItemCopyToastSelect); 8808 toastEle.classList.remove(this.toastShowClass); 8809 } 8810 }, { 8811 key: "collectionItemCopySubmitEvent", 8812 value: function collectionItemCopySubmitEvent(e) { 8813 this.log("collectionItemCopySubmitEvent()"); 8814 // use relative to e.target to allow for multiple forms on page 8815 var formEle = e.target.closest(this.collectionItemCopyFormSelect); 8816 if (formEle === null) { 8817 this.log("collectionItemCopySubmitEvent() [error] missing form element"); 8818 return false; 8819 } 8820 var messageEle = formEle.querySelector(this.collectionItemCopyMessageSelect); 8821 if (messageEle === null) { 8822 this.log("collectionItemCopySubmitEvent() [error] missing message element"); 8823 return false;
8824 } 8825 // clear message 8826 messageEle.innerHTML = ""; 8827 var contentId = formEle.getAttribute(this.contentIdAttr); 8828 if (contentId === null) { 8829 this.log("collectionItemCopySubmitEvent() [error] missing data-content-id attribute"); 8830 return false; 8831 } 8832 var fromCollectionKey = formEle.getAttribute(this.collectionKeyAttr); 8833 if (fromCollectionKey === null) { 8834 this.log("collectionItemMoveSubmitEvent() [error] missing data-collection-key attribute"); 8835 return false; 8836 } 8837 var inputEle = formEle.querySelector(this.collectionItemCopyInputSelect); 8838 if (inputEle === null) { 8839 this.log("collectionItemCopySubmitEvent() [error] missing input element"); 8840 return false; 8841 } 8842 // get select input's value (cookieKey format) 8843 var toCollectionCookie = inputEle.value; 8844 if (!toCollectionCookie) { 8845 this.log("collectionItemCopySubmitEvent() [error] selected toCollectionCookie missing value"); 8846 return false; 8847 } 8848 var toCollectionKey = this.MyOncoLinkAPI.unformatCookieCollectionKey(toCollectionCookie); 8849 if (!toCollectionKey) { 8850 this.log("collectionItemCopySubmitEvent() [error] selected toCollectionKey missing"); 8851 return false; 8852 } 8853 var success = this.MyOncoLinkAPI.addContentToCollection(contentId, toCollectionKey); 8854 if (success === false) { 8855 this.log("collectionItemCopySubmitEvent() [error] adding content FAILED!"); 8856 messageEle.innerHTML = "<span class='input-error'>Error copy API</span>"; 8857 return false; 8858 } 8859 // VALIDATE that the collection was actually created before resetting form 8860 if (this.MyOncoLinkAPI.checkContentInCollection(contentId, toCollectionKey) !== true) { 8861 this.log("collectionItemCopySubmitEvent() [error] checking copy to collection check FAILED!"); 8862 messageEle.innerHTML = "<span class='input-error'>Error copy check API</span>"; 8863 return false; 8864 } 8865 8866 // assume success 8867 messageEle.innerHTML = _Translations["default"].get(this.lang, "Success!"); 8868 setTimeout(function (messageEle) { 8869 messageEle.innerHTML = ""; // DELETE entirely 8870 }, 1500, messageEle); // notify timeout 8871 8872 if (typeof this.callBackSuccess === "function") { 8873 this.log('collectionItemCopySubmitEvent() callback() ' + toCollectionKey); 8874 this.callBackSuccess(contentId, fromCollectionKey, toCollectionKey); 8875 } 8876 return true; 8877 } 8878 }, { 8879 key: "callBackSuccess", 8880 value: function callBackSuccess(contentId, toCollectionKey) { 8881 this.log("callBackSuccess() [ok]"); 8882 // will be overwritten 8883 } 8884 8885 /***************/ 8886 /*** Utility ***/ 8887 }, { 8888 key: "log", 8889 value: function log(msg) { 8890 // ?debug=1, ?debug=(className), ?debug=(className),(className) 8891 if (console && (window.location.href.indexOf('debug=1') > 0 || window.location.href.indexOf(this.constructor.name) > 0 && window.location.href.indexOf('debug') > 0)) { 8892 if (_typeof(msg) === "object") { 8893 console.log(msg); 8894 } else { 8895 console.log(this.constructor.name + "(): " + msg); 8896 } 8897 } 8898 } 8899 }]); 8900}(); 8901var _default = exports["default"] = new CollectionItemCopyForm(); 8902 8903},{"../templates/collection-item-copy-form.hbs":60,"./Translations":52,"handlebars":1}],47:[function(require,module,exports){ 8904"use strict"; 8905 8906Object.defineProperty(exports, "__esModule", { 8907 value: true 8908}); 8909exports["default"] = void 0; 8910var _handlebars = _interopRequireDefault(require("handlebars")); 8911var _collectionItemMoveForm = _interopRequireDefault(require("../templates/collection-item-move-form.hbs")); 8912var _Translations = _interopRequireDefault(require("./Translations")); 8913function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 8914function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } 8915function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } 8916function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } 8917function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } 8918function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 8919function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } 8920function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 8921function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } 8922function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } 8923var collectionItemMoveFormTemplate = _handlebars["default"].compile(_collectionItemMoveForm["default"]); 8924_handlebars["default"].registerHelper('trans', function (value1, value2, options) { 8925 return _Translations["default"].get(value1, value2); 8926}); 8927var CollectionItemMoveForm = /*#__PURE__*/function () { 8928 function CollectionItemMoveForm() { 8929 _classCallCheck(this, CollectionItemMoveForm); 8930 // align with application detector 8931 this.appSelector = "[data-comp='myol-collection-item-move']"; 8932 } 8933 return _createClass(CollectionItemMoveForm, [{ 8934 key: "init", 8935 value: function init(MyOncoLinkAPI) { 8936 // set API connection 8937 if (MyOncoLinkAPI === null) { 8938 this.log('init() [error] missing MyOncoLinkAPI'); 8939 return false;
8940 } 8941 this.MyOncoLinkAPI = MyOncoLinkAPI; // load API into this class 8942 if (this.MyOncoLinkAPI.isEnabled === false) { 8943 this.log("init() [halt] MyOncoLinkAPI.isEnabled == false"); 8944 return false; 8945 } 8946 this.callBackSuccess = null; // override success function for specific use 8947 8948 // form selectors 8949 this.collectionItemMoveToastSelect = ".myol-collection-item-move-toast"; 8950 this.collectionItemMoveFormSelect = ".myol-collection-item-move-form"; 8951 this.collectionItemMoveInputSelect = "select.myol-collection-item-move-input"; 8952 this.collectionItemMoveSubmitSelect = "button.myol-collection-item-move-submit"; 8953 this.collectionItemMoveMessageSelect = ".myol-collection-item-move-message"; // errors and messages 8954 8955 this.contentIdAttr = "data-content-id"; 8956 this.collectionKeyAttr = "data-collection-key"; 8957 this.toastCloseSelect = ".btn-close"; 8958 this.toastShowClass = "show"; 8959 this.lang = 'en'; // default 8960 try { 8961 this.lang = document.querySelector('html').getAttribute('lang'); 8962 this.log('Language: ' + this.lang); 8963 } catch (_unused) {} 8964 } 8965 }, { 8966 key: "buildUI", 8967 value: function buildUI() { 8968 this.log("buildUI()"); 8969 // option 1: in page already 8970 this.assignEvents(); 8971 } 8972 }, { 8973 key: "renderTemplate", 8974 value: function renderTemplate(params) { 8975 this.log("renderTemplate()"); 8976 params.lang = this.lang; // append lang 8977 // option 2: not already in page, render html 8978 return collectionItemMoveFormTemplate(params); 8979 } 8980 }, { 8981 key: "assignEvents", 8982 value: function assignEvents() { 8983 this.log("assignEvents()"); 8984 // option 2: not already in page, assign events to rendered HTML 8985 var widgetEles = document.querySelectorAll(this.appSelector); 8986 // for loop to preserve 'this' 8987 var _iterator = _createForOfIteratorHelper(widgetEles), 8988 _step; 8989 try { 8990 for (_iterator.s(); !(_step = _iterator.n()).done;) { 8991 var widgetEle = _step.value; 8992 // 'this' correctly refers to myObj 8993 var submitEle = widgetEle.querySelector(this.collectionItemMoveSubmitSelect); 8994 submitEle.addEventListener('click', this.collectionItemMoveSubmitEvent.bind(this)); 8995 8996 // if bootstrap toasts missing 8997 if (typeof bootstrap.Toast === "undefined") { 8998 // Assign 'close' popup event 8999 var popupCloseButtonEle = widgetEle.querySelector(this.toastCloseSelect); 9000 if (popupCloseButtonEle) { 9001 popupCloseButtonEle.addEventListener('click', this.toastCloseEvent.bind(this)); 9002 } else { 9003 this.log("buildWidgetUI() [error] missing popup close element"); 9004 } 9005 } 9006 } 9007 9008 //if bootstrap (HOLD breaks submit) 9009 } catch (err) { 9010 _iterator.e(err); 9011 } finally { 9012 _iterator.f(); 9013 } 9014 if (typeof bootstrap.Toast !== "undefined") { 9015 // toasts 9016 var toastElList = [].slice.call(document.querySelectorAll('.toast')); 9017 var toastList = toastElList.map(function (toastEl) { 9018 return new bootstrap.Toast(toastEl, {}); 9019 }); 9020 } 9021 } 9022 }, { 9023 key: "toastCloseEvent", 9024 value: function toastCloseEvent(e) { 9025 this.log("toastCloseEvent()"); 9026 var toastEle = e.target.closest(this.collectionItemMoveToastSelect); 9027 toastEle.classList.remove(this.toastShowClass); 9028 } 9029 }, { 9030 key: "collectionItemMoveSubmitEvent", 9031 value: function collectionItemMoveSubmitEvent(e) { 9032 this.log("collectionItemMoveSubmitEvent()"); 9033 9034 // use relative to e.target to allow for multiple forms on page 9035 var formEle = e.target.closest(this.collectionItemMoveFormSelect); 9036 if (formEle === null) { 9037 this.log("collectionItemMoveSubmitEvent() [error] missing form element"); 9038 return false; 9039 } 9040 var messageEle = formEle.querySelector(this.collectionItemMoveMessageSelect); 9041 if (messageEle === null) { 9042 this.log("collectionItemMoveSubmitEvent() [error] missing message element"); 9043 return false;
9044 } 9045 // clear message 9046 messageEle.innerHTML = ""; 9047 var contentId = formEle.getAttribute(this.contentIdAttr); 9048 if (contentId === null) { 9049 this.log("collectionItemMoveSubmitEvent() [error] missing data-content-id attribute"); 9050 return false; 9051 } 9052 var fromCollectionKey = formEle.getAttribute(this.collectionKeyAttr); 9053 if (fromCollectionKey === null) { 9054 this.log("collectionItemMoveSubmitEvent() [error] missing data-collection-key attribute"); 9055 return false; 9056 } 9057 var inputEle = formEle.querySelector(this.collectionItemMoveInputSelect); 9058 if (inputEle === null) { 9059 this.log("collectionItemMoveSubmitEvent() [error] missing input element"); 9060 return false; 9061 } 9062 9063 // get select input's value (cookieKey format) 9064 var toCollectionCookie = inputEle.value; 9065 if (!toCollectionCookie) { 9066 this.log("collectionItemMoveSubmitEvent() [error] selected toCollectionCookie missing value"); 9067 return false; 9068 } 9069 var toCollectionKey = this.MyOncoLinkAPI.unformatCookieCollectionKey(toCollectionCookie); 9070 if (!toCollectionKey) { 9071 this.log("collectionItemMoveSubmitEvent() [error] selected toCollectionKey missing"); 9072 return false; 9073 } 9074 9075 // clear message 9076 messageEle.innerHTML = ""; 9077 var successAdd = this.MyOncoLinkAPI.addContentToCollection(contentId, toCollectionKey); 9078 if (successAdd === false) { 9079 this.log("collectionItemMoveSubmitEvent() [error] adding content FAILED!"); 9080 messageEle.innerHTML = "<span class='input-error'>Error moveing content via API</span>"; 9081 return false; 9082 } 9083 9084 // VALIDATE that the collection was actually created before resetting form 9085 if (this.MyOncoLinkAPI.checkContentInCollection(contentId, toCollectionKey) !== true) { 9086 this.log("collectionItemMoveSubmitEvent() [error] checking move to collection check FAILED!"); 9087 messageEle.innerHTML = "<span class='input-error'>Error add content to collection API</span>"; 9088 return false; 9089 } 9090 var successRemove = this.MyOncoLinkAPI.removeContentFromCollection(contentId, fromCollectionKey); 9091 // FOR NOW: assume remove worked (ignore if error) 9092 9093 // VALIDATE that the collection was actually created before resetting form 9094 if (this.MyOncoLinkAPI.checkContentInCollection(contentId, fromCollectionKey) !== false) { 9095 this.log("collectionItemMoveSubmitEvent() [error] checking move to collection check FAILED!"); 9096 messageEle.innerHTML = "<span class='input-error'>Error remove content from collection API</span>"; 9097 return false; 9098 } 9099 9100 // assume success 9101 messageEle.innerHTML = _Translations["default"].get(this.lang, "Success!"); 9102 setTimeout(function (messageEle) { 9103 messageEle.innerHTML = ""; // DELETE entirely 9104 }, 1500, messageEle); // notify timeout 9105 9106 if (typeof this.callBackSuccess === "function") { 9107 this.log('collectionItemMoveSubmitEvent() callback() from:' + fromCollectionKey + " to: " + toCollectionKey); 9108 this.callBackSuccess(contentId, fromCollectionKey, toCollectionKey); 9109 } 9110 return true; 9111 } 9112 }, { 9113 key: "callBackSuccess", 9114 value: function callBackSuccess(contentId, fromCollectionKey, toCollectionKey) { 9115 this.log("callBackSuccess() [ok]"); 9116 // will be overwritten 9117 } 9118 9119 /***************/ 9120 /*** Utility ***/ 9121 }, { 9122 key: "log", 9123 value: function log(msg) { 9124 // ?debug=1, ?debug=(className), ?debug=(className),(className) 9125 if (console && (window.location.href.indexOf('debug=1') > 0 || window.location.href.indexOf(this.constructor.name) > 0 && window.location.href.indexOf('debug') > 0)) { 9126 if (_typeof(msg) === "object") { 9127 console.log(msg); 9128 } else { 9129 console.log(this.constructor.name + "(): " + msg); 9130 } 9131 } 9132 } 9133 }]); 9134}(); 9135var _default = exports["default"] = new CollectionItemMoveForm(); 9136 9137},{"../templates/collection-item-move-form.hbs":62,"./Translations":52,"handlebars":1}],48:[function(require,module,exports){ 9138"use strict"; 9139 9140Object.defineProperty(exports, "__esModule", { 9141 value: true 9142}); 9143exports["default"] = void 0; 9144var _jsCookie = _interopRequireDefault(require("js-cookie")); 9145function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 9146function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } 9147function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } 9148function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } 9149function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } 9150function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } 9151function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } 9152function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2
vendor: 9,720 bytes, lines 9152-9156
9152; } 9153function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; } 9154function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } 9155function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } 9156function _
9156classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 9157function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } 9158function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 9159function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } 9160function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // https://www.npmjs.com/package/js-cookie 9161var cookieParams = {}; 9162// only production uses TLD 9163if (window.location.host.indexOf('www.oncolink.org') >= 0 || window.location.host.indexOf('es.oncolink.org') >= 0) { 9164 cookieParams = { 9165 domain: '.oncolink.org' 9166 }; 9167} 9168var CookieApi = _jsCookie["default"].withAttributes(cookieParams); 9169var MyOncoLinkAPI = /*#__PURE__*/function () { 9170 function MyOncoLinkAPI() { 9171 _classCallCheck(this, MyOncoLinkAPI); 9172 // request/response trick to get class in response promise 9173 this.ajaxGetCollectionItemList = this.ajaxGetCollectionItemList.bind(this); 9174 } 9175 return _createClass(MyOncoLinkAPI, [{ 9176 key: "init", 9177 value: function init() { 9178 this.log("Initialized."); 9179 this.collectionKeyDefault = '1'; // 9180 this.isAPIConnected = false; // TBD API wiring later 9181 this.isEnabled = false; // TBD default is NOT enabled 9182 9183 // v0.1 cookie storage 9184 this.cookieCollectionPrefix = "my_oncolink_collection_"; // prefix cookie per collection 9185 this.cookieCollectionLookupKey = "my_oncolink_collections"; 9186 this.cookieEnabledKey = "my_oncolink_enabled"; // during testing, this is how to enable app 9187 this.cookieExpireDays = 360; 9188 this.cookieMaxCollections = 5; // limit 9189 this.maxCollectionNameLength = 25; // limit 9190 9191 // during testing period, have to specifically enable 9192 this.detectEnabledByUrlOrCookie(); 9193 9194 // API endpoints 9195 this.apiContentList = "/my_oncolink_api/content/list"; 9196 9197 // INIT lookup collections cookie 9198 this.initCookieCollectionLookup(); 9199 } 9200 }, { 9201 key: "setCookieDomain", 9202 value: function setCookieDomain() {} 9203 }, { 9204 key: "createCollection", 9205 value: function createCollection(label) { 9206 // passthrough to Cookie storage 9207 return this.createCookieCollection(label); 9208 } 9209 }, { 9210 key: "renameCollection", 9211 value: function renameCollection(collectionKey, label) { 9212 // passthrough to Cookie storage 9213 return this.renameCookieCollectionLookup(collectionKey, label); 9214 } 9215 }, { 9216 key: "isCollection", 9217 value: function isCollection(collectionKey) { 9218 // passthrough to Cookie storage 9219 return this.isCookieCollection(collectionKey); 9220 } 9221 }, { 9222 key: "getCollectionInfo", 9223 value: function getCollectionInfo(collectionKey) { 9224 return this.getCookieCollectionInfo(collectionKey); 9225 } 9226 }, { 9227 key: "checkContentInCollection", 9228 value: function checkContentInCollection(contentId, collectionKey) { 9229 // passthrough to Cookie storage 9230 return this.checkCookieContentInCollection(contentId, collectionKey); 9231 } 9232 }, { 9233 key: "deleteCollection", 9234 value: function deleteCollection(collectionKey, label) { 9235 return this.deleteCookieCollection(collectionKey, label); 9236 } 9237 9238 /** 9239 * 9240 * @param contentId 9241 * @returns {*|string} collectionKey (no prefix) 9242 */ 9243 }, { 9244 key: "checkContentInAnyCollection", 9245 value: function checkContentInAnyCollection(contentId) { 9246 contentId = "" + contentId; 9247 this.log('checkContentInAnyCollection() ' + contentId + " [any]"); 9248 // passthrough to Cookie storage 9249 9250 var lookupObject = this.getCookieCollectionLookupObject(); 9251 var matchCollectionKey = ""; 9252 for (var cookieKey in lookupObject) { 9253 var cookieValue = CookieApi.get(cookieKey); 9254 if (typeof cookieValue !== "undefined" && cookieValue.length > 0) { 9255 cookieValue = "" + cookieValue; // string;
9256 // this.log("checking " + cookieKey + " " + cookieValue); 9257 if (cookieValue.split(',').indexOf(contentId) >= 0) { 9258 this.log('match ' + contentId + " in " + cookieKey); 9259 return this.unformatCookieCollectionKey(cookieKey); 9260 } 9261 } 9262 } 9263 return matchCollectionKey; 9264 } 9265 }, { 9266 key: "addContentToCollection", 9267 value: function addContentToCollection(contentId, collectionKey) { 9268 collectionKey = collectionKey ? collectionKey : ""; 9269 this.log('addContentToCollection() ' + contentId + " " + collectionKey); 9270 // passthrough to Cookie storage 9271 return this.addCookieContentToCollection(contentId, collectionKey); 9272 } 9273 }, { 9274 key: "removeContentFromCollection", 9275 value: function removeContentFromCollection(contentId, collectionKey) { 9276 contentId = "" + contentId; 9277 collectionKey = collectionKey ? collectionKey : ""; 9278 this.log('removeContentFromCollection() ' + contentId + " " + collectionKey); 9279 // passthrough to Cookie storage 9280 return this.removeCookieContentFromCollection(contentId, collectionKey); 9281 } 9282 }, { 9283 key: "getCollectionItemsArray", 9284 value: function getCollectionItemsArray(collectionKey) { 9285 // passthrough to Cookie storage 9286 return this.getCookieCollectionItemsArray(collectionKey); 9287 } 9288 9289 /* 9290 For testing period, users have to specifically use a trigger url param to get the cookie set for the website 9291 */ 9292 }, { 9293 key: "detectEnabledByUrlOrCookie", 9294 value: function detectEnabledByUrlOrCookie() { 9295 // Part 1: check for Url param to enable/disable app via cookie 9296 if (window.location.href.indexOf('my-oncolink-app=enable') > 0) { 9297 CookieApi.set(this.cookieEnabledKey, true, { 9298 expires: this.cookieExpireDays 9299 }); 9300 this.log("App enable requested, create cookie"); 9301 this.isEnabled = true; 9302 } else if (window.location.href.indexOf('my-oncolink-app=disable') > 0) { 9303 this.log("App disable requested, remove cookie"); 9304 CookieApi.remove(this.cookieEnabledKey); 9305 this.isEnabled = false; 9306 }
9307 // Part 2: check for cookie (if not already enabled by url request) 9308 if (this.isEnabled === false) { 9309 try { 9310 var appEnabledCookie = CookieApi.get(this.cookieEnabledKey); 9311 if (typeof appEnabledCookie !== "undefined") { 9312 this.isEnabled = true; 9313 } 9314 } catch (error) { 9315 this.log("[error] tried to get app enabled cookie ".concat(error)); 9316 } 9317 } 9318 } 9319 9320 /****************/ 9321 /*** AJAX API ***/ 9322 }, { 9323 key: "ajaxGetCollectionItemList", 9324 value: (function () { 9325 var _ajaxGetCollectionItemList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(collectionKey) { 9326 var items, data; 9327 return _regeneratorRuntime().wrap(function _callee$(_context) { 9328 while (1) switch (_context.prev = _context.next) { 9329 case 0: 9330 collectionKey = "" + collectionKey; 9331 // part 1 get collectionitems 9332 items = this.getCollectionItemsArray(collectionKey); 9333 if (!(items.length === 0)) { 9334 _context.next = 5; 9335 break; 9336 } 9337 this.log("ajaxGetCollectionItemList() [skip] collection empty"); 9338 return _context.abrupt("return", []); 9339 case 5: 9340 data = { 9341 ids: items.join(',') 9342 }; // part 2 call AJAX API and get response JSON 9343 _context.next = 8; 9344 return fetch(this.apiContentList, { 9345 method: 'POST', 9346 body: JSON.stringify(data) 9347 }).then(function (response) { 9348 return response.json(); 9349 }) // Parse the response body as JSON 9350 ["catch"](function (error) { 9351 return function () { 9352 if (console) { 9353 console.error('Error:', error); 9354 } 9355 }; 9356 }); 9357 case 8: 9358 return _context.abrupt("return", _context.sent); 9359 case 9: 9360 case "end": 9361 return _context.stop(); 9362 } 9363 }, _callee, this); 9364 })); 9365 function ajaxGetCollectionItemList(_x) { 9366 return _ajaxGetCollectionItemList.apply(this, arguments); 9367 } 9368 return ajaxGetCollectionItemList; 9369 }() 9370 /* 9371 // RULE: only collection lookup with names will considered 'active' 9372 // RULE: cannot delete collection _1 9373 deleteCollection(collectionKey) { 9374 set collection CSV = ""; set collectionName = ""; 9375 } 9376 */ 9377 /****************************/ 9378 /* COOKIE Collection Lookup */ 9379 ) 9380 }, { 9381 key: "defaultLookupObject", 9382 value: function defaultLookupObject() { 9383 this.log('defaultLookup()'); 9384 return { 9385 my_oncolink_collection_1: "My Collection", 9386 my_oncolink_collection_2: "", 9387 my_oncolink_collection_3: "", 9388 my_oncolink_collection_4: "", 9389 my_oncolink_collection_5: "" 9390 }; 9391 } 9392 }, { 9393 key: "initCookieCollectionLookup", 9394 value: function initCookieCollectionLookup() { 9395 var checkLookupCookie = CookieApi.get(this.cookieCollectionLookupKey); 9396 if (checkLookupCookie) { 9397 this.log("initCookieCollectionLookup() Lookup cookie exists"); 9398 return true; 9399 } 9400 // serialize 9401 var lookup = this.defaultLookupObject(); 9402 this.log("initCookieCollectionLookup() creating lookup cookie"); 9403 CookieApi.set(this.cookieCollectionLookupKey, JSON.stringify(lookup), { 9404 expires: this.cookieExpireDays 9405 }); 9406 this.log(checkLookupCookie); 9407 } 9408 }, { 9409 key: "getCookieCollectionLookupObject", 9410 value: function getCookieCollectionLookupObject() { 9411 var cookieValue = CookieApi.get(this.cookieCollectionLookupKey); 9412 // if valid, return json converted 9413 if (typeof cookieValue === "string") { 9414 return JSON.parse(cookieValue); 9415 } 9416 // failsafe to fresh cookie 9417 this.initCookieCollectionLookup(); 9418 return this.defaultLookupObject; 9419 } 9420 9421 /** 9422 * Check this collection exists / is active (has label in lookup) and therefore can have items added 9423 * @param collectionKey 9424 * @returns {boolean} 9425 */ 9426 }, { 9427 key: "isCookieCollection", 9428 value: function isCookieCollection(collectionKey) { 9429 this.log("createCookieCollection() " + collectionKey); 9430 var cookieKey = this.formatCookieCollectionKey(collectionKey); 9431 var lookupObject = this.getCookieCollectionLookupObject(); 9432 return cookieKey.indexOf(cookieKey) >= 0; 9433 } 9434 }, { 9435 key: "getCookieCollectionInfo", 9436 value: function getCookieCollectionInfo(collectionKey) { 9437 var data = { 9438 'collectionKey': "", 9439 'label': "" 9440 }; 9441 this.log("getCookieCollectionInfo() " + collectionKey); 9442 var cookieKey = this.formatCookieCollectionKey(collectionKey); 9443 var lookupObject = this.getCookieCollectionLookupObject(); 9444 if (lookupObject.hasOwnProperty(cookieKey)) { 9445 data.collectionKey = collectionKey; 9446 data.label = lookupObject[cookieKey]; 9447 return data; 9448 } 9449 return data; 9450 } 9451 9452 /** 9453 * Take an open Collection cookie (blank), not really creating 9454 * @param {string} label 9455 * @returns {object} data = { 'collectionKey':"",'error': "",'label':""} 9456 */ 9457 }, { 9458 key: "createCookieCollection", 9459 value: function createCookieCollection() { 9460 var label = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ""; 9461 // response data holder 9462 var data = { 9463 'label': "", 9464 'collectionKey': "", 9465 'error': "" 9466 }; 9467 label = this.cleanTruncateCollectionLabel(label); 9468 if (!label || label.length === 0) { 9469 this.log("Missing label"); 9470 data.error = "Missing label"; 9471 return data; 9472 } 9473 data.label = label; // store updated label 9474 this.log("createCookieCollection() " + label); 9475 var lookupObject = this.getCookieCollectionLookupObject(); 9476 var nextCollectionKey = ""; 9477 for (var cookieKey in lookupObject) { 9478 var lookupLabel = lookupObject[cookieKey]; 9479 // next empty label 9480 if (lookupLabel.trim() === "") { 9481 nextCollectionKey = this.unformatCookieCollectionKey(cookieKey); 9482 this.log("Next collection cookieKey: " + nextCollectionKey); 9483 break; // exit loop when found 9484 } 9485 } 9486 // if NO empty collection labels found then MAX hit 9487 if (!nextCollectionKey || nextCollectionKey.length === 0) { 9488 this.log("createCookieCollection() [error] No more collections can be added (max)"); 9489 data.error = "Collection limit hit"; 9490 return data; 9491 } 9492 this.log("createCookieCollection() " + nextCollectionKey); 9493 data.collectionKey = nextCollectionKey; // store nextCollectionKey 9494 var success = this.renameCookieCollectionLookup(nextCollectionKey, label); 9495 if (success) { 9496 return data; 9497 } 9498 9499 // if failed to set, then return empty 9500 data.error = "not created"; 9501 return data; 9502 } 9503 }, { 9504 key: "deleteCookieCollection", 9505 value: function deleteCookieCollection(collectionKey) { 9506 var label = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ""; 9507 // response data holder 9508 var data = { 9509 'label': "", 9510 'collectionKey': collectionKey, 9511 'error': "" 9512 }; 9513 label = this.cleanTruncateCollectionLabel(label); 9514 if (!label || label.length === 0) { 9515 this.log("Missing label"); 9516 data.error = "Missing label"; 9517 return data; 9518 } 9519 data.label = label; // store updated label 9520 var cookieKey = this.formatCookieCollectionKey(collectionKey); 9521 this.log("deleteCookieCollection() " + cookieKey + " " + label); 9522 if (!cookieKey) { 9523 data.error = "Missing key match"; 9524 return data; 9525 } 9526 var lookupObject = this.getCookieCollectionLookupObject(); 9527 lookupObject[cookieKey] = ""; // delete label deletes collection 9528 // store 9529 CookieApi.set(this.cookieCollectionLookupKey, JSON.stringify(lookupObject), { 9530 expires: this.cookieExpireDays 9531 }); 9532 CookieApi.remove(cookieKey); // delete cookie holding content 9533 return data; 9534 } 9535 }, { 9536 key: "renameCookieCollectionLookup", 9537 value: function renameCookieCollectionLookup(collectionKey) { 9538 var label = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ""; 9539 // response data holder 9540 var data = { 9541 'label': "", 9542 'collectionKey': collectionKey, 9543 'error': "" 9544 }; 9545 label = this.cleanTruncateCollectionLabel(label); 9546 if (!label || label.length === 0) { 9547 this.log("Missing label"); 9548 data.error = "Missing label"; 9549 return data; 9550 } 9551 data.label = label; // store updated label 9552 var cookieKey = this.formatCookieCollectionKey(collectionKey); 9553 this.log("renameCookieCollectionLookup() " + cookieKey + " " + label); 9554 if (!cookieKey) { 9555 data.error = "Missing key match"; 9556 return data; 9557 } 9558 var lookupObject = this.getCookieCollectionLookupObject(); 9559 lookupObject[cookieKey] = label; 9560 // store 9561 // this.log(lookup); 9562 CookieApi.set(this.cookieCollectionLookupKey, JSON.stringify(lookupObject), { 9563 expires: this.cookieExpireDays 9564 }); 9565 return data; 9566 } 9567 9568 /***************************/ 9569 9570 /* COOKIE Collection Items */ 9571 }, { 9572 key: "addCookieContentToCollection", 9573 value: function addCookieContentToCollection(contentId, collectionKey) { 9574 contentId = "" + contentId; 9575 var items = this.getCookieCollectionItemsArray(collectionKey); 9576 // add to array 9577 items.push(contentId); // as string to prevent id keys 9578 // make unique 9579 var unique = _toConsumableArray(new Set(items)); 9580 // array to CSV and store 9581 var newCookieValue = unique.join(','); 9582 var cookieKey = this.formatCookieCollectionKey(collectionKey); 9583 CookieApi.set(cookieKey, newCookieValue, { 9584 expires: this.cookieExpireDays 9585 }); 9586 this.log("addCookieContentToCollection() [" + cookieKey + "] new value [" + newCookieValue + "]"); 9587 return true; 9588 } 9589 }, { 9590 key: "removeCookieContentFromCollection", 9591 value: function removeCookieContentFromCollection(contentId, collectionKey) { 9592 contentId = "" + contentId; 9593 var items = this.getCookieCollectionItemsArray(collectionKey); 9594 if (items === null || items.length === 0) { 9595 this.log("removeCookieContentFromCollection() [skip] cookie empty"); 9596 return false;
9597 } 9598 // remove from items (cloned array to be 100% sure) 9599 var itemsNew = this.removeArrayItemByKey(contentId, items); 9600 if (items.length === itemsNew.length) { 9601 this.log("removeCookieContentFromCollection() [error] item was not removed"); 9602 return false; 9603 } 9604 // make unique 9605 var unique = _toConsumableArray(new Set(itemsNew)); 9606 // array to CSV and store 9607 var newCookieValue = unique.join(','); 9608 var cookieKey = this.formatCookieCollectionKey(collectionKey); 9609 CookieApi.set(cookieKey, newCookieValue, { 9610 expires: this.cookieExpireDays 9611 }); 9612 this.log("removeCookieContentFromCollection() [" + cookieKey + "] new value [" + newCookieValue + "]"); 9613 return true; 9614 } 9615 }, { 9616 key: "checkCookieContentInCollection", 9617 value: function checkCookieContentInCollection(contentId, collectionKey) { 9618 collectionKey = collectionKey ? collectionKey : ""; 9619 contentId = "" + contentId; 9620 this.log('checkCookieContentInCollection() ' + contentId + " " + collectionKey); 9621 var collectionItems = this.getCollectionItemsArray(collectionKey); 9622 if (typeof collectionItems !== "undefined" && collectionItems.length > 0) { 9623 var inCollection = collectionItems.indexOf(contentId) > -1; 9624 if (inCollection === true) { 9625 this.log("checkCookieContentInCollection() " + contentId + " found!"); 9626 } else { 9627 this.log("checkCookieContentInCollection() " + contentId + " not found!"); 9628 } 9629 return inCollection; 9630 } 9631 this.log("checkCookieContentInCollection() [Skip] not found or empty"); 9632 return false; 9633 } 9634 }, { 9635 key: "getCookieCollectionItemsArray", 9636 value: function getCookieCollectionItemsArray(collectionKey) { 9637 collectionKey = "" + collectionKey; 9638 var cookieKey = this.formatCookieCollectionKey(collectionKey); 9639 var cookieValue = CookieApi.get(cookieKey); 9640 if (typeof cookieValue !== "undefined" && cookieValue.length > 0) { 9641 cookieValue = "" + cookieValue; // string; 9642 this.log("getCollectionItems() [" + cookieKey + "] => [" + cookieValue + "]"); 9643 return cookieValue.split(','); 9644 } 9645 this.log("getCollectionItems() " + cookieKey + " is empty"); 9646 return []; 9647 } 9648 }, { 9649 key: "formatCookieCollectionKey", 9650 value: function formatCookieCollectionKey(collectionKey) { 9651 collectionKey = "" + collectionKey.trim(); 9652 var cookieKey = this.cookieCollectionPrefix + '' + this.collectionKeyDefault; 9653 // not empty value ("1","2","test",...) 9654 if (typeof collectionKey === "string" && collectionKey.length !== 0) { 9655 cookieKey = this.cookieCollectionPrefix + '' + collectionKey; 9656 } 9657 this.log("formatCookieCollectionKey() Cookie: [" + cookieKey + "]"); 9658 return cookieKey; 9659 } 9660 }, { 9661 key: "unformatCookieCollectionKey", 9662 value: function unformatCookieCollectionKey(cookieKey) { 9663 return cookieKey.replaceAll(this.cookieCollectionPrefix, ""); 9664 } 9665 9666 /***************/ 9667 /*** Utility ***/ 9668 }, { 9669 key: "cleanTruncateCollectionLabel", 9670 value: function cleanTruncateCollectionLabel(label) { 9671 if (!label) { 9672 return ""; 9673 } 9674 // allow letters, numbers, SPACE, '-','_' 9675 return label.trim().replace(/[^a-zA-Z0-9 -_]/g, "").slice(0, this.maxCollectionNameLength); // clean/truncate 9676 } 9677 }, { 9678 key: "removeArrayItemByKey", 9679 value: function removeArrayItemByKey(removeKey, arr) { 9680 removeKey = "" + removeKey.trim(); // convert to string; 9681 if (!Array.isArray(arr)) { 9682 console.error('Passing non array into remove function'); 9683 return arr; 9684 } 9685 if (typeof removeKey !== "string") { 9686 console.error('Passing non string removeKey into remove function'); 9687 return arr; 9688 } 9689 9690 // create proper CLONE else pass by reference will not change array 9691 var newArr = _toConsumableArray(new Set(arr)); 9692 var index = newArr.indexOf(removeKey); // Find the index of the string 9693 if (index > -1) { 9694 // Only splice if the item is found 9695 // console.log("Removing item from array"); 9696 newArr.splice(index, 1); // 2nd parameter means remove one item only 9697 } 9698 return newArr; 9699 } 9700 }, { 9701 key: "log", 9702 value: function log(msg) { 9703 if (console && window.location.href.indexOf('debug') > 0 && (window.location.href.indexOf(this.constructor.name) > 0 || window.location.href.indexOf('debug=1') > 0)) { 9704 if (_typeof(msg) === "object") { 9705 console.log(msg); 9706 } else { 9707 console.log(this.constructor.name + "(): " + msg); 9708 } 9709 } 9710 } 9711 }]); 9712}(); 9713var _default = exports["default"] = new MyOncoLinkAPI(); 9714 9715},{"js-cookie":42}],49:[function(require,module,exports){ 9716"use strict"; 9717 9718Object.defineProperty(exports, "__esModule", { 9719 value: true 9720}); 9721exports["default"] = void 0; 9722var _handlebars = _interopRequireDefault(require("handlebars")); 9723var _collectionPageLayout = _interopRequireDefault(require("../templates/collection-
9723page-layout.hbs")); 9724var _collectionItemLine = _interopRequireDefault(require("../templates/collection-item-line.hbs")); 9725var _Translations = _interopRequireDefault(require("./Translations")); 9726function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 9727function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } 9728function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } 9729function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } 9730function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } 9731function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 9732function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } 9733function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 9734function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } 9735function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // Build collection page 9736var collectionPageLayoutTemplate = _handlebars["default"].compile(_collectionPageLayout["default"]); 9737var collectionItemLineTemplate = _handlebars["default"].compile(_collectionItemLine["default"]); 9738_handlebars["default"].registerHelper('eq', function (a, b) { 9739 return a === b; 9740}); 9741_handlebars["default"].registerHelper('trans', function (value1, value2, options) { 9742 return _Translations["default"].get(value1, value2); 9743}); 9744var MyOncoLinkCollectionPage = /*#__PURE__*/function () { 9745 function MyOncoLinkCollectionPage() { 9746 _classCallCheck(this, MyOncoLinkCollectionPage); 9747 // align with application detector
9748 this.appSelector = "[data-comp='myol-collection-page']"; 9749 // magic 9750 this.populateTabPane = this.populateTabPane.bind(this); 9751 } 9752 return _createClass(MyOncoLinkCollectionPage, [{ 9753 key: "init", 9754 value: function init(MyOncoLinkAPI, CollectionCreateForm, CollectionEditForm, CollectionDeleteForm, CollectionItemCopyForm, CollectionItemMoveForm) { 9755 this.log("init()"); 9756 9757 // check single page app 9758 this.pageEle = document.querySelector(this.appSelector); 9759 if (this.pageEle === null) { 9760 this.log('init() [error] detecting app'); 9761 return false; 9762 } 9763 9764 // set API connection 9765 if (MyOncoLinkAPI === null) { 9766 this.log('init() [error] missing MyOncoLinkAPI'); 9767 return false; 9768 } 9769 this.MyOncoLinkAPI = MyOncoLinkAPI; // load API into this class 9770 if (this.MyOncoLinkAPI.isEnabled === false) { 9771 this.log("init() [halt] MyOncoLinkAPI.isEnabled == false"); 9772 return false; 9773 } 9774 if (CollectionCreateForm === null) { 9775 this.log('init() [error] missing CollectionCreateForm'); 9776 return false; 9777 } 9778 this.CollectionCreateForm = CollectionCreateForm; // load into this class 9779 this.CollectionCreateForm.init(this.MyOncoLinkAPI); // init (no events yet) 9780 this.CollectionCreateForm.callBackSuccess = this.callbackCollectionCreateSubmitSuccess.bind(this); 9781 if (CollectionEditForm === null) { 9782 this.log('init() [error] missing CollectionEditForm'); 9783 return false; 9784 } 9785 this.CollectionEditForm = CollectionEditForm; // load into this class 9786 this.CollectionEditForm.init(this.MyOncoLinkAPI); // init (no events yet) 9787 this.CollectionEditForm.callBackSuccess = this.callbackCollectionEditSubmitSuccess.bind(this); 9788 if (CollectionDeleteForm === null) { 9789 this.log('init() [error] missing CollectionDeleteForm'); 9790 return false; 9791 } 9792 this.CollectionDeleteForm = CollectionDeleteForm; // load into this class 9793 this.CollectionDeleteForm.init(this.MyOncoLinkAPI); // init (no events yet) 9794 this.CollectionDeleteForm.callBackSuccess = this.callbackCollectionDeleteSubmitSuccess.bind(this); 9795 if (CollectionItemCopyForm === null) { 9796 this.log('init() [error] missing CollectionItemCopyForm'); 9797 return false; 9798 } 9799 this.CollectionItemCopyForm = CollectionItemCopyForm; // load into this class 9800 this.CollectionItemCopyForm.init(this.MyOncoLinkAPI); // init (no events yet) 9801 this.CollectionItemCopyForm.callBackSuccess = this.callbackCollectionItemCopySubmitSuccess.bind(this); 9802 if (CollectionItemMoveForm === null) { 9803 this.log('init() [error] missing CollectionItemMoveForm'); 9804 return false; 9805 } 9806 this.CollectionItemMoveForm = CollectionItemMoveForm; // load into this class 9807 this.CollectionItemMoveForm.init(this.MyOncoLinkAPI); // init (no events yet) 9808 this.CollectionItemMoveForm.callBackSuccess = this.callbackCollectionItemMoveSubmitSuccess.bind(this); 9809 9810 // Top level elements 9811 this.containerLayoutTargetSelect = '#myol-collection-layout-target'; // where layout is appended to page 9812 this.containerLayoutSelect = '#myol-collection-layout'; // MAIN layout holder 9813 this.pageSpinnerSelect = '#myol-ajax-spinner'; 9814 this.pageMessageSelect = '#myol-collection-page-message'; // messages go here 9815 this.containerTabNavSelect = "#nav-tab"; // tab nav holder 9816 this.containerTabContentSelect = "#nav-tab-content"; // tab content holder 9817 this.collectionCreateTargetSelect = ".myol-collection-create-target"; // single 9818 this.collectionEditTargetSelect = ".myol-collection-edit-target"; // Multiple under specific tab content 9819 this.collectionDeleteTargetSelect = ".myol-collection-delete-target"; // Multiple under specific tab content 9820 9821 this.collectionKeyDataAttr = "data-collection-key"; 9822 9823 // Layout listing elements 9824 this.containerArticlesSelect = '.myol-collection-articles'; // N tab + articles holder 9825 this.containerDrugsSelect = '.myol-collection-drugs'; // N tab + drugs holder 9826 9827 // generic utility selectors 9828 this.hideSelect = '.visually-hidden'; 9829 this.hideClassName = this.hideSelect.replace('.', ''); // remove dot 9830 this.listGroupSelect = ".list-group"; 9831 this.listGroupItemSelect = '.list-group-item'; 9832 this.tabPaneSelect = '.tab-pane'; 9833 this.navLinkSelect = "button.nav-link"; // child links of #nav-tab 9834 9835 // list-items 9836 this.collectionItemCopyTargetSelect = ".myol-collection-item-copy-target"; // N per list item 9837 this.collectionItemCopyDropDownSelect = ".myol-collection-item-copy-dropdown"; // N per list item 9838 this.collectionItemCopyButtonSelect = 'button.myol-collection-item-copy-toggle'; // N per list item 9839 9840 this.collectionItemMoveTargetSelect = ".myol-collection-item-move-target"; // N per list item 9841 this.collectionItemMoveDropDownSelect = ".myol-collection-item-move-dropdown"; // N per list item 9842 this.collectionItemMoveButtonSelect = 'button.myol-collection-item-move-toggle'; // N per list item 9843 9844 this.collectionItemRemoveButtonSelect = 'button.myol-collection-item-remove'; // N per list item 9845 9846 // re-usable elements (after UI build) 9847 this.collectionLayoutEle = null; 9848 this.ajaxItemsSpinnerEle = null; 9849 this.pageMessageEle = null; 9850 this.toastTitle = "myOncoLink"; 9851 this.lang = 'en'; // default
9852 try { 9853 this.lang = document.querySelector('html').getAttribute('lang'); 9854 this.log('Language: ' + this.lang); 9855 } catch (_unused) {} 9856 this.buildUI(); 9857 } 9858 }, { 9859 key: "buildUI", 9860 value: function buildUI() { 9861 this.buildLayoutUI(); 9862 this.buildRecommendUI(); 9863 this.buildCollectionCreateUI(); 9864 this.buildCollectionEditMultipleUI(); 9865 this.buildCollectionDeleteMultipleUI(); 9866 } 9867 }, { 9868 key: "buildLayoutUI", 9869 value: function buildLayoutUI() { 9870 // populate with ajax data 9871 this.log("buildLayoutUI()"); 9872 9873 // TODO: populate from collections 9874 // first element = active 9875 var navLinks = []; 9876 var lookupObject = this.MyOncoLinkAPI.getCookieCollectionLookupObject(); 9877 var navCount = 0; 9878 for (var cookieKey in lookupObject) { 9879 var navActive = false; 9880 // only first item is true; rest are false 9881 if (navCount === 0) { 9882 navActive = true; 9883 } 9884 var label = lookupObject[cookieKey]; 9885 if (label.length === 0) { 9886 continue; 9887 } 9888 // only add not empty labels 9889 if (label && label.length > 0) { 9890 navLinks.push({ 9891 'label': label, 9892 'collectionKey': this.MyOncoLinkAPI.unformatCookieCollectionKey(cookieKey), 9893 'active': navActive 9894 }); 9895 } 9896 navCount++; 9897 } 9898 var targetEle = document.querySelector(this.containerLayoutTargetSelect); 9899 var htmlPageLayout = collectionPageLayoutTemplate({ 9900 'lang': this.lang, 9901 'navLinks': navLinks 9902 }); 9903 targetEle.insertAdjacentHTML('beforeend', htmlPageLayout); 9904 this.collectionLayoutEle = targetEle.querySelector(this.containerLayoutSelect); 9905 if (this.collectionLayoutEle === null) { 9906 this.log("buildLayoutUI() [error] missing layout element"); 9907 } 9908 9909 // re-use spinner 9910 this.ajaxItemsSpinnerEle = targetEle.querySelector(this.pageSpinnerSelect); 9911 9912 // re-use page message 9913 this.pageMessageEle = targetEle.querySelector(this.pageMessageSelect); 9914 9915 // Build first tab .tab-pane 9916 var tabPanes = targetEle.querySelectorAll(this.tabPaneSelect); 9917 if (tabPanes === null || tabPanes.length === 0) { 9918 this.log("buildLayoutUI() [error] missing tab panes"); 9919 return false; 9920 } 9921 var firstTabPane = tabPanes[0]; // ajax on first tab 9922 var firstCollectionKey = firstTabPane.dataset.collectionKey; 9923 9924 // build first tab using ajax 9925 this.fetchTabPaneContent(firstCollectionKey); 9926 9927 // assign Nav Item click events to trigger re-populate; 9928 var navTabEle = document.querySelector(this.containerTabNavSelect); 9929 var navTabLinkEles = navTabEle.querySelectorAll(this.navLinkSelect); 9930 var _iterator = _createForOfIteratorHelper(navTabLinkEles), 9931 _step; 9932 try { 9933 for (_iterator.s(); !(_step = _iterator.n()).done;) { 9934 var navTabLink = _step.value; 9935 // navTabLink.addEventListener('click',this.navLinkBootstrapTabAfterEvent.bind(this)); 9936 navTabLink.addEventListener('shown.bs.tab', this.navLinkBootstrapTabAfterEvent.bind(this)); 9937 } 9938 } catch (err) { 9939 _iterator.e(err); 9940 } finally { 9941 _iterator.f(); 9942 } 9943 } 9944 }, { 9945 key: "buildRecommendUI", 9946 value: function buildRecommendUI() { 9947 /// TBD 9948 } 9949 }, { 9950 key: "buildCollectionCreateUI", 9951 value: function buildCollectionCreateUI() { 9952 this.log("buildCollectionCreateUI()"); 9953 9954 // Part 1: append to target(s) 9955 var targetEles = document.querySelectorAll(this.collectionCreateTargetSelect); 9956 var _iterator2 = _createForOfIteratorHelper(targetEles), 9957 _step2; 9958 try { 9959 for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { 9960 var targetEle = _step2.value; 9961 if (!targetEle) { 9962 this.log("buildCollectionCreateUI() [error] missing collection create target element"); 9963 } 9964 targetEle.innerHTML = this.CollectionCreateForm.renderTemplate({ 9965 'lang': this.lang, 9966 'maxLength': this.MyOncoLinkAPI.maxCollectionNameLength 9967 }); 9968 } 9969 9970 // Part 2: assign events after HTML 9971 } catch (err) { 9972 _iterator2.e(err); 9973 } finally { 9974 _iterator2.f(); 9975 } 9976 this.CollectionCreateForm.assignEvents(); 9977 9978 // Hide if at MAX 9979 this.checkCollectionCreateDisplay(); 9980 } 9981 }, { 9982 key: "buildCollectionEditMultipleUI", 9983 value: function buildCollectionEditMultipleUI() { 9984 this.log("buildCollectionEditMultipleUI()"); 9985 9986 // append EDIT forms to each tab-content 9987 var tabContentEles = document.querySelectorAll(this.containerTabContentSelect + ' ' + this.tabPaneSelect); 9988 var _iterator3 = _createForOfIteratorHelper(tabContentEles), 9989 _step3;
9990 try { 9991 for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { 9992 var tabPaneEle = _step3.value; 9993 if (!tabPaneEle) { 9994 this.log("buildCollectionEditMultipleUI() [error] missing tab-pane element"); 9995 continue; 9996 } 9997 var targetEle = tabPaneEle.querySelector(this.collectionEditTargetSelect); 9998 if (!targetEle) { 9999 this.log("buildCollectionEditMultipleUI() [error] missing collection edit target"); 10000 continue; 10001 } 10002 var collectionKey = tabPaneEle.dataset.collectionKey; 10003 var collectionName = tabPaneEle.dataset.collectionName; 10004 targetEle.innerHTML = this.CollectionEditForm.renderTemplate({ 10005 'collectionKey': collectionKey, 10006 'label': collectionName, 10007 'maxLength': this.MyOncoLinkAPI.maxCollectionNameLength, 10008 'lang': this.lang 10009 }); 10010 } 10011 10012 // Part 2: assign events 10013 } catch (err) { 10014 _iterator3.e(err); 10015 } finally { 10016 _iterator3.f(); 10017 } 10018 this.CollectionEditForm.assignEvents(); 10019 } 10020 }, { 10021 key: "buildCollectionDeleteMultipleUI", 10022 value: function buildCollectionDeleteMultipleUI() { 10023 this.log("buildCollectionDeleteMultipleUI()"); 10024 10025 // append DELETE forms to each tab-content 10026 var tabContentEles = document.querySelectorAll(this.containerTabContentSelect + ' ' + this.tabPaneSelect); 10027 var _iterator4 = _createForOfIteratorHelper(tabContentEles), 10028 _step4; 10029 try { 10030 for (_iterator4.s();
10030 !(_step4 = _iterator4.n()).done;) { 10031 var tabPaneEle = _step4.value; 10032 if (!tabPaneEle) { 10033 this.log("buildCollectionDeleteMultipleUI() [error] missing tab-pane element"); 10034 continue; 10035 } 10036 var targetEle = tabPaneEle.querySelector(this.collectionDeleteTargetSelect); 10037 if (!targetEle) { 10038 this.log("buildCollectionDeleteMultipleUI() [error] missing collection delete target"); 10039 continue; 10040 } 10041 var collectionKey = tabPaneEle.dataset.collectionKey; 10042 var collectionName = tabPaneEle.dataset.collectionName; 10043 targetEle.innerHTML = this.CollectionDeleteForm.renderTemplate({ 10044 'collectionKey': collectionKey, 10045 'label': collectionName, 10046 'maxLength': this.MyOncoLinkAPI.maxCollectionNameLength, 10047 'lang': this.lang 10048 }); 10049 } 10050 } catch (err) { 10051 _iterator4.e(err); 10052 } finally { 10053 _iterator4.f(); 10054 } 10055 this.CollectionDeleteForm.assignEvents(); 10056 } 10057 }, { 10058 key: "checkCollectionCreateDisplay", 10059 value: function checkCollectionCreateDisplay() { 10060 // if collection count is at max, then hide the create form 10061 var tabNavLinkEles = document.querySelectorAll(this.containerTabNavSelect + ' ' + this.navLinkSelect); 10062 if (!tabNavLinkEles) { 10063 this.log("checkCollectionCreateDisplay() [error] missing navlink elements"); 10064 return false; 10065 } 10066 var formEle = document.querySelector(this.CollectionCreateForm.collectionCreateFormSelect); 10067 if (!formEle) { 10068 this.log("checkCollectionCreateDisplay() [error] missing form element"); 10069 return false; 10070 } 10071 if (tabNavLinkEles.length === this.MyOncoLinkAPI.cookieMaxCollections) { 10072 this.log("checkCollectionCreateDisplay() at max, hide"); 10073 formEle.classList.add(this.hideClassName); 10074 } else { 10075 this.log("checkCollectionCreateDisplay() not max, show"); 10076 formEle.classList.remove(this.hideClassName); 10077 } 10078 } 10079 10080 /** 10081 * Leverage BootTrap 5 tab event 'show.bs.tab' finished event 10082 * @param e 10083 */ 10084 }, { 10085 key: "navLinkBootstrapTabAfterEvent", 10086 value: function navLinkBootstrapTabAfterEvent(e) { 10087 this.log("navLinkBootstrapTabAfterEvent()"); 10088 var activeTabNavLink = document.querySelector(this.containerTabNavSelect + " .active"); 10089 var activeCollectionKey = activeTabNavLink.dataset.collectionKey; 10090 this.log("navLinkBootstrapTabAfterEvent() active collectionKey: " + activeCollectionKey); 10091 this.fetchTabPaneContent(activeCollectionKey); 10092 } 10093 10094 /***********************************/ 10095 /** Callbacks (extending classes) **/ 10096 }, { 10097 key: "callbackAPISuccess", 10098 value: function callbackAPISuccess(message) { 10099 this.log("callbackAPISuccess()"); 10100 // clear / show success message 10101 } 10102 }, { 10103 key: "callbackAPIError", 10104 value: function callbackAPIError(message) { 10105 this.log("callbackAPIError()"); 10106 // clear / show error message 10107 } 10108 }, { 10109 key: "callbackCollectionCreateSubmitSuccess", 10110 value: function callbackCollectionCreateSubmitSuccess(createResult) { 10111 this.log("callbackCollectionCreateSubmitSuccess()"); 10112 // reload the current page 10113 window.location.reload(); 10114 // refresh page on new collection create 10115 } 10116 }, { 10117 key: "callbackCollectionEditSubmitSuccess", 10118 value: function callbackCollectionEditSubmitSuccess(collectionKey, label) { 10119 this.log("callbackCollectionEditSubmitSuccess()"); 10120 // on submit, update nav item label to match 10121 var navMatchSelect = this.containerTabNavSelect + " [" + this.collectionKeyDataAttr + "='" + collectionKey + "']"; 10122 var matchNavItem = document.querySelector(navMatchSelect); 10123 matchNavItem.textContent = label; 10124 } 10125 }, { 10126 key: "callbackCollectionDeleteSubmitSuccess", 10127 value: function callbackCollectionDeleteSubmitSuccess(deleteResult) { 10128 // reload the current page 10129 window.location.reload(); 10130 } 10131 }, { 10132 key: "callbackCollectionItemCopySubmitSuccess", 10133 value: function callbackCollectionItemCopySubmitSuccess(contentId, fromCollectionKey, toCollectionKey) { 10134 this.log("callbackCollectionItemCopySubmitSuccess() .. TODO"); 10135 // nothing yet 10136 } 10137 }, { 10138 key: "callbackCollectionItemMoveSubmitSuccess", 10139 value: function callbackCollectionItemMoveSubmitSuccess(contentId, fromCollectionKey, toCollectionKey) { 10140 this.log("callbackCollectionItemMoveSubmitSuccess() .. "); 10141 // remove this contentId from list-group 10142 var listGroupItem = this.pageEle.querySelector(".list-group-item[data-content-id='" + contentId + "'][data-collection-key='" + fromCollectionKey + "']"); 10143 listGroupItem.parentNode.removeChild(listGroupItem); 10144 } 10145 10146 /***********************************/ 10147 }, { 10148 key: "fetchTabPaneContent", 10149 value: function fetchTabPaneContent(collectionKey) { 10150 var _this = this; 10151 this.log("fetchTabPaneContent()"); 10152 10153 // show spinner on load 10154 this.ajaxItemsSpinnerEle.classList.remove(this.hideClassName); 10155 this.pageMessageEle.classList.add(this.hideClassName); 10156 this.pageMessageEle.innerHTML = ""; 10157 10158 // async ajax 10159 var request = this.MyOncoLinkAPI.ajaxGetCollectionItemList(collectionKey); 10160 request.then(function (response) { 10161 _this.log("fetchTabPaneContent() Ajax response"); 10162 // hide spinner on return 10163 _this.ajaxItemsSpinnerEle.classList.add(_this.hideClassName); 10164 if (typeof response.items === "undefined") { 10165 _this.log("fetchTabPaneContent() [error] response.items not found (likely empty collection)"); 10166 _this.pageMessageEle.classList.remove(_this.hideClassName); 10167 _this.pageMessageEle.innerHTML = _Translations["default"].get(_this.lang, "Empty collection"); 10168 return false;
10169 } 10170 var contentItems = response.items; 10171 // console.log(response); 10172 _this.populateTabPane(contentItems, collectionKey); 10173 }); 10174 } 10175 }, { 10176 key: "populateTabPane", 10177 value: function populateTabPane(contentItems, collectionKey) { 10178 this.log("populateTabPane()"); 10179 if (contentItems === null || contentItems.length === 0) { 10180 this.log("populateTabPane() [skip] response.items empty"); 10181 this.pageMessageEle.classList.remove(this.hideClassName); 10182 this.pageMessageEle.innerHTML = _Translations["default"].get(this.lang, "Collection is empty"); 10183 return false; 10184 } 10185 if (collectionKey === null || collectionKey.length === 0) { 10186 this.log("populateTabPane() [skip] collectionKey missing"); 10187 this.pageMessageEle.classList.remove(this.hideClassName); 10188 this.pageMessageEle.innerHTML = _Translations["default"].get(this.lang, "Collection was not found"); 10189 return false; 10190 } 10191 // get tab based on collectionKey 10192 var tabPaneEle = this.collectionLayoutEle.querySelector(this.tabPaneSelect + '[data-collection-key="' + collectionKey + '"]'); 10193 if (!tabPaneEle) { 10194 this.log("populateTabPane() [error] missing tabPaneEle"); 10195 } 10196 10197 // Get first tab content 10198 var articleContainerEle = tabPaneEle.querySelector(this.containerArticlesSelect); 10199 var articleListGroupEle = articleContainerEle.querySelector(this.listGroupSelect); 10200 if (articleListGroupEle === null) { 10201 this.log('[error] missing articleListGroupEle'); 10202 return false; 10203 } 10204 articleContainerEle.classList.add(this.hideClassName); // hide parent 10205 articleListGroupEle.innerHTML = ""; // clear 10206 10207 var drugContainerEle = tabPaneEle.querySelector(this.containerDrugsSelect); 10208 var drugListGroupEle = drugContainerEle.querySelector(this.listGroupSelect); 10209 if (drugListGroupEle === null) { 10210 this.log('[error] missing drugListGroupEle'); 10211 return false; 10212 } 10213 drugContainerEle.classList.add(this.hideClassName); // hide parent 10214 drugListGroupEle.innerHTML = ""; // clear 10215 10216 var that = this; // needed for use in closures 10217 10218 var articleItems = []; 10219 var drugItems = []; 10220 10221 // loop to split into holder arrays, and for sorting 10222 contentItems.forEach(function (item, index) { 10223 if (item.contentType === "drug") { 10224 drugItems[item.title] = item; 10225 } else { 10226 articleItems[item.title] = item; 10227 } 10228 }); 10229 this.log("populateListGroups() process " + contentItems.length + " content items"); 10230 var sortedArticleKeys = Object.keys(articleItems).sort(); // keys 10231 if (sortedArticleKeys.length > 0) { 10232 this.log("populateListGroups() render Articles"); 10233 var htmlArticleItems = ""; 10234 // This is becuase javascript is stupid and looping over an object that is sorted by key is broken 10235 var _iterator5 = _createForOfIteratorHelper(sortedArticleKeys), 10236 _step5; 10237 try { 10238 for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) { 10239 var key = _step5.value; 10240 var item = articleItems[key]; 10241 that.log("append item " + item.title); 10242 htmlArticleItems += collectionItemLineTemplate({ 10243 item: item, 10244 collectionKey: collectionKey, 10245 lang: this.lang 10246 }); 10247 } 10248 } catch (err) { 10249 _iterator5.e(err); 10250 } finally { 10251 _iterator5.f(); 10252 } 10253 articleListGroupEle.innerHTML = htmlArticleItems; // append at once (no dom elements to mess with sort order 10254 articleContainerEle.classList.remove(this.hideClassName); // has content, show parent container 10255 } 10256 var sortedDrugKeys = Object.keys(drugItems).sort(); // keys 10257 if (sortedDrugKeys.length > 0) { 10258 this.log("populateListGroups() render Drugs"); 10259 var htmlDrugItems = ""; 10260 // This is because javascript is stupid and looping over an object that is sorted by key is broken 10261 var _iterator6 = _createForOfIteratorHelper(sortedDrugKeys), 10262 _step6; 10263 try { 10264 for (_iterator6.s();
10264 !(_step6 = _iterator6.n()).done;) { 10265 var _key = _step6.value; 10266 var _item = drugItems[_key]; 10267 that.log("append item " + _item.title); 10268 htmlDrugItems += collectionItemLineTemplate({ 10269 item: _item, 10270 collectionKey: collectionKey, 10271 lang: this.lang 10272 }); 10273 } 10274 } catch (err) { 10275 _iterator6.e(err); 10276 } finally { 10277 _iterator6.f(); 10278 } 10279 drugListGroupEle.innerHTML = htmlDrugItems; // append at once (no dom elements to mess with sort order 10280 drugContainerEle.classList.remove(this.hideClassName); // has content, show parent container 10281 } 10282 var tabNavLinkEles = document.querySelectorAll(this.containerTabNavSelect + ' ' + this.navLinkSelect); 10283 10284 // assign 'remove' events to ALL item buttons (read list-group-item.dataset.contentId) 10285 var removeButtonEles = this.pageEle.querySelectorAll(this.collectionItemRemoveButtonSelect); 10286 removeButtonEles.forEach(function (ele) { 10287 // that scope 10288 ele.addEventListener('click', that.removeItemFromCollectionEvent.bind(that)); 10289 }); 10290 10291 // ONLY show copy if multi-collections 10292 if (tabNavLinkEles.length > 1) { 10293 // assign 'copy' events to ALL item buttons (read list-group-item.dataset.contentId) 10294 var copyButtonEles = this.pageEle.querySelectorAll(that.collectionItemCopyButtonSelect); 10295 copyButtonEles.forEach(function (ele) { 10296 // that scope 10297 ele.closest(that.collectionItemCopyDropDownSelect).classList.remove(that.hideClassName); // show dropdown (default hidden for single collections) 10298 // ele.classList.remove(that.hideClassName); 10299 ele.addEventListener('click', that.copyItemToCollectionShowEvent.bind(that)); 10300 }); 10301 } 10302 10303 // ONLY show move if multi-collections 10304 if (tabNavLinkEles.length > 1) { 10305 // assign 'move' events to ALL item buttons (read list-group-item.dataset.contentId) 10306 var moveButtonEles = this.pageEle.querySelectorAll(this.collectionItemMoveButtonSelect); 10307 moveButtonEles.forEach(function (ele) { 10308 // that scope 10309 ele.closest(that.collectionItemMoveDropDownSelect).classList.remove(that.hideClassName); // show dropdown (default hidden for single collections) 10310 // ele.classList.remove(that.hideClassName); // show move (default hidden for single collections) 10311 ele.addEventListener('click', that.moveItemToCollectionShowEvent.bind(that)); 10312 }); 10313 } 10314 } 10315 }, { 10316 key: "copyItemToCollectionShowEvent", 10317 value: function copyItemToCollectionShowEvent(e) { 10318 this.log("copyItemToCollectionShowEvent()"); 10319 10320 // Collect data from parent list-item, and dynamically build the html and init widget 10321 10322 var parentListGroupItem = e.target.closest(this.listGroupItemSelect); 10323 if (parentListGroupItem === null || parentListGroupItem.dataset.contentId === "undefined") { 10324 this.log("copyItemToCollectionShowEvent() missing listGroupItem data"); 10325 return false; 10326 } 10327 var contentId = parentListGroupItem.dataset.contentId; 10328 if (contentId === null) { 10329 this.log("copyItemToCollectionShowEvent() [error] missing contentId"); 10330 return false; 10331 } 10332 var currentCollectionKey = parentListGroupItem.dataset.collectionKey; 10333 if (currentCollectionKey === null) { 10334 this.log("copyItemToCollectionShowEvent() [error] missing currentCollectionKey"); 10335 return false; 10336 } 10337 var currentCookieKey = this.MyOncoLinkAPI.formatCookieCollectionKey(currentCollectionKey); 10338 10339 // Part 1: build from template 10340 var lookupObject = this.MyOncoLinkAPI.getCookieCollectionLookupObject(); 10341 var options = []; 10342 for (var cookieKey in lookupObject) { 10343 if (cookieKey === currentCookieKey) { 10344 this.log("copyItemToCollectionShowEvent() skip " + currentCookieKey); 10345 continue; 10346 } 10347 var label = lookupObject[cookieKey]; 10348 // only add not empty labels 10349 if (label && label.length > 0) { 10350 options.push({ 10351 'label': label, 10352 'value': cookieKey 10353 }); 10354 } 10355 } 10356 var params = { 10357 'lang': this.lang, 10358 'title': this.toastTitle, 10359 'options': options, 10360 'contentId': contentId, 10361 'collectionKey': currentCollectionKey 10362 }; 10363 // part 1: render copy form and populate with data-content-id 10364 var targetEle = parentListGroupItem.querySelector(this.collectionItemCopyTargetSelect); 10365 targetEle.innerHTML = this.CollectionItemCopyForm.renderTemplate(params); 10366 10367 // Part 2: assign events after HTML in DOM 10368 this.CollectionItemCopyForm.assignEvents(); 10369 } 10370 }, { 10371 key: "moveItemToCollectionShowEvent", 10372 value: function moveItemToCollectionShowEvent(e) { 10373 this.log("moveItemToCollectionShowEvent()"); 10374 10375 // Collect data from parent list-item, and dynamically build the html and init widget 10376 var parentListGroupItem = e.target.closest(this.listGroupItemSelect); 10377 if (parentListGroupItem === null || parentListGroupItem.dataset.contentId === "undefined") { 10378 this.log("moveItemToCollectionShowEvent() missing listGroupItem data"); 10379 return false;
10380 } 10381 var contentId = parentListGroupItem.dataset.contentId; 10382 if (contentId === null) { 10383 this.log("moveItemToCollectionShowEvent() [error] missing contentId"); 10384 return false; 10385 } 10386 var currentCollectionKey = parentListGroupItem.dataset.collectionKey; 10387 if (currentCollectionKey === null) { 10388 this.log("moveItemToCollectionShowEvent() [error] missing currentCollectionKey"); 10389 return false; 10390 } 10391 var currentCookieKey = this.MyOncoLinkAPI.formatCookieCollectionKey(currentCollectionKey); 10392 10393 // Part 1: build from template 10394 var lookupObject = this.MyOncoLinkAPI.getCookieCollectionLookupObject(); 10395 var options = []; 10396 for (var cookieKey in lookupObject) { 10397 if (cookieKey === currentCookieKey) { 10398 this.log("moveItemToCollectionShowEvent() skip " + currentCookieKey); 10399 continue; 10400 } 10401 var label = lookupObject[cookieKey]; 10402 // only add not empty labels 10403 if (label && label.length > 0) { 10404 options.push({ 10405 'label': label, 10406 'value': cookieKey 10407 }); 10408 } 10409 } 10410 var params = { 10411 'lang': this.lang, 10412 'title': this.toastTitle, 10413 'options': options, 10414 'contentId': contentId, 10415 'collectionKey': currentCollectionKey 10416 }; 10417 // part 1: render move form and populate with data-content-id 10418 var targetEle = parentListGroupItem.querySelector(this.collectionItemMoveTargetSelect); 10419 targetEle.innerHTML = this.CollectionItemMoveForm.renderTemplate(params); 10420 10421 // Part 2: assign events after HTML in DOM 10422 this.CollectionItemMoveForm.assignEvents(); 10423 } 10424 }, { 10425 key: "removeItemFromCollectionEvent", 10426 value: function removeItemFromCollectionEvent(e) { 10427 var that = this; 10428 // read data element from parent 10429 var parentListGroupItem = e.target.closest(this.listGroupItemSelect); 10430 if (parentListGroupItem === null || parentListGroupItem.dataset.contentId === "undefined") { 10431 this.log("removeItemFromCollectionEvent() missing listGroupItem data"); 10432 return false; 10433 } 10434 var contentId = parentListGroupItem.dataset.contentId; 10435 if (!contentId) { 10436 this.log("removeItemFromCollectionEvent() [error] missing contentId"); 10437 return false; 10438 } 10439 var collectionKey = parentListGroupItem.dataset.collectionKey; 10440 if (!collectionKey) { 10441 this.log("removeItemFromCollectionEvent() [error] missing collectionKey"); 10442 return false; 10443 } 10444 var success = this.MyOncoLinkAPI.removeContentFromCollection(contentId, collectionKey); 10445 if (success === true) { 10446 parentListGroupItem.remove(); // delete item 10447 that.log("removeItemFromCollectionEvent() removed " + contentId + " from " + collectionKey); 10448 } else { 10449 that.log("removeItemFromCollectionEvent() [error] item not removed"); 10450 } 10451 } 10452 10453 /***************/ 10454 /*** Utility ***/ 10455 }, { 10456 key: "toggleHiddenClass", 10457 value: function toggleHiddenClass(ele) { 10458 var cssClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "hidden"; 10459 if (ele) { 10460 if (ele.classList.contains('hidden')) { 10461 ele.classList.remove('hidden'); 10462 } else { 10463 ele.classList.add('hidden'); 10464 } 10465 } else { 10466 this.log("toggleHiddenClass() [error] element missing"); 10467 } 10468 return true; 10469 } 10470 }, { 10471 key: "log", 10472 value: function log(msg) { 10473 if (!msg) { 10474 return; 10475 } 10476 // ?debug=1, ?debug=(className), ?debug=(className),(className) 10477 if (console && (window.location.href.indexOf('debug=1') > 0 || window.location.href.indexOf(this.constructor.name) > 0 && window.location.href.indexOf('debug') > 0)) { 10478 if (_typeof(msg) === "object") { 10479 console.log(msg); 10480 } else { 10481 console.log(this.constructor.name + "(): " + msg); 10482 } 10483 } 10484 } 10485 }]); 10486}(); 10487var _default = exports["default"] = new MyOncoLinkCollectionPage(); 10488 10489},{"../templates/collection-item-line.hbs":61,"../templates/collection-page-layout.hbs":63,"./Translations":52,"handlebars":1}],50:[function(require,module,exports){ 10490"use strict"; 10491 10492Object.defineProperty(exports, "__esModule", { 10493 value: true 10494}); 10495exports["default"] = void 0; 10496var _handlebars = _interopRequireDefault(require("handlebars")); 10497var _collectionWidget = _interopRequireDefault(require("../templates/collection-widget.hbs")); 10498var _notifyToast = _interopRequireDefault(require("../templates/notify-toast.hbs")); 10499var _iconCollectionOn = _interopRequireDefault(require("../templates/icon-collection-on.hbs")); 10500var _iconCollectionOff = _interopRequireDefault(require("../templates/icon-collection-off.hbs")); 10501var _Translations = _interopRequireDefault(require("./Translations")); 10502function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 10503function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } 10504function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } 10505function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } 10506function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } 10507function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 10508function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } 10509function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 10510function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } 10511function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // Augment Content Pages 10512// detect <... data-comp='my-oncolink-content' ...> 10513// templates 10514_handlebars["default"].registerHelper('trans', function (value1, value2, options) { 10515 return _Translations["default"].get(value1, value2); 10516}); 10517_handlebars["default"].registerHelper('eq', function (a, b) { 10518 return a === b; 10519}); 10520var collectionWidgetTemplate = _handlebars["default"].compile(_collectionWidget["default"]); 10521var notifyToastTemplate = _handlebars["default"].compile(_notifyToast["default"]); 10522var iconCollectionOnTemplate = _handlebars["default"].compile(_iconCollectionOn["default"]); 10523var iconCollectionOffTemplate = _handlebars["default"].compile(_iconCollectionOff["default"]); 10524 10525/** 10526 * NEW: 10527 * If only 1 active collections, heart is a TOGGLE into default collection 10528 * if > 1 active collection, heart is show/hide widget 10529 */ 10530var MyOncoLinkContentPage = /*#__PURE__*/function () { 10531 function MyOncoLinkContentPage() { 10532 _classCallCheck(this, MyOncoLinkContentPage); 10533 this.appSelector = "[data-comp='myol-content-page']"; 10534 } 10535 return _createClass(MyOncoLinkContentPage, [{ 10536 key: "init", 10537 value: function init(MyOncoLinkAPI, CollectionCreateForm) { 10538 this.log("init()"); 10539 10540 // check single page app 10541 this.pageEle = document.querySelector(this.appSelector); 10542 if (this.pageEle === null) { 10543 this.log('init() [error] detecting app'); 10544 return false;
10545 } 10546 10547 // set API connection 10548 if (MyOncoLinkAPI === null) { 10549 this.log('init() [error] missing MyOncoLinkAPI'); 10550 return false; 10551 } 10552 this.MyOncoLinkAPI = MyOncoLinkAPI; // load API into this class 10553 if (this.MyOncoLinkAPI.isEnabled === false) { 10554 this.log("init() [halt] MyOncoLinkAPI.isEnabled == false"); 10555 return false; 10556 } 10557 if (CollectionCreateForm === null) { 10558 this.log('init() [error] missing CollectionCreateForm'); 10559 return false; 10560 } 10561 this.CollectionCreateForm = CollectionCreateForm; // load API into this class 10562 10563 this.hideClassName = "d-none"; // used for hide/show 10564 this.toastCloseSelect = ".btn-close"; // popup close button 10565 this.contentPageTitleEle = this.pageEle.querySelector('h1.content-title'); 10566 10567 // Parent holder widget (align with template and CSS) 10568 this.collectionWidgetTriggerSelect = ".myol-collection-widget-trigger"; // option 1: single collection; option 2: multicollection 10569 this.collectionWidgetSelect = ".myol-collection-widget"; // parent of all child widget elements 10570 10571 // collection toast 10572 this.collectionToastSelect = ".myol-collection-toast"; 10573 this.collectionAssignSubmitSelect = ".myol-collection-assign-submit"; 10574 this.collectionCreateShowSelect = ".myol-collection-create-show"; // show/hide create form (see CollectionCreateForm) 10575 this.collectionCreateTargetSelect = '.myol-collection-create-target'; // append form here 10576 this.collectionWidgetNotifyTargetSelect = ".myol-notify-target"; // parent for notify toasts creation 10577 10578 this.contentId = this.pageEle.dataset.contentId; 10579 this.log("ContentID: " + this.contentId); 10580 if (this.contentId === null) { 10581 this.log('init() [error] missing content-id'); 10582 return false; 10583 } 10584 this.collectionKey = ""; // default empty, set if found, keep track with popup dialog 10585 10586 // re-usable elements 10587 this.widgetEle = null; 10588 this.triggerIconEle = null; 10589 this.triggerNotifyEle = null; 10590 this.lang = 'en'; // default 10591 try { 10592 this.lang = document.querySelector('html').getAttribute('lang'); 10593 this.log('Language: ' + this.lang); 10594 } catch (_unused) {} 10595 this.buildUI(); 10596 } 10597 }, { 10598 key: "buildUI", 10599 value: function buildUI() { 10600 this.buildWidgetUI(); 10601 this.buildCollectionCreateUI(); 10602 } 10603 10604 /* multi collection content action 10605 * click heart, open dialog 10606 * dialog 10607 * part 1: drop down for selecting which collection to add item to 10608 * click 'Add' 10609 * save to cookie, toggle heart, render 'saved' and hide toast 10610 * click 'x' closes dialog 10611 * 10612 * part 2: detect lookup 'active' count, if < 5 show 'input' + 'create' button 10613 * on collection create, refresh selection drop down within dialog and auto select new collection (key) 10614 */ 10615 10616 // 1-time render 10617 }, { 10618 key: "buildWidgetUI", 10619 value: function buildWidgetUI() { 10620 this.log("buildWidgetUI()"); 10621 10622 // Part 1: build from template 10623 var lookupObject = this.MyOncoLinkAPI.getCookieCollectionLookupObject(); 10624 var options = []; 10625 for (var cookieKey in lookupObject) { 10626 var label = lookupObject[cookieKey]; 10627 // only add not empty labels 10628 if (label && label.length > 0) { 10629 options.push({ 10630 'label': label, 10631 'value': cookieKey 10632 }); 10633 } 10634 } 10635 var htmlCollectionWidget = collectionWidgetTemplate({ 10636 lang: this.lang, 10637 'title': "myOncoLink", 10638 'options': options 10639 }); 10640 10641 // Part 2: APPEND to title 10642 this.contentPageTitleEle.insertAdjacentHTML('beforeend', htmlCollectionWidget); 10643 10644 // Part 3: Store Global re-usable elemnts 10645 this.widgetEle = document.querySelector(this.collectionWidgetSelect); 10646 if (this.widgetEle === null) { 10647 this.log("buildWidgetUI() [error] missing widget element"); 10648 return; 10649 } 10650 this.triggerIconEle = this.widgetEle.querySelector(this.collectionWidgetTriggerSelect); 10651 if (this.triggerIconEle === null) { 10652 this.log("buildWidgetUI() [error] missing triggerIconEle"); 10653 return false;
10654 } 10655 this.triggerNotifyEle = this.widgetEle.querySelector(this.collectionWidgetNotifyTargetSelect); 10656 if (this.triggerNotifyEle === null) { 10657 this.log("buildWidgetUI() [error] missing triggerNotifyEle"); 10658 return false; 10659 } 10660 10661 // Assign event to 'show/hide' collection create form (hidden by default) 10662 var collectionCreateShowEle = this.widgetEle.querySelector(this.collectionCreateShowSelect); 10663 if (collectionCreateShowEle) { 10664 // hide toggle if MAX collection hit 10665 if (options.length === this.MyOncoLinkAPI.cookieMaxCollections) { 10666 this.log("buildWidgetUI() max collections, hide add new button"); 10667 collectionCreateShowEle.classList.add(this.hideClassName); 10668 } 10669 // always assign event listener even if max, JIC 10670 collectionCreateShowEle.addEventListener('click', this.toggleCollectionCreateFormEvent.bind(this)); 10671 } else { 10672 this.log("buildWidgetUI() [error] Missing collection create show element"); 10673 } 10674 10675 // Assign 'close' popup event 10676 var popupCloseButtonEle = this.widgetEle.querySelector(this.toastCloseSelect); 10677 if (popupCloseButtonEle) { 10678 popupCloseButtonEle.addEventListener('click', this.widgetCloseEvent.bind(this)); 10679 } else { 10680 this.log("buildWidgetUI() [error] missing popup close element"); 10681 } 10682 10683 // Assign collection event 10684 var collectionWidgetAssignButtonEle = this.widgetEle.querySelector(this.collectionAssignSubmitSelect); 10685 if (collectionWidgetAssignButtonEle) { 10686 collectionWidgetAssignButtonEle.addEventListener('click', this.collectionAssignSubmitEvent.bind(this)); 10687 } else { 10688 this.log("buildWidgetUI() [error] missing collection Assign button element"); 10689 } 10690 10691 // part 5: select option settings 10692 var currentCollectionCookieKey = this.MyOncoLinkAPI.formatCookieCollectionKey(this.collectionKey); 10693 // mark select option based on currentCollection (cannot do render time) 10694 var findOption = this.widgetEle.querySelector('select option[value="' + currentCollectionCookieKey + '"]'); 10695 findOption.setAttribute('selected', 'selected'); 10696 10697 // Part 6: Build Trigger Icon (heart) 10698 // check content is in ANY collection(s) and render trigger (status) 10699 var matchCollection = this.MyOncoLinkAPI.checkContentInAnyCollection(this.contentId); 10700 if (matchCollection && matchCollection.length > 0) { 10701 // render 'item On' 10702 this.log("Content found in (any) collection"); 10703 this.collectionKey = matchCollection; // save for repeat access 10704 this.triggerIconEle.innerHTML = iconCollectionOnTemplate({ 10705 lang: this.lang 10706 }); // add 'On' state icon 10707 } else { 10708 // render 'item Off' 10709 this.log("Content not found in (any) collection"); 10710 this.triggerIconEle.innerHTML = iconCollectionOffTemplate({ 10711 lang: this.lang 10712 }); // add 'Off' state icon 10713 } 10714 10715 // magic: event uses .bind(this) from call 10716 this.triggerIconEle.addEventListener('click', this.widgetTriggerEvent.bind(this)); 10717 } 10718 }, { 10719 key: "buildCollectionCreateUI", 10720 value: function buildCollectionCreateUI() { 10721 this.log("buildCollectionCreateUI()"); 10722 this.CollectionCreateForm.init(this.MyOncoLinkAPI); // init multiple edit forms with API 10723 this.CollectionCreateForm.callBackSuccess = this.callbackCollectionCreateSubmitSuccess.bind(this); 10724 10725 // Part 1: append to target(s) 10726 var targetEles = document.querySelectorAll(this.collectionCreateTargetSelect); 10727 var _iterator = _createForOfIteratorHelper(targetEles), 10728 _step; 10729 try { 10730 for (_iterator.s(); !(_step = _iterator.n()).done;) { 10731 var targetEle = _step.value; 10732 if (!targetEle) { 10733 this.log("buildCollectionCreateUI() [error] missing collection create target element"); 10734 } 10735 targetEle.innerHTML = this.CollectionCreateForm.renderTemplate({ 10736 'lang': this.lang, 10737 'maxLength': this.MyOncoLinkAPI.maxCollectionNameLength 10738 }); 10739 } 10740 10741 // Part 2: assign events after HTML 10742 } catch (err) { 10743 _iterator.e(err); 10744 } finally { 10745 _iterator.f(); 10746 } 10747 this.CollectionCreateForm.assignEvents(); 10748 10749 // Part 3: Default hide creation form on load/build 10750 var collectionCreateFormEle = document.querySelector(this.CollectionCreateForm.collectionCreateFormSelect); 10751 collectionCreateFormEle.classList.add(this.hideClassName); 10752 } 10753 10754 // single click add/remove 10755 }, { 10756 key: "toggleCollectionItemEvent", 10757 value: function toggleCollectionItemEvent(e) { 10758 // magic: event uses .bind(this) from call 10759 this.log("toggleCollectionItemEvent()"); 10760 var collectionKey = ""; // default collection 10761 10762 // click heart, if off, render popup 10763 // click heart, if ON, remove from (current) collection 10764 10765 // TODO: currently assumes only 1 collection, will change storage and approach when multi-collections 10766 // check status of item in storage 10767 var matchCollectionKey = this.MyOncoLinkAPI.checkContentInAnyCollection(this.contentId); 10768 if (typeof matchCollectionKey === "string" && matchCollectionKey.length > 0) { 10769 var success = this.MyOncoLinkAPI.removeContentFromCollection(this.contentId, matchCollectionKey); 10770 if (success === true) { 10771 this.triggerIconEle.innerHTML = iconCollectionOffTemplate({ 10772 lang: this.lang 10773 }); // 'off' 10774 this.notifyTriggerMessage(_Translations["default"].get(this.lang, "Removed from collection"), "My OncoLink"); // TODO: translations 10775 } else { 10776 this.log("toggleCollectionItemEvent() [error] not removed"); 10777 } 10778 } else { 10779 var _success = this.MyOncoLinkAPI.addContentToCollection(this.contentId); // empty = default 10780 if (_success === true) { 10781 this.triggerIconEle.innerHTML = iconCollectionOnTemplate({ 10782 lang: this.lang 10783 }); // 'on' 10784 this.notifyTriggerMessage(_Translations["default"].get(this.lang, "Assigned to collection"), "myOncoLink"); // TODO: translations 10785 } else { 10786 this.log("toggleCollectionItemEvent() [error] not added"); 10787 } 10788 } 10789 } 10790 }, { 10791 key: "toggleCollectionCreateFormEvent", 10792 value: function toggleCollectionCreateFormEvent(e) { 10793 // magic: event uses .bind(this) from call 10794 this.log("toggleCollectionCreateFormEvent()"); 10795 var formEle = this.widgetEle.querySelector(this.CollectionCreateForm.collectionCreateFormSelect); 10796 this.toggleHiddenClass(formEle); 10797 } 10798 }, { 10799 key: "collectionAssignSubmitEvent", 10800 value: function collectionAssignSubmitEvent(e) { 10801 this.log("collectionAssignSubmitEvent()");
10802 // select in widget (not form) 10803 var selectEle = this.widgetEle.querySelector('select'); 10804 if (selectEle === null) { 10805 this.log("collectionAssignSubmitEvent() [error] missing select element"); 10806 return; 10807 } 10808 var selectedValue = selectEle.value; // currently a cookieKey (to unformat) 10809 this.log("collectionAssignSubmitEvent() option: " + selectedValue); 10810 var collectionKey = this.MyOncoLinkAPI.unformatCookieCollectionKey(selectedValue); 10811 this.log("collectionAssignSubmitEvent() collectionKey: " + collectionKey); 10812 var success = this.MyOncoLinkAPI.addContentToCollection(this.contentId, collectionKey); // empty = default 10813 if (success === true) { 10814 this.triggerIconEle.innerHTML = iconCollectionOnTemplate({ 10815 lang: this.lang 10816 }); // 'on' 10817 this.notifyTriggerMessage(_Translations["default"].get(this.lang, "Assignment success!")); // TODO: translations 10818 } else { 10819 this.log("toggleCollectionItemEvent() [error] not added"); 10820 this.notifyTriggerMessage(_Translations["default"].get(this.lang, "Error, not assigned")); // TODO: translations 10821 } 10822 } 10823 10824 /** 10825 * 10826 * @param createResult - example object {'collectionKey':"",'label':"", 'error':""} 10827 */ 10828 }, { 10829 key: "callbackCollectionCreateSubmitSuccess", 10830 value: function callbackCollectionCreateSubmitSuccess(createResult) { 10831 this.notifyTriggerMessage(_Translations["default"].get(this.lang, "Collection added")); // TODO: translations 10832 10833 // get from holder; 10834 var collectionKey = createResult.collectionKey; 10835 var label = createResult.label; 10836 // assume no errors if success 10837 10838 // NOTE: currently using cookie, so update select based on cookie key 10839 var cookieKey = this.MyOncoLinkAPI.formatCookieCollectionKey(collectionKey); 10840 var optionMatchEle = this.widgetEle.querySelector('select option[value="+ cookieKey + "]'); 10841 if (optionMatchEle === null) { 10842 this.log("collectionCreateFormEvent() [error] unable to find matching option"); 10843 10844 // look at widget for select (not in form) 10845 var selectEle = this.widgetEle.querySelector('select'); 10846 if (selectEle === null) { 10847 this.log("collectionCreateFormEvent() [error] unable to find select"); 10848 return; 10849 } 10850 this.log("collectionCreateFormEvent() failsafe append new select option"); 10851 var newOption = document.createElement('option'); 10852 newOption.setAttribute('value', cookieKey); 10853 newOption.innerHTML = label; 10854 selectEle.append(newOption); 10855 optionMatchEle = newOption; // copy for next logic 10856 } 10857 10858 // VALIDATE that the collection was actually created before resetting form 10859 if (this.MyOncoLinkAPI.isCollection(collectionKey) !== true) { 10860 this.log("collectionCreateFormEvent() [error] checking new collection check FAILED!"); 10861 // TODO: notify use with error 10862 return; 10863 } 10864 10865 // update 'selected' by removing current and setting to 'new' option 10866 var currentOptions = this.widgetEle.querySelectorAll('select option'); 10867 currentOptions.forEach(function (item) { 10868 item.removeAttribute('selected'); 10869 }); 10870 10871 // now set NEW option 10872 optionMatchEle.setAttribute('selected', 'selected'); 10873 10874 // hide the form after success 10875 var formEle = this.widgetEle.querySelector(this.CollectionCreateForm.collectionCreateFormSelect); 10876 formEle.classList.add(this.hideClassName); 10877 } 10878 }, { 10879 key: "widgetCloseEvent", 10880 value: function widgetCloseEvent(e) { 10881 // Option 2: n-collection 10882 var toastEle = this.widgetEle.querySelector(this.collectionToastSelect); 10883 this.toggleHiddenClass(toastEle); 10884 } 10885 }, { 10886 key: "widgetTriggerEvent", 10887 value: function widgetTriggerEvent(e) { 10888 // magic: event uses .bind(this) from call 10889 this.log("widgetTriggerEvent()"); 10890 var lookupObject = this.MyOncoLinkAPI.getCookieCollectionLookupObject(); 10891 var activeCollections = []; 10892 for (var cookieKey in lookupObject) { 10893 var label = lookupObject[cookieKey]; 10894 // only add not empty labels 10895 if (label && label.length > 0) { 10896 activeCollections.push({ 10897 'label': label, 10898 'value': cookieKey 10899 }); 10900 } 10901 } 10902 10903 // Option 1: 1-collection 10904 if (activeCollections.length === 1) { 10905 this.toggleCollectionItemEvent(e); 10906 return; 10907 } 10908 10909 // Option 2: n-collection 10910 var toastEle = this.widgetEle.querySelector(this.collectionToastSelect); 10911 this.toggleHiddenClass(toastEle); 10912 } 10913 }, { 10914 key: "notifyTriggerMessage", 10915 value: function notifyTriggerMessage(message) { 10916 var title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "myOncoLink"; 10917 var cssStyle = arguments.length > 2 ? arguments[2] : undefined; 10918 cssStyle = cssStyle ? cssStyle : "default"; 10919 this.triggerNotifyEle.innerHTML = notifyToastTemplate({ 10920 lang: this.lang, 10921 title: title, 10922 message: message, 10923 cssStyle: cssStyle 10924 }); 10925 var that = this; 10926 this.triggerNotifyEle.classList.add("active"); 10927 var triggerNotifyEle = this.triggerNotifyEle; // copy for closure 10928 setTimeout(function (triggerNotifyEle) { 10929 triggerNotifyEle.innerHTML = "";
10929 // DELETE entirely 10930 }, 1500, triggerNotifyEle); // notify timeout 10931 } 10932 10933 /***************/ 10934 /*** Utility ***/ 10935 }, { 10936 key: "toggleHiddenClass", 10937 value: function toggleHiddenClass(ele) { 10938 var cssClass = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "d-none"; 10939 if (ele) { 10940 if (ele.classList.contains(cssClass)) { 10941 ele.classList.remove(cssClass); 10942 } else { 10943 ele.classList.add(cssClass); 10944 } 10945 } else { 10946 this.log("toggleHiddenClass() [error] element missing"); 10947 } 10948 return true; 10949 } 10950 }, { 10951 key: "log", 10952 value: function log(msg) { 10953 // ?debug=1, ?debug=(className), ?debug=(className),(className) 10954 if (console && (window.location.href.indexOf('debug=1') > 0 || window.location.href.indexOf(this.constructor.name) > 0 && window.location.href.indexOf('debug') > 0)) { 10955 if (_typeof(msg) === "object") { 10956 console.log(msg); 10957 } else { 10958 console.log(this.constructor.name + "(): " + msg); 10959 } 10960 } 10961 } 10962 }]); 10963}(); 10964var _default = exports["default"] = new MyOncoLinkContentPage(); 10965 10966},{"../templates/collection-widget.hbs":64,"../templates/icon-collection-off.hbs":65,"../templates/icon-collection-on.hbs":66,"../templates/notify-toast.hbs":68,"./Translations":52,"handlebars":1}],51:[function(require,module,exports){ 10967"use strict"; 10968 10969Object.defineProperty(exports, "__esModule", { 10970 value: true 10971}); 10972exports["default"] = void 0; 10973var _handlebars = _interopRequireDefault(require("handlebars")); 10974var _navMyOncolink = _interopRequireDefault(require("../templates/nav-my-oncolink.hbs")); 10975function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 10976function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } 10977function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 10978function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } 10979function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 10980function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } 10981function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // templates 10982var navMyOncoLinkTemplate = _handlebars["default"].compile(_navMyOncolink["default"]); 10983var MyOncoLinkNav = /*#__PURE__*/function () { 10984 function MyOncoLinkNav() { 10985 _classCallCheck(this, MyOncoLinkNav); 10986 this.appSelector = "[data-comp='myol-nav']"; 10987 } 10988 return _createClass(MyOncoLinkNav, [{ 10989 key: "init", 10990 value: function init(MyOncoLinkAPI) { 10991 this.log("init()"); 10992 10993 // NOTE: only show if enabled! 10994 10995 // set API connection 10996 if (MyOncoLinkAPI === null) { 10997 this.log('Error missing MyOncoLinkAPI'); 10998 return false; 10999 } 11000 if (MyOncoLinkAPI.isEnabled !== true) { 11001 this.log("MyOncoLinkAPI disabled"); 11002 return false; 11003 } 11004 11005 // load API into this class 11006 this.MyOncoLinkAPI = MyOncoLinkAPI; 11007 this.pageEle = document.querySelector(this.appSelector); 11008 if (this.pageEle === null) { 11009 this.log('init() [error] detecting app'); 11010 return false;
11011 } 11012 this.lang = 'en'; // default 11013 try { 11014 this.lang = document.querySelector('html').getAttribute('lang'); 11015 this.log('Language: ' + this.lang); 11016 } catch (_unused) {} 11017 this.buildUI(); 11018 } 11019 }, { 11020 key: "buildUI", 11021 value: function buildUI() { 11022 var targetEle = document.querySelector(this.appSelector); 11023 targetEle.innerHTML = navMyOncoLinkTemplate({}); 11024 } 11025 11026 /***************/ 11027 /*** Utility ***/ 11028 }, { 11029 key: "log", 11030 value: function log(msg) { 11031 // ?debug=1, ?debug=(className), ?debug=(className),(className) 11032 if (console && (window.location.href.indexOf('debug=1') > 0 || window.location.href.indexOf(this.constructor.name) > 0 && window.location.href.indexOf('debug') > 0)) { 11033 if (_typeof(msg) === "object") { 11034 console.log(msg); 11035 } else { 11036 console.log(this.constructor.name + "(): " + msg); 11037 } 11038 } 11039 } 11040 }]); 11041}(); 11042var _default = exports["default"] = new MyOncoLinkNav(); 11043 11044},{"../templates/nav-my-oncolink.hbs":67,"handlebars":1}],52:[function(require,module,exports){ 11045"use strict"; 11046 11047Object.defineProperty(exports, "__esModule", { 11048 value: true 11049}); 11050exports["default"] = void 0; 11051function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } 11052function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 11053function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } 11054function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 11055function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } 11056function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } 11057var Translations = /*#__PURE__*/function () { 11058 function Translations() { 11059 _classCallCheck(this, Translations); 11060 this.defaultLang = 'en'; 11061 this.lookup = { 11062 'en': { 11063 'Articles': 'Articles', 11064 'Assign to myOncoLink collection': 'Assign to myOncoLink collection', 11065 'Assign': 'Assign', 11066 'Assigned to collection': 'Assigned to collection', 11067 'Assignment success!': 'Assignment success!', 11068 'Close': 'Close', 11069 'Collection name': 'Collection name', 11070 'Collection added': 'Collection added', 11071 'Collection is empty': 'Collection is empty', 11072 'Collection was not found': 'Collection was not found', 11073 'Collection': 'Collection', 11074 'Confirm': 'Confirm', 11075 'Copy to another collection': 'Copy to another collection', 11076 'Copy': 'Copy', 11077 'Create': 'Create', 11078 'Delete': 'Delete', 11079 'Empty collection': 'Empty collection', 11080 'Error, not assigned': 'Error, not assigned', 11081 'In Collection': 'In Collection', 11082 'Loading': 'Loading', 11083 'Medications': 'Medications', 11084 'Move to another collection': 'Move to another collection', 11085 'Move': 'Move', 11086 'New': 'New', 11087 'Remove collection!': 'Remove collection!', 11088 'Remove item from collection': 'Remove item from collection', 11089 'Remove': 'Remove', 11090 'Removed from collection': 'Removed from collection', 11091 'Rename': 'Rename', 11092 'Success!': 'Success!', 11093 'Type collection name': 'Type collection name' 11094 }, 11095 'es': { 11096 'Articles': 'Articulos',
11097 'Assign to myOncoLink collection': 'Asignar a mi colección de myOncoLink', 11098 'Assign': 'Asignar', 11099 'Assigned to collection': 'Asignado a la colección', 11100 'Assignment success!': '¡Asignación exitosa!', 11101 'Close': 'Cerrar', 11102 'Collection name': 'Nombre de la colección', 11103 'Collection added': 'Colección añadida', 11104 'Collection is empty': 'La colección está vacÃa', 11105 'Collection was not found': 'No se encontró la colección', 11106 'Collection': 'Colección', 11107 'Confirm': 'Confirmar', 11108 'Copy to another collection': 'Copiar a otra colección', 11109 'Copy': 'Copiar', 11110 'Create': 'Crear', 11111 'Delete': 'Eliminar', 11112 'Empty collection': 'La colección está vacÃa', 11113 'Error, not assigned': 'Error, no asignado', 11114 'In Collection': 'En la colección', 11115 'Loading': 'Cargando', 11116 'Medications': 'Medicamentos', 11117 'Move to another collection': 'Mover a otra colección', 11118 'Move': 'Mover', 11119 'New': 'Nuevo', 11120 'Not in collection': 'No está en la colección', 11121 'Remove collection!': '¡Eliminar la colección!', 11122 'Remove item from collection': 'Eliminar articulo de la colección', 11123 'Remove': 'Eliminar', 11124 'Removed from collection': 'Eliminado de la colección', 11125 'Rename': 'Renombrar', 11126 'Success!': '¡Ãxito!', 11127 'Type collection name': 'Escriba el nombre de la colección' 11128 } 11129 }; 11130 } 11131 return _createClass(Translations, [{ 11132 key: "get", 11133 value: function get(lang, key) { 11134 var defaultLookup = this.lookup[this.defaultLang]; 11135 if (lang !== this.defaultLang) { 11136 if (this.lookup.hasOwnProperty(lang)) { 11137 var langLookup = this.lookup[lang]; 11138 if (langLookup.hasOwnProperty(key)) { 11139 this.log("Match [" + lang + "] " + key); 11140 return langLookup[key]; 11141 } 11142 } 11143 } 11144 // fallback to 'en' 11145 if (defaultLookup.hasOwnProperty(key)) { 11146 this.log("Default lang: " + key); 11147 return defaultLookup[key]; 11148 } 11149 this.log("Default [" + this.defaultLang + "] " + key); 11150 return key; 11151 } 11152 11153 /***************/ 11154 /*** Utility ***/ 11155 }, { 11156 key: "log", 11157 value: function log(msg) { 11158 // ?debug=1, ?debug=(className), ?debug=(className),(className) 11159 if (console && (window.location.href.indexOf('debug=1') > 0 || window.location.href.indexOf(this.constructor.name) > 0 && window.location.href.indexOf('debug') > 0)) { 11160 if (_typeof(msg) === "object") { 11161 console.log(msg); 11162 } else { 11163 console.log(this.constructor.name + "(): " + msg); 11164 } 11165 } 11166 } 11167 }]); 11168}(); 11169var _default = exports["default"] = new Translations(); 11170 11171},{}],53:[function(require,module,exports){ 11172"use strict"; 11173 11174Object.defineProperty(exports, "__esModule", { 11175 value: true 11176}); 11177exports.isInPage = void 0; 11178// Helpers 11179var isInPage = exports.isInPage = function isInPage(node) { 11180 return document.body.contains(node); 11181}; 11182 11183},{}],54:[function(require,module,exports){ 11184"use strict"; 11185 11186var _functions = require("./functions"); 11187var _MyOncoLinkNav = _interopRequireDefault(require("./MyOncoLinkNav")); 11188var _MyOncoLinkAPI = _interopRequireDefault(require("./MyOncoLinkAPI")); 11189var _MyOncoLinkContentPage = _interopRequireDefault(require("./MyOncoLinkContentPage")); 11190var _MyOncoLinkCollectionPage = _interopRequireDefault(require("./MyOncoLinkCollectionPage")); 11191var _CollectionCreateForm = _interopRequireDefault(require("./CollectionCreateForm")); 11192var _CollectionEditForm = _interopRequireDefault(require("./CollectionEditForm")); 11193var _CollectionDeleteForm = _interopRequireDefault(require("./CollectionDeleteForm")); 11194var _CollectionItemCopyForm = _interopRequireDefault(require("./CollectionItemCopyForm")); 11195var _CollectionItemMoveForm = _interopRequireDefault(require("./CollectionItemMoveForm")); 11196var _MyOncoLinkAPICookieTests = _interopRequireDefault(require("./tests/MyOncoLinkAPICookieTests")); 11197var _MyOncoLinkAPIInterfaceTests = _interopRequireDefault(require("./tests/MyOncoLinkAPIInterfaceTests")); 11198function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 11199// Functions 11200 11201// TESTS 11202 11203_MyOncoLinkAPI["default"].init(); 11204if ((0, _functions.isInPage)(document.querySelector(_MyOncoLinkNav["default"].appSelector))) { 11205 // pass in API 11206 _MyOncoLinkNav["default"].init(_MyOncoLinkAPI["default"]); 11207} 11208if ((0, _functions.isInPage)(document.querySelector(_MyOncoLinkContentPage["default"].appSelector))) { 11209 // pass in API 11210 _MyOncoLinkContentPage["default"].init(_MyOncoLinkAPI["default"], _CollectionCreateForm["default"]); 11211} 11212if ((0, _functions.isInPage)(document.querySelector(_MyOncoLinkCollectionPage["default"].appSelector))) { 11213 // pass in API 11214 // pass in Collection Create (only init after page rendered) 11215 // pass in Collection Edit (only init after page rendered) 11216 _MyOncoLinkCollectionPage["default"].init(_MyOncoLinkAPI["default"], _CollectionCreateForm["default"], _CollectionEditForm["default"], _CollectionDeleteForm["default"], _CollectionItemCopyForm["default"], _CollectionItemMoveForm["default"]); 11217} 11218 11219// check for test requests 11220if (console && window.location.href.indexOf('test=1') > 0) { 11221 _MyOncoLinkAPICookieTests["default"].init(_MyOncoLinkAPI["default"]); 11222 _MyOncoLinkAPICookieTests["default"].run(); 11223 _MyOncoLinkAPIInterfaceTests["default"].init(_MyOncoLinkAPI["default"]); 11224 _MyOncoLinkAPIInterfaceTests["default"].run(); 11225} 11226 11227},{"./CollectionCreateForm":43,"./CollectionDeleteForm":44,"./CollectionEditForm":45,"./CollectionItemCopyForm":46,"./CollectionItemMoveForm":47,"./MyOncoLinkAPI":48,"./MyOncoLinkCollectionPage":49,"./MyOncoLinkContentPage":50,"./MyOncoLinkNav":51,"./functions":53,"./tests/MyOncoLinkAPICookieTests":55,"./tests/MyOncoLinkAPIInterfaceTests":56}],55:[function(require,module,exports){ 11228"use strict"; 11229 11230Object.defineProperty(exports, "__esModule", { 11231 value: true 11232}); 11233exports["default"] = void 0; 11234var _jsCookie = _interopRequireDefault(require("js-cookie")); 11235function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } 11236function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } 11237function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 11238function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } 11239function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 11240function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } 11241function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // https://www.npmjs.com/package/js-cookie 11242var MyOncoLinkAPICookieTests = /*#__PURE__*/function () { 11243 function MyOncoLinkAPICookieTests() { 11244 _classCallCheck(this, MyOncoLinkAPICookieTests); 11245 } 11246 return _createClass(MyOncoLinkAPICookieTests, [{ 11247 key: "init", 11248 value: function init(MyOncoLinkAPI) { 11249 this.log("init()"); 11250 11251 // set API connection 11252 if (MyOncoLinkAPI === null) { 11253 this.log('init() [error] missing MyOncoLinkAPI'); 11254 return false;
11255 } 11256 if (MyOncoLinkAPI.isEnabled !== true) { 11257 this.log("init() MyOncoLinkAPI disabled"); 11258 return false; 11259 } 11260 11261 // load API into this class 11262 this.MyOncoLinkAPI = MyOncoLinkAPI; 11263 this.collectionKeyTest = 'test'; // test collection key 11264 } 11265 11266 /**************************/ 11267 /*** Cookie Item Tests ***/ 11268 }, { 11269 key: "run", 11270 value: function run() { 11271 this.log("runCookieTests()"); 11272 this.testCookieClear(); 11273 //this.testCookieAddContentToCollection(); 11274 this.testCookieRemoveContentFromCollection(); 11275 this.testCookieRenameCollectionLookup(); 11276 } 11277 }, { 11278 key: "testCookieClear", 11279 value: function testCookieClear() { 11280 var cookietestContentId = this.MyOncoLinkAPI.formatCookieCollectionKey(this.collectionKeyTest); 11281 // Clear test cookie 11282 _jsCookie["default"].set(cookietestContentId, '', { 11283 expires: this.cookieExpireDays 11284 }); 11285 } 11286 }, { 11287 key: "testCookieAddContentToCollection", 11288 value: function testCookieAddContentToCollection() { 11289 var testContentId4 = "4444"; 11290 // TODO: check for async/await 11291 this.MyOncoLinkAPI.addCookieContentToCollection(testContentId4, this.collectionKeyTest); 11292 if (this.MyOncoLinkAPI.checkCookieContentInCollection(testContentId4, this.collectionKeyTest) === true) { 11293 this.log('testCookieAddContentToCollection() ' + testContentId4 + ' [Success] collection item added'); 11294 } else { 11295 this.log('testCookieAddContentToCollection() ' + testContentId4 + ' [ERROR] collection item not added'); 11296 } 11297 } 11298 }, { 11299 key: "testCookieRemoveContentFromCollection", 11300 value: function testCookieRemoveContentFromCollection() { 11301 var testContentId9 = "9999"; 11302 // TODO: check for async/await 11303 this.MyOncoLinkAPI.addCookieContentToCollection(testContentId9, this.collectionKeyTest); 11304 this.MyOncoLinkAPI.removeCookieContentFromCollection(testContentId9, this.collectionKeyTest); 11305 if (this.MyOncoLinkAPI.checkCookieContentInCollection(testContentId9, this.collectionKeyTest) === false) { 11306 this.log('testCookieRemoveContentFromCollection() ' + testContentId9 + ' [Success] collection item removed'); 11307 } else { 11308 this.log('testCookieRemoveContentFromCollection() ' + testContentId9 + ' [ERROR] collection item not removed'); 11309 } 11310 } 11311 }, { 11312 key: "testCookieRenameCollectionLookup", 11313 value: function testCookieRenameCollectionLookup() { 11314 var testCollectionKey = "2"; 11315 this.MyOncoLinkAPI.renameCookieCollectionLookup(testCollectionKey, "Test Collection 2"); 11316 this.MyOncoLinkAPI.renameCookieCollectionLookup(testCollectionKey, "Test Collection 2.1"); 11317 } 11318 }, { 11319 key: "textIsCookieCollection", 11320 value: function textIsCookieCollection() { 11321 var testCollectionKey = "2"; 11322 if (this.MyOncoLinkAPI.isCookieCollection(testCollectionKey) !== true) { 11323 this.log("textIsCookieCollection() [error] should have found collectionKey " + testCollectionKey); 11324 } 11325 } 11326 }, { 11327 key: "log", 11328 value: function log(msg) { 11329 if (console && window.location.href.indexOf('debug') > 0 && (window.location.href.indexOf(this.constructor.name) > 0 || window.location.href.indexOf('debug=1') > 0)) { 11330 if (_typeof(msg) === "object") { 11331 console.log(msg); 11332 } else { 11333 console.log(this.constructor.name + "(): " + msg); 11334 } 11335 } 11336 } 11337 }]); 11338}(); 11339var _default = exports["default"] = new MyOncoLinkAPICookieTests(); 11340 11341},{"js-cookie":42}],56:[function(require,module,exports){ 11342"use strict"; 11343 11344Object.defineProperty(exports, "__esModule", { 11345 value: true 11346}); 11347exports["default"] = void 0; 11348function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } 11349function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 11350function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } 11351function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } 11352function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } 11353function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } 11354/** 11355 * API Interface tests (storage agnostic) 11356 */ 11357var MyOncoLinkAPIInterfaceTests = /*#__PURE__*/function () { 11358 function MyOncoLinkAPIInterfaceTests() { 11359 _classCallCheck(this, MyOncoLinkAPIInterfaceTests); 11360 } 11361 return _createClass(MyOncoLinkAPIInterfaceTests, [{ 11362 key: "init", 11363 value: function init(MyOncoLinkAPI) { 11364 this.log("init()"); 11365 11366 // set API connection 11367 if (MyOncoLinkAPI === null) { 11368 this.log('init() [error] missing MyOncoLinkAPI'); 11369 return false;
11370 } 11371 if (MyOncoLinkAPI.isEnabled !== true) { 11372 this.log("init() MyOncoLinkAPI disabled"); 11373 return false; 11374 } 11375 11376 // load API into this class 11377 this.MyOncoLinkAPI = MyOncoLinkAPI; 11378 this.collectionKeyTest = 'test'; // test collection key 11379 } 11380 11381 /************************/ 11382 /*** Interface Tests ***/ 11383 }, { 11384 key: "run", 11385 value: function run() { 11386 this.log("runInterfaceTests()"); 11387 this.testAddContentToCollection(); 11388 this.testRemoveContentFromCollection(); 11389 } 11390 }, { 11391 key: "testAddContentToCollection", 11392 value: function testAddContentToCollection() { 11393 var testContentId1 = "1111"; 11394 // TODO: check for async/await 11395 this.MyOncoLinkAPI.addContentToCollection(testContentId1, this.collectionKeyTest); 11396 if (this.MyOncoLinkAPI.checkCookieContentInCollection(testContentId1, this.collectionKeyTest) === true) { 11397 this.log("testAddContentToCollection() [Success] collection item added"); 11398 } else { 11399 this.log("testAddContentToCollection() [ERROR] collection item not added"); 11400 } 11401 } 11402 }, { 11403 key: "testRemoveContentFromCollection", 11404 value: function testRemoveContentFromCollection() { 11405 var testContentId8 = "8888"; 11406 // TODO: check for async/await 11407 this.MyOncoLinkAPI.addContentToCollection(testContentId8, this.collectionKeyTest); 11408 this.MyOncoLinkAPI.removeContentFromCollection(testContentId8, this.collectionKeyTest); 11409 if (this.MyOncoLinkAPI.checkCookieContentInCollection(testContentId8, this.collectionKeyTest) === false) { 11410 this.log("testRemoveContentFromCollection() [Success] collection item removed"); 11411 } else { 11412 this.log("testRemoveContentFromCollection() [ERROR] collection item not removed"); 11413 } 11414 } 11415 11416 // TODO: more interface tests 11417 }, { 11418 key: "log", 11419 value: function log(msg) { 11420 if (console && window.location.href.indexOf('debug') > 0 && (window.location.href.indexOf(this.constructor.name) > 0 || window.location.href.indexOf('debug=1') > 0)) { 11421 if (_typeof(msg) === "object") { 11422 console.log(msg); 11423 } else { 11424 console.log(this.constructor.name + "(): " + msg); 11425 } 11426 } 11427 } 11428 }]); 11429}(); 11430var _default = exports["default"] = new MyOncoLinkAPIInterfaceTests(); 11431 11432},{}],57:[function(require,module,exports){ 11433module.exports = "<div class=\"myol-collection-create-form row g-3\" data-comp=\"myol-collection-create-form\">\n <div class=\"col-auto\">\n <div class=\"input-group\">\n <label class=\"input-group-text\" for=\"myol-collection-create-input\">{{trans lang 'Collection name'}}</label>\n <input type=\"text\" id=\"myol-collection-create-input\" name=\"myol-collection-create-input\" class=\"myol-collection-create-input form-control\" size=\"{{maxLength}}\" maxlength=\"{{maxLength}}\">\n <button type=\"button\" class=\"myol-collection-create-submit btn btn-outline-primary\" title=\"Create new collection\">{{trans lang 'Create'}}</button>\n </div>\n </div>\n <div class=\"col-auto\">\n <span class=\"myol-collection-create-message\"><!-- target --></span>\n </div>\n</div>"; 11434 11435},{}],58:[function(require,module,exports){ 11436module.exports = "<div class=\"myol-collection-delete-form row g-3\" data-comp=\"myol-collection-delete-form\" data-collection-key=\"{{collectionKey}}\">\n <div class=\"col-auto\">\n <div class=\"input-group\">\n<!-- <label class=\"input-group-text visually-hidden\" for=\"{{collectionKey}}-myol-collection-delete-input\">{{trans lang 'Confirm'}}</label>-->\n <input type=\"text\" id=\"{{collectionKey}}-myol-collection-delete-input\" name=\"myol-collection-delete-input\" class=\"myol-collection-delete-input form-control\" size=\"{{maxLength}}\" maxlength=\"{{maxLength}}\" value=\"\" title=\"Confirm Collection Name\" placeholder=\"{{trans lang 'Collection name'}}\">\n <button type=\"button\" class=\"myol-collection-delete-submit btn btn-outline-danger\">{{trans lang 'Remove collection!'}}</button>\n </div>\n </div>\n <div class=\"col-auto\">
11436\n <span class=\"myol-collection-delete-message\"><!-- target --></span>\n </div>\n</div>"; 11437 11438},{}],59:[function(require,module,exports){ 11439module.exports = "<div class=\"myol-collection-edit-form row g-3\" data-comp=\"myol-collection-edit-form\" data-collection-key=\"{{collectionKey}}\">\n <div class=\"col-auto\">\n <div class=\"input-group\">\n <label class=\"input-group-text\" for=\"{{collectionKey}}-myol-collection-edit-name\">{{trans lang 'Collection name'}}</label>\n <input type=\"text\" id=\"{{collectionKey}}-myol-collection-edit-name\" name=\"myol-collection-edit-name\" class=\"myol-collection-edit-name form-control\" size=\"{{maxLength}}\" maxlength=\"{{maxLength}}\" value=\"{{label}}\">\n <button type=\"button\" class=\"myol-collection-edit-submit btn btn-outline-primary\" title=\"Rename current collection\">{{trans lang 'Rename'}}</button>\n </div>\n </div>\n <div class=\"col-auto\">\n <span class=\"myol-collection-edit-message\"><!-- target --></span>\n </div>\n</div>"; 11440 11441},{}],60:[function(require,module,exports){ 11442module.exports = "<div class=\"myol-collection-item-copy\" data-comp=\"myol-collection-item-copy\">\n <div class=\"myol-collection-item-copy-form\" data-content-id=\"{{contentId}}\" data-collection-key=\"{{collectionKey}}\">\n <div class=\"mb-2 text-secondary small fw-semibold\">\n {{title}}\n </div>\n <div class=\"d-flex gap-2\" data-content-id=\"{{contentId}}\" data-collection-key=\"{{collectionKey}}\">\n <select name=\"myol-collection-item-copy-input\" class=\"myol-collection-item-copy-input form-select form-select-sm\">\n {{#each options}}\n <option value=\"{{value}}\">{{label}}</option>\n {{/each}}\n <!-- target for <options> -->\n </select>\n <button name=\"myol-collection-item-copy-submit\" class=\"myol-collection-item-copy-submit btn btn-dark btn-sm px-3\">{{trans lang 'Copy'}}</button>\n </div>\n <div class=\"mt-2 small text-muted\">\n <div class=\"myol-collection-item-copy-message\"><!-- messages target --></div>\n </div>\n </div>\n</div>\n\n"; 11443 11444},{}],61:[function(require,module,exports){ 11445module.exports = "<div class=\"list-group-item p-2 row d-flex\" data-title=\"{{ item.title }}\" data-collection-key=\"{{collectionKey}}\" data-content-id=\"{{item.contentId}}\" data-content-type=\"{{item.contentType}}\">\n <div class=\"col-sm-12 col-md-6 col-lg-8 mt-2\">\n <span class=\"myol-icon pe-2\">\n {{#if (eq item.contentType 'drug') }}\n <i class=\"bi bi-prescription\"></i>\n {{else}}\n <i class=\"bi bi-file-text\"></i>\n {{/if}}\n </span>\n <span class=\"attr-title\"><a href=\"{{ item.url }}\" target=\"_blank\" class=\"link-underline-light\">{{ item.title }}</a></span>\n </div>\n <div class=\"col-sm-12 col-md-6 col-lg-4 text-end mt-2 mb-2\">\n\n <div class=\"d-flex gap-2 justify-content-end\">\n <div class=\"myol-collection-item-copy-dropdown visually-hidden\">\n <!-- copy btn -->\n <div class=\"dropdown\">\n <!-- Trigger -->\n <button class=\"myol-collection-item-copy-toggle btn btn-outline-secondary dropdown-toggle\" title=\"{{ trans lang 'Copy to another collection' }}\" type=\"button\" data-bs-toggle=\"dropdown\" data-bs-auto-close=\"outside\" aria-expanded=\"false\">\n <i class=\"bi bi-copy\"> </i> {{ trans lang 'Copy' }}\n </button>\n <div class=\"dropdown-menu p-3 shadow-sm rounded-3\" style=\"min-width: 260px;\">\n <span class=\"myol-collection-item-copy-target\"><!-- toast here --></span>\n </div>\n </div>\n </div>\n\n <div class=\"myol-collection-item-move-dropdown visually-hidden\">\n <!-- move btn -->\n <div class=\"dropdown\">\n <!-- Trigger -->\n <button class=\"myol-collection-item-move-toggle btn btn-outline-secondary dropdown-toggle\" title=\"{{ trans lang 'Move to another collection' }}\" type=\"button\" data-bs-toggle=\"dropdown\" data-bs-auto-close
11445=\"outside\" aria-expanded=\"false\">\n <i class=\"bi bi-arrow-right-square\"> </i> {{ trans lang 'Move' }}\n </button>\n <div class=\"dropdown-menu p-3 shadow-sm rounded-3\" style=\"min-width: 260px;\">\n <span class=\"myol-collection-item-move-target\"><!-- toast here --></span>\n </div>\n </div>\n </div>\n\n <button class=\"myol-collection-item-remove btn btn-outline-danger\" title=\"{{ trans lang 'Remove item from collection' }}\"><i class=\" bi bi-trash3\"> </i> {{ trans lang 'Remove' }}</button>\n\n </div>\n </div> \n</div>"; 11446 11447},{}],62:[function(require,module,exports){ 11448module.exports = "<div class=\"myol-collection-item-move\" data-comp=\"myol-collection-item-move\">\n <div class=\"myol-collection-item-move-form\" data-content-id=\"{{contentId}}\" data-collection-key=\"{{collectionKey}}\">\n <div class=\"mb-2 text-secondary small fw-semibold\">\n {{title}}\n </div>\n <div class=\"d-flex gap-2\" data-content-id=\"{{contentId}}\" data-collection-key=\"{{collectionKey}}\">\n <label for=\"myol-collection-item-move-input\" class=\"visually-hidden\">{{trans lang 'Collection'}}</label>\n <select name=\"myol-collection-item-move-input\" class=\"myol-collection-item-move-input form-select form-select-sm\">\n {{#each options}}\n <option value=\"{{value}}\">{{label}}</option>\n {{/each}}\n <!-- target for <options> -->\n </select>\n <button name=\"myol-collection-item-move-submit\" class=\"myol-collection-item-move-submit btn btn-dark btn-sm px-3\">{{trans lang 'Move'}}</button>\n </div>\n <div class=\"mt-2 small text-muted\">\n <div class=\"myol-collection-item-move-message\"><!-- messages target --></div>\n </div>\n </div>\n</div>\n"; 11449 11450},{}],63:[function(require,module,exports){ 11451module.exports = "<div id=\"myol-collection-layout\">\n\n <div class=\"d-flex\">\n <span class=\"myol-collection-create-target ms-auto\"><!--target --></span>\n </div>\n\n <div class=\"row pb-3\">\n <div class=\"col-sm-12 col-lg-12\">\n <nav>\n <div class=\"nav nav-tabs fs-6\" id=\"nav-tab\" role=\"tablist\">\n <!-- TODO: dynamic tab navs -->\n {{#each navLinks}}\n <button class=\"nav-link {{#if active}}active{{/if}}\" id=\"nav-link-{{collectionKey}}\" data-bs-toggle=\"tab\" data-bs-target=\"#tab-pane-{{collectionKey}}\" type=\"button\" role=\"tab\" aria-controls=\"nav-pane-{{collectionKey}}\" aria-selected=\"{{active}}\" data-collection-key=\"{{collectionKey}}\">{{label}}</button>\n {{/each}}\n </div>\n </nav>\n </div>\n </div>\n\n <div class=\"spinner-border visually-hidden\" role=\"status\" id=\"myol-ajax-spinner\"><span class=\"visually-hidden\">{{ trans lang 'Loading' }}...</span></div>\n\n <div class=\"visually-hidden pt-3 pb-2 container\" id=\"myol-collection-page-message\"><!-- target global messages --></div>\n\n <div class=\"tab-content container pt-2\" id=\"nav-tab-content\">\n {{#each navLinks}}\n <div class=\"tab-pane fade show {{#if this.active}}active{{/if}}\" id=\"tab-pane-{{collectionKey}}\" role=\"tabpanel\" aria-labelledby=\"nav-link-{{collectionKey}}\" data-collection-name=\"{{label}}\" data-collection-key=\"{{collectionKey}}\">\n\n <div class=\"myol-collection-articles row g-2 pb-4 visually-hidden\">\n <div class=\"col-lg-12\">\n <div class=\"list-header\"><h4>{{ trans lang 'Articles' }}</h4></div>\n <div class=\"list-group \"> <!-- target --> </div>\n </div>\n </div>\n\n <div class=\"myol-collection-drugs row g-2 pb-4 visually-hidden\">\n <div class=\"col-lg-12\">\n <div class=\"list-header\"><h4>{{ trans lang 'Medications' }}</h4></div>\n <div class=\"list-group\"> <!-- target --> </div>\n </div>\n </div>\n\n <div class=\"mt-5 row\">\n <div class=\"col-sm-12 col-lg-6 d-flex\">
11451\n <span class=\"myol-collection-edit-target ms-auto me-auto\"><!-- target --></span>\n </div>\n <div class=\"col sm-12 col-lg-6 d-flex\">\n <span class=\"myol-collection-delete-target ms-auto me-auto\"><!-- target --></span>\n </div>\n </div>\n\n </div>\n {{/each}}\n </div>\n\n\n\n</div>"; 11452 11453},{}],64:[function(require,module,exports){ 11454module.exports = "<div class=\"myol-collection-widget\">\n\n <span class=\"myol-icon myol-collection-widget-trigger\"><!-- heart target --></span>\n\n <div class=\"toast-list\">\n\n <!-- hidden until 'show' click -->\n <div class=\"card myol-toast myol-collection-toast d-none\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\">\n\n <div class=\"card-header d-flex justify-content-between align-items-center\">\n <strong class=\"me-auto\">{{title}}</strong>\n <button type=\"button\" class=\"btn-close\" aria-label=\"{{ trans lang 'Close' }}\"></button>\n </div>\n\n <div class=\"card-body\">\n\n <!-- Part 1: collection assign form -->\n <div class=\"myol-collection-assign-form mb-2\">\n <label aria-label=\"Choose which collection to assign this content\">\n <select name=\"myol-collection-assign\" class=\"myol-collection-assign-input form-select\">\n {{#each options}}\n <option value=\"{{value}}\">{{label}}</option>\n {{/each}}\n <!-- target for <options> -->\n </select>\n </label>\n <button name=\"myol-collection-assign-submit\" class=\"btn btn-primary btn-sm myol-collection-assign-submit\">{{ trans lang 'Assign' }}</button>\n <div class=\"myol-collection-assign-message hidden\"><!-- messages target --></div>\n </div>\n\n <!-- Part 2: toggle create (sub) form show/hide--->\n <div class=\"mb-2\">\n <button class=\"px-0 btn btn-link myol-collection-create-show d-flex justify-content-start align-items-center gap-1\">\n {{ trans lang 'New' }} \n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" class=\"feather feather-chevron-down\">\n <polyline points=\"6 9 12 15 18 9\"></polyline>\n </svg>\n </button>\n </div>\n\n <!-- Part 3: collection create form -->\n <span class=\"myol-collection-create-target\"><!-- target --></span>\n\n </div>\n\n </div>\n\n <!-- create (n) notification toasts holder -->\n <div class=\"myol-notify-target\"><!-- target for notify creation --></div>\n </div> <!-- #toast-list -->\n</div>\n"; 11455 11456},{}],65:[function(require,module,exports){ 11457module.exports = "<i class=\"myol-item-off fa-regular fa-heart\" title=\"{{ trans lang 'Assign to myOncoLink collection' }}\"></i>"; 11458 11459},{}],66:[function(require,module,exports){ 11460module.exports = "<i class=\"myol-item-on fa-solid fa-heart\" title=\"{{ trans lang 'In Collection' }}\"></i>"; 11461 11462},{}],67:[function(require,module,exports){ 11463module.exports = "<div class=\"myol-nav-link\"><i class=\"myol-icon fa-solid fa-heart\"></i><a href=\"/my-oncolink\">myOncoLink</a></div>"; 11464 11465},{}],68:[function(require,module,exports){ 11466module.exports = "<div class=\"card {{cssStyle}} myol-toast myol-notify-toast\" role=\"alert\" aria-live=\"assertive\" aria-atomic=\"true\">\n <div class=\"card-header d-flex justify-content-between align-items-center\">\n <strong class=\"me-auto\">{{title}}</strong>\n <button type=\"button\" class=\"btn-close\" aria-label=\"{{ trans lang 'Close' }}\"></button>\n </div>\n <div class=\"card-body\">\n {{message}}\n </div>\n</div>\n"; 11467 11468},{}]},{},[54]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.