1 (function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (function(modules) { // webpackBootstrap
2 /******/ // The module cache
3 /******/ var installedModules = {};
5 /******/ // The require function
6 /******/ function __webpack_require__(moduleId) {
8 /******/ // Check if module is in cache
9 /******/ if(installedModules[moduleId]) {
10 /******/ return installedModules[moduleId].exports;
12 /******/ // Create a new module (and put it into the cache)
13 /******/ var module = installedModules[moduleId] = {
19 /******/ // Execute the module function
20 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22 /******/ // Flag the module as loaded
23 /******/ module.l = true;
25 /******/ // Return the exports of the module
26 /******/ return module.exports;
30 /******/ // expose the modules object (__webpack_modules__)
31 /******/ __webpack_require__.m = modules;
33 /******/ // expose the module cache
34 /******/ __webpack_require__.c = installedModules;
36 /******/ // define getter function for harmony exports
37 /******/ __webpack_require__.d = function(exports, name, getter) {
38 /******/ if(!__webpack_require__.o(exports, name)) {
39 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
43 /******/ // define __esModule on exports
44 /******/ __webpack_require__.r = function(exports) {
45 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
46 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
48 /******/ Object.defineProperty(exports, '__esModule', { value: true });
51 /******/ // create a fake namespace object
52 /******/ // mode & 1: value is a module id, require it
53 /******/ // mode & 2: merge all properties of value into the ns
54 /******/ // mode & 4: return value when already ns object
55 /******/ // mode & 8|1: behave like require
56 /******/ __webpack_require__.t = function(value, mode) {
57 /******/ if(mode & 1) value = __webpack_require__(value);
58 /******/ if(mode & 8) return value;
59 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
60 /******/ var ns = Object.create(null);
61 /******/ __webpack_require__.r(ns);
62 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
63 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
67 /******/ // getDefaultExport function for compatibility with non-harmony modules
68 /******/ __webpack_require__.n = function(module) {
69 /******/ var getter = module && module.__esModule ?
70 /******/ function getDefault() { return module['default']; } :
71 /******/ function getModuleExports() { return module; };
72 /******/ __webpack_require__.d(getter, 'a', getter);
73 /******/ return getter;
76 /******/ // Object.prototype.hasOwnProperty.call
77 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
79 /******/ // __webpack_public_path__
80 /******/ __webpack_require__.p = "";
83 /******/ // Load entry module and return exports
84 /******/ return __webpack_require__(__webpack_require__.s = 0);
86 /************************************************************************/
89 /***/ (function(module, exports, __webpack_require__) {
93 Object.defineProperty(exports, "__esModule", { value: true });
94 exports.activate = void 0;
95 const coc_nvim_1 = __webpack_require__(1);
96 const engine_1 = __webpack_require__(2);
97 const documentSelector = [
103 language: 'markdown',
107 let documentVersion = 0;
108 const engine = new engine_1.MarkdownlintEngine();
109 const config = coc_nvim_1.workspace.getConfiguration('markdownlint');
110 function didOpenTextDocument(document) {
111 if (config.get('onOpen', true)) {
112 engine.lint(document);
115 async function didChangeTextDocument(params) {
116 if (!config.get('onChange', true)) {
119 if (params.textDocument.version && documentVersion !== params.textDocument.version) {
120 documentVersion = params.textDocument.version;
121 const { document } = await coc_nvim_1.workspace.getCurrentState();
122 engine.lint(document);
125 async function didSaveTextDocument(document) {
126 if (config.get('onSave', true)) {
127 engine.lint(document);
130 async function activate(context) {
131 await engine.parseConfig();
132 context.subscriptions.push(coc_nvim_1.languages.registerCodeActionProvider(documentSelector, engine, 'markdownlint'), coc_nvim_1.commands.registerCommand(engine.fixAllCommandName, async () => {
133 const { document } = await coc_nvim_1.workspace.getCurrentState();
134 engine.fixAll(document);
135 }), coc_nvim_1.workspace.onDidOpenTextDocument(didOpenTextDocument), coc_nvim_1.workspace.onDidChangeTextDocument(didChangeTextDocument), coc_nvim_1.workspace.onDidSaveTextDocument(didSaveTextDocument), coc_nvim_1.events.on('BufEnter', bufnr => {
139 const doc = coc_nvim_1.workspace.getDocument(bufnr);
143 didOpenTextDocument(doc.textDocument);
145 coc_nvim_1.workspace.documents.map((doc) => {
146 didOpenTextDocument(doc.textDocument);
149 exports.activate = activate;
154 /***/ (function(module, exports) {
156 module.exports = require("coc.nvim");
160 /***/ (function(module, exports, __webpack_require__) {
164 var __importDefault = (this && this.__importDefault) || function (mod) {
165 return (mod && mod.__esModule) ? mod : { "default": mod };
167 Object.defineProperty(exports, "__esModule", { value: true });
168 exports.MarkdownlintEngine = void 0;
169 const coc_nvim_1 = __webpack_require__(1);
170 const deep_extend_1 = __importDefault(__webpack_require__(3));
171 const fs_1 = __importDefault(__webpack_require__(4));
172 const js_yaml_1 = __importDefault(__webpack_require__(5));
173 const markdownlint_1 = __importDefault(__webpack_require__(37));
174 const markdownlint_rule_helpers_1 = __webpack_require__(156);
175 const path_1 = __importDefault(__webpack_require__(38));
176 const rc_1 = __importDefault(__webpack_require__(157));
177 const vscode_languageserver_protocol_1 = __webpack_require__(162);
178 const projectConfigFiles = ['.markdownlint.json', '.markdownlint.yaml', '.markdownlint.yml'];
179 const configFileParsers = [JSON.parse, js_yaml_1.default.safeLoad];
180 class MarkdownlintEngine {
182 this.fixAllCommandName = 'markdownlint.fixAll';
183 this.source = 'markdownlint';
184 this.outputChannel = coc_nvim_1.workspace.createOutputChannel(this.source);
185 this.diagnosticCollection = coc_nvim_1.languages.createDiagnosticCollection(this.source);
188 outputLine(message) {
189 if (this.outputChannel) {
190 this.outputChannel.appendLine(`[${new Date().toLocaleTimeString()}] ${message}`);
193 async parseConfig() {
195 this.config = rc_1.default(this.source, {});
196 this.outputLine(`Info: global config: ${JSON.stringify(rc_1.default(this.source, {}))}`);
199 this.outputLine(`Error: global config parse failed: ${e}`);
202 const preferences = coc_nvim_1.workspace.getConfiguration('coc.preferences');
203 const rootFolder = await coc_nvim_1.workspace.resolveRootFolder(coc_nvim_1.Uri.parse(coc_nvim_1.workspace.uri), preferences.get('rootPatterns', []));
204 for (const projectConfigFile of projectConfigFiles) {
205 const fullPath = path_1.default.join(rootFolder, projectConfigFile);
206 if (fs_1.default.existsSync(fullPath)) {
208 const projectConfig = markdownlint_1.default.readConfigSync(fullPath, configFileParsers);
209 this.config = deep_extend_1.default(this.config, projectConfig);
210 this.outputLine(`Info: local config: ${fullPath}, ${JSON.stringify(projectConfig)}`);
216 this.outputLine(`Error: local config parse failed: ${e}`);
218 const cocConfig = coc_nvim_1.workspace.getConfiguration('markdownlint').get('config');
220 this.config = deep_extend_1.default(this.config, cocConfig);
221 this.outputLine(`Info: config from coc-settings.json: ${JSON.stringify(cocConfig)}`);
223 this.outputLine(`Info: full config: ${JSON.stringify(this.config)}`);
225 markdownlintWrapper(document) {
229 // customRules: customRules,
231 [document.uri]: document.getText()
236 results = markdownlint_1.default.sync(options)[document.uri];
239 this.outputLine(`Error: lint exception: ${e.stack}`);
243 async provideCodeActions(document, _range, context) {
244 const codeActions = [];
245 const fixInfoDiagnostics = [];
246 for (const diagnostic of context.diagnostics) {
248 if (diagnostic.fixInfo) {
250 const lineNumber = diagnostic.fixInfo.lineNumber - 1 || diagnostic.range.start.line;
251 const line = await coc_nvim_1.workspace.getLine(document.uri, lineNumber);
253 const newText = markdownlint_rule_helpers_1.applyFix(line, diagnostic.fixInfo, '\n');
254 const edit = { changes: {} };
255 if (typeof newText === 'string') {
256 const range = vscode_languageserver_protocol_1.Range.create(lineNumber, 0, lineNumber, line.length);
257 edit.changes[document.uri] = [vscode_languageserver_protocol_1.TextEdit.replace(range, newText)];
260 edit.changes[document.uri] = [vscode_languageserver_protocol_1.TextEdit.del(diagnostic.range)];
262 const title = `Fix: ${diagnostic.message.split(':')[0]}`;
266 diagnostics: [...context.diagnostics]
268 fixInfoDiagnostics.push(diagnostic);
269 codeActions.push(action);
272 if (fixInfoDiagnostics.length) {
273 const title = 'Fix All error found by markdownlint';
274 const sourceFixAllAction = {
276 kind: vscode_languageserver_protocol_1.CodeActionKind.SourceFixAll,
277 diagnostics: fixInfoDiagnostics,
280 command: this.fixAllCommandName
283 codeActions.push(sourceFixAllAction);
288 this.diagnosticCollection.clear();
289 if (document.languageId !== 'markdown') {
292 const results = this.markdownlintWrapper(document);
293 if (!results.length) {
296 const diagnostics = [];
297 results.forEach((result) => {
298 const ruleDescription = result.ruleDescription;
299 let message = result.ruleNames.join('/') + ': ' + ruleDescription;
300 if (result.errorDetail) {
301 message += ' [' + result.errorDetail + ']';
303 const start = vscode_languageserver_protocol_1.Position.create(result.lineNumber - 1, 0);
304 const end = vscode_languageserver_protocol_1.Position.create(result.lineNumber - 1, 0);
305 if (result.errorRange) {
306 start.character = result.errorRange[0] - 1;
307 end.character = start.character + result.errorRange[1];
309 const range = vscode_languageserver_protocol_1.Range.create(start, end);
310 const diagnostic = vscode_languageserver_protocol_1.Diagnostic.create(range, message);
311 diagnostic.severity = vscode_languageserver_protocol_1.DiagnosticSeverity.Warning;
312 diagnostic.source = this.source;
314 diagnostic.fixInfo = result.fixInfo;
315 diagnostics.push(diagnostic);
317 this.diagnosticCollection.set(document.uri, diagnostics);
319 async fixAll(document) {
320 const results = this.markdownlintWrapper(document);
321 if (!results.length) {
324 const text = document.getText();
325 const fixedText = markdownlint_rule_helpers_1.applyFixes(text, results);
326 if (text != fixedText) {
327 const doc = coc_nvim_1.workspace.getDocument(document.uri);
328 const end = vscode_languageserver_protocol_1.Position.create(doc.lineCount - 1, doc.getline(doc.lineCount - 1).length);
331 [document.uri]: [vscode_languageserver_protocol_1.TextEdit.replace(vscode_languageserver_protocol_1.Range.create(vscode_languageserver_protocol_1.Position.create(0, 0), end), fixedText)]
334 await coc_nvim_1.workspace.applyEdit(edit);
338 exports.MarkdownlintEngine = MarkdownlintEngine;
343 /***/ (function(module, exports, __webpack_require__) {
347 * @description Recursive object extending
348 * @author Viacheslav Lotsmanov <lotsmanov89@gmail.com>
351 * The MIT License (MIT)
353 * Copyright (c) 2013-2018 Viacheslav Lotsmanov
355 * Permission is hereby granted, free of charge, to any person obtaining a copy of
356 * this software and associated documentation files (the "Software"), to deal in
357 * the Software without restriction, including without limitation the rights to
358 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
359 * the Software, and to permit persons to whom the Software is furnished to do so,
360 * subject to the following conditions:
362 * The above copyright notice and this permission notice shall be included in all
363 * copies or substantial portions of the Software.
365 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
366 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
367 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
368 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
369 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
370 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
375 function isSpecificValue(val) {
377 val instanceof Buffer
378 || val instanceof Date
379 || val instanceof RegExp
383 function cloneSpecificValue(val) {
384 if (val instanceof Buffer) {
386 ? Buffer.alloc(val.length)
387 : new Buffer(val.length);
390 } else if (val instanceof Date) {
391 return new Date(val.getTime());
392 } else if (val instanceof RegExp) {
393 return new RegExp(val);
395 throw new Error('Unexpected situation');
400 * Recursive cloning array.
402 function deepCloneArray(arr) {
404 arr.forEach(function (item, index) {
405 if (typeof item === 'object' && item !== null) {
406 if (Array.isArray(item)) {
407 clone[index] = deepCloneArray(item);
408 } else if (isSpecificValue(item)) {
409 clone[index] = cloneSpecificValue(item);
411 clone[index] = deepExtend({}, item);
420 function safeGetProperty(object, property) {
421 return property === '__proto__' ? undefined : object[property];
425 * Extening object that entered in first argument.
427 * Returns extended object or false if have no target object or incorrect type.
429 * If you wish to clone source object (without modify it), just use empty new
430 * object as first argument, like this:
431 * deepExtend({}, yourObj_1, [yourObj_N]);
433 var deepExtend = module.exports = function (/*obj_1, [obj_2], [obj_N]*/) {
434 if (arguments.length < 1 || typeof arguments[0] !== 'object') {
438 if (arguments.length < 2) {
442 var target = arguments[0];
444 // convert arguments to array and cut off target object
445 var args = Array.prototype.slice.call(arguments, 1);
449 args.forEach(function (obj) {
450 // skip argument if isn't an object, is null, or is an array
451 if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
455 Object.keys(obj).forEach(function (key) {
456 src = safeGetProperty(target, key); // source value
457 val = safeGetProperty(obj, key); // new value
459 // recursion prevention
460 if (val === target) {
464 * if new value isn't object then just overwrite by new value
465 * instead of extending.
467 } else if (typeof val !== 'object' || val === null) {
471 // just clone arrays (and recursive clone objects inside)
472 } else if (Array.isArray(val)) {
473 target[key] = deepCloneArray(val);
476 // custom cloning and overwrite for specific objects
477 } else if (isSpecificValue(val)) {
478 target[key] = cloneSpecificValue(val);
481 // overwrite by new value if source isn't object or array
482 } else if (typeof src !== 'object' || src === null || Array.isArray(src)) {
483 target[key] = deepExtend({}, val);
486 // source value and new value is objects both, extending...
488 target[key] = deepExtend(src, val);
500 /***/ (function(module, exports) {
502 module.exports = require("fs");
506 /***/ (function(module, exports, __webpack_require__) {
512 var yaml = __webpack_require__(6);
515 module.exports = yaml;
520 /***/ (function(module, exports, __webpack_require__) {
526 var loader = __webpack_require__(7);
527 var dumper = __webpack_require__(36);
530 function deprecated(name) {
532 throw new Error('Function ' + name + ' is deprecated and cannot be used.');
537 module.exports.Type = __webpack_require__(13);
538 module.exports.Schema = __webpack_require__(12);
539 module.exports.FAILSAFE_SCHEMA = __webpack_require__(16);
540 module.exports.JSON_SCHEMA = __webpack_require__(15);
541 module.exports.CORE_SCHEMA = __webpack_require__(14);
542 module.exports.DEFAULT_SAFE_SCHEMA = __webpack_require__(11);
543 module.exports.DEFAULT_FULL_SCHEMA = __webpack_require__(31);
544 module.exports.load = loader.load;
545 module.exports.loadAll = loader.loadAll;
546 module.exports.safeLoad = loader.safeLoad;
547 module.exports.safeLoadAll = loader.safeLoadAll;
548 module.exports.dump = dumper.dump;
549 module.exports.safeDump = dumper.safeDump;
550 module.exports.YAMLException = __webpack_require__(9);
552 // Deprecated schema names from JS-YAML 2.0.x
553 module.exports.MINIMAL_SCHEMA = __webpack_require__(16);
554 module.exports.SAFE_SCHEMA = __webpack_require__(11);
555 module.exports.DEFAULT_SCHEMA = __webpack_require__(31);
557 // Deprecated functions from JS-YAML 1.x.x
558 module.exports.scan = deprecated('scan');
559 module.exports.parse = deprecated('parse');
560 module.exports.compose = deprecated('compose');
561 module.exports.addConstructor = deprecated('addConstructor');
566 /***/ (function(module, exports, __webpack_require__) {
571 /*eslint-disable max-len,no-use-before-define*/
573 var common = __webpack_require__(8);
574 var YAMLException = __webpack_require__(9);
575 var Mark = __webpack_require__(10);
576 var DEFAULT_SAFE_SCHEMA = __webpack_require__(11);
577 var DEFAULT_FULL_SCHEMA = __webpack_require__(31);
580 var _hasOwnProperty = Object.prototype.hasOwnProperty;
583 var CONTEXT_FLOW_IN = 1;
584 var CONTEXT_FLOW_OUT = 2;
585 var CONTEXT_BLOCK_IN = 3;
586 var CONTEXT_BLOCK_OUT = 4;
589 var CHOMPING_CLIP = 1;
590 var CHOMPING_STRIP = 2;
591 var CHOMPING_KEEP = 3;
594 var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
595 var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
596 var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
597 var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
598 var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
601 function _class(obj) { return Object.prototype.toString.call(obj); }
604 return (c === 0x0A/* LF */) || (c === 0x0D/* CR */);
607 function is_WHITE_SPACE(c) {
608 return (c === 0x09/* Tab */) || (c === 0x20/* Space */);
611 function is_WS_OR_EOL(c) {
612 return (c === 0x09/* Tab */) ||
613 (c === 0x20/* Space */) ||
614 (c === 0x0A/* LF */) ||
615 (c === 0x0D/* CR */);
618 function is_FLOW_INDICATOR(c) {
619 return c === 0x2C/* , */ ||
626 function fromHexCode(c) {
629 if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
633 /*eslint-disable no-bitwise*/
636 if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) {
637 return lc - 0x61 + 10;
643 function escapedHexLen(c) {
644 if (c === 0x78/* x */) { return 2; }
645 if (c === 0x75/* u */) { return 4; }
646 if (c === 0x55/* U */) { return 8; }
650 function fromDecimalCode(c) {
651 if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) {
658 function simpleEscapeSequence(c) {
659 /* eslint-disable indent */
660 return (c === 0x30/* 0 */) ? '\x00' :
661 (c === 0x61/* a */) ? '\x07' :
662 (c === 0x62/* b */) ? '\x08' :
663 (c === 0x74/* t */) ? '\x09' :
664 (c === 0x09/* Tab */) ? '\x09' :
665 (c === 0x6E/* n */) ? '\x0A' :
666 (c === 0x76/* v */) ? '\x0B' :
667 (c === 0x66/* f */) ? '\x0C' :
668 (c === 0x72/* r */) ? '\x0D' :
669 (c === 0x65/* e */) ? '\x1B' :
670 (c === 0x20/* Space */) ? ' ' :
671 (c === 0x22/* " */) ? '\x22' :
672 (c === 0x2F/* / */) ? '/' :
673 (c === 0x5C/* \ */) ? '\x5C' :
674 (c === 0x4E/* N */) ? '\x85' :
675 (c === 0x5F/* _ */) ? '\xA0' :
676 (c === 0x4C/* L */) ? '\u2028' :
677 (c === 0x50/* P */) ? '\u2029' : '';
680 function charFromCodepoint(c) {
682 return String.fromCharCode(c);
684 // Encode UTF-16 surrogate pair
685 // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF
686 return String.fromCharCode(
687 ((c - 0x010000) >> 10) + 0xD800,
688 ((c - 0x010000) & 0x03FF) + 0xDC00
692 var simpleEscapeCheck = new Array(256); // integer, for fast access
693 var simpleEscapeMap = new Array(256);
694 for (var i = 0; i < 256; i++) {
695 simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
696 simpleEscapeMap[i] = simpleEscapeSequence(i);
700 function State(input, options) {
703 this.filename = options['filename'] || null;
704 this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
705 this.onWarning = options['onWarning'] || null;
706 this.legacy = options['legacy'] || false;
707 this.json = options['json'] || false;
708 this.listener = options['listener'] || null;
710 this.implicitTypes = this.schema.compiledImplicit;
711 this.typeMap = this.schema.compiledTypeMap;
713 this.length = input.length;
723 this.checkLineBreaks;
734 function generateError(state, message) {
735 return new YAMLException(
737 new Mark(state.filename, state.input, state.position, state.line, (state.position - state.lineStart)));
740 function throwError(state, message) {
741 throw generateError(state, message);
744 function throwWarning(state, message) {
745 if (state.onWarning) {
746 state.onWarning.call(null, generateError(state, message));
751 var directiveHandlers = {
753 YAML: function handleYamlDirective(state, name, args) {
755 var match, major, minor;
757 if (state.version !== null) {
758 throwError(state, 'duplication of %YAML directive');
761 if (args.length !== 1) {
762 throwError(state, 'YAML directive accepts exactly one argument');
765 match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
767 if (match === null) {
768 throwError(state, 'ill-formed argument of the YAML directive');
771 major = parseInt(match[1], 10);
772 minor = parseInt(match[2], 10);
775 throwError(state, 'unacceptable YAML version of the document');
778 state.version = args[0];
779 state.checkLineBreaks = (minor < 2);
781 if (minor !== 1 && minor !== 2) {
782 throwWarning(state, 'unsupported YAML version of the document');
786 TAG: function handleTagDirective(state, name, args) {
790 if (args.length !== 2) {
791 throwError(state, 'TAG directive accepts exactly two arguments');
797 if (!PATTERN_TAG_HANDLE.test(handle)) {
798 throwError(state, 'ill-formed tag handle (first argument) of the TAG directive');
801 if (_hasOwnProperty.call(state.tagMap, handle)) {
802 throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
805 if (!PATTERN_TAG_URI.test(prefix)) {
806 throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive');
809 state.tagMap[handle] = prefix;
814 function captureSegment(state, start, end, checkJson) {
815 var _position, _length, _character, _result;
818 _result = state.input.slice(start, end);
821 for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
822 _character = _result.charCodeAt(_position);
823 if (!(_character === 0x09 ||
824 (0x20 <= _character && _character <= 0x10FFFF))) {
825 throwError(state, 'expected valid JSON character');
828 } else if (PATTERN_NON_PRINTABLE.test(_result)) {
829 throwError(state, 'the stream contains non-printable characters');
832 state.result += _result;
836 function mergeMappings(state, destination, source, overridableKeys) {
837 var sourceKeys, key, index, quantity;
839 if (!common.isObject(source)) {
840 throwError(state, 'cannot merge mappings; the provided source object is unacceptable');
843 sourceKeys = Object.keys(source);
845 for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
846 key = sourceKeys[index];
848 if (!_hasOwnProperty.call(destination, key)) {
849 destination[key] = source[key];
850 overridableKeys[key] = true;
855 function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) {
858 // The output is a plain object here, so keys can only be strings.
859 // We need to convert keyNode to a string, but doing so can hang the process
860 // (deeply nested arrays that explode exponentially using aliases).
861 if (Array.isArray(keyNode)) {
862 keyNode = Array.prototype.slice.call(keyNode);
864 for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
865 if (Array.isArray(keyNode[index])) {
866 throwError(state, 'nested arrays are not supported inside keys');
869 if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') {
870 keyNode[index] = '[object Object]';
875 // Avoid code execution in load() via toString property
876 // (still use its own toString for arrays, timestamps,
877 // and whatever user schema extensions happen to have @@toStringTag)
878 if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') {
879 keyNode = '[object Object]';
883 keyNode = String(keyNode);
885 if (_result === null) {
889 if (keyTag === 'tag:yaml.org,2002:merge') {
890 if (Array.isArray(valueNode)) {
891 for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
892 mergeMappings(state, _result, valueNode[index], overridableKeys);
895 mergeMappings(state, _result, valueNode, overridableKeys);
899 !_hasOwnProperty.call(overridableKeys, keyNode) &&
900 _hasOwnProperty.call(_result, keyNode)) {
901 state.line = startLine || state.line;
902 state.position = startPos || state.position;
903 throwError(state, 'duplicated mapping key');
905 _result[keyNode] = valueNode;
906 delete overridableKeys[keyNode];
912 function readLineBreak(state) {
915 ch = state.input.charCodeAt(state.position);
917 if (ch === 0x0A/* LF */) {
919 } else if (ch === 0x0D/* CR */) {
921 if (state.input.charCodeAt(state.position) === 0x0A/* LF */) {
925 throwError(state, 'a line break is expected');
929 state.lineStart = state.position;
932 function skipSeparationSpace(state, allowComments, checkIndent) {
934 ch = state.input.charCodeAt(state.position);
937 while (is_WHITE_SPACE(ch)) {
938 ch = state.input.charCodeAt(++state.position);
941 if (allowComments && ch === 0x23/* # */) {
943 ch = state.input.charCodeAt(++state.position);
944 } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0);
948 readLineBreak(state);
950 ch = state.input.charCodeAt(state.position);
952 state.lineIndent = 0;
954 while (ch === 0x20/* Space */) {
956 ch = state.input.charCodeAt(++state.position);
963 if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
964 throwWarning(state, 'deficient indentation');
970 function testDocumentSeparator(state) {
971 var _position = state.position,
974 ch = state.input.charCodeAt(_position);
976 // Condition state.position === state.lineStart is tested
977 // in parent on each call, for efficiency. No needs to test here again.
978 if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) &&
979 ch === state.input.charCodeAt(_position + 1) &&
980 ch === state.input.charCodeAt(_position + 2)) {
984 ch = state.input.charCodeAt(_position);
986 if (ch === 0 || is_WS_OR_EOL(ch)) {
994 function writeFoldedLines(state, count) {
997 } else if (count > 1) {
998 state.result += common.repeat('\n', count - 1);
1003 function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1013 _result = state.result,
1016 ch = state.input.charCodeAt(state.position);
1018 if (is_WS_OR_EOL(ch) ||
1019 is_FLOW_INDICATOR(ch) ||
1020 ch === 0x23/* # */ ||
1021 ch === 0x26/* & */ ||
1022 ch === 0x2A/* * */ ||
1023 ch === 0x21/* ! */ ||
1024 ch === 0x7C/* | */ ||
1025 ch === 0x3E/* > */ ||
1026 ch === 0x27/* ' */ ||
1027 ch === 0x22/* " */ ||
1028 ch === 0x25/* % */ ||
1029 ch === 0x40/* @ */ ||
1030 ch === 0x60/* ` */) {
1034 if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) {
1035 following = state.input.charCodeAt(state.position + 1);
1037 if (is_WS_OR_EOL(following) ||
1038 withinFlowCollection && is_FLOW_INDICATOR(following)) {
1043 state.kind = 'scalar';
1045 captureStart = captureEnd = state.position;
1046 hasPendingContent = false;
1049 if (ch === 0x3A/* : */) {
1050 following = state.input.charCodeAt(state.position + 1);
1052 if (is_WS_OR_EOL(following) ||
1053 withinFlowCollection && is_FLOW_INDICATOR(following)) {
1057 } else if (ch === 0x23/* # */) {
1058 preceding = state.input.charCodeAt(state.position - 1);
1060 if (is_WS_OR_EOL(preceding)) {
1064 } else if ((state.position === state.lineStart && testDocumentSeparator(state)) ||
1065 withinFlowCollection && is_FLOW_INDICATOR(ch)) {
1068 } else if (is_EOL(ch)) {
1070 _lineStart = state.lineStart;
1071 _lineIndent = state.lineIndent;
1072 skipSeparationSpace(state, false, -1);
1074 if (state.lineIndent >= nodeIndent) {
1075 hasPendingContent = true;
1076 ch = state.input.charCodeAt(state.position);
1079 state.position = captureEnd;
1081 state.lineStart = _lineStart;
1082 state.lineIndent = _lineIndent;
1087 if (hasPendingContent) {
1088 captureSegment(state, captureStart, captureEnd, false);
1089 writeFoldedLines(state, state.line - _line);
1090 captureStart = captureEnd = state.position;
1091 hasPendingContent = false;
1094 if (!is_WHITE_SPACE(ch)) {
1095 captureEnd = state.position + 1;
1098 ch = state.input.charCodeAt(++state.position);
1101 captureSegment(state, captureStart, captureEnd, false);
1108 state.result = _result;
1112 function readSingleQuotedScalar(state, nodeIndent) {
1114 captureStart, captureEnd;
1116 ch = state.input.charCodeAt(state.position);
1118 if (ch !== 0x27/* ' */) {
1122 state.kind = 'scalar';
1125 captureStart = captureEnd = state.position;
1127 while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1128 if (ch === 0x27/* ' */) {
1129 captureSegment(state, captureStart, state.position, true);
1130 ch = state.input.charCodeAt(++state.position);
1132 if (ch === 0x27/* ' */) {
1133 captureStart = state.position;
1135 captureEnd = state.position;
1140 } else if (is_EOL(ch)) {
1141 captureSegment(state, captureStart, captureEnd, true);
1142 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1143 captureStart = captureEnd = state.position;
1145 } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1146 throwError(state, 'unexpected end of the document within a single quoted scalar');
1150 captureEnd = state.position;
1154 throwError(state, 'unexpected end of the stream within a single quoted scalar');
1157 function readDoubleQuotedScalar(state, nodeIndent) {
1165 ch = state.input.charCodeAt(state.position);
1167 if (ch !== 0x22/* " */) {
1171 state.kind = 'scalar';
1174 captureStart = captureEnd = state.position;
1176 while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1177 if (ch === 0x22/* " */) {
1178 captureSegment(state, captureStart, state.position, true);
1182 } else if (ch === 0x5C/* \ */) {
1183 captureSegment(state, captureStart, state.position, true);
1184 ch = state.input.charCodeAt(++state.position);
1187 skipSeparationSpace(state, false, nodeIndent);
1189 // TODO: rework to inline fn with no type cast?
1190 } else if (ch < 256 && simpleEscapeCheck[ch]) {
1191 state.result += simpleEscapeMap[ch];
1194 } else if ((tmp = escapedHexLen(ch)) > 0) {
1198 for (; hexLength > 0; hexLength--) {
1199 ch = state.input.charCodeAt(++state.position);
1201 if ((tmp = fromHexCode(ch)) >= 0) {
1202 hexResult = (hexResult << 4) + tmp;
1205 throwError(state, 'expected hexadecimal character');
1209 state.result += charFromCodepoint(hexResult);
1214 throwError(state, 'unknown escape sequence');
1217 captureStart = captureEnd = state.position;
1219 } else if (is_EOL(ch)) {
1220 captureSegment(state, captureStart, captureEnd, true);
1221 writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1222 captureStart = captureEnd = state.position;
1224 } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1225 throwError(state, 'unexpected end of the document within a double quoted scalar');
1229 captureEnd = state.position;
1233 throwError(state, 'unexpected end of the stream within a double quoted scalar');
1236 function readFlowCollection(state, nodeIndent) {
1237 var readNext = true,
1241 _anchor = state.anchor,
1247 overridableKeys = {},
1253 ch = state.input.charCodeAt(state.position);
1255 if (ch === 0x5B/* [ */) {
1256 terminator = 0x5D;/* ] */
1259 } else if (ch === 0x7B/* { */) {
1260 terminator = 0x7D;/* } */
1267 if (state.anchor !== null) {
1268 state.anchorMap[state.anchor] = _result;
1271 ch = state.input.charCodeAt(++state.position);
1274 skipSeparationSpace(state, true, nodeIndent);
1276 ch = state.input.charCodeAt(state.position);
1278 if (ch === terminator) {
1281 state.anchor = _anchor;
1282 state.kind = isMapping ? 'mapping' : 'sequence';
1283 state.result = _result;
1285 } else if (!readNext) {
1286 throwError(state, 'missed comma between flow collection entries');
1289 keyTag = keyNode = valueNode = null;
1290 isPair = isExplicitPair = false;
1292 if (ch === 0x3F/* ? */) {
1293 following = state.input.charCodeAt(state.position + 1);
1295 if (is_WS_OR_EOL(following)) {
1296 isPair = isExplicitPair = true;
1298 skipSeparationSpace(state, true, nodeIndent);
1303 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1305 keyNode = state.result;
1306 skipSeparationSpace(state, true, nodeIndent);
1308 ch = state.input.charCodeAt(state.position);
1310 if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) {
1312 ch = state.input.charCodeAt(++state.position);
1313 skipSeparationSpace(state, true, nodeIndent);
1314 composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
1315 valueNode = state.result;
1319 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode);
1320 } else if (isPair) {
1321 _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode));
1323 _result.push(keyNode);
1326 skipSeparationSpace(state, true, nodeIndent);
1328 ch = state.input.charCodeAt(state.position);
1330 if (ch === 0x2C/* , */) {
1332 ch = state.input.charCodeAt(++state.position);
1338 throwError(state, 'unexpected end of the stream within a flow collection');
1341 function readBlockScalar(state, nodeIndent) {
1344 chomping = CHOMPING_CLIP,
1345 didReadContent = false,
1346 detectedIndent = false,
1347 textIndent = nodeIndent,
1349 atMoreIndented = false,
1353 ch = state.input.charCodeAt(state.position);
1355 if (ch === 0x7C/* | */) {
1357 } else if (ch === 0x3E/* > */) {
1363 state.kind = 'scalar';
1367 ch = state.input.charCodeAt(++state.position);
1369 if (ch === 0x2B/* + */ || ch === 0x2D/* - */) {
1370 if (CHOMPING_CLIP === chomping) {
1371 chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP;
1373 throwError(state, 'repeat of a chomping mode identifier');
1376 } else if ((tmp = fromDecimalCode(ch)) >= 0) {
1378 throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one');
1379 } else if (!detectedIndent) {
1380 textIndent = nodeIndent + tmp - 1;
1381 detectedIndent = true;
1383 throwError(state, 'repeat of an indentation width identifier');
1391 if (is_WHITE_SPACE(ch)) {
1392 do { ch = state.input.charCodeAt(++state.position); }
1393 while (is_WHITE_SPACE(ch));
1395 if (ch === 0x23/* # */) {
1396 do { ch = state.input.charCodeAt(++state.position); }
1397 while (!is_EOL(ch) && (ch !== 0));
1402 readLineBreak(state);
1403 state.lineIndent = 0;
1405 ch = state.input.charCodeAt(state.position);
1407 while ((!detectedIndent || state.lineIndent < textIndent) &&
1408 (ch === 0x20/* Space */)) {
1410 ch = state.input.charCodeAt(++state.position);
1413 if (!detectedIndent && state.lineIndent > textIndent) {
1414 textIndent = state.lineIndent;
1422 // End of the scalar.
1423 if (state.lineIndent < textIndent) {
1425 // Perform the chomping.
1426 if (chomping === CHOMPING_KEEP) {
1427 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
1428 } else if (chomping === CHOMPING_CLIP) {
1429 if (didReadContent) { // i.e. only if the scalar is not empty.
1430 state.result += '\n';
1434 // Break this `while` cycle and go to the funciton's epilogue.
1438 // Folded style: use fancy rules to handle line breaks.
1441 // Lines starting with white space characters (more-indented lines) are not folded.
1442 if (is_WHITE_SPACE(ch)) {
1443 atMoreIndented = true;
1444 // except for the first content line (cf. Example 8.1)
1445 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
1447 // End of more-indented block.
1448 } else if (atMoreIndented) {
1449 atMoreIndented = false;
1450 state.result += common.repeat('\n', emptyLines + 1);
1452 // Just one line break - perceive as the same line.
1453 } else if (emptyLines === 0) {
1454 if (didReadContent) { // i.e. only if we have already read some scalar content.
1455 state.result += ' ';
1458 // Several line breaks - perceive as different lines.
1460 state.result += common.repeat('\n', emptyLines);
1463 // Literal style: just add exact number of line breaks between content lines.
1465 // Keep all line breaks except the header line break.
1466 state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines);
1469 didReadContent = true;
1470 detectedIndent = true;
1472 captureStart = state.position;
1474 while (!is_EOL(ch) && (ch !== 0)) {
1475 ch = state.input.charCodeAt(++state.position);
1478 captureSegment(state, captureStart, state.position, false);
1484 function readBlockSequence(state, nodeIndent) {
1487 _anchor = state.anchor,
1493 if (state.anchor !== null) {
1494 state.anchorMap[state.anchor] = _result;
1497 ch = state.input.charCodeAt(state.position);
1501 if (ch !== 0x2D/* - */) {
1505 following = state.input.charCodeAt(state.position + 1);
1507 if (!is_WS_OR_EOL(following)) {
1514 if (skipSeparationSpace(state, true, -1)) {
1515 if (state.lineIndent <= nodeIndent) {
1517 ch = state.input.charCodeAt(state.position);
1523 composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
1524 _result.push(state.result);
1525 skipSeparationSpace(state, true, -1);
1527 ch = state.input.charCodeAt(state.position);
1529 if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) {
1530 throwError(state, 'bad indentation of a sequence entry');
1531 } else if (state.lineIndent < nodeIndent) {
1538 state.anchor = _anchor;
1539 state.kind = 'sequence';
1540 state.result = _result;
1546 function readBlockMapping(state, nodeIndent, flowIndent) {
1552 _anchor = state.anchor,
1554 overridableKeys = {},
1558 atExplicitKey = false,
1562 if (state.anchor !== null) {
1563 state.anchorMap[state.anchor] = _result;
1566 ch = state.input.charCodeAt(state.position);
1569 following = state.input.charCodeAt(state.position + 1);
1570 _line = state.line; // Save the current line.
1571 _pos = state.position;
1574 // Explicit notation case. There are two separate blocks:
1575 // first for the key (denoted by "?") and second for the value (denoted by ":")
1577 if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) {
1579 if (ch === 0x3F/* ? */) {
1580 if (atExplicitKey) {
1581 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
1582 keyTag = keyNode = valueNode = null;
1586 atExplicitKey = true;
1587 allowCompact = true;
1589 } else if (atExplicitKey) {
1590 // i.e. 0x3A/* : */ === character after the explicit key.
1591 atExplicitKey = false;
1592 allowCompact = true;
1595 throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line');
1598 state.position += 1;
1602 // Implicit notation case. Flow-style node as the key first, then ":", and the value.
1604 } else if (composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
1606 if (state.line === _line) {
1607 ch = state.input.charCodeAt(state.position);
1609 while (is_WHITE_SPACE(ch)) {
1610 ch = state.input.charCodeAt(++state.position);
1613 if (ch === 0x3A/* : */) {
1614 ch = state.input.charCodeAt(++state.position);
1616 if (!is_WS_OR_EOL(ch)) {
1617 throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping');
1620 if (atExplicitKey) {
1621 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
1622 keyTag = keyNode = valueNode = null;
1626 atExplicitKey = false;
1627 allowCompact = false;
1629 keyNode = state.result;
1631 } else if (detected) {
1632 throwError(state, 'can not read an implicit mapping pair; a colon is missed');
1636 state.anchor = _anchor;
1637 return true; // Keep the result of `composeNode`.
1640 } else if (detected) {
1641 throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key');
1645 state.anchor = _anchor;
1646 return true; // Keep the result of `composeNode`.
1650 break; // Reading is done. Go to the epilogue.
1654 // Common reading code for both explicit and implicit notations.
1656 if (state.line === _line || state.lineIndent > nodeIndent) {
1657 if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
1658 if (atExplicitKey) {
1659 keyNode = state.result;
1661 valueNode = state.result;
1665 if (!atExplicitKey) {
1666 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _pos);
1667 keyTag = keyNode = valueNode = null;
1670 skipSeparationSpace(state, true, -1);
1671 ch = state.input.charCodeAt(state.position);
1674 if (state.lineIndent > nodeIndent && (ch !== 0)) {
1675 throwError(state, 'bad indentation of a mapping entry');
1676 } else if (state.lineIndent < nodeIndent) {
1685 // Special case: last mapping's node contains only the key in explicit notation.
1686 if (atExplicitKey) {
1687 storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null);
1690 // Expose the resulting mapping.
1693 state.anchor = _anchor;
1694 state.kind = 'mapping';
1695 state.result = _result;
1701 function readTagProperty(state) {
1709 ch = state.input.charCodeAt(state.position);
1711 if (ch !== 0x21/* ! */) return false;
1713 if (state.tag !== null) {
1714 throwError(state, 'duplication of a tag property');
1717 ch = state.input.charCodeAt(++state.position);
1719 if (ch === 0x3C/* < */) {
1721 ch = state.input.charCodeAt(++state.position);
1723 } else if (ch === 0x21/* ! */) {
1726 ch = state.input.charCodeAt(++state.position);
1732 _position = state.position;
1735 do { ch = state.input.charCodeAt(++state.position); }
1736 while (ch !== 0 && ch !== 0x3E/* > */);
1738 if (state.position < state.length) {
1739 tagName = state.input.slice(_position, state.position);
1740 ch = state.input.charCodeAt(++state.position);
1742 throwError(state, 'unexpected end of the stream within a verbatim tag');
1745 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
1747 if (ch === 0x21/* ! */) {
1749 tagHandle = state.input.slice(_position - 1, state.position + 1);
1751 if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
1752 throwError(state, 'named tag handle cannot contain such characters');
1756 _position = state.position + 1;
1758 throwError(state, 'tag suffix cannot contain exclamation marks');
1762 ch = state.input.charCodeAt(++state.position);
1765 tagName = state.input.slice(_position, state.position);
1767 if (PATTERN_FLOW_INDICATORS.test(tagName)) {
1768 throwError(state, 'tag suffix cannot contain flow indicator characters');
1772 if (tagName && !PATTERN_TAG_URI.test(tagName)) {
1773 throwError(state, 'tag name cannot contain such characters: ' + tagName);
1777 state.tag = tagName;
1779 } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) {
1780 state.tag = state.tagMap[tagHandle] + tagName;
1782 } else if (tagHandle === '!') {
1783 state.tag = '!' + tagName;
1785 } else if (tagHandle === '!!') {
1786 state.tag = 'tag:yaml.org,2002:' + tagName;
1789 throwError(state, 'undeclared tag handle "' + tagHandle + '"');
1795 function readAnchorProperty(state) {
1799 ch = state.input.charCodeAt(state.position);
1801 if (ch !== 0x26/* & */) return false;
1803 if (state.anchor !== null) {
1804 throwError(state, 'duplication of an anchor property');
1807 ch = state.input.charCodeAt(++state.position);
1808 _position = state.position;
1810 while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
1811 ch = state.input.charCodeAt(++state.position);
1814 if (state.position === _position) {
1815 throwError(state, 'name of an anchor node must contain at least one character');
1818 state.anchor = state.input.slice(_position, state.position);
1822 function readAlias(state) {
1823 var _position, alias,
1826 ch = state.input.charCodeAt(state.position);
1828 if (ch !== 0x2A/* * */) return false;
1830 ch = state.input.charCodeAt(++state.position);
1831 _position = state.position;
1833 while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
1834 ch = state.input.charCodeAt(++state.position);
1837 if (state.position === _position) {
1838 throwError(state, 'name of an alias node must contain at least one character');
1841 alias = state.input.slice(_position, state.position);
1843 if (!state.anchorMap.hasOwnProperty(alias)) {
1844 throwError(state, 'unidentified alias "' + alias + '"');
1847 state.result = state.anchorMap[alias];
1848 skipSeparationSpace(state, true, -1);
1852 function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
1853 var allowBlockStyles,
1855 allowBlockCollections,
1856 indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this<parent
1865 if (state.listener !== null) {
1866 state.listener('open', state);
1870 state.anchor = null;
1872 state.result = null;
1874 allowBlockStyles = allowBlockScalars = allowBlockCollections =
1875 CONTEXT_BLOCK_OUT === nodeContext ||
1876 CONTEXT_BLOCK_IN === nodeContext;
1879 if (skipSeparationSpace(state, true, -1)) {
1882 if (state.lineIndent > parentIndent) {
1884 } else if (state.lineIndent === parentIndent) {
1886 } else if (state.lineIndent < parentIndent) {
1892 if (indentStatus === 1) {
1893 while (readTagProperty(state) || readAnchorProperty(state)) {
1894 if (skipSeparationSpace(state, true, -1)) {
1896 allowBlockCollections = allowBlockStyles;
1898 if (state.lineIndent > parentIndent) {
1900 } else if (state.lineIndent === parentIndent) {
1902 } else if (state.lineIndent < parentIndent) {
1906 allowBlockCollections = false;
1911 if (allowBlockCollections) {
1912 allowBlockCollections = atNewLine || allowCompact;
1915 if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
1916 if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
1917 flowIndent = parentIndent;
1919 flowIndent = parentIndent + 1;
1922 blockIndent = state.position - state.lineStart;
1924 if (indentStatus === 1) {
1925 if (allowBlockCollections &&
1926 (readBlockSequence(state, blockIndent) ||
1927 readBlockMapping(state, blockIndent, flowIndent)) ||
1928 readFlowCollection(state, flowIndent)) {
1931 if ((allowBlockScalars && readBlockScalar(state, flowIndent)) ||
1932 readSingleQuotedScalar(state, flowIndent) ||
1933 readDoubleQuotedScalar(state, flowIndent)) {
1936 } else if (readAlias(state)) {
1939 if (state.tag !== null || state.anchor !== null) {
1940 throwError(state, 'alias node should not have any properties');
1943 } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
1946 if (state.tag === null) {
1951 if (state.anchor !== null) {
1952 state.anchorMap[state.anchor] = state.result;
1955 } else if (indentStatus === 0) {
1956 // Special case: block sequences are allowed to have same indentation level as the parent.
1957 // http://www.yaml.org/spec/1.2/spec.html#id2799784
1958 hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
1962 if (state.tag !== null && state.tag !== '!') {
1963 if (state.tag === '?') {
1964 // Implicit resolving is not allowed for non-scalar types, and '?'
1965 // non-specific tag is only automatically assigned to plain scalars.
1967 // We only need to check kind conformity in case user explicitly assigns '?'
1968 // tag, for example like this: "!<?> [0]"
1970 if (state.result !== null && state.kind !== 'scalar') {
1971 throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
1974 for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
1975 type = state.implicitTypes[typeIndex];
1977 if (type.resolve(state.result)) { // `state.result` updated in resolver if matched
1978 state.result = type.construct(state.result);
1979 state.tag = type.tag;
1980 if (state.anchor !== null) {
1981 state.anchorMap[state.anchor] = state.result;
1986 } else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
1987 type = state.typeMap[state.kind || 'fallback'][state.tag];
1989 if (state.result !== null && type.kind !== state.kind) {
1990 throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
1993 if (!type.resolve(state.result)) { // `state.result` updated in resolver if matched
1994 throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag');
1996 state.result = type.construct(state.result);
1997 if (state.anchor !== null) {
1998 state.anchorMap[state.anchor] = state.result;
2002 throwError(state, 'unknown tag !<' + state.tag + '>');
2006 if (state.listener !== null) {
2007 state.listener('close', state);
2009 return state.tag !== null || state.anchor !== null || hasContent;
2012 function readDocument(state) {
2013 var documentStart = state.position,
2017 hasDirectives = false,
2020 state.version = null;
2021 state.checkLineBreaks = state.legacy;
2023 state.anchorMap = {};
2025 while ((ch = state.input.charCodeAt(state.position)) !== 0) {
2026 skipSeparationSpace(state, true, -1);
2028 ch = state.input.charCodeAt(state.position);
2030 if (state.lineIndent > 0 || ch !== 0x25/* % */) {
2034 hasDirectives = true;
2035 ch = state.input.charCodeAt(++state.position);
2036 _position = state.position;
2038 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2039 ch = state.input.charCodeAt(++state.position);
2042 directiveName = state.input.slice(_position, state.position);
2045 if (directiveName.length < 1) {
2046 throwError(state, 'directive name must not be less than one character in length');
2050 while (is_WHITE_SPACE(ch)) {
2051 ch = state.input.charCodeAt(++state.position);
2054 if (ch === 0x23/* # */) {
2055 do { ch = state.input.charCodeAt(++state.position); }
2056 while (ch !== 0 && !is_EOL(ch));
2060 if (is_EOL(ch)) break;
2062 _position = state.position;
2064 while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2065 ch = state.input.charCodeAt(++state.position);
2068 directiveArgs.push(state.input.slice(_position, state.position));
2071 if (ch !== 0) readLineBreak(state);
2073 if (_hasOwnProperty.call(directiveHandlers, directiveName)) {
2074 directiveHandlers[directiveName](state, directiveName, directiveArgs);
2076 throwWarning(state, 'unknown document directive "' + directiveName + '"');
2080 skipSeparationSpace(state, true, -1);
2082 if (state.lineIndent === 0 &&
2083 state.input.charCodeAt(state.position) === 0x2D/* - */ &&
2084 state.input.charCodeAt(state.position + 1) === 0x2D/* - */ &&
2085 state.input.charCodeAt(state.position + 2) === 0x2D/* - */) {
2086 state.position += 3;
2087 skipSeparationSpace(state, true, -1);
2089 } else if (hasDirectives) {
2090 throwError(state, 'directives end mark is expected');
2093 composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
2094 skipSeparationSpace(state, true, -1);
2096 if (state.checkLineBreaks &&
2097 PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
2098 throwWarning(state, 'non-ASCII line breaks are interpreted as content');
2101 state.documents.push(state.result);
2103 if (state.position === state.lineStart && testDocumentSeparator(state)) {
2105 if (state.input.charCodeAt(state.position) === 0x2E/* . */) {
2106 state.position += 3;
2107 skipSeparationSpace(state, true, -1);
2112 if (state.position < (state.length - 1)) {
2113 throwError(state, 'end of the stream or a document separator is expected');
2120 function loadDocuments(input, options) {
2121 input = String(input);
2122 options = options || {};
2124 if (input.length !== 0) {
2126 // Add tailing `\n` if not exists
2127 if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ &&
2128 input.charCodeAt(input.length - 1) !== 0x0D/* CR */) {
2133 if (input.charCodeAt(0) === 0xFEFF) {
2134 input = input.slice(1);
2138 var state = new State(input, options);
2140 var nullpos = input.indexOf('\0');
2142 if (nullpos !== -1) {
2143 state.position = nullpos;
2144 throwError(state, 'null byte is not allowed in input');
2147 // Use 0 as string terminator. That significantly simplifies bounds check.
2148 state.input += '\0';
2150 while (state.input.charCodeAt(state.position) === 0x20/* Space */) {
2151 state.lineIndent += 1;
2152 state.position += 1;
2155 while (state.position < (state.length - 1)) {
2156 readDocument(state);
2159 return state.documents;
2163 function loadAll(input, iterator, options) {
2164 if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') {
2169 var documents = loadDocuments(input, options);
2171 if (typeof iterator !== 'function') {
2175 for (var index = 0, length = documents.length; index < length; index += 1) {
2176 iterator(documents[index]);
2181 function load(input, options) {
2182 var documents = loadDocuments(input, options);
2184 if (documents.length === 0) {
2185 /*eslint-disable no-undefined*/
2187 } else if (documents.length === 1) {
2188 return documents[0];
2190 throw new YAMLException('expected a single document in the stream, but found more');
2194 function safeLoadAll(input, iterator, options) {
2195 if (typeof iterator === 'object' && iterator !== null && typeof options === 'undefined') {
2200 return loadAll(input, iterator, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
2204 function safeLoad(input, options) {
2205 return load(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
2209 module.exports.loadAll = loadAll;
2210 module.exports.load = load;
2211 module.exports.safeLoadAll = safeLoadAll;
2212 module.exports.safeLoad = safeLoad;
2217 /***/ (function(module, exports, __webpack_require__) {
2223 function isNothing(subject) {
2224 return (typeof subject === 'undefined') || (subject === null);
2228 function isObject(subject) {
2229 return (typeof subject === 'object') && (subject !== null);
2233 function toArray(sequence) {
2234 if (Array.isArray(sequence)) return sequence;
2235 else if (isNothing(sequence)) return [];
2237 return [ sequence ];
2241 function extend(target, source) {
2242 var index, length, key, sourceKeys;
2245 sourceKeys = Object.keys(source);
2247 for (index = 0, length = sourceKeys.length; index < length; index += 1) {
2248 key = sourceKeys[index];
2249 target[key] = source[key];
2257 function repeat(string, count) {
2258 var result = '', cycle;
2260 for (cycle = 0; cycle < count; cycle += 1) {
2268 function isNegativeZero(number) {
2269 return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number);
2273 module.exports.isNothing = isNothing;
2274 module.exports.isObject = isObject;
2275 module.exports.toArray = toArray;
2276 module.exports.repeat = repeat;
2277 module.exports.isNegativeZero = isNegativeZero;
2278 module.exports.extend = extend;
2283 /***/ (function(module, exports, __webpack_require__) {
2286 // YAML error class. http://stackoverflow.com/questions/8458984
2290 function YAMLException(reason, mark) {
2291 // Super constructor
2294 this.name = 'YAMLException';
2295 this.reason = reason;
2297 this.message = (this.reason || '(unknown reason)') + (this.mark ? ' ' + this.mark.toString() : '');
2299 // Include stack trace in error object
2300 if (Error.captureStackTrace) {
2301 // Chrome and NodeJS
2302 Error.captureStackTrace(this, this.constructor);
2304 // FF, IE 10+ and Safari 6+. Fallback for others
2305 this.stack = (new Error()).stack || '';
2310 // Inherit from Error
2311 YAMLException.prototype = Object.create(Error.prototype);
2312 YAMLException.prototype.constructor = YAMLException;
2315 YAMLException.prototype.toString = function toString(compact) {
2316 var result = this.name + ': ';
2318 result += this.reason || '(unknown reason)';
2320 if (!compact && this.mark) {
2321 result += ' ' + this.mark.toString();
2328 module.exports = YAMLException;
2333 /***/ (function(module, exports, __webpack_require__) {
2339 var common = __webpack_require__(8);
2342 function Mark(name, buffer, position, line, column) {
2344 this.buffer = buffer;
2345 this.position = position;
2347 this.column = column;
2351 Mark.prototype.getSnippet = function getSnippet(indent, maxLength) {
2352 var head, start, tail, end, snippet;
2354 if (!this.buffer) return null;
2356 indent = indent || 4;
2357 maxLength = maxLength || 75;
2360 start = this.position;
2362 while (start > 0 && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(start - 1)) === -1) {
2364 if (this.position - start > (maxLength / 2 - 1)) {
2372 end = this.position;
2374 while (end < this.buffer.length && '\x00\r\n\x85\u2028\u2029'.indexOf(this.buffer.charAt(end)) === -1) {
2376 if (end - this.position > (maxLength / 2 - 1)) {
2383 snippet = this.buffer.slice(start, end);
2385 return common.repeat(' ', indent) + head + snippet + tail + '\n' +
2386 common.repeat(' ', indent + this.position - start + head.length) + '^';
2390 Mark.prototype.toString = function toString(compact) {
2391 var snippet, where = '';
2394 where += 'in "' + this.name + '" ';
2397 where += 'at line ' + (this.line + 1) + ', column ' + (this.column + 1);
2400 snippet = this.getSnippet();
2403 where += ':\n' + snippet;
2411 module.exports = Mark;
2416 /***/ (function(module, exports, __webpack_require__) {
2419 // JS-YAML's default schema for `safeLoad` function.
2420 // It is not described in the YAML specification.
2422 // This schema is based on standard YAML's Core schema and includes most of
2423 // extra types described at YAML tag repository. (http://yaml.org/type/)
2429 var Schema = __webpack_require__(12);
2432 module.exports = new Schema({
2434 __webpack_require__(14)
2437 __webpack_require__(24),
2438 __webpack_require__(25)
2441 __webpack_require__(26),
2442 __webpack_require__(28),
2443 __webpack_require__(29),
2444 __webpack_require__(30)
2451 /***/ (function(module, exports, __webpack_require__) {
2456 /*eslint-disable max-len*/
2458 var common = __webpack_require__(8);
2459 var YAMLException = __webpack_require__(9);
2460 var Type = __webpack_require__(13);
2463 function compileList(schema, name, result) {
2466 schema.include.forEach(function (includedSchema) {
2467 result = compileList(includedSchema, name, result);
2470 schema[name].forEach(function (currentType) {
2471 result.forEach(function (previousType, previousIndex) {
2472 if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
2473 exclude.push(previousIndex);
2477 result.push(currentType);
2480 return result.filter(function (type, index) {
2481 return exclude.indexOf(index) === -1;
2486 function compileMap(/* lists... */) {
2494 function collectType(type) {
2495 result[type.kind][type.tag] = result['fallback'][type.tag] = type;
2498 for (index = 0, length = arguments.length; index < length; index += 1) {
2499 arguments[index].forEach(collectType);
2505 function Schema(definition) {
2506 this.include = definition.include || [];
2507 this.implicit = definition.implicit || [];
2508 this.explicit = definition.explicit || [];
2510 this.implicit.forEach(function (type) {
2511 if (type.loadKind && type.loadKind !== 'scalar') {
2512 throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.');
2516 this.compiledImplicit = compileList(this, 'implicit', []);
2517 this.compiledExplicit = compileList(this, 'explicit', []);
2518 this.compiledTypeMap = compileMap(this.compiledImplicit, this.compiledExplicit);
2522 Schema.DEFAULT = null;
2525 Schema.create = function createSchema() {
2528 switch (arguments.length) {
2530 schemas = Schema.DEFAULT;
2531 types = arguments[0];
2535 schemas = arguments[0];
2536 types = arguments[1];
2540 throw new YAMLException('Wrong number of arguments for Schema.create function');
2543 schemas = common.toArray(schemas);
2544 types = common.toArray(types);
2546 if (!schemas.every(function (schema) { return schema instanceof Schema; })) {
2547 throw new YAMLException('Specified list of super schemas (or a single Schema object) contains a non-Schema object.');
2550 if (!types.every(function (type) { return type instanceof Type; })) {
2551 throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.');
2561 module.exports = Schema;
2566 /***/ (function(module, exports, __webpack_require__) {
2571 var YAMLException = __webpack_require__(9);
2573 var TYPE_CONSTRUCTOR_OPTIONS = [
2584 var YAML_NODE_KINDS = [
2590 function compileStyleAliases(map) {
2594 Object.keys(map).forEach(function (style) {
2595 map[style].forEach(function (alias) {
2596 result[String(alias)] = style;
2604 function Type(tag, options) {
2605 options = options || {};
2607 Object.keys(options).forEach(function (name) {
2608 if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
2609 throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
2613 // TODO: Add tag format check.
2615 this.kind = options['kind'] || null;
2616 this.resolve = options['resolve'] || function () { return true; };
2617 this.construct = options['construct'] || function (data) { return data; };
2618 this.instanceOf = options['instanceOf'] || null;
2619 this.predicate = options['predicate'] || null;
2620 this.represent = options['represent'] || null;
2621 this.defaultStyle = options['defaultStyle'] || null;
2622 this.styleAliases = compileStyleAliases(options['styleAliases'] || null);
2624 if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
2625 throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
2629 module.exports = Type;
2634 /***/ (function(module, exports, __webpack_require__) {
2637 // Standard YAML's Core schema.
2638 // http://www.yaml.org/spec/1.2/spec.html#id2804923
2640 // NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
2641 // So, Core schema has no distinctions from JSON schema is JS-YAML.
2647 var Schema = __webpack_require__(12);
2650 module.exports = new Schema({
2652 __webpack_require__(15)
2659 /***/ (function(module, exports, __webpack_require__) {
2662 // Standard YAML's JSON schema.
2663 // http://www.yaml.org/spec/1.2/spec.html#id2803231
2665 // NOTE: JS-YAML does not support schema-specific tag resolution restrictions.
2666 // So, this schema is not such strict as defined in the YAML specification.
2667 // It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc.
2673 var Schema = __webpack_require__(12);
2676 module.exports = new Schema({
2678 __webpack_require__(16)
2681 __webpack_require__(20),
2682 __webpack_require__(21),
2683 __webpack_require__(22),
2684 __webpack_require__(23)
2691 /***/ (function(module, exports, __webpack_require__) {
2694 // Standard YAML's Failsafe schema.
2695 // http://www.yaml.org/spec/1.2/spec.html#id2802346
2701 var Schema = __webpack_require__(12);
2704 module.exports = new Schema({
2706 __webpack_require__(17),
2707 __webpack_require__(18),
2708 __webpack_require__(19)
2715 /***/ (function(module, exports, __webpack_require__) {
2720 var Type = __webpack_require__(13);
2722 module.exports = new Type('tag:yaml.org,2002:str', {
2724 construct: function (data) { return data !== null ? data : ''; }
2730 /***/ (function(module, exports, __webpack_require__) {
2735 var Type = __webpack_require__(13);
2737 module.exports = new Type('tag:yaml.org,2002:seq', {
2739 construct: function (data) { return data !== null ? data : []; }
2745 /***/ (function(module, exports, __webpack_require__) {
2750 var Type = __webpack_require__(13);
2752 module.exports = new Type('tag:yaml.org,2002:map', {
2754 construct: function (data) { return data !== null ? data : {}; }
2760 /***/ (function(module, exports, __webpack_require__) {
2765 var Type = __webpack_require__(13);
2767 function resolveYamlNull(data) {
2768 if (data === null) return true;
2770 var max = data.length;
2772 return (max === 1 && data === '~') ||
2773 (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'));
2776 function constructYamlNull() {
2780 function isNull(object) {
2781 return object === null;
2784 module.exports = new Type('tag:yaml.org,2002:null', {
2786 resolve: resolveYamlNull,
2787 construct: constructYamlNull,
2790 canonical: function () { return '~'; },
2791 lowercase: function () { return 'null'; },
2792 uppercase: function () { return 'NULL'; },
2793 camelcase: function () { return 'Null'; }
2795 defaultStyle: 'lowercase'
2801 /***/ (function(module, exports, __webpack_require__) {
2806 var Type = __webpack_require__(13);
2808 function resolveYamlBoolean(data) {
2809 if (data === null) return false;
2811 var max = data.length;
2813 return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) ||
2814 (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE'));
2817 function constructYamlBoolean(data) {
2818 return data === 'true' ||
2823 function isBoolean(object) {
2824 return Object.prototype.toString.call(object) === '[object Boolean]';
2827 module.exports = new Type('tag:yaml.org,2002:bool', {
2829 resolve: resolveYamlBoolean,
2830 construct: constructYamlBoolean,
2831 predicate: isBoolean,
2833 lowercase: function (object) { return object ? 'true' : 'false'; },
2834 uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; },
2835 camelcase: function (object) { return object ? 'True' : 'False'; }
2837 defaultStyle: 'lowercase'
2843 /***/ (function(module, exports, __webpack_require__) {
2848 var common = __webpack_require__(8);
2849 var Type = __webpack_require__(13);
2851 function isHexCode(c) {
2852 return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) ||
2853 ((0x41/* A */ <= c) && (c <= 0x46/* F */)) ||
2854 ((0x61/* a */ <= c) && (c <= 0x66/* f */));
2857 function isOctCode(c) {
2858 return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */));
2861 function isDecCode(c) {
2862 return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */));
2865 function resolveYamlInteger(data) {
2866 if (data === null) return false;
2868 var max = data.length,
2873 if (!max) return false;
2878 if (ch === '-' || ch === '+') {
2884 if (index + 1 === max) return true;
2887 // base 2, base 8, base 16
2893 for (; index < max; index++) {
2895 if (ch === '_') continue;
2896 if (ch !== '0' && ch !== '1') return false;
2899 return hasDigits && ch !== '_';
2907 for (; index < max; index++) {
2909 if (ch === '_') continue;
2910 if (!isHexCode(data.charCodeAt(index))) return false;
2913 return hasDigits && ch !== '_';
2917 for (; index < max; index++) {
2919 if (ch === '_') continue;
2920 if (!isOctCode(data.charCodeAt(index))) return false;
2923 return hasDigits && ch !== '_';
2926 // base 10 (except 0) or base 60
2928 // value should not start with `_`;
2929 if (ch === '_') return false;
2931 for (; index < max; index++) {
2933 if (ch === '_') continue;
2934 if (ch === ':') break;
2935 if (!isDecCode(data.charCodeAt(index))) {
2941 // Should have digits and should not end with `_`
2942 if (!hasDigits || ch === '_') return false;
2944 // if !base60 - done;
2945 if (ch !== ':') return true;
2947 // base60 almost not used, no needs to optimize
2948 return /^(:[0-5]?[0-9])+$/.test(data.slice(index));
2951 function constructYamlInteger(data) {
2952 var value = data, sign = 1, ch, base, digits = [];
2954 if (value.indexOf('_') !== -1) {
2955 value = value.replace(/_/g, '');
2960 if (ch === '-' || ch === '+') {
2961 if (ch === '-') sign = -1;
2962 value = value.slice(1);
2966 if (value === '0') return 0;
2969 if (value[1] === 'b') return sign * parseInt(value.slice(2), 2);
2970 if (value[1] === 'x') return sign * parseInt(value, 16);
2971 return sign * parseInt(value, 8);
2974 if (value.indexOf(':') !== -1) {
2975 value.split(':').forEach(function (v) {
2976 digits.unshift(parseInt(v, 10));
2982 digits.forEach(function (d) {
2983 value += (d * base);
2987 return sign * value;
2991 return sign * parseInt(value, 10);
2994 function isInteger(object) {
2995 return (Object.prototype.toString.call(object)) === '[object Number]' &&
2996 (object % 1 === 0 && !common.isNegativeZero(object));
2999 module.exports = new Type('tag:yaml.org,2002:int', {
3001 resolve: resolveYamlInteger,
3002 construct: constructYamlInteger,
3003 predicate: isInteger,
3005 binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); },
3006 octal: function (obj) { return obj >= 0 ? '0' + obj.toString(8) : '-0' + obj.toString(8).slice(1); },
3007 decimal: function (obj) { return obj.toString(10); },
3008 /* eslint-disable max-len */
3009 hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); }
3011 defaultStyle: 'decimal',
3013 binary: [ 2, 'bin' ],
3014 octal: [ 8, 'oct' ],
3015 decimal: [ 10, 'dec' ],
3016 hexadecimal: [ 16, 'hex' ]
3023 /***/ (function(module, exports, __webpack_require__) {
3028 var common = __webpack_require__(8);
3029 var Type = __webpack_require__(13);
3031 var YAML_FLOAT_PATTERN = new RegExp(
3032 // 2.5e4, 2.5 and integers
3033 '^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' +
3035 // special case, seems not from spec
3036 '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' +
3038 '|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*' +
3040 '|[-+]?\\.(?:inf|Inf|INF)' +
3042 '|\\.(?:nan|NaN|NAN))$');
3044 function resolveYamlFloat(data) {
3045 if (data === null) return false;
3047 if (!YAML_FLOAT_PATTERN.test(data) ||
3048 // Quick hack to not allow integers end with `_`
3049 // Probably should update regexp & check speed
3050 data[data.length - 1] === '_') {
3057 function constructYamlFloat(data) {
3058 var value, sign, base, digits;
3060 value = data.replace(/_/g, '').toLowerCase();
3061 sign = value[0] === '-' ? -1 : 1;
3064 if ('+-'.indexOf(value[0]) >= 0) {
3065 value = value.slice(1);
3068 if (value === '.inf') {
3069 return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
3071 } else if (value === '.nan') {
3074 } else if (value.indexOf(':') >= 0) {
3075 value.split(':').forEach(function (v) {
3076 digits.unshift(parseFloat(v, 10));
3082 digits.forEach(function (d) {
3087 return sign * value;
3090 return sign * parseFloat(value, 10);
3094 var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
3096 function representYamlFloat(object, style) {
3099 if (isNaN(object)) {
3101 case 'lowercase': return '.nan';
3102 case 'uppercase': return '.NAN';
3103 case 'camelcase': return '.NaN';
3105 } else if (Number.POSITIVE_INFINITY === object) {
3107 case 'lowercase': return '.inf';
3108 case 'uppercase': return '.INF';
3109 case 'camelcase': return '.Inf';
3111 } else if (Number.NEGATIVE_INFINITY === object) {
3113 case 'lowercase': return '-.inf';
3114 case 'uppercase': return '-.INF';
3115 case 'camelcase': return '-.Inf';
3117 } else if (common.isNegativeZero(object)) {
3121 res = object.toString(10);
3123 // JS stringifier can build scientific format without dots: 5e-100,
3124 // while YAML requres dot: 5.e-100. Fix it with simple hack
3126 return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res;
3129 function isFloat(object) {
3130 return (Object.prototype.toString.call(object) === '[object Number]') &&
3131 (object % 1 !== 0 || common.isNegativeZero(object));
3134 module.exports = new Type('tag:yaml.org,2002:float', {
3136 resolve: resolveYamlFloat,
3137 construct: constructYamlFloat,
3139 represent: representYamlFloat,
3140 defaultStyle: 'lowercase'
3146 /***/ (function(module, exports, __webpack_require__) {
3151 var Type = __webpack_require__(13);
3153 var YAML_DATE_REGEXP = new RegExp(
3154 '^([0-9][0-9][0-9][0-9])' + // [1] year
3155 '-([0-9][0-9])' + // [2] month
3156 '-([0-9][0-9])$'); // [3] day
3158 var YAML_TIMESTAMP_REGEXP = new RegExp(
3159 '^([0-9][0-9][0-9][0-9])' + // [1] year
3160 '-([0-9][0-9]?)' + // [2] month
3161 '-([0-9][0-9]?)' + // [3] day
3162 '(?:[Tt]|[ \\t]+)' + // ...
3163 '([0-9][0-9]?)' + // [4] hour
3164 ':([0-9][0-9])' + // [5] minute
3165 ':([0-9][0-9])' + // [6] second
3166 '(?:\\.([0-9]*))?' + // [7] fraction
3167 '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour
3168 '(?::([0-9][0-9]))?))?$'); // [11] tz_minute
3170 function resolveYamlTimestamp(data) {
3171 if (data === null) return false;
3172 if (YAML_DATE_REGEXP.exec(data) !== null) return true;
3173 if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
3177 function constructYamlTimestamp(data) {
3178 var match, year, month, day, hour, minute, second, fraction = 0,
3179 delta = null, tz_hour, tz_minute, date;
3181 match = YAML_DATE_REGEXP.exec(data);
3182 if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
3184 if (match === null) throw new Error('Date resolve error');
3186 // match: [1] year [2] month [3] day
3189 month = +(match[2]) - 1; // JS month starts with 0
3192 if (!match[4]) { // no hour
3193 return new Date(Date.UTC(year, month, day));
3196 // match: [4] hour [5] minute [6] second [7] fraction
3199 minute = +(match[5]);
3200 second = +(match[6]);
3203 fraction = match[7].slice(0, 3);
3204 while (fraction.length < 3) { // milli-seconds
3207 fraction = +fraction;
3210 // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
3213 tz_hour = +(match[10]);
3214 tz_minute = +(match[11] || 0);
3215 delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds
3216 if (match[9] === '-') delta = -delta;
3219 date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
3221 if (delta) date.setTime(date.getTime() - delta);
3226 function representYamlTimestamp(object /*, style*/) {
3227 return object.toISOString();
3230 module.exports = new Type('tag:yaml.org,2002:timestamp', {
3232 resolve: resolveYamlTimestamp,
3233 construct: constructYamlTimestamp,
3235 represent: representYamlTimestamp
3241 /***/ (function(module, exports, __webpack_require__) {
3246 var Type = __webpack_require__(13);
3248 function resolveYamlMerge(data) {
3249 return data === '<<' || data === null;
3252 module.exports = new Type('tag:yaml.org,2002:merge', {
3254 resolve: resolveYamlMerge
3260 /***/ (function(module, exports, __webpack_require__) {
3265 /*eslint-disable no-bitwise*/
3270 // A trick for browserified version, to not include `Buffer` shim
3271 var _require = require;
3272 NodeBuffer = __webpack_require__(27).Buffer;
3275 var Type = __webpack_require__(13);
3278 // [ 64, 65, 66 ] -> [ padding, CR, LF ]
3279 var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r';
3282 function resolveYamlBinary(data) {
3283 if (data === null) return false;
3285 var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP;
3287 // Convert one by one.
3288 for (idx = 0; idx < max; idx++) {
3289 code = map.indexOf(data.charAt(idx));
3292 if (code > 64) continue;
3294 // Fail on illegal characters
3295 if (code < 0) return false;
3300 // If there are any bits left, source was corrupted
3301 return (bitlen % 8) === 0;
3304 function constructYamlBinary(data) {
3306 input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan
3312 // Collect by 6*4 bits (3 bytes)
3314 for (idx = 0; idx < max; idx++) {
3315 if ((idx % 4 === 0) && idx) {
3316 result.push((bits >> 16) & 0xFF);
3317 result.push((bits >> 8) & 0xFF);
3318 result.push(bits & 0xFF);
3321 bits = (bits << 6) | map.indexOf(input.charAt(idx));
3326 tailbits = (max % 4) * 6;
3328 if (tailbits === 0) {
3329 result.push((bits >> 16) & 0xFF);
3330 result.push((bits >> 8) & 0xFF);
3331 result.push(bits & 0xFF);
3332 } else if (tailbits === 18) {
3333 result.push((bits >> 10) & 0xFF);
3334 result.push((bits >> 2) & 0xFF);
3335 } else if (tailbits === 12) {
3336 result.push((bits >> 4) & 0xFF);
3339 // Wrap into Buffer for NodeJS and leave Array for browser
3341 // Support node 6.+ Buffer API when available
3342 return NodeBuffer.from ? NodeBuffer.from(result) : new NodeBuffer(result);
3348 function representYamlBinary(object /*, style*/) {
3349 var result = '', bits = 0, idx, tail,
3350 max = object.length,
3353 // Convert every three bytes to 4 ASCII characters.
3355 for (idx = 0; idx < max; idx++) {
3356 if ((idx % 3 === 0) && idx) {
3357 result += map[(bits >> 18) & 0x3F];
3358 result += map[(bits >> 12) & 0x3F];
3359 result += map[(bits >> 6) & 0x3F];
3360 result += map[bits & 0x3F];
3363 bits = (bits << 8) + object[idx];
3371 result += map[(bits >> 18) & 0x3F];
3372 result += map[(bits >> 12) & 0x3F];
3373 result += map[(bits >> 6) & 0x3F];
3374 result += map[bits & 0x3F];
3375 } else if (tail === 2) {
3376 result += map[(bits >> 10) & 0x3F];
3377 result += map[(bits >> 4) & 0x3F];
3378 result += map[(bits << 2) & 0x3F];
3380 } else if (tail === 1) {
3381 result += map[(bits >> 2) & 0x3F];
3382 result += map[(bits << 4) & 0x3F];
3390 function isBinary(object) {
3391 return NodeBuffer && NodeBuffer.isBuffer(object);
3394 module.exports = new Type('tag:yaml.org,2002:binary', {
3396 resolve: resolveYamlBinary,
3397 construct: constructYamlBinary,
3398 predicate: isBinary,
3399 represent: representYamlBinary
3405 /***/ (function(module, exports) {
3407 module.exports = require("buffer");
3411 /***/ (function(module, exports, __webpack_require__) {
3416 var Type = __webpack_require__(13);
3418 var _hasOwnProperty = Object.prototype.hasOwnProperty;
3419 var _toString = Object.prototype.toString;
3421 function resolveYamlOmap(data) {
3422 if (data === null) return true;
3424 var objectKeys = [], index, length, pair, pairKey, pairHasKey,
3427 for (index = 0, length = object.length; index < length; index += 1) {
3428 pair = object[index];
3431 if (_toString.call(pair) !== '[object Object]') return false;
3433 for (pairKey in pair) {
3434 if (_hasOwnProperty.call(pair, pairKey)) {
3435 if (!pairHasKey) pairHasKey = true;
3440 if (!pairHasKey) return false;
3442 if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey);
3449 function constructYamlOmap(data) {
3450 return data !== null ? data : [];
3453 module.exports = new Type('tag:yaml.org,2002:omap', {
3455 resolve: resolveYamlOmap,
3456 construct: constructYamlOmap
3462 /***/ (function(module, exports, __webpack_require__) {
3467 var Type = __webpack_require__(13);
3469 var _toString = Object.prototype.toString;
3471 function resolveYamlPairs(data) {
3472 if (data === null) return true;
3474 var index, length, pair, keys, result,
3477 result = new Array(object.length);
3479 for (index = 0, length = object.length; index < length; index += 1) {
3480 pair = object[index];
3482 if (_toString.call(pair) !== '[object Object]') return false;
3484 keys = Object.keys(pair);
3486 if (keys.length !== 1) return false;
3488 result[index] = [ keys[0], pair[keys[0]] ];
3494 function constructYamlPairs(data) {
3495 if (data === null) return [];
3497 var index, length, pair, keys, result,
3500 result = new Array(object.length);
3502 for (index = 0, length = object.length; index < length; index += 1) {
3503 pair = object[index];
3505 keys = Object.keys(pair);
3507 result[index] = [ keys[0], pair[keys[0]] ];
3513 module.exports = new Type('tag:yaml.org,2002:pairs', {
3515 resolve: resolveYamlPairs,
3516 construct: constructYamlPairs
3522 /***/ (function(module, exports, __webpack_require__) {
3527 var Type = __webpack_require__(13);
3529 var _hasOwnProperty = Object.prototype.hasOwnProperty;
3531 function resolveYamlSet(data) {
3532 if (data === null) return true;
3534 var key, object = data;
3536 for (key in object) {
3537 if (_hasOwnProperty.call(object, key)) {
3538 if (object[key] !== null) return false;
3545 function constructYamlSet(data) {
3546 return data !== null ? data : {};
3549 module.exports = new Type('tag:yaml.org,2002:set', {
3551 resolve: resolveYamlSet,
3552 construct: constructYamlSet
3558 /***/ (function(module, exports, __webpack_require__) {
3561 // JS-YAML's default schema for `load` function.
3562 // It is not described in the YAML specification.
3564 // This schema is based on JS-YAML's default safe schema and includes
3565 // JavaScript-specific types: !!js/undefined, !!js/regexp and !!js/function.
3567 // Also this schema is used as default base schema at `Schema.create` function.
3573 var Schema = __webpack_require__(12);
3576 module.exports = Schema.DEFAULT = new Schema({
3578 __webpack_require__(11)
3581 __webpack_require__(32),
3582 __webpack_require__(33),
3583 __webpack_require__(34)
3590 /***/ (function(module, exports, __webpack_require__) {
3595 var Type = __webpack_require__(13);
3597 function resolveJavascriptUndefined() {
3601 function constructJavascriptUndefined() {
3602 /*eslint-disable no-undefined*/
3606 function representJavascriptUndefined() {
3610 function isUndefined(object) {
3611 return typeof object === 'undefined';
3614 module.exports = new Type('tag:yaml.org,2002:js/undefined', {
3616 resolve: resolveJavascriptUndefined,
3617 construct: constructJavascriptUndefined,
3618 predicate: isUndefined,
3619 represent: representJavascriptUndefined
3625 /***/ (function(module, exports, __webpack_require__) {
3630 var Type = __webpack_require__(13);
3632 function resolveJavascriptRegExp(data) {
3633 if (data === null) return false;
3634 if (data.length === 0) return false;
3637 tail = /\/([gim]*)$/.exec(data),
3640 // if regexp starts with '/' it can have modifiers and must be properly closed
3641 // `/foo/gim` - modifiers tail can be maximum 3 chars
3642 if (regexp[0] === '/') {
3643 if (tail) modifiers = tail[1];
3645 if (modifiers.length > 3) return false;
3646 // if expression starts with /, is should be properly terminated
3647 if (regexp[regexp.length - modifiers.length - 1] !== '/') return false;
3653 function constructJavascriptRegExp(data) {
3655 tail = /\/([gim]*)$/.exec(data),
3658 // `/foo/gim` - tail can be maximum 4 chars
3659 if (regexp[0] === '/') {
3660 if (tail) modifiers = tail[1];
3661 regexp = regexp.slice(1, regexp.length - modifiers.length - 1);
3664 return new RegExp(regexp, modifiers);
3667 function representJavascriptRegExp(object /*, style*/) {
3668 var result = '/' + object.source + '/';
3670 if (object.global) result += 'g';
3671 if (object.multiline) result += 'm';
3672 if (object.ignoreCase) result += 'i';
3677 function isRegExp(object) {
3678 return Object.prototype.toString.call(object) === '[object RegExp]';
3681 module.exports = new Type('tag:yaml.org,2002:js/regexp', {
3683 resolve: resolveJavascriptRegExp,
3684 construct: constructJavascriptRegExp,
3685 predicate: isRegExp,
3686 represent: representJavascriptRegExp
3692 /***/ (function(module, exports, __webpack_require__) {
3699 // Browserified version does not have esprima
3701 // 1. For node.js just require module as deps
3702 // 2. For browser try to require mudule via external AMD system.
3703 // If not found - try to fallback to window.esprima. If not
3704 // found too - then fail to parse.
3707 // workaround to exclude package from browserify list.
3708 var _require = require;
3709 esprima = __webpack_require__(35);
3711 /* eslint-disable no-redeclare */
3713 if (typeof window !== 'undefined') esprima = window.esprima;
3716 var Type = __webpack_require__(13);
3718 function resolveJavascriptFunction(data) {
3719 if (data === null) return false;
3722 var source = '(' + data + ')',
3723 ast = esprima.parse(source, { range: true });
3725 if (ast.type !== 'Program' ||
3726 ast.body.length !== 1 ||
3727 ast.body[0].type !== 'ExpressionStatement' ||
3728 (ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
3729 ast.body[0].expression.type !== 'FunctionExpression')) {
3739 function constructJavascriptFunction(data) {
3740 /*jslint evil:true*/
3742 var source = '(' + data + ')',
3743 ast = esprima.parse(source, { range: true }),
3747 if (ast.type !== 'Program' ||
3748 ast.body.length !== 1 ||
3749 ast.body[0].type !== 'ExpressionStatement' ||
3750 (ast.body[0].expression.type !== 'ArrowFunctionExpression' &&
3751 ast.body[0].expression.type !== 'FunctionExpression')) {
3752 throw new Error('Failed to resolve function');
3755 ast.body[0].expression.params.forEach(function (param) {
3756 params.push(param.name);
3759 body = ast.body[0].expression.body.range;
3761 // Esprima's ranges include the first '{' and the last '}' characters on
3762 // function expressions. So cut them out.
3763 if (ast.body[0].expression.body.type === 'BlockStatement') {
3764 /*eslint-disable no-new-func*/
3765 return new Function(params, source.slice(body[0] + 1, body[1] - 1));
3767 // ES6 arrow functions can omit the BlockStatement. In that case, just return
3769 /*eslint-disable no-new-func*/
3770 return new Function(params, 'return ' + source.slice(body[0], body[1]));
3773 function representJavascriptFunction(object /*, style*/) {
3774 return object.toString();
3777 function isFunction(object) {
3778 return Object.prototype.toString.call(object) === '[object Function]';
3781 module.exports = new Type('tag:yaml.org,2002:js/function', {
3783 resolve: resolveJavascriptFunction,
3784 construct: constructJavascriptFunction,
3785 predicate: isFunction,
3786 represent: representJavascriptFunction
3792 /***/ (function(module, exports, __webpack_require__) {
3794 (function webpackUniversalModuleDefinition(root, factory) {
3795 /* istanbul ignore next */
3797 module.exports = factory();
3799 })(this, function() {
3800 return /******/ (function(modules) { // webpackBootstrap
3801 /******/ // The module cache
3802 /******/ var installedModules = {};
3804 /******/ // The require function
3805 /******/ function __webpack_require__(moduleId) {
3807 /******/ // Check if module is in cache
3808 /* istanbul ignore if */
3809 /******/ if(installedModules[moduleId])
3810 /******/ return installedModules[moduleId].exports;
3812 /******/ // Create a new module (and put it into the cache)
3813 /******/ var module = installedModules[moduleId] = {
3814 /******/ exports: {},
3815 /******/ id: moduleId,
3816 /******/ loaded: false
3819 /******/ // Execute the module function
3820 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
3822 /******/ // Flag the module as loaded
3823 /******/ module.loaded = true;
3825 /******/ // Return the exports of the module
3826 /******/ return module.exports;
3830 /******/ // expose the modules object (__webpack_modules__)
3831 /******/ __webpack_require__.m = modules;
3833 /******/ // expose the module cache
3834 /******/ __webpack_require__.c = installedModules;
3836 /******/ // __webpack_public_path__
3837 /******/ __webpack_require__.p = "";
3839 /******/ // Load entry module and return exports
3840 /******/ return __webpack_require__(0);
3842 /************************************************************************/
3845 /***/ function(module, exports, __webpack_require__) {
3849 Copyright JS Foundation and other contributors, https://js.foundation/
3851 Redistribution and use in source and binary forms, with or without
3852 modification, are permitted provided that the following conditions are met:
3854 * Redistributions of source code must retain the above copyright
3855 notice, this list of conditions and the following disclaimer.
3856 * Redistributions in binary form must reproduce the above copyright
3857 notice, this list of conditions and the following disclaimer in the
3858 documentation and/or other materials provided with the distribution.
3860 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
3861 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3862 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3863 ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
3864 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
3865 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
3866 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
3867 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
3868 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
3869 THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3871 Object.defineProperty(exports, "__esModule", { value: true });
3872 var comment_handler_1 = __webpack_require__(1);
3873 var jsx_parser_1 = __webpack_require__(3);
3874 var parser_1 = __webpack_require__(8);
3875 var tokenizer_1 = __webpack_require__(15);
3876 function parse(code, options, delegate) {
3877 var commentHandler = null;
3878 var proxyDelegate = function (node, metadata) {
3880 delegate(node, metadata);
3882 if (commentHandler) {
3883 commentHandler.visit(node, metadata);
3886 var parserDelegate = (typeof delegate === 'function') ? proxyDelegate : null;
3887 var collectComment = false;
3889 collectComment = (typeof options.comment === 'boolean' && options.comment);
3890 var attachComment = (typeof options.attachComment === 'boolean' && options.attachComment);
3891 if (collectComment || attachComment) {
3892 commentHandler = new comment_handler_1.CommentHandler();
3893 commentHandler.attach = attachComment;
3894 options.comment = true;
3895 parserDelegate = proxyDelegate;
3898 var isModule = false;
3899 if (options && typeof options.sourceType === 'string') {
3900 isModule = (options.sourceType === 'module');
3903 if (options && typeof options.jsx === 'boolean' && options.jsx) {
3904 parser = new jsx_parser_1.JSXParser(code, options, parserDelegate);
3907 parser = new parser_1.Parser(code, options, parserDelegate);
3909 var program = isModule ? parser.parseModule() : parser.parseScript();
3911 if (collectComment && commentHandler) {
3912 ast.comments = commentHandler.comments;
3914 if (parser.config.tokens) {
3915 ast.tokens = parser.tokens;
3917 if (parser.config.tolerant) {
3918 ast.errors = parser.errorHandler.errors;
3922 exports.parse = parse;
3923 function parseModule(code, options, delegate) {
3924 var parsingOptions = options || {};
3925 parsingOptions.sourceType = 'module';
3926 return parse(code, parsingOptions, delegate);
3928 exports.parseModule = parseModule;
3929 function parseScript(code, options, delegate) {
3930 var parsingOptions = options || {};
3931 parsingOptions.sourceType = 'script';
3932 return parse(code, parsingOptions, delegate);
3934 exports.parseScript = parseScript;
3935 function tokenize(code, options, delegate) {
3936 var tokenizer = new tokenizer_1.Tokenizer(code, options);
3941 var token = tokenizer.getNextToken();
3946 token = delegate(token);
3952 tokenizer.errorHandler.tolerate(e);
3954 if (tokenizer.errorHandler.tolerant) {
3955 tokens.errors = tokenizer.errors();
3959 exports.tokenize = tokenize;
3960 var syntax_1 = __webpack_require__(2);
3961 exports.Syntax = syntax_1.Syntax;
3962 // Sync with *.json manifests.
3963 exports.version = '4.0.1';
3968 /***/ function(module, exports, __webpack_require__) {
3971 Object.defineProperty(exports, "__esModule", { value: true });
3972 var syntax_1 = __webpack_require__(2);
3973 var CommentHandler = (function () {
3974 function CommentHandler() {
3975 this.attach = false;
3981 CommentHandler.prototype.insertInnerComments = function (node, metadata) {
3982 // innnerComments for properties empty block
3983 // `function a() {/** comments **\/}`
3984 if (node.type === syntax_1.Syntax.BlockStatement && node.body.length === 0) {
3985 var innerComments = [];
3986 for (var i = this.leading.length - 1; i >= 0; --i) {
3987 var entry = this.leading[i];
3988 if (metadata.end.offset >= entry.start) {
3989 innerComments.unshift(entry.comment);
3990 this.leading.splice(i, 1);
3991 this.trailing.splice(i, 1);
3994 if (innerComments.length) {
3995 node.innerComments = innerComments;
3999 CommentHandler.prototype.findTrailingComments = function (metadata) {
4000 var trailingComments = [];
4001 if (this.trailing.length > 0) {
4002 for (var i = this.trailing.length - 1; i >= 0; --i) {
4003 var entry_1 = this.trailing[i];
4004 if (entry_1.start >= metadata.end.offset) {
4005 trailingComments.unshift(entry_1.comment);
4008 this.trailing.length = 0;
4009 return trailingComments;
4011 var entry = this.stack[this.stack.length - 1];
4012 if (entry && entry.node.trailingComments) {
4013 var firstComment = entry.node.trailingComments[0];
4014 if (firstComment && firstComment.range[0] >= metadata.end.offset) {
4015 trailingComments = entry.node.trailingComments;
4016 delete entry.node.trailingComments;
4019 return trailingComments;
4021 CommentHandler.prototype.findLeadingComments = function (metadata) {
4022 var leadingComments = [];
4024 while (this.stack.length > 0) {
4025 var entry = this.stack[this.stack.length - 1];
4026 if (entry && entry.start >= metadata.start.offset) {
4027 target = entry.node;
4035 var count = target.leadingComments ? target.leadingComments.length : 0;
4036 for (var i = count - 1; i >= 0; --i) {
4037 var comment = target.leadingComments[i];
4038 if (comment.range[1] <= metadata.start.offset) {
4039 leadingComments.unshift(comment);
4040 target.leadingComments.splice(i, 1);
4043 if (target.leadingComments && target.leadingComments.length === 0) {
4044 delete target.leadingComments;
4046 return leadingComments;
4048 for (var i = this.leading.length - 1; i >= 0; --i) {
4049 var entry = this.leading[i];
4050 if (entry.start <= metadata.start.offset) {
4051 leadingComments.unshift(entry.comment);
4052 this.leading.splice(i, 1);
4055 return leadingComments;
4057 CommentHandler.prototype.visitNode = function (node, metadata) {
4058 if (node.type === syntax_1.Syntax.Program && node.body.length > 0) {
4061 this.insertInnerComments(node, metadata);
4062 var trailingComments = this.findTrailingComments(metadata);
4063 var leadingComments = this.findLeadingComments(metadata);
4064 if (leadingComments.length > 0) {
4065 node.leadingComments = leadingComments;
4067 if (trailingComments.length > 0) {
4068 node.trailingComments = trailingComments;
4072 start: metadata.start.offset
4075 CommentHandler.prototype.visitComment = function (node, metadata) {
4076 var type = (node.type[0] === 'L') ? 'Line' : 'Block';
4082 comment.range = node.range;
4085 comment.loc = node.loc;
4087 this.comments.push(comment);
4093 range: [metadata.start.offset, metadata.end.offset]
4095 start: metadata.start.offset
4098 entry.comment.loc = node.loc;
4101 this.leading.push(entry);
4102 this.trailing.push(entry);
4105 CommentHandler.prototype.visit = function (node, metadata) {
4106 if (node.type === 'LineComment') {
4107 this.visitComment(node, metadata);
4109 else if (node.type === 'BlockComment') {
4110 this.visitComment(node, metadata);
4112 else if (this.attach) {
4113 this.visitNode(node, metadata);
4116 return CommentHandler;
4118 exports.CommentHandler = CommentHandler;
4123 /***/ function(module, exports) {
4126 Object.defineProperty(exports, "__esModule", { value: true });
4128 AssignmentExpression: 'AssignmentExpression',
4129 AssignmentPattern: 'AssignmentPattern',
4130 ArrayExpression: 'ArrayExpression',
4131 ArrayPattern: 'ArrayPattern',
4132 ArrowFunctionExpression: 'ArrowFunctionExpression',
4133 AwaitExpression: 'AwaitExpression',
4134 BlockStatement: 'BlockStatement',
4135 BinaryExpression: 'BinaryExpression',
4136 BreakStatement: 'BreakStatement',
4137 CallExpression: 'CallExpression',
4138 CatchClause: 'CatchClause',
4139 ClassBody: 'ClassBody',
4140 ClassDeclaration: 'ClassDeclaration',
4141 ClassExpression: 'ClassExpression',
4142 ConditionalExpression: 'ConditionalExpression',
4143 ContinueStatement: 'ContinueStatement',
4144 DoWhileStatement: 'DoWhileStatement',
4145 DebuggerStatement: 'DebuggerStatement',
4146 EmptyStatement: 'EmptyStatement',
4147 ExportAllDeclaration: 'ExportAllDeclaration',
4148 ExportDefaultDeclaration: 'ExportDefaultDeclaration',
4149 ExportNamedDeclaration: 'ExportNamedDeclaration',
4150 ExportSpecifier: 'ExportSpecifier',
4151 ExpressionStatement: 'ExpressionStatement',
4152 ForStatement: 'ForStatement',
4153 ForOfStatement: 'ForOfStatement',
4154 ForInStatement: 'ForInStatement',
4155 FunctionDeclaration: 'FunctionDeclaration',
4156 FunctionExpression: 'FunctionExpression',
4157 Identifier: 'Identifier',
4158 IfStatement: 'IfStatement',
4159 ImportDeclaration: 'ImportDeclaration',
4160 ImportDefaultSpecifier: 'ImportDefaultSpecifier',
4161 ImportNamespaceSpecifier: 'ImportNamespaceSpecifier',
4162 ImportSpecifier: 'ImportSpecifier',
4164 LabeledStatement: 'LabeledStatement',
4165 LogicalExpression: 'LogicalExpression',
4166 MemberExpression: 'MemberExpression',
4167 MetaProperty: 'MetaProperty',
4168 MethodDefinition: 'MethodDefinition',
4169 NewExpression: 'NewExpression',
4170 ObjectExpression: 'ObjectExpression',
4171 ObjectPattern: 'ObjectPattern',
4173 Property: 'Property',
4174 RestElement: 'RestElement',
4175 ReturnStatement: 'ReturnStatement',
4176 SequenceExpression: 'SequenceExpression',
4177 SpreadElement: 'SpreadElement',
4179 SwitchCase: 'SwitchCase',
4180 SwitchStatement: 'SwitchStatement',
4181 TaggedTemplateExpression: 'TaggedTemplateExpression',
4182 TemplateElement: 'TemplateElement',
4183 TemplateLiteral: 'TemplateLiteral',
4184 ThisExpression: 'ThisExpression',
4185 ThrowStatement: 'ThrowStatement',
4186 TryStatement: 'TryStatement',
4187 UnaryExpression: 'UnaryExpression',
4188 UpdateExpression: 'UpdateExpression',
4189 VariableDeclaration: 'VariableDeclaration',
4190 VariableDeclarator: 'VariableDeclarator',
4191 WhileStatement: 'WhileStatement',
4192 WithStatement: 'WithStatement',
4193 YieldExpression: 'YieldExpression'
4199 /***/ function(module, exports, __webpack_require__) {
4202 /* istanbul ignore next */
4203 var __extends = (this && this.__extends) || (function () {
4204 var extendStatics = Object.setPrototypeOf ||
4205 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
4206 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
4207 return function (d, b) {
4208 extendStatics(d, b);
4209 function __() { this.constructor = d; }
4210 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
4213 Object.defineProperty(exports, "__esModule", { value: true });
4214 var character_1 = __webpack_require__(4);
4215 var JSXNode = __webpack_require__(5);
4216 var jsx_syntax_1 = __webpack_require__(6);
4217 var Node = __webpack_require__(7);
4218 var parser_1 = __webpack_require__(8);
4219 var token_1 = __webpack_require__(13);
4220 var xhtml_entities_1 = __webpack_require__(14);
4221 token_1.TokenName[100 /* Identifier */] = 'JSXIdentifier';
4222 token_1.TokenName[101 /* Text */] = 'JSXText';
4223 // Fully qualified element name, e.g. <svg:path> returns "svg:path"
4224 function getQualifiedElementName(elementName) {
4226 switch (elementName.type) {
4227 case jsx_syntax_1.JSXSyntax.JSXIdentifier:
4228 var id = elementName;
4229 qualifiedName = id.name;
4231 case jsx_syntax_1.JSXSyntax.JSXNamespacedName:
4232 var ns = elementName;
4233 qualifiedName = getQualifiedElementName(ns.namespace) + ':' +
4234 getQualifiedElementName(ns.name);
4236 case jsx_syntax_1.JSXSyntax.JSXMemberExpression:
4237 var expr = elementName;
4238 qualifiedName = getQualifiedElementName(expr.object) + '.' +
4239 getQualifiedElementName(expr.property);
4241 /* istanbul ignore next */
4245 return qualifiedName;
4247 var JSXParser = (function (_super) {
4248 __extends(JSXParser, _super);
4249 function JSXParser(code, options, delegate) {
4250 return _super.call(this, code, options, delegate) || this;
4252 JSXParser.prototype.parsePrimaryExpression = function () {
4253 return this.match('<') ? this.parseJSXRoot() : _super.prototype.parsePrimaryExpression.call(this);
4255 JSXParser.prototype.startJSX = function () {
4256 // Unwind the scanner before the lookahead token.
4257 this.scanner.index = this.startMarker.index;
4258 this.scanner.lineNumber = this.startMarker.line;
4259 this.scanner.lineStart = this.startMarker.index - this.startMarker.column;
4261 JSXParser.prototype.finishJSX = function () {
4262 // Prime the next lookahead.
4265 JSXParser.prototype.reenterJSX = function () {
4267 this.expectJSX('}');
4268 // Pop the closing '}' added from the lookahead.
4269 if (this.config.tokens) {
4273 JSXParser.prototype.createJSXNode = function () {
4274 this.collectComments();
4276 index: this.scanner.index,
4277 line: this.scanner.lineNumber,
4278 column: this.scanner.index - this.scanner.lineStart
4281 JSXParser.prototype.createJSXChildNode = function () {
4283 index: this.scanner.index,
4284 line: this.scanner.lineNumber,
4285 column: this.scanner.index - this.scanner.lineStart
4288 JSXParser.prototype.scanXHTMLEntity = function (quote) {
4291 var terminated = false;
4292 var numeric = false;
4294 while (!this.scanner.eof() && valid && !terminated) {
4295 var ch = this.scanner.source[this.scanner.index];
4299 terminated = (ch === ';');
4301 ++this.scanner.index;
4303 switch (result.length) {
4306 numeric = (ch === '#');
4312 valid = hex || character_1.Character.isDecimalDigit(ch.charCodeAt(0));
4313 numeric = numeric && !hex;
4317 valid = valid && !(numeric && !character_1.Character.isDecimalDigit(ch.charCodeAt(0)));
4318 valid = valid && !(hex && !character_1.Character.isHexDigit(ch.charCodeAt(0)));
4323 if (valid && terminated && result.length > 2) {
4324 // e.g. 'A' becomes just '#x41'
4325 var str = result.substr(1, result.length - 2);
4326 if (numeric && str.length > 1) {
4327 result = String.fromCharCode(parseInt(str.substr(1), 10));
4329 else if (hex && str.length > 2) {
4330 result = String.fromCharCode(parseInt('0' + str.substr(1), 16));
4332 else if (!numeric && !hex && xhtml_entities_1.XHTMLEntities[str]) {
4333 result = xhtml_entities_1.XHTMLEntities[str];
4338 // Scan the next JSX token. This replaces Scanner#lex when in JSX mode.
4339 JSXParser.prototype.lexJSX = function () {
4340 var cp = this.scanner.source.charCodeAt(this.scanner.index);
4342 if (cp === 60 || cp === 62 || cp === 47 || cp === 58 || cp === 61 || cp === 123 || cp === 125) {
4343 var value = this.scanner.source[this.scanner.index++];
4345 type: 7 /* Punctuator */,
4347 lineNumber: this.scanner.lineNumber,
4348 lineStart: this.scanner.lineStart,
4349 start: this.scanner.index - 1,
4350 end: this.scanner.index
4354 if (cp === 34 || cp === 39) {
4355 var start = this.scanner.index;
4356 var quote = this.scanner.source[this.scanner.index++];
4358 while (!this.scanner.eof()) {
4359 var ch = this.scanner.source[this.scanner.index++];
4363 else if (ch === '&') {
4364 str += this.scanXHTMLEntity(quote);
4371 type: 8 /* StringLiteral */,
4373 lineNumber: this.scanner.lineNumber,
4374 lineStart: this.scanner.lineStart,
4376 end: this.scanner.index
4381 var n1 = this.scanner.source.charCodeAt(this.scanner.index + 1);
4382 var n2 = this.scanner.source.charCodeAt(this.scanner.index + 2);
4383 var value = (n1 === 46 && n2 === 46) ? '...' : '.';
4384 var start = this.scanner.index;
4385 this.scanner.index += value.length;
4387 type: 7 /* Punctuator */,
4389 lineNumber: this.scanner.lineNumber,
4390 lineStart: this.scanner.lineStart,
4392 end: this.scanner.index
4397 // Only placeholder, since it will be rescanned as a real assignment expression.
4399 type: 10 /* Template */,
4401 lineNumber: this.scanner.lineNumber,
4402 lineStart: this.scanner.lineStart,
4403 start: this.scanner.index,
4404 end: this.scanner.index
4407 // Identifer can not contain backslash (char code 92).
4408 if (character_1.Character.isIdentifierStart(cp) && (cp !== 92)) {
4409 var start = this.scanner.index;
4410 ++this.scanner.index;
4411 while (!this.scanner.eof()) {
4412 var ch = this.scanner.source.charCodeAt(this.scanner.index);
4413 if (character_1.Character.isIdentifierPart(ch) && (ch !== 92)) {
4414 ++this.scanner.index;
4416 else if (ch === 45) {
4417 // Hyphen (char code 45) can be part of an identifier.
4418 ++this.scanner.index;
4424 var id = this.scanner.source.slice(start, this.scanner.index);
4426 type: 100 /* Identifier */,
4428 lineNumber: this.scanner.lineNumber,
4429 lineStart: this.scanner.lineStart,
4431 end: this.scanner.index
4434 return this.scanner.lex();
4436 JSXParser.prototype.nextJSXToken = function () {
4437 this.collectComments();
4438 this.startMarker.index = this.scanner.index;
4439 this.startMarker.line = this.scanner.lineNumber;
4440 this.startMarker.column = this.scanner.index - this.scanner.lineStart;
4441 var token = this.lexJSX();
4442 this.lastMarker.index = this.scanner.index;
4443 this.lastMarker.line = this.scanner.lineNumber;
4444 this.lastMarker.column = this.scanner.index - this.scanner.lineStart;
4445 if (this.config.tokens) {
4446 this.tokens.push(this.convertToken(token));
4450 JSXParser.prototype.nextJSXText = function () {
4451 this.startMarker.index = this.scanner.index;
4452 this.startMarker.line = this.scanner.lineNumber;
4453 this.startMarker.column = this.scanner.index - this.scanner.lineStart;
4454 var start = this.scanner.index;
4456 while (!this.scanner.eof()) {
4457 var ch = this.scanner.source[this.scanner.index];
4458 if (ch === '{' || ch === '<') {
4461 ++this.scanner.index;
4463 if (character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
4464 ++this.scanner.lineNumber;
4465 if (ch === '\r' && this.scanner.source[this.scanner.index] === '\n') {
4466 ++this.scanner.index;
4468 this.scanner.lineStart = this.scanner.index;
4471 this.lastMarker.index = this.scanner.index;
4472 this.lastMarker.line = this.scanner.lineNumber;
4473 this.lastMarker.column = this.scanner.index - this.scanner.lineStart;
4475 type: 101 /* Text */,
4477 lineNumber: this.scanner.lineNumber,
4478 lineStart: this.scanner.lineStart,
4480 end: this.scanner.index
4482 if ((text.length > 0) && this.config.tokens) {
4483 this.tokens.push(this.convertToken(token));
4487 JSXParser.prototype.peekJSXToken = function () {
4488 var state = this.scanner.saveState();
4489 this.scanner.scanComments();
4490 var next = this.lexJSX();
4491 this.scanner.restoreState(state);
4494 // Expect the next JSX token to match the specified punctuator.
4495 // If not, an exception will be thrown.
4496 JSXParser.prototype.expectJSX = function (value) {
4497 var token = this.nextJSXToken();
4498 if (token.type !== 7 /* Punctuator */ || token.value !== value) {
4499 this.throwUnexpectedToken(token);
4502 // Return true if the next JSX token matches the specified punctuator.
4503 JSXParser.prototype.matchJSX = function (value) {
4504 var next = this.peekJSXToken();
4505 return next.type === 7 /* Punctuator */ && next.value === value;
4507 JSXParser.prototype.parseJSXIdentifier = function () {
4508 var node = this.createJSXNode();
4509 var token = this.nextJSXToken();
4510 if (token.type !== 100 /* Identifier */) {
4511 this.throwUnexpectedToken(token);
4513 return this.finalize(node, new JSXNode.JSXIdentifier(token.value));
4515 JSXParser.prototype.parseJSXElementName = function () {
4516 var node = this.createJSXNode();
4517 var elementName = this.parseJSXIdentifier();
4518 if (this.matchJSX(':')) {
4519 var namespace = elementName;
4520 this.expectJSX(':');
4521 var name_1 = this.parseJSXIdentifier();
4522 elementName = this.finalize(node, new JSXNode.JSXNamespacedName(namespace, name_1));
4524 else if (this.matchJSX('.')) {
4525 while (this.matchJSX('.')) {
4526 var object = elementName;
4527 this.expectJSX('.');
4528 var property = this.parseJSXIdentifier();
4529 elementName = this.finalize(node, new JSXNode.JSXMemberExpression(object, property));
4534 JSXParser.prototype.parseJSXAttributeName = function () {
4535 var node = this.createJSXNode();
4537 var identifier = this.parseJSXIdentifier();
4538 if (this.matchJSX(':')) {
4539 var namespace = identifier;
4540 this.expectJSX(':');
4541 var name_2 = this.parseJSXIdentifier();
4542 attributeName = this.finalize(node, new JSXNode.JSXNamespacedName(namespace, name_2));
4545 attributeName = identifier;
4547 return attributeName;
4549 JSXParser.prototype.parseJSXStringLiteralAttribute = function () {
4550 var node = this.createJSXNode();
4551 var token = this.nextJSXToken();
4552 if (token.type !== 8 /* StringLiteral */) {
4553 this.throwUnexpectedToken(token);
4555 var raw = this.getTokenRaw(token);
4556 return this.finalize(node, new Node.Literal(token.value, raw));
4558 JSXParser.prototype.parseJSXExpressionAttribute = function () {
4559 var node = this.createJSXNode();
4560 this.expectJSX('{');
4562 if (this.match('}')) {
4563 this.tolerateError('JSX attributes must only be assigned a non-empty expression');
4565 var expression = this.parseAssignmentExpression();
4567 return this.finalize(node, new JSXNode.JSXExpressionContainer(expression));
4569 JSXParser.prototype.parseJSXAttributeValue = function () {
4570 return this.matchJSX('{') ? this.parseJSXExpressionAttribute() :
4571 this.matchJSX('<') ? this.parseJSXElement() : this.parseJSXStringLiteralAttribute();
4573 JSXParser.prototype.parseJSXNameValueAttribute = function () {
4574 var node = this.createJSXNode();
4575 var name = this.parseJSXAttributeName();
4577 if (this.matchJSX('=')) {
4578 this.expectJSX('=');
4579 value = this.parseJSXAttributeValue();
4581 return this.finalize(node, new JSXNode.JSXAttribute(name, value));
4583 JSXParser.prototype.parseJSXSpreadAttribute = function () {
4584 var node = this.createJSXNode();
4585 this.expectJSX('{');
4586 this.expectJSX('...');
4588 var argument = this.parseAssignmentExpression();
4590 return this.finalize(node, new JSXNode.JSXSpreadAttribute(argument));
4592 JSXParser.prototype.parseJSXAttributes = function () {
4593 var attributes = [];
4594 while (!this.matchJSX('/') && !this.matchJSX('>')) {
4595 var attribute = this.matchJSX('{') ? this.parseJSXSpreadAttribute() :
4596 this.parseJSXNameValueAttribute();
4597 attributes.push(attribute);
4601 JSXParser.prototype.parseJSXOpeningElement = function () {
4602 var node = this.createJSXNode();
4603 this.expectJSX('<');
4604 var name = this.parseJSXElementName();
4605 var attributes = this.parseJSXAttributes();
4606 var selfClosing = this.matchJSX('/');
4608 this.expectJSX('/');
4610 this.expectJSX('>');
4611 return this.finalize(node, new JSXNode.JSXOpeningElement(name, selfClosing, attributes));
4613 JSXParser.prototype.parseJSXBoundaryElement = function () {
4614 var node = this.createJSXNode();
4615 this.expectJSX('<');
4616 if (this.matchJSX('/')) {
4617 this.expectJSX('/');
4618 var name_3 = this.parseJSXElementName();
4619 this.expectJSX('>');
4620 return this.finalize(node, new JSXNode.JSXClosingElement(name_3));
4622 var name = this.parseJSXElementName();
4623 var attributes = this.parseJSXAttributes();
4624 var selfClosing = this.matchJSX('/');
4626 this.expectJSX('/');
4628 this.expectJSX('>');
4629 return this.finalize(node, new JSXNode.JSXOpeningElement(name, selfClosing, attributes));
4631 JSXParser.prototype.parseJSXEmptyExpression = function () {
4632 var node = this.createJSXChildNode();
4633 this.collectComments();
4634 this.lastMarker.index = this.scanner.index;
4635 this.lastMarker.line = this.scanner.lineNumber;
4636 this.lastMarker.column = this.scanner.index - this.scanner.lineStart;
4637 return this.finalize(node, new JSXNode.JSXEmptyExpression());
4639 JSXParser.prototype.parseJSXExpressionContainer = function () {
4640 var node = this.createJSXNode();
4641 this.expectJSX('{');
4643 if (this.matchJSX('}')) {
4644 expression = this.parseJSXEmptyExpression();
4645 this.expectJSX('}');
4649 expression = this.parseAssignmentExpression();
4652 return this.finalize(node, new JSXNode.JSXExpressionContainer(expression));
4654 JSXParser.prototype.parseJSXChildren = function () {
4656 while (!this.scanner.eof()) {
4657 var node = this.createJSXChildNode();
4658 var token = this.nextJSXText();
4659 if (token.start < token.end) {
4660 var raw = this.getTokenRaw(token);
4661 var child = this.finalize(node, new JSXNode.JSXText(token.value, raw));
4662 children.push(child);
4664 if (this.scanner.source[this.scanner.index] === '{') {
4665 var container = this.parseJSXExpressionContainer();
4666 children.push(container);
4674 JSXParser.prototype.parseComplexJSXElement = function (el) {
4676 while (!this.scanner.eof()) {
4677 el.children = el.children.concat(this.parseJSXChildren());
4678 var node = this.createJSXChildNode();
4679 var element = this.parseJSXBoundaryElement();
4680 if (element.type === jsx_syntax_1.JSXSyntax.JSXOpeningElement) {
4681 var opening = element;
4682 if (opening.selfClosing) {
4683 var child = this.finalize(node, new JSXNode.JSXElement(opening, [], null));
4684 el.children.push(child);
4688 el = { node: node, opening: opening, closing: null, children: [] };
4691 if (element.type === jsx_syntax_1.JSXSyntax.JSXClosingElement) {
4692 el.closing = element;
4693 var open_1 = getQualifiedElementName(el.opening.name);
4694 var close_1 = getQualifiedElementName(el.closing.name);
4695 if (open_1 !== close_1) {
4696 this.tolerateError('Expected corresponding JSX closing tag for %0', open_1);
4698 if (stack.length > 0) {
4699 var child = this.finalize(el.node, new JSXNode.JSXElement(el.opening, el.children, el.closing));
4700 el = stack[stack.length - 1];
4701 el.children.push(child);
4711 JSXParser.prototype.parseJSXElement = function () {
4712 var node = this.createJSXNode();
4713 var opening = this.parseJSXOpeningElement();
4716 if (!opening.selfClosing) {
4717 var el = this.parseComplexJSXElement({ node: node, opening: opening, closing: closing, children: children });
4718 children = el.children;
4719 closing = el.closing;
4721 return this.finalize(node, new JSXNode.JSXElement(opening, children, closing));
4723 JSXParser.prototype.parseJSXRoot = function () {
4724 // Pop the opening '<' added from the lookahead.
4725 if (this.config.tokens) {
4729 var element = this.parseJSXElement();
4733 JSXParser.prototype.isStartOfExpression = function () {
4734 return _super.prototype.isStartOfExpression.call(this) || this.match('<');
4737 }(parser_1.Parser));
4738 exports.JSXParser = JSXParser;
4743 /***/ function(module, exports) {
4746 Object.defineProperty(exports, "__esModule", { value: true });
4747 // See also tools/generate-unicode-regex.js.
4749 // Unicode v8.0.0 NonAsciiIdentifierStart:
4750 NonAsciiIdentifierStart: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B4\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309B-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]/,
4751 // Unicode v8.0.0 NonAsciiIdentifierPart:
4752 NonAsciiIdentifierPart: /[\xAA\xB5\xB7\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u08A0-\u08B4\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C81-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D01-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u1371\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1CD0-\u1CD2\u1CD4-\u1CF6\u1CF8\u1CF9\u1D00-\u1DF5\u1DFC-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200C\u200D\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2118-\u211D\u2124\u2126\u2128\u212A-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FD5\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C4\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF30-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/
4754 exports.Character = {
4755 /* tslint:disable:no-bitwise */
4756 fromCodePoint: function (cp) {
4757 return (cp < 0x10000) ? String.fromCharCode(cp) :
4758 String.fromCharCode(0xD800 + ((cp - 0x10000) >> 10)) +
4759 String.fromCharCode(0xDC00 + ((cp - 0x10000) & 1023));
4761 // https://tc39.github.io/ecma262/#sec-white-space
4762 isWhiteSpace: function (cp) {
4763 return (cp === 0x20) || (cp === 0x09) || (cp === 0x0B) || (cp === 0x0C) || (cp === 0xA0) ||
4764 (cp >= 0x1680 && [0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x202F, 0x205F, 0x3000, 0xFEFF].indexOf(cp) >= 0);
4766 // https://tc39.github.io/ecma262/#sec-line-terminators
4767 isLineTerminator: function (cp) {
4768 return (cp === 0x0A) || (cp === 0x0D) || (cp === 0x2028) || (cp === 0x2029);
4770 // https://tc39.github.io/ecma262/#sec-names-and-keywords
4771 isIdentifierStart: function (cp) {
4772 return (cp === 0x24) || (cp === 0x5F) ||
4773 (cp >= 0x41 && cp <= 0x5A) ||
4774 (cp >= 0x61 && cp <= 0x7A) ||
4776 ((cp >= 0x80) && Regex.NonAsciiIdentifierStart.test(exports.Character.fromCodePoint(cp)));
4778 isIdentifierPart: function (cp) {
4779 return (cp === 0x24) || (cp === 0x5F) ||
4780 (cp >= 0x41 && cp <= 0x5A) ||
4781 (cp >= 0x61 && cp <= 0x7A) ||
4782 (cp >= 0x30 && cp <= 0x39) ||
4784 ((cp >= 0x80) && Regex.NonAsciiIdentifierPart.test(exports.Character.fromCodePoint(cp)));
4786 // https://tc39.github.io/ecma262/#sec-literals-numeric-literals
4787 isDecimalDigit: function (cp) {
4788 return (cp >= 0x30 && cp <= 0x39); // 0..9
4790 isHexDigit: function (cp) {
4791 return (cp >= 0x30 && cp <= 0x39) ||
4792 (cp >= 0x41 && cp <= 0x46) ||
4793 (cp >= 0x61 && cp <= 0x66); // a..f
4795 isOctalDigit: function (cp) {
4796 return (cp >= 0x30 && cp <= 0x37); // 0..7
4803 /***/ function(module, exports, __webpack_require__) {
4806 Object.defineProperty(exports, "__esModule", { value: true });
4807 var jsx_syntax_1 = __webpack_require__(6);
4808 /* tslint:disable:max-classes-per-file */
4809 var JSXClosingElement = (function () {
4810 function JSXClosingElement(name) {
4811 this.type = jsx_syntax_1.JSXSyntax.JSXClosingElement;
4814 return JSXClosingElement;
4816 exports.JSXClosingElement = JSXClosingElement;
4817 var JSXElement = (function () {
4818 function JSXElement(openingElement, children, closingElement) {
4819 this.type = jsx_syntax_1.JSXSyntax.JSXElement;
4820 this.openingElement = openingElement;
4821 this.children = children;
4822 this.closingElement = closingElement;
4826 exports.JSXElement = JSXElement;
4827 var JSXEmptyExpression = (function () {
4828 function JSXEmptyExpression() {
4829 this.type = jsx_syntax_1.JSXSyntax.JSXEmptyExpression;
4831 return JSXEmptyExpression;
4833 exports.JSXEmptyExpression = JSXEmptyExpression;
4834 var JSXExpressionContainer = (function () {
4835 function JSXExpressionContainer(expression) {
4836 this.type = jsx_syntax_1.JSXSyntax.JSXExpressionContainer;
4837 this.expression = expression;
4839 return JSXExpressionContainer;
4841 exports.JSXExpressionContainer = JSXExpressionContainer;
4842 var JSXIdentifier = (function () {
4843 function JSXIdentifier(name) {
4844 this.type = jsx_syntax_1.JSXSyntax.JSXIdentifier;
4847 return JSXIdentifier;
4849 exports.JSXIdentifier = JSXIdentifier;
4850 var JSXMemberExpression = (function () {
4851 function JSXMemberExpression(object, property) {
4852 this.type = jsx_syntax_1.JSXSyntax.JSXMemberExpression;
4853 this.object = object;
4854 this.property = property;
4856 return JSXMemberExpression;
4858 exports.JSXMemberExpression = JSXMemberExpression;
4859 var JSXAttribute = (function () {
4860 function JSXAttribute(name, value) {
4861 this.type = jsx_syntax_1.JSXSyntax.JSXAttribute;
4865 return JSXAttribute;
4867 exports.JSXAttribute = JSXAttribute;
4868 var JSXNamespacedName = (function () {
4869 function JSXNamespacedName(namespace, name) {
4870 this.type = jsx_syntax_1.JSXSyntax.JSXNamespacedName;
4871 this.namespace = namespace;
4874 return JSXNamespacedName;
4876 exports.JSXNamespacedName = JSXNamespacedName;
4877 var JSXOpeningElement = (function () {
4878 function JSXOpeningElement(name, selfClosing, attributes) {
4879 this.type = jsx_syntax_1.JSXSyntax.JSXOpeningElement;
4881 this.selfClosing = selfClosing;
4882 this.attributes = attributes;
4884 return JSXOpeningElement;
4886 exports.JSXOpeningElement = JSXOpeningElement;
4887 var JSXSpreadAttribute = (function () {
4888 function JSXSpreadAttribute(argument) {
4889 this.type = jsx_syntax_1.JSXSyntax.JSXSpreadAttribute;
4890 this.argument = argument;
4892 return JSXSpreadAttribute;
4894 exports.JSXSpreadAttribute = JSXSpreadAttribute;
4895 var JSXText = (function () {
4896 function JSXText(value, raw) {
4897 this.type = jsx_syntax_1.JSXSyntax.JSXText;
4903 exports.JSXText = JSXText;
4908 /***/ function(module, exports) {
4911 Object.defineProperty(exports, "__esModule", { value: true });
4912 exports.JSXSyntax = {
4913 JSXAttribute: 'JSXAttribute',
4914 JSXClosingElement: 'JSXClosingElement',
4915 JSXElement: 'JSXElement',
4916 JSXEmptyExpression: 'JSXEmptyExpression',
4917 JSXExpressionContainer: 'JSXExpressionContainer',
4918 JSXIdentifier: 'JSXIdentifier',
4919 JSXMemberExpression: 'JSXMemberExpression',
4920 JSXNamespacedName: 'JSXNamespacedName',
4921 JSXOpeningElement: 'JSXOpeningElement',
4922 JSXSpreadAttribute: 'JSXSpreadAttribute',
4929 /***/ function(module, exports, __webpack_require__) {
4932 Object.defineProperty(exports, "__esModule", { value: true });
4933 var syntax_1 = __webpack_require__(2);
4934 /* tslint:disable:max-classes-per-file */
4935 var ArrayExpression = (function () {
4936 function ArrayExpression(elements) {
4937 this.type = syntax_1.Syntax.ArrayExpression;
4938 this.elements = elements;
4940 return ArrayExpression;
4942 exports.ArrayExpression = ArrayExpression;
4943 var ArrayPattern = (function () {
4944 function ArrayPattern(elements) {
4945 this.type = syntax_1.Syntax.ArrayPattern;
4946 this.elements = elements;
4948 return ArrayPattern;
4950 exports.ArrayPattern = ArrayPattern;
4951 var ArrowFunctionExpression = (function () {
4952 function ArrowFunctionExpression(params, body, expression) {
4953 this.type = syntax_1.Syntax.ArrowFunctionExpression;
4955 this.params = params;
4957 this.generator = false;
4958 this.expression = expression;
4961 return ArrowFunctionExpression;
4963 exports.ArrowFunctionExpression = ArrowFunctionExpression;
4964 var AssignmentExpression = (function () {
4965 function AssignmentExpression(operator, left, right) {
4966 this.type = syntax_1.Syntax.AssignmentExpression;
4967 this.operator = operator;
4971 return AssignmentExpression;
4973 exports.AssignmentExpression = AssignmentExpression;
4974 var AssignmentPattern = (function () {
4975 function AssignmentPattern(left, right) {
4976 this.type = syntax_1.Syntax.AssignmentPattern;
4980 return AssignmentPattern;
4982 exports.AssignmentPattern = AssignmentPattern;
4983 var AsyncArrowFunctionExpression = (function () {
4984 function AsyncArrowFunctionExpression(params, body, expression) {
4985 this.type = syntax_1.Syntax.ArrowFunctionExpression;
4987 this.params = params;
4989 this.generator = false;
4990 this.expression = expression;
4993 return AsyncArrowFunctionExpression;
4995 exports.AsyncArrowFunctionExpression = AsyncArrowFunctionExpression;
4996 var AsyncFunctionDeclaration = (function () {
4997 function AsyncFunctionDeclaration(id, params, body) {
4998 this.type = syntax_1.Syntax.FunctionDeclaration;
5000 this.params = params;
5002 this.generator = false;
5003 this.expression = false;
5006 return AsyncFunctionDeclaration;
5008 exports.AsyncFunctionDeclaration = AsyncFunctionDeclaration;
5009 var AsyncFunctionExpression = (function () {
5010 function AsyncFunctionExpression(id, params, body) {
5011 this.type = syntax_1.Syntax.FunctionExpression;
5013 this.params = params;
5015 this.generator = false;
5016 this.expression = false;
5019 return AsyncFunctionExpression;
5021 exports.AsyncFunctionExpression = AsyncFunctionExpression;
5022 var AwaitExpression = (function () {
5023 function AwaitExpression(argument) {
5024 this.type = syntax_1.Syntax.AwaitExpression;
5025 this.argument = argument;
5027 return AwaitExpression;
5029 exports.AwaitExpression = AwaitExpression;
5030 var BinaryExpression = (function () {
5031 function BinaryExpression(operator, left, right) {
5032 var logical = (operator === '||' || operator === '&&');
5033 this.type = logical ? syntax_1.Syntax.LogicalExpression : syntax_1.Syntax.BinaryExpression;
5034 this.operator = operator;
5038 return BinaryExpression;
5040 exports.BinaryExpression = BinaryExpression;
5041 var BlockStatement = (function () {
5042 function BlockStatement(body) {
5043 this.type = syntax_1.Syntax.BlockStatement;
5046 return BlockStatement;
5048 exports.BlockStatement = BlockStatement;
5049 var BreakStatement = (function () {
5050 function BreakStatement(label) {
5051 this.type = syntax_1.Syntax.BreakStatement;
5054 return BreakStatement;
5056 exports.BreakStatement = BreakStatement;
5057 var CallExpression = (function () {
5058 function CallExpression(callee, args) {
5059 this.type = syntax_1.Syntax.CallExpression;
5060 this.callee = callee;
5061 this.arguments = args;
5063 return CallExpression;
5065 exports.CallExpression = CallExpression;
5066 var CatchClause = (function () {
5067 function CatchClause(param, body) {
5068 this.type = syntax_1.Syntax.CatchClause;
5074 exports.CatchClause = CatchClause;
5075 var ClassBody = (function () {
5076 function ClassBody(body) {
5077 this.type = syntax_1.Syntax.ClassBody;
5082 exports.ClassBody = ClassBody;
5083 var ClassDeclaration = (function () {
5084 function ClassDeclaration(id, superClass, body) {
5085 this.type = syntax_1.Syntax.ClassDeclaration;
5087 this.superClass = superClass;
5090 return ClassDeclaration;
5092 exports.ClassDeclaration = ClassDeclaration;
5093 var ClassExpression = (function () {
5094 function ClassExpression(id, superClass, body) {
5095 this.type = syntax_1.Syntax.ClassExpression;
5097 this.superClass = superClass;
5100 return ClassExpression;
5102 exports.ClassExpression = ClassExpression;
5103 var ComputedMemberExpression = (function () {
5104 function ComputedMemberExpression(object, property) {
5105 this.type = syntax_1.Syntax.MemberExpression;
5106 this.computed = true;
5107 this.object = object;
5108 this.property = property;
5110 return ComputedMemberExpression;
5112 exports.ComputedMemberExpression = ComputedMemberExpression;
5113 var ConditionalExpression = (function () {
5114 function ConditionalExpression(test, consequent, alternate) {
5115 this.type = syntax_1.Syntax.ConditionalExpression;
5117 this.consequent = consequent;
5118 this.alternate = alternate;
5120 return ConditionalExpression;
5122 exports.ConditionalExpression = ConditionalExpression;
5123 var ContinueStatement = (function () {
5124 function ContinueStatement(label) {
5125 this.type = syntax_1.Syntax.ContinueStatement;
5128 return ContinueStatement;
5130 exports.ContinueStatement = ContinueStatement;
5131 var DebuggerStatement = (function () {
5132 function DebuggerStatement() {
5133 this.type = syntax_1.Syntax.DebuggerStatement;
5135 return DebuggerStatement;
5137 exports.DebuggerStatement = DebuggerStatement;
5138 var Directive = (function () {
5139 function Directive(expression, directive) {
5140 this.type = syntax_1.Syntax.ExpressionStatement;
5141 this.expression = expression;
5142 this.directive = directive;
5146 exports.Directive = Directive;
5147 var DoWhileStatement = (function () {
5148 function DoWhileStatement(body, test) {
5149 this.type = syntax_1.Syntax.DoWhileStatement;
5153 return DoWhileStatement;
5155 exports.DoWhileStatement = DoWhileStatement;
5156 var EmptyStatement = (function () {
5157 function EmptyStatement() {
5158 this.type = syntax_1.Syntax.EmptyStatement;
5160 return EmptyStatement;
5162 exports.EmptyStatement = EmptyStatement;
5163 var ExportAllDeclaration = (function () {
5164 function ExportAllDeclaration(source) {
5165 this.type = syntax_1.Syntax.ExportAllDeclaration;
5166 this.source = source;
5168 return ExportAllDeclaration;
5170 exports.ExportAllDeclaration = ExportAllDeclaration;
5171 var ExportDefaultDeclaration = (function () {
5172 function ExportDefaultDeclaration(declaration) {
5173 this.type = syntax_1.Syntax.ExportDefaultDeclaration;
5174 this.declaration = declaration;
5176 return ExportDefaultDeclaration;
5178 exports.ExportDefaultDeclaration = ExportDefaultDeclaration;
5179 var ExportNamedDeclaration = (function () {
5180 function ExportNamedDeclaration(declaration, specifiers, source) {
5181 this.type = syntax_1.Syntax.ExportNamedDeclaration;
5182 this.declaration = declaration;
5183 this.specifiers = specifiers;
5184 this.source = source;
5186 return ExportNamedDeclaration;
5188 exports.ExportNamedDeclaration = ExportNamedDeclaration;
5189 var ExportSpecifier = (function () {
5190 function ExportSpecifier(local, exported) {
5191 this.type = syntax_1.Syntax.ExportSpecifier;
5192 this.exported = exported;
5195 return ExportSpecifier;
5197 exports.ExportSpecifier = ExportSpecifier;
5198 var ExpressionStatement = (function () {
5199 function ExpressionStatement(expression) {
5200 this.type = syntax_1.Syntax.ExpressionStatement;
5201 this.expression = expression;
5203 return ExpressionStatement;
5205 exports.ExpressionStatement = ExpressionStatement;
5206 var ForInStatement = (function () {
5207 function ForInStatement(left, right, body) {
5208 this.type = syntax_1.Syntax.ForInStatement;
5214 return ForInStatement;
5216 exports.ForInStatement = ForInStatement;
5217 var ForOfStatement = (function () {
5218 function ForOfStatement(left, right, body) {
5219 this.type = syntax_1.Syntax.ForOfStatement;
5224 return ForOfStatement;
5226 exports.ForOfStatement = ForOfStatement;
5227 var ForStatement = (function () {
5228 function ForStatement(init, test, update, body) {
5229 this.type = syntax_1.Syntax.ForStatement;
5232 this.update = update;
5235 return ForStatement;
5237 exports.ForStatement = ForStatement;
5238 var FunctionDeclaration = (function () {
5239 function FunctionDeclaration(id, params, body, generator) {
5240 this.type = syntax_1.Syntax.FunctionDeclaration;
5242 this.params = params;
5244 this.generator = generator;
5245 this.expression = false;
5248 return FunctionDeclaration;
5250 exports.FunctionDeclaration = FunctionDeclaration;
5251 var FunctionExpression = (function () {
5252 function FunctionExpression(id, params, body, generator) {
5253 this.type = syntax_1.Syntax.FunctionExpression;
5255 this.params = params;
5257 this.generator = generator;
5258 this.expression = false;
5261 return FunctionExpression;
5263 exports.FunctionExpression = FunctionExpression;
5264 var Identifier = (function () {
5265 function Identifier(name) {
5266 this.type = syntax_1.Syntax.Identifier;
5271 exports.Identifier = Identifier;
5272 var IfStatement = (function () {
5273 function IfStatement(test, consequent, alternate) {
5274 this.type = syntax_1.Syntax.IfStatement;
5276 this.consequent = consequent;
5277 this.alternate = alternate;
5281 exports.IfStatement = IfStatement;
5282 var ImportDeclaration = (function () {
5283 function ImportDeclaration(specifiers, source) {
5284 this.type = syntax_1.Syntax.ImportDeclaration;
5285 this.specifiers = specifiers;
5286 this.source = source;
5288 return ImportDeclaration;
5290 exports.ImportDeclaration = ImportDeclaration;
5291 var ImportDefaultSpecifier = (function () {
5292 function ImportDefaultSpecifier(local) {
5293 this.type = syntax_1.Syntax.ImportDefaultSpecifier;
5296 return ImportDefaultSpecifier;
5298 exports.ImportDefaultSpecifier = ImportDefaultSpecifier;
5299 var ImportNamespaceSpecifier = (function () {
5300 function ImportNamespaceSpecifier(local) {
5301 this.type = syntax_1.Syntax.ImportNamespaceSpecifier;
5304 return ImportNamespaceSpecifier;
5306 exports.ImportNamespaceSpecifier = ImportNamespaceSpecifier;
5307 var ImportSpecifier = (function () {
5308 function ImportSpecifier(local, imported) {
5309 this.type = syntax_1.Syntax.ImportSpecifier;
5311 this.imported = imported;
5313 return ImportSpecifier;
5315 exports.ImportSpecifier = ImportSpecifier;
5316 var LabeledStatement = (function () {
5317 function LabeledStatement(label, body) {
5318 this.type = syntax_1.Syntax.LabeledStatement;
5322 return LabeledStatement;
5324 exports.LabeledStatement = LabeledStatement;
5325 var Literal = (function () {
5326 function Literal(value, raw) {
5327 this.type = syntax_1.Syntax.Literal;
5333 exports.Literal = Literal;
5334 var MetaProperty = (function () {
5335 function MetaProperty(meta, property) {
5336 this.type = syntax_1.Syntax.MetaProperty;
5338 this.property = property;
5340 return MetaProperty;
5342 exports.MetaProperty = MetaProperty;
5343 var MethodDefinition = (function () {
5344 function MethodDefinition(key, computed, value, kind, isStatic) {
5345 this.type = syntax_1.Syntax.MethodDefinition;
5347 this.computed = computed;
5350 this.static = isStatic;
5352 return MethodDefinition;
5354 exports.MethodDefinition = MethodDefinition;
5355 var Module = (function () {
5356 function Module(body) {
5357 this.type = syntax_1.Syntax.Program;
5359 this.sourceType = 'module';
5363 exports.Module = Module;
5364 var NewExpression = (function () {
5365 function NewExpression(callee, args) {
5366 this.type = syntax_1.Syntax.NewExpression;
5367 this.callee = callee;
5368 this.arguments = args;
5370 return NewExpression;
5372 exports.NewExpression = NewExpression;
5373 var ObjectExpression = (function () {
5374 function ObjectExpression(properties) {
5375 this.type = syntax_1.Syntax.ObjectExpression;
5376 this.properties = properties;
5378 return ObjectExpression;
5380 exports.ObjectExpression = ObjectExpression;
5381 var ObjectPattern = (function () {
5382 function ObjectPattern(properties) {
5383 this.type = syntax_1.Syntax.ObjectPattern;
5384 this.properties = properties;
5386 return ObjectPattern;
5388 exports.ObjectPattern = ObjectPattern;
5389 var Property = (function () {
5390 function Property(kind, key, computed, value, method, shorthand) {
5391 this.type = syntax_1.Syntax.Property;
5393 this.computed = computed;
5396 this.method = method;
5397 this.shorthand = shorthand;
5401 exports.Property = Property;
5402 var RegexLiteral = (function () {
5403 function RegexLiteral(value, raw, pattern, flags) {
5404 this.type = syntax_1.Syntax.Literal;
5407 this.regex = { pattern: pattern, flags: flags };
5409 return RegexLiteral;
5411 exports.RegexLiteral = RegexLiteral;
5412 var RestElement = (function () {
5413 function RestElement(argument) {
5414 this.type = syntax_1.Syntax.RestElement;
5415 this.argument = argument;
5419 exports.RestElement = RestElement;
5420 var ReturnStatement = (function () {
5421 function ReturnStatement(argument) {
5422 this.type = syntax_1.Syntax.ReturnStatement;
5423 this.argument = argument;
5425 return ReturnStatement;
5427 exports.ReturnStatement = ReturnStatement;
5428 var Script = (function () {
5429 function Script(body) {
5430 this.type = syntax_1.Syntax.Program;
5432 this.sourceType = 'script';
5436 exports.Script = Script;
5437 var SequenceExpression = (function () {
5438 function SequenceExpression(expressions) {
5439 this.type = syntax_1.Syntax.SequenceExpression;
5440 this.expressions = expressions;
5442 return SequenceExpression;
5444 exports.SequenceExpression = SequenceExpression;
5445 var SpreadElement = (function () {
5446 function SpreadElement(argument) {
5447 this.type = syntax_1.Syntax.SpreadElement;
5448 this.argument = argument;
5450 return SpreadElement;
5452 exports.SpreadElement = SpreadElement;
5453 var StaticMemberExpression = (function () {
5454 function StaticMemberExpression(object, property) {
5455 this.type = syntax_1.Syntax.MemberExpression;
5456 this.computed = false;
5457 this.object = object;
5458 this.property = property;
5460 return StaticMemberExpression;
5462 exports.StaticMemberExpression = StaticMemberExpression;
5463 var Super = (function () {
5465 this.type = syntax_1.Syntax.Super;
5469 exports.Super = Super;
5470 var SwitchCase = (function () {
5471 function SwitchCase(test, consequent) {
5472 this.type = syntax_1.Syntax.SwitchCase;
5474 this.consequent = consequent;
5478 exports.SwitchCase = SwitchCase;
5479 var SwitchStatement = (function () {
5480 function SwitchStatement(discriminant, cases) {
5481 this.type = syntax_1.Syntax.SwitchStatement;
5482 this.discriminant = discriminant;
5485 return SwitchStatement;
5487 exports.SwitchStatement = SwitchStatement;
5488 var TaggedTemplateExpression = (function () {
5489 function TaggedTemplateExpression(tag, quasi) {
5490 this.type = syntax_1.Syntax.TaggedTemplateExpression;
5494 return TaggedTemplateExpression;
5496 exports.TaggedTemplateExpression = TaggedTemplateExpression;
5497 var TemplateElement = (function () {
5498 function TemplateElement(value, tail) {
5499 this.type = syntax_1.Syntax.TemplateElement;
5503 return TemplateElement;
5505 exports.TemplateElement = TemplateElement;
5506 var TemplateLiteral = (function () {
5507 function TemplateLiteral(quasis, expressions) {
5508 this.type = syntax_1.Syntax.TemplateLiteral;
5509 this.quasis = quasis;
5510 this.expressions = expressions;
5512 return TemplateLiteral;
5514 exports.TemplateLiteral = TemplateLiteral;
5515 var ThisExpression = (function () {
5516 function ThisExpression() {
5517 this.type = syntax_1.Syntax.ThisExpression;
5519 return ThisExpression;
5521 exports.ThisExpression = ThisExpression;
5522 var ThrowStatement = (function () {
5523 function ThrowStatement(argument) {
5524 this.type = syntax_1.Syntax.ThrowStatement;
5525 this.argument = argument;
5527 return ThrowStatement;
5529 exports.ThrowStatement = ThrowStatement;
5530 var TryStatement = (function () {
5531 function TryStatement(block, handler, finalizer) {
5532 this.type = syntax_1.Syntax.TryStatement;
5534 this.handler = handler;
5535 this.finalizer = finalizer;
5537 return TryStatement;
5539 exports.TryStatement = TryStatement;
5540 var UnaryExpression = (function () {
5541 function UnaryExpression(operator, argument) {
5542 this.type = syntax_1.Syntax.UnaryExpression;
5543 this.operator = operator;
5544 this.argument = argument;
5547 return UnaryExpression;
5549 exports.UnaryExpression = UnaryExpression;
5550 var UpdateExpression = (function () {
5551 function UpdateExpression(operator, argument, prefix) {
5552 this.type = syntax_1.Syntax.UpdateExpression;
5553 this.operator = operator;
5554 this.argument = argument;
5555 this.prefix = prefix;
5557 return UpdateExpression;
5559 exports.UpdateExpression = UpdateExpression;
5560 var VariableDeclaration = (function () {
5561 function VariableDeclaration(declarations, kind) {
5562 this.type = syntax_1.Syntax.VariableDeclaration;
5563 this.declarations = declarations;
5566 return VariableDeclaration;
5568 exports.VariableDeclaration = VariableDeclaration;
5569 var VariableDeclarator = (function () {
5570 function VariableDeclarator(id, init) {
5571 this.type = syntax_1.Syntax.VariableDeclarator;
5575 return VariableDeclarator;
5577 exports.VariableDeclarator = VariableDeclarator;
5578 var WhileStatement = (function () {
5579 function WhileStatement(test, body) {
5580 this.type = syntax_1.Syntax.WhileStatement;
5584 return WhileStatement;
5586 exports.WhileStatement = WhileStatement;
5587 var WithStatement = (function () {
5588 function WithStatement(object, body) {
5589 this.type = syntax_1.Syntax.WithStatement;
5590 this.object = object;
5593 return WithStatement;
5595 exports.WithStatement = WithStatement;
5596 var YieldExpression = (function () {
5597 function YieldExpression(argument, delegate) {
5598 this.type = syntax_1.Syntax.YieldExpression;
5599 this.argument = argument;
5600 this.delegate = delegate;
5602 return YieldExpression;
5604 exports.YieldExpression = YieldExpression;
5609 /***/ function(module, exports, __webpack_require__) {
5612 Object.defineProperty(exports, "__esModule", { value: true });
5613 var assert_1 = __webpack_require__(9);
5614 var error_handler_1 = __webpack_require__(10);
5615 var messages_1 = __webpack_require__(11);
5616 var Node = __webpack_require__(7);
5617 var scanner_1 = __webpack_require__(12);
5618 var syntax_1 = __webpack_require__(2);
5619 var token_1 = __webpack_require__(13);
5620 var ArrowParameterPlaceHolder = 'ArrowParameterPlaceHolder';
5621 var Parser = (function () {
5622 function Parser(code, options, delegate) {
5623 if (options === void 0) { options = {}; }
5625 range: (typeof options.range === 'boolean') && options.range,
5626 loc: (typeof options.loc === 'boolean') && options.loc,
5628 tokens: (typeof options.tokens === 'boolean') && options.tokens,
5629 comment: (typeof options.comment === 'boolean') && options.comment,
5630 tolerant: (typeof options.tolerant === 'boolean') && options.tolerant
5632 if (this.config.loc && options.source && options.source !== null) {
5633 this.config.source = String(options.source);
5635 this.delegate = delegate;
5636 this.errorHandler = new error_handler_1.ErrorHandler();
5637 this.errorHandler.tolerant = this.config.tolerant;
5638 this.scanner = new scanner_1.Scanner(code, this.errorHandler);
5639 this.scanner.trackComment = this.config.comment;
5640 this.operatorPrecedence = {
5671 lineNumber: this.scanner.lineNumber,
5676 this.hasLineTerminator = false;
5681 allowStrictDirective: true,
5683 firstCoverInitializedNameError: null,
5684 isAssignmentTarget: false,
5685 isBindingElement: false,
5686 inFunctionBody: false,
5693 this.startMarker = {
5695 line: this.scanner.lineNumber,
5700 line: this.scanner.lineNumber,
5705 index: this.scanner.index,
5706 line: this.scanner.lineNumber,
5707 column: this.scanner.index - this.scanner.lineStart
5710 Parser.prototype.throwError = function (messageFormat) {
5712 for (var _i = 1; _i < arguments.length; _i++) {
5713 values[_i - 1] = arguments[_i];
5715 var args = Array.prototype.slice.call(arguments, 1);
5716 var msg = messageFormat.replace(/%(\d)/g, function (whole, idx) {
5717 assert_1.assert(idx < args.length, 'Message reference must be in range');
5720 var index = this.lastMarker.index;
5721 var line = this.lastMarker.line;
5722 var column = this.lastMarker.column + 1;
5723 throw this.errorHandler.createError(index, line, column, msg);
5725 Parser.prototype.tolerateError = function (messageFormat) {
5727 for (var _i = 1; _i < arguments.length; _i++) {
5728 values[_i - 1] = arguments[_i];
5730 var args = Array.prototype.slice.call(arguments, 1);
5731 var msg = messageFormat.replace(/%(\d)/g, function (whole, idx) {
5732 assert_1.assert(idx < args.length, 'Message reference must be in range');
5735 var index = this.lastMarker.index;
5736 var line = this.scanner.lineNumber;
5737 var column = this.lastMarker.column + 1;
5738 this.errorHandler.tolerateError(index, line, column, msg);
5740 // Throw an exception because of the token.
5741 Parser.prototype.unexpectedTokenError = function (token, message) {
5742 var msg = message || messages_1.Messages.UnexpectedToken;
5746 msg = (token.type === 2 /* EOF */) ? messages_1.Messages.UnexpectedEOS :
5747 (token.type === 3 /* Identifier */) ? messages_1.Messages.UnexpectedIdentifier :
5748 (token.type === 6 /* NumericLiteral */) ? messages_1.Messages.UnexpectedNumber :
5749 (token.type === 8 /* StringLiteral */) ? messages_1.Messages.UnexpectedString :
5750 (token.type === 10 /* Template */) ? messages_1.Messages.UnexpectedTemplate :
5751 messages_1.Messages.UnexpectedToken;
5752 if (token.type === 4 /* Keyword */) {
5753 if (this.scanner.isFutureReservedWord(token.value)) {
5754 msg = messages_1.Messages.UnexpectedReserved;
5756 else if (this.context.strict && this.scanner.isStrictModeReservedWord(token.value)) {
5757 msg = messages_1.Messages.StrictReservedWord;
5761 value = token.value;
5766 msg = msg.replace('%0', value);
5767 if (token && typeof token.lineNumber === 'number') {
5768 var index = token.start;
5769 var line = token.lineNumber;
5770 var lastMarkerLineStart = this.lastMarker.index - this.lastMarker.column;
5771 var column = token.start - lastMarkerLineStart + 1;
5772 return this.errorHandler.createError(index, line, column, msg);
5775 var index = this.lastMarker.index;
5776 var line = this.lastMarker.line;
5777 var column = this.lastMarker.column + 1;
5778 return this.errorHandler.createError(index, line, column, msg);
5781 Parser.prototype.throwUnexpectedToken = function (token, message) {
5782 throw this.unexpectedTokenError(token, message);
5784 Parser.prototype.tolerateUnexpectedToken = function (token, message) {
5785 this.errorHandler.tolerate(this.unexpectedTokenError(token, message));
5787 Parser.prototype.collectComments = function () {
5788 if (!this.config.comment) {
5789 this.scanner.scanComments();
5792 var comments = this.scanner.scanComments();
5793 if (comments.length > 0 && this.delegate) {
5794 for (var i = 0; i < comments.length; ++i) {
5795 var e = comments[i];
5798 type: e.multiLine ? 'BlockComment' : 'LineComment',
5799 value: this.scanner.source.slice(e.slice[0], e.slice[1])
5801 if (this.config.range) {
5802 node.range = e.range;
5804 if (this.config.loc) {
5809 line: e.loc.start.line,
5810 column: e.loc.start.column,
5814 line: e.loc.end.line,
5815 column: e.loc.end.column,
5819 this.delegate(node, metadata);
5824 // From internal representation to an external structure
5825 Parser.prototype.getTokenRaw = function (token) {
5826 return this.scanner.source.slice(token.start, token.end);
5828 Parser.prototype.convertToken = function (token) {
5830 type: token_1.TokenName[token.type],
5831 value: this.getTokenRaw(token)
5833 if (this.config.range) {
5834 t.range = [token.start, token.end];
5836 if (this.config.loc) {
5839 line: this.startMarker.line,
5840 column: this.startMarker.column
5843 line: this.scanner.lineNumber,
5844 column: this.scanner.index - this.scanner.lineStart
5848 if (token.type === 9 /* RegularExpression */) {
5849 var pattern = token.pattern;
5850 var flags = token.flags;
5851 t.regex = { pattern: pattern, flags: flags };
5855 Parser.prototype.nextToken = function () {
5856 var token = this.lookahead;
5857 this.lastMarker.index = this.scanner.index;
5858 this.lastMarker.line = this.scanner.lineNumber;
5859 this.lastMarker.column = this.scanner.index - this.scanner.lineStart;
5860 this.collectComments();
5861 if (this.scanner.index !== this.startMarker.index) {
5862 this.startMarker.index = this.scanner.index;
5863 this.startMarker.line = this.scanner.lineNumber;
5864 this.startMarker.column = this.scanner.index - this.scanner.lineStart;
5866 var next = this.scanner.lex();
5867 this.hasLineTerminator = (token.lineNumber !== next.lineNumber);
5868 if (next && this.context.strict && next.type === 3 /* Identifier */) {
5869 if (this.scanner.isStrictModeReservedWord(next.value)) {
5870 next.type = 4 /* Keyword */;
5873 this.lookahead = next;
5874 if (this.config.tokens && next.type !== 2 /* EOF */) {
5875 this.tokens.push(this.convertToken(next));
5879 Parser.prototype.nextRegexToken = function () {
5880 this.collectComments();
5881 var token = this.scanner.scanRegExp();
5882 if (this.config.tokens) {
5883 // Pop the previous token, '/' or '/='
5884 // This is added from the lookahead token.
5886 this.tokens.push(this.convertToken(token));
5888 // Prime the next lookahead.
5889 this.lookahead = token;
5893 Parser.prototype.createNode = function () {
5895 index: this.startMarker.index,
5896 line: this.startMarker.line,
5897 column: this.startMarker.column
5900 Parser.prototype.startNode = function (token, lastLineStart) {
5901 if (lastLineStart === void 0) { lastLineStart = 0; }
5902 var column = token.start - token.lineStart;
5903 var line = token.lineNumber;
5905 column += lastLineStart;
5914 Parser.prototype.finalize = function (marker, node) {
5915 if (this.config.range) {
5916 node.range = [marker.index, this.lastMarker.index];
5918 if (this.config.loc) {
5922 column: marker.column,
5925 line: this.lastMarker.line,
5926 column: this.lastMarker.column
5929 if (this.config.source) {
5930 node.loc.source = this.config.source;
5933 if (this.delegate) {
5937 column: marker.column,
5938 offset: marker.index
5941 line: this.lastMarker.line,
5942 column: this.lastMarker.column,
5943 offset: this.lastMarker.index
5946 this.delegate(node, metadata);
5950 // Expect the next token to match the specified punctuator.
5951 // If not, an exception will be thrown.
5952 Parser.prototype.expect = function (value) {
5953 var token = this.nextToken();
5954 if (token.type !== 7 /* Punctuator */ || token.value !== value) {
5955 this.throwUnexpectedToken(token);
5958 // Quietly expect a comma when in tolerant mode, otherwise delegates to expect().
5959 Parser.prototype.expectCommaSeparator = function () {
5960 if (this.config.tolerant) {
5961 var token = this.lookahead;
5962 if (token.type === 7 /* Punctuator */ && token.value === ',') {
5965 else if (token.type === 7 /* Punctuator */ && token.value === ';') {
5967 this.tolerateUnexpectedToken(token);
5970 this.tolerateUnexpectedToken(token, messages_1.Messages.UnexpectedToken);
5977 // Expect the next token to match the specified keyword.
5978 // If not, an exception will be thrown.
5979 Parser.prototype.expectKeyword = function (keyword) {
5980 var token = this.nextToken();
5981 if (token.type !== 4 /* Keyword */ || token.value !== keyword) {
5982 this.throwUnexpectedToken(token);
5985 // Return true if the next token matches the specified punctuator.
5986 Parser.prototype.match = function (value) {
5987 return this.lookahead.type === 7 /* Punctuator */ && this.lookahead.value === value;
5989 // Return true if the next token matches the specified keyword
5990 Parser.prototype.matchKeyword = function (keyword) {
5991 return this.lookahead.type === 4 /* Keyword */ && this.lookahead.value === keyword;
5993 // Return true if the next token matches the specified contextual keyword
5994 // (where an identifier is sometimes a keyword depending on the context)
5995 Parser.prototype.matchContextualKeyword = function (keyword) {
5996 return this.lookahead.type === 3 /* Identifier */ && this.lookahead.value === keyword;
5998 // Return true if the next token is an assignment operator
5999 Parser.prototype.matchAssign = function () {
6000 if (this.lookahead.type !== 7 /* Punctuator */) {
6003 var op = this.lookahead.value;
6004 return op === '=' ||
6018 // Cover grammar support.
6020 // When an assignment expression position starts with an left parenthesis, the determination of the type
6021 // of the syntax is to be deferred arbitrarily long until the end of the parentheses pair (plus a lookahead)
6022 // or the first comma. This situation also defers the determination of all the expressions nested in the pair.
6024 // There are three productions that can be parsed in a parentheses pair that needs to be determined
6025 // after the outermost pair is closed. They are:
6027 // 1. AssignmentExpression
6028 // 2. BindingElements
6029 // 3. AssignmentTargets
6031 // In order to avoid exponential backtracking, we use two flags to denote if the production can be
6032 // binding element or assignment target.
6034 // The three productions have the relationship:
6036 // BindingElements ⊆ AssignmentTargets ⊆ AssignmentExpression
6038 // with a single exception that CoverInitializedName when used directly in an Expression, generates
6039 // an early error. Therefore, we need the third state, firstCoverInitializedNameError, to track the
6040 // first usage of CoverInitializedName and report it when we reached the end of the parentheses pair.
6042 // isolateCoverGrammar function runs the given parser function with a new cover grammar context, and it does not
6043 // effect the current flags. This means the production the parser parses is only used as an expression. Therefore
6044 // the CoverInitializedName check is conducted.
6046 // inheritCoverGrammar function runs the given parse function with a new cover grammar context, and it propagates
6047 // the flags outside of the parser. This means the production the parser parses is used as a part of a potential
6048 // pattern. The CoverInitializedName check is deferred.
6049 Parser.prototype.isolateCoverGrammar = function (parseFunction) {
6050 var previousIsBindingElement = this.context.isBindingElement;
6051 var previousIsAssignmentTarget = this.context.isAssignmentTarget;
6052 var previousFirstCoverInitializedNameError = this.context.firstCoverInitializedNameError;
6053 this.context.isBindingElement = true;
6054 this.context.isAssignmentTarget = true;
6055 this.context.firstCoverInitializedNameError = null;
6056 var result = parseFunction.call(this);
6057 if (this.context.firstCoverInitializedNameError !== null) {
6058 this.throwUnexpectedToken(this.context.firstCoverInitializedNameError);
6060 this.context.isBindingElement = previousIsBindingElement;
6061 this.context.isAssignmentTarget = previousIsAssignmentTarget;
6062 this.context.firstCoverInitializedNameError = previousFirstCoverInitializedNameError;
6065 Parser.prototype.inheritCoverGrammar = function (parseFunction) {
6066 var previousIsBindingElement = this.context.isBindingElement;
6067 var previousIsAssignmentTarget = this.context.isAssignmentTarget;
6068 var previousFirstCoverInitializedNameError = this.context.firstCoverInitializedNameError;
6069 this.context.isBindingElement = true;
6070 this.context.isAssignmentTarget = true;
6071 this.context.firstCoverInitializedNameError = null;
6072 var result = parseFunction.call(this);
6073 this.context.isBindingElement = this.context.isBindingElement && previousIsBindingElement;
6074 this.context.isAssignmentTarget = this.context.isAssignmentTarget && previousIsAssignmentTarget;
6075 this.context.firstCoverInitializedNameError = previousFirstCoverInitializedNameError || this.context.firstCoverInitializedNameError;
6078 Parser.prototype.consumeSemicolon = function () {
6079 if (this.match(';')) {
6082 else if (!this.hasLineTerminator) {
6083 if (this.lookahead.type !== 2 /* EOF */ && !this.match('}')) {
6084 this.throwUnexpectedToken(this.lookahead);
6086 this.lastMarker.index = this.startMarker.index;
6087 this.lastMarker.line = this.startMarker.line;
6088 this.lastMarker.column = this.startMarker.column;
6091 // https://tc39.github.io/ecma262/#sec-primary-expression
6092 Parser.prototype.parsePrimaryExpression = function () {
6093 var node = this.createNode();
6096 switch (this.lookahead.type) {
6097 case 3 /* Identifier */:
6098 if ((this.context.isModule || this.context.await) && this.lookahead.value === 'await') {
6099 this.tolerateUnexpectedToken(this.lookahead);
6101 expr = this.matchAsyncFunction() ? this.parseFunctionExpression() : this.finalize(node, new Node.Identifier(this.nextToken().value));
6103 case 6 /* NumericLiteral */:
6104 case 8 /* StringLiteral */:
6105 if (this.context.strict && this.lookahead.octal) {
6106 this.tolerateUnexpectedToken(this.lookahead, messages_1.Messages.StrictOctalLiteral);
6108 this.context.isAssignmentTarget = false;
6109 this.context.isBindingElement = false;
6110 token = this.nextToken();
6111 raw = this.getTokenRaw(token);
6112 expr = this.finalize(node, new Node.Literal(token.value, raw));
6114 case 1 /* BooleanLiteral */:
6115 this.context.isAssignmentTarget = false;
6116 this.context.isBindingElement = false;
6117 token = this.nextToken();
6118 raw = this.getTokenRaw(token);
6119 expr = this.finalize(node, new Node.Literal(token.value === 'true', raw));
6121 case 5 /* NullLiteral */:
6122 this.context.isAssignmentTarget = false;
6123 this.context.isBindingElement = false;
6124 token = this.nextToken();
6125 raw = this.getTokenRaw(token);
6126 expr = this.finalize(node, new Node.Literal(null, raw));
6128 case 10 /* Template */:
6129 expr = this.parseTemplateLiteral();
6131 case 7 /* Punctuator */:
6132 switch (this.lookahead.value) {
6134 this.context.isBindingElement = false;
6135 expr = this.inheritCoverGrammar(this.parseGroupExpression);
6138 expr = this.inheritCoverGrammar(this.parseArrayInitializer);
6141 expr = this.inheritCoverGrammar(this.parseObjectInitializer);
6145 this.context.isAssignmentTarget = false;
6146 this.context.isBindingElement = false;
6147 this.scanner.index = this.startMarker.index;
6148 token = this.nextRegexToken();
6149 raw = this.getTokenRaw(token);
6150 expr = this.finalize(node, new Node.RegexLiteral(token.regex, raw, token.pattern, token.flags));
6153 expr = this.throwUnexpectedToken(this.nextToken());
6156 case 4 /* Keyword */:
6157 if (!this.context.strict && this.context.allowYield && this.matchKeyword('yield')) {
6158 expr = this.parseIdentifierName();
6160 else if (!this.context.strict && this.matchKeyword('let')) {
6161 expr = this.finalize(node, new Node.Identifier(this.nextToken().value));
6164 this.context.isAssignmentTarget = false;
6165 this.context.isBindingElement = false;
6166 if (this.matchKeyword('function')) {
6167 expr = this.parseFunctionExpression();
6169 else if (this.matchKeyword('this')) {
6171 expr = this.finalize(node, new Node.ThisExpression());
6173 else if (this.matchKeyword('class')) {
6174 expr = this.parseClassExpression();
6177 expr = this.throwUnexpectedToken(this.nextToken());
6182 expr = this.throwUnexpectedToken(this.nextToken());
6186 // https://tc39.github.io/ecma262/#sec-array-initializer
6187 Parser.prototype.parseSpreadElement = function () {
6188 var node = this.createNode();
6190 var arg = this.inheritCoverGrammar(this.parseAssignmentExpression);
6191 return this.finalize(node, new Node.SpreadElement(arg));
6193 Parser.prototype.parseArrayInitializer = function () {
6194 var node = this.createNode();
6197 while (!this.match(']')) {
6198 if (this.match(',')) {
6200 elements.push(null);
6202 else if (this.match('...')) {
6203 var element = this.parseSpreadElement();
6204 if (!this.match(']')) {
6205 this.context.isAssignmentTarget = false;
6206 this.context.isBindingElement = false;
6209 elements.push(element);
6212 elements.push(this.inheritCoverGrammar(this.parseAssignmentExpression));
6213 if (!this.match(']')) {
6219 return this.finalize(node, new Node.ArrayExpression(elements));
6221 // https://tc39.github.io/ecma262/#sec-object-initializer
6222 Parser.prototype.parsePropertyMethod = function (params) {
6223 this.context.isAssignmentTarget = false;
6224 this.context.isBindingElement = false;
6225 var previousStrict = this.context.strict;
6226 var previousAllowStrictDirective = this.context.allowStrictDirective;
6227 this.context.allowStrictDirective = params.simple;
6228 var body = this.isolateCoverGrammar(this.parseFunctionSourceElements);
6229 if (this.context.strict && params.firstRestricted) {
6230 this.tolerateUnexpectedToken(params.firstRestricted, params.message);
6232 if (this.context.strict && params.stricted) {
6233 this.tolerateUnexpectedToken(params.stricted, params.message);
6235 this.context.strict = previousStrict;
6236 this.context.allowStrictDirective = previousAllowStrictDirective;
6239 Parser.prototype.parsePropertyMethodFunction = function () {
6240 var isGenerator = false;
6241 var node = this.createNode();
6242 var previousAllowYield = this.context.allowYield;
6243 this.context.allowYield = true;
6244 var params = this.parseFormalParameters();
6245 var method = this.parsePropertyMethod(params);
6246 this.context.allowYield = previousAllowYield;
6247 return this.finalize(node, new Node.FunctionExpression(null, params.params, method, isGenerator));
6249 Parser.prototype.parsePropertyMethodAsyncFunction = function () {
6250 var node = this.createNode();
6251 var previousAllowYield = this.context.allowYield;
6252 var previousAwait = this.context.await;
6253 this.context.allowYield = false;
6254 this.context.await = true;
6255 var params = this.parseFormalParameters();
6256 var method = this.parsePropertyMethod(params);
6257 this.context.allowYield = previousAllowYield;
6258 this.context.await = previousAwait;
6259 return this.finalize(node, new Node.AsyncFunctionExpression(null, params.params, method));
6261 Parser.prototype.parseObjectPropertyKey = function () {
6262 var node = this.createNode();
6263 var token = this.nextToken();
6265 switch (token.type) {
6266 case 8 /* StringLiteral */:
6267 case 6 /* NumericLiteral */:
6268 if (this.context.strict && token.octal) {
6269 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictOctalLiteral);
6271 var raw = this.getTokenRaw(token);
6272 key = this.finalize(node, new Node.Literal(token.value, raw));
6274 case 3 /* Identifier */:
6275 case 1 /* BooleanLiteral */:
6276 case 5 /* NullLiteral */:
6277 case 4 /* Keyword */:
6278 key = this.finalize(node, new Node.Identifier(token.value));
6280 case 7 /* Punctuator */:
6281 if (token.value === '[') {
6282 key = this.isolateCoverGrammar(this.parseAssignmentExpression);
6286 key = this.throwUnexpectedToken(token);
6290 key = this.throwUnexpectedToken(token);
6294 Parser.prototype.isPropertyKey = function (key, value) {
6295 return (key.type === syntax_1.Syntax.Identifier && key.name === value) ||
6296 (key.type === syntax_1.Syntax.Literal && key.value === value);
6298 Parser.prototype.parseObjectProperty = function (hasProto) {
6299 var node = this.createNode();
6300 var token = this.lookahead;
6304 var computed = false;
6306 var shorthand = false;
6307 var isAsync = false;
6308 if (token.type === 3 /* Identifier */) {
6309 var id = token.value;
6311 computed = this.match('[');
6312 isAsync = !this.hasLineTerminator && (id === 'async') &&
6313 !this.match(':') && !this.match('(') && !this.match('*') && !this.match(',');
6314 key = isAsync ? this.parseObjectPropertyKey() : this.finalize(node, new Node.Identifier(id));
6316 else if (this.match('*')) {
6320 computed = this.match('[');
6321 key = this.parseObjectPropertyKey();
6323 var lookaheadPropertyKey = this.qualifiedPropertyName(this.lookahead);
6324 if (token.type === 3 /* Identifier */ && !isAsync && token.value === 'get' && lookaheadPropertyKey) {
6326 computed = this.match('[');
6327 key = this.parseObjectPropertyKey();
6328 this.context.allowYield = false;
6329 value = this.parseGetterMethod();
6331 else if (token.type === 3 /* Identifier */ && !isAsync && token.value === 'set' && lookaheadPropertyKey) {
6333 computed = this.match('[');
6334 key = this.parseObjectPropertyKey();
6335 value = this.parseSetterMethod();
6337 else if (token.type === 7 /* Punctuator */ && token.value === '*' && lookaheadPropertyKey) {
6339 computed = this.match('[');
6340 key = this.parseObjectPropertyKey();
6341 value = this.parseGeneratorMethod();
6346 this.throwUnexpectedToken(this.lookahead);
6349 if (this.match(':') && !isAsync) {
6350 if (!computed && this.isPropertyKey(key, '__proto__')) {
6351 if (hasProto.value) {
6352 this.tolerateError(messages_1.Messages.DuplicateProtoProperty);
6354 hasProto.value = true;
6357 value = this.inheritCoverGrammar(this.parseAssignmentExpression);
6359 else if (this.match('(')) {
6360 value = isAsync ? this.parsePropertyMethodAsyncFunction() : this.parsePropertyMethodFunction();
6363 else if (token.type === 3 /* Identifier */) {
6364 var id = this.finalize(node, new Node.Identifier(token.value));
6365 if (this.match('=')) {
6366 this.context.firstCoverInitializedNameError = this.lookahead;
6369 var init = this.isolateCoverGrammar(this.parseAssignmentExpression);
6370 value = this.finalize(node, new Node.AssignmentPattern(id, init));
6378 this.throwUnexpectedToken(this.nextToken());
6381 return this.finalize(node, new Node.Property(kind, key, computed, value, method, shorthand));
6383 Parser.prototype.parseObjectInitializer = function () {
6384 var node = this.createNode();
6386 var properties = [];
6387 var hasProto = { value: false };
6388 while (!this.match('}')) {
6389 properties.push(this.parseObjectProperty(hasProto));
6390 if (!this.match('}')) {
6391 this.expectCommaSeparator();
6395 return this.finalize(node, new Node.ObjectExpression(properties));
6397 // https://tc39.github.io/ecma262/#sec-template-literals
6398 Parser.prototype.parseTemplateHead = function () {
6399 assert_1.assert(this.lookahead.head, 'Template literal must start with a template head');
6400 var node = this.createNode();
6401 var token = this.nextToken();
6402 var raw = token.value;
6403 var cooked = token.cooked;
6404 return this.finalize(node, new Node.TemplateElement({ raw: raw, cooked: cooked }, token.tail));
6406 Parser.prototype.parseTemplateElement = function () {
6407 if (this.lookahead.type !== 10 /* Template */) {
6408 this.throwUnexpectedToken();
6410 var node = this.createNode();
6411 var token = this.nextToken();
6412 var raw = token.value;
6413 var cooked = token.cooked;
6414 return this.finalize(node, new Node.TemplateElement({ raw: raw, cooked: cooked }, token.tail));
6416 Parser.prototype.parseTemplateLiteral = function () {
6417 var node = this.createNode();
6418 var expressions = [];
6420 var quasi = this.parseTemplateHead();
6422 while (!quasi.tail) {
6423 expressions.push(this.parseExpression());
6424 quasi = this.parseTemplateElement();
6427 return this.finalize(node, new Node.TemplateLiteral(quasis, expressions));
6429 // https://tc39.github.io/ecma262/#sec-grouping-operator
6430 Parser.prototype.reinterpretExpressionAsPattern = function (expr) {
6431 switch (expr.type) {
6432 case syntax_1.Syntax.Identifier:
6433 case syntax_1.Syntax.MemberExpression:
6434 case syntax_1.Syntax.RestElement:
6435 case syntax_1.Syntax.AssignmentPattern:
6437 case syntax_1.Syntax.SpreadElement:
6438 expr.type = syntax_1.Syntax.RestElement;
6439 this.reinterpretExpressionAsPattern(expr.argument);
6441 case syntax_1.Syntax.ArrayExpression:
6442 expr.type = syntax_1.Syntax.ArrayPattern;
6443 for (var i = 0; i < expr.elements.length; i++) {
6444 if (expr.elements[i] !== null) {
6445 this.reinterpretExpressionAsPattern(expr.elements[i]);
6449 case syntax_1.Syntax.ObjectExpression:
6450 expr.type = syntax_1.Syntax.ObjectPattern;
6451 for (var i = 0; i < expr.properties.length; i++) {
6452 this.reinterpretExpressionAsPattern(expr.properties[i].value);
6455 case syntax_1.Syntax.AssignmentExpression:
6456 expr.type = syntax_1.Syntax.AssignmentPattern;
6457 delete expr.operator;
6458 this.reinterpretExpressionAsPattern(expr.left);
6461 // Allow other node type for tolerant parsing.
6465 Parser.prototype.parseGroupExpression = function () {
6468 if (this.match(')')) {
6470 if (!this.match('=>')) {
6474 type: ArrowParameterPlaceHolder,
6480 var startToken = this.lookahead;
6482 if (this.match('...')) {
6483 expr = this.parseRestElement(params);
6485 if (!this.match('=>')) {
6489 type: ArrowParameterPlaceHolder,
6496 this.context.isBindingElement = true;
6497 expr = this.inheritCoverGrammar(this.parseAssignmentExpression);
6498 if (this.match(',')) {
6499 var expressions = [];
6500 this.context.isAssignmentTarget = false;
6501 expressions.push(expr);
6502 while (this.lookahead.type !== 2 /* EOF */) {
6503 if (!this.match(',')) {
6507 if (this.match(')')) {
6509 for (var i = 0; i < expressions.length; i++) {
6510 this.reinterpretExpressionAsPattern(expressions[i]);
6514 type: ArrowParameterPlaceHolder,
6515 params: expressions,
6519 else if (this.match('...')) {
6520 if (!this.context.isBindingElement) {
6521 this.throwUnexpectedToken(this.lookahead);
6523 expressions.push(this.parseRestElement(params));
6525 if (!this.match('=>')) {
6528 this.context.isBindingElement = false;
6529 for (var i = 0; i < expressions.length; i++) {
6530 this.reinterpretExpressionAsPattern(expressions[i]);
6534 type: ArrowParameterPlaceHolder,
6535 params: expressions,
6540 expressions.push(this.inheritCoverGrammar(this.parseAssignmentExpression));
6547 expr = this.finalize(this.startNode(startToken), new Node.SequenceExpression(expressions));
6552 if (this.match('=>')) {
6553 if (expr.type === syntax_1.Syntax.Identifier && expr.name === 'yield') {
6556 type: ArrowParameterPlaceHolder,
6562 if (!this.context.isBindingElement) {
6563 this.throwUnexpectedToken(this.lookahead);
6565 if (expr.type === syntax_1.Syntax.SequenceExpression) {
6566 for (var i = 0; i < expr.expressions.length; i++) {
6567 this.reinterpretExpressionAsPattern(expr.expressions[i]);
6571 this.reinterpretExpressionAsPattern(expr);
6573 var parameters = (expr.type === syntax_1.Syntax.SequenceExpression ? expr.expressions : [expr]);
6575 type: ArrowParameterPlaceHolder,
6581 this.context.isBindingElement = false;
6587 // https://tc39.github.io/ecma262/#sec-left-hand-side-expressions
6588 Parser.prototype.parseArguments = function () {
6591 if (!this.match(')')) {
6593 var expr = this.match('...') ? this.parseSpreadElement() :
6594 this.isolateCoverGrammar(this.parseAssignmentExpression);
6596 if (this.match(')')) {
6599 this.expectCommaSeparator();
6600 if (this.match(')')) {
6608 Parser.prototype.isIdentifierName = function (token) {
6609 return token.type === 3 /* Identifier */ ||
6610 token.type === 4 /* Keyword */ ||
6611 token.type === 1 /* BooleanLiteral */ ||
6612 token.type === 5 /* NullLiteral */;
6614 Parser.prototype.parseIdentifierName = function () {
6615 var node = this.createNode();
6616 var token = this.nextToken();
6617 if (!this.isIdentifierName(token)) {
6618 this.throwUnexpectedToken(token);
6620 return this.finalize(node, new Node.Identifier(token.value));
6622 Parser.prototype.parseNewExpression = function () {
6623 var node = this.createNode();
6624 var id = this.parseIdentifierName();
6625 assert_1.assert(id.name === 'new', 'New expression must start with `new`');
6627 if (this.match('.')) {
6629 if (this.lookahead.type === 3 /* Identifier */ && this.context.inFunctionBody && this.lookahead.value === 'target') {
6630 var property = this.parseIdentifierName();
6631 expr = new Node.MetaProperty(id, property);
6634 this.throwUnexpectedToken(this.lookahead);
6638 var callee = this.isolateCoverGrammar(this.parseLeftHandSideExpression);
6639 var args = this.match('(') ? this.parseArguments() : [];
6640 expr = new Node.NewExpression(callee, args);
6641 this.context.isAssignmentTarget = false;
6642 this.context.isBindingElement = false;
6644 return this.finalize(node, expr);
6646 Parser.prototype.parseAsyncArgument = function () {
6647 var arg = this.parseAssignmentExpression();
6648 this.context.firstCoverInitializedNameError = null;
6651 Parser.prototype.parseAsyncArguments = function () {
6654 if (!this.match(')')) {
6656 var expr = this.match('...') ? this.parseSpreadElement() :
6657 this.isolateCoverGrammar(this.parseAsyncArgument);
6659 if (this.match(')')) {
6662 this.expectCommaSeparator();
6663 if (this.match(')')) {
6671 Parser.prototype.parseLeftHandSideExpressionAllowCall = function () {
6672 var startToken = this.lookahead;
6673 var maybeAsync = this.matchContextualKeyword('async');
6674 var previousAllowIn = this.context.allowIn;
6675 this.context.allowIn = true;
6677 if (this.matchKeyword('super') && this.context.inFunctionBody) {
6678 expr = this.createNode();
6680 expr = this.finalize(expr, new Node.Super());
6681 if (!this.match('(') && !this.match('.') && !this.match('[')) {
6682 this.throwUnexpectedToken(this.lookahead);
6686 expr = this.inheritCoverGrammar(this.matchKeyword('new') ? this.parseNewExpression : this.parsePrimaryExpression);
6689 if (this.match('.')) {
6690 this.context.isBindingElement = false;
6691 this.context.isAssignmentTarget = true;
6693 var property = this.parseIdentifierName();
6694 expr = this.finalize(this.startNode(startToken), new Node.StaticMemberExpression(expr, property));
6696 else if (this.match('(')) {
6697 var asyncArrow = maybeAsync && (startToken.lineNumber === this.lookahead.lineNumber);
6698 this.context.isBindingElement = false;
6699 this.context.isAssignmentTarget = false;
6700 var args = asyncArrow ? this.parseAsyncArguments() : this.parseArguments();
6701 expr = this.finalize(this.startNode(startToken), new Node.CallExpression(expr, args));
6702 if (asyncArrow && this.match('=>')) {
6703 for (var i = 0; i < args.length; ++i) {
6704 this.reinterpretExpressionAsPattern(args[i]);
6707 type: ArrowParameterPlaceHolder,
6713 else if (this.match('[')) {
6714 this.context.isBindingElement = false;
6715 this.context.isAssignmentTarget = true;
6717 var property = this.isolateCoverGrammar(this.parseExpression);
6719 expr = this.finalize(this.startNode(startToken), new Node.ComputedMemberExpression(expr, property));
6721 else if (this.lookahead.type === 10 /* Template */ && this.lookahead.head) {
6722 var quasi = this.parseTemplateLiteral();
6723 expr = this.finalize(this.startNode(startToken), new Node.TaggedTemplateExpression(expr, quasi));
6729 this.context.allowIn = previousAllowIn;
6732 Parser.prototype.parseSuper = function () {
6733 var node = this.createNode();
6734 this.expectKeyword('super');
6735 if (!this.match('[') && !this.match('.')) {
6736 this.throwUnexpectedToken(this.lookahead);
6738 return this.finalize(node, new Node.Super());
6740 Parser.prototype.parseLeftHandSideExpression = function () {
6741 assert_1.assert(this.context.allowIn, 'callee of new expression always allow in keyword.');
6742 var node = this.startNode(this.lookahead);
6743 var expr = (this.matchKeyword('super') && this.context.inFunctionBody) ? this.parseSuper() :
6744 this.inheritCoverGrammar(this.matchKeyword('new') ? this.parseNewExpression : this.parsePrimaryExpression);
6746 if (this.match('[')) {
6747 this.context.isBindingElement = false;
6748 this.context.isAssignmentTarget = true;
6750 var property = this.isolateCoverGrammar(this.parseExpression);
6752 expr = this.finalize(node, new Node.ComputedMemberExpression(expr, property));
6754 else if (this.match('.')) {
6755 this.context.isBindingElement = false;
6756 this.context.isAssignmentTarget = true;
6758 var property = this.parseIdentifierName();
6759 expr = this.finalize(node, new Node.StaticMemberExpression(expr, property));
6761 else if (this.lookahead.type === 10 /* Template */ && this.lookahead.head) {
6762 var quasi = this.parseTemplateLiteral();
6763 expr = this.finalize(node, new Node.TaggedTemplateExpression(expr, quasi));
6771 // https://tc39.github.io/ecma262/#sec-update-expressions
6772 Parser.prototype.parseUpdateExpression = function () {
6774 var startToken = this.lookahead;
6775 if (this.match('++') || this.match('--')) {
6776 var node = this.startNode(startToken);
6777 var token = this.nextToken();
6778 expr = this.inheritCoverGrammar(this.parseUnaryExpression);
6779 if (this.context.strict && expr.type === syntax_1.Syntax.Identifier && this.scanner.isRestrictedWord(expr.name)) {
6780 this.tolerateError(messages_1.Messages.StrictLHSPrefix);
6782 if (!this.context.isAssignmentTarget) {
6783 this.tolerateError(messages_1.Messages.InvalidLHSInAssignment);
6786 expr = this.finalize(node, new Node.UpdateExpression(token.value, expr, prefix));
6787 this.context.isAssignmentTarget = false;
6788 this.context.isBindingElement = false;
6791 expr = this.inheritCoverGrammar(this.parseLeftHandSideExpressionAllowCall);
6792 if (!this.hasLineTerminator && this.lookahead.type === 7 /* Punctuator */) {
6793 if (this.match('++') || this.match('--')) {
6794 if (this.context.strict && expr.type === syntax_1.Syntax.Identifier && this.scanner.isRestrictedWord(expr.name)) {
6795 this.tolerateError(messages_1.Messages.StrictLHSPostfix);
6797 if (!this.context.isAssignmentTarget) {
6798 this.tolerateError(messages_1.Messages.InvalidLHSInAssignment);
6800 this.context.isAssignmentTarget = false;
6801 this.context.isBindingElement = false;
6802 var operator = this.nextToken().value;
6804 expr = this.finalize(this.startNode(startToken), new Node.UpdateExpression(operator, expr, prefix));
6810 // https://tc39.github.io/ecma262/#sec-unary-operators
6811 Parser.prototype.parseAwaitExpression = function () {
6812 var node = this.createNode();
6814 var argument = this.parseUnaryExpression();
6815 return this.finalize(node, new Node.AwaitExpression(argument));
6817 Parser.prototype.parseUnaryExpression = function () {
6819 if (this.match('+') || this.match('-') || this.match('~') || this.match('!') ||
6820 this.matchKeyword('delete') || this.matchKeyword('void') || this.matchKeyword('typeof')) {
6821 var node = this.startNode(this.lookahead);
6822 var token = this.nextToken();
6823 expr = this.inheritCoverGrammar(this.parseUnaryExpression);
6824 expr = this.finalize(node, new Node.UnaryExpression(token.value, expr));
6825 if (this.context.strict && expr.operator === 'delete' && expr.argument.type === syntax_1.Syntax.Identifier) {
6826 this.tolerateError(messages_1.Messages.StrictDelete);
6828 this.context.isAssignmentTarget = false;
6829 this.context.isBindingElement = false;
6831 else if (this.context.await && this.matchContextualKeyword('await')) {
6832 expr = this.parseAwaitExpression();
6835 expr = this.parseUpdateExpression();
6839 Parser.prototype.parseExponentiationExpression = function () {
6840 var startToken = this.lookahead;
6841 var expr = this.inheritCoverGrammar(this.parseUnaryExpression);
6842 if (expr.type !== syntax_1.Syntax.UnaryExpression && this.match('**')) {
6844 this.context.isAssignmentTarget = false;
6845 this.context.isBindingElement = false;
6847 var right = this.isolateCoverGrammar(this.parseExponentiationExpression);
6848 expr = this.finalize(this.startNode(startToken), new Node.BinaryExpression('**', left, right));
6852 // https://tc39.github.io/ecma262/#sec-exp-operator
6853 // https://tc39.github.io/ecma262/#sec-multiplicative-operators
6854 // https://tc39.github.io/ecma262/#sec-additive-operators
6855 // https://tc39.github.io/ecma262/#sec-bitwise-shift-operators
6856 // https://tc39.github.io/ecma262/#sec-relational-operators
6857 // https://tc39.github.io/ecma262/#sec-equality-operators
6858 // https://tc39.github.io/ecma262/#sec-binary-bitwise-operators
6859 // https://tc39.github.io/ecma262/#sec-binary-logical-operators
6860 Parser.prototype.binaryPrecedence = function (token) {
6861 var op = token.value;
6863 if (token.type === 7 /* Punctuator */) {
6864 precedence = this.operatorPrecedence[op] || 0;
6866 else if (token.type === 4 /* Keyword */) {
6867 precedence = (op === 'instanceof' || (this.context.allowIn && op === 'in')) ? 7 : 0;
6874 Parser.prototype.parseBinaryExpression = function () {
6875 var startToken = this.lookahead;
6876 var expr = this.inheritCoverGrammar(this.parseExponentiationExpression);
6877 var token = this.lookahead;
6878 var prec = this.binaryPrecedence(token);
6881 this.context.isAssignmentTarget = false;
6882 this.context.isBindingElement = false;
6883 var markers = [startToken, this.lookahead];
6885 var right = this.isolateCoverGrammar(this.parseExponentiationExpression);
6886 var stack = [left, token.value, right];
6887 var precedences = [prec];
6889 prec = this.binaryPrecedence(this.lookahead);
6893 // Reduce: make a binary expression from the three topmost entries.
6894 while ((stack.length > 2) && (prec <= precedences[precedences.length - 1])) {
6895 right = stack.pop();
6896 var operator = stack.pop();
6900 var node = this.startNode(markers[markers.length - 1]);
6901 stack.push(this.finalize(node, new Node.BinaryExpression(operator, left, right)));
6904 stack.push(this.nextToken().value);
6905 precedences.push(prec);
6906 markers.push(this.lookahead);
6907 stack.push(this.isolateCoverGrammar(this.parseExponentiationExpression));
6909 // Final reduce to clean-up the stack.
6910 var i = stack.length - 1;
6912 var lastMarker = markers.pop();
6914 var marker = markers.pop();
6915 var lastLineStart = lastMarker && lastMarker.lineStart;
6916 var node = this.startNode(marker, lastLineStart);
6917 var operator = stack[i - 1];
6918 expr = this.finalize(node, new Node.BinaryExpression(operator, stack[i - 2], expr));
6920 lastMarker = marker;
6925 // https://tc39.github.io/ecma262/#sec-conditional-operator
6926 Parser.prototype.parseConditionalExpression = function () {
6927 var startToken = this.lookahead;
6928 var expr = this.inheritCoverGrammar(this.parseBinaryExpression);
6929 if (this.match('?')) {
6931 var previousAllowIn = this.context.allowIn;
6932 this.context.allowIn = true;
6933 var consequent = this.isolateCoverGrammar(this.parseAssignmentExpression);
6934 this.context.allowIn = previousAllowIn;
6936 var alternate = this.isolateCoverGrammar(this.parseAssignmentExpression);
6937 expr = this.finalize(this.startNode(startToken), new Node.ConditionalExpression(expr, consequent, alternate));
6938 this.context.isAssignmentTarget = false;
6939 this.context.isBindingElement = false;
6943 // https://tc39.github.io/ecma262/#sec-assignment-operators
6944 Parser.prototype.checkPatternParam = function (options, param) {
6945 switch (param.type) {
6946 case syntax_1.Syntax.Identifier:
6947 this.validateParam(options, param, param.name);
6949 case syntax_1.Syntax.RestElement:
6950 this.checkPatternParam(options, param.argument);
6952 case syntax_1.Syntax.AssignmentPattern:
6953 this.checkPatternParam(options, param.left);
6955 case syntax_1.Syntax.ArrayPattern:
6956 for (var i = 0; i < param.elements.length; i++) {
6957 if (param.elements[i] !== null) {
6958 this.checkPatternParam(options, param.elements[i]);
6962 case syntax_1.Syntax.ObjectPattern:
6963 for (var i = 0; i < param.properties.length; i++) {
6964 this.checkPatternParam(options, param.properties[i].value);
6970 options.simple = options.simple && (param instanceof Node.Identifier);
6972 Parser.prototype.reinterpretAsCoverFormalsList = function (expr) {
6973 var params = [expr];
6975 var asyncArrow = false;
6976 switch (expr.type) {
6977 case syntax_1.Syntax.Identifier:
6979 case ArrowParameterPlaceHolder:
6980 params = expr.params;
6981 asyncArrow = expr.async;
6990 for (var i = 0; i < params.length; ++i) {
6991 var param = params[i];
6992 if (param.type === syntax_1.Syntax.AssignmentPattern) {
6993 if (param.right.type === syntax_1.Syntax.YieldExpression) {
6994 if (param.right.argument) {
6995 this.throwUnexpectedToken(this.lookahead);
6997 param.right.type = syntax_1.Syntax.Identifier;
6998 param.right.name = 'yield';
6999 delete param.right.argument;
7000 delete param.right.delegate;
7003 else if (asyncArrow && param.type === syntax_1.Syntax.Identifier && param.name === 'await') {
7004 this.throwUnexpectedToken(this.lookahead);
7006 this.checkPatternParam(options, param);
7009 if (this.context.strict || !this.context.allowYield) {
7010 for (var i = 0; i < params.length; ++i) {
7011 var param = params[i];
7012 if (param.type === syntax_1.Syntax.YieldExpression) {
7013 this.throwUnexpectedToken(this.lookahead);
7017 if (options.message === messages_1.Messages.StrictParamDupe) {
7018 var token = this.context.strict ? options.stricted : options.firstRestricted;
7019 this.throwUnexpectedToken(token, options.message);
7022 simple: options.simple,
7024 stricted: options.stricted,
7025 firstRestricted: options.firstRestricted,
7026 message: options.message
7029 Parser.prototype.parseAssignmentExpression = function () {
7031 if (!this.context.allowYield && this.matchKeyword('yield')) {
7032 expr = this.parseYieldExpression();
7035 var startToken = this.lookahead;
7036 var token = startToken;
7037 expr = this.parseConditionalExpression();
7038 if (token.type === 3 /* Identifier */ && (token.lineNumber === this.lookahead.lineNumber) && token.value === 'async') {
7039 if (this.lookahead.type === 3 /* Identifier */ || this.matchKeyword('yield')) {
7040 var arg = this.parsePrimaryExpression();
7041 this.reinterpretExpressionAsPattern(arg);
7043 type: ArrowParameterPlaceHolder,
7049 if (expr.type === ArrowParameterPlaceHolder || this.match('=>')) {
7050 // https://tc39.github.io/ecma262/#sec-arrow-function-definitions
7051 this.context.isAssignmentTarget = false;
7052 this.context.isBindingElement = false;
7053 var isAsync = expr.async;
7054 var list = this.reinterpretAsCoverFormalsList(expr);
7056 if (this.hasLineTerminator) {
7057 this.tolerateUnexpectedToken(this.lookahead);
7059 this.context.firstCoverInitializedNameError = null;
7060 var previousStrict = this.context.strict;
7061 var previousAllowStrictDirective = this.context.allowStrictDirective;
7062 this.context.allowStrictDirective = list.simple;
7063 var previousAllowYield = this.context.allowYield;
7064 var previousAwait = this.context.await;
7065 this.context.allowYield = true;
7066 this.context.await = isAsync;
7067 var node = this.startNode(startToken);
7070 if (this.match('{')) {
7071 var previousAllowIn = this.context.allowIn;
7072 this.context.allowIn = true;
7073 body = this.parseFunctionSourceElements();
7074 this.context.allowIn = previousAllowIn;
7077 body = this.isolateCoverGrammar(this.parseAssignmentExpression);
7079 var expression = body.type !== syntax_1.Syntax.BlockStatement;
7080 if (this.context.strict && list.firstRestricted) {
7081 this.throwUnexpectedToken(list.firstRestricted, list.message);
7083 if (this.context.strict && list.stricted) {
7084 this.tolerateUnexpectedToken(list.stricted, list.message);
7086 expr = isAsync ? this.finalize(node, new Node.AsyncArrowFunctionExpression(list.params, body, expression)) :
7087 this.finalize(node, new Node.ArrowFunctionExpression(list.params, body, expression));
7088 this.context.strict = previousStrict;
7089 this.context.allowStrictDirective = previousAllowStrictDirective;
7090 this.context.allowYield = previousAllowYield;
7091 this.context.await = previousAwait;
7095 if (this.matchAssign()) {
7096 if (!this.context.isAssignmentTarget) {
7097 this.tolerateError(messages_1.Messages.InvalidLHSInAssignment);
7099 if (this.context.strict && expr.type === syntax_1.Syntax.Identifier) {
7101 if (this.scanner.isRestrictedWord(id.name)) {
7102 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictLHSAssignment);
7104 if (this.scanner.isStrictModeReservedWord(id.name)) {
7105 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictReservedWord);
7108 if (!this.match('=')) {
7109 this.context.isAssignmentTarget = false;
7110 this.context.isBindingElement = false;
7113 this.reinterpretExpressionAsPattern(expr);
7115 token = this.nextToken();
7116 var operator = token.value;
7117 var right = this.isolateCoverGrammar(this.parseAssignmentExpression);
7118 expr = this.finalize(this.startNode(startToken), new Node.AssignmentExpression(operator, expr, right));
7119 this.context.firstCoverInitializedNameError = null;
7125 // https://tc39.github.io/ecma262/#sec-comma-operator
7126 Parser.prototype.parseExpression = function () {
7127 var startToken = this.lookahead;
7128 var expr = this.isolateCoverGrammar(this.parseAssignmentExpression);
7129 if (this.match(',')) {
7130 var expressions = [];
7131 expressions.push(expr);
7132 while (this.lookahead.type !== 2 /* EOF */) {
7133 if (!this.match(',')) {
7137 expressions.push(this.isolateCoverGrammar(this.parseAssignmentExpression));
7139 expr = this.finalize(this.startNode(startToken), new Node.SequenceExpression(expressions));
7143 // https://tc39.github.io/ecma262/#sec-block
7144 Parser.prototype.parseStatementListItem = function () {
7146 this.context.isAssignmentTarget = true;
7147 this.context.isBindingElement = true;
7148 if (this.lookahead.type === 4 /* Keyword */) {
7149 switch (this.lookahead.value) {
7151 if (!this.context.isModule) {
7152 this.tolerateUnexpectedToken(this.lookahead, messages_1.Messages.IllegalExportDeclaration);
7154 statement = this.parseExportDeclaration();
7157 if (!this.context.isModule) {
7158 this.tolerateUnexpectedToken(this.lookahead, messages_1.Messages.IllegalImportDeclaration);
7160 statement = this.parseImportDeclaration();
7163 statement = this.parseLexicalDeclaration({ inFor: false });
7166 statement = this.parseFunctionDeclaration();
7169 statement = this.parseClassDeclaration();
7172 statement = this.isLexicalDeclaration() ? this.parseLexicalDeclaration({ inFor: false }) : this.parseStatement();
7175 statement = this.parseStatement();
7180 statement = this.parseStatement();
7184 Parser.prototype.parseBlock = function () {
7185 var node = this.createNode();
7189 if (this.match('}')) {
7192 block.push(this.parseStatementListItem());
7195 return this.finalize(node, new Node.BlockStatement(block));
7197 // https://tc39.github.io/ecma262/#sec-let-and-const-declarations
7198 Parser.prototype.parseLexicalBinding = function (kind, options) {
7199 var node = this.createNode();
7201 var id = this.parsePattern(params, kind);
7202 if (this.context.strict && id.type === syntax_1.Syntax.Identifier) {
7203 if (this.scanner.isRestrictedWord(id.name)) {
7204 this.tolerateError(messages_1.Messages.StrictVarName);
7208 if (kind === 'const') {
7209 if (!this.matchKeyword('in') && !this.matchContextualKeyword('of')) {
7210 if (this.match('=')) {
7212 init = this.isolateCoverGrammar(this.parseAssignmentExpression);
7215 this.throwError(messages_1.Messages.DeclarationMissingInitializer, 'const');
7219 else if ((!options.inFor && id.type !== syntax_1.Syntax.Identifier) || this.match('=')) {
7221 init = this.isolateCoverGrammar(this.parseAssignmentExpression);
7223 return this.finalize(node, new Node.VariableDeclarator(id, init));
7225 Parser.prototype.parseBindingList = function (kind, options) {
7226 var list = [this.parseLexicalBinding(kind, options)];
7227 while (this.match(',')) {
7229 list.push(this.parseLexicalBinding(kind, options));
7233 Parser.prototype.isLexicalDeclaration = function () {
7234 var state = this.scanner.saveState();
7235 this.scanner.scanComments();
7236 var next = this.scanner.lex();
7237 this.scanner.restoreState(state);
7238 return (next.type === 3 /* Identifier */) ||
7239 (next.type === 7 /* Punctuator */ && next.value === '[') ||
7240 (next.type === 7 /* Punctuator */ && next.value === '{') ||
7241 (next.type === 4 /* Keyword */ && next.value === 'let') ||
7242 (next.type === 4 /* Keyword */ && next.value === 'yield');
7244 Parser.prototype.parseLexicalDeclaration = function (options) {
7245 var node = this.createNode();
7246 var kind = this.nextToken().value;
7247 assert_1.assert(kind === 'let' || kind === 'const', 'Lexical declaration must be either let or const');
7248 var declarations = this.parseBindingList(kind, options);
7249 this.consumeSemicolon();
7250 return this.finalize(node, new Node.VariableDeclaration(declarations, kind));
7252 // https://tc39.github.io/ecma262/#sec-destructuring-binding-patterns
7253 Parser.prototype.parseBindingRestElement = function (params, kind) {
7254 var node = this.createNode();
7256 var arg = this.parsePattern(params, kind);
7257 return this.finalize(node, new Node.RestElement(arg));
7259 Parser.prototype.parseArrayPattern = function (params, kind) {
7260 var node = this.createNode();
7263 while (!this.match(']')) {
7264 if (this.match(',')) {
7266 elements.push(null);
7269 if (this.match('...')) {
7270 elements.push(this.parseBindingRestElement(params, kind));
7274 elements.push(this.parsePatternWithDefault(params, kind));
7276 if (!this.match(']')) {
7282 return this.finalize(node, new Node.ArrayPattern(elements));
7284 Parser.prototype.parsePropertyPattern = function (params, kind) {
7285 var node = this.createNode();
7286 var computed = false;
7287 var shorthand = false;
7291 if (this.lookahead.type === 3 /* Identifier */) {
7292 var keyToken = this.lookahead;
7293 key = this.parseVariableIdentifier();
7294 var init = this.finalize(node, new Node.Identifier(keyToken.value));
7295 if (this.match('=')) {
7296 params.push(keyToken);
7299 var expr = this.parseAssignmentExpression();
7300 value = this.finalize(this.startNode(keyToken), new Node.AssignmentPattern(init, expr));
7302 else if (!this.match(':')) {
7303 params.push(keyToken);
7309 value = this.parsePatternWithDefault(params, kind);
7313 computed = this.match('[');
7314 key = this.parseObjectPropertyKey();
7316 value = this.parsePatternWithDefault(params, kind);
7318 return this.finalize(node, new Node.Property('init', key, computed, value, method, shorthand));
7320 Parser.prototype.parseObjectPattern = function (params, kind) {
7321 var node = this.createNode();
7322 var properties = [];
7324 while (!this.match('}')) {
7325 properties.push(this.parsePropertyPattern(params, kind));
7326 if (!this.match('}')) {
7331 return this.finalize(node, new Node.ObjectPattern(properties));
7333 Parser.prototype.parsePattern = function (params, kind) {
7335 if (this.match('[')) {
7336 pattern = this.parseArrayPattern(params, kind);
7338 else if (this.match('{')) {
7339 pattern = this.parseObjectPattern(params, kind);
7342 if (this.matchKeyword('let') && (kind === 'const' || kind === 'let')) {
7343 this.tolerateUnexpectedToken(this.lookahead, messages_1.Messages.LetInLexicalBinding);
7345 params.push(this.lookahead);
7346 pattern = this.parseVariableIdentifier(kind);
7350 Parser.prototype.parsePatternWithDefault = function (params, kind) {
7351 var startToken = this.lookahead;
7352 var pattern = this.parsePattern(params, kind);
7353 if (this.match('=')) {
7355 var previousAllowYield = this.context.allowYield;
7356 this.context.allowYield = true;
7357 var right = this.isolateCoverGrammar(this.parseAssignmentExpression);
7358 this.context.allowYield = previousAllowYield;
7359 pattern = this.finalize(this.startNode(startToken), new Node.AssignmentPattern(pattern, right));
7363 // https://tc39.github.io/ecma262/#sec-variable-statement
7364 Parser.prototype.parseVariableIdentifier = function (kind) {
7365 var node = this.createNode();
7366 var token = this.nextToken();
7367 if (token.type === 4 /* Keyword */ && token.value === 'yield') {
7368 if (this.context.strict) {
7369 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictReservedWord);
7371 else if (!this.context.allowYield) {
7372 this.throwUnexpectedToken(token);
7375 else if (token.type !== 3 /* Identifier */) {
7376 if (this.context.strict && token.type === 4 /* Keyword */ && this.scanner.isStrictModeReservedWord(token.value)) {
7377 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictReservedWord);
7380 if (this.context.strict || token.value !== 'let' || kind !== 'var') {
7381 this.throwUnexpectedToken(token);
7385 else if ((this.context.isModule || this.context.await) && token.type === 3 /* Identifier */ && token.value === 'await') {
7386 this.tolerateUnexpectedToken(token);
7388 return this.finalize(node, new Node.Identifier(token.value));
7390 Parser.prototype.parseVariableDeclaration = function (options) {
7391 var node = this.createNode();
7393 var id = this.parsePattern(params, 'var');
7394 if (this.context.strict && id.type === syntax_1.Syntax.Identifier) {
7395 if (this.scanner.isRestrictedWord(id.name)) {
7396 this.tolerateError(messages_1.Messages.StrictVarName);
7400 if (this.match('=')) {
7402 init = this.isolateCoverGrammar(this.parseAssignmentExpression);
7404 else if (id.type !== syntax_1.Syntax.Identifier && !options.inFor) {
7407 return this.finalize(node, new Node.VariableDeclarator(id, init));
7409 Parser.prototype.parseVariableDeclarationList = function (options) {
7410 var opt = { inFor: options.inFor };
7412 list.push(this.parseVariableDeclaration(opt));
7413 while (this.match(',')) {
7415 list.push(this.parseVariableDeclaration(opt));
7419 Parser.prototype.parseVariableStatement = function () {
7420 var node = this.createNode();
7421 this.expectKeyword('var');
7422 var declarations = this.parseVariableDeclarationList({ inFor: false });
7423 this.consumeSemicolon();
7424 return this.finalize(node, new Node.VariableDeclaration(declarations, 'var'));
7426 // https://tc39.github.io/ecma262/#sec-empty-statement
7427 Parser.prototype.parseEmptyStatement = function () {
7428 var node = this.createNode();
7430 return this.finalize(node, new Node.EmptyStatement());
7432 // https://tc39.github.io/ecma262/#sec-expression-statement
7433 Parser.prototype.parseExpressionStatement = function () {
7434 var node = this.createNode();
7435 var expr = this.parseExpression();
7436 this.consumeSemicolon();
7437 return this.finalize(node, new Node.ExpressionStatement(expr));
7439 // https://tc39.github.io/ecma262/#sec-if-statement
7440 Parser.prototype.parseIfClause = function () {
7441 if (this.context.strict && this.matchKeyword('function')) {
7442 this.tolerateError(messages_1.Messages.StrictFunction);
7444 return this.parseStatement();
7446 Parser.prototype.parseIfStatement = function () {
7447 var node = this.createNode();
7449 var alternate = null;
7450 this.expectKeyword('if');
7452 var test = this.parseExpression();
7453 if (!this.match(')') && this.config.tolerant) {
7454 this.tolerateUnexpectedToken(this.nextToken());
7455 consequent = this.finalize(this.createNode(), new Node.EmptyStatement());
7459 consequent = this.parseIfClause();
7460 if (this.matchKeyword('else')) {
7462 alternate = this.parseIfClause();
7465 return this.finalize(node, new Node.IfStatement(test, consequent, alternate));
7467 // https://tc39.github.io/ecma262/#sec-do-while-statement
7468 Parser.prototype.parseDoWhileStatement = function () {
7469 var node = this.createNode();
7470 this.expectKeyword('do');
7471 var previousInIteration = this.context.inIteration;
7472 this.context.inIteration = true;
7473 var body = this.parseStatement();
7474 this.context.inIteration = previousInIteration;
7475 this.expectKeyword('while');
7477 var test = this.parseExpression();
7478 if (!this.match(')') && this.config.tolerant) {
7479 this.tolerateUnexpectedToken(this.nextToken());
7483 if (this.match(';')) {
7487 return this.finalize(node, new Node.DoWhileStatement(body, test));
7489 // https://tc39.github.io/ecma262/#sec-while-statement
7490 Parser.prototype.parseWhileStatement = function () {
7491 var node = this.createNode();
7493 this.expectKeyword('while');
7495 var test = this.parseExpression();
7496 if (!this.match(')') && this.config.tolerant) {
7497 this.tolerateUnexpectedToken(this.nextToken());
7498 body = this.finalize(this.createNode(), new Node.EmptyStatement());
7502 var previousInIteration = this.context.inIteration;
7503 this.context.inIteration = true;
7504 body = this.parseStatement();
7505 this.context.inIteration = previousInIteration;
7507 return this.finalize(node, new Node.WhileStatement(test, body));
7509 // https://tc39.github.io/ecma262/#sec-for-statement
7510 // https://tc39.github.io/ecma262/#sec-for-in-and-for-of-statements
7511 Parser.prototype.parseForStatement = function () {
7517 var node = this.createNode();
7518 this.expectKeyword('for');
7520 if (this.match(';')) {
7524 if (this.matchKeyword('var')) {
7525 init = this.createNode();
7527 var previousAllowIn = this.context.allowIn;
7528 this.context.allowIn = false;
7529 var declarations = this.parseVariableDeclarationList({ inFor: true });
7530 this.context.allowIn = previousAllowIn;
7531 if (declarations.length === 1 && this.matchKeyword('in')) {
7532 var decl = declarations[0];
7533 if (decl.init && (decl.id.type === syntax_1.Syntax.ArrayPattern || decl.id.type === syntax_1.Syntax.ObjectPattern || this.context.strict)) {
7534 this.tolerateError(messages_1.Messages.ForInOfLoopInitializer, 'for-in');
7536 init = this.finalize(init, new Node.VariableDeclaration(declarations, 'var'));
7539 right = this.parseExpression();
7542 else if (declarations.length === 1 && declarations[0].init === null && this.matchContextualKeyword('of')) {
7543 init = this.finalize(init, new Node.VariableDeclaration(declarations, 'var'));
7546 right = this.parseAssignmentExpression();
7551 init = this.finalize(init, new Node.VariableDeclaration(declarations, 'var'));
7555 else if (this.matchKeyword('const') || this.matchKeyword('let')) {
7556 init = this.createNode();
7557 var kind = this.nextToken().value;
7558 if (!this.context.strict && this.lookahead.value === 'in') {
7559 init = this.finalize(init, new Node.Identifier(kind));
7562 right = this.parseExpression();
7566 var previousAllowIn = this.context.allowIn;
7567 this.context.allowIn = false;
7568 var declarations = this.parseBindingList(kind, { inFor: true });
7569 this.context.allowIn = previousAllowIn;
7570 if (declarations.length === 1 && declarations[0].init === null && this.matchKeyword('in')) {
7571 init = this.finalize(init, new Node.VariableDeclaration(declarations, kind));
7574 right = this.parseExpression();
7577 else if (declarations.length === 1 && declarations[0].init === null && this.matchContextualKeyword('of')) {
7578 init = this.finalize(init, new Node.VariableDeclaration(declarations, kind));
7581 right = this.parseAssignmentExpression();
7586 this.consumeSemicolon();
7587 init = this.finalize(init, new Node.VariableDeclaration(declarations, kind));
7592 var initStartToken = this.lookahead;
7593 var previousAllowIn = this.context.allowIn;
7594 this.context.allowIn = false;
7595 init = this.inheritCoverGrammar(this.parseAssignmentExpression);
7596 this.context.allowIn = previousAllowIn;
7597 if (this.matchKeyword('in')) {
7598 if (!this.context.isAssignmentTarget || init.type === syntax_1.Syntax.AssignmentExpression) {
7599 this.tolerateError(messages_1.Messages.InvalidLHSInForIn);
7602 this.reinterpretExpressionAsPattern(init);
7604 right = this.parseExpression();
7607 else if (this.matchContextualKeyword('of')) {
7608 if (!this.context.isAssignmentTarget || init.type === syntax_1.Syntax.AssignmentExpression) {
7609 this.tolerateError(messages_1.Messages.InvalidLHSInForLoop);
7612 this.reinterpretExpressionAsPattern(init);
7614 right = this.parseAssignmentExpression();
7619 if (this.match(',')) {
7620 var initSeq = [init];
7621 while (this.match(',')) {
7623 initSeq.push(this.isolateCoverGrammar(this.parseAssignmentExpression));
7625 init = this.finalize(this.startNode(initStartToken), new Node.SequenceExpression(initSeq));
7631 if (typeof left === 'undefined') {
7632 if (!this.match(';')) {
7633 test = this.parseExpression();
7636 if (!this.match(')')) {
7637 update = this.parseExpression();
7641 if (!this.match(')') && this.config.tolerant) {
7642 this.tolerateUnexpectedToken(this.nextToken());
7643 body = this.finalize(this.createNode(), new Node.EmptyStatement());
7647 var previousInIteration = this.context.inIteration;
7648 this.context.inIteration = true;
7649 body = this.isolateCoverGrammar(this.parseStatement);
7650 this.context.inIteration = previousInIteration;
7652 return (typeof left === 'undefined') ?
7653 this.finalize(node, new Node.ForStatement(init, test, update, body)) :
7654 forIn ? this.finalize(node, new Node.ForInStatement(left, right, body)) :
7655 this.finalize(node, new Node.ForOfStatement(left, right, body));
7657 // https://tc39.github.io/ecma262/#sec-continue-statement
7658 Parser.prototype.parseContinueStatement = function () {
7659 var node = this.createNode();
7660 this.expectKeyword('continue');
7662 if (this.lookahead.type === 3 /* Identifier */ && !this.hasLineTerminator) {
7663 var id = this.parseVariableIdentifier();
7665 var key = '$' + id.name;
7666 if (!Object.prototype.hasOwnProperty.call(this.context.labelSet, key)) {
7667 this.throwError(messages_1.Messages.UnknownLabel, id.name);
7670 this.consumeSemicolon();
7671 if (label === null && !this.context.inIteration) {
7672 this.throwError(messages_1.Messages.IllegalContinue);
7674 return this.finalize(node, new Node.ContinueStatement(label));
7676 // https://tc39.github.io/ecma262/#sec-break-statement
7677 Parser.prototype.parseBreakStatement = function () {
7678 var node = this.createNode();
7679 this.expectKeyword('break');
7681 if (this.lookahead.type === 3 /* Identifier */ && !this.hasLineTerminator) {
7682 var id = this.parseVariableIdentifier();
7683 var key = '$' + id.name;
7684 if (!Object.prototype.hasOwnProperty.call(this.context.labelSet, key)) {
7685 this.throwError(messages_1.Messages.UnknownLabel, id.name);
7689 this.consumeSemicolon();
7690 if (label === null && !this.context.inIteration && !this.context.inSwitch) {
7691 this.throwError(messages_1.Messages.IllegalBreak);
7693 return this.finalize(node, new Node.BreakStatement(label));
7695 // https://tc39.github.io/ecma262/#sec-return-statement
7696 Parser.prototype.parseReturnStatement = function () {
7697 if (!this.context.inFunctionBody) {
7698 this.tolerateError(messages_1.Messages.IllegalReturn);
7700 var node = this.createNode();
7701 this.expectKeyword('return');
7702 var hasArgument = (!this.match(';') && !this.match('}') &&
7703 !this.hasLineTerminator && this.lookahead.type !== 2 /* EOF */) ||
7704 this.lookahead.type === 8 /* StringLiteral */ ||
7705 this.lookahead.type === 10 /* Template */;
7706 var argument = hasArgument ? this.parseExpression() : null;
7707 this.consumeSemicolon();
7708 return this.finalize(node, new Node.ReturnStatement(argument));
7710 // https://tc39.github.io/ecma262/#sec-with-statement
7711 Parser.prototype.parseWithStatement = function () {
7712 if (this.context.strict) {
7713 this.tolerateError(messages_1.Messages.StrictModeWith);
7715 var node = this.createNode();
7717 this.expectKeyword('with');
7719 var object = this.parseExpression();
7720 if (!this.match(')') && this.config.tolerant) {
7721 this.tolerateUnexpectedToken(this.nextToken());
7722 body = this.finalize(this.createNode(), new Node.EmptyStatement());
7726 body = this.parseStatement();
7728 return this.finalize(node, new Node.WithStatement(object, body));
7730 // https://tc39.github.io/ecma262/#sec-switch-statement
7731 Parser.prototype.parseSwitchCase = function () {
7732 var node = this.createNode();
7734 if (this.matchKeyword('default')) {
7739 this.expectKeyword('case');
7740 test = this.parseExpression();
7743 var consequent = [];
7745 if (this.match('}') || this.matchKeyword('default') || this.matchKeyword('case')) {
7748 consequent.push(this.parseStatementListItem());
7750 return this.finalize(node, new Node.SwitchCase(test, consequent));
7752 Parser.prototype.parseSwitchStatement = function () {
7753 var node = this.createNode();
7754 this.expectKeyword('switch');
7756 var discriminant = this.parseExpression();
7758 var previousInSwitch = this.context.inSwitch;
7759 this.context.inSwitch = true;
7761 var defaultFound = false;
7764 if (this.match('}')) {
7767 var clause = this.parseSwitchCase();
7768 if (clause.test === null) {
7770 this.throwError(messages_1.Messages.MultipleDefaultsInSwitch);
7772 defaultFound = true;
7777 this.context.inSwitch = previousInSwitch;
7778 return this.finalize(node, new Node.SwitchStatement(discriminant, cases));
7780 // https://tc39.github.io/ecma262/#sec-labelled-statements
7781 Parser.prototype.parseLabelledStatement = function () {
7782 var node = this.createNode();
7783 var expr = this.parseExpression();
7785 if ((expr.type === syntax_1.Syntax.Identifier) && this.match(':')) {
7788 var key = '$' + id.name;
7789 if (Object.prototype.hasOwnProperty.call(this.context.labelSet, key)) {
7790 this.throwError(messages_1.Messages.Redeclaration, 'Label', id.name);
7792 this.context.labelSet[key] = true;
7794 if (this.matchKeyword('class')) {
7795 this.tolerateUnexpectedToken(this.lookahead);
7796 body = this.parseClassDeclaration();
7798 else if (this.matchKeyword('function')) {
7799 var token = this.lookahead;
7800 var declaration = this.parseFunctionDeclaration();
7801 if (this.context.strict) {
7802 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictFunction);
7804 else if (declaration.generator) {
7805 this.tolerateUnexpectedToken(token, messages_1.Messages.GeneratorInLegacyContext);
7810 body = this.parseStatement();
7812 delete this.context.labelSet[key];
7813 statement = new Node.LabeledStatement(id, body);
7816 this.consumeSemicolon();
7817 statement = new Node.ExpressionStatement(expr);
7819 return this.finalize(node, statement);
7821 // https://tc39.github.io/ecma262/#sec-throw-statement
7822 Parser.prototype.parseThrowStatement = function () {
7823 var node = this.createNode();
7824 this.expectKeyword('throw');
7825 if (this.hasLineTerminator) {
7826 this.throwError(messages_1.Messages.NewlineAfterThrow);
7828 var argument = this.parseExpression();
7829 this.consumeSemicolon();
7830 return this.finalize(node, new Node.ThrowStatement(argument));
7832 // https://tc39.github.io/ecma262/#sec-try-statement
7833 Parser.prototype.parseCatchClause = function () {
7834 var node = this.createNode();
7835 this.expectKeyword('catch');
7837 if (this.match(')')) {
7838 this.throwUnexpectedToken(this.lookahead);
7841 var param = this.parsePattern(params);
7843 for (var i = 0; i < params.length; i++) {
7844 var key = '$' + params[i].value;
7845 if (Object.prototype.hasOwnProperty.call(paramMap, key)) {
7846 this.tolerateError(messages_1.Messages.DuplicateBinding, params[i].value);
7848 paramMap[key] = true;
7850 if (this.context.strict && param.type === syntax_1.Syntax.Identifier) {
7851 if (this.scanner.isRestrictedWord(param.name)) {
7852 this.tolerateError(messages_1.Messages.StrictCatchVariable);
7856 var body = this.parseBlock();
7857 return this.finalize(node, new Node.CatchClause(param, body));
7859 Parser.prototype.parseFinallyClause = function () {
7860 this.expectKeyword('finally');
7861 return this.parseBlock();
7863 Parser.prototype.parseTryStatement = function () {
7864 var node = this.createNode();
7865 this.expectKeyword('try');
7866 var block = this.parseBlock();
7867 var handler = this.matchKeyword('catch') ? this.parseCatchClause() : null;
7868 var finalizer = this.matchKeyword('finally') ? this.parseFinallyClause() : null;
7869 if (!handler && !finalizer) {
7870 this.throwError(messages_1.Messages.NoCatchOrFinally);
7872 return this.finalize(node, new Node.TryStatement(block, handler, finalizer));
7874 // https://tc39.github.io/ecma262/#sec-debugger-statement
7875 Parser.prototype.parseDebuggerStatement = function () {
7876 var node = this.createNode();
7877 this.expectKeyword('debugger');
7878 this.consumeSemicolon();
7879 return this.finalize(node, new Node.DebuggerStatement());
7881 // https://tc39.github.io/ecma262/#sec-ecmascript-language-statements-and-declarations
7882 Parser.prototype.parseStatement = function () {
7884 switch (this.lookahead.type) {
7885 case 1 /* BooleanLiteral */:
7886 case 5 /* NullLiteral */:
7887 case 6 /* NumericLiteral */:
7888 case 8 /* StringLiteral */:
7889 case 10 /* Template */:
7890 case 9 /* RegularExpression */:
7891 statement = this.parseExpressionStatement();
7893 case 7 /* Punctuator */:
7894 var value = this.lookahead.value;
7895 if (value === '{') {
7896 statement = this.parseBlock();
7898 else if (value === '(') {
7899 statement = this.parseExpressionStatement();
7901 else if (value === ';') {
7902 statement = this.parseEmptyStatement();
7905 statement = this.parseExpressionStatement();
7908 case 3 /* Identifier */:
7909 statement = this.matchAsyncFunction() ? this.parseFunctionDeclaration() : this.parseLabelledStatement();
7911 case 4 /* Keyword */:
7912 switch (this.lookahead.value) {
7914 statement = this.parseBreakStatement();
7917 statement = this.parseContinueStatement();
7920 statement = this.parseDebuggerStatement();
7923 statement = this.parseDoWhileStatement();
7926 statement = this.parseForStatement();
7929 statement = this.parseFunctionDeclaration();
7932 statement = this.parseIfStatement();
7935 statement = this.parseReturnStatement();
7938 statement = this.parseSwitchStatement();
7941 statement = this.parseThrowStatement();
7944 statement = this.parseTryStatement();
7947 statement = this.parseVariableStatement();
7950 statement = this.parseWhileStatement();
7953 statement = this.parseWithStatement();
7956 statement = this.parseExpressionStatement();
7961 statement = this.throwUnexpectedToken(this.lookahead);
7965 // https://tc39.github.io/ecma262/#sec-function-definitions
7966 Parser.prototype.parseFunctionSourceElements = function () {
7967 var node = this.createNode();
7969 var body = this.parseDirectivePrologues();
7970 var previousLabelSet = this.context.labelSet;
7971 var previousInIteration = this.context.inIteration;
7972 var previousInSwitch = this.context.inSwitch;
7973 var previousInFunctionBody = this.context.inFunctionBody;
7974 this.context.labelSet = {};
7975 this.context.inIteration = false;
7976 this.context.inSwitch = false;
7977 this.context.inFunctionBody = true;
7978 while (this.lookahead.type !== 2 /* EOF */) {
7979 if (this.match('}')) {
7982 body.push(this.parseStatementListItem());
7985 this.context.labelSet = previousLabelSet;
7986 this.context.inIteration = previousInIteration;
7987 this.context.inSwitch = previousInSwitch;
7988 this.context.inFunctionBody = previousInFunctionBody;
7989 return this.finalize(node, new Node.BlockStatement(body));
7991 Parser.prototype.validateParam = function (options, param, name) {
7992 var key = '$' + name;
7993 if (this.context.strict) {
7994 if (this.scanner.isRestrictedWord(name)) {
7995 options.stricted = param;
7996 options.message = messages_1.Messages.StrictParamName;
7998 if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
7999 options.stricted = param;
8000 options.message = messages_1.Messages.StrictParamDupe;
8003 else if (!options.firstRestricted) {
8004 if (this.scanner.isRestrictedWord(name)) {
8005 options.firstRestricted = param;
8006 options.message = messages_1.Messages.StrictParamName;
8008 else if (this.scanner.isStrictModeReservedWord(name)) {
8009 options.firstRestricted = param;
8010 options.message = messages_1.Messages.StrictReservedWord;
8012 else if (Object.prototype.hasOwnProperty.call(options.paramSet, key)) {
8013 options.stricted = param;
8014 options.message = messages_1.Messages.StrictParamDupe;
8017 /* istanbul ignore next */
8018 if (typeof Object.defineProperty === 'function') {
8019 Object.defineProperty(options.paramSet, key, { value: true, enumerable: true, writable: true, configurable: true });
8022 options.paramSet[key] = true;
8025 Parser.prototype.parseRestElement = function (params) {
8026 var node = this.createNode();
8028 var arg = this.parsePattern(params);
8029 if (this.match('=')) {
8030 this.throwError(messages_1.Messages.DefaultRestParameter);
8032 if (!this.match(')')) {
8033 this.throwError(messages_1.Messages.ParameterAfterRestParameter);
8035 return this.finalize(node, new Node.RestElement(arg));
8037 Parser.prototype.parseFormalParameter = function (options) {
8039 var param = this.match('...') ? this.parseRestElement(params) : this.parsePatternWithDefault(params);
8040 for (var i = 0; i < params.length; i++) {
8041 this.validateParam(options, params[i], params[i].value);
8043 options.simple = options.simple && (param instanceof Node.Identifier);
8044 options.params.push(param);
8046 Parser.prototype.parseFormalParameters = function (firstRestricted) {
8051 firstRestricted: firstRestricted
8054 if (!this.match(')')) {
8055 options.paramSet = {};
8056 while (this.lookahead.type !== 2 /* EOF */) {
8057 this.parseFormalParameter(options);
8058 if (this.match(')')) {
8062 if (this.match(')')) {
8069 simple: options.simple,
8070 params: options.params,
8071 stricted: options.stricted,
8072 firstRestricted: options.firstRestricted,
8073 message: options.message
8076 Parser.prototype.matchAsyncFunction = function () {
8077 var match = this.matchContextualKeyword('async');
8079 var state = this.scanner.saveState();
8080 this.scanner.scanComments();
8081 var next = this.scanner.lex();
8082 this.scanner.restoreState(state);
8083 match = (state.lineNumber === next.lineNumber) && (next.type === 4 /* Keyword */) && (next.value === 'function');
8087 Parser.prototype.parseFunctionDeclaration = function (identifierIsOptional) {
8088 var node = this.createNode();
8089 var isAsync = this.matchContextualKeyword('async');
8093 this.expectKeyword('function');
8094 var isGenerator = isAsync ? false : this.match('*');
8100 var firstRestricted = null;
8101 if (!identifierIsOptional || !this.match('(')) {
8102 var token = this.lookahead;
8103 id = this.parseVariableIdentifier();
8104 if (this.context.strict) {
8105 if (this.scanner.isRestrictedWord(token.value)) {
8106 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictFunctionName);
8110 if (this.scanner.isRestrictedWord(token.value)) {
8111 firstRestricted = token;
8112 message = messages_1.Messages.StrictFunctionName;
8114 else if (this.scanner.isStrictModeReservedWord(token.value)) {
8115 firstRestricted = token;
8116 message = messages_1.Messages.StrictReservedWord;
8120 var previousAllowAwait = this.context.await;
8121 var previousAllowYield = this.context.allowYield;
8122 this.context.await = isAsync;
8123 this.context.allowYield = !isGenerator;
8124 var formalParameters = this.parseFormalParameters(firstRestricted);
8125 var params = formalParameters.params;
8126 var stricted = formalParameters.stricted;
8127 firstRestricted = formalParameters.firstRestricted;
8128 if (formalParameters.message) {
8129 message = formalParameters.message;
8131 var previousStrict = this.context.strict;
8132 var previousAllowStrictDirective = this.context.allowStrictDirective;
8133 this.context.allowStrictDirective = formalParameters.simple;
8134 var body = this.parseFunctionSourceElements();
8135 if (this.context.strict && firstRestricted) {
8136 this.throwUnexpectedToken(firstRestricted, message);
8138 if (this.context.strict && stricted) {
8139 this.tolerateUnexpectedToken(stricted, message);
8141 this.context.strict = previousStrict;
8142 this.context.allowStrictDirective = previousAllowStrictDirective;
8143 this.context.await = previousAllowAwait;
8144 this.context.allowYield = previousAllowYield;
8145 return isAsync ? this.finalize(node, new Node.AsyncFunctionDeclaration(id, params, body)) :
8146 this.finalize(node, new Node.FunctionDeclaration(id, params, body, isGenerator));
8148 Parser.prototype.parseFunctionExpression = function () {
8149 var node = this.createNode();
8150 var isAsync = this.matchContextualKeyword('async');
8154 this.expectKeyword('function');
8155 var isGenerator = isAsync ? false : this.match('*');
8161 var firstRestricted;
8162 var previousAllowAwait = this.context.await;
8163 var previousAllowYield = this.context.allowYield;
8164 this.context.await = isAsync;
8165 this.context.allowYield = !isGenerator;
8166 if (!this.match('(')) {
8167 var token = this.lookahead;
8168 id = (!this.context.strict && !isGenerator && this.matchKeyword('yield')) ? this.parseIdentifierName() : this.parseVariableIdentifier();
8169 if (this.context.strict) {
8170 if (this.scanner.isRestrictedWord(token.value)) {
8171 this.tolerateUnexpectedToken(token, messages_1.Messages.StrictFunctionName);
8175 if (this.scanner.isRestrictedWord(token.value)) {
8176 firstRestricted = token;
8177 message = messages_1.Messages.StrictFunctionName;
8179 else if (this.scanner.isStrictModeReservedWord(token.value)) {
8180 firstRestricted = token;
8181 message = messages_1.Messages.StrictReservedWord;
8185 var formalParameters = this.parseFormalParameters(firstRestricted);
8186 var params = formalParameters.params;
8187 var stricted = formalParameters.stricted;
8188 firstRestricted = formalParameters.firstRestricted;
8189 if (formalParameters.message) {
8190 message = formalParameters.message;
8192 var previousStrict = this.context.strict;
8193 var previousAllowStrictDirective = this.context.allowStrictDirective;
8194 this.context.allowStrictDirective = formalParameters.simple;
8195 var body = this.parseFunctionSourceElements();
8196 if (this.context.strict && firstRestricted) {
8197 this.throwUnexpectedToken(firstRestricted, message);
8199 if (this.context.strict && stricted) {
8200 this.tolerateUnexpectedToken(stricted, message);
8202 this.context.strict = previousStrict;
8203 this.context.allowStrictDirective = previousAllowStrictDirective;
8204 this.context.await = previousAllowAwait;
8205 this.context.allowYield = previousAllowYield;
8206 return isAsync ? this.finalize(node, new Node.AsyncFunctionExpression(id, params, body)) :
8207 this.finalize(node, new Node.FunctionExpression(id, params, body, isGenerator));
8209 // https://tc39.github.io/ecma262/#sec-directive-prologues-and-the-use-strict-directive
8210 Parser.prototype.parseDirective = function () {
8211 var token = this.lookahead;
8212 var node = this.createNode();
8213 var expr = this.parseExpression();
8214 var directive = (expr.type === syntax_1.Syntax.Literal) ? this.getTokenRaw(token).slice(1, -1) : null;
8215 this.consumeSemicolon();
8216 return this.finalize(node, directive ? new Node.Directive(expr, directive) : new Node.ExpressionStatement(expr));
8218 Parser.prototype.parseDirectivePrologues = function () {
8219 var firstRestricted = null;
8222 var token = this.lookahead;
8223 if (token.type !== 8 /* StringLiteral */) {
8226 var statement = this.parseDirective();
8227 body.push(statement);
8228 var directive = statement.directive;
8229 if (typeof directive !== 'string') {
8232 if (directive === 'use strict') {
8233 this.context.strict = true;
8234 if (firstRestricted) {
8235 this.tolerateUnexpectedToken(firstRestricted, messages_1.Messages.StrictOctalLiteral);
8237 if (!this.context.allowStrictDirective) {
8238 this.tolerateUnexpectedToken(token, messages_1.Messages.IllegalLanguageModeDirective);
8242 if (!firstRestricted && token.octal) {
8243 firstRestricted = token;
8249 // https://tc39.github.io/ecma262/#sec-method-definitions
8250 Parser.prototype.qualifiedPropertyName = function (token) {
8251 switch (token.type) {
8252 case 3 /* Identifier */:
8253 case 8 /* StringLiteral */:
8254 case 1 /* BooleanLiteral */:
8255 case 5 /* NullLiteral */:
8256 case 6 /* NumericLiteral */:
8257 case 4 /* Keyword */:
8259 case 7 /* Punctuator */:
8260 return token.value === '[';
8266 Parser.prototype.parseGetterMethod = function () {
8267 var node = this.createNode();
8268 var isGenerator = false;
8269 var previousAllowYield = this.context.allowYield;
8270 this.context.allowYield = !isGenerator;
8271 var formalParameters = this.parseFormalParameters();
8272 if (formalParameters.params.length > 0) {
8273 this.tolerateError(messages_1.Messages.BadGetterArity);
8275 var method = this.parsePropertyMethod(formalParameters);
8276 this.context.allowYield = previousAllowYield;
8277 return this.finalize(node, new Node.FunctionExpression(null, formalParameters.params, method, isGenerator));
8279 Parser.prototype.parseSetterMethod = function () {
8280 var node = this.createNode();
8281 var isGenerator = false;
8282 var previousAllowYield = this.context.allowYield;
8283 this.context.allowYield = !isGenerator;
8284 var formalParameters = this.parseFormalParameters();
8285 if (formalParameters.params.length !== 1) {
8286 this.tolerateError(messages_1.Messages.BadSetterArity);
8288 else if (formalParameters.params[0] instanceof Node.RestElement) {
8289 this.tolerateError(messages_1.Messages.BadSetterRestParameter);
8291 var method = this.parsePropertyMethod(formalParameters);
8292 this.context.allowYield = previousAllowYield;
8293 return this.finalize(node, new Node.FunctionExpression(null, formalParameters.params, method, isGenerator));
8295 Parser.prototype.parseGeneratorMethod = function () {
8296 var node = this.createNode();
8297 var isGenerator = true;
8298 var previousAllowYield = this.context.allowYield;
8299 this.context.allowYield = true;
8300 var params = this.parseFormalParameters();
8301 this.context.allowYield = false;
8302 var method = this.parsePropertyMethod(params);
8303 this.context.allowYield = previousAllowYield;
8304 return this.finalize(node, new Node.FunctionExpression(null, params.params, method, isGenerator));
8306 // https://tc39.github.io/ecma262/#sec-generator-function-definitions
8307 Parser.prototype.isStartOfExpression = function () {
8309 var value = this.lookahead.value;
8310 switch (this.lookahead.type) {
8311 case 7 /* Punctuator */:
8312 start = (value === '[') || (value === '(') || (value === '{') ||
8313 (value === '+') || (value === '-') ||
8314 (value === '!') || (value === '~') ||
8315 (value === '++') || (value === '--') ||
8316 (value === '/') || (value === '/='); // regular expression literal
8318 case 4 /* Keyword */:
8319 start = (value === 'class') || (value === 'delete') ||
8320 (value === 'function') || (value === 'let') || (value === 'new') ||
8321 (value === 'super') || (value === 'this') || (value === 'typeof') ||
8322 (value === 'void') || (value === 'yield');
8329 Parser.prototype.parseYieldExpression = function () {
8330 var node = this.createNode();
8331 this.expectKeyword('yield');
8332 var argument = null;
8333 var delegate = false;
8334 if (!this.hasLineTerminator) {
8335 var previousAllowYield = this.context.allowYield;
8336 this.context.allowYield = false;
8337 delegate = this.match('*');
8340 argument = this.parseAssignmentExpression();
8342 else if (this.isStartOfExpression()) {
8343 argument = this.parseAssignmentExpression();
8345 this.context.allowYield = previousAllowYield;
8347 return this.finalize(node, new Node.YieldExpression(argument, delegate));
8349 // https://tc39.github.io/ecma262/#sec-class-definitions
8350 Parser.prototype.parseClassElement = function (hasConstructor) {
8351 var token = this.lookahead;
8352 var node = this.createNode();
8356 var computed = false;
8358 var isStatic = false;
8359 var isAsync = false;
8360 if (this.match('*')) {
8364 computed = this.match('[');
8365 key = this.parseObjectPropertyKey();
8367 if (id.name === 'static' && (this.qualifiedPropertyName(this.lookahead) || this.match('*'))) {
8368 token = this.lookahead;
8370 computed = this.match('[');
8371 if (this.match('*')) {
8375 key = this.parseObjectPropertyKey();
8378 if ((token.type === 3 /* Identifier */) && !this.hasLineTerminator && (token.value === 'async')) {
8379 var punctuator = this.lookahead.value;
8380 if (punctuator !== ':' && punctuator !== '(' && punctuator !== '*') {
8382 token = this.lookahead;
8383 key = this.parseObjectPropertyKey();
8384 if (token.type === 3 /* Identifier */ && token.value === 'constructor') {
8385 this.tolerateUnexpectedToken(token, messages_1.Messages.ConstructorIsAsync);
8390 var lookaheadPropertyKey = this.qualifiedPropertyName(this.lookahead);
8391 if (token.type === 3 /* Identifier */) {
8392 if (token.value === 'get' && lookaheadPropertyKey) {
8394 computed = this.match('[');
8395 key = this.parseObjectPropertyKey();
8396 this.context.allowYield = false;
8397 value = this.parseGetterMethod();
8399 else if (token.value === 'set' && lookaheadPropertyKey) {
8401 computed = this.match('[');
8402 key = this.parseObjectPropertyKey();
8403 value = this.parseSetterMethod();
8406 else if (token.type === 7 /* Punctuator */ && token.value === '*' && lookaheadPropertyKey) {
8408 computed = this.match('[');
8409 key = this.parseObjectPropertyKey();
8410 value = this.parseGeneratorMethod();
8413 if (!kind && key && this.match('(')) {
8415 value = isAsync ? this.parsePropertyMethodAsyncFunction() : this.parsePropertyMethodFunction();
8419 this.throwUnexpectedToken(this.lookahead);
8421 if (kind === 'init') {
8425 if (isStatic && this.isPropertyKey(key, 'prototype')) {
8426 this.throwUnexpectedToken(token, messages_1.Messages.StaticPrototype);
8428 if (!isStatic && this.isPropertyKey(key, 'constructor')) {
8429 if (kind !== 'method' || !method || (value && value.generator)) {
8430 this.throwUnexpectedToken(token, messages_1.Messages.ConstructorSpecialMethod);
8432 if (hasConstructor.value) {
8433 this.throwUnexpectedToken(token, messages_1.Messages.DuplicateConstructor);
8436 hasConstructor.value = true;
8438 kind = 'constructor';
8441 return this.finalize(node, new Node.MethodDefinition(key, computed, value, kind, isStatic));
8443 Parser.prototype.parseClassElementList = function () {
8445 var hasConstructor = { value: false };
8447 while (!this.match('}')) {
8448 if (this.match(';')) {
8452 body.push(this.parseClassElement(hasConstructor));
8458 Parser.prototype.parseClassBody = function () {
8459 var node = this.createNode();
8460 var elementList = this.parseClassElementList();
8461 return this.finalize(node, new Node.ClassBody(elementList));
8463 Parser.prototype.parseClassDeclaration = function (identifierIsOptional) {
8464 var node = this.createNode();
8465 var previousStrict = this.context.strict;
8466 this.context.strict = true;
8467 this.expectKeyword('class');
8468 var id = (identifierIsOptional && (this.lookahead.type !== 3 /* Identifier */)) ? null : this.parseVariableIdentifier();
8469 var superClass = null;
8470 if (this.matchKeyword('extends')) {
8472 superClass = this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall);
8474 var classBody = this.parseClassBody();
8475 this.context.strict = previousStrict;
8476 return this.finalize(node, new Node.ClassDeclaration(id, superClass, classBody));
8478 Parser.prototype.parseClassExpression = function () {
8479 var node = this.createNode();
8480 var previousStrict = this.context.strict;
8481 this.context.strict = true;
8482 this.expectKeyword('class');
8483 var id = (this.lookahead.type === 3 /* Identifier */) ? this.parseVariableIdentifier() : null;
8484 var superClass = null;
8485 if (this.matchKeyword('extends')) {
8487 superClass = this.isolateCoverGrammar(this.parseLeftHandSideExpressionAllowCall);
8489 var classBody = this.parseClassBody();
8490 this.context.strict = previousStrict;
8491 return this.finalize(node, new Node.ClassExpression(id, superClass, classBody));
8493 // https://tc39.github.io/ecma262/#sec-scripts
8494 // https://tc39.github.io/ecma262/#sec-modules
8495 Parser.prototype.parseModule = function () {
8496 this.context.strict = true;
8497 this.context.isModule = true;
8498 this.scanner.isModule = true;
8499 var node = this.createNode();
8500 var body = this.parseDirectivePrologues();
8501 while (this.lookahead.type !== 2 /* EOF */) {
8502 body.push(this.parseStatementListItem());
8504 return this.finalize(node, new Node.Module(body));
8506 Parser.prototype.parseScript = function () {
8507 var node = this.createNode();
8508 var body = this.parseDirectivePrologues();
8509 while (this.lookahead.type !== 2 /* EOF */) {
8510 body.push(this.parseStatementListItem());
8512 return this.finalize(node, new Node.Script(body));
8514 // https://tc39.github.io/ecma262/#sec-imports
8515 Parser.prototype.parseModuleSpecifier = function () {
8516 var node = this.createNode();
8517 if (this.lookahead.type !== 8 /* StringLiteral */) {
8518 this.throwError(messages_1.Messages.InvalidModuleSpecifier);
8520 var token = this.nextToken();
8521 var raw = this.getTokenRaw(token);
8522 return this.finalize(node, new Node.Literal(token.value, raw));
8524 // import {<foo as bar>} ...;
8525 Parser.prototype.parseImportSpecifier = function () {
8526 var node = this.createNode();
8529 if (this.lookahead.type === 3 /* Identifier */) {
8530 imported = this.parseVariableIdentifier();
8532 if (this.matchContextualKeyword('as')) {
8534 local = this.parseVariableIdentifier();
8538 imported = this.parseIdentifierName();
8540 if (this.matchContextualKeyword('as')) {
8542 local = this.parseVariableIdentifier();
8545 this.throwUnexpectedToken(this.nextToken());
8548 return this.finalize(node, new Node.ImportSpecifier(local, imported));
8550 // {foo, bar as bas}
8551 Parser.prototype.parseNamedImports = function () {
8553 var specifiers = [];
8554 while (!this.match('}')) {
8555 specifiers.push(this.parseImportSpecifier());
8556 if (!this.match('}')) {
8563 // import <foo> ...;
8564 Parser.prototype.parseImportDefaultSpecifier = function () {
8565 var node = this.createNode();
8566 var local = this.parseIdentifierName();
8567 return this.finalize(node, new Node.ImportDefaultSpecifier(local));
8569 // import <* as foo> ...;
8570 Parser.prototype.parseImportNamespaceSpecifier = function () {
8571 var node = this.createNode();
8573 if (!this.matchContextualKeyword('as')) {
8574 this.throwError(messages_1.Messages.NoAsAfterImportNamespace);
8577 var local = this.parseIdentifierName();
8578 return this.finalize(node, new Node.ImportNamespaceSpecifier(local));
8580 Parser.prototype.parseImportDeclaration = function () {
8581 if (this.context.inFunctionBody) {
8582 this.throwError(messages_1.Messages.IllegalImportDeclaration);
8584 var node = this.createNode();
8585 this.expectKeyword('import');
8587 var specifiers = [];
8588 if (this.lookahead.type === 8 /* StringLiteral */) {
8590 src = this.parseModuleSpecifier();
8593 if (this.match('{')) {
8595 specifiers = specifiers.concat(this.parseNamedImports());
8597 else if (this.match('*')) {
8599 specifiers.push(this.parseImportNamespaceSpecifier());
8601 else if (this.isIdentifierName(this.lookahead) && !this.matchKeyword('default')) {
8603 specifiers.push(this.parseImportDefaultSpecifier());
8604 if (this.match(',')) {
8606 if (this.match('*')) {
8607 // import foo, * as foo
8608 specifiers.push(this.parseImportNamespaceSpecifier());
8610 else if (this.match('{')) {
8611 // import foo, {bar}
8612 specifiers = specifiers.concat(this.parseNamedImports());
8615 this.throwUnexpectedToken(this.lookahead);
8620 this.throwUnexpectedToken(this.nextToken());
8622 if (!this.matchContextualKeyword('from')) {
8623 var message = this.lookahead.value ? messages_1.Messages.UnexpectedToken : messages_1.Messages.MissingFromClause;
8624 this.throwError(message, this.lookahead.value);
8627 src = this.parseModuleSpecifier();
8629 this.consumeSemicolon();
8630 return this.finalize(node, new Node.ImportDeclaration(specifiers, src));
8632 // https://tc39.github.io/ecma262/#sec-exports
8633 Parser.prototype.parseExportSpecifier = function () {
8634 var node = this.createNode();
8635 var local = this.parseIdentifierName();
8636 var exported = local;
8637 if (this.matchContextualKeyword('as')) {
8639 exported = this.parseIdentifierName();
8641 return this.finalize(node, new Node.ExportSpecifier(local, exported));
8643 Parser.prototype.parseExportDeclaration = function () {
8644 if (this.context.inFunctionBody) {
8645 this.throwError(messages_1.Messages.IllegalExportDeclaration);
8647 var node = this.createNode();
8648 this.expectKeyword('export');
8649 var exportDeclaration;
8650 if (this.matchKeyword('default')) {
8651 // export default ...
8653 if (this.matchKeyword('function')) {
8654 // export default function foo () {}
8655 // export default function () {}
8656 var declaration = this.parseFunctionDeclaration(true);
8657 exportDeclaration = this.finalize(node, new Node.ExportDefaultDeclaration(declaration));
8659 else if (this.matchKeyword('class')) {
8660 // export default class foo {}
8661 var declaration = this.parseClassDeclaration(true);
8662 exportDeclaration = this.finalize(node, new Node.ExportDefaultDeclaration(declaration));
8664 else if (this.matchContextualKeyword('async')) {
8665 // export default async function f () {}
8666 // export default async function () {}
8667 // export default async x => x
8668 var declaration = this.matchAsyncFunction() ? this.parseFunctionDeclaration(true) : this.parseAssignmentExpression();
8669 exportDeclaration = this.finalize(node, new Node.ExportDefaultDeclaration(declaration));
8672 if (this.matchContextualKeyword('from')) {
8673 this.throwError(messages_1.Messages.UnexpectedToken, this.lookahead.value);
8675 // export default {};
8676 // export default [];
8677 // export default (1 + 2);
8678 var declaration = this.match('{') ? this.parseObjectInitializer() :
8679 this.match('[') ? this.parseArrayInitializer() : this.parseAssignmentExpression();
8680 this.consumeSemicolon();
8681 exportDeclaration = this.finalize(node, new Node.ExportDefaultDeclaration(declaration));
8684 else if (this.match('*')) {
8685 // export * from 'foo';
8687 if (!this.matchContextualKeyword('from')) {
8688 var message = this.lookahead.value ? messages_1.Messages.UnexpectedToken : messages_1.Messages.MissingFromClause;
8689 this.throwError(message, this.lookahead.value);
8692 var src = this.parseModuleSpecifier();
8693 this.consumeSemicolon();
8694 exportDeclaration = this.finalize(node, new Node.ExportAllDeclaration(src));
8696 else if (this.lookahead.type === 4 /* Keyword */) {
8697 // export var f = 1;
8698 var declaration = void 0;
8699 switch (this.lookahead.value) {
8702 declaration = this.parseLexicalDeclaration({ inFor: false });
8707 declaration = this.parseStatementListItem();
8710 this.throwUnexpectedToken(this.lookahead);
8712 exportDeclaration = this.finalize(node, new Node.ExportNamedDeclaration(declaration, [], null));
8714 else if (this.matchAsyncFunction()) {
8715 var declaration = this.parseFunctionDeclaration();
8716 exportDeclaration = this.finalize(node, new Node.ExportNamedDeclaration(declaration, [], null));
8719 var specifiers = [];
8721 var isExportFromIdentifier = false;
8723 while (!this.match('}')) {
8724 isExportFromIdentifier = isExportFromIdentifier || this.matchKeyword('default');
8725 specifiers.push(this.parseExportSpecifier());
8726 if (!this.match('}')) {
8731 if (this.matchContextualKeyword('from')) {
8732 // export {default} from 'foo';
8733 // export {foo} from 'foo';
8735 source = this.parseModuleSpecifier();
8736 this.consumeSemicolon();
8738 else if (isExportFromIdentifier) {
8739 // export {default}; // missing fromClause
8740 var message = this.lookahead.value ? messages_1.Messages.UnexpectedToken : messages_1.Messages.MissingFromClause;
8741 this.throwError(message, this.lookahead.value);
8745 this.consumeSemicolon();
8747 exportDeclaration = this.finalize(node, new Node.ExportNamedDeclaration(null, specifiers, source));
8749 return exportDeclaration;
8753 exports.Parser = Parser;
8758 /***/ function(module, exports) {
8761 // Ensure the condition is true, otherwise throw an error.
8762 // This is only to have a better contract semantic, i.e. another safety net
8763 // to catch a logic error. The condition shall be fulfilled in normal case.
8764 // Do NOT use this to enforce a certain condition on any user input.
8765 Object.defineProperty(exports, "__esModule", { value: true });
8766 function assert(condition, message) {
8767 /* istanbul ignore if */
8769 throw new Error('ASSERT: ' + message);
8772 exports.assert = assert;
8777 /***/ function(module, exports) {
8780 /* tslint:disable:max-classes-per-file */
8781 Object.defineProperty(exports, "__esModule", { value: true });
8782 var ErrorHandler = (function () {
8783 function ErrorHandler() {
8785 this.tolerant = false;
8787 ErrorHandler.prototype.recordError = function (error) {
8788 this.errors.push(error);
8790 ErrorHandler.prototype.tolerate = function (error) {
8791 if (this.tolerant) {
8792 this.recordError(error);
8798 ErrorHandler.prototype.constructError = function (msg, column) {
8799 var error = new Error(msg);
8804 /* istanbul ignore else */
8805 if (Object.create && Object.defineProperty) {
8806 error = Object.create(base);
8807 Object.defineProperty(error, 'column', { value: column });
8810 /* istanbul ignore next */
8813 ErrorHandler.prototype.createError = function (index, line, col, description) {
8814 var msg = 'Line ' + line + ': ' + description;
8815 var error = this.constructError(msg, col);
8816 error.index = index;
8817 error.lineNumber = line;
8818 error.description = description;
8821 ErrorHandler.prototype.throwError = function (index, line, col, description) {
8822 throw this.createError(index, line, col, description);
8824 ErrorHandler.prototype.tolerateError = function (index, line, col, description) {
8825 var error = this.createError(index, line, col, description);
8826 if (this.tolerant) {
8827 this.recordError(error);
8833 return ErrorHandler;
8835 exports.ErrorHandler = ErrorHandler;
8840 /***/ function(module, exports) {
8843 Object.defineProperty(exports, "__esModule", { value: true });
8844 // Error messages should be identical to V8.
8845 exports.Messages = {
8846 BadGetterArity: 'Getter must not have any formal parameters',
8847 BadSetterArity: 'Setter must have exactly one formal parameter',
8848 BadSetterRestParameter: 'Setter function argument must not be a rest parameter',
8849 ConstructorIsAsync: 'Class constructor may not be an async method',
8850 ConstructorSpecialMethod: 'Class constructor may not be an accessor',
8851 DeclarationMissingInitializer: 'Missing initializer in %0 declaration',
8852 DefaultRestParameter: 'Unexpected token =',
8853 DuplicateBinding: 'Duplicate binding %0',
8854 DuplicateConstructor: 'A class may only have one constructor',
8855 DuplicateProtoProperty: 'Duplicate __proto__ fields are not allowed in object literals',
8856 ForInOfLoopInitializer: '%0 loop variable declaration may not have an initializer',
8857 GeneratorInLegacyContext: 'Generator declarations are not allowed in legacy contexts',
8858 IllegalBreak: 'Illegal break statement',
8859 IllegalContinue: 'Illegal continue statement',
8860 IllegalExportDeclaration: 'Unexpected token',
8861 IllegalImportDeclaration: 'Unexpected token',
8862 IllegalLanguageModeDirective: 'Illegal \'use strict\' directive in function with non-simple parameter list',
8863 IllegalReturn: 'Illegal return statement',
8864 InvalidEscapedReservedWord: 'Keyword must not contain escaped characters',
8865 InvalidHexEscapeSequence: 'Invalid hexadecimal escape sequence',
8866 InvalidLHSInAssignment: 'Invalid left-hand side in assignment',
8867 InvalidLHSInForIn: 'Invalid left-hand side in for-in',
8868 InvalidLHSInForLoop: 'Invalid left-hand side in for-loop',
8869 InvalidModuleSpecifier: 'Unexpected token',
8870 InvalidRegExp: 'Invalid regular expression',
8871 LetInLexicalBinding: 'let is disallowed as a lexically bound name',
8872 MissingFromClause: 'Unexpected token',
8873 MultipleDefaultsInSwitch: 'More than one default clause in switch statement',
8874 NewlineAfterThrow: 'Illegal newline after throw',
8875 NoAsAfterImportNamespace: 'Unexpected token',
8876 NoCatchOrFinally: 'Missing catch or finally after try',
8877 ParameterAfterRestParameter: 'Rest parameter must be last formal parameter',
8878 Redeclaration: '%0 \'%1\' has already been declared',
8879 StaticPrototype: 'Classes may not have static property named prototype',
8880 StrictCatchVariable: 'Catch variable may not be eval or arguments in strict mode',
8881 StrictDelete: 'Delete of an unqualified identifier in strict mode.',
8882 StrictFunction: 'In strict mode code, functions can only be declared at top level or inside a block',
8883 StrictFunctionName: 'Function name may not be eval or arguments in strict mode',
8884 StrictLHSAssignment: 'Assignment to eval or arguments is not allowed in strict mode',
8885 StrictLHSPostfix: 'Postfix increment/decrement may not have eval or arguments operand in strict mode',
8886 StrictLHSPrefix: 'Prefix increment/decrement may not have eval or arguments operand in strict mode',
8887 StrictModeWith: 'Strict mode code may not include a with statement',
8888 StrictOctalLiteral: 'Octal literals are not allowed in strict mode.',
8889 StrictParamDupe: 'Strict mode function may not have duplicate parameter names',
8890 StrictParamName: 'Parameter name eval or arguments is not allowed in strict mode',
8891 StrictReservedWord: 'Use of future reserved word in strict mode',
8892 StrictVarName: 'Variable name may not be eval or arguments in strict mode',
8893 TemplateOctalLiteral: 'Octal literals are not allowed in template strings.',
8894 UnexpectedEOS: 'Unexpected end of input',
8895 UnexpectedIdentifier: 'Unexpected identifier',
8896 UnexpectedNumber: 'Unexpected number',
8897 UnexpectedReserved: 'Unexpected reserved word',
8898 UnexpectedString: 'Unexpected string',
8899 UnexpectedTemplate: 'Unexpected quasi %0',
8900 UnexpectedToken: 'Unexpected token %0',
8901 UnexpectedTokenIllegal: 'Unexpected token ILLEGAL',
8902 UnknownLabel: 'Undefined label \'%0\'',
8903 UnterminatedRegExp: 'Invalid regular expression: missing /'
8909 /***/ function(module, exports, __webpack_require__) {
8912 Object.defineProperty(exports, "__esModule", { value: true });
8913 var assert_1 = __webpack_require__(9);
8914 var character_1 = __webpack_require__(4);
8915 var messages_1 = __webpack_require__(11);
8916 function hexValue(ch) {
8917 return '0123456789abcdef'.indexOf(ch.toLowerCase());
8919 function octalValue(ch) {
8920 return '01234567'.indexOf(ch);
8922 var Scanner = (function () {
8923 function Scanner(code, handler) {
8925 this.errorHandler = handler;
8926 this.trackComment = false;
8927 this.isModule = false;
8928 this.length = code.length;
8930 this.lineNumber = (code.length > 0) ? 1 : 0;
8932 this.curlyStack = [];
8934 Scanner.prototype.saveState = function () {
8937 lineNumber: this.lineNumber,
8938 lineStart: this.lineStart
8941 Scanner.prototype.restoreState = function (state) {
8942 this.index = state.index;
8943 this.lineNumber = state.lineNumber;
8944 this.lineStart = state.lineStart;
8946 Scanner.prototype.eof = function () {
8947 return this.index >= this.length;
8949 Scanner.prototype.throwUnexpectedToken = function (message) {
8950 if (message === void 0) { message = messages_1.Messages.UnexpectedTokenIllegal; }
8951 return this.errorHandler.throwError(this.index, this.lineNumber, this.index - this.lineStart + 1, message);
8953 Scanner.prototype.tolerateUnexpectedToken = function (message) {
8954 if (message === void 0) { message = messages_1.Messages.UnexpectedTokenIllegal; }
8955 this.errorHandler.tolerateError(this.index, this.lineNumber, this.index - this.lineStart + 1, message);
8957 // https://tc39.github.io/ecma262/#sec-comments
8958 Scanner.prototype.skipSingleLineComment = function (offset) {
8961 if (this.trackComment) {
8963 start = this.index - offset;
8966 line: this.lineNumber,
8967 column: this.index - this.lineStart - offset
8972 while (!this.eof()) {
8973 var ch = this.source.charCodeAt(this.index);
8975 if (character_1.Character.isLineTerminator(ch)) {
8976 if (this.trackComment) {
8978 line: this.lineNumber,
8979 column: this.index - this.lineStart - 1
8983 slice: [start + offset, this.index - 1],
8984 range: [start, this.index - 1],
8987 comments.push(entry);
8989 if (ch === 13 && this.source.charCodeAt(this.index) === 10) {
8993 this.lineStart = this.index;
8997 if (this.trackComment) {
8999 line: this.lineNumber,
9000 column: this.index - this.lineStart
9004 slice: [start + offset, this.index],
9005 range: [start, this.index],
9008 comments.push(entry);
9012 Scanner.prototype.skipMultiLineComment = function () {
9015 if (this.trackComment) {
9017 start = this.index - 2;
9020 line: this.lineNumber,
9021 column: this.index - this.lineStart - 2
9026 while (!this.eof()) {
9027 var ch = this.source.charCodeAt(this.index);
9028 if (character_1.Character.isLineTerminator(ch)) {
9029 if (ch === 0x0D && this.source.charCodeAt(this.index + 1) === 0x0A) {
9034 this.lineStart = this.index;
9036 else if (ch === 0x2A) {
9037 // Block comment ends with '*/'.
9038 if (this.source.charCodeAt(this.index + 1) === 0x2F) {
9040 if (this.trackComment) {
9042 line: this.lineNumber,
9043 column: this.index - this.lineStart
9047 slice: [start + 2, this.index - 2],
9048 range: [start, this.index],
9051 comments.push(entry);
9061 // Ran off the end of the file - the whole thing is a comment
9062 if (this.trackComment) {
9064 line: this.lineNumber,
9065 column: this.index - this.lineStart
9069 slice: [start + 2, this.index],
9070 range: [start, this.index],
9073 comments.push(entry);
9075 this.tolerateUnexpectedToken();
9078 Scanner.prototype.scanComments = function () {
9080 if (this.trackComment) {
9083 var start = (this.index === 0);
9084 while (!this.eof()) {
9085 var ch = this.source.charCodeAt(this.index);
9086 if (character_1.Character.isWhiteSpace(ch)) {
9089 else if (character_1.Character.isLineTerminator(ch)) {
9091 if (ch === 0x0D && this.source.charCodeAt(this.index) === 0x0A) {
9095 this.lineStart = this.index;
9098 else if (ch === 0x2F) {
9099 ch = this.source.charCodeAt(this.index + 1);
9102 var comment = this.skipSingleLineComment(2);
9103 if (this.trackComment) {
9104 comments = comments.concat(comment);
9108 else if (ch === 0x2A) {
9110 var comment = this.skipMultiLineComment();
9111 if (this.trackComment) {
9112 comments = comments.concat(comment);
9119 else if (start && ch === 0x2D) {
9121 if ((this.source.charCodeAt(this.index + 1) === 0x2D) && (this.source.charCodeAt(this.index + 2) === 0x3E)) {
9122 // '-->' is a single-line comment
9124 var comment = this.skipSingleLineComment(3);
9125 if (this.trackComment) {
9126 comments = comments.concat(comment);
9133 else if (ch === 0x3C && !this.isModule) {
9134 if (this.source.slice(this.index + 1, this.index + 4) === '!--') {
9135 this.index += 4; // `<!--`
9136 var comment = this.skipSingleLineComment(4);
9137 if (this.trackComment) {
9138 comments = comments.concat(comment);
9151 // https://tc39.github.io/ecma262/#sec-future-reserved-words
9152 Scanner.prototype.isFutureReservedWord = function (id) {
9163 Scanner.prototype.isStrictModeReservedWord = function (id) {
9179 Scanner.prototype.isRestrictedWord = function (id) {
9180 return id === 'eval' || id === 'arguments';
9182 // https://tc39.github.io/ecma262/#sec-keywords
9183 Scanner.prototype.isKeyword = function (id) {
9184 switch (id.length) {
9186 return (id === 'if') || (id === 'in') || (id === 'do');
9188 return (id === 'var') || (id === 'for') || (id === 'new') ||
9189 (id === 'try') || (id === 'let');
9191 return (id === 'this') || (id === 'else') || (id === 'case') ||
9192 (id === 'void') || (id === 'with') || (id === 'enum');
9194 return (id === 'while') || (id === 'break') || (id === 'catch') ||
9195 (id === 'throw') || (id === 'const') || (id === 'yield') ||
9196 (id === 'class') || (id === 'super');
9198 return (id === 'return') || (id === 'typeof') || (id === 'delete') ||
9199 (id === 'switch') || (id === 'export') || (id === 'import');
9201 return (id === 'default') || (id === 'finally') || (id === 'extends');
9203 return (id === 'function') || (id === 'continue') || (id === 'debugger');
9205 return (id === 'instanceof');
9210 Scanner.prototype.codePointAt = function (i) {
9211 var cp = this.source.charCodeAt(i);
9212 if (cp >= 0xD800 && cp <= 0xDBFF) {
9213 var second = this.source.charCodeAt(i + 1);
9214 if (second >= 0xDC00 && second <= 0xDFFF) {
9216 cp = (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
9221 Scanner.prototype.scanHexEscape = function (prefix) {
9222 var len = (prefix === 'u') ? 4 : 2;
9224 for (var i = 0; i < len; ++i) {
9225 if (!this.eof() && character_1.Character.isHexDigit(this.source.charCodeAt(this.index))) {
9226 code = code * 16 + hexValue(this.source[this.index++]);
9232 return String.fromCharCode(code);
9234 Scanner.prototype.scanUnicodeCodePointEscape = function () {
9235 var ch = this.source[this.index];
9237 // At least, one hex digit is required.
9239 this.throwUnexpectedToken();
9241 while (!this.eof()) {
9242 ch = this.source[this.index++];
9243 if (!character_1.Character.isHexDigit(ch.charCodeAt(0))) {
9246 code = code * 16 + hexValue(ch);
9248 if (code > 0x10FFFF || ch !== '}') {
9249 this.throwUnexpectedToken();
9251 return character_1.Character.fromCodePoint(code);
9253 Scanner.prototype.getIdentifier = function () {
9254 var start = this.index++;
9255 while (!this.eof()) {
9256 var ch = this.source.charCodeAt(this.index);
9258 // Blackslash (U+005C) marks Unicode escape sequence.
9260 return this.getComplexIdentifier();
9262 else if (ch >= 0xD800 && ch < 0xDFFF) {
9263 // Need to handle surrogate pairs.
9265 return this.getComplexIdentifier();
9267 if (character_1.Character.isIdentifierPart(ch)) {
9274 return this.source.slice(start, this.index);
9276 Scanner.prototype.getComplexIdentifier = function () {
9277 var cp = this.codePointAt(this.index);
9278 var id = character_1.Character.fromCodePoint(cp);
9279 this.index += id.length;
9280 // '\u' (U+005C, U+0075) denotes an escaped character.
9283 if (this.source.charCodeAt(this.index) !== 0x75) {
9284 this.throwUnexpectedToken();
9287 if (this.source[this.index] === '{') {
9289 ch = this.scanUnicodeCodePointEscape();
9292 ch = this.scanHexEscape('u');
9293 if (ch === null || ch === '\\' || !character_1.Character.isIdentifierStart(ch.charCodeAt(0))) {
9294 this.throwUnexpectedToken();
9299 while (!this.eof()) {
9300 cp = this.codePointAt(this.index);
9301 if (!character_1.Character.isIdentifierPart(cp)) {
9304 ch = character_1.Character.fromCodePoint(cp);
9306 this.index += ch.length;
9307 // '\u' (U+005C, U+0075) denotes an escaped character.
9309 id = id.substr(0, id.length - 1);
9310 if (this.source.charCodeAt(this.index) !== 0x75) {
9311 this.throwUnexpectedToken();
9314 if (this.source[this.index] === '{') {
9316 ch = this.scanUnicodeCodePointEscape();
9319 ch = this.scanHexEscape('u');
9320 if (ch === null || ch === '\\' || !character_1.Character.isIdentifierPart(ch.charCodeAt(0))) {
9321 this.throwUnexpectedToken();
9329 Scanner.prototype.octalToDecimal = function (ch) {
9330 // \0 is not octal escape sequence
9331 var octal = (ch !== '0');
9332 var code = octalValue(ch);
9333 if (!this.eof() && character_1.Character.isOctalDigit(this.source.charCodeAt(this.index))) {
9335 code = code * 8 + octalValue(this.source[this.index++]);
9336 // 3 digits are only allowed when string starts
9338 if ('0123'.indexOf(ch) >= 0 && !this.eof() && character_1.Character.isOctalDigit(this.source.charCodeAt(this.index))) {
9339 code = code * 8 + octalValue(this.source[this.index++]);
9347 // https://tc39.github.io/ecma262/#sec-names-and-keywords
9348 Scanner.prototype.scanIdentifier = function () {
9350 var start = this.index;
9351 // Backslash (U+005C) starts an escaped character.
9352 var id = (this.source.charCodeAt(start) === 0x5C) ? this.getComplexIdentifier() : this.getIdentifier();
9353 // There is no keyword or literal with only one character.
9354 // Thus, it must be an identifier.
9355 if (id.length === 1) {
9356 type = 3 /* Identifier */;
9358 else if (this.isKeyword(id)) {
9359 type = 4 /* Keyword */;
9361 else if (id === 'null') {
9362 type = 5 /* NullLiteral */;
9364 else if (id === 'true' || id === 'false') {
9365 type = 1 /* BooleanLiteral */;
9368 type = 3 /* Identifier */;
9370 if (type !== 3 /* Identifier */ && (start + id.length !== this.index)) {
9371 var restore = this.index;
9373 this.tolerateUnexpectedToken(messages_1.Messages.InvalidEscapedReservedWord);
9374 this.index = restore;
9379 lineNumber: this.lineNumber,
9380 lineStart: this.lineStart,
9385 // https://tc39.github.io/ecma262/#sec-punctuators
9386 Scanner.prototype.scanPunctuator = function () {
9387 var start = this.index;
9388 // Check for most common single-character punctuators.
9389 var str = this.source[this.index];
9394 this.curlyStack.push('{');
9400 if (this.source[this.index] === '.' && this.source[this.index + 1] === '.') {
9401 // Spread operator: ...
9408 this.curlyStack.pop();
9421 // 4-character punctuator.
9422 str = this.source.substr(this.index, 4);
9423 if (str === '>>>=') {
9427 // 3-character punctuators.
9428 str = str.substr(0, 3);
9429 if (str === '===' || str === '!==' || str === '>>>' ||
9430 str === '<<=' || str === '>>=' || str === '**=') {
9434 // 2-character punctuators.
9435 str = str.substr(0, 2);
9436 if (str === '&&' || str === '||' || str === '==' || str === '!=' ||
9437 str === '+=' || str === '-=' || str === '*=' || str === '/=' ||
9438 str === '++' || str === '--' || str === '<<' || str === '>>' ||
9439 str === '&=' || str === '|=' || str === '^=' || str === '%=' ||
9440 str === '<=' || str === '>=' || str === '=>' || str === '**') {
9444 // 1-character punctuators.
9445 str = this.source[this.index];
9446 if ('<>=!+-*%&|^/'.indexOf(str) >= 0) {
9453 if (this.index === start) {
9454 this.throwUnexpectedToken();
9457 type: 7 /* Punctuator */,
9459 lineNumber: this.lineNumber,
9460 lineStart: this.lineStart,
9465 // https://tc39.github.io/ecma262/#sec-literals-numeric-literals
9466 Scanner.prototype.scanHexLiteral = function (start) {
9468 while (!this.eof()) {
9469 if (!character_1.Character.isHexDigit(this.source.charCodeAt(this.index))) {
9472 num += this.source[this.index++];
9474 if (num.length === 0) {
9475 this.throwUnexpectedToken();
9477 if (character_1.Character.isIdentifierStart(this.source.charCodeAt(this.index))) {
9478 this.throwUnexpectedToken();
9481 type: 6 /* NumericLiteral */,
9482 value: parseInt('0x' + num, 16),
9483 lineNumber: this.lineNumber,
9484 lineStart: this.lineStart,
9489 Scanner.prototype.scanBinaryLiteral = function (start) {
9492 while (!this.eof()) {
9493 ch = this.source[this.index];
9494 if (ch !== '0' && ch !== '1') {
9497 num += this.source[this.index++];
9499 if (num.length === 0) {
9501 this.throwUnexpectedToken();
9504 ch = this.source.charCodeAt(this.index);
9505 /* istanbul ignore else */
9506 if (character_1.Character.isIdentifierStart(ch) || character_1.Character.isDecimalDigit(ch)) {
9507 this.throwUnexpectedToken();
9511 type: 6 /* NumericLiteral */,
9512 value: parseInt(num, 2),
9513 lineNumber: this.lineNumber,
9514 lineStart: this.lineStart,
9519 Scanner.prototype.scanOctalLiteral = function (prefix, start) {
9522 if (character_1.Character.isOctalDigit(prefix.charCodeAt(0))) {
9524 num = '0' + this.source[this.index++];
9529 while (!this.eof()) {
9530 if (!character_1.Character.isOctalDigit(this.source.charCodeAt(this.index))) {
9533 num += this.source[this.index++];
9535 if (!octal && num.length === 0) {
9537 this.throwUnexpectedToken();
9539 if (character_1.Character.isIdentifierStart(this.source.charCodeAt(this.index)) || character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
9540 this.throwUnexpectedToken();
9543 type: 6 /* NumericLiteral */,
9544 value: parseInt(num, 8),
9546 lineNumber: this.lineNumber,
9547 lineStart: this.lineStart,
9552 Scanner.prototype.isImplicitOctalLiteral = function () {
9553 // Implicit octal, unless there is a non-octal digit.
9554 // (Annex B.1.1 on Numeric Literals)
9555 for (var i = this.index + 1; i < this.length; ++i) {
9556 var ch = this.source[i];
9557 if (ch === '8' || ch === '9') {
9560 if (!character_1.Character.isOctalDigit(ch.charCodeAt(0))) {
9566 Scanner.prototype.scanNumericLiteral = function () {
9567 var start = this.index;
9568 var ch = this.source[start];
9569 assert_1.assert(character_1.Character.isDecimalDigit(ch.charCodeAt(0)) || (ch === '.'), 'Numeric literal must start with a decimal digit or a decimal point');
9572 num = this.source[this.index++];
9573 ch = this.source[this.index];
9574 // Hex number starts with '0x'.
9575 // Octal number starts with '0'.
9576 // Octal number in ES6 starts with '0o'.
9577 // Binary number in ES6 starts with '0b'.
9579 if (ch === 'x' || ch === 'X') {
9581 return this.scanHexLiteral(start);
9583 if (ch === 'b' || ch === 'B') {
9585 return this.scanBinaryLiteral(start);
9587 if (ch === 'o' || ch === 'O') {
9588 return this.scanOctalLiteral(ch, start);
9590 if (ch && character_1.Character.isOctalDigit(ch.charCodeAt(0))) {
9591 if (this.isImplicitOctalLiteral()) {
9592 return this.scanOctalLiteral(ch, start);
9596 while (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
9597 num += this.source[this.index++];
9599 ch = this.source[this.index];
9602 num += this.source[this.index++];
9603 while (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
9604 num += this.source[this.index++];
9606 ch = this.source[this.index];
9608 if (ch === 'e' || ch === 'E') {
9609 num += this.source[this.index++];
9610 ch = this.source[this.index];
9611 if (ch === '+' || ch === '-') {
9612 num += this.source[this.index++];
9614 if (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
9615 while (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
9616 num += this.source[this.index++];
9620 this.throwUnexpectedToken();
9623 if (character_1.Character.isIdentifierStart(this.source.charCodeAt(this.index))) {
9624 this.throwUnexpectedToken();
9627 type: 6 /* NumericLiteral */,
9628 value: parseFloat(num),
9629 lineNumber: this.lineNumber,
9630 lineStart: this.lineStart,
9635 // https://tc39.github.io/ecma262/#sec-literals-string-literals
9636 Scanner.prototype.scanStringLiteral = function () {
9637 var start = this.index;
9638 var quote = this.source[start];
9639 assert_1.assert((quote === '\'' || quote === '"'), 'String literal must starts with a quote');
9643 while (!this.eof()) {
9644 var ch = this.source[this.index++];
9649 else if (ch === '\\') {
9650 ch = this.source[this.index++];
9651 if (!ch || !character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
9654 if (this.source[this.index] === '{') {
9656 str += this.scanUnicodeCodePointEscape();
9659 var unescaped_1 = this.scanHexEscape(ch);
9660 if (unescaped_1 === null) {
9661 this.throwUnexpectedToken();
9667 var unescaped = this.scanHexEscape(ch);
9668 if (unescaped === null) {
9669 this.throwUnexpectedToken(messages_1.Messages.InvalidHexEscapeSequence);
9694 this.tolerateUnexpectedToken();
9697 if (ch && character_1.Character.isOctalDigit(ch.charCodeAt(0))) {
9698 var octToDec = this.octalToDecimal(ch);
9699 octal = octToDec.octal || octal;
9700 str += String.fromCharCode(octToDec.code);
9710 if (ch === '\r' && this.source[this.index] === '\n') {
9713 this.lineStart = this.index;
9716 else if (character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
9725 this.throwUnexpectedToken();
9728 type: 8 /* StringLiteral */,
9731 lineNumber: this.lineNumber,
9732 lineStart: this.lineStart,
9737 // https://tc39.github.io/ecma262/#sec-template-literal-lexical-components
9738 Scanner.prototype.scanTemplate = function () {
9740 var terminated = false;
9741 var start = this.index;
9742 var head = (this.source[start] === '`');
9746 while (!this.eof()) {
9747 var ch = this.source[this.index++];
9754 else if (ch === '$') {
9755 if (this.source[this.index] === '{') {
9756 this.curlyStack.push('${');
9763 else if (ch === '\\') {
9764 ch = this.source[this.index++];
9765 if (!character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
9777 if (this.source[this.index] === '{') {
9779 cooked += this.scanUnicodeCodePointEscape();
9782 var restore = this.index;
9783 var unescaped_2 = this.scanHexEscape(ch);
9784 if (unescaped_2 !== null) {
9785 cooked += unescaped_2;
9788 this.index = restore;
9794 var unescaped = this.scanHexEscape(ch);
9795 if (unescaped === null) {
9796 this.throwUnexpectedToken(messages_1.Messages.InvalidHexEscapeSequence);
9798 cooked += unescaped;
9811 if (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index))) {
9812 // Illegal: \01 \02 and so on
9813 this.throwUnexpectedToken(messages_1.Messages.TemplateOctalLiteral);
9817 else if (character_1.Character.isOctalDigit(ch.charCodeAt(0))) {
9819 this.throwUnexpectedToken(messages_1.Messages.TemplateOctalLiteral);
9829 if (ch === '\r' && this.source[this.index] === '\n') {
9832 this.lineStart = this.index;
9835 else if (character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
9837 if (ch === '\r' && this.source[this.index] === '\n') {
9840 this.lineStart = this.index;
9848 this.throwUnexpectedToken();
9851 this.curlyStack.pop();
9854 type: 10 /* Template */,
9855 value: this.source.slice(start + 1, this.index - rawOffset),
9859 lineNumber: this.lineNumber,
9860 lineStart: this.lineStart,
9865 // https://tc39.github.io/ecma262/#sec-literals-regular-expression-literals
9866 Scanner.prototype.testRegExp = function (pattern, flags) {
9867 // The BMP character to use as a replacement for astral symbols when
9868 // translating an ES6 "u"-flagged pattern to an ES5-compatible
9870 // Note: replacing with '\uFFFF' enables false positives in unlikely
9871 // scenarios. For example, `[\u{1044f}-\u{10440}]` is an invalid
9872 // pattern that would not be detected by this substitution.
9873 var astralSubstitute = '\uFFFF';
9876 if (flags.indexOf('u') >= 0) {
9878 .replace(/\\u\{([0-9a-fA-F]+)\}|\\u([a-fA-F0-9]{4})/g, function ($0, $1, $2) {
9879 var codePoint = parseInt($1 || $2, 16);
9880 if (codePoint > 0x10FFFF) {
9881 self.throwUnexpectedToken(messages_1.Messages.InvalidRegExp);
9883 if (codePoint <= 0xFFFF) {
9884 return String.fromCharCode(codePoint);
9886 return astralSubstitute;
9888 .replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g, astralSubstitute);
9890 // First, detect invalid regular expressions.
9895 this.throwUnexpectedToken(messages_1.Messages.InvalidRegExp);
9897 // Return a regular expression object for this pattern-flag pair, or
9898 // `null` in case the current environment doesn't support the flags it
9901 return new RegExp(pattern, flags);
9904 /* istanbul ignore next */
9908 Scanner.prototype.scanRegExpBody = function () {
9909 var ch = this.source[this.index];
9910 assert_1.assert(ch === '/', 'Regular expression literal must start with a slash');
9911 var str = this.source[this.index++];
9912 var classMarker = false;
9913 var terminated = false;
9914 while (!this.eof()) {
9915 ch = this.source[this.index++];
9918 ch = this.source[this.index++];
9919 // https://tc39.github.io/ecma262/#sec-literals-regular-expression-literals
9920 if (character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
9921 this.throwUnexpectedToken(messages_1.Messages.UnterminatedRegExp);
9925 else if (character_1.Character.isLineTerminator(ch.charCodeAt(0))) {
9926 this.throwUnexpectedToken(messages_1.Messages.UnterminatedRegExp);
9928 else if (classMarker) {
9930 classMarker = false;
9938 else if (ch === '[') {
9944 this.throwUnexpectedToken(messages_1.Messages.UnterminatedRegExp);
9946 // Exclude leading and trailing slash.
9947 return str.substr(1, str.length - 2);
9949 Scanner.prototype.scanRegExpFlags = function () {
9952 while (!this.eof()) {
9953 var ch = this.source[this.index];
9954 if (!character_1.Character.isIdentifierPart(ch.charCodeAt(0))) {
9958 if (ch === '\\' && !this.eof()) {
9959 ch = this.source[this.index];
9962 var restore = this.index;
9963 var char = this.scanHexEscape('u');
9964 if (char !== null) {
9966 for (str += '\\u'; restore < this.index; ++restore) {
9967 str += this.source[restore];
9971 this.index = restore;
9975 this.tolerateUnexpectedToken();
9979 this.tolerateUnexpectedToken();
9989 Scanner.prototype.scanRegExp = function () {
9990 var start = this.index;
9991 var pattern = this.scanRegExpBody();
9992 var flags = this.scanRegExpFlags();
9993 var value = this.testRegExp(pattern, flags);
9995 type: 9 /* RegularExpression */,
10000 lineNumber: this.lineNumber,
10001 lineStart: this.lineStart,
10006 Scanner.prototype.lex = function () {
10011 lineNumber: this.lineNumber,
10012 lineStart: this.lineStart,
10017 var cp = this.source.charCodeAt(this.index);
10018 if (character_1.Character.isIdentifierStart(cp)) {
10019 return this.scanIdentifier();
10021 // Very common: ( and ) and ;
10022 if (cp === 0x28 || cp === 0x29 || cp === 0x3B) {
10023 return this.scanPunctuator();
10025 // String literal starts with single quote (U+0027) or double quote (U+0022).
10026 if (cp === 0x27 || cp === 0x22) {
10027 return this.scanStringLiteral();
10029 // Dot (.) U+002E can also start a floating-point number, hence the need
10030 // to check the next character.
10032 if (character_1.Character.isDecimalDigit(this.source.charCodeAt(this.index + 1))) {
10033 return this.scanNumericLiteral();
10035 return this.scanPunctuator();
10037 if (character_1.Character.isDecimalDigit(cp)) {
10038 return this.scanNumericLiteral();
10040 // Template literals start with ` (U+0060) for template head
10041 // or } (U+007D) for template middle or template tail.
10042 if (cp === 0x60 || (cp === 0x7D && this.curlyStack[this.curlyStack.length - 1] === '${')) {
10043 return this.scanTemplate();
10045 // Possible identifier start in a surrogate pair.
10046 if (cp >= 0xD800 && cp < 0xDFFF) {
10047 if (character_1.Character.isIdentifierStart(this.codePointAt(this.index))) {
10048 return this.scanIdentifier();
10051 return this.scanPunctuator();
10055 exports.Scanner = Scanner;
10060 /***/ function(module, exports) {
10063 Object.defineProperty(exports, "__esModule", { value: true });
10064 exports.TokenName = {};
10065 exports.TokenName[1 /* BooleanLiteral */] = 'Boolean';
10066 exports.TokenName[2 /* EOF */] = '<end>';
10067 exports.TokenName[3 /* Identifier */] = 'Identifier';
10068 exports.TokenName[4 /* Keyword */] = 'Keyword';
10069 exports.TokenName[5 /* NullLiteral */] = 'Null';
10070 exports.TokenName[6 /* NumericLiteral */] = 'Numeric';
10071 exports.TokenName[7 /* Punctuator */] = 'Punctuator';
10072 exports.TokenName[8 /* StringLiteral */] = 'String';
10073 exports.TokenName[9 /* RegularExpression */] = 'RegularExpression';
10074 exports.TokenName[10 /* Template */] = 'Template';
10079 /***/ function(module, exports) {
10082 // Generated by generate-xhtml-entities.js. DO NOT MODIFY!
10083 Object.defineProperty(exports, "__esModule", { value: true });
10084 exports.XHTMLEntities = {
10242 thetasym: '\u03D1',
10342 /***/ function(module, exports, __webpack_require__) {
10345 Object.defineProperty(exports, "__esModule", { value: true });
10346 var error_handler_1 = __webpack_require__(10);
10347 var scanner_1 = __webpack_require__(12);
10348 var token_1 = __webpack_require__(13);
10349 var Reader = (function () {
10350 function Reader() {
10352 this.curly = this.paren = -1;
10354 // A function following one of those tokens is an expression.
10355 Reader.prototype.beforeFunctionExpression = function (t) {
10356 return ['(', '{', '[', 'in', 'typeof', 'instanceof', 'new',
10357 'return', 'case', 'delete', 'throw', 'void',
10358 // assignment operators
10359 '=', '+=', '-=', '*=', '**=', '/=', '%=', '<<=', '>>=', '>>>=',
10360 '&=', '|=', '^=', ',',
10361 // binary/unary operators
10362 '+', '-', '*', '**', '/', '%', '++', '--', '<<', '>>', '>>>', '&',
10363 '|', '^', '!', '~', '&&', '||', '?', ':', '===', '==', '>=',
10364 '<=', '<', '>', '!=', '!=='].indexOf(t) >= 0;
10366 // Determine if forward slash (/) is an operator or part of a regular expression
10367 // https://github.com/mozilla/sweet.js/wiki/design
10368 Reader.prototype.isRegexStart = function () {
10369 var previous = this.values[this.values.length - 1];
10370 var regex = (previous !== null);
10371 switch (previous) {
10377 var keyword = this.values[this.paren - 1];
10378 regex = (keyword === 'if' || keyword === 'while' || keyword === 'for' || keyword === 'with');
10381 // Dividing a function by anything makes little sense,
10382 // but we have to check for that.
10384 if (this.values[this.curly - 3] === 'function') {
10385 // Anonymous function, e.g. function(){} /42
10386 var check = this.values[this.curly - 4];
10387 regex = check ? !this.beforeFunctionExpression(check) : false;
10389 else if (this.values[this.curly - 4] === 'function') {
10390 // Named function, e.g. function f(){} /42/
10391 var check = this.values[this.curly - 5];
10392 regex = check ? !this.beforeFunctionExpression(check) : true;
10400 Reader.prototype.push = function (token) {
10401 if (token.type === 7 /* Punctuator */ || token.type === 4 /* Keyword */) {
10402 if (token.value === '{') {
10403 this.curly = this.values.length;
10405 else if (token.value === '(') {
10406 this.paren = this.values.length;
10408 this.values.push(token.value);
10411 this.values.push(null);
10416 var Tokenizer = (function () {
10417 function Tokenizer(code, config) {
10418 this.errorHandler = new error_handler_1.ErrorHandler();
10419 this.errorHandler.tolerant = config ? (typeof config.tolerant === 'boolean' && config.tolerant) : false;
10420 this.scanner = new scanner_1.Scanner(code, this.errorHandler);
10421 this.scanner.trackComment = config ? (typeof config.comment === 'boolean' && config.comment) : false;
10422 this.trackRange = config ? (typeof config.range === 'boolean' && config.range) : false;
10423 this.trackLoc = config ? (typeof config.loc === 'boolean' && config.loc) : false;
10425 this.reader = new Reader();
10427 Tokenizer.prototype.errors = function () {
10428 return this.errorHandler.errors;
10430 Tokenizer.prototype.getNextToken = function () {
10431 if (this.buffer.length === 0) {
10432 var comments = this.scanner.scanComments();
10433 if (this.scanner.trackComment) {
10434 for (var i = 0; i < comments.length; ++i) {
10435 var e = comments[i];
10436 var value = this.scanner.source.slice(e.slice[0], e.slice[1]);
10438 type: e.multiLine ? 'BlockComment' : 'LineComment',
10441 if (this.trackRange) {
10442 comment.range = e.range;
10444 if (this.trackLoc) {
10445 comment.loc = e.loc;
10447 this.buffer.push(comment);
10450 if (!this.scanner.eof()) {
10452 if (this.trackLoc) {
10455 line: this.scanner.lineNumber,
10456 column: this.scanner.index - this.scanner.lineStart
10461 var startRegex = (this.scanner.source[this.scanner.index] === '/') && this.reader.isRegexStart();
10462 var token = startRegex ? this.scanner.scanRegExp() : this.scanner.lex();
10463 this.reader.push(token);
10465 type: token_1.TokenName[token.type],
10466 value: this.scanner.source.slice(token.start, token.end)
10468 if (this.trackRange) {
10469 entry.range = [token.start, token.end];
10471 if (this.trackLoc) {
10473 line: this.scanner.lineNumber,
10474 column: this.scanner.index - this.scanner.lineStart
10478 if (token.type === 9 /* RegularExpression */) {
10479 var pattern = token.pattern;
10480 var flags = token.flags;
10481 entry.regex = { pattern: pattern, flags: flags };
10483 this.buffer.push(entry);
10486 return this.buffer.shift();
10490 exports.Tokenizer = Tokenizer;
10500 /***/ (function(module, exports, __webpack_require__) {
10505 /*eslint-disable no-use-before-define*/
10507 var common = __webpack_require__(8);
10508 var YAMLException = __webpack_require__(9);
10509 var DEFAULT_FULL_SCHEMA = __webpack_require__(31);
10510 var DEFAULT_SAFE_SCHEMA = __webpack_require__(11);
10512 var _toString = Object.prototype.toString;
10513 var _hasOwnProperty = Object.prototype.hasOwnProperty;
10515 var CHAR_TAB = 0x09; /* Tab */
10516 var CHAR_LINE_FEED = 0x0A; /* LF */
10517 var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */
10518 var CHAR_SPACE = 0x20; /* Space */
10519 var CHAR_EXCLAMATION = 0x21; /* ! */
10520 var CHAR_DOUBLE_QUOTE = 0x22; /* " */
10521 var CHAR_SHARP = 0x23; /* # */
10522 var CHAR_PERCENT = 0x25; /* % */
10523 var CHAR_AMPERSAND = 0x26; /* & */
10524 var CHAR_SINGLE_QUOTE = 0x27; /* ' */
10525 var CHAR_ASTERISK = 0x2A; /* * */
10526 var CHAR_COMMA = 0x2C; /* , */
10527 var CHAR_MINUS = 0x2D; /* - */
10528 var CHAR_COLON = 0x3A; /* : */
10529 var CHAR_EQUALS = 0x3D; /* = */
10530 var CHAR_GREATER_THAN = 0x3E; /* > */
10531 var CHAR_QUESTION = 0x3F; /* ? */
10532 var CHAR_COMMERCIAL_AT = 0x40; /* @ */
10533 var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */
10534 var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */
10535 var CHAR_GRAVE_ACCENT = 0x60; /* ` */
10536 var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */
10537 var CHAR_VERTICAL_LINE = 0x7C; /* | */
10538 var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */
10540 var ESCAPE_SEQUENCES = {};
10542 ESCAPE_SEQUENCES[0x00] = '\\0';
10543 ESCAPE_SEQUENCES[0x07] = '\\a';
10544 ESCAPE_SEQUENCES[0x08] = '\\b';
10545 ESCAPE_SEQUENCES[0x09] = '\\t';
10546 ESCAPE_SEQUENCES[0x0A] = '\\n';
10547 ESCAPE_SEQUENCES[0x0B] = '\\v';
10548 ESCAPE_SEQUENCES[0x0C] = '\\f';
10549 ESCAPE_SEQUENCES[0x0D] = '\\r';
10550 ESCAPE_SEQUENCES[0x1B] = '\\e';
10551 ESCAPE_SEQUENCES[0x22] = '\\"';
10552 ESCAPE_SEQUENCES[0x5C] = '\\\\';
10553 ESCAPE_SEQUENCES[0x85] = '\\N';
10554 ESCAPE_SEQUENCES[0xA0] = '\\_';
10555 ESCAPE_SEQUENCES[0x2028] = '\\L';
10556 ESCAPE_SEQUENCES[0x2029] = '\\P';
10558 var DEPRECATED_BOOLEANS_SYNTAX = [
10559 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON',
10560 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF'
10563 function compileStyleMap(schema, map) {
10564 var result, keys, index, length, tag, style, type;
10566 if (map === null) return {};
10569 keys = Object.keys(map);
10571 for (index = 0, length = keys.length; index < length; index += 1) {
10573 style = String(map[tag]);
10575 if (tag.slice(0, 2) === '!!') {
10576 tag = 'tag:yaml.org,2002:' + tag.slice(2);
10578 type = schema.compiledTypeMap['fallback'][tag];
10580 if (type && _hasOwnProperty.call(type.styleAliases, style)) {
10581 style = type.styleAliases[style];
10584 result[tag] = style;
10590 function encodeHex(character) {
10591 var string, handle, length;
10593 string = character.toString(16).toUpperCase();
10595 if (character <= 0xFF) {
10598 } else if (character <= 0xFFFF) {
10601 } else if (character <= 0xFFFFFFFF) {
10605 throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF');
10608 return '\\' + handle + common.repeat('0', length - string.length) + string;
10611 function State(options) {
10612 this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
10613 this.indent = Math.max(1, (options['indent'] || 2));
10614 this.noArrayIndent = options['noArrayIndent'] || false;
10615 this.skipInvalid = options['skipInvalid'] || false;
10616 this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
10617 this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
10618 this.sortKeys = options['sortKeys'] || false;
10619 this.lineWidth = options['lineWidth'] || 80;
10620 this.noRefs = options['noRefs'] || false;
10621 this.noCompatMode = options['noCompatMode'] || false;
10622 this.condenseFlow = options['condenseFlow'] || false;
10624 this.implicitTypes = this.schema.compiledImplicit;
10625 this.explicitTypes = this.schema.compiledExplicit;
10630 this.duplicates = [];
10631 this.usedDuplicates = null;
10634 // Indents every line in a string. Empty lines (\n only) are not indented.
10635 function indentString(string, spaces) {
10636 var ind = common.repeat(' ', spaces),
10641 length = string.length;
10643 while (position < length) {
10644 next = string.indexOf('\n', position);
10646 line = string.slice(position);
10649 line = string.slice(position, next + 1);
10650 position = next + 1;
10653 if (line.length && line !== '\n') result += ind;
10661 function generateNextLine(state, level) {
10662 return '\n' + common.repeat(' ', state.indent * level);
10665 function testImplicitResolving(state, str) {
10666 var index, length, type;
10668 for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
10669 type = state.implicitTypes[index];
10671 if (type.resolve(str)) {
10679 // [33] s-white ::= s-space | s-tab
10680 function isWhitespace(c) {
10681 return c === CHAR_SPACE || c === CHAR_TAB;
10684 // Returns true if the character can be printed without escaping.
10685 // From YAML 1.2: "any allowed characters known to be non-printable
10686 // should also be escaped. [However,] This isn’t mandatory"
10687 // Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029.
10688 function isPrintable(c) {
10689 return (0x00020 <= c && c <= 0x00007E)
10690 || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029)
10691 || ((0x0E000 <= c && c <= 0x00FFFD) && c !== 0xFEFF /* BOM */)
10692 || (0x10000 <= c && c <= 0x10FFFF);
10695 // [34] ns-char ::= nb-char - s-white
10696 // [27] nb-char ::= c-printable - b-char - c-byte-order-mark
10697 // [26] b-char ::= b-line-feed | b-carriage-return
10698 // [24] b-line-feed ::= #xA /* LF */
10699 // [25] b-carriage-return ::= #xD /* CR */
10700 // [3] c-byte-order-mark ::= #xFEFF
10701 function isNsChar(c) {
10702 return isPrintable(c) && !isWhitespace(c)
10706 && c !== CHAR_CARRIAGE_RETURN
10707 && c !== CHAR_LINE_FEED;
10710 // Simplified test for values allowed after the first character in plain style.
10711 function isPlainSafe(c, prev) {
10712 // Uses a subset of nb-char - c-flow-indicator - ":" - "#"
10713 // where nb-char ::= c-printable - b-char - c-byte-order-mark.
10714 return isPrintable(c) && c !== 0xFEFF
10715 // - c-flow-indicator
10716 && c !== CHAR_COMMA
10717 && c !== CHAR_LEFT_SQUARE_BRACKET
10718 && c !== CHAR_RIGHT_SQUARE_BRACKET
10719 && c !== CHAR_LEFT_CURLY_BRACKET
10720 && c !== CHAR_RIGHT_CURLY_BRACKET
10722 // /* An ns-char preceding */ "#"
10723 && c !== CHAR_COLON
10724 && ((c !== CHAR_SHARP) || (prev && isNsChar(prev)));
10727 // Simplified test for values allowed as the first character in plain style.
10728 function isPlainSafeFirst(c) {
10729 // Uses a subset of ns-char - c-indicator
10730 // where ns-char = nb-char - s-white.
10731 return isPrintable(c) && c !== 0xFEFF
10732 && !isWhitespace(c) // - s-white
10733 // - (c-indicator ::=
10734 // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}”
10735 && c !== CHAR_MINUS
10736 && c !== CHAR_QUESTION
10737 && c !== CHAR_COLON
10738 && c !== CHAR_COMMA
10739 && c !== CHAR_LEFT_SQUARE_BRACKET
10740 && c !== CHAR_RIGHT_SQUARE_BRACKET
10741 && c !== CHAR_LEFT_CURLY_BRACKET
10742 && c !== CHAR_RIGHT_CURLY_BRACKET
10743 // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"”
10744 && c !== CHAR_SHARP
10745 && c !== CHAR_AMPERSAND
10746 && c !== CHAR_ASTERISK
10747 && c !== CHAR_EXCLAMATION
10748 && c !== CHAR_VERTICAL_LINE
10749 && c !== CHAR_EQUALS
10750 && c !== CHAR_GREATER_THAN
10751 && c !== CHAR_SINGLE_QUOTE
10752 && c !== CHAR_DOUBLE_QUOTE
10753 // | “%” | “@” | “`”)
10754 && c !== CHAR_PERCENT
10755 && c !== CHAR_COMMERCIAL_AT
10756 && c !== CHAR_GRAVE_ACCENT;
10759 // Determines whether block indentation indicator is required.
10760 function needIndentIndicator(string) {
10761 var leadingSpaceRe = /^\n* /;
10762 return leadingSpaceRe.test(string);
10765 var STYLE_PLAIN = 1,
10771 // Determines which scalar styles are possible and returns the preferred style.
10772 // lineWidth = -1 => no limit.
10773 // Pre-conditions: str.length > 0.
10774 // Post-conditions:
10775 // STYLE_PLAIN or STYLE_SINGLE => no \n are in the string.
10776 // STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1).
10777 // STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1).
10778 function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType) {
10780 var char, prev_char;
10781 var hasLineBreak = false;
10782 var hasFoldableLine = false; // only checked if shouldTrackWidth
10783 var shouldTrackWidth = lineWidth !== -1;
10784 var previousLineBreak = -1; // count the first line correctly
10785 var plain = isPlainSafeFirst(string.charCodeAt(0))
10786 && !isWhitespace(string.charCodeAt(string.length - 1));
10788 if (singleLineOnly) {
10789 // Case: no block styles.
10790 // Check for disallowed characters to rule out plain and single.
10791 for (i = 0; i < string.length; i++) {
10792 char = string.charCodeAt(i);
10793 if (!isPrintable(char)) {
10794 return STYLE_DOUBLE;
10796 prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
10797 plain = plain && isPlainSafe(char, prev_char);
10800 // Case: block styles permitted.
10801 for (i = 0; i < string.length; i++) {
10802 char = string.charCodeAt(i);
10803 if (char === CHAR_LINE_FEED) {
10804 hasLineBreak = true;
10805 // Check if any line can be folded.
10806 if (shouldTrackWidth) {
10807 hasFoldableLine = hasFoldableLine ||
10808 // Foldable line = too long, and not more-indented.
10809 (i - previousLineBreak - 1 > lineWidth &&
10810 string[previousLineBreak + 1] !== ' ');
10811 previousLineBreak = i;
10813 } else if (!isPrintable(char)) {
10814 return STYLE_DOUBLE;
10816 prev_char = i > 0 ? string.charCodeAt(i - 1) : null;
10817 plain = plain && isPlainSafe(char, prev_char);
10819 // in case the end is missing a \n
10820 hasFoldableLine = hasFoldableLine || (shouldTrackWidth &&
10821 (i - previousLineBreak - 1 > lineWidth &&
10822 string[previousLineBreak + 1] !== ' '));
10824 // Although every style can represent \n without escaping, prefer block styles
10825 // for multiline, since they're more readable and they don't add empty lines.
10826 // Also prefer folding a super-long line.
10827 if (!hasLineBreak && !hasFoldableLine) {
10828 // Strings interpretable as another type have to be quoted;
10829 // e.g. the string 'true' vs. the boolean true.
10830 return plain && !testAmbiguousType(string)
10831 ? STYLE_PLAIN : STYLE_SINGLE;
10833 // Edge case: block indentation indicator can only have one digit.
10834 if (indentPerLevel > 9 && needIndentIndicator(string)) {
10835 return STYLE_DOUBLE;
10837 // At this point we know block styles are valid.
10838 // Prefer literal style unless we want to fold.
10839 return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
10842 // Note: line breaking/folding is implemented for only the folded style.
10843 // NB. We drop the last trailing newline (if any) of a returned block scalar
10844 // since the dumper adds its own newline. This always works:
10845 // • No ending newline => unaffected; already using strip "-" chomping.
10846 // • Ending newline => removed then restored.
10847 // Importantly, this keeps the "+" chomp indicator from gaining an extra line.
10848 function writeScalar(state, string, level, iskey) {
10849 state.dump = (function () {
10850 if (string.length === 0) {
10853 if (!state.noCompatMode &&
10854 DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1) {
10855 return "'" + string + "'";
10858 var indent = state.indent * Math.max(1, level); // no 0-indent scalars
10859 // As indentation gets deeper, let the width decrease monotonically
10860 // to the lower bound min(state.lineWidth, 40).
10861 // Note that this implies
10862 // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound.
10863 // state.lineWidth > 40 + state.indent: width decreases until the lower bound.
10864 // This behaves better than a constant minimum width which disallows narrower options,
10865 // or an indent threshold which causes the width to suddenly increase.
10866 var lineWidth = state.lineWidth === -1
10867 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
10869 // Without knowing if keys are implicit/explicit, assume implicit for safety.
10870 var singleLineOnly = iskey
10871 // No block styles in flow mode.
10872 || (state.flowLevel > -1 && level >= state.flowLevel);
10873 function testAmbiguity(string) {
10874 return testImplicitResolving(state, string);
10877 switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity)) {
10881 return "'" + string.replace(/'/g, "''") + "'";
10882 case STYLE_LITERAL:
10883 return '|' + blockHeader(string, state.indent)
10884 + dropEndingNewline(indentString(string, indent));
10886 return '>' + blockHeader(string, state.indent)
10887 + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
10889 return '"' + escapeString(string, lineWidth) + '"';
10891 throw new YAMLException('impossible error: invalid scalar style');
10896 // Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9.
10897 function blockHeader(string, indentPerLevel) {
10898 var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : '';
10900 // note the special case: the string '\n' counts as a "trailing" empty line.
10901 var clip = string[string.length - 1] === '\n';
10902 var keep = clip && (string[string.length - 2] === '\n' || string === '\n');
10903 var chomp = keep ? '+' : (clip ? '' : '-');
10905 return indentIndicator + chomp + '\n';
10908 // (See the note for writeScalar.)
10909 function dropEndingNewline(string) {
10910 return string[string.length - 1] === '\n' ? string.slice(0, -1) : string;
10913 // Note: a long line without a suitable break point will exceed the width limit.
10914 // Pre-conditions: every char in str isPrintable, str.length > 0, width > 0.
10915 function foldString(string, width) {
10916 // In folded style, $k$ consecutive newlines output as $k+1$ newlines—
10917 // unless they're before or after a more-indented line, or at the very
10918 // beginning or end, in which case $k$ maps to $k$.
10919 // Therefore, parse each chunk as newline(s) followed by a content line.
10920 var lineRe = /(\n+)([^\n]*)/g;
10922 // first line (possibly an empty line)
10923 var result = (function () {
10924 var nextLF = string.indexOf('\n');
10925 nextLF = nextLF !== -1 ? nextLF : string.length;
10926 lineRe.lastIndex = nextLF;
10927 return foldLine(string.slice(0, nextLF), width);
10929 // If we haven't reached the first content line yet, don't add an extra \n.
10930 var prevMoreIndented = string[0] === '\n' || string[0] === ' ';
10933 // rest of the lines
10935 while ((match = lineRe.exec(string))) {
10936 var prefix = match[1], line = match[2];
10937 moreIndented = (line[0] === ' ');
10939 + (!prevMoreIndented && !moreIndented && line !== ''
10941 + foldLine(line, width);
10942 prevMoreIndented = moreIndented;
10948 // Greedy line breaking.
10949 // Picks the longest line under the limit each time,
10950 // otherwise settles for the shortest line over the limit.
10951 // NB. More-indented lines *cannot* be folded, as that would add an extra \n.
10952 function foldLine(line, width) {
10953 if (line === '' || line[0] === ' ') return line;
10955 // Since a more-indented line adds a \n, breaks can't be followed by a space.
10956 var breakRe = / [^ ]/g; // note: the match index will always be <= length-2.
10958 // start is an inclusive index. end, curr, and next are exclusive.
10959 var start = 0, end, curr = 0, next = 0;
10962 // Invariants: 0 <= start <= length-1.
10963 // 0 <= curr <= next <= max(0, length-2). curr - start <= width.
10964 // Inside the loop:
10965 // A match implies length >= 2, so curr and next are <= length-2.
10966 while ((match = breakRe.exec(line))) {
10967 next = match.index;
10968 // maintain invariant: curr - start <= width
10969 if (next - start > width) {
10970 end = (curr > start) ? curr : next; // derive end <= length-2
10971 result += '\n' + line.slice(start, end);
10972 // skip the space that was output as \n
10973 start = end + 1; // derive start <= length-1
10978 // By the invariants, start <= length-1, so there is something left over.
10979 // It is either the whole string or a part starting from non-whitespace.
10981 // Insert a break if the remainder is too long and there is a break available.
10982 if (line.length - start > width && curr > start) {
10983 result += line.slice(start, curr) + '\n' + line.slice(curr + 1);
10985 result += line.slice(start);
10988 return result.slice(1); // drop extra \n joiner
10991 // Escapes a double-quoted string.
10992 function escapeString(string) {
10994 var char, nextChar;
10997 for (var i = 0; i < string.length; i++) {
10998 char = string.charCodeAt(i);
10999 // Check for surrogate pairs (reference Unicode 3.0 section "3.7 Surrogates").
11000 if (char >= 0xD800 && char <= 0xDBFF/* high surrogate */) {
11001 nextChar = string.charCodeAt(i + 1);
11002 if (nextChar >= 0xDC00 && nextChar <= 0xDFFF/* low surrogate */) {
11003 // Combine the surrogate pair and store it escaped.
11004 result += encodeHex((char - 0xD800) * 0x400 + nextChar - 0xDC00 + 0x10000);
11005 // Advance index one extra since we already used that char here.
11009 escapeSeq = ESCAPE_SEQUENCES[char];
11010 result += !escapeSeq && isPrintable(char)
11012 : escapeSeq || encodeHex(char);
11018 function writeFlowSequence(state, level, object) {
11024 for (index = 0, length = object.length; index < length; index += 1) {
11025 // Write only valid elements.
11026 if (writeNode(state, level, object[index], false, false)) {
11027 if (index !== 0) _result += ',' + (!state.condenseFlow ? ' ' : '');
11028 _result += state.dump;
11033 state.dump = '[' + _result + ']';
11036 function writeBlockSequence(state, level, object, compact) {
11042 for (index = 0, length = object.length; index < length; index += 1) {
11043 // Write only valid elements.
11044 if (writeNode(state, level + 1, object[index], true, true)) {
11045 if (!compact || index !== 0) {
11046 _result += generateNextLine(state, level);
11049 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
11055 _result += state.dump;
11060 state.dump = _result || '[]'; // Empty sequence if no valid values.
11063 function writeFlowMapping(state, level, object) {
11066 objectKeyList = Object.keys(object),
11073 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
11076 if (index !== 0) pairBuffer += ', ';
11078 if (state.condenseFlow) pairBuffer += '"';
11080 objectKey = objectKeyList[index];
11081 objectValue = object[objectKey];
11083 if (!writeNode(state, level, objectKey, false, false)) {
11084 continue; // Skip this pair because of invalid key;
11087 if (state.dump.length > 1024) pairBuffer += '? ';
11089 pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' ');
11091 if (!writeNode(state, level, objectValue, false, false)) {
11092 continue; // Skip this pair because of invalid value.
11095 pairBuffer += state.dump;
11097 // Both key and value are valid.
11098 _result += pairBuffer;
11102 state.dump = '{' + _result + '}';
11105 function writeBlockMapping(state, level, object, compact) {
11108 objectKeyList = Object.keys(object),
11116 // Allow sorting keys so that the output file is deterministic
11117 if (state.sortKeys === true) {
11119 objectKeyList.sort();
11120 } else if (typeof state.sortKeys === 'function') {
11121 // Custom sort function
11122 objectKeyList.sort(state.sortKeys);
11123 } else if (state.sortKeys) {
11124 // Something is wrong
11125 throw new YAMLException('sortKeys must be a boolean or a function');
11128 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
11131 if (!compact || index !== 0) {
11132 pairBuffer += generateNextLine(state, level);
11135 objectKey = objectKeyList[index];
11136 objectValue = object[objectKey];
11138 if (!writeNode(state, level + 1, objectKey, true, true, true)) {
11139 continue; // Skip this pair because of invalid key.
11142 explicitPair = (state.tag !== null && state.tag !== '?') ||
11143 (state.dump && state.dump.length > 1024);
11145 if (explicitPair) {
11146 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
11149 pairBuffer += '? ';
11153 pairBuffer += state.dump;
11155 if (explicitPair) {
11156 pairBuffer += generateNextLine(state, level);
11159 if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
11160 continue; // Skip this pair because of invalid value.
11163 if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
11166 pairBuffer += ': ';
11169 pairBuffer += state.dump;
11171 // Both key and value are valid.
11172 _result += pairBuffer;
11176 state.dump = _result || '{}'; // Empty mapping if no valid pairs.
11179 function detectType(state, object, explicit) {
11180 var _result, typeList, index, length, type, style;
11182 typeList = explicit ? state.explicitTypes : state.implicitTypes;
11184 for (index = 0, length = typeList.length; index < length; index += 1) {
11185 type = typeList[index];
11187 if ((type.instanceOf || type.predicate) &&
11188 (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) &&
11189 (!type.predicate || type.predicate(object))) {
11191 state.tag = explicit ? type.tag : '?';
11193 if (type.represent) {
11194 style = state.styleMap[type.tag] || type.defaultStyle;
11196 if (_toString.call(type.represent) === '[object Function]') {
11197 _result = type.represent(object, style);
11198 } else if (_hasOwnProperty.call(type.represent, style)) {
11199 _result = type.represent[style](object, style);
11201 throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style');
11204 state.dump = _result;
11214 // Serializes `object` and writes it to global `result`.
11215 // Returns true on success, or false on invalid object.
11217 function writeNode(state, level, object, block, compact, iskey) {
11219 state.dump = object;
11221 if (!detectType(state, object, false)) {
11222 detectType(state, object, true);
11225 var type = _toString.call(state.dump);
11228 block = (state.flowLevel < 0 || state.flowLevel > level);
11231 var objectOrArray = type === '[object Object]' || type === '[object Array]',
11235 if (objectOrArray) {
11236 duplicateIndex = state.duplicates.indexOf(object);
11237 duplicate = duplicateIndex !== -1;
11240 if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) {
11244 if (duplicate && state.usedDuplicates[duplicateIndex]) {
11245 state.dump = '*ref_' + duplicateIndex;
11247 if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
11248 state.usedDuplicates[duplicateIndex] = true;
11250 if (type === '[object Object]') {
11251 if (block && (Object.keys(state.dump).length !== 0)) {
11252 writeBlockMapping(state, level, state.dump, compact);
11254 state.dump = '&ref_' + duplicateIndex + state.dump;
11257 writeFlowMapping(state, level, state.dump);
11259 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
11262 } else if (type === '[object Array]') {
11263 var arrayLevel = (state.noArrayIndent && (level > 0)) ? level - 1 : level;
11264 if (block && (state.dump.length !== 0)) {
11265 writeBlockSequence(state, arrayLevel, state.dump, compact);
11267 state.dump = '&ref_' + duplicateIndex + state.dump;
11270 writeFlowSequence(state, arrayLevel, state.dump);
11272 state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
11275 } else if (type === '[object String]') {
11276 if (state.tag !== '?') {
11277 writeScalar(state, state.dump, level, iskey);
11280 if (state.skipInvalid) return false;
11281 throw new YAMLException('unacceptable kind of an object to dump ' + type);
11284 if (state.tag !== null && state.tag !== '?') {
11285 state.dump = '!<' + state.tag + '> ' + state.dump;
11292 function getDuplicateReferences(object, state) {
11294 duplicatesIndexes = [],
11298 inspectNode(object, objects, duplicatesIndexes);
11300 for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
11301 state.duplicates.push(objects[duplicatesIndexes[index]]);
11303 state.usedDuplicates = new Array(length);
11306 function inspectNode(object, objects, duplicatesIndexes) {
11311 if (object !== null && typeof object === 'object') {
11312 index = objects.indexOf(object);
11313 if (index !== -1) {
11314 if (duplicatesIndexes.indexOf(index) === -1) {
11315 duplicatesIndexes.push(index);
11318 objects.push(object);
11320 if (Array.isArray(object)) {
11321 for (index = 0, length = object.length; index < length; index += 1) {
11322 inspectNode(object[index], objects, duplicatesIndexes);
11325 objectKeyList = Object.keys(object);
11327 for (index = 0, length = objectKeyList.length; index < length; index += 1) {
11328 inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
11335 function dump(input, options) {
11336 options = options || {};
11338 var state = new State(options);
11340 if (!state.noRefs) getDuplicateReferences(input, state);
11342 if (writeNode(state, 0, input, true, true)) return state.dump + '\n';
11347 function safeDump(input, options) {
11348 return dump(input, common.extend({ schema: DEFAULT_SAFE_SCHEMA }, options));
11351 module.exports.dump = dump;
11352 module.exports.safeDump = safeDump;
11357 /***/ (function(module, exports, __webpack_require__) {
11364 const fs = __webpack_require__(4);
11365 const path = __webpack_require__(38);
11366 const { URL } = __webpack_require__(39);
11367 const markdownIt = __webpack_require__(40);
11368 const rules = __webpack_require__(107);
11369 const helpers = __webpack_require__(110);
11370 const cache = __webpack_require__(115);
11372 const deprecatedRuleNames = [ "MD002", "MD006" ];
11376 * Validate the list of rules for structure and reuse.
11378 * @param {Rule[]} ruleList List of rules.
11379 * @returns {string} Error message if validation fails.
11381 function validateRuleList(ruleList) {
11383 if (ruleList.length === rules.length) {
11384 // No need to validate if only using built-in rules
11388 ruleList.forEach(function forRule(rule, index) {
11389 const customIndex = index - rules.length;
11390 // eslint-disable-next-line jsdoc/require-jsdoc
11391 function newError(property) {
11393 "Property '" + property + "' of custom rule at index " +
11394 customIndex + " is incorrect.");
11396 [ "names", "tags" ].forEach(function forProperty(property) {
11397 const value = rule[property];
11399 (!value || !Array.isArray(value) || (value.length === 0) ||
11400 !value.every(helpers.isString) || value.some(helpers.isEmptyString))) {
11401 result = newError(property);
11405 [ "description", "string" ],
11406 [ "function", "function" ]
11407 ].forEach(function forProperty(propertyInfo) {
11408 const property = propertyInfo[0];
11409 const value = rule[property];
11410 if (!result && (!value || (typeof value !== propertyInfo[1]))) {
11411 result = newError(property);
11414 if (!result && rule.information) {
11415 if (Object.getPrototypeOf(rule.information) !== URL.prototype) {
11416 result = newError("information");
11420 rule.names.forEach(function forName(name) {
11421 const nameUpper = name.toUpperCase();
11422 if (!result && (allIds[nameUpper] !== undefined)) {
11423 result = new Error("Name '" + name + "' of custom rule at index " +
11424 customIndex + " is already used as a name or tag.");
11426 allIds[nameUpper] = true;
11428 rule.tags.forEach(function forTag(tag) {
11429 const tagUpper = tag.toUpperCase();
11430 if (!result && allIds[tagUpper]) {
11431 result = new Error("Tag '" + tag + "' of custom rule at index " +
11432 customIndex + " is already used as a name.");
11434 allIds[tagUpper] = false;
11442 * Creates a LintResults instance with toString for pretty display.
11444 * @param {Rule[]} ruleList List of rules.
11445 * @returns {LintResults} New LintResults instance.
11447 function newResults(ruleList) {
11448 // eslint-disable-next-line jsdoc/require-jsdoc
11449 function Results() {}
11450 Results.prototype.toString = function toString(useAlias) {
11452 let ruleNameToRule = null;
11453 const results = [];
11454 Object.keys(that).forEach(function forFile(file) {
11455 const fileResults = that[file];
11456 if (Array.isArray(fileResults)) {
11457 fileResults.forEach(function forResult(result) {
11458 const ruleMoniker = result.ruleNames ?
11459 result.ruleNames.join("/") :
11460 (result.ruleName + "/" + result.ruleAlias);
11463 result.lineNumber + ": " +
11464 ruleMoniker + " " +
11465 result.ruleDescription +
11466 (result.errorDetail ?
11467 " [" + result.errorDetail + "]" :
11469 (result.errorContext ?
11470 " [Context: \"" + result.errorContext + "\"]" :
11474 if (!ruleNameToRule) {
11475 ruleNameToRule = {};
11476 ruleList.forEach(function forRule(rule) {
11477 const ruleName = rule.names[0].toUpperCase();
11478 ruleNameToRule[ruleName] = rule;
11481 Object.keys(fileResults).forEach(function forRule(ruleName) {
11482 const rule = ruleNameToRule[ruleName.toUpperCase()];
11483 const ruleResults = fileResults[ruleName];
11484 ruleResults.forEach(function forLine(lineNumber) {
11485 const nameIndex = Math.min(useAlias ? 1 : 0, rule.names.length - 1);
11488 lineNumber + ": " +
11489 rule.names[nameIndex] + " " +
11491 results.push(result);
11496 return results.join("\n");
11499 return new Results();
11503 * Remove front matter (if present at beginning of content).
11505 * @param {string} content Markdown content.
11506 * @param {RegExp} frontMatter Regular expression to match front matter.
11507 * @returns {Object} Trimmed content and front matter lines.
11509 function removeFrontMatter(content, frontMatter) {
11510 let frontMatterLines = [];
11512 const frontMatterMatch = content.match(frontMatter);
11513 if (frontMatterMatch && !frontMatterMatch.index) {
11514 const contentMatched = frontMatterMatch[0];
11515 content = content.slice(contentMatched.length);
11516 frontMatterLines = contentMatched.split(helpers.newLineRe);
11517 if (frontMatterLines.length &&
11518 (frontMatterLines[frontMatterLines.length - 1] === "")) {
11519 frontMatterLines.length--;
11524 "content": content,
11525 "frontMatterLines": frontMatterLines
11530 * Annotate tokens with line/lineNumber.
11532 * @param {MarkdownItToken[]} tokens Array of markdown-it tokens.
11533 * @param {string[]} lines Lines of Markdown content.
11536 function annotateTokens(tokens, lines) {
11537 let tbodyMap = null;
11538 tokens.forEach(function forToken(token) {
11539 // Handle missing maps for table body
11540 if (token.type === "tbody_open") {
11541 tbodyMap = token.map.slice();
11542 } else if ((token.type === "tr_close") && tbodyMap) {
11544 } else if (token.type === "tbody_close") {
11547 if (tbodyMap && !token.map) {
11548 token.map = tbodyMap.slice();
11550 // Update token metadata
11552 token.line = lines[token.map[0]];
11553 token.lineNumber = token.map[0] + 1;
11554 // Trim bottom of token to exclude whitespace lines
11555 while (token.map[1] && !((lines[token.map[1] - 1] || "").trim())) {
11558 // Annotate children with lineNumber
11559 let lineNumber = token.lineNumber;
11560 const codeSpanExtraLines = [];
11561 helpers.forEachInlineCodeSpan(
11563 function handleInlineCodeSpan(code) {
11564 codeSpanExtraLines.push(code.split(helpers.newLineRe).length - 1);
11567 (token.children || []).forEach(function forChild(child) {
11568 child.lineNumber = lineNumber;
11569 child.line = lines[lineNumber - 1];
11570 if ((child.type === "softbreak") || (child.type === "hardbreak")) {
11572 } else if (child.type === "code_inline") {
11573 lineNumber += codeSpanExtraLines.shift();
11581 * Map rule names/tags to canonical rule name.
11583 * @param {Rule[]} ruleList List of rules.
11584 * @returns {Object.<string, string[]>} Map of alias to rule name.
11586 function mapAliasToRuleNames(ruleList) {
11587 const aliasToRuleNames = {};
11588 // const tagToRuleNames = {};
11589 ruleList.forEach(function forRule(rule) {
11590 const ruleName = rule.names[0].toUpperCase();
11591 // The following is useful for updating README.md:
11593 // "* **[" + ruleName + "](doc/Rules.md#" + ruleName.toLowerCase() +
11594 // ")** *" + rule.names.slice(1).join("/") + "* - " + rule.description);
11595 rule.names.forEach(function forName(name) {
11596 const nameUpper = name.toUpperCase();
11597 aliasToRuleNames[nameUpper] = [ ruleName ];
11599 rule.tags.forEach(function forTag(tag) {
11600 const tagUpper = tag.toUpperCase();
11601 const ruleNames = aliasToRuleNames[tagUpper] || [];
11602 ruleNames.push(ruleName);
11603 aliasToRuleNames[tagUpper] = ruleNames;
11604 // tagToRuleNames[tag] = ruleName;
11607 // The following is useful for updating README.md:
11608 // Object.keys(tagToRuleNames).sort().forEach(function forTag(tag) {
11609 // console.log("* **" + tag + "** - " +
11610 // aliasToRuleNames[tag.toUpperCase()].join(", "));
11613 return aliasToRuleNames;
11617 * Apply (and normalize) configuration object.
11619 * @param {Rule[]} ruleList List of rules.
11620 * @param {Configuration} config Configuration object.
11621 * @param {Object.<string, string[]>} aliasToRuleNames Map of alias to rule
11623 * @returns {Configuration} Effective configuration.
11625 function getEffectiveConfig(ruleList, config, aliasToRuleNames) {
11626 const defaultKey = Object.keys(config).filter(
11627 (key) => key.toUpperCase() === "DEFAULT"
11629 const ruleDefault = (defaultKey.length === 0) || !!config[defaultKey[0]];
11630 const effectiveConfig = {};
11631 ruleList.forEach((rule) => {
11632 const ruleName = rule.names[0].toUpperCase();
11633 effectiveConfig[ruleName] = ruleDefault;
11635 deprecatedRuleNames.forEach((ruleName) => {
11636 effectiveConfig[ruleName] = false;
11638 Object.keys(config).forEach((key) => {
11639 let value = config[key];
11641 if (!(value instanceof Object)) {
11647 const keyUpper = key.toUpperCase();
11648 (aliasToRuleNames[keyUpper] || []).forEach((ruleName) => {
11649 effectiveConfig[ruleName] = value;
11652 return effectiveConfig;
11656 * Create a mapping of enabled rules per line.
11658 * @param {Rule[]} ruleList List of rules.
11659 * @param {string[]} lines List of content lines.
11660 * @param {string[]} frontMatterLines List of front matter lines.
11661 * @param {boolean} noInlineConfig Whether to allow inline configuration.
11662 * @param {Configuration} config Configuration object.
11663 * @param {Object.<string, string[]>} aliasToRuleNames Map of alias to rule
11665 * @returns {Object} Effective configuration and enabled rules per line number.
11667 function getEnabledRulesPerLineNumber(
11673 aliasToRuleNames) {
11674 // Shared variables
11675 let enabledRules = {};
11676 let capturedRules = {};
11677 const allRuleNames = [];
11678 const enabledRulesPerLineNumber = new Array(1 + frontMatterLines.length);
11679 // Helper functions
11680 // eslint-disable-next-line jsdoc/require-jsdoc
11681 function handleInlineConfig(perLine, forEachMatch, forEachLine) {
11682 const input = perLine ? lines : [ lines.join("\n") ];
11683 input.forEach((line) => {
11684 if (!noInlineConfig) {
11686 while ((match = helpers.inlineCommentRe.exec(line))) {
11687 const action = (match[1] || match[3]).toUpperCase();
11688 const parameter = match[2] || match[4];
11689 forEachMatch(action, parameter);
11697 // eslint-disable-next-line jsdoc/require-jsdoc
11698 function configureFile(action, parameter) {
11699 if (action === "CONFIGURE-FILE") {
11701 const json = JSON.parse(parameter);
11707 // Ignore parse errors for inline configuration
11711 // eslint-disable-next-line jsdoc/require-jsdoc
11712 function applyEnableDisable(action, parameter) {
11713 const enabled = (action.startsWith("ENABLE"));
11714 const items = parameter ?
11715 parameter.trim().toUpperCase().split(/\s+/) :
11717 items.forEach((nameUpper) => {
11718 (aliasToRuleNames[nameUpper] || []).forEach((ruleName) => {
11719 enabledRules[ruleName] = enabled;
11723 // eslint-disable-next-line jsdoc/require-jsdoc
11724 function enableDisableFile(action, parameter) {
11725 if ((action === "ENABLE-FILE") || (action === "DISABLE-FILE")) {
11726 applyEnableDisable(action, parameter);
11729 // eslint-disable-next-line jsdoc/require-jsdoc
11730 function captureRestoreEnableDisable(action, parameter) {
11731 if (action === "CAPTURE") {
11732 capturedRules = { ...enabledRules };
11733 } else if (action === "RESTORE") {
11734 enabledRules = { ...capturedRules };
11735 } else if ((action === "ENABLE") || (action === "DISABLE")) {
11736 enabledRules = { ...enabledRules };
11737 applyEnableDisable(action, parameter);
11740 // eslint-disable-next-line jsdoc/require-jsdoc
11741 function updateLineState() {
11742 enabledRulesPerLineNumber.push(enabledRules);
11744 // Handle inline comments
11745 handleInlineConfig(false, configureFile);
11746 const effectiveConfig = getEffectiveConfig(
11747 ruleList, config, aliasToRuleNames);
11748 ruleList.forEach((rule) => {
11749 const ruleName = rule.names[0].toUpperCase();
11750 allRuleNames.push(ruleName);
11751 enabledRules[ruleName] = !!effectiveConfig[ruleName];
11753 capturedRules = enabledRules;
11754 handleInlineConfig(true, enableDisableFile);
11755 handleInlineConfig(true, captureRestoreEnableDisable, updateLineState);
11759 enabledRulesPerLineNumber
11764 * Compare function for Array.prototype.sort for ascending order of errors.
11766 * @param {LintError} a First error.
11767 * @param {LintError} b Second error.
11768 * @returns {number} Positive value if a>b, negative value if b<a, 0 otherwise.
11770 function lineNumberComparison(a, b) {
11771 return a.lineNumber - b.lineNumber;
11775 * Filter function to include everything.
11777 * @returns {boolean} True.
11779 function filterAllValues() {
11784 * Function to return unique values from a sorted errors array.
11786 * @param {LintError} value Error instance.
11787 * @param {number} index Index in array.
11788 * @param {LintError[]} array Array of errors.
11789 * @returns {boolean} Filter value.
11791 function uniqueFilterForSortedErrors(value, index, array) {
11792 return (index === 0) || (value.lineNumber > array[index - 1].lineNumber);
11796 * Lints a string containing Markdown content.
11798 * @param {Rule[]} ruleList List of rules.
11799 * @param {string} name Identifier for the content.
11800 * @param {string} content Markdown content
11801 * @param {Object} md markdown-it instance.
11802 * @param {Configuration} config Configuration object.
11803 * @param {RegExp} frontMatter Regular expression for front matter.
11804 * @param {boolean} handleRuleFailures Whether to handle exceptions in rules.
11805 * @param {boolean} noInlineConfig Whether to allow inline configuration.
11806 * @param {number} resultVersion Version of the LintResults object to return.
11807 * @param {Function} callback Callback (err, result) function.
11810 function lintContent(
11817 handleRuleFailures,
11821 // Remove UTF-8 byte order marker (if present)
11822 content = content.replace(/^\ufeff/, "");
11823 // Remove front matter
11824 const removeFrontMatterResult = removeFrontMatter(content, frontMatter);
11825 const frontMatterLines = removeFrontMatterResult.frontMatterLines;
11826 // Ignore the content of HTML comments
11827 content = helpers.clearHtmlCommentText(removeFrontMatterResult.content);
11828 // Parse content into tokens and lines
11829 const tokens = md.parse(content, {});
11830 const lines = content.split(helpers.newLineRe);
11831 annotateTokens(tokens, lines);
11832 const aliasToRuleNames = mapAliasToRuleNames(ruleList);
11833 const { effectiveConfig, enabledRulesPerLineNumber } =
11834 getEnabledRulesPerLineNumber(
11842 // Create parameters for rules
11849 cache.lineMetadata(helpers.getLineMetadata(params));
11850 cache.flattenedLists(helpers.flattenLists(params));
11851 // Function to run for each rule
11852 const result = (resultVersion === 0) ? {} : [];
11853 // eslint-disable-next-line jsdoc/require-jsdoc
11854 function forRule(rule) {
11856 const ruleNameFriendly = rule.names[0];
11857 const ruleName = ruleNameFriendly.toUpperCase();
11858 params.config = effectiveConfig[ruleName];
11859 // eslint-disable-next-line jsdoc/require-jsdoc
11860 function throwError(property) {
11862 "Property '" + property + "' of onError parameter is incorrect.");
11865 // eslint-disable-next-line jsdoc/require-jsdoc
11866 function onError(errorInfo) {
11868 !helpers.isNumber(errorInfo.lineNumber) ||
11869 (errorInfo.lineNumber < 1) ||
11870 (errorInfo.lineNumber > lines.length)) {
11871 throwError("lineNumber");
11873 if (errorInfo.detail &&
11874 !helpers.isString(errorInfo.detail)) {
11875 throwError("detail");
11877 if (errorInfo.context &&
11878 !helpers.isString(errorInfo.context)) {
11879 throwError("context");
11881 if (errorInfo.range &&
11882 (!Array.isArray(errorInfo.range) ||
11883 (errorInfo.range.length !== 2) ||
11884 !helpers.isNumber(errorInfo.range[0]) ||
11885 (errorInfo.range[0] < 1) ||
11886 !helpers.isNumber(errorInfo.range[1]) ||
11887 (errorInfo.range[1] < 1) ||
11888 ((errorInfo.range[0] + errorInfo.range[1] - 1) >
11889 lines[errorInfo.lineNumber - 1].length))) {
11890 throwError("range");
11892 const fixInfo = errorInfo.fixInfo;
11893 const cleanFixInfo = {};
11895 if (!helpers.isObject(fixInfo)) {
11896 throwError("fixInfo");
11898 if (fixInfo.lineNumber !== undefined) {
11899 if ((!helpers.isNumber(fixInfo.lineNumber) ||
11900 (fixInfo.lineNumber < 1) ||
11901 (fixInfo.lineNumber > lines.length))) {
11902 throwError("fixInfo.lineNumber");
11904 cleanFixInfo.lineNumber =
11905 fixInfo.lineNumber + frontMatterLines.length;
11907 const effectiveLineNumber = fixInfo.lineNumber || errorInfo.lineNumber;
11908 if (fixInfo.editColumn !== undefined) {
11909 if ((!helpers.isNumber(fixInfo.editColumn) ||
11910 (fixInfo.editColumn < 1) ||
11911 (fixInfo.editColumn >
11912 lines[effectiveLineNumber - 1].length + 1))) {
11913 throwError("fixInfo.editColumn");
11915 cleanFixInfo.editColumn = fixInfo.editColumn;
11917 if (fixInfo.deleteCount !== undefined) {
11918 if ((!helpers.isNumber(fixInfo.deleteCount) ||
11919 (fixInfo.deleteCount < -1) ||
11920 (fixInfo.deleteCount >
11921 lines[effectiveLineNumber - 1].length))) {
11922 throwError("fixInfo.deleteCount");
11924 cleanFixInfo.deleteCount = fixInfo.deleteCount;
11926 if (fixInfo.insertText !== undefined) {
11927 if (!helpers.isString(fixInfo.insertText)) {
11928 throwError("fixInfo.insertText");
11930 cleanFixInfo.insertText = fixInfo.insertText;
11934 "lineNumber": errorInfo.lineNumber + frontMatterLines.length,
11935 "detail": errorInfo.detail || null,
11936 "context": errorInfo.context || null,
11937 "range": errorInfo.range ? [ ...errorInfo.range ] : null,
11938 "fixInfo": fixInfo ? cleanFixInfo : null
11941 // Call (possibly external) rule function
11942 if (handleRuleFailures) {
11944 rule.function(params, onError);
11948 "detail": `This rule threw an exception: ${ex.message}`
11952 rule.function(params, onError);
11954 // Record any errors (significant performance benefit from length check)
11955 if (errors.length) {
11956 errors.sort(lineNumberComparison);
11957 const filteredErrors = errors
11958 .filter((resultVersion === 3) ?
11960 uniqueFilterForSortedErrors)
11961 .filter(function removeDisabledRules(error) {
11962 return enabledRulesPerLineNumber[error.lineNumber][ruleName];
11964 .map(function formatResults(error) {
11965 if (resultVersion === 0) {
11966 return error.lineNumber;
11968 const errorObject = {};
11969 errorObject.lineNumber = error.lineNumber;
11970 if (resultVersion === 1) {
11971 errorObject.ruleName = ruleNameFriendly;
11972 errorObject.ruleAlias = rule.names[1] || rule.names[0];
11974 errorObject.ruleNames = rule.names;
11976 errorObject.ruleDescription = rule.description;
11977 errorObject.ruleInformation =
11978 rule.information ? rule.information.href : null;
11979 errorObject.errorDetail = error.detail;
11980 errorObject.errorContext = error.context;
11981 errorObject.errorRange = error.range;
11982 if (resultVersion === 3) {
11983 errorObject.fixInfo = error.fixInfo;
11985 return errorObject;
11987 if (filteredErrors.length) {
11988 if (resultVersion === 0) {
11989 result[ruleNameFriendly] = filteredErrors;
11991 Array.prototype.push.apply(result, filteredErrors);
11998 ruleList.forEach(forRule);
12001 return callback(ex);
12004 return callback(null, result);
12008 * Lints a file containing Markdown content.
12010 * @param {Rule[]} ruleList List of rules.
12011 * @param {string} file Path of file to lint.
12012 * @param {Object} md markdown-it instance.
12013 * @param {Configuration} config Configuration object.
12014 * @param {RegExp} frontMatter Regular expression for front matter.
12015 * @param {boolean} handleRuleFailures Whether to handle exceptions in rules.
12016 * @param {boolean} noInlineConfig Whether to allow inline configuration.
12017 * @param {number} resultVersion Version of the LintResults object to return.
12018 * @param {boolean} synchronous Whether to execute synchronously.
12019 * @param {Function} callback Callback (err, result) function.
12028 handleRuleFailures,
12033 // eslint-disable-next-line jsdoc/require-jsdoc
12034 function lintContentWrapper(err, content) {
12036 return callback(err);
12038 return lintContent(ruleList, file, content, md, config, frontMatter,
12039 handleRuleFailures, noInlineConfig, resultVersion, callback);
12041 // Make a/synchronous call to read file
12043 lintContentWrapper(null, fs.readFileSync(file, helpers.utf8Encoding));
12045 fs.readFile(file, helpers.utf8Encoding, lintContentWrapper);
12050 * Lint files and strings specified in the Options object.
12052 * @param {Options} options Options object.
12053 * @param {boolean} synchronous Whether to execute synchronously.
12054 * @param {Function} callback Callback (err, result) function.
12057 function lintInput(options, synchronous, callback) {
12058 // Normalize inputs
12059 options = options || {};
12060 callback = callback || function noop() {};
12061 const ruleList = rules.concat(options.customRules || []);
12062 const ruleErr = validateRuleList(ruleList);
12064 return callback(ruleErr);
12067 if (Array.isArray(options.files)) {
12068 files = options.files.slice();
12069 } else if (options.files) {
12070 files = [ String(options.files) ];
12072 const strings = options.strings || {};
12073 const stringsKeys = Object.keys(strings);
12074 const config = options.config || { "default": true };
12075 const frontMatter = (options.frontMatter === undefined) ?
12076 helpers.frontMatterRe : options.frontMatter;
12077 const handleRuleFailures = !!options.handleRuleFailures;
12078 const noInlineConfig = !!options.noInlineConfig;
12079 const resultVersion = (options.resultVersion === undefined) ?
12080 2 : options.resultVersion;
12081 const md = markdownIt({ "html": true });
12082 const markdownItPlugins = options.markdownItPlugins || [];
12083 markdownItPlugins.forEach(function forPlugin(plugin) {
12087 const results = newResults(ruleList);
12088 // Helper to lint the next string or file
12089 /* eslint-disable consistent-return */
12090 // eslint-disable-next-line jsdoc/require-jsdoc
12091 function lintNextItem() {
12092 let iterating = true;
12094 // eslint-disable-next-line jsdoc/require-jsdoc
12095 function lintNextItemCallback(err, result) {
12098 return callback(err);
12100 results[item] = result;
12101 return iterating || lintNextItem();
12103 while (iterating) {
12104 if ((item = stringsKeys.shift())) {
12108 strings[item] || "",
12112 handleRuleFailures,
12115 lintNextItemCallback);
12116 } else if ((item = files.shift())) {
12117 iterating = synchronous;
12124 handleRuleFailures,
12128 lintNextItemCallback);
12130 return callback(null, results);
12134 return lintNextItem();
12138 * Lint specified Markdown files.
12140 * @param {Options} options Configuration options.
12141 * @param {LintCallback} callback Callback (err, result) function.
12144 function markdownlint(options, callback) {
12145 return lintInput(options, false, callback);
12149 * Lint specified Markdown files synchronously.
12151 * @param {Options} options Configuration options.
12152 * @returns {LintResults} Results object.
12154 function markdownlintSync(options) {
12155 let results = null;
12156 lintInput(options, true, function callback(error, res) {
12166 * Parse the content of a configuration file.
12168 * @param {string} name Name of the configuration file.
12169 * @param {string} content Configuration content.
12170 * @param {ConfigurationParser[]} parsers Parsing function(s).
12171 * @returns {Object} Configuration object and error message.
12173 function parseConfiguration(name, content, parsers) {
12178 (parsers || [ JSON.parse ]).every((parser) => {
12180 config = parser(content);
12182 errors.push(ex.message);
12186 // Message if unable to parse
12188 errors.unshift(`Unable to parse '${name}'`);
12189 message = errors.join("; ");
12198 * Read specified configuration file.
12200 * @param {string} file Configuration file name.
12201 * @param {ConfigurationParser[] | ReadConfigCallback} parsers Parsing
12203 * @param {ReadConfigCallback} [callback] Callback (err, result) function.
12206 function readConfig(file, parsers, callback) {
12209 callback = parsers;
12213 fs.readFile(file, helpers.utf8Encoding, (err, content) => {
12215 return callback(err);
12217 // Try to parse file
12219 const { config, message } = parseConfiguration(file, content, parsers);
12221 return callback(new Error(message));
12223 // Extend configuration
12224 const configExtends = config.extends;
12225 if (configExtends) {
12226 delete config.extends;
12227 const extendsFile = path.resolve(path.dirname(file), configExtends);
12228 return readConfig(extendsFile, parsers, (errr, extendsConfig) => {
12230 return callback(errr);
12232 return callback(null, {
12238 return callback(null, config);
12243 * Read specified configuration file synchronously.
12245 * @param {string} file Configuration file name.
12246 * @param {ConfigurationParser[]} [parsers] Parsing function(s).
12247 * @returns {Configuration} Configuration object.
12249 function readConfigSync(file, parsers) {
12251 const content = fs.readFileSync(file, helpers.utf8Encoding);
12252 // Try to parse file
12253 const { config, message } = parseConfiguration(file, content, parsers);
12255 throw new Error(message);
12257 // Extend configuration
12258 const configExtends = config.extends;
12259 if (configExtends) {
12260 delete config.extends;
12263 path.resolve(path.dirname(file), configExtends),
12272 // Export a/synchronous APIs
12273 markdownlint.sync = markdownlintSync;
12274 markdownlint.readConfig = readConfig;
12275 markdownlint.readConfigSync = readConfigSync;
12276 module.exports = markdownlint;
12278 // Type declarations
12281 * Function to implement rule logic.
12283 * @callback RuleFunction
12284 * @param {RuleParams} params Rule parameters.
12285 * @param {RuleOnError} onError Error-reporting callback.
12292 * @typedef {Object} RuleParams
12293 * @property {string} name File/string name.
12294 * @property {MarkdownItToken[]} tokens markdown-it token objects.
12295 * @property {string[]} lines File/string lines.
12296 * @property {string[]} frontMatterLines Front matter lines.
12297 * @property {RuleConfiguration} config Rule configuration.
12301 * Markdown-It token.
12303 * @typedef {Object} MarkdownItToken
12304 * @property {string[][]} attrs HTML attributes.
12305 * @property {boolean} block Block-level token.
12306 * @property {MarkdownItToken[]} children Child nodes.
12307 * @property {string} content Tag contents.
12308 * @property {boolean} hidden Ignore element.
12309 * @property {string} info Fence info.
12310 * @property {number} level Nesting level.
12311 * @property {number[]} map Beginning/ending line numbers.
12312 * @property {string} markup Markup text.
12313 * @property {Object} meta Arbitrary data.
12314 * @property {number} nesting Level change.
12315 * @property {string} tag HTML tag name.
12316 * @property {string} type Token type.
12317 * @property {number} lineNumber Line number (1-based).
12318 * @property {string} line Line content.
12322 * Error-reporting callback.
12324 * @callback RuleOnError
12325 * @param {RuleOnErrorInfo} onErrorInfo Error information.
12330 * Fix information for RuleOnError callback.
12332 * @typedef {Object} RuleOnErrorInfo
12333 * @property {number} lineNumber Line number (1-based).
12334 * @property {string} [details] Details about the error.
12335 * @property {string} [context] Context for the error.
12336 * @property {number[]} [range] Column number (1-based) and length.
12337 * @property {RuleOnErrorFixInfo} [fixInfo] Fix information.
12341 * Fix information for RuleOnErrorInfo.
12343 * @typedef {Object} RuleOnErrorFixInfo
12344 * @property {number} [lineNumber] Line number (1-based).
12345 * @property {number} [editColumn] Column of the fix (1-based).
12346 * @property {number} [deleteCount] Count of characters to delete.
12347 * @property {string} [insertText] Text to insert (after deleting).
12353 * @typedef {Object} Rule
12354 * @property {string[]} names Rule name(s).
12355 * @property {string} description Rule description.
12356 * @property {URL} [information] Link to more information.
12357 * @property {string[]} tags Rule tag(s).
12358 * @property {RuleFunction} function Rule implementation.
12362 * Configuration options.
12364 * @typedef {Object} Options
12365 * @property {string[] | string} [files] Files to lint.
12366 * @property {Object.<string, string>} [strings] Strings to lint.
12367 * @property {Configuration} [config] Configuration object.
12368 * @property {Rule[] | Rule} [customRules] Custom rules.
12369 * @property {RegExp} [frontMatter] Front matter pattern.
12370 * @property {boolean} [handleRuleFailures] True to catch exceptions.
12371 * @property {boolean} [noInlineConfig] True to ignore HTML directives.
12372 * @property {number} [resultVersion] Results object version.
12373 * @property {Plugin[]} [markdownItPlugins] Additional plugins.
12377 * markdown-it plugin.
12379 * @typedef {Array} Plugin
12383 * Function to pretty-print lint results.
12385 * @callback ToStringCallback
12386 * @param {boolean} [ruleAliases] True to use rule aliases.
12387 * @returns {string}
12391 * Lint results (for resultVersion 3).
12393 * @typedef {Object.<string, LintError[]>} LintResults
12395 // The following should be part of the LintResults typedef, but that causes
12396 // TypeScript to "forget" about the string map.
12397 // * @property {ToStringCallback} toString String representation.
12398 // https://github.com/microsoft/TypeScript/issues/34911
12403 * @typedef {Object} LintError
12404 * @property {number} lineNumber Line number (1-based).
12405 * @property {string[]} ruleNames Rule name(s).
12406 * @property {string} ruleDescription Rule description.
12407 * @property {string} ruleInformation Link to more information.
12408 * @property {string} errorDetail Detail about the error.
12409 * @property {string} errorContext Context for the error.
12410 * @property {number[]} errorRange Column number (1-based) and length.
12411 * @property {FixInfo} fixInfo Fix information.
12417 * @typedef {Object} FixInfo
12418 * @property {number} [editColumn] Column of the fix (1-based).
12419 * @property {number} [deleteCount] Count of characters to delete.
12420 * @property {string} [insertText] Text to insert (after deleting).
12424 * Called with the result of the lint operation.
12426 * @callback LintCallback
12427 * @param {Error | null} err Error object or null.
12428 * @param {LintResults} [results] Lint results.
12433 * Configuration object for linting rules. For a detailed schema, see
12434 * {@link ../schema/markdownlint-config-schema.json}.
12436 * @typedef {Object.<string, RuleConfiguration>} Configuration
12440 * Rule configuration object.
12442 * @typedef {boolean | Object} RuleConfiguration Rule configuration.
12446 * Parses a configuration string and returns a configuration object.
12448 * @callback ConfigurationParser
12449 * @param {string} text Configuration string.
12450 * @returns {Configuration}
12454 * Called with the result of the readConfig operation.
12456 * @callback ReadConfigCallback
12457 * @param {Error | null} err Error object or null.
12458 * @param {Configuration} [config] Configuration object.
12465 /***/ (function(module, exports) {
12467 module.exports = require("path");
12471 /***/ (function(module, exports) {
12473 module.exports = require("url");
12477 /***/ (function(module, exports, __webpack_require__) {
12483 module.exports = __webpack_require__(41);
12488 /***/ (function(module, exports, __webpack_require__) {
12491 // Main parser class
12496 var utils = __webpack_require__(42);
12497 var helpers = __webpack_require__(56);
12498 var Renderer = __webpack_require__(60);
12499 var ParserCore = __webpack_require__(61);
12500 var ParserBlock = __webpack_require__(71);
12501 var ParserInline = __webpack_require__(86);
12502 var LinkifyIt = __webpack_require__(101);
12503 var mdurl = __webpack_require__(46);
12504 var punycode = __webpack_require__(103);
12508 'default': __webpack_require__(104),
12509 zero: __webpack_require__(105),
12510 commonmark: __webpack_require__(106)
12513 ////////////////////////////////////////////////////////////////////////////////
12515 // This validator can prohibit more than really needed to prevent XSS. It's a
12516 // tradeoff to keep code simple and to be secure by default.
12518 // If you need different setup - override validator method as you wish. Or
12519 // replace it with dummy function and use external sanitizer.
12522 var BAD_PROTO_RE = /^(vbscript|javascript|file|data):/;
12523 var GOOD_DATA_RE = /^data:image\/(gif|png|jpeg|webp);/;
12525 function validateLink(url) {
12526 // url should be normalized at this point, and existing entities are decoded
12527 var str = url.trim().toLowerCase();
12529 return BAD_PROTO_RE.test(str) ? (GOOD_DATA_RE.test(str) ? true : false) : true;
12532 ////////////////////////////////////////////////////////////////////////////////
12535 var RECODE_HOSTNAME_FOR = [ 'http:', 'https:', 'mailto:' ];
12537 function normalizeLink(url) {
12538 var parsed = mdurl.parse(url, true);
12540 if (parsed.hostname) {
12541 // Encode hostnames in urls like:
12542 // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
12544 // We don't encode unknown schemas, because it's likely that we encode
12545 // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
12547 if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
12549 parsed.hostname = punycode.toASCII(parsed.hostname);
12550 } catch (er) { /**/ }
12554 return mdurl.encode(mdurl.format(parsed));
12557 function normalizeLinkText(url) {
12558 var parsed = mdurl.parse(url, true);
12560 if (parsed.hostname) {
12561 // Encode hostnames in urls like:
12562 // `http://host/`, `https://host/`, `mailto:user@host`, `//host/`
12564 // We don't encode unknown schemas, because it's likely that we encode
12565 // something we shouldn't (e.g. `skype:name` treated as `skype:host`)
12567 if (!parsed.protocol || RECODE_HOSTNAME_FOR.indexOf(parsed.protocol) >= 0) {
12569 parsed.hostname = punycode.toUnicode(parsed.hostname);
12570 } catch (er) { /**/ }
12574 return mdurl.decode(mdurl.format(parsed));
12581 * Main parser/renderer class.
12586 * // node.js, "classic" way:
12587 * var MarkdownIt = require('markdown-it'),
12588 * md = new MarkdownIt();
12589 * var result = md.render('# markdown-it rulezz!');
12591 * // node.js, the same, but with sugar:
12592 * var md = require('markdown-it')();
12593 * var result = md.render('# markdown-it rulezz!');
12595 * // browser without AMD, added to "window" on script load
12596 * // Note, there are no dash.
12597 * var md = window.markdownit();
12598 * var result = md.render('# markdown-it rulezz!');
12601 * Single line rendering, without paragraph wrap:
12604 * var md = require('markdown-it')();
12605 * var result = md.renderInline('__markdown-it__ rulezz!');
12610 * new MarkdownIt([presetName, options])
12611 * - presetName (String): optional, `commonmark` / `zero`
12612 * - options (Object)
12614 * Creates parser instanse with given config. Can be called without `new`.
12618 * MarkdownIt provides named presets as a convenience to quickly
12619 * enable/disable active syntax rules and options for common use cases.
12621 * - ["commonmark"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/commonmark.js) -
12622 * configures parser to strict [CommonMark](http://commonmark.org/) mode.
12623 * - [default](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/default.js) -
12624 * similar to GFM, used when no preset name given. Enables all available rules,
12625 * but still without html, typographer & autolinker.
12626 * - ["zero"](https://github.com/markdown-it/markdown-it/blob/master/lib/presets/zero.js) -
12627 * all rules disabled. Useful to quickly setup your config via `.enable()`.
12628 * For example, when you need only `bold` and `italic` markup and nothing else.
12632 * - __html__ - `false`. Set `true` to enable HTML tags in source. Be careful!
12633 * That's not safe! You may need external sanitizer to protect output from XSS.
12634 * It's better to extend features via plugins, instead of enabling HTML.
12635 * - __xhtmlOut__ - `false`. Set `true` to add '/' when closing single tags
12636 * (`<br />`). This is needed only for full CommonMark compatibility. In real
12637 * world you will need HTML output.
12638 * - __breaks__ - `false`. Set `true` to convert `\n` in paragraphs into `<br>`.
12639 * - __langPrefix__ - `language-`. CSS language class prefix for fenced blocks.
12640 * Can be useful for external highlighters.
12641 * - __linkify__ - `false`. Set `true` to autoconvert URL-like text to links.
12642 * - __typographer__ - `false`. Set `true` to enable [some language-neutral
12643 * replacement](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/replacements.js) +
12644 * quotes beautification (smartquotes).
12645 * - __quotes__ - `“”‘’`, String or Array. Double + single quotes replacement
12646 * pairs, when typographer enabled and smartquotes on. For example, you can
12647 * use `'«»„“'` for Russian, `'„“‚‘'` for German, and
12648 * `['«\xA0', '\xA0»', '‹\xA0', '\xA0›']` for French (including nbsp).
12649 * - __highlight__ - `null`. Highlighter function for fenced code blocks.
12650 * Highlighter `function (str, lang)` should return escaped HTML. It can also
12651 * return empty string if the source was not changed and should be escaped
12652 * externaly. If result starts with <pre... internal wrapper is skipped.
12657 * // commonmark mode
12658 * var md = require('markdown-it')('commonmark');
12661 * var md = require('markdown-it')();
12663 * // enable everything
12664 * var md = require('markdown-it')({
12667 * typographer: true
12671 * ##### Syntax highlighting
12674 * var hljs = require('highlight.js') // https://highlightjs.org/
12676 * var md = require('markdown-it')({
12677 * highlight: function (str, lang) {
12678 * if (lang && hljs.getLanguage(lang)) {
12680 * return hljs.highlight(lang, str, true).value;
12684 * return ''; // use external default escaping
12689 * Or with full wrapper override (if you need assign class to `<pre>`):
12692 * var hljs = require('highlight.js') // https://highlightjs.org/
12694 * // Actual default values
12695 * var md = require('markdown-it')({
12696 * highlight: function (str, lang) {
12697 * if (lang && hljs.getLanguage(lang)) {
12699 * return '<pre class="hljs"><code>' +
12700 * hljs.highlight(lang, str, true).value +
12705 * return '<pre class="hljs"><code>' + md.utils.escapeHtml(str) + '</code></pre>';
12711 function MarkdownIt(presetName, options) {
12712 if (!(this instanceof MarkdownIt)) {
12713 return new MarkdownIt(presetName, options);
12717 if (!utils.isString(presetName)) {
12718 options = presetName || {};
12719 presetName = 'default';
12724 * MarkdownIt#inline -> ParserInline
12726 * Instance of [[ParserInline]]. You may need it to add new rules when
12727 * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
12728 * [[MarkdownIt.enable]].
12730 this.inline = new ParserInline();
12733 * MarkdownIt#block -> ParserBlock
12735 * Instance of [[ParserBlock]]. You may need it to add new rules when
12736 * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
12737 * [[MarkdownIt.enable]].
12739 this.block = new ParserBlock();
12742 * MarkdownIt#core -> Core
12744 * Instance of [[Core]] chain executor. You may need it to add new rules when
12745 * writing plugins. For simple rules control use [[MarkdownIt.disable]] and
12746 * [[MarkdownIt.enable]].
12748 this.core = new ParserCore();
12751 * MarkdownIt#renderer -> Renderer
12753 * Instance of [[Renderer]]. Use it to modify output look. Or to add rendering
12754 * rules for new token types, generated by plugins.
12759 * var md = require('markdown-it')();
12761 * function myToken(tokens, idx, options, env, self) {
12766 * md.renderer.rules['my_token'] = myToken
12769 * See [[Renderer]] docs and [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js).
12771 this.renderer = new Renderer();
12774 * MarkdownIt#linkify -> LinkifyIt
12776 * [linkify-it](https://github.com/markdown-it/linkify-it) instance.
12777 * Used by [linkify](https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js)
12780 this.linkify = new LinkifyIt();
12783 * MarkdownIt#validateLink(url) -> Boolean
12785 * Link validation function. CommonMark allows too much in links. By default
12786 * we disable `javascript:`, `vbscript:`, `file:` schemas, and almost all `data:...` schemas
12787 * except some embedded image types.
12789 * You can change this behaviour:
12792 * var md = require('markdown-it')();
12793 * // enable everything
12794 * md.validateLink = function () { return true; }
12797 this.validateLink = validateLink;
12800 * MarkdownIt#normalizeLink(url) -> String
12802 * Function used to encode link url to a machine-readable format,
12803 * which includes url-encoding, punycode, etc.
12805 this.normalizeLink = normalizeLink;
12808 * MarkdownIt#normalizeLinkText(url) -> String
12810 * Function used to decode link url to a human-readable format`
12812 this.normalizeLinkText = normalizeLinkText;
12815 // Expose utils & helpers for easy acces from plugins
12818 * MarkdownIt#utils -> utils
12820 * Assorted utility functions, useful to write plugins. See details
12821 * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/common/utils.js).
12823 this.utils = utils;
12826 * MarkdownIt#helpers -> helpers
12828 * Link components parser functions, useful to write plugins. See details
12829 * [here](https://github.com/markdown-it/markdown-it/blob/master/lib/helpers).
12831 this.helpers = utils.assign({}, helpers);
12835 this.configure(presetName);
12837 if (options) { this.set(options); }
12842 * MarkdownIt.set(options)
12844 * Set parser options (in the same format as in constructor). Probably, you
12845 * will never need it, but you can change options after constructor call.
12850 * var md = require('markdown-it')()
12851 * .set({ html: true, breaks: true })
12852 * .set({ typographer, true });
12855 * __Note:__ To achieve the best possible performance, don't modify a
12856 * `markdown-it` instance options on the fly. If you need multiple configurations
12857 * it's best to create multiple instances and initialize each with separate
12860 MarkdownIt.prototype.set = function (options) {
12861 utils.assign(this.options, options);
12866 /** chainable, internal
12867 * MarkdownIt.configure(presets)
12869 * Batch load of all options and compenent settings. This is internal method,
12870 * and you probably will not need it. But if you with - see available presets
12871 * and data structure [here](https://github.com/markdown-it/markdown-it/tree/master/lib/presets)
12873 * We strongly recommend to use presets instead of direct config loads. That
12874 * will give better compatibility with next versions.
12876 MarkdownIt.prototype.configure = function (presets) {
12877 var self = this, presetName;
12879 if (utils.isString(presets)) {
12880 presetName = presets;
12881 presets = config[presetName];
12882 if (!presets) { throw new Error('Wrong `markdown-it` preset "' + presetName + '", check name'); }
12885 if (!presets) { throw new Error('Wrong `markdown-it` preset, can\'t be empty'); }
12887 if (presets.options) { self.set(presets.options); }
12889 if (presets.components) {
12890 Object.keys(presets.components).forEach(function (name) {
12891 if (presets.components[name].rules) {
12892 self[name].ruler.enableOnly(presets.components[name].rules);
12894 if (presets.components[name].rules2) {
12895 self[name].ruler2.enableOnly(presets.components[name].rules2);
12904 * MarkdownIt.enable(list, ignoreInvalid)
12905 * - list (String|Array): rule name or list of rule names to enable
12906 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
12908 * Enable list or rules. It will automatically find appropriate components,
12909 * containing rules with given names. If rule not found, and `ignoreInvalid`
12910 * not set - throws exception.
12915 * var md = require('markdown-it')()
12916 * .enable(['sub', 'sup'])
12917 * .disable('smartquotes');
12920 MarkdownIt.prototype.enable = function (list, ignoreInvalid) {
12923 if (!Array.isArray(list)) { list = [ list ]; }
12925 [ 'core', 'block', 'inline' ].forEach(function (chain) {
12926 result = result.concat(this[chain].ruler.enable(list, true));
12929 result = result.concat(this.inline.ruler2.enable(list, true));
12931 var missed = list.filter(function (name) { return result.indexOf(name) < 0; });
12933 if (missed.length && !ignoreInvalid) {
12934 throw new Error('MarkdownIt. Failed to enable unknown rule(s): ' + missed);
12942 * MarkdownIt.disable(list, ignoreInvalid)
12943 * - list (String|Array): rule name or list of rule names to disable.
12944 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
12946 * The same as [[MarkdownIt.enable]], but turn specified rules off.
12948 MarkdownIt.prototype.disable = function (list, ignoreInvalid) {
12951 if (!Array.isArray(list)) { list = [ list ]; }
12953 [ 'core', 'block', 'inline' ].forEach(function (chain) {
12954 result = result.concat(this[chain].ruler.disable(list, true));
12957 result = result.concat(this.inline.ruler2.disable(list, true));
12959 var missed = list.filter(function (name) { return result.indexOf(name) < 0; });
12961 if (missed.length && !ignoreInvalid) {
12962 throw new Error('MarkdownIt. Failed to disable unknown rule(s): ' + missed);
12969 * MarkdownIt.use(plugin, params)
12971 * Load specified plugin with given params into current parser instance.
12972 * It's just a sugar to call `plugin(md, params)` with curring.
12977 * var iterator = require('markdown-it-for-inline');
12978 * var md = require('markdown-it')()
12979 * .use(iterator, 'foo_replace', 'text', function (tokens, idx) {
12980 * tokens[idx].content = tokens[idx].content.replace(/foo/g, 'bar');
12984 MarkdownIt.prototype.use = function (plugin /*, params, ... */) {
12985 var args = [ this ].concat(Array.prototype.slice.call(arguments, 1));
12986 plugin.apply(plugin, args);
12992 * MarkdownIt.parse(src, env) -> Array
12993 * - src (String): source string
12994 * - env (Object): environment sandbox
12996 * Parse input string and returns list of block tokens (special token type
12997 * "inline" will contain list of inline tokens). You should not call this
12998 * method directly, until you write custom renderer (for example, to produce
13001 * `env` is used to pass data between "distributed" rules and return additional
13002 * metadata like reference info, needed for the renderer. It also can be used to
13003 * inject data in specific cases. Usually, you will be ok to pass `{}`,
13004 * and then pass updated object to renderer.
13006 MarkdownIt.prototype.parse = function (src, env) {
13007 if (typeof src !== 'string') {
13008 throw new Error('Input data should be a String');
13011 var state = new this.core.State(src, this, env);
13013 this.core.process(state);
13015 return state.tokens;
13020 * MarkdownIt.render(src [, env]) -> String
13021 * - src (String): source string
13022 * - env (Object): environment sandbox
13024 * Render markdown string into html. It does all magic for you :).
13026 * `env` can be used to inject additional metadata (`{}` by default).
13027 * But you will not need it with high probability. See also comment
13028 * in [[MarkdownIt.parse]].
13030 MarkdownIt.prototype.render = function (src, env) {
13033 return this.renderer.render(this.parse(src, env), this.options, env);
13038 * MarkdownIt.parseInline(src, env) -> Array
13039 * - src (String): source string
13040 * - env (Object): environment sandbox
13042 * The same as [[MarkdownIt.parse]] but skip all block rules. It returns the
13043 * block tokens list with the single `inline` element, containing parsed inline
13044 * tokens in `children` property. Also updates `env` object.
13046 MarkdownIt.prototype.parseInline = function (src, env) {
13047 var state = new this.core.State(src, this, env);
13049 state.inlineMode = true;
13050 this.core.process(state);
13052 return state.tokens;
13057 * MarkdownIt.renderInline(src [, env]) -> String
13058 * - src (String): source string
13059 * - env (Object): environment sandbox
13061 * Similar to [[MarkdownIt.render]] but for single paragraph content. Result
13062 * will NOT be wrapped into `<p>` tags.
13064 MarkdownIt.prototype.renderInline = function (src, env) {
13067 return this.renderer.render(this.parseInline(src, env), this.options, env);
13071 module.exports = MarkdownIt;
13076 /***/ (function(module, exports, __webpack_require__) {
13084 function _class(obj) { return Object.prototype.toString.call(obj); }
13086 function isString(obj) { return _class(obj) === '[object String]'; }
13088 var _hasOwnProperty = Object.prototype.hasOwnProperty;
13090 function has(object, key) {
13091 return _hasOwnProperty.call(object, key);
13096 function assign(obj /*from1, from2, from3, ...*/) {
13097 var sources = Array.prototype.slice.call(arguments, 1);
13099 sources.forEach(function (source) {
13100 if (!source) { return; }
13102 if (typeof source !== 'object') {
13103 throw new TypeError(source + 'must be object');
13106 Object.keys(source).forEach(function (key) {
13107 obj[key] = source[key];
13114 // Remove element from array and put another array at those position.
13115 // Useful for some operations with tokens
13116 function arrayReplaceAt(src, pos, newElements) {
13117 return [].concat(src.slice(0, pos), newElements, src.slice(pos + 1));
13120 ////////////////////////////////////////////////////////////////////////////////
13122 function isValidEntityCode(c) {
13123 /*eslint no-bitwise:0*/
13125 if (c >= 0xD800 && c <= 0xDFFF) { return false; }
13127 if (c >= 0xFDD0 && c <= 0xFDEF) { return false; }
13128 if ((c & 0xFFFF) === 0xFFFF || (c & 0xFFFF) === 0xFFFE) { return false; }
13130 if (c >= 0x00 && c <= 0x08) { return false; }
13131 if (c === 0x0B) { return false; }
13132 if (c >= 0x0E && c <= 0x1F) { return false; }
13133 if (c >= 0x7F && c <= 0x9F) { return false; }
13135 if (c > 0x10FFFF) { return false; }
13139 function fromCodePoint(c) {
13140 /*eslint no-bitwise:0*/
13143 var surrogate1 = 0xd800 + (c >> 10),
13144 surrogate2 = 0xdc00 + (c & 0x3ff);
13146 return String.fromCharCode(surrogate1, surrogate2);
13148 return String.fromCharCode(c);
13152 var UNESCAPE_MD_RE = /\\([!"#$%&'()*+,\-.\/:;<=>?@[\\\]^_`{|}~])/g;
13153 var ENTITY_RE = /&([a-z#][a-z0-9]{1,31});/gi;
13154 var UNESCAPE_ALL_RE = new RegExp(UNESCAPE_MD_RE.source + '|' + ENTITY_RE.source, 'gi');
13156 var DIGITAL_ENTITY_TEST_RE = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i;
13158 var entities = __webpack_require__(43);
13160 function replaceEntityPattern(match, name) {
13163 if (has(entities, name)) {
13164 return entities[name];
13167 if (name.charCodeAt(0) === 0x23/* # */ && DIGITAL_ENTITY_TEST_RE.test(name)) {
13168 code = name[1].toLowerCase() === 'x' ?
13169 parseInt(name.slice(2), 16) : parseInt(name.slice(1), 10);
13171 if (isValidEntityCode(code)) {
13172 return fromCodePoint(code);
13179 /*function replaceEntities(str) {
13180 if (str.indexOf('&') < 0) { return str; }
13182 return str.replace(ENTITY_RE, replaceEntityPattern);
13185 function unescapeMd(str) {
13186 if (str.indexOf('\\') < 0) { return str; }
13187 return str.replace(UNESCAPE_MD_RE, '$1');
13190 function unescapeAll(str) {
13191 if (str.indexOf('\\') < 0 && str.indexOf('&') < 0) { return str; }
13193 return str.replace(UNESCAPE_ALL_RE, function (match, escaped, entity) {
13194 if (escaped) { return escaped; }
13195 return replaceEntityPattern(match, entity);
13199 ////////////////////////////////////////////////////////////////////////////////
13201 var HTML_ESCAPE_TEST_RE = /[&<>"]/;
13202 var HTML_ESCAPE_REPLACE_RE = /[&<>"]/g;
13203 var HTML_REPLACEMENTS = {
13210 function replaceUnsafeChar(ch) {
13211 return HTML_REPLACEMENTS[ch];
13214 function escapeHtml(str) {
13215 if (HTML_ESCAPE_TEST_RE.test(str)) {
13216 return str.replace(HTML_ESCAPE_REPLACE_RE, replaceUnsafeChar);
13221 ////////////////////////////////////////////////////////////////////////////////
13223 var REGEXP_ESCAPE_RE = /[.?*+^$[\]\\(){}|-]/g;
13225 function escapeRE(str) {
13226 return str.replace(REGEXP_ESCAPE_RE, '\\$&');
13229 ////////////////////////////////////////////////////////////////////////////////
13231 function isSpace(code) {
13240 // Zs (unicode class) || [\t\f\v\r\n]
13241 function isWhiteSpace(code) {
13242 if (code >= 0x2000 && code <= 0x200A) { return true; }
13260 ////////////////////////////////////////////////////////////////////////////////
13262 /*eslint-disable max-len*/
13263 var UNICODE_PUNCT_RE = __webpack_require__(45);
13265 // Currently without astral characters support.
13266 function isPunctChar(ch) {
13267 return UNICODE_PUNCT_RE.test(ch);
13271 // Markdown ASCII punctuation characters.
13273 // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
13274 // http://spec.commonmark.org/0.15/#ascii-punctuation-character
13276 // Don't confuse with unicode punctuation !!! It lacks some chars in ascii range.
13278 function isMdAsciiPunct(ch) {
13318 // Hepler to unify [reference labels].
13320 function normalizeReference(str) {
13321 // Trim and collapse whitespace
13323 str = str.trim().replace(/\s+/g, ' ');
13325 // In node v10 'ẞ'.toLowerCase() === 'Ṿ', which is presumed to be a bug
13326 // fixed in v12 (couldn't find any details).
13328 // So treat this one as a special case
13329 // (remove this when node v10 is no longer supported).
13331 if ('ẞ'.toLowerCase() === 'Ṿ') {
13332 str = str.replace(/ẞ/g, 'ß');
13335 // .toLowerCase().toUpperCase() should get rid of all differences
13336 // between letter variants.
13338 // Simple .toLowerCase() doesn't normalize 125 code points correctly,
13339 // and .toUpperCase doesn't normalize 6 of them (list of exceptions:
13340 // İ, ϴ, ẞ, Ω, K, Å - those are already uppercased, but have differently
13341 // uppercased versions).
13343 // Here's an example showing how it happens. Lets take greek letter omega:
13344 // uppercase U+0398 (Θ), U+03f4 (ϴ) and lowercase U+03b8 (θ), U+03d1 (ϑ)
13346 // Unicode entries:
13347 // 0398;GREEK CAPITAL LETTER THETA;Lu;0;L;;;;;N;;;;03B8;
13348 // 03B8;GREEK SMALL LETTER THETA;Ll;0;L;;;;;N;;;0398;;0398
13349 // 03D1;GREEK THETA SYMBOL;Ll;0;L;<compat> 03B8;;;;N;GREEK SMALL LETTER SCRIPT THETA;;0398;;0398
13350 // 03F4;GREEK CAPITAL THETA SYMBOL;Lu;0;L;<compat> 0398;;;;N;;;;03B8;
13352 // Case-insensitive comparison should treat all of them as equivalent.
13354 // But .toLowerCase() doesn't change ϑ (it's already lowercase),
13355 // and .toUpperCase() doesn't change ϴ (already uppercase).
13357 // Applying first lower then upper case normalizes any character:
13358 // '\u0398\u03f4\u03b8\u03d1'.toLowerCase().toUpperCase() === '\u0398\u0398\u0398\u0398'
13360 // Note: this is equivalent to unicode case folding; unicode normalization
13361 // is a different step that is not required here.
13363 // Final result should be uppercased, because it's later stored in an object
13364 // (this avoid a conflict with Object.prototype members,
13365 // most notably, `__proto__`)
13367 return str.toLowerCase().toUpperCase();
13370 ////////////////////////////////////////////////////////////////////////////////
13372 // Re-export libraries commonly used in both markdown-it and its plugins,
13373 // so plugins won't have to depend on them explicitly, which reduces their
13374 // bundled size (e.g. a browser build).
13377 exports.lib.mdurl = __webpack_require__(46);
13378 exports.lib.ucmicro = __webpack_require__(51);
13380 exports.assign = assign;
13381 exports.isString = isString;
13383 exports.unescapeMd = unescapeMd;
13384 exports.unescapeAll = unescapeAll;
13385 exports.isValidEntityCode = isValidEntityCode;
13386 exports.fromCodePoint = fromCodePoint;
13387 // exports.replaceEntities = replaceEntities;
13388 exports.escapeHtml = escapeHtml;
13389 exports.arrayReplaceAt = arrayReplaceAt;
13390 exports.isSpace = isSpace;
13391 exports.isWhiteSpace = isWhiteSpace;
13392 exports.isMdAsciiPunct = isMdAsciiPunct;
13393 exports.isPunctChar = isPunctChar;
13394 exports.escapeRE = escapeRE;
13395 exports.normalizeReference = normalizeReference;
13400 /***/ (function(module, exports, __webpack_require__) {
13403 // HTML5 entities map: { name -> utf16string }
13407 /*eslint quotes:0*/
13408 module.exports = __webpack_require__(44);
13413 /***/ (function(module) {
13415 module.exports = JSON.parse("{\"Aacute\":\"Á\",\"aacute\":\"á\",\"Abreve\":\"Ă\",\"abreve\":\"ă\",\"ac\":\"∾\",\"acd\":\"∿\",\"acE\":\"∾̳\",\"Acirc\":\"Â\",\"acirc\":\"â\",\"acute\":\"´\",\"Acy\":\"А\",\"acy\":\"а\",\"AElig\":\"Æ\",\"aelig\":\"æ\",\"af\":\"\",\"Afr\":\"𝔄\",\"afr\":\"𝔞\",\"Agrave\":\"À\",\"agrave\":\"à\",\"alefsym\":\"ℵ\",\"aleph\":\"ℵ\",\"Alpha\":\"Α\",\"alpha\":\"α\",\"Amacr\":\"Ā\",\"amacr\":\"ā\",\"amalg\":\"⨿\",\"amp\":\"&\",\"AMP\":\"&\",\"andand\":\"⩕\",\"And\":\"⩓\",\"and\":\"∧\",\"andd\":\"⩜\",\"andslope\":\"⩘\",\"andv\":\"⩚\",\"ang\":\"∠\",\"ange\":\"⦤\",\"angle\":\"∠\",\"angmsdaa\":\"⦨\",\"angmsdab\":\"⦩\",\"angmsdac\":\"⦪\",\"angmsdad\":\"⦫\",\"angmsdae\":\"⦬\",\"angmsdaf\":\"⦭\",\"angmsdag\":\"⦮\",\"angmsdah\":\"⦯\",\"angmsd\":\"∡\",\"angrt\":\"∟\",\"angrtvb\":\"⊾\",\"angrtvbd\":\"⦝\",\"angsph\":\"∢\",\"angst\":\"Å\",\"angzarr\":\"⍼\",\"Aogon\":\"Ą\",\"aogon\":\"ą\",\"Aopf\":\"𝔸\",\"aopf\":\"𝕒\",\"apacir\":\"⩯\",\"ap\":\"≈\",\"apE\":\"⩰\",\"ape\":\"≊\",\"apid\":\"≋\",\"apos\":\"'\",\"ApplyFunction\":\"\",\"approx\":\"≈\",\"approxeq\":\"≊\",\"Aring\":\"Å\",\"aring\":\"å\",\"Ascr\":\"𝒜\",\"ascr\":\"𝒶\",\"Assign\":\"≔\",\"ast\":\"*\",\"asymp\":\"≈\",\"asympeq\":\"≍\",\"Atilde\":\"Ã\",\"atilde\":\"ã\",\"Auml\":\"Ä\",\"auml\":\"ä\",\"awconint\":\"∳\",\"awint\":\"⨑\",\"backcong\":\"≌\",\"backepsilon\":\"϶\",\"backprime\":\"‵\",\"backsim\":\"∽\",\"backsimeq\":\"⋍\",\"Backslash\":\"∖\",\"Barv\":\"⫧\",\"barvee\":\"⊽\",\"barwed\":\"⌅\",\"Barwed\":\"⌆\",\"barwedge\":\"⌅\",\"bbrk\":\"⎵\",\"bbrktbrk\":\"⎶\",\"bcong\":\"≌\",\"Bcy\":\"Б\",\"bcy\":\"б\",\"bdquo\":\"„\",\"becaus\":\"∵\",\"because\":\"∵\",\"Because\":\"∵\",\"bemptyv\":\"⦰\",\"bepsi\":\"϶\",\"bernou\":\"ℬ\",\"Bernoullis\":\"ℬ\",\"Beta\":\"Β\",\"beta\":\"β\",\"beth\":\"ℶ\",\"between\":\"≬\",\"Bfr\":\"𝔅\",\"bfr\":\"𝔟\",\"bigcap\":\"⋂\",\"bigcirc\":\"◯\",\"bigcup\":\"⋃\",\"bigodot\":\"⨀\",\"bigoplus\":\"⨁\",\"bigotimes\":\"⨂\",\"bigsqcup\":\"⨆\",\"bigstar\":\"★\",\"bigtriangledown\":\"▽\",\"bigtriangleup\":\"△\",\"biguplus\":\"⨄\",\"bigvee\":\"⋁\",\"bigwedge\":\"⋀\",\"bkarow\":\"⤍\",\"blacklozenge\":\"⧫\",\"blacksquare\":\"▪\",\"blacktriangle\":\"▴\",\"blacktriangledown\":\"▾\",\"blacktriangleleft\":\"◂\",\"blacktriangleright\":\"▸\",\"blank\":\"␣\",\"blk12\":\"▒\",\"blk14\":\"░\",\"blk34\":\"▓\",\"block\":\"█\",\"bne\":\"=⃥\",\"bnequiv\":\"≡⃥\",\"bNot\":\"⫭\",\"bnot\":\"⌐\",\"Bopf\":\"𝔹\",\"bopf\":\"𝕓\",\"bot\":\"⊥\",\"bottom\":\"⊥\",\"bowtie\":\"⋈\",\"boxbox\":\"⧉\",\"boxdl\":\"┐\",\"boxdL\":\"╕\",\"boxDl\":\"╖\",\"boxDL\":\"╗\",\"boxdr\":\"┌\",\"boxdR\":\"╒\",\"boxDr\":\"╓\",\"boxDR\":\"╔\",\"boxh\":\"─\",\"boxH\":\"═\",\"boxhd\":\"┬\",\"boxHd\":\"╤\",\"boxhD\":\"╥\",\"boxHD\":\"╦\",\"boxhu\":\"┴\",\"boxHu\":\"╧\",\"boxhU\":\"╨\",\"boxHU\":\"╩\",\"boxminus\":\"⊟\",\"boxplus\":\"⊞\",\"boxtimes\":\"⊠\",\"boxul\":\"┘\",\"boxuL\":\"╛\",\"boxUl\":\"╜\",\"boxUL\":\"╝\",\"boxur\":\"└\",\"boxuR\":\"╘\",\"boxUr\":\"╙\",\"boxUR\":\"╚\",\"boxv\":\"│\",\"boxV\":\"║\",\"boxvh\":\"┼\",\"boxvH\":\"╪\",\"boxVh\":\"╫\",\"boxVH\":\"╬\",\"boxvl\":\"┤\",\"boxvL\":\"╡\",\"boxVl\":\"╢\",\"boxVL\":\"╣\",\"boxvr\":\"├\",\"boxvR\":\"╞\",\"boxVr\":\"╟\",\"boxVR\":\"╠\",\"bprime\":\"‵\",\"breve\":\"˘\",\"Breve\":\"˘\",\"brvbar\":\"¦\",\"bscr\":\"𝒷\",\"Bscr\":\"ℬ\",\"bsemi\":\"⁏\",\"bsim\":\"∽\",\"bsime\":\"⋍\",\"bsolb\":\"⧅\",\"bsol\":\"\\\\\",\"bsolhsub\":\"⟈\",\"bull\":\"•\",\"bullet\":\"•\",\"bump\":\"≎\",\"bumpE\":\"⪮\",\"bumpe\":\"≏\",\"Bumpeq\":\"≎\",\"bumpeq\":\"≏\",\"Cacute\":\"Ć\",\"cacute\":\"ć\",\"capand\":\"⩄\",\"capbrcup\":\"⩉\",\"capcap\":\"⩋\",\"cap\":\"∩\",\"Cap\":\"⋒\",\"capcup\":\"⩇\",\"capdot\":\"⩀\",\"CapitalDifferentialD\":\"ⅅ\",\"caps\":\"∩︀\",\"caret\":\"⁁\",\"caron\":\"ˇ\",\"Cayleys\":\"ℭ\",\"ccaps\":\"⩍\",\"Ccaron\":\"Č\",\"ccaron\":\"č\",\"Ccedil\":\"Ç\",\"ccedil\":\"ç\",\"Ccirc\":\"Ĉ\",\"ccirc\":\"ĉ\",\"Cconint\":\"∰\",\"ccups\":\"⩌\",\"ccupssm\":\"⩐\",\"Cdot\":\"Ċ\",\"cdot\":\"ċ\",\"cedil\":\"¸\",\"Cedilla\":\"¸\",\"cemptyv\":\"⦲\",\"cent\":\"¢\",\"centerdot\":\"·\",\"CenterDot\":\"·\",\"cfr\":\"𝔠\",\"Cfr\":\"ℭ\",\"CHcy\":\"Ч\",\"chcy\":\"ч\",\"check\":\"✓\",\"checkmark\":\"✓\",\"Chi\":\"Χ\",\"chi\":\"χ\",\"circ\":\"ˆ\",\"circeq\":\"≗\",\"circlearrowleft\":\"↺\",\"circlearrowright\":\"↻\",\"circledast\":\"⊛\",\"circledcirc\":\"⊚\",\"circleddash\":\"⊝\",\"CircleDot\":\"⊙\",\"circledR\":\"®\",\"circledS\":\"Ⓢ\",\"CircleMinus\":\"⊖\",\"CirclePlus\":\"⊕\",\"CircleTimes\":\"⊗\",\"cir\":\"○\",\"cirE\":\"⧃\",\"cire\":\"≗\",\"cirfnint\":\"⨐\",\"cirmid\":\"⫯\",\"cirscir\":\"⧂\",\"ClockwiseContourIntegral\":\"∲\",\"CloseCurlyDoubleQuote\":\"”\",\"CloseCurlyQuote\":\"’\",\"clubs\":\"♣\",\"clubsuit\":\"♣\",\"colon\":\":\",\"Colon\":\"∷\",\"Colone\":\"⩴\",\"colone\":\"≔\",\"coloneq\":\"≔\",\"comma\":\",\",\"commat\":\"@\",\"comp\":\"∁\",\"compfn\":\"∘\",\"complement\":\"∁\",\"complexes\":\"ℂ\",\"cong\":\"≅\",\"congdot\":\"⩭\",\"Congruent\":\"≡\",\"conint\":\"∮\",\"Conint\":\"∯\",\"ContourIntegral\":\"∮\",\"copf\":\"𝕔\",\"Copf\":\"ℂ\",\"coprod\":\"∐\",\"Coproduct\":\"∐\",\"copy\":\"©\",\"COPY\":\"©\",\"copysr\":\"℗\",\"CounterClockwiseContourIntegral\":\"∳\",\"crarr\":\"↵\",\"cross\":\"✗\",\"Cross\":\"⨯\",\"Cscr\":\"𝒞\",\"cscr\":\"𝒸\",\"csub\":\"⫏\",\"csube\":\"⫑\",\"csup\":\"⫐\",\"csupe\":\"⫒\",\"ctdot\":\"⋯\",\"cudarrl\":\"⤸\",\"cudarrr\":\"⤵\",\"cuepr\":\"⋞\",\"cuesc\":\"⋟\",\"cularr\":\"↶\",\"cularrp\":\"⤽\",\"cupbrcap\":\"⩈\",\"cupcap\":\"⩆\",\"CupCap\":\"≍\",\"cup\":\"∪\",\"Cup\":\"⋓\",\"cupcup\":\"⩊\",\"cupdot\":\"⊍\",\"cupor\":\"⩅\",\"cups\":\"∪︀\",\"curarr\":\"↷\",\"curarrm\":\"⤼\",\"curlyeqprec\":\"⋞\",\"curlyeqsucc\":\"⋟\",\"curlyvee\":\"⋎\",\"curlywedge\":\"⋏\",\"curren\":\"¤\",\"curvearrowleft\":\"↶\",\"curvearrowright\":\"↷\",\"cuvee\":\"⋎\",\"cuwed\":\"⋏\",\"cwconint\":\"∲\",\"cwint\":\"∱\",\"cylcty\":\"⌭\",\"dagger\":\"†\",\"Dagger\":\"‡\",\"daleth\":\"ℸ\",\"darr\":\"↓\",\"Darr\":\"↡\",\"dArr\":\"⇓\",\"dash\":\"‐\",\"Dashv\":\"⫤\",\"dashv\":\"⊣\",\"dbkarow\":\"⤏\",\"dblac\":\"˝\",\"Dcaron\":\"Ď\",\"dcaron\":\"ď\",\"Dcy\":\"Д\",\"dcy\":\"д\",\"ddagger\":\"‡\",\"ddarr\":\"⇊\",\"DD\":\"ⅅ\",\"dd\":\"ⅆ\",\"DDotrahd\":\"⤑\",\"ddotseq\":\"⩷\",\"deg\":\"°\",\"Del\":\"∇\",\"Delta\":\"Δ\",\"delta\":\"δ\",\"demptyv\":\"⦱\",\"dfisht\":\"⥿\",\"Dfr\":\"𝔇\",\"dfr\":\"𝔡\",\"dHar\":\"⥥\",\"dharl\":\"⇃\",\"dharr\":\"⇂\",\"DiacriticalAcute\":\"´\",\"DiacriticalDot\":\"˙\",\"DiacriticalDoubleAcute\":\"˝\",\"DiacriticalGrave\":\"`\",\"DiacriticalTilde\":\"˜\",\"diam\":\"⋄\",\"diamond\":\"⋄\",\"Diamond\":\"⋄\",\"diamondsuit\":\"♦\",\"diams\":\"♦\",\"die\":\"¨\",\"DifferentialD\":\"ⅆ\",\"digamma\":\"ϝ\",\"disin\":\"⋲\",\"div\":\"÷\",\"divide\":\"÷\",\"divideontimes\":\"⋇\",\"divonx\":\"⋇\",\"DJcy\":\"Ђ\",\"djcy\":\"ђ\",\"dlcorn\":\"⌞\",\"dlcrop\":\"⌍\",\"dollar\":\"$\",\"Dopf\":\"𝔻\",\"dopf\":\"𝕕\",\"Dot\":\"¨\",\"dot\":\"˙\",\"DotDot\":\"⃜\",\"doteq\":\"≐\",\"doteqdot\":\"≑\",\"DotEqual\":\"≐\",\"dotminus\":\"∸\",\"dotplus\":\"∔\",\"dotsquare\":\"⊡\",\"doublebarwedge\":\"⌆\",\"DoubleContourIntegral\":\"∯\",\"DoubleDot\":\"¨\",\"DoubleDownArrow\":\"⇓\",\"DoubleLeftArrow\":\"⇐\",\"DoubleLeftRightArrow\":\"⇔\",\"DoubleLeftTee\":\"⫤\",\"DoubleLongLeftArrow\":\"⟸\",\"DoubleLongLeftRightArrow\":\"⟺\",\"DoubleLongRightArrow\":\"⟹\",\"DoubleRightArrow\":\"⇒\",\"DoubleRightTee\":\"⊨\",\"DoubleUpArrow\":\"⇑\",\"DoubleUpDownArrow\":\"⇕\",\"DoubleVerticalBar\":\"∥\",\"DownArrowBar\":\"⤓\",\"downarrow\":\"↓\",\"DownArrow\":\"↓\",\"Downarrow\":\"⇓\",\"DownArrowUpArrow\":\"⇵\",\"DownBreve\":\"̑\",\"downdownarrows\":\"⇊\",\"downharpoonleft\":\"⇃\",\"downharpoonright\":\"⇂\",\"DownLeftRightVector\":\"⥐\",\"DownLeftTeeVector\":\"⥞\",\"DownLeftVectorBar\":\"⥖\",\"DownLeftVector\":\"↽\",\"DownRightTeeVector\":\"⥟\",\"DownRightVectorBar\":\"⥗\",\"DownRightVector\":\"⇁\",\"DownTeeArrow\":\"↧\",\"DownTee\":\"⊤\",\"drbkarow\":\"⤐\",\"drcorn\":\"⌟\",\"drcrop\":\"⌌\",\"Dscr\":\"𝒟\",\"dscr\":\"𝒹\",\"DScy\":\"Ѕ\",\"dscy\":\"ѕ\",\"dsol\":\"⧶\",\"Dstrok\":\"Đ\",\"dstrok\":\"đ\",\"dtdot\":\"⋱\",\"dtri\":\"▿\",\"dtrif\":\"▾\",\"duarr\":\"⇵\",\"duhar\":\"⥯\",\"dwangle\":\"⦦\",\"DZcy\":\"Џ\",\"dzcy\":\"џ\",\"dzigrarr\":\"⟿\",\"Eacute\":\"É\",\"eacute\":\"é\",\"easter\":\"⩮\",\"Ecaron\":\"Ě\",\"ecaron\":\"ě\",\"Ecirc\":\"Ê\",\"ecirc\":\"ê\",\"ecir\":\"≖\",\"ecolon\":\"≕\",\"Ecy\":\"Э\",\"ecy\":\"э\",\"eDDot\":\"⩷\",\"Edot\":\"Ė\",\"edot\":\"ė\",\"eDot\":\"≑\",\"ee\":\"ⅇ\",\"efDot\":\"≒\",\"Efr\":\"𝔈\",\"efr\":\"𝔢\",\"eg\":\"⪚\",\"Egrave\":\"È\",\"egrave\":\"è\",\"egs\":\"⪖\",\"egsdot\":\"⪘\",\"el\":\"⪙\",\"Element\":\"∈\",\"elinters\":\"⏧\",\"ell\":\"ℓ\",\"els\":\"⪕\",\"elsdot\":\"⪗\",\"Emacr\":\"Ē\",\"emacr\":\"ē\",\"empty\":\"∅\",\"emptyset\":\"∅\",\"EmptySmallSquare\":\"◻\",\"emptyv\":\"∅\",\"EmptyVerySmallSquare\":\"▫\",\"emsp13\":\" \",\"emsp14\":\" \",\"emsp\":\" \",\"ENG\":\"Ŋ\",\"eng\":\"ŋ\",\"ensp\":\" \",\"Eogon\":\"Ę\",\"eogon\":\"ę\",\"Eopf\":\"𝔼\",\"eopf\":\"𝕖\",\"epar\":\"⋕\",\"eparsl\":\"⧣\",\"eplus\":\"⩱\",\"epsi\":\"ε\",\"Epsilon\":\"Ε\",\"epsilon\":\"ε\",\"epsiv\":\"ϵ\",\"eqcirc\":\"≖\",\"eqcolon\":\"≕\",\"eqsim\":\"≂\",\"eqslantgtr\":\"⪖\",\"eqslantless\":\"⪕\",\"Equal\":\"⩵\",\"equals\":\"=\",\"EqualTilde\":\"≂\",\"equest\":\"≟\",\"Equilibrium\":\"⇌\",\"equiv\":\"≡\",\"equivDD\":\"⩸\",\"eqvparsl\":\"⧥\",\"erarr\":\"⥱\",\"erDot\":\"≓\",\"escr\":\"ℯ\",\"Escr\":\"ℰ\",\"esdot\":\"≐\",\"Esim\":\"⩳\",\"esim\":\"≂\",\"Eta\":\"Η\",\"eta\":\"η\",\"ETH\":\"Ð\",\"eth\":\"ð\",\"Euml\":\"Ë\",\"euml\":\"ë\",\"euro\":\"€\",\"excl\":\"!\",\"exist\":\"∃\",\"Exists\":\"∃\",\"expectation\":\"ℰ\",\"exponentiale\":\"ⅇ\",\"ExponentialE\":\"ⅇ\",\"fallingdotseq\":\"≒\",\"Fcy\":\"Ф\",\"fcy\":\"ф\",\"female\":\"♀\",\"ffilig\":\"ffi\",\"fflig\":\"ff\",\"ffllig\":\"ffl\",\"Ffr\":\"𝔉\",\"ffr\":\"𝔣\",\"filig\":\"fi\",\"FilledSmallSquare\":\"◼\",\"FilledVerySmallSquare\":\"▪\",\"fjlig\":\"fj\",\"flat\":\"♭\",\"fllig\":\"fl\",\"fltns\":\"▱\",\"fnof\":\"ƒ\",\"Fopf\":\"𝔽\",\"fopf\":\"𝕗\",\"forall\":\"∀\",\"ForAll\":\"∀\",\"fork\":\"⋔\",\"forkv\":\"⫙\",\"Fouriertrf\":\"ℱ\",\"fpartint\":\"⨍\",\"frac12\":\"½\",\"frac13\":\"⅓\",\"frac14\":\"¼\",\"frac15\":\"⅕\",\"frac16\":\"⅙\",\"frac18\":\"⅛\",\"frac23\":\"⅔\",\"frac25\":\"⅖\",\"frac34\":\"¾\",\"frac35\":\"⅗\",\"frac38\":\"⅜\",\"frac45\":\"⅘\",\"frac56\":\"⅚\",\"frac58\":\"⅝\",\"frac78\":\"⅞\",\"frasl\":\"⁄\",\"frown\":\"⌢\",\"fscr\":\"𝒻\",\"Fscr\":\"ℱ\",\"gacute\":\"ǵ\",\"Gamma\":\"Γ\",\"gamma\":\"γ\",\"Gammad\":\"Ϝ\",\"gammad\":\"ϝ\",\"gap\":\"⪆\",\"Gbreve\":\"Ğ\",\"gbreve\":\"ğ\",\"Gcedil\":\"Ģ\",\"Gcirc\":\"Ĝ\",\"gcirc\":\"ĝ\",\"Gcy\":\"Г\",\"gcy\":\"г\",\"Gdot\":\"Ġ\",\"gdot\":\"ġ\",\"ge\":\"≥\",\"gE\":\"≧\",\"gEl\":\"⪌\",\"gel\":\"⋛\",\"geq\":\"≥\",\"geqq\":\"≧\",\"geqslant\":\"⩾\",\"gescc\":\"⪩\",\"ges\":\"⩾\",\"gesdot\":\"⪀\",\"gesdoto\":\"⪂\",\"gesdotol\":\"⪄\",\"gesl\":\"⋛︀\",\"gesles\":\"⪔\",\"Gfr\":\"𝔊\",\"gfr\":\"𝔤\",\"gg\":\"≫\",\"Gg\":\"⋙\",\"ggg\":\"⋙\",\"gimel\":\"ℷ\",\"GJcy\":\"Ѓ\",\"gjcy\":\"ѓ\",\"gla\":\"⪥\",\"gl\":\"≷\",\"glE\":\"⪒\",\"glj\":\"⪤\",\"gnap\":\"⪊\",\"gnapprox\":\"⪊\",\"gne\":\"⪈\",\"gnE\":\"≩\",\"gneq\":\"⪈\",\"gneqq\":\"≩\",\"gnsim\":\"⋧\",\"Gopf\":\"𝔾\",\"gopf\":\"𝕘\",\"grave\":\"`\",\"GreaterEqual\":\"≥\",\"GreaterEqualLess\":\"⋛\",\"GreaterFullEqual\":\"≧\",\"GreaterGreater\":\"⪢\",\"GreaterLess\":\"≷\",\"GreaterSlantEqual\":\"⩾\",\"GreaterTilde\":\"≳\",\"Gscr\":\"𝒢\",\"gscr\":\"ℊ\",\"gsim\":\"≳\",\"gsime\":\"⪎\",\"gsiml\":\"⪐\",\"gtcc\":\"⪧\",\"gtcir\":\"⩺\",\"gt\":\">\",\"GT\":\">\",\"Gt\":\"≫\",\"gtdot\":\"⋗\",\"gtlPar\":\"⦕\",\"gtquest\":\"⩼\",\"gtrapprox\":\"⪆\",\"gtrarr\":\"⥸\",\"gtrdot\":\"⋗\",\"gtreqless\":\"⋛\",\"gtreqqless\":\"⪌\",\"gtrless\":\"≷\",\"gtrsim\":\"≳\",\"gvertneqq\":\"≩︀\",\"gvnE\":\"≩︀\",\"Hacek\":\"ˇ\",\"hairsp\":\" \",\"half\":\"½\",\"hamilt\":\"ℋ\",\"HARDcy\":\"Ъ\",\"hardcy\":\"ъ\",\"harrcir\":\"⥈\",\"harr\":\"↔\",\"hArr\":\"⇔\",\"harrw\":\"↭\",\"Hat\":\"^\",\"hbar\":\"ℏ\",\"Hcirc\":\"Ĥ\",\"hcirc\":\"ĥ\",\"hearts\":\"♥\",\"heartsuit\":\"♥\",\"hellip\":\"…\",\"hercon\":\"⊹\",\"hfr\":\"𝔥\",\"Hfr\":\"ℌ\",\"HilbertSpace\":\"ℋ\",\"hksearow\":\"⤥\",\"hkswarow\":\"⤦\",\"hoarr\":\"⇿\",\"homtht\":\"∻\",\"hookleftarrow\":\"↩\",\"hookrightarrow\":\"↪\",\"hopf\":\"𝕙\",\"Hopf\":\"ℍ\",\"horbar\":\"―\",\"HorizontalLine\":\"─\",\"hscr\":\"𝒽\",\"Hscr\":\"ℋ\",\"hslash\":\"ℏ\",\"Hstrok\":\"Ħ\",\"hstrok\":\"ħ\",\"HumpDownHump\":\"≎\",\"HumpEqual\":\"≏\",\"hybull\":\"⁃\",\"hyphen\":\"‐\",\"Iacute\":\"Í\",\"iacute\":\"í\",\"ic\":\"\",\"Icirc\":\"Î\",\"icirc\":\"î\",\"Icy\":\"И\",\"icy\":\"и\",\"Idot\":\"İ\",\"IEcy\":\"Е\",\"iecy\":\"е\",\"iexcl\":\"¡\",\"iff\":\"⇔\",\"ifr\":\"𝔦\",\"Ifr\":\"ℑ\",\"Igrave\":\"Ì\",\"igrave\":\"ì\",\"ii\":\"ⅈ\",\"iiiint\":\"⨌\",\"iiint\":\"∭\",\"iinfin\":\"⧜\",\"iiota\":\"℩\",\"IJlig\":\"IJ\",\"ijlig\":\"ij\",\"Imacr\":\"Ī\",\"imacr\":\"ī\",\"image\":\"ℑ\",\"ImaginaryI\":\"ⅈ\",\"imagline\":\"ℐ\",\"imagpart\":\"ℑ\",\"imath\":\"ı\",\"Im\":\"ℑ\",\"imof\":\"⊷\",\"imped\":\"Ƶ\",\"Implies\":\"⇒\",\"incare\":\"℅\",\"in\":\"∈\",\"infin\":\"∞\",\"infintie\":\"⧝\",\"inodot\":\"ı\",\"intcal\":\"⊺\",\"int\":\"∫\",\"Int\":\"∬\",\"integers\":\"ℤ\",\"Integral\":\"∫\",\"intercal\":\"⊺\",\"Intersection\":\"⋂\",\"intlarhk\":\"⨗\",\"intprod\":\"⨼\",\"InvisibleComma\":\"\",\"InvisibleTimes\":\"\",\"IOcy\":\"Ё\",\"iocy\":\"ё\",\"Iogon\":\"Į\",\"iogon\":\"į\",\"Iopf\":\"𝕀\",\"iopf\":\"𝕚\",\"Iota\":\"Ι\",\"iota\":\"ι\",\"iprod\":\"⨼\",\"iquest\":\"¿\",\"iscr\":\"𝒾\",\"Iscr\":\"ℐ\",\"isin\":\"∈\",\"isindot\":\"⋵\",\"isinE\":\"⋹\",\"isins\":\"⋴\",\"isinsv\":\"⋳\",\"isinv\":\"∈\",\"it\":\"\",\"Itilde\":\"Ĩ\",\"itilde\":\"ĩ\",\"Iukcy\":\"І\",\"iukcy\":\"і\",\"Iuml\":\"Ï\",\"iuml\":\"ï\",\"Jcirc\":\"Ĵ\",\"jcirc\":\"ĵ\",\"Jcy\":\"Й\",\"jcy\":\"й\",\"Jfr\":\"𝔍\",\"jfr\":\"𝔧\",\"jmath\":\"ȷ\",\"Jopf\":\"𝕁\",\"jopf\":\"𝕛\",\"Jscr\":\"𝒥\",\"jscr\":\"𝒿\",\"Jsercy\":\"Ј\",\"jsercy\":\"ј\",\"Jukcy\":\"Є\",\"jukcy\":\"є\",\"Kappa\":\"Κ\",\"kappa\":\"κ\",\"kappav\":\"ϰ\",\"Kcedil\":\"Ķ\",\"kcedil\":\"ķ\",\"Kcy\":\"К\",\"kcy\":\"к\",\"Kfr\":\"𝔎\",\"kfr\":\"𝔨\",\"kgreen\":\"ĸ\",\"KHcy\":\"Х\",\"khcy\":\"х\",\"KJcy\":\"Ќ\",\"kjcy\":\"ќ\",\"Kopf\":\"𝕂\",\"kopf\":\"𝕜\",\"Kscr\":\"𝒦\",\"kscr\":\"𝓀\",\"lAarr\":\"⇚\",\"Lacute\":\"Ĺ\",\"lacute\":\"ĺ\",\"laemptyv\":\"⦴\",\"lagran\":\"ℒ\",\"Lambda\":\"Λ\",\"lambda\":\"λ\",\"lang\":\"⟨\",\"Lang\":\"⟪\",\"langd\":\"⦑\",\"langle\":\"⟨\",\"lap\":\"⪅\",\"Laplacetrf\":\"ℒ\",\"laquo\":\"«\",\"larrb\":\"⇤\",\"larrbfs\":\"⤟\",\"larr\":\"←\",\"Larr\":\"↞\",\"lArr\":\"⇐\",\"larrfs\":\"⤝\",\"larrhk\":\"↩\",\"larrlp\":\"↫\",\"larrpl\":\"⤹\",\"larrsim\":\"⥳\",\"larrtl\":\"↢\",\"latail\":\"⤙\",\"lAtail\":\"⤛\",\"lat\":\"⪫\",\"late\":\"⪭\",\"lates\":\"⪭︀\",\"lbarr\":\"⤌\",\"lBarr\":\"⤎\",\"lbbrk\":\"❲\",\"lbrace\":\"{\",\"lbrack\":\"[\",\"lbrke\":\"⦋\",\"lbrksld\":\"⦏\",\"lbrkslu\":\"⦍\",\"Lcaron\":\"Ľ\",\"lcaron\":\"ľ\",\"Lcedil\":\"Ļ\",\"lcedil\":\"ļ\",\"lceil\":\"⌈\",\"lcub\":\"{\",\"Lcy\":\"Л\",\"lcy\":\"л\",\"ldca\":\"⤶\",\"ldquo\":\"“\",\"ldquor\":\"„\",\"ldrdhar\":\"⥧\",\"ldrushar\":\"⥋\",\"ldsh\":\"↲\",\"le\":\"≤\",\"lE\":\"≦\",\"LeftAngleBracket\":\"⟨\",\"LeftArrowBar\":\"⇤\",\"leftarrow\":\"←\",\"LeftArrow\":\"←\",\"Leftarrow\":\"⇐\",\"LeftArrowRightArrow\":\"⇆\",\"leftarrowtail\":\"↢\",\"LeftCeiling\":\"⌈\",\"LeftDoubleBracket\":\"⟦\",\"LeftDownTeeVector\":\"⥡\",\"LeftDownVectorBar\":\"⥙\",\"LeftDownVector\":\"⇃\",\"LeftFloor\":\"⌊\",\"leftharpoondown\":\"↽\",\"leftharpoonup\":\"↼\",\"leftleftarrows\":\"⇇\",\"leftrightarrow\":\"↔\",\"LeftRightArrow\":\"↔\",\"Leftrightarrow\":\"⇔\",\"leftrightarrows\":\"⇆\",\"leftrightharpoons\":\"⇋\",\"leftrightsquigarrow\":\"↭\",\"LeftRightVector\":\"⥎\",\"LeftTeeArrow\":\"↤\",\"LeftTee\":\"⊣\",\"LeftTeeVector\":\"⥚\",\"leftthreetimes\":\"⋋\",\"LeftTriangleBar\":\"⧏\",\"LeftTriangle\":\"⊲\",\"LeftTriangleEqual\":\"⊴\",\"LeftUpDownVector\":\"⥑\",\"LeftUpTeeVector\":\"⥠\",\"LeftUpVectorBar\":\"⥘\",\"LeftUpVector\":\"↿\",\"LeftVectorBar\":\"⥒\",\"LeftVector\":\"↼\",\"lEg\":\"⪋\",\"leg\":\"⋚\",\"leq\":\"≤\",\"leqq\":\"≦\",\"leqslant\":\"⩽\",\"lescc\":\"⪨\",\"les\":\"⩽\",\"lesdot\":\"⩿\",\"lesdoto\":\"⪁\",\"lesdotor\":\"⪃\",\"lesg\":\"⋚︀\",\"lesges\":\"⪓\",\"lessapprox\":\"⪅\",\"lessdot\":\"⋖\",\"lesseqgtr\":\"⋚\",\"lesseqqgtr\":\"⪋\",\"LessEqualGreater\":\"⋚\",\"LessFullEqual\":\"≦\",\"LessGreater\":\"≶\",\"lessgtr\":\"≶\",\"LessLess\":\"⪡\",\"lesssim\":\"≲\",\"LessSlantEqual\":\"⩽\",\"LessTilde\":\"≲\",\"lfisht\":\"⥼\",\"lfloor\":\"⌊\",\"Lfr\":\"𝔏\",\"lfr\":\"𝔩\",\"lg\":\"≶\",\"lgE\":\"⪑\",\"lHar\":\"⥢\",\"lhard\":\"↽\",\"lharu\":\"↼\",\"lharul\":\"⥪\",\"lhblk\":\"▄\",\"LJcy\":\"Љ\",\"ljcy\":\"љ\",\"llarr\":\"⇇\",\"ll\":\"≪\",\"Ll\":\"⋘\",\"llcorner\":\"⌞\",\"Lleftarrow\":\"⇚\",\"llhard\":\"⥫\",\"lltri\":\"◺\",\"Lmidot\":\"Ŀ\",\"lmidot\":\"ŀ\",\"lmoustache\":\"⎰\",\"lmoust\":\"⎰\",\"lnap\":\"⪉\",\"lnapprox\":\"⪉\",\"lne\":\"⪇\",\"lnE\":\"≨\",\"lneq\":\"⪇\",\"lneqq\":\"≨\",\"lnsim\":\"⋦\",\"loang\":\"⟬\",\"loarr\":\"⇽\",\"lobrk\":\"⟦\",\"longleftarrow\":\"⟵\",\"LongLeftArrow\":\"⟵\",\"Longleftarrow\":\"⟸\",\"longleftrightarrow\":\"⟷\",\"LongLeftRightArrow\":\"⟷\",\"Longleftrightarrow\":\"⟺\",\"longmapsto\":\"⟼\",\"longrightarrow\":\"⟶\",\"LongRightArrow\":\"⟶\",\"Longrightarrow\":\"⟹\",\"looparrowleft\":\"↫\",\"looparrowright\":\"↬\",\"lopar\":\"⦅\",\"Lopf\":\"𝕃\",\"lopf\":\"𝕝\",\"loplus\":\"⨭\",\"lotimes\":\"⨴\",\"lowast\":\"∗\",\"lowbar\":\"_\",\"LowerLeftArrow\":\"↙\",\"LowerRightArrow\":\"↘\",\"loz\":\"◊\",\"lozenge\":\"◊\",\"lozf\":\"⧫\",\"lpar\":\"(\",\"lparlt\":\"⦓\",\"lrarr\":\"⇆\",\"lrcorner\":\"⌟\",\"lrhar\":\"⇋\",\"lrhard\":\"⥭\",\"lrm\":\"\",\"lrtri\":\"⊿\",\"lsaquo\":\"‹\",\"lscr\":\"𝓁\",\"Lscr\":\"ℒ\",\"lsh\":\"↰\",\"Lsh\":\"↰\",\"lsim\":\"≲\",\"lsime\":\"⪍\",\"lsimg\":\"⪏\",\"lsqb\":\"[\",\"lsquo\":\"‘\",\"lsquor\":\"‚\",\"Lstrok\":\"Ł\",\"lstrok\":\"ł\",\"ltcc\":\"⪦\",\"ltcir\":\"⩹\",\"lt\":\"<\",\"LT\":\"<\",\"Lt\":\"≪\",\"ltdot\":\"⋖\",\"lthree\":\"⋋\",\"ltimes\":\"⋉\",\"ltlarr\":\"⥶\",\"ltquest\":\"⩻\",\"ltri\":\"◃\",\"ltrie\":\"⊴\",\"ltrif\":\"◂\",\"ltrPar\":\"⦖\",\"lurdshar\":\"⥊\",\"luruhar\":\"⥦\",\"lvertneqq\":\"≨︀\",\"lvnE\":\"≨︀\",\"macr\":\"¯\",\"male\":\"♂\",\"malt\":\"✠\",\"maltese\":\"✠\",\"Map\":\"⤅\",\"map\":\"↦\",\"mapsto\":\"↦\",\"mapstodown\":\"↧\",\"mapstoleft\":\"↤\",\"mapstoup\":\"↥\",\"marker\":\"▮\",\"mcomma\":\"⨩\",\"Mcy\":\"М\",\"mcy\":\"м\",\"mdash\":\"—\",\"mDDot\":\"∺\",\"measuredangle\":\"∡\",\"MediumSpace\":\" \",\"Mellintrf\":\"ℳ\",\"Mfr\":\"𝔐\",\"mfr\":\"𝔪\",\"mho\":\"℧\",\"micro\":\"µ\",\"midast\":\"*\",\"midcir\":\"⫰\",\"mid\":\"∣\",\"middot\":\"·\",\"minusb\":\"⊟\",\"minus\":\"−\",\"minusd\":\"∸\",\"minusdu\":\"⨪\",\"MinusPlus\":\"∓\",\"mlcp\":\"⫛\",\"mldr\":\"…\",\"mnplus\":\"∓\",\"models\":\"⊧\",\"Mopf\":\"𝕄\",\"mopf\":\"𝕞\",\"mp\":\"∓\",\"mscr\":\"𝓂\",\"Mscr\":\"ℳ\",\"mstpos\":\"∾\",\"Mu\":\"Μ\",\"mu\":\"μ\",\"multimap\":\"⊸\",\"mumap\":\"⊸\",\"nabla\":\"∇\",\"Nacute\":\"Ń\",\"nacute\":\"ń\",\"nang\":\"∠⃒\",\"nap\":\"≉\",\"napE\":\"⩰̸\",\"napid\":\"≋̸\",\"napos\":\"ʼn\",\"napprox\":\"≉\",\"natural\":\"♮\",\"naturals\":\"ℕ\",\"natur\":\"♮\",\"nbsp\":\" \",\"nbump\":\"≎̸\",\"nbumpe\":\"≏̸\",\"ncap\":\"⩃\",\"Ncaron\":\"Ň\",\"ncaron\":\"ň\",\"Ncedil\":\"Ņ\",\"ncedil\":\"ņ\",\"ncong\":\"≇\",\"ncongdot\":\"⩭̸\",\"ncup\":\"⩂\",\"Ncy\":\"Н\",\"ncy\":\"н\",\"ndash\":\"–\",\"nearhk\":\"⤤\",\"nearr\":\"↗\",\"neArr\":\"⇗\",\"nearrow\":\"↗\",\"ne\":\"≠\",\"nedot\":\"≐̸\",\"NegativeMediumSpace\":\"\",\"NegativeThickSpace\":\"\",\"NegativeThinSpace\":\"\",\"NegativeVeryThinSpace\":\"\",\"nequiv\":\"≢\",\"nesear\":\"⤨\",\"nesim\":\"≂̸\",\"NestedGreaterGreater\":\"≫\",\"NestedLessLess\":\"≪\",\"NewLine\":\"\\n\",\"nexist\":\"∄\",\"nexists\":\"∄\",\"Nfr\":\"𝔑\",\"nfr\":\"𝔫\",\"ngE\":\"≧̸\",\"nge\":\"≱\",\"ngeq\":\"≱\",\"ngeqq\":\"≧̸\",\"ngeqslant\":\"⩾̸\",\"nges\":\"⩾̸\",\"nGg\":\"⋙̸\",\"ngsim\":\"≵\",\"nGt\":\"≫⃒\",\"ngt\":\"≯\",\"ngtr\":\"≯\",\"nGtv\":\"≫̸\",\"nharr\":\"↮\",\"nhArr\":\"⇎\",\"nhpar\":\"⫲\",\"ni\":\"∋\",\"nis\":\"⋼\",\"nisd\":\"⋺\",\"niv\":\"∋\",\"NJcy\":\"Њ\",\"njcy\":\"њ\",\"nlarr\":\"↚\",\"nlArr\":\"⇍\",\"nldr\":\"‥\",\"nlE\":\"≦̸\",\"nle\":\"≰\",\"nleftarrow\":\"↚\",\"nLeftarrow\":\"⇍\",\"nleftrightarrow\":\"↮\",\"nLeftrightarrow\":\"⇎\",\"nleq\":\"≰\",\"nleqq\":\"≦̸\",\"nleqslant\":\"⩽̸\",\"nles\":\"⩽̸\",\"nless\":\"≮\",\"nLl\":\"⋘̸\",\"nlsim\":\"≴\",\"nLt\":\"≪⃒\",\"nlt\":\"≮\",\"nltri\":\"⋪\",\"nltrie\":\"⋬\",\"nLtv\":\"≪̸\",\"nmid\":\"∤\",\"NoBreak\":\"\",\"NonBreakingSpace\":\" \",\"nopf\":\"𝕟\",\"Nopf\":\"ℕ\",\"Not\":\"⫬\",\"not\":\"¬\",\"NotCongruent\":\"≢\",\"NotCupCap\":\"≭\",\"NotDoubleVerticalBar\":\"∦\",\"NotElement\":\"∉\",\"NotEqual\":\"≠\",\"NotEqualTilde\":\"≂̸\",\"NotExists\":\"∄\",\"NotGreater\":\"≯\",\"NotGreaterEqual\":\"≱\",\"NotGreaterFullEqual\":\"≧̸\",\"NotGreaterGreater\":\"≫̸\",\"NotGreaterLess\":\"≹\",\"NotGreaterSlantEqual\":\"⩾̸\",\"NotGreaterTilde\":\"≵\",\"NotHumpDownHump\":\"≎̸\",\"NotHumpEqual\":\"≏̸\",\"notin\":\"∉\",\"notindot\":\"⋵̸\",\"notinE\":\"⋹̸\",\"notinva\":\"∉\",\"notinvb\":\"⋷\",\"notinvc\":\"⋶\",\"NotLeftTriangleBar\":\"⧏̸\",\"NotLeftTriangle\":\"⋪\",\"NotLeftTriangleEqual\":\"⋬\",\"NotLess\":\"≮\",\"NotLessEqual\":\"≰\",\"NotLessGreater\":\"≸\",\"NotLessLess\":\"≪̸\",\"NotLessSlantEqual\":\"⩽̸\",\"NotLessTilde\":\"≴\",\"NotNestedGreaterGreater\":\"⪢̸\",\"NotNestedLessLess\":\"⪡̸\",\"notni\":\"∌\",\"notniva\":\"∌\",\"notnivb\":\"⋾\",\"notnivc\":\"⋽\",\"NotPrecedes\":\"⊀\",\"NotPrecedesEqual\":\"⪯̸\",\"NotPrecedesSlantEqual\":\"⋠\",\"NotReverseElement\":\"∌\",\"NotRightTriangleBar\":\"⧐̸\",\"NotRightTriangle\":\"⋫\",\"NotRightTriangleEqual\":\"⋭\",\"NotSquareSubset\":\"⊏̸\",\"NotSquareSubsetEqual\":\"⋢\",\"NotSquareSuperset\":\"⊐̸\",\"NotSquareSupersetEqual\":\"⋣\",\"NotSubset\":\"⊂⃒\",\"NotSubsetEqual\":\"⊈\",\"NotSucceeds\":\"⊁\",\"NotSucceedsEqual\":\"⪰̸\",\"NotSucceedsSlantEqual\":\"⋡\",\"NotSucceedsTilde\":\"≿̸\",\"NotSuperset\":\"⊃⃒\",\"NotSupersetEqual\":\"⊉\",\"NotTilde\":\"≁\",\"NotTildeEqual\":\"≄\",\"NotTildeFullEqual\":\"≇\",\"NotTildeTilde\":\"≉\",\"NotVerticalBar\":\"∤\",\"nparallel\":\"∦\",\"npar\":\"∦\",\"nparsl\":\"⫽⃥\",\"npart\":\"∂̸\",\"npolint\":\"⨔\",\"npr\":\"⊀\",\"nprcue\":\"⋠\",\"nprec\":\"⊀\",\"npreceq\":\"⪯̸\",\"npre\":\"⪯̸\",\"nrarrc\":\"⤳̸\",\"nrarr\":\"↛\",\"nrArr\":\"⇏\",\"nrarrw\":\"↝̸\",\"nrightarrow\":\"↛\",\"nRightarrow\":\"⇏\",\"nrtri\":\"⋫\",\"nrtrie\":\"⋭\",\"nsc\":\"⊁\",\"nsccue\":\"⋡\",\"nsce\":\"⪰̸\",\"Nscr\":\"𝒩\",\"nscr\":\"𝓃\",\"nshortmid\":\"∤\",\"nshortparallel\":\"∦\",\"nsim\":\"≁\",\"nsime\":\"≄\",\"nsimeq\":\"≄\",\"nsmid\":\"∤\",\"nspar\":\"∦\",\"nsqsube\":\"⋢\",\"nsqsupe\":\"⋣\",\"nsub\":\"⊄\",\"nsubE\":\"⫅̸\",\"nsube\":\"⊈\",\"nsubset\":\"⊂⃒\",\"nsubseteq\":\"⊈\",\"nsubseteqq\":\"⫅̸\",\"nsucc\":\"⊁\",\"nsucceq\":\"⪰̸\",\"nsup\":\"⊅\",\"nsupE\":\"⫆̸\",\"nsupe\":\"⊉\",\"nsupset\":\"⊃⃒\",\"nsupseteq\":\"⊉\",\"nsupseteqq\":\"⫆̸\",\"ntgl\":\"≹\",\"Ntilde\":\"Ñ\",\"ntilde\":\"ñ\",\"ntlg\":\"≸\",\"ntriangleleft\":\"⋪\",\"ntrianglelefteq\":\"⋬\",\"ntriangleright\":\"⋫\",\"ntrianglerighteq\":\"⋭\",\"Nu\":\"Ν\",\"nu\":\"ν\",\"num\":\"#\",\"numero\":\"№\",\"numsp\":\" \",\"nvap\":\"≍⃒\",\"nvdash\":\"⊬\",\"nvDash\":\"⊭\",\"nVdash\":\"⊮\",\"nVDash\":\"⊯\",\"nvge\":\"≥⃒\",\"nvgt\":\">⃒\",\"nvHarr\":\"⤄\",\"nvinfin\":\"⧞\",\"nvlArr\":\"⤂\",\"nvle\":\"≤⃒\",\"nvlt\":\"<⃒\",\"nvltrie\":\"⊴⃒\",\"nvrArr\":\"⤃\",\"nvrtrie\":\"⊵⃒\",\"nvsim\":\"∼⃒\",\"nwarhk\":\"⤣\",\"nwarr\":\"↖\",\"nwArr\":\"⇖\",\"nwarrow\":\"↖\",\"nwnear\":\"⤧\",\"Oacute\":\"Ó\",\"oacute\":\"ó\",\"oast\":\"⊛\",\"Ocirc\":\"Ô\",\"ocirc\":\"ô\",\"ocir\":\"⊚\",\"Ocy\":\"О\",\"ocy\":\"о\",\"odash\":\"⊝\",\"Odblac\":\"Ő\",\"odblac\":\"ő\",\"odiv\":\"⨸\",\"odot\":\"⊙\",\"odsold\":\"⦼\",\"OElig\":\"Œ\",\"oelig\":\"œ\",\"ofcir\":\"⦿\",\"Ofr\":\"𝔒\",\"ofr\":\"𝔬\",\"ogon\":\"˛\",\"Ograve\":\"Ò\",\"ograve\":\"ò\",\"ogt\":\"⧁\",\"ohbar\":\"⦵\",\"ohm\":\"Ω\",\"oint\":\"∮\",\"olarr\":\"↺\",\"olcir\":\"⦾\",\"olcross\":\"⦻\",\"oline\":\"‾\",\"olt\":\"⧀\",\"Omacr\":\"Ō\",\"omacr\":\"ō\",\"Omega\":\"Ω\",\"omega\":\"ω\",\"Omicron\":\"Ο\",\"omicron\":\"ο\",\"omid\":\"⦶\",\"ominus\":\"⊖\",\"Oopf\":\"𝕆\",\"oopf\":\"𝕠\",\"opar\":\"⦷\",\"OpenCurlyDoubleQuote\":\"“\",\"OpenCurlyQuote\":\"‘\",\"operp\":\"⦹\",\"oplus\":\"⊕\",\"orarr\":\"↻\",\"Or\":\"⩔\",\"or\":\"∨\",\"ord\":\"⩝\",\"order\":\"ℴ\",\"orderof\":\"ℴ\",\"ordf\":\"ª\",\"ordm\":\"º\",\"origof\":\"⊶\",\"oror\":\"⩖\",\"orslope\":\"⩗\",\"orv\":\"⩛\",\"oS\":\"Ⓢ\",\"Oscr\":\"𝒪\",\"oscr\":\"ℴ\",\"Oslash\":\"Ø\",\"oslash\":\"ø\",\"osol\":\"⊘\",\"Otilde\":\"Õ\",\"otilde\":\"õ\",\"otimesas\":\"⨶\",\"Otimes\":\"⨷\",\"otimes\":\"⊗\",\"Ouml\":\"Ö\",\"ouml\":\"ö\",\"ovbar\":\"⌽\",\"OverBar\":\"‾\",\"OverBrace\":\"⏞\",\"OverBracket\":\"⎴\",\"OverParenthesis\":\"⏜\",\"para\":\"¶\",\"parallel\":\"∥\",\"par\":\"∥\",\"parsim\":\"⫳\",\"parsl\":\"⫽\",\"part\":\"∂\",\"PartialD\":\"∂\",\"Pcy\":\"П\",\"pcy\":\"п\",\"percnt\":\"%\",\"period\":\".\",\"permil\":\"‰\",\"perp\":\"⊥\",\"pertenk\":\"‱\",\"Pfr\":\"𝔓\",\"pfr\":\"𝔭\",\"Phi\":\"Φ\",\"phi\":\"φ\",\"phiv\":\"ϕ\",\"phmmat\":\"ℳ\",\"phone\":\"☎\",\"Pi\":\"Π\",\"pi\":\"π\",\"pitchfork\":\"⋔\",\"piv\":\"ϖ\",\"planck\":\"ℏ\",\"planckh\":\"ℎ\",\"plankv\":\"ℏ\",\"plusacir\":\"⨣\",\"plusb\":\"⊞\",\"pluscir\":\"⨢\",\"plus\":\"+\",\"plusdo\":\"∔\",\"plusdu\":\"⨥\",\"pluse\":\"⩲\",\"PlusMinus\":\"±\",\"plusmn\":\"±\",\"plussim\":\"⨦\",\"plustwo\":\"⨧\",\"pm\":\"±\",\"Poincareplane\":\"ℌ\",\"pointint\":\"⨕\",\"popf\":\"𝕡\",\"Popf\":\"ℙ\",\"pound\":\"£\",\"prap\":\"⪷\",\"Pr\":\"⪻\",\"pr\":\"≺\",\"prcue\":\"≼\",\"precapprox\":\"⪷\",\"prec\":\"≺\",\"preccurlyeq\":\"≼\",\"Precedes\":\"≺\",\"PrecedesEqual\":\"⪯\",\"PrecedesSlantEqual\":\"≼\",\"PrecedesTilde\":\"≾\",\"preceq\":\"⪯\",\"precnapprox\":\"⪹\",\"precneqq\":\"⪵\",\"precnsim\":\"⋨\",\"pre\":\"⪯\",\"prE\":\"⪳\",\"precsim\":\"≾\",\"prime\":\"′\",\"Prime\":\"″\",\"primes\":\"ℙ\",\"prnap\":\"⪹\",\"prnE\":\"⪵\",\"prnsim\":\"⋨\",\"prod\":\"∏\",\"Product\":\"∏\",\"profalar\":\"⌮\",\"profline\":\"⌒\",\"profsurf\":\"⌓\",\"prop\":\"∝\",\"Proportional\":\"∝\",\"Proportion\":\"∷\",\"propto\":\"∝\",\"prsim\":\"≾\",\"prurel\":\"⊰\",\"Pscr\":\"𝒫\",\"pscr\":\"𝓅\",\"Psi\":\"Ψ\",\"psi\":\"ψ\",\"puncsp\":\" \",\"Qfr\":\"𝔔\",\"qfr\":\"𝔮\",\"qint\":\"⨌\",\"qopf\":\"𝕢\",\"Qopf\":\"ℚ\",\"qprime\":\"⁗\",\"Qscr\":\"𝒬\",\"qscr\":\"𝓆\",\"quaternions\":\"ℍ\",\"quatint\":\"⨖\",\"quest\":\"?\",\"questeq\":\"≟\",\"quot\":\"\\\"\",\"QUOT\":\"\\\"\",\"rAarr\":\"⇛\",\"race\":\"∽̱\",\"Racute\":\"Ŕ\",\"racute\":\"ŕ\",\"radic\":\"√\",\"raemptyv\":\"⦳\",\"rang\":\"⟩\",\"Rang\":\"⟫\",\"rangd\":\"⦒\",\"range\":\"⦥\",\"rangle\":\"⟩\",\"raquo\":\"»\",\"rarrap\":\"⥵\",\"rarrb\":\"⇥\",\"rarrbfs\":\"⤠\",\"rarrc\":\"⤳\",\"rarr\":\"→\",\"Rarr\":\"↠\",\"rArr\":\"⇒\",\"rarrfs\":\"⤞\",\"rarrhk\":\"↪\",\"rarrlp\":\"↬\",\"rarrpl\":\"⥅\",\"rarrsim\":\"⥴\",\"Rarrtl\":\"⤖\",\"rarrtl\":\"↣\",\"rarrw\":\"↝\",\"ratail\":\"⤚\",\"rAtail\":\"⤜\",\"ratio\":\"∶\",\"rationals\":\"ℚ\",\"rbarr\":\"⤍\",\"rBarr\":\"⤏\",\"RBarr\":\"⤐\",\"rbbrk\":\"❳\",\"rbrace\":\"}\",\"rbrack\":\"]\",\"rbrke\":\"⦌\",\"rbrksld\":\"⦎\",\"rbrkslu\":\"⦐\",\"Rcaron\":\"Ř\",\"rcaron\":\"ř\",\"Rcedil\":\"Ŗ\",\"rcedil\":\"ŗ\",\"rceil\":\"⌉\",\"rcub\":\"}\",\"Rcy\":\"Р\",\"rcy\":\"р\",\"rdca\":\"⤷\",\"rdldhar\":\"⥩\",\"rdquo\":\"”\",\"rdquor\":\"”\",\"rdsh\":\"↳\",\"real\":\"ℜ\",\"realine\":\"ℛ\",\"realpart\":\"ℜ\",\"reals\":\"ℝ\",\"Re\":\"ℜ\",\"rect\":\"▭\",\"reg\":\"®\",\"REG\":\"®\",\"ReverseElement\":\"∋\",\"ReverseEquilibrium\":\"⇋\",\"ReverseUpEquilibrium\":\"⥯\",\"rfisht\":\"⥽\",\"rfloor\":\"⌋\",\"rfr\":\"𝔯\",\"Rfr\":\"ℜ\",\"rHar\":\"⥤\",\"rhard\":\"⇁\",\"rharu\":\"⇀\",\"rharul\":\"⥬\",\"Rho\":\"Ρ\",\"rho\":\"ρ\",\"rhov\":\"ϱ\",\"RightAngleBracket\":\"⟩\",\"RightArrowBar\":\"⇥\",\"rightarrow\":\"→\",\"RightArrow\":\"→\",\"Rightarrow\":\"⇒\",\"RightArrowLeftArrow\":\"⇄\",\"rightarrowtail\":\"↣\",\"RightCeiling\":\"⌉\",\"RightDoubleBracket\":\"⟧\",\"RightDownTeeVector\":\"⥝\",\"RightDownVectorBar\":\"⥕\",\"RightDownVector\":\"⇂\",\"RightFloor\":\"⌋\",\"rightharpoondown\":\"⇁\",\"rightharpoonup\":\"⇀\",\"rightleftarrows\":\"⇄\",\"rightleftharpoons\":\"⇌\",\"rightrightarrows\":\"⇉\",\"rightsquigarrow\":\"↝\",\"RightTeeArrow\":\"↦\",\"RightTee\":\"⊢\",\"RightTeeVector\":\"⥛\",\"rightthreetimes\":\"⋌\",\"RightTriangleBar\":\"⧐\",\"RightTriangle\":\"⊳\",\"RightTriangleEqual\":\"⊵\",\"RightUpDownVector\":\"⥏\",\"RightUpTeeVector\":\"⥜\",\"RightUpVectorBar\":\"⥔\",\"RightUpVector\":\"↾\",\"RightVectorBar\":\"⥓\",\"RightVector\":\"⇀\",\"ring\":\"˚\",\"risingdotseq\":\"≓\",\"rlarr\":\"⇄\",\"rlhar\":\"⇌\",\"rlm\":\"\",\"rmoustache\":\"⎱\",\"rmoust\":\"⎱\",\"rnmid\":\"⫮\",\"roang\":\"⟭\",\"roarr\":\"⇾\",\"robrk\":\"⟧\",\"ropar\":\"⦆\",\"ropf\":\"𝕣\",\"Ropf\":\"ℝ\",\"roplus\":\"⨮\",\"rotimes\":\"⨵\",\"RoundImplies\":\"⥰\",\"rpar\":\")\",\"rpargt\":\"⦔\",\"rppolint\":\"⨒\",\"rrarr\":\"⇉\",\"Rrightarrow\":\"⇛\",\"rsaquo\":\"›\",\"rscr\":\"𝓇\",\"Rscr\":\"ℛ\",\"rsh\":\"↱\",\"Rsh\":\"↱\",\"rsqb\":\"]\",\"rsquo\":\"’\",\"rsquor\":\"’\",\"rthree\":\"⋌\",\"rtimes\":\"⋊\",\"rtri\":\"▹\",\"rtrie\":\"⊵\",\"rtrif\":\"▸\",\"rtriltri\":\"⧎\",\"RuleDelayed\":\"⧴\",\"ruluhar\":\"⥨\",\"rx\":\"℞\",\"Sacute\":\"Ś\",\"sacute\":\"ś\",\"sbquo\":\"‚\",\"scap\":\"⪸\",\"Scaron\":\"Š\",\"scaron\":\"š\",\"Sc\":\"⪼\",\"sc\":\"≻\",\"sccue\":\"≽\",\"sce\":\"⪰\",\"scE\":\"⪴\",\"Scedil\":\"Ş\",\"scedil\":\"ş\",\"Scirc\":\"Ŝ\",\"scirc\":\"ŝ\",\"scnap\":\"⪺\",\"scnE\":\"⪶\",\"scnsim\":\"⋩\",\"scpolint\":\"⨓\",\"scsim\":\"≿\",\"Scy\":\"С\",\"scy\":\"с\",\"sdotb\":\"⊡\",\"sdot\":\"⋅\",\"sdote\":\"⩦\",\"searhk\":\"⤥\",\"searr\":\"↘\",\"seArr\":\"⇘\",\"searrow\":\"↘\",\"sect\":\"§\",\"semi\":\";\",\"seswar\":\"⤩\",\"setminus\":\"∖\",\"setmn\":\"∖\",\"sext\":\"✶\",\"Sfr\":\"𝔖\",\"sfr\":\"𝔰\",\"sfrown\":\"⌢\",\"sharp\":\"♯\",\"SHCHcy\":\"Щ\",\"shchcy\":\"щ\",\"SHcy\":\"Ш\",\"shcy\":\"ш\",\"ShortDownArrow\":\"↓\",\"ShortLeftArrow\":\"←\",\"shortmid\":\"∣\",\"shortparallel\":\"∥\",\"ShortRightArrow\":\"→\",\"ShortUpArrow\":\"↑\",\"shy\":\"\",\"Sigma\":\"Σ\",\"sigma\":\"σ\",\"sigmaf\":\"ς\",\"sigmav\":\"ς\",\"sim\":\"∼\",\"simdot\":\"⩪\",\"sime\":\"≃\",\"simeq\":\"≃\",\"simg\":\"⪞\",\"simgE\":\"⪠\",\"siml\":\"⪝\",\"simlE\":\"⪟\",\"simne\":\"≆\",\"simplus\":\"⨤\",\"simrarr\":\"⥲\",\"slarr\":\"←\",\"SmallCircle\":\"∘\",\"smallsetminus\":\"∖\",\"smashp\":\"⨳\",\"smeparsl\":\"⧤\",\"smid\":\"∣\",\"smile\":\"⌣\",\"smt\":\"⪪\",\"smte\":\"⪬\",\"smtes\":\"⪬︀\",\"SOFTcy\":\"Ь\",\"softcy\":\"ь\",\"solbar\":\"⌿\",\"solb\":\"⧄\",\"sol\":\"/\",\"Sopf\":\"𝕊\",\"sopf\":\"𝕤\",\"spades\":\"♠\",\"spadesuit\":\"♠\",\"spar\":\"∥\",\"sqcap\":\"⊓\",\"sqcaps\":\"⊓︀\",\"sqcup\":\"⊔\",\"sqcups\":\"⊔︀\",\"Sqrt\":\"√\",\"sqsub\":\"⊏\",\"sqsube\":\"⊑\",\"sqsubset\":\"⊏\",\"sqsubseteq\":\"⊑\",\"sqsup\":\"⊐\",\"sqsupe\":\"⊒\",\"sqsupset\":\"⊐\",\"sqsupseteq\":\"⊒\",\"square\":\"□\",\"Square\":\"□\",\"SquareIntersection\":\"⊓\",\"SquareSubset\":\"⊏\",\"SquareSubsetEqual\":\"⊑\",\"SquareSuperset\":\"⊐\",\"SquareSupersetEqual\":\"⊒\",\"SquareUnion\":\"⊔\",\"squarf\":\"▪\",\"squ\":\"□\",\"squf\":\"▪\",\"srarr\":\"→\",\"Sscr\":\"𝒮\",\"sscr\":\"𝓈\",\"ssetmn\":\"∖\",\"ssmile\":\"⌣\",\"sstarf\":\"⋆\",\"Star\":\"⋆\",\"star\":\"☆\",\"starf\":\"★\",\"straightepsilon\":\"ϵ\",\"straightphi\":\"ϕ\",\"strns\":\"¯\",\"sub\":\"⊂\",\"Sub\":\"⋐\",\"subdot\":\"⪽\",\"subE\":\"⫅\",\"sube\":\"⊆\",\"subedot\":\"⫃\",\"submult\":\"⫁\",\"subnE\":\"⫋\",\"subne\":\"⊊\",\"subplus\":\"⪿\",\"subrarr\":\"⥹\",\"subset\":\"⊂\",\"Subset\":\"⋐\",\"subseteq\":\"⊆\",\"subseteqq\":\"⫅\",\"SubsetEqual\":\"⊆\",\"subsetneq\":\"⊊\",\"subsetneqq\":\"⫋\",\"subsim\":\"⫇\",\"subsub\":\"⫕\",\"subsup\":\"⫓\",\"succapprox\":\"⪸\",\"succ\":\"≻\",\"succcurlyeq\":\"≽\",\"Succeeds\":\"≻\",\"SucceedsEqual\":\"⪰\",\"SucceedsSlantEqual\":\"≽\",\"SucceedsTilde\":\"≿\",\"succeq\":\"⪰\",\"succnapprox\":\"⪺\",\"succneqq\":\"⪶\",\"succnsim\":\"⋩\",\"succsim\":\"≿\",\"SuchThat\":\"∋\",\"sum\":\"∑\",\"Sum\":\"∑\",\"sung\":\"♪\",\"sup1\":\"¹\",\"sup2\":\"²\",\"sup3\":\"³\",\"sup\":\"⊃\",\"Sup\":\"⋑\",\"supdot\":\"⪾\",\"supdsub\":\"⫘\",\"supE\":\"⫆\",\"supe\":\"⊇\",\"supedot\":\"⫄\",\"Superset\":\"⊃\",\"SupersetEqual\":\"⊇\",\"suphsol\":\"⟉\",\"suphsub\":\"⫗\",\"suplarr\":\"⥻\",\"supmult\":\"⫂\",\"supnE\":\"⫌\",\"supne\":\"⊋\",\"supplus\":\"⫀\",\"supset\":\"⊃\",\"Supset\":\"⋑\",\"supseteq\":\"⊇\",\"supseteqq\":\"⫆\",\"supsetneq\":\"⊋\",\"supsetneqq\":\"⫌\",\"supsim\":\"⫈\",\"supsub\":\"⫔\",\"supsup\":\"⫖\",\"swarhk\":\"⤦\",\"swarr\":\"↙\",\"swArr\":\"⇙\",\"swarrow\":\"↙\",\"swnwar\":\"⤪\",\"szlig\":\"ß\",\"Tab\":\"\\t\",\"target\":\"⌖\",\"Tau\":\"Τ\",\"tau\":\"τ\",\"tbrk\":\"⎴\",\"Tcaron\":\"Ť\",\"tcaron\":\"ť\",\"Tcedil\":\"Ţ\",\"tcedil\":\"ţ\",\"Tcy\":\"Т\",\"tcy\":\"т\",\"tdot\":\"⃛\",\"telrec\":\"⌕\",\"Tfr\":\"𝔗\",\"tfr\":\"𝔱\",\"there4\":\"∴\",\"therefore\":\"∴\",\"Therefore\":\"∴\",\"Theta\":\"Θ\",\"theta\":\"θ\",\"thetasym\":\"ϑ\",\"thetav\":\"ϑ\",\"thickapprox\":\"≈\",\"thicksim\":\"∼\",\"ThickSpace\":\" \",\"ThinSpace\":\" \",\"thinsp\":\" \",\"thkap\":\"≈\",\"thksim\":\"∼\",\"THORN\":\"Þ\",\"thorn\":\"þ\",\"tilde\":\"˜\",\"Tilde\":\"∼\",\"TildeEqual\":\"≃\",\"TildeFullEqual\":\"≅\",\"TildeTilde\":\"≈\",\"timesbar\":\"⨱\",\"timesb\":\"⊠\",\"times\":\"×\",\"timesd\":\"⨰\",\"tint\":\"∭\",\"toea\":\"⤨\",\"topbot\":\"⌶\",\"topcir\":\"⫱\",\"top\":\"⊤\",\"Topf\":\"𝕋\",\"topf\":\"𝕥\",\"topfork\":\"⫚\",\"tosa\":\"⤩\",\"tprime\":\"‴\",\"trade\":\"™\",\"TRADE\":\"™\",\"triangle\":\"▵\",\"triangledown\":\"▿\",\"triangleleft\":\"◃\",\"trianglelefteq\":\"⊴\",\"triangleq\":\"≜\",\"triangleright\":\"▹\",\"trianglerighteq\":\"⊵\",\"tridot\":\"◬\",\"trie\":\"≜\",\"triminus\":\"⨺\",\"TripleDot\":\"⃛\",\"triplus\":\"⨹\",\"trisb\":\"⧍\",\"tritime\":\"⨻\",\"trpezium\":\"⏢\",\"Tscr\":\"𝒯\",\"tscr\":\"𝓉\",\"TScy\":\"Ц\",\"tscy\":\"ц\",\"TSHcy\":\"Ћ\",\"tshcy\":\"ћ\",\"Tstrok\":\"Ŧ\",\"tstrok\":\"ŧ\",\"twixt\":\"≬\",\"twoheadleftarrow\":\"↞\",\"twoheadrightarrow\":\"↠\",\"Uacute\":\"Ú\",\"uacute\":\"ú\",\"uarr\":\"↑\",\"Uarr\":\"↟\",\"uArr\":\"⇑\",\"Uarrocir\":\"⥉\",\"Ubrcy\":\"Ў\",\"ubrcy\":\"ў\",\"Ubreve\":\"Ŭ\",\"ubreve\":\"ŭ\",\"Ucirc\":\"Û\",\"ucirc\":\"û\",\"Ucy\":\"У\",\"ucy\":\"у\",\"udarr\":\"⇅\",\"Udblac\":\"Ű\",\"udblac\":\"ű\",\"udhar\":\"⥮\",\"ufisht\":\"⥾\",\"Ufr\":\"𝔘\",\"ufr\":\"𝔲\",\"Ugrave\":\"Ù\",\"ugrave\":\"ù\",\"uHar\":\"⥣\",\"uharl\":\"↿\",\"uharr\":\"↾\",\"uhblk\":\"▀\",\"ulcorn\":\"⌜\",\"ulcorner\":\"⌜\",\"ulcrop\":\"⌏\",\"ultri\":\"◸\",\"Umacr\":\"Ū\",\"umacr\":\"ū\",\"uml\":\"¨\",\"UnderBar\":\"_\",\"UnderBrace\":\"⏟\",\"UnderBracket\":\"⎵\",\"UnderParenthesis\":\"⏝\",\"Union\":\"⋃\",\"UnionPlus\":\"⊎\",\"Uogon\":\"Ų\",\"uogon\":\"ų\",\"Uopf\":\"𝕌\",\"uopf\":\"𝕦\",\"UpArrowBar\":\"⤒\",\"uparrow\":\"↑\",\"UpArrow\":\"↑\",\"Uparrow\":\"⇑\",\"UpArrowDownArrow\":\"⇅\",\"updownarrow\":\"↕\",\"UpDownArrow\":\"↕\",\"Updownarrow\":\"⇕\",\"UpEquilibrium\":\"⥮\",\"upharpoonleft\":\"↿\",\"upharpoonright\":\"↾\",\"uplus\":\"⊎\",\"UpperLeftArrow\":\"↖\",\"UpperRightArrow\":\"↗\",\"upsi\":\"υ\",\"Upsi\":\"ϒ\",\"upsih\":\"ϒ\",\"Upsilon\":\"Υ\",\"upsilon\":\"υ\",\"UpTeeArrow\":\"↥\",\"UpTee\":\"⊥\",\"upuparrows\":\"⇈\",\"urcorn\":\"⌝\",\"urcorner\":\"⌝\",\"urcrop\":\"⌎\",\"Uring\":\"Ů\",\"uring\":\"ů\",\"urtri\":\"◹\",\"Uscr\":\"𝒰\",\"uscr\":\"𝓊\",\"utdot\":\"⋰\",\"Utilde\":\"Ũ\",\"utilde\":\"ũ\",\"utri\":\"▵\",\"utrif\":\"▴\",\"uuarr\":\"⇈\",\"Uuml\":\"Ü\",\"uuml\":\"ü\",\"uwangle\":\"⦧\",\"vangrt\":\"⦜\",\"varepsilon\":\"ϵ\",\"varkappa\":\"ϰ\",\"varnothing\":\"∅\",\"varphi\":\"ϕ\",\"varpi\":\"ϖ\",\"varpropto\":\"∝\",\"varr\":\"↕\",\"vArr\":\"⇕\",\"varrho\":\"ϱ\",\"varsigma\":\"ς\",\"varsubsetneq\":\"⊊︀\",\"varsubsetneqq\":\"⫋︀\",\"varsupsetneq\":\"⊋︀\",\"varsupsetneqq\":\"⫌︀\",\"vartheta\":\"ϑ\",\"vartriangleleft\":\"⊲\",\"vartriangleright\":\"⊳\",\"vBar\":\"⫨\",\"Vbar\":\"⫫\",\"vBarv\":\"⫩\",\"Vcy\":\"В\",\"vcy\":\"в\",\"vdash\":\"⊢\",\"vDash\":\"⊨\",\"Vdash\":\"⊩\",\"VDash\":\"⊫\",\"Vdashl\":\"⫦\",\"veebar\":\"⊻\",\"vee\":\"∨\",\"Vee\":\"⋁\",\"veeeq\":\"≚\",\"vellip\":\"⋮\",\"verbar\":\"|\",\"Verbar\":\"‖\",\"vert\":\"|\",\"Vert\":\"‖\",\"VerticalBar\":\"∣\",\"VerticalLine\":\"|\",\"VerticalSeparator\":\"❘\",\"VerticalTilde\":\"≀\",\"VeryThinSpace\":\" \",\"Vfr\":\"𝔙\",\"vfr\":\"𝔳\",\"vltri\":\"⊲\",\"vnsub\":\"⊂⃒\",\"vnsup\":\"⊃⃒\",\"Vopf\":\"𝕍\",\"vopf\":\"𝕧\",\"vprop\":\"∝\",\"vrtri\":\"⊳\",\"Vscr\":\"𝒱\",\"vscr\":\"𝓋\",\"vsubnE\":\"⫋︀\",\"vsubne\":\"⊊︀\",\"vsupnE\":\"⫌︀\",\"vsupne\":\"⊋︀\",\"Vvdash\":\"⊪\",\"vzigzag\":\"⦚\",\"Wcirc\":\"Ŵ\",\"wcirc\":\"ŵ\",\"wedbar\":\"⩟\",\"wedge\":\"∧\",\"Wedge\":\"⋀\",\"wedgeq\":\"≙\",\"weierp\":\"℘\",\"Wfr\":\"𝔚\",\"wfr\":\"𝔴\",\"Wopf\":\"𝕎\",\"wopf\":\"𝕨\",\"wp\":\"℘\",\"wr\":\"≀\",\"wreath\":\"≀\",\"Wscr\":\"𝒲\",\"wscr\":\"𝓌\",\"xcap\":\"⋂\",\"xcirc\":\"◯\",\"xcup\":\"⋃\",\"xdtri\":\"▽\",\"Xfr\":\"𝔛\",\"xfr\":\"𝔵\",\"xharr\":\"⟷\",\"xhArr\":\"⟺\",\"Xi\":\"Ξ\",\"xi\":\"ξ\",\"xlarr\":\"⟵\",\"xlArr\":\"⟸\",\"xmap\":\"⟼\",\"xnis\":\"⋻\",\"xodot\":\"⨀\",\"Xopf\":\"𝕏\",\"xopf\":\"𝕩\",\"xoplus\":\"⨁\",\"xotime\":\"⨂\",\"xrarr\":\"⟶\",\"xrArr\":\"⟹\",\"Xscr\":\"𝒳\",\"xscr\":\"𝓍\",\"xsqcup\":\"⨆\",\"xuplus\":\"⨄\",\"xutri\":\"△\",\"xvee\":\"⋁\",\"xwedge\":\"⋀\",\"Yacute\":\"Ý\",\"yacute\":\"ý\",\"YAcy\":\"Я\",\"yacy\":\"я\",\"Ycirc\":\"Ŷ\",\"ycirc\":\"ŷ\",\"Ycy\":\"Ы\",\"ycy\":\"ы\",\"yen\":\"¥\",\"Yfr\":\"𝔜\",\"yfr\":\"𝔶\",\"YIcy\":\"Ї\",\"yicy\":\"ї\",\"Yopf\":\"𝕐\",\"yopf\":\"𝕪\",\"Yscr\":\"𝒴\",\"yscr\":\"𝓎\",\"YUcy\":\"Ю\",\"yucy\":\"ю\",\"yuml\":\"ÿ\",\"Yuml\":\"Ÿ\",\"Zacute\":\"Ź\",\"zacute\":\"ź\",\"Zcaron\":\"Ž\",\"zcaron\":\"ž\",\"Zcy\":\"З\",\"zcy\":\"з\",\"Zdot\":\"Ż\",\"zdot\":\"ż\",\"zeetrf\":\"ℨ\",\"ZeroWidthSpace\":\"\",\"Zeta\":\"Ζ\",\"zeta\":\"ζ\",\"zfr\":\"𝔷\",\"Zfr\":\"ℨ\",\"ZHcy\":\"Ж\",\"zhcy\":\"ж\",\"zigrarr\":\"⇝\",\"zopf\":\"𝕫\",\"Zopf\":\"ℤ\",\"Zscr\":\"𝒵\",\"zscr\":\"𝓏\",\"zwj\":\"\",\"zwnj\":\"\"}");
13419 /***/ (function(module, exports) {
13421 module.exports=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4E\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/
13425 /***/ (function(module, exports, __webpack_require__) {
13431 module.exports.encode = __webpack_require__(47);
13432 module.exports.decode = __webpack_require__(48);
13433 module.exports.format = __webpack_require__(49);
13434 module.exports.parse = __webpack_require__(50);
13439 /***/ (function(module, exports, __webpack_require__) {
13446 var encodeCache = {};
13449 // Create a lookup array where anything but characters in `chars` string
13450 // and alphanumeric chars is percent-encoded.
13452 function getEncodeCache(exclude) {
13453 var i, ch, cache = encodeCache[exclude];
13454 if (cache) { return cache; }
13456 cache = encodeCache[exclude] = [];
13458 for (i = 0; i < 128; i++) {
13459 ch = String.fromCharCode(i);
13461 if (/^[0-9a-z]$/i.test(ch)) {
13462 // always allow unencoded alphanumeric characters
13465 cache.push('%' + ('0' + i.toString(16).toUpperCase()).slice(-2));
13469 for (i = 0; i < exclude.length; i++) {
13470 cache[exclude.charCodeAt(i)] = exclude[i];
13477 // Encode unsafe characters with percent-encoding, skipping already
13478 // encoded sequences.
13480 // - string - string to encode
13481 // - exclude - list of characters to ignore (in addition to a-zA-Z0-9)
13482 // - keepEscaped - don't encode '%' in a correct escape sequence (default: true)
13484 function encode(string, exclude, keepEscaped) {
13485 var i, l, code, nextCode, cache,
13488 if (typeof exclude !== 'string') {
13489 // encode(string, keepEscaped)
13490 keepEscaped = exclude;
13491 exclude = encode.defaultChars;
13494 if (typeof keepEscaped === 'undefined') {
13495 keepEscaped = true;
13498 cache = getEncodeCache(exclude);
13500 for (i = 0, l = string.length; i < l; i++) {
13501 code = string.charCodeAt(i);
13503 if (keepEscaped && code === 0x25 /* % */ && i + 2 < l) {
13504 if (/^[0-9a-f]{2}$/i.test(string.slice(i + 1, i + 3))) {
13505 result += string.slice(i, i + 3);
13512 result += cache[code];
13516 if (code >= 0xD800 && code <= 0xDFFF) {
13517 if (code >= 0xD800 && code <= 0xDBFF && i + 1 < l) {
13518 nextCode = string.charCodeAt(i + 1);
13519 if (nextCode >= 0xDC00 && nextCode <= 0xDFFF) {
13520 result += encodeURIComponent(string[i] + string[i + 1]);
13525 result += '%EF%BF%BD';
13529 result += encodeURIComponent(string[i]);
13535 encode.defaultChars = ";/?:@&=+$,-_.!~*'()#";
13536 encode.componentChars = "-_.!~*'()";
13539 module.exports = encode;
13544 /***/ (function(module, exports, __webpack_require__) {
13551 /* eslint-disable no-bitwise */
13553 var decodeCache = {};
13555 function getDecodeCache(exclude) {
13556 var i, ch, cache = decodeCache[exclude];
13557 if (cache) { return cache; }
13559 cache = decodeCache[exclude] = [];
13561 for (i = 0; i < 128; i++) {
13562 ch = String.fromCharCode(i);
13566 for (i = 0; i < exclude.length; i++) {
13567 ch = exclude.charCodeAt(i);
13568 cache[ch] = '%' + ('0' + ch.toString(16).toUpperCase()).slice(-2);
13575 // Decode percent-encoded string.
13577 function decode(string, exclude) {
13580 if (typeof exclude !== 'string') {
13581 exclude = decode.defaultChars;
13584 cache = getDecodeCache(exclude);
13586 return string.replace(/(%[a-f0-9]{2})+/gi, function(seq) {
13587 var i, l, b1, b2, b3, b4, chr,
13590 for (i = 0, l = seq.length; i < l; i += 3) {
13591 b1 = parseInt(seq.slice(i + 1, i + 3), 16);
13594 result += cache[b1];
13598 if ((b1 & 0xE0) === 0xC0 && (i + 3 < l)) {
13599 // 110xxxxx 10xxxxxx
13600 b2 = parseInt(seq.slice(i + 4, i + 6), 16);
13602 if ((b2 & 0xC0) === 0x80) {
13603 chr = ((b1 << 6) & 0x7C0) | (b2 & 0x3F);
13606 result += '\ufffd\ufffd';
13608 result += String.fromCharCode(chr);
13616 if ((b1 & 0xF0) === 0xE0 && (i + 6 < l)) {
13617 // 1110xxxx 10xxxxxx 10xxxxxx
13618 b2 = parseInt(seq.slice(i + 4, i + 6), 16);
13619 b3 = parseInt(seq.slice(i + 7, i + 9), 16);
13621 if ((b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {
13622 chr = ((b1 << 12) & 0xF000) | ((b2 << 6) & 0xFC0) | (b3 & 0x3F);
13624 if (chr < 0x800 || (chr >= 0xD800 && chr <= 0xDFFF)) {
13625 result += '\ufffd\ufffd\ufffd';
13627 result += String.fromCharCode(chr);
13635 if ((b1 & 0xF8) === 0xF0 && (i + 9 < l)) {
13636 // 111110xx 10xxxxxx 10xxxxxx 10xxxxxx
13637 b2 = parseInt(seq.slice(i + 4, i + 6), 16);
13638 b3 = parseInt(seq.slice(i + 7, i + 9), 16);
13639 b4 = parseInt(seq.slice(i + 10, i + 12), 16);
13641 if ((b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80 && (b4 & 0xC0) === 0x80) {
13642 chr = ((b1 << 18) & 0x1C0000) | ((b2 << 12) & 0x3F000) | ((b3 << 6) & 0xFC0) | (b4 & 0x3F);
13644 if (chr < 0x10000 || chr > 0x10FFFF) {
13645 result += '\ufffd\ufffd\ufffd\ufffd';
13648 result += String.fromCharCode(0xD800 + (chr >> 10), 0xDC00 + (chr & 0x3FF));
13656 result += '\ufffd';
13664 decode.defaultChars = ';/?:@&=+$,#';
13665 decode.componentChars = '';
13668 module.exports = decode;
13673 /***/ (function(module, exports, __webpack_require__) {
13680 module.exports = function format(url) {
13683 result += url.protocol || '';
13684 result += url.slashes ? '//' : '';
13685 result += url.auth ? url.auth + '@' : '';
13687 if (url.hostname && url.hostname.indexOf(':') !== -1) {
13689 result += '[' + url.hostname + ']';
13691 result += url.hostname || '';
13694 result += url.port ? ':' + url.port : '';
13695 result += url.pathname || '';
13696 result += url.search || '';
13697 result += url.hash || '';
13705 /***/ (function(module, exports, __webpack_require__) {
13708 // Copyright Joyent, Inc. and other Node contributors.
13710 // Permission is hereby granted, free of charge, to any person obtaining a
13711 // copy of this software and associated documentation files (the
13712 // "Software"), to deal in the Software without restriction, including
13713 // without limitation the rights to use, copy, modify, merge, publish,
13714 // distribute, sublicense, and/or sell copies of the Software, and to permit
13715 // persons to whom the Software is furnished to do so, subject to the
13716 // following conditions:
13718 // The above copyright notice and this permission notice shall be included
13719 // in all copies or substantial portions of the Software.
13721 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
13722 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
13723 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
13724 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
13725 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
13726 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
13727 // USE OR OTHER DEALINGS IN THE SOFTWARE.
13732 // Changes from joyent/node:
13734 // 1. No leading slash in paths,
13735 // e.g. in `url.parse('http://foo?bar')` pathname is ``, not `/`
13737 // 2. Backslashes are not replaced with slashes,
13738 // so `http:\\example.org\` is treated like a relative path
13740 // 3. Trailing colon is treated like a part of the path,
13741 // i.e. in `http://example.org:foo` pathname is `:foo`
13743 // 4. Nothing is URL-encoded in the resulting object,
13744 // (in joyent/node some chars in auth and paths are encoded)
13746 // 5. `url.parse()` does not have `parseQueryString` argument
13748 // 6. Removed extraneous result properties: `host`, `path`, `query`, etc.,
13749 // which can be constructed using other parts of the url.
13754 this.protocol = null;
13755 this.slashes = null;
13758 this.hostname = null;
13760 this.search = null;
13761 this.pathname = null;
13764 // Reference: RFC 3986, RFC 1808, RFC 2396
13766 // define these here so at least they only have to be
13767 // compiled once on the first module load.
13768 var protocolPattern = /^([a-z0-9.+-]+:)/i,
13769 portPattern = /:[0-9]*$/,
13771 // Special case for a simple path URL
13772 simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,
13774 // RFC 2396: characters reserved for delimiting URLs.
13775 // We actually just auto-escape these.
13776 delims = [ '<', '>', '"', '`', ' ', '\r', '\n', '\t' ],
13778 // RFC 2396: characters not allowed for various reasons.
13779 unwise = [ '{', '}', '|', '\\', '^', '`' ].concat(delims),
13781 // Allowed by RFCs, but cause of XSS attacks. Always escape these.
13782 autoEscape = [ '\'' ].concat(unwise),
13783 // Characters that are never ever allowed in a hostname.
13784 // Note that any invalid chars are also handled, but these
13785 // are the ones that are *expected* to be seen, so we fast-path
13787 nonHostChars = [ '%', '/', '?', ';', '#' ].concat(autoEscape),
13788 hostEndingChars = [ '/', '?', '#' ],
13789 hostnameMaxLen = 255,
13790 hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/,
13791 hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/,
13792 // protocols that can allow "unsafe" and "unwise" chars.
13793 /* eslint-disable no-script-url */
13794 // protocols that never have a hostname.
13795 hostlessProtocol = {
13796 'javascript': true,
13797 'javascript:': true
13799 // protocols that always contain a // bit.
13800 slashedProtocol = {
13812 /* eslint-enable no-script-url */
13814 function urlParse(url, slashesDenoteHost) {
13815 if (url && url instanceof Url) { return url; }
13818 u.parse(url, slashesDenoteHost);
13822 Url.prototype.parse = function(url, slashesDenoteHost) {
13823 var i, l, lowerProto, hec, slashes,
13826 // trim before proceeding.
13827 // This is to support parse stuff like " http://foo.com \n"
13828 rest = rest.trim();
13830 if (!slashesDenoteHost && url.split('#').length === 1) {
13831 // Try fast path regexp
13832 var simplePath = simplePathPattern.exec(rest);
13834 this.pathname = simplePath[1];
13835 if (simplePath[2]) {
13836 this.search = simplePath[2];
13842 var proto = protocolPattern.exec(rest);
13845 lowerProto = proto.toLowerCase();
13846 this.protocol = proto;
13847 rest = rest.substr(proto.length);
13850 // figure out if it's got a host
13851 // user@server is *always* interpreted as a hostname, and url
13852 // resolution will treat //foo/bar as host=foo,path=bar because that's
13853 // how the browser resolves relative URLs.
13854 if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
13855 slashes = rest.substr(0, 2) === '//';
13856 if (slashes && !(proto && hostlessProtocol[proto])) {
13857 rest = rest.substr(2);
13858 this.slashes = true;
13862 if (!hostlessProtocol[proto] &&
13863 (slashes || (proto && !slashedProtocol[proto]))) {
13865 // there's a hostname.
13866 // the first instance of /, ?, ;, or # ends the host.
13868 // If there is an @ in the hostname, then non-host chars *are* allowed
13869 // to the left of the last @ sign, unless some host-ending character
13870 // comes *before* the @-sign.
13871 // URLs are obnoxious.
13874 // http://a@b@c/ => user:a@b host:c
13875 // http://a@b?@c => user:a host:c path:/?@c
13877 // v0.12 TODO(isaacs): This is not quite how Chrome does things.
13878 // Review our test case against browsers more comprehensively.
13880 // find the first instance of any hostEndingChars
13882 for (i = 0; i < hostEndingChars.length; i++) {
13883 hec = rest.indexOf(hostEndingChars[i]);
13884 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {
13889 // at this point, either we have an explicit point where the
13890 // auth portion cannot go past, or the last @ char is the decider.
13892 if (hostEnd === -1) {
13893 // atSign can be anywhere.
13894 atSign = rest.lastIndexOf('@');
13896 // atSign must be in auth portion.
13897 // http://a@b/c@d => host:b auth:a path:/c@d
13898 atSign = rest.lastIndexOf('@', hostEnd);
13901 // Now we have a portion which is definitely the auth.
13903 if (atSign !== -1) {
13904 auth = rest.slice(0, atSign);
13905 rest = rest.slice(atSign + 1);
13909 // the host is the remaining to the left of the first non-host char
13911 for (i = 0; i < nonHostChars.length; i++) {
13912 hec = rest.indexOf(nonHostChars[i]);
13913 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) {
13917 // if we still have not hit it, then the entire thing is a host.
13918 if (hostEnd === -1) {
13919 hostEnd = rest.length;
13922 if (rest[hostEnd - 1] === ':') { hostEnd--; }
13923 var host = rest.slice(0, hostEnd);
13924 rest = rest.slice(hostEnd);
13927 this.parseHost(host);
13929 // we've indicated that there is a hostname,
13930 // so even if it's empty, it has to be present.
13931 this.hostname = this.hostname || '';
13933 // if hostname begins with [ and ends with ]
13934 // assume that it's an IPv6 address.
13935 var ipv6Hostname = this.hostname[0] === '[' &&
13936 this.hostname[this.hostname.length - 1] === ']';
13938 // validate a little.
13939 if (!ipv6Hostname) {
13940 var hostparts = this.hostname.split(/\./);
13941 for (i = 0, l = hostparts.length; i < l; i++) {
13942 var part = hostparts[i];
13943 if (!part) { continue; }
13944 if (!part.match(hostnamePartPattern)) {
13946 for (var j = 0, k = part.length; j < k; j++) {
13947 if (part.charCodeAt(j) > 127) {
13948 // we replace non-ASCII char with a temporary placeholder
13949 // we need this to make sure size of hostname is not
13950 // broken by replacing non-ASCII by nothing
13953 newpart += part[j];
13956 // we test again with ASCII char only
13957 if (!newpart.match(hostnamePartPattern)) {
13958 var validParts = hostparts.slice(0, i);
13959 var notHost = hostparts.slice(i + 1);
13960 var bit = part.match(hostnamePartStart);
13962 validParts.push(bit[1]);
13963 notHost.unshift(bit[2]);
13965 if (notHost.length) {
13966 rest = notHost.join('.') + rest;
13968 this.hostname = validParts.join('.');
13975 if (this.hostname.length > hostnameMaxLen) {
13976 this.hostname = '';
13979 // strip [ and ] from the hostname
13980 // the host field still retains them, though
13981 if (ipv6Hostname) {
13982 this.hostname = this.hostname.substr(1, this.hostname.length - 2);
13986 // chop off from the tail first.
13987 var hash = rest.indexOf('#');
13989 // got a fragment string.
13990 this.hash = rest.substr(hash);
13991 rest = rest.slice(0, hash);
13993 var qm = rest.indexOf('?');
13995 this.search = rest.substr(qm);
13996 rest = rest.slice(0, qm);
13998 if (rest) { this.pathname = rest; }
13999 if (slashedProtocol[lowerProto] &&
14000 this.hostname && !this.pathname) {
14001 this.pathname = '';
14007 Url.prototype.parseHost = function(host) {
14008 var port = portPattern.exec(host);
14011 if (port !== ':') {
14012 this.port = port.substr(1);
14014 host = host.substr(0, host.length - port.length);
14016 if (host) { this.hostname = host; }
14019 module.exports = urlParse;
14024 /***/ (function(module, exports, __webpack_require__) {
14029 exports.Any = __webpack_require__(52);
14030 exports.Cc = __webpack_require__(53);
14031 exports.Cf = __webpack_require__(54);
14032 exports.P = __webpack_require__(45);
14033 exports.Z = __webpack_require__(55);
14038 /***/ (function(module, exports) {
14040 module.exports=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/
14044 /***/ (function(module, exports) {
14046 module.exports=/[\0-\x1F\x7F-\x9F]/
14050 /***/ (function(module, exports) {
14052 module.exports=/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/
14056 /***/ (function(module, exports) {
14058 module.exports=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/
14062 /***/ (function(module, exports, __webpack_require__) {
14065 // Just a shortcut for bulk export
14069 exports.parseLinkLabel = __webpack_require__(57);
14070 exports.parseLinkDestination = __webpack_require__(58);
14071 exports.parseLinkTitle = __webpack_require__(59);
14076 /***/ (function(module, exports, __webpack_require__) {
14079 // Parse link label
14081 // this function assumes that first character ("[") already matches;
14082 // returns the end of the label
14086 module.exports = function parseLinkLabel(state, start, disableNested) {
14087 var level, found, marker, prevPos,
14089 max = state.posMax,
14090 oldPos = state.pos;
14092 state.pos = start + 1;
14095 while (state.pos < max) {
14096 marker = state.src.charCodeAt(state.pos);
14097 if (marker === 0x5D /* ] */) {
14105 prevPos = state.pos;
14106 state.md.inline.skipToken(state);
14107 if (marker === 0x5B /* [ */) {
14108 if (prevPos === state.pos - 1) {
14109 // increase level if we find text `[`, which is not a part of any token
14111 } else if (disableNested) {
14112 state.pos = oldPos;
14119 labelEnd = state.pos;
14122 // restore old state
14123 state.pos = oldPos;
14131 /***/ (function(module, exports, __webpack_require__) {
14134 // Parse link destination
14139 var unescapeAll = __webpack_require__(42).unescapeAll;
14142 module.exports = function parseLinkDestination(str, pos, max) {
14153 if (str.charCodeAt(pos) === 0x3C /* < */) {
14155 while (pos < max) {
14156 code = str.charCodeAt(pos);
14157 if (code === 0x0A /* \n */) { return result; }
14158 if (code === 0x3E /* > */) {
14159 result.pos = pos + 1;
14160 result.str = unescapeAll(str.slice(start + 1, pos));
14164 if (code === 0x5C /* \ */ && pos + 1 < max) {
14176 // this should be ... } else { ... branch
14179 while (pos < max) {
14180 code = str.charCodeAt(pos);
14182 if (code === 0x20) { break; }
14184 // ascii control characters
14185 if (code < 0x20 || code === 0x7F) { break; }
14187 if (code === 0x5C /* \ */ && pos + 1 < max) {
14192 if (code === 0x28 /* ( */) {
14196 if (code === 0x29 /* ) */) {
14197 if (level === 0) { break; }
14204 if (start === pos) { return result; }
14205 if (level !== 0) { return result; }
14207 result.str = unescapeAll(str.slice(start, pos));
14208 result.lines = lines;
14217 /***/ (function(module, exports, __webpack_require__) {
14220 // Parse link title
14225 var unescapeAll = __webpack_require__(42).unescapeAll;
14228 module.exports = function parseLinkTitle(str, pos, max) {
14240 if (pos >= max) { return result; }
14242 marker = str.charCodeAt(pos);
14244 if (marker !== 0x22 /* " */ && marker !== 0x27 /* ' */ && marker !== 0x28 /* ( */) { return result; }
14248 // if opening marker is "(", switch it to closing marker ")"
14249 if (marker === 0x28) { marker = 0x29; }
14251 while (pos < max) {
14252 code = str.charCodeAt(pos);
14253 if (code === marker) {
14254 result.pos = pos + 1;
14255 result.lines = lines;
14256 result.str = unescapeAll(str.slice(start + 1, pos));
14259 } else if (code === 0x0A) {
14261 } else if (code === 0x5C /* \ */ && pos + 1 < max) {
14263 if (str.charCodeAt(pos) === 0x0A) {
14277 /***/ (function(module, exports, __webpack_require__) {
14283 * Generates HTML from parsed token stream. Each instance has independent
14284 * copy of rules. Those can be rewritten with ease. Also, you can add new
14285 * rules if you create plugin and adds new token types.
14290 var assign = __webpack_require__(42).assign;
14291 var unescapeAll = __webpack_require__(42).unescapeAll;
14292 var escapeHtml = __webpack_require__(42).escapeHtml;
14295 ////////////////////////////////////////////////////////////////////////////////
14297 var default_rules = {};
14300 default_rules.code_inline = function (tokens, idx, options, env, slf) {
14301 var token = tokens[idx];
14303 return '<code' + slf.renderAttrs(token) + '>' +
14304 escapeHtml(tokens[idx].content) +
14309 default_rules.code_block = function (tokens, idx, options, env, slf) {
14310 var token = tokens[idx];
14312 return '<pre' + slf.renderAttrs(token) + '><code>' +
14313 escapeHtml(tokens[idx].content) +
14318 default_rules.fence = function (tokens, idx, options, env, slf) {
14319 var token = tokens[idx],
14320 info = token.info ? unescapeAll(token.info).trim() : '',
14322 highlighted, i, tmpAttrs, tmpToken;
14325 langName = info.split(/\s+/g)[0];
14328 if (options.highlight) {
14329 highlighted = options.highlight(token.content, langName) || escapeHtml(token.content);
14331 highlighted = escapeHtml(token.content);
14334 if (highlighted.indexOf('<pre') === 0) {
14335 return highlighted + '\n';
14338 // If language exists, inject class gently, without modifying original token.
14339 // May be, one day we will add .clone() for token and simplify this part, but
14340 // now we prefer to keep things local.
14342 i = token.attrIndex('class');
14343 tmpAttrs = token.attrs ? token.attrs.slice() : [];
14346 tmpAttrs.push([ 'class', options.langPrefix + langName ]);
14348 tmpAttrs[i][1] += ' ' + options.langPrefix + langName;
14351 // Fake token just to render attributes
14356 return '<pre><code' + slf.renderAttrs(tmpToken) + '>'
14358 + '</code></pre>\n';
14362 return '<pre><code' + slf.renderAttrs(token) + '>'
14364 + '</code></pre>\n';
14368 default_rules.image = function (tokens, idx, options, env, slf) {
14369 var token = tokens[idx];
14371 // "alt" attr MUST be set, even if empty. Because it's mandatory and
14372 // should be placed on proper position for tests.
14374 // Replace content with actual value
14376 token.attrs[token.attrIndex('alt')][1] =
14377 slf.renderInlineAsText(token.children, options, env);
14379 return slf.renderToken(tokens, idx, options);
14383 default_rules.hardbreak = function (tokens, idx, options /*, env */) {
14384 return options.xhtmlOut ? '<br />\n' : '<br>\n';
14386 default_rules.softbreak = function (tokens, idx, options /*, env */) {
14387 return options.breaks ? (options.xhtmlOut ? '<br />\n' : '<br>\n') : '\n';
14391 default_rules.text = function (tokens, idx /*, options, env */) {
14392 return escapeHtml(tokens[idx].content);
14396 default_rules.html_block = function (tokens, idx /*, options, env */) {
14397 return tokens[idx].content;
14399 default_rules.html_inline = function (tokens, idx /*, options, env */) {
14400 return tokens[idx].content;
14407 * Creates new [[Renderer]] instance and fill [[Renderer#rules]] with defaults.
14409 function Renderer() {
14412 * Renderer#rules -> Object
14414 * Contains render rules for tokens. Can be updated and extended.
14419 * var md = require('markdown-it')();
14421 * md.renderer.rules.strong_open = function () { return '<b>'; };
14422 * md.renderer.rules.strong_close = function () { return '</b>'; };
14424 * var result = md.renderInline(...);
14427 * Each rule is called as independent static function with fixed signature:
14430 * function my_token_render(tokens, idx, options, env, renderer) {
14432 * return renderedHTML;
14436 * See [source code](https://github.com/markdown-it/markdown-it/blob/master/lib/renderer.js)
14437 * for more details and examples.
14439 this.rules = assign({}, default_rules);
14444 * Renderer.renderAttrs(token) -> String
14446 * Render token attributes to string.
14448 Renderer.prototype.renderAttrs = function renderAttrs(token) {
14451 if (!token.attrs) { return ''; }
14455 for (i = 0, l = token.attrs.length; i < l; i++) {
14456 result += ' ' + escapeHtml(token.attrs[i][0]) + '="' + escapeHtml(token.attrs[i][1]) + '"';
14464 * Renderer.renderToken(tokens, idx, options) -> String
14465 * - tokens (Array): list of tokens
14466 * - idx (Numbed): token index to render
14467 * - options (Object): params of parser instance
14469 * Default token renderer. Can be overriden by custom function
14470 * in [[Renderer#rules]].
14472 Renderer.prototype.renderToken = function renderToken(tokens, idx, options) {
14476 token = tokens[idx];
14478 // Tight list paragraphs
14479 if (token.hidden) {
14483 // Insert a newline between hidden paragraph and subsequent opening
14484 // block-level tag.
14486 // For example, here we should insert a newline before blockquote:
14490 if (token.block && token.nesting !== -1 && idx && tokens[idx - 1].hidden) {
14494 // Add token name, e.g. `<img`
14495 result += (token.nesting === -1 ? '</' : '<') + token.tag;
14497 // Encode attributes, e.g. `<img src="foo"`
14498 result += this.renderAttrs(token);
14500 // Add a slash for self-closing tags, e.g. `<img src="foo" /`
14501 if (token.nesting === 0 && options.xhtmlOut) {
14505 // Check if we need to add a newline after this tag
14509 if (token.nesting === 1) {
14510 if (idx + 1 < tokens.length) {
14511 nextToken = tokens[idx + 1];
14513 if (nextToken.type === 'inline' || nextToken.hidden) {
14514 // Block-level tag containing an inline tag.
14518 } else if (nextToken.nesting === -1 && nextToken.tag === token.tag) {
14519 // Opening tag + closing tag of the same type. E.g. `<li></li>`.
14527 result += needLf ? '>\n' : '>';
14534 * Renderer.renderInline(tokens, options, env) -> String
14535 * - tokens (Array): list on block tokens to renter
14536 * - options (Object): params of parser instance
14537 * - env (Object): additional data from parsed input (references, for example)
14539 * The same as [[Renderer.render]], but for single token of `inline` type.
14541 Renderer.prototype.renderInline = function (tokens, options, env) {
14544 rules = this.rules;
14546 for (var i = 0, len = tokens.length; i < len; i++) {
14547 type = tokens[i].type;
14549 if (typeof rules[type] !== 'undefined') {
14550 result += rules[type](tokens, i, options, env, this);
14552 result += this.renderToken(tokens, i, options);
14561 * Renderer.renderInlineAsText(tokens, options, env) -> String
14562 * - tokens (Array): list on block tokens to renter
14563 * - options (Object): params of parser instance
14564 * - env (Object): additional data from parsed input (references, for example)
14566 * Special kludge for image `alt` attributes to conform CommonMark spec.
14567 * Don't try to use it! Spec requires to show `alt` content with stripped markup,
14568 * instead of simple escaping.
14570 Renderer.prototype.renderInlineAsText = function (tokens, options, env) {
14573 for (var i = 0, len = tokens.length; i < len; i++) {
14574 if (tokens[i].type === 'text') {
14575 result += tokens[i].content;
14576 } else if (tokens[i].type === 'image') {
14577 result += this.renderInlineAsText(tokens[i].children, options, env);
14586 * Renderer.render(tokens, options, env) -> String
14587 * - tokens (Array): list on block tokens to renter
14588 * - options (Object): params of parser instance
14589 * - env (Object): additional data from parsed input (references, for example)
14591 * Takes token stream and generates HTML. Probably, you will never need to call
14592 * this method directly.
14594 Renderer.prototype.render = function (tokens, options, env) {
14597 rules = this.rules;
14599 for (i = 0, len = tokens.length; i < len; i++) {
14600 type = tokens[i].type;
14602 if (type === 'inline') {
14603 result += this.renderInline(tokens[i].children, options, env);
14604 } else if (typeof rules[type] !== 'undefined') {
14605 result += rules[tokens[i].type](tokens, i, options, env, this);
14607 result += this.renderToken(tokens, i, options, env);
14614 module.exports = Renderer;
14619 /***/ (function(module, exports, __webpack_require__) {
14625 * Top-level rules executor. Glues block/inline parsers and does intermediate
14631 var Ruler = __webpack_require__(62);
14635 [ 'normalize', __webpack_require__(63) ],
14636 [ 'block', __webpack_require__(64) ],
14637 [ 'inline', __webpack_require__(65) ],
14638 [ 'linkify', __webpack_require__(66) ],
14639 [ 'replacements', __webpack_require__(67) ],
14640 [ 'smartquotes', __webpack_require__(68) ]
14649 * Core#ruler -> Ruler
14651 * [[Ruler]] instance. Keep configuration of core rules.
14653 this.ruler = new Ruler();
14655 for (var i = 0; i < _rules.length; i++) {
14656 this.ruler.push(_rules[i][0], _rules[i][1]);
14662 * Core.process(state)
14664 * Executes core chain rules.
14666 Core.prototype.process = function (state) {
14669 rules = this.ruler.getRules('');
14671 for (i = 0, l = rules.length; i < l; i++) {
14676 Core.prototype.State = __webpack_require__(69);
14679 module.exports = Core;
14684 /***/ (function(module, exports, __webpack_require__) {
14690 * Helper class, used by [[MarkdownIt#core]], [[MarkdownIt#block]] and
14691 * [[MarkdownIt#inline]] to manage sequences of functions (rules):
14693 * - keep rules in defined order
14694 * - assign the name to each rule
14695 * - enable/disable rules
14696 * - add/replace rules
14697 * - allow assign rules to additional named chains (in the same)
14698 * - cacheing lists of active rules
14700 * You will not need use this class directly until write plugins. For simple
14701 * rules control use [[MarkdownIt.disable]], [[MarkdownIt.enable]] and
14702 * [[MarkdownIt.use]].
14711 // List of added rules. Each element is:
14715 // enabled: Boolean,
14717 // alt: [ name2, name3 ]
14720 this.__rules__ = [];
14722 // Cached rule chains.
14724 // First level - chain name, '' for default.
14725 // Second level - diginal anchor for fast filtering by charcodes.
14727 this.__cache__ = null;
14730 ////////////////////////////////////////////////////////////////////////////////
14731 // Helper methods, should not be used directly
14734 // Find rule index by name
14736 Ruler.prototype.__find__ = function (name) {
14737 for (var i = 0; i < this.__rules__.length; i++) {
14738 if (this.__rules__[i].name === name) {
14746 // Build rules lookup cache
14748 Ruler.prototype.__compile__ = function () {
14750 var chains = [ '' ];
14752 // collect unique names
14753 self.__rules__.forEach(function (rule) {
14754 if (!rule.enabled) { return; }
14756 rule.alt.forEach(function (altName) {
14757 if (chains.indexOf(altName) < 0) {
14758 chains.push(altName);
14763 self.__cache__ = {};
14765 chains.forEach(function (chain) {
14766 self.__cache__[chain] = [];
14767 self.__rules__.forEach(function (rule) {
14768 if (!rule.enabled) { return; }
14770 if (chain && rule.alt.indexOf(chain) < 0) { return; }
14772 self.__cache__[chain].push(rule.fn);
14779 * Ruler.at(name, fn [, options])
14780 * - name (String): rule name to replace.
14781 * - fn (Function): new rule function.
14782 * - options (Object): new rule options (not mandatory).
14784 * Replace rule by name with new function & options. Throws error if name not
14789 * - __alt__ - array with names of "alternate" chains.
14793 * Replace existing typographer replacement rule with new one:
14796 * var md = require('markdown-it')();
14798 * md.core.ruler.at('replacements', function replace(state) {
14803 Ruler.prototype.at = function (name, fn, options) {
14804 var index = this.__find__(name);
14805 var opt = options || {};
14807 if (index === -1) { throw new Error('Parser rule not found: ' + name); }
14809 this.__rules__[index].fn = fn;
14810 this.__rules__[index].alt = opt.alt || [];
14811 this.__cache__ = null;
14816 * Ruler.before(beforeName, ruleName, fn [, options])
14817 * - beforeName (String): new rule will be added before this one.
14818 * - ruleName (String): name of added rule.
14819 * - fn (Function): rule function.
14820 * - options (Object): rule options (not mandatory).
14822 * Add new rule to chain before one with given name. See also
14823 * [[Ruler.after]], [[Ruler.push]].
14827 * - __alt__ - array with names of "alternate" chains.
14832 * var md = require('markdown-it')();
14834 * md.block.ruler.before('paragraph', 'my_rule', function replace(state) {
14839 Ruler.prototype.before = function (beforeName, ruleName, fn, options) {
14840 var index = this.__find__(beforeName);
14841 var opt = options || {};
14843 if (index === -1) { throw new Error('Parser rule not found: ' + beforeName); }
14845 this.__rules__.splice(index, 0, {
14852 this.__cache__ = null;
14857 * Ruler.after(afterName, ruleName, fn [, options])
14858 * - afterName (String): new rule will be added after this one.
14859 * - ruleName (String): name of added rule.
14860 * - fn (Function): rule function.
14861 * - options (Object): rule options (not mandatory).
14863 * Add new rule to chain after one with given name. See also
14864 * [[Ruler.before]], [[Ruler.push]].
14868 * - __alt__ - array with names of "alternate" chains.
14873 * var md = require('markdown-it')();
14875 * md.inline.ruler.after('text', 'my_rule', function replace(state) {
14880 Ruler.prototype.after = function (afterName, ruleName, fn, options) {
14881 var index = this.__find__(afterName);
14882 var opt = options || {};
14884 if (index === -1) { throw new Error('Parser rule not found: ' + afterName); }
14886 this.__rules__.splice(index + 1, 0, {
14893 this.__cache__ = null;
14897 * Ruler.push(ruleName, fn [, options])
14898 * - ruleName (String): name of added rule.
14899 * - fn (Function): rule function.
14900 * - options (Object): rule options (not mandatory).
14902 * Push new rule to the end of chain. See also
14903 * [[Ruler.before]], [[Ruler.after]].
14907 * - __alt__ - array with names of "alternate" chains.
14912 * var md = require('markdown-it')();
14914 * md.core.ruler.push('my_rule', function replace(state) {
14919 Ruler.prototype.push = function (ruleName, fn, options) {
14920 var opt = options || {};
14922 this.__rules__.push({
14929 this.__cache__ = null;
14934 * Ruler.enable(list [, ignoreInvalid]) -> Array
14935 * - list (String|Array): list of rule names to enable.
14936 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
14938 * Enable rules with given names. If any rule name not found - throw Error.
14939 * Errors can be disabled by second param.
14941 * Returns list of found rule names (if no exception happened).
14943 * See also [[Ruler.disable]], [[Ruler.enableOnly]].
14945 Ruler.prototype.enable = function (list, ignoreInvalid) {
14946 if (!Array.isArray(list)) { list = [ list ]; }
14950 // Search by name and enable
14951 list.forEach(function (name) {
14952 var idx = this.__find__(name);
14955 if (ignoreInvalid) { return; }
14956 throw new Error('Rules manager: invalid rule name ' + name);
14958 this.__rules__[idx].enabled = true;
14962 this.__cache__ = null;
14968 * Ruler.enableOnly(list [, ignoreInvalid])
14969 * - list (String|Array): list of rule names to enable (whitelist).
14970 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
14972 * Enable rules with given names, and disable everything else. If any rule name
14973 * not found - throw Error. Errors can be disabled by second param.
14975 * See also [[Ruler.disable]], [[Ruler.enable]].
14977 Ruler.prototype.enableOnly = function (list, ignoreInvalid) {
14978 if (!Array.isArray(list)) { list = [ list ]; }
14980 this.__rules__.forEach(function (rule) { rule.enabled = false; });
14982 this.enable(list, ignoreInvalid);
14987 * Ruler.disable(list [, ignoreInvalid]) -> Array
14988 * - list (String|Array): list of rule names to disable.
14989 * - ignoreInvalid (Boolean): set `true` to ignore errors when rule not found.
14991 * Disable rules with given names. If any rule name not found - throw Error.
14992 * Errors can be disabled by second param.
14994 * Returns list of found rule names (if no exception happened).
14996 * See also [[Ruler.enable]], [[Ruler.enableOnly]].
14998 Ruler.prototype.disable = function (list, ignoreInvalid) {
14999 if (!Array.isArray(list)) { list = [ list ]; }
15003 // Search by name and disable
15004 list.forEach(function (name) {
15005 var idx = this.__find__(name);
15008 if (ignoreInvalid) { return; }
15009 throw new Error('Rules manager: invalid rule name ' + name);
15011 this.__rules__[idx].enabled = false;
15015 this.__cache__ = null;
15021 * Ruler.getRules(chainName) -> Array
15023 * Return array of active functions (rules) for given chain name. It analyzes
15024 * rules configuration, compiles caches if not exists and returns result.
15026 * Default chain name is `''` (empty string). It can't be skipped. That's
15027 * done intentionally, to keep signature monomorphic for high speed.
15029 Ruler.prototype.getRules = function (chainName) {
15030 if (this.__cache__ === null) {
15031 this.__compile__();
15034 // Chain can be empty, if rules disabled. But we still have to return Array.
15035 return this.__cache__[chainName] || [];
15038 module.exports = Ruler;
15043 /***/ (function(module, exports, __webpack_require__) {
15046 // Normalize input string
15051 // https://spec.commonmark.org/0.29/#line-ending
15052 var NEWLINES_RE = /\r\n?|\n/g;
15053 var NULL_RE = /\0/g;
15056 module.exports = function normalize(state) {
15059 // Normalize newlines
15060 str = state.src.replace(NEWLINES_RE, '\n');
15062 // Replace NULL characters
15063 str = str.replace(NULL_RE, '\uFFFD');
15071 /***/ (function(module, exports, __webpack_require__) {
15077 module.exports = function block(state) {
15080 if (state.inlineMode) {
15081 token = new state.Token('inline', '', 0);
15082 token.content = state.src;
15083 token.map = [ 0, 1 ];
15084 token.children = [];
15085 state.tokens.push(token);
15087 state.md.block.parse(state.src, state.md, state.env, state.tokens);
15094 /***/ (function(module, exports, __webpack_require__) {
15099 module.exports = function inline(state) {
15100 var tokens = state.tokens, tok, i, l;
15103 for (i = 0, l = tokens.length; i < l; i++) {
15105 if (tok.type === 'inline') {
15106 state.md.inline.parse(tok.content, state.md, state.env, tok.children);
15114 /***/ (function(module, exports, __webpack_require__) {
15117 // Replace link-like texts with link nodes.
15119 // Currently restricted by `md.validateLink()` to http/https/ftp
15124 var arrayReplaceAt = __webpack_require__(42).arrayReplaceAt;
15127 function isLinkOpen(str) {
15128 return /^<a[>\s]/i.test(str);
15130 function isLinkClose(str) {
15131 return /^<\/a\s*>/i.test(str);
15135 module.exports = function linkify(state) {
15136 var i, j, l, tokens, token, currentToken, nodes, ln, text, pos, lastPos,
15137 level, htmlLinkLevel, url, fullUrl, urlText,
15138 blockTokens = state.tokens,
15141 if (!state.md.options.linkify) { return; }
15143 for (j = 0, l = blockTokens.length; j < l; j++) {
15144 if (blockTokens[j].type !== 'inline' ||
15145 !state.md.linkify.pretest(blockTokens[j].content)) {
15149 tokens = blockTokens[j].children;
15153 // We scan from the end, to keep position when new tags added.
15154 // Use reversed logic in links start/end match
15155 for (i = tokens.length - 1; i >= 0; i--) {
15156 currentToken = tokens[i];
15158 // Skip content of markdown links
15159 if (currentToken.type === 'link_close') {
15161 while (tokens[i].level !== currentToken.level && tokens[i].type !== 'link_open') {
15167 // Skip content of html tag links
15168 if (currentToken.type === 'html_inline') {
15169 if (isLinkOpen(currentToken.content) && htmlLinkLevel > 0) {
15172 if (isLinkClose(currentToken.content)) {
15176 if (htmlLinkLevel > 0) { continue; }
15178 if (currentToken.type === 'text' && state.md.linkify.test(currentToken.content)) {
15180 text = currentToken.content;
15181 links = state.md.linkify.match(text);
15183 // Now split string to nodes
15185 level = currentToken.level;
15188 for (ln = 0; ln < links.length; ln++) {
15190 url = links[ln].url;
15191 fullUrl = state.md.normalizeLink(url);
15192 if (!state.md.validateLink(fullUrl)) { continue; }
15194 urlText = links[ln].text;
15196 // Linkifier might send raw hostnames like "example.com", where url
15197 // starts with domain name. So we prepend http:// in those cases,
15198 // and remove it afterwards.
15200 if (!links[ln].schema) {
15201 urlText = state.md.normalizeLinkText('http://' + urlText).replace(/^http:\/\//, '');
15202 } else if (links[ln].schema === 'mailto:' && !/^mailto:/i.test(urlText)) {
15203 urlText = state.md.normalizeLinkText('mailto:' + urlText).replace(/^mailto:/, '');
15205 urlText = state.md.normalizeLinkText(urlText);
15208 pos = links[ln].index;
15210 if (pos > lastPos) {
15211 token = new state.Token('text', '', 0);
15212 token.content = text.slice(lastPos, pos);
15213 token.level = level;
15217 token = new state.Token('link_open', 'a', 1);
15218 token.attrs = [ [ 'href', fullUrl ] ];
15219 token.level = level++;
15220 token.markup = 'linkify';
15221 token.info = 'auto';
15224 token = new state.Token('text', '', 0);
15225 token.content = urlText;
15226 token.level = level;
15229 token = new state.Token('link_close', 'a', -1);
15230 token.level = --level;
15231 token.markup = 'linkify';
15232 token.info = 'auto';
15235 lastPos = links[ln].lastIndex;
15237 if (lastPos < text.length) {
15238 token = new state.Token('text', '', 0);
15239 token.content = text.slice(lastPos);
15240 token.level = level;
15244 // replace current node
15245 blockTokens[j].children = tokens = arrayReplaceAt(tokens, i, nodes);
15254 /***/ (function(module, exports, __webpack_require__) {
15257 // Simple typographic replacements
15264 // ... → … (also ?.... → ?.., !.... → !..)
15265 // ???????? → ???, !!!!! → !!!, `,,` → `,`
15266 // -- → –, --- → —
15271 // - fractionals 1/2, 1/4, 3/4 -> ½, ¼, ¾
15272 // - miltiplication 2 x 4 -> 2 × 4
15274 var RARE_RE = /\+-|\.\.|\?\?\?\?|!!!!|,,|--/;
15276 // Workaround for phantomjs - need regex without /g flag,
15277 // or root check will fail every second time
15278 var SCOPED_ABBR_TEST_RE = /\((c|tm|r|p)\)/i;
15280 var SCOPED_ABBR_RE = /\((c|tm|r|p)\)/ig;
15281 var SCOPED_ABBR = {
15288 function replaceFn(match, name) {
15289 return SCOPED_ABBR[name.toLowerCase()];
15292 function replace_scoped(inlineTokens) {
15293 var i, token, inside_autolink = 0;
15295 for (i = inlineTokens.length - 1; i >= 0; i--) {
15296 token = inlineTokens[i];
15298 if (token.type === 'text' && !inside_autolink) {
15299 token.content = token.content.replace(SCOPED_ABBR_RE, replaceFn);
15302 if (token.type === 'link_open' && token.info === 'auto') {
15306 if (token.type === 'link_close' && token.info === 'auto') {
15312 function replace_rare(inlineTokens) {
15313 var i, token, inside_autolink = 0;
15315 for (i = inlineTokens.length - 1; i >= 0; i--) {
15316 token = inlineTokens[i];
15318 if (token.type === 'text' && !inside_autolink) {
15319 if (RARE_RE.test(token.content)) {
15320 token.content = token.content
15321 .replace(/\+-/g, '±')
15322 // .., ..., ....... -> …
15323 // but ?..... & !..... -> ?.. & !..
15324 .replace(/\.{2,}/g, '…').replace(/([?!])…/g, '$1..')
15325 .replace(/([?!]){4,}/g, '$1$1$1').replace(/,{2,}/g, ',')
15327 .replace(/(^|[^-])---([^-]|$)/mg, '$1\u2014$2')
15329 .replace(/(^|\s)--(\s|$)/mg, '$1\u2013$2')
15330 .replace(/(^|[^-\s])--([^-\s]|$)/mg, '$1\u2013$2');
15334 if (token.type === 'link_open' && token.info === 'auto') {
15338 if (token.type === 'link_close' && token.info === 'auto') {
15345 module.exports = function replace(state) {
15348 if (!state.md.options.typographer) { return; }
15350 for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
15352 if (state.tokens[blkIdx].type !== 'inline') { continue; }
15354 if (SCOPED_ABBR_TEST_RE.test(state.tokens[blkIdx].content)) {
15355 replace_scoped(state.tokens[blkIdx].children);
15358 if (RARE_RE.test(state.tokens[blkIdx].content)) {
15359 replace_rare(state.tokens[blkIdx].children);
15368 /***/ (function(module, exports, __webpack_require__) {
15371 // Convert straight quotation marks to typographic ones
15376 var isWhiteSpace = __webpack_require__(42).isWhiteSpace;
15377 var isPunctChar = __webpack_require__(42).isPunctChar;
15378 var isMdAsciiPunct = __webpack_require__(42).isMdAsciiPunct;
15380 var QUOTE_TEST_RE = /['"]/;
15381 var QUOTE_RE = /['"]/g;
15382 var APOSTROPHE = '\u2019'; /* ’ */
15385 function replaceAt(str, index, ch) {
15386 return str.substr(0, index) + ch + str.substr(index + 1);
15389 function process_inlines(tokens, state) {
15390 var i, token, text, t, pos, max, thisLevel, item, lastChar, nextChar,
15391 isLastPunctChar, isNextPunctChar, isLastWhiteSpace, isNextWhiteSpace,
15392 canOpen, canClose, j, isSingle, stack, openQuote, closeQuote;
15396 for (i = 0; i < tokens.length; i++) {
15399 thisLevel = tokens[i].level;
15401 for (j = stack.length - 1; j >= 0; j--) {
15402 if (stack[j].level <= thisLevel) { break; }
15404 stack.length = j + 1;
15406 if (token.type !== 'text') { continue; }
15408 text = token.content;
15412 /*eslint no-labels:0,block-scoped-var:0*/
15414 while (pos < max) {
15415 QUOTE_RE.lastIndex = pos;
15416 t = QUOTE_RE.exec(text);
15419 canOpen = canClose = true;
15421 isSingle = (t[0] === "'");
15423 // Find previous character,
15424 // default to space if it's the beginning of the line
15428 if (t.index - 1 >= 0) {
15429 lastChar = text.charCodeAt(t.index - 1);
15431 for (j = i - 1; j >= 0; j--) {
15432 if (tokens[j].type === 'softbreak' || tokens[j].type === 'hardbreak') break; // lastChar defaults to 0x20
15433 if (tokens[j].type !== 'text') continue;
15435 lastChar = tokens[j].content.charCodeAt(tokens[j].content.length - 1);
15440 // Find next character,
15441 // default to space if it's the end of the line
15446 nextChar = text.charCodeAt(pos);
15448 for (j = i + 1; j < tokens.length; j++) {
15449 if (tokens[j].type === 'softbreak' || tokens[j].type === 'hardbreak') break; // nextChar defaults to 0x20
15450 if (tokens[j].type !== 'text') continue;
15452 nextChar = tokens[j].content.charCodeAt(0);
15457 isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
15458 isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
15460 isLastWhiteSpace = isWhiteSpace(lastChar);
15461 isNextWhiteSpace = isWhiteSpace(nextChar);
15463 if (isNextWhiteSpace) {
15465 } else if (isNextPunctChar) {
15466 if (!(isLastWhiteSpace || isLastPunctChar)) {
15471 if (isLastWhiteSpace) {
15473 } else if (isLastPunctChar) {
15474 if (!(isNextWhiteSpace || isNextPunctChar)) {
15479 if (nextChar === 0x22 /* " */ && t[0] === '"') {
15480 if (lastChar >= 0x30 /* 0 */ && lastChar <= 0x39 /* 9 */) {
15481 // special case: 1"" - count first quote as an inch
15482 canClose = canOpen = false;
15486 if (canOpen && canClose) {
15487 // treat this as the middle of the word
15489 canClose = isNextPunctChar;
15492 if (!canOpen && !canClose) {
15495 token.content = replaceAt(token.content, t.index, APOSTROPHE);
15501 // this could be a closing quote, rewind the stack to get a match
15502 for (j = stack.length - 1; j >= 0; j--) {
15504 if (stack[j].level < thisLevel) { break; }
15505 if (item.single === isSingle && stack[j].level === thisLevel) {
15509 openQuote = state.md.options.quotes[2];
15510 closeQuote = state.md.options.quotes[3];
15512 openQuote = state.md.options.quotes[0];
15513 closeQuote = state.md.options.quotes[1];
15516 // replace token.content *before* tokens[item.token].content,
15517 // because, if they are pointing at the same token, replaceAt
15518 // could mess up indices when quote length != 1
15519 token.content = replaceAt(token.content, t.index, closeQuote);
15520 tokens[item.token].content = replaceAt(
15521 tokens[item.token].content, item.pos, openQuote);
15523 pos += closeQuote.length - 1;
15524 if (item.token === i) { pos += openQuote.length - 1; }
15526 text = token.content;
15542 } else if (canClose && isSingle) {
15543 token.content = replaceAt(token.content, t.index, APOSTROPHE);
15550 module.exports = function smartquotes(state) {
15551 /*eslint max-depth:0*/
15554 if (!state.md.options.typographer) { return; }
15556 for (blkIdx = state.tokens.length - 1; blkIdx >= 0; blkIdx--) {
15558 if (state.tokens[blkIdx].type !== 'inline' ||
15559 !QUOTE_TEST_RE.test(state.tokens[blkIdx].content)) {
15563 process_inlines(state.tokens[blkIdx].children, state);
15570 /***/ (function(module, exports, __webpack_require__) {
15573 // Core state object
15577 var Token = __webpack_require__(70);
15580 function StateCore(src, md, env) {
15584 this.inlineMode = false;
15585 this.md = md; // link to parser instance
15588 // re-export Token class to use in core rules
15589 StateCore.prototype.Token = Token;
15592 module.exports = StateCore;
15597 /***/ (function(module, exports, __webpack_require__) {
15610 * new Token(type, tag, nesting)
15612 * Create new token and fill passed properties.
15614 function Token(type, tag, nesting) {
15616 * Token#type -> String
15618 * Type of the token (string, e.g. "paragraph_open")
15623 * Token#tag -> String
15625 * html tag name, e.g. "p"
15630 * Token#attrs -> Array
15632 * Html attributes. Format: `[ [ name1, value1 ], [ name2, value2 ] ]`
15637 * Token#map -> Array
15639 * Source map info. Format: `[ line_begin, line_end ]`
15644 * Token#nesting -> Number
15646 * Level change (number in {-1, 0, 1} set), where:
15648 * - `1` means the tag is opening
15649 * - `0` means the tag is self-closing
15650 * - `-1` means the tag is closing
15652 this.nesting = nesting;
15655 * Token#level -> Number
15657 * nesting level, the same as `state.level`
15662 * Token#children -> Array
15664 * An array of child nodes (inline and img tokens)
15666 this.children = null;
15669 * Token#content -> String
15671 * In a case of self-closing tag (code, html, fence, etc.),
15672 * it has contents of this tag.
15677 * Token#markup -> String
15679 * '*' or '_' for emphasis, fence string for fence, etc.
15684 * Token#info -> String
15691 * Token#meta -> Object
15693 * A place for plugins to store an arbitrary data
15698 * Token#block -> Boolean
15700 * True for block-level tokens, false for inline tokens.
15701 * Used in renderer to calculate line breaks
15703 this.block = false;
15706 * Token#hidden -> Boolean
15708 * If it's true, ignore this element when rendering. Used for tight lists
15709 * to hide paragraphs.
15711 this.hidden = false;
15716 * Token.attrIndex(name) -> Number
15718 * Search attribute index by name.
15720 Token.prototype.attrIndex = function attrIndex(name) {
15723 if (!this.attrs) { return -1; }
15725 attrs = this.attrs;
15727 for (i = 0, len = attrs.length; i < len; i++) {
15728 if (attrs[i][0] === name) { return i; }
15735 * Token.attrPush(attrData)
15737 * Add `[ name, value ]` attribute to list. Init attrs if necessary
15739 Token.prototype.attrPush = function attrPush(attrData) {
15741 this.attrs.push(attrData);
15743 this.attrs = [ attrData ];
15749 * Token.attrSet(name, value)
15751 * Set `name` attribute to `value`. Override old value if exists.
15753 Token.prototype.attrSet = function attrSet(name, value) {
15754 var idx = this.attrIndex(name),
15755 attrData = [ name, value ];
15758 this.attrPush(attrData);
15760 this.attrs[idx] = attrData;
15766 * Token.attrGet(name)
15768 * Get the value of attribute `name`, or null if it does not exist.
15770 Token.prototype.attrGet = function attrGet(name) {
15771 var idx = this.attrIndex(name), value = null;
15773 value = this.attrs[idx][1];
15780 * Token.attrJoin(name, value)
15782 * Join value to existing attribute via space. Or create new attribute if not
15783 * exists. Useful to operate with token classes.
15785 Token.prototype.attrJoin = function attrJoin(name, value) {
15786 var idx = this.attrIndex(name);
15789 this.attrPush([ name, value ]);
15791 this.attrs[idx][1] = this.attrs[idx][1] + ' ' + value;
15796 module.exports = Token;
15801 /***/ (function(module, exports, __webpack_require__) {
15805 * class ParserBlock
15807 * Block-level tokenizer.
15812 var Ruler = __webpack_require__(62);
15816 // First 2 params - rule name & source. Secondary array - list of rules,
15817 // which can be terminated by this one.
15818 [ 'table', __webpack_require__(72), [ 'paragraph', 'reference' ] ],
15819 [ 'code', __webpack_require__(73) ],
15820 [ 'fence', __webpack_require__(74), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],
15821 [ 'blockquote', __webpack_require__(75), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],
15822 [ 'hr', __webpack_require__(76), [ 'paragraph', 'reference', 'blockquote', 'list' ] ],
15823 [ 'list', __webpack_require__(77), [ 'paragraph', 'reference', 'blockquote' ] ],
15824 [ 'reference', __webpack_require__(78) ],
15825 [ 'heading', __webpack_require__(79), [ 'paragraph', 'reference', 'blockquote' ] ],
15826 [ 'lheading', __webpack_require__(80) ],
15827 [ 'html_block', __webpack_require__(81), [ 'paragraph', 'reference', 'blockquote' ] ],
15828 [ 'paragraph', __webpack_require__(84) ]
15833 * new ParserBlock()
15835 function ParserBlock() {
15837 * ParserBlock#ruler -> Ruler
15839 * [[Ruler]] instance. Keep configuration of block rules.
15841 this.ruler = new Ruler();
15843 for (var i = 0; i < _rules.length; i++) {
15844 this.ruler.push(_rules[i][0], _rules[i][1], { alt: (_rules[i][2] || []).slice() });
15849 // Generate tokens for input range
15851 ParserBlock.prototype.tokenize = function (state, startLine, endLine) {
15853 rules = this.ruler.getRules(''),
15854 len = rules.length,
15856 hasEmptyLines = false,
15857 maxNesting = state.md.options.maxNesting;
15859 while (line < endLine) {
15860 state.line = line = state.skipEmptyLines(line);
15861 if (line >= endLine) { break; }
15863 // Termination condition for nested calls.
15864 // Nested calls currently used for blockquotes & lists
15865 if (state.sCount[line] < state.blkIndent) { break; }
15867 // If nesting level exceeded - skip tail to the end. That's not ordinary
15868 // situation and we should not care about content.
15869 if (state.level >= maxNesting) {
15870 state.line = endLine;
15874 // Try all possible rules.
15875 // On success, rule should:
15877 // - update `state.line`
15878 // - update `state.tokens`
15881 for (i = 0; i < len; i++) {
15882 ok = rules[i](state, line, endLine, false);
15886 // set state.tight if we had an empty line before current tag
15887 // i.e. latest empty line should not count
15888 state.tight = !hasEmptyLines;
15890 // paragraph might "eat" one newline after it in nested lists
15891 if (state.isEmpty(state.line - 1)) {
15892 hasEmptyLines = true;
15897 if (line < endLine && state.isEmpty(line)) {
15898 hasEmptyLines = true;
15907 * ParserBlock.parse(str, md, env, outTokens)
15909 * Process input string and push block tokens into `outTokens`
15911 ParserBlock.prototype.parse = function (src, md, env, outTokens) {
15914 if (!src) { return; }
15916 state = new this.State(src, md, env, outTokens);
15918 this.tokenize(state, state.line, state.lineMax);
15922 ParserBlock.prototype.State = __webpack_require__(85);
15925 module.exports = ParserBlock;
15930 /***/ (function(module, exports, __webpack_require__) {
15933 // GFM table, non-standard
15937 var isSpace = __webpack_require__(42).isSpace;
15940 function getLine(state, line) {
15941 var pos = state.bMarks[line] + state.blkIndent,
15942 max = state.eMarks[line];
15944 return state.src.substr(pos, max - pos);
15947 function escapedSplit(str) {
15954 backTicked = false,
15957 ch = str.charCodeAt(pos);
15959 while (pos < max) {
15960 if (ch === 0x60/* ` */) {
15962 // make \` close code sequence, but not open it;
15963 // the reason is: `\` is correct code block
15964 backTicked = false;
15965 lastBackTick = pos;
15966 } else if (escapes % 2 === 0) {
15968 lastBackTick = pos;
15970 } else if (ch === 0x7c/* | */ && (escapes % 2 === 0) && !backTicked) {
15971 result.push(str.substring(lastPos, pos));
15975 if (ch === 0x5c/* \ */) {
15983 // If there was an un-closed backtick, go back to just after
15984 // the last backtick, but as if it was a normal character
15985 if (pos === max && backTicked) {
15986 backTicked = false;
15987 pos = lastBackTick + 1;
15990 ch = str.charCodeAt(pos);
15993 result.push(str.substring(lastPos));
15999 module.exports = function table(state, startLine, endLine, silent) {
16000 var ch, lineText, pos, i, nextLine, columns, columnCount, token,
16001 aligns, t, tableLines, tbodyLines;
16003 // should have at least two lines
16004 if (startLine + 2 > endLine) { return false; }
16006 nextLine = startLine + 1;
16008 if (state.sCount[nextLine] < state.blkIndent) { return false; }
16010 // if it's indented more than 3 spaces, it should be a code block
16011 if (state.sCount[nextLine] - state.blkIndent >= 4) { return false; }
16013 // first character of the second line should be '|', '-', ':',
16014 // and no other characters are allowed but spaces;
16015 // basically, this is the equivalent of /^[-:|][-:|\s]*$/ regexp
16017 pos = state.bMarks[nextLine] + state.tShift[nextLine];
16018 if (pos >= state.eMarks[nextLine]) { return false; }
16020 ch = state.src.charCodeAt(pos++);
16021 if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */) { return false; }
16023 while (pos < state.eMarks[nextLine]) {
16024 ch = state.src.charCodeAt(pos);
16026 if (ch !== 0x7C/* | */ && ch !== 0x2D/* - */ && ch !== 0x3A/* : */ && !isSpace(ch)) { return false; }
16031 lineText = getLine(state, startLine + 1);
16033 columns = lineText.split('|');
16035 for (i = 0; i < columns.length; i++) {
16036 t = columns[i].trim();
16038 // allow empty columns before and after table, but not in between columns;
16039 // e.g. allow ` |---| `, disallow ` ---||--- `
16040 if (i === 0 || i === columns.length - 1) {
16047 if (!/^:?-+:?$/.test(t)) { return false; }
16048 if (t.charCodeAt(t.length - 1) === 0x3A/* : */) {
16049 aligns.push(t.charCodeAt(0) === 0x3A/* : */ ? 'center' : 'right');
16050 } else if (t.charCodeAt(0) === 0x3A/* : */) {
16051 aligns.push('left');
16057 lineText = getLine(state, startLine).trim();
16058 if (lineText.indexOf('|') === -1) { return false; }
16059 if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
16060 columns = escapedSplit(lineText.replace(/^\||\|$/g, ''));
16062 // header row will define an amount of columns in the entire table,
16063 // and align row shouldn't be smaller than that (the rest of the rows can)
16064 columnCount = columns.length;
16065 if (columnCount > aligns.length) { return false; }
16067 if (silent) { return true; }
16069 token = state.push('table_open', 'table', 1);
16070 token.map = tableLines = [ startLine, 0 ];
16072 token = state.push('thead_open', 'thead', 1);
16073 token.map = [ startLine, startLine + 1 ];
16075 token = state.push('tr_open', 'tr', 1);
16076 token.map = [ startLine, startLine + 1 ];
16078 for (i = 0; i < columns.length; i++) {
16079 token = state.push('th_open', 'th', 1);
16080 token.map = [ startLine, startLine + 1 ];
16082 token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ];
16085 token = state.push('inline', '', 0);
16086 token.content = columns[i].trim();
16087 token.map = [ startLine, startLine + 1 ];
16088 token.children = [];
16090 token = state.push('th_close', 'th', -1);
16093 token = state.push('tr_close', 'tr', -1);
16094 token = state.push('thead_close', 'thead', -1);
16096 token = state.push('tbody_open', 'tbody', 1);
16097 token.map = tbodyLines = [ startLine + 2, 0 ];
16099 for (nextLine = startLine + 2; nextLine < endLine; nextLine++) {
16100 if (state.sCount[nextLine] < state.blkIndent) { break; }
16102 lineText = getLine(state, nextLine).trim();
16103 if (lineText.indexOf('|') === -1) { break; }
16104 if (state.sCount[nextLine] - state.blkIndent >= 4) { break; }
16105 columns = escapedSplit(lineText.replace(/^\||\|$/g, ''));
16107 token = state.push('tr_open', 'tr', 1);
16108 for (i = 0; i < columnCount; i++) {
16109 token = state.push('td_open', 'td', 1);
16111 token.attrs = [ [ 'style', 'text-align:' + aligns[i] ] ];
16114 token = state.push('inline', '', 0);
16115 token.content = columns[i] ? columns[i].trim() : '';
16116 token.children = [];
16118 token = state.push('td_close', 'td', -1);
16120 token = state.push('tr_close', 'tr', -1);
16122 token = state.push('tbody_close', 'tbody', -1);
16123 token = state.push('table_close', 'table', -1);
16125 tableLines[1] = tbodyLines[1] = nextLine;
16126 state.line = nextLine;
16133 /***/ (function(module, exports, __webpack_require__) {
16136 // Code block (4 spaces padded)
16141 module.exports = function code(state, startLine, endLine/*, silent*/) {
16142 var nextLine, last, token;
16144 if (state.sCount[startLine] - state.blkIndent < 4) { return false; }
16146 last = nextLine = startLine + 1;
16148 while (nextLine < endLine) {
16149 if (state.isEmpty(nextLine)) {
16154 if (state.sCount[nextLine] - state.blkIndent >= 4) {
16164 token = state.push('code_block', 'code', 0);
16165 token.content = state.getLines(startLine, last, 4 + state.blkIndent, true);
16166 token.map = [ startLine, state.line ];
16174 /***/ (function(module, exports, __webpack_require__) {
16177 // fences (``` lang, ~~~ lang)
16182 module.exports = function fence(state, startLine, endLine, silent) {
16183 var marker, len, params, nextLine, mem, token, markup,
16184 haveEndMarker = false,
16185 pos = state.bMarks[startLine] + state.tShift[startLine],
16186 max = state.eMarks[startLine];
16188 // if it's indented more than 3 spaces, it should be a code block
16189 if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
16191 if (pos + 3 > max) { return false; }
16193 marker = state.src.charCodeAt(pos);
16195 if (marker !== 0x7E/* ~ */ && marker !== 0x60 /* ` */) {
16199 // scan marker length
16201 pos = state.skipChars(pos, marker);
16205 if (len < 3) { return false; }
16207 markup = state.src.slice(mem, pos);
16208 params = state.src.slice(pos, max);
16210 if (marker === 0x60 /* ` */) {
16211 if (params.indexOf(String.fromCharCode(marker)) >= 0) {
16216 // Since start is found, we can report success here in validation mode
16217 if (silent) { return true; }
16219 // search end of block
16220 nextLine = startLine;
16224 if (nextLine >= endLine) {
16225 // unclosed block should be autoclosed by end of document.
16226 // also block seems to be autoclosed by end of parent
16230 pos = mem = state.bMarks[nextLine] + state.tShift[nextLine];
16231 max = state.eMarks[nextLine];
16233 if (pos < max && state.sCount[nextLine] < state.blkIndent) {
16234 // non-empty line with negative indent should stop the list:
16240 if (state.src.charCodeAt(pos) !== marker) { continue; }
16242 if (state.sCount[nextLine] - state.blkIndent >= 4) {
16243 // closing fence should be indented less than 4 spaces
16247 pos = state.skipChars(pos, marker);
16249 // closing code fence must be at least as long as the opening one
16250 if (pos - mem < len) { continue; }
16252 // make sure tail has spaces only
16253 pos = state.skipSpaces(pos);
16255 if (pos < max) { continue; }
16257 haveEndMarker = true;
16262 // If a fence has heading spaces, they should be removed from its inner block
16263 len = state.sCount[startLine];
16265 state.line = nextLine + (haveEndMarker ? 1 : 0);
16267 token = state.push('fence', 'code', 0);
16268 token.info = params;
16269 token.content = state.getLines(startLine + 1, nextLine, len, true);
16270 token.markup = markup;
16271 token.map = [ startLine, state.line ];
16279 /***/ (function(module, exports, __webpack_require__) {
16286 var isSpace = __webpack_require__(42).isSpace;
16289 module.exports = function blockquote(state, startLine, endLine, silent) {
16310 oldLineMax = state.lineMax,
16311 pos = state.bMarks[startLine] + state.tShift[startLine],
16312 max = state.eMarks[startLine];
16314 // if it's indented more than 3 spaces, it should be a code block
16315 if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
16317 // check the block quote marker
16318 if (state.src.charCodeAt(pos++) !== 0x3E/* > */) { return false; }
16320 // we know that it's going to be a valid blockquote,
16321 // so no point trying to find the end of it in silent mode
16322 if (silent) { return true; }
16324 // skip spaces after ">" and re-calculate offset
16325 initial = offset = state.sCount[startLine] + pos - (state.bMarks[startLine] + state.tShift[startLine]);
16327 // skip one optional space after '>'
16328 if (state.src.charCodeAt(pos) === 0x20 /* space */) {
16330 // ^ -- position start of line here:
16335 spaceAfterMarker = true;
16336 } else if (state.src.charCodeAt(pos) === 0x09 /* tab */) {
16337 spaceAfterMarker = true;
16339 if ((state.bsCount[startLine] + offset) % 4 === 3) {
16341 // ^ -- position start of line here (tab has width===1)
16348 // ^ -- position start of line here + shift bsCount slightly
16349 // to make extra space appear
16353 spaceAfterMarker = false;
16356 oldBMarks = [ state.bMarks[startLine] ];
16357 state.bMarks[startLine] = pos;
16359 while (pos < max) {
16360 ch = state.src.charCodeAt(pos);
16364 offset += 4 - (offset + state.bsCount[startLine] + (adjustTab ? 1 : 0)) % 4;
16375 oldBSCount = [ state.bsCount[startLine] ];
16376 state.bsCount[startLine] = state.sCount[startLine] + 1 + (spaceAfterMarker ? 1 : 0);
16378 lastLineEmpty = pos >= max;
16380 oldSCount = [ state.sCount[startLine] ];
16381 state.sCount[startLine] = offset - initial;
16383 oldTShift = [ state.tShift[startLine] ];
16384 state.tShift[startLine] = pos - state.bMarks[startLine];
16386 terminatorRules = state.md.block.ruler.getRules('blockquote');
16388 oldParentType = state.parentType;
16389 state.parentType = 'blockquote';
16390 wasOutdented = false;
16392 // Search the end of the block
16394 // Block ends with either:
16395 // 1. an empty line outside:
16400 // 2. an empty line inside:
16410 for (nextLine = startLine + 1; nextLine < endLine; nextLine++) {
16411 // check if it's outdented, i.e. it's inside list item and indented
16412 // less than said list item:
16416 // > current blockquote
16417 // 2. checking this line
16419 if (state.sCount[nextLine] < state.blkIndent) wasOutdented = true;
16421 pos = state.bMarks[nextLine] + state.tShift[nextLine];
16422 max = state.eMarks[nextLine];
16425 // Case 1: line is not inside the blockquote, and this line is empty.
16429 if (state.src.charCodeAt(pos++) === 0x3E/* > */ && !wasOutdented) {
16430 // This line is inside the blockquote.
16432 // skip spaces after ">" and re-calculate offset
16433 initial = offset = state.sCount[nextLine] + pos - (state.bMarks[nextLine] + state.tShift[nextLine]);
16435 // skip one optional space after '>'
16436 if (state.src.charCodeAt(pos) === 0x20 /* space */) {
16438 // ^ -- position start of line here:
16443 spaceAfterMarker = true;
16444 } else if (state.src.charCodeAt(pos) === 0x09 /* tab */) {
16445 spaceAfterMarker = true;
16447 if ((state.bsCount[nextLine] + offset) % 4 === 3) {
16449 // ^ -- position start of line here (tab has width===1)
16456 // ^ -- position start of line here + shift bsCount slightly
16457 // to make extra space appear
16461 spaceAfterMarker = false;
16464 oldBMarks.push(state.bMarks[nextLine]);
16465 state.bMarks[nextLine] = pos;
16467 while (pos < max) {
16468 ch = state.src.charCodeAt(pos);
16472 offset += 4 - (offset + state.bsCount[nextLine] + (adjustTab ? 1 : 0)) % 4;
16483 lastLineEmpty = pos >= max;
16485 oldBSCount.push(state.bsCount[nextLine]);
16486 state.bsCount[nextLine] = state.sCount[nextLine] + 1 + (spaceAfterMarker ? 1 : 0);
16488 oldSCount.push(state.sCount[nextLine]);
16489 state.sCount[nextLine] = offset - initial;
16491 oldTShift.push(state.tShift[nextLine]);
16492 state.tShift[nextLine] = pos - state.bMarks[nextLine];
16496 // Case 2: line is not inside the blockquote, and the last line was empty.
16497 if (lastLineEmpty) { break; }
16499 // Case 3: another tag found.
16501 for (i = 0, l = terminatorRules.length; i < l; i++) {
16502 if (terminatorRules[i](state, nextLine, endLine, true)) {
16509 // Quirk to enforce "hard termination mode" for paragraphs;
16510 // normally if you call `tokenize(state, startLine, nextLine)`,
16511 // paragraphs will look below nextLine for paragraph continuation,
16512 // but if blockquote is terminated by another tag, they shouldn't
16513 state.lineMax = nextLine;
16515 if (state.blkIndent !== 0) {
16516 // state.blkIndent was non-zero, we now set it to zero,
16517 // so we need to re-calculate all offsets to appear as
16518 // if indent wasn't changed
16519 oldBMarks.push(state.bMarks[nextLine]);
16520 oldBSCount.push(state.bsCount[nextLine]);
16521 oldTShift.push(state.tShift[nextLine]);
16522 oldSCount.push(state.sCount[nextLine]);
16523 state.sCount[nextLine] -= state.blkIndent;
16529 oldBMarks.push(state.bMarks[nextLine]);
16530 oldBSCount.push(state.bsCount[nextLine]);
16531 oldTShift.push(state.tShift[nextLine]);
16532 oldSCount.push(state.sCount[nextLine]);
16534 // A negative indentation means that this is a paragraph continuation
16536 state.sCount[nextLine] = -1;
16539 oldIndent = state.blkIndent;
16540 state.blkIndent = 0;
16542 token = state.push('blockquote_open', 'blockquote', 1);
16543 token.markup = '>';
16544 token.map = lines = [ startLine, 0 ];
16546 state.md.block.tokenize(state, startLine, nextLine);
16548 token = state.push('blockquote_close', 'blockquote', -1);
16549 token.markup = '>';
16551 state.lineMax = oldLineMax;
16552 state.parentType = oldParentType;
16553 lines[1] = state.line;
16555 // Restore original tShift; this might not be necessary since the parser
16556 // has already been here, but just to make sure we can do that.
16557 for (i = 0; i < oldTShift.length; i++) {
16558 state.bMarks[i + startLine] = oldBMarks[i];
16559 state.tShift[i + startLine] = oldTShift[i];
16560 state.sCount[i + startLine] = oldSCount[i];
16561 state.bsCount[i + startLine] = oldBSCount[i];
16563 state.blkIndent = oldIndent;
16571 /***/ (function(module, exports, __webpack_require__) {
16578 var isSpace = __webpack_require__(42).isSpace;
16581 module.exports = function hr(state, startLine, endLine, silent) {
16582 var marker, cnt, ch, token,
16583 pos = state.bMarks[startLine] + state.tShift[startLine],
16584 max = state.eMarks[startLine];
16586 // if it's indented more than 3 spaces, it should be a code block
16587 if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
16589 marker = state.src.charCodeAt(pos++);
16592 if (marker !== 0x2A/* * */ &&
16593 marker !== 0x2D/* - */ &&
16594 marker !== 0x5F/* _ */) {
16598 // markers can be mixed with spaces, but there should be at least 3 of them
16601 while (pos < max) {
16602 ch = state.src.charCodeAt(pos++);
16603 if (ch !== marker && !isSpace(ch)) { return false; }
16604 if (ch === marker) { cnt++; }
16607 if (cnt < 3) { return false; }
16609 if (silent) { return true; }
16611 state.line = startLine + 1;
16613 token = state.push('hr', 'hr', 0);
16614 token.map = [ startLine, state.line ];
16615 token.markup = Array(cnt + 1).join(String.fromCharCode(marker));
16623 /***/ (function(module, exports, __webpack_require__) {
16630 var isSpace = __webpack_require__(42).isSpace;
16633 // Search `[-+*][\n ]`, returns next pos after marker on success
16635 function skipBulletListMarker(state, startLine) {
16636 var marker, pos, max, ch;
16638 pos = state.bMarks[startLine] + state.tShift[startLine];
16639 max = state.eMarks[startLine];
16641 marker = state.src.charCodeAt(pos++);
16643 if (marker !== 0x2A/* * */ &&
16644 marker !== 0x2D/* - */ &&
16645 marker !== 0x2B/* + */) {
16650 ch = state.src.charCodeAt(pos);
16652 if (!isSpace(ch)) {
16653 // " -test " - is not a list item
16661 // Search `\d+[.)][\n ]`, returns next pos after marker on success
16663 function skipOrderedListMarker(state, startLine) {
16665 start = state.bMarks[startLine] + state.tShift[startLine],
16667 max = state.eMarks[startLine];
16669 // List marker should have at least 2 chars (digit + dot)
16670 if (pos + 1 >= max) { return -1; }
16672 ch = state.src.charCodeAt(pos++);
16674 if (ch < 0x30/* 0 */ || ch > 0x39/* 9 */) { return -1; }
16678 if (pos >= max) { return -1; }
16680 ch = state.src.charCodeAt(pos++);
16682 if (ch >= 0x30/* 0 */ && ch <= 0x39/* 9 */) {
16684 // List marker should have no more than 9 digits
16685 // (prevents integer overflow in browsers)
16686 if (pos - start >= 10) { return -1; }
16691 // found valid marker
16692 if (ch === 0x29/* ) */ || ch === 0x2e/* . */) {
16701 ch = state.src.charCodeAt(pos);
16703 if (!isSpace(ch)) {
16704 // " 1.test " - is not a list item
16711 function markTightParagraphs(state, idx) {
16713 level = state.level + 2;
16715 for (i = idx + 2, l = state.tokens.length - 2; i < l; i++) {
16716 if (state.tokens[i].level === level && state.tokens[i].type === 'paragraph_open') {
16717 state.tokens[i + 2].hidden = true;
16718 state.tokens[i].hidden = true;
16725 module.exports = function list(state, startLine, endLine, silent) {
16754 isTerminatingParagraph = false,
16757 // if it's indented more than 3 spaces, it should be a code block
16758 if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
16765 // - this one is a paragraph continuation
16766 if (state.listIndent >= 0 &&
16767 state.sCount[startLine] - state.listIndent >= 4 &&
16768 state.sCount[startLine] < state.blkIndent) {
16772 // limit conditions when list can interrupt
16773 // a paragraph (validation mode only)
16774 if (silent && state.parentType === 'paragraph') {
16775 // Next list item should still terminate previous list item;
16777 // This code can fail if plugins use blkIndent as well as lists,
16778 // but I hope the spec gets fixed long before that happens.
16780 if (state.tShift[startLine] >= state.blkIndent) {
16781 isTerminatingParagraph = true;
16785 // Detect list type and position after marker
16786 if ((posAfterMarker = skipOrderedListMarker(state, startLine)) >= 0) {
16788 start = state.bMarks[startLine] + state.tShift[startLine];
16789 markerValue = Number(state.src.substr(start, posAfterMarker - start - 1));
16791 // If we're starting a new ordered list right after
16792 // a paragraph, it should start with 1.
16793 if (isTerminatingParagraph && markerValue !== 1) return false;
16795 } else if ((posAfterMarker = skipBulletListMarker(state, startLine)) >= 0) {
16802 // If we're starting a new unordered list right after
16803 // a paragraph, first line should not be empty.
16804 if (isTerminatingParagraph) {
16805 if (state.skipSpaces(posAfterMarker) >= state.eMarks[startLine]) return false;
16808 // We should terminate list on style change. Remember first one to compare.
16809 markerCharCode = state.src.charCodeAt(posAfterMarker - 1);
16811 // For validation mode we can terminate immediately
16812 if (silent) { return true; }
16815 listTokIdx = state.tokens.length;
16818 token = state.push('ordered_list_open', 'ol', 1);
16819 if (markerValue !== 1) {
16820 token.attrs = [ [ 'start', markerValue ] ];
16824 token = state.push('bullet_list_open', 'ul', 1);
16827 token.map = listLines = [ startLine, 0 ];
16828 token.markup = String.fromCharCode(markerCharCode);
16831 // Iterate list items
16834 nextLine = startLine;
16835 prevEmptyEnd = false;
16836 terminatorRules = state.md.block.ruler.getRules('list');
16838 oldParentType = state.parentType;
16839 state.parentType = 'list';
16841 while (nextLine < endLine) {
16842 pos = posAfterMarker;
16843 max = state.eMarks[nextLine];
16845 initial = offset = state.sCount[nextLine] + posAfterMarker - (state.bMarks[startLine] + state.tShift[startLine]);
16847 while (pos < max) {
16848 ch = state.src.charCodeAt(pos);
16851 offset += 4 - (offset + state.bsCount[nextLine]) % 4;
16852 } else if (ch === 0x20) {
16861 contentStart = pos;
16863 if (contentStart >= max) {
16864 // trimming space in "- \n 3" case, indent is 1 here
16865 indentAfterMarker = 1;
16867 indentAfterMarker = offset - initial;
16870 // If we have more than 4 spaces, the indent is 1
16871 // (the rest is just indented code block)
16872 if (indentAfterMarker > 4) { indentAfterMarker = 1; }
16875 // ^^^^^ - calculating total length of this thing
16876 indent = initial + indentAfterMarker;
16878 // Run subparser & write tokens
16879 token = state.push('list_item_open', 'li', 1);
16880 token.markup = String.fromCharCode(markerCharCode);
16881 token.map = itemLines = [ startLine, 0 ];
16883 // change current state, then restore it after parser subcall
16884 oldTight = state.tight;
16885 oldTShift = state.tShift[startLine];
16886 oldSCount = state.sCount[startLine];
16889 // ^ listIndent position will be here
16890 // ^ blkIndent position will be here
16892 oldListIndent = state.listIndent;
16893 state.listIndent = state.blkIndent;
16894 state.blkIndent = indent;
16896 state.tight = true;
16897 state.tShift[startLine] = contentStart - state.bMarks[startLine];
16898 state.sCount[startLine] = offset;
16900 if (contentStart >= max && state.isEmpty(startLine + 1)) {
16901 // workaround for this case
16902 // (list item is empty, list terminates before "foo"):
16908 state.line = Math.min(state.line + 2, endLine);
16910 state.md.block.tokenize(state, startLine, endLine, true);
16913 // If any of list item is tight, mark list as tight
16914 if (!state.tight || prevEmptyEnd) {
16917 // Item become loose if finish with empty line,
16918 // but we should filter last element, because it means list finish
16919 prevEmptyEnd = (state.line - startLine) > 1 && state.isEmpty(state.line - 1);
16921 state.blkIndent = state.listIndent;
16922 state.listIndent = oldListIndent;
16923 state.tShift[startLine] = oldTShift;
16924 state.sCount[startLine] = oldSCount;
16925 state.tight = oldTight;
16927 token = state.push('list_item_close', 'li', -1);
16928 token.markup = String.fromCharCode(markerCharCode);
16930 nextLine = startLine = state.line;
16931 itemLines[1] = nextLine;
16932 contentStart = state.bMarks[startLine];
16934 if (nextLine >= endLine) { break; }
16937 // Try to check if list is terminated or continued.
16939 if (state.sCount[nextLine] < state.blkIndent) { break; }
16941 // if it's indented more than 3 spaces, it should be a code block
16942 if (state.sCount[startLine] - state.blkIndent >= 4) { break; }
16944 // fail if terminating block found
16946 for (i = 0, l = terminatorRules.length; i < l; i++) {
16947 if (terminatorRules[i](state, nextLine, endLine, true)) {
16952 if (terminate) { break; }
16954 // fail if list has another type
16956 posAfterMarker = skipOrderedListMarker(state, nextLine);
16957 if (posAfterMarker < 0) { break; }
16959 posAfterMarker = skipBulletListMarker(state, nextLine);
16960 if (posAfterMarker < 0) { break; }
16963 if (markerCharCode !== state.src.charCodeAt(posAfterMarker - 1)) { break; }
16968 token = state.push('ordered_list_close', 'ol', -1);
16970 token = state.push('bullet_list_close', 'ul', -1);
16972 token.markup = String.fromCharCode(markerCharCode);
16974 listLines[1] = nextLine;
16975 state.line = nextLine;
16977 state.parentType = oldParentType;
16979 // mark paragraphs tight if needed
16981 markTightParagraphs(state, listTokIdx);
16990 /***/ (function(module, exports, __webpack_require__) {
16996 var normalizeReference = __webpack_require__(42).normalizeReference;
16997 var isSpace = __webpack_require__(42).isSpace;
17000 module.exports = function reference(state, startLine, _endLine, silent) {
17018 pos = state.bMarks[startLine] + state.tShift[startLine],
17019 max = state.eMarks[startLine],
17020 nextLine = startLine + 1;
17022 // if it's indented more than 3 spaces, it should be a code block
17023 if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
17025 if (state.src.charCodeAt(pos) !== 0x5B/* [ */) { return false; }
17027 // Simple check to quickly interrupt scan on [link](url) at the start of line.
17028 // Can be useful on practice: https://github.com/markdown-it/markdown-it/issues/54
17029 while (++pos < max) {
17030 if (state.src.charCodeAt(pos) === 0x5D /* ] */ &&
17031 state.src.charCodeAt(pos - 1) !== 0x5C/* \ */) {
17032 if (pos + 1 === max) { return false; }
17033 if (state.src.charCodeAt(pos + 1) !== 0x3A/* : */) { return false; }
17038 endLine = state.lineMax;
17040 // jump line-by-line until empty one or EOF
17041 terminatorRules = state.md.block.ruler.getRules('reference');
17043 oldParentType = state.parentType;
17044 state.parentType = 'reference';
17046 for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
17047 // this would be a code block normally, but after paragraph
17048 // it's considered a lazy continuation regardless of what's there
17049 if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }
17051 // quirk for blockquotes, this line should already be checked by that rule
17052 if (state.sCount[nextLine] < 0) { continue; }
17054 // Some tags can terminate paragraph without empty line.
17056 for (i = 0, l = terminatorRules.length; i < l; i++) {
17057 if (terminatorRules[i](state, nextLine, endLine, true)) {
17062 if (terminate) { break; }
17065 str = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
17068 for (pos = 1; pos < max; pos++) {
17069 ch = str.charCodeAt(pos);
17070 if (ch === 0x5B /* [ */) {
17072 } else if (ch === 0x5D /* ] */) {
17075 } else if (ch === 0x0A /* \n */) {
17077 } else if (ch === 0x5C /* \ */) {
17079 if (pos < max && str.charCodeAt(pos) === 0x0A) {
17085 if (labelEnd < 0 || str.charCodeAt(labelEnd + 1) !== 0x3A/* : */) { return false; }
17087 // [label]: destination 'title'
17088 // ^^^ skip optional whitespace here
17089 for (pos = labelEnd + 2; pos < max; pos++) {
17090 ch = str.charCodeAt(pos);
17093 } else if (isSpace(ch)) {
17094 /*eslint no-empty:0*/
17100 // [label]: destination 'title'
17101 // ^^^^^^^^^^^ parse this
17102 res = state.md.helpers.parseLinkDestination(str, pos, max);
17103 if (!res.ok) { return false; }
17105 href = state.md.normalizeLink(res.str);
17106 if (!state.md.validateLink(href)) { return false; }
17109 lines += res.lines;
17111 // save cursor state, we could require to rollback later
17113 destEndLineNo = lines;
17115 // [label]: destination 'title'
17116 // ^^^ skipping those spaces
17118 for (; pos < max; pos++) {
17119 ch = str.charCodeAt(pos);
17122 } else if (isSpace(ch)) {
17123 /*eslint no-empty:0*/
17129 // [label]: destination 'title'
17130 // ^^^^^^^ parse this
17131 res = state.md.helpers.parseLinkTitle(str, pos, max);
17132 if (pos < max && start !== pos && res.ok) {
17135 lines += res.lines;
17139 lines = destEndLineNo;
17142 // skip trailing spaces until the rest of the line
17143 while (pos < max) {
17144 ch = str.charCodeAt(pos);
17145 if (!isSpace(ch)) { break; }
17149 if (pos < max && str.charCodeAt(pos) !== 0x0A) {
17151 // garbage at the end of the line after title,
17152 // but it could still be a valid reference if we roll back
17155 lines = destEndLineNo;
17156 while (pos < max) {
17157 ch = str.charCodeAt(pos);
17158 if (!isSpace(ch)) { break; }
17164 if (pos < max && str.charCodeAt(pos) !== 0x0A) {
17165 // garbage at the end of the line
17169 label = normalizeReference(str.slice(1, labelEnd));
17171 // CommonMark 0.20 disallows empty labels
17175 // Reference can not terminate anything. This check is for safety only.
17176 /*istanbul ignore if*/
17177 if (silent) { return true; }
17179 if (typeof state.env.references === 'undefined') {
17180 state.env.references = {};
17182 if (typeof state.env.references[label] === 'undefined') {
17183 state.env.references[label] = { title: title, href: href };
17186 state.parentType = oldParentType;
17188 state.line = startLine + lines + 1;
17195 /***/ (function(module, exports, __webpack_require__) {
17198 // heading (#, ##, ...)
17202 var isSpace = __webpack_require__(42).isSpace;
17205 module.exports = function heading(state, startLine, endLine, silent) {
17206 var ch, level, tmp, token,
17207 pos = state.bMarks[startLine] + state.tShift[startLine],
17208 max = state.eMarks[startLine];
17210 // if it's indented more than 3 spaces, it should be a code block
17211 if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
17213 ch = state.src.charCodeAt(pos);
17215 if (ch !== 0x23/* # */ || pos >= max) { return false; }
17217 // count heading level
17219 ch = state.src.charCodeAt(++pos);
17220 while (ch === 0x23/* # */ && pos < max && level <= 6) {
17222 ch = state.src.charCodeAt(++pos);
17225 if (level > 6 || (pos < max && !isSpace(ch))) { return false; }
17227 if (silent) { return true; }
17229 // Let's cut tails like ' ### ' from the end of string
17231 max = state.skipSpacesBack(max, pos);
17232 tmp = state.skipCharsBack(max, 0x23, pos); // #
17233 if (tmp > pos && isSpace(state.src.charCodeAt(tmp - 1))) {
17237 state.line = startLine + 1;
17239 token = state.push('heading_open', 'h' + String(level), 1);
17240 token.markup = '########'.slice(0, level);
17241 token.map = [ startLine, state.line ];
17243 token = state.push('inline', '', 0);
17244 token.content = state.src.slice(pos, max).trim();
17245 token.map = [ startLine, state.line ];
17246 token.children = [];
17248 token = state.push('heading_close', 'h' + String(level), -1);
17249 token.markup = '########'.slice(0, level);
17257 /***/ (function(module, exports, __webpack_require__) {
17260 // lheading (---, ===)
17265 module.exports = function lheading(state, startLine, endLine/*, silent*/) {
17266 var content, terminate, i, l, token, pos, max, level, marker,
17267 nextLine = startLine + 1, oldParentType,
17268 terminatorRules = state.md.block.ruler.getRules('paragraph');
17270 // if it's indented more than 3 spaces, it should be a code block
17271 if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
17273 oldParentType = state.parentType;
17274 state.parentType = 'paragraph'; // use paragraph to match terminatorRules
17276 // jump line-by-line until empty one or EOF
17277 for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
17278 // this would be a code block normally, but after paragraph
17279 // it's considered a lazy continuation regardless of what's there
17280 if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }
17283 // Check for underline in setext header
17285 if (state.sCount[nextLine] >= state.blkIndent) {
17286 pos = state.bMarks[nextLine] + state.tShift[nextLine];
17287 max = state.eMarks[nextLine];
17290 marker = state.src.charCodeAt(pos);
17292 if (marker === 0x2D/* - */ || marker === 0x3D/* = */) {
17293 pos = state.skipChars(pos, marker);
17294 pos = state.skipSpaces(pos);
17297 level = (marker === 0x3D/* = */ ? 1 : 2);
17304 // quirk for blockquotes, this line should already be checked by that rule
17305 if (state.sCount[nextLine] < 0) { continue; }
17307 // Some tags can terminate paragraph without empty line.
17309 for (i = 0, l = terminatorRules.length; i < l; i++) {
17310 if (terminatorRules[i](state, nextLine, endLine, true)) {
17315 if (terminate) { break; }
17319 // Didn't find valid underline
17323 content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
17325 state.line = nextLine + 1;
17327 token = state.push('heading_open', 'h' + String(level), 1);
17328 token.markup = String.fromCharCode(marker);
17329 token.map = [ startLine, state.line ];
17331 token = state.push('inline', '', 0);
17332 token.content = content;
17333 token.map = [ startLine, state.line - 1 ];
17334 token.children = [];
17336 token = state.push('heading_close', 'h' + String(level), -1);
17337 token.markup = String.fromCharCode(marker);
17339 state.parentType = oldParentType;
17347 /***/ (function(module, exports, __webpack_require__) {
17355 var block_names = __webpack_require__(82);
17356 var HTML_OPEN_CLOSE_TAG_RE = __webpack_require__(83).HTML_OPEN_CLOSE_TAG_RE;
17358 // An array of opening and corresponding closing sequences for html tags,
17359 // last argument defines whether it can terminate a paragraph or not
17361 var HTML_SEQUENCES = [
17362 [ /^<(script|pre|style)(?=(\s|>|$))/i, /<\/(script|pre|style)>/i, true ],
17363 [ /^<!--/, /-->/, true ],
17364 [ /^<\?/, /\?>/, true ],
17365 [ /^<![A-Z]/, />/, true ],
17366 [ /^<!\[CDATA\[/, /\]\]>/, true ],
17367 [ new RegExp('^</?(' + block_names.join('|') + ')(?=(\\s|/?>|$))', 'i'), /^$/, true ],
17368 [ new RegExp(HTML_OPEN_CLOSE_TAG_RE.source + '\\s*$'), /^$/, false ]
17372 module.exports = function html_block(state, startLine, endLine, silent) {
17373 var i, nextLine, token, lineText,
17374 pos = state.bMarks[startLine] + state.tShift[startLine],
17375 max = state.eMarks[startLine];
17377 // if it's indented more than 3 spaces, it should be a code block
17378 if (state.sCount[startLine] - state.blkIndent >= 4) { return false; }
17380 if (!state.md.options.html) { return false; }
17382 if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }
17384 lineText = state.src.slice(pos, max);
17386 for (i = 0; i < HTML_SEQUENCES.length; i++) {
17387 if (HTML_SEQUENCES[i][0].test(lineText)) { break; }
17390 if (i === HTML_SEQUENCES.length) { return false; }
17393 // true if this sequence can be a terminator, false otherwise
17394 return HTML_SEQUENCES[i][2];
17397 nextLine = startLine + 1;
17399 // If we are here - we detected HTML block.
17400 // Let's roll down till block end.
17401 if (!HTML_SEQUENCES[i][1].test(lineText)) {
17402 for (; nextLine < endLine; nextLine++) {
17403 if (state.sCount[nextLine] < state.blkIndent) { break; }
17405 pos = state.bMarks[nextLine] + state.tShift[nextLine];
17406 max = state.eMarks[nextLine];
17407 lineText = state.src.slice(pos, max);
17409 if (HTML_SEQUENCES[i][1].test(lineText)) {
17410 if (lineText.length !== 0) { nextLine++; }
17416 state.line = nextLine;
17418 token = state.push('html_block', '', 0);
17419 token.map = [ startLine, nextLine ];
17420 token.content = state.getLines(startLine, nextLine, state.blkIndent, true);
17428 /***/ (function(module, exports, __webpack_require__) {
17431 // List of valid html blocks names, accorting to commonmark spec
17432 // http://jgm.github.io/CommonMark/spec.html#html-blocks
17506 /***/ (function(module, exports, __webpack_require__) {
17509 // Regexps to match html elements
17513 var attr_name = '[a-zA-Z_:][a-zA-Z0-9:._-]*';
17515 var unquoted = '[^"\'=<>`\\x00-\\x20]+';
17516 var single_quoted = "'[^']*'";
17517 var double_quoted = '"[^"]*"';
17519 var attr_value = '(?:' + unquoted + '|' + single_quoted + '|' + double_quoted + ')';
17521 var attribute = '(?:\\s+' + attr_name + '(?:\\s*=\\s*' + attr_value + ')?)';
17523 var open_tag = '<[A-Za-z][A-Za-z0-9\\-]*' + attribute + '*\\s*\\/?>';
17525 var close_tag = '<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>';
17526 var comment = '<!---->|<!--(?:-?[^>-])(?:-?[^-])*-->';
17527 var processing = '<[?].*?[?]>';
17528 var declaration = '<![A-Z]+\\s+[^>]*>';
17529 var cdata = '<!\\[CDATA\\[[\\s\\S]*?\\]\\]>';
17531 var HTML_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + '|' + comment +
17532 '|' + processing + '|' + declaration + '|' + cdata + ')');
17533 var HTML_OPEN_CLOSE_TAG_RE = new RegExp('^(?:' + open_tag + '|' + close_tag + ')');
17535 module.exports.HTML_TAG_RE = HTML_TAG_RE;
17536 module.exports.HTML_OPEN_CLOSE_TAG_RE = HTML_OPEN_CLOSE_TAG_RE;
17541 /***/ (function(module, exports, __webpack_require__) {
17549 module.exports = function paragraph(state, startLine/*, endLine*/) {
17550 var content, terminate, i, l, token, oldParentType,
17551 nextLine = startLine + 1,
17552 terminatorRules = state.md.block.ruler.getRules('paragraph'),
17553 endLine = state.lineMax;
17555 oldParentType = state.parentType;
17556 state.parentType = 'paragraph';
17558 // jump line-by-line until empty one or EOF
17559 for (; nextLine < endLine && !state.isEmpty(nextLine); nextLine++) {
17560 // this would be a code block normally, but after paragraph
17561 // it's considered a lazy continuation regardless of what's there
17562 if (state.sCount[nextLine] - state.blkIndent > 3) { continue; }
17564 // quirk for blockquotes, this line should already be checked by that rule
17565 if (state.sCount[nextLine] < 0) { continue; }
17567 // Some tags can terminate paragraph without empty line.
17569 for (i = 0, l = terminatorRules.length; i < l; i++) {
17570 if (terminatorRules[i](state, nextLine, endLine, true)) {
17575 if (terminate) { break; }
17578 content = state.getLines(startLine, nextLine, state.blkIndent, false).trim();
17580 state.line = nextLine;
17582 token = state.push('paragraph_open', 'p', 1);
17583 token.map = [ startLine, state.line ];
17585 token = state.push('inline', '', 0);
17586 token.content = content;
17587 token.map = [ startLine, state.line ];
17588 token.children = [];
17590 token = state.push('paragraph_close', 'p', -1);
17592 state.parentType = oldParentType;
17600 /***/ (function(module, exports, __webpack_require__) {
17603 // Parser state class
17607 var Token = __webpack_require__(70);
17608 var isSpace = __webpack_require__(42).isSpace;
17611 function StateBlock(src, md, env, tokens) {
17612 var ch, s, start, pos, len, indent, offset, indent_found;
17616 // link to parser instance
17622 // Internal state vartiables
17625 this.tokens = tokens;
17627 this.bMarks = []; // line begin offsets for fast jumps
17628 this.eMarks = []; // line end offsets for fast jumps
17629 this.tShift = []; // offsets of the first non-space characters (tabs not expanded)
17630 this.sCount = []; // indents for each line (tabs expanded)
17632 // An amount of virtual spaces (tabs expanded) between beginning
17633 // of each line (bMarks) and real beginning of that line.
17635 // It exists only as a hack because blockquotes override bMarks
17636 // losing information in the process.
17638 // It's used only when expanding tabs, you can think about it as
17639 // an initial tab length, e.g. bsCount=21 applied to string `\t123`
17640 // means first tab should be expanded to 4-21%4 === 3 spaces.
17644 // block parser variables
17645 this.blkIndent = 0; // required block content indent (for example, if we are
17646 // inside a list, it would be positioned after list marker)
17647 this.line = 0; // line index in src
17648 this.lineMax = 0; // lines count
17649 this.tight = false; // loose/tight mode for lists
17650 this.ddIndent = -1; // indent of the current dd block (-1 if there isn't any)
17651 this.listIndent = -1; // indent of the current list block (-1 if there isn't any)
17653 // can be 'blockquote', 'list', 'root', 'paragraph' or 'reference'
17654 // used in lists to determine if they interrupt a paragraph
17655 this.parentType = 'root';
17663 // Generate markers.
17665 indent_found = false;
17667 for (start = pos = indent = offset = 0, len = s.length; pos < len; pos++) {
17668 ch = s.charCodeAt(pos);
17670 if (!indent_found) {
17675 offset += 4 - offset % 4;
17681 indent_found = true;
17685 if (ch === 0x0A || pos === len - 1) {
17686 if (ch !== 0x0A) { pos++; }
17687 this.bMarks.push(start);
17688 this.eMarks.push(pos);
17689 this.tShift.push(indent);
17690 this.sCount.push(offset);
17691 this.bsCount.push(0);
17693 indent_found = false;
17700 // Push fake entry to simplify cache bounds checks
17701 this.bMarks.push(s.length);
17702 this.eMarks.push(s.length);
17703 this.tShift.push(0);
17704 this.sCount.push(0);
17705 this.bsCount.push(0);
17707 this.lineMax = this.bMarks.length - 1; // don't count last fake line
17710 // Push new token to "stream".
17712 StateBlock.prototype.push = function (type, tag, nesting) {
17713 var token = new Token(type, tag, nesting);
17714 token.block = true;
17716 if (nesting < 0) this.level--; // closing tag
17717 token.level = this.level;
17718 if (nesting > 0) this.level++; // opening tag
17720 this.tokens.push(token);
17724 StateBlock.prototype.isEmpty = function isEmpty(line) {
17725 return this.bMarks[line] + this.tShift[line] >= this.eMarks[line];
17728 StateBlock.prototype.skipEmptyLines = function skipEmptyLines(from) {
17729 for (var max = this.lineMax; from < max; from++) {
17730 if (this.bMarks[from] + this.tShift[from] < this.eMarks[from]) {
17737 // Skip spaces from given position.
17738 StateBlock.prototype.skipSpaces = function skipSpaces(pos) {
17741 for (var max = this.src.length; pos < max; pos++) {
17742 ch = this.src.charCodeAt(pos);
17743 if (!isSpace(ch)) { break; }
17748 // Skip spaces from given position in reverse.
17749 StateBlock.prototype.skipSpacesBack = function skipSpacesBack(pos, min) {
17750 if (pos <= min) { return pos; }
17752 while (pos > min) {
17753 if (!isSpace(this.src.charCodeAt(--pos))) { return pos + 1; }
17758 // Skip char codes from given position
17759 StateBlock.prototype.skipChars = function skipChars(pos, code) {
17760 for (var max = this.src.length; pos < max; pos++) {
17761 if (this.src.charCodeAt(pos) !== code) { break; }
17766 // Skip char codes reverse from given position - 1
17767 StateBlock.prototype.skipCharsBack = function skipCharsBack(pos, code, min) {
17768 if (pos <= min) { return pos; }
17770 while (pos > min) {
17771 if (code !== this.src.charCodeAt(--pos)) { return pos + 1; }
17776 // cut lines range from source.
17777 StateBlock.prototype.getLines = function getLines(begin, end, indent, keepLastLF) {
17778 var i, lineIndent, ch, first, last, queue, lineStart,
17781 if (begin >= end) {
17785 queue = new Array(end - begin);
17787 for (i = 0; line < end; line++, i++) {
17789 lineStart = first = this.bMarks[line];
17791 if (line + 1 < end || keepLastLF) {
17792 // No need for bounds check because we have fake entry on tail.
17793 last = this.eMarks[line] + 1;
17795 last = this.eMarks[line];
17798 while (first < last && lineIndent < indent) {
17799 ch = this.src.charCodeAt(first);
17803 lineIndent += 4 - (lineIndent + this.bsCount[line]) % 4;
17807 } else if (first - lineStart < this.tShift[line]) {
17808 // patched tShift masked characters to look like spaces (blockquotes, list markers)
17817 if (lineIndent > indent) {
17818 // partially expanding tabs in code blocks, e.g '\t\tfoobar'
17819 // with indent=2 becomes ' \tfoobar'
17820 queue[i] = new Array(lineIndent - indent + 1).join(' ') + this.src.slice(first, last);
17822 queue[i] = this.src.slice(first, last);
17826 return queue.join('');
17829 // re-export Token class to use in block rules
17830 StateBlock.prototype.Token = Token;
17833 module.exports = StateBlock;
17838 /***/ (function(module, exports, __webpack_require__) {
17842 * class ParserInline
17844 * Tokenizes paragraph content.
17849 var Ruler = __webpack_require__(62);
17852 ////////////////////////////////////////////////////////////////////////////////
17856 [ 'text', __webpack_require__(87) ],
17857 [ 'newline', __webpack_require__(88) ],
17858 [ 'escape', __webpack_require__(89) ],
17859 [ 'backticks', __webpack_require__(90) ],
17860 [ 'strikethrough', __webpack_require__(91).tokenize ],
17861 [ 'emphasis', __webpack_require__(92).tokenize ],
17862 [ 'link', __webpack_require__(93) ],
17863 [ 'image', __webpack_require__(94) ],
17864 [ 'autolink', __webpack_require__(95) ],
17865 [ 'html_inline', __webpack_require__(96) ],
17866 [ 'entity', __webpack_require__(97) ]
17870 [ 'balance_pairs', __webpack_require__(98) ],
17871 [ 'strikethrough', __webpack_require__(91).postProcess ],
17872 [ 'emphasis', __webpack_require__(92).postProcess ],
17873 [ 'text_collapse', __webpack_require__(99) ]
17878 * new ParserInline()
17880 function ParserInline() {
17884 * ParserInline#ruler -> Ruler
17886 * [[Ruler]] instance. Keep configuration of inline rules.
17888 this.ruler = new Ruler();
17890 for (i = 0; i < _rules.length; i++) {
17891 this.ruler.push(_rules[i][0], _rules[i][1]);
17895 * ParserInline#ruler2 -> Ruler
17897 * [[Ruler]] instance. Second ruler used for post-processing
17898 * (e.g. in emphasis-like rules).
17900 this.ruler2 = new Ruler();
17902 for (i = 0; i < _rules2.length; i++) {
17903 this.ruler2.push(_rules2[i][0], _rules2[i][1]);
17908 // Skip single token by running all rules in validation mode;
17909 // returns `true` if any rule reported success
17911 ParserInline.prototype.skipToken = function (state) {
17912 var ok, i, pos = state.pos,
17913 rules = this.ruler.getRules(''),
17914 len = rules.length,
17915 maxNesting = state.md.options.maxNesting,
17916 cache = state.cache;
17919 if (typeof cache[pos] !== 'undefined') {
17920 state.pos = cache[pos];
17924 if (state.level < maxNesting) {
17925 for (i = 0; i < len; i++) {
17926 // Increment state.level and decrement it later to limit recursion.
17927 // It's harmless to do here, because no tokens are created. But ideally,
17928 // we'd need a separate private state variable for this purpose.
17931 ok = rules[i](state, true);
17937 // Too much nesting, just skip until the end of the paragraph.
17939 // NOTE: this will cause links to behave incorrectly in the following case,
17940 // when an amount of `[` is exactly equal to `maxNesting + 1`:
17942 // [[[[[[[[[[[[[[[[[[[[[foo]()
17944 // TODO: remove this workaround when CM standard will allow nested links
17945 // (we can replace it by preventing links from being parsed in
17946 // validation mode)
17948 state.pos = state.posMax;
17951 if (!ok) { state.pos++; }
17952 cache[pos] = state.pos;
17956 // Generate tokens for input range
17958 ParserInline.prototype.tokenize = function (state) {
17960 rules = this.ruler.getRules(''),
17961 len = rules.length,
17962 end = state.posMax,
17963 maxNesting = state.md.options.maxNesting;
17965 while (state.pos < end) {
17966 // Try all possible rules.
17967 // On success, rule should:
17969 // - update `state.pos`
17970 // - update `state.tokens`
17973 if (state.level < maxNesting) {
17974 for (i = 0; i < len; i++) {
17975 ok = rules[i](state, false);
17981 if (state.pos >= end) { break; }
17985 state.pending += state.src[state.pos++];
17988 if (state.pending) {
17989 state.pushPending();
17995 * ParserInline.parse(str, md, env, outTokens)
17997 * Process input string and push inline tokens into `outTokens`
17999 ParserInline.prototype.parse = function (str, md, env, outTokens) {
18001 var state = new this.State(str, md, env, outTokens);
18003 this.tokenize(state);
18005 rules = this.ruler2.getRules('');
18006 len = rules.length;
18008 for (i = 0; i < len; i++) {
18014 ParserInline.prototype.State = __webpack_require__(100);
18017 module.exports = ParserInline;
18022 /***/ (function(module, exports, __webpack_require__) {
18025 // Skip text characters for text token, place those to pending buffer
18026 // and increment current pos
18031 // Rule to skip pure text
18032 // '{}$%@~+=:' reserved for extentions
18034 // !, ", #, $, %, &, ', (, ), *, +, ,, -, ., /, :, ;, <, =, >, ?, @, [, \, ], ^, _, `, {, |, }, or ~
18036 // !!!! Don't confuse with "Markdown ASCII Punctuation" chars
18037 // http://spec.commonmark.org/0.15/#ascii-punctuation-character
18038 function isTerminatorChar(ch) {
18069 module.exports = function text(state, silent) {
18070 var pos = state.pos;
18072 while (pos < state.posMax && !isTerminatorChar(state.src.charCodeAt(pos))) {
18076 if (pos === state.pos) { return false; }
18078 if (!silent) { state.pending += state.src.slice(state.pos, pos); }
18085 // Alternative implementation, for memory.
18087 // It costs 10% of performance, but allows extend terminators list, if place it
18088 // to `ParcerInline` property. Probably, will switch to it sometime, such
18089 // flexibility required.
18092 var TERMINATOR_RE = /[\n!#$%&*+\-:<=>@[\\\]^_`{}~]/;
18094 module.exports = function text(state, silent) {
18095 var pos = state.pos,
18096 idx = state.src.slice(pos).search(TERMINATOR_RE);
18098 // first char is terminator -> empty text
18099 if (idx === 0) { return false; }
18101 // no terminator -> text till end of string
18103 if (!silent) { state.pending += state.src.slice(pos); }
18104 state.pos = state.src.length;
18108 if (!silent) { state.pending += state.src.slice(pos, pos + idx); }
18118 /***/ (function(module, exports, __webpack_require__) {
18125 var isSpace = __webpack_require__(42).isSpace;
18128 module.exports = function newline(state, silent) {
18129 var pmax, max, pos = state.pos;
18131 if (state.src.charCodeAt(pos) !== 0x0A/* \n */) { return false; }
18133 pmax = state.pending.length - 1;
18134 max = state.posMax;
18136 // ' \n' -> hardbreak
18137 // Lookup in pending chars is bad practice! Don't copy to other rules!
18138 // Pending string is stored in concat mode, indexed lookups will cause
18139 // convertion to flat mode.
18141 if (pmax >= 0 && state.pending.charCodeAt(pmax) === 0x20) {
18142 if (pmax >= 1 && state.pending.charCodeAt(pmax - 1) === 0x20) {
18143 state.pending = state.pending.replace(/ +$/, '');
18144 state.push('hardbreak', 'br', 0);
18146 state.pending = state.pending.slice(0, -1);
18147 state.push('softbreak', 'br', 0);
18151 state.push('softbreak', 'br', 0);
18157 // skip heading spaces for next line
18158 while (pos < max && isSpace(state.src.charCodeAt(pos))) { pos++; }
18167 /***/ (function(module, exports, __webpack_require__) {
18170 // Process escaped chars and hardbreaks
18174 var isSpace = __webpack_require__(42).isSpace;
18178 for (var i = 0; i < 256; i++) { ESCAPED.push(0); }
18180 '\\!"#$%&\'()*+,./:;<=>?@[]^_`{|}~-'
18181 .split('').forEach(function (ch) { ESCAPED[ch.charCodeAt(0)] = 1; });
18184 module.exports = function escape(state, silent) {
18185 var ch, pos = state.pos, max = state.posMax;
18187 if (state.src.charCodeAt(pos) !== 0x5C/* \ */) { return false; }
18192 ch = state.src.charCodeAt(pos);
18194 if (ch < 256 && ESCAPED[ch] !== 0) {
18195 if (!silent) { state.pending += state.src[pos]; }
18202 state.push('hardbreak', 'br', 0);
18206 // skip leading whitespaces from next line
18207 while (pos < max) {
18208 ch = state.src.charCodeAt(pos);
18209 if (!isSpace(ch)) { break; }
18218 if (!silent) { state.pending += '\\'; }
18226 /***/ (function(module, exports, __webpack_require__) {
18233 module.exports = function backtick(state, silent) {
18234 var start, max, marker, matchStart, matchEnd, token,
18236 ch = state.src.charCodeAt(pos);
18238 if (ch !== 0x60/* ` */) { return false; }
18242 max = state.posMax;
18244 while (pos < max && state.src.charCodeAt(pos) === 0x60/* ` */) { pos++; }
18246 marker = state.src.slice(start, pos);
18248 matchStart = matchEnd = pos;
18250 while ((matchStart = state.src.indexOf('`', matchEnd)) !== -1) {
18251 matchEnd = matchStart + 1;
18253 while (matchEnd < max && state.src.charCodeAt(matchEnd) === 0x60/* ` */) { matchEnd++; }
18255 if (matchEnd - matchStart === marker.length) {
18257 token = state.push('code_inline', 'code', 0);
18258 token.markup = marker;
18259 token.content = state.src.slice(pos, matchStart)
18260 .replace(/\n/g, ' ')
18261 .replace(/^ (.+) $/, '$1');
18263 state.pos = matchEnd;
18268 if (!silent) { state.pending += marker; }
18269 state.pos += marker.length;
18276 /***/ (function(module, exports, __webpack_require__) {
18279 // ~~strike through~~
18284 // Insert each marker as a separate text token, and add it to delimiter list
18286 module.exports.tokenize = function strikethrough(state, silent) {
18287 var i, scanned, token, len, ch,
18289 marker = state.src.charCodeAt(start);
18291 if (silent) { return false; }
18293 if (marker !== 0x7E/* ~ */) { return false; }
18295 scanned = state.scanDelims(state.pos, true);
18296 len = scanned.length;
18297 ch = String.fromCharCode(marker);
18299 if (len < 2) { return false; }
18302 token = state.push('text', '', 0);
18303 token.content = ch;
18307 for (i = 0; i < len; i += 2) {
18308 token = state.push('text', '', 0);
18309 token.content = ch + ch;
18311 state.delimiters.push({
18313 length: 0, // disable "rule of 3" length checks meant for emphasis
18315 token: state.tokens.length - 1,
18317 open: scanned.can_open,
18318 close: scanned.can_close
18322 state.pos += scanned.length;
18328 function postProcess(state, delimiters) {
18334 max = delimiters.length;
18336 for (i = 0; i < max; i++) {
18337 startDelim = delimiters[i];
18339 if (startDelim.marker !== 0x7E/* ~ */) {
18343 if (startDelim.end === -1) {
18347 endDelim = delimiters[startDelim.end];
18349 token = state.tokens[startDelim.token];
18350 token.type = 's_open';
18353 token.markup = '~~';
18354 token.content = '';
18356 token = state.tokens[endDelim.token];
18357 token.type = 's_close';
18359 token.nesting = -1;
18360 token.markup = '~~';
18361 token.content = '';
18363 if (state.tokens[endDelim.token - 1].type === 'text' &&
18364 state.tokens[endDelim.token - 1].content === '~') {
18366 loneMarkers.push(endDelim.token - 1);
18370 // If a marker sequence has an odd number of characters, it's splitted
18371 // like this: `~~~~~` -> `~` + `~~` + `~~`, leaving one marker at the
18372 // start of the sequence.
18374 // So, we have to move all those markers after subsequent s_close tags.
18376 while (loneMarkers.length) {
18377 i = loneMarkers.pop();
18380 while (j < state.tokens.length && state.tokens[j].type === 's_close') {
18387 token = state.tokens[j];
18388 state.tokens[j] = state.tokens[i];
18389 state.tokens[i] = token;
18395 // Walk through delimiter list and replace text tokens with tags
18397 module.exports.postProcess = function strikethrough(state) {
18399 tokens_meta = state.tokens_meta,
18400 max = state.tokens_meta.length;
18402 postProcess(state, state.delimiters);
18404 for (curr = 0; curr < max; curr++) {
18405 if (tokens_meta[curr] && tokens_meta[curr].delimiters) {
18406 postProcess(state, tokens_meta[curr].delimiters);
18414 /***/ (function(module, exports, __webpack_require__) {
18417 // Process *this* and _that_
18422 // Insert each marker as a separate text token, and add it to delimiter list
18424 module.exports.tokenize = function emphasis(state, silent) {
18425 var i, scanned, token,
18427 marker = state.src.charCodeAt(start);
18429 if (silent) { return false; }
18431 if (marker !== 0x5F /* _ */ && marker !== 0x2A /* * */) { return false; }
18433 scanned = state.scanDelims(state.pos, marker === 0x2A);
18435 for (i = 0; i < scanned.length; i++) {
18436 token = state.push('text', '', 0);
18437 token.content = String.fromCharCode(marker);
18439 state.delimiters.push({
18440 // Char code of the starting marker (number).
18444 // Total length of these series of delimiters.
18446 length: scanned.length,
18448 // An amount of characters before this one that's equivalent to
18449 // current one. In plain English: if this delimiter does not open
18450 // an emphasis, neither do previous `jump` characters.
18452 // Used to skip sequences like "*****" in one step, for 1st asterisk
18453 // value will be 0, for 2nd it's 1 and so on.
18457 // A position of the token this delimiter corresponds to.
18459 token: state.tokens.length - 1,
18461 // If this delimiter is matched as a valid opener, `end` will be
18462 // equal to its position, otherwise it's `-1`.
18466 // Boolean flags that determine if this delimiter could open or close
18469 open: scanned.can_open,
18470 close: scanned.can_close
18474 state.pos += scanned.length;
18480 function postProcess(state, delimiters) {
18487 max = delimiters.length;
18489 for (i = max - 1; i >= 0; i--) {
18490 startDelim = delimiters[i];
18492 if (startDelim.marker !== 0x5F/* _ */ && startDelim.marker !== 0x2A/* * */) {
18496 // Process only opening markers
18497 if (startDelim.end === -1) {
18501 endDelim = delimiters[startDelim.end];
18503 // If the previous delimiter has the same marker and is adjacent to this one,
18504 // merge those into one strong delimiter.
18506 // `<em><em>whatever</em></em>` -> `<strong>whatever</strong>`
18508 isStrong = i > 0 &&
18509 delimiters[i - 1].end === startDelim.end + 1 &&
18510 delimiters[i - 1].token === startDelim.token - 1 &&
18511 delimiters[startDelim.end + 1].token === endDelim.token + 1 &&
18512 delimiters[i - 1].marker === startDelim.marker;
18514 ch = String.fromCharCode(startDelim.marker);
18516 token = state.tokens[startDelim.token];
18517 token.type = isStrong ? 'strong_open' : 'em_open';
18518 token.tag = isStrong ? 'strong' : 'em';
18520 token.markup = isStrong ? ch + ch : ch;
18521 token.content = '';
18523 token = state.tokens[endDelim.token];
18524 token.type = isStrong ? 'strong_close' : 'em_close';
18525 token.tag = isStrong ? 'strong' : 'em';
18526 token.nesting = -1;
18527 token.markup = isStrong ? ch + ch : ch;
18528 token.content = '';
18531 state.tokens[delimiters[i - 1].token].content = '';
18532 state.tokens[delimiters[startDelim.end + 1].token].content = '';
18539 // Walk through delimiter list and replace text tokens with tags
18541 module.exports.postProcess = function emphasis(state) {
18543 tokens_meta = state.tokens_meta,
18544 max = state.tokens_meta.length;
18546 postProcess(state, state.delimiters);
18548 for (curr = 0; curr < max; curr++) {
18549 if (tokens_meta[curr] && tokens_meta[curr].delimiters) {
18550 postProcess(state, tokens_meta[curr].delimiters);
18558 /***/ (function(module, exports, __webpack_require__) {
18561 // Process [link](<to> "stuff")
18565 var normalizeReference = __webpack_require__(42).normalizeReference;
18566 var isSpace = __webpack_require__(42).isSpace;
18569 module.exports = function link(state, silent) {
18581 oldPos = state.pos,
18582 max = state.posMax,
18584 parseReference = true;
18586 if (state.src.charCodeAt(state.pos) !== 0x5B/* [ */) { return false; }
18588 labelStart = state.pos + 1;
18589 labelEnd = state.md.helpers.parseLinkLabel(state, state.pos, true);
18591 // parser failed to find ']', so it's not a valid link
18592 if (labelEnd < 0) { return false; }
18594 pos = labelEnd + 1;
18595 if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) {
18600 // might have found a valid shortcut link, disable reference parsing
18601 parseReference = false;
18603 // [link]( <href> "title" )
18604 // ^^ skipping these spaces
18606 for (; pos < max; pos++) {
18607 code = state.src.charCodeAt(pos);
18608 if (!isSpace(code) && code !== 0x0A) { break; }
18610 if (pos >= max) { return false; }
18612 // [link]( <href> "title" )
18613 // ^^^^^^ parsing link destination
18615 res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax);
18617 href = state.md.normalizeLink(res.str);
18618 if (state.md.validateLink(href)) {
18625 // [link]( <href> "title" )
18626 // ^^ skipping these spaces
18628 for (; pos < max; pos++) {
18629 code = state.src.charCodeAt(pos);
18630 if (!isSpace(code) && code !== 0x0A) { break; }
18633 // [link]( <href> "title" )
18634 // ^^^^^^^ parsing link title
18635 res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax);
18636 if (pos < max && start !== pos && res.ok) {
18640 // [link]( <href> "title" )
18641 // ^^ skipping these spaces
18642 for (; pos < max; pos++) {
18643 code = state.src.charCodeAt(pos);
18644 if (!isSpace(code) && code !== 0x0A) { break; }
18650 if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) {
18651 // parsing a valid shortcut link failed, fallback to reference
18652 parseReference = true;
18657 if (parseReference) {
18661 if (typeof state.env.references === 'undefined') { return false; }
18663 if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) {
18665 pos = state.md.helpers.parseLinkLabel(state, pos);
18667 label = state.src.slice(start, pos++);
18669 pos = labelEnd + 1;
18672 pos = labelEnd + 1;
18675 // covers label === '' and label === undefined
18676 // (collapsed reference link and shortcut reference link respectively)
18677 if (!label) { label = state.src.slice(labelStart, labelEnd); }
18679 ref = state.env.references[normalizeReference(label)];
18681 state.pos = oldPos;
18689 // We found the end of the link, and know for a fact it's a valid link;
18690 // so all that's left to do is to call tokenizer.
18693 state.pos = labelStart;
18694 state.posMax = labelEnd;
18696 token = state.push('link_open', 'a', 1);
18697 token.attrs = attrs = [ [ 'href', href ] ];
18699 attrs.push([ 'title', title ]);
18702 state.md.inline.tokenize(state);
18704 token = state.push('link_close', 'a', -1);
18708 state.posMax = max;
18715 /***/ (function(module, exports, __webpack_require__) {
18718 // Process ![image](<src> "title")
18722 var normalizeReference = __webpack_require__(42).normalizeReference;
18723 var isSpace = __webpack_require__(42).isSpace;
18726 module.exports = function image(state, silent) {
18741 oldPos = state.pos,
18742 max = state.posMax;
18744 if (state.src.charCodeAt(state.pos) !== 0x21/* ! */) { return false; }
18745 if (state.src.charCodeAt(state.pos + 1) !== 0x5B/* [ */) { return false; }
18747 labelStart = state.pos + 2;
18748 labelEnd = state.md.helpers.parseLinkLabel(state, state.pos + 1, false);
18750 // parser failed to find ']', so it's not a valid link
18751 if (labelEnd < 0) { return false; }
18753 pos = labelEnd + 1;
18754 if (pos < max && state.src.charCodeAt(pos) === 0x28/* ( */) {
18759 // [link]( <href> "title" )
18760 // ^^ skipping these spaces
18762 for (; pos < max; pos++) {
18763 code = state.src.charCodeAt(pos);
18764 if (!isSpace(code) && code !== 0x0A) { break; }
18766 if (pos >= max) { return false; }
18768 // [link]( <href> "title" )
18769 // ^^^^^^ parsing link destination
18771 res = state.md.helpers.parseLinkDestination(state.src, pos, state.posMax);
18773 href = state.md.normalizeLink(res.str);
18774 if (state.md.validateLink(href)) {
18781 // [link]( <href> "title" )
18782 // ^^ skipping these spaces
18784 for (; pos < max; pos++) {
18785 code = state.src.charCodeAt(pos);
18786 if (!isSpace(code) && code !== 0x0A) { break; }
18789 // [link]( <href> "title" )
18790 // ^^^^^^^ parsing link title
18791 res = state.md.helpers.parseLinkTitle(state.src, pos, state.posMax);
18792 if (pos < max && start !== pos && res.ok) {
18796 // [link]( <href> "title" )
18797 // ^^ skipping these spaces
18798 for (; pos < max; pos++) {
18799 code = state.src.charCodeAt(pos);
18800 if (!isSpace(code) && code !== 0x0A) { break; }
18806 if (pos >= max || state.src.charCodeAt(pos) !== 0x29/* ) */) {
18807 state.pos = oldPos;
18815 if (typeof state.env.references === 'undefined') { return false; }
18817 if (pos < max && state.src.charCodeAt(pos) === 0x5B/* [ */) {
18819 pos = state.md.helpers.parseLinkLabel(state, pos);
18821 label = state.src.slice(start, pos++);
18823 pos = labelEnd + 1;
18826 pos = labelEnd + 1;
18829 // covers label === '' and label === undefined
18830 // (collapsed reference link and shortcut reference link respectively)
18831 if (!label) { label = state.src.slice(labelStart, labelEnd); }
18833 ref = state.env.references[normalizeReference(label)];
18835 state.pos = oldPos;
18843 // We found the end of the link, and know for a fact it's a valid link;
18844 // so all that's left to do is to call tokenizer.
18847 content = state.src.slice(labelStart, labelEnd);
18849 state.md.inline.parse(
18856 token = state.push('image', 'img', 0);
18857 token.attrs = attrs = [ [ 'src', href ], [ 'alt', '' ] ];
18858 token.children = tokens;
18859 token.content = content;
18862 attrs.push([ 'title', title ]);
18867 state.posMax = max;
18874 /***/ (function(module, exports, __webpack_require__) {
18877 // Process autolinks '<protocol:...>'
18882 /*eslint max-len:0*/
18883 var EMAIL_RE = /^<([a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)>/;
18884 var AUTOLINK_RE = /^<([a-zA-Z][a-zA-Z0-9+.\-]{1,31}):([^<>\x00-\x20]*)>/;
18887 module.exports = function autolink(state, silent) {
18888 var tail, linkMatch, emailMatch, url, fullUrl, token,
18891 if (state.src.charCodeAt(pos) !== 0x3C/* < */) { return false; }
18893 tail = state.src.slice(pos);
18895 if (tail.indexOf('>') < 0) { return false; }
18897 if (AUTOLINK_RE.test(tail)) {
18898 linkMatch = tail.match(AUTOLINK_RE);
18900 url = linkMatch[0].slice(1, -1);
18901 fullUrl = state.md.normalizeLink(url);
18902 if (!state.md.validateLink(fullUrl)) { return false; }
18905 token = state.push('link_open', 'a', 1);
18906 token.attrs = [ [ 'href', fullUrl ] ];
18907 token.markup = 'autolink';
18908 token.info = 'auto';
18910 token = state.push('text', '', 0);
18911 token.content = state.md.normalizeLinkText(url);
18913 token = state.push('link_close', 'a', -1);
18914 token.markup = 'autolink';
18915 token.info = 'auto';
18918 state.pos += linkMatch[0].length;
18922 if (EMAIL_RE.test(tail)) {
18923 emailMatch = tail.match(EMAIL_RE);
18925 url = emailMatch[0].slice(1, -1);
18926 fullUrl = state.md.normalizeLink('mailto:' + url);
18927 if (!state.md.validateLink(fullUrl)) { return false; }
18930 token = state.push('link_open', 'a', 1);
18931 token.attrs = [ [ 'href', fullUrl ] ];
18932 token.markup = 'autolink';
18933 token.info = 'auto';
18935 token = state.push('text', '', 0);
18936 token.content = state.md.normalizeLinkText(url);
18938 token = state.push('link_close', 'a', -1);
18939 token.markup = 'autolink';
18940 token.info = 'auto';
18943 state.pos += emailMatch[0].length;
18953 /***/ (function(module, exports, __webpack_require__) {
18956 // Process html tags
18961 var HTML_TAG_RE = __webpack_require__(83).HTML_TAG_RE;
18964 function isLetter(ch) {
18965 /*eslint no-bitwise:0*/
18966 var lc = ch | 0x20; // to lower case
18967 return (lc >= 0x61/* a */) && (lc <= 0x7a/* z */);
18971 module.exports = function html_inline(state, silent) {
18972 var ch, match, max, token,
18975 if (!state.md.options.html) { return false; }
18978 max = state.posMax;
18979 if (state.src.charCodeAt(pos) !== 0x3C/* < */ ||
18984 // Quick fail on second char
18985 ch = state.src.charCodeAt(pos + 1);
18986 if (ch !== 0x21/* ! */ &&
18987 ch !== 0x3F/* ? */ &&
18988 ch !== 0x2F/* / */ &&
18993 match = state.src.slice(pos).match(HTML_TAG_RE);
18994 if (!match) { return false; }
18997 token = state.push('html_inline', '', 0);
18998 token.content = state.src.slice(pos, pos + match[0].length);
19000 state.pos += match[0].length;
19007 /***/ (function(module, exports, __webpack_require__) {
19010 // Process html entity - {, ¯, ", ...
19014 var entities = __webpack_require__(43);
19015 var has = __webpack_require__(42).has;
19016 var isValidEntityCode = __webpack_require__(42).isValidEntityCode;
19017 var fromCodePoint = __webpack_require__(42).fromCodePoint;
19020 var DIGITAL_RE = /^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i;
19021 var NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i;
19024 module.exports = function entity(state, silent) {
19025 var ch, code, match, pos = state.pos, max = state.posMax;
19027 if (state.src.charCodeAt(pos) !== 0x26/* & */) { return false; }
19029 if (pos + 1 < max) {
19030 ch = state.src.charCodeAt(pos + 1);
19032 if (ch === 0x23 /* # */) {
19033 match = state.src.slice(pos).match(DIGITAL_RE);
19036 code = match[1][0].toLowerCase() === 'x' ? parseInt(match[1].slice(1), 16) : parseInt(match[1], 10);
19037 state.pending += isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(0xFFFD);
19039 state.pos += match[0].length;
19043 match = state.src.slice(pos).match(NAMED_RE);
19045 if (has(entities, match[1])) {
19046 if (!silent) { state.pending += entities[match[1]]; }
19047 state.pos += match[0].length;
19054 if (!silent) { state.pending += '&'; }
19062 /***/ (function(module, exports, __webpack_require__) {
19065 // For each opening emphasis-like marker find a matching closing one
19070 function processDelimiters(state, delimiters) {
19071 var closerIdx, openerIdx, closer, opener, minOpenerIdx, newMinOpenerIdx,
19072 isOddMatch, lastJump,
19073 openersBottom = {},
19074 max = delimiters.length;
19076 for (closerIdx = 0; closerIdx < max; closerIdx++) {
19077 closer = delimiters[closerIdx];
19079 // Length is only used for emphasis-specific "rule of 3",
19080 // if it's not defined (in strikethrough or 3rd party plugins),
19081 // we can default it to 0 to disable those checks.
19083 closer.length = closer.length || 0;
19085 if (!closer.close) continue;
19087 // Previously calculated lower bounds (previous fails)
19088 // for each marker and each delimiter length modulo 3.
19089 if (!openersBottom.hasOwnProperty(closer.marker)) {
19090 openersBottom[closer.marker] = [ -1, -1, -1 ];
19093 minOpenerIdx = openersBottom[closer.marker][closer.length % 3];
19094 newMinOpenerIdx = -1;
19096 openerIdx = closerIdx - closer.jump - 1;
19098 for (; openerIdx > minOpenerIdx; openerIdx -= opener.jump + 1) {
19099 opener = delimiters[openerIdx];
19101 if (opener.marker !== closer.marker) continue;
19103 if (newMinOpenerIdx === -1) newMinOpenerIdx = openerIdx;
19107 opener.level === closer.level) {
19109 isOddMatch = false;
19113 // If one of the delimiters can both open and close emphasis, then the
19114 // sum of the lengths of the delimiter runs containing the opening and
19115 // closing delimiters must not be a multiple of 3 unless both lengths
19116 // are multiples of 3.
19118 if (opener.close || closer.open) {
19119 if ((opener.length + closer.length) % 3 === 0) {
19120 if (opener.length % 3 !== 0 || closer.length % 3 !== 0) {
19127 // If previous delimiter cannot be an opener, we can safely skip
19128 // the entire sequence in future checks. This is required to make
19129 // sure algorithm has linear complexity (see *_*_*_*_*_... case).
19131 lastJump = openerIdx > 0 && !delimiters[openerIdx - 1].open ?
19132 delimiters[openerIdx - 1].jump + 1 :
19135 closer.jump = closerIdx - openerIdx + lastJump;
19136 closer.open = false;
19137 opener.end = closerIdx;
19138 opener.jump = lastJump;
19139 opener.close = false;
19140 newMinOpenerIdx = -1;
19146 if (newMinOpenerIdx !== -1) {
19147 // If match for this delimiter run failed, we want to set lower bound for
19148 // future lookups. This is required to make sure algorithm has linear
19151 // See details here:
19152 // https://github.com/commonmark/cmark/issues/178#issuecomment-270417442
19154 openersBottom[closer.marker][(closer.length || 0) % 3] = newMinOpenerIdx;
19160 module.exports = function link_pairs(state) {
19162 tokens_meta = state.tokens_meta,
19163 max = state.tokens_meta.length;
19165 processDelimiters(state, state.delimiters);
19167 for (curr = 0; curr < max; curr++) {
19168 if (tokens_meta[curr] && tokens_meta[curr].delimiters) {
19169 processDelimiters(state, tokens_meta[curr].delimiters);
19177 /***/ (function(module, exports, __webpack_require__) {
19180 // Clean up tokens after emphasis and strikethrough postprocessing:
19181 // merge adjacent text nodes into one and re-calculate all token levels
19183 // This is necessary because initially emphasis delimiter markers (*, _, ~)
19184 // are treated as their own separate text tokens. Then emphasis rule either
19185 // leaves them as text (needed to merge with adjacent text) or turns them
19186 // into opening/closing tags (which messes up levels inside).
19191 module.exports = function text_collapse(state) {
19194 tokens = state.tokens,
19195 max = state.tokens.length;
19197 for (curr = last = 0; curr < max; curr++) {
19198 // re-calculate levels after emphasis/strikethrough turns some text nodes
19199 // into opening/closing tags
19200 if (tokens[curr].nesting < 0) level--; // closing tag
19201 tokens[curr].level = level;
19202 if (tokens[curr].nesting > 0) level++; // opening tag
19204 if (tokens[curr].type === 'text' &&
19206 tokens[curr + 1].type === 'text') {
19208 // collapse two adjacent text nodes
19209 tokens[curr + 1].content = tokens[curr].content + tokens[curr + 1].content;
19211 if (curr !== last) { tokens[last] = tokens[curr]; }
19217 if (curr !== last) {
19218 tokens.length = last;
19225 /***/ (function(module, exports, __webpack_require__) {
19228 // Inline parser state
19233 var Token = __webpack_require__(70);
19234 var isWhiteSpace = __webpack_require__(42).isWhiteSpace;
19235 var isPunctChar = __webpack_require__(42).isPunctChar;
19236 var isMdAsciiPunct = __webpack_require__(42).isMdAsciiPunct;
19239 function StateInline(src, md, env, outTokens) {
19243 this.tokens = outTokens;
19244 this.tokens_meta = Array(outTokens.length);
19247 this.posMax = this.src.length;
19250 this.pendingLevel = 0;
19252 // Stores { start: end } pairs. Useful for backtrack
19253 // optimization of pairs parse (emphasis, strikes).
19256 // List of emphasis-like delimiters for current tag
19257 this.delimiters = [];
19259 // Stack of delimiter lists for upper level tags
19260 this._prev_delimiters = [];
19264 // Flush pending text
19266 StateInline.prototype.pushPending = function () {
19267 var token = new Token('text', '', 0);
19268 token.content = this.pending;
19269 token.level = this.pendingLevel;
19270 this.tokens.push(token);
19276 // Push new token to "stream".
19277 // If pending text exists - flush it as text token
19279 StateInline.prototype.push = function (type, tag, nesting) {
19280 if (this.pending) {
19281 this.pushPending();
19284 var token = new Token(type, tag, nesting);
19285 var token_meta = null;
19290 this.delimiters = this._prev_delimiters.pop();
19293 token.level = this.level;
19298 this._prev_delimiters.push(this.delimiters);
19299 this.delimiters = [];
19300 token_meta = { delimiters: this.delimiters };
19303 this.pendingLevel = this.level;
19304 this.tokens.push(token);
19305 this.tokens_meta.push(token_meta);
19310 // Scan a sequence of emphasis-like markers, and determine whether
19311 // it can start an emphasis sequence or end an emphasis sequence.
19313 // - start - position to scan from (it should point at a valid marker);
19314 // - canSplitWord - determine if these markers can be found inside a word
19316 StateInline.prototype.scanDelims = function (start, canSplitWord) {
19317 var pos = start, lastChar, nextChar, count, can_open, can_close,
19318 isLastWhiteSpace, isLastPunctChar,
19319 isNextWhiteSpace, isNextPunctChar,
19320 left_flanking = true,
19321 right_flanking = true,
19323 marker = this.src.charCodeAt(start);
19325 // treat beginning of the line as a whitespace
19326 lastChar = start > 0 ? this.src.charCodeAt(start - 1) : 0x20;
19328 while (pos < max && this.src.charCodeAt(pos) === marker) { pos++; }
19330 count = pos - start;
19332 // treat end of the line as a whitespace
19333 nextChar = pos < max ? this.src.charCodeAt(pos) : 0x20;
19335 isLastPunctChar = isMdAsciiPunct(lastChar) || isPunctChar(String.fromCharCode(lastChar));
19336 isNextPunctChar = isMdAsciiPunct(nextChar) || isPunctChar(String.fromCharCode(nextChar));
19338 isLastWhiteSpace = isWhiteSpace(lastChar);
19339 isNextWhiteSpace = isWhiteSpace(nextChar);
19341 if (isNextWhiteSpace) {
19342 left_flanking = false;
19343 } else if (isNextPunctChar) {
19344 if (!(isLastWhiteSpace || isLastPunctChar)) {
19345 left_flanking = false;
19349 if (isLastWhiteSpace) {
19350 right_flanking = false;
19351 } else if (isLastPunctChar) {
19352 if (!(isNextWhiteSpace || isNextPunctChar)) {
19353 right_flanking = false;
19357 if (!canSplitWord) {
19358 can_open = left_flanking && (!right_flanking || isLastPunctChar);
19359 can_close = right_flanking && (!left_flanking || isNextPunctChar);
19361 can_open = left_flanking;
19362 can_close = right_flanking;
19366 can_open: can_open,
19367 can_close: can_close,
19373 // re-export Token class to use in block rules
19374 StateInline.prototype.Token = Token;
19377 module.exports = StateInline;
19382 /***/ (function(module, exports, __webpack_require__) {
19388 ////////////////////////////////////////////////////////////////////////////////
19393 function assign(obj /*from1, from2, from3, ...*/) {
19394 var sources = Array.prototype.slice.call(arguments, 1);
19396 sources.forEach(function (source) {
19397 if (!source) { return; }
19399 Object.keys(source).forEach(function (key) {
19400 obj[key] = source[key];
19407 function _class(obj) { return Object.prototype.toString.call(obj); }
19408 function isString(obj) { return _class(obj) === '[object String]'; }
19409 function isObject(obj) { return _class(obj) === '[object Object]'; }
19410 function isRegExp(obj) { return _class(obj) === '[object RegExp]'; }
19411 function isFunction(obj) { return _class(obj) === '[object Function]'; }
19414 function escapeRE(str) { return str.replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&'); }
19416 ////////////////////////////////////////////////////////////////////////////////
19419 var defaultOptions = {
19426 function isOptionsObj(obj) {
19427 return Object.keys(obj || {}).reduce(function (acc, k) {
19428 return acc || defaultOptions.hasOwnProperty(k);
19433 var defaultSchemas = {
19435 validate: function (text, pos, self) {
19436 var tail = text.slice(pos);
19438 if (!self.re.http) {
19439 // compile lazily, because "host"-containing variables can change on tlds update.
19440 self.re.http = new RegExp(
19441 '^\\/\\/' + self.re.src_auth + self.re.src_host_port_strict + self.re.src_path, 'i'
19444 if (self.re.http.test(tail)) {
19445 return tail.match(self.re.http)[0].length;
19453 validate: function (text, pos, self) {
19454 var tail = text.slice(pos);
19456 if (!self.re.no_http) {
19457 // compile lazily, because "host"-containing variables can change on tlds update.
19458 self.re.no_http = new RegExp(
19461 // Don't allow single-level domains, because of false positives like '//test'
19462 // with code comments
19463 '(?:localhost|(?:(?:' + self.re.src_domain + ')\\.)+' + self.re.src_domain_root + ')' +
19465 self.re.src_host_terminator +
19472 if (self.re.no_http.test(tail)) {
19473 // should not be `://` & `///`, that protects from errors in protocol name
19474 if (pos >= 3 && text[pos - 3] === ':') { return 0; }
19475 if (pos >= 3 && text[pos - 3] === '/') { return 0; }
19476 return tail.match(self.re.no_http)[0].length;
19482 validate: function (text, pos, self) {
19483 var tail = text.slice(pos);
19485 if (!self.re.mailto) {
19486 self.re.mailto = new RegExp(
19487 '^' + self.re.src_email_name + '@' + self.re.src_host_strict, 'i'
19490 if (self.re.mailto.test(tail)) {
19491 return tail.match(self.re.mailto)[0].length;
19498 /*eslint-disable max-len*/
19500 // RE pattern for 2-character tlds (autogenerated by ./support/tlds_2char_gen.js)
19501 var tlds_2ch_src_re = 'a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]';
19503 // DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead
19504 var tlds_default = 'biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф'.split('|');
19506 /*eslint-enable max-len*/
19508 ////////////////////////////////////////////////////////////////////////////////
19510 function resetScanCache(self) {
19511 self.__index__ = -1;
19512 self.__text_cache__ = '';
19515 function createValidator(re) {
19516 return function (text, pos) {
19517 var tail = text.slice(pos);
19519 if (re.test(tail)) {
19520 return tail.match(re)[0].length;
19526 function createNormalizer() {
19527 return function (match, self) {
19528 self.normalize(match);
19532 // Schemas compiler. Build regexps.
19534 function compile(self) {
19536 // Load & clone RE patterns.
19537 var re = self.re = __webpack_require__(102)(self.__opts__);
19539 // Define dynamic patterns
19540 var tlds = self.__tlds__.slice();
19544 if (!self.__tlds_replaced__) {
19545 tlds.push(tlds_2ch_src_re);
19547 tlds.push(re.src_xn);
19549 re.src_tlds = tlds.join('|');
19551 function untpl(tpl) { return tpl.replace('%TLDS%', re.src_tlds); }
19553 re.email_fuzzy = RegExp(untpl(re.tpl_email_fuzzy), 'i');
19554 re.link_fuzzy = RegExp(untpl(re.tpl_link_fuzzy), 'i');
19555 re.link_no_ip_fuzzy = RegExp(untpl(re.tpl_link_no_ip_fuzzy), 'i');
19556 re.host_fuzzy_test = RegExp(untpl(re.tpl_host_fuzzy_test), 'i');
19559 // Compile each schema
19564 self.__compiled__ = {}; // Reset compiled data
19566 function schemaError(name, val) {
19567 throw new Error('(LinkifyIt) Invalid schema "' + name + '": ' + val);
19570 Object.keys(self.__schemas__).forEach(function (name) {
19571 var val = self.__schemas__[name];
19573 // skip disabled methods
19574 if (val === null) { return; }
19576 var compiled = { validate: null, link: null };
19578 self.__compiled__[name] = compiled;
19580 if (isObject(val)) {
19581 if (isRegExp(val.validate)) {
19582 compiled.validate = createValidator(val.validate);
19583 } else if (isFunction(val.validate)) {
19584 compiled.validate = val.validate;
19586 schemaError(name, val);
19589 if (isFunction(val.normalize)) {
19590 compiled.normalize = val.normalize;
19591 } else if (!val.normalize) {
19592 compiled.normalize = createNormalizer();
19594 schemaError(name, val);
19600 if (isString(val)) {
19601 aliases.push(name);
19605 schemaError(name, val);
19609 // Compile postponed aliases
19612 aliases.forEach(function (alias) {
19613 if (!self.__compiled__[self.__schemas__[alias]]) {
19614 // Silently fail on missed schemas to avoid errons on disable.
19615 // schemaError(alias, self.__schemas__[alias]);
19619 self.__compiled__[alias].validate =
19620 self.__compiled__[self.__schemas__[alias]].validate;
19621 self.__compiled__[alias].normalize =
19622 self.__compiled__[self.__schemas__[alias]].normalize;
19626 // Fake record for guessed links
19628 self.__compiled__[''] = { validate: null, normalize: createNormalizer() };
19631 // Build schema condition
19633 var slist = Object.keys(self.__compiled__)
19634 .filter(function (name) {
19635 // Filter disabled & fake schemas
19636 return name.length > 0 && self.__compiled__[name];
19640 // (?!_) cause 1.5x slowdown
19641 self.re.schema_test = RegExp('(^|(?!_)(?:[><\uff5c]|' + re.src_ZPCc + '))(' + slist + ')', 'i');
19642 self.re.schema_search = RegExp('(^|(?!_)(?:[><\uff5c]|' + re.src_ZPCc + '))(' + slist + ')', 'ig');
19644 self.re.pretest = RegExp(
19645 '(' + self.re.schema_test.source + ')|(' + self.re.host_fuzzy_test.source + ')|@',
19653 resetScanCache(self);
19659 * Match result. Single element of array, returned by [[LinkifyIt#match]]
19661 function Match(self, shift) {
19662 var start = self.__index__,
19663 end = self.__last_index__,
19664 text = self.__text_cache__.slice(start, end);
19667 * Match#schema -> String
19669 * Prefix (protocol) for matched string.
19671 this.schema = self.__schema__.toLowerCase();
19673 * Match#index -> Number
19675 * First position of matched string.
19677 this.index = start + shift;
19679 * Match#lastIndex -> Number
19681 * Next position after matched string.
19683 this.lastIndex = end + shift;
19685 * Match#raw -> String
19691 * Match#text -> String
19693 * Notmalized text of matched string.
19697 * Match#url -> String
19699 * Normalized url of matched string.
19704 function createMatch(self, shift) {
19705 var match = new Match(self, shift);
19707 self.__compiled__[match.schema].normalize(match, self);
19718 * new LinkifyIt(schemas, options)
19719 * - schemas (Object): Optional. Additional schemas to validate (prefix/validator)
19720 * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }
19722 * Creates new linkifier instance with optional additional schemas.
19723 * Can be called without `new` keyword for convenience.
19725 * By default understands:
19727 * - `http(s)://...` , `ftp://...`, `mailto:...` & `//...` links
19728 * - "fuzzy" links and emails (example.com, foo@bar.com).
19730 * `schemas` is an object, where each key/value describes protocol/rule:
19732 * - __key__ - link prefix (usually, protocol name with `:` at the end, `skype:`
19733 * for example). `linkify-it` makes shure that prefix is not preceeded with
19734 * alphanumeric char and symbols. Only whitespaces and punctuation allowed.
19735 * - __value__ - rule to check tail after link prefix
19736 * - _String_ - just alias to existing rule
19738 * - _validate_ - validator function (should return matched length on success),
19740 * - _normalize_ - optional function to normalize text & url of matched result
19741 * (for example, for @twitter mentions).
19745 * - __fuzzyLink__ - recognige URL-s without `http(s):` prefix. Default `true`.
19746 * - __fuzzyIP__ - allow IPs in fuzzy links above. Can conflict with some texts
19747 * like version numbers. Default `false`.
19748 * - __fuzzyEmail__ - recognize emails without `mailto:` prefix.
19751 function LinkifyIt(schemas, options) {
19752 if (!(this instanceof LinkifyIt)) {
19753 return new LinkifyIt(schemas, options);
19757 if (isOptionsObj(schemas)) {
19763 this.__opts__ = assign({}, defaultOptions, options);
19765 // Cache last tested result. Used to skip repeating steps on next `match` call.
19766 this.__index__ = -1;
19767 this.__last_index__ = -1; // Next scan position
19768 this.__schema__ = '';
19769 this.__text_cache__ = '';
19771 this.__schemas__ = assign({}, defaultSchemas, schemas);
19772 this.__compiled__ = {};
19774 this.__tlds__ = tlds_default;
19775 this.__tlds_replaced__ = false;
19784 * LinkifyIt#add(schema, definition)
19785 * - schema (String): rule name (fixed pattern prefix)
19786 * - definition (String|RegExp|Object): schema definition
19788 * Add new rule definition. See constructor description for details.
19790 LinkifyIt.prototype.add = function add(schema, definition) {
19791 this.__schemas__[schema] = definition;
19798 * LinkifyIt#set(options)
19799 * - options (Object): { fuzzyLink|fuzzyEmail|fuzzyIP: true|false }
19801 * Set recognition options for links without schema.
19803 LinkifyIt.prototype.set = function set(options) {
19804 this.__opts__ = assign(this.__opts__, options);
19810 * LinkifyIt#test(text) -> Boolean
19812 * Searches linkifiable pattern and returns `true` on success or `false` on fail.
19814 LinkifyIt.prototype.test = function test(text) {
19815 // Reset scan cache
19816 this.__text_cache__ = text;
19817 this.__index__ = -1;
19819 if (!text.length) { return false; }
19821 var m, ml, me, len, shift, next, re, tld_pos, at_pos;
19823 // try to scan for link with schema - that's the most simple rule
19824 if (this.re.schema_test.test(text)) {
19825 re = this.re.schema_search;
19827 while ((m = re.exec(text)) !== null) {
19828 len = this.testSchemaAt(text, m[2], re.lastIndex);
19830 this.__schema__ = m[2];
19831 this.__index__ = m.index + m[1].length;
19832 this.__last_index__ = m.index + m[0].length + len;
19838 if (this.__opts__.fuzzyLink && this.__compiled__['http:']) {
19839 // guess schemaless links
19840 tld_pos = text.search(this.re.host_fuzzy_test);
19841 if (tld_pos >= 0) {
19842 // if tld is located after found link - no need to check fuzzy pattern
19843 if (this.__index__ < 0 || tld_pos < this.__index__) {
19844 if ((ml = text.match(this.__opts__.fuzzyIP ? this.re.link_fuzzy : this.re.link_no_ip_fuzzy)) !== null) {
19846 shift = ml.index + ml[1].length;
19848 if (this.__index__ < 0 || shift < this.__index__) {
19849 this.__schema__ = '';
19850 this.__index__ = shift;
19851 this.__last_index__ = ml.index + ml[0].length;
19858 if (this.__opts__.fuzzyEmail && this.__compiled__['mailto:']) {
19859 // guess schemaless emails
19860 at_pos = text.indexOf('@');
19862 // We can't skip this check, because this cases are possible:
19863 // 192.168.1.1@gmail.com, my.in@example.com
19864 if ((me = text.match(this.re.email_fuzzy)) !== null) {
19866 shift = me.index + me[1].length;
19867 next = me.index + me[0].length;
19869 if (this.__index__ < 0 || shift < this.__index__ ||
19870 (shift === this.__index__ && next > this.__last_index__)) {
19871 this.__schema__ = 'mailto:';
19872 this.__index__ = shift;
19873 this.__last_index__ = next;
19879 return this.__index__ >= 0;
19884 * LinkifyIt#pretest(text) -> Boolean
19886 * Very quick check, that can give false positives. Returns true if link MAY BE
19887 * can exists. Can be used for speed optimization, when you need to check that
19890 LinkifyIt.prototype.pretest = function pretest(text) {
19891 return this.re.pretest.test(text);
19896 * LinkifyIt#testSchemaAt(text, name, position) -> Number
19897 * - text (String): text to scan
19898 * - name (String): rule (schema) name
19899 * - position (Number): text offset to check from
19901 * Similar to [[LinkifyIt#test]] but checks only specific protocol tail exactly
19902 * at given position. Returns length of found pattern (0 on fail).
19904 LinkifyIt.prototype.testSchemaAt = function testSchemaAt(text, schema, pos) {
19905 // If not supported schema check requested - terminate
19906 if (!this.__compiled__[schema.toLowerCase()]) {
19909 return this.__compiled__[schema.toLowerCase()].validate(text, pos, this);
19914 * LinkifyIt#match(text) -> Array|null
19916 * Returns array of found link descriptions or `null` on fail. We strongly
19917 * recommend to use [[LinkifyIt#test]] first, for best speed.
19919 * ##### Result match description
19921 * - __schema__ - link schema, can be empty for fuzzy links, or `//` for
19922 * protocol-neutral links.
19923 * - __index__ - offset of matched text
19924 * - __lastIndex__ - index of next char after mathch end
19925 * - __raw__ - matched text
19926 * - __text__ - normalized text
19927 * - __url__ - link, generated from matched text
19929 LinkifyIt.prototype.match = function match(text) {
19930 var shift = 0, result = [];
19932 // Try to take previous element from cache, if .test() called before
19933 if (this.__index__ >= 0 && this.__text_cache__ === text) {
19934 result.push(createMatch(this, shift));
19935 shift = this.__last_index__;
19938 // Cut head if cache was used
19939 var tail = shift ? text.slice(shift) : text;
19941 // Scan string until end reached
19942 while (this.test(tail)) {
19943 result.push(createMatch(this, shift));
19945 tail = tail.slice(this.__last_index__);
19946 shift += this.__last_index__;
19949 if (result.length) {
19958 * LinkifyIt#tlds(list [, keepOld]) -> this
19959 * - list (Array): list of tlds
19960 * - keepOld (Boolean): merge with current list if `true` (`false` by default)
19962 * Load (or merge) new tlds list. Those are user for fuzzy links (without prefix)
19963 * to avoid false positives. By default this algorythm used:
19965 * - hostname with any 2-letter root zones are ok.
19966 * - biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф
19968 * - encoded (`xn--...`) root zones are ok.
19970 * If list is replaced, then exact match for 2-chars root zones will be checked.
19972 LinkifyIt.prototype.tlds = function tlds(list, keepOld) {
19973 list = Array.isArray(list) ? list : [ list ];
19976 this.__tlds__ = list.slice();
19977 this.__tlds_replaced__ = true;
19982 this.__tlds__ = this.__tlds__.concat(list)
19984 .filter(function (el, idx, arr) {
19985 return el !== arr[idx - 1];
19994 * LinkifyIt#normalize(match)
19996 * Default normalizer (if schema does not define it's own).
19998 LinkifyIt.prototype.normalize = function normalize(match) {
20000 // Do minimal possible changes by default. Need to collect feedback prior
20001 // to move forward https://github.com/markdown-it/linkify-it/issues/1
20003 if (!match.schema) { match.url = 'http://' + match.url; }
20005 if (match.schema === 'mailto:' && !/^mailto:/i.test(match.url)) {
20006 match.url = 'mailto:' + match.url;
20012 * LinkifyIt#onCompile()
20014 * Override to modify basic RegExp-s.
20016 LinkifyIt.prototype.onCompile = function onCompile() {
20020 module.exports = LinkifyIt;
20025 /***/ (function(module, exports, __webpack_require__) {
20031 module.exports = function (opts) {
20034 // Use direct extract instead of `regenerate` to reduse browserified size
20035 re.src_Any = __webpack_require__(52).source;
20036 re.src_Cc = __webpack_require__(53).source;
20037 re.src_Z = __webpack_require__(55).source;
20038 re.src_P = __webpack_require__(45).source;
20040 // \p{\Z\P\Cc\CF} (white spaces + control + format + punctuation)
20041 re.src_ZPCc = [ re.src_Z, re.src_P, re.src_Cc ].join('|');
20043 // \p{\Z\Cc} (white spaces + control)
20044 re.src_ZCc = [ re.src_Z, re.src_Cc ].join('|');
20046 // Experimental. List of chars, completely prohibited in links
20047 // because can separate it from other part of text
20048 var text_separators = '[><\uff5c]';
20050 // All possible word characters (everything without punctuation, spaces & controls)
20051 // Defined via punctuation & spaces to save space
20052 // Should be something like \p{\L\N\S\M} (\w but without `_`)
20053 re.src_pseudo_letter = '(?:(?!' + text_separators + '|' + re.src_ZPCc + ')' + re.src_Any + ')';
20054 // The same as abothe but without [0-9]
20055 // var src_pseudo_letter_non_d = '(?:(?![0-9]|' + src_ZPCc + ')' + src_Any + ')';
20057 ////////////////////////////////////////////////////////////////////////////////
20061 '(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)';
20063 // Prohibit any of "@/[]()" in user/pass to avoid wrong domain fetch.
20064 re.src_auth = '(?:(?:(?!' + re.src_ZCc + '|[@/\\[\\]()]).)+@)?';
20068 '(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?';
20070 re.src_host_terminator =
20072 '(?=$|' + text_separators + '|' + re.src_ZPCc + ')(?!-|_|:\\d|\\.-|\\.(?!$|' + re.src_ZPCc + '))';
20079 '(?!' + re.src_ZCc + '|' + text_separators + '|[()[\\]{}.,"\'?!\\-]).|' +
20080 '\\[(?:(?!' + re.src_ZCc + '|\\]).)*\\]|' +
20081 '\\((?:(?!' + re.src_ZCc + '|[)]).)*\\)|' +
20082 '\\{(?:(?!' + re.src_ZCc + '|[}]).)*\\}|' +
20083 '\\"(?:(?!' + re.src_ZCc + '|["]).)+\\"|' +
20084 "\\'(?:(?!" + re.src_ZCc + "|[']).)+\\'|" +
20085 "\\'(?=" + re.src_pseudo_letter + '|[-]).|' + // allow `I'm_king` if no pair found
20086 '\\.{2,4}[a-zA-Z0-9%/]|' + // github has ... in commit range links,
20087 // google has .... in links (issue #66)
20090 // - percent-encoded
20091 // - parts of file path
20092 // until more examples found.
20093 '\\.(?!' + re.src_ZCc + '|[.]).|' +
20094 (opts && opts['---'] ?
20095 '\\-(?!--(?:[^-]|$))(?:-*)|' // `---` => long dash, terminate
20099 '\\,(?!' + re.src_ZCc + ').|' + // allow `,,,` in paths
20100 '\\!(?!' + re.src_ZCc + '|[!]).|' +
20101 '\\?(?!' + re.src_ZCc + '|[?]).' +
20106 // Allow anything in markdown spec, forbid quote (") at the first position
20107 // because emails enclosed in quotes are far more common
20108 re.src_email_name =
20110 '[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*';
20114 'xn--[a-z0-9\\-]{1,59}';
20116 // More to read about domain names
20117 // http://serverfault.com/questions/638260/
20119 re.src_domain_root =
20121 // Allow letters & digits (http://test1)
20125 re.src_pseudo_letter + '{1,63}' +
20133 '(?:' + re.src_pseudo_letter + ')' +
20135 '(?:' + re.src_pseudo_letter + '(?:-|' + re.src_pseudo_letter + '){0,61}' + re.src_pseudo_letter + ')' +
20141 // Don't need IP check, because digits are already allowed in normal domain names
20144 '(?:(?:(?:' + re.src_domain + ')\\.)*' + re.src_domain/*_root*/ + ')' +
20147 re.tpl_host_fuzzy =
20152 '(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))' +
20155 re.tpl_host_no_ip_fuzzy =
20157 '(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))';
20159 re.src_host_strict =
20161 re.src_host + re.src_host_terminator;
20163 re.tpl_host_fuzzy_strict =
20165 re.tpl_host_fuzzy + re.src_host_terminator;
20167 re.src_host_port_strict =
20169 re.src_host + re.src_port + re.src_host_terminator;
20171 re.tpl_host_port_fuzzy_strict =
20173 re.tpl_host_fuzzy + re.src_port + re.src_host_terminator;
20175 re.tpl_host_port_no_ip_fuzzy_strict =
20177 re.tpl_host_no_ip_fuzzy + re.src_port + re.src_host_terminator;
20180 ////////////////////////////////////////////////////////////////////////////////
20183 // Rude test fuzzy links by host, for quick deny
20184 re.tpl_host_fuzzy_test =
20186 'localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:' + re.src_ZPCc + '|>|$))';
20188 re.tpl_email_fuzzy =
20190 '(^|' + text_separators + '|"|\\(|' + re.src_ZCc + ')' +
20191 '(' + re.src_email_name + '@' + re.tpl_host_fuzzy_strict + ')';
20193 re.tpl_link_fuzzy =
20194 // Fuzzy link can't be prepended with .:/\- and non punctuation.
20195 // but can start with > (markdown blockquote)
20196 '(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|' + re.src_ZPCc + '))' +
20197 '((?![$+<=>^`|\uff5c])' + re.tpl_host_port_fuzzy_strict + re.src_path + ')';
20199 re.tpl_link_no_ip_fuzzy =
20200 // Fuzzy link can't be prepended with .:/\- and non punctuation.
20201 // but can start with > (markdown blockquote)
20202 '(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|' + re.src_ZPCc + '))' +
20203 '((?![$+<=>^`|\uff5c])' + re.tpl_host_port_no_ip_fuzzy_strict + re.src_path + ')';
20211 /***/ (function(module, exports) {
20213 module.exports = require("punycode");
20217 /***/ (function(module, exports, __webpack_require__) {
20220 // markdown-it default options
20227 html: false, // Enable HTML tags in source
20228 xhtmlOut: false, // Use '/' to close single tags (<br />)
20229 breaks: false, // Convert '\n' in paragraphs into <br>
20230 langPrefix: 'language-', // CSS language prefix for fenced blocks
20231 linkify: false, // autoconvert URL-like texts to links
20233 // Enable some language-neutral replacements + quotes beautification
20234 typographer: false,
20236 // Double + single quotes replacement pairs, when typographer enabled,
20237 // and smartquotes on. Could be either a String or an Array.
20239 // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
20240 // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
20241 quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */
20243 // Highlighter function. Should return escaped HTML,
20244 // or '' if the source string is not changed and should be escaped externaly.
20245 // If result starts with <pre... internal wrapper is skipped.
20247 // function (/*str, lang*/) { return ''; }
20251 maxNesting: 100 // Internal protection, recursion limit
20265 /***/ (function(module, exports, __webpack_require__) {
20268 // "Zero" preset, with nothing enabled. Useful for manual configuring of simple
20269 // modes. For example, to parse bold/italic only.
20276 html: false, // Enable HTML tags in source
20277 xhtmlOut: false, // Use '/' to close single tags (<br />)
20278 breaks: false, // Convert '\n' in paragraphs into <br>
20279 langPrefix: 'language-', // CSS language prefix for fenced blocks
20280 linkify: false, // autoconvert URL-like texts to links
20282 // Enable some language-neutral replacements + quotes beautification
20283 typographer: false,
20285 // Double + single quotes replacement pairs, when typographer enabled,
20286 // and smartquotes on. Could be either a String or an Array.
20288 // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
20289 // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
20290 quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */
20292 // Highlighter function. Should return escaped HTML,
20293 // or '' if the source string is not changed and should be escaped externaly.
20294 // If result starts with <pre... internal wrapper is skipped.
20296 // function (/*str, lang*/) { return ''; }
20300 maxNesting: 20 // Internal protection, recursion limit
20334 /***/ (function(module, exports, __webpack_require__) {
20337 // Commonmark default options
20344 html: true, // Enable HTML tags in source
20345 xhtmlOut: true, // Use '/' to close single tags (<br />)
20346 breaks: false, // Convert '\n' in paragraphs into <br>
20347 langPrefix: 'language-', // CSS language prefix for fenced blocks
20348 linkify: false, // autoconvert URL-like texts to links
20350 // Enable some language-neutral replacements + quotes beautification
20351 typographer: false,
20353 // Double + single quotes replacement pairs, when typographer enabled,
20354 // and smartquotes on. Could be either a String or an Array.
20356 // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
20357 // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
20358 quotes: '\u201c\u201d\u2018\u2019', /* “”‘’ */
20360 // Highlighter function. Should return escaped HTML,
20361 // or '' if the source string is not changed and should be escaped externaly.
20362 // If result starts with <pre... internal wrapper is skipped.
20364 // function (/*str, lang*/) { return ''; }
20368 maxNesting: 20 // Internal protection, recursion limit
20421 /***/ (function(module, exports, __webpack_require__) {
20428 const { URL } = __webpack_require__(39);
20429 const packageJson = __webpack_require__(108);
20430 const homepage = packageJson.homepage;
20431 const version = packageJson.version;
20434 __webpack_require__(109),
20435 __webpack_require__(112),
20436 __webpack_require__(113),
20437 __webpack_require__(114),
20438 __webpack_require__(116),
20439 __webpack_require__(117),
20440 __webpack_require__(118),
20441 __webpack_require__(119),
20442 __webpack_require__(120),
20443 __webpack_require__(121),
20444 __webpack_require__(122),
20445 __webpack_require__(123),
20446 __webpack_require__(124),
20447 __webpack_require__(125),
20448 __webpack_require__(126),
20449 __webpack_require__(127),
20450 __webpack_require__(128),
20451 __webpack_require__(129),
20452 __webpack_require__(130),
20453 __webpack_require__(131),
20454 __webpack_require__(132),
20455 __webpack_require__(133),
20456 __webpack_require__(134),
20457 __webpack_require__(135),
20458 __webpack_require__(136),
20459 __webpack_require__(137),
20460 __webpack_require__(138),
20461 __webpack_require__(139),
20462 __webpack_require__(140),
20463 __webpack_require__(141),
20464 __webpack_require__(142),
20465 __webpack_require__(143),
20466 __webpack_require__(144),
20467 __webpack_require__(145),
20468 __webpack_require__(146),
20469 __webpack_require__(147),
20470 __webpack_require__(148),
20471 __webpack_require__(149),
20472 __webpack_require__(150),
20473 __webpack_require__(151),
20474 __webpack_require__(152),
20475 __webpack_require__(153),
20476 __webpack_require__(154),
20477 __webpack_require__(155)
20479 rules.forEach((rule) => {
20480 const name = rule.names[0].toLowerCase();
20482 new URL(`${homepage}/blob/v${version}/doc/Rules.md#${name}`);
20484 module.exports = rules;
20489 /***/ (function(module) {
20491 module.exports = JSON.parse("{\"name\":\"markdownlint\",\"version\":\"0.20.4\",\"description\":\"A Node.js style checker and lint tool for Markdown/CommonMark files.\",\"main\":\"lib/markdownlint.js\",\"types\":\"lib/markdownlint.d.ts\",\"author\":\"David Anson (https://dlaa.me/)\",\"license\":\"MIT\",\"homepage\":\"https://github.com/DavidAnson/markdownlint\",\"repository\":{\"type\":\"git\",\"url\":\"https://github.com/DavidAnson/markdownlint.git\"},\"bugs\":\"https://github.com/DavidAnson/markdownlint/issues\",\"scripts\":{\"test\":\"node test/markdownlint-test.js\",\"test-cover\":\"c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 node test/markdownlint-test.js\",\"test-declaration\":\"cd example/typescript && tsc && node type-check.js\",\"test-extra\":\"node test/markdownlint-test-extra.js\",\"debug\":\"node debug node_modules/nodeunit/bin/nodeunit\",\"lint\":\"eslint --max-warnings 0 lib helpers test schema && eslint --env browser --global markdownit --global markdownlint --rule \\\"no-unused-vars: 0, no-extend-native: 0, max-statements: 0, no-console: 0, no-var: 0\\\" demo && eslint --rule \\\"no-console: 0, no-invalid-this: 0, no-shadow: 0, object-property-newline: 0\\\" example\",\"ci\":\"npm run test-cover && npm run lint && npm run test-declaration\",\"build-config-schema\":\"node schema/build-config-schema.js\",\"build-declaration\":\"tsc --allowJs --declaration --outDir declaration --resolveJsonModule lib/markdownlint.js && cpy declaration/lib/markdownlint.d.ts lib && rimraf declaration\",\"build-demo\":\"cpy node_modules/markdown-it/dist/markdown-it.min.js demo && cd demo && rimraf markdownlint-browser.* && cpy file-header.js . --rename=markdownlint-browser.js && tsc --allowJs --resolveJsonModule --outDir ../lib-es3 ../lib/markdownlint.js && cpy ../helpers/package.json ../lib-es3/helpers && browserify ../lib-es3/lib/markdownlint.js --standalone markdownlint >> markdownlint-browser.js && uglifyjs markdownlint-browser.js --compress --mangle --comments --output markdownlint-browser.min.js\",\"build-example\":\"npm install --no-save --ignore-scripts grunt grunt-cli gulp through2\",\"example\":\"cd example && node standalone.js && grunt markdownlint --force && gulp markdownlint\",\"clone-test-repos\":\"make-dir test-repos && cd test-repos && git clone https://github.com/eslint/eslint eslint-eslint --depth 1 --no-tags --quiet && git clone https://github.com/mkdocs/mkdocs mkdocs-mkdocs --depth 1 --no-tags --quiet && git clone https://github.com/pi-hole/docs pi-hole-docs --depth 1 --no-tags --quiet\",\"clone-test-repos-large\":\"npm run clone-test-repos && cd test-repos && git clone https://github.com/dotnet/docs dotnet-docs --depth 1 --no-tags --quiet\",\"lint-test-repos\":\"node test/markdownlint-test-repos.js\",\"clean-test-repos\":\"rimraf test-repos\"},\"engines\":{\"node\":\">=10\"},\"dependencies\":{\"markdown-it\":\"10.0.0\"},\"devDependencies\":{\"@types/node\":\"~13.11.1\",\"browserify\":\"~16.5.1\",\"c8\":\"~7.1.2\",\"cpy-cli\":\"~3.1.0\",\"eslint\":\"~6.8.0\",\"eslint-plugin-jsdoc\":\"~22.1.0\",\"globby\":\"~11.0.0\",\"js-yaml\":\"~3.13.1\",\"make-dir-cli\":\"~2.0.0\",\"markdown-it-for-inline\":\"~0.1.1\",\"markdown-it-katex\":\"~2.0.3\",\"markdown-it-sub\":\"~1.0.0\",\"markdown-it-sup\":\"~1.0.0\",\"markdownlint-rule-helpers\":\"~0.7.0\",\"rimraf\":\"~3.0.2\",\"strip-json-comments\":\"~3.1.0\",\"tape\":\"~4.13.2\",\"tape-player\":\"~0.1.0\",\"toml\":\"~3.0.0\",\"tv4\":\"~1.3.0\",\"typescript\":\"~3.8.3\",\"uglify-js\":\"~3.8.1\"},\"keywords\":[\"markdown\",\"lint\",\"md\",\"CommonMark\",\"markdownlint\"],\"browser\":{\"markdown-it\":\"../demo/markdown-it-stub.js\"}}");
20495 /***/ (function(module, exports, __webpack_require__) {
20502 const { addErrorDetailIf, filterTokens } = __webpack_require__(110);
20505 "names": [ "MD001", "heading-increment", "header-increment" ],
20506 "description": "Heading levels should only increment by one level at a time",
20507 "tags": [ "headings", "headers" ],
20508 "function": function MD001(params, onError) {
20510 filterTokens(params, "heading_open", function forToken(token) {
20511 const level = parseInt(token.tag.slice(1), 10);
20512 if (prevLevel && (level > prevLevel)) {
20513 addErrorDetailIf(onError, token.lineNumber,
20514 "h" + (prevLevel + 1), "h" + level);
20524 /***/ (function(module, exports, __webpack_require__) {
20531 const os = __webpack_require__(111);
20533 // Regular expression for matching common newline characters
20534 // See NEWLINES_RE in markdown-it/lib/rules_core/normalize.js
20535 const newLineRe = /\r\n?|\n/g;
20536 module.exports.newLineRe = newLineRe;
20538 // Regular expression for matching common front matter (YAML and TOML)
20539 module.exports.frontMatterRe =
20540 // eslint-disable-next-line max-len
20541 /((^---\s*$[^]*?^---\s*$)|(^\+\+\+\s*$[^]*?^(\+\+\+|\.\.\.)\s*$))(\r\n|\r|\n|$)/m;
20543 // Regular expression for matching inline disable/enable comments
20544 const inlineCommentRe =
20545 // eslint-disable-next-line max-len
20546 /<!--\s*markdownlint-(?:(?:(disable|enable|capture|restore|disable-file|enable-file)((?:\s+[a-z0-9_-]+)*))|(?:(configure-file)\s+([\s\S]*?)))\s*-->/ig;
20547 module.exports.inlineCommentRe = inlineCommentRe;
20549 // Regular expressions for range matching
20550 module.exports.bareUrlRe = /(?:http|ftp)s?:\/\/[^\s\]"']*(?:\/|[^\s\]"'\W])/ig;
20551 module.exports.listItemMarkerRe = /^([\s>]*)(?:[*+-]|\d+[.)])\s+/;
20552 module.exports.orderedListItemMarkerRe = /^[\s>]*0*(\d+)[.)]/;
20554 // Regular expression for all instances of emphasis markers
20555 const emphasisMarkersRe = /[_*]/g;
20557 // Regular expression for inline links and shortcut reference links
20558 const linkRe = /\[(?:[^[\]]|\[[^\]]*\])*\](?:\(\S*\))?/g;
20560 // readFile options for reading with the UTF-8 encoding
20561 module.exports.utf8Encoding = { "encoding": "utf8" };
20563 // All punctuation characters (normal and full-width)
20564 module.exports.allPunctuation = ".,;:!?。,;:!?";
20566 // Returns true iff the input is a number
20567 module.exports.isNumber = function isNumber(obj) {
20568 return typeof obj === "number";
20571 // Returns true iff the input is a string
20572 module.exports.isString = function isString(obj) {
20573 return typeof obj === "string";
20576 // Returns true iff the input string is empty
20577 module.exports.isEmptyString = function isEmptyString(str) {
20578 return str.length === 0;
20581 // Returns true iff the input is an object
20582 module.exports.isObject = function isObject(obj) {
20583 return (obj !== null) && (typeof obj === "object") && !Array.isArray(obj);
20586 // Returns true iff the input line is blank (no content)
20587 // Example: Contains nothing, whitespace, or comments
20588 const blankLineRe = />|(?:<!--.*?-->)/g;
20589 module.exports.isBlankLine = function isBlankLine(line) {
20590 return !line || !line.trim() || !line.replace(blankLineRe, "").trim();
20594 * Compare function for Array.prototype.sort for ascending order of numbers.
20596 * @param {number} a First number.
20597 * @param {number} b Second number.
20598 * @returns {number} Positive value if a>b, negative value if b<a, 0 otherwise.
20600 module.exports.numericSortAscending = function numericSortAscending(a, b) {
20604 // Returns true iff the sorted array contains the specified element
20605 module.exports.includesSorted = function includesSorted(array, element) {
20607 let right = array.length - 1;
20608 while (left <= right) {
20609 /* eslint-disable no-bitwise */
20610 const mid = (left + right) >> 1;
20611 if (array[mid] < element) {
20613 } else if (array[mid] > element) {
20622 // Replaces the text of all properly-formatted HTML comments with whitespace
20623 // This preserves the line/column information for the rest of the document
20624 // Trailing whitespace is avoided with a '\' character in the last column
20625 // See https://www.w3.org/TR/html5/syntax.html#comments for details
20626 const htmlCommentBegin = "<!--";
20627 const htmlCommentEnd = "-->";
20628 module.exports.clearHtmlCommentText = function clearHtmlCommentText(text) {
20630 while ((i = text.indexOf(htmlCommentBegin, i)) !== -1) {
20631 const j = text.indexOf(htmlCommentEnd, i);
20633 // Un-terminated comments are treated as text
20636 const comment = text.slice(i + htmlCommentBegin.length, j);
20637 if ((comment.length > 0) &&
20638 (comment[0] !== ">") &&
20639 (comment[comment.length - 1] !== "-") &&
20640 !comment.includes("--") &&
20641 (text.slice(i, j + htmlCommentEnd.length)
20642 .search(inlineCommentRe) === -1)) {
20643 const blanks = comment
20644 .replace(/[^\r\n]/g, " ")
20645 .replace(/ ([\r\n])/g, "\\$1");
20646 text = text.slice(0, i + htmlCommentBegin.length) +
20647 blanks + text.slice(j);
20649 i = j + htmlCommentEnd.length;
20654 // Escapes a string for use in a RegExp
20655 module.exports.escapeForRegExp = function escapeForRegExp(str) {
20656 return str.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
20659 // Un-escapes Markdown content (simple algorithm; not a parser)
20660 const escapedMarkdownRe = /\\./g;
20661 module.exports.unescapeMarkdown =
20662 function unescapeMarkdown(markdown, replacement) {
20663 return markdown.replace(escapedMarkdownRe, (match) => {
20664 const char = match[1];
20665 if ("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~".includes(char)) {
20666 return replacement || char;
20673 * Return the string representation of a fence markup character.
20675 * @param {string} markup Fence string.
20676 * @returns {string} String representation.
20678 module.exports.fencedCodeBlockStyleFor =
20679 function fencedCodeBlockStyleFor(markup) {
20680 switch (markup[0]) {
20689 * Return the number of characters of indent for a token.
20691 * @param {Object} token MarkdownItToken instance.
20692 * @returns {number} Characters of indent.
20694 function indentFor(token) {
20695 const line = token.line.replace(/^[\s>]*(> |>)/, "");
20696 return line.length - line.trimLeft().length;
20698 module.exports.indentFor = indentFor;
20700 // Returns the heading style for a heading token
20701 module.exports.headingStyleFor = function headingStyleFor(token) {
20702 if ((token.map[1] - token.map[0]) === 1) {
20703 if (/[^\\]#\s*$/.test(token.line)) {
20704 return "atx_closed";
20712 * Return the string representation of an unordered list marker.
20714 * @param {Object} token MarkdownItToken instance.
20715 * @returns {string} String representation.
20717 module.exports.unorderedListStyleFor = function unorderedListStyleFor(token) {
20718 switch (token.markup) {
20730 * Calls the provided function for each matching token.
20732 * @param {Object} params RuleParams instance.
20733 * @param {string} type Token type identifier.
20734 * @param {Function} handler Callback function.
20737 function filterTokens(params, type, handler) {
20738 params.tokens.forEach(function forToken(token) {
20739 if (token.type === type) {
20744 module.exports.filterTokens = filterTokens;
20746 // Get line metadata array
20747 module.exports.getLineMetadata = function getLineMetadata(params) {
20748 const lineMetadata = params.lines.map(function mapLine(line, index) {
20749 return [ line, index, false, 0, false, false ];
20751 filterTokens(params, "fence", function forToken(token) {
20752 lineMetadata[token.map[0]][3] = 1;
20753 lineMetadata[token.map[1] - 1][3] = -1;
20754 for (let i = token.map[0] + 1; i < token.map[1] - 1; i++) {
20755 lineMetadata[i][2] = true;
20758 filterTokens(params, "code_block", function forToken(token) {
20759 for (let i = token.map[0]; i < token.map[1]; i++) {
20760 lineMetadata[i][2] = true;
20763 filterTokens(params, "table_open", function forToken(token) {
20764 for (let i = token.map[0]; i < token.map[1]; i++) {
20765 lineMetadata[i][4] = true;
20768 filterTokens(params, "list_item_open", function forToken(token) {
20770 for (let i = token.map[0]; i < token.map[1]; i++) {
20771 lineMetadata[i][5] = count;
20775 filterTokens(params, "hr", function forToken(token) {
20776 lineMetadata[token.map[0]][6] = true;
20778 return lineMetadata;
20781 // Calls the provided function for each line (with context)
20782 module.exports.forEachLine = function forEachLine(lineMetadata, handler) {
20783 lineMetadata.forEach(function forMetadata(metadata) {
20784 // Parameters: line, lineIndex, inCode, onFence, inTable, inItem, inBreak
20785 handler(...metadata);
20789 // Returns (nested) lists as a flat array (in order)
20790 module.exports.flattenLists = function flattenLists(params) {
20791 const flattenedLists = [];
20793 let current = null;
20795 const nestingStack = [];
20796 let lastWithMap = { "map": [ 0, 1 ] };
20797 params.tokens.forEach(function forToken(token) {
20798 if ((token.type === "bullet_list_open") ||
20799 (token.type === "ordered_list_open")) {
20800 // Save current context and start a new one
20801 stack.push(current);
20803 "unordered": (token.type === "bullet_list_open"),
20804 "parentsUnordered": !current ||
20805 (current.unordered && current.parentsUnordered),
20807 "indent": indentFor(token),
20808 "parentIndent": (current && current.indent) || 0,
20810 "nesting": nesting,
20811 "lastLineIndex": -1,
20812 "insert": flattenedLists.length
20815 } else if ((token.type === "bullet_list_close") ||
20816 (token.type === "ordered_list_close")) {
20817 // Finalize current context and restore previous
20818 current.lastLineIndex = lastWithMap.map[1];
20819 flattenedLists.splice(current.insert, 0, current);
20820 delete current.insert;
20821 current = stack.pop();
20823 } else if (token.type === "list_item_open") {
20825 current.items.push(token);
20826 } else if (token.type === "blockquote_open") {
20827 nestingStack.push(nesting);
20829 } else if (token.type === "blockquote_close") {
20830 nesting = nestingStack.pop();
20831 } else if (token.map) {
20832 // Track last token with map
20833 lastWithMap = token;
20836 return flattenedLists;
20839 // Calls the provided function for each specified inline child token
20840 module.exports.forEachInlineChild =
20841 function forEachInlineChild(params, type, handler) {
20842 filterTokens(params, "inline", function forToken(token) {
20843 token.children.forEach(function forChild(child) {
20844 if (child.type === type) {
20845 handler(child, token);
20851 // Calls the provided function for each heading's content
20852 module.exports.forEachHeading = function forEachHeading(params, handler) {
20853 let heading = null;
20854 params.tokens.forEach(function forToken(token) {
20855 if (token.type === "heading_open") {
20857 } else if (token.type === "heading_close") {
20859 } else if ((token.type === "inline") && heading) {
20860 handler(heading, token.content);
20866 * Calls the provided function for each inline code span's content.
20868 * @param {string} input Markdown content.
20869 * @param {Function} handler Callback function.
20872 function forEachInlineCodeSpan(input, handler) {
20873 let currentLine = 0;
20874 let currentColumn = 0;
20876 while (index < input.length) {
20877 let startIndex = -1;
20878 let startLine = -1;
20879 let startColumn = -1;
20881 let currentTicks = 0;
20882 let state = "normal";
20883 // Deliberate <= so trailing 0 completes the last span (ex: "text `code`")
20884 for (; index <= input.length; index++) {
20885 const char = input[index];
20886 // Ignore backticks in link destination
20887 if ((char === "[") && (state === "normal")) {
20888 state = "linkTextOpen";
20889 } else if ((char === "]") && (state === "linkTextOpen")) {
20890 state = "linkTextClosed";
20891 } else if ((char === "(") && (state === "linkTextClosed")) {
20892 state = "linkDestinationOpen";
20894 ((char === "(") && (state === "linkDestinationOpen")) ||
20895 ((char === ")") && (state === "linkDestinationOpen")) ||
20896 (state === "linkTextClosed")) {
20899 // Parse backtick open/close
20900 if ((char === "`") && (state !== "linkDestinationOpen")) {
20901 // Count backticks at start or end of code span
20903 if ((startIndex === -1) || (startColumn === -1)) {
20904 startIndex = index + 1;
20907 if ((startIndex >= 0) &&
20908 (startColumn >= 0) &&
20909 (tickCount === currentTicks)) {
20910 // Found end backticks; invoke callback for code span
20912 input.substring(startIndex, index - currentTicks),
20913 startLine, startColumn, tickCount);
20916 } else if ((startIndex >= 0) && (startColumn === -1)) {
20917 // Found start backticks
20918 tickCount = currentTicks;
20919 startLine = currentLine;
20920 startColumn = currentColumn;
20922 // Not in backticks
20925 if (char === "\n") {
20929 } else if ((char === "\\") &&
20930 ((startIndex === -1) || (startColumn === -1)) &&
20931 (input[index + 1] !== "\n")) {
20932 // Escape character outside code, skip next
20934 currentColumn += 2;
20940 if (startIndex >= 0) {
20941 // Restart loop after unmatched start backticks (ex: "`text``code``")
20942 index = startIndex;
20943 currentLine = startLine;
20944 currentColumn = startColumn;
20948 module.exports.forEachInlineCodeSpan = forEachInlineCodeSpan;
20951 * Adds a generic error object via the onError callback.
20953 * @param {Object} onError RuleOnError instance.
20954 * @param {number} lineNumber Line number.
20955 * @param {string} [detail] Error details.
20956 * @param {string} [context] Error context.
20957 * @param {number[]} [range] Column and length of error.
20958 * @param {Object} [fixInfo] RuleOnErrorFixInfo instance.
20961 function addError(onError, lineNumber, detail, context, range, fixInfo) {
20970 module.exports.addError = addError;
20972 // Adds an error object with details conditionally via the onError callback
20973 module.exports.addErrorDetailIf = function addErrorDetailIf(
20974 onError, lineNumber, expected, actual, detail, context, range, fixInfo) {
20975 if (expected !== actual) {
20979 "Expected: " + expected + "; Actual: " + actual +
20980 (detail ? "; " + detail : ""),
20987 // Adds an error object with context via the onError callback
20988 module.exports.addErrorContext = function addErrorContext(
20989 onError, lineNumber, context, left, right, range, fixInfo) {
20990 if (context.length <= 30) {
20992 } else if (left && right) {
20993 context = context.substr(0, 15) + "..." + context.substr(-15);
20994 } else if (right) {
20995 context = "..." + context.substr(-30);
20997 context = context.substr(0, 30) + "...";
20999 addError(onError, lineNumber, null, context, range, fixInfo);
21002 // Returns a range object for a line by applying a RegExp
21003 module.exports.rangeFromRegExp = function rangeFromRegExp(line, regexp) {
21005 const match = line.match(regexp);
21007 const column = match.index + 1;
21008 const length = match[0].length;
21009 range = [ column, length ];
21014 // Determines if the front matter includes a title
21015 module.exports.frontMatterHasTitle =
21016 function frontMatterHasTitle(frontMatterLines, frontMatterTitlePattern) {
21017 const ignoreFrontMatter =
21018 (frontMatterTitlePattern !== undefined) && !frontMatterTitlePattern;
21019 const frontMatterTitleRe =
21020 new RegExp(String(frontMatterTitlePattern || "^\\s*title\\s*[:=]"), "i");
21021 return !ignoreFrontMatter &&
21022 frontMatterLines.some((line) => frontMatterTitleRe.test(line));
21026 * Returns a list of emphasis markers in code spans and links.
21028 * @param {Object} params RuleParams instance.
21029 * @returns {number[][]} List of markers.
21031 function emphasisMarkersInContent(params) {
21032 const { lines } = params;
21033 const byLine = new Array(lines.length);
21034 // Search code spans
21035 filterTokens(params, "inline", (token) => {
21036 const { children, lineNumber, map } = token;
21037 if (children.some((child) => child.type === "code_inline")) {
21038 const tokenLines = lines.slice(map[0], map[1]);
21039 forEachInlineCodeSpan(
21040 tokenLines.join("\n"),
21041 (code, lineIndex, column, tickCount) => {
21042 const codeLines = code.split(newLineRe);
21043 codeLines.forEach((codeLine, codeLineIndex) => {
21045 while ((match = emphasisMarkersRe.exec(codeLine))) {
21046 const byLineIndex = lineNumber - 1 + lineIndex + codeLineIndex;
21047 const inLine = byLine[byLineIndex] || [];
21048 const codeLineOffset = codeLineIndex ? 0 : column - 1 + tickCount;
21049 inLine.push(codeLineOffset + match.index);
21050 byLine[byLineIndex] = inLine;
21058 lines.forEach((tokenLine, tokenLineIndex) => {
21059 let linkMatch = null;
21060 while ((linkMatch = linkRe.exec(tokenLine))) {
21061 let markerMatch = null;
21062 while ((markerMatch = emphasisMarkersRe.exec(linkMatch[0]))) {
21063 const inLine = byLine[tokenLineIndex] || [];
21064 inLine.push(linkMatch.index + markerMatch.index);
21065 byLine[tokenLineIndex] = inLine;
21071 module.exports.emphasisMarkersInContent = emphasisMarkersInContent;
21074 * Gets the most common line ending, falling back to the platform default.
21076 * @param {string} input Markdown content to analyze.
21077 * @returns {string} Preferred line ending.
21079 function getPreferredLineEnding(input) {
21083 const endings = input.match(newLineRe) || [];
21084 endings.forEach((ending) => {
21085 // eslint-disable-next-line default-case
21098 let preferredLineEnding = null;
21099 if (!cr && !lf && !crlf) {
21100 preferredLineEnding = os.EOL;
21101 } else if ((lf >= crlf) && (lf >= cr)) {
21102 preferredLineEnding = "\n";
21103 } else if (crlf >= cr) {
21104 preferredLineEnding = "\r\n";
21106 preferredLineEnding = "\r";
21108 return preferredLineEnding;
21110 module.exports.getPreferredLineEnding = getPreferredLineEnding;
21113 * Normalizes the fields of a RuleOnErrorFixInfo instance.
21115 * @param {Object} fixInfo RuleOnErrorFixInfo instance.
21116 * @param {number} [lineNumber] Line number.
21117 * @returns {Object} Normalized RuleOnErrorFixInfo instance.
21119 function normalizeFixInfo(fixInfo, lineNumber) {
21121 "lineNumber": fixInfo.lineNumber || lineNumber,
21122 "editColumn": fixInfo.editColumn || 1,
21123 "deleteCount": fixInfo.deleteCount || 0,
21124 "insertText": fixInfo.insertText || ""
21129 * Fixes the specified error on a line of Markdown content.
21131 * @param {string} line Line of Markdown content.
21132 * @param {Object} fixInfo RuleOnErrorFixInfo instance.
21133 * @param {string} lineEnding Line ending to use.
21134 * @returns {string} Fixed content.
21136 function applyFix(line, fixInfo, lineEnding) {
21137 const { editColumn, deleteCount, insertText } = normalizeFixInfo(fixInfo);
21138 const editIndex = editColumn - 1;
21139 return (deleteCount === -1) ?
21141 line.slice(0, editIndex) +
21142 insertText.replace(/\n/g, lineEnding || "\n") +
21143 line.slice(editIndex + deleteCount);
21145 module.exports.applyFix = applyFix;
21147 // Applies as many fixes as possible to the input lines
21148 module.exports.applyFixes = function applyFixes(input, errors) {
21149 const lineEnding = getPreferredLineEnding(input);
21150 const lines = input.split(newLineRe);
21151 // Normalize fixInfo objects
21152 let fixInfos = errors
21153 .filter((error) => error.fixInfo)
21154 .map((error) => normalizeFixInfo(error.fixInfo, error.lineNumber));
21155 // Sort bottom-to-top, line-deletes last, right-to-left, long-to-short
21156 fixInfos.sort((a, b) => {
21157 const aDeletingLine = (a.deleteCount === -1);
21158 const bDeletingLine = (b.deleteCount === -1);
21160 (b.lineNumber - a.lineNumber) ||
21161 (aDeletingLine ? 1 : (bDeletingLine ? -1 : 0)) ||
21162 (b.editColumn - a.editColumn) ||
21163 (b.insertText.length - a.insertText.length)
21166 // Remove duplicate entries (needed for following collapse step)
21167 let lastFixInfo = {};
21168 fixInfos = fixInfos.filter((fixInfo) => {
21170 (fixInfo.lineNumber !== lastFixInfo.lineNumber) ||
21171 (fixInfo.editColumn !== lastFixInfo.editColumn) ||
21172 (fixInfo.deleteCount !== lastFixInfo.deleteCount) ||
21173 (fixInfo.insertText !== lastFixInfo.insertText)
21175 lastFixInfo = fixInfo;
21178 // Collapse insert/no-delete and no-insert/delete for same line/column
21180 fixInfos.forEach((fixInfo) => {
21182 (fixInfo.lineNumber === lastFixInfo.lineNumber) &&
21183 (fixInfo.editColumn === lastFixInfo.editColumn) &&
21184 !fixInfo.insertText &&
21185 (fixInfo.deleteCount > 0) &&
21186 lastFixInfo.insertText &&
21187 !lastFixInfo.deleteCount) {
21188 fixInfo.insertText = lastFixInfo.insertText;
21189 lastFixInfo.lineNumber = 0;
21191 lastFixInfo = fixInfo;
21193 fixInfos = fixInfos.filter((fixInfo) => fixInfo.lineNumber);
21194 // Apply all (remaining/updated) fixes
21195 let lastLineIndex = -1;
21196 let lastEditIndex = -1;
21197 fixInfos.forEach((fixInfo) => {
21198 const { lineNumber, editColumn, deleteCount } = fixInfo;
21199 const lineIndex = lineNumber - 1;
21200 const editIndex = editColumn - 1;
21202 (lineIndex !== lastLineIndex) ||
21203 ((editIndex + deleteCount) < lastEditIndex) ||
21204 (deleteCount === -1)
21206 lines[lineIndex] = applyFix(lines[lineIndex], fixInfo, lineEnding);
21208 lastLineIndex = lineIndex;
21209 lastEditIndex = editIndex;
21211 // Return corrected input
21212 return lines.filter((line) => line !== null).join(lineEnding);
21218 /***/ (function(module, exports) {
21220 module.exports = require("os");
21224 /***/ (function(module, exports, __webpack_require__) {
21231 const { addErrorDetailIf } = __webpack_require__(110);
21234 "names": [ "MD002", "first-heading-h1", "first-header-h1" ],
21235 "description": "First heading should be a top level heading",
21236 "tags": [ "headings", "headers" ],
21237 "function": function MD002(params, onError) {
21238 const level = Number(params.config.level || 1);
21239 const tag = "h" + level;
21240 params.tokens.every(function forToken(token) {
21241 if (token.type === "heading_open") {
21242 addErrorDetailIf(onError, token.lineNumber, tag, token.tag);
21253 /***/ (function(module, exports, __webpack_require__) {
21260 const { addErrorDetailIf, filterTokens, headingStyleFor } =
21261 __webpack_require__(110);
21264 "names": [ "MD003", "heading-style", "header-style" ],
21265 "description": "Heading style",
21266 "tags": [ "headings", "headers" ],
21267 "function": function MD003(params, onError) {
21268 let style = String(params.config.style || "consistent");
21269 filterTokens(params, "heading_open", function forToken(token) {
21270 const styleForToken = headingStyleFor(token);
21271 if (style === "consistent") {
21272 style = styleForToken;
21274 if (styleForToken !== style) {
21275 const h12 = /h[12]/.test(token.tag);
21276 const setextWithAtx =
21277 (style === "setext_with_atx") &&
21278 ((h12 && (styleForToken === "setext")) ||
21279 (!h12 && (styleForToken === "atx")));
21280 const setextWithAtxClosed =
21281 (style === "setext_with_atx_closed") &&
21282 ((h12 && (styleForToken === "setext")) ||
21283 (!h12 && (styleForToken === "atx_closed")));
21284 if (!setextWithAtx && !setextWithAtxClosed) {
21285 let expected = style;
21286 if (style === "setext_with_atx") {
21287 expected = h12 ? "setext" : "atx";
21288 } else if (style === "setext_with_atx_closed") {
21289 expected = h12 ? "setext" : "atx_closed";
21291 addErrorDetailIf(onError, token.lineNumber,
21292 expected, styleForToken);
21302 /***/ (function(module, exports, __webpack_require__) {
21309 const { addErrorDetailIf, listItemMarkerRe,
21310 rangeFromRegExp, unorderedListStyleFor } = __webpack_require__(110);
21311 const { flattenedLists } = __webpack_require__(115);
21314 "names": [ "MD004", "ul-style" ],
21315 "description": "Unordered list style",
21316 "tags": [ "bullet", "ul" ],
21317 "function": function MD004(params, onError) {
21318 const style = String(params.config.style || "consistent");
21319 let expectedStyle = style;
21320 const nestingStyles = [];
21321 flattenedLists().forEach((list) => {
21322 if (list.unordered) {
21323 if (expectedStyle === "consistent") {
21324 expectedStyle = unorderedListStyleFor(list.items[0]);
21326 list.items.forEach((item) => {
21327 const itemStyle = unorderedListStyleFor(item);
21328 if (style === "sublist") {
21329 const nesting = list.nesting;
21330 if (!nestingStyles[nesting] &&
21331 (itemStyle !== nestingStyles[nesting - 1])) {
21332 nestingStyles[nesting] = itemStyle;
21334 addErrorDetailIf(onError, item.lineNumber,
21335 nestingStyles[nesting], itemStyle, null, null,
21336 rangeFromRegExp(item.line, listItemMarkerRe));
21339 addErrorDetailIf(onError, item.lineNumber,
21340 expectedStyle, itemStyle, null, null,
21341 rangeFromRegExp(item.line, listItemMarkerRe));
21352 /***/ (function(module, exports, __webpack_require__) {
21359 let lineMetadata = null;
21360 module.exports.lineMetadata = (value) => {
21362 lineMetadata = value;
21364 return lineMetadata;
21367 let flattenedLists = null;
21368 module.exports.flattenedLists = (value) => {
21370 flattenedLists = value;
21372 return flattenedLists;
21375 module.exports.clear = () => {
21376 lineMetadata = null;
21377 flattenedLists = null;
21383 /***/ (function(module, exports, __webpack_require__) {
21390 const { addError, addErrorDetailIf, indentFor, listItemMarkerRe,
21391 orderedListItemMarkerRe, rangeFromRegExp } = __webpack_require__(110);
21392 const { flattenedLists } = __webpack_require__(115);
21395 "names": [ "MD005", "list-indent" ],
21396 "description": "Inconsistent indentation for list items at the same level",
21397 "tags": [ "bullet", "ul", "indentation" ],
21398 "function": function MD005(params, onError) {
21399 flattenedLists().forEach((list) => {
21400 const expectedIndent = list.indent;
21401 let expectedEnd = 0;
21402 let actualEnd = -1;
21403 let endMatching = false;
21404 list.items.forEach((item) => {
21405 const { line, lineNumber } = item;
21406 const actualIndent = indentFor(item);
21408 if (list.unordered) {
21416 rangeFromRegExp(line, listItemMarkerRe)
21417 // No fixInfo; MD007 handles this scenario better
21419 } else if ((match = orderedListItemMarkerRe.exec(line))) {
21420 actualEnd = match[0].length;
21421 expectedEnd = expectedEnd || actualEnd;
21422 const markerLength = match[1].length + 1;
21423 if ((expectedIndent !== actualIndent) || endMatching) {
21424 if (expectedEnd === actualEnd) {
21425 endMatching = true;
21427 const detail = endMatching ?
21428 `Expected: (${expectedEnd}); Actual: (${actualEnd})` :
21429 `Expected: ${expectedIndent}; Actual: ${actualIndent}`;
21430 const expected = endMatching ?
21431 expectedEnd - markerLength :
21433 const actual = endMatching ?
21434 actualEnd - markerLength :
21441 rangeFromRegExp(line, listItemMarkerRe),
21443 "editColumn": Math.min(actual, expected) + 1,
21444 "deleteCount": Math.max(actual - expected, 0),
21445 "insertText": "".padEnd(Math.max(expected - actual, 0))
21459 /***/ (function(module, exports, __webpack_require__) {
21466 const { addErrorDetailIf, listItemMarkerRe, rangeFromRegExp } =
21467 __webpack_require__(110);
21468 const { flattenedLists } = __webpack_require__(115);
21471 "names": [ "MD006", "ul-start-left" ],
21473 "Consider starting bulleted lists at the beginning of the line",
21474 "tags": [ "bullet", "ul", "indentation" ],
21475 "function": function MD006(params, onError) {
21476 flattenedLists().forEach((list) => {
21477 if (list.unordered && !list.nesting && (list.indent !== 0)) {
21478 list.items.forEach((item) => {
21479 const { lineNumber, line } = item;
21487 rangeFromRegExp(line, listItemMarkerRe),
21489 "deleteCount": line.length - line.trimLeft().length
21500 /***/ (function(module, exports, __webpack_require__) {
21507 const { addErrorDetailIf, indentFor, listItemMarkerRe } =
21508 __webpack_require__(110);
21509 const { flattenedLists } = __webpack_require__(115);
21512 "names": [ "MD007", "ul-indent" ],
21513 "description": "Unordered list indentation",
21514 "tags": [ "bullet", "ul", "indentation" ],
21515 "function": function MD007(params, onError) {
21516 const indent = Number(params.config.indent || 2);
21517 const startIndented = !!params.config.start_indented;
21518 flattenedLists().forEach((list) => {
21519 if (list.unordered && list.parentsUnordered) {
21520 list.items.forEach((item) => {
21521 const { lineNumber, line } = item;
21522 const expectedNesting = list.nesting + (startIndented ? 1 : 0);
21523 const expectedIndent = expectedNesting * indent;
21524 const actualIndent = indentFor(item);
21526 let editColumn = 1;
21527 const match = line.match(listItemMarkerRe);
21529 range = [ 1, match[0].length ];
21530 editColumn += match[1].length - actualIndent;
21542 "deleteCount": actualIndent,
21543 "insertText": "".padEnd(expectedIndent)
21554 /***/ (function(module, exports, __webpack_require__) {
21561 const { addError, filterTokens, forEachInlineCodeSpan, forEachLine,
21562 includesSorted, newLineRe, numericSortAscending } = __webpack_require__(110);
21563 const { lineMetadata } = __webpack_require__(115);
21566 "names": [ "MD009", "no-trailing-spaces" ],
21567 "description": "Trailing spaces",
21568 "tags": [ "whitespace" ],
21569 "function": function MD009(params, onError) {
21570 let brSpaces = params.config.br_spaces;
21571 brSpaces = Number((brSpaces === undefined) ? 2 : brSpaces);
21572 const listItemEmptyLines = !!params.config.list_item_empty_lines;
21573 const strict = !!params.config.strict;
21574 const listItemLineNumbers = [];
21575 if (listItemEmptyLines) {
21576 filterTokens(params, "list_item_open", (token) => {
21577 for (let i = token.map[0]; i < token.map[1]; i++) {
21578 listItemLineNumbers.push(i + 1);
21581 listItemLineNumbers.sort(numericSortAscending);
21583 const paragraphLineNumbers = [];
21584 const codeInlineLineNumbers = [];
21586 filterTokens(params, "paragraph_open", (token) => {
21587 for (let i = token.map[0]; i < token.map[1] - 1; i++) {
21588 paragraphLineNumbers.push(i + 1);
21591 paragraphLineNumbers.sort(numericSortAscending);
21592 filterTokens(params, "inline", (token) => {
21593 if (token.children.some((child) => child.type === "code_inline")) {
21594 const tokenLines = params.lines.slice(token.map[0], token.map[1]);
21595 forEachInlineCodeSpan(tokenLines.join("\n"), (code, lineIndex) => {
21596 const codeLineCount = code.split(newLineRe).length;
21597 for (let i = 0; i < codeLineCount; i++) {
21598 codeInlineLineNumbers.push(token.lineNumber + lineIndex + i);
21603 codeInlineLineNumbers.sort(numericSortAscending);
21605 const expected = (brSpaces < 2) ? 0 : brSpaces;
21606 let inFencedCode = 0;
21607 forEachLine(lineMetadata(), (line, lineIndex, inCode, onFence) => {
21608 inFencedCode += onFence;
21609 const lineNumber = lineIndex + 1;
21610 const trailingSpaces = line.length - line.trimRight().length;
21611 if ((!inCode || inFencedCode) && trailingSpaces &&
21612 !includesSorted(listItemLineNumbers, lineNumber)) {
21613 if ((expected !== trailingSpaces) ||
21615 (!includesSorted(paragraphLineNumbers, lineNumber) ||
21616 includesSorted(codeInlineLineNumbers, lineNumber)))) {
21617 const column = line.length - trailingSpaces + 1;
21621 "Expected: " + (expected === 0 ? "" : "0 or ") +
21622 expected + "; Actual: " + trailingSpaces,
21624 [ column, trailingSpaces ],
21626 "editColumn": column,
21627 "deleteCount": trailingSpaces
21638 /***/ (function(module, exports, __webpack_require__) {
21645 const { addError, forEachLine } = __webpack_require__(110);
21646 const { lineMetadata } = __webpack_require__(115);
21648 const tabRe = /\t+/g;
21651 "names": [ "MD010", "no-hard-tabs" ],
21652 "description": "Hard tabs",
21653 "tags": [ "whitespace", "hard_tab" ],
21654 "function": function MD010(params, onError) {
21655 const codeBlocks = params.config.code_blocks;
21656 const includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
21657 forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
21658 if (!inCode || includeCodeBlocks) {
21660 while ((match = tabRe.exec(line)) !== null) {
21661 const column = match.index + 1;
21662 const length = match[0].length;
21666 "Column: " + column,
21668 [ column, length ],
21670 "editColumn": column,
21671 "deleteCount": length,
21672 "insertText": "".padEnd(length)
21683 /***/ (function(module, exports, __webpack_require__) {
21690 const { addError, forEachInlineChild, unescapeMarkdown } =
21691 __webpack_require__(110);
21693 const reversedLinkRe = /\(([^)]+)\)\[([^\]^][^\]]*)]/g;
21696 "names": [ "MD011", "no-reversed-links" ],
21697 "description": "Reversed link syntax",
21698 "tags": [ "links" ],
21699 "function": function MD011(params, onError) {
21700 forEachInlineChild(params, "text", (token) => {
21701 const { lineNumber, content } = token;
21703 while ((match = reversedLinkRe.exec(content)) !== null) {
21704 const [ reversedLink, linkText, linkDestination ] = match;
21705 const line = params.lines[lineNumber - 1];
21706 const column = unescapeMarkdown(line).indexOf(reversedLink) + 1;
21707 const length = reversedLink.length;
21713 [ column, length ],
21715 "editColumn": column,
21716 "deleteCount": length,
21717 "insertText": `[${linkText}](${linkDestination})`
21728 /***/ (function(module, exports, __webpack_require__) {
21735 const { addErrorDetailIf, forEachLine } = __webpack_require__(110);
21736 const { lineMetadata } = __webpack_require__(115);
21739 "names": [ "MD012", "no-multiple-blanks" ],
21740 "description": "Multiple consecutive blank lines",
21741 "tags": [ "whitespace", "blank_lines" ],
21742 "function": function MD012(params, onError) {
21743 const maximum = Number(params.config.maximum || 1);
21745 forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
21746 count = (inCode || line.trim().length) ? 0 : count + 1;
21747 if (maximum < count) {
21767 /***/ (function(module, exports, __webpack_require__) {
21774 const { addErrorDetailIf, filterTokens, forEachHeading, forEachLine,
21775 includesSorted } = __webpack_require__(110);
21776 const { lineMetadata } = __webpack_require__(115);
21778 const longLineRePrefix = "^.{";
21779 const longLineRePostfixRelaxed = "}.*\\s.*$";
21780 const longLineRePostfixStrict = "}.+$";
21781 const labelRe = /^\s*\[.*[^\\]]:/;
21782 const linkOrImageOnlyLineRe = /^[es]*(lT?L|I)[ES]*$/;
21783 const sternModeRe = /^([#>\s]*\s)?\S*$/;
21784 const tokenTypeMap = {
21790 "strong_open": "s",
21791 "strong_close": "S",
21796 "names": [ "MD013", "line-length" ],
21797 "description": "Line length",
21798 "tags": [ "line_length" ],
21799 "function": function MD013(params, onError) {
21800 const lineLength = Number(params.config.line_length || 80);
21801 const headingLineLength =
21802 Number(params.config.heading_line_length || lineLength);
21803 const codeLineLength =
21804 Number(params.config.code_block_line_length || lineLength);
21805 const strict = !!params.config.strict;
21806 const stern = !!params.config.stern;
21807 const longLineRePostfix =
21808 (strict || stern) ? longLineRePostfixStrict : longLineRePostfixRelaxed;
21810 new RegExp(longLineRePrefix + lineLength + longLineRePostfix);
21811 const longHeadingLineRe =
21812 new RegExp(longLineRePrefix + headingLineLength + longLineRePostfix);
21813 const longCodeLineRe =
21814 new RegExp(longLineRePrefix + codeLineLength + longLineRePostfix);
21815 const codeBlocks = params.config.code_blocks;
21816 const includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
21817 const tables = params.config.tables;
21818 const includeTables = (tables === undefined) ? true : !!tables;
21819 let headings = params.config.headings;
21820 if (headings === undefined) {
21821 headings = params.config.headers;
21823 const includeHeadings = (headings === undefined) ? true : !!headings;
21824 const headingLineNumbers = [];
21825 forEachHeading(params, (heading) => {
21826 headingLineNumbers.push(heading.lineNumber);
21828 const linkOnlyLineNumbers = [];
21829 filterTokens(params, "inline", (token) => {
21830 let childTokenTypes = "";
21831 token.children.forEach((child) => {
21832 if (child.type !== "text" || child.content !== "") {
21833 childTokenTypes += tokenTypeMap[child.type] || "x";
21836 if (linkOrImageOnlyLineRe.test(childTokenTypes)) {
21837 linkOnlyLineNumbers.push(token.lineNumber);
21840 forEachLine(lineMetadata(), (line, lineIndex, inCode, onFence, inTable) => {
21841 const lineNumber = lineIndex + 1;
21842 const isHeading = includesSorted(headingLineNumbers, lineNumber);
21843 const length = inCode ?
21845 (isHeading ? headingLineLength : lineLength);
21846 const lengthRe = inCode ?
21848 (isHeading ? longHeadingLineRe : longLineRe);
21849 if ((includeCodeBlocks || !inCode) &&
21850 (includeTables || !inTable) &&
21851 (includeHeadings || !isHeading) &&
21853 (!(stern && sternModeRe.test(line)) &&
21854 !includesSorted(linkOnlyLineNumbers, lineNumber) &&
21855 !labelRe.test(line))) &&
21856 lengthRe.test(line)) {
21864 [ length + 1, line.length - length ]);
21873 /***/ (function(module, exports, __webpack_require__) {
21880 const { addErrorContext, filterTokens } = __webpack_require__(110);
21882 const dollarCommandRe = /^(\s*)(\$\s+)/;
21885 "names": [ "MD014", "commands-show-output" ],
21886 "description": "Dollar signs used before commands without showing output",
21887 "tags": [ "code" ],
21888 "function": function MD014(params, onError) {
21889 [ "code_block", "fence" ].forEach((type) => {
21890 filterTokens(params, type, (token) => {
21891 const margin = (token.type === "fence") ? 1 : 0;
21892 const dollarInstances = [];
21893 let allDollars = true;
21894 for (let i = token.map[0] + margin; i < token.map[1] - margin; i++) {
21895 const line = params.lines[i];
21896 const lineTrim = line.trim();
21898 const match = dollarCommandRe.exec(line);
21900 const column = match[1].length + 1;
21901 const length = match[2].length;
21902 dollarInstances.push([ i, lineTrim, column, length ]);
21904 allDollars = false;
21909 dollarInstances.forEach((instance) => {
21910 const [ i, lineTrim, column, length ] = instance;
21917 [ column, length ],
21919 "editColumn": column,
21920 "deleteCount": length
21933 /***/ (function(module, exports, __webpack_require__) {
21940 const { addErrorContext, forEachLine } = __webpack_require__(110);
21941 const { lineMetadata } = __webpack_require__(115);
21944 "names": [ "MD018", "no-missing-space-atx" ],
21945 "description": "No space after hash on atx style heading",
21946 "tags": [ "headings", "headers", "atx", "spaces" ],
21947 "function": function MD018(params, onError) {
21948 forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
21950 /^#+[^#\s]/.test(line) &&
21951 !/#\s*$/.test(line) &&
21952 !line.startsWith("#️⃣")) {
21953 const hashCount = /^#+/.exec(line)[0].length;
21960 [ 1, hashCount + 1 ],
21962 "editColumn": hashCount + 1,
21974 /***/ (function(module, exports, __webpack_require__) {
21981 const { addErrorContext, filterTokens, headingStyleFor } =
21982 __webpack_require__(110);
21985 "names": [ "MD019", "no-multiple-space-atx" ],
21986 "description": "Multiple spaces after hash on atx style heading",
21987 "tags": [ "headings", "headers", "atx", "spaces" ],
21988 "function": function MD019(params, onError) {
21989 filterTokens(params, "heading_open", (token) => {
21990 if (headingStyleFor(token) === "atx") {
21991 const { line, lineNumber } = token;
21992 const match = /^(#+)(\s{2,})(?:\S)/.exec(line);
21996 { "length": hashLength },
21997 { "length": spacesLength }
22005 [ 1, hashLength + spacesLength + 1 ],
22007 "editColumn": hashLength + 1,
22008 "deleteCount": spacesLength - 1
22020 /***/ (function(module, exports, __webpack_require__) {
22027 const { addErrorContext, forEachLine } = __webpack_require__(110);
22028 const { lineMetadata } = __webpack_require__(115);
22031 "names": [ "MD020", "no-missing-space-closed-atx" ],
22032 "description": "No space inside hashes on closed atx style heading",
22033 "tags": [ "headings", "headers", "atx_closed", "spaces" ],
22034 "function": function MD020(params, onError) {
22035 forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
22038 /^(#+)(\s*)([^#]*?[^#\\])(\s*)((?:\\#)?)(#+)(\s*)$/.exec(line);
22043 { "length": leftSpaceLength },
22045 { "length": rightSpaceLength },
22048 { "length": trailSpaceLength }
22050 const leftHashLength = leftHash.length;
22051 const rightHashLength = rightHash.length;
22052 const left = !leftSpaceLength;
22053 const right = !rightSpaceLength || rightEscape;
22054 const rightEscapeReplacement = rightEscape ? `${rightEscape} ` : "";
22055 if (left || right) {
22056 const range = left ?
22062 line.length - trailSpaceLength - rightHashLength,
22063 rightHashLength + 1
22074 "deleteCount": line.length,
22076 `${leftHash} ${content} ${rightEscapeReplacement}${rightHash}`
22089 /***/ (function(module, exports, __webpack_require__) {
22096 const { addErrorContext, filterTokens, headingStyleFor } =
22097 __webpack_require__(110);
22100 "names": [ "MD021", "no-multiple-space-closed-atx" ],
22101 "description": "Multiple spaces inside hashes on closed atx style heading",
22102 "tags": [ "headings", "headers", "atx_closed", "spaces" ],
22103 "function": function MD021(params, onError) {
22104 filterTokens(params, "heading_open", (token) => {
22105 if (headingStyleFor(token) === "atx_closed") {
22106 const { line, lineNumber } = token;
22107 const match = /^(#+)(\s+)([^#]+?)(\s+)(#+)(\s*)$/.exec(line);
22112 { "length": leftSpaceLength },
22114 { "length": rightSpaceLength },
22116 { "length": trailSpaceLength }
22118 const left = leftSpaceLength > 1;
22119 const right = rightSpaceLength > 1;
22120 if (left || right) {
22121 const length = line.length;
22122 const leftHashLength = leftHash.length;
22123 const rightHashLength = rightHash.length;
22124 const range = left ?
22127 leftHashLength + leftSpaceLength + 1
22130 length - trailSpaceLength - rightHashLength - rightSpaceLength,
22131 rightSpaceLength + rightHashLength + 1
22142 "deleteCount": length,
22143 "insertText": `${leftHash} ${content} ${rightHash}`
22156 /***/ (function(module, exports, __webpack_require__) {
22163 const { addErrorDetailIf, filterTokens, isBlankLine } = __webpack_require__(110);
22166 "names": [ "MD022", "blanks-around-headings", "blanks-around-headers" ],
22167 "description": "Headings should be surrounded by blank lines",
22168 "tags": [ "headings", "headers", "blank_lines" ],
22169 "function": function MD022(params, onError) {
22170 let linesAbove = params.config.lines_above;
22171 linesAbove = Number((linesAbove === undefined) ? 1 : linesAbove);
22172 let linesBelow = params.config.lines_below;
22173 linesBelow = Number((linesBelow === undefined) ? 1 : linesBelow);
22174 const { lines } = params;
22175 filterTokens(params, "heading_open", (token) => {
22176 const [ topIndex, nextIndex ] = token.map;
22177 let actualAbove = 0;
22178 for (let i = 0; i < linesAbove; i++) {
22179 if (isBlankLine(lines[topIndex - i - 1])) {
22189 lines[topIndex].trim(),
22192 "insertText": "".padEnd(linesAbove - actualAbove, "\n")
22194 let actualBelow = 0;
22195 for (let i = 0; i < linesBelow; i++) {
22196 if (isBlankLine(lines[nextIndex + i])) {
22206 lines[topIndex].trim(),
22209 "lineNumber": nextIndex + 1,
22210 "insertText": "".padEnd(linesBelow - actualBelow, "\n")
22219 /***/ (function(module, exports, __webpack_require__) {
22226 const { addErrorContext, filterTokens } = __webpack_require__(110);
22228 const spaceBeforeHeadingRe = /^((?:\s+)|(?:[>\s]+\s\s))[^>\s]/;
22231 "names": [ "MD023", "heading-start-left", "header-start-left" ],
22232 "description": "Headings must start at the beginning of the line",
22233 "tags": [ "headings", "headers", "spaces" ],
22234 "function": function MD023(params, onError) {
22235 filterTokens(params, "heading_open", function forToken(token) {
22236 const { lineNumber, line } = token;
22237 const match = line.match(spaceBeforeHeadingRe);
22239 const [ prefixAndFirstChar, prefix ] = match;
22240 let deleteCount = prefix.length;
22241 const prefixLengthNoSpace = prefix.trimRight().length;
22242 if (prefixLengthNoSpace) {
22243 deleteCount -= prefixLengthNoSpace - 1;
22251 [ 1, prefixAndFirstChar.length ],
22253 "editColumn": prefixLengthNoSpace + 1,
22254 "deleteCount": deleteCount
22264 /***/ (function(module, exports, __webpack_require__) {
22271 const { addErrorContext, forEachHeading } = __webpack_require__(110);
22274 "names": [ "MD024", "no-duplicate-heading", "no-duplicate-header" ],
22275 "description": "Multiple headings with the same content",
22276 "tags": [ "headings", "headers" ],
22277 "function": function MD024(params, onError) {
22278 const siblingsOnly = !!params.config.siblings_only ||
22279 !!params.config.allow_different_nesting || false;
22280 const knownContents = [ null, [] ];
22282 let knownContent = knownContents[lastLevel];
22283 forEachHeading(params, (heading, content) => {
22284 if (siblingsOnly) {
22285 const newLevel = heading.tag.slice(1);
22286 while (lastLevel < newLevel) {
22288 knownContents[lastLevel] = [];
22290 while (lastLevel > newLevel) {
22291 knownContents[lastLevel] = [];
22294 knownContent = knownContents[newLevel];
22296 if (knownContent.includes(content)) {
22297 addErrorContext(onError, heading.lineNumber,
22298 heading.line.trim());
22300 knownContent.push(content);
22309 /***/ (function(module, exports, __webpack_require__) {
22316 const { addErrorContext, filterTokens, frontMatterHasTitle } =
22317 __webpack_require__(110);
22320 "names": [ "MD025", "single-title", "single-h1" ],
22321 "description": "Multiple top level headings in the same document",
22322 "tags": [ "headings", "headers" ],
22323 "function": function MD025(params, onError) {
22324 const level = Number(params.config.level || 1);
22325 const tag = "h" + level;
22326 const foundFrontMatterTitle =
22327 frontMatterHasTitle(
22328 params.frontMatterLines,
22329 params.config.front_matter_title
22331 let hasTopLevelHeading = false;
22332 filterTokens(params, "heading_open", function forToken(token) {
22333 if (token.tag === tag) {
22334 if (hasTopLevelHeading || foundFrontMatterTitle) {
22335 addErrorContext(onError, token.lineNumber,
22336 token.line.trim());
22337 } else if (token.lineNumber === 1) {
22338 hasTopLevelHeading = true;
22348 /***/ (function(module, exports, __webpack_require__) {
22355 const { addError, allPunctuation, escapeForRegExp, forEachHeading } =
22356 __webpack_require__(110);
22359 "names": [ "MD026", "no-trailing-punctuation" ],
22360 "description": "Trailing punctuation in heading",
22361 "tags": [ "headings", "headers" ],
22362 "function": function MD026(params, onError) {
22363 let punctuation = params.config.punctuation;
22365 String((punctuation === undefined) ? allPunctuation : punctuation);
22366 const trailingPunctuationRe =
22367 new RegExp("\\s*[" + escapeForRegExp(punctuation) + "]+$");
22368 forEachHeading(params, (heading) => {
22369 const { line, lineNumber } = heading;
22370 const trimmedLine = line.replace(/[\s#]*$/, "");
22371 const match = trailingPunctuationRe.exec(trimmedLine);
22373 const fullMatch = match[0];
22374 const column = match.index + 1;
22375 const length = fullMatch.length;
22379 `Punctuation: '${fullMatch}'`,
22381 [ column, length ],
22383 "editColumn": column,
22384 "deleteCount": length
22395 /***/ (function(module, exports, __webpack_require__) {
22402 const { addErrorContext, newLineRe } = __webpack_require__(110);
22404 const spaceAfterBlockQuoteRe = /^((?:\s*>)+)(\s{2,})\S/;
22407 "names": [ "MD027", "no-multiple-space-blockquote" ],
22408 "description": "Multiple spaces after blockquote symbol",
22409 "tags": [ "blockquote", "whitespace", "indentation" ],
22410 "function": function MD027(params, onError) {
22411 let blockquoteNesting = 0;
22412 let listItemNesting = 0;
22413 params.tokens.forEach((token) => {
22414 const { content, lineNumber, type } = token;
22415 if (type === "blockquote_open") {
22416 blockquoteNesting++;
22417 } else if (type === "blockquote_close") {
22418 blockquoteNesting--;
22419 } else if (type === "list_item_open") {
22421 } else if (type === "list_item_close") {
22423 } else if ((type === "inline") && blockquoteNesting) {
22424 const lineCount = content.split(newLineRe).length;
22425 for (let i = 0; i < lineCount; i++) {
22426 const line = params.lines[lineNumber + i - 1];
22427 const match = line.match(spaceAfterBlockQuoteRe);
22431 { "length": blockquoteLength },
22432 { "length": spaceLength }
22434 if (!listItemNesting || (fullMatch[fullMatch.length - 1] === ">")) {
22441 [ 1, fullMatch.length ],
22443 "editColumn": blockquoteLength + 1,
22444 "deleteCount": spaceLength - 1
22458 /***/ (function(module, exports, __webpack_require__) {
22465 const { addError } = __webpack_require__(110);
22468 "names": [ "MD028", "no-blanks-blockquote" ],
22469 "description": "Blank line inside blockquote",
22470 "tags": [ "blockquote", "whitespace" ],
22471 "function": function MD028(params, onError) {
22472 let prevToken = {};
22473 let prevLineNumber = null;
22474 params.tokens.forEach(function forToken(token) {
22475 if ((token.type === "blockquote_open") &&
22476 (prevToken.type === "blockquote_close")) {
22478 let lineNumber = prevLineNumber;
22479 lineNumber < token.lineNumber;
22493 if (token.type === "blockquote_open") {
22494 prevLineNumber = token.map[1] + 1;
22503 /***/ (function(module, exports, __webpack_require__) {
22510 const { addErrorDetailIf, listItemMarkerRe, orderedListItemMarkerRe,
22511 rangeFromRegExp } = __webpack_require__(110);
22512 const { flattenedLists } = __webpack_require__(115);
22514 const listStyleExamples = {
22516 "ordered": "1/2/3",
22521 "names": [ "MD029", "ol-prefix" ],
22522 "description": "Ordered list item prefix",
22524 "function": function MD029(params, onError) {
22525 const style = String(params.config.style || "one_or_ordered");
22526 flattenedLists().filter((list) => !list.unordered).forEach((list) => {
22527 const { items } = list;
22529 let incrementing = false;
22530 // Check for incrementing number pattern 1/2/3 or 0/1/2
22531 if (items.length >= 2) {
22532 const first = orderedListItemMarkerRe.exec(items[0].line);
22533 const second = orderedListItemMarkerRe.exec(items[1].line);
22534 if (first && second) {
22535 const [ , firstNumber ] = first;
22536 const [ , secondNumber ] = second;
22537 if ((secondNumber !== "1") || (firstNumber === "0")) {
22538 incrementing = true;
22539 if (firstNumber === "0") {
22545 // Determine effective style
22546 let listStyle = style;
22547 if (listStyle === "one_or_ordered") {
22548 listStyle = incrementing ? "ordered" : "one";
22550 // Force expected value for 0/0/0 and 1/1/1 patterns
22551 if (listStyle === "zero") {
22553 } else if (listStyle === "one") {
22556 // Validate each list item marker
22557 items.forEach((item) => {
22558 const match = orderedListItemMarkerRe.exec(item.line);
22560 addErrorDetailIf(onError, item.lineNumber,
22561 String(current), match[1],
22562 "Style: " + listStyleExamples[listStyle], null,
22563 rangeFromRegExp(item.line, listItemMarkerRe));
22564 if (listStyle === "ordered") {
22576 /***/ (function(module, exports, __webpack_require__) {
22583 const { addErrorDetailIf } = __webpack_require__(110);
22584 const { flattenedLists } = __webpack_require__(115);
22587 "names": [ "MD030", "list-marker-space" ],
22588 "description": "Spaces after list markers",
22589 "tags": [ "ol", "ul", "whitespace" ],
22590 "function": function MD030(params, onError) {
22591 const ulSingle = Number(params.config.ul_single || 1);
22592 const olSingle = Number(params.config.ol_single || 1);
22593 const ulMulti = Number(params.config.ul_multi || 1);
22594 const olMulti = Number(params.config.ol_multi || 1);
22595 flattenedLists().forEach((list) => {
22596 const lineCount = list.lastLineIndex - list.open.map[0];
22597 const allSingle = lineCount === list.items.length;
22598 const expectedSpaces = list.unordered ?
22599 (allSingle ? ulSingle : ulMulti) :
22600 (allSingle ? olSingle : olMulti);
22601 list.items.forEach((item) => {
22602 const { line, lineNumber } = item;
22603 const match = /^[\s>]*\S+(\s*)/.exec(line);
22604 const [ { "length": matchLength }, { "length": actualSpaces } ] = match;
22605 if (matchLength < line.length) {
22606 let fixInfo = null;
22607 if (expectedSpaces !== actualSpaces) {
22609 "editColumn": matchLength - actualSpaces + 1,
22610 "deleteCount": actualSpaces,
22611 "insertText": "".padEnd(expectedSpaces)
22621 [ 1, matchLength ],
22633 /***/ (function(module, exports, __webpack_require__) {
22640 const { addErrorContext, forEachLine, isBlankLine } = __webpack_require__(110);
22641 const { lineMetadata } = __webpack_require__(115);
22643 const codeFencePrefixRe = /^(.*?)\s*[`~]/;
22646 "names": [ "MD031", "blanks-around-fences" ],
22647 "description": "Fenced code blocks should be surrounded by blank lines",
22648 "tags": [ "code", "blank_lines" ],
22649 "function": function MD031(params, onError) {
22650 const listItems = params.config.list_items;
22651 const includeListItems = (listItems === undefined) ? true : !!listItems;
22652 const { lines } = params;
22653 forEachLine(lineMetadata(), (line, i, inCode, onFence, inTable, inItem) => {
22654 const onTopFence = (onFence > 0);
22655 const onBottomFence = (onFence < 0);
22656 if ((includeListItems || !inItem) &&
22657 ((onTopFence && !isBlankLine(lines[i - 1])) ||
22658 (onBottomFence && !isBlankLine(lines[i + 1])))) {
22659 const [ , prefix ] = line.match(codeFencePrefixRe);
22668 "lineNumber": i + (onTopFence ? 1 : 2),
22669 "insertText": `${prefix}\n`
22679 /***/ (function(module, exports, __webpack_require__) {
22686 const { addErrorContext, isBlankLine } = __webpack_require__(110);
22687 const { flattenedLists } = __webpack_require__(115);
22689 const quotePrefixRe = /^[>\s]*/;
22692 "names": [ "MD032", "blanks-around-lists" ],
22693 "description": "Lists should be surrounded by blank lines",
22694 "tags": [ "bullet", "ul", "ol", "blank_lines" ],
22695 "function": function MD032(params, onError) {
22696 const { lines } = params;
22697 flattenedLists().filter((list) => !list.nesting).forEach((list) => {
22698 const firstIndex = list.open.map[0];
22699 if (!isBlankLine(lines[firstIndex - 1])) {
22700 const line = lines[firstIndex];
22701 const quotePrefix = line.match(quotePrefixRe)[0].trimRight();
22710 "insertText": `${quotePrefix}\n`
22713 const lastIndex = list.lastLineIndex - 1;
22714 if (!isBlankLine(lines[lastIndex + 1])) {
22715 const line = lines[lastIndex];
22716 const quotePrefix = line.match(quotePrefixRe)[0].trimRight();
22725 "lineNumber": lastIndex + 2,
22726 "insertText": `${quotePrefix}\n`
22736 /***/ (function(module, exports, __webpack_require__) {
22743 const { addError, forEachLine, unescapeMarkdown } = __webpack_require__(110);
22744 const { lineMetadata } = __webpack_require__(115);
22746 const htmlElementRe = /<(([A-Za-z][A-Za-z0-9-]*)(?:\s[^>]*)?)\/?>/g;
22747 const linkDestinationRe = /]\(\s*$/;
22748 const inlineCodeRe = /^[^`]*(`+[^`]+`+[^`]+)*`+[^`]*$/;
22749 // See https://spec.commonmark.org/0.29/#autolinks
22750 const emailAddressRe =
22751 // eslint-disable-next-line max-len
22752 /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
22755 "names": [ "MD033", "no-inline-html" ],
22756 "description": "Inline HTML",
22757 "tags": [ "html" ],
22758 "function": function MD033(params, onError) {
22759 let allowedElements = params.config.allowed_elements;
22760 allowedElements = Array.isArray(allowedElements) ? allowedElements : [];
22761 allowedElements = allowedElements.map((element) => element.toLowerCase());
22762 forEachLine(lineMetadata(), (line, lineIndex, inCode) => {
22764 // eslint-disable-next-line no-unmodified-loop-condition
22765 while (!inCode && ((match = htmlElementRe.exec(line)) !== null)) {
22766 const [ tag, content, element ] = match;
22767 if (!allowedElements.includes(element.toLowerCase()) &&
22768 !tag.endsWith("\\>") &&
22769 !emailAddressRe.test(content)) {
22770 const prefix = line.substring(0, match.index);
22771 if (!linkDestinationRe.test(prefix) && !inlineCodeRe.test(prefix)) {
22772 const unescaped = unescapeMarkdown(prefix + "<", "_");
22773 if (!unescaped.endsWith("_") &&
22774 ((unescaped + "`").match(/`/g).length % 2)) {
22775 addError(onError, lineIndex + 1, "Element: " + element,
22776 null, [ match.index + 1, tag.length ]);
22788 /***/ (function(module, exports, __webpack_require__) {
22795 const { addErrorContext, bareUrlRe, filterTokens } = __webpack_require__(110);
22798 "names": [ "MD034", "no-bare-urls" ],
22799 "description": "Bare URL used",
22800 "tags": [ "links", "url" ],
22801 "function": function MD034(params, onError) {
22802 filterTokens(params, "inline", (token) => {
22803 let inLink = false;
22804 token.children.forEach((child) => {
22805 const { content, line, lineNumber, type } = child;
22807 if (type === "link_open") {
22809 } else if (type === "link_close") {
22811 } else if ((type === "text") && !inLink) {
22812 while ((match = bareUrlRe.exec(content)) !== null) {
22813 const [ bareUrl ] = match;
22814 const matchIndex = match.index;
22815 const bareUrlLength = bareUrl.length;
22816 // Allow "[https://example.com]" to avoid conflicts with
22817 // MD011/no-reversed-links; allow quoting as another way
22818 // of deliberately including a bare URL
22819 const leftChar = content[matchIndex - 1];
22820 const rightChar = content[matchIndex + bareUrlLength];
22822 !((leftChar === "[") && (rightChar === "]")) &&
22823 !((leftChar === "\"") && (rightChar === "\"")) &&
22824 !((leftChar === "'") && (rightChar === "'"))
22826 const index = line.indexOf(content);
22827 const range = (index === -1) ? null : [
22828 index + matchIndex + 1,
22831 const fixInfo = range ? {
22832 "editColumn": range[0],
22833 "deleteCount": range[1],
22834 "insertText": `<${bareUrl}>`
22856 /***/ (function(module, exports, __webpack_require__) {
22863 const { addErrorDetailIf, filterTokens } = __webpack_require__(110);
22866 "names": [ "MD035", "hr-style" ],
22867 "description": "Horizontal rule style",
22869 "function": function MD035(params, onError) {
22870 let style = String(params.config.style || "consistent");
22871 filterTokens(params, "hr", function forToken(token) {
22872 const lineTrim = token.line.trim();
22873 if (style === "consistent") {
22876 addErrorDetailIf(onError, token.lineNumber, style, lineTrim);
22884 /***/ (function(module, exports, __webpack_require__) {
22891 const { addErrorContext, allPunctuation } = __webpack_require__(110);
22894 "names": [ "MD036", "no-emphasis-as-heading", "no-emphasis-as-header" ],
22895 "description": "Emphasis used instead of a heading",
22896 "tags": [ "headings", "headers", "emphasis" ],
22897 "function": function MD036(params, onError) {
22898 let punctuation = params.config.punctuation;
22900 String((punctuation === undefined) ? allPunctuation : punctuation);
22901 const re = new RegExp("[" + punctuation + "]$");
22902 // eslint-disable-next-line jsdoc/require-jsdoc
22903 function base(token) {
22904 if (token.type === "paragraph_open") {
22905 return function inParagraph(t) {
22906 // Always paragraph_open/inline/paragraph_close,
22907 const children = t.children.filter(function notEmptyText(child) {
22908 return (child.type !== "text") || (child.content !== "");
22910 if ((children.length === 3) &&
22911 ((children[0].type === "strong_open") ||
22912 (children[0].type === "em_open")) &&
22913 (children[1].type === "text") &&
22914 !re.test(children[1].content)) {
22915 addErrorContext(onError, t.lineNumber,
22916 children[1].content);
22920 } else if (token.type === "blockquote_open") {
22921 return function inBlockquote(t) {
22922 if (t.type !== "blockquote_close") {
22923 return inBlockquote;
22927 } else if (token.type === "list_item_open") {
22928 return function inListItem(t) {
22929 if (t.type !== "list_item_close") {
22938 params.tokens.forEach(function forToken(token) {
22939 state = state(token);
22947 /***/ (function(module, exports, __webpack_require__) {
22954 const { addErrorContext, emphasisMarkersInContent, forEachLine, isBlankLine } =
22955 __webpack_require__(110);
22956 const { lineMetadata } = __webpack_require__(115);
22958 const emphasisRe = /(^|[^\\]|\\\\)(?:(\*\*?\*?)|(__?_?))/g;
22959 const asteriskListItemMarkerRe = /^([\s>]*)\*(\s+)/;
22960 const leftSpaceRe = /^\s+/;
22961 const rightSpaceRe = /\s+$/;
22964 "names": [ "MD037", "no-space-in-emphasis" ],
22965 "description": "Spaces inside emphasis markers",
22966 "tags": [ "whitespace", "emphasis" ],
22967 "function": function MD037(params, onError) {
22968 // eslint-disable-next-line init-declarations
22969 let effectiveEmphasisLength, emphasisIndex, emphasisKind, emphasisLength,
22970 pendingError = null;
22971 // eslint-disable-next-line jsdoc/require-jsdoc
22972 function resetRunTracking() {
22973 emphasisIndex = -1;
22974 emphasisLength = 0;
22976 effectiveEmphasisLength = 0;
22977 pendingError = null;
22979 // eslint-disable-next-line jsdoc/require-jsdoc
22980 function handleRunEnd(line, lineIndex, contextLength, match, matchIndex) {
22981 // Close current run
22982 let content = line.substring(emphasisIndex, matchIndex);
22983 if (!emphasisLength) {
22984 content = content.trimStart();
22987 content = content.trimEnd();
22989 const leftSpace = leftSpaceRe.test(content);
22990 const rightSpace = rightSpaceRe.test(content);
22991 if (leftSpace || rightSpace) {
22992 // Report the violation
22993 const contextStart = emphasisIndex - emphasisLength;
22994 const contextEnd = matchIndex + contextLength;
22995 const context = line.substring(contextStart, contextEnd);
22996 const column = contextStart + 1;
22997 const length = contextEnd - contextStart;
22998 const leftMarker = line.substring(contextStart, emphasisIndex);
22999 const rightMarker = match ? (match[2] || match[3]) : "";
23000 const fixedText = `${leftMarker}${content.trim()}${rightMarker}`;
23007 [ column, length ],
23009 "editColumn": column,
23010 "deleteCount": length,
23011 "insertText": fixedText
23018 const ignoreMarkersByLine = emphasisMarkersInContent(params);
23019 resetRunTracking();
23022 (line, lineIndex, inCode, onFence, inTable, inItem, onBreak) => {
23023 const onItemStart = (inItem === 1);
23024 if (inCode || inTable || onBreak || onItemStart || isBlankLine(line)) {
23025 // Emphasis resets when leaving a block
23026 resetRunTracking();
23028 if (inCode || onBreak) {
23029 // Emphasis has no meaning here
23033 // Trim overlapping '*' list item marker
23034 line = line.replace(asteriskListItemMarkerRe, "$1 $2");
23037 // Match all emphasis-looking runs in the line...
23038 while ((match = emphasisRe.exec(line))) {
23039 const ignoreMarkersForLine = ignoreMarkersByLine[lineIndex] || [];
23040 const matchIndex = match.index + match[1].length;
23041 if (ignoreMarkersForLine.includes(matchIndex)) {
23042 // Ignore emphasis markers inside code spans and links
23045 const matchLength = match[0].length - match[1].length;
23046 const matchKind = (match[2] || match[3])[0];
23047 if (emphasisIndex === -1) {
23049 emphasisIndex = matchIndex + matchLength;
23050 emphasisLength = matchLength;
23051 emphasisKind = matchKind;
23052 effectiveEmphasisLength = matchLength;
23053 } else if (matchKind === emphasisKind) {
23054 // Matching emphasis markers
23055 if (matchLength === effectiveEmphasisLength) {
23056 // Ending an existing run, report any pending error
23057 if (pendingError) {
23058 addErrorContext(...pendingError);
23059 pendingError = null;
23061 const error = handleRunEnd(
23062 line, lineIndex, effectiveEmphasisLength, match, matchIndex);
23064 addErrorContext(...error);
23067 resetRunTracking();
23068 } else if (matchLength === 3) {
23069 // Swap internal run length (1->2 or 2->1)
23070 effectiveEmphasisLength = matchLength - effectiveEmphasisLength;
23071 } else if (effectiveEmphasisLength === 3) {
23072 // Downgrade internal run (3->1 or 3->2)
23073 effectiveEmphasisLength -= matchLength;
23075 // Upgrade to internal run (1->3 or 2->3)
23076 effectiveEmphasisLength += matchLength;
23078 // Back up one character so RegExp has a chance to match the
23079 // next marker (ex: "**star**_underscore_")
23080 if (emphasisRe.lastIndex > 1) {
23081 emphasisRe.lastIndex--;
23083 } else if (emphasisRe.lastIndex > 1) {
23084 // Back up one character so RegExp has a chance to match the
23085 // mis-matched marker (ex: "*text_*")
23086 emphasisRe.lastIndex--;
23089 if (emphasisIndex !== -1) {
23090 pendingError = pendingError ||
23091 handleRunEnd(line, lineIndex, 0, null, line.length);
23092 // Adjust for pending run on new line
23094 emphasisLength = 0;
23104 /***/ (function(module, exports, __webpack_require__) {
23111 const { addErrorContext, filterTokens, forEachInlineCodeSpan, newLineRe } =
23112 __webpack_require__(110);
23114 const leftSpaceRe = /^\s([^`]|$)/;
23115 const rightSpaceRe = /[^`]\s$/;
23116 const singleLeftRightSpaceRe = /^\s(?:\S.*\S|\S)\s$/;
23119 "names": [ "MD038", "no-space-in-code" ],
23120 "description": "Spaces inside code span elements",
23121 "tags": [ "whitespace", "code" ],
23122 "function": function MD038(params, onError) {
23123 filterTokens(params, "inline", (token) => {
23124 if (token.children.some((child) => child.type === "code_inline")) {
23125 const tokenLines = params.lines.slice(token.map[0], token.map[1]);
23126 forEachInlineCodeSpan(
23127 tokenLines.join("\n"),
23128 (code, lineIndex, columnIndex, tickCount) => {
23129 let rangeIndex = columnIndex - tickCount;
23130 let rangeLength = code.length + (2 * tickCount);
23131 let rangeLineOffset = 0;
23132 let fixIndex = columnIndex;
23133 let fixLength = code.length;
23134 const codeLines = code.split(newLineRe);
23135 const left = leftSpaceRe.test(code);
23136 const right = !left && rightSpaceRe.test(code);
23137 if (right && (codeLines.length > 1)) {
23139 rangeLineOffset = codeLines.length - 1;
23142 const allowed = singleLeftRightSpaceRe.test(code);
23143 if ((left || right) && !allowed) {
23144 const codeLinesRange = codeLines[rangeLineOffset];
23145 if (codeLines.length > 1) {
23146 rangeLength = codeLinesRange.length + tickCount;
23147 fixLength = codeLinesRange.length;
23149 const context = tokenLines[lineIndex + rangeLineOffset]
23150 .substring(rangeIndex, rangeIndex + rangeLength);
23151 const codeLinesRangeTrim = codeLinesRange.trim();
23153 (codeLinesRangeTrim.startsWith("`") ? " " : "") +
23154 codeLinesRangeTrim +
23155 (codeLinesRangeTrim.endsWith("`") ? " " : "");
23158 token.lineNumber + lineIndex + rangeLineOffset,
23162 [ rangeIndex + 1, rangeLength ],
23164 "editColumn": fixIndex + 1,
23165 "deleteCount": fixLength,
23166 "insertText": fixText
23179 /***/ (function(module, exports, __webpack_require__) {
23186 const { addErrorContext, filterTokens } = __webpack_require__(110);
23188 const spaceInLinkRe = /\[(?:\s+(?:[^\]]*?)\s*|(?:[^\]]*?)\s+)](?=\(\S*\))/;
23191 "names": [ "MD039", "no-space-in-links" ],
23192 "description": "Spaces inside link text",
23193 "tags": [ "whitespace", "links" ],
23194 "function": function MD039(params, onError) {
23195 filterTokens(params, "inline", (token) => {
23196 const { children } = token;
23197 let { lineNumber } = token;
23198 let inLink = false;
23201 children.forEach((child) => {
23202 const { content, type } = child;
23203 if (type === "link_open") {
23206 } else if (type === "link_close") {
23208 const left = linkText.trimLeft().length !== linkText.length;
23209 const right = linkText.trimRight().length !== linkText.length;
23210 if (left || right) {
23211 const line = params.lines[lineNumber - 1];
23213 let fixInfo = null;
23214 const match = line.slice(lineIndex).match(spaceInLinkRe);
23216 const column = match.index + lineIndex + 1;
23217 const length = match[0].length;
23218 range = [ column, length ];
23220 "editColumn": column + 1,
23221 "deleteCount": length - 2,
23222 "insertText": linkText.trim()
23224 lineIndex = column + length - 1;
23236 } else if ((type === "softbreak") || (type === "hardbreak")) {
23239 } else if (inLink) {
23240 linkText += content;
23250 /***/ (function(module, exports, __webpack_require__) {
23257 const { addErrorContext, filterTokens } = __webpack_require__(110);
23260 "names": [ "MD040", "fenced-code-language" ],
23261 "description": "Fenced code blocks should have a language specified",
23262 "tags": [ "code", "language" ],
23263 "function": function MD040(params, onError) {
23264 filterTokens(params, "fence", function forToken(token) {
23265 if (!token.info.trim()) {
23266 addErrorContext(onError, token.lineNumber, token.line);
23275 /***/ (function(module, exports, __webpack_require__) {
23282 const { addErrorContext, frontMatterHasTitle } = __webpack_require__(110);
23285 "names": [ "MD041", "first-line-heading", "first-line-h1" ],
23286 "description": "First line in file should be a top level heading",
23287 "tags": [ "headings", "headers" ],
23288 "function": function MD041(params, onError) {
23289 const level = Number(params.config.level || 1);
23290 const tag = "h" + level;
23291 const foundFrontMatterTitle =
23292 frontMatterHasTitle(
23293 params.frontMatterLines,
23294 params.config.front_matter_title
23296 if (!foundFrontMatterTitle) {
23297 params.tokens.every((token) => {
23298 if (token.type === "html_block") {
23301 if ((token.type !== "heading_open") || (token.tag !== tag)) {
23302 addErrorContext(onError, token.lineNumber, token.line);
23313 /***/ (function(module, exports, __webpack_require__) {
23320 const { addErrorContext, filterTokens, rangeFromRegExp } =
23321 __webpack_require__(110);
23323 const emptyLinkRe = /\[[^\]]*](?:\((?:#?|(?:<>))\))/;
23326 "names": [ "MD042", "no-empty-links" ],
23327 "description": "No empty links",
23328 "tags": [ "links" ],
23329 "function": function MD042(params, onError) {
23330 filterTokens(params, "inline", function forToken(token) {
23331 let inLink = false;
23333 let emptyLink = false;
23334 token.children.forEach(function forChild(child) {
23335 if (child.type === "link_open") {
23338 child.attrs.forEach(function forAttr(attr) {
23339 if (attr[0] === "href" && (!attr[1] || (attr[1] === "#"))) {
23343 } else if (child.type === "link_close") {
23346 addErrorContext(onError, child.lineNumber,
23347 "[" + linkText + "]()", null, null,
23348 rangeFromRegExp(child.line, emptyLinkRe));
23350 } else if (inLink) {
23351 linkText += child.content;
23361 /***/ (function(module, exports, __webpack_require__) {
23368 const { addErrorContext, addErrorDetailIf, forEachHeading } =
23369 __webpack_require__(110);
23372 "names": [ "MD043", "required-headings", "required-headers" ],
23373 "description": "Required heading structure",
23374 "tags": [ "headings", "headers" ],
23375 "function": function MD043(params, onError) {
23376 const requiredHeadings = params.config.headings || params.config.headers;
23377 if (Array.isArray(requiredHeadings)) {
23379 [ 1, 2, 3, 4, 5, 6 ].forEach(function forLevel(level) {
23380 levels["h" + level] = "######".substr(-level);
23383 let optional = false;
23384 let errorCount = 0;
23385 forEachHeading(params, function forHeading(heading, content) {
23387 const actual = levels[heading.tag] + " " + content;
23388 const expected = requiredHeadings[i++] || "[None]";
23389 if (expected === "*") {
23391 } else if (expected.toLowerCase() === actual.toLowerCase()) {
23393 } else if (optional) {
23396 addErrorDetailIf(onError, heading.lineNumber,
23402 if ((i < requiredHeadings.length) && !errorCount) {
23403 addErrorContext(onError, params.lines.length,
23404 requiredHeadings[i]);
23413 /***/ (function(module, exports, __webpack_require__) {
23420 const { addErrorDetailIf, bareUrlRe, escapeForRegExp, filterTokens,
23421 forEachInlineChild, newLineRe } = __webpack_require__(110);
23423 const startNonWordRe = /^\W/;
23424 const endNonWordRe = /\W$/;
23427 "names": [ "MD044", "proper-names" ],
23428 "description": "Proper names should have the correct capitalization",
23429 "tags": [ "spelling" ],
23430 "function": function MD044(params, onError) {
23431 let names = params.config.names;
23432 names = Array.isArray(names) ? names : [];
23433 const codeBlocks = params.config.code_blocks;
23434 const includeCodeBlocks = (codeBlocks === undefined) ? true : !!codeBlocks;
23435 names.forEach((name) => {
23436 const escapedName = escapeForRegExp(name);
23437 const startNamePattern = startNonWordRe.test(name) ? "" : "\\S*\\b";
23438 const endNamePattern = endNonWordRe.test(name) ? "" : "\\b\\S*";
23439 const namePattern =
23440 `(${startNamePattern})(${escapedName})(${endNamePattern})`;
23441 const anyNameRe = new RegExp(namePattern, "gi");
23442 // eslint-disable-next-line jsdoc/require-jsdoc
23443 function forToken(token) {
23444 const fenceOffset = (token.type === "fence") ? 1 : 0;
23445 token.content.split(newLineRe)
23446 .forEach((line, index) => {
23448 while ((match = anyNameRe.exec(line)) !== null) {
23449 const [ fullMatch, leftMatch, nameMatch, rightMatch ] = match;
23450 if (fullMatch.search(bareUrlRe) === -1) {
23451 const wordMatch = fullMatch
23452 .replace(new RegExp(`^\\W{0,${leftMatch.length}}`), "")
23453 .replace(new RegExp(`\\W{0,${rightMatch.length}}$`), "");
23454 if (!names.includes(wordMatch)) {
23455 const lineNumber = token.lineNumber + index + fenceOffset;
23456 const fullLine = params.lines[lineNumber - 1];
23457 const matchLength = wordMatch.length;
23458 const matchIndex = fullLine.indexOf(wordMatch);
23459 const range = (matchIndex === -1) ?
23461 [ matchIndex + 1, matchLength ];
23462 const fixInfo = (matchIndex === -1) ?
23465 "editColumn": matchIndex + 1,
23466 "deleteCount": matchLength,
23484 forEachInlineChild(params, "text", forToken);
23485 if (includeCodeBlocks) {
23486 forEachInlineChild(params, "code_inline", forToken);
23487 filterTokens(params, "code_block", forToken);
23488 filterTokens(params, "fence", forToken);
23497 /***/ (function(module, exports, __webpack_require__) {
23504 const { addError, forEachInlineChild } = __webpack_require__(110);
23507 "names": [ "MD045", "no-alt-text" ],
23508 "description": "Images should have alternate text (alt text)",
23509 "tags": [ "accessibility", "images" ],
23510 "function": function MD045(params, onError) {
23511 forEachInlineChild(params, "image", function forToken(token) {
23512 if (token.content === "") {
23513 addError(onError, token.lineNumber);
23522 /***/ (function(module, exports, __webpack_require__) {
23529 const { addErrorDetailIf } = __webpack_require__(110);
23531 const tokenTypeToStyle = {
23533 "code_block": "indented"
23537 "names": [ "MD046", "code-block-style" ],
23538 "description": "Code block style",
23539 "tags": [ "code" ],
23540 "function": function MD046(params, onError) {
23541 let expectedStyle = String(params.config.style || "consistent");
23543 .filter((token) => token.type === "code_block" || token.type === "fence")
23544 .forEach((token) => {
23545 const { lineNumber, type } = token;
23546 if (expectedStyle === "consistent") {
23547 expectedStyle = tokenTypeToStyle[type];
23553 tokenTypeToStyle[type]);
23561 /***/ (function(module, exports, __webpack_require__) {
23568 const { addError, isBlankLine } = __webpack_require__(110);
23571 "names": [ "MD047", "single-trailing-newline" ],
23572 "description": "Files should end with a single newline character",
23573 "tags": [ "blank_lines" ],
23574 "function": function MD047(params, onError) {
23575 const lastLineNumber = params.lines.length;
23576 const lastLine = params.lines[lastLineNumber - 1];
23577 if (!isBlankLine(lastLine)) {
23583 [ lastLine.length, 1 ],
23585 "insertText": "\n",
23586 "editColumn": lastLine.length + 1
23596 /***/ (function(module, exports, __webpack_require__) {
23603 const { addErrorDetailIf, fencedCodeBlockStyleFor } = __webpack_require__(110);
23606 "names": [ "MD048", "code-fence-style" ],
23607 "description": "Code fence style",
23608 "tags": [ "code" ],
23609 "function": function MD048(params, onError) {
23610 const style = String(params.config.style || "consistent");
23611 let expectedStyle = style;
23613 .filter((token) => token.type === "fence")
23614 .forEach((fenceToken) => {
23615 const { lineNumber, markup } = fenceToken;
23616 if (expectedStyle === "consistent") {
23617 expectedStyle = fencedCodeBlockStyleFor(markup);
23623 fencedCodeBlockStyleFor(markup)
23632 /***/ (function(module, exports, __webpack_require__) {
23639 const os = __webpack_require__(111);
23641 // Regular expression for matching common newline characters
23642 // See NEWLINES_RE in markdown-it/lib/rules_core/normalize.js
23643 const newLineRe = /\r\n?|\n/g;
23644 module.exports.newLineRe = newLineRe;
23646 // Regular expression for matching common front matter (YAML and TOML)
23647 module.exports.frontMatterRe =
23648 // eslint-disable-next-line max-len
23649 /((^---\s*$[^]*?^---\s*$)|(^\+\+\+\s*$[^]*?^(\+\+\+|\.\.\.)\s*$))(\r\n|\r|\n|$)/m;
23651 // Regular expression for matching inline disable/enable comments
23652 const inlineCommentRe =
23653 // eslint-disable-next-line max-len
23654 /<!--\s*markdownlint-(?:(?:(disable|enable|capture|restore|disable-file|enable-file)((?:\s+[a-z0-9_-]+)*))|(?:(configure-file)\s+([\s\S]*?)))\s*-->/ig;
23655 module.exports.inlineCommentRe = inlineCommentRe;
23657 // Regular expressions for range matching
23658 module.exports.bareUrlRe = /(?:http|ftp)s?:\/\/[^\s\]"']*(?:\/|[^\s\]"'\W])/ig;
23659 module.exports.listItemMarkerRe = /^([\s>]*)(?:[*+-]|\d+[.)])\s+/;
23660 module.exports.orderedListItemMarkerRe = /^[\s>]*0*(\d+)[.)]/;
23662 // Regular expression for all instances of emphasis markers
23663 const emphasisMarkersRe = /[_*]/g;
23665 // Regular expression for inline links and shortcut reference links
23666 const linkRe = /\[(?:[^[\]]|\[[^\]]*\])*\](?:\(\S*\))?/g;
23668 // readFile options for reading with the UTF-8 encoding
23669 module.exports.utf8Encoding = { "encoding": "utf8" };
23671 // All punctuation characters (normal and full-width)
23672 module.exports.allPunctuation = ".,;:!?。,;:!?";
23674 // Returns true iff the input is a number
23675 module.exports.isNumber = function isNumber(obj) {
23676 return typeof obj === "number";
23679 // Returns true iff the input is a string
23680 module.exports.isString = function isString(obj) {
23681 return typeof obj === "string";
23684 // Returns true iff the input string is empty
23685 module.exports.isEmptyString = function isEmptyString(str) {
23686 return str.length === 0;
23689 // Returns true iff the input is an object
23690 module.exports.isObject = function isObject(obj) {
23691 return (obj !== null) && (typeof obj === "object") && !Array.isArray(obj);
23694 // Returns true iff the input line is blank (no content)
23695 // Example: Contains nothing, whitespace, or comments
23696 const blankLineRe = />|(?:<!--.*?-->)/g;
23697 module.exports.isBlankLine = function isBlankLine(line) {
23698 return !line || !line.trim() || !line.replace(blankLineRe, "").trim();
23702 * Compare function for Array.prototype.sort for ascending order of numbers.
23704 * @param {number} a First number.
23705 * @param {number} b Second number.
23706 * @returns {number} Positive value if a>b, negative value if b<a, 0 otherwise.
23708 module.exports.numericSortAscending = function numericSortAscending(a, b) {
23712 // Returns true iff the sorted array contains the specified element
23713 module.exports.includesSorted = function includesSorted(array, element) {
23715 let right = array.length - 1;
23716 while (left <= right) {
23717 /* eslint-disable no-bitwise */
23718 const mid = (left + right) >> 1;
23719 if (array[mid] < element) {
23721 } else if (array[mid] > element) {
23730 // Replaces the text of all properly-formatted HTML comments with whitespace
23731 // This preserves the line/column information for the rest of the document
23732 // Trailing whitespace is avoided with a '\' character in the last column
23733 // See https://www.w3.org/TR/html5/syntax.html#comments for details
23734 const htmlCommentBegin = "<!--";
23735 const htmlCommentEnd = "-->";
23736 module.exports.clearHtmlCommentText = function clearHtmlCommentText(text) {
23738 while ((i = text.indexOf(htmlCommentBegin, i)) !== -1) {
23739 const j = text.indexOf(htmlCommentEnd, i);
23741 // Un-terminated comments are treated as text
23744 const comment = text.slice(i + htmlCommentBegin.length, j);
23745 if ((comment.length > 0) &&
23746 (comment[0] !== ">") &&
23747 (comment[comment.length - 1] !== "-") &&
23748 !comment.includes("--") &&
23749 (text.slice(i, j + htmlCommentEnd.length)
23750 .search(inlineCommentRe) === -1)) {
23751 const blanks = comment
23752 .replace(/[^\r\n]/g, " ")
23753 .replace(/ ([\r\n])/g, "\\$1");
23754 text = text.slice(0, i + htmlCommentBegin.length) +
23755 blanks + text.slice(j);
23757 i = j + htmlCommentEnd.length;
23762 // Escapes a string for use in a RegExp
23763 module.exports.escapeForRegExp = function escapeForRegExp(str) {
23764 return str.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&");
23767 // Un-escapes Markdown content (simple algorithm; not a parser)
23768 const escapedMarkdownRe = /\\./g;
23769 module.exports.unescapeMarkdown =
23770 function unescapeMarkdown(markdown, replacement) {
23771 return markdown.replace(escapedMarkdownRe, (match) => {
23772 const char = match[1];
23773 if ("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~".includes(char)) {
23774 return replacement || char;
23781 * Return the string representation of a fence markup character.
23783 * @param {string} markup Fence string.
23784 * @returns {string} String representation.
23786 module.exports.fencedCodeBlockStyleFor =
23787 function fencedCodeBlockStyleFor(markup) {
23788 switch (markup[0]) {
23797 * Return the number of characters of indent for a token.
23799 * @param {Object} token MarkdownItToken instance.
23800 * @returns {number} Characters of indent.
23802 function indentFor(token) {
23803 const line = token.line.replace(/^[\s>]*(> |>)/, "");
23804 return line.length - line.trimLeft().length;
23806 module.exports.indentFor = indentFor;
23808 // Returns the heading style for a heading token
23809 module.exports.headingStyleFor = function headingStyleFor(token) {
23810 if ((token.map[1] - token.map[0]) === 1) {
23811 if (/[^\\]#\s*$/.test(token.line)) {
23812 return "atx_closed";
23820 * Return the string representation of an unordered list marker.
23822 * @param {Object} token MarkdownItToken instance.
23823 * @returns {string} String representation.
23825 module.exports.unorderedListStyleFor = function unorderedListStyleFor(token) {
23826 switch (token.markup) {
23838 * Calls the provided function for each matching token.
23840 * @param {Object} params RuleParams instance.
23841 * @param {string} type Token type identifier.
23842 * @param {Function} handler Callback function.
23845 function filterTokens(params, type, handler) {
23846 params.tokens.forEach(function forToken(token) {
23847 if (token.type === type) {
23852 module.exports.filterTokens = filterTokens;
23854 // Get line metadata array
23855 module.exports.getLineMetadata = function getLineMetadata(params) {
23856 const lineMetadata = params.lines.map(function mapLine(line, index) {
23857 return [ line, index, false, 0, false, false ];
23859 filterTokens(params, "fence", function forToken(token) {
23860 lineMetadata[token.map[0]][3] = 1;
23861 lineMetadata[token.map[1] - 1][3] = -1;
23862 for (let i = token.map[0] + 1; i < token.map[1] - 1; i++) {
23863 lineMetadata[i][2] = true;
23866 filterTokens(params, "code_block", function forToken(token) {
23867 for (let i = token.map[0]; i < token.map[1]; i++) {
23868 lineMetadata[i][2] = true;
23871 filterTokens(params, "table_open", function forToken(token) {
23872 for (let i = token.map[0]; i < token.map[1]; i++) {
23873 lineMetadata[i][4] = true;
23876 filterTokens(params, "list_item_open", function forToken(token) {
23878 for (let i = token.map[0]; i < token.map[1]; i++) {
23879 lineMetadata[i][5] = count;
23883 filterTokens(params, "hr", function forToken(token) {
23884 lineMetadata[token.map[0]][6] = true;
23886 return lineMetadata;
23889 // Calls the provided function for each line (with context)
23890 module.exports.forEachLine = function forEachLine(lineMetadata, handler) {
23891 lineMetadata.forEach(function forMetadata(metadata) {
23892 // Parameters: line, lineIndex, inCode, onFence, inTable, inItem, inBreak
23893 handler(...metadata);
23897 // Returns (nested) lists as a flat array (in order)
23898 module.exports.flattenLists = function flattenLists(params) {
23899 const flattenedLists = [];
23901 let current = null;
23903 const nestingStack = [];
23904 let lastWithMap = { "map": [ 0, 1 ] };
23905 params.tokens.forEach(function forToken(token) {
23906 if ((token.type === "bullet_list_open") ||
23907 (token.type === "ordered_list_open")) {
23908 // Save current context and start a new one
23909 stack.push(current);
23911 "unordered": (token.type === "bullet_list_open"),
23912 "parentsUnordered": !current ||
23913 (current.unordered && current.parentsUnordered),
23915 "indent": indentFor(token),
23916 "parentIndent": (current && current.indent) || 0,
23918 "nesting": nesting,
23919 "lastLineIndex": -1,
23920 "insert": flattenedLists.length
23923 } else if ((token.type === "bullet_list_close") ||
23924 (token.type === "ordered_list_close")) {
23925 // Finalize current context and restore previous
23926 current.lastLineIndex = lastWithMap.map[1];
23927 flattenedLists.splice(current.insert, 0, current);
23928 delete current.insert;
23929 current = stack.pop();
23931 } else if (token.type === "list_item_open") {
23933 current.items.push(token);
23934 } else if (token.type === "blockquote_open") {
23935 nestingStack.push(nesting);
23937 } else if (token.type === "blockquote_close") {
23938 nesting = nestingStack.pop();
23939 } else if (token.map) {
23940 // Track last token with map
23941 lastWithMap = token;
23944 return flattenedLists;
23947 // Calls the provided function for each specified inline child token
23948 module.exports.forEachInlineChild =
23949 function forEachInlineChild(params, type, handler) {
23950 filterTokens(params, "inline", function forToken(token) {
23951 token.children.forEach(function forChild(child) {
23952 if (child.type === type) {
23953 handler(child, token);
23959 // Calls the provided function for each heading's content
23960 module.exports.forEachHeading = function forEachHeading(params, handler) {
23961 let heading = null;
23962 params.tokens.forEach(function forToken(token) {
23963 if (token.type === "heading_open") {
23965 } else if (token.type === "heading_close") {
23967 } else if ((token.type === "inline") && heading) {
23968 handler(heading, token.content);
23974 * Calls the provided function for each inline code span's content.
23976 * @param {string} input Markdown content.
23977 * @param {Function} handler Callback function.
23980 function forEachInlineCodeSpan(input, handler) {
23981 let currentLine = 0;
23982 let currentColumn = 0;
23984 while (index < input.length) {
23985 let startIndex = -1;
23986 let startLine = -1;
23987 let startColumn = -1;
23989 let currentTicks = 0;
23990 let state = "normal";
23991 // Deliberate <= so trailing 0 completes the last span (ex: "text `code`")
23992 for (; index <= input.length; index++) {
23993 const char = input[index];
23994 // Ignore backticks in link destination
23995 if ((char === "[") && (state === "normal")) {
23996 state = "linkTextOpen";
23997 } else if ((char === "]") && (state === "linkTextOpen")) {
23998 state = "linkTextClosed";
23999 } else if ((char === "(") && (state === "linkTextClosed")) {
24000 state = "linkDestinationOpen";
24002 ((char === "(") && (state === "linkDestinationOpen")) ||
24003 ((char === ")") && (state === "linkDestinationOpen")) ||
24004 (state === "linkTextClosed")) {
24007 // Parse backtick open/close
24008 if ((char === "`") && (state !== "linkDestinationOpen")) {
24009 // Count backticks at start or end of code span
24011 if ((startIndex === -1) || (startColumn === -1)) {
24012 startIndex = index + 1;
24015 if ((startIndex >= 0) &&
24016 (startColumn >= 0) &&
24017 (tickCount === currentTicks)) {
24018 // Found end backticks; invoke callback for code span
24020 input.substring(startIndex, index - currentTicks),
24021 startLine, startColumn, tickCount);
24024 } else if ((startIndex >= 0) && (startColumn === -1)) {
24025 // Found start backticks
24026 tickCount = currentTicks;
24027 startLine = currentLine;
24028 startColumn = currentColumn;
24030 // Not in backticks
24033 if (char === "\n") {
24037 } else if ((char === "\\") &&
24038 ((startIndex === -1) || (startColumn === -1)) &&
24039 (input[index + 1] !== "\n")) {
24040 // Escape character outside code, skip next
24042 currentColumn += 2;
24048 if (startIndex >= 0) {
24049 // Restart loop after unmatched start backticks (ex: "`text``code``")
24050 index = startIndex;
24051 currentLine = startLine;
24052 currentColumn = startColumn;
24056 module.exports.forEachInlineCodeSpan = forEachInlineCodeSpan;
24059 * Adds a generic error object via the onError callback.
24061 * @param {Object} onError RuleOnError instance.
24062 * @param {number} lineNumber Line number.
24063 * @param {string} [detail] Error details.
24064 * @param {string} [context] Error context.
24065 * @param {number[]} [range] Column and length of error.
24066 * @param {Object} [fixInfo] RuleOnErrorFixInfo instance.
24069 function addError(onError, lineNumber, detail, context, range, fixInfo) {
24078 module.exports.addError = addError;
24080 // Adds an error object with details conditionally via the onError callback
24081 module.exports.addErrorDetailIf = function addErrorDetailIf(
24082 onError, lineNumber, expected, actual, detail, context, range, fixInfo) {
24083 if (expected !== actual) {
24087 "Expected: " + expected + "; Actual: " + actual +
24088 (detail ? "; " + detail : ""),
24095 // Adds an error object with context via the onError callback
24096 module.exports.addErrorContext = function addErrorContext(
24097 onError, lineNumber, context, left, right, range, fixInfo) {
24098 if (context.length <= 30) {
24100 } else if (left && right) {
24101 context = context.substr(0, 15) + "..." + context.substr(-15);
24102 } else if (right) {
24103 context = "..." + context.substr(-30);
24105 context = context.substr(0, 30) + "...";
24107 addError(onError, lineNumber, null, context, range, fixInfo);
24110 // Returns a range object for a line by applying a RegExp
24111 module.exports.rangeFromRegExp = function rangeFromRegExp(line, regexp) {
24113 const match = line.match(regexp);
24115 const column = match.index + 1;
24116 const length = match[0].length;
24117 range = [ column, length ];
24122 // Determines if the front matter includes a title
24123 module.exports.frontMatterHasTitle =
24124 function frontMatterHasTitle(frontMatterLines, frontMatterTitlePattern) {
24125 const ignoreFrontMatter =
24126 (frontMatterTitlePattern !== undefined) && !frontMatterTitlePattern;
24127 const frontMatterTitleRe =
24128 new RegExp(String(frontMatterTitlePattern || "^\\s*title\\s*[:=]"), "i");
24129 return !ignoreFrontMatter &&
24130 frontMatterLines.some((line) => frontMatterTitleRe.test(line));
24134 * Returns a list of emphasis markers in code spans and links.
24136 * @param {Object} params RuleParams instance.
24137 * @returns {number[][]} List of markers.
24139 function emphasisMarkersInContent(params) {
24140 const { lines } = params;
24141 const byLine = new Array(lines.length);
24142 // Search code spans
24143 filterTokens(params, "inline", (token) => {
24144 const { children, lineNumber, map } = token;
24145 if (children.some((child) => child.type === "code_inline")) {
24146 const tokenLines = lines.slice(map[0], map[1]);
24147 forEachInlineCodeSpan(
24148 tokenLines.join("\n"),
24149 (code, lineIndex, column, tickCount) => {
24150 const codeLines = code.split(newLineRe);
24151 codeLines.forEach((codeLine, codeLineIndex) => {
24153 while ((match = emphasisMarkersRe.exec(codeLine))) {
24154 const byLineIndex = lineNumber - 1 + lineIndex + codeLineIndex;
24155 const inLine = byLine[byLineIndex] || [];
24156 const codeLineOffset = codeLineIndex ? 0 : column - 1 + tickCount;
24157 inLine.push(codeLineOffset + match.index);
24158 byLine[byLineIndex] = inLine;
24166 lines.forEach((tokenLine, tokenLineIndex) => {
24167 let linkMatch = null;
24168 while ((linkMatch = linkRe.exec(tokenLine))) {
24169 let markerMatch = null;
24170 while ((markerMatch = emphasisMarkersRe.exec(linkMatch[0]))) {
24171 const inLine = byLine[tokenLineIndex] || [];
24172 inLine.push(linkMatch.index + markerMatch.index);
24173 byLine[tokenLineIndex] = inLine;
24179 module.exports.emphasisMarkersInContent = emphasisMarkersInContent;
24182 * Gets the most common line ending, falling back to the platform default.
24184 * @param {string} input Markdown content to analyze.
24185 * @returns {string} Preferred line ending.
24187 function getPreferredLineEnding(input) {
24191 const endings = input.match(newLineRe) || [];
24192 endings.forEach((ending) => {
24193 // eslint-disable-next-line default-case
24206 let preferredLineEnding = null;
24207 if (!cr && !lf && !crlf) {
24208 preferredLineEnding = os.EOL;
24209 } else if ((lf >= crlf) && (lf >= cr)) {
24210 preferredLineEnding = "\n";
24211 } else if (crlf >= cr) {
24212 preferredLineEnding = "\r\n";
24214 preferredLineEnding = "\r";
24216 return preferredLineEnding;
24218 module.exports.getPreferredLineEnding = getPreferredLineEnding;
24221 * Normalizes the fields of a RuleOnErrorFixInfo instance.
24223 * @param {Object} fixInfo RuleOnErrorFixInfo instance.
24224 * @param {number} [lineNumber] Line number.
24225 * @returns {Object} Normalized RuleOnErrorFixInfo instance.
24227 function normalizeFixInfo(fixInfo, lineNumber) {
24229 "lineNumber": fixInfo.lineNumber || lineNumber,
24230 "editColumn": fixInfo.editColumn || 1,
24231 "deleteCount": fixInfo.deleteCount || 0,
24232 "insertText": fixInfo.insertText || ""
24237 * Fixes the specified error on a line of Markdown content.
24239 * @param {string} line Line of Markdown content.
24240 * @param {Object} fixInfo RuleOnErrorFixInfo instance.
24241 * @param {string} lineEnding Line ending to use.
24242 * @returns {string} Fixed content.
24244 function applyFix(line, fixInfo, lineEnding) {
24245 const { editColumn, deleteCount, insertText } = normalizeFixInfo(fixInfo);
24246 const editIndex = editColumn - 1;
24247 return (deleteCount === -1) ?
24249 line.slice(0, editIndex) +
24250 insertText.replace(/\n/g, lineEnding || "\n") +
24251 line.slice(editIndex + deleteCount);
24253 module.exports.applyFix = applyFix;
24255 // Applies as many fixes as possible to the input lines
24256 module.exports.applyFixes = function applyFixes(input, errors) {
24257 const lineEnding = getPreferredLineEnding(input);
24258 const lines = input.split(newLineRe);
24259 // Normalize fixInfo objects
24260 let fixInfos = errors
24261 .filter((error) => error.fixInfo)
24262 .map((error) => normalizeFixInfo(error.fixInfo, error.lineNumber));
24263 // Sort bottom-to-top, line-deletes last, right-to-left, long-to-short
24264 fixInfos.sort((a, b) => {
24265 const aDeletingLine = (a.deleteCount === -1);
24266 const bDeletingLine = (b.deleteCount === -1);
24268 (b.lineNumber - a.lineNumber) ||
24269 (aDeletingLine ? 1 : (bDeletingLine ? -1 : 0)) ||
24270 (b.editColumn - a.editColumn) ||
24271 (b.insertText.length - a.insertText.length)
24274 // Remove duplicate entries (needed for following collapse step)
24275 let lastFixInfo = {};
24276 fixInfos = fixInfos.filter((fixInfo) => {
24278 (fixInfo.lineNumber !== lastFixInfo.lineNumber) ||
24279 (fixInfo.editColumn !== lastFixInfo.editColumn) ||
24280 (fixInfo.deleteCount !== lastFixInfo.deleteCount) ||
24281 (fixInfo.insertText !== lastFixInfo.insertText)
24283 lastFixInfo = fixInfo;
24286 // Collapse insert/no-delete and no-insert/delete for same line/column
24288 fixInfos.forEach((fixInfo) => {
24290 (fixInfo.lineNumber === lastFixInfo.lineNumber) &&
24291 (fixInfo.editColumn === lastFixInfo.editColumn) &&
24292 !fixInfo.insertText &&
24293 (fixInfo.deleteCount > 0) &&
24294 lastFixInfo.insertText &&
24295 !lastFixInfo.deleteCount) {
24296 fixInfo.insertText = lastFixInfo.insertText;
24297 lastFixInfo.lineNumber = 0;
24299 lastFixInfo = fixInfo;
24301 fixInfos = fixInfos.filter((fixInfo) => fixInfo.lineNumber);
24302 // Apply all (remaining/updated) fixes
24303 let lastLineIndex = -1;
24304 let lastEditIndex = -1;
24305 fixInfos.forEach((fixInfo) => {
24306 const { lineNumber, editColumn, deleteCount } = fixInfo;
24307 const lineIndex = lineNumber - 1;
24308 const editIndex = editColumn - 1;
24310 (lineIndex !== lastLineIndex) ||
24311 ((editIndex + deleteCount) < lastEditIndex) ||
24312 (deleteCount === -1)
24314 lines[lineIndex] = applyFix(lines[lineIndex], fixInfo, lineEnding);
24316 lastLineIndex = lineIndex;
24317 lastEditIndex = editIndex;
24319 // Return corrected input
24320 return lines.filter((line) => line !== null).join(lineEnding);
24326 /***/ (function(module, exports, __webpack_require__) {
24328 var cc = __webpack_require__(158)
24329 var join = __webpack_require__(38).join
24330 var deepExtend = __webpack_require__(3)
24332 var win = process.platform === "win32"
24334 ? process.env.USERPROFILE
24337 module.exports = function (name, defaults, argv, parse) {
24338 if('string' !== typeof name)
24339 throw new Error('rc(name): name *must* be string')
24341 argv = __webpack_require__(161)(process.argv.slice(2))
24343 'string' === typeof defaults
24344 ? cc.json(defaults) : defaults
24347 parse = parse || cc.parse
24349 var env = cc.env(name + '_')
24351 var configs = [defaults]
24352 var configFiles = []
24353 function addConfigFile (file) {
24354 if (configFiles.indexOf(file) >= 0) return
24355 var fileConfig = cc.file(file)
24357 configs.push(parse(fileConfig))
24358 configFiles.push(file)
24362 // which files do we look at?
24364 [join(etc, name, 'config'),
24365 join(etc, name + 'rc')].forEach(addConfigFile)
24367 [join(home, '.config', name, 'config'),
24368 join(home, '.config', name),
24369 join(home, '.' + name, 'config'),
24370 join(home, '.' + name + 'rc')].forEach(addConfigFile)
24371 addConfigFile(cc.find('.'+name+'rc'))
24372 if (env.config) addConfigFile(env.config)
24373 if (argv.config) addConfigFile(argv.config)
24375 return deepExtend.apply(null, configs.concat([
24378 configFiles.length ? {configs: configFiles, config: configFiles[configFiles.length - 1]} : undefined,
24385 /***/ (function(module, exports, __webpack_require__) {
24389 var fs = __webpack_require__(4)
24390 var ini = __webpack_require__(159)
24391 var path = __webpack_require__(38)
24392 var stripJsonComments = __webpack_require__(160)
24394 var parse = exports.parse = function (content) {
24396 //if it ends in .json or starts with { then it must be json.
24397 //must be done this way, because ini accepts everything.
24398 //can't just try and parse it and let it throw if it's not ini.
24399 //everything is ini. even json with a syntax error.
24401 if(/^\s*{/.test(content))
24402 return JSON.parse(stripJsonComments(content))
24403 return ini.parse(content)
24407 var file = exports.file = function () {
24408 var args = [].slice.call(arguments).filter(function (arg) { return arg != null })
24410 //path.join breaks if it's a not a string, so just skip this.
24412 if('string' !== typeof args[i])
24415 var file = path.join.apply(null, args)
24418 return fs.readFileSync(file,'utf-8')
24424 var json = exports.json = function () {
24425 var content = file.apply(null, arguments)
24426 return content ? parse(content) : null
24429 var env = exports.env = function (prefix, env) {
24430 env = env || process.env
24432 var l = prefix.length
24433 for(var k in env) {
24434 if(k.toLowerCase().indexOf(prefix.toLowerCase()) === 0) {
24436 var keypath = k.substring(l).split('__')
24438 // Trim empty strings from keypath array
24439 var _emptyStringIndex
24440 while ((_emptyStringIndex=keypath.indexOf('')) > -1) {
24441 keypath.splice(_emptyStringIndex, 1)
24445 keypath.forEach(function _buildSubObj(_subkey,i){
24447 // (check for _subkey first so we ignore empty strings)
24448 // (check for cursor to avoid assignment to primitive objects)
24449 if (!_subkey || typeof cursor !== 'object')
24452 // If this is the last key, just stuff the value in there
24453 // Assigns actual value from env variable to final key
24454 // (unless it's just an empty string- in that case use the last valid key)
24455 if (i === keypath.length-1)
24456 cursor[_subkey] = env[k]
24459 // Build sub-object if nothing already exists at the keypath
24460 if (cursor[_subkey] === undefined)
24461 cursor[_subkey] = {}
24463 // Increment cursor used to track the object at the current depth
24464 cursor = cursor[_subkey]
24475 var find = exports.find = function () {
24476 var rel = path.join.apply(null, [].slice.call(arguments))
24478 function find(start, rel) {
24479 var file = path.join(start, rel)
24484 if(path.dirname(start) !== start) // root
24485 return find(path.dirname(start), rel)
24488 return find(process.cwd(), rel)
24496 /***/ (function(module, exports) {
24498 exports.parse = exports.decode = decode
24500 exports.stringify = exports.encode = encode
24502 exports.safe = safe
24503 exports.unsafe = unsafe
24505 var eol = typeof process !== 'undefined' &&
24506 process.platform === 'win32' ? '\r\n' : '\n'
24508 function encode (obj, opt) {
24512 if (typeof opt === 'string') {
24519 opt.whitespace = opt.whitespace === true
24522 var separator = opt.whitespace ? ' = ' : '='
24524 Object.keys(obj).forEach(function (k, _, __) {
24526 if (val && Array.isArray(val)) {
24527 val.forEach(function (item) {
24528 out += safe(k + '[]') + separator + safe(item) + '\n'
24530 } else if (val && typeof val === 'object') {
24533 out += safe(k) + separator + safe(val) + eol
24537 if (opt.section && out.length) {
24538 out = '[' + safe(opt.section) + ']' + eol + out
24541 children.forEach(function (k, _, __) {
24542 var nk = dotSplit(k).join('\\.')
24543 var section = (opt.section ? opt.section + '.' : '') + nk
24544 var child = encode(obj[k], {
24546 whitespace: opt.whitespace
24548 if (out.length && child.length) {
24557 function dotSplit (str) {
24558 return str.replace(/\1/g, '\u0002LITERAL\\1LITERAL\u0002')
24559 .replace(/\\\./g, '\u0001')
24560 .split(/\./).map(function (part) {
24561 return part.replace(/\1/g, '\\.')
24562 .replace(/\2LITERAL\\1LITERAL\2/g, '\u0001')
24566 function decode (str) {
24570 // section |key = value
24571 var re = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i
24572 var lines = str.split(/[\r\n]+/g)
24574 lines.forEach(function (line, _, __) {
24575 if (!line || line.match(/^\s*[;#]/)) return
24576 var match = line.match(re)
24578 if (match[1] !== undefined) {
24579 section = unsafe(match[1])
24580 p = out[section] = out[section] || {}
24583 var key = unsafe(match[2])
24584 var value = match[3] ? unsafe(match[4]) : true
24588 case 'null': value = JSON.parse(value)
24591 // Convert keys with '[]' suffix to an array
24592 if (key.length > 2 && key.slice(-2) === '[]') {
24593 key = key.substring(0, key.length - 2)
24596 } else if (!Array.isArray(p[key])) {
24601 // safeguard against resetting a previously defined
24602 // array by accidentally forgetting the brackets
24603 if (Array.isArray(p[key])) {
24610 // {a:{y:1},"a.b":{x:2}} --> {a:{y:1,b:{x:2}}}
24611 // use a filter to return the keys that have to be deleted.
24612 Object.keys(out).filter(function (k, _, __) {
24614 typeof out[k] !== 'object' ||
24615 Array.isArray(out[k])) {
24618 // see if the parent section is also an object.
24619 // if so, add it to that, and mark this one for deletion
24620 var parts = dotSplit(k)
24622 var l = parts.pop()
24623 var nl = l.replace(/\\\./g, '.')
24624 parts.forEach(function (part, _, __) {
24625 if (!p[part] || typeof p[part] !== 'object') p[part] = {}
24628 if (p === out && nl === l) {
24633 }).forEach(function (del, _, __) {
24640 function isQuoted (val) {
24641 return (val.charAt(0) === '"' && val.slice(-1) === '"') ||
24642 (val.charAt(0) === "'" && val.slice(-1) === "'")
24645 function safe (val) {
24646 return (typeof val !== 'string' ||
24647 val.match(/[=\r\n]/) ||
24648 val.match(/^\[/) ||
24651 val !== val.trim())
24652 ? JSON.stringify(val)
24653 : val.replace(/;/g, '\\;').replace(/#/g, '\\#')
24656 function unsafe (val, doUnesc) {
24657 val = (val || '').trim()
24658 if (isQuoted(val)) {
24659 // remove the single quotes before calling JSON.parse
24660 if (val.charAt(0) === "'") {
24661 val = val.substr(1, val.length - 2)
24663 try { val = JSON.parse(val) } catch (_) {}
24665 // walk the val to find the first not-escaped ; character
24668 for (var i = 0, l = val.length; i < l; i++) {
24669 var c = val.charAt(i)
24671 if ('\\;#'.indexOf(c) !== -1) {
24677 } else if (';#'.indexOf(c) !== -1) {
24679 } else if (c === '\\') {
24688 return unesc.trim()
24696 /***/ (function(module, exports, __webpack_require__) {
24700 var singleComment = 1;
24701 var multiComment = 2;
24703 function stripWithoutWhitespace() {
24707 function stripWithWhitespace(str, start, end) {
24708 return str.slice(start, end).replace(/\S/g, ' ');
24711 module.exports = function (str, opts) {
24716 var insideString = false;
24717 var insideComment = false;
24720 var strip = opts.whitespace === false ? stripWithoutWhitespace : stripWithWhitespace;
24722 for (var i = 0; i < str.length; i++) {
24723 currentChar = str[i];
24724 nextChar = str[i + 1];
24726 if (!insideComment && currentChar === '"') {
24727 var escaped = str[i - 1] === '\\' && str[i - 2] !== '\\';
24729 insideString = !insideString;
24733 if (insideString) {
24737 if (!insideComment && currentChar + nextChar === '//') {
24738 ret += str.slice(offset, i);
24740 insideComment = singleComment;
24742 } else if (insideComment === singleComment && currentChar + nextChar === '\r\n') {
24744 insideComment = false;
24745 ret += strip(str, offset, i);
24748 } else if (insideComment === singleComment && currentChar === '\n') {
24749 insideComment = false;
24750 ret += strip(str, offset, i);
24752 } else if (!insideComment && currentChar + nextChar === '/*') {
24753 ret += str.slice(offset, i);
24755 insideComment = multiComment;
24758 } else if (insideComment === multiComment && currentChar + nextChar === '*/') {
24760 insideComment = false;
24761 ret += strip(str, offset, i + 1);
24767 return ret + (insideComment ? strip(str.substr(offset)) : str.substr(offset));
24773 /***/ (function(module, exports) {
24775 module.exports = function (args, opts) {
24776 if (!opts) opts = {};
24778 var flags = { bools : {}, strings : {}, unknownFn: null };
24780 if (typeof opts['unknown'] === 'function') {
24781 flags.unknownFn = opts['unknown'];
24784 if (typeof opts['boolean'] === 'boolean' && opts['boolean']) {
24785 flags.allBools = true;
24787 [].concat(opts['boolean']).filter(Boolean).forEach(function (key) {
24788 flags.bools[key] = true;
24793 Object.keys(opts.alias || {}).forEach(function (key) {
24794 aliases[key] = [].concat(opts.alias[key]);
24795 aliases[key].forEach(function (x) {
24796 aliases[x] = [key].concat(aliases[key].filter(function (y) {
24802 [].concat(opts.string).filter(Boolean).forEach(function (key) {
24803 flags.strings[key] = true;
24804 if (aliases[key]) {
24805 flags.strings[aliases[key]] = true;
24809 var defaults = opts['default'] || {};
24811 var argv = { _ : [] };
24812 Object.keys(flags.bools).forEach(function (key) {
24813 setArg(key, defaults[key] === undefined ? false : defaults[key]);
24818 if (args.indexOf('--') !== -1) {
24819 notFlags = args.slice(args.indexOf('--')+1);
24820 args = args.slice(0, args.indexOf('--'));
24823 function argDefined(key, arg) {
24824 return (flags.allBools && /^--[^=]+$/.test(arg)) ||
24825 flags.strings[key] || flags.bools[key] || aliases[key];
24828 function setArg (key, val, arg) {
24829 if (arg && flags.unknownFn && !argDefined(key, arg)) {
24830 if (flags.unknownFn(arg) === false) return;
24833 var value = !flags.strings[key] && isNumber(val)
24834 ? Number(val) : val
24836 setKey(argv, key.split('.'), value);
24838 (aliases[key] || []).forEach(function (x) {
24839 setKey(argv, x.split('.'), value);
24843 function setKey (obj, keys, value) {
24845 for (var i = 0; i < keys.length-1; i++) {
24847 if (key === '__proto__') return;
24848 if (o[key] === undefined) o[key] = {};
24849 if (o[key] === Object.prototype || o[key] === Number.prototype
24850 || o[key] === String.prototype) o[key] = {};
24851 if (o[key] === Array.prototype) o[key] = [];
24855 var key = keys[keys.length - 1];
24856 if (key === '__proto__') return;
24857 if (o === Object.prototype || o === Number.prototype
24858 || o === String.prototype) o = {};
24859 if (o === Array.prototype) o = [];
24860 if (o[key] === undefined || flags.bools[key] || typeof o[key] === 'boolean') {
24863 else if (Array.isArray(o[key])) {
24864 o[key].push(value);
24867 o[key] = [ o[key], value ];
24871 function aliasIsBoolean(key) {
24872 return aliases[key].some(function (x) {
24873 return flags.bools[x];
24877 for (var i = 0; i < args.length; i++) {
24880 if (/^--.+=/.test(arg)) {
24881 // Using [\s\S] instead of . because js doesn't support the
24882 // 'dotall' regex modifier. See:
24883 // http://stackoverflow.com/a/1068308/13216
24884 var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
24887 if (flags.bools[key]) {
24888 value = value !== 'false';
24890 setArg(key, value, arg);
24892 else if (/^--no-.+/.test(arg)) {
24893 var key = arg.match(/^--no-(.+)/)[1];
24894 setArg(key, false, arg);
24896 else if (/^--.+/.test(arg)) {
24897 var key = arg.match(/^--(.+)/)[1];
24898 var next = args[i + 1];
24899 if (next !== undefined && !/^-/.test(next)
24900 && !flags.bools[key]
24902 && (aliases[key] ? !aliasIsBoolean(key) : true)) {
24903 setArg(key, next, arg);
24906 else if (/^(true|false)$/.test(next)) {
24907 setArg(key, next === 'true', arg);
24911 setArg(key, flags.strings[key] ? '' : true, arg);
24914 else if (/^-[^-]+/.test(arg)) {
24915 var letters = arg.slice(1,-1).split('');
24917 var broken = false;
24918 for (var j = 0; j < letters.length; j++) {
24919 var next = arg.slice(j+2);
24921 if (next === '-') {
24922 setArg(letters[j], next, arg)
24926 if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) {
24927 setArg(letters[j], next.split('=')[1], arg);
24932 if (/[A-Za-z]/.test(letters[j])
24933 && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
24934 setArg(letters[j], next, arg);
24939 if (letters[j+1] && letters[j+1].match(/\W/)) {
24940 setArg(letters[j], arg.slice(j+2), arg);
24945 setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
24949 var key = arg.slice(-1)[0];
24950 if (!broken && key !== '-') {
24951 if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1])
24952 && !flags.bools[key]
24953 && (aliases[key] ? !aliasIsBoolean(key) : true)) {
24954 setArg(key, args[i+1], arg);
24957 else if (args[i+1] && /^(true|false)$/.test(args[i+1])) {
24958 setArg(key, args[i+1] === 'true', arg);
24962 setArg(key, flags.strings[key] ? '' : true, arg);
24967 if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
24969 flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
24972 if (opts.stopEarly) {
24973 argv._.push.apply(argv._, args.slice(i + 1));
24979 Object.keys(defaults).forEach(function (key) {
24980 if (!hasKey(argv, key.split('.'))) {
24981 setKey(argv, key.split('.'), defaults[key]);
24983 (aliases[key] || []).forEach(function (x) {
24984 setKey(argv, x.split('.'), defaults[key]);
24990 argv['--'] = new Array();
24991 notFlags.forEach(function(key) {
24992 argv['--'].push(key);
24996 notFlags.forEach(function(key) {
25004 function hasKey (obj, keys) {
25006 keys.slice(0,-1).forEach(function (key) {
25007 o = (o[key] || {});
25010 var key = keys[keys.length - 1];
25014 function isNumber (x) {
25015 if (typeof x === 'number') return true;
25016 if (/^0x[0-9a-f]+$/i.test(x)) return true;
25017 return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
25024 /***/ (function(module, exports, __webpack_require__) {
25027 /* --------------------------------------------------------------------------------------------
\r
25028 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
25029 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
25030 * ------------------------------------------------------------------------------------------ */
\r
25032 function __export(m) {
\r
25033 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
\r
25035 Object.defineProperty(exports, "__esModule", { value: true });
\r
25036 const vscode_jsonrpc_1 = __webpack_require__(163);
\r
25037 exports.ErrorCodes = vscode_jsonrpc_1.ErrorCodes;
\r
25038 exports.ResponseError = vscode_jsonrpc_1.ResponseError;
\r
25039 exports.CancellationToken = vscode_jsonrpc_1.CancellationToken;
\r
25040 exports.CancellationTokenSource = vscode_jsonrpc_1.CancellationTokenSource;
\r
25041 exports.Disposable = vscode_jsonrpc_1.Disposable;
\r
25042 exports.Event = vscode_jsonrpc_1.Event;
\r
25043 exports.Emitter = vscode_jsonrpc_1.Emitter;
\r
25044 exports.Trace = vscode_jsonrpc_1.Trace;
\r
25045 exports.TraceFormat = vscode_jsonrpc_1.TraceFormat;
\r
25046 exports.SetTraceNotification = vscode_jsonrpc_1.SetTraceNotification;
\r
25047 exports.LogTraceNotification = vscode_jsonrpc_1.LogTraceNotification;
\r
25048 exports.RequestType = vscode_jsonrpc_1.RequestType;
\r
25049 exports.RequestType0 = vscode_jsonrpc_1.RequestType0;
\r
25050 exports.NotificationType = vscode_jsonrpc_1.NotificationType;
\r
25051 exports.NotificationType0 = vscode_jsonrpc_1.NotificationType0;
\r
25052 exports.MessageReader = vscode_jsonrpc_1.MessageReader;
\r
25053 exports.MessageWriter = vscode_jsonrpc_1.MessageWriter;
\r
25054 exports.ConnectionStrategy = vscode_jsonrpc_1.ConnectionStrategy;
\r
25055 exports.StreamMessageReader = vscode_jsonrpc_1.StreamMessageReader;
\r
25056 exports.StreamMessageWriter = vscode_jsonrpc_1.StreamMessageWriter;
\r
25057 exports.IPCMessageReader = vscode_jsonrpc_1.IPCMessageReader;
\r
25058 exports.IPCMessageWriter = vscode_jsonrpc_1.IPCMessageWriter;
\r
25059 exports.createClientPipeTransport = vscode_jsonrpc_1.createClientPipeTransport;
\r
25060 exports.createServerPipeTransport = vscode_jsonrpc_1.createServerPipeTransport;
\r
25061 exports.generateRandomPipeName = vscode_jsonrpc_1.generateRandomPipeName;
\r
25062 exports.createClientSocketTransport = vscode_jsonrpc_1.createClientSocketTransport;
\r
25063 exports.createServerSocketTransport = vscode_jsonrpc_1.createServerSocketTransport;
\r
25064 exports.ProgressType = vscode_jsonrpc_1.ProgressType;
\r
25065 __export(__webpack_require__(175));
\r
25066 __export(__webpack_require__(176));
\r
25067 const callHierarchy = __webpack_require__(188);
\r
25068 const st = __webpack_require__(189);
\r
25070 (function (Proposed) {
\r
25071 let CallHierarchyPrepareRequest;
\r
25072 (function (CallHierarchyPrepareRequest) {
\r
25073 CallHierarchyPrepareRequest.method = callHierarchy.CallHierarchyPrepareRequest.method;
\r
25074 CallHierarchyPrepareRequest.type = callHierarchy.CallHierarchyPrepareRequest.type;
\r
25075 })(CallHierarchyPrepareRequest = Proposed.CallHierarchyPrepareRequest || (Proposed.CallHierarchyPrepareRequest = {}));
\r
25076 let CallHierarchyIncomingCallsRequest;
\r
25077 (function (CallHierarchyIncomingCallsRequest) {
\r
25078 CallHierarchyIncomingCallsRequest.method = callHierarchy.CallHierarchyIncomingCallsRequest.method;
\r
25079 CallHierarchyIncomingCallsRequest.type = callHierarchy.CallHierarchyIncomingCallsRequest.type;
\r
25080 })(CallHierarchyIncomingCallsRequest = Proposed.CallHierarchyIncomingCallsRequest || (Proposed.CallHierarchyIncomingCallsRequest = {}));
\r
25081 let CallHierarchyOutgoingCallsRequest;
\r
25082 (function (CallHierarchyOutgoingCallsRequest) {
\r
25083 CallHierarchyOutgoingCallsRequest.method = callHierarchy.CallHierarchyOutgoingCallsRequest.method;
\r
25084 CallHierarchyOutgoingCallsRequest.type = callHierarchy.CallHierarchyOutgoingCallsRequest.type;
\r
25085 })(CallHierarchyOutgoingCallsRequest = Proposed.CallHierarchyOutgoingCallsRequest || (Proposed.CallHierarchyOutgoingCallsRequest = {}));
\r
25086 Proposed.SemanticTokenTypes = st.SemanticTokenTypes;
\r
25087 Proposed.SemanticTokenModifiers = st.SemanticTokenModifiers;
\r
25088 Proposed.SemanticTokens = st.SemanticTokens;
\r
25089 let SemanticTokensRequest;
\r
25090 (function (SemanticTokensRequest) {
\r
25091 SemanticTokensRequest.method = st.SemanticTokensRequest.method;
\r
25092 SemanticTokensRequest.type = st.SemanticTokensRequest.type;
\r
25093 })(SemanticTokensRequest = Proposed.SemanticTokensRequest || (Proposed.SemanticTokensRequest = {}));
\r
25094 let SemanticTokensEditsRequest;
\r
25095 (function (SemanticTokensEditsRequest) {
\r
25096 SemanticTokensEditsRequest.method = st.SemanticTokensEditsRequest.method;
\r
25097 SemanticTokensEditsRequest.type = st.SemanticTokensEditsRequest.type;
\r
25098 })(SemanticTokensEditsRequest = Proposed.SemanticTokensEditsRequest || (Proposed.SemanticTokensEditsRequest = {}));
\r
25099 let SemanticTokensRangeRequest;
\r
25100 (function (SemanticTokensRangeRequest) {
\r
25101 SemanticTokensRangeRequest.method = st.SemanticTokensRangeRequest.method;
\r
25102 SemanticTokensRangeRequest.type = st.SemanticTokensRangeRequest.type;
\r
25103 })(SemanticTokensRangeRequest = Proposed.SemanticTokensRangeRequest || (Proposed.SemanticTokensRangeRequest = {}));
\r
25104 })(Proposed = exports.Proposed || (exports.Proposed = {}));
\r
25105 function createProtocolConnection(reader, writer, logger, strategy) {
\r
25106 return vscode_jsonrpc_1.createMessageConnection(reader, writer, logger, strategy);
\r
25108 exports.createProtocolConnection = createProtocolConnection;
\r
25113 /***/ (function(module, exports, __webpack_require__) {
25116 /* --------------------------------------------------------------------------------------------
\r
25117 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
25118 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
25119 * ------------------------------------------------------------------------------------------ */
\r
25120 /// <reference path="../typings/thenable.d.ts" />
\r
25122 function __export(m) {
\r
25123 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
\r
25125 Object.defineProperty(exports, "__esModule", { value: true });
\r
25126 const Is = __webpack_require__(164);
\r
25127 const messages_1 = __webpack_require__(165);
\r
25128 exports.RequestType = messages_1.RequestType;
\r
25129 exports.RequestType0 = messages_1.RequestType0;
\r
25130 exports.RequestType1 = messages_1.RequestType1;
\r
25131 exports.RequestType2 = messages_1.RequestType2;
\r
25132 exports.RequestType3 = messages_1.RequestType3;
\r
25133 exports.RequestType4 = messages_1.RequestType4;
\r
25134 exports.RequestType5 = messages_1.RequestType5;
\r
25135 exports.RequestType6 = messages_1.RequestType6;
\r
25136 exports.RequestType7 = messages_1.RequestType7;
\r
25137 exports.RequestType8 = messages_1.RequestType8;
\r
25138 exports.RequestType9 = messages_1.RequestType9;
\r
25139 exports.ResponseError = messages_1.ResponseError;
\r
25140 exports.ErrorCodes = messages_1.ErrorCodes;
\r
25141 exports.NotificationType = messages_1.NotificationType;
\r
25142 exports.NotificationType0 = messages_1.NotificationType0;
\r
25143 exports.NotificationType1 = messages_1.NotificationType1;
\r
25144 exports.NotificationType2 = messages_1.NotificationType2;
\r
25145 exports.NotificationType3 = messages_1.NotificationType3;
\r
25146 exports.NotificationType4 = messages_1.NotificationType4;
\r
25147 exports.NotificationType5 = messages_1.NotificationType5;
\r
25148 exports.NotificationType6 = messages_1.NotificationType6;
\r
25149 exports.NotificationType7 = messages_1.NotificationType7;
\r
25150 exports.NotificationType8 = messages_1.NotificationType8;
\r
25151 exports.NotificationType9 = messages_1.NotificationType9;
\r
25152 const messageReader_1 = __webpack_require__(166);
\r
25153 exports.MessageReader = messageReader_1.MessageReader;
\r
25154 exports.StreamMessageReader = messageReader_1.StreamMessageReader;
\r
25155 exports.IPCMessageReader = messageReader_1.IPCMessageReader;
\r
25156 exports.SocketMessageReader = messageReader_1.SocketMessageReader;
\r
25157 const messageWriter_1 = __webpack_require__(168);
\r
25158 exports.MessageWriter = messageWriter_1.MessageWriter;
\r
25159 exports.StreamMessageWriter = messageWriter_1.StreamMessageWriter;
\r
25160 exports.IPCMessageWriter = messageWriter_1.IPCMessageWriter;
\r
25161 exports.SocketMessageWriter = messageWriter_1.SocketMessageWriter;
\r
25162 const events_1 = __webpack_require__(167);
\r
25163 exports.Disposable = events_1.Disposable;
\r
25164 exports.Event = events_1.Event;
\r
25165 exports.Emitter = events_1.Emitter;
\r
25166 const cancellation_1 = __webpack_require__(169);
\r
25167 exports.CancellationTokenSource = cancellation_1.CancellationTokenSource;
\r
25168 exports.CancellationToken = cancellation_1.CancellationToken;
\r
25169 const linkedMap_1 = __webpack_require__(170);
\r
25170 __export(__webpack_require__(171));
\r
25171 __export(__webpack_require__(174));
\r
25172 var CancelNotification;
\r
25173 (function (CancelNotification) {
\r
25174 CancelNotification.type = new messages_1.NotificationType('$/cancelRequest');
\r
25175 })(CancelNotification || (CancelNotification = {}));
\r
25176 var ProgressNotification;
\r
25177 (function (ProgressNotification) {
\r
25178 ProgressNotification.type = new messages_1.NotificationType('$/progress');
\r
25179 })(ProgressNotification || (ProgressNotification = {}));
\r
25180 class ProgressType {
\r
25184 exports.ProgressType = ProgressType;
\r
25185 exports.NullLogger = Object.freeze({
\r
25186 error: () => { },
\r
25192 (function (Trace) {
\r
25193 Trace[Trace["Off"] = 0] = "Off";
\r
25194 Trace[Trace["Messages"] = 1] = "Messages";
\r
25195 Trace[Trace["Verbose"] = 2] = "Verbose";
\r
25196 })(Trace = exports.Trace || (exports.Trace = {}));
\r
25197 (function (Trace) {
\r
25198 function fromString(value) {
\r
25199 if (!Is.string(value)) {
\r
25200 return Trace.Off;
\r
25202 value = value.toLowerCase();
\r
25205 return Trace.Off;
\r
25207 return Trace.Messages;
\r
25209 return Trace.Verbose;
\r
25211 return Trace.Off;
\r
25214 Trace.fromString = fromString;
\r
25215 function toString(value) {
\r
25219 case Trace.Messages:
\r
25220 return 'messages';
\r
25221 case Trace.Verbose:
\r
25222 return 'verbose';
\r
25227 Trace.toString = toString;
\r
25228 })(Trace = exports.Trace || (exports.Trace = {}));
\r
25230 (function (TraceFormat) {
\r
25231 TraceFormat["Text"] = "text";
\r
25232 TraceFormat["JSON"] = "json";
\r
25233 })(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
\r
25234 (function (TraceFormat) {
\r
25235 function fromString(value) {
\r
25236 value = value.toLowerCase();
\r
25237 if (value === 'json') {
\r
25238 return TraceFormat.JSON;
\r
25241 return TraceFormat.Text;
\r
25244 TraceFormat.fromString = fromString;
\r
25245 })(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
\r
25246 var SetTraceNotification;
\r
25247 (function (SetTraceNotification) {
\r
25248 SetTraceNotification.type = new messages_1.NotificationType('$/setTraceNotification');
\r
25249 })(SetTraceNotification = exports.SetTraceNotification || (exports.SetTraceNotification = {}));
\r
25250 var LogTraceNotification;
\r
25251 (function (LogTraceNotification) {
\r
25252 LogTraceNotification.type = new messages_1.NotificationType('$/logTraceNotification');
\r
25253 })(LogTraceNotification = exports.LogTraceNotification || (exports.LogTraceNotification = {}));
\r
25254 var ConnectionErrors;
\r
25255 (function (ConnectionErrors) {
\r
25257 * The connection is closed.
\r
25259 ConnectionErrors[ConnectionErrors["Closed"] = 1] = "Closed";
\r
25261 * The connection got disposed.
\r
25263 ConnectionErrors[ConnectionErrors["Disposed"] = 2] = "Disposed";
\r
25265 * The connection is already in listening mode.
\r
25267 ConnectionErrors[ConnectionErrors["AlreadyListening"] = 3] = "AlreadyListening";
\r
25268 })(ConnectionErrors = exports.ConnectionErrors || (exports.ConnectionErrors = {}));
\r
25269 class ConnectionError extends Error {
\r
25270 constructor(code, message) {
\r
25272 this.code = code;
\r
25273 Object.setPrototypeOf(this, ConnectionError.prototype);
\r
25276 exports.ConnectionError = ConnectionError;
\r
25277 var ConnectionStrategy;
\r
25278 (function (ConnectionStrategy) {
\r
25279 function is(value) {
\r
25280 let candidate = value;
\r
25281 return candidate && Is.func(candidate.cancelUndispatched);
\r
25283 ConnectionStrategy.is = is;
\r
25284 })(ConnectionStrategy = exports.ConnectionStrategy || (exports.ConnectionStrategy = {}));
\r
25285 var ConnectionState;
\r
25286 (function (ConnectionState) {
\r
25287 ConnectionState[ConnectionState["New"] = 1] = "New";
\r
25288 ConnectionState[ConnectionState["Listening"] = 2] = "Listening";
\r
25289 ConnectionState[ConnectionState["Closed"] = 3] = "Closed";
\r
25290 ConnectionState[ConnectionState["Disposed"] = 4] = "Disposed";
\r
25291 })(ConnectionState || (ConnectionState = {}));
\r
25292 function _createMessageConnection(messageReader, messageWriter, logger, strategy) {
\r
25293 let sequenceNumber = 0;
\r
25294 let notificationSquenceNumber = 0;
\r
25295 let unknownResponseSquenceNumber = 0;
\r
25296 const version = '2.0';
\r
25297 let starRequestHandler = undefined;
\r
25298 let requestHandlers = Object.create(null);
\r
25299 let starNotificationHandler = undefined;
\r
25300 let notificationHandlers = Object.create(null);
\r
25301 let progressHandlers = new Map();
\r
25303 let messageQueue = new linkedMap_1.LinkedMap();
\r
25304 let responsePromises = Object.create(null);
\r
25305 let requestTokens = Object.create(null);
\r
25306 let trace = Trace.Off;
\r
25307 let traceFormat = TraceFormat.Text;
\r
25309 let state = ConnectionState.New;
\r
25310 let errorEmitter = new events_1.Emitter();
\r
25311 let closeEmitter = new events_1.Emitter();
\r
25312 let unhandledNotificationEmitter = new events_1.Emitter();
\r
25313 let unhandledProgressEmitter = new events_1.Emitter();
\r
25314 let disposeEmitter = new events_1.Emitter();
\r
25315 function createRequestQueueKey(id) {
\r
25316 return 'req-' + id.toString();
\r
25318 function createResponseQueueKey(id) {
\r
25319 if (id === null) {
\r
25320 return 'res-unknown-' + (++unknownResponseSquenceNumber).toString();
\r
25323 return 'res-' + id.toString();
\r
25326 function createNotificationQueueKey() {
\r
25327 return 'not-' + (++notificationSquenceNumber).toString();
\r
25329 function addMessageToQueue(queue, message) {
\r
25330 if (messages_1.isRequestMessage(message)) {
\r
25331 queue.set(createRequestQueueKey(message.id), message);
\r
25333 else if (messages_1.isResponseMessage(message)) {
\r
25334 queue.set(createResponseQueueKey(message.id), message);
\r
25337 queue.set(createNotificationQueueKey(), message);
\r
25340 function cancelUndispatched(_message) {
\r
25341 return undefined;
\r
25343 function isListening() {
\r
25344 return state === ConnectionState.Listening;
\r
25346 function isClosed() {
\r
25347 return state === ConnectionState.Closed;
\r
25349 function isDisposed() {
\r
25350 return state === ConnectionState.Disposed;
\r
25352 function closeHandler() {
\r
25353 if (state === ConnectionState.New || state === ConnectionState.Listening) {
\r
25354 state = ConnectionState.Closed;
\r
25355 closeEmitter.fire(undefined);
\r
25357 // If the connection is disposed don't sent close events.
\r
25359 function readErrorHandler(error) {
\r
25360 errorEmitter.fire([error, undefined, undefined]);
\r
25362 function writeErrorHandler(data) {
\r
25363 errorEmitter.fire(data);
\r
25365 messageReader.onClose(closeHandler);
\r
25366 messageReader.onError(readErrorHandler);
\r
25367 messageWriter.onClose(closeHandler);
\r
25368 messageWriter.onError(writeErrorHandler);
\r
25369 function triggerMessageQueue() {
\r
25370 if (timer || messageQueue.size === 0) {
\r
25373 timer = setImmediate(() => {
\r
25374 timer = undefined;
\r
25375 processMessageQueue();
\r
25378 function processMessageQueue() {
\r
25379 if (messageQueue.size === 0) {
\r
25382 let message = messageQueue.shift();
\r
25384 if (messages_1.isRequestMessage(message)) {
\r
25385 handleRequest(message);
\r
25387 else if (messages_1.isNotificationMessage(message)) {
\r
25388 handleNotification(message);
\r
25390 else if (messages_1.isResponseMessage(message)) {
\r
25391 handleResponse(message);
\r
25394 handleInvalidMessage(message);
\r
25398 triggerMessageQueue();
\r
25401 let callback = (message) => {
\r
25403 // We have received a cancellation message. Check if the message is still in the queue
\r
25404 // and cancel it if allowed to do so.
\r
25405 if (messages_1.isNotificationMessage(message) && message.method === CancelNotification.type.method) {
\r
25406 let key = createRequestQueueKey(message.params.id);
\r
25407 let toCancel = messageQueue.get(key);
\r
25408 if (messages_1.isRequestMessage(toCancel)) {
\r
25409 let response = strategy && strategy.cancelUndispatched ? strategy.cancelUndispatched(toCancel, cancelUndispatched) : cancelUndispatched(toCancel);
\r
25410 if (response && (response.error !== void 0 || response.result !== void 0)) {
\r
25411 messageQueue.delete(key);
\r
25412 response.id = toCancel.id;
\r
25413 traceSendingResponse(response, message.method, Date.now());
\r
25414 messageWriter.write(response);
\r
25419 addMessageToQueue(messageQueue, message);
\r
25422 triggerMessageQueue();
\r
25425 function handleRequest(requestMessage) {
\r
25426 if (isDisposed()) {
\r
25427 // we return here silently since we fired an event when the
\r
25428 // connection got disposed.
\r
25431 function reply(resultOrError, method, startTime) {
\r
25433 jsonrpc: version,
\r
25434 id: requestMessage.id
\r
25436 if (resultOrError instanceof messages_1.ResponseError) {
\r
25437 message.error = resultOrError.toJson();
\r
25440 message.result = resultOrError === void 0 ? null : resultOrError;
\r
25442 traceSendingResponse(message, method, startTime);
\r
25443 messageWriter.write(message);
\r
25445 function replyError(error, method, startTime) {
\r
25447 jsonrpc: version,
\r
25448 id: requestMessage.id,
\r
25449 error: error.toJson()
\r
25451 traceSendingResponse(message, method, startTime);
\r
25452 messageWriter.write(message);
\r
25454 function replySuccess(result, method, startTime) {
\r
25455 // The JSON RPC defines that a response must either have a result or an error
\r
25456 // So we can't treat undefined as a valid response result.
\r
25457 if (result === void 0) {
\r
25461 jsonrpc: version,
\r
25462 id: requestMessage.id,
\r
25465 traceSendingResponse(message, method, startTime);
\r
25466 messageWriter.write(message);
\r
25468 traceReceivedRequest(requestMessage);
\r
25469 let element = requestHandlers[requestMessage.method];
\r
25471 let requestHandler;
\r
25473 type = element.type;
\r
25474 requestHandler = element.handler;
\r
25476 let startTime = Date.now();
\r
25477 if (requestHandler || starRequestHandler) {
\r
25478 let cancellationSource = new cancellation_1.CancellationTokenSource();
\r
25479 let tokenKey = String(requestMessage.id);
\r
25480 requestTokens[tokenKey] = cancellationSource;
\r
25482 let handlerResult;
\r
25483 if (requestMessage.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {
\r
25484 handlerResult = requestHandler
\r
25485 ? requestHandler(cancellationSource.token)
\r
25486 : starRequestHandler(requestMessage.method, cancellationSource.token);
\r
25488 else if (Is.array(requestMessage.params) && (type === void 0 || type.numberOfParams > 1)) {
\r
25489 handlerResult = requestHandler
\r
25490 ? requestHandler(...requestMessage.params, cancellationSource.token)
\r
25491 : starRequestHandler(requestMessage.method, ...requestMessage.params, cancellationSource.token);
\r
25494 handlerResult = requestHandler
\r
25495 ? requestHandler(requestMessage.params, cancellationSource.token)
\r
25496 : starRequestHandler(requestMessage.method, requestMessage.params, cancellationSource.token);
\r
25498 let promise = handlerResult;
\r
25499 if (!handlerResult) {
\r
25500 delete requestTokens[tokenKey];
\r
25501 replySuccess(handlerResult, requestMessage.method, startTime);
\r
25503 else if (promise.then) {
\r
25504 promise.then((resultOrError) => {
\r
25505 delete requestTokens[tokenKey];
\r
25506 reply(resultOrError, requestMessage.method, startTime);
\r
25508 delete requestTokens[tokenKey];
\r
25509 if (error instanceof messages_1.ResponseError) {
\r
25510 replyError(error, requestMessage.method, startTime);
\r
25512 else if (error && Is.string(error.message)) {
\r
25513 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
\r
25516 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
\r
25521 delete requestTokens[tokenKey];
\r
25522 reply(handlerResult, requestMessage.method, startTime);
\r
25526 delete requestTokens[tokenKey];
\r
25527 if (error instanceof messages_1.ResponseError) {
\r
25528 reply(error, requestMessage.method, startTime);
\r
25530 else if (error && Is.string(error.message)) {
\r
25531 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
\r
25534 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
\r
25539 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);
\r
25542 function handleResponse(responseMessage) {
\r
25543 if (isDisposed()) {
\r
25544 // See handle request.
\r
25547 if (responseMessage.id === null) {
\r
25548 if (responseMessage.error) {
\r
25549 logger.error(`Received response message without id: Error is: \n${JSON.stringify(responseMessage.error, undefined, 4)}`);
\r
25552 logger.error(`Received response message without id. No further error information provided.`);
\r
25556 let key = String(responseMessage.id);
\r
25557 let responsePromise = responsePromises[key];
\r
25558 traceReceivedResponse(responseMessage, responsePromise);
\r
25559 if (responsePromise) {
\r
25560 delete responsePromises[key];
\r
25562 if (responseMessage.error) {
\r
25563 let error = responseMessage.error;
\r
25564 responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));
\r
25566 else if (responseMessage.result !== void 0) {
\r
25567 responsePromise.resolve(responseMessage.result);
\r
25570 throw new Error('Should never happen.');
\r
25574 if (error.message) {
\r
25575 logger.error(`Response handler '${responsePromise.method}' failed with message: ${error.message}`);
\r
25578 logger.error(`Response handler '${responsePromise.method}' failed unexpectedly.`);
\r
25584 function handleNotification(message) {
\r
25585 if (isDisposed()) {
\r
25586 // See handle request.
\r
25589 let type = undefined;
\r
25590 let notificationHandler;
\r
25591 if (message.method === CancelNotification.type.method) {
\r
25592 notificationHandler = (params) => {
\r
25593 let id = params.id;
\r
25594 let source = requestTokens[String(id)];
\r
25601 let element = notificationHandlers[message.method];
\r
25603 notificationHandler = element.handler;
\r
25604 type = element.type;
\r
25607 if (notificationHandler || starNotificationHandler) {
\r
25609 traceReceivedNotification(message);
\r
25610 if (message.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {
\r
25611 notificationHandler ? notificationHandler() : starNotificationHandler(message.method);
\r
25613 else if (Is.array(message.params) && (type === void 0 || type.numberOfParams > 1)) {
\r
25614 notificationHandler ? notificationHandler(...message.params) : starNotificationHandler(message.method, ...message.params);
\r
25617 notificationHandler ? notificationHandler(message.params) : starNotificationHandler(message.method, message.params);
\r
25621 if (error.message) {
\r
25622 logger.error(`Notification handler '${message.method}' failed with message: ${error.message}`);
\r
25625 logger.error(`Notification handler '${message.method}' failed unexpectedly.`);
\r
25630 unhandledNotificationEmitter.fire(message);
\r
25633 function handleInvalidMessage(message) {
\r
25635 logger.error('Received empty message.');
\r
25638 logger.error(`Received message which is neither a response nor a notification message:\n${JSON.stringify(message, null, 4)}`);
\r
25639 // Test whether we find an id to reject the promise
\r
25640 let responseMessage = message;
\r
25641 if (Is.string(responseMessage.id) || Is.number(responseMessage.id)) {
\r
25642 let key = String(responseMessage.id);
\r
25643 let responseHandler = responsePromises[key];
\r
25644 if (responseHandler) {
\r
25645 responseHandler.reject(new Error('The received response has neither a result nor an error property.'));
\r
25649 function traceSendingRequest(message) {
\r
25650 if (trace === Trace.Off || !tracer) {
\r
25653 if (traceFormat === TraceFormat.Text) {
\r
25654 let data = undefined;
\r
25655 if (trace === Trace.Verbose && message.params) {
\r
25656 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
25658 tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);
\r
25661 logLSPMessage('send-request', message);
\r
25664 function traceSendingNotification(message) {
\r
25665 if (trace === Trace.Off || !tracer) {
\r
25668 if (traceFormat === TraceFormat.Text) {
\r
25669 let data = undefined;
\r
25670 if (trace === Trace.Verbose) {
\r
25671 if (message.params) {
\r
25672 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
25675 data = 'No parameters provided.\n\n';
\r
25678 tracer.log(`Sending notification '${message.method}'.`, data);
\r
25681 logLSPMessage('send-notification', message);
\r
25684 function traceSendingResponse(message, method, startTime) {
\r
25685 if (trace === Trace.Off || !tracer) {
\r
25688 if (traceFormat === TraceFormat.Text) {
\r
25689 let data = undefined;
\r
25690 if (trace === Trace.Verbose) {
\r
25691 if (message.error && message.error.data) {
\r
25692 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
\r
25695 if (message.result) {
\r
25696 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
\r
25698 else if (message.error === void 0) {
\r
25699 data = 'No result returned.\n\n';
\r
25703 tracer.log(`Sending response '${method} - (${message.id})'. Processing request took ${Date.now() - startTime}ms`, data);
\r
25706 logLSPMessage('send-response', message);
\r
25709 function traceReceivedRequest(message) {
\r
25710 if (trace === Trace.Off || !tracer) {
\r
25713 if (traceFormat === TraceFormat.Text) {
\r
25714 let data = undefined;
\r
25715 if (trace === Trace.Verbose && message.params) {
\r
25716 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
25718 tracer.log(`Received request '${message.method} - (${message.id})'.`, data);
\r
25721 logLSPMessage('receive-request', message);
\r
25724 function traceReceivedNotification(message) {
\r
25725 if (trace === Trace.Off || !tracer || message.method === LogTraceNotification.type.method) {
\r
25728 if (traceFormat === TraceFormat.Text) {
\r
25729 let data = undefined;
\r
25730 if (trace === Trace.Verbose) {
\r
25731 if (message.params) {
\r
25732 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
\r
25735 data = 'No parameters provided.\n\n';
\r
25738 tracer.log(`Received notification '${message.method}'.`, data);
\r
25741 logLSPMessage('receive-notification', message);
\r
25744 function traceReceivedResponse(message, responsePromise) {
\r
25745 if (trace === Trace.Off || !tracer) {
\r
25748 if (traceFormat === TraceFormat.Text) {
\r
25749 let data = undefined;
\r
25750 if (trace === Trace.Verbose) {
\r
25751 if (message.error && message.error.data) {
\r
25752 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
\r
25755 if (message.result) {
\r
25756 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
\r
25758 else if (message.error === void 0) {
\r
25759 data = 'No result returned.\n\n';
\r
25763 if (responsePromise) {
\r
25764 let error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : '';
\r
25765 tracer.log(`Received response '${responsePromise.method} - (${message.id})' in ${Date.now() - responsePromise.timerStart}ms.${error}`, data);
\r
25768 tracer.log(`Received response ${message.id} without active response promise.`, data);
\r
25772 logLSPMessage('receive-response', message);
\r
25775 function logLSPMessage(type, message) {
\r
25776 if (!tracer || trace === Trace.Off) {
\r
25779 const lspMessage = {
\r
25780 isLSPMessage: true,
\r
25783 timestamp: Date.now()
\r
25785 tracer.log(lspMessage);
\r
25787 function throwIfClosedOrDisposed() {
\r
25788 if (isClosed()) {
\r
25789 throw new ConnectionError(ConnectionErrors.Closed, 'Connection is closed.');
\r
25791 if (isDisposed()) {
\r
25792 throw new ConnectionError(ConnectionErrors.Disposed, 'Connection is disposed.');
\r
25795 function throwIfListening() {
\r
25796 if (isListening()) {
\r
25797 throw new ConnectionError(ConnectionErrors.AlreadyListening, 'Connection is already listening');
\r
25800 function throwIfNotListening() {
\r
25801 if (!isListening()) {
\r
25802 throw new Error('Call listen() first.');
\r
25805 function undefinedToNull(param) {
\r
25806 if (param === void 0) {
\r
25813 function computeMessageParams(type, params) {
\r
25815 let numberOfParams = type.numberOfParams;
\r
25816 switch (numberOfParams) {
\r
25821 result = undefinedToNull(params[0]);
\r
25825 for (let i = 0; i < params.length && i < numberOfParams; i++) {
\r
25826 result.push(undefinedToNull(params[i]));
\r
25828 if (params.length < numberOfParams) {
\r
25829 for (let i = params.length; i < numberOfParams; i++) {
\r
25830 result.push(null);
\r
25837 let connection = {
\r
25838 sendNotification: (type, ...params) => {
\r
25839 throwIfClosedOrDisposed();
\r
25841 let messageParams;
\r
25842 if (Is.string(type)) {
\r
25844 switch (params.length) {
\r
25846 messageParams = null;
\r
25849 messageParams = params[0];
\r
25852 messageParams = params;
\r
25857 method = type.method;
\r
25858 messageParams = computeMessageParams(type, params);
\r
25860 let notificationMessage = {
\r
25861 jsonrpc: version,
\r
25863 params: messageParams
\r
25865 traceSendingNotification(notificationMessage);
\r
25866 messageWriter.write(notificationMessage);
\r
25868 onNotification: (type, handler) => {
\r
25869 throwIfClosedOrDisposed();
\r
25870 if (Is.func(type)) {
\r
25871 starNotificationHandler = type;
\r
25873 else if (handler) {
\r
25874 if (Is.string(type)) {
\r
25875 notificationHandlers[type] = { type: undefined, handler };
\r
25878 notificationHandlers[type.method] = { type, handler };
\r
25882 onProgress: (_type, token, handler) => {
\r
25883 if (progressHandlers.has(token)) {
\r
25884 throw new Error(`Progress handler for token ${token} already registered`);
\r
25886 progressHandlers.set(token, handler);
\r
25889 progressHandlers.delete(token);
\r
25893 sendProgress: (_type, token, value) => {
\r
25894 connection.sendNotification(ProgressNotification.type, { token, value });
\r
25896 onUnhandledProgress: unhandledProgressEmitter.event,
\r
25897 sendRequest: (type, ...params) => {
\r
25898 throwIfClosedOrDisposed();
\r
25899 throwIfNotListening();
\r
25901 let messageParams;
\r
25902 let token = undefined;
\r
25903 if (Is.string(type)) {
\r
25905 switch (params.length) {
\r
25907 messageParams = null;
\r
25910 // The cancellation token is optional so it can also be undefined.
\r
25911 if (cancellation_1.CancellationToken.is(params[0])) {
\r
25912 messageParams = null;
\r
25913 token = params[0];
\r
25916 messageParams = undefinedToNull(params[0]);
\r
25920 const last = params.length - 1;
\r
25921 if (cancellation_1.CancellationToken.is(params[last])) {
\r
25922 token = params[last];
\r
25923 if (params.length === 2) {
\r
25924 messageParams = undefinedToNull(params[0]);
\r
25927 messageParams = params.slice(0, last).map(value => undefinedToNull(value));
\r
25931 messageParams = params.map(value => undefinedToNull(value));
\r
25937 method = type.method;
\r
25938 messageParams = computeMessageParams(type, params);
\r
25939 let numberOfParams = type.numberOfParams;
\r
25940 token = cancellation_1.CancellationToken.is(params[numberOfParams]) ? params[numberOfParams] : undefined;
\r
25942 let id = sequenceNumber++;
\r
25943 let result = new Promise((resolve, reject) => {
\r
25944 let requestMessage = {
\r
25945 jsonrpc: version,
\r
25948 params: messageParams
\r
25950 let responsePromise = { method: method, timerStart: Date.now(), resolve, reject };
\r
25951 traceSendingRequest(requestMessage);
\r
25953 messageWriter.write(requestMessage);
\r
25956 // Writing the message failed. So we need to reject the promise.
\r
25957 responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, e.message ? e.message : 'Unknown reason'));
\r
25958 responsePromise = null;
\r
25960 if (responsePromise) {
\r
25961 responsePromises[String(id)] = responsePromise;
\r
25965 token.onCancellationRequested(() => {
\r
25966 connection.sendNotification(CancelNotification.type, { id });
\r
25971 onRequest: (type, handler) => {
\r
25972 throwIfClosedOrDisposed();
\r
25973 if (Is.func(type)) {
\r
25974 starRequestHandler = type;
\r
25976 else if (handler) {
\r
25977 if (Is.string(type)) {
\r
25978 requestHandlers[type] = { type: undefined, handler };
\r
25981 requestHandlers[type.method] = { type, handler };
\r
25985 trace: (_value, _tracer, sendNotificationOrTraceOptions) => {
\r
25986 let _sendNotification = false;
\r
25987 let _traceFormat = TraceFormat.Text;
\r
25988 if (sendNotificationOrTraceOptions !== void 0) {
\r
25989 if (Is.boolean(sendNotificationOrTraceOptions)) {
\r
25990 _sendNotification = sendNotificationOrTraceOptions;
\r
25993 _sendNotification = sendNotificationOrTraceOptions.sendNotification || false;
\r
25994 _traceFormat = sendNotificationOrTraceOptions.traceFormat || TraceFormat.Text;
\r
25998 traceFormat = _traceFormat;
\r
25999 if (trace === Trace.Off) {
\r
26000 tracer = undefined;
\r
26003 tracer = _tracer;
\r
26005 if (_sendNotification && !isClosed() && !isDisposed()) {
\r
26006 connection.sendNotification(SetTraceNotification.type, { value: Trace.toString(_value) });
\r
26009 onError: errorEmitter.event,
\r
26010 onClose: closeEmitter.event,
\r
26011 onUnhandledNotification: unhandledNotificationEmitter.event,
\r
26012 onDispose: disposeEmitter.event,
\r
26014 if (isDisposed()) {
\r
26017 state = ConnectionState.Disposed;
\r
26018 disposeEmitter.fire(undefined);
\r
26019 let error = new Error('Connection got disposed.');
\r
26020 Object.keys(responsePromises).forEach((key) => {
\r
26021 responsePromises[key].reject(error);
\r
26023 responsePromises = Object.create(null);
\r
26024 requestTokens = Object.create(null);
\r
26025 messageQueue = new linkedMap_1.LinkedMap();
\r
26026 // Test for backwards compatibility
\r
26027 if (Is.func(messageWriter.dispose)) {
\r
26028 messageWriter.dispose();
\r
26030 if (Is.func(messageReader.dispose)) {
\r
26031 messageReader.dispose();
\r
26035 throwIfClosedOrDisposed();
\r
26036 throwIfListening();
\r
26037 state = ConnectionState.Listening;
\r
26038 messageReader.listen(callback);
\r
26041 // eslint-disable-next-line no-console
\r
26042 console.log('inspect');
\r
26045 connection.onNotification(LogTraceNotification.type, (params) => {
\r
26046 if (trace === Trace.Off || !tracer) {
\r
26049 tracer.log(params.message, trace === Trace.Verbose ? params.verbose : undefined);
\r
26051 connection.onNotification(ProgressNotification.type, (params) => {
\r
26052 const handler = progressHandlers.get(params.token);
\r
26054 handler(params.value);
\r
26057 unhandledProgressEmitter.fire(params);
\r
26060 return connection;
\r
26062 function isMessageReader(value) {
\r
26063 return value.listen !== void 0 && value.read === void 0;
\r
26065 function isMessageWriter(value) {
\r
26066 return value.write !== void 0 && value.end === void 0;
\r
26068 function createMessageConnection(input, output, logger, strategy) {
\r
26070 logger = exports.NullLogger;
\r
26072 let reader = isMessageReader(input) ? input : new messageReader_1.StreamMessageReader(input);
\r
26073 let writer = isMessageWriter(output) ? output : new messageWriter_1.StreamMessageWriter(output);
\r
26074 return _createMessageConnection(reader, writer, logger, strategy);
\r
26076 exports.createMessageConnection = createMessageConnection;
\r
26081 /***/ (function(module, exports, __webpack_require__) {
26084 /* --------------------------------------------------------------------------------------------
\r
26085 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
26086 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
26087 * ------------------------------------------------------------------------------------------ */
\r
26089 Object.defineProperty(exports, "__esModule", { value: true });
\r
26090 function boolean(value) {
\r
26091 return value === true || value === false;
\r
26093 exports.boolean = boolean;
\r
26094 function string(value) {
\r
26095 return typeof value === 'string' || value instanceof String;
\r
26097 exports.string = string;
\r
26098 function number(value) {
\r
26099 return typeof value === 'number' || value instanceof Number;
\r
26101 exports.number = number;
\r
26102 function error(value) {
\r
26103 return value instanceof Error;
\r
26105 exports.error = error;
\r
26106 function func(value) {
\r
26107 return typeof value === 'function';
\r
26109 exports.func = func;
\r
26110 function array(value) {
\r
26111 return Array.isArray(value);
\r
26113 exports.array = array;
\r
26114 function stringArray(value) {
\r
26115 return array(value) && value.every(elem => string(elem));
\r
26117 exports.stringArray = stringArray;
\r
26122 /***/ (function(module, exports, __webpack_require__) {
26125 /* --------------------------------------------------------------------------------------------
\r
26126 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
26127 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
26128 * ------------------------------------------------------------------------------------------ */
\r
26130 Object.defineProperty(exports, "__esModule", { value: true });
\r
26131 const is = __webpack_require__(164);
\r
26133 * Predefined error codes.
\r
26136 (function (ErrorCodes) {
\r
26137 // Defined by JSON RPC
\r
26138 ErrorCodes.ParseError = -32700;
\r
26139 ErrorCodes.InvalidRequest = -32600;
\r
26140 ErrorCodes.MethodNotFound = -32601;
\r
26141 ErrorCodes.InvalidParams = -32602;
\r
26142 ErrorCodes.InternalError = -32603;
\r
26143 ErrorCodes.serverErrorStart = -32099;
\r
26144 ErrorCodes.serverErrorEnd = -32000;
\r
26145 ErrorCodes.ServerNotInitialized = -32002;
\r
26146 ErrorCodes.UnknownErrorCode = -32001;
\r
26147 // Defined by the protocol.
\r
26148 ErrorCodes.RequestCancelled = -32800;
\r
26149 ErrorCodes.ContentModified = -32801;
\r
26150 // Defined by VSCode library.
\r
26151 ErrorCodes.MessageWriteError = 1;
\r
26152 ErrorCodes.MessageReadError = 2;
\r
26153 })(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));
\r
26155 * An error object return in a response in case a request
\r
26158 class ResponseError extends Error {
\r
26159 constructor(code, message, data) {
\r
26161 this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;
\r
26162 this.data = data;
\r
26163 Object.setPrototypeOf(this, ResponseError.prototype);
\r
26168 message: this.message,
\r
26173 exports.ResponseError = ResponseError;
\r
26175 * An abstract implementation of a MessageType.
\r
26177 class AbstractMessageType {
\r
26178 constructor(_method, _numberOfParams) {
\r
26179 this._method = _method;
\r
26180 this._numberOfParams = _numberOfParams;
\r
26183 return this._method;
\r
26185 get numberOfParams() {
\r
26186 return this._numberOfParams;
\r
26189 exports.AbstractMessageType = AbstractMessageType;
\r
26191 * Classes to type request response pairs
\r
26193 * The type parameter RO will be removed in the next major version
\r
26194 * of the JSON RPC library since it is a LSP concept and doesn't
\r
26195 * belong here. For now it is tagged as default never.
\r
26197 class RequestType0 extends AbstractMessageType {
\r
26198 constructor(method) {
\r
26199 super(method, 0);
\r
26202 exports.RequestType0 = RequestType0;
\r
26203 class RequestType extends AbstractMessageType {
\r
26204 constructor(method) {
\r
26205 super(method, 1);
\r
26208 exports.RequestType = RequestType;
\r
26209 class RequestType1 extends AbstractMessageType {
\r
26210 constructor(method) {
\r
26211 super(method, 1);
\r
26214 exports.RequestType1 = RequestType1;
\r
26215 class RequestType2 extends AbstractMessageType {
\r
26216 constructor(method) {
\r
26217 super(method, 2);
\r
26220 exports.RequestType2 = RequestType2;
\r
26221 class RequestType3 extends AbstractMessageType {
\r
26222 constructor(method) {
\r
26223 super(method, 3);
\r
26226 exports.RequestType3 = RequestType3;
\r
26227 class RequestType4 extends AbstractMessageType {
\r
26228 constructor(method) {
\r
26229 super(method, 4);
\r
26232 exports.RequestType4 = RequestType4;
\r
26233 class RequestType5 extends AbstractMessageType {
\r
26234 constructor(method) {
\r
26235 super(method, 5);
\r
26238 exports.RequestType5 = RequestType5;
\r
26239 class RequestType6 extends AbstractMessageType {
\r
26240 constructor(method) {
\r
26241 super(method, 6);
\r
26244 exports.RequestType6 = RequestType6;
\r
26245 class RequestType7 extends AbstractMessageType {
\r
26246 constructor(method) {
\r
26247 super(method, 7);
\r
26250 exports.RequestType7 = RequestType7;
\r
26251 class RequestType8 extends AbstractMessageType {
\r
26252 constructor(method) {
\r
26253 super(method, 8);
\r
26256 exports.RequestType8 = RequestType8;
\r
26257 class RequestType9 extends AbstractMessageType {
\r
26258 constructor(method) {
\r
26259 super(method, 9);
\r
26262 exports.RequestType9 = RequestType9;
\r
26264 * The type parameter RO will be removed in the next major version
\r
26265 * of the JSON RPC library since it is a LSP concept and doesn't
\r
26266 * belong here. For now it is tagged as default never.
\r
26268 class NotificationType extends AbstractMessageType {
\r
26269 constructor(method) {
\r
26270 super(method, 1);
\r
26271 this._ = undefined;
\r
26274 exports.NotificationType = NotificationType;
\r
26275 class NotificationType0 extends AbstractMessageType {
\r
26276 constructor(method) {
\r
26277 super(method, 0);
\r
26280 exports.NotificationType0 = NotificationType0;
\r
26281 class NotificationType1 extends AbstractMessageType {
\r
26282 constructor(method) {
\r
26283 super(method, 1);
\r
26286 exports.NotificationType1 = NotificationType1;
\r
26287 class NotificationType2 extends AbstractMessageType {
\r
26288 constructor(method) {
\r
26289 super(method, 2);
\r
26292 exports.NotificationType2 = NotificationType2;
\r
26293 class NotificationType3 extends AbstractMessageType {
\r
26294 constructor(method) {
\r
26295 super(method, 3);
\r
26298 exports.NotificationType3 = NotificationType3;
\r
26299 class NotificationType4 extends AbstractMessageType {
\r
26300 constructor(method) {
\r
26301 super(method, 4);
\r
26304 exports.NotificationType4 = NotificationType4;
\r
26305 class NotificationType5 extends AbstractMessageType {
\r
26306 constructor(method) {
\r
26307 super(method, 5);
\r
26310 exports.NotificationType5 = NotificationType5;
\r
26311 class NotificationType6 extends AbstractMessageType {
\r
26312 constructor(method) {
\r
26313 super(method, 6);
\r
26316 exports.NotificationType6 = NotificationType6;
\r
26317 class NotificationType7 extends AbstractMessageType {
\r
26318 constructor(method) {
\r
26319 super(method, 7);
\r
26322 exports.NotificationType7 = NotificationType7;
\r
26323 class NotificationType8 extends AbstractMessageType {
\r
26324 constructor(method) {
\r
26325 super(method, 8);
\r
26328 exports.NotificationType8 = NotificationType8;
\r
26329 class NotificationType9 extends AbstractMessageType {
\r
26330 constructor(method) {
\r
26331 super(method, 9);
\r
26334 exports.NotificationType9 = NotificationType9;
\r
26336 * Tests if the given message is a request message
\r
26338 function isRequestMessage(message) {
\r
26339 let candidate = message;
\r
26340 return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));
\r
26342 exports.isRequestMessage = isRequestMessage;
\r
26344 * Tests if the given message is a notification message
\r
26346 function isNotificationMessage(message) {
\r
26347 let candidate = message;
\r
26348 return candidate && is.string(candidate.method) && message.id === void 0;
\r
26350 exports.isNotificationMessage = isNotificationMessage;
\r
26352 * Tests if the given message is a response message
\r
26354 function isResponseMessage(message) {
\r
26355 let candidate = message;
\r
26356 return candidate && (candidate.result !== void 0 || !!candidate.error) && (is.string(candidate.id) || is.number(candidate.id) || candidate.id === null);
\r
26358 exports.isResponseMessage = isResponseMessage;
\r
26363 /***/ (function(module, exports, __webpack_require__) {
26366 /* --------------------------------------------------------------------------------------------
\r
26367 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
26368 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
26369 * ------------------------------------------------------------------------------------------ */
\r
26371 Object.defineProperty(exports, "__esModule", { value: true });
\r
26372 const events_1 = __webpack_require__(167);
\r
26373 const Is = __webpack_require__(164);
\r
26374 let DefaultSize = 8192;
\r
26375 let CR = Buffer.from('\r', 'ascii')[0];
\r
26376 let LF = Buffer.from('\n', 'ascii')[0];
\r
26377 let CRLF = '\r\n';
\r
26378 class MessageBuffer {
\r
26379 constructor(encoding = 'utf8') {
\r
26380 this.encoding = encoding;
\r
26382 this.buffer = Buffer.allocUnsafe(DefaultSize);
\r
26385 var toAppend = chunk;
\r
26386 if (typeof (chunk) === 'string') {
\r
26388 var bufferLen = Buffer.byteLength(str, this.encoding);
\r
26389 toAppend = Buffer.allocUnsafe(bufferLen);
\r
26390 toAppend.write(str, 0, bufferLen, this.encoding);
\r
26392 if (this.buffer.length - this.index >= toAppend.length) {
\r
26393 toAppend.copy(this.buffer, this.index, 0, toAppend.length);
\r
26396 var newSize = (Math.ceil((this.index + toAppend.length) / DefaultSize) + 1) * DefaultSize;
\r
26397 if (this.index === 0) {
\r
26398 this.buffer = Buffer.allocUnsafe(newSize);
\r
26399 toAppend.copy(this.buffer, 0, 0, toAppend.length);
\r
26402 this.buffer = Buffer.concat([this.buffer.slice(0, this.index), toAppend], newSize);
\r
26405 this.index += toAppend.length;
\r
26407 tryReadHeaders() {
\r
26408 let result = undefined;
\r
26410 while (current + 3 < this.index && (this.buffer[current] !== CR || this.buffer[current + 1] !== LF || this.buffer[current + 2] !== CR || this.buffer[current + 3] !== LF)) {
\r
26413 // No header / body separator found (e.g CRLFCRLF)
\r
26414 if (current + 3 >= this.index) {
\r
26417 result = Object.create(null);
\r
26418 let headers = this.buffer.toString('ascii', 0, current).split(CRLF);
\r
26419 headers.forEach((header) => {
\r
26420 let index = header.indexOf(':');
\r
26421 if (index === -1) {
\r
26422 throw new Error('Message header must separate key and value using :');
\r
26424 let key = header.substr(0, index);
\r
26425 let value = header.substr(index + 1).trim();
\r
26426 result[key] = value;
\r
26428 let nextStart = current + 4;
\r
26429 this.buffer = this.buffer.slice(nextStart);
\r
26430 this.index = this.index - nextStart;
\r
26433 tryReadContent(length) {
\r
26434 if (this.index < length) {
\r
26437 let result = this.buffer.toString(this.encoding, 0, length);
\r
26438 let nextStart = length;
\r
26439 this.buffer.copy(this.buffer, 0, nextStart);
\r
26440 this.index = this.index - nextStart;
\r
26443 get numberOfBytes() {
\r
26444 return this.index;
\r
26447 var MessageReader;
\r
26448 (function (MessageReader) {
\r
26449 function is(value) {
\r
26450 let candidate = value;
\r
26451 return candidate && Is.func(candidate.listen) && Is.func(candidate.dispose) &&
\r
26452 Is.func(candidate.onError) && Is.func(candidate.onClose) && Is.func(candidate.onPartialMessage);
\r
26454 MessageReader.is = is;
\r
26455 })(MessageReader = exports.MessageReader || (exports.MessageReader = {}));
\r
26456 class AbstractMessageReader {
\r
26458 this.errorEmitter = new events_1.Emitter();
\r
26459 this.closeEmitter = new events_1.Emitter();
\r
26460 this.partialMessageEmitter = new events_1.Emitter();
\r
26463 this.errorEmitter.dispose();
\r
26464 this.closeEmitter.dispose();
\r
26467 return this.errorEmitter.event;
\r
26469 fireError(error) {
\r
26470 this.errorEmitter.fire(this.asError(error));
\r
26473 return this.closeEmitter.event;
\r
26476 this.closeEmitter.fire(undefined);
\r
26478 get onPartialMessage() {
\r
26479 return this.partialMessageEmitter.event;
\r
26481 firePartialMessage(info) {
\r
26482 this.partialMessageEmitter.fire(info);
\r
26485 if (error instanceof Error) {
\r
26489 return new Error(`Reader received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
\r
26493 exports.AbstractMessageReader = AbstractMessageReader;
\r
26494 class StreamMessageReader extends AbstractMessageReader {
\r
26495 constructor(readable, encoding = 'utf8') {
\r
26497 this.readable = readable;
\r
26498 this.buffer = new MessageBuffer(encoding);
\r
26499 this._partialMessageTimeout = 10000;
\r
26501 set partialMessageTimeout(timeout) {
\r
26502 this._partialMessageTimeout = timeout;
\r
26504 get partialMessageTimeout() {
\r
26505 return this._partialMessageTimeout;
\r
26507 listen(callback) {
\r
26508 this.nextMessageLength = -1;
\r
26509 this.messageToken = 0;
\r
26510 this.partialMessageTimer = undefined;
\r
26511 this.callback = callback;
\r
26512 this.readable.on('data', (data) => {
\r
26513 this.onData(data);
\r
26515 this.readable.on('error', (error) => this.fireError(error));
\r
26516 this.readable.on('close', () => this.fireClose());
\r
26519 this.buffer.append(data);
\r
26521 if (this.nextMessageLength === -1) {
\r
26522 let headers = this.buffer.tryReadHeaders();
\r
26526 let contentLength = headers['Content-Length'];
\r
26527 if (!contentLength) {
\r
26528 throw new Error('Header must provide a Content-Length property.');
\r
26530 let length = parseInt(contentLength);
\r
26531 if (isNaN(length)) {
\r
26532 throw new Error('Content-Length value must be a number.');
\r
26534 this.nextMessageLength = length;
\r
26535 // Take the encoding form the header. For compatibility
\r
26536 // treat both utf-8 and utf8 as node utf8
\r
26538 var msg = this.buffer.tryReadContent(this.nextMessageLength);
\r
26539 if (msg === null) {
\r
26540 /** We haven't received the full message yet. */
\r
26541 this.setPartialMessageTimer();
\r
26544 this.clearPartialMessageTimer();
\r
26545 this.nextMessageLength = -1;
\r
26546 this.messageToken++;
\r
26547 var json = JSON.parse(msg);
\r
26548 this.callback(json);
\r
26551 clearPartialMessageTimer() {
\r
26552 if (this.partialMessageTimer) {
\r
26553 clearTimeout(this.partialMessageTimer);
\r
26554 this.partialMessageTimer = undefined;
\r
26557 setPartialMessageTimer() {
\r
26558 this.clearPartialMessageTimer();
\r
26559 if (this._partialMessageTimeout <= 0) {
\r
26562 this.partialMessageTimer = setTimeout((token, timeout) => {
\r
26563 this.partialMessageTimer = undefined;
\r
26564 if (token === this.messageToken) {
\r
26565 this.firePartialMessage({ messageToken: token, waitingTime: timeout });
\r
26566 this.setPartialMessageTimer();
\r
26568 }, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);
\r
26571 exports.StreamMessageReader = StreamMessageReader;
\r
26572 class IPCMessageReader extends AbstractMessageReader {
\r
26573 constructor(process) {
\r
26575 this.process = process;
\r
26576 let eventEmitter = this.process;
\r
26577 eventEmitter.on('error', (error) => this.fireError(error));
\r
26578 eventEmitter.on('close', () => this.fireClose());
\r
26580 listen(callback) {
\r
26581 this.process.on('message', callback);
\r
26584 exports.IPCMessageReader = IPCMessageReader;
\r
26585 class SocketMessageReader extends StreamMessageReader {
\r
26586 constructor(socket, encoding = 'utf-8') {
\r
26587 super(socket, encoding);
\r
26590 exports.SocketMessageReader = SocketMessageReader;
\r
26595 /***/ (function(module, exports, __webpack_require__) {
26598 /* --------------------------------------------------------------------------------------------
\r
26599 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
26600 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
26601 * ------------------------------------------------------------------------------------------ */
\r
26603 Object.defineProperty(exports, "__esModule", { value: true });
\r
26605 (function (Disposable) {
\r
26606 function create(func) {
\r
26611 Disposable.create = create;
\r
26612 })(Disposable = exports.Disposable || (exports.Disposable = {}));
\r
26614 (function (Event) {
\r
26615 const _disposable = { dispose() { } };
\r
26616 Event.None = function () { return _disposable; };
\r
26617 })(Event = exports.Event || (exports.Event = {}));
\r
26618 class CallbackList {
\r
26619 add(callback, context = null, bucket) {
\r
26620 if (!this._callbacks) {
\r
26621 this._callbacks = [];
\r
26622 this._contexts = [];
\r
26624 this._callbacks.push(callback);
\r
26625 this._contexts.push(context);
\r
26626 if (Array.isArray(bucket)) {
\r
26627 bucket.push({ dispose: () => this.remove(callback, context) });
\r
26630 remove(callback, context = null) {
\r
26631 if (!this._callbacks) {
\r
26634 var foundCallbackWithDifferentContext = false;
\r
26635 for (var i = 0, len = this._callbacks.length; i < len; i++) {
\r
26636 if (this._callbacks[i] === callback) {
\r
26637 if (this._contexts[i] === context) {
\r
26638 // callback & context match => remove it
\r
26639 this._callbacks.splice(i, 1);
\r
26640 this._contexts.splice(i, 1);
\r
26644 foundCallbackWithDifferentContext = true;
\r
26648 if (foundCallbackWithDifferentContext) {
\r
26649 throw new Error('When adding a listener with a context, you should remove it with the same context');
\r
26652 invoke(...args) {
\r
26653 if (!this._callbacks) {
\r
26656 var ret = [], callbacks = this._callbacks.slice(0), contexts = this._contexts.slice(0);
\r
26657 for (var i = 0, len = callbacks.length; i < len; i++) {
\r
26659 ret.push(callbacks[i].apply(contexts[i], args));
\r
26662 // eslint-disable-next-line no-console
\r
26663 console.error(e);
\r
26669 return !this._callbacks || this._callbacks.length === 0;
\r
26672 this._callbacks = undefined;
\r
26673 this._contexts = undefined;
\r
26677 constructor(_options) {
\r
26678 this._options = _options;
\r
26681 * For the public to allow to subscribe
\r
26682 * to events from this Emitter
\r
26685 if (!this._event) {
\r
26686 this._event = (listener, thisArgs, disposables) => {
\r
26687 if (!this._callbacks) {
\r
26688 this._callbacks = new CallbackList();
\r
26690 if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {
\r
26691 this._options.onFirstListenerAdd(this);
\r
26693 this._callbacks.add(listener, thisArgs);
\r
26697 this._callbacks.remove(listener, thisArgs);
\r
26698 result.dispose = Emitter._noop;
\r
26699 if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) {
\r
26700 this._options.onLastListenerRemove(this);
\r
26704 if (Array.isArray(disposables)) {
\r
26705 disposables.push(result);
\r
26710 return this._event;
\r
26713 * To be kept private to fire an event to
\r
26717 if (this._callbacks) {
\r
26718 this._callbacks.invoke.call(this._callbacks, event);
\r
26722 if (this._callbacks) {
\r
26723 this._callbacks.dispose();
\r
26724 this._callbacks = undefined;
\r
26728 exports.Emitter = Emitter;
\r
26729 Emitter._noop = function () { };
\r
26734 /***/ (function(module, exports, __webpack_require__) {
26737 /* --------------------------------------------------------------------------------------------
\r
26738 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
26739 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
26740 * ------------------------------------------------------------------------------------------ */
\r
26742 Object.defineProperty(exports, "__esModule", { value: true });
\r
26743 const events_1 = __webpack_require__(167);
\r
26744 const Is = __webpack_require__(164);
\r
26745 let ContentLength = 'Content-Length: ';
\r
26746 let CRLF = '\r\n';
\r
26747 var MessageWriter;
\r
26748 (function (MessageWriter) {
\r
26749 function is(value) {
\r
26750 let candidate = value;
\r
26751 return candidate && Is.func(candidate.dispose) && Is.func(candidate.onClose) &&
\r
26752 Is.func(candidate.onError) && Is.func(candidate.write);
\r
26754 MessageWriter.is = is;
\r
26755 })(MessageWriter = exports.MessageWriter || (exports.MessageWriter = {}));
\r
26756 class AbstractMessageWriter {
\r
26758 this.errorEmitter = new events_1.Emitter();
\r
26759 this.closeEmitter = new events_1.Emitter();
\r
26762 this.errorEmitter.dispose();
\r
26763 this.closeEmitter.dispose();
\r
26766 return this.errorEmitter.event;
\r
26768 fireError(error, message, count) {
\r
26769 this.errorEmitter.fire([this.asError(error), message, count]);
\r
26772 return this.closeEmitter.event;
\r
26775 this.closeEmitter.fire(undefined);
\r
26778 if (error instanceof Error) {
\r
26782 return new Error(`Writer received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
\r
26786 exports.AbstractMessageWriter = AbstractMessageWriter;
\r
26787 class StreamMessageWriter extends AbstractMessageWriter {
\r
26788 constructor(writable, encoding = 'utf8') {
\r
26790 this.writable = writable;
\r
26791 this.encoding = encoding;
\r
26792 this.errorCount = 0;
\r
26793 this.writable.on('error', (error) => this.fireError(error));
\r
26794 this.writable.on('close', () => this.fireClose());
\r
26797 let json = JSON.stringify(msg);
\r
26798 let contentLength = Buffer.byteLength(json, this.encoding);
\r
26800 ContentLength, contentLength.toString(), CRLF,
\r
26804 // Header must be written in ASCII encoding
\r
26805 this.writable.write(headers.join(''), 'ascii');
\r
26806 // Now write the content. This can be written in any encoding
\r
26807 this.writable.write(json, this.encoding);
\r
26808 this.errorCount = 0;
\r
26811 this.errorCount++;
\r
26812 this.fireError(error, msg, this.errorCount);
\r
26816 exports.StreamMessageWriter = StreamMessageWriter;
\r
26817 class IPCMessageWriter extends AbstractMessageWriter {
\r
26818 constructor(process) {
\r
26820 this.process = process;
\r
26821 this.errorCount = 0;
\r
26823 this.sending = false;
\r
26824 let eventEmitter = this.process;
\r
26825 eventEmitter.on('error', (error) => this.fireError(error));
\r
26826 eventEmitter.on('close', () => this.fireClose);
\r
26829 if (!this.sending && this.queue.length === 0) {
\r
26830 // See https://github.com/nodejs/node/issues/7657
\r
26831 this.doWriteMessage(msg);
\r
26834 this.queue.push(msg);
\r
26837 doWriteMessage(msg) {
\r
26839 if (this.process.send) {
\r
26840 this.sending = true;
\r
26841 this.process.send(msg, undefined, undefined, (error) => {
\r
26842 this.sending = false;
\r
26844 this.errorCount++;
\r
26845 this.fireError(error, msg, this.errorCount);
\r
26848 this.errorCount = 0;
\r
26850 if (this.queue.length > 0) {
\r
26851 this.doWriteMessage(this.queue.shift());
\r
26857 this.errorCount++;
\r
26858 this.fireError(error, msg, this.errorCount);
\r
26862 exports.IPCMessageWriter = IPCMessageWriter;
\r
26863 class SocketMessageWriter extends AbstractMessageWriter {
\r
26864 constructor(socket, encoding = 'utf8') {
\r
26866 this.socket = socket;
\r
26868 this.sending = false;
\r
26869 this.encoding = encoding;
\r
26870 this.errorCount = 0;
\r
26871 this.socket.on('error', (error) => this.fireError(error));
\r
26872 this.socket.on('close', () => this.fireClose());
\r
26876 this.socket.destroy();
\r
26879 if (!this.sending && this.queue.length === 0) {
\r
26880 // See https://github.com/nodejs/node/issues/7657
\r
26881 this.doWriteMessage(msg);
\r
26884 this.queue.push(msg);
\r
26887 doWriteMessage(msg) {
\r
26888 let json = JSON.stringify(msg);
\r
26889 let contentLength = Buffer.byteLength(json, this.encoding);
\r
26891 ContentLength, contentLength.toString(), CRLF,
\r
26895 // Header must be written in ASCII encoding
\r
26896 this.sending = true;
\r
26897 this.socket.write(headers.join(''), 'ascii', (error) => {
\r
26899 this.handleError(error, msg);
\r
26902 // Now write the content. This can be written in any encoding
\r
26903 this.socket.write(json, this.encoding, (error) => {
\r
26904 this.sending = false;
\r
26906 this.handleError(error, msg);
\r
26909 this.errorCount = 0;
\r
26911 if (this.queue.length > 0) {
\r
26912 this.doWriteMessage(this.queue.shift());
\r
26917 this.handleError(error, msg);
\r
26922 this.handleError(error, msg);
\r
26925 handleError(error, msg) {
\r
26926 this.errorCount++;
\r
26927 this.fireError(error, msg, this.errorCount);
\r
26930 exports.SocketMessageWriter = SocketMessageWriter;
\r
26935 /***/ (function(module, exports, __webpack_require__) {
26938 /*---------------------------------------------------------------------------------------------
\r
26939 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
26940 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
26941 *--------------------------------------------------------------------------------------------*/
\r
26943 Object.defineProperty(exports, "__esModule", { value: true });
\r
26944 const events_1 = __webpack_require__(167);
\r
26945 const Is = __webpack_require__(164);
\r
26946 var CancellationToken;
\r
26947 (function (CancellationToken) {
\r
26948 CancellationToken.None = Object.freeze({
\r
26949 isCancellationRequested: false,
\r
26950 onCancellationRequested: events_1.Event.None
\r
26952 CancellationToken.Cancelled = Object.freeze({
\r
26953 isCancellationRequested: true,
\r
26954 onCancellationRequested: events_1.Event.None
\r
26956 function is(value) {
\r
26957 let candidate = value;
\r
26958 return candidate && (candidate === CancellationToken.None
\r
26959 || candidate === CancellationToken.Cancelled
\r
26960 || (Is.boolean(candidate.isCancellationRequested) && !!candidate.onCancellationRequested));
\r
26962 CancellationToken.is = is;
\r
26963 })(CancellationToken = exports.CancellationToken || (exports.CancellationToken = {}));
\r
26964 const shortcutEvent = Object.freeze(function (callback, context) {
\r
26965 let handle = setTimeout(callback.bind(context), 0);
\r
26966 return { dispose() { clearTimeout(handle); } };
\r
26968 class MutableToken {
\r
26970 this._isCancelled = false;
\r
26973 if (!this._isCancelled) {
\r
26974 this._isCancelled = true;
\r
26975 if (this._emitter) {
\r
26976 this._emitter.fire(undefined);
\r
26981 get isCancellationRequested() {
\r
26982 return this._isCancelled;
\r
26984 get onCancellationRequested() {
\r
26985 if (this._isCancelled) {
\r
26986 return shortcutEvent;
\r
26988 if (!this._emitter) {
\r
26989 this._emitter = new events_1.Emitter();
\r
26991 return this._emitter.event;
\r
26994 if (this._emitter) {
\r
26995 this._emitter.dispose();
\r
26996 this._emitter = undefined;
\r
27000 class CancellationTokenSource {
\r
27002 if (!this._token) {
\r
27003 // be lazy and create the token only when
\r
27004 // actually needed
\r
27005 this._token = new MutableToken();
\r
27007 return this._token;
\r
27010 if (!this._token) {
\r
27011 // save an object by returning the default
\r
27012 // cancelled token when cancellation happens
\r
27013 // before someone asks for the token
\r
27014 this._token = CancellationToken.Cancelled;
\r
27017 this._token.cancel();
\r
27021 if (!this._token) {
\r
27022 // ensure to initialize with an empty token if we had none
\r
27023 this._token = CancellationToken.None;
\r
27025 else if (this._token instanceof MutableToken) {
\r
27026 // actually dispose
\r
27027 this._token.dispose();
\r
27031 exports.CancellationTokenSource = CancellationTokenSource;
\r
27036 /***/ (function(module, exports, __webpack_require__) {
27040 /*---------------------------------------------------------------------------------------------
\r
27041 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
27042 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
27043 *--------------------------------------------------------------------------------------------*/
\r
27044 Object.defineProperty(exports, "__esModule", { value: true });
\r
27046 (function (Touch) {
\r
27050 })(Touch = exports.Touch || (exports.Touch = {}));
\r
27051 class LinkedMap {
\r
27053 this._map = new Map();
\r
27054 this._head = undefined;
\r
27055 this._tail = undefined;
\r
27059 this._map.clear();
\r
27060 this._head = undefined;
\r
27061 this._tail = undefined;
\r
27065 return !this._head && !this._tail;
\r
27068 return this._size;
\r
27071 return this._map.has(key);
\r
27074 const item = this._map.get(key);
\r
27076 return undefined;
\r
27078 return item.value;
\r
27080 set(key, value, touch = Touch.None) {
\r
27081 let item = this._map.get(key);
\r
27083 item.value = value;
\r
27084 if (touch !== Touch.None) {
\r
27085 this.touch(item, touch);
\r
27089 item = { key, value, next: undefined, previous: undefined };
\r
27092 this.addItemLast(item);
\r
27094 case Touch.First:
\r
27095 this.addItemFirst(item);
\r
27098 this.addItemLast(item);
\r
27101 this.addItemLast(item);
\r
27104 this._map.set(key, item);
\r
27109 const item = this._map.get(key);
\r
27113 this._map.delete(key);
\r
27114 this.removeItem(item);
\r
27119 if (!this._head && !this._tail) {
\r
27120 return undefined;
\r
27122 if (!this._head || !this._tail) {
\r
27123 throw new Error('Invalid list');
\r
27125 const item = this._head;
\r
27126 this._map.delete(item.key);
\r
27127 this.removeItem(item);
\r
27129 return item.value;
\r
27131 forEach(callbackfn, thisArg) {
\r
27132 let current = this._head;
\r
27133 while (current) {
\r
27135 callbackfn.bind(thisArg)(current.value, current.key, this);
\r
27138 callbackfn(current.value, current.key, this);
\r
27140 current = current.next;
\r
27143 forEachReverse(callbackfn, thisArg) {
\r
27144 let current = this._tail;
\r
27145 while (current) {
\r
27147 callbackfn.bind(thisArg)(current.value, current.key, this);
\r
27150 callbackfn(current.value, current.key, this);
\r
27152 current = current.previous;
\r
27157 let current = this._head;
\r
27158 while (current) {
\r
27159 result.push(current.value);
\r
27160 current = current.next;
\r
27166 let current = this._head;
\r
27167 while (current) {
\r
27168 result.push(current.key);
\r
27169 current = current.next;
\r
27173 /* JSON RPC run on es5 which has no Symbol.iterator
\r
27174 public keys(): IterableIterator<K> {
\r
27175 let current = this._head;
\r
27176 let iterator: IterableIterator<K> = {
\r
27177 [Symbol.iterator]() {
\r
27180 next():IteratorResult<K> {
\r
27182 let result = { value: current.key, done: false };
\r
27183 current = current.next;
\r
27186 return { value: undefined, done: true };
\r
27193 public values(): IterableIterator<V> {
\r
27194 let current = this._head;
\r
27195 let iterator: IterableIterator<V> = {
\r
27196 [Symbol.iterator]() {
\r
27199 next():IteratorResult<V> {
\r
27201 let result = { value: current.value, done: false };
\r
27202 current = current.next;
\r
27205 return { value: undefined, done: true };
\r
27212 addItemFirst(item) {
\r
27213 // First time Insert
\r
27214 if (!this._head && !this._tail) {
\r
27215 this._tail = item;
\r
27217 else if (!this._head) {
\r
27218 throw new Error('Invalid list');
\r
27221 item.next = this._head;
\r
27222 this._head.previous = item;
\r
27224 this._head = item;
\r
27226 addItemLast(item) {
\r
27227 // First time Insert
\r
27228 if (!this._head && !this._tail) {
\r
27229 this._head = item;
\r
27231 else if (!this._tail) {
\r
27232 throw new Error('Invalid list');
\r
27235 item.previous = this._tail;
\r
27236 this._tail.next = item;
\r
27238 this._tail = item;
\r
27240 removeItem(item) {
\r
27241 if (item === this._head && item === this._tail) {
\r
27242 this._head = undefined;
\r
27243 this._tail = undefined;
\r
27245 else if (item === this._head) {
\r
27246 this._head = item.next;
\r
27248 else if (item === this._tail) {
\r
27249 this._tail = item.previous;
\r
27252 const next = item.next;
\r
27253 const previous = item.previous;
\r
27254 if (!next || !previous) {
\r
27255 throw new Error('Invalid list');
\r
27257 next.previous = previous;
\r
27258 previous.next = next;
\r
27261 touch(item, touch) {
\r
27262 if (!this._head || !this._tail) {
\r
27263 throw new Error('Invalid list');
\r
27265 if ((touch !== Touch.First && touch !== Touch.Last)) {
\r
27268 if (touch === Touch.First) {
\r
27269 if (item === this._head) {
\r
27272 const next = item.next;
\r
27273 const previous = item.previous;
\r
27274 // Unlink the item
\r
27275 if (item === this._tail) {
\r
27276 // previous must be defined since item was not head but is tail
\r
27277 // So there are more than on item in the map
\r
27278 previous.next = undefined;
\r
27279 this._tail = previous;
\r
27282 // Both next and previous are not undefined since item was neither head nor tail.
\r
27283 next.previous = previous;
\r
27284 previous.next = next;
\r
27286 // Insert the node at head
\r
27287 item.previous = undefined;
\r
27288 item.next = this._head;
\r
27289 this._head.previous = item;
\r
27290 this._head = item;
\r
27292 else if (touch === Touch.Last) {
\r
27293 if (item === this._tail) {
\r
27296 const next = item.next;
\r
27297 const previous = item.previous;
\r
27298 // Unlink the item.
\r
27299 if (item === this._head) {
\r
27300 // next must be defined since item was not tail but is head
\r
27301 // So there are more than on item in the map
\r
27302 next.previous = undefined;
\r
27303 this._head = next;
\r
27306 // Both next and previous are not undefined since item was neither head nor tail.
\r
27307 next.previous = previous;
\r
27308 previous.next = next;
\r
27310 item.next = undefined;
\r
27311 item.previous = this._tail;
\r
27312 this._tail.next = item;
\r
27313 this._tail = item;
\r
27317 exports.LinkedMap = LinkedMap;
\r
27322 /***/ (function(module, exports, __webpack_require__) {
27325 /* --------------------------------------------------------------------------------------------
\r
27326 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
27327 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
27328 * ------------------------------------------------------------------------------------------ */
\r
27330 Object.defineProperty(exports, "__esModule", { value: true });
\r
27331 const path_1 = __webpack_require__(38);
\r
27332 const os_1 = __webpack_require__(111);
\r
27333 const crypto_1 = __webpack_require__(172);
\r
27334 const net_1 = __webpack_require__(173);
\r
27335 const messageReader_1 = __webpack_require__(166);
\r
27336 const messageWriter_1 = __webpack_require__(168);
\r
27337 function generateRandomPipeName() {
\r
27338 const randomSuffix = crypto_1.randomBytes(21).toString('hex');
\r
27339 if (process.platform === 'win32') {
\r
27340 return `\\\\.\\pipe\\vscode-jsonrpc-${randomSuffix}-sock`;
\r
27343 // Mac/Unix: use socket file
\r
27344 return path_1.join(os_1.tmpdir(), `vscode-${randomSuffix}.sock`);
\r
27347 exports.generateRandomPipeName = generateRandomPipeName;
\r
27348 function createClientPipeTransport(pipeName, encoding = 'utf-8') {
\r
27349 let connectResolve;
\r
27350 let connected = new Promise((resolve, _reject) => {
\r
27351 connectResolve = resolve;
\r
27353 return new Promise((resolve, reject) => {
\r
27354 let server = net_1.createServer((socket) => {
\r
27357 new messageReader_1.SocketMessageReader(socket, encoding),
\r
27358 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
27361 server.on('error', reject);
\r
27362 server.listen(pipeName, () => {
\r
27363 server.removeListener('error', reject);
\r
27365 onConnected: () => { return connected; }
\r
27370 exports.createClientPipeTransport = createClientPipeTransport;
\r
27371 function createServerPipeTransport(pipeName, encoding = 'utf-8') {
\r
27372 const socket = net_1.createConnection(pipeName);
\r
27374 new messageReader_1.SocketMessageReader(socket, encoding),
\r
27375 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
27378 exports.createServerPipeTransport = createServerPipeTransport;
\r
27383 /***/ (function(module, exports) {
27385 module.exports = require("crypto");
27389 /***/ (function(module, exports) {
27391 module.exports = require("net");
27395 /***/ (function(module, exports, __webpack_require__) {
27398 /* --------------------------------------------------------------------------------------------
\r
27399 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
27400 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
27401 * ------------------------------------------------------------------------------------------ */
\r
27403 Object.defineProperty(exports, "__esModule", { value: true });
\r
27404 const net_1 = __webpack_require__(173);
\r
27405 const messageReader_1 = __webpack_require__(166);
\r
27406 const messageWriter_1 = __webpack_require__(168);
\r
27407 function createClientSocketTransport(port, encoding = 'utf-8') {
\r
27408 let connectResolve;
\r
27409 let connected = new Promise((resolve, _reject) => {
\r
27410 connectResolve = resolve;
\r
27412 return new Promise((resolve, reject) => {
\r
27413 let server = net_1.createServer((socket) => {
\r
27416 new messageReader_1.SocketMessageReader(socket, encoding),
\r
27417 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
27420 server.on('error', reject);
\r
27421 server.listen(port, '127.0.0.1', () => {
\r
27422 server.removeListener('error', reject);
\r
27424 onConnected: () => { return connected; }
\r
27429 exports.createClientSocketTransport = createClientSocketTransport;
\r
27430 function createServerSocketTransport(port, encoding = 'utf-8') {
\r
27431 const socket = net_1.createConnection(port, '127.0.0.1');
\r
27433 new messageReader_1.SocketMessageReader(socket, encoding),
\r
27434 new messageWriter_1.SocketMessageWriter(socket, encoding)
\r
27437 exports.createServerSocketTransport = createServerSocketTransport;
\r
27442 /***/ (function(module, __webpack_exports__, __webpack_require__) {
27445 __webpack_require__.r(__webpack_exports__);
27446 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Position", function() { return Position; });
27447 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Range", function() { return Range; });
27448 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Location", function() { return Location; });
27449 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocationLink", function() { return LocationLink; });
27450 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color", function() { return Color; });
27451 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorInformation", function() { return ColorInformation; });
27452 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPresentation", function() { return ColorPresentation; });
27453 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRangeKind", function() { return FoldingRangeKind; });
27454 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRange", function() { return FoldingRange; });
27455 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticRelatedInformation", function() { return DiagnosticRelatedInformation; });
27456 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticSeverity", function() { return DiagnosticSeverity; });
27457 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticTag", function() { return DiagnosticTag; });
27458 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Diagnostic", function() { return Diagnostic; });
27459 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Command", function() { return Command; });
27460 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextEdit", function() { return TextEdit; });
27461 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentEdit", function() { return TextDocumentEdit; });
27462 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CreateFile", function() { return CreateFile; });
27463 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenameFile", function() { return RenameFile; });
27464 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeleteFile", function() { return DeleteFile; });
27465 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceEdit", function() { return WorkspaceEdit; });
27466 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceChange", function() { return WorkspaceChange; });
27467 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentIdentifier", function() { return TextDocumentIdentifier; });
27468 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VersionedTextDocumentIdentifier", function() { return VersionedTextDocumentIdentifier; });
27469 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentItem", function() { return TextDocumentItem; });
27470 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupKind", function() { return MarkupKind; });
27471 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupContent", function() { return MarkupContent; });
27472 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItemKind", function() { return CompletionItemKind; });
27473 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InsertTextFormat", function() { return InsertTextFormat; });
27474 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItemTag", function() { return CompletionItemTag; });
27475 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItem", function() { return CompletionItem; });
27476 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionList", function() { return CompletionList; });
27477 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkedString", function() { return MarkedString; });
27478 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hover", function() { return Hover; });
27479 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParameterInformation", function() { return ParameterInformation; });
27480 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SignatureInformation", function() { return SignatureInformation; });
27481 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlightKind", function() { return DocumentHighlightKind; });
27482 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlight", function() { return DocumentHighlight; });
27483 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolKind", function() { return SymbolKind; });
27484 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolTag", function() { return SymbolTag; });
27485 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolInformation", function() { return SymbolInformation; });
27486 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentSymbol", function() { return DocumentSymbol; });
27487 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionKind", function() { return CodeActionKind; });
27488 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionContext", function() { return CodeActionContext; });
27489 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeAction", function() { return CodeAction; });
27490 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeLens", function() { return CodeLens; });
27491 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FormattingOptions", function() { return FormattingOptions; });
27492 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentLink", function() { return DocumentLink; });
27493 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionRange", function() { return SelectionRange; });
27494 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EOL", function() { return EOL; });
27495 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocument", function() { return TextDocument; });
27496 /* --------------------------------------------------------------------------------------------
\r
27497 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
27498 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
27499 * ------------------------------------------------------------------------------------------ */
\r
27502 * The Position namespace provides helper functions to work with
\r
27503 * [Position](#Position) literals.
\r
27506 (function (Position) {
\r
27508 * Creates a new Position literal from the given line and character.
\r
27509 * @param line The position's line.
\r
27510 * @param character The position's character.
\r
27512 function create(line, character) {
\r
27513 return { line: line, character: character };
\r
27515 Position.create = create;
\r
27517 * Checks whether the given liternal conforms to the [Position](#Position) interface.
\r
27519 function is(value) {
\r
27520 var candidate = value;
\r
27521 return Is.objectLiteral(candidate) && Is.number(candidate.line) && Is.number(candidate.character);
\r
27523 Position.is = is;
\r
27524 })(Position || (Position = {}));
\r
27526 * The Range namespace provides helper functions to work with
\r
27527 * [Range](#Range) literals.
\r
27530 (function (Range) {
\r
27531 function create(one, two, three, four) {
\r
27532 if (Is.number(one) && Is.number(two) && Is.number(three) && Is.number(four)) {
\r
27533 return { start: Position.create(one, two), end: Position.create(three, four) };
\r
27535 else if (Position.is(one) && Position.is(two)) {
\r
27536 return { start: one, end: two };
\r
27539 throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
\r
27542 Range.create = create;
\r
27544 * Checks whether the given literal conforms to the [Range](#Range) interface.
\r
27546 function is(value) {
\r
27547 var candidate = value;
\r
27548 return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
\r
27551 })(Range || (Range = {}));
\r
27553 * The Location namespace provides helper functions to work with
\r
27554 * [Location](#Location) literals.
\r
27557 (function (Location) {
\r
27559 * Creates a Location literal.
\r
27560 * @param uri The location's uri.
\r
27561 * @param range The location's range.
\r
27563 function create(uri, range) {
\r
27564 return { uri: uri, range: range };
\r
27566 Location.create = create;
\r
27568 * Checks whether the given literal conforms to the [Location](#Location) interface.
\r
27570 function is(value) {
\r
27571 var candidate = value;
\r
27572 return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
\r
27574 Location.is = is;
\r
27575 })(Location || (Location = {}));
\r
27577 * The LocationLink namespace provides helper functions to work with
\r
27578 * [LocationLink](#LocationLink) literals.
\r
27580 var LocationLink;
\r
27581 (function (LocationLink) {
\r
27583 * Creates a LocationLink literal.
\r
27584 * @param targetUri The definition's uri.
\r
27585 * @param targetRange The full range of the definition.
\r
27586 * @param targetSelectionRange The span of the symbol definition at the target.
\r
27587 * @param originSelectionRange The span of the symbol being defined in the originating source file.
\r
27589 function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
\r
27590 return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange };
\r
27592 LocationLink.create = create;
\r
27594 * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface.
\r
27596 function is(value) {
\r
27597 var candidate = value;
\r
27598 return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri)
\r
27599 && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange))
\r
27600 && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
\r
27602 LocationLink.is = is;
\r
27603 })(LocationLink || (LocationLink = {}));
\r
27605 * The Color namespace provides helper functions to work with
\r
27606 * [Color](#Color) literals.
\r
27609 (function (Color) {
\r
27611 * Creates a new Color literal.
\r
27613 function create(red, green, blue, alpha) {
\r
27621 Color.create = create;
\r
27623 * Checks whether the given literal conforms to the [Color](#Color) interface.
\r
27625 function is(value) {
\r
27626 var candidate = value;
\r
27627 return Is.number(candidate.red)
\r
27628 && Is.number(candidate.green)
\r
27629 && Is.number(candidate.blue)
\r
27630 && Is.number(candidate.alpha);
\r
27633 })(Color || (Color = {}));
\r
27635 * The ColorInformation namespace provides helper functions to work with
\r
27636 * [ColorInformation](#ColorInformation) literals.
\r
27638 var ColorInformation;
\r
27639 (function (ColorInformation) {
\r
27641 * Creates a new ColorInformation literal.
\r
27643 function create(range, color) {
\r
27649 ColorInformation.create = create;
\r
27651 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
\r
27653 function is(value) {
\r
27654 var candidate = value;
\r
27655 return Range.is(candidate.range) && Color.is(candidate.color);
\r
27657 ColorInformation.is = is;
\r
27658 })(ColorInformation || (ColorInformation = {}));
\r
27660 * The Color namespace provides helper functions to work with
\r
27661 * [ColorPresentation](#ColorPresentation) literals.
\r
27663 var ColorPresentation;
\r
27664 (function (ColorPresentation) {
\r
27666 * Creates a new ColorInformation literal.
\r
27668 function create(label, textEdit, additionalTextEdits) {
\r
27671 textEdit: textEdit,
\r
27672 additionalTextEdits: additionalTextEdits,
\r
27675 ColorPresentation.create = create;
\r
27677 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
\r
27679 function is(value) {
\r
27680 var candidate = value;
\r
27681 return Is.string(candidate.label)
\r
27682 && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate))
\r
27683 && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
\r
27685 ColorPresentation.is = is;
\r
27686 })(ColorPresentation || (ColorPresentation = {}));
\r
27688 * Enum of known range kinds
\r
27690 var FoldingRangeKind;
\r
27691 (function (FoldingRangeKind) {
\r
27693 * Folding range for a comment
\r
27695 FoldingRangeKind["Comment"] = "comment";
\r
27697 * Folding range for a imports or includes
\r
27699 FoldingRangeKind["Imports"] = "imports";
\r
27701 * Folding range for a region (e.g. `#region`)
\r
27703 FoldingRangeKind["Region"] = "region";
\r
27704 })(FoldingRangeKind || (FoldingRangeKind = {}));
\r
27706 * The folding range namespace provides helper functions to work with
\r
27707 * [FoldingRange](#FoldingRange) literals.
\r
27709 var FoldingRange;
\r
27710 (function (FoldingRange) {
\r
27712 * Creates a new FoldingRange literal.
\r
27714 function create(startLine, endLine, startCharacter, endCharacter, kind) {
\r
27716 startLine: startLine,
\r
27719 if (Is.defined(startCharacter)) {
\r
27720 result.startCharacter = startCharacter;
\r
27722 if (Is.defined(endCharacter)) {
\r
27723 result.endCharacter = endCharacter;
\r
27725 if (Is.defined(kind)) {
\r
27726 result.kind = kind;
\r
27730 FoldingRange.create = create;
\r
27732 * Checks whether the given literal conforms to the [FoldingRange](#FoldingRange) interface.
\r
27734 function is(value) {
\r
27735 var candidate = value;
\r
27736 return Is.number(candidate.startLine) && Is.number(candidate.startLine)
\r
27737 && (Is.undefined(candidate.startCharacter) || Is.number(candidate.startCharacter))
\r
27738 && (Is.undefined(candidate.endCharacter) || Is.number(candidate.endCharacter))
\r
27739 && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
\r
27741 FoldingRange.is = is;
\r
27742 })(FoldingRange || (FoldingRange = {}));
\r
27744 * The DiagnosticRelatedInformation namespace provides helper functions to work with
\r
27745 * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.
\r
27747 var DiagnosticRelatedInformation;
\r
27748 (function (DiagnosticRelatedInformation) {
\r
27750 * Creates a new DiagnosticRelatedInformation literal.
\r
27752 function create(location, message) {
\r
27754 location: location,
\r
27758 DiagnosticRelatedInformation.create = create;
\r
27760 * Checks whether the given literal conforms to the [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) interface.
\r
27762 function is(value) {
\r
27763 var candidate = value;
\r
27764 return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
\r
27766 DiagnosticRelatedInformation.is = is;
\r
27767 })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
\r
27769 * The diagnostic's severity.
\r
27771 var DiagnosticSeverity;
\r
27772 (function (DiagnosticSeverity) {
\r
27774 * Reports an error.
\r
27776 DiagnosticSeverity.Error = 1;
\r
27778 * Reports a warning.
\r
27780 DiagnosticSeverity.Warning = 2;
\r
27782 * Reports an information.
\r
27784 DiagnosticSeverity.Information = 3;
\r
27786 * Reports a hint.
\r
27788 DiagnosticSeverity.Hint = 4;
\r
27789 })(DiagnosticSeverity || (DiagnosticSeverity = {}));
\r
27791 * The diagnostic tags.
\r
27795 var DiagnosticTag;
\r
27796 (function (DiagnosticTag) {
\r
27798 * Unused or unnecessary code.
\r
27800 * Clients are allowed to render diagnostics with this tag faded out instead of having
\r
27801 * an error squiggle.
\r
27803 DiagnosticTag.Unnecessary = 1;
\r
27805 * Deprecated or obsolete code.
\r
27807 * Clients are allowed to rendered diagnostics with this tag strike through.
\r
27809 DiagnosticTag.Deprecated = 2;
\r
27810 })(DiagnosticTag || (DiagnosticTag = {}));
\r
27812 * The Diagnostic namespace provides helper functions to work with
\r
27813 * [Diagnostic](#Diagnostic) literals.
\r
27816 (function (Diagnostic) {
\r
27818 * Creates a new Diagnostic literal.
\r
27820 function create(range, message, severity, code, source, relatedInformation) {
\r
27821 var result = { range: range, message: message };
\r
27822 if (Is.defined(severity)) {
\r
27823 result.severity = severity;
\r
27825 if (Is.defined(code)) {
\r
27826 result.code = code;
\r
27828 if (Is.defined(source)) {
\r
27829 result.source = source;
\r
27831 if (Is.defined(relatedInformation)) {
\r
27832 result.relatedInformation = relatedInformation;
\r
27836 Diagnostic.create = create;
\r
27838 * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.
\r
27840 function is(value) {
\r
27841 var candidate = value;
\r
27842 return Is.defined(candidate)
\r
27843 && Range.is(candidate.range)
\r
27844 && Is.string(candidate.message)
\r
27845 && (Is.number(candidate.severity) || Is.undefined(candidate.severity))
\r
27846 && (Is.number(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code))
\r
27847 && (Is.string(candidate.source) || Is.undefined(candidate.source))
\r
27848 && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
\r
27850 Diagnostic.is = is;
\r
27851 })(Diagnostic || (Diagnostic = {}));
\r
27853 * The Command namespace provides helper functions to work with
\r
27854 * [Command](#Command) literals.
\r
27857 (function (Command) {
\r
27859 * Creates a new Command literal.
\r
27861 function create(title, command) {
\r
27863 for (var _i = 2; _i < arguments.length; _i++) {
\r
27864 args[_i - 2] = arguments[_i];
\r
27866 var result = { title: title, command: command };
\r
27867 if (Is.defined(args) && args.length > 0) {
\r
27868 result.arguments = args;
\r
27872 Command.create = create;
\r
27874 * Checks whether the given literal conforms to the [Command](#Command) interface.
\r
27876 function is(value) {
\r
27877 var candidate = value;
\r
27878 return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
\r
27881 })(Command || (Command = {}));
\r
27883 * The TextEdit namespace provides helper function to create replace,
\r
27884 * insert and delete edits more easily.
\r
27887 (function (TextEdit) {
\r
27889 * Creates a replace text edit.
\r
27890 * @param range The range of text to be replaced.
\r
27891 * @param newText The new text.
\r
27893 function replace(range, newText) {
\r
27894 return { range: range, newText: newText };
\r
27896 TextEdit.replace = replace;
\r
27898 * Creates a insert text edit.
\r
27899 * @param position The position to insert the text at.
\r
27900 * @param newText The text to be inserted.
\r
27902 function insert(position, newText) {
\r
27903 return { range: { start: position, end: position }, newText: newText };
\r
27905 TextEdit.insert = insert;
\r
27907 * Creates a delete text edit.
\r
27908 * @param range The range of text to be deleted.
\r
27910 function del(range) {
\r
27911 return { range: range, newText: '' };
\r
27913 TextEdit.del = del;
\r
27914 function is(value) {
\r
27915 var candidate = value;
\r
27916 return Is.objectLiteral(candidate)
\r
27917 && Is.string(candidate.newText)
\r
27918 && Range.is(candidate.range);
\r
27920 TextEdit.is = is;
\r
27921 })(TextEdit || (TextEdit = {}));
\r
27923 * The TextDocumentEdit namespace provides helper function to create
\r
27924 * an edit that manipulates a text document.
\r
27926 var TextDocumentEdit;
\r
27927 (function (TextDocumentEdit) {
\r
27929 * Creates a new `TextDocumentEdit`
\r
27931 function create(textDocument, edits) {
\r
27932 return { textDocument: textDocument, edits: edits };
\r
27934 TextDocumentEdit.create = create;
\r
27935 function is(value) {
\r
27936 var candidate = value;
\r
27937 return Is.defined(candidate)
\r
27938 && VersionedTextDocumentIdentifier.is(candidate.textDocument)
\r
27939 && Array.isArray(candidate.edits);
\r
27941 TextDocumentEdit.is = is;
\r
27942 })(TextDocumentEdit || (TextDocumentEdit = {}));
\r
27944 (function (CreateFile) {
\r
27945 function create(uri, options) {
\r
27950 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
\r
27951 result.options = options;
\r
27955 CreateFile.create = create;
\r
27956 function is(value) {
\r
27957 var candidate = value;
\r
27958 return candidate && candidate.kind === 'create' && Is.string(candidate.uri) &&
\r
27959 (candidate.options === void 0 ||
\r
27960 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
\r
27962 CreateFile.is = is;
\r
27963 })(CreateFile || (CreateFile = {}));
\r
27965 (function (RenameFile) {
\r
27966 function create(oldUri, newUri, options) {
\r
27972 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
\r
27973 result.options = options;
\r
27977 RenameFile.create = create;
\r
27978 function is(value) {
\r
27979 var candidate = value;
\r
27980 return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) &&
\r
27981 (candidate.options === void 0 ||
\r
27982 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
\r
27984 RenameFile.is = is;
\r
27985 })(RenameFile || (RenameFile = {}));
\r
27987 (function (DeleteFile) {
\r
27988 function create(uri, options) {
\r
27993 if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
\r
27994 result.options = options;
\r
27998 DeleteFile.create = create;
\r
27999 function is(value) {
\r
28000 var candidate = value;
\r
28001 return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) &&
\r
28002 (candidate.options === void 0 ||
\r
28003 ((candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))));
\r
28005 DeleteFile.is = is;
\r
28006 })(DeleteFile || (DeleteFile = {}));
\r
28007 var WorkspaceEdit;
\r
28008 (function (WorkspaceEdit) {
\r
28009 function is(value) {
\r
28010 var candidate = value;
\r
28011 return candidate &&
\r
28012 (candidate.changes !== void 0 || candidate.documentChanges !== void 0) &&
\r
28013 (candidate.documentChanges === void 0 || candidate.documentChanges.every(function (change) {
\r
28014 if (Is.string(change.kind)) {
\r
28015 return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
\r
28018 return TextDocumentEdit.is(change);
\r
28022 WorkspaceEdit.is = is;
\r
28023 })(WorkspaceEdit || (WorkspaceEdit = {}));
\r
28024 var TextEditChangeImpl = /** @class */ (function () {
\r
28025 function TextEditChangeImpl(edits) {
\r
28026 this.edits = edits;
\r
28028 TextEditChangeImpl.prototype.insert = function (position, newText) {
\r
28029 this.edits.push(TextEdit.insert(position, newText));
\r
28031 TextEditChangeImpl.prototype.replace = function (range, newText) {
\r
28032 this.edits.push(TextEdit.replace(range, newText));
\r
28034 TextEditChangeImpl.prototype.delete = function (range) {
\r
28035 this.edits.push(TextEdit.del(range));
\r
28037 TextEditChangeImpl.prototype.add = function (edit) {
\r
28038 this.edits.push(edit);
\r
28040 TextEditChangeImpl.prototype.all = function () {
\r
28041 return this.edits;
\r
28043 TextEditChangeImpl.prototype.clear = function () {
\r
28044 this.edits.splice(0, this.edits.length);
\r
28046 return TextEditChangeImpl;
\r
28049 * A workspace change helps constructing changes to a workspace.
\r
28051 var WorkspaceChange = /** @class */ (function () {
\r
28052 function WorkspaceChange(workspaceEdit) {
\r
28053 var _this = this;
\r
28054 this._textEditChanges = Object.create(null);
\r
28055 if (workspaceEdit) {
\r
28056 this._workspaceEdit = workspaceEdit;
\r
28057 if (workspaceEdit.documentChanges) {
\r
28058 workspaceEdit.documentChanges.forEach(function (change) {
\r
28059 if (TextDocumentEdit.is(change)) {
\r
28060 var textEditChange = new TextEditChangeImpl(change.edits);
\r
28061 _this._textEditChanges[change.textDocument.uri] = textEditChange;
\r
28065 else if (workspaceEdit.changes) {
\r
28066 Object.keys(workspaceEdit.changes).forEach(function (key) {
\r
28067 var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
\r
28068 _this._textEditChanges[key] = textEditChange;
\r
28073 Object.defineProperty(WorkspaceChange.prototype, "edit", {
\r
28075 * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal
\r
28076 * use to be returned from a workspace edit operation like rename.
\r
28078 get: function () {
\r
28079 return this._workspaceEdit;
\r
28081 enumerable: true,
\r
28082 configurable: true
\r
28084 WorkspaceChange.prototype.getTextEditChange = function (key) {
\r
28085 if (VersionedTextDocumentIdentifier.is(key)) {
\r
28086 if (!this._workspaceEdit) {
\r
28087 this._workspaceEdit = {
\r
28088 documentChanges: []
\r
28091 if (!this._workspaceEdit.documentChanges) {
\r
28092 throw new Error('Workspace edit is not configured for document changes.');
\r
28094 var textDocument = key;
\r
28095 var result = this._textEditChanges[textDocument.uri];
\r
28098 var textDocumentEdit = {
\r
28099 textDocument: textDocument,
\r
28102 this._workspaceEdit.documentChanges.push(textDocumentEdit);
\r
28103 result = new TextEditChangeImpl(edits);
\r
28104 this._textEditChanges[textDocument.uri] = result;
\r
28109 if (!this._workspaceEdit) {
\r
28110 this._workspaceEdit = {
\r
28111 changes: Object.create(null)
\r
28114 if (!this._workspaceEdit.changes) {
\r
28115 throw new Error('Workspace edit is not configured for normal text edit changes.');
\r
28117 var result = this._textEditChanges[key];
\r
28120 this._workspaceEdit.changes[key] = edits;
\r
28121 result = new TextEditChangeImpl(edits);
\r
28122 this._textEditChanges[key] = result;
\r
28127 WorkspaceChange.prototype.createFile = function (uri, options) {
\r
28128 this.checkDocumentChanges();
\r
28129 this._workspaceEdit.documentChanges.push(CreateFile.create(uri, options));
\r
28131 WorkspaceChange.prototype.renameFile = function (oldUri, newUri, options) {
\r
28132 this.checkDocumentChanges();
\r
28133 this._workspaceEdit.documentChanges.push(RenameFile.create(oldUri, newUri, options));
\r
28135 WorkspaceChange.prototype.deleteFile = function (uri, options) {
\r
28136 this.checkDocumentChanges();
\r
28137 this._workspaceEdit.documentChanges.push(DeleteFile.create(uri, options));
\r
28139 WorkspaceChange.prototype.checkDocumentChanges = function () {
\r
28140 if (!this._workspaceEdit || !this._workspaceEdit.documentChanges) {
\r
28141 throw new Error('Workspace edit is not configured for document changes.');
\r
28144 return WorkspaceChange;
\r
28148 * The TextDocumentIdentifier namespace provides helper functions to work with
\r
28149 * [TextDocumentIdentifier](#TextDocumentIdentifier) literals.
\r
28151 var TextDocumentIdentifier;
\r
28152 (function (TextDocumentIdentifier) {
\r
28154 * Creates a new TextDocumentIdentifier literal.
\r
28155 * @param uri The document's uri.
\r
28157 function create(uri) {
\r
28158 return { uri: uri };
\r
28160 TextDocumentIdentifier.create = create;
\r
28162 * Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.
\r
28164 function is(value) {
\r
28165 var candidate = value;
\r
28166 return Is.defined(candidate) && Is.string(candidate.uri);
\r
28168 TextDocumentIdentifier.is = is;
\r
28169 })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
\r
28171 * The VersionedTextDocumentIdentifier namespace provides helper functions to work with
\r
28172 * [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.
\r
28174 var VersionedTextDocumentIdentifier;
\r
28175 (function (VersionedTextDocumentIdentifier) {
\r
28177 * Creates a new VersionedTextDocumentIdentifier literal.
\r
28178 * @param uri The document's uri.
\r
28179 * @param uri The document's text.
\r
28181 function create(uri, version) {
\r
28182 return { uri: uri, version: version };
\r
28184 VersionedTextDocumentIdentifier.create = create;
\r
28186 * Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.
\r
28188 function is(value) {
\r
28189 var candidate = value;
\r
28190 return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.number(candidate.version));
\r
28192 VersionedTextDocumentIdentifier.is = is;
\r
28193 })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
\r
28195 * The TextDocumentItem namespace provides helper functions to work with
\r
28196 * [TextDocumentItem](#TextDocumentItem) literals.
\r
28198 var TextDocumentItem;
\r
28199 (function (TextDocumentItem) {
\r
28201 * Creates a new TextDocumentItem literal.
\r
28202 * @param uri The document's uri.
\r
28203 * @param languageId The document's language identifier.
\r
28204 * @param version The document's version number.
\r
28205 * @param text The document's text.
\r
28207 function create(uri, languageId, version, text) {
\r
28208 return { uri: uri, languageId: languageId, version: version, text: text };
\r
28210 TextDocumentItem.create = create;
\r
28212 * Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.
\r
28214 function is(value) {
\r
28215 var candidate = value;
\r
28216 return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.number(candidate.version) && Is.string(candidate.text);
\r
28218 TextDocumentItem.is = is;
\r
28219 })(TextDocumentItem || (TextDocumentItem = {}));
\r
28221 * Describes the content type that a client supports in various
\r
28222 * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
\r
28224 * Please note that `MarkupKinds` must not start with a `$`. This kinds
\r
28225 * are reserved for internal usage.
\r
28228 (function (MarkupKind) {
\r
28230 * Plain text is supported as a content format
\r
28232 MarkupKind.PlainText = 'plaintext';
\r
28234 * Markdown is supported as a content format
\r
28236 MarkupKind.Markdown = 'markdown';
\r
28237 })(MarkupKind || (MarkupKind = {}));
\r
28238 (function (MarkupKind) {
\r
28240 * Checks whether the given value is a value of the [MarkupKind](#MarkupKind) type.
\r
28242 function is(value) {
\r
28243 var candidate = value;
\r
28244 return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;
\r
28246 MarkupKind.is = is;
\r
28247 })(MarkupKind || (MarkupKind = {}));
\r
28248 var MarkupContent;
\r
28249 (function (MarkupContent) {
\r
28251 * Checks whether the given value conforms to the [MarkupContent](#MarkupContent) interface.
\r
28253 function is(value) {
\r
28254 var candidate = value;
\r
28255 return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
\r
28257 MarkupContent.is = is;
\r
28258 })(MarkupContent || (MarkupContent = {}));
\r
28260 * The kind of a completion entry.
\r
28262 var CompletionItemKind;
\r
28263 (function (CompletionItemKind) {
\r
28264 CompletionItemKind.Text = 1;
\r
28265 CompletionItemKind.Method = 2;
\r
28266 CompletionItemKind.Function = 3;
\r
28267 CompletionItemKind.Constructor = 4;
\r
28268 CompletionItemKind.Field = 5;
\r
28269 CompletionItemKind.Variable = 6;
\r
28270 CompletionItemKind.Class = 7;
\r
28271 CompletionItemKind.Interface = 8;
\r
28272 CompletionItemKind.Module = 9;
\r
28273 CompletionItemKind.Property = 10;
\r
28274 CompletionItemKind.Unit = 11;
\r
28275 CompletionItemKind.Value = 12;
\r
28276 CompletionItemKind.Enum = 13;
\r
28277 CompletionItemKind.Keyword = 14;
\r
28278 CompletionItemKind.Snippet = 15;
\r
28279 CompletionItemKind.Color = 16;
\r
28280 CompletionItemKind.File = 17;
\r
28281 CompletionItemKind.Reference = 18;
\r
28282 CompletionItemKind.Folder = 19;
\r
28283 CompletionItemKind.EnumMember = 20;
\r
28284 CompletionItemKind.Constant = 21;
\r
28285 CompletionItemKind.Struct = 22;
\r
28286 CompletionItemKind.Event = 23;
\r
28287 CompletionItemKind.Operator = 24;
\r
28288 CompletionItemKind.TypeParameter = 25;
\r
28289 })(CompletionItemKind || (CompletionItemKind = {}));
\r
28291 * Defines whether the insert text in a completion item should be interpreted as
\r
28292 * plain text or a snippet.
\r
28294 var InsertTextFormat;
\r
28295 (function (InsertTextFormat) {
\r
28297 * The primary text to be inserted is treated as a plain string.
\r
28299 InsertTextFormat.PlainText = 1;
\r
28301 * The primary text to be inserted is treated as a snippet.
\r
28303 * A snippet can define tab stops and placeholders with `$1`, `$2`
\r
28304 * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
\r
28305 * the end of the snippet. Placeholders with equal identifiers are linked,
\r
28306 * that is typing in one will update others too.
\r
28308 * See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
\r
28310 InsertTextFormat.Snippet = 2;
\r
28311 })(InsertTextFormat || (InsertTextFormat = {}));
\r
28313 * Completion item tags are extra annotations that tweak the rendering of a completion
\r
28318 var CompletionItemTag;
\r
28319 (function (CompletionItemTag) {
\r
28321 * Render a completion as obsolete, usually using a strike-out.
\r
28323 CompletionItemTag.Deprecated = 1;
\r
28324 })(CompletionItemTag || (CompletionItemTag = {}));
\r
28326 * The CompletionItem namespace provides functions to deal with
\r
28327 * completion items.
\r
28329 var CompletionItem;
\r
28330 (function (CompletionItem) {
\r
28332 * Create a completion item and seed it with a label.
\r
28333 * @param label The completion item's label
\r
28335 function create(label) {
\r
28336 return { label: label };
\r
28338 CompletionItem.create = create;
\r
28339 })(CompletionItem || (CompletionItem = {}));
\r
28341 * The CompletionList namespace provides functions to deal with
\r
28342 * completion lists.
\r
28344 var CompletionList;
\r
28345 (function (CompletionList) {
\r
28347 * Creates a new completion list.
\r
28349 * @param items The completion items.
\r
28350 * @param isIncomplete The list is not complete.
\r
28352 function create(items, isIncomplete) {
\r
28353 return { items: items ? items : [], isIncomplete: !!isIncomplete };
\r
28355 CompletionList.create = create;
\r
28356 })(CompletionList || (CompletionList = {}));
\r
28357 var MarkedString;
\r
28358 (function (MarkedString) {
\r
28360 * Creates a marked string from plain text.
\r
28362 * @param plainText The plain text.
\r
28364 function fromPlainText(plainText) {
\r
28365 return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&'); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
\r
28367 MarkedString.fromPlainText = fromPlainText;
\r
28369 * Checks whether the given value conforms to the [MarkedString](#MarkedString) type.
\r
28371 function is(value) {
\r
28372 var candidate = value;
\r
28373 return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));
\r
28375 MarkedString.is = is;
\r
28376 })(MarkedString || (MarkedString = {}));
\r
28378 (function (Hover) {
\r
28380 * Checks whether the given value conforms to the [Hover](#Hover) interface.
\r
28382 function is(value) {
\r
28383 var candidate = value;
\r
28384 return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) ||
\r
28385 MarkedString.is(candidate.contents) ||
\r
28386 Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));
\r
28389 })(Hover || (Hover = {}));
\r
28391 * The ParameterInformation namespace provides helper functions to work with
\r
28392 * [ParameterInformation](#ParameterInformation) literals.
\r
28394 var ParameterInformation;
\r
28395 (function (ParameterInformation) {
\r
28397 * Creates a new parameter information literal.
\r
28399 * @param label A label string.
\r
28400 * @param documentation A doc string.
\r
28402 function create(label, documentation) {
\r
28403 return documentation ? { label: label, documentation: documentation } : { label: label };
\r
28405 ParameterInformation.create = create;
\r
28406 })(ParameterInformation || (ParameterInformation = {}));
\r
28408 * The SignatureInformation namespace provides helper functions to work with
\r
28409 * [SignatureInformation](#SignatureInformation) literals.
\r
28411 var SignatureInformation;
\r
28412 (function (SignatureInformation) {
\r
28413 function create(label, documentation) {
\r
28414 var parameters = [];
\r
28415 for (var _i = 2; _i < arguments.length; _i++) {
\r
28416 parameters[_i - 2] = arguments[_i];
\r
28418 var result = { label: label };
\r
28419 if (Is.defined(documentation)) {
\r
28420 result.documentation = documentation;
\r
28422 if (Is.defined(parameters)) {
\r
28423 result.parameters = parameters;
\r
28426 result.parameters = [];
\r
28430 SignatureInformation.create = create;
\r
28431 })(SignatureInformation || (SignatureInformation = {}));
\r
28433 * A document highlight kind.
\r
28435 var DocumentHighlightKind;
\r
28436 (function (DocumentHighlightKind) {
\r
28438 * A textual occurrence.
\r
28440 DocumentHighlightKind.Text = 1;
\r
28442 * Read-access of a symbol, like reading a variable.
\r
28444 DocumentHighlightKind.Read = 2;
\r
28446 * Write-access of a symbol, like writing to a variable.
\r
28448 DocumentHighlightKind.Write = 3;
\r
28449 })(DocumentHighlightKind || (DocumentHighlightKind = {}));
\r
28451 * DocumentHighlight namespace to provide helper functions to work with
\r
28452 * [DocumentHighlight](#DocumentHighlight) literals.
\r
28454 var DocumentHighlight;
\r
28455 (function (DocumentHighlight) {
\r
28457 * Create a DocumentHighlight object.
\r
28458 * @param range The range the highlight applies to.
\r
28460 function create(range, kind) {
\r
28461 var result = { range: range };
\r
28462 if (Is.number(kind)) {
\r
28463 result.kind = kind;
\r
28467 DocumentHighlight.create = create;
\r
28468 })(DocumentHighlight || (DocumentHighlight = {}));
\r
28473 (function (SymbolKind) {
\r
28474 SymbolKind.File = 1;
\r
28475 SymbolKind.Module = 2;
\r
28476 SymbolKind.Namespace = 3;
\r
28477 SymbolKind.Package = 4;
\r
28478 SymbolKind.Class = 5;
\r
28479 SymbolKind.Method = 6;
\r
28480 SymbolKind.Property = 7;
\r
28481 SymbolKind.Field = 8;
\r
28482 SymbolKind.Constructor = 9;
\r
28483 SymbolKind.Enum = 10;
\r
28484 SymbolKind.Interface = 11;
\r
28485 SymbolKind.Function = 12;
\r
28486 SymbolKind.Variable = 13;
\r
28487 SymbolKind.Constant = 14;
\r
28488 SymbolKind.String = 15;
\r
28489 SymbolKind.Number = 16;
\r
28490 SymbolKind.Boolean = 17;
\r
28491 SymbolKind.Array = 18;
\r
28492 SymbolKind.Object = 19;
\r
28493 SymbolKind.Key = 20;
\r
28494 SymbolKind.Null = 21;
\r
28495 SymbolKind.EnumMember = 22;
\r
28496 SymbolKind.Struct = 23;
\r
28497 SymbolKind.Event = 24;
\r
28498 SymbolKind.Operator = 25;
\r
28499 SymbolKind.TypeParameter = 26;
\r
28500 })(SymbolKind || (SymbolKind = {}));
\r
28502 * Symbol tags are extra annotations that tweak the rendering of a symbol.
\r
28506 (function (SymbolTag) {
\r
28508 * Render a symbol as obsolete, usually using a strike-out.
\r
28510 SymbolTag.Deprecated = 1;
\r
28511 })(SymbolTag || (SymbolTag = {}));
\r
28512 var SymbolInformation;
\r
28513 (function (SymbolInformation) {
\r
28515 * Creates a new symbol information literal.
\r
28517 * @param name The name of the symbol.
\r
28518 * @param kind The kind of the symbol.
\r
28519 * @param range The range of the location of the symbol.
\r
28520 * @param uri The resource of the location of symbol, defaults to the current document.
\r
28521 * @param containerName The name of the symbol containing the symbol.
\r
28523 function create(name, kind, range, uri, containerName) {
\r
28527 location: { uri: uri, range: range }
\r
28529 if (containerName) {
\r
28530 result.containerName = containerName;
\r
28534 SymbolInformation.create = create;
\r
28535 })(SymbolInformation || (SymbolInformation = {}));
\r
28536 var DocumentSymbol;
\r
28537 (function (DocumentSymbol) {
\r
28539 * Creates a new symbol information literal.
\r
28541 * @param name The name of the symbol.
\r
28542 * @param detail The detail of the symbol.
\r
28543 * @param kind The kind of the symbol.
\r
28544 * @param range The range of the symbol.
\r
28545 * @param selectionRange The selectionRange of the symbol.
\r
28546 * @param children Children of the symbol.
\r
28548 function create(name, detail, kind, range, selectionRange, children) {
\r
28554 selectionRange: selectionRange
\r
28556 if (children !== void 0) {
\r
28557 result.children = children;
\r
28561 DocumentSymbol.create = create;
\r
28563 * Checks whether the given literal conforms to the [DocumentSymbol](#DocumentSymbol) interface.
\r
28565 function is(value) {
\r
28566 var candidate = value;
\r
28567 return candidate &&
\r
28568 Is.string(candidate.name) && Is.number(candidate.kind) &&
\r
28569 Range.is(candidate.range) && Range.is(candidate.selectionRange) &&
\r
28570 (candidate.detail === void 0 || Is.string(candidate.detail)) &&
\r
28571 (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) &&
\r
28572 (candidate.children === void 0 || Array.isArray(candidate.children));
\r
28574 DocumentSymbol.is = is;
\r
28575 })(DocumentSymbol || (DocumentSymbol = {}));
\r
28577 * A set of predefined code action kinds
\r
28579 var CodeActionKind;
\r
28580 (function (CodeActionKind) {
\r
28584 CodeActionKind.Empty = '';
\r
28586 * Base kind for quickfix actions: 'quickfix'
\r
28588 CodeActionKind.QuickFix = 'quickfix';
\r
28590 * Base kind for refactoring actions: 'refactor'
\r
28592 CodeActionKind.Refactor = 'refactor';
\r
28594 * Base kind for refactoring extraction actions: 'refactor.extract'
\r
28596 * Example extract actions:
\r
28598 * - Extract method
\r
28599 * - Extract function
\r
28600 * - Extract variable
\r
28601 * - Extract interface from class
\r
28604 CodeActionKind.RefactorExtract = 'refactor.extract';
\r
28606 * Base kind for refactoring inline actions: 'refactor.inline'
\r
28608 * Example inline actions:
\r
28610 * - Inline function
\r
28611 * - Inline variable
\r
28612 * - Inline constant
\r
28615 CodeActionKind.RefactorInline = 'refactor.inline';
\r
28617 * Base kind for refactoring rewrite actions: 'refactor.rewrite'
\r
28619 * Example rewrite actions:
\r
28621 * - Convert JavaScript function to class
\r
28622 * - Add or remove parameter
\r
28623 * - Encapsulate field
\r
28624 * - Make method static
\r
28625 * - Move method to base class
\r
28628 CodeActionKind.RefactorRewrite = 'refactor.rewrite';
\r
28630 * Base kind for source actions: `source`
\r
28632 * Source code actions apply to the entire file.
\r
28634 CodeActionKind.Source = 'source';
\r
28636 * Base kind for an organize imports source action: `source.organizeImports`
\r
28638 CodeActionKind.SourceOrganizeImports = 'source.organizeImports';
\r
28640 * Base kind for auto-fix source actions: `source.fixAll`.
\r
28642 * Fix all actions automatically fix errors that have a clear fix that do not require user input.
\r
28643 * They should not suppress errors or perform unsafe fixes such as generating new types or classes.
\r
28647 CodeActionKind.SourceFixAll = 'source.fixAll';
\r
28648 })(CodeActionKind || (CodeActionKind = {}));
\r
28650 * The CodeActionContext namespace provides helper functions to work with
\r
28651 * [CodeActionContext](#CodeActionContext) literals.
\r
28653 var CodeActionContext;
\r
28654 (function (CodeActionContext) {
\r
28656 * Creates a new CodeActionContext literal.
\r
28658 function create(diagnostics, only) {
\r
28659 var result = { diagnostics: diagnostics };
\r
28660 if (only !== void 0 && only !== null) {
\r
28661 result.only = only;
\r
28665 CodeActionContext.create = create;
\r
28667 * Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.
\r
28669 function is(value) {
\r
28670 var candidate = value;
\r
28671 return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));
\r
28673 CodeActionContext.is = is;
\r
28674 })(CodeActionContext || (CodeActionContext = {}));
\r
28676 (function (CodeAction) {
\r
28677 function create(title, commandOrEdit, kind) {
\r
28678 var result = { title: title };
\r
28679 if (Command.is(commandOrEdit)) {
\r
28680 result.command = commandOrEdit;
\r
28683 result.edit = commandOrEdit;
\r
28685 if (kind !== void 0) {
\r
28686 result.kind = kind;
\r
28690 CodeAction.create = create;
\r
28691 function is(value) {
\r
28692 var candidate = value;
\r
28693 return candidate && Is.string(candidate.title) &&
\r
28694 (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) &&
\r
28695 (candidate.kind === void 0 || Is.string(candidate.kind)) &&
\r
28696 (candidate.edit !== void 0 || candidate.command !== void 0) &&
\r
28697 (candidate.command === void 0 || Command.is(candidate.command)) &&
\r
28698 (candidate.isPreferred === void 0 || Is.boolean(candidate.isPreferred)) &&
\r
28699 (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));
\r
28701 CodeAction.is = is;
\r
28702 })(CodeAction || (CodeAction = {}));
\r
28704 * The CodeLens namespace provides helper functions to work with
\r
28705 * [CodeLens](#CodeLens) literals.
\r
28708 (function (CodeLens) {
\r
28710 * Creates a new CodeLens literal.
\r
28712 function create(range, data) {
\r
28713 var result = { range: range };
\r
28714 if (Is.defined(data)) {
\r
28715 result.data = data;
\r
28719 CodeLens.create = create;
\r
28721 * Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.
\r
28723 function is(value) {
\r
28724 var candidate = value;
\r
28725 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
\r
28727 CodeLens.is = is;
\r
28728 })(CodeLens || (CodeLens = {}));
\r
28730 * The FormattingOptions namespace provides helper functions to work with
\r
28731 * [FormattingOptions](#FormattingOptions) literals.
\r
28733 var FormattingOptions;
\r
28734 (function (FormattingOptions) {
\r
28736 * Creates a new FormattingOptions literal.
\r
28738 function create(tabSize, insertSpaces) {
\r
28739 return { tabSize: tabSize, insertSpaces: insertSpaces };
\r
28741 FormattingOptions.create = create;
\r
28743 * Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.
\r
28745 function is(value) {
\r
28746 var candidate = value;
\r
28747 return Is.defined(candidate) && Is.number(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
\r
28749 FormattingOptions.is = is;
\r
28750 })(FormattingOptions || (FormattingOptions = {}));
\r
28752 * The DocumentLink namespace provides helper functions to work with
\r
28753 * [DocumentLink](#DocumentLink) literals.
\r
28755 var DocumentLink;
\r
28756 (function (DocumentLink) {
\r
28758 * Creates a new DocumentLink literal.
\r
28760 function create(range, target, data) {
\r
28761 return { range: range, target: target, data: data };
\r
28763 DocumentLink.create = create;
\r
28765 * Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.
\r
28767 function is(value) {
\r
28768 var candidate = value;
\r
28769 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
\r
28771 DocumentLink.is = is;
\r
28772 })(DocumentLink || (DocumentLink = {}));
\r
28774 * The SelectionRange namespace provides helper function to work with
\r
28775 * SelectionRange literals.
\r
28777 var SelectionRange;
\r
28778 (function (SelectionRange) {
\r
28780 * Creates a new SelectionRange
\r
28781 * @param range the range.
\r
28782 * @param parent an optional parent.
\r
28784 function create(range, parent) {
\r
28785 return { range: range, parent: parent };
\r
28787 SelectionRange.create = create;
\r
28788 function is(value) {
\r
28789 var candidate = value;
\r
28790 return candidate !== undefined && Range.is(candidate.range) && (candidate.parent === undefined || SelectionRange.is(candidate.parent));
\r
28792 SelectionRange.is = is;
\r
28793 })(SelectionRange || (SelectionRange = {}));
\r
28794 var EOL = ['\n', '\r\n', '\r'];
\r
28796 * @deprecated Use the text document from the new vscode-languageserver-textdocument package.
\r
28798 var TextDocument;
\r
28799 (function (TextDocument) {
\r
28801 * Creates a new ITextDocument literal from the given uri and content.
\r
28802 * @param uri The document's uri.
\r
28803 * @param languageId The document's language Id.
\r
28804 * @param content The document's content.
\r
28806 function create(uri, languageId, version, content) {
\r
28807 return new FullTextDocument(uri, languageId, version, content);
\r
28809 TextDocument.create = create;
\r
28811 * Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.
\r
28813 function is(value) {
\r
28814 var candidate = value;
\r
28815 return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.number(candidate.lineCount)
\r
28816 && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
\r
28818 TextDocument.is = is;
\r
28819 function applyEdits(document, edits) {
\r
28820 var text = document.getText();
\r
28821 var sortedEdits = mergeSort(edits, function (a, b) {
\r
28822 var diff = a.range.start.line - b.range.start.line;
\r
28823 if (diff === 0) {
\r
28824 return a.range.start.character - b.range.start.character;
\r
28828 var lastModifiedOffset = text.length;
\r
28829 for (var i = sortedEdits.length - 1; i >= 0; i--) {
\r
28830 var e = sortedEdits[i];
\r
28831 var startOffset = document.offsetAt(e.range.start);
\r
28832 var endOffset = document.offsetAt(e.range.end);
\r
28833 if (endOffset <= lastModifiedOffset) {
\r
28834 text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
\r
28837 throw new Error('Overlapping edit');
\r
28839 lastModifiedOffset = startOffset;
\r
28843 TextDocument.applyEdits = applyEdits;
\r
28844 function mergeSort(data, compare) {
\r
28845 if (data.length <= 1) {
\r
28849 var p = (data.length / 2) | 0;
\r
28850 var left = data.slice(0, p);
\r
28851 var right = data.slice(p);
\r
28852 mergeSort(left, compare);
\r
28853 mergeSort(right, compare);
\r
28855 var rightIdx = 0;
\r
28857 while (leftIdx < left.length && rightIdx < right.length) {
\r
28858 var ret = compare(left[leftIdx], right[rightIdx]);
\r
28860 // smaller_equal -> take left to preserve order
\r
28861 data[i++] = left[leftIdx++];
\r
28864 // greater -> take right
\r
28865 data[i++] = right[rightIdx++];
\r
28868 while (leftIdx < left.length) {
\r
28869 data[i++] = left[leftIdx++];
\r
28871 while (rightIdx < right.length) {
\r
28872 data[i++] = right[rightIdx++];
\r
28876 })(TextDocument || (TextDocument = {}));
\r
28877 var FullTextDocument = /** @class */ (function () {
\r
28878 function FullTextDocument(uri, languageId, version, content) {
\r
28880 this._languageId = languageId;
\r
28881 this._version = version;
\r
28882 this._content = content;
\r
28883 this._lineOffsets = undefined;
\r
28885 Object.defineProperty(FullTextDocument.prototype, "uri", {
\r
28886 get: function () {
\r
28887 return this._uri;
\r
28889 enumerable: true,
\r
28890 configurable: true
\r
28892 Object.defineProperty(FullTextDocument.prototype, "languageId", {
\r
28893 get: function () {
\r
28894 return this._languageId;
\r
28896 enumerable: true,
\r
28897 configurable: true
\r
28899 Object.defineProperty(FullTextDocument.prototype, "version", {
\r
28900 get: function () {
\r
28901 return this._version;
\r
28903 enumerable: true,
\r
28904 configurable: true
\r
28906 FullTextDocument.prototype.getText = function (range) {
\r
28908 var start = this.offsetAt(range.start);
\r
28909 var end = this.offsetAt(range.end);
\r
28910 return this._content.substring(start, end);
\r
28912 return this._content;
\r
28914 FullTextDocument.prototype.update = function (event, version) {
\r
28915 this._content = event.text;
\r
28916 this._version = version;
\r
28917 this._lineOffsets = undefined;
\r
28919 FullTextDocument.prototype.getLineOffsets = function () {
\r
28920 if (this._lineOffsets === undefined) {
\r
28921 var lineOffsets = [];
\r
28922 var text = this._content;
\r
28923 var isLineStart = true;
\r
28924 for (var i = 0; i < text.length; i++) {
\r
28925 if (isLineStart) {
\r
28926 lineOffsets.push(i);
\r
28927 isLineStart = false;
\r
28929 var ch = text.charAt(i);
\r
28930 isLineStart = (ch === '\r' || ch === '\n');
\r
28931 if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {
\r
28935 if (isLineStart && text.length > 0) {
\r
28936 lineOffsets.push(text.length);
\r
28938 this._lineOffsets = lineOffsets;
\r
28940 return this._lineOffsets;
\r
28942 FullTextDocument.prototype.positionAt = function (offset) {
\r
28943 offset = Math.max(Math.min(offset, this._content.length), 0);
\r
28944 var lineOffsets = this.getLineOffsets();
\r
28945 var low = 0, high = lineOffsets.length;
\r
28946 if (high === 0) {
\r
28947 return Position.create(0, offset);
\r
28949 while (low < high) {
\r
28950 var mid = Math.floor((low + high) / 2);
\r
28951 if (lineOffsets[mid] > offset) {
\r
28958 // low is the least x for which the line offset is larger than the current offset
\r
28959 // or array.length if no line offset is larger than the current offset
\r
28960 var line = low - 1;
\r
28961 return Position.create(line, offset - lineOffsets[line]);
\r
28963 FullTextDocument.prototype.offsetAt = function (position) {
\r
28964 var lineOffsets = this.getLineOffsets();
\r
28965 if (position.line >= lineOffsets.length) {
\r
28966 return this._content.length;
\r
28968 else if (position.line < 0) {
\r
28971 var lineOffset = lineOffsets[position.line];
\r
28972 var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;
\r
28973 return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
\r
28975 Object.defineProperty(FullTextDocument.prototype, "lineCount", {
\r
28976 get: function () {
\r
28977 return this.getLineOffsets().length;
\r
28979 enumerable: true,
\r
28980 configurable: true
\r
28982 return FullTextDocument;
\r
28986 var toString = Object.prototype.toString;
\r
28987 function defined(value) {
\r
28988 return typeof value !== 'undefined';
\r
28990 Is.defined = defined;
\r
28991 function undefined(value) {
\r
28992 return typeof value === 'undefined';
\r
28994 Is.undefined = undefined;
\r
28995 function boolean(value) {
\r
28996 return value === true || value === false;
\r
28998 Is.boolean = boolean;
\r
28999 function string(value) {
\r
29000 return toString.call(value) === '[object String]';
\r
29002 Is.string = string;
\r
29003 function number(value) {
\r
29004 return toString.call(value) === '[object Number]';
\r
29006 Is.number = number;
\r
29007 function func(value) {
\r
29008 return toString.call(value) === '[object Function]';
\r
29011 function objectLiteral(value) {
\r
29012 // Strictly speaking class instances pass this check as well. Since the LSP
\r
29013 // doesn't use classes we ignore this for now. If we do we need to add something
\r
29014 // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
\r
29015 return value !== null && typeof value === 'object';
\r
29017 Is.objectLiteral = objectLiteral;
\r
29018 function typedArray(value, check) {
\r
29019 return Array.isArray(value) && value.every(check);
\r
29021 Is.typedArray = typedArray;
\r
29022 })(Is || (Is = {}));
\r
29027 /***/ (function(module, exports, __webpack_require__) {
29030 /* --------------------------------------------------------------------------------------------
\r
29031 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
29032 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
29033 * ------------------------------------------------------------------------------------------ */
\r
29035 Object.defineProperty(exports, "__esModule", { value: true });
\r
29036 const Is = __webpack_require__(177);
\r
29037 const vscode_jsonrpc_1 = __webpack_require__(163);
\r
29038 const messages_1 = __webpack_require__(178);
\r
29039 const protocol_implementation_1 = __webpack_require__(179);
\r
29040 exports.ImplementationRequest = protocol_implementation_1.ImplementationRequest;
\r
29041 const protocol_typeDefinition_1 = __webpack_require__(180);
\r
29042 exports.TypeDefinitionRequest = protocol_typeDefinition_1.TypeDefinitionRequest;
\r
29043 const protocol_workspaceFolders_1 = __webpack_require__(181);
\r
29044 exports.WorkspaceFoldersRequest = protocol_workspaceFolders_1.WorkspaceFoldersRequest;
\r
29045 exports.DidChangeWorkspaceFoldersNotification = protocol_workspaceFolders_1.DidChangeWorkspaceFoldersNotification;
\r
29046 const protocol_configuration_1 = __webpack_require__(182);
\r
29047 exports.ConfigurationRequest = protocol_configuration_1.ConfigurationRequest;
\r
29048 const protocol_colorProvider_1 = __webpack_require__(183);
\r
29049 exports.DocumentColorRequest = protocol_colorProvider_1.DocumentColorRequest;
\r
29050 exports.ColorPresentationRequest = protocol_colorProvider_1.ColorPresentationRequest;
\r
29051 const protocol_foldingRange_1 = __webpack_require__(184);
\r
29052 exports.FoldingRangeRequest = protocol_foldingRange_1.FoldingRangeRequest;
\r
29053 const protocol_declaration_1 = __webpack_require__(185);
\r
29054 exports.DeclarationRequest = protocol_declaration_1.DeclarationRequest;
\r
29055 const protocol_selectionRange_1 = __webpack_require__(186);
\r
29056 exports.SelectionRangeRequest = protocol_selectionRange_1.SelectionRangeRequest;
\r
29057 const protocol_progress_1 = __webpack_require__(187);
\r
29058 exports.WorkDoneProgress = protocol_progress_1.WorkDoneProgress;
\r
29059 exports.WorkDoneProgressCreateRequest = protocol_progress_1.WorkDoneProgressCreateRequest;
\r
29060 exports.WorkDoneProgressCancelNotification = protocol_progress_1.WorkDoneProgressCancelNotification;
\r
29061 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
29062 let __noDynamicImport;
\r
29064 * The DocumentFilter namespace provides helper functions to work with
\r
29065 * [DocumentFilter](#DocumentFilter) literals.
\r
29067 var DocumentFilter;
\r
29068 (function (DocumentFilter) {
\r
29069 function is(value) {
\r
29070 const candidate = value;
\r
29071 return Is.string(candidate.language) || Is.string(candidate.scheme) || Is.string(candidate.pattern);
\r
29073 DocumentFilter.is = is;
\r
29074 })(DocumentFilter = exports.DocumentFilter || (exports.DocumentFilter = {}));
\r
29076 * The DocumentSelector namespace provides helper functions to work with
\r
29077 * [DocumentSelector](#DocumentSelector)s.
\r
29079 var DocumentSelector;
\r
29080 (function (DocumentSelector) {
\r
29081 function is(value) {
\r
29082 if (!Array.isArray(value)) {
\r
29085 for (let elem of value) {
\r
29086 if (!Is.string(elem) && !DocumentFilter.is(elem)) {
\r
29092 DocumentSelector.is = is;
\r
29093 })(DocumentSelector = exports.DocumentSelector || (exports.DocumentSelector = {}));
\r
29095 * The `client/registerCapability` request is sent from the server to the client to register a new capability
\r
29096 * handler on the client side.
\r
29098 var RegistrationRequest;
\r
29099 (function (RegistrationRequest) {
\r
29100 RegistrationRequest.type = new messages_1.ProtocolRequestType('client/registerCapability');
\r
29101 })(RegistrationRequest = exports.RegistrationRequest || (exports.RegistrationRequest = {}));
\r
29103 * The `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability
\r
29104 * handler on the client side.
\r
29106 var UnregistrationRequest;
\r
29107 (function (UnregistrationRequest) {
\r
29108 UnregistrationRequest.type = new messages_1.ProtocolRequestType('client/unregisterCapability');
\r
29109 })(UnregistrationRequest = exports.UnregistrationRequest || (exports.UnregistrationRequest = {}));
\r
29110 var ResourceOperationKind;
\r
29111 (function (ResourceOperationKind) {
\r
29113 * Supports creating new files and folders.
\r
29115 ResourceOperationKind.Create = 'create';
\r
29117 * Supports renaming existing files and folders.
\r
29119 ResourceOperationKind.Rename = 'rename';
\r
29121 * Supports deleting existing files and folders.
\r
29123 ResourceOperationKind.Delete = 'delete';
\r
29124 })(ResourceOperationKind = exports.ResourceOperationKind || (exports.ResourceOperationKind = {}));
\r
29125 var FailureHandlingKind;
\r
29126 (function (FailureHandlingKind) {
\r
29128 * Applying the workspace change is simply aborted if one of the changes provided
\r
29129 * fails. All operations executed before the failing operation stay executed.
\r
29131 FailureHandlingKind.Abort = 'abort';
\r
29133 * All operations are executed transactional. That means they either all
\r
29134 * succeed or no changes at all are applied to the workspace.
\r
29136 FailureHandlingKind.Transactional = 'transactional';
\r
29138 * If the workspace edit contains only textual file changes they are executed transactional.
\r
29139 * If resource changes (create, rename or delete file) are part of the change the failure
\r
29140 * handling startegy is abort.
\r
29142 FailureHandlingKind.TextOnlyTransactional = 'textOnlyTransactional';
\r
29144 * The client tries to undo the operations already executed. But there is no
\r
29145 * guarantee that this is succeeding.
\r
29147 FailureHandlingKind.Undo = 'undo';
\r
29148 })(FailureHandlingKind = exports.FailureHandlingKind || (exports.FailureHandlingKind = {}));
\r
29150 * The StaticRegistrationOptions namespace provides helper functions to work with
\r
29151 * [StaticRegistrationOptions](#StaticRegistrationOptions) literals.
\r
29153 var StaticRegistrationOptions;
\r
29154 (function (StaticRegistrationOptions) {
\r
29155 function hasId(value) {
\r
29156 const candidate = value;
\r
29157 return candidate && Is.string(candidate.id) && candidate.id.length > 0;
\r
29159 StaticRegistrationOptions.hasId = hasId;
\r
29160 })(StaticRegistrationOptions = exports.StaticRegistrationOptions || (exports.StaticRegistrationOptions = {}));
\r
29162 * The TextDocumentRegistrationOptions namespace provides helper functions to work with
\r
29163 * [TextDocumentRegistrationOptions](#TextDocumentRegistrationOptions) literals.
\r
29165 var TextDocumentRegistrationOptions;
\r
29166 (function (TextDocumentRegistrationOptions) {
\r
29167 function is(value) {
\r
29168 const candidate = value;
\r
29169 return candidate && (candidate.documentSelector === null || DocumentSelector.is(candidate.documentSelector));
\r
29171 TextDocumentRegistrationOptions.is = is;
\r
29172 })(TextDocumentRegistrationOptions = exports.TextDocumentRegistrationOptions || (exports.TextDocumentRegistrationOptions = {}));
\r
29174 * The WorkDoneProgressOptions namespace provides helper functions to work with
\r
29175 * [WorkDoneProgressOptions](#WorkDoneProgressOptions) literals.
\r
29177 var WorkDoneProgressOptions;
\r
29178 (function (WorkDoneProgressOptions) {
\r
29179 function is(value) {
\r
29180 const candidate = value;
\r
29181 return Is.objectLiteral(candidate) && (candidate.workDoneProgress === undefined || Is.boolean(candidate.workDoneProgress));
\r
29183 WorkDoneProgressOptions.is = is;
\r
29184 function hasWorkDoneProgress(value) {
\r
29185 const candidate = value;
\r
29186 return candidate && Is.boolean(candidate.workDoneProgress);
\r
29188 WorkDoneProgressOptions.hasWorkDoneProgress = hasWorkDoneProgress;
\r
29189 })(WorkDoneProgressOptions = exports.WorkDoneProgressOptions || (exports.WorkDoneProgressOptions = {}));
\r
29191 * The initialize request is sent from the client to the server.
\r
29192 * It is sent once as the request after starting up the server.
\r
29193 * The requests parameter is of type [InitializeParams](#InitializeParams)
\r
29194 * the response if of type [InitializeResult](#InitializeResult) of a Thenable that
\r
29195 * resolves to such.
\r
29197 var InitializeRequest;
\r
29198 (function (InitializeRequest) {
\r
29199 InitializeRequest.type = new messages_1.ProtocolRequestType('initialize');
\r
29200 })(InitializeRequest = exports.InitializeRequest || (exports.InitializeRequest = {}));
\r
29202 * Known error codes for an `InitializeError`;
\r
29204 var InitializeError;
\r
29205 (function (InitializeError) {
\r
29207 * If the protocol version provided by the client can't be handled by the server.
\r
29208 * @deprecated This initialize error got replaced by client capabilities. There is
\r
29209 * no version handshake in version 3.0x
\r
29211 InitializeError.unknownProtocolVersion = 1;
\r
29212 })(InitializeError = exports.InitializeError || (exports.InitializeError = {}));
\r
29214 * The intialized notification is sent from the client to the
\r
29215 * server after the client is fully initialized and the server
\r
29216 * is allowed to send requests from the server to the client.
\r
29218 var InitializedNotification;
\r
29219 (function (InitializedNotification) {
\r
29220 InitializedNotification.type = new messages_1.ProtocolNotificationType('initialized');
\r
29221 })(InitializedNotification = exports.InitializedNotification || (exports.InitializedNotification = {}));
\r
29222 //---- Shutdown Method ----
\r
29224 * A shutdown request is sent from the client to the server.
\r
29225 * It is sent once when the client decides to shutdown the
\r
29226 * server. The only notification that is sent after a shutdown request
\r
29227 * is the exit event.
\r
29229 var ShutdownRequest;
\r
29230 (function (ShutdownRequest) {
\r
29231 ShutdownRequest.type = new messages_1.ProtocolRequestType0('shutdown');
\r
29232 })(ShutdownRequest = exports.ShutdownRequest || (exports.ShutdownRequest = {}));
\r
29233 //---- Exit Notification ----
\r
29235 * The exit event is sent from the client to the server to
\r
29236 * ask the server to exit its process.
\r
29238 var ExitNotification;
\r
29239 (function (ExitNotification) {
\r
29240 ExitNotification.type = new messages_1.ProtocolNotificationType0('exit');
\r
29241 })(ExitNotification = exports.ExitNotification || (exports.ExitNotification = {}));
\r
29243 * The configuration change notification is sent from the client to the server
\r
29244 * when the client's configuration has changed. The notification contains
\r
29245 * the changed configuration as defined by the language client.
\r
29247 var DidChangeConfigurationNotification;
\r
29248 (function (DidChangeConfigurationNotification) {
\r
29249 DidChangeConfigurationNotification.type = new messages_1.ProtocolNotificationType('workspace/didChangeConfiguration');
\r
29250 })(DidChangeConfigurationNotification = exports.DidChangeConfigurationNotification || (exports.DidChangeConfigurationNotification = {}));
\r
29251 //---- Message show and log notifications ----
\r
29253 * The message type
\r
29256 (function (MessageType) {
\r
29258 * An error message.
\r
29260 MessageType.Error = 1;
\r
29262 * A warning message.
\r
29264 MessageType.Warning = 2;
\r
29266 * An information message.
\r
29268 MessageType.Info = 3;
\r
29272 MessageType.Log = 4;
\r
29273 })(MessageType = exports.MessageType || (exports.MessageType = {}));
\r
29275 * The show message notification is sent from a server to a client to ask
\r
29276 * the client to display a particular message in the user interface.
\r
29278 var ShowMessageNotification;
\r
29279 (function (ShowMessageNotification) {
\r
29280 ShowMessageNotification.type = new messages_1.ProtocolNotificationType('window/showMessage');
\r
29281 })(ShowMessageNotification = exports.ShowMessageNotification || (exports.ShowMessageNotification = {}));
\r
29283 * The show message request is sent from the server to the client to show a message
\r
29284 * and a set of options actions to the user.
\r
29286 var ShowMessageRequest;
\r
29287 (function (ShowMessageRequest) {
\r
29288 ShowMessageRequest.type = new messages_1.ProtocolRequestType('window/showMessageRequest');
\r
29289 })(ShowMessageRequest = exports.ShowMessageRequest || (exports.ShowMessageRequest = {}));
\r
29291 * The log message notification is sent from the server to the client to ask
\r
29292 * the client to log a particular message.
\r
29294 var LogMessageNotification;
\r
29295 (function (LogMessageNotification) {
\r
29296 LogMessageNotification.type = new messages_1.ProtocolNotificationType('window/logMessage');
\r
29297 })(LogMessageNotification = exports.LogMessageNotification || (exports.LogMessageNotification = {}));
\r
29298 //---- Telemetry notification
\r
29300 * The telemetry event notification is sent from the server to the client to ask
\r
29301 * the client to log telemetry data.
\r
29303 var TelemetryEventNotification;
\r
29304 (function (TelemetryEventNotification) {
\r
29305 TelemetryEventNotification.type = new messages_1.ProtocolNotificationType('telemetry/event');
\r
29306 })(TelemetryEventNotification = exports.TelemetryEventNotification || (exports.TelemetryEventNotification = {}));
\r
29308 * Defines how the host (editor) should sync
\r
29309 * document changes to the language server.
\r
29311 var TextDocumentSyncKind;
\r
29312 (function (TextDocumentSyncKind) {
\r
29314 * Documents should not be synced at all.
\r
29316 TextDocumentSyncKind.None = 0;
\r
29318 * Documents are synced by always sending the full content
\r
29319 * of the document.
\r
29321 TextDocumentSyncKind.Full = 1;
\r
29323 * Documents are synced by sending the full content on open.
\r
29324 * After that only incremental updates to the document are
\r
29327 TextDocumentSyncKind.Incremental = 2;
\r
29328 })(TextDocumentSyncKind = exports.TextDocumentSyncKind || (exports.TextDocumentSyncKind = {}));
\r
29330 * The document open notification is sent from the client to the server to signal
\r
29331 * newly opened text documents. The document's truth is now managed by the client
\r
29332 * and the server must not try to read the document's truth using the document's
\r
29333 * uri. Open in this sense means it is managed by the client. It doesn't necessarily
\r
29334 * mean that its content is presented in an editor. An open notification must not
\r
29335 * be sent more than once without a corresponding close notification send before.
\r
29336 * This means open and close notification must be balanced and the max open count
\r
29339 var DidOpenTextDocumentNotification;
\r
29340 (function (DidOpenTextDocumentNotification) {
\r
29341 DidOpenTextDocumentNotification.method = 'textDocument/didOpen';
\r
29342 DidOpenTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidOpenTextDocumentNotification.method);
\r
29343 })(DidOpenTextDocumentNotification = exports.DidOpenTextDocumentNotification || (exports.DidOpenTextDocumentNotification = {}));
\r
29345 * The document change notification is sent from the client to the server to signal
\r
29346 * changes to a text document.
\r
29348 var DidChangeTextDocumentNotification;
\r
29349 (function (DidChangeTextDocumentNotification) {
\r
29350 DidChangeTextDocumentNotification.method = 'textDocument/didChange';
\r
29351 DidChangeTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidChangeTextDocumentNotification.method);
\r
29352 })(DidChangeTextDocumentNotification = exports.DidChangeTextDocumentNotification || (exports.DidChangeTextDocumentNotification = {}));
\r
29354 * The document close notification is sent from the client to the server when
\r
29355 * the document got closed in the client. The document's truth now exists where
\r
29356 * the document's uri points to (e.g. if the document's uri is a file uri the
\r
29357 * truth now exists on disk). As with the open notification the close notification
\r
29358 * is about managing the document's content. Receiving a close notification
\r
29359 * doesn't mean that the document was open in an editor before. A close
\r
29360 * notification requires a previous open notification to be sent.
\r
29362 var DidCloseTextDocumentNotification;
\r
29363 (function (DidCloseTextDocumentNotification) {
\r
29364 DidCloseTextDocumentNotification.method = 'textDocument/didClose';
\r
29365 DidCloseTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidCloseTextDocumentNotification.method);
\r
29366 })(DidCloseTextDocumentNotification = exports.DidCloseTextDocumentNotification || (exports.DidCloseTextDocumentNotification = {}));
\r
29368 * The document save notification is sent from the client to the server when
\r
29369 * the document got saved in the client.
\r
29371 var DidSaveTextDocumentNotification;
\r
29372 (function (DidSaveTextDocumentNotification) {
\r
29373 DidSaveTextDocumentNotification.method = 'textDocument/didSave';
\r
29374 DidSaveTextDocumentNotification.type = new messages_1.ProtocolNotificationType(DidSaveTextDocumentNotification.method);
\r
29375 })(DidSaveTextDocumentNotification = exports.DidSaveTextDocumentNotification || (exports.DidSaveTextDocumentNotification = {}));
\r
29377 * Represents reasons why a text document is saved.
\r
29379 var TextDocumentSaveReason;
\r
29380 (function (TextDocumentSaveReason) {
\r
29382 * Manually triggered, e.g. by the user pressing save, by starting debugging,
\r
29383 * or by an API call.
\r
29385 TextDocumentSaveReason.Manual = 1;
\r
29387 * Automatic after a delay.
\r
29389 TextDocumentSaveReason.AfterDelay = 2;
\r
29391 * When the editor lost focus.
\r
29393 TextDocumentSaveReason.FocusOut = 3;
\r
29394 })(TextDocumentSaveReason = exports.TextDocumentSaveReason || (exports.TextDocumentSaveReason = {}));
\r
29396 * A document will save notification is sent from the client to the server before
\r
29397 * the document is actually saved.
\r
29399 var WillSaveTextDocumentNotification;
\r
29400 (function (WillSaveTextDocumentNotification) {
\r
29401 WillSaveTextDocumentNotification.method = 'textDocument/willSave';
\r
29402 WillSaveTextDocumentNotification.type = new messages_1.ProtocolNotificationType(WillSaveTextDocumentNotification.method);
\r
29403 })(WillSaveTextDocumentNotification = exports.WillSaveTextDocumentNotification || (exports.WillSaveTextDocumentNotification = {}));
\r
29405 * A document will save request is sent from the client to the server before
\r
29406 * the document is actually saved. The request can return an array of TextEdits
\r
29407 * which will be applied to the text document before it is saved. Please note that
\r
29408 * clients might drop results if computing the text edits took too long or if a
\r
29409 * server constantly fails on this request. This is done to keep the save fast and
\r
29412 var WillSaveTextDocumentWaitUntilRequest;
\r
29413 (function (WillSaveTextDocumentWaitUntilRequest) {
\r
29414 WillSaveTextDocumentWaitUntilRequest.method = 'textDocument/willSaveWaitUntil';
\r
29415 WillSaveTextDocumentWaitUntilRequest.type = new messages_1.ProtocolRequestType(WillSaveTextDocumentWaitUntilRequest.method);
\r
29416 })(WillSaveTextDocumentWaitUntilRequest = exports.WillSaveTextDocumentWaitUntilRequest || (exports.WillSaveTextDocumentWaitUntilRequest = {}));
\r
29418 * The watched files notification is sent from the client to the server when
\r
29419 * the client detects changes to file watched by the language client.
\r
29421 var DidChangeWatchedFilesNotification;
\r
29422 (function (DidChangeWatchedFilesNotification) {
\r
29423 DidChangeWatchedFilesNotification.type = new messages_1.ProtocolNotificationType('workspace/didChangeWatchedFiles');
\r
29424 })(DidChangeWatchedFilesNotification = exports.DidChangeWatchedFilesNotification || (exports.DidChangeWatchedFilesNotification = {}));
\r
29426 * The file event type
\r
29428 var FileChangeType;
\r
29429 (function (FileChangeType) {
\r
29431 * The file got created.
\r
29433 FileChangeType.Created = 1;
\r
29435 * The file got changed.
\r
29437 FileChangeType.Changed = 2;
\r
29439 * The file got deleted.
\r
29441 FileChangeType.Deleted = 3;
\r
29442 })(FileChangeType = exports.FileChangeType || (exports.FileChangeType = {}));
\r
29444 (function (WatchKind) {
\r
29446 * Interested in create events.
\r
29448 WatchKind.Create = 1;
\r
29450 * Interested in change events
\r
29452 WatchKind.Change = 2;
\r
29454 * Interested in delete events
\r
29456 WatchKind.Delete = 4;
\r
29457 })(WatchKind = exports.WatchKind || (exports.WatchKind = {}));
\r
29459 * Diagnostics notification are sent from the server to the client to signal
\r
29460 * results of validation runs.
\r
29462 var PublishDiagnosticsNotification;
\r
29463 (function (PublishDiagnosticsNotification) {
\r
29464 PublishDiagnosticsNotification.type = new messages_1.ProtocolNotificationType('textDocument/publishDiagnostics');
\r
29465 })(PublishDiagnosticsNotification = exports.PublishDiagnosticsNotification || (exports.PublishDiagnosticsNotification = {}));
\r
29467 * How a completion was triggered
\r
29469 var CompletionTriggerKind;
\r
29470 (function (CompletionTriggerKind) {
\r
29472 * Completion was triggered by typing an identifier (24x7 code
\r
29473 * complete), manual invocation (e.g Ctrl+Space) or via API.
\r
29475 CompletionTriggerKind.Invoked = 1;
\r
29477 * Completion was triggered by a trigger character specified by
\r
29478 * the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
\r
29480 CompletionTriggerKind.TriggerCharacter = 2;
\r
29482 * Completion was re-triggered as current completion list is incomplete
\r
29484 CompletionTriggerKind.TriggerForIncompleteCompletions = 3;
\r
29485 })(CompletionTriggerKind = exports.CompletionTriggerKind || (exports.CompletionTriggerKind = {}));
\r
29487 * Request to request completion at a given text document position. The request's
\r
29488 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response
\r
29489 * is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)
\r
29490 * or a Thenable that resolves to such.
\r
29492 * The request can delay the computation of the [`detail`](#CompletionItem.detail)
\r
29493 * and [`documentation`](#CompletionItem.documentation) properties to the `completionItem/resolve`
\r
29494 * request. However, properties that are needed for the initial sorting and filtering, like `sortText`,
\r
29495 * `filterText`, `insertText`, and `textEdit`, must not be changed during resolve.
\r
29497 var CompletionRequest;
\r
29498 (function (CompletionRequest) {
\r
29499 CompletionRequest.method = 'textDocument/completion';
\r
29500 CompletionRequest.type = new messages_1.ProtocolRequestType(CompletionRequest.method);
\r
29501 /** @deprecated Use CompletionRequest.type */
\r
29502 CompletionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
29503 })(CompletionRequest = exports.CompletionRequest || (exports.CompletionRequest = {}));
\r
29505 * Request to resolve additional information for a given completion item.The request's
\r
29506 * parameter is of type [CompletionItem](#CompletionItem) the response
\r
29507 * is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.
\r
29509 var CompletionResolveRequest;
\r
29510 (function (CompletionResolveRequest) {
\r
29511 CompletionResolveRequest.method = 'completionItem/resolve';
\r
29512 CompletionResolveRequest.type = new messages_1.ProtocolRequestType(CompletionResolveRequest.method);
\r
29513 })(CompletionResolveRequest = exports.CompletionResolveRequest || (exports.CompletionResolveRequest = {}));
\r
29515 * Request to request hover information at a given text document position. The request's
\r
29516 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of
\r
29517 * type [Hover](#Hover) or a Thenable that resolves to such.
\r
29519 var HoverRequest;
\r
29520 (function (HoverRequest) {
\r
29521 HoverRequest.method = 'textDocument/hover';
\r
29522 HoverRequest.type = new messages_1.ProtocolRequestType(HoverRequest.method);
\r
29523 })(HoverRequest = exports.HoverRequest || (exports.HoverRequest = {}));
\r
29525 * How a signature help was triggered.
\r
29529 var SignatureHelpTriggerKind;
\r
29530 (function (SignatureHelpTriggerKind) {
\r
29532 * Signature help was invoked manually by the user or by a command.
\r
29534 SignatureHelpTriggerKind.Invoked = 1;
\r
29536 * Signature help was triggered by a trigger character.
\r
29538 SignatureHelpTriggerKind.TriggerCharacter = 2;
\r
29540 * Signature help was triggered by the cursor moving or by the document content changing.
\r
29542 SignatureHelpTriggerKind.ContentChange = 3;
\r
29543 })(SignatureHelpTriggerKind = exports.SignatureHelpTriggerKind || (exports.SignatureHelpTriggerKind = {}));
\r
29544 var SignatureHelpRequest;
\r
29545 (function (SignatureHelpRequest) {
\r
29546 SignatureHelpRequest.method = 'textDocument/signatureHelp';
\r
29547 SignatureHelpRequest.type = new messages_1.ProtocolRequestType(SignatureHelpRequest.method);
\r
29548 })(SignatureHelpRequest = exports.SignatureHelpRequest || (exports.SignatureHelpRequest = {}));
\r
29550 * A request to resolve the definition location of a symbol at a given text
\r
29551 * document position. The request's parameter is of type [TextDocumentPosition]
\r
29552 * (#TextDocumentPosition) the response is of either type [Definition](#Definition)
\r
29553 * or a typed array of [DefinitionLink](#DefinitionLink) or a Thenable that resolves
\r
29556 var DefinitionRequest;
\r
29557 (function (DefinitionRequest) {
\r
29558 DefinitionRequest.method = 'textDocument/definition';
\r
29559 DefinitionRequest.type = new messages_1.ProtocolRequestType(DefinitionRequest.method);
\r
29560 /** @deprecated Use DefinitionRequest.type */
\r
29561 DefinitionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
29562 })(DefinitionRequest = exports.DefinitionRequest || (exports.DefinitionRequest = {}));
\r
29564 * A request to resolve project-wide references for the symbol denoted
\r
29565 * by the given text document position. The request's parameter is of
\r
29566 * type [ReferenceParams](#ReferenceParams) the response is of type
\r
29567 * [Location[]](#Location) or a Thenable that resolves to such.
\r
29569 var ReferencesRequest;
\r
29570 (function (ReferencesRequest) {
\r
29571 ReferencesRequest.method = 'textDocument/references';
\r
29572 ReferencesRequest.type = new messages_1.ProtocolRequestType(ReferencesRequest.method);
\r
29573 /** @deprecated Use ReferencesRequest.type */
\r
29574 ReferencesRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
29575 })(ReferencesRequest = exports.ReferencesRequest || (exports.ReferencesRequest = {}));
\r
29577 * Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given
\r
29578 * text document position. The request's parameter is of type [TextDocumentPosition]
\r
29579 * (#TextDocumentPosition) the request response is of type [DocumentHighlight[]]
\r
29580 * (#DocumentHighlight) or a Thenable that resolves to such.
\r
29582 var DocumentHighlightRequest;
\r
29583 (function (DocumentHighlightRequest) {
\r
29584 DocumentHighlightRequest.method = 'textDocument/documentHighlight';
\r
29585 DocumentHighlightRequest.type = new messages_1.ProtocolRequestType(DocumentHighlightRequest.method);
\r
29586 /** @deprecated Use DocumentHighlightRequest.type */
\r
29587 DocumentHighlightRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
29588 })(DocumentHighlightRequest = exports.DocumentHighlightRequest || (exports.DocumentHighlightRequest = {}));
\r
29590 * A request to list all symbols found in a given text document. The request's
\r
29591 * parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the
\r
29592 * response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable
\r
29593 * that resolves to such.
\r
29595 var DocumentSymbolRequest;
\r
29596 (function (DocumentSymbolRequest) {
\r
29597 DocumentSymbolRequest.method = 'textDocument/documentSymbol';
\r
29598 DocumentSymbolRequest.type = new messages_1.ProtocolRequestType(DocumentSymbolRequest.method);
\r
29599 /** @deprecated Use DocumentSymbolRequest.type */
\r
29600 DocumentSymbolRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
29601 })(DocumentSymbolRequest = exports.DocumentSymbolRequest || (exports.DocumentSymbolRequest = {}));
\r
29603 * A request to provide commands for the given text document and range.
\r
29605 var CodeActionRequest;
\r
29606 (function (CodeActionRequest) {
\r
29607 CodeActionRequest.method = 'textDocument/codeAction';
\r
29608 CodeActionRequest.type = new messages_1.ProtocolRequestType(CodeActionRequest.method);
\r
29609 /** @deprecated Use CodeActionRequest.type */
\r
29610 CodeActionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
29611 })(CodeActionRequest = exports.CodeActionRequest || (exports.CodeActionRequest = {}));
\r
29613 * A request to list project-wide symbols matching the query string given
\r
29614 * by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is
\r
29615 * of type [SymbolInformation[]](#SymbolInformation) or a Thenable that
\r
29616 * resolves to such.
\r
29618 var WorkspaceSymbolRequest;
\r
29619 (function (WorkspaceSymbolRequest) {
\r
29620 WorkspaceSymbolRequest.method = 'workspace/symbol';
\r
29621 WorkspaceSymbolRequest.type = new messages_1.ProtocolRequestType(WorkspaceSymbolRequest.method);
\r
29622 /** @deprecated Use WorkspaceSymbolRequest.type */
\r
29623 WorkspaceSymbolRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
29624 })(WorkspaceSymbolRequest = exports.WorkspaceSymbolRequest || (exports.WorkspaceSymbolRequest = {}));
\r
29626 * A request to provide code lens for the given text document.
\r
29628 var CodeLensRequest;
\r
29629 (function (CodeLensRequest) {
\r
29630 CodeLensRequest.type = new messages_1.ProtocolRequestType('textDocument/codeLens');
\r
29631 /** @deprecated Use CodeLensRequest.type */
\r
29632 CodeLensRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
29633 })(CodeLensRequest = exports.CodeLensRequest || (exports.CodeLensRequest = {}));
\r
29635 * A request to resolve a command for a given code lens.
\r
29637 var CodeLensResolveRequest;
\r
29638 (function (CodeLensResolveRequest) {
\r
29639 CodeLensResolveRequest.type = new messages_1.ProtocolRequestType('codeLens/resolve');
\r
29640 })(CodeLensResolveRequest = exports.CodeLensResolveRequest || (exports.CodeLensResolveRequest = {}));
\r
29642 * A request to provide document links
\r
29644 var DocumentLinkRequest;
\r
29645 (function (DocumentLinkRequest) {
\r
29646 DocumentLinkRequest.method = 'textDocument/documentLink';
\r
29647 DocumentLinkRequest.type = new messages_1.ProtocolRequestType(DocumentLinkRequest.method);
\r
29648 /** @deprecated Use DocumentLinkRequest.type */
\r
29649 DocumentLinkRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
29650 })(DocumentLinkRequest = exports.DocumentLinkRequest || (exports.DocumentLinkRequest = {}));
\r
29652 * Request to resolve additional information for a given document link. The request's
\r
29653 * parameter is of type [DocumentLink](#DocumentLink) the response
\r
29654 * is of type [DocumentLink](#DocumentLink) or a Thenable that resolves to such.
\r
29656 var DocumentLinkResolveRequest;
\r
29657 (function (DocumentLinkResolveRequest) {
\r
29658 DocumentLinkResolveRequest.type = new messages_1.ProtocolRequestType('documentLink/resolve');
\r
29659 })(DocumentLinkResolveRequest = exports.DocumentLinkResolveRequest || (exports.DocumentLinkResolveRequest = {}));
\r
29661 * A request to to format a whole document.
\r
29663 var DocumentFormattingRequest;
\r
29664 (function (DocumentFormattingRequest) {
\r
29665 DocumentFormattingRequest.method = 'textDocument/formatting';
\r
29666 DocumentFormattingRequest.type = new messages_1.ProtocolRequestType(DocumentFormattingRequest.method);
\r
29667 })(DocumentFormattingRequest = exports.DocumentFormattingRequest || (exports.DocumentFormattingRequest = {}));
\r
29669 * A request to to format a range in a document.
\r
29671 var DocumentRangeFormattingRequest;
\r
29672 (function (DocumentRangeFormattingRequest) {
\r
29673 DocumentRangeFormattingRequest.method = 'textDocument/rangeFormatting';
\r
29674 DocumentRangeFormattingRequest.type = new messages_1.ProtocolRequestType(DocumentRangeFormattingRequest.method);
\r
29675 })(DocumentRangeFormattingRequest = exports.DocumentRangeFormattingRequest || (exports.DocumentRangeFormattingRequest = {}));
\r
29677 * A request to format a document on type.
\r
29679 var DocumentOnTypeFormattingRequest;
\r
29680 (function (DocumentOnTypeFormattingRequest) {
\r
29681 DocumentOnTypeFormattingRequest.method = 'textDocument/onTypeFormatting';
\r
29682 DocumentOnTypeFormattingRequest.type = new messages_1.ProtocolRequestType(DocumentOnTypeFormattingRequest.method);
\r
29683 })(DocumentOnTypeFormattingRequest = exports.DocumentOnTypeFormattingRequest || (exports.DocumentOnTypeFormattingRequest = {}));
\r
29685 * A request to rename a symbol.
\r
29687 var RenameRequest;
\r
29688 (function (RenameRequest) {
\r
29689 RenameRequest.method = 'textDocument/rename';
\r
29690 RenameRequest.type = new messages_1.ProtocolRequestType(RenameRequest.method);
\r
29691 })(RenameRequest = exports.RenameRequest || (exports.RenameRequest = {}));
\r
29693 * A request to test and perform the setup necessary for a rename.
\r
29695 var PrepareRenameRequest;
\r
29696 (function (PrepareRenameRequest) {
\r
29697 PrepareRenameRequest.method = 'textDocument/prepareRename';
\r
29698 PrepareRenameRequest.type = new messages_1.ProtocolRequestType(PrepareRenameRequest.method);
\r
29699 })(PrepareRenameRequest = exports.PrepareRenameRequest || (exports.PrepareRenameRequest = {}));
\r
29701 * A request send from the client to the server to execute a command. The request might return
\r
29702 * a workspace edit which the client will apply to the workspace.
\r
29704 var ExecuteCommandRequest;
\r
29705 (function (ExecuteCommandRequest) {
\r
29706 ExecuteCommandRequest.type = new messages_1.ProtocolRequestType('workspace/executeCommand');
\r
29707 })(ExecuteCommandRequest = exports.ExecuteCommandRequest || (exports.ExecuteCommandRequest = {}));
\r
29709 * A request sent from the server to the client to modified certain resources.
\r
29711 var ApplyWorkspaceEditRequest;
\r
29712 (function (ApplyWorkspaceEditRequest) {
\r
29713 ApplyWorkspaceEditRequest.type = new messages_1.ProtocolRequestType('workspace/applyEdit');
\r
29714 })(ApplyWorkspaceEditRequest = exports.ApplyWorkspaceEditRequest || (exports.ApplyWorkspaceEditRequest = {}));
\r
29719 /***/ (function(module, exports, __webpack_require__) {
29722 /* --------------------------------------------------------------------------------------------
\r
29723 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
29724 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
29725 * ------------------------------------------------------------------------------------------ */
\r
29727 Object.defineProperty(exports, "__esModule", { value: true });
\r
29728 function boolean(value) {
\r
29729 return value === true || value === false;
\r
29731 exports.boolean = boolean;
\r
29732 function string(value) {
\r
29733 return typeof value === 'string' || value instanceof String;
\r
29735 exports.string = string;
\r
29736 function number(value) {
\r
29737 return typeof value === 'number' || value instanceof Number;
\r
29739 exports.number = number;
\r
29740 function error(value) {
\r
29741 return value instanceof Error;
\r
29743 exports.error = error;
\r
29744 function func(value) {
\r
29745 return typeof value === 'function';
\r
29747 exports.func = func;
\r
29748 function array(value) {
\r
29749 return Array.isArray(value);
\r
29751 exports.array = array;
\r
29752 function stringArray(value) {
\r
29753 return array(value) && value.every(elem => string(elem));
\r
29755 exports.stringArray = stringArray;
\r
29756 function typedArray(value, check) {
\r
29757 return Array.isArray(value) && value.every(check);
\r
29759 exports.typedArray = typedArray;
\r
29760 function objectLiteral(value) {
\r
29761 // Strictly speaking class instances pass this check as well. Since the LSP
\r
29762 // doesn't use classes we ignore this for now. If we do we need to add something
\r
29763 // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
\r
29764 return value !== null && typeof value === 'object';
\r
29766 exports.objectLiteral = objectLiteral;
\r
29771 /***/ (function(module, exports, __webpack_require__) {
29774 /* --------------------------------------------------------------------------------------------
\r
29775 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
29776 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
29777 * ------------------------------------------------------------------------------------------ */
\r
29779 Object.defineProperty(exports, "__esModule", { value: true });
\r
29780 const vscode_jsonrpc_1 = __webpack_require__(163);
\r
29781 class ProtocolRequestType0 extends vscode_jsonrpc_1.RequestType0 {
\r
29782 constructor(method) {
\r
29786 exports.ProtocolRequestType0 = ProtocolRequestType0;
\r
29787 class ProtocolRequestType extends vscode_jsonrpc_1.RequestType {
\r
29788 constructor(method) {
\r
29792 exports.ProtocolRequestType = ProtocolRequestType;
\r
29793 class ProtocolNotificationType extends vscode_jsonrpc_1.NotificationType {
\r
29794 constructor(method) {
\r
29798 exports.ProtocolNotificationType = ProtocolNotificationType;
\r
29799 class ProtocolNotificationType0 extends vscode_jsonrpc_1.NotificationType0 {
\r
29800 constructor(method) {
\r
29804 exports.ProtocolNotificationType0 = ProtocolNotificationType0;
\r
29809 /***/ (function(module, exports, __webpack_require__) {
29812 /* --------------------------------------------------------------------------------------------
\r
29813 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
29814 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
29815 * ------------------------------------------------------------------------------------------ */
\r
29817 Object.defineProperty(exports, "__esModule", { value: true });
\r
29818 const vscode_jsonrpc_1 = __webpack_require__(163);
\r
29819 const messages_1 = __webpack_require__(178);
\r
29820 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
29821 let __noDynamicImport;
\r
29823 * A request to resolve the implementation locations of a symbol at a given text
\r
29824 * document position. The request's parameter is of type [TextDocumentPositioParams]
\r
29825 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
\r
29826 * Thenable that resolves to such.
\r
29828 var ImplementationRequest;
\r
29829 (function (ImplementationRequest) {
\r
29830 ImplementationRequest.method = 'textDocument/implementation';
\r
29831 ImplementationRequest.type = new messages_1.ProtocolRequestType(ImplementationRequest.method);
\r
29832 /** @deprecated Use ImplementationRequest.type */
\r
29833 ImplementationRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
29834 })(ImplementationRequest = exports.ImplementationRequest || (exports.ImplementationRequest = {}));
\r
29839 /***/ (function(module, exports, __webpack_require__) {
29842 /* --------------------------------------------------------------------------------------------
\r
29843 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
29844 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
29845 * ------------------------------------------------------------------------------------------ */
\r
29847 Object.defineProperty(exports, "__esModule", { value: true });
\r
29848 const vscode_jsonrpc_1 = __webpack_require__(163);
\r
29849 const messages_1 = __webpack_require__(178);
\r
29850 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
29851 let __noDynamicImport;
\r
29853 * A request to resolve the type definition locations of a symbol at a given text
\r
29854 * document position. The request's parameter is of type [TextDocumentPositioParams]
\r
29855 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
\r
29856 * Thenable that resolves to such.
\r
29858 var TypeDefinitionRequest;
\r
29859 (function (TypeDefinitionRequest) {
\r
29860 TypeDefinitionRequest.method = 'textDocument/typeDefinition';
\r
29861 TypeDefinitionRequest.type = new messages_1.ProtocolRequestType(TypeDefinitionRequest.method);
\r
29862 /** @deprecated Use TypeDefinitionRequest.type */
\r
29863 TypeDefinitionRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
29864 })(TypeDefinitionRequest = exports.TypeDefinitionRequest || (exports.TypeDefinitionRequest = {}));
\r
29869 /***/ (function(module, exports, __webpack_require__) {
29872 /* --------------------------------------------------------------------------------------------
\r
29873 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
29874 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
29875 * ------------------------------------------------------------------------------------------ */
\r
29877 Object.defineProperty(exports, "__esModule", { value: true });
\r
29878 const messages_1 = __webpack_require__(178);
\r
29880 * The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.
\r
29882 var WorkspaceFoldersRequest;
\r
29883 (function (WorkspaceFoldersRequest) {
\r
29884 WorkspaceFoldersRequest.type = new messages_1.ProtocolRequestType0('workspace/workspaceFolders');
\r
29885 })(WorkspaceFoldersRequest = exports.WorkspaceFoldersRequest || (exports.WorkspaceFoldersRequest = {}));
\r
29887 * The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace
\r
29888 * folder configuration changes.
\r
29890 var DidChangeWorkspaceFoldersNotification;
\r
29891 (function (DidChangeWorkspaceFoldersNotification) {
\r
29892 DidChangeWorkspaceFoldersNotification.type = new messages_1.ProtocolNotificationType('workspace/didChangeWorkspaceFolders');
\r
29893 })(DidChangeWorkspaceFoldersNotification = exports.DidChangeWorkspaceFoldersNotification || (exports.DidChangeWorkspaceFoldersNotification = {}));
\r
29898 /***/ (function(module, exports, __webpack_require__) {
29901 /* --------------------------------------------------------------------------------------------
\r
29902 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
29903 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
29904 * ------------------------------------------------------------------------------------------ */
\r
29906 Object.defineProperty(exports, "__esModule", { value: true });
\r
29907 const messages_1 = __webpack_require__(178);
\r
29909 * The 'workspace/configuration' request is sent from the server to the client to fetch a certain
\r
29910 * configuration setting.
\r
29912 * This pull model replaces the old push model were the client signaled configuration change via an
\r
29913 * event. If the server still needs to react to configuration changes (since the server caches the
\r
29914 * result of `workspace/configuration` requests) the server should register for an empty configuration
\r
29915 * change event and empty the cache if such an event is received.
\r
29917 var ConfigurationRequest;
\r
29918 (function (ConfigurationRequest) {
\r
29919 ConfigurationRequest.type = new messages_1.ProtocolRequestType('workspace/configuration');
\r
29920 })(ConfigurationRequest = exports.ConfigurationRequest || (exports.ConfigurationRequest = {}));
\r
29925 /***/ (function(module, exports, __webpack_require__) {
29928 /* --------------------------------------------------------------------------------------------
\r
29929 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
29930 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
29931 * ------------------------------------------------------------------------------------------ */
\r
29933 Object.defineProperty(exports, "__esModule", { value: true });
\r
29934 const vscode_jsonrpc_1 = __webpack_require__(163);
\r
29935 const messages_1 = __webpack_require__(178);
\r
29937 * A request to list all color symbols found in a given text document. The request's
\r
29938 * parameter is of type [DocumentColorParams](#DocumentColorParams) the
\r
29939 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
\r
29940 * that resolves to such.
\r
29942 var DocumentColorRequest;
\r
29943 (function (DocumentColorRequest) {
\r
29944 DocumentColorRequest.method = 'textDocument/documentColor';
\r
29945 DocumentColorRequest.type = new messages_1.ProtocolRequestType(DocumentColorRequest.method);
\r
29946 /** @deprecated Use DocumentColorRequest.type */
\r
29947 DocumentColorRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
29948 })(DocumentColorRequest = exports.DocumentColorRequest || (exports.DocumentColorRequest = {}));
\r
29950 * A request to list all presentation for a color. The request's
\r
29951 * parameter is of type [ColorPresentationParams](#ColorPresentationParams) the
\r
29952 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
\r
29953 * that resolves to such.
\r
29955 var ColorPresentationRequest;
\r
29956 (function (ColorPresentationRequest) {
\r
29957 ColorPresentationRequest.type = new messages_1.ProtocolRequestType('textDocument/colorPresentation');
\r
29958 })(ColorPresentationRequest = exports.ColorPresentationRequest || (exports.ColorPresentationRequest = {}));
\r
29963 /***/ (function(module, exports, __webpack_require__) {
29967 /*---------------------------------------------------------------------------------------------
\r
29968 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
29969 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
29970 *--------------------------------------------------------------------------------------------*/
\r
29971 Object.defineProperty(exports, "__esModule", { value: true });
\r
29972 const vscode_jsonrpc_1 = __webpack_require__(163);
\r
29973 const messages_1 = __webpack_require__(178);
\r
29975 * Enum of known range kinds
\r
29977 var FoldingRangeKind;
\r
29978 (function (FoldingRangeKind) {
\r
29980 * Folding range for a comment
\r
29982 FoldingRangeKind["Comment"] = "comment";
\r
29984 * Folding range for a imports or includes
\r
29986 FoldingRangeKind["Imports"] = "imports";
\r
29988 * Folding range for a region (e.g. `#region`)
\r
29990 FoldingRangeKind["Region"] = "region";
\r
29991 })(FoldingRangeKind = exports.FoldingRangeKind || (exports.FoldingRangeKind = {}));
\r
29993 * A request to provide folding ranges in a document. The request's
\r
29994 * parameter is of type [FoldingRangeParams](#FoldingRangeParams), the
\r
29995 * response is of type [FoldingRangeList](#FoldingRangeList) or a Thenable
\r
29996 * that resolves to such.
\r
29998 var FoldingRangeRequest;
\r
29999 (function (FoldingRangeRequest) {
\r
30000 FoldingRangeRequest.method = 'textDocument/foldingRange';
\r
30001 FoldingRangeRequest.type = new messages_1.ProtocolRequestType(FoldingRangeRequest.method);
\r
30002 /** @deprecated Use FoldingRangeRequest.type */
\r
30003 FoldingRangeRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
30004 })(FoldingRangeRequest = exports.FoldingRangeRequest || (exports.FoldingRangeRequest = {}));
\r
30009 /***/ (function(module, exports, __webpack_require__) {
30012 /* --------------------------------------------------------------------------------------------
\r
30013 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
30014 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
30015 * ------------------------------------------------------------------------------------------ */
\r
30017 Object.defineProperty(exports, "__esModule", { value: true });
\r
30018 const vscode_jsonrpc_1 = __webpack_require__(163);
\r
30019 const messages_1 = __webpack_require__(178);
\r
30020 // @ts-ignore: to avoid inlining LocatioLink as dynamic import
\r
30021 let __noDynamicImport;
\r
30023 * A request to resolve the type definition locations of a symbol at a given text
\r
30024 * document position. The request's parameter is of type [TextDocumentPositioParams]
\r
30025 * (#TextDocumentPositionParams) the response is of type [Declaration](#Declaration)
\r
30026 * or a typed array of [DeclarationLink](#DeclarationLink) or a Thenable that resolves
\r
30029 var DeclarationRequest;
\r
30030 (function (DeclarationRequest) {
\r
30031 DeclarationRequest.method = 'textDocument/declaration';
\r
30032 DeclarationRequest.type = new messages_1.ProtocolRequestType(DeclarationRequest.method);
\r
30033 /** @deprecated Use DeclarationRequest.type */
\r
30034 DeclarationRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
30035 })(DeclarationRequest = exports.DeclarationRequest || (exports.DeclarationRequest = {}));
\r
30040 /***/ (function(module, exports, __webpack_require__) {
30044 /*---------------------------------------------------------------------------------------------
\r
30045 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
30046 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
30047 *--------------------------------------------------------------------------------------------*/
\r
30048 Object.defineProperty(exports, "__esModule", { value: true });
\r
30049 const vscode_jsonrpc_1 = __webpack_require__(163);
\r
30050 const messages_1 = __webpack_require__(178);
\r
30052 * A request to provide selection ranges in a document. The request's
\r
30053 * parameter is of type [SelectionRangeParams](#SelectionRangeParams), the
\r
30054 * response is of type [SelectionRange[]](#SelectionRange[]) or a Thenable
\r
30055 * that resolves to such.
\r
30057 var SelectionRangeRequest;
\r
30058 (function (SelectionRangeRequest) {
\r
30059 SelectionRangeRequest.method = 'textDocument/selectionRange';
\r
30060 SelectionRangeRequest.type = new messages_1.ProtocolRequestType(SelectionRangeRequest.method);
\r
30061 /** @deprecated Use SelectionRangeRequest.type */
\r
30062 SelectionRangeRequest.resultType = new vscode_jsonrpc_1.ProgressType();
\r
30063 })(SelectionRangeRequest = exports.SelectionRangeRequest || (exports.SelectionRangeRequest = {}));
\r
30068 /***/ (function(module, exports, __webpack_require__) {
30071 /* --------------------------------------------------------------------------------------------
\r
30072 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
30073 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
30074 * ------------------------------------------------------------------------------------------ */
\r
30076 Object.defineProperty(exports, "__esModule", { value: true });
\r
30077 const vscode_jsonrpc_1 = __webpack_require__(163);
\r
30078 const messages_1 = __webpack_require__(178);
\r
30079 var WorkDoneProgress;
\r
30080 (function (WorkDoneProgress) {
\r
30081 WorkDoneProgress.type = new vscode_jsonrpc_1.ProgressType();
\r
30082 })(WorkDoneProgress = exports.WorkDoneProgress || (exports.WorkDoneProgress = {}));
\r
30084 * The `window/workDoneProgress/create` request is sent from the server to the client to initiate progress
\r
30085 * reporting from the server.
\r
30087 var WorkDoneProgressCreateRequest;
\r
30088 (function (WorkDoneProgressCreateRequest) {
\r
30089 WorkDoneProgressCreateRequest.type = new messages_1.ProtocolRequestType('window/workDoneProgress/create');
\r
30090 })(WorkDoneProgressCreateRequest = exports.WorkDoneProgressCreateRequest || (exports.WorkDoneProgressCreateRequest = {}));
\r
30092 * The `window/workDoneProgress/cancel` notification is sent from the client to the server to cancel a progress
\r
30093 * initiated on the server side.
\r
30095 var WorkDoneProgressCancelNotification;
\r
30096 (function (WorkDoneProgressCancelNotification) {
\r
30097 WorkDoneProgressCancelNotification.type = new messages_1.ProtocolNotificationType('window/workDoneProgress/cancel');
\r
30098 })(WorkDoneProgressCancelNotification = exports.WorkDoneProgressCancelNotification || (exports.WorkDoneProgressCancelNotification = {}));
\r
30103 /***/ (function(module, exports, __webpack_require__) {
30106 /* --------------------------------------------------------------------------------------------
\r
30107 * Copyright (c) TypeFox and others. All rights reserved.
\r
30108 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
30109 * ------------------------------------------------------------------------------------------ */
\r
30111 Object.defineProperty(exports, "__esModule", { value: true });
\r
30112 const messages_1 = __webpack_require__(178);
\r
30114 * A request to result a `CallHierarchyItem` in a document at a given position.
\r
30115 * Can be used as an input to a incoming or outgoing call hierarchy.
\r
30117 * @since 3.16.0 - Proposed state
\r
30119 var CallHierarchyPrepareRequest;
\r
30120 (function (CallHierarchyPrepareRequest) {
\r
30121 CallHierarchyPrepareRequest.method = 'textDocument/prepareCallHierarchy';
\r
30122 CallHierarchyPrepareRequest.type = new messages_1.ProtocolRequestType(CallHierarchyPrepareRequest.method);
\r
30123 })(CallHierarchyPrepareRequest = exports.CallHierarchyPrepareRequest || (exports.CallHierarchyPrepareRequest = {}));
\r
30125 * A request to resolve the incoming calls for a given `CallHierarchyItem`.
\r
30127 * @since 3.16.0 - Proposed state
\r
30129 var CallHierarchyIncomingCallsRequest;
\r
30130 (function (CallHierarchyIncomingCallsRequest) {
\r
30131 CallHierarchyIncomingCallsRequest.method = 'callHierarchy/incomingCalls';
\r
30132 CallHierarchyIncomingCallsRequest.type = new messages_1.ProtocolRequestType(CallHierarchyIncomingCallsRequest.method);
\r
30133 })(CallHierarchyIncomingCallsRequest = exports.CallHierarchyIncomingCallsRequest || (exports.CallHierarchyIncomingCallsRequest = {}));
\r
30135 * A request to resolve the outgoing calls for a given `CallHierarchyItem`.
\r
30137 * @since 3.16.0 - Proposed state
\r
30139 var CallHierarchyOutgoingCallsRequest;
\r
30140 (function (CallHierarchyOutgoingCallsRequest) {
\r
30141 CallHierarchyOutgoingCallsRequest.method = 'callHierarchy/outgoingCalls';
\r
30142 CallHierarchyOutgoingCallsRequest.type = new messages_1.ProtocolRequestType(CallHierarchyOutgoingCallsRequest.method);
\r
30143 })(CallHierarchyOutgoingCallsRequest = exports.CallHierarchyOutgoingCallsRequest || (exports.CallHierarchyOutgoingCallsRequest = {}));
\r
30148 /***/ (function(module, exports, __webpack_require__) {
30151 /* --------------------------------------------------------------------------------------------
\r
30152 * Copyright (c) Microsoft Corporation. All rights reserved.
\r
30153 * Licensed under the MIT License. See License.txt in the project root for license information.
\r
30154 * ------------------------------------------------------------------------------------------ */
\r
30156 Object.defineProperty(exports, "__esModule", { value: true });
\r
30157 const messages_1 = __webpack_require__(178);
\r
30159 * A set of predefined token types. This set is not fixed
\r
30160 * an clients can specify additional token types via the
\r
30161 * corresponding client capabilities.
\r
30163 * @since 3.16.0 - Proposed state
\r
30165 var SemanticTokenTypes;
\r
30166 (function (SemanticTokenTypes) {
\r
30167 SemanticTokenTypes["comment"] = "comment";
\r
30168 SemanticTokenTypes["keyword"] = "keyword";
\r
30169 SemanticTokenTypes["string"] = "string";
\r
30170 SemanticTokenTypes["number"] = "number";
\r
30171 SemanticTokenTypes["regexp"] = "regexp";
\r
30172 SemanticTokenTypes["operator"] = "operator";
\r
30173 SemanticTokenTypes["namespace"] = "namespace";
\r
30174 SemanticTokenTypes["type"] = "type";
\r
30175 SemanticTokenTypes["struct"] = "struct";
\r
30176 SemanticTokenTypes["class"] = "class";
\r
30177 SemanticTokenTypes["interface"] = "interface";
\r
30178 SemanticTokenTypes["enum"] = "enum";
\r
30179 SemanticTokenTypes["typeParameter"] = "typeParameter";
\r
30180 SemanticTokenTypes["function"] = "function";
\r
30181 SemanticTokenTypes["member"] = "member";
\r
30182 SemanticTokenTypes["property"] = "property";
\r
30183 SemanticTokenTypes["macro"] = "macro";
\r
30184 SemanticTokenTypes["variable"] = "variable";
\r
30185 SemanticTokenTypes["parameter"] = "parameter";
\r
30186 SemanticTokenTypes["label"] = "label";
\r
30187 })(SemanticTokenTypes = exports.SemanticTokenTypes || (exports.SemanticTokenTypes = {}));
\r
30189 * A set of predefined token modifiers. This set is not fixed
\r
30190 * an clients can specify additional token types via the
\r
30191 * corresponding client capabilities.
\r
30193 * @since 3.16.0 - Proposed state
\r
30195 var SemanticTokenModifiers;
\r
30196 (function (SemanticTokenModifiers) {
\r
30197 SemanticTokenModifiers["documentation"] = "documentation";
\r
30198 SemanticTokenModifiers["declaration"] = "declaration";
\r
30199 SemanticTokenModifiers["definition"] = "definition";
\r
30200 SemanticTokenModifiers["reference"] = "reference";
\r
30201 SemanticTokenModifiers["static"] = "static";
\r
30202 SemanticTokenModifiers["abstract"] = "abstract";
\r
30203 SemanticTokenModifiers["deprecated"] = "deprecated";
\r
30204 SemanticTokenModifiers["async"] = "async";
\r
30205 SemanticTokenModifiers["volatile"] = "volatile";
\r
30206 SemanticTokenModifiers["readonly"] = "readonly";
\r
30207 })(SemanticTokenModifiers = exports.SemanticTokenModifiers || (exports.SemanticTokenModifiers = {}));
\r
30209 * @since 3.16.0 - Proposed state
\r
30211 var SemanticTokens;
\r
30212 (function (SemanticTokens) {
\r
30213 function is(value) {
\r
30214 const candidate = value;
\r
30215 return candidate !== undefined && (candidate.resultId === undefined || typeof candidate.resultId === 'string') &&
\r
30216 Array.isArray(candidate.data) && (candidate.data.length === 0 || typeof candidate.data[0] === 'number');
\r
30218 SemanticTokens.is = is;
\r
30219 })(SemanticTokens = exports.SemanticTokens || (exports.SemanticTokens = {}));
\r
30221 * @since 3.16.0 - Proposed state
\r
30223 var SemanticTokensRequest;
\r
30224 (function (SemanticTokensRequest) {
\r
30225 SemanticTokensRequest.method = 'textDocument/semanticTokens';
\r
30226 SemanticTokensRequest.type = new messages_1.ProtocolRequestType(SemanticTokensRequest.method);
\r
30227 })(SemanticTokensRequest = exports.SemanticTokensRequest || (exports.SemanticTokensRequest = {}));
\r
30229 * @since 3.16.0 - Proposed state
\r
30231 var SemanticTokensEditsRequest;
\r
30232 (function (SemanticTokensEditsRequest) {
\r
30233 SemanticTokensEditsRequest.method = 'textDocument/semanticTokens/edits';
\r
30234 SemanticTokensEditsRequest.type = new messages_1.ProtocolRequestType(SemanticTokensEditsRequest.method);
\r
30235 })(SemanticTokensEditsRequest = exports.SemanticTokensEditsRequest || (exports.SemanticTokensEditsRequest = {}));
\r
30237 * @since 3.16.0 - Proposed state
\r
30239 var SemanticTokensRangeRequest;
\r
30240 (function (SemanticTokensRangeRequest) {
\r
30241 SemanticTokensRangeRequest.method = 'textDocument/semanticTokens/range';
\r
30242 SemanticTokensRangeRequest.type = new messages_1.ProtocolRequestType(SemanticTokensRangeRequest.method);
\r
30243 })(SemanticTokensRangeRequest = exports.SemanticTokensRangeRequest || (exports.SemanticTokensRangeRequest = {}));
\r