55 %
66 % MLAPPTOOLS' public methods:
77 %
8- % aboutDojo - Return the dojo toolkit version .
8+ % aboutJSLibs - Return version information about certain JS libraries .
99 % fontColor - Modify font color.
1010 % fontWeight - Modify font weight.
1111 % getHTML - Return the full HTML code of a uifigure.
2929
3030 methods (Access = public , Static = true )
3131
32- function [dojoVersion ] = aboutDojo()
33- % A method for getting version info about the Dojo Toolkit visible by MATLAB.
32+ function [jsLibVersions ] = aboutJSLibs()
33+ % A method for getting version info about some JS libararies visible to MATLAB.
34+ % This includes the Dojo Toolkit and ReactJS.
3435
3536 if ~numel(matlab .internal .webwindowmanager .instance .findAllWebwindows())
3637 f= uifigure ; drawnow ; tmpWindowCreated = true ;
4041
4142 dojoVersion = matlab .internal .webwindowmanager .instance ...
4243 .windowList(1 ).executeJS(' dojo.version' );
43-
44+
45+ reactVersion = matlab .internal .webwindowmanager .instance ...
46+ .windowList(1 ).executeJS(...
47+ ' require("react/react.min").version;' );
4448 if tmpWindowCreated
4549 delete(f );
4650 end
51+
4752 % If MATLAB is sufficiently new, convert the JSON to a struct:
4853 if str2double(subsref(ver(' matlab' ), substruct(' .' ,' Version' ))) >= 9.1 % R2016b
49- dojoVersion = jsondecode(dojoVersion );
54+ dv = jsondecode(dojoVersion );
55+ dojoVersion = strrep(join(string(struct2cell(dv )),' .' ),' ..' ,' .' );
56+ reactVersion = jsondecode(reactVersion );
57+ else
58+ dojoVersion = strsplit(dojoVersion ,{' :' ,' ,' ,' "' ,' }' ,' {' });
59+ dojoVersion = char(strjoin(dojoVersion([3 ,5 ,7 ,10 ]),' .' ));
60+ reactVersion = reactVersion(2 : end - 1 );
5061 end
51- end % aboutDojo
62+ jsLibVersions = struct(' dojo' , dojoVersion , ' react_js' , reactVersion );
63+ end % aboutJSLibs
5264
5365 function fontColor(uiElement , newcolor )
5466 % A method for manipulating text color.
@@ -541,8 +553,13 @@ function waitTillWebwindowLoaded(hWebwindow, hFig)
541553end % classdef
542554
543555%{
544- Useful debugging code:
556+ --- Useful debugging commands ---
545557
546558jsprops = sort(jsondecode(win.executeJS('Object.keys(this)')));
547559
560+ ReactJS:
561+ win.executeJS('var R = require("react/react.min"); Object.keys(R)')
562+ win.executeJS('var R = require("react/react-dom.min"); Object.keys(R)')
563+
564+
548565%}
0 commit comments