projects/guix·blob version-0.14.0 · refs

401 lines · 17.0 KiB

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