terra-draw 1.0.0-beta.0 → 1.0.0-beta.3

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.
@@ -41,6 +41,8 @@
41
41
  <button id="linestring">Linestring</button>
42
42
  <button id="polygon">Polygon</button>
43
43
  <button id="rectangle">Rectangle</button>
44
+ <button id="angled-rectangle">Angled Rectangle</button>
45
+ <button id="sector">Sector</button>
44
46
  <button id="circle">Circle</button>
45
47
  <button id="clear">Clear</button>
46
48
  </div>
@@ -53,7 +53,7 @@ test.describe("page setup", () => {
53
53
  test.describe("point mode", () => {
54
54
  const mode = "point";
55
55
 
56
- test("mode can set and can be used to create a point", async ({ page }) => {
56
+ test("mode can set and used to create a point", async ({ page }) => {
57
57
  const mapDiv = await setupMap({ page });
58
58
  await changeMode({ page, mode });
59
59
  await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
@@ -61,9 +61,7 @@ test.describe("point mode", () => {
61
61
  await expectPaths({ page, count: 1 });
62
62
  });
63
63
 
64
- test("mode can set and can be used to create multiple points", async ({
65
- page,
66
- }) => {
64
+ test("mode can set and used to create multiple points", async ({ page }) => {
67
65
  const mapDiv = await setupMap({ page });
68
66
  await changeMode({ page, mode });
69
67
 
@@ -91,7 +89,7 @@ test.describe("linestring mode", () => {
91
89
  ] as { name: string; config: TestConfigOptions[] }[];
92
90
 
93
91
  for (const { name, config } of options) {
94
- test(`mode can set and can be used to create a linestring${name}`, async ({
92
+ test(`mode can set and used to create a linestring${name}`, async ({
95
93
  page,
96
94
  }) => {
97
95
  const mapDiv = await setupMap({ page, configQueryParam: config });
@@ -108,7 +106,7 @@ test.describe("linestring mode", () => {
108
106
  await expectPaths({ page, count: 1 });
109
107
  });
110
108
 
111
- test(`mode can set and can be used to create a linestring with multiple points${name}`, async ({
109
+ test(`mode can set and used to create a linestring with multiple points${name}`, async ({
112
110
  page,
113
111
  }) => {
114
112
  const mapDiv = await setupMap({ page, configQueryParam: config });
@@ -133,7 +131,7 @@ test.describe("linestring mode", () => {
133
131
  await expectPaths({ page, count: 1 });
134
132
  });
135
133
 
136
- test(`mode can set and can be used to create a linestring with multiple clicked points${name}`, async ({
134
+ test(`mode can set and used to create a linestring with multiple clicked points${name}`, async ({
137
135
  page,
138
136
  }) => {
139
137
  const mapDiv = await setupMap({ page, configQueryParam: config });
@@ -158,7 +156,7 @@ test.describe("linestring mode", () => {
158
156
  await expectPaths({ page, count: 1 });
159
157
  });
160
158
 
161
- test(`mode can set and can be used to create multiple linestrings${name}`, async ({
159
+ test(`mode can set and used to create multiple linestrings${name}`, async ({
162
160
  page,
163
161
  }) => {
164
162
  const mapDiv = await setupMap({ page, configQueryParam: config });
@@ -197,7 +195,7 @@ test.describe("linestring mode", () => {
197
195
  test.describe("polygon mode", () => {
198
196
  const mode = "polygon";
199
197
 
200
- test("mode can set and can be used to create a polygon", async ({ page }) => {
198
+ test("mode can set and used to create a polygon", async ({ page }) => {
201
199
  const mapDiv = await setupMap({ page });
202
200
  await changeMode({ page, mode });
203
201
 
@@ -312,9 +310,7 @@ test.describe("polygon mode", () => {
312
310
  test.describe("rectangle mode", () => {
313
311
  const mode = "rectangle";
314
312
 
315
- test("mode can set and can be used to create a rectangle", async ({
316
- page,
317
- }) => {
313
+ test("mode can set and used to create a rectangle", async ({ page }) => {
318
314
  const mapDiv = await setupMap({ page });
319
315
  await changeMode({ page, mode });
320
316
 
@@ -328,10 +324,216 @@ test.describe("rectangle mode", () => {
328
324
  });
329
325
  });
330
326
 
327
+ test.describe("angled rectangle mode", () => {
328
+ const mode = "angled-rectangle";
329
+
330
+ test("mode can set and used to create an angled rectangle (horizontal up)", async ({
331
+ page,
332
+ }) => {
333
+ const mapDiv = await setupMap({ page });
334
+ await changeMode({ page, mode });
335
+
336
+ await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
337
+ await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
338
+ await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
339
+ await page.mouse.move(mapDiv.width / 3 + 50, mapDiv.height / 3 + 50, {
340
+ steps: 30,
341
+ });
342
+ await page.mouse.click(mapDiv.width / 3 + 50, mapDiv.height / 3 + 50);
343
+
344
+ await expectPaths({ page, count: 1 });
345
+
346
+ await expectPathDimensions({ page, width: 217, height: 74 });
347
+ });
348
+
349
+ test("mode can set and used to create an angled rectangle (horizontal down)", async ({
350
+ page,
351
+ }) => {
352
+ const mapDiv = await setupMap({ page });
353
+ await changeMode({ page, mode });
354
+
355
+ await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
356
+ await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
357
+ await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
358
+ await page.mouse.move(mapDiv.width / 3 + 50, mapDiv.height / 3 + 200, {
359
+ steps: 30,
360
+ });
361
+ await page.mouse.click(mapDiv.width / 3 + 50, mapDiv.height / 3 + 200);
362
+
363
+ await expectPaths({ page, count: 1 });
364
+
365
+ await expectPathDimensions({ page, width: 217, height: 84 });
366
+ });
367
+
368
+ test("mode can set and used to create an angled (diagonal)", async ({
369
+ page,
370
+ }) => {
371
+ const mapDiv = await setupMap({ page });
372
+ await changeMode({ page, mode });
373
+
374
+ await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
375
+ await page.mouse.move(mapDiv.width / 3, mapDiv.height / 3, { steps: 30 });
376
+ await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
377
+ await page.mouse.move(mapDiv.width / 3 + 150, mapDiv.height / 3 + 150, {
378
+ steps: 30,
379
+ });
380
+ await page.mouse.click(mapDiv.width / 3 + 150, mapDiv.height / 3 + 150);
381
+
382
+ await expectPaths({ page, count: 1 });
383
+
384
+ await expectPathDimensions({ page, width: 245, height: 174 });
385
+ });
386
+
387
+ test("mode can set and used to create an angled (diagonal 2)", async ({
388
+ page,
389
+ }) => {
390
+ const mapDiv = await setupMap({ page });
391
+ await changeMode({ page, mode });
392
+
393
+ await page.mouse.click(mapDiv.width / 1.8, mapDiv.height / 1.8);
394
+ await page.mouse.move(mapDiv.width / 2.5, mapDiv.height / 1.3, {
395
+ steps: 30,
396
+ });
397
+ await page.mouse.click(mapDiv.width / 2.5, mapDiv.height / 1.3);
398
+ await page.mouse.move(mapDiv.width / 2.5 + 50, mapDiv.height / 1.3 + 50, {
399
+ steps: 30,
400
+ });
401
+ await page.mouse.click(mapDiv.width / 2.5 + 50, mapDiv.height / 1.3 + 50);
402
+
403
+ await expectPaths({ page, count: 1 });
404
+
405
+ await expectPathDimensions({ page, width: 246, height: 213 });
406
+ });
407
+ });
408
+
409
+ test.describe("sector mode", () => {
410
+ const mode = "sector";
411
+
412
+ test("mode can set and used to create a sector less than 90 degrees (clockwise)", async ({
413
+ page,
414
+ }) => {
415
+ const mapDiv = await setupMap({ page });
416
+ await changeMode({ page, mode });
417
+
418
+ await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
419
+ await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
420
+ await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
421
+ await page.mouse.move(mapDiv.width / 3, mapDiv.height / 3, {
422
+ steps: 30,
423
+ });
424
+ await page.mouse.click(mapDiv.width / 3, mapDiv.height / 3);
425
+
426
+ await expectPaths({ page, count: 1 });
427
+
428
+ await expectPathDimensions({ page, width: 217, height: 109 });
429
+ });
430
+
431
+ test("mode can set and used to create a sector more than 90 degrees (clockwise)", async ({
432
+ page,
433
+ }) => {
434
+ const mapDiv = await setupMap({ page });
435
+ await changeMode({ page, mode });
436
+
437
+ await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
438
+ await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
439
+ await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
440
+ await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 3, {
441
+ steps: 30,
442
+ });
443
+ await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 3);
444
+
445
+ await expectPaths({ page, count: 1 });
446
+
447
+ await expectPathDimensions({ page, width: 417, height: 217 });
448
+ });
449
+
450
+ test("mode can set and used to create a sector more than 180 degrees (clockwise)", async ({
451
+ page,
452
+ }) => {
453
+ const mapDiv = await setupMap({ page });
454
+ await changeMode({ page, mode });
455
+
456
+ await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
457
+ await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
458
+ await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
459
+ await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 3, {
460
+ steps: 10,
461
+ });
462
+ await page.mouse.move(mapDiv.width * 0.4, mapDiv.height / 1.5, {
463
+ steps: 10,
464
+ });
465
+ await page.mouse.click(mapDiv.width * 0.4, mapDiv.height / 1.5);
466
+
467
+ await expectPaths({ page, count: 1 });
468
+
469
+ await expectPathDimensions({ page, width: 430, height: 430 });
470
+ });
471
+
472
+ test("mode can set and used to create a sector less than 90 degrees (anticlockwise)", async ({
473
+ page,
474
+ }) => {
475
+ const mapDiv = await setupMap({ page });
476
+ await changeMode({ page, mode });
477
+
478
+ await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
479
+ await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
480
+ await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
481
+ await page.mouse.move(mapDiv.width * 0.4, mapDiv.height / 1.5, {
482
+ steps: 30,
483
+ });
484
+ await page.mouse.click(mapDiv.width * 0.4, mapDiv.height / 1.5);
485
+
486
+ await expectPaths({ page, count: 1 });
487
+
488
+ await expectPathDimensions({ page, width: 217, height: 150 });
489
+ });
490
+
491
+ test("mode can set and used to create a sector more than 90 degrees (anticlockwise)", async ({
492
+ page,
493
+ }) => {
494
+ const mapDiv = await setupMap({ page });
495
+ await changeMode({ page, mode });
496
+
497
+ await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
498
+ await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
499
+ await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
500
+ await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 1.5, {
501
+ steps: 30,
502
+ });
503
+ await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 1.5);
504
+
505
+ await expectPaths({ page, count: 1 });
506
+
507
+ await expectPathDimensions({ page, width: 417, height: 217 });
508
+ });
509
+
510
+ test("mode can set and used to create a sector more than 180 degrees (anticlockwise)", async ({
511
+ page,
512
+ }) => {
513
+ const mapDiv = await setupMap({ page });
514
+ await changeMode({ page, mode });
515
+
516
+ await page.mouse.click(mapDiv.width / 2, mapDiv.height / 2);
517
+ await page.mouse.move(mapDiv.width / 3, mapDiv.height / 2, { steps: 30 });
518
+ await page.mouse.click(mapDiv.width / 3, mapDiv.height / 2);
519
+ await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 1.5, {
520
+ steps: 30,
521
+ });
522
+ await page.mouse.move(mapDiv.width * 0.75, mapDiv.height / 3, {
523
+ steps: 30,
524
+ });
525
+ await page.mouse.click(mapDiv.width * 0.75, mapDiv.height / 3);
526
+
527
+ await expectPaths({ page, count: 1 });
528
+
529
+ await expectPathDimensions({ page, width: 430, height: 292 });
530
+ });
531
+ });
532
+
331
533
  test.describe("circle mode", () => {
332
534
  const mode = "circle";
333
535
 
334
- test("mode can set and can be used to create a web mercator circle", async ({
536
+ test("mode can set and used to create a web mercator circle", async ({
335
537
  page,
336
538
  }) => {
337
539
  const mapDiv = await setupMap({ page });
@@ -346,7 +548,7 @@ test.describe("circle mode", () => {
346
548
  await expectPathDimensions({ page, width: 146, height: 146 });
347
549
  });
348
550
 
349
- test("mode can set and can be used to create a geodesic circle", async ({
551
+ test("mode can set and used to create a geodesic circle", async ({
350
552
  page,
351
553
  }) => {
352
554
  const mapDiv = await setupMap({ page, configQueryParam: ["globeCircle"] });
@@ -53,9 +53,27 @@ export const changeMode = async ({
53
53
  mode,
54
54
  }: {
55
55
  page: Page;
56
- mode: "point" | "polygon" | "linestring" | "select" | "rectangle" | "circle";
56
+ mode:
57
+ | "point"
58
+ | "polygon"
59
+ | "linestring"
60
+ | "select"
61
+ | "rectangle"
62
+ | "circle"
63
+ | "angled-rectangle"
64
+ | "sector";
57
65
  }) => {
58
- const modeText = mode.charAt(0).toUpperCase() + mode.slice(1);
66
+ let modeText = mode.charAt(0).toUpperCase() + mode.slice(1);
67
+
68
+ if (mode.includes("-")) {
69
+ modeText = mode
70
+ .split("-")
71
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
72
+ .join(" ");
73
+ } else {
74
+ modeText = mode.charAt(0).toUpperCase() + mode.slice(1);
75
+ }
76
+
59
77
  const buttons = page.getByTestId("buttons");
60
78
  const button = buttons.getByText(modeText, { exact: true });
61
79
 
@@ -66,7 +84,10 @@ export const changeMode = async ({
66
84
  const color = await button.evaluate((el) =>
67
85
  window.getComputedStyle(el).getPropertyValue("color"),
68
86
  );
69
- expect(color).toBe("rgb(39, 204, 255)"); // We set hex but it gets computed to rgb
87
+ expect(
88
+ color,
89
+ "Text rgb color should match the expected selected button color",
90
+ ).toBe("rgb(39, 204, 255)"); // We set hex but it gets computed to rgb
70
91
  };
71
92
 
72
93
  export const expectPaths = async ({
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "terra-draw",
3
- "version": "1.0.0-beta.0",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "Frictionless map drawing across mapping provider",
5
5
  "scripts": {
6
6
  "docs": "typedoc",
7
7
  "docs:serve": "serve ./docs",
8
- "release:beta:major": "standard-version --prerelease beta --release-as major",
9
8
  "release:beta:increment": "standard-version --prerelease beta",
10
9
  "release:beta:changelog": "tsx ./scripts/changelog-valid.ts",
11
10
  "release:beta:next": "tsx ./scripts/next-beta-version.ts",
12
11
  "build": "microbundle",
13
12
  "watch": "microbundle --watch --format modern",
13
+ "unused": "knip",
14
14
  "test": "jest --config jest.config.ts",
15
15
  "test:coverage": "jest --config jest.config.ts --coverage",
16
16
  "test:nocheck": "jest --config jest.nocheck.config.ts",
@@ -71,17 +71,18 @@
71
71
  "husky": "7.0.0",
72
72
  "jest": "29.7.0",
73
73
  "jest-environment-jsdom": "29.7.0",
74
+ "knip": "^5.30.2",
74
75
  "leaflet": "^1.9.4",
75
76
  "mapbox-gl": "2.13.0",
76
77
  "maplibre-gl": "3.2.0",
77
78
  "microbundle": "0.15.0",
78
- "ol": "7.1.0",
79
+ "ol": "10.0.0",
79
80
  "serve": "14.1.2",
80
81
  "standard-version": "9.5.0",
81
82
  "ts-jest": "29.1.2",
82
83
  "ts-loader": "9.5.1",
83
84
  "tsx": "4.7.2",
84
- "typedoc": "^0.26.2",
85
+ "typedoc": "^0.26.6",
85
86
  "typescript": "5.5.2"
86
87
  },
87
88
  "commitlint": {
@@ -156,5 +157,18 @@
156
157
  }
157
158
  ]
158
159
  },
159
- "sideEffects": false
160
+ "sideEffects": false,
161
+ "knip": {
162
+ "$schema": "https://unpkg.com/knip@5/schema.json",
163
+ "entry": [
164
+ "src/terra-draw.ts"
165
+ ],
166
+ "project": [
167
+ "src/**/*.ts"
168
+ ],
169
+ "include": [
170
+ "files",
171
+ "types"
172
+ ]
173
+ }
160
174
  }
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