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