{"version":3,"sources":["webpack://WebLinksAddon/webpack/universalModuleDefinition","webpack://WebLinksAddon/webpack/bootstrap","webpack://WebLinksAddon/./src/WebLinksAddon.ts","webpack://WebLinksAddon/./src/WebLinkProvider.ts"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","strictUrlRegex","RegExp","start","handleLink","event","uri","newWindow","open","opener","location","href","console","warn","_handler","_options","_useLinkProvider","this","matchIndex","activate","terminal","_terminal","_linkProvider","registerLinkProvider","WebLinkProvider","_linkMatcherId","registerLinkMatcher","dispose","undefined","deregisterLinkMatcher","WebLinksAddon","_regex","provideLinks","y","callback","LinkComputer","computeLink","regex","handler","match","rex","source","flags","_translateBufferLineToStringWithWrap","line","startLineIndex","stringIndex","result","exec","text","log","indexOf","lastIndex","length","endX","endY","cols","range","x","end","push","lineIndex","trimRight","lineWrapsToNext","prevLinesToWrap","lineString","buffer","active","getLine","isWrapped","nextLine","translateToString","substring"],"mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAAuB,cAAID,IAE3BD,EAAoB,cAAIC,IAR1B,CASGK,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUP,QAGnC,IAAIC,EAASI,EAAiBE,GAAY,CACzCC,EAAGD,EACHE,GAAG,EACHT,QAAS,IAUV,OANAU,EAAQH,GAAUI,KAAKV,EAAOD,QAASC,EAAQA,EAAOD,QAASM,GAG/DL,EAAOQ,GAAI,EAGJR,EAAOD,QA0Df,OArDAM,EAAoBM,EAAIF,EAGxBJ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AKU,EAAM,CAGTrC,QAAQsC,IAAI,gDACZ,MASF,GAFAJ,EAAcF,EAAKO,QAAQF,EAAMH,EAAc,GAC/CN,EAAIY,UAAYN,EAAcG,EAAKI,OAC/BP,EAAc,EAEhB,MAMF,IAHA,IAAIQ,EAAOR,EAAcG,EAAKI,OAC1BE,EAAOV,EAAiB,EAErBS,EAAOlC,EAASoC,MACrBF,GAAQlC,EAASoC,KACjBD,IAGF,IAAME,EAAQ,CACZtD,MAAO,CACLuD,EAAGZ,EAAc,EACjBb,EAAGY,EAAiB,GAEtBc,IAAK,CACHD,EAAGJ,EACHrB,EAAGsB,IAIPR,EAAOa,KAAK,CAAEH,MAAK,EAAER,KAAI,EAAE9B,SAAUmB,IAGvC,OAAOS,GASM,EAAAJ,qCAAf,SAAoDkB,EAAmBC,EAAoB1C,GACzF,IACI2C,EACAC,EAFAC,EAAa,GAIjB,EAAG,CAED,KADMrB,EAAOxB,EAAS8C,OAAOC,OAAOC,QAAQP,IAE1C,MAGEjB,EAAKyB,WACPR,IAGFG,EAAkBpB,EAAKyB,gBAChBL,GAET,IAAMnB,EAAiBgB,EAEvB,EAAG,CACD,IAEMjB,EAFA0B,EAAWlD,EAAS8C,OAAOC,OAAOC,QAAQP,EAAY,GAG5D,GAFAE,IAAkBO,GAAWA,EAASD,YAChCzB,EAAOxB,EAAS8C,OAAOC,OAAOC,QAAQP,IAE1C,MAEFI,GAAcrB,EAAK2B,mBAAmBR,GAAmBD,GAAWU,UAAU,EAAGpD,EAASoC,MAC1FK,UACOE,GAET,MAAO,CAACE,EAAYpB,IAExB,EA9FA,GAAa,EAAAV","file":"xterm-addon-web-links.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WebLinksAddon\"] = factory();\n\telse\n\t\troot[\"WebLinksAddon\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { Terminal, ILinkMatcherOptions, ITerminalAddon, IDisposable } from 'xterm';\nimport { WebLinkProvider } from './WebLinkProvider';\n\nconst protocolClause = '(https?:\\\\/\\\\/)';\nconst domainCharacterSet = '[\\\\da-z\\\\.-]+';\nconst negatedDomainCharacterSet = '[^\\\\da-z\\\\.-]+';\nconst domainBodyClause = '(' + domainCharacterSet + ')';\nconst tldClause = '([a-z\\\\.]{2,6})';\nconst ipClause = '((\\\\d{1,3}\\\\.){3}\\\\d{1,3})';\nconst localHostClause = '(localhost)';\nconst portClause = '(:\\\\d{1,5})';\nconst hostClause = '((' + domainBodyClause + '\\\\.' + tldClause + ')|' + ipClause + '|' + localHostClause + ')' + portClause + '?';\nconst pathCharacterSet = '(\\\\/[\\\\/\\\\w\\\\.\\\\-%~:+@]*)*([^:\"\\'\\\\s])';\nconst pathClause = '(' + pathCharacterSet + ')?';\nconst queryStringHashFragmentCharacterSet = '[0-9\\\\w\\\\[\\\\]\\\\(\\\\)\\\\/\\\\?\\\\!#@$%&\\'*+,:;~\\\\=\\\\.\\\\-]*';\nconst queryStringClause = '(\\\\?' + queryStringHashFragmentCharacterSet + ')?';\nconst hashFragmentClause = '(#' + queryStringHashFragmentCharacterSet + ')?';\nconst negatedPathCharacterSet = '[^\\\\/\\\\w\\\\.\\\\-%]+';\nconst bodyClause = hostClause + pathClause + queryStringClause + hashFragmentClause;\nconst start = '(?:^|' + negatedDomainCharacterSet + ')(';\nconst end = ')($|' + negatedPathCharacterSet + ')';\nconst strictUrlRegex = new RegExp(start + protocolClause + bodyClause + end);\n\nfunction handleLink(event: MouseEvent, uri: string): void {\n const newWindow = window.open();\n if (newWindow) {\n newWindow.opener = null;\n newWindow.location.href = uri;\n } else {\n console.warn('Opening link blocked as opener could not be cleared');\n }\n}\n\nexport class WebLinksAddon implements ITerminalAddon {\n private _linkMatcherId: number | undefined;\n private _terminal: Terminal | undefined;\n private _linkProvider: IDisposable | undefined;\n\n constructor(\n private _handler: (event: MouseEvent, uri: string) => void = handleLink,\n private _options: ILinkMatcherOptions = {},\n private _useLinkProvider: boolean = false\n ) {\n this._options.matchIndex = 1;\n }\n\n public activate(terminal: Terminal): void {\n this._terminal = terminal;\n\n if (this._useLinkProvider && 'registerLinkProvider' in this._terminal) {\n this._linkProvider = this._terminal.registerLinkProvider(new WebLinkProvider(this._terminal, strictUrlRegex, this._handler));\n } else {\n // TODO: This should be removed eventually\n this._linkMatcherId = (this._terminal as Terminal).registerLinkMatcher(strictUrlRegex, this._handler, this._options);\n }\n }\n\n public dispose(): void {\n if (this._linkMatcherId !== undefined && this._terminal !== undefined) {\n this._terminal.deregisterLinkMatcher(this._linkMatcherId);\n }\n\n this._linkProvider?.dispose();\n }\n}\n","/**\n * Copyright (c) 2019 The xterm.js authors. All rights reserved.\n * @license MIT\n */\n\nimport { ILinkProvider, IBufferCellPosition, ILink, Terminal } from 'xterm';\n\nexport class WebLinkProvider implements ILinkProvider {\n\n constructor(\n private readonly _terminal: Terminal,\n private readonly _regex: RegExp,\n private readonly _handler: (event: MouseEvent, uri: string) => void\n ) {\n\n }\n\n public provideLinks(y: number, callback: (links: ILink[] | undefined) => void): void {\n callback(LinkComputer.computeLink(y, this._regex, this._terminal, this._handler));\n }\n}\n\nexport class LinkComputer {\n public static computeLink(y: number, regex: RegExp, terminal: Terminal, handler: (event: MouseEvent, uri: string) => void): ILink[] {\n const rex = new RegExp(regex.source, (regex.flags || '') + 'g');\n\n const [line, startLineIndex] = LinkComputer._translateBufferLineToStringWithWrap(y - 1, false, terminal);\n\n let match;\n let stringIndex = -1;\n const result: ILink[] = [];\n\n while ((match = rex.exec(line)) !== null) {\n const text = match[1];\n if (!text) {\n // something matched but does not comply with the given matchIndex\n // since this is most likely a bug the regex itself we simply do nothing here\n console.log('match found without corresponding matchIndex');\n break;\n }\n\n // Get index, match.index is for the outer match which includes negated chars\n // therefore we cannot use match.index directly, instead we search the position\n // of the match group in text again\n // also correct regex and string search offsets for the next loop run\n stringIndex = line.indexOf(text, stringIndex + 1);\n rex.lastIndex = stringIndex + text.length;\n if (stringIndex < 0) {\n // invalid stringIndex (should not have happened)\n break;\n }\n\n let endX = stringIndex + text.length;\n let endY = startLineIndex + 1;\n\n while (endX > terminal.cols) {\n endX -= terminal.cols;\n endY++;\n }\n\n const range = {\n start: {\n x: stringIndex + 1,\n y: startLineIndex + 1\n },\n end: {\n x: endX,\n y: endY\n }\n };\n\n result.push({ range, text, activate: handler });\n }\n\n return result;\n }\n\n /**\n * Gets the entire line for the buffer line\n * @param line The line being translated.\n * @param trimRight Whether to trim whitespace to the right.\n * @param terminal The terminal\n */\n private static _translateBufferLineToStringWithWrap(lineIndex: number, trimRight: boolean, terminal: Terminal): [string, number] {\n let lineString = '';\n let lineWrapsToNext: boolean;\n let prevLinesToWrap: boolean;\n\n do {\n const line = terminal.buffer.active.getLine(lineIndex);\n if (!line) {\n break;\n }\n\n if (line.isWrapped) {\n lineIndex--;\n }\n\n prevLinesToWrap = line.isWrapped;\n } while (prevLinesToWrap);\n\n const startLineIndex = lineIndex;\n\n do {\n const nextLine = terminal.buffer.active.getLine(lineIndex + 1);\n lineWrapsToNext = nextLine ? nextLine.isWrapped : false;\n const line = terminal.buffer.active.getLine(lineIndex);\n if (!line) {\n break;\n }\n lineString += line.translateToString(!lineWrapsToNext && trimRight).substring(0, terminal.cols);\n lineIndex++;\n } while (lineWrapsToNext);\n\n return [lineString, startLineIndex];\n }\n}\n"],"sourceRoot":""}