@maptiler/sdk 3.2.2 → 3.2.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.
- package/README.md +1 -0
- package/dist/maptiler-sdk.mjs +3 -3
- package/dist/maptiler-sdk.mjs.map +1 -1
- package/dist/src/helpers/index.d.ts +2 -0
- package/dist/src/index.d.ts +1 -0
- package/{eslint.config.mjs → eslint.config.ts} +16 -3
- package/package.json +7 -4
- package/tsconfig.json +1 -0
- package/vite.config-dev.ts +82 -16
package/dist/src/index.d.ts
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
3
3
|
import tseslint from "typescript-eslint";
|
|
4
4
|
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
|
|
5
5
|
|
|
6
|
+
import { TSESTree } from "@typescript-eslint/utils";
|
|
7
|
+
import { RuleContext } from "@typescript-eslint/utils/dist/ts-eslint";
|
|
8
|
+
|
|
9
|
+
type Node = TSESTree.ImportDeclaration;
|
|
10
|
+
|
|
11
|
+
type CustomRuleOptions = {
|
|
12
|
+
locations: string[];
|
|
13
|
+
message?: string;
|
|
14
|
+
fixedLocation?: string;
|
|
15
|
+
ignoreTypeImports?: boolean;
|
|
16
|
+
};
|
|
17
|
+
|
|
6
18
|
export default tseslint.config(
|
|
7
19
|
// https://typescript-eslint.io/getting-started/typed-linting/
|
|
8
20
|
tseslint.configs.strictTypeChecked,
|
|
@@ -27,7 +39,7 @@ export default tseslint.config(
|
|
|
27
39
|
},
|
|
28
40
|
],
|
|
29
41
|
},
|
|
30
|
-
create: function (context) {
|
|
42
|
+
create: function (context: RuleContext<"bannedImport", Node[]>) {
|
|
31
43
|
const filePath = context.getFilename();
|
|
32
44
|
const options = context.options[0] || {
|
|
33
45
|
"^/(.*)": {
|
|
@@ -36,8 +48,8 @@ export default tseslint.config(
|
|
|
36
48
|
};
|
|
37
49
|
|
|
38
50
|
return {
|
|
39
|
-
ImportDeclaration: (node) => {
|
|
40
|
-
Object.entries(options).forEach(([bannedImport, config]) => {
|
|
51
|
+
ImportDeclaration: (node: Node) => {
|
|
52
|
+
Object.entries(options).forEach(([bannedImport, config]: [string, CustomRuleOptions]) => {
|
|
41
53
|
const importLocationRegex = new RegExp(bannedImport);
|
|
42
54
|
|
|
43
55
|
if (config.ignoreTypeImports && node.importKind === "type") return;
|
|
@@ -50,6 +62,7 @@ export default tseslint.config(
|
|
|
50
62
|
node.specifiers.forEach((specifier) => {
|
|
51
63
|
if (specifier.type !== "ImportDefaultSpecifier") {
|
|
52
64
|
context.report({
|
|
65
|
+
// @ts-expect-error `message` seems to work with this...
|
|
53
66
|
message: config.message ?? `Importing from '${bannedImport}' is banned in '${fp}'`,
|
|
54
67
|
node,
|
|
55
68
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maptiler/sdk",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.3",
|
|
4
4
|
"description": "The Javascript & TypeScript map SDK tailored for MapTiler Cloud",
|
|
5
5
|
"author": "MapTiler",
|
|
6
6
|
"module": "dist/maptiler-sdk.mjs",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"prepare": "husky",
|
|
39
39
|
"doc": "rm -rf docs/* && typedoc --out docs && cp -r images docs/",
|
|
40
40
|
"ncu": "npx npm-check-updates",
|
|
41
|
-
"lint": "eslint src",
|
|
42
|
-
"lint:fix": "eslint src --fix",
|
|
41
|
+
"lint": "tsc --noEmit && eslint src",
|
|
42
|
+
"lint:fix": "tsc --noEmit && eslint src --fix",
|
|
43
43
|
"test:watch": "vitest watch -c vite.config-test.ts --dom",
|
|
44
44
|
"test": "vitest run -c vite.config-test.ts --dom",
|
|
45
45
|
"install:clean": "rm -rf build/ dist/ node_modules/ && npm ci",
|
|
46
|
-
"dev": "
|
|
46
|
+
"dev": "vite -c vite.config-dev.ts",
|
|
47
47
|
"dev-umd": "npm run build-css && tsc && NODE_ENV=development vite build -w -c vite.config-umd.ts",
|
|
48
48
|
"build-css": "mkdir -p dist build && node scripts/replace-path-with-content.js src/style/style_template.css dist/tmp_maptiler-sdk.css && cat node_modules/maplibre-gl/dist/maplibre-gl.css dist/tmp_maptiler-sdk.css > dist/maptiler-sdk.css && rm dist/tmp_maptiler-sdk.css && cp dist/maptiler-sdk.css build/maptiler-sdk.css",
|
|
49
49
|
"build-umd": "tsc && NODE_ENV=production vite build -c vite.config-umd.ts",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@canvas/image-data": "^1.0.0",
|
|
59
59
|
"@eslint/js": "^9.21.0",
|
|
60
|
+
"@types/stats.js": "^0.17.4",
|
|
60
61
|
"@types/uuid": "^10.0.0",
|
|
61
62
|
"@types/xmldom": "^0.1.31",
|
|
62
63
|
"@vitest/web-worker": "^3.0.9",
|
|
@@ -67,8 +68,10 @@
|
|
|
67
68
|
"eslint-plugin-prettier": "^5.2.3",
|
|
68
69
|
"happy-dom": "^17.4.4",
|
|
69
70
|
"husky": "^8.0.0",
|
|
71
|
+
"jiti": "^2.4.2",
|
|
70
72
|
"lint-staged": "^15.4.3",
|
|
71
73
|
"prettier": "3.5.2",
|
|
74
|
+
"stats.js": "^0.17.0",
|
|
72
75
|
"typedoc": "^0.27.6",
|
|
73
76
|
"typescript": "^5.7.3",
|
|
74
77
|
"typescript-eslint": "^8.25.0",
|
package/tsconfig.json
CHANGED
package/vite.config-dev.ts
CHANGED
|
@@ -1,9 +1,66 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { defineConfig } from 'vite';
|
|
2
3
|
import packagejson from "./package.json";
|
|
4
|
+
import { readdirSync } from 'fs';
|
|
5
|
+
|
|
6
|
+
function green(text: string) {
|
|
7
|
+
return `\x1b[32m${text}\x1b[0m`;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function yellow(text: string) {
|
|
11
|
+
return `\x1b[33m${text}\x1b[0m`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function d(text: string) {
|
|
15
|
+
return `\x1b[0m${text}\x1b[0m`;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function purple(text: string) {
|
|
19
|
+
return `\x1b[35m${text}\x1b[0m`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function centerText(text: string, lineLength: number) {
|
|
23
|
+
// strip ansi codes from the text
|
|
24
|
+
const stripped = text.replace(/\x1b\[[0-9;]*m/g, '');
|
|
25
|
+
const ansiCodes = text.match(/\x1b\[[0-9;]*m/g) || [];
|
|
26
|
+
const diff = lineLength - stripped.length;
|
|
27
|
+
const leftPadding = Math.floor(diff / 2);
|
|
28
|
+
const rightPadding = diff - leftPadding;
|
|
29
|
+
const left = ' '.repeat(leftPadding);
|
|
30
|
+
const right = ' '.repeat(rightPadding - 1);
|
|
31
|
+
return `${left}${ansiCodes}${text}${right}`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const entrypoints = readdirSync(resolve(__dirname, 'demos/public')).filter((file) => {
|
|
35
|
+
return file.endsWith('.html');
|
|
36
|
+
}).reduce((entries, file) => {
|
|
37
|
+
// const file = path.
|
|
38
|
+
|
|
39
|
+
const camelKey = file
|
|
40
|
+
.replace(/\.html$/, '')
|
|
41
|
+
.replace(/-([a-z])/g, (g) => g[1].toUpperCase())
|
|
42
|
+
.replace(/([0-9])/g, '')
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
const key = camelKey.charAt(0).toUpperCase() + camelKey.slice(1);
|
|
46
|
+
const entry = file
|
|
47
|
+
return {
|
|
48
|
+
...entries,
|
|
49
|
+
[key]: entry,
|
|
50
|
+
}
|
|
51
|
+
}, {})
|
|
52
|
+
|
|
53
|
+
// console.log('Demos being server from:', Object.values(entrypoints).map((entry) => entry).join('\n'));
|
|
3
54
|
|
|
4
55
|
export default defineConfig({
|
|
5
|
-
|
|
6
|
-
|
|
56
|
+
mode: "development",
|
|
57
|
+
root: "./demos",
|
|
58
|
+
build: {
|
|
59
|
+
minify: false,
|
|
60
|
+
sourcemap: true,
|
|
61
|
+
rollupOptions: {
|
|
62
|
+
input: entrypoints,
|
|
63
|
+
},
|
|
7
64
|
},
|
|
8
65
|
define: {
|
|
9
66
|
__MT_SDK_VERSION__: JSON.stringify(packagejson.version),
|
|
@@ -15,19 +72,28 @@ export default defineConfig({
|
|
|
15
72
|
* Changing logged URLs to include the path to the demo directory.
|
|
16
73
|
*/
|
|
17
74
|
configureServer: (server) => {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
75
|
+
const port = server.config.server.port
|
|
76
|
+
const urls = Object.values(entrypoints).map((entry) => {
|
|
77
|
+
return `http://localhost:${port}/${entry}`
|
|
78
|
+
})
|
|
79
|
+
const lineLength = Math.max(...urls.map((entry) => entry.length)) + 4
|
|
80
|
+
console.log('\n')
|
|
81
|
+
console.log('┏' + '━'.repeat(lineLength) + '┓')
|
|
82
|
+
console.info(`┃` + ' '.repeat(lineLength) + '┃')
|
|
83
|
+
console.info('┃' + yellow(centerText(`** MapTiler SDK JS **`, lineLength)) + ' ┃')
|
|
84
|
+
console.info('┃' + purple(centerText(`** Demos **`, lineLength)) + ' ┃')
|
|
85
|
+
console.info(`┃` + ' '.repeat(lineLength) + '┃')
|
|
86
|
+
urls.map((entry) => {
|
|
87
|
+
return `${d('┃')} - ${entry}`
|
|
88
|
+
}, []).forEach((entry, _, arr) => {
|
|
89
|
+
const numCharactersToPad = Math.max(...arr.map((entry) => entry.length)) - entry.length
|
|
90
|
+
const padding = ' '.repeat(numCharactersToPad)
|
|
91
|
+
const output = green(entry) + padding + ' ┃'
|
|
92
|
+
console.log(output)
|
|
93
|
+
})
|
|
94
|
+
console.log('┗' + '━'.repeat(lineLength) + '┛')
|
|
95
|
+
|
|
96
|
+
console.log('\n')
|
|
31
97
|
}
|
|
32
98
|
}
|
|
33
99
|
],
|