Imported Upstream version 4.8.10

This commit is contained in:
Mario Fetka
2021-10-03 11:06:28 +02:00
parent 10dfc9587b
commit 03a8170b15
2361 changed files with 1883897 additions and 338759 deletions

View File

@@ -20,6 +20,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Build script for FreeIPA Web UI
set -o errexit
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@@ -31,6 +32,5 @@ if [[ ! $profile ]] ; then
exit 1
fi
RHINO="java -Xss${JAVA_STACK_SIZE:-512k} -classpath /usr/share/java/js.jar org.mozilla.javascript.tools.shell.Main"
$RHINO $DIR/build/build.js baseUrl=$DIR/build load=build profile=$DIR/../src/$profile.profile.js
node $DIR/build/build.js load=build profile=$DIR/../src/$profile.profile.js
exit $?

View File

@@ -1,5 +1,5 @@
build.js is builded dojo builder, with applied patches from 'patches' folder, by
itself and compiled using uglify.js
itself and compiled using python3-rjsmin
_base/configRhino.js is unmodifed file from dojo/dojo. Required for a build to work.
@@ -9,4 +9,4 @@ Available via Academic Free License >= 2.1 OR the modified BSD license.
see: http://dojotoolkit.org/license for details
= License =
Full Dojo license is in LICENSE file.
Full Dojo license is in LICENSE file.

View File

@@ -0,0 +1,108 @@
exports.config = function(config){
// summary:
// This module provides bootstrap configuration for running dojo in node.js
// any command line arguments with the load flag are pushed into deps
for(var deps = [], args = [], i = 0; i < process.argv.length; i++){
var arg = (process.argv[i] + "").split("=");
if(arg[0] == "load"){
deps.push(arg[1]);
}else if(arg[0] == "mapPackage") {
var parts = arg[1].split(":"),
name = parts[0],
location=parts[1],
isPrexisting = false;
for (var j = 0; j < config.packages.length; j++) {
var pkg = config.packages[j];
if (pkg.name === name) {
pkg.location = location;
isPrexisting = true;
break;
}
}
if (!isPrexisting) {
config.packages.push({
name: name,
location: location
});
}
}else{
args.push(arg);
}
}
var fs = require("fs");
// make sure global require exists
//if (typeof global.require=="undefined"){
// global.require= {};
//}
// reset the has cache with node-appropriate values;
var hasCache = {
"host-node":1,
"host-browser":0,
"dom":0,
"dojo-has-api":1,
"dojo-xhr-factory":0,
"dojo-inject-api":1,
"dojo-timeout-api":0,
"dojo-trace-api":1,
"dojo-dom-ready-api":0,
"dojo-publish-privates":1,
"dojo-sniff":0,
"dojo-loader":1,
"dojo-test-xd":0,
"dojo-test-sniff":0
};
for(var p in hasCache){
config.hasCache[p] = hasCache[p];
}
var vm = require('vm'),
path = require('path');
// reset some configuration switches with node-appropriate values
var nodeConfig = {
baseUrl: path.dirname(process.argv[1]),
commandLineArgs:args,
deps:deps,
timeout:0,
// TODO: really get the locale
locale:"en-us",
loaderPatch: {
log:function(item){
// define debug for console messages during dev instead of console.log
// (node's heavy async makes console.log confusing sometimes)
var util = require("util");
util.debug(util.inspect(item));
},
eval: function(__text, __urlHint){
return vm.runInThisContext(__text, __urlHint);
},
injectUrl: function(url, callback){
try{
vm.runInThisContext(fs.readFileSync(url, "utf8"), url);
callback();
}catch(e){
this.log("failed to load resource (" + url + ")");
this.log(e);
}
},
getText: function(url, sync, onLoad){
// TODO: implement async and http/https handling
onLoad(fs.readFileSync(url, "utf8"));
}
}
};
for(p in nodeConfig){
config[p] = nodeConfig[p];
}
};

View File

@@ -1,121 +0,0 @@
function rhinoDojoConfig(config, baseUrl, rhinoArgs){
// summary:
// This module provides bootstrap configuration for running dojo in rhino.
// TODO: v1.6 tries to set dojo.doc and dojo.body in rhino; why?
// get a minimal console up
var log = function(hint, args){
print((hint ? hint + ":" : "") + args[0]);
for(var i = 1; i < args.length; i++){
print(", " + args[i]);
}
};
// intentionally define console in the global namespace
console= {
log: function(){ log(0, arguments); },
error: function(){ log("ERROR", arguments); },
warn: function(){ log("WARN", arguments); }
};
// any command line arguments with the load flag are pushed into deps
for(var deps = [], i = 0; i < rhinoArgs.length; i++){
var arg = (rhinoArgs[i] + "").split("=");
if(arg[0] == "load"){
deps.push(arg[1]);
}
}
// provides timed callbacks using Java threads
if(typeof setTimeout == "undefined" || typeof clearTimeout == "undefined"){
var timeouts = [];
clearTimeout = function(idx){
if(!timeouts[idx]){ return; }
timeouts[idx].stop();
};
setTimeout = function(func, delay){
var def = {
sleepTime:delay,
hasSlept:false,
run:function(){
if(!this.hasSlept){
this.hasSlept = true;
java.lang.Thread.currentThread().sleep(this.sleepTime);
}
try{
func();
}catch(e){
console.debug("Error running setTimeout thread:" + e);
}
}
};
var runnable = new java.lang.Runnable(def);
var thread = new java.lang.Thread(runnable);
thread.start();
return timeouts.push(thread) - 1;
};
}
var isLocal = function(url){
return (new java.io.File(url)).exists();
};
// reset the has cache with node-appropriate values;
var hasCache = {
"host-rhino":1,
"host-browser":0,
"dom":0,
"dojo-has-api":1,
"dojo-xhr-factory":0,
"dojo-inject-api":1,
"dojo-timeout-api":0,
"dojo-trace-api":1,
"dojo-loader-catches":1,
"dojo-dom-ready-api":0,
"dojo-publish-privates":1,
"dojo-sniff":0,
"dojo-loader":1,
"dojo-test-xd":0,
"dojo-test-sniff":0
};
for(var p in hasCache){
config.hasCache[p] = hasCache[p];
}
// reset some configuration switches with rhino-appropriate values
var rhinoConfig = {
baseUrl:baseUrl,
commandLineArgs:rhinoArgs,
deps:deps,
timeout:0,
locale:String(java.util.Locale.getDefault().toString().replace('_', '-').toLowerCase()),
loaderPatch:{
injectUrl: function(url, callback){
try{
if(isLocal(url)){
load(url);
}else{
require.eval(readUrl(url, "UTF-8"));
}
callback();
}catch(e){
console.log("failed to load resource (" + url + ")");
console.log(e);
}
},
getText: function(url, sync, onLoad){
// TODO: test https://bugzilla.mozilla.org/show_bug.cgi?id=471005; see v1.6 hostenv_rhino
// note: async mode not supported in rhino
onLoad(isLocal(url) ? readFile(url, "UTF-8") : readUrl(url, "UTF-8"));
}
}
};
for(p in rhinoConfig){
config[p] = rhinoConfig[p];
}
}

File diff suppressed because one or more lines are too long

View File

@@ -1,7 +1,7 @@
From c0962cfb520d25c367689243b71e43af1dcc0601 Mon Sep 17 00:00:00 2001
From be32e8039fca859a8fc9202c50dcd8663023dd53 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvoborni@redhat.com>
Date: Thu, 8 Nov 2012 13:22:30 +0100
Subject: [PATCH] Make dojo builder buildable by itself
Subject: [PATCH 1/2] Make dojo builder buildable by itself
Dojo builder is now buildable by itself. It just needed a packackage information,
profile and separating of internal definition of commanLineArgs module to separate
@@ -22,7 +22,7 @@ get rid of this dependency.
create mode 100644 build/package.json
diff --git a/build/argv.js b/build/argv.js
index 18bda74b0eb80e37d9c83cb23a10f29f8ffe91d9..997576687eb74cbb6a6a293b3a855a6d15142368 100644
index c6589afb..98d95bf8 100644
--- a/build/argv.js
+++ b/build/argv.js
@@ -5,7 +5,7 @@ define([
@@ -36,7 +36,7 @@ index 18bda74b0eb80e37d9c83cb23a10f29f8ffe91d9..997576687eb74cbb6a6a293b3a855a6d
"./messages",
diff --git a/build/build.profile.js b/build/build.profile.js
new file mode 100644
index 0000000000000000000000000000000000000000..507728c283c5703106fe029c0fd282cb864c994d
index 00000000..507728c2
--- /dev/null
+++ b/build/build.profile.js
@@ -0,0 +1,32 @@
@@ -75,7 +75,7 @@ index 0000000000000000000000000000000000000000..507728c283c5703106fe029c0fd282cb
\ No newline at end of file
diff --git a/build/commandLineArgs.js b/build/commandLineArgs.js
new file mode 100644
index 0000000000000000000000000000000000000000..41df62e31a05ef2c00e1eb609c0fabe8641e2d03
index 00000000..41df62e3
--- /dev/null
+++ b/build/commandLineArgs.js
@@ -0,0 +1,7 @@
@@ -88,7 +88,7 @@ index 0000000000000000000000000000000000000000..41df62e31a05ef2c00e1eb609c0fabe8
+});
\ No newline at end of file
diff --git a/build/main.js b/build/main.js
index eeb329c91c0eb4df94178cdfc445e5235409401a..89ad7a9d639257ec99ca86be59abdb74d54939a3 100644
index 131ed644..c0eb36e9 100644
--- a/build/main.js
+++ b/build/main.js
@@ -33,16 +33,14 @@
@@ -105,7 +105,7 @@ index eeb329c91c0eb4df94178cdfc445e5235409401a..89ad7a9d639257ec99ca86be59abdb74
- return process.argv.slice(2);
- });
+ //arg[0] is node; argv[1] is dojo.js; therefore, start with argv[2]
+ commandLineArgs.push(process.argv.slice(2));
+ commandLineArgs.push.apply(commandLineArgs, process.argv.slice(2));
- // helps during dev or heavily async node...
+ // helps during dev or heavily async node
@@ -137,13 +137,13 @@ index eeb329c91c0eb4df94178cdfc445e5235409401a..89ad7a9d639257ec99ca86be59abdb74
}else{
diff --git a/build/package.json b/build/package.json
new file mode 100644
index 0000000000000000000000000000000000000000..568101cb1a182d3415c73d02e151359e1ce3e27d
index 00000000..576030f2
--- /dev/null
+++ b/build/package.json
@@ -0,0 +1,23 @@
+{
+ "name": "build",
+ "version":"1.8.1",
+ "version":"1.13.0",
+ "directories": {
+ "lib": "."
+ },
@@ -165,5 +165,5 @@ index 0000000000000000000000000000000000000000..568101cb1a182d3415c73d02e151359e
+ "dojoBuild": "build.profile.js"
+}
--
1.7.11.7
2.14.3

View File

@@ -18,6 +18,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -o errexit
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
RDIR=$DIR/../release
@@ -139,4 +140,4 @@ pushd $DIR/../js
git update-index --no-assume-unchanged ./dojo
git update-index --no-assume-unchanged ./freeipa
fi
popd
popd

View File

@@ -18,9 +18,10 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -o errexit
# Clean after build
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
rm -rf $DIR/../release
rm -rf $DIR/../release

View File

@@ -18,21 +18,25 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -o errexit
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
RDIR=$DIR/../release
# for platform ID
. /etc/os-release
usage() {
cat <<-__EOF__;
NAME
compile.sh - Compiles layer file of Dojo build using uglify.js.
compile.sh - Compiles layer file of Dojo build using Python rjsmin.
Deletes all other files.
SYNOPSIS
path/to/compile.sh [--help] --release RELEASE --layer NAME/NAME
DESCRIPTION
Compiles layer file of Dojo build output using uglify.js.
Compiles layer file of Dojo build output using Python rjsmin.
Deletes all other files.
OPTIONS
@@ -104,5 +108,13 @@ if [[ ! $OUTPUT_FILE ]] ; then
OUTPUT_FILE=$RDIR/$RELEASE/$LAYER.js
fi
# compile using uglify.js
$DIR/uglifyjs/uglify $RDIR/$RELEASE/$LAYER.js $OUTPUT_FILE
# compile using python rjsmin on most platforms and uglify-js on RHEL 8
echo "Minimizing: $RDIR/$RELEASE/$LAYER.js"
echo "Target file: $OUTPUT_FILE"
if [ $ID = "rhel" ]; then
echo "Minifier: uglifyjs"
uglifyjs < $RDIR/$RELEASE/$LAYER.js > $OUTPUT_FILE
else
echo "Minifier: rjsmin"
${PYTHON:-python3} -m rjsmin < $RDIR/$RELEASE/$LAYER.js > $OUTPUT_FILE
fi

View File

@@ -0,0 +1,43 @@
From 1d61fd9407e6fbe82fe55cb0b938307aa0791f77 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20Go=C5=82=C4=99biowski-Owczarek?=
<m.goleb@gmail.com>
Date: Mon, 16 Mar 2020 21:49:29 +0100
Subject: [PATCH] Manipulation: Make jQuery.htmlPrefilter an identity function
Closes gh-4642
(cherry picked from 90fed4b453a5becdb7f173d9e3c1492390a1441f)
---
src/manipulation.js | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/src/manipulation.js b/src/manipulation.js
index 017345af..dec21ea0 100644
--- a/src/manipulation.js
+++ b/src/manipulation.js
@@ -33,13 +33,6 @@ define( [
var
- /* eslint-disable max-len */
-
- // See https://github.com/eslint/eslint/issues/3229
- rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
-
- /* eslint-enable */
-
// Support: IE <=10 - 11, Edge 12 - 13 only
// In IE/Edge using regex groups here causes severe slowdowns.
// See https://connect.microsoft.com/IE/feedback/details/1736512/
@@ -236,7 +229,7 @@ function remove( elem, selector, keepData ) {
jQuery.extend( {
htmlPrefilter: function( html ) {
- return html.replace( rxhtmlTag, "<$1></$2>" );
+ return html;
},
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
--
2.20.1

View File

@@ -0,0 +1,71 @@
From 966a70909019aa09632c87c0002c522fa4a1e30e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20Go=C5=82=C4=99biowski-Owczarek?=
<m.goleb@gmail.com>
Date: Mon, 30 Mar 2020 20:15:09 +0200
Subject: [PATCH] Manipulation: Skip the select wrapper for <option> outside of
IE 9
Closes gh-4647
---
src/manipulation/support.js | 6 ++++++
src/manipulation/wrapMap.js | 15 ++++++++-------
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/src/manipulation/support.js b/src/manipulation/support.js
index 4a5d9af4..62d6bb3e 100644
--- a/src/manipulation/support.js
+++ b/src/manipulation/support.js
@@ -28,6 +28,12 @@ define( [
// Make sure textarea (and checkbox) defaultValue is properly cloned
div.innerHTML = "<textarea>x</textarea>";
support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
+
+ // Support: IE <=9 only
+ // IE <=9 replaces <option> tags with their contents when inserted outside of
+ // the select element.
+ div.innerHTML = "<option></option>";
+ support.option = !!div.lastChild;
} )();
return support;
diff --git a/src/manipulation/wrapMap.js b/src/manipulation/wrapMap.js
index 1f446f7d..da48bf9f 100644
--- a/src/manipulation/wrapMap.js
+++ b/src/manipulation/wrapMap.js
@@ -1,13 +1,12 @@
-define( function() {
+define( [
+ "./support"
+], function( support ) {
"use strict";
// We have to close these tags to support XHTML (#13200)
var wrapMap = {
- // Support: IE <=9 only
- option: [ 1, "<select multiple='multiple'>", "</select>" ],
-
// XHTML parsers do not magically insert elements in the
// same way that tag soup parsers do. So we cannot shorten
// this by omitting <tbody> or other required elements.
@@ -19,11 +18,13 @@ var wrapMap = {
_default: [ 0, "", "" ]
};
-// Support: IE <=9 only
-wrapMap.optgroup = wrapMap.option;
-
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
wrapMap.th = wrapMap.td;
+// Support: IE <=9 only
+if ( !support.option ) {
+ wrapMap.optgroup = wrapMap.option = [ 1, "<select multiple='multiple'>", "</select>" ];
+}
+
return wrapMap;
} );
--
2.20.1

View File

@@ -18,6 +18,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -o errexit
# Build DOJO builder, overwrites util/build/build.js. Cleans after itself.
@@ -47,4 +48,4 @@ $DIR/clean.sh
# Delete DOJO symbolic links
rm -f $DIR/../src/dojo
rm -f $DIR/../src/build
rm -f $DIR/../src/build

View File

@@ -1,25 +0,0 @@
#!/bin/bash
# Authors:
# Petr Vobornik <pvoborni@redhat.com>
#
# Copyright (C) 2013 Red Hat
# see file 'COPYING' for use and warranty information
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
lesscpy -x $DIR/../less/ipa.less > $DIR/../css/ipa.css
exit $?

View File

@@ -18,6 +18,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -o errexit
# Build script for Dojo library
@@ -35,4 +36,4 @@ if [[ $? != 0 ]] ; then
fi
$DIR/compile.sh --release dojo --layer dojo/dojo --output $DIR/../build/dojo/dojo.js
$DIR/clean.sh
$DIR/clean.sh

29
install/ui/util/make-jquery.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash -eu
if [ $# -ne 1 ]; then
echo 'The script requires exactly one argument (a jQuery version):'
echo
echo ' $ ./make-jquery.sh 3.4.1'
echo
exit 1
fi
WD=$(realpath $(dirname "${BASH_SOURCE[0]}"))
JQUERY_VERSION=$1
# Clone jQuery and apply patches
JQUERY_CLONE=$(mktemp -d)
git clone -b ${JQUERY_VERSION} --depth 1 https://github.com/jquery/jquery.git $JQUERY_CLONE
pushd $JQUERY_CLONE
git am ${WD}/jquery-patches/${JQUERY_VERSION}/*
# Build jQuery
npm install
npm run-script build
# Replace the project version of jQuery with the built one
cp -fv dist/jquery.min.js ${WD}/../src/libs/jquery.js
# Clean up
popd
rm -rf $JQUERY_CLONE

View File

@@ -18,6 +18,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -o errexit
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

View File

@@ -18,6 +18,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -o errexit
# Build script for FreeIPA Web UI
@@ -33,4 +34,4 @@ $DIR/build.sh webui
# don't stop at error. Some dependency errors are expected.
$DIR/compile.sh --release lib --layer freeipa/core --output $IPA_DIR/core.js
$DIR/compile.sh --release lib --layer freeipa/app --output $IPA_DIR/app.js
$DIR/clean.sh
$DIR/clean.sh

View File

@@ -18,6 +18,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -o errexit
#
# This script prepares working enviroment to use dojo toolkit.
@@ -58,7 +59,7 @@ OPTIONS
--all Do --clone --checkout --patches --links --dojo --util
--branch <br> Specify a Dojo branch/tag/hash to checkout, default: 1.8.3
--branch <br> Specify a Dojo branch/tag/hash to checkout, default: 1.16.2
--dir <dir> Specify a clone dir, default: freeipa/../dojo/
__EOF__
@@ -75,7 +76,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
DOJO_DIR=$DIR/../../../../dojo
# working version of Dojo toolkit
BRANCH='1.8.3'
BRANCH='1.16.2'
YES='YES'
args=`getopt -q -u -l help,checkout,clone,patches,links,dojo,util,all,branch:,dir: a $*`
@@ -165,7 +166,6 @@ if [[ $DOJO = $YES ]] ; then
git checkout master
git fetch --tags
git fetch
git branch -D $BRANCH
git checkout $BRANCH
fi
popd
@@ -186,7 +186,6 @@ if [[ $UTIL = $YES ]] ; then
git checkout master
git fetch --tags
git fetch
git branch -D $BRANCH
git checkout $BRANCH
fi
@@ -202,4 +201,4 @@ if [[ $UTIL = $YES ]] ; then
fi
fi
popd # $DOJO_DIR
popd # $DOJO_DIR

View File

@@ -18,6 +18,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -o errexit
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
RDIR=$DIR/../release
@@ -60,7 +61,7 @@ OPTIONS
--config
files from html/
--strings
ipalib/plugins/internal.py
ipaserver/plugins/internal.py
-C
--compiled
changes source dir of --freeipa and --dojo to /src/build/freeipa
@@ -340,8 +341,8 @@ pushd $DIR/../../ #freeipa/install
popd
if [[ $STRINGS ]] ; then
SOURCE=ipalib/plugins/internal.py
TARGET=/usr/lib/python2.7/site-packages/ipalib/plugins
SOURCE=ipaserver/plugins/internal.py
TARGET=/usr/lib/python2.7/site-packages/ipaserver/plugins
RECURSIVE=0
CLEAN=0 # don't clean entire folder
pushd $DIR/../../../
@@ -357,4 +358,4 @@ if [[ $RESTART ]] ; then
echo "Restarting httpd: $HOST"
ssh $HOST "systemctl restart httpd.service"
fi
fi
fi

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,78 +0,0 @@
var jsp = require("./parse-js"),
pro = require("./process"),
slice = jsp.slice,
member = jsp.member,
curry = jsp.curry,
MAP = pro.MAP,
PRECEDENCE = jsp.PRECEDENCE,
OPERATORS = jsp.OPERATORS;
function ast_squeeze_more(ast) {
var w = pro.ast_walker(), walk = w.walk, scope;
function with_scope(s, cont) {
var save = scope, ret;
scope = s;
ret = cont();
scope = save;
return ret;
};
function _lambda(name, args, body) {
return [ this[0], name, args, with_scope(body.scope, curry(MAP, body, walk)) ];
};
return w.with_walkers({
"toplevel": function(body) {
return [ this[0], with_scope(this.scope, curry(MAP, body, walk)) ];
},
"function": _lambda,
"defun": _lambda,
"new": function(ctor, args) {
if (ctor[0] == "name") {
if (ctor[1] == "Array" && !scope.has("Array")) {
if (args.length != 1) {
return [ "array", args ];
} else {
return walk([ "call", [ "name", "Array" ], args ]);
}
} else if (ctor[1] == "Object" && !scope.has("Object")) {
if (!args.length) {
return [ "object", [] ];
} else {
return walk([ "call", [ "name", "Object" ], args ]);
}
} else if ((ctor[1] == "RegExp" || ctor[1] == "Function" || ctor[1] == "Error") && !scope.has(ctor[1])) {
return walk([ "call", [ "name", ctor[1] ], args]);
}
}
},
"call": function(expr, args) {
if (expr[0] == "dot" && expr[1][0] == "string" && args.length == 1
&& (args[0][1] > 0 && expr[2] == "substring" || expr[2] == "substr")) {
return [ "call", [ "dot", expr[1], "slice"], args];
}
if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) {
// foo.toString() ==> foo+""
if (expr[1][0] == "string") return expr[1];
return [ "binary", "+", expr[1], [ "string", "" ]];
}
if (expr[0] == "name") {
if (expr[1] == "Array" && args.length != 1 && !scope.has("Array")) {
return [ "array", args ];
}
if (expr[1] == "Object" && !args.length && !scope.has("Object")) {
return [ "object", [] ];
}
if (expr[1] == "String" && !scope.has("String")) {
return [ "binary", "+", args[0], [ "string", "" ]];
}
}
}
}, function() {
return walk(pro.ast_add_scope(ast));
});
};
exports.ast_squeeze_more = ast_squeeze_more;
// Local variables:
// js-indent-level: 4
// End:

View File

@@ -1 +0,0 @@
//just empty file to make rhino happy

View File

@@ -1,33 +0,0 @@
#!/bin/bash
# Authors:
# Petr Vobornik <pvoborni@redhat.com>
#
# Copyright (C) 2012 Red Hat
# see file 'COPYING' for use and warranty information
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Wrapper for calling uglify.js under rhino
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# rhino-1.7R4 doesn't have -main option to enable CommonJS support. It was
# replaced by -require option.
RHINO="java -Xss${JAVA_STACK_SIZE:-512k} -classpath /usr/share/java/js.jar org.mozilla.javascript.tools.shell.Main"
if [ `$RHINO --help | grep -e -require | wc -l` -gt 0 ] ; then
$RHINO -require $DIR/uglify-js.js $@
else
$RHINO -main $DIR/uglify-js.js $DIR/ug.js $@
fi

View File

@@ -1,86 +0,0 @@
// Modified version of the orignal uglify-js.js. Modified to be runnable
// under rhino by Petr Vobornik, Red Hat
// writeFile(), read() code written by John Resig.
function uglify(orig_code, options){
options || (options = {});
var jsp = uglify.parser;
var pro = uglify.uglify;
var ast = jsp.parse(orig_code, options.strict_semicolons); // parse code and get the initial AST
ast = pro.ast_mangle(ast, options.mangle_options); // get a new AST with mangled names
ast = pro.ast_squeeze(ast, options.squeeze_options); // get an AST with compression optimizations
var final_code = pro.gen_code(ast, options.gen_options); // compressed code here
return final_code;
};
uglify.parser = require("./lib/parse-js");
uglify.uglify = require("./lib/process");
uglify.consolidator = require("./lib/consolidator");
module.exports = uglify
importPackage(java.io);
function writeFile( file, stream ) {
var buffer = new PrintWriter( new FileWriter( file ) );
buffer.print( stream );
buffer.close();
}
function read( file ) {
var f = new File(file);
var reader = new BufferedReader(new FileReader(f));
var line = null;
var buffer = new java.lang.StringBuffer(f.length());
while( (line = reader.readLine()) != null) {
buffer.append(line);
buffer.append("\n");
}
return buffer.toString();
}
var options = {
ast: false,
consolidate: false,
mangle: true,
mangle_toplevel: false,
no_mangle_functions: false,
squeeze: true,
make_seqs: true,
dead_code: true,
verbose: false,
show_copyright: true,
out_same_file: false,
max_line_length: 32 * 1024,
unsafe: false,
reserved_names: null,
defines: { },
lift_vars: false,
codegen_options: {
ascii_only: false,
beautify: false,
indent_level: 4,
indent_start: 0,
quote_keys: false,
space_colon: false,
inline_script: false
},
make: false,
output: true // stdout
};
if (arguments.length < 2) {
print('Invalid input\nUsage: uglify inputFile outputFile');
quit();
}
if (arguments.indexOf('-v')) {
print('Uglifying '+arguments[0] +'\nOutput: '+arguments[1]);
}
//read input file
var input = read(arguments[0]) + '';
var output = uglify(input, options);
writeFile(arguments[1], output);