terra-draw 0.0.1-alpha.6 → 0.0.1-alpha.61
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/.devcontainer/Dockerfile +8 -0
- package/.devcontainer/devcontainer.json +21 -0
- package/.devcontainer/post-create.sh +16 -0
- package/README.md +30 -6
- package/dist/adapters/arcgis-maps-sdk.adapter.d.ts +105 -0
- package/dist/adapters/common/adapter-listener.d.ts +22 -0
- package/dist/adapters/common/base.adapter.d.ts +59 -0
- package/dist/adapters/google-maps.adapter.d.ts +90 -39
- package/dist/adapters/leaflet.adapter.d.ts +97 -33
- package/dist/adapters/mapbox-gl.adapter.d.ts +89 -37
- package/dist/adapters/maplibre-gl.adapter.d.ts +71 -0
- package/dist/adapters/openlayers.adapter.d.ts +118 -0
- package/dist/common.d.ts +103 -98
- package/dist/geometry/boolean/is-valid-coordinate.d.ts +4 -0
- package/dist/geometry/boolean/is-valid-linestring-feature.d.ts +2 -0
- package/dist/geometry/boolean/is-valid-point.d.ts +2 -0
- package/dist/geometry/boolean/is-valid-polygon-feature.d.ts +3 -0
- package/dist/geometry/boolean/point-in-polygon.d.ts +2 -2
- package/dist/geometry/boolean/self-intersects.d.ts +2 -2
- package/dist/geometry/centroid.d.ts +2 -2
- package/dist/geometry/coordinates-identical.d.ts +2 -2
- package/dist/geometry/get-coordinates-as-points.d.ts +6 -6
- package/dist/geometry/get-midpoints.d.ts +8 -7
- package/dist/geometry/helpers.d.ts +4 -4
- package/dist/geometry/limit-decimal-precision.d.ts +1 -1
- package/dist/geometry/measure/haversine-distance.d.ts +2 -2
- package/dist/geometry/measure/pixel-distance-to-line.d.ts +10 -10
- package/dist/geometry/measure/pixel-distance.d.ts +7 -7
- package/dist/geometry/measure/rhumb-bearing.d.ts +2 -2
- package/dist/geometry/measure/rhumb-destination.d.ts +2 -2
- package/dist/geometry/measure/rhumb-distance.d.ts +2 -2
- package/dist/geometry/midpoint-coordinate.d.ts +3 -2
- package/dist/geometry/shape/create-bbox.d.ts +10 -0
- package/dist/geometry/shape/create-circle.d.ts +7 -7
- package/dist/geometry/shape/great-circle-line.d.ts +12 -0
- package/dist/geometry/transform/rotate.d.ts +2 -2
- package/dist/geometry/transform/scale.d.ts +2 -2
- package/dist/modes/base.behavior.d.ts +19 -19
- package/dist/modes/base.mode.d.ts +62 -33
- package/dist/modes/circle/circle.mode.d.ts +55 -35
- package/dist/modes/click-bounding-box.behavior.d.ts +6 -7
- package/dist/modes/freehand/freehand.mode.d.ts +63 -37
- package/dist/modes/great-circle-snapping.behavior.d.ts +14 -0
- package/dist/modes/greatcircle/great-circle.mode.d.ts +64 -0
- package/dist/modes/linestring/linestring.mode.d.ts +67 -40
- package/dist/modes/pixel-distance.behavior.d.ts +7 -7
- package/dist/modes/point/point.mode.d.ts +44 -26
- package/dist/modes/polygon/behaviors/closing-points.behavior.d.ts +19 -19
- package/dist/modes/polygon/polygon.mode.d.ts +70 -49
- package/dist/modes/rectangle/rectangle.mode.d.ts +55 -0
- package/dist/modes/render/render.mode.d.ts +52 -23
- package/dist/modes/select/behaviors/drag-coordinate-resize.behavior.d.ts +28 -0
- package/dist/modes/select/behaviors/drag-coordinate.behavior.d.ts +20 -13
- package/dist/modes/select/behaviors/drag-feature.behavior.d.ts +20 -17
- package/dist/modes/select/behaviors/{features-at-mouse-event.behavior.d.ts → feature-at-pointer-event.behavior.d.ts} +15 -15
- package/dist/modes/select/behaviors/midpoint.behavior.d.ts +19 -18
- package/dist/modes/select/behaviors/rotate-feature.behavior.d.ts +14 -13
- package/dist/modes/select/behaviors/scale-feature.behavior.d.ts +14 -13
- package/dist/modes/select/behaviors/selection-point.behavior.d.ts +19 -18
- package/dist/modes/select/select.mode.d.ts +117 -78
- package/dist/modes/snapping.behavior.d.ts +16 -13
- package/dist/modes/static/static.mode.d.ts +32 -30
- package/dist/store/spatial-index/quickselect.d.ts +2 -2
- package/dist/store/spatial-index/rbush.d.ts +35 -35
- package/dist/store/spatial-index/spatial-index.d.ts +18 -18
- package/dist/store/store-feature-validation.d.ts +16 -0
- package/dist/store/store.d.ts +59 -48
- package/dist/terra-draw.cjs +1 -1
- package/dist/terra-draw.cjs.map +1 -1
- package/dist/terra-draw.d.ts +220 -48
- 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/util/geoms.d.ts +3 -3
- package/dist/util/id.d.ts +1 -1
- package/dist/util/styling.d.ts +2 -2
- package/e2e/README.md +29 -0
- package/e2e/package-lock.json +4249 -0
- package/e2e/package.json +26 -0
- package/e2e/playwright.config.ts +77 -0
- package/e2e/public/index.html +53 -0
- package/e2e/src/index.ts +165 -0
- package/e2e/tests/leaflet.spec.ts +413 -0
- package/e2e/tests/setup.ts +164 -0
- package/e2e/webpack.config.js +36 -0
- package/jest.nocheck.config.ts +17 -0
- package/package.json +157 -87
- package/readme.gif +0 -0
- package/tsconfig.json +17 -12
- package/CODE_OF_CONDUCT.md +0 -36
- package/CONTRIBUTING.md +0 -17
- package/DEVELOPMENT.md +0 -77
- package/dist/bundle.js +0 -6
- package/dist/bundle.js.LICENSE.txt +0 -4
- package/dist/geometry/create-circle.d.ts +0 -6
- package/dist/geometry/get-pixel-distance-to-line.d.ts +0 -10
- package/dist/geometry/get-pixel-distance.d.ts +0 -7
- package/dist/geometry/haversine-distance.d.ts +0 -1
- package/dist/geometry/point-in-polygon.d.ts +0 -1
- package/dist/geometry/self-intersects.d.ts +0 -2
- package/dist/modes/circle.mode.d.ts +0 -18
- package/dist/modes/freehand.mode.d.ts +0 -20
- package/dist/modes/line-string.mode.d.ts +0 -21
- package/dist/modes/point.mode.d.ts +0 -14
- package/dist/modes/polygon/behaviors/start-end-point.behavior.d.ts +0 -11
- package/dist/modes/polygon.mode.d.ts +0 -21
- package/dist/modes/select.mode.d.ts +0 -21
- package/dist/modes/static.mode.d.ts +0 -10
- package/jest.config.ts +0 -27
package/package.json
CHANGED
|
@@ -1,88 +1,158 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
2
|
+
"name": "terra-draw",
|
|
3
|
+
"version": "0.0.1-alpha.61",
|
|
4
|
+
"description": "Frictionless map drawing across mapping provider",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"docs": "typedoc",
|
|
7
|
+
"docs:serve": "serve ./docs",
|
|
8
|
+
"release": "standard-version",
|
|
9
|
+
"release:alpha:changelog": "tsx ./scripts/changelog-valid.ts",
|
|
10
|
+
"release:alpha:next": "tsx ./scripts/next-alpha-version.ts",
|
|
11
|
+
"build": "microbundle",
|
|
12
|
+
"watch": "microbundle --watch --format modern",
|
|
13
|
+
"test": "jest --config jest.config.ts",
|
|
14
|
+
"test:coverage": "jest --config jest.config.ts --coverage",
|
|
15
|
+
"test:nocheck": "jest --config jest.nocheck.config.ts",
|
|
16
|
+
"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/",
|
|
21
|
+
"format": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\"",
|
|
22
|
+
"format:quiet": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\" --log-level=silent",
|
|
23
|
+
"prepare": "husky install"
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"source": "src/terra-draw.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
"types": "./dist/terra-draw.d.ts",
|
|
29
|
+
"require": "./dist/terra-draw.cjs",
|
|
30
|
+
"default": "./dist/terra-draw.modern.js"
|
|
31
|
+
},
|
|
32
|
+
"types": "./dist/terra-draw.d.ts",
|
|
33
|
+
"main": "./dist/terra-draw.cjs",
|
|
34
|
+
"module": "./dist/terra-draw.module.js",
|
|
35
|
+
"unpkg": "./dist/terra-draw.umd.js",
|
|
36
|
+
"author": "James Milner",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"repository": "JamesLMilner/terra-draw",
|
|
39
|
+
"keywords": [
|
|
40
|
+
"map",
|
|
41
|
+
"drawing",
|
|
42
|
+
"draw",
|
|
43
|
+
"map drawing",
|
|
44
|
+
"geometry",
|
|
45
|
+
"leaflet",
|
|
46
|
+
"leafletjs",
|
|
47
|
+
"mapbox",
|
|
48
|
+
"mapboxgl",
|
|
49
|
+
"google maps",
|
|
50
|
+
"openlayers",
|
|
51
|
+
"maplibre"
|
|
52
|
+
],
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@arcgis/core": "^4.27.6",
|
|
55
|
+
"@commitlint/cli": "^17.1.2",
|
|
56
|
+
"@commitlint/config-conventional": "^17.1.0",
|
|
57
|
+
"@googlemaps/js-api-loader": "^1.14.3",
|
|
58
|
+
"@swc/jest": "^0.2.29",
|
|
59
|
+
"@types/geojson": "^7946.0.8",
|
|
60
|
+
"@types/google.maps": "^3.49.2",
|
|
61
|
+
"@types/jest": "^28.1.5",
|
|
62
|
+
"@types/leaflet": "^1.7.11",
|
|
63
|
+
"@types/mapbox-gl": "^2.7.3",
|
|
64
|
+
"@types/rbush": "^3.0.0",
|
|
65
|
+
"@typescript-eslint/eslint-plugin": "^6.7.4",
|
|
66
|
+
"@typescript-eslint/parser": "^6.7.4",
|
|
67
|
+
"eslint": "^8.24.0",
|
|
68
|
+
"eslint-config-prettier": "^9.0.0",
|
|
69
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
70
|
+
"husky": "^7.0.0",
|
|
71
|
+
"jest": "^29.3.1",
|
|
72
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
73
|
+
"leaflet": "^1.8.0",
|
|
74
|
+
"mapbox-gl": "^2.13.0",
|
|
75
|
+
"maplibre-gl": "3.2.0",
|
|
76
|
+
"microbundle": "^0.15.0",
|
|
77
|
+
"ol": "^7.1.0",
|
|
78
|
+
"serve": "^14.1.2",
|
|
79
|
+
"standard-version": "^9.5.0",
|
|
80
|
+
"ts-jest": "^29.1.0",
|
|
81
|
+
"ts-loader": "^9.4.2",
|
|
82
|
+
"tsx": "^4.7.0",
|
|
83
|
+
"typedoc": "^0.25.1",
|
|
84
|
+
"typescript": "^5.2.2"
|
|
85
|
+
},
|
|
86
|
+
"commitlint": {
|
|
87
|
+
"extends": [
|
|
88
|
+
"@commitlint/config-conventional"
|
|
89
|
+
]
|
|
90
|
+
},
|
|
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
|
+
"prettier": {
|
|
106
|
+
"printWidth": 80,
|
|
107
|
+
"semi": true,
|
|
108
|
+
"useTabs": true
|
|
109
|
+
},
|
|
110
|
+
"standard-version": {
|
|
111
|
+
"types": [
|
|
112
|
+
{
|
|
113
|
+
"type": "feat",
|
|
114
|
+
"section": "Features"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"type": "fix",
|
|
118
|
+
"section": "Bug Fixes"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"type": "docs",
|
|
122
|
+
"section": "Documentation"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"type": "style",
|
|
126
|
+
"section": "Styling"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"type": "refactor",
|
|
130
|
+
"section": "Refactors"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"type": "perf",
|
|
134
|
+
"section": "Performance"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"type": "test",
|
|
138
|
+
"section": "Tests"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"type": "build",
|
|
142
|
+
"section": "Build System"
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"type": "ci",
|
|
146
|
+
"section": "CI"
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"type": "chore",
|
|
150
|
+
"section": "Chore"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"type": "revert",
|
|
154
|
+
"section": "Reverts"
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
}
|
package/readme.gif
ADDED
|
Binary file
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "./dist/",
|
|
4
|
+
"strict": true,
|
|
5
|
+
"module": "es6",
|
|
6
|
+
"target": "es6",
|
|
7
|
+
"jsx": "react",
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"allowJs": true,
|
|
10
|
+
"moduleResolution": "node",
|
|
11
|
+
"allowSyntheticDefaultImports": true
|
|
12
|
+
},
|
|
13
|
+
"typedocOptions": {
|
|
14
|
+
"entryPoints": ["src/terra-draw.ts"],
|
|
15
|
+
"exclude": ["src/geometry/**/*.ts", "src/test/**/*.ts", "src/util/**/*.ts"],
|
|
16
|
+
"out": "docs",
|
|
17
|
+
"skipErrorChecking": true
|
|
18
|
+
}
|
|
14
19
|
}
|
package/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
Contributor Covenant Code of Conduct
|
|
2
|
-
Our Pledge
|
|
3
|
-
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
|
4
|
-
|
|
5
|
-
Our Standards
|
|
6
|
-
Examples of behavior that contributes to creating a positive environment include:
|
|
7
|
-
|
|
8
|
-
Using welcoming and inclusive language
|
|
9
|
-
Being respectful of differing viewpoints and experiences
|
|
10
|
-
Gracefully accepting constructive criticism
|
|
11
|
-
Focusing on what is best for the community
|
|
12
|
-
Showing empathy towards other community members
|
|
13
|
-
Examples of unacceptable behavior by participants include:
|
|
14
|
-
|
|
15
|
-
The use of sexualized language or imagery and unwelcome sexual attention or advances
|
|
16
|
-
Trolling, insulting/derogatory comments, and personal or political attacks
|
|
17
|
-
Public or private harassment
|
|
18
|
-
Publishing others' private information, such as a physical or electronic address, without explicit permission
|
|
19
|
-
Other conduct which could reasonably be considered inappropriate in a professional setting
|
|
20
|
-
Our Responsibilities
|
|
21
|
-
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
|
22
|
-
|
|
23
|
-
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
|
24
|
-
|
|
25
|
-
Scope
|
|
26
|
-
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
|
27
|
-
|
|
28
|
-
Enforcement
|
|
29
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at codeofconduct@loxo.industries. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
|
30
|
-
|
|
31
|
-
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
|
32
|
-
|
|
33
|
-
Attribution
|
|
34
|
-
This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
|
35
|
-
|
|
36
|
-
For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq
|
package/CONTRIBUTING.md
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
# Contributing
|
|
2
|
-
|
|
3
|
-
## Instructions
|
|
4
|
-
|
|
5
|
-
This document will receive a more thorough update in the future. For the time being, if you wish to contribute to Terra Draw, we request that you:
|
|
6
|
-
|
|
7
|
-
1) Make an issue on GitHub describing the bug you intend to fix or the feature you intend to add.
|
|
8
|
-
2) Create a fork of the project, and work on a branch that represents the issue
|
|
9
|
-
3) Ensure that the work you have done is unit tested, aiming for 80% code coverage
|
|
10
|
-
4) Create a PR that represents this work. Please refer to the issue from the PR
|
|
11
|
-
5) We will address the PR and give you feedback
|
|
12
|
-
|
|
13
|
-
Please note that we can not garauntee that all PRs will be merged. There are cases where a PR may deviate from the long-term vision for Terra Draw and hence we may have to decline it. Creating the issue in advance helps us discuss any potential issues upfront before the PR is made.
|
|
14
|
-
|
|
15
|
-
## Code of Conduct
|
|
16
|
-
|
|
17
|
-
We have a code of conduct which we expect individuals interacting with the project to respect. Please see the [full Code of Conduct in the repository](./CODE_OF_CONDUCT.md).
|
package/DEVELOPMENT.md
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
# Development
|
|
2
|
-
|
|
3
|
-
This file acts as a way to document how to develop the Terra Draw project locally.
|
|
4
|
-
|
|
5
|
-
### Prerequisites
|
|
6
|
-
|
|
7
|
-
A few things you will need to have installed in order to develop on this project:
|
|
8
|
-
|
|
9
|
-
* git
|
|
10
|
-
* Node LTS - currently v16
|
|
11
|
-
* npm 8
|
|
12
|
-
|
|
13
|
-
### Folder Structure
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* `.github` - used for all GitHub related configuration such as the GitHub Actions work flows
|
|
17
|
-
* `.husky` - used to storing the precommit hooks that are used on the project
|
|
18
|
-
* `src` - source files for the project
|
|
19
|
-
* `dist` - the bundled distributed files of the project
|
|
20
|
-
* `docs` - the demo app that is published to GitHub pages
|
|
21
|
-
* `development` - the local development app that is used for developing locally (see below)
|
|
22
|
-
* `common` - code that is used across `development` and `docs` folder`
|
|
23
|
-
|
|
24
|
-
### Technologies Used
|
|
25
|
-
|
|
26
|
-
Terra Draw
|
|
27
|
-
|
|
28
|
-
* [TypeScript](https://www.typescriptlang.org/) - provides strong compile time typing for JavaScript
|
|
29
|
-
* Jest - used for testing (see more information below)
|
|
30
|
-
* microbundle - used for the production bundle
|
|
31
|
-
* Webpack - used for bundling locally in development (`development` and `docs` folders)
|
|
32
|
-
* esno - for running tests quickly without type checking
|
|
33
|
-
|
|
34
|
-
### Precommit Hooks
|
|
35
|
-
|
|
36
|
-
It is probably useful to be aware of the precommit hooks you will face when trying to run a git commit on the project. There are two currently in use, namely:
|
|
37
|
-
|
|
38
|
-
* Uses pre-commit hook to run lint rules (eslint/prettier) on code before commit
|
|
39
|
-
* Uses pre-commit hook to ensure [conventional commit messages](https://www.conventionalcommits.org/en/v1.0.0/) are used
|
|
40
|
-
|
|
41
|
-
### Testing
|
|
42
|
-
|
|
43
|
-
Terra Draw uses [jest](https://jestjs.io/) as it's testing framework. You can distinguish a test by it's `.spec.ts` prefix on the file name.
|
|
44
|
-
|
|
45
|
-
To run the tests as they would run in CI:
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
npm run test
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
You can also check the coverage by running:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
```
|
|
55
|
-
npm run test:coverage
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
For local development you may benefit from the `nocheck` option which allows you to avoid running TypeScript type checking when running the tests. This option also only checks files which are explicitly tested (i.e. have a spec file.)
|
|
59
|
-
|
|
60
|
-
```
|
|
61
|
-
npm run test:nocheck
|
|
62
|
-
npm run test:nocheck:coverage
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Developing Locally
|
|
66
|
-
|
|
67
|
-
A folder called `development` has been set up locally to allow you to test developing Terra Draw locally more easily. It allows you to run the different adapters and test different map providers in parallel, ensuring. You will need to update the .env file in the `development` folder in order to use the related adapters working. An example `.env` file in the `development` folder:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
```
|
|
71
|
-
GOOGLE_API_KEY=YOUR_KEY_HERE
|
|
72
|
-
MAPBOX_ACCESS_TOKEN=YOUR_KEY_HERE
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### GitHub Pages Example
|
|
76
|
-
|
|
77
|
-
We also provide a GitHub Pages example that can developed on in the `docs` folder. This automatically deploys from the `main` branch.
|
package/dist/bundle.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function haversineDistanceKilometers(pointOne: [lng: number, lat: number], pointTwo: [lng: number, lat: number]): number;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function pointInPolygon(point: [number, number], rings: [number, number][][]): boolean;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { TerraDrawMouseEvent, TerraDrawMode, TerraDrawModeRegisterConfig, TerraDrawAdapterStyling, TerraDrawKeyboardEvent } from "../common";
|
|
2
|
-
export declare class TerraDrawCircleMode implements TerraDrawMode {
|
|
3
|
-
mode: string;
|
|
4
|
-
private store;
|
|
5
|
-
private project;
|
|
6
|
-
private center;
|
|
7
|
-
private clickCount;
|
|
8
|
-
private currentCircleId;
|
|
9
|
-
constructor(options?: {
|
|
10
|
-
styling?: Partial<TerraDrawAdapterStyling>;
|
|
11
|
-
});
|
|
12
|
-
styling: TerraDrawAdapterStyling;
|
|
13
|
-
register(config: TerraDrawModeRegisterConfig): void;
|
|
14
|
-
onClick(event: TerraDrawMouseEvent): void;
|
|
15
|
-
onMouseMove(event: TerraDrawMouseEvent): void;
|
|
16
|
-
onKeyPress(event: TerraDrawKeyboardEvent): void;
|
|
17
|
-
cleanUp(): void;
|
|
18
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { TerraDrawMouseEvent, TerraDrawMode, TerraDrawModeRegisterConfig, TerraDrawAdapterStyling, TerraDrawKeyboardEvent } from "../common";
|
|
2
|
-
export declare class TerraDrawFreehandMode implements TerraDrawMode {
|
|
3
|
-
mode: string;
|
|
4
|
-
private store;
|
|
5
|
-
private project;
|
|
6
|
-
private startingClick;
|
|
7
|
-
private currentId;
|
|
8
|
-
private skip;
|
|
9
|
-
private everyNthMouseEvent;
|
|
10
|
-
constructor(options?: {
|
|
11
|
-
styling?: Partial<TerraDrawAdapterStyling>;
|
|
12
|
-
everyNthMouseEvent?: number;
|
|
13
|
-
});
|
|
14
|
-
styling: TerraDrawAdapterStyling;
|
|
15
|
-
register(config: TerraDrawModeRegisterConfig): void;
|
|
16
|
-
onMouseMove(event: TerraDrawMouseEvent): void;
|
|
17
|
-
onClick(event: TerraDrawMouseEvent): void;
|
|
18
|
-
onKeyPress(event: TerraDrawKeyboardEvent): void;
|
|
19
|
-
cleanUp(): void;
|
|
20
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { TerraDrawMouseEvent, TerraDrawMode, TerraDrawModeRegisterConfig, TerraDrawAdapterStyling, TerraDrawKeyboardEvent } from "../common";
|
|
2
|
-
export declare class TerraDrawLineStringMode implements TerraDrawMode {
|
|
3
|
-
mode: string;
|
|
4
|
-
private store;
|
|
5
|
-
private project;
|
|
6
|
-
private pointerDistance;
|
|
7
|
-
private currentCoordinate;
|
|
8
|
-
private currentId;
|
|
9
|
-
private allowSelfIntersections;
|
|
10
|
-
constructor(options?: {
|
|
11
|
-
allowSelfIntersections?: boolean;
|
|
12
|
-
styling?: Partial<TerraDrawAdapterStyling>;
|
|
13
|
-
pointerDistance?: number;
|
|
14
|
-
});
|
|
15
|
-
styling: TerraDrawAdapterStyling;
|
|
16
|
-
register(config: TerraDrawModeRegisterConfig): void;
|
|
17
|
-
onMouseMove(event: TerraDrawMouseEvent): void;
|
|
18
|
-
onClick(event: TerraDrawMouseEvent): void;
|
|
19
|
-
onKeyPress(event: TerraDrawKeyboardEvent): void;
|
|
20
|
-
cleanUp(): void;
|
|
21
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { TerraDrawMouseEvent, TerraDrawMode, TerraDrawModeRegisterConfig, TerraDrawAdapterStyling } from "../common";
|
|
2
|
-
export declare class TerraDrawPointMode implements TerraDrawMode {
|
|
3
|
-
mode: string;
|
|
4
|
-
private store;
|
|
5
|
-
constructor(options?: {
|
|
6
|
-
styling?: Partial<TerraDrawAdapterStyling>;
|
|
7
|
-
});
|
|
8
|
-
styling: TerraDrawAdapterStyling;
|
|
9
|
-
register(config: TerraDrawModeRegisterConfig): void;
|
|
10
|
-
onClick(event: TerraDrawMouseEvent): void;
|
|
11
|
-
onMouseMove(): void;
|
|
12
|
-
onKeyPress(): void;
|
|
13
|
-
cleanUp(): void;
|
|
14
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Position } from "geojson";
|
|
2
|
-
import { BehaviorConfig, TerraDrawModeBehavior } from "../../base.behavior";
|
|
3
|
-
export declare class StartEndPointBehavior extends TerraDrawModeBehavior {
|
|
4
|
-
constructor(config: BehaviorConfig);
|
|
5
|
-
private _startEndPoints;
|
|
6
|
-
get ids(): string[];
|
|
7
|
-
set ids(_: string[]);
|
|
8
|
-
create(selectedCoords: Position[], mode: string): void;
|
|
9
|
-
delete(): void;
|
|
10
|
-
update(updatedCoordinates: Position[]): void;
|
|
11
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { TerraDrawMouseEvent, TerraDrawMode, TerraDrawModeRegisterConfig, TerraDrawAdapterStyling, TerraDrawKeyboardEvent } from "../common";
|
|
2
|
-
export declare class TerraDrawPolygonMode implements TerraDrawMode {
|
|
3
|
-
mode: string;
|
|
4
|
-
private store;
|
|
5
|
-
private project;
|
|
6
|
-
private currentCoordinate;
|
|
7
|
-
private currentId;
|
|
8
|
-
private allowSelfIntersections;
|
|
9
|
-
private pointerDistance;
|
|
10
|
-
constructor(options?: {
|
|
11
|
-
allowSelfIntersections?: boolean;
|
|
12
|
-
styling?: Partial<TerraDrawAdapterStyling>;
|
|
13
|
-
pointerDistance?: number;
|
|
14
|
-
});
|
|
15
|
-
styling: TerraDrawAdapterStyling;
|
|
16
|
-
register(config: TerraDrawModeRegisterConfig): void;
|
|
17
|
-
onMouseMove(event: TerraDrawMouseEvent): void;
|
|
18
|
-
onClick(event: TerraDrawMouseEvent): void;
|
|
19
|
-
onKeyPress(event: TerraDrawKeyboardEvent): void;
|
|
20
|
-
cleanUp(): void;
|
|
21
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { TerraDrawMouseEvent, TerraDrawMode, TerraDrawModeRegisterConfig, TerraDrawKeyboardEvent, TerraDrawAdapterStyling } from "../common";
|
|
2
|
-
export declare class TerraDrawSelectMode implements TerraDrawMode {
|
|
3
|
-
mode: string;
|
|
4
|
-
private store;
|
|
5
|
-
private project;
|
|
6
|
-
private selected;
|
|
7
|
-
private pointerDistance;
|
|
8
|
-
private selectionPoints;
|
|
9
|
-
constructor(options?: {
|
|
10
|
-
styling?: Partial<TerraDrawAdapterStyling>;
|
|
11
|
-
pointerDistance?: number;
|
|
12
|
-
});
|
|
13
|
-
styling: TerraDrawAdapterStyling;
|
|
14
|
-
onClick(event: TerraDrawMouseEvent): void;
|
|
15
|
-
onKeyPress(event: TerraDrawKeyboardEvent): void;
|
|
16
|
-
cleanUp(): void;
|
|
17
|
-
onMouseMove(): void;
|
|
18
|
-
register(config: TerraDrawModeRegisterConfig): void;
|
|
19
|
-
onDeselect(deselectedId: string): void;
|
|
20
|
-
onSelect(selectedId: string): void;
|
|
21
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { TerraDrawAdapterStyling, TerraDrawMode } from "../common";
|
|
2
|
-
export declare class TerraDrawStaticMode implements TerraDrawMode {
|
|
3
|
-
mode: string;
|
|
4
|
-
styling: TerraDrawAdapterStyling;
|
|
5
|
-
register(): void;
|
|
6
|
-
onKeyPress(): void;
|
|
7
|
-
onClick(): void;
|
|
8
|
-
onMouseMove(): void;
|
|
9
|
-
cleanUp(): void;
|
|
10
|
-
}
|
package/jest.config.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
let options = {}
|
|
3
|
-
|
|
4
|
-
if (process.env.NO_CHECK) {
|
|
5
|
-
options = {
|
|
6
|
-
"transform": {
|
|
7
|
-
"^.+\\.(t|j)sx?$": "@swc/jest"
|
|
8
|
-
},
|
|
9
|
-
"setupFilesAfterEnv": ["<rootDir>/src/test/jest.matchers.ts"],
|
|
10
|
-
}
|
|
11
|
-
} else {
|
|
12
|
-
options = {
|
|
13
|
-
"preset": "ts-jest",
|
|
14
|
-
"testEnvironment": "node",
|
|
15
|
-
"coveragePathIgnorePatterns": ["<rootDir>/src/test/"],
|
|
16
|
-
"setupFilesAfterEnv": ["<rootDir>/src/test/jest.matchers.ts"],
|
|
17
|
-
"collectCoverage": true,
|
|
18
|
-
"collectCoverageFrom": ["./src/**"],
|
|
19
|
-
"coverageThreshold": {
|
|
20
|
-
"global": {
|
|
21
|
-
"lines": 65
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
module.exports = options
|