less-execjs 2.6.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (632) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.gitmodules +9 -0
  4. data/.rubocop.yml +8 -0
  5. data/.travis.yml +19 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE +177 -0
  8. data/README.md +55 -0
  9. data/Rakefile +8 -0
  10. data/bin/lessc +22 -0
  11. data/less-execjs.gemspec +34 -0
  12. data/lib/less-execjs.rb +1 -0
  13. data/lib/less.rb +29 -0
  14. data/lib/less/compiler.js +24 -0
  15. data/lib/less/defaults.rb +15 -0
  16. data/lib/less/errors.rb +16 -0
  17. data/lib/less/js/image-size.js +4 -0
  18. data/lib/less/js/image-size/.gitignore +7 -0
  19. data/lib/less/js/image-size/.jshintrc +19 -0
  20. data/lib/less/js/image-size/.travis.yml +12 -0
  21. data/lib/less/js/image-size/Contributors.md +9 -0
  22. data/lib/less/js/image-size/LICENSE +9 -0
  23. data/lib/less/js/image-size/Readme.md +87 -0
  24. data/lib/less/js/image-size/bin/image-size.js +36 -0
  25. data/lib/less/js/image-size/lib/detector.js +19 -0
  26. data/lib/less/js/image-size/lib/index.js +104 -0
  27. data/lib/less/js/image-size/lib/readUInt.js +11 -0
  28. data/lib/less/js/image-size/lib/types.js +12 -0
  29. data/lib/less/js/image-size/lib/types/bmp.js +17 -0
  30. data/lib/less/js/image-size/lib/types/gif.js +19 -0
  31. data/lib/less/js/image-size/lib/types/jpg.js +62 -0
  32. data/lib/less/js/image-size/lib/types/png.js +23 -0
  33. data/lib/less/js/image-size/lib/types/psd.js +17 -0
  34. data/lib/less/js/image-size/lib/types/svg.js +78 -0
  35. data/lib/less/js/image-size/lib/types/tiff.js +118 -0
  36. data/lib/less/js/image-size/lib/types/webp.js +51 -0
  37. data/lib/less/js/image-size/package.json +49 -0
  38. data/lib/less/js/image-size/specs/.jshintrc +9 -0
  39. data/lib/less/js/image-size/specs/complexity.js +58 -0
  40. data/lib/less/js/image-size/specs/fs-close.spec.js +61 -0
  41. data/lib/less/js/image-size/specs/images/invalid/malformed.svg +1 -0
  42. data/lib/less/js/image-size/specs/images/invalid/sample.png +0 -0
  43. data/lib/less/js/image-size/specs/images/invalid/width.svg +1 -0
  44. data/lib/less/js/image-size/specs/images/valid/bmp/sample.bmp +0 -0
  45. data/lib/less/js/image-size/specs/images/valid/gif/sample.gif +0 -0
  46. data/lib/less/js/image-size/specs/images/valid/jpg/large.jpg +0 -0
  47. data/lib/less/js/image-size/specs/images/valid/jpg/progressive.jpg +0 -0
  48. data/lib/less/js/image-size/specs/images/valid/jpg/sample.jpg +0 -0
  49. data/lib/less/js/image-size/specs/images/valid/jpg/sampleExported.jpg +0 -0
  50. data/lib/less/js/image-size/specs/images/valid/jpg/very-large.jpg +0 -0
  51. data/lib/less/js/image-size/specs/images/valid/png/sample.png +0 -0
  52. data/lib/less/js/image-size/specs/images/valid/psd/sample.psd +0 -0
  53. data/lib/less/js/image-size/specs/images/valid/svg/percentage.svg +4 -0
  54. data/lib/less/js/image-size/specs/images/valid/svg/single-quotes.svg +5 -0
  55. data/lib/less/js/image-size/specs/images/valid/svg/viewbox-height.svg +4 -0
  56. data/lib/less/js/image-size/specs/images/valid/svg/viewbox-width-height.svg +4 -0
  57. data/lib/less/js/image-size/specs/images/valid/svg/viewbox-width.svg +4 -0
  58. data/lib/less/js/image-size/specs/images/valid/svg/viewbox.svg +4 -0
  59. data/lib/less/js/image-size/specs/images/valid/svg/width-height.svg +5 -0
  60. data/lib/less/js/image-size/specs/images/valid/tiff/big-endian.tiff +0 -0
  61. data/lib/less/js/image-size/specs/images/valid/tiff/jpeg.tiff +0 -0
  62. data/lib/less/js/image-size/specs/images/valid/tiff/little-endian.tiff +0 -0
  63. data/lib/less/js/image-size/specs/images/valid/webp/lossless.webp +0 -0
  64. data/lib/less/js/image-size/specs/images/valid/webp/lossy.webp +0 -0
  65. data/lib/less/js/image-size/specs/invalid.spec.js +53 -0
  66. data/lib/less/js/image-size/specs/others.spec.js +77 -0
  67. data/lib/less/js/image-size/specs/unsupported.spec.js +34 -0
  68. data/lib/less/js/image-size/specs/valid.spec.js +75 -0
  69. data/lib/less/js/less/.gitattributes +11 -0
  70. data/lib/less/js/less/.gitignore +27 -0
  71. data/lib/less/js/less/.jscsrc +73 -0
  72. data/lib/less/js/less/.jshintrc +11 -0
  73. data/lib/less/js/less/.npmignore +9 -0
  74. data/lib/less/js/less/.travis.yml +14 -0
  75. data/lib/less/js/less/CHANGELOG.md +561 -0
  76. data/lib/less/js/less/CONTRIBUTING.md +50 -0
  77. data/lib/less/js/less/Gruntfile.js +459 -0
  78. data/lib/less/js/less/LICENSE +177 -0
  79. data/lib/less/js/less/README.md +56 -0
  80. data/lib/less/js/less/appveyor.yml +32 -0
  81. data/lib/less/js/less/benchmark/benchmark.less +3979 -0
  82. data/lib/less/js/less/benchmark/index.js +55 -0
  83. data/lib/less/js/less/bin/lessc +488 -0
  84. data/lib/less/js/less/bower.json +24 -0
  85. data/lib/less/js/less/browser.js +1 -0
  86. data/lib/less/js/less/build.gradle +347 -0
  87. data/lib/less/js/less/build/amd.js +6 -0
  88. data/lib/less/js/less/build/build.yml +130 -0
  89. data/lib/less/js/less/build/require-rhino.js +12 -0
  90. data/lib/less/js/less/build/rhino-header.js +4 -0
  91. data/lib/less/js/less/build/rhino-modules.js +131 -0
  92. data/lib/less/js/less/build/tasks/.gitkeep +1 -0
  93. data/lib/less/js/less/dist/less.js +10500 -0
  94. data/lib/less/js/less/dist/less.min.js +20 -0
  95. data/lib/less/js/less/gradle/wrapper/gradle-wrapper.jar +0 -0
  96. data/lib/less/js/less/gradle/wrapper/gradle-wrapper.properties +6 -0
  97. data/lib/less/js/less/gradlew +164 -0
  98. data/lib/less/js/less/gradlew.bat +90 -0
  99. data/lib/less/js/less/index.js +1 -0
  100. data/lib/less/js/less/lib/less-browser/add-default-options.js +46 -0
  101. data/lib/less/js/less/lib/less-browser/bootstrap.js +51 -0
  102. data/lib/less/js/less/lib/less-browser/browser.js +64 -0
  103. data/lib/less/js/less/lib/less-browser/cache.js +42 -0
  104. data/lib/less/js/less/lib/less-browser/error-reporting.js +170 -0
  105. data/lib/less/js/less/lib/less-browser/file-manager.js +119 -0
  106. data/lib/less/js/less/lib/less-browser/image-size.js +28 -0
  107. data/lib/less/js/less/lib/less-browser/index.js +263 -0
  108. data/lib/less/js/less/lib/less-browser/log-listener.js +43 -0
  109. data/lib/less/js/less/lib/less-browser/utils.js +24 -0
  110. data/lib/less/js/less/lib/less-node/environment.js +14 -0
  111. data/lib/less/js/less/lib/less-node/file-manager.js +108 -0
  112. data/lib/less/js/less/lib/less-node/fs.js +10 -0
  113. data/lib/less/js/less/lib/less-node/image-size.js +57 -0
  114. data/lib/less/js/less/lib/less-node/index.js +74 -0
  115. data/lib/less/js/less/lib/less-node/lessc-helper.js +82 -0
  116. data/lib/less/js/less/lib/less-node/plugin-loader.js +91 -0
  117. data/lib/less/js/less/lib/less-node/url-file-manager.js +56 -0
  118. data/lib/less/js/less/lib/less-rhino/index.js +450 -0
  119. data/lib/less/js/less/lib/less/contexts.js +111 -0
  120. data/lib/less/js/less/lib/less/data/colors.js +150 -0
  121. data/lib/less/js/less/lib/less/data/index.js +4 -0
  122. data/lib/less/js/less/lib/less/data/unit-conversions.js +21 -0
  123. data/lib/less/js/less/lib/less/environment/abstract-file-manager.js +123 -0
  124. data/lib/less/js/less/lib/less/environment/environment-api.js +25 -0
  125. data/lib/less/js/less/lib/less/environment/environment.js +51 -0
  126. data/lib/less/js/less/lib/less/environment/file-manager-api.js +103 -0
  127. data/lib/less/js/less/lib/less/functions/color-blending.js +74 -0
  128. data/lib/less/js/less/lib/less/functions/color.js +322 -0
  129. data/lib/less/js/less/lib/less/functions/data-uri.js +85 -0
  130. data/lib/less/js/less/lib/less/functions/default.js +27 -0
  131. data/lib/less/js/less/lib/less/functions/function-caller.js +46 -0
  132. data/lib/less/js/less/lib/less/functions/function-registry.js +29 -0
  133. data/lib/less/js/less/lib/less/functions/index.js +19 -0
  134. data/lib/less/js/less/lib/less/functions/math-helper.js +16 -0
  135. data/lib/less/js/less/lib/less/functions/math.js +29 -0
  136. data/lib/less/js/less/lib/less/functions/number.js +81 -0
  137. data/lib/less/js/less/lib/less/functions/string.js +37 -0
  138. data/lib/less/js/less/lib/less/functions/svg.js +88 -0
  139. data/lib/less/js/less/lib/less/functions/types.js +89 -0
  140. data/lib/less/js/less/lib/less/import-manager.js +131 -0
  141. data/lib/less/js/less/lib/less/index.js +29 -0
  142. data/lib/less/js/less/lib/less/less-error.js +42 -0
  143. data/lib/less/js/less/lib/less/logger.js +34 -0
  144. data/lib/less/js/less/lib/less/parse-tree.js +60 -0
  145. data/lib/less/js/less/lib/less/parse.js +68 -0
  146. data/lib/less/js/less/lib/less/parser/chunker.js +112 -0
  147. data/lib/less/js/less/lib/less/parser/parser-input.js +259 -0
  148. data/lib/less/js/less/lib/less/parser/parser.js +1851 -0
  149. data/lib/less/js/less/lib/less/plugin-manager.js +114 -0
  150. data/lib/less/js/less/lib/less/plugins/function-importer.js +35 -0
  151. data/lib/less/js/less/lib/less/render.js +41 -0
  152. data/lib/less/js/less/lib/less/source-map-builder.js +69 -0
  153. data/lib/less/js/less/lib/less/source-map-output.js +138 -0
  154. data/lib/less/js/less/lib/less/transform-tree.js +74 -0
  155. data/lib/less/js/less/lib/less/tree/alpha.js +28 -0
  156. data/lib/less/js/less/lib/less/tree/anonymous.js +26 -0
  157. data/lib/less/js/less/lib/less/tree/assignment.js +27 -0
  158. data/lib/less/js/less/lib/less/tree/attribute.js +27 -0
  159. data/lib/less/js/less/lib/less/tree/call.js +62 -0
  160. data/lib/less/js/less/lib/less/tree/color.js +189 -0
  161. data/lib/less/js/less/lib/less/tree/combinator.js +23 -0
  162. data/lib/less/js/less/lib/less/tree/comment.js +21 -0
  163. data/lib/less/js/less/lib/less/tree/condition.js +37 -0
  164. data/lib/less/js/less/lib/less/tree/debug-info.js +38 -0
  165. data/lib/less/js/less/lib/less/tree/detached-ruleset.js +21 -0
  166. data/lib/less/js/less/lib/less/tree/dimension.js +157 -0
  167. data/lib/less/js/less/lib/less/tree/directive.js +133 -0
  168. data/lib/less/js/less/lib/less/tree/element.js +60 -0
  169. data/lib/less/js/less/lib/less/tree/expression.js +56 -0
  170. data/lib/less/js/less/lib/less/tree/extend.js +56 -0
  171. data/lib/less/js/less/lib/less/tree/import.js +165 -0
  172. data/lib/less/js/less/lib/less/tree/index.js +41 -0
  173. data/lib/less/js/less/lib/less/tree/javascript.js +28 -0
  174. data/lib/less/js/less/lib/less/tree/js-eval-node.js +61 -0
  175. data/lib/less/js/less/lib/less/tree/keyword.js +14 -0
  176. data/lib/less/js/less/lib/less/tree/media.js +144 -0
  177. data/lib/less/js/less/lib/less/tree/mixin-call.js +182 -0
  178. data/lib/less/js/less/lib/less/tree/mixin-definition.js +200 -0
  179. data/lib/less/js/less/lib/less/tree/negative.js +20 -0
  180. data/lib/less/js/less/lib/less/tree/node.js +123 -0
  181. data/lib/less/js/less/lib/less/tree/operation.js +48 -0
  182. data/lib/less/js/less/lib/less/tree/paren.js +16 -0
  183. data/lib/less/js/less/lib/less/tree/quoted.js +55 -0
  184. data/lib/less/js/less/lib/less/tree/rule.js +95 -0
  185. data/lib/less/js/less/lib/less/tree/ruleset-call.js +13 -0
  186. data/lib/less/js/less/lib/less/tree/ruleset.js +709 -0
  187. data/lib/less/js/less/lib/less/tree/selector.js +111 -0
  188. data/lib/less/js/less/lib/less/tree/unicode-descriptor.js +9 -0
  189. data/lib/less/js/less/lib/less/tree/unit.js +120 -0
  190. data/lib/less/js/less/lib/less/tree/url.js +54 -0
  191. data/lib/less/js/less/lib/less/tree/value.js +34 -0
  192. data/lib/less/js/less/lib/less/tree/variable.js +53 -0
  193. data/lib/less/js/less/lib/less/utils.js +20 -0
  194. data/lib/less/js/less/lib/less/visitors/extend-visitor.js +460 -0
  195. data/lib/less/js/less/lib/less/visitors/import-sequencer.js +54 -0
  196. data/lib/less/js/less/lib/less/visitors/import-visitor.js +189 -0
  197. data/lib/less/js/less/lib/less/visitors/index.js +10 -0
  198. data/lib/less/js/less/lib/less/visitors/join-selector-visitor.js +51 -0
  199. data/lib/less/js/less/lib/less/visitors/set-tree-visibility-visitor.js +38 -0
  200. data/lib/less/js/less/lib/less/visitors/to-css-visitor.js +383 -0
  201. data/lib/less/js/less/lib/less/visitors/visitor.js +152 -0
  202. data/lib/less/js/less/lib/source-map/source-map-0.1.31.js +1933 -0
  203. data/lib/less/js/less/lib/source-map/source-map-footer.js +4 -0
  204. data/lib/less/js/less/lib/source-map/source-map-header.js +3 -0
  205. data/lib/less/js/less/package.json +89 -0
  206. data/lib/less/js/less/test/browser/common.js +206 -0
  207. data/lib/less/js/less/test/browser/css/global-vars/simple.css +3 -0
  208. data/lib/less/js/less/test/browser/css/modify-vars/simple.css +8 -0
  209. data/lib/less/js/less/test/browser/css/postProcessor/postProcessor.css +4 -0
  210. data/lib/less/js/less/test/browser/css/relative-urls/urls.css +36 -0
  211. data/lib/less/js/less/test/browser/css/rootpath-relative/urls.css +35 -0
  212. data/lib/less/js/less/test/browser/css/rootpath/urls.css +35 -0
  213. data/lib/less/js/less/test/browser/css/urls.css +57 -0
  214. data/lib/less/js/less/test/browser/jasmine-jsreporter.js +391 -0
  215. data/lib/less/js/less/test/browser/less/console-errors/test-error.less +3 -0
  216. data/lib/less/js/less/test/browser/less/console-errors/test-error.txt +2 -0
  217. data/lib/less/js/less/test/browser/less/errors/image-height-error.less +3 -0
  218. data/lib/less/js/less/test/browser/less/errors/image-height-error.txt +4 -0
  219. data/lib/less/js/less/test/browser/less/errors/image-size-error.less +3 -0
  220. data/lib/less/js/less/test/browser/less/errors/image-size-error.txt +4 -0
  221. data/lib/less/js/less/test/browser/less/errors/image-width-error.less +3 -0
  222. data/lib/less/js/less/test/browser/less/errors/image-width-error.txt +4 -0
  223. data/lib/less/js/less/test/browser/less/global-vars/simple.less +3 -0
  224. data/lib/less/js/less/test/browser/less/imports/urls.less +4 -0
  225. data/lib/less/js/less/test/browser/less/imports/urls2.less +4 -0
  226. data/lib/less/js/less/test/browser/less/modify-vars/imports/simple2.less +4 -0
  227. data/lib/less/js/less/test/browser/less/modify-vars/simple.less +8 -0
  228. data/lib/less/js/less/test/browser/less/nested-gradient-with-svg-gradient/mixin-consumer.less +5 -0
  229. data/lib/less/js/less/test/browser/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +15 -0
  230. data/lib/less/js/less/test/browser/less/postProcessor/postProcessor.less +4 -0
  231. data/lib/less/js/less/test/browser/less/relative-urls/urls.less +34 -0
  232. data/lib/less/js/less/test/browser/less/rootpath-relative/urls.less +33 -0
  233. data/lib/less/js/less/test/browser/less/rootpath/urls.less +33 -0
  234. data/lib/less/js/less/test/browser/less/urls.less +65 -0
  235. data/lib/less/js/less/test/browser/runner-VisitorPlugin-options.js +3 -0
  236. data/lib/less/js/less/test/browser/runner-VisitorPlugin.js +3 -0
  237. data/lib/less/js/less/test/browser/runner-browser-options.js +51 -0
  238. data/lib/less/js/less/test/browser/runner-browser-spec.js +12 -0
  239. data/lib/less/js/less/test/browser/runner-console-errors.js +5 -0
  240. data/lib/less/js/less/test/browser/runner-errors-options.js +4 -0
  241. data/lib/less/js/less/test/browser/runner-errors-spec.js +3 -0
  242. data/lib/less/js/less/test/browser/runner-filemanagerPlugin-options.js +4 -0
  243. data/lib/less/js/less/test/browser/runner-filemanagerPlugin.js +3 -0
  244. data/lib/less/js/less/test/browser/runner-global-vars-options.js +7 -0
  245. data/lib/less/js/less/test/browser/runner-global-vars-spec.js +3 -0
  246. data/lib/less/js/less/test/browser/runner-legacy-options.js +5 -0
  247. data/lib/less/js/less/test/browser/runner-legacy-spec.js +3 -0
  248. data/lib/less/js/less/test/browser/runner-main-options.js +18 -0
  249. data/lib/less/js/less/test/browser/runner-main-spec.js +7 -0
  250. data/lib/less/js/less/test/browser/runner-modify-vars-options.js +5 -0
  251. data/lib/less/js/less/test/browser/runner-modify-vars-spec.js +33 -0
  252. data/lib/less/js/less/test/browser/runner-no-js-errors-options.js +4 -0
  253. data/lib/less/js/less/test/browser/runner-no-js-errors-spec.js +3 -0
  254. data/lib/less/js/less/test/browser/runner-postProcessor-options.js +5 -0
  255. data/lib/less/js/less/test/browser/runner-postProcessor.js +3 -0
  256. data/lib/less/js/less/test/browser/runner-postProcessorPlugin-options.js +3 -0
  257. data/lib/less/js/less/test/browser/runner-postProcessorPlugin.js +3 -0
  258. data/lib/less/js/less/test/browser/runner-preProcessorPlugin-options.js +3 -0
  259. data/lib/less/js/less/test/browser/runner-preProcessorPlugin.js +3 -0
  260. data/lib/less/js/less/test/browser/runner-production-options.js +3 -0
  261. data/lib/less/js/less/test/browser/runner-production-spec.js +5 -0
  262. data/lib/less/js/less/test/browser/runner-relative-urls-options.js +3 -0
  263. data/lib/less/js/less/test/browser/runner-relative-urls-spec.js +3 -0
  264. data/lib/less/js/less/test/browser/runner-rootpath-options.js +3 -0
  265. data/lib/less/js/less/test/browser/runner-rootpath-relative-options.js +4 -0
  266. data/lib/less/js/less/test/browser/runner-rootpath-relative-spec.js +3 -0
  267. data/lib/less/js/less/test/browser/runner-rootpath-spec.js +3 -0
  268. data/lib/less/js/less/test/browser/runner-strict-units-options.js +5 -0
  269. data/lib/less/js/less/test/browser/runner-strict-units-spec.js +3 -0
  270. data/lib/less/js/less/test/browser/test-runner-template.tmpl +95 -0
  271. data/lib/less/js/less/test/copy-bom.js +72 -0
  272. data/lib/less/js/less/test/css/charsets.css +1 -0
  273. data/lib/less/js/less/test/css/colors.css +87 -0
  274. data/lib/less/js/less/test/css/comments.css +83 -0
  275. data/lib/less/js/less/test/css/comments2.css +18 -0
  276. data/lib/less/js/less/test/css/compression/compression.css +3 -0
  277. data/lib/less/js/less/test/css/css-3.css +157 -0
  278. data/lib/less/js/less/test/css/css-escapes.css +24 -0
  279. data/lib/less/js/less/test/css/css-guards.css +37 -0
  280. data/lib/less/js/less/test/css/css.css +95 -0
  281. data/lib/less/js/less/test/css/debug/linenumbers-all.css +50 -0
  282. data/lib/less/js/less/test/css/debug/linenumbers-comments.css +41 -0
  283. data/lib/less/js/less/test/css/debug/linenumbers-mediaquery.css +41 -0
  284. data/lib/less/js/less/test/css/detached-rulesets.css +76 -0
  285. data/lib/less/js/less/test/css/directives-bubling.css +119 -0
  286. data/lib/less/js/less/test/css/empty.css +0 -0
  287. data/lib/less/js/less/test/css/extend-chaining.css +81 -0
  288. data/lib/less/js/less/test/css/extend-clearfix.css +19 -0
  289. data/lib/less/js/less/test/css/extend-exact.css +37 -0
  290. data/lib/less/js/less/test/css/extend-media.css +24 -0
  291. data/lib/less/js/less/test/css/extend-nest.css +57 -0
  292. data/lib/less/js/less/test/css/extend-selector.css +87 -0
  293. data/lib/less/js/less/test/css/extend.css +76 -0
  294. data/lib/less/js/less/test/css/extract-and-length.css +133 -0
  295. data/lib/less/js/less/test/css/filemanagerPlugin/filemanager.css +3 -0
  296. data/lib/less/js/less/test/css/functions.css +201 -0
  297. data/lib/less/js/less/test/css/globalVars/extended.css +12 -0
  298. data/lib/less/js/less/test/css/globalVars/simple.css +6 -0
  299. data/lib/less/js/less/test/css/ie-filters.css +9 -0
  300. data/lib/less/js/less/test/css/import-inline.css +8 -0
  301. data/lib/less/js/less/test/css/import-interpolation.css +13 -0
  302. data/lib/less/js/less/test/css/import-once.css +15 -0
  303. data/lib/less/js/less/test/css/import-reference-issues.css +24 -0
  304. data/lib/less/js/less/test/css/import-reference.css +97 -0
  305. data/lib/less/js/less/test/css/import.css +49 -0
  306. data/lib/less/js/less/test/css/include-path-string/include-path-string.css +3 -0
  307. data/lib/less/js/less/test/css/include-path/include-path.css +9 -0
  308. data/lib/less/js/less/test/css/javascript.css +28 -0
  309. data/lib/less/js/less/test/css/lazy-eval.css +3 -0
  310. data/lib/less/js/less/test/css/legacy/legacy.css +21 -0
  311. data/lib/less/js/less/test/css/media.css +218 -0
  312. data/lib/less/js/less/test/css/merge.css +34 -0
  313. data/lib/less/js/less/test/css/mixins-args.css +163 -0
  314. data/lib/less/js/less/test/css/mixins-closure.css +9 -0
  315. data/lib/less/js/less/test/css/mixins-guards-default-func.css +129 -0
  316. data/lib/less/js/less/test/css/mixins-guards.css +211 -0
  317. data/lib/less/js/less/test/css/mixins-important.css +57 -0
  318. data/lib/less/js/less/test/css/mixins-interpolated.css +43 -0
  319. data/lib/less/js/less/test/css/mixins-named-args.css +27 -0
  320. data/lib/less/js/less/test/css/mixins-nested.css +14 -0
  321. data/lib/less/js/less/test/css/mixins-pattern.css +51 -0
  322. data/lib/less/js/less/test/css/mixins.css +144 -0
  323. data/lib/less/js/less/test/css/modifyVars/extended.css +9 -0
  324. data/lib/less/js/less/test/css/no-output.css +0 -0
  325. data/lib/less/js/less/test/css/no-strict-math/mixins-guards.css +12 -0
  326. data/lib/less/js/less/test/css/no-strict-math/no-sm-operations.css +12 -0
  327. data/lib/less/js/less/test/css/operations.css +50 -0
  328. data/lib/less/js/less/test/css/parens.css +36 -0
  329. data/lib/less/js/less/test/css/plugin.css +44 -0
  330. data/lib/less/js/less/test/css/postProcessorPlugin/postProcessor.css +4 -0
  331. data/lib/less/js/less/test/css/preProcessorPlugin/preProcessor.css +3 -0
  332. data/lib/less/js/less/test/css/property-name-interp.css +21 -0
  333. data/lib/less/js/less/test/css/rulesets.css +33 -0
  334. data/lib/less/js/less/test/css/scope.css +38 -0
  335. data/lib/less/js/less/test/css/selectors.css +170 -0
  336. data/lib/less/js/less/test/css/static-urls/urls.css +46 -0
  337. data/lib/less/js/less/test/css/strict-units/strict-units.css +4 -0
  338. data/lib/less/js/less/test/css/strings.css +55 -0
  339. data/lib/less/js/less/test/css/url-args/urls.css +56 -0
  340. data/lib/less/js/less/test/css/urls.css +87 -0
  341. data/lib/less/js/less/test/css/variables-in-at-rules.css +18 -0
  342. data/lib/less/js/less/test/css/variables.css +68 -0
  343. data/lib/less/js/less/test/css/visitorPlugin/visitor.css +3 -0
  344. data/lib/less/js/less/test/css/whitespace.css +42 -0
  345. data/lib/less/js/less/test/data/data-uri-fail.png +0 -0
  346. data/lib/less/js/less/test/data/image.jpg +0 -0
  347. data/lib/less/js/less/test/data/image.svg +4 -0
  348. data/lib/less/js/less/test/data/page.html +1 -0
  349. data/lib/less/js/less/test/index.js +59 -0
  350. data/lib/less/js/less/test/less-test.js +386 -0
  351. data/lib/less/js/less/test/less/charsets.less +3 -0
  352. data/lib/less/js/less/test/less/colors.less +98 -0
  353. data/lib/less/js/less/test/less/comments.less +102 -0
  354. data/lib/less/js/less/test/less/comments2.less +31 -0
  355. data/lib/less/js/less/test/less/compression/compression.less +36 -0
  356. data/lib/less/js/less/test/less/css-3.less +162 -0
  357. data/lib/less/js/less/test/less/css-escapes.less +33 -0
  358. data/lib/less/js/less/test/less/css-guards.less +103 -0
  359. data/lib/less/js/less/test/less/css.less +108 -0
  360. data/lib/less/js/less/test/less/debug/import/test.less +25 -0
  361. data/lib/less/js/less/test/less/debug/linenumbers.less +33 -0
  362. data/lib/less/js/less/test/less/detached-rulesets.less +112 -0
  363. data/lib/less/js/less/test/less/directives-bubling.less +142 -0
  364. data/lib/less/js/less/test/less/empty.less +0 -0
  365. data/lib/less/js/less/test/less/errors/add-mixed-units.less +3 -0
  366. data/lib/less/js/less/test/less/errors/add-mixed-units.txt +4 -0
  367. data/lib/less/js/less/test/less/errors/add-mixed-units2.less +3 -0
  368. data/lib/less/js/less/test/less/errors/add-mixed-units2.txt +4 -0
  369. data/lib/less/js/less/test/less/errors/at-rules-undefined-var.less +4 -0
  370. data/lib/less/js/less/test/less/errors/at-rules-undefined-var.txt +4 -0
  371. data/lib/less/js/less/test/less/errors/bad-variable-declaration1.less +1 -0
  372. data/lib/less/js/less/test/less/errors/bad-variable-declaration1.txt +2 -0
  373. data/lib/less/js/less/test/less/errors/color-func-invalid-color.less +3 -0
  374. data/lib/less/js/less/test/less/errors/color-func-invalid-color.txt +4 -0
  375. data/lib/less/js/less/test/less/errors/color-invalid-hex-code.less +3 -0
  376. data/lib/less/js/less/test/less/errors/color-invalid-hex-code.txt +4 -0
  377. data/lib/less/js/less/test/less/errors/color-invalid-hex-code2.less +3 -0
  378. data/lib/less/js/less/test/less/errors/color-invalid-hex-code2.txt +4 -0
  379. data/lib/less/js/less/test/less/errors/css-guard-default-func.less +4 -0
  380. data/lib/less/js/less/test/less/errors/css-guard-default-func.txt +4 -0
  381. data/lib/less/js/less/test/less/errors/detached-ruleset-1.less +6 -0
  382. data/lib/less/js/less/test/less/errors/detached-ruleset-1.txt +4 -0
  383. data/lib/less/js/less/test/less/errors/detached-ruleset-2.less +6 -0
  384. data/lib/less/js/less/test/less/errors/detached-ruleset-2.txt +4 -0
  385. data/lib/less/js/less/test/less/errors/detached-ruleset-3.less +4 -0
  386. data/lib/less/js/less/test/less/errors/detached-ruleset-3.txt +4 -0
  387. data/lib/less/js/less/test/less/errors/detached-ruleset-5.less +4 -0
  388. data/lib/less/js/less/test/less/errors/detached-ruleset-5.txt +3 -0
  389. data/lib/less/js/less/test/less/errors/detached-ruleset-6.less +5 -0
  390. data/lib/less/js/less/test/less/errors/detached-ruleset-6.txt +4 -0
  391. data/lib/less/js/less/test/less/errors/divide-mixed-units.less +3 -0
  392. data/lib/less/js/less/test/less/errors/divide-mixed-units.txt +4 -0
  393. data/lib/less/js/less/test/less/errors/extend-no-selector.less +3 -0
  394. data/lib/less/js/less/test/less/errors/extend-no-selector.txt +3 -0
  395. data/lib/less/js/less/test/less/errors/extend-not-at-end.less +3 -0
  396. data/lib/less/js/less/test/less/errors/extend-not-at-end.txt +3 -0
  397. data/lib/less/js/less/test/less/errors/import-malformed.less +1 -0
  398. data/lib/less/js/less/test/less/errors/import-malformed.txt +3 -0
  399. data/lib/less/js/less/test/less/errors/import-missing.less +6 -0
  400. data/lib/less/js/less/test/less/errors/import-missing.txt +3 -0
  401. data/lib/less/js/less/test/less/errors/import-no-semi.less +1 -0
  402. data/lib/less/js/less/test/less/errors/import-no-semi.txt +2 -0
  403. data/lib/less/js/less/test/less/errors/import-subfolder1.less +1 -0
  404. data/lib/less/js/less/test/less/errors/import-subfolder1.txt +3 -0
  405. data/lib/less/js/less/test/less/errors/import-subfolder2.less +1 -0
  406. data/lib/less/js/less/test/less/errors/import-subfolder2.txt +4 -0
  407. data/lib/less/js/less/test/less/errors/imports/import-subfolder1.less +1 -0
  408. data/lib/less/js/less/test/less/errors/imports/import-subfolder2.less +1 -0
  409. data/lib/less/js/less/test/less/errors/imports/import-test.less +4 -0
  410. data/lib/less/js/less/test/less/errors/imports/subfolder/mixin-not-defined.less +1 -0
  411. data/lib/less/js/less/test/less/errors/imports/subfolder/parse-error-curly-bracket.less +1 -0
  412. data/lib/less/js/less/test/less/errors/javascript-error.less +3 -0
  413. data/lib/less/js/less/test/less/errors/javascript-error.txt +4 -0
  414. data/lib/less/js/less/test/less/errors/javascript-undefined-var.less +3 -0
  415. data/lib/less/js/less/test/less/errors/javascript-undefined-var.txt +4 -0
  416. data/lib/less/js/less/test/less/errors/mixed-mixin-definition-args-1.less +6 -0
  417. data/lib/less/js/less/test/less/errors/mixed-mixin-definition-args-1.txt +4 -0
  418. data/lib/less/js/less/test/less/errors/mixed-mixin-definition-args-2.less +6 -0
  419. data/lib/less/js/less/test/less/errors/mixed-mixin-definition-args-2.txt +4 -0
  420. data/lib/less/js/less/test/less/errors/mixin-not-defined.less +11 -0
  421. data/lib/less/js/less/test/less/errors/mixin-not-defined.txt +3 -0
  422. data/lib/less/js/less/test/less/errors/mixin-not-matched.less +6 -0
  423. data/lib/less/js/less/test/less/errors/mixin-not-matched.txt +3 -0
  424. data/lib/less/js/less/test/less/errors/mixin-not-matched2.less +6 -0
  425. data/lib/less/js/less/test/less/errors/mixin-not-matched2.txt +3 -0
  426. data/lib/less/js/less/test/less/errors/mixin-not-visible-in-scope-1.less +9 -0
  427. data/lib/less/js/less/test/less/errors/mixin-not-visible-in-scope-1.txt +4 -0
  428. data/lib/less/js/less/test/less/errors/mixins-guards-default-func-1.less +9 -0
  429. data/lib/less/js/less/test/less/errors/mixins-guards-default-func-1.txt +4 -0
  430. data/lib/less/js/less/test/less/errors/mixins-guards-default-func-2.less +9 -0
  431. data/lib/less/js/less/test/less/errors/mixins-guards-default-func-2.txt +4 -0
  432. data/lib/less/js/less/test/less/errors/mixins-guards-default-func-3.less +9 -0
  433. data/lib/less/js/less/test/less/errors/mixins-guards-default-func-3.txt +4 -0
  434. data/lib/less/js/less/test/less/errors/multiple-guards-on-css-selectors.less +4 -0
  435. data/lib/less/js/less/test/less/errors/multiple-guards-on-css-selectors.txt +4 -0
  436. data/lib/less/js/less/test/less/errors/multiple-guards-on-css-selectors2.less +4 -0
  437. data/lib/less/js/less/test/less/errors/multiple-guards-on-css-selectors2.txt +4 -0
  438. data/lib/less/js/less/test/less/errors/multiply-mixed-units.less +7 -0
  439. data/lib/less/js/less/test/less/errors/multiply-mixed-units.txt +4 -0
  440. data/lib/less/js/less/test/less/errors/parens-error-1.less +3 -0
  441. data/lib/less/js/less/test/less/errors/parens-error-1.txt +4 -0
  442. data/lib/less/js/less/test/less/errors/parens-error-2.less +3 -0
  443. data/lib/less/js/less/test/less/errors/parens-error-2.txt +4 -0
  444. data/lib/less/js/less/test/less/errors/parens-error-3.less +3 -0
  445. data/lib/less/js/less/test/less/errors/parens-error-3.txt +4 -0
  446. data/lib/less/js/less/test/less/errors/parse-error-curly-bracket.less +4 -0
  447. data/lib/less/js/less/test/less/errors/parse-error-curly-bracket.txt +4 -0
  448. data/lib/less/js/less/test/less/errors/parse-error-media-no-block-1.less +5 -0
  449. data/lib/less/js/less/test/less/errors/parse-error-media-no-block-1.txt +3 -0
  450. data/lib/less/js/less/test/less/errors/parse-error-media-no-block-2.less +1 -0
  451. data/lib/less/js/less/test/less/errors/parse-error-media-no-block-2.txt +2 -0
  452. data/lib/less/js/less/test/less/errors/parse-error-media-no-block-3.less +4 -0
  453. data/lib/less/js/less/test/less/errors/parse-error-media-no-block-3.txt +3 -0
  454. data/lib/less/js/less/test/less/errors/parse-error-missing-bracket.less +2 -0
  455. data/lib/less/js/less/test/less/errors/parse-error-missing-bracket.txt +3 -0
  456. data/lib/less/js/less/test/less/errors/parse-error-missing-parens.less +5 -0
  457. data/lib/less/js/less/test/less/errors/parse-error-missing-parens.txt +3 -0
  458. data/lib/less/js/less/test/less/errors/parse-error-with-import.less +13 -0
  459. data/lib/less/js/less/test/less/errors/parse-error-with-import.txt +4 -0
  460. data/lib/less/js/less/test/less/errors/percentage-missing-space.less +3 -0
  461. data/lib/less/js/less/test/less/errors/percentage-missing-space.txt +4 -0
  462. data/lib/less/js/less/test/less/errors/percentage-non-number-argument.less +3 -0
  463. data/lib/less/js/less/test/less/errors/percentage-non-number-argument.txt +4 -0
  464. data/lib/less/js/less/test/less/errors/property-asterisk-only-name.less +3 -0
  465. data/lib/less/js/less/test/less/errors/property-asterisk-only-name.txt +4 -0
  466. data/lib/less/js/less/test/less/errors/property-ie5-hack.less +3 -0
  467. data/lib/less/js/less/test/less/errors/property-ie5-hack.txt +3 -0
  468. data/lib/less/js/less/test/less/errors/property-in-root.less +4 -0
  469. data/lib/less/js/less/test/less/errors/property-in-root.txt +4 -0
  470. data/lib/less/js/less/test/less/errors/property-in-root2.less +1 -0
  471. data/lib/less/js/less/test/less/errors/property-in-root2.txt +4 -0
  472. data/lib/less/js/less/test/less/errors/property-in-root3.less +4 -0
  473. data/lib/less/js/less/test/less/errors/property-in-root3.txt +3 -0
  474. data/lib/less/js/less/test/less/errors/property-interp-not-defined.less +1 -0
  475. data/lib/less/js/less/test/less/errors/property-interp-not-defined.txt +2 -0
  476. data/lib/less/js/less/test/less/errors/recursive-variable.less +1 -0
  477. data/lib/less/js/less/test/less/errors/recursive-variable.txt +2 -0
  478. data/lib/less/js/less/test/less/errors/single-character.less +1 -0
  479. data/lib/less/js/less/test/less/errors/single-character.txt +2 -0
  480. data/lib/less/js/less/test/less/errors/svg-gradient1.less +3 -0
  481. data/lib/less/js/less/test/less/errors/svg-gradient1.txt +4 -0
  482. data/lib/less/js/less/test/less/errors/svg-gradient2.less +3 -0
  483. data/lib/less/js/less/test/less/errors/svg-gradient2.txt +4 -0
  484. data/lib/less/js/less/test/less/errors/svg-gradient3.less +3 -0
  485. data/lib/less/js/less/test/less/errors/svg-gradient3.txt +4 -0
  486. data/lib/less/js/less/test/less/errors/svg-gradient4.less +4 -0
  487. data/lib/less/js/less/test/less/errors/svg-gradient4.txt +4 -0
  488. data/lib/less/js/less/test/less/errors/svg-gradient5.less +4 -0
  489. data/lib/less/js/less/test/less/errors/svg-gradient5.txt +4 -0
  490. data/lib/less/js/less/test/less/errors/svg-gradient6.less +4 -0
  491. data/lib/less/js/less/test/less/errors/svg-gradient6.txt +4 -0
  492. data/lib/less/js/less/test/less/errors/unit-function.less +3 -0
  493. data/lib/less/js/less/test/less/errors/unit-function.txt +4 -0
  494. data/lib/less/js/less/test/less/extend-chaining.less +91 -0
  495. data/lib/less/js/less/test/less/extend-clearfix.less +19 -0
  496. data/lib/less/js/less/test/less/extend-exact.less +46 -0
  497. data/lib/less/js/less/test/less/extend-media.less +24 -0
  498. data/lib/less/js/less/test/less/extend-nest.less +65 -0
  499. data/lib/less/js/less/test/less/extend-selector.less +110 -0
  500. data/lib/less/js/less/test/less/extend.less +81 -0
  501. data/lib/less/js/less/test/less/extract-and-length.less +133 -0
  502. data/lib/less/js/less/test/less/filemanagerPlugin/colors.test +1 -0
  503. data/lib/less/js/less/test/less/filemanagerPlugin/filemanager.less +4 -0
  504. data/lib/less/js/less/test/less/functions.less +232 -0
  505. data/lib/less/js/less/test/less/globalVars/extended.json +5 -0
  506. data/lib/less/js/less/test/less/globalVars/extended.less +10 -0
  507. data/lib/less/js/less/test/less/globalVars/simple.json +3 -0
  508. data/lib/less/js/less/test/less/globalVars/simple.less +3 -0
  509. data/lib/less/js/less/test/less/ie-filters.less +15 -0
  510. data/lib/less/js/less/test/less/import-inline.less +3 -0
  511. data/lib/less/js/less/test/less/import-interpolation.less +8 -0
  512. data/lib/less/js/less/test/less/import-once.less +6 -0
  513. data/lib/less/js/less/test/less/import-reference-issues.less +50 -0
  514. data/lib/less/js/less/test/less/import-reference-issues/appender-reference-1968.less +6 -0
  515. data/lib/less/js/less/test/less/import-reference-issues/global-scope-import.less +13 -0
  516. data/lib/less/js/less/test/less/import-reference-issues/global-scope-nested.less +3 -0
  517. data/lib/less/js/less/test/less/import-reference-issues/mixin-1968.less +8 -0
  518. data/lib/less/js/less/test/less/import-reference-issues/multiple-import-nested.less +12 -0
  519. data/lib/less/js/less/test/less/import-reference-issues/multiple-import.less +10 -0
  520. data/lib/less/js/less/test/less/import-reference-issues/simple-mixin.css +3 -0
  521. data/lib/less/js/less/test/less/import-reference-issues/simple-ruleset-2162.less +3 -0
  522. data/lib/less/js/less/test/less/import-reference.less +26 -0
  523. data/lib/less/js/less/test/less/import.less +31 -0
  524. data/lib/less/js/less/test/less/import/css-import.less +1 -0
  525. data/lib/less/js/less/test/less/import/deeper/deeper-2/url-import-2.less +3 -0
  526. data/lib/less/js/less/test/less/import/deeper/deeper-2/url-import.less +1 -0
  527. data/lib/less/js/less/test/less/import/deeper/import-once-test-a.less +1 -0
  528. data/lib/less/js/less/test/less/import/deeper/url-import.less +1 -0
  529. data/lib/less/js/less/test/less/import/import-and-relative-paths-test.less +17 -0
  530. data/lib/less/js/less/test/less/import/import-charset-test.less +1 -0
  531. data/lib/less/js/less/test/less/import/import-inline-invalid-css.less +1 -0
  532. data/lib/less/js/less/test/less/import/import-interpolation.less +2 -0
  533. data/lib/less/js/less/test/less/import/import-interpolation2.less +5 -0
  534. data/lib/less/js/less/test/less/import/import-once-test-c.less +6 -0
  535. data/lib/less/js/less/test/less/import/import-reference.less +98 -0
  536. data/lib/less/js/less/test/less/import/import-test-a.less +5 -0
  537. data/lib/less/js/less/test/less/import/import-test-b.less +8 -0
  538. data/lib/less/js/less/test/less/import/import-test-c.less +6 -0
  539. data/lib/less/js/less/test/less/import/import-test-d.css +1 -0
  540. data/lib/less/js/less/test/less/import/import-test-e.less +2 -0
  541. data/lib/less/js/less/test/less/import/import-test-f.less +5 -0
  542. data/lib/less/js/less/test/less/import/imports/font.less +8 -0
  543. data/lib/less/js/less/test/less/import/imports/logo.less +6 -0
  544. data/lib/less/js/less/test/less/import/interpolation-vars.less +6 -0
  545. data/lib/less/js/less/test/less/import/invalid-css.less +1 -0
  546. data/lib/less/js/less/test/less/import/urls.less +1 -0
  547. data/lib/less/js/less/test/less/include-path-string/include-path-string.less +3 -0
  548. data/lib/less/js/less/test/less/include-path/include-path.less +8 -0
  549. data/lib/less/js/less/test/less/javascript.less +38 -0
  550. data/lib/less/js/less/test/less/lazy-eval.less +6 -0
  551. data/lib/less/js/less/test/less/legacy/legacy.less +21 -0
  552. data/lib/less/js/less/test/less/media.less +234 -0
  553. data/lib/less/js/less/test/less/merge.less +78 -0
  554. data/lib/less/js/less/test/less/mixins-args.less +263 -0
  555. data/lib/less/js/less/test/less/mixins-closure.less +26 -0
  556. data/lib/less/js/less/test/less/mixins-guards-default-func.less +195 -0
  557. data/lib/less/js/less/test/less/mixins-guards.less +358 -0
  558. data/lib/less/js/less/test/less/mixins-important.less +53 -0
  559. data/lib/less/js/less/test/less/mixins-interpolated.less +75 -0
  560. data/lib/less/js/less/test/less/mixins-named-args.less +36 -0
  561. data/lib/less/js/less/test/less/mixins-nested.less +22 -0
  562. data/lib/less/js/less/test/less/mixins-pattern.less +102 -0
  563. data/lib/less/js/less/test/less/mixins.less +145 -0
  564. data/lib/less/js/less/test/less/modifyVars/extended.json +5 -0
  565. data/lib/less/js/less/test/less/modifyVars/extended.less +11 -0
  566. data/lib/less/js/less/test/less/nested-gradient-with-svg-gradient/mixin-consumer.less +5 -0
  567. data/lib/less/js/less/test/less/nested-gradient-with-svg-gradient/svg-gradient-mixin.less +15 -0
  568. data/lib/less/js/less/test/less/no-js-errors/no-js-errors.less +3 -0
  569. data/lib/less/js/less/test/less/no-js-errors/no-js-errors.txt +4 -0
  570. data/lib/less/js/less/test/less/no-output.less +2 -0
  571. data/lib/less/js/less/test/less/no-strict-math/mixins-guards.less +25 -0
  572. data/lib/less/js/less/test/less/no-strict-math/no-sm-operations.less +10 -0
  573. data/lib/less/js/less/test/less/operations.less +63 -0
  574. data/lib/less/js/less/test/less/parens.less +45 -0
  575. data/lib/less/js/less/test/less/plugin.less +85 -0
  576. data/lib/less/js/less/test/less/plugin/plugin-global.js +9 -0
  577. data/lib/less/js/less/test/less/plugin/plugin-local.js +8 -0
  578. data/lib/less/js/less/test/less/plugin/plugin-transitive.js +5 -0
  579. data/lib/less/js/less/test/less/plugin/plugin-transitive.less +5 -0
  580. data/lib/less/js/less/test/less/postProcessorPlugin/postProcessor.less +4 -0
  581. data/lib/less/js/less/test/less/preProcessorPlugin/preProcessor.less +3 -0
  582. data/lib/less/js/less/test/less/property-name-interp.less +56 -0
  583. data/lib/less/js/less/test/less/rulesets.less +30 -0
  584. data/lib/less/js/less/test/less/scope.less +104 -0
  585. data/lib/less/js/less/test/less/selectors.less +184 -0
  586. data/lib/less/js/less/test/less/sourcemaps-empty/empty.less +0 -0
  587. data/lib/less/js/less/test/less/sourcemaps-empty/var-defs.less +1 -0
  588. data/lib/less/js/less/test/less/sourcemaps/basic.json +3 -0
  589. data/lib/less/js/less/test/less/sourcemaps/basic.less +27 -0
  590. data/lib/less/js/less/test/less/sourcemaps/imported.css +7 -0
  591. data/lib/less/js/less/test/less/static-urls/urls.less +33 -0
  592. data/lib/less/js/less/test/less/strict-units/strict-units.less +4 -0
  593. data/lib/less/js/less/test/less/strings.less +73 -0
  594. data/lib/less/js/less/test/less/url-args/urls.less +63 -0
  595. data/lib/less/js/less/test/less/urls.less +94 -0
  596. data/lib/less/js/less/test/less/variables-in-at-rules.less +20 -0
  597. data/lib/less/js/less/test/less/variables.less +119 -0
  598. data/lib/less/js/less/test/less/visitorPlugin/visitor.less +4 -0
  599. data/lib/less/js/less/test/less/whitespace.less +44 -0
  600. data/lib/less/js/less/test/modify-vars.js +19 -0
  601. data/lib/less/js/less/test/plugins/filemanager/index.js +19 -0
  602. data/lib/less/js/less/test/plugins/postprocess/index.js +14 -0
  603. data/lib/less/js/less/test/plugins/preprocess/index.js +19 -0
  604. data/lib/less/js/less/test/plugins/visitor/index.js +24 -0
  605. data/lib/less/js/less/test/rhino/test-header.js +15 -0
  606. data/lib/less/js/less/test/sourcemaps/basic.json +1 -0
  607. data/lib/less/js/less/test/sourcemaps/index.html +17 -0
  608. data/lib/less/js/node-mime/.gitignore +2 -0
  609. data/lib/less/js/node-mime/.npmignore +0 -0
  610. data/lib/less/js/node-mime/LICENSE +19 -0
  611. data/lib/less/js/node-mime/README.md +90 -0
  612. data/lib/less/js/node-mime/build/build.js +11 -0
  613. data/lib/less/js/node-mime/build/test.js +57 -0
  614. data/lib/less/js/node-mime/cli.js +8 -0
  615. data/lib/less/js/node-mime/mime.js +108 -0
  616. data/lib/less/js/node-mime/package.json +41 -0
  617. data/lib/less/js/node-mime/types.json +1 -0
  618. data/lib/less/loader.rb +13 -0
  619. data/lib/less/parser.rb +62 -0
  620. data/lib/less/runner.js +20 -0
  621. data/lib/less/version.rb +3 -0
  622. data/script/bootstrap +6 -0
  623. data/script/cibuild +7 -0
  624. data/spec/less/parser_spec.rb +170 -0
  625. data/spec/spec_helper.rb +3 -0
  626. data/spec/support/custom_functions/custom_functions.js +7 -0
  627. data/spec/support/custom_functions/custom_functions.less +3 -0
  628. data/spec/support/faulty/faulty.less +3 -0
  629. data/spec/support/less.js.tests-custom-functions.js +20 -0
  630. data/spec/support/one/one.less +1 -0
  631. data/spec/support/two/two.less +1 -0
  632. metadata +733 -0
@@ -0,0 +1,152 @@
1
+ var tree = require("../tree");
2
+
3
+ var _visitArgs = { visitDeeper: true },
4
+ _hasIndexed = false;
5
+
6
+ function _noop(node) {
7
+ return node;
8
+ }
9
+
10
+ function indexNodeTypes(parent, ticker) {
11
+ // add .typeIndex to tree node types for lookup table
12
+ var key, child;
13
+ for (key in parent) {
14
+ if (parent.hasOwnProperty(key)) {
15
+ child = parent[key];
16
+ switch (typeof child) {
17
+ case "function":
18
+ // ignore bound functions directly on tree which do not have a prototype
19
+ // or aren't nodes
20
+ if (child.prototype && child.prototype.type) {
21
+ child.prototype.typeIndex = ticker++;
22
+ }
23
+ break;
24
+ case "object":
25
+ ticker = indexNodeTypes(child, ticker);
26
+ break;
27
+ }
28
+ }
29
+ }
30
+ return ticker;
31
+ }
32
+
33
+ var Visitor = function(implementation) {
34
+ this._implementation = implementation;
35
+ this._visitFnCache = [];
36
+
37
+ if (!_hasIndexed) {
38
+ indexNodeTypes(tree, 1);
39
+ _hasIndexed = true;
40
+ }
41
+ };
42
+
43
+ Visitor.prototype = {
44
+ visit: function(node) {
45
+ if (!node) {
46
+ return node;
47
+ }
48
+
49
+ var nodeTypeIndex = node.typeIndex;
50
+ if (!nodeTypeIndex) {
51
+ return node;
52
+ }
53
+
54
+ var visitFnCache = this._visitFnCache,
55
+ impl = this._implementation,
56
+ aryIndx = nodeTypeIndex << 1,
57
+ outAryIndex = aryIndx | 1,
58
+ func = visitFnCache[aryIndx],
59
+ funcOut = visitFnCache[outAryIndex],
60
+ visitArgs = _visitArgs,
61
+ fnName;
62
+
63
+ visitArgs.visitDeeper = true;
64
+
65
+ if (!func) {
66
+ fnName = "visit" + node.type;
67
+ func = impl[fnName] || _noop;
68
+ funcOut = impl[fnName + "Out"] || _noop;
69
+ visitFnCache[aryIndx] = func;
70
+ visitFnCache[outAryIndex] = funcOut;
71
+ }
72
+
73
+ if (func !== _noop) {
74
+ var newNode = func.call(impl, node, visitArgs);
75
+ if (impl.isReplacing) {
76
+ node = newNode;
77
+ }
78
+ }
79
+
80
+ if (visitArgs.visitDeeper && node && node.accept) {
81
+ node.accept(this);
82
+ }
83
+
84
+ if (funcOut != _noop) {
85
+ funcOut.call(impl, node);
86
+ }
87
+
88
+ return node;
89
+ },
90
+ visitArray: function(nodes, nonReplacing) {
91
+ if (!nodes) {
92
+ return nodes;
93
+ }
94
+
95
+ var cnt = nodes.length, i;
96
+
97
+ // Non-replacing
98
+ if (nonReplacing || !this._implementation.isReplacing) {
99
+ for (i = 0; i < cnt; i++) {
100
+ this.visit(nodes[i]);
101
+ }
102
+ return nodes;
103
+ }
104
+
105
+ // Replacing
106
+ var out = [];
107
+ for (i = 0; i < cnt; i++) {
108
+ var evald = this.visit(nodes[i]);
109
+ if (evald === undefined) { continue; }
110
+ if (!evald.splice) {
111
+ out.push(evald);
112
+ } else if (evald.length) {
113
+ this.flatten(evald, out);
114
+ }
115
+ }
116
+ return out;
117
+ },
118
+ flatten: function(arr, out) {
119
+ if (!out) {
120
+ out = [];
121
+ }
122
+
123
+ var cnt, i, item,
124
+ nestedCnt, j, nestedItem;
125
+
126
+ for (i = 0, cnt = arr.length; i < cnt; i++) {
127
+ item = arr[i];
128
+ if (item === undefined) {
129
+ continue;
130
+ }
131
+ if (!item.splice) {
132
+ out.push(item);
133
+ continue;
134
+ }
135
+
136
+ for (j = 0, nestedCnt = item.length; j < nestedCnt; j++) {
137
+ nestedItem = item[j];
138
+ if (nestedItem === undefined) {
139
+ continue;
140
+ }
141
+ if (!nestedItem.splice) {
142
+ out.push(nestedItem);
143
+ } else if (nestedItem.length) {
144
+ this.flatten(nestedItem, out);
145
+ }
146
+ }
147
+ }
148
+
149
+ return out;
150
+ }
151
+ };
152
+ module.exports = Visitor;
@@ -0,0 +1,1933 @@
1
+ /* -*- Mode: js; js-indent-level: 2; -*- */
2
+ /*
3
+ * Copyright 2011 Mozilla Foundation and contributors
4
+ * Licensed under the New BSD license. See LICENSE or:
5
+ * http://opensource.org/licenses/BSD-3-Clause
6
+ */
7
+
8
+ /**
9
+ * Define a module along with a payload.
10
+ * @param {string} moduleName Name for the payload
11
+ * @param {ignored} deps Ignored. For compatibility with CommonJS AMD Spec
12
+ * @param {function} payload Function with (require, exports, module) params
13
+ */
14
+ function define(moduleName, deps, payload) {
15
+ if (typeof moduleName != "string") {
16
+ throw new TypeError('Expected string, got: ' + moduleName);
17
+ }
18
+
19
+ if (arguments.length == 2) {
20
+ payload = deps;
21
+ }
22
+
23
+ if (moduleName in define.modules) {
24
+ throw new Error("Module already defined: " + moduleName);
25
+ }
26
+ define.modules[moduleName] = payload;
27
+ };
28
+
29
+ /**
30
+ * The global store of un-instantiated modules
31
+ */
32
+ define.modules = {};
33
+
34
+
35
+ /**
36
+ * We invoke require() in the context of a Domain so we can have multiple
37
+ * sets of modules running separate from each other.
38
+ * This contrasts with JSMs which are singletons, Domains allows us to
39
+ * optionally load a CommonJS module twice with separate data each time.
40
+ * Perhaps you want 2 command lines with a different set of commands in each,
41
+ * for example.
42
+ */
43
+ function Domain() {
44
+ this.modules = {};
45
+ this._currentModule = null;
46
+ }
47
+
48
+ (function () {
49
+
50
+ /**
51
+ * Lookup module names and resolve them by calling the definition function if
52
+ * needed.
53
+ * There are 2 ways to call this, either with an array of dependencies and a
54
+ * callback to call when the dependencies are found (which can happen
55
+ * asynchronously in an in-page context) or with a single string an no callback
56
+ * where the dependency is resolved synchronously and returned.
57
+ * The API is designed to be compatible with the CommonJS AMD spec and
58
+ * RequireJS.
59
+ * @param {string[]|string} deps A name, or names for the payload
60
+ * @param {function|undefined} callback Function to call when the dependencies
61
+ * are resolved
62
+ * @return {undefined|object} The module required or undefined for
63
+ * array/callback method
64
+ */
65
+ Domain.prototype.require = function(deps, callback) {
66
+ if (Array.isArray(deps)) {
67
+ var params = deps.map(function(dep) {
68
+ return this.lookup(dep);
69
+ }, this);
70
+ if (callback) {
71
+ callback.apply(null, params);
72
+ }
73
+ return undefined;
74
+ }
75
+ else {
76
+ return this.lookup(deps);
77
+ }
78
+ };
79
+
80
+ function normalize(path) {
81
+ var bits = path.split('/');
82
+ var i = 1;
83
+ while (i < bits.length) {
84
+ if (bits[i] === '..') {
85
+ bits.splice(i-1, 1);
86
+ } else if (bits[i] === '.') {
87
+ bits.splice(i, 1);
88
+ } else {
89
+ i++;
90
+ }
91
+ }
92
+ return bits.join('/');
93
+ }
94
+
95
+ function join(a, b) {
96
+ a = a.trim();
97
+ b = b.trim();
98
+ if (/^\//.test(b)) {
99
+ return b;
100
+ } else {
101
+ return a.replace(/\/*$/, '/') + b;
102
+ }
103
+ }
104
+
105
+ function dirname(path) {
106
+ var bits = path.split('/');
107
+ bits.pop();
108
+ return bits.join('/');
109
+ }
110
+
111
+ /**
112
+ * Lookup module names and resolve them by calling the definition function if
113
+ * needed.
114
+ * @param {string} moduleName A name for the payload to lookup
115
+ * @return {object} The module specified by aModuleName or null if not found.
116
+ */
117
+ Domain.prototype.lookup = function(moduleName) {
118
+ if (/^\./.test(moduleName)) {
119
+ moduleName = normalize(join(dirname(this._currentModule), moduleName));
120
+ }
121
+
122
+ if (moduleName in this.modules) {
123
+ var module = this.modules[moduleName];
124
+ return module;
125
+ }
126
+
127
+ if (!(moduleName in define.modules)) {
128
+ throw new Error("Module not defined: " + moduleName);
129
+ }
130
+
131
+ var module = define.modules[moduleName];
132
+
133
+ if (typeof module == "function") {
134
+ var exports = {};
135
+ var previousModule = this._currentModule;
136
+ this._currentModule = moduleName;
137
+ module(this.require.bind(this), exports, { id: moduleName, uri: "" });
138
+ this._currentModule = previousModule;
139
+ module = exports;
140
+ }
141
+
142
+ // cache the resulting module object for next time
143
+ this.modules[moduleName] = module;
144
+
145
+ return module;
146
+ };
147
+
148
+ }());
149
+
150
+ define.Domain = Domain;
151
+ define.globalDomain = new Domain();
152
+ var require = define.globalDomain.require.bind(define.globalDomain);
153
+ /* -*- Mode: js; js-indent-level: 2; -*- */
154
+ /*
155
+ * Copyright 2011 Mozilla Foundation and contributors
156
+ * Licensed under the New BSD license. See LICENSE or:
157
+ * http://opensource.org/licenses/BSD-3-Clause
158
+ */
159
+ define('source-map/source-map-generator', ['require', 'exports', 'module' , 'source-map/base64-vlq', 'source-map/util', 'source-map/array-set'], function(require, exports, module) {
160
+
161
+ var base64VLQ = require('./base64-vlq');
162
+ var util = require('./util');
163
+ var ArraySet = require('./array-set').ArraySet;
164
+
165
+ /**
166
+ * An instance of the SourceMapGenerator represents a source map which is
167
+ * being built incrementally. To create a new one, you must pass an object
168
+ * with the following properties:
169
+ *
170
+ * - file: The filename of the generated source.
171
+ * - sourceRoot: An optional root for all URLs in this source map.
172
+ */
173
+ function SourceMapGenerator(aArgs) {
174
+ this._file = util.getArg(aArgs, 'file');
175
+ this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
176
+ this._sources = new ArraySet();
177
+ this._names = new ArraySet();
178
+ this._mappings = [];
179
+ this._sourcesContents = null;
180
+ }
181
+
182
+ SourceMapGenerator.prototype._version = 3;
183
+
184
+ /**
185
+ * Creates a new SourceMapGenerator based on a SourceMapConsumer
186
+ *
187
+ * @param aSourceMapConsumer The SourceMap.
188
+ */
189
+ SourceMapGenerator.fromSourceMap =
190
+ function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
191
+ var sourceRoot = aSourceMapConsumer.sourceRoot;
192
+ var generator = new SourceMapGenerator({
193
+ file: aSourceMapConsumer.file,
194
+ sourceRoot: sourceRoot
195
+ });
196
+ aSourceMapConsumer.eachMapping(function (mapping) {
197
+ var newMapping = {
198
+ generated: {
199
+ line: mapping.generatedLine,
200
+ column: mapping.generatedColumn
201
+ }
202
+ };
203
+
204
+ if (mapping.source) {
205
+ newMapping.source = mapping.source;
206
+ if (sourceRoot) {
207
+ newMapping.source = util.relative(sourceRoot, newMapping.source);
208
+ }
209
+
210
+ newMapping.original = {
211
+ line: mapping.originalLine,
212
+ column: mapping.originalColumn
213
+ };
214
+
215
+ if (mapping.name) {
216
+ newMapping.name = mapping.name;
217
+ }
218
+ }
219
+
220
+ generator.addMapping(newMapping);
221
+ });
222
+ aSourceMapConsumer.sources.forEach(function (sourceFile) {
223
+ var content = aSourceMapConsumer.sourceContentFor(sourceFile);
224
+ if (content) {
225
+ generator.setSourceContent(sourceFile, content);
226
+ }
227
+ });
228
+ return generator;
229
+ };
230
+
231
+ /**
232
+ * Add a single mapping from original source line and column to the generated
233
+ * source's line and column for this source map being created. The mapping
234
+ * object should have the following properties:
235
+ *
236
+ * - generated: An object with the generated line and column positions.
237
+ * - original: An object with the original line and column positions.
238
+ * - source: The original source file (relative to the sourceRoot).
239
+ * - name: An optional original token name for this mapping.
240
+ */
241
+ SourceMapGenerator.prototype.addMapping =
242
+ function SourceMapGenerator_addMapping(aArgs) {
243
+ var generated = util.getArg(aArgs, 'generated');
244
+ var original = util.getArg(aArgs, 'original', null);
245
+ var source = util.getArg(aArgs, 'source', null);
246
+ var name = util.getArg(aArgs, 'name', null);
247
+
248
+ this._validateMapping(generated, original, source, name);
249
+
250
+ if (source && !this._sources.has(source)) {
251
+ this._sources.add(source);
252
+ }
253
+
254
+ if (name && !this._names.has(name)) {
255
+ this._names.add(name);
256
+ }
257
+
258
+ this._mappings.push({
259
+ generatedLine: generated.line,
260
+ generatedColumn: generated.column,
261
+ originalLine: original != null && original.line,
262
+ originalColumn: original != null && original.column,
263
+ source: source,
264
+ name: name
265
+ });
266
+ };
267
+
268
+ /**
269
+ * Set the source content for a source file.
270
+ */
271
+ SourceMapGenerator.prototype.setSourceContent =
272
+ function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
273
+ var source = aSourceFile;
274
+ if (this._sourceRoot) {
275
+ source = util.relative(this._sourceRoot, source);
276
+ }
277
+
278
+ if (aSourceContent !== null) {
279
+ // Add the source content to the _sourcesContents map.
280
+ // Create a new _sourcesContents map if the property is null.
281
+ if (!this._sourcesContents) {
282
+ this._sourcesContents = {};
283
+ }
284
+ this._sourcesContents[util.toSetString(source)] = aSourceContent;
285
+ } else {
286
+ // Remove the source file from the _sourcesContents map.
287
+ // If the _sourcesContents map is empty, set the property to null.
288
+ delete this._sourcesContents[util.toSetString(source)];
289
+ if (Object.keys(this._sourcesContents).length === 0) {
290
+ this._sourcesContents = null;
291
+ }
292
+ }
293
+ };
294
+
295
+ /**
296
+ * Applies the mappings of a sub-source-map for a specific source file to the
297
+ * source map being generated. Each mapping to the supplied source file is
298
+ * rewritten using the supplied source map. Note: The resolution for the
299
+ * resulting mappings is the minimium of this map and the supplied map.
300
+ *
301
+ * @param aSourceMapConsumer The source map to be applied.
302
+ * @param aSourceFile Optional. The filename of the source file.
303
+ * If omitted, SourceMapConsumer's file property will be used.
304
+ */
305
+ SourceMapGenerator.prototype.applySourceMap =
306
+ function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile) {
307
+ // If aSourceFile is omitted, we will use the file property of the SourceMap
308
+ if (!aSourceFile) {
309
+ aSourceFile = aSourceMapConsumer.file;
310
+ }
311
+ var sourceRoot = this._sourceRoot;
312
+ // Make "aSourceFile" relative if an absolute Url is passed.
313
+ if (sourceRoot) {
314
+ aSourceFile = util.relative(sourceRoot, aSourceFile);
315
+ }
316
+ // Applying the SourceMap can add and remove items from the sources and
317
+ // the names array.
318
+ var newSources = new ArraySet();
319
+ var newNames = new ArraySet();
320
+
321
+ // Find mappings for the "aSourceFile"
322
+ this._mappings.forEach(function (mapping) {
323
+ if (mapping.source === aSourceFile && mapping.originalLine) {
324
+ // Check if it can be mapped by the source map, then update the mapping.
325
+ var original = aSourceMapConsumer.originalPositionFor({
326
+ line: mapping.originalLine,
327
+ column: mapping.originalColumn
328
+ });
329
+ if (original.source !== null) {
330
+ // Copy mapping
331
+ if (sourceRoot) {
332
+ mapping.source = util.relative(sourceRoot, original.source);
333
+ } else {
334
+ mapping.source = original.source;
335
+ }
336
+ mapping.originalLine = original.line;
337
+ mapping.originalColumn = original.column;
338
+ if (original.name !== null && mapping.name !== null) {
339
+ // Only use the identifier name if it's an identifier
340
+ // in both SourceMaps
341
+ mapping.name = original.name;
342
+ }
343
+ }
344
+ }
345
+
346
+ var source = mapping.source;
347
+ if (source && !newSources.has(source)) {
348
+ newSources.add(source);
349
+ }
350
+
351
+ var name = mapping.name;
352
+ if (name && !newNames.has(name)) {
353
+ newNames.add(name);
354
+ }
355
+
356
+ }, this);
357
+ this._sources = newSources;
358
+ this._names = newNames;
359
+
360
+ // Copy sourcesContents of applied map.
361
+ aSourceMapConsumer.sources.forEach(function (sourceFile) {
362
+ var content = aSourceMapConsumer.sourceContentFor(sourceFile);
363
+ if (content) {
364
+ if (sourceRoot) {
365
+ sourceFile = util.relative(sourceRoot, sourceFile);
366
+ }
367
+ this.setSourceContent(sourceFile, content);
368
+ }
369
+ }, this);
370
+ };
371
+
372
+ /**
373
+ * A mapping can have one of the three levels of data:
374
+ *
375
+ * 1. Just the generated position.
376
+ * 2. The Generated position, original position, and original source.
377
+ * 3. Generated and original position, original source, as well as a name
378
+ * token.
379
+ *
380
+ * To maintain consistency, we validate that any new mapping being added falls
381
+ * in to one of these categories.
382
+ */
383
+ SourceMapGenerator.prototype._validateMapping =
384
+ function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
385
+ aName) {
386
+ if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
387
+ && aGenerated.line > 0 && aGenerated.column >= 0
388
+ && !aOriginal && !aSource && !aName) {
389
+ // Case 1.
390
+ return;
391
+ }
392
+ else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
393
+ && aOriginal && 'line' in aOriginal && 'column' in aOriginal
394
+ && aGenerated.line > 0 && aGenerated.column >= 0
395
+ && aOriginal.line > 0 && aOriginal.column >= 0
396
+ && aSource) {
397
+ // Cases 2 and 3.
398
+ return;
399
+ }
400
+ else {
401
+ throw new Error('Invalid mapping: ' + JSON.stringify({
402
+ generated: aGenerated,
403
+ source: aSource,
404
+ original: aOriginal,
405
+ name: aName
406
+ }));
407
+ }
408
+ };
409
+
410
+ /**
411
+ * Serialize the accumulated mappings in to the stream of base 64 VLQs
412
+ * specified by the source map format.
413
+ */
414
+ SourceMapGenerator.prototype._serializeMappings =
415
+ function SourceMapGenerator_serializeMappings() {
416
+ var previousGeneratedColumn = 0;
417
+ var previousGeneratedLine = 1;
418
+ var previousOriginalColumn = 0;
419
+ var previousOriginalLine = 0;
420
+ var previousName = 0;
421
+ var previousSource = 0;
422
+ var result = '';
423
+ var mapping;
424
+
425
+ // The mappings must be guaranteed to be in sorted order before we start
426
+ // serializing them or else the generated line numbers (which are defined
427
+ // via the ';' separators) will be all messed up. Note: it might be more
428
+ // performant to maintain the sorting as we insert them, rather than as we
429
+ // serialize them, but the big O is the same either way.
430
+ this._mappings.sort(util.compareByGeneratedPositions);
431
+
432
+ for (var i = 0, len = this._mappings.length; i < len; i++) {
433
+ mapping = this._mappings[i];
434
+
435
+ if (mapping.generatedLine !== previousGeneratedLine) {
436
+ previousGeneratedColumn = 0;
437
+ while (mapping.generatedLine !== previousGeneratedLine) {
438
+ result += ';';
439
+ previousGeneratedLine++;
440
+ }
441
+ }
442
+ else {
443
+ if (i > 0) {
444
+ if (!util.compareByGeneratedPositions(mapping, this._mappings[i - 1])) {
445
+ continue;
446
+ }
447
+ result += ',';
448
+ }
449
+ }
450
+
451
+ result += base64VLQ.encode(mapping.generatedColumn
452
+ - previousGeneratedColumn);
453
+ previousGeneratedColumn = mapping.generatedColumn;
454
+
455
+ if (mapping.source) {
456
+ result += base64VLQ.encode(this._sources.indexOf(mapping.source)
457
+ - previousSource);
458
+ previousSource = this._sources.indexOf(mapping.source);
459
+
460
+ // lines are stored 0-based in SourceMap spec version 3
461
+ result += base64VLQ.encode(mapping.originalLine - 1
462
+ - previousOriginalLine);
463
+ previousOriginalLine = mapping.originalLine - 1;
464
+
465
+ result += base64VLQ.encode(mapping.originalColumn
466
+ - previousOriginalColumn);
467
+ previousOriginalColumn = mapping.originalColumn;
468
+
469
+ if (mapping.name) {
470
+ result += base64VLQ.encode(this._names.indexOf(mapping.name)
471
+ - previousName);
472
+ previousName = this._names.indexOf(mapping.name);
473
+ }
474
+ }
475
+ }
476
+
477
+ return result;
478
+ };
479
+
480
+ SourceMapGenerator.prototype._generateSourcesContent =
481
+ function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
482
+ return aSources.map(function (source) {
483
+ if (!this._sourcesContents) {
484
+ return null;
485
+ }
486
+ if (aSourceRoot) {
487
+ source = util.relative(aSourceRoot, source);
488
+ }
489
+ var key = util.toSetString(source);
490
+ return Object.prototype.hasOwnProperty.call(this._sourcesContents,
491
+ key)
492
+ ? this._sourcesContents[key]
493
+ : null;
494
+ }, this);
495
+ };
496
+
497
+ /**
498
+ * Externalize the source map.
499
+ */
500
+ SourceMapGenerator.prototype.toJSON =
501
+ function SourceMapGenerator_toJSON() {
502
+ var map = {
503
+ version: this._version,
504
+ file: this._file,
505
+ sources: this._sources.toArray(),
506
+ names: this._names.toArray(),
507
+ mappings: this._serializeMappings()
508
+ };
509
+ if (this._sourceRoot) {
510
+ map.sourceRoot = this._sourceRoot;
511
+ }
512
+ if (this._sourcesContents) {
513
+ map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
514
+ }
515
+
516
+ return map;
517
+ };
518
+
519
+ /**
520
+ * Render the source map being generated to a string.
521
+ */
522
+ SourceMapGenerator.prototype.toString =
523
+ function SourceMapGenerator_toString() {
524
+ return JSON.stringify(this);
525
+ };
526
+
527
+ exports.SourceMapGenerator = SourceMapGenerator;
528
+
529
+ });
530
+ /* -*- Mode: js; js-indent-level: 2; -*- */
531
+ /*
532
+ * Copyright 2011 Mozilla Foundation and contributors
533
+ * Licensed under the New BSD license. See LICENSE or:
534
+ * http://opensource.org/licenses/BSD-3-Clause
535
+ *
536
+ * Based on the Base 64 VLQ implementation in Closure Compiler:
537
+ * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
538
+ *
539
+ * Copyright 2011 The Closure Compiler Authors. All rights reserved.
540
+ * Redistribution and use in source and binary forms, with or without
541
+ * modification, are permitted provided that the following conditions are
542
+ * met:
543
+ *
544
+ * * Redistributions of source code must retain the above copyright
545
+ * notice, this list of conditions and the following disclaimer.
546
+ * * Redistributions in binary form must reproduce the above
547
+ * copyright notice, this list of conditions and the following
548
+ * disclaimer in the documentation and/or other materials provided
549
+ * with the distribution.
550
+ * * Neither the name of Google Inc. nor the names of its
551
+ * contributors may be used to endorse or promote products derived
552
+ * from this software without specific prior written permission.
553
+ *
554
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
555
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
556
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
557
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
558
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
559
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
560
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
561
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
562
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
563
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
564
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
565
+ */
566
+ define('source-map/base64-vlq', ['require', 'exports', 'module' , 'source-map/base64'], function(require, exports, module) {
567
+
568
+ var base64 = require('./base64');
569
+
570
+ // A single base 64 digit can contain 6 bits of data. For the base 64 variable
571
+ // length quantities we use in the source map spec, the first bit is the sign,
572
+ // the next four bits are the actual value, and the 6th bit is the
573
+ // continuation bit. The continuation bit tells us whether there are more
574
+ // digits in this value following this digit.
575
+ //
576
+ // Continuation
577
+ // | Sign
578
+ // | |
579
+ // V V
580
+ // 101011
581
+
582
+ var VLQ_BASE_SHIFT = 5;
583
+
584
+ // binary: 100000
585
+ var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
586
+
587
+ // binary: 011111
588
+ var VLQ_BASE_MASK = VLQ_BASE - 1;
589
+
590
+ // binary: 100000
591
+ var VLQ_CONTINUATION_BIT = VLQ_BASE;
592
+
593
+ /**
594
+ * Converts from a two-complement value to a value where the sign bit is
595
+ * is placed in the least significant bit. For example, as decimals:
596
+ * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
597
+ * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
598
+ */
599
+ function toVLQSigned(aValue) {
600
+ return aValue < 0
601
+ ? ((-aValue) << 1) + 1
602
+ : (aValue << 1) + 0;
603
+ }
604
+
605
+ /**
606
+ * Converts to a two-complement value from a value where the sign bit is
607
+ * is placed in the least significant bit. For example, as decimals:
608
+ * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1
609
+ * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2
610
+ */
611
+ function fromVLQSigned(aValue) {
612
+ var isNegative = (aValue & 1) === 1;
613
+ var shifted = aValue >> 1;
614
+ return isNegative
615
+ ? -shifted
616
+ : shifted;
617
+ }
618
+
619
+ /**
620
+ * Returns the base 64 VLQ encoded value.
621
+ */
622
+ exports.encode = function base64VLQ_encode(aValue) {
623
+ var encoded = "";
624
+ var digit;
625
+
626
+ var vlq = toVLQSigned(aValue);
627
+
628
+ do {
629
+ digit = vlq & VLQ_BASE_MASK;
630
+ vlq >>>= VLQ_BASE_SHIFT;
631
+ if (vlq > 0) {
632
+ // There are still more digits in this value, so we must make sure the
633
+ // continuation bit is marked.
634
+ digit |= VLQ_CONTINUATION_BIT;
635
+ }
636
+ encoded += base64.encode(digit);
637
+ } while (vlq > 0);
638
+
639
+ return encoded;
640
+ };
641
+
642
+ /**
643
+ * Decodes the next base 64 VLQ value from the given string and returns the
644
+ * value and the rest of the string.
645
+ */
646
+ exports.decode = function base64VLQ_decode(aStr) {
647
+ var i = 0;
648
+ var strLen = aStr.length;
649
+ var result = 0;
650
+ var shift = 0;
651
+ var continuation, digit;
652
+
653
+ do {
654
+ if (i >= strLen) {
655
+ throw new Error("Expected more digits in base 64 VLQ value.");
656
+ }
657
+ digit = base64.decode(aStr.charAt(i++));
658
+ continuation = !!(digit & VLQ_CONTINUATION_BIT);
659
+ digit &= VLQ_BASE_MASK;
660
+ result = result + (digit << shift);
661
+ shift += VLQ_BASE_SHIFT;
662
+ } while (continuation);
663
+
664
+ return {
665
+ value: fromVLQSigned(result),
666
+ rest: aStr.slice(i)
667
+ };
668
+ };
669
+
670
+ });
671
+ /* -*- Mode: js; js-indent-level: 2; -*- */
672
+ /*
673
+ * Copyright 2011 Mozilla Foundation and contributors
674
+ * Licensed under the New BSD license. See LICENSE or:
675
+ * http://opensource.org/licenses/BSD-3-Clause
676
+ */
677
+ define('source-map/base64', ['require', 'exports', 'module' , ], function(require, exports, module) {
678
+
679
+ var charToIntMap = {};
680
+ var intToCharMap = {};
681
+
682
+ 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
683
+ .split('')
684
+ .forEach(function (ch, index) {
685
+ charToIntMap[ch] = index;
686
+ intToCharMap[index] = ch;
687
+ });
688
+
689
+ /**
690
+ * Encode an integer in the range of 0 to 63 to a single base 64 digit.
691
+ */
692
+ exports.encode = function base64_encode(aNumber) {
693
+ if (aNumber in intToCharMap) {
694
+ return intToCharMap[aNumber];
695
+ }
696
+ throw new TypeError("Must be between 0 and 63: " + aNumber);
697
+ };
698
+
699
+ /**
700
+ * Decode a single base 64 digit to an integer.
701
+ */
702
+ exports.decode = function base64_decode(aChar) {
703
+ if (aChar in charToIntMap) {
704
+ return charToIntMap[aChar];
705
+ }
706
+ throw new TypeError("Not a valid base 64 digit: " + aChar);
707
+ };
708
+
709
+ });
710
+ /* -*- Mode: js; js-indent-level: 2; -*- */
711
+ /*
712
+ * Copyright 2011 Mozilla Foundation and contributors
713
+ * Licensed under the New BSD license. See LICENSE or:
714
+ * http://opensource.org/licenses/BSD-3-Clause
715
+ */
716
+ define('source-map/util', ['require', 'exports', 'module' , ], function(require, exports, module) {
717
+
718
+ /**
719
+ * This is a helper function for getting values from parameter/options
720
+ * objects.
721
+ *
722
+ * @param args The object we are extracting values from
723
+ * @param name The name of the property we are getting.
724
+ * @param defaultValue An optional value to return if the property is missing
725
+ * from the object. If this is not specified and the property is missing, an
726
+ * error will be thrown.
727
+ */
728
+ function getArg(aArgs, aName, aDefaultValue) {
729
+ if (aName in aArgs) {
730
+ return aArgs[aName];
731
+ } else if (arguments.length === 3) {
732
+ return aDefaultValue;
733
+ } else {
734
+ throw new Error('"' + aName + '" is a required argument.');
735
+ }
736
+ }
737
+ exports.getArg = getArg;
738
+
739
+ var urlRegexp = /([\w+\-.]+):\/\/((\w+:\w+)@)?([\w.]+)?(:(\d+))?(\S+)?/;
740
+ var dataUrlRegexp = /^data:.+\,.+/;
741
+
742
+ function urlParse(aUrl) {
743
+ var match = aUrl.match(urlRegexp);
744
+ if (!match) {
745
+ return null;
746
+ }
747
+ return {
748
+ scheme: match[1],
749
+ auth: match[3],
750
+ host: match[4],
751
+ port: match[6],
752
+ path: match[7]
753
+ };
754
+ }
755
+ exports.urlParse = urlParse;
756
+
757
+ function urlGenerate(aParsedUrl) {
758
+ var url = aParsedUrl.scheme + "://";
759
+ if (aParsedUrl.auth) {
760
+ url += aParsedUrl.auth + "@"
761
+ }
762
+ if (aParsedUrl.host) {
763
+ url += aParsedUrl.host;
764
+ }
765
+ if (aParsedUrl.port) {
766
+ url += ":" + aParsedUrl.port
767
+ }
768
+ if (aParsedUrl.path) {
769
+ url += aParsedUrl.path;
770
+ }
771
+ return url;
772
+ }
773
+ exports.urlGenerate = urlGenerate;
774
+
775
+ function join(aRoot, aPath) {
776
+ var url;
777
+
778
+ if (aPath.match(urlRegexp) || aPath.match(dataUrlRegexp)) {
779
+ return aPath;
780
+ }
781
+
782
+ if (aPath.charAt(0) === '/' && (url = urlParse(aRoot))) {
783
+ url.path = aPath;
784
+ return urlGenerate(url);
785
+ }
786
+
787
+ return aRoot.replace(/\/$/, '') + '/' + aPath;
788
+ }
789
+ exports.join = join;
790
+
791
+ /**
792
+ * Because behavior goes wacky when you set `__proto__` on objects, we
793
+ * have to prefix all the strings in our set with an arbitrary character.
794
+ *
795
+ * See https://github.com/mozilla/source-map/pull/31 and
796
+ * https://github.com/mozilla/source-map/issues/30
797
+ *
798
+ * @param String aStr
799
+ */
800
+ function toSetString(aStr) {
801
+ return '$' + aStr;
802
+ }
803
+ exports.toSetString = toSetString;
804
+
805
+ function fromSetString(aStr) {
806
+ return aStr.substr(1);
807
+ }
808
+ exports.fromSetString = fromSetString;
809
+
810
+ function relative(aRoot, aPath) {
811
+ aRoot = aRoot.replace(/\/$/, '');
812
+
813
+ var url = urlParse(aRoot);
814
+ if (aPath.charAt(0) == "/" && url && url.path == "/") {
815
+ return aPath.slice(1);
816
+ }
817
+
818
+ return aPath.indexOf(aRoot + '/') === 0
819
+ ? aPath.substr(aRoot.length + 1)
820
+ : aPath;
821
+ }
822
+ exports.relative = relative;
823
+
824
+ function strcmp(aStr1, aStr2) {
825
+ var s1 = aStr1 || "";
826
+ var s2 = aStr2 || "";
827
+ return (s1 > s2) - (s1 < s2);
828
+ }
829
+
830
+ /**
831
+ * Comparator between two mappings where the original positions are compared.
832
+ *
833
+ * Optionally pass in `true` as `onlyCompareGenerated` to consider two
834
+ * mappings with the same original source/line/column, but different generated
835
+ * line and column the same. Useful when searching for a mapping with a
836
+ * stubbed out mapping.
837
+ */
838
+ function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
839
+ var cmp;
840
+
841
+ cmp = strcmp(mappingA.source, mappingB.source);
842
+ if (cmp) {
843
+ return cmp;
844
+ }
845
+
846
+ cmp = mappingA.originalLine - mappingB.originalLine;
847
+ if (cmp) {
848
+ return cmp;
849
+ }
850
+
851
+ cmp = mappingA.originalColumn - mappingB.originalColumn;
852
+ if (cmp || onlyCompareOriginal) {
853
+ return cmp;
854
+ }
855
+
856
+ cmp = strcmp(mappingA.name, mappingB.name);
857
+ if (cmp) {
858
+ return cmp;
859
+ }
860
+
861
+ cmp = mappingA.generatedLine - mappingB.generatedLine;
862
+ if (cmp) {
863
+ return cmp;
864
+ }
865
+
866
+ return mappingA.generatedColumn - mappingB.generatedColumn;
867
+ };
868
+ exports.compareByOriginalPositions = compareByOriginalPositions;
869
+
870
+ /**
871
+ * Comparator between two mappings where the generated positions are
872
+ * compared.
873
+ *
874
+ * Optionally pass in `true` as `onlyCompareGenerated` to consider two
875
+ * mappings with the same generated line and column, but different
876
+ * source/name/original line and column the same. Useful when searching for a
877
+ * mapping with a stubbed out mapping.
878
+ */
879
+ function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) {
880
+ var cmp;
881
+
882
+ cmp = mappingA.generatedLine - mappingB.generatedLine;
883
+ if (cmp) {
884
+ return cmp;
885
+ }
886
+
887
+ cmp = mappingA.generatedColumn - mappingB.generatedColumn;
888
+ if (cmp || onlyCompareGenerated) {
889
+ return cmp;
890
+ }
891
+
892
+ cmp = strcmp(mappingA.source, mappingB.source);
893
+ if (cmp) {
894
+ return cmp;
895
+ }
896
+
897
+ cmp = mappingA.originalLine - mappingB.originalLine;
898
+ if (cmp) {
899
+ return cmp;
900
+ }
901
+
902
+ cmp = mappingA.originalColumn - mappingB.originalColumn;
903
+ if (cmp) {
904
+ return cmp;
905
+ }
906
+
907
+ return strcmp(mappingA.name, mappingB.name);
908
+ };
909
+ exports.compareByGeneratedPositions = compareByGeneratedPositions;
910
+
911
+ });
912
+ /* -*- Mode: js; js-indent-level: 2; -*- */
913
+ /*
914
+ * Copyright 2011 Mozilla Foundation and contributors
915
+ * Licensed under the New BSD license. See LICENSE or:
916
+ * http://opensource.org/licenses/BSD-3-Clause
917
+ */
918
+ define('source-map/array-set', ['require', 'exports', 'module' , 'source-map/util'], function(require, exports, module) {
919
+
920
+ var util = require('./util');
921
+
922
+ /**
923
+ * A data structure which is a combination of an array and a set. Adding a new
924
+ * member is O(1), testing for membership is O(1), and finding the index of an
925
+ * element is O(1). Removing elements from the set is not supported. Only
926
+ * strings are supported for membership.
927
+ */
928
+ function ArraySet() {
929
+ this._array = [];
930
+ this._set = {};
931
+ }
932
+
933
+ /**
934
+ * Static method for creating ArraySet instances from an existing array.
935
+ */
936
+ ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
937
+ var set = new ArraySet();
938
+ for (var i = 0, len = aArray.length; i < len; i++) {
939
+ set.add(aArray[i], aAllowDuplicates);
940
+ }
941
+ return set;
942
+ };
943
+
944
+ /**
945
+ * Add the given string to this set.
946
+ *
947
+ * @param String aStr
948
+ */
949
+ ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
950
+ var isDuplicate = this.has(aStr);
951
+ var idx = this._array.length;
952
+ if (!isDuplicate || aAllowDuplicates) {
953
+ this._array.push(aStr);
954
+ }
955
+ if (!isDuplicate) {
956
+ this._set[util.toSetString(aStr)] = idx;
957
+ }
958
+ };
959
+
960
+ /**
961
+ * Is the given string a member of this set?
962
+ *
963
+ * @param String aStr
964
+ */
965
+ ArraySet.prototype.has = function ArraySet_has(aStr) {
966
+ return Object.prototype.hasOwnProperty.call(this._set,
967
+ util.toSetString(aStr));
968
+ };
969
+
970
+ /**
971
+ * What is the index of the given string in the array?
972
+ *
973
+ * @param String aStr
974
+ */
975
+ ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
976
+ if (this.has(aStr)) {
977
+ return this._set[util.toSetString(aStr)];
978
+ }
979
+ throw new Error('"' + aStr + '" is not in the set.');
980
+ };
981
+
982
+ /**
983
+ * What is the element at the given index?
984
+ *
985
+ * @param Number aIdx
986
+ */
987
+ ArraySet.prototype.at = function ArraySet_at(aIdx) {
988
+ if (aIdx >= 0 && aIdx < this._array.length) {
989
+ return this._array[aIdx];
990
+ }
991
+ throw new Error('No element indexed by ' + aIdx);
992
+ };
993
+
994
+ /**
995
+ * Returns the array representation of this set (which has the proper indices
996
+ * indicated by indexOf). Note that this is a copy of the internal array used
997
+ * for storing the members so that no one can mess with internal state.
998
+ */
999
+ ArraySet.prototype.toArray = function ArraySet_toArray() {
1000
+ return this._array.slice();
1001
+ };
1002
+
1003
+ exports.ArraySet = ArraySet;
1004
+
1005
+ });
1006
+ /* -*- Mode: js; js-indent-level: 2; -*- */
1007
+ /*
1008
+ * Copyright 2011 Mozilla Foundation and contributors
1009
+ * Licensed under the New BSD license. See LICENSE or:
1010
+ * http://opensource.org/licenses/BSD-3-Clause
1011
+ */
1012
+ define('source-map/source-map-consumer', ['require', 'exports', 'module' , 'source-map/util', 'source-map/binary-search', 'source-map/array-set', 'source-map/base64-vlq'], function(require, exports, module) {
1013
+
1014
+ var util = require('./util');
1015
+ var binarySearch = require('./binary-search');
1016
+ var ArraySet = require('./array-set').ArraySet;
1017
+ var base64VLQ = require('./base64-vlq');
1018
+
1019
+ /**
1020
+ * A SourceMapConsumer instance represents a parsed source map which we can
1021
+ * query for information about the original file positions by giving it a file
1022
+ * position in the generated source.
1023
+ *
1024
+ * The only parameter is the raw source map (either as a JSON string, or
1025
+ * already parsed to an object). According to the spec, source maps have the
1026
+ * following attributes:
1027
+ *
1028
+ * - version: Which version of the source map spec this map is following.
1029
+ * - sources: An array of URLs to the original source files.
1030
+ * - names: An array of identifiers which can be referrenced by individual mappings.
1031
+ * - sourceRoot: Optional. The URL root from which all sources are relative.
1032
+ * - sourcesContent: Optional. An array of contents of the original source files.
1033
+ * - mappings: A string of base64 VLQs which contain the actual mappings.
1034
+ * - file: The generated file this source map is associated with.
1035
+ *
1036
+ * Here is an example source map, taken from the source map spec[0]:
1037
+ *
1038
+ * {
1039
+ * version : 3,
1040
+ * file: "out.js",
1041
+ * sourceRoot : "",
1042
+ * sources: ["foo.js", "bar.js"],
1043
+ * names: ["src", "maps", "are", "fun"],
1044
+ * mappings: "AA,AB;;ABCDE;"
1045
+ * }
1046
+ *
1047
+ * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
1048
+ */
1049
+ function SourceMapConsumer(aSourceMap) {
1050
+ var sourceMap = aSourceMap;
1051
+ if (typeof aSourceMap === 'string') {
1052
+ sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
1053
+ }
1054
+
1055
+ var version = util.getArg(sourceMap, 'version');
1056
+ var sources = util.getArg(sourceMap, 'sources');
1057
+ // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
1058
+ // requires the array) to play nice here.
1059
+ var names = util.getArg(sourceMap, 'names', []);
1060
+ var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
1061
+ var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
1062
+ var mappings = util.getArg(sourceMap, 'mappings');
1063
+ var file = util.getArg(sourceMap, 'file', null);
1064
+
1065
+ // Once again, Sass deviates from the spec and supplies the version as a
1066
+ // string rather than a number, so we use loose equality checking here.
1067
+ if (version != this._version) {
1068
+ throw new Error('Unsupported version: ' + version);
1069
+ }
1070
+
1071
+ // Pass `true` below to allow duplicate names and sources. While source maps
1072
+ // are intended to be compressed and deduplicated, the TypeScript compiler
1073
+ // sometimes generates source maps with duplicates in them. See Github issue
1074
+ // #72 and bugzil.la/889492.
1075
+ this._names = ArraySet.fromArray(names, true);
1076
+ this._sources = ArraySet.fromArray(sources, true);
1077
+
1078
+ this.sourceRoot = sourceRoot;
1079
+ this.sourcesContent = sourcesContent;
1080
+ this._mappings = mappings;
1081
+ this.file = file;
1082
+ }
1083
+
1084
+ /**
1085
+ * Create a SourceMapConsumer from a SourceMapGenerator.
1086
+ *
1087
+ * @param SourceMapGenerator aSourceMap
1088
+ * The source map that will be consumed.
1089
+ * @returns SourceMapConsumer
1090
+ */
1091
+ SourceMapConsumer.fromSourceMap =
1092
+ function SourceMapConsumer_fromSourceMap(aSourceMap) {
1093
+ var smc = Object.create(SourceMapConsumer.prototype);
1094
+
1095
+ smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
1096
+ smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
1097
+ smc.sourceRoot = aSourceMap._sourceRoot;
1098
+ smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
1099
+ smc.sourceRoot);
1100
+ smc.file = aSourceMap._file;
1101
+
1102
+ smc.__generatedMappings = aSourceMap._mappings.slice()
1103
+ .sort(util.compareByGeneratedPositions);
1104
+ smc.__originalMappings = aSourceMap._mappings.slice()
1105
+ .sort(util.compareByOriginalPositions);
1106
+
1107
+ return smc;
1108
+ };
1109
+
1110
+ /**
1111
+ * The version of the source mapping spec that we are consuming.
1112
+ */
1113
+ SourceMapConsumer.prototype._version = 3;
1114
+
1115
+ /**
1116
+ * The list of original sources.
1117
+ */
1118
+ Object.defineProperty(SourceMapConsumer.prototype, 'sources', {
1119
+ get: function () {
1120
+ return this._sources.toArray().map(function (s) {
1121
+ return this.sourceRoot ? util.join(this.sourceRoot, s) : s;
1122
+ }, this);
1123
+ }
1124
+ });
1125
+
1126
+ // `__generatedMappings` and `__originalMappings` are arrays that hold the
1127
+ // parsed mapping coordinates from the source map's "mappings" attribute. They
1128
+ // are lazily instantiated, accessed via the `_generatedMappings` and
1129
+ // `_originalMappings` getters respectively, and we only parse the mappings
1130
+ // and create these arrays once queried for a source location. We jump through
1131
+ // these hoops because there can be many thousands of mappings, and parsing
1132
+ // them is expensive, so we only want to do it if we must.
1133
+ //
1134
+ // Each object in the arrays is of the form:
1135
+ //
1136
+ // {
1137
+ // generatedLine: The line number in the generated code,
1138
+ // generatedColumn: The column number in the generated code,
1139
+ // source: The path to the original source file that generated this
1140
+ // chunk of code,
1141
+ // originalLine: The line number in the original source that
1142
+ // corresponds to this chunk of generated code,
1143
+ // originalColumn: The column number in the original source that
1144
+ // corresponds to this chunk of generated code,
1145
+ // name: The name of the original symbol which generated this chunk of
1146
+ // code.
1147
+ // }
1148
+ //
1149
+ // All properties except for `generatedLine` and `generatedColumn` can be
1150
+ // `null`.
1151
+ //
1152
+ // `_generatedMappings` is ordered by the generated positions.
1153
+ //
1154
+ // `_originalMappings` is ordered by the original positions.
1155
+
1156
+ SourceMapConsumer.prototype.__generatedMappings = null;
1157
+ Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
1158
+ get: function () {
1159
+ if (!this.__generatedMappings) {
1160
+ this.__generatedMappings = [];
1161
+ this.__originalMappings = [];
1162
+ this._parseMappings(this._mappings, this.sourceRoot);
1163
+ }
1164
+
1165
+ return this.__generatedMappings;
1166
+ }
1167
+ });
1168
+
1169
+ SourceMapConsumer.prototype.__originalMappings = null;
1170
+ Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
1171
+ get: function () {
1172
+ if (!this.__originalMappings) {
1173
+ this.__generatedMappings = [];
1174
+ this.__originalMappings = [];
1175
+ this._parseMappings(this._mappings, this.sourceRoot);
1176
+ }
1177
+
1178
+ return this.__originalMappings;
1179
+ }
1180
+ });
1181
+
1182
+ /**
1183
+ * Parse the mappings in a string in to a data structure which we can easily
1184
+ * query (the ordered arrays in the `this.__generatedMappings` and
1185
+ * `this.__originalMappings` properties).
1186
+ */
1187
+ SourceMapConsumer.prototype._parseMappings =
1188
+ function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
1189
+ var generatedLine = 1;
1190
+ var previousGeneratedColumn = 0;
1191
+ var previousOriginalLine = 0;
1192
+ var previousOriginalColumn = 0;
1193
+ var previousSource = 0;
1194
+ var previousName = 0;
1195
+ var mappingSeparator = /^[,;]/;
1196
+ var str = aStr;
1197
+ var mapping;
1198
+ var temp;
1199
+
1200
+ while (str.length > 0) {
1201
+ if (str.charAt(0) === ';') {
1202
+ generatedLine++;
1203
+ str = str.slice(1);
1204
+ previousGeneratedColumn = 0;
1205
+ }
1206
+ else if (str.charAt(0) === ',') {
1207
+ str = str.slice(1);
1208
+ }
1209
+ else {
1210
+ mapping = {};
1211
+ mapping.generatedLine = generatedLine;
1212
+
1213
+ // Generated column.
1214
+ temp = base64VLQ.decode(str);
1215
+ mapping.generatedColumn = previousGeneratedColumn + temp.value;
1216
+ previousGeneratedColumn = mapping.generatedColumn;
1217
+ str = temp.rest;
1218
+
1219
+ if (str.length > 0 && !mappingSeparator.test(str.charAt(0))) {
1220
+ // Original source.
1221
+ temp = base64VLQ.decode(str);
1222
+ mapping.source = this._sources.at(previousSource + temp.value);
1223
+ previousSource += temp.value;
1224
+ str = temp.rest;
1225
+ if (str.length === 0 || mappingSeparator.test(str.charAt(0))) {
1226
+ throw new Error('Found a source, but no line and column');
1227
+ }
1228
+
1229
+ // Original line.
1230
+ temp = base64VLQ.decode(str);
1231
+ mapping.originalLine = previousOriginalLine + temp.value;
1232
+ previousOriginalLine = mapping.originalLine;
1233
+ // Lines are stored 0-based
1234
+ mapping.originalLine += 1;
1235
+ str = temp.rest;
1236
+ if (str.length === 0 || mappingSeparator.test(str.charAt(0))) {
1237
+ throw new Error('Found a source and line, but no column');
1238
+ }
1239
+
1240
+ // Original column.
1241
+ temp = base64VLQ.decode(str);
1242
+ mapping.originalColumn = previousOriginalColumn + temp.value;
1243
+ previousOriginalColumn = mapping.originalColumn;
1244
+ str = temp.rest;
1245
+
1246
+ if (str.length > 0 && !mappingSeparator.test(str.charAt(0))) {
1247
+ // Original name.
1248
+ temp = base64VLQ.decode(str);
1249
+ mapping.name = this._names.at(previousName + temp.value);
1250
+ previousName += temp.value;
1251
+ str = temp.rest;
1252
+ }
1253
+ }
1254
+
1255
+ this.__generatedMappings.push(mapping);
1256
+ if (typeof mapping.originalLine === 'number') {
1257
+ this.__originalMappings.push(mapping);
1258
+ }
1259
+ }
1260
+ }
1261
+
1262
+ this.__originalMappings.sort(util.compareByOriginalPositions);
1263
+ };
1264
+
1265
+ /**
1266
+ * Find the mapping that best matches the hypothetical "needle" mapping that
1267
+ * we are searching for in the given "haystack" of mappings.
1268
+ */
1269
+ SourceMapConsumer.prototype._findMapping =
1270
+ function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
1271
+ aColumnName, aComparator) {
1272
+ // To return the position we are searching for, we must first find the
1273
+ // mapping for the given position and then return the opposite position it
1274
+ // points to. Because the mappings are sorted, we can use binary search to
1275
+ // find the best mapping.
1276
+
1277
+ if (aNeedle[aLineName] <= 0) {
1278
+ throw new TypeError('Line must be greater than or equal to 1, got '
1279
+ + aNeedle[aLineName]);
1280
+ }
1281
+ if (aNeedle[aColumnName] < 0) {
1282
+ throw new TypeError('Column must be greater than or equal to 0, got '
1283
+ + aNeedle[aColumnName]);
1284
+ }
1285
+
1286
+ return binarySearch.search(aNeedle, aMappings, aComparator);
1287
+ };
1288
+
1289
+ /**
1290
+ * Returns the original source, line, and column information for the generated
1291
+ * source's line and column positions provided. The only argument is an object
1292
+ * with the following properties:
1293
+ *
1294
+ * - line: The line number in the generated source.
1295
+ * - column: The column number in the generated source.
1296
+ *
1297
+ * and an object is returned with the following properties:
1298
+ *
1299
+ * - source: The original source file, or null.
1300
+ * - line: The line number in the original source, or null.
1301
+ * - column: The column number in the original source, or null.
1302
+ * - name: The original identifier, or null.
1303
+ */
1304
+ SourceMapConsumer.prototype.originalPositionFor =
1305
+ function SourceMapConsumer_originalPositionFor(aArgs) {
1306
+ var needle = {
1307
+ generatedLine: util.getArg(aArgs, 'line'),
1308
+ generatedColumn: util.getArg(aArgs, 'column')
1309
+ };
1310
+
1311
+ var mapping = this._findMapping(needle,
1312
+ this._generatedMappings,
1313
+ "generatedLine",
1314
+ "generatedColumn",
1315
+ util.compareByGeneratedPositions);
1316
+
1317
+ if (mapping) {
1318
+ var source = util.getArg(mapping, 'source', null);
1319
+ if (source && this.sourceRoot) {
1320
+ source = util.join(this.sourceRoot, source);
1321
+ }
1322
+ return {
1323
+ source: source,
1324
+ line: util.getArg(mapping, 'originalLine', null),
1325
+ column: util.getArg(mapping, 'originalColumn', null),
1326
+ name: util.getArg(mapping, 'name', null)
1327
+ };
1328
+ }
1329
+
1330
+ return {
1331
+ source: null,
1332
+ line: null,
1333
+ column: null,
1334
+ name: null
1335
+ };
1336
+ };
1337
+
1338
+ /**
1339
+ * Returns the original source content. The only argument is the url of the
1340
+ * original source file. Returns null if no original source content is
1341
+ * availible.
1342
+ */
1343
+ SourceMapConsumer.prototype.sourceContentFor =
1344
+ function SourceMapConsumer_sourceContentFor(aSource) {
1345
+ if (!this.sourcesContent) {
1346
+ return null;
1347
+ }
1348
+
1349
+ if (this.sourceRoot) {
1350
+ aSource = util.relative(this.sourceRoot, aSource);
1351
+ }
1352
+
1353
+ if (this._sources.has(aSource)) {
1354
+ return this.sourcesContent[this._sources.indexOf(aSource)];
1355
+ }
1356
+
1357
+ var url;
1358
+ if (this.sourceRoot
1359
+ && (url = util.urlParse(this.sourceRoot))) {
1360
+ // XXX: file:// URIs and absolute paths lead to unexpected behavior for
1361
+ // many users. We can help them out when they expect file:// URIs to
1362
+ // behave like it would if they were running a local HTTP server. See
1363
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
1364
+ var fileUriAbsPath = aSource.replace(/^file:\/\//, "");
1365
+ if (url.scheme == "file"
1366
+ && this._sources.has(fileUriAbsPath)) {
1367
+ return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
1368
+ }
1369
+
1370
+ if ((!url.path || url.path == "/")
1371
+ && this._sources.has("/" + aSource)) {
1372
+ return this.sourcesContent[this._sources.indexOf("/" + aSource)];
1373
+ }
1374
+ }
1375
+
1376
+ throw new Error('"' + aSource + '" is not in the SourceMap.');
1377
+ };
1378
+
1379
+ /**
1380
+ * Returns the generated line and column information for the original source,
1381
+ * line, and column positions provided. The only argument is an object with
1382
+ * the following properties:
1383
+ *
1384
+ * - source: The filename of the original source.
1385
+ * - line: The line number in the original source.
1386
+ * - column: The column number in the original source.
1387
+ *
1388
+ * and an object is returned with the following properties:
1389
+ *
1390
+ * - line: The line number in the generated source, or null.
1391
+ * - column: The column number in the generated source, or null.
1392
+ */
1393
+ SourceMapConsumer.prototype.generatedPositionFor =
1394
+ function SourceMapConsumer_generatedPositionFor(aArgs) {
1395
+ var needle = {
1396
+ source: util.getArg(aArgs, 'source'),
1397
+ originalLine: util.getArg(aArgs, 'line'),
1398
+ originalColumn: util.getArg(aArgs, 'column')
1399
+ };
1400
+
1401
+ if (this.sourceRoot) {
1402
+ needle.source = util.relative(this.sourceRoot, needle.source);
1403
+ }
1404
+
1405
+ var mapping = this._findMapping(needle,
1406
+ this._originalMappings,
1407
+ "originalLine",
1408
+ "originalColumn",
1409
+ util.compareByOriginalPositions);
1410
+
1411
+ if (mapping) {
1412
+ return {
1413
+ line: util.getArg(mapping, 'generatedLine', null),
1414
+ column: util.getArg(mapping, 'generatedColumn', null)
1415
+ };
1416
+ }
1417
+
1418
+ return {
1419
+ line: null,
1420
+ column: null
1421
+ };
1422
+ };
1423
+
1424
+ SourceMapConsumer.GENERATED_ORDER = 1;
1425
+ SourceMapConsumer.ORIGINAL_ORDER = 2;
1426
+
1427
+ /**
1428
+ * Iterate over each mapping between an original source/line/column and a
1429
+ * generated line/column in this source map.
1430
+ *
1431
+ * @param Function aCallback
1432
+ * The function that is called with each mapping.
1433
+ * @param Object aContext
1434
+ * Optional. If specified, this object will be the value of `this` every
1435
+ * time that `aCallback` is called.
1436
+ * @param aOrder
1437
+ * Either `SourceMapConsumer.GENERATED_ORDER` or
1438
+ * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
1439
+ * iterate over the mappings sorted by the generated file's line/column
1440
+ * order or the original's source/line/column order, respectively. Defaults to
1441
+ * `SourceMapConsumer.GENERATED_ORDER`.
1442
+ */
1443
+ SourceMapConsumer.prototype.eachMapping =
1444
+ function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
1445
+ var context = aContext || null;
1446
+ var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
1447
+
1448
+ var mappings;
1449
+ switch (order) {
1450
+ case SourceMapConsumer.GENERATED_ORDER:
1451
+ mappings = this._generatedMappings;
1452
+ break;
1453
+ case SourceMapConsumer.ORIGINAL_ORDER:
1454
+ mappings = this._originalMappings;
1455
+ break;
1456
+ default:
1457
+ throw new Error("Unknown order of iteration.");
1458
+ }
1459
+
1460
+ var sourceRoot = this.sourceRoot;
1461
+ mappings.map(function (mapping) {
1462
+ var source = mapping.source;
1463
+ if (source && sourceRoot) {
1464
+ source = util.join(sourceRoot, source);
1465
+ }
1466
+ return {
1467
+ source: source,
1468
+ generatedLine: mapping.generatedLine,
1469
+ generatedColumn: mapping.generatedColumn,
1470
+ originalLine: mapping.originalLine,
1471
+ originalColumn: mapping.originalColumn,
1472
+ name: mapping.name
1473
+ };
1474
+ }).forEach(aCallback, context);
1475
+ };
1476
+
1477
+ exports.SourceMapConsumer = SourceMapConsumer;
1478
+
1479
+ });
1480
+ /* -*- Mode: js; js-indent-level: 2; -*- */
1481
+ /*
1482
+ * Copyright 2011 Mozilla Foundation and contributors
1483
+ * Licensed under the New BSD license. See LICENSE or:
1484
+ * http://opensource.org/licenses/BSD-3-Clause
1485
+ */
1486
+ define('source-map/binary-search', ['require', 'exports', 'module' , ], function(require, exports, module) {
1487
+
1488
+ /**
1489
+ * Recursive implementation of binary search.
1490
+ *
1491
+ * @param aLow Indices here and lower do not contain the needle.
1492
+ * @param aHigh Indices here and higher do not contain the needle.
1493
+ * @param aNeedle The element being searched for.
1494
+ * @param aHaystack The non-empty array being searched.
1495
+ * @param aCompare Function which takes two elements and returns -1, 0, or 1.
1496
+ */
1497
+ function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare) {
1498
+ // This function terminates when one of the following is true:
1499
+ //
1500
+ // 1. We find the exact element we are looking for.
1501
+ //
1502
+ // 2. We did not find the exact element, but we can return the next
1503
+ // closest element that is less than that element.
1504
+ //
1505
+ // 3. We did not find the exact element, and there is no next-closest
1506
+ // element which is less than the one we are searching for, so we
1507
+ // return null.
1508
+ var mid = Math.floor((aHigh - aLow) / 2) + aLow;
1509
+ var cmp = aCompare(aNeedle, aHaystack[mid], true);
1510
+ if (cmp === 0) {
1511
+ // Found the element we are looking for.
1512
+ return aHaystack[mid];
1513
+ }
1514
+ else if (cmp > 0) {
1515
+ // aHaystack[mid] is greater than our needle.
1516
+ if (aHigh - mid > 1) {
1517
+ // The element is in the upper half.
1518
+ return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare);
1519
+ }
1520
+ // We did not find an exact match, return the next closest one
1521
+ // (termination case 2).
1522
+ return aHaystack[mid];
1523
+ }
1524
+ else {
1525
+ // aHaystack[mid] is less than our needle.
1526
+ if (mid - aLow > 1) {
1527
+ // The element is in the lower half.
1528
+ return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare);
1529
+ }
1530
+ // The exact needle element was not found in this haystack. Determine if
1531
+ // we are in termination case (2) or (3) and return the appropriate thing.
1532
+ return aLow < 0
1533
+ ? null
1534
+ : aHaystack[aLow];
1535
+ }
1536
+ }
1537
+
1538
+ /**
1539
+ * This is an implementation of binary search which will always try and return
1540
+ * the next lowest value checked if there is no exact hit. This is because
1541
+ * mappings between original and generated line/col pairs are single points,
1542
+ * and there is an implicit region between each of them, so a miss just means
1543
+ * that you aren't on the very start of a region.
1544
+ *
1545
+ * @param aNeedle The element you are looking for.
1546
+ * @param aHaystack The array that is being searched.
1547
+ * @param aCompare A function which takes the needle and an element in the
1548
+ * array and returns -1, 0, or 1 depending on whether the needle is less
1549
+ * than, equal to, or greater than the element, respectively.
1550
+ */
1551
+ exports.search = function search(aNeedle, aHaystack, aCompare) {
1552
+ return aHaystack.length > 0
1553
+ ? recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare)
1554
+ : null;
1555
+ };
1556
+
1557
+ });
1558
+ /* -*- Mode: js; js-indent-level: 2; -*- */
1559
+ /*
1560
+ * Copyright 2011 Mozilla Foundation and contributors
1561
+ * Licensed under the New BSD license. See LICENSE or:
1562
+ * http://opensource.org/licenses/BSD-3-Clause
1563
+ */
1564
+ define('source-map/source-node', ['require', 'exports', 'module' , 'source-map/source-map-generator', 'source-map/util'], function(require, exports, module) {
1565
+
1566
+ var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator;
1567
+ var util = require('./util');
1568
+
1569
+ /**
1570
+ * SourceNodes provide a way to abstract over interpolating/concatenating
1571
+ * snippets of generated JavaScript source code while maintaining the line and
1572
+ * column information associated with the original source code.
1573
+ *
1574
+ * @param aLine The original line number.
1575
+ * @param aColumn The original column number.
1576
+ * @param aSource The original source's filename.
1577
+ * @param aChunks Optional. An array of strings which are snippets of
1578
+ * generated JS, or other SourceNodes.
1579
+ * @param aName The original identifier.
1580
+ */
1581
+ function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
1582
+ this.children = [];
1583
+ this.sourceContents = {};
1584
+ this.line = aLine === undefined ? null : aLine;
1585
+ this.column = aColumn === undefined ? null : aColumn;
1586
+ this.source = aSource === undefined ? null : aSource;
1587
+ this.name = aName === undefined ? null : aName;
1588
+ if (aChunks != null) this.add(aChunks);
1589
+ }
1590
+
1591
+ /**
1592
+ * Creates a SourceNode from generated code and a SourceMapConsumer.
1593
+ *
1594
+ * @param aGeneratedCode The generated code
1595
+ * @param aSourceMapConsumer The SourceMap for the generated code
1596
+ */
1597
+ SourceNode.fromStringWithSourceMap =
1598
+ function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer) {
1599
+ // The SourceNode we want to fill with the generated code
1600
+ // and the SourceMap
1601
+ var node = new SourceNode();
1602
+
1603
+ // The generated code
1604
+ // Processed fragments are removed from this array.
1605
+ var remainingLines = aGeneratedCode.split('\n');
1606
+
1607
+ // We need to remember the position of "remainingLines"
1608
+ var lastGeneratedLine = 1, lastGeneratedColumn = 0;
1609
+
1610
+ // The generate SourceNodes we need a code range.
1611
+ // To extract it current and last mapping is used.
1612
+ // Here we store the last mapping.
1613
+ var lastMapping = null;
1614
+
1615
+ aSourceMapConsumer.eachMapping(function (mapping) {
1616
+ if (lastMapping === null) {
1617
+ // We add the generated code until the first mapping
1618
+ // to the SourceNode without any mapping.
1619
+ // Each line is added as separate string.
1620
+ while (lastGeneratedLine < mapping.generatedLine) {
1621
+ node.add(remainingLines.shift() + "\n");
1622
+ lastGeneratedLine++;
1623
+ }
1624
+ if (lastGeneratedColumn < mapping.generatedColumn) {
1625
+ var nextLine = remainingLines[0];
1626
+ node.add(nextLine.substr(0, mapping.generatedColumn));
1627
+ remainingLines[0] = nextLine.substr(mapping.generatedColumn);
1628
+ lastGeneratedColumn = mapping.generatedColumn;
1629
+ }
1630
+ } else {
1631
+ // We add the code from "lastMapping" to "mapping":
1632
+ // First check if there is a new line in between.
1633
+ if (lastGeneratedLine < mapping.generatedLine) {
1634
+ var code = "";
1635
+ // Associate full lines with "lastMapping"
1636
+ do {
1637
+ code += remainingLines.shift() + "\n";
1638
+ lastGeneratedLine++;
1639
+ lastGeneratedColumn = 0;
1640
+ } while (lastGeneratedLine < mapping.generatedLine);
1641
+ // When we reached the correct line, we add code until we
1642
+ // reach the correct column too.
1643
+ if (lastGeneratedColumn < mapping.generatedColumn) {
1644
+ var nextLine = remainingLines[0];
1645
+ code += nextLine.substr(0, mapping.generatedColumn);
1646
+ remainingLines[0] = nextLine.substr(mapping.generatedColumn);
1647
+ lastGeneratedColumn = mapping.generatedColumn;
1648
+ }
1649
+ // Create the SourceNode.
1650
+ addMappingWithCode(lastMapping, code);
1651
+ } else {
1652
+ // There is no new line in between.
1653
+ // Associate the code between "lastGeneratedColumn" and
1654
+ // "mapping.generatedColumn" with "lastMapping"
1655
+ var nextLine = remainingLines[0];
1656
+ var code = nextLine.substr(0, mapping.generatedColumn -
1657
+ lastGeneratedColumn);
1658
+ remainingLines[0] = nextLine.substr(mapping.generatedColumn -
1659
+ lastGeneratedColumn);
1660
+ lastGeneratedColumn = mapping.generatedColumn;
1661
+ addMappingWithCode(lastMapping, code);
1662
+ }
1663
+ }
1664
+ lastMapping = mapping;
1665
+ }, this);
1666
+ // We have processed all mappings.
1667
+ // Associate the remaining code in the current line with "lastMapping"
1668
+ // and add the remaining lines without any mapping
1669
+ addMappingWithCode(lastMapping, remainingLines.join("\n"));
1670
+
1671
+ // Copy sourcesContent into SourceNode
1672
+ aSourceMapConsumer.sources.forEach(function (sourceFile) {
1673
+ var content = aSourceMapConsumer.sourceContentFor(sourceFile);
1674
+ if (content) {
1675
+ node.setSourceContent(sourceFile, content);
1676
+ }
1677
+ });
1678
+
1679
+ return node;
1680
+
1681
+ function addMappingWithCode(mapping, code) {
1682
+ if (mapping === null || mapping.source === undefined) {
1683
+ node.add(code);
1684
+ } else {
1685
+ node.add(new SourceNode(mapping.originalLine,
1686
+ mapping.originalColumn,
1687
+ mapping.source,
1688
+ code,
1689
+ mapping.name));
1690
+ }
1691
+ }
1692
+ };
1693
+
1694
+ /**
1695
+ * Add a chunk of generated JS to this source node.
1696
+ *
1697
+ * @param aChunk A string snippet of generated JS code, another instance of
1698
+ * SourceNode, or an array where each member is one of those things.
1699
+ */
1700
+ SourceNode.prototype.add = function SourceNode_add(aChunk) {
1701
+ if (Array.isArray(aChunk)) {
1702
+ aChunk.forEach(function (chunk) {
1703
+ this.add(chunk);
1704
+ }, this);
1705
+ }
1706
+ else if (aChunk instanceof SourceNode || typeof aChunk === "string") {
1707
+ if (aChunk) {
1708
+ this.children.push(aChunk);
1709
+ }
1710
+ }
1711
+ else {
1712
+ throw new TypeError(
1713
+ "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
1714
+ );
1715
+ }
1716
+ return this;
1717
+ };
1718
+
1719
+ /**
1720
+ * Add a chunk of generated JS to the beginning of this source node.
1721
+ *
1722
+ * @param aChunk A string snippet of generated JS code, another instance of
1723
+ * SourceNode, or an array where each member is one of those things.
1724
+ */
1725
+ SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
1726
+ if (Array.isArray(aChunk)) {
1727
+ for (var i = aChunk.length-1; i >= 0; i--) {
1728
+ this.prepend(aChunk[i]);
1729
+ }
1730
+ }
1731
+ else if (aChunk instanceof SourceNode || typeof aChunk === "string") {
1732
+ this.children.unshift(aChunk);
1733
+ }
1734
+ else {
1735
+ throw new TypeError(
1736
+ "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
1737
+ );
1738
+ }
1739
+ return this;
1740
+ };
1741
+
1742
+ /**
1743
+ * Walk over the tree of JS snippets in this node and its children. The
1744
+ * walking function is called once for each snippet of JS and is passed that
1745
+ * snippet and the its original associated source's line/column location.
1746
+ *
1747
+ * @param aFn The traversal function.
1748
+ */
1749
+ SourceNode.prototype.walk = function SourceNode_walk(aFn) {
1750
+ var chunk;
1751
+ for (var i = 0, len = this.children.length; i < len; i++) {
1752
+ chunk = this.children[i];
1753
+ if (chunk instanceof SourceNode) {
1754
+ chunk.walk(aFn);
1755
+ }
1756
+ else {
1757
+ if (chunk !== '') {
1758
+ aFn(chunk, { source: this.source,
1759
+ line: this.line,
1760
+ column: this.column,
1761
+ name: this.name });
1762
+ }
1763
+ }
1764
+ }
1765
+ };
1766
+
1767
+ /**
1768
+ * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
1769
+ * each of `this.children`.
1770
+ *
1771
+ * @param aSep The separator.
1772
+ */
1773
+ SourceNode.prototype.join = function SourceNode_join(aSep) {
1774
+ var newChildren;
1775
+ var i;
1776
+ var len = this.children.length;
1777
+ if (len > 0) {
1778
+ newChildren = [];
1779
+ for (i = 0; i < len-1; i++) {
1780
+ newChildren.push(this.children[i]);
1781
+ newChildren.push(aSep);
1782
+ }
1783
+ newChildren.push(this.children[i]);
1784
+ this.children = newChildren;
1785
+ }
1786
+ return this;
1787
+ };
1788
+
1789
+ /**
1790
+ * Call String.prototype.replace on the very right-most source snippet. Useful
1791
+ * for trimming whitespace from the end of a source node, etc.
1792
+ *
1793
+ * @param aPattern The pattern to replace.
1794
+ * @param aReplacement The thing to replace the pattern with.
1795
+ */
1796
+ SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
1797
+ var lastChild = this.children[this.children.length - 1];
1798
+ if (lastChild instanceof SourceNode) {
1799
+ lastChild.replaceRight(aPattern, aReplacement);
1800
+ }
1801
+ else if (typeof lastChild === 'string') {
1802
+ this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
1803
+ }
1804
+ else {
1805
+ this.children.push(''.replace(aPattern, aReplacement));
1806
+ }
1807
+ return this;
1808
+ };
1809
+
1810
+ /**
1811
+ * Set the source content for a source file. This will be added to the SourceMapGenerator
1812
+ * in the sourcesContent field.
1813
+ *
1814
+ * @param aSourceFile The filename of the source file
1815
+ * @param aSourceContent The content of the source file
1816
+ */
1817
+ SourceNode.prototype.setSourceContent =
1818
+ function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
1819
+ this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
1820
+ };
1821
+
1822
+ /**
1823
+ * Walk over the tree of SourceNodes. The walking function is called for each
1824
+ * source file content and is passed the filename and source content.
1825
+ *
1826
+ * @param aFn The traversal function.
1827
+ */
1828
+ SourceNode.prototype.walkSourceContents =
1829
+ function SourceNode_walkSourceContents(aFn) {
1830
+ for (var i = 0, len = this.children.length; i < len; i++) {
1831
+ if (this.children[i] instanceof SourceNode) {
1832
+ this.children[i].walkSourceContents(aFn);
1833
+ }
1834
+ }
1835
+
1836
+ var sources = Object.keys(this.sourceContents);
1837
+ for (var i = 0, len = sources.length; i < len; i++) {
1838
+ aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
1839
+ }
1840
+ };
1841
+
1842
+ /**
1843
+ * Return the string representation of this source node. Walks over the tree
1844
+ * and concatenates all the various snippets together to one string.
1845
+ */
1846
+ SourceNode.prototype.toString = function SourceNode_toString() {
1847
+ var str = "";
1848
+ this.walk(function (chunk) {
1849
+ str += chunk;
1850
+ });
1851
+ return str;
1852
+ };
1853
+
1854
+ /**
1855
+ * Returns the string representation of this source node along with a source
1856
+ * map.
1857
+ */
1858
+ SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
1859
+ var generated = {
1860
+ code: "",
1861
+ line: 1,
1862
+ column: 0
1863
+ };
1864
+ var map = new SourceMapGenerator(aArgs);
1865
+ var sourceMappingActive = false;
1866
+ var lastOriginalSource = null;
1867
+ var lastOriginalLine = null;
1868
+ var lastOriginalColumn = null;
1869
+ var lastOriginalName = null;
1870
+ this.walk(function (chunk, original) {
1871
+ generated.code += chunk;
1872
+ if (original.source !== null
1873
+ && original.line !== null
1874
+ && original.column !== null) {
1875
+ if (lastOriginalSource !== original.source
1876
+ || lastOriginalLine !== original.line
1877
+ || lastOriginalColumn !== original.column
1878
+ || lastOriginalName !== original.name) {
1879
+ map.addMapping({
1880
+ source: original.source,
1881
+ original: {
1882
+ line: original.line,
1883
+ column: original.column
1884
+ },
1885
+ generated: {
1886
+ line: generated.line,
1887
+ column: generated.column
1888
+ },
1889
+ name: original.name
1890
+ });
1891
+ }
1892
+ lastOriginalSource = original.source;
1893
+ lastOriginalLine = original.line;
1894
+ lastOriginalColumn = original.column;
1895
+ lastOriginalName = original.name;
1896
+ sourceMappingActive = true;
1897
+ } else if (sourceMappingActive) {
1898
+ map.addMapping({
1899
+ generated: {
1900
+ line: generated.line,
1901
+ column: generated.column
1902
+ }
1903
+ });
1904
+ lastOriginalSource = null;
1905
+ sourceMappingActive = false;
1906
+ }
1907
+ chunk.split('').forEach(function (ch) {
1908
+ if (ch === '\n') {
1909
+ generated.line++;
1910
+ generated.column = 0;
1911
+ } else {
1912
+ generated.column++;
1913
+ }
1914
+ });
1915
+ });
1916
+ this.walkSourceContents(function (sourceFile, sourceContent) {
1917
+ map.setSourceContent(sourceFile, sourceContent);
1918
+ });
1919
+
1920
+ return { code: generated.code, map: map };
1921
+ };
1922
+
1923
+ exports.SourceNode = SourceNode;
1924
+
1925
+ });
1926
+ /* -*- Mode: js; js-indent-level: 2; -*- */
1927
+ ///////////////////////////////////////////////////////////////////////////////
1928
+
1929
+ this.sourceMap = {
1930
+ SourceMapConsumer: require('source-map/source-map-consumer').SourceMapConsumer,
1931
+ SourceMapGenerator: require('source-map/source-map-generator').SourceMapGenerator,
1932
+ SourceNode: require('source-map/source-node').SourceNode
1933
+ };