@versatiles/style 3.8.2 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.MD CHANGED
@@ -35,7 +35,7 @@ Use it in:
35
35
  <script src="maplibre-gl.js"></script>
36
36
  <script src="versatiles-style.js"></script>
37
37
  <script>
38
- const style = VersaTilesStyle.graybeard({
38
+ const style = VersaTilesStyle.styles.graybeard({
39
39
  tiles: ['https://???.org/tiles/osm/{z}/{x}/{y}'],
40
40
  sprite: 'https://???.org/assets/styles/swr-bright/sprite',
41
41
  glyphs: 'https://???.org/assets/fonts/{fontstack}/{range}.pbf',
@@ -62,9 +62,10 @@ npm install versatiles-style
62
62
  Use it in Node.js:
63
63
 
64
64
  ```javascript
65
- import { Colorful } from 'versatiles-style';
66
- let style = new Colorful();
67
- style.language = 'de';
65
+ import { styles } from 'versatiles-style';
66
+ let style = styles.colorful({
67
+ languageSuffix: '_en',
68
+ });
68
69
  writeFileSync('style.json', JSON.stringify(style.build()));
69
70
  ```
70
71
 
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import type { MaplibreStyle, StylemakerOptions } from './lib/types.js';
2
+ export type { TileJSONSpecification, TileJSONSpecificationRaster, TileJSONSpecificationVector } from './lib/types.js';
2
3
  import Colorful from './style/colorful.js';
3
- export declare function colorful(options?: StylemakerOptions<Colorful>): MaplibreStyle;
4
4
  import Graybeard from './style/graybeard.js';
5
- export declare function graybeard(options?: StylemakerOptions<Graybeard>): MaplibreStyle;
6
5
  import Neutrino from './style/neutrino.js';
7
- export declare function neutrino(options?: StylemakerOptions<Neutrino>): MaplibreStyle;
8
- export type { TileJSONSpecification, TileJSONSpecificationRaster, TileJSONSpecificationVector } from './lib/types.js';
9
- export { default as guessStyle } from './lib/style_guesser.js';
6
+ export declare const styles: {
7
+ colorful: (options?: StylemakerOptions<Colorful>) => MaplibreStyle;
8
+ graybeard: (options?: StylemakerOptions<Graybeard>) => MaplibreStyle;
9
+ neutrino: (options?: StylemakerOptions<Neutrino>) => MaplibreStyle;
10
+ };
11
+ export { default as guessStyle } from './lib/guess_style.js';
package/dist/index.js CHANGED
@@ -1,13 +1,15 @@
1
1
  import Colorful from './style/colorful.js';
2
- export function colorful(options) {
3
- return new Colorful().build(options);
4
- }
5
2
  import Graybeard from './style/graybeard.js';
6
- export function graybeard(options) {
7
- return new Graybeard().build(options);
8
- }
9
3
  import Neutrino from './style/neutrino.js';
10
- export function neutrino(options) {
11
- return new Neutrino().build(options);
12
- }
13
- export { default as guessStyle } from './lib/style_guesser.js';
4
+ export const styles = {
5
+ colorful: function colorful(options) {
6
+ return new Colorful().build(options);
7
+ },
8
+ graybeard: function graybeard(options) {
9
+ return new Graybeard().build(options);
10
+ },
11
+ neutrino: function neutrino(options) {
12
+ return new Neutrino().build(options);
13
+ },
14
+ };
15
+ export { default as guessStyle } from './lib/guess_style.js';
@@ -1,17 +1,16 @@
1
1
  /* eslint-disable @typescript-eslint/naming-convention */
2
- import * as builders from './index.js';
3
- describe('Style Builders', () => {
4
- const styles = [
5
- { name: 'Colorful', builder: builders.colorful },
6
- { name: 'Graybeard', builder: builders.graybeard },
7
- { name: 'Neutrino', builder: builders.neutrino },
8
- ];
9
- styles.forEach(({ name, builder }) => {
2
+ import { guessStyle, styles } from './index.js';
3
+ describe('styles', () => {
4
+ it('should be all styles', () => {
5
+ expect(Array.from(Object.keys(styles)).sort())
6
+ .toStrictEqual(['colorful', 'graybeard', 'neutrino']);
7
+ });
8
+ Object.entries(styles).forEach(([name, builder]) => {
10
9
  it(`should create and test an instance of ${name}`, () => {
11
10
  expect(typeof builder).toBe('function');
12
11
  const style = builder({ baseUrl: 'https://example.org' });
13
12
  expect(JSON.stringify(style).length).toBeGreaterThan(50000);
14
- expect(style.name).toBe('versatiles-' + name.toLowerCase());
13
+ expect(style.name).toBe('versatiles-' + name);
15
14
  expect(style.glyphs).toBe('https://example.org/assets/fonts/{fontstack}/{range}.pbf');
16
15
  expect(style.sprite).toBe('https://example.org/assets/sprites/sprites');
17
16
  expect(Object.keys(style.sources).join(',')).toBe('versatiles-shortbread');
@@ -20,7 +19,7 @@ describe('Style Builders', () => {
20
19
  });
21
20
  });
22
21
  describe('Colorful', () => {
23
- const style = builders.colorful({
22
+ const style = styles.colorful({
24
23
  baseUrl: 'https://dev.null',
25
24
  colors: { commercial: '#f00' },
26
25
  });
@@ -38,7 +37,7 @@ describe('guessStyle', () => {
38
37
  const tiles = ['https://fancy.map/tiles/{z}/{x}/{y}'];
39
38
  const vectorLayers = [{ id: 'hallo', fields: { label: 'String' } }];
40
39
  it('should build raster styles', () => {
41
- const style = builders.guessStyle({
40
+ const style = guessStyle({
42
41
  tiles,
43
42
  format: 'png',
44
43
  });
@@ -49,7 +48,7 @@ describe('guessStyle', () => {
49
48
  });
50
49
  });
51
50
  it('should build vector styles', () => {
52
- const style = builders.guessStyle({
51
+ const style = guessStyle({
53
52
  tiles,
54
53
  format: 'pbf',
55
54
  vectorLayers,
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/naming-convention */
2
2
  import Color from 'color';
3
- import StyleBuilder from './style_builder.js';
3
+ import StyleBuilder from './build_style.js';
4
4
  // Mock class for abstract class StyleBuilder
5
5
  class MockStyleBuilder extends StyleBuilder {
6
6
  name = 'mock';
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/naming-convention */
2
2
  import getTemplate from './shortbread/template.js';
3
- import guessStyle from './style_guesser.js';
3
+ import guessStyle from './guess_style.js';
4
4
  describe('guessStyle', () => {
5
5
  const tiles = ['https://example.com/tiles/{z}/{x}/{y}'];
6
6
  const vectorLayersSomething = [{ id: 'geometry', fields: { label: 'String', height: 'Number' } }];
@@ -1,4 +1,4 @@
1
1
  import type { RecolorOptions, StylemakerColors } from './types.js';
2
- import type StyleBuilder from './style_builder.ts';
2
+ import type StyleBuilder from './build_style.ts';
3
3
  export declare function getDefaultRecolorFlags(): RecolorOptions;
4
4
  export declare function recolor<Subclass extends StyleBuilder<Subclass>>(colors: StylemakerColors<Subclass>, opt?: RecolorOptions): void;
@@ -1,5 +1,5 @@
1
1
  import type { StyleRules, StyleRulesOptions } from './types.js';
2
- import StyleBuilder from './style_builder.js';
2
+ import StyleBuilder from './build_style.js';
3
3
  export default class TestStyle extends StyleBuilder<TestStyle> {
4
4
  readonly name: string;
5
5
  defaultFonts: {};
@@ -1,5 +1,5 @@
1
1
  import { getDefaultRecolorFlags, recolor } from './recolor.js';
2
- import StyleBuilder from './style_builder.js';
2
+ import StyleBuilder from './build_style.js';
3
3
  describe('colorTransformer', () => {
4
4
  describe('getDefaultRecolorFlags', () => {
5
5
  it('should return the default color transformer flags', () => {
@@ -1,6 +1,6 @@
1
1
  import type { BackgroundLayerSpecification, FillLayerSpecification, FilterSpecification, LineLayerSpecification, StyleSpecification, SymbolLayerSpecification } from '@maplibre/maplibre-gl-style-spec';
2
2
  import type Color from 'color';
3
- import type StyleBuilder from './style_builder.ts';
3
+ import type StyleBuilder from './build_style.ts';
4
4
  /** Represents the available tile formats. */
5
5
  export type TileFormat = 'avif' | 'bin' | 'geojson' | 'jpg' | 'json' | 'pbf' | 'png' | 'svg' | 'topojson' | 'webp';
6
6
  /** Type for Maplibre layers, including background, fill, line, and symbol specifications. */
@@ -1,4 +1,4 @@
1
- import StyleBuilder from '../lib/style_builder.js';
1
+ import StyleBuilder from '../lib/build_style.js';
2
2
  import type { StyleRules, StyleRulesOptions } from '../lib/types.js';
3
3
  export default class Colorful extends StyleBuilder<Colorful> {
4
4
  readonly name: string;
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/naming-convention */
2
- import StyleBuilder from '../lib/style_builder.js';
2
+ import StyleBuilder from '../lib/build_style.js';
3
3
  export default class Colorful extends StyleBuilder {
4
4
  name = 'Colorful';
5
5
  defaultFonts = {
@@ -1,4 +1,4 @@
1
- import StyleBuilder from '../lib/style_builder.js';
1
+ import StyleBuilder from '../lib/build_style.js';
2
2
  import type { StyleRules, StyleRulesOptions } from '../lib/types.js';
3
3
  export default class Neutrino extends StyleBuilder<Neutrino> {
4
4
  readonly name: string;
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/naming-convention */
2
- import StyleBuilder from '../lib/style_builder.js';
2
+ import StyleBuilder from '../lib/build_style.js';
3
3
  export default class Neutrino extends StyleBuilder {
4
4
  name = 'Neutrino';
5
5
  defaultFonts = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@versatiles/style",
3
- "version": "3.8.2",
3
+ "version": "4.0.0",
4
4
  "description": "Generate StyleJSON for MapLibre",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -45,7 +45,7 @@
45
45
  "@types/brace-expansion": "^1.1.2",
46
46
  "@types/inquirer": "^9.0.7",
47
47
  "@types/jest": "^29.5.12",
48
- "@types/node": "^20.11.17",
48
+ "@types/node": "^20.11.19",
49
49
  "@typescript-eslint/eslint-plugin": "^7.0.1",
50
50
  "@typescript-eslint/parser": "^7.0.1",
51
51
  "@versatiles/release-tool": "^1.2.1",
@@ -55,7 +55,7 @@
55
55
  "jest-environment-jsdom": "^29.7.0",
56
56
  "jest-ts-webcompat-resolver": "^1.0.0",
57
57
  "npm-check-updates": "^16.14.15",
58
- "rollup": "^4.10.0",
58
+ "rollup": "^4.11.0",
59
59
  "rollup-plugin-dts": "^6.1.0",
60
60
  "ts-jest": "^29.1.2",
61
61
  "ts-node": "^10.9.2",
File without changes
File without changes