@maplibre-yaml/core 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.
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 mariogiampieri
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,106 @@
1
+ import { M as MapRenderer } from '../map-renderer-RQc5_bdo.js';
2
+ import 'maplibre-gl';
3
+ import 'zod';
4
+ import '../map.schema-EnZRrtIh.js';
5
+
6
+ /**
7
+ * @file Custom HTML element for declarative map creation
8
+ * @module @maplibre-yaml/core/components
9
+ */
10
+
11
+ /**
12
+ * Custom HTML element for creating maps declaratively
13
+ *
14
+ * @example
15
+ * ```html
16
+ * <!-- Using JSON attribute -->
17
+ * <ml-map config='{"config": {...}, "layers": [...]}'></ml-map>
18
+ *
19
+ * <!-- Using inline YAML -->
20
+ * <ml-map>
21
+ * <script type="application/yaml">
22
+ * config:
23
+ * mapStyle: https://demotiles.maplibre.org/style.json
24
+ * center: [-74.5, 40]
25
+ * zoom: 9
26
+ * layers:
27
+ * - id: points
28
+ * type: circle
29
+ * </script>
30
+ * </ml-map>
31
+ *
32
+ * <!-- Using inline JSON -->
33
+ * <ml-map>
34
+ * <script type="application/json">
35
+ * {
36
+ * "config": {
37
+ * "mapStyle": "https://demotiles.maplibre.org/style.json",
38
+ * "center": [-74.5, 40],
39
+ * "zoom": 9
40
+ * }
41
+ * }
42
+ * </script>
43
+ * </ml-map>
44
+ * ```
45
+ */
46
+ declare class MLMap extends HTMLElement {
47
+ private renderer;
48
+ private container;
49
+ /**
50
+ * Observed attributes that trigger attributeChangedCallback
51
+ */
52
+ static get observedAttributes(): string[];
53
+ /**
54
+ * Called when element is added to the DOM
55
+ */
56
+ connectedCallback(): void;
57
+ /**
58
+ * Called when element is removed from the DOM
59
+ */
60
+ disconnectedCallback(): void;
61
+ /**
62
+ * Called when an observed attribute changes
63
+ */
64
+ attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
65
+ /**
66
+ * Get configuration from one of three sources:
67
+ * 1. 'config' attribute (JSON string)
68
+ * 2. Inline <script type="application/yaml">
69
+ * 3. Inline <script type="application/json">
70
+ */
71
+ private getConfig;
72
+ /**
73
+ * Render the map with the given configuration
74
+ */
75
+ private render;
76
+ /**
77
+ * Get the underlying MapRenderer instance
78
+ */
79
+ getRenderer(): MapRenderer | null;
80
+ /**
81
+ * Get the underlying MapLibre Map instance
82
+ */
83
+ getMap(): any;
84
+ }
85
+
86
+ /**
87
+ * @file Default CSS styles for ml-map web component
88
+ * @module @maplibre-yaml/core/components
89
+ */
90
+ /**
91
+ * Default CSS styles for the ml-map custom element
92
+ *
93
+ * These styles ensure:
94
+ * - The ml-map element behaves as a block-level container
95
+ * - The map fills the available space
96
+ * - Proper display defaults for embedded elements
97
+ */
98
+ declare const defaultStyles = "\n ml-map {\n display: block;\n position: relative;\n width: 100%;\n height: 400px;\n }\n\n ml-map > div {\n width: 100%;\n height: 100%;\n }\n\n ml-map script[type=\"application/yaml\"],\n ml-map script[type=\"application/json\"] {\n display: none;\n }\n";
99
+ /**
100
+ * Inject default styles into the document head
101
+ *
102
+ * This function is idempotent - it will only inject styles once even if called multiple times.
103
+ */
104
+ declare function injectStyles(): void;
105
+
106
+ export { MLMap, defaultStyles, injectStyles };