diff --git a/index.html b/index.html
index 454f50c..9190482 100644
--- a/index.html
+++ b/index.html
@@ -13,20 +13,26 @@
MapTiler Geocoding Control Examples
Svelte
React
-Vanilla JS
+Vanilla JS (UMD)
+
+
+ Before opening the following examples first build the library with
+ npm run build
.
+
+
diff --git a/package-lock.json b/package-lock.json
index 294f08c..25c83a0 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,18 +1,18 @@
{
"name": "@maptiler/geocoding-control",
- "version": "1.3.1",
+ "version": "1.3.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@maptiler/geocoding-control",
- "version": "1.3.1",
+ "version": "1.3.2",
"license": "BSD-3-Clause",
"dependencies": {
"geo-coordinates-parser": "^1.7.3"
},
"devDependencies": {
- "@maptiler/sdk": "^2.1.0",
+ "@maptiler/sdk": "^2.2.0",
"@sveltejs/package": "^2.3.2",
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"@tsconfig/svelte": "^5.0.4",
@@ -29,26 +29,26 @@
"eslint": "^8.57.0",
"eslint-plugin-svelte": "^2.41.0",
"esm-env": "^1.0.0",
- "globals": "^15.6.0",
+ "globals": "^15.8.0",
"husky": "^9.0.11",
"leaflet": "^1.9.4",
"lint-staged": "^15.2.7",
- "maplibre-gl": "^4.4.1",
+ "maplibre-gl": "^4.5.0",
"ol": "9.1",
"prettier": "^3.3.2",
- "prettier-plugin-organize-imports": "^3.2.4",
+ "prettier-plugin-organize-imports": "^4.0.0",
"prettier-plugin-svelte": "^3.2.5",
"react": "^18.3.1",
"react-dom": "^18.3.1",
- "replace-in-file": "^8.0.1",
+ "replace-in-file": "^8.1.0",
"sass": "^1.77.6",
"svelte": "^4.2.18",
"svelte-check": "^3.8.4",
"svelte-preprocess": "^6.0.1",
"tslib": "^2.6.3",
- "typescript": "^5.5.2",
- "typescript-eslint": "^7.14.1",
- "vite": "^5.3.1"
+ "typescript": "^5.5.3",
+ "typescript-eslint": "^7.15.0",
+ "vite": "^5.3.3"
},
"peerDependencies": {
"@maptiler/sdk": "^1 || ^2",
@@ -73,6 +73,9 @@
},
"react": {
"optional": true
+ },
+ "svelte": {
+ "optional": true
}
}
},
@@ -3104,21 +3107,23 @@
"dev": true
},
"node_modules/glob": {
- "version": "7.2.3",
- "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
- "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
- "deprecated": "Glob versions prior to v9 are no longer supported",
+ "version": "10.4.2",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.2.tgz",
+ "integrity": "sha512-GwMlUF6PkPo3Gk21UxkCohOv0PLcIXVtKyLlpEI28R/cO/4eNOdmLk3CMW1wROV/WR/EsZOWAfBbBOqYvs88/w==",
"dev": true,
"dependencies": {
- "fs.realpath": "^1.0.0",
- "inflight": "^1.0.4",
- "inherits": "2",
- "minimatch": "^3.1.1",
- "once": "^1.3.0",
- "path-is-absolute": "^1.0.0"
+ "foreground-child": "^3.1.0",
+ "jackspeak": "^3.1.2",
+ "minimatch": "^9.0.4",
+ "minipass": "^7.1.2",
+ "package-json-from-dist": "^1.0.0",
+ "path-scurry": "^1.11.1"
+ },
+ "bin": {
+ "glob": "dist/esm/bin.mjs"
},
"engines": {
- "node": "*"
+ "node": ">=16 || 14 >=14.18"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
@@ -3136,6 +3141,30 @@
"node": ">= 6"
}
},
+ "node_modules/glob/node_modules/brace-expansion": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
+ "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
+ "dev": true,
+ "dependencies": {
+ "balanced-match": "^1.0.0"
+ }
+ },
+ "node_modules/glob/node_modules/minimatch": {
+ "version": "9.0.5",
+ "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
+ "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
+ "dev": true,
+ "dependencies": {
+ "brace-expansion": "^2.0.1"
+ },
+ "engines": {
+ "node": ">=16 || 14 >=14.17"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
"node_modules/global-prefix": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/global-prefix/-/global-prefix-3.0.0.tgz",
@@ -4842,21 +4871,21 @@
}
},
"node_modules/prettier-plugin-organize-imports": {
- "version": "3.2.4",
- "resolved": "https://registry.npmjs.org/prettier-plugin-organize-imports/-/prettier-plugin-organize-imports-3.2.4.tgz",
- "integrity": "sha512-6m8WBhIp0dfwu0SkgfOxJqh+HpdyfqSSLfKKRZSFbDuEQXDDndb8fTpRWkUrX/uBenkex3MgnVk0J3b3Y5byog==",
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/prettier-plugin-organize-imports/-/prettier-plugin-organize-imports-4.0.0.tgz",
+ "integrity": "sha512-vnKSdgv9aOlqKeEFGhf9SCBsTyzDSyScy1k7E0R1Uo4L0cTcOV7c1XQaT7jfXIOc/p08WLBfN2QUQA9zDSZMxA==",
"dev": true,
"peerDependencies": {
- "@volar/vue-language-plugin-pug": "^1.0.4",
- "@volar/vue-typescript": "^1.0.4",
+ "@vue/language-plugin-pug": "^2.0.24",
"prettier": ">=2.0",
- "typescript": ">=2.9"
+ "typescript": ">=2.9",
+ "vue-tsc": "^2.0.24"
},
"peerDependenciesMeta": {
- "@volar/vue-language-plugin-pug": {
+ "@vue/language-plugin-pug": {
"optional": true
},
- "@volar/vue-typescript": {
+ "vue-tsc": {
"optional": true
}
}
@@ -5011,15 +5040,6 @@
"node": ">=18"
}
},
- "node_modules/replace-in-file/node_modules/brace-expansion": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
- "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
- "dev": true,
- "dependencies": {
- "balanced-match": "^1.0.0"
- }
- },
"node_modules/replace-in-file/node_modules/chalk": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz",
@@ -5032,44 +5052,6 @@
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
- "node_modules/replace-in-file/node_modules/glob": {
- "version": "10.4.2",
- "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.2.tgz",
- "integrity": "sha512-GwMlUF6PkPo3Gk21UxkCohOv0PLcIXVtKyLlpEI28R/cO/4eNOdmLk3CMW1wROV/WR/EsZOWAfBbBOqYvs88/w==",
- "dev": true,
- "dependencies": {
- "foreground-child": "^3.1.0",
- "jackspeak": "^3.1.2",
- "minimatch": "^9.0.4",
- "minipass": "^7.1.2",
- "package-json-from-dist": "^1.0.0",
- "path-scurry": "^1.11.1"
- },
- "bin": {
- "glob": "dist/esm/bin.mjs"
- },
- "engines": {
- "node": ">=16 || 14 >=14.18"
- },
- "funding": {
- "url": "https://github.com/sponsors/isaacs"
- }
- },
- "node_modules/replace-in-file/node_modules/minimatch": {
- "version": "9.0.5",
- "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
- "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
- "dev": true,
- "dependencies": {
- "brace-expansion": "^2.0.1"
- },
- "engines": {
- "node": ">=16 || 14 >=14.17"
- },
- "funding": {
- "url": "https://github.com/sponsors/isaacs"
- }
- },
"node_modules/require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
@@ -5175,6 +5157,27 @@
"url": "https://github.com/sponsors/isaacs"
}
},
+ "node_modules/rimraf/node_modules/glob": {
+ "version": "7.2.3",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
+ "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
+ "deprecated": "Glob versions prior to v9 are no longer supported",
+ "dev": true,
+ "dependencies": {
+ "fs.realpath": "^1.0.0",
+ "inflight": "^1.0.4",
+ "inherits": "2",
+ "minimatch": "^3.1.1",
+ "once": "^1.3.0",
+ "path-is-absolute": "^1.0.0"
+ },
+ "engines": {
+ "node": "*"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
"node_modules/robust-predicates": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/robust-predicates/-/robust-predicates-3.0.2.tgz",
@@ -5278,6 +5281,27 @@
"rimraf": "^2.5.2"
}
},
+ "node_modules/sander/node_modules/glob": {
+ "version": "7.2.3",
+ "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
+ "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
+ "deprecated": "Glob versions prior to v9 are no longer supported",
+ "dev": true,
+ "dependencies": {
+ "fs.realpath": "^1.0.0",
+ "inflight": "^1.0.4",
+ "inherits": "2",
+ "minimatch": "^3.1.1",
+ "once": "^1.3.0",
+ "path-is-absolute": "^1.0.0"
+ },
+ "engines": {
+ "node": "*"
+ },
+ "funding": {
+ "url": "https://github.com/sponsors/isaacs"
+ }
+ },
"node_modules/sander/node_modules/rimraf": {
"version": "2.7.1",
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
diff --git a/package.json b/package.json
index 7c44e47..dbec042 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@maptiler/geocoding-control",
- "version": "1.3.1",
+ "version": "1.3.2",
"description": "The Javascript & TypeScript Map Control component for MapTiler Geocoding service. Easy to be integrated into any JavaScript mapping application.",
"type": "module",
"author": {
@@ -102,7 +102,7 @@
"./types": "./types.d.ts"
},
"devDependencies": {
- "@maptiler/sdk": "^2.1.0",
+ "@maptiler/sdk": "^2.2.0",
"@sveltejs/package": "^2.3.2",
"@sveltejs/vite-plugin-svelte": "^3.1.1",
"@tsconfig/svelte": "^5.0.4",
@@ -119,26 +119,26 @@
"eslint": "^8.57.0",
"eslint-plugin-svelte": "^2.41.0",
"esm-env": "^1.0.0",
- "globals": "^15.6.0",
+ "globals": "^15.8.0",
"husky": "^9.0.11",
"leaflet": "^1.9.4",
"lint-staged": "^15.2.7",
- "maplibre-gl": "^4.4.1",
+ "maplibre-gl": "^4.5.0",
"ol": "9.1",
"prettier": "^3.3.2",
- "prettier-plugin-organize-imports": "^3.2.4",
+ "prettier-plugin-organize-imports": "^4.0.0",
"prettier-plugin-svelte": "^3.2.5",
"react": "^18.3.1",
"react-dom": "^18.3.1",
- "replace-in-file": "^8.0.1",
+ "replace-in-file": "^8.1.0",
"sass": "^1.77.6",
"svelte": "^4.2.18",
"svelte-check": "^3.8.4",
"svelte-preprocess": "^6.0.1",
"tslib": "^2.6.3",
- "typescript": "^5.5.2",
- "typescript-eslint": "^7.14.1",
- "vite": "^5.3.1"
+ "typescript": "^5.5.3",
+ "typescript-eslint": "^7.15.0",
+ "vite": "^5.3.3"
},
"peerDependencies": {
"@maptiler/sdk": "^1 || ^2",
@@ -158,10 +158,13 @@
"maplibre-gl": {
"optional": true
},
+ "ol": {
+ "optional": true
+ },
"react": {
"optional": true
},
- "ol": {
+ "svelte": {
"optional": true
}
},
diff --git a/vite.config.ts b/vite.config.ts
index 3bcc683..0480777 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -1,7 +1,7 @@
import { svelte } from "@sveltejs/vite-plugin-svelte";
import process from "node:process";
import { sveltePreprocess } from "svelte-preprocess";
-import { defineConfig } from "vite";
+import { BuildOptions, defineConfig } from "vite";
const libs = {
leaflet: {
@@ -51,17 +51,60 @@ const libs = {
},
};
+let lib: BuildOptions["lib"];
+
+let rollupOptions: BuildOptions["rollupOptions"];
+
const flavour = process.env.FLAVOUR;
-if (!flavour) {
- throw new Error("missing FLAVOUR environment variable");
-}
+if (flavour) {
+ if (!(flavour in libs)) {
+ throw new Error("invalid FLAVOUR");
+ }
-if (!(flavour in libs)) {
- throw new Error("invalid FLAVOUR");
-}
+ lib = libs[flavour as keyof typeof libs];
+
+ rollupOptions = {
+ external: [
+ "@maptiler/sdk",
+ "maplibre-gl",
+ "leaflet",
+ "react",
+ "react-dom",
+ /^ol(\/.*)?/,
+ ],
+ output: [
+ {
+ format: "es",
+ entryFileNames: "[name].js",
+ chunkFileNames: "[name].js",
+ assetFileNames: "[name].[ext]",
+ },
+ {
+ name: lib.name,
+ format: "umd",
+ entryFileNames: "[name].umd.js",
+ chunkFileNames: "[name].umd.js",
+ assetFileNames: "[name].[ext]",
+
+ // Provide global variables to use in the UMD build for externalized deps
+ globals(name) {
+ const global = {
+ "@maptiler/sdk": "maptilersdk",
+ "maplibre-gl": "maplibregl",
+ leaflet: "L",
+ react: "React",
+ "react-dom": "ReactDOM",
+ }[name];
-const lib = libs[flavour as keyof typeof libs];
+ return (
+ global ?? (name.startsWith("ol") ? name.replace(/\//g, ".") : "")
+ );
+ },
+ },
+ ],
+ };
+}
// https://vitejs.dev/config/
export default defineConfig({
@@ -75,46 +118,6 @@ export default defineConfig({
sourcemap: true,
emptyOutDir: false,
lib,
- // simplify after https://github.com/vitejs/vite/pull/10609 is released
- rollupOptions: {
- external: [
- "@maptiler/sdk",
- "maplibre-gl",
- "leaflet",
- "react",
- "react-dom",
- /^ol(\/.*)?/,
- ],
- output: [
- {
- format: "es",
- entryFileNames: "[name].js",
- chunkFileNames: "[name].js",
- assetFileNames: "[name].[ext]",
- },
- {
- name: lib.name,
- format: "umd",
- entryFileNames: "[name].umd.js",
- chunkFileNames: "[name].umd.js",
- assetFileNames: "[name].[ext]",
-
- // Provide global variables to use in the UMD build for externalized deps
- globals(name) {
- const global = {
- "@maptiler/sdk": "maptilersdk",
- "maplibre-gl": "maplibregl",
- leaflet: "L",
- react: "React",
- "react-dom": "ReactDOM",
- }[name];
-
- return (
- global ?? (name.startsWith("ol") ? name.replace(/\//g, ".") : "")
- );
- },
- },
- ],
- },
+ rollupOptions,
},
});