• Bug#1064824: libjs-d3-tip: TypeError: h.map is not a function

    From Julian Gilbey@21:1/5 to All on Mon Feb 26 10:40:01 2024
    Package: libjs-d3-tip
    Version: 0.7.1-5
    Severity: important

    I have tried to use d3-tip.min.js for a website in another package,
    but it fails with the error: "Uncaught (in promise) TypeError: h.map
    is not a function". This comes from the index.js line "d3.map({
    ...". Presumably d3 no longer ships a map function. In more recent
    versions of d3-tip (which is now archived), this has been resolved by
    importing "map" from d3-collections. So maybe the best way to fix
    this bug is to upgrade the package.

    Best wishes,

    Julian

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Julian Gilbey@21:1/5 to Julian Gilbey on Mon Feb 26 11:20:01 2024
    On Mon, Feb 26, 2024 at 09:32:44AM +0000, Julian Gilbey wrote:
    Package: libjs-d3-tip
    Version: 0.7.1-5
    Severity: important

    I have tried to use d3-tip.min.js for a website in another package,
    but it fails with the error: "Uncaught (in promise) TypeError: h.map
    is not a function". This comes from the index.js line "d3.map({
    ...". Presumably d3 no longer ships a map function. In more recent
    versions of d3-tip (which is now archived), this has been resolved by importing "map" from d3-collections. So maybe the best way to fix
    this bug is to upgrade the package.

    Hi Petter,

    I see you've updated the version in salsa but not yet released it; is
    there any reason not to do so? Obviously, there are some missing (build-)dependencies (d3-collection, d3-selection, rollup), but those
    can be added without trouble. If it's OK, I can do that and release
    it.

    Best wishes,

    Julian

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Petter Reinholdtsen@21:1/5 to All on Mon Feb 26 12:20:01 2024
    [Julian Gilbey]
    If it's OK, I can do that and release it.

    It is more than OK, it is most welcome. I packaged this to solve a
    dependency, but do not know much about javascript packaging and would
    love for someone who do to take over. :)

    I suspect I prepared a new version and decided to wait for the next
    release before uploading, or ran into build problems and did not have
    time to investigate. I do not really remember any more.

    --
    Happy hacking
    Petter Reinholdtsen

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Julian Gilbey@21:1/5 to Petter Reinholdtsen on Mon Feb 26 17:40:01 2024
    On Mon, Feb 26, 2024 at 12:15:54PM +0100, Petter Reinholdtsen wrote:
    [Julian Gilbey]
    If it's OK, I can do that and release it.

    It is more than OK, it is most welcome. I packaged this to solve a dependency, but do not know much about javascript packaging and would
    love for someone who do to take over. :)

    I suspect I prepared a new version and decided to wait for the next
    release before uploading, or ran into build problems and did not have
    time to investigate. I do not really remember any more.

    Thanks Petter!

    There are definitely some build problems, and I've fixed most of them
    (though it's a bit clunky). But I don't understand enough JavaScript/ECMA-Script to solve the remaining issues. I will probably
    ask on the list for some help with this.

    Best wishes,

    Julian

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Julian Gilbey@21:1/5 to All on Wed Feb 28 23:00:01 2024
    reassign 1064824 node-d3 5.16.0+~cs5.28.10-1
    severity 1064824 serious
    retitle 1064824 node-d3: fails to export map and probably other functions thanks

    (I'm raising this to severity "serious" because it breaks a different
    package.)

    (For background to the discovery of this bug, see below.) The Debian
    version of d3.js does not export "map", which it should. This breaks
    the libjs-d3-tip package. In fact, the export lists are significantly different:

    $ grep '^exports' d3-npm/dist/d3.js | sort > /tmp/d3-npm.exports
    $ grep ^exports /usr/share/nodejs/d3/dist/d3.js | sort > /tmp/d3-debian.exports $ diff -u /tmp/d3-npm.exports /tmp/d3-debian.exports
    [520 lines, lots of differences are due to "$1" type suffixes/
    $ sed -e 's/\$[0-9]*;/;/' /tmp/d3-npm.exports > /tmp/d3-npm.exports.trimmed
    $ sed -e 's/\$[0-9]*;/;/' /tmp/d3-debian.exports > /tmp/d3-debian.exports.trimmed
    $ diff -u /tmp/d3-npm.exports.trimmed /tmp/d3-debian.exports.trimmed

    This gives lots of differences still; stripping down to just the
    differences still has many, many differences: some new exports not in
    the original d3, and some lost exports; the list begins:

    +exports.Adder = Adder;
    -exports.bisect = bisectRight;
    +exports.bin = bin;
    +exports.bisect = bisect;
    +exports.bisectCenter = bisectCenter;
    +exports.blur2 = blur2;
    +exports.blur = blur;
    +exports.blurImage = blurImage;
    +exports.count = count;
    -exports.csvFormatRow = csvFormatRow;
    -exports.csvFormatValue = csvFormatValue;

    Now, one *might* guess that the reason for this is that d3 imports
    lots of d3-* modules, and these have been updated and changed since d3
    v5.16.0 was released, so these changes are reflected in the new list
    of exports (though people assuming that the Debian version of d3
    v5.16.0 reflects the upstream version will then be confused and
    possibly frustrated). But that doesn't explain the absence of map,
    which comes from (node-)d3-collection. For /usr/share/nodejs/d3-collection/dist/d3-collection.js reads:

    exports.entries = entries;
    exports.keys = keys;
    exports.map = map;
    exports.nest = nest;
    exports.set = set;
    exports.values = values;

    So I cannot fathom why map is not being exported by d3 itself. There
    may be other cases of this behaviour, but I have not investigated
    further. I am quite stumped by this.


    Background to this: I'm trying to package a new package which provides
    a web server to visualise some data. The package includes a few
    precompiled JavaScript libraries obtained from npmjs.com, and the
    server works fine with them. But following Debian policy, I need to
    replace those with the source packages. And the server then doesn't
    work.

    The JavaScript libraries which the package uses are: d3 v5.16.0,
    d3-tip, apparently v0.9.1, along with jQuery and bootstrap4. I have
    replaced all of these with the versions in the corresponding Debian
    packages (and I've just uploaded a new version of d3-tip, thinking
    that that was the cause of the bug).

    When visiting the served web page, the console log gives the error
    message:

    Uncaught (in promise) TypeError: t.map is not a function
    n http://localhost:8080/js/d3/d3-tip.min.js:1
    main http://localhost:8080/js/index.js:848
    async* http://localhost:8080/js/index.js:993

    (This has changed from the original bug report as the minimised new
    version of d3-tip has t.map instead of h.map.)

    d3-tip.js requires d3-collection, from which it calls a map function.
    I tried replacing d3-tip.min.js with the pre-packaged version rather
    than the (newly built) Debian version, but that did not help. I
    reverted that change and instead replaced d3.v5.min.js (which is a
    copy of /usr/share/nodejs/d3/dist/d3.min.js) with the version provided
    by upstream, which is a verbatim copy of the npmjs.com d3.min.js, and
    the server then worked perfectly. So this told me that it is the
    Debian compiled d3 which is not working correctly.

    Best wishes,

    Julian

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Julian Gilbey@21:1/5 to Julian Gilbey on Mon Mar 4 23:00:02 2024
    On Mon, Mar 04, 2024 at 09:18:01PM +0000, Julian Gilbey wrote:
    [...]
    So it's specifically "map" that is problematic, and I just happen to
    have stumbled upon it: d3 v5 depends on d3-array version 1, but the
    version of node-d3-array in unstable is 3.2.0+~cs5.0.6-2, and this is
    causing the conflict.

    I don't know the best way to fix this. node-d3-array version was
    upgraded from 1.2.4 to 3.x about two years ago, so d3 would have had
    this bug since then, but I'm the first one to stumble upon it :-/

    Perhaps we could package node-d3-array-1 (version 1.2.4) and have
    node-d3 build-depends on that?

    I was just wondering if there's a simpler way than having a new
    package: have d3-array 1.2.4 being an unexported component of the
    node-d3 source package, and instead of Build-Depends: node-d3-array,
    have a Build-Conflicts: node-d3-array. But then I discovered that the
    binary package node-d3 depends on node-d3-array, as do 7 other
    packages in testing (I haven't checked unstable). I'm guessing that
    most of those dependencies probably need version 1.x of d3-array, so
    it may be that having a node-d3-array-1 (or -v1) package is actually
    the way forward in this situation.

    Best wishes,

    Julian

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nilesh Patra@21:1/5 to Julian Gilbey on Tue Mar 5 13:20:01 2024
    On Mon, Mar 04, 2024 at 09:18:01PM +0000, Julian Gilbey wrote:
    index.js → dist/d3.js...
    (!) Conflicting re-exports
    "index.js" re-exports "map" from both "../../../usr/share/nodejs/d3-array/src/index.js" and "../../../usr/share/nodejs/d3-collection/src/index.js" (will be ignored).
    created dist/d3.js in 1.9s

    index.js → dist/d3.min.js...
    (!) Conflicting re-exports
    "index.js" re-exports "map" from both "../../../usr/share/nodejs/d3-array/src/index.js" and "../../../usr/share/nodejs/d3-collection/src/index.js" (will be ignored).
    created dist/d3.min.js in 4.2s
    -----

    I have pushed a commit to salsa that hopefully fixes this - can you please try with the same and see if that
    helps you somewhat?

    So it's specifically "map" that is problematic, and I just happen to
    have stumbled upon it: d3 v5 depends on d3-array version 1, but the
    version of node-d3-array in unstable is 3.2.0+~cs5.0.6-2, and this is
    causing the conflict.

    I don't know the best way to fix this. node-d3-array version was
    upgraded from 1.2.4 to 3.x about two years ago, so d3 would have had
    this bug since then, but I'm the first one to stumble upon it :-/

    Perhaps we could package node-d3-array-1 (version 1.2.4) and have
    node-d3 build-depends on that?

    I tried to embed it and realised it is creating an unholy mess. I got it working eventually
    but it can open a can of worms sometime later. Maybe packaging the older version
    would be the way to go if my fix above does not work.

    I've added yadd to the thread for more qualified advice.

    Best,
    Nilesh

    -----BEGIN PGP SIGNATURE-----

    iHUEABYIAB0WIQSglbZu4JAkvuai8HIqJ5BL1yQ+2gUCZecLXAAKCRAqJ5BL1yQ+ 2sTSAQCkK7LE3I4f/zqmszPf1DWGf8qSr16ssvpJCR+QVzYXJQD/bwGS7PBRB5qJ zf4Gsf6Ft4Y55A7YP3cVB7Pk+4nSBQ8=
    =P2SN
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)