@@ -206,15 +206,18 @@ const transpile = {
206
206
// Replace initial ROS3D assignment
207
207
initialROS3DAssignment : [
208
208
// from
209
- / v a r R O S 3 D = R O S 3 D \| \| \{ \n R E V I S I O N \: ' 0 . 1 8 . 0 ' \n \} ; / m,
209
+ / v a r R O S 3 D = R O S 3 D \| \| \{ \n R E V I S I O N \: ' ( [ 0 - 9 ] + \. [ 0 - 9 ] + \. [ 0 - 9 ] + ) ' \n \} ; / m,
210
210
// to
211
- `export var REVISION = '0.18.0';` ,
211
+ ( match , $1 ) => {
212
+ const revision = $1
213
+ return `export var REVISION = '${ revision } ';`
214
+ } ,
212
215
] ,
213
216
// Replace mutations with exported properties
214
- exportedProperites : ( filepath ) => [
217
+ exportedProperties : ( filepath ) => [
215
218
// from:
216
219
// ROS3D.MARKER_ARROW = 0;
217
- / \n R O S 3 D \. ( .* ) \s + ? = \s + ? ( .* ) / g,
220
+ / \n R O S 3 D \. ( .* ) \s * = \s * ( .* ) / g,
218
221
// to:
219
222
// export var MARKER_ARROW = 0;
220
223
( match , $1 , $2 ) => {
@@ -268,7 +271,7 @@ const transpile = {
268
271
buildInheritanceIndexViaProto : [
269
272
// from:
270
273
// ROS3D.PoseWithCovariance.prototype.__proto__ = THREE.Object3D.prototype;
271
- / R O S 3 D .( \w + ) .p r o t o t y p e ._ _ p r o t o _ _ = ( .* ) .p r o t o t y p e ; [ \r \n ] ? / g,
274
+ / R O S 3 D \ .( \w + ) \ .p r o t o t y p e \ ._ _ p r o t o _ _ = ( .* ) \ .p r o t o t y p e ; [ \r \n ] ? / g,
272
275
// to:
273
276
// set PoseWithCovariance to subclass from THREE.Object3D in inheritance index
274
277
( match , $1 , $2 ) => {
@@ -282,7 +285,7 @@ const transpile = {
282
285
buildInheritanceIndexViaObjectAssign : [
283
286
// from:
284
287
// Object.assign(InteractiveMarker.prototype, THREE.EventDispatcher.prototype);
285
- / O b j e c t .a s s i g n \( ( \w + ) .p r o t o t y p e , ( .* ) .p r o t o t y p e \) ; / g,
288
+ / O b j e c t \ .a s s i g n \( ( \w + ) \ .p r o t o t y p e , \s * ( .* ) \ .p r o t o t y p e \) ; / g,
286
289
// to:
287
290
// set InteractiveMarker to subclass from THREE.EventDispatcher in inheritance index
288
291
( match , $1 , $2 ) => {
@@ -295,8 +298,8 @@ const transpile = {
295
298
// Refactor methods
296
299
methods : [
297
300
// from:
298
- // ROS3D.Arrow2.prototype.dispose = function() { ... };
299
- / R O S 3 D .( \w + ) .p r o t o t y p e .( \w + ) = f u n c t i o n | f u n c t i o n \s + ? ( \w + ) / g,
301
+ // ROS3D.Arrow2.prototype.dispose = function () { ... };
302
+ / R O S 3 D \ .( \w + ) \ .p r o t o t y p e \ .( \w + ) \s * = \s * f u n c t i o n \s * | f u n c t i o n \s + ( \w + ) / g,
300
303
// to:
301
304
// dispose() { ... };
302
305
( match , $1 , $2 , $3 ) => {
@@ -324,10 +327,10 @@ const transpile = {
324
327
constructors : ( filepath , state = { foundConstructor : false } ) => [
325
328
// from:
326
329
// ROS3D.Arrow2 = function(options) { ... };
327
- / R O S 3 D .( \w + ) \s * = \s * f u n c t i o n / g,
330
+ / R O S 3 D \ .( \w + ) \s * = \s * f u n c t i o n \s * \( ( . * ) \) / g,
328
331
// to:
329
332
// constructor(options) { ... };
330
- ( match , $1 ) => {
333
+ ( match , $1 , $2 ) => {
331
334
const isClass = isFileClass ( filepath , $1 )
332
335
// if (isClass1 !== isClass2) {
333
336
// logWarning('class mismatch', {
@@ -339,13 +342,14 @@ const transpile = {
339
342
// }
340
343
if ( isClass ) {
341
344
if ( state . foundConstructor ) {
342
- logError ( 'already found a constructor in this file...' , { match, $1 } )
345
+ logError ( 'Already found a constructor in this file...' , { match, $1, $2 } )
343
346
}
344
347
state . foundConstructor = true
345
348
if ( debugRules . logConstructors ) {
346
- logInfo ( 'found constructor' , { match, $1 } )
349
+ logInfo ( 'Found constructor' , { match, $1, $2 } )
347
350
}
348
- return 'constructor'
351
+ const arguments = $2
352
+ return `constructor(${ arguments } )`
349
353
} else {
350
354
return match
351
355
}
@@ -434,7 +438,7 @@ const transpile = {
434
438
// }
435
439
// /.*(\*\/).*|[\r\n]+$(?:[\r\n]+$)+((?![\r\n]+))|.*/gm,
436
440
// /(\/\*\*(?:$|[.\r\n])*\*\/(?:$|[\s\r\n])*constructor\(.*)|[\r\n]+$(?:[\r\n]+$)+((?![\r\n]+))|.*/gm,
437
- / ( (?: \/ \* \* (?: (?: \* [ ^ / ] | [ ^ * ] ) + ?) \* \/ ) (?: [ \s \r \n ] ) * c o n s t r u c t o r \( .* ) | $ (?: [ \r \n ] $ ) * ( (? ! [ \r \n ] ) ) | .+ / gm,
441
+ / ( (?: \/ \* \* (?: (?: \* [ ^ / ] | [ ^ * ] ) + ?) \* \/ ) (?: [ \s \r \n ] ) * c o n s t r u c t o r \s * \ ( .* ) | $ (?: [ \r \n ] $ ) * ( (? ! [ \r \n ] ) ) | .+ / gm,
438
442
// to:
439
443
// export class Arrow2 extends THREE.ArrowHelper {
440
444
// constructor(options) {
@@ -671,7 +675,7 @@ const transpileToEs6 = function (content, filepath, grunt) {
671
675
const transpileConstructors = transpile . constructors ( filepath )
672
676
const transpileSuperCalls = transpile . superCalls ( filepath )
673
677
const transpileClasses = transpile . classes ( filepath )
674
- const transpileExportedProperites = transpile . exportedProperites ( filepath )
678
+ const transpileExportedProperties = transpile . exportedProperties ( filepath )
675
679
676
680
return transpiled
677
681
. replace ( ...transpileInternalDependencies )
@@ -682,7 +686,7 @@ const transpileToEs6 = function (content, filepath, grunt) {
682
686
. replace ( ...transpileConstructors )
683
687
. replace ( ...transpileSuperCalls )
684
688
. replace ( ...transpileClasses )
685
- . replace ( ...transpileExportedProperites )
689
+ . replace ( ...transpileExportedProperties )
686
690
}
687
691
688
692
// Injects es6 imports based on dependency and export
0 commit comments