jazz-jss 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/dist/handlebars/handlebars.js +1493 -0
- data/dist/hashchange/{jquery.ba-hashchange.js → hashchange.js} +0 -0
- data/dist/jazz/lib/controller.js +1 -1
- data/dist/jazz/lib/core.js +3 -0
- data/dist/jazz/lib/db.js +1 -1
- data/dist/jazz/lib/helper.js +2 -1
- data/dist/jazz/lib/model.js +11 -4
- data/dist/jazz/lib/view.js +1 -1
- data/dist/jazz/module.js +15 -0
- data/dist/jquery/jquery.js +0 -0
- data/dist/require/require.js +0 -0
- data/dist/require/template.js +98 -0
- data/dist/underscore/underscore.js +0 -0
- data/lib/jazz/app_detector.rb +6 -3
- data/lib/jazz/app_generator.rb +12 -8
- data/lib/jazz/helper_generator.rb +30 -0
- data/lib/jazz/scaffold_generator.rb +4 -0
- data/templates/app_root/Rakefile +11 -0
- data/templates/app_root/{app → development/app}/assets/javascripts/application.js +0 -0
- data/templates/app_root/{app → development/app}/assets/stylesheets/application.css +0 -0
- data/templates/app_root/development/app/controllers/application_controller.js +11 -0
- data/templates/app_root/development/app/helpers/application_helper.js +7 -0
- data/templates/app_root/development/config/glue.js +9 -0
- data/templates/app_root/development/config/routes.js +5 -0
- data/templates/app_root/scripts/build.js +30 -0
- data/templates/app_root/scripts/r.js/LICENSE +58 -0
- data/templates/app_root/scripts/r.js/README.md +177 -0
- data/templates/app_root/scripts/r.js/build/build.js +26 -0
- data/templates/app_root/scripts/r.js/build/buildebug.sh +4 -0
- data/templates/app_root/scripts/r.js/build/example.build.js +296 -0
- data/templates/app_root/scripts/r.js/build/jslib/blank.js +4 -0
- data/templates/app_root/scripts/r.js/build/jslib/build.js +952 -0
- data/templates/app_root/scripts/r.js/build/jslib/commandLine.js +23 -0
- data/templates/app_root/scripts/r.js/build/jslib/commonJs.js +152 -0
- data/templates/app_root/scripts/r.js/build/jslib/env.js +47 -0
- data/templates/app_root/scripts/r.js/build/jslib/lang.js +49 -0
- data/templates/app_root/scripts/r.js/build/jslib/logger.js +58 -0
- data/templates/app_root/scripts/r.js/build/jslib/node.js +106 -0
- data/templates/app_root/scripts/r.js/build/jslib/node/args.js +20 -0
- data/templates/app_root/scripts/r.js/build/jslib/node/file.js +263 -0
- data/templates/app_root/scripts/r.js/build/jslib/node/load.js +17 -0
- data/templates/app_root/scripts/r.js/build/jslib/node/optimize.js +10 -0
- data/templates/app_root/scripts/r.js/build/jslib/node/print.js +16 -0
- data/templates/app_root/scripts/r.js/build/jslib/optimize.js +279 -0
- data/templates/app_root/scripts/r.js/build/jslib/opto.build.js +11 -0
- data/templates/app_root/scripts/r.js/build/jslib/parse.js +590 -0
- data/templates/app_root/scripts/r.js/build/jslib/pragma.js +251 -0
- data/templates/app_root/scripts/r.js/build/jslib/requirePatch.js +286 -0
- data/templates/app_root/scripts/r.js/build/jslib/rhino.js +22 -0
- data/templates/app_root/scripts/r.js/build/jslib/rhino/args.js +21 -0
- data/templates/app_root/scripts/r.js/build/jslib/rhino/file.js +244 -0
- data/templates/app_root/scripts/r.js/build/jslib/rhino/load.js +12 -0
- data/templates/app_root/scripts/r.js/build/jslib/rhino/optimize.js +100 -0
- data/templates/app_root/scripts/r.js/build/jslib/rhino/print.js +12 -0
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/README.md +16 -0
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/index.js +21 -0
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/parse-js.js +1342 -0
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/process.js +2005 -0
- data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/squeeze-more.js +55 -0
- data/templates/app_root/scripts/r.js/build/jslib/x.js +243 -0
- data/templates/app_root/scripts/r.js/build/tests/all.js +47 -0
- data/templates/app_root/scripts/r.js/build/tests/allj.sh +3 -0
- data/templates/app_root/scripts/r.js/build/tests/alln.sh +18 -0
- data/templates/app_root/scripts/r.js/build/tests/anonSimple.build.js +7 -0
- data/templates/app_root/scripts/r.js/build/tests/buildUtils.js +19 -0
- data/templates/app_root/scripts/r.js/build/tests/builds.js +489 -0
- data/templates/app_root/scripts/r.js/build/tests/circular.build.js +18 -0
- data/templates/app_root/scripts/r.js/build/tests/convert.js +18 -0
- data/templates/app_root/scripts/r.js/build/tests/css.build.js +6 -0
- data/templates/app_root/scripts/r.js/build/tests/css/common/common.css +4 -0
- data/templates/app_root/scripts/r.js/build/tests/css/master.css +10 -0
- data/templates/app_root/scripts/r.js/build/tests/css/sub/sub1.css +7 -0
- data/templates/app_root/scripts/r.js/build/tests/cssTestCompare.css +13 -0
- data/templates/app_root/scripts/r.js/build/tests/end.frag +3 -0
- data/templates/app_root/scripts/r.js/build/tests/expected/unoExcludeShallow.js +23 -0
- data/templates/app_root/scripts/r.js/build/tests/exports.build.js +12 -0
- data/templates/app_root/scripts/r.js/build/tests/hasTestModule.build.js +10 -0
- data/templates/app_root/scripts/r.js/build/tests/hasTestModule.js +30 -0
- data/templates/app_root/scripts/r.js/build/tests/http/httpBuild.js +70 -0
- data/templates/app_root/scripts/r.js/build/tests/http/main.html +28 -0
- data/templates/app_root/scripts/r.js/build/tests/http/scripts/main.js +18 -0
- data/templates/app_root/scripts/r.js/build/tests/http/scripts/one.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/http/scripts/three.js +5 -0
- data/templates/app_root/scripts/r.js/build/tests/http/scripts/two.js +7 -0
- data/templates/app_root/scripts/r.js/build/tests/i18n.build.js +17 -0
- data/templates/app_root/scripts/r.js/build/tests/indexBuilder.build.js +8 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/a.js +17 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/b.js +8 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/build.js +6 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/c.js +7 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/d.js +5 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/expected.js +36 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/LICENSE +58 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/amdefine.js +188 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/package.json +21 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/comments/bang.js +10 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/comments/build.js +6 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/comments/expected.js +9 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/comments/license.js +13 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/app.build.js +15 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/main-expected.js +13 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/main.js +7 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/build.js +13 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/expected.js +8 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/main.js +1 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/sub1.js +1 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/empty/sub2.js +1 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/build.js +6 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/expected.js +12 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/main.js +9 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/build.js +8 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/expected.js +47 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/main.js +6 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/four.js +7 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/one.js +9 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/three.js +14 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/two.js +5 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/a.js +12 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/b.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/build.js +6 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/buildWithCE.js +7 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/c.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/d.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/e.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/expected-built.js +36 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/expected-builtWithCE.js +42 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/main.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nested/top.js +10 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/a.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/b.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/build.js +6 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedAll.js +9 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedB.js +11 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedC.js +11 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedD.js +11 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNested.js +7 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/c.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/d.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-built.js +21 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedAll.js +31 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedB.js +24 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedC.js +24 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedD.js +25 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNested.js +31 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/main.js +17 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/build.js +6 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/converter.js +11 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/main.js +6 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/plug.js +29 -0
- data/templates/app_root/scripts/r.js/build/tests/lib/plugins/util.js +7 -0
- data/templates/app_root/scripts/r.js/build/tests/nameOnly.build.js +10 -0
- data/templates/app_root/scripts/r.js/build/tests/nodeAll.js +3 -0
- data/templates/app_root/scripts/r.js/build/tests/nodeOptimize.js +12 -0
- data/templates/app_root/scripts/r.js/build/tests/nodeOptimizeNoCallback.js +10 -0
- data/templates/app_root/scripts/r.js/build/tests/order.build.js +16 -0
- data/templates/app_root/scripts/r.js/build/tests/override/override.js +36 -0
- data/templates/app_root/scripts/r.js/build/tests/packages.build.js +59 -0
- data/templates/app_root/scripts/r.js/build/tests/parse.js +103 -0
- data/templates/app_root/scripts/r.js/build/tests/simple.build.js +13 -0
- data/templates/app_root/scripts/r.js/build/tests/simpleNamespace.build.js +17 -0
- data/templates/app_root/scripts/r.js/build/tests/start.frag +4 -0
- data/templates/app_root/scripts/r.js/build/tests/text.build.js +16 -0
- data/templates/app_root/scripts/r.js/build/tests/textExclude.build.js +16 -0
- data/templates/app_root/scripts/r.js/dist.js +95 -0
- data/templates/app_root/scripts/r.js/dist/README.md +6 -0
- data/templates/app_root/scripts/r.js/dist/r-1.0.0.js +9042 -0
- data/templates/app_root/scripts/r.js/dist/r-edge.js +9191 -0
- data/templates/app_root/scripts/r.js/dist/r.js +9099 -0
- data/templates/app_root/scripts/r.js/lib/closure/COPYING +202 -0
- data/templates/app_root/scripts/r.js/lib/closure/README +292 -0
- data/templates/app_root/scripts/r.js/lib/closure/compiler.jar +0 -0
- data/templates/app_root/scripts/r.js/lib/rhino/LICENSE +4 -0
- data/templates/app_root/scripts/r.js/lib/rhino/js.jar +0 -0
- data/templates/app_root/scripts/r.js/require.js +1952 -0
- data/templates/app_root/scripts/r.js/tasks.txt +2 -0
- data/templates/app_root/scripts/r.js/tests/all.js +49 -0
- data/templates/app_root/scripts/r.js/tests/allNode.js +3 -0
- data/templates/app_root/scripts/r.js/tests/allj.sh +1 -0
- data/templates/app_root/scripts/r.js/tests/alln.sh +2 -0
- data/templates/app_root/scripts/r.js/tests/alpha.js +3 -0
- data/templates/app_root/scripts/r.js/tests/beta.js +6 -0
- data/templates/app_root/scripts/r.js/tests/doh/LICENSE +195 -0
- data/templates/app_root/scripts/r.js/tests/doh/README +12 -0
- data/templates/app_root/scripts/r.js/tests/doh/_browserRunner.js +855 -0
- data/templates/app_root/scripts/r.js/tests/doh/_nodeRunner.js +20 -0
- data/templates/app_root/scripts/r.js/tests/doh/_rhinoRunner.js +17 -0
- data/templates/app_root/scripts/r.js/tests/doh/_sounds/LICENSE +10 -0
- data/templates/app_root/scripts/r.js/tests/doh/_sounds/doh.wav +0 -0
- data/templates/app_root/scripts/r.js/tests/doh/_sounds/dohaaa.wav +0 -0
- data/templates/app_root/scripts/r.js/tests/doh/_sounds/woohoo.wav +0 -0
- data/templates/app_root/scripts/r.js/tests/doh/runner.html +316 -0
- data/templates/app_root/scripts/r.js/tests/doh/runner.js +1499 -0
- data/templates/app_root/scripts/r.js/tests/doh/runner.sh +3 -0
- data/templates/app_root/scripts/r.js/tests/doh/small_logo.png +0 -0
- data/templates/app_root/scripts/r.js/tests/node/canvasTest.js +39 -0
- data/templates/app_root/scripts/r.js/tests/node/embedded/README.md +15 -0
- data/templates/app_root/scripts/r.js/tests/node/embedded/coffee/foo.coffee +1 -0
- data/templates/app_root/scripts/r.js/tests/node/embedded/main.js +13 -0
- data/templates/app_root/scripts/r.js/tests/node/embedded/scripts/bar.js +13 -0
- data/templates/app_root/scripts/r.js/tests/node/index.js +11 -0
- data/templates/app_root/scripts/r.js/tests/node/tests/alpha/foo.js +6 -0
- data/templates/app_root/scripts/r.js/tests/node/tests/alpha/hello.html +9 -0
- data/templates/app_root/scripts/r.js/tests/node/tests/foo.js +3 -0
- data/templates/app_root/scripts/r.js/tests/node/tests/server.js +11 -0
- data/templates/app_root/scripts/r.js/tests/relative.js +10 -0
- data/templates/app_root/scripts/r.js/tests/sub/betaSub.js +3 -0
- data/templates/application.js +6 -5
- data/templates/boot.js +42 -0
- data/templates/helper.js +9 -0
- data/templates/index.html +1 -1
- metadata +201 -11
- data/dist/jazz/main.js +0 -65
- data/dist/mustache/mustache.js +0 -324
- data/templates/app_root/config/routes.js +0 -4
- data/templates/glue.js +0 -4
@@ -0,0 +1,23 @@
|
|
1
|
+
/**
|
2
|
+
* @license RequireJS Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
|
3
|
+
* Available via the MIT or new BSD license.
|
4
|
+
* see: http://github.com/jrburke/requirejs for details
|
5
|
+
*/
|
6
|
+
|
7
|
+
/*jslint strict: false */
|
8
|
+
/*global Packages: false */
|
9
|
+
|
10
|
+
var commandLine = {};
|
11
|
+
(function () {
|
12
|
+
var runtime = Packages.java.lang.Runtime.getRuntime();
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Executes a command on the command line. May not work right in
|
16
|
+
* Windows environments, except maybe via something like cygwin.
|
17
|
+
* @param {String} command the command to run on the command line.
|
18
|
+
*/
|
19
|
+
commandLine.exec = function (command) {
|
20
|
+
var process = runtime.exec(["/bin/sh", "-c", command]);
|
21
|
+
process.waitFor();
|
22
|
+
};
|
23
|
+
}());
|
@@ -0,0 +1,152 @@
|
|
1
|
+
/**
|
2
|
+
* @license RequireJS Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
|
3
|
+
* Available via the MIT or new BSD license.
|
4
|
+
* see: http://github.com/jrburke/requirejs for details
|
5
|
+
*/
|
6
|
+
|
7
|
+
/*jslint plusplus: false, regexp: false, strict: false */
|
8
|
+
/*global define: false, console: false */
|
9
|
+
|
10
|
+
define(['env!env/file', 'uglifyjs/index'], function (file, uglify) {
|
11
|
+
var commonJs = {
|
12
|
+
depRegExp: /require\s*\(\s*["']([\w-_\.\/]+)["']\s*\)/g,
|
13
|
+
|
14
|
+
//Set this to false in non-rhino environments. If rhino, then it uses
|
15
|
+
//rhino's decompiler to remove comments before looking for require() calls,
|
16
|
+
//otherwise, it will use a crude regexp approach to remove comments. The
|
17
|
+
//rhino way is more robust, but he regexp is more portable across environments.
|
18
|
+
useRhino: true,
|
19
|
+
|
20
|
+
//Set to false if you do not want this file to log. Useful in environments
|
21
|
+
//like node where you want the work to happen without noise.
|
22
|
+
useLog: true,
|
23
|
+
|
24
|
+
convertDir: function (commonJsPath, savePath) {
|
25
|
+
var fileList, i,
|
26
|
+
jsFileRegExp = /\.js$/,
|
27
|
+
fileName, convertedFileName, fileContents;
|
28
|
+
|
29
|
+
//Get list of files to convert.
|
30
|
+
fileList = file.getFilteredFileList(commonJsPath, /\w/, true);
|
31
|
+
|
32
|
+
//Normalize on front slashes and make sure the paths do not end in a slash.
|
33
|
+
commonJsPath = commonJsPath.replace(/\\/g, "/");
|
34
|
+
savePath = savePath.replace(/\\/g, "/");
|
35
|
+
if (commonJsPath.charAt(commonJsPath.length - 1) === "/") {
|
36
|
+
commonJsPath = commonJsPath.substring(0, commonJsPath.length - 1);
|
37
|
+
}
|
38
|
+
if (savePath.charAt(savePath.length - 1) === "/") {
|
39
|
+
savePath = savePath.substring(0, savePath.length - 1);
|
40
|
+
}
|
41
|
+
|
42
|
+
//Cycle through all the JS files and convert them.
|
43
|
+
if (!fileList || !fileList.length) {
|
44
|
+
if (commonJs.useLog) {
|
45
|
+
if (commonJsPath === "convert") {
|
46
|
+
//A request just to convert one file.
|
47
|
+
console.log('\n\n' + commonJs.convert(savePath, file.readFile(savePath)));
|
48
|
+
} else {
|
49
|
+
console.log("No files to convert in directory: " + commonJsPath);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
} else {
|
53
|
+
for (i = 0; (fileName = fileList[i]); i++) {
|
54
|
+
convertedFileName = fileName.replace(commonJsPath, savePath);
|
55
|
+
|
56
|
+
//Handle JS files.
|
57
|
+
if (jsFileRegExp.test(fileName)) {
|
58
|
+
fileContents = file.readFile(fileName);
|
59
|
+
fileContents = commonJs.convert(fileName, fileContents);
|
60
|
+
file.saveUtf8File(convertedFileName, fileContents);
|
61
|
+
} else {
|
62
|
+
//Just copy the file over.
|
63
|
+
file.copyFile(fileName, convertedFileName, true);
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
67
|
+
},
|
68
|
+
|
69
|
+
/**
|
70
|
+
* Removes the comments from a string.
|
71
|
+
*
|
72
|
+
* @param {String} fileContents
|
73
|
+
* @param {String} fileName mostly used for informative reasons if an error.
|
74
|
+
*
|
75
|
+
* @returns {String} a string of JS with comments removed.
|
76
|
+
*/
|
77
|
+
removeComments: function (fileContents, fileName) {
|
78
|
+
//Uglify's ast generation removes comments, so just convert to ast,
|
79
|
+
//then back to source code to get rid of comments.
|
80
|
+
return uglify.uglify.gen_code(uglify.parser.parse(fileContents), true);
|
81
|
+
},
|
82
|
+
|
83
|
+
/**
|
84
|
+
* Regexp for testing if there is already a require.def call in the file,
|
85
|
+
* in which case do not try to convert it.
|
86
|
+
*/
|
87
|
+
defRegExp: /define\s*\(\s*("|'|\[|function)/,
|
88
|
+
|
89
|
+
/**
|
90
|
+
* Regexp for testing if there is a require([]) or require(function(){})
|
91
|
+
* call, indicating the file is already in requirejs syntax.
|
92
|
+
*/
|
93
|
+
rjsRegExp: /require\s*\(\s*(\[|function)/,
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Does the actual file conversion.
|
97
|
+
*
|
98
|
+
* @param {String} fileName the name of the file.
|
99
|
+
*
|
100
|
+
* @param {String} fileContents the contents of a file :)
|
101
|
+
*
|
102
|
+
* @param {Boolean} skipDeps if true, require("") dependencies
|
103
|
+
* will not be searched, but the contents will just be wrapped in the
|
104
|
+
* standard require, exports, module dependencies. Only usable in sync
|
105
|
+
* environments like Node where the require("") calls can be resolved on
|
106
|
+
* the fly.
|
107
|
+
*
|
108
|
+
* @returns {String} the converted contents
|
109
|
+
*/
|
110
|
+
convert: function (fileName, fileContents, skipDeps) {
|
111
|
+
//Strip out comments.
|
112
|
+
try {
|
113
|
+
var deps = [], depName, match,
|
114
|
+
//Remove comments
|
115
|
+
tempContents = commonJs.removeComments(fileContents, fileName);
|
116
|
+
|
117
|
+
//First see if the module is not already RequireJS-formatted.
|
118
|
+
if (commonJs.defRegExp.test(tempContents) || commonJs.rjsRegExp.test(tempContents)) {
|
119
|
+
return fileContents;
|
120
|
+
}
|
121
|
+
|
122
|
+
//Reset the regexp to start at beginning of file. Do this
|
123
|
+
//since the regexp is reused across files.
|
124
|
+
commonJs.depRegExp.lastIndex = 0;
|
125
|
+
|
126
|
+
if (!skipDeps) {
|
127
|
+
//Find dependencies in the code that was not in comments.
|
128
|
+
while ((match = commonJs.depRegExp.exec(tempContents))) {
|
129
|
+
depName = match[1];
|
130
|
+
if (depName) {
|
131
|
+
deps.push('"' + depName + '"');
|
132
|
+
}
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
//Construct the wrapper boilerplate.
|
137
|
+
fileContents = 'define(["require", "exports", "module"' +
|
138
|
+
(deps.length ? ', ' + deps.join(",") : '') + '], ' +
|
139
|
+
'function(require, exports, module) {\n' +
|
140
|
+
fileContents +
|
141
|
+
'\n});\n';
|
142
|
+
} catch (e) {
|
143
|
+
console.log("COULD NOT CONVERT: " + fileName + ", so skipping it. Error was: " + e);
|
144
|
+
return fileContents;
|
145
|
+
}
|
146
|
+
|
147
|
+
return fileContents;
|
148
|
+
}
|
149
|
+
};
|
150
|
+
|
151
|
+
return commonJs;
|
152
|
+
});
|
@@ -0,0 +1,47 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
|
3
|
+
* Available via the MIT or new BSD license.
|
4
|
+
* see: http://github.com/jrburke/requirejs for details
|
5
|
+
*/
|
6
|
+
|
7
|
+
/*jslint strict: false */
|
8
|
+
/*global Packages: false, process: false, window: false, navigator: false,
|
9
|
+
document: false, define: false */
|
10
|
+
|
11
|
+
/**
|
12
|
+
* A plugin that modifies any /env/ path to be the right path based on
|
13
|
+
* the host environment. Right now only works for Node, Rhino and browser.
|
14
|
+
*/
|
15
|
+
(function () {
|
16
|
+
var pathRegExp = /(\/|^)env\/|\{env\}/,
|
17
|
+
env = 'unknown';
|
18
|
+
|
19
|
+
if (typeof Packages !== 'undefined') {
|
20
|
+
env = 'rhino';
|
21
|
+
} else if (typeof process !== 'undefined') {
|
22
|
+
env = 'node';
|
23
|
+
} else if (typeof window !== "undefined" && navigator && document) {
|
24
|
+
env = 'browser';
|
25
|
+
}
|
26
|
+
|
27
|
+
define({
|
28
|
+
load: function (name, req, load, config) {
|
29
|
+
//Allow override in the config.
|
30
|
+
if (config.env) {
|
31
|
+
env = config.env;
|
32
|
+
}
|
33
|
+
|
34
|
+
name = name.replace(pathRegExp, function (match, prefix) {
|
35
|
+
if (match.indexOf('{') === -1) {
|
36
|
+
return prefix + env + '/';
|
37
|
+
} else {
|
38
|
+
return env;
|
39
|
+
}
|
40
|
+
});
|
41
|
+
|
42
|
+
req([name], function (mod) {
|
43
|
+
load(mod);
|
44
|
+
});
|
45
|
+
}
|
46
|
+
});
|
47
|
+
}());
|
@@ -0,0 +1,49 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
|
3
|
+
* Available via the MIT or new BSD license.
|
4
|
+
* see: http://github.com/jrburke/requirejs for details
|
5
|
+
*/
|
6
|
+
|
7
|
+
/*jslint plusplus: false, strict: false */
|
8
|
+
/*global define: false */
|
9
|
+
|
10
|
+
define(function () {
|
11
|
+
var lang = {
|
12
|
+
backSlashRegExp: /\\/g,
|
13
|
+
ostring: Object.prototype.toString,
|
14
|
+
|
15
|
+
isArray: Array.isArray ? Array.isArray : function (it) {
|
16
|
+
return lang.ostring.call(it) === "[object Array]";
|
17
|
+
},
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Simple function to mix in properties from source into target,
|
21
|
+
* but only if target does not already have a property of the same name.
|
22
|
+
*/
|
23
|
+
mixin: function (target, source, override) {
|
24
|
+
//Use an empty object to avoid other bad JS code that modifies
|
25
|
+
//Object.prototype.
|
26
|
+
var empty = {}, prop;
|
27
|
+
for (prop in source) {
|
28
|
+
if (override || !(prop in target)) {
|
29
|
+
target[prop] = source[prop];
|
30
|
+
}
|
31
|
+
}
|
32
|
+
},
|
33
|
+
|
34
|
+
delegate: (function () {
|
35
|
+
// boodman/crockford delegation w/ cornford optimization
|
36
|
+
function TMP() {}
|
37
|
+
return function (obj, props) {
|
38
|
+
TMP.prototype = obj;
|
39
|
+
var tmp = new TMP();
|
40
|
+
TMP.prototype = null;
|
41
|
+
if (props) {
|
42
|
+
lang.mixin(tmp, props);
|
43
|
+
}
|
44
|
+
return tmp; // Object
|
45
|
+
};
|
46
|
+
}())
|
47
|
+
};
|
48
|
+
return lang;
|
49
|
+
});
|
@@ -0,0 +1,58 @@
|
|
1
|
+
/**
|
2
|
+
* @license RequireJS Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
|
3
|
+
* Available via the MIT or new BSD license.
|
4
|
+
* see: http://github.com/jrburke/requirejs for details
|
5
|
+
*/
|
6
|
+
|
7
|
+
/*jslint nomen: false, strict: false */
|
8
|
+
/*global define: false */
|
9
|
+
|
10
|
+
define(['env!env/print'], function (print) {
|
11
|
+
var logger = {
|
12
|
+
TRACE: 0,
|
13
|
+
INFO: 1,
|
14
|
+
WARN: 2,
|
15
|
+
ERROR: 3,
|
16
|
+
SILENT: 4,
|
17
|
+
level: 0,
|
18
|
+
logPrefix: "",
|
19
|
+
|
20
|
+
logLevel: function( level ) {
|
21
|
+
this.level = level;
|
22
|
+
},
|
23
|
+
|
24
|
+
trace: function (message) {
|
25
|
+
if (this.level <= this.TRACE) {
|
26
|
+
this._print(message);
|
27
|
+
}
|
28
|
+
},
|
29
|
+
|
30
|
+
info: function (message) {
|
31
|
+
if (this.level <= this.INFO) {
|
32
|
+
this._print(message);
|
33
|
+
}
|
34
|
+
},
|
35
|
+
|
36
|
+
warn: function (message) {
|
37
|
+
if (this.level <= this.WARN) {
|
38
|
+
this._print(message);
|
39
|
+
}
|
40
|
+
},
|
41
|
+
|
42
|
+
error: function (message) {
|
43
|
+
if (this.level <= this.ERROR) {
|
44
|
+
this._print(message);
|
45
|
+
}
|
46
|
+
},
|
47
|
+
|
48
|
+
_print: function (message) {
|
49
|
+
this._sysPrint((this.logPrefix ? (this.logPrefix + " ") : "") + message);
|
50
|
+
},
|
51
|
+
|
52
|
+
_sysPrint: function (message) {
|
53
|
+
print(message);
|
54
|
+
}
|
55
|
+
};
|
56
|
+
|
57
|
+
return logger;
|
58
|
+
});
|
@@ -0,0 +1,106 @@
|
|
1
|
+
/**
|
2
|
+
* @license RequireJS node Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
|
3
|
+
* Available via the MIT or new BSD license.
|
4
|
+
* see: http://github.com/jrburke/requirejs for details
|
5
|
+
*/
|
6
|
+
|
7
|
+
/*jslint regexp: false, strict: false */
|
8
|
+
/*global require: false, define: false, requirejsVars: false, process: false */
|
9
|
+
|
10
|
+
/**
|
11
|
+
* This adapter assumes that x.js has loaded it and set up
|
12
|
+
* some variables. This adapter just allows limited RequireJS
|
13
|
+
* usage from within the requirejs directory. The general
|
14
|
+
* node adapater is r.js.
|
15
|
+
*/
|
16
|
+
|
17
|
+
(function () {
|
18
|
+
var nodeReq = requirejsVars.nodeRequire,
|
19
|
+
req = requirejsVars.require,
|
20
|
+
def = requirejsVars.define,
|
21
|
+
fs = nodeReq('fs'),
|
22
|
+
path = nodeReq('path'),
|
23
|
+
vm = nodeReq('vm');
|
24
|
+
|
25
|
+
//Supply an implementation that allows synchronous get of a module.
|
26
|
+
req.get = function (context, moduleName, relModuleMap) {
|
27
|
+
if (moduleName === "require" || moduleName === "exports" || moduleName === "module") {
|
28
|
+
req.onError(new Error("Explicit require of " + moduleName + " is not allowed."));
|
29
|
+
}
|
30
|
+
|
31
|
+
var ret,
|
32
|
+
moduleMap = context.makeModuleMap(moduleName, relModuleMap);
|
33
|
+
|
34
|
+
//Normalize module name, if it contains . or ..
|
35
|
+
moduleName = moduleMap.fullName;
|
36
|
+
|
37
|
+
if (moduleName in context.defined) {
|
38
|
+
ret = context.defined[moduleName];
|
39
|
+
} else {
|
40
|
+
if (ret === undefined) {
|
41
|
+
//Try to dynamically fetch it.
|
42
|
+
req.load(context, moduleName, moduleMap.url);
|
43
|
+
//The above call is sync, so can do the next thing safely.
|
44
|
+
ret = context.defined[moduleName];
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
return ret;
|
49
|
+
};
|
50
|
+
|
51
|
+
//Add wrapper around the code so that it gets the requirejs
|
52
|
+
//API instead of the Node API, and it is done lexically so
|
53
|
+
//that it survives later execution.
|
54
|
+
req.makeNodeWrapper = function (contents) {
|
55
|
+
return '(function (require, requirejs, define) { ' +
|
56
|
+
contents +
|
57
|
+
'\n}(requirejsVars.require, requirejsVars.requirejs, requirejsVars.define));';
|
58
|
+
};
|
59
|
+
|
60
|
+
req.load = function (context, moduleName, url) {
|
61
|
+
var contents, err;
|
62
|
+
|
63
|
+
//Indicate a the module is in process of loading.
|
64
|
+
context.scriptCount += 1;
|
65
|
+
|
66
|
+
if (path.existsSync(url)) {
|
67
|
+
contents = fs.readFileSync(url, 'utf8');
|
68
|
+
|
69
|
+
contents = req.makeNodeWrapper(contents);
|
70
|
+
try {
|
71
|
+
vm.runInThisContext(contents, fs.realpathSync(url));
|
72
|
+
} catch (e) {
|
73
|
+
err = new Error('Evaluating ' + url + ' as module "' +
|
74
|
+
moduleName + '" failed with error: ' + e);
|
75
|
+
err.originalError = e;
|
76
|
+
err.moduleName = moduleName;
|
77
|
+
err.fileName = url;
|
78
|
+
return req.onError(err);
|
79
|
+
}
|
80
|
+
} else {
|
81
|
+
def(moduleName, function () {
|
82
|
+
try {
|
83
|
+
return (context.config.nodeRequire || req.nodeRequire)(moduleName);
|
84
|
+
} catch (e) {
|
85
|
+
err = new Error('Calling node\'s require("' +
|
86
|
+
moduleName + '") failed with error: ' + e);
|
87
|
+
err.originalError = e;
|
88
|
+
err.moduleName = moduleName;
|
89
|
+
return req.onError(err);
|
90
|
+
}
|
91
|
+
});
|
92
|
+
}
|
93
|
+
|
94
|
+
//Support anonymous modules.
|
95
|
+
context.completeLoad(moduleName);
|
96
|
+
|
97
|
+
return undefined;
|
98
|
+
};
|
99
|
+
|
100
|
+
//Override to provide the function wrapper for define/require.
|
101
|
+
req.exec = function (text) {
|
102
|
+
/*jslint evil: true */
|
103
|
+
text = req.makeNodeWrapper(text);
|
104
|
+
return eval(text);
|
105
|
+
};
|
106
|
+
}());
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
|
3
|
+
* Available via the MIT or new BSD license.
|
4
|
+
* see: http://github.com/jrburke/requirejs for details
|
5
|
+
*/
|
6
|
+
|
7
|
+
/*jslint strict: false */
|
8
|
+
/*global define: false, process: false */
|
9
|
+
|
10
|
+
define(function () {
|
11
|
+
//Do not return the "node" or "r.js" arguments
|
12
|
+
var args = process.argv.slice(2);
|
13
|
+
|
14
|
+
//Ignore any command option used for rq.js
|
15
|
+
if (args[0] && args[0].indexOf('-' === 0)) {
|
16
|
+
args = args.slice(1);
|
17
|
+
}
|
18
|
+
|
19
|
+
return args;
|
20
|
+
});
|