@feltmaps/js-sdk 1.5.0-next.2 → 1.5.0-next.4
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 +77 -7
- package/dist/client.d.ts +77 -7
- package/dist/client.js +1 -1
- package/dist/handler.cjs +1 -1
- package/dist/handler.d.cts +1371 -98
- package/dist/handler.d.ts +1371 -98
- package/dist/handler.js +1 -1
- package/dist/types-CPZlLnbg.d.cts +2429 -0
- package/dist/types-CPZlLnbg.d.ts +2429 -0
- package/handler.d.ts +1371 -98
- package/handler.js +1 -1
- package/package.json +1 -1
- package/types-CPZlLnbg.d.ts +2429 -0
- package/dist/types-BLsf5GHN.d.cts +0 -1229
- package/dist/types-BLsf5GHN.d.ts +0 -1229
- package/types-BLsf5GHN.d.ts +0 -1229
package/dist/client.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var g=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var b=(e,
|
|
1
|
+
"use strict";var g=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var b=(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))!M.call(e,l)&&l!==r&&g(e,l,{get:()=>n[l],enumerable:!(s=F(n,l))||s.enumerable});return e};var G=e=>I(g({},"__esModule",{value:!0}),e);var f={};b(f,{Felt:()=>V});module.exports=G(f);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=>({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),...h(e),...u(e),...L(e),...C(e),...T(e)}}var V={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 x(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(V.connect).then(m=>(Object.defineProperties(m,{iframe:{value:p,writable:!1,configurable:!1}}),m))},connect(e){let n=P(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))}})}},x=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, L as Layer,
|
|
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 EntityNode, u as FeatureSelection, T as ToolType, I as InputToolSettings, C as ConfigurableToolType, v as ToolSettingsMap, w as ToolSettingsChangeEvent, z as zInfer, V as ViewportState, x as SetViewportCenterZoomParams, y as ViewportConstraints, A as ViewportFitBoundsParams, B as ViewportCenterZoom } from './types-CPZlLnbg.cjs';
|
|
2
|
+
export { D as CircleElementCreate, H as CircleElementRead, J as CircleElementUpdate, av as CircleToolSettings, ah as ElementGroupNode, ai as ElementNode, aj as FeatureNode, am as FeltBoundary, an as FeltZoom, ae as FilterExpression, af as FilterLogicGate, ag as FilterTernary, K as HighlighterElementCreate, N as HighlighterElementRead, O as HighlighterElementUpdate, aw as HighlighterToolSettings, P as ImageElementCreate, Q as ImageElementRead, R as ImageElementUpdate, ao as LatLng, ak as LayerGroupNode, al as LayerNode, ac as LayerProcessingStatus, ap as LineStringGeometry, ax as LineToolSettings, U as LinkElementRead, aq as LngLatTuple, W as MarkerElementCreate, X as MarkerElementRead, Y as MarkerElementUpdate, ay as MarkerToolSettings, ar as MultiLineStringGeometry, as as MultiPolygonGeometry, Z as NoteElementCreate, _ as NoteElementRead, $ as NoteElementUpdate, az as NoteToolSettings, a0 as PathElementCreate, a1 as PathElementRead, a2 as PathElementUpdate, aA as PinToolSettings, a3 as PlaceElementCreate, a4 as PlaceElementRead, a5 as PlaceElementUpdate, aB as PlaceFrame, aC as PlaceSymbol, at as PointGeometry, a6 as PolygonElementCreate, a7 as PolygonElementRead, a8 as PolygonElementUpdate, au as PolygonGeometry, aD as PolygonToolSettings, ad as RasterValue, aE as RouteToolSettings, a9 as TextElementCreate, aa as TextElementRead, ab as TextElementUpdate, aF as TextToolSettings } from './types-CPZlLnbg.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
|
*
|
|
@@ -147,6 +200,23 @@ interface ElementsController {
|
|
|
147
200
|
};
|
|
148
201
|
handler: (change: ElementGroupChangeCallbackParams) => void;
|
|
149
202
|
}): VoidFunction;
|
|
203
|
+
/**
|
|
204
|
+
* Create a new element on the map.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* const element = await felt.createElement({ type: "Place", coordinates: [10, 10] });
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
createElement(element: ElementCreate): Promise<Element>;
|
|
212
|
+
/**
|
|
213
|
+
* Update an element on the map.
|
|
214
|
+
*/
|
|
215
|
+
updateElement(element: ElementUpdate): Promise<Element>;
|
|
216
|
+
/**
|
|
217
|
+
* Delete an element from the map.
|
|
218
|
+
*/
|
|
219
|
+
deleteElement(id: string): Promise<void>;
|
|
150
220
|
}
|
|
151
221
|
|
|
152
222
|
/**
|
|
@@ -1090,17 +1160,17 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
|
|
|
1090
1160
|
}>;
|
|
1091
1161
|
zoom: z.ZodNumber;
|
|
1092
1162
|
}, "strip", z.ZodTypeAny, {
|
|
1163
|
+
zoom: number;
|
|
1093
1164
|
center: {
|
|
1094
1165
|
latitude: number;
|
|
1095
1166
|
longitude: number;
|
|
1096
1167
|
};
|
|
1097
|
-
zoom: number;
|
|
1098
1168
|
}, {
|
|
1169
|
+
zoom: number;
|
|
1099
1170
|
center: {
|
|
1100
1171
|
latitude: number;
|
|
1101
1172
|
longitude: number;
|
|
1102
1173
|
};
|
|
1103
|
-
zoom: number;
|
|
1104
1174
|
}>>;
|
|
1105
1175
|
}, "strip", z.ZodTypeAny, {
|
|
1106
1176
|
origin?: string | undefined;
|
|
@@ -1114,11 +1184,11 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
|
|
|
1114
1184
|
scaleBar?: boolean | undefined;
|
|
1115
1185
|
} | undefined;
|
|
1116
1186
|
initialViewport?: {
|
|
1187
|
+
zoom: number;
|
|
1117
1188
|
center: {
|
|
1118
1189
|
latitude: number;
|
|
1119
1190
|
longitude: number;
|
|
1120
1191
|
};
|
|
1121
|
-
zoom: number;
|
|
1122
1192
|
} | undefined;
|
|
1123
1193
|
}, {
|
|
1124
1194
|
origin?: string | undefined;
|
|
@@ -1132,11 +1202,11 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
|
|
|
1132
1202
|
scaleBar?: boolean | undefined;
|
|
1133
1203
|
} | undefined;
|
|
1134
1204
|
initialViewport?: {
|
|
1205
|
+
zoom: number;
|
|
1135
1206
|
center: {
|
|
1136
1207
|
latitude: number;
|
|
1137
1208
|
longitude: number;
|
|
1138
1209
|
};
|
|
1139
|
-
zoom: number;
|
|
1140
1210
|
} | undefined;
|
|
1141
1211
|
}>;
|
|
1142
1212
|
|
|
@@ -1196,4 +1266,4 @@ declare const Felt: {
|
|
|
1196
1266
|
connect(feltWindow: Window): Promise<FeltController>;
|
|
1197
1267
|
};
|
|
1198
1268
|
|
|
1199
|
-
export { ConfigurableToolType, Element, ElementChangeCallbackParams, ElementGroup, ElementGroupChangeCallbackParams, 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 };
|
|
1269
|
+
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 };
|
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, L as Layer,
|
|
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 EntityNode, u as FeatureSelection, T as ToolType, I as InputToolSettings, C as ConfigurableToolType, v as ToolSettingsMap, w as ToolSettingsChangeEvent, z as zInfer, V as ViewportState, x as SetViewportCenterZoomParams, y as ViewportConstraints, A as ViewportFitBoundsParams, B as ViewportCenterZoom } from './types-CPZlLnbg.js';
|
|
2
|
+
export { D as CircleElementCreate, H as CircleElementRead, J as CircleElementUpdate, av as CircleToolSettings, ah as ElementGroupNode, ai as ElementNode, aj as FeatureNode, am as FeltBoundary, an as FeltZoom, ae as FilterExpression, af as FilterLogicGate, ag as FilterTernary, K as HighlighterElementCreate, N as HighlighterElementRead, O as HighlighterElementUpdate, aw as HighlighterToolSettings, P as ImageElementCreate, Q as ImageElementRead, R as ImageElementUpdate, ao as LatLng, ak as LayerGroupNode, al as LayerNode, ac as LayerProcessingStatus, ap as LineStringGeometry, ax as LineToolSettings, U as LinkElementRead, aq as LngLatTuple, W as MarkerElementCreate, X as MarkerElementRead, Y as MarkerElementUpdate, ay as MarkerToolSettings, ar as MultiLineStringGeometry, as as MultiPolygonGeometry, Z as NoteElementCreate, _ as NoteElementRead, $ as NoteElementUpdate, az as NoteToolSettings, a0 as PathElementCreate, a1 as PathElementRead, a2 as PathElementUpdate, aA as PinToolSettings, a3 as PlaceElementCreate, a4 as PlaceElementRead, a5 as PlaceElementUpdate, aB as PlaceFrame, aC as PlaceSymbol, at as PointGeometry, a6 as PolygonElementCreate, a7 as PolygonElementRead, a8 as PolygonElementUpdate, au as PolygonGeometry, aD as PolygonToolSettings, ad as RasterValue, aE as RouteToolSettings, a9 as TextElementCreate, aa as TextElementRead, ab as TextElementUpdate, aF as TextToolSettings } from './types-CPZlLnbg.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
|
*
|
|
@@ -147,6 +200,23 @@ interface ElementsController {
|
|
|
147
200
|
};
|
|
148
201
|
handler: (change: ElementGroupChangeCallbackParams) => void;
|
|
149
202
|
}): VoidFunction;
|
|
203
|
+
/**
|
|
204
|
+
* Create a new element on the map.
|
|
205
|
+
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* const element = await felt.createElement({ type: "Place", coordinates: [10, 10] });
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
createElement(element: ElementCreate): Promise<Element>;
|
|
212
|
+
/**
|
|
213
|
+
* Update an element on the map.
|
|
214
|
+
*/
|
|
215
|
+
updateElement(element: ElementUpdate): Promise<Element>;
|
|
216
|
+
/**
|
|
217
|
+
* Delete an element from the map.
|
|
218
|
+
*/
|
|
219
|
+
deleteElement(id: string): Promise<void>;
|
|
150
220
|
}
|
|
151
221
|
|
|
152
222
|
/**
|
|
@@ -1090,17 +1160,17 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
|
|
|
1090
1160
|
}>;
|
|
1091
1161
|
zoom: z.ZodNumber;
|
|
1092
1162
|
}, "strip", z.ZodTypeAny, {
|
|
1163
|
+
zoom: number;
|
|
1093
1164
|
center: {
|
|
1094
1165
|
latitude: number;
|
|
1095
1166
|
longitude: number;
|
|
1096
1167
|
};
|
|
1097
|
-
zoom: number;
|
|
1098
1168
|
}, {
|
|
1169
|
+
zoom: number;
|
|
1099
1170
|
center: {
|
|
1100
1171
|
latitude: number;
|
|
1101
1172
|
longitude: number;
|
|
1102
1173
|
};
|
|
1103
|
-
zoom: number;
|
|
1104
1174
|
}>>;
|
|
1105
1175
|
}, "strip", z.ZodTypeAny, {
|
|
1106
1176
|
origin?: string | undefined;
|
|
@@ -1114,11 +1184,11 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
|
|
|
1114
1184
|
scaleBar?: boolean | undefined;
|
|
1115
1185
|
} | undefined;
|
|
1116
1186
|
initialViewport?: {
|
|
1187
|
+
zoom: number;
|
|
1117
1188
|
center: {
|
|
1118
1189
|
latitude: number;
|
|
1119
1190
|
longitude: number;
|
|
1120
1191
|
};
|
|
1121
|
-
zoom: number;
|
|
1122
1192
|
} | undefined;
|
|
1123
1193
|
}, {
|
|
1124
1194
|
origin?: string | undefined;
|
|
@@ -1132,11 +1202,11 @@ declare const FeltEmbedOptionsSchema: z.ZodObject<{
|
|
|
1132
1202
|
scaleBar?: boolean | undefined;
|
|
1133
1203
|
} | undefined;
|
|
1134
1204
|
initialViewport?: {
|
|
1205
|
+
zoom: number;
|
|
1135
1206
|
center: {
|
|
1136
1207
|
latitude: number;
|
|
1137
1208
|
longitude: number;
|
|
1138
1209
|
};
|
|
1139
|
-
zoom: number;
|
|
1140
1210
|
} | undefined;
|
|
1141
1211
|
}>;
|
|
1142
1212
|
|
|
@@ -1196,4 +1266,4 @@ declare const Felt: {
|
|
|
1196
1266
|
connect(feltWindow: Window): Promise<FeltController>;
|
|
1197
1267
|
};
|
|
1198
1268
|
|
|
1199
|
-
export { ConfigurableToolType, Element, ElementChangeCallbackParams, ElementGroup, ElementGroupChangeCallbackParams, 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 };
|
|
1269
|
+
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 };
|
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=>({onSelectionChange:o(e,"onSelectionChange"),getSelection:t(e,"getSelection"),selectFeature:t(e,"selectFeature"),clearSelection:t(e,"clearSelection")});var L=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 T=e=>({updateUiControls:t(e,"updateUiControls"),setOnMapInteractionsUi:t(e,"setOnMapInteractionsUi")});var E=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,...E(e),...T(e),...C(e),...c(e),...h(e),...u(e),...L(e)}}var P={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 V(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(P.connect).then(l=>(Object.defineProperties(l,{iframe:{value:a,writable:!1,configurable:!1}}),l))},connect(e){let p=v(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))}})}},V=Object.entries;export{P as Felt};
|
package/dist/handler.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var v=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var he=Object.prototype.hasOwnProperty;var Se=(o,s)=>{for(var h in s)v(o,h,{get:s[h],enumerable:!0})},be=(o,s,h,L)=>{if(s&&typeof s=="object"||typeof s=="function")for(let u of fe(s))!he.call(o,u)&&u!==h&&v(o,u,{get:()=>s[u],enumerable:!(L=ue(s,u))||L.enumerable});return o};var Me=o=>be(v({},"__esModule",{value:!0}),o);var Ot={};Se(Ot,{createMessageHandler:()=>Ft});module.exports=Me(Ot);var l=require("zod");var f=require("zod");var g=require("zod");function t(o,s){return g.z.strictObject({type:g.z.literal(o),params:s})}function S(o,s){return g.z.strictObject({eventName:g.z.literal(o),id:g.z.string(),options:s})}function m(o){return g.z.strictObject({eventName:g.z.literal(o),id:g.z.string()})}var c=require("zod"),V=c.z.number(),P=c.z.number(),z=c.z.object({latitude:P,longitude:V}),Z=c.z.number().min(1).max(23),I=c.z.tuple([V,P,V,P]),b=c.z.object({show:c.z.array(c.z.string()).optional(),hide:c.z.array(c.z.string()).optional()});var M=require("zod"),U=M.z.object({ids:M.z.array(M.z.string()).optional()}),B=M.z.object({ids:M.z.array(M.z.string()).optional()});var Le=t("getElement",f.z.string()),xe=t("getElementGeometry",f.z.string()),Ge=t("getElements",U.optional()),Ie=t("getElementGroup",f.z.string()),Te=t("getElementGroups",B.optional()),Ce=t("setElementGroupVisibility",b),ze=S("onElementChange",f.z.object({id:f.z.string()})),Fe=S("onElementGroupChange",f.z.object({id:f.z.string()})),A={methods:[Le,xe,Ge,Ie,Te,Ce],listeners:[ze,Fe]};var Ee=m("onPointerClick"),we=m("onPointerMove"),q={methods:null,listeners:[Ee,we]};var i=require("zod");var n=require("zod"),ve=n.z.enum(["in","ni"]),Ve=n.z.enum(["lt","gt","le","ge","eq","ne","cn","nc","is","isnt"]),_t=n.z.enum(["and","or"]),H=n.z.union([n.z.number(),n.z.string(),n.z.boolean(),n.z.null()]),W=n.z.string().or(n.z.null()),Pe=n.z.tuple([W,ve,n.z.array(H).or(n.z.null())]),ke=n.z.tuple([W,Ve,H]),k=n.z.union([Pe,ke]),O=n.z.tuple([n.z.lazy(()=>n.z.union([O,k,n.z.null(),n.z.boolean()])),n.z.enum(["and","or"]),n.z.lazy(()=>n.z.union([O,k,n.z.null(),n.z.boolean()]))]),K=n.z.union([O,k,n.z.null(),n.z.boolean()]);var r=require("zod");var $t=r.z.enum(["processing","completed","failed","incomplete"]),_=r.z.object({ids:r.z.array(r.z.string()).optional()}),Q=r.z.object({ids:r.z.array(r.z.string()).optional()}),x=r.z.object({id:r.z.string(),layerId:r.z.string()}),D=r.z.object({ids:x.array().optional(),layerIds:r.z.string().array().optional()}),$=r.z.object({layerIds:r.z.array(r.z.string()).optional(),areaQuery:r.z.union([r.z.object({coordinates:z}),r.z.object({boundary:I})]).optional()});var Oe=t("getLayer",i.z.string()),je=t("getLayers",_.optional()),Ne=t("setLayerVisibility",b),Re=S("onLayerChange",i.z.object({id:i.z.string()})),Ze=t("setLayerStyle",i.z.object({id:i.z.string(),style:i.z.object({}).passthrough()})),Ue=t("setLayerLegendVisibility",b),Be=t("getLayerGroup",i.z.string()),Ae=t("getLayerGroups",Q.optional()),qe=t("setLayerGroupVisibility",b),He=t("setLayerGroupLegendVisibility",b),We=S("onLayerGroupChange",i.z.object({id:i.z.string()})),Ke=t("getLegendItem",x),_e=t("getLegendItems",D.optional()),Qe=S("onLegendItemChange",x),De=t("setLegendItemVisibility",i.z.object({show:x.array().optional(),hide:x.array().optional()})),$e=t("getLayerFilters",i.z.string()),Je=t("setLayerFilters",i.z.object({layerId:i.z.string(),filters:K,note:i.z.string().optional()})),Xe=t("getRenderedFeatures",$.optional()),J={methods:[Oe,je,Ne,Ze,Ue,Be,Ae,qe,He,Ke,_e,De,$e,Je,Xe],listeners:[Re,We,Qe]};var T=require("zod");var d=require("zod"),X=d.z.object({id:d.z.string().or(d.z.number()),layerId:d.z.string(),showPopup:d.z.boolean().optional(),fitViewport:d.z.boolean().or(d.z.object({maxZoom:d.z.number()})).optional()});var Ye=t("getSelection",T.z.undefined()),et=m("onSelectionChange"),tt=t("selectFeature",X),ot=t("clearSelection",T.z.object({features:T.z.boolean().optional(),elements:T.z.boolean().optional()}).optional()),Y={methods:[Ye,tt,ot],listeners:[et]};var re=require("zod");var e=require("zod"),ee=["pin","line","route","polygon","circle","marker","highlighter","text","note"],te=e.z.enum([...ee,"link"]),oe=e.z.enum(ee),nt=e.z.object({color:e.z.string(),symbol:e.z.string(),frame:e.z.enum(["frame-circle","frame-square"]).nullable()}),rt=e.z.object({color:e.z.string(),strokeOpacity:e.z.number(),strokeWidth:e.z.number(),strokeStyle:e.z.enum(["solid","dashed","dotted"]),distanceMarker:e.z.boolean()}),st=e.z.object({color:e.z.string(),routingMode:e.z.enum(["driving","cycling","walking","flying"]),strokeOpacity:e.z.number(),strokeWidth:e.z.number(),strokeStyle:e.z.enum(["solid","dashed","dotted"]),distanceMarker:e.z.boolean(),endCaps:e.z.boolean()}),it=e.z.object({color:e.z.string(),fillOpacity:e.z.number().min(0).max(1),strokeOpacity:e.z.number().min(0).max(1),strokeWidth:e.z.number().min(0),strokeStyle:e.z.enum(["solid","dashed","dotted"]),areaMarker:e.z.boolean()}),at=e.z.object({color:e.z.string(),fillOpacity:e.z.number().min(0).max(1),strokeOpacity:e.z.number().min(0).max(1),strokeWidth:e.z.number().min(0),strokeStyle:e.z.enum(["solid","dashed","dotted"]),radiusMarker:e.z.boolean()}),lt=e.z.object({color:e.z.string(),opacity:e.z.number().min(0).max(1),size:e.z.number().min(0).max(100)}),pt=e.z.object({color:e.z.string(),opacity:e.z.number().min(0).max(1),size:e.z.number().min(0).max(200)}),mt=e.z.object({color:e.z.string(),align:e.z.enum(["left","center","right"]),style:e.z.enum(["italic","light","regular","caps"])}),ct=e.z.object({color:e.z.string(),align:e.z.enum(["left","center","right"]),style:e.z.enum(["italic","light","regular","caps"])}),ne=e.z.discriminatedUnion("tool",[nt.partial().extend({tool:e.z.literal("pin")}),rt.partial().extend({tool:e.z.literal("line")}),st.partial().extend({tool:e.z.literal("route")}),it.partial().extend({tool:e.z.literal("polygon")}),at.partial().extend({tool:e.z.literal("circle")}),lt.partial().extend({tool:e.z.literal("marker")}),pt.partial().extend({tool:e.z.literal("highlighter")}),mt.partial().extend({tool:e.z.literal("text")}),ct.partial().extend({tool:e.z.literal("note")})]);var yt=t("setTool",te.nullable()),gt=t("getTool",re.z.undefined()),dt=m("onToolChange"),ut=t("setToolSettings",ne),ft=t("getToolSettings",oe),ht=m("onToolSettingsChange"),se={methods:[yt,gt,ut,ft],listeners:[dt,ht]};var a=require("zod"),ie=a.z.object({showLegend:a.z.boolean().optional(),cooperativeGestures:a.z.boolean().optional(),fullScreenButton:a.z.boolean().optional(),geolocation:a.z.boolean().optional(),zoomControls:a.z.boolean().optional(),scaleBar:a.z.boolean().optional()}),ae=a.z.object({featureSelectPanel:a.z.boolean().optional(),featureHoverPanel:a.z.boolean().optional(),elementSelectPanel:a.z.boolean().optional(),linkClickOpen:a.z.boolean().optional(),imageLightboxOpen:a.z.boolean().optional()});var St=t("updateUiControls",ie),bt=t("setOnMapInteractionsUi",ae),le={methods:[St,bt],listeners:null};var j=require("zod");var C=require("zod");var F=C.z.object({center:z,zoom:Z}),pe=C.z.object({center:F.shape.center.optional(),zoom:F.shape.zoom.optional()}),me=C.z.object({minZoom:F.shape.zoom.nullish(),maxZoom:F.shape.zoom.nullish(),bounds:I.nullish()}).nullable(),ce=C.z.object({bounds:I});var Mt=t("getViewport",j.z.undefined()),Lt=t("setViewport",pe),xt=t("getViewportConstraints",j.z.undefined()),Gt=t("setViewportConstraints",me),It=t("fitViewportToBounds",ce),Tt=m("onViewportMove"),Ct=m("onViewportMoveEnd"),zt=m("onMapIdle"),ye={methods:[Lt,Mt,xt,Gt,It],listeners:[Tt,Ct,zt]};var N=[le,ye,J,A,Y,q,se];function Ft(o,s,h){let L=new Map;async function u(y){if(!kt.safeParse(y.data).success){h?.onUnknownMessage?.(y.data);return}let R=de.safeParse(y.data);if(!R.success){h?.onInvalidMessage?.(y.data);return}let{data:p}=R;if(p.type==="felt.ready")y.ports[0]?.postMessage(!0);else if(p.type==="felt.addListener"){if(p.event.eventName==="")throw new Error("felt.addListener eventName cannot be empty");let G="options"in p.event?{options:"options"in p.event?p.event.options:void 0,handler:w=>{y.ports[0]?.postMessage(w)}}:{handler:w=>{y.ports[0]?.postMessage(w)}},E=s.listeners[p.event.eventName](G);L.set(p.event.id,E)}else if(p.type==="felt.removeListener")L.get(p.id)?.(),L.delete(p.id);else try{let G=s.methods[p.type],E=await G(p.params);y.ports[0]?.postMessage(E)}catch(G){y.ports[0]?.postMessage({__error__:Et(G)})}}return o.addEventListener("message",u),()=>{o.removeEventListener("message",u)}}function Et(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 ge={methods:N.map(o=>o.methods??[]).flat(),listeners:N.map(o=>o.listeners??[]).flat()},wt=l.z.discriminatedUnion("eventName",[l.z.strictObject({eventName:l.z.literal("")}),...ge.listeners]),vt=l.z.strictObject({type:l.z.literal("felt.addListener"),event:wt}),Vt=l.z.strictObject({type:l.z.literal("felt.removeListener"),id:l.z.string()}),Pt=l.z.strictObject({type:l.z.literal("felt.ready")}),de=l.z.discriminatedUnion("type",[Pt,vt,Vt,...ge.methods]),kt=l.z.object({type:l.z.enum(de.options.map(o=>o.shape.type.value))});0&&(module.exports={createMessageHandler});
|
|
1
|
+
"use strict";var Z=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var We=Object.getOwnPropertyNames;var Ke=Object.prototype.hasOwnProperty;var _e=(o,i)=>{for(var I in i)Z(o,I,{get:i[I],enumerable:!0})},Qe=(o,i,I,T)=>{if(i&&typeof i=="object"||typeof i=="function")for(let b of We(i))!Ke.call(o,b)&&b!==I&&Z(o,b,{get:()=>i[b],enumerable:!(T=De(i,b))||T.enumerable});return o};var $e=o=>Qe(Z({},"__esModule",{value:!0}),o);var ko={};_e(ko,{createMessageHandler:()=>Co});module.exports=$e(ko);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}),Je=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(Je.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"])}),Xe=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:Xe.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}),Ye=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}),et=J.partial().required(f).required({imageUrl:!0}).omit(S),ge=e.z.discriminatedUnion("type",[X,R,Y,ee,te,oe,et,ne,re]),Uo=H.omit({coordinates:!0}),Ro=A.omit({coordinates:!0}),No=D.omit({coordinates:!0}),jo=W.omit({coordinates:!0}),qo=K.omit({coordinates:!0}),Zo=_.omit({coordinates:!0}),Bo=Q.omit({coordinates:!0}),Ho=$.omit({coordinates:!0}),Ao=J.omit({coordinates:!0}),Do=Ye.omit({coordinates:!0}),x={type:!0,id:!0},tt=H.partial().required(x),ot=A.partial().required(x),nt=D.partial().required(x),rt=W.partial().required(x),at=K.partial().required(x),it=_.partial().required(x),st=Q.partial().required(x).omit({coordinates:!0,name:!0}),lt=$.partial().required(x).omit({coordinates:!0,name:!0}),pt=J.partial().required(x),ue=e.z.discriminatedUnion("type",[tt,ot,nt,rt,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",y.z.string()),ct=t("getElementGeometry",y.z.string()),dt=t("getElements",he.optional()),yt=t("getElementGroup",y.z.string()),gt=t("getElementGroups",fe.optional()),ut=t("setElementGroupVisibility",E),ht=L("onElementChange",y.z.object({id:y.z.string()})),ft=l("onElementCreate"),St=L("onElementDelete",y.z.object({id:y.z.string()})),xt=L("onElementGroupChange",y.z.object({id:y.z.string()})),Mt=t("createElement",ge),bt=t("updateElement",ue),Lt=t("deleteElement",y.z.string()),Se={methods:[mt,ct,dt,yt,gt,ut,Mt,bt,Lt],listeners:[ht,ft,St,xt]};var Ct=l("onPointerClick"),It=l("onPointerMove"),xe={methods:null,listeners:[Ct,It]};var s=require("zod");var n=require("zod"),Et=n.z.enum(["in","ni"]),Tt=n.z.enum(["lt","gt","le","ge","eq","ne","cn","nc","is","isnt"]),Yo=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()),Gt=n.z.tuple([be,Et,n.z.array(Me).or(n.z.null())]),zt=n.z.tuple([be,Tt,Me]),ae=n.z.union([Gt,zt]),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 on=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 Pt=t("getLayer",s.z.string()),kt=t("getLayers",Ce.optional()),Ft=t("setLayerVisibility",E),wt=L("onLayerChange",s.z.object({id:s.z.string()})),Vt=t("setLayerStyle",s.z.object({id:s.z.string(),style:s.z.object({}).passthrough()})),vt=t("setLayerLegendVisibility",E),Ot=t("getLayerGroup",s.z.string()),Ut=t("getLayerGroups",Ie.optional()),Rt=t("setLayerGroupVisibility",E),Nt=t("setLayerGroupLegendVisibility",E),jt=L("onLayerGroupChange",s.z.object({id:s.z.string()})),qt=t("getLegendItem",G),Zt=t("getLegendItems",Ee.optional()),Bt=L("onLegendItemChange",G),Ht=t("setLegendItemVisibility",s.z.object({show:G.array().optional(),hide:G.array().optional()})),At=t("getLayerFilters",s.z.string()),Dt=t("setLayerFilters",s.z.object({layerId:s.z.string(),filters:Le,note:s.z.string().optional()})),Wt=t("getRenderedFeatures",Te.optional()),Ge={methods:[Pt,kt,Ft,Vt,vt,Ot,Ut,Rt,Nt,qt,Zt,Ht,At,Dt,Wt],listeners:[wt,jt,Bt]};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 Kt=t("getSelection",F.z.undefined()),_t=l("onSelectionChange"),Qt=t("selectFeature",ze),$t=t("clearSelection",F.z.object({features:F.z.boolean().optional(),elements:F.z.boolean().optional()}).optional()),Pe={methods:[Kt,Qt,$t],listeners:[_t]};var ve=require("zod");var p=require("zod");var ke=["pin","line","route","polygon","circle","marker","highlighter","text","note"],Fe=p.z.enum([...ke,"link"]),we=p.z.enum(ke),Jt=X.pick({color:!0,symbol:!0,frame:!0}).required(),Xt=R.pick({color:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,distanceMarker:!0}).required(),Yt=R.pick({color:!0,routingMode:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,distanceMarker:!0,endCaps:!0}).required(),eo=Y.pick({color:!0,fillOpacity:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,areaMarker:!0}).required(),to=ee.pick({color:!0,fillOpacity:!0,strokeOpacity:!0,strokeWidth:!0,strokeStyle:!0,radiusMarker:!0}).required(),oo=te.pick({color:!0,opacity:!0,size:!0}).required(),no=oe.pick({color:!0,opacity:!0}).extend({size:p.z.number().min(0).max(200)}).required(),ro=ne.pick({color:!0,align:!0,style:!0}).required(),ao=re.pick({color:!0,align:!0,style:!0}).required(),Ve=p.z.discriminatedUnion("tool",[Jt.partial().extend({tool:p.z.literal("pin")}),Xt.partial().extend({tool:p.z.literal("line")}),Yt.partial().extend({tool:p.z.literal("route")}),eo.partial().extend({tool:p.z.literal("polygon")}),to.partial().extend({tool:p.z.literal("circle")}),oo.partial().extend({tool:p.z.literal("marker")}),no.partial().extend({tool:p.z.literal("highlighter")}),ro.partial().extend({tool:p.z.literal("text")}),ao.partial().extend({tool:p.z.literal("note")})]);var io=t("setTool",Fe.nullable()),so=t("getTool",ve.z.undefined()),lo=l("onToolChange"),po=t("setToolSettings",Ve),mo=t("getToolSettings",we),co=l("onToolSettingsChange"),Oe={methods:[io,so,po,mo],listeners:[lo,co]};var m=require("zod"),Ue=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()}),Re=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 yo=t("updateUiControls",Ue),go=t("setOnMapInteractionsUi",Re),Ne={methods:[yo,go],listeners:null};var se=require("zod");var w=require("zod");var N=w.z.object({center:O,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 uo=t("getViewport",se.z.undefined()),ho=t("setViewport",je),fo=t("getViewportConstraints",se.z.undefined()),So=t("setViewportConstraints",qe),xo=t("fitViewportToBounds",Ze),Mo=l("onViewportMove"),bo=l("onViewportMoveEnd"),Lo=l("onMapIdle"),Be={methods:[ho,uo,fo,So,xo],listeners:[Mo,bo,Lo]};var le=[Ne,Be,Ge,Se,Pe,xe,Oe];function Co(o,i,I){let T=new Map;async function b(u){if(!Po.safeParse(u.data).success){I?.onUnknownMessage?.(u.data);return}let pe=Ae.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__:Io(z)})}}return o.addEventListener("message",b),()=>{o.removeEventListener("message",b)}}function Io(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()},Eo=c.z.discriminatedUnion("eventName",[c.z.strictObject({eventName:c.z.literal("")}),...He.listeners]),To=c.z.strictObject({type:c.z.literal("felt.addListener"),event:Eo}),Go=c.z.strictObject({type:c.z.literal("felt.removeListener"),id:c.z.string()}),zo=c.z.strictObject({type:c.z.literal("felt.ready")}),Ae=c.z.discriminatedUnion("type",[zo,To,Go,...He.methods]),Po=c.z.object({type:c.z.enum(Ae.options.map(o=>o.shape.type.value))});0&&(module.exports={createMessageHandler});
|