gnu: perl-file-pushd: Update to 1.016.
[jackhill/guix/guix.git] / gnu / packages / javascript.scm
CommitLineData
a3d3b7a4
AI
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
b37b48f8 3;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
77217b43 4;;; Copyright © 2017 Tobias Geerinckx-Rice <me@tobias.gr>
89ba894e 5;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
11b43f99 6;;; Copyright © 2018 Nicolas Goaziou <mail@nicolasgoaziou.fr>
a3d3b7a4
AI
7;;;
8;;; This file is part of GNU Guix.
9;;;
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.
14;;;
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.
19;;;
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/>.
22
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)
a3d3b7a4
AI
28 #:use-module (gnu packages lisp)
29 #:use-module (guix packages)
30 #:use-module (guix download)
68ffb6c5 31 #:use-module (guix git-download)
89ba894e 32 #:use-module (guix build-system gnu)
68ffb6c5
RW
33 #:use-module (guix build-system trivial)
34 #:use-module (guix build-system minify))
a3d3b7a4 35
649c438c
LC
36(define-public font-mathjax
37 (package
38 (name "font-mathjax")
d6a7268b 39 (version "2.7.2")
649c438c
LC
40 (source
41 (origin
42 (method url-fetch)
43 (uri (string-append
44 "https://github.com/mathjax/MathJax/archive/"
45 version ".tar.gz"))
46 (file-name (string-append name "-" version ".tar.gz"))
47 (sha256
48 (base32
d6a7268b 49 "1r72di4pg4i6pfhcskkxqmf1158m81ki6a7lbw6nz4zh7xw23hy4"))))
649c438c
LC
50 (build-system trivial-build-system)
51 (arguments
52 `(#:modules ((guix build utils))
53 #:builder
54 (begin
55 (use-modules (guix build utils)
56 (ice-9 match))
57 (set-path-environment-variable
58 "PATH" '("bin") (map (match-lambda
59 ((_ . input)
60 input))
61 %build-inputs))
62 (let ((install-directory (string-append %output "/share/fonts/mathjax")))
63 (mkdir-p install-directory)
64 (zero? (system* "tar" "-C" install-directory "-xvf"
65 (assoc-ref %build-inputs "source")
77217b43
TGR
66 ,(string-append "MathJax-" version "/fonts")
67 "--strip" "2"))))))
649c438c
LC
68 (native-inputs
69 `(("gzip" ,gzip)
70 ("tar" ,tar)))
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)))
75
a3d3b7a4
AI
76(define-public js-mathjax
77 (package
78 (inherit font-mathjax)
79 (name "js-mathjax")
80 (arguments
81 `(#:modules ((guix build utils))
82 #:builder
83 (begin
84 (use-modules (guix build utils)
85 (ice-9 match)
86 (ice-9 popen)
87 (ice-9 regex))
88 (set-path-environment-variable
89 "PATH" '("bin") (map (match-lambda
90 ((_ . input)
91 input))
92 %build-inputs))
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 (system* "tar" "xvf" (assoc-ref %build-inputs "source")
77217b43
TGR
99 ,(string-append "MathJax-" (package-version font-mathjax)
100 "/unpacked")
101 "--strip" "2")
a3d3b7a4
AI
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"))
106
107 (for-each
108 (lambda (file)
109 (let ((installed (string-append install-directory
110 ;; remove prefix "."
111 (string-drop file 1))))
112 (format #t "~a -> ~a~%" file installed)
113 (cond
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
118 (lambda (port)
119 (dump-port minified port)))))
120 (else
121 (install-file file (dirname installed))))))
122 (find-files "."))))))
123 (native-inputs
124 `(("font-mathjax" ,font-mathjax)
125 ("glibc-utf8-locales" ,glibc-utf8-locales)
126 ("uglify-js" ,uglify-js)
127 ,@(package-native-inputs font-mathjax)))
128 (synopsis "JavaScript display engine for LaTeX, MathML, and AsciiMath")
129 (description "MathJax is a JavaScript display engine for LaTeX, MathML,
130and AsciiMath notation that works in all modern browsers. It requires no
131plugins or software to be installed on the browser. So the page author can
132write web documents that include mathematics and be confident that readers will
133be able to view it naturally and easily.")))
b37b48f8
RW
134
135(define-public js-respond
136 (package
137 (name "js-respond")
138 (version "1.4.2")
139 (source (origin
140 (method url-fetch)
141 (uri (string-append "https://github.com/scottjehl/Respond/"
142 "archive/" version ".tar.gz"))
143 (file-name (string-append name "-" version ".tar.gz"))
144 (sha256
145 (base32
146 "0ds1ya2a185jp93mdn07159c2x8zczwi960ykrawpp62bwk2n93d"))))
147 (build-system trivial-build-system)
148 (arguments
149 `(#:modules ((guix build utils))
150 #:builder
151 (begin
152 (use-modules (guix build utils)
153 (ice-9 match)
154 (ice-9 popen)
155 (srfi srfi-26))
156 (set-path-environment-variable
157 "PATH" '("bin") (map (match-lambda
158 ((_ . input)
159 input))
160 %build-inputs))
161 (let ((install-directory (string-append %output
162 "/share/javascript/respond/")))
163 (system* "tar" "xvf"
164 (assoc-ref %build-inputs "source")
165 "--strip" "1")
166 (mkdir-p install-directory)
167 (let* ((file "src/respond.js")
168 (installed (string-append install-directory "respond.min.js")))
169 (let ((minified (open-pipe* OPEN_READ "uglify-js" file)))
170 (call-with-output-file installed
171 (cut dump-port minified <>)))))
172 #t)))
173 (home-page "https://github.com/scottjehl/Respond")
174 (native-inputs
175 `(("uglify-js" ,uglify-js)
176 ("source" ,source)
177 ("gzip" ,gzip)
178 ("tar" ,tar)))
179 (synopsis "Polyfill for min/max-width CSS3 Media Queries")
180 (description "The goal of this script is to provide a fast and lightweight
181script to enable responsive web designs in browsers that don't support CSS3
182Media Queries.")
183 (license license:expat)))
ed69963b
RW
184
185(define-public js-html5shiv
186 (package
187 (name "js-html5shiv")
188 (version "3.7.3")
189 (source (origin
190 (method url-fetch)
191 (uri (string-append "https://github.com/aFarkas/html5shiv/"
192 "archive/" version ".tar.gz"))
193 (file-name (string-append name "-" version ".tar.gz"))
194 (sha256
195 (base32
196 "0inlbpxpqzdyi24lqagzf7l24zxg0y02xcpqs2h4npjscazzw7hg"))))
197 (build-system minify-build-system)
198 (home-page "https://github.com/aFarkas/html5shiv")
199 (synopsis "Enable HTML5 sectioning elements in legacy browsers")
200 (description "The HTML5 Shiv enables use of HTML5 sectioning elements in
201legacy Internet Explorer and provides basic HTML5 styling for Internet
202Explorer 6-9, Safari 4.x (and iPhone 3.x), and Firefox 3.x.")
203 ;; From the file "MIT and GPL2 licenses.md":
204 ;;
205 ;; This software is licensed under a dual license system (MIT or GPL
206 ;; version 2). This means you are free to choose with which of both
207 ;; licenses (MIT or GPL version 2) you want to use this library.
208 (license (list license:expat license:gpl2))))
68ffb6c5
RW
209
210(define-public js-json2
211 (let ((commit "031b1d9e6971bd4c433ca85e216cc853f5a867bd")
212 (revision "1"))
213 (package
214 (name "js-json2")
215 (version (string-append "2016-10-28." revision "-" (string-take commit 7)))
216 (source (origin
217 (method git-fetch)
218 (uri (git-reference
219 (url "https://github.com/douglascrockford/JSON-js.git")
220 (commit commit)))
221 (file-name (string-append name "-" version "-checkout"))
222 (sha256
223 (base32
224 "1fvb6b2y5sd3sqdgcj683sdxcbxdii34q0ysc9wg0dq1sy81l11v"))))
225 (build-system minify-build-system)
226 (arguments
227 `(#:javascript-files '("json2.js"
228 "json_parse.js"
229 "json_parse_state.js"
230 "cycle.js")))
231 (home-page "https://github.com/douglascrockford/JSON-js")
232 (synopsis "JSON encoders and decoders")
233 (description "The files in this collection implement JSON
234encoders/decoders in JavaScript.
235
236@code{json2.js}: This file creates a JSON property in the global object, if
237there isn't already one, setting its value to an object containing a stringify
238method and a parse method. The @code{parse} method uses the @code{eval}
239method to do the parsing, guarding it with several regular expressions to
240defend against accidental code execution hazards. On current browsers, this
241file does nothing, preferring the built-in JSON object.
242
243@code{json_parse.js}: This file contains an alternative JSON @code{parse}
244function that uses recursive descent instead of @code{eval}.
245
246@code{json_parse_state.js}: This files contains an alternative JSON
247@code{parse} function that uses a state machine instead of @code{eval}.
248
249@code{cycle.js}: This file contains two functions, @code{JSON.decycle} and
250@code{JSON.retrocycle}, which make it possible to encode cyclical structures
251and DAGs in JSON, and to then recover them. This is a capability that is not
252provided by ES5. @code{JSONPath} is used to represent the links.")
253 (license license:public-domain))))
3f48403a
RW
254
255(define-public js-strftime
256 (package
257 (name "js-strftime")
258 (version "0.10.0")
259 (source (origin
260 (method url-fetch)
261 (uri (string-append "https://github.com/samsonjs/strftime/"
262 "archive/v" version ".tar.gz"))
263 (file-name (string-append name "-" version ".tar.gz"))
264 (sha256
265 (base32
266 "1iya43w7y26y2dp9l4d40bhjc4scb5a9mng5ng5c8hsqr82f1375"))))
267 (build-system minify-build-system)
268 (arguments
269 `(#:javascript-files '("strftime.js")))
270 (home-page "https://github.com/samsonjs/strftime")
271 (synopsis "Implementation of strftime to JavaScript")
272 (description "This is an implementation of the @code{strftime} procedure
273for JavaScript. It works in (at least) node.js and browsers. It supports
274localization and timezones. Most standard specifiers from C are supported as
275well as some other extensions from Ruby.")
276 (license license:expat)))
a6bbb2a0
RW
277
278(define-public js-highlight
279 (package
280 (name "js-highlight")
281 (version "9.12.0")
282 (source (origin
283 (method url-fetch)
284 (uri (string-append "https://github.com/isagalaev/highlight.js/"
285 "archive/" version ".tar.gz"))
286 (file-name (string-append name "-" version ".tar.gz"))
287 (sha256
288 (base32
289 "1jjn9mj7fwq4zpr6is438bscf03b3q8jkj0k5c3fc6pkmjnhw939"))))
290 (build-system minify-build-system)
291 (arguments
292 `(#:javascript-files '("src/highlight.js")))
293 (home-page "https://github.com/isagalaev/highlight.js")
294 (synopsis "Syntax highlighting for JavaScript")
295 (description "Highlight.js is a syntax highlighter written in JavaScript.
296It works in the browser as well as on the server. It works with pretty much
297any markup, doesn’t depend on any framework and has automatic language
298detection.")
299 (license license:bsd-3)))
c4abc94d
RW
300
301(define-public js-datatables
302 (package
303 (name "js-datatables")
304 (version "1.10.15")
305 (source (origin
306 (method url-fetch)
307 (uri (string-append "https://datatables.net/releases/DataTables-"
308 version ".zip"))
309 (sha256
310 (base32
311 "1y9xqyqyz7x1ls3ska71pshl2hpiy3qnw1f7wygyslbhy4ssgf57"))))
312 (build-system minify-build-system)
313 (arguments
314 `(#:javascript-files '("media/js/dataTables.bootstrap.js"
315 "media/js/jquery.dataTables.js")))
316 (native-inputs
317 `(("unzip" ,unzip)))
318 (home-page "https://datatables.net")
319 (synopsis "DataTables plug-in for jQuery")
320 (description "DataTables is a table enhancing plug-in for the jQuery
321Javascript library, adding sorting, paging and filtering abilities to plain
322HTML tables with minimal effort.")
323 (license license:expat)))
4f65067b
RW
324
325(define-public js-selectize
326 (package
327 (name "js-selectize")
328 (version "0.12.4")
329 (source (origin
330 (method url-fetch)
331 (uri (string-append "https://github.com/selectize/selectize.js/"
332 "archive/v" version ".tar.gz"))
333 (file-name (string-append name "-" version ".tar.gz"))
334 (sha256
335 (base32
336 "0756p49aaz34mw2dx8k1gxf210mngfrri25vkba0j7wihd2af8gn"))))
337 (build-system minify-build-system)
338 (arguments `(#:javascript-files '("src/selectize.js")))
339 (home-page "http://selectize.github.io/selectize.js/")
340 (synopsis "Hybrid widget between a textbox and <select> box")
341 (description "Selectize is the hybrid of a textbox and @code{<select>}
342box. It's jQuery based and it has autocomplete and native-feeling keyboard
343navigation; it is useful for tagging, contact lists, etc.")
344 (license license:asl2.0)))
0b0aa76f
RW
345
346(define-public js-es5-shim
347 (package
348 (name "js-es5-shim")
349 (version "4.5.9")
350 (source (origin
351 (method url-fetch)
352 (uri (string-append "https://github.com/es-shims/es5-shim/"
353 "archive/v" version ".tar.gz"))
354 (file-name (string-append name "-" version ".tar.gz"))
355 (sha256
356 (base32
357 "0yfndyijz0ykddzprpvfjb2453gzpn528klmwycwbqc1bqd3m1hl"))))
358 (build-system minify-build-system)
359 (arguments `(#:javascript-files
360 '("es5-sham.js"
361 "es5-shim.js")))
362 (home-page "https://github.com/es-shims/es5-shim")
363 (synopsis "ECMAScript 5 compatibility shims for legacy JavaScript engines")
364 (description "@code{es5-shim.js} patches a JavaScript context to contain
365all ECMAScript 5 methods that can be faithfully emulated with a legacy
366JavaScript engine. @code{es5-sham.js} patches other ES5 methods as closely as
367possible. Many of these shams are intended only to allow code to be written
368to ES5 without causing run-time errors in older engines. In many cases, this
369means that these shams cause many ES5 methods to silently fail.")
370 (license license:expat)))
89ba894e 371
11b43f99
NG
372(define-public js-filesaver
373 (package
374 (name "js-filesaver")
375 (version "1.3.8")
376 (source (origin
377 (method url-fetch)
378 (uri (string-append "https://github.com/eligrey/FileSaver.js/"
379 "archive/" version ".tar.gz"))
380 (file-name (string-append name "-" version))
381 (sha256
382 (base32
383 "1rkhfqs5plaj628kzj7qgm5qahy4v7ihygifidqr6g6265mil97h"))))
384 (build-system minify-build-system)
385 (arguments
386 `(#:phases
387 (modify-phases %standard-phases
388 (add-after 'unpack 'fix-uglification
389 ;; Remove "export" keyword which prevents the file from being
390 ;; uglified by uglify-js. Moreover, that keyword is not present in
391 ;; the minified version of the library some projects are using,
392 ;; e.g.,
393 ;; <https://github.com/jmoenig/Snap--Build-Your-Own-Blocks/blob/master/FileSaver.min.js>
394 (lambda _
395 (substitute* "src/FileSaver.js"
396 (("export ") ""))
397 #t)))))
398 (home-page
399 "https://eligrey.com/blog/saving-generated-files-on-the-client-side/")
400 (synopsis "HTML5 saveAs() FileSaver implementation")
401 (description "@file{FileSaver.js} implements the @code{saveAs()}
402FileSaver interface in browsers that do not natively support it.
403
404@file{FileSaver.js} is the solution to saving files on the
405client-side, and is perfect for webapps that need to generate files,
406or for saving sensitive information that shouldn't be sent to an
407external server.")
408 (license license:expat)))
409
89ba894e
EF
410(define-public mujs
411 (package
412 (name "mujs")
66939d59 413 (version "1.0.3")
89ba894e
EF
414 (source (origin
415 (method git-fetch)
416 (uri (git-reference
94b779b6 417 (url "https://git.ghostscript.com/mujs.git")
89ba894e
EF
418 (commit version)))
419 (file-name (string-append name "-" version "-checkout"))
420 (sha256
421 (base32
66939d59 422 "15ml3rzjl44lqdb1yxipdh8bhh0rvk2g6w6sjv667q8xywijwqv8"))))
89ba894e
EF
423 (build-system gnu-build-system)
424 (arguments
425 '(#:phases (modify-phases %standard-phases
426 (delete 'configure)) ; no configure
427 #:make-flags (list (string-append "prefix=" (assoc-ref %outputs "out"))
428 (string-append "CC=gcc"))
429 #:tests? #f)) ; no tests
94b779b6 430 (home-page "https://artifex.com/mujs/")
89ba894e
EF
431 (synopsis "JavaScript interpreter written in C")
432 (description "MuJS is a lightweight Javascript interpreter designed for
433embedding in other software to extend them with scripting capabilities. MuJS
434was designed with a focus on small size, correctness, and simplicity. It is
435written in portable C and implements ECMAScript as specified by ECMA-262. The
436interface for binding with native code is designed to be as simple as possible
437to use, and is very similar to Lua. There is no need to interact with byzantine
438C++ template mechanisms, or worry about marking and unmarking garbage collection
439roots, or wrestle with obscure build systems.")
440 (license license:isc)))