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