@@ -883,83 +883,87 @@ else if (!global.CBOR)
883883 var listeners = null , branch , xTree , xxTree , isolatedBranch , endReached , currentType = type [ i ] ,
884884 nextType = type [ i + 1 ] , branches , _listeners ;
885885
886- if ( i === typeLength && tree . _listeners ) {
886+ if ( i === typeLength ) {
887887 //
888888 // If at the end of the event(s) list and the tree has listeners
889889 // invoke those listeners.
890890 //
891- if ( typeof tree . _listeners === 'function' ) {
892- handlers && handlers . push ( tree . _listeners ) ;
893- return [ tree ] ;
894- } else {
895- handlers && handlers . push . apply ( handlers , tree . _listeners ) ;
896- return [ tree ] ;
891+
892+ if ( tree . _listeners ) {
893+ if ( typeof tree . _listeners === 'function' ) {
894+ handlers && handlers . push ( tree . _listeners ) ;
895+ listeners = [ tree ] ;
896+ } else {
897+ handlers && handlers . push . apply ( handlers , tree . _listeners ) ;
898+ listeners = [ tree ] ;
899+ }
897900 }
898- }
901+ } else {
899902
900- if ( currentType === '*' ) {
901- //
902- // If the event emitted is '*' at this part
903- // or there is a concrete match at this patch
904- //
905- branches = ownKeys ( tree ) ;
906- n = branches . length ;
907- while ( n -- > 0 ) {
908- branch = branches [ n ] ;
909- if ( branch !== '_listeners' ) {
910- _listeners = searchListenerTree ( handlers , type , tree [ branch ] , i + 1 , typeLength ) ;
911- if ( _listeners ) {
912- if ( listeners ) {
913- listeners . push . apply ( listeners , _listeners ) ;
914- } else {
915- listeners = _listeners ;
903+ if ( currentType === '*' ) {
904+ //
905+ // If the event emitted is '*' at this part
906+ // or there is a concrete match at this patch
907+ //
908+ branches = ownKeys ( tree ) ;
909+ n = branches . length ;
910+ while ( n -- > 0 ) {
911+ branch = branches [ n ] ;
912+ if ( branch !== '_listeners' ) {
913+ _listeners = searchListenerTree ( handlers , type , tree [ branch ] , i + 1 , typeLength ) ;
914+ if ( _listeners ) {
915+ if ( listeners ) {
916+ listeners . push . apply ( listeners , _listeners ) ;
917+ } else {
918+ listeners = _listeners ;
919+ }
916920 }
917921 }
918922 }
919- }
920- return listeners ;
921- } else if ( currentType === '**' ) {
922- endReached = ( i + 1 === typeLength || ( i + 2 === typeLength && nextType === '*' ) ) ;
923- if ( endReached && tree . _listeners ) {
924- // The next element has a _listeners, add it to the handlers.
925- listeners = searchListenerTree ( handlers , type , tree , typeLength , typeLength ) ;
926- }
923+ return listeners ;
924+ } else if ( currentType === '**' ) {
925+ endReached = ( i + 1 === typeLength || ( i + 2 === typeLength && nextType === '*' ) ) ;
926+ if ( endReached && tree . _listeners ) {
927+ // The next element has a _listeners, add it to the handlers.
928+ listeners = searchListenerTree ( handlers , type , tree , typeLength , typeLength ) ;
929+ }
927930
928- branches = ownKeys ( tree ) ;
929- n = branches . length ;
930- while ( n -- > 0 ) {
931- branch = branches [ n ] ;
932- if ( branch !== '_listeners' ) {
933- if ( branch === '*' || branch === '**' ) {
934- if ( tree [ branch ] . _listeners && ! endReached ) {
935- _listeners = searchListenerTree ( handlers , type , tree [ branch ] , typeLength , typeLength ) ;
936- if ( _listeners ) {
937- if ( listeners ) {
938- listeners . push . apply ( listeners , _listeners ) ;
939- } else {
940- listeners = _listeners ;
931+ branches = ownKeys ( tree ) ;
932+ n = branches . length ;
933+ while ( n -- > 0 ) {
934+ branch = branches [ n ] ;
935+ if ( branch !== '_listeners' ) {
936+ if ( branch === '*' || branch === '**' ) {
937+ if ( tree [ branch ] . _listeners && ! endReached ) {
938+ _listeners = searchListenerTree ( handlers , type , tree [ branch ] , typeLength , typeLength ) ;
939+ if ( _listeners ) {
940+ if ( listeners ) {
941+ listeners . push . apply ( listeners , _listeners ) ;
942+ } else {
943+ listeners = _listeners ;
944+ }
941945 }
942946 }
947+ _listeners = searchListenerTree ( handlers , type , tree [ branch ] , i , typeLength ) ;
948+ } else if ( branch === nextType ) {
949+ _listeners = searchListenerTree ( handlers , type , tree [ branch ] , i + 2 , typeLength ) ;
950+ } else {
951+ // No match on this one, shift into the tree but not in the type array.
952+ _listeners = searchListenerTree ( handlers , type , tree [ branch ] , i , typeLength ) ;
943953 }
944- _listeners = searchListenerTree ( handlers , type , tree [ branch ] , i , typeLength ) ;
945- } else if ( branch === nextType ) {
946- _listeners = searchListenerTree ( handlers , type , tree [ branch ] , i + 2 , typeLength ) ;
947- } else {
948- // No match on this one, shift into the tree but not in the type array.
949- _listeners = searchListenerTree ( handlers , type , tree [ branch ] , i , typeLength ) ;
950- }
951- if ( _listeners ) {
952- if ( listeners ) {
953- listeners . push . apply ( listeners , _listeners ) ;
954- } else {
955- listeners = _listeners ;
954+ if ( _listeners ) {
955+ if ( listeners ) {
956+ listeners . push . apply ( listeners , _listeners ) ;
957+ } else {
958+ listeners = _listeners ;
959+ }
956960 }
957961 }
958962 }
963+ return listeners ;
964+ } else if ( tree [ currentType ] ) {
965+ listeners = searchListenerTree ( handlers , type , tree [ currentType ] , i + 1 , typeLength ) ;
959966 }
960- return listeners ;
961- } else if ( tree [ currentType ] ) {
962- listeners = searchListenerTree ( handlers , type , tree [ currentType ] , i + 1 , typeLength ) ;
963967 }
964968
965969 xTree = tree [ '*' ] ;
@@ -3880,7 +3884,7 @@ Ros.prototype.getTopicsAndRawTypes = function(callback, failedCallback) {
38803884
38813885module . exports = Ros ;
38823886
3883- } , { "../util/workerSocket" :48 , "./Service" :17 , "./ServiceRequest" :18 , "./SocketAdapter.js" :20 , "eventemitter2" :2 , "object-assign" :3 , "ws" :44 } ] , 17 :[ function ( require , module , exports ) {
3887+ } , { "../util/workerSocket" :48 , "./Service" :17 , "./ServiceRequest" :18 , "./SocketAdapter.js" :20 , "eventemitter2" :2 , "object-assign" :3 , "ws" :45 } ] , 17 :[ function ( require , module , exports ) {
38843888/**
38853889 * @fileoverview
38863890 * @author Brandon Alexander - [email protected] @@ -4176,7 +4180,7 @@ function SocketAdapter(client) {
41764180
41774181module . exports = SocketAdapter ;
41784182
4179- } , { "../util/cborTypedArrayTags" :43 , "../util/decompressPng" :46 , "cbor-js" :1 } ] , 21 :[ function ( require , module , exports ) {
4183+ } , { "../util/cborTypedArrayTags" :43 , "../util/decompressPng" :47 , "cbor-js" :1 } ] , 21 :[ function ( require , module , exports ) {
41804184/**
41814185 * @fileoverview
41824186 * @author Brandon Alexander - [email protected] @@ -4753,6 +4757,7 @@ function TFClient(options) {
47534757 this . frameInfos = { } ;
47544758 this . republisherUpdateRequested = false ;
47554759 this . _subscribeCB = null ;
4760+ this . _isDisposed = false ;
47564761
47574762 // Create an Action client
47584763 this . actionClient = new ActionClient ( {
@@ -4845,6 +4850,12 @@ TFClient.prototype.updateGoal = function() {
48454850 * @param response the service response containing the topic name
48464851 */
48474852TFClient . prototype . processResponse = function ( response ) {
4853+ // Do not setup a topic subscription if already disposed. Prevents a race condition where
4854+ // The dispose() function is called before the service call receives a response.
4855+ if ( this . _isDisposed ) {
4856+ return ;
4857+ }
4858+
48484859 // if we subscribed to a topic before, unsubscribe so
48494860 // the republisher stops publishing it
48504861 if ( this . currentTopic ) {
@@ -4917,6 +4928,7 @@ TFClient.prototype.unsubscribe = function(frameID, callback) {
49174928 * Unsubscribe and unadvertise all topics associated with this TFClient.
49184929 */
49194930TFClient . prototype . dispose = function ( ) {
4931+ this . _isDisposed = true ;
49204932 this . actionClient . dispose ( ) ;
49214933 if ( this . currentTopic ) {
49224934 this . currentTopic . unsubscribe ( this . _subscribeCB ) ;
@@ -5223,15 +5235,15 @@ function UrdfMesh(options) {
52235235module . exports = UrdfMesh ;
52245236} , { "../math/Vector3" :26 , "./UrdfTypes" :40 } ] , 38 :[ function ( require , module , exports ) {
52255237/**
5226- * @fileOverview
5238+ * @fileOverview
52275239 * @author Benjamin Pitzer - [email protected] 52285240 * @author Russell Toris - [email protected] 52295241 */
52305242
52315243var UrdfMaterial = require ( './UrdfMaterial' ) ;
52325244var UrdfLink = require ( './UrdfLink' ) ;
52335245var UrdfJoint = require ( './UrdfJoint' ) ;
5234- var DOMParser = require ( 'xmldom' ) . DOMParser ;
5246+ var DOMParser = require ( '@xmldom/ xmldom' ) . DOMParser ;
52355247
52365248// See https://developer.mozilla.org/docs/XPathResult#Constants
52375249var XPATH_FIRST_ORDERED_NODE_TYPE = 9 ;
@@ -5294,7 +5306,7 @@ function UrdfModel(options) {
52945306 // Check for a material
52955307 for ( var j = 0 ; j < link . visuals . length ; j ++ )
52965308 {
5297- var mat = link . visuals [ j ] . material ;
5309+ var mat = link . visuals [ j ] . material ;
52985310 if ( mat !== null && mat . name ) {
52995311 if ( this . materials [ mat . name ] !== void 0 ) {
53005312 link . visuals [ j ] . material = this . materials [ mat . name ] ;
@@ -5318,7 +5330,7 @@ function UrdfModel(options) {
53185330
53195331module . exports = UrdfModel ;
53205332
5321- } , { "./UrdfJoint" :34 , "./UrdfLink" :35 , "./UrdfMaterial" :36 , "xmldom" : 47 } ] , 39 :[ function ( require , module , exports ) {
5333+ } , { "./UrdfJoint" :34 , "./UrdfLink" :35 , "./UrdfMaterial" :36 , "@ xmldom/xmldom" : 44 } ] , 39 :[ function ( require , module , exports ) {
53225334/**
53235335 * @fileOverview
53245336 * @author Benjamin Pitzer - [email protected] @@ -5613,14 +5625,19 @@ if (typeof module !== 'undefined' && module.exports) {
56135625}
56145626
56155627} , { } ] , 44 :[ function ( require , module , exports ) {
5616- module . exports = typeof window !== 'undefined' ? window . WebSocket : WebSocket ;
5628+ exports . DOMImplementation = window . DOMImplementation ;
5629+ exports . XMLSerializer = window . XMLSerializer ;
5630+ exports . DOMParser = window . DOMParser ;
56175631
56185632} , { } ] , 45 :[ function ( require , module , exports ) {
5633+ module . exports = typeof window !== 'undefined' ? window . WebSocket : WebSocket ;
5634+
5635+ } , { } ] , 46 :[ function ( require , module , exports ) {
56195636/* global document */
56205637module . exports = function Canvas ( ) {
56215638 return document . createElement ( 'canvas' ) ;
56225639} ;
5623- } , { } ] , 46 :[ function ( require , module , exports ) {
5640+ } , { } ] , 47 :[ function ( require , module , exports ) {
56245641/**
56255642 * @fileOverview
56265643 * @author Graeme Yeates - github.com/megawac
@@ -5678,12 +5695,7 @@ function decompressPng(data, callback) {
56785695
56795696module . exports = decompressPng ;
56805697
5681- } , { "canvas" :45 } ] , 47 :[ function ( require , module , exports ) {
5682- exports . DOMImplementation = window . DOMImplementation ;
5683- exports . XMLSerializer = window . XMLSerializer ;
5684- exports . DOMParser = window . DOMParser ;
5685-
5686- } , { } ] , 48 :[ function ( require , module , exports ) {
5698+ } , { "canvas" :46 } ] , 48 :[ function ( require , module , exports ) {
56875699var work = require ( 'webworkify' ) ;
56885700var workerSocketImpl = require ( './workerSocketImpl' ) ;
56895701
@@ -5779,4 +5791,4 @@ module.exports = function(self) {
57795791 } ) ;
57805792} ;
57815793
5782- } , { "ws" :44 } ] } , { } , [ 8 ] ) ;
5794+ } , { "ws" :45 } ] } , { } , [ 8 ] ) ;
0 commit comments