node.js 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.default = void 0;
  4. var _cssSyntaxError = _interopRequireDefault(require("./css-syntax-error"));
  5. var _stringifier = _interopRequireDefault(require("./stringifier"));
  6. var _stringify = _interopRequireDefault(require("./stringify"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. function cloneNode(obj, parent) {
  9. var cloned = new obj.constructor();
  10. for (var i in obj) {
  11. if (!obj.hasOwnProperty(i)) continue;
  12. var value = obj[i];
  13. var type = typeof value;
  14. if (i === 'parent' && type === 'object') {
  15. if (parent) cloned[i] = parent;
  16. } else if (i === 'source') {
  17. cloned[i] = value;
  18. } else if (value instanceof Array) {
  19. cloned[i] = value.map(function (j) {
  20. return cloneNode(j, cloned);
  21. });
  22. } else {
  23. if (type === 'object' && value !== null) value = cloneNode(value);
  24. cloned[i] = value;
  25. }
  26. }
  27. return cloned;
  28. }
  29. /**
  30. * All node classes inherit the following common methods.
  31. *
  32. * @abstract
  33. */
  34. var Node = /*#__PURE__*/function () {
  35. /**
  36. * @param {object} [defaults] Value for node properties.
  37. */
  38. function Node(defaults) {
  39. if (defaults === void 0) {
  40. defaults = {};
  41. }
  42. this.raws = {};
  43. if (process.env.NODE_ENV !== 'production') {
  44. if (typeof defaults !== 'object' && typeof defaults !== 'undefined') {
  45. throw new Error('PostCSS nodes constructor accepts object, not ' + JSON.stringify(defaults));
  46. }
  47. }
  48. for (var name in defaults) {
  49. this[name] = defaults[name];
  50. }
  51. }
  52. /**
  53. * Returns a `CssSyntaxError` instance containing the original position
  54. * of the node in the source, showing line and column numbers and also
  55. * a small excerpt to facilitate debugging.
  56. *
  57. * If present, an input source map will be used to get the original position
  58. * of the source, even from a previous compilation step
  59. * (e.g., from Sass compilation).
  60. *
  61. * This method produces very useful error messages.
  62. *
  63. * @param {string} message Error description.
  64. * @param {object} [opts] Options.
  65. * @param {string} opts.plugin Plugin name that created this error.
  66. * PostCSS will set it automatically.
  67. * @param {string} opts.word A word inside a node’s string that should
  68. * be highlighted as the source of the error.
  69. * @param {number} opts.index An index inside a node’s string that should
  70. * be highlighted as the source of the error.
  71. *
  72. * @return {CssSyntaxError} Error object to throw it.
  73. *
  74. * @example
  75. * if (!variables[name]) {
  76. * throw decl.error('Unknown variable ' + name, { word: name })
  77. * // CssSyntaxError: postcss-vars:a.sass:4:3: Unknown variable $black
  78. * // color: $black
  79. * // a
  80. * // ^
  81. * // background: white
  82. * }
  83. */
  84. var _proto = Node.prototype;
  85. _proto.error = function error(message, opts) {
  86. if (opts === void 0) {
  87. opts = {};
  88. }
  89. if (this.source) {
  90. var pos = this.positionBy(opts);
  91. return this.source.input.error(message, pos.line, pos.column, opts);
  92. }
  93. return new _cssSyntaxError.default(message);
  94. }
  95. /**
  96. * This method is provided as a convenience wrapper for {@link Result#warn}.
  97. *
  98. * @param {Result} result The {@link Result} instance
  99. * that will receive the warning.
  100. * @param {string} text Warning message.
  101. * @param {object} [opts] Options
  102. * @param {string} opts.plugin Plugin name that created this warning.
  103. * PostCSS will set it automatically.
  104. * @param {string} opts.word A word inside a node’s string that should
  105. * be highlighted as the source of the warning.
  106. * @param {number} opts.index An index inside a node’s string that should
  107. * be highlighted as the source of the warning.
  108. *
  109. * @return {Warning} Created warning object.
  110. *
  111. * @example
  112. * const plugin = postcss.plugin('postcss-deprecated', () => {
  113. * return (root, result) => {
  114. * root.walkDecls('bad', decl => {
  115. * decl.warn(result, 'Deprecated property bad')
  116. * })
  117. * }
  118. * })
  119. */
  120. ;
  121. _proto.warn = function warn(result, text, opts) {
  122. var data = {
  123. node: this
  124. };
  125. for (var i in opts) {
  126. data[i] = opts[i];
  127. }
  128. return result.warn(text, data);
  129. }
  130. /**
  131. * Removes the node from its parent and cleans the parent properties
  132. * from the node and its children.
  133. *
  134. * @example
  135. * if (decl.prop.match(/^-webkit-/)) {
  136. * decl.remove()
  137. * }
  138. *
  139. * @return {Node} Node to make calls chain.
  140. */
  141. ;
  142. _proto.remove = function remove() {
  143. if (this.parent) {
  144. this.parent.removeChild(this);
  145. }
  146. this.parent = undefined;
  147. return this;
  148. }
  149. /**
  150. * Returns a CSS string representing the node.
  151. *
  152. * @param {stringifier|syntax} [stringifier] A syntax to use
  153. * in string generation.
  154. *
  155. * @return {string} CSS string of this node.
  156. *
  157. * @example
  158. * postcss.rule({ selector: 'a' }).toString() //=> "a {}"
  159. */
  160. ;
  161. _proto.toString = function toString(stringifier) {
  162. if (stringifier === void 0) {
  163. stringifier = _stringify.default;
  164. }
  165. if (stringifier.stringify) stringifier = stringifier.stringify;
  166. var result = '';
  167. stringifier(this, function (i) {
  168. result += i;
  169. });
  170. return result;
  171. }
  172. /**
  173. * Returns an exact clone of the node.
  174. *
  175. * The resulting cloned node and its (cloned) children will retain
  176. * code style properties.
  177. *
  178. * @param {object} [overrides] New properties to override in the clone.
  179. *
  180. * @example
  181. * decl.raws.before //=> "\n "
  182. * const cloned = decl.clone({ prop: '-moz-' + decl.prop })
  183. * cloned.raws.before //=> "\n "
  184. * cloned.toString() //=> -moz-transform: scale(0)
  185. *
  186. * @return {Node} Clone of the node.
  187. */
  188. ;
  189. _proto.clone = function clone(overrides) {
  190. if (overrides === void 0) {
  191. overrides = {};
  192. }
  193. var cloned = cloneNode(this);
  194. for (var name in overrides) {
  195. cloned[name] = overrides[name];
  196. }
  197. return cloned;
  198. }
  199. /**
  200. * Shortcut to clone the node and insert the resulting cloned node
  201. * before the current node.
  202. *
  203. * @param {object} [overrides] Mew properties to override in the clone.
  204. *
  205. * @example
  206. * decl.cloneBefore({ prop: '-moz-' + decl.prop })
  207. *
  208. * @return {Node} New node
  209. */
  210. ;
  211. _proto.cloneBefore = function cloneBefore(overrides) {
  212. if (overrides === void 0) {
  213. overrides = {};
  214. }
  215. var cloned = this.clone(overrides);
  216. this.parent.insertBefore(this, cloned);
  217. return cloned;
  218. }
  219. /**
  220. * Shortcut to clone the node and insert the resulting cloned node
  221. * after the current node.
  222. *
  223. * @param {object} [overrides] New properties to override in the clone.
  224. *
  225. * @return {Node} New node.
  226. */
  227. ;
  228. _proto.cloneAfter = function cloneAfter(overrides) {
  229. if (overrides === void 0) {
  230. overrides = {};
  231. }
  232. var cloned = this.clone(overrides);
  233. this.parent.insertAfter(this, cloned);
  234. return cloned;
  235. }
  236. /**
  237. * Inserts node(s) before the current node and removes the current node.
  238. *
  239. * @param {...Node} nodes Mode(s) to replace current one.
  240. *
  241. * @example
  242. * if (atrule.name === 'mixin') {
  243. * atrule.replaceWith(mixinRules[atrule.params])
  244. * }
  245. *
  246. * @return {Node} Current node to methods chain.
  247. */
  248. ;
  249. _proto.replaceWith = function replaceWith() {
  250. if (this.parent) {
  251. for (var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++) {
  252. nodes[_key] = arguments[_key];
  253. }
  254. for (var _i = 0, _nodes = nodes; _i < _nodes.length; _i++) {
  255. var node = _nodes[_i];
  256. this.parent.insertBefore(this, node);
  257. }
  258. this.remove();
  259. }
  260. return this;
  261. }
  262. /**
  263. * Returns the next child of the node’s parent.
  264. * Returns `undefined` if the current node is the last child.
  265. *
  266. * @return {Node|undefined} Next node.
  267. *
  268. * @example
  269. * if (comment.text === 'delete next') {
  270. * const next = comment.next()
  271. * if (next) {
  272. * next.remove()
  273. * }
  274. * }
  275. */
  276. ;
  277. _proto.next = function next() {
  278. if (!this.parent) return undefined;
  279. var index = this.parent.index(this);
  280. return this.parent.nodes[index + 1];
  281. }
  282. /**
  283. * Returns the previous child of the node’s parent.
  284. * Returns `undefined` if the current node is the first child.
  285. *
  286. * @return {Node|undefined} Previous node.
  287. *
  288. * @example
  289. * const annotation = decl.prev()
  290. * if (annotation.type === 'comment') {
  291. * readAnnotation(annotation.text)
  292. * }
  293. */
  294. ;
  295. _proto.prev = function prev() {
  296. if (!this.parent) return undefined;
  297. var index = this.parent.index(this);
  298. return this.parent.nodes[index - 1];
  299. }
  300. /**
  301. * Insert new node before current node to current node’s parent.
  302. *
  303. * Just alias for `node.parent.insertBefore(node, add)`.
  304. *
  305. * @param {Node|object|string|Node[]} add New node.
  306. *
  307. * @return {Node} This node for methods chain.
  308. *
  309. * @example
  310. * decl.before('content: ""')
  311. */
  312. ;
  313. _proto.before = function before(add) {
  314. this.parent.insertBefore(this, add);
  315. return this;
  316. }
  317. /**
  318. * Insert new node after current node to current node’s parent.
  319. *
  320. * Just alias for `node.parent.insertAfter(node, add)`.
  321. *
  322. * @param {Node|object|string|Node[]} add New node.
  323. *
  324. * @return {Node} This node for methods chain.
  325. *
  326. * @example
  327. * decl.after('color: black')
  328. */
  329. ;
  330. _proto.after = function after(add) {
  331. this.parent.insertAfter(this, add);
  332. return this;
  333. };
  334. _proto.toJSON = function toJSON() {
  335. var fixed = {};
  336. for (var name in this) {
  337. if (!this.hasOwnProperty(name)) continue;
  338. if (name === 'parent') continue;
  339. var value = this[name];
  340. if (value instanceof Array) {
  341. fixed[name] = value.map(function (i) {
  342. if (typeof i === 'object' && i.toJSON) {
  343. return i.toJSON();
  344. } else {
  345. return i;
  346. }
  347. });
  348. } else if (typeof value === 'object' && value.toJSON) {
  349. fixed[name] = value.toJSON();
  350. } else {
  351. fixed[name] = value;
  352. }
  353. }
  354. return fixed;
  355. }
  356. /**
  357. * Returns a {@link Node#raws} value. If the node is missing
  358. * the code style property (because the node was manually built or cloned),
  359. * PostCSS will try to autodetect the code style property by looking
  360. * at other nodes in the tree.
  361. *
  362. * @param {string} prop Name of code style property.
  363. * @param {string} [defaultType] Name of default value, it can be missed
  364. * if the value is the same as prop.
  365. *
  366. * @example
  367. * const root = postcss.parse('a { background: white }')
  368. * root.nodes[0].append({ prop: 'color', value: 'black' })
  369. * root.nodes[0].nodes[1].raws.before //=> undefined
  370. * root.nodes[0].nodes[1].raw('before') //=> ' '
  371. *
  372. * @return {string} Code style value.
  373. */
  374. ;
  375. _proto.raw = function raw(prop, defaultType) {
  376. var str = new _stringifier.default();
  377. return str.raw(this, prop, defaultType);
  378. }
  379. /**
  380. * Finds the Root instance of the node’s tree.
  381. *
  382. * @example
  383. * root.nodes[0].nodes[0].root() === root
  384. *
  385. * @return {Root} Root parent.
  386. */
  387. ;
  388. _proto.root = function root() {
  389. var result = this;
  390. while (result.parent) {
  391. result = result.parent;
  392. }
  393. return result;
  394. }
  395. /**
  396. * Clear the code style properties for the node and its children.
  397. *
  398. * @param {boolean} [keepBetween] Keep the raws.between symbols.
  399. *
  400. * @return {undefined}
  401. *
  402. * @example
  403. * node.raws.before //=> ' '
  404. * node.cleanRaws()
  405. * node.raws.before //=> undefined
  406. */
  407. ;
  408. _proto.cleanRaws = function cleanRaws(keepBetween) {
  409. delete this.raws.before;
  410. delete this.raws.after;
  411. if (!keepBetween) delete this.raws.between;
  412. };
  413. _proto.positionInside = function positionInside(index) {
  414. var string = this.toString();
  415. var column = this.source.start.column;
  416. var line = this.source.start.line;
  417. for (var i = 0; i < index; i++) {
  418. if (string[i] === '\n') {
  419. column = 1;
  420. line += 1;
  421. } else {
  422. column += 1;
  423. }
  424. }
  425. return {
  426. line: line,
  427. column: column
  428. };
  429. };
  430. _proto.positionBy = function positionBy(opts) {
  431. var pos = this.source.start;
  432. if (opts.index) {
  433. pos = this.positionInside(opts.index);
  434. } else if (opts.word) {
  435. var index = this.toString().indexOf(opts.word);
  436. if (index !== -1) pos = this.positionInside(index);
  437. }
  438. return pos;
  439. }
  440. /**
  441. * @memberof Node#
  442. * @member {string} type String representing the node’s type.
  443. * Possible values are `root`, `atrule`, `rule`,
  444. * `decl`, or `comment`.
  445. *
  446. * @example
  447. * postcss.decl({ prop: 'color', value: 'black' }).type //=> 'decl'
  448. */
  449. /**
  450. * @memberof Node#
  451. * @member {Container} parent The node’s parent node.
  452. *
  453. * @example
  454. * root.nodes[0].parent === root
  455. */
  456. /**
  457. * @memberof Node#
  458. * @member {source} source The input source of the node.
  459. *
  460. * The property is used in source map generation.
  461. *
  462. * If you create a node manually (e.g., with `postcss.decl()`),
  463. * that node will not have a `source` property and will be absent
  464. * from the source map. For this reason, the plugin developer should
  465. * consider cloning nodes to create new ones (in which case the new node’s
  466. * source will reference the original, cloned node) or setting
  467. * the `source` property manually.
  468. *
  469. * ```js
  470. * // Bad
  471. * const prefixed = postcss.decl({
  472. * prop: '-moz-' + decl.prop,
  473. * value: decl.value
  474. * })
  475. *
  476. * // Good
  477. * const prefixed = decl.clone({ prop: '-moz-' + decl.prop })
  478. * ```
  479. *
  480. * ```js
  481. * if (atrule.name === 'add-link') {
  482. * const rule = postcss.rule({ selector: 'a', source: atrule.source })
  483. * atrule.parent.insertBefore(atrule, rule)
  484. * }
  485. * ```
  486. *
  487. * @example
  488. * decl.source.input.from //=> '/home/ai/a.sass'
  489. * decl.source.start //=> { line: 10, column: 2 }
  490. * decl.source.end //=> { line: 10, column: 12 }
  491. */
  492. /**
  493. * @memberof Node#
  494. * @member {object} raws Information to generate byte-to-byte equal
  495. * node string as it was in the origin input.
  496. *
  497. * Every parser saves its own properties,
  498. * but the default CSS parser uses:
  499. *
  500. * * `before`: the space symbols before the node. It also stores `*`
  501. * and `_` symbols before the declaration (IE hack).
  502. * * `after`: the space symbols after the last child of the node
  503. * to the end of the node.
  504. * * `between`: the symbols between the property and value
  505. * for declarations, selector and `{` for rules, or last parameter
  506. * and `{` for at-rules.
  507. * * `semicolon`: contains true if the last child has
  508. * an (optional) semicolon.
  509. * * `afterName`: the space between the at-rule name and its parameters.
  510. * * `left`: the space symbols between `/*` and the comment’s text.
  511. * * `right`: the space symbols between the comment’s text
  512. * and <code>*&#47;</code>.
  513. * * `important`: the content of the important statement,
  514. * if it is not just `!important`.
  515. *
  516. * PostCSS cleans selectors, declaration values and at-rule parameters
  517. * from comments and extra spaces, but it stores origin content in raws
  518. * properties. As such, if you don’t change a declaration’s value,
  519. * PostCSS will use the raw value with comments.
  520. *
  521. * @example
  522. * const root = postcss.parse('a {\n color:black\n}')
  523. * root.first.first.raws //=> { before: '\n ', between: ':' }
  524. */
  525. ;
  526. return Node;
  527. }();
  528. var _default = Node;
  529. /**
  530. * @typedef {object} position
  531. * @property {number} line Source line in file.
  532. * @property {number} column Source column in file.
  533. */
  534. /**
  535. * @typedef {object} source
  536. * @property {Input} input {@link Input} with input file
  537. * @property {position} start The starting position of the node’s source.
  538. * @property {position} end The ending position of the node’s source.
  539. */
  540. exports.default = _default;
  541. module.exports = exports.default;
  542. //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGUuZXM2Il0sIm5hbWVzIjpbImNsb25lTm9kZSIsIm9iaiIsInBhcmVudCIsImNsb25lZCIsImNvbnN0cnVjdG9yIiwiaSIsImhhc093blByb3BlcnR5IiwidmFsdWUiLCJ0eXBlIiwiQXJyYXkiLCJtYXAiLCJqIiwiTm9kZSIsImRlZmF1bHRzIiwicmF3cyIsInByb2Nlc3MiLCJlbnYiLCJOT0RFX0VOViIsIkVycm9yIiwiSlNPTiIsIn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