@versatiles/style
    Preparing search index...

    Function styleMetadata

    Recording the options a style was built from, and reading them back. Opt-in: the builders do not write this themselves — see the note on styleMetadata. Free functions, so a bundle that never calls them drops them.

    • Metadata recording the options a style was built from, so a tool can later read a finished style.json back into the options that made it.

      Opt-in, and deliberately not written by the builders themselves. osm() and friends guarantee that osm(minimizeOptions(x)) builds the identical style to osm(x); minimising drops representations that resolve differently but render the same (a tint at amount 0, the icons alias), so baking the options into the style would make that guarantee false and src/api/minimize.test.ts fail. It would also add a copy of every option to every style built by every consumer, most of whom never read it back.

      So the caller that wants a round-trip asks for one — pass the minimised options, which is what such a caller already holds:

      const options = osm.minimizeOptions(myOptions);
      const style = { ...osm(myOptions), metadata: styleMetadata('osm', options) };

      Pass options only — never a resolved tree containing urls, whose osm field may be a whole pre-fetched TileJSON, and which pins the style to the host that built it. URLs are environment, not style: a reader supplies its own.

      Parameters

      • builder: StyleBuilder
      • options: object
      • base: unknown = STYLE_METADATA

      Returns unknown