@posthog/rrweb-snapshot 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.
package/dist/replay.cjs CHANGED
@@ -39,7 +39,7 @@ function getDefaultExportFromCjs(x) {
39
39
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
40
40
  }
41
41
  function getAugmentedNamespace(n) {
42
- if (n.__esModule) return n;
42
+ if (Object.prototype.hasOwnProperty.call(n, "__esModule")) return n;
43
43
  var f = n.default;
44
44
  if (typeof f == "function") {
45
45
  var a = function a2() {
@@ -558,6 +558,9 @@ function requireNode() {
558
558
  return offset;
559
559
  }
560
560
  class Node {
561
+ get proxyOf() {
562
+ return this;
563
+ }
561
564
  constructor(defaults = {}) {
562
565
  this.raws = {};
563
566
  this[isClean] = false;
@@ -676,7 +679,7 @@ function requireNode() {
676
679
  let index = this.parent.index(this);
677
680
  return this.parent.nodes[index + 1];
678
681
  }
679
- positionBy(opts) {
682
+ positionBy(opts = {}) {
680
683
  let pos = this.source.start;
681
684
  if (opts.index) {
682
685
  pos = this.positionInside(opts.index);
@@ -705,27 +708,38 @@ function requireNode() {
705
708
  column += 1;
706
709
  }
707
710
  }
708
- return { column, line };
711
+ return { column, line, offset: end };
709
712
  }
710
713
  prev() {
711
714
  if (!this.parent) return void 0;
712
715
  let index = this.parent.index(this);
713
716
  return this.parent.nodes[index - 1];
714
717
  }
715
- rangeBy(opts) {
718
+ rangeBy(opts = {}) {
719
+ let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
716
720
  let start = {
717
721
  column: this.source.start.column,
718
- line: this.source.start.line
722
+ line: this.source.start.line,
723
+ offset: sourceOffset(inputString, this.source.start)
719
724
  };
720
725
  let end = this.source.end ? {
721
726
  column: this.source.end.column + 1,
722
- line: this.source.end.line
727
+ line: this.source.end.line,
728
+ offset: typeof this.source.end.offset === "number" ? (
729
+ // `source.end.offset` is exclusive, so we don't need to add 1
730
+ this.source.end.offset
731
+ ) : (
732
+ // Since line/column in this.source.end is inclusive,
733
+ // the `sourceOffset(... , this.source.end)` returns an inclusive offset.
734
+ // So, we add 1 to convert it to exclusive.
735
+ sourceOffset(inputString, this.source.end) + 1
736
+ )
723
737
  } : {
724
738
  column: start.column + 1,
725
- line: start.line
739
+ line: start.line,
740
+ offset: start.offset + 1
726
741
  };
727
742
  if (opts.word) {
728
- let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
729
743
  let stringRepresentation = inputString.slice(
730
744
  sourceOffset(inputString, this.source.start),
731
745
  sourceOffset(inputString, this.source.end)
@@ -733,15 +747,14 @@ function requireNode() {
733
747
  let index = stringRepresentation.indexOf(opts.word);
734
748
  if (index !== -1) {
735
749
  start = this.positionInside(index);
736
- end = this.positionInside(
737
- index + opts.word.length
738
- );
750
+ end = this.positionInside(index + opts.word.length);
739
751
  }
740
752
  } else {
741
753
  if (opts.start) {
742
754
  start = {
743
755
  column: opts.start.column,
744
- line: opts.start.line
756
+ line: opts.start.line,
757
+ offset: sourceOffset(inputString, opts.start)
745
758
  };
746
759
  } else if (opts.index) {
747
760
  start = this.positionInside(opts.index);
@@ -749,7 +762,8 @@ function requireNode() {
749
762
  if (opts.end) {
750
763
  end = {
751
764
  column: opts.end.column,
752
- line: opts.end.line
765
+ line: opts.end.line,
766
+ offset: sourceOffset(inputString, opts.end)
753
767
  };
754
768
  } else if (typeof opts.endIndex === "number") {
755
769
  end = this.positionInside(opts.endIndex);
@@ -758,7 +772,11 @@ function requireNode() {
758
772
  }
759
773
  }
760
774
  if (end.line < start.line || end.line === start.line && end.column <= start.column) {
761
- end = { column: start.column + 1, line: start.line };
775
+ end = {
776
+ column: start.column + 1,
777
+ line: start.line,
778
+ offset: start.offset + 1
779
+ };
762
780
  }
763
781
  return { end, start };
764
782
  }
@@ -822,6 +840,7 @@ function requireNode() {
822
840
  } else if (typeof value === "object" && value.toJSON) {
823
841
  fixed[name] = value.toJSON(null, inputs);
824
842
  } else if (name === "source") {
843
+ if (value == null) continue;
825
844
  let inputId = inputs.get(value.input);
826
845
  if (inputId == null) {
827
846
  inputId = inputsNextIndex;
@@ -856,14 +875,11 @@ function requireNode() {
856
875
  });
857
876
  return result2;
858
877
  }
859
- warn(result2, text, opts) {
878
+ warn(result2, text, opts = {}) {
860
879
  let data = { node: this };
861
880
  for (let i in opts) data[i] = opts[i];
862
881
  return result2.warn(text, data);
863
882
  }
864
- get proxyOf() {
865
- return this;
866
- }
867
883
  }
868
884
  node = Node;
869
885
  Node.default = Node;
@@ -892,6 +908,9 @@ function requireDeclaration() {
892
908
  hasRequiredDeclaration = 1;
893
909
  let Node = requireNode();
894
910
  class Declaration extends Node {
911
+ get variable() {
912
+ return this.prop.startsWith("--") || this.prop[0] === "$";
913
+ }
895
914
  constructor(defaults) {
896
915
  if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
897
916
  defaults = { ...defaults, value: String(defaults.value) };
@@ -899,9 +918,6 @@ function requireDeclaration() {
899
918
  super(defaults);
900
919
  this.type = "decl";
901
920
  }
902
- get variable() {
903
- return this.prop.startsWith("--") || this.prop[0] === "$";
904
- }
905
921
  }
906
922
  declaration = Declaration;
907
923
  Declaration.default = Declaration;
@@ -933,6 +949,14 @@ function requireContainer() {
933
949
  }
934
950
  }
935
951
  class Container extends Node {
952
+ get first() {
953
+ if (!this.proxyOf.nodes) return void 0;
954
+ return this.proxyOf.nodes[0];
955
+ }
956
+ get last() {
957
+ if (!this.proxyOf.nodes) return void 0;
958
+ return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
959
+ }
936
960
  append(...children) {
937
961
  for (let child of children) {
938
962
  let nodes = this.normalize(child, this.last);
@@ -1245,14 +1269,6 @@ function requireContainer() {
1245
1269
  }
1246
1270
  });
1247
1271
  }
1248
- get first() {
1249
- if (!this.proxyOf.nodes) return void 0;
1250
- return this.proxyOf.nodes[0];
1251
- }
1252
- get last() {
1253
- if (!this.proxyOf.nodes) return void 0;
1254
- return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
1255
- }
1256
1272
  }
1257
1273
  Container.registerParse = (dependant) => {
1258
1274
  parse = dependant;
@@ -1502,10 +1518,25 @@ function requireInput() {
1502
1518
  let CssSyntaxError = requireCssSyntaxError();
1503
1519
  let PreviousMap = requirePreviousMap();
1504
1520
  let terminalHighlight = require$$2;
1505
- let fromOffsetCache = Symbol("fromOffsetCache");
1521
+ let lineToIndexCache = Symbol("lineToIndexCache");
1506
1522
  let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
1507
1523
  let pathAvailable = Boolean(resolve && isAbsolute);
1524
+ function getLineToIndex(input2) {
1525
+ if (input2[lineToIndexCache]) return input2[lineToIndexCache];
1526
+ let lines = input2.css.split("\n");
1527
+ let lineToIndex = new Array(lines.length);
1528
+ let prevIndex = 0;
1529
+ for (let i = 0, l = lines.length; i < l; i++) {
1530
+ lineToIndex[i] = prevIndex;
1531
+ prevIndex += lines[i].length + 1;
1532
+ }
1533
+ input2[lineToIndexCache] = lineToIndex;
1534
+ return lineToIndex;
1535
+ }
1508
1536
  class Input {
1537
+ get from() {
1538
+ return this.file || this.id;
1539
+ }
1509
1540
  constructor(css, opts = {}) {
1510
1541
  if (css === null || typeof css === "undefined" || typeof css === "object" && !css.toString) {
1511
1542
  throw new Error(`PostCSS received ${css} instead of CSS string`);
@@ -1540,30 +1571,37 @@ function requireInput() {
1540
1571
  if (this.map) this.map.file = this.from;
1541
1572
  }
1542
1573
  error(message, line, column, opts = {}) {
1543
- let endColumn, endLine, result2;
1574
+ let endColumn, endLine, endOffset, offset, result2;
1544
1575
  if (line && typeof line === "object") {
1545
1576
  let start = line;
1546
1577
  let end = column;
1547
1578
  if (typeof start.offset === "number") {
1548
- let pos = this.fromOffset(start.offset);
1579
+ offset = start.offset;
1580
+ let pos = this.fromOffset(offset);
1549
1581
  line = pos.line;
1550
1582
  column = pos.col;
1551
1583
  } else {
1552
1584
  line = start.line;
1553
1585
  column = start.column;
1586
+ offset = this.fromLineAndColumn(line, column);
1554
1587
  }
1555
1588
  if (typeof end.offset === "number") {
1556
- let pos = this.fromOffset(end.offset);
1589
+ endOffset = end.offset;
1590
+ let pos = this.fromOffset(endOffset);
1557
1591
  endLine = pos.line;
1558
1592
  endColumn = pos.col;
1559
1593
  } else {
1560
1594
  endLine = end.line;
1561
1595
  endColumn = end.column;
1596
+ endOffset = this.fromLineAndColumn(end.line, end.column);
1562
1597
  }
1563
1598
  } else if (!column) {
1564
- let pos = this.fromOffset(line);
1599
+ offset = line;
1600
+ let pos = this.fromOffset(offset);
1565
1601
  line = pos.line;
1566
1602
  column = pos.col;
1603
+ } else {
1604
+ offset = this.fromLineAndColumn(line, column);
1567
1605
  }
1568
1606
  let origin = this.origin(line, column, endLine, endColumn);
1569
1607
  if (origin) {
@@ -1585,7 +1623,7 @@ function requireInput() {
1585
1623
  opts.plugin
1586
1624
  );
1587
1625
  }
1588
- result2.input = { column, endColumn, endLine, line, source: this.css };
1626
+ result2.input = { column, endColumn, endLine, endOffset, line, offset, source: this.css };
1589
1627
  if (this.file) {
1590
1628
  if (pathToFileURL) {
1591
1629
  result2.input.url = pathToFileURL(this.file).toString();
@@ -1594,21 +1632,14 @@ function requireInput() {
1594
1632
  }
1595
1633
  return result2;
1596
1634
  }
1635
+ fromLineAndColumn(line, column) {
1636
+ let lineToIndex = getLineToIndex(this);
1637
+ let index = lineToIndex[line - 1];
1638
+ return index + column - 1;
1639
+ }
1597
1640
  fromOffset(offset) {
1598
- let lastLine, lineToIndex;
1599
- if (!this[fromOffsetCache]) {
1600
- let lines = this.css.split("\n");
1601
- lineToIndex = new Array(lines.length);
1602
- let prevIndex = 0;
1603
- for (let i = 0, l = lines.length; i < l; i++) {
1604
- lineToIndex[i] = prevIndex;
1605
- prevIndex += lines[i].length + 1;
1606
- }
1607
- this[fromOffsetCache] = lineToIndex;
1608
- } else {
1609
- lineToIndex = this[fromOffsetCache];
1610
- }
1611
- lastLine = lineToIndex[lineToIndex.length - 1];
1641
+ let lineToIndex = getLineToIndex(this);
1642
+ let lastLine = lineToIndex[lineToIndex.length - 1];
1612
1643
  let min = 0;
1613
1644
  if (offset >= lastLine) {
1614
1645
  min = lineToIndex.length - 1;
@@ -1689,9 +1720,6 @@ function requireInput() {
1689
1720
  }
1690
1721
  return json;
1691
1722
  }
1692
- get from() {
1693
- return this.file || this.id;
1694
- }
1695
1723
  }
1696
1724
  input = Input;
1697
1725
  Input.default = Input;
@@ -1817,11 +1845,6 @@ function requireRule() {
1817
1845
  let Container = requireContainer();
1818
1846
  let list = requireList();
1819
1847
  class Rule extends Container {
1820
- constructor(defaults) {
1821
- super(defaults);
1822
- this.type = "rule";
1823
- if (!this.nodes) this.nodes = [];
1824
- }
1825
1848
  get selectors() {
1826
1849
  return list.comma(this.selector);
1827
1850
  }
@@ -1830,6 +1853,11 @@ function requireRule() {
1830
1853
  let sep = match ? match[0] : "," + this.raw("between", "beforeOpen");
1831
1854
  this.selector = values.join(sep);
1832
1855
  }
1856
+ constructor(defaults) {
1857
+ super(defaults);
1858
+ this.type = "rule";
1859
+ if (!this.nodes) this.nodes = [];
1860
+ }
1833
1861
  }
1834
1862
  rule = Rule;
1835
1863
  Rule.default = Rule;
@@ -2729,6 +2757,8 @@ function requireParser() {
2729
2757
  if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
2730
2758
  prev.raws.ownSemicolon = this.spaces;
2731
2759
  this.spaces = "";
2760
+ prev.source.end = this.getPosition(token[2]);
2761
+ prev.source.end.offset += prev.raws.ownSemicolon.length;
2732
2762
  }
2733
2763
  }
2734
2764
  }
@@ -2940,7 +2970,7 @@ function requireParser() {
2940
2970
  }
2941
2971
  unknownWord(tokens) {
2942
2972
  throw this.input.error(
2943
- "Unknown word",
2973
+ "Unknown word " + tokens[0][1],
2944
2974
  { offset: tokens[0][2] },
2945
2975
  { offset: tokens[0][2] + tokens[0][1].length }
2946
2976
  );
@@ -3033,12 +3063,15 @@ function requireResult() {
3033
3063
  hasRequiredResult = 1;
3034
3064
  let Warning = requireWarning();
3035
3065
  class Result {
3066
+ get content() {
3067
+ return this.css;
3068
+ }
3036
3069
  constructor(processor2, root2, opts) {
3037
3070
  this.processor = processor2;
3038
3071
  this.messages = [];
3039
3072
  this.root = root2;
3040
3073
  this.opts = opts;
3041
- this.css = void 0;
3074
+ this.css = "";
3042
3075
  this.map = void 0;
3043
3076
  }
3044
3077
  toString() {
@@ -3057,9 +3090,6 @@ function requireResult() {
3057
3090
  warnings() {
3058
3091
  return this.messages.filter((i) => i.type === "warning");
3059
3092
  }
3060
- get content() {
3061
- return this.css;
3062
- }
3063
3093
  }
3064
3094
  result = Result;
3065
3095
  Result.default = Result;
@@ -3178,6 +3208,30 @@ function requireLazyResult() {
3178
3208
  }
3179
3209
  let postcss2 = {};
3180
3210
  class LazyResult {
3211
+ get content() {
3212
+ return this.stringify().content;
3213
+ }
3214
+ get css() {
3215
+ return this.stringify().css;
3216
+ }
3217
+ get map() {
3218
+ return this.stringify().map;
3219
+ }
3220
+ get messages() {
3221
+ return this.sync().messages;
3222
+ }
3223
+ get opts() {
3224
+ return this.result.opts;
3225
+ }
3226
+ get processor() {
3227
+ return this.result.processor;
3228
+ }
3229
+ get root() {
3230
+ return this.sync().root;
3231
+ }
3232
+ get [Symbol.toStringTag]() {
3233
+ return "LazyResult";
3234
+ }
3181
3235
  constructor(processor2, css, opts) {
3182
3236
  this.stringified = false;
3183
3237
  this.processed = false;
@@ -3520,30 +3574,6 @@ function requireLazyResult() {
3520
3574
  warnings() {
3521
3575
  return this.sync().warnings();
3522
3576
  }
3523
- get content() {
3524
- return this.stringify().content;
3525
- }
3526
- get css() {
3527
- return this.stringify().css;
3528
- }
3529
- get map() {
3530
- return this.stringify().map;
3531
- }
3532
- get messages() {
3533
- return this.sync().messages;
3534
- }
3535
- get opts() {
3536
- return this.result.opts;
3537
- }
3538
- get processor() {
3539
- return this.result.processor;
3540
- }
3541
- get root() {
3542
- return this.sync().root;
3543
- }
3544
- get [Symbol.toStringTag]() {
3545
- return "LazyResult";
3546
- }
3547
3577
  }
3548
3578
  LazyResult.registerPostcss = (dependant) => {
3549
3579
  postcss2 = dependant;
@@ -3565,6 +3595,45 @@ function requireNoWorkResult() {
3565
3595
  let stringify = requireStringify();
3566
3596
  let warnOnce2 = requireWarnOnce();
3567
3597
  class NoWorkResult {
3598
+ get content() {
3599
+ return this.result.css;
3600
+ }
3601
+ get css() {
3602
+ return this.result.css;
3603
+ }
3604
+ get map() {
3605
+ return this.result.map;
3606
+ }
3607
+ get messages() {
3608
+ return [];
3609
+ }
3610
+ get opts() {
3611
+ return this.result.opts;
3612
+ }
3613
+ get processor() {
3614
+ return this.result.processor;
3615
+ }
3616
+ get root() {
3617
+ if (this._root) {
3618
+ return this._root;
3619
+ }
3620
+ let root2;
3621
+ let parser2 = parse;
3622
+ try {
3623
+ root2 = parser2(this._css, this._opts);
3624
+ } catch (error) {
3625
+ this.error = error;
3626
+ }
3627
+ if (this.error) {
3628
+ throw this.error;
3629
+ } else {
3630
+ this._root = root2;
3631
+ return root2;
3632
+ }
3633
+ }
3634
+ get [Symbol.toStringTag]() {
3635
+ return "NoWorkResult";
3636
+ }
3568
3637
  constructor(processor2, css, opts) {
3569
3638
  css = css.toString();
3570
3639
  this.stringified = false;
@@ -3626,45 +3695,6 @@ function requireNoWorkResult() {
3626
3695
  warnings() {
3627
3696
  return [];
3628
3697
  }
3629
- get content() {
3630
- return this.result.css;
3631
- }
3632
- get css() {
3633
- return this.result.css;
3634
- }
3635
- get map() {
3636
- return this.result.map;
3637
- }
3638
- get messages() {
3639
- return [];
3640
- }
3641
- get opts() {
3642
- return this.result.opts;
3643
- }
3644
- get processor() {
3645
- return this.result.processor;
3646
- }
3647
- get root() {
3648
- if (this._root) {
3649
- return this._root;
3650
- }
3651
- let root2;
3652
- let parser2 = parse;
3653
- try {
3654
- root2 = parser2(this._css, this._opts);
3655
- } catch (error) {
3656
- this.error = error;
3657
- }
3658
- if (this.error) {
3659
- throw this.error;
3660
- } else {
3661
- this._root = root2;
3662
- return root2;
3663
- }
3664
- }
3665
- get [Symbol.toStringTag]() {
3666
- return "NoWorkResult";
3667
- }
3668
3698
  }
3669
3699
  noWorkResult = NoWorkResult;
3670
3700
  NoWorkResult.default = NoWorkResult;
@@ -3681,7 +3711,7 @@ function requireProcessor() {
3681
3711
  let Root = requireRoot();
3682
3712
  class Processor {
3683
3713
  constructor(plugins = []) {
3684
- this.version = "8.5.1";
3714
+ this.version = "8.5.6";
3685
3715
  this.plugins = this.normalize(plugins);
3686
3716
  }
3687
3717
  normalize(plugins) {