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.
Files changed (60) hide show
  1. package/README.md +9 -2
  2. package/dist/adapters/common/adapter-listener.d.ts +22 -0
  3. package/dist/adapters/common/base.adapter.d.ts +59 -0
  4. package/dist/adapters/mapbox-gl.adapter.d.ts +0 -1
  5. package/dist/adapters/openlayers.adapter.d.ts +14 -13
  6. package/dist/common.d.ts +11 -9
  7. package/dist/extend.d.ts +4 -0
  8. package/dist/geometry/calculate-relative-angle.d.ts +2 -10
  9. package/dist/geometry/clockwise.d.ts +2 -0
  10. package/dist/geometry/determine-halfplane.d.ts +2 -10
  11. package/dist/geometry/measure/bearing.d.ts +3 -7
  12. package/dist/geometry/measure/destination.d.ts +2 -7
  13. package/dist/geometry/measure/pixel-distance-to-line.d.ts +2 -10
  14. package/dist/geometry/measure/pixel-distance.d.ts +2 -7
  15. package/dist/geometry/point-on-line.d.ts +5 -0
  16. package/dist/geometry/project/web-mercator.d.ts +2 -4
  17. package/dist/geometry/web-mercator-centroid.d.ts +2 -4
  18. package/dist/geometry/web-mercator-point-on-line.d.ts +11 -0
  19. package/dist/modes/angled-rectangle/angled-rectangle.mode.d.ts +2 -7
  20. package/dist/modes/base.mode.d.ts +3 -1
  21. package/dist/modes/circle/circle.mode.d.ts +3 -2
  22. package/dist/modes/coordinate-snapping.behavior.d.ts +16 -0
  23. package/dist/modes/freehand/freehand.mode.d.ts +8 -2
  24. package/dist/modes/{snapping.behavior.d.ts → line-snapping.behavior.d.ts} +1 -1
  25. package/dist/modes/linestring/linestring.mode.d.ts +16 -5
  26. package/dist/modes/point/point.mode.d.ts +2 -2
  27. package/dist/modes/polygon/polygon.mode.d.ts +17 -4
  28. package/dist/modes/rectangle/rectangle.mode.d.ts +2 -2
  29. package/dist/modes/render/render.mode.d.ts +2 -1
  30. package/dist/modes/sector/sector.mode.d.ts +60 -0
  31. package/dist/modes/select/behaviors/drag-feature.behavior.d.ts +2 -2
  32. package/dist/modes/sensor/sensor.mode.d.ts +69 -0
  33. package/dist/store/store-feature-validation.d.ts +8 -2
  34. package/dist/store/store.d.ts +7 -3
  35. package/dist/terra-draw.cjs +1 -1
  36. package/dist/terra-draw.cjs.map +1 -1
  37. package/dist/terra-draw.d.ts +12 -13
  38. package/dist/terra-draw.modern.js +1 -1
  39. package/dist/terra-draw.modern.js.map +1 -1
  40. package/dist/terra-draw.module.js +1 -1
  41. package/dist/terra-draw.module.js.map +1 -1
  42. package/dist/terra-draw.umd.js +1 -1
  43. package/dist/terra-draw.umd.js.map +1 -1
  44. package/dist/validation-reasons.d.ts +13 -0
  45. package/dist/validations/common-validations.d.ts +2 -0
  46. package/dist/validations/linestring.validation.d.ts +4 -1
  47. package/dist/validations/max-size.validation.d.ts +3 -1
  48. package/dist/validations/min-size.validation.d.ts +3 -1
  49. package/dist/validations/not-self-intersecting.validation.d.ts +4 -1
  50. package/dist/validations/point.validation.d.ts +4 -1
  51. package/dist/validations/polygon.validation.d.ts +8 -2
  52. package/e2e/package-lock.json +5 -4
  53. package/e2e/package.json +1 -1
  54. package/e2e/public/index.html +2 -0
  55. package/e2e/tests/leaflet.spec.ts +414 -18
  56. package/e2e/tests/setup.ts +16 -5
  57. package/eslint.config.js +32 -0
  58. package/package.json +29 -28
  59. package/tsconfig.json +2 -1
  60. package/readme.gif +0 -0
@@ -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(color).toBe("rgb(39, 204, 255)"); // We set hex but it gets computed to rgb
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(await page.locator(selector).count()).toBe(0);
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);
@@ -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.1",
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 --ext .ts src/",
18
- "lint:quiet": "eslint --ext .ts --quiet src/",
19
- "lint:fix": "eslint --fix --ext .ts src/",
20
- "lint:fix:quiet": "eslint --fix --quiet --ext .ts src/",
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": "^1.9.12",
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": "7.14.1",
66
- "@typescript-eslint/parser": "7.14.1",
67
- "eslint": "8.57.0",
68
- "eslint-config-prettier": "9.0.0",
69
- "eslint-plugin-prettier": "5.0.0",
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": "^0.26.2",
84
- "typescript": "5.5.2"
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