GNU bug report logs - #67019
[PATCH 00/16] gnu: Add KaTeX, lessc, and flow-remove-types.

Previous Next

Package: guix-patches;

Reported by: Philip McGrath <philip <at> philipmcgrath.com>

Date: Thu, 9 Nov 2023 16:09:02 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 67019 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to philip <at> philipmcgrath.com, julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 09 Nov 2023 16:09:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Philip McGrath <philip <at> philipmcgrath.com>:
New bug report received and forwarded. Copy sent to philip <at> philipmcgrath.com, julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org. (Thu, 09 Nov 2023 16:09:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: guix-patches <at> gnu.org
Subject: [PATCH 00/16] gnu: Add KaTeX, lessc, and flow-remove-types.
Date: Thu,  9 Nov 2023 11:06:29 -0500
Hi,

This patch series adds KaTeX, which renders TeX math notation to HTML and/or
MathML. (It's somewhat similar to MathJax, but with different emphases: in
particular, the rendered output from KaTeX doesn't require JavaScript.)

Along the way, this series adds two dependencies of KaTeX that are especially
notable in their own right:

 1. Patches 01/16 to 03/16 add lessc, the compiler for the Less CSS extension
    language (not to be confused with the pager less).

 2. Patches 04/16 to 11/16 add flow-remove-types, which erases Flow type
    annotations from JavaScript source code.  This enables Guix to build
    software written using Flow somewhat analagously to how esbuild does with
    TypeScript.

Philip

Philip McGrath (16):
  gnu: Add node-is-what.
  gnu: Add node-copy-anything.
  gnu: Add lessc.
  gnu: Add ocaml-wtf8.
  gnu: Add ocaml-visitors.
  gnu: Add ocaml-ppx-gen-rec.
  gnu: Add ocaml-dtoa.
  gnu: Add node-vlq.
  gnu: Add ocaml-flow-parser.
  gnu: Add node-flow-parser.
  gnu: Add flow-remove-types.
  gnu: js-commander: Update to 11.1.0.
  gnu: js-commander: Install as a node module.
  gnu: Add mftrace.
  gnu: Add font-katex.
  gnu: Add katex.

 gnu/packages/fontutils.scm  |  45 +++++
 gnu/packages/javascript.scm | 381 +++++++++++++++++++++++++++++++++--
 gnu/packages/node-xyz.scm   | 220 +++++++++++++++++++++
 gnu/packages/ocaml.scm      |  99 ++++++++++
 gnu/packages/web.scm        | 385 ++++++++++++++++++++++++++++++++++++
 5 files changed, 1113 insertions(+), 17 deletions(-)


base-commit: 19fe24c5b978a16cbca3cddbfa3ab9d1ee2c68f2
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 09 Nov 2023 16:16:02 GMT) Full text and rfc822 format available.

Message #8 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>
Subject: [PATCH 01/16] gnu: Add node-is-what.
Date: Thu,  9 Nov 2023 11:12:18 -0500
* gnu/packages/node-xyz.scm (node-is-what): New variable.
---
 gnu/packages/node-xyz.scm | 81 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 6c16417309..49760ded2b 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1631,3 +1631,84 @@ (define-public node-yazl
 @item Prefer to open input files one at a time than all at once.
 @end enumerate")
     (license license:expat)))
+
+(define-public node-is-what
+  (package
+    (name "node-is-what")
+    (version "4.1.16")
+    (source
+     (origin (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/mesqueeb/is-what")
+                   (commit (string-append "v" version))))
+             (sha256
+              (base32 "02h76klvjxgk0cl8a7sq4wbi7l4pvdimbams08l34k5carg03bdx"))
+             (snippet
+              #~(for-each delete-file
+                          '("dist/cjs/index.cjs"
+                            "dist/index.js")))
+             (file-name (git-file-name name version))))
+    (build-system node-build-system)
+    (native-inputs (list esbuild))
+    (arguments
+     (list
+      #:tests? #f ; needs more dependencies
+      #:modules
+      `((guix build node-build-system)
+        (ice-9 match)
+        (guix build utils))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'patch-dependencies 'delete-dependencies
+            (lambda args
+              (delete-dependencies
+               '(;; devDependencies
+                 "@typescript-eslint/eslint-plugin"
+                 "@typescript-eslint/parser"
+                 "del-cli"
+                 "eslint"
+                 "eslint-config-prettier"
+                 "eslint-plugin-tree-shaking"
+                 "np"
+                 "prettier"
+                 "prettier-plugin-jsdoc"
+                 "rollup"
+                 "rollup-plugin-dts"
+                 "rollup-plugin-esbuild"
+                 "rollup-plugin-typescript2"
+                 "typedoc"
+                 "typescript"
+                 "vitest"))))
+          (add-after 'delete-dependencies 'patch-build-script
+            (lambda args
+              (define esbuild
+                "esbuild --bundle --platform=node")
+              (define new-build-script
+                (string-append
+                 esbuild
+                 " --format=cjs --outfile=dist/cjs/index.cjs src/index.ts"
+                 " && "
+                 esbuild
+                 " --format=esm --outfile=dist/index.js src/index.ts"))
+              (with-atomic-json-file-replacement "package.json"
+                (match-lambda
+                  (('@ . alist)
+                   (cons '@
+                    (map (match-lambda
+                           (("scripts" @ . alist)
+                            `("scripts" @ ,@(map (match-lambda
+                                                   (("build" . _)
+                                                    (cons "build"
+                                                          new-build-script))
+                                                   (other
+                                                    other))
+                                                 alist)))
+                           (other
+                            other))
+                         alist))))))))))
+    (home-page "https://npmjs.com/is-what")
+    (synopsis "Type predicate functions for JavaScript")
+    (description "This package provides simple and small type predicate
+functions for JavaScript, such as @code{isString}, @code{isDate}, and
+@code{isPlainObject}.")
+    (license license:expat)))
-- 
2.41.0





Information forwarded to philip <at> philipmcgrath.com, julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 09 Nov 2023 16:28:01 GMT) Full text and rfc822 format available.

Message #11 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>
Subject: [PATCH 02/16] gnu: Add node-copy-anything.
Date: Thu,  9 Nov 2023 11:26:24 -0500
* gnu/packages/node-xyz.scm (node-copy-anything): New variable.
---
 gnu/packages/node-xyz.scm | 81 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 49760ded2b..ee96dee767 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1712,3 +1712,84 @@ (define-public node-is-what
 functions for JavaScript, such as @code{isString}, @code{isDate}, and
 @code{isPlainObject}.")
     (license license:expat)))
+
+(define-public node-copy-anything
+  (package
+    (name "node-copy-anything")
+    (version "3.0.5")
+    (source
+     (origin (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/mesqueeb/copy-anything")
+                   (commit (string-append "v" version))))
+             (sha256
+              (base32 "1lpjqanjl04k088banpns4yvp6hgf97snaj7gfbfancjpd3i8gk6"))
+             (snippet
+              #~(for-each delete-file
+                          '("dist/cjs/index.cjs"
+                            "dist/index.js")))
+             (file-name (git-file-name name version))))
+    (build-system node-build-system)
+    (native-inputs (list esbuild))
+    (inputs (list node-is-what))
+    (arguments
+     (list
+      #:tests? #f ; needs more dependencies
+      #:modules
+      `((guix build node-build-system)
+        (ice-9 match)
+        (guix build utils))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'patch-dependencies 'delete-dependencies
+            (lambda args
+              (delete-dependencies
+               '(;; devDependencies
+                 "@typescript-eslint/eslint-plugin"
+                 "@typescript-eslint/parser"
+                 "del-cli"
+                 "eslint"
+                 "eslint-config-prettier"
+                 "eslint-plugin-tree-shaking"
+                 "np"
+                 "prettier"
+                 "rollup"
+                 "rollup-plugin-dts"
+                 "rollup-plugin-esbuild"
+                 "rollup-plugin-typescript2"
+                 "typescript"
+                 "vitest"))))
+          (add-after 'delete-dependencies 'patch-build-script
+            (lambda args
+              (define esbuild
+                "esbuild --bundle --platform=node --external:is-what")
+              (define new-build-script
+                (string-append
+                 esbuild
+                 " --format=cjs --outfile=dist/cjs/index.cjs src/index.ts"
+                 " && "
+                 esbuild
+                 " --format=esm --outfile=dist/index.js src/index.ts"))
+              (with-atomic-json-file-replacement "package.json"
+                (match-lambda
+                  (('@ . alist)
+                   (cons '@
+                    (map (match-lambda
+                           (("scripts" @ . alist)
+                            `("scripts" @ ,@(map (match-lambda
+                                                   (("build" . _)
+                                                    (cons "build"
+                                                          new-build-script))
+                                                   (other
+                                                    other))
+                                                 alist)))
+                           (other
+                            other))
+                         alist))))))))))
+    (home-page "https://npmjs.com/copy-anything")
+    (synopsis "JavaScript library for copying objects and arrays")
+    (description "This library provides deep copying for JavaScript objects
+and arrays.  Its design emphasizes speed, simplicity, and correctness in the
+face of complications like special objects, symbols, and non-enumerable
+properties.")
+    (license license:expat)))
-- 
2.41.0





Information forwarded to philip <at> philipmcgrath.com, julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 09 Nov 2023 16:28:02 GMT) Full text and rfc822 format available.

Message #14 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>
Subject: [PATCH 03/16] gnu: Add lessc.
Date: Thu,  9 Nov 2023 11:26:25 -0500
* gnu/packages/web.scm (lessc): New variable.
---
 gnu/packages/web.scm | 187 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 187 insertions(+)

diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index 66d09700db..8e22997957 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -64,6 +64,7 @@
 ;;; Copyright © 2023 David Thompson <dthompson2 <at> worcester.edu>
 ;;; Copyright © 2023 Christopher Howard <christopher <at> librehacker.com>
 ;;; Copyright © 2023 Felix Lechner <felix.lechner <at> lease-up.com>
+;;; Copyright © 2023 Philip McGrath <philip <at> philipmcgrath.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -98,6 +99,7 @@ (define-module (gnu packages web)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
   #:use-module (guix build-system meson)
+  #:use-module (guix build-system node)
   #:use-module (guix build-system perl)
   #:use-module (guix build-system pyproject)
   #:use-module (guix build-system python)
@@ -168,6 +170,7 @@ (define-module (gnu packages web)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages networking)
   #:use-module (gnu packages node)
+  #:use-module (gnu packages node-xyz)
   #:use-module (gnu packages nss)
   #:use-module (gnu packages openldap)
   #:use-module (gnu packages openstack)
@@ -2343,6 +2346,190 @@ (define-public sassc/libsass-3.5
                                                     "0830pjcvhzxh6yixj82x5k5r1xnadjqzi16kp53213icbly0r9ma")))))))
     (properties '((hidden? . #t)))))
 
+(define-public lessc
+  (package
+    (name "lessc")
+    (version "4.2.0")
+    (source
+     (origin (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/less/less.js")
+                   (commit (string-append "v" version))))
+             (sha256
+              (base32 "1b6anlafk7lnayxy3vhsi474jcdah2ffaw2qyac5s2ibxb1wmr54"))
+             (snippet
+              #~(begin
+                  (use-modules (guix build utils))
+                  (delete-file-recursively "packages/less/dist")))
+             (file-name (git-file-name name version))))
+    (build-system node-build-system)
+    (native-inputs (list esbuild))
+    (inputs (list node-copy-anything))
+    (arguments
+     (list
+      #:tests? #f ; many more dependencies
+      #:modules
+      `((guix build node-build-system)
+        (ice-9 match)
+        (guix build utils))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'chdir
+            (lambda args
+              (chdir "packages/less")))
+          (add-after 'patch-dependencies 'delete-dependencies
+            (lambda args
+              (delete-dependencies
+               '(;; dependencies
+                 "parse-node-version" ; patched out
+                 "tslib" ; probably not needed w/ esbuild
+                 ;; devDependencies
+                 "@less/test-data"
+                 "@less/test-import-module"
+                 "@rollup/plugin-commonjs"
+                 "@rollup/plugin-json"
+                 "@rollup/plugin-node-resolve"
+                 "@typescript-eslint/eslint-plugin"
+                 "@typescript-eslint/parser"
+                 "benny"
+                 "bootstrap-less-port"
+                 "chai"
+                 "cross-env"
+                 "diff"
+                 "eslint"
+                 "fs-extra"
+                 "git-rev"
+                 "globby"
+                 "grunt"
+                 "grunt-cli"
+                 "grunt-contrib-clean"
+                 "grunt-contrib-connect"
+                 "grunt-eslint"
+                 "grunt-saucelabs"
+                 "grunt-shell"
+                 "html-template-tag"
+                 "jit-grunt"
+                 "less-plugin-autoprefix"
+                 "less-plugin-clean-css"
+                 "minimist"
+                 "mocha"
+                 "mocha-headless-chrome"
+                 "mocha-teamcity-reporter"
+                 "nock"
+                 "npm-run-all"
+                 "performance-now"
+                 "phin"
+                 "promise"
+                 "read-glob"
+                 "resolve"
+                 "rollup"
+                 "rollup-plugin-terser"
+                 "rollup-plugin-typescript2"
+                 "semver"
+                 "shx"
+                 "time-grunt"
+                 "ts-node"
+                 "typescript"
+                 "uikit"
+                 ;; optionalDependencies
+                 "errno"
+                 "graceful-fs"
+                 "image-size"
+                 "make-dir"
+                 "mime"
+                 "needle"
+                 "source-map"))))
+          (add-after 'delete-dependencies 'avoid-parse-node-version
+            (lambda args
+              (define version
+                #$(package-version this-package))
+              (substitute* "src/less/index.js"
+                (("import [{] version [}]" orig)
+                 (string-append "// " orig))
+                (("import parseVersion from 'parse-node-version';" orig)
+                 (string-append "// " orig))
+                (("const v = parseVersion[(]`v\\$[{]version[}]`[)];" orig)
+                 (string-append "// " orig))
+                (("(version: )(\\[v\\.major, v\\.minor, v\\.patch],)" _ lhs rhs)
+                 (string-append
+                  lhs
+                  "["
+                  (string-join
+                   (list-head (string-split
+                               version (char-set-complement char-set:digit))
+                              3)
+                   ", ")
+                  "], // "
+                  rhs)))))
+          (add-after 'avoid-parse-node-version 'do-not-target-es5
+            (lambda args
+              ;; esbuild can't compile all features to ES5
+              (with-atomic-json-file-replacement "tsconfig.json"
+                (match-lambda
+                  (('@ . alist)
+                   (cons '@
+                    (map (match-lambda
+                           (("compilerOptions" '@ . alist)
+                            `("scripts" @ ,@(filter (match-lambda
+                                                      (("target" "ES5")
+                                                       #f)
+                                                      (_
+                                                       #t))
+                                                    alist)))
+                           (other
+                            other))
+                         alist)))))))
+          (add-after 'do-not-target-es5 'patch-build-script
+            (lambda args
+              (define new-build-script
+                (string-join
+                 `("esbuild"
+                   "--platform=node"
+                   "--format=cjs"
+                   "--outdir=lib"
+                   ,@(find-files "src/less" "\\.js$")
+                   ,@(find-files "src/less-node" "\\.js$"))))
+              (with-atomic-json-file-replacement "package.json"
+                (match-lambda
+                  (('@ . alist)
+                   (cons '@
+                    (map (match-lambda
+                           (("scripts" @ . alist)
+                            `("scripts" @ ,@(map (match-lambda
+                                                   (("build" . _)
+                                                    (cons "build"
+                                                          new-build-script))
+                                                   (other
+                                                    other))
+                                                 alist)))
+                           (other
+                            other))
+                         alist)))))))
+          (add-after 'build 'build-browser
+            (lambda args
+              (invoke "esbuild"
+                      "--bundle"
+                      "--platform=browser"
+                      "--format=cjs"
+                      "--outfile=dist/less.js"
+                      "src/less-browser/bootstrap.js")
+              (invoke "esbuild"
+                      "--bundle"
+                      "--minify"
+                      "--sourcemap"
+                      "--platform=browser"
+                      "--format=cjs"
+                      "--outfile=dist/less.min.js"
+                      "src/less-browser/bootstrap.js"))))))
+    (home-page "https://lesscss.org")
+    (synopsis "Compiler for @acronym{Less} @acronym{CSS} language extension")
+    ;; XXX: @abbr{} seems better for Less (which is always capitalized that
+    ;; way), but it is rejected as invalid Texinfo markup here.
+    (description "@acronym{Less, Leaner Style Sheets} is a
+backwards-compatible language extension for @acronym{CSS}.  This package
+provides @command{lessc}, which compiles Less files to plain @acronym{CSS}.")
+    (license license:asl2.0)))
+
 
 (define-public perl-apache-logformat-compiler
   (package
-- 
2.41.0





Information forwarded to philip <at> philipmcgrath.com, julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 09 Nov 2023 16:29:02 GMT) Full text and rfc822 format available.

Message #17 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>
Subject: [PATCH 05/16] gnu: Add ocaml-visitors.
Date: Thu,  9 Nov 2023 11:26:27 -0500
* gnu/packages/ocaml.scm (ocaml-visitors): New variable.
---
 gnu/packages/ocaml.scm | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index 50b0d1ddb7..f9a3932d18 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -5232,6 +5232,28 @@ (define-public ocaml-graph
     (description "OCamlgraph is a generic graph library for OCaml.")
     (license license:lgpl2.1)))
 
+(define-public ocaml-visitors
+  (package
+    (name "ocaml-visitors")
+    (version "20210608")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append "https://gitlab.inria.fr/fpottier/visitors/-/"
+                              "archive/" version "/archive.tar.gz"))
+              (sha256
+               (base32
+                "1yx4bjw4yw3zi35yfp66x320xgb9f8jh7rqj1j7hrrvn0f60m2y2"))))
+    (build-system dune-build-system)
+    (propagated-inputs (list ocaml-ppxlib ocaml-ppx-deriving ocaml-result))
+    (home-page "https://gitlab.inria.fr/fpottier/visitors")
+    (synopsis "OCaml syntax extension for generating visitor classes")
+    (description
+     "This package provides an OCaml syntax extension that automatically
+generates object-oriented visitors for traversing and transforming data
+structures.")
+    (license license:lgpl2.1)))
+
 (define-public ocaml-piqi
   (package
     (name "ocaml-piqi")
-- 
2.41.0





Information forwarded to philip <at> philipmcgrath.com, julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 09 Nov 2023 16:29:02 GMT) Full text and rfc822 format available.

Message #20 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>
Subject: [PATCH 06/16] gnu: Add ocaml-ppx-gen-rec.
Date: Thu,  9 Nov 2023 11:26:28 -0500
* gnu/packages/ocaml.scm (ocaml-ppx-gen-rec): New variable.
---
 gnu/packages/ocaml.scm | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index f9a3932d18..b12c12fad5 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -6722,6 +6722,34 @@ (define-public ocaml-ppx-deriving
 on type definitions, and a set of useful plugins for common tasks.")
     (license license:expat)))
 
+(define-public ocaml-ppx-gen-rec
+  (package
+    (name "ocaml-ppx-gen-rec")
+    (version "2.0.0")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append "https://github.com/flow/ocaml-ppx_gen_rec/"
+                              "releases/download/v"
+                              version
+                              "/ppx_gen_rec-v" version ".tbz"))
+              (sha256
+               (base32
+                "0ncy7ps0w3cnb3nk6y1j4v4g60rs500qwv1daw3a9n7n8kjj6qzy"))))
+    (build-system dune-build-system)
+    (propagated-inputs (list ocaml-ppxlib))
+    (native-inputs (list ocaml-ppx-deriving))
+    (properties `((upstream-name . "ppx_gen_rec")))
+    (home-page "https://github.com/flow/ocaml-ppx_gen_rec")
+    (synopsis "Ppx rewriter for recursive module expressions")
+    (description
+     "This package provides a ppx rewriter that transforms a recursive module
+expression into a struct.  In a recursive module expression, the struct can be
+derived from the signature automatically by the compiler.  This package does
+the same thing, but doing it this way allows @code{ppx_deriving} to transform
+the signature and the struct separately.")
+    (license license:expat)))
+
 (define-public ocaml-ppx-derivers
   (package
     (name "ocaml-ppx-derivers")
-- 
2.41.0





Information forwarded to philip <at> philipmcgrath.com, julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 09 Nov 2023 16:29:03 GMT) Full text and rfc822 format available.

Message #23 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>
Subject: [PATCH 10/16] gnu: Add node-flow-parser.
Date: Thu,  9 Nov 2023 11:26:32 -0500
* gnu/packages/web.scm (node-flow-parser): New variable.
(ocaml-flow-parser)[description]: Mention it.
---
 gnu/packages/web.scm | 45 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index 82923786f2..0ade9e46e3 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -2029,9 +2029,52 @@ (define-public ocaml-flow-parser
     (synopsis "Parser for the Flow JavaScript type system")
     (description "Flow is a gradual type system for JavaScript.  This package
 provides the Flow parser, which is an OCaml library that can also be compiled
-to JavaScript.")
+to JavaScript.  To use the compiled parser with Node.js or NPM, see the Guix
+package @code{node-flow-parser}.")
     (license license:expat)))
 
+(define-public node-flow-parser
+  (package
+    (inherit ocaml-flow-parser)
+    (name "node-flow-parser")
+    (properties '())
+    (outputs '("out"))
+    (propagated-inputs '())
+    (native-inputs '())
+    (inputs (list `(,ocaml-flow-parser "js")))
+    (build-system node-build-system)
+    (arguments
+     (list
+      #:tests? #f ; need unpackaged dependencies
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'delete-workspace-file
+            (lambda args
+              ;; this workspace file causes NPM to try to install dependencies
+              ;; of other packages developed in this source repository
+              (delete-file "package.json")))
+          (add-after 'delete-workspace-file 'chdir
+            (lambda args
+              (chdir "packages/flow-parser")))
+          (add-after 'chdir 'unpack-generated-js
+            (lambda* (#:key inputs #:allow-other-keys)
+              (install-file
+               (search-input-file inputs
+                                  "share/javascript/flow/flow_parser.js")
+               ".")
+              (delete-file "Makefile")))
+          (add-after 'patch-dependencies 'delete-dependencies
+            (lambda args
+              (delete-dependencies
+               '("ast-types"
+                 "colors"
+                 "esprima-fb"
+                 "minimist")))))))
+    (synopsis "Parser for the Flow JavaScript type system")
+    (description "Flow is a gradual type system for JavaScript.  This package
+provides the Flow parser in its compiled-to-JavaScript form for use with
+Node.js and NPM.")))
+
 (define-public tinyproxy
   (package
     (name "tinyproxy")
-- 
2.41.0





Information forwarded to philip <at> philipmcgrath.com, julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 09 Nov 2023 16:29:03 GMT) Full text and rfc822 format available.

Message #26 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>
Subject: [PATCH 11/16] gnu: Add flow-remove-types.
Date: Thu,  9 Nov 2023 11:26:33 -0500
* gnu/packages/web.scm (flow-remove-types): New variable.
---
 gnu/packages/web.scm | 60 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index 0ade9e46e3..8f0295998a 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -2075,6 +2075,66 @@ (define-public node-flow-parser
 provides the Flow parser in its compiled-to-JavaScript form for use with
 Node.js and NPM.")))
 
+(define-public flow-remove-types
+  (package
+    (inherit node-flow-parser)
+    (name "flow-remove-types")
+    (inputs (list node-flow-parser node-vlq))
+    (arguments
+     (list
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'delete-workspace-file
+            (lambda args
+              ;; this workspace file causes NPM to try to install dependencies
+              ;; of other packages developed in this source repository
+              (delete-file "package.json")))
+          (add-after 'delete-workspace-file 'chdir
+            (lambda args
+              (chdir "packages/flow-remove-types")))
+          (add-after 'patch-dependencies 'delete-dependencies
+            (lambda args
+              (delete-dependencies '("pirates"))))
+          (add-after 'delete-dependencies 'remove-unsupported-features
+            (lambda args
+              (delete-file "register.js")
+              (with-output-to-file "register.js"
+                (lambda ()
+                  (for-each
+                   display
+                   '("console.warn('flow-remove-types/register.js does not add"
+                     " a require hook on Guix');\n"
+                     "module.exports ="
+                     " function setOptions(newOptions) {};\n"))))
+              (substitute* "flow-node"
+                (("var flowRemoveTypes")
+                 (string-append
+                  "process.stderr.write('flow-node: not yet supported"
+                  " on Guix');\n"
+                  "return process.exit(1);\n"
+                  "var flowRemoveTypes")))
+              (substitute* "test.sh"
+                (("echo \"Test: node require hook\"")
+                  "echo \"SKIPPING Test: node require hook\"")
+                (("RES=\\$[(]node -e 'require[(]\"\\./register\"[)];")
+                 "RES=42 # ")
+                (("echo \"Test: flow-node\"")
+                 "echo \"SKIPPING Test: flow-node\"")
+                (("FLOW_NODE=")
+                 "FLOW_NODE=42 # ")
+                (("echo \"Test: flow-node with options\"")
+                 "echo \"SKIPPING Test: flow-node with options\"")
+                (("FLOW_NODE_OPTS=")
+                 "FLOW_NODE_OPTS=4 # ")))))))
+    (synopsis "Utility to erase Flow type annotations from JavaScript")
+    (description "Flow is a gradual type system for JavaScript.  This package
+provides @command{flow-remove-types}, a command-line tool that erases Flow
+type annotations, producing standard JavaScript files.  The functionality is
+also provided as a JavaScript library.
+
+Note that the Guix package does not yet support the @command{flow-node}
+command or the Node.js require hook for interactive development.")))
+
 (define-public tinyproxy
   (package
     (name "tinyproxy")
-- 
2.41.0





Information forwarded to philip <at> philipmcgrath.com, julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 09 Nov 2023 16:29:03 GMT) Full text and rfc822 format available.

Message #29 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>
Subject: [PATCH 04/16] gnu: Add ocaml-wtf8.
Date: Thu,  9 Nov 2023 11:26:26 -0500
* gnu/packages/ocaml.scm (ocaml-wtf8): New variable.
---
 gnu/packages/ocaml.scm | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index 7993dbaa73..50b0d1ddb7 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -29,6 +29,7 @@
 ;;; Copyright © 2022 Garek Dyszel <garekdyszel <at> disroot.org>
 ;;; Copyright © 2023 Csepp <raingloom <at> riseup.net>
 ;;; Copyright © 2023 Foundation Devices, Inc. <hello <at> foundationdevices.com>
+;;; Copyright © 2023 Philip McGrath <philip <at> philipmcgrath.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -3655,6 +3656,30 @@ (define-public ocaml-uutf
 string values and to directly encode characters in OCaml Buffer.t values.")
     (license license:isc)))
 
+(define-public ocaml-wtf8
+  (package
+    (name "ocaml-wtf8")
+    (version "1.0.2")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://github.com/flow/ocaml-wtf8/releases/download/"
+                    "v" version "/wtf8-v" version ".tbz"))
+              (sha256
+               (base32
+                "09ygcxxd5warkdzz17rgpidrd0pg14cy2svvnvy1hna080lzg7vp"))))
+    (build-system dune-build-system)
+    (home-page "https://github.com/flow/ocaml-wtf8")
+    (synopsis "OCaml encoder and decoder for @acronym{WTF-8}")
+    (description
+     "This library provides an OCaml encoder and decoder for @acronym{WTF-8,
+Wobbly Transformation Format---8 bit}, a superset of UTF-8 that allows
+unpaired surrogates while preserving the other well-formedness constraints of
+UTF-8.  This format is useful for interoperating with systems that use
+potentially ill-formed UTF-16, notably including ECMAScript strings and
+Windows filesystems.")
+    (license license:expat)))
+
 (define-public ocaml-uunf
   (package
     (name "ocaml-uunf")
-- 
2.41.0





Information forwarded to philip <at> philipmcgrath.com, julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 09 Nov 2023 16:29:04 GMT) Full text and rfc822 format available.

Message #32 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>
Subject: [PATCH 08/16] gnu: Add node-vlq.
Date: Thu,  9 Nov 2023 11:26:30 -0500
* gnu/packages/node-xyz.scm (node-vlq): New variable.
---
 gnu/packages/node-xyz.scm | 58 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index ee96dee767..adbac8a6cd 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1793,3 +1793,61 @@ (define-public node-copy-anything
 face of complications like special objects, symbols, and non-enumerable
 properties.")
     (license license:expat)))
+
+(define-public node-vlq
+  (package
+    (name "node-vlq")
+    (version "0.2.3") ; last version accepted by flow-remove-types ("^0.2.1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/Rich-Harris/vlq")
+             (commit (string-append "v" version))))
+       (sha256
+        (base32 "1vdrarssrwxpcngyfx050ba0gnfinzi5jn3xs4w9rnjvxngx6m8f"))
+       (snippet
+        #~(delete-file "dist/vlq.js"))
+       (file-name (git-file-name name version))))
+    (build-system node-build-system)
+    (native-inputs (list esbuild))
+    (arguments
+     (list
+      #:modules
+      `((guix build node-build-system)
+        (ice-9 match)
+        (guix build utils))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'patch-dependencies 'delete-dependencies
+            (lambda args
+              (delete-dependencies
+               '("eslint"
+                 "rollup"))))
+          (add-after 'delete-dependencies 'patch-build-script
+            (lambda args
+              (define new-build-script
+                "esbuild --bundle --platform=node --outdir=dist src/vlq.js")
+              (with-atomic-json-file-replacement "package.json"
+                (lambda (js)
+                  (match js
+                    (('@ . alist)
+                     (cons '@
+                      (map (match-lambda
+                             (("scripts" @ . alist)
+                              `("scripts" @ ,@(map (match-lambda
+                                                     (("build" . _)
+                                                      (cons "build"
+                                                            new-build-script))
+                                                     (other
+                                                      other))
+                                                   alist)))
+                             (other
+                              other))
+                           alist)))))))))))
+    (home-page "https://github.com/Rich-Harris/vlq")
+    (synopsis "JavaScript library for @acronym{VLQ} encoding and decoding")
+    (description "This package provides a JavaScript library for converting
+integers to and from Base64-encoded @acronym{VLQ, variable-length quantity}
+strings.")
+    (license license:expat)))
-- 
2.41.0





Information forwarded to philip <at> philipmcgrath.com, julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 09 Nov 2023 16:29:04 GMT) Full text and rfc822 format available.

Message #35 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>
Subject: [PATCH 12/16] gnu: js-commander: Update to 11.1.0.
Date: Thu,  9 Nov 2023 11:26:34 -0500
* gnu/packages/javascript.scm (js-commander): Update to 11.1.0.
---
 gnu/packages/javascript.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/javascript.scm b/gnu/packages/javascript.scm
index e70aa7d7e1..c62b23a4c4 100644
--- a/gnu/packages/javascript.scm
+++ b/gnu/packages/javascript.scm
@@ -373,7 +373,7 @@ (define-public js-mathjax-for-r-mathjaxr
 (define-public js-commander
   (package
     (name "js-commander")
-    (version "6.2.1")
+    (version "11.1.0")
     (source
      (origin
        (method git-fetch)
@@ -383,7 +383,7 @@ (define-public js-commander
        (file-name (git-file-name name version))
        (sha256
         (base32
-         "126m25s6mxpxmdj4aw5awz06b47r8r798lcf1c5bnmmh39cik5i1"))))
+         "1xwh85kbxj76ni41r2h0apl8mjbfcnmxzzp3vlspq30w8kwfckni"))))
     (build-system trivial-build-system)
     (arguments
      `(#:modules ((guix build utils))
-- 
2.41.0





Information forwarded to philip <at> philipmcgrath.com, julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 09 Nov 2023 16:29:05 GMT) Full text and rfc822 format available.

Message #38 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>
Subject: [PATCH 09/16] gnu: Add ocaml-flow-parser.
Date: Thu,  9 Nov 2023 11:26:31 -0500
* gnu/packages/web.scm (ocaml-flow-parser): New variable.
---

Note: `guix lint` reports that a v0.220.1 has been tagged, but this is the
version that `guix import opam` finds, and I could not readily figure out how
to get this building with v0.220.1.

 gnu/packages/web.scm | 95 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)

diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index 8e22997957..82923786f2 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -95,6 +95,7 @@ (define-module (gnu packages web)
   #:use-module (guix build-system cargo)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system copy)
+  #:use-module (guix build-system dune)
   #:use-module (guix build-system glib-or-gtk)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
@@ -172,6 +173,7 @@ (define-module (gnu packages web)
   #:use-module (gnu packages node)
   #:use-module (gnu packages node-xyz)
   #:use-module (gnu packages nss)
+  #:use-module (gnu packages ocaml)
   #:use-module (gnu packages openldap)
   #:use-module (gnu packages openstack)
   #:use-module (gnu packages package-management)
@@ -1937,6 +1939,99 @@ (define-public esbuild
 and other data, for distribution on the web.")
     (license license:expat)))
 
+(define-public ocaml-flow-parser
+  (package
+    (name "ocaml-flow-parser")
+    (version "0.159.0")
+    (outputs '("out" "js"))
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/facebook/flow")
+             (commit (string-append "v" version))))
+       (sha256
+        (base32 "1i9svf641s24nj4w6y9vvglzg29h0lr4n9a6mvwrn9psy9x1lril"))
+       (file-name (git-file-name "flow" version))))
+    (build-system dune-build-system)
+    (propagated-inputs (list ocaml-base
+                             ocaml-core-kernel
+                             ocaml-dtoa
+                             ocaml-sedlex
+                             ocaml-wtf8))
+    (native-inputs (list js-of-ocaml
+                         ocamlbuild
+                         ocaml-findlib
+                         ocaml-ounit2
+                         ocaml-ppx-deriving
+                         ocaml-ppx-gen-rec
+                         ocaml-visitors))
+    (arguments
+     (list
+      #:tests? #f ; tests need lwt_ppx
+      #:package "flow_parser"
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-before 'build 'chdir
+            (lambda args
+              (chdir "src/parser")))
+          (add-before 'build 'patch-source
+            (lambda args
+              ;; Avoid errors with newer OCaml:
+              ;; "Error (warning 16 [unerasable-optional-argument]):"
+              ;;   " this optional argument cannot be erased."
+              ;; "Error (warning 69 [unused-field]):"
+              ;;   " mutable record field buf is never mutated."
+              ;; "Error (warning 70 [missing-mli]): Cannot find interface file."
+              (substitute* "_tags"
+                (("<\\*\\.ml\\*>: warn[(]-39[)]")
+                 "<*.ml*>: warn(-16-39-70)"))
+              (substitute* "../../_tags"
+                (("<\\*\\*/\\*.ml\\*>: ")
+                 "<**/*.ml*>: warn(-69), "))
+              ;; Deprecation of Js.Unsafe.variable, Js.Error, Js.raise_js_error
+              (substitute* "flow_parser_js.ml"
+                (("Js\\.Unsafe\\.variable")
+                 "Js.Unsafe.pure_js_expr"))
+              (substitute* "flow_parser_dot_js.ml"
+                (("Js\\.Error")
+                 "Js_of_ocaml.Js_error.Exn")
+                (("Js\\.raise_js_error")
+                 "Js_of_ocaml.Js_error.raise_"))))
+          (replace 'build
+            (lambda args
+              (invoke "make"
+                      (string-append "CC=" #$(cc-for-target))
+                      "build-parser")))
+          (add-after 'build 'build-js
+            (lambda args
+              (invoke "make"
+                      (string-append "CC=" #$(cc-for-target))
+                      "js")))
+          (replace 'check
+            (lambda* (#:key tests? #:allow-other-keys)
+              (when tests?
+                (invoke "make"
+                        (string-append "CC=" #$(cc-for-target))
+                        "test-ocaml"))))
+          (replace 'install
+            (lambda args
+              (invoke "make"
+                      (string-append "CC=" #$(cc-for-target))
+                      "ocamlfind-install")))
+          (add-after 'install 'install-js
+            (lambda args
+              (install-file "flow_parser.js"
+                            (string-append #$output:js
+                                           "/share/javascript/flow")))))))
+    (properties `((upstream-name . "flow_parser")))
+    (home-page "https://flow.org")
+    (synopsis "Parser for the Flow JavaScript type system")
+    (description "Flow is a gradual type system for JavaScript.  This package
+provides the Flow parser, which is an OCaml library that can also be compiled
+to JavaScript.")
+    (license license:expat)))
+
 (define-public tinyproxy
   (package
     (name "tinyproxy")
-- 
2.41.0





Information forwarded to philip <at> philipmcgrath.com, julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 09 Nov 2023 16:29:05 GMT) Full text and rfc822 format available.

Message #41 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>
Subject: [PATCH 07/16] gnu: Add ocaml-dtoa.
Date: Thu,  9 Nov 2023 11:26:29 -0500
* gnu/packages/ocaml.scm (ocaml-dtoa): New variable.
---
 gnu/packages/ocaml.scm | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index b12c12fad5..36f349df73 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -2513,6 +2513,30 @@ (define-public ocaml4.07-fmt
                   "0gkkkj4x678vxdda4xaw2dd44qjacavsvn5nx8gydfwah6pjbkxk"))))
       (properties '()))))
 
+(define-public ocaml-dtoa
+  (package
+    (name "ocaml-dtoa")
+    (version "0.3.3")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append "https://github.com/flow/ocaml-dtoa/releases/"
+                              "download/v" version "/dtoa-" version ".tbz"))
+              (sha256
+               (base32
+                "0gpfr6iyiihmkpas542916cnhfdbrigvzwrix8jrxcljks661x6q"))))
+    (build-system dune-build-system)
+    (native-inputs (list ocaml-ounit2))
+    (home-page "https://github.com/flow/ocaml-dtoa")
+    (synopsis
+     "Efficent float to string conversion for OCaml")
+    (description
+     "This package provides functions that convert OCaml floats into strings
+quickly, accurately, and (almost always) optimally using the Grisu3 algorithm.
+The implementation was adapted from a C++ library originally developed as part
+of the V8 JavaScript engine.")
+    (license license:expat)))
+
 (define-public ocaml-astring
   (package
     (name "ocaml-astring")
-- 
2.41.0





Information forwarded to philip <at> philipmcgrath.com, julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 09 Nov 2023 16:29:06 GMT) Full text and rfc822 format available.

Message #44 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>
Subject: [PATCH 13/16] gnu: js-commander: Install as a node module.
Date: Thu,  9 Nov 2023 11:26:35 -0500
Previously, NPM would not find 'commander' when resolving dependencies.

In case anyone is using it, keep building the bundled version at
'share/javascript/commander/index.min.js', too.

* gnu/packages/javascript.scm (js-commander)[build-system]: Use
'node-build-system'.
[arguments]: Delete unpackaged 'devDependencies'.  Build bundle for
compatibility.
---
 gnu/packages/javascript.scm | 52 ++++++++++++++++++++++++++-----------
 1 file changed, 37 insertions(+), 15 deletions(-)

diff --git a/gnu/packages/javascript.scm b/gnu/packages/javascript.scm
index c62b23a4c4..97cb3b6270 100644
--- a/gnu/packages/javascript.scm
+++ b/gnu/packages/javascript.scm
@@ -7,6 +7,7 @@
 ;;; Copyright © 2021 Pierre Neidhardt <mail <at> ambrevar.xyz>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;; Copyright © 2022 Frank Pursel <frank.pursel <at> gmail.com>
+;;; Copyright © 2023 Philip McGrath <philip <at> philipmcgrath.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -42,6 +43,7 @@ (define-module (gnu packages javascript)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system minify)
+  #:use-module (guix build-system node)
   #:use-module (guix build-system trivial)
   #:use-module (guix utils))
 
@@ -384,22 +386,42 @@ (define-public js-commander
        (sha256
         (base32
          "1xwh85kbxj76ni41r2h0apl8mjbfcnmxzzp3vlspq30w8kwfckni"))))
-    (build-system trivial-build-system)
+    (build-system node-build-system)
     (arguments
-     `(#:modules ((guix build utils))
-       #:builder
-       (begin
-         (use-modules (guix build utils))
-         (chdir (assoc-ref %build-inputs "source"))
-         (let ((esbuild (search-input-file %build-inputs "/bin/esbuild"))
-               (target (string-append %output "/share/javascript/commander")))
-           (invoke esbuild
-                   "--bundle"
-                   "--minify"
-                   "--tsconfig=tsconfig.json"
-                   "--platform=node"
-                   (string-append "--outfile=" target "/index.min.js")
-                   "index.js")))))
+     (list
+      #:tests? #f ; many more dependencies
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'patch-dependencies 'delete-dependencies
+            (lambda args
+              (delete-dependencies `(;; devDependencies
+                                     "@types/jest"
+                                     "@types/node"
+                                     "@typescript-eslint/eslint-plugin"
+                                     "@typescript-eslint/parser"
+                                     "eslint"
+                                     "eslint-config-standard"
+                                     "eslint-config-standard-with-typescript"
+                                     "eslint-plugin-import"
+                                     "eslint-plugin-jest"
+                                     "eslint-plugin-n"
+                                     "eslint-plugin-promise"
+                                     "jest"
+                                     "ts-jest"
+                                     "tsd"
+                                     "typescript"))))
+          (add-after 'install 'install-compat
+            (lambda args
+              ;; This is what this package built before adopting
+              ;; node-build-system.  Does anything use it?
+              (invoke "esbuild"
+                      "--bundle"
+                      "--minify"
+                      "--platform=node"
+                      (string-append "--outfile="
+                                     #$output
+                                     "/share/javascript/commander/index.min.js")
+                      "index.js"))))))
     (native-inputs
      (list esbuild))
     (home-page "https://github.com/tj/commander.js")
-- 
2.41.0





Information forwarded to philip <at> philipmcgrath.com, julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 09 Nov 2023 16:29:06 GMT) Full text and rfc822 format available.

Message #47 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>
Subject: [PATCH 14/16] gnu: Add mftrace.
Date: Thu,  9 Nov 2023 11:26:36 -0500
* gnu/packages/fontutils.scm (mftrace): New variable.
---
 gnu/packages/fontutils.scm | 45 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gnu/packages/fontutils.scm b/gnu/packages/fontutils.scm
index 5bfdea1b27..6bab6ab7df 100644
--- a/gnu/packages/fontutils.scm
+++ b/gnu/packages/fontutils.scm
@@ -1182,6 +1182,51 @@ (define-public ttf2pt1
     (home-page "https://ttf2pt1.sourceforge.net/")
     (license license:bsd-3)))
 
+(define-public mftrace
+  (let ((commit "3b4bc2e5b8a4ae6f9c776593961b38389e62a484")
+        ;; see https://github.com/hanwen/mftrace/pull/12
+        (revision "0"))
+    (package
+      (name "mftrace")
+      (version (git-version "1.2.20" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/hanwen/mftrace")
+               (commit commit)))
+         (sha256
+          (base32 "01cg6z1z69za07wrvx1y5dnfagx4di2a9qnx25f97l6843x03s36"))
+         (file-name (git-file-name name version))))
+      (build-system gnu-build-system)
+      (native-inputs (list autoconf
+                           ;; for tests:
+                           (texlive-updmap.cfg
+                            (list texlive-cm))))
+      (propagated-inputs (list potrace lcdf-typetools))
+      (arguments
+       (list
+        ;; setting CC is needed for implicit rule
+        #:make-flags #~(list (string-append "CC=" #$(cc-for-target)))
+        #:test-target "test"
+        #:phases
+        #~(modify-phases %standard-phases
+            (replace 'bootstrap
+              (lambda args
+                (invoke "autoconf"))))))
+      (home-page "https://lilypond.org/mftrace/")
+      (synopsis "Scalable PostScript fonts for MetaFont")
+      (description "This package provides @command{mftrace}, a small Python
+program that lets you trace a TeX bitmap font into a PFA or PFB font (a
+PostScript Type 1 Scalable Font) or a @acronym{TTF,TrueType Font}.
+
+Scalable fonts offer many advantages over bitmaps, as they allow documents to
+render correctly at many printer resolutions.  Moreover, Ghostscript can
+generate much better PDFs if given scalable PostScript fonts.
+
+Versions of this program prior to 1.0.5 were called @command{pktrace}.")
+      (license license:gpl2+))))
+
 (define-public woff2
   (package
     (name "woff2")
-- 
2.41.0





Information forwarded to philip <at> philipmcgrath.com, julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 09 Nov 2023 16:29:07 GMT) Full text and rfc822 format available.

Message #50 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>
Subject: [PATCH 15/16] gnu: Add font-katex.
Date: Thu,  9 Nov 2023 11:26:37 -0500
* gnu/packages/javascript.scm (font-katex): New variable.
---
 gnu/packages/javascript.scm | 74 +++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/gnu/packages/javascript.scm b/gnu/packages/javascript.scm
index 97cb3b6270..ee7a48154c 100644
--- a/gnu/packages/javascript.scm
+++ b/gnu/packages/javascript.scm
@@ -30,9 +30,15 @@ (define-module (gnu packages javascript)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages fontutils)
   #:use-module (gnu packages java)
   #:use-module (gnu packages node)
+  #:use-module (gnu packages perl)
+  #:use-module (gnu packages python)
+  #:use-module (gnu packages python-compression)
+  #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages readline)
+  #:use-module (gnu packages tex)
   #:use-module (gnu packages uglifyjs)
   #:use-module (gnu packages web)
   #:use-module (guix gexp)
@@ -41,6 +47,7 @@ (define-module (gnu packages javascript)
   #:use-module (guix git-download)
   #:use-module (guix build-system ant)
   #:use-module (guix build-system cmake)
+  #:use-module (guix build-system copy)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system minify)
   #:use-module (guix build-system node)
@@ -372,6 +379,73 @@ (define-public js-mathjax-for-r-mathjaxr
               (base32
                "1q063l6477z285j6h5wvccp6iswvlp0jmb96sgk32sh0lf7nhknh")))))))))
 
+(define-public font-katex
+  (package
+    (name "font-katex")
+    (version "0.16.4")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+              (url "https://github.com/KaTeX/KaTeX")
+              (commit (string-append "v" version))))
+       (sha256
+        (base32
+         "0z6y2188lhfv0gk0hp4rm37g6fs99qb3ab2q3n9g76ga9dwxhw3s"))
+       (snippet
+        ;; unbundle generated files
+        #~(begin
+            (use-modules (guix build utils))
+            (delete-file "src/fontMetricsData.js")
+            (delete-file-recursively "fonts")))
+       (file-name (git-file-name "katex" version))))
+    (build-system copy-build-system)
+    (native-inputs (list (texlive-updmap.cfg
+                          (list texlive-amsfonts
+                                texlive-cm
+                                texlive-fonts-rsfs))
+                         fontforge
+                         mftrace
+                         ttfautohint
+                         perl
+                         perl-json
+                         python
+                         python-fonttools
+                         python-brotli
+                         python-zopfli
+                         which))
+    (arguments
+     (list
+      #:install-plan
+      #~`(("fonts/" "share/fonts/truetype/katex/")
+          ("src/fontMetricsData.js" "share/katex/"))
+      #:imported-modules
+      `((guix build union)
+        ,@%copy-build-system-modules)
+      #:modules
+      '((guix build copy-build-system)
+        (guix build union)
+        (guix build utils))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-before 'install 'build
+            (lambda args
+              (invoke "make" "-C" "src/fonts" "all")
+              (union-build "fonts"
+                           '("src/fonts/ttf"
+                             "src/fonts/woff"
+                             "src/fonts/woff2")
+                           #:symlink copy-file)))
+          (add-after 'build 'build-metrics
+            (lambda args
+              (with-directory-excursion "dockers/fonts"
+                ;; script assumes it is run from this directory
+                (invoke "./buildMetrics.sh")))))))
+    (home-page "https://katex.org")
+    (synopsis "Fonts for KaTeX")
+    (description "This package contains the fonts required for KaTeX.")
+    (license license:expat)))
+
 (define-public js-commander
   (package
     (name "js-commander")
-- 
2.41.0





Information forwarded to philip <at> philipmcgrath.com, julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 09 Nov 2023 16:29:07 GMT) Full text and rfc822 format available.

Message #53 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>
Subject: [PATCH 16/16] gnu: Add katex.
Date: Thu,  9 Nov 2023 11:26:38 -0500
* gnu/packages/javascript.scm (katex): New variable.
---
 gnu/packages/javascript.scm | 255 +++++++++++++++++++++++++++++++++++-
 1 file changed, 253 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/javascript.scm b/gnu/packages/javascript.scm
index ee7a48154c..76a51c22ac 100644
--- a/gnu/packages/javascript.scm
+++ b/gnu/packages/javascript.scm
@@ -32,6 +32,7 @@ (define-module (gnu packages javascript)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages fontutils)
   #:use-module (gnu packages java)
+  #:use-module (gnu packages man)
   #:use-module (gnu packages node)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages python)
@@ -382,7 +383,7 @@ (define-public js-mathjax-for-r-mathjaxr
 (define-public font-katex
   (package
     (name "font-katex")
-    (version "0.16.4")
+    (version "0.16.9")
     (source
      (origin
        (method git-fetch)
@@ -391,7 +392,7 @@ (define-public font-katex
               (commit (string-append "v" version))))
        (sha256
         (base32
-         "0z6y2188lhfv0gk0hp4rm37g6fs99qb3ab2q3n9g76ga9dwxhw3s"))
+         "1aq8n9s4r15m1fdi4h58qxal4brkafm4xsw6rpz40wqi9454kkgn"))
        (snippet
         ;; unbundle generated files
         #~(begin
@@ -446,6 +447,256 @@ (define-public font-katex
     (description "This package contains the fonts required for KaTeX.")
     (license license:expat)))
 
+(define-public katex
+  (package
+    (inherit font-katex)
+    (name "katex")
+    (outputs '("out" "dist"))
+    (build-system node-build-system)
+    (native-inputs
+     (list esbuild
+           flow-remove-types
+           help2man
+           lessc))
+    (inputs
+     (list font-katex
+           js-commander))
+    (arguments
+     (list
+      #:tests? #f ; many more dependencies
+      #:modules
+      `((guix build node-build-system)
+        (ice-9 match)
+        (srfi srfi-1)
+        (srfi srfi-26)
+        (guix build utils))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-before 'patch-dependencies 'move-sources
+            (lambda* (#:key inputs #:allow-other-keys)
+              ;; Our node-build-system doesn't properly respect the "files"
+              ;; entry in "package.json" to determine which files to install.
+              ;; This case is particularly egregious because the source
+              ;; repository also contains the source for the whole katex.org
+              ;; website.  For now, manually do what "files" ought to do.
+              (mkdir "../guix-source")
+              (copy-recursively "src" "../guix-source/src")
+              (copy-recursively "contrib" "../guix-source/contrib")
+              (for-each (cut install-file <> "../guix-source")
+                        '("README.md"
+                          "LICENSE"
+                          "package.json"
+                          "katex.js"
+                          "cli.js"))
+              (install-file
+               (search-input-file inputs "share/katex/fontMetricsData.js")
+               "../guix-source/src")
+              (chdir "../guix-source")))
+          (add-after 'move-sources 'patch-package-json
+            (lambda args
+              (with-atomic-json-file-replacement "package.json"
+                (match-lambda
+                  (('@ . alist)
+                   (cons '@
+                    (filter-map
+                     (match-lambda
+                       (((or "devDependencies" "scripts") . _)
+                        #f)
+                       ;; ESBuild can't generate Universal Module Definitions,
+                       ;; so keep our CJS separate from our browser builds:
+                       (("files" . lst)
+                        `("files" "guix-node-cjs/" ,@lst))
+                       (("main" . "dist/katex.js")
+                        `("main" . "guix-node-cjs/katex.js"))
+                       (("exports" '@ . alist)
+                        `("exports" @
+                          ,@(map (match-lambda
+                                   (("./*" . "./*")
+                                    `("./*" . "./*"))
+                                   ((lhs '@ . alist)
+                                    `(,lhs @
+                                      ,@(map (match-lambda
+                                               (("require" . ,str)
+                                                (cons
+                                                 "require"
+                                                 (string-append
+                                                  "./guix-node-cjs/"
+                                                  (substring str
+                                                             (string-length
+                                                              "./dist")))))
+                                               (other
+                                                other))
+                                             alist))))
+                                 alist)))
+                       (other
+                        other))
+                       alist)))))))
+          (add-after 'patch-dependencies 'patch-sources
+            (lambda* (#:key inputs #:allow-other-keys)
+              (substitute* "src/SourceLocation.js"
+                ;; for some reason, the + prefix isn't handled
+                ;; by flow-remove-types
+                (("[+](lexer|start|end)" _ name)
+                 name))
+              (substitute* "src/fonts.less"
+                ;; what webpack would do
+                (("@font-folder: \"\\.\\./fonts\";" orig)
+                 (string-append "@font-folder: \"fonts\"; // " orig)))
+              (define version
+                #$(package-version this-package))
+              (substitute* "src/katex.less"
+                (("@version: \"\";" orig)
+                 (string-append "@version: \"" version "\"; // " orig)))
+              (substitute* "katex.js"
+                (("version: __VERSION__," orig)
+                 (string-append "version: \"" version "\", // " orig)))))
+          (add-after 'patch-sources 'erase-types
+            (lambda args
+              (invoke "flow-remove-types"
+                      "--sourcemaps"
+                      "--out-dir" "../erased/src/"
+                      "src/")
+              (invoke  "flow-remove-types"
+                       "--sourcemaps"
+                       "--out-dir" "../erased/"
+                       "katex.js")
+              (invoke "flow-remove-types"
+                      "--sourcemaps"
+                      "--out-dir" "../erased/contrib/"
+                      "contrib/")))
+          (add-after 'erase-types 'build-js
+            (lambda args
+              (with-directory-excursion "../erased"
+                ;; ^ avoid "../erased" in generated code
+                (define (esbuild . args)
+                  (apply invoke `("esbuild"
+                                  "--bundle"
+                                  "--log-limit=0"
+                                  "--platform=neutral"
+                                  ,@args)))
+                (esbuild "--outfile=../guix-source/dist/katex.mjs"
+                         "--format=esm"
+                         "katex.js")
+                ;; Workaround  for different handling of ES6 default export
+                ;; when generating CJS:
+                (esbuild "--outfile=katex-cjs.js"
+                         "--format=cjs"
+                         "katex.js")
+                (with-output-to-file "katex-wrapper.js"
+                  (lambda ()
+                    (display
+                     "module.exports = require('./katex-cjs.js').default;\n")))
+                (esbuild "--outfile=../guix-source/guix-node-cjs/katex.js"
+                         "--format=cjs"
+                         "katex-wrapper.js")
+                (esbuild "--outfile=../guix-source/dist/katex.js"
+                         "--format=iife"
+                         "--global-name=katex"
+                         "katex-wrapper.js")
+                (esbuild "--outfile=../guix-source/dist/katex.min.js"
+                         "--minify"
+                         "--format=iife"
+                         "--global-name=katex"
+                         "katex-wrapper.js")
+                ;; Build extensions:
+                (for-each
+                 (match-lambda
+                   ((name export)
+                    ;; The copy-tex extension doesn't actually import katex,
+                    ;; but it's harmless to handle it the same way.
+                    (with-directory-excursion (string-append "contrib/" name)
+                      (esbuild (string-append "--outfile=../../../guix-source"
+                                              "/guix-node-cjs/contrib/"
+                                              name ".js")
+                               "--format=cjs"
+                               "--external:katex"
+                               (string-append name ".js"))
+                      (substitute* (string-append name ".js")
+                        (("import katex from \"katex\";")
+                         "import katex from \"../katex.mjs\";"))
+                      (esbuild (string-append "--outfile=" name ".mjs")
+                               "--format=esm"
+                               "--external:../katex.mjs"
+                               (string-append name ".js"))
+                      (install-file (string-append name ".mjs")
+                                    "../../../guix-source/dist/contrib")
+                      (substitute* (string-append name ".js")
+                        (("import katex")
+                         "// import katex"))
+                      (for-each
+                       (lambda (minify?)
+                         (apply
+                          esbuild
+                          `(,(string-append "--outfile=../../.."
+                                            "/guix-source/dist/contrib/"
+                                            name
+                                            (if minify? ".min" "")
+                                            ".js")
+                            "--format=iife"
+                            ,@(if minify?
+                                  '("--minify")
+                                  '())
+                            ,@(if export
+                                  `("--global-name=guixTmp"
+                                    ,(string-append "--banner:js=const "
+                                                    export
+                                                    " = (() => {")
+                                    "--footer:js=return guixTmp.default;\n})();")
+                                  '())
+                            ,(string-append name ".js"))))
+                       '(#t #f)))))
+                 '(("auto-render" "renderMathInElement")
+                   ("copy-tex" #f)
+                   ("mathtex-script-type" #f)
+                   ("mhchem" #f)
+                   ("render-a11y-string" "renderA11yString"))))))
+          (add-after 'build-js 'build-css
+            (lambda args
+              (invoke "lessc" "src/katex.less" "dist/katex.css")))
+          (add-after 'install 'generate-man-page
+            (lambda args
+              (invoke "help2man"
+                      "-N"
+                      "-n" "render TeX math to HTML and MathML"
+                      "--output=katex.1"
+                      (string-append #$output "/bin/katex"))
+              (install-file "katex.1"
+                            (string-append #$output "/share/man/man1"))))
+          (add-after 'generate-man-page 'install-dist
+            (lambda* (#:key inputs #:allow-other-keys)
+              ;; The CSS, fonts, etc. needed for KaTeX, plus the optional
+              ;; bundled version of the JavaScript for dynamic use in the
+              ;; browser, are in the 'dist' directory of the Node module.
+              ;; Putting them in a separate output lets them be used without
+              ;; retaining a reference to Node and the cli utility.
+              ;; In Debian, 'dist' is a symlink to /usr/share/javascript/katex:
+              ;; do likewise to help tools that may need to find it.
+              (define up-dist-dir
+                (string-append #$output:dist "/share/javascript"))
+              (define dist-dir
+                (string-append up-dist-dir "/katex"))
+              (mkdir-p up-dist-dir)
+              (with-directory-excursion
+                  (string-append #$output "/lib/node_modules/katex")
+                (rename-file "dist" dist-dir)
+                (symlink dist-dir "dist"))
+              (with-directory-excursion dist-dir
+                ;; Link the fonts to where the CSS expects them:
+                (symlink (search-input-directory inputs
+                                                 "share/fonts/truetype/katex")
+                         "fonts")
+                ;; We can't actually minify the CSS, but fake it for anything
+                ;; that may expect it. With Brotli compression, the difference
+                ;; is only about 300 bytes anyway.
+                (symlink "katex.css" "katex.min.css")))))))
+    (synopsis "Fast math typesetting for the web")
+    (description "KaTeX renders TeX math notation to HTML and/or MathML.  The
+rendered output does not depend on JavaScript, so rendering can be done
+entirely ahead-of-time using the @command{katex} command-line tool.  When
+desired, KaTeX can also be used as a JavaScript library in the browser to
+render math dynamically, and it is designed to be fast, even on pages with
+hundreds of mathematical expressions.")))
+
 (define-public js-commander
   (package
     (name "js-commander")
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Sat, 11 Nov 2023 00:57:02 GMT) Full text and rfc822 format available.

Message #56 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Liliana Marie Prikler <liliana.prikler <at> gmail.com>
To: Philip McGrath <philip <at> philipmcgrath.com>, 67019 <at> debbugs.gnu.org
Subject: Re: [PATCH 03/16] gnu: Add lessc.
Date: Sat, 11 Nov 2023 01:56:06 +0100
Am Donnerstag, dem 09.11.2023 um 11:26 -0500 schrieb Philip McGrath:
> * gnu/packages/web.scm (lessc): New variable.
> ---
>  gnu/packages/web.scm | 187
> +++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 187 insertions(+)
> 
> diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
> index 66d09700db..8e22997957 100644
> --- a/gnu/packages/web.scm
> +++ b/gnu/packages/web.scm
> @@ -64,6 +64,7 @@
>  ;;; Copyright © 2023 David Thompson <dthompson2 <at> worcester.edu>
>  ;;; Copyright © 2023 Christopher Howard
> <christopher <at> librehacker.com>
>  ;;; Copyright © 2023 Felix Lechner <felix.lechner <at> lease-up.com>
> +;;; Copyright © 2023 Philip McGrath <philip <at> philipmcgrath.com>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -98,6 +99,7 @@ (define-module (gnu packages web)
>    #:use-module (guix build-system gnu)
>    #:use-module (guix build-system go)
>    #:use-module (guix build-system meson)
> +  #:use-module (guix build-system node)
>    #:use-module (guix build-system perl)
>    #:use-module (guix build-system pyproject)
>    #:use-module (guix build-system python)
> @@ -168,6 +170,7 @@ (define-module (gnu packages web)
>    #:use-module (gnu packages ncurses)
>    #:use-module (gnu packages networking)
>    #:use-module (gnu packages node)
> +  #:use-module (gnu packages node-xyz)
>    #:use-module (gnu packages nss)
>    #:use-module (gnu packages openldap)
>    #:use-module (gnu packages openstack)
> @@ -2343,6 +2346,190 @@ (define-public sassc/libsass-3.5
>                                                     
> "0830pjcvhzxh6yixj82x5k5r1xnadjqzi16kp53213icbly0r9ma")))))))
>      (properties '((hidden? . #t)))))
>  
> +(define-public lessc
> +  (package
> +    (name "lessc")
> +    (version "4.2.0")
> +    (source
> +     (origin (method git-fetch)
> +             (uri (git-reference
> +                   (url "https://github.com/less/less.js")
> +                   (commit (string-append "v" version))))
> +             (sha256
> +              (base32
> "1b6anlafk7lnayxy3vhsi474jcdah2ffaw2qyac5s2ibxb1wmr54"))
> +             (snippet
> +              #~(begin
> +                  (use-modules (guix build utils))
> +                  (delete-file-recursively "packages/less/dist")))
> +             (file-name (git-file-name name version))))
> +    (build-system node-build-system)
> +    (native-inputs (list esbuild))
> +    (inputs (list node-copy-anything))
> +    (arguments
> +     (list
> +      #:tests? #f ; many more dependencies
> +      #:modules
> +      `((guix build node-build-system)
> +        (ice-9 match)
> +        (guix build utils))
> +      #:phases
> +      #~(modify-phases %standard-phases
> +          (add-after 'unpack 'chdir
> +            (lambda args
> +              (chdir "packages/less")))
> +          (add-after 'patch-dependencies 'delete-dependencies
> +            (lambda args
> +              (delete-dependencies
> +               '(;; dependencies
> +                 "parse-node-version" ; patched out
> +                 "tslib" ; probably not needed w/ esbuild
> +                 ;; devDependencies
> +                 "@less/test-data"
> +                 "@less/test-import-module"
> +                 "@rollup/plugin-commonjs"
> +                 "@rollup/plugin-json"
> +                 "@rollup/plugin-node-resolve"
> +                 "@typescript-eslint/eslint-plugin"
> +                 "@typescript-eslint/parser"
> +                 "benny"
> +                 "bootstrap-less-port"
> +                 "chai"
> +                 "cross-env"
> +                 "diff"
> +                 "eslint"
> +                 "fs-extra"
> +                 "git-rev"
> +                 "globby"
> +                 "grunt"
> +                 "grunt-cli"
> +                 "grunt-contrib-clean"
> +                 "grunt-contrib-connect"
> +                 "grunt-eslint"
> +                 "grunt-saucelabs"
> +                 "grunt-shell"
> +                 "html-template-tag"
> +                 "jit-grunt"
> +                 "less-plugin-autoprefix"
> +                 "less-plugin-clean-css"
> +                 "minimist"
> +                 "mocha"
> +                 "mocha-headless-chrome"
> +                 "mocha-teamcity-reporter"
> +                 "nock"
> +                 "npm-run-all"
> +                 "performance-now"
> +                 "phin"
> +                 "promise"
> +                 "read-glob"
> +                 "resolve"
> +                 "rollup"
> +                 "rollup-plugin-terser"
> +                 "rollup-plugin-typescript2"
> +                 "semver"
> +                 "shx"
> +                 "time-grunt"
> +                 "ts-node"
> +                 "typescript"
> +                 "uikit"
> +                 ;; optionalDependencies
> +                 "errno"
> +                 "graceful-fs"
> +                 "image-size"
> +                 "make-dir"
> +                 "mime"
> +                 "needle"
> +                 "source-map"))))
> +          (add-after 'delete-dependencies 'avoid-parse-node-version
> +            (lambda args
> +              (define version
> +                #$(package-version this-package))
> +              (substitute* "src/less/index.js"
> +                (("import [{] version [}]" orig)
> +                 (string-append "// " orig))
> +                (("import parseVersion from 'parse-node-version';"
> orig)
> +                 (string-append "// " orig))
> +                (("const v = parseVersion[(]`v\\$[{]version[}]`[)];"
> orig)
> +                 (string-append "// " orig))
> +                (("(version: )(\\[v\\.major, v\\.minor,
> v\\.patch],)" _ lhs rhs)
> +                 (string-append
> +                  lhs
> +                  "["
> +                  (string-join
> +                   (list-head (string-split
> +                               version (char-set-complement char-
> set:digit))
> +                              3)
> +                   ", ")
> +                  "], // "
> +                  rhs)))))
> +          (add-after 'avoid-parse-node-version 'do-not-target-es5
> +            (lambda args
> +              ;; esbuild can't compile all features to ES5
> +              (with-atomic-json-file-replacement "tsconfig.json"
> +                (match-lambda
> +                  (('@ . alist)
> +                   (cons '@
> +                    (map (match-lambda
> +                           (("compilerOptions" '@ . alist)
> +                            `("scripts" @ ,@(filter (match-lambda
> +                                                      (("target"
> "ES5")
> +                                                       #f)
> +                                                      (_
> +                                                       #t))
> +                                                    alist)))
> +                           (other
> +                            other))
> +                         alist)))))))
> +          (add-after 'do-not-target-es5 'patch-build-script
> +            (lambda args
> +              (define new-build-script
> +                (string-join
> +                 `("esbuild"
> +                   "--platform=node"
> +                   "--format=cjs"
> +                   "--outdir=lib"
> +                   ,@(find-files "src/less" "\\.js$")
> +                   ,@(find-files "src/less-node" "\\.js$"))))
> +              (with-atomic-json-file-replacement "package.json"
> +                (match-lambda
> +                  (('@ . alist)
> +                   (cons '@
> +                    (map (match-lambda
> +                           (("scripts" @ . alist)
> +                            `("scripts" @ ,@(map (match-lambda
> +                                                   (("build" . _)
> +                                                    (cons "build"
> +                                                          new-build-
> script))
> +                                                   (other
> +                                                    other))
> +                                                 alist)))
> +                           (other
> +                            other))
> +                         alist)))))))
Can we somehow save a bit of horizontal real-estate here?  Same goes
for 1 and 2.
> +          (add-after 'build 'build-browser
> +            (lambda args
> +              (invoke "esbuild"
> +                      "--bundle"
> +                      "--platform=browser"
> +                      "--format=cjs"
> +                      "--outfile=dist/less.js"
> +                      "src/less-browser/bootstrap.js")
> +              (invoke "esbuild"
> +                      "--bundle"
> +                      "--minify"
> +                      "--sourcemap"
> +                      "--platform=browser"
> +                      "--format=cjs"
> +                      "--outfile=dist/less.min.js"
> +                      "src/less-browser/bootstrap.js"))))))
> +    (home-page "https://lesscss.org")
> +    (synopsis "Compiler for @acronym{Less} @acronym{CSS} language
> extension")
> +    ;; XXX: @abbr{} seems better for Less (which is always
> capitalized that
> +    ;; way), but it is rejected as invalid Texinfo markup here.
> +    (description "@acronym{Less, Leaner Style Sheets} is a
> +backwards-compatible language extension for @acronym{CSS}.  This
> package
> +provides @command{lessc}, which compiles Less files to plain
> @acronym{CSS}.")
> +    (license license:asl2.0)))
> +
IMHO it doesn't make sense to type @acronym without the expansion.

Cheers

Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Wed, 15 Nov 2023 19:36:02 GMT) Full text and rfc822 format available.

Message #59 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: Liliana Marie Prikler <liliana.prikler <at> gmail.com>, 67019 <at> debbugs.gnu.org
Subject: Re: [PATCH 03/16] gnu: Add lessc.
Date: Wed, 15 Nov 2023 14:35:31 -0500
Hi,

Thanks for taking a look at this!

On 11/10/23 19:56, Liliana Marie Prikler wrote:
> Am Donnerstag, dem 09.11.2023 um 11:26 -0500 schrieb Philip McGrath:
>> * gnu/packages/web.scm (lessc): New variable.
>>
>> [...]
>>
>> +          (add-after 'avoid-parse-node-version 'do-not-target-es5
>> +            (lambda args
>> +              ;; esbuild can't compile all features to ES5
>> +              (with-atomic-json-file-replacement "tsconfig.json"
>> +                (match-lambda
>> +                  (('@ . alist)
>> +                   (cons '@
>> +                    (map (match-lambda
>> +                           (("compilerOptions" '@ . alist)
>> +                            `("scripts" @ ,@(filter (match-lambda
>> +                                                      (("target"
>> "ES5")
>> +                                                       #f)
>> +                                                      (_
>> +                                                       #t))
>> +                                                    alist)))
>> +                           (other
>> +                            other))
>> +                         alist)))))))
>> +          (add-after 'do-not-target-es5 'patch-build-script
>> +            (lambda args
>> +              (define new-build-script
>> +                (string-join
>> +                 `("esbuild"
>> +                   "--platform=node"
>> +                   "--format=cjs"
>> +                   "--outdir=lib"
>> +                   ,@(find-files "src/less" "\\.js$")
>> +                   ,@(find-files "src/less-node" "\\.js$"))))
>> +              (with-atomic-json-file-replacement "package.json"
>> +                (match-lambda
>> +                  (('@ . alist)
>> +                   (cons '@
>> +                    (map (match-lambda
>> +                           (("scripts" @ . alist)
>> +                            `("scripts" @ ,@(map (match-lambda
>> +                                                   (("build" . _)
>> +                                                    (cons "build"
>> +                                                          new-build-
>> script))
>> +                                                   (other
>> +                                                    other))
>> +                                                 alist)))
>> +                           (other
>> +                            other))
>> +                         alist)))))))
> Can we somehow save a bit of horizontal real-estate here?  Same goes
> for 1 and 2.

To clarify, do you mean vertical or horizontal?

The long list of dependencies to delete does take a *lot* of vertical 
space, especially in this patch. The obvious alternative would be to put 
more than one dependency on the same line. I'm not opposed to that, but 
it would deviate from normal style and could make future diffs less clear.

For horizontal space, I don't really like any of the alternatives I've 
thought of. The culprit in each case seems to be the three 
`match-lambda`s under `with-atomic-json-file-replacement`. (Specifically 
in do-not-target-es5, I guess the innermost one could be replaced with 
just `remove`, which might help a little.)

In normal programming, I'd want to abstract the three patch-build-script 
phases into a helper function that would take the new-build-script 
string as an argument, but that's a bit awkward to do with build-side 
code in Guix. Putting it in guix/build/node-build-system.scm (like 
delete-dependencies) would trigger a lot of rebuilds that seem hard to 
justify. It could be done as a gexp-producing function, but 
node-is-what, node-copy-anything, and lessc aren't in the same file: I 
guess the arguments field is delayed, so maybe it wouldn't create a 
cyclic dependency issue, but that seemed to open a whole new can of worms.

(Making e.g. `jsobject-update*` from guix/build/node-build-system.scm 
public would also help, but I have no desire to revisit that.)

Obviously it would be possible, within each G-expression, to lift one of 
the `match-lambda`s (probably the innermost one) to a local definition, 
but IMO that would make the structure of the code less obviously 
correspond to the structure of the JSON being transformed.

I could also imagine breaking these lines:

>> +                           (("scripts" @ . alist)
>> +                            `("scripts" @ ,@(map (match-lambda

instead as:

>> +                           (("scripts"
>> +                             @ . alist)
>> +                            `("scripts"
>> +                              @ ,@(map (match-lambda

but that doesn't seem like much of an improvement to me.


>> +    (synopsis "Compiler for @acronym{Less} @acronym{CSS} language
>> extension")
>> +    ;; XXX: @abbr{} seems better for Less (which is always
>> capitalized that
>> +    ;; way), but it is rejected as invalid Texinfo markup here.
>> +    (description "@acronym{Less, Leaner Style Sheets} is a
>> +backwards-compatible language extension for @acronym{CSS}.  This
>> package
>> +provides @command{lessc}, which compiles Less files to plain
>> @acronym{CSS}.")
>> +    (license license:asl2.0)))
>> +
> IMHO it doesn't make sense to type @acronym without the expansion.
> 

I don't have a strong opinion on this, and I only know the tiny amount 
of Texinfo I've picked up for Guix. I inferred from the fact that the 
one-argument version of @acronym{} exists that it should be used when 
applicable. I know that some typographical conventions handle capital 
letters and punctuation in acronyms specially, which would be one reason 
for @acronym{} to exist, but maybe that isn't relevant?

Philip




Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Wed, 15 Nov 2023 20:25:02 GMT) Full text and rfc822 format available.

Message #62 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Liliana Marie Prikler <liliana.prikler <at> gmail.com>
To: Philip McGrath <philip <at> philipmcgrath.com>, 67019 <at> debbugs.gnu.org
Subject: Re: [PATCH 03/16] gnu: Add lessc.
Date: Wed, 15 Nov 2023 21:23:57 +0100
Am Mittwoch, dem 15.11.2023 um 14:35 -0500 schrieb Philip McGrath:
> Hi,
> 
> Thanks for taking a look at this!
> 
> On 11/10/23 19:56, Liliana Marie Prikler wrote:
> > Am Donnerstag, dem 09.11.2023 um 11:26 -0500 schrieb Philip
> > McGrath:
> > > * gnu/packages/web.scm (lessc): New variable.
> > > 
> > > [...]
>  >>
> > > +          (add-after 'avoid-parse-node-version 'do-not-target-
> > > es5
> > > +            (lambda args
> > > +              ;; esbuild can't compile all features to ES5
> > > +              (with-atomic-json-file-replacement "tsconfig.json"
> > > +                (match-lambda
> > > +                  (('@ . alist)
> > > +                   (cons '@
> > > +                    (map (match-lambda
> > > +                           (("compilerOptions" '@ . alist)
> > > +                            `("scripts" @ ,@(filter (match-
> > > lambda
> > > +                                                      (("target"
> > > "ES5")
> > > +                                                       #f)
> > > +                                                      (_
> > > +                                                       #t))
> > > +                                                    alist)))
> > > +                           (other
> > > +                            other))
> > > +                         alist)))))))
> > > +          (add-after 'do-not-target-es5 'patch-build-script
> > > +            (lambda args
> > > +              (define new-build-script
> > > +                (string-join
> > > +                 `("esbuild"
> > > +                   "--platform=node"
> > > +                   "--format=cjs"
> > > +                   "--outdir=lib"
> > > +                   ,@(find-files "src/less" "\\.js$")
> > > +                   ,@(find-files "src/less-node" "\\.js$"))))
> > > +              (with-atomic-json-file-replacement "package.json"
> > > +                (match-lambda
> > > +                  (('@ . alist)
> > > +                   (cons '@
> > > +                    (map (match-lambda
> > > +                           (("scripts" @ . alist)
> > > +                            `("scripts" @ ,@(map (match-lambda
> > > +                                                   (("build" .
> > > _)
> > > +                                                    (cons
> > > "build"
> > > +                                                          new-
> > > build-
> > > script))
> > > +                                                   (other
> > > +                                                    other))
> > > +                                                 alist)))
> > > +                           (other
> > > +                            other))
> > > +                         alist)))))))
> > Can we somehow save a bit of horizontal real-estate here?  Same
> > goes
> > for 1 and 2.
> 
> To clarify, do you mean vertical or horizontal?
I do mean horizontal.

> The long list of dependencies to delete does take a *lot* of vertical
> space, especially in this patch. The obvious alternative would be to
> put  more than one dependency on the same line. I'm not opposed to
> that, but it would deviate from normal style and could make future
> diffs less clear.
Speaking of which, can we has regexps here?

> For horizontal space, I don't really like any of the alternatives
> I've thought of. The culprit in each case seems to be the three 
> `match-lambda`s under `with-atomic-json-file-replacement`.
> (Specifically in do-not-target-es5, I guess the innermost one could
> be replaced with just `remove`, which might help a little.)
> 
> In normal programming, I'd want to abstract the three patch-build-
> script phases into a helper function that would take the new-build-
> script string as an argument, but that's a bit awkward to do with
> build-side code in Guix. Putting it in guix/build/node-build-
> system.scm (like 
> delete-dependencies) would trigger a lot of rebuilds that seem hard
> to justify. It could be done as a gexp-producing function, but 
> node-is-what, node-copy-anything, and lessc aren't in the same file:
> I guess the arguments field is delayed, so maybe it wouldn't create a
> cyclic dependency issue, but that seemed to open a whole new can of
> worms.
> 
> (Making e.g. `jsobject-update*` from guix/build/node-build-system.scm
> public would also help, but I have no desire to revisit that.)
I think this is valid criticism of our node-build-system to perhaps
take to another thread.

> Obviously it would be possible, within each G-expression, to lift one
> of the `match-lambda`s (probably the innermost one) to a local
> definition, but IMO that would make the structure of the code less
> obviously correspond to the structure of the JSON being transformed.
> 
> I could also imagine breaking these lines:
> 
>  >> +                           (("scripts" @ . alist)
>  >> +                            `("scripts" @ ,@(map (match-lambda
> 
> instead as:
> 
>  >> +                           (("scripts"
>  >> +                             @ . alist)
>  >> +                            `("scripts"
>  >> +                              @ ,@(map (match-lambda
> 
> but that doesn't seem like much of an improvement to me.
But what about breaking lines before (match-lambda?  That ought to at
least give us enough to get (_ #f) onto a single line, no?

> > > +    (synopsis "Compiler for @acronym{Less} @acronym{CSS}
> > > language
> > > extension")
> > > +    ;; XXX: @abbr{} seems better for Less (which is always
> > > capitalized that
> > > +    ;; way), but it is rejected as invalid Texinfo markup here.
> > > +    (description "@acronym{Less, Leaner Style Sheets} is a
> > > +backwards-compatible language extension for @acronym{CSS}.  This
> > > package
> > > +provides @command{lessc}, which compiles Less files to plain
> > > @acronym{CSS}.")
> > > +    (license license:asl2.0)))
> > > +
> > IMHO it doesn't make sense to type @acronym without the expansion.
> > 
> 
> I don't have a strong opinion on this, and I only know the tiny
> amount of Texinfo I've picked up for Guix. I inferred from the fact
> that the one-argument version of @acronym{} exists that it should be
> used when applicable. I know that some typographical conventions
> handle capital letters and punctuation in acronyms specially, which
> would be one reason for @acronym{} to exist, but maybe that isn't
> relevant?
Yeah, CAPS aren't relevant here.  The @acronym is typically for giving
meaning to an acronym, but if said meaning has already been given once,
repeating it would not make sense.

Some quotes from the manual:

>    - In Texinfo, an acronym (but not an abbreviation) should consist
>      only of capital letters and periods, no lowercase.
>    [...]
>    - It usually turns out to be quite difficult and/or time-consuming
> to consistently use '@acronym' for all sequences of uppercase
>      letters.  Furthermore, it looks strange for some acronyms to be
>      in the normal font size and others to be smaller.  Thus, a
>      simpler approach you may wish to consider is to avoid '@acronym'
>      and just typeset everything as normal text in all capitals:
>      'GNU', producing the output 'GNU'.
> 
>    - In general, it's not essential to use either of these commands
>      for all abbreviations; use your judgment.  Text is perfectly
>      readable without them.

Cheers

Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 00:04:02 GMT) Full text and rfc822 format available.

Message #65 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: Liliana Marie Prikler <liliana.prikler <at> gmail.com>, 67019 <at> debbugs.gnu.org
Subject: Re: [PATCH 03/16] gnu: Add lessc.
Date: Wed, 15 Nov 2023 19:03:26 -0500
Hi,

On 11/15/23 15:23, Liliana Marie Prikler wrote:
> Am Mittwoch, dem 15.11.2023 um 14:35 -0500 schrieb Philip McGrath:
>> On 11/10/23 19:56, Liliana Marie Prikler wrote:
>>> Am Donnerstag, dem 09.11.2023 um 11:26 -0500 schrieb Philip
>>> McGrath:
>>>> * gnu/packages/web.scm (lessc): New variable.
>>>>
>>>> [...]
>>   >>
>>>> +          (add-after 'avoid-parse-node-version 'do-not-target-
>>>> es5
>>>> +            (lambda args
>>>> +              ;; esbuild can't compile all features to ES5
>>>> +              (with-atomic-json-file-replacement "tsconfig.json"
>>>> +                (match-lambda
>>>> +                  (('@ . alist)
>>>> +                   (cons '@
>>>> +                    (map (match-lambda
>>>> +                           (("compilerOptions" '@ . alist)
>>>> +                            `("scripts" @ ,@(filter (match-
>>>> lambda
>>>> +                                                      (("target"
>>>> "ES5")
>>>> +                                                       #f)
>>>> +                                                      (_
>>>> +                                                       #t))
>>>> +                                                    alist)))
>>>> +                           (other
>>>> +                            other))
>>>> +                         alist)))))))
>>>> +          (add-after 'do-not-target-es5 'patch-build-script
>>>> +            (lambda args
>>>> +              (define new-build-script
>>>> +                (string-join
>>>> +                 `("esbuild"
>>>> +                   "--platform=node"
>>>> +                   "--format=cjs"
>>>> +                   "--outdir=lib"
>>>> +                   ,@(find-files "src/less" "\\.js$")
>>>> +                   ,@(find-files "src/less-node" "\\.js$"))))
>>>> +              (with-atomic-json-file-replacement "package.json"
>>>> +                (match-lambda
>>>> +                  (('@ . alist)
>>>> +                   (cons '@
>>>> +                    (map (match-lambda
>>>> +                           (("scripts" @ . alist)
>>>> +                            `("scripts" @ ,@(map (match-lambda
>>>> +                                                   (("build" .
>>>> _)
>>>> +                                                    (cons
>>>> "build"
>>>> +                                                          new-
>>>> build-
>>>> script))
>>>> +                                                   (other
>>>> +                                                    other))
>>>> +                                                 alist)))
>>>> +                           (other
>>>> +                            other))
>>>> +                         alist)))))))
>>> Can we somehow save a bit of horizontal real-estate here?  Same
>>> goes
>>> for 1 and 2.
>>
>> To clarify, do you mean vertical or horizontal?
> I do mean horizontal.
> 
> [...]
>
>>
>> I could also imagine breaking these lines:
>>
>>   >> +                           (("scripts" @ . alist)
>>   >> +                            `("scripts" @ ,@(map (match-lambda
>>
>> instead as:
>>
>>   >> +                           (("scripts"
>>   >> +                             @ . alist)
>>   >> +                            `("scripts"
>>   >> +                              @ ,@(map (match-lambda
>>
>> but that doesn't seem like much of an improvement to me.
> But what about breaking lines before (match-lambda?  That ought to at
> least give us enough to get (_ #f) onto a single line, no?
> 

Maybe I'm confused: there isn't (_ #f) anywhere. There is currently 
enough space to put (other other) on a single line, but I thought it was 
better style to put a newline between the match pattern and the 
expression, especially when the pattern is not _.

Breaking before match-lambda gets enough space to put (cons "build" 
new-build-script) on a single line, but I don't think it looks better 
overall:

>           (add-after 'do-not-target-es5 'patch-build-script
>             (lambda args
>               (define new-build-script
>                 (string-join
>                  `("esbuild"
>                    "--platform=node"
>                    "--format=cjs"
>                    "--outdir=lib"
>                    ,@(find-files "src/less" "\\.js$")
>                    ,@(find-files "src/less-node" "\\.js$"))))
>               (with-atomic-json-file-replacement "package.json"
>                 (match-lambda
>                   (('@ . alist)
>                    (cons '@
>                     (map
>                      (match-lambda
>                        (("scripts" @ . alist)
>                         `("scripts" @ ,@(map
>                                          (match-lambda
>                                            (("build" . _)
>                                             (cons "build" new-build-script))
>                                            (other
>                                             other))
>                                          alist)))
>                        (other
>                         other))
>                      alist)))))))

Using delete in do-not-target-es5 does seem like a minor improvement:

>           (add-after 'avoid-parse-node-version 'do-not-target-es5
>             (lambda args
>               ;; esbuild can't compile all features to ES5
>               (with-atomic-json-file-replacement "tsconfig.json"
>                 (match-lambda
>                   (('@ . alist)
>                    (cons '@
>                     (map (match-lambda
>                            (("compilerOptions" '@ . alist)
>                             `("scripts" @ ,@(delete '("target" "ES5")
>                                                     alist)))
>                            (other
>                             other))
>                          alist)))))))

Philip




Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 01:18:01 GMT) Full text and rfc822 format available.

Message #68 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Liliana Marie Prikler <liliana.prikler <at> gmail.com>
To: Philip McGrath <philip <at> philipmcgrath.com>, 67019 <at> debbugs.gnu.org
Subject: Re: [PATCH 03/16] gnu: Add lessc.
Date: Thu, 16 Nov 2023 02:17:38 +0100
Hi,

Am Mittwoch, dem 15.11.2023 um 19:03 -0500 schrieb Philip McGrath:
> Hi,
> 
> On 11/15/23 15:23, Liliana Marie Prikler wrote:
> > Am Mittwoch, dem 15.11.2023 um 14:35 -0500 schrieb Philip McGrath:
> > > [...]
> > > 
> > > To clarify, do you mean vertical or horizontal?
> > I do mean horizontal.
> > 
> > [...]
>  >
> > > 
> > > I could also imagine breaking these lines:
> > > 
> > >   >> +                           (("scripts" @ . alist)
> > >   >> +                            `("scripts" @ ,@(map (match-
> > > lambda
> > > 
> > > instead as:
> > > 
> > >   >> +                           (("scripts"
> > >   >> +                             @ . alist)
> > >   >> +                            `("scripts"
> > >   >> +                              @ ,@(map (match-lambda
> > > 
> > > but that doesn't seem like much of an improvement to me.
> > But what about breaking lines before (match-lambda?  That ought to
> > at least give us enough to get (_ #f) onto a single line, no?
> > 
> 
> Maybe I'm confused: there isn't (_ #f) anywhere.
There was a (_ #t) in the filter, though :)
In any case, such trivial matches should fit onto one line imho.

> There is currently enough space to put (other other) on a single
> line, but I thought it was better style to put a newline between the
> match pattern and the expression, especially when the pattern is not
> _.
IMHO, this only makes sense for non-trivial replacements.  If you keep
some piece of data as-is, you more often than not don't want to draw
attention to this implementation detail by blowing up its size.

> Breaking before match-lambda gets enough space to put (cons "build" 
> new-build-script) on a single line, but I don't think it looks better
> overall:
> 
> >           (add-after 'do-not-target-es5 'patch-build-script
> >             (lambda args
> >               (define new-build-script
> >                 (string-join
> >                  `("esbuild"
> >                    "--platform=node"
> >                    "--format=cjs"
> >                    "--outdir=lib"
> >                    ,@(find-files "src/less" "\\.js$")
> >                    ,@(find-files "src/less-node" "\\.js$"))))
> >               (with-atomic-json-file-replacement "package.json"
> >                 (match-lambda
> >                   (('@ . alist)
> >                    (cons '@
> >                     (map
> >                      (match-lambda
> >                        (("scripts" @ . alist)
> >                         `("scripts" @ ,@(map
> >                                          (match-lambda
> >                                            (("build" . _)
> >                                             (cons "build" new-
> > build-script))
> >                                            (other
> >                                             other))
> >                                          alist)))
> >                        (other
> >                         other))
> >                      alist)))))))
> 
> Using delete in do-not-target-es5 does seem like a minor improvement:
> 
> >           (add-after 'avoid-parse-node-version 'do-not-target-es5
> >             (lambda args
> >               ;; esbuild can't compile all features to ES5
> >               (with-atomic-json-file-replacement "tsconfig.json"
> >                 (match-lambda
> >                   (('@ . alist)
> >                    (cons '@
> >                     (map (match-lambda
> >                            (("compilerOptions" '@ . alist)
> >                             `("scripts" @ ,@(delete '("target"
> > "ES5")
> >                                                     alist)))
> >                            (other
> >                             other))
> >                          alist)))))))
Fun fact, you could inline this delete into the "compilerOptions" line
– or sexp at least, by using (= (cute delete '("target" "ES5") <>)
options).  That being said, it's not necessary to do so; the delete you
currently have works fine.

Anyhow, since this isn't a clean alist, I'd use a different variable
name, perhaps "options"?

Cheers

Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 01:53:01 GMT) Full text and rfc822 format available.

Message #71 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: Liliana Marie Prikler <liliana.prikler <at> gmail.com>, 67019 <at> debbugs.gnu.org
Subject: Re: [PATCH 03/16] gnu: Add lessc.
Date: Wed, 15 Nov 2023 20:51:49 -0500
Hi,

On 11/15/23 20:17, Liliana Marie Prikler wrote:
> Hi,
> 
> Am Mittwoch, dem 15.11.2023 um 19:03 -0500 schrieb Philip McGrath:
>> Hi,
>>
>> On 11/15/23 15:23, Liliana Marie Prikler wrote:
>>> Am Mittwoch, dem 15.11.2023 um 14:35 -0500 schrieb Philip McGrath:
>>>> [...]
>>>>
>>>> To clarify, do you mean vertical or horizontal?
>>> I do mean horizontal.
>>>
>>> [...]
>>   >
>>>>
>>>> I could also imagine breaking these lines:
>>>>
>>>>    >> +                           (("scripts" @ . alist)
>>>>    >> +                            `("scripts" @ ,@(map (match-
>>>> lambda
>>>>
>>>> instead as:
>>>>
>>>>    >> +                           (("scripts"
>>>>    >> +                             @ . alist)
>>>>    >> +                            `("scripts"
>>>>    >> +                              @ ,@(map (match-lambda
>>>>
>>>> but that doesn't seem like much of an improvement to me.
>>> But what about breaking lines before (match-lambda?  That ought to
>>> at least give us enough to get (_ #f) onto a single line, no?
>>>
>>
>> Maybe I'm confused: there isn't (_ #f) anywhere.
> There was a (_ #t) in the filter, though :)
> In any case, such trivial matches should fit onto one line imho.
> 
>> There is currently enough space to put (other other) on a single
>> line, but I thought it was better style to put a newline between the
>> match pattern and the expression, especially when the pattern is not
>> _.
> IMHO, this only makes sense for non-trivial replacements.  If you keep
> some piece of data as-is, you more often than not don't want to draw
> attention to this implementation detail by blowing up its size.
> 

I don't think the content of the right-hand side is relevant: in my 
view, the purpose of the newline is to make the shape of the clause 
clear, especially given that the left-hand side is not an expression. 
The fact that Guix's style forbids square brackets makes the newline 
even more necessary, IMO.

In any case, what arrangement of whitespace in patch-build-script would 
unblock this patch series for you?

>>
>> Using delete in do-not-target-es5 does seem like a minor improvement:
>>
>>>            (add-after 'avoid-parse-node-version 'do-not-target-es5
>>>              (lambda args
>>>                ;; esbuild can't compile all features to ES5
>>>                (with-atomic-json-file-replacement "tsconfig.json"
>>>                  (match-lambda
>>>                    (('@ . alist)
>>>                     (cons '@
>>>                      (map (match-lambda
>>>                             (("compilerOptions" '@ . alist)
>>>                              `("scripts" @ ,@(delete '("target"
>>> "ES5")
>>>                                                      alist)))
>>>                             (other
>>>                              other))
>>>                           alist)))))))
> Fun fact, you could inline this delete into the "compilerOptions" line
> – or sexp at least, by using (= (cute delete '("target" "ES5") <>)
> options).  That being said, it's not necessary to do so; the delete you
> currently have works fine.
> 
> Anyhow, since this isn't a clean alist, I'd use a different variable
> name, perhaps "options"?
> 

All of the variables named alist are, in fact, alists.

I noticed, though, that this was inadvertently renaming 
"compilerOptions" to "scripts" and thus effectively patching out all the 
other options, too: things seemed to work regardless, but here's a 
correct version:

>           (add-after 'avoid-parse-node-version 'do-not-target-es5
>             (lambda args
>               ;; esbuild can't compile all features to ES5
>               (with-atomic-json-file-replacement "tsconfig.json"
>                 (match-lambda
>                   (('@ . alist)
>                    (cons '@
>                     (map (match-lambda
>                            (("compilerOptions" '@ . alist)
>                             `("compilerOptions" @ ,@(delete '("target" . "ES5")
>                                                             alist)))
>                            (other
>                             other))
>                          alist)))))))

Philip




Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 07:19:02 GMT) Full text and rfc822 format available.

Message #74 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Liliana Marie Prikler <liliana.prikler <at> gmail.com>
To: Philip McGrath <philip <at> philipmcgrath.com>, 67019 <at> debbugs.gnu.org
Subject: Re: [PATCH 03/16] gnu: Add lessc.
Date: Thu, 16 Nov 2023 08:18:27 +0100
Hi,

Am Mittwoch, dem 15.11.2023 um 20:51 -0500 schrieb Philip McGrath:
> Hi,
> 
> On 11/15/23 20:17, Liliana Marie Prikler wrote:
> > Hi,
> > 
> > Am Mittwoch, dem 15.11.2023 um 19:03 -0500 schrieb Philip McGrath:
> > > Hi,
> > > 
> > > On 11/15/23 15:23, Liliana Marie Prikler wrote:
> > > > Am Mittwoch, dem 15.11.2023 um 14:35 -0500 schrieb Philip
> > > > McGrath:
> > > > > [...]
> > > > > 
> > > > > To clarify, do you mean vertical or horizontal?
> > > > I do mean horizontal.
> > > > 
> > > > [...]
> > >   >
> > > > > 
> > > > > I could also imagine breaking these lines:
> > > > > 
> > > > >    >> +                           (("scripts" @ . alist)
> > > > >    >> +                            `("scripts" @ ,@(map
> > > > > (match-
> > > > > lambda
> > > > > 
> > > > > instead as:
> > > > > 
> > > > >    >> +                           (("scripts"
> > > > >    >> +                             @ . alist)
> > > > >    >> +                            `("scripts"
> > > > >    >> +                              @ ,@(map (match-lambda
> > > > > 
> > > > > but that doesn't seem like much of an improvement to me.
> > > > But what about breaking lines before (match-lambda?  That ought
> > > > to
> > > > at least give us enough to get (_ #f) onto a single line, no?
> > > > 
> > > 
> > > Maybe I'm confused: there isn't (_ #f) anywhere.
> > There was a (_ #t) in the filter, though :)
> > In any case, such trivial matches should fit onto one line imho.
> > 
> > > There is currently enough space to put (other other) on a single
> > > line, but I thought it was better style to put a newline between
> > > the
> > > match pattern and the expression, especially when the pattern is
> > > not
> > > _.
> > IMHO, this only makes sense for non-trivial replacements.  If you
> > keep
> > some piece of data as-is, you more often than not don't want to
> > draw
> > attention to this implementation detail by blowing up its size.
> > 
> 
> I don't think the content of the right-hand side is relevant: in my 
> view, the purpose of the newline is to make the shape of the clause 
> clear, especially given that the left-hand side is not an expression.
> The fact that Guix's style forbids square brackets makes the newline 
> even more necessary, IMO.
> 
> In any case, what arrangement of whitespace in patch-build-script
> would unblock this patch series for you?
If push comes to shove, I can rearrange the whitespace as I want, given
my committer privileges; it's just that you've complained about me
abusing them before, so I don't really want to.

Anyhow, stuff like (_ #t), (_ #f), (x x), … should all fit onto a
single line.

> > > 
> > > Using delete in do-not-target-es5 does seem like a minor
> > > improvement:
> > > 
> > > >            (add-after 'avoid-parse-node-version 'do-not-target-
> > > > es5
> > > >              (lambda args
> > > >                ;; esbuild can't compile all features to ES5
> > > >                (with-atomic-json-file-replacement
> > > > "tsconfig.json"
> > > >                  (match-lambda
> > > >                    (('@ . alist)
> > > >                     (cons '@
> > > >                      (map (match-lambda
> > > >                             (("compilerOptions" '@ . alist)
> > > >                              `("scripts" @ ,@(delete '("target"
> > > > "ES5")
> > > >                                                      alist)))
> > > >                             (other
> > > >                              other))
> > > >                           alist)))))))
> > Fun fact, you could inline this delete into the "compilerOptions"
> > line  or sexp at least, by using (= (cute delete '("target" "ES5")
> > <>) options).  That being said, it's not necessary to do so; the
> > delete you currently have works fine.
> > 
> > Anyhow, since this isn't a clean alist, I'd use a different
> > variable name, perhaps "options"?
> 
> All of the variables named alist are, in fact, alists.
TIL.

> I noticed, though, that this was inadvertently renaming 
> "compilerOptions" to "scripts" and thus effectively patching out all
> the other options, too: things seemed to work regardless, but here's
> a correct version:
> 
> >           (add-after 'avoid-parse-node-version 'do-not-target-es5
> >             (lambda args
> >               ;; esbuild can't compile all features to ES5
> >               (with-atomic-json-file-replacement "tsconfig.json"
> >                 (match-lambda
> >                   (('@ . alist)
> >                    (cons '@
> >                     (map (match-lambda
> >                            (("compilerOptions" '@ . alist)
> >                             `("compilerOptions" @ ,@(delete
> > '("target" . "ES5")
> >                                                            
> > alist)))
> >                            (other
> >                             other))
> >                          alist)))))))
Now that looks like a proper alist to me :)

Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 19:17:01 GMT) Full text and rfc822 format available.

Message #77 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Subject: [PATCH v2 00/16] gnu: Add KaTeX, lessc, and flow-remove-types.
Date: Thu, 16 Nov 2023 14:15:38 -0500
Hi,

Here is a v2.

Other than rebasing, the only change is in 03/16, in which I've fixed
do-not-target-es5 as I explained in <https://issues.guix.gnu.org/67019#20>.

I've not made other whitespace changes, as I still prefer this to the other
options we've discussed, but, Liliana, feel free to adjust it to your liking
if you feel this is otherwise ready to merge.

Philip

Philip McGrath (16):
  gnu: Add node-is-what.
  gnu: Add node-copy-anything.
  gnu: Add lessc.
  gnu: Add ocaml-wtf8.
  gnu: Add ocaml-visitors.
  gnu: Add ocaml-ppx-gen-rec.
  gnu: Add ocaml-dtoa.
  gnu: Add node-vlq.
  gnu: Add ocaml-flow-parser.
  gnu: Add node-flow-parser.
  gnu: Add flow-remove-types.
  gnu: js-commander: Update to 11.1.0.
  gnu: js-commander: Install as a node module.
  gnu: Add mftrace.
  gnu: Add font-katex.
  gnu: Add katex.

 gnu/packages/fontutils.scm  |  45 +++++
 gnu/packages/javascript.scm | 381 ++++++++++++++++++++++++++++++++++--
 gnu/packages/node-xyz.scm   | 220 +++++++++++++++++++++
 gnu/packages/ocaml.scm      |  99 ++++++++++
 gnu/packages/web.scm        | 381 ++++++++++++++++++++++++++++++++++++
 5 files changed, 1109 insertions(+), 17 deletions(-)


base-commit: fc6bdaad57bf91609849623c5f485403c030cb49
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 19:17:02 GMT) Full text and rfc822 format available.

Message #80 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Subject: [PATCH v2 01/16] gnu: Add node-is-what.
Date: Thu, 16 Nov 2023 14:15:39 -0500
* gnu/packages/node-xyz.scm (node-is-what): New variable.
---
 gnu/packages/node-xyz.scm | 81 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 6c16417309..49760ded2b 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1631,3 +1631,84 @@ (define-public node-yazl
 @item Prefer to open input files one at a time than all at once.
 @end enumerate")
     (license license:expat)))
+
+(define-public node-is-what
+  (package
+    (name "node-is-what")
+    (version "4.1.16")
+    (source
+     (origin (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/mesqueeb/is-what")
+                   (commit (string-append "v" version))))
+             (sha256
+              (base32 "02h76klvjxgk0cl8a7sq4wbi7l4pvdimbams08l34k5carg03bdx"))
+             (snippet
+              #~(for-each delete-file
+                          '("dist/cjs/index.cjs"
+                            "dist/index.js")))
+             (file-name (git-file-name name version))))
+    (build-system node-build-system)
+    (native-inputs (list esbuild))
+    (arguments
+     (list
+      #:tests? #f ; needs more dependencies
+      #:modules
+      `((guix build node-build-system)
+        (ice-9 match)
+        (guix build utils))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'patch-dependencies 'delete-dependencies
+            (lambda args
+              (delete-dependencies
+               '(;; devDependencies
+                 "@typescript-eslint/eslint-plugin"
+                 "@typescript-eslint/parser"
+                 "del-cli"
+                 "eslint"
+                 "eslint-config-prettier"
+                 "eslint-plugin-tree-shaking"
+                 "np"
+                 "prettier"
+                 "prettier-plugin-jsdoc"
+                 "rollup"
+                 "rollup-plugin-dts"
+                 "rollup-plugin-esbuild"
+                 "rollup-plugin-typescript2"
+                 "typedoc"
+                 "typescript"
+                 "vitest"))))
+          (add-after 'delete-dependencies 'patch-build-script
+            (lambda args
+              (define esbuild
+                "esbuild --bundle --platform=node")
+              (define new-build-script
+                (string-append
+                 esbuild
+                 " --format=cjs --outfile=dist/cjs/index.cjs src/index.ts"
+                 " && "
+                 esbuild
+                 " --format=esm --outfile=dist/index.js src/index.ts"))
+              (with-atomic-json-file-replacement "package.json"
+                (match-lambda
+                  (('@ . alist)
+                   (cons '@
+                    (map (match-lambda
+                           (("scripts" @ . alist)
+                            `("scripts" @ ,@(map (match-lambda
+                                                   (("build" . _)
+                                                    (cons "build"
+                                                          new-build-script))
+                                                   (other
+                                                    other))
+                                                 alist)))
+                           (other
+                            other))
+                         alist))))))))))
+    (home-page "https://npmjs.com/is-what")
+    (synopsis "Type predicate functions for JavaScript")
+    (description "This package provides simple and small type predicate
+functions for JavaScript, such as @code{isString}, @code{isDate}, and
+@code{isPlainObject}.")
+    (license license:expat)))
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 19:17:02 GMT) Full text and rfc822 format available.

Message #83 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Subject: [PATCH v2 02/16] gnu: Add node-copy-anything.
Date: Thu, 16 Nov 2023 14:15:40 -0500
* gnu/packages/node-xyz.scm (node-copy-anything): New variable.
---
 gnu/packages/node-xyz.scm | 81 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index 49760ded2b..ee96dee767 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1712,3 +1712,84 @@ (define-public node-is-what
 functions for JavaScript, such as @code{isString}, @code{isDate}, and
 @code{isPlainObject}.")
     (license license:expat)))
+
+(define-public node-copy-anything
+  (package
+    (name "node-copy-anything")
+    (version "3.0.5")
+    (source
+     (origin (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/mesqueeb/copy-anything")
+                   (commit (string-append "v" version))))
+             (sha256
+              (base32 "1lpjqanjl04k088banpns4yvp6hgf97snaj7gfbfancjpd3i8gk6"))
+             (snippet
+              #~(for-each delete-file
+                          '("dist/cjs/index.cjs"
+                            "dist/index.js")))
+             (file-name (git-file-name name version))))
+    (build-system node-build-system)
+    (native-inputs (list esbuild))
+    (inputs (list node-is-what))
+    (arguments
+     (list
+      #:tests? #f ; needs more dependencies
+      #:modules
+      `((guix build node-build-system)
+        (ice-9 match)
+        (guix build utils))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'patch-dependencies 'delete-dependencies
+            (lambda args
+              (delete-dependencies
+               '(;; devDependencies
+                 "@typescript-eslint/eslint-plugin"
+                 "@typescript-eslint/parser"
+                 "del-cli"
+                 "eslint"
+                 "eslint-config-prettier"
+                 "eslint-plugin-tree-shaking"
+                 "np"
+                 "prettier"
+                 "rollup"
+                 "rollup-plugin-dts"
+                 "rollup-plugin-esbuild"
+                 "rollup-plugin-typescript2"
+                 "typescript"
+                 "vitest"))))
+          (add-after 'delete-dependencies 'patch-build-script
+            (lambda args
+              (define esbuild
+                "esbuild --bundle --platform=node --external:is-what")
+              (define new-build-script
+                (string-append
+                 esbuild
+                 " --format=cjs --outfile=dist/cjs/index.cjs src/index.ts"
+                 " && "
+                 esbuild
+                 " --format=esm --outfile=dist/index.js src/index.ts"))
+              (with-atomic-json-file-replacement "package.json"
+                (match-lambda
+                  (('@ . alist)
+                   (cons '@
+                    (map (match-lambda
+                           (("scripts" @ . alist)
+                            `("scripts" @ ,@(map (match-lambda
+                                                   (("build" . _)
+                                                    (cons "build"
+                                                          new-build-script))
+                                                   (other
+                                                    other))
+                                                 alist)))
+                           (other
+                            other))
+                         alist))))))))))
+    (home-page "https://npmjs.com/copy-anything")
+    (synopsis "JavaScript library for copying objects and arrays")
+    (description "This library provides deep copying for JavaScript objects
+and arrays.  Its design emphasizes speed, simplicity, and correctness in the
+face of complications like special objects, symbols, and non-enumerable
+properties.")
+    (license license:expat)))
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 19:17:03 GMT) Full text and rfc822 format available.

Message #86 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Subject: [PATCH v2 03/16] gnu: Add lessc.
Date: Thu, 16 Nov 2023 14:15:41 -0500
* gnu/packages/web.scm (lessc): New variable.
---
 gnu/packages/web.scm | 183 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 183 insertions(+)

diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index 389f7d1375..9efc6ebc9d 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -65,6 +65,7 @@
 ;;; Copyright © 2023 Christopher Howard <christopher <at> librehacker.com>
 ;;; Copyright © 2023 Felix Lechner <felix.lechner <at> lease-up.com>
 ;;; Copyright © 2023 Evgeny Pisemsky <evgeny <at> pisemsky.com>
+;;; Copyright © 2023 Philip McGrath <philip <at> philipmcgrath.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -99,6 +100,7 @@ (define-module (gnu packages web)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
   #:use-module (guix build-system meson)
+  #:use-module (guix build-system node)
   #:use-module (guix build-system perl)
   #:use-module (guix build-system pyproject)
   #:use-module (guix build-system python)
@@ -169,6 +171,7 @@ (define-module (gnu packages web)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages networking)
   #:use-module (gnu packages node)
+  #:use-module (gnu packages node-xyz)
   #:use-module (gnu packages nss)
   #:use-module (gnu packages openldap)
   #:use-module (gnu packages openstack)
@@ -2344,6 +2347,186 @@ (define-public sassc/libsass-3.5
                                                     "0830pjcvhzxh6yixj82x5k5r1xnadjqzi16kp53213icbly0r9ma")))))))
     (properties '((hidden? . #t)))))
 
+(define-public lessc
+  (package
+    (name "lessc")
+    (version "4.2.0")
+    (source
+     (origin (method git-fetch)
+             (uri (git-reference
+                   (url "https://github.com/less/less.js")
+                   (commit (string-append "v" version))))
+             (sha256
+              (base32 "1b6anlafk7lnayxy3vhsi474jcdah2ffaw2qyac5s2ibxb1wmr54"))
+             (snippet
+              #~(begin
+                  (use-modules (guix build utils))
+                  (delete-file-recursively "packages/less/dist")))
+             (file-name (git-file-name name version))))
+    (build-system node-build-system)
+    (native-inputs (list esbuild))
+    (inputs (list node-copy-anything))
+    (arguments
+     (list
+      #:tests? #f ; many more dependencies
+      #:modules
+      `((guix build node-build-system)
+        (ice-9 match)
+        (guix build utils))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'chdir
+            (lambda args
+              (chdir "packages/less")))
+          (add-after 'patch-dependencies 'delete-dependencies
+            (lambda args
+              (delete-dependencies
+               '(;; dependencies
+                 "parse-node-version" ; patched out
+                 "tslib" ; probably not needed w/ esbuild
+                 ;; devDependencies
+                 "@less/test-data"
+                 "@less/test-import-module"
+                 "@rollup/plugin-commonjs"
+                 "@rollup/plugin-json"
+                 "@rollup/plugin-node-resolve"
+                 "@typescript-eslint/eslint-plugin"
+                 "@typescript-eslint/parser"
+                 "benny"
+                 "bootstrap-less-port"
+                 "chai"
+                 "cross-env"
+                 "diff"
+                 "eslint"
+                 "fs-extra"
+                 "git-rev"
+                 "globby"
+                 "grunt"
+                 "grunt-cli"
+                 "grunt-contrib-clean"
+                 "grunt-contrib-connect"
+                 "grunt-eslint"
+                 "grunt-saucelabs"
+                 "grunt-shell"
+                 "html-template-tag"
+                 "jit-grunt"
+                 "less-plugin-autoprefix"
+                 "less-plugin-clean-css"
+                 "minimist"
+                 "mocha"
+                 "mocha-headless-chrome"
+                 "mocha-teamcity-reporter"
+                 "nock"
+                 "npm-run-all"
+                 "performance-now"
+                 "phin"
+                 "promise"
+                 "read-glob"
+                 "resolve"
+                 "rollup"
+                 "rollup-plugin-terser"
+                 "rollup-plugin-typescript2"
+                 "semver"
+                 "shx"
+                 "time-grunt"
+                 "ts-node"
+                 "typescript"
+                 "uikit"
+                 ;; optionalDependencies
+                 "errno"
+                 "graceful-fs"
+                 "image-size"
+                 "make-dir"
+                 "mime"
+                 "needle"
+                 "source-map"))))
+          (add-after 'delete-dependencies 'avoid-parse-node-version
+            (lambda args
+              (define version
+                #$(package-version this-package))
+              (substitute* "src/less/index.js"
+                (("import [{] version [}]" orig)
+                 (string-append "// " orig))
+                (("import parseVersion from 'parse-node-version';" orig)
+                 (string-append "// " orig))
+                (("const v = parseVersion[(]`v\\$[{]version[}]`[)];" orig)
+                 (string-append "// " orig))
+                (("(version: )(\\[v\\.major, v\\.minor, v\\.patch],)" _ lhs rhs)
+                 (string-append
+                  lhs
+                  "["
+                  (string-join
+                   (list-head (string-split
+                               version (char-set-complement char-set:digit))
+                              3)
+                   ", ")
+                  "], // "
+                  rhs)))))
+          (add-after 'avoid-parse-node-version 'do-not-target-es5
+            (lambda args
+              ;; esbuild can't compile all features to ES5
+              (with-atomic-json-file-replacement "tsconfig.json"
+                (match-lambda
+                  (('@ . alist)
+                   (cons '@
+                    (map (match-lambda
+                           (("compilerOptions" '@ . alist)
+                            `("compilerOptions" @ ,@(delete '("target" . "ES5")
+                                                            alist)))
+                           (other
+                            other))
+                         alist)))))))
+          (add-after 'do-not-target-es5 'patch-build-script
+            (lambda args
+              (define new-build-script
+                (string-join
+                 `("esbuild"
+                   "--platform=node"
+                   "--format=cjs"
+                   "--outdir=lib"
+                   ,@(find-files "src/less" "\\.js$")
+                   ,@(find-files "src/less-node" "\\.js$"))))
+              (with-atomic-json-file-replacement "package.json"
+                (match-lambda
+                  (('@ . alist)
+                   (cons '@
+                    (map (match-lambda
+                           (("scripts" @ . alist)
+                            `("scripts" @ ,@(map (match-lambda
+                                                   (("build" . _)
+                                                    (cons "build"
+                                                          new-build-script))
+                                                   (other
+                                                    other))
+                                                 alist)))
+                           (other
+                            other))
+                         alist)))))))
+          (add-after 'build 'build-browser
+            (lambda args
+              (invoke "esbuild"
+                      "--bundle"
+                      "--platform=browser"
+                      "--format=cjs"
+                      "--outfile=dist/less.js"
+                      "src/less-browser/bootstrap.js")
+              (invoke "esbuild"
+                      "--bundle"
+                      "--minify"
+                      "--sourcemap"
+                      "--platform=browser"
+                      "--format=cjs"
+                      "--outfile=dist/less.min.js"
+                      "src/less-browser/bootstrap.js"))))))
+    (home-page "https://lesscss.org")
+    (synopsis "Compiler for @acronym{Less} @acronym{CSS} language extension")
+    ;; XXX: @abbr{} seems better for Less (which is always capitalized that
+    ;; way), but it is rejected as invalid Texinfo markup here.
+    (description "@acronym{Less, Leaner Style Sheets} is a
+backwards-compatible language extension for @acronym{CSS}.  This package
+provides @command{lessc}, which compiles Less files to plain @acronym{CSS}.")
+    (license license:asl2.0)))
+
 
 (define-public perl-apache-logformat-compiler
   (package
-- 
2.41.0





Information forwarded to julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 19:17:03 GMT) Full text and rfc822 format available.

Message #89 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Subject: [PATCH v2 04/16] gnu: Add ocaml-wtf8.
Date: Thu, 16 Nov 2023 14:15:42 -0500
* gnu/packages/ocaml.scm (ocaml-wtf8): New variable.
---
 gnu/packages/ocaml.scm | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index 7993dbaa73..50b0d1ddb7 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -29,6 +29,7 @@
 ;;; Copyright © 2022 Garek Dyszel <garekdyszel <at> disroot.org>
 ;;; Copyright © 2023 Csepp <raingloom <at> riseup.net>
 ;;; Copyright © 2023 Foundation Devices, Inc. <hello <at> foundationdevices.com>
+;;; Copyright © 2023 Philip McGrath <philip <at> philipmcgrath.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -3655,6 +3656,30 @@ (define-public ocaml-uutf
 string values and to directly encode characters in OCaml Buffer.t values.")
     (license license:isc)))
 
+(define-public ocaml-wtf8
+  (package
+    (name "ocaml-wtf8")
+    (version "1.0.2")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://github.com/flow/ocaml-wtf8/releases/download/"
+                    "v" version "/wtf8-v" version ".tbz"))
+              (sha256
+               (base32
+                "09ygcxxd5warkdzz17rgpidrd0pg14cy2svvnvy1hna080lzg7vp"))))
+    (build-system dune-build-system)
+    (home-page "https://github.com/flow/ocaml-wtf8")
+    (synopsis "OCaml encoder and decoder for @acronym{WTF-8}")
+    (description
+     "This library provides an OCaml encoder and decoder for @acronym{WTF-8,
+Wobbly Transformation Format---8 bit}, a superset of UTF-8 that allows
+unpaired surrogates while preserving the other well-formedness constraints of
+UTF-8.  This format is useful for interoperating with systems that use
+potentially ill-formed UTF-16, notably including ECMAScript strings and
+Windows filesystems.")
+    (license license:expat)))
+
 (define-public ocaml-uunf
   (package
     (name "ocaml-uunf")
-- 
2.41.0





Information forwarded to julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 19:17:04 GMT) Full text and rfc822 format available.

Message #92 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Subject: [PATCH v2 05/16] gnu: Add ocaml-visitors.
Date: Thu, 16 Nov 2023 14:15:43 -0500
* gnu/packages/ocaml.scm (ocaml-visitors): New variable.
---
 gnu/packages/ocaml.scm | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index 50b0d1ddb7..f9a3932d18 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -5232,6 +5232,28 @@ (define-public ocaml-graph
     (description "OCamlgraph is a generic graph library for OCaml.")
     (license license:lgpl2.1)))
 
+(define-public ocaml-visitors
+  (package
+    (name "ocaml-visitors")
+    (version "20210608")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append "https://gitlab.inria.fr/fpottier/visitors/-/"
+                              "archive/" version "/archive.tar.gz"))
+              (sha256
+               (base32
+                "1yx4bjw4yw3zi35yfp66x320xgb9f8jh7rqj1j7hrrvn0f60m2y2"))))
+    (build-system dune-build-system)
+    (propagated-inputs (list ocaml-ppxlib ocaml-ppx-deriving ocaml-result))
+    (home-page "https://gitlab.inria.fr/fpottier/visitors")
+    (synopsis "OCaml syntax extension for generating visitor classes")
+    (description
+     "This package provides an OCaml syntax extension that automatically
+generates object-oriented visitors for traversing and transforming data
+structures.")
+    (license license:lgpl2.1)))
+
 (define-public ocaml-piqi
   (package
     (name "ocaml-piqi")
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 19:17:04 GMT) Full text and rfc822 format available.

Message #95 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Subject: [PATCH v2 11/16] gnu: Add flow-remove-types.
Date: Thu, 16 Nov 2023 14:15:49 -0500
* gnu/packages/web.scm (flow-remove-types): New variable.
---
 gnu/packages/web.scm | 60 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index b8646e9d0d..f5afb453f9 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -2076,6 +2076,66 @@ (define-public node-flow-parser
 provides the Flow parser in its compiled-to-JavaScript form for use with
 Node.js and NPM.")))
 
+(define-public flow-remove-types
+  (package
+    (inherit node-flow-parser)
+    (name "flow-remove-types")
+    (inputs (list node-flow-parser node-vlq))
+    (arguments
+     (list
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'delete-workspace-file
+            (lambda args
+              ;; this workspace file causes NPM to try to install dependencies
+              ;; of other packages developed in this source repository
+              (delete-file "package.json")))
+          (add-after 'delete-workspace-file 'chdir
+            (lambda args
+              (chdir "packages/flow-remove-types")))
+          (add-after 'patch-dependencies 'delete-dependencies
+            (lambda args
+              (delete-dependencies '("pirates"))))
+          (add-after 'delete-dependencies 'remove-unsupported-features
+            (lambda args
+              (delete-file "register.js")
+              (with-output-to-file "register.js"
+                (lambda ()
+                  (for-each
+                   display
+                   '("console.warn('flow-remove-types/register.js does not add"
+                     " a require hook on Guix');\n"
+                     "module.exports ="
+                     " function setOptions(newOptions) {};\n"))))
+              (substitute* "flow-node"
+                (("var flowRemoveTypes")
+                 (string-append
+                  "process.stderr.write('flow-node: not yet supported"
+                  " on Guix');\n"
+                  "return process.exit(1);\n"
+                  "var flowRemoveTypes")))
+              (substitute* "test.sh"
+                (("echo \"Test: node require hook\"")
+                  "echo \"SKIPPING Test: node require hook\"")
+                (("RES=\\$[(]node -e 'require[(]\"\\./register\"[)];")
+                 "RES=42 # ")
+                (("echo \"Test: flow-node\"")
+                 "echo \"SKIPPING Test: flow-node\"")
+                (("FLOW_NODE=")
+                 "FLOW_NODE=42 # ")
+                (("echo \"Test: flow-node with options\"")
+                 "echo \"SKIPPING Test: flow-node with options\"")
+                (("FLOW_NODE_OPTS=")
+                 "FLOW_NODE_OPTS=4 # ")))))))
+    (synopsis "Utility to erase Flow type annotations from JavaScript")
+    (description "Flow is a gradual type system for JavaScript.  This package
+provides @command{flow-remove-types}, a command-line tool that erases Flow
+type annotations, producing standard JavaScript files.  The functionality is
+also provided as a JavaScript library.
+
+Note that the Guix package does not yet support the @command{flow-node}
+command or the Node.js require hook for interactive development.")))
+
 (define-public tinyproxy
   (package
     (name "tinyproxy")
-- 
2.41.0





Information forwarded to julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 19:18:02 GMT) Full text and rfc822 format available.

Message #98 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Subject: [PATCH v2 06/16] gnu: Add ocaml-ppx-gen-rec.
Date: Thu, 16 Nov 2023 14:15:44 -0500
* gnu/packages/ocaml.scm (ocaml-ppx-gen-rec): New variable.
---
 gnu/packages/ocaml.scm | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index f9a3932d18..b12c12fad5 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -6722,6 +6722,34 @@ (define-public ocaml-ppx-deriving
 on type definitions, and a set of useful plugins for common tasks.")
     (license license:expat)))
 
+(define-public ocaml-ppx-gen-rec
+  (package
+    (name "ocaml-ppx-gen-rec")
+    (version "2.0.0")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append "https://github.com/flow/ocaml-ppx_gen_rec/"
+                              "releases/download/v"
+                              version
+                              "/ppx_gen_rec-v" version ".tbz"))
+              (sha256
+               (base32
+                "0ncy7ps0w3cnb3nk6y1j4v4g60rs500qwv1daw3a9n7n8kjj6qzy"))))
+    (build-system dune-build-system)
+    (propagated-inputs (list ocaml-ppxlib))
+    (native-inputs (list ocaml-ppx-deriving))
+    (properties `((upstream-name . "ppx_gen_rec")))
+    (home-page "https://github.com/flow/ocaml-ppx_gen_rec")
+    (synopsis "Ppx rewriter for recursive module expressions")
+    (description
+     "This package provides a ppx rewriter that transforms a recursive module
+expression into a struct.  In a recursive module expression, the struct can be
+derived from the signature automatically by the compiler.  This package does
+the same thing, but doing it this way allows @code{ppx_deriving} to transform
+the signature and the struct separately.")
+    (license license:expat)))
+
 (define-public ocaml-ppx-derivers
   (package
     (name "ocaml-ppx-derivers")
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 19:18:02 GMT) Full text and rfc822 format available.

Message #101 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Subject: [PATCH v2 12/16] gnu: js-commander: Update to 11.1.0.
Date: Thu, 16 Nov 2023 14:15:50 -0500
* gnu/packages/javascript.scm (js-commander): Update to 11.1.0.
---
 gnu/packages/javascript.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/javascript.scm b/gnu/packages/javascript.scm
index e70aa7d7e1..c62b23a4c4 100644
--- a/gnu/packages/javascript.scm
+++ b/gnu/packages/javascript.scm
@@ -373,7 +373,7 @@ (define-public js-mathjax-for-r-mathjaxr
 (define-public js-commander
   (package
     (name "js-commander")
-    (version "6.2.1")
+    (version "11.1.0")
     (source
      (origin
        (method git-fetch)
@@ -383,7 +383,7 @@ (define-public js-commander
        (file-name (git-file-name name version))
        (sha256
         (base32
-         "126m25s6mxpxmdj4aw5awz06b47r8r798lcf1c5bnmmh39cik5i1"))))
+         "1xwh85kbxj76ni41r2h0apl8mjbfcnmxzzp3vlspq30w8kwfckni"))))
     (build-system trivial-build-system)
     (arguments
      `(#:modules ((guix build utils))
-- 
2.41.0





Information forwarded to julien <at> lepiller.eu, pukkamustard <at> posteo.net, guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 19:18:02 GMT) Full text and rfc822 format available.

Message #104 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Subject: [PATCH v2 07/16] gnu: Add ocaml-dtoa.
Date: Thu, 16 Nov 2023 14:15:45 -0500
* gnu/packages/ocaml.scm (ocaml-dtoa): New variable.
---
 gnu/packages/ocaml.scm | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index b12c12fad5..36f349df73 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -2513,6 +2513,30 @@ (define-public ocaml4.07-fmt
                   "0gkkkj4x678vxdda4xaw2dd44qjacavsvn5nx8gydfwah6pjbkxk"))))
       (properties '()))))
 
+(define-public ocaml-dtoa
+  (package
+    (name "ocaml-dtoa")
+    (version "0.3.3")
+    (source (origin
+              (method url-fetch)
+              (uri
+               (string-append "https://github.com/flow/ocaml-dtoa/releases/"
+                              "download/v" version "/dtoa-" version ".tbz"))
+              (sha256
+               (base32
+                "0gpfr6iyiihmkpas542916cnhfdbrigvzwrix8jrxcljks661x6q"))))
+    (build-system dune-build-system)
+    (native-inputs (list ocaml-ounit2))
+    (home-page "https://github.com/flow/ocaml-dtoa")
+    (synopsis
+     "Efficent float to string conversion for OCaml")
+    (description
+     "This package provides functions that convert OCaml floats into strings
+quickly, accurately, and (almost always) optimally using the Grisu3 algorithm.
+The implementation was adapted from a C++ library originally developed as part
+of the V8 JavaScript engine.")
+    (license license:expat)))
+
 (define-public ocaml-astring
   (package
     (name "ocaml-astring")
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 19:18:03 GMT) Full text and rfc822 format available.

Message #107 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Subject: [PATCH v2 13/16] gnu: js-commander: Install as a node module.
Date: Thu, 16 Nov 2023 14:15:51 -0500
Previously, NPM would not find 'commander' when resolving dependencies.

In case anyone is using it, keep building the bundled version at
'share/javascript/commander/index.min.js', too.

* gnu/packages/javascript.scm (js-commander)[build-system]: Use
'node-build-system'.
[arguments]: Delete unpackaged 'devDependencies'.  Build bundle for
compatibility.
---
 gnu/packages/javascript.scm | 52 ++++++++++++++++++++++++++-----------
 1 file changed, 37 insertions(+), 15 deletions(-)

diff --git a/gnu/packages/javascript.scm b/gnu/packages/javascript.scm
index c62b23a4c4..97cb3b6270 100644
--- a/gnu/packages/javascript.scm
+++ b/gnu/packages/javascript.scm
@@ -7,6 +7,7 @@
 ;;; Copyright © 2021 Pierre Neidhardt <mail <at> ambrevar.xyz>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
 ;;; Copyright © 2022 Frank Pursel <frank.pursel <at> gmail.com>
+;;; Copyright © 2023 Philip McGrath <philip <at> philipmcgrath.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -42,6 +43,7 @@ (define-module (gnu packages javascript)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system minify)
+  #:use-module (guix build-system node)
   #:use-module (guix build-system trivial)
   #:use-module (guix utils))
 
@@ -384,22 +386,42 @@ (define-public js-commander
        (sha256
         (base32
          "1xwh85kbxj76ni41r2h0apl8mjbfcnmxzzp3vlspq30w8kwfckni"))))
-    (build-system trivial-build-system)
+    (build-system node-build-system)
     (arguments
-     `(#:modules ((guix build utils))
-       #:builder
-       (begin
-         (use-modules (guix build utils))
-         (chdir (assoc-ref %build-inputs "source"))
-         (let ((esbuild (search-input-file %build-inputs "/bin/esbuild"))
-               (target (string-append %output "/share/javascript/commander")))
-           (invoke esbuild
-                   "--bundle"
-                   "--minify"
-                   "--tsconfig=tsconfig.json"
-                   "--platform=node"
-                   (string-append "--outfile=" target "/index.min.js")
-                   "index.js")))))
+     (list
+      #:tests? #f ; many more dependencies
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'patch-dependencies 'delete-dependencies
+            (lambda args
+              (delete-dependencies `(;; devDependencies
+                                     "@types/jest"
+                                     "@types/node"
+                                     "@typescript-eslint/eslint-plugin"
+                                     "@typescript-eslint/parser"
+                                     "eslint"
+                                     "eslint-config-standard"
+                                     "eslint-config-standard-with-typescript"
+                                     "eslint-plugin-import"
+                                     "eslint-plugin-jest"
+                                     "eslint-plugin-n"
+                                     "eslint-plugin-promise"
+                                     "jest"
+                                     "ts-jest"
+                                     "tsd"
+                                     "typescript"))))
+          (add-after 'install 'install-compat
+            (lambda args
+              ;; This is what this package built before adopting
+              ;; node-build-system.  Does anything use it?
+              (invoke "esbuild"
+                      "--bundle"
+                      "--minify"
+                      "--platform=node"
+                      (string-append "--outfile="
+                                     #$output
+                                     "/share/javascript/commander/index.min.js")
+                      "index.js"))))))
     (native-inputs
      (list esbuild))
     (home-page "https://github.com/tj/commander.js")
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 19:18:03 GMT) Full text and rfc822 format available.

Message #110 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Subject: [PATCH v2 08/16] gnu: Add node-vlq.
Date: Thu, 16 Nov 2023 14:15:46 -0500
* gnu/packages/node-xyz.scm (node-vlq): New variable.
---
 gnu/packages/node-xyz.scm | 58 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/gnu/packages/node-xyz.scm b/gnu/packages/node-xyz.scm
index ee96dee767..adbac8a6cd 100644
--- a/gnu/packages/node-xyz.scm
+++ b/gnu/packages/node-xyz.scm
@@ -1793,3 +1793,61 @@ (define-public node-copy-anything
 face of complications like special objects, symbols, and non-enumerable
 properties.")
     (license license:expat)))
+
+(define-public node-vlq
+  (package
+    (name "node-vlq")
+    (version "0.2.3") ; last version accepted by flow-remove-types ("^0.2.1")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/Rich-Harris/vlq")
+             (commit (string-append "v" version))))
+       (sha256
+        (base32 "1vdrarssrwxpcngyfx050ba0gnfinzi5jn3xs4w9rnjvxngx6m8f"))
+       (snippet
+        #~(delete-file "dist/vlq.js"))
+       (file-name (git-file-name name version))))
+    (build-system node-build-system)
+    (native-inputs (list esbuild))
+    (arguments
+     (list
+      #:modules
+      `((guix build node-build-system)
+        (ice-9 match)
+        (guix build utils))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'patch-dependencies 'delete-dependencies
+            (lambda args
+              (delete-dependencies
+               '("eslint"
+                 "rollup"))))
+          (add-after 'delete-dependencies 'patch-build-script
+            (lambda args
+              (define new-build-script
+                "esbuild --bundle --platform=node --outdir=dist src/vlq.js")
+              (with-atomic-json-file-replacement "package.json"
+                (lambda (js)
+                  (match js
+                    (('@ . alist)
+                     (cons '@
+                      (map (match-lambda
+                             (("scripts" @ . alist)
+                              `("scripts" @ ,@(map (match-lambda
+                                                     (("build" . _)
+                                                      (cons "build"
+                                                            new-build-script))
+                                                     (other
+                                                      other))
+                                                   alist)))
+                             (other
+                              other))
+                           alist)))))))))))
+    (home-page "https://github.com/Rich-Harris/vlq")
+    (synopsis "JavaScript library for @acronym{VLQ} encoding and decoding")
+    (description "This package provides a JavaScript library for converting
+integers to and from Base64-encoded @acronym{VLQ, variable-length quantity}
+strings.")
+    (license license:expat)))
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 19:18:04 GMT) Full text and rfc822 format available.

Message #113 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Subject: [PATCH v2 14/16] gnu: Add mftrace.
Date: Thu, 16 Nov 2023 14:15:52 -0500
* gnu/packages/fontutils.scm (mftrace): New variable.
---
 gnu/packages/fontutils.scm | 45 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/gnu/packages/fontutils.scm b/gnu/packages/fontutils.scm
index 5bfdea1b27..6bab6ab7df 100644
--- a/gnu/packages/fontutils.scm
+++ b/gnu/packages/fontutils.scm
@@ -1182,6 +1182,51 @@ (define-public ttf2pt1
     (home-page "https://ttf2pt1.sourceforge.net/")
     (license license:bsd-3)))
 
+(define-public mftrace
+  (let ((commit "3b4bc2e5b8a4ae6f9c776593961b38389e62a484")
+        ;; see https://github.com/hanwen/mftrace/pull/12
+        (revision "0"))
+    (package
+      (name "mftrace")
+      (version (git-version "1.2.20" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/hanwen/mftrace")
+               (commit commit)))
+         (sha256
+          (base32 "01cg6z1z69za07wrvx1y5dnfagx4di2a9qnx25f97l6843x03s36"))
+         (file-name (git-file-name name version))))
+      (build-system gnu-build-system)
+      (native-inputs (list autoconf
+                           ;; for tests:
+                           (texlive-updmap.cfg
+                            (list texlive-cm))))
+      (propagated-inputs (list potrace lcdf-typetools))
+      (arguments
+       (list
+        ;; setting CC is needed for implicit rule
+        #:make-flags #~(list (string-append "CC=" #$(cc-for-target)))
+        #:test-target "test"
+        #:phases
+        #~(modify-phases %standard-phases
+            (replace 'bootstrap
+              (lambda args
+                (invoke "autoconf"))))))
+      (home-page "https://lilypond.org/mftrace/")
+      (synopsis "Scalable PostScript fonts for MetaFont")
+      (description "This package provides @command{mftrace}, a small Python
+program that lets you trace a TeX bitmap font into a PFA or PFB font (a
+PostScript Type 1 Scalable Font) or a @acronym{TTF,TrueType Font}.
+
+Scalable fonts offer many advantages over bitmaps, as they allow documents to
+render correctly at many printer resolutions.  Moreover, Ghostscript can
+generate much better PDFs if given scalable PostScript fonts.
+
+Versions of this program prior to 1.0.5 were called @command{pktrace}.")
+      (license license:gpl2+))))
+
 (define-public woff2
   (package
     (name "woff2")
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 19:18:04 GMT) Full text and rfc822 format available.

Message #116 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Subject: [PATCH v2 09/16] gnu: Add ocaml-flow-parser.
Date: Thu, 16 Nov 2023 14:15:47 -0500
* gnu/packages/web.scm (ocaml-flow-parser): New variable.
---
 gnu/packages/web.scm | 95 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)

diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index 9efc6ebc9d..b222c2ae40 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -96,6 +96,7 @@ (define-module (gnu packages web)
   #:use-module (guix build-system cargo)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system copy)
+  #:use-module (guix build-system dune)
   #:use-module (guix build-system glib-or-gtk)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system go)
@@ -173,6 +174,7 @@ (define-module (gnu packages web)
   #:use-module (gnu packages node)
   #:use-module (gnu packages node-xyz)
   #:use-module (gnu packages nss)
+  #:use-module (gnu packages ocaml)
   #:use-module (gnu packages openldap)
   #:use-module (gnu packages openstack)
   #:use-module (gnu packages package-management)
@@ -1938,6 +1940,99 @@ (define-public esbuild
 and other data, for distribution on the web.")
     (license license:expat)))
 
+(define-public ocaml-flow-parser
+  (package
+    (name "ocaml-flow-parser")
+    (version "0.159.0")
+    (outputs '("out" "js"))
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/facebook/flow")
+             (commit (string-append "v" version))))
+       (sha256
+        (base32 "1i9svf641s24nj4w6y9vvglzg29h0lr4n9a6mvwrn9psy9x1lril"))
+       (file-name (git-file-name "flow" version))))
+    (build-system dune-build-system)
+    (propagated-inputs (list ocaml-base
+                             ocaml-core-kernel
+                             ocaml-dtoa
+                             ocaml-sedlex
+                             ocaml-wtf8))
+    (native-inputs (list js-of-ocaml
+                         ocamlbuild
+                         ocaml-findlib
+                         ocaml-ounit2
+                         ocaml-ppx-deriving
+                         ocaml-ppx-gen-rec
+                         ocaml-visitors))
+    (arguments
+     (list
+      #:tests? #f ; tests need lwt_ppx
+      #:package "flow_parser"
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-before 'build 'chdir
+            (lambda args
+              (chdir "src/parser")))
+          (add-before 'build 'patch-source
+            (lambda args
+              ;; Avoid errors with newer OCaml:
+              ;; "Error (warning 16 [unerasable-optional-argument]):"
+              ;;   " this optional argument cannot be erased."
+              ;; "Error (warning 69 [unused-field]):"
+              ;;   " mutable record field buf is never mutated."
+              ;; "Error (warning 70 [missing-mli]): Cannot find interface file."
+              (substitute* "_tags"
+                (("<\\*\\.ml\\*>: warn[(]-39[)]")
+                 "<*.ml*>: warn(-16-39-70)"))
+              (substitute* "../../_tags"
+                (("<\\*\\*/\\*.ml\\*>: ")
+                 "<**/*.ml*>: warn(-69), "))
+              ;; Deprecation of Js.Unsafe.variable, Js.Error, Js.raise_js_error
+              (substitute* "flow_parser_js.ml"
+                (("Js\\.Unsafe\\.variable")
+                 "Js.Unsafe.pure_js_expr"))
+              (substitute* "flow_parser_dot_js.ml"
+                (("Js\\.Error")
+                 "Js_of_ocaml.Js_error.Exn")
+                (("Js\\.raise_js_error")
+                 "Js_of_ocaml.Js_error.raise_"))))
+          (replace 'build
+            (lambda args
+              (invoke "make"
+                      (string-append "CC=" #$(cc-for-target))
+                      "build-parser")))
+          (add-after 'build 'build-js
+            (lambda args
+              (invoke "make"
+                      (string-append "CC=" #$(cc-for-target))
+                      "js")))
+          (replace 'check
+            (lambda* (#:key tests? #:allow-other-keys)
+              (when tests?
+                (invoke "make"
+                        (string-append "CC=" #$(cc-for-target))
+                        "test-ocaml"))))
+          (replace 'install
+            (lambda args
+              (invoke "make"
+                      (string-append "CC=" #$(cc-for-target))
+                      "ocamlfind-install")))
+          (add-after 'install 'install-js
+            (lambda args
+              (install-file "flow_parser.js"
+                            (string-append #$output:js
+                                           "/share/javascript/flow")))))))
+    (properties `((upstream-name . "flow_parser")))
+    (home-page "https://flow.org")
+    (synopsis "Parser for the Flow JavaScript type system")
+    (description "Flow is a gradual type system for JavaScript.  This package
+provides the Flow parser, which is an OCaml library that can also be compiled
+to JavaScript.")
+    (license license:expat)))
+
 (define-public tinyproxy
   (package
     (name "tinyproxy")
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 19:18:05 GMT) Full text and rfc822 format available.

Message #119 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Subject: [PATCH v2 10/16] gnu: Add node-flow-parser.
Date: Thu, 16 Nov 2023 14:15:48 -0500
* gnu/packages/web.scm (node-flow-parser): New variable.
(ocaml-flow-parser)[description]: Mention it.
---
 gnu/packages/web.scm | 45 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index b222c2ae40..b8646e9d0d 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -2030,9 +2030,52 @@ (define-public ocaml-flow-parser
     (synopsis "Parser for the Flow JavaScript type system")
     (description "Flow is a gradual type system for JavaScript.  This package
 provides the Flow parser, which is an OCaml library that can also be compiled
-to JavaScript.")
+to JavaScript.  To use the compiled parser with Node.js or NPM, see the Guix
+package @code{node-flow-parser}.")
     (license license:expat)))
 
+(define-public node-flow-parser
+  (package
+    (inherit ocaml-flow-parser)
+    (name "node-flow-parser")
+    (properties '())
+    (outputs '("out"))
+    (propagated-inputs '())
+    (native-inputs '())
+    (inputs (list `(,ocaml-flow-parser "js")))
+    (build-system node-build-system)
+    (arguments
+     (list
+      #:tests? #f ; need unpackaged dependencies
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'delete-workspace-file
+            (lambda args
+              ;; this workspace file causes NPM to try to install dependencies
+              ;; of other packages developed in this source repository
+              (delete-file "package.json")))
+          (add-after 'delete-workspace-file 'chdir
+            (lambda args
+              (chdir "packages/flow-parser")))
+          (add-after 'chdir 'unpack-generated-js
+            (lambda* (#:key inputs #:allow-other-keys)
+              (install-file
+               (search-input-file inputs
+                                  "share/javascript/flow/flow_parser.js")
+               ".")
+              (delete-file "Makefile")))
+          (add-after 'patch-dependencies 'delete-dependencies
+            (lambda args
+              (delete-dependencies
+               '("ast-types"
+                 "colors"
+                 "esprima-fb"
+                 "minimist")))))))
+    (synopsis "Parser for the Flow JavaScript type system")
+    (description "Flow is a gradual type system for JavaScript.  This package
+provides the Flow parser in its compiled-to-JavaScript form for use with
+Node.js and NPM.")))
+
 (define-public tinyproxy
   (package
     (name "tinyproxy")
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 19:18:05 GMT) Full text and rfc822 format available.

Message #122 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Subject: [PATCH v2 15/16] gnu: Add font-katex.
Date: Thu, 16 Nov 2023 14:15:53 -0500
* gnu/packages/javascript.scm (font-katex): New variable.
---
 gnu/packages/javascript.scm | 74 +++++++++++++++++++++++++++++++++++++
 1 file changed, 74 insertions(+)

diff --git a/gnu/packages/javascript.scm b/gnu/packages/javascript.scm
index 97cb3b6270..ee7a48154c 100644
--- a/gnu/packages/javascript.scm
+++ b/gnu/packages/javascript.scm
@@ -30,9 +30,15 @@ (define-module (gnu packages javascript)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages fontutils)
   #:use-module (gnu packages java)
   #:use-module (gnu packages node)
+  #:use-module (gnu packages perl)
+  #:use-module (gnu packages python)
+  #:use-module (gnu packages python-compression)
+  #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages readline)
+  #:use-module (gnu packages tex)
   #:use-module (gnu packages uglifyjs)
   #:use-module (gnu packages web)
   #:use-module (guix gexp)
@@ -41,6 +47,7 @@ (define-module (gnu packages javascript)
   #:use-module (guix git-download)
   #:use-module (guix build-system ant)
   #:use-module (guix build-system cmake)
+  #:use-module (guix build-system copy)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system minify)
   #:use-module (guix build-system node)
@@ -372,6 +379,73 @@ (define-public js-mathjax-for-r-mathjaxr
               (base32
                "1q063l6477z285j6h5wvccp6iswvlp0jmb96sgk32sh0lf7nhknh")))))))))
 
+(define-public font-katex
+  (package
+    (name "font-katex")
+    (version "0.16.4")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+              (url "https://github.com/KaTeX/KaTeX")
+              (commit (string-append "v" version))))
+       (sha256
+        (base32
+         "0z6y2188lhfv0gk0hp4rm37g6fs99qb3ab2q3n9g76ga9dwxhw3s"))
+       (snippet
+        ;; unbundle generated files
+        #~(begin
+            (use-modules (guix build utils))
+            (delete-file "src/fontMetricsData.js")
+            (delete-file-recursively "fonts")))
+       (file-name (git-file-name "katex" version))))
+    (build-system copy-build-system)
+    (native-inputs (list (texlive-updmap.cfg
+                          (list texlive-amsfonts
+                                texlive-cm
+                                texlive-fonts-rsfs))
+                         fontforge
+                         mftrace
+                         ttfautohint
+                         perl
+                         perl-json
+                         python
+                         python-fonttools
+                         python-brotli
+                         python-zopfli
+                         which))
+    (arguments
+     (list
+      #:install-plan
+      #~`(("fonts/" "share/fonts/truetype/katex/")
+          ("src/fontMetricsData.js" "share/katex/"))
+      #:imported-modules
+      `((guix build union)
+        ,@%copy-build-system-modules)
+      #:modules
+      '((guix build copy-build-system)
+        (guix build union)
+        (guix build utils))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-before 'install 'build
+            (lambda args
+              (invoke "make" "-C" "src/fonts" "all")
+              (union-build "fonts"
+                           '("src/fonts/ttf"
+                             "src/fonts/woff"
+                             "src/fonts/woff2")
+                           #:symlink copy-file)))
+          (add-after 'build 'build-metrics
+            (lambda args
+              (with-directory-excursion "dockers/fonts"
+                ;; script assumes it is run from this directory
+                (invoke "./buildMetrics.sh")))))))
+    (home-page "https://katex.org")
+    (synopsis "Fonts for KaTeX")
+    (description "This package contains the fonts required for KaTeX.")
+    (license license:expat)))
+
 (define-public js-commander
   (package
     (name "js-commander")
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 19:18:06 GMT) Full text and rfc822 format available.

Message #125 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Philip McGrath <philip <at> philipmcgrath.com>
To: 67019 <at> debbugs.gnu.org
Cc: Philip McGrath <philip <at> philipmcgrath.com>,
 Liliana Marie Prikler <liliana.prikler <at> gmail.com>
Subject: [PATCH v2 16/16] gnu: Add katex.
Date: Thu, 16 Nov 2023 14:15:54 -0500
* gnu/packages/javascript.scm (katex): New variable.
---
 gnu/packages/javascript.scm | 255 +++++++++++++++++++++++++++++++++++-
 1 file changed, 253 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/javascript.scm b/gnu/packages/javascript.scm
index ee7a48154c..76a51c22ac 100644
--- a/gnu/packages/javascript.scm
+++ b/gnu/packages/javascript.scm
@@ -32,6 +32,7 @@ (define-module (gnu packages javascript)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages fontutils)
   #:use-module (gnu packages java)
+  #:use-module (gnu packages man)
   #:use-module (gnu packages node)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages python)
@@ -382,7 +383,7 @@ (define-public js-mathjax-for-r-mathjaxr
 (define-public font-katex
   (package
     (name "font-katex")
-    (version "0.16.4")
+    (version "0.16.9")
     (source
      (origin
        (method git-fetch)
@@ -391,7 +392,7 @@ (define-public font-katex
               (commit (string-append "v" version))))
        (sha256
         (base32
-         "0z6y2188lhfv0gk0hp4rm37g6fs99qb3ab2q3n9g76ga9dwxhw3s"))
+         "1aq8n9s4r15m1fdi4h58qxal4brkafm4xsw6rpz40wqi9454kkgn"))
        (snippet
         ;; unbundle generated files
         #~(begin
@@ -446,6 +447,256 @@ (define-public font-katex
     (description "This package contains the fonts required for KaTeX.")
     (license license:expat)))
 
+(define-public katex
+  (package
+    (inherit font-katex)
+    (name "katex")
+    (outputs '("out" "dist"))
+    (build-system node-build-system)
+    (native-inputs
+     (list esbuild
+           flow-remove-types
+           help2man
+           lessc))
+    (inputs
+     (list font-katex
+           js-commander))
+    (arguments
+     (list
+      #:tests? #f ; many more dependencies
+      #:modules
+      `((guix build node-build-system)
+        (ice-9 match)
+        (srfi srfi-1)
+        (srfi srfi-26)
+        (guix build utils))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-before 'patch-dependencies 'move-sources
+            (lambda* (#:key inputs #:allow-other-keys)
+              ;; Our node-build-system doesn't properly respect the "files"
+              ;; entry in "package.json" to determine which files to install.
+              ;; This case is particularly egregious because the source
+              ;; repository also contains the source for the whole katex.org
+              ;; website.  For now, manually do what "files" ought to do.
+              (mkdir "../guix-source")
+              (copy-recursively "src" "../guix-source/src")
+              (copy-recursively "contrib" "../guix-source/contrib")
+              (for-each (cut install-file <> "../guix-source")
+                        '("README.md"
+                          "LICENSE"
+                          "package.json"
+                          "katex.js"
+                          "cli.js"))
+              (install-file
+               (search-input-file inputs "share/katex/fontMetricsData.js")
+               "../guix-source/src")
+              (chdir "../guix-source")))
+          (add-after 'move-sources 'patch-package-json
+            (lambda args
+              (with-atomic-json-file-replacement "package.json"
+                (match-lambda
+                  (('@ . alist)
+                   (cons '@
+                    (filter-map
+                     (match-lambda
+                       (((or "devDependencies" "scripts") . _)
+                        #f)
+                       ;; ESBuild can't generate Universal Module Definitions,
+                       ;; so keep our CJS separate from our browser builds:
+                       (("files" . lst)
+                        `("files" "guix-node-cjs/" ,@lst))
+                       (("main" . "dist/katex.js")
+                        `("main" . "guix-node-cjs/katex.js"))
+                       (("exports" '@ . alist)
+                        `("exports" @
+                          ,@(map (match-lambda
+                                   (("./*" . "./*")
+                                    `("./*" . "./*"))
+                                   ((lhs '@ . alist)
+                                    `(,lhs @
+                                      ,@(map (match-lambda
+                                               (("require" . ,str)
+                                                (cons
+                                                 "require"
+                                                 (string-append
+                                                  "./guix-node-cjs/"
+                                                  (substring str
+                                                             (string-length
+                                                              "./dist")))))
+                                               (other
+                                                other))
+                                             alist))))
+                                 alist)))
+                       (other
+                        other))
+                       alist)))))))
+          (add-after 'patch-dependencies 'patch-sources
+            (lambda* (#:key inputs #:allow-other-keys)
+              (substitute* "src/SourceLocation.js"
+                ;; for some reason, the + prefix isn't handled
+                ;; by flow-remove-types
+                (("[+](lexer|start|end)" _ name)
+                 name))
+              (substitute* "src/fonts.less"
+                ;; what webpack would do
+                (("@font-folder: \"\\.\\./fonts\";" orig)
+                 (string-append "@font-folder: \"fonts\"; // " orig)))
+              (define version
+                #$(package-version this-package))
+              (substitute* "src/katex.less"
+                (("@version: \"\";" orig)
+                 (string-append "@version: \"" version "\"; // " orig)))
+              (substitute* "katex.js"
+                (("version: __VERSION__," orig)
+                 (string-append "version: \"" version "\", // " orig)))))
+          (add-after 'patch-sources 'erase-types
+            (lambda args
+              (invoke "flow-remove-types"
+                      "--sourcemaps"
+                      "--out-dir" "../erased/src/"
+                      "src/")
+              (invoke  "flow-remove-types"
+                       "--sourcemaps"
+                       "--out-dir" "../erased/"
+                       "katex.js")
+              (invoke "flow-remove-types"
+                      "--sourcemaps"
+                      "--out-dir" "../erased/contrib/"
+                      "contrib/")))
+          (add-after 'erase-types 'build-js
+            (lambda args
+              (with-directory-excursion "../erased"
+                ;; ^ avoid "../erased" in generated code
+                (define (esbuild . args)
+                  (apply invoke `("esbuild"
+                                  "--bundle"
+                                  "--log-limit=0"
+                                  "--platform=neutral"
+                                  ,@args)))
+                (esbuild "--outfile=../guix-source/dist/katex.mjs"
+                         "--format=esm"
+                         "katex.js")
+                ;; Workaround  for different handling of ES6 default export
+                ;; when generating CJS:
+                (esbuild "--outfile=katex-cjs.js"
+                         "--format=cjs"
+                         "katex.js")
+                (with-output-to-file "katex-wrapper.js"
+                  (lambda ()
+                    (display
+                     "module.exports = require('./katex-cjs.js').default;\n")))
+                (esbuild "--outfile=../guix-source/guix-node-cjs/katex.js"
+                         "--format=cjs"
+                         "katex-wrapper.js")
+                (esbuild "--outfile=../guix-source/dist/katex.js"
+                         "--format=iife"
+                         "--global-name=katex"
+                         "katex-wrapper.js")
+                (esbuild "--outfile=../guix-source/dist/katex.min.js"
+                         "--minify"
+                         "--format=iife"
+                         "--global-name=katex"
+                         "katex-wrapper.js")
+                ;; Build extensions:
+                (for-each
+                 (match-lambda
+                   ((name export)
+                    ;; The copy-tex extension doesn't actually import katex,
+                    ;; but it's harmless to handle it the same way.
+                    (with-directory-excursion (string-append "contrib/" name)
+                      (esbuild (string-append "--outfile=../../../guix-source"
+                                              "/guix-node-cjs/contrib/"
+                                              name ".js")
+                               "--format=cjs"
+                               "--external:katex"
+                               (string-append name ".js"))
+                      (substitute* (string-append name ".js")
+                        (("import katex from \"katex\";")
+                         "import katex from \"../katex.mjs\";"))
+                      (esbuild (string-append "--outfile=" name ".mjs")
+                               "--format=esm"
+                               "--external:../katex.mjs"
+                               (string-append name ".js"))
+                      (install-file (string-append name ".mjs")
+                                    "../../../guix-source/dist/contrib")
+                      (substitute* (string-append name ".js")
+                        (("import katex")
+                         "// import katex"))
+                      (for-each
+                       (lambda (minify?)
+                         (apply
+                          esbuild
+                          `(,(string-append "--outfile=../../.."
+                                            "/guix-source/dist/contrib/"
+                                            name
+                                            (if minify? ".min" "")
+                                            ".js")
+                            "--format=iife"
+                            ,@(if minify?
+                                  '("--minify")
+                                  '())
+                            ,@(if export
+                                  `("--global-name=guixTmp"
+                                    ,(string-append "--banner:js=const "
+                                                    export
+                                                    " = (() => {")
+                                    "--footer:js=return guixTmp.default;\n})();")
+                                  '())
+                            ,(string-append name ".js"))))
+                       '(#t #f)))))
+                 '(("auto-render" "renderMathInElement")
+                   ("copy-tex" #f)
+                   ("mathtex-script-type" #f)
+                   ("mhchem" #f)
+                   ("render-a11y-string" "renderA11yString"))))))
+          (add-after 'build-js 'build-css
+            (lambda args
+              (invoke "lessc" "src/katex.less" "dist/katex.css")))
+          (add-after 'install 'generate-man-page
+            (lambda args
+              (invoke "help2man"
+                      "-N"
+                      "-n" "render TeX math to HTML and MathML"
+                      "--output=katex.1"
+                      (string-append #$output "/bin/katex"))
+              (install-file "katex.1"
+                            (string-append #$output "/share/man/man1"))))
+          (add-after 'generate-man-page 'install-dist
+            (lambda* (#:key inputs #:allow-other-keys)
+              ;; The CSS, fonts, etc. needed for KaTeX, plus the optional
+              ;; bundled version of the JavaScript for dynamic use in the
+              ;; browser, are in the 'dist' directory of the Node module.
+              ;; Putting them in a separate output lets them be used without
+              ;; retaining a reference to Node and the cli utility.
+              ;; In Debian, 'dist' is a symlink to /usr/share/javascript/katex:
+              ;; do likewise to help tools that may need to find it.
+              (define up-dist-dir
+                (string-append #$output:dist "/share/javascript"))
+              (define dist-dir
+                (string-append up-dist-dir "/katex"))
+              (mkdir-p up-dist-dir)
+              (with-directory-excursion
+                  (string-append #$output "/lib/node_modules/katex")
+                (rename-file "dist" dist-dir)
+                (symlink dist-dir "dist"))
+              (with-directory-excursion dist-dir
+                ;; Link the fonts to where the CSS expects them:
+                (symlink (search-input-directory inputs
+                                                 "share/fonts/truetype/katex")
+                         "fonts")
+                ;; We can't actually minify the CSS, but fake it for anything
+                ;; that may expect it. With Brotli compression, the difference
+                ;; is only about 300 bytes anyway.
+                (symlink "katex.css" "katex.min.css")))))))
+    (synopsis "Fast math typesetting for the web")
+    (description "KaTeX renders TeX math notation to HTML and/or MathML.  The
+rendered output does not depend on JavaScript, so rendering can be done
+entirely ahead-of-time using the @command{katex} command-line tool.  When
+desired, KaTeX can also be used as a JavaScript library in the browser to
+render math dynamically, and it is designed to be fast, even on pages with
+hundreds of mathematical expressions.")))
+
 (define-public js-commander
   (package
     (name "js-commander")
-- 
2.41.0





Information forwarded to guix-patches <at> gnu.org:
bug#67019; Package guix-patches. (Thu, 16 Nov 2023 20:30:01 GMT) Full text and rfc822 format available.

Message #128 received at 67019 <at> debbugs.gnu.org (full text, mbox):

From: Liliana Marie Prikler <liliana.prikler <at> gmail.com>
To: Philip McGrath <philip <at> philipmcgrath.com>, 67019 <at> debbugs.gnu.org
Subject: Re: [PATCH v2 09/16] gnu: Add ocaml-flow-parser.
Date: Thu, 16 Nov 2023 21:29:09 +0100
Am Donnerstag, dem 16.11.2023 um 14:15 -0500 schrieb Philip McGrath:
> * gnu/packages/web.scm (ocaml-flow-parser): New variable.
> ---
>  gnu/packages/web.scm | 95
> ++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 95 insertions(+)
> 
> diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
> index 9efc6ebc9d..b222c2ae40 100644
> --- a/gnu/packages/web.scm
> +++ b/gnu/packages/web.scm
> @@ -96,6 +96,7 @@ (define-module (gnu packages web)
>    #:use-module (guix build-system cargo)
>    #:use-module (guix build-system cmake)
>    #:use-module (guix build-system copy)
> +  #:use-module (guix build-system dune)
>    #:use-module (guix build-system glib-or-gtk)
>    #:use-module (guix build-system gnu)
>    #:use-module (guix build-system go)
> @@ -173,6 +174,7 @@ (define-module (gnu packages web)
>    #:use-module (gnu packages node)
>    #:use-module (gnu packages node-xyz)
>    #:use-module (gnu packages nss)
> +  #:use-module (gnu packages ocaml)
>    #:use-module (gnu packages openldap)
>    #:use-module (gnu packages openstack)
>    #:use-module (gnu packages package-management)
> @@ -1938,6 +1940,99 @@ (define-public esbuild
>  and other data, for distribution on the web.")
>      (license license:expat)))
>  
> +(define-public ocaml-flow-parser
> +  (package
> +    (name "ocaml-flow-parser")
> +    (version "0.159.0")
> +    (outputs '("out" "js"))
> +    (source
> +     (origin
> +       (method git-fetch)
> +       (uri (git-reference
> +             (url "https://github.com/facebook/flow")
> +             (commit (string-append "v" version))))
> +       (sha256
> +        (base32
> "1i9svf641s24nj4w6y9vvglzg29h0lr4n9a6mvwrn9psy9x1lril"))
> +       (file-name (git-file-name "flow" version))))
> +    (build-system dune-build-system)
> +    (propagated-inputs (list ocaml-base
> +                             ocaml-core-kernel
> +                             ocaml-dtoa
> +                             ocaml-sedlex
> +                             ocaml-wtf8))
> +    (native-inputs (list js-of-ocaml
> +                         ocamlbuild
> +                         ocaml-findlib
> +                         ocaml-ounit2
> +                         ocaml-ppx-deriving
> +                         ocaml-ppx-gen-rec
> +                         ocaml-visitors))
> +    (arguments
> +     (list
> +      #:tests? #f ; tests need lwt_ppx
> +      #:package "flow_parser"
> +      #:phases
> +      #~(modify-phases %standard-phases
> +          (add-before 'build 'chdir
> +            (lambda args
> +              (chdir "src/parser")))
> +          (add-before 'build 'patch-source
> +            (lambda args
> +              ;; Avoid errors with newer OCaml:
> +              ;; "Error (warning 16 [unerasable-optional-
> argument]):"
> +              ;;   " this optional argument cannot be erased."
> +              ;; "Error (warning 69 [unused-field]):"
> +              ;;   " mutable record field buf is never mutated."
> +              ;; "Error (warning 70 [missing-mli]): Cannot find
> interface file."
> +              (substitute* "_tags"
> +                (("<\\*\\.ml\\*>: warn[(]-39[)]")
> +                 "<*.ml*>: warn(-16-39-70)"))
> +              (substitute* "../../_tags"
> +                (("<\\*\\*/\\*.ml\\*>: ")
> +                 "<**/*.ml*>: warn(-69), "))
> +              ;; Deprecation of Js.Unsafe.variable, Js.Error,
> Js.raise_js_error
> +              (substitute* "flow_parser_js.ml"
> +                (("Js\\.Unsafe\\.variable")
> +                 "Js.Unsafe.pure_js_expr"))
> +              (substitute* "flow_parser_dot_js.ml"
> +                (("Js\\.Error")
> +                 "Js_of_ocaml.Js_error.Exn")
> +                (("Js\\.raise_js_error")
> +                 "Js_of_ocaml.Js_error.raise_"))))
> +          (replace 'build
> +            (lambda args
> +              (invoke "make"
> +                      (string-append "CC=" #$(cc-for-target))
> +                      "build-parser")))
You might want to let-bind (invoke "make" "CC=..." <>) so that you can
call it with a single argument in this and other phases.
> +          (add-after 'build 'build-js
> +            (lambda args
> +              (invoke "make"
> +                      (string-append "CC=" #$(cc-for-target))
> +                      "js")))
> +          (replace 'check
> +            (lambda* (#:key tests? #:allow-other-keys)
> +              (when tests?
> +                (invoke "make"
> +                        (string-append "CC=" #$(cc-for-target))
> +                        "test-ocaml"))))
> +          (replace 'install
> +            (lambda args
> +              (invoke "make"
> +                      (string-append "CC=" #$(cc-for-target))
> +                      "ocamlfind-install")))
> +          (add-after 'install 'install-js
> +            (lambda args
> +              (install-file "flow_parser.js"
> +                            (string-append #$output:js
> +                                          
> "/share/javascript/flow")))))))
> +    (properties `((upstream-name . "flow_parser")))
> +    (home-page "https://flow.org")
> +    (synopsis "Parser for the Flow JavaScript type system")
> +    (description "Flow is a gradual type system for JavaScript. 
> This package
> +provides the Flow parser, which is an OCaml library that can also be
> compiled
> +to JavaScript.")
> +    (license license:expat)))
> +
Cheers

This bug report was last modified 169 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.