@feltmaps/js-sdk 1.5.0-next.6 → 1.5.0-next.7

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/client.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var y=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var G=Object.getOwnPropertyNames;var S=Object.prototype.hasOwnProperty;var b=(e,n)=>{for(var r in n)y(e,r,{get:n[r],enumerable:!0})},x=(e,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of G(n))!S.call(e,l)&&l!==r&&y(e,l,{get:()=>n[l],enumerable:!(s=F(n,l))||s.enumerable});return e};var I=e=>x(y({},"__esModule",{value:!0}),e);var K={};b(K,{Felt:()=>M});module.exports=I(K);function o(e,n){return r=>{let s=new MessageChannel,l=r.handler,i="options"in r?r.options:void 0,a=crypto.randomUUID();return e.postMessage({type:"felt.addListener",event:i?{eventName:n,id:a,options:i}:{eventName:n,id:a}},"*",[s.port2]),s.port1.onmessage=d=>{l(d.data)},()=>{s.port1.onmessage=null,s.port1.close(),s.port2.close(),e.postMessage({type:"felt.removeListener",id:a},"*")}}}function t(e,n){return r=>{let s=new MessageChannel;return e.postMessage({type:n,params:r},"*",[s.port2]),new Promise((l,i)=>{s.port1.onmessage=a=>{a.data&&typeof a.data=="object"&&"__error__"in a.data?i(new Error(a.data.__error__)):l(a.data),s.port1.close(),s.port2.close()}})}}var u=e=>({getElement:t(e,"getElement"),getElementGeometry:t(e,"getElementGeometry"),getElements:t(e,"getElements"),setElementGroupVisibility:t(e,"setElementGroupVisibility"),getElementGroup:t(e,"getElementGroup"),getElementGroups:t(e,"getElementGroups"),onElementChange:o(e,"onElementChange"),onElementCreate:o(e,"onElementCreate"),onElementDelete:o(e,"onElementDelete"),onElementGroupChange:o(e,"onElementGroupChange"),createElement:t(e,"createElement"),updateElement:t(e,"updateElement"),deleteElement:t(e,"deleteElement")});var C=e=>({onPointerClick:o(e,"onPointerClick"),onPointerMove:o(e,"onPointerMove")});var h=e=>({getLayer:t(e,"getLayer"),getLayers:t(e,"getLayers"),setLayerVisibility:t(e,"setLayerVisibility"),setLayerStyle:t(e,"setLayerStyle"),setLayerLegendVisibility:t(e,"setLayerLegendVisibility"),onLayerChange:o(e,"onLayerChange"),getLayerGroup:t(e,"getLayerGroup"),getLayerGroups:t(e,"getLayerGroups"),setLayerGroupVisibility:t(e,"setLayerGroupVisibility"),setLayerGroupLegendVisibility:t(e,"setLayerGroupLegendVisibility"),onLayerGroupChange:o(e,"onLayerGroupChange"),getLegendItem:t(e,"getLegendItem"),getLegendItems:t(e,"getLegendItems"),setLegendItemVisibility:t(e,"setLegendItemVisibility"),onLegendItemChange:o(e,"onLegendItemChange"),getLayerFilters:t(e,"getLayerFilters"),setLayerFilters:t(e,"setLayerFilters"),getRenderedFeatures:t(e,"getRenderedFeatures"),getCategoryData:t(e,"getCategoryData"),getHistogramData:t(e,"getHistogramData"),getAggregates:t(e,"getAggregates")});var L=e=>({getMapDetails:t(e,"getMapDetails")});var T=e=>({onSelectionChange:o(e,"onSelectionChange"),getSelection:t(e,"getSelection"),selectFeature:t(e,"selectFeature"),clearSelection:t(e,"clearSelection")});var E=e=>({setTool:t(e,"setTool"),getTool:t(e,"getTool"),onToolChange:o(e,"onToolChange"),setToolSettings:t(e,"setToolSettings"),getToolSettings:t(e,"getToolSettings"),onToolSettingsChange:o(e,"onToolSettingsChange")});var v=e=>({updateUiControls:t(e,"updateUiControls"),setOnMapInteractionsUi:t(e,"setOnMapInteractionsUi")});var P=e=>({getViewport:t(e,"getViewport"),setViewport:t(e,"setViewport"),getViewportConstraints:t(e,"getViewportConstraints"),setViewportConstraints:t(e,"setViewportConstraints"),fitViewportToBounds:t(e,"fitViewportToBounds"),onViewportMove:o(e,"onViewportMove"),onViewportMoveEnd:o(e,"onViewportMoveEnd"),onMapIdle:o(e,"onMapIdle")});function V(e){return{iframe:null,...P(e),...v(e),...h(e),...u(e),...T(e),...C(e),...E(e),...L(e)}}var M={embed(e,n,r){let s={uiControls:{showLegend:!0,cooperativeGestures:!0,fullScreenButton:!0,geolocation:!1,zoomControls:!0,scaleBar:!0},initialViewport:void 0,origin:"https://felt.com"},l=r?.origin??s.origin,i=new URL(`${l}/embed/map/${n}`),a={showLegend:"legend",cooperativeGestures:"cooperativeGestures",fullScreenButton:"link",geolocation:"geolocation",zoomControls:"zoomControls",scaleBar:"scaleBar"},d={...s.uiControls,...r?.uiControls};for(let[p,g]of f(d))g!=null&&i.searchParams.set(a[p],g?"1":"0");if(r?.token&&i.searchParams.set("token",r.token),r?.initialViewport){let p=r.initialViewport;i.searchParams.set("loc",`${p.center.latitude},${p.center.longitude},${p.zoom}z`)}let c=e.tagName==="IFRAME",m=c?e:e.ownerDocument.createElement("iframe");return m.src=i.toString(),c||(m.style.width="100%",m.style.height="100%",m.style.border="none",m.style.margin="0",e.appendChild(m)),m.referrerPolicy="strict-origin-when-cross-origin",new Promise((p,g)=>{m.addEventListener("load",()=>{m.contentWindow==null?g(new Error("Failed to load Felt map")):p(m.contentWindow)},{once:!0})}).then(M.connect).then(p=>(Object.defineProperties(p,{iframe:{value:m,writable:!1,configurable:!1}}),p))},connect(e){let n=V(e);return new Promise((r,s)=>{let l=setTimeout(()=>{s(new Error("Failed to load Felt map")),clearInterval(a)},5e3),i=new MessageChannel,a=setInterval(()=>{e.postMessage({type:"felt.ready"},"*",[i.port2])},100);i.port1.onmessage=d=>{d.data===!0&&(clearInterval(a),clearTimeout(l),i.port1.close(),i.port2.close(),r(n))}})}},f=Object.entries;0&&(module.exports={Felt});
1
+ "use strict";var g=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var F=Object.prototype.hasOwnProperty;var G=(e,n)=>{for(var r in n)g(e,r,{get:n[r],enumerable:!0})},I=(e,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of S(n))!F.call(e,l)&&l!==r&&g(e,l,{get:()=>n[l],enumerable:!(s=b(n,l))||s.enumerable});return e};var x=e=>I(g({},"__esModule",{value:!0}),e);var K={};G(K,{Felt:()=>M});module.exports=x(K);function o(e,n){return r=>{let s=new MessageChannel,l=r.handler,a="options"in r?r.options:void 0,i=crypto.randomUUID();return e.postMessage({type:"felt.addListener",event:a?{eventName:n,id:i,options:a}:{eventName:n,id:i}},"*",[s.port2]),s.port1.onmessage=d=>{l(d.data)},()=>{s.port1.onmessage=null,s.port1.close(),s.port2.close(),e.postMessage({type:"felt.removeListener",id:i},"*")}}}function t(e,n){return r=>{let s=new MessageChannel;return e.postMessage({type:n,params:r},"*",[s.port2]),new Promise((l,a)=>{s.port1.onmessage=i=>{i.data&&typeof i.data=="object"&&"__error__"in i.data?a(new Error(i.data.__error__)):l(i.data),s.port1.close(),s.port2.close()}})}}var u=e=>({getElement:t(e,"getElement"),getElementGeometry:t(e,"getElementGeometry"),getElements:t(e,"getElements"),setElementGroupVisibility:t(e,"setElementGroupVisibility"),getElementGroup:t(e,"getElementGroup"),getElementGroups:t(e,"getElementGroups"),onElementChange:o(e,"onElementChange"),onElementCreate:o(e,"onElementCreate"),onElementCreateEnd:o(e,"onElementCreateEnd"),onElementDelete:o(e,"onElementDelete"),onElementGroupChange:o(e,"onElementGroupChange"),createElement:t(e,"createElement"),updateElement:t(e,"updateElement"),deleteElement:t(e,"deleteElement")});var C=e=>({onPointerClick:o(e,"onPointerClick"),onPointerMove:o(e,"onPointerMove")});var h=e=>({getLayer:t(e,"getLayer"),getLayers:t(e,"getLayers"),setLayerVisibility:t(e,"setLayerVisibility"),setLayerStyle:t(e,"setLayerStyle"),setLayerLegendVisibility:t(e,"setLayerLegendVisibility"),onLayerChange:o(e,"onLayerChange"),getLayerGroup:t(e,"getLayerGroup"),getLayerGroups:t(e,"getLayerGroups"),setLayerGroupVisibility:t(e,"setLayerGroupVisibility"),setLayerGroupLegendVisibility:t(e,"setLayerGroupLegendVisibility"),onLayerGroupChange:o(e,"onLayerGroupChange"),getLegendItem:t(e,"getLegendItem"),getLegendItems:t(e,"getLegendItems"),setLegendItemVisibility:t(e,"setLegendItemVisibility"),onLegendItemChange:o(e,"onLegendItemChange"),getLayerFilters:t(e,"getLayerFilters"),setLayerFilters:t(e,"setLayerFilters"),getRenderedFeatures:t(e,"getRenderedFeatures"),getCategoryData:t(e,"getCategoryData"),getHistogramData:t(e,"getHistogramData"),getAggregates:t(e,"getAggregates")});var L=e=>({getMapDetails:t(e,"getMapDetails")});var T=e=>({onSelectionChange:o(e,"onSelectionChange"),getSelection:t(e,"getSelection"),selectFeature:t(e,"selectFeature"),clearSelection:t(e,"clearSelection")});var E=e=>({setTool:t(e,"setTool"),getTool:t(e,"getTool"),onToolChange:o(e,"onToolChange"),setToolSettings:t(e,"setToolSettings"),getToolSettings:t(e,"getToolSettings"),onToolSettingsChange:o(e,"onToolSettingsChange")});var v=e=>({updateUiControls:t(e,"updateUiControls"),setOnMapInteractionsUi:t(e,"setOnMapInteractionsUi"),showLayerDataTable:t(e,"showLayerDataTable"),hideLayerDataTable:t(e,"hideLayerDataTable")});var P=e=>({getViewport:t(e,"getViewport"),setViewport:t(e,"setViewport"),getViewportConstraints:t(e,"getViewportConstraints"),setViewportConstraints:t(e,"setViewportConstraints"),fitViewportToBounds:t(e,"fitViewportToBounds"),onViewportMove:o(e,"onViewportMove"),onViewportMoveEnd:o(e,"onViewportMoveEnd"),onMapIdle:o(e,"onMapIdle")});function V(e){return{iframe:null,...P(e),...v(e),...h(e),...u(e),...T(e),...C(e),...E(e),...L(e)}}var M={embed(e,n,r){let s={uiControls:{showLegend:!0,cooperativeGestures:!0,fullScreenButton:!0,geolocation:!1,zoomControls:!0,scaleBar:!0},initialViewport:void 0,origin:"https://felt.com"},l=r?.origin??s.origin,a=new URL(`${l}/embed/map/${n}`),i={showLegend:"legend",cooperativeGestures:"cooperativeGestures",fullScreenButton:"link",geolocation:"geolocation",zoomControls:"zoomControls",scaleBar:"scaleBar"},d={...s.uiControls,...r?.uiControls};for(let[p,y]of f(d))y!=null&&a.searchParams.set(i[p],y?"1":"0");if(r?.token&&a.searchParams.set("token",r.token),r?.initialViewport){let p=r.initialViewport;a.searchParams.set("loc",`${p.center.latitude},${p.center.longitude},${p.zoom}z`)}let c=e.tagName==="IFRAME",m=c?e:e.ownerDocument.createElement("iframe");return m.src=a.toString(),c||(m.style.width="100%",m.style.height="100%",m.style.border="none",m.style.margin="0",e.appendChild(m)),m.referrerPolicy="strict-origin-when-cross-origin",new Promise((p,y)=>{m.addEventListener("load",()=>{m.contentWindow==null?y(new Error("Failed to load Felt map")):p(m.contentWindow)},{once:!0})}).then(M.connect).then(p=>(Object.defineProperties(p,{iframe:{value:m,writable:!1,configurable:!1}}),p))},connect(e){let n=V(e);return new Promise((r,s)=>{let l=setTimeout(()=>{s(new Error("Failed to load Felt map")),clearInterval(i)},5e3),a=new MessageChannel,i=setInterval(()=>{e.postMessage({type:"felt.ready"},"*",[a.port2])},100);a.port1.onmessage=d=>{d.data===!0&&(clearInterval(i),clearTimeout(l),a.port1.close(),a.port2.close(),r(n))}})}},f=Object.entries;0&&(module.exports={Felt});
package/dist/client.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as Element, G as Geometry, a as GetElementsConstraint, b as ElementGroup, c as GetElementGroupsConstraint, S as SetVisibilityRequest, d as ElementChangeCallbackParams, e as ElementGroupChangeCallbackParams, f as ElementCreate, g as ElementUpdate, L as Layer, h as GetLayersConstraint, i as LayerChangeCallbackParams, j as LayerGroup, k as GetLayerGroupsConstraint, l as LayerGroupChangeCallbackParams, m as LegendItemIdentifier, n as LegendItem, o as LegendItemsConstraint, p as LegendItemChangeCallbackParams, q as LayerFilters, F as Filters, r as GetRenderedFeaturesConstraint, s as Feature, t as GetLayerCategoriesParams, u as GetLayerCategoriesGroup, v as GetLayerHistogramParams, w as GetLayerHistogramBin, A as AggregationMethod, x as GetLayerCalculationParams, M as MapInteractionEvent, y as MapDetails, z as EntityNode, B as FeatureSelection, T as ToolType, I as InputToolSettings, C as ConfigurableToolType, D as ToolSettingsMap, H as ToolSettingsChangeEvent, J as zInfer, V as ViewportState, K as SetViewportCenterZoomParams, N as ViewportConstraints, O as ViewportFitBoundsParams, P as ViewportCenterZoom } from './types-CQwkpLq-.cjs';
2
- export { ao as AggregationConfig, Q as CircleElementCreate, R as CircleElementRead, U as CircleElementUpdate, aF as CircleToolSettings, ar as ElementGroupNode, as as ElementNode, at as FeatureNode, aw as FeltBoundary, ax as FeltZoom, al as FilterExpression, am as FilterLogicGate, an as FilterTernary, W as HighlighterElementCreate, X as HighlighterElementRead, Y as HighlighterElementUpdate, aG as HighlighterToolSettings, Z as ImageElementCreate, _ as ImageElementRead, $ as ImageElementUpdate, ay as LatLng, au as LayerGroupNode, av as LayerNode, aj as LayerProcessingStatus, az as LineStringGeometry, aH as LineToolSettings, a0 as LinkElementRead, aA as LngLatTuple, a1 as MarkerElementCreate, a2 as MarkerElementRead, a3 as MarkerElementUpdate, aI as MarkerToolSettings, ap as MultiAggregationConfig, aB as MultiLineStringGeometry, aC as MultiPolygonGeometry, a4 as NoteElementCreate, a5 as NoteElementRead, a6 as NoteElementUpdate, aJ as NoteToolSettings, a7 as PathElementCreate, a8 as PathElementRead, a9 as PathElementUpdate, aK as PinToolSettings, aa as PlaceElementCreate, ab as PlaceElementRead, ac as PlaceElementUpdate, aL as PlaceFrame, aM as PlaceSymbol, aD as PointGeometry, ad as PolygonElementCreate, ae as PolygonElementRead, af as PolygonElementUpdate, aE as PolygonGeometry, aN as PolygonToolSettings, ak as RasterValue, aO as RouteToolSettings, ag as TextElementCreate, ah as TextElementRead, ai as TextElementUpdate, aP as TextToolSettings, aq as ValueConfiguration } from './types-CQwkpLq-.cjs';
1
+ import { E as Element, G as Geometry, a as GetElementsConstraint, b as ElementGroup, c as GetElementGroupsConstraint, S as SetVisibilityRequest, d as ElementChangeCallbackParams, e as ElementGroupChangeCallbackParams, f as ElementCreate, g as ElementUpdate, L as Layer, h as GetLayersConstraint, i as LayerChangeCallbackParams, j as LayerGroup, k as GetLayerGroupsConstraint, l as LayerGroupChangeCallbackParams, m as LegendItemIdentifier, n as LegendItem, o as LegendItemsConstraint, p as LegendItemChangeCallbackParams, q as LayerFilters, F as Filters, r as GetRenderedFeaturesConstraint, s as Feature, t as GetLayerCategoriesParams, u as GetLayerCategoriesGroup, v as GetLayerHistogramParams, w as GetLayerHistogramBin, A as AggregationMethod, x as GetLayerCalculationParams, M as MapInteractionEvent, y as MapDetails, z as EntityNode, B as FeatureSelection, T as ToolType, I as InputToolSettings, C as ConfigurableToolType, D as ToolSettingsMap, H as ToolSettingsChangeEvent, J as zInfer, K as SortConfig, V as ViewportState, N as SetViewportCenterZoomParams, O as ViewportConstraints, P as ViewportFitBoundsParams, Q as ViewportCenterZoom } from './types-XLCA2cX-.cjs';
2
+ export { ap as AggregationConfig, R as CircleElementCreate, U as CircleElementRead, W as CircleElementUpdate, aH as CircleToolSettings, as as ElementGroupNode, at as ElementNode, au as FeatureNode, ax as FeltBoundary, ay as FeltZoom, am as FilterExpression, an as FilterLogicGate, ao as FilterTernary, X as HighlighterElementCreate, Y as HighlighterElementRead, Z as HighlighterElementUpdate, aI as HighlighterToolSettings, _ as ImageElementCreate, $ as ImageElementRead, a0 as ImageElementUpdate, az as LatLng, av as LayerGroupNode, aw as LayerNode, ak as LayerProcessingStatus, aA as LineStringGeometry, aJ as LineToolSettings, a1 as LinkElementRead, aB as LngLatTuple, a2 as MarkerElementCreate, a3 as MarkerElementRead, a4 as MarkerElementUpdate, aK as MarkerToolSettings, aq as MultiAggregationConfig, aC as MultiLineStringGeometry, aD as MultiPolygonGeometry, a5 as NoteElementCreate, a6 as NoteElementRead, a7 as NoteElementUpdate, aL as NoteToolSettings, a8 as PathElementCreate, a9 as PathElementRead, aa as PathElementUpdate, aM as PinToolSettings, ab as PlaceElementCreate, ac as PlaceElementRead, ad as PlaceElementUpdate, aN as PlaceFrame, aO as PlaceSymbol, aE as PointGeometry, ae as PolygonElementCreate, af as PolygonElementRead, ag as PolygonElementUpdate, aF as PolygonGeometry, aP as PolygonToolSettings, al as RasterValue, aQ as RouteToolSettings, aG as SortDirection, ah as TextElementCreate, ai as TextElementRead, aj as TextElementUpdate, aR as TextToolSettings, ar as ValueConfiguration } from './types-XLCA2cX-.cjs';
3
3
  import { z } from 'zod';
4
4
 
5
5
  /**
@@ -62,7 +62,7 @@ interface ElementsController {
62
62
  *
63
63
  * @example
64
64
  * ```typescript
65
- * felt.getElementGroup("element-group-1");
65
+ * const elementGroup = await felt.getElementGroup("element-group-1");
66
66
  * ```
67
67
  * @returns The requested element group.
68
68
  */
@@ -111,13 +111,67 @@ interface ElementsController {
111
111
  /**
112
112
  * The handler that is called when an element is created.
113
113
  *
114
+ * This will fire when elements are created programatically, or when the
115
+ * user starts creating an element with a drawing tool.
116
+ *
117
+ * When the user creates an element with a drawing tool, it can begin in
118
+ * an invalid state, such as if you've just placed a single point in a polygon.
119
+ *
120
+ * You can use the `isBeingCreated` property to determine if the element is
121
+ * still being created by a drawing tool.
122
+ *
123
+ * If you want to know when the element is finished being created, you can
124
+ * use the `onToolCreateElementEnd` listener.
125
+ *
114
126
  * @param change - An object describing the change that occurred.
115
127
  */
116
128
  handler: (change: ElementChangeCallbackParams) => void;
117
129
  }): VoidFunction;
130
+ /**
131
+ * Listens for when a new element is finished being created by a drawing tool.
132
+ *
133
+ * This differs from the `onElementCreate` listener, which fires whenever an
134
+ * element is first created. This fires when the user finishes creating an element
135
+ * which could be after a series of interactions.
136
+ *
137
+ * For example, when creating a polygon, the user places a series of points then
138
+ * finishes by pressing Enter or Escape. Or when creating a Place element, they
139
+ * add the marker, type a label, then finally deselect the element.
140
+ *
141
+ * @returns A function to unsubscribe from the listener
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * const unsubscribe = felt.onToolCreatedElement({
146
+ * handler: (params) => console.log(params),
147
+ * });
148
+ *
149
+ * // later on...
150
+ * unsubscribe();
151
+ * ```
152
+ */
153
+ onElementCreateEnd(args: {
154
+ /**
155
+ * The handler to call whenever this event fires.
156
+ *
157
+ * @param params - An object containing the element that was created.
158
+ */
159
+ handler: (params: {
160
+ element: Element;
161
+ }) => void;
162
+ }): VoidFunction;
118
163
  /**
119
164
  * Adds a listener for when an element changes.
120
165
  *
166
+ * This will fire when an element is being edited, either on the map by the user
167
+ * or programatically.
168
+ *
169
+ * Like the `onElementCreate` listener, this will fire when an element is
170
+ * still being created by a drawing tool.
171
+ *
172
+ * You can check the `isBeingCreated` property to determine if the element is
173
+ * still being created by a drawing tool.
174
+ *
121
175
  * @returns A function to unsubscribe from the listener
122
176
  *
123
177
  * @event
@@ -235,7 +289,7 @@ interface LayersController {
235
289
  *
236
290
  * @example
237
291
  * ```typescript
238
- * const layers = await felt.getLayer({ ids: ["layer-1", "layer-2"] });
292
+ * const layer = await felt.getLayer("layer-1");
239
293
  * ```
240
294
  * @returns The requested layer.
241
295
  */
@@ -356,7 +410,7 @@ interface LayersController {
356
410
  *
357
411
  * @example
358
412
  * ```typescript
359
- * felt.getLayerGroup("layer-group-1");
413
+ * const layerGroup = await felt.getLayerGroup("layer-group-1");
360
414
  * ```
361
415
  * @returns The requested layer group.
362
416
  */
@@ -869,7 +923,7 @@ interface ToolsController {
869
923
  * @param tool - The tool to set.
870
924
  *
871
925
  * @example
872
- * ```ts
926
+ * ```typescript
873
927
  * // Set the tool to "marker"
874
928
  * felt.setTool("marker");
875
929
  *
@@ -884,7 +938,7 @@ interface ToolsController {
884
938
  * @returns The current tool, or `null` if no tool is in use.
885
939
  *
886
940
  * @example
887
- * ```ts
941
+ * ```typescript
888
942
  * const tool = await felt.getTool(); // "marker", "polygon", etc.
889
943
  * ```
890
944
  */
@@ -895,7 +949,7 @@ interface ToolsController {
895
949
  * @returns A function to unsubscribe from the listener
896
950
  *
897
951
  * @example
898
- * ```ts
952
+ * ```typescript
899
953
  * const unsubscribe = felt.onToolChange({
900
954
  * handler: tool => console.log(tool),
901
955
  * });
@@ -1073,8 +1127,10 @@ declare const UiOnMapInteractionsOptionsSchema: z.ZodObject<{
1073
1127
  }>;
1074
1128
 
1075
1129
  /**
1076
- * The UI controller allows you to enable and disable UI controls on the
1077
- * embedded map.
1130
+ * The UI controller allows you to control various aspects of the Felt UI in your embedded map.
1131
+ *
1132
+ * This includes enabling/disabling UI controls, managing on-map interactions, and controlling
1133
+ * the visibility of UI components like the data table.
1078
1134
  *
1079
1135
  * @group Controller
1080
1136
  * @public
@@ -1098,6 +1154,42 @@ interface UiController {
1098
1154
  * will still be selected when clicked.
1099
1155
  */
1100
1156
  setOnMapInteractionsUi(options: UiOnMapInteractionsOptions): void;
1157
+ /**
1158
+ * Shows a data table view for the specified layer, optionally sorted by a given attribute.
1159
+ *
1160
+ * @example
1161
+ * ```typescript
1162
+ * // Show data table with default sorting
1163
+ * await felt.showLayerDataTable({
1164
+ * layerId: "layer-1",
1165
+ * });
1166
+ *
1167
+ * // Show data table sorted by height in descending order
1168
+ * await felt.showLayerDataTable({
1169
+ * layerId: "layer-1",
1170
+ * sorting: {
1171
+ * attribute: "height",
1172
+ * direction: "desc",
1173
+ * },
1174
+ * });
1175
+ *
1176
+ * // Show the data table pane with no table visible
1177
+ * await felt.showLayerDataTable();
1178
+ * ```
1179
+ */
1180
+ showLayerDataTable(params?: {
1181
+ layerId: string;
1182
+ sorting?: SortConfig;
1183
+ }): Promise<void>;
1184
+ /**
1185
+ * Hides the data table.
1186
+ *
1187
+ * @example
1188
+ * ```typescript
1189
+ * await felt.hideLayerDataTable();
1190
+ * ```
1191
+ */
1192
+ hideLayerDataTable(): Promise<void>;
1101
1193
  }
1102
1194
 
1103
1195
  /**
@@ -1428,4 +1520,4 @@ declare const Felt: {
1428
1520
  connect(feltWindow: Window): Promise<FeltController>;
1429
1521
  };
1430
1522
 
1431
- export { AggregationMethod, ConfigurableToolType, Element, ElementChangeCallbackParams, ElementCreate, ElementGroup, ElementGroupChangeCallbackParams, ElementUpdate, type ElementsController, EntityNode, Feature, FeatureSelection, Felt, type FeltController, type FeltEmbedOptions, Filters, Geometry, GetElementGroupsConstraint, GetElementsConstraint, GetLayerCalculationParams, GetLayerCategoriesGroup, GetLayerCategoriesParams, GetLayerGroupsConstraint, GetLayerHistogramBin, GetLayerHistogramParams, GetLayersConstraint, GetRenderedFeaturesConstraint, InputToolSettings, type InteractionsController, Layer, LayerChangeCallbackParams, LayerFilters, LayerGroup, LayerGroupChangeCallbackParams, type LayersController, LegendItem, LegendItemChangeCallbackParams, LegendItemIdentifier, LegendItemsConstraint, MapDetails, MapInteractionEvent, type MiscController, type UiOnMapInteractionsOptions as OnMapInteractionsOptions, type SelectionController, SetViewportCenterZoomParams, SetVisibilityRequest, ToolSettingsChangeEvent, ToolSettingsMap, ToolType, type ToolsController, type UiController, type UiControlsOptions, ViewportCenterZoom, ViewportConstraints, type ViewportController, ViewportFitBoundsParams, ViewportState };
1523
+ export { AggregationMethod, ConfigurableToolType, Element, ElementChangeCallbackParams, ElementCreate, ElementGroup, ElementGroupChangeCallbackParams, ElementUpdate, type ElementsController, EntityNode, Feature, FeatureSelection, Felt, type FeltController, type FeltEmbedOptions, Filters, Geometry, GetElementGroupsConstraint, GetElementsConstraint, GetLayerCalculationParams, GetLayerCategoriesGroup, GetLayerCategoriesParams, GetLayerGroupsConstraint, GetLayerHistogramBin, GetLayerHistogramParams, GetLayersConstraint, GetRenderedFeaturesConstraint, InputToolSettings, type InteractionsController, Layer, LayerChangeCallbackParams, LayerFilters, LayerGroup, LayerGroupChangeCallbackParams, type LayersController, LegendItem, LegendItemChangeCallbackParams, LegendItemIdentifier, LegendItemsConstraint, MapDetails, MapInteractionEvent, type MiscController, type UiOnMapInteractionsOptions as OnMapInteractionsOptions, type SelectionController, SetViewportCenterZoomParams, SetVisibilityRequest, SortConfig, ToolSettingsChangeEvent, ToolSettingsMap, ToolType, type ToolsController, type UiController, type UiControlsOptions, ViewportCenterZoom, ViewportConstraints, type ViewportController, ViewportFitBoundsParams, ViewportState };
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as Element, G as Geometry, a as GetElementsConstraint, b as ElementGroup, c as GetElementGroupsConstraint, S as SetVisibilityRequest, d as ElementChangeCallbackParams, e as ElementGroupChangeCallbackParams, f as ElementCreate, g as ElementUpdate, L as Layer, h as GetLayersConstraint, i as LayerChangeCallbackParams, j as LayerGroup, k as GetLayerGroupsConstraint, l as LayerGroupChangeCallbackParams, m as LegendItemIdentifier, n as LegendItem, o as LegendItemsConstraint, p as LegendItemChangeCallbackParams, q as LayerFilters, F as Filters, r as GetRenderedFeaturesConstraint, s as Feature, t as GetLayerCategoriesParams, u as GetLayerCategoriesGroup, v as GetLayerHistogramParams, w as GetLayerHistogramBin, A as AggregationMethod, x as GetLayerCalculationParams, M as MapInteractionEvent, y as MapDetails, z as EntityNode, B as FeatureSelection, T as ToolType, I as InputToolSettings, C as ConfigurableToolType, D as ToolSettingsMap, H as ToolSettingsChangeEvent, J as zInfer, V as ViewportState, K as SetViewportCenterZoomParams, N as ViewportConstraints, O as ViewportFitBoundsParams, P as ViewportCenterZoom } from './types-CQwkpLq-.js';
2
- export { ao as AggregationConfig, Q as CircleElementCreate, R as CircleElementRead, U as CircleElementUpdate, aF as CircleToolSettings, ar as ElementGroupNode, as as ElementNode, at as FeatureNode, aw as FeltBoundary, ax as FeltZoom, al as FilterExpression, am as FilterLogicGate, an as FilterTernary, W as HighlighterElementCreate, X as HighlighterElementRead, Y as HighlighterElementUpdate, aG as HighlighterToolSettings, Z as ImageElementCreate, _ as ImageElementRead, $ as ImageElementUpdate, ay as LatLng, au as LayerGroupNode, av as LayerNode, aj as LayerProcessingStatus, az as LineStringGeometry, aH as LineToolSettings, a0 as LinkElementRead, aA as LngLatTuple, a1 as MarkerElementCreate, a2 as MarkerElementRead, a3 as MarkerElementUpdate, aI as MarkerToolSettings, ap as MultiAggregationConfig, aB as MultiLineStringGeometry, aC as MultiPolygonGeometry, a4 as NoteElementCreate, a5 as NoteElementRead, a6 as NoteElementUpdate, aJ as NoteToolSettings, a7 as PathElementCreate, a8 as PathElementRead, a9 as PathElementUpdate, aK as PinToolSettings, aa as PlaceElementCreate, ab as PlaceElementRead, ac as PlaceElementUpdate, aL as PlaceFrame, aM as PlaceSymbol, aD as PointGeometry, ad as PolygonElementCreate, ae as PolygonElementRead, af as PolygonElementUpdate, aE as PolygonGeometry, aN as PolygonToolSettings, ak as RasterValue, aO as RouteToolSettings, ag as TextElementCreate, ah as TextElementRead, ai as TextElementUpdate, aP as TextToolSettings, aq as ValueConfiguration } from './types-CQwkpLq-.js';
1
+ import { E as Element, G as Geometry, a as GetElementsConstraint, b as ElementGroup, c as GetElementGroupsConstraint, S as SetVisibilityRequest, d as ElementChangeCallbackParams, e as ElementGroupChangeCallbackParams, f as ElementCreate, g as ElementUpdate, L as Layer, h as GetLayersConstraint, i as LayerChangeCallbackParams, j as LayerGroup, k as GetLayerGroupsConstraint, l as LayerGroupChangeCallbackParams, m as LegendItemIdentifier, n as LegendItem, o as LegendItemsConstraint, p as LegendItemChangeCallbackParams, q as LayerFilters, F as Filters, r as GetRenderedFeaturesConstraint, s as Feature, t as GetLayerCategoriesParams, u as GetLayerCategoriesGroup, v as GetLayerHistogramParams, w as GetLayerHistogramBin, A as AggregationMethod, x as GetLayerCalculationParams, M as MapInteractionEvent, y as MapDetails, z as EntityNode, B as FeatureSelection, T as ToolType, I as InputToolSettings, C as ConfigurableToolType, D as ToolSettingsMap, H as ToolSettingsChangeEvent, J as zInfer, K as SortConfig, V as ViewportState, N as SetViewportCenterZoomParams, O as ViewportConstraints, P as ViewportFitBoundsParams, Q as ViewportCenterZoom } from './types-XLCA2cX-.js';
2
+ export { ap as AggregationConfig, R as CircleElementCreate, U as CircleElementRead, W as CircleElementUpdate, aH as CircleToolSettings, as as ElementGroupNode, at as ElementNode, au as FeatureNode, ax as FeltBoundary, ay as FeltZoom, am as FilterExpression, an as FilterLogicGate, ao as FilterTernary, X as HighlighterElementCreate, Y as HighlighterElementRead, Z as HighlighterElementUpdate, aI as HighlighterToolSettings, _ as ImageElementCreate, $ as ImageElementRead, a0 as ImageElementUpdate, az as LatLng, av as LayerGroupNode, aw as LayerNode, ak as LayerProcessingStatus, aA as LineStringGeometry, aJ as LineToolSettings, a1 as LinkElementRead, aB as LngLatTuple, a2 as MarkerElementCreate, a3 as MarkerElementRead, a4 as MarkerElementUpdate, aK as MarkerToolSettings, aq as MultiAggregationConfig, aC as MultiLineStringGeometry, aD as MultiPolygonGeometry, a5 as NoteElementCreate, a6 as NoteElementRead, a7 as NoteElementUpdate, aL as NoteToolSettings, a8 as PathElementCreate, a9 as PathElementRead, aa as PathElementUpdate, aM as PinToolSettings, ab as PlaceElementCreate, ac as PlaceElementRead, ad as PlaceElementUpdate, aN as PlaceFrame, aO as PlaceSymbol, aE as PointGeometry, ae as PolygonElementCreate, af as PolygonElementRead, ag as PolygonElementUpdate, aF as PolygonGeometry, aP as PolygonToolSettings, al as RasterValue, aQ as RouteToolSettings, aG as SortDirection, ah as TextElementCreate, ai as TextElementRead, aj as TextElementUpdate, aR as TextToolSettings, ar as ValueConfiguration } from './types-XLCA2cX-.js';
3
3
  import { z } from 'zod';
4
4
 
5
5
  /**
@@ -62,7 +62,7 @@ interface ElementsController {
62
62
  *
63
63
  * @example
64
64
  * ```typescript
65
- * felt.getElementGroup("element-group-1");
65
+ * const elementGroup = await felt.getElementGroup("element-group-1");
66
66
  * ```
67
67
  * @returns The requested element group.
68
68
  */
@@ -111,13 +111,67 @@ interface ElementsController {
111
111
  /**
112
112
  * The handler that is called when an element is created.
113
113
  *
114
+ * This will fire when elements are created programatically, or when the
115
+ * user starts creating an element with a drawing tool.
116
+ *
117
+ * When the user creates an element with a drawing tool, it can begin in
118
+ * an invalid state, such as if you've just placed a single point in a polygon.
119
+ *
120
+ * You can use the `isBeingCreated` property to determine if the element is
121
+ * still being created by a drawing tool.
122
+ *
123
+ * If you want to know when the element is finished being created, you can
124
+ * use the `onToolCreateElementEnd` listener.
125
+ *
114
126
  * @param change - An object describing the change that occurred.
115
127
  */
116
128
  handler: (change: ElementChangeCallbackParams) => void;
117
129
  }): VoidFunction;
130
+ /**
131
+ * Listens for when a new element is finished being created by a drawing tool.
132
+ *
133
+ * This differs from the `onElementCreate` listener, which fires whenever an
134
+ * element is first created. This fires when the user finishes creating an element
135
+ * which could be after a series of interactions.
136
+ *
137
+ * For example, when creating a polygon, the user places a series of points then
138
+ * finishes by pressing Enter or Escape. Or when creating a Place element, they
139
+ * add the marker, type a label, then finally deselect the element.
140
+ *
141
+ * @returns A function to unsubscribe from the listener
142
+ *
143
+ * @example
144
+ * ```typescript
145
+ * const unsubscribe = felt.onToolCreatedElement({
146
+ * handler: (params) => console.log(params),
147
+ * });
148
+ *
149
+ * // later on...
150
+ * unsubscribe();
151
+ * ```
152
+ */
153
+ onElementCreateEnd(args: {
154
+ /**
155
+ * The handler to call whenever this event fires.
156
+ *
157
+ * @param params - An object containing the element that was created.
158
+ */
159
+ handler: (params: {
160
+ element: Element;
161
+ }) => void;
162
+ }): VoidFunction;
118
163
  /**
119
164
  * Adds a listener for when an element changes.
120
165
  *
166
+ * This will fire when an element is being edited, either on the map by the user
167
+ * or programatically.
168
+ *
169
+ * Like the `onElementCreate` listener, this will fire when an element is
170
+ * still being created by a drawing tool.
171
+ *
172
+ * You can check the `isBeingCreated` property to determine if the element is
173
+ * still being created by a drawing tool.
174
+ *
121
175
  * @returns A function to unsubscribe from the listener
122
176
  *
123
177
  * @event
@@ -235,7 +289,7 @@ interface LayersController {
235
289
  *
236
290
  * @example
237
291
  * ```typescript
238
- * const layers = await felt.getLayer({ ids: ["layer-1", "layer-2"] });
292
+ * const layer = await felt.getLayer("layer-1");
239
293
  * ```
240
294
  * @returns The requested layer.
241
295
  */
@@ -356,7 +410,7 @@ interface LayersController {
356
410
  *
357
411
  * @example
358
412
  * ```typescript
359
- * felt.getLayerGroup("layer-group-1");
413
+ * const layerGroup = await felt.getLayerGroup("layer-group-1");
360
414
  * ```
361
415
  * @returns The requested layer group.
362
416
  */
@@ -869,7 +923,7 @@ interface ToolsController {
869
923
  * @param tool - The tool to set.
870
924
  *
871
925
  * @example
872
- * ```ts
926
+ * ```typescript
873
927
  * // Set the tool to "marker"
874
928
  * felt.setTool("marker");
875
929
  *
@@ -884,7 +938,7 @@ interface ToolsController {
884
938
  * @returns The current tool, or `null` if no tool is in use.
885
939
  *
886
940
  * @example
887
- * ```ts
941
+ * ```typescript
888
942
  * const tool = await felt.getTool(); // "marker", "polygon", etc.
889
943
  * ```
890
944
  */
@@ -895,7 +949,7 @@ interface ToolsController {
895
949
  * @returns A function to unsubscribe from the listener
896
950
  *
897
951
  * @example
898
- * ```ts
952
+ * ```typescript
899
953
  * const unsubscribe = felt.onToolChange({
900
954
  * handler: tool => console.log(tool),
901
955
  * });
@@ -1073,8 +1127,10 @@ declare const UiOnMapInteractionsOptionsSchema: z.ZodObject<{
1073
1127
  }>;
1074
1128
 
1075
1129
  /**
1076
- * The UI controller allows you to enable and disable UI controls on the
1077
- * embedded map.
1130
+ * The UI controller allows you to control various aspects of the Felt UI in your embedded map.
1131
+ *
1132
+ * This includes enabling/disabling UI controls, managing on-map interactions, and controlling
1133
+ * the visibility of UI components like the data table.
1078
1134
  *
1079
1135
  * @group Controller
1080
1136
  * @public
@@ -1098,6 +1154,42 @@ interface UiController {
1098
1154
  * will still be selected when clicked.
1099
1155
  */
1100
1156
  setOnMapInteractionsUi(options: UiOnMapInteractionsOptions): void;
1157
+ /**
1158
+ * Shows a data table view for the specified layer, optionally sorted by a given attribute.
1159
+ *
1160
+ * @example
1161
+ * ```typescript
1162
+ * // Show data table with default sorting
1163
+ * await felt.showLayerDataTable({
1164
+ * layerId: "layer-1",
1165
+ * });
1166
+ *
1167
+ * // Show data table sorted by height in descending order
1168
+ * await felt.showLayerDataTable({
1169
+ * layerId: "layer-1",
1170
+ * sorting: {
1171
+ * attribute: "height",
1172
+ * direction: "desc",
1173
+ * },
1174
+ * });
1175
+ *
1176
+ * // Show the data table pane with no table visible
1177
+ * await felt.showLayerDataTable();
1178
+ * ```
1179
+ */
1180
+ showLayerDataTable(params?: {
1181
+ layerId: string;
1182
+ sorting?: SortConfig;
1183
+ }): Promise<void>;
1184
+ /**
1185
+ * Hides the data table.
1186
+ *
1187
+ * @example
1188
+ * ```typescript
1189
+ * await felt.hideLayerDataTable();
1190
+ * ```
1191
+ */
1192
+ hideLayerDataTable(): Promise<void>;
1101
1193
  }
1102
1194
 
1103
1195
  /**
@@ -1428,4 +1520,4 @@ declare const Felt: {
1428
1520
  connect(feltWindow: Window): Promise<FeltController>;
1429
1521
  };
1430
1522
 
1431
- export { AggregationMethod, ConfigurableToolType, Element, ElementChangeCallbackParams, ElementCreate, ElementGroup, ElementGroupChangeCallbackParams, ElementUpdate, type ElementsController, EntityNode, Feature, FeatureSelection, Felt, type FeltController, type FeltEmbedOptions, Filters, Geometry, GetElementGroupsConstraint, GetElementsConstraint, GetLayerCalculationParams, GetLayerCategoriesGroup, GetLayerCategoriesParams, GetLayerGroupsConstraint, GetLayerHistogramBin, GetLayerHistogramParams, GetLayersConstraint, GetRenderedFeaturesConstraint, InputToolSettings, type InteractionsController, Layer, LayerChangeCallbackParams, LayerFilters, LayerGroup, LayerGroupChangeCallbackParams, type LayersController, LegendItem, LegendItemChangeCallbackParams, LegendItemIdentifier, LegendItemsConstraint, MapDetails, MapInteractionEvent, type MiscController, type UiOnMapInteractionsOptions as OnMapInteractionsOptions, type SelectionController, SetViewportCenterZoomParams, SetVisibilityRequest, ToolSettingsChangeEvent, ToolSettingsMap, ToolType, type ToolsController, type UiController, type UiControlsOptions, ViewportCenterZoom, ViewportConstraints, type ViewportController, ViewportFitBoundsParams, ViewportState };
1523
+ export { AggregationMethod, ConfigurableToolType, Element, ElementChangeCallbackParams, ElementCreate, ElementGroup, ElementGroupChangeCallbackParams, ElementUpdate, type ElementsController, EntityNode, Feature, FeatureSelection, Felt, type FeltController, type FeltEmbedOptions, Filters, Geometry, GetElementGroupsConstraint, GetElementsConstraint, GetLayerCalculationParams, GetLayerCategoriesGroup, GetLayerCategoriesParams, GetLayerGroupsConstraint, GetLayerHistogramBin, GetLayerHistogramParams, GetLayersConstraint, GetRenderedFeaturesConstraint, InputToolSettings, type InteractionsController, Layer, LayerChangeCallbackParams, LayerFilters, LayerGroup, LayerGroupChangeCallbackParams, type LayersController, LegendItem, LegendItemChangeCallbackParams, LegendItemIdentifier, LegendItemsConstraint, MapDetails, MapInteractionEvent, type MiscController, type UiOnMapInteractionsOptions as OnMapInteractionsOptions, type SelectionController, SetViewportCenterZoomParams, SetVisibilityRequest, SortConfig, ToolSettingsChangeEvent, ToolSettingsMap, ToolType, type ToolsController, type UiController, type UiControlsOptions, ViewportCenterZoom, ViewportConstraints, type ViewportController, ViewportFitBoundsParams, ViewportState };
package/dist/client.js CHANGED
@@ -1 +1 @@
1
- function o(e,m){return n=>{let r=new MessageChannel,p=n.handler,s="options"in n?n.options:void 0,i=crypto.randomUUID();return e.postMessage({type:"felt.addListener",event:s?{eventName:m,id:i,options:s}:{eventName:m,id:i}},"*",[r.port2]),r.port1.onmessage=d=>{p(d.data)},()=>{r.port1.onmessage=null,r.port1.close(),r.port2.close(),e.postMessage({type:"felt.removeListener",id:i},"*")}}}function t(e,m){return n=>{let r=new MessageChannel;return e.postMessage({type:m,params:n},"*",[r.port2]),new Promise((p,s)=>{r.port1.onmessage=i=>{i.data&&typeof i.data=="object"&&"__error__"in i.data?s(new Error(i.data.__error__)):p(i.data),r.port1.close(),r.port2.close()}})}}var c=e=>({getElement:t(e,"getElement"),getElementGeometry:t(e,"getElementGeometry"),getElements:t(e,"getElements"),setElementGroupVisibility:t(e,"setElementGroupVisibility"),getElementGroup:t(e,"getElementGroup"),getElementGroups:t(e,"getElementGroups"),onElementChange:o(e,"onElementChange"),onElementCreate:o(e,"onElementCreate"),onElementDelete:o(e,"onElementDelete"),onElementGroupChange:o(e,"onElementGroupChange"),createElement:t(e,"createElement"),updateElement:t(e,"updateElement"),deleteElement:t(e,"deleteElement")});var u=e=>({onPointerClick:o(e,"onPointerClick"),onPointerMove:o(e,"onPointerMove")});var C=e=>({getLayer:t(e,"getLayer"),getLayers:t(e,"getLayers"),setLayerVisibility:t(e,"setLayerVisibility"),setLayerStyle:t(e,"setLayerStyle"),setLayerLegendVisibility:t(e,"setLayerLegendVisibility"),onLayerChange:o(e,"onLayerChange"),getLayerGroup:t(e,"getLayerGroup"),getLayerGroups:t(e,"getLayerGroups"),setLayerGroupVisibility:t(e,"setLayerGroupVisibility"),setLayerGroupLegendVisibility:t(e,"setLayerGroupLegendVisibility"),onLayerGroupChange:o(e,"onLayerGroupChange"),getLegendItem:t(e,"getLegendItem"),getLegendItems:t(e,"getLegendItems"),setLegendItemVisibility:t(e,"setLegendItemVisibility"),onLegendItemChange:o(e,"onLegendItemChange"),getLayerFilters:t(e,"getLayerFilters"),setLayerFilters:t(e,"setLayerFilters"),getRenderedFeatures:t(e,"getRenderedFeatures"),getCategoryData:t(e,"getCategoryData"),getHistogramData:t(e,"getHistogramData"),getAggregates:t(e,"getAggregates")});var h=e=>({getMapDetails:t(e,"getMapDetails")});var L=e=>({onSelectionChange:o(e,"onSelectionChange"),getSelection:t(e,"getSelection"),selectFeature:t(e,"selectFeature"),clearSelection:t(e,"clearSelection")});var T=e=>({setTool:t(e,"setTool"),getTool:t(e,"getTool"),onToolChange:o(e,"onToolChange"),setToolSettings:t(e,"setToolSettings"),getToolSettings:t(e,"getToolSettings"),onToolSettingsChange:o(e,"onToolSettingsChange")});var E=e=>({updateUiControls:t(e,"updateUiControls"),setOnMapInteractionsUi:t(e,"setOnMapInteractionsUi")});var v=e=>({getViewport:t(e,"getViewport"),setViewport:t(e,"setViewport"),getViewportConstraints:t(e,"getViewportConstraints"),setViewportConstraints:t(e,"setViewportConstraints"),fitViewportToBounds:t(e,"fitViewportToBounds"),onViewportMove:o(e,"onViewportMove"),onViewportMoveEnd:o(e,"onViewportMoveEnd"),onMapIdle:o(e,"onMapIdle")});function P(e){return{iframe:null,...v(e),...E(e),...C(e),...c(e),...L(e),...u(e),...T(e),...h(e)}}var V={embed(e,m,n){let r={uiControls:{showLegend:!0,cooperativeGestures:!0,fullScreenButton:!0,geolocation:!1,zoomControls:!0,scaleBar:!0},initialViewport:void 0,origin:"https://felt.com"},p=n?.origin??r.origin,s=new URL(`${p}/embed/map/${m}`),i={showLegend:"legend",cooperativeGestures:"cooperativeGestures",fullScreenButton:"link",geolocation:"geolocation",zoomControls:"zoomControls",scaleBar:"scaleBar"},d={...r.uiControls,...n?.uiControls};for(let[l,g]of M(d))g!=null&&s.searchParams.set(i[l],g?"1":"0");if(n?.token&&s.searchParams.set("token",n.token),n?.initialViewport){let l=n.initialViewport;s.searchParams.set("loc",`${l.center.latitude},${l.center.longitude},${l.zoom}z`)}let y=e.tagName==="IFRAME",a=y?e:e.ownerDocument.createElement("iframe");return a.src=s.toString(),y||(a.style.width="100%",a.style.height="100%",a.style.border="none",a.style.margin="0",e.appendChild(a)),a.referrerPolicy="strict-origin-when-cross-origin",new Promise((l,g)=>{a.addEventListener("load",()=>{a.contentWindow==null?g(new Error("Failed to load Felt map")):l(a.contentWindow)},{once:!0})}).then(V.connect).then(l=>(Object.defineProperties(l,{iframe:{value:a,writable:!1,configurable:!1}}),l))},connect(e){let m=P(e);return new Promise((n,r)=>{let p=setTimeout(()=>{r(new Error("Failed to load Felt map")),clearInterval(i)},5e3),s=new MessageChannel,i=setInterval(()=>{e.postMessage({type:"felt.ready"},"*",[s.port2])},100);s.port1.onmessage=d=>{d.data===!0&&(clearInterval(i),clearTimeout(p),s.port1.close(),s.port2.close(),n(m))}})}},M=Object.entries;export{V as Felt};
1
+ function o(e,m){return n=>{let r=new MessageChannel,p=n.handler,s="options"in n?n.options:void 0,a=crypto.randomUUID();return e.postMessage({type:"felt.addListener",event:s?{eventName:m,id:a,options:s}:{eventName:m,id:a}},"*",[r.port2]),r.port1.onmessage=d=>{p(d.data)},()=>{r.port1.onmessage=null,r.port1.close(),r.port2.close(),e.postMessage({type:"felt.removeListener",id:a},"*")}}}function t(e,m){return n=>{let r=new MessageChannel;return e.postMessage({type:m,params:n},"*",[r.port2]),new Promise((p,s)=>{r.port1.onmessage=a=>{a.data&&typeof a.data=="object"&&"__error__"in a.data?s(new Error(a.data.__error__)):p(a.data),r.port1.close(),r.port2.close()}})}}var c=e=>({getElement:t(e,"getElement"),getElementGeometry:t(e,"getElementGeometry"),getElements:t(e,"getElements"),setElementGroupVisibility:t(e,"setElementGroupVisibility"),getElementGroup:t(e,"getElementGroup"),getElementGroups:t(e,"getElementGroups"),onElementChange:o(e,"onElementChange"),onElementCreate:o(e,"onElementCreate"),onElementCreateEnd:o(e,"onElementCreateEnd"),onElementDelete:o(e,"onElementDelete"),onElementGroupChange:o(e,"onElementGroupChange"),createElement:t(e,"createElement"),updateElement:t(e,"updateElement"),deleteElement:t(e,"deleteElement")});var u=e=>({onPointerClick:o(e,"onPointerClick"),onPointerMove:o(e,"onPointerMove")});var C=e=>({getLayer:t(e,"getLayer"),getLayers:t(e,"getLayers"),setLayerVisibility:t(e,"setLayerVisibility"),setLayerStyle:t(e,"setLayerStyle"),setLayerLegendVisibility:t(e,"setLayerLegendVisibility"),onLayerChange:o(e,"onLayerChange"),getLayerGroup:t(e,"getLayerGroup"),getLayerGroups:t(e,"getLayerGroups"),setLayerGroupVisibility:t(e,"setLayerGroupVisibility"),setLayerGroupLegendVisibility:t(e,"setLayerGroupLegendVisibility"),onLayerGroupChange:o(e,"onLayerGroupChange"),getLegendItem:t(e,"getLegendItem"),getLegendItems:t(e,"getLegendItems"),setLegendItemVisibility:t(e,"setLegendItemVisibility"),onLegendItemChange:o(e,"onLegendItemChange"),getLayerFilters:t(e,"getLayerFilters"),setLayerFilters:t(e,"setLayerFilters"),getRenderedFeatures:t(e,"getRenderedFeatures"),getCategoryData:t(e,"getCategoryData"),getHistogramData:t(e,"getHistogramData"),getAggregates:t(e,"getAggregates")});var h=e=>({getMapDetails:t(e,"getMapDetails")});var L=e=>({onSelectionChange:o(e,"onSelectionChange"),getSelection:t(e,"getSelection"),selectFeature:t(e,"selectFeature"),clearSelection:t(e,"clearSelection")});var T=e=>({setTool:t(e,"setTool"),getTool:t(e,"getTool"),onToolChange:o(e,"onToolChange"),setToolSettings:t(e,"setToolSettings"),getToolSettings:t(e,"getToolSettings"),onToolSettingsChange:o(e,"onToolSettingsChange")});var E=e=>({updateUiControls:t(e,"updateUiControls"),setOnMapInteractionsUi:t(e,"setOnMapInteractionsUi"),showLayerDataTable:t(e,"showLayerDataTable"),hideLayerDataTable:t(e,"hideLayerDataTable")});var v=e=>({getViewport:t(e,"getViewport"),setViewport:t(e,"setViewport"),getViewportConstraints:t(e,"getViewportConstraints"),setViewportConstraints:t(e,"setViewportConstraints"),fitViewportToBounds:t(e,"fitViewportToBounds"),onViewportMove:o(e,"onViewportMove"),onViewportMoveEnd:o(e,"onViewportMoveEnd"),onMapIdle:o(e,"onMapIdle")});function P(e){return{iframe:null,...v(e),...E(e),...C(e),...c(e),...L(e),...u(e),...T(e),...h(e)}}var V={embed(e,m,n){let r={uiControls:{showLegend:!0,cooperativeGestures:!0,fullScreenButton:!0,geolocation:!1,zoomControls:!0,scaleBar:!0},initialViewport:void 0,origin:"https://felt.com"},p=n?.origin??r.origin,s=new URL(`${p}/embed/map/${m}`),a={showLegend:"legend",cooperativeGestures:"cooperativeGestures",fullScreenButton:"link",geolocation:"geolocation",zoomControls:"zoomControls",scaleBar:"scaleBar"},d={...r.uiControls,...n?.uiControls};for(let[l,y]of M(d))y!=null&&s.searchParams.set(a[l],y?"1":"0");if(n?.token&&s.searchParams.set("token",n.token),n?.initialViewport){let l=n.initialViewport;s.searchParams.set("loc",`${l.center.latitude},${l.center.longitude},${l.zoom}z`)}let g=e.tagName==="IFRAME",i=g?e:e.ownerDocument.createElement("iframe");return i.src=s.toString(),g||(i.style.width="100%",i.style.height="100%",i.style.border="none",i.style.margin="0",e.appendChild(i)),i.referrerPolicy="strict-origin-when-cross-origin",new Promise((l,y)=>{i.addEventListener("load",()=>{i.contentWindow==null?y(new Error("Failed to load Felt map")):l(i.contentWindow)},{once:!0})}).then(V.connect).then(l=>(Object.defineProperties(l,{iframe:{value:i,writable:!1,configurable:!1}}),l))},connect(e){let m=P(e);return new Promise((n,r)=>{let p=setTimeout(()=>{r(new Error("Failed to load Felt map")),clearInterval(a)},5e3),s=new MessageChannel,a=setInterval(()=>{e.postMessage({type:"felt.ready"},"*",[s.port2])},100);s.port1.onmessage=d=>{d.data===!0&&(clearInterval(a),clearTimeout(p),s.port1.close(),s.port2.close(),n(m))}})}},M=Object.entries;export{V as Felt};
package/dist/handler.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var Z=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var ot=Object.getOwnPropertyNames;var rt=Object.prototype.hasOwnProperty;var nt=(r,s)=>{for(var E in s)Z(r,E,{get:s[E],enumerable:!0})},at=(r,s,E,F)=>{if(s&&typeof s=="object"||typeof s=="function")for(let L of ot(s))!rt.call(r,L)&&L!==E&&Z(r,L,{get:()=>s[L],enumerable:!(F=tt(s,L))||F.enumerable});return r};var it=r=>at(Z({},"__esModule",{value:!0}),r);var _o={};nt(_o,{createMessageHandler:()=>Ao});module.exports=it(_o);var g=require("zod");var y=require("zod");var f=require("zod");function t(r,s){return f.z.strictObject({type:f.z.literal(r),params:s})}function C(r,s){return f.z.strictObject({eventName:f.z.literal(r),id:f.z.string(),options:s})}function p(r){return f.z.strictObject({eventName:f.z.literal(r),id:f.z.string()})}var a=require("zod"),O=a.z.number(),U=a.z.number(),R=a.z.object({latitude:U,longitude:O}),I=a.z.tuple([O,U]),de=a.z.object({type:a.z.literal("Point"),coordinates:I}),ye=a.z.object({type:a.z.literal("Polygon"),coordinates:a.z.array(a.z.array(I))}),st=a.z.object({type:a.z.literal("LineString"),coordinates:a.z.array(I)}),G=a.z.object({type:a.z.literal("MultiLineString"),coordinates:a.z.array(st.shape.coordinates)}),ue=a.z.number().min(1).max(23),T=a.z.tuple([O,U,O,U]),z=a.z.object({show:a.z.array(a.z.string()).optional(),hide:a.z.array(a.z.string()).optional()});var e=require("zod");var u=e.z.object({id:e.z.string(),groupId:e.z.string().nullable(),color:e.z.string(),name:e.z.union([e.z.string(),e.z.null()]),description:e.z.union([e.z.string(),e.z.null()]),attributes:e.z.record(e.z.string(),e.z.unknown())}),N=e.z.object({imageUrl:e.z.string().nullable()}),D=e.z.object({strokeOpacity:e.z.number(),strokeWidth:e.z.number(),strokeStyle:e.z.enum(["solid","dashed","dotted"])}),lt=e.z.enum(["meter","kilometer","foot","mile"]),W=u.extend(N.shape).extend({type:e.z.literal("Place"),coordinates:de.shape.coordinates,symbol:e.z.string(),frame:e.z.enum(["frame-circle","frame-square"]).nullable(),hideLabel:e.z.boolean()}),K=u.extend(N.shape).extend(D.shape).extend({type:e.z.literal("Path"),coordinates:G.shape.coordinates,distanceMarker:e.z.boolean(),endCaps:e.z.boolean(),routingMode:e.z.enum(["driving","cycling","walking","flying"]).nullable()}),_=u.extend(N.shape).extend(D.shape).extend({type:e.z.literal("Polygon"),coordinates:G.shape.coordinates,fillOpacity:e.z.number().min(0).max(1),areaMarker:e.z.boolean()}),Q=u.extend(N.shape).extend(D.shape).extend({type:e.z.literal("Circle"),coordinates:I,radius:e.z.number(),radiusDisplayAngle:e.z.number(),radiusDisplayUnit:lt.nullable(),fillOpacity:e.z.number().min(0).max(1),radiusMarker:e.z.boolean()}),$=u.extend({type:e.z.literal("Marker"),coordinates:G.shape.coordinates,opacity:e.z.number().min(0).max(1),size:e.z.number().min(0).max(100),zoom:e.z.number().min(0).max(23)}),J=u.extend({type:e.z.literal("Highlighter"),coordinates:G.shape.coordinates,opacity:e.z.number().min(0).max(1)}),he=e.z.object({position:I,rotation:e.z.number(),scale:e.z.number(),zoom:e.z.number().min(0).max(23),coordinates:G.shape.coordinates}),fe=e.z.object({text:e.z.string(),align:e.z.enum(["left","center","right"]),style:e.z.enum(["italic","light","regular","caps"]),name:e.z.string()}),X=u.extend(he.shape).extend(fe.shape).extend({type:e.z.literal("Text")}),Y=u.extend(he.shape).extend(fe.shape).extend({type:e.z.literal("Note"),widthScale:e.z.number().min(0)}),ee=u.extend({type:e.z.literal("Image"),coordinates:G.shape.coordinates,imageUrl:e.z.string(),opacity:e.z.number().min(0).max(1)}).omit({color:!0}),pt=u.extend({type:e.z.literal("Link"),coordinates:G.shape.coordinates,url:e.z.string()}),S={type:!0,coordinates:!0},x={id:!0},te=W.partial().required(S).omit(x),j=K.partial().required(S).omit(x),oe=_.partial().required(S).omit(x),re=Q.partial().required(S).required({radius:!0}).omit(x),ne=$.partial().required(S).omit(x),ae=J.partial().required(S).omit(x),ie=X.partial().required(S).required({text:!0}).omit(x).omit({coordinates:!0,name:!0}),se=Y.partial().required(S).required({text:!0}).omit(x).omit({coordinates:!0,name:!0}),mt=ee.partial().required(S).required({imageUrl:!0}).omit(x),Se=e.z.discriminatedUnion("type",[te,j,oe,re,ne,ae,mt,ie,se]),er=W.omit({coordinates:!0}),tr=K.omit({coordinates:!0}),or=_.omit({coordinates:!0}),rr=Q.omit({coordinates:!0}),nr=$.omit({coordinates:!0}),ar=J.omit({coordinates:!0}),ir=X.omit({coordinates:!0}),sr=Y.omit({coordinates:!0}),lr=ee.omit({coordinates:!0}),pr=pt.omit({coordinates:!0}),M={type:!0,id:!0},ct=W.partial().required(M),gt=K.partial().required(M),dt=_.partial().required(M),yt=Q.partial().required(M),ut=$.partial().required(M),ht=J.partial().required(M),ft=X.partial().required(M).omit({coordinates:!0,name:!0}),St=Y.partial().required(M).omit({coordinates:!0,name:!0}),xt=ee.partial().required(M),xe=e.z.discriminatedUnion("type",[ct,gt,dt,yt,ut,ht,ft,St,xt]),Me=e.z.object({ids:e.z.array(e.z.string()).optional()}),be=e.z.object({ids:e.z.array(e.z.string()).optional()});var Mt=t("getElement",y.z.string()),bt=t("getElementGeometry",y.z.string()),Lt=t("getElements",Me.optional()),Ct=t("getElementGroup",y.z.string()),It=t("getElementGroups",be.optional()),Gt=t("setElementGroupVisibility",z),Et=C("onElementChange",y.z.object({id:y.z.string()})),Tt=p("onElementCreate"),zt=C("onElementDelete",y.z.object({id:y.z.string()})),Pt=C("onElementGroupChange",y.z.object({id:y.z.string()})),Ft=t("createElement",Se),kt=t("updateElement",xe),vt=t("deleteElement",y.z.string()),Le={methods:[Mt,bt,Lt,Ct,It,Gt,Ft,kt,vt],listeners:[Et,Tt,zt,Pt]};var wt=p("onPointerClick"),Vt=p("onPointerMove"),Ce={methods:null,listeners:[wt,Vt]};var l=require("zod");var n=require("zod"),Ot=n.z.enum(["in","ni"]),Ut=n.z.enum(["lt","gt","le","ge","eq","ne","cn","nc","is","isnt"]),fr=n.z.enum(["and","or"]),Ie=n.z.union([n.z.number(),n.z.string(),n.z.boolean(),n.z.null()]),Ge=n.z.string().or(n.z.null()),Rt=n.z.tuple([Ge,Ot,n.z.array(Ie).or(n.z.null())]),Nt=n.z.tuple([Ge,Ut,Ie]),le=n.z.union([Rt,Nt]),pe=n.z.tuple([n.z.lazy(()=>n.z.union([pe,le,n.z.null(),n.z.boolean()])),n.z.enum(["and","or"]),n.z.lazy(()=>n.z.union([pe,le,n.z.null(),n.z.boolean()]))]),P=n.z.union([pe,le,n.z.null(),n.z.boolean()]);var o=require("zod");var Ee=o.z.enum(["avg","max","min","sum","median"]),jt=o.z.object({method:Ee,attribute:o.z.string()}),qt=o.z.object({methods:o.z.array(o.z.union([Ee,o.z.literal("count")])),attribute:o.z.string().optional()}),q=o.z.union([T,ye,o.z.array(I)]),Te=o.z.object({boundary:q.optional(),filters:P.optional(),aggregation:jt.optional()}),ze=o.z.object({layerId:o.z.string(),attribute:o.z.string(),limit:o.z.number().optional(),boundary:q.optional(),filters:P.optional(),values:Te.optional()}),br=o.z.object({key:o.z.union([o.z.number(),o.z.string(),o.z.boolean()]),value:o.z.number().nullable()}),At=o.z.object({type:o.z.literal("equal-intervals"),count:o.z.number()}),Ht=o.z.object({type:o.z.literal("time-interval"),interval:o.z.enum(["hour","day","week","month","year"])}),Pe=o.z.object({layerId:o.z.string(),attribute:o.z.string(),steps:o.z.union([At,Ht,o.z.array(o.z.number())]),boundary:q.optional(),filters:P.optional(),values:Te.optional()}),Lr=o.z.object({min:o.z.number(),max:o.z.number(),value:o.z.number()}),Fe=o.z.object({layerId:o.z.string(),boundary:q.optional(),filters:P.optional(),aggregation:qt});var i=require("zod");var Gr=i.z.enum(["processing","completed","failed","incomplete"]),ke=i.z.object({ids:i.z.array(i.z.string()).optional()}),ve=i.z.object({ids:i.z.array(i.z.string()).optional()}),k=i.z.object({id:i.z.string(),layerId:i.z.string()}),we=i.z.object({ids:k.array().optional(),layerIds:i.z.string().array().optional()}),Ve=i.z.object({layerIds:i.z.array(i.z.string()).optional(),areaQuery:i.z.union([i.z.object({coordinates:R}),i.z.object({boundary:T})]).optional()});var Bt=t("getLayer",l.z.string()),Zt=t("getLayers",ke.optional()),Dt=t("setLayerVisibility",z),Wt=C("onLayerChange",l.z.object({id:l.z.string()})),Kt=t("setLayerStyle",l.z.object({id:l.z.string(),style:l.z.object({}).passthrough()})),_t=t("setLayerLegendVisibility",z),Qt=t("getLayerGroup",l.z.string()),$t=t("getLayerGroups",ve.optional()),Jt=t("setLayerGroupVisibility",z),Xt=t("setLayerGroupLegendVisibility",z),Yt=C("onLayerGroupChange",l.z.object({id:l.z.string()})),eo=t("getLegendItem",k),to=t("getLegendItems",we.optional()),oo=C("onLegendItemChange",k),ro=t("setLegendItemVisibility",l.z.object({show:k.array().optional(),hide:k.array().optional()})),no=t("getLayerFilters",l.z.string()),ao=t("setLayerFilters",l.z.object({layerId:l.z.string(),filters:P,note:l.z.string().optional()})),io=t("getRenderedFeatures",Ve.optional()),so=t("getCategoryData",ze),lo=t("getHistogramData",Pe),po=t("getAggregates",Fe),Oe={methods:[Bt,Zt,Dt,Kt,_t,Qt,$t,Jt,Xt,eo,to,ro,no,ao,io,so,lo,po],listeners:[Wt,Yt,oo]};var Ue=require("zod");var mo=t("getMapDetails",Ue.z.undefined()),Re={methods:[mo],listeners:[]};var w=require("zod");var b=require("zod"),Ne=b.z.object({id:b.z.string().or(b.z.number()),layerId:b.z.string(),showPopup:b.z.boolean().optional(),fitViewport:b.z.boolean().or(b.z.object({maxZoom:b.z.number()})).optional()});var co=t("getSelection",w.z.undefined()),go=p("onSelectionChange"),yo=t("selectFeature",Ne),uo=t("clearSelection",w.z.object({features:w.z.boolean().optional(),elements:w.z.boolean().optional()}).optional()),je={methods:[co,yo,uo],listeners:[go]};var Ze=require("zod");var m=require("zod");var qe=["pin","line","route","polygon","circle","marker","highlighter","text","note"],Ae=m.z.enum([...qe,"link"]),He=m.z.enum(qe),ho=te.pick({color:!0,symbol:!0,frame:!0}).required(),fo=j.pick({color:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,distanceMarker:!0}).required(),So=j.pick({color:!0,routingMode:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,distanceMarker:!0,endCaps:!0}).required(),xo=oe.pick({color:!0,fillOpacity:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,areaMarker:!0}).required(),Mo=re.pick({color:!0,fillOpacity:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,radiusMarker:!0}).required(),bo=ne.pick({color:!0,opacity:!0,size:!0}).required(),Lo=ae.pick({color:!0,opacity:!0}).extend({size:m.z.number().min(0).max(200)}).required(),Co=ie.pick({color:!0,align:!0,style:!0}).required(),Io=se.pick({color:!0,align:!0,style:!0}).required(),Be=m.z.discriminatedUnion("tool",[ho.partial().extend({tool:m.z.literal("pin")}),fo.partial().extend({tool:m.z.literal("line")}),So.partial().extend({tool:m.z.literal("route")}),xo.partial().extend({tool:m.z.literal("polygon")}),Mo.partial().extend({tool:m.z.literal("circle")}),bo.partial().extend({tool:m.z.literal("marker")}),Lo.partial().extend({tool:m.z.literal("highlighter")}),Co.partial().extend({tool:m.z.literal("text")}),Io.partial().extend({tool:m.z.literal("note")})]);var Go=t("setTool",Ae.nullable()),Eo=t("getTool",Ze.z.undefined()),To=p("onToolChange"),zo=t("setToolSettings",Be),Po=t("getToolSettings",He),Fo=p("onToolSettingsChange"),De={methods:[Go,Eo,zo,Po],listeners:[To,Fo]};var c=require("zod"),We=c.z.object({showLegend:c.z.boolean().optional(),cooperativeGestures:c.z.boolean().optional(),fullScreenButton:c.z.boolean().optional(),geolocation:c.z.boolean().optional(),zoomControls:c.z.boolean().optional(),scaleBar:c.z.boolean().optional()}),Ke=c.z.object({featureSelectPanel:c.z.boolean().optional(),featureHoverPanel:c.z.boolean().optional(),elementSelectPanel:c.z.boolean().optional(),linkClickOpen:c.z.boolean().optional(),imageLightboxOpen:c.z.boolean().optional()});var ko=t("updateUiControls",We),vo=t("setOnMapInteractionsUi",Ke),_e={methods:[ko,vo],listeners:null};var me=require("zod");var V=require("zod");var A=V.z.object({center:R,zoom:ue}),Qe=V.z.object({center:A.shape.center.optional(),zoom:A.shape.zoom.optional()}),$e=V.z.object({minZoom:A.shape.zoom.nullish(),maxZoom:A.shape.zoom.nullish(),bounds:T.nullish()}).nullable(),Je=V.z.object({bounds:T});var wo=t("getViewport",me.z.undefined()),Vo=t("setViewport",Qe),Oo=t("getViewportConstraints",me.z.undefined()),Uo=t("setViewportConstraints",$e),Ro=t("fitViewportToBounds",Je),No=p("onViewportMove"),jo=p("onViewportMoveEnd"),qo=p("onMapIdle"),Xe={methods:[Vo,wo,Oo,Uo,Ro],listeners:[No,jo,qo]};var ce=[_e,Xe,Oe,Le,je,Ce,De,Re];function Ao(r,s,E){let F=new Map;async function L(h){if(!Ko.safeParse(h.data).success){E?.onUnknownMessage?.(h.data);return}let ge=et.safeParse(h.data);if(!ge.success){E?.onInvalidMessage?.(h.data);return}let{data:d}=ge;if(d.type==="felt.ready")h.ports[0]?.postMessage(!0);else if(d.type==="felt.addListener"){if(d.event.eventName==="")throw new Error("felt.addListener eventName cannot be empty");let v="options"in d.event?{options:"options"in d.event?d.event.options:void 0,handler:B=>{h.ports[0]?.postMessage(B)}}:{handler:B=>{h.ports[0]?.postMessage(B)}},H=s.listeners[d.event.eventName](v);F.set(d.event.id,H)}else if(d.type==="felt.removeListener")F.get(d.id)?.(),F.delete(d.id);else try{let v=s.methods[d.type],H=await v(d.params);h.ports[0]?.postMessage(H)}catch(v){h.ports[0]?.postMessage({__error__:Ho(v)})}}return r.addEventListener("message",L),()=>{r.removeEventListener("message",L)}}function Ho(r){return r instanceof Error?r.message:typeof r=="object"&&r!==null&&"message"in r?String(r.message):typeof r=="string"?r:"Unknown error"}var Ye={methods:ce.map(r=>r.methods??[]).flat(),listeners:ce.map(r=>r.listeners??[]).flat()},Bo=g.z.discriminatedUnion("eventName",[g.z.strictObject({eventName:g.z.literal("")}),...Ye.listeners]),Zo=g.z.strictObject({type:g.z.literal("felt.addListener"),event:Bo}),Do=g.z.strictObject({type:g.z.literal("felt.removeListener"),id:g.z.string()}),Wo=g.z.strictObject({type:g.z.literal("felt.ready")}),et=g.z.discriminatedUnion("type",[Wo,Zo,Do,...Ye.methods]),Ko=g.z.object({type:g.z.enum(et.options.map(r=>r.shape.type.value))});0&&(module.exports={createMessageHandler});
1
+ "use strict";var Z=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var nt=Object.getOwnPropertyNames;var at=Object.prototype.hasOwnProperty;var it=(r,s)=>{for(var E in s)Z(r,E,{get:s[E],enumerable:!0})},st=(r,s,E,F)=>{if(s&&typeof s=="object"||typeof s=="function")for(let L of nt(s))!at.call(r,L)&&L!==E&&Z(r,L,{get:()=>s[L],enumerable:!(F=rt(s,L))||F.enumerable});return r};var lt=r=>st(Z({},"__esModule",{value:!0}),r);var er={};it(er,{createMessageHandler:()=>Ko});module.exports=lt(er);var g=require("zod");var y=require("zod");var f=require("zod");function t(r,s){return f.z.strictObject({type:f.z.literal(r),params:s})}function C(r,s){return f.z.strictObject({eventName:f.z.literal(r),id:f.z.string(),options:s})}function l(r){return f.z.strictObject({eventName:f.z.literal(r),id:f.z.string()})}var a=require("zod"),O=a.z.number(),U=a.z.number(),R=a.z.object({latitude:U,longitude:O}),I=a.z.tuple([O,U]),ge=a.z.object({type:a.z.literal("Point"),coordinates:I}),de=a.z.object({type:a.z.literal("Polygon"),coordinates:a.z.array(a.z.array(I))}),pt=a.z.object({type:a.z.literal("LineString"),coordinates:a.z.array(I)}),G=a.z.object({type:a.z.literal("MultiLineString"),coordinates:a.z.array(pt.shape.coordinates)}),ye=a.z.number().min(1).max(23),T=a.z.tuple([O,U,O,U]),z=a.z.object({show:a.z.array(a.z.string()).optional(),hide:a.z.array(a.z.string()).optional()}),mt=a.z.enum(["asc","desc"]),ue=a.z.object({attribute:a.z.string(),direction:mt});var e=require("zod");var u=e.z.object({id:e.z.string(),groupId:e.z.string().nullable(),color:e.z.string(),name:e.z.union([e.z.string(),e.z.null()]),description:e.z.union([e.z.string(),e.z.null()]),attributes:e.z.record(e.z.string(),e.z.unknown())}),N=e.z.object({imageUrl:e.z.string().nullable()}),W=e.z.object({strokeOpacity:e.z.number(),strokeWidth:e.z.number(),strokeStyle:e.z.enum(["solid","dashed","dotted"])}),ct=e.z.enum(["meter","kilometer","foot","mile"]),he=u.extend(N.shape).extend({type:e.z.literal("Place"),coordinates:ge.shape.coordinates,symbol:e.z.string(),frame:e.z.enum(["frame-circle","frame-square"]).nullable(),hideLabel:e.z.boolean()}),K=u.extend(N.shape).extend(W.shape).extend({type:e.z.literal("Path"),coordinates:G.shape.coordinates,distanceMarker:e.z.boolean(),endCaps:e.z.boolean(),routingMode:e.z.enum(["driving","cycling","walking","flying"]).nullable()}),_=u.extend(N.shape).extend(W.shape).extend({type:e.z.literal("Polygon"),coordinates:G.shape.coordinates,fillOpacity:e.z.number().min(0).max(1),areaMarker:e.z.boolean()}),fe=u.extend(N.shape).extend(W.shape).extend({type:e.z.literal("Circle"),coordinates:I,radius:e.z.number(),radiusDisplayAngle:e.z.number(),radiusDisplayUnit:ct.nullable(),fillOpacity:e.z.number().min(0).max(1),radiusMarker:e.z.boolean()}),Q=u.extend({type:e.z.literal("Marker"),coordinates:G.shape.coordinates,opacity:e.z.number().min(0).max(1),size:e.z.number().min(0).max(100),zoom:e.z.number().min(0).max(23)}),$=u.extend({type:e.z.literal("Highlighter"),coordinates:G.shape.coordinates,opacity:e.z.number().min(0).max(1)}),Se=e.z.object({position:I,rotation:e.z.number(),scale:e.z.number(),zoom:e.z.number().min(0).max(23),coordinates:G.shape.coordinates}),xe=e.z.object({text:e.z.string(),align:e.z.enum(["left","center","right"]),style:e.z.enum(["italic","light","regular","caps"]),name:e.z.string()}),J=u.extend(Se.shape).extend(xe.shape).extend({type:e.z.literal("Text")}),X=u.extend(Se.shape).extend(xe.shape).extend({type:e.z.literal("Note"),widthScale:e.z.number().min(0)}),Y=u.extend({type:e.z.literal("Image"),coordinates:G.shape.coordinates,imageUrl:e.z.string(),opacity:e.z.number().min(0).max(1)}).omit({color:!0}),gt=u.extend({type:e.z.literal("Link"),coordinates:G.shape.coordinates,url:e.z.string()}),S={type:!0,coordinates:!0},x={id:!0},ee=he.partial().required(S).omit(x),j=K.partial().required(S).omit(x),te=_.partial().required(S).omit(x),oe=fe.partial().required(S).required({radius:!0}).omit(x),re=Q.partial().required(S).omit(x),ne=$.partial().required(S).omit(x),ae=J.partial().required(S).required({text:!0}).omit(x).omit({coordinates:!0,name:!0}),ie=X.partial().required(S).required({text:!0}).omit(x).omit({coordinates:!0,name:!0}),dt=Y.partial().required(S).required({imageUrl:!0}).omit(x),Me=e.z.discriminatedUnion("type",[ee,j,te,oe,re,ne,dt,ae,ie]);var ir=K.omit({coordinates:!0}),sr=_.omit({coordinates:!0});var lr=Q.omit({coordinates:!0}),pr=$.omit({coordinates:!0}),mr=J.omit({coordinates:!0}),cr=X.omit({coordinates:!0}),gr=Y.omit({coordinates:!0}),dr=gt.omit({coordinates:!0}),M={type:!0,id:!0},yt=he.partial().required(M),ut=K.partial().required(M),ht=_.partial().required(M),ft=fe.partial().required(M),St=Q.partial().required(M),xt=$.partial().required(M),Mt=J.partial().required(M).omit({coordinates:!0,name:!0}),bt=X.partial().required(M).omit({coordinates:!0,name:!0}),Lt=Y.partial().required(M),be=e.z.discriminatedUnion("type",[yt,ut,ht,ft,St,xt,Mt,bt,Lt]),Le=e.z.object({ids:e.z.array(e.z.string()).optional()}),Ce=e.z.object({ids:e.z.array(e.z.string()).optional()});var Ct=t("getElement",y.z.string()),It=t("getElementGeometry",y.z.string()),Gt=t("getElements",Le.optional()),Et=t("getElementGroup",y.z.string()),Tt=t("getElementGroups",Ce.optional()),zt=t("setElementGroupVisibility",z),Pt=C("onElementChange",y.z.object({id:y.z.string()})),Ft=l("onElementCreate"),kt=l("onElementCreateEnd"),wt=C("onElementDelete",y.z.object({id:y.z.string()})),vt=C("onElementGroupChange",y.z.object({id:y.z.string()})),Vt=t("createElement",Me),Ot=t("updateElement",be),Ut=t("deleteElement",y.z.string()),Ie={methods:[Ct,It,Gt,Et,Tt,zt,Vt,Ot,Ut],listeners:[Pt,Ft,kt,wt,vt]};var Rt=l("onPointerClick"),Nt=l("onPointerMove"),Ge={methods:null,listeners:[Rt,Nt]};var p=require("zod");var n=require("zod"),jt=n.z.enum(["in","ni"]),qt=n.z.enum(["lt","gt","le","ge","eq","ne","cn","nc","is","isnt"]),br=n.z.enum(["and","or"]),Ee=n.z.union([n.z.number(),n.z.string(),n.z.boolean(),n.z.null()]),Te=n.z.string().or(n.z.null()),At=n.z.tuple([Te,jt,n.z.array(Ee).or(n.z.null())]),Ht=n.z.tuple([Te,qt,Ee]),se=n.z.union([At,Ht]),le=n.z.tuple([n.z.lazy(()=>n.z.union([le,se,n.z.null(),n.z.boolean()])),n.z.enum(["and","or"]),n.z.lazy(()=>n.z.union([le,se,n.z.null(),n.z.boolean()]))]),P=n.z.union([le,se,n.z.null(),n.z.boolean()]);var o=require("zod");var ze=o.z.enum(["avg","max","min","sum","median"]),Bt=o.z.object({method:ze,attribute:o.z.string()}),Dt=o.z.object({methods:o.z.array(o.z.union([ze,o.z.literal("count")])),attribute:o.z.string().optional()}),q=o.z.union([T,de,o.z.array(I)]),Pe=o.z.object({boundary:q.optional(),filters:P.optional(),aggregation:Bt.optional()}),Fe=o.z.object({layerId:o.z.string(),attribute:o.z.string(),limit:o.z.number().optional(),boundary:q.optional(),filters:P.optional(),values:Pe.optional()}),Gr=o.z.object({key:o.z.union([o.z.number(),o.z.string(),o.z.boolean()]),value:o.z.number().nullable()}),Zt=o.z.object({type:o.z.literal("equal-intervals"),count:o.z.number()}),Wt=o.z.object({type:o.z.literal("time-interval"),interval:o.z.enum(["hour","day","week","month","year"])}),ke=o.z.object({layerId:o.z.string(),attribute:o.z.string(),steps:o.z.union([Zt,Wt,o.z.array(o.z.number())]),boundary:q.optional(),filters:P.optional(),values:Pe.optional()}),Er=o.z.object({min:o.z.number(),max:o.z.number(),value:o.z.number()}),we=o.z.object({layerId:o.z.string(),boundary:q.optional(),filters:P.optional(),aggregation:Dt});var i=require("zod");var Pr=i.z.enum(["processing","completed","failed","incomplete"]),ve=i.z.object({ids:i.z.array(i.z.string()).optional()}),Ve=i.z.object({ids:i.z.array(i.z.string()).optional()}),k=i.z.object({id:i.z.string(),layerId:i.z.string()}),Oe=i.z.object({ids:k.array().optional(),layerIds:i.z.string().array().optional()}),Ue=i.z.object({layerIds:i.z.array(i.z.string()).optional(),areaQuery:i.z.union([i.z.object({coordinates:R}),i.z.object({boundary:T})]).optional()});var Kt=t("getLayer",p.z.string()),_t=t("getLayers",ve.optional()),Qt=t("setLayerVisibility",z),$t=C("onLayerChange",p.z.object({id:p.z.string()})),Jt=t("setLayerStyle",p.z.object({id:p.z.string(),style:p.z.object({}).passthrough()})),Xt=t("setLayerLegendVisibility",z),Yt=t("getLayerGroup",p.z.string()),eo=t("getLayerGroups",Ve.optional()),to=t("setLayerGroupVisibility",z),oo=t("setLayerGroupLegendVisibility",z),ro=C("onLayerGroupChange",p.z.object({id:p.z.string()})),no=t("getLegendItem",k),ao=t("getLegendItems",Oe.optional()),io=C("onLegendItemChange",k),so=t("setLegendItemVisibility",p.z.object({show:k.array().optional(),hide:k.array().optional()})),lo=t("getLayerFilters",p.z.string()),po=t("setLayerFilters",p.z.object({layerId:p.z.string(),filters:P,note:p.z.string().optional()})),mo=t("getRenderedFeatures",Ue.optional()),co=t("getCategoryData",Fe),go=t("getHistogramData",ke),yo=t("getAggregates",we),Re={methods:[Kt,_t,Qt,Jt,Xt,Yt,eo,to,oo,no,ao,so,lo,po,mo,co,go,yo],listeners:[$t,ro,io]};var Ne=require("zod");var uo=t("getMapDetails",Ne.z.undefined()),je={methods:[uo],listeners:[]};var v=require("zod");var b=require("zod"),qe=b.z.object({id:b.z.string().or(b.z.number()),layerId:b.z.string(),showPopup:b.z.boolean().optional(),fitViewport:b.z.boolean().or(b.z.object({maxZoom:b.z.number()})).optional()});var ho=t("getSelection",v.z.undefined()),fo=l("onSelectionChange"),So=t("selectFeature",qe),xo=t("clearSelection",v.z.object({features:v.z.boolean().optional(),elements:v.z.boolean().optional()}).optional()),Ae={methods:[ho,So,xo],listeners:[fo]};var We=require("zod");var m=require("zod");var He=["pin","line","route","polygon","circle","marker","highlighter","text","note"],Be=m.z.enum([...He,"link"]),De=m.z.enum(He),Mo=ee.pick({color:!0,symbol:!0,frame:!0}).required(),bo=j.pick({color:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,distanceMarker:!0}).required(),Lo=j.pick({color:!0,routingMode:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,distanceMarker:!0,endCaps:!0}).required(),Co=te.pick({color:!0,fillOpacity:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,areaMarker:!0}).required(),Io=oe.pick({color:!0,fillOpacity:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,radiusMarker:!0}).required(),Go=re.pick({color:!0,opacity:!0,size:!0}).required(),Eo=ne.pick({color:!0,opacity:!0}).extend({size:m.z.number().min(0).max(200)}).required(),To=ae.pick({color:!0,align:!0,style:!0}).required(),zo=ie.pick({color:!0,align:!0,style:!0}).required(),Ze=m.z.discriminatedUnion("tool",[Mo.partial().extend({tool:m.z.literal("pin")}),bo.partial().extend({tool:m.z.literal("line")}),Lo.partial().extend({tool:m.z.literal("route")}),Co.partial().extend({tool:m.z.literal("polygon")}),Io.partial().extend({tool:m.z.literal("circle")}),Go.partial().extend({tool:m.z.literal("marker")}),Eo.partial().extend({tool:m.z.literal("highlighter")}),To.partial().extend({tool:m.z.literal("text")}),zo.partial().extend({tool:m.z.literal("note")})]);var Po=t("setTool",Be.nullable()),Fo=t("getTool",We.z.undefined()),ko=l("onToolChange"),wo=t("setToolSettings",Ze),vo=t("getToolSettings",De),Vo=l("onToolSettingsChange"),Ke={methods:[Po,Fo,wo,vo],listeners:[ko,Vo]};var A=require("zod");var c=require("zod"),_e=c.z.object({showLegend:c.z.boolean().optional(),cooperativeGestures:c.z.boolean().optional(),fullScreenButton:c.z.boolean().optional(),geolocation:c.z.boolean().optional(),zoomControls:c.z.boolean().optional(),scaleBar:c.z.boolean().optional()}),Qe=c.z.object({featureSelectPanel:c.z.boolean().optional(),featureHoverPanel:c.z.boolean().optional(),elementSelectPanel:c.z.boolean().optional(),linkClickOpen:c.z.boolean().optional(),imageLightboxOpen:c.z.boolean().optional()});var Oo=t("updateUiControls",_e),Uo=t("setOnMapInteractionsUi",Qe),Ro=t("showLayerDataTable",A.z.object({layerId:A.z.string(),sorting:ue.optional()}).optional()),No=t("hideLayerDataTable",A.z.undefined()),$e={methods:[Oo,Uo,Ro,No],listeners:null};var pe=require("zod");var V=require("zod");var H=V.z.object({center:R,zoom:ye}),Je=V.z.object({center:H.shape.center.optional(),zoom:H.shape.zoom.optional()}),Xe=V.z.object({minZoom:H.shape.zoom.nullish(),maxZoom:H.shape.zoom.nullish(),bounds:T.nullish()}).nullable(),Ye=V.z.object({bounds:T});var jo=t("getViewport",pe.z.undefined()),qo=t("setViewport",Je),Ao=t("getViewportConstraints",pe.z.undefined()),Ho=t("setViewportConstraints",Xe),Bo=t("fitViewportToBounds",Ye),Do=l("onViewportMove"),Zo=l("onViewportMoveEnd"),Wo=l("onMapIdle"),et={methods:[qo,jo,Ao,Ho,Bo],listeners:[Do,Zo,Wo]};var me=[$e,et,Re,Ie,Ae,Ge,Ke,je];function Ko(r,s,E){let F=new Map;async function L(h){if(!Yo.safeParse(h.data).success){E?.onUnknownMessage?.(h.data);return}let ce=ot.safeParse(h.data);if(!ce.success){E?.onInvalidMessage?.(h.data);return}let{data:d}=ce;if(d.type==="felt.ready")h.ports[0]?.postMessage(!0);else if(d.type==="felt.addListener"){if(d.event.eventName==="")throw new Error("felt.addListener eventName cannot be empty");let w="options"in d.event?{options:"options"in d.event?d.event.options:void 0,handler:D=>{h.ports[0]?.postMessage(D)}}:{handler:D=>{h.ports[0]?.postMessage(D)}},B=s.listeners[d.event.eventName](w);F.set(d.event.id,B)}else if(d.type==="felt.removeListener")F.get(d.id)?.(),F.delete(d.id);else try{let w=s.methods[d.type],B=await w(d.params);h.ports[0]?.postMessage(B)}catch(w){h.ports[0]?.postMessage({__error__:_o(w)})}}return r.addEventListener("message",L),()=>{r.removeEventListener("message",L)}}function _o(r){return r instanceof Error?r.message:typeof r=="object"&&r!==null&&"message"in r?String(r.message):typeof r=="string"?r:"Unknown error"}var tt={methods:me.map(r=>r.methods??[]).flat(),listeners:me.map(r=>r.listeners??[]).flat()},Qo=g.z.discriminatedUnion("eventName",[g.z.strictObject({eventName:g.z.literal("")}),...tt.listeners]),$o=g.z.strictObject({type:g.z.literal("felt.addListener"),event:Qo}),Jo=g.z.strictObject({type:g.z.literal("felt.removeListener"),id:g.z.string()}),Xo=g.z.strictObject({type:g.z.literal("felt.ready")}),ot=g.z.discriminatedUnion("type",[Xo,$o,Jo,...tt.methods]),Yo=g.z.object({type:g.z.enum(ot.options.map(r=>r.shape.type.value))});0&&(module.exports={createMessageHandler});