@maptiler/client 2.6.0-rc.1 → 2.6.0-rc.3

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.
@@ -0,0 +1,51 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
+
4
+ name: Node.js Package
5
+
6
+ on:
7
+ pull_request:
8
+ types: [opened]
9
+
10
+ jobs:
11
+ build-and-publish:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Checkout repo
15
+ uses: actions/checkout@v4
16
+ with:
17
+ ref: ${{ github.event.release.target_commitish }}
18
+
19
+ - uses: actions/setup-node@v4
20
+ with:
21
+ node-version: 18
22
+ registry-url: https://registry.npmjs.org/
23
+
24
+ - name: Clear NPM cache
25
+ run: npm cache clean --force
26
+
27
+ - name: Install dependencies and build
28
+ run: npm ci
29
+
30
+ - name: Make release
31
+ run: npm run build
32
+ id: makeRelease
33
+
34
+ - name: Fail job if makeRelease failed
35
+ if: steps.makeRelease.outcome == 'failure'
36
+ run: exit 1
37
+
38
+ id: check-build-status
39
+ - name: Publish NPM package (regular)
40
+ if: "!github.event.release.prerelease"
41
+ run: |
42
+ npm publish --dry-run
43
+ env:
44
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}
45
+
46
+ - name: Publish NPM package (pre-release)
47
+ if: "github.event.release.prerelease"
48
+ run: |
49
+ npm publish --tag next --dry-run
50
+ env:
51
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}
@@ -11,13 +11,53 @@ jobs:
11
11
  build-and-publish:
12
12
  runs-on: ubuntu-latest
13
13
  steps:
14
- - uses: actions/checkout@v3
15
- - uses: actions/setup-node@v3
14
+ - name: Checkout repo
15
+ uses: actions/checkout@v4
16
+ with:
17
+ ref: ${{ github.event.release.target_commitish }}
18
+
19
+ - uses: actions/setup-node@v4
16
20
  with:
17
21
  node-version: 18
18
22
  registry-url: https://registry.npmjs.org/
19
- - run: npm ci
20
- - run: npm test
21
- - run: npm publish
23
+
24
+ - name: Clear NPM cache
25
+ run: npm cache clean --force
26
+
27
+ - name: Install dependencies and build
28
+ run: npm ci
29
+
30
+ - name: Make release
31
+ run: npm run build
32
+ id: makeRelease
33
+
34
+ - name: Fail job if makeRelease failed
35
+ if: steps.makeRelease.outcome == 'failure'
36
+ run: exit 1
37
+
38
+ id: check-build-status
39
+ - name: Publish NPM package (regular)
40
+ if: "!github.event.release.prerelease"
41
+ run: |
42
+ npm publish
22
43
  env:
23
44
  NODE_AUTH_TOKEN: ${{secrets.npm_token}}
45
+
46
+ - name: Publish NPM package (pre-release)
47
+ if: "github.event.release.prerelease"
48
+ run: |
49
+ npm publish --tag next
50
+ env:
51
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}
52
+ - name: Get Package version
53
+ id: version
54
+ run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
55
+ - name: Publish to CDN Cloudflar R2
56
+ uses: ryand56/r2-upload-action@v1.4
57
+ with:
58
+ r2-account-id: ${{ secrets.CDN_MAPTILER_ACCOUNT_ID }}
59
+ r2-access-key-id: ${{ secrets.CDN_MAPTILER_ACCESS_KEY_ID }}
60
+ r2-secret-access-key: ${{ secrets.CDN_MAPTILER_SECRET_ACCESS_KEY }}
61
+ r2-bucket: cdn-storage
62
+ source-dir: dist
63
+ destination-dir: /client-js/v${{ env.PACKAGE_VERSION }}/
package/CHANGELOG.md CHANGED
@@ -1,9 +1,10 @@
1
1
  # MapTiler Client Changelog
2
2
 
3
- ## 2.6.0
3
+ ## NEXT (2.6.0)
4
4
  ### New Features
5
5
  - Bumps 'Streets' & 'Landscape' styles (and their variants) to new v4 styles.
6
6
  - Adds the new 'Base' style and its variants.
7
+ - Namespaces V4 and V2 Styles and adds mechanism for switching to defaults.
7
8
 
8
9
  ### Bug Fixes
9
10
  None
@@ -1463,35 +1463,14 @@ class ReferenceMapStyle {
1463
1463
  }
1464
1464
  const mapStylePresetList = [
1465
1465
  {
1466
- referenceStyleID: "STREETS",
1466
+ referenceStyleID: "STREETS_V2",
1467
1467
  name: "Streets",
1468
1468
  description: "",
1469
1469
  variants: [
1470
- {
1471
- id: "streets-v4",
1472
- name: "Default",
1473
- variantType: "DEFAULT",
1474
- description: "",
1475
- imageURL: ""
1476
- },
1477
- {
1478
- id: "streets-v4-dark",
1479
- name: "Dark",
1480
- variantType: "DARK",
1481
- description: "",
1482
- imageURL: ""
1483
- },
1484
- {
1485
- id: "streets-v4-pastel",
1486
- name: "Pastel",
1487
- variantType: "PASTEL",
1488
- description: "",
1489
- imageURL: ""
1490
- },
1491
1470
  {
1492
1471
  id: "streets-v2",
1493
1472
  name: "Default v2",
1494
- variantType: "DEFAULT_V2",
1473
+ variantType: "DEFAULT",
1495
1474
  description: "",
1496
1475
  imageURL: "",
1497
1476
  deprecated: true,
@@ -1500,7 +1479,7 @@ const mapStylePresetList = [
1500
1479
  {
1501
1480
  id: "streets-v2-dark",
1502
1481
  name: "Dark v2",
1503
- variantType: "DARK_V2",
1482
+ variantType: "DARK",
1504
1483
  description: "",
1505
1484
  imageURL: "",
1506
1485
  deprecated: true,
@@ -1509,7 +1488,7 @@ const mapStylePresetList = [
1509
1488
  {
1510
1489
  id: "streets-v2-light",
1511
1490
  name: "Light v2",
1512
- variantType: "LIGHT_V2",
1491
+ variantType: "LIGHT",
1513
1492
  description: "",
1514
1493
  imageURL: "",
1515
1494
  deprecated: true,
@@ -1518,7 +1497,7 @@ const mapStylePresetList = [
1518
1497
  {
1519
1498
  id: "streets-v2-night",
1520
1499
  name: "Night v2",
1521
- variantType: "NIGHT_V2",
1500
+ variantType: "NIGHT",
1522
1501
  description: "",
1523
1502
  imageURL: "",
1524
1503
  deprecated: true,
@@ -1527,7 +1506,7 @@ const mapStylePresetList = [
1527
1506
  {
1528
1507
  id: "streets-v2-pastel",
1529
1508
  name: "Pastel v2",
1530
- variantType: "PASTEL_V2",
1509
+ variantType: "PASTEL",
1531
1510
  description: "",
1532
1511
  imageURL: "",
1533
1512
  deprecated: true,
@@ -1536,7 +1515,35 @@ const mapStylePresetList = [
1536
1515
  ]
1537
1516
  },
1538
1517
  {
1539
- referenceStyleID: "BASE",
1518
+ referenceStyleID: "STREETS_V4",
1519
+ name: "Streets",
1520
+ description: "",
1521
+ variants: [
1522
+ {
1523
+ id: "streets-v4",
1524
+ name: "Default",
1525
+ variantType: "DEFAULT",
1526
+ description: "",
1527
+ imageURL: ""
1528
+ },
1529
+ {
1530
+ id: "streets-v4-dark",
1531
+ name: "Dark",
1532
+ variantType: "DARK",
1533
+ description: "",
1534
+ imageURL: ""
1535
+ },
1536
+ {
1537
+ id: "streets-v4-pastel",
1538
+ name: "Pastel",
1539
+ variantType: "PASTEL",
1540
+ description: "",
1541
+ imageURL: ""
1542
+ }
1543
+ ]
1544
+ },
1545
+ {
1546
+ referenceStyleID: "BASE_V4",
1540
1547
  name: "Base",
1541
1548
  description: "",
1542
1549
  variants: [
@@ -1563,7 +1570,7 @@ const mapStylePresetList = [
1563
1570
  },
1564
1571
  {
1565
1572
  id: "base-v4-ai",
1566
- name: "Night",
1573
+ name: "Base AI",
1567
1574
  variantType: "NIGHT",
1568
1575
  description: "",
1569
1576
  imageURL: ""
@@ -1641,7 +1648,7 @@ const mapStylePresetList = [
1641
1648
  ]
1642
1649
  },
1643
1650
  {
1644
- referenceStyleID: "BASIC",
1651
+ referenceStyleID: "BASIC_V2",
1645
1652
  name: "Basic",
1646
1653
  description: "",
1647
1654
  variants: [
@@ -1650,7 +1657,9 @@ const mapStylePresetList = [
1650
1657
  name: "Default",
1651
1658
  variantType: "DEFAULT",
1652
1659
  description: "",
1653
- imageURL: ""
1660
+ imageURL: "",
1661
+ deprecated: true,
1662
+ deprecationMessage: `"basic-v2" is deprecated, use "basic-v4" instead`
1654
1663
  },
1655
1664
  {
1656
1665
  id: "basic-v2-dark",
@@ -1935,61 +1944,98 @@ const mapStylePresetList = [
1935
1944
  ]
1936
1945
  },
1937
1946
  {
1938
- referenceStyleID: "LANDSCAPE",
1947
+ referenceStyleID: "LANDSCAPE_V2",
1939
1948
  name: "Landscape",
1940
1949
  description: "Terrain map for data overlays and visualisations",
1941
1950
  variants: [
1942
1951
  {
1943
- id: "landscape-v4",
1952
+ id: "landscape",
1944
1953
  name: "Default",
1945
1954
  variantType: "DEFAULT",
1946
1955
  description: "",
1947
- imageURL: ""
1956
+ imageURL: "",
1957
+ deprecated: true,
1958
+ deprecationMessage: `"landscape" is deprecated, use "landscape-v4" instead`
1948
1959
  },
1949
1960
  {
1950
- id: "landscape-v4-dark",
1961
+ id: "landscape-dark",
1951
1962
  name: "Dark",
1952
1963
  variantType: "DARK",
1953
1964
  description: "",
1954
- imageURL: ""
1965
+ imageURL: "",
1966
+ deprecated: true,
1967
+ deprecationMessage: `"landscape-dark" is deprecated, use "landscape-v4-dark" instead`
1955
1968
  },
1956
1969
  {
1957
- id: "landscape-v4-vivid",
1970
+ id: "landscape-vivid",
1958
1971
  name: "Vivid",
1959
1972
  variantType: "VIVID",
1960
1973
  description: "",
1961
- imageURL: ""
1962
- },
1974
+ imageURL: "",
1975
+ deprecated: true,
1976
+ deprecationMessage: `"landscape-vivid" is deprecated, use "landscape-v4-vivid" instead`
1977
+ }
1978
+ ]
1979
+ },
1980
+ {
1981
+ referenceStyleID: "LANDSCAPE_V4",
1982
+ name: "Landscape",
1983
+ description: "Terrain map for data overlays and visualisations",
1984
+ variants: [
1963
1985
  {
1964
- id: "landscape",
1986
+ id: "landscape-v4",
1965
1987
  name: "Default",
1966
- variantType: "DEFAULT_V2",
1988
+ variantType: "DEFAULT",
1967
1989
  description: "",
1968
- imageURL: "",
1969
- deprecated: true,
1970
- deprecationMessage: `"landscape" is deprecated, use "landscape-v4" instead`
1990
+ imageURL: ""
1971
1991
  },
1972
1992
  {
1973
- id: "landscape-dark",
1993
+ id: "landscape-v4-dark",
1974
1994
  name: "Dark",
1975
- variantType: "DARK_V2",
1995
+ variantType: "DARK",
1976
1996
  description: "",
1977
- imageURL: "",
1978
- deprecated: true,
1979
- deprecationMessage: `"landscape-dark" is deprecated, use "landscape-v4-dark" instead`
1997
+ imageURL: ""
1980
1998
  },
1981
1999
  {
1982
- id: "landscape-vivid",
2000
+ id: "landscape-v4-vivid",
1983
2001
  name: "Vivid",
1984
- variantType: "VIVID_V2",
2002
+ variantType: "VIVID",
1985
2003
  description: "",
1986
- imageURL: "",
1987
- deprecated: true,
1988
- deprecationMessage: `"landscape-vivid" is deprecated, use "landscape-v4-vivid" instead`
2004
+ imageURL: ""
1989
2005
  }
1990
2006
  ]
1991
2007
  }
1992
2008
  ];
2009
+ const defaultReferenceStyleMap = {
2010
+ STREETS: "STREETS_V2",
2011
+ BASIC: "BASIC_V2",
2012
+ LANDSCAPE: "LANDSCAPE_V2"
2013
+ };
2014
+ function applyVersionToDefaultReferenceStyle(defaultKey, referenceKey) {
2015
+ if (mapStylePresetList.find((style) => style.referenceStyleID === defaultKey)) {
2016
+ console.warn(
2017
+ `Default reference style ${defaultKey} already exists, it will be overwritten...`
2018
+ );
2019
+ }
2020
+ const versionedMapStyle = mapStylePresetList.find(
2021
+ (style) => style.referenceStyleID === referenceKey
2022
+ );
2023
+ if (!versionedMapStyle) {
2024
+ throw new Error(
2025
+ `Versioned map style not found for reference style: ${referenceKey}`
2026
+ );
2027
+ }
2028
+ const defaultStyle = {
2029
+ ...versionedMapStyle,
2030
+ referenceStyleID: defaultKey
2031
+ };
2032
+ mapStylePresetList.push(defaultStyle);
2033
+ }
2034
+ Object.entries(defaultReferenceStyleMap).forEach(
2035
+ ([defaultKey, referenceKey]) => {
2036
+ applyVersionToDefaultReferenceStyle(defaultKey, referenceKey);
2037
+ }
2038
+ );
1993
2039
  function makeReferenceStyleProxy(referenceStyle) {
1994
2040
  return new Proxy(referenceStyle, {
1995
2041
  get(target, prop, receiver) {