1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
3 ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
4 ;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2018 Nicolas Goaziou <mail@nicolasgoaziou.fr>
8 ;;; This file is part of GNU Guix.
10 ;;; GNU Guix is free software; you can redistribute it and/or modify it
11 ;;; under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or (at
13 ;;; your option) any later version.
15 ;;; GNU Guix is distributed in the hope that it will be useful, but
16 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23 (define-module (gnu packages javascript)
24 #:use-module ((guix licenses) #:prefix license:)
25 #:use-module (gnu packages)
26 #:use-module (gnu packages base)
27 #:use-module (gnu packages compression)
28 #:use-module (gnu packages lisp)
29 #:use-module (guix packages)
30 #:use-module (guix download)
31 #:use-module (guix git-download)
32 #:use-module (guix build-system gnu)
33 #:use-module (guix build-system trivial)
34 #:use-module (guix build-system minify))
36 (define-public font-mathjax
44 "https://github.com/mathjax/MathJax/archive/"
46 (file-name (string-append name "-" version ".tar.gz"))
49 "1r72di4pg4i6pfhcskkxqmf1158m81ki6a7lbw6nz4zh7xw23hy4"))))
50 (build-system trivial-build-system)
52 `(#:modules ((guix build utils))
55 (use-modules (guix build utils)
57 (set-path-environment-variable
58 "PATH" '("bin") (map (match-lambda
62 (let ((install-directory (string-append %output "/share/fonts/mathjax")))
63 (mkdir-p install-directory)
64 (invoke "tar" "-C" install-directory "-xvf"
65 (assoc-ref %build-inputs "source")
66 ,(string-append "MathJax-" version "/fonts")
71 (home-page "https://www.mathjax.org/")
72 (synopsis "Fonts for MathJax")
73 (description "This package contains the fonts required for MathJax.")
74 (license license:asl2.0)))
76 (define-public js-mathjax
78 (inherit font-mathjax)
81 `(#:modules ((guix build utils))
84 (use-modules (guix build utils)
88 (set-path-environment-variable
89 "PATH" '("bin") (map (match-lambda
93 (set-path-environment-variable
94 "GUIX_LOCPATH" '("lib/locale")
95 (list (assoc-ref %build-inputs "glibc-utf8-locales")))
96 (setenv "LANG" "en_US.UTF-8")
97 (let ((install-directory (string-append %output "/share/javascript/mathjax")))
98 (invoke "tar" "xvf" (assoc-ref %build-inputs "source")
99 ,(string-append "MathJax-" (package-version font-mathjax)
102 (mkdir-p install-directory)
103 (symlink (string-append (assoc-ref %build-inputs "font-mathjax")
104 "/share/fonts/mathjax")
105 (string-append install-directory "/fonts"))
109 (let ((installed (string-append install-directory
111 (string-drop file 1))))
112 (format #t "~a -> ~a~%" file installed)
114 ((string-match "\\.js$" file)
115 (mkdir-p (dirname installed))
116 (let ((minified (open-pipe* OPEN_READ "uglify-js" file)))
117 (call-with-output-file installed
119 (dump-port minified port)))))
121 (install-file file (dirname installed))))))
126 `(("font-mathjax" ,font-mathjax)
127 ("glibc-utf8-locales" ,glibc-utf8-locales)
128 ("uglify-js" ,uglify-js)
129 ,@(package-native-inputs font-mathjax)))
130 (synopsis "JavaScript display engine for LaTeX, MathML, and AsciiMath")
131 (description "MathJax is a JavaScript display engine for LaTeX, MathML,
132 and AsciiMath notation that works in all modern browsers. It requires no
133 plugins or software to be installed on the browser. So the page author can
134 write web documents that include mathematics and be confident that readers will
135 be able to view it naturally and easily.")))
137 (define-public js-respond
143 (uri (string-append "https://github.com/scottjehl/Respond/"
144 "archive/" version ".tar.gz"))
145 (file-name (string-append name "-" version ".tar.gz"))
148 "0ds1ya2a185jp93mdn07159c2x8zczwi960ykrawpp62bwk2n93d"))))
149 (build-system trivial-build-system)
151 `(#:modules ((guix build utils))
154 (use-modules (guix build utils)
158 (set-path-environment-variable
159 "PATH" '("bin") (map (match-lambda
163 (let ((install-directory (string-append %output
164 "/share/javascript/respond/")))
166 (assoc-ref %build-inputs "source")
168 (mkdir-p install-directory)
169 (let* ((file "src/respond.js")
170 (installed (string-append install-directory "respond.min.js")))
171 (let ((minified (open-pipe* OPEN_READ "uglify-js" file)))
172 (call-with-output-file installed
173 (cut dump-port minified <>)))))
175 (home-page "https://github.com/scottjehl/Respond")
177 `(("uglify-js" ,uglify-js)
181 (synopsis "Polyfill for min/max-width CSS3 Media Queries")
182 (description "The goal of this script is to provide a fast and lightweight
183 script to enable responsive web designs in browsers that don't support CSS3
185 (license license:expat)))
187 (define-public js-html5shiv
189 (name "js-html5shiv")
193 (uri (string-append "https://github.com/aFarkas/html5shiv/"
194 "archive/" version ".tar.gz"))
195 (file-name (string-append name "-" version ".tar.gz"))
198 "0inlbpxpqzdyi24lqagzf7l24zxg0y02xcpqs2h4npjscazzw7hg"))))
199 (build-system minify-build-system)
200 (home-page "https://github.com/aFarkas/html5shiv")
201 (synopsis "Enable HTML5 sectioning elements in legacy browsers")
202 (description "The HTML5 Shiv enables use of HTML5 sectioning elements in
203 legacy Internet Explorer and provides basic HTML5 styling for Internet
204 Explorer 6-9, Safari 4.x (and iPhone 3.x), and Firefox 3.x.")
205 ;; From the file "MIT and GPL2 licenses.md":
207 ;; This software is licensed under a dual license system (MIT or GPL
208 ;; version 2). This means you are free to choose with which of both
209 ;; licenses (MIT or GPL version 2) you want to use this library.
210 (license (list license:expat license:gpl2))))
212 (define-public js-json2
213 (let ((commit "031b1d9e6971bd4c433ca85e216cc853f5a867bd")
217 (version (string-append "2016-10-28." revision "-" (string-take commit 7)))
221 (url "https://github.com/douglascrockford/JSON-js.git")
223 (file-name (string-append name "-" version "-checkout"))
226 "1fvb6b2y5sd3sqdgcj683sdxcbxdii34q0ysc9wg0dq1sy81l11v"))))
227 (build-system minify-build-system)
229 `(#:javascript-files '("json2.js"
231 "json_parse_state.js"
233 (home-page "https://github.com/douglascrockford/JSON-js")
234 (synopsis "JSON encoders and decoders")
235 (description "The files in this collection implement JSON
236 encoders/decoders in JavaScript.
238 @code{json2.js}: This file creates a JSON property in the global object, if
239 there isn't already one, setting its value to an object containing a stringify
240 method and a parse method. The @code{parse} method uses the @code{eval}
241 method to do the parsing, guarding it with several regular expressions to
242 defend against accidental code execution hazards. On current browsers, this
243 file does nothing, preferring the built-in JSON object.
245 @code{json_parse.js}: This file contains an alternative JSON @code{parse}
246 function that uses recursive descent instead of @code{eval}.
248 @code{json_parse_state.js}: This files contains an alternative JSON
249 @code{parse} function that uses a state machine instead of @code{eval}.
251 @code{cycle.js}: This file contains two functions, @code{JSON.decycle} and
252 @code{JSON.retrocycle}, which make it possible to encode cyclical structures
253 and DAGs in JSON, and to then recover them. This is a capability that is not
254 provided by ES5. @code{JSONPath} is used to represent the links.")
255 (license license:public-domain))))
257 (define-public js-strftime
263 (uri (string-append "https://github.com/samsonjs/strftime/"
264 "archive/v" version ".tar.gz"))
265 (file-name (string-append name "-" version ".tar.gz"))
268 "1iya43w7y26y2dp9l4d40bhjc4scb5a9mng5ng5c8hsqr82f1375"))))
269 (build-system minify-build-system)
271 `(#:javascript-files '("strftime.js")))
272 (home-page "https://github.com/samsonjs/strftime")
273 (synopsis "Implementation of strftime to JavaScript")
274 (description "This is an implementation of the @code{strftime} procedure
275 for JavaScript. It works in (at least) node.js and browsers. It supports
276 localization and timezones. Most standard specifiers from C are supported as
277 well as some other extensions from Ruby.")
278 (license license:expat)))
280 (define-public js-highlight
282 (name "js-highlight")
286 (uri (string-append "https://github.com/isagalaev/highlight.js/"
287 "archive/" version ".tar.gz"))
288 (file-name (string-append name "-" version ".tar.gz"))
291 "1jjn9mj7fwq4zpr6is438bscf03b3q8jkj0k5c3fc6pkmjnhw939"))))
292 (build-system minify-build-system)
294 `(#:javascript-files '("src/highlight.js")))
295 (home-page "https://github.com/isagalaev/highlight.js")
296 (synopsis "Syntax highlighting for JavaScript")
297 (description "Highlight.js is a syntax highlighter written in JavaScript.
298 It works in the browser as well as on the server. It works with pretty much
299 any markup, doesn’t depend on any framework and has automatic language
301 (license license:bsd-3)))
303 (define-public js-datatables
305 (name "js-datatables")
309 (uri (string-append "https://datatables.net/releases/DataTables-"
313 "1y9xqyqyz7x1ls3ska71pshl2hpiy3qnw1f7wygyslbhy4ssgf57"))))
314 (build-system minify-build-system)
316 `(#:javascript-files '("media/js/dataTables.bootstrap.js"
317 "media/js/jquery.dataTables.js")))
320 (home-page "https://datatables.net")
321 (synopsis "DataTables plug-in for jQuery")
322 (description "DataTables is a table enhancing plug-in for the jQuery
323 Javascript library, adding sorting, paging and filtering abilities to plain
324 HTML tables with minimal effort.")
325 (license license:expat)))
327 (define-public js-selectize
329 (name "js-selectize")
333 (uri (string-append "https://github.com/selectize/selectize.js/"
334 "archive/v" version ".tar.gz"))
335 (file-name (string-append name "-" version ".tar.gz"))
338 "0756p49aaz34mw2dx8k1gxf210mngfrri25vkba0j7wihd2af8gn"))))
339 (build-system minify-build-system)
340 (arguments `(#:javascript-files '("src/selectize.js")))
341 (home-page "http://selectize.github.io/selectize.js/")
342 (synopsis "Hybrid widget between a textbox and <select> box")
343 (description "Selectize is the hybrid of a textbox and @code{<select>}
344 box. It's jQuery based and it has autocomplete and native-feeling keyboard
345 navigation; it is useful for tagging, contact lists, etc.")
346 (license license:asl2.0)))
348 (define-public js-es5-shim
354 (uri (string-append "https://github.com/es-shims/es5-shim/"
355 "archive/v" version ".tar.gz"))
356 (file-name (string-append name "-" version ".tar.gz"))
359 "0yfndyijz0ykddzprpvfjb2453gzpn528klmwycwbqc1bqd3m1hl"))))
360 (build-system minify-build-system)
361 (arguments `(#:javascript-files
364 (home-page "https://github.com/es-shims/es5-shim")
365 (synopsis "ECMAScript 5 compatibility shims for legacy JavaScript engines")
366 (description "@code{es5-shim.js} patches a JavaScript context to contain
367 all ECMAScript 5 methods that can be faithfully emulated with a legacy
368 JavaScript engine. @code{es5-sham.js} patches other ES5 methods as closely as
369 possible. Many of these shams are intended only to allow code to be written
370 to ES5 without causing run-time errors in older engines. In many cases, this
371 means that these shams cause many ES5 methods to silently fail.")
372 (license license:expat)))
374 (define-public js-filesaver
376 (name "js-filesaver")
380 (uri (string-append "https://github.com/eligrey/FileSaver.js/"
381 "archive/" version ".tar.gz"))
382 (file-name (string-append name "-" version))
385 "1rkhfqs5plaj628kzj7qgm5qahy4v7ihygifidqr6g6265mil97h"))))
386 (build-system minify-build-system)
389 (modify-phases %standard-phases
390 (add-after 'unpack 'fix-uglification
391 ;; Remove "export" keyword which prevents the file from being
392 ;; uglified by uglify-js. Moreover, that keyword is not present in
393 ;; the minified version of the library some projects are using,
395 ;; <https://github.com/jmoenig/Snap--Build-Your-Own-Blocks/blob/master/FileSaver.min.js>
397 (substitute* "src/FileSaver.js"
401 "https://eligrey.com/blog/saving-generated-files-on-the-client-side/")
402 (synopsis "HTML5 saveAs() FileSaver implementation")
403 (description "@file{FileSaver.js} implements the @code{saveAs()}
404 FileSaver interface in browsers that do not natively support it.
406 @file{FileSaver.js} is the solution to saving files on the
407 client-side, and is perfect for webapps that need to generate files,
408 or for saving sensitive information that shouldn't be sent to an
410 (license license:expat)))
419 (url "https://git.ghostscript.com/mujs.git")
421 (file-name (string-append name "-" version "-checkout"))
424 "15ml3rzjl44lqdb1yxipdh8bhh0rvk2g6w6sjv667q8xywijwqv8"))))
425 (build-system gnu-build-system)
427 '(#:phases (modify-phases %standard-phases
428 (delete 'configure)) ; no configure
429 #:make-flags (list (string-append "prefix=" (assoc-ref %outputs "out"))
430 (string-append "CC=gcc"))
431 #:tests? #f)) ; no tests
432 (home-page "https://artifex.com/mujs/")
433 (synopsis "JavaScript interpreter written in C")
434 (description "MuJS is a lightweight Javascript interpreter designed for
435 embedding in other software to extend them with scripting capabilities. MuJS
436 was designed with a focus on small size, correctness, and simplicity. It is
437 written in portable C and implements ECMAScript as specified by ECMA-262. The
438 interface for binding with native code is designed to be as simple as possible
439 to use, and is very similar to Lua. There is no need to interact with byzantine
440 C++ template mechanisms, or worry about marking and unmarking garbage collection
441 roots, or wrestle with obscure build systems.")
442 (license license:isc)))