@kispace-io/gs-lib 1.3.9 → 1.3.10

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/dist/index.js CHANGED
@@ -1,12 +1,10 @@
1
1
  import { v4 } from "@eclipse-lyra/core/externals/third-party";
2
- import * as ol$1 from "ol";
3
- import { Feature, Overlay, Map as Map$1, View } from "ol";
4
- export * from "ol";
5
- import * as olGeom from "ol/geom";
2
+ import { Feature, Map as Map$1, Overlay, View } from "ol";
3
+ import * as geom from "ol/geom";
6
4
  import * as style from "ol/style";
7
5
  import { Circle, Fill, Icon, RegularShape, Stroke, Style, Text } from "ol/style";
8
6
  import * as source from "ol/source";
9
- import { OSM, XYZ, TileWMS, WMTS, GeoTIFF } from "ol/source";
7
+ import { GeoTIFF, OSM, TileWMS, WMTS, XYZ } from "ol/source";
10
8
  import { optionsFromCapabilities } from "ol/source/WMTS";
11
9
  import WMTSCapabilities from "ol/format/WMTSCapabilities";
12
10
  import VectorSource from "ol/source/Vector";
@@ -14,348 +12,295 @@ import { bbox } from "ol/loadingstrategy";
14
12
  import * as proj from "ol/proj";
15
13
  import { transformExtent } from "ol/proj";
16
14
  import * as format from "ol/format";
17
- import { GeoJSON, GPX } from "ol/format";
15
+ import { GPX, GeoJSON } from "ol/format";
18
16
  import TileLayer from "ol/layer/Tile";
19
17
  import VectorLayer from "ol/layer/Vector";
20
- import { apply } from "ol-mapbox-style";
21
- import { apply as apply2 } from "ol-mapbox-style";
18
+ import { apply, apply as applyMapboxStyle } from "ol-mapbox-style";
22
19
  import LayerGroup from "ol/layer/Group";
23
20
  import { Control } from "ol/control";
24
- import * as layerNS from "ol/layer";
25
- import * as interactionNS from "ol/interaction";
21
+ import * as layer from "ol/layer";
22
+ import * as interaction from "ol/interaction";
26
23
  import * as sphere from "ol/sphere";
27
24
  import * as extent from "ol/extent";
28
25
  import * as events from "ol/events";
29
26
  import * as eventsCondition from "ol/events/condition";
30
- import Base from "ol/layer/Base";
31
- import { default as default2 } from "ol/layer/Base";
32
- import { defaults } from "ol/control/defaults";
33
- import { defaults as defaults2 } from "ol/control/defaults";
34
- import { defaults as defaults$1 } from "ol/interaction/defaults";
35
- import { defaults as defaults3 } from "ol/interaction/defaults";
27
+ import BaseLayer from "ol/layer/Base";
28
+ import { defaults as defaultControls } from "ol/control/defaults";
29
+ import { defaults as defaultInteractions } from "ol/interaction/defaults";
36
30
  import * as lit from "@eclipse-lyra/core/externals/lit";
37
31
  import { render } from "@eclipse-lyra/core/externals/lit";
38
- import { unsubscribe, publish, subscribe } from "@eclipse-lyra/core/core/events";
32
+ import { publish, subscribe, unsubscribe } from "@eclipse-lyra/core/core/events";
39
33
  import "ol/ol.css";
40
34
  import { v4 as v4$1 } from "uuid";
41
- function _mergeNamespaces(n, m) {
42
- for (var i = 0; i < m.length; i++) {
43
- const e = m[i];
44
- if (typeof e !== "string" && !Array.isArray(e)) {
45
- for (const k in e) {
46
- if (k !== "default" && !(k in n)) {
47
- const d = Object.getOwnPropertyDescriptor(e, k);
48
- if (d) {
49
- Object.defineProperty(n, k, d.get ? d : {
50
- enumerable: true,
51
- get: () => e[k]
52
- });
53
- }
54
- }
55
- }
56
- }
57
- }
58
- return Object.freeze(Object.defineProperty(n, Symbol.toStringTag, { value: "Module" }));
59
- }
60
- const KEY_LABEL = "label";
61
- const KEY_NAME = "name";
62
- const KEY_URL = "url";
63
- const KEY_FORMAT = "format";
64
- const KEY_ICON_PATH = "iconPath";
65
- const KEY_STATE = "_state";
66
- const KEY_SRC = "src";
67
- const KEY_SOURCETYPE = "sourceType";
68
- const KEY_ENV = "_env";
69
- const KEY_GS_MANAGED = "gsManaged";
70
- const KEY_SETTINGS = "settings";
71
- const KEY_UUID = "uuid";
72
- const KEY_EVENT_SUBSCRIPTIONS = "_eventSubscriptions";
73
- const LAYER_GEOCODED_MARKERS = "geocoded-markers";
35
+ export * from "ol";
36
+ //#region \0rolldown/runtime.js
37
+ var __defProp = Object.defineProperty;
38
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
39
+ var __getOwnPropNames = Object.getOwnPropertyNames;
40
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
41
+ var __exportAll = (all, no_symbols) => {
42
+ let target = {};
43
+ for (var name in all) __defProp(target, name, {
44
+ get: all[name],
45
+ enumerable: true
46
+ });
47
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
48
+ return target;
49
+ };
50
+ var __copyProps = (to, from, except, desc) => {
51
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
52
+ key = keys[i];
53
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
54
+ get: ((k) => from[k]).bind(null, key),
55
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
56
+ });
57
+ }
58
+ return to;
59
+ };
60
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
61
+ //#endregion
62
+ //#region src/gs-model.ts
63
+ var KEY_LABEL = "label";
64
+ var KEY_NAME = "name";
65
+ var KEY_URL = "url";
66
+ var KEY_FORMAT = "format";
67
+ var KEY_ICON_PATH = "iconPath";
68
+ var KEY_STATE = "_state";
69
+ var KEY_SRC = "src";
70
+ var KEY_SOURCETYPE = "sourceType";
71
+ var KEY_ENV = "_env";
72
+ var KEY_GS_MANAGED = "gsManaged";
73
+ var KEY_SETTINGS = "settings";
74
+ var KEY_UUID = "uuid";
75
+ var KEY_EVENT_SUBSCRIPTIONS = "_eventSubscriptions";
76
+ var LAYER_GEOCODED_MARKERS = "geocoded-markers";
74
77
  function ensureUuid(obj) {
75
- if (!obj.uuid) {
76
- obj.uuid = v4();
77
- }
78
- return obj;
78
+ if (!obj.uuid) obj.uuid = v4();
79
+ return obj;
79
80
  }
80
81
  function ensureUuidsRecursive(obj) {
81
- ensureUuid(obj);
82
- if ("geometry" in obj && obj.geometry) {
83
- ensureUuid(obj.geometry);
84
- }
85
- if ("source" in obj && obj.source) {
86
- const source2 = obj.source;
87
- ensureUuid(source2);
88
- if (source2.features && Array.isArray(source2.features)) {
89
- source2.features.forEach((feature) => ensureUuidsRecursive(feature));
90
- }
91
- }
92
- if ("layers" in obj && Array.isArray(obj.layers)) {
93
- obj.layers.forEach((layer) => ensureUuidsRecursive(layer));
94
- }
95
- if ("overlays" in obj && Array.isArray(obj.overlays)) {
96
- obj.overlays.forEach((overlay) => ensureUuid(overlay));
97
- }
98
- if ("controls" in obj && Array.isArray(obj.controls)) {
99
- obj.controls.forEach((control) => ensureUuid(control));
100
- }
101
- if ("interactions" in obj && Array.isArray(obj.interactions)) {
102
- obj.interactions.forEach((interaction) => ensureUuid(interaction));
103
- }
104
- if ("view" in obj && obj.view) {
105
- ensureUuid(obj.view);
106
- }
107
- return obj;
82
+ ensureUuid(obj);
83
+ if ("geometry" in obj && obj.geometry) ensureUuid(obj.geometry);
84
+ if ("source" in obj && obj.source) {
85
+ const source = obj.source;
86
+ ensureUuid(source);
87
+ if (source.features && Array.isArray(source.features)) source.features.forEach((feature) => ensureUuidsRecursive(feature));
88
+ }
89
+ if ("layers" in obj && Array.isArray(obj.layers)) obj.layers.forEach((layer) => ensureUuidsRecursive(layer));
90
+ if ("overlays" in obj && Array.isArray(obj.overlays)) obj.overlays.forEach((overlay) => ensureUuid(overlay));
91
+ if ("controls" in obj && Array.isArray(obj.controls)) obj.controls.forEach((control) => ensureUuid(control));
92
+ if ("interactions" in obj && Array.isArray(obj.interactions)) obj.interactions.forEach((interaction) => ensureUuid(interaction));
93
+ if ("view" in obj && obj.view) ensureUuid(obj.view);
94
+ return obj;
108
95
  }
109
- var GsSourceType = /* @__PURE__ */ ((GsSourceType2) => {
110
- GsSourceType2["OSM"] = "OSM";
111
- GsSourceType2["GeoJSON"] = "GeoJSON";
112
- GsSourceType2["Features"] = "Features";
113
- GsSourceType2["KML"] = "KML";
114
- GsSourceType2["GeoTIFF"] = "GeoTIFF";
115
- GsSourceType2["GPX"] = "GPX";
116
- GsSourceType2["BM"] = "BM";
117
- GsSourceType2["WMS"] = "WMS";
118
- GsSourceType2["WMTS"] = "WMTS";
119
- GsSourceType2["XYZ"] = "XYZ";
120
- GsSourceType2["Scripted"] = "Scripted";
121
- return GsSourceType2;
122
- })(GsSourceType || {});
123
- var GsLayerType = /* @__PURE__ */ ((GsLayerType2) => {
124
- GsLayerType2["TILE"] = "TILE";
125
- GsLayerType2["VECTOR"] = "VECTOR";
126
- GsLayerType2["GROUP"] = "GROUP";
127
- GsLayerType2["SCRIPTED"] = "SCRIPTED";
128
- return GsLayerType2;
129
- })(GsLayerType || {});
130
- var GsGeometryType = /* @__PURE__ */ ((GsGeometryType2) => {
131
- GsGeometryType2["Point"] = "Point";
132
- GsGeometryType2["MultiPoint"] = "MultiPoint";
133
- GsGeometryType2["Polygon"] = "Polygon";
134
- GsGeometryType2["MultiPolygon"] = "MultiPolygon";
135
- GsGeometryType2["LineString"] = "LineString";
136
- GsGeometryType2["MultiLineString"] = "MultiLineString";
137
- GsGeometryType2["Circle"] = "Circle";
138
- GsGeometryType2["LinearRing"] = "LinearRing";
139
- return GsGeometryType2;
140
- })(GsGeometryType || {});
141
- const DEFAULT_STYLES = {
142
- "default-point": {
143
- id: "default-point",
144
- image: {
145
- type: "circle",
146
- radius: 5,
147
- fill: { color: "rgba(0, 100, 255, 0.8)" },
148
- stroke: { color: "white", width: 2 }
149
- }
150
- },
151
- "default-line": {
152
- id: "default-line",
153
- stroke: {
154
- color: "rgba(0, 100, 255, 0.8)",
155
- width: 2
156
- }
157
- },
158
- "default-polygon": {
159
- id: "default-polygon",
160
- fill: { color: "rgba(0, 100, 255, 0.3)" },
161
- stroke: {
162
- color: "rgba(0, 100, 255, 0.8)",
163
- width: 2
164
- }
165
- },
166
- "selection": {
167
- id: "selection",
168
- image: {
169
- type: "circle",
170
- radius: 7,
171
- fill: { color: "rgba(255, 255, 0, 0.3)" },
172
- stroke: { color: "rgba(255, 255, 0, 1)", width: 3 }
173
- },
174
- stroke: {
175
- color: "rgba(255, 255, 0, 1)",
176
- width: 3
177
- },
178
- fill: {
179
- color: "rgba(255, 255, 0, 0.3)"
180
- }
181
- }
96
+ var GsSourceType = /* @__PURE__ */ function(GsSourceType) {
97
+ GsSourceType["OSM"] = "OSM";
98
+ GsSourceType["GeoJSON"] = "GeoJSON";
99
+ GsSourceType["Features"] = "Features";
100
+ GsSourceType["KML"] = "KML";
101
+ GsSourceType["GeoTIFF"] = "GeoTIFF";
102
+ GsSourceType["GPX"] = "GPX";
103
+ GsSourceType["BM"] = "BM";
104
+ GsSourceType["WMS"] = "WMS";
105
+ GsSourceType["WMTS"] = "WMTS";
106
+ GsSourceType["XYZ"] = "XYZ";
107
+ GsSourceType["Scripted"] = "Scripted";
108
+ return GsSourceType;
109
+ }({});
110
+ var GsLayerType = /* @__PURE__ */ function(GsLayerType) {
111
+ GsLayerType["TILE"] = "TILE";
112
+ GsLayerType["VECTOR"] = "VECTOR";
113
+ GsLayerType["GROUP"] = "GROUP";
114
+ GsLayerType["SCRIPTED"] = "SCRIPTED";
115
+ return GsLayerType;
116
+ }({});
117
+ var GsGeometryType = /* @__PURE__ */ function(GsGeometryType) {
118
+ GsGeometryType["Point"] = "Point";
119
+ GsGeometryType["MultiPoint"] = "MultiPoint";
120
+ GsGeometryType["Polygon"] = "Polygon";
121
+ GsGeometryType["MultiPolygon"] = "MultiPolygon";
122
+ GsGeometryType["LineString"] = "LineString";
123
+ GsGeometryType["MultiLineString"] = "MultiLineString";
124
+ GsGeometryType["Circle"] = "Circle";
125
+ GsGeometryType["LinearRing"] = "LinearRing";
126
+ return GsGeometryType;
127
+ }({});
128
+ var DEFAULT_STYLES = {
129
+ "default-point": {
130
+ id: "default-point",
131
+ image: {
132
+ type: "circle",
133
+ radius: 5,
134
+ fill: { color: "rgba(0, 100, 255, 0.8)" },
135
+ stroke: {
136
+ color: "white",
137
+ width: 2
138
+ }
139
+ }
140
+ },
141
+ "default-line": {
142
+ id: "default-line",
143
+ stroke: {
144
+ color: "rgba(0, 100, 255, 0.8)",
145
+ width: 2
146
+ }
147
+ },
148
+ "default-polygon": {
149
+ id: "default-polygon",
150
+ fill: { color: "rgba(0, 100, 255, 0.3)" },
151
+ stroke: {
152
+ color: "rgba(0, 100, 255, 0.8)",
153
+ width: 2
154
+ }
155
+ },
156
+ "selection": {
157
+ id: "selection",
158
+ image: {
159
+ type: "circle",
160
+ radius: 7,
161
+ fill: { color: "rgba(255, 255, 0, 0.3)" },
162
+ stroke: {
163
+ color: "rgba(255, 255, 0, 1)",
164
+ width: 3
165
+ }
166
+ },
167
+ stroke: {
168
+ color: "rgba(255, 255, 0, 1)",
169
+ width: 3
170
+ },
171
+ fill: { color: "rgba(255, 255, 0, 0.3)" }
172
+ }
182
173
  };
183
174
  function evaluateStyleRule(rule, feature, layerName) {
184
- const condition = rule.condition;
185
- if (condition.geometryType) {
186
- const types = Array.isArray(condition.geometryType) ? condition.geometryType : [condition.geometryType];
187
- if (!types.includes(feature.geometry.type)) {
188
- return false;
189
- }
190
- }
191
- if (condition.layerName && condition.layerName !== layerName) {
192
- return false;
193
- }
194
- if (condition.property) {
195
- const prop = condition.property;
196
- const featureValue = feature.state?.[prop.key];
197
- if (!prop.operator || prop.operator === "exists") {
198
- return featureValue !== void 0;
199
- }
200
- if (prop.operator === "equals") {
201
- return featureValue === prop.value;
202
- }
203
- if (prop.operator === "not-equals") {
204
- return featureValue !== prop.value;
205
- }
206
- if (prop.operator === "contains" && typeof featureValue === "string" && typeof prop.value === "string") {
207
- return featureValue.includes(prop.value);
208
- }
209
- if (prop.operator === "greater-than" && typeof featureValue === "number" && typeof prop.value === "number") {
210
- return featureValue > prop.value;
211
- }
212
- if (prop.operator === "less-than" && typeof featureValue === "number" && typeof prop.value === "number") {
213
- return featureValue < prop.value;
214
- }
215
- }
216
- return true;
175
+ const condition = rule.condition;
176
+ if (condition.geometryType) {
177
+ if (!(Array.isArray(condition.geometryType) ? condition.geometryType : [condition.geometryType]).includes(feature.geometry.type)) return false;
178
+ }
179
+ if (condition.layerName && condition.layerName !== layerName) return false;
180
+ if (condition.property) {
181
+ const prop = condition.property;
182
+ const featureValue = feature.state?.[prop.key];
183
+ if (!prop.operator || prop.operator === "exists") return featureValue !== void 0;
184
+ if (prop.operator === "equals") return featureValue === prop.value;
185
+ if (prop.operator === "not-equals") return featureValue !== prop.value;
186
+ if (prop.operator === "contains" && typeof featureValue === "string" && typeof prop.value === "string") return featureValue.includes(prop.value);
187
+ if (prop.operator === "greater-than" && typeof featureValue === "number" && typeof prop.value === "number") return featureValue > prop.value;
188
+ if (prop.operator === "less-than" && typeof featureValue === "number" && typeof prop.value === "number") return featureValue < prop.value;
189
+ }
190
+ return true;
217
191
  }
218
192
  function getStyleForFeature(feature, rules, stylesMap, layerName) {
219
- const sortedRules = [...rules].sort((a, b) => (b.priority || 0) - (a.priority || 0));
220
- for (const rule of sortedRules) {
221
- if (evaluateStyleRule(rule, feature, layerName)) {
222
- return stylesMap[rule.styleId];
223
- }
224
- }
225
- return void 0;
193
+ const sortedRules = [...rules].sort((a, b) => (b.priority || 0) - (a.priority || 0));
194
+ for (const rule of sortedRules) if (evaluateStyleRule(rule, feature, layerName)) return stylesMap[rule.styleId];
226
195
  }
227
- const DEFAULT_STYLE_RULES = [
228
- {
229
- id: "default-points",
230
- condition: {
231
- geometryType: [
232
- "Point",
233
- "MultiPoint"
234
- /* MultiPoint */
235
- ]
236
- },
237
- styleId: "default-point",
238
- priority: 0
239
- },
240
- {
241
- id: "default-lines",
242
- condition: {
243
- geometryType: [
244
- "LineString",
245
- "MultiLineString"
246
- /* MultiLineString */
247
- ]
248
- },
249
- styleId: "default-line",
250
- priority: 0
251
- },
252
- {
253
- id: "default-polygons",
254
- condition: {
255
- geometryType: [
256
- "Polygon",
257
- "MultiPolygon",
258
- "Circle"
259
- /* Circle */
260
- ]
261
- },
262
- styleId: "default-polygon",
263
- priority: 0
264
- }
196
+ var DEFAULT_STYLE_RULES = [
197
+ {
198
+ id: "default-points",
199
+ condition: { geometryType: [GsGeometryType.Point, GsGeometryType.MultiPoint] },
200
+ styleId: "default-point",
201
+ priority: 0
202
+ },
203
+ {
204
+ id: "default-lines",
205
+ condition: { geometryType: [GsGeometryType.LineString, GsGeometryType.MultiLineString] },
206
+ styleId: "default-line",
207
+ priority: 0
208
+ },
209
+ {
210
+ id: "default-polygons",
211
+ condition: { geometryType: [
212
+ GsGeometryType.Polygon,
213
+ GsGeometryType.MultiPolygon,
214
+ GsGeometryType.Circle
215
+ ] },
216
+ styleId: "default-polygon",
217
+ priority: 0
218
+ }
265
219
  ];
266
- const DEFAULT_GSMAP = ensureUuid({
267
- view: ensureUuid({
268
- center: [0, 0],
269
- zoom: 0,
270
- projection: "EPSG:3857"
271
- }),
272
- layers: [ensureUuid({
273
- type: "TILE",
274
- source: ensureUuid({
275
- type: "OSM"
276
- /* OSM */
277
- })
278
- })],
279
- overlays: [],
280
- controls: [],
281
- interactions: [],
282
- state: {},
283
- styles: { ...DEFAULT_STYLES },
284
- styleRules: [...DEFAULT_STYLE_RULES]
220
+ var DEFAULT_GSMAP = ensureUuid({
221
+ view: ensureUuid({
222
+ center: [0, 0],
223
+ zoom: 0,
224
+ projection: "EPSG:3857"
225
+ }),
226
+ layers: [ensureUuid({
227
+ type: GsLayerType.TILE,
228
+ source: ensureUuid({ type: GsSourceType.OSM })
229
+ })],
230
+ overlays: [],
231
+ controls: [],
232
+ interactions: [],
233
+ state: {},
234
+ styles: { ...DEFAULT_STYLES },
235
+ styleRules: [...DEFAULT_STYLE_RULES]
285
236
  });
286
- class ScriptedRuntimeRegistryImpl {
287
- constructor() {
288
- this.runtimes = /* @__PURE__ */ new Map();
289
- }
290
- register(lang, runtime) {
291
- this.runtimes.set(lang, runtime);
292
- }
293
- get(lang) {
294
- return this.runtimes.get(lang);
295
- }
296
- }
297
- const scriptedRuntimeRegistry = new ScriptedRuntimeRegistryImpl();
298
- const jsRuntime = {
299
- async run(src, vars) {
300
- const mod = await import(
301
- /* @vite-ignore */
302
- src
303
- );
304
- const fn = mod instanceof Function ? mod : mod.default;
305
- if (typeof fn !== "function") {
306
- throw new Error(`Scripted layer module at "${src}" must export a default function`);
307
- }
308
- return fn(vars);
309
- }
237
+ //#endregion
238
+ //#region src/scripted-runtime-registry.ts
239
+ var ScriptedRuntimeRegistryImpl = class {
240
+ constructor() {
241
+ this.runtimes = /* @__PURE__ */ new Map();
242
+ }
243
+ register(lang, runtime) {
244
+ this.runtimes.set(lang, runtime);
245
+ }
246
+ get(lang) {
247
+ return this.runtimes.get(lang);
248
+ }
310
249
  };
311
- scriptedRuntimeRegistry.register("javascript", jsRuntime);
250
+ var scriptedRuntimeRegistry = new ScriptedRuntimeRegistryImpl();
251
+ scriptedRuntimeRegistry.register("javascript", { async run(src, vars) {
252
+ const mod = await import(
253
+ /* @vite-ignore */
254
+ src
255
+ );
256
+ const fn = mod instanceof Function ? mod : mod.default;
257
+ if (typeof fn !== "function") throw new Error(`Scripted layer module at "${src}" must export a default function`);
258
+ return fn(vars);
259
+ } });
260
+ //#endregion
261
+ //#region src/map-renderer.ts
312
262
  function findLayerByUuid(gsMap, uuid) {
313
- return gsMap.layers.find((layer) => layer.uuid === uuid);
263
+ return gsMap.layers.find((layer) => layer.uuid === uuid);
314
264
  }
315
265
  function findLayerIndexByUuid(gsMap, uuid) {
316
- return gsMap.layers.findIndex((layer) => layer.uuid === uuid);
266
+ return gsMap.layers.findIndex((layer) => layer.uuid === uuid);
317
267
  }
318
268
  function findControlByUuid(gsMap, uuid) {
319
- return gsMap.controls.find((control) => control.uuid === uuid);
269
+ return gsMap.controls.find((control) => control.uuid === uuid);
320
270
  }
321
271
  function findControlIndexByUuid(gsMap, uuid) {
322
- return gsMap.controls.findIndex((control) => control.uuid === uuid);
272
+ return gsMap.controls.findIndex((control) => control.uuid === uuid);
323
273
  }
324
274
  function findOverlayByUuid(gsMap, uuid) {
325
- return gsMap.overlays.find((overlay) => overlay.uuid === uuid);
275
+ return gsMap.overlays.find((overlay) => overlay.uuid === uuid);
326
276
  }
327
277
  function findOverlayIndexByUuid(gsMap, uuid) {
328
- return gsMap.overlays.findIndex((overlay) => overlay.uuid === uuid);
278
+ return gsMap.overlays.findIndex((overlay) => overlay.uuid === uuid);
329
279
  }
330
- const createProxy = (operations) => {
331
- return new Proxy({}, {
332
- get: (_, prop) => {
333
- return async (...args) => {
334
- await Promise.all(
335
- operations.map((operation) => {
336
- const fn = operation[prop];
337
- if (typeof fn === "function") {
338
- return fn.apply(operation, args);
339
- }
340
- return void 0;
341
- })
342
- );
343
- };
344
- }
345
- });
280
+ var createProxy = (operations) => {
281
+ return new Proxy({}, { get: (_, prop) => {
282
+ return async (...args) => {
283
+ await Promise.all(operations.map((operation) => {
284
+ const fn = operation[prop];
285
+ if (typeof fn === "function") return fn.apply(operation, args);
286
+ }));
287
+ };
288
+ } });
346
289
  };
290
+ //#endregion
291
+ //#region src/base-map-builder.ts
292
+ /**
293
+ * Generate the entry point JavaScript code for the map application
294
+ */
347
295
  function generateAppJs(vars) {
348
- const allScripts = [...vars.gsMap.controls || [], ...vars.gsMap.overlays || []];
349
- const scriptPaths = allScripts.map((script) => script.src).filter((src) => src);
350
- const scriptImports = scriptPaths.map((src, index) => {
351
- const escapedSrc = src.replace(/`/g, "\\`").replace(/\$/g, "\\$");
352
- return `import script${index} from '${escapedSrc}'`;
353
- });
354
- const modulesMap = scriptPaths.map((src, index) => {
355
- const escapedSrc = JSON.stringify(src);
356
- return `${escapedSrc}: script${index}`;
357
- }).join(",\n ");
358
- return `
296
+ const scriptPaths = [...vars.gsMap.controls || [], ...vars.gsMap.overlays || []].map((script) => script.src).filter((src) => src);
297
+ const scriptImports = scriptPaths.map((src, index) => {
298
+ return `import script${index} from '${src.replace(/`/g, "\\`").replace(/\$/g, "\\$")}'`;
299
+ });
300
+ const modulesMap = scriptPaths.map((src, index) => {
301
+ return `${JSON.stringify(src)}: script${index}`;
302
+ }).join(",\n ");
303
+ return `
359
304
  import {gsLib} from "${vars.gsLibPath}"
360
305
  import "./gs-lib/gs-lib.css"
361
306
 
@@ -377,1645 +322,1542 @@ export const renderMap = (mapContainerSelector) => {
377
322
  }
378
323
  `;
379
324
  }
325
+ /**
326
+ * Generate precache manifest for Workbox
327
+ */
380
328
  function generatePrecacheManifest(assets) {
381
- return JSON.stringify(assets, null, 2);
329
+ return JSON.stringify(assets, null, 2);
382
330
  }
331
+ /**
332
+ * Process service worker content by injecting precache manifest
333
+ */
383
334
  function processServiceWorker(content, precacheManifest) {
384
- if (precacheManifest) {
385
- const manifestJson = generatePrecacheManifest(precacheManifest);
386
- if (content.includes("self.__WB_MANIFEST")) {
387
- return content.replace(
388
- "self.__WB_MANIFEST || []",
389
- `${manifestJson}`
390
- );
391
- } else {
392
- return content.replace(
393
- /workbox\.precaching\.precacheAndRoute\(/,
394
- `self.__WB_MANIFEST = ${manifestJson};
395
- workbox.precaching.precacheAndRoute(`
396
- );
397
- }
398
- }
399
- return content;
335
+ if (precacheManifest) {
336
+ const manifestJson = generatePrecacheManifest(precacheManifest);
337
+ if (content.includes("self.__WB_MANIFEST")) return content.replace("self.__WB_MANIFEST || []", `${manifestJson}`);
338
+ else return content.replace(/workbox\.precaching\.precacheAndRoute\(/, `self.__WB_MANIFEST = ${manifestJson};\nworkbox.precaching.precacheAndRoute(`);
339
+ }
340
+ return content;
400
341
  }
342
+ /**
343
+ * Process manifest content by updating title and version
344
+ */
401
345
  function processManifest(content, title, version) {
402
- const manifest = JSON.parse(content);
403
- manifest.name = title;
404
- manifest.short_name = title;
405
- manifest.description = title;
406
- manifest.version = version;
407
- return JSON.stringify(manifest, null, 2);
346
+ const manifest = JSON.parse(content);
347
+ manifest.name = title;
348
+ manifest.short_name = title;
349
+ manifest.description = title;
350
+ manifest.version = version;
351
+ return JSON.stringify(manifest, null, 2);
408
352
  }
353
+ /**
354
+ * Process HTML template by replacing title placeholder, app.js reference, and app.css reference
355
+ */
409
356
  function processHtml(content, title, appJsFilename, appCssFilename) {
410
- let processed = content.replace(/\$TITLE/g, title);
411
- if (appJsFilename) {
412
- processed = processed.replace(/\.\/app\.js/g, `./${appJsFilename}`);
413
- }
414
- if (appCssFilename) {
415
- processed = processed.replace(/href=["']app\.css["']/g, `href="${appCssFilename}"`);
416
- }
417
- return processed;
357
+ let processed = content.replace(/\$TITLE/g, title);
358
+ if (appJsFilename) processed = processed.replace(/\.\/app\.js/g, `./${appJsFilename}`);
359
+ if (appCssFilename) processed = processed.replace(/href=["']app\.css["']/g, `href="${appCssFilename}"`);
360
+ return processed;
418
361
  }
419
- async function bundleApp(entryPointPath, outputDir, gsLibPath, fileSys, resolvePlugin, esbuildInstance, progress, currentStep, totalSteps) {
420
- const updateProgress = (message) => {
421
- if (progress) {
422
- if (currentStep !== void 0) {
423
- progress(++currentStep.value, message, totalSteps);
424
- } else {
425
- progress(0, message, totalSteps);
426
- }
427
- }
428
- };
429
- updateProgress("Bundling and minifying code...");
430
- const result = await esbuildInstance.build({
431
- entryPoints: [entryPointPath],
432
- bundle: true,
433
- outdir: outputDir,
434
- format: "esm",
435
- minify: true,
436
- plugins: [resolvePlugin],
437
- entryNames: "[name]-[hash]",
438
- // Runtime dependencies (lit, webawesome) are bundled with gs-lib
439
- external: [],
440
- // Bundle all dependencies
441
- packages: "bundle",
442
- write: false,
443
- // Don't write to disk, we'll handle it
444
- metafile: true
445
- // Generate metafile to get output information
446
- });
447
- updateProgress("Saving bundled output...");
448
- if (!result.outputFiles || result.outputFiles.length === 0) {
449
- throw new Error("No output files generated by esbuild");
450
- }
451
- let mainOutputFile = null;
452
- let cssOutputFile = null;
453
- if (result.metafile && result.metafile.outputs) {
454
- const entryName = "app";
455
- for (const [outputPath, output] of Object.entries(result.metafile.outputs)) {
456
- if (output && typeof output === "object" && "entryPoint" in output) {
457
- if (outputPath.includes(entryName) && outputPath.endsWith(".js")) {
458
- mainOutputFile = outputPath;
459
- } else if (outputPath.endsWith(".css")) {
460
- cssOutputFile = outputPath;
461
- }
462
- }
463
- }
464
- }
465
- const extractFilename = (filePath) => {
466
- const lastSlash = Math.max(filePath.lastIndexOf("/"), filePath.lastIndexOf("\\"));
467
- return lastSlash >= 0 ? filePath.substring(lastSlash + 1) : filePath;
468
- };
469
- for (const file of result.outputFiles) {
470
- let filePath = file.path || "";
471
- let relativePath;
472
- let filename;
473
- if (filePath.startsWith("/") || filePath.length > 2 && filePath[1] === ":") {
474
- filename = extractFilename(filePath);
475
- relativePath = `${outputDir}/${filename}`;
476
- } else {
477
- filename = extractFilename(filePath);
478
- relativePath = filePath.startsWith(outputDir) ? filePath : `${outputDir}/${filePath}`;
479
- }
480
- await fileSys.writeFile(relativePath, file.contents);
481
- if (!mainOutputFile && filename.includes("app-") && filename.endsWith(".js")) {
482
- mainOutputFile = filename;
483
- }
484
- if (!cssOutputFile && filename.includes("app-") && filename.endsWith(".css")) {
485
- cssOutputFile = filename;
486
- }
487
- }
488
- if (!mainOutputFile) {
489
- throw new Error("Could not find main output file");
490
- }
491
- return {
492
- js: extractFilename(mainOutputFile),
493
- css: cssOutputFile ? extractFilename(cssOutputFile) : null
494
- };
362
+ /**
363
+ * Bundle the application code using esbuild with hashed filenames
364
+ * @param esbuildInstance - The esbuild instance to use (esbuild-wasm for browser, esbuild for Node.js)
365
+ * @returns Object with both JS and CSS filenames (CSS may be null if not generated)
366
+ */
367
+ async function bundleApp(entryPointPath, outputDir, _gsLibPath, fileSys, resolvePlugin, esbuildInstance, progress, currentStep, totalSteps) {
368
+ const updateProgress = (message) => {
369
+ if (progress) if (currentStep !== void 0) progress(++currentStep.value, message, totalSteps);
370
+ else progress(0, message, totalSteps);
371
+ };
372
+ updateProgress("Bundling and minifying code...");
373
+ const result = await esbuildInstance.build({
374
+ entryPoints: [entryPointPath],
375
+ bundle: true,
376
+ outdir: outputDir,
377
+ format: "esm",
378
+ minify: true,
379
+ plugins: [resolvePlugin],
380
+ entryNames: "[name]-[hash]",
381
+ external: [],
382
+ packages: "bundle",
383
+ write: false,
384
+ metafile: true
385
+ });
386
+ updateProgress("Saving bundled output...");
387
+ if (!result.outputFiles || result.outputFiles.length === 0) throw new Error("No output files generated by esbuild");
388
+ let mainOutputFile = null;
389
+ let cssOutputFile = null;
390
+ if (result.metafile && result.metafile.outputs) {
391
+ const entryName = "app";
392
+ for (const [outputPath, output] of Object.entries(result.metafile.outputs)) if (output && typeof output === "object" && "entryPoint" in output) {
393
+ if (outputPath.includes(entryName) && outputPath.endsWith(".js")) mainOutputFile = outputPath;
394
+ else if (outputPath.endsWith(".css")) cssOutputFile = outputPath;
395
+ }
396
+ }
397
+ const extractFilename = (filePath) => {
398
+ const lastSlash = Math.max(filePath.lastIndexOf("/"), filePath.lastIndexOf("\\"));
399
+ return lastSlash >= 0 ? filePath.substring(lastSlash + 1) : filePath;
400
+ };
401
+ for (const file of result.outputFiles) {
402
+ let filePath = file.path || "";
403
+ let relativePath;
404
+ let filename;
405
+ if (filePath.startsWith("/") || filePath.length > 2 && filePath[1] === ":") {
406
+ filename = extractFilename(filePath);
407
+ relativePath = `${outputDir}/${filename}`;
408
+ } else {
409
+ filename = extractFilename(filePath);
410
+ relativePath = filePath.startsWith(outputDir) ? filePath : `${outputDir}/${filePath}`;
411
+ }
412
+ await fileSys.writeFile(relativePath, file.contents);
413
+ if (!mainOutputFile && filename.includes("app-") && filename.endsWith(".js")) mainOutputFile = filename;
414
+ if (!cssOutputFile && filename.includes("app-") && filename.endsWith(".css")) cssOutputFile = filename;
415
+ }
416
+ if (!mainOutputFile) throw new Error("Could not find main output file");
417
+ return {
418
+ js: extractFilename(mainOutputFile),
419
+ css: cssOutputFile ? extractFilename(cssOutputFile) : null
420
+ };
495
421
  }
422
+ /**
423
+ * Create a standard GsLibFileCopier that uses FileSystem to read from gs-lib package
424
+ */
496
425
  function createFileSystemGsLibCopier(fs, gsLibPackagePath) {
497
- const copyFile = async (srcPath, destPath, asText, processor) => {
498
- const fullSrcPath = `${gsLibPackagePath}/${srcPath}`;
499
- let content = await fs.readFile(fullSrcPath);
500
- if (asText) {
501
- if (content instanceof Uint8Array) {
502
- content = new TextDecoder().decode(content);
503
- } else {
504
- content = content;
505
- }
506
- if (processor) {
507
- content = await processor(content);
508
- }
509
- }
510
- await fs.writeFile(destPath, content);
511
- };
512
- return {
513
- async copyTextFile(srcPath, destPath, processor) {
514
- await copyFile(srcPath, destPath, true, processor);
515
- },
516
- async copyBinaryFile(srcPath, destPath) {
517
- await copyFile(srcPath, destPath, false);
518
- }
519
- };
426
+ const copyFile = async (srcPath, destPath, asText, processor) => {
427
+ const fullSrcPath = `${gsLibPackagePath}/${srcPath}`;
428
+ let content = await fs.readFile(fullSrcPath);
429
+ if (asText) {
430
+ if (content instanceof Uint8Array) content = new TextDecoder().decode(content);
431
+ else content = content;
432
+ if (processor) content = await processor(content);
433
+ }
434
+ await fs.writeFile(destPath, content);
435
+ };
436
+ return {
437
+ async copyTextFile(srcPath, destPath, processor) {
438
+ await copyFile(srcPath, destPath, true, processor);
439
+ },
440
+ async copyBinaryFile(srcPath, destPath) {
441
+ await copyFile(srcPath, destPath, false);
442
+ }
443
+ };
520
444
  }
445
+ /**
446
+ * Unified build function that works in both browser and Node.js
447
+ * This is the single source of truth for the build process
448
+ */
521
449
  async function buildMap(options, fs, resolvePlugin, esbuildInstance, config = {}, progress) {
522
- const {
523
- outputDir = "dist",
524
- buildDir = "__build",
525
- gsLibPath = `${buildDir}/gs-lib/index.js`,
526
- gsLibPackagePath,
527
- gsLibCopier: providedGsLibCopier,
528
- cleanBeforeBuild = true,
529
- cleanAfterBuild = true,
530
- copyAssets
531
- } = config;
532
- const gsLibCopier = providedGsLibCopier || (gsLibPackagePath ? createFileSystemGsLibCopier(fs, gsLibPackagePath) : null);
533
- if (!gsLibCopier) {
534
- throw new Error("Either gsLibCopier or gsLibPackagePath must be provided");
535
- }
536
- const buildGsLibPath = gsLibPath;
537
- let step = config.startingStep ?? 0;
538
- const totalSteps = config.totalSteps;
539
- const updateProgress = (message) => {
540
- if (progress) progress(++step, message, totalSteps);
541
- };
542
- if (cleanBeforeBuild) {
543
- updateProgress("Cleaning build directories...");
544
- const cleanupPromises = [];
545
- if (fs.deleteDir) {
546
- cleanupPromises.push(
547
- fs.deleteDir(buildDir).catch(() => {
548
- }),
549
- // Ignore errors if directory doesn't exist
550
- fs.deleteDir(outputDir).catch(() => {
551
- })
552
- );
553
- } else {
554
- try {
555
- const nodeFs = await import("fs/promises");
556
- const path = await import("path");
557
- const projectRoot = process.cwd();
558
- cleanupPromises.push(
559
- nodeFs.rm(path.resolve(projectRoot, buildDir), { recursive: true, force: true }).catch(() => {
560
- }),
561
- nodeFs.rm(path.resolve(projectRoot, outputDir), { recursive: true, force: true }).catch(() => {
562
- })
563
- );
564
- } catch {
565
- }
566
- }
567
- await Promise.all(cleanupPromises);
568
- }
569
- updateProgress("Preparing build directories...");
570
- await Promise.all([
571
- fs.ensureDir(`${outputDir}/assets/icons/`),
572
- fs.ensureDir(`${buildDir}/gs-lib/`)
573
- ]);
574
- updateProgress("Copying gs-lib package...");
575
- await Promise.all([
576
- gsLibCopier.copyTextFile("dist/index.js", `${buildDir}/gs-lib/index.js`),
577
- gsLibCopier.copyTextFile("dist/gs-lib.css", `${buildDir}/gs-lib/gs-lib.css`)
578
- ]);
579
- updateProgress("Copying PWA core files...");
580
- await gsLibCopier.copyTextFile("public/pwa/staticwebapp.config.json", `${outputDir}/staticwebapp.config.json`);
581
- updateProgress("Creating manifest file...");
582
- await gsLibCopier.copyTextFile("public/pwa/manifest.json", `${outputDir}/manifest.json`, (content) => processManifest(content, options.title, options.version));
583
- updateProgress("Copying PWA icons...");
584
- const iconFiles = [
585
- "24x24.png",
586
- "48x48.png",
587
- "192x192.png",
588
- "512x512.png",
589
- "icon_24.png",
590
- "icon_48.png",
591
- "icon_192.png",
592
- "icon_512.png"
593
- ];
594
- await Promise.all(iconFiles.map(
595
- (icon) => gsLibCopier.copyBinaryFile(`public/pwa/assets/icons/${icon}`, `${outputDir}/assets/icons/${icon}`)
596
- ));
597
- if (copyAssets) {
598
- updateProgress("Copying workspace assets...");
599
- await copyAssets(fs, outputDir, progress);
600
- }
601
- updateProgress("Generating application code...");
602
- const entryPointContent = generateAppJs({
603
- gsMap: options.gsMap,
604
- gsLibPath: buildGsLibPath,
605
- env: { ...options.env, BUILD_TIME: /* @__PURE__ */ new Date() }
606
- });
607
- await fs.writeFile(`${buildDir}/app.js`, entryPointContent);
608
- const stepRef = { value: step };
609
- const bundleResult = await bundleApp(`${buildDir}/app.js`, outputDir, buildGsLibPath, fs, resolvePlugin, esbuildInstance, progress, stepRef, totalSteps);
610
- step = stepRef.value;
611
- const appJsFilename = bundleResult.js;
612
- const appCssFilename = bundleResult.css;
613
- updateProgress("Generating HTML file...");
614
- await gsLibCopier.copyTextFile("public/index.html", `${outputDir}/index.html`, (content) => processHtml(content, options.title, appJsFilename, appCssFilename || void 0));
615
- const precacheManifest = [
616
- { url: `/${appJsFilename}`, revision: null },
617
- // Hashed filename handles versioning
618
- ...appCssFilename ? [{ url: `/${appCssFilename}`, revision: null }] : [],
619
- // Hashed CSS filename handles versioning
620
- ...iconFiles.map((icon) => ({ url: `/assets/icons/${icon}`, revision: null }))
621
- // Workbox will check file content
622
- ];
623
- updateProgress("Processing service worker...");
624
- await gsLibCopier.copyTextFile(
625
- "public/pwa/sw.js",
626
- `${outputDir}/sw.js`,
627
- (content) => processServiceWorker(content, precacheManifest)
628
- );
629
- if (cleanAfterBuild) {
630
- updateProgress("Cleaning up temporary files...");
631
- if (fs.deleteDir) {
632
- await fs.deleteDir(buildDir);
633
- } else {
634
- try {
635
- const nodeFs = await import("fs/promises");
636
- const path = await import("path");
637
- const fullPath = path.resolve(process.cwd(), buildDir);
638
- await nodeFs.rm(fullPath, { recursive: true, force: true });
639
- } catch (error) {
640
- }
641
- }
642
- }
643
- updateProgress("Build completed!");
644
- }
645
- const ol = /* @__PURE__ */ _mergeNamespaces({
646
- __proto__: null,
647
- BaseLayer: Base,
648
- applyMapboxStyle: apply,
649
- defaultControls: defaults,
650
- defaultInteractions: defaults$1,
651
- events,
652
- eventsCondition,
653
- extent,
654
- format,
655
- geom: olGeom,
656
- interaction: interactionNS,
657
- layer: layerNS,
658
- proj,
659
- source,
660
- sphere,
661
- style
662
- }, [ol$1]);
663
- class GsOlAdapter {
664
- constructor(olObject) {
665
- this.map = olObject.getMap();
666
- this.olObject = olObject;
667
- }
668
- getMap() {
669
- return this.map;
670
- }
671
- getElement() {
672
- return this.olObject.getElement();
673
- }
674
- render(strings) {
675
- if (strings === void 0 && this.templateFunction) {
676
- strings = this.templateFunction();
677
- } else if (strings instanceof Function) {
678
- this.templateFunction = strings;
679
- strings = this.templateFunction();
680
- }
681
- if (strings) {
682
- render(strings, this.getElement());
683
- }
684
- }
685
- onRendered() {
686
- }
687
- style(styleJson) {
688
- const style2 = this.getElement().style;
689
- for (const property in styleJson) {
690
- const value = styleJson[property];
691
- style2.setProperty(property, value);
692
- }
693
- }
450
+ const { outputDir = "dist", buildDir = "__build", gsLibPath = `${buildDir}/gs-lib/index.js`, gsLibPackagePath, gsLibCopier: providedGsLibCopier, cleanBeforeBuild = true, cleanAfterBuild = true, copyAssets } = config;
451
+ const gsLibCopier = providedGsLibCopier || (gsLibPackagePath ? createFileSystemGsLibCopier(fs, gsLibPackagePath) : null);
452
+ if (!gsLibCopier) throw new Error("Either gsLibCopier or gsLibPackagePath must be provided");
453
+ const buildGsLibPath = gsLibPath;
454
+ let step = config.startingStep ?? 0;
455
+ const totalSteps = config.totalSteps;
456
+ const updateProgress = (message) => {
457
+ if (progress) progress(++step, message, totalSteps);
458
+ };
459
+ if (cleanBeforeBuild) {
460
+ updateProgress("Cleaning build directories...");
461
+ const cleanupPromises = [];
462
+ if (fs.deleteDir) cleanupPromises.push(fs.deleteDir(buildDir).catch(() => {}), fs.deleteDir(outputDir).catch(() => {}));
463
+ else try {
464
+ const nodeFs = await import("fs/promises");
465
+ const path = await import("path");
466
+ const projectRoot = process.cwd();
467
+ cleanupPromises.push(nodeFs.rm(path.resolve(projectRoot, buildDir), {
468
+ recursive: true,
469
+ force: true
470
+ }).catch(() => {}), nodeFs.rm(path.resolve(projectRoot, outputDir), {
471
+ recursive: true,
472
+ force: true
473
+ }).catch(() => {}));
474
+ } catch {}
475
+ await Promise.all(cleanupPromises);
476
+ }
477
+ updateProgress("Preparing build directories...");
478
+ await Promise.all([fs.ensureDir(`${outputDir}/assets/icons/`), fs.ensureDir(`${buildDir}/gs-lib/`)]);
479
+ updateProgress("Copying gs-lib package...");
480
+ await Promise.all([gsLibCopier.copyTextFile("dist/index.js", `${buildDir}/gs-lib/index.js`), gsLibCopier.copyTextFile("dist/gs-lib.css", `${buildDir}/gs-lib/gs-lib.css`)]);
481
+ updateProgress("Copying PWA core files...");
482
+ await gsLibCopier.copyTextFile("public/pwa/staticwebapp.config.json", `${outputDir}/staticwebapp.config.json`);
483
+ updateProgress("Creating manifest file...");
484
+ await gsLibCopier.copyTextFile("public/pwa/manifest.json", `${outputDir}/manifest.json`, (content) => processManifest(content, options.title, options.version));
485
+ updateProgress("Copying PWA icons...");
486
+ const iconFiles = [
487
+ "24x24.png",
488
+ "48x48.png",
489
+ "192x192.png",
490
+ "512x512.png",
491
+ "icon_24.png",
492
+ "icon_48.png",
493
+ "icon_192.png",
494
+ "icon_512.png"
495
+ ];
496
+ await Promise.all(iconFiles.map((icon) => gsLibCopier.copyBinaryFile(`public/pwa/assets/icons/${icon}`, `${outputDir}/assets/icons/${icon}`)));
497
+ if (copyAssets) {
498
+ updateProgress("Copying workspace assets...");
499
+ await copyAssets(fs, outputDir, progress);
500
+ }
501
+ updateProgress("Generating application code...");
502
+ const entryPointContent = generateAppJs({
503
+ gsMap: options.gsMap,
504
+ gsLibPath: buildGsLibPath,
505
+ env: {
506
+ ...options.env,
507
+ BUILD_TIME: /* @__PURE__ */ new Date()
508
+ }
509
+ });
510
+ await fs.writeFile(`${buildDir}/app.js`, entryPointContent);
511
+ const stepRef = { value: step };
512
+ const bundleResult = await bundleApp(`${buildDir}/app.js`, outputDir, buildGsLibPath, fs, resolvePlugin, esbuildInstance, progress, stepRef, totalSteps);
513
+ step = stepRef.value;
514
+ const appJsFilename = bundleResult.js;
515
+ const appCssFilename = bundleResult.css;
516
+ updateProgress("Generating HTML file...");
517
+ await gsLibCopier.copyTextFile("public/index.html", `${outputDir}/index.html`, (content) => processHtml(content, options.title, appJsFilename, appCssFilename || void 0));
518
+ const precacheManifest = [
519
+ {
520
+ url: `/${appJsFilename}`,
521
+ revision: null
522
+ },
523
+ ...appCssFilename ? [{
524
+ url: `/${appCssFilename}`,
525
+ revision: null
526
+ }] : [],
527
+ ...iconFiles.map((icon) => ({
528
+ url: `/assets/icons/${icon}`,
529
+ revision: null
530
+ }))
531
+ ];
532
+ updateProgress("Processing service worker...");
533
+ await gsLibCopier.copyTextFile("public/pwa/sw.js", `${outputDir}/sw.js`, (content) => processServiceWorker(content, precacheManifest));
534
+ if (cleanAfterBuild) {
535
+ updateProgress("Cleaning up temporary files...");
536
+ if (fs.deleteDir) await fs.deleteDir(buildDir);
537
+ else try {
538
+ const nodeFs = await import("fs/promises");
539
+ const fullPath = (await import("path")).resolve(process.cwd(), buildDir);
540
+ await nodeFs.rm(fullPath, {
541
+ recursive: true,
542
+ force: true
543
+ });
544
+ } catch (error) {}
545
+ }
546
+ updateProgress("Build completed!");
694
547
  }
695
- class GsControlAdapter extends GsOlAdapter {
696
- style(styleJson) {
697
- super.style(styleJson);
698
- if ("--gs-contribution" in styleJson) {
699
- this.retargetSelector = styleJson["--gs-contribution"];
700
- }
701
- }
702
- rendered() {
703
- if (this.retargetSelector) {
704
- const [parentPath, queryString] = this.retargetSelector.split("?");
705
- const parent = this.map.getTargetElement().querySelector(parentPath);
706
- if (parent) {
707
- const element = this.olObject.getElement();
708
- if (queryString) {
709
- const params = new URLSearchParams(queryString);
710
- const sibling = parent.querySelector(`[name='${params.get("before")}']`);
711
- if (sibling) {
712
- parent.insertBefore(element, sibling);
713
- }
714
- } else {
715
- parent.appendChild(element);
716
- }
717
- this.olObject.setTarget(element);
718
- this.render();
719
- }
720
- }
721
- }
722
- }
723
- class GsOverlayAdapter extends GsOlAdapter {
724
- show(coords) {
725
- this.getElement().style.display = "block";
726
- this.olObject.setPosition(coords);
727
- }
728
- hide() {
729
- this.getElement().style.display = "none";
730
- }
731
- }
732
- const withState = (state, olObject) => {
733
- if (state.uuid) {
734
- olObject.set(KEY_UUID, state.uuid);
735
- }
736
- if (state.state) {
737
- for (let stateKey in state.state) {
738
- olObject.set(stateKey, state.state[stateKey]);
739
- }
740
- olObject.set(KEY_STATE, state.state);
741
- }
742
- return olObject;
548
+ //#endregion
549
+ //#region src/ol/gs-olns.ts
550
+ var gs_olns_exports = /* @__PURE__ */ __exportAll({
551
+ BaseLayer: () => BaseLayer,
552
+ applyMapboxStyle: () => applyMapboxStyle,
553
+ defaultControls: () => defaultControls,
554
+ defaultInteractions: () => defaultInteractions,
555
+ events: () => events,
556
+ eventsCondition: () => eventsCondition,
557
+ extent: () => extent,
558
+ format: () => format,
559
+ geom: () => geom,
560
+ interaction: () => interaction,
561
+ layer: () => layer,
562
+ proj: () => proj,
563
+ source: () => source,
564
+ sphere: () => sphere,
565
+ style: () => style
566
+ });
567
+ import * as import_ol from "ol";
568
+ __reExport(gs_olns_exports, import_ol);
569
+ //#endregion
570
+ //#region src/ol/gs-ol-adapters.ts
571
+ var GsOlAdapter = class {
572
+ constructor(olObject) {
573
+ this.map = olObject.getMap();
574
+ this.olObject = olObject;
575
+ }
576
+ getMap() {
577
+ return this.map;
578
+ }
579
+ getElement() {
580
+ return this.olObject.getElement();
581
+ }
582
+ render(strings) {
583
+ if (strings === void 0 && this.templateFunction) strings = this.templateFunction();
584
+ else if (strings instanceof Function) {
585
+ this.templateFunction = strings;
586
+ strings = this.templateFunction();
587
+ }
588
+ if (strings) render(strings, this.getElement());
589
+ }
590
+ onRendered() {}
591
+ style(styleJson) {
592
+ const style = this.getElement().style;
593
+ for (const property in styleJson) {
594
+ const value = styleJson[property];
595
+ style.setProperty(property, value);
596
+ }
597
+ }
743
598
  };
744
- const toOLGeometry = (geometry) => {
745
- return withState(geometry, new olGeom[geometry.type](geometry.coordinates));
599
+ var GsControlAdapter = class extends GsOlAdapter {
600
+ style(styleJson) {
601
+ super.style(styleJson);
602
+ if ("--gs-contribution" in styleJson) this.retargetSelector = styleJson["--gs-contribution"];
603
+ }
604
+ rendered() {
605
+ if (this.retargetSelector) {
606
+ const [parentPath, queryString] = this.retargetSelector.split("?");
607
+ const parent = this.map.getTargetElement().querySelector(parentPath);
608
+ if (parent) {
609
+ const element = this.olObject.getElement();
610
+ if (queryString) {
611
+ const params = new URLSearchParams(queryString);
612
+ const sibling = parent.querySelector(`[name='${params.get("before")}']`);
613
+ if (sibling) parent.insertBefore(element, sibling);
614
+ } else parent.appendChild(element);
615
+ this.olObject.setTarget(element);
616
+ this.render();
617
+ }
618
+ }
619
+ }
746
620
  };
747
- const toOlResource = (resource) => {
748
- return new Icon({
749
- src: resource.src
750
- });
621
+ var GsOverlayAdapter = class extends GsOlAdapter {
622
+ show(coords) {
623
+ this.getElement().style.display = "block";
624
+ this.olObject.setPosition(coords);
625
+ }
626
+ hide() {
627
+ this.getElement().style.display = "none";
628
+ }
751
629
  };
752
- const toOlStroke = (gsStroke) => {
753
- return new Stroke({
754
- color: gsStroke.color,
755
- width: gsStroke.width,
756
- lineDash: gsStroke.lineDash,
757
- lineCap: gsStroke.lineCap,
758
- lineJoin: gsStroke.lineJoin,
759
- miterLimit: gsStroke.miterLimit
760
- });
630
+ //#endregion
631
+ //#region src/ol/gs-gs2ol.ts
632
+ var withState = (state, olObject) => {
633
+ if (state.uuid) olObject.set(KEY_UUID, state.uuid);
634
+ if (state.state) {
635
+ for (let stateKey in state.state) olObject.set(stateKey, state.state[stateKey]);
636
+ olObject.set(KEY_STATE, state.state);
637
+ }
638
+ return olObject;
761
639
  };
762
- const toOlFill = (gsFill) => {
763
- return new Fill({
764
- color: gsFill.color
765
- });
640
+ var toOLGeometry = (geometry) => {
641
+ return withState(geometry, new geom[geometry.type](geometry.coordinates));
766
642
  };
767
- const toOlCircleImage = (gsImage) => {
768
- return new Circle({
769
- radius: gsImage.radius || 5,
770
- fill: gsImage.fill ? toOlFill(gsImage.fill) : void 0,
771
- stroke: gsImage.stroke ? toOlStroke(gsImage.stroke) : void 0,
772
- displacement: gsImage.displacement,
773
- scale: gsImage.scale,
774
- rotation: gsImage.rotation,
775
- rotateWithView: gsImage.rotateWithView,
776
- declutterMode: void 0
777
- });
643
+ var toOlResource = (resource) => {
644
+ return new Icon({ src: resource.src });
778
645
  };
779
- const toOlIconImage = (gsImage) => {
780
- if (!gsImage.src) {
781
- throw new Error("Icon image requires src property");
782
- }
783
- return new Icon({
784
- src: gsImage.src,
785
- anchor: gsImage.anchor || [0.5, 1],
786
- anchorXUnits: gsImage.anchorXUnits || "fraction",
787
- anchorYUnits: gsImage.anchorYUnits || "fraction",
788
- anchorOrigin: gsImage.anchorOrigin,
789
- scale: gsImage.scale || 1,
790
- opacity: gsImage.opacity,
791
- rotation: gsImage.rotation,
792
- rotateWithView: gsImage.rotateWithView,
793
- displacement: gsImage.displacement,
794
- offset: gsImage.offset,
795
- offsetOrigin: gsImage.offsetOrigin,
796
- size: gsImage.size,
797
- color: gsImage.color,
798
- crossOrigin: gsImage.crossOrigin,
799
- declutterMode: void 0
800
- });
646
+ var toOlStroke = (gsStroke) => {
647
+ return new Stroke({
648
+ color: gsStroke.color,
649
+ width: gsStroke.width,
650
+ lineDash: gsStroke.lineDash,
651
+ lineCap: gsStroke.lineCap,
652
+ lineJoin: gsStroke.lineJoin,
653
+ miterLimit: gsStroke.miterLimit
654
+ });
801
655
  };
802
- const toOlRegularShapeImage = (gsImage) => {
803
- return new RegularShape({
804
- points: gsImage.points || 3,
805
- radius: gsImage.radius || gsImage.radius1 || 5,
806
- radius2: gsImage.radius2,
807
- angle: gsImage.angle || 0,
808
- displacement: gsImage.displacement,
809
- fill: gsImage.fill ? toOlFill(gsImage.fill) : void 0,
810
- stroke: gsImage.stroke ? toOlStroke(gsImage.stroke) : void 0,
811
- rotation: gsImage.rotation,
812
- rotateWithView: gsImage.rotateWithView,
813
- scale: gsImage.scale,
814
- declutterMode: void 0
815
- });
656
+ var toOlFill = (gsFill) => {
657
+ return new Fill({ color: gsFill.color });
816
658
  };
817
- const toOlImage = (gsImage) => {
818
- switch (gsImage.type) {
819
- case "circle":
820
- return toOlCircleImage(gsImage);
821
- case "icon":
822
- return toOlIconImage(gsImage);
823
- case "regular-shape":
824
- return toOlRegularShapeImage(gsImage);
825
- default:
826
- throw new Error(`Unknown image type: ${gsImage.type}`);
827
- }
659
+ var toOlCircleImage = (gsImage) => {
660
+ return new Circle({
661
+ radius: gsImage.radius || 5,
662
+ fill: gsImage.fill ? toOlFill(gsImage.fill) : void 0,
663
+ stroke: gsImage.stroke ? toOlStroke(gsImage.stroke) : void 0,
664
+ displacement: gsImage.displacement,
665
+ scale: gsImage.scale,
666
+ rotation: gsImage.rotation,
667
+ rotateWithView: gsImage.rotateWithView,
668
+ declutterMode: void 0
669
+ });
828
670
  };
829
- const toOlText = (gsText) => {
830
- return new Text({
831
- text: gsText.text,
832
- font: gsText.font,
833
- maxAngle: gsText.maxAngle,
834
- offsetX: gsText.offsetX,
835
- offsetY: gsText.offsetY,
836
- overflow: gsText.overflow,
837
- placement: gsText.placement,
838
- repeat: gsText.repeat,
839
- scale: gsText.scale,
840
- rotateWithView: gsText.rotateWithView,
841
- rotation: gsText.rotation,
842
- textAlign: gsText.textAlign,
843
- justify: gsText.justify,
844
- textBaseline: gsText.textBaseline,
845
- fill: gsText.fill ? toOlFill(gsText.fill) : void 0,
846
- stroke: gsText.stroke ? toOlStroke(gsText.stroke) : void 0,
847
- backgroundFill: gsText.backgroundFill ? toOlFill(gsText.backgroundFill) : void 0,
848
- backgroundStroke: gsText.backgroundStroke ? toOlStroke(gsText.backgroundStroke) : void 0,
849
- padding: gsText.padding,
850
- declutterMode: void 0
851
- });
671
+ var toOlIconImage = (gsImage) => {
672
+ if (!gsImage.src) throw new Error("Icon image requires src property");
673
+ return new Icon({
674
+ src: gsImage.src,
675
+ anchor: gsImage.anchor || [.5, 1],
676
+ anchorXUnits: gsImage.anchorXUnits || "fraction",
677
+ anchorYUnits: gsImage.anchorYUnits || "fraction",
678
+ anchorOrigin: gsImage.anchorOrigin,
679
+ scale: gsImage.scale || 1,
680
+ opacity: gsImage.opacity,
681
+ rotation: gsImage.rotation,
682
+ rotateWithView: gsImage.rotateWithView,
683
+ displacement: gsImage.displacement,
684
+ offset: gsImage.offset,
685
+ offsetOrigin: gsImage.offsetOrigin,
686
+ size: gsImage.size,
687
+ color: gsImage.color,
688
+ crossOrigin: gsImage.crossOrigin,
689
+ declutterMode: void 0
690
+ });
852
691
  };
853
- const toOlStyle = (gsStyle) => {
854
- const styleOptions = {};
855
- if (gsStyle.stroke) {
856
- styleOptions.stroke = toOlStroke(gsStyle.stroke);
857
- }
858
- if (gsStyle.fill) {
859
- styleOptions.fill = toOlFill(gsStyle.fill);
860
- }
861
- if (gsStyle.image) {
862
- styleOptions.image = toOlImage(gsStyle.image);
863
- }
864
- if (gsStyle.text) {
865
- styleOptions.text = toOlText(gsStyle.text);
866
- }
867
- if (gsStyle.zIndex !== void 0) {
868
- styleOptions.zIndex = gsStyle.zIndex;
869
- }
870
- return new Style(styleOptions);
692
+ var toOlRegularShapeImage = (gsImage) => {
693
+ return new RegularShape({
694
+ points: gsImage.points || 3,
695
+ radius: gsImage.radius || gsImage.radius1 || 5,
696
+ radius2: gsImage.radius2,
697
+ angle: gsImage.angle || 0,
698
+ displacement: gsImage.displacement,
699
+ fill: gsImage.fill ? toOlFill(gsImage.fill) : void 0,
700
+ stroke: gsImage.stroke ? toOlStroke(gsImage.stroke) : void 0,
701
+ rotation: gsImage.rotation,
702
+ rotateWithView: gsImage.rotateWithView,
703
+ scale: gsImage.scale,
704
+ declutterMode: void 0
705
+ });
871
706
  };
872
- const toOlFeature = (feature) => {
873
- return withState(feature, new Feature({
874
- geometry: toOLGeometry(feature.geometry)
875
- }));
707
+ var toOlImage = (gsImage) => {
708
+ switch (gsImage.type) {
709
+ case "circle": return toOlCircleImage(gsImage);
710
+ case "icon": return toOlIconImage(gsImage);
711
+ case "regular-shape": return toOlRegularShapeImage(gsImage);
712
+ default: throw new Error(`Unknown image type: ${gsImage.type}`);
713
+ }
876
714
  };
877
- const OL_SOURCES = {};
878
- OL_SOURCES[GsSourceType.OSM] = (source2) => {
879
- const olSource = new OSM();
880
- olSource.set(KEY_LABEL, source2.type);
881
- return olSource;
715
+ var toOlText = (gsText) => {
716
+ return new Text({
717
+ text: gsText.text,
718
+ font: gsText.font,
719
+ maxAngle: gsText.maxAngle,
720
+ offsetX: gsText.offsetX,
721
+ offsetY: gsText.offsetY,
722
+ overflow: gsText.overflow,
723
+ placement: gsText.placement,
724
+ repeat: gsText.repeat,
725
+ scale: gsText.scale,
726
+ rotateWithView: gsText.rotateWithView,
727
+ rotation: gsText.rotation,
728
+ textAlign: gsText.textAlign,
729
+ justify: gsText.justify,
730
+ textBaseline: gsText.textBaseline,
731
+ fill: gsText.fill ? toOlFill(gsText.fill) : void 0,
732
+ stroke: gsText.stroke ? toOlStroke(gsText.stroke) : void 0,
733
+ backgroundFill: gsText.backgroundFill ? toOlFill(gsText.backgroundFill) : void 0,
734
+ backgroundStroke: gsText.backgroundStroke ? toOlStroke(gsText.backgroundStroke) : void 0,
735
+ padding: gsText.padding,
736
+ declutterMode: void 0
737
+ });
882
738
  };
883
- OL_SOURCES[GsSourceType.XYZ] = (source2) => {
884
- const olSource = new XYZ({
885
- url: source2.url,
886
- crossOrigin: "anonymous"
887
- });
888
- olSource.set(KEY_URL, source2.url);
889
- olSource.set(KEY_LABEL, `${source2.type}@${source2.url}`);
890
- return olSource;
739
+ var toOlStyle = (gsStyle) => {
740
+ const styleOptions = {};
741
+ if (gsStyle.stroke) styleOptions.stroke = toOlStroke(gsStyle.stroke);
742
+ if (gsStyle.fill) styleOptions.fill = toOlFill(gsStyle.fill);
743
+ if (gsStyle.image) styleOptions.image = toOlImage(gsStyle.image);
744
+ if (gsStyle.text) styleOptions.text = toOlText(gsStyle.text);
745
+ if (gsStyle.zIndex !== void 0) styleOptions.zIndex = gsStyle.zIndex;
746
+ return new Style(styleOptions);
891
747
  };
892
- OL_SOURCES[GsSourceType.WMS] = (source2) => {
893
- const olSource = new TileWMS({
894
- url: source2.url,
895
- params: {
896
- "LAYERS": "",
897
- // Will be overridden by source.state
898
- ...source2.state || {}
899
- },
900
- crossOrigin: "anonymous"
901
- // Required for COEP, same as OSM default
902
- });
903
- olSource.set(KEY_URL, source2.url);
904
- olSource.set(KEY_LABEL, `${source2.type}@${source2.url}`);
905
- return olSource;
748
+ var toOlFeature = (feature) => {
749
+ return withState(feature, new Feature({ geometry: toOLGeometry(feature.geometry) }));
906
750
  };
907
- OL_SOURCES[GsSourceType.WMTS] = (source2, olLayer) => {
908
- const state = source2.state || {};
909
- const parser = new WMTSCapabilities();
910
- const olSource = new WMTS({
911
- url: source2.url,
912
- layer: state["LAYER"] || "",
913
- matrixSet: state["MATRIXSET"] || "GLOBAL_WEBMERCATOR",
914
- style: state["STYLE"] || "default",
915
- crossOrigin: "anonymous"
916
- });
917
- fetch(source2.url).then((response) => response.text()).then((text) => {
918
- const result = parser.read(text);
919
- const options = optionsFromCapabilities(result, {
920
- layer: state["LAYER"] || "",
921
- matrixSet: state["MATRIXSET"] || "GLOBAL_WEBMERCATOR"
922
- });
923
- if (options) {
924
- const newSource = new WMTS({
925
- ...options,
926
- crossOrigin: "anonymous"
927
- });
928
- newSource.set(KEY_URL, source2.url);
929
- newSource.set(KEY_LABEL, `${source2.type}@${source2.url}`);
930
- if (olLayer && olLayer.setSource) {
931
- olLayer.setSource(newSource);
932
- }
933
- }
934
- }).catch((error) => {
935
- console.error("Failed to fetch WMTS capabilities:", error);
936
- });
937
- olSource.set(KEY_URL, source2.url);
938
- olSource.set(KEY_LABEL, `${source2.type}@${source2.url}`);
939
- return olSource;
751
+ var OL_SOURCES = {};
752
+ OL_SOURCES[GsSourceType.OSM] = (source) => {
753
+ const olSource = new OSM();
754
+ olSource.set(KEY_LABEL, source.type);
755
+ return olSource;
940
756
  };
941
- const formatSource = (source2, format2) => {
942
- const olSource = new VectorSource({
943
- format: format2,
944
- url: source2.url
945
- });
946
- olSource.set(KEY_FORMAT, source2.type);
947
- olSource.set(KEY_URL, source2.url);
948
- olSource.set(KEY_LABEL, `${source2.type}@${source2.url}`);
949
- return olSource;
757
+ OL_SOURCES[GsSourceType.XYZ] = (source) => {
758
+ const olSource = new XYZ({
759
+ url: source.url,
760
+ crossOrigin: "anonymous"
761
+ });
762
+ olSource.set("url", source.url);
763
+ olSource.set(KEY_LABEL, `${source.type}@${source.url}`);
764
+ return olSource;
950
765
  };
951
- OL_SOURCES[GsSourceType.GeoJSON] = (source2) => {
952
- return formatSource(source2, new GeoJSON());
766
+ OL_SOURCES[GsSourceType.WMS] = (source) => {
767
+ const olSource = new TileWMS({
768
+ url: source.url,
769
+ params: {
770
+ "LAYERS": "",
771
+ ...source.state || {}
772
+ },
773
+ crossOrigin: "anonymous"
774
+ });
775
+ olSource.set("url", source.url);
776
+ olSource.set(KEY_LABEL, `${source.type}@${source.url}`);
777
+ return olSource;
953
778
  };
954
- OL_SOURCES[GsSourceType.GPX] = (source2) => {
955
- return formatSource(source2, new GPX());
779
+ OL_SOURCES[GsSourceType.WMTS] = (source, olLayer) => {
780
+ const state = source.state || {};
781
+ const parser = new WMTSCapabilities();
782
+ const olSource = new WMTS({
783
+ url: source.url,
784
+ layer: state["LAYER"] || "",
785
+ matrixSet: state["MATRIXSET"] || "GLOBAL_WEBMERCATOR",
786
+ style: state["STYLE"] || "default",
787
+ crossOrigin: "anonymous"
788
+ });
789
+ fetch(source.url).then((response) => response.text()).then((text) => {
790
+ const options = optionsFromCapabilities(parser.read(text), {
791
+ layer: state["LAYER"] || "",
792
+ matrixSet: state["MATRIXSET"] || "GLOBAL_WEBMERCATOR"
793
+ });
794
+ if (options) {
795
+ const newSource = new WMTS({
796
+ ...options,
797
+ crossOrigin: "anonymous"
798
+ });
799
+ newSource.set("url", source.url);
800
+ newSource.set(KEY_LABEL, `${source.type}@${source.url}`);
801
+ if (olLayer && olLayer.setSource) olLayer.setSource(newSource);
802
+ }
803
+ }).catch((error) => {
804
+ console.error("Failed to fetch WMTS capabilities:", error);
805
+ });
806
+ olSource.set("url", source.url);
807
+ olSource.set(KEY_LABEL, `${source.type}@${source.url}`);
808
+ return olSource;
956
809
  };
957
- OL_SOURCES[GsSourceType.GeoTIFF] = (source2) => {
958
- const olSource = new GeoTIFF({
959
- sources: [
960
- {
961
- url: source2.url
962
- }
963
- ]
964
- });
965
- olSource.set(KEY_URL, source2.url);
966
- olSource.set(KEY_LABEL, `${source2.type}@${source2.url}`);
967
- return olSource;
810
+ var formatSource = (source, format) => {
811
+ const olSource = new VectorSource({
812
+ format,
813
+ url: source.url
814
+ });
815
+ olSource.set(KEY_FORMAT, source.type);
816
+ olSource.set("url", source.url);
817
+ olSource.set(KEY_LABEL, `${source.type}@${source.url}`);
818
+ return olSource;
968
819
  };
969
- OL_SOURCES[GsSourceType.Features] = (source2) => {
970
- const features = (source2.features || []).map((feature) => toOlFeature(feature));
971
- const olSource = new VectorSource({
972
- features
973
- });
974
- olSource.set(KEY_LABEL, source2.type);
975
- return olSource;
820
+ OL_SOURCES[GsSourceType.GeoJSON] = (source) => {
821
+ return formatSource(source, new GeoJSON());
976
822
  };
977
- const toOlSource = (source2, olLayer) => {
978
- return withState(source2, OL_SOURCES[source2.type](source2, olLayer));
823
+ OL_SOURCES[GsSourceType.GPX] = (source) => {
824
+ return formatSource(source, new GPX());
979
825
  };
980
- const resolveScriptLang = (src, lang) => {
981
- if (lang) return lang;
982
- const ext = src.split("?")[0].split(".").pop()?.toLowerCase() ?? "";
983
- if (ext === "py") return "python";
984
- return "javascript";
826
+ OL_SOURCES[GsSourceType.GeoTIFF] = (source) => {
827
+ const olSource = new GeoTIFF({ sources: [{ url: source.url }] });
828
+ olSource.set("url", source.url);
829
+ olSource.set(KEY_LABEL, `${source.type}@${source.url}`);
830
+ return olSource;
985
831
  };
986
- const OL_LAYERS = {};
832
+ OL_SOURCES[GsSourceType.Features] = (source) => {
833
+ const olSource = new VectorSource({ features: (source.features || []).map((feature) => toOlFeature(feature)) });
834
+ olSource.set(KEY_LABEL, source.type);
835
+ return olSource;
836
+ };
837
+ var toOlSource = (source, olLayer) => {
838
+ return withState(source, OL_SOURCES[source.type](source, olLayer));
839
+ };
840
+ var resolveScriptLang = (src, lang) => {
841
+ if (lang) return lang;
842
+ if ((src.split("?")[0].split(".").pop()?.toLowerCase() ?? "") === "py") return "python";
843
+ return "javascript";
844
+ };
845
+ var OL_LAYERS = {};
987
846
  OL_LAYERS[GsLayerType.TILE] = (layer) => {
988
- const tileLayer = new TileLayer();
989
- const source2 = toOlSource(layer.source, tileLayer);
990
- tileLayer.setSource(source2);
991
- return tileLayer;
847
+ const tileLayer = new TileLayer();
848
+ const source = toOlSource(layer.source, tileLayer);
849
+ tileLayer.setSource(source);
850
+ return tileLayer;
992
851
  };
993
852
  OL_LAYERS[GsLayerType.VECTOR] = (layer) => {
994
- return new VectorLayer({
995
- source: toOlSource(layer.source)
996
- });
853
+ return new VectorLayer({ source: toOlSource(layer.source) });
997
854
  };
998
855
  OL_LAYERS[GsLayerType.GROUP] = (layer) => {
999
- const group = new LayerGroup();
1000
- group.set(KEY_URL, layer.source.url);
1001
- group.set(KEY_SOURCETYPE, layer.source.type);
1002
- apply(group, layer.source.url).then();
1003
- return group;
856
+ const group = new LayerGroup();
857
+ group.set("url", layer.source.url);
858
+ group.set(KEY_SOURCETYPE, layer.source.type);
859
+ apply(group, layer.source.url).then();
860
+ return group;
1004
861
  };
1005
862
  OL_LAYERS[GsLayerType.SCRIPTED] = (layer, env) => {
1006
- const src = layer.source.url;
1007
- const lang = resolveScriptLang(src, layer.lang);
1008
- const runtime = scriptedRuntimeRegistry.get(lang);
1009
- if (!runtime) throw new Error(`No scripted runtime registered for lang "${lang}"`);
1010
- let olVectorLayer;
1011
- const source2 = new VectorSource({
1012
- loader: async (extent2, resolution, projection, success, failure) => {
1013
- const view = olVectorLayer?.getMapInternal()?.getView();
1014
- const vars = {
1015
- params: layer.params ?? {},
1016
- env: env ?? {},
1017
- viewState: {
1018
- extent: transformExtent(extent2, projection, "EPSG:4326"),
1019
- zoom: view?.getZoomForResolution(resolution) ?? 0,
1020
- projection: "EPSG:4326"
1021
- }
1022
- };
1023
- try {
1024
- const result = await runtime.run(src, vars);
1025
- const format2 = new GeoJSON();
1026
- source2.clear();
1027
- const allFeatures = [];
1028
- const readBatch = (data) => {
1029
- const features = format2.readFeatures(data, {
1030
- dataProjection: "EPSG:4326",
1031
- featureProjection: projection
1032
- });
1033
- source2.addFeatures(features);
1034
- allFeatures.push(...features);
1035
- };
1036
- if (result && typeof result[Symbol.asyncIterator] === "function") {
1037
- for await (const batch of result) {
1038
- readBatch(batch);
1039
- }
1040
- } else {
1041
- readBatch(result);
1042
- }
1043
- success(allFeatures);
1044
- } catch (e) {
1045
- console.error("Scripted layer error:", e);
1046
- failure();
1047
- }
1048
- },
1049
- strategy: bbox
1050
- });
1051
- olVectorLayer = new VectorLayer({ source: source2 });
1052
- return olVectorLayer;
863
+ const src = layer.source.url;
864
+ const lang = resolveScriptLang(src, layer.lang);
865
+ const runtime = scriptedRuntimeRegistry.get(lang);
866
+ if (!runtime) throw new Error(`No scripted runtime registered for lang "${lang}"`);
867
+ let olVectorLayer;
868
+ const source = new VectorSource({
869
+ loader: async (extent, resolution, projection, success, failure) => {
870
+ const view = olVectorLayer?.getMapInternal()?.getView();
871
+ const vars = {
872
+ params: layer.params ?? {},
873
+ env: env ?? {},
874
+ viewState: {
875
+ extent: transformExtent(extent, projection, "EPSG:4326"),
876
+ zoom: view?.getZoomForResolution(resolution) ?? 0,
877
+ projection: "EPSG:4326"
878
+ }
879
+ };
880
+ try {
881
+ const result = await runtime.run(src, vars);
882
+ const format = new GeoJSON();
883
+ source.clear();
884
+ const allFeatures = [];
885
+ const readBatch = (data) => {
886
+ const features = format.readFeatures(data, {
887
+ dataProjection: "EPSG:4326",
888
+ featureProjection: projection
889
+ });
890
+ source.addFeatures(features);
891
+ allFeatures.push(...features);
892
+ };
893
+ if (result && typeof result[Symbol.asyncIterator] === "function") for await (const batch of result) readBatch(batch);
894
+ else readBatch(result);
895
+ success(allFeatures);
896
+ } catch (e) {
897
+ console.error("Scripted layer error:", e);
898
+ failure();
899
+ }
900
+ },
901
+ strategy: bbox
902
+ });
903
+ olVectorLayer = new VectorLayer({ source });
904
+ return olVectorLayer;
1053
905
  };
1054
- const toOlLayer = (layer, env) => {
1055
- const olLayer = withState(layer, OL_LAYERS[layer.type](layer, env));
1056
- olLayer.set(KEY_LABEL, layer.type);
1057
- olLayer.set(KEY_NAME, layer.name);
1058
- olLayer.set(KEY_GS_MANAGED, true);
1059
- olLayer.setVisible(layer.visible ?? true);
1060
- return olLayer;
906
+ var toOlLayer = (layer, env) => {
907
+ const olLayer = withState(layer, OL_LAYERS[layer.type](layer, env));
908
+ olLayer.set(KEY_LABEL, layer.type);
909
+ olLayer.set(KEY_NAME, layer.name);
910
+ olLayer.set(KEY_GS_MANAGED, true);
911
+ olLayer.setVisible(layer.visible ?? true);
912
+ return olLayer;
1061
913
  };
1062
- class GsOlControl extends Control {
1063
- constructor(options) {
1064
- const element = document.createElement("div");
1065
- element.style.margin = "0";
1066
- element.style.padding = "0";
1067
- super({
1068
- ...options,
1069
- element
1070
- });
1071
- }
1072
- getElement() {
1073
- return this.element;
1074
- }
1075
- }
1076
- class GsOlOverlay extends Overlay {
1077
- constructor(options) {
1078
- const element = document.createElement("div");
1079
- element.style.margin = "0";
1080
- element.style.padding = "0";
1081
- super({
1082
- ...options
1083
- });
1084
- }
1085
- getElement() {
1086
- return this.element;
1087
- }
1088
- }
1089
- const toOlOverlay = (overlay) => {
1090
- const olOverlay = withState(overlay, new GsOlOverlay({
1091
- positioning: overlay.position,
1092
- stopEvent: true
1093
- }));
1094
- olOverlay.set(KEY_SRC, overlay.src);
1095
- return olOverlay;
914
+ var GsOlControl = class extends Control {
915
+ constructor(options) {
916
+ const element = document.createElement("div");
917
+ element.style.margin = "0";
918
+ element.style.padding = "0";
919
+ super({
920
+ ...options,
921
+ element
922
+ });
923
+ }
924
+ getElement() {
925
+ return this.element;
926
+ }
1096
927
  };
1097
- const toOlControl = (control) => {
1098
- const olControl = withState(control, new GsOlControl());
1099
- olControl.set(KEY_SRC, control.src);
1100
- return olControl;
928
+ var GsOlOverlay = class extends Overlay {
929
+ constructor(options) {
930
+ const element = document.createElement("div");
931
+ element.style.margin = "0";
932
+ element.style.padding = "0";
933
+ super({ ...options });
934
+ }
935
+ getElement() {
936
+ return this.element;
937
+ }
1101
938
  };
1102
- const importSrc = async (adapter, src, importer) => {
1103
- const olMap = adapter.getMap();
1104
- return (importer || DefaultImporter)(src).then((mod) => {
1105
- const init = () => {
1106
- olMap.removeEventListener("rendercomplete", init);
1107
- const vars = {
1108
- // backward compatibility
1109
- ...lit,
1110
- // forward compatibility
1111
- lit,
1112
- style: adapter.style.bind(adapter),
1113
- render: adapter.render.bind(adapter),
1114
- map: olMap,
1115
- element: adapter.getElement(),
1116
- querySelector: adapter.getElement().querySelector.bind(adapter.getElement()),
1117
- querySelectorAll: adapter.getElement().querySelector.bind(adapter.getElement()),
1118
- ol,
1119
- env: olMap.get(KEY_ENV) || {},
1120
- utils: {
1121
- uuid: v4
1122
- },
1123
- asset: (path) => {
1124
- return rtUtils.resolveUrl(`assets/${path}`);
1125
- },
1126
- signal: (_name) => {
1127
- },
1128
- events: (topic, callback) => {
1129
- if (callback instanceof Function) {
1130
- const token = subscribe(topic, callback);
1131
- let subscriptions = olMap.get(KEY_EVENT_SUBSCRIPTIONS);
1132
- if (!subscriptions) {
1133
- subscriptions = [];
1134
- olMap.set(KEY_EVENT_SUBSCRIPTIONS, subscriptions);
1135
- }
1136
- subscriptions.push(token);
1137
- return token;
1138
- } else {
1139
- return publish(topic, callback);
1140
- }
1141
- },
1142
- settings: (key, callback) => {
1143
- const mapUuid = olMap.get(KEY_UUID);
1144
- const storageKey = mapUuid ? `gs-settings-${mapUuid}` : "gs-settings";
1145
- const loadSettings = () => {
1146
- try {
1147
- const stored = localStorage.getItem(storageKey);
1148
- return stored ? JSON.parse(stored) : {};
1149
- } catch {
1150
- return {};
1151
- }
1152
- };
1153
- const saveSettings = (settings2) => {
1154
- try {
1155
- localStorage.setItem(storageKey, JSON.stringify(settings2));
1156
- } catch (error) {
1157
- console.error("Failed to save settings to localStorage:", error);
1158
- }
1159
- };
1160
- const settings = loadSettings();
1161
- if (callback === void 0) {
1162
- return settings[key];
1163
- }
1164
- if (callback instanceof Function) {
1165
- vars.events(key, callback);
1166
- callback(settings[key]);
1167
- return settings[key];
1168
- }
1169
- settings[key] = callback;
1170
- saveSettings(settings);
1171
- return publish(key, callback);
1172
- }
1173
- };
1174
- const objectType = adapter instanceof GsControlAdapter ? "control" : "overlay";
1175
- vars[objectType] = adapter;
1176
- const templateFunction = mod instanceof Function ? mod : mod.default;
1177
- if (templateFunction) {
1178
- vars.state = (initialValue) => {
1179
- const createReactiveProperty = (target, key, getValue, setValue) => {
1180
- Object.defineProperty(target, key, {
1181
- get() {
1182
- return getValue();
1183
- },
1184
- set(newValue) {
1185
- const oldValue = getValue();
1186
- if (oldValue !== newValue) {
1187
- setValue(newValue);
1188
- adapter.render();
1189
- }
1190
- },
1191
- enumerable: true,
1192
- configurable: true
1193
- });
1194
- };
1195
- if (typeof initialValue === "object" && initialValue !== null && !Array.isArray(initialValue)) {
1196
- const values = { ...initialValue };
1197
- return new Proxy({}, {
1198
- get(_target, prop) {
1199
- return values[prop];
1200
- },
1201
- set(_target, prop, newValue) {
1202
- if (values[prop] !== newValue) {
1203
- values[prop] = newValue;
1204
- adapter.render();
1205
- }
1206
- return true;
1207
- },
1208
- has(_target, prop) {
1209
- return prop in values;
1210
- },
1211
- ownKeys(_target) {
1212
- return Object.keys(values);
1213
- },
1214
- getOwnPropertyDescriptor(_target, prop) {
1215
- if (prop in values) {
1216
- return {
1217
- enumerable: true,
1218
- configurable: true,
1219
- value: values[prop]
1220
- };
1221
- }
1222
- return void 0;
1223
- }
1224
- });
1225
- } else {
1226
- const stateObj = {};
1227
- let value = initialValue;
1228
- createReactiveProperty(
1229
- stateObj,
1230
- "value",
1231
- () => value,
1232
- (v) => {
1233
- value = v;
1234
- }
1235
- );
1236
- return stateObj;
1237
- }
1238
- };
1239
- const component = templateFunction(vars);
1240
- if (component instanceof Function) {
1241
- adapter.render(component);
1242
- } else {
1243
- adapter.render(component);
1244
- }
1245
- }
1246
- if (adapter instanceof GsControlAdapter) {
1247
- adapter.rendered();
1248
- }
1249
- olMap.render();
1250
- };
1251
- olMap.on("rendercomplete", init);
1252
- });
939
+ var toOlOverlay = (overlay) => {
940
+ const olOverlay = withState(overlay, new GsOlOverlay({
941
+ positioning: overlay.position,
942
+ stopEvent: true
943
+ }));
944
+ olOverlay.set("src", overlay.src);
945
+ return olOverlay;
1253
946
  };
1254
- const importOverlaySource = async (olOverlay, src, importer) => {
1255
- const overlayAdapter = new GsOverlayAdapter(olOverlay);
1256
- return importSrc(overlayAdapter, src, importer);
947
+ var toOlControl = (control) => {
948
+ const olControl = withState(control, new GsOlControl());
949
+ olControl.set("src", control.src);
950
+ return olControl;
1257
951
  };
1258
- const importControlSource = async (olControl, src, importer) => {
1259
- const controlAdapter = new GsControlAdapter(olControl);
1260
- return importSrc(controlAdapter, src, importer);
952
+ var importSrc = async (adapter, src, importer) => {
953
+ const olMap = adapter.getMap();
954
+ return (importer || DefaultImporter)(src).then((mod) => {
955
+ const init = () => {
956
+ olMap.removeEventListener("rendercomplete", init);
957
+ const vars = {
958
+ ...lit,
959
+ lit,
960
+ style: adapter.style.bind(adapter),
961
+ render: adapter.render.bind(adapter),
962
+ map: olMap,
963
+ element: adapter.getElement(),
964
+ querySelector: adapter.getElement().querySelector.bind(adapter.getElement()),
965
+ querySelectorAll: adapter.getElement().querySelector.bind(adapter.getElement()),
966
+ ol: gs_olns_exports,
967
+ env: olMap.get("_env") || {},
968
+ utils: { uuid: v4 },
969
+ asset: (path) => {
970
+ return rtUtils.resolveUrl(`assets/${path}`);
971
+ },
972
+ signal: (_name) => {},
973
+ events: (topic, callback) => {
974
+ if (callback instanceof Function) {
975
+ const token = subscribe(topic, callback);
976
+ let subscriptions = olMap.get(KEY_EVENT_SUBSCRIPTIONS);
977
+ if (!subscriptions) {
978
+ subscriptions = [];
979
+ olMap.set(KEY_EVENT_SUBSCRIPTIONS, subscriptions);
980
+ }
981
+ subscriptions.push(token);
982
+ return token;
983
+ } else return publish(topic, callback);
984
+ },
985
+ settings: (key, callback) => {
986
+ const mapUuid = olMap.get(KEY_UUID);
987
+ const storageKey = mapUuid ? `gs-settings-${mapUuid}` : "gs-settings";
988
+ const loadSettings = () => {
989
+ try {
990
+ const stored = localStorage.getItem(storageKey);
991
+ return stored ? JSON.parse(stored) : {};
992
+ } catch {
993
+ return {};
994
+ }
995
+ };
996
+ const saveSettings = (settings) => {
997
+ try {
998
+ localStorage.setItem(storageKey, JSON.stringify(settings));
999
+ } catch (error) {
1000
+ console.error("Failed to save settings to localStorage:", error);
1001
+ }
1002
+ };
1003
+ const settings = loadSettings();
1004
+ if (callback === void 0) return settings[key];
1005
+ if (callback instanceof Function) {
1006
+ vars.events(key, callback);
1007
+ callback(settings[key]);
1008
+ return settings[key];
1009
+ }
1010
+ settings[key] = callback;
1011
+ saveSettings(settings);
1012
+ return publish(key, callback);
1013
+ }
1014
+ };
1015
+ const objectType = adapter instanceof GsControlAdapter ? "control" : "overlay";
1016
+ vars[objectType] = adapter;
1017
+ const templateFunction = mod instanceof Function ? mod : mod.default;
1018
+ if (templateFunction) {
1019
+ vars.state = (initialValue) => {
1020
+ const createReactiveProperty = (target, key, getValue, setValue) => {
1021
+ Object.defineProperty(target, key, {
1022
+ get() {
1023
+ return getValue();
1024
+ },
1025
+ set(newValue) {
1026
+ if (getValue() !== newValue) {
1027
+ setValue(newValue);
1028
+ adapter.render();
1029
+ }
1030
+ },
1031
+ enumerable: true,
1032
+ configurable: true
1033
+ });
1034
+ };
1035
+ if (typeof initialValue === "object" && initialValue !== null && !Array.isArray(initialValue)) {
1036
+ const values = { ...initialValue };
1037
+ return new Proxy({}, {
1038
+ get(_target, prop) {
1039
+ return values[prop];
1040
+ },
1041
+ set(_target, prop, newValue) {
1042
+ if (values[prop] !== newValue) {
1043
+ values[prop] = newValue;
1044
+ adapter.render();
1045
+ }
1046
+ return true;
1047
+ },
1048
+ has(_target, prop) {
1049
+ return prop in values;
1050
+ },
1051
+ ownKeys(_target) {
1052
+ return Object.keys(values);
1053
+ },
1054
+ getOwnPropertyDescriptor(_target, prop) {
1055
+ if (prop in values) return {
1056
+ enumerable: true,
1057
+ configurable: true,
1058
+ value: values[prop]
1059
+ };
1060
+ }
1061
+ });
1062
+ } else {
1063
+ const stateObj = {};
1064
+ let value = initialValue;
1065
+ createReactiveProperty(stateObj, "value", () => value, (v) => {
1066
+ value = v;
1067
+ });
1068
+ return stateObj;
1069
+ }
1070
+ };
1071
+ const component = templateFunction(vars);
1072
+ if (component instanceof Function) adapter.render(component);
1073
+ else adapter.render(component);
1074
+ }
1075
+ if (adapter instanceof GsControlAdapter) adapter.rendered();
1076
+ olMap.render();
1077
+ };
1078
+ olMap.on("rendercomplete", init);
1079
+ });
1261
1080
  };
1262
- const DefaultImporter = (src) => import(src);
1263
- const cleanupEventSubscriptions = (olMap) => {
1264
- const subscriptions = olMap.get(KEY_EVENT_SUBSCRIPTIONS);
1265
- if (subscriptions) {
1266
- subscriptions.forEach((token) => unsubscribe(token));
1267
- olMap.set(KEY_EVENT_SUBSCRIPTIONS, []);
1268
- }
1081
+ var importOverlaySource = async (olOverlay, src, importer) => {
1082
+ return importSrc(new GsOverlayAdapter(olOverlay), src, importer);
1269
1083
  };
1270
- const toOlMap = async (gsMap, options, env, importer, target) => {
1271
- const olMap = withState(gsMap, new Map$1(options));
1272
- olMap.set(KEY_ENV, env);
1273
- olMap.setView(new View({
1274
- center: gsMap.view.center && gsMap.view.center.length == 2 ? gsMap.view.center : DEFAULT_GSMAP.view.center,
1275
- zoom: gsMap.view.zoom || DEFAULT_GSMAP.view.zoom,
1276
- projection: gsMap.view.projection || DEFAULT_GSMAP.view.projection
1277
- }));
1278
- for (const layer of gsMap.layers || []) {
1279
- const olLayer = toOlLayer(layer, env);
1280
- olMap.addLayer(olLayer);
1281
- }
1282
- if (target) {
1283
- olMap.setTarget(target);
1284
- }
1285
- for (const overlay of gsMap.overlays || []) {
1286
- const olOverlay = toOlOverlay(overlay);
1287
- olMap.addOverlay(olOverlay);
1288
- await importOverlaySource(olOverlay, overlay.src, importer);
1289
- }
1290
- for (const control of gsMap.controls || []) {
1291
- const olControl = toOlControl(control);
1292
- olMap.addControl(olControl);
1293
- await importControlSource(olControl, control.src, importer);
1294
- }
1295
- return olMap;
1084
+ var importControlSource = async (olControl, src, importer) => {
1085
+ return importSrc(new GsControlAdapter(olControl), src, importer);
1296
1086
  };
1297
- const toGsLayerType = (tag) => {
1298
- switch (tag?.toLowerCase()) {
1299
- case "osm":
1300
- case "bing":
1301
- case "google":
1302
- case "geotiff":
1303
- case "wms":
1304
- case "wmts":
1305
- case "xyz":
1306
- return GsLayerType.TILE;
1307
- case "bm":
1308
- case "basemap.de":
1309
- return GsLayerType.GROUP;
1310
- case "scripted":
1311
- return GsLayerType.SCRIPTED;
1312
- default:
1313
- return GsLayerType.VECTOR;
1314
- }
1087
+ var DefaultImporter = (src) => import(src);
1088
+ var cleanupEventSubscriptions = (olMap) => {
1089
+ const subscriptions = olMap.get(KEY_EVENT_SUBSCRIPTIONS);
1090
+ if (subscriptions) {
1091
+ subscriptions.forEach((token) => unsubscribe(token));
1092
+ olMap.set(KEY_EVENT_SUBSCRIPTIONS, []);
1093
+ }
1315
1094
  };
1316
- const toGsSourceType = (tag) => {
1317
- if (tag) {
1318
- tag = tag.toLowerCase();
1319
- const sourceTypes = Object.values(GsSourceType);
1320
- const hit = sourceTypes.find((t) => tag === t.toLowerCase());
1321
- if (hit) {
1322
- return hit;
1323
- }
1324
- }
1325
- throw new Error("Unsupported source type: " + tag);
1095
+ var toOlMap = async (gsMap, options, env, importer, target) => {
1096
+ const olMap = withState(gsMap, new Map$1(options));
1097
+ olMap.set(KEY_ENV, env);
1098
+ olMap.setView(new View({
1099
+ center: gsMap.view.center && gsMap.view.center.length == 2 ? gsMap.view.center : DEFAULT_GSMAP.view.center,
1100
+ zoom: gsMap.view.zoom || DEFAULT_GSMAP.view.zoom,
1101
+ projection: gsMap.view.projection || DEFAULT_GSMAP.view.projection
1102
+ }));
1103
+ for (const layer of gsMap.layers || []) {
1104
+ const olLayer = toOlLayer(layer, env);
1105
+ olMap.addLayer(olLayer);
1106
+ }
1107
+ if (target) olMap.setTarget(target);
1108
+ for (const overlay of gsMap.overlays || []) {
1109
+ const olOverlay = toOlOverlay(overlay);
1110
+ olMap.addOverlay(olOverlay);
1111
+ await importOverlaySource(olOverlay, overlay.src, importer);
1112
+ }
1113
+ for (const control of gsMap.controls || []) {
1114
+ const olControl = toOlControl(control);
1115
+ olMap.addControl(olControl);
1116
+ await importControlSource(olControl, control.src, importer);
1117
+ }
1118
+ return olMap;
1326
1119
  };
1327
- const toSourceUrl = (sourceType) => {
1328
- switch (sourceType) {
1329
- case GsSourceType.BM:
1330
- return "https://sgx.geodatenzentrum.de/gdz_basemapworld_vektor/styles/bm_web_wld_col.json";
1331
- }
1332
- return void 0;
1120
+ //#endregion
1121
+ //#region src/ol/gs-ol2gs.ts
1122
+ var toGsLayerType = (tag) => {
1123
+ switch (tag?.toLowerCase()) {
1124
+ case "osm":
1125
+ case "bing":
1126
+ case "google":
1127
+ case "geotiff":
1128
+ case "wms":
1129
+ case "wmts":
1130
+ case "xyz": return GsLayerType.TILE;
1131
+ case "bm":
1132
+ case "basemap.de": return GsLayerType.GROUP;
1133
+ case "scripted": return GsLayerType.SCRIPTED;
1134
+ default: return GsLayerType.VECTOR;
1135
+ }
1333
1136
  };
1334
- const withGsState = (olObj, gsState) => {
1335
- const state = olObj.get(KEY_STATE);
1336
- gsState.state = state;
1337
- if (state?.uuid) {
1338
- gsState.uuid = state.uuid;
1339
- } else {
1340
- const uuid = olObj.get(KEY_UUID);
1341
- if (uuid) {
1342
- gsState.uuid = uuid;
1343
- }
1344
- }
1345
- return gsState;
1137
+ var toGsSourceType = (tag) => {
1138
+ if (tag) {
1139
+ tag = tag.toLowerCase();
1140
+ const hit = Object.values(GsSourceType).find((t) => tag === t.toLowerCase());
1141
+ if (hit) return hit;
1142
+ }
1143
+ throw new Error("Unsupported source type: " + tag);
1144
+ };
1145
+ var toSourceUrl = (sourceType) => {
1146
+ switch (sourceType) {
1147
+ case GsSourceType.BM: return "https://sgx.geodatenzentrum.de/gdz_basemapworld_vektor/styles/bm_web_wld_col.json";
1148
+ }
1149
+ };
1150
+ var withGsState = (olObj, gsState) => {
1151
+ const state = olObj.get(KEY_STATE);
1152
+ gsState.state = state;
1153
+ if (state?.uuid) gsState.uuid = state.uuid;
1154
+ else {
1155
+ const uuid = olObj.get(KEY_UUID);
1156
+ if (uuid) gsState.uuid = uuid;
1157
+ }
1158
+ return gsState;
1346
1159
  };
1347
1160
  function toGsGeometry(geometry) {
1348
- return withGsState(geometry, {
1349
- type: geometry.getType(),
1350
- coordinates: geometry.getCoordinates()
1351
- });
1161
+ return withGsState(geometry, {
1162
+ type: geometry.getType(),
1163
+ coordinates: geometry.getCoordinates()
1164
+ });
1352
1165
  }
1353
1166
  function toGsFeature(feature) {
1354
- return withGsState(feature, {
1355
- geometry: toGsGeometry(feature.getGeometry())
1356
- });
1167
+ return withGsState(feature, { geometry: toGsGeometry(feature.getGeometry()) });
1357
1168
  }
1358
- const olLib = async (options) => {
1359
- const mapOptions = {
1360
- interactions: defaults$1({ keyboard: false }),
1361
- controls: defaults(options.mapOptions?.controls)
1362
- };
1363
- let importer = options.importer;
1364
- if (!importer && options.modules) {
1365
- importer = async (src) => {
1366
- const module = options.modules[src];
1367
- if (module) {
1368
- if (typeof module === "string") {
1369
- return import(module);
1370
- }
1371
- return module;
1372
- }
1373
- throw new Error(`Module not found: ${src}`);
1374
- };
1375
- }
1376
- const target = typeof options.containerSelector === "string" ? document.querySelector(options.containerSelector) : options.containerSelector;
1377
- const olMap = await toOlMap(options.gsMap, mapOptions, options.env, importer, target);
1378
- return olMap;
1169
+ //#endregion
1170
+ //#region src/ol/gs-ol-lib.ts
1171
+ var olLib = async (options) => {
1172
+ const mapOptions = {
1173
+ interactions: defaultInteractions({ keyboard: false }),
1174
+ controls: defaultControls(options.mapOptions?.controls)
1175
+ };
1176
+ let importer = options.importer;
1177
+ if (!importer && options.modules) importer = async (src) => {
1178
+ const module = options.modules[src];
1179
+ if (module) {
1180
+ if (typeof module === "string") return import(module);
1181
+ return module;
1182
+ }
1183
+ throw new Error(`Module not found: ${src}`);
1184
+ };
1185
+ const target = typeof options.containerSelector === "string" ? document.querySelector(options.containerSelector) : options.containerSelector;
1186
+ return await toOlMap(options.gsMap, mapOptions, options.env, importer, target);
1379
1187
  };
1188
+ //#endregion
1189
+ //#region src/ol/openlayers-map-renderer.ts
1190
+ /**
1191
+ * Lightweight helper to extract minimal GsFeature data for style evaluation
1192
+ * Avoids the overhead of full toGsFeature() conversion
1193
+ */
1380
1194
  function getFeatureStyleData(feature) {
1381
- const geometry = feature.getGeometry();
1382
- return ensureUuid({
1383
- geometry: ensureUuid({
1384
- type: geometry.getType(),
1385
- coordinates: []
1386
- // Not needed for style rules
1387
- }),
1388
- state: feature.get(KEY_STATE)
1389
- });
1195
+ return ensureUuid({
1196
+ geometry: ensureUuid({
1197
+ type: feature.getGeometry().getType(),
1198
+ coordinates: []
1199
+ }),
1200
+ state: feature.get(KEY_STATE)
1201
+ });
1390
1202
  }
1391
- class OpenLayersMapRenderer {
1392
- constructor(gsMap, env) {
1393
- this.isDestroyed = false;
1394
- this.styleCache = /* @__PURE__ */ new Map();
1395
- this.gsMap = gsMap;
1396
- this.env = env;
1397
- }
1398
- async reattached() {
1399
- }
1400
- async render(container) {
1401
- try {
1402
- this.olMap = await olLib({
1403
- containerSelector: container,
1404
- gsMap: this.gsMap,
1405
- env: this.env,
1406
- mapOptions: {
1407
- controls: { zoom: false, attribution: false }
1408
- }
1409
- });
1410
- this.operations = new OpenLayersMapOperations(this.olMap, this);
1411
- this.applyStylesToLayers();
1412
- this.olMap.once("rendercomplete", () => {
1413
- this.setupEventListeners();
1414
- });
1415
- } catch (error) {
1416
- console.error("Failed to render map:", error);
1417
- throw error;
1418
- }
1419
- }
1420
- applyStylesToLayers() {
1421
- if (!this.olMap) return;
1422
- const layers = this.olMap.getLayers().getArray();
1423
- layers.forEach((layer) => {
1424
- if (layer instanceof layerNS.Vector) {
1425
- this.applyStyleToVectorLayer(layer);
1426
- }
1427
- });
1428
- }
1429
- applyStyleToVectorLayer(layer) {
1430
- const layerName = layer.get(KEY_NAME);
1431
- const styleFunction = (feature) => {
1432
- if (!(feature instanceof Feature)) {
1433
- return void 0;
1434
- }
1435
- const featureStyleData = getFeatureStyleData(feature);
1436
- const styleRules = this.gsMap.styleRules;
1437
- const stylesMap = this.gsMap.styles;
1438
- if (styleRules && stylesMap) {
1439
- const gsStyle = getStyleForFeature(featureStyleData, styleRules, stylesMap, layerName);
1440
- if (gsStyle && gsStyle.id) {
1441
- let olStyle = this.styleCache.get(gsStyle.id);
1442
- if (!olStyle) {
1443
- olStyle = toOlStyle(gsStyle);
1444
- this.styleCache.set(gsStyle.id, olStyle);
1445
- }
1446
- return olStyle;
1447
- } else if (gsStyle) {
1448
- return toOlStyle(gsStyle);
1449
- }
1450
- }
1451
- return void 0;
1452
- };
1453
- layer.setStyle(styleFunction);
1454
- }
1455
- clearStyleCache() {
1456
- this.styleCache.clear();
1457
- }
1458
- async modelToUI(updatedGsMap) {
1459
- if (!this.olMap) {
1460
- throw new Error("Map not initialized");
1461
- }
1462
- if (updatedGsMap) {
1463
- this.gsMap = updatedGsMap;
1464
- }
1465
- this.clearStyleCache();
1466
- const target = this.olMap.getTarget();
1467
- if (!target || typeof target === "string") {
1468
- throw new Error("Map container not found or invalid");
1469
- }
1470
- this.destroy();
1471
- target.innerHTML = "";
1472
- this.isDestroyed = false;
1473
- await this.render(target);
1474
- }
1475
- getOperations() {
1476
- if (!this.operations) {
1477
- throw new Error("Operations not available - map not rendered yet");
1478
- }
1479
- return this.operations;
1480
- }
1481
- async getViewExtent() {
1482
- console.debug("Getting view extent");
1483
- if (!this.olMap) {
1484
- throw new Error("Map not available for extent calculation");
1485
- }
1486
- const view = this.olMap.getView();
1487
- const extent2 = view.calculateExtent();
1488
- console.debug(`View extent: ${extent2}`);
1489
- return extent2;
1490
- }
1491
- async captureScreenshot() {
1492
- if (!this.olMap) {
1493
- return { success: false, error: "Map not available" };
1494
- }
1495
- const olMap = this.olMap;
1496
- await new Promise((resolve) => {
1497
- olMap.renderSync();
1498
- olMap.once("rendercomplete", () => resolve());
1499
- setTimeout(() => resolve(), 2e3);
1500
- });
1501
- const size = olMap.getSize();
1502
- const width = size ? size[0] : olMap.getViewport().clientWidth;
1503
- const height = size ? size[1] : olMap.getViewport().clientHeight;
1504
- try {
1505
- const canvas = olMap.getViewport().querySelector("canvas");
1506
- if (!canvas) {
1507
- return { success: false, error: "Map canvas not found" };
1508
- }
1509
- const dataUrl = canvas.toDataURL("image/png");
1510
- return { success: true, dataUrl, width, height };
1511
- } catch (error) {
1512
- return { success: false, error: `Failed to capture canvas: ${error.message}` };
1513
- }
1514
- }
1515
- setOnDirty(callback) {
1516
- this.onDirtyCallback = callback;
1517
- }
1518
- setOnSync(callback) {
1519
- this.onSyncCallback = callback;
1520
- }
1521
- triggerDirty() {
1522
- if (this.isDestroyed || !this.onDirtyCallback) return;
1523
- this.onDirtyCallback();
1524
- }
1525
- triggerSync(event) {
1526
- if (this.isDestroyed || !this.onSyncCallback) return;
1527
- this.onSyncCallback(event);
1528
- }
1529
- syncViewToModel() {
1530
- if (!this.olMap) return;
1531
- const view = this.olMap.getView();
1532
- const center = view.getCenter();
1533
- const zoom = view.getZoom();
1534
- const rotation = view.getRotation();
1535
- if (center && zoom !== void 0) {
1536
- this.triggerSync({
1537
- type: "viewChanged",
1538
- view: { center, zoom, rotation }
1539
- });
1540
- }
1541
- }
1542
- syncLayerFeaturesToModel(layerUuid) {
1543
- if (!this.olMap) return;
1544
- const layers = this.olMap.getLayers();
1545
- let olLayer;
1546
- for (let i = 0; i < layers.getLength(); i++) {
1547
- const layer = layers.item(i);
1548
- if (layer.get(KEY_UUID) === layerUuid) {
1549
- olLayer = layer;
1550
- break;
1551
- }
1552
- }
1553
- if (!olLayer || !(olLayer instanceof layerNS.Vector)) return;
1554
- const source2 = olLayer.getSource();
1555
- if (!source2) return;
1556
- const olFeatures = source2.getFeatures();
1557
- const gsFeatures = olFeatures.map((olFeature) => toGsFeature(olFeature));
1558
- this.triggerSync({
1559
- type: "featuresChanged",
1560
- layerUuid,
1561
- features: gsFeatures
1562
- });
1563
- }
1564
- setupEventListeners() {
1565
- if (!this.olMap) return;
1566
- this.olMap.getView().on("change:center", () => {
1567
- this.syncViewToModel();
1568
- this.triggerDirty();
1569
- });
1570
- this.olMap.getView().on("change:resolution", () => {
1571
- this.syncViewToModel();
1572
- this.triggerDirty();
1573
- });
1574
- this.olMap.getView().on("change:rotation", () => {
1575
- this.syncViewToModel();
1576
- this.triggerDirty();
1577
- });
1578
- this.olMap.getLayers().on("add", () => this.triggerDirty());
1579
- this.olMap.getLayers().on("remove", () => this.triggerDirty());
1580
- this.olMap.getControls().on("add", () => this.triggerDirty());
1581
- this.olMap.getControls().on("remove", () => this.triggerDirty());
1582
- this.olMap.getOverlays().on("add", () => this.triggerDirty());
1583
- this.olMap.getOverlays().on("remove", () => this.triggerDirty());
1584
- }
1585
- destroy() {
1586
- this.isDestroyed = true;
1587
- this.clearStyleCache();
1588
- if (this.operations) {
1589
- const ops = this.operations;
1590
- if (ops.cleanup) {
1591
- ops.cleanup();
1592
- }
1593
- }
1594
- if (this.olMap) {
1595
- cleanupEventSubscriptions(this.olMap);
1596
- }
1597
- this.olMap?.dispose();
1598
- this.olMap = void 0;
1599
- }
1600
- async transform(coord, options) {
1601
- if (!this.olMap) {
1602
- throw new Error("Map not available for coordinate transformation");
1603
- }
1604
- const view = this.olMap.getView();
1605
- const mapProj = view.getProjection()?.getCode() || "EPSG:3857";
1606
- const source2 = options?.sourceProjection ?? mapProj;
1607
- const target = options?.targetProjection ?? "EPSG:4326";
1608
- if (source2 === target) {
1609
- return coord;
1610
- }
1611
- const result = proj.transform(coord, source2, target);
1612
- return result;
1613
- }
1614
- }
1615
- class OpenLayersMapOperations {
1616
- constructor(olMap, renderer) {
1617
- this.olMap = olMap;
1618
- this.renderer = renderer;
1619
- if (!olMap) {
1620
- throw new Error("OpenLayers map is required for operations");
1621
- }
1622
- this.keyDownListener = (event) => {
1623
- if (event.key === "Escape") {
1624
- if (this.drawInteraction) {
1625
- this.disableDrawing();
1626
- this.renderer?.triggerSync({ type: "drawingDisabled" });
1627
- }
1628
- if (this.selectInteraction) {
1629
- this.disableSelection();
1630
- }
1631
- }
1632
- };
1633
- const target = this.olMap.getTargetElement();
1634
- if (target && target instanceof HTMLElement) {
1635
- target.setAttribute("tabindex", "-1");
1636
- target.addEventListener("keydown", this.keyDownListener);
1637
- }
1638
- }
1639
- async setZoom(zoom) {
1640
- this.olMap.getView().setZoom(zoom);
1641
- }
1642
- async setCenter(center) {
1643
- this.olMap.getView().setCenter(center);
1644
- }
1645
- async switchColorMode(mode) {
1646
- const olMap = this.olMap;
1647
- let darkMode = olMap.get("darkmode") ?? false;
1648
- if (mode === "dark") {
1649
- darkMode = true;
1650
- } else if (mode === "light") {
1651
- darkMode = false;
1652
- } else {
1653
- darkMode = !darkMode;
1654
- }
1655
- olMap.set("darkmode", darkMode);
1656
- const canvasElements = document.querySelectorAll("canvas");
1657
- canvasElements.forEach((canvas) => {
1658
- canvas.style.filter = darkMode ? "invert(100%)" : "";
1659
- });
1660
- olMap.render();
1661
- }
1662
- async addLayer(layer, isBasemap) {
1663
- const olLayer = toOlLayer(layer);
1664
- if (isBasemap) {
1665
- this.olMap.getLayers().insertAt(0, olLayer);
1666
- } else {
1667
- this.olMap.getLayers().push(olLayer);
1668
- }
1669
- }
1670
- async deleteLayer(uuid) {
1671
- const layers = this.olMap.getLayers();
1672
- for (let i = 0; i < layers.getLength(); i++) {
1673
- const layer = layers.item(i);
1674
- if (layer.get(KEY_UUID) === uuid) {
1675
- layers.removeAt(i);
1676
- return;
1677
- }
1678
- }
1679
- }
1680
- async renameLayer(uuid, newName) {
1681
- const layers = this.olMap.getLayers();
1682
- for (let i = 0; i < layers.getLength(); i++) {
1683
- const layer = layers.item(i);
1684
- if (layer.get(KEY_UUID) === uuid) {
1685
- layer.set(KEY_NAME, newName);
1686
- return;
1687
- }
1688
- }
1689
- }
1690
- async moveLayer(uuid, targetUuid) {
1691
- const layers = this.olMap.getLayers();
1692
- let fromIndex = -1;
1693
- let toIndex = -1;
1694
- for (let i = 0; i < layers.getLength(); i++) {
1695
- const layer = layers.item(i);
1696
- if (layer.get(KEY_UUID) === uuid) {
1697
- fromIndex = i;
1698
- }
1699
- if (targetUuid && layer.get(KEY_UUID) === targetUuid) {
1700
- toIndex = i;
1701
- }
1702
- }
1703
- if (fromIndex < 0) return;
1704
- if (targetUuid) {
1705
- if (toIndex < 0 || fromIndex === toIndex) return;
1706
- } else {
1707
- toIndex = fromIndex > 0 ? fromIndex - 1 : fromIndex + 1;
1708
- }
1709
- if (toIndex >= 0 && toIndex < layers.getLength() && fromIndex !== toIndex) {
1710
- const layer = layers.item(fromIndex);
1711
- layers.removeAt(fromIndex);
1712
- layers.insertAt(toIndex, layer);
1713
- }
1714
- }
1715
- async setLayerVisible(uuid, visible) {
1716
- const layers = this.olMap.getLayers();
1717
- for (let i = 0; i < layers.getLength(); i++) {
1718
- const layer = layers.item(i);
1719
- if (layer.get(KEY_UUID) === uuid) {
1720
- layer.setVisible(visible);
1721
- return;
1722
- }
1723
- }
1724
- }
1725
- async addControlFromModule(_src) {
1726
- }
1727
- async removeControl(_uuid) {
1728
- }
1729
- async addOverlayFromModule(_src, _position) {
1730
- }
1731
- async removeOverlay(_uuid) {
1732
- }
1733
- setCursor(cursor) {
1734
- const viewport = this.olMap.getViewport();
1735
- if (viewport) {
1736
- viewport.style.cursor = cursor;
1737
- }
1738
- }
1739
- async enableDrawing(geometryType, layerUuid) {
1740
- this.disableSelection();
1741
- if (this.drawInteraction) {
1742
- this.olMap.removeInteraction(this.drawInteraction);
1743
- }
1744
- this.activeDrawingLayerUuid = layerUuid;
1745
- this.setCursor("crosshair");
1746
- const layers = this.olMap.getLayers();
1747
- let layer;
1748
- for (let i = 0; i < layers.getLength(); i++) {
1749
- const l = layers.item(i);
1750
- if (l.get(KEY_UUID) === layerUuid) {
1751
- layer = l;
1752
- break;
1753
- }
1754
- }
1755
- if (!layer || !(layer instanceof layerNS.Vector)) {
1756
- throw new Error("Drawing only supported on vector layers");
1757
- }
1758
- const source2 = layer.getSource();
1759
- if (!source2) {
1760
- throw new Error("Layer has no source");
1761
- }
1762
- const layerSourceType = layer.get("sourceType");
1763
- if (layerSourceType && layerSourceType !== GsSourceType.Features) {
1764
- throw new Error("Drawing only supported on layers with in-memory features");
1765
- }
1766
- this.drawInteraction = new interactionNS.Draw({
1767
- source: source2,
1768
- type: geometryType
1769
- });
1770
- const onFeatureAdded = (event) => {
1771
- const feature = event.feature;
1772
- if (feature && !feature.get(KEY_UUID)) {
1773
- const uuid = v4$1();
1774
- feature.set(KEY_UUID, uuid);
1775
- const state = feature.get(KEY_STATE) || {};
1776
- state.uuid = uuid;
1777
- feature.set(KEY_STATE, state);
1778
- }
1779
- if (this.renderer && this.activeDrawingLayerUuid) {
1780
- this.renderer.syncLayerFeaturesToModel(this.activeDrawingLayerUuid);
1781
- }
1782
- this.renderer?.triggerDirty();
1783
- };
1784
- source2.on("addfeature", onFeatureAdded);
1785
- this.drawInteraction._featureAddedListener = onFeatureAdded;
1786
- this.drawInteraction._sourceRef = source2;
1787
- this.olMap.addInteraction(this.drawInteraction);
1788
- }
1789
- async disableDrawing() {
1790
- if (this.drawInteraction) {
1791
- const listener = this.drawInteraction._featureAddedListener;
1792
- const source2 = this.drawInteraction._sourceRef;
1793
- if (listener && source2) {
1794
- source2.un("addfeature", listener);
1795
- }
1796
- this.olMap.removeInteraction(this.drawInteraction);
1797
- this.drawInteraction = void 0;
1798
- this.setCursor("");
1799
- }
1800
- }
1801
- cleanup() {
1802
- if (this.keyDownListener) {
1803
- const target = this.olMap.getTargetElement();
1804
- if (target && target instanceof HTMLElement) {
1805
- target.removeEventListener("keydown", this.keyDownListener);
1806
- }
1807
- this.keyDownListener = void 0;
1808
- }
1809
- }
1810
- async enableFeatureSelection() {
1811
- this.disableDrawing();
1812
- this.disableSelection();
1813
- const olLayers = this.olMap.getLayers();
1814
- const vectorLayers = olLayers.getArray().filter((layer) => layer instanceof layerNS.Vector);
1815
- if (vectorLayers.length === 0) {
1816
- throw new Error("No vector layers available for selection");
1817
- }
1818
- const gsMap = this.renderer?.gsMap;
1819
- const selectionStyle = gsMap?.styles?.["selection"];
1820
- const selectOptions = {
1821
- condition: eventsCondition.click,
1822
- layers: vectorLayers,
1823
- hitTolerance: 5,
1824
- style: selectionStyle ? toOlStyle(selectionStyle) : (_feature) => {
1825
- const stroke = new style.Stroke({ color: "rgba(255, 255, 0, 1)", width: 3 });
1826
- const fill = new style.Fill({ color: "rgba(255, 255, 0, 0.3)" });
1827
- return new style.Style({
1828
- image: new style.Circle({ radius: 7, fill, stroke }),
1829
- stroke,
1830
- fill
1831
- });
1832
- }
1833
- };
1834
- this.selectInteraction = new interactionNS.Select(selectOptions);
1835
- this.selectInteraction.on("select", (event) => {
1836
- if (event.selected.length > 0) {
1837
- const selectedFeature = event.selected[0];
1838
- let featureLayerUuid;
1839
- olLayers.getArray().forEach((layer) => {
1840
- if (layer instanceof layerNS.Vector) {
1841
- const source2 = layer.getSource();
1842
- if (source2 && source2.hasFeature(selectedFeature)) {
1843
- const uuid = layer.get(KEY_UUID);
1844
- if (uuid) featureLayerUuid = uuid;
1845
- }
1846
- }
1847
- });
1848
- if (featureLayerUuid && this.renderer) {
1849
- const gsFeature = toGsFeature(selectedFeature);
1850
- const geometry = selectedFeature.getGeometry();
1851
- const metrics = {};
1852
- if (geometry) {
1853
- const geometryType = geometry.getType();
1854
- try {
1855
- if (geometryType === "LineString" || geometryType === "MultiLineString") {
1856
- metrics.length = sphere.getLength(geometry, { projection: this.olMap.getView().getProjection() });
1857
- } else if (geometryType === "Polygon" || geometryType === "MultiPolygon") {
1858
- metrics.area = sphere.getArea(geometry, { projection: this.olMap.getView().getProjection() });
1859
- const coordinates = geometryType === "Polygon" ? geometry.getCoordinates()[0] : geometry.getCoordinates()[0][0];
1860
- if (coordinates?.length > 0) {
1861
- const perimeterLine = new olGeom.LineString(coordinates);
1862
- metrics.length = sphere.getLength(perimeterLine, { projection: this.olMap.getView().getProjection() });
1863
- }
1864
- }
1865
- } catch (error) {
1866
- console.warn("Error calculating feature metrics:", error);
1867
- }
1868
- }
1869
- this.renderer.triggerSync({
1870
- type: "featureSelected",
1871
- layerUuid: featureLayerUuid,
1872
- feature: gsFeature,
1873
- metrics
1874
- });
1875
- }
1876
- } else if (event.deselected.length > 0) {
1877
- this.renderer?.triggerSync({ type: "featureDeselected" });
1878
- }
1879
- });
1880
- this.olMap.addInteraction(this.selectInteraction);
1881
- this.setCursor("pointer");
1882
- }
1883
- async deleteSelectedFeatures() {
1884
- if (!this.selectInteraction) {
1885
- throw new Error("No selection interaction active");
1886
- }
1887
- const selectedFeatures = this.selectInteraction.getFeatures();
1888
- if (selectedFeatures.getLength() === 0) {
1889
- throw new Error("No features selected");
1890
- }
1891
- const layersToSync = /* @__PURE__ */ new Set();
1892
- const olLayers = this.olMap.getLayers();
1893
- selectedFeatures.forEach((feature) => {
1894
- for (let i = 0; i < olLayers.getLength(); i++) {
1895
- const layer = olLayers.item(i);
1896
- if (layer instanceof layerNS.Vector) {
1897
- const source2 = layer.getSource();
1898
- if (source2 && source2.hasFeature(feature)) {
1899
- source2.removeFeature(feature);
1900
- const layerUuid = layer.get(KEY_UUID);
1901
- if (layerUuid) layersToSync.add(layerUuid);
1902
- break;
1903
- }
1904
- }
1905
- }
1906
- });
1907
- selectedFeatures.clear();
1908
- if (this.renderer && layersToSync.size > 0) {
1909
- layersToSync.forEach((layerUuid) => {
1910
- this.renderer.syncLayerFeaturesToModel(layerUuid);
1911
- });
1912
- }
1913
- this.renderer?.triggerDirty();
1914
- }
1915
- async disableSelection() {
1916
- if (this.selectInteraction) {
1917
- this.olMap.removeInteraction(this.selectInteraction);
1918
- this.selectInteraction = void 0;
1919
- this.setCursor("");
1920
- this.renderer?.triggerSync({ type: "featureDeselected" });
1921
- }
1922
- }
1923
- }
1924
- const rtUtils = {
1925
- async resolveUrl(url) {
1926
- return url;
1927
- }
1203
+ /**
1204
+ * OpenLayers map renderer that manages OpenLayers maps
1205
+ * Provides complete isolation between the host app and the rendering engine
1206
+ * User modules are handled by the toOlMap() function
1207
+ */
1208
+ var OpenLayersMapRenderer = class {
1209
+ constructor(gsMap, env) {
1210
+ this.isDestroyed = false;
1211
+ this.styleCache = /* @__PURE__ */ new Map();
1212
+ this.gsMap = gsMap;
1213
+ this.env = env;
1214
+ }
1215
+ async reattached() {}
1216
+ async render(container) {
1217
+ try {
1218
+ this.olMap = await olLib({
1219
+ containerSelector: container,
1220
+ gsMap: this.gsMap,
1221
+ env: this.env,
1222
+ mapOptions: { controls: {
1223
+ zoom: false,
1224
+ attribution: false
1225
+ } }
1226
+ });
1227
+ this.operations = new OpenLayersMapOperations(this.olMap, this);
1228
+ this.applyStylesToLayers();
1229
+ this.olMap.once("rendercomplete", () => {
1230
+ this.setupEventListeners();
1231
+ });
1232
+ } catch (error) {
1233
+ console.error("Failed to render map:", error);
1234
+ throw error;
1235
+ }
1236
+ }
1237
+ applyStylesToLayers() {
1238
+ if (!this.olMap) return;
1239
+ this.olMap.getLayers().getArray().forEach((layer$1) => {
1240
+ if (layer$1 instanceof layer.Vector) this.applyStyleToVectorLayer(layer$1);
1241
+ });
1242
+ }
1243
+ applyStyleToVectorLayer(layer) {
1244
+ const layerName = layer.get(KEY_NAME);
1245
+ const styleFunction = (feature) => {
1246
+ if (!(feature instanceof gs_olns_exports.Feature)) return;
1247
+ const featureStyleData = getFeatureStyleData(feature);
1248
+ const styleRules = this.gsMap.styleRules;
1249
+ const stylesMap = this.gsMap.styles;
1250
+ if (styleRules && stylesMap) {
1251
+ const gsStyle = getStyleForFeature(featureStyleData, styleRules, stylesMap, layerName);
1252
+ if (gsStyle && gsStyle.id) {
1253
+ let olStyle = this.styleCache.get(gsStyle.id);
1254
+ if (!olStyle) {
1255
+ olStyle = toOlStyle(gsStyle);
1256
+ this.styleCache.set(gsStyle.id, olStyle);
1257
+ }
1258
+ return olStyle;
1259
+ } else if (gsStyle) return toOlStyle(gsStyle);
1260
+ }
1261
+ };
1262
+ layer.setStyle(styleFunction);
1263
+ }
1264
+ clearStyleCache() {
1265
+ this.styleCache.clear();
1266
+ }
1267
+ async modelToUI(updatedGsMap) {
1268
+ if (!this.olMap) throw new Error("Map not initialized");
1269
+ if (updatedGsMap) this.gsMap = updatedGsMap;
1270
+ this.clearStyleCache();
1271
+ const target = this.olMap.getTarget();
1272
+ if (!target || typeof target === "string") throw new Error("Map container not found or invalid");
1273
+ this.destroy();
1274
+ target.innerHTML = "";
1275
+ this.isDestroyed = false;
1276
+ await this.render(target);
1277
+ }
1278
+ getOperations() {
1279
+ if (!this.operations) throw new Error("Operations not available - map not rendered yet");
1280
+ return this.operations;
1281
+ }
1282
+ async getViewExtent() {
1283
+ console.debug("Getting view extent");
1284
+ if (!this.olMap) throw new Error("Map not available for extent calculation");
1285
+ const extent = this.olMap.getView().calculateExtent();
1286
+ console.debug(`View extent: ${extent}`);
1287
+ return extent;
1288
+ }
1289
+ async captureScreenshot() {
1290
+ if (!this.olMap) return {
1291
+ success: false,
1292
+ error: "Map not available"
1293
+ };
1294
+ const olMap = this.olMap;
1295
+ await new Promise((resolve) => {
1296
+ olMap.renderSync();
1297
+ olMap.once("rendercomplete", () => resolve());
1298
+ setTimeout(() => resolve(), 2e3);
1299
+ });
1300
+ const size = olMap.getSize();
1301
+ const width = size ? size[0] : olMap.getViewport().clientWidth;
1302
+ const height = size ? size[1] : olMap.getViewport().clientHeight;
1303
+ try {
1304
+ const canvas = olMap.getViewport().querySelector("canvas");
1305
+ if (!canvas) return {
1306
+ success: false,
1307
+ error: "Map canvas not found"
1308
+ };
1309
+ return {
1310
+ success: true,
1311
+ dataUrl: canvas.toDataURL("image/png"),
1312
+ width,
1313
+ height
1314
+ };
1315
+ } catch (error) {
1316
+ return {
1317
+ success: false,
1318
+ error: `Failed to capture canvas: ${error.message}`
1319
+ };
1320
+ }
1321
+ }
1322
+ setOnDirty(callback) {
1323
+ this.onDirtyCallback = callback;
1324
+ }
1325
+ setOnSync(callback) {
1326
+ this.onSyncCallback = callback;
1327
+ }
1328
+ triggerDirty() {
1329
+ if (this.isDestroyed || !this.onDirtyCallback) return;
1330
+ this.onDirtyCallback();
1331
+ }
1332
+ triggerSync(event) {
1333
+ if (this.isDestroyed || !this.onSyncCallback) return;
1334
+ this.onSyncCallback(event);
1335
+ }
1336
+ syncViewToModel() {
1337
+ if (!this.olMap) return;
1338
+ const view = this.olMap.getView();
1339
+ const center = view.getCenter();
1340
+ const zoom = view.getZoom();
1341
+ const rotation = view.getRotation();
1342
+ if (center && zoom !== void 0) this.triggerSync({
1343
+ type: "viewChanged",
1344
+ view: {
1345
+ center,
1346
+ zoom,
1347
+ rotation
1348
+ }
1349
+ });
1350
+ }
1351
+ syncLayerFeaturesToModel(layerUuid) {
1352
+ if (!this.olMap) return;
1353
+ const layers = this.olMap.getLayers();
1354
+ let olLayer;
1355
+ for (let i = 0; i < layers.getLength(); i++) {
1356
+ const layer = layers.item(i);
1357
+ if (layer.get("uuid") === layerUuid) {
1358
+ olLayer = layer;
1359
+ break;
1360
+ }
1361
+ }
1362
+ if (!olLayer || !(olLayer instanceof layer.Vector)) return;
1363
+ const source = olLayer.getSource();
1364
+ if (!source) return;
1365
+ const gsFeatures = source.getFeatures().map((olFeature) => toGsFeature(olFeature));
1366
+ this.triggerSync({
1367
+ type: "featuresChanged",
1368
+ layerUuid,
1369
+ features: gsFeatures
1370
+ });
1371
+ }
1372
+ setupEventListeners() {
1373
+ if (!this.olMap) return;
1374
+ this.olMap.getView().on("change:center", () => {
1375
+ this.syncViewToModel();
1376
+ this.triggerDirty();
1377
+ });
1378
+ this.olMap.getView().on("change:resolution", () => {
1379
+ this.syncViewToModel();
1380
+ this.triggerDirty();
1381
+ });
1382
+ this.olMap.getView().on("change:rotation", () => {
1383
+ this.syncViewToModel();
1384
+ this.triggerDirty();
1385
+ });
1386
+ this.olMap.getLayers().on("add", () => this.triggerDirty());
1387
+ this.olMap.getLayers().on("remove", () => this.triggerDirty());
1388
+ this.olMap.getControls().on("add", () => this.triggerDirty());
1389
+ this.olMap.getControls().on("remove", () => this.triggerDirty());
1390
+ this.olMap.getOverlays().on("add", () => this.triggerDirty());
1391
+ this.olMap.getOverlays().on("remove", () => this.triggerDirty());
1392
+ }
1393
+ destroy() {
1394
+ this.isDestroyed = true;
1395
+ this.clearStyleCache();
1396
+ if (this.operations) {
1397
+ const ops = this.operations;
1398
+ if (ops.cleanup) ops.cleanup();
1399
+ }
1400
+ if (this.olMap) cleanupEventSubscriptions(this.olMap);
1401
+ this.olMap?.dispose();
1402
+ this.olMap = void 0;
1403
+ }
1404
+ async transform(coord, options) {
1405
+ if (!this.olMap) throw new Error("Map not available for coordinate transformation");
1406
+ const mapProj = this.olMap.getView().getProjection()?.getCode() || "EPSG:3857";
1407
+ const source = options?.sourceProjection ?? mapProj;
1408
+ const target = options?.targetProjection ?? "EPSG:4326";
1409
+ if (source === target) return coord;
1410
+ return proj.transform(coord, source, target);
1411
+ }
1928
1412
  };
1929
- export {
1930
- default2 as BaseLayer,
1931
- DEFAULT_GSMAP,
1932
- DEFAULT_STYLES,
1933
- DEFAULT_STYLE_RULES,
1934
- DefaultImporter,
1935
- GsControlAdapter,
1936
- GsGeometryType,
1937
- GsLayerType,
1938
- GsOlAdapter,
1939
- GsOlControl,
1940
- GsOlOverlay,
1941
- GsOverlayAdapter,
1942
- GsSourceType,
1943
- KEY_ENV,
1944
- KEY_EVENT_SUBSCRIPTIONS,
1945
- KEY_FORMAT,
1946
- KEY_GS_MANAGED,
1947
- KEY_ICON_PATH,
1948
- KEY_LABEL,
1949
- KEY_NAME,
1950
- KEY_SETTINGS,
1951
- KEY_SOURCETYPE,
1952
- KEY_SRC,
1953
- KEY_STATE,
1954
- KEY_URL,
1955
- KEY_UUID,
1956
- LAYER_GEOCODED_MARKERS,
1957
- OL_LAYERS,
1958
- OL_SOURCES,
1959
- OpenLayersMapRenderer,
1960
- apply2 as applyMapboxStyle,
1961
- buildMap,
1962
- bundleApp,
1963
- cleanupEventSubscriptions,
1964
- createProxy,
1965
- defaults2 as defaultControls,
1966
- defaults3 as defaultInteractions,
1967
- ensureUuid,
1968
- ensureUuidsRecursive,
1969
- evaluateStyleRule,
1970
- events,
1971
- eventsCondition,
1972
- extent,
1973
- findControlByUuid,
1974
- findControlIndexByUuid,
1975
- findLayerByUuid,
1976
- findLayerIndexByUuid,
1977
- findOverlayByUuid,
1978
- findOverlayIndexByUuid,
1979
- format,
1980
- generateAppJs,
1981
- olGeom as geom,
1982
- getStyleForFeature,
1983
- olLib as gsLib,
1984
- importControlSource,
1985
- importOverlaySource,
1986
- interactionNS as interaction,
1987
- layerNS as layer,
1988
- olLib,
1989
- processHtml,
1990
- processManifest,
1991
- processServiceWorker,
1992
- proj,
1993
- resolveScriptLang,
1994
- rtUtils,
1995
- scriptedRuntimeRegistry,
1996
- source,
1997
- sphere,
1998
- style,
1999
- toGsFeature,
2000
- toGsGeometry,
2001
- toGsLayerType,
2002
- toGsSourceType,
2003
- toOLGeometry,
2004
- toOlCircleImage,
2005
- toOlControl,
2006
- toOlFeature,
2007
- toOlFill,
2008
- toOlIconImage,
2009
- toOlImage,
2010
- toOlLayer,
2011
- toOlMap,
2012
- toOlOverlay,
2013
- toOlRegularShapeImage,
2014
- toOlResource,
2015
- toOlSource,
2016
- toOlStroke,
2017
- toOlStyle,
2018
- toOlText,
2019
- toSourceUrl
1413
+ /**
1414
+ * OpenLayers-specific map operations implementation
1415
+ */
1416
+ var OpenLayersMapOperations = class {
1417
+ constructor(olMap, renderer) {
1418
+ this.olMap = olMap;
1419
+ this.renderer = renderer;
1420
+ if (!olMap) throw new Error("OpenLayers map is required for operations");
1421
+ this.keyDownListener = (event) => {
1422
+ if (event.key === "Escape") {
1423
+ if (this.drawInteraction) {
1424
+ this.disableDrawing();
1425
+ this.renderer?.triggerSync({ type: "drawingDisabled" });
1426
+ }
1427
+ if (this.selectInteraction) this.disableSelection();
1428
+ }
1429
+ };
1430
+ const target = this.olMap.getTargetElement();
1431
+ if (target && target instanceof HTMLElement) {
1432
+ target.setAttribute("tabindex", "-1");
1433
+ target.addEventListener("keydown", this.keyDownListener);
1434
+ }
1435
+ }
1436
+ async setZoom(zoom) {
1437
+ this.olMap.getView().setZoom(zoom);
1438
+ }
1439
+ async setCenter(center) {
1440
+ this.olMap.getView().setCenter(center);
1441
+ }
1442
+ async switchColorMode(mode) {
1443
+ const olMap = this.olMap;
1444
+ let darkMode = olMap.get("darkmode") ?? false;
1445
+ if (mode === "dark") darkMode = true;
1446
+ else if (mode === "light") darkMode = false;
1447
+ else darkMode = !darkMode;
1448
+ olMap.set("darkmode", darkMode);
1449
+ document.querySelectorAll("canvas").forEach((canvas) => {
1450
+ canvas.style.filter = darkMode ? "invert(100%)" : "";
1451
+ });
1452
+ olMap.render();
1453
+ }
1454
+ async addLayer(layer, isBasemap) {
1455
+ const olLayer = toOlLayer(layer);
1456
+ if (isBasemap) this.olMap.getLayers().insertAt(0, olLayer);
1457
+ else this.olMap.getLayers().push(olLayer);
1458
+ }
1459
+ async deleteLayer(uuid) {
1460
+ const layers = this.olMap.getLayers();
1461
+ for (let i = 0; i < layers.getLength(); i++) if (layers.item(i).get("uuid") === uuid) {
1462
+ layers.removeAt(i);
1463
+ return;
1464
+ }
1465
+ }
1466
+ async renameLayer(uuid, newName) {
1467
+ const layers = this.olMap.getLayers();
1468
+ for (let i = 0; i < layers.getLength(); i++) {
1469
+ const layer = layers.item(i);
1470
+ if (layer.get("uuid") === uuid) {
1471
+ layer.set(KEY_NAME, newName);
1472
+ return;
1473
+ }
1474
+ }
1475
+ }
1476
+ async moveLayer(uuid, targetUuid) {
1477
+ const layers = this.olMap.getLayers();
1478
+ let fromIndex = -1;
1479
+ let toIndex = -1;
1480
+ for (let i = 0; i < layers.getLength(); i++) {
1481
+ const layer = layers.item(i);
1482
+ if (layer.get("uuid") === uuid) fromIndex = i;
1483
+ if (targetUuid && layer.get("uuid") === targetUuid) toIndex = i;
1484
+ }
1485
+ if (fromIndex < 0) return;
1486
+ if (targetUuid) {
1487
+ if (toIndex < 0 || fromIndex === toIndex) return;
1488
+ } else toIndex = fromIndex > 0 ? fromIndex - 1 : fromIndex + 1;
1489
+ if (toIndex >= 0 && toIndex < layers.getLength() && fromIndex !== toIndex) {
1490
+ const layer = layers.item(fromIndex);
1491
+ layers.removeAt(fromIndex);
1492
+ layers.insertAt(toIndex, layer);
1493
+ }
1494
+ }
1495
+ async setLayerVisible(uuid, visible) {
1496
+ const layers = this.olMap.getLayers();
1497
+ for (let i = 0; i < layers.getLength(); i++) {
1498
+ const layer = layers.item(i);
1499
+ if (layer.get("uuid") === uuid) {
1500
+ layer.setVisible(visible);
1501
+ return;
1502
+ }
1503
+ }
1504
+ }
1505
+ async addControlFromModule(_src) {}
1506
+ async removeControl(_uuid) {}
1507
+ async addOverlayFromModule(_src, _position) {}
1508
+ async removeOverlay(_uuid) {}
1509
+ setCursor(cursor) {
1510
+ const viewport = this.olMap.getViewport();
1511
+ if (viewport) viewport.style.cursor = cursor;
1512
+ }
1513
+ async enableDrawing(geometryType, layerUuid) {
1514
+ this.disableSelection();
1515
+ if (this.drawInteraction) this.olMap.removeInteraction(this.drawInteraction);
1516
+ this.activeDrawingLayerUuid = layerUuid;
1517
+ this.setCursor("crosshair");
1518
+ const layers = this.olMap.getLayers();
1519
+ let layer$2;
1520
+ for (let i = 0; i < layers.getLength(); i++) {
1521
+ const l = layers.item(i);
1522
+ if (l.get("uuid") === layerUuid) {
1523
+ layer$2 = l;
1524
+ break;
1525
+ }
1526
+ }
1527
+ if (!layer$2 || !(layer$2 instanceof layer.Vector)) throw new Error("Drawing only supported on vector layers");
1528
+ const source = layer$2.getSource();
1529
+ if (!source) throw new Error("Layer has no source");
1530
+ const layerSourceType = layer$2.get("sourceType");
1531
+ if (layerSourceType && layerSourceType !== GsSourceType.Features) throw new Error("Drawing only supported on layers with in-memory features");
1532
+ this.drawInteraction = new interaction.Draw({
1533
+ source,
1534
+ type: geometryType
1535
+ });
1536
+ const onFeatureAdded = (event) => {
1537
+ const feature = event.feature;
1538
+ if (feature && !feature.get("uuid")) {
1539
+ const uuid = v4$1();
1540
+ feature.set(KEY_UUID, uuid);
1541
+ const state = feature.get("_state") || {};
1542
+ state.uuid = uuid;
1543
+ feature.set(KEY_STATE, state);
1544
+ }
1545
+ if (this.renderer && this.activeDrawingLayerUuid) this.renderer.syncLayerFeaturesToModel(this.activeDrawingLayerUuid);
1546
+ this.renderer?.triggerDirty();
1547
+ };
1548
+ source.on("addfeature", onFeatureAdded);
1549
+ this.drawInteraction._featureAddedListener = onFeatureAdded;
1550
+ this.drawInteraction._sourceRef = source;
1551
+ this.olMap.addInteraction(this.drawInteraction);
1552
+ }
1553
+ async disableDrawing() {
1554
+ if (this.drawInteraction) {
1555
+ const listener = this.drawInteraction._featureAddedListener;
1556
+ const source = this.drawInteraction._sourceRef;
1557
+ if (listener && source) source.un("addfeature", listener);
1558
+ this.olMap.removeInteraction(this.drawInteraction);
1559
+ this.drawInteraction = void 0;
1560
+ this.setCursor("");
1561
+ }
1562
+ }
1563
+ cleanup() {
1564
+ if (this.keyDownListener) {
1565
+ const target = this.olMap.getTargetElement();
1566
+ if (target && target instanceof HTMLElement) target.removeEventListener("keydown", this.keyDownListener);
1567
+ this.keyDownListener = void 0;
1568
+ }
1569
+ }
1570
+ async enableFeatureSelection() {
1571
+ this.disableDrawing();
1572
+ this.disableSelection();
1573
+ const olLayers = this.olMap.getLayers();
1574
+ const vectorLayers = olLayers.getArray().filter((layer$3) => layer$3 instanceof layer.Vector);
1575
+ if (vectorLayers.length === 0) throw new Error("No vector layers available for selection");
1576
+ const selectionStyle = (this.renderer?.gsMap)?.styles?.["selection"];
1577
+ const selectOptions = {
1578
+ condition: eventsCondition.click,
1579
+ layers: vectorLayers,
1580
+ hitTolerance: 5,
1581
+ style: selectionStyle ? toOlStyle(selectionStyle) : (_feature) => {
1582
+ const stroke = new style.Stroke({
1583
+ color: "rgba(255, 255, 0, 1)",
1584
+ width: 3
1585
+ });
1586
+ const fill = new style.Fill({ color: "rgba(255, 255, 0, 0.3)" });
1587
+ return new style.Style({
1588
+ image: new style.Circle({
1589
+ radius: 7,
1590
+ fill,
1591
+ stroke
1592
+ }),
1593
+ stroke,
1594
+ fill
1595
+ });
1596
+ }
1597
+ };
1598
+ this.selectInteraction = new interaction.Select(selectOptions);
1599
+ this.selectInteraction.on("select", (event) => {
1600
+ if (event.selected.length > 0) {
1601
+ const selectedFeature = event.selected[0];
1602
+ let featureLayerUuid;
1603
+ olLayers.getArray().forEach((layer$4) => {
1604
+ if (layer$4 instanceof layer.Vector) {
1605
+ const source = layer$4.getSource();
1606
+ if (source && source.hasFeature(selectedFeature)) {
1607
+ const uuid = layer$4.get(KEY_UUID);
1608
+ if (uuid) featureLayerUuid = uuid;
1609
+ }
1610
+ }
1611
+ });
1612
+ if (featureLayerUuid && this.renderer) {
1613
+ const gsFeature = toGsFeature(selectedFeature);
1614
+ const geometry = selectedFeature.getGeometry();
1615
+ const metrics = {};
1616
+ if (geometry) {
1617
+ const geometryType = geometry.getType();
1618
+ try {
1619
+ if (geometryType === "LineString" || geometryType === "MultiLineString") metrics.length = sphere.getLength(geometry, { projection: this.olMap.getView().getProjection() });
1620
+ else if (geometryType === "Polygon" || geometryType === "MultiPolygon") {
1621
+ metrics.area = sphere.getArea(geometry, { projection: this.olMap.getView().getProjection() });
1622
+ const coordinates = geometryType === "Polygon" ? geometry.getCoordinates()[0] : geometry.getCoordinates()[0][0];
1623
+ if (coordinates?.length > 0) {
1624
+ const perimeterLine = new geom.LineString(coordinates);
1625
+ metrics.length = sphere.getLength(perimeterLine, { projection: this.olMap.getView().getProjection() });
1626
+ }
1627
+ }
1628
+ } catch (error) {
1629
+ console.warn("Error calculating feature metrics:", error);
1630
+ }
1631
+ }
1632
+ this.renderer.triggerSync({
1633
+ type: "featureSelected",
1634
+ layerUuid: featureLayerUuid,
1635
+ feature: gsFeature,
1636
+ metrics
1637
+ });
1638
+ }
1639
+ } else if (event.deselected.length > 0) this.renderer?.triggerSync({ type: "featureDeselected" });
1640
+ });
1641
+ this.olMap.addInteraction(this.selectInteraction);
1642
+ this.setCursor("pointer");
1643
+ }
1644
+ async deleteSelectedFeatures() {
1645
+ if (!this.selectInteraction) throw new Error("No selection interaction active");
1646
+ const selectedFeatures = this.selectInteraction.getFeatures();
1647
+ if (selectedFeatures.getLength() === 0) throw new Error("No features selected");
1648
+ const layersToSync = /* @__PURE__ */ new Set();
1649
+ const olLayers = this.olMap.getLayers();
1650
+ selectedFeatures.forEach((feature) => {
1651
+ for (let i = 0; i < olLayers.getLength(); i++) {
1652
+ const layer$5 = olLayers.item(i);
1653
+ if (layer$5 instanceof layer.Vector) {
1654
+ const source = layer$5.getSource();
1655
+ if (source && source.hasFeature(feature)) {
1656
+ source.removeFeature(feature);
1657
+ const layerUuid = layer$5.get(KEY_UUID);
1658
+ if (layerUuid) layersToSync.add(layerUuid);
1659
+ break;
1660
+ }
1661
+ }
1662
+ }
1663
+ });
1664
+ selectedFeatures.clear();
1665
+ if (this.renderer && layersToSync.size > 0) layersToSync.forEach((layerUuid) => {
1666
+ this.renderer.syncLayerFeaturesToModel(layerUuid);
1667
+ });
1668
+ this.renderer?.triggerDirty();
1669
+ }
1670
+ async disableSelection() {
1671
+ if (this.selectInteraction) {
1672
+ this.olMap.removeInteraction(this.selectInteraction);
1673
+ this.selectInteraction = void 0;
1674
+ this.setCursor("");
1675
+ this.renderer?.triggerSync({ type: "featureDeselected" });
1676
+ }
1677
+ }
2020
1678
  };
2021
- //# sourceMappingURL=index.js.map
1679
+ //#endregion
1680
+ //#region src/ol/index.ts
1681
+ var ol_exports = /* @__PURE__ */ __exportAll({
1682
+ BaseLayer: () => BaseLayer,
1683
+ DEFAULT_GSMAP: () => DEFAULT_GSMAP,
1684
+ DEFAULT_STYLES: () => DEFAULT_STYLES,
1685
+ DEFAULT_STYLE_RULES: () => DEFAULT_STYLE_RULES,
1686
+ DefaultImporter: () => DefaultImporter,
1687
+ GsControlAdapter: () => GsControlAdapter,
1688
+ GsGeometryType: () => GsGeometryType,
1689
+ GsLayerType: () => GsLayerType,
1690
+ GsOlAdapter: () => GsOlAdapter,
1691
+ GsOlControl: () => GsOlControl,
1692
+ GsOlOverlay: () => GsOlOverlay,
1693
+ GsOverlayAdapter: () => GsOverlayAdapter,
1694
+ GsSourceType: () => GsSourceType,
1695
+ KEY_ENV: () => KEY_ENV,
1696
+ KEY_EVENT_SUBSCRIPTIONS: () => KEY_EVENT_SUBSCRIPTIONS,
1697
+ KEY_FORMAT: () => KEY_FORMAT,
1698
+ KEY_GS_MANAGED: () => KEY_GS_MANAGED,
1699
+ KEY_ICON_PATH: () => KEY_ICON_PATH,
1700
+ KEY_LABEL: () => KEY_LABEL,
1701
+ KEY_NAME: () => KEY_NAME,
1702
+ KEY_SETTINGS: () => KEY_SETTINGS,
1703
+ KEY_SOURCETYPE: () => KEY_SOURCETYPE,
1704
+ KEY_SRC: () => "src",
1705
+ KEY_STATE: () => KEY_STATE,
1706
+ KEY_URL: () => "url",
1707
+ KEY_UUID: () => KEY_UUID,
1708
+ LAYER_GEOCODED_MARKERS: () => LAYER_GEOCODED_MARKERS,
1709
+ OL_LAYERS: () => OL_LAYERS,
1710
+ OL_SOURCES: () => OL_SOURCES,
1711
+ OpenLayersMapRenderer: () => OpenLayersMapRenderer,
1712
+ applyMapboxStyle: () => applyMapboxStyle,
1713
+ cleanupEventSubscriptions: () => cleanupEventSubscriptions,
1714
+ createProxy: () => createProxy,
1715
+ defaultControls: () => defaultControls,
1716
+ defaultInteractions: () => defaultInteractions,
1717
+ ensureUuid: () => ensureUuid,
1718
+ ensureUuidsRecursive: () => ensureUuidsRecursive,
1719
+ evaluateStyleRule: () => evaluateStyleRule,
1720
+ events: () => events,
1721
+ eventsCondition: () => eventsCondition,
1722
+ extent: () => extent,
1723
+ findControlByUuid: () => findControlByUuid,
1724
+ findControlIndexByUuid: () => findControlIndexByUuid,
1725
+ findLayerByUuid: () => findLayerByUuid,
1726
+ findLayerIndexByUuid: () => findLayerIndexByUuid,
1727
+ findOverlayByUuid: () => findOverlayByUuid,
1728
+ findOverlayIndexByUuid: () => findOverlayIndexByUuid,
1729
+ format: () => format,
1730
+ geom: () => geom,
1731
+ getStyleForFeature: () => getStyleForFeature,
1732
+ importControlSource: () => importControlSource,
1733
+ importOverlaySource: () => importOverlaySource,
1734
+ interaction: () => interaction,
1735
+ layer: () => layer,
1736
+ olLib: () => olLib,
1737
+ proj: () => proj,
1738
+ resolveScriptLang: () => resolveScriptLang,
1739
+ source: () => source,
1740
+ sphere: () => sphere,
1741
+ style: () => style,
1742
+ toGsFeature: () => toGsFeature,
1743
+ toGsGeometry: () => toGsGeometry,
1744
+ toGsLayerType: () => toGsLayerType,
1745
+ toGsSourceType: () => toGsSourceType,
1746
+ toOLGeometry: () => toOLGeometry,
1747
+ toOlCircleImage: () => toOlCircleImage,
1748
+ toOlControl: () => toOlControl,
1749
+ toOlFeature: () => toOlFeature,
1750
+ toOlFill: () => toOlFill,
1751
+ toOlIconImage: () => toOlIconImage,
1752
+ toOlImage: () => toOlImage,
1753
+ toOlLayer: () => toOlLayer,
1754
+ toOlMap: () => toOlMap,
1755
+ toOlOverlay: () => toOlOverlay,
1756
+ toOlRegularShapeImage: () => toOlRegularShapeImage,
1757
+ toOlResource: () => toOlResource,
1758
+ toOlSource: () => toOlSource,
1759
+ toOlStroke: () => toOlStroke,
1760
+ toOlStyle: () => toOlStyle,
1761
+ toOlText: () => toOlText,
1762
+ toSourceUrl: () => toSourceUrl
1763
+ });
1764
+ __reExport(ol_exports, gs_olns_exports);
1765
+ __reExport(/* @__PURE__ */ __exportAll({
1766
+ BaseLayer: () => BaseLayer,
1767
+ DEFAULT_GSMAP: () => DEFAULT_GSMAP,
1768
+ DEFAULT_STYLES: () => DEFAULT_STYLES,
1769
+ DEFAULT_STYLE_RULES: () => DEFAULT_STYLE_RULES,
1770
+ DefaultImporter: () => DefaultImporter,
1771
+ GsControlAdapter: () => GsControlAdapter,
1772
+ GsGeometryType: () => GsGeometryType,
1773
+ GsLayerType: () => GsLayerType,
1774
+ GsOlAdapter: () => GsOlAdapter,
1775
+ GsOlControl: () => GsOlControl,
1776
+ GsOlOverlay: () => GsOlOverlay,
1777
+ GsOverlayAdapter: () => GsOverlayAdapter,
1778
+ GsSourceType: () => GsSourceType,
1779
+ KEY_ENV: () => KEY_ENV,
1780
+ KEY_EVENT_SUBSCRIPTIONS: () => KEY_EVENT_SUBSCRIPTIONS,
1781
+ KEY_FORMAT: () => KEY_FORMAT,
1782
+ KEY_GS_MANAGED: () => KEY_GS_MANAGED,
1783
+ KEY_ICON_PATH: () => KEY_ICON_PATH,
1784
+ KEY_LABEL: () => KEY_LABEL,
1785
+ KEY_NAME: () => KEY_NAME,
1786
+ KEY_SETTINGS: () => KEY_SETTINGS,
1787
+ KEY_SOURCETYPE: () => KEY_SOURCETYPE,
1788
+ KEY_SRC: () => "src",
1789
+ KEY_STATE: () => KEY_STATE,
1790
+ KEY_URL: () => "url",
1791
+ KEY_UUID: () => KEY_UUID,
1792
+ LAYER_GEOCODED_MARKERS: () => LAYER_GEOCODED_MARKERS,
1793
+ OL_LAYERS: () => OL_LAYERS,
1794
+ OL_SOURCES: () => OL_SOURCES,
1795
+ OpenLayersMapRenderer: () => OpenLayersMapRenderer,
1796
+ applyMapboxStyle: () => applyMapboxStyle,
1797
+ buildMap: () => buildMap,
1798
+ bundleApp: () => bundleApp,
1799
+ cleanupEventSubscriptions: () => cleanupEventSubscriptions,
1800
+ createProxy: () => createProxy,
1801
+ defaultControls: () => defaultControls,
1802
+ defaultInteractions: () => defaultInteractions,
1803
+ ensureUuid: () => ensureUuid,
1804
+ ensureUuidsRecursive: () => ensureUuidsRecursive,
1805
+ evaluateStyleRule: () => evaluateStyleRule,
1806
+ events: () => events,
1807
+ eventsCondition: () => eventsCondition,
1808
+ extent: () => extent,
1809
+ findControlByUuid: () => findControlByUuid,
1810
+ findControlIndexByUuid: () => findControlIndexByUuid,
1811
+ findLayerByUuid: () => findLayerByUuid,
1812
+ findLayerIndexByUuid: () => findLayerIndexByUuid,
1813
+ findOverlayByUuid: () => findOverlayByUuid,
1814
+ findOverlayIndexByUuid: () => findOverlayIndexByUuid,
1815
+ format: () => format,
1816
+ generateAppJs: () => generateAppJs,
1817
+ geom: () => geom,
1818
+ getStyleForFeature: () => getStyleForFeature,
1819
+ gsLib: () => olLib,
1820
+ importControlSource: () => importControlSource,
1821
+ importOverlaySource: () => importOverlaySource,
1822
+ interaction: () => interaction,
1823
+ layer: () => layer,
1824
+ olLib: () => olLib,
1825
+ processHtml: () => processHtml,
1826
+ processManifest: () => processManifest,
1827
+ processServiceWorker: () => processServiceWorker,
1828
+ proj: () => proj,
1829
+ resolveScriptLang: () => resolveScriptLang,
1830
+ rtUtils: () => rtUtils,
1831
+ scriptedRuntimeRegistry: () => scriptedRuntimeRegistry,
1832
+ source: () => source,
1833
+ sphere: () => sphere,
1834
+ style: () => style,
1835
+ toGsFeature: () => toGsFeature,
1836
+ toGsGeometry: () => toGsGeometry,
1837
+ toGsLayerType: () => toGsLayerType,
1838
+ toGsSourceType: () => toGsSourceType,
1839
+ toOLGeometry: () => toOLGeometry,
1840
+ toOlCircleImage: () => toOlCircleImage,
1841
+ toOlControl: () => toOlControl,
1842
+ toOlFeature: () => toOlFeature,
1843
+ toOlFill: () => toOlFill,
1844
+ toOlIconImage: () => toOlIconImage,
1845
+ toOlImage: () => toOlImage,
1846
+ toOlLayer: () => toOlLayer,
1847
+ toOlMap: () => toOlMap,
1848
+ toOlOverlay: () => toOlOverlay,
1849
+ toOlRegularShapeImage: () => toOlRegularShapeImage,
1850
+ toOlResource: () => toOlResource,
1851
+ toOlSource: () => toOlSource,
1852
+ toOlStroke: () => toOlStroke,
1853
+ toOlStyle: () => toOlStyle,
1854
+ toOlText: () => toOlText,
1855
+ toSourceUrl: () => toSourceUrl
1856
+ }), ol_exports);
1857
+ var rtUtils = { async resolveUrl(url) {
1858
+ return url;
1859
+ } };
1860
+ //#endregion
1861
+ export { BaseLayer, DEFAULT_GSMAP, DEFAULT_STYLES, DEFAULT_STYLE_RULES, DefaultImporter, GsControlAdapter, GsGeometryType, GsLayerType, GsOlAdapter, GsOlControl, GsOlOverlay, GsOverlayAdapter, GsSourceType, KEY_ENV, KEY_EVENT_SUBSCRIPTIONS, KEY_FORMAT, KEY_GS_MANAGED, KEY_ICON_PATH, KEY_LABEL, KEY_NAME, KEY_SETTINGS, KEY_SOURCETYPE, KEY_SRC, KEY_STATE, KEY_URL, KEY_UUID, LAYER_GEOCODED_MARKERS, OL_LAYERS, OL_SOURCES, OpenLayersMapRenderer, applyMapboxStyle, buildMap, bundleApp, cleanupEventSubscriptions, createProxy, defaultControls, defaultInteractions, ensureUuid, ensureUuidsRecursive, evaluateStyleRule, events, eventsCondition, extent, findControlByUuid, findControlIndexByUuid, findLayerByUuid, findLayerIndexByUuid, findOverlayByUuid, findOverlayIndexByUuid, format, generateAppJs, geom, getStyleForFeature, olLib as gsLib, olLib, importControlSource, importOverlaySource, interaction, layer, processHtml, processManifest, processServiceWorker, proj, resolveScriptLang, rtUtils, scriptedRuntimeRegistry, source, sphere, style, toGsFeature, toGsGeometry, toGsLayerType, toGsSourceType, toOLGeometry, toOlCircleImage, toOlControl, toOlFeature, toOlFill, toOlIconImage, toOlImage, toOlLayer, toOlMap, toOlOverlay, toOlRegularShapeImage, toOlResource, toOlSource, toOlStroke, toOlStyle, toOlText, toSourceUrl };
1862
+
1863
+ //# sourceMappingURL=index.js.map