From f7720d970a53095006f851c99e594caba3d4b9a9 Mon Sep 17 00:00:00 2001 From: Jonathan Lurie Date: Thu, 19 Dec 2024 22:50:42 +0100 Subject: [PATCH] Sdk v2.5 (#17) * update example dep * linting and formatting * github action can now publich release candidates --- .github/workflows/npm-publish.yml | 21 ++++- CHANGELOG.md | 4 + demos/QR.html | 4 +- demos/activate.html | 4 +- demos/auto-activate.html | 4 +- demos/auto-activate2.html | 4 +- demos/custom.html | 4 +- demos/image.html | 4 +- demos/image_overlay.html | 4 +- demos/index.html | 4 +- demos/no-button.html | 4 +- package-lock.json | 133 +++++++++++++++++------------- package.json | 4 +- src/MaptilerARControl.ts | 34 ++++---- 14 files changed, 136 insertions(+), 96 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 7cd1538..36824f7 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -8,13 +8,28 @@ jobs: build-and-publish: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Checkout repo + uses: actions/checkout@v4 + with: + ref: ${{ github.event.release.target_commitish }} + - uses: actions/setup-node@v4 with: node-version: 20 registry-url: https://registry.npmjs.org/ - run: npm ci - run: npm run make - - run: npm publish --access public + + - name: Publish NPM package (regular) + if: !github.event.release.prerelease + run: | + npm publish + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} + + - name: Publish NPM package (pre-release) + if: github.event.release.prerelease + run: | + npm publish --tag next env: - NODE_AUTH_TOKEN: ${{secrets.npm_token}} \ No newline at end of file + NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/CHANGELOG.md b/CHANGELOG.md index b1d3ffd..be7421b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # MapTiler AR Control Changelog +## 2.1.3 +### Others +- Updating with SDK v2.4.0 + ## 2.1.2 ### New Features - Display the attribution on top of the 3D model view (web) diff --git a/demos/QR.html b/demos/QR.html index 43ed73b..01befc3 100644 --- a/demos/QR.html +++ b/demos/QR.html @@ -3,8 +3,8 @@ MapTiler AR Control - - + + diff --git a/demos/activate.html b/demos/activate.html index dd66646..7ffb968 100644 --- a/demos/activate.html +++ b/demos/activate.html @@ -7,8 +7,8 @@ - - + + diff --git a/demos/auto-activate.html b/demos/auto-activate.html index 67a501e..547c653 100644 --- a/demos/auto-activate.html +++ b/demos/auto-activate.html @@ -3,8 +3,8 @@ MapTiler AR Control - - + + diff --git a/demos/auto-activate2.html b/demos/auto-activate2.html index 1114e2c..4d5b744 100644 --- a/demos/auto-activate2.html +++ b/demos/auto-activate2.html @@ -3,8 +3,8 @@ MapTiler AR Control - - + + diff --git a/demos/custom.html b/demos/custom.html index d2e67cb..b514fdf 100644 --- a/demos/custom.html +++ b/demos/custom.html @@ -7,8 +7,8 @@ - - + + diff --git a/demos/image.html b/demos/image.html index 25444ad..fb2ddaf 100644 --- a/demos/image.html +++ b/demos/image.html @@ -3,8 +3,8 @@ MapTiler AR Control - - + + diff --git a/demos/image_overlay.html b/demos/image_overlay.html index 694012d..77a40e9 100644 --- a/demos/image_overlay.html +++ b/demos/image_overlay.html @@ -3,8 +3,8 @@ MapTiler AR Control - - + + diff --git a/demos/index.html b/demos/index.html index f3181df..45e1573 100644 --- a/demos/index.html +++ b/demos/index.html @@ -3,8 +3,8 @@ MapTiler AR Control - - + + diff --git a/demos/no-button.html b/demos/no-button.html index 64509ff..2e2e73e 100644 --- a/demos/no-button.html +++ b/demos/no-button.html @@ -7,8 +7,8 @@ - - + + diff --git a/package-lock.json b/package-lock.json index 54a9d1e..9e3d9ec 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,19 +1,19 @@ { "name": "@maptiler/ar-control", - "version": "2.1.1", + "version": "2.2.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@maptiler/ar-control", - "version": "2.1.1", + "version": "2.2.0", "license": "See LICENSE.md", "dependencies": { "@capacitor-community/file-opener": "^1.0.5", "@capacitor/core": "^5.7.1", "@capacitor/filesystem": "^5.2.1", "@google/model-viewer": "^3.5.0", - "@maptiler/sdk": "^2.1.0", + "@maptiler/sdk": "^2.5.0", "events": "^3.3.0", "three": "^0.163.0" }, @@ -646,9 +646,9 @@ } }, "node_modules/@maplibre/maplibre-gl-style-spec": { - "version": "20.3.0", - "resolved": "https://registry.npmjs.org/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-20.3.0.tgz", - "integrity": "sha512-eSiQ3E5LUSxAOY9ABXGyfNhout2iEa6mUxKeaQ9nJ8NL1NuaQYU7zKqzx/LEYcXe1neT4uYAgM1wYZj3fTSXtA==", + "version": "20.3.1", + "resolved": "https://registry.npmjs.org/@maplibre/maplibre-gl-style-spec/-/maplibre-gl-style-spec-20.3.1.tgz", + "integrity": "sha512-5ueL4UDitzVtceQ8J4kY+Px3WK+eZTsmGwha3MBKHKqiHvKrjWWwBCIl1K8BuJSc5OFh83uI8IFNoFvQxX2uUw==", "dependencies": { "@mapbox/jsonlint-lines-primitives": "~2.0.2", "@mapbox/unitbezier": "^0.0.1", @@ -657,7 +657,7 @@ "quickselect": "^2.0.0", "rw": "^1.3.3", "sort-object": "^3.0.3", - "tinyqueue": "^2.0.3" + "tinyqueue": "^3.0.0" }, "bin": { "gl-style-format": "dist/gl-style-format.mjs", @@ -666,22 +666,23 @@ } }, "node_modules/@maptiler/client": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/@maptiler/client/-/client-1.8.1.tgz", - "integrity": "sha512-G1z2xCBwT5WU1CqeukY3R4g1saSjKzi6tmg24LJWZHP81RQ4quVvwdmsx829BxITlFbFhND+BSphFgrDGmwhcA==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@maptiler/client/-/client-2.2.0.tgz", + "integrity": "sha512-kV4dSJK2PLfRLnl437CQgDJBboHcf+Z7FWkSoPW3ANca/csoYQQOwz42BPNkda/98OT+CviIueeQdNUyeEL1OQ==", "dependencies": { "quick-lru": "^7.0.0" } }, "node_modules/@maptiler/sdk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@maptiler/sdk/-/sdk-2.1.0.tgz", - "integrity": "sha512-hP9LGAeq3hL0UJob3rrD94xJwRz+pkfoe4yAiP1whjvWBbObcvAion8KazoBzvHLWSQsRF+mmP2xgN9k8J55VQ==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@maptiler/sdk/-/sdk-2.5.0.tgz", + "integrity": "sha512-noyj935NMAHTd0Shr3xItsqJF5+wiAFB9Iz0iHXGiN6Q3zWWimr9qkXzD5nuuR1PgQ7HbccIWzlAgKqHLAdepg==", "dependencies": { - "@maptiler/client": "^1.8.1", + "@maplibre/maplibre-gl-style-spec": "^20.3.1", + "@maptiler/client": "^2.2.0", "events": "^3.3.0", "js-base64": "^3.7.4", - "maplibre-gl": "4.4.1", + "maplibre-gl": "4.7.1", "uuid": "^9.0.0" } }, @@ -1019,11 +1020,6 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, - "node_modules/@types/junit-report-builder": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/junit-report-builder/-/junit-report-builder-3.0.2.tgz", - "integrity": "sha512-R5M+SYhMbwBeQcNXYWNCZkl09vkVfAtcPIaCGdzIkkbeaTrVbGQ7HVgi4s+EmM/M1K4ZuWQH0jGcvMvNePfxYA==" - }, "node_modules/@types/mapbox__point-geometry": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/@types/mapbox__point-geometry/-/mapbox__point-geometry-0.1.4.tgz", @@ -1987,9 +1983,9 @@ } }, "node_modules/earcut": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/earcut/-/earcut-2.2.4.tgz", - "integrity": "sha512-/pjZsA1b4RPHbeWZQn66SWS8nZZWLQQ23oE3Eam7aroEFGEvwKAsJfZ9ytiEMycfzXWpca4FA9QIOehf7PocBQ==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/earcut/-/earcut-3.0.0.tgz", + "integrity": "sha512-41Fs7Q/PLq1SDbqjsgcY7GA42T0jvaCNGXgGtsNdvg+Yv8eIu06bxv4/PoREkZ9nMDNwnUSG9OFB9+yv8eKhDg==" }, "node_modules/enhanced-resolve": { "version": "5.17.0", @@ -2782,9 +2778,9 @@ } }, "node_modules/geojson-vt": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/geojson-vt/-/geojson-vt-3.2.1.tgz", - "integrity": "sha512-EvGQQi/zPrDA6zr6BnJD/YhwAkBP8nnJ9emh3EnHQKVMfg/MRVtPbMYdgVy/IaEmn4UfagD2a6fafPDL5hbtwg==" + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/geojson-vt/-/geojson-vt-4.0.2.tgz", + "integrity": "sha512-AV9ROqlNqoZEIJGfm1ncNjEXfkz2hdFlZf0qkVfmkwdKa8vj7H16YUOT81rJw1rdFhyEDlN2Tds91p/glzbl5A==" }, "node_modules/get-intrinsic": { "version": "1.2.4", @@ -2914,27 +2910,38 @@ } }, "node_modules/global-prefix": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-3.0.0.tgz", - "integrity": "sha512-awConJSVCHVGND6x3tmMaKcQvwXLhjdkmomy2W+Goaui8YPgYgXJZewhg3fWC+DlfqqQuWg8AwqjGTD2nAPVWg==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-4.0.0.tgz", + "integrity": "sha512-w0Uf9Y9/nyHinEk5vMJKRie+wa4kR5hmDbEhGGds/kG1PwGLLHKRoNMeJOyCQjjBkANlnScqgzcFwGHgmgLkVA==", "dependencies": { - "ini": "^1.3.5", - "kind-of": "^6.0.2", - "which": "^1.3.1" + "ini": "^4.1.3", + "kind-of": "^6.0.3", + "which": "^4.0.0" }, "engines": { - "node": ">=6" + "node": ">=16" + } + }, + "node_modules/global-prefix/node_modules/isexe": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-3.1.1.tgz", + "integrity": "sha512-LpB/54B+/2J5hqQ7imZHfdU31OlgQqx7ZicVlkm9kzg9/w8GKLEcFfJl/t7DCEDueOyBAD6zCCwTO6Fzs0NoEQ==", + "engines": { + "node": ">=16" } }, "node_modules/global-prefix/node_modules/which": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", - "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/which/-/which-4.0.0.tgz", + "integrity": "sha512-GlaYyEb07DPxYCKhKzplCWBJtvxZcZMrL+4UkrTSJHHPyZU4mYYTv3qaOe77H7EODLSSopAUFAc6W8U4yqvscg==", "dependencies": { - "isexe": "^2.0.0" + "isexe": "^3.1.1" }, "bin": { - "which": "bin/which" + "node-which": "bin/which.js" + }, + "engines": { + "node": "^16.13.0 || >=18.0.0" } }, "node_modules/globals": { @@ -3187,9 +3194,12 @@ "dev": true }, "node_modules/ini": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", - "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/ini/-/ini-4.1.3.tgz", + "integrity": "sha512-X7rqawQBvfdjS10YU1y1YVreA3SsLrW9dX2CewP2EbBJM4ypVNLDkO5y04gejPwKIY9lR+7r9gn3rFPt/kmWFg==", + "engines": { + "node": "^14.17.0 || ^16.13.0 || >=18.0.0" + } }, "node_modules/internal-slot": { "version": "1.0.7", @@ -3490,7 +3500,8 @@ "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true }, "node_modules/isobject": { "version": "3.0.1", @@ -3705,9 +3716,9 @@ } }, "node_modules/maplibre-gl": { - "version": "4.4.1", - "resolved": "https://registry.npmjs.org/maplibre-gl/-/maplibre-gl-4.4.1.tgz", - "integrity": "sha512-tD+wn8qWSLCGhABKBrbewmgFfyopZDz+fkYXeOM8vdBhnf126DvMPyaYGGoKvoF4QuswCsgikETd2c39wK+OQw==", + "version": "4.7.1", + "resolved": "https://registry.npmjs.org/maplibre-gl/-/maplibre-gl-4.7.1.tgz", + "integrity": "sha512-lgL7XpIwsgICiL82ITplfS7IGwrB1OJIw/pCvprDp2dhmSSEBgmPzYRvwYYYvJGJD7fxUv1Tvpih4nZ6VrLuaA==", "dependencies": { "@mapbox/geojson-rewind": "^0.5.2", "@mapbox/jsonlint-lines-primitives": "^2.0.2", @@ -3716,25 +3727,24 @@ "@mapbox/unitbezier": "^0.0.1", "@mapbox/vector-tile": "^1.3.1", "@mapbox/whoots-js": "^3.1.0", - "@maplibre/maplibre-gl-style-spec": "^20.3.0", + "@maplibre/maplibre-gl-style-spec": "^20.3.1", "@types/geojson": "^7946.0.14", "@types/geojson-vt": "3.2.5", - "@types/junit-report-builder": "^3.0.2", "@types/mapbox__point-geometry": "^0.1.4", "@types/mapbox__vector-tile": "^1.3.4", "@types/pbf": "^3.0.5", "@types/supercluster": "^7.1.3", - "earcut": "^2.2.4", - "geojson-vt": "^3.2.1", + "earcut": "^3.0.0", + "geojson-vt": "^4.0.2", "gl-matrix": "^3.4.3", - "global-prefix": "^3.0.0", + "global-prefix": "^4.0.0", "kdbush": "^4.0.2", "murmurhash-js": "^1.0.0", - "pbf": "^3.2.1", + "pbf": "^3.3.0", "potpack": "^2.0.0", - "quickselect": "^2.0.0", + "quickselect": "^3.0.0", "supercluster": "^8.0.1", - "tinyqueue": "^2.0.3", + "tinyqueue": "^3.0.0", "vt-pbf": "^3.1.3" }, "engines": { @@ -3745,6 +3755,11 @@ "url": "https://github.com/maplibre/maplibre-gl-js?sponsor=1" } }, + "node_modules/maplibre-gl/node_modules/quickselect": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/quickselect/-/quickselect-3.0.0.tgz", + "integrity": "sha512-XdjUArbK4Bm5fLLvlm5KpTFOiOThgfWWI4axAZDWg4E/0mKdZyI9tNEfds27qCi1ze/vwTR16kvmmGhRra3c2g==" + }, "node_modules/merge2": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", @@ -4045,9 +4060,9 @@ } }, "node_modules/pbf": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/pbf/-/pbf-3.2.1.tgz", - "integrity": "sha512-ClrV7pNOn7rtmoQVF4TS1vyU0WhYRnP92fzbfF75jAIwpnzdJXf8iTd4CMEqO4yUenH6NDqLiwjqlh6QgZzgLQ==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/pbf/-/pbf-3.3.0.tgz", + "integrity": "sha512-XDF38WCH3z5OV/OVa8GKUNtLAyneuzbCisx7QUCF8Q6Nutx0WnJrQe5O+kOtBlLfRNUws98Y58Lblp+NJG5T4Q==", "dependencies": { "ieee754": "^1.1.12", "resolve-protobuf-schema": "^2.1.0" @@ -4705,9 +4720,9 @@ "integrity": "sha512-HlMgCb2TF/dTLRtknBnjUTsR8FsDqBY43itYop2+Zg822I+Kd0Ua2vs8CvfBVefXkBdNDrLMoRTGCIIpfCuDew==" }, "node_modules/tinyqueue": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/tinyqueue/-/tinyqueue-2.0.3.tgz", - "integrity": "sha512-ppJZNDuKGgxzkHihX8v9v9G5f+18gzaTfrukGrq6ueg0lmH4nqVnA2IPG0AEH3jKEk2GRJCUhDoqpoiw3PHLBA==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/tinyqueue/-/tinyqueue-3.0.0.tgz", + "integrity": "sha512-gRa9gwYU3ECmQYv3lslts5hxuIa90veaEcxDYuu3QGOIAEM2mOZkVHp48ANJuu1CURtRdHKUBY5Lm1tHV+sD4g==" }, "node_modules/to-regex-range": { "version": "5.0.1", diff --git a/package.json b/package.json index 3841f7e..5a8e738 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@maptiler/ar-control", - "version": "2.1.2", + "version": "2.2.0", "description": "AR Control for MapTiler SDK", "type": "module", "homepage": "https://docs.maptiler.com/sdk-js/modules/ar/", @@ -58,7 +58,7 @@ "@capacitor/core": "^5.7.1", "@capacitor/filesystem": "^5.2.1", "@google/model-viewer": "^3.5.0", - "@maptiler/sdk": "^2.1.0", + "@maptiler/sdk": "^2.5.0", "events": "^3.3.0", "three": "^0.163.0" } diff --git a/src/MaptilerARControl.ts b/src/MaptilerARControl.ts index ab24a34..56ddbb0 100644 --- a/src/MaptilerARControl.ts +++ b/src/MaptilerARControl.ts @@ -1,6 +1,12 @@ // @ts-nocheck -import { Map, LngLatBounds, LngLat, IControl, math } from "@maptiler/sdk"; +import { + type Map as MapSDK, + type LngLatBounds, + LngLat, + type IControl, + math, +} from "@maptiler/sdk"; import { ModelViewerElement } from "@google/model-viewer"; import * as platformConstants from "./platform-constants.ts"; @@ -111,12 +117,12 @@ function injectToContext( const image = new Image(); image.crossOrigin = "anonymous"; image.src = imageUrl; - image.onload = function () { + image.onload = () => { context.drawImage(image, topLeftPosition[0], topLeftPosition[1]); resolve(); }; - image.onerror = function () { + image.onerror = () => { resolve(); }; }); @@ -153,8 +159,8 @@ function cropCanvas( * @param map * @returns */ -function idleAsync(map: Map) { - return new Promise(function (myResolve) { +function idleAsync(map: MapSDK) { + return new Promise((myResolve) => { map.once("idle", () => { myResolve(true); }); @@ -307,7 +313,7 @@ const defaultCloseButtonStyle = { export class MaptilerARControl extends EventEmitter implements IControl { private controlButton!: HTMLButtonElement; private controlButtonContainer!: HTMLDivElement; - private map!: Map; + private map!: MapSDK; private colorData: MapTextureData | null = null; private landMaskData: MapTextureData | null = null; private terrainData: MapTextureData | null = null; @@ -368,7 +374,7 @@ export class MaptilerARControl extends EventEmitter implements IControl { } onAdd(map: maplibregl.Map): HTMLElement { - this.setMap(map as Map); + this.setMap(map as MapSDK); // Creation of the button to show on map this.controlButtonContainer = window.document.createElement("div"); @@ -463,7 +469,7 @@ export class MaptilerARControl extends EventEmitter implements IControl { ); } - setMap(m: Map) { + setMap(m: MapSDK) { this.map = m; } @@ -937,7 +943,7 @@ export class MaptilerARControl extends EventEmitter implements IControl { const h = this.terrainData.height; // detecting the minimum elevation - let minEle = +Infinity; + let minEle = Number.POSITIVE_INFINITY; for (let i = 0; i < positionBuf.length / 3; i += 1) { const r = this.terrainData.pixelData[i * 4]; const g = this.terrainData.pixelData[i * 4 + 1]; @@ -1148,7 +1154,7 @@ export class MaptilerARControl extends EventEmitter implements IControl { } private async runMobile() { - if (!typeof window) return; + if (typeof window === "undefined") return; const container = this.map.getContainer(); const modelBlobGLB = await this.getModelBlobGLB(); @@ -1177,9 +1183,9 @@ export class MaptilerARControl extends EventEmitter implements IControl { if (this.options.arButtonClassName) { this.arButton.classList.add(this.options.arButtonClassName); } else { - Object.keys(defaultArButtonStyle).forEach((el) => { + for (const el of Object.keys(defaultArButtonStyle)) { this.arButton.style[el] = defaultArButtonStyle[el]; - }); + } } // Adding content to the AR button @@ -1198,9 +1204,9 @@ export class MaptilerARControl extends EventEmitter implements IControl { if (this.options.closeButtonClassName) { this.closeButton.classList.add(this.options.closeButtonClassName); } else { - Object.keys(defaultCloseButtonStyle).forEach((el) => { + for (const el of Object.keys(defaultCloseButtonStyle)) { this.closeButton.style[el] = defaultCloseButtonStyle[el]; - }); + } } // Adding content to the close button