map-gl-offline 0.1.0-alpha.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.
Files changed (88) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +590 -0
  3. package/dist/index.d.ts +17 -0
  4. package/dist/index.esm.js +15863 -0
  5. package/dist/index.esm.js.map +1 -0
  6. package/dist/index.js +16015 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/main.d.ts +2 -0
  9. package/dist/managers/offlineMapManager/analyticsManagement.d.ts +7 -0
  10. package/dist/managers/offlineMapManager/base.d.ts +14 -0
  11. package/dist/managers/offlineMapManager/cleanupManagement.d.ts +16 -0
  12. package/dist/managers/offlineMapManager/importExportManagement.d.ts +10 -0
  13. package/dist/managers/offlineMapManager/index.d.ts +72 -0
  14. package/dist/managers/offlineMapManager/maintenanceManagement.d.ts +13 -0
  15. package/dist/managers/offlineMapManager/modules.d.ts +10 -0
  16. package/dist/managers/offlineMapManager/regionManagement.d.ts +11 -0
  17. package/dist/managers/offlineMapManager/resourceManagement.d.ts +24 -0
  18. package/dist/managers/offlineMapManager/styleManagement.d.ts +17 -0
  19. package/dist/managers/offlineMapManager.d.ts +2 -0
  20. package/dist/services/analyticsService.d.ts +10 -0
  21. package/dist/services/baseDownloadService.d.ts +96 -0
  22. package/dist/services/cleanupService.d.ts +34 -0
  23. package/dist/services/fontService.d.ts +26 -0
  24. package/dist/services/glyphService.d.ts +58 -0
  25. package/dist/services/importExportService.d.ts +57 -0
  26. package/dist/services/maintenanceService.d.ts +15 -0
  27. package/dist/services/regionService.d.ts +31 -0
  28. package/dist/services/resourceService.d.ts +42 -0
  29. package/dist/services/spriteService.d.ts +30 -0
  30. package/dist/services/styleService.d.ts +73 -0
  31. package/dist/services/tileService.d.ts +24 -0
  32. package/dist/storage/indexedDbManager.d.ts +2 -0
  33. package/dist/style.css +213 -0
  34. package/dist/types/cleanup.d.ts +49 -0
  35. package/dist/types/database.d.ts +33 -0
  36. package/dist/types/font.d.ts +115 -0
  37. package/dist/types/glyph.d.ts +127 -0
  38. package/dist/types/import-export.d.ts +96 -0
  39. package/dist/types/index.d.ts +12 -0
  40. package/dist/types/maintenance.d.ts +49 -0
  41. package/dist/types/progress.d.ts +11 -0
  42. package/dist/types/region.d.ts +57 -0
  43. package/dist/types/sprite.d.ts +172 -0
  44. package/dist/types/style.d.ts +103 -0
  45. package/dist/types/tile.d.ts +112 -0
  46. package/dist/types/ui.d.ts +10 -0
  47. package/dist/ui/ThemeManager.d.ts +23 -0
  48. package/dist/ui/components/DownloadProgress.d.ts +14 -0
  49. package/dist/ui/components/PanelActions.d.ts +12 -0
  50. package/dist/ui/components/PanelHeader.d.ts +15 -0
  51. package/dist/ui/components/RegionList.d.ts +24 -0
  52. package/dist/ui/components/shared/BaseComponent.d.ts +86 -0
  53. package/dist/ui/components/shared/Button.d.ts +45 -0
  54. package/dist/ui/components/shared/List.d.ts +56 -0
  55. package/dist/ui/components/shared/MapControlButton.d.ts +37 -0
  56. package/dist/ui/components/shared/Modal.d.ts +49 -0
  57. package/dist/ui/components/shared/Panel.d.ts +53 -0
  58. package/dist/ui/components/shared/PanelContent.d.ts +39 -0
  59. package/dist/ui/components/shared/RegionDrawingTool.d.ts +54 -0
  60. package/dist/ui/components/shared/index.d.ts +12 -0
  61. package/dist/ui/controls/polygonControl.d.ts +83 -0
  62. package/dist/ui/controls/regionControl.d.ts +71 -0
  63. package/dist/ui/managers/ControlButtonManager.d.ts +42 -0
  64. package/dist/ui/managers/PanelManager.d.ts +160 -0
  65. package/dist/ui/managers/downloadManager.d.ts +63 -0
  66. package/dist/ui/modals/confirmationModal.d.ts +30 -0
  67. package/dist/ui/modals/importExportModal.d.ts +46 -0
  68. package/dist/ui/modals/importExportModal.old.d.ts +27 -0
  69. package/dist/ui/modals/modalManager.d.ts +23 -0
  70. package/dist/ui/modals/regionDetailsModal.d.ts +37 -0
  71. package/dist/ui/modals/regionFormModal.d.ts +86 -0
  72. package/dist/ui/offlineManagerControl.d.ts +120 -0
  73. package/dist/utils/asyncUtils.d.ts +24 -0
  74. package/dist/utils/cleanupCompressedTiles.d.ts +12 -0
  75. package/dist/utils/constants.d.ts +94 -0
  76. package/dist/utils/download.d.ts +52 -0
  77. package/dist/utils/errorHandling.d.ts +67 -0
  78. package/dist/utils/formatUtils.d.ts +24 -0
  79. package/dist/utils/formatting.d.ts +31 -0
  80. package/dist/utils/icons.d.ts +50 -0
  81. package/dist/utils/idbFetchHandler.d.ts +2 -0
  82. package/dist/utils/index.d.ts +13 -0
  83. package/dist/utils/logger.d.ts +52 -0
  84. package/dist/utils/performance.d.ts +164 -0
  85. package/dist/utils/styleProviderUtils.d.ts +42 -0
  86. package/dist/utils/styleUtils.d.ts +35 -0
  87. package/dist/utils/validation.d.ts +67 -0
  88. package/package.json +145 -0
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Validation utilities for common patterns
3
+ * Provides reusable validation functions to ensure data integrity
4
+ */
5
+ import type { OfflineRegionOptions } from '../types';
6
+ /**
7
+ * Validate geographic bounds
8
+ * @param bounds - Array of two [lng, lat] coordinate pairs
9
+ * @returns true if valid, throws error if invalid
10
+ */
11
+ export declare function validateBounds(bounds: unknown): bounds is [[number, number], [number, number]];
12
+ /**
13
+ * Validate zoom levels
14
+ * @param minZoom - Minimum zoom level
15
+ * @param maxZoom - Maximum zoom level
16
+ * @param allowedMin - Minimum allowed value (default: 0)
17
+ * @param allowedMax - Maximum allowed value (default: 24)
18
+ * @returns true if valid, throws error if invalid
19
+ */
20
+ export declare function validateZoomLevels(minZoom: unknown, maxZoom: unknown, allowedMin?: number, allowedMax?: number): boolean;
21
+ /**
22
+ * Validate region configuration
23
+ * @param options - Region options to validate
24
+ * @returns true if valid, throws error if invalid
25
+ */
26
+ export declare function validateRegionOptions(options: unknown): options is OfflineRegionOptions;
27
+ /**
28
+ * Validate style URL
29
+ * @param url - Style URL to validate
30
+ * @returns true if valid, throws error if invalid
31
+ */
32
+ export declare function validateStyleUrl(url: unknown): url is string;
33
+ /**
34
+ * Validate region ID format
35
+ * @param id - Region ID to validate
36
+ * @returns true if valid, throws error if invalid
37
+ */
38
+ export declare function validateRegionId(id: unknown): id is string;
39
+ /**
40
+ * Validate download options batch size
41
+ * @param batchSize - Batch size to validate
42
+ * @param min - Minimum allowed value (default: 1)
43
+ * @param max - Maximum allowed value (default: 100)
44
+ * @returns true if valid, throws error if invalid
45
+ */
46
+ export declare function validateBatchSize(batchSize: unknown, min?: number, max?: number): batchSize is number;
47
+ /**
48
+ * Validate timeout value
49
+ * @param timeout - Timeout in milliseconds
50
+ * @param min - Minimum allowed value (default: 1000)
51
+ * @param max - Maximum allowed value (default: 120000)
52
+ * @returns true if valid, throws error if invalid
53
+ */
54
+ export declare function validateTimeout(timeout: unknown, min?: number, max?: number): timeout is number;
55
+ /**
56
+ * Safe validation wrapper that returns a result object instead of throwing
57
+ * @param validator - Validation function that throws on error
58
+ * @param value - Value to validate
59
+ * @returns Object with isValid boolean and optional error message
60
+ */
61
+ export declare function safeValidate<T>(validator: (value: unknown) => value is T, value: unknown): {
62
+ isValid: true;
63
+ value: T;
64
+ } | {
65
+ isValid: false;
66
+ error: string;
67
+ };
package/package.json ADDED
@@ -0,0 +1,145 @@
1
+ {
2
+ "name": "map-gl-offline",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "A TypeScript-compatible npm package for MapLibre GL JS that enables comprehensive offline storage and usage of vector/raster tiles, sprites, styles, fonts (glyphs), and entire map regions with advanced analytics, import/export capabilities, and intelligent cleanup.",
5
+ "main": "dist/index.js",
6
+ "module": "dist/index.esm.js",
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.esm.js",
12
+ "require": "./dist/index.js"
13
+ },
14
+ "./style.css": "./dist/style.css"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/muimsd/map-gl-offline.git"
24
+ },
25
+ "homepage": "https://github.com/muimsd/map-gl-offline#readme",
26
+ "bugs": {
27
+ "url": "https://github.com/muimsd/map-gl-offline/issues"
28
+ },
29
+ "scripts": {
30
+ "dev": "vite",
31
+ "build": "npm run build:clean && npm run build:lib && npm run build:types && npm run build:css",
32
+ "build:clean": "rimraf dist",
33
+ "build:lib": "rollup -c",
34
+ "build:types": "tsc --declaration --emitDeclarationOnly --outDir dist",
35
+ "build:css": "cp src/styles/style.css dist/style.css",
36
+ "build:watch": "rollup -c -w",
37
+ "build:dev": "npm run build:clean && npm run build:lib",
38
+ "preview": "vite preview",
39
+ "start:examples": "cd examples/maplibre && npm i && npm run dev",
40
+ "test": "jest",
41
+ "test:watch": "jest --watch",
42
+ "test:coverage": "jest --coverage",
43
+ "test:ci": "jest --ci --coverage --watchAll=false",
44
+ "lint": "eslint src --ext .ts,.tsx --ignore-pattern 'src/main.ts'",
45
+ "lint:fix": "eslint src --ext .ts,.tsx --ignore-pattern 'src/main.ts' --fix",
46
+ "lint:warn": "eslint src --ext .ts,.tsx --ignore-pattern 'src/main.ts' --max-warnings 200",
47
+ "format": "prettier --write \"src/**/*.{ts,tsx,json,md}\"",
48
+ "format:check": "prettier --check \"src/**/*.{ts,tsx,json,md}\"",
49
+ "typecheck": "tsc --noEmit",
50
+ "validate": "npm run typecheck && npm run test:ci",
51
+ "validate:strict": "npm run typecheck && npm run lint && npm run test:ci",
52
+ "clean": "npm run build:clean && rimraf node_modules/.cache",
53
+ "prepublishOnly": "npm run validate && npm run build",
54
+ "release": "npm version patch && npm publish",
55
+ "release:minor": "npm version minor && npm publish",
56
+ "release:major": "npm version major && npm publish",
57
+ "release:dry": "npm publish --dry-run"
58
+ },
59
+ "keywords": [
60
+ "mapbox-gl",
61
+ "maplibre-gl",
62
+ "offline",
63
+ "maps",
64
+ "tiles",
65
+ "caching",
66
+ "indexeddb",
67
+ "pwa",
68
+ "vector-tiles",
69
+ "raster-tiles",
70
+ "sprites",
71
+ "fonts",
72
+ "glyphs",
73
+ "pmtiles",
74
+ "mbtiles",
75
+ "import",
76
+ "export",
77
+ "typescript",
78
+ "progressive-web-app",
79
+ "offline-maps",
80
+ "map-tiles",
81
+ "mobile",
82
+ "analytics"
83
+ ],
84
+ "author": "Muhammad Imran Siddique",
85
+ "license": "MIT",
86
+ "type": "module",
87
+ "dependencies": {
88
+ "@mapbox/tilebelt": "^2.0.2",
89
+ "@tabler/icons": "^3.34.0",
90
+ "@tailwindcss/vite": "^4.1.8",
91
+ "@turf/turf": "^7.2.0",
92
+ "idb": "^8.0.2"
93
+ },
94
+ "peerDependencies": {
95
+ "mapbox-gl": ">=2.0.0",
96
+ "maplibre-gl": ">=1.0.0"
97
+ },
98
+ "peerDependenciesMeta": {
99
+ "mapbox-gl": {
100
+ "optional": true
101
+ },
102
+ "maplibre-gl": {
103
+ "optional": true
104
+ }
105
+ },
106
+ "devDependencies": {
107
+ "@eslint/js": "^9.28.0",
108
+ "@rollup/plugin-commonjs": "^28.0.3",
109
+ "@rollup/plugin-node-resolve": "^16.0.1",
110
+ "@rollup/plugin-typescript": "^12.1.2",
111
+ "@tailwindcss/postcss": "^4.1.8",
112
+ "@types/jest": "^29.5.14",
113
+ "@types/mapbox-gl": "^3.4.1",
114
+ "@types/mapbox__tilebelt": "^1.0.4",
115
+ "@types/maplibre-gl": "^1.14.0",
116
+ "@types/node": "^22.13.10",
117
+ "@typescript-eslint/eslint-plugin": "^8.33.1",
118
+ "@typescript-eslint/parser": "^8.33.1",
119
+ "autoprefixer": "^10.4.21",
120
+ "concurrently": "^9.1.2",
121
+ "eslint": "^9.22.0",
122
+ "eslint-config-prettier": "^9.1.0",
123
+ "eslint-plugin-prettier": "^5.4.1",
124
+ "fake-indexeddb": "^6.0.1",
125
+ "jest": "^29.7.0",
126
+ "jest-environment-jsdom": "30.0.0-beta.3",
127
+ "map-gl-style-switcher": "^0.9.1",
128
+ "nodemon": "^3.1.9",
129
+ "postcss": "^8.5.4",
130
+ "prettier": "^3.5.3",
131
+ "rimraf": "^6.0.1",
132
+ "rollup": "^4.37.0",
133
+ "rollup-plugin-dts": "^6.2.1",
134
+ "tailwindcss": "^4.1.8",
135
+ "ts-jest": "^29.2.6",
136
+ "ts-node": "^10.9.2",
137
+ "tsconfig-paths": "^4.2.0",
138
+ "tslib": "^2.8.1",
139
+ "tsx": "^4.19.3",
140
+ "typescript": "^5.8.2",
141
+ "typescript-eslint": "^8.33.1",
142
+ "vite": "^6.2.3",
143
+ "vite-tsconfig-paths": "^5.1.4"
144
+ }
145
+ }