@feltmaps/js-sdk
Version:
An SDK for Felt maps
1,033 lines (1,021 loc) • 32.4 kB
TypeScript
import * as zod from 'zod';
import { z } from 'zod';
import { z as zInfer, E as Element, G as Geometry, b as ElementGroup, d as ElementChangeCallbackParams, e as ElementGroupChangeCallbackParams, M as MapInteractionEvent, L as Layer, h as LayerGroup, l as LegendItem, o as LayerFilters, q as Feature, g as LayerChangeCallbackParams, j as LayerGroupChangeCallbackParams, n as LegendItemChangeCallbackParams, A as FilterTernary, r as EntityNode, V as ViewportState, X as UnionToIntersection, Y as PromiseOrNot } from './types-BDviYZ-T.js';
type Method<TRequest extends {
type: string;
params?: any;
}, TResponse> = {
request: TRequest;
response: TResponse;
};
type Listener<TOptions, TParams> = {
options: TOptions;
eventParams: TParams;
};
declare const GetElementMessage: z.ZodObject<{
type: z.ZodLiteral<"getElement">;
params: z.ZodString;
}, z.UnknownKeysParam, z.ZodTypeAny, {
params: string;
type: "getElement";
}, {
params: string;
type: "getElement";
}>;
declare const GetElementGeometryMessage: z.ZodObject<{
type: z.ZodLiteral<"getElementGeometry">;
params: z.ZodString;
}, z.UnknownKeysParam, z.ZodTypeAny, {
params: string;
type: "getElementGeometry";
}, {
params: string;
type: "getElementGeometry";
}>;
declare const GetElementsMessage: z.ZodObject<{
type: z.ZodLiteral<"getElements">;
params: z.ZodOptional<z.ZodObject<{
ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
ids?: string[] | undefined;
}, {
ids?: string[] | undefined;
}>>;
}, z.UnknownKeysParam, z.ZodTypeAny, {
type: "getElements";
params?: {
ids?: string[] | undefined;
} | undefined;
}, {
type: "getElements";
params?: {
ids?: string[] | undefined;
} | undefined;
}>;
declare const GetGroupMessage$1: z.ZodObject<{
type: z.ZodLiteral<"getElementGroup">;
params: z.ZodString;
}, z.UnknownKeysParam, z.ZodTypeAny, {
params: string;
type: "getElementGroup";
}, {
params: string;
type: "getElementGroup";
}>;
declare const GetGroupsMessage$1: z.ZodObject<{
type: z.ZodLiteral<"getElementGroups">;
params: z.ZodOptional<z.ZodObject<{
ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
ids?: string[] | undefined;
}, {
ids?: string[] | undefined;
}>>;
}, z.UnknownKeysParam, z.ZodTypeAny, {
type: "getElementGroups";
params?: {
ids?: string[] | undefined;
} | undefined;
}, {
type: "getElementGroups";
params?: {
ids?: string[] | undefined;
} | undefined;
}>;
declare const SetElementGroupVisibilityMessage: z.ZodObject<{
type: z.ZodLiteral<"setElementGroupVisibility">;
params: z.ZodObject<{
show: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
hide: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
show?: string[] | undefined;
hide?: string[] | undefined;
}, {
show?: string[] | undefined;
hide?: string[] | undefined;
}>;
}, z.UnknownKeysParam, z.ZodTypeAny, {
params: {
show?: string[] | undefined;
hide?: string[] | undefined;
};
type: "setElementGroupVisibility";
}, {
params: {
show?: string[] | undefined;
hide?: string[] | undefined;
};
type: "setElementGroupVisibility";
}>;
declare const OnElementChangeMessage: z.ZodObject<{
eventName: z.ZodLiteral<"onElementChange">;
id: z.ZodString;
options: z.ZodObject<{
id: z.ZodString;
}, "strip", z.ZodTypeAny, {
id: string;
}, {
id: string;
}>;
}, "strict", z.ZodTypeAny, {
options: {
id: string;
};
eventName: "onElementChange";
id: string;
}, {
options: {
id: string;
};
eventName: "onElementChange";
id: string;
}>;
declare const OnElementGroupChangeMessage: z.ZodObject<{
eventName: z.ZodLiteral<"onElementGroupChange">;
id: z.ZodString;
options: z.ZodObject<{
id: z.ZodString;
}, "strip", z.ZodTypeAny, {
id: string;
}, {
id: string;
}>;
}, "strict", z.ZodTypeAny, {
options: {
id: string;
};
eventName: "onElementGroupChange";
id: string;
}, {
options: {
id: string;
};
eventName: "onElementGroupChange";
id: string;
}>;
type ElementsSchema = {
methods: {
getElement: Method<zInfer<typeof GetElementMessage>, Element | null>;
getElementGeometry: Method<zInfer<typeof GetElementGeometryMessage>, Geometry | null>;
getElements: Method<zInfer<typeof GetElementsMessage>, Array<Element | null>>;
getElementGroup: Method<zInfer<typeof GetGroupMessage$1>, ElementGroup | null>;
getElementGroups: Method<zInfer<typeof GetGroupsMessage$1>, Array<ElementGroup | null>>;
setElementGroupVisibility: Method<zInfer<typeof SetElementGroupVisibilityMessage>, void>;
};
listeners: {
onElementChange: Listener<zInfer<typeof OnElementChangeMessage.shape.options>, ElementChangeCallbackParams>;
onElementGroupChange: Listener<zInfer<typeof OnElementGroupChangeMessage.shape.options>, ElementGroupChangeCallbackParams>;
};
};
type InteractionsSchema = {
methods: {};
listeners: {
onPointerClick: Listener<void, MapInteractionEvent>;
onPointerMove: Listener<void, MapInteractionEvent>;
};
};
declare const GetLayerMessage: z.ZodObject<{
type: z.ZodLiteral<"getLayer">;
params: z.ZodString;
}, z.UnknownKeysParam, z.ZodTypeAny, {
params: string;
type: "getLayer";
}, {
params: string;
type: "getLayer";
}>;
declare const GetLayersMessage: z.ZodObject<{
type: z.ZodLiteral<"getLayers">;
params: z.ZodOptional<z.ZodObject<{
ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
ids?: string[] | undefined;
}, {
ids?: string[] | undefined;
}>>;
}, z.UnknownKeysParam, z.ZodTypeAny, {
type: "getLayers";
params?: {
ids?: string[] | undefined;
} | undefined;
}, {
type: "getLayers";
params?: {
ids?: string[] | undefined;
} | undefined;
}>;
declare const SetLayerVisibilityMessage: z.ZodObject<{
type: z.ZodLiteral<"setLayerVisibility">;
params: z.ZodObject<{
show: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
hide: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
show?: string[] | undefined;
hide?: string[] | undefined;
}, {
show?: string[] | undefined;
hide?: string[] | undefined;
}>;
}, z.UnknownKeysParam, z.ZodTypeAny, {
params: {
show?: string[] | undefined;
hide?: string[] | undefined;
};
type: "setLayerVisibility";
}, {
params: {
show?: string[] | undefined;
hide?: string[] | undefined;
};
type: "setLayerVisibility";
}>;
declare const OnLayerChangeMessage: z.ZodObject<{
eventName: z.ZodLiteral<"onLayerChange">;
id: z.ZodString;
options: z.ZodObject<{
id: z.ZodString;
}, "strip", z.ZodTypeAny, {
id: string;
}, {
id: string;
}>;
}, "strict", z.ZodTypeAny, {
options: {
id: string;
};
eventName: "onLayerChange";
id: string;
}, {
options: {
id: string;
};
eventName: "onLayerChange";
id: string;
}>;
declare const SetLayerStyleMessage: z.ZodObject<{
type: z.ZodLiteral<"setLayerStyle">;
params: z.ZodObject<{
id: z.ZodString;
style: z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>;
}, "strip", z.ZodTypeAny, {
id: string;
style: {} & {
[k: string]: unknown;
};
}, {
id: string;
style: {} & {
[k: string]: unknown;
};
}>;
}, z.UnknownKeysParam, z.ZodTypeAny, {
params: {
id: string;
style: {} & {
[k: string]: unknown;
};
};
type: "setLayerStyle";
}, {
params: {
id: string;
style: {} & {
[k: string]: unknown;
};
};
type: "setLayerStyle";
}>;
declare const GetGroupMessage: z.ZodObject<{
type: z.ZodLiteral<"getLayerGroup">;
params: z.ZodString;
}, z.UnknownKeysParam, z.ZodTypeAny, {
params: string;
type: "getLayerGroup";
}, {
params: string;
type: "getLayerGroup";
}>;
declare const GetGroupsMessage: z.ZodObject<{
type: z.ZodLiteral<"getLayerGroups">;
params: z.ZodOptional<z.ZodObject<{
ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
ids?: string[] | undefined;
}, {
ids?: string[] | undefined;
}>>;
}, z.UnknownKeysParam, z.ZodTypeAny, {
type: "getLayerGroups";
params?: {
ids?: string[] | undefined;
} | undefined;
}, {
type: "getLayerGroups";
params?: {
ids?: string[] | undefined;
} | undefined;
}>;
declare const SetLayerGroupVisibilityMessage: z.ZodObject<{
type: z.ZodLiteral<"setLayerGroupVisibility">;
params: z.ZodObject<{
show: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
hide: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
show?: string[] | undefined;
hide?: string[] | undefined;
}, {
show?: string[] | undefined;
hide?: string[] | undefined;
}>;
}, z.UnknownKeysParam, z.ZodTypeAny, {
params: {
show?: string[] | undefined;
hide?: string[] | undefined;
};
type: "setLayerGroupVisibility";
}, {
params: {
show?: string[] | undefined;
hide?: string[] | undefined;
};
type: "setLayerGroupVisibility";
}>;
declare const OnLayerGroupChangeMessage: z.ZodObject<{
eventName: z.ZodLiteral<"onLayerGroupChange">;
id: z.ZodString;
options: z.ZodObject<{
id: z.ZodString;
}, "strip", z.ZodTypeAny, {
id: string;
}, {
id: string;
}>;
}, "strict", z.ZodTypeAny, {
options: {
id: string;
};
eventName: "onLayerGroupChange";
id: string;
}, {
options: {
id: string;
};
eventName: "onLayerGroupChange";
id: string;
}>;
declare const GetLegendItemMessage: z.ZodObject<{
type: z.ZodLiteral<"getLegendItem">;
params: z.ZodObject<{
id: z.ZodString;
layerId: z.ZodString;
}, "strip", z.ZodTypeAny, {
id: string;
layerId: string;
}, {
id: string;
layerId: string;
}>;
}, z.UnknownKeysParam, z.ZodTypeAny, {
params: {
id: string;
layerId: string;
};
type: "getLegendItem";
}, {
params: {
id: string;
layerId: string;
};
type: "getLegendItem";
}>;
declare const GetLegendItemsMessage: z.ZodObject<{
type: z.ZodLiteral<"getLegendItems">;
params: z.ZodOptional<z.ZodObject<{
ids: z.ZodOptional<z.ZodArray<z.ZodObject<{
id: z.ZodString;
layerId: z.ZodString;
}, "strip", z.ZodTypeAny, {
id: string;
layerId: string;
}, {
id: string;
layerId: string;
}>, "many">>;
layerIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
}, "strip", z.ZodTypeAny, {
ids?: {
id: string;
layerId: string;
}[] | undefined;
layerIds?: string[] | undefined;
}, {
ids?: {
id: string;
layerId: string;
}[] | undefined;
layerIds?: string[] | undefined;
}>>;
}, z.UnknownKeysParam, z.ZodTypeAny, {
type: "getLegendItems";
params?: {
ids?: {
id: string;
layerId: string;
}[] | undefined;
layerIds?: string[] | undefined;
} | undefined;
}, {
type: "getLegendItems";
params?: {
ids?: {
id: string;
layerId: string;
}[] | undefined;
layerIds?: string[] | undefined;
} | undefined;
}>;
declare const OnLegendItemChangeMessage: z.ZodObject<{
eventName: z.ZodLiteral<"onLegendItemChange">;
id: z.ZodString;
options: z.ZodObject<{
id: z.ZodString;
layerId: z.ZodString;
}, "strip", z.ZodTypeAny, {
id: string;
layerId: string;
}, {
id: string;
layerId: string;
}>;
}, "strict", z.ZodTypeAny, {
options: {
id: string;
layerId: string;
};
eventName: "onLegendItemChange";
id: string;
}, {
options: {
id: string;
layerId: string;
};
eventName: "onLegendItemChange";
id: string;
}>;
declare const SetLegendItemVisibilityMessage: z.ZodObject<{
type: z.ZodLiteral<"setLegendItemVisibility">;
params: z.ZodObject<{
show: z.ZodOptional<z.ZodArray<z.ZodObject<{
id: z.ZodString;
layerId: z.ZodString;
}, "strip", z.ZodTypeAny, {
id: string;
layerId: string;
}, {
id: string;
layerId: string;
}>, "many">>;
hide: z.ZodOptional<z.ZodArray<z.ZodObject<{
id: z.ZodString;
layerId: z.ZodString;
}, "strip", z.ZodTypeAny, {
id: string;
layerId: string;
}, {
id: string;
layerId: string;
}>, "many">>;
}, "strip", z.ZodTypeAny, {
show?: {
id: string;
layerId: string;
}[] | undefined;
hide?: {
id: string;
layerId: string;
}[] | undefined;
}, {
show?: {
id: string;
layerId: string;
}[] | undefined;
hide?: {
id: string;
layerId: string;
}[] | undefined;
}>;
}, z.UnknownKeysParam, z.ZodTypeAny, {
params: {
show?: {
id: string;
layerId: string;
}[] | undefined;
hide?: {
id: string;
layerId: string;
}[] | undefined;
};
type: "setLegendItemVisibility";
}, {
params: {
show?: {
id: string;
layerId: string;
}[] | undefined;
hide?: {
id: string;
layerId: string;
}[] | undefined;
};
type: "setLegendItemVisibility";
}>;
declare const GetFiltersMessage: z.ZodObject<{
type: z.ZodLiteral<"getLayerFilters">;
params: z.ZodString;
}, z.UnknownKeysParam, z.ZodTypeAny, {
params: string;
type: "getLayerFilters";
}, {
params: string;
type: "getLayerFilters";
}>;
declare const SetFiltersMessage: z.ZodObject<{
type: z.ZodLiteral<"setLayerFilters">;
params: z.ZodObject<{
layerId: z.ZodString;
filters: z.ZodUnion<[z.ZodType<FilterTernary, z.ZodTypeDef, FilterTernary>, z.ZodUnion<[z.ZodTuple<[z.ZodUnion<[z.ZodString, z.ZodNull]>, z.ZodEnum<["in", "ni"]>, z.ZodUnion<[z.ZodArray<z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>, "many">, z.ZodNull]>], null>, z.ZodTuple<[z.ZodUnion<[z.ZodString, z.ZodNull]>, z.ZodEnum<["lt", "gt", "le", "ge", "eq", "ne", "cn", "nc", "is", "isnt"]>, z.ZodUnion<[z.ZodNumber, z.ZodString, z.ZodBoolean, z.ZodNull]>], null>]>, z.ZodNull, z.ZodBoolean]>;
note: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
layerId: string;
filters: boolean | [string | null, "in" | "ni", (string | number | boolean | null)[] | null] | [string | null, "lt" | "gt" | "le" | "ge" | "eq" | "ne" | "cn" | "nc" | "is" | "isnt", string | number | boolean | null] | FilterTernary | null;
note?: string | undefined;
}, {
layerId: string;
filters: boolean | [string | null, "in" | "ni", (string | number | boolean | null)[] | null] | [string | null, "lt" | "gt" | "le" | "ge" | "eq" | "ne" | "cn" | "nc" | "is" | "isnt", string | number | boolean | null] | FilterTernary | null;
note?: string | undefined;
}>;
}, z.UnknownKeysParam, z.ZodTypeAny, {
params: {
layerId: string;
filters: boolean | [string | null, "in" | "ni", (string | number | boolean | null)[] | null] | [string | null, "lt" | "gt" | "le" | "ge" | "eq" | "ne" | "cn" | "nc" | "is" | "isnt", string | number | boolean | null] | FilterTernary | null;
note?: string | undefined;
};
type: "setLayerFilters";
}, {
params: {
layerId: string;
filters: boolean | [string | null, "in" | "ni", (string | number | boolean | null)[] | null] | [string | null, "lt" | "gt" | "le" | "ge" | "eq" | "ne" | "cn" | "nc" | "is" | "isnt", string | number | boolean | null] | FilterTernary | null;
note?: string | undefined;
};
type: "setLayerFilters";
}>;
declare const GetRenderedFeaturesMessage: z.ZodObject<{
type: z.ZodLiteral<"getRenderedFeatures">;
params: z.ZodOptional<z.ZodObject<{
layerIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
areaQuery: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
coordinates: z.ZodObject<{
latitude: z.ZodNumber;
longitude: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
latitude: number;
longitude: number;
}, {
latitude: number;
longitude: number;
}>;
}, "strip", z.ZodTypeAny, {
coordinates: {
latitude: number;
longitude: number;
};
}, {
coordinates: {
latitude: number;
longitude: number;
};
}>, z.ZodObject<{
boundary: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
}, "strip", z.ZodTypeAny, {
boundary: [number, number, number, number];
}, {
boundary: [number, number, number, number];
}>]>>;
}, "strip", z.ZodTypeAny, {
layerIds?: string[] | undefined;
areaQuery?: {
coordinates: {
latitude: number;
longitude: number;
};
} | {
boundary: [number, number, number, number];
} | undefined;
}, {
layerIds?: string[] | undefined;
areaQuery?: {
coordinates: {
latitude: number;
longitude: number;
};
} | {
boundary: [number, number, number, number];
} | undefined;
}>>;
}, z.UnknownKeysParam, z.ZodTypeAny, {
type: "getRenderedFeatures";
params?: {
layerIds?: string[] | undefined;
areaQuery?: {
coordinates: {
latitude: number;
longitude: number;
};
} | {
boundary: [number, number, number, number];
} | undefined;
} | undefined;
}, {
type: "getRenderedFeatures";
params?: {
layerIds?: string[] | undefined;
areaQuery?: {
coordinates: {
latitude: number;
longitude: number;
};
} | {
boundary: [number, number, number, number];
} | undefined;
} | undefined;
}>;
type LayersSchema = {
methods: {
getLayer: Method<zInfer<typeof GetLayerMessage>, Layer | null>;
getLayers: Method<zInfer<typeof GetLayersMessage>, Array<Layer | null>>;
setLayerVisibility: Method<zInfer<typeof SetLayerVisibilityMessage>, void>;
setLayerStyle: Method<zInfer<typeof SetLayerStyleMessage>, void>;
getLayerGroup: Method<zInfer<typeof GetGroupMessage>, LayerGroup | null>;
getLayerGroups: Method<zInfer<typeof GetGroupsMessage>, Array<LayerGroup | null>>;
setLayerGroupVisibility: Method<zInfer<typeof SetLayerGroupVisibilityMessage>, void>;
getLegendItem: Method<zInfer<typeof GetLegendItemMessage>, LegendItem | null>;
getLegendItems: Method<zInfer<typeof GetLegendItemsMessage>, Array<LegendItem | null>>;
setLegendItemVisibility: Method<zInfer<typeof SetLegendItemVisibilityMessage>, void>;
getLayerFilters: Method<zInfer<typeof GetFiltersMessage>, LayerFilters | null>;
setLayerFilters: Method<zInfer<typeof SetFiltersMessage>, void>;
getRenderedFeatures: Method<zInfer<typeof GetRenderedFeaturesMessage>, Array<Feature>>;
};
listeners: {
onLayerChange: Listener<zInfer<typeof OnLayerChangeMessage.shape.options>, LayerChangeCallbackParams>;
onLayerGroupChange: Listener<zInfer<typeof OnLayerGroupChangeMessage.shape.options>, LayerGroupChangeCallbackParams>;
onLegendItemChange: Listener<zInfer<typeof OnLegendItemChangeMessage.shape.options>, LegendItemChangeCallbackParams>;
};
};
declare const GetSelectionMessage: z.ZodObject<{
type: z.ZodLiteral<"getSelection">;
params: z.ZodUndefined;
}, z.UnknownKeysParam, z.ZodTypeAny, {
type: "getSelection";
params?: undefined;
}, {
type: "getSelection";
params?: undefined;
}>;
declare const SelectFeatureMessage: z.ZodObject<{
type: z.ZodLiteral<"selectFeature">;
params: z.ZodObject<{
id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
layerId: z.ZodString;
showPopup: z.ZodOptional<z.ZodBoolean>;
fitViewport: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodObject<{
maxZoom: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
maxZoom: number;
}, {
maxZoom: number;
}>]>>;
}, "strip", z.ZodTypeAny, {
id: string | number;
layerId: string;
showPopup?: boolean | undefined;
fitViewport?: boolean | {
maxZoom: number;
} | undefined;
}, {
id: string | number;
layerId: string;
showPopup?: boolean | undefined;
fitViewport?: boolean | {
maxZoom: number;
} | undefined;
}>;
}, z.UnknownKeysParam, z.ZodTypeAny, {
params: {
id: string | number;
layerId: string;
showPopup?: boolean | undefined;
fitViewport?: boolean | {
maxZoom: number;
} | undefined;
};
type: "selectFeature";
}, {
params: {
id: string | number;
layerId: string;
showPopup?: boolean | undefined;
fitViewport?: boolean | {
maxZoom: number;
} | undefined;
};
type: "selectFeature";
}>;
declare const ClearSelectionMessage: z.ZodObject<{
type: z.ZodLiteral<"clearSelection">;
params: z.ZodOptional<z.ZodObject<{
features: z.ZodOptional<z.ZodBoolean>;
elements: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
features?: boolean | undefined;
elements?: boolean | undefined;
}, {
features?: boolean | undefined;
elements?: boolean | undefined;
}>>;
}, z.UnknownKeysParam, z.ZodTypeAny, {
type: "clearSelection";
params?: {
features?: boolean | undefined;
elements?: boolean | undefined;
} | undefined;
}, {
type: "clearSelection";
params?: {
features?: boolean | undefined;
elements?: boolean | undefined;
} | undefined;
}>;
type SelectionSchema = {
methods: {
getSelection: Method<zInfer<typeof GetSelectionMessage>, Array<EntityNode>>;
selectFeature: Method<zInfer<typeof SelectFeatureMessage>, void>;
clearSelection: Method<zInfer<typeof ClearSelectionMessage>, void>;
};
listeners: {
onSelectionChange: Listener<void, {
selection: Array<EntityNode>;
}>;
};
};
declare const UiControlsMessage: zod.ZodObject<{
type: zod.ZodLiteral<"updateUiControls">;
params: zod.ZodObject<{
showLegend: zod.ZodOptional<zod.ZodBoolean>;
cooperativeGestures: zod.ZodOptional<zod.ZodBoolean>;
fullScreenButton: zod.ZodOptional<zod.ZodBoolean>;
geolocation: zod.ZodOptional<zod.ZodBoolean>;
zoomControls: zod.ZodOptional<zod.ZodBoolean>;
scaleBar: zod.ZodOptional<zod.ZodBoolean>;
}, "strip", zod.ZodTypeAny, {
showLegend?: boolean | undefined;
cooperativeGestures?: boolean | undefined;
fullScreenButton?: boolean | undefined;
geolocation?: boolean | undefined;
zoomControls?: boolean | undefined;
scaleBar?: boolean | undefined;
}, {
showLegend?: boolean | undefined;
cooperativeGestures?: boolean | undefined;
fullScreenButton?: boolean | undefined;
geolocation?: boolean | undefined;
zoomControls?: boolean | undefined;
scaleBar?: boolean | undefined;
}>;
}, zod.UnknownKeysParam, zod.ZodTypeAny, {
params: {
showLegend?: boolean | undefined;
cooperativeGestures?: boolean | undefined;
fullScreenButton?: boolean | undefined;
geolocation?: boolean | undefined;
zoomControls?: boolean | undefined;
scaleBar?: boolean | undefined;
};
type: "updateUiControls";
}, {
params: {
showLegend?: boolean | undefined;
cooperativeGestures?: boolean | undefined;
fullScreenButton?: boolean | undefined;
geolocation?: boolean | undefined;
zoomControls?: boolean | undefined;
scaleBar?: boolean | undefined;
};
type: "updateUiControls";
}>;
declare const OnMapInteractionsMessage: zod.ZodObject<{
type: zod.ZodLiteral<"setOnMapInteractionsUi">;
params: zod.ZodObject<{
featureSelectPanel: zod.ZodOptional<zod.ZodBoolean>;
featureHoverPanel: zod.ZodOptional<zod.ZodBoolean>;
elementSelectPanel: zod.ZodOptional<zod.ZodBoolean>;
linkClickOpen: zod.ZodOptional<zod.ZodBoolean>;
imageLightboxOpen: zod.ZodOptional<zod.ZodBoolean>;
}, "strip", zod.ZodTypeAny, {
featureSelectPanel?: boolean | undefined;
featureHoverPanel?: boolean | undefined;
elementSelectPanel?: boolean | undefined;
linkClickOpen?: boolean | undefined;
imageLightboxOpen?: boolean | undefined;
}, {
featureSelectPanel?: boolean | undefined;
featureHoverPanel?: boolean | undefined;
elementSelectPanel?: boolean | undefined;
linkClickOpen?: boolean | undefined;
imageLightboxOpen?: boolean | undefined;
}>;
}, zod.UnknownKeysParam, zod.ZodTypeAny, {
params: {
featureSelectPanel?: boolean | undefined;
featureHoverPanel?: boolean | undefined;
elementSelectPanel?: boolean | undefined;
linkClickOpen?: boolean | undefined;
imageLightboxOpen?: boolean | undefined;
};
type: "setOnMapInteractionsUi";
}, {
params: {
featureSelectPanel?: boolean | undefined;
featureHoverPanel?: boolean | undefined;
elementSelectPanel?: boolean | undefined;
linkClickOpen?: boolean | undefined;
imageLightboxOpen?: boolean | undefined;
};
type: "setOnMapInteractionsUi";
}>;
type UiSchema = {
methods: {
updateUiControls: Method<zInfer<typeof UiControlsMessage>, void>;
setOnMapInteractionsUi: Method<zInfer<typeof OnMapInteractionsMessage>, void>;
};
listeners: {};
};
declare const GetViewportMessage: z.ZodObject<{
type: z.ZodLiteral<"getViewport">;
params: z.ZodUndefined;
}, z.UnknownKeysParam, z.ZodTypeAny, {
type: "getViewport";
params?: undefined;
}, {
type: "getViewport";
params?: undefined;
}>;
declare const GotoViewportMessage: z.ZodObject<{
type: z.ZodLiteral<"setViewport">;
params: z.ZodObject<{
center: z.ZodOptional<z.ZodObject<{
latitude: z.ZodNumber;
longitude: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
latitude: number;
longitude: number;
}, {
latitude: number;
longitude: number;
}>>;
zoom: z.ZodOptional<z.ZodNumber>;
}, "strip", z.ZodTypeAny, {
center?: {
latitude: number;
longitude: number;
} | undefined;
zoom?: number | undefined;
}, {
center?: {
latitude: number;
longitude: number;
} | undefined;
zoom?: number | undefined;
}>;
}, z.UnknownKeysParam, z.ZodTypeAny, {
params: {
center?: {
latitude: number;
longitude: number;
} | undefined;
zoom?: number | undefined;
};
type: "setViewport";
}, {
params: {
center?: {
latitude: number;
longitude: number;
} | undefined;
zoom?: number | undefined;
};
type: "setViewport";
}>;
declare const ViewportFitBoundsMessage: z.ZodObject<{
type: z.ZodLiteral<"fitViewportToBounds">;
params: z.ZodObject<{
bounds: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
}, "strip", z.ZodTypeAny, {
bounds: [number, number, number, number];
}, {
bounds: [number, number, number, number];
}>;
}, z.UnknownKeysParam, z.ZodTypeAny, {
params: {
bounds: [number, number, number, number];
};
type: "fitViewportToBounds";
}, {
params: {
bounds: [number, number, number, number];
};
type: "fitViewportToBounds";
}>;
type ViewportSchema = {
methods: {
getViewport: Method<zInfer<typeof GetViewportMessage>, ViewportState>;
setViewport: Method<zInfer<typeof GotoViewportMessage>, void>;
fitViewportToBounds: Method<zInfer<typeof ViewportFitBoundsMessage>, void>;
};
listeners: {
onViewportMove: Listener<void, ViewportState>;
onViewportMoveEnd: Listener<void, ViewportState>;
onMapIdle: Listener<void, void>;
};
};
type AllModules = UiSchema | ViewportSchema | LayersSchema | ElementsSchema | SelectionSchema | InteractionsSchema;
type FeltHandlers = {
methods: FeltMethodHandlers;
listeners: FeltListenerHandlers;
};
type MethodSpec = UnionToIntersection<AllModules["methods"]>;
type ListenerSpec = UnionToIntersection<AllModules["listeners"]>;
type ExtractMethodParams<T extends Record<string, {
request: {
params?: any;
};
response: any;
}>> = {
[K in keyof T]: {
request: T[K]["request"]["params"];
response: T[K]["response"];
};
};
type ExtractListenerParams<T extends Record<string, {
options: any;
eventParams: any;
}>> = {
[K in keyof T]: {
options: T[K]["options"];
eventParams: T[K]["eventParams"];
};
};
type MethodHandlers<T> = {
[K in keyof T]: (request: T[K] extends {
request: any;
} ? T[K]["request"] : never) => PromiseOrNot<T[K] extends {
response: any;
} ? T[K]["response"] : never>;
};
type FeltMethodHandlers = MethodHandlers<ExtractMethodParams<MethodSpec>>;
type ListenerHandlers<T> = {
[K in keyof T]: (args: {
handler: (event: T[K] extends {
eventParams: any;
} ? T[K]["eventParams"] : never) => void;
options: T[K] extends {
options: any;
} ? T[K]["options"] : never;
}) => VoidFunction;
};
type FeltListenerHandlers = ListenerHandlers<ExtractListenerParams<ListenerSpec>>;
/**
* This function creates a message handler for the Felt SDK. Its job is to start listening
* for messages from the Felt SDKl, validate and parses the messages before calling the
* appropriate handler.
*
* @param feltWindow - The window to listen on, which is typically just `window`
* @param handlers - The handlers to call for each type of message.
* @param options - Optional callbacks for handling unknown and invalid messages.
* @returns A function to stop the message handler.
*/
declare function createMessageHandler(feltWindow: Window, handlers: FeltHandlers, options?: {
/**
* Called when a message is received of an unknown type.
*
* @param message - The message that was received.
*/
onUnknownMessage?: (message: unknown) => void;
/**
* Called when a message is received that matches a known
* type, but fails to parse with the full schema.
*
* @param message
*/
onInvalidMessage?: (message: unknown) => void;
}): VoidFunction;
export { createMessageHandler };