@feltmaps/js-sdk 1.5.0-next.3 → 1.5.0-next.5
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 +1 -1
- package/dist/client.d.cts +74 -10
- package/dist/client.d.ts +74 -10
- package/dist/client.js +1 -1
- package/dist/handler.cjs +1 -1
- package/dist/handler.d.cts +120 -61
- package/dist/handler.d.ts +120 -61
- package/dist/handler.js +1 -1
- package/dist/{types-C1KBpQWi.d.cts → types-BKxKmuZn.d.cts} +67 -36
- package/dist/{types-C1KBpQWi.d.ts → types-BKxKmuZn.d.ts} +67 -36
- package/handler.d.ts +120 -61
- package/handler.js +1 -1
- package/package.json +1 -1
- package/{types-C1KBpQWi.d.ts → types-BKxKmuZn.d.ts} +67 -36
package/dist/client.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var g=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var
|
|
1
|
+
"use strict";var g=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var I=(e,n)=>{for(var r in n)g(e,r,{get:n[r],enumerable:!0})},x=(e,n,r,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let l of S(n))!b.call(e,l)&&l!==r&&g(e,l,{get:()=>n[l],enumerable:!(s=F(n,l))||s.enumerable});return e};var f=e=>x(g({},"__esModule",{value:!0}),e);var K={};I(K,{Felt:()=>M});module.exports=f(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")});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[m,y]of G(d))y!=null&&i.searchParams.set(a[m],y?"1":"0");if(r?.token&&i.searchParams.set("token",r.token),r?.initialViewport){let m=r.initialViewport;i.searchParams.set("loc",`${m.center.latitude},${m.center.longitude},${m.zoom}z`)}let c=e.tagName==="IFRAME",p=c?e:e.ownerDocument.createElement("iframe");return p.src=i.toString(),c||(p.style.width="100%",p.style.height="100%",p.style.border="none",p.style.margin="0",e.appendChild(p)),p.referrerPolicy="strict-origin-when-cross-origin",new Promise((m,y)=>{p.addEventListener("load",()=>{p.contentWindow==null?y(new Error("Failed to load Felt map")):m(p.contentWindow)},{once:!0})}).then(M.connect).then(m=>(Object.defineProperties(m,{iframe:{value:p,writable:!1,configurable:!1}}),m))},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))}})}},G=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, M as MapInteractionEvent, t as
|
|
2
|
-
export {
|
|
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, M as MapInteractionEvent, t as MapDetails, u as EntityNode, v as FeatureSelection, T as ToolType, I as InputToolSettings, C as ConfigurableToolType, w as ToolSettingsMap, x as ToolSettingsChangeEvent, z as zInfer, V as ViewportState, y as SetViewportCenterZoomParams, A as ViewportConstraints, B as ViewportFitBoundsParams, D as ViewportCenterZoom } from './types-BKxKmuZn.cjs';
|
|
2
|
+
export { H as CircleElementCreate, J as CircleElementRead, K as CircleElementUpdate, aw as CircleToolSettings, ai as ElementGroupNode, aj as ElementNode, ak as FeatureNode, an as FeltBoundary, ao as FeltZoom, af as FilterExpression, ag as FilterLogicGate, ah as FilterTernary, N as HighlighterElementCreate, O as HighlighterElementRead, P as HighlighterElementUpdate, ax as HighlighterToolSettings, Q as ImageElementCreate, R as ImageElementRead, U as ImageElementUpdate, ap as LatLng, al as LayerGroupNode, am as LayerNode, ad as LayerProcessingStatus, aq as LineStringGeometry, ay as LineToolSettings, W as LinkElementRead, ar as LngLatTuple, X as MarkerElementCreate, Y as MarkerElementRead, Z as MarkerElementUpdate, az as MarkerToolSettings, as as MultiLineStringGeometry, at as MultiPolygonGeometry, _ as NoteElementCreate, $ as NoteElementRead, a0 as NoteElementUpdate, aA as NoteToolSettings, a1 as PathElementCreate, a2 as PathElementRead, a3 as PathElementUpdate, aB as PinToolSettings, a4 as PlaceElementCreate, a5 as PlaceElementRead, a6 as PlaceElementUpdate, aC as PlaceFrame, aD as PlaceSymbol, au as PointGeometry, a7 as PolygonElementCreate, a8 as PolygonElementRead, a9 as PolygonElementUpdate, av as PolygonGeometry, aE as PolygonToolSettings, ae as RasterValue, aF as RouteToolSettings, aa as TextElementCreate, ab as TextElementRead, ac as TextElementUpdate, aG as TextToolSettings } from './types-BKxKmuZn.cjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -91,6 +91,30 @@ interface ElementsController {
|
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
93
93
|
setElementGroupVisibility(visibility: SetVisibilityRequest): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Adds a listener for when an element is created.
|
|
96
|
+
*
|
|
97
|
+
* @returns A function to unsubscribe from the listener
|
|
98
|
+
*
|
|
99
|
+
* @event
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const unsubscribe = felt.onElementCreate({
|
|
103
|
+
* handler: (element) => console.log(element.id),
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* // later on...
|
|
107
|
+
* unsubscribe();
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
onElementCreate(args: {
|
|
111
|
+
/**
|
|
112
|
+
* The handler that is called when an element is created.
|
|
113
|
+
*
|
|
114
|
+
* @param change - An object describing the change that occurred.
|
|
115
|
+
*/
|
|
116
|
+
handler: (change: ElementChangeCallbackParams) => void;
|
|
117
|
+
}): VoidFunction;
|
|
94
118
|
/**
|
|
95
119
|
* Adds a listener for when an element changes.
|
|
96
120
|
*
|
|
@@ -124,6 +148,35 @@ interface ElementsController {
|
|
|
124
148
|
*/
|
|
125
149
|
change: ElementChangeCallbackParams) => void;
|
|
126
150
|
}): VoidFunction;
|
|
151
|
+
/**
|
|
152
|
+
* Adds a listener for when an element is deleted.
|
|
153
|
+
*
|
|
154
|
+
* @returns A function to unsubscribe from the listener
|
|
155
|
+
*
|
|
156
|
+
* @event
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const unsubscribe = felt.onElementDelete({
|
|
160
|
+
* options: { id: "element-1" },
|
|
161
|
+
* handler: (element) => console.log(element.id),
|
|
162
|
+
* });
|
|
163
|
+
*
|
|
164
|
+
* // later on...
|
|
165
|
+
* unsubscribe();
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
onElementDelete(args: {
|
|
169
|
+
options: {
|
|
170
|
+
/**
|
|
171
|
+
* The id of the element to listen for deletions of.
|
|
172
|
+
*/
|
|
173
|
+
id: string;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* The handler that is called when the element is deleted.
|
|
177
|
+
*/
|
|
178
|
+
handler: () => void;
|
|
179
|
+
}): VoidFunction;
|
|
127
180
|
/**
|
|
128
181
|
* Adds a listener for when an element group changes.
|
|
129
182
|
*
|
|
@@ -155,11 +208,11 @@ interface ElementsController {
|
|
|
155
208
|
* const element = await felt.createElement({ type: "Place", coordinates: [10, 10] });
|
|
156
209
|
* ```
|
|
157
210
|
*/
|
|
158
|
-
createElement(element: ElementCreate): Promise<Element
|
|
211
|
+
createElement(element: ElementCreate): Promise<Element>;
|
|
159
212
|
/**
|
|
160
213
|
* Update an element on the map.
|
|
161
214
|
*/
|
|
162
|
-
updateElement(element: ElementUpdate): Promise<Element
|
|
215
|
+
updateElement(element: ElementUpdate): Promise<Element>;
|
|
163
216
|
/**
|
|
164
217
|
* Delete an element from the map.
|
|
165
218
|
*/
|
|
@@ -540,6 +593,17 @@ interface InteractionsController {
|
|
|
540
593
|
}): VoidFunction;
|
|
541
594
|
}
|
|
542
595
|
|
|
596
|
+
/**
|
|
597
|
+
* @group Controller
|
|
598
|
+
* @public
|
|
599
|
+
*/
|
|
600
|
+
interface MiscController {
|
|
601
|
+
/**
|
|
602
|
+
* Gets the details of the map.
|
|
603
|
+
*/
|
|
604
|
+
getMapDetails(): Promise<MapDetails>;
|
|
605
|
+
}
|
|
606
|
+
|
|
543
607
|
/**
|
|
544
608
|
* The Selection controller allows you to listen for changes to the selection on the map.
|
|
545
609
|
*
|
|
@@ -1042,7 +1106,7 @@ interface ViewportController {
|
|
|
1042
1106
|
* @group Controller
|
|
1043
1107
|
* @public
|
|
1044
1108
|
*/
|
|
1045
|
-
interface FeltController extends ViewportController, UiController, LayersController, ElementsController, SelectionController, InteractionsController, ToolsController {
|
|
1109
|
+
interface FeltController extends ViewportController, UiController, LayersController, ElementsController, SelectionController, InteractionsController, ToolsController, InteractionsController, MiscController {
|
|
1046
1110
|
/**
|
|
1047
1111
|
* The iframe element containing the Felt map, if it is an embedded map.
|
|
1048
1112
|
*
|
|
@@ -1107,17 +1171,17 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
|
|
|
1107
1171
|
}>;
|
|
1108
1172
|
zoom: z.ZodNumber;
|
|
1109
1173
|
}, "strip", z.ZodTypeAny, {
|
|
1174
|
+
zoom: number;
|
|
1110
1175
|
center: {
|
|
1111
1176
|
latitude: number;
|
|
1112
1177
|
longitude: number;
|
|
1113
1178
|
};
|
|
1114
|
-
zoom: number;
|
|
1115
1179
|
}, {
|
|
1180
|
+
zoom: number;
|
|
1116
1181
|
center: {
|
|
1117
1182
|
latitude: number;
|
|
1118
1183
|
longitude: number;
|
|
1119
1184
|
};
|
|
1120
|
-
zoom: number;
|
|
1121
1185
|
}>>;
|
|
1122
1186
|
}, "strip", z.ZodTypeAny, {
|
|
1123
1187
|
origin?: string | undefined;
|
|
@@ -1131,11 +1195,11 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
|
|
|
1131
1195
|
scaleBar?: boolean | undefined;
|
|
1132
1196
|
} | undefined;
|
|
1133
1197
|
initialViewport?: {
|
|
1198
|
+
zoom: number;
|
|
1134
1199
|
center: {
|
|
1135
1200
|
latitude: number;
|
|
1136
1201
|
longitude: number;
|
|
1137
1202
|
};
|
|
1138
|
-
zoom: number;
|
|
1139
1203
|
} | undefined;
|
|
1140
1204
|
}, {
|
|
1141
1205
|
origin?: string | undefined;
|
|
@@ -1149,11 +1213,11 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
|
|
|
1149
1213
|
scaleBar?: boolean | undefined;
|
|
1150
1214
|
} | undefined;
|
|
1151
1215
|
initialViewport?: {
|
|
1216
|
+
zoom: number;
|
|
1152
1217
|
center: {
|
|
1153
1218
|
latitude: number;
|
|
1154
1219
|
longitude: number;
|
|
1155
1220
|
};
|
|
1156
|
-
zoom: number;
|
|
1157
1221
|
} | undefined;
|
|
1158
1222
|
}>;
|
|
1159
1223
|
|
|
@@ -1213,4 +1277,4 @@ declare const Felt: {
|
|
|
1213
1277
|
connect(feltWindow: Window): Promise<FeltController>;
|
|
1214
1278
|
};
|
|
1215
1279
|
|
|
1216
|
-
export { ConfigurableToolType, Element, ElementChangeCallbackParams, ElementCreate, ElementGroup, ElementGroupChangeCallbackParams, ElementUpdate, type ElementsController, EntityNode, Feature, FeatureSelection, Felt, type FeltController, type FeltEmbedOptions, Filters, Geometry, GetElementGroupsConstraint, GetElementsConstraint, GetLayerGroupsConstraint, GetLayersConstraint, GetRenderedFeaturesConstraint, InputToolSettings, type InteractionsController, Layer, LayerChangeCallbackParams, LayerFilters, LayerGroup, LayerGroupChangeCallbackParams, type LayersController, LegendItem, LegendItemChangeCallbackParams, LegendItemIdentifier, LegendItemsConstraint, MapInteractionEvent, type UiOnMapInteractionsOptions as OnMapInteractionsOptions, type SelectionController, SetViewportCenterZoomParams, SetVisibilityRequest, ToolSettingsChangeEvent, ToolSettingsMap, ToolType, type ToolsController, type UiController, type UiControlsOptions, ViewportCenterZoom, ViewportConstraints, type ViewportController, ViewportFitBoundsParams, ViewportState };
|
|
1280
|
+
export { ConfigurableToolType, Element, ElementChangeCallbackParams, ElementCreate, ElementGroup, ElementGroupChangeCallbackParams, ElementUpdate, type ElementsController, EntityNode, Feature, FeatureSelection, Felt, type FeltController, type FeltEmbedOptions, Filters, Geometry, GetElementGroupsConstraint, GetElementsConstraint, GetLayerGroupsConstraint, 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 };
|
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, M as MapInteractionEvent, t as
|
|
2
|
-
export {
|
|
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, M as MapInteractionEvent, t as MapDetails, u as EntityNode, v as FeatureSelection, T as ToolType, I as InputToolSettings, C as ConfigurableToolType, w as ToolSettingsMap, x as ToolSettingsChangeEvent, z as zInfer, V as ViewportState, y as SetViewportCenterZoomParams, A as ViewportConstraints, B as ViewportFitBoundsParams, D as ViewportCenterZoom } from './types-BKxKmuZn.js';
|
|
2
|
+
export { H as CircleElementCreate, J as CircleElementRead, K as CircleElementUpdate, aw as CircleToolSettings, ai as ElementGroupNode, aj as ElementNode, ak as FeatureNode, an as FeltBoundary, ao as FeltZoom, af as FilterExpression, ag as FilterLogicGate, ah as FilterTernary, N as HighlighterElementCreate, O as HighlighterElementRead, P as HighlighterElementUpdate, ax as HighlighterToolSettings, Q as ImageElementCreate, R as ImageElementRead, U as ImageElementUpdate, ap as LatLng, al as LayerGroupNode, am as LayerNode, ad as LayerProcessingStatus, aq as LineStringGeometry, ay as LineToolSettings, W as LinkElementRead, ar as LngLatTuple, X as MarkerElementCreate, Y as MarkerElementRead, Z as MarkerElementUpdate, az as MarkerToolSettings, as as MultiLineStringGeometry, at as MultiPolygonGeometry, _ as NoteElementCreate, $ as NoteElementRead, a0 as NoteElementUpdate, aA as NoteToolSettings, a1 as PathElementCreate, a2 as PathElementRead, a3 as PathElementUpdate, aB as PinToolSettings, a4 as PlaceElementCreate, a5 as PlaceElementRead, a6 as PlaceElementUpdate, aC as PlaceFrame, aD as PlaceSymbol, au as PointGeometry, a7 as PolygonElementCreate, a8 as PolygonElementRead, a9 as PolygonElementUpdate, av as PolygonGeometry, aE as PolygonToolSettings, ae as RasterValue, aF as RouteToolSettings, aa as TextElementCreate, ab as TextElementRead, ac as TextElementUpdate, aG as TextToolSettings } from './types-BKxKmuZn.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -91,6 +91,30 @@ interface ElementsController {
|
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
93
93
|
setElementGroupVisibility(visibility: SetVisibilityRequest): Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Adds a listener for when an element is created.
|
|
96
|
+
*
|
|
97
|
+
* @returns A function to unsubscribe from the listener
|
|
98
|
+
*
|
|
99
|
+
* @event
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* const unsubscribe = felt.onElementCreate({
|
|
103
|
+
* handler: (element) => console.log(element.id),
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* // later on...
|
|
107
|
+
* unsubscribe();
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
onElementCreate(args: {
|
|
111
|
+
/**
|
|
112
|
+
* The handler that is called when an element is created.
|
|
113
|
+
*
|
|
114
|
+
* @param change - An object describing the change that occurred.
|
|
115
|
+
*/
|
|
116
|
+
handler: (change: ElementChangeCallbackParams) => void;
|
|
117
|
+
}): VoidFunction;
|
|
94
118
|
/**
|
|
95
119
|
* Adds a listener for when an element changes.
|
|
96
120
|
*
|
|
@@ -124,6 +148,35 @@ interface ElementsController {
|
|
|
124
148
|
*/
|
|
125
149
|
change: ElementChangeCallbackParams) => void;
|
|
126
150
|
}): VoidFunction;
|
|
151
|
+
/**
|
|
152
|
+
* Adds a listener for when an element is deleted.
|
|
153
|
+
*
|
|
154
|
+
* @returns A function to unsubscribe from the listener
|
|
155
|
+
*
|
|
156
|
+
* @event
|
|
157
|
+
* @example
|
|
158
|
+
* ```typescript
|
|
159
|
+
* const unsubscribe = felt.onElementDelete({
|
|
160
|
+
* options: { id: "element-1" },
|
|
161
|
+
* handler: (element) => console.log(element.id),
|
|
162
|
+
* });
|
|
163
|
+
*
|
|
164
|
+
* // later on...
|
|
165
|
+
* unsubscribe();
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
onElementDelete(args: {
|
|
169
|
+
options: {
|
|
170
|
+
/**
|
|
171
|
+
* The id of the element to listen for deletions of.
|
|
172
|
+
*/
|
|
173
|
+
id: string;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* The handler that is called when the element is deleted.
|
|
177
|
+
*/
|
|
178
|
+
handler: () => void;
|
|
179
|
+
}): VoidFunction;
|
|
127
180
|
/**
|
|
128
181
|
* Adds a listener for when an element group changes.
|
|
129
182
|
*
|
|
@@ -155,11 +208,11 @@ interface ElementsController {
|
|
|
155
208
|
* const element = await felt.createElement({ type: "Place", coordinates: [10, 10] });
|
|
156
209
|
* ```
|
|
157
210
|
*/
|
|
158
|
-
createElement(element: ElementCreate): Promise<Element
|
|
211
|
+
createElement(element: ElementCreate): Promise<Element>;
|
|
159
212
|
/**
|
|
160
213
|
* Update an element on the map.
|
|
161
214
|
*/
|
|
162
|
-
updateElement(element: ElementUpdate): Promise<Element
|
|
215
|
+
updateElement(element: ElementUpdate): Promise<Element>;
|
|
163
216
|
/**
|
|
164
217
|
* Delete an element from the map.
|
|
165
218
|
*/
|
|
@@ -540,6 +593,17 @@ interface InteractionsController {
|
|
|
540
593
|
}): VoidFunction;
|
|
541
594
|
}
|
|
542
595
|
|
|
596
|
+
/**
|
|
597
|
+
* @group Controller
|
|
598
|
+
* @public
|
|
599
|
+
*/
|
|
600
|
+
interface MiscController {
|
|
601
|
+
/**
|
|
602
|
+
* Gets the details of the map.
|
|
603
|
+
*/
|
|
604
|
+
getMapDetails(): Promise<MapDetails>;
|
|
605
|
+
}
|
|
606
|
+
|
|
543
607
|
/**
|
|
544
608
|
* The Selection controller allows you to listen for changes to the selection on the map.
|
|
545
609
|
*
|
|
@@ -1042,7 +1106,7 @@ interface ViewportController {
|
|
|
1042
1106
|
* @group Controller
|
|
1043
1107
|
* @public
|
|
1044
1108
|
*/
|
|
1045
|
-
interface FeltController extends ViewportController, UiController, LayersController, ElementsController, SelectionController, InteractionsController, ToolsController {
|
|
1109
|
+
interface FeltController extends ViewportController, UiController, LayersController, ElementsController, SelectionController, InteractionsController, ToolsController, InteractionsController, MiscController {
|
|
1046
1110
|
/**
|
|
1047
1111
|
* The iframe element containing the Felt map, if it is an embedded map.
|
|
1048
1112
|
*
|
|
@@ -1107,17 +1171,17 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
|
|
|
1107
1171
|
}>;
|
|
1108
1172
|
zoom: z.ZodNumber;
|
|
1109
1173
|
}, "strip", z.ZodTypeAny, {
|
|
1174
|
+
zoom: number;
|
|
1110
1175
|
center: {
|
|
1111
1176
|
latitude: number;
|
|
1112
1177
|
longitude: number;
|
|
1113
1178
|
};
|
|
1114
|
-
zoom: number;
|
|
1115
1179
|
}, {
|
|
1180
|
+
zoom: number;
|
|
1116
1181
|
center: {
|
|
1117
1182
|
latitude: number;
|
|
1118
1183
|
longitude: number;
|
|
1119
1184
|
};
|
|
1120
|
-
zoom: number;
|
|
1121
1185
|
}>>;
|
|
1122
1186
|
}, "strip", z.ZodTypeAny, {
|
|
1123
1187
|
origin?: string | undefined;
|
|
@@ -1131,11 +1195,11 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
|
|
|
1131
1195
|
scaleBar?: boolean | undefined;
|
|
1132
1196
|
} | undefined;
|
|
1133
1197
|
initialViewport?: {
|
|
1198
|
+
zoom: number;
|
|
1134
1199
|
center: {
|
|
1135
1200
|
latitude: number;
|
|
1136
1201
|
longitude: number;
|
|
1137
1202
|
};
|
|
1138
|
-
zoom: number;
|
|
1139
1203
|
} | undefined;
|
|
1140
1204
|
}, {
|
|
1141
1205
|
origin?: string | undefined;
|
|
@@ -1149,11 +1213,11 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
|
|
|
1149
1213
|
scaleBar?: boolean | undefined;
|
|
1150
1214
|
} | undefined;
|
|
1151
1215
|
initialViewport?: {
|
|
1216
|
+
zoom: number;
|
|
1152
1217
|
center: {
|
|
1153
1218
|
latitude: number;
|
|
1154
1219
|
longitude: number;
|
|
1155
1220
|
};
|
|
1156
|
-
zoom: number;
|
|
1157
1221
|
} | undefined;
|
|
1158
1222
|
}>;
|
|
1159
1223
|
|
|
@@ -1213,4 +1277,4 @@ declare const Felt: {
|
|
|
1213
1277
|
connect(feltWindow: Window): Promise<FeltController>;
|
|
1214
1278
|
};
|
|
1215
1279
|
|
|
1216
|
-
export { ConfigurableToolType, Element, ElementChangeCallbackParams, ElementCreate, ElementGroup, ElementGroupChangeCallbackParams, ElementUpdate, type ElementsController, EntityNode, Feature, FeatureSelection, Felt, type FeltController, type FeltEmbedOptions, Filters, Geometry, GetElementGroupsConstraint, GetElementsConstraint, GetLayerGroupsConstraint, GetLayersConstraint, GetRenderedFeaturesConstraint, InputToolSettings, type InteractionsController, Layer, LayerChangeCallbackParams, LayerFilters, LayerGroup, LayerGroupChangeCallbackParams, type LayersController, LegendItem, LegendItemChangeCallbackParams, LegendItemIdentifier, LegendItemsConstraint, MapInteractionEvent, type UiOnMapInteractionsOptions as OnMapInteractionsOptions, type SelectionController, SetViewportCenterZoomParams, SetVisibilityRequest, ToolSettingsChangeEvent, ToolSettingsMap, ToolType, type ToolsController, type UiController, type UiControlsOptions, ViewportCenterZoom, ViewportConstraints, type ViewportController, ViewportFitBoundsParams, ViewportState };
|
|
1280
|
+
export { ConfigurableToolType, Element, ElementChangeCallbackParams, ElementCreate, ElementGroup, ElementGroupChangeCallbackParams, ElementUpdate, type ElementsController, EntityNode, Feature, FeatureSelection, Felt, type FeltController, type FeltEmbedOptions, Filters, Geometry, GetElementGroupsConstraint, GetElementsConstraint, GetLayerGroupsConstraint, 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 };
|
package/dist/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function o(e,
|
|
1
|
+
function o(e,p){return n=>{let r=new MessageChannel,m=n.handler,s="options"in n?n.options:void 0,i=crypto.randomUUID();return e.postMessage({type:"felt.addListener",event:s?{eventName:p,id:i,options:s}:{eventName:p,id:i}},"*",[r.port2]),r.port1.onmessage=d=>{m(d.data)},()=>{r.port1.onmessage=null,r.port1.close(),r.port2.close(),e.postMessage({type:"felt.removeListener",id:i},"*")}}}function t(e,p){return n=>{let r=new MessageChannel;return e.postMessage({type:p,params:n},"*",[r.port2]),new Promise((m,s)=>{r.port1.onmessage=i=>{i.data&&typeof i.data=="object"&&"__error__"in i.data?s(new Error(i.data.__error__)):m(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")});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,p,n){let r={uiControls:{showLegend:!0,cooperativeGestures:!0,fullScreenButton:!0,geolocation:!1,zoomControls:!0,scaleBar:!0},initialViewport:void 0,origin:"https://felt.com"},m=n?.origin??r.origin,s=new URL(`${m}/embed/map/${p}`),i={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(i[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",a=g?e:e.ownerDocument.createElement("iframe");return a.src=s.toString(),g||(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,y)=>{a.addEventListener("load",()=>{a.contentWindow==null?y(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 p=P(e);return new Promise((n,r)=>{let m=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(m),s.port1.close(),s.port2.close(),n(p))}})}},M=Object.entries;export{V as Felt};
|
package/dist/handler.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Z=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var De=Object.getOwnPropertyNames;var Ke=Object.prototype.hasOwnProperty;var _e=(o,i)=>{for(var C in i)Z(o,C,{get:i[C],enumerable:!0})},Qe=(o,i,C,T)=>{if(i&&typeof i=="object"||typeof i=="function")for(let b of De(i))!Ke.call(o,b)&&b!==C&&Z(o,b,{get:()=>i[b],enumerable:!(T=We(i,b))||T.enumerable});return o};var $e=o=>Qe(Z({},"__esModule",{value:!0}),o);var zo={};_e(zo,{createMessageHandler:()=>bo});module.exports=$e(zo);var m=require("zod");var x=require("zod");var u=require("zod");function t(o,i){return u.z.strictObject({type:u.z.literal(o),params:i})}function I(o,i){return u.z.strictObject({eventName:u.z.literal(o),id:u.z.string(),options:i})}function d(o){return u.z.strictObject({eventName:u.z.literal(o),id:u.z.string()})}var n=require("zod"),v=n.z.number(),V=n.z.number(),U=n.z.object({latitude:V,longitude:v}),P=n.z.tuple([v,V]),me=n.z.object({type:n.z.literal("Point"),coordinates:P}),Je=n.z.object({type:n.z.literal("LineString"),coordinates:n.z.array(P)}),L=n.z.object({type:n.z.literal("MultiLineString"),coordinates:n.z.array(Je.shape.coordinates)}),ce=n.z.number().min(1).max(23),k=n.z.tuple([v,V,v,V]),E=n.z.object({show:n.z.array(n.z.string()).optional(),hide:n.z.array(n.z.string()).optional()});var e=require("zod");var y=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())}),R=e.z.object({imageUrl:e.z.string().nullable()}),B=e.z.object({strokeOpacity:e.z.number(),strokeWidth:e.z.number(),strokeStyle:e.z.enum(["solid","dashed","dotted"])}),Xe=e.z.enum(["meter","kilometer","foot","mile"]),H=y.extend(R.shape).extend({type:e.z.literal("Place"),coordinates:me.shape.coordinates,symbol:e.z.string(),frame:e.z.enum(["frame-circle","frame-square"]).nullable(),hideLabel:e.z.boolean()}),A=y.extend(R.shape).extend(B.shape).extend({type:e.z.literal("Path"),coordinates:L.shape.coordinates,distanceMarker:e.z.boolean(),endCaps:e.z.boolean(),routingMode:e.z.enum(["driving","cycling","walking","flying"]).nullable()}),W=y.extend(R.shape).extend(B.shape).extend({type:e.z.literal("Polygon"),coordinates:L.shape.coordinates,fillOpacity:e.z.number().min(0).max(1),areaMarker:e.z.boolean()}),D=y.extend(R.shape).extend(B.shape).extend({type:e.z.literal("Circle"),coordinates:P,radius:e.z.number(),radiusDisplayAngle:e.z.number(),radiusDisplayUnit:Xe.nullable(),fillOpacity:e.z.number().min(0).max(1),radiusMarker:e.z.boolean()}),K=y.extend({type:e.z.literal("Marker"),coordinates:L.shape.coordinates,opacity:e.z.number().min(0).max(1),size:e.z.number().min(0).max(100)}),_=y.extend({type:e.z.literal("Highlighter"),coordinates:L.shape.coordinates,opacity:e.z.number().min(0).max(1)}),de=e.z.object({position:P,rotation:e.z.number(),scale:e.z.number(),coordinates:L.shape.coordinates}),ye=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()}),Q=y.extend(de.shape).extend(ye.shape).extend({type:e.z.literal("Text")}),$=y.extend(de.shape).extend(ye.shape).extend({type:e.z.literal("Note"),widthMultiplier:e.z.number().min(0)}),J=y.extend({type:e.z.literal("Image"),coordinates:L.shape.coordinates,imageUrl:e.z.string(),opacity:e.z.number().min(0).max(1)}),Ye=y.extend({type:e.z.literal("Link"),coordinates:L.shape.coordinates,url:e.z.string()}),h={type:!0,coordinates:!0},f={id:!0},X=H.partial().required(h).omit(f),O=A.partial().required(h).omit(f),Y=W.partial().required(h).omit(f),ee=D.partial().required(h).required({radius:!0}).omit(f),te=K.partial().required(h).omit(f),oe=_.partial().required(h).omit(f),re=Q.partial().required(h).required({text:!0}).omit(f).omit({coordinates:!0,name:!0}),ne=$.partial().required(h).required({text:!0}).omit(f).omit({coordinates:!0,name:!0}),et=J.partial().required(h).required({imageUrl:!0}).omit(f),ge=e.z.discriminatedUnion("type",[X,O,Y,ee,te,oe,et,re,ne]),Vo=H.omit({coordinates:!0}),Uo=A.omit({coordinates:!0}),Ro=W.omit({coordinates:!0}),Oo=D.omit({coordinates:!0}),No=K.omit({coordinates:!0}),jo=_.omit({coordinates:!0}),qo=Q.omit({coordinates:!0}),Zo=$.omit({coordinates:!0}),Bo=J.omit({coordinates:!0}),Ho=Ye.omit({coordinates:!0}),S={type:!0,id:!0},tt=H.partial().required(S),ot=A.partial().required(S),rt=W.partial().required(S),nt=D.partial().required(S),at=K.partial().required(S),it=_.partial().required(S),st=Q.partial().required(S),lt=$.partial().required(S),pt=J.partial().required(S),ue=e.z.discriminatedUnion("type",[tt,ot,rt,nt,at,it,st,lt,pt]),he=e.z.object({ids:e.z.array(e.z.string()).optional()}),fe=e.z.object({ids:e.z.array(e.z.string()).optional()});var mt=t("getElement",x.z.string()),ct=t("getElementGeometry",x.z.string()),dt=t("getElements",he.optional()),yt=t("getElementGroup",x.z.string()),gt=t("getElementGroups",fe.optional()),ut=t("setElementGroupVisibility",E),ht=I("onElementChange",x.z.object({id:x.z.string()})),ft=I("onElementGroupChange",x.z.object({id:x.z.string()})),St=t("createElement",ge),xt=t("updateElement",ue),Mt=t("deleteElement",x.z.string()),Se={methods:[mt,ct,dt,yt,gt,ut,St,xt,Mt],listeners:[ht,ft]};var bt=d("onPointerClick"),Lt=d("onPointerMove"),xe={methods:null,listeners:[bt,Lt]};var s=require("zod");var r=require("zod"),Ct=r.z.enum(["in","ni"]),It=r.z.enum(["lt","gt","le","ge","eq","ne","cn","nc","is","isnt"]),Jo=r.z.enum(["and","or"]),Me=r.z.union([r.z.number(),r.z.string(),r.z.boolean(),r.z.null()]),be=r.z.string().or(r.z.null()),Et=r.z.tuple([be,Ct,r.z.array(Me).or(r.z.null())]),Tt=r.z.tuple([be,It,Me]),ae=r.z.union([Et,Tt]),ie=r.z.tuple([r.z.lazy(()=>r.z.union([ie,ae,r.z.null(),r.z.boolean()])),r.z.enum(["and","or"]),r.z.lazy(()=>r.z.union([ie,ae,r.z.null(),r.z.boolean()]))]),Le=r.z.union([ie,ae,r.z.null(),r.z.boolean()]);var a=require("zod");var er=a.z.enum(["processing","completed","failed","incomplete"]),Ce=a.z.object({ids:a.z.array(a.z.string()).optional()}),Ie=a.z.object({ids:a.z.array(a.z.string()).optional()}),G=a.z.object({id:a.z.string(),layerId:a.z.string()}),Ee=a.z.object({ids:G.array().optional(),layerIds:a.z.string().array().optional()}),Te=a.z.object({layerIds:a.z.array(a.z.string()).optional(),areaQuery:a.z.union([a.z.object({coordinates:U}),a.z.object({boundary:k})]).optional()});var Gt=t("getLayer",s.z.string()),zt=t("getLayers",Ce.optional()),Pt=t("setLayerVisibility",E),kt=I("onLayerChange",s.z.object({id:s.z.string()})),Ft=t("setLayerStyle",s.z.object({id:s.z.string(),style:s.z.object({}).passthrough()})),wt=t("setLayerLegendVisibility",E),vt=t("getLayerGroup",s.z.string()),Vt=t("getLayerGroups",Ie.optional()),Ut=t("setLayerGroupVisibility",E),Rt=t("setLayerGroupLegendVisibility",E),Ot=I("onLayerGroupChange",s.z.object({id:s.z.string()})),Nt=t("getLegendItem",G),jt=t("getLegendItems",Ee.optional()),qt=I("onLegendItemChange",G),Zt=t("setLegendItemVisibility",s.z.object({show:G.array().optional(),hide:G.array().optional()})),Bt=t("getLayerFilters",s.z.string()),Ht=t("setLayerFilters",s.z.object({layerId:s.z.string(),filters:Le,note:s.z.string().optional()})),At=t("getRenderedFeatures",Te.optional()),Ge={methods:[Gt,zt,Pt,Ft,wt,vt,Vt,Ut,Rt,Nt,jt,Zt,Bt,Ht,At],listeners:[kt,Ot,qt]};var F=require("zod");var M=require("zod"),ze=M.z.object({id:M.z.string().or(M.z.number()),layerId:M.z.string(),showPopup:M.z.boolean().optional(),fitViewport:M.z.boolean().or(M.z.object({maxZoom:M.z.number()})).optional()});var Wt=t("getSelection",F.z.undefined()),Dt=d("onSelectionChange"),Kt=t("selectFeature",ze),_t=t("clearSelection",F.z.object({features:F.z.boolean().optional(),elements:F.z.boolean().optional()}).optional()),Pe={methods:[Wt,Kt,_t],listeners:[Dt]};var Ve=require("zod");var l=require("zod");var ke=["pin","line","route","polygon","circle","marker","highlighter","text","note"],Fe=l.z.enum([...ke,"link"]),we=l.z.enum(ke),Qt=X.pick({color:!0,symbol:!0,frame:!0}).required(),$t=O.pick({color:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,distanceMarker:!0}).required(),Jt=O.pick({color:!0,routingMode:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,distanceMarker:!0,endCaps:!0}).required(),Xt=Y.pick({color:!0,fillOpacity:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,areaMarker:!0}).required(),Yt=ee.pick({color:!0,fillOpacity:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,radiusMarker:!0}).required(),eo=te.pick({color:!0,opacity:!0,size:!0}).required(),to=oe.pick({color:!0,opacity:!0}).extend({size:l.z.number().min(0).max(200)}).required(),oo=re.pick({color:!0,align:!0,style:!0}).required(),ro=ne.pick({color:!0,align:!0,style:!0}).required(),ve=l.z.discriminatedUnion("tool",[Qt.partial().extend({tool:l.z.literal("pin")}),$t.partial().extend({tool:l.z.literal("line")}),Jt.partial().extend({tool:l.z.literal("route")}),Xt.partial().extend({tool:l.z.literal("polygon")}),Yt.partial().extend({tool:l.z.literal("circle")}),eo.partial().extend({tool:l.z.literal("marker")}),to.partial().extend({tool:l.z.literal("highlighter")}),oo.partial().extend({tool:l.z.literal("text")}),ro.partial().extend({tool:l.z.literal("note")})]);var no=t("setTool",Fe.nullable()),ao=t("getTool",Ve.z.undefined()),io=d("onToolChange"),so=t("setToolSettings",ve),lo=t("getToolSettings",we),po=d("onToolSettingsChange"),Ue={methods:[no,ao,so,lo],listeners:[io,po]};var p=require("zod"),Re=p.z.object({showLegend:p.z.boolean().optional(),cooperativeGestures:p.z.boolean().optional(),fullScreenButton:p.z.boolean().optional(),geolocation:p.z.boolean().optional(),zoomControls:p.z.boolean().optional(),scaleBar:p.z.boolean().optional()}),Oe=p.z.object({featureSelectPanel:p.z.boolean().optional(),featureHoverPanel:p.z.boolean().optional(),elementSelectPanel:p.z.boolean().optional(),linkClickOpen:p.z.boolean().optional(),imageLightboxOpen:p.z.boolean().optional()});var mo=t("updateUiControls",Re),co=t("setOnMapInteractionsUi",Oe),Ne={methods:[mo,co],listeners:null};var se=require("zod");var w=require("zod");var N=w.z.object({center:U,zoom:ce}),je=w.z.object({center:N.shape.center.optional(),zoom:N.shape.zoom.optional()}),qe=w.z.object({minZoom:N.shape.zoom.nullish(),maxZoom:N.shape.zoom.nullish(),bounds:k.nullish()}).nullable(),Ze=w.z.object({bounds:k});var yo=t("getViewport",se.z.undefined()),go=t("setViewport",je),uo=t("getViewportConstraints",se.z.undefined()),ho=t("setViewportConstraints",qe),fo=t("fitViewportToBounds",Ze),So=d("onViewportMove"),xo=d("onViewportMoveEnd"),Mo=d("onMapIdle"),Be={methods:[go,yo,uo,ho,fo],listeners:[So,xo,Mo]};var le=[Ne,Be,Ge,Se,Pe,xe,Ue];function bo(o,i,C){let T=new Map;async function b(g){if(!Go.safeParse(g.data).success){C?.onUnknownMessage?.(g.data);return}let pe=Ae.safeParse(g.data);if(!pe.success){C?.onInvalidMessage?.(g.data);return}let{data:c}=pe;if(c.type==="felt.ready")g.ports[0]?.postMessage(!0);else if(c.type==="felt.addListener"){if(c.event.eventName==="")throw new Error("felt.addListener eventName cannot be empty");let z="options"in c.event?{options:"options"in c.event?c.event.options:void 0,handler:q=>{g.ports[0]?.postMessage(q)}}:{handler:q=>{g.ports[0]?.postMessage(q)}},j=i.listeners[c.event.eventName](z);T.set(c.event.id,j)}else if(c.type==="felt.removeListener")T.get(c.id)?.(),T.delete(c.id);else try{let z=i.methods[c.type],j=await z(c.params);g.ports[0]?.postMessage(j)}catch(z){g.ports[0]?.postMessage({__error__:Lo(z)})}}return o.addEventListener("message",b),()=>{o.removeEventListener("message",b)}}function Lo(o){return o instanceof Error?o.message:typeof o=="object"&&o!==null&&"message"in o?String(o.message):typeof o=="string"?o:"Unknown error"}var He={methods:le.map(o=>o.methods??[]).flat(),listeners:le.map(o=>o.listeners??[]).flat()},Co=m.z.discriminatedUnion("eventName",[m.z.strictObject({eventName:m.z.literal("")}),...He.listeners]),Io=m.z.strictObject({type:m.z.literal("felt.addListener"),event:Co}),Eo=m.z.strictObject({type:m.z.literal("felt.removeListener"),id:m.z.string()}),To=m.z.strictObject({type:m.z.literal("felt.ready")}),Ae=m.z.discriminatedUnion("type",[To,Io,Eo,...He.methods]),Go=m.z.object({type:m.z.enum(Ae.options.map(o=>o.shape.type.value))});0&&(module.exports={createMessageHandler});
|
|
1
|
+
"use strict";var Z=Object.defineProperty;var Ke=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Qe=Object.prototype.hasOwnProperty;var $e=(o,i)=>{for(var I in i)Z(o,I,{get:i[I],enumerable:!0})},Je=(o,i,I,T)=>{if(i&&typeof i=="object"||typeof i=="function")for(let b of _e(i))!Qe.call(o,b)&&b!==I&&Z(o,b,{get:()=>i[b],enumerable:!(T=Ke(i,b))||T.enumerable});return o};var Xe=o=>Je(Z({},"__esModule",{value:!0}),o);var Vo={};$e(Vo,{createMessageHandler:()=>To});module.exports=Xe(Vo);var c=require("zod");var y=require("zod");var h=require("zod");function t(o,i){return h.z.strictObject({type:h.z.literal(o),params:i})}function L(o,i){return h.z.strictObject({eventName:h.z.literal(o),id:h.z.string(),options:i})}function l(o){return h.z.strictObject({eventName:h.z.literal(o),id:h.z.string()})}var r=require("zod"),V=r.z.number(),v=r.z.number(),O=r.z.object({latitude:v,longitude:V}),P=r.z.tuple([V,v]),me=r.z.object({type:r.z.literal("Point"),coordinates:P}),Ye=r.z.object({type:r.z.literal("LineString"),coordinates:r.z.array(P)}),C=r.z.object({type:r.z.literal("MultiLineString"),coordinates:r.z.array(Ye.shape.coordinates)}),ce=r.z.number().min(1).max(23),k=r.z.tuple([V,v,V,v]),E=r.z.object({show:r.z.array(r.z.string()).optional(),hide:r.z.array(r.z.string()).optional()});var e=require("zod");var g=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())}),U=e.z.object({imageUrl:e.z.string().nullable()}),B=e.z.object({strokeOpacity:e.z.number(),strokeWidth:e.z.number(),strokeStyle:e.z.enum(["solid","dashed","dotted"])}),et=e.z.enum(["meter","kilometer","foot","mile"]),H=g.extend(U.shape).extend({type:e.z.literal("Place"),coordinates:me.shape.coordinates,symbol:e.z.string(),frame:e.z.enum(["frame-circle","frame-square"]).nullable(),hideLabel:e.z.boolean()}),A=g.extend(U.shape).extend(B.shape).extend({type:e.z.literal("Path"),coordinates:C.shape.coordinates,distanceMarker:e.z.boolean(),endCaps:e.z.boolean(),routingMode:e.z.enum(["driving","cycling","walking","flying"]).nullable()}),D=g.extend(U.shape).extend(B.shape).extend({type:e.z.literal("Polygon"),coordinates:C.shape.coordinates,fillOpacity:e.z.number().min(0).max(1),areaMarker:e.z.boolean()}),W=g.extend(U.shape).extend(B.shape).extend({type:e.z.literal("Circle"),coordinates:P,radius:e.z.number(),radiusDisplayAngle:e.z.number(),radiusDisplayUnit:et.nullable(),fillOpacity:e.z.number().min(0).max(1),radiusMarker:e.z.boolean()}),K=g.extend({type:e.z.literal("Marker"),coordinates:C.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)}),_=g.extend({type:e.z.literal("Highlighter"),coordinates:C.shape.coordinates,opacity:e.z.number().min(0).max(1)}),de=e.z.object({position:P,rotation:e.z.number(),scale:e.z.number(),zoom:e.z.number().min(0).max(23),coordinates:C.shape.coordinates}),ye=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()}),Q=g.extend(de.shape).extend(ye.shape).extend({type:e.z.literal("Text")}),$=g.extend(de.shape).extend(ye.shape).extend({type:e.z.literal("Note"),widthScale:e.z.number().min(0)}),J=g.extend({type:e.z.literal("Image"),coordinates:C.shape.coordinates,imageUrl:e.z.string(),opacity:e.z.number().min(0).max(1)}).omit({color:!0}),tt=g.extend({type:e.z.literal("Link"),coordinates:C.shape.coordinates,url:e.z.string()}),f={type:!0,coordinates:!0},S={id:!0},X=H.partial().required(f).omit(S),R=A.partial().required(f).omit(S),Y=D.partial().required(f).omit(S),ee=W.partial().required(f).required({radius:!0}).omit(S),te=K.partial().required(f).omit(S),oe=_.partial().required(f).omit(S),ne=Q.partial().required(f).required({text:!0}).omit(S).omit({coordinates:!0,name:!0}),re=$.partial().required(f).required({text:!0}).omit(S).omit({coordinates:!0,name:!0}),ot=J.partial().required(f).required({imageUrl:!0}).omit(S),ge=e.z.discriminatedUnion("type",[X,R,Y,ee,te,oe,ot,ne,re]),jo=H.omit({coordinates:!0}),qo=A.omit({coordinates:!0}),Zo=D.omit({coordinates:!0}),Bo=W.omit({coordinates:!0}),Ho=K.omit({coordinates:!0}),Ao=_.omit({coordinates:!0}),Do=Q.omit({coordinates:!0}),Wo=$.omit({coordinates:!0}),Ko=J.omit({coordinates:!0}),_o=tt.omit({coordinates:!0}),x={type:!0,id:!0},nt=H.partial().required(x),rt=A.partial().required(x),at=D.partial().required(x),it=W.partial().required(x),st=K.partial().required(x),lt=_.partial().required(x),pt=Q.partial().required(x).omit({coordinates:!0,name:!0}),mt=$.partial().required(x).omit({coordinates:!0,name:!0}),ct=J.partial().required(x),ue=e.z.discriminatedUnion("type",[nt,rt,at,it,st,lt,pt,mt,ct]),he=e.z.object({ids:e.z.array(e.z.string()).optional()}),fe=e.z.object({ids:e.z.array(e.z.string()).optional()});var dt=t("getElement",y.z.string()),yt=t("getElementGeometry",y.z.string()),gt=t("getElements",he.optional()),ut=t("getElementGroup",y.z.string()),ht=t("getElementGroups",fe.optional()),ft=t("setElementGroupVisibility",E),St=L("onElementChange",y.z.object({id:y.z.string()})),xt=l("onElementCreate"),Mt=L("onElementDelete",y.z.object({id:y.z.string()})),bt=L("onElementGroupChange",y.z.object({id:y.z.string()})),Lt=t("createElement",ge),Ct=t("updateElement",ue),It=t("deleteElement",y.z.string()),Se={methods:[dt,yt,gt,ut,ht,ft,Lt,Ct,It],listeners:[St,xt,Mt,bt]};var Et=l("onPointerClick"),Tt=l("onPointerMove"),xe={methods:null,listeners:[Et,Tt]};var s=require("zod");var n=require("zod"),Gt=n.z.enum(["in","ni"]),zt=n.z.enum(["lt","gt","le","ge","eq","ne","cn","nc","is","isnt"]),on=n.z.enum(["and","or"]),Me=n.z.union([n.z.number(),n.z.string(),n.z.boolean(),n.z.null()]),be=n.z.string().or(n.z.null()),Pt=n.z.tuple([be,Gt,n.z.array(Me).or(n.z.null())]),kt=n.z.tuple([be,zt,Me]),ae=n.z.union([Pt,kt]),ie=n.z.tuple([n.z.lazy(()=>n.z.union([ie,ae,n.z.null(),n.z.boolean()])),n.z.enum(["and","or"]),n.z.lazy(()=>n.z.union([ie,ae,n.z.null(),n.z.boolean()]))]),Le=n.z.union([ie,ae,n.z.null(),n.z.boolean()]);var a=require("zod");var an=a.z.enum(["processing","completed","failed","incomplete"]),Ce=a.z.object({ids:a.z.array(a.z.string()).optional()}),Ie=a.z.object({ids:a.z.array(a.z.string()).optional()}),G=a.z.object({id:a.z.string(),layerId:a.z.string()}),Ee=a.z.object({ids:G.array().optional(),layerIds:a.z.string().array().optional()}),Te=a.z.object({layerIds:a.z.array(a.z.string()).optional(),areaQuery:a.z.union([a.z.object({coordinates:O}),a.z.object({boundary:k})]).optional()});var Ft=t("getLayer",s.z.string()),wt=t("getLayers",Ce.optional()),Vt=t("setLayerVisibility",E),vt=L("onLayerChange",s.z.object({id:s.z.string()})),Ot=t("setLayerStyle",s.z.object({id:s.z.string(),style:s.z.object({}).passthrough()})),Ut=t("setLayerLegendVisibility",E),Rt=t("getLayerGroup",s.z.string()),Nt=t("getLayerGroups",Ie.optional()),jt=t("setLayerGroupVisibility",E),qt=t("setLayerGroupLegendVisibility",E),Zt=L("onLayerGroupChange",s.z.object({id:s.z.string()})),Bt=t("getLegendItem",G),Ht=t("getLegendItems",Ee.optional()),At=L("onLegendItemChange",G),Dt=t("setLegendItemVisibility",s.z.object({show:G.array().optional(),hide:G.array().optional()})),Wt=t("getLayerFilters",s.z.string()),Kt=t("setLayerFilters",s.z.object({layerId:s.z.string(),filters:Le,note:s.z.string().optional()})),_t=t("getRenderedFeatures",Te.optional()),Ge={methods:[Ft,wt,Vt,Ot,Ut,Rt,Nt,jt,qt,Bt,Ht,Dt,Wt,Kt,_t],listeners:[vt,Zt,At]};var ze=require("zod");var Qt=t("getMapDetails",ze.z.undefined()),Pe={methods:[Qt],listeners:[]};var F=require("zod");var M=require("zod"),ke=M.z.object({id:M.z.string().or(M.z.number()),layerId:M.z.string(),showPopup:M.z.boolean().optional(),fitViewport:M.z.boolean().or(M.z.object({maxZoom:M.z.number()})).optional()});var $t=t("getSelection",F.z.undefined()),Jt=l("onSelectionChange"),Xt=t("selectFeature",ke),Yt=t("clearSelection",F.z.object({features:F.z.boolean().optional(),elements:F.z.boolean().optional()}).optional()),Fe={methods:[$t,Xt,Yt],listeners:[Jt]};var Ue=require("zod");var p=require("zod");var we=["pin","line","route","polygon","circle","marker","highlighter","text","note"],Ve=p.z.enum([...we,"link"]),ve=p.z.enum(we),eo=X.pick({color:!0,symbol:!0,frame:!0}).required(),to=R.pick({color:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,distanceMarker:!0}).required(),oo=R.pick({color:!0,routingMode:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,distanceMarker:!0,endCaps:!0}).required(),no=Y.pick({color:!0,fillOpacity:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,areaMarker:!0}).required(),ro=ee.pick({color:!0,fillOpacity:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,radiusMarker:!0}).required(),ao=te.pick({color:!0,opacity:!0,size:!0}).required(),io=oe.pick({color:!0,opacity:!0}).extend({size:p.z.number().min(0).max(200)}).required(),so=ne.pick({color:!0,align:!0,style:!0}).required(),lo=re.pick({color:!0,align:!0,style:!0}).required(),Oe=p.z.discriminatedUnion("tool",[eo.partial().extend({tool:p.z.literal("pin")}),to.partial().extend({tool:p.z.literal("line")}),oo.partial().extend({tool:p.z.literal("route")}),no.partial().extend({tool:p.z.literal("polygon")}),ro.partial().extend({tool:p.z.literal("circle")}),ao.partial().extend({tool:p.z.literal("marker")}),io.partial().extend({tool:p.z.literal("highlighter")}),so.partial().extend({tool:p.z.literal("text")}),lo.partial().extend({tool:p.z.literal("note")})]);var po=t("setTool",Ve.nullable()),mo=t("getTool",Ue.z.undefined()),co=l("onToolChange"),yo=t("setToolSettings",Oe),go=t("getToolSettings",ve),uo=l("onToolSettingsChange"),Re={methods:[po,mo,yo,go],listeners:[co,uo]};var m=require("zod"),Ne=m.z.object({showLegend:m.z.boolean().optional(),cooperativeGestures:m.z.boolean().optional(),fullScreenButton:m.z.boolean().optional(),geolocation:m.z.boolean().optional(),zoomControls:m.z.boolean().optional(),scaleBar:m.z.boolean().optional()}),je=m.z.object({featureSelectPanel:m.z.boolean().optional(),featureHoverPanel:m.z.boolean().optional(),elementSelectPanel:m.z.boolean().optional(),linkClickOpen:m.z.boolean().optional(),imageLightboxOpen:m.z.boolean().optional()});var ho=t("updateUiControls",Ne),fo=t("setOnMapInteractionsUi",je),qe={methods:[ho,fo],listeners:null};var se=require("zod");var w=require("zod");var N=w.z.object({center:O,zoom:ce}),Ze=w.z.object({center:N.shape.center.optional(),zoom:N.shape.zoom.optional()}),Be=w.z.object({minZoom:N.shape.zoom.nullish(),maxZoom:N.shape.zoom.nullish(),bounds:k.nullish()}).nullable(),He=w.z.object({bounds:k});var So=t("getViewport",se.z.undefined()),xo=t("setViewport",Ze),Mo=t("getViewportConstraints",se.z.undefined()),bo=t("setViewportConstraints",Be),Lo=t("fitViewportToBounds",He),Co=l("onViewportMove"),Io=l("onViewportMoveEnd"),Eo=l("onMapIdle"),Ae={methods:[xo,So,Mo,bo,Lo],listeners:[Co,Io,Eo]};var le=[qe,Ae,Ge,Se,Fe,xe,Re,Pe];function To(o,i,I){let T=new Map;async function b(u){if(!wo.safeParse(u.data).success){I?.onUnknownMessage?.(u.data);return}let pe=We.safeParse(u.data);if(!pe.success){I?.onInvalidMessage?.(u.data);return}let{data:d}=pe;if(d.type==="felt.ready")u.ports[0]?.postMessage(!0);else if(d.type==="felt.addListener"){if(d.event.eventName==="")throw new Error("felt.addListener eventName cannot be empty");let z="options"in d.event?{options:"options"in d.event?d.event.options:void 0,handler:q=>{u.ports[0]?.postMessage(q)}}:{handler:q=>{u.ports[0]?.postMessage(q)}},j=i.listeners[d.event.eventName](z);T.set(d.event.id,j)}else if(d.type==="felt.removeListener")T.get(d.id)?.(),T.delete(d.id);else try{let z=i.methods[d.type],j=await z(d.params);u.ports[0]?.postMessage(j)}catch(z){u.ports[0]?.postMessage({__error__:Go(z)})}}return o.addEventListener("message",b),()=>{o.removeEventListener("message",b)}}function Go(o){return o instanceof Error?o.message:typeof o=="object"&&o!==null&&"message"in o?String(o.message):typeof o=="string"?o:"Unknown error"}var De={methods:le.map(o=>o.methods??[]).flat(),listeners:le.map(o=>o.listeners??[]).flat()},zo=c.z.discriminatedUnion("eventName",[c.z.strictObject({eventName:c.z.literal("")}),...De.listeners]),Po=c.z.strictObject({type:c.z.literal("felt.addListener"),event:zo}),ko=c.z.strictObject({type:c.z.literal("felt.removeListener"),id:c.z.string()}),Fo=c.z.strictObject({type:c.z.literal("felt.ready")}),We=c.z.discriminatedUnion("type",[Fo,Po,ko,...De.methods]),wo=c.z.object({type:c.z.enum(We.options.map(o=>o.shape.type.value))});0&&(module.exports={createMessageHandler});
|