projects/guix·blob librewolf-updates · refs

1294 lines · 55.0 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2017 Arun Isaac <[email protected]>
3;;; Copyright © 2017, 2019, 2020, 2022, 2023, 2026 Ricardo Wurmus <[email protected]>
4;;; Copyright © 2017, 2018, 2020, 2021 Tobias Geerinckx-Rice <[email protected]>
5;;; Copyright © 2017-2020, 2022-2024 Efraim Flashner <[email protected]>
6;;; Copyright © 2018 Nicolas Goaziou <[email protected]>
7;;; Copyright © 2021 Pierre Neidhardt <[email protected]>
8;;; Copyright © 2021 Maxim Cournoyer <[email protected]>
9;;; Copyright © 2022 Frank Pursel <[email protected]>
10;;; Copyright © 2023 Zheng Junjie <[email protected]>
11;;; Copyright © 2025 Ashvith Shetty <[email protected]>
12;;;
13;;; This file is part of GNU Guix.
14;;;
15;;; GNU Guix is free software; you can redistribute it and/or modify it
16;;; under the terms of the GNU General Public License as published by
17;;; the Free Software Foundation; either version 3 of the License, or (at
18;;; your option) any later version.
19;;;
20;;; GNU Guix is distributed in the hope that it will be useful, but
21;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23;;; GNU General Public License for more details.
24;;;
25;;; You should have received a copy of the GNU General Public License
26;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27
28(define-module (gnu packages javascript)
29 #:use-module ((guix licenses) #:prefix license:)
30 #:use-module (gnu packages)
31 #:use-module (gnu packages base)
32 #:use-module (gnu packages bash)
33 #:use-module (gnu packages c)
34 #:use-module (gnu packages compression)
35 #:use-module (gnu packages java)
36 #:use-module (gnu packages node)
37 #:use-module (gnu packages readline)
38 #:use-module (gnu packages uglifyjs)
39 #:use-module (gnu packages web)
40 #:use-module (guix gexp)
41 #:use-module (guix packages)
42 #:use-module (guix download)
43 #:use-module (guix git-download)
44 #:use-module (guix build-system ant)
45 #:use-module (guix build-system cmake)
46 #:use-module (guix build-system gnu)
47 #:use-module (guix build-system minify)
48 #:use-module (guix build-system trivial)
49 #:use-module (guix utils))
50
51(define-public cjson
52 (package
53 (name "cjson")
54 (version "1.7.18")
55 (source (origin
56 (method git-fetch)
57 (uri (git-reference
58 (url "https://github.com/DaveGamble/cJSON")
59 (commit (string-append "v" version))))
60 (file-name (git-file-name name version))
61 (sha256
62 (base32 "08p37q4i3za3dgz7wynma1fh8y4rq7pyzyjzcda710nxrmsm1pyv"))))
63 (build-system cmake-build-system)
64 (arguments
65 `(#:configure-flags '("-DENABLE_CJSON_UTILS=On")))
66 (home-page "https://github.com/DaveGamble/cJSON")
67 (synopsis "JSON parser written in ANSI C")
68 (description "This library provides a portable embeddable JSON parser.")
69 (license license:expat)))
70
71(define-public js-context-menu
72 (package
73 (name "js-context-menu")
74 (version "0.6.1")
75 (source
76 (origin
77 (method git-fetch)
78 (uri (git-reference
79 (url "https://github.com/zorkow/context-menu")
80 (commit (string-append "v" version))))
81 (file-name (git-file-name name version))
82 (sha256
83 (base32
84 "1q063l6477z285j6h5wvccp6iswvlp0jmb96sgk32sh0lf7nhknh"))))
85 (build-system trivial-build-system)
86 (arguments
87 `(#:modules ((guix build utils))
88 #:builder
89 (begin
90 (use-modules (guix build utils))
91 (chdir (assoc-ref %build-inputs "source"))
92 (let ((target (string-append %output "/share/javascript/context-menu")))
93 (apply invoke (search-input-file %build-inputs "/bin/esbuild")
94 "--bundle"
95 "--tsconfig=tsconfig.json"
96 (string-append "--outdir=" target)
97 (find-files "ts" "\\.ts$"))))))
98 (native-inputs
99 (list esbuild))
100 (home-page "https://github.com/zorkow/context-menu")
101 (synopsis "Generic context menu")
102 (description "This package provides a reimplementation of the MathJax
103context menu in TypeScript.")
104 (license license:asl2.0)))
105
106(define-public font-mathjax
107 (package
108 (name "font-mathjax")
109 (version "2.7.2")
110 (source
111 (origin
112 (method git-fetch)
113 (uri (git-reference
114 (url "https://github.com/mathjax/MathJax")
115 (commit version)))
116 (file-name (git-file-name name version))
117 (sha256
118 (base32
119 "127j12g7v2hx6k7r00b8cp49s7nkrwhxy6l8p03pw34xpxbgbimm"))))
120 (build-system trivial-build-system)
121 (arguments
122 `(#:modules ((guix build utils))
123 #:builder
124 (begin
125 (use-modules (guix build utils)
126 (ice-9 match))
127 (let ((install-directory (string-append %output "/share/fonts/mathjax")))
128 (mkdir-p install-directory)
129 (copy-recursively (string-append (assoc-ref %build-inputs "source")
130 "/fonts")
131 install-directory)))))
132 (home-page "https://www.mathjax.org/")
133 (synopsis "Fonts for MathJax")
134 (description "This package contains the fonts required for MathJax.")
135 (license license:asl2.0)))
136
137(define-public js-mathjax
138 (package
139 (inherit font-mathjax)
140 (name "js-mathjax")
141 (arguments
142 `(#:modules ((guix build utils))
143 #:builder
144 (begin
145 (use-modules (guix build utils)
146 (ice-9 match)
147 (ice-9 popen)
148 (ice-9 regex))
149 (set-path-environment-variable
150 "PATH" '("bin") (map (match-lambda
151 ((_ . input)
152 input))
153 %build-inputs))
154 (set-path-environment-variable
155 "GUIX_LOCPATH" '("lib/locale")
156 (list (assoc-ref %build-inputs "glibc-utf8-locales")))
157 (setenv "LANG" "en_US.UTF-8")
158 (let ((install-directory (string-append %output "/share/javascript/mathjax")))
159 (copy-recursively (string-append (assoc-ref %build-inputs "source") "/unpacked")
160 "MathJax-unpacked")
161 (mkdir-p install-directory)
162 (symlink (string-append (assoc-ref %build-inputs "font-mathjax")
163 "/share/fonts/mathjax")
164 (string-append install-directory "/fonts"))
165
166 (for-each
167 (lambda (file)
168 (let ((installed (string-append install-directory
169 ;; remove prefix "./MathJax-unpacked"
170 (string-drop file 18))))
171 (format #t "~a -> ~a~%" file installed)
172 (cond
173 ((string-match "\\.js$" file)
174 (mkdir-p (dirname installed))
175 (let ((minified (open-pipe* OPEN_READ "uglifyjs" file)))
176 (call-with-output-file installed
177 (lambda (port)
178 (dump-port minified port)))
179
180 (let ((exit (close-pipe minified)))
181 (unless (zero? exit)
182 (error "dear, uglifyjs failed" exit)))))
183 (else
184 (install-file file (dirname installed))))))
185 (find-files "."))
186
187 #t))))
188 (native-inputs
189 `(("font-mathjax" ,font-mathjax)
190 ("glibc-utf8-locales" ,(libc-utf8-locales-for-target))
191 ("uglifyjs" ,node-uglify-js)
192 ,@(package-native-inputs font-mathjax)))
193 (synopsis "JavaScript display engine for LaTeX, MathML, and AsciiMath")
194 (description "MathJax is a JavaScript display engine for LaTeX, MathML,
195and AsciiMath notation that works in all modern browsers. It requires no
196plugins or software to be installed on the browser. So the page author can
197write web documents that include mathematics and be confident that readers will
198be able to view it naturally and easily.")))
199
200(define-public js-mathjax-3
201 (package
202 (name "js-mathjax")
203 (version "3.2.0")
204 (source
205 (origin
206 (method git-fetch)
207 (uri (git-reference
208 (url "https://github.com/mathjax/MathJax-src")
209 (commit version)))
210 (file-name (git-file-name name version))
211 (sha256
212 (base32
213 "05lm6nw7rzpcc5yz7xsjxi4id9369vvnrksx82nglxrqrpws97wx"))
214 (patches (search-patches "mathjax-disable-webpack.patch"
215 "mathjax-no-a11y.patch"))))
216 (build-system gnu-build-system)
217 (arguments
218 `(#:phases
219 (modify-phases %standard-phases
220 (add-after 'unpack 'prepare-sources
221 (lambda* (#:key inputs #:allow-other-keys)
222 ;; All a11y components depend on speech-rule-engine, which cannot be
223 ;; built from source. Since this only affects accessibility, remove them.
224 (delete-file-recursively "ts/a11y")
225 (delete-file-recursively "components/src/a11y")
226 (delete-file-recursively "components/src/sre")
227 (delete-file-recursively "components/src/node-main")
228
229 ;; Copy sources of dependencies, so we can create symlinks.
230 (mkdir-p "node_modules")
231 (with-directory-excursion "node_modules"
232 (for-each
233 (lambda (p)
234 (copy-recursively (assoc-ref inputs (string-append "node-" p)) p))
235 '("mj-context-menu" "mhchemparser")))
236
237 ;; Make sure esbuild can find imports. This way we don’t have to rewrite files.
238 (symlink "ts" "js")
239 (symlink "ts" "node_modules/mj-context-menu/js")))
240 (delete 'configure)
241 (replace 'build
242 (lambda* (#:key inputs outputs #:allow-other-keys)
243 (let ((esbuild (string-append (assoc-ref inputs "esbuild")
244 "/bin/esbuild"))
245 (node (string-append (assoc-ref inputs "node")
246 "/bin/node"))
247 (target (string-append (assoc-ref outputs "out")
248 "/share/javascript/mathjax/es5")))
249 ;; Preprocess files and generate lib/ subdirs.
250 (invoke node "components/bin/makeAll")
251 ;; Build components.
252 (apply
253 invoke
254 esbuild
255 "--bundle"
256 "--minify"
257 ;; esbuild cannot transpile some features to ES5, so use ES6 instead.
258 "--target=es6"
259 (string-append "--outdir=" target)
260 "--sourcemap"
261 "--outbase=components/src"
262 "--define:__dirname=\"/\""
263 ;; In the browser the global object is window, see
264 ;; https://developer.mozilla.org/en-US/docs/Glossary/Global_object
265 "--define:global=window"
266 ;; Find all component entry points, which have the same name as their
267 ;; parent directory.
268 (filter
269 (lambda (f)
270 (string=?
271 (basename (dirname f))
272 (string-drop-right (basename f) 3)))
273 (find-files "components/src" "\\.js$")))
274 ;; Move all .js files into their parent directory, where MathJax
275 ;; expects them.
276 (for-each
277 (lambda (f)
278 (rename-file f (string-append (dirname (dirname f)) "/" (basename f))))
279 (find-files target "\\.js(\\.map)?$"))
280 ;; Copy font files.
281 (copy-recursively
282 "ts/output/chtml/fonts/tex-woff-v2"
283 (string-append target "/output/chtml/fonts/woff-v2")))))
284 (delete 'check)
285 (delete 'install))))
286 (native-inputs
287 `(("esbuild" ,esbuild)
288 ("node" ,node-lts)
289 ("node-mj-context-menu"
290 ,(let ((name "context-menu")
291 (version "0.6.1"))
292 (origin
293 (method git-fetch)
294 (uri (git-reference
295 (url "https://github.com/zorkow/context-menu.git")
296 (commit (string-append "v" version))))
297 (file-name (git-file-name name version))
298 (sha256
299 (base32
300 "1q063l6477z285j6h5wvccp6iswvlp0jmb96sgk32sh0lf7nhknh")))))
301 ("node-mhchemparser"
302 ,(let ((name "mhchemparser")
303 ;; Version 4.1.1. There are no tags.
304 (version "b1bd0670df7e9bbd5a724ac642aa2664d6e500b3"))
305 (origin
306 (method git-fetch)
307 (uri (git-reference
308 (url "https://github.com/mhchem/mhchemParser.git")
309 (commit version)))
310 (file-name (git-file-name name version))
311 (sha256
312 (base32
313 "1g72kbxzf9f2igidpma3jwk28ln4bp3qhwspmhnm79baf3701dgv")))))))
314 (home-page "https://www.mathjax.org/")
315 (synopsis (package-synopsis js-mathjax))
316 (description (package-description js-mathjax))
317 (license license:asl2.0)))
318
319(define-public js-mathjax-4
320 (package
321 (name "js-mathjax")
322 (version "4.0.0")
323 (source
324 (origin
325 (method git-fetch)
326 (uri (git-reference
327 (url "https://github.com/mathjax/MathJax-src")
328 (commit version)))
329 (file-name (git-file-name name version))
330 (sha256
331 (base32
332 "1ak864p80bvsvmz5fb41snrb165zs5miy54h08lld005ph8pqgk0"))
333 (patches (search-patches "mathjax-4.0.0-disable-webpack.patch"
334 "mathjax-4.0.0-no-a11y.patch"))))
335 (build-system gnu-build-system)
336 (arguments
337 (list
338 #:phases
339 #~(modify-phases %standard-phases
340 (add-after 'unpack 'prepare-sources
341 (lambda* (#:key inputs #:allow-other-keys)
342 ;; All a11y components depend on speech-rule-engine, which cannot be
343 ;; built from source. Since this only affects accessibility, remove them.
344 (delete-file-recursively "ts/a11y/")
345 (delete-file-recursively "components/mjs/a11y")
346 (delete-file-recursively "components/mjs/sre")
347 (delete-file-recursively "components/mjs/node-main")
348
349 ;; Copy sources of dependencies, so we can create symlinks.
350 (mkdir-p "node_modules")
351 (let ((components (string-append (getcwd) "/components"))
352 (subdir "mathjax-newcm-font"))
353 (with-directory-excursion "node_modules"
354 (for-each
355 (lambda (p)
356 (copy-recursively (assoc-ref inputs (string-append "node-" p)) p))
357 '("mj-context-menu" "mhchemparser")))
358
359 ;; Unpack font files.
360 (mkdir-p subdir)
361 (invoke "tar" "-xf" (assoc-ref inputs "node-mathjax-newcm-font")
362 "-C" subdir
363 "--strip-components=1")
364 (substitute* (find-files subdir "\\.js$")
365 (("@mathjax/src/mjs/output/chtml/")
366 (string-append components "/mjs/output/chtml/lib/output/chtml/"))
367 (("@mathjax/src/mjs/output/svg/")
368 (string-append components "/mjs/output/svg/lib/output/svg/"))
369 (("@mathjax/src/mjs/output/common/")
370 (string-append components "/mjs/output/chtml/lib/output/common/"))
371 (("@mathjax/src/components/")
372 (string-append components "/"))
373 (("@mathjax/src/mjs/util/Options.js")
374 (string-append components "/mjs/core/lib/util/Options.js")))
375 (rename-file (string-append subdir "/mjs") "components/mjs/font"))
376
377 ;; Make sure esbuild can find imports. This way we don’t have to rewrite files.
378 (symlink "ts" "js")
379 (symlink "ts" "mjs")
380 (symlink "ts" "node_modules/mj-context-menu/js")
381 (substitute* "package.json"
382 (("@mathjax/src/") "./js/")
383 (("@mathjax/mathjax-newcm-font/mjs/") "./components/mjs/font/"))))
384 (delete 'configure)
385 (replace 'build
386 (lambda* (#:key inputs outputs #:allow-other-keys)
387 (let ((esbuild (string-append (assoc-ref inputs "esbuild")
388 "/bin/esbuild"))
389 (node (string-append (assoc-ref inputs "node")
390 "/bin/node"))
391 (npm (string-append (assoc-ref inputs "node")
392 "/bin/npm"))
393 (target (string-append #$output
394 "/share/javascript/mathjax")))
395 ;; Prepare fonts.
396 (invoke node "components/bin/makeAll" "--mjs" "components/mjs/font")
397 ;; Preprocess files and generate lib/ subdirs.
398 (invoke node "components/bin/makeAll" "--mjs" "components/mjs")
399 ;; Build components.
400 (apply
401 invoke
402 esbuild
403 "--bundle"
404 "--minify"
405 ;; esbuild cannot transpile some features to ES5, so use ES6 instead.
406 "--target=es6"
407 (string-append "--outdir=" target)
408 "--sourcemap"
409 "--outbase=components/mjs"
410 "--define:__dirname=\"/\""
411 ;; In the browser the global object is window, see
412 ;; https://developer.mozilla.org/en-US/docs/Glossary/Global_object
413 "--define:global=window"
414 ;; Find all component entry points, which have the same name as their
415 ;; parent directory.
416 (filter
417 (lambda (f)
418 (string=?
419 (basename (dirname f))
420 (string-drop-right (basename f) 3)))
421 (find-files "components/mjs" "\\.js$")))
422 ;; Move all .js files into their parent directory, where MathJax
423 ;; expects them.
424 (for-each
425 (lambda (f)
426 (rename-file f (string-append (dirname (dirname f)) "/" (basename f))))
427 (find-files target "\\.js(\\.map)?$"))
428
429 ;; Copy font files. These files contain character tables,
430 ;; which is why they are so large. The tools to generate
431 ;; these tables has not been released yet, so we install them
432 ;; as opaque data instead of building them from font
433 ;; definition files.
434 (install-file
435 "mathjax-newcm-font/chtml.js"
436 (string-append target "/font/"))
437 (install-file
438 "mathjax-newcm-font/tex-mml-chtml-mathjax-newcm.js"
439 (string-append target "/font/"))
440 (copy-recursively
441 "mathjax-newcm-font/chtml/woff2"
442 (string-append target "/font/chtml/woff2")))))
443 (delete 'check)
444 (delete 'install))))
445 (native-inputs
446 `(("esbuild" ,esbuild)
447 ("node" ,node-lts)
448 ;; There is no public source code repository for this component. See
449 ;; <https://github.com/mathjax/MathJax-src/issues/973>.
450 ("node-mathjax-newcm-font"
451 ,(origin
452 (method url-fetch)
453 (uri (string-append "https://registry.npmjs.org/@mathjax/"
454 "mathjax-newcm-font/-/mathjax-newcm-font-"
455 version ".tgz"))
456 (sha256
457 (base32
458 "0cklfhl2n5zy20cnik1ww068rk91bsvllx8bnrjhjbk1sz7yw63q"))))
459 ("node-mj-context-menu"
460 ,(let ((name "context-menu")
461 (version "0.9.1"))
462 (origin
463 (method git-fetch)
464 (uri (git-reference
465 (url "https://github.com/zorkow/context-menu.git")
466 (commit (string-append "v" version))))
467 (file-name (git-file-name name version))
468 (sha256
469 (base32
470 "03wdf8v99sxr91h4b21gaggf32h5l0h2jk0yw3wm6f6r1ildxdap")))))
471 ("node-mhchemparser"
472 ,(let ((name "mhchemparser")
473 ;; Version 4.2.1. There are no tags.
474 (commit "2159346e2bb45ec6beaf64b617e0e5a049b4d200")
475 (revision "0"))
476 (origin
477 (method git-fetch)
478 (uri (git-reference
479 (url "https://github.com/mhchem/mhchemParser.git")
480 (commit commit)))
481 (file-name (git-file-name name (git-version "4.2.1" revision commit)))
482 (sha256
483 (base32
484 "1xzzfrk5bl5cby77qm0bdsmzjmfxxzjrzdh0cw5f811r78js0cib")))))))
485 (home-page "https://www.mathjax.org/")
486 (synopsis (package-synopsis js-mathjax))
487 (description (package-description js-mathjax))
488 (license license:asl2.0)))
489
490(define-public js-mathjax-for-r-mathjaxr js-mathjax-4)
491
492(define-public js-commander
493 (package
494 (name "js-commander")
495 (version "6.2.1")
496 (source
497 (origin
498 (method git-fetch)
499 (uri (git-reference
500 (url "https://github.com/tj/commander.js")
501 (commit (string-append "v" version))))
502 (file-name (git-file-name name version))
503 (sha256
504 (base32
505 "126m25s6mxpxmdj4aw5awz06b47r8r798lcf1c5bnmmh39cik5i1"))))
506 (build-system trivial-build-system)
507 (arguments
508 `(#:modules ((guix build utils))
509 #:builder
510 (begin
511 (use-modules (guix build utils))
512 (chdir (assoc-ref %build-inputs "source"))
513 (let ((esbuild (search-input-file %build-inputs "/bin/esbuild"))
514 (target (string-append %output "/share/javascript/commander")))
515 (invoke esbuild
516 "--bundle"
517 "--minify"
518 "--tsconfig=tsconfig.json"
519 "--platform=node"
520 (string-append "--outfile=" target "/index.min.js")
521 "index.js")))))
522 (native-inputs
523 (list esbuild))
524 (home-page "https://github.com/tj/commander.js")
525 (synopsis "Library for node.js command-line interfaces")
526 (description "Commander.js aims to be the complete solution for node.js
527command-line interfaces.")
528 (license license:expat)))
529
530(define-public js-xmldom-sre
531 ;; This commit corresponds to the untagged release 0.1.32
532 (let ((commit "3c79325bc2c9e5d27e3ba44b680fa8c5dd6a381d")
533 (revision "1"))
534 (package
535 (name "js-xmldom-sre")
536 (version "0.1.32")
537 (source
538 (origin
539 (method git-fetch)
540 (uri (git-reference
541 (url "https://github.com/zorkow/xmldom/")
542 (commit commit)))
543 (file-name (git-file-name name version))
544 (sha256
545 (base32
546 "0a88v0id3mjflpvjqhv8a28br0xvaaszxbf7alg6pxfbnkb69yyq"))))
547 (build-system trivial-build-system)
548 (arguments
549 `(#:modules ((guix build utils))
550 #:builder
551 (begin
552 (use-modules (guix build utils))
553 (chdir (assoc-ref %build-inputs "source"))
554 (let ((esbuild (search-input-file %build-inputs "/bin/esbuild"))
555 (target (string-append %output "/share/javascript/xmldom-sre")))
556 (invoke esbuild
557 "--bundle"
558 "--minify"
559 "--platform=node"
560 (string-append "--outfile=" target "/dom-parser.min.js")
561 "dom-parser.js")))))
562 (native-inputs
563 (list esbuild))
564 (home-page "https://github.com/zorkow/xmldom/")
565 (synopsis "DOM parser and XML serializer")
566 (description "This is a fork of the xmldom library. It allows the use
567of wicked-good-xpath together with xmldom.")
568 ;; One of these licenses may be selected.
569 (license (list license:expat
570 license:lgpl2.0)))))
571
572(define-public js-respond
573 (package
574 (name "js-respond")
575 (version "1.4.2")
576 (source (origin
577 (method git-fetch)
578 (uri (git-reference
579 (url "https://github.com/scottjehl/Respond")
580 (commit version)))
581 (file-name (git-file-name name version))
582 (sha256
583 (base32
584 "00xid731rirc7sdy1gc8qal3v9g0agr2qx15hm4x97l1lcbylyn2"))))
585 (build-system minify-build-system)
586 (arguments
587 `(#:javascript-files '("src/matchmedia.addListener.js"
588 "src/matchmedia.polyfill.js"
589 "src/respond.js")))
590 (home-page "https://github.com/scottjehl/Respond")
591 (synopsis "Polyfill for min/max-width CSS3 Media Queries")
592 (description "The goal of this script is to provide a fast and lightweight
593script to enable responsive web designs in browsers that don't support CSS3
594Media Queries.")
595 (license license:expat)))
596
597(define-public js-html5shiv
598 (package
599 (name "js-html5shiv")
600 (version "3.7.3")
601 (source (origin
602 (method git-fetch)
603 (uri (git-reference
604 (url "https://github.com/aFarkas/html5shiv")
605 (commit version)))
606 (file-name (git-file-name name version))
607 (sha256
608 (base32
609 "0y1c5nyq0brl9fjdihhax33vks4s1ij9iv113879sg3zflmgqpd0"))))
610 (build-system minify-build-system)
611 (home-page "https://github.com/aFarkas/html5shiv")
612 (synopsis "Enable HTML5 sectioning elements in legacy browsers")
613 (description "The HTML5 Shiv enables use of HTML5 sectioning elements in
614legacy Internet Explorer and provides basic HTML5 styling for Internet
615Explorer 6-9, Safari 4.x (and iPhone 3.x), and Firefox 3.x.")
616 ;; From the file "MIT and GPL2 licenses.md":
617 ;;
618 ;; This software is licensed under a dual license system (MIT or GPL
619 ;; version 2). This means you are free to choose with which of both
620 ;; licenses (MIT or GPL version 2) you want to use this library.
621 (license (list license:expat license:gpl2))))
622
623(define-public js-json2
624 (let ((commit "031b1d9e6971bd4c433ca85e216cc853f5a867bd")
625 (revision "1"))
626 (package
627 (name "js-json2")
628 (version (string-append "2016-10-28." revision "-" (string-take commit 7)))
629 (source (origin
630 (method git-fetch)
631 (uri (git-reference
632 (url "https://github.com/douglascrockford/JSON-js")
633 (commit commit)))
634 (file-name (string-append name "-" version "-checkout"))
635 (sha256
636 (base32
637 "1fvb6b2y5sd3sqdgcj683sdxcbxdii34q0ysc9wg0dq1sy81l11v"))))
638 (build-system minify-build-system)
639 (arguments
640 `(#:javascript-files '("json2.js"
641 "json_parse.js"
642 "json_parse_state.js"
643 "cycle.js")))
644 (home-page "https://github.com/douglascrockford/JSON-js")
645 (synopsis "JSON encoders and decoders")
646 (description "The files in this collection implement JSON
647encoders/decoders in JavaScript.
648
649@code{json2.js}: This file creates a JSON property in the global object, if
650there isn't already one, setting its value to an object containing a stringify
651method and a parse method. The @code{parse} method uses the @code{eval}
652method to do the parsing, guarding it with several regular expressions to
653defend against accidental code execution hazards. On current browsers, this
654file does nothing, preferring the built-in JSON object.
655
656@code{json_parse.js}: This file contains an alternative JSON @code{parse}
657function that uses recursive descent instead of @code{eval}.
658
659@code{json_parse_state.js}: This files contains an alternative JSON
660@code{parse} function that uses a state machine instead of @code{eval}.
661
662@code{cycle.js}: This file contains two functions, @code{JSON.decycle} and
663@code{JSON.retrocycle}, which make it possible to encode cyclical structures
664and DAGs in JSON, and to then recover them. This is a capability that is not
665provided by ES5. @code{JSONPath} is used to represent the links.")
666 (license license:public-domain))))
667
668(define (make-js-lunr-lang lang-name abbrev)
669 (package
670 (name (string-append "js-lunr-" abbrev))
671 (version "1.13.0")
672 (source
673 (origin
674 (method git-fetch)
675 (uri (git-reference
676 (url "https://github.com/MihaiValentin/lunr-languages")
677 (commit version)))
678 (file-name (git-file-name name version))
679 (sha256
680 (base32 "03q1awcg5plxdzxg89cd4x8lvnjfba541kbx59q2c6ly7dh4pyv6"))))
681 (build-system minify-build-system)
682 (arguments
683 (list
684 #:javascript-files
685 #~(list #$(string-append "lunr." abbrev ".js"))
686 #:phases
687 #~(modify-phases %standard-phases
688 (delete 'install-license-files))))
689 (home-page "https://github.com/MihaiValentin/lunr-languages")
690 (synopsis (string-append lang-name "stemmers and stopwords"))
691 (description
692 (format #f "This package provides ~a stemmers and stopwords for the Lunr \
693Javascript library."
694 lang-name))
695 (license license:expat)))
696
697(define-public js-lunr-ar (make-js-lunr-lang "Arabic" "ar"))
698(define-public js-lunr-da (make-js-lunr-lang "Danish" "da"))
699(define-public js-lunr-de (make-js-lunr-lang "German" "de"))
700(define-public js-lunr-el (make-js-lunr-lang "Greek" "el"))
701(define-public js-lunr-es (make-js-lunr-lang "Spanish" "es"))
702(define-public js-lunr-fi (make-js-lunr-lang "Finnish" "fi"))
703(define-public js-lunr-fr (make-js-lunr-lang "French" "fr"))
704(define-public js-lunr-he (make-js-lunr-lang "Hebrew" "he"))
705(define-public js-lunr-hi (make-js-lunr-lang "Hindi" "hi"))
706(define-public js-lunr-hu (make-js-lunr-lang "Hungarian" "hu"))
707(define-public js-lunr-hy (make-js-lunr-lang "Armenian" "hy"))
708(define-public js-lunr-it (make-js-lunr-lang "Italian" "it"))
709(define-public js-lunr-ja (make-js-lunr-lang "Japanese" "ja"))
710(define-public js-lunr-kn (make-js-lunr-lang "Kannada" "kn"))
711(define-public js-lunr-ko (make-js-lunr-lang "Korean" "ko"))
712(define-public js-lunr-nl (make-js-lunr-lang "Dutch" "nl"))
713(define-public js-lunr-no (make-js-lunr-lang "Norwegian" "no"))
714(define-public js-lunr-pt (make-js-lunr-lang "Portuguese" "pt"))
715(define-public js-lunr-ro (make-js-lunr-lang "Romanian" "ro"))
716(define-public js-lunr-ru (make-js-lunr-lang "Russian" "ru"))
717(define-public js-lunr-sa (make-js-lunr-lang "Sanskrit" "sa"))
718(define-public js-lunr-sv (make-js-lunr-lang "Swedish" "sv"))
719(define-public js-lunr-ta (make-js-lunr-lang "Tamil" "ta"))
720(define-public js-lunr-te (make-js-lunr-lang "Telugu" "te"))
721(define-public js-lunr-th (make-js-lunr-lang "Thai" "th"))
722(define-public js-lunr-tr (make-js-lunr-lang "Turkish" "tr"))
723(define-public js-lunr-vi (make-js-lunr-lang "Vietnamese" "vi"))
724(define-public js-lunr-zh (make-js-lunr-lang "Chinese" "zh"))
725
726(define-public js-lunr-multi (make-js-lunr-lang "Multilanguages" "multi"))
727(define-public js-lunr-stemmer-support
728 (let ((pkg (make-js-lunr-lang "" "stemmer.support")))
729 (package/inherit pkg
730 (name "js-lunr-stemmer-support")
731 (synopsis "Stemmer support for Lunr")
732 (description
733 "This package provides stemmer support for the Lunr Javascript
734library."))))
735
736(define-public js-strftime
737 (package
738 (name "js-strftime")
739 (version "0.10.0")
740 (source (origin
741 (method git-fetch)
742 (uri (git-reference
743 (url"https://github.com/samsonjs/strftime")
744 (commit (string-append "v" version))))
745 (file-name (git-file-name name version))
746 (sha256
747 (base32
748 "131nmlivazwxyba25kh9lda99749fq4xsyin6lzfalaaydviby4p"))))
749 (build-system minify-build-system)
750 (arguments
751 `(#:javascript-files '("strftime.js")))
752 (home-page "https://github.com/samsonjs/strftime")
753 (synopsis "Implementation of strftime to JavaScript")
754 (description "This is an implementation of the @code{strftime} procedure
755for JavaScript. It works in (at least) node.js and browsers. It supports
756localization and timezones. Most standard specifiers from C are supported as
757well as some other extensions from Ruby.")
758 (license license:expat)))
759
760(define-public js-highlight
761 (package
762 (name "js-highlight")
763 (version "9.12.0")
764 (source (origin
765 (method git-fetch)
766 (uri (git-reference
767 (url "https://github.com/isagalaev/highlight.js")
768 (commit version)))
769 (file-name (git-file-name name version))
770 (sha256
771 (base32
772 "12qz22qjpd6svj58pwgcwg2x2rzhihfdrxg6lgj39nfpaln6dris"))))
773 (build-system minify-build-system)
774 (arguments
775 `(#:javascript-files '("src/highlight.js")))
776 (home-page "https://github.com/isagalaev/highlight.js")
777 (synopsis "Syntax highlighting for JavaScript")
778 (description "Highlight.js is a syntax highlighter written in JavaScript.
779It works in the browser as well as on the server. It works with pretty much
780any markup, doesn’t depend on any framework and has automatic language
781detection.")
782 (license license:bsd-3)))
783
784(define-public js-datatables
785 (package
786 (name "js-datatables")
787 (version "1.10.19")
788 (source (origin
789 (method url-fetch)
790 (uri (string-append "https://datatables.net/releases/DataTables-"
791 version ".zip"))
792 (sha256
793 (base32
794 "0cff8a1g7pjwbjdqq0yzqd963ar7pfi4splmm6rwdzganr77rkhb"))))
795 (build-system minify-build-system)
796 (arguments
797 `(#:javascript-files '("media/js/dataTables.bootstrap.js"
798 "media/js/jquery.dataTables.js")))
799 (native-inputs
800 (list unzip))
801 (home-page "https://datatables.net")
802 (synopsis "DataTables plug-in for jQuery")
803 (description "DataTables is a table enhancing plug-in for the jQuery
804Javascript library, adding sorting, paging and filtering abilities to plain
805HTML tables with minimal effort.")
806 (license license:expat)))
807
808(define-public js-datatables-1.9
809 (package
810 (inherit js-datatables)
811 (name "js-datatables")
812 (version "1.9.4")
813 (source (origin
814 (method url-fetch)
815 (uri (string-append "https://datatables.net/releases/DataTables-"
816 version ".zip"))
817 (sha256
818 (base32
819 "0yd6548cbpb4hlpwybjp93b9m084n5rba6v1x5n83y0dvlxcd06g"))))
820 (arguments
821 (list #:javascript-files '(list "media/js/jquery.dataTables.js")))))
822
823(define-public js-requirejs
824 (package
825 (name "js-requirejs")
826 (version "2.3.6")
827 (source (origin
828 (method git-fetch)
829 (uri (git-reference
830 (url "https://github.com/requirejs/requirejs")
831 (commit version)))
832 (file-name (git-file-name name version))
833 (sha256
834 (base32
835 "0cvd5y2mb3h6yil3niqn3gjqrzixdsxcz4rvc2f0hg4kzp5y0w86"))))
836 (build-system minify-build-system)
837 (arguments `(#:javascript-files '("require.js")))
838 (home-page "https://github.com/requirejs/requirejs/")
839 (synopsis "File and module loader for JavaScript")
840 (description "RequireJS loads plain JavaScript files as well as more
841defined modules. It is optimized for in-browser use, including in a Web
842Worker, but it can be used in other JavaScript environments.")
843 (license license:expat)))
844
845(define-public js-selectize
846 (package
847 (name "js-selectize")
848 (version "0.12.6")
849 (source (origin
850 (method git-fetch)
851 (uri (git-reference
852 (url "https://github.com/selectize/selectize.js")
853 (commit (string-append "v" version))))
854 (file-name (git-file-name name version))
855 (sha256
856 (base32
857 "15gichl8wi6yxag2ps723nxrgyan15976dzsnvw9h9py8sbyyzjn"))))
858 (build-system minify-build-system)
859 ;; We use the standalone file instead of src/selectize.js because the
860 ;; former includes the source code for MicroEvent and other modules that
861 ;; Selectize refers to.
862 (arguments `(#:javascript-files '("dist/js/standalone/selectize.js")))
863 (home-page "https://selectize.github.io/selectize.js/")
864 (synopsis "Hybrid widget between a textbox and <select> box")
865 (description "Selectize is the hybrid of a textbox and @code{<select>}
866box. It's jQuery based and it has autocomplete and native-feeling keyboard
867navigation; it is useful for tagging, contact lists, etc.")
868 (license license:asl2.0)))
869
870(define-public js-es5-shim
871 (package
872 (name "js-es5-shim")
873 (version "4.5.13")
874 (source (origin
875 (method git-fetch)
876 (uri (git-reference
877 (url "https://github.com/es-shims/es5-shim")
878 (commit (string-append "v" version))))
879 (file-name (git-file-name name version))
880 (sha256
881 (base32
882 "142w384fbyllq4yggv173g82lw3wix4jqcg6hkhx1ymq89vvnpmh"))))
883 (build-system minify-build-system)
884 (arguments `(#:javascript-files
885 '("es5-sham.js"
886 "es5-shim.js")))
887 (home-page "https://github.com/es-shims/es5-shim")
888 (synopsis "ECMAScript 5 compatibility shims for legacy JavaScript engines")
889 (description "@code{es5-shim.js} patches a JavaScript context to contain
890all ECMAScript 5 methods that can be faithfully emulated with a legacy
891JavaScript engine. @code{es5-sham.js} patches other ES5 methods as closely as
892possible. Many of these shams are intended only to allow code to be written
893to ES5 without causing run-time errors in older engines. In many cases, this
894means that these shams cause many ES5 methods to silently fail.")
895 (license license:expat)))
896
897(define-public js-filesaver
898 (package
899 (name "js-filesaver")
900 (version "1.3.8")
901 (source (origin
902 (method git-fetch)
903 (uri (git-reference
904 (url "https://github.com/eligrey/FileSaver.js")
905 (commit version)))
906 (file-name (git-file-name name version))
907 (sha256
908 (base32
909 "0gvqk0hnr8fig0n4da7vj7q6z31bcyv52916xz3rbmdj3pgpiv1d"))))
910 (build-system minify-build-system)
911 (arguments
912 `(#:phases
913 (modify-phases %standard-phases
914 (add-after 'unpack 'fix-uglification
915 ;; Remove "export" keyword. That keyword is not present in
916 ;; the minified version of the library some projects are using,
917 ;; e.g.,
918 ;; <https://github.com/jmoenig/Snap--Build-Your-Own-Blocks/blob/master/FileSaver.min.js>
919 (lambda _
920 (substitute* "src/FileSaver.js"
921 (("export ") ""))
922 #t))
923 (add-after 'install 'install-unminified-version
924 (lambda* (#:key outputs #:allow-other-keys)
925 (install-file "src/FileSaver.js"
926 (string-append (assoc-ref outputs "out")
927 "/share/javascript"))
928 #t)))))
929 (home-page
930 "https://eligrey.com/blog/saving-generated-files-on-the-client-side/")
931 (synopsis "HTML5 saveAs() FileSaver implementation")
932 (description "@file{FileSaver.js} implements the @code{saveAs()}
933FileSaver interface in browsers that do not natively support it.
934
935@file{FileSaver.js} is the solution to saving files on the
936client-side, and is perfect for webapps that need to generate files,
937or for saving sensitive information that shouldn't be sent to an
938external server.")
939 (license license:expat)))
940
941(define-public js-scianimator
942 (package
943 (name "js-scianimator")
944 (version "1.4")
945 (source (origin
946 (method git-fetch)
947 (uri (git-reference
948 (url "https://github.com/brentertz/scianimator.git")
949 (commit version)))
950 (file-name (git-file-name name version))
951 (sha256
952 (base32
953 "0b4r6z85gnsjagdchvf1pvrhylfiaidh701hna8jrm0l4kbb735x"))))
954 (build-system minify-build-system)
955 (arguments
956 '(#:javascript-files
957 (list "assets/js/jquery.scianimator.js")))
958 (home-page "https://github.com/brentertz/scianimator")
959 (synopsis "Scientific image animator plugin for jQuery")
960 (description "SciAnimator provides a simple yet powerful interface for
961animating a series of images.")
962 (license license:expat)))
963
964(define-public mujs
965 (package
966 (name "mujs")
967 (version "1.3.5")
968 (source
969 (origin
970 (method git-fetch)
971 (uri (git-reference
972 (url "https://github.com/ccxvii/mujs")
973 (commit version)))
974 (file-name (git-file-name name version))
975 (sha256
976 (base32 "1p90cb830li6y38m748s4kz2pkimxarbcaym3bwrxnk3jaqcf69q"))
977 (snippet
978 #~(begin
979 (use-modules (guix build utils))
980 (for-each delete-file
981 (list "astnames.h"
982 "opnames.h"
983 "one.c"))))))
984 (build-system gnu-build-system)
985 (arguments
986 (list
987 #:phases
988 #~(modify-phases %standard-phases
989 (delete 'configure) ; no configure script
990 (replace 'install
991 (lambda* (#:key (make-flags '()) #:allow-other-keys)
992 (apply invoke "make" "install-shared" make-flags))))
993 #:make-flags
994 #~(list (string-append "VERSION=" #$version)
995 (string-append "CC=" #$(cc-for-target))
996 (string-append "prefix=" #$output))
997 #:tests? #f)) ; no tests
998 (inputs
999 (list readline))
1000 (home-page "https://mujs.com/")
1001 (synopsis "JavaScript interpreter written in C")
1002 (description "MuJS is a lightweight Javascript interpreter designed for
1003embedding in other software to extend them with scripting capabilities. MuJS
1004was designed with a focus on small size, correctness, and simplicity. It is
1005written in portable C and implements ECMAScript as specified by ECMA-262. The
1006interface for binding with native code is designed to be as simple as possible
1007to use, and is very similar to Lua. There is no need to interact with byzantine
1008C++ template mechanisms, or worry about marking and unmarking garbage collection
1009roots, or wrestle with obscure build systems.")
1010 (license license:isc)))
1011
1012(define-public quickjs
1013 (package
1014 (name "quickjs")
1015 (version "2025-04-26")
1016 (source (origin
1017 (method url-fetch)
1018 (uri (string-append "https://bellard.org/quickjs/quickjs-"
1019 version ".tar.xz"))
1020 (sha256
1021 (base32
1022 "1gw39jazggpbrjmkkmkhsj2wn0mmaw6wb0gkh7vzcvhn4m60f81g"))
1023 (snippet
1024 #~(begin (use-modules (guix build utils))
1025 (for-each delete-file
1026 '("doc/quickjs.pdf"
1027 "doc/quickjs.html"))))))
1028 (build-system gnu-build-system)
1029 (arguments
1030 (list #:make-flags
1031 #~(list (string-append "PREFIX=" #$output)
1032 #$@(if (or (target-riscv64?)
1033 (target-ppc32?))
1034 '("LDFLAGS=-latomic")
1035 '()))
1036 #:phases #~(modify-phases %standard-phases
1037 (delete 'configure)
1038 (replace 'check
1039 (lambda* (#:key tests? #:allow-other-keys)
1040 (when tests?
1041 (invoke "make" "microbench")))))))
1042 (home-page "https://bellard.org/quickjs/")
1043 (synopsis "Small embeddable Javascript engine")
1044 (description "QuickJS supports the ES2023 specification including modules,
1045asynchronous generators, proxies, BigInt, BigDecimal, BigFloat and operator
1046overloading. It can compile Javascript sources to executables with no external
1047dependency. It includes a command line interpreter with contextual colorization
1048implemented in Javascript and a small built-in standard library with C library
1049wrappers.")
1050 (license license:expat)))
1051
1052(define-public test262-source
1053 (origin
1054 (method git-fetch)
1055 (uri (git-reference (url "https://github.com/tc39/test262")
1056 (commit "a5e69a1534de88d1eb29b76657d84c8541b72df7")))
1057 (file-name "test262")
1058 (sha256 (base32 "078a7nim0n9x36q7q8yvjwhk4ig29p25b03rr4l7g2b545cky66l"))
1059 (modules '((guix build utils)))
1060 (snippet #~(begin
1061 (for-each delete-file
1062 (list "ECMA TR-104.pdf" "docs/coverage.html"
1063 "docs/ES3_ES5_Changes.xlsx"))))))
1064
1065(define-public quickjs-ng
1066 (package
1067 (name "quickjs-ng")
1068 (version "0.11.0")
1069 (source
1070 (origin
1071 (method git-fetch)
1072 (uri (git-reference
1073 (url "https://github.com/quickjs-ng/quickjs")
1074 (commit (string-append "v" version))))
1075 (file-name (git-file-name name version))
1076 (sha256
1077 (base32 "0mfk32zvvh6c9a9plp6ad07888g795lhdmal3jyaclyn2k5iig9i"))
1078 ;; Remove these patches on next release as they will be included.
1079 (patches (search-patches
1080 "quickjs-ng-64-bits-precision-on-i686.patch"
1081 "quickjs-ng-fix-atomics.pause-on-32-bit.patch"))))
1082 (arguments
1083 (list
1084 #:configure-flags
1085 #~(list "-DBUILD_SHARED_LIBS:BOOL=TRUE"
1086 "-DQJS_BUILD_EXAMPLES:BOOL=FALSE"
1087 "-DQJS_BUILD_CLI_WITH_MIMALLOC:BOOL=TRUE"
1088 "-DQJS_ENABLE_ASAN:BOOL=FALSE"
1089 "-DQJS_ENABLE_UBSAN:BOOL=FALSE"
1090 "-DQJS_ENABLE_MSAN:BOOL=FALSE"
1091 "-DQJS_ENABLE_TSAN:BOOL=FALSE"
1092 ;; Only works with static build
1093 "-DQJS_BUILD_LIBC:BOOL=FALSE"
1094 #$@(if (or (target-riscv64?)
1095 (target-ppc32?))
1096 #~("-DCMAKE_EXE_LINKER_FLAGS=-latomic")
1097 #~()))
1098 #:phases
1099 #~(modify-phases %standard-phases
1100 (add-before 'configure 'prepare-tests
1101 (lambda* (#:key inputs #:allow-other-keys)
1102 (substitute* '("test262.conf" "test262-fast.conf"
1103 "test262_errors.txt")
1104 (("test262/")
1105 (string-append (assoc-ref inputs "test262") "/")))
1106 (substitute* "tests/test_std.js"
1107 (("/bin/sh")
1108 (which "sh")))
1109 (substitute* "Makefile"
1110 ((" \\$\\(QJS\\)")
1111 "")
1112 (("BUILD_DIR=build")
1113 "BUILD_DIR=../build"))))
1114 (replace 'check
1115 (lambda* (#:key tests? #:allow-other-keys)
1116 (when tests?
1117 (with-directory-excursion "../source"
1118 (invoke "make" "test")
1119 (invoke "make" "test262-fast")
1120 (invoke "make" "microbench")
1121 (invoke "../build/qjs" "-c" "examples/hello.js" "-o" "hello")
1122 (invoke "./hello")
1123 (invoke "../build/api-test"))))))))
1124 (build-system cmake-build-system)
1125 (native-inputs (list test262-source))
1126 (inputs (list mimalloc))
1127 (home-page "https://quickjs-ng.github.io/quickjs/")
1128 (synopsis "Small embeddable Javascript engine")
1129 (description
1130 "@code{quickjs-ng} supports the ES2023 specification including modules,
1131asynchronous generators, proxies, BigInt, BigDecimal, BigFloat and operator
1132overloading. It can compile Javascript sources to executables with no external
1133dependency. It includes a command line interpreter with contextual colorization
1134implemented in Javascript and a small built-in standard library with C library
1135wrappers.")
1136 ;; 3-clause BSD license for test262
1137 (license (list license:expat license:bsd-3))))
1138
1139(define-public duktape
1140 (package
1141 (name "duktape")
1142 (version "2.6.0")
1143 (source (origin
1144 (method url-fetch)
1145 (uri (string-append "https://duktape.org/duktape-"
1146 version ".tar.xz"))
1147 (sha256
1148 (base32
1149 "19szwxzvl2g65fw95ggvb8h0ma5bd9vvnnccn59hwnc4dida1x4n"))))
1150 (build-system gnu-build-system)
1151 (arguments
1152 (list #:tests? #f ; No tests.
1153 #:make-flags
1154 #~(list "-f" "Makefile.sharedlibrary"
1155 (string-append "INSTALL_PREFIX="
1156 ;; XXX Replace with #$output on core-updates.
1157 #$(if (%current-target-system)
1158 #~#$output
1159 #~%output))
1160 ;; XXX Unconditionally set to CC-FOR-TARGET on core-updates.
1161 #$@(if (%current-target-system)
1162 #~((string-append "CC=" #$(cc-for-target)))
1163 #~()))
1164 #:phases
1165 #~(modify-phases %standard-phases
1166 (delete 'configure)
1167 ;; At least another major GNU/Linux distribution carries their own
1168 ;; .pc file with this package.
1169 (add-after 'install 'install-pkg-config
1170 (lambda* (#:key outputs #:allow-other-keys)
1171 (let* ((out (assoc-ref outputs "out"))
1172 (pkg-config-dir (string-append out "/lib/pkgconfig")))
1173 (mkdir-p pkg-config-dir)
1174 (with-output-to-file (string-append pkg-config-dir "/duktape.pc")
1175 (lambda _
1176 (format #t "prefix=~@*~a~@
1177 libdir=${prefix}/lib~@
1178 includedir=${prefix}/include~@
1179
1180 Name: duktape~@
1181 Description: Embeddable Javascript engine~@
1182 Version: ~a~@
1183 Libs: -L${libdir} -lduktape~@
1184 Cflags: -I${includedir}~%"
1185 out #$version)))))))))
1186 (home-page "https://duktape.org/")
1187 (synopsis "Small embeddable Javascript engine")
1188 (description "Duktape is an embeddable Javascript engine, with a focus on
1189portability and compact footprint. Duktape is easy to integrate into a C/C++
1190project: add @file{duktape.c}, @file{duktape.h}, and @file{duk_config.h} to
1191your build, and use the Duktape API to call ECMAScript functions from C code
1192and vice versa.")
1193 (license license:expat)))
1194
1195(define-public rhino
1196 (package
1197 (name "rhino")
1198 (version "1.7.7.2")
1199 (source (origin
1200 (method git-fetch)
1201 (uri (git-reference
1202 (url "https://github.com/mozilla/rhino.git")
1203 (commit "935942527ff434b205e797df4185518e5369466e")))
1204 (file-name (git-file-name name version))
1205 (sha256
1206 (base32
1207 "09i4yr98hs6855fs7fhgmrpiwpr90lhxdv2bvfj97nn4rv1d7wl8"))
1208 (modules '((guix build utils)))
1209 (snippet '(begin
1210 ;; Remove benchmark testing
1211 (delete-file-recursively "testsrc/benchmarks")
1212 (delete-file-recursively
1213 "testsrc/org/mozilla/javascript/benchmarks")
1214 ;; Identify bundled jars
1215 (format #t "~%~a~%" "Sourced jars")
1216 (for-each (lambda (f)
1217 (format #t "~/Deleting: ~a~%" f)
1218 (delete-file f))
1219 (find-files "." "\\.jar$"))))))
1220 (build-system ant-build-system)
1221 (inputs (list bash-minimal))
1222 (native-inputs (list java-junit java-hamcrest-core java-snakeyaml))
1223 (arguments
1224 `(#:phases
1225 (modify-phases
1226 %standard-phases
1227 (add-after 'unpack 'remove-build-dates
1228 ;; Avoid embedding build date for reproducible builds
1229 (lambda _
1230 (substitute*
1231 "build.properties"
1232 (("..implementation.date.") ""))))
1233 (replace 'check
1234 (lambda* (#:key tests? inputs native-inputs
1235 #:allow-other-keys)
1236 (when tests?
1237 (setenv "ANT_OPTS" "-Doffline=true")
1238 (let ((junit-lib
1239 (assoc-ref inputs "java-junit"))
1240 (hamcrest-lib
1241 (assoc-ref inputs "java-hamcrest-core"))
1242 (snakeyaml-lib
1243 (assoc-ref inputs "java-snakeyaml")))
1244 (with-directory-excursion "testsrc"
1245 (substitute* "build.xml"
1246 (("<pathelement location=\"\\$\\{xbean.jar\\}\" */>" all)
1247 (string-append "<!-- " all " -->"))
1248 (("<pathelement location=\"\\$\\{jsr173.jar\\}\" */>" all)
1249 (string-append "<!-- " all " -->"))
1250 (("<pathelement path=\"\\$\\{coverage.classes.dir\\}\" */>"
1251 all)
1252 (string-append "<!-- " all " -->"))
1253 (("<pathelement path=\"lib/emma.jar\"/>" all)
1254 (string-append "<!-- " all " -->"))
1255 (("<pathelement path=\"lib/junit.jar\" ?/>")
1256 (string-append
1257 "<fileset dir=\"" junit-lib "\" includes=\"**/*.jar\"/>"))
1258 (("<pathelement path=\"lib/hamcrest.jar\" ?/>")
1259 (string-append "<fileset dir=\"" hamcrest-lib
1260 "\" includes=\"**/*.jar\"/>"))
1261 (("<pathelement path=\"lib/snakeyaml.jar\" ?/>")
1262 (string-append "<fileset dir=\"" snakeyaml-lib
1263 "\" includes=\"**/*.jar\"/>"))
1264 ;; Disabling instrumentation.
1265 (("(<target name=\"junit\" depends=\"junit-compile),.*"
1266 all pre)
1267 (string-append pre "\">"))))
1268 (invoke "ant" "junit")))))
1269 (replace 'install
1270 (lambda* (#:key inputs outputs #:allow-other-keys)
1271 (let* ((out (assoc-ref outputs "out"))
1272 (pkg+ver (string-append ,name ,version))
1273 (bin (string-append out "/bin"))
1274 (rhino (string-append bin "/rhino"))
1275 (man (string-append out "/share/man/man1")))
1276 (mkdir-p bin)
1277 (install-file "man/rhino.1" man)
1278 (install-file (string-append "build/" pkg+ver
1279 "/js.jar")
1280 (string-append out "/share/java"))
1281 (with-output-to-file rhino
1282 (lambda _
1283 (format #t "#!~a~%~a -jar ~a $@~%"
1284 (search-input-file inputs "/bin/bash")
1285 (search-input-file inputs "/bin/java")
1286 (string-append out "/share/java/js.jar"))))
1287 (chmod rhino #o755)))))))
1288 (home-page "https://mozilla.github.io/rhino")
1289 (synopsis "Javascript implemented in Java")
1290 (description
1291 "Rhino implements ECMAScript, also known as JavaScript, in Java as
1292specified in the fifth edition of ECMA-262.")
1293 (license license:mpl2.0)))
1294