terra-draw 1.0.0-beta.1 → 1.0.0-beta.11
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/README.md +9 -2
- package/dist/adapters/common/adapter-listener.d.ts +22 -0
- package/dist/adapters/common/base.adapter.d.ts +59 -0
- package/dist/adapters/mapbox-gl.adapter.d.ts +0 -1
- package/dist/adapters/openlayers.adapter.d.ts +14 -13
- package/dist/common.d.ts +11 -9
- package/dist/extend.d.ts +4 -0
- package/dist/geometry/calculate-relative-angle.d.ts +2 -10
- package/dist/geometry/clockwise.d.ts +2 -0
- package/dist/geometry/determine-halfplane.d.ts +2 -10
- package/dist/geometry/measure/bearing.d.ts +3 -7
- package/dist/geometry/measure/destination.d.ts +2 -7
- package/dist/geometry/measure/pixel-distance-to-line.d.ts +2 -10
- package/dist/geometry/measure/pixel-distance.d.ts +2 -7
- package/dist/geometry/point-on-line.d.ts +5 -0
- package/dist/geometry/project/web-mercator.d.ts +2 -4
- package/dist/geometry/web-mercator-centroid.d.ts +2 -4
- package/dist/geometry/web-mercator-point-on-line.d.ts +11 -0
- package/dist/modes/angled-rectangle/angled-rectangle.mode.d.ts +2 -7
- package/dist/modes/base.mode.d.ts +3 -1
- package/dist/modes/circle/circle.mode.d.ts +3 -2
- package/dist/modes/coordinate-snapping.behavior.d.ts +16 -0
- package/dist/modes/freehand/freehand.mode.d.ts +8 -2
- package/dist/modes/{snapping.behavior.d.ts → line-snapping.behavior.d.ts} +1 -1
- package/dist/modes/linestring/linestring.mode.d.ts +16 -5
- package/dist/modes/point/point.mode.d.ts +2 -2
- package/dist/modes/polygon/polygon.mode.d.ts +17 -4
- package/dist/modes/rectangle/rectangle.mode.d.ts +2 -2
- package/dist/modes/render/render.mode.d.ts +2 -1
- package/dist/modes/sector/sector.mode.d.ts +60 -0
- package/dist/modes/select/behaviors/drag-feature.behavior.d.ts +2 -2
- package/dist/modes/sensor/sensor.mode.d.ts +69 -0
- package/dist/store/store-feature-validation.d.ts +8 -2
- package/dist/store/store.d.ts +7 -3
- package/dist/terra-draw.cjs +1 -1
- package/dist/terra-draw.cjs.map +1 -1
- package/dist/terra-draw.d.ts +12 -13
- 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/validation-reasons.d.ts +13 -0
- package/dist/validations/common-validations.d.ts +2 -0
- package/dist/validations/linestring.validation.d.ts +4 -1
- package/dist/validations/max-size.validation.d.ts +3 -1
- package/dist/validations/min-size.validation.d.ts +3 -1
- package/dist/validations/not-self-intersecting.validation.d.ts +4 -1
- package/dist/validations/point.validation.d.ts +4 -1
- package/dist/validations/polygon.validation.d.ts +8 -2
- package/e2e/package-lock.json +5 -4
- package/e2e/package.json +1 -1
- package/e2e/public/index.html +2 -0
- package/e2e/tests/leaflet.spec.ts +414 -18
- package/e2e/tests/setup.ts +16 -5
- package/eslint.config.js +32 -0
- package/package.json +29 -28
- package/tsconfig.json +2 -1
- package/readme.gif +0 -0
package/e2e/tests/setup.ts
CHANGED
|
@@ -8,7 +8,8 @@ export type TestConfigOptions =
|
|
|
8
8
|
| "insertCoordinates"
|
|
9
9
|
| "insertCoordinatesGlobe"
|
|
10
10
|
| "globeCircle"
|
|
11
|
-
| "globeSelect"
|
|
11
|
+
| "globeSelect"
|
|
12
|
+
| "snappingCoordinate";
|
|
12
13
|
|
|
13
14
|
export const setupMap = async ({
|
|
14
15
|
page,
|
|
@@ -60,7 +61,9 @@ export const changeMode = async ({
|
|
|
60
61
|
| "select"
|
|
61
62
|
| "rectangle"
|
|
62
63
|
| "circle"
|
|
63
|
-
| "angled-rectangle"
|
|
64
|
+
| "angled-rectangle"
|
|
65
|
+
| "sector"
|
|
66
|
+
| "sensor";
|
|
64
67
|
}) => {
|
|
65
68
|
let modeText = mode.charAt(0).toUpperCase() + mode.slice(1);
|
|
66
69
|
|
|
@@ -83,7 +86,10 @@ export const changeMode = async ({
|
|
|
83
86
|
const color = await button.evaluate((el) =>
|
|
84
87
|
window.getComputedStyle(el).getPropertyValue("color"),
|
|
85
88
|
);
|
|
86
|
-
expect(
|
|
89
|
+
expect(
|
|
90
|
+
color,
|
|
91
|
+
"Text rgb color should match the expected selected button color",
|
|
92
|
+
).toBe("rgb(39, 204, 255)"); // We set hex but it gets computed to rgb
|
|
87
93
|
};
|
|
88
94
|
|
|
89
95
|
export const expectPaths = async ({
|
|
@@ -99,7 +105,10 @@ export const expectPaths = async ({
|
|
|
99
105
|
await page.waitForSelector(selector);
|
|
100
106
|
expect(await page.locator(selector).count()).toBe(count);
|
|
101
107
|
} else {
|
|
102
|
-
await expect(
|
|
108
|
+
await expect(
|
|
109
|
+
await page.locator(selector).count(),
|
|
110
|
+
`locator count should be greater than 0 for selector ${selector}`,
|
|
111
|
+
).toBe(0);
|
|
103
112
|
}
|
|
104
113
|
};
|
|
105
114
|
|
|
@@ -107,14 +116,16 @@ export const expectPathDimensions = async ({
|
|
|
107
116
|
page,
|
|
108
117
|
width,
|
|
109
118
|
height,
|
|
119
|
+
item = 0,
|
|
110
120
|
}: {
|
|
111
121
|
page: Page;
|
|
112
122
|
width: number;
|
|
113
123
|
height: number;
|
|
124
|
+
item?: number;
|
|
114
125
|
}) => {
|
|
115
126
|
const selector = "svg > g > path";
|
|
116
127
|
|
|
117
|
-
const boundingBox = await page.locator(selector).boundingBox();
|
|
128
|
+
const boundingBox = await page.locator(selector).nth(item).boundingBox();
|
|
118
129
|
|
|
119
130
|
expect(boundingBox?.width).toBe(width);
|
|
120
131
|
expect(boundingBox?.height).toBe(height);
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import typescriptEslint from "@typescript-eslint/eslint-plugin";
|
|
2
|
+
import tsParser from "@typescript-eslint/parser";
|
|
3
|
+
import eslintPluginPrettier from "eslint-plugin-prettier";
|
|
4
|
+
import prettierConfig from "eslint-config-prettier";
|
|
5
|
+
|
|
6
|
+
export default [
|
|
7
|
+
{
|
|
8
|
+
name: "prettier", // Configuration name
|
|
9
|
+
files: ["**/*.{js,jsx,ts,tsx,json,md,yml,yaml,html,css}"],
|
|
10
|
+
plugins: {
|
|
11
|
+
prettier: eslintPluginPrettier, // Include Prettier plugin
|
|
12
|
+
},
|
|
13
|
+
rules: {
|
|
14
|
+
...prettierConfig.rules, // Disable ESLint rules that conflict with Prettier
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "typescript", // Configuration name
|
|
19
|
+
files: ["**/*.ts"], // TypeScript-specific configuration
|
|
20
|
+
plugins: {
|
|
21
|
+
"@typescript-eslint": typescriptEslint, // Include TypeScript ESLint plugin
|
|
22
|
+
},
|
|
23
|
+
languageOptions: {
|
|
24
|
+
parser: tsParser,
|
|
25
|
+
},
|
|
26
|
+
rules: {
|
|
27
|
+
"@typescript-eslint/no-empty-function": "warn",
|
|
28
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
29
|
+
"no-console": process.env.CI ? "error" : "warn",
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "terra-draw",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.11",
|
|
4
4
|
"description": "Frictionless map drawing across mapping provider",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"docs": "typedoc",
|
|
@@ -10,14 +10,15 @@
|
|
|
10
10
|
"release:beta:next": "tsx ./scripts/next-beta-version.ts",
|
|
11
11
|
"build": "microbundle",
|
|
12
12
|
"watch": "microbundle --watch --format modern",
|
|
13
|
+
"unused": "knip",
|
|
13
14
|
"test": "jest --config jest.config.ts",
|
|
14
15
|
"test:coverage": "jest --config jest.config.ts --coverage",
|
|
15
16
|
"test:nocheck": "jest --config jest.nocheck.config.ts",
|
|
16
17
|
"test:nocheck:coverage": "jest --config jest.nocheck.config.ts --coverage",
|
|
17
|
-
"lint": "eslint
|
|
18
|
-
"lint:quiet": "eslint --
|
|
19
|
-
"lint:fix": "eslint --fix
|
|
20
|
-
"lint:fix:quiet": "eslint --fix --quiet
|
|
18
|
+
"lint": "eslint src/",
|
|
19
|
+
"lint:quiet": "eslint --quiet src/",
|
|
20
|
+
"lint:fix": "eslint --fix src/",
|
|
21
|
+
"lint:fix:quiet": "eslint --fix --quiet src/",
|
|
21
22
|
"format": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\"",
|
|
22
23
|
"format:quiet": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\" --log-level=silent",
|
|
23
24
|
"prepare": "husky install"
|
|
@@ -59,17 +60,18 @@
|
|
|
59
60
|
"@types/geojson": "7946.0.8",
|
|
60
61
|
"@types/google.maps": "3.49.2",
|
|
61
62
|
"@types/jest": "29.5.12",
|
|
62
|
-
"@types/leaflet": "
|
|
63
|
+
"@types/leaflet": "1.9.12",
|
|
63
64
|
"@types/mapbox-gl": "2.7.3",
|
|
64
65
|
"@types/rbush": "3.0.0",
|
|
65
|
-
"@typescript-eslint/eslint-plugin": "
|
|
66
|
-
"@typescript-eslint/parser": "
|
|
67
|
-
"eslint": "
|
|
68
|
-
"eslint-config-prettier": "9.
|
|
69
|
-
"eslint-plugin-prettier": "5.
|
|
66
|
+
"@typescript-eslint/eslint-plugin": "8.17.0",
|
|
67
|
+
"@typescript-eslint/parser": "8.17.0",
|
|
68
|
+
"eslint": "9.1.0",
|
|
69
|
+
"eslint-config-prettier": "9.1.0",
|
|
70
|
+
"eslint-plugin-prettier": "5.2.1",
|
|
70
71
|
"husky": "7.0.0",
|
|
71
72
|
"jest": "29.7.0",
|
|
72
73
|
"jest-environment-jsdom": "29.7.0",
|
|
74
|
+
"knip": "^5.30.2",
|
|
73
75
|
"leaflet": "^1.9.4",
|
|
74
76
|
"mapbox-gl": "2.13.0",
|
|
75
77
|
"maplibre-gl": "3.2.0",
|
|
@@ -80,28 +82,14 @@
|
|
|
80
82
|
"ts-jest": "29.1.2",
|
|
81
83
|
"ts-loader": "9.5.1",
|
|
82
84
|
"tsx": "4.7.2",
|
|
83
|
-
"typedoc": "
|
|
84
|
-
"typescript": "5.
|
|
85
|
+
"typedoc": "0.26.11",
|
|
86
|
+
"typescript": "5.6.3"
|
|
85
87
|
},
|
|
86
88
|
"commitlint": {
|
|
87
89
|
"extends": [
|
|
88
90
|
"@commitlint/config-conventional"
|
|
89
91
|
]
|
|
90
92
|
},
|
|
91
|
-
"eslintConfig": {
|
|
92
|
-
"parser": "@typescript-eslint/parser",
|
|
93
|
-
"plugins": [
|
|
94
|
-
"@typescript-eslint"
|
|
95
|
-
],
|
|
96
|
-
"rules": {
|
|
97
|
-
"@typescript-eslint/no-empty-function": "warn",
|
|
98
|
-
"@typescript-eslint/no-explicit-any": "warn"
|
|
99
|
-
},
|
|
100
|
-
"extends": [
|
|
101
|
-
"plugin:@typescript-eslint/recommended",
|
|
102
|
-
"prettier"
|
|
103
|
-
]
|
|
104
|
-
},
|
|
105
93
|
"prettier": {
|
|
106
94
|
"printWidth": 80,
|
|
107
95
|
"semi": true,
|
|
@@ -155,5 +143,18 @@
|
|
|
155
143
|
}
|
|
156
144
|
]
|
|
157
145
|
},
|
|
158
|
-
"sideEffects": false
|
|
146
|
+
"sideEffects": false,
|
|
147
|
+
"knip": {
|
|
148
|
+
"$schema": "https://unpkg.com/knip@5/schema.json",
|
|
149
|
+
"entry": [
|
|
150
|
+
"src/terra-draw.ts"
|
|
151
|
+
],
|
|
152
|
+
"project": [
|
|
153
|
+
"src/**/*.ts"
|
|
154
|
+
],
|
|
155
|
+
"include": [
|
|
156
|
+
"files",
|
|
157
|
+
"types"
|
|
158
|
+
]
|
|
159
|
+
}
|
|
159
160
|
}
|
package/tsconfig.json
CHANGED
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"entryPoints": ["src/terra-draw.ts"],
|
|
15
15
|
"exclude": ["src/geometry/**/*.ts", "src/test/**/*.ts", "src/util/**/*.ts"],
|
|
16
16
|
"out": "docs",
|
|
17
|
-
"skipErrorChecking": true
|
|
17
|
+
"skipErrorChecking": true,
|
|
18
|
+
"sourceLinkExternal": true
|
|
18
19
|
},
|
|
19
20
|
"exclude": [
|
|
20
21
|
"node_modules/",
|
package/readme.gif
DELETED
|
Binary file
|