Changeset 2371
- Timestamp:
- 2008-08-20 15:07:30 (3 months ago)
- Location:
- CKEditor/branches/prototype
- Files:
-
- 14 modified
-
ckeditor.pack (modified) (2 diffs)
-
_dev/packager/ckpackager/includes/packagefile.js (modified) (2 diffs)
-
_dev/packager/ckpackager/includes/packager.js (modified) (1 diff)
-
_dev/packager/ckpackager/includes/scope.js (modified) (1 diff)
-
_dev/packager/ckpackager/includes/scriptcompressor.js (modified) (9 diffs)
-
_dev/packager/ckpackager/test/test.js (modified) (1 diff)
-
_source/core/ckeditor_base.js (modified) (2 diffs)
-
_source/core/dom/document.js (modified) (1 diff)
-
_source/core/dom/element.js (modified) (1 diff)
-
_source/core/dom.js (modified) (1 diff)
-
_source/core/dtd.js (modified) (1 diff)
-
_source/core/env.js (modified) (1 diff)
-
_source/core/tools.js (modified) (1 diff)
-
_source/core/ui.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
CKEditor/branches/prototype/ckeditor.pack
r2366 r2371 30 30 { 31 31 output : 'ckeditor_basic.js', 32 wrap : true, 32 33 files : 33 34 [ … … 42 43 { 43 44 output : 'ckeditor.js', 45 wrap : true, 44 46 files : 45 47 [ -
CKEditor/branches/prototype/_dev/packager/ckpackager/includes/packagefile.js
r2366 r2371 18 18 this.renameGlobals = false; 19 19 this.compactJavascript = true; 20 this.wrap = false; 20 21 this.files = []; 21 22 }; … … 41 42 42 43 var compressed = this.compactJavascript ? 43 CKPACKAGER.scriptCompressor.compress( source, this.renameGlobals, this.constants, this.noCheck ) :44 CKPACKAGER.scriptCompressor.compress( source, this.renameGlobals, this.constants, this.noCheck, this.wrap ) : 44 45 source; 45 46 -
CKEditor/branches/prototype/_dev/packager/ckpackager/includes/packager.js
r2366 r2371 58 58 packFile.compactJavascript = packDefinition.compactJavascript; 59 59 60 if ( typeof packDefinition.wrap != 'undefined' ) 61 packFile.wrap = packDefinition.wrap; 62 60 63 var files = packDefinition.files; 61 64 -
CKEditor/branches/prototype/_dev/packager/ckpackager/includes/scope.js
r2366 r2371 144 144 this.declaredNames[ name ] = 1; 145 145 }; 146 147 CKPACKAGER.scope.prototype.addRenamedRef = function( name ) 148 { 149 return this.names[ name ] = getNextName( this ); 150 }; 146 151 })(); -
CKEditor/branches/prototype/_dev/packager/ckpackager/includes/scriptcompressor.js
r2370 r2371 24 24 output, 25 25 outputSize = 0, 26 maxSize = 2 000;26 maxSize = 2500; 27 27 28 28 var lang = {}; … … 156 156 isReserved.words = { 'break':1,'else':1,'new':1,'var':1,'case':1,'finally':1,'return':1,'void':1,'catch':1,'for':1,'switch':1,'while':1,'continue':1,'function':1,'this':1,'with':1,'default':1,'if':1,'throw':1,'delete':1,'in':1,'try':1,'do':1,'instanceof':1,'typeof':1,'abstract':1,'enum':1,'int':1,'short':1,'boolean':1,'export':1,'interface':1,'static':1,'byte':1,'extends':1,'long':1,'super':1,'char':1,'final':1,'native':1,'synchronized':1,'class':1,'float':1,'package':1,'throws':1,'const':1,'goto':1,'private':1,'transient':1,'debugger':1,'implements':1,'protected':1,'volatile':1,'double':1,'import':1,'public':1 }; 157 157 158 var getPropParts = function( propNode, parts ) 159 { 160 if ( !parts ) 161 parts = []; 162 163 var owner = propNode.getFirstChild(), 164 property = propNode.getLastChild(); 165 166 if ( owner ) 167 { 168 if ( owner.getType() == Token.GETPROP ) 169 getPropParts( owner, parts ); 170 else 171 parts.push( owner ); 172 173 parts.push( property ); 174 } 175 else 176 parts.push( propNode ); 177 178 return parts; 179 }; 180 158 181 var writeNode = function( node, opt ) 159 182 { … … 349 372 isFunctionCall = ( childType == Token.FUNCTION || childType == Token.SETPROP || childType == Token.SETELEM ); 350 373 374 if ( childType == Token.NAME && child.getString() == 'PACKAGER_RENAME' ) 375 { 376 var renamed = child.getNext(), 377 renamedRef = '', 378 parts = getPropParts( renamed ); 379 380 for ( var i = 0 ; i < parts.length ; i++ ) 381 { 382 if ( i > 0 ) 383 renamedRef += '.'; 384 renamedRef += parts[ i ].getString(); 385 } 386 387 // print( '[' + renamedRef + ']' ); 388 389 out( 'var ', scope.addRenamedRef( renamedRef ), '=' ); 390 writeNode( renamed ); 391 392 scope.declareName( renamedRef ); 393 394 break; 395 } 396 351 397 if ( isFunctionCall ) 352 398 out( '(' ); … … 595 641 name = child.getNext().getString(), 596 642 finalName = name; 597 598 // Build the full name, like Obj.Prop1.Prop2 599 while ( child ) 600 { 601 if ( child.getType() == Token.NAME ) 602 { 603 name = child.getString() + '.' + name; 604 finalName = scope.getNewName( child.getString() ) + '.' + finalName; 643 644 // Get all parts that compose this node (part1.part2.partN). 645 var parts = getPropParts( node ), 646 startAt = 0, 647 names = []; 648 649 // Get all part names form the start. 650 for ( var i = 0 ; i < parts.length ; i++ ) 651 { 652 var part = parts[ i ], 653 partType = part.getType(); 654 if ( partType == Token.NAME || partType == Token.STRING ) 655 names.push( String( part.getString() ) ); 656 else 605 657 break; 606 } 607 608 if ( child.getType() == Token.GETPROP ) 609 { 610 child = child.getFirstChild(); 611 name = child.getNext().getString() + '.' + name; 612 613 if ( child ) 614 finalName = name; 615 else 616 finalName = scope.getNewName( child.getNext().getString() ) + '.' + finalName; 617 618 continue; 619 } 620 621 var parenthesis = !!precedence[ child.getType() ]; 622 623 if ( parenthesis ) 624 out( '(' ); 625 626 writeNode( child ); 627 628 if ( parenthesis ) 629 out( ')' ); 630 631 finalName = '.' + finalName; 632 633 child = null; 634 break; 635 } 636 637 // Check if the full name is a constant. 638 if ( child && constantList[ name ] ) 639 { 640 out( constantList[ name ] ); 641 break; 642 } 643 else 644 out( finalName ); 658 } 659 660 // Check if the name parts are to be replaced. 661 for ( var i = names.length ; i > 0 ; i-- ) 662 { 663 // Build the full name (e.g. Obj.prop1.prop2). 664 var fullName = i == 1 ? names[ 0 ] : names.slice( 0, i ).join( '.' ); 665 666 // If we have a property composed by names only. 667 if ( i == parts.length && typeof constantList[ fullName ] != 'undefined' ) 668 { 669 out( constantList[ fullName ] ) 670 return true; 671 } 672 673 var newName = scope.getNewName( fullName ); 674 675 // If a new names is available. 676 if ( newName != fullName ) 677 { 678 // Send the new name. 679 out( newName ); 680 681 // Removed the replaced names from the parts list. 682 startAt = i; 683 break; 684 } 685 } 686 687 for ( var i = startAt ; i < parts.length ; i++ ) 688 { 689 var part = parts[ i ], 690 partType = part.getType(), 691 parenthesis = !!precedence[ partType ]; 692 693 if ( i > 0 ) 694 out( '.' ); 695 696 if ( partType == Token.STRING ) 697 out( part.getString() ); 698 else 699 { 700 if ( parenthesis ) 701 out( '(' ); 702 703 writeNode( part ); 704 705 if ( parenthesis ) 706 out( ')' ); 707 } 708 } 645 709 646 710 break; … … 1037 1101 var regexLib = 1038 1102 { 1039 packagerRemove : Pattern.compile( '(?m-s:^.*?@Packager\.Remove\.Start).*?(?m-s:@Packager\.Remove\.End.*?$\n?)', Pattern.DOTALL ), 1040 packagerRemoveLine : Pattern.compile( '^.*@Packager\.RemoveLine.*$\n?', Pattern.MULTILINE ) 1103 packagerRemove : Pattern.compile( '(?m-s:^.*?@Packager\\.Remove\\.Start).*?(?m-s:@Packager\\.Remove\\.End.*?$)', Pattern.DOTALL ), 1104 packagerRemoveLine : Pattern.compile( '^.*@Packager\\.RemoveLine.*$', Pattern.MULTILINE ), 1105 packagerRename : Pattern.compile( '^.*PACKAGER_RENAME\\(\\s*([^\\s]+).*$', Pattern.MULTILINE ) 1041 1106 }; 1042 1107 … … 1059 1124 // script = script.replace( /^.*@Packager\.RemoveLine.*/gm, '' ); 1060 1125 1126 script = String( regexLib.packagerRename.matcher( script ).replaceAll( 'PACKAGER_RENAME($1);' ) ); 1127 1061 1128 return script; 1062 1129 }; … … 1074 1141 CKPACKAGER.scriptCompressor = 1075 1142 { 1076 compress : function( script, renameGlobals, constants, noCheck )1143 compress : function( script, renameGlobals, constants, noCheck, wrap ) 1077 1144 { 1078 1145 script = preProcess( script ); … … 1084 1151 ignoreSiblings = false; 1085 1152 isLoop = false; 1153 1154 if ( wrap ) 1155 script = '(function(){' + script + '})();'; 1086 1156 1087 1157 var compilerEnv = new CompilerEnvirons(), … … 1090 1160 scriptNode = parser.parse( script, null, 1 ); 1091 1161 1092 noGlobals = ! renameGlobals;1162 noGlobals = !wrap && !renameGlobals; 1093 1163 constantList = constants || {}; 1094 1164 -
CKEditor/branches/prototype/_dev/packager/ckpackager/test/test.js
r2370 r2371 252 252 253 253 [ "a=b+c*1;", 254 "a=b+ +c;" ] 254 "a=b+ +c;" ], 255 256 [ "function(){\n// PACKAGER_RENAME( CKEDITOR )\nCKEDITOR.env={ie:true};\n// PACKAGER_RENAME( CKEDITOR.env )\n// PACKAGER_RENAME( CKEDITOR.env.ie )\nif (CKEDITOR&&CKEDITOR.env&&CKEDITOR.env.ie){go();}}", 257 "function(){var a=CKEDITOR;a.env={ie:true};var b=a.env;var c=b.ie;if(a&&b&&c)go();}" ] 258 255 259 ]; 256 260 -
CKEditor/branches/prototype/_source/core/ckeditor_base.js
r2214 r2371 124 124 // Relative path. 125 125 else 126 path = location.href.match( /^[^\?]*\/ / )[0] + path;126 path = location.href.match( /^[^\?]*\/(?:)/ )[0] + path; 127 127 } 128 128 … … 159 159 })(); 160 160 } 161 162 // PACKAGER_RENAME( CKEDITOR ) -
CKEditor/branches/prototype/_source/core/dom/document.js
r2261 r2371 44 44 this.$ = domDocument; 45 45 }; 46 47 // PACKAGER_RENAME( CKEDITOR.dom.document ) 46 48 47 49 CKEDITOR.dom.document.prototype = new CKEDITOR.dom.domObject(); -
CKEditor/branches/prototype/_source/core/dom/element.js
r2352 r2371 55 55 }; 56 56 57 // PACKAGER_RENAME( CKEDITOR.dom.element ) 58 57 59 /** 58 60 * The the {@link CKEDITOR.dom.element} representing and element. If the -
CKEditor/branches/prototype/_source/core/dom.js
r2147 r2371 34 34 CKEDITOR.dom = 35 35 {}; 36 37 // PACKAGER_RENAME( CKEDITOR.dom ) -
CKEditor/branches/prototype/_source/core/dtd.js
r2343 r2371 201 201 "<b>this is a <a>link</a></b><a> test</a>". 202 202 */ 203 204 // PACKAGER_RENAME( CKEDITOR.dtd ) -
CKEditor/branches/prototype/_source/core/env.js
r2341 r2371 139 139 })(); 140 140 } 141 142 // PACKAGER_RENAME( CKEDITOR.env ) 143 // PACKAGER_RENAME( CKEDITOR.env.ie ) -
CKEditor/branches/prototype/_source/core/tools.js
r2365 r2371 362 362 } 363 363 }; 364 365 // PACKAGER_RENAME( CKEDITOR.tools ) -
CKEditor/branches/prototype/_source/core/ui.js
r2278 r2371 39 39 return this; 40 40 }; 41 42 // PACKAGER_RENAME( CKEDITOR.ui ) 41 43 42 44 CKEDITOR.ui.prototype =