terra-draw 1.15.0 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/benchmark/setup.d.ts +33 -0
- package/dist/common.d.ts +4 -0
- package/dist/modes/base.mode.d.ts +3 -2
- package/dist/modes/marker/marker.mode.d.ts +59 -0
- package/dist/modes/marker/marker.mode.spec.d.ts +1 -0
- package/dist/modes/static/static.mode.d.ts +3 -0
- package/dist/terra-draw.benchmark.d.ts +1 -0
- package/dist/terra-draw.cjs +1 -1
- package/dist/terra-draw.cjs.map +1 -1
- package/dist/terra-draw.d.ts +3 -1
- package/dist/terra-draw.modern.js +1 -1
- package/dist/terra-draw.modern.js.map +1 -1
- package/dist/terra-draw.module.js +1 -1
- package/dist/terra-draw.module.js.map +1 -1
- package/dist/terra-draw.umd.js +1 -1
- package/dist/terra-draw.umd.js.map +1 -1
- package/dist/test/test-adapter.d.ts +44 -0
- package/package.json +3 -2
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { FeatureId } from "../extend";
|
|
2
|
+
import { GeoJSONStoreFeatures, TerraDraw } from "../terra-draw";
|
|
3
|
+
import { Bench } from "tinybench";
|
|
4
|
+
type BenchmarkResult = {
|
|
5
|
+
name: string;
|
|
6
|
+
opsPerSecond: number;
|
|
7
|
+
averageTimeMs: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const createPointFeatures: (n: number) => GeoJSONStoreFeatures[];
|
|
10
|
+
export declare const createDraw: () => TerraDraw;
|
|
11
|
+
type BenchmarkProps = {
|
|
12
|
+
draw: TerraDraw;
|
|
13
|
+
features: GeoJSONStoreFeatures[];
|
|
14
|
+
featureIds: FeatureId[];
|
|
15
|
+
randomFeatureId: FeatureId;
|
|
16
|
+
};
|
|
17
|
+
export type BenchmarkTask = {
|
|
18
|
+
name: string;
|
|
19
|
+
beforeEach: (benchmarkProps: BenchmarkProps) => void;
|
|
20
|
+
task: (benchmarkProps: BenchmarkProps) => void;
|
|
21
|
+
featureCount?: number;
|
|
22
|
+
loopCount?: number;
|
|
23
|
+
enabled?: boolean;
|
|
24
|
+
};
|
|
25
|
+
export declare const createBenchmark: (benmarkName: string, tasks: BenchmarkTask[]) => Bench;
|
|
26
|
+
export declare const processBenchmarks: (bench: Bench, benchmarkTasks: BenchmarkTask[]) => BenchmarkResult[];
|
|
27
|
+
export declare function writeBenchmarkSummary(results: BenchmarkResult[]): void;
|
|
28
|
+
export declare const logBenchmarkResults: (results: {
|
|
29
|
+
name: string;
|
|
30
|
+
opsPerSecond: number;
|
|
31
|
+
averageTimeMs: number;
|
|
32
|
+
}[]) => void;
|
|
33
|
+
export {};
|
package/dist/common.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { StoreChangeHandler, GeoJSONStore, GeoJSONStoreFeatures, FeatureId } fro
|
|
|
3
3
|
export type HexColor = `#${string}`;
|
|
4
4
|
export type HexColorStyling = HexColor | ((feature: GeoJSONStoreFeatures) => HexColor);
|
|
5
5
|
export type NumericStyling = number | ((feature: GeoJSONStoreFeatures) => number);
|
|
6
|
+
export type UrlStyling = string | ((feature: GeoJSONStoreFeatures) => string);
|
|
6
7
|
export interface TerraDrawAdapterStyling {
|
|
7
8
|
pointColor: HexColor;
|
|
8
9
|
pointWidth: number;
|
|
@@ -15,6 +16,9 @@ export interface TerraDrawAdapterStyling {
|
|
|
15
16
|
lineStringWidth: number;
|
|
16
17
|
lineStringColor: HexColor;
|
|
17
18
|
zIndex: number;
|
|
19
|
+
markerUrl?: string;
|
|
20
|
+
markerHeight?: number;
|
|
21
|
+
markerWidth?: number;
|
|
18
22
|
}
|
|
19
23
|
export type CartesianPoint = {
|
|
20
24
|
x: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BehaviorConfig, TerraDrawModeBehavior } from "./base.behavior";
|
|
2
|
-
import { OnChangeContext, HexColor, OnFinishContext, Projection, TerraDrawAdapterStyling, TerraDrawGeoJSONStore, TerraDrawKeyboardEvent, TerraDrawModeRegisterConfig, TerraDrawModeState, TerraDrawMouseEvent, Validation } from "../common";
|
|
2
|
+
import { OnChangeContext, HexColor, OnFinishContext, Projection, TerraDrawAdapterStyling, TerraDrawGeoJSONStore, TerraDrawKeyboardEvent, TerraDrawModeRegisterConfig, TerraDrawModeState, TerraDrawMouseEvent, Validation, HexColorStyling, NumericStyling, UrlStyling } from "../common";
|
|
3
3
|
import { FeatureId, GeoJSONStoreFeatures, StoreChangeHandler } from "../store/store";
|
|
4
|
-
export type CustomStyling = Record<string, string | number |
|
|
4
|
+
export type CustomStyling = Record<string, string | number | HexColorStyling | NumericStyling | UrlStyling>;
|
|
5
5
|
export declare enum ModeTypes {
|
|
6
6
|
Drawing = "drawing",
|
|
7
7
|
Select = "select",
|
|
@@ -82,6 +82,7 @@ export declare abstract class TerraDrawBaseDrawMode<Styling extends CustomStylin
|
|
|
82
82
|
onDragEnd(event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void): void;
|
|
83
83
|
protected getHexColorStylingValue(value: HexColor | ((feature: GeoJSONStoreFeatures) => HexColor) | undefined, defaultValue: HexColor, feature: GeoJSONStoreFeatures): HexColor;
|
|
84
84
|
protected getNumericStylingValue(value: number | ((feature: GeoJSONStoreFeatures) => number) | undefined, defaultValue: number, feature: GeoJSONStoreFeatures): number;
|
|
85
|
+
protected getUrlStylingValue(value: UrlStyling | undefined, defaultValue: string, feature: GeoJSONStoreFeatures): string;
|
|
85
86
|
private getStylingValue;
|
|
86
87
|
}
|
|
87
88
|
export declare abstract class TerraDrawBaseSelectMode<Styling extends CustomStyling> extends TerraDrawBaseDrawMode<Styling> {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { TerraDrawMouseEvent, TerraDrawAdapterStyling, NumericStyling, Cursor, UrlStyling } from "../../common";
|
|
2
|
+
import { GeoJSONStoreFeatures, StoreValidation } from "../../store/store";
|
|
3
|
+
import { BaseModeOptions, CustomStyling, TerraDrawBaseDrawMode } from "../base.mode";
|
|
4
|
+
import { BehaviorConfig } from "../base.behavior";
|
|
5
|
+
type MarkerModeStyling = {
|
|
6
|
+
markerUrl: UrlStyling;
|
|
7
|
+
markerHeight: NumericStyling;
|
|
8
|
+
markerWidth: NumericStyling;
|
|
9
|
+
};
|
|
10
|
+
interface Cursors {
|
|
11
|
+
create?: Cursor;
|
|
12
|
+
dragStart?: Cursor;
|
|
13
|
+
dragEnd?: Cursor;
|
|
14
|
+
}
|
|
15
|
+
interface TerraDrawMarkerModeOptions<T extends CustomStyling> extends BaseModeOptions<T> {
|
|
16
|
+
cursors?: Cursors;
|
|
17
|
+
editable?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare class TerraDrawMarkerMode extends TerraDrawBaseDrawMode<MarkerModeStyling> {
|
|
20
|
+
mode: "marker";
|
|
21
|
+
private cursors;
|
|
22
|
+
private editable;
|
|
23
|
+
private editedFeatureId;
|
|
24
|
+
private markerUrl;
|
|
25
|
+
private markerHeight;
|
|
26
|
+
private markerWidth;
|
|
27
|
+
private pixelDistance;
|
|
28
|
+
private clickBoundingBox;
|
|
29
|
+
constructor(options?: TerraDrawMarkerModeOptions<MarkerModeStyling>);
|
|
30
|
+
updateOptions(options?: TerraDrawMarkerModeOptions<MarkerModeStyling> | undefined): void;
|
|
31
|
+
/** @internal */
|
|
32
|
+
start(): void;
|
|
33
|
+
/** @internal */
|
|
34
|
+
stop(): void;
|
|
35
|
+
/** @internal */
|
|
36
|
+
onClick(event: TerraDrawMouseEvent): void;
|
|
37
|
+
/** @internal */
|
|
38
|
+
onMouseMove(): void;
|
|
39
|
+
/** @internal */
|
|
40
|
+
onKeyDown(): void;
|
|
41
|
+
/** @internal */
|
|
42
|
+
onKeyUp(): void;
|
|
43
|
+
/** @internal */
|
|
44
|
+
cleanUp(): void;
|
|
45
|
+
onDragStart(event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void): void;
|
|
46
|
+
/** @internal */
|
|
47
|
+
onDrag(event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void): void;
|
|
48
|
+
/** @internal */
|
|
49
|
+
onDragEnd(event: TerraDrawMouseEvent, setMapDraggability: (enabled: boolean) => void): void;
|
|
50
|
+
registerBehaviors(config: BehaviorConfig): void;
|
|
51
|
+
/** @internal */
|
|
52
|
+
styleFeature(feature: GeoJSONStoreFeatures): TerraDrawAdapterStyling;
|
|
53
|
+
validateFeature(feature: unknown): StoreValidation;
|
|
54
|
+
private onLeftClick;
|
|
55
|
+
private onRightClick;
|
|
56
|
+
private getNearestPointFeature;
|
|
57
|
+
afterFeatureUpdated(feature: GeoJSONStoreFeatures): void;
|
|
58
|
+
}
|
|
59
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -27,6 +27,9 @@ export declare class TerraDrawStaticMode extends TerraDrawBaseDrawMode<StaticMod
|
|
|
27
27
|
lineStringWidth: number;
|
|
28
28
|
lineStringColor: import("../../common").HexColor;
|
|
29
29
|
zIndex: number;
|
|
30
|
+
markerUrl?: string;
|
|
31
|
+
markerHeight?: number;
|
|
32
|
+
markerWidth?: number;
|
|
30
33
|
};
|
|
31
34
|
}
|
|
32
35
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|