javascript.scm 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017 Arun Isaac <arunisaac@systemreboot.net>
  3. ;;; Copyright © 2017, 2019, 2020, 2022 Ricardo Wurmus <rekado@elephly.net>
  4. ;;; Copyright © 2017, 2018, 2020, 2021 Tobias Geerinckx-Rice <me@tobias.gr>
  5. ;;; Copyright © 2017, 2018, 2019, 2020 Efraim Flashner <efraim@flashner.co.il>
  6. ;;; Copyright © 2018 Nicolas Goaziou <mail@nicolasgoaziou.fr>
  7. ;;; Copyright © 2021 Pierre Neidhardt <mail@ambrevar.xyz>
  8. ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
  9. ;;; Copyright © 2022 Frank Pursel <frank.pursel@gmail.com>
  10. ;;;
  11. ;;; This file is part of GNU Guix.
  12. ;;;
  13. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  14. ;;; under the terms of the GNU General Public License as published by
  15. ;;; the Free Software Foundation; either version 3 of the License, or (at
  16. ;;; your option) any later version.
  17. ;;;
  18. ;;; GNU Guix is distributed in the hope that it will be useful, but
  19. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  20. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. ;;; GNU General Public License for more details.
  22. ;;;
  23. ;;; You should have received a copy of the GNU General Public License
  24. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  25. (define-module (gnu packages javascript)
  26. #:use-module ((guix licenses) #:prefix license:)
  27. #:use-module (gnu packages)
  28. #:use-module (gnu packages base)
  29. #:use-module (gnu packages bash)
  30. #:use-module (gnu packages compression)
  31. #:use-module (gnu packages java)
  32. #:use-module (gnu packages node)
  33. #:use-module (gnu packages readline)
  34. #:use-module (gnu packages uglifyjs)
  35. #:use-module (gnu packages web)
  36. #:use-module (guix packages)
  37. #:use-module (guix download)
  38. #:use-module (guix git-download)
  39. #:use-module (guix build-system ant)
  40. #:use-module (guix build-system cmake)
  41. #:use-module (guix build-system gnu)
  42. #:use-module (guix build-system minify)
  43. #:use-module (guix build-system trivial)
  44. #:use-module (guix utils))
  45. (define-public cjson
  46. (package
  47. (name "cjson")
  48. (version "1.7.15")
  49. (source (origin
  50. (method git-fetch)
  51. (uri (git-reference
  52. (url "https://github.com/DaveGamble/cJSON")
  53. (commit (string-append "v" version))))
  54. (file-name (git-file-name name version))
  55. (sha256
  56. (base32 "0lmq7sx09rmsirimbyvaaia44i134ppkp10cw1d2rygr76k9qwq2"))))
  57. (build-system cmake-build-system)
  58. (arguments
  59. `(#:configure-flags '("-DENABLE_CJSON_UTILS=On")))
  60. (home-page "https://github.com/DaveGamble/cJSON")
  61. (synopsis "JSON parser written in ANSI C")
  62. (description "This library provides a portable embeddable JSON parser.")
  63. (license license:expat)))
  64. (define-public js-context-menu
  65. (package
  66. (name "js-context-menu")
  67. (version "0.6.1")
  68. (source
  69. (origin
  70. (method git-fetch)
  71. (uri (git-reference
  72. (url "https://github.com/zorkow/context-menu")
  73. (commit (string-append "v" version))))
  74. (file-name (git-file-name name version))
  75. (sha256
  76. (base32
  77. "1q063l6477z285j6h5wvccp6iswvlp0jmb96sgk32sh0lf7nhknh"))))
  78. (build-system trivial-build-system)
  79. (arguments
  80. `(#:modules ((guix build utils))
  81. #:builder
  82. (begin
  83. (use-modules (guix build utils))
  84. (chdir (assoc-ref %build-inputs "source"))
  85. (let ((target (string-append %output "/share/javascript/context-menu")))
  86. (apply invoke (search-input-file %build-inputs "/bin/esbuild")
  87. "--bundle"
  88. "--tsconfig=tsconfig.json"
  89. (string-append "--outdir=" target)
  90. (find-files "ts" "\\.ts$"))))))
  91. (native-inputs
  92. (list esbuild))
  93. (home-page "https://github.com/zorkow/context-menu")
  94. (synopsis "Generic context menu")
  95. (description "This package provides a reimplementation of the MathJax
  96. context menu in TypeScript.")
  97. (license license:asl2.0)))
  98. (define-public font-mathjax
  99. (package
  100. (name "font-mathjax")
  101. (version "2.7.2")
  102. (source
  103. (origin
  104. (method git-fetch)
  105. (uri (git-reference
  106. (url "https://github.com/mathjax/MathJax")
  107. (commit version)))
  108. (file-name (git-file-name name version))
  109. (sha256
  110. (base32
  111. "127j12g7v2hx6k7r00b8cp49s7nkrwhxy6l8p03pw34xpxbgbimm"))))
  112. (build-system trivial-build-system)
  113. (arguments
  114. `(#:modules ((guix build utils))
  115. #:builder
  116. (begin
  117. (use-modules (guix build utils)
  118. (ice-9 match))
  119. (let ((install-directory (string-append %output "/share/fonts/mathjax")))
  120. (mkdir-p install-directory)
  121. (copy-recursively (string-append (assoc-ref %build-inputs "source")
  122. "/fonts")
  123. install-directory)))))
  124. (home-page "https://www.mathjax.org/")
  125. (synopsis "Fonts for MathJax")
  126. (description "This package contains the fonts required for MathJax.")
  127. (license license:asl2.0)))
  128. (define-public js-mathjax
  129. (package
  130. (inherit font-mathjax)
  131. (name "js-mathjax")
  132. (arguments
  133. `(#:modules ((guix build utils))
  134. #:builder
  135. (begin
  136. (use-modules (guix build utils)
  137. (ice-9 match)
  138. (ice-9 popen)
  139. (ice-9 regex))
  140. (set-path-environment-variable
  141. "PATH" '("bin") (map (match-lambda
  142. ((_ . input)
  143. input))
  144. %build-inputs))
  145. (set-path-environment-variable
  146. "GUIX_LOCPATH" '("lib/locale")
  147. (list (assoc-ref %build-inputs "glibc-utf8-locales")))
  148. (setenv "LANG" "en_US.UTF-8")
  149. (let ((install-directory (string-append %output "/share/javascript/mathjax")))
  150. (copy-recursively (string-append (assoc-ref %build-inputs "source") "/unpacked")
  151. "MathJax-unpacked")
  152. (mkdir-p install-directory)
  153. (symlink (string-append (assoc-ref %build-inputs "font-mathjax")
  154. "/share/fonts/mathjax")
  155. (string-append install-directory "/fonts"))
  156. (for-each
  157. (lambda (file)
  158. (let ((installed (string-append install-directory
  159. ;; remove prefix "./MathJax-unpacked"
  160. (string-drop file 18))))
  161. (format #t "~a -> ~a~%" file installed)
  162. (cond
  163. ((string-match "\\.js$" file)
  164. (mkdir-p (dirname installed))
  165. (let ((minified (open-pipe* OPEN_READ "uglifyjs" file)))
  166. (call-with-output-file installed
  167. (lambda (port)
  168. (dump-port minified port)))
  169. (let ((exit (close-pipe minified)))
  170. (unless (zero? exit)
  171. (error "dear, uglifyjs failed" exit)))))
  172. (else
  173. (install-file file (dirname installed))))))
  174. (find-files "."))
  175. #t))))
  176. (native-inputs
  177. `(("font-mathjax" ,font-mathjax)
  178. ("glibc-utf8-locales" ,glibc-utf8-locales)
  179. ("uglifyjs" ,node-uglify-js)
  180. ,@(package-native-inputs font-mathjax)))
  181. (synopsis "JavaScript display engine for LaTeX, MathML, and AsciiMath")
  182. (description "MathJax is a JavaScript display engine for LaTeX, MathML,
  183. and AsciiMath notation that works in all modern browsers. It requires no
  184. plugins or software to be installed on the browser. So the page author can
  185. write web documents that include mathematics and be confident that readers will
  186. be able to view it naturally and easily.")))
  187. (define-public js-mathjax-3
  188. (package
  189. (name "js-mathjax")
  190. (version "3.2.0")
  191. (source
  192. (origin
  193. (method git-fetch)
  194. (uri (git-reference
  195. (url "https://github.com/mathjax/MathJax-src")
  196. (commit version)))
  197. (file-name (git-file-name name version))
  198. (sha256
  199. (base32
  200. "05lm6nw7rzpcc5yz7xsjxi4id9369vvnrksx82nglxrqrpws97wx"))
  201. (patches (search-patches "mathjax-disable-webpack.patch"
  202. "mathjax-no-a11y.patch"))))
  203. (build-system gnu-build-system)
  204. (arguments
  205. `(#:phases
  206. (modify-phases %standard-phases
  207. (add-after 'unpack 'prepare-sources
  208. (lambda* (#:key inputs #:allow-other-keys)
  209. ;; All a11y components depend on speech-rule-engine, which cannot be
  210. ;; built from source. Since this only affects accessibility, remove them.
  211. (delete-file-recursively "ts/a11y")
  212. (delete-file-recursively "components/src/a11y")
  213. (delete-file-recursively "components/src/sre")
  214. (delete-file-recursively "components/src/node-main")
  215. ;; Copy sources of dependencies, so we can create symlinks.
  216. (mkdir-p "node_modules")
  217. (with-directory-excursion "node_modules"
  218. (for-each
  219. (lambda (p)
  220. (copy-recursively (assoc-ref inputs (string-append "node-" p)) p))
  221. '("mj-context-menu" "mhchemparser")))
  222. ;; Make sure esbuild can find imports. This way we don’t have to rewrite files.
  223. (symlink "ts" "js")
  224. (symlink "ts" "node_modules/mj-context-menu/js")))
  225. (delete 'configure)
  226. (replace 'build
  227. (lambda* (#:key inputs outputs #:allow-other-keys)
  228. (let ((esbuild (string-append (assoc-ref inputs "esbuild")
  229. "/bin/esbuild"))
  230. (node (string-append (assoc-ref inputs "node")
  231. "/bin/node"))
  232. (target (string-append (assoc-ref outputs "out")
  233. "/share/javascript/mathjax/es5")))
  234. ;; Preprocess files and generate lib/ subdirs.
  235. (invoke node "components/bin/makeAll")
  236. ;; Build components.
  237. (apply
  238. invoke
  239. esbuild
  240. "--bundle"
  241. "--minify"
  242. ;; esbuild cannot transpile some features to ES5, so use ES6 instead.
  243. "--target=es6"
  244. (string-append "--outdir=" target)
  245. "--sourcemap"
  246. "--outbase=components/src"
  247. "--define:__dirname=\"/\""
  248. ;; In the browser the global object is window, see
  249. ;; https://developer.mozilla.org/en-US/docs/Glossary/Global_object
  250. "--define:global=window"
  251. ;; Find all component entry points, which have the same name as their
  252. ;; parent directory.
  253. (filter
  254. (lambda (f)
  255. (string=?
  256. (basename (dirname f))
  257. (string-drop-right (basename f) 3)))
  258. (find-files "components/src" "\\.js$")))
  259. ;; Move all .js files into their parent directory, where MathJax
  260. ;; expects them.
  261. (for-each
  262. (lambda (f)
  263. (rename-file f (string-append (dirname (dirname f)) "/" (basename f))))
  264. (find-files target "\\.js(\\.map)?$"))
  265. ;; Copy font files.
  266. (copy-recursively
  267. "ts/output/chtml/fonts/tex-woff-v2"
  268. (string-append target "/output/chtml/fonts/woff-v2")))))
  269. (delete 'check)
  270. (delete 'install))))
  271. (native-inputs
  272. `(("esbuild" ,esbuild)
  273. ("node" ,node-lts)
  274. ("node-mj-context-menu"
  275. ,(let ((name "context-menu")
  276. (version "0.6.1"))
  277. (origin
  278. (method git-fetch)
  279. (uri (git-reference
  280. (url "https://github.com/zorkow/context-menu.git")
  281. (commit (string-append "v" version))))
  282. (file-name (git-file-name name version))
  283. (sha256
  284. (base32
  285. "1q063l6477z285j6h5wvccp6iswvlp0jmb96sgk32sh0lf7nhknh")))))
  286. ("node-mhchemparser"
  287. ,(let ((name "mhchemparser")
  288. ;; Version 4.1.1. There are no tags.
  289. (version "b1bd0670df7e9bbd5a724ac642aa2664d6e500b3"))
  290. (origin
  291. (method git-fetch)
  292. (uri (git-reference
  293. (url "https://github.com/mhchem/mhchemParser.git")
  294. (commit version)))
  295. (file-name (git-file-name name version))
  296. (sha256
  297. (base32
  298. "1g72kbxzf9f2igidpma3jwk28ln4bp3qhwspmhnm79baf3701dgv")))))))
  299. (home-page "https://www.mathjax.org/")
  300. (synopsis (package-synopsis js-mathjax))
  301. (description (package-description js-mathjax))
  302. (license license:asl2.0)))
  303. (define-public js-commander
  304. (package
  305. (name "js-commander")
  306. (version "6.2.1")
  307. (source
  308. (origin
  309. (method git-fetch)
  310. (uri (git-reference
  311. (url "https://github.com/tj/commander.js")
  312. (commit (string-append "v" version))))
  313. (file-name (git-file-name name version))
  314. (sha256
  315. (base32
  316. "126m25s6mxpxmdj4aw5awz06b47r8r798lcf1c5bnmmh39cik5i1"))))
  317. (build-system trivial-build-system)
  318. (arguments
  319. `(#:modules ((guix build utils))
  320. #:builder
  321. (begin
  322. (use-modules (guix build utils))
  323. (chdir (assoc-ref %build-inputs "source"))
  324. (let ((esbuild (search-input-file %build-inputs "/bin/esbuild"))
  325. (target (string-append %output "/share/javascript/commander")))
  326. (invoke esbuild
  327. "--bundle"
  328. "--minify"
  329. "--tsconfig=tsconfig.json"
  330. "--platform=node"
  331. (string-append "--outfile=" target "/index.min.js")
  332. "index.js")))))
  333. (native-inputs
  334. (list esbuild))
  335. (home-page "https://github.com/tj/commander.js")
  336. (synopsis "Library for node.js command-line interfaces")
  337. (description "Commander.js aims to be the complete solution for node.js
  338. command-line interfaces.")
  339. (license license:expat)))
  340. (define-public js-xmldom-sre
  341. ;; This commit corresponds to the untagged release 0.1.32
  342. (let ((commit "3c79325bc2c9e5d27e3ba44b680fa8c5dd6a381d")
  343. (revision "1"))
  344. (package
  345. (name "js-xmldom-sre")
  346. (version "0.1.32")
  347. (source
  348. (origin
  349. (method git-fetch)
  350. (uri (git-reference
  351. (url "https://github.com/zorkow/xmldom/")
  352. (commit commit)))
  353. (file-name (git-file-name name version))
  354. (sha256
  355. (base32
  356. "0a88v0id3mjflpvjqhv8a28br0xvaaszxbf7alg6pxfbnkb69yyq"))))
  357. (build-system trivial-build-system)
  358. (arguments
  359. `(#:modules ((guix build utils))
  360. #:builder
  361. (begin
  362. (use-modules (guix build utils))
  363. (chdir (assoc-ref %build-inputs "source"))
  364. (let ((esbuild (search-input-file %build-inputs "/bin/esbuild"))
  365. (target (string-append %output "/share/javascript/xmldom-sre")))
  366. (invoke esbuild
  367. "--bundle"
  368. "--minify"
  369. "--platform=node"
  370. (string-append "--outfile=" target "/dom-parser.min.js")
  371. "dom-parser.js")))))
  372. (native-inputs
  373. (list esbuild))
  374. (home-page "https://github.com/zorkow/xmldom/")
  375. (synopsis "DOM parser and XML serializer")
  376. (description "This is a fork of the xmldom library. It allows the use
  377. of wicked-good-xpath together with xmldom.")
  378. ;; One of these licenses may be selected.
  379. (license (list license:expat
  380. license:lgpl2.0)))))
  381. (define-public js-respond
  382. (package
  383. (name "js-respond")
  384. (version "1.4.2")
  385. (source (origin
  386. (method git-fetch)
  387. (uri (git-reference
  388. (url "https://github.com/scottjehl/Respond")
  389. (commit version)))
  390. (file-name (git-file-name name version))
  391. (sha256
  392. (base32
  393. "00xid731rirc7sdy1gc8qal3v9g0agr2qx15hm4x97l1lcbylyn2"))))
  394. (build-system minify-build-system)
  395. (arguments
  396. `(#:javascript-files '("src/matchmedia.addListener.js"
  397. "src/matchmedia.polyfill.js"
  398. "src/respond.js")))
  399. (home-page "https://github.com/scottjehl/Respond")
  400. (synopsis "Polyfill for min/max-width CSS3 Media Queries")
  401. (description "The goal of this script is to provide a fast and lightweight
  402. script to enable responsive web designs in browsers that don't support CSS3
  403. Media Queries.")
  404. (license license:expat)))
  405. (define-public js-html5shiv
  406. (package
  407. (name "js-html5shiv")
  408. (version "3.7.3")
  409. (source (origin
  410. (method git-fetch)
  411. (uri (git-reference
  412. (url "https://github.com/aFarkas/html5shiv")
  413. (commit version)))
  414. (file-name (git-file-name name version))
  415. (sha256
  416. (base32
  417. "0y1c5nyq0brl9fjdihhax33vks4s1ij9iv113879sg3zflmgqpd0"))))
  418. (build-system minify-build-system)
  419. (home-page "https://github.com/aFarkas/html5shiv")
  420. (synopsis "Enable HTML5 sectioning elements in legacy browsers")
  421. (description "The HTML5 Shiv enables use of HTML5 sectioning elements in
  422. legacy Internet Explorer and provides basic HTML5 styling for Internet
  423. Explorer 6-9, Safari 4.x (and iPhone 3.x), and Firefox 3.x.")
  424. ;; From the file "MIT and GPL2 licenses.md":
  425. ;;
  426. ;; This software is licensed under a dual license system (MIT or GPL
  427. ;; version 2). This means you are free to choose with which of both
  428. ;; licenses (MIT or GPL version 2) you want to use this library.
  429. (license (list license:expat license:gpl2))))
  430. (define-public js-json2
  431. (let ((commit "031b1d9e6971bd4c433ca85e216cc853f5a867bd")
  432. (revision "1"))
  433. (package
  434. (name "js-json2")
  435. (version (string-append "2016-10-28." revision "-" (string-take commit 7)))
  436. (source (origin
  437. (method git-fetch)
  438. (uri (git-reference
  439. (url "https://github.com/douglascrockford/JSON-js")
  440. (commit commit)))
  441. (file-name (string-append name "-" version "-checkout"))
  442. (sha256
  443. (base32
  444. "1fvb6b2y5sd3sqdgcj683sdxcbxdii34q0ysc9wg0dq1sy81l11v"))))
  445. (build-system minify-build-system)
  446. (arguments
  447. `(#:javascript-files '("json2.js"
  448. "json_parse.js"
  449. "json_parse_state.js"
  450. "cycle.js")))
  451. (home-page "https://github.com/douglascrockford/JSON-js")
  452. (synopsis "JSON encoders and decoders")
  453. (description "The files in this collection implement JSON
  454. encoders/decoders in JavaScript.
  455. @code{json2.js}: This file creates a JSON property in the global object, if
  456. there isn't already one, setting its value to an object containing a stringify
  457. method and a parse method. The @code{parse} method uses the @code{eval}
  458. method to do the parsing, guarding it with several regular expressions to
  459. defend against accidental code execution hazards. On current browsers, this
  460. file does nothing, preferring the built-in JSON object.
  461. @code{json_parse.js}: This file contains an alternative JSON @code{parse}
  462. function that uses recursive descent instead of @code{eval}.
  463. @code{json_parse_state.js}: This files contains an alternative JSON
  464. @code{parse} function that uses a state machine instead of @code{eval}.
  465. @code{cycle.js}: This file contains two functions, @code{JSON.decycle} and
  466. @code{JSON.retrocycle}, which make it possible to encode cyclical structures
  467. and DAGs in JSON, and to then recover them. This is a capability that is not
  468. provided by ES5. @code{JSONPath} is used to represent the links.")
  469. (license license:public-domain))))
  470. (define-public js-strftime
  471. (package
  472. (name "js-strftime")
  473. (version "0.10.0")
  474. (source (origin
  475. (method git-fetch)
  476. (uri (git-reference
  477. (url"https://github.com/samsonjs/strftime")
  478. (commit (string-append "v" version))))
  479. (file-name (git-file-name name version))
  480. (sha256
  481. (base32
  482. "131nmlivazwxyba25kh9lda99749fq4xsyin6lzfalaaydviby4p"))))
  483. (build-system minify-build-system)
  484. (arguments
  485. `(#:javascript-files '("strftime.js")))
  486. (home-page "https://github.com/samsonjs/strftime")
  487. (synopsis "Implementation of strftime to JavaScript")
  488. (description "This is an implementation of the @code{strftime} procedure
  489. for JavaScript. It works in (at least) node.js and browsers. It supports
  490. localization and timezones. Most standard specifiers from C are supported as
  491. well as some other extensions from Ruby.")
  492. (license license:expat)))
  493. (define-public js-highlight
  494. (package
  495. (name "js-highlight")
  496. (version "9.12.0")
  497. (source (origin
  498. (method git-fetch)
  499. (uri (git-reference
  500. (url "https://github.com/isagalaev/highlight.js")
  501. (commit version)))
  502. (file-name (git-file-name name version))
  503. (sha256
  504. (base32
  505. "12qz22qjpd6svj58pwgcwg2x2rzhihfdrxg6lgj39nfpaln6dris"))))
  506. (build-system minify-build-system)
  507. (arguments
  508. `(#:javascript-files '("src/highlight.js")))
  509. (home-page "https://github.com/isagalaev/highlight.js")
  510. (synopsis "Syntax highlighting for JavaScript")
  511. (description "Highlight.js is a syntax highlighter written in JavaScript.
  512. It works in the browser as well as on the server. It works with pretty much
  513. any markup, doesn’t depend on any framework and has automatic language
  514. detection.")
  515. (license license:bsd-3)))
  516. (define-public js-datatables
  517. (package
  518. (name "js-datatables")
  519. (version "1.10.19")
  520. (source (origin
  521. (method url-fetch)
  522. (uri (string-append "https://datatables.net/releases/DataTables-"
  523. version ".zip"))
  524. (sha256
  525. (base32
  526. "0cff8a1g7pjwbjdqq0yzqd963ar7pfi4splmm6rwdzganr77rkhb"))))
  527. (build-system minify-build-system)
  528. (arguments
  529. `(#:javascript-files '("media/js/dataTables.bootstrap.js"
  530. "media/js/jquery.dataTables.js")))
  531. (native-inputs
  532. (list unzip))
  533. (home-page "https://datatables.net")
  534. (synopsis "DataTables plug-in for jQuery")
  535. (description "DataTables is a table enhancing plug-in for the jQuery
  536. Javascript library, adding sorting, paging and filtering abilities to plain
  537. HTML tables with minimal effort.")
  538. (license license:expat)))
  539. (define-public js-requirejs
  540. (package
  541. (name "js-requirejs")
  542. (version "2.3.6")
  543. (source (origin
  544. (method git-fetch)
  545. (uri (git-reference
  546. (url "https://github.com/requirejs/requirejs")
  547. (commit version)))
  548. (file-name (git-file-name name version))
  549. (sha256
  550. (base32
  551. "0cvd5y2mb3h6yil3niqn3gjqrzixdsxcz4rvc2f0hg4kzp5y0w86"))))
  552. (build-system minify-build-system)
  553. (arguments `(#:javascript-files '("require.js")))
  554. (home-page "https://github.com/requirejs/requirejs/")
  555. (synopsis "File and module loader for JavaScript")
  556. (description "RequireJS loads plain JavaScript files as well as more
  557. defined modules. It is optimized for in-browser use, including in a Web
  558. Worker, but it can be used in other JavaScript environments.")
  559. (license license:expat)))
  560. (define-public js-selectize
  561. (package
  562. (name "js-selectize")
  563. (version "0.12.6")
  564. (source (origin
  565. (method git-fetch)
  566. (uri (git-reference
  567. (url "https://github.com/selectize/selectize.js")
  568. (commit (string-append "v" version))))
  569. (file-name (git-file-name name version))
  570. (sha256
  571. (base32
  572. "15gichl8wi6yxag2ps723nxrgyan15976dzsnvw9h9py8sbyyzjn"))))
  573. (build-system minify-build-system)
  574. ;; We use the standalone file instead of src/selectize.js because the
  575. ;; former includes the source code for MicroEvent and other modules that
  576. ;; Selectize refers to.
  577. (arguments `(#:javascript-files '("dist/js/standalone/selectize.js")))
  578. (home-page "https://selectize.github.io/selectize.js/")
  579. (synopsis "Hybrid widget between a textbox and <select> box")
  580. (description "Selectize is the hybrid of a textbox and @code{<select>}
  581. box. It's jQuery based and it has autocomplete and native-feeling keyboard
  582. navigation; it is useful for tagging, contact lists, etc.")
  583. (license license:asl2.0)))
  584. (define-public js-es5-shim
  585. (package
  586. (name "js-es5-shim")
  587. (version "4.5.13")
  588. (source (origin
  589. (method git-fetch)
  590. (uri (git-reference
  591. (url "https://github.com/es-shims/es5-shim")
  592. (commit (string-append "v" version))))
  593. (file-name (git-file-name name version))
  594. (sha256
  595. (base32
  596. "142w384fbyllq4yggv173g82lw3wix4jqcg6hkhx1ymq89vvnpmh"))))
  597. (build-system minify-build-system)
  598. (arguments `(#:javascript-files
  599. '("es5-sham.js"
  600. "es5-shim.js")))
  601. (home-page "https://github.com/es-shims/es5-shim")
  602. (synopsis "ECMAScript 5 compatibility shims for legacy JavaScript engines")
  603. (description "@code{es5-shim.js} patches a JavaScript context to contain
  604. all ECMAScript 5 methods that can be faithfully emulated with a legacy
  605. JavaScript engine. @code{es5-sham.js} patches other ES5 methods as closely as
  606. possible. Many of these shams are intended only to allow code to be written
  607. to ES5 without causing run-time errors in older engines. In many cases, this
  608. means that these shams cause many ES5 methods to silently fail.")
  609. (license license:expat)))
  610. (define-public js-filesaver
  611. (package
  612. (name "js-filesaver")
  613. (version "1.3.8")
  614. (source (origin
  615. (method git-fetch)
  616. (uri (git-reference
  617. (url "https://github.com/eligrey/FileSaver.js")
  618. (commit version)))
  619. (file-name (git-file-name name version))
  620. (sha256
  621. (base32
  622. "0gvqk0hnr8fig0n4da7vj7q6z31bcyv52916xz3rbmdj3pgpiv1d"))))
  623. (build-system minify-build-system)
  624. (arguments
  625. `(#:phases
  626. (modify-phases %standard-phases
  627. (add-after 'unpack 'fix-uglification
  628. ;; Remove "export" keyword. That keyword is not present in
  629. ;; the minified version of the library some projects are using,
  630. ;; e.g.,
  631. ;; <https://github.com/jmoenig/Snap--Build-Your-Own-Blocks/blob/master/FileSaver.min.js>
  632. (lambda _
  633. (substitute* "src/FileSaver.js"
  634. (("export ") ""))
  635. #t))
  636. (add-after 'install 'install-unminified-version
  637. (lambda* (#:key outputs #:allow-other-keys)
  638. (install-file "src/FileSaver.js"
  639. (string-append (assoc-ref outputs "out")
  640. "/share/javascript"))
  641. #t)))))
  642. (home-page
  643. "https://eligrey.com/blog/saving-generated-files-on-the-client-side/")
  644. (synopsis "HTML5 saveAs() FileSaver implementation")
  645. (description "@file{FileSaver.js} implements the @code{saveAs()}
  646. FileSaver interface in browsers that do not natively support it.
  647. @file{FileSaver.js} is the solution to saving files on the
  648. client-side, and is perfect for webapps that need to generate files,
  649. or for saving sensitive information that shouldn't be sent to an
  650. external server.")
  651. (license license:expat)))
  652. (define-public mujs
  653. (package
  654. (name "mujs")
  655. (version "1.1.3")
  656. (source
  657. (origin
  658. (method git-fetch)
  659. (uri (git-reference
  660. (url "https://github.com/ccxvii/mujs")
  661. (commit version)))
  662. (file-name (git-file-name name version))
  663. (sha256
  664. (base32 "0qizld89qw24i9v6i2j9cxjyqn425xbiqfp1b7qfrkyxqkn0byws"))))
  665. (build-system gnu-build-system)
  666. (arguments
  667. `(#:phases
  668. (modify-phases %standard-phases
  669. (delete 'configure) ; no configure script
  670. (replace 'install
  671. (lambda* (#:key (make-flags '()) #:allow-other-keys)
  672. (apply invoke "make" "install-shared" make-flags))))
  673. #:make-flags
  674. (list ,(string-append "VERSION=" version)
  675. ,(string-append "CC=" (cc-for-target))
  676. (string-append "prefix=" (assoc-ref %outputs "out")))
  677. #:tests? #f)) ; no tests
  678. (inputs
  679. (list readline))
  680. (home-page "https://mujs.com/")
  681. (synopsis "JavaScript interpreter written in C")
  682. (description "MuJS is a lightweight Javascript interpreter designed for
  683. embedding in other software to extend them with scripting capabilities. MuJS
  684. was designed with a focus on small size, correctness, and simplicity. It is
  685. written in portable C and implements ECMAScript as specified by ECMA-262. The
  686. interface for binding with native code is designed to be as simple as possible
  687. to use, and is very similar to Lua. There is no need to interact with byzantine
  688. C++ template mechanisms, or worry about marking and unmarking garbage collection
  689. roots, or wrestle with obscure build systems.")
  690. (license license:isc)))
  691. (define-public quickjs
  692. (package
  693. (name "quickjs")
  694. (version "2021-03-27")
  695. (source (origin
  696. (method url-fetch)
  697. (uri (string-append "https://bellard.org/quickjs/quickjs-"
  698. version ".tar.xz"))
  699. (sha256
  700. (base32
  701. "06pywwpmfwjz225h59wf90q96a2fd66qfcw5xa6m6y9k9k7glnx4"))))
  702. (build-system gnu-build-system)
  703. (arguments
  704. `(#:make-flags
  705. (list "prefix="
  706. (string-append "DESTDIR=" %output))
  707. #:phases
  708. (modify-phases %standard-phases
  709. (delete 'configure)
  710. (replace 'check
  711. (lambda _
  712. (invoke "make" "microbench"))))))
  713. (home-page "https://bellard.org/quickjs/")
  714. (synopsis "Small embeddable Javascript engine")
  715. (description "QuickJS supports the ES2020 specification including modules,
  716. asynchronous generators, proxies, BigInt and BigDecimal. It can compile
  717. Javascript sources to executables with no external dependency. It includes a
  718. command line interpreter with contextual colorization implemented in
  719. Javascript and a small built-in standard library with C library wrappers.")
  720. (license license:expat)))
  721. (define-public duktape
  722. (package
  723. (name "duktape")
  724. (version "2.6.0")
  725. (source (origin
  726. (method url-fetch)
  727. (uri (string-append "https://duktape.org/duktape-"
  728. version ".tar.xz"))
  729. (sha256
  730. (base32
  731. "19szwxzvl2g65fw95ggvb8h0ma5bd9vvnnccn59hwnc4dida1x4n"))))
  732. (build-system gnu-build-system)
  733. (arguments
  734. `(#:tests? #f ; No tests.
  735. #:make-flags (list "-f" "Makefile.sharedlibrary"
  736. (string-append "INSTALL_PREFIX=" %output))
  737. #:phases
  738. (modify-phases %standard-phases
  739. (delete 'configure)
  740. ;; At least another major GNU/Linux distribution carries their own
  741. ;; .pc file with this package.
  742. (add-after 'install 'install-pkg-config
  743. (lambda* (#:key outputs #:allow-other-keys)
  744. (let* ((out (assoc-ref outputs "out"))
  745. (pkg-config-dir (string-append out "/lib/pkgconfig")))
  746. (mkdir-p pkg-config-dir)
  747. (with-output-to-file (string-append pkg-config-dir "/duktape.pc")
  748. (lambda _
  749. (format #t "prefix=~@*~a~@
  750. libdir=${prefix}/lib~@
  751. includedir=${prefix}/include~@
  752. Name: duktape~@
  753. Description: Embeddable Javascript engine~@
  754. Version: ~a~@
  755. Libs: -L${libdir} -lduktape~@
  756. Cflags: -I${includedir}~%"
  757. out ,version)))))))))
  758. (home-page "https://duktape.org/")
  759. (synopsis "Small embeddable Javascript engine")
  760. (description "Duktape is an embeddable Javascript engine, with a focus on
  761. portability and compact footprint. Duktape is easy to integrate into a C/C++
  762. project: add @file{duktape.c}, @file{duktape.h}, and @file{duk_config.h} to
  763. your build, and use the Duktape API to call ECMAScript functions from C code
  764. and vice versa.")
  765. (license license:expat)))
  766. (define-public rhino
  767. (package
  768. (name "rhino")
  769. (version "1.7.7.2")
  770. (source (origin
  771. (method git-fetch)
  772. (uri (git-reference
  773. (url "https://github.com/mozilla/rhino.git")
  774. (commit "935942527ff434b205e797df4185518e5369466e")))
  775. (file-name (git-file-name name version))
  776. (sha256
  777. (base32
  778. "09i4yr98hs6855fs7fhgmrpiwpr90lhxdv2bvfj97nn4rv1d7wl8"))
  779. (modules '((guix build utils)))
  780. (snippet '(begin
  781. ;; Remove benchmark testing
  782. (delete-file-recursively "testsrc/benchmarks")
  783. (delete-file-recursively
  784. "testsrc/org/mozilla/javascript/benchmarks")
  785. ;; Identify bundled jars
  786. (format #t "~%~a~%" "Sourced jars")
  787. (for-each (lambda (f)
  788. (format #t "~/Deleting: ~a~%" f)
  789. (delete-file f))
  790. (find-files "." "\\.jar$"))))))
  791. (build-system ant-build-system)
  792. (inputs (list bash-minimal))
  793. (native-inputs (list java-junit java-hamcrest-core java-snakeyaml))
  794. (arguments
  795. `(#:phases
  796. (modify-phases
  797. %standard-phases
  798. (replace 'check
  799. (lambda* (#:key tests? inputs native-inputs
  800. #:allow-other-keys)
  801. (when tests?
  802. (setenv "ANT_OPTS" "-Doffline=true")
  803. (let ((junit-lib
  804. (assoc-ref inputs "java-junit"))
  805. (hamcrest-lib
  806. (assoc-ref inputs "java-hamcrest-core"))
  807. (snakeyaml-lib
  808. (assoc-ref inputs "java-snakeyaml")))
  809. (with-directory-excursion "testsrc"
  810. (substitute* "build.xml"
  811. (("<pathelement location=\"\\$\\{xbean.jar\\}\" */>" all)
  812. (string-append "<!-- " all " -->"))
  813. (("<pathelement location=\"\\$\\{jsr173.jar\\}\" */>" all)
  814. (string-append "<!-- " all " -->"))
  815. (("<pathelement path=\"\\$\\{coverage.classes.dir\\}\" */>"
  816. all)
  817. (string-append "<!-- " all " -->"))
  818. (("<pathelement path=\"lib/emma.jar\"/>" all)
  819. (string-append "<!-- " all " -->"))
  820. (("<pathelement path=\"lib/junit.jar\" ?/>")
  821. (string-append
  822. "<fileset dir=\"" junit-lib "\" includes=\"**/*.jar\"/>"))
  823. (("<pathelement path=\"lib/hamcrest.jar\" ?/>")
  824. (string-append "<fileset dir=\"" hamcrest-lib
  825. "\" includes=\"**/*.jar\"/>"))
  826. (("<pathelement path=\"lib/snakeyaml.jar\" ?/>")
  827. (string-append "<fileset dir=\"" snakeyaml-lib
  828. "\" includes=\"**/*.jar\"/>"))
  829. ;; Disabling instrumentation.
  830. (("(<target name=\"junit\" depends=\"junit-compile),.*"
  831. all pre)
  832. (string-append pre "\">"))))
  833. (invoke "ant" "junit")))))
  834. (replace 'install
  835. (lambda* (#:key inputs outputs #:allow-other-keys)
  836. (let* ((out (assoc-ref outputs "out"))
  837. (pkg+ver (string-append ,name ,version))
  838. (bin (string-append out "/bin"))
  839. (rhino (string-append bin "/rhino"))
  840. (man (string-append out "/share/man/man1")))
  841. (mkdir-p bin)
  842. (install-file "man/rhino.1" man)
  843. (install-file (string-append "build/" pkg+ver
  844. "/js.jar")
  845. (string-append out "/share/java"))
  846. (with-output-to-file rhino
  847. (lambda _
  848. (format #t "#!~a~%~a -jar ~a $@~%"
  849. (search-input-file inputs "/bin/bash")
  850. (search-input-file inputs "/bin/java")
  851. (string-append out "/share/java/js.jar"))))
  852. (chmod rhino #o755)))))))
  853. (home-page "https://mozilla.github.io/rhino")
  854. (synopsis "Javascript implemented in Java")
  855. (description
  856. "Rhino implements ECMAScript, also known as JavaScript, in Java as
  857. specified in the fifth edition of ECMA-262.")
  858. (license license:mpl2.0)))