From 61ada56b3d1dbfa6b5311b899fa8673afd16206e Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Wed, 29 Jan 2025 13:02:39 +0100 Subject: [PATCH 01/12] WIP tool selection --- src/modules/main/controller.ts | 5 ++++- src/modules/main/schema.ts | 5 ++++- src/modules/ui/controller.ts | 9 +++++++++ src/modules/ui/schema.ts | 16 +++++++++++++++- 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/modules/main/controller.ts b/src/modules/main/controller.ts index 27efd5e..1801dfb 100644 --- a/src/modules/main/controller.ts +++ b/src/modules/main/controller.ts @@ -11,6 +11,7 @@ import { selectionController, type SelectionController, } from "../selection/controller"; +import { toolsController, type ToolsController } from "../tools/controller"; import { uiController, type UiController } from "../ui/controller"; import { viewportController, @@ -31,6 +32,7 @@ export function makeController(feltWindow: Window): FeltController { ...elementsController(feltWindow), ...selectionController(feltWindow), ...interactionsController(feltWindow), + ...toolsController(feltWindow), }; } @@ -56,7 +58,8 @@ export interface FeltController LayersController, ElementsController, SelectionController, - InteractionsController { + InteractionsController, + ToolsController { /** * The iframe element containing the Felt map, if it is an embedded map. * diff --git a/src/modules/main/schema.ts b/src/modules/main/schema.ts index d4a3a2f..6e474ca 100644 --- a/src/modules/main/schema.ts +++ b/src/modules/main/schema.ts @@ -5,6 +5,7 @@ import { } from "../interactions/schema"; import { layersSchema, type LayersSchema } from "../layers/schema"; import { selectionSchema, type SelectionSchema } from "../selection/schema"; +import { toolsSchema, type ToolsSchema } from "../tools/schema"; import { uiSchema, type UiSchema } from "../ui/schema"; import { viewportSchema, type ViewportSchema } from "../viewport/schema"; @@ -15,6 +16,7 @@ export const allModules = [ elementsSchema, selectionSchema, interactionsSchema, + toolsSchema, ]; export type AllModules = @@ -23,4 +25,5 @@ export type AllModules = | LayersSchema | ElementsSchema | SelectionSchema - | InteractionsSchema; + | InteractionsSchema + | ToolsSchema; diff --git a/src/modules/ui/controller.ts b/src/modules/ui/controller.ts index ffe6c79..b5fa18a 100644 --- a/src/modules/ui/controller.ts +++ b/src/modules/ui/controller.ts @@ -7,6 +7,7 @@ import type { UiControlsOptions, UiOnMapInteractionsOptions } from "./types"; export const uiController = (feltWindow: Window): UiController => ({ updateUiControls: method(feltWindow, "updateUiControls"), setOnMapInteractionsUi: method(feltWindow, "setOnMapInteractionsUi"), + enableToolSettingsUi: method(feltWindow, "enableToolSettingsUi"), }); /** @@ -36,4 +37,12 @@ export interface UiController { * will still be selected when clicked. */ setOnMapInteractionsUi(options: UiOnMapInteractionsOptions): void; + + /** + * Enables or disables the tool settings UI which shows up on the right hand side + * when a tool is in use. + * + * @param enabled - Whether to enable the tool settings UI. + */ + enableToolSettingsUi(enabled: boolean): void; } diff --git a/src/modules/ui/schema.ts b/src/modules/ui/schema.ts index ea55f9b..0709271 100644 --- a/src/modules/ui/schema.ts +++ b/src/modules/ui/schema.ts @@ -1,3 +1,4 @@ +import { z } from "zod"; import type { ModuleSchema } from "~/lib/ModuleSchema"; import { type Method, methodMessage } from "~/lib/builders"; import type { zInfer } from "~/lib/utils"; @@ -16,8 +17,17 @@ const OnMapInteractionsMessage = methodMessage( UiOnMapInteractionsOptionsSchema, ); +const EnableToolSettingsUiMessage = methodMessage( + "enableToolSettingsUi", + z.boolean(), +); + export const uiSchema = { - methods: [UiControlsMessage, OnMapInteractionsMessage], + methods: [ + UiControlsMessage, + OnMapInteractionsMessage, + EnableToolSettingsUiMessage, + ], listeners: null, } satisfies ModuleSchema; @@ -28,6 +38,10 @@ export type UiSchema = { zInfer, void >; + enableToolSettingsUi: Method< + zInfer, + void + >; }; listeners: {}; }; From 408716136c9078145fdaec4fe68e51494519c9ff Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Wed, 29 Jan 2025 13:26:04 +0100 Subject: [PATCH 02/12] Build docs --- docs/Main/FeltController.md | 166 ++++++++++++++++++++- docs/README.md | 1 + docs/Tools/InputToolSettings.md | 3 + docs/Tools/README.md | 15 ++ docs/Tools/ToolSettings.md | 3 + docs/Tools/ToolType.md | 3 + docs/Tools/ToolsController.md | 152 +++++++++++++++++++ docs/UI/UiController.md | 19 +++ etc/js-sdk.api.md | 123 ++++++++------- src/modules/tools/controller.ts | 105 +++++++++++++ src/modules/tools/index.ts | 8 + src/modules/tools/schema.ts | 58 +++++++ src/modules/tools/types.ts | 257 ++++++++++++++++++++++++++++++++ 13 files changed, 862 insertions(+), 51 deletions(-) create mode 100644 docs/Tools/InputToolSettings.md create mode 100644 docs/Tools/README.md create mode 100644 docs/Tools/ToolSettings.md create mode 100644 docs/Tools/ToolType.md create mode 100644 docs/Tools/ToolsController.md create mode 100644 src/modules/tools/controller.ts create mode 100644 src/modules/tools/index.ts create mode 100644 src/modules/tools/schema.ts create mode 100644 src/modules/tools/types.ts diff --git a/docs/Main/FeltController.md b/docs/Main/FeltController.md index d1e473d..6c834c2 100644 --- a/docs/Main/FeltController.md +++ b/docs/Main/FeltController.md @@ -10,7 +10,7 @@ own to make it easier to find related methods and events. ## Extends -* [`ViewportController`](../Viewport/ViewportController.md).[`UiController`](../UI/UiController.md).[`LayersController`](../Layers/LayersController.md).[`ElementsController`](../Elements/ElementsController.md).[`SelectionController`](../Selection/SelectionController.md).[`InteractionsController`](../Interactions/InteractionsController.md) +* [`ViewportController`](../Viewport/ViewportController.md).[`UiController`](../UI/UiController.md).[`LayersController`](../Layers/LayersController.md).[`ElementsController`](../Elements/ElementsController.md).[`SelectionController`](../Selection/SelectionController.md).[`InteractionsController`](../Interactions/InteractionsController.md).[`ToolsController`](../Tools/ToolsController.md) ## Properties @@ -696,6 +696,151 @@ felt.clearSelection({ elements: true }); *** +### setTool() + +> **setTool**(`tool`: `null` | `"note"` | `"pin"` | `"line"` | `"route"` | `"polygon"` | `"circle"` | `"marker"` | `"highlighter"` | `"text"` | `"link"`): `void` + +Sets the tool to use for drawing elements on the map. + +#### Parameters + +| Parameter | Type | Description | +| --------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | +| `tool` | `null` \| `"note"` \| `"pin"` \| `"line"` \| `"route"` \| `"polygon"` \| `"circle"` \| `"marker"` \| `"highlighter"` \| `"text"` \| `"link"` | The tool to set. | + +#### Returns + +`void` + +#### Example + +```ts +// Set the tool to "marker" +felt.setTool("marker"); + +// put down the tool +felt.setTool(null); +``` + +*** + +### getTool() + +> **getTool**(): `Promise`\<`null` | `"note"` | `"pin"` | `"line"` | `"route"` | `"polygon"` | `"circle"` | `"marker"` | `"highlighter"` | `"text"` | `"link"`> + +Gets the current tool, if any is in use. + +#### Returns + +`Promise`\<`null` | `"note"` | `"pin"` | `"line"` | `"route"` | `"polygon"` | `"circle"` | `"marker"` | `"highlighter"` | `"text"` | `"link"`> + +The current tool, or `null` if no tool is in use. + +#### Example + +```ts +const tool = await felt.getTool(); // "marker", "polygon", etc. +``` + +*** + +### onToolChange() + +> **onToolChange**(`args`: \{`handler`: (`tool`: `null` | `"note"` | `"pin"` | `"line"` | `"route"` | `"polygon"` | `"circle"` | `"marker"` | `"highlighter"` | `"text"` | `"link"`) => `void`; }): `VoidFunction` + +Listens for changes to the current tool. + +#### Parameters + +| Parameter | Type | Description | +| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | +| `args` | `object` | - | +| `args.handler` | (`tool`: `null` \| `"note"` \| `"pin"` \| `"line"` \| `"route"` \| `"polygon"` \| `"circle"` \| `"marker"` \| `"highlighter"` \| `"text"` \| `"link"`) => `void` | This callback is called with the current tool whenever the tool changes. | + +#### Returns + +`VoidFunction` + +A function to unsubscribe from the listener + +#### Example + +```ts +const unsubscribe = felt.onToolChange({ + handler: tool => console.log(tool), +}); + +// later on... +unsubscribe(); +``` + +*** + +### setToolSettings() + +> **setToolSettings**(`settings`: \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; } | \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; } | \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } | \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; } | \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; } | \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }): `void` + +Sets the settings for the current tool. + +#### Parameters + +| Parameter | Type | Description | +| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------- | +| `settings` | \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` \| `string`; } \| \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`distanceMarker`: `boolean`; } \| \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } \| \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`areaMarker`: `boolean`; } \| \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`radiusMarker`: `boolean`; } \| \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } \| \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } \| \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` \| `"center"` \| `"right"`;`style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` \| `"center"` \| `"right"`;`style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } | The settings to set. | + +#### Returns + +`void` + +*** + +### getToolSettings() + +> **getToolSettings**\<`T`>(`tool`: `T`): `Promise`\<`Extract`\<\{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{`tool`: `T`; }>> + +Gets the settings for the current tool. + +#### Type Parameters + +| Type Parameter | +| ------------------------------------------------------------------------------------------------------------------------------------ | +| `T` *extends* `"note"` \| `"pin"` \| `"line"` \| `"route"` \| `"polygon"` \| `"circle"` \| `"marker"` \| `"highlighter"` \| `"text"` | + +#### Parameters + +| Parameter | Type | +| --------- | ---- | +| `tool` | `T` | + +#### Returns + +`Promise`\<`Extract`\<\{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{`tool`: `T`; }>> + +The settings for the current tool. + +*** + +### onToolSettingsChange() + +> **onToolSettingsChange**(`args`: \{`handler`: (`settings`: \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; } | \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; } | \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } | \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; } | \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; } | \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }) => `void`; }): `VoidFunction` + +Listens for changes to the settings on all tools. + +#### Parameters + +| Parameter | Type | +| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `args` | `object` | +| `args.handler` | (`settings`: \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` \| `string`; } \| \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`distanceMarker`: `boolean`; } \| \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } \| \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`areaMarker`: `boolean`; } \| \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`radiusMarker`: `boolean`; } \| \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } \| \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } \| \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` \| `"center"` \| `"right"`;`style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` \| `"center"` \| `"right"`;`style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; }) => `void` | + +#### Returns + +`VoidFunction` + +A function to unsubscribe from the listener + +*** + ### updateUiControls() > **updateUiControls**(`controls`: [`UiControlsOptions`](../UI/UiControlsOptions.md)): `void` @@ -740,6 +885,25 @@ will still be selected when clicked. *** +### enableToolSettingsUi() + +> **enableToolSettingsUi**(`enabled`: `boolean`): `void` + +Enables or disables the tool settings UI which shows up on the right hand side +when a tool is in use. + +#### Parameters + +| Parameter | Type | Description | +| --------- | --------- | --------------------------------------- | +| `enabled` | `boolean` | Whether to enable the tool settings UI. | + +#### Returns + +`void` + +*** + ### getViewport() > **getViewport**(): `Promise`\<[`ViewportState`](../Viewport/ViewportState.md)> diff --git a/docs/README.md b/docs/README.md index 691b63a..1a55054 100644 --- a/docs/README.md +++ b/docs/README.md @@ -8,5 +8,6 @@ * [Main](Main/README.md) * [Selection](Selection/README.md) * [Shared](Shared/README.md) +* [Tools](Tools/README.md) * [UI](UI/README.md) * [Viewport](Viewport/README.md) diff --git a/docs/Tools/InputToolSettings.md b/docs/Tools/InputToolSettings.md new file mode 100644 index 0000000..d058b55 --- /dev/null +++ b/docs/Tools/InputToolSettings.md @@ -0,0 +1,3 @@ +*** + +> **InputToolSettings**: \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; } | \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; } | \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } | \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; } | \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; } | \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } diff --git a/docs/Tools/README.md b/docs/Tools/README.md new file mode 100644 index 0000000..eaeae2c --- /dev/null +++ b/docs/Tools/README.md @@ -0,0 +1,15 @@ +*** + +The Tools part allows you to let users draw elements on the map. + +## Index + +### Type Aliases + +* [ToolType](ToolType.md) +* [InputToolSettings](InputToolSettings.md) +* [ToolSettings](ToolSettings.md) + +### Controller + +* [ToolsController](ToolsController.md) diff --git a/docs/Tools/ToolSettings.md b/docs/Tools/ToolSettings.md new file mode 100644 index 0000000..61d8a33 --- /dev/null +++ b/docs/Tools/ToolSettings.md @@ -0,0 +1,3 @@ +*** + +> **ToolSettings**: \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; } | \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; } | \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } | \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; } | \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; } | \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } diff --git a/docs/Tools/ToolType.md b/docs/Tools/ToolType.md new file mode 100644 index 0000000..98e09d8 --- /dev/null +++ b/docs/Tools/ToolType.md @@ -0,0 +1,3 @@ +*** + +> **ToolType**: `"note"` | `"pin"` | `"line"` | `"route"` | `"polygon"` | `"circle"` | `"marker"` | `"highlighter"` | `"text"` | `"link"` diff --git a/docs/Tools/ToolsController.md b/docs/Tools/ToolsController.md new file mode 100644 index 0000000..c818c0d --- /dev/null +++ b/docs/Tools/ToolsController.md @@ -0,0 +1,152 @@ +*** + +The Tools controller allows you to let users draw elements on the map. + +## Extended by + +* [`FeltController`](../Main/FeltController.md) + +## Methods + +### setTool() + +> **setTool**(`tool`: `null` | `"note"` | `"pin"` | `"line"` | `"route"` | `"polygon"` | `"circle"` | `"marker"` | `"highlighter"` | `"text"` | `"link"`): `void` + +Sets the tool to use for drawing elements on the map. + +#### Parameters + +| Parameter | Type | Description | +| --------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | +| `tool` | `null` \| `"note"` \| `"pin"` \| `"line"` \| `"route"` \| `"polygon"` \| `"circle"` \| `"marker"` \| `"highlighter"` \| `"text"` \| `"link"` | The tool to set. | + +#### Returns + +`void` + +#### Example + +```ts +// Set the tool to "marker" +felt.setTool("marker"); + +// put down the tool +felt.setTool(null); +``` + +*** + +### getTool() + +> **getTool**(): `Promise`\<`null` | `"note"` | `"pin"` | `"line"` | `"route"` | `"polygon"` | `"circle"` | `"marker"` | `"highlighter"` | `"text"` | `"link"`> + +Gets the current tool, if any is in use. + +#### Returns + +`Promise`\<`null` | `"note"` | `"pin"` | `"line"` | `"route"` | `"polygon"` | `"circle"` | `"marker"` | `"highlighter"` | `"text"` | `"link"`> + +The current tool, or `null` if no tool is in use. + +#### Example + +```ts +const tool = await felt.getTool(); // "marker", "polygon", etc. +``` + +*** + +### onToolChange() + +> **onToolChange**(`args`: \{`handler`: (`tool`: `null` | `"note"` | `"pin"` | `"line"` | `"route"` | `"polygon"` | `"circle"` | `"marker"` | `"highlighter"` | `"text"` | `"link"`) => `void`; }): `VoidFunction` + +Listens for changes to the current tool. + +#### Parameters + +| Parameter | Type | Description | +| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | +| `args` | `object` | - | +| `args.handler` | (`tool`: `null` \| `"note"` \| `"pin"` \| `"line"` \| `"route"` \| `"polygon"` \| `"circle"` \| `"marker"` \| `"highlighter"` \| `"text"` \| `"link"`) => `void` | This callback is called with the current tool whenever the tool changes. | + +#### Returns + +`VoidFunction` + +A function to unsubscribe from the listener + +#### Example + +```ts +const unsubscribe = felt.onToolChange({ + handler: tool => console.log(tool), +}); + +// later on... +unsubscribe(); +``` + +*** + +### setToolSettings() + +> **setToolSettings**(`settings`: \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; } | \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; } | \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } | \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; } | \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; } | \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }): `void` + +Sets the settings for the current tool. + +#### Parameters + +| Parameter | Type | Description | +| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------- | +| `settings` | \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` \| `string`; } \| \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`distanceMarker`: `boolean`; } \| \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } \| \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`areaMarker`: `boolean`; } \| \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`radiusMarker`: `boolean`; } \| \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } \| \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } \| \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` \| `"center"` \| `"right"`;`style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` \| `"center"` \| `"right"`;`style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } | The settings to set. | + +#### Returns + +`void` + +*** + +### getToolSettings() + +> **getToolSettings**\<`T`>(`tool`: `T`): `Promise`\<`Extract`\<\{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{`tool`: `T`; }>> + +Gets the settings for the current tool. + +#### Type Parameters + +| Type Parameter | +| ------------------------------------------------------------------------------------------------------------------------------------ | +| `T` *extends* `"note"` \| `"pin"` \| `"line"` \| `"route"` \| `"polygon"` \| `"circle"` \| `"marker"` \| `"highlighter"` \| `"text"` | + +#### Parameters + +| Parameter | Type | +| --------- | ---- | +| `tool` | `T` | + +#### Returns + +`Promise`\<`Extract`\<\{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{`tool`: `T`; }>> + +The settings for the current tool. + +*** + +### onToolSettingsChange() + +> **onToolSettingsChange**(`args`: \{`handler`: (`settings`: \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; } | \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; } | \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } | \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; } | \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; } | \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }) => `void`; }): `VoidFunction` + +Listens for changes to the settings on all tools. + +#### Parameters + +| Parameter | Type | +| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `args` | `object` | +| `args.handler` | (`settings`: \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` \| `string`; } \| \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`distanceMarker`: `boolean`; } \| \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } \| \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`areaMarker`: `boolean`; } \| \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`radiusMarker`: `boolean`; } \| \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } \| \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } \| \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` \| `"center"` \| `"right"`;`style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` \| `"center"` \| `"right"`;`style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; }) => `void` | + +#### Returns + +`VoidFunction` + +A function to unsubscribe from the listener diff --git a/docs/UI/UiController.md b/docs/UI/UiController.md index df1a84e..413d908 100644 --- a/docs/UI/UiController.md +++ b/docs/UI/UiController.md @@ -50,3 +50,22 @@ will still be selected when clicked. #### Returns `void` + +*** + +### enableToolSettingsUi() + +> **enableToolSettingsUi**(`enabled`: `boolean`): `void` + +Enables or disables the tool settings UI which shows up on the right hand side +when a tool is in use. + +#### Parameters + +| Parameter | Type | Description | +| --------- | --------- | --------------------------------------- | +| `enabled` | `boolean` | Whether to enable the tool settings UI. | + +#### Returns + +`void` diff --git a/etc/js-sdk.api.md b/etc/js-sdk.api.md index 08f4196..51fcdc2 100644 --- a/etc/js-sdk.api.md +++ b/etc/js-sdk.api.md @@ -4,55 +4,59 @@ ```ts -import { E as Element_2 } from './types-BDviYZ-T.js'; -import { d as ElementChangeCallbackParams } from './types-BDviYZ-T.js'; -import { b as ElementGroup } from './types-BDviYZ-T.js'; -import { e as ElementGroupChangeCallbackParams } from './types-BDviYZ-T.js'; -import { B as ElementGroupNode } from './types-BDviYZ-T.js'; -import { C as ElementNode } from './types-BDviYZ-T.js'; -import { r as EntityNode } from './types-BDviYZ-T.js'; -import { q as Feature } from './types-BDviYZ-T.js'; -import { D as FeatureNode } from './types-BDviYZ-T.js'; -import { s as FeatureSelection } from './types-BDviYZ-T.js'; -import { J as FeltBoundary } from './types-BDviYZ-T.js'; -import { K as FeltZoom } from './types-BDviYZ-T.js'; -import { x as FilterExpression } from './types-BDviYZ-T.js'; -import { y as FilterLogicGate } from './types-BDviYZ-T.js'; -import { F as Filters } from './types-BDviYZ-T.js'; -import { A as FilterTernary } from './types-BDviYZ-T.js'; -import { G as Geometry } from './types-BDviYZ-T.js'; -import { c as GetElementGroupsConstraint } from './types-BDviYZ-T.js'; -import { a as GetElementsConstraint } from './types-BDviYZ-T.js'; -import { i as GetLayerGroupsConstraint } from './types-BDviYZ-T.js'; -import { f as GetLayersConstraint } from './types-BDviYZ-T.js'; -import { p as GetRenderedFeaturesConstraint } from './types-BDviYZ-T.js'; -import { N as LatLng } from './types-BDviYZ-T.js'; -import { L as Layer } from './types-BDviYZ-T.js'; -import { g as LayerChangeCallbackParams } from './types-BDviYZ-T.js'; -import { o as LayerFilters } from './types-BDviYZ-T.js'; -import { h as LayerGroup } from './types-BDviYZ-T.js'; -import { j as LayerGroupChangeCallbackParams } from './types-BDviYZ-T.js'; -import { H as LayerGroupNode } from './types-BDviYZ-T.js'; -import { I as LayerNode } from './types-BDviYZ-T.js'; -import { w as LayerProcessingStatus } from './types-BDviYZ-T.js'; -import { l as LegendItem } from './types-BDviYZ-T.js'; -import { n as LegendItemChangeCallbackParams } from './types-BDviYZ-T.js'; -import { k as LegendItemIdentifier } from './types-BDviYZ-T.js'; -import { m as LegendItemsConstraint } from './types-BDviYZ-T.js'; -import { O as LineStringGeometry } from './types-BDviYZ-T.js'; -import { P as LngLatTuple } from './types-BDviYZ-T.js'; -import { M as MapInteractionEvent } from './types-BDviYZ-T.js'; -import { Q as MultiLineStringGeometry } from './types-BDviYZ-T.js'; -import { T as MultiPolygonGeometry } from './types-BDviYZ-T.js'; -import { U as PointGeometry } from './types-BDviYZ-T.js'; -import { W as PolygonGeometry } from './types-BDviYZ-T.js'; -import { R as RasterValue } from './types-BDviYZ-T.js'; -import { t as SetViewportCenterZoomParams } from './types-BDviYZ-T.js'; -import { S as SetVisibilityRequest } from './types-BDviYZ-T.js'; -import { v as ViewportCenterZoom } from './types-BDviYZ-T.js'; -import { u as ViewportFitBoundsParams } from './types-BDviYZ-T.js'; -import { V as ViewportState } from './types-BDviYZ-T.js'; -import { z } from './types-BDviYZ-T.js'; +import { C } from './types-fQVWhD-M.js'; +import { E as Element_2 } from './types-fQVWhD-M.js'; +import { d as ElementChangeCallbackParams } from './types-fQVWhD-M.js'; +import { b as ElementGroup } from './types-fQVWhD-M.js'; +import { e as ElementGroupChangeCallbackParams } from './types-fQVWhD-M.js'; +import { D as ElementGroupNode } from './types-fQVWhD-M.js'; +import { H as ElementNode } from './types-fQVWhD-M.js'; +import { r as EntityNode } from './types-fQVWhD-M.js'; +import { q as Feature } from './types-fQVWhD-M.js'; +import { J as FeatureNode } from './types-fQVWhD-M.js'; +import { s as FeatureSelection } from './types-fQVWhD-M.js'; +import { O as FeltBoundary } from './types-fQVWhD-M.js'; +import { P as FeltZoom } from './types-fQVWhD-M.js'; +import { y as FilterExpression } from './types-fQVWhD-M.js'; +import { A as FilterLogicGate } from './types-fQVWhD-M.js'; +import { F as Filters } from './types-fQVWhD-M.js'; +import { B as FilterTernary } from './types-fQVWhD-M.js'; +import { G as Geometry } from './types-fQVWhD-M.js'; +import { c as GetElementGroupsConstraint } from './types-fQVWhD-M.js'; +import { a as GetElementsConstraint } from './types-fQVWhD-M.js'; +import { i as GetLayerGroupsConstraint } from './types-fQVWhD-M.js'; +import { f as GetLayersConstraint } from './types-fQVWhD-M.js'; +import { p as GetRenderedFeaturesConstraint } from './types-fQVWhD-M.js'; +import { I } from './types-fQVWhD-M.js'; +import { Q as LatLng } from './types-fQVWhD-M.js'; +import { L as Layer } from './types-fQVWhD-M.js'; +import { g as LayerChangeCallbackParams } from './types-fQVWhD-M.js'; +import { o as LayerFilters } from './types-fQVWhD-M.js'; +import { h as LayerGroup } from './types-fQVWhD-M.js'; +import { j as LayerGroupChangeCallbackParams } from './types-fQVWhD-M.js'; +import { K as LayerGroupNode } from './types-fQVWhD-M.js'; +import { N as LayerNode } from './types-fQVWhD-M.js'; +import { x as LayerProcessingStatus } from './types-fQVWhD-M.js'; +import { l as LegendItem } from './types-fQVWhD-M.js'; +import { n as LegendItemChangeCallbackParams } from './types-fQVWhD-M.js'; +import { k as LegendItemIdentifier } from './types-fQVWhD-M.js'; +import { m as LegendItemsConstraint } from './types-fQVWhD-M.js'; +import { U as LineStringGeometry } from './types-fQVWhD-M.js'; +import { W as LngLatTuple } from './types-fQVWhD-M.js'; +import { M as MapInteractionEvent } from './types-fQVWhD-M.js'; +import { X as MultiLineStringGeometry } from './types-fQVWhD-M.js'; +import { Y as MultiPolygonGeometry } from './types-fQVWhD-M.js'; +import { Z as PointGeometry } from './types-fQVWhD-M.js'; +import { _ as PolygonGeometry } from './types-fQVWhD-M.js'; +import { R as RasterValue } from './types-fQVWhD-M.js'; +import { u as SetViewportCenterZoomParams } from './types-fQVWhD-M.js'; +import { S as SetVisibilityRequest } from './types-fQVWhD-M.js'; +import { T } from './types-fQVWhD-M.js'; +import { t } from './types-fQVWhD-M.js'; +import { w as ViewportCenterZoom } from './types-fQVWhD-M.js'; +import { v as ViewportFitBoundsParams } from './types-fQVWhD-M.js'; +import { V as ViewportState } from './types-fQVWhD-M.js'; +import { z } from './types-fQVWhD-M.js'; import { z as z_2 } from 'zod'; export { Element_2 as Element } @@ -110,8 +114,10 @@ export const Felt: { export { FeltBoundary } +// Warning: (ae-forgotten-export) The symbol "ToolsController" needs to be exported by the entry point client.d.ts +// // @public -export interface FeltController extends ViewportController, UiController, LayersController, ElementsController, SelectionController, InteractionsController { +export interface FeltController extends ViewportController, UiController, LayersController, ElementsController, SelectionController, InteractionsController, ToolsController { iframe: HTMLIFrameElement | null; } @@ -364,8 +370,25 @@ export { SetViewportCenterZoomParams } export { SetVisibilityRequest } +// @public +interface ToolsController { + getTool(): Promise; + getToolSettings(tool: T): Promise>; + onToolChange(args: { + handler: (tool: T | null) => void; + }): VoidFunction; + onToolSettingsChange(args: { + handler: (settings: t) => void; + }): VoidFunction; + setTool(tool: T | null): void; + setToolSettings(settings: I): void; +} + // @public export interface UiController { + enableToolSettingsUi(enabled: boolean): void; setOnMapInteractionsUi(options: OnMapInteractionsOptions): void; updateUiControls(controls: UiControlsOptions): void; } diff --git a/src/modules/tools/controller.ts b/src/modules/tools/controller.ts new file mode 100644 index 0000000..9cb011d --- /dev/null +++ b/src/modules/tools/controller.ts @@ -0,0 +1,105 @@ +import { listener, method } from "~/lib/interface"; +import type { + ConfigurableToolType, + InputToolSettings, + ToolSettings, + ToolType, +} from "./types"; + +/** + * @ignore + */ +export const toolsController = (feltWindow: Window): ToolsController => ({ + setTool: method(feltWindow, "setTool"), + getTool: method(feltWindow, "getTool"), + onToolChange: listener(feltWindow, "onToolChange"), + + setToolSettings: method(feltWindow, "setToolSettings"), + getToolSettings: method(feltWindow, "getToolSettings"), + onToolSettingsChange: listener(feltWindow, "onToolSettingsChange"), +}); + +/** + * The Tools controller allows you to let users draw elements on the map. + * + * @group Controller + * @public + */ +export interface ToolsController { + /** + * Sets the tool to use for drawing elements on the map. + * + * @param tool - The tool to set. + * + * @example + * ```ts + * // Set the tool to "marker" + * felt.setTool("marker"); + * + * // put down the tool + * felt.setTool(null); + * ``` + */ + setTool(tool: ToolType | null): void; + + /** + * Gets the current tool, if any is in use. + * + * @returns The current tool, or `null` if no tool is in use. + * + * @example + * ```ts + * const tool = await felt.getTool(); // "marker", "polygon", etc. + * ``` + */ + getTool(): Promise; + + /** + * Listens for changes to the current tool. + * + * @returns A function to unsubscribe from the listener + * + * @example + * ```ts + * const unsubscribe = felt.onToolChange({ + * handler: tool => console.log(tool), + * }); + * + * // later on... + * unsubscribe(); + * ``` + */ + onToolChange(args: { + /** + * This callback is called with the current tool whenever the tool changes. + * + * @param tool - The current tool, or `null` if no tool is in use. + */ + handler: (tool: ToolType | null) => void; + }): VoidFunction; + + /** + * Sets the settings for the current tool. + * + * @param settings - The settings to set. + */ + setToolSettings(settings: InputToolSettings): void; + + /** + * Gets the settings for the current tool. + * + * @returns The settings for the current tool. + */ + getToolSettings( + tool: T, + ): Promise>; + + /** + * Listens for changes to the settings on all tools. + * + * @returns A function to unsubscribe from the listener + */ + onToolSettingsChange(args: { + handler: (settings: ToolSettings) => void; + }): VoidFunction; +} diff --git a/src/modules/tools/index.ts b/src/modules/tools/index.ts new file mode 100644 index 0000000..3036de4 --- /dev/null +++ b/src/modules/tools/index.ts @@ -0,0 +1,8 @@ +/** + * The Tools part allows you to let users draw elements on the map. + * + * @module Tools + */ +export type { InputToolSettings, ToolSettings, ToolType } from "./types"; + +export type { ToolsController } from "./controller"; diff --git a/src/modules/tools/schema.ts b/src/modules/tools/schema.ts new file mode 100644 index 0000000..16372f6 --- /dev/null +++ b/src/modules/tools/schema.ts @@ -0,0 +1,58 @@ +import { z } from "zod"; +import type { ModuleSchema } from "~/lib/ModuleSchema"; +import { + type Listener, + listenerMessageNoParams, + type Method, + methodMessage, +} from "~/lib/builders"; +import type { zInfer } from "~/lib/utils"; +import { + ConfigurableToolSchema, + InputToolSettingsSchema, + ToolSchema, + type ToolSettings, + type ToolType, +} from "./types"; + +const SetToolMessage = methodMessage("setTool", ToolSchema.nullable()); +const GetToolMessage = methodMessage("getTool", z.undefined()); +const OnToolChangeMessage = listenerMessageNoParams("onToolChange"); + +const SetToolSettingsMessage = methodMessage( + "setToolSettings", + InputToolSettingsSchema, +); +const GetToolSettingsMessage = methodMessage( + "getToolSettings", + ConfigurableToolSchema, +); +const OnToolSettingsChangeMessage = listenerMessageNoParams( + "onToolSettingsChange", +); + +export const toolsSchema = { + methods: [ + SetToolMessage, + GetToolMessage, + SetToolSettingsMessage, + GetToolSettingsMessage, + ], + listeners: [OnToolChangeMessage, OnToolSettingsChangeMessage], +} satisfies ModuleSchema; + +export type ToolsSchema = { + methods: { + setTool: Method, void>; + getTool: Method, ToolType | null>; + setToolSettings: Method, void>; + getToolSettings: Method< + zInfer, + ToolSettings | any + >; + }; + listeners: { + onToolChange: Listener; + onToolSettingsChange: Listener; + }; +}; diff --git a/src/modules/tools/types.ts b/src/modules/tools/types.ts new file mode 100644 index 0000000..4538ad2 --- /dev/null +++ b/src/modules/tools/types.ts @@ -0,0 +1,257 @@ +import { z } from "zod"; + +const configurableTools = [ + "pin", + "line", + "route", + "polygon", + "circle", + "marker", + "highlighter", + "text", + "note", +] as const; + +export const ToolSchema = z.enum([...configurableTools, "link"]); +export const ConfigurableToolSchema = z.enum(configurableTools); + +export type ToolType = z.infer; +export type ConfigurableToolType = z.infer; + +const InputPinToolSettingsSchema = z.object({ + tool: z.literal("pin"), + color: z.string().optional(), + symbol: z.string().optional(), + frame: z.string().nullable().optional(), +}); + +const InputLineToolSettingsSchema = z.object({ + tool: z.literal("line"), + color: z.string().optional(), + strokeOpacity: z.number().optional(), + strokeWidth: z.number().optional(), + strokeStyle: z.enum(["solid", "dashed", "dotted"]).optional(), + distanceMarker: z.boolean().optional(), +}); + +const InputRouteToolSettingsSchema = z.object({ + tool: z.literal("route"), + color: z.string().optional(), + routingMode: z.enum(["driving", "cycling", "walking", "flying"]).optional(), + strokeOpacity: z.number().optional(), + strokeWidth: z.number().optional(), + strokeStyle: z.enum(["solid", "dashed", "dotted"]).optional(), + distanceMarker: z.boolean().optional(), + endCaps: z.boolean().optional(), +}); + +const InputPolygonToolSettingsSchema = z.object({ + tool: z.literal("polygon"), + color: z.string().optional(), + fillOpacity: z.number().optional(), + strokeOpacity: z.number().optional(), + strokeWidth: z.number().optional(), + strokeStyle: z.enum(["solid", "dashed", "dotted"]).optional(), + areaMarker: z.boolean().optional(), +}); + +const InputCircleToolSettingsSchema = z.object({ + tool: z.literal("circle"), + color: z.string().optional(), + fillOpacity: z.number().optional(), + strokeOpacity: z.number().optional(), + strokeWidth: z.number().optional(), + strokeStyle: z.enum(["solid", "dashed", "dotted"]).optional(), + radiusMarker: z.boolean().optional(), +}); + +const InputMarkerToolSettingsSchema = z.object({ + tool: z.literal("marker"), + color: z.string().optional(), + opacity: z.number().optional(), + size: z.number().optional(), +}); + +const InputHighlighterToolSettingsSchema = z.object({ + tool: z.literal("highlighter"), + color: z.string().optional(), + opacity: z.number().optional(), + size: z.number().optional(), +}); + +const InputTextToolSettingsSchema = z.object({ + tool: z.literal("text"), + color: z.string().optional(), + align: z.enum(["left", "center", "right"]).optional(), + style: z.enum(["italic", "light", "regular", "caps"]).optional(), +}); + +const InputNoteToolSettingsSchema = z.object({ + tool: z.literal("note"), + color: z.string().optional(), + align: z.enum(["left", "center", "right"]).optional(), + style: z.enum(["italic", "light", "regular", "caps"]).optional(), +}); + +export const InputToolSettingsSchema = z.discriminatedUnion("tool", [ + // GEOGRAPHIC TOOLS + InputPinToolSettingsSchema, + InputLineToolSettingsSchema, + InputRouteToolSettingsSchema, + InputPolygonToolSettingsSchema, + InputCircleToolSettingsSchema, + + // ANNOTATION TOOLS + InputMarkerToolSettingsSchema, + InputHighlighterToolSettingsSchema, + InputTextToolSettingsSchema, + InputNoteToolSettingsSchema, +]); + +export const ToolSettingsSchema = z.discriminatedUnion("tool", [ + // GEOGRAPHIC TOOLS + InputPinToolSettingsSchema.required(), + InputLineToolSettingsSchema.required(), + InputRouteToolSettingsSchema.required(), + InputPolygonToolSettingsSchema.required(), + InputCircleToolSettingsSchema.required(), + + // ANNOTATION TOOLS + InputMarkerToolSettingsSchema.required(), + InputHighlighterToolSettingsSchema.required(), + InputTextToolSettingsSchema.required(), + InputNoteToolSettingsSchema.required(), +]); + +export type InputToolSettings = z.infer; +export type ToolSettings = z.infer; + +export type PinFrame = "frame-circle" | "frame-square"; + +export type PinSymbol = + | "dot" + | "square" + | "diamond" + | "triangle" + | "x" + | "plus" + | "circle-line" + | "circle-slash" + | "star" + | "heart" + | "hexagon" + | "octagon" + | "pedestrian" + | "bicycle" + | "wheelchair" + | "airport" + | "car" + | "bus" + | "train" + | "truck" + | "ferry" + | "sailboat" + | "electric-service" + | "gas-service" + | "blood-clinic" + | "badge" + | "traffic-light" + | "traffic-cone" + | "road-sign-caution" + | "person" + | "restroom" + | "house" + | "work" + | "letter" + | "hotel" + | "factory" + | "hospital" + | "religious-facility" + | "school" + | "government" + | "university" + | "bank" + | "landmark" + | "museum" + | "clothing" + | "shopping" + | "store" + | "bar" + | "pub" + | "cafe" + | "food" + | "park" + | "amusement-park" + | "camping-tent" + | "cabin" + | "picnic" + | "water-refill" + | "trailhead" + | "guidepost" + | "viewpoint" + | "camera" + | "us-football" + | "football" + | "tennis" + | "binoculars" + | "swimming" + | "zap" + | "battery-full" + | "battery-half" + | "battery-low" + | "boom" + | "radar" + | "wind-turbine" + | "solar-panel" + | "antenna" + | "telephone-pole" + | "oil-well" + | "oil-barrel" + | "railroad-track" + | "bridge" + | "lighthouse" + | "lock-closed" + | "lock-open" + | "wifi" + | "trash" + | "recycle" + | "tree" + | "flower" + | "leaf" + | "fire" + | "mountain" + | "snowy-mountain" + | "volcano" + | "island" + | "wave" + | "hot-springs" + | "water" + | "lake" + | "ocean" + | "animal" + | "bird" + | "duck" + | "dog" + | "fish" + | "beach" + | "wetland" + | "sun" + | "moon" + | "cloud" + | "partial-sun" + | "rain" + | "lightning" + | "snowflake" + | "wind" + | "snow" + | "fog" + | "sleet" + | "hurricane" + | "warning" + | "parking" + | "info" + | "circle-exclamation" + | "circle-triangle" + | "circle-x" + | "circle-plus" + | (`:${string}:` & {}); From 6426324f82ed2cb40b0a6b881b2a4d07bf662963 Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Wed, 29 Jan 2025 13:30:11 +0100 Subject: [PATCH 03/12] Update typedoc --- docs/Main/FeltController.md | 32 ++++++++++++++++---------------- docs/Tools/InputToolSettings.md | 2 +- docs/Tools/README.md | 6 ++---- docs/Tools/ToolSettings.md | 2 +- docs/Tools/ToolsController.md | 32 ++++++++++++++++---------------- src/modules/tools/types.ts | 3 +++ 6 files changed, 39 insertions(+), 38 deletions(-) diff --git a/docs/Main/FeltController.md b/docs/Main/FeltController.md index 6c834c2..fdd48ac 100644 --- a/docs/Main/FeltController.md +++ b/docs/Main/FeltController.md @@ -746,16 +746,16 @@ const tool = await felt.getTool(); // "marker", "polygon", etc. ### onToolChange() -> **onToolChange**(`args`: \{`handler`: (`tool`: `null` | `"note"` | `"pin"` | `"line"` | `"route"` | `"polygon"` | `"circle"` | `"marker"` | `"highlighter"` | `"text"` | `"link"`) => `void`; }): `VoidFunction` +> **onToolChange**(`args`: \{ `handler`: (`tool`: `null` | `"note"` | `"pin"` | `"line"` | `"route"` | `"polygon"` | `"circle"` | `"marker"` | `"highlighter"` | `"text"` | `"link"`) => `void`; }): `VoidFunction` Listens for changes to the current tool. #### Parameters -| Parameter | Type | Description | -| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | -| `args` | `object` | - | -| `args.handler` | (`tool`: `null` \| `"note"` \| `"pin"` \| `"line"` \| `"route"` \| `"polygon"` \| `"circle"` \| `"marker"` \| `"highlighter"` \| `"text"` \| `"link"`) => `void` | This callback is called with the current tool whenever the tool changes. | +| Parameter | Type | Description | +| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | +| `args` | \{ `handler`: (`tool`: `null` \| `"note"` \| `"pin"` \| `"line"` \| `"route"` \| `"polygon"` \| `"circle"` \| `"marker"` \| `"highlighter"` \| `"text"` \| `"link"`) => `void`; } | - | +| `args.handler` | (`tool`: `null` \| `"note"` \| `"pin"` \| `"line"` \| `"route"` \| `"polygon"` \| `"circle"` \| `"marker"` \| `"highlighter"` \| `"text"` \| `"link"`) => `void` | This callback is called with the current tool whenever the tool changes. | #### Returns @@ -778,15 +778,15 @@ unsubscribe(); ### setToolSettings() -> **setToolSettings**(`settings`: \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; } | \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; } | \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } | \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; } | \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; } | \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }): `void` +> **setToolSettings**(`settings`: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; } | \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; } | \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } | \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; } | \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; } | \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }): `void` Sets the settings for the current tool. #### Parameters -| Parameter | Type | Description | -| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------- | -| `settings` | \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` \| `string`; } \| \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`distanceMarker`: `boolean`; } \| \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } \| \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`areaMarker`: `boolean`; } \| \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`radiusMarker`: `boolean`; } \| \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } \| \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } \| \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` \| `"center"` \| `"right"`;`style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` \| `"center"` \| `"right"`;`style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } | The settings to set. | +| Parameter | Type | Description | +| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------- | +| `settings` | \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` \| `string`; } \| \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; } \| \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } \| \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `areaMarker`: `boolean`; } \| \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `radiusMarker`: `boolean`; } \| \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } | The settings to set. | #### Returns @@ -796,7 +796,7 @@ Sets the settings for the current tool. ### getToolSettings() -> **getToolSettings**\<`T`>(`tool`: `T`): `Promise`\<`Extract`\<\{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{`tool`: `T`; }>> +> **getToolSettings**\<`T`>(`tool`: `T`): `Promise`\<`Extract`\<\{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{ `tool`: `T`; }>> Gets the settings for the current tool. @@ -814,7 +814,7 @@ Gets the settings for the current tool. #### Returns -`Promise`\<`Extract`\<\{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{`tool`: `T`; }>> +`Promise`\<`Extract`\<\{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{ `tool`: `T`; }>> The settings for the current tool. @@ -822,16 +822,16 @@ The settings for the current tool. ### onToolSettingsChange() -> **onToolSettingsChange**(`args`: \{`handler`: (`settings`: \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; } | \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; } | \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } | \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; } | \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; } | \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }) => `void`; }): `VoidFunction` +> **onToolSettingsChange**(`args`: \{ `handler`: (`settings`: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; } | \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; } | \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } | \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; } | \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; } | \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }) => `void`; }): `VoidFunction` Listens for changes to the settings on all tools. #### Parameters -| Parameter | Type | -| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `args` | `object` | -| `args.handler` | (`settings`: \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` \| `string`; } \| \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`distanceMarker`: `boolean`; } \| \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } \| \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`areaMarker`: `boolean`; } \| \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`radiusMarker`: `boolean`; } \| \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } \| \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } \| \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` \| `"center"` \| `"right"`;`style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` \| `"center"` \| `"right"`;`style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; }) => `void` | +| Parameter | Type | +| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `args` | \{ `handler`: (`settings`: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` \| `string`; } \| \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; } \| \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } \| \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `areaMarker`: `boolean`; } \| \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `radiusMarker`: `boolean`; } \| \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; }) => `void`; } | +| `args.handler` | (`settings`: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` \| `string`; } \| \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; } \| \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } \| \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `areaMarker`: `boolean`; } \| \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `radiusMarker`: `boolean`; } \| \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; }) => `void` | #### Returns diff --git a/docs/Tools/InputToolSettings.md b/docs/Tools/InputToolSettings.md index d058b55..17fe53f 100644 --- a/docs/Tools/InputToolSettings.md +++ b/docs/Tools/InputToolSettings.md @@ -1,3 +1,3 @@ *** -> **InputToolSettings**: \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; } | \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; } | \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } | \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; } | \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; } | \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } +> **InputToolSettings**: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; } | \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; } | \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } | \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; } | \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; } | \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } diff --git a/docs/Tools/README.md b/docs/Tools/README.md index eaeae2c..1aa65d6 100644 --- a/docs/Tools/README.md +++ b/docs/Tools/README.md @@ -2,14 +2,12 @@ The Tools part allows you to let users draw elements on the map. -## Index - -### Type Aliases +## Type Aliases * [ToolType](ToolType.md) * [InputToolSettings](InputToolSettings.md) * [ToolSettings](ToolSettings.md) -### Controller +## Controller * [ToolsController](ToolsController.md) diff --git a/docs/Tools/ToolSettings.md b/docs/Tools/ToolSettings.md index 61d8a33..b84f7f3 100644 --- a/docs/Tools/ToolSettings.md +++ b/docs/Tools/ToolSettings.md @@ -1,3 +1,3 @@ *** -> **ToolSettings**: \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; } | \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; } | \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } | \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; } | \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; } | \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } +> **ToolSettings**: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; } | \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; } | \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } | \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; } | \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; } | \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } diff --git a/docs/Tools/ToolsController.md b/docs/Tools/ToolsController.md index c818c0d..517a3d5 100644 --- a/docs/Tools/ToolsController.md +++ b/docs/Tools/ToolsController.md @@ -58,16 +58,16 @@ const tool = await felt.getTool(); // "marker", "polygon", etc. ### onToolChange() -> **onToolChange**(`args`: \{`handler`: (`tool`: `null` | `"note"` | `"pin"` | `"line"` | `"route"` | `"polygon"` | `"circle"` | `"marker"` | `"highlighter"` | `"text"` | `"link"`) => `void`; }): `VoidFunction` +> **onToolChange**(`args`: \{ `handler`: (`tool`: `null` | `"note"` | `"pin"` | `"line"` | `"route"` | `"polygon"` | `"circle"` | `"marker"` | `"highlighter"` | `"text"` | `"link"`) => `void`; }): `VoidFunction` Listens for changes to the current tool. #### Parameters -| Parameter | Type | Description | -| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | -| `args` | `object` | - | -| `args.handler` | (`tool`: `null` \| `"note"` \| `"pin"` \| `"line"` \| `"route"` \| `"polygon"` \| `"circle"` \| `"marker"` \| `"highlighter"` \| `"text"` \| `"link"`) => `void` | This callback is called with the current tool whenever the tool changes. | +| Parameter | Type | Description | +| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ | +| `args` | \{ `handler`: (`tool`: `null` \| `"note"` \| `"pin"` \| `"line"` \| `"route"` \| `"polygon"` \| `"circle"` \| `"marker"` \| `"highlighter"` \| `"text"` \| `"link"`) => `void`; } | - | +| `args.handler` | (`tool`: `null` \| `"note"` \| `"pin"` \| `"line"` \| `"route"` \| `"polygon"` \| `"circle"` \| `"marker"` \| `"highlighter"` \| `"text"` \| `"link"`) => `void` | This callback is called with the current tool whenever the tool changes. | #### Returns @@ -90,15 +90,15 @@ unsubscribe(); ### setToolSettings() -> **setToolSettings**(`settings`: \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; } | \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; } | \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } | \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; } | \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; } | \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }): `void` +> **setToolSettings**(`settings`: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; } | \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; } | \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } | \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; } | \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; } | \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }): `void` Sets the settings for the current tool. #### Parameters -| Parameter | Type | Description | -| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------- | -| `settings` | \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` \| `string`; } \| \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`distanceMarker`: `boolean`; } \| \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } \| \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`areaMarker`: `boolean`; } \| \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`radiusMarker`: `boolean`; } \| \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } \| \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } \| \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` \| `"center"` \| `"right"`;`style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` \| `"center"` \| `"right"`;`style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } | The settings to set. | +| Parameter | Type | Description | +| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------- | +| `settings` | \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` \| `string`; } \| \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; } \| \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } \| \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `areaMarker`: `boolean`; } \| \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `radiusMarker`: `boolean`; } \| \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } | The settings to set. | #### Returns @@ -108,7 +108,7 @@ Sets the settings for the current tool. ### getToolSettings() -> **getToolSettings**\<`T`>(`tool`: `T`): `Promise`\<`Extract`\<\{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{`tool`: `T`; }>> +> **getToolSettings**\<`T`>(`tool`: `T`): `Promise`\<`Extract`\<\{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{ `tool`: `T`; }>> Gets the settings for the current tool. @@ -126,7 +126,7 @@ Gets the settings for the current tool. #### Returns -`Promise`\<`Extract`\<\{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{`tool`: `T`; }> | `Extract`\<\{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{`tool`: `T`; }>> +`Promise`\<`Extract`\<\{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{ `tool`: `T`; }>> The settings for the current tool. @@ -134,16 +134,16 @@ The settings for the current tool. ### onToolSettingsChange() -> **onToolSettingsChange**(`args`: \{`handler`: (`settings`: \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` | `string`; } | \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`; } | \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } | \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`areaMarker`: `boolean`; } | \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`;`radiusMarker`: `boolean`; } | \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } | \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` | `"center"` | `"right"`;`style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }) => `void`; }): `VoidFunction` +> **onToolSettingsChange**(`args`: \{ `handler`: (`settings`: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; } | \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; } | \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } | \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; } | \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; } | \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }) => `void`; }): `VoidFunction` Listens for changes to the settings on all tools. #### Parameters -| Parameter | Type | -| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `args` | `object` | -| `args.handler` | (`settings`: \{`tool`: `"pin"`;`color`: `string`;`symbol`: `string`;`frame`: `null` \| `string`; } \| \{`tool`: `"line"`;`color`: `string`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`distanceMarker`: `boolean`; } \| \{`tool`: `"route"`;`color`: `string`;`routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`distanceMarker`: `boolean`;`endCaps`: `boolean`; } \| \{`tool`: `"polygon"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`areaMarker`: `boolean`; } \| \{`tool`: `"circle"`;`color`: `string`;`fillOpacity`: `number`;`strokeOpacity`: `number`;`strokeWidth`: `number`;`strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`;`radiusMarker`: `boolean`; } \| \{`tool`: `"marker"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } \| \{`tool`: `"highlighter"`;`color`: `string`;`opacity`: `number`;`size`: `number`; } \| \{`tool`: `"text"`;`color`: `string`;`align`: `"left"` \| `"center"` \| `"right"`;`style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{`tool`: `"note"`;`color`: `string`;`align`: `"left"` \| `"center"` \| `"right"`;`style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; }) => `void` | +| Parameter | Type | +| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `args` | \{ `handler`: (`settings`: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` \| `string`; } \| \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; } \| \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } \| \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `areaMarker`: `boolean`; } \| \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `radiusMarker`: `boolean`; } \| \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; }) => `void`; } | +| `args.handler` | (`settings`: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` \| `string`; } \| \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; } \| \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } \| \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `areaMarker`: `boolean`; } \| \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `radiusMarker`: `boolean`; } \| \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; }) => `void` | #### Returns diff --git a/src/modules/tools/types.ts b/src/modules/tools/types.ts index 4538ad2..2d3b2b4 100644 --- a/src/modules/tools/types.ts +++ b/src/modules/tools/types.ts @@ -123,6 +123,9 @@ export const ToolSettingsSchema = z.discriminatedUnion("tool", [ InputNoteToolSettingsSchema.required(), ]); +/** + * @useDeclaredType + */ export type InputToolSettings = z.infer; export type ToolSettings = z.infer; From 8366eb2a41ea3be0c59ca617ac7adc56afbc6d09 Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Wed, 29 Jan 2025 13:56:25 +0100 Subject: [PATCH 04/12] Update documentation shape --- docs/Main/FeltController.md | 22 +-- docs/Tools/CircleToolSettings.md | 37 +++++ docs/Tools/HighlighterToolSettings.md | 19 +++ docs/Tools/InputToolSettings.md | 2 +- docs/Tools/LineToolSettings.md | 37 +++++ docs/Tools/MarkerToolSettings.md | 19 +++ docs/Tools/NoteToolSettings.md | 19 +++ docs/Tools/PinToolSettings.md | 19 +++ docs/Tools/PolygonToolSettings.md | 37 +++++ docs/Tools/README.md | 14 +- docs/Tools/RouteToolSettings.md | 43 ++++++ docs/Tools/TextToolSettings.md | 19 +++ docs/Tools/ToolSettings.md | 3 - docs/Tools/ToolSettingsMap.md | 41 ++++++ docs/Tools/ToolsController.md | 22 +-- etc/js-sdk.api.md | 112 ++++++++------- src/modules/tools/controller.ts | 6 +- src/modules/tools/index.ts | 15 +- src/modules/tools/schema.ts | 9 +- src/modules/tools/types.ts | 192 +++++++++++++++----------- 20 files changed, 512 insertions(+), 175 deletions(-) create mode 100644 docs/Tools/CircleToolSettings.md create mode 100644 docs/Tools/HighlighterToolSettings.md create mode 100644 docs/Tools/LineToolSettings.md create mode 100644 docs/Tools/MarkerToolSettings.md create mode 100644 docs/Tools/NoteToolSettings.md create mode 100644 docs/Tools/PinToolSettings.md create mode 100644 docs/Tools/PolygonToolSettings.md create mode 100644 docs/Tools/RouteToolSettings.md create mode 100644 docs/Tools/TextToolSettings.md delete mode 100644 docs/Tools/ToolSettings.md create mode 100644 docs/Tools/ToolSettingsMap.md diff --git a/docs/Main/FeltController.md b/docs/Main/FeltController.md index fdd48ac..648b8ae 100644 --- a/docs/Main/FeltController.md +++ b/docs/Main/FeltController.md @@ -778,15 +778,15 @@ unsubscribe(); ### setToolSettings() -> **setToolSettings**(`settings`: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; } | \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; } | \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } | \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; } | \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; } | \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }): `void` +> **setToolSettings**(`settings`: [`InputToolSettings`](../Tools/InputToolSettings.md)): `void` Sets the settings for the current tool. #### Parameters -| Parameter | Type | Description | -| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------- | -| `settings` | \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` \| `string`; } \| \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; } \| \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } \| \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `areaMarker`: `boolean`; } \| \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `radiusMarker`: `boolean`; } \| \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } | The settings to set. | +| Parameter | Type | Description | +| ---------- | ---------------------------------------------------- | -------------------- | +| `settings` | [`InputToolSettings`](../Tools/InputToolSettings.md) | The settings to set. | #### Returns @@ -796,7 +796,7 @@ Sets the settings for the current tool. ### getToolSettings() -> **getToolSettings**\<`T`>(`tool`: `T`): `Promise`\<`Extract`\<\{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{ `tool`: `T`; }>> +> **getToolSettings**\<`T`>(`tool`: `T`): `Promise`\<[`ToolSettingsMap`](../Tools/ToolSettingsMap.md)\[`T`]> Gets the settings for the current tool. @@ -814,7 +814,7 @@ Gets the settings for the current tool. #### Returns -`Promise`\<`Extract`\<\{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{ `tool`: `T`; }>> +`Promise`\<[`ToolSettingsMap`](../Tools/ToolSettingsMap.md)\[`T`]> The settings for the current tool. @@ -822,16 +822,16 @@ The settings for the current tool. ### onToolSettingsChange() -> **onToolSettingsChange**(`args`: \{ `handler`: (`settings`: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; } | \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; } | \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } | \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; } | \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; } | \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }) => `void`; }): `VoidFunction` +> **onToolSettingsChange**(`args`: \{ `handler`: (`settings`: [`NoteToolSettings`](../Tools/NoteToolSettings.md) | [`PinToolSettings`](../Tools/PinToolSettings.md) | [`LineToolSettings`](../Tools/LineToolSettings.md) | [`RouteToolSettings`](../Tools/RouteToolSettings.md) | [`PolygonToolSettings`](../Tools/PolygonToolSettings.md) | [`CircleToolSettings`](../Tools/CircleToolSettings.md) | [`MarkerToolSettings`](../Tools/MarkerToolSettings.md) | [`HighlighterToolSettings`](../Tools/HighlighterToolSettings.md) | [`TextToolSettings`](../Tools/TextToolSettings.md)) => `void`; }): `VoidFunction` Listens for changes to the settings on all tools. #### Parameters -| Parameter | Type | -| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `args` | \{ `handler`: (`settings`: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` \| `string`; } \| \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; } \| \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } \| \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `areaMarker`: `boolean`; } \| \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `radiusMarker`: `boolean`; } \| \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; }) => `void`; } | -| `args.handler` | (`settings`: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` \| `string`; } \| \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; } \| \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } \| \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `areaMarker`: `boolean`; } \| \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `radiusMarker`: `boolean`; } \| \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; }) => `void` | +| Parameter | Type | +| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `args` | \{ `handler`: (`settings`: [`NoteToolSettings`](../Tools/NoteToolSettings.md) \| [`PinToolSettings`](../Tools/PinToolSettings.md) \| [`LineToolSettings`](../Tools/LineToolSettings.md) \| [`RouteToolSettings`](../Tools/RouteToolSettings.md) \| [`PolygonToolSettings`](../Tools/PolygonToolSettings.md) \| [`CircleToolSettings`](../Tools/CircleToolSettings.md) \| [`MarkerToolSettings`](../Tools/MarkerToolSettings.md) \| [`HighlighterToolSettings`](../Tools/HighlighterToolSettings.md) \| [`TextToolSettings`](../Tools/TextToolSettings.md)) => `void`; } | +| `args.handler` | (`settings`: [`NoteToolSettings`](../Tools/NoteToolSettings.md) \| [`PinToolSettings`](../Tools/PinToolSettings.md) \| [`LineToolSettings`](../Tools/LineToolSettings.md) \| [`RouteToolSettings`](../Tools/RouteToolSettings.md) \| [`PolygonToolSettings`](../Tools/PolygonToolSettings.md) \| [`CircleToolSettings`](../Tools/CircleToolSettings.md) \| [`MarkerToolSettings`](../Tools/MarkerToolSettings.md) \| [`HighlighterToolSettings`](../Tools/HighlighterToolSettings.md) \| [`TextToolSettings`](../Tools/TextToolSettings.md)) => `void` | #### Returns diff --git a/docs/Tools/CircleToolSettings.md b/docs/Tools/CircleToolSettings.md new file mode 100644 index 0000000..724adf7 --- /dev/null +++ b/docs/Tools/CircleToolSettings.md @@ -0,0 +1,37 @@ +*** + +## Properties + +### color + +> **color**: `string` + +*** + +### fillOpacity + +> **fillOpacity**: `number` + +*** + +### strokeOpacity + +> **strokeOpacity**: `number` + +*** + +### strokeWidth + +> **strokeWidth**: `number` + +*** + +### strokeStyle + +> **strokeStyle**: `"solid"` | `"dashed"` | `"dotted"` + +*** + +### radiusMarker + +> **radiusMarker**: `boolean` diff --git a/docs/Tools/HighlighterToolSettings.md b/docs/Tools/HighlighterToolSettings.md new file mode 100644 index 0000000..bf04ea9 --- /dev/null +++ b/docs/Tools/HighlighterToolSettings.md @@ -0,0 +1,19 @@ +*** + +## Properties + +### color + +> **color**: `string` + +*** + +### opacity + +> **opacity**: `number` + +*** + +### size + +> **size**: `number` diff --git a/docs/Tools/InputToolSettings.md b/docs/Tools/InputToolSettings.md index 17fe53f..e0e4077 100644 --- a/docs/Tools/InputToolSettings.md +++ b/docs/Tools/InputToolSettings.md @@ -1,3 +1,3 @@ *** -> **InputToolSettings**: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; } | \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; } | \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } | \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; } | \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; } | \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } +> **InputToolSettings**: `Partial`\<[`PinToolSettings`](PinToolSettings.md)> & \{ `tool`: `"pin"`; } | `Partial`\<[`LineToolSettings`](LineToolSettings.md)> & \{ `tool`: `"line"`; } | `Partial`\<[`RouteToolSettings`](RouteToolSettings.md)> & \{ `tool`: `"route"`; } | `Partial`\<[`PolygonToolSettings`](PolygonToolSettings.md)> & \{ `tool`: `"polygon"`; } | `Partial`\<[`CircleToolSettings`](CircleToolSettings.md)> & \{ `tool`: `"circle"`; } | `Partial`\<[`MarkerToolSettings`](MarkerToolSettings.md)> & \{ `tool`: `"marker"`; } | `Partial`\<[`HighlighterToolSettings`](HighlighterToolSettings.md)> & \{ `tool`: `"highlighter"`; } | `Partial`\<[`TextToolSettings`](TextToolSettings.md)> & \{ `tool`: `"text"`; } | `Partial`\<[`NoteToolSettings`](NoteToolSettings.md)> & \{ `tool`: `"note"`; } diff --git a/docs/Tools/LineToolSettings.md b/docs/Tools/LineToolSettings.md new file mode 100644 index 0000000..838b5b0 --- /dev/null +++ b/docs/Tools/LineToolSettings.md @@ -0,0 +1,37 @@ +*** + +## Properties + +### tool + +> **tool**: `"line"` + +*** + +### color + +> **color**: `string` + +*** + +### strokeOpacity + +> **strokeOpacity**: `number` + +*** + +### strokeWidth + +> **strokeWidth**: `number` + +*** + +### strokeStyle + +> **strokeStyle**: `"solid"` | `"dashed"` | `"dotted"` + +*** + +### distanceMarker + +> **distanceMarker**: `boolean` diff --git a/docs/Tools/MarkerToolSettings.md b/docs/Tools/MarkerToolSettings.md new file mode 100644 index 0000000..bf04ea9 --- /dev/null +++ b/docs/Tools/MarkerToolSettings.md @@ -0,0 +1,19 @@ +*** + +## Properties + +### color + +> **color**: `string` + +*** + +### opacity + +> **opacity**: `number` + +*** + +### size + +> **size**: `number` diff --git a/docs/Tools/NoteToolSettings.md b/docs/Tools/NoteToolSettings.md new file mode 100644 index 0000000..7966b9f --- /dev/null +++ b/docs/Tools/NoteToolSettings.md @@ -0,0 +1,19 @@ +*** + +## Properties + +### color + +> **color**: `string` + +*** + +### align + +> **align**: `"left"` | `"center"` | `"right"` + +*** + +### style + +> **style**: `"italic"` | `"light"` | `"regular"` | `"caps"` diff --git a/docs/Tools/PinToolSettings.md b/docs/Tools/PinToolSettings.md new file mode 100644 index 0000000..2e95490 --- /dev/null +++ b/docs/Tools/PinToolSettings.md @@ -0,0 +1,19 @@ +*** + +## Properties + +### color + +> **color**: `string` + +*** + +### symbol + +> **symbol**: `string` + +*** + +### frame + +> **frame**: `null` | `string` diff --git a/docs/Tools/PolygonToolSettings.md b/docs/Tools/PolygonToolSettings.md new file mode 100644 index 0000000..2ab0612 --- /dev/null +++ b/docs/Tools/PolygonToolSettings.md @@ -0,0 +1,37 @@ +*** + +## Properties + +### color + +> **color**: `string` + +*** + +### fillOpacity + +> **fillOpacity**: `number` + +*** + +### strokeOpacity + +> **strokeOpacity**: `number` + +*** + +### strokeWidth + +> **strokeWidth**: `number` + +*** + +### strokeStyle + +> **strokeStyle**: `"solid"` | `"dashed"` | `"dotted"` + +*** + +### areaMarker + +> **areaMarker**: `boolean` diff --git a/docs/Tools/README.md b/docs/Tools/README.md index 1aa65d6..bdef22b 100644 --- a/docs/Tools/README.md +++ b/docs/Tools/README.md @@ -2,11 +2,23 @@ The Tools part allows you to let users draw elements on the map. +## Interfaces + +* [PinToolSettings](PinToolSettings.md) +* [LineToolSettings](LineToolSettings.md) +* [RouteToolSettings](RouteToolSettings.md) +* [PolygonToolSettings](PolygonToolSettings.md) +* [CircleToolSettings](CircleToolSettings.md) +* [MarkerToolSettings](MarkerToolSettings.md) +* [HighlighterToolSettings](HighlighterToolSettings.md) +* [TextToolSettings](TextToolSettings.md) +* [NoteToolSettings](NoteToolSettings.md) + ## Type Aliases * [ToolType](ToolType.md) * [InputToolSettings](InputToolSettings.md) -* [ToolSettings](ToolSettings.md) +* [ToolSettingsMap](ToolSettingsMap.md) ## Controller diff --git a/docs/Tools/RouteToolSettings.md b/docs/Tools/RouteToolSettings.md new file mode 100644 index 0000000..198d4c3 --- /dev/null +++ b/docs/Tools/RouteToolSettings.md @@ -0,0 +1,43 @@ +*** + +## Properties + +### color + +> **color**: `string` + +*** + +### routingMode + +> **routingMode**: `"driving"` | `"cycling"` | `"walking"` | `"flying"` + +*** + +### strokeOpacity + +> **strokeOpacity**: `number` + +*** + +### strokeWidth + +> **strokeWidth**: `number` + +*** + +### strokeStyle + +> **strokeStyle**: `"solid"` | `"dashed"` | `"dotted"` + +*** + +### distanceMarker + +> **distanceMarker**: `boolean` + +*** + +### endCaps + +> **endCaps**: `boolean` diff --git a/docs/Tools/TextToolSettings.md b/docs/Tools/TextToolSettings.md new file mode 100644 index 0000000..7966b9f --- /dev/null +++ b/docs/Tools/TextToolSettings.md @@ -0,0 +1,19 @@ +*** + +## Properties + +### color + +> **color**: `string` + +*** + +### align + +> **align**: `"left"` | `"center"` | `"right"` + +*** + +### style + +> **style**: `"italic"` | `"light"` | `"regular"` | `"caps"` diff --git a/docs/Tools/ToolSettings.md b/docs/Tools/ToolSettings.md deleted file mode 100644 index b84f7f3..0000000 --- a/docs/Tools/ToolSettings.md +++ /dev/null @@ -1,3 +0,0 @@ -*** - -> **ToolSettings**: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; } | \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; } | \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } | \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; } | \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; } | \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } diff --git a/docs/Tools/ToolSettingsMap.md b/docs/Tools/ToolSettingsMap.md new file mode 100644 index 0000000..6dd09b2 --- /dev/null +++ b/docs/Tools/ToolSettingsMap.md @@ -0,0 +1,41 @@ +*** + +> **ToolSettingsMap**: \{ `pin`: [`PinToolSettings`](PinToolSettings.md); `line`: [`LineToolSettings`](LineToolSettings.md); `route`: [`RouteToolSettings`](RouteToolSettings.md); `polygon`: [`PolygonToolSettings`](PolygonToolSettings.md); `circle`: [`CircleToolSettings`](CircleToolSettings.md); `marker`: [`MarkerToolSettings`](MarkerToolSettings.md); `highlighter`: [`HighlighterToolSettings`](HighlighterToolSettings.md); `text`: [`TextToolSettings`](TextToolSettings.md); `note`: [`NoteToolSettings`](NoteToolSettings.md); } + +## Type declaration + +### pin + +> **pin**: [`PinToolSettings`](PinToolSettings.md) + +### line + +> **line**: [`LineToolSettings`](LineToolSettings.md) + +### route + +> **route**: [`RouteToolSettings`](RouteToolSettings.md) + +### polygon + +> **polygon**: [`PolygonToolSettings`](PolygonToolSettings.md) + +### circle + +> **circle**: [`CircleToolSettings`](CircleToolSettings.md) + +### marker + +> **marker**: [`MarkerToolSettings`](MarkerToolSettings.md) + +### highlighter + +> **highlighter**: [`HighlighterToolSettings`](HighlighterToolSettings.md) + +### text + +> **text**: [`TextToolSettings`](TextToolSettings.md) + +### note + +> **note**: [`NoteToolSettings`](NoteToolSettings.md) diff --git a/docs/Tools/ToolsController.md b/docs/Tools/ToolsController.md index 517a3d5..198a1e5 100644 --- a/docs/Tools/ToolsController.md +++ b/docs/Tools/ToolsController.md @@ -90,15 +90,15 @@ unsubscribe(); ### setToolSettings() -> **setToolSettings**(`settings`: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; } | \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; } | \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } | \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; } | \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; } | \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }): `void` +> **setToolSettings**(`settings`: [`InputToolSettings`](InputToolSettings.md)): `void` Sets the settings for the current tool. #### Parameters -| Parameter | Type | Description | -| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------- | -| `settings` | \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` \| `string`; } \| \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; } \| \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } \| \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `areaMarker`: `boolean`; } \| \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `radiusMarker`: `boolean`; } \| \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } | The settings to set. | +| Parameter | Type | Description | +| ---------- | ------------------------------------------- | -------------------- | +| `settings` | [`InputToolSettings`](InputToolSettings.md) | The settings to set. | #### Returns @@ -108,7 +108,7 @@ Sets the settings for the current tool. ### getToolSettings() -> **getToolSettings**\<`T`>(`tool`: `T`): `Promise`\<`Extract`\<\{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{ `tool`: `T`; }>> +> **getToolSettings**\<`T`>(`tool`: `T`): `Promise`\<[`ToolSettingsMap`](ToolSettingsMap.md)\[`T`]> Gets the settings for the current tool. @@ -126,7 +126,7 @@ Gets the settings for the current tool. #### Returns -`Promise`\<`Extract`\<\{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{ `tool`: `T`; }> | `Extract`\<\{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }, \{ `tool`: `T`; }>> +`Promise`\<[`ToolSettingsMap`](ToolSettingsMap.md)\[`T`]> The settings for the current tool. @@ -134,16 +134,16 @@ The settings for the current tool. ### onToolSettingsChange() -> **onToolSettingsChange**(`args`: \{ `handler`: (`settings`: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` | `string`; } | \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; } | \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` | `"cycling"` | `"walking"` | `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } | \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `areaMarker`: `boolean`; } | \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` | `"dashed"` | `"dotted"`; `radiusMarker`: `boolean`; } | \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } | \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; } | \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` | `"center"` | `"right"`; `style`: `"italic"` | `"light"` | `"regular"` | `"caps"`; }) => `void`; }): `VoidFunction` +> **onToolSettingsChange**(`args`: \{ `handler`: (`settings`: [`NoteToolSettings`](NoteToolSettings.md) | [`PinToolSettings`](PinToolSettings.md) | [`LineToolSettings`](LineToolSettings.md) | [`RouteToolSettings`](RouteToolSettings.md) | [`PolygonToolSettings`](PolygonToolSettings.md) | [`CircleToolSettings`](CircleToolSettings.md) | [`MarkerToolSettings`](MarkerToolSettings.md) | [`HighlighterToolSettings`](HighlighterToolSettings.md) | [`TextToolSettings`](TextToolSettings.md)) => `void`; }): `VoidFunction` Listens for changes to the settings on all tools. #### Parameters -| Parameter | Type | -| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `args` | \{ `handler`: (`settings`: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` \| `string`; } \| \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; } \| \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } \| \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `areaMarker`: `boolean`; } \| \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `radiusMarker`: `boolean`; } \| \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; }) => `void`; } | -| `args.handler` | (`settings`: \{ `tool`: `"pin"`; `color`: `string`; `symbol`: `string`; `frame`: `null` \| `string`; } \| \{ `tool`: `"line"`; `color`: `string`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; } \| \{ `tool`: `"route"`; `color`: `string`; `routingMode`: `"driving"` \| `"cycling"` \| `"walking"` \| `"flying"`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `distanceMarker`: `boolean`; `endCaps`: `boolean`; } \| \{ `tool`: `"polygon"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `areaMarker`: `boolean`; } \| \{ `tool`: `"circle"`; `color`: `string`; `fillOpacity`: `number`; `strokeOpacity`: `number`; `strokeWidth`: `number`; `strokeStyle`: `"solid"` \| `"dashed"` \| `"dotted"`; `radiusMarker`: `boolean`; } \| \{ `tool`: `"marker"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"highlighter"`; `color`: `string`; `opacity`: `number`; `size`: `number`; } \| \{ `tool`: `"text"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; } \| \{ `tool`: `"note"`; `color`: `string`; `align`: `"left"` \| `"center"` \| `"right"`; `style`: `"italic"` \| `"light"` \| `"regular"` \| `"caps"`; }) => `void` | +| Parameter | Type | +| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `args` | \{ `handler`: (`settings`: [`NoteToolSettings`](NoteToolSettings.md) \| [`PinToolSettings`](PinToolSettings.md) \| [`LineToolSettings`](LineToolSettings.md) \| [`RouteToolSettings`](RouteToolSettings.md) \| [`PolygonToolSettings`](PolygonToolSettings.md) \| [`CircleToolSettings`](CircleToolSettings.md) \| [`MarkerToolSettings`](MarkerToolSettings.md) \| [`HighlighterToolSettings`](HighlighterToolSettings.md) \| [`TextToolSettings`](TextToolSettings.md)) => `void`; } | +| `args.handler` | (`settings`: [`NoteToolSettings`](NoteToolSettings.md) \| [`PinToolSettings`](PinToolSettings.md) \| [`LineToolSettings`](LineToolSettings.md) \| [`RouteToolSettings`](RouteToolSettings.md) \| [`PolygonToolSettings`](PolygonToolSettings.md) \| [`CircleToolSettings`](CircleToolSettings.md) \| [`MarkerToolSettings`](MarkerToolSettings.md) \| [`HighlighterToolSettings`](HighlighterToolSettings.md) \| [`TextToolSettings`](TextToolSettings.md)) => `void` | #### Returns diff --git a/etc/js-sdk.api.md b/etc/js-sdk.api.md index 51fcdc2..69c9c0f 100644 --- a/etc/js-sdk.api.md +++ b/etc/js-sdk.api.md @@ -4,59 +4,59 @@ ```ts -import { C } from './types-fQVWhD-M.js'; -import { E as Element_2 } from './types-fQVWhD-M.js'; -import { d as ElementChangeCallbackParams } from './types-fQVWhD-M.js'; -import { b as ElementGroup } from './types-fQVWhD-M.js'; -import { e as ElementGroupChangeCallbackParams } from './types-fQVWhD-M.js'; -import { D as ElementGroupNode } from './types-fQVWhD-M.js'; -import { H as ElementNode } from './types-fQVWhD-M.js'; -import { r as EntityNode } from './types-fQVWhD-M.js'; -import { q as Feature } from './types-fQVWhD-M.js'; -import { J as FeatureNode } from './types-fQVWhD-M.js'; -import { s as FeatureSelection } from './types-fQVWhD-M.js'; -import { O as FeltBoundary } from './types-fQVWhD-M.js'; -import { P as FeltZoom } from './types-fQVWhD-M.js'; -import { y as FilterExpression } from './types-fQVWhD-M.js'; -import { A as FilterLogicGate } from './types-fQVWhD-M.js'; -import { F as Filters } from './types-fQVWhD-M.js'; -import { B as FilterTernary } from './types-fQVWhD-M.js'; -import { G as Geometry } from './types-fQVWhD-M.js'; -import { c as GetElementGroupsConstraint } from './types-fQVWhD-M.js'; -import { a as GetElementsConstraint } from './types-fQVWhD-M.js'; -import { i as GetLayerGroupsConstraint } from './types-fQVWhD-M.js'; -import { f as GetLayersConstraint } from './types-fQVWhD-M.js'; -import { p as GetRenderedFeaturesConstraint } from './types-fQVWhD-M.js'; -import { I } from './types-fQVWhD-M.js'; -import { Q as LatLng } from './types-fQVWhD-M.js'; -import { L as Layer } from './types-fQVWhD-M.js'; -import { g as LayerChangeCallbackParams } from './types-fQVWhD-M.js'; -import { o as LayerFilters } from './types-fQVWhD-M.js'; -import { h as LayerGroup } from './types-fQVWhD-M.js'; -import { j as LayerGroupChangeCallbackParams } from './types-fQVWhD-M.js'; -import { K as LayerGroupNode } from './types-fQVWhD-M.js'; -import { N as LayerNode } from './types-fQVWhD-M.js'; -import { x as LayerProcessingStatus } from './types-fQVWhD-M.js'; -import { l as LegendItem } from './types-fQVWhD-M.js'; -import { n as LegendItemChangeCallbackParams } from './types-fQVWhD-M.js'; -import { k as LegendItemIdentifier } from './types-fQVWhD-M.js'; -import { m as LegendItemsConstraint } from './types-fQVWhD-M.js'; -import { U as LineStringGeometry } from './types-fQVWhD-M.js'; -import { W as LngLatTuple } from './types-fQVWhD-M.js'; -import { M as MapInteractionEvent } from './types-fQVWhD-M.js'; -import { X as MultiLineStringGeometry } from './types-fQVWhD-M.js'; -import { Y as MultiPolygonGeometry } from './types-fQVWhD-M.js'; -import { Z as PointGeometry } from './types-fQVWhD-M.js'; -import { _ as PolygonGeometry } from './types-fQVWhD-M.js'; -import { R as RasterValue } from './types-fQVWhD-M.js'; -import { u as SetViewportCenterZoomParams } from './types-fQVWhD-M.js'; -import { S as SetVisibilityRequest } from './types-fQVWhD-M.js'; -import { T } from './types-fQVWhD-M.js'; -import { t } from './types-fQVWhD-M.js'; -import { w as ViewportCenterZoom } from './types-fQVWhD-M.js'; -import { v as ViewportFitBoundsParams } from './types-fQVWhD-M.js'; -import { V as ViewportState } from './types-fQVWhD-M.js'; -import { z } from './types-fQVWhD-M.js'; +import { C } from './types-DS4upEnH.js'; +import { E as Element_2 } from './types-DS4upEnH.js'; +import { d as ElementChangeCallbackParams } from './types-DS4upEnH.js'; +import { b as ElementGroup } from './types-DS4upEnH.js'; +import { e as ElementGroupChangeCallbackParams } from './types-DS4upEnH.js'; +import { D as ElementGroupNode } from './types-DS4upEnH.js'; +import { H as ElementNode } from './types-DS4upEnH.js'; +import { r as EntityNode } from './types-DS4upEnH.js'; +import { q as Feature } from './types-DS4upEnH.js'; +import { J as FeatureNode } from './types-DS4upEnH.js'; +import { s as FeatureSelection } from './types-DS4upEnH.js'; +import { O as FeltBoundary } from './types-DS4upEnH.js'; +import { P as FeltZoom } from './types-DS4upEnH.js'; +import { y as FilterExpression } from './types-DS4upEnH.js'; +import { A as FilterLogicGate } from './types-DS4upEnH.js'; +import { F as Filters } from './types-DS4upEnH.js'; +import { B as FilterTernary } from './types-DS4upEnH.js'; +import { G as Geometry } from './types-DS4upEnH.js'; +import { c as GetElementGroupsConstraint } from './types-DS4upEnH.js'; +import { a as GetElementsConstraint } from './types-DS4upEnH.js'; +import { i as GetLayerGroupsConstraint } from './types-DS4upEnH.js'; +import { f as GetLayersConstraint } from './types-DS4upEnH.js'; +import { p as GetRenderedFeaturesConstraint } from './types-DS4upEnH.js'; +import { I } from './types-DS4upEnH.js'; +import { Q as LatLng } from './types-DS4upEnH.js'; +import { L as Layer } from './types-DS4upEnH.js'; +import { g as LayerChangeCallbackParams } from './types-DS4upEnH.js'; +import { o as LayerFilters } from './types-DS4upEnH.js'; +import { h as LayerGroup } from './types-DS4upEnH.js'; +import { j as LayerGroupChangeCallbackParams } from './types-DS4upEnH.js'; +import { K as LayerGroupNode } from './types-DS4upEnH.js'; +import { N as LayerNode } from './types-DS4upEnH.js'; +import { x as LayerProcessingStatus } from './types-DS4upEnH.js'; +import { l as LegendItem } from './types-DS4upEnH.js'; +import { n as LegendItemChangeCallbackParams } from './types-DS4upEnH.js'; +import { k as LegendItemIdentifier } from './types-DS4upEnH.js'; +import { m as LegendItemsConstraint } from './types-DS4upEnH.js'; +import { U as LineStringGeometry } from './types-DS4upEnH.js'; +import { W as LngLatTuple } from './types-DS4upEnH.js'; +import { M as MapInteractionEvent } from './types-DS4upEnH.js'; +import { X as MultiLineStringGeometry } from './types-DS4upEnH.js'; +import { Y as MultiPolygonGeometry } from './types-DS4upEnH.js'; +import { Z as PointGeometry } from './types-DS4upEnH.js'; +import { _ as PolygonGeometry } from './types-DS4upEnH.js'; +import { R as RasterValue } from './types-DS4upEnH.js'; +import { u as SetViewportCenterZoomParams } from './types-DS4upEnH.js'; +import { S as SetVisibilityRequest } from './types-DS4upEnH.js'; +import { T } from './types-DS4upEnH.js'; +import { t } from './types-DS4upEnH.js'; +import { w as ViewportCenterZoom } from './types-DS4upEnH.js'; +import { v as ViewportFitBoundsParams } from './types-DS4upEnH.js'; +import { V as ViewportState } from './types-DS4upEnH.js'; +import { z } from './types-DS4upEnH.js'; import { z as z_2 } from 'zod'; export { Element_2 as Element } @@ -373,14 +373,12 @@ export { SetVisibilityRequest } // @public interface ToolsController { getTool(): Promise; - getToolSettings(tool: T): Promise>; + getToolSettings(tool: T): Promise; onToolChange(args: { handler: (tool: T | null) => void; }): VoidFunction; onToolSettingsChange(args: { - handler: (settings: t) => void; + handler: (settings: t[keyof t]) => void; }): VoidFunction; setTool(tool: T | null): void; setToolSettings(settings: I): void; diff --git a/src/modules/tools/controller.ts b/src/modules/tools/controller.ts index 9cb011d..c39a251 100644 --- a/src/modules/tools/controller.ts +++ b/src/modules/tools/controller.ts @@ -2,7 +2,7 @@ import { listener, method } from "~/lib/interface"; import type { ConfigurableToolType, InputToolSettings, - ToolSettings, + ToolSettingsMap, ToolType, } from "./types"; @@ -92,7 +92,7 @@ export interface ToolsController { */ getToolSettings( tool: T, - ): Promise>; + ): Promise; /** * Listens for changes to the settings on all tools. @@ -100,6 +100,6 @@ export interface ToolsController { * @returns A function to unsubscribe from the listener */ onToolSettingsChange(args: { - handler: (settings: ToolSettings) => void; + handler: (settings: ToolSettingsMap[keyof ToolSettingsMap]) => void; }): VoidFunction; } diff --git a/src/modules/tools/index.ts b/src/modules/tools/index.ts index 3036de4..a880b1e 100644 --- a/src/modules/tools/index.ts +++ b/src/modules/tools/index.ts @@ -3,6 +3,19 @@ * * @module Tools */ -export type { InputToolSettings, ToolSettings, ToolType } from "./types"; +export type { + CircleToolSettings, + HighlighterToolSettings, + InputToolSettings, + LineToolSettings, + MarkerToolSettings, + NoteToolSettings, + PinToolSettings, + PolygonToolSettings, + RouteToolSettings, + TextToolSettings, + ToolSettingsMap, + ToolType, +} from "./types"; export type { ToolsController } from "./controller"; diff --git a/src/modules/tools/schema.ts b/src/modules/tools/schema.ts index 16372f6..5479e06 100644 --- a/src/modules/tools/schema.ts +++ b/src/modules/tools/schema.ts @@ -11,7 +11,7 @@ import { ConfigurableToolSchema, InputToolSettingsSchema, ToolSchema, - type ToolSettings, + type ToolSettingsMap, type ToolType, } from "./types"; @@ -48,11 +48,14 @@ export type ToolsSchema = { setToolSettings: Method, void>; getToolSettings: Method< zInfer, - ToolSettings | any + ToolSettingsMap[keyof ToolSettingsMap] | any >; }; listeners: { onToolChange: Listener; - onToolSettingsChange: Listener; + onToolSettingsChange: Listener< + void, + ToolSettingsMap[keyof ToolSettingsMap] + >; }; }; diff --git a/src/modules/tools/types.ts b/src/modules/tools/types.ts index 2d3b2b4..ef5516e 100644 --- a/src/modules/tools/types.ts +++ b/src/modules/tools/types.ts @@ -1,4 +1,5 @@ import { z } from "zod"; +import type { zInfer } from "~/lib/utils"; const configurableTools = [ "pin", @@ -18,116 +19,139 @@ export const ConfigurableToolSchema = z.enum(configurableTools); export type ToolType = z.infer; export type ConfigurableToolType = z.infer; -const InputPinToolSettingsSchema = z.object({ - tool: z.literal("pin"), - color: z.string().optional(), - symbol: z.string().optional(), - frame: z.string().nullable().optional(), +const PinToolSettingsSchema = z.object({ + color: z.string(), + symbol: z.string(), + frame: z.string().nullable(), }); +export interface PinToolSettings extends zInfer {} -const InputLineToolSettingsSchema = z.object({ +const LineToolSettingsSchema = z.object({ tool: z.literal("line"), - color: z.string().optional(), - strokeOpacity: z.number().optional(), - strokeWidth: z.number().optional(), - strokeStyle: z.enum(["solid", "dashed", "dotted"]).optional(), - distanceMarker: z.boolean().optional(), + color: z.string(), + strokeOpacity: z.number(), + strokeWidth: z.number(), + strokeStyle: z.enum(["solid", "dashed", "dotted"]), + distanceMarker: z.boolean(), }); - -const InputRouteToolSettingsSchema = z.object({ - tool: z.literal("route"), - color: z.string().optional(), - routingMode: z.enum(["driving", "cycling", "walking", "flying"]).optional(), - strokeOpacity: z.number().optional(), - strokeWidth: z.number().optional(), - strokeStyle: z.enum(["solid", "dashed", "dotted"]).optional(), - distanceMarker: z.boolean().optional(), - endCaps: z.boolean().optional(), +export interface LineToolSettings + extends zInfer {} +const RouteToolSettingsSchema = z.object({ + color: z.string(), + routingMode: z.enum(["driving", "cycling", "walking", "flying"]), + strokeOpacity: z.number(), + strokeWidth: z.number(), + strokeStyle: z.enum(["solid", "dashed", "dotted"]), + distanceMarker: z.boolean(), + endCaps: z.boolean(), }); +export interface RouteToolSettings + extends zInfer {} -const InputPolygonToolSettingsSchema = z.object({ - tool: z.literal("polygon"), - color: z.string().optional(), - fillOpacity: z.number().optional(), - strokeOpacity: z.number().optional(), - strokeWidth: z.number().optional(), - strokeStyle: z.enum(["solid", "dashed", "dotted"]).optional(), - areaMarker: z.boolean().optional(), +const PolygonToolSettingsSchema = z.object({ + color: z.string(), + fillOpacity: z.number(), + strokeOpacity: z.number(), + strokeWidth: z.number(), + strokeStyle: z.enum(["solid", "dashed", "dotted"]), + areaMarker: z.boolean(), }); - -const InputCircleToolSettingsSchema = z.object({ - tool: z.literal("circle"), - color: z.string().optional(), - fillOpacity: z.number().optional(), - strokeOpacity: z.number().optional(), - strokeWidth: z.number().optional(), - strokeStyle: z.enum(["solid", "dashed", "dotted"]).optional(), - radiusMarker: z.boolean().optional(), +export interface PolygonToolSettings + extends zInfer {} +const CircleToolSettingsSchema = z.object({ + color: z.string(), + fillOpacity: z.number(), + strokeOpacity: z.number(), + strokeWidth: z.number(), + strokeStyle: z.enum(["solid", "dashed", "dotted"]), + radiusMarker: z.boolean(), }); - -const InputMarkerToolSettingsSchema = z.object({ - tool: z.literal("marker"), - color: z.string().optional(), - opacity: z.number().optional(), - size: z.number().optional(), +export interface CircleToolSettings + extends zInfer {} +const MarkerToolSettingsSchema = z.object({ + color: z.string(), + opacity: z.number(), + size: z.number(), }); +export interface MarkerToolSettings + extends zInfer {} -const InputHighlighterToolSettingsSchema = z.object({ - tool: z.literal("highlighter"), - color: z.string().optional(), - opacity: z.number().optional(), - size: z.number().optional(), +const HighlighterToolSettingsSchema = z.object({ + color: z.string(), + opacity: z.number(), + size: z.number(), }); - -const InputTextToolSettingsSchema = z.object({ - tool: z.literal("text"), - color: z.string().optional(), - align: z.enum(["left", "center", "right"]).optional(), - style: z.enum(["italic", "light", "regular", "caps"]).optional(), +export interface HighlighterToolSettings + extends zInfer {} +const TextToolSettingsSchema = z.object({ + color: z.string(), + align: z.enum(["left", "center", "right"]), + style: z.enum(["italic", "light", "regular", "caps"]), }); - -const InputNoteToolSettingsSchema = z.object({ - tool: z.literal("note"), - color: z.string().optional(), - align: z.enum(["left", "center", "right"]).optional(), - style: z.enum(["italic", "light", "regular", "caps"]).optional(), +export interface TextToolSettings + extends zInfer {} +const NoteToolSettingsSchema = z.object({ + color: z.string(), + align: z.enum(["left", "center", "right"]), + style: z.enum(["italic", "light", "regular", "caps"]), }); +export interface NoteToolSettings + extends zInfer {} export const InputToolSettingsSchema = z.discriminatedUnion("tool", [ // GEOGRAPHIC TOOLS - InputPinToolSettingsSchema, - InputLineToolSettingsSchema, - InputRouteToolSettingsSchema, - InputPolygonToolSettingsSchema, - InputCircleToolSettingsSchema, + PinToolSettingsSchema.partial().extend({ tool: z.literal("pin") }), + LineToolSettingsSchema.partial().extend({ tool: z.literal("line") }), + RouteToolSettingsSchema.partial().extend({ tool: z.literal("route") }), + PolygonToolSettingsSchema.partial().extend({ tool: z.literal("polygon") }), + CircleToolSettingsSchema.partial().extend({ tool: z.literal("circle") }), // ANNOTATION TOOLS - InputMarkerToolSettingsSchema, - InputHighlighterToolSettingsSchema, - InputTextToolSettingsSchema, - InputNoteToolSettingsSchema, + MarkerToolSettingsSchema.partial().extend({ tool: z.literal("marker") }), + HighlighterToolSettingsSchema.partial().extend({ + tool: z.literal("highlighter"), + }), + TextToolSettingsSchema.partial().extend({ tool: z.literal("text") }), + NoteToolSettingsSchema.partial().extend({ tool: z.literal("note") }), ]); export const ToolSettingsSchema = z.discriminatedUnion("tool", [ // GEOGRAPHIC TOOLS - InputPinToolSettingsSchema.required(), - InputLineToolSettingsSchema.required(), - InputRouteToolSettingsSchema.required(), - InputPolygonToolSettingsSchema.required(), - InputCircleToolSettingsSchema.required(), + PinToolSettingsSchema.extend({ tool: z.literal("pin") }), + LineToolSettingsSchema.extend({ tool: z.literal("line") }), + RouteToolSettingsSchema.extend({ tool: z.literal("route") }), + PolygonToolSettingsSchema.extend({ tool: z.literal("polygon") }), + CircleToolSettingsSchema.extend({ tool: z.literal("circle") }), // ANNOTATION TOOLS - InputMarkerToolSettingsSchema.required(), - InputHighlighterToolSettingsSchema.required(), - InputTextToolSettingsSchema.required(), - InputNoteToolSettingsSchema.required(), + MarkerToolSettingsSchema.extend({ tool: z.literal("marker") }), + HighlighterToolSettingsSchema.extend({ tool: z.literal("highlighter") }), + TextToolSettingsSchema.extend({ tool: z.literal("text") }), + NoteToolSettingsSchema.extend({ tool: z.literal("note") }), ]); -/** - * @useDeclaredType - */ -export type InputToolSettings = z.infer; -export type ToolSettings = z.infer; +export type InputToolSettings = + | (Partial & { tool: "pin" }) + | (Partial & { tool: "line" }) + | (Partial & { tool: "route" }) + | (Partial & { tool: "polygon" }) + | (Partial & { tool: "circle" }) + | (Partial & { tool: "marker" }) + | (Partial & { tool: "highlighter" }) + | (Partial & { tool: "text" }) + | (Partial & { tool: "note" }); + +export type ToolSettingsMap = { + pin: PinToolSettings; + line: LineToolSettings; + route: RouteToolSettings; + polygon: PolygonToolSettings; + circle: CircleToolSettings; + marker: MarkerToolSettings; + highlighter: HighlighterToolSettings; + text: TextToolSettings; + note: NoteToolSettings; +}; export type PinFrame = "frame-circle" | "frame-square"; From 041054a4019829dda5fb70a1931dccc49890dc70 Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Wed, 29 Jan 2025 14:03:54 +0100 Subject: [PATCH 05/12] Reduce type duplication --- src/modules/tools/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/tools/types.ts b/src/modules/tools/types.ts index ef5516e..1f62255 100644 --- a/src/modules/tools/types.ts +++ b/src/modules/tools/types.ts @@ -11,13 +11,13 @@ const configurableTools = [ "highlighter", "text", "note", -] as const; +] as const satisfies Array; export const ToolSchema = z.enum([...configurableTools, "link"]); export const ConfigurableToolSchema = z.enum(configurableTools); export type ToolType = z.infer; -export type ConfigurableToolType = z.infer; +export type ConfigurableToolType = keyof ToolSettingsMap; const PinToolSettingsSchema = z.object({ color: z.string(), From 15b0a59072414cef2ecb5e187c8baa0d615a3b07 Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Wed, 29 Jan 2025 14:18:36 +0100 Subject: [PATCH 06/12] Update Input type for tool settings --- docs/Main/FeltController.md | 6 +- docs/Tools/ConfigurableToolType.md | 3 + docs/Tools/InputToolSettings.md | 2 +- docs/Tools/PinFrame.md | 3 + docs/Tools/PinSymbol.md | 3 + docs/Tools/PinToolSettings.md | 4 +- docs/Tools/README.md | 3 + docs/Tools/ToolsController.md | 6 +- etc/js-sdk.api.md | 106 ++++++++++++++--------------- src/modules/tools/index.ts | 3 + src/modules/tools/types.ts | 33 ++------- 11 files changed, 84 insertions(+), 88 deletions(-) create mode 100644 docs/Tools/ConfigurableToolType.md create mode 100644 docs/Tools/PinFrame.md create mode 100644 docs/Tools/PinSymbol.md diff --git a/docs/Main/FeltController.md b/docs/Main/FeltController.md index 648b8ae..c3d2093 100644 --- a/docs/Main/FeltController.md +++ b/docs/Main/FeltController.md @@ -802,9 +802,9 @@ Gets the settings for the current tool. #### Type Parameters -| Type Parameter | -| ------------------------------------------------------------------------------------------------------------------------------------ | -| `T` *extends* `"note"` \| `"pin"` \| `"line"` \| `"route"` \| `"polygon"` \| `"circle"` \| `"marker"` \| `"highlighter"` \| `"text"` | +| Type Parameter | +| -------------------------------------------------------------------- | +| `T` *extends* keyof [`ToolSettingsMap`](../Tools/ToolSettingsMap.md) | #### Parameters diff --git a/docs/Tools/ConfigurableToolType.md b/docs/Tools/ConfigurableToolType.md new file mode 100644 index 0000000..9a75a72 --- /dev/null +++ b/docs/Tools/ConfigurableToolType.md @@ -0,0 +1,3 @@ +*** + +> **ConfigurableToolType**: keyof [`ToolSettingsMap`](ToolSettingsMap.md) diff --git a/docs/Tools/InputToolSettings.md b/docs/Tools/InputToolSettings.md index e0e4077..8c8f4e6 100644 --- a/docs/Tools/InputToolSettings.md +++ b/docs/Tools/InputToolSettings.md @@ -1,3 +1,3 @@ *** -> **InputToolSettings**: `Partial`\<[`PinToolSettings`](PinToolSettings.md)> & \{ `tool`: `"pin"`; } | `Partial`\<[`LineToolSettings`](LineToolSettings.md)> & \{ `tool`: `"line"`; } | `Partial`\<[`RouteToolSettings`](RouteToolSettings.md)> & \{ `tool`: `"route"`; } | `Partial`\<[`PolygonToolSettings`](PolygonToolSettings.md)> & \{ `tool`: `"polygon"`; } | `Partial`\<[`CircleToolSettings`](CircleToolSettings.md)> & \{ `tool`: `"circle"`; } | `Partial`\<[`MarkerToolSettings`](MarkerToolSettings.md)> & \{ `tool`: `"marker"`; } | `Partial`\<[`HighlighterToolSettings`](HighlighterToolSettings.md)> & \{ `tool`: `"highlighter"`; } | `Partial`\<[`TextToolSettings`](TextToolSettings.md)> & \{ `tool`: `"text"`; } | `Partial`\<[`NoteToolSettings`](NoteToolSettings.md)> & \{ `tool`: `"note"`; } +> **InputToolSettings**: `{ [K in ConfigurableToolType]: Partial & { tool: K } }`\[[`ConfigurableToolType`](ConfigurableToolType.md)] diff --git a/docs/Tools/PinFrame.md b/docs/Tools/PinFrame.md new file mode 100644 index 0000000..50000eb --- /dev/null +++ b/docs/Tools/PinFrame.md @@ -0,0 +1,3 @@ +*** + +> **PinFrame**: `"frame-circle"` | `"frame-square"` diff --git a/docs/Tools/PinSymbol.md b/docs/Tools/PinSymbol.md new file mode 100644 index 0000000..d7a7a59 --- /dev/null +++ b/docs/Tools/PinSymbol.md @@ -0,0 +1,3 @@ +*** + +> **PinSymbol**: `"dot"` | `"square"` | `"diamond"` | `"triangle"` | `"x"` | `"plus"` | `"circle-line"` | `"circle-slash"` | `"star"` | `"heart"` | `"hexagon"` | `"octagon"` | `"pedestrian"` | `"bicycle"` | `"wheelchair"` | `"airport"` | `"car"` | `"bus"` | `"train"` | `"truck"` | `"ferry"` | `"sailboat"` | `"electric-service"` | `"gas-service"` | `"blood-clinic"` | `"badge"` | `"traffic-light"` | `"traffic-cone"` | `"road-sign-caution"` | `"person"` | `"restroom"` | `"house"` | `"work"` | `"letter"` | `"hotel"` | `"factory"` | `"hospital"` | `"religious-facility"` | `"school"` | `"government"` | `"university"` | `"bank"` | `"landmark"` | `"museum"` | `"clothing"` | `"shopping"` | `"store"` | `"bar"` | `"pub"` | `"cafe"` | `"food"` | `"park"` | `"amusement-park"` | `"camping-tent"` | `"cabin"` | `"picnic"` | `"water-refill"` | `"trailhead"` | `"guidepost"` | `"viewpoint"` | `"camera"` | `"us-football"` | `"football"` | `"tennis"` | `"binoculars"` | `"swimming"` | `"zap"` | `"battery-full"` | `"battery-half"` | `"battery-low"` | `"boom"` | `"radar"` | `"wind-turbine"` | `"solar-panel"` | `"antenna"` | `"telephone-pole"` | `"oil-well"` | `"oil-barrel"` | `"railroad-track"` | `"bridge"` | `"lighthouse"` | `"lock-closed"` | `"lock-open"` | `"wifi"` | `"trash"` | `"recycle"` | `"tree"` | `"flower"` | `"leaf"` | `"fire"` | `"mountain"` | `"snowy-mountain"` | `"volcano"` | `"island"` | `"wave"` | `"hot-springs"` | `"water"` | `"lake"` | `"ocean"` | `"animal"` | `"bird"` | `"duck"` | `"dog"` | `"fish"` | `"beach"` | `"wetland"` | `"sun"` | `"moon"` | `"cloud"` | `"partial-sun"` | `"rain"` | `"lightning"` | `"snowflake"` | `"wind"` | `"snow"` | `"fog"` | `"sleet"` | `"hurricane"` | `"warning"` | `"parking"` | `"info"` | `"circle-exclamation"` | `"circle-triangle"` | `"circle-x"` | `"circle-plus"` | `` `:${string}:` `` & \{} diff --git a/docs/Tools/PinToolSettings.md b/docs/Tools/PinToolSettings.md index 2e95490..5893f76 100644 --- a/docs/Tools/PinToolSettings.md +++ b/docs/Tools/PinToolSettings.md @@ -10,10 +10,10 @@ ### symbol -> **symbol**: `string` +> **symbol**: [`PinSymbol`](PinSymbol.md) *** ### frame -> **frame**: `null` | `string` +> **frame**: [`PinFrame`](PinFrame.md) diff --git a/docs/Tools/README.md b/docs/Tools/README.md index bdef22b..0807ed1 100644 --- a/docs/Tools/README.md +++ b/docs/Tools/README.md @@ -17,8 +17,11 @@ The Tools part allows you to let users draw elements on the map. ## Type Aliases * [ToolType](ToolType.md) +* [ConfigurableToolType](ConfigurableToolType.md) * [InputToolSettings](InputToolSettings.md) * [ToolSettingsMap](ToolSettingsMap.md) +* [PinFrame](PinFrame.md) +* [PinSymbol](PinSymbol.md) ## Controller diff --git a/docs/Tools/ToolsController.md b/docs/Tools/ToolsController.md index 198a1e5..d90b156 100644 --- a/docs/Tools/ToolsController.md +++ b/docs/Tools/ToolsController.md @@ -114,9 +114,9 @@ Gets the settings for the current tool. #### Type Parameters -| Type Parameter | -| ------------------------------------------------------------------------------------------------------------------------------------ | -| `T` *extends* `"note"` \| `"pin"` \| `"line"` \| `"route"` \| `"polygon"` \| `"circle"` \| `"marker"` \| `"highlighter"` \| `"text"` | +| Type Parameter | +| ----------------------------------------------------------- | +| `T` *extends* keyof [`ToolSettingsMap`](ToolSettingsMap.md) | #### Parameters diff --git a/etc/js-sdk.api.md b/etc/js-sdk.api.md index 69c9c0f..b2da5cd 100644 --- a/etc/js-sdk.api.md +++ b/etc/js-sdk.api.md @@ -4,59 +4,59 @@ ```ts -import { C } from './types-DS4upEnH.js'; -import { E as Element_2 } from './types-DS4upEnH.js'; -import { d as ElementChangeCallbackParams } from './types-DS4upEnH.js'; -import { b as ElementGroup } from './types-DS4upEnH.js'; -import { e as ElementGroupChangeCallbackParams } from './types-DS4upEnH.js'; -import { D as ElementGroupNode } from './types-DS4upEnH.js'; -import { H as ElementNode } from './types-DS4upEnH.js'; -import { r as EntityNode } from './types-DS4upEnH.js'; -import { q as Feature } from './types-DS4upEnH.js'; -import { J as FeatureNode } from './types-DS4upEnH.js'; -import { s as FeatureSelection } from './types-DS4upEnH.js'; -import { O as FeltBoundary } from './types-DS4upEnH.js'; -import { P as FeltZoom } from './types-DS4upEnH.js'; -import { y as FilterExpression } from './types-DS4upEnH.js'; -import { A as FilterLogicGate } from './types-DS4upEnH.js'; -import { F as Filters } from './types-DS4upEnH.js'; -import { B as FilterTernary } from './types-DS4upEnH.js'; -import { G as Geometry } from './types-DS4upEnH.js'; -import { c as GetElementGroupsConstraint } from './types-DS4upEnH.js'; -import { a as GetElementsConstraint } from './types-DS4upEnH.js'; -import { i as GetLayerGroupsConstraint } from './types-DS4upEnH.js'; -import { f as GetLayersConstraint } from './types-DS4upEnH.js'; -import { p as GetRenderedFeaturesConstraint } from './types-DS4upEnH.js'; -import { I } from './types-DS4upEnH.js'; -import { Q as LatLng } from './types-DS4upEnH.js'; -import { L as Layer } from './types-DS4upEnH.js'; -import { g as LayerChangeCallbackParams } from './types-DS4upEnH.js'; -import { o as LayerFilters } from './types-DS4upEnH.js'; -import { h as LayerGroup } from './types-DS4upEnH.js'; -import { j as LayerGroupChangeCallbackParams } from './types-DS4upEnH.js'; -import { K as LayerGroupNode } from './types-DS4upEnH.js'; -import { N as LayerNode } from './types-DS4upEnH.js'; -import { x as LayerProcessingStatus } from './types-DS4upEnH.js'; -import { l as LegendItem } from './types-DS4upEnH.js'; -import { n as LegendItemChangeCallbackParams } from './types-DS4upEnH.js'; -import { k as LegendItemIdentifier } from './types-DS4upEnH.js'; -import { m as LegendItemsConstraint } from './types-DS4upEnH.js'; -import { U as LineStringGeometry } from './types-DS4upEnH.js'; -import { W as LngLatTuple } from './types-DS4upEnH.js'; -import { M as MapInteractionEvent } from './types-DS4upEnH.js'; -import { X as MultiLineStringGeometry } from './types-DS4upEnH.js'; -import { Y as MultiPolygonGeometry } from './types-DS4upEnH.js'; -import { Z as PointGeometry } from './types-DS4upEnH.js'; -import { _ as PolygonGeometry } from './types-DS4upEnH.js'; -import { R as RasterValue } from './types-DS4upEnH.js'; -import { u as SetViewportCenterZoomParams } from './types-DS4upEnH.js'; -import { S as SetVisibilityRequest } from './types-DS4upEnH.js'; -import { T } from './types-DS4upEnH.js'; -import { t } from './types-DS4upEnH.js'; -import { w as ViewportCenterZoom } from './types-DS4upEnH.js'; -import { v as ViewportFitBoundsParams } from './types-DS4upEnH.js'; -import { V as ViewportState } from './types-DS4upEnH.js'; -import { z } from './types-DS4upEnH.js'; +import { C } from './types-F17OM3Wt.js'; +import { E as Element_2 } from './types-F17OM3Wt.js'; +import { d as ElementChangeCallbackParams } from './types-F17OM3Wt.js'; +import { b as ElementGroup } from './types-F17OM3Wt.js'; +import { e as ElementGroupChangeCallbackParams } from './types-F17OM3Wt.js'; +import { D as ElementGroupNode } from './types-F17OM3Wt.js'; +import { H as ElementNode } from './types-F17OM3Wt.js'; +import { r as EntityNode } from './types-F17OM3Wt.js'; +import { q as Feature } from './types-F17OM3Wt.js'; +import { J as FeatureNode } from './types-F17OM3Wt.js'; +import { s as FeatureSelection } from './types-F17OM3Wt.js'; +import { O as FeltBoundary } from './types-F17OM3Wt.js'; +import { P as FeltZoom } from './types-F17OM3Wt.js'; +import { y as FilterExpression } from './types-F17OM3Wt.js'; +import { A as FilterLogicGate } from './types-F17OM3Wt.js'; +import { F as Filters } from './types-F17OM3Wt.js'; +import { B as FilterTernary } from './types-F17OM3Wt.js'; +import { G as Geometry } from './types-F17OM3Wt.js'; +import { c as GetElementGroupsConstraint } from './types-F17OM3Wt.js'; +import { a as GetElementsConstraint } from './types-F17OM3Wt.js'; +import { i as GetLayerGroupsConstraint } from './types-F17OM3Wt.js'; +import { f as GetLayersConstraint } from './types-F17OM3Wt.js'; +import { p as GetRenderedFeaturesConstraint } from './types-F17OM3Wt.js'; +import { I } from './types-F17OM3Wt.js'; +import { Q as LatLng } from './types-F17OM3Wt.js'; +import { L as Layer } from './types-F17OM3Wt.js'; +import { g as LayerChangeCallbackParams } from './types-F17OM3Wt.js'; +import { o as LayerFilters } from './types-F17OM3Wt.js'; +import { h as LayerGroup } from './types-F17OM3Wt.js'; +import { j as LayerGroupChangeCallbackParams } from './types-F17OM3Wt.js'; +import { K as LayerGroupNode } from './types-F17OM3Wt.js'; +import { N as LayerNode } from './types-F17OM3Wt.js'; +import { x as LayerProcessingStatus } from './types-F17OM3Wt.js'; +import { l as LegendItem } from './types-F17OM3Wt.js'; +import { n as LegendItemChangeCallbackParams } from './types-F17OM3Wt.js'; +import { k as LegendItemIdentifier } from './types-F17OM3Wt.js'; +import { m as LegendItemsConstraint } from './types-F17OM3Wt.js'; +import { U as LineStringGeometry } from './types-F17OM3Wt.js'; +import { W as LngLatTuple } from './types-F17OM3Wt.js'; +import { M as MapInteractionEvent } from './types-F17OM3Wt.js'; +import { X as MultiLineStringGeometry } from './types-F17OM3Wt.js'; +import { Y as MultiPolygonGeometry } from './types-F17OM3Wt.js'; +import { Z as PointGeometry } from './types-F17OM3Wt.js'; +import { _ as PolygonGeometry } from './types-F17OM3Wt.js'; +import { R as RasterValue } from './types-F17OM3Wt.js'; +import { u as SetViewportCenterZoomParams } from './types-F17OM3Wt.js'; +import { S as SetVisibilityRequest } from './types-F17OM3Wt.js'; +import { T } from './types-F17OM3Wt.js'; +import { t } from './types-F17OM3Wt.js'; +import { w as ViewportCenterZoom } from './types-F17OM3Wt.js'; +import { v as ViewportFitBoundsParams } from './types-F17OM3Wt.js'; +import { V as ViewportState } from './types-F17OM3Wt.js'; +import { z } from './types-F17OM3Wt.js'; import { z as z_2 } from 'zod'; export { Element_2 as Element } diff --git a/src/modules/tools/index.ts b/src/modules/tools/index.ts index a880b1e..45ed60b 100644 --- a/src/modules/tools/index.ts +++ b/src/modules/tools/index.ts @@ -5,11 +5,14 @@ */ export type { CircleToolSettings, + ConfigurableToolType, HighlighterToolSettings, InputToolSettings, LineToolSettings, MarkerToolSettings, NoteToolSettings, + PinFrame, + PinSymbol, PinToolSettings, PolygonToolSettings, RouteToolSettings, diff --git a/src/modules/tools/types.ts b/src/modules/tools/types.ts index 1f62255..434ed63 100644 --- a/src/modules/tools/types.ts +++ b/src/modules/tools/types.ts @@ -24,7 +24,10 @@ const PinToolSettingsSchema = z.object({ symbol: z.string(), frame: z.string().nullable(), }); -export interface PinToolSettings extends zInfer {} +export interface PinToolSettings extends zInfer { + symbol: PinSymbol; + frame: PinFrame; +} const LineToolSettingsSchema = z.object({ tool: z.literal("line"), @@ -115,31 +118,9 @@ export const InputToolSettingsSchema = z.discriminatedUnion("tool", [ NoteToolSettingsSchema.partial().extend({ tool: z.literal("note") }), ]); -export const ToolSettingsSchema = z.discriminatedUnion("tool", [ - // GEOGRAPHIC TOOLS - PinToolSettingsSchema.extend({ tool: z.literal("pin") }), - LineToolSettingsSchema.extend({ tool: z.literal("line") }), - RouteToolSettingsSchema.extend({ tool: z.literal("route") }), - PolygonToolSettingsSchema.extend({ tool: z.literal("polygon") }), - CircleToolSettingsSchema.extend({ tool: z.literal("circle") }), - - // ANNOTATION TOOLS - MarkerToolSettingsSchema.extend({ tool: z.literal("marker") }), - HighlighterToolSettingsSchema.extend({ tool: z.literal("highlighter") }), - TextToolSettingsSchema.extend({ tool: z.literal("text") }), - NoteToolSettingsSchema.extend({ tool: z.literal("note") }), -]); - -export type InputToolSettings = - | (Partial & { tool: "pin" }) - | (Partial & { tool: "line" }) - | (Partial & { tool: "route" }) - | (Partial & { tool: "polygon" }) - | (Partial & { tool: "circle" }) - | (Partial & { tool: "marker" }) - | (Partial & { tool: "highlighter" }) - | (Partial & { tool: "text" }) - | (Partial & { tool: "note" }); +export type InputToolSettings = { + [K in ConfigurableToolType]: Partial & { tool: K }; +}[ConfigurableToolType]; export type ToolSettingsMap = { pin: PinToolSettings; From e559ac0ea623ce4581ec9b763b05446f2fd49ffb Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Wed, 29 Jan 2025 20:19:17 +0100 Subject: [PATCH 07/12] Refine types and docs further --- docs/Main/FeltController.md | 10 +++--- docs/Tools/LineToolSettings.md | 6 ---- docs/Tools/PinFrame.md | 2 +- docs/Tools/PinToolSettings.md | 8 ++--- docs/Tools/README.md | 1 + docs/Tools/ToolSettingsChangeEvent.md | 3 ++ docs/Tools/ToolsController.md | 10 +++--- src/client.ts | 1 + src/lib/interface.ts | 46 +++++++++++++++++++-------- src/modules/tools/controller.ts | 8 +++-- src/modules/tools/index.ts | 1 + src/modules/tools/schema.ts | 8 ++--- src/modules/tools/types.ts | 30 +++++++++-------- 13 files changed, 79 insertions(+), 55 deletions(-) create mode 100644 docs/Tools/ToolSettingsChangeEvent.md diff --git a/docs/Main/FeltController.md b/docs/Main/FeltController.md index c3d2093..1fce176 100644 --- a/docs/Main/FeltController.md +++ b/docs/Main/FeltController.md @@ -822,16 +822,16 @@ The settings for the current tool. ### onToolSettingsChange() -> **onToolSettingsChange**(`args`: \{ `handler`: (`settings`: [`NoteToolSettings`](../Tools/NoteToolSettings.md) | [`PinToolSettings`](../Tools/PinToolSettings.md) | [`LineToolSettings`](../Tools/LineToolSettings.md) | [`RouteToolSettings`](../Tools/RouteToolSettings.md) | [`PolygonToolSettings`](../Tools/PolygonToolSettings.md) | [`CircleToolSettings`](../Tools/CircleToolSettings.md) | [`MarkerToolSettings`](../Tools/MarkerToolSettings.md) | [`HighlighterToolSettings`](../Tools/HighlighterToolSettings.md) | [`TextToolSettings`](../Tools/TextToolSettings.md)) => `void`; }): `VoidFunction` +> **onToolSettingsChange**(`args`: \{ `handler`: (`settings`: [`ToolSettingsChangeEvent`](../Tools/ToolSettingsChangeEvent.md)) => `void`; }): `VoidFunction` Listens for changes to the settings on all tools. #### Parameters -| Parameter | Type | -| -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `args` | \{ `handler`: (`settings`: [`NoteToolSettings`](../Tools/NoteToolSettings.md) \| [`PinToolSettings`](../Tools/PinToolSettings.md) \| [`LineToolSettings`](../Tools/LineToolSettings.md) \| [`RouteToolSettings`](../Tools/RouteToolSettings.md) \| [`PolygonToolSettings`](../Tools/PolygonToolSettings.md) \| [`CircleToolSettings`](../Tools/CircleToolSettings.md) \| [`MarkerToolSettings`](../Tools/MarkerToolSettings.md) \| [`HighlighterToolSettings`](../Tools/HighlighterToolSettings.md) \| [`TextToolSettings`](../Tools/TextToolSettings.md)) => `void`; } | -| `args.handler` | (`settings`: [`NoteToolSettings`](../Tools/NoteToolSettings.md) \| [`PinToolSettings`](../Tools/PinToolSettings.md) \| [`LineToolSettings`](../Tools/LineToolSettings.md) \| [`RouteToolSettings`](../Tools/RouteToolSettings.md) \| [`PolygonToolSettings`](../Tools/PolygonToolSettings.md) \| [`CircleToolSettings`](../Tools/CircleToolSettings.md) \| [`MarkerToolSettings`](../Tools/MarkerToolSettings.md) \| [`HighlighterToolSettings`](../Tools/HighlighterToolSettings.md) \| [`TextToolSettings`](../Tools/TextToolSettings.md)) => `void` | +| Parameter | Type | +| -------------- | --------------------------------------------------------------------------------------------------------- | +| `args` | \{ `handler`: (`settings`: [`ToolSettingsChangeEvent`](../Tools/ToolSettingsChangeEvent.md)) => `void`; } | +| `args.handler` | (`settings`: [`ToolSettingsChangeEvent`](../Tools/ToolSettingsChangeEvent.md)) => `void` | #### Returns diff --git a/docs/Tools/LineToolSettings.md b/docs/Tools/LineToolSettings.md index 838b5b0..fc2351b 100644 --- a/docs/Tools/LineToolSettings.md +++ b/docs/Tools/LineToolSettings.md @@ -2,12 +2,6 @@ ## Properties -### tool - -> **tool**: `"line"` - -*** - ### color > **color**: `string` diff --git a/docs/Tools/PinFrame.md b/docs/Tools/PinFrame.md index 50000eb..a09285a 100644 --- a/docs/Tools/PinFrame.md +++ b/docs/Tools/PinFrame.md @@ -1,3 +1,3 @@ *** -> **PinFrame**: `"frame-circle"` | `"frame-square"` +> **PinFrame**: `"frame-circle"` | `"frame-square"` | `null` diff --git a/docs/Tools/PinToolSettings.md b/docs/Tools/PinToolSettings.md index 5893f76..38ae517 100644 --- a/docs/Tools/PinToolSettings.md +++ b/docs/Tools/PinToolSettings.md @@ -8,12 +8,12 @@ *** -### symbol +### frame -> **symbol**: [`PinSymbol`](PinSymbol.md) +> **frame**: `null` | `"frame-circle"` | `"frame-square"` *** -### frame +### symbol -> **frame**: [`PinFrame`](PinFrame.md) +> **symbol**: [`PinSymbol`](PinSymbol.md) diff --git a/docs/Tools/README.md b/docs/Tools/README.md index 0807ed1..372c3c2 100644 --- a/docs/Tools/README.md +++ b/docs/Tools/README.md @@ -19,6 +19,7 @@ The Tools part allows you to let users draw elements on the map. * [ToolType](ToolType.md) * [ConfigurableToolType](ConfigurableToolType.md) * [InputToolSettings](InputToolSettings.md) +* [ToolSettingsChangeEvent](ToolSettingsChangeEvent.md) * [ToolSettingsMap](ToolSettingsMap.md) * [PinFrame](PinFrame.md) * [PinSymbol](PinSymbol.md) diff --git a/docs/Tools/ToolSettingsChangeEvent.md b/docs/Tools/ToolSettingsChangeEvent.md new file mode 100644 index 0000000..06f353f --- /dev/null +++ b/docs/Tools/ToolSettingsChangeEvent.md @@ -0,0 +1,3 @@ +*** + +> **ToolSettingsChangeEvent**: `{ [K in ConfigurableToolType]: ToolSettingsMap[K] & { tool: K } }`\[[`ConfigurableToolType`](ConfigurableToolType.md)] diff --git a/docs/Tools/ToolsController.md b/docs/Tools/ToolsController.md index d90b156..52beb46 100644 --- a/docs/Tools/ToolsController.md +++ b/docs/Tools/ToolsController.md @@ -134,16 +134,16 @@ The settings for the current tool. ### onToolSettingsChange() -> **onToolSettingsChange**(`args`: \{ `handler`: (`settings`: [`NoteToolSettings`](NoteToolSettings.md) | [`PinToolSettings`](PinToolSettings.md) | [`LineToolSettings`](LineToolSettings.md) | [`RouteToolSettings`](RouteToolSettings.md) | [`PolygonToolSettings`](PolygonToolSettings.md) | [`CircleToolSettings`](CircleToolSettings.md) | [`MarkerToolSettings`](MarkerToolSettings.md) | [`HighlighterToolSettings`](HighlighterToolSettings.md) | [`TextToolSettings`](TextToolSettings.md)) => `void`; }): `VoidFunction` +> **onToolSettingsChange**(`args`: \{ `handler`: (`settings`: [`ToolSettingsChangeEvent`](ToolSettingsChangeEvent.md)) => `void`; }): `VoidFunction` Listens for changes to the settings on all tools. #### Parameters -| Parameter | Type | -| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `args` | \{ `handler`: (`settings`: [`NoteToolSettings`](NoteToolSettings.md) \| [`PinToolSettings`](PinToolSettings.md) \| [`LineToolSettings`](LineToolSettings.md) \| [`RouteToolSettings`](RouteToolSettings.md) \| [`PolygonToolSettings`](PolygonToolSettings.md) \| [`CircleToolSettings`](CircleToolSettings.md) \| [`MarkerToolSettings`](MarkerToolSettings.md) \| [`HighlighterToolSettings`](HighlighterToolSettings.md) \| [`TextToolSettings`](TextToolSettings.md)) => `void`; } | -| `args.handler` | (`settings`: [`NoteToolSettings`](NoteToolSettings.md) \| [`PinToolSettings`](PinToolSettings.md) \| [`LineToolSettings`](LineToolSettings.md) \| [`RouteToolSettings`](RouteToolSettings.md) \| [`PolygonToolSettings`](PolygonToolSettings.md) \| [`CircleToolSettings`](CircleToolSettings.md) \| [`MarkerToolSettings`](MarkerToolSettings.md) \| [`HighlighterToolSettings`](HighlighterToolSettings.md) \| [`TextToolSettings`](TextToolSettings.md)) => `void` | +| Parameter | Type | +| -------------- | ------------------------------------------------------------------------------------------------ | +| `args` | \{ `handler`: (`settings`: [`ToolSettingsChangeEvent`](ToolSettingsChangeEvent.md)) => `void`; } | +| `args.handler` | (`settings`: [`ToolSettingsChangeEvent`](ToolSettingsChangeEvent.md)) => `void` | #### Returns diff --git a/src/client.ts b/src/client.ts index cdfb4a7..c9e3a53 100644 --- a/src/client.ts +++ b/src/client.ts @@ -4,5 +4,6 @@ export * from "./modules/layers"; export * from "./modules/main"; export * from "./modules/selection"; export * from "./modules/shared"; +export * from "./modules/tools"; export * from "./modules/ui"; export * from "./modules/viewport"; diff --git a/src/lib/interface.ts b/src/lib/interface.ts index 2b6f49f..db49c84 100644 --- a/src/lib/interface.ts +++ b/src/lib/interface.ts @@ -10,12 +10,17 @@ type MethodSpec = UnionToIntersection; type ListenerSpec = UnionToIntersection; type ExtractMethodParams< - T extends Record, + T extends Record< + string, + AnyFunction | { request: { params?: any }; response: any } + >, > = { - [K in keyof T]: { - request: T[K]["request"]["params"]; - response: T[K]["response"]; - }; + [K in keyof T]: T[K] extends { request: { params?: any }; response: any } + ? { + request: T[K]["request"]["params"]; + response: T[K]["response"]; + } + : T[K]; }; type ExtractListenerParams< @@ -27,10 +32,16 @@ type ExtractListenerParams< }; }; +type AnyFunction = (...args: any[]) => any; + type MethodHandlers = { - [K in keyof T]: ( - request: T[K] extends { request: any } ? T[K]["request"] : never, - ) => PromiseOrNot; + [K in keyof T]: T[K] extends AnyFunction + ? T[K] + : ( + request: T[K] extends { request: any } ? T[K]["request"] : never, + ) => PromiseOrNot< + T[K] extends { response: any } ? T[K]["response"] : never + >; }; type FeltMethodHandlers = MethodHandlers>; @@ -83,18 +94,27 @@ export function listener( }; } -type MaybeOneMethod = { +// methods where we write out the entire function signature +type LiteralMethodKeys = { + [K in keyof MethodSpec]: MethodSpec[K] extends (...args: any[]) => any + ? K + : never; +}[keyof MethodSpec]; + +type MaybeOneMethod> = { [K1 in K]: MethodSpec[K1]["request"]; }[K]["params"]; -type OneMethod = +type StandardMethods = Omit; + +type OneMethod = MaybeOneMethod extends undefined ? void : MaybeOneMethod; -type FeltMethod = ( +type FeltMethod = ( payload: OneMethod, -) => Promise; +) => Promise; -export function method( +export function method( feltWindow: Window, type: TKey, ): FeltMethod { diff --git a/src/modules/tools/controller.ts b/src/modules/tools/controller.ts index c39a251..b2ed840 100644 --- a/src/modules/tools/controller.ts +++ b/src/modules/tools/controller.ts @@ -2,6 +2,7 @@ import { listener, method } from "~/lib/interface"; import type { ConfigurableToolType, InputToolSettings, + ToolSettingsChangeEvent, ToolSettingsMap, ToolType, } from "./types"; @@ -15,7 +16,10 @@ export const toolsController = (feltWindow: Window): ToolsController => ({ onToolChange: listener(feltWindow, "onToolChange"), setToolSettings: method(feltWindow, "setToolSettings"), - getToolSettings: method(feltWindow, "getToolSettings"), + getToolSettings: method( + feltWindow, + "getToolSettings", + ) as ToolsController["getToolSettings"], onToolSettingsChange: listener(feltWindow, "onToolSettingsChange"), }); @@ -100,6 +104,6 @@ export interface ToolsController { * @returns A function to unsubscribe from the listener */ onToolSettingsChange(args: { - handler: (settings: ToolSettingsMap[keyof ToolSettingsMap]) => void; + handler: (settings: ToolSettingsChangeEvent) => void; }): VoidFunction; } diff --git a/src/modules/tools/index.ts b/src/modules/tools/index.ts index 45ed60b..93b79f2 100644 --- a/src/modules/tools/index.ts +++ b/src/modules/tools/index.ts @@ -17,6 +17,7 @@ export type { PolygonToolSettings, RouteToolSettings, TextToolSettings, + ToolSettingsChangeEvent, ToolSettingsMap, ToolType, } from "./types"; diff --git a/src/modules/tools/schema.ts b/src/modules/tools/schema.ts index 5479e06..4e75dbb 100644 --- a/src/modules/tools/schema.ts +++ b/src/modules/tools/schema.ts @@ -11,6 +11,7 @@ import { ConfigurableToolSchema, InputToolSettingsSchema, ToolSchema, + type ToolSettingsChangeEvent, type ToolSettingsMap, type ToolType, } from "./types"; @@ -48,14 +49,11 @@ export type ToolsSchema = { setToolSettings: Method, void>; getToolSettings: Method< zInfer, - ToolSettingsMap[keyof ToolSettingsMap] | any + ToolSettingsMap[keyof ToolSettingsMap] >; }; listeners: { onToolChange: Listener; - onToolSettingsChange: Listener< - void, - ToolSettingsMap[keyof ToolSettingsMap] - >; + onToolSettingsChange: Listener; }; }; diff --git a/src/modules/tools/types.ts b/src/modules/tools/types.ts index 434ed63..13404b4 100644 --- a/src/modules/tools/types.ts +++ b/src/modules/tools/types.ts @@ -22,15 +22,13 @@ export type ConfigurableToolType = keyof ToolSettingsMap; const PinToolSettingsSchema = z.object({ color: z.string(), symbol: z.string(), - frame: z.string().nullable(), + frame: z.enum(["frame-circle", "frame-square"]).nullable(), }); export interface PinToolSettings extends zInfer { symbol: PinSymbol; - frame: PinFrame; } const LineToolSettingsSchema = z.object({ - tool: z.literal("line"), color: z.string(), strokeOpacity: z.number(), strokeWidth: z.number(), @@ -53,9 +51,9 @@ export interface RouteToolSettings const PolygonToolSettingsSchema = z.object({ color: z.string(), - fillOpacity: z.number(), - strokeOpacity: z.number(), - strokeWidth: z.number(), + fillOpacity: z.number().min(0).max(1), + strokeOpacity: z.number().min(0).max(1), + strokeWidth: z.number().min(0), strokeStyle: z.enum(["solid", "dashed", "dotted"]), areaMarker: z.boolean(), }); @@ -63,9 +61,9 @@ export interface PolygonToolSettings extends zInfer {} const CircleToolSettingsSchema = z.object({ color: z.string(), - fillOpacity: z.number(), - strokeOpacity: z.number(), - strokeWidth: z.number(), + fillOpacity: z.number().min(0).max(1), + strokeOpacity: z.number().min(0).max(1), + strokeWidth: z.number().min(0), strokeStyle: z.enum(["solid", "dashed", "dotted"]), radiusMarker: z.boolean(), }); @@ -73,16 +71,16 @@ export interface CircleToolSettings extends zInfer {} const MarkerToolSettingsSchema = z.object({ color: z.string(), - opacity: z.number(), - size: z.number(), + opacity: z.number().min(0).max(1), + size: z.number().min(0).max(100), }); export interface MarkerToolSettings extends zInfer {} const HighlighterToolSettingsSchema = z.object({ color: z.string(), - opacity: z.number(), - size: z.number(), + opacity: z.number().min(0).max(1), + size: z.number().min(0).max(200), }); export interface HighlighterToolSettings extends zInfer {} @@ -122,6 +120,10 @@ export type InputToolSettings = { [K in ConfigurableToolType]: Partial & { tool: K }; }[ConfigurableToolType]; +export type ToolSettingsChangeEvent = { + [K in ConfigurableToolType]: ToolSettingsMap[K] & { tool: K }; +}[ConfigurableToolType]; + export type ToolSettingsMap = { pin: PinToolSettings; line: LineToolSettings; @@ -134,7 +136,7 @@ export type ToolSettingsMap = { note: NoteToolSettings; }; -export type PinFrame = "frame-circle" | "frame-square"; +export type PinFrame = "frame-circle" | "frame-square" | null; export type PinSymbol = | "dot" From 70e236d58cc804eb25c3e9e9856b5bcff8952bea Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Thu, 30 Jan 2025 15:16:56 +0100 Subject: [PATCH 08/12] Fix issue reporting errors from Felt when return type is string --- src/lib/interface.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/interface.ts b/src/lib/interface.ts index db49c84..3c159a0 100644 --- a/src/lib/interface.ts +++ b/src/lib/interface.ts @@ -124,7 +124,11 @@ export function method( return new Promise((resolve, reject) => { messageChannel.port1.onmessage = (event) => { - if (event.data && "__error__" in event.data) { + if ( + event.data && + typeof event.data === "object" && + "__error__" in event.data + ) { reject(new Error(event.data.__error__)); } else { resolve(event.data); From 8fb0674aaf82ecac8b16beceb415cee9033723c0 Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Thu, 30 Jan 2025 19:08:11 +0100 Subject: [PATCH 09/12] Update API definition --- etc/js-sdk.api.md | 166 +++++++++++++++++++++++++++++----------------- 1 file changed, 104 insertions(+), 62 deletions(-) diff --git a/etc/js-sdk.api.md b/etc/js-sdk.api.md index b2da5cd..b6c8535 100644 --- a/etc/js-sdk.api.md +++ b/etc/js-sdk.api.md @@ -4,61 +4,77 @@ ```ts -import { C } from './types-F17OM3Wt.js'; -import { E as Element_2 } from './types-F17OM3Wt.js'; -import { d as ElementChangeCallbackParams } from './types-F17OM3Wt.js'; -import { b as ElementGroup } from './types-F17OM3Wt.js'; -import { e as ElementGroupChangeCallbackParams } from './types-F17OM3Wt.js'; -import { D as ElementGroupNode } from './types-F17OM3Wt.js'; -import { H as ElementNode } from './types-F17OM3Wt.js'; -import { r as EntityNode } from './types-F17OM3Wt.js'; -import { q as Feature } from './types-F17OM3Wt.js'; -import { J as FeatureNode } from './types-F17OM3Wt.js'; -import { s as FeatureSelection } from './types-F17OM3Wt.js'; -import { O as FeltBoundary } from './types-F17OM3Wt.js'; -import { P as FeltZoom } from './types-F17OM3Wt.js'; -import { y as FilterExpression } from './types-F17OM3Wt.js'; -import { A as FilterLogicGate } from './types-F17OM3Wt.js'; -import { F as Filters } from './types-F17OM3Wt.js'; -import { B as FilterTernary } from './types-F17OM3Wt.js'; -import { G as Geometry } from './types-F17OM3Wt.js'; -import { c as GetElementGroupsConstraint } from './types-F17OM3Wt.js'; -import { a as GetElementsConstraint } from './types-F17OM3Wt.js'; -import { i as GetLayerGroupsConstraint } from './types-F17OM3Wt.js'; -import { f as GetLayersConstraint } from './types-F17OM3Wt.js'; -import { p as GetRenderedFeaturesConstraint } from './types-F17OM3Wt.js'; -import { I } from './types-F17OM3Wt.js'; -import { Q as LatLng } from './types-F17OM3Wt.js'; -import { L as Layer } from './types-F17OM3Wt.js'; -import { g as LayerChangeCallbackParams } from './types-F17OM3Wt.js'; -import { o as LayerFilters } from './types-F17OM3Wt.js'; -import { h as LayerGroup } from './types-F17OM3Wt.js'; -import { j as LayerGroupChangeCallbackParams } from './types-F17OM3Wt.js'; -import { K as LayerGroupNode } from './types-F17OM3Wt.js'; -import { N as LayerNode } from './types-F17OM3Wt.js'; -import { x as LayerProcessingStatus } from './types-F17OM3Wt.js'; -import { l as LegendItem } from './types-F17OM3Wt.js'; -import { n as LegendItemChangeCallbackParams } from './types-F17OM3Wt.js'; -import { k as LegendItemIdentifier } from './types-F17OM3Wt.js'; -import { m as LegendItemsConstraint } from './types-F17OM3Wt.js'; -import { U as LineStringGeometry } from './types-F17OM3Wt.js'; -import { W as LngLatTuple } from './types-F17OM3Wt.js'; -import { M as MapInteractionEvent } from './types-F17OM3Wt.js'; -import { X as MultiLineStringGeometry } from './types-F17OM3Wt.js'; -import { Y as MultiPolygonGeometry } from './types-F17OM3Wt.js'; -import { Z as PointGeometry } from './types-F17OM3Wt.js'; -import { _ as PolygonGeometry } from './types-F17OM3Wt.js'; -import { R as RasterValue } from './types-F17OM3Wt.js'; -import { u as SetViewportCenterZoomParams } from './types-F17OM3Wt.js'; -import { S as SetVisibilityRequest } from './types-F17OM3Wt.js'; -import { T } from './types-F17OM3Wt.js'; -import { t } from './types-F17OM3Wt.js'; -import { w as ViewportCenterZoom } from './types-F17OM3Wt.js'; -import { v as ViewportFitBoundsParams } from './types-F17OM3Wt.js'; -import { V as ViewportState } from './types-F17OM3Wt.js'; -import { z } from './types-F17OM3Wt.js'; +import { a0 as CircleToolSettings } from './types-CVxZMwC_.js'; +import { C as ConfigurableToolType } from './types-CVxZMwC_.js'; +import { E as Element_2 } from './types-CVxZMwC_.js'; +import { d as ElementChangeCallbackParams } from './types-CVxZMwC_.js'; +import { b as ElementGroup } from './types-CVxZMwC_.js'; +import { e as ElementGroupChangeCallbackParams } from './types-CVxZMwC_.js'; +import { H as ElementGroupNode } from './types-CVxZMwC_.js'; +import { J as ElementNode } from './types-CVxZMwC_.js'; +import { r as EntityNode } from './types-CVxZMwC_.js'; +import { q as Feature } from './types-CVxZMwC_.js'; +import { K as FeatureNode } from './types-CVxZMwC_.js'; +import { s as FeatureSelection } from './types-CVxZMwC_.js'; +import { P as FeltBoundary } from './types-CVxZMwC_.js'; +import { Q as FeltZoom } from './types-CVxZMwC_.js'; +import { A as FilterExpression } from './types-CVxZMwC_.js'; +import { B as FilterLogicGate } from './types-CVxZMwC_.js'; +import { F as Filters } from './types-CVxZMwC_.js'; +import { D as FilterTernary } from './types-CVxZMwC_.js'; +import { G as Geometry } from './types-CVxZMwC_.js'; +import { c as GetElementGroupsConstraint } from './types-CVxZMwC_.js'; +import { a as GetElementsConstraint } from './types-CVxZMwC_.js'; +import { i as GetLayerGroupsConstraint } from './types-CVxZMwC_.js'; +import { f as GetLayersConstraint } from './types-CVxZMwC_.js'; +import { p as GetRenderedFeaturesConstraint } from './types-CVxZMwC_.js'; +import { a1 as HighlighterToolSettings } from './types-CVxZMwC_.js'; +import { I as InputToolSettings } from './types-CVxZMwC_.js'; +import { U as LatLng } from './types-CVxZMwC_.js'; +import { L as Layer } from './types-CVxZMwC_.js'; +import { g as LayerChangeCallbackParams } from './types-CVxZMwC_.js'; +import { o as LayerFilters } from './types-CVxZMwC_.js'; +import { h as LayerGroup } from './types-CVxZMwC_.js'; +import { j as LayerGroupChangeCallbackParams } from './types-CVxZMwC_.js'; +import { N as LayerGroupNode } from './types-CVxZMwC_.js'; +import { O as LayerNode } from './types-CVxZMwC_.js'; +import { y as LayerProcessingStatus } from './types-CVxZMwC_.js'; +import { l as LegendItem } from './types-CVxZMwC_.js'; +import { n as LegendItemChangeCallbackParams } from './types-CVxZMwC_.js'; +import { k as LegendItemIdentifier } from './types-CVxZMwC_.js'; +import { m as LegendItemsConstraint } from './types-CVxZMwC_.js'; +import { W as LineStringGeometry } from './types-CVxZMwC_.js'; +import { a2 as LineToolSettings } from './types-CVxZMwC_.js'; +import { X as LngLatTuple } from './types-CVxZMwC_.js'; +import { M as MapInteractionEvent } from './types-CVxZMwC_.js'; +import { a3 as MarkerToolSettings } from './types-CVxZMwC_.js'; +import { Y as MultiLineStringGeometry } from './types-CVxZMwC_.js'; +import { Z as MultiPolygonGeometry } from './types-CVxZMwC_.js'; +import { a4 as NoteToolSettings } from './types-CVxZMwC_.js'; +import { a5 as PinFrame } from './types-CVxZMwC_.js'; +import { a6 as PinSymbol } from './types-CVxZMwC_.js'; +import { a7 as PinToolSettings } from './types-CVxZMwC_.js'; +import { _ as PointGeometry } from './types-CVxZMwC_.js'; +import { $ as PolygonGeometry } from './types-CVxZMwC_.js'; +import { a8 as PolygonToolSettings } from './types-CVxZMwC_.js'; +import { R as RasterValue } from './types-CVxZMwC_.js'; +import { a9 as RouteToolSettings } from './types-CVxZMwC_.js'; +import { v as SetViewportCenterZoomParams } from './types-CVxZMwC_.js'; +import { S as SetVisibilityRequest } from './types-CVxZMwC_.js'; +import { aa as TextToolSettings } from './types-CVxZMwC_.js'; +import { u as ToolSettingsChangeEvent } from './types-CVxZMwC_.js'; +import { t as ToolSettingsMap } from './types-CVxZMwC_.js'; +import { T as ToolType } from './types-CVxZMwC_.js'; +import { x as ViewportCenterZoom } from './types-CVxZMwC_.js'; +import { w as ViewportFitBoundsParams } from './types-CVxZMwC_.js'; +import { V as ViewportState } from './types-CVxZMwC_.js'; +import { z } from './types-CVxZMwC_.js'; import { z as z_2 } from 'zod'; +export { CircleToolSettings } + +export { ConfigurableToolType } + export { Element_2 as Element } export { ElementChangeCallbackParams } @@ -114,8 +130,6 @@ export const Felt: { export { FeltBoundary } -// Warning: (ae-forgotten-export) The symbol "ToolsController" needs to be exported by the entry point client.d.ts -// // @public export interface FeltController extends ViewportController, UiController, LayersController, ElementsController, SelectionController, InteractionsController, ToolsController { iframe: HTMLIFrameElement | null; @@ -242,6 +256,10 @@ export { GetLayersConstraint } export { GetRenderedFeaturesConstraint } +export { HighlighterToolSettings } + +export { InputToolSettings } + // @public export interface InteractionsController { onPointerClick(params: { @@ -331,26 +349,42 @@ export { LegendItemsConstraint } export { LineStringGeometry } +export { LineToolSettings } + export { LngLatTuple } export { MapInteractionEvent } +export { MarkerToolSettings } + export { MultiLineStringGeometry } export { MultiPolygonGeometry } +export { NoteToolSettings } + // Warning: (ae-forgotten-export) The symbol "UiOnMapInteractionsOptionsSchema" needs to be exported by the entry point client.d.ts // // @public export interface OnMapInteractionsOptions extends z { } +export { PinFrame } + +export { PinSymbol } + +export { PinToolSettings } + export { PointGeometry } export { PolygonGeometry } +export { PolygonToolSettings } + export { RasterValue } +export { RouteToolSettings } + // @public export interface SelectionController { clearSelection(params?: { @@ -370,20 +404,28 @@ export { SetViewportCenterZoomParams } export { SetVisibilityRequest } +export { TextToolSettings } + // @public -interface ToolsController { - getTool(): Promise; - getToolSettings(tool: T): Promise; +export interface ToolsController { + getTool(): Promise; + getToolSettings(tool: T): Promise; onToolChange(args: { - handler: (tool: T | null) => void; + handler: (tool: ToolType | null) => void; }): VoidFunction; onToolSettingsChange(args: { - handler: (settings: t[keyof t]) => void; + handler: (settings: ToolSettingsChangeEvent) => void; }): VoidFunction; - setTool(tool: T | null): void; - setToolSettings(settings: I): void; + setTool(tool: ToolType | null): void; + setToolSettings(settings: InputToolSettings): void; } +export { ToolSettingsChangeEvent } + +export { ToolSettingsMap } + +export { ToolType } + // @public export interface UiController { enableToolSettingsUi(enabled: boolean): void; From b0ad527c6487858b7934825b4e4ff4c63f2ab135 Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Thu, 30 Jan 2025 19:13:23 +0100 Subject: [PATCH 10/12] Remove unwanted API --- docs/Main/FeltController.md | 19 ------------------- docs/UI/UiController.md | 19 ------------------- etc/js-sdk.api.md | 1 - src/modules/ui/controller.ts | 9 --------- src/modules/ui/schema.ts | 16 +--------------- 5 files changed, 1 insertion(+), 63 deletions(-) diff --git a/docs/Main/FeltController.md b/docs/Main/FeltController.md index 1fce176..f4236bf 100644 --- a/docs/Main/FeltController.md +++ b/docs/Main/FeltController.md @@ -885,25 +885,6 @@ will still be selected when clicked. *** -### enableToolSettingsUi() - -> **enableToolSettingsUi**(`enabled`: `boolean`): `void` - -Enables or disables the tool settings UI which shows up on the right hand side -when a tool is in use. - -#### Parameters - -| Parameter | Type | Description | -| --------- | --------- | --------------------------------------- | -| `enabled` | `boolean` | Whether to enable the tool settings UI. | - -#### Returns - -`void` - -*** - ### getViewport() > **getViewport**(): `Promise`\<[`ViewportState`](../Viewport/ViewportState.md)> diff --git a/docs/UI/UiController.md b/docs/UI/UiController.md index 413d908..df1a84e 100644 --- a/docs/UI/UiController.md +++ b/docs/UI/UiController.md @@ -50,22 +50,3 @@ will still be selected when clicked. #### Returns `void` - -*** - -### enableToolSettingsUi() - -> **enableToolSettingsUi**(`enabled`: `boolean`): `void` - -Enables or disables the tool settings UI which shows up on the right hand side -when a tool is in use. - -#### Parameters - -| Parameter | Type | Description | -| --------- | --------- | --------------------------------------- | -| `enabled` | `boolean` | Whether to enable the tool settings UI. | - -#### Returns - -`void` diff --git a/etc/js-sdk.api.md b/etc/js-sdk.api.md index b6c8535..a792e96 100644 --- a/etc/js-sdk.api.md +++ b/etc/js-sdk.api.md @@ -428,7 +428,6 @@ export { ToolType } // @public export interface UiController { - enableToolSettingsUi(enabled: boolean): void; setOnMapInteractionsUi(options: OnMapInteractionsOptions): void; updateUiControls(controls: UiControlsOptions): void; } diff --git a/src/modules/ui/controller.ts b/src/modules/ui/controller.ts index b5fa18a..ffe6c79 100644 --- a/src/modules/ui/controller.ts +++ b/src/modules/ui/controller.ts @@ -7,7 +7,6 @@ import type { UiControlsOptions, UiOnMapInteractionsOptions } from "./types"; export const uiController = (feltWindow: Window): UiController => ({ updateUiControls: method(feltWindow, "updateUiControls"), setOnMapInteractionsUi: method(feltWindow, "setOnMapInteractionsUi"), - enableToolSettingsUi: method(feltWindow, "enableToolSettingsUi"), }); /** @@ -37,12 +36,4 @@ export interface UiController { * will still be selected when clicked. */ setOnMapInteractionsUi(options: UiOnMapInteractionsOptions): void; - - /** - * Enables or disables the tool settings UI which shows up on the right hand side - * when a tool is in use. - * - * @param enabled - Whether to enable the tool settings UI. - */ - enableToolSettingsUi(enabled: boolean): void; } diff --git a/src/modules/ui/schema.ts b/src/modules/ui/schema.ts index 0709271..ea55f9b 100644 --- a/src/modules/ui/schema.ts +++ b/src/modules/ui/schema.ts @@ -1,4 +1,3 @@ -import { z } from "zod"; import type { ModuleSchema } from "~/lib/ModuleSchema"; import { type Method, methodMessage } from "~/lib/builders"; import type { zInfer } from "~/lib/utils"; @@ -17,17 +16,8 @@ const OnMapInteractionsMessage = methodMessage( UiOnMapInteractionsOptionsSchema, ); -const EnableToolSettingsUiMessage = methodMessage( - "enableToolSettingsUi", - z.boolean(), -); - export const uiSchema = { - methods: [ - UiControlsMessage, - OnMapInteractionsMessage, - EnableToolSettingsUiMessage, - ], + methods: [UiControlsMessage, OnMapInteractionsMessage], listeners: null, } satisfies ModuleSchema; @@ -38,10 +28,6 @@ export type UiSchema = { zInfer, void >; - enableToolSettingsUi: Method< - zInfer, - void - >; }; listeners: {}; }; From 0a813b17a6c3b4556c3eff4f8660728f3bfbcebb Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Thu, 30 Jan 2025 19:18:27 +0100 Subject: [PATCH 11/12] Improve documentation --- docs/Tools/README.md | 17 +++++++++++++++++ src/modules/tools/index.ts | 16 ++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/docs/Tools/README.md b/docs/Tools/README.md index 372c3c2..b58d0d0 100644 --- a/docs/Tools/README.md +++ b/docs/Tools/README.md @@ -2,6 +2,23 @@ The Tools part allows you to let users draw elements on the map. +## Example + +```ts +// Change the settings for the line tool +felt.setToolSettings({ + tool: "line", + strokeWidth: 8, + color: "#448C2A" +}); + +// Start using the line tool +felt.setTool("line"); + +// Put down the tool +felt.setTool(null); +``` + ## Interfaces * [PinToolSettings](PinToolSettings.md) diff --git a/src/modules/tools/index.ts b/src/modules/tools/index.ts index 93b79f2..8d3c2de 100644 --- a/src/modules/tools/index.ts +++ b/src/modules/tools/index.ts @@ -1,6 +1,22 @@ /** * The Tools part allows you to let users draw elements on the map. * + * @example + * ```ts + * // Change the settings for the line tool + * felt.setToolSettings({ + * tool: "line", + * strokeWidth: 8, + * color: "#448C2A" + * }); + * + * // Start using the line tool + * felt.setTool("line"); + * + * // Put down the tool + * felt.setTool(null); + * ``` + * * @module Tools */ export type { From 94935bccc02755120ae1b3082a6e4ac1d1cfbf90 Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Thu, 30 Jan 2025 19:24:23 +0100 Subject: [PATCH 12/12] docs(changeset): Adds APIs to use Felt's drawing tools on read-only maps --- .changeset/few-cats-fix.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/few-cats-fix.md diff --git a/.changeset/few-cats-fix.md b/.changeset/few-cats-fix.md new file mode 100644 index 0000000..76c34c5 --- /dev/null +++ b/.changeset/few-cats-fix.md @@ -0,0 +1,5 @@ +--- +"@feltmaps/js-sdk": minor +--- + +Adds APIs to use Felt's drawing tools on read-only maps