unstale

npm / d3-cloud

d3-cloud

What changed in d3-cloud 1 to 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-10-30.

21 breaking1 security7 new APIs and options6 behavior and defaults2 tooling2 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli 0.2.9 on npm

d3-cloud 235 changes

Breaking changes 19

  • Invalid arguments now throw instead of being silently replaced, including invalid coordinates, dimensions, padding, random functions, fonts, and canvases.

    2.0.0release notes

  • Both built-in spirals stretch to the aspect ratio only up to 64:1, changing layouts with more extreme aspect ratios.

    2.0.0release notes

  • clear() throws while place() is searching rather than corrupting masks or occupancy.

    2.0.0release notes

  • The event-driven factory API is replaced with the class-based CloudLayout API.

    2.0.0release notes

  • The class-based API introduces CloudSprite in place of the old event-driven factory API.

    2.0.0release notes

  • Custom data is carried by a single datum option, stored by reference on sprites and placed words; other option fields are ignored rather than copied.

    2.0.0release notes

  • The default font size is now 1 instead of sqrt(value); set styling explicitly.

    2.0.0release notes

  • The default rotation is now zero instead of a random multiple of 30 degrees.

    2.0.0release notes

  • The package is ESM-only; the old Browserify and CommonJS distribution shapes are removed.

    2.0.0release notes

  • getSprite() throws if called while a sprite is being drawn to the same canvas.

    2.0.0release notes

  • Input word objects are no longer mutated; placement returns separate plain words and callers control word ordering.

    2.0.0release notes

  • The minimum Node.js version is now 20.

    2.0.0release notes

  • The rectangular strategy visits every point of a 4-pixel grid in aspect-ratio-shaped rings, producing denser packing at any aspect ratio.

    2.0.0release notes

  • Search limits scale with the number of possible placement positions and apply equally to built-in and custom strategies.

    2.0.0release notes

  • size([width, height]) now defines the centered layout box; layouts may grow beyond it.

    2.0.0release notes

  • The old spiral() API is replaced with strategy().

    2.0.0release notes

  • Padding uses round stroke joins, extending exactly padding pixels from glyph outlines instead of up to ten times that at sharp corners.

    2.0.0release notes

  • Text rasters use measured ink bounds, account for overhang and accents, redraw when ink reaches the edge, and use centered text alignment.

    2.0.0release notes

  • The UMD/script-tag build and d3.layout.cloud global are removed; browser scripts must use ESM imports.

    2.0.0release notes

Security 1

  • Placement uses a private copy of each sprite mask and accepts only sprites created by getSprite(), preventing changed or forged sprites from corrupting a layout.

    2.0.0release notes

New APIs and options 7

  • erase() erases a word returned by place().

    2.0.0release notes

  • CloudLayout.getSprite(...) explicitly prepares immutable sprites that have no position and can be placed repeatedly.

    2.0.0release notes

  • Sprites can be extracted from image alpha masks, with optional resizing; images without intrinsic dimensions can be drawn at explicit dimensions.

    2.0.0release notes

  • A built-in noneStrategy provides single-attempt placement.

    2.0.0release notes

  • overflow(true | false) controls whether placement may extend beyond the layout box.

    2.0.0release notes

  • place() lets callers control placement using sprites created by getSprite().

    2.0.0release notes

  • Sparse packed block placement supports effectively unbounded layouts.

    2.0.0release notes

Behavior and default changes 4

  • Image sources may be images, videos, canvases, or ImageBitmaps, including node-canvas, and placed words retain the source type.

    2.0.0release notes

  • Placement tries the seed first, then searches from the nearest possible touch position, skipping positions that cannot fit without collision checks.

    2.0.0release notes

  • Image coordinates mark the sprite center, and text is rendered from x and y with a centered horizontal anchor.

    2.0.0release notes

  • Layouts may share a scratch canvas; a failed draw or readback makes layouts using it request a canvas from their factory again.

    2.0.0release notes

Tooling 2

  • datum is typed generically and inferred from getSprite() options.

    2.0.0release notes

  • The package now includes TypeScript declarations for both the package entry and build/d3-cloud.js.

    2.0.0release notes

Fixes and other changes 2

  • blockSize() throws while place() is searching rather than corrupting masks or occupancy.

    2.0.0release notes

  • Sprite geometry is trimmed to occupied pixels independently of packed row alignment, preventing bounded layouts from rejecting words because of raster slack.

    2.0.0release notes

d3-cloud 14 changes

Breaking changes 2

Behavior and default changes 2

  • The browser bundle now includes the 1.2.8 change to default rotations, so its rotation behavior is updated.

    1.2.9release notes

  • Default rotation now uses the layout's random() function, making rotations reproducible with a seeded random number generator.

    1.2.8release notes