@posthog/rrweb-snapshot 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.
@@ -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("rrwebSnapshot", [], f);
6
- } else if ("object" == typeof exports) {
7
- exports["rrwebSnapshot"] = f();
8
- } else {
9
- g["rrwebSnapshot"] = 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("rrwebSnapshot", [], f);} else if ("object" == typeof exports) {exports["rrwebSnapshot"] = f();} else {g["rrwebSnapshot"] = 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;
@@ -1620,7 +1608,7 @@ var require_replay = __commonJS({
1620
1608
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1621
1609
  }
1622
1610
  function getAugmentedNamespace(n) {
1623
- if (n.__esModule) return n;
1611
+ if (Object.prototype.hasOwnProperty.call(n, "__esModule")) return n;
1624
1612
  var f = n.default;
1625
1613
  if (typeof f == "function") {
1626
1614
  var a = function a2() {
@@ -2139,6 +2127,9 @@ var require_replay = __commonJS({
2139
2127
  return offset;
2140
2128
  }
2141
2129
  class Node {
2130
+ get proxyOf() {
2131
+ return this;
2132
+ }
2142
2133
  constructor(defaults = {}) {
2143
2134
  this.raws = {};
2144
2135
  this[isClean] = false;
@@ -2257,7 +2248,7 @@ var require_replay = __commonJS({
2257
2248
  let index = this.parent.index(this);
2258
2249
  return this.parent.nodes[index + 1];
2259
2250
  }
2260
- positionBy(opts) {
2251
+ positionBy(opts = {}) {
2261
2252
  let pos = this.source.start;
2262
2253
  if (opts.index) {
2263
2254
  pos = this.positionInside(opts.index);
@@ -2286,27 +2277,38 @@ var require_replay = __commonJS({
2286
2277
  column += 1;
2287
2278
  }
2288
2279
  }
2289
- return { column, line };
2280
+ return { column, line, offset: end };
2290
2281
  }
2291
2282
  prev() {
2292
2283
  if (!this.parent) return void 0;
2293
2284
  let index = this.parent.index(this);
2294
2285
  return this.parent.nodes[index - 1];
2295
2286
  }
2296
- rangeBy(opts) {
2287
+ rangeBy(opts = {}) {
2288
+ let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
2297
2289
  let start = {
2298
2290
  column: this.source.start.column,
2299
- line: this.source.start.line
2291
+ line: this.source.start.line,
2292
+ offset: sourceOffset(inputString, this.source.start)
2300
2293
  };
2301
2294
  let end = this.source.end ? {
2302
2295
  column: this.source.end.column + 1,
2303
- line: this.source.end.line
2296
+ line: this.source.end.line,
2297
+ offset: typeof this.source.end.offset === "number" ? (
2298
+ // `source.end.offset` is exclusive, so we don't need to add 1
2299
+ this.source.end.offset
2300
+ ) : (
2301
+ // Since line/column in this.source.end is inclusive,
2302
+ // the `sourceOffset(... , this.source.end)` returns an inclusive offset.
2303
+ // So, we add 1 to convert it to exclusive.
2304
+ sourceOffset(inputString, this.source.end) + 1
2305
+ )
2304
2306
  } : {
2305
2307
  column: start.column + 1,
2306
- line: start.line
2308
+ line: start.line,
2309
+ offset: start.offset + 1
2307
2310
  };
2308
2311
  if (opts.word) {
2309
- let inputString = "document" in this.source.input ? this.source.input.document : this.source.input.css;
2310
2312
  let stringRepresentation = inputString.slice(
2311
2313
  sourceOffset(inputString, this.source.start),
2312
2314
  sourceOffset(inputString, this.source.end)
@@ -2314,15 +2316,14 @@ var require_replay = __commonJS({
2314
2316
  let index = stringRepresentation.indexOf(opts.word);
2315
2317
  if (index !== -1) {
2316
2318
  start = this.positionInside(index);
2317
- end = this.positionInside(
2318
- index + opts.word.length
2319
- );
2319
+ end = this.positionInside(index + opts.word.length);
2320
2320
  }
2321
2321
  } else {
2322
2322
  if (opts.start) {
2323
2323
  start = {
2324
2324
  column: opts.start.column,
2325
- line: opts.start.line
2325
+ line: opts.start.line,
2326
+ offset: sourceOffset(inputString, opts.start)
2326
2327
  };
2327
2328
  } else if (opts.index) {
2328
2329
  start = this.positionInside(opts.index);
@@ -2330,7 +2331,8 @@ var require_replay = __commonJS({
2330
2331
  if (opts.end) {
2331
2332
  end = {
2332
2333
  column: opts.end.column,
2333
- line: opts.end.line
2334
+ line: opts.end.line,
2335
+ offset: sourceOffset(inputString, opts.end)
2334
2336
  };
2335
2337
  } else if (typeof opts.endIndex === "number") {
2336
2338
  end = this.positionInside(opts.endIndex);
@@ -2339,7 +2341,11 @@ var require_replay = __commonJS({
2339
2341
  }
2340
2342
  }
2341
2343
  if (end.line < start.line || end.line === start.line && end.column <= start.column) {
2342
- end = { column: start.column + 1, line: start.line };
2344
+ end = {
2345
+ column: start.column + 1,
2346
+ line: start.line,
2347
+ offset: start.offset + 1
2348
+ };
2343
2349
  }
2344
2350
  return { end, start };
2345
2351
  }
@@ -2403,6 +2409,7 @@ var require_replay = __commonJS({
2403
2409
  } else if (typeof value === "object" && value.toJSON) {
2404
2410
  fixed[name] = value.toJSON(null, inputs);
2405
2411
  } else if (name === "source") {
2412
+ if (value == null) continue;
2406
2413
  let inputId = inputs.get(value.input);
2407
2414
  if (inputId == null) {
2408
2415
  inputId = inputsNextIndex;
@@ -2437,14 +2444,11 @@ var require_replay = __commonJS({
2437
2444
  });
2438
2445
  return result2;
2439
2446
  }
2440
- warn(result2, text, opts) {
2447
+ warn(result2, text, opts = {}) {
2441
2448
  let data = { node: this };
2442
2449
  for (let i in opts) data[i] = opts[i];
2443
2450
  return result2.warn(text, data);
2444
2451
  }
2445
- get proxyOf() {
2446
- return this;
2447
- }
2448
2452
  }
2449
2453
  node = Node;
2450
2454
  Node.default = Node;
@@ -2473,6 +2477,9 @@ var require_replay = __commonJS({
2473
2477
  hasRequiredDeclaration = 1;
2474
2478
  let Node = requireNode();
2475
2479
  class Declaration extends Node {
2480
+ get variable() {
2481
+ return this.prop.startsWith("--") || this.prop[0] === "$";
2482
+ }
2476
2483
  constructor(defaults) {
2477
2484
  if (defaults && typeof defaults.value !== "undefined" && typeof defaults.value !== "string") {
2478
2485
  defaults = __spreadProps(__spreadValues({}, defaults), { value: String(defaults.value) });
@@ -2480,9 +2487,6 @@ var require_replay = __commonJS({
2480
2487
  super(defaults);
2481
2488
  this.type = "decl";
2482
2489
  }
2483
- get variable() {
2484
- return this.prop.startsWith("--") || this.prop[0] === "$";
2485
- }
2486
2490
  }
2487
2491
  declaration = Declaration;
2488
2492
  Declaration.default = Declaration;
@@ -2514,6 +2518,14 @@ var require_replay = __commonJS({
2514
2518
  }
2515
2519
  }
2516
2520
  class Container extends Node {
2521
+ get first() {
2522
+ if (!this.proxyOf.nodes) return void 0;
2523
+ return this.proxyOf.nodes[0];
2524
+ }
2525
+ get last() {
2526
+ if (!this.proxyOf.nodes) return void 0;
2527
+ return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
2528
+ }
2517
2529
  append(...children) {
2518
2530
  for (let child of children) {
2519
2531
  let nodes = this.normalize(child, this.last);
@@ -2826,14 +2838,6 @@ var require_replay = __commonJS({
2826
2838
  }
2827
2839
  });
2828
2840
  }
2829
- get first() {
2830
- if (!this.proxyOf.nodes) return void 0;
2831
- return this.proxyOf.nodes[0];
2832
- }
2833
- get last() {
2834
- if (!this.proxyOf.nodes) return void 0;
2835
- return this.proxyOf.nodes[this.proxyOf.nodes.length - 1];
2836
- }
2837
2841
  }
2838
2842
  Container.registerParse = (dependant) => {
2839
2843
  parse = dependant;
@@ -3083,10 +3087,25 @@ var require_replay = __commonJS({
3083
3087
  let CssSyntaxError = requireCssSyntaxError();
3084
3088
  let PreviousMap = requirePreviousMap();
3085
3089
  let terminalHighlight = require$$2;
3086
- let fromOffsetCache = Symbol("fromOffsetCache");
3090
+ let lineToIndexCache = Symbol("lineToIndexCache");
3087
3091
  let sourceMapAvailable = Boolean(SourceMapConsumer && SourceMapGenerator);
3088
3092
  let pathAvailable = Boolean(resolve && isAbsolute);
3093
+ function getLineToIndex(input2) {
3094
+ if (input2[lineToIndexCache]) return input2[lineToIndexCache];
3095
+ let lines = input2.css.split("\n");
3096
+ let lineToIndex = new Array(lines.length);
3097
+ let prevIndex = 0;
3098
+ for (let i = 0, l = lines.length; i < l; i++) {
3099
+ lineToIndex[i] = prevIndex;
3100
+ prevIndex += lines[i].length + 1;
3101
+ }
3102
+ input2[lineToIndexCache] = lineToIndex;
3103
+ return lineToIndex;
3104
+ }
3089
3105
  class Input {
3106
+ get from() {
3107
+ return this.file || this.id;
3108
+ }
3090
3109
  constructor(css, opts = {}) {
3091
3110
  if (css === null || typeof css === "undefined" || typeof css === "object" && !css.toString) {
3092
3111
  throw new Error(`PostCSS received ${css} instead of CSS string`);
@@ -3121,30 +3140,37 @@ var require_replay = __commonJS({
3121
3140
  if (this.map) this.map.file = this.from;
3122
3141
  }
3123
3142
  error(message, line, column, opts = {}) {
3124
- let endColumn, endLine, result2;
3143
+ let endColumn, endLine, endOffset, offset, result2;
3125
3144
  if (line && typeof line === "object") {
3126
3145
  let start = line;
3127
3146
  let end = column;
3128
3147
  if (typeof start.offset === "number") {
3129
- let pos = this.fromOffset(start.offset);
3148
+ offset = start.offset;
3149
+ let pos = this.fromOffset(offset);
3130
3150
  line = pos.line;
3131
3151
  column = pos.col;
3132
3152
  } else {
3133
3153
  line = start.line;
3134
3154
  column = start.column;
3155
+ offset = this.fromLineAndColumn(line, column);
3135
3156
  }
3136
3157
  if (typeof end.offset === "number") {
3137
- let pos = this.fromOffset(end.offset);
3158
+ endOffset = end.offset;
3159
+ let pos = this.fromOffset(endOffset);
3138
3160
  endLine = pos.line;
3139
3161
  endColumn = pos.col;
3140
3162
  } else {
3141
3163
  endLine = end.line;
3142
3164
  endColumn = end.column;
3165
+ endOffset = this.fromLineAndColumn(end.line, end.column);
3143
3166
  }
3144
3167
  } else if (!column) {
3145
- let pos = this.fromOffset(line);
3168
+ offset = line;
3169
+ let pos = this.fromOffset(offset);
3146
3170
  line = pos.line;
3147
3171
  column = pos.col;
3172
+ } else {
3173
+ offset = this.fromLineAndColumn(line, column);
3148
3174
  }
3149
3175
  let origin = this.origin(line, column, endLine, endColumn);
3150
3176
  if (origin) {
@@ -3166,7 +3192,7 @@ var require_replay = __commonJS({
3166
3192
  opts.plugin
3167
3193
  );
3168
3194
  }
3169
- result2.input = { column, endColumn, endLine, line, source: this.css };
3195
+ result2.input = { column, endColumn, endLine, endOffset, line, offset, source: this.css };
3170
3196
  if (this.file) {
3171
3197
  if (pathToFileURL) {
3172
3198
  result2.input.url = pathToFileURL(this.file).toString();
@@ -3175,21 +3201,14 @@ var require_replay = __commonJS({
3175
3201
  }
3176
3202
  return result2;
3177
3203
  }
3204
+ fromLineAndColumn(line, column) {
3205
+ let lineToIndex = getLineToIndex(this);
3206
+ let index = lineToIndex[line - 1];
3207
+ return index + column - 1;
3208
+ }
3178
3209
  fromOffset(offset) {
3179
- let lastLine, lineToIndex;
3180
- if (!this[fromOffsetCache]) {
3181
- let lines = this.css.split("\n");
3182
- lineToIndex = new Array(lines.length);
3183
- let prevIndex = 0;
3184
- for (let i = 0, l = lines.length; i < l; i++) {
3185
- lineToIndex[i] = prevIndex;
3186
- prevIndex += lines[i].length + 1;
3187
- }
3188
- this[fromOffsetCache] = lineToIndex;
3189
- } else {
3190
- lineToIndex = this[fromOffsetCache];
3191
- }
3192
- lastLine = lineToIndex[lineToIndex.length - 1];
3210
+ let lineToIndex = getLineToIndex(this);
3211
+ let lastLine = lineToIndex[lineToIndex.length - 1];
3193
3212
  let min = 0;
3194
3213
  if (offset >= lastLine) {
3195
3214
  min = lineToIndex.length - 1;
@@ -3270,9 +3289,6 @@ var require_replay = __commonJS({
3270
3289
  }
3271
3290
  return json;
3272
3291
  }
3273
- get from() {
3274
- return this.file || this.id;
3275
- }
3276
3292
  }
3277
3293
  input = Input;
3278
3294
  Input.default = Input;
@@ -3398,11 +3414,6 @@ var require_replay = __commonJS({
3398
3414
  let Container = requireContainer();
3399
3415
  let list = requireList();
3400
3416
  class Rule extends Container {
3401
- constructor(defaults) {
3402
- super(defaults);
3403
- this.type = "rule";
3404
- if (!this.nodes) this.nodes = [];
3405
- }
3406
3417
  get selectors() {
3407
3418
  return list.comma(this.selector);
3408
3419
  }
@@ -3411,6 +3422,11 @@ var require_replay = __commonJS({
3411
3422
  let sep = match ? match[0] : "," + this.raw("between", "beforeOpen");
3412
3423
  this.selector = values.join(sep);
3413
3424
  }
3425
+ constructor(defaults) {
3426
+ super(defaults);
3427
+ this.type = "rule";
3428
+ if (!this.nodes) this.nodes = [];
3429
+ }
3414
3430
  }
3415
3431
  rule = Rule;
3416
3432
  Rule.default = Rule;
@@ -4309,6 +4325,8 @@ var require_replay = __commonJS({
4309
4325
  if (prev && prev.type === "rule" && !prev.raws.ownSemicolon) {
4310
4326
  prev.raws.ownSemicolon = this.spaces;
4311
4327
  this.spaces = "";
4328
+ prev.source.end = this.getPosition(token[2]);
4329
+ prev.source.end.offset += prev.raws.ownSemicolon.length;
4312
4330
  }
4313
4331
  }
4314
4332
  }
@@ -4520,7 +4538,7 @@ var require_replay = __commonJS({
4520
4538
  }
4521
4539
  unknownWord(tokens) {
4522
4540
  throw this.input.error(
4523
- "Unknown word",
4541
+ "Unknown word " + tokens[0][1],
4524
4542
  { offset: tokens[0][2] },
4525
4543
  { offset: tokens[0][2] + tokens[0][1].length }
4526
4544
  );
@@ -4613,12 +4631,15 @@ var require_replay = __commonJS({
4613
4631
  hasRequiredResult = 1;
4614
4632
  let Warning = requireWarning();
4615
4633
  class Result {
4634
+ get content() {
4635
+ return this.css;
4636
+ }
4616
4637
  constructor(processor2, root2, opts) {
4617
4638
  this.processor = processor2;
4618
4639
  this.messages = [];
4619
4640
  this.root = root2;
4620
4641
  this.opts = opts;
4621
- this.css = void 0;
4642
+ this.css = "";
4622
4643
  this.map = void 0;
4623
4644
  }
4624
4645
  toString() {
@@ -4637,9 +4658,6 @@ var require_replay = __commonJS({
4637
4658
  warnings() {
4638
4659
  return this.messages.filter((i) => i.type === "warning");
4639
4660
  }
4640
- get content() {
4641
- return this.css;
4642
- }
4643
4661
  }
4644
4662
  result = Result;
4645
4663
  Result.default = Result;
@@ -4758,6 +4776,30 @@ var require_replay = __commonJS({
4758
4776
  }
4759
4777
  let postcss2 = {};
4760
4778
  class LazyResult {
4779
+ get content() {
4780
+ return this.stringify().content;
4781
+ }
4782
+ get css() {
4783
+ return this.stringify().css;
4784
+ }
4785
+ get map() {
4786
+ return this.stringify().map;
4787
+ }
4788
+ get messages() {
4789
+ return this.sync().messages;
4790
+ }
4791
+ get opts() {
4792
+ return this.result.opts;
4793
+ }
4794
+ get processor() {
4795
+ return this.result.processor;
4796
+ }
4797
+ get root() {
4798
+ return this.sync().root;
4799
+ }
4800
+ get [Symbol.toStringTag]() {
4801
+ return "LazyResult";
4802
+ }
4761
4803
  constructor(processor2, css, opts) {
4762
4804
  this.stringified = false;
4763
4805
  this.processed = false;
@@ -5100,30 +5142,6 @@ var require_replay = __commonJS({
5100
5142
  warnings() {
5101
5143
  return this.sync().warnings();
5102
5144
  }
5103
- get content() {
5104
- return this.stringify().content;
5105
- }
5106
- get css() {
5107
- return this.stringify().css;
5108
- }
5109
- get map() {
5110
- return this.stringify().map;
5111
- }
5112
- get messages() {
5113
- return this.sync().messages;
5114
- }
5115
- get opts() {
5116
- return this.result.opts;
5117
- }
5118
- get processor() {
5119
- return this.result.processor;
5120
- }
5121
- get root() {
5122
- return this.sync().root;
5123
- }
5124
- get [Symbol.toStringTag]() {
5125
- return "LazyResult";
5126
- }
5127
5145
  }
5128
5146
  LazyResult.registerPostcss = (dependant) => {
5129
5147
  postcss2 = dependant;
@@ -5145,6 +5163,45 @@ var require_replay = __commonJS({
5145
5163
  let stringify = requireStringify();
5146
5164
  let warnOnce2 = requireWarnOnce();
5147
5165
  class NoWorkResult {
5166
+ get content() {
5167
+ return this.result.css;
5168
+ }
5169
+ get css() {
5170
+ return this.result.css;
5171
+ }
5172
+ get map() {
5173
+ return this.result.map;
5174
+ }
5175
+ get messages() {
5176
+ return [];
5177
+ }
5178
+ get opts() {
5179
+ return this.result.opts;
5180
+ }
5181
+ get processor() {
5182
+ return this.result.processor;
5183
+ }
5184
+ get root() {
5185
+ if (this._root) {
5186
+ return this._root;
5187
+ }
5188
+ let root2;
5189
+ let parser2 = parse;
5190
+ try {
5191
+ root2 = parser2(this._css, this._opts);
5192
+ } catch (error) {
5193
+ this.error = error;
5194
+ }
5195
+ if (this.error) {
5196
+ throw this.error;
5197
+ } else {
5198
+ this._root = root2;
5199
+ return root2;
5200
+ }
5201
+ }
5202
+ get [Symbol.toStringTag]() {
5203
+ return "NoWorkResult";
5204
+ }
5148
5205
  constructor(processor2, css, opts) {
5149
5206
  css = css.toString();
5150
5207
  this.stringified = false;
@@ -5206,45 +5263,6 @@ var require_replay = __commonJS({
5206
5263
  warnings() {
5207
5264
  return [];
5208
5265
  }
5209
- get content() {
5210
- return this.result.css;
5211
- }
5212
- get css() {
5213
- return this.result.css;
5214
- }
5215
- get map() {
5216
- return this.result.map;
5217
- }
5218
- get messages() {
5219
- return [];
5220
- }
5221
- get opts() {
5222
- return this.result.opts;
5223
- }
5224
- get processor() {
5225
- return this.result.processor;
5226
- }
5227
- get root() {
5228
- if (this._root) {
5229
- return this._root;
5230
- }
5231
- let root2;
5232
- let parser2 = parse;
5233
- try {
5234
- root2 = parser2(this._css, this._opts);
5235
- } catch (error) {
5236
- this.error = error;
5237
- }
5238
- if (this.error) {
5239
- throw this.error;
5240
- } else {
5241
- this._root = root2;
5242
- return root2;
5243
- }
5244
- }
5245
- get [Symbol.toStringTag]() {
5246
- return "NoWorkResult";
5247
- }
5248
5266
  }
5249
5267
  noWorkResult = NoWorkResult;
5250
5268
  NoWorkResult.default = NoWorkResult;
@@ -5261,7 +5279,7 @@ var require_replay = __commonJS({
5261
5279
  let Root = requireRoot();
5262
5280
  class Processor {
5263
5281
  constructor(plugins = []) {
5264
- this.version = "8.5.1";
5282
+ this.version = "8.5.6";
5265
5283
  this.plugins = this.normalize(plugins);
5266
5284
  }
5267
5285
  normalize(plugins) {
@@ -5982,7 +6000,7 @@ exports.recompressBase64Image = types.recompressBase64Image;
5982
6000
  exports.stringifyRule = types.stringifyRule;
5983
6001
  exports.stringifyStylesheet = types.stringifyStylesheet;
5984
6002
  exports.toLowerCase = types.toLowerCase;
5985
- if (typeof module.exports == "object" && typeof exports == "object") {
6003
+ ;if (typeof module.exports == "object" && typeof exports == "object") {
5986
6004
  var __cp = (to, from, except, desc) => {
5987
6005
  if ((from && typeof from === "object") || typeof from === "function") {
5988
6006
  for (let key of Object.getOwnPropertyNames(from)) {