@posthog/rrdom 0.0.34 → 0.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/rrdom.js CHANGED
@@ -66,7 +66,7 @@ function getDefaultExportFromCjs(x) {
66
66
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
67
67
  }
68
68
  function getAugmentedNamespace(n) {
69
- if (n.__esModule) return n;
69
+ if (Object.prototype.hasOwnProperty.call(n, "__esModule")) return n;
70
70
  var f2 = n.default;
71
71
  if (typeof f2 == "function") {
72
72
  var a2 = function a3() {
@@ -585,6 +585,9 @@ function requireNode() {
585
585
  return offset;
586
586
  }
587
587
  class Node {
588
+ get proxyOf() {
589
+ return this;
590
+ }
588
591
  constructor(defaults = {}) {
589
592
  this.raws = {};
590
593
  this[isClean] = false;
@@ -703,7 +706,7 @@ function requireNode() {
703
706
  let index = this.parent.index(this);
704
707
  return this.parent.nodes[index + 1];
705
708
  }
706
- positionBy(opts) {
709
+ positionBy(opts = {}) {
707
710
  let pos = this.source.start;
708
711
  if (opts.index) {
709
712
  pos = this.positionInside(opts.index);
@@ -732,27 +735,38 @@ function requireNode() {
732
735
  column += 1;
733
736
  }
734
737
  }
735
- return { column, line };
738
+ return { column, line, offset: end };
736
739
  }
737
740
  prev() {
738
741
  if (!this.parent) return void 0;
739
742
  let index = this.parent.index(this);
740
743
  return this.parent.nodes[index - 1];
741
744
  }
742
- rangeBy(opts) {
745
+ rangeBy(opts = {}) {
746
+ let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
743
747
  let start = {
744
748
  column: this.source.start.column,
745
- line: this.source.start.line
749
+ line: this.source.start.line,
750
+ offset: sourceOffset(inputString, this.source.start)
746
751
  };
747
752
  let end = this.source.end ? {
748
753
  column: this.source.end.column + 1,
749
- line: this.source.end.line
754
+ line: this.source.end.line,
755
+ offset: typeof this.source.end.offset === "number" ? (
756
+ // `source.end.offset` is exclusive, so we don't need to add 1
757
+ this.source.end.offset
758
+ ) : (
759
+ // Since line/column in this.source.end is inclusive,
760
+ // the `sourceOffset(... , this.source.end)` returns an inclusive offset.
761
+ // So, we add 1 to convert it to exclusive.
762
+ sourceOffset(inputString, this.source.end) + 1
763
+ )
750
764
  } : {
751
765
  column: start.column + 1,
752
- line: start.line
766
+ line: start.line,
767
+ offset: start.offset + 1
753
768
  };
754
769
  if (opts.word) {
755
- let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
756
770
  let stringRepresentation = inputString.slice(
757
771
  sourceOffset(inputString, this.source.start),
758
772
  sourceOffset(inputString, this.source.end)
@@ -760,15 +774,14 @@ function requireNode() {
760
774
  let index = stringRepresentation.indexOf(opts.word);
761
775
  if (index !== -1) {
762
776
  start = this.positionInside(index);
763
- end = this.positionInside(
764
- index + opts.word.length
765
- );
777
+ end = this.positionInside(index + opts.word.length);
766
778
  }
767
779
  } else {
768
780
  if (opts.start) {
769
781
  start = {
770
782
  column: opts.start.column,
771
- line: opts.start.line
783
+ line: opts.start.line,
784
+ offset: sourceOffset(inputString, opts.start)
772
785
  };
773
786
  } else if (opts.index) {
774
787
  start = this.positionInside(opts.index);
@@ -776,7 +789,8 @@ function requireNode() {
776
789
  if (opts.end) {
777
790
  end = {
778
791
  column: opts.end.column,
779
- line: opts.end.line
792
+ line: opts.end.line,
793
+ offset: sourceOffset(inputString, opts.end)
780
794
  };
781
795
  } else if (typeof opts.endIndex === "number") {
782
796
  end = this.positionInside(opts.endIndex);
@@ -785,7 +799,11 @@ function requireNode() {
785
799
  }
786
800
  }
787
801
  if (end.line < start.line || end.line === start.line && end.column <= start.column) {
788
- end = { column: start.column + 1, line: start.line };
802
+ end = {
803
+ column: start.column + 1,
804
+ line: start.line,
805
+ offset: start.offset + 1
806
+ };
789
807
  }
790
808
  return { end, start };
791
809
  }
@@ -849,6 +867,7 @@ function requireNode() {
849
867
  } else if (typeof value === "object" && value.toJSON) {
850
868
  fixed[name] = value.toJSON(null, inputs);
851
869
  } else if (name === "source") {
870
+ if (value == null) continue;
852
871
  let inputId = inputs.get(value.input);
853
872
  if (inputId == null) {
854
873
  inputId = inputsNextIndex;
@@ -883,14 +902,11 @@ function requireNode() {
883
902
  });
884
903
  return result2;
885
904
  }
886
- warn(result2, text, opts) {
905
+ warn(result2, text, opts = {}) {
887
906
  let data = { node: this };
888
907
  for (let i in opts) data[i] = opts[i];
889
908
  return result2.warn(text, data);
890
909
  }
891
- get proxyOf() {
892
- return this;
893
- }
894
910
  }
895
911
  node = Node;
896
912
  Node.default = Node;
@@ -919,6 +935,9 @@ function requireDeclaration() {
919
935
  hasRequiredDeclaration = 1;
920
936
  let Node = requireNode();
921
937
  class Declaration extends Node {
938
+ get variable() {
939
+ return this.prop.startsWith("--") || this.prop[0] === "$";
940
+ }
922
941
  constructor(defaults) {
923
942
  if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
924
943
  defaults = { ...defaults, value: String(defaults.value) };
@@ -926,9 +945,6 @@ function requireDeclaration() {
926
945
  super(defaults);
927
946
  this.type = "decl";
928
947
  }
929
- get variable() {
930
- return this.prop.startsWith("--") || this.prop[0] === "$";
931
- }
932
948
  }
933
949
  declaration = Declaration;
934
950
  Declaration.default = Declaration;
@@ -960,6 +976,14 @@ function requireContainer() {
960
976
  }
961
977
  }
962
978
  class Container extends Node {
979
+ get first() {
980
+ if (!this.proxyOf.nodes) return void 0;
981
+ return this.proxyOf.nodes[0];
982
+ }
983
+ get last() {
984
+ if (!this.proxyOf.nodes) return void 0;
985
+ return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
986
+ }
963
987
  append(...children) {
964
988
  for (let child of children) {
965
989
  let nodes = this.normalize(child, this.last);
@@ -1272,14 +1296,6 @@ function requireContainer() {
1272
1296
  }
1273
1297
  });
1274
1298
  }
1275
- get first() {
1276
- if (!this.proxyOf.nodes) return void 0;
1277
- return this.proxyOf.nodes[0];
1278
- }
1279
- get last() {
1280
- if (!this.proxyOf.nodes) return void 0;
1281
- return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
1282
- }
1283
1299
  }
1284
1300
  Container.registerParse = (dependant) => {
1285
1301
  parse = dependant;
@@ -1529,10 +1545,25 @@ function requireInput() {
1529
1545
  let CssSyntaxError = requireCssSyntaxError();
1530
1546
  let PreviousMap = requirePreviousMap();
1531
1547
  let terminalHighlight = require$$2;
1532
- let fromOffsetCache = Symbol("fromOffsetCache");
1548
+ let lineToIndexCache = Symbol("lineToIndexCache");
1533
1549
  let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
1534
1550
  let pathAvailable = Boolean(resolve && isAbsolute);
1551
+ function getLineToIndex(input2) {
1552
+ if (input2[lineToIndexCache]) return input2[lineToIndexCache];
1553
+ let lines = input2.css.split("\n");
1554
+ let lineToIndex = new Array(lines.length);
1555
+ let prevIndex = 0;
1556
+ for (let i = 0, l2 = lines.length; i < l2; i++) {
1557
+ lineToIndex[i] = prevIndex;
1558
+ prevIndex += lines[i].length + 1;
1559
+ }
1560
+ input2[lineToIndexCache] = lineToIndex;
1561
+ return lineToIndex;
1562
+ }
1535
1563
  class Input {
1564
+ get from() {
1565
+ return this.file || this.id;
1566
+ }
1536
1567
  constructor(css, opts = {}) {
1537
1568
  if (css === null || typeof css === "undefined" || typeof css === "object" && !css.toString) {
1538
1569
  throw new Error(`PostCSS received ${css} instead of CSS string`);
@@ -1567,30 +1598,37 @@ function requireInput() {
1567
1598
  if (this.map) this.map.file = this.from;
1568
1599
  }
1569
1600
  error(message, line, column, opts = {}) {
1570
- let endColumn, endLine, result2;
1601
+ let endColumn, endLine, endOffset, offset, result2;
1571
1602
  if (line && typeof line === "object") {
1572
1603
  let start = line;
1573
1604
  let end = column;
1574
1605
  if (typeof start.offset === "number") {
1575
- let pos = this.fromOffset(start.offset);
1606
+ offset = start.offset;
1607
+ let pos = this.fromOffset(offset);
1576
1608
  line = pos.line;
1577
1609
  column = pos.col;
1578
1610
  } else {
1579
1611
  line = start.line;
1580
1612
  column = start.column;
1613
+ offset = this.fromLineAndColumn(line, column);
1581
1614
  }
1582
1615
  if (typeof end.offset === "number") {
1583
- let pos = this.fromOffset(end.offset);
1616
+ endOffset = end.offset;
1617
+ let pos = this.fromOffset(endOffset);
1584
1618
  endLine = pos.line;
1585
1619
  endColumn = pos.col;
1586
1620
  } else {
1587
1621
  endLine = end.line;
1588
1622
  endColumn = end.column;
1623
+ endOffset = this.fromLineAndColumn(end.line, end.column);
1589
1624
  }
1590
1625
  } else if (!column) {
1591
- let pos = this.fromOffset(line);
1626
+ offset = line;
1627
+ let pos = this.fromOffset(offset);
1592
1628
  line = pos.line;
1593
1629
  column = pos.col;
1630
+ } else {
1631
+ offset = this.fromLineAndColumn(line, column);
1594
1632
  }
1595
1633
  let origin = this.origin(line, column, endLine, endColumn);
1596
1634
  if (origin) {
@@ -1612,7 +1650,7 @@ function requireInput() {
1612
1650
  opts.plugin
1613
1651
  );
1614
1652
  }
1615
- result2.input = { column, endColumn, endLine, line, source: this.css };
1653
+ result2.input = { column, endColumn, endLine, endOffset, line, offset, source: this.css };
1616
1654
  if (this.file) {
1617
1655
  if (pathToFileURL) {
1618
1656
  result2.input.url = pathToFileURL(this.file).toString();
@@ -1621,21 +1659,14 @@ function requireInput() {
1621
1659
  }
1622
1660
  return result2;
1623
1661
  }
1662
+ fromLineAndColumn(line, column) {
1663
+ let lineToIndex = getLineToIndex(this);
1664
+ let index = lineToIndex[line - 1];
1665
+ return index + column - 1;
1666
+ }
1624
1667
  fromOffset(offset) {
1625
- let lastLine, lineToIndex;
1626
- if (!this[fromOffsetCache]) {
1627
- let lines = this.css.split("\n");
1628
- lineToIndex = new Array(lines.length);
1629
- let prevIndex = 0;
1630
- for (let i = 0, l2 = lines.length; i < l2; i++) {
1631
- lineToIndex[i] = prevIndex;
1632
- prevIndex += lines[i].length + 1;
1633
- }
1634
- this[fromOffsetCache] = lineToIndex;
1635
- } else {
1636
- lineToIndex = this[fromOffsetCache];
1637
- }
1638
- lastLine = lineToIndex[lineToIndex.length - 1];
1668
+ let lineToIndex = getLineToIndex(this);
1669
+ let lastLine = lineToIndex[lineToIndex.length - 1];
1639
1670
  let min = 0;
1640
1671
  if (offset >= lastLine) {
1641
1672
  min = lineToIndex.length - 1;
@@ -1716,9 +1747,6 @@ function requireInput() {
1716
1747
  }
1717
1748
  return json;
1718
1749
  }
1719
- get from() {
1720
- return this.file || this.id;
1721
- }
1722
1750
  }
1723
1751
  input = Input;
1724
1752
  Input.default = Input;
@@ -1844,11 +1872,6 @@ function requireRule() {
1844
1872
  let Container = requireContainer();
1845
1873
  let list = requireList();
1846
1874
  class Rule extends Container {
1847
- constructor(defaults) {
1848
- super(defaults);
1849
- this.type = "rule";
1850
- if (!this.nodes) this.nodes = [];
1851
- }
1852
1875
  get selectors() {
1853
1876
  return list.comma(this.selector);
1854
1877
  }
@@ -1857,6 +1880,11 @@ function requireRule() {
1857
1880
  let sep = match ? match[0] : "," + this.raw("between", "beforeOpen");
1858
1881
  this.selector = values.join(sep);
1859
1882
  }
1883
+ constructor(defaults) {
1884
+ super(defaults);
1885
+ this.type = "rule";
1886
+ if (!this.nodes) this.nodes = [];
1887
+ }
1860
1888
  }
1861
1889
  rule = Rule;
1862
1890
  Rule.default = Rule;
@@ -2756,6 +2784,8 @@ function requireParser() {
2756
2784
  if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
2757
2785
  prev.raws.ownSemicolon = this.spaces;
2758
2786
  this.spaces = "";
2787
+ prev.source.end = this.getPosition(token[2]);
2788
+ prev.source.end.offset += prev.raws.ownSemicolon.length;
2759
2789
  }
2760
2790
  }
2761
2791
  }
@@ -2967,7 +2997,7 @@ function requireParser() {
2967
2997
  }
2968
2998
  unknownWord(tokens) {
2969
2999
  throw this.input.error(
2970
- "Unknown word",
3000
+ "Unknown word " + tokens[0][1],
2971
3001
  { offset: tokens[0][2] },
2972
3002
  { offset: tokens[0][2] + tokens[0][1].length }
2973
3003
  );
@@ -3060,12 +3090,15 @@ function requireResult() {
3060
3090
  hasRequiredResult = 1;
3061
3091
  let Warning = requireWarning();
3062
3092
  class Result {
3093
+ get content() {
3094
+ return this.css;
3095
+ }
3063
3096
  constructor(processor2, root2, opts) {
3064
3097
  this.processor = processor2;
3065
3098
  this.messages = [];
3066
3099
  this.root = root2;
3067
3100
  this.opts = opts;
3068
- this.css = void 0;
3101
+ this.css = "";
3069
3102
  this.map = void 0;
3070
3103
  }
3071
3104
  toString() {
@@ -3084,9 +3117,6 @@ function requireResult() {
3084
3117
  warnings() {
3085
3118
  return this.messages.filter((i) => i.type === "warning");
3086
3119
  }
3087
- get content() {
3088
- return this.css;
3089
- }
3090
3120
  }
3091
3121
  result = Result;
3092
3122
  Result.default = Result;
@@ -3205,6 +3235,30 @@ function requireLazyResult() {
3205
3235
  }
3206
3236
  let postcss2 = {};
3207
3237
  class LazyResult {
3238
+ get content() {
3239
+ return this.stringify().content;
3240
+ }
3241
+ get css() {
3242
+ return this.stringify().css;
3243
+ }
3244
+ get map() {
3245
+ return this.stringify().map;
3246
+ }
3247
+ get messages() {
3248
+ return this.sync().messages;
3249
+ }
3250
+ get opts() {
3251
+ return this.result.opts;
3252
+ }
3253
+ get processor() {
3254
+ return this.result.processor;
3255
+ }
3256
+ get root() {
3257
+ return this.sync().root;
3258
+ }
3259
+ get [Symbol.toStringTag]() {
3260
+ return "LazyResult";
3261
+ }
3208
3262
  constructor(processor2, css, opts) {
3209
3263
  this.stringified = false;
3210
3264
  this.processed = false;
@@ -3547,30 +3601,6 @@ function requireLazyResult() {
3547
3601
  warnings() {
3548
3602
  return this.sync().warnings();
3549
3603
  }
3550
- get content() {
3551
- return this.stringify().content;
3552
- }
3553
- get css() {
3554
- return this.stringify().css;
3555
- }
3556
- get map() {
3557
- return this.stringify().map;
3558
- }
3559
- get messages() {
3560
- return this.sync().messages;
3561
- }
3562
- get opts() {
3563
- return this.result.opts;
3564
- }
3565
- get processor() {
3566
- return this.result.processor;
3567
- }
3568
- get root() {
3569
- return this.sync().root;
3570
- }
3571
- get [Symbol.toStringTag]() {
3572
- return "LazyResult";
3573
- }
3574
3604
  }
3575
3605
  LazyResult.registerPostcss = (dependant) => {
3576
3606
  postcss2 = dependant;
@@ -3592,6 +3622,45 @@ function requireNoWorkResult() {
3592
3622
  let stringify = requireStringify();
3593
3623
  let warnOnce2 = requireWarnOnce();
3594
3624
  class NoWorkResult {
3625
+ get content() {
3626
+ return this.result.css;
3627
+ }
3628
+ get css() {
3629
+ return this.result.css;
3630
+ }
3631
+ get map() {
3632
+ return this.result.map;
3633
+ }
3634
+ get messages() {
3635
+ return [];
3636
+ }
3637
+ get opts() {
3638
+ return this.result.opts;
3639
+ }
3640
+ get processor() {
3641
+ return this.result.processor;
3642
+ }
3643
+ get root() {
3644
+ if (this._root) {
3645
+ return this._root;
3646
+ }
3647
+ let root2;
3648
+ let parser2 = parse;
3649
+ try {
3650
+ root2 = parser2(this._css, this._opts);
3651
+ } catch (error) {
3652
+ this.error = error;
3653
+ }
3654
+ if (this.error) {
3655
+ throw this.error;
3656
+ } else {
3657
+ this._root = root2;
3658
+ return root2;
3659
+ }
3660
+ }
3661
+ get [Symbol.toStringTag]() {
3662
+ return "NoWorkResult";
3663
+ }
3595
3664
  constructor(processor2, css, opts) {
3596
3665
  css = css.toString();
3597
3666
  this.stringified = false;
@@ -3653,45 +3722,6 @@ function requireNoWorkResult() {
3653
3722
  warnings() {
3654
3723
  return [];
3655
3724
  }
3656
- get content() {
3657
- return this.result.css;
3658
- }
3659
- get css() {
3660
- return this.result.css;
3661
- }
3662
- get map() {
3663
- return this.result.map;
3664
- }
3665
- get messages() {
3666
- return [];
3667
- }
3668
- get opts() {
3669
- return this.result.opts;
3670
- }
3671
- get processor() {
3672
- return this.result.processor;
3673
- }
3674
- get root() {
3675
- if (this._root) {
3676
- return this._root;
3677
- }
3678
- let root2;
3679
- let parser2 = parse;
3680
- try {
3681
- root2 = parser2(this._css, this._opts);
3682
- } catch (error) {
3683
- this.error = error;
3684
- }
3685
- if (this.error) {
3686
- throw this.error;
3687
- } else {
3688
- this._root = root2;
3689
- return root2;
3690
- }
3691
- }
3692
- get [Symbol.toStringTag]() {
3693
- return "NoWorkResult";
3694
- }
3695
3725
  }
3696
3726
  noWorkResult = NoWorkResult;
3697
3727
  NoWorkResult.default = NoWorkResult;
@@ -3708,7 +3738,7 @@ function requireProcessor() {
3708
3738
  let Root = requireRoot();
3709
3739
  class Processor {
3710
3740
  constructor(plugins = []) {
3711
- this.version = "8.5.1";
3741
+ this.version = "8.5.6";
3712
3742
  this.plugins = this.normalize(plugins);
3713
3743
  }
3714
3744
  normalize(plugins) {