@maplibre-yaml/core 0.1.3 → 0.2.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/README.md +44 -0
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +25 -12
- package/dist/components/index.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +23 -10
- package/dist/index.js.map +1 -1
- package/dist/{map-renderer-Br4guic2.d.ts → map-renderer-8-c51Ww7.d.ts} +3 -2
- package/dist/{page.schema-EBT_0Ojm.d.ts → page.schema-Cad2FFqh.d.ts} +1637 -1
- package/dist/register.browser.js +25 -12
- package/dist/register.browser.js.map +1 -1
- package/dist/register.d.ts +2 -2
- package/dist/register.js +25 -12
- package/dist/register.js.map +1 -1
- package/dist/schemas/index.d.ts +2 -1638
- package/dist/schemas/index.js +2 -0
- package/dist/schemas/index.js.map +1 -1
- package/package.json +1 -1
package/dist/register.browser.js
CHANGED
|
@@ -11887,6 +11887,7 @@ var MapBlockSchema = external_exports.object({
|
|
|
11887
11887
|
className: external_exports.string().optional().describe("CSS class name for container"),
|
|
11888
11888
|
style: external_exports.string().optional().describe("Inline CSS styles for container"),
|
|
11889
11889
|
config: MapConfigSchema.describe("Map configuration"),
|
|
11890
|
+
sources: external_exports.record(external_exports.string(), LayerSourceSchema).optional().describe("Map sources"),
|
|
11890
11891
|
layers: external_exports.array(LayerOrReferenceSchema).default([]).describe("Map layers"),
|
|
11891
11892
|
controls: ControlsConfigSchema.optional().describe("Map controls"),
|
|
11892
11893
|
legend: LegendConfigSchema.optional().describe("Legend configuration")
|
|
@@ -11897,6 +11898,7 @@ var MapFullPageBlockSchema = external_exports.object({
|
|
|
11897
11898
|
className: external_exports.string().optional().describe("CSS class name for container"),
|
|
11898
11899
|
style: external_exports.string().optional().describe("Inline CSS styles for container"),
|
|
11899
11900
|
config: MapConfigSchema.describe("Map configuration"),
|
|
11901
|
+
sources: external_exports.record(external_exports.string(), LayerSourceSchema).optional().describe("Map sources"),
|
|
11900
11902
|
layers: external_exports.array(LayerOrReferenceSchema).default([]).describe("Map layers"),
|
|
11901
11903
|
controls: ControlsConfigSchema.optional().describe("Map controls"),
|
|
11902
11904
|
legend: LegendConfigSchema.optional().describe("Legend configuration")
|
|
@@ -14868,9 +14870,16 @@ var LayerManager = class {
|
|
|
14868
14870
|
this.abortControllers = /* @__PURE__ */ new Map();
|
|
14869
14871
|
}
|
|
14870
14872
|
async addLayer(layer) {
|
|
14871
|
-
const
|
|
14873
|
+
const isSourceRef = typeof layer.source === "string";
|
|
14874
|
+
const sourceId = isSourceRef ? layer.source : `${layer.id}-source`;
|
|
14872
14875
|
this.layerToSource.set(layer.id, sourceId);
|
|
14873
|
-
|
|
14876
|
+
if (!isSourceRef) {
|
|
14877
|
+
await this.addSource(sourceId, layer);
|
|
14878
|
+
} else if (!this.map.getSource(sourceId)) {
|
|
14879
|
+
throw new Error(
|
|
14880
|
+
`Source '${sourceId}' referenced by layer '${layer.id}' not found. Ensure it is defined in the block-level 'sources' map.`
|
|
14881
|
+
);
|
|
14882
|
+
}
|
|
14874
14883
|
const layerSpec = {
|
|
14875
14884
|
id: layer.id,
|
|
14876
14885
|
type: layer.type,
|
|
@@ -14898,12 +14907,6 @@ var LayerManager = class {
|
|
|
14898
14907
|
}
|
|
14899
14908
|
}
|
|
14900
14909
|
async addSource(sourceId, layer) {
|
|
14901
|
-
if (typeof layer.source === "string") {
|
|
14902
|
-
if (!this.map.getSource(layer.source)) {
|
|
14903
|
-
throw new Error(`Source reference '${layer.source}' not found`);
|
|
14904
|
-
}
|
|
14905
|
-
return;
|
|
14906
|
-
}
|
|
14907
14910
|
const source = layer.source;
|
|
14908
14911
|
if (source.type === "geojson") {
|
|
14909
14912
|
const geojsonSource = source;
|
|
@@ -15123,7 +15126,10 @@ var LayerManager = class {
|
|
|
15123
15126
|
}
|
|
15124
15127
|
if (this.map.getLayer(layerId)) this.map.removeLayer(layerId);
|
|
15125
15128
|
const sourceId = this.layerToSource.get(layerId) || `${layerId}-source`;
|
|
15126
|
-
|
|
15129
|
+
const isInlineSource = sourceId === `${layerId}-source`;
|
|
15130
|
+
if (isInlineSource && this.map.getSource(sourceId)) {
|
|
15131
|
+
this.map.removeSource(sourceId);
|
|
15132
|
+
}
|
|
15127
15133
|
this.sourceData.delete(sourceId);
|
|
15128
15134
|
this.layerToSource.delete(layerId);
|
|
15129
15135
|
}
|
|
@@ -15485,7 +15491,7 @@ var MapRenderer = class {
|
|
|
15485
15491
|
controlsManager;
|
|
15486
15492
|
eventListeners;
|
|
15487
15493
|
isLoaded;
|
|
15488
|
-
constructor(container, config, layers = [], options = {}) {
|
|
15494
|
+
constructor(container, config, layers = [], options = {}, sources) {
|
|
15489
15495
|
this.eventListeners = /* @__PURE__ */ new Map();
|
|
15490
15496
|
this.isLoaded = false;
|
|
15491
15497
|
this.map = new maplibregl2.Map({
|
|
@@ -15513,6 +15519,13 @@ var MapRenderer = class {
|
|
|
15513
15519
|
this.controlsManager = new ControlsManager(this.map);
|
|
15514
15520
|
this.map.on("load", () => {
|
|
15515
15521
|
this.isLoaded = true;
|
|
15522
|
+
if (sources) {
|
|
15523
|
+
for (const [id, sourceSpec] of Object.entries(sources)) {
|
|
15524
|
+
if (!this.map.getSource(id)) {
|
|
15525
|
+
this.map.addSource(id, sourceSpec);
|
|
15526
|
+
}
|
|
15527
|
+
}
|
|
15528
|
+
}
|
|
15516
15529
|
Promise.all(layers.map((layer) => this.addLayer(layer))).then(() => {
|
|
15517
15530
|
this.emit("load", void 0);
|
|
15518
15531
|
options.onLoad?.();
|
|
@@ -15812,7 +15825,7 @@ var MLMap = class extends HTMLElement {
|
|
|
15812
15825
|
}
|
|
15813
15826
|
this.appendChild(this.mapContainer);
|
|
15814
15827
|
try {
|
|
15815
|
-
const { config, layers = [] } = mapBlock;
|
|
15828
|
+
const { config, sources, layers = [] } = mapBlock;
|
|
15816
15829
|
this.renderer = new MapRenderer(this.mapContainer, config, layers, {
|
|
15817
15830
|
onLoad: () => {
|
|
15818
15831
|
},
|
|
@@ -15824,7 +15837,7 @@ var MLMap = class extends HTMLElement {
|
|
|
15824
15837
|
})
|
|
15825
15838
|
);
|
|
15826
15839
|
}
|
|
15827
|
-
});
|
|
15840
|
+
}, sources);
|
|
15828
15841
|
this.setupEventForwarding();
|
|
15829
15842
|
} catch (error) {
|
|
15830
15843
|
this.handleError([
|