@posthog/rrdom 0.0.34 → 0.0.36

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.
@@ -1,16 +1,4 @@
1
- (function (g, f) {
2
- if ("object" == typeof exports && "object" == typeof module) {
3
- module.exports = f();
4
- } else if ("function" == typeof define && define.amd) {
5
- define("rrdom", [], f);
6
- } else if ("object" == typeof exports) {
7
- exports["rrdom"] = f();
8
- } else {
9
- g["rrdom"] = f();
10
- }
11
- }(this, () => {
12
- var exports = {};
13
- var module = { exports };
1
+ (function (g, f) {if ("object" == typeof exports && "object" == typeof module) {module.exports = f();} else if ("function" == typeof define && define.amd) {define("rrdom", [], f);} else if ("object" == typeof exports) {exports["rrdom"] = f();} else {g["rrdom"] = f();}}(typeof self !== 'undefined' ? self : typeof globalThis !== 'undefined' ? globalThis : this, () => {var exports = {};var module = { exports };
14
2
  "use strict";
15
3
  var __defProp = Object.defineProperty;
16
4
  var __defProps = Object.defineProperties;
@@ -112,7 +100,7 @@ function getDefaultExportFromCjs(x) {
112
100
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
113
101
  }
114
102
  function getAugmentedNamespace(n) {
115
- if (n.__esModule) return n;
103
+ if (Object.prototype.hasOwnProperty.call(n, "__esModule")) return n;
116
104
  var f2 = n.default;
117
105
  if (typeof f2 == "function") {
118
106
  var a2 = function a3() {
@@ -631,6 +619,9 @@ function requireNode() {
631
619
  return offset;
632
620
  }
633
621
  class Node {
622
+ get proxyOf() {
623
+ return this;
624
+ }
634
625
  constructor(defaults = {}) {
635
626
  this.raws = {};
636
627
  this[isClean] = false;
@@ -749,7 +740,7 @@ function requireNode() {
749
740
  let index = this.parent.index(this);
750
741
  return this.parent.nodes[index + 1];
751
742
  }
752
- positionBy(opts) {
743
+ positionBy(opts = {}) {
753
744
  let pos = this.source.start;
754
745
  if (opts.index) {
755
746
  pos = this.positionInside(opts.index);
@@ -778,27 +769,38 @@ function requireNode() {
778
769
  column += 1;
779
770
  }
780
771
  }
781
- return { column, line };
772
+ return { column, line, offset: end };
782
773
  }
783
774
  prev() {
784
775
  if (!this.parent) return void 0;
785
776
  let index = this.parent.index(this);
786
777
  return this.parent.nodes[index - 1];
787
778
  }
788
- rangeBy(opts) {
779
+ rangeBy(opts = {}) {
780
+ let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
789
781
  let start = {
790
782
  column: this.source.start.column,
791
- line: this.source.start.line
783
+ line: this.source.start.line,
784
+ offset: sourceOffset(inputString, this.source.start)
792
785
  };
793
786
  let end = this.source.end ? {
794
787
  column: this.source.end.column + 1,
795
- line: this.source.end.line
788
+ line: this.source.end.line,
789
+ offset: typeof this.source.end.offset === "number" ? (
790
+ // `source.end.offset` is exclusive, so we don't need to add 1
791
+ this.source.end.offset
792
+ ) : (
793
+ // Since line/column in this.source.end is inclusive,
794
+ // the `sourceOffset(... , this.source.end)` returns an inclusive offset.
795
+ // So, we add 1 to convert it to exclusive.
796
+ sourceOffset(inputString, this.source.end) + 1
797
+ )
796
798
  } : {
797
799
  column: start.column + 1,
798
- line: start.line
800
+ line: start.line,
801
+ offset: start.offset + 1
799
802
  };
800
803
  if (opts.word) {
801
- let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
802
804
  let stringRepresentation = inputString.slice(
803
805
  sourceOffset(inputString, this.source.start),
804
806
  sourceOffset(inputString, this.source.end)
@@ -806,15 +808,14 @@ function requireNode() {
806
808
  let index = stringRepresentation.indexOf(opts.word);
807
809
  if (index !== -1) {
808
810
  start = this.positionInside(index);
809
- end = this.positionInside(
810
- index + opts.word.length
811
- );
811
+ end = this.positionInside(index + opts.word.length);
812
812
  }
813
813
  } else {
814
814
  if (opts.start) {
815
815
  start = {
816
816
  column: opts.start.column,
817
- line: opts.start.line
817
+ line: opts.start.line,
818
+ offset: sourceOffset(inputString, opts.start)
818
819
  };
819
820
  } else if (opts.index) {
820
821
  start = this.positionInside(opts.index);
@@ -822,7 +823,8 @@ function requireNode() {
822
823
  if (opts.end) {
823
824
  end = {
824
825
  column: opts.end.column,
825
- line: opts.end.line
826
+ line: opts.end.line,
827
+ offset: sourceOffset(inputString, opts.end)
826
828
  };
827
829
  } else if (typeof opts.endIndex === "number") {
828
830
  end = this.positionInside(opts.endIndex);
@@ -831,7 +833,11 @@ function requireNode() {
831
833
  }
832
834
  }
833
835
  if (end.line < start.line || end.line === start.line && end.column <= start.column) {
834
- end = { column: start.column + 1, line: start.line };
836
+ end = {
837
+ column: start.column + 1,
838
+ line: start.line,
839
+ offset: start.offset + 1
840
+ };
835
841
  }
836
842
  return { end, start };
837
843
  }
@@ -895,6 +901,7 @@ function requireNode() {
895
901
  } else if (typeof value === "object" && value.toJSON) {
896
902
  fixed[name] = value.toJSON(null, inputs);
897
903
  } else if (name === "source") {
904
+ if (value == null) continue;
898
905
  let inputId = inputs.get(value.input);
899
906
  if (inputId == null) {
900
907
  inputId = inputsNextIndex;
@@ -929,14 +936,11 @@ function requireNode() {
929
936
  });
930
937
  return result2;
931
938
  }
932
- warn(result2, text, opts) {
939
+ warn(result2, text, opts = {}) {
933
940
  let data = { node: this };
934
941
  for (let i in opts) data[i] = opts[i];
935
942
  return result2.warn(text, data);
936
943
  }
937
- get proxyOf() {
938
- return this;
939
- }
940
944
  }
941
945
  node = Node;
942
946
  Node.default = Node;
@@ -965,6 +969,9 @@ function requireDeclaration() {
965
969
  hasRequiredDeclaration = 1;
966
970
  let Node = requireNode();
967
971
  class Declaration extends Node {
972
+ get variable() {
973
+ return this.prop.startsWith("--") || this.prop[0] === "$";
974
+ }
968
975
  constructor(defaults) {
969
976
  if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
970
977
  defaults = __spreadProps(__spreadValues({}, defaults), { value: String(defaults.value) });
@@ -972,9 +979,6 @@ function requireDeclaration() {
972
979
  super(defaults);
973
980
  this.type = "decl";
974
981
  }
975
- get variable() {
976
- return this.prop.startsWith("--") || this.prop[0] === "$";
977
- }
978
982
  }
979
983
  declaration = Declaration;
980
984
  Declaration.default = Declaration;
@@ -1006,6 +1010,14 @@ function requireContainer() {
1006
1010
  }
1007
1011
  }
1008
1012
  class Container extends Node {
1013
+ get first() {
1014
+ if (!this.proxyOf.nodes) return void 0;
1015
+ return this.proxyOf.nodes[0];
1016
+ }
1017
+ get last() {
1018
+ if (!this.proxyOf.nodes) return void 0;
1019
+ return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
1020
+ }
1009
1021
  append(...children) {
1010
1022
  for (let child of children) {
1011
1023
  let nodes = this.normalize(child, this.last);
@@ -1318,14 +1330,6 @@ function requireContainer() {
1318
1330
  }
1319
1331
  });
1320
1332
  }
1321
- get first() {
1322
- if (!this.proxyOf.nodes) return void 0;
1323
- return this.proxyOf.nodes[0];
1324
- }
1325
- get last() {
1326
- if (!this.proxyOf.nodes) return void 0;
1327
- return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
1328
- }
1329
1333
  }
1330
1334
  Container.registerParse = (dependant) => {
1331
1335
  parse = dependant;
@@ -1575,10 +1579,25 @@ function requireInput() {
1575
1579
  let CssSyntaxError = requireCssSyntaxError();
1576
1580
  let PreviousMap = requirePreviousMap();
1577
1581
  let terminalHighlight = require$$2;
1578
- let fromOffsetCache = Symbol("fromOffsetCache");
1582
+ let lineToIndexCache = Symbol("lineToIndexCache");
1579
1583
  let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
1580
1584
  let pathAvailable = Boolean(resolve && isAbsolute);
1585
+ function getLineToIndex(input2) {
1586
+ if (input2[lineToIndexCache]) return input2[lineToIndexCache];
1587
+ let lines = input2.css.split("\n");
1588
+ let lineToIndex = new Array(lines.length);
1589
+ let prevIndex = 0;
1590
+ for (let i = 0, l2 = lines.length; i < l2; i++) {
1591
+ lineToIndex[i] = prevIndex;
1592
+ prevIndex += lines[i].length + 1;
1593
+ }
1594
+ input2[lineToIndexCache] = lineToIndex;
1595
+ return lineToIndex;
1596
+ }
1581
1597
  class Input {
1598
+ get from() {
1599
+ return this.file || this.id;
1600
+ }
1582
1601
  constructor(css, opts = {}) {
1583
1602
  if (css === null || typeof css === "undefined" || typeof css === "object" && !css.toString) {
1584
1603
  throw new Error(`PostCSS received ${css} instead of CSS string`);
@@ -1613,30 +1632,37 @@ function requireInput() {
1613
1632
  if (this.map) this.map.file = this.from;
1614
1633
  }
1615
1634
  error(message, line, column, opts = {}) {
1616
- let endColumn, endLine, result2;
1635
+ let endColumn, endLine, endOffset, offset, result2;
1617
1636
  if (line && typeof line === "object") {
1618
1637
  let start = line;
1619
1638
  let end = column;
1620
1639
  if (typeof start.offset === "number") {
1621
- let pos = this.fromOffset(start.offset);
1640
+ offset = start.offset;
1641
+ let pos = this.fromOffset(offset);
1622
1642
  line = pos.line;
1623
1643
  column = pos.col;
1624
1644
  } else {
1625
1645
  line = start.line;
1626
1646
  column = start.column;
1647
+ offset = this.fromLineAndColumn(line, column);
1627
1648
  }
1628
1649
  if (typeof end.offset === "number") {
1629
- let pos = this.fromOffset(end.offset);
1650
+ endOffset = end.offset;
1651
+ let pos = this.fromOffset(endOffset);
1630
1652
  endLine = pos.line;
1631
1653
  endColumn = pos.col;
1632
1654
  } else {
1633
1655
  endLine = end.line;
1634
1656
  endColumn = end.column;
1657
+ endOffset = this.fromLineAndColumn(end.line, end.column);
1635
1658
  }
1636
1659
  } else if (!column) {
1637
- let pos = this.fromOffset(line);
1660
+ offset = line;
1661
+ let pos = this.fromOffset(offset);
1638
1662
  line = pos.line;
1639
1663
  column = pos.col;
1664
+ } else {
1665
+ offset = this.fromLineAndColumn(line, column);
1640
1666
  }
1641
1667
  let origin = this.origin(line, column, endLine, endColumn);
1642
1668
  if (origin) {
@@ -1658,7 +1684,7 @@ function requireInput() {
1658
1684
  opts.plugin
1659
1685
  );
1660
1686
  }
1661
- result2.input = { column, endColumn, endLine, line, source: this.css };
1687
+ result2.input = { column, endColumn, endLine, endOffset, line, offset, source: this.css };
1662
1688
  if (this.file) {
1663
1689
  if (pathToFileURL) {
1664
1690
  result2.input.url = pathToFileURL(this.file).toString();
@@ -1667,21 +1693,14 @@ function requireInput() {
1667
1693
  }
1668
1694
  return result2;
1669
1695
  }
1696
+ fromLineAndColumn(line, column) {
1697
+ let lineToIndex = getLineToIndex(this);
1698
+ let index = lineToIndex[line - 1];
1699
+ return index + column - 1;
1700
+ }
1670
1701
  fromOffset(offset) {
1671
- let lastLine, lineToIndex;
1672
- if (!this[fromOffsetCache]) {
1673
- let lines = this.css.split("\n");
1674
- lineToIndex = new Array(lines.length);
1675
- let prevIndex = 0;
1676
- for (let i = 0, l2 = lines.length; i < l2; i++) {
1677
- lineToIndex[i] = prevIndex;
1678
- prevIndex += lines[i].length + 1;
1679
- }
1680
- this[fromOffsetCache] = lineToIndex;
1681
- } else {
1682
- lineToIndex = this[fromOffsetCache];
1683
- }
1684
- lastLine = lineToIndex[lineToIndex.length - 1];
1702
+ let lineToIndex = getLineToIndex(this);
1703
+ let lastLine = lineToIndex[lineToIndex.length - 1];
1685
1704
  let min = 0;
1686
1705
  if (offset >= lastLine) {
1687
1706
  min = lineToIndex.length - 1;
@@ -1762,9 +1781,6 @@ function requireInput() {
1762
1781
  }
1763
1782
  return json;
1764
1783
  }
1765
- get from() {
1766
- return this.file || this.id;
1767
- }
1768
1784
  }
1769
1785
  input = Input;
1770
1786
  Input.default = Input;
@@ -1890,11 +1906,6 @@ function requireRule() {
1890
1906
  let Container = requireContainer();
1891
1907
  let list = requireList();
1892
1908
  class Rule extends Container {
1893
- constructor(defaults) {
1894
- super(defaults);
1895
- this.type = "rule";
1896
- if (!this.nodes) this.nodes = [];
1897
- }
1898
1909
  get selectors() {
1899
1910
  return list.comma(this.selector);
1900
1911
  }
@@ -1903,6 +1914,11 @@ function requireRule() {
1903
1914
  let sep = match ? match[0] : "," + this.raw("between", "beforeOpen");
1904
1915
  this.selector = values.join(sep);
1905
1916
  }
1917
+ constructor(defaults) {
1918
+ super(defaults);
1919
+ this.type = "rule";
1920
+ if (!this.nodes) this.nodes = [];
1921
+ }
1906
1922
  }
1907
1923
  rule = Rule;
1908
1924
  Rule.default = Rule;
@@ -2801,6 +2817,8 @@ function requireParser() {
2801
2817
  if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
2802
2818
  prev.raws.ownSemicolon = this.spaces;
2803
2819
  this.spaces = "";
2820
+ prev.source.end = this.getPosition(token[2]);
2821
+ prev.source.end.offset += prev.raws.ownSemicolon.length;
2804
2822
  }
2805
2823
  }
2806
2824
  }
@@ -3012,7 +3030,7 @@ function requireParser() {
3012
3030
  }
3013
3031
  unknownWord(tokens) {
3014
3032
  throw this.input.error(
3015
- "Unknown word",
3033
+ "Unknown word " + tokens[0][1],
3016
3034
  { offset: tokens[0][2] },
3017
3035
  { offset: tokens[0][2] + tokens[0][1].length }
3018
3036
  );
@@ -3105,12 +3123,15 @@ function requireResult() {
3105
3123
  hasRequiredResult = 1;
3106
3124
  let Warning = requireWarning();
3107
3125
  class Result {
3126
+ get content() {
3127
+ return this.css;
3128
+ }
3108
3129
  constructor(processor2, root2, opts) {
3109
3130
  this.processor = processor2;
3110
3131
  this.messages = [];
3111
3132
  this.root = root2;
3112
3133
  this.opts = opts;
3113
- this.css = void 0;
3134
+ this.css = "";
3114
3135
  this.map = void 0;
3115
3136
  }
3116
3137
  toString() {
@@ -3129,9 +3150,6 @@ function requireResult() {
3129
3150
  warnings() {
3130
3151
  return this.messages.filter((i) => i.type === "warning");
3131
3152
  }
3132
- get content() {
3133
- return this.css;
3134
- }
3135
3153
  }
3136
3154
  result = Result;
3137
3155
  Result.default = Result;
@@ -3250,6 +3268,30 @@ function requireLazyResult() {
3250
3268
  }
3251
3269
  let postcss2 = {};
3252
3270
  class LazyResult {
3271
+ get content() {
3272
+ return this.stringify().content;
3273
+ }
3274
+ get css() {
3275
+ return this.stringify().css;
3276
+ }
3277
+ get map() {
3278
+ return this.stringify().map;
3279
+ }
3280
+ get messages() {
3281
+ return this.sync().messages;
3282
+ }
3283
+ get opts() {
3284
+ return this.result.opts;
3285
+ }
3286
+ get processor() {
3287
+ return this.result.processor;
3288
+ }
3289
+ get root() {
3290
+ return this.sync().root;
3291
+ }
3292
+ get [Symbol.toStringTag]() {
3293
+ return "LazyResult";
3294
+ }
3253
3295
  constructor(processor2, css, opts) {
3254
3296
  this.stringified = false;
3255
3297
  this.processed = false;
@@ -3592,30 +3634,6 @@ function requireLazyResult() {
3592
3634
  warnings() {
3593
3635
  return this.sync().warnings();
3594
3636
  }
3595
- get content() {
3596
- return this.stringify().content;
3597
- }
3598
- get css() {
3599
- return this.stringify().css;
3600
- }
3601
- get map() {
3602
- return this.stringify().map;
3603
- }
3604
- get messages() {
3605
- return this.sync().messages;
3606
- }
3607
- get opts() {
3608
- return this.result.opts;
3609
- }
3610
- get processor() {
3611
- return this.result.processor;
3612
- }
3613
- get root() {
3614
- return this.sync().root;
3615
- }
3616
- get [Symbol.toStringTag]() {
3617
- return "LazyResult";
3618
- }
3619
3637
  }
3620
3638
  LazyResult.registerPostcss = (dependant) => {
3621
3639
  postcss2 = dependant;
@@ -3637,6 +3655,45 @@ function requireNoWorkResult() {
3637
3655
  let stringify = requireStringify();
3638
3656
  let warnOnce2 = requireWarnOnce();
3639
3657
  class NoWorkResult {
3658
+ get content() {
3659
+ return this.result.css;
3660
+ }
3661
+ get css() {
3662
+ return this.result.css;
3663
+ }
3664
+ get map() {
3665
+ return this.result.map;
3666
+ }
3667
+ get messages() {
3668
+ return [];
3669
+ }
3670
+ get opts() {
3671
+ return this.result.opts;
3672
+ }
3673
+ get processor() {
3674
+ return this.result.processor;
3675
+ }
3676
+ get root() {
3677
+ if (this._root) {
3678
+ return this._root;
3679
+ }
3680
+ let root2;
3681
+ let parser2 = parse;
3682
+ try {
3683
+ root2 = parser2(this._css, this._opts);
3684
+ } catch (error) {
3685
+ this.error = error;
3686
+ }
3687
+ if (this.error) {
3688
+ throw this.error;
3689
+ } else {
3690
+ this._root = root2;
3691
+ return root2;
3692
+ }
3693
+ }
3694
+ get [Symbol.toStringTag]() {
3695
+ return "NoWorkResult";
3696
+ }
3640
3697
  constructor(processor2, css, opts) {
3641
3698
  css = css.toString();
3642
3699
  this.stringified = false;
@@ -3698,45 +3755,6 @@ function requireNoWorkResult() {
3698
3755
  warnings() {
3699
3756
  return [];
3700
3757
  }
3701
- get content() {
3702
- return this.result.css;
3703
- }
3704
- get css() {
3705
- return this.result.css;
3706
- }
3707
- get map() {
3708
- return this.result.map;
3709
- }
3710
- get messages() {
3711
- return [];
3712
- }
3713
- get opts() {
3714
- return this.result.opts;
3715
- }
3716
- get processor() {
3717
- return this.result.processor;
3718
- }
3719
- get root() {
3720
- if (this._root) {
3721
- return this._root;
3722
- }
3723
- let root2;
3724
- let parser2 = parse;
3725
- try {
3726
- root2 = parser2(this._css, this._opts);
3727
- } catch (error) {
3728
- this.error = error;
3729
- }
3730
- if (this.error) {
3731
- throw this.error;
3732
- } else {
3733
- this._root = root2;
3734
- return root2;
3735
- }
3736
- }
3737
- get [Symbol.toStringTag]() {
3738
- return "NoWorkResult";
3739
- }
3740
3758
  }
3741
3759
  noWorkResult = NoWorkResult;
3742
3760
  NoWorkResult.default = NoWorkResult;
@@ -3753,7 +3771,7 @@ function requireProcessor() {
3753
3771
  let Root = requireRoot();
3754
3772
  class Processor {
3755
3773
  constructor(plugins = []) {
3756
- this.version = "8.5.1";
3774
+ this.version = "8.5.6";
3757
3775
  this.plugins = this.normalize(plugins);
3758
3776
  }
3759
3777
  normalize(plugins) {
@@ -4722,7 +4740,6 @@ function diffAfterUpdatingChildren(oldTree, newTree, replayer) {
4722
4740
  );
4723
4741
  break;
4724
4742
  }
4725
- // Props of style elements have to be updated after all children are updated. Otherwise the props can be overwritten by textContent.
4726
4743
  case "STYLE": {
4727
4744
  const styleSheet = oldElement.sheet;
4728
4745
  styleSheet && newTree.rules.forEach(
@@ -5149,7 +5166,6 @@ function buildFromNode(node2, rrdom, domMirror, parentRRNode) {
5149
5166
  case NodeType.COMMENT_NODE:
5150
5167
  rrNode = rrdom.createComment(node2.textContent || "");
5151
5168
  break;
5152
- // if node is a shadow root
5153
5169
  case NodeType.DOCUMENT_FRAGMENT_NODE:
5154
5170
  rrNode = parentRRNode.attachShadow({ mode: "open" });
5155
5171
  break;
@@ -5346,7 +5362,7 @@ exports.createOrGetNode = createOrGetNode;
5346
5362
  exports.diff = diff;
5347
5363
  exports.getDefaultSN = getDefaultSN;
5348
5364
  exports.printRRDom = printRRDom;
5349
- if (typeof module.exports == "object" && typeof exports == "object") {
5365
+ ;if (typeof module.exports == "object" && typeof exports == "object") {
5350
5366
  var __cp = (to, from, except, desc) => {
5351
5367
  if ((from && typeof from === "object") || typeof from === "function") {
5352
5368
  for (let key of Object.getOwnPropertyNames(from)) {