1 |
- {"version":3,"sources":["align.js"],"names":["__rest","s","e","t","p","Object","prototype","hasOwnProperty","call","indexOf","getOwnPropertySymbols","i","length","propertyIsEnumerable","defineProperty","exports","value","primitives_1","require","util_1","zeroWidth","start","tag","type","name","getWidth","w","tokens","delimiter","Markers","Math","max","space","len","padStart","align","intoTags","update","line","assign","isEmpty","description","end","delim","postDelimiter","nothingAfter","postName","postType","postTag","_a","source","fields","reduce","rewireSource","map","default"],"mappings":"AAAA;;AACA,IAAIA,MAAM,GAAI,QAAQ,KAAKA,MAAd,IAAyB,UAAUC,CAAV,EAAaC,CAAb,EAAgB;AAClD,MAAIC,CAAC,GAAG,EAAR;;AACA,OAAK,IAAIC,CAAT,IAAcH,CAAd,EAAiB,IAAII,MAAM,CAACC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCP,CAArC,EAAwCG,CAAxC,KAA8CF,CAAC,CAACO,OAAF,CAAUL,CAAV,IAAe,CAAjE,EACbD,CAAC,CAACC,CAAD,CAAD,GAAOH,CAAC,CAACG,CAAD,CAAR;;AACJ,MAAIH,CAAC,IAAI,IAAL,IAAa,OAAOI,MAAM,CAACK,qBAAd,KAAwC,UAAzD,EACI,KAAK,IAAIC,CAAC,GAAG,CAAR,EAAWP,CAAC,GAAGC,MAAM,CAACK,qBAAP,CAA6BT,CAA7B,CAApB,EAAqDU,CAAC,GAAGP,CAAC,CAACQ,MAA3D,EAAmED,CAAC,EAApE,EAAwE;AACpE,QAAIT,CAAC,CAACO,OAAF,CAAUL,CAAC,CAACO,CAAD,CAAX,IAAkB,CAAlB,IAAuBN,MAAM,CAACC,SAAP,CAAiBO,oBAAjB,CAAsCL,IAAtC,CAA2CP,CAA3C,EAA8CG,CAAC,CAACO,CAAD,CAA/C,CAA3B,EACIR,CAAC,CAACC,CAAC,CAACO,CAAD,CAAF,CAAD,GAAUV,CAAC,CAACG,CAAC,CAACO,CAAD,CAAF,CAAX;AACP;AACL,SAAOR,CAAP;AACH,CAVD;;AAWA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AYX,MAArB,GAA8B,CAA/B,CAAvB;AACJ,QAAI,CAACiC,YAAY,CAACrB,IAAlB,EACIG,MAAM,CAACmB,QAAP,GAAkBd,KAAK,CAACN,CAAC,CAACF,IAAF,GAASG,MAAM,CAACH,IAAP,CAAYZ,MAArB,GAA8B,CAA/B,CAAvB;AACJ,WAAOP,MAAM,CAACkC,MAAP,CAAclC,MAAM,CAACkC,MAAP,CAAc,EAAd,EAAkBD,IAAlB,CAAd,EAAuC;AAAEX,MAAAA;AAAF,KAAvC,CAAP;AACH;;AACD,SAAQsB,EAAD,IAAQ;AACX,QAAI;AAAEC,MAAAA;AAAF,QAAaD,EAAjB;AAAA,QAAqBE,MAAM,GAAGnD,MAAM,CAACiD,EAAD,EAAK,CAAC,QAAD,CAAL,CAApC;;AACAvB,IAAAA,CAAC,GAAGwB,MAAM,CAACE,MAAP,CAAc3B,QAAd,EAAwBpB,MAAM,CAACkC,MAAP,CAAc,EAAd,EAAkBnB,SAAlB,CAAxB,CAAJ;AACA,WAAOD,MAAM,CAACkC,YAAP,CAAoBhD,MAAM,CAACkC,MAAP,CAAclC,MAAM,CAACkC,MAAP,CAAc,EAAd,EAAkBY,MAAlB,CAAd,EAAyC;AAAED,MAAAA,MAAM,EAAEA,MAAM,CAACI,GAAP,CAAWjB,MAAX;AAAV,KAAzC,CAApB,CAAP;AACH,GAJD;AAKH;;AACDtB,OAAO,CAACwC,OAAR,GAAkBpB,KAAlB","sourcesContent":["\"use strict\";\nvar __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nconst primitives_1 = require(\"../primitives\");\nconst util_1 = require(\"../util\");\nconst zeroWidth = {\n start: 0,\n tag: 0,\n type: 0,\n name: 0,\n};\nconst getWidth = (w, { tokens: t }) => ({\n start: t.delimiter === primitives_1.Markers.start ? t.start.length : w.start,\n tag: Math.max(w.tag, t.tag.length),\n type: Math.max(w.type, t.type.length),\n name: Math.max(w.name, t.name.length),\n});\nconst space = (len) => ''.padStart(len, ' ');\nfunction align() {\n let intoTags = false;\n let w;\n function update(line) {\n const tokens = Object.assign({}, line.tokens);\n if (tokens.tag !== '')\n intoTags = true;\n const isEmpty = tokens.tag === '' &&\n tokens.name === '' &&\n tokens.type === '' &&\n tokens.description === '';\n // dangling '*/'\n if (tokens.end === primitives_1.Markers.end && isEmpty) {\n tokens.start = space(w.start + 1);\n return Object.assign(Object.assign({}, line), { tokens });\n }\n switch (tokens.delimiter) {\n case primitives_1.Markers.start:\n tokens.start = space(w.start);\n break;\n case primitives_1.Markers.delim:\n tokens.start = space(w.start + 1);\n break;\n default:\n tokens.delimiter = '';\n tokens.start = space(w.start + 2); // compensate delimiter\n }\n if (!intoTags) {\n tokens.postDelimiter = tokens.description === '' ? '' : ' ';\n return Object.assign(Object.assign({}, line), { tokens });\n }\n const nothingAfter = {\n delim: false,\n tag: false,\n type: false,\n name: false,\n };\n if (tokens.description === '') {\n nothingAfter.name = true;\n tokens.postName = '';\n if (tokens.name === '') {\n nothingAfter.type = true;\n tokens.postType = '';\n if (tokens.type === '') {\n nothingAfter.tag = true;\n tokens.postTag = '';\n if (tokens.tag === '') {\n nothingAfter.delim = true;\n }\n }\n }\n }\n tokens.postDelimiter = nothingAfter.delim ? '' : ' ';\n if (!nothingAfter.tag)\n tokens.postTag = space(w.tag - tokens.tag.length + 1);\n if (!nothingAfter.type)\n tokens.postType = space(w.type - tokens.type.length + 1);\n if (!nothingAfter.name)\n tokens.postName = space(w.name - tokens.name.length + 1);\n return Object.assign(Object.assign({}, line), { tokens });\n }\n return (_a) => {\n var { source } = _a, fields = __rest(_a, [\"source\"]);\n w = source.reduce(getWidth, Object.assign({}, zeroWidth));\n return util_1.rewireSource(Object.assign(Object.assign({}, fields), { source: source.map(update) }));\n };\n}\nexports.default = align;\n"],"file":"align.cjs"}
|