projects/guix·blob javascript-team · refs

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