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