@openreplay/tracker 3.4.6 → 3.4.10

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.
Files changed (94) hide show
  1. package/cjs/app/index.d.ts +7 -7
  2. package/cjs/app/index.js +22 -21
  3. package/cjs/app/logger.d.ts +0 -0
  4. package/cjs/app/logger.js +1 -0
  5. package/cjs/app/observer/iframe_observer.d.ts +1 -1
  6. package/cjs/app/observer/iframe_observer.js +8 -7
  7. package/cjs/app/observer/observer.d.ts +5 -2
  8. package/cjs/app/observer/observer.js +70 -49
  9. package/cjs/app/observer/shadow_root_observer.d.ts +1 -1
  10. package/cjs/app/observer/shadow_root_observer.js +4 -4
  11. package/cjs/app/observer/top_observer.d.ts +3 -3
  12. package/cjs/app/observer/top_observer.js +28 -24
  13. package/cjs/app/observer.d.ts +1 -1
  14. package/cjs/app/observer.js +26 -22
  15. package/cjs/app/sanitizer.d.ts +0 -0
  16. package/cjs/app/sanitizer.js +1 -0
  17. package/cjs/app/ticker.d.ts +1 -1
  18. package/cjs/index.d.ts +11 -10
  19. package/cjs/index.js +59 -56
  20. package/cjs/messages/index.d.ts +2 -2
  21. package/cjs/messages/message.d.ts +1 -1
  22. package/cjs/modules/connection.d.ts +1 -1
  23. package/cjs/modules/connection.js +2 -2
  24. package/cjs/modules/console.d.ts +1 -1
  25. package/cjs/modules/console.js +6 -6
  26. package/cjs/modules/cssrules.d.ts +1 -1
  27. package/cjs/modules/cssrules.js +4 -4
  28. package/cjs/modules/exception.d.ts +2 -2
  29. package/cjs/modules/exception.js +4 -4
  30. package/cjs/modules/img.d.ts +1 -1
  31. package/cjs/modules/img.js +6 -6
  32. package/cjs/modules/input.d.ts +1 -1
  33. package/cjs/modules/input.js +11 -11
  34. package/cjs/modules/longtasks.d.ts +1 -1
  35. package/cjs/modules/longtasks.js +2 -2
  36. package/cjs/modules/mouse.d.ts +1 -1
  37. package/cjs/modules/mouse.js +10 -10
  38. package/cjs/modules/performance.d.ts +1 -1
  39. package/cjs/modules/performance.js +5 -5
  40. package/cjs/modules/scroll.d.ts +1 -1
  41. package/cjs/modules/scroll.js +3 -3
  42. package/cjs/modules/timing.d.ts +1 -1
  43. package/cjs/modules/timing.js +6 -6
  44. package/cjs/modules/viewport.d.ts +1 -1
  45. package/cjs/modules/viewport.js +4 -4
  46. package/cjs/utils.js +1 -1
  47. package/lib/app/index.d.ts +7 -7
  48. package/lib/app/index.js +10 -9
  49. package/lib/app/logger.d.ts +0 -0
  50. package/lib/app/logger.js +1 -0
  51. package/lib/app/observer/iframe_observer.d.ts +1 -1
  52. package/lib/app/observer/iframe_observer.js +7 -6
  53. package/lib/app/observer/observer.d.ts +5 -2
  54. package/lib/app/observer/observer.js +58 -37
  55. package/lib/app/observer/shadow_root_observer.d.ts +1 -1
  56. package/lib/app/observer/shadow_root_observer.js +2 -2
  57. package/lib/app/observer/top_observer.d.ts +3 -3
  58. package/lib/app/observer/top_observer.js +22 -18
  59. package/lib/app/observer.d.ts +1 -1
  60. package/lib/app/observer.js +9 -5
  61. package/lib/app/sanitizer.d.ts +0 -0
  62. package/lib/app/sanitizer.js +1 -0
  63. package/lib/app/ticker.d.ts +1 -1
  64. package/lib/index.d.ts +11 -10
  65. package/lib/index.js +25 -22
  66. package/lib/messages/index.d.ts +2 -2
  67. package/lib/messages/message.d.ts +1 -1
  68. package/lib/messages/tsconfig.tsbuildinfo +1 -1
  69. package/lib/modules/connection.d.ts +1 -1
  70. package/lib/modules/connection.js +1 -1
  71. package/lib/modules/console.d.ts +1 -1
  72. package/lib/modules/console.js +4 -4
  73. package/lib/modules/cssrules.d.ts +1 -1
  74. package/lib/modules/cssrules.js +1 -1
  75. package/lib/modules/exception.d.ts +2 -2
  76. package/lib/modules/exception.js +1 -1
  77. package/lib/modules/img.d.ts +1 -1
  78. package/lib/modules/img.js +2 -2
  79. package/lib/modules/input.d.ts +1 -1
  80. package/lib/modules/input.js +2 -2
  81. package/lib/modules/longtasks.d.ts +1 -1
  82. package/lib/modules/longtasks.js +1 -1
  83. package/lib/modules/mouse.d.ts +1 -1
  84. package/lib/modules/mouse.js +3 -3
  85. package/lib/modules/performance.d.ts +1 -1
  86. package/lib/modules/performance.js +2 -2
  87. package/lib/modules/scroll.d.ts +1 -1
  88. package/lib/modules/scroll.js +1 -1
  89. package/lib/modules/timing.d.ts +1 -1
  90. package/lib/modules/timing.js +3 -3
  91. package/lib/modules/viewport.d.ts +1 -1
  92. package/lib/modules/viewport.js +1 -1
  93. package/package.json +2 -2
  94. package/tsconfig-base.json +1 -1
@@ -1,10 +1,10 @@
1
- import Message from '../messages/message';
2
- import Nodes from './nodes';
3
- import Observer from './observer';
4
- import Ticker from './ticker';
5
- import type { Options as ObserverOptions } from './observer';
6
- import type { Options as WebworkerOptions } from '../messages/webworker';
7
- interface OnStartInfo {
1
+ import Message from "../messages/message.js";
2
+ import Nodes from "./nodes.js";
3
+ import Observer from "./observer/top_observer.js";
4
+ import Ticker from "./ticker.js";
5
+ import type { Options as ObserverOptions } from "./observer.js";
6
+ import type { Options as WebworkerOptions } from "../messages/webworker.js";
7
+ export interface OnStartInfo {
8
8
  sessionID: string;
9
9
  sessionToken: string;
10
10
  userUUID: string;
package/cjs/app/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DEFAULT_INGEST_POINT = void 0;
4
- const utils_1 = require("../utils");
5
- const messages_1 = require("../messages");
6
- const nodes_1 = require("./nodes");
7
- const observer_1 = require("./observer");
8
- const ticker_1 = require("./ticker");
9
- const performance_1 = require("../modules/performance");
4
+ const utils_js_1 = require("../utils.js");
5
+ const index_js_1 = require("../messages/index.js");
6
+ const nodes_js_1 = require("./nodes.js");
7
+ const top_observer_js_1 = require("./observer/top_observer.js");
8
+ const ticker_js_1 = require("./ticker.js");
9
+ const performance_js_1 = require("../modules/performance.js");
10
10
  // TODO: use backendHost only
11
11
  exports.DEFAULT_INGEST_POINT = 'https://api.openreplay.com/ingest';
12
12
  class App {
@@ -17,7 +17,7 @@ class App {
17
17
  this.commitCallbacks = [];
18
18
  this._sessionID = null;
19
19
  this.isActive = false;
20
- this.version = '3.4.6';
20
+ this.version = '3.4.10';
21
21
  this.projectKey = projectKey;
22
22
  this.options = Object.assign({
23
23
  revID: '',
@@ -38,17 +38,17 @@ class App {
38
38
  sessionStorage.setItem(this.options.session_token_key, sessionToken);
39
39
  }
40
40
  this.revID = this.options.revID;
41
- this.nodes = new nodes_1.default(this.options.node_id);
42
- this.observer = new observer_1.default(this, this.options);
43
- this.ticker = new ticker_1.default(this);
41
+ this.nodes = new nodes_js_1.default(this.options.node_id);
42
+ this.observer = new top_observer_js_1.default(this, this.options);
43
+ this.ticker = new ticker_js_1.default(this);
44
44
  this.ticker.attach(() => this.commit());
45
45
  try {
46
- this.worker = new Worker(URL.createObjectURL(new Blob([`"use strict";function t(t){function s(...s){return new t(...s)}return s.prototype=t.prototype,s}const s=new Map;const i=t(class{constructor(t,s,i){this.pageNo=t,this.firstIndex=s,this.timestamp=i,this._id=80}encode(t){return t.uint(80)&&t.uint(this.pageNo)&&t.uint(this.firstIndex)&&t.int(this.timestamp)}});s.set(80,i);const n=t(class{constructor(t){this.timestamp=t,this._id=0}encode(t){return t.uint(0)&&t.uint(this.timestamp)}});s.set(0,n);const e=t(class{constructor(t,s,i){this.url=t,this.referrer=s,this.navigationStart=i,this._id=4}encode(t){return t.uint(4)&&t.string(this.url)&&t.string(this.referrer)&&t.uint(this.navigationStart)}});s.set(4,e);const r=t(class{constructor(t,s){this.width=t,this.height=s,this._id=5}encode(t){return t.uint(5)&&t.uint(this.width)&&t.uint(this.height)}});s.set(5,r);const o=t(class{constructor(t,s){this.x=t,this.y=s,this._id=6}encode(t){return t.uint(6)&&t.int(this.x)&&t.int(this.y)}});s.set(6,o);const h=t(class{constructor(){this._id=7}encode(t){return t.uint(7)}});s.set(7,h);const c=t(class{constructor(t,s,i,n,e){this.id=t,this.parentID=s,this.index=i,this.tag=n,this.svg=e,this._id=8}encode(t){return t.uint(8)&&t.uint(this.id)&&t.uint(this.parentID)&&t.uint(this.index)&&t.string(this.tag)&&t.boolean(this.svg)}});s.set(8,c);const u=t(class{constructor(t,s,i){this.id=t,this.parentID=s,this.index=i,this._id=9}encode(t){return t.uint(9)&&t.uint(this.id)&&t.uint(this.parentID)&&t.uint(this.index)}});s.set(9,u);const a=t(class{constructor(t,s,i){this.id=t,this.parentID=s,this.index=i,this._id=10}encode(t){return t.uint(10)&&t.uint(this.id)&&t.uint(this.parentID)&&t.uint(this.index)}});s.set(10,a);const d=t(class{constructor(t){this.id=t,this._id=11}encode(t){return t.uint(11)&&t.uint(this.id)}});s.set(11,d);const l=t(class{constructor(t,s,i){this.id=t,this.name=s,this.value=i,this._id=12}encode(t){return t.uint(12)&&t.uint(this.id)&&t.string(this.name)&&t.string(this.value)}});s.set(12,l);const g=t(class{constructor(t,s){this.id=t,this.name=s,this._id=13}encode(t){return t.uint(13)&&t.uint(this.id)&&t.string(this.name)}});s.set(13,g);const f=t(class{constructor(t,s){this.id=t,this.data=s,this._id=14}encode(t){return t.uint(14)&&t.uint(this.id)&&t.string(this.data)}});s.set(14,f);const p=t(class{constructor(t,s,i){this.id=t,this.x=s,this.y=i,this._id=16}encode(t){return t.uint(16)&&t.uint(this.id)&&t.int(this.x)&&t.int(this.y)}});s.set(16,p);const m=t(class{constructor(t,s){this.id=t,this.label=s,this._id=17}encode(t){return t.uint(17)&&t.uint(this.id)&&t.string(this.label)}});s.set(17,m);const _=t(class{constructor(t,s,i){this.id=t,this.value=s,this.mask=i,this._id=18}encode(t){return t.uint(18)&&t.uint(this.id)&&t.string(this.value)&&t.int(this.mask)}});s.set(18,_);const y=t(class{constructor(t,s){this.id=t,this.checked=s,this._id=19}encode(t){return t.uint(19)&&t.uint(this.id)&&t.boolean(this.checked)}});s.set(19,y);const v=t(class{constructor(t,s){this.x=t,this.y=s,this._id=20}encode(t){return t.uint(20)&&t.uint(this.x)&&t.uint(this.y)}});s.set(20,v);const S=t(class{constructor(t,s){this.level=t,this.value=s,this._id=22}encode(t){return t.uint(22)&&t.string(this.level)&&t.string(this.value)}});s.set(22,S);const b=t(class{constructor(t,s,i,n,e,r,o,h,c){this.requestStart=t,this.responseStart=s,this.responseEnd=i,this.domContentLoadedEventStart=n,this.domContentLoadedEventEnd=e,this.loadEventStart=r,this.loadEventEnd=o,this.firstPaint=h,this.firstContentfulPaint=c,this._id=23}encode(t){return t.uint(23)&&t.uint(this.requestStart)&&t.uint(this.responseStart)&&t.uint(this.responseEnd)&&t.uint(this.domContentLoadedEventStart)&&t.uint(this.domContentLoadedEventEnd)&&t.uint(this.loadEventStart)&&t.uint(this.loadEventEnd)&&t.uint(this.firstPaint)&&t.uint(this.firstContentfulPaint)}});s.set(23,b);const x=t(class{constructor(t,s,i){this.speedIndex=t,this.visuallyComplete=s,this.timeToInteractive=i,this._id=24}encode(t){return t.uint(24)&&t.uint(this.speedIndex)&&t.uint(this.visuallyComplete)&&t.uint(this.timeToInteractive)}});s.set(24,x);const E=t(class{constructor(t,s,i){this.name=t,this.message=s,this.payload=i,this._id=25}encode(t){return t.uint(25)&&t.string(this.name)&&t.string(this.message)&&t.string(this.payload)}});s.set(25,E);const k=t(class{constructor(t,s){this.name=t,this.payload=s,this._id=27}encode(t){return t.uint(27)&&t.string(this.name)&&t.string(this.payload)}});s.set(27,k);const I=t(class{constructor(t){this.id=t,this._id=28}encode(t){return t.uint(28)&&t.string(this.id)}});s.set(28,I);const z=t(class{constructor(t){this.id=t,this._id=29}encode(t){return t.uint(29)&&t.string(this.id)}});s.set(29,z);const w=t(class{constructor(t,s){this.key=t,this.value=s,this._id=30}encode(t){return t.uint(30)&&t.string(this.key)&&t.string(this.value)}});s.set(30,w);const T=t(class{constructor(t,s,i){this.id=t,this.rule=s,this.index=i,this._id=37}encode(t){return t.uint(37)&&t.uint(this.id)&&t.string(this.rule)&&t.uint(this.index)}});s.set(37,T);const L=t(class{constructor(t,s){this.id=t,this.index=s,this._id=38}encode(t){return t.uint(38)&&t.uint(this.id)&&t.uint(this.index)}});s.set(38,L);const A=t(class{constructor(t,s,i,n,e,r,o){this.method=t,this.url=s,this.request=i,this.response=n,this.status=e,this.timestamp=r,this.duration=o,this._id=39}encode(t){return t.uint(39)&&t.string(this.method)&&t.string(this.url)&&t.string(this.request)&&t.string(this.response)&&t.uint(this.status)&&t.uint(this.timestamp)&&t.uint(this.duration)}});s.set(39,A);const C=t(class{constructor(t,s,i,n){this.name=t,this.duration=s,this.args=i,this.result=n,this._id=40}encode(t){return t.uint(40)&&t.string(this.name)&&t.uint(this.duration)&&t.string(this.args)&&t.string(this.result)}});s.set(40,C);const M=t(class{constructor(t,s){this.key=t,this.value=s,this._id=41}encode(t){return t.uint(41)&&t.string(this.key)&&t.string(this.value)}});s.set(41,M);const R=t(class{constructor(t){this.type=t,this._id=42}encode(t){return t.uint(42)&&t.string(this.type)}});s.set(42,R);const N=t(class{constructor(t,s,i){this.action=t,this.state=s,this.duration=i,this._id=44}encode(t){return t.uint(44)&&t.string(this.action)&&t.string(this.state)&&t.uint(this.duration)}});s.set(44,N);const D=t(class{constructor(t,s){this.mutation=t,this.state=s,this._id=45}encode(t){return t.uint(45)&&t.string(this.mutation)&&t.string(this.state)}});s.set(45,D);const U=t(class{constructor(t,s){this.type=t,this.payload=s,this._id=46}encode(t){return t.uint(46)&&t.string(this.type)&&t.string(this.payload)}});s.set(46,U);const O=t(class{constructor(t,s,i){this.action=t,this.state=s,this.duration=i,this._id=47}encode(t){return t.uint(47)&&t.string(this.action)&&t.string(this.state)&&t.uint(this.duration)}});s.set(47,O);const q=t(class{constructor(t,s,i,n){this.operationKind=t,this.operationName=s,this.variables=i,this.response=n,this._id=48}encode(t){return t.uint(48)&&t.string(this.operationKind)&&t.string(this.operationName)&&t.string(this.variables)&&t.string(this.response)}});s.set(48,q);const H=t(class{constructor(t,s,i,n){this.frames=t,this.ticks=s,this.totalJSHeapSize=i,this.usedJSHeapSize=n,this._id=49}encode(t){return t.uint(49)&&t.int(this.frames)&&t.int(this.ticks)&&t.uint(this.totalJSHeapSize)&&t.uint(this.usedJSHeapSize)}});s.set(49,H);const P=t(class{constructor(t,s,i,n,e,r,o,h){this.timestamp=t,this.duration=s,this.ttfb=i,this.headerSize=n,this.encodedBodySize=e,this.decodedBodySize=r,this.url=o,this.initiator=h,this._id=53}encode(t){return t.uint(53)&&t.uint(this.timestamp)&&t.uint(this.duration)&&t.uint(this.ttfb)&&t.uint(this.headerSize)&&t.uint(this.encodedBodySize)&&t.uint(this.decodedBodySize)&&t.string(this.url)&&t.string(this.initiator)}});s.set(53,P);const B=t(class{constructor(t,s){this.downlink=t,this.type=s,this._id=54}encode(t){return t.uint(54)&&t.uint(this.downlink)&&t.string(this.type)}});s.set(54,B);const J=t(class{constructor(t){this.hidden=t,this._id=55}encode(t){return t.uint(55)&&t.boolean(this.hidden)}});s.set(55,J);const j=t(class{constructor(t,s,i,n,e,r,o){this.timestamp=t,this.duration=s,this.context=i,this.containerType=n,this.containerSrc=e,this.containerId=r,this.containerName=o,this._id=59}encode(t){return t.uint(59)&&t.uint(this.timestamp)&&t.uint(this.duration)&&t.uint(this.context)&&t.uint(this.containerType)&&t.string(this.containerSrc)&&t.string(this.containerId)&&t.string(this.containerName)}});s.set(59,j);const G=t(class{constructor(t,s,i,n){this.id=t,this.name=s,this.value=i,this.baseURL=n,this._id=60}encode(t){return t.uint(60)&&t.uint(this.id)&&t.string(this.name)&&t.string(this.value)&&t.string(this.baseURL)}});s.set(60,G);const K=t(class{constructor(t,s,i){this.id=t,this.data=s,this.baseURL=i,this._id=61}encode(t){return t.uint(61)&&t.uint(this.id)&&t.string(this.data)&&t.string(this.baseURL)}});s.set(61,K);const X=t(class{constructor(t,s){this.type=t,this.value=s,this._id=63}encode(t){return t.uint(63)&&t.string(this.type)&&t.string(this.value)}});s.set(63,X);const F=t(class{constructor(t,s){this.name=t,this.payload=s,this._id=64}encode(t){return t.uint(64)&&t.string(this.name)&&t.string(this.payload)}});s.set(64,F);const Q=t(class{constructor(){this._id=65}encode(t){return t.uint(65)}});s.set(65,Q);const V=t(class{constructor(t,s,i,n){this.id=t,this.rule=s,this.index=i,this.baseURL=n,this._id=67}encode(t){return t.uint(67)&&t.uint(this.id)&&t.string(this.rule)&&t.uint(this.index)&&t.string(this.baseURL)}});s.set(67,V);const W=t(class{constructor(t,s,i,n){this.id=t,this.hesitationTime=s,this.label=i,this.selector=n,this._id=69}encode(t){return t.uint(69)&&t.uint(this.id)&&t.uint(this.hesitationTime)&&t.string(this.label)&&t.string(this.selector)}});s.set(69,W);const Y=t(class{constructor(t,s){this.frameID=t,this.id=s,this._id=70}encode(t){return t.uint(70)&&t.uint(this.frameID)&&t.uint(this.id)}});s.set(70,Y);const Z="function"==typeof TextEncoder?new TextEncoder:{encode(t){const s=t.length,i=new Uint8Array(3*s);let n=-1;for(var e=0,r=0,o=0;o!==s;){if(e=t.charCodeAt(o),o+=1,e>=55296&&e<=56319){if(o===s){i[n+=1]=239,i[n+=1]=191,i[n+=1]=189;break}if(!((r=t.charCodeAt(o))>=56320&&r<=57343)){i[n+=1]=239,i[n+=1]=191,i[n+=1]=189;continue}if(o+=1,(e=1024*(e-55296)+r-56320+65536)>65535){i[n+=1]=240|e>>>18,i[n+=1]=128|e>>>12&63,i[n+=1]=128|e>>>6&63,i[n+=1]=128|63&e;continue}}e<=127?i[n+=1]=0|e:e<=2047?(i[n+=1]=192|e>>>6,i[n+=1]=128|63&e):(i[n+=1]=224|e>>>12,i[n+=1]=128|e>>>6&63,i[n+=1]=128|63&e)}return i.subarray(0,n+1)}};class tt{constructor(t){this.size=t,this.offset=0,this.checkpointOffset=0,this.data=new Uint8Array(t)}checkpoint(){this.checkpointOffset=this.offset}isEmpty(){return 0===this.offset}boolean(t){return this.data[this.offset++]=+t,this.offset<=this.size}uint(t){for((t<0||t>Number.MAX_SAFE_INTEGER)&&(t=0);t>=128;)this.data[this.offset++]=t%256|128,t=Math.floor(t/128);return this.data[this.offset++]=t,this.offset<=this.size}int(t){return t=Math.round(t),this.uint(t>=0?2*t:-2*t-1)}string(t){const s=Z.encode(t),i=s.byteLength;return!(!this.uint(i)||this.offset+i>this.size)&&(this.data.set(s,this.offset),this.offset+=i,!0)}reset(){this.offset=0,this.checkpointOffset=0}flush(){const t=this.data.slice(0,this.checkpointOffset);return this.reset(),t}}let st,it=1e6,nt=4e5,et=new tt(nt),rt="",ot="",ht=0,ct=0,ut=0,at=0,dt=!0;function lt(){return new i(ht,at,ct).encode(et)}const gt=[];let ft,pt=!1,mt=0,_t=8e3,yt=10;function vt(){if(dt||""===ot||""===rt)return;const t=et.flush();pt?gt.push(t):(pt=!0,function t(s){const i=new XMLHttpRequest;i.open("POST",rt+"/v1/web/i",!1),i.setRequestHeader("Authorization","Bearer "+ot),i.onreadystatechange=function(){if(4===this.readyState){if(0==this.status)return;if(this.status>=400)return St(),gt.length=0,401===this.status?void self.postMessage("restart"):void self.postMessage(null);const s=gt.shift();s?t(s):pt=!1}},i.onerror=function(i){if(mt>=yt)return St(),void self.postMessage(null);mt++,setTimeout(()=>t(s),_t)},i.send(s.buffer)}(t)),dt=!0,lt()}function St(){rt="",ot="",clearInterval(st),et.reset()}self.onmessage=({data:t})=>{if(null!==t)return"stop"===t?(vt(),void St()):Array.isArray(t)?void t.forEach(t=>{const i=new(s.get(t._id));if(Object.assign(i,t),i instanceof n?ct=i.timestamp:i instanceof J&&(i.hidden?ft=setTimeout(()=>self.postMessage("restart"),3e5):clearTimeout(ft)),et.checkpoint(),!i.encode(et)&&(vt(),!i.encode(et)))for(;!i.encode(et);){if(nt===it)return console.warn("OpenReplay: beacon size overflow."),et.reset(),void lt();nt=Math.min(2*nt,it),et=new tt(nt),lt()}at++,dt=!1}):(rt=t.ingestPoint||rt,ot=t.token||ot,ht=t.pageNo||ht,ct=t.startTimestamp||ct,ut=t.timeAdjustment||ut,yt=t.connAttemptCount||yt,_t=t.connAttemptGap||_t,it=t.beaconSizeLimit||it,nt=Math.min(it,t.beaconSize||nt),et.isEmpty()&&lt(),void(null==st&&(st=setInterval(vt,2e4))));vt()};
46
+ this.worker = new Worker(URL.createObjectURL(new Blob([`"use strict";function t(t){function s(...s){return new t(...s)}return s.prototype=t.prototype,s}const s=new Map;const i=t(class{constructor(t,s,i){this.pageNo=t,this.firstIndex=s,this.timestamp=i,this._id=80}encode(t){return t.uint(80)&&t.uint(this.pageNo)&&t.uint(this.firstIndex)&&t.int(this.timestamp)}});s.set(80,i);const n=t(class{constructor(t){this.timestamp=t,this._id=0}encode(t){return t.uint(0)&&t.uint(this.timestamp)}});s.set(0,n);const e=t(class{constructor(t,s,i){this.url=t,this.referrer=s,this.navigationStart=i,this._id=4}encode(t){return t.uint(4)&&t.string(this.url)&&t.string(this.referrer)&&t.uint(this.navigationStart)}});s.set(4,e);const r=t(class{constructor(t,s){this.width=t,this.height=s,this._id=5}encode(t){return t.uint(5)&&t.uint(this.width)&&t.uint(this.height)}});s.set(5,r);const o=t(class{constructor(t,s){this.x=t,this.y=s,this._id=6}encode(t){return t.uint(6)&&t.int(this.x)&&t.int(this.y)}});s.set(6,o);const h=t(class{constructor(){this._id=7}encode(t){return t.uint(7)}});s.set(7,h);const c=t(class{constructor(t,s,i,n,e){this.id=t,this.parentID=s,this.index=i,this.tag=n,this.svg=e,this._id=8}encode(t){return t.uint(8)&&t.uint(this.id)&&t.uint(this.parentID)&&t.uint(this.index)&&t.string(this.tag)&&t.boolean(this.svg)}});s.set(8,c);const u=t(class{constructor(t,s,i){this.id=t,this.parentID=s,this.index=i,this._id=9}encode(t){return t.uint(9)&&t.uint(this.id)&&t.uint(this.parentID)&&t.uint(this.index)}});s.set(9,u);const a=t(class{constructor(t,s,i){this.id=t,this.parentID=s,this.index=i,this._id=10}encode(t){return t.uint(10)&&t.uint(this.id)&&t.uint(this.parentID)&&t.uint(this.index)}});s.set(10,a);const d=t(class{constructor(t){this.id=t,this._id=11}encode(t){return t.uint(11)&&t.uint(this.id)}});s.set(11,d);const l=t(class{constructor(t,s,i){this.id=t,this.name=s,this.value=i,this._id=12}encode(t){return t.uint(12)&&t.uint(this.id)&&t.string(this.name)&&t.string(this.value)}});s.set(12,l);const g=t(class{constructor(t,s){this.id=t,this.name=s,this._id=13}encode(t){return t.uint(13)&&t.uint(this.id)&&t.string(this.name)}});s.set(13,g);const f=t(class{constructor(t,s){this.id=t,this.data=s,this._id=14}encode(t){return t.uint(14)&&t.uint(this.id)&&t.string(this.data)}});s.set(14,f);const p=t(class{constructor(t,s,i){this.id=t,this.x=s,this.y=i,this._id=16}encode(t){return t.uint(16)&&t.uint(this.id)&&t.int(this.x)&&t.int(this.y)}});s.set(16,p);const m=t(class{constructor(t,s){this.id=t,this.label=s,this._id=17}encode(t){return t.uint(17)&&t.uint(this.id)&&t.string(this.label)}});s.set(17,m);const _=t(class{constructor(t,s,i){this.id=t,this.value=s,this.mask=i,this._id=18}encode(t){return t.uint(18)&&t.uint(this.id)&&t.string(this.value)&&t.int(this.mask)}});s.set(18,_);const y=t(class{constructor(t,s){this.id=t,this.checked=s,this._id=19}encode(t){return t.uint(19)&&t.uint(this.id)&&t.boolean(this.checked)}});s.set(19,y);const v=t(class{constructor(t,s){this.x=t,this.y=s,this._id=20}encode(t){return t.uint(20)&&t.uint(this.x)&&t.uint(this.y)}});s.set(20,v);const S=t(class{constructor(t,s){this.level=t,this.value=s,this._id=22}encode(t){return t.uint(22)&&t.string(this.level)&&t.string(this.value)}});s.set(22,S);const b=t(class{constructor(t,s,i,n,e,r,o,h,c){this.requestStart=t,this.responseStart=s,this.responseEnd=i,this.domContentLoadedEventStart=n,this.domContentLoadedEventEnd=e,this.loadEventStart=r,this.loadEventEnd=o,this.firstPaint=h,this.firstContentfulPaint=c,this._id=23}encode(t){return t.uint(23)&&t.uint(this.requestStart)&&t.uint(this.responseStart)&&t.uint(this.responseEnd)&&t.uint(this.domContentLoadedEventStart)&&t.uint(this.domContentLoadedEventEnd)&&t.uint(this.loadEventStart)&&t.uint(this.loadEventEnd)&&t.uint(this.firstPaint)&&t.uint(this.firstContentfulPaint)}});s.set(23,b);const x=t(class{constructor(t,s,i){this.speedIndex=t,this.visuallyComplete=s,this.timeToInteractive=i,this._id=24}encode(t){return t.uint(24)&&t.uint(this.speedIndex)&&t.uint(this.visuallyComplete)&&t.uint(this.timeToInteractive)}});s.set(24,x);const E=t(class{constructor(t,s,i){this.name=t,this.message=s,this.payload=i,this._id=25}encode(t){return t.uint(25)&&t.string(this.name)&&t.string(this.message)&&t.string(this.payload)}});s.set(25,E);const k=t(class{constructor(t,s){this.name=t,this.payload=s,this._id=27}encode(t){return t.uint(27)&&t.string(this.name)&&t.string(this.payload)}});s.set(27,k);const I=t(class{constructor(t){this.id=t,this._id=28}encode(t){return t.uint(28)&&t.string(this.id)}});s.set(28,I);const z=t(class{constructor(t){this.id=t,this._id=29}encode(t){return t.uint(29)&&t.string(this.id)}});s.set(29,z);const w=t(class{constructor(t,s){this.key=t,this.value=s,this._id=30}encode(t){return t.uint(30)&&t.string(this.key)&&t.string(this.value)}});s.set(30,w);const T=t(class{constructor(t,s,i){this.id=t,this.rule=s,this.index=i,this._id=37}encode(t){return t.uint(37)&&t.uint(this.id)&&t.string(this.rule)&&t.uint(this.index)}});s.set(37,T);const L=t(class{constructor(t,s){this.id=t,this.index=s,this._id=38}encode(t){return t.uint(38)&&t.uint(this.id)&&t.uint(this.index)}});s.set(38,L);const A=t(class{constructor(t,s,i,n,e,r,o){this.method=t,this.url=s,this.request=i,this.response=n,this.status=e,this.timestamp=r,this.duration=o,this._id=39}encode(t){return t.uint(39)&&t.string(this.method)&&t.string(this.url)&&t.string(this.request)&&t.string(this.response)&&t.uint(this.status)&&t.uint(this.timestamp)&&t.uint(this.duration)}});s.set(39,A);const C=t(class{constructor(t,s,i,n){this.name=t,this.duration=s,this.args=i,this.result=n,this._id=40}encode(t){return t.uint(40)&&t.string(this.name)&&t.uint(this.duration)&&t.string(this.args)&&t.string(this.result)}});s.set(40,C);const M=t(class{constructor(t,s){this.key=t,this.value=s,this._id=41}encode(t){return t.uint(41)&&t.string(this.key)&&t.string(this.value)}});s.set(41,M);const R=t(class{constructor(t){this.type=t,this._id=42}encode(t){return t.uint(42)&&t.string(this.type)}});s.set(42,R);const N=t(class{constructor(t,s,i){this.action=t,this.state=s,this.duration=i,this._id=44}encode(t){return t.uint(44)&&t.string(this.action)&&t.string(this.state)&&t.uint(this.duration)}});s.set(44,N);const D=t(class{constructor(t,s){this.mutation=t,this.state=s,this._id=45}encode(t){return t.uint(45)&&t.string(this.mutation)&&t.string(this.state)}});s.set(45,D);const U=t(class{constructor(t,s){this.type=t,this.payload=s,this._id=46}encode(t){return t.uint(46)&&t.string(this.type)&&t.string(this.payload)}});s.set(46,U);const O=t(class{constructor(t,s,i){this.action=t,this.state=s,this.duration=i,this._id=47}encode(t){return t.uint(47)&&t.string(this.action)&&t.string(this.state)&&t.uint(this.duration)}});s.set(47,O);const q=t(class{constructor(t,s,i,n){this.operationKind=t,this.operationName=s,this.variables=i,this.response=n,this._id=48}encode(t){return t.uint(48)&&t.string(this.operationKind)&&t.string(this.operationName)&&t.string(this.variables)&&t.string(this.response)}});s.set(48,q);const H=t(class{constructor(t,s,i,n){this.frames=t,this.ticks=s,this.totalJSHeapSize=i,this.usedJSHeapSize=n,this._id=49}encode(t){return t.uint(49)&&t.int(this.frames)&&t.int(this.ticks)&&t.uint(this.totalJSHeapSize)&&t.uint(this.usedJSHeapSize)}});s.set(49,H);const P=t(class{constructor(t,s,i,n,e,r,o,h){this.timestamp=t,this.duration=s,this.ttfb=i,this.headerSize=n,this.encodedBodySize=e,this.decodedBodySize=r,this.url=o,this.initiator=h,this._id=53}encode(t){return t.uint(53)&&t.uint(this.timestamp)&&t.uint(this.duration)&&t.uint(this.ttfb)&&t.uint(this.headerSize)&&t.uint(this.encodedBodySize)&&t.uint(this.decodedBodySize)&&t.string(this.url)&&t.string(this.initiator)}});s.set(53,P);const B=t(class{constructor(t,s){this.downlink=t,this.type=s,this._id=54}encode(t){return t.uint(54)&&t.uint(this.downlink)&&t.string(this.type)}});s.set(54,B);const J=t(class{constructor(t){this.hidden=t,this._id=55}encode(t){return t.uint(55)&&t.boolean(this.hidden)}});s.set(55,J);const j=t(class{constructor(t,s,i,n,e,r,o){this.timestamp=t,this.duration=s,this.context=i,this.containerType=n,this.containerSrc=e,this.containerId=r,this.containerName=o,this._id=59}encode(t){return t.uint(59)&&t.uint(this.timestamp)&&t.uint(this.duration)&&t.uint(this.context)&&t.uint(this.containerType)&&t.string(this.containerSrc)&&t.string(this.containerId)&&t.string(this.containerName)}});s.set(59,j);const G=t(class{constructor(t,s,i,n){this.id=t,this.name=s,this.value=i,this.baseURL=n,this._id=60}encode(t){return t.uint(60)&&t.uint(this.id)&&t.string(this.name)&&t.string(this.value)&&t.string(this.baseURL)}});s.set(60,G);const K=t(class{constructor(t,s,i){this.id=t,this.data=s,this.baseURL=i,this._id=61}encode(t){return t.uint(61)&&t.uint(this.id)&&t.string(this.data)&&t.string(this.baseURL)}});s.set(61,K);const X=t(class{constructor(t,s){this.type=t,this.value=s,this._id=63}encode(t){return t.uint(63)&&t.string(this.type)&&t.string(this.value)}});s.set(63,X);const F=t(class{constructor(t,s){this.name=t,this.payload=s,this._id=64}encode(t){return t.uint(64)&&t.string(this.name)&&t.string(this.payload)}});s.set(64,F);const Q=t(class{constructor(){this._id=65}encode(t){return t.uint(65)}});s.set(65,Q);const V=t(class{constructor(t,s,i,n){this.id=t,this.rule=s,this.index=i,this.baseURL=n,this._id=67}encode(t){return t.uint(67)&&t.uint(this.id)&&t.string(this.rule)&&t.uint(this.index)&&t.string(this.baseURL)}});s.set(67,V);const W=t(class{constructor(t,s,i,n){this.id=t,this.hesitationTime=s,this.label=i,this.selector=n,this._id=69}encode(t){return t.uint(69)&&t.uint(this.id)&&t.uint(this.hesitationTime)&&t.string(this.label)&&t.string(this.selector)}});s.set(69,W);const Y=t(class{constructor(t,s){this.frameID=t,this.id=s,this._id=70}encode(t){return t.uint(70)&&t.uint(this.frameID)&&t.uint(this.id)}});s.set(70,Y);const Z="function"==typeof TextEncoder?new TextEncoder:{encode(t){const s=t.length,i=new Uint8Array(3*s);let n=-1;for(var e=0,r=0,o=0;o!==s;){if(e=t.charCodeAt(o),o+=1,e>=55296&&e<=56319){if(o===s){i[n+=1]=239,i[n+=1]=191,i[n+=1]=189;break}if(!((r=t.charCodeAt(o))>=56320&&r<=57343)){i[n+=1]=239,i[n+=1]=191,i[n+=1]=189;continue}if(o+=1,(e=1024*(e-55296)+r-56320+65536)>65535){i[n+=1]=240|e>>>18,i[n+=1]=128|e>>>12&63,i[n+=1]=128|e>>>6&63,i[n+=1]=128|63&e;continue}}e<=127?i[n+=1]=0|e:e<=2047?(i[n+=1]=192|e>>>6,i[n+=1]=128|63&e):(i[n+=1]=224|e>>>12,i[n+=1]=128|e>>>6&63,i[n+=1]=128|63&e)}return i.subarray(0,n+1)}};class tt{constructor(t){this.size=t,this.offset=0,this.checkpointOffset=0,this.data=new Uint8Array(t)}checkpoint(){this.checkpointOffset=this.offset}isEmpty(){return 0===this.offset}boolean(t){return this.data[this.offset++]=+t,this.offset<=this.size}uint(t){for((t<0||t>Number.MAX_SAFE_INTEGER)&&(t=0);t>=128;)this.data[this.offset++]=t%256|128,t=Math.floor(t/128);return this.data[this.offset++]=t,this.offset<=this.size}int(t){return t=Math.round(t),this.uint(t>=0?2*t:-2*t-1)}string(t){const s=Z.encode(t),i=s.byteLength;return!(!this.uint(i)||this.offset+i>this.size)&&(this.data.set(s,this.offset),this.offset+=i,!0)}reset(){this.offset=0,this.checkpointOffset=0}flush(){const t=this.data.slice(0,this.checkpointOffset);return this.reset(),t}}let st,it=1e6,nt=4e5,et=new tt(nt),rt="",ot="",ht=0,ct=0,ut=0,at=0,dt=!0;function lt(){return new i(ht,at,ct).encode(et)}const gt=[];let ft,pt=!1,mt=0,_t=8e3,yt=10;function vt(){if(dt||""===ot||""===rt)return;const t=et.flush();pt?gt.push(t):(pt=!0,function t(s){const i=new XMLHttpRequest;i.open("POST",rt+"/v1/web/i",!1),i.setRequestHeader("Authorization","Bearer "+ot),i.onreadystatechange=function(){if(4===this.readyState){if(0==this.status)return;if(this.status>=400)return St(),gt.length=0,401===this.status?void self.postMessage("restart"):void self.postMessage(null);const s=gt.shift();s?t(s):pt=!1}},i.onerror=function(i){if(mt>=yt)return St(),void self.postMessage(null);mt++,setTimeout(()=>t(s),_t)},i.send(s.buffer)}(t)),dt=!0,lt()}function St(){rt="",ot="",clearInterval(st),et.reset()}self.onmessage=({data:t})=>{if(null!==t)return"stop"===t?(vt(),void St()):Array.isArray(t)?void t.forEach(t=>{const i=new(s.get(t._id));if(Object.assign(i,t),i instanceof n?ct=i.timestamp:i instanceof J&&(i.hidden?ft=setTimeout(()=>self.postMessage("restart"),3e5):clearTimeout(ft)),et.checkpoint(),!i.encode(et)&&(vt(),!i.encode(et)))for(;!i.encode(et);){if(nt===it)return console.warn("OpenReplay: beacon size overflow."),et.reset(),void lt();nt=Math.min(2*nt,it),et=new tt(nt),lt()}at++,dt=!1}):(rt=t.ingestPoint||rt,ot=t.token||ot,ht=t.pageNo||ht,ct=t.startTimestamp||ct,ut=t.timeAdjustment||ut,yt=t.connAttemptCount||yt,_t=t.connAttemptGap||_t,it=t.beaconSizeLimit||it,nt=Math.min(it,t.beaconSize||nt),et.isEmpty()&&lt(),void(null==st&&(st=setInterval(vt,8e3))));vt()};
47
47
  `], { type: 'text/javascript' })));
48
48
  this.worker.onerror = e => {
49
49
  this._debug("webworker_error", e);
50
50
  };
51
- let lastTs = utils_1.timestamp();
51
+ let lastTs = (0, utils_js_1.timestamp)();
52
52
  let fileno = 0;
53
53
  this.worker.onmessage = ({ data }) => {
54
54
  if (data === null) {
@@ -85,7 +85,7 @@ class App {
85
85
  });
86
86
  }
87
87
  if (this.options.__debug_log) {
88
- utils_1.warn("OpenReplay error: ", context, e);
88
+ (0, utils_js_1.warn)("OpenReplay error: ", context, e);
89
89
  }
90
90
  }
91
91
  send(message, urgent = false) {
@@ -99,7 +99,7 @@ class App {
99
99
  }
100
100
  commit() {
101
101
  if (this.worker && this.messages.length) {
102
- this.messages.unshift(new messages_1.Timestamp(utils_1.timestamp()));
102
+ this.messages.unshift(new index_js_1.Timestamp((0, utils_js_1.timestamp)()));
103
103
  this.worker.postMessage(this.messages);
104
104
  this.commitCallbacks.forEach(cb => cb(this.messages));
105
105
  this.messages.length = 0;
@@ -194,7 +194,7 @@ class App {
194
194
  pageNo++;
195
195
  }
196
196
  sessionStorage.setItem(this.options.session_pageno_key, pageNo.toString());
197
- const startTimestamp = utils_1.timestamp();
197
+ const startTimestamp = (0, utils_js_1.timestamp)();
198
198
  const messageData = {
199
199
  ingestPoint: this.options.ingestPoint,
200
200
  pageNo,
@@ -216,8 +216,8 @@ class App {
216
216
  timestamp: startTimestamp,
217
217
  trackerVersion: this.version,
218
218
  isSnippet: this.options.__is_snippet,
219
- deviceMemory: performance_1.deviceMemory,
220
- jsHeapSizeLimit: performance_1.jsHeapSizeLimit,
219
+ deviceMemory: performance_js_1.deviceMemory,
220
+ jsHeapSizeLimit: performance_js_1.jsHeapSizeLimit,
221
221
  reset,
222
222
  }),
223
223
  })
@@ -250,7 +250,7 @@ class App {
250
250
  this.startCallbacks.forEach((cb) => cb());
251
251
  this.observer.observe();
252
252
  this.ticker.start();
253
- utils_1.log("OpenReplay tracking started.");
253
+ (0, utils_js_1.log)("OpenReplay tracking started.");
254
254
  const onStartInfo = { sessionToken: token, userUUID, sessionID };
255
255
  if (typeof this.options.onStart === 'function') {
256
256
  this.options.onStart(onStartInfo);
@@ -258,13 +258,14 @@ class App {
258
258
  return onStartInfo;
259
259
  })
260
260
  .catch(e => {
261
+ sessionStorage.removeItem(this.options.session_token_key);
261
262
  this.stop();
262
- utils_1.warn("OpenReplay was unable to start. ", e);
263
+ (0, utils_js_1.warn)("OpenReplay was unable to start. ", e);
263
264
  this._debug("session_start", e);
264
265
  throw e;
265
266
  });
266
267
  }
267
- return Promise.reject("Player is active");
268
+ return Promise.reject("Player is already active");
268
269
  }
269
270
  start(reset = false) {
270
271
  if (!document.hidden) {
@@ -292,7 +293,7 @@ class App {
292
293
  this.nodes.clear();
293
294
  this.ticker.stop();
294
295
  this.stopCallbacks.forEach((cb) => cb());
295
- utils_1.log("OpenReplay tracking stopped.");
296
+ (0, utils_js_1.log)("OpenReplay tracking stopped.");
296
297
  }
297
298
  finally {
298
299
  this.isActive = false;
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -1,4 +1,4 @@
1
- import Observer from './observer';
1
+ import Observer from "./observer.js";
2
2
  export default class IFrameObserver extends Observer {
3
3
  observe(iframe: HTMLIFrameElement): void;
4
4
  }
@@ -1,20 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const observer_1 = require("./observer");
4
- const messages_1 = require("../../messages");
5
- class IFrameObserver extends observer_1.default {
3
+ const observer_js_1 = require("./observer.js");
4
+ const index_js_1 = require("../../messages/index.js");
5
+ class IFrameObserver extends observer_js_1.default {
6
6
  observe(iframe) {
7
7
  const doc = iframe.contentDocument;
8
- const frameID = this.app.nodes.getID(iframe);
9
- if (!doc || frameID === undefined) {
8
+ const hostID = this.app.nodes.getID(iframe);
9
+ if (!doc || hostID === undefined) {
10
10
  return;
11
11
  } //log TODO common app.logger
12
+ // Have to observe document, because the inner <html> might be changed
12
13
  this.observeRoot(doc, (docID) => {
13
14
  if (docID === undefined) {
14
- console.log("OpenReplay: Document not bound");
15
+ console.log("OpenReplay: Iframe document not bound");
15
16
  return;
16
17
  }
17
- this.app.send(messages_1.CreateIFrameDocument(frameID, docID));
18
+ this.app.send((0, index_js_1.CreateIFrameDocument)(hostID, docID));
18
19
  });
19
20
  }
20
21
  }
@@ -1,4 +1,4 @@
1
- import App from '../index';
1
+ import App from "../index.js";
2
2
  export interface Window extends globalThis.Window {
3
3
  HTMLInputElement: typeof HTMLInputElement;
4
4
  HTMLLinkElement: typeof HTMLLinkElement;
@@ -30,9 +30,12 @@ export default abstract class Observer<AdditionalOptions = {}> {
30
30
  private readonly textSet;
31
31
  private readonly textMasked;
32
32
  protected readonly options: Options & AdditionalOptions;
33
+ private readonly inUpperContext;
33
34
  constructor(app: App, options: Partial<Options> & AdditionalOptions, context?: Window);
34
35
  private clear;
35
36
  private sendNodeAttribute;
37
+ getInnerTextSecure(el: HTMLElement): string;
38
+ private checkObscure;
36
39
  private sendNodeData;
37
40
  private bindNode;
38
41
  private bindTree;
@@ -40,7 +43,7 @@ export default abstract class Observer<AdditionalOptions = {}> {
40
43
  private _commitNode;
41
44
  private commitNode;
42
45
  private commitNodes;
43
- protected observeRoot(node: Node, beforeCommit: (id?: number) => unknown): void;
46
+ protected observeRoot(node: Node, beforeCommit: (id?: number) => unknown, nodeToBind?: Node): void;
44
47
  disconnect(): void;
45
48
  }
46
49
  export {};
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isInstance = void 0;
4
- const utils_1 = require("../../utils");
5
- const messages_1 = require("../../messages");
4
+ const utils_js_1 = require("../../utils.js");
5
+ const index_js_1 = require("../../messages/index.js");
6
6
  function isSVGElement(node) {
7
7
  return node.namespaceURI === 'http://www.w3.org/2000/svg';
8
8
  }
@@ -65,6 +65,7 @@ class Observer {
65
65
  obscureTextEmails: true,
66
66
  obscureTextNumbers: false,
67
67
  }, options);
68
+ this.inUpperContext = context.parent === context;
68
69
  this.observer = new MutationObserver(this.app.safe((mutations) => {
69
70
  for (const mutation of mutations) {
70
71
  const target = mutation.target;
@@ -145,16 +146,16 @@ class Observer {
145
146
  name = name.substr(6);
146
147
  }
147
148
  if (value === null) {
148
- this.app.send(new messages_1.RemoveNodeAttribute(id, name));
149
+ this.app.send(new index_js_1.RemoveNodeAttribute(id, name));
149
150
  }
150
151
  else if (name === 'href') {
151
152
  if (value.length > 1e5) {
152
153
  value = '';
153
154
  }
154
- this.app.send(new messages_1.SetNodeAttributeURLBased(id, name, value, this.app.getBaseHref()));
155
+ this.app.send(new index_js_1.SetNodeAttributeURLBased(id, name, value, this.app.getBaseHref()));
155
156
  }
156
157
  else {
157
- this.app.send(new messages_1.SetNodeAttribute(id, name, value));
158
+ this.app.send(new index_js_1.SetNodeAttribute(id, name, value));
158
159
  }
159
160
  return;
160
161
  }
@@ -174,36 +175,47 @@ class Observer {
174
175
  return;
175
176
  }
176
177
  if (value === null) {
177
- this.app.send(new messages_1.RemoveNodeAttribute(id, name));
178
+ this.app.send(new index_js_1.RemoveNodeAttribute(id, name));
178
179
  return;
179
180
  }
180
181
  if (name === 'style' || name === 'href' && isInstance(node, HTMLLinkElement)) {
181
- this.app.send(new messages_1.SetNodeAttributeURLBased(id, name, value, this.app.getBaseHref()));
182
+ this.app.send(new index_js_1.SetNodeAttributeURLBased(id, name, value, this.app.getBaseHref()));
182
183
  return;
183
184
  }
184
185
  if (name === 'href' || value.length > 1e5) {
185
186
  value = '';
186
187
  }
187
- this.app.send(new messages_1.SetNodeAttribute(id, name, value));
188
+ this.app.send(new index_js_1.SetNodeAttribute(id, name, value));
188
189
  }
189
- sendNodeData(id, parentElement, data) {
190
- if (isInstance(parentElement, HTMLStyleElement) || isInstance(parentElement, SVGStyleElement)) {
191
- this.app.send(new messages_1.SetCSSDataURLBased(id, data, this.app.getBaseHref()));
192
- return;
190
+ /* TODO: abstract sanitation */
191
+ getInnerTextSecure(el) {
192
+ const id = this.app.nodes.getID(el);
193
+ if (!id) {
194
+ return '';
193
195
  }
196
+ return this.checkObscure(id, el.innerText);
197
+ }
198
+ checkObscure(id, data) {
194
199
  if (this.textMasked.has(id)) {
195
- data = data.replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g, '█');
200
+ return data.replace(/[^\f\n\r\t\v\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]/g, '█');
196
201
  }
197
- else {
198
- if (this.options.obscureTextNumbers) {
199
- data = data.replace(/\d/g, '0');
200
- }
201
- if (this.options.obscureTextEmails) {
202
- data = data.replace(/([^\s]+)@([^\s]+)\.([^\s]+)/g, (...f) => utils_1.stars(f[1]) + '@' + utils_1.stars(f[2]) + '.' + utils_1.stars(f[3]));
203
- }
202
+ if (this.options.obscureTextNumbers) {
203
+ data = data.replace(/\d/g, '0');
204
+ }
205
+ if (this.options.obscureTextEmails) {
206
+ data = data.replace(/([^\s]+)@([^\s]+)\.([^\s]+)/g, (...f) => (0, utils_js_1.stars)(f[1]) + '@' + (0, utils_js_1.stars)(f[2]) + '.' + (0, utils_js_1.stars)(f[3]));
207
+ }
208
+ return data;
209
+ }
210
+ sendNodeData(id, parentElement, data) {
211
+ if (isInstance(parentElement, HTMLStyleElement) || isInstance(parentElement, SVGStyleElement)) {
212
+ this.app.send(new index_js_1.SetCSSDataURLBased(id, data, this.app.getBaseHref()));
213
+ return;
204
214
  }
205
- this.app.send(new messages_1.SetNodeData(id, data));
215
+ data = this.checkObscure(id, data);
216
+ this.app.send(new index_js_1.SetNodeData(id, data));
206
217
  }
218
+ /* end TODO: abstract sanitation */
207
219
  bindNode(node) {
208
220
  const r = this.app.nodes.registerNode(node);
209
221
  const id = r[0];
@@ -218,7 +230,9 @@ class Observer {
218
230
  acceptNode: (node) => isIgnored(node) || this.app.nodes.getID(node) !== undefined
219
231
  ? NodeFilter.FILTER_REJECT
220
232
  : NodeFilter.FILTER_ACCEPT,
221
- }, false);
233
+ },
234
+ // @ts-ignore
235
+ false);
222
236
  while (walker.nextNode()) {
223
237
  this.bindNode(walker.currentNode);
224
238
  }
@@ -226,7 +240,7 @@ class Observer {
226
240
  unbindNode(node) {
227
241
  const id = this.app.nodes.unregisterNode(node);
228
242
  if (id !== undefined && this.recents[id] === false) {
229
- this.app.send(new messages_1.RemoveNode(id));
243
+ this.app.send(new index_js_1.RemoveNode(id));
230
244
  }
231
245
  }
232
246
  _commitNode(id, node) {
@@ -235,25 +249,27 @@ class Observer {
235
249
  }
236
250
  const parent = node.parentNode;
237
251
  let parentID;
238
- // if (isInstance(node, HTMLHtmlElement)) { // ?? TODO: get rid of "specia" cases
239
- // this.indexes[id] = 0
240
- // } else {
241
- if (parent === null) {
242
- this.unbindNode(node);
243
- return false;
244
- }
245
- parentID = this.app.nodes.getID(parent);
246
- if (parentID === undefined) {
247
- this.unbindNode(node);
248
- return false;
249
- }
250
- if (!this.commitNode(parentID)) {
251
- this.unbindNode(node);
252
- return false;
253
- }
254
- if (this.textMasked.has(parentID) ||
255
- (isInstance(node, Element) && utils_1.hasOpenreplayAttribute(node, 'masked'))) {
256
- this.textMasked.add(id);
252
+ // Disable parent check for the upper context HTMLHtmlElement, because it is root there... (before)
253
+ // TODO: get rid of "special" cases (there is an issue with CreateDocument altered behaviour though)
254
+ // TODO: Clean the logic (though now it workd fine)
255
+ if (!isInstance(node, HTMLHtmlElement) || !this.inUpperContext) {
256
+ if (parent === null) {
257
+ this.unbindNode(node);
258
+ return false;
259
+ }
260
+ parentID = this.app.nodes.getID(parent);
261
+ if (parentID === undefined) {
262
+ this.unbindNode(node);
263
+ return false;
264
+ }
265
+ if (!this.commitNode(parentID)) {
266
+ this.unbindNode(node);
267
+ return false;
268
+ }
269
+ if (this.textMasked.has(parentID) ||
270
+ (isInstance(node, Element) && (0, utils_js_1.hasOpenreplayAttribute)(node, 'masked'))) {
271
+ this.textMasked.add(id);
272
+ }
257
273
  }
258
274
  let sibling = node.previousSibling;
259
275
  while (sibling !== null) {
@@ -266,7 +282,7 @@ class Observer {
266
282
  sibling = sibling.previousSibling;
267
283
  }
268
284
  if (sibling === null) {
269
- this.indexes[id] = 0;
285
+ this.indexes[id] = 0; //
270
286
  }
271
287
  const isNew = this.recents[id];
272
288
  const index = this.indexes[id];
@@ -276,7 +292,7 @@ class Observer {
276
292
  if (isNew === true) {
277
293
  if (isInstance(node, Element)) {
278
294
  if (parentID !== undefined) {
279
- this.app.send(new messages_1.CreateElementNode(id, parentID, index, node.tagName, isSVGElement(node)));
295
+ this.app.send(new index_js_1.CreateElementNode(id, parentID, index, node.tagName, isSVGElement(node)));
280
296
  }
281
297
  for (let i = 0; i < node.attributes.length; i++) {
282
298
  const attr = node.attributes[i];
@@ -285,13 +301,13 @@ class Observer {
285
301
  }
286
302
  else if (isInstance(node, Text)) {
287
303
  // for text node id != 0, hence parentID !== undefined and parent is Element
288
- this.app.send(new messages_1.CreateTextNode(id, parentID, index));
304
+ this.app.send(new index_js_1.CreateTextNode(id, parentID, index));
289
305
  this.sendNodeData(id, parent, node.data);
290
306
  }
291
307
  return true;
292
308
  }
293
309
  if (isNew === false && parentID !== undefined) {
294
- this.app.send(new messages_1.MoveNode(id, parentID, index));
310
+ this.app.send(new index_js_1.MoveNode(id, parentID, index));
295
311
  }
296
312
  const attr = this.attributesList[id];
297
313
  if (attr !== undefined) {
@@ -325,14 +341,19 @@ class Observer {
325
341
  commitNodes() {
326
342
  let node;
327
343
  for (let id = 0; id < this.recents.length; id++) {
344
+ // TODO: take a look at recents/ commitNode logic. why wasn't this check here before commitNode? only because of committed check inside?
345
+ if (!this.recents[id]) {
346
+ continue;
347
+ }
328
348
  this.commitNode(id);
329
- if (this.recents[id] === true && (node = this.app.nodes.getNode(id))) {
349
+ if (node = this.app.nodes.getNode(id)) {
330
350
  this.app.nodes.callNodeCallbacks(node);
331
351
  }
332
352
  }
333
353
  this.clear();
334
354
  }
335
- observeRoot(node, beforeCommit) {
355
+ // ISSSUE
356
+ observeRoot(node, beforeCommit, nodeToBind = node) {
336
357
  this.observer.observe(node, {
337
358
  childList: true,
338
359
  attributes: true,
@@ -341,7 +362,7 @@ class Observer {
341
362
  attributeOldValue: false,
342
363
  characterDataOldValue: false,
343
364
  });
344
- this.bindTree(node);
365
+ this.bindTree(nodeToBind);
345
366
  beforeCommit(this.app.nodes.getID(node));
346
367
  this.commitNodes();
347
368
  }
@@ -1,4 +1,4 @@
1
- import Observer from './observer';
1
+ import Observer from "./observer.js";
2
2
  export default class ShadowRootObserver extends Observer {
3
3
  observe(el: Element): void;
4
4
  }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const observer_1 = require("./observer");
4
- const messages_1 = require("../../messages");
5
- class ShadowRootObserver extends observer_1.default {
3
+ const observer_js_1 = require("./observer.js");
4
+ const index_js_1 = require("../../messages/index.js");
5
+ class ShadowRootObserver extends observer_js_1.default {
6
6
  observe(el) {
7
7
  const shRoot = el.shadowRoot;
8
8
  const hostID = this.app.nodes.getID(el);
@@ -14,7 +14,7 @@ class ShadowRootObserver extends observer_1.default {
14
14
  console.log("OpenReplay: Shadow Root was not bound");
15
15
  return;
16
16
  }
17
- this.app.send(messages_1.CreateIFrameDocument(hostID, rootID));
17
+ this.app.send((0, index_js_1.CreateIFrameDocument)(hostID, rootID));
18
18
  });
19
19
  }
20
20
  }
@@ -1,6 +1,6 @@
1
- import Observer from './observer';
2
- import type { Options as BaseOptions } from './observer';
3
- import type App from '../index';
1
+ import Observer from "./observer.js";
2
+ import type { Options as BaseOptions } from "./observer.js";
3
+ import App from "../index.js";
4
4
  export interface Options extends Partial<BaseOptions> {
5
5
  captureIFrames: boolean;
6
6
  }
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const observer_1 = require("./observer");
4
- const iframe_observer_1 = require("./iframe_observer");
5
- const shadow_root_observer_1 = require("./shadow_root_observer");
6
- const messages_1 = require("../../messages");
7
- class TopObserver extends observer_1.default {
3
+ const observer_js_1 = require("./observer.js");
4
+ const iframe_observer_js_1 = require("./iframe_observer.js");
5
+ const shadow_root_observer_js_1 = require("./shadow_root_observer.js");
6
+ const index_js_1 = require("../../messages/index.js");
7
+ const attachShadowNativeFn = Element.prototype.attachShadow;
8
+ class TopObserver extends observer_js_1.default {
8
9
  constructor(app, options) {
9
10
  super(app, Object.assign({
10
11
  captureIFrames: false
@@ -13,32 +14,21 @@ class TopObserver extends observer_1.default {
13
14
  this.shadowRootObservers = [];
14
15
  // IFrames
15
16
  this.app.nodes.attachNodeCallback(node => {
16
- if (observer_1.isInstance(node, HTMLIFrameElement) &&
17
+ if ((0, observer_js_1.isInstance)(node, HTMLIFrameElement) &&
17
18
  (this.options.captureIFrames || node.getAttribute("data-openreplay-capture"))) {
18
19
  this.handleIframe(node);
19
20
  }
20
21
  });
21
22
  // ShadowDOM
22
23
  this.app.nodes.attachNodeCallback(node => {
23
- if (observer_1.isInstance(node, Element) && node.shadowRoot !== null) {
24
+ if ((0, observer_js_1.isInstance)(node, Element) && node.shadowRoot !== null) {
24
25
  this.handleShadowRoot(node.shadowRoot);
25
26
  }
26
27
  });
27
- const attachShadowNative = Element.prototype.attachShadow;
28
- const observer = this;
29
- Element.prototype.attachShadow = function () {
30
- const shadow = attachShadowNative.apply(this, arguments);
31
- if (app.active()) { // Is it necessary here?
32
- // TODO: clearify logic - sub-observation should happen only during main observation.
33
- // THat works well with node callbacks, but not here
34
- observer.handleShadowRoot(shadow);
35
- }
36
- return shadow;
37
- };
38
28
  }
39
29
  handleIframe(iframe) {
40
30
  let context = null;
41
- const handle = () => {
31
+ const handle = this.app.safe(() => {
42
32
  const id = this.app.nodes.getID(iframe);
43
33
  if (id === undefined) {
44
34
  return;
@@ -50,24 +40,38 @@ class TopObserver extends observer_1.default {
50
40
  if (!context) {
51
41
  return;
52
42
  }
53
- const observer = new iframe_observer_1.default(this.app, this.options, context);
43
+ const observer = new iframe_observer_js_1.default(this.app, this.options, context);
54
44
  this.iframeObservers.push(observer);
55
45
  observer.observe(iframe);
56
- };
46
+ });
57
47
  this.app.attachEventListener(iframe, "load", handle);
58
48
  handle();
59
49
  }
60
50
  handleShadowRoot(shRoot) {
61
- const observer = new shadow_root_observer_1.default(this.app, this.options, this.context);
51
+ const observer = new shadow_root_observer_js_1.default(this.app, this.options, this.context);
62
52
  this.shadowRootObservers.push(observer);
63
53
  observer.observe(shRoot.host);
64
54
  }
65
55
  observe() {
56
+ // Protection from several subsequent calls?
57
+ const observer = this;
58
+ Element.prototype.attachShadow = function () {
59
+ const shadow = attachShadowNativeFn.apply(this, arguments);
60
+ observer.handleShadowRoot(shadow);
61
+ return shadow;
62
+ };
63
+ // Can observe documentElement (<html>) here, because it is not supposed to be changing.
64
+ // However, it is possible in some exotic cases and may cause an ignorance of the newly created <html>
65
+ // In this case context.document have to be observed, but this will cause
66
+ // the change in the re-player behaviour caused by CreateDocument message:
67
+ // the 0-node ("fRoot") will become #document rather than documentElement as it is now.
68
+ // Alternatively - observe(#document) then bindNode(documentElement)
66
69
  this.observeRoot(this.context.document, () => {
67
- this.app.send(new messages_1.CreateDocument());
68
- });
70
+ this.app.send(new index_js_1.CreateDocument());
71
+ }, this.context.document.documentElement);
69
72
  }
70
73
  disconnect() {
74
+ Element.prototype.attachShadow = attachShadowNativeFn;
71
75
  this.iframeObservers.forEach(o => o.disconnect());
72
76
  this.iframeObservers = [];
73
77
  this.shadowRootObservers.forEach(o => o.disconnect());