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