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.
Files changed (215) hide show
  1. data/dist/handlebars/handlebars.js +1493 -0
  2. data/dist/hashchange/{jquery.ba-hashchange.js → hashchange.js} +0 -0
  3. data/dist/jazz/lib/controller.js +1 -1
  4. data/dist/jazz/lib/core.js +3 -0
  5. data/dist/jazz/lib/db.js +1 -1
  6. data/dist/jazz/lib/helper.js +2 -1
  7. data/dist/jazz/lib/model.js +11 -4
  8. data/dist/jazz/lib/view.js +1 -1
  9. data/dist/jazz/module.js +15 -0
  10. data/dist/jquery/jquery.js +0 -0
  11. data/dist/require/require.js +0 -0
  12. data/dist/require/template.js +98 -0
  13. data/dist/underscore/underscore.js +0 -0
  14. data/lib/jazz/app_detector.rb +6 -3
  15. data/lib/jazz/app_generator.rb +12 -8
  16. data/lib/jazz/helper_generator.rb +30 -0
  17. data/lib/jazz/scaffold_generator.rb +4 -0
  18. data/templates/app_root/Rakefile +11 -0
  19. data/templates/app_root/{app → development/app}/assets/javascripts/application.js +0 -0
  20. data/templates/app_root/{app → development/app}/assets/stylesheets/application.css +0 -0
  21. data/templates/app_root/development/app/controllers/application_controller.js +11 -0
  22. data/templates/app_root/development/app/helpers/application_helper.js +7 -0
  23. data/templates/app_root/development/config/glue.js +9 -0
  24. data/templates/app_root/development/config/routes.js +5 -0
  25. data/templates/app_root/scripts/build.js +30 -0
  26. data/templates/app_root/scripts/r.js/LICENSE +58 -0
  27. data/templates/app_root/scripts/r.js/README.md +177 -0
  28. data/templates/app_root/scripts/r.js/build/build.js +26 -0
  29. data/templates/app_root/scripts/r.js/build/buildebug.sh +4 -0
  30. data/templates/app_root/scripts/r.js/build/example.build.js +296 -0
  31. data/templates/app_root/scripts/r.js/build/jslib/blank.js +4 -0
  32. data/templates/app_root/scripts/r.js/build/jslib/build.js +952 -0
  33. data/templates/app_root/scripts/r.js/build/jslib/commandLine.js +23 -0
  34. data/templates/app_root/scripts/r.js/build/jslib/commonJs.js +152 -0
  35. data/templates/app_root/scripts/r.js/build/jslib/env.js +47 -0
  36. data/templates/app_root/scripts/r.js/build/jslib/lang.js +49 -0
  37. data/templates/app_root/scripts/r.js/build/jslib/logger.js +58 -0
  38. data/templates/app_root/scripts/r.js/build/jslib/node.js +106 -0
  39. data/templates/app_root/scripts/r.js/build/jslib/node/args.js +20 -0
  40. data/templates/app_root/scripts/r.js/build/jslib/node/file.js +263 -0
  41. data/templates/app_root/scripts/r.js/build/jslib/node/load.js +17 -0
  42. data/templates/app_root/scripts/r.js/build/jslib/node/optimize.js +10 -0
  43. data/templates/app_root/scripts/r.js/build/jslib/node/print.js +16 -0
  44. data/templates/app_root/scripts/r.js/build/jslib/optimize.js +279 -0
  45. data/templates/app_root/scripts/r.js/build/jslib/opto.build.js +11 -0
  46. data/templates/app_root/scripts/r.js/build/jslib/parse.js +590 -0
  47. data/templates/app_root/scripts/r.js/build/jslib/pragma.js +251 -0
  48. data/templates/app_root/scripts/r.js/build/jslib/requirePatch.js +286 -0
  49. data/templates/app_root/scripts/r.js/build/jslib/rhino.js +22 -0
  50. data/templates/app_root/scripts/r.js/build/jslib/rhino/args.js +21 -0
  51. data/templates/app_root/scripts/r.js/build/jslib/rhino/file.js +244 -0
  52. data/templates/app_root/scripts/r.js/build/jslib/rhino/load.js +12 -0
  53. data/templates/app_root/scripts/r.js/build/jslib/rhino/optimize.js +100 -0
  54. data/templates/app_root/scripts/r.js/build/jslib/rhino/print.js +12 -0
  55. data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/README.md +16 -0
  56. data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/index.js +21 -0
  57. data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/parse-js.js +1342 -0
  58. data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/process.js +2005 -0
  59. data/templates/app_root/scripts/r.js/build/jslib/uglifyjs/squeeze-more.js +55 -0
  60. data/templates/app_root/scripts/r.js/build/jslib/x.js +243 -0
  61. data/templates/app_root/scripts/r.js/build/tests/all.js +47 -0
  62. data/templates/app_root/scripts/r.js/build/tests/allj.sh +3 -0
  63. data/templates/app_root/scripts/r.js/build/tests/alln.sh +18 -0
  64. data/templates/app_root/scripts/r.js/build/tests/anonSimple.build.js +7 -0
  65. data/templates/app_root/scripts/r.js/build/tests/buildUtils.js +19 -0
  66. data/templates/app_root/scripts/r.js/build/tests/builds.js +489 -0
  67. data/templates/app_root/scripts/r.js/build/tests/circular.build.js +18 -0
  68. data/templates/app_root/scripts/r.js/build/tests/convert.js +18 -0
  69. data/templates/app_root/scripts/r.js/build/tests/css.build.js +6 -0
  70. data/templates/app_root/scripts/r.js/build/tests/css/common/common.css +4 -0
  71. data/templates/app_root/scripts/r.js/build/tests/css/master.css +10 -0
  72. data/templates/app_root/scripts/r.js/build/tests/css/sub/sub1.css +7 -0
  73. data/templates/app_root/scripts/r.js/build/tests/cssTestCompare.css +13 -0
  74. data/templates/app_root/scripts/r.js/build/tests/end.frag +3 -0
  75. data/templates/app_root/scripts/r.js/build/tests/expected/unoExcludeShallow.js +23 -0
  76. data/templates/app_root/scripts/r.js/build/tests/exports.build.js +12 -0
  77. data/templates/app_root/scripts/r.js/build/tests/hasTestModule.build.js +10 -0
  78. data/templates/app_root/scripts/r.js/build/tests/hasTestModule.js +30 -0
  79. data/templates/app_root/scripts/r.js/build/tests/http/httpBuild.js +70 -0
  80. data/templates/app_root/scripts/r.js/build/tests/http/main.html +28 -0
  81. data/templates/app_root/scripts/r.js/build/tests/http/scripts/main.js +18 -0
  82. data/templates/app_root/scripts/r.js/build/tests/http/scripts/one.js +3 -0
  83. data/templates/app_root/scripts/r.js/build/tests/http/scripts/three.js +5 -0
  84. data/templates/app_root/scripts/r.js/build/tests/http/scripts/two.js +7 -0
  85. data/templates/app_root/scripts/r.js/build/tests/i18n.build.js +17 -0
  86. data/templates/app_root/scripts/r.js/build/tests/indexBuilder.build.js +8 -0
  87. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/a.js +17 -0
  88. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/b.js +8 -0
  89. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/build.js +6 -0
  90. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/c.js +7 -0
  91. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/d.js +5 -0
  92. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/expected.js +36 -0
  93. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/LICENSE +58 -0
  94. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/amdefine.js +188 -0
  95. data/templates/app_root/scripts/r.js/build/tests/lib/amdefine/node_modules/amdefine/package.json +21 -0
  96. data/templates/app_root/scripts/r.js/build/tests/lib/comments/bang.js +10 -0
  97. data/templates/app_root/scripts/r.js/build/tests/lib/comments/build.js +6 -0
  98. data/templates/app_root/scripts/r.js/build/tests/lib/comments/expected.js +9 -0
  99. data/templates/app_root/scripts/r.js/build/tests/lib/comments/license.js +13 -0
  100. data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/app.build.js +15 -0
  101. data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/main-expected.js +13 -0
  102. data/templates/app_root/scripts/r.js/build/tests/lib/dotpackage/scripts/main.js +7 -0
  103. data/templates/app_root/scripts/r.js/build/tests/lib/empty/build.js +13 -0
  104. data/templates/app_root/scripts/r.js/build/tests/lib/empty/expected.js +8 -0
  105. data/templates/app_root/scripts/r.js/build/tests/lib/empty/main.js +1 -0
  106. data/templates/app_root/scripts/r.js/build/tests/lib/empty/sub1.js +1 -0
  107. data/templates/app_root/scripts/r.js/build/tests/lib/empty/sub2.js +1 -0
  108. data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/build.js +6 -0
  109. data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/expected.js +12 -0
  110. data/templates/app_root/scripts/r.js/build/tests/lib/nameInsertion/main.js +9 -0
  111. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/build.js +8 -0
  112. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/expected.js +47 -0
  113. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/main.js +6 -0
  114. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/four.js +7 -0
  115. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/one.js +9 -0
  116. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/three.js +14 -0
  117. data/templates/app_root/scripts/r.js/build/tests/lib/namespace/modules/two.js +5 -0
  118. data/templates/app_root/scripts/r.js/build/tests/lib/nested/a.js +12 -0
  119. data/templates/app_root/scripts/r.js/build/tests/lib/nested/b.js +3 -0
  120. data/templates/app_root/scripts/r.js/build/tests/lib/nested/build.js +6 -0
  121. data/templates/app_root/scripts/r.js/build/tests/lib/nested/buildWithCE.js +7 -0
  122. data/templates/app_root/scripts/r.js/build/tests/lib/nested/c.js +3 -0
  123. data/templates/app_root/scripts/r.js/build/tests/lib/nested/d.js +3 -0
  124. data/templates/app_root/scripts/r.js/build/tests/lib/nested/e.js +3 -0
  125. data/templates/app_root/scripts/r.js/build/tests/lib/nested/expected-built.js +36 -0
  126. data/templates/app_root/scripts/r.js/build/tests/lib/nested/expected-builtWithCE.js +42 -0
  127. data/templates/app_root/scripts/r.js/build/tests/lib/nested/main.js +3 -0
  128. data/templates/app_root/scripts/r.js/build/tests/lib/nested/top.js +10 -0
  129. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/a.js +3 -0
  130. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/b.js +3 -0
  131. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/build.js +6 -0
  132. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedAll.js +9 -0
  133. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedB.js +11 -0
  134. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedC.js +11 -0
  135. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNeedD.js +11 -0
  136. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/buildNested.js +7 -0
  137. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/c.js +3 -0
  138. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/d.js +3 -0
  139. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-built.js +21 -0
  140. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedAll.js +31 -0
  141. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedB.js +24 -0
  142. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedC.js +24 -0
  143. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNeedD.js +25 -0
  144. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/expected-builtNested.js +31 -0
  145. data/templates/app_root/scripts/r.js/build/tests/lib/nestedHas/main.js +17 -0
  146. data/templates/app_root/scripts/r.js/build/tests/lib/plugins/build.js +6 -0
  147. data/templates/app_root/scripts/r.js/build/tests/lib/plugins/converter.js +11 -0
  148. data/templates/app_root/scripts/r.js/build/tests/lib/plugins/main.js +6 -0
  149. data/templates/app_root/scripts/r.js/build/tests/lib/plugins/plug.js +29 -0
  150. data/templates/app_root/scripts/r.js/build/tests/lib/plugins/util.js +7 -0
  151. data/templates/app_root/scripts/r.js/build/tests/nameOnly.build.js +10 -0
  152. data/templates/app_root/scripts/r.js/build/tests/nodeAll.js +3 -0
  153. data/templates/app_root/scripts/r.js/build/tests/nodeOptimize.js +12 -0
  154. data/templates/app_root/scripts/r.js/build/tests/nodeOptimizeNoCallback.js +10 -0
  155. data/templates/app_root/scripts/r.js/build/tests/order.build.js +16 -0
  156. data/templates/app_root/scripts/r.js/build/tests/override/override.js +36 -0
  157. data/templates/app_root/scripts/r.js/build/tests/packages.build.js +59 -0
  158. data/templates/app_root/scripts/r.js/build/tests/parse.js +103 -0
  159. data/templates/app_root/scripts/r.js/build/tests/simple.build.js +13 -0
  160. data/templates/app_root/scripts/r.js/build/tests/simpleNamespace.build.js +17 -0
  161. data/templates/app_root/scripts/r.js/build/tests/start.frag +4 -0
  162. data/templates/app_root/scripts/r.js/build/tests/text.build.js +16 -0
  163. data/templates/app_root/scripts/r.js/build/tests/textExclude.build.js +16 -0
  164. data/templates/app_root/scripts/r.js/dist.js +95 -0
  165. data/templates/app_root/scripts/r.js/dist/README.md +6 -0
  166. data/templates/app_root/scripts/r.js/dist/r-1.0.0.js +9042 -0
  167. data/templates/app_root/scripts/r.js/dist/r-edge.js +9191 -0
  168. data/templates/app_root/scripts/r.js/dist/r.js +9099 -0
  169. data/templates/app_root/scripts/r.js/lib/closure/COPYING +202 -0
  170. data/templates/app_root/scripts/r.js/lib/closure/README +292 -0
  171. data/templates/app_root/scripts/r.js/lib/closure/compiler.jar +0 -0
  172. data/templates/app_root/scripts/r.js/lib/rhino/LICENSE +4 -0
  173. data/templates/app_root/scripts/r.js/lib/rhino/js.jar +0 -0
  174. data/templates/app_root/scripts/r.js/require.js +1952 -0
  175. data/templates/app_root/scripts/r.js/tasks.txt +2 -0
  176. data/templates/app_root/scripts/r.js/tests/all.js +49 -0
  177. data/templates/app_root/scripts/r.js/tests/allNode.js +3 -0
  178. data/templates/app_root/scripts/r.js/tests/allj.sh +1 -0
  179. data/templates/app_root/scripts/r.js/tests/alln.sh +2 -0
  180. data/templates/app_root/scripts/r.js/tests/alpha.js +3 -0
  181. data/templates/app_root/scripts/r.js/tests/beta.js +6 -0
  182. data/templates/app_root/scripts/r.js/tests/doh/LICENSE +195 -0
  183. data/templates/app_root/scripts/r.js/tests/doh/README +12 -0
  184. data/templates/app_root/scripts/r.js/tests/doh/_browserRunner.js +855 -0
  185. data/templates/app_root/scripts/r.js/tests/doh/_nodeRunner.js +20 -0
  186. data/templates/app_root/scripts/r.js/tests/doh/_rhinoRunner.js +17 -0
  187. data/templates/app_root/scripts/r.js/tests/doh/_sounds/LICENSE +10 -0
  188. data/templates/app_root/scripts/r.js/tests/doh/_sounds/doh.wav +0 -0
  189. data/templates/app_root/scripts/r.js/tests/doh/_sounds/dohaaa.wav +0 -0
  190. data/templates/app_root/scripts/r.js/tests/doh/_sounds/woohoo.wav +0 -0
  191. data/templates/app_root/scripts/r.js/tests/doh/runner.html +316 -0
  192. data/templates/app_root/scripts/r.js/tests/doh/runner.js +1499 -0
  193. data/templates/app_root/scripts/r.js/tests/doh/runner.sh +3 -0
  194. data/templates/app_root/scripts/r.js/tests/doh/small_logo.png +0 -0
  195. data/templates/app_root/scripts/r.js/tests/node/canvasTest.js +39 -0
  196. data/templates/app_root/scripts/r.js/tests/node/embedded/README.md +15 -0
  197. data/templates/app_root/scripts/r.js/tests/node/embedded/coffee/foo.coffee +1 -0
  198. data/templates/app_root/scripts/r.js/tests/node/embedded/main.js +13 -0
  199. data/templates/app_root/scripts/r.js/tests/node/embedded/scripts/bar.js +13 -0
  200. data/templates/app_root/scripts/r.js/tests/node/index.js +11 -0
  201. data/templates/app_root/scripts/r.js/tests/node/tests/alpha/foo.js +6 -0
  202. data/templates/app_root/scripts/r.js/tests/node/tests/alpha/hello.html +9 -0
  203. data/templates/app_root/scripts/r.js/tests/node/tests/foo.js +3 -0
  204. data/templates/app_root/scripts/r.js/tests/node/tests/server.js +11 -0
  205. data/templates/app_root/scripts/r.js/tests/relative.js +10 -0
  206. data/templates/app_root/scripts/r.js/tests/sub/betaSub.js +3 -0
  207. data/templates/application.js +6 -5
  208. data/templates/boot.js +42 -0
  209. data/templates/helper.js +9 -0
  210. data/templates/index.html +1 -1
  211. metadata +201 -11
  212. data/dist/jazz/main.js +0 -65
  213. data/dist/mustache/mustache.js +0 -324
  214. data/templates/app_root/config/routes.js +0 -4
  215. 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
+ });