1+ "use strict" ;
2+
3+ function _typeof ( obj ) { "@babel/helpers - typeof" ; if ( typeof Symbol === "function" && typeof Symbol . iterator === "symbol" ) { _typeof = function _typeof ( obj ) { return typeof obj ; } ; } else { _typeof = function _typeof ( obj ) { return obj && typeof Symbol === "function" && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } ; } return _typeof ( obj ) ; }
4+
5+ Object . defineProperty ( exports , "__esModule" , {
6+ value : true
7+ } ) ;
8+ exports . default = void 0 ;
9+
10+ var _react = _interopRequireDefault ( require ( "react" ) ) ;
11+
12+ require ( "./retool.css" ) ;
13+
14+ function _interopRequireDefault ( obj ) { return obj && obj . __esModule ? obj : { default : obj } ; }
15+
16+ function ownKeys ( object , enumerableOnly ) { var keys = Object . keys ( object ) ; if ( Object . getOwnPropertySymbols ) { var symbols = Object . getOwnPropertySymbols ( object ) ; if ( enumerableOnly ) symbols = symbols . filter ( function ( sym ) { return Object . getOwnPropertyDescriptor ( object , sym ) . enumerable ; } ) ; keys . push . apply ( keys , symbols ) ; } return keys ; }
17+
18+ function _objectSpread ( target ) { for ( var i = 1 ; i < arguments . length ; i ++ ) { var source = arguments [ i ] != null ? arguments [ i ] : { } ; if ( i % 2 ) { ownKeys ( Object ( source ) , true ) . forEach ( function ( key ) { _defineProperty ( target , key , source [ key ] ) ; } ) ; } else if ( Object . getOwnPropertyDescriptors ) { Object . defineProperties ( target , Object . getOwnPropertyDescriptors ( source ) ) ; } else { ownKeys ( Object ( source ) ) . forEach ( function ( key ) { Object . defineProperty ( target , key , Object . getOwnPropertyDescriptor ( source , key ) ) ; } ) ; } } return target ; }
19+
20+ function _classCallCheck ( instance , Constructor ) { if ( ! ( instance instanceof Constructor ) ) { throw new TypeError ( "Cannot call a class as a function" ) ; } }
21+
22+ function _defineProperties ( target , props ) { for ( var i = 0 ; i < props . length ; i ++ ) { var descriptor = props [ i ] ; descriptor . enumerable = descriptor . enumerable || false ; descriptor . configurable = true ; if ( "value" in descriptor ) descriptor . writable = true ; Object . defineProperty ( target , descriptor . key , descriptor ) ; } }
23+
24+ function _createClass ( Constructor , protoProps , staticProps ) { if ( protoProps ) _defineProperties ( Constructor . prototype , protoProps ) ; if ( staticProps ) _defineProperties ( Constructor , staticProps ) ; return Constructor ; }
25+
26+ function _inherits ( subClass , superClass ) { if ( typeof superClass !== "function" && superClass !== null ) { throw new TypeError ( "Super expression must either be null or a function" ) ; } subClass . prototype = Object . create ( superClass && superClass . prototype , { constructor : { value : subClass , writable : true , configurable : true } } ) ; if ( superClass ) _setPrototypeOf ( subClass , superClass ) ; }
27+
28+ function _setPrototypeOf ( o , p ) { _setPrototypeOf = Object . setPrototypeOf || function _setPrototypeOf ( o , p ) { o . __proto__ = p ; return o ; } ; return _setPrototypeOf ( o , p ) ; }
29+
30+ function _createSuper ( Derived ) { var hasNativeReflectConstruct = _isNativeReflectConstruct ( ) ; return function _createSuperInternal ( ) { var Super = _getPrototypeOf ( Derived ) , result ; if ( hasNativeReflectConstruct ) { var NewTarget = _getPrototypeOf ( this ) . constructor ; result = Reflect . construct ( Super , arguments , NewTarget ) ; } else { result = Super . apply ( this , arguments ) ; } return _possibleConstructorReturn ( this , result ) ; } ; }
31+
32+ function _possibleConstructorReturn ( self , call ) { if ( call && ( _typeof ( call ) === "object" || typeof call === "function" ) ) { return call ; } return _assertThisInitialized ( self ) ; }
33+
34+ function _assertThisInitialized ( self ) { if ( self === void 0 ) { throw new ReferenceError ( "this hasn't been initialised - super() hasn't been called" ) ; } return self ; }
35+
36+ function _isNativeReflectConstruct ( ) { if ( typeof Reflect === "undefined" || ! Reflect . construct ) return false ; if ( Reflect . construct . sham ) return false ; if ( typeof Proxy === "function" ) return true ; try { Boolean . prototype . valueOf . call ( Reflect . construct ( Boolean , [ ] , function ( ) { } ) ) ; return true ; } catch ( e ) { return false ; } }
37+
38+ function _getPrototypeOf ( o ) { _getPrototypeOf = Object . setPrototypeOf ? Object . getPrototypeOf : function _getPrototypeOf ( o ) { return o . __proto__ || Object . getPrototypeOf ( o ) ; } ; return _getPrototypeOf ( o ) ; }
39+
140function _defineProperty ( obj , key , value ) { if ( key in obj ) { Object . defineProperty ( obj , key , { value : value , enumerable : true , configurable : true , writable : true } ) ; } else { obj [ key ] = value ; } return obj ; }
241
3- import React from 'react' ;
4- import './retool.css' ;
42+ var Retool = /*#__PURE__*/ function ( _React$Component ) {
43+ _inherits ( Retool , _React$Component ) ;
44+
45+ var _super = _createSuper ( Retool ) ;
546
6- class Retool extends React . Component {
7- constructor ( props ) {
8- super ( props ) ;
47+ function Retool ( props ) {
48+ var _this ;
949
10- _defineProperty ( this , "startListening" , ( ) => {
11- window . addEventListener ( 'message' , e => this . handle ( e ) ) ;
50+ _classCallCheck ( this , Retool ) ;
51+
52+ _this = _super . call ( this , props ) ;
53+
54+ _defineProperty ( _assertThisInitialized ( _this ) , "startListening" , function ( ) {
55+ window . addEventListener ( 'message' , function ( e ) {
56+ return _this . handle ( e ) ;
57+ } ) ;
1258 } ) ;
1359
14- _defineProperty ( this , "startWatchers" , ( ) => {
15- var watcherKeys = Object . keys ( this . state . elementWatchers ) ;
60+ _defineProperty ( _assertThisInitialized ( _this ) , "startWatchers" , function ( ) {
61+ var watcherKeys = Object . keys ( _this . state . elementWatchers ) ;
1662
1763 for ( var i = 0 ; i < watcherKeys . length ; i ++ ) {
1864 var key = watcherKeys [ i ] ;
19- var watcher = this . state . elementWatchers [ key ] ;
65+ var watcher = _this . state . elementWatchers [ key ] ;
2066 var selector = watcher . selector ;
2167 var node = document . querySelector ( selector ) ;
22- var value = node ? .textContent ;
68+ var value = node === null || node === void 0 ? void 0 : node . textContent ;
2369
2470 if ( value !== watcher . prevValue ) {
2571 watcher . prevValue = value ;
@@ -32,71 +78,89 @@ class Retool extends React.Component {
3278 }
3379 }
3480
35- setTimeout ( this . startWatchers , 100 ) ;
81+ setTimeout ( _this . startWatchers , 100 ) ;
3682 } ) ;
3783
38- _defineProperty ( this , "createOrReplaceWatcher" , ( selector , pageName , queryId ) => {
84+ _defineProperty ( _assertThisInitialized ( _this ) , "createOrReplaceWatcher" , function ( selector , pageName , queryId ) {
3985 var watcherId = pageName + '-' + queryId ;
40- var watchers = { ...this . state . elementWatchers
41- } ;
86+
87+ var watchers = _objectSpread ( { } , _this . state . elementWatchers ) ;
88+
4289 watchers [ watcherId ] = {
43- iframe : this . iframe ,
90+ iframe : _this . iframe ,
4491 selector : selector ,
4592 pageName : pageName ,
4693 queryId : queryId ,
4794 prevValue : null
4895 } ;
49- this . setState ( {
96+
97+ _this . setState ( {
5098 elementWatchers : watchers
5199 } ) ;
52100 } ) ;
53101
54- _defineProperty ( this , "handle" , event => {
55- if ( ! this . iframe . contentWindow ) return ;
102+ _defineProperty ( _assertThisInitialized ( _this ) , "handle" , function ( event ) {
103+ if ( ! _this . iframe . contentWindow ) return ;
56104 var node ;
57105
58106 if ( event . data . type === 'PARENT_WINDOW_QUERY' ) {
107+ var _node ;
108+
59109 node = document . querySelector ( event . data . selector ) ;
60- this . createOrReplaceWatcher ( event . data . selector , event . data . pageName , event . data . id ) ;
61- this . iframe . contentWindow . postMessage ( {
110+
111+ _this . createOrReplaceWatcher ( event . data . selector , event . data . pageName , event . data . id ) ;
112+
113+ _this . iframe . contentWindow . postMessage ( {
62114 type : 'PARENT_WINDOW_RESULT' ,
63- result : node ? .textContent ,
115+ result : ( _node = node ) === null || _node === void 0 ? void 0 : _node . textContent ,
64116 id : event . data . id ,
65117 pageName : event . data . pageName
66118 } , '*' ) ;
67119 }
68120
69121 if ( event . data . type === 'PARENT_WINDOW_PREVIEW_QUERY' ) {
122+ var _node2 ;
123+
70124 node = document . querySelector ( event . data . selector ) ;
71- this . iframe . contentWindow . postMessage ( {
125+
126+ _this . iframe . contentWindow . postMessage ( {
72127 type : 'PARENT_WINDOW_PREVIEW_RESULT' ,
73- result : node ? .textContent ,
128+ result : ( _node2 = node ) === null || _node2 === void 0 ? void 0 : _node2 . textContent ,
74129 id : event . data . id
75130 } , '*' ) ;
76131 }
77132 } ) ;
78133
79- this . state = {
134+ _this . state = {
80135 url : props . url ,
81136 elementWatchers : { }
82137 } ;
138+ return _this ;
83139 }
84140
85- componentDidMount ( ) {
86- this . startListening ( ) ;
87- this . startWatchers ( ) ;
88- }
89-
90- render ( ) {
91- return /*#__PURE__*/ React . createElement ( "iframe" , {
92- frameBorder : "none" ,
93- src : this . state . url ,
94- ref : e => {
95- this . iframe = e ;
96- }
97- } ) ;
98- }
141+ _createClass ( Retool , [ {
142+ key : "componentDidMount" ,
143+ value : function componentDidMount ( ) {
144+ this . startListening ( ) ;
145+ this . startWatchers ( ) ;
146+ }
147+ } , {
148+ key : "render" ,
149+ value : function render ( ) {
150+ var _this2 = this ;
151+
152+ return /*#__PURE__*/ _react . default . createElement ( "iframe" , {
153+ frameBorder : "none" ,
154+ src : this . state . url ,
155+ ref : function ref ( e ) {
156+ _this2 . iframe = e ;
157+ }
158+ } ) ;
159+ }
160+ } ] ) ;
99161
100- }
162+ return Retool ;
163+ } ( _react . default . Component ) ;
101164
102- export default Retool ;
165+ var _default = Retool ;
166+ exports . default = _default ;
0 commit comments