Releases: edemaine/svgtiler
Releases · edemaine/svgtiler
v3.1.0
Render
gainsforEach
helper that iterates over all cells with aContext
Render
gainscontext
helper to make newContext
instances at arbitrary locationsContext
gainsstartsWith
/endsWith
shortcut helpers (to query thekey
even when it might beundefined
)- Empty fragments returned from mapping now treated like empty symbols (just like empty-string SVG content); previously crashed (#104)
- Empty content returned from mapping always treated as having width/height 0 instead of warning
- Not-first symbols in an array stack no longer warn about missing width/height (#105)
- Documentation improvements:
- Render class
key
isundefined
, notnull
, when out of bounds- How to upgrade with NPM
Full Changelog: v3.0.0...v3.1.0
v3.0.0
- Major rewrite to improve usage and add a ton of features, including Maketiles, stacked symbols in a single tile, automatically dynamic map functions, arbitrary pre/postprocessing, global underlays/overlays,
<def>
s support, better SVG cropping, improved performance, and smaller SVG outputs. - New "Maketile" feature for setting default
svgtiler
command-line arguments (replacing the need for Makefiles andmake
). (#84, #99)Maketile.args
can specify default command-line arguments, as if they were in a shell. In particular, you can use glob patterns like**/*.asc
, quotes and backslash escapes, and comments via#
. Unlike shells, you can freely use multiple lines.Maketile.js
orMaketile.coffee
canexport make
(orexport default
) with a function that runssvgtiler
with computed arguments.svgtiler(...args)
is like runningsvgtiler
on the command line with the specified arguments. String arguments are parsed as in.args
, whileArray
arguments are treated as is without further processing. You can also pass in already loadedDrawing
,Mapping
, orStyle
objects.- You can write multiple make rules (chosen on the command line) by wrapping functions in an object or
Map
(similar to mapping files), or write a generic function that takes the rule name as an argument. - You can loop over files matching a glob pattern via
svgtiler.glob
, and check for additional glob pattern matches viasvgtiler.match
.
- If you specify an actual file (mapping and/or drawing), default Maketiles get ignored.
- You can still specify additional arguments to add to what's run by the
Maketile
, e.g.svgtiler -v
. - You can specify a differently named Maketile via
--maketile
.
- Other command-line changes: (#84, #99)
- Specifying a directory name on the command line recurses into that directory, running the
Maketile
within. -O
lets you override the generated output filename stem (sans extension), including specifying patterns likeprefix_*_suffix
(#84)-s key=value
setsshare.key
to the string"value"
, as shorthand for creating a mapping file that setsshare
.( ... )
contains mapping files,-s
share settings, and other command-line options to within the parentheses.--bg color
for specifying background color. (#57)--use-data
addsdata-{key,i,j,k}
attributes to<use>
tags. (#48)--use-href
useshref
attributes instead ofxlink:href
--clean
for deleting files that would be generated.- Support multiple single-dash arguments like
-pP
as shorthand for-p -P
. -v
/--verbose
option to help debug e.g. Babel processing.
- Specifying a directory name on the command line recurses into that directory, running the
- Generalized mappings (#13)
- All function mappings are now automatically dynamic; no need to wrap in a second layer of function.
- For efficiency, you can force a function (or any mapping) to be treated as static (dependent only on key, not e.g. neighbors) via
svgtiler.static
wrapper. - Function mappings get
context
as a second argument (afterkey
) in addition tothis
, which is helpful for passingcontext
around or when using=>
arrow functions (which can't receivethis
). Current context can also be found viagetContext()
. - Mapping can defined by
Map
orWeakMap
as alternative to raw object. - Sequential composition mapping via
new Mappings map1, map2
applies both maps and takes the first match, as if two maps were specified on the command line. (#89) - Can nest functions, objects,
Map
s,Mappings
, orArray
s (see below) arbitrarily deep.
- Tiles can stack multiple
<symbol>
s on top of each other, by returning an array of SVG content from a mapping function (#33). The first non-null symbol defines defines the tile size.- Each
<symbol>
can have its ownz-index
, for proper component stacking. - Deduplication of the individual
<symbol>
s makes for smaller SVG output. - Parallel composition mapping via
[map1, map2]
applies both maps and stacks one on top of the other (depending onz-index
). (#83)
- Each
<symbol>
s in mappings no longer needviewBox
; you can simply specifywidth
andheight
and theviewBox
will default to0 0 width height
. You can also specify both and it behaves as in SVG. (#44)boundingBox
is the new name for theoverflowBox
attribute (though the old name is still supported). The box can now be smaller than the layout box (specified viawidth
/height
orviewBox
), which trims the overall bounding box when possible (#86). Technically this is a BREAKING CHANGE if youroverflowBox
is smaller than the layout box, but this is what it ought to happen then..js
/.coffee
mapping files can now have many newexport
s:init
is useful for applying side effects to theshared
object; it runs once per "load" of the mapping file, with mapping files alwaysinit
ing in command-line order (but sometimes more than once to restore an old state).preprocess
lets you scan and/or modify the tile keys in a drawing (#79)postprocess
lets you draw global content after tiles have been rendered (#81)- The mapping object can be exported as
map
, as a more descriptive name thandefault
. - For the final expression to be implicitly exported as the default, it must be an object expression (literal) or function expression; in particular, it cannot be an assignment or function call. Potentially BREAKING CHANGE, but fixes the behavior in many other files.
- You can specify a background fill (drawn via a big backing rectangle) via the
--bg
command-line option, or viasvgtiler.background(color)
. (#57) This is a helpful special case ofpostprocess
ing. - Tiles causing errors in your
.js
/.coffee
code now render as a warning symbol, and will no longer prevent the rest of the drawing from rendering. This makes it easier to see where your mapping code is crashing, and helps you write mappings incrementally. (#49) - Drawing file behavior tweaks (BREAKING CHANGES)
- Lines in ASCII art and CSV/TSV/SSV files are automatically normalized to have the same length, by appending blank strings (
''
) to short lines (same as XLSX files were). You can get the old behavior via--uneven
. (#85) - A blank sheet name in a spreadsheet file no longer has
_
in the generated filename. - If a spreadsheet file has only one sheet and it has a nonblank name, it will be in the generated filename.
- Lines in ASCII art and CSV/TSV/SSV files are automatically normalized to have the same length, by appending blank strings (
- Examples
- New grid-graph example, including
<marker>
demonstration - Chess examples with attack graph via
postprocess
- Tilt example modernized to use Preact
- Improve mario example to use tile arrays to reduce duplication and demonstrate background feature.
- Modernize to new generalized mappings, e.g. avoiding excess function wrappers and using
svgtiler.static
- New grid-graph example, including
- API changes:
renderDOM
(and otherrender
methods) now takemappings
andstyles
as part of general settings object, instead of as separate arguments. Thesemappings
andstyles
are now automatically cast intoMapping
andStyle
objects if needed. Butmappings
can no longer be a map object; it needs to be of the form{map: ...}
(or{default: ...}
), just like what would beimport *
ed from a mapping file. BREAKING CHANGESsvgtiler.def
lets you build markers, gradients, clip masks, etc. with automatically generated IDs, with automatic deduplication and removal of unused defs, and makes it easy to reference them. (#38)svgtiler.id
lets you build unique IDs, e.g. to re-use a graphical object (#38). (svgtiler.def
also uses this internally.)svgtiler.add(svg)
to add SVG content to the current rendering, e.g., in apreprocess
orpostprocess
function. This also enables adding metadata like<title>
(#94).svgtiler.require(filename)
loads a file (including drawings like ASCII art or spreadsheets, mappings, etc.) as if it were on the command line, producing aMapping
,Drawing
,Drawings
,Style
,Args
, orSVGFile
object.svgtiler.needVersion
for specifying version constraints on SVG Tiler, e.g.svgtiler.needVersion('3.x')
in yourMaketile.coffee
. (#99)svgtiler.getContext()
to find the currentContext
for a tile rendering, so you don't need to pass it through to auxiliary functions.svgtiler.runWithContext()
allows you to override the result ofsvgtiler.getContext()
.Context
has newat
method for absolute indexing (#78) andset
method for modifying keys (#69)Context
no longer hassymbols
orsymbol
attributes (as cells are now rendered one at a time, instead of all ahead of time).Context
object now shared throughout each drawing, so you could store extra drawing-specific data there.Context
hasrender
attribute pointing to currentRender
instance, in addition todrawing
attribute pointer to currentDrawing
instance.Drawing
keys are now allowed to be objects other thanString
s, e.g., via preprocessing or when creating manually vianew Drawing
.Drawing
has newat
,get
, andset
methods.Drawing
's main attribute renamed fromdata
tokeys
, andMapping
's main attribute renamed fromdata
tomap
. (#88)Drawing
has newmargins
andunevenLengths
attributes for understanding what happened during margin trimming and uneven length fixing.Mapping
'smodule
attribute renamed toexports
.- New
Render
class represents a rendering task for oneDrawing
, including all render parameters (e.g.drawing
,mappings
, andstyles
).xMin
,xMax
,yMin
,yMax
,width
,height
, andlayers
attributes which are useful inpreprocess
andpostprocess
.id
method for generating unique IDs;svgtiler.id
calls this.def
method for including<defs>
content;svgtiler.def
calls this.add
method for adding SVG content;svgtiler.add
calls this.makeDOM
,makeSVG
,makeTeX
re...
v2.4.1
- Fix
svgtiler
CLI on Windows, broken in v2.3.0 when fixing Linux, by wrapping CLI in another NodeJS layer - Revise Mario example to use new
share
feature - Improve documentation, e.g., what "SKIPPED" and "UNCHANGED" mean.
- Minor code cleanup
Full Changelog: v2.4.0...v2.4.1
v2.4.0
- Selective building (#70):
svgtiler
no longer builds everything; it now acts likemake
and selectively builds what it detects needs rebuilding..svg
/.tex
files will be recomputed only when they are older than the drawing file, any mapping file (or one of theirrequire
d dependencies), or any style file; otherwise, you will see the message(SKIPPED)
. These files only get rewritten (and their date stamp changed) if their contents have actually changed; otherwise, you will see the message(UNCHANGED)
. This pairs well with the PDF/PNG conversion of v2.3.0, which only does Inkscape conversion when the SVG file is newer: if the SVG doesn't change, it will no longer trigger PDF/PNG conversion.- Use
-f
/--force
to override and force all builds, like the old behavior.
- Use
- Support
require
/import
ing raster images and SVG files from JavaScript/CoffeeScript mapping files (#73). Returns the SVG content as Preact Virtual DOM, making it easy to modify (e.g., strip off<svg>
wrapper or add a child). Raw SVG string also available viarequire(...).svg
. - New Chess example illustrating new
require
feature for loading and manipulating.svg
files, dynamic symbol computation, and JSX notation for creating and composing symbols. - Provide new
share
global variable for sharing state between mapping files (#77). For example, this lets you define one mapping file whose behavior is controlled by options specified by one or more other mapping files. (See revised Mario example.) - Add
match
method toContext
for simpler RegExp matching (previously documented by not implemented) - Omit SVG Tiler version number from generated
.tex
files, for consistent builds and version control across multiple users - Warn instead of crash when mapping returns string
- Fix multiple
xmlns:xlink
attributes arising when embedding using.svg
files directly inside tiles. - Fix removal of SVG/XML comment headers in
.svg
source files (whenrequire
/import
ing and for namespace mangling) - Remove
examples
directory from NPM package, reducing package size from 1.1 MB (135.6 kB compressed) to 184.9 kB (55.8 kB compressed), for faster installation. - Document
-i
/--inkscape
option - Documentation now has table of contents for easier navigation
Full Changelog: v2.3.0...v2.4.0
v2.3.0
- More efficient conversion of SVG files to PDF/PNG via a new spin-off project svgink. (#75)
- You can now specify an
.svg
file (drawn with another tool) directly on the command line to just convert it to PDF/PNG. (Alternatively, you can runsvgink
directly.) (#75) - New command-line options
-f
/--force
to force conversion. - Bug fix for Linux which prevented v2.2.0 from running.
- API change: renamed
SVGTilerException
toSVGTilerError
.
Full Changelog: v2.2.0...v2.3.0
v2.2.0
- .js and .coffee mapping files are now loaded as NodeJS modules. (Previously, they were run as special functions.)
- Makes these files more interoperable when using them as mappings vs. via
require
orimport
. - Reveals additional Node features (e.g.
module
global) - Enables a lot of other exciting features:
- Makes these files more interoperable when using them as mappings vs. via
- New support for
import
syntax as an alternative torequire
. - New ways to specify the mapping from a mapping file:
export default mapping
orexports.default = mapping
. You can still just write themapping
at the end of the file. require
d andimport
ed modules can use JSX syntax, so you can share JSX code between mapping files. (#65)- Source maps are now fully supported, which means errors from your CoffeeScript mapping files will now have correct line numbers. (#56)
- Command-line interface has new options for setting the output directory, helping you keep organized. (#58)
-o
/--output
sets an overall default output directory-os
/--output-svg
,-op
/--output-pdf
,-oP
/--output-png
,-ot
/--output-tex
control output directory by file type
- API changes to support a settings object instead of overriding class static attributes. (#47)
- All settings can now be overridden in
renderDOM
viadata-*
attributes. - New
defaultSettings
exported object to modify defaults. - Replaces old undocumented
renderDOMDefaults
object. - Replaces old undocumented overrides:
Drawing.inlineImages
,Drawing.keepMargins
,Drawing.useHref
,Drawings.keepHidden
,Symbol.svgEncoding
,Symbol.forceWidth
,Symbol.forceHeight
,Symbol.texText
,Symbol.overflowDefault
- All settings can now be overridden in
xmldom
upgrade means that>
is now escaped as>
. This can affect CSS output, but should make the resulting SVG easier to parse.
Full Changelog: v2.1.1...v2.2.0
v2.1.1
- Fix support for DOS-formatted (
\r\n
newlines) and old Mac-formatted (\r
newlines).txt
files
Full Changelog: v2.1.0...v2.1.1
v2.1.0
- New
renderDOM
API feature for rendering DOM elements that contain drawings (e.g. ASCII art) directly into SVG (#64). See these slides for an example of usage. Mapping
API now supports direct construction of a mapping vianew Mapping(data)
wheredata
is an object or function. (Previously, you had to create anew Mapping
and then call theload
method.)- Document above subset of API as stable
v2.0.1
- Update xmldom, improving SVG output in edge cases, in particular addressing a security vulnerability
- Update Babel and xlsx
v2.0.0
- BREAKING CHANGE: Switch from
preserveAspectRatio="xMinYMin meet"
to defaultpreserveAspectRatio="xMidyMid meet"
(centering), which seems more useful especially in the context of slides. See preserveAspectRatio. - Fix
href
attribute in case of image embedding (broken in v1.17.0 when addingDrawing.href
feature)