projects/guix·blob perlssl · refs

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