Index: /CKEditor/branches/prototype/_dev/packager/ckpackager/includes/packagefile.js
===================================================================
--- /CKEditor/branches/prototype/_dev/packager/ckpackager/includes/packagefile.js (revision 2370)
+++ /CKEditor/branches/prototype/_dev/packager/ckpackager/includes/packagefile.js (revision 2371)
@@ -18,4 +18,5 @@
this.renameGlobals = false;
this.compactJavascript = true;
+ this.wrap = false;
this.files = [];
};
@@ -41,5 +42,5 @@
var compressed = this.compactJavascript ?
- CKPACKAGER.scriptCompressor.compress( source, this.renameGlobals, this.constants, this.noCheck ) :
+ CKPACKAGER.scriptCompressor.compress( source, this.renameGlobals, this.constants, this.noCheck, this.wrap ) :
source;
Index: /CKEditor/branches/prototype/_dev/packager/ckpackager/includes/packager.js
===================================================================
--- /CKEditor/branches/prototype/_dev/packager/ckpackager/includes/packager.js (revision 2370)
+++ /CKEditor/branches/prototype/_dev/packager/ckpackager/includes/packager.js (revision 2371)
@@ -58,4 +58,7 @@
packFile.compactJavascript = packDefinition.compactJavascript;
+ if ( typeof packDefinition.wrap != 'undefined' )
+ packFile.wrap = packDefinition.wrap;
+
var files = packDefinition.files;
Index: /CKEditor/branches/prototype/_dev/packager/ckpackager/includes/scope.js
===================================================================
--- /CKEditor/branches/prototype/_dev/packager/ckpackager/includes/scope.js (revision 2370)
+++ /CKEditor/branches/prototype/_dev/packager/ckpackager/includes/scope.js (revision 2371)
@@ -144,3 +144,8 @@
this.declaredNames[ name ] = 1;
};
+
+ CKPACKAGER.scope.prototype.addRenamedRef = function( name )
+ {
+ return this.names[ name ] = getNextName( this );
+ };
})();
Index: /CKEditor/branches/prototype/_dev/packager/ckpackager/includes/scriptcompressor.js
===================================================================
--- /CKEditor/branches/prototype/_dev/packager/ckpackager/includes/scriptcompressor.js (revision 2370)
+++ /CKEditor/branches/prototype/_dev/packager/ckpackager/includes/scriptcompressor.js (revision 2371)
@@ -24,5 +24,5 @@
output,
outputSize = 0,
- maxSize = 2000;
+ maxSize = 2500;
var lang = {};
@@ -156,4 +156,27 @@
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 };
+ var getPropParts = function( propNode, parts )
+ {
+ if ( !parts )
+ parts = [];
+
+ var owner = propNode.getFirstChild(),
+ property = propNode.getLastChild();
+
+ if ( owner )
+ {
+ if ( owner.getType() == Token.GETPROP )
+ getPropParts( owner, parts );
+ else
+ parts.push( owner );
+
+ parts.push( property );
+ }
+ else
+ parts.push( propNode );
+
+ return parts;
+ };
+
var writeNode = function( node, opt )
{
@@ -349,4 +372,27 @@
isFunctionCall = ( childType == Token.FUNCTION || childType == Token.SETPROP || childType == Token.SETELEM );
+ if ( childType == Token.NAME && child.getString() == 'PACKAGER_RENAME' )
+ {
+ var renamed = child.getNext(),
+ renamedRef = '',
+ parts = getPropParts( renamed );
+
+ for ( var i = 0 ; i < parts.length ; i++ )
+ {
+ if ( i > 0 )
+ renamedRef += '.';
+ renamedRef += parts[ i ].getString();
+ }
+
+ // print( '[' + renamedRef + ']' );
+
+ out( 'var ', scope.addRenamedRef( renamedRef ), '=' );
+ writeNode( renamed );
+
+ scope.declareName( renamedRef );
+
+ break;
+ }
+
if ( isFunctionCall )
out( '(' );
@@ -595,52 +641,70 @@
name = child.getNext().getString(),
finalName = name;
-
- // Build the full name, like Obj.Prop1.Prop2
- while ( child )
- {
- if ( child.getType() == Token.NAME )
- {
- name = child.getString() + '.' + name;
- finalName = scope.getNewName( child.getString() ) + '.' + finalName;
+
+ // Get all parts that compose this node (part1.part2.partN).
+ var parts = getPropParts( node ),
+ startAt = 0,
+ names = [];
+
+ // Get all part names form the start.
+ for ( var i = 0 ; i < parts.length ; i++ )
+ {
+ var part = parts[ i ],
+ partType = part.getType();
+ if ( partType == Token.NAME || partType == Token.STRING )
+ names.push( String( part.getString() ) );
+ else
break;
- }
-
- if ( child.getType() == Token.GETPROP )
- {
- child = child.getFirstChild();
- name = child.getNext().getString() + '.' + name;
-
- if ( child )
- finalName = name;
- else
- finalName = scope.getNewName( child.getNext().getString() ) + '.' + finalName;
-
- continue;
- }
-
- var parenthesis = !!precedence[ child.getType() ];
-
- if ( parenthesis )
- out( '(' );
-
- writeNode( child );
-
- if ( parenthesis )
- out( ')' );
-
- finalName = '.' + finalName;
-
- child = null;
- break;
- }
-
- // Check if the full name is a constant.
- if ( child && constantList[ name ] )
- {
- out( constantList[ name ] );
- break;
- }
- else
- out( finalName );
+ }
+
+ // Check if the name parts are to be replaced.
+ for ( var i = names.length ; i > 0 ; i-- )
+ {
+ // Build the full name (e.g. Obj.prop1.prop2).
+ var fullName = i == 1 ? names[ 0 ] : names.slice( 0, i ).join( '.' );
+
+ // If we have a property composed by names only.
+ if ( i == parts.length && typeof constantList[ fullName ] != 'undefined' )
+ {
+ out( constantList[ fullName ] )
+ return true;
+ }
+
+ var newName = scope.getNewName( fullName );
+
+ // If a new names is available.
+ if ( newName != fullName )
+ {
+ // Send the new name.
+ out( newName );
+
+ // Removed the replaced names from the parts list.
+ startAt = i;
+ break;
+ }
+ }
+
+ for ( var i = startAt ; i < parts.length ; i++ )
+ {
+ var part = parts[ i ],
+ partType = part.getType(),
+ parenthesis = !!precedence[ partType ];
+
+ if ( i > 0 )
+ out( '.' );
+
+ if ( partType == Token.STRING )
+ out( part.getString() );
+ else
+ {
+ if ( parenthesis )
+ out( '(' );
+
+ writeNode( part );
+
+ if ( parenthesis )
+ out( ')' );
+ }
+ }
break;
@@ -1037,6 +1101,7 @@
var regexLib =
{
- packagerRemove : Pattern.compile( '(?m-s:^.*?@Packager\.Remove\.Start).*?(?m-s:@Packager\.Remove\.End.*?$\n?)', Pattern.DOTALL ),
- packagerRemoveLine : Pattern.compile( '^.*@Packager\.RemoveLine.*$\n?', Pattern.MULTILINE )
+ packagerRemove : Pattern.compile( '(?m-s:^.*?@Packager\\.Remove\\.Start).*?(?m-s:@Packager\\.Remove\\.End.*?$)', Pattern.DOTALL ),
+ packagerRemoveLine : Pattern.compile( '^.*@Packager\\.RemoveLine.*$', Pattern.MULTILINE ),
+ packagerRename : Pattern.compile( '^.*PACKAGER_RENAME\\(\\s*([^\\s]+).*$', Pattern.MULTILINE )
};
@@ -1059,4 +1124,6 @@
// script = script.replace( /^.*@Packager\.RemoveLine.*/gm, '' );
+ script = String( regexLib.packagerRename.matcher( script ).replaceAll( 'PACKAGER_RENAME($1);' ) );
+
return script;
};
@@ -1074,5 +1141,5 @@
CKPACKAGER.scriptCompressor =
{
- compress : function( script, renameGlobals, constants, noCheck )
+ compress : function( script, renameGlobals, constants, noCheck, wrap )
{
script = preProcess( script );
@@ -1084,4 +1151,7 @@
ignoreSiblings = false;
isLoop = false;
+
+ if ( wrap )
+ script = '(function(){' + script + '})();';
var compilerEnv = new CompilerEnvirons(),
@@ -1090,5 +1160,5 @@
scriptNode = parser.parse( script, null, 1 );
- noGlobals = !renameGlobals;
+ noGlobals = !wrap && !renameGlobals;
constantList = constants || {};
Index: /CKEditor/branches/prototype/_dev/packager/ckpackager/test/test.js
===================================================================
--- /CKEditor/branches/prototype/_dev/packager/ckpackager/test/test.js (revision 2370)
+++ /CKEditor/branches/prototype/_dev/packager/ckpackager/test/test.js (revision 2371)
@@ -252,5 +252,9 @@
[ "a=b+c*1;",
- "a=b+ +c;" ]
+ "a=b+ +c;" ],
+
+ [ "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();}}",
+ "function(){var a=CKEDITOR;a.env={ie:true};var b=a.env;var c=b.ie;if(a&&b&&c)go();}" ]
+
];
Index: /CKEditor/branches/prototype/_source/core/ckeditor_base.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/ckeditor_base.js (revision 2370)
+++ /CKEditor/branches/prototype/_source/core/ckeditor_base.js (revision 2371)
@@ -124,5 +124,5 @@
// Relative path.
else
- path = location.href.match( /^[^\?]*\// )[0] + path;
+ path = location.href.match( /^[^\?]*\/(?:)/ )[0] + path;
}
@@ -159,2 +159,4 @@
})();
}
+
+// PACKAGER_RENAME( CKEDITOR )
Index: /CKEditor/branches/prototype/_source/core/dom.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/dom.js (revision 2370)
+++ /CKEditor/branches/prototype/_source/core/dom.js (revision 2371)
@@ -34,2 +34,4 @@
CKEDITOR.dom =
{};
+
+// PACKAGER_RENAME( CKEDITOR.dom )
Index: /CKEditor/branches/prototype/_source/core/dom/document.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/dom/document.js (revision 2370)
+++ /CKEditor/branches/prototype/_source/core/dom/document.js (revision 2371)
@@ -44,4 +44,6 @@
this.$ = domDocument;
};
+
+// PACKAGER_RENAME( CKEDITOR.dom.document )
CKEDITOR.dom.document.prototype = new CKEDITOR.dom.domObject();
Index: /CKEditor/branches/prototype/_source/core/dom/element.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/dom/element.js (revision 2370)
+++ /CKEditor/branches/prototype/_source/core/dom/element.js (revision 2371)
@@ -55,4 +55,6 @@
};
+// PACKAGER_RENAME( CKEDITOR.dom.element )
+
/**
* The the {@link CKEDITOR.dom.element} representing and element. If the
Index: /CKEditor/branches/prototype/_source/core/dtd.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/dtd.js (revision 2370)
+++ /CKEditor/branches/prototype/_source/core/dtd.js (revision 2371)
@@ -201,2 +201,4 @@
"this is a link test".
*/
+
+// PACKAGER_RENAME( CKEDITOR.dtd )
Index: /CKEditor/branches/prototype/_source/core/env.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/env.js (revision 2370)
+++ /CKEditor/branches/prototype/_source/core/env.js (revision 2371)
@@ -139,2 +139,5 @@
})();
}
+
+// PACKAGER_RENAME( CKEDITOR.env )
+// PACKAGER_RENAME( CKEDITOR.env.ie )
Index: /CKEditor/branches/prototype/_source/core/tools.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/tools.js (revision 2370)
+++ /CKEditor/branches/prototype/_source/core/tools.js (revision 2371)
@@ -362,2 +362,4 @@
}
};
+
+// PACKAGER_RENAME( CKEDITOR.tools )
Index: /CKEditor/branches/prototype/_source/core/ui.js
===================================================================
--- /CKEditor/branches/prototype/_source/core/ui.js (revision 2370)
+++ /CKEditor/branches/prototype/_source/core/ui.js (revision 2371)
@@ -39,4 +39,6 @@
return this;
};
+
+// PACKAGER_RENAME( CKEDITOR.ui )
CKEDITOR.ui.prototype =
Index: /CKEditor/branches/prototype/ckeditor.pack
===================================================================
--- /CKEditor/branches/prototype/ckeditor.pack (revision 2370)
+++ /CKEditor/branches/prototype/ckeditor.pack (revision 2371)
@@ -30,4 +30,5 @@
{
output : 'ckeditor_basic.js',
+ wrap : true,
files :
[
@@ -42,4 +43,5 @@
{
output : 'ckeditor.js',
+ wrap : true,
files :
[