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,251 @@
|
|
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 regexp: false, strict: false, plusplus: false */
|
8
|
+
/*global define: false */
|
9
|
+
|
10
|
+
define(['parse', 'logger'], function (parse, logger) {
|
11
|
+
|
12
|
+
function Temp() {}
|
13
|
+
|
14
|
+
function create(obj, mixin) {
|
15
|
+
Temp.prototype = obj;
|
16
|
+
var temp = new Temp(), prop;
|
17
|
+
|
18
|
+
//Avoid any extra memory hanging around
|
19
|
+
Temp.prototype = null;
|
20
|
+
|
21
|
+
if (mixin) {
|
22
|
+
for (prop in mixin) {
|
23
|
+
if (mixin.hasOwnProperty(prop) && !(prop in temp)) {
|
24
|
+
temp[prop] = mixin[prop];
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
return temp; // Object
|
30
|
+
}
|
31
|
+
|
32
|
+
var pragma = {
|
33
|
+
conditionalRegExp: /(exclude|include)Start\s*\(\s*["'](\w+)["']\s*,(.*)\)/,
|
34
|
+
useStrictRegExp: /['"]use strict['"];/g,
|
35
|
+
hasRegExp: /has\s*\(\s*['"]([^'"]+)['"]\s*\)/g,
|
36
|
+
nsRegExp: /(^|[^\.])(requirejs|require|define)\s*\(/,
|
37
|
+
nsWrapRegExp: /\/\*requirejs namespace: true \*\//,
|
38
|
+
apiDefRegExp: /var requirejs, require, define;/,
|
39
|
+
defineCheckRegExp: /typeof\s+define\s*===\s*["']function["']\s*&&\s*define\s*\.\s*amd/g,
|
40
|
+
defineJQueryRegExp: /typeof\s+define\s*===\s*["']function["']\s*&&\s*define\s*\.\s*amd\s*&&\s*define\s*\.\s*amd\s*\.\s*jQuery/g,
|
41
|
+
defineHasRegExp: /typeof\s+define\s*==(=)?\s*['"]function['"]\s*&&\s*typeof\s+define\.amd\s*==(=)?\s*['"]object['"]\s*&&\s*define\.amd/g,
|
42
|
+
defineTernaryRegExp: /typeof\s+define\s*===\s*['"]function["']\s*&&\s*define\s*\.\s*amd\s*\?\s*define/,
|
43
|
+
amdefineRegExp: /if\s*\(\s*typeof define\s*\!==\s*'function'\s*\)\s*\{\s*[^\{\}]+amdefine[^\{\}]+\}/g,
|
44
|
+
|
45
|
+
removeStrict: function (contents, config) {
|
46
|
+
return config.useStrict ? contents : contents.replace(pragma.useStrictRegExp, '');
|
47
|
+
},
|
48
|
+
|
49
|
+
namespace: function (fileContents, ns, onLifecycleName) {
|
50
|
+
if (ns) {
|
51
|
+
//Namespace require/define calls
|
52
|
+
fileContents = fileContents.replace(pragma.nsRegExp, '$1' + ns + '.$2(');
|
53
|
+
|
54
|
+
//Namespace define ternary use:
|
55
|
+
fileContents = fileContents.replace(pragma.defineTernaryRegExp,
|
56
|
+
"typeof " + ns + ".define === 'function' && " + ns + ".define.amd ? " + ns + ".define");
|
57
|
+
|
58
|
+
//Namespace define jquery use:
|
59
|
+
fileContents = fileContents.replace(pragma.defineJQueryRegExp,
|
60
|
+
"typeof " + ns + ".define === 'function' && " + ns + ".define.amd && " + ns + ".define.jQuery");
|
61
|
+
|
62
|
+
//Namespace has.js define use:
|
63
|
+
fileContents = fileContents.replace(pragma.defineHasRegExp,
|
64
|
+
"typeof " + ns + ".define === 'function' && typeof " + ns + ".define.amd === 'object' && " + ns + ".define.amd");
|
65
|
+
|
66
|
+
//Namespace define checks.
|
67
|
+
//Do this one last, since it is a subset of the more specific
|
68
|
+
//checks above.
|
69
|
+
fileContents = fileContents.replace(pragma.defineCheckRegExp,
|
70
|
+
"typeof " + ns + ".define === 'function' && " + ns + ".define.amd");
|
71
|
+
|
72
|
+
//Check for require.js with the require/define definitions
|
73
|
+
if (pragma.apiDefRegExp.test(fileContents) &&
|
74
|
+
fileContents.indexOf("if (typeof " + ns + " === 'undefined')") === -1) {
|
75
|
+
//Wrap the file contents in a typeof check, and a function
|
76
|
+
//to contain the API globals.
|
77
|
+
fileContents = "var " + ns + ";(function () { if (typeof " +
|
78
|
+
ns + " === 'undefined') {\n" +
|
79
|
+
ns + ' = {};\n' +
|
80
|
+
fileContents +
|
81
|
+
"\n" +
|
82
|
+
ns + ".requirejs = requirejs;" +
|
83
|
+
ns + ".require = require;" +
|
84
|
+
ns + ".define = define;\n" +
|
85
|
+
"}\n}());";
|
86
|
+
}
|
87
|
+
|
88
|
+
//Finally, if the file wants a special wrapper because it ties
|
89
|
+
//in to the requirejs internals in a way that would not fit
|
90
|
+
//the above matches, do that. Look for /*requirejs namespace: true*/
|
91
|
+
if (pragma.nsWrapRegExp.test(fileContents)) {
|
92
|
+
//Remove the pragma.
|
93
|
+
fileContents = fileContents.replace(pragma.nsWrapRegExp, '');
|
94
|
+
|
95
|
+
//Alter the contents.
|
96
|
+
fileContents = '(function () {\n' +
|
97
|
+
'var require = ' + ns + '.require,' +
|
98
|
+
'requirejs = ' + ns + '.requirejs,' +
|
99
|
+
'define = ' + ns + '.define;\n' +
|
100
|
+
fileContents +
|
101
|
+
'\n}());'
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
return fileContents;
|
106
|
+
},
|
107
|
+
|
108
|
+
/**
|
109
|
+
* processes the fileContents for some //>> conditional statements
|
110
|
+
*/
|
111
|
+
process: function (fileName, fileContents, config, onLifecycleName, pluginCollector) {
|
112
|
+
/*jslint evil: true */
|
113
|
+
var foundIndex = -1, startIndex = 0, lineEndIndex, conditionLine,
|
114
|
+
matches, type, marker, condition, isTrue, endRegExp, endMatches,
|
115
|
+
endMarkerIndex, shouldInclude, startLength, lifecycleHas, deps,
|
116
|
+
i, dep, moduleName,
|
117
|
+
lifecyclePragmas, pragmas = config.pragmas, hasConfig = config.has,
|
118
|
+
//Legacy arg defined to help in dojo conversion script. Remove later
|
119
|
+
//when dojo no longer needs conversion:
|
120
|
+
kwArgs = pragmas;
|
121
|
+
|
122
|
+
//Mix in a specific lifecycle scoped object, to allow targeting
|
123
|
+
//some pragmas/has tests to only when files are saved, or at different
|
124
|
+
//lifecycle events. Do not bother with kwArgs in this section, since
|
125
|
+
//the old dojo kwArgs were for all points in the build lifecycle.
|
126
|
+
if (onLifecycleName) {
|
127
|
+
lifecyclePragmas = config['pragmas' + onLifecycleName];
|
128
|
+
lifecycleHas = config['has' + onLifecycleName];
|
129
|
+
|
130
|
+
if (lifecyclePragmas) {
|
131
|
+
pragmas = create(pragmas || {}, lifecyclePragmas);
|
132
|
+
}
|
133
|
+
|
134
|
+
if (lifecycleHas) {
|
135
|
+
hasConfig = create(hasConfig || {}, lifecycleHas);
|
136
|
+
}
|
137
|
+
}
|
138
|
+
|
139
|
+
//Replace has references if desired
|
140
|
+
if (hasConfig) {
|
141
|
+
fileContents = fileContents.replace(pragma.hasRegExp, function (match, test) {
|
142
|
+
if (test in hasConfig) {
|
143
|
+
return !!hasConfig[test];
|
144
|
+
}
|
145
|
+
return match;
|
146
|
+
});
|
147
|
+
}
|
148
|
+
|
149
|
+
if (!config.skipPragmas) {
|
150
|
+
|
151
|
+
while ((foundIndex = fileContents.indexOf("//>>", startIndex)) !== -1) {
|
152
|
+
//Found a conditional. Get the conditional line.
|
153
|
+
lineEndIndex = fileContents.indexOf("\n", foundIndex);
|
154
|
+
if (lineEndIndex === -1) {
|
155
|
+
lineEndIndex = fileContents.length - 1;
|
156
|
+
}
|
157
|
+
|
158
|
+
//Increment startIndex past the line so the next conditional search can be done.
|
159
|
+
startIndex = lineEndIndex + 1;
|
160
|
+
|
161
|
+
//Break apart the conditional.
|
162
|
+
conditionLine = fileContents.substring(foundIndex, lineEndIndex + 1);
|
163
|
+
matches = conditionLine.match(pragma.conditionalRegExp);
|
164
|
+
if (matches) {
|
165
|
+
type = matches[1];
|
166
|
+
marker = matches[2];
|
167
|
+
condition = matches[3];
|
168
|
+
isTrue = false;
|
169
|
+
//See if the condition is true.
|
170
|
+
try {
|
171
|
+
isTrue = !!eval("(" + condition + ")");
|
172
|
+
} catch (e) {
|
173
|
+
throw "Error in file: " +
|
174
|
+
fileName +
|
175
|
+
". Conditional comment: " +
|
176
|
+
conditionLine +
|
177
|
+
" failed with this error: " + e;
|
178
|
+
}
|
179
|
+
|
180
|
+
//Find the endpoint marker.
|
181
|
+
endRegExp = new RegExp('\\/\\/\\>\\>\\s*' + type + 'End\\(\\s*[\'"]' + marker + '[\'"]\\s*\\)', "g");
|
182
|
+
endMatches = endRegExp.exec(fileContents.substring(startIndex, fileContents.length));
|
183
|
+
if (endMatches) {
|
184
|
+
endMarkerIndex = startIndex + endRegExp.lastIndex - endMatches[0].length;
|
185
|
+
|
186
|
+
//Find the next line return based on the match position.
|
187
|
+
lineEndIndex = fileContents.indexOf("\n", endMarkerIndex);
|
188
|
+
if (lineEndIndex === -1) {
|
189
|
+
lineEndIndex = fileContents.length - 1;
|
190
|
+
}
|
191
|
+
|
192
|
+
//Should we include the segment?
|
193
|
+
shouldInclude = ((type === "exclude" && !isTrue) || (type === "include" && isTrue));
|
194
|
+
|
195
|
+
//Remove the conditional comments, and optionally remove the content inside
|
196
|
+
//the conditional comments.
|
197
|
+
startLength = startIndex - foundIndex;
|
198
|
+
fileContents = fileContents.substring(0, foundIndex) +
|
199
|
+
(shouldInclude ? fileContents.substring(startIndex, endMarkerIndex) : "") +
|
200
|
+
fileContents.substring(lineEndIndex + 1, fileContents.length);
|
201
|
+
|
202
|
+
//Move startIndex to foundIndex, since that is the new position in the file
|
203
|
+
//where we need to look for more conditionals in the next while loop pass.
|
204
|
+
startIndex = foundIndex;
|
205
|
+
} else {
|
206
|
+
throw "Error in file: " +
|
207
|
+
fileName +
|
208
|
+
". Cannot find end marker for conditional comment: " +
|
209
|
+
conditionLine;
|
210
|
+
|
211
|
+
}
|
212
|
+
}
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
//If need to find all plugin resources to optimize, do that now,
|
217
|
+
//before namespacing, since the namespacing will change the API
|
218
|
+
//names.
|
219
|
+
//If there is a plugin collector, scan the file for plugin resources.
|
220
|
+
if (config.optimizeAllPluginResources && pluginCollector) {
|
221
|
+
try {
|
222
|
+
deps = parse.findDependencies(fileName, fileContents);
|
223
|
+
if (deps.length) {
|
224
|
+
for (i = 0; (dep = deps[i]); i++) {
|
225
|
+
if (dep.indexOf('!') !== -1) {
|
226
|
+
(pluginCollector[moduleName] ||
|
227
|
+
(pluginCollector[moduleName] = [])).push(dep);
|
228
|
+
}
|
229
|
+
}
|
230
|
+
}
|
231
|
+
} catch (eDep) {
|
232
|
+
logger.error('Parse error looking for plugin resources in ' +
|
233
|
+
fileName + ', skipping.');
|
234
|
+
}
|
235
|
+
}
|
236
|
+
|
237
|
+
//Strip amdefine use for node-shared modules.
|
238
|
+
fileContents = fileContents.replace(pragma.amdefineRegExp, '');
|
239
|
+
|
240
|
+
//Do namespacing
|
241
|
+
if (onLifecycleName === 'OnSave' && config.namespace) {
|
242
|
+
fileContents = pragma.namespace(fileContents, config.namespace, onLifecycleName);
|
243
|
+
}
|
244
|
+
|
245
|
+
|
246
|
+
return pragma.removeStrict(fileContents, config);
|
247
|
+
}
|
248
|
+
};
|
249
|
+
|
250
|
+
return pragma;
|
251
|
+
});
|
@@ -0,0 +1,286 @@
|
|
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
|
+
* This file patches require.js to communicate with the build system.
|
8
|
+
*/
|
9
|
+
|
10
|
+
/*jslint nomen: false, plusplus: false, regexp: false, strict: false */
|
11
|
+
/*global require: false, define: true */
|
12
|
+
|
13
|
+
//NOT asking for require as a dependency since the goal is to modify the
|
14
|
+
//global require below
|
15
|
+
define([ 'env!env/file', 'pragma', 'parse'],
|
16
|
+
function (file, pragma, parse) {
|
17
|
+
|
18
|
+
var allowRun = true;
|
19
|
+
|
20
|
+
//This method should be called when the patches to require should take hold.
|
21
|
+
return function () {
|
22
|
+
if (!allowRun) {
|
23
|
+
return;
|
24
|
+
}
|
25
|
+
allowRun = false;
|
26
|
+
|
27
|
+
var layer,
|
28
|
+
pluginBuilderRegExp = /(["']?)pluginBuilder(["']?)\s*[=\:]\s*["']([^'"\s]+)["']/,
|
29
|
+
oldDef;
|
30
|
+
|
31
|
+
|
32
|
+
/** Print out some extrs info about the module tree that caused the error. **/
|
33
|
+
require.onError = function (err) {
|
34
|
+
|
35
|
+
var msg = '\nIn module tree:\n',
|
36
|
+
standardIndent = ' ',
|
37
|
+
tree = err.moduleTree,
|
38
|
+
i, j, mod;
|
39
|
+
|
40
|
+
if (tree && tree.length > 0) {
|
41
|
+
for (i = tree.length - 1; i > -1 && (mod = tree[i]); i--) {
|
42
|
+
for (j = tree.length - i; j > -1; j--) {
|
43
|
+
msg += standardIndent;
|
44
|
+
}
|
45
|
+
msg += mod + '\n';
|
46
|
+
}
|
47
|
+
|
48
|
+
err = new Error(err.toString() + msg);
|
49
|
+
}
|
50
|
+
|
51
|
+
throw err;
|
52
|
+
};
|
53
|
+
|
54
|
+
//Stored cached file contents for reuse in other layers.
|
55
|
+
require._cachedFileContents = {};
|
56
|
+
|
57
|
+
/** Reset state for each build layer pass. */
|
58
|
+
require._buildReset = function () {
|
59
|
+
var oldContext = require.s.contexts._;
|
60
|
+
|
61
|
+
//Clear up the existing context.
|
62
|
+
delete require.s.contexts._;
|
63
|
+
|
64
|
+
//Set up new context, so the layer object can hold onto it.
|
65
|
+
require({});
|
66
|
+
|
67
|
+
layer = require._layer = {
|
68
|
+
buildPathMap: {},
|
69
|
+
buildFileToModule: {},
|
70
|
+
buildFilePaths: [],
|
71
|
+
pathAdded: {},
|
72
|
+
modulesWithNames: {},
|
73
|
+
needsDefine: {},
|
74
|
+
existingRequireUrl: "",
|
75
|
+
context: require.s.contexts._
|
76
|
+
};
|
77
|
+
|
78
|
+
//Return the previous context in case it is needed, like for
|
79
|
+
//the basic config object.
|
80
|
+
return oldContext;
|
81
|
+
};
|
82
|
+
|
83
|
+
require._buildReset();
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Makes sure the URL is something that can be supported by the
|
87
|
+
* optimization tool.
|
88
|
+
* @param {String} url
|
89
|
+
* @returns {Boolean}
|
90
|
+
*/
|
91
|
+
require._isSupportedBuildUrl = function (url) {
|
92
|
+
//Ignore URLs with protocols or question marks, means either network
|
93
|
+
//access is needed to fetch it or it is too dynamic. Note that
|
94
|
+
//on Windows, full paths are used for some urls, which include
|
95
|
+
//the drive, like c:/something, so need to test for something other
|
96
|
+
//than just a colon.
|
97
|
+
return url.indexOf("://") === -1 && url.indexOf("?") === -1 &&
|
98
|
+
url.indexOf('empty:') !== 0;
|
99
|
+
};
|
100
|
+
|
101
|
+
//Override define() to catch modules that just define an object, so that
|
102
|
+
//a dummy define call is not put in the build file for them. They do
|
103
|
+
//not end up getting defined via require.execCb, so we need to catch them
|
104
|
+
//at the define call.
|
105
|
+
oldDef = define;
|
106
|
+
|
107
|
+
//This function signature does not have to be exact, just match what we
|
108
|
+
//are looking for.
|
109
|
+
define = function (name, obj) {
|
110
|
+
if (typeof name === "string" && !layer.needsDefine[name]) {
|
111
|
+
layer.modulesWithNames[name] = true;
|
112
|
+
}
|
113
|
+
return oldDef.apply(require, arguments);
|
114
|
+
};
|
115
|
+
|
116
|
+
define.amd = oldDef.amd;
|
117
|
+
|
118
|
+
//Add some utilities for plugins
|
119
|
+
require._readFile = file.readFile;
|
120
|
+
require._fileExists = function (path) {
|
121
|
+
return file.exists(path);
|
122
|
+
};
|
123
|
+
|
124
|
+
function normalizeUrlWithBase(context, moduleName, url) {
|
125
|
+
//Adjust the URL if it was not transformed to use baseUrl.
|
126
|
+
if (require.jsExtRegExp.test(moduleName)) {
|
127
|
+
url = (context.config.dir || context.config.dirBaseUrl) + url;
|
128
|
+
}
|
129
|
+
return url;
|
130
|
+
}
|
131
|
+
|
132
|
+
//Override load so that the file paths can be collected.
|
133
|
+
require.load = function (context, moduleName, url) {
|
134
|
+
/*jslint evil: true */
|
135
|
+
var contents, pluginBuilderMatch, builderName;
|
136
|
+
|
137
|
+
//Adjust the URL if it was not transformed to use baseUrl.
|
138
|
+
url = normalizeUrlWithBase(context, moduleName, url);
|
139
|
+
|
140
|
+
context.scriptCount += 1;
|
141
|
+
|
142
|
+
//Only handle urls that can be inlined, so that means avoiding some
|
143
|
+
//URLs like ones that require network access or may be too dynamic,
|
144
|
+
//like JSONP
|
145
|
+
if (require._isSupportedBuildUrl(url)) {
|
146
|
+
//Save the module name to path and path to module name mappings.
|
147
|
+
layer.buildPathMap[moduleName] = url;
|
148
|
+
layer.buildFileToModule[url] = moduleName;
|
149
|
+
|
150
|
+
if (moduleName in context.plugins) {
|
151
|
+
//plugins need to have their source evaled as-is.
|
152
|
+
context.needFullExec[moduleName] = true;
|
153
|
+
}
|
154
|
+
|
155
|
+
try {
|
156
|
+
if (url in require._cachedFileContents &&
|
157
|
+
(!context.needFullExec[moduleName] || context.fullExec[moduleName])) {
|
158
|
+
contents = require._cachedFileContents[url];
|
159
|
+
} else {
|
160
|
+
//Load the file contents, process for conditionals, then
|
161
|
+
//evaluate it.
|
162
|
+
contents = file.readFile(url);
|
163
|
+
contents = pragma.process(url, contents, context.config, 'OnExecute');
|
164
|
+
|
165
|
+
//Find out if the file contains a require() definition. Need to know
|
166
|
+
//this so we can inject plugins right after it, but before they are needed,
|
167
|
+
//and to make sure this file is first, so that define calls work.
|
168
|
+
//This situation mainly occurs when the build is done on top of the output
|
169
|
+
//of another build, where the first build may include require somewhere in it.
|
170
|
+
if (!layer.existingRequireUrl && parse.definesRequire(url, contents)) {
|
171
|
+
layer.existingRequireUrl = url;
|
172
|
+
}
|
173
|
+
|
174
|
+
if (moduleName in context.plugins) {
|
175
|
+
//This is a loader plugin, check to see if it has a build extension,
|
176
|
+
//otherwise the plugin will act as the plugin builder too.
|
177
|
+
pluginBuilderMatch = pluginBuilderRegExp.exec(contents);
|
178
|
+
if (pluginBuilderMatch) {
|
179
|
+
//Load the plugin builder for the plugin contents.
|
180
|
+
builderName = context.normalize(pluginBuilderMatch[3], moduleName);
|
181
|
+
contents = file.readFile(context.nameToUrl(builderName));
|
182
|
+
}
|
183
|
+
}
|
184
|
+
|
185
|
+
//Parse out the require and define calls.
|
186
|
+
//Do this even for plugins in case they have their own
|
187
|
+
//dependencies that may be separate to how the pluginBuilder works.
|
188
|
+
if (!context.needFullExec[moduleName]) {
|
189
|
+
contents = parse(moduleName, url, contents, {
|
190
|
+
insertNeedsDefine: true,
|
191
|
+
has: context.config.has,
|
192
|
+
findNestedDependencies: context.config.findNestedDependencies
|
193
|
+
});
|
194
|
+
}
|
195
|
+
|
196
|
+
require._cachedFileContents[url] = contents;
|
197
|
+
}
|
198
|
+
|
199
|
+
if (contents) {
|
200
|
+
eval(contents);
|
201
|
+
}
|
202
|
+
|
203
|
+
//Need to close out completion of this module
|
204
|
+
//so that listeners will get notified that it is available.
|
205
|
+
try {
|
206
|
+
context.completeLoad(moduleName);
|
207
|
+
} catch (e) {
|
208
|
+
//Track which module could not complete loading.
|
209
|
+
(e.moduleTree || (e.moduleTree = [])).push(moduleName);
|
210
|
+
throw e;
|
211
|
+
}
|
212
|
+
|
213
|
+
} catch (eOuter) {
|
214
|
+
if (!eOuter.fileName) {
|
215
|
+
eOuter.fileName = url;
|
216
|
+
}
|
217
|
+
throw eOuter;
|
218
|
+
}
|
219
|
+
} else {
|
220
|
+
//With unsupported URLs still need to call completeLoad to
|
221
|
+
//finish loading.
|
222
|
+
context.completeLoad(moduleName);
|
223
|
+
}
|
224
|
+
|
225
|
+
//Mark the module loaded.
|
226
|
+
context.loaded[moduleName] = true;
|
227
|
+
};
|
228
|
+
|
229
|
+
|
230
|
+
//Called when execManager runs for a dependency. Used to figure out
|
231
|
+
//what order of execution.
|
232
|
+
require.onResourceLoad = function (context, map) {
|
233
|
+
var fullName = map.fullName,
|
234
|
+
url;
|
235
|
+
|
236
|
+
//Ignore "fake" modules, usually generated by plugin code, since
|
237
|
+
//they do not map back to a real file to include in the optimizer,
|
238
|
+
//or it will be included, but in a different form.
|
239
|
+
if (context.fake[fullName]) {
|
240
|
+
return;
|
241
|
+
}
|
242
|
+
|
243
|
+
//A plugin.
|
244
|
+
if (map.prefix) {
|
245
|
+
if (!layer.pathAdded[fullName]) {
|
246
|
+
layer.buildFilePaths.push(fullName);
|
247
|
+
//For plugins the real path is not knowable, use the name
|
248
|
+
//for both module to file and file to module mappings.
|
249
|
+
layer.buildPathMap[fullName] = fullName;
|
250
|
+
layer.buildFileToModule[fullName] = fullName;
|
251
|
+
layer.modulesWithNames[fullName] = true;
|
252
|
+
layer.pathAdded[fullName] = true;
|
253
|
+
}
|
254
|
+
} else if (map.url && require._isSupportedBuildUrl(map.url)) {
|
255
|
+
//If the url has not been added to the layer yet, and it
|
256
|
+
//is from an actual file that was loaded, add it now.
|
257
|
+
if (!layer.pathAdded[url] && layer.buildPathMap[fullName]) {
|
258
|
+
url = normalizeUrlWithBase(context, map.fullName, map.url);
|
259
|
+
//Remember the list of dependencies for this layer.
|
260
|
+
layer.buildFilePaths.push(url);
|
261
|
+
layer.pathAdded[url] = true;
|
262
|
+
}
|
263
|
+
}
|
264
|
+
};
|
265
|
+
|
266
|
+
//Called by output of the parse() function, when a file does not
|
267
|
+
//explicitly call define, probably just require, but the parse()
|
268
|
+
//function normalizes on define() for dependency mapping and file
|
269
|
+
//ordering works correctly.
|
270
|
+
require.needsDefine = function (moduleName) {
|
271
|
+
layer.needsDefine[moduleName] = true;
|
272
|
+
};
|
273
|
+
|
274
|
+
//Marks module has having a name, and optionally executes the
|
275
|
+
//callback, but only if it meets certain criteria.
|
276
|
+
require.execCb = function (name, cb, args, exports) {
|
277
|
+
if (!layer.needsDefine[name]) {
|
278
|
+
layer.modulesWithNames[name] = true;
|
279
|
+
}
|
280
|
+
if (cb.__requireJsBuild || layer.context.needFullExec[name]) {
|
281
|
+
return cb.apply(exports, args);
|
282
|
+
}
|
283
|
+
return undefined;
|
284
|
+
};
|
285
|
+
};
|
286
|
+
});
|