@versatiles/svelte 1.1.1 → 2.0.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.
Files changed (53) hide show
  1. package/dist/components/BBoxMap/AutoComplete.svelte +0 -1
  2. package/dist/components/BBoxMap/BBoxMap.svelte +1 -2
  3. package/dist/{utils/draw → components/BBoxMap/lib}/bbox.d.ts +1 -2
  4. package/dist/components/BasicMap/BasicMap.svelte +7 -9
  5. package/dist/components/BasicMap/BasicMap.svelte.d.ts +5 -4
  6. package/dist/components/LocatorMap/LocatorMap.svelte +0 -2
  7. package/dist/components/MapEditor/MapEditor.svelte +16 -3
  8. package/dist/components/MapEditor/components/Editor.svelte +46 -39
  9. package/dist/components/MapEditor/components/Editor.svelte.d.ts +1 -1
  10. package/dist/components/MapEditor/components/EditorFill.svelte +7 -9
  11. package/dist/components/MapEditor/components/EditorStroke.svelte +9 -11
  12. package/dist/components/MapEditor/components/EditorSymbol.svelte +23 -19
  13. package/dist/components/MapEditor/components/InputRow.svelte +34 -0
  14. package/dist/components/MapEditor/components/InputRow.svelte.d.ts +9 -0
  15. package/dist/components/MapEditor/components/Sidebar.svelte +116 -111
  16. package/dist/components/MapEditor/components/SidebarPanel.svelte +92 -0
  17. package/dist/components/MapEditor/components/SidebarPanel.svelte.d.ts +10 -0
  18. package/dist/components/MapEditor/components/SymbolSelector.svelte +7 -15
  19. package/dist/components/MapEditor/lib/element/abstract.d.ts +3 -3
  20. package/dist/components/MapEditor/lib/element/abstract.js +1 -1
  21. package/dist/components/MapEditor/lib/element/line.d.ts +3 -4
  22. package/dist/components/MapEditor/lib/element/line.js +0 -1
  23. package/dist/components/MapEditor/lib/element/marker.d.ts +4 -4
  24. package/dist/components/MapEditor/lib/element/polygon.d.ts +3 -3
  25. package/dist/components/MapEditor/lib/geometry_manager.d.ts +20 -10
  26. package/dist/components/MapEditor/lib/geometry_manager.js +46 -52
  27. package/dist/components/MapEditor/lib/map_layer/abstract.d.ts +4 -3
  28. package/dist/components/MapEditor/lib/map_layer/abstract.js +30 -12
  29. package/dist/components/MapEditor/lib/map_layer/fill.d.ts +4 -3
  30. package/dist/components/MapEditor/lib/map_layer/fill.js +9 -8
  31. package/dist/components/MapEditor/lib/map_layer/line.d.ts +4 -3
  32. package/dist/components/MapEditor/lib/map_layer/line.js +15 -14
  33. package/dist/components/MapEditor/lib/map_layer/symbol.d.ts +21 -10
  34. package/dist/components/MapEditor/lib/map_layer/symbol.js +72 -31
  35. package/dist/components/MapEditor/lib/state/constants.d.ts +4 -0
  36. package/dist/components/MapEditor/lib/state/constants.js +22 -0
  37. package/dist/components/MapEditor/lib/state/manager.d.ts +16 -0
  38. package/dist/components/MapEditor/lib/state/manager.js +76 -0
  39. package/dist/components/MapEditor/lib/state/reader.d.ts +21 -14
  40. package/dist/components/MapEditor/lib/state/reader.js +259 -139
  41. package/dist/components/MapEditor/lib/state/types.d.ts +28 -12
  42. package/dist/components/MapEditor/lib/state/writer.d.ts +18 -14
  43. package/dist/components/MapEditor/lib/state/writer.js +183 -156
  44. package/dist/components/MapEditor/lib/utils.d.ts +2 -5
  45. package/dist/components/MapEditor/lib/utils.js +0 -19
  46. package/package.json +28 -27
  47. package/dist/components/MapEditor/lib/__mocks__/cursor.d.ts +0 -5
  48. package/dist/components/MapEditor/lib/__mocks__/cursor.js +0 -6
  49. package/dist/components/MapEditor/lib/__mocks__/geometry_manager.d.ts +0 -22
  50. package/dist/components/MapEditor/lib/__mocks__/geometry_manager.js +0 -21
  51. package/dist/components/MapEditor/lib/__mocks__/map.d.ts +0 -36
  52. package/dist/components/MapEditor/lib/__mocks__/map.js +0 -26
  53. /package/dist/{utils/draw → components/BBoxMap/lib}/bbox.js +0 -0
@@ -1,178 +1,205 @@
1
1
  import { Color } from '@versatiles/style';
2
- import { compress, uint8ArrayToBase64 } from '../utils.js';
3
- const chunkSize = 65536;
2
+ import { BASE64_CHARS, CHAR_CODE2VALUE } from './constants.js';
3
+ import { StateReader } from './reader.js';
4
4
  export class StateWriter {
5
- buffer = new Uint8Array(chunkSize);
6
- offset = 0;
5
+ bits = [];
7
6
  constructor() { }
8
- writeByte(num) {
9
- if (this.offset >= this.buffer.length) {
10
- const newBuffer = new Uint8Array(this.buffer.length + chunkSize);
11
- newBuffer.set(this.buffer);
12
- this.buffer = newBuffer;
7
+ asBase64() {
8
+ const reader = new StateReader(this.bits);
9
+ const chars = [];
10
+ while (!reader.ended()) {
11
+ chars.push(BASE64_CHARS[reader.read6pack()]);
13
12
  }
14
- this.buffer[this.offset++] = num;
13
+ return chars.join('');
15
14
  }
16
- writeUnsignedInteger(i) {
17
- if (!Number.isSafeInteger(i)) {
18
- throw new RangeError(`Number out of safe integer range: ${i}`);
19
- }
20
- while (i > 0x7f) {
21
- this.writeByte((i & 0x7f) | 0x80);
22
- i >>>= 7;
15
+ asBitString() {
16
+ return this.bits.map((bit) => (bit ? '1' : '0')).join('');
17
+ }
18
+ writeBit(value) {
19
+ this.bits.push(value);
20
+ }
21
+ writeInteger(value, bits) {
22
+ if (value % 1 !== 0)
23
+ throw new Error('value must be an integer');
24
+ for (let i = bits - 1; i >= 0; i--) {
25
+ this.bits.push((value & (1 << i)) > 0);
23
26
  }
24
- this.writeByte(i);
27
+ return value;
25
28
  }
26
- writeSignedInteger(i) {
27
- if (!Number.isSafeInteger(i)) {
28
- throw new RangeError(`Number out of safe integer range: ${i}`);
29
+ writeVarint(value, signed) {
30
+ if (value % 1 !== 0)
31
+ throw new Error('value must be an integer');
32
+ if (signed) {
33
+ value = value < 0 ? ((-1 - value) << 1) | 1 : value << 1;
34
+ }
35
+ else {
36
+ if (value < 0)
37
+ throw new Error('Unsigned varint cannot be negative');
38
+ }
39
+ while (true) {
40
+ this.writeInteger(value & 0x1f, 5);
41
+ value >>= 5;
42
+ this.writeBit(value >= 1);
43
+ if (value < 1)
44
+ break;
29
45
  }
30
- this.writeUnsignedInteger(i < 0 ? -i * 2 - 1 : i * 2);
31
46
  }
32
- writeString(str) {
33
- const length = str.length;
34
- this.writeUnsignedInteger(length);
47
+ writeArray(array, cb) {
48
+ const length = array.length;
49
+ this.writeVarint(length);
35
50
  for (let i = 0; i < length; i++)
36
- this.writeUnsignedInteger(str.charCodeAt(i));
37
- }
38
- writeBoolean(b) {
39
- this.writeByte(b ? 1 : 0);
51
+ cb(array[i]);
40
52
  }
41
- getBase64() {
42
- return uint8ArrayToBase64(this.getBuffer());
53
+ writePoint(point, level = 14) {
54
+ const scale = Math.pow(2, level + 2);
55
+ this.writeInteger(Math.round(point[0] * scale), level + 11);
56
+ this.writeInteger(Math.round(point[1] * scale), level + 10);
43
57
  }
44
- async getBase64compressed() {
45
- return uint8ArrayToBase64(await compress(this.getBuffer()));
46
- }
47
- getBuffer() {
48
- return this.buffer.slice(0, this.offset);
58
+ writePoints(points, level = 14) {
59
+ this.writeVarint(points.length);
60
+ const scale = Math.pow(2, level + 2);
61
+ let x = 0;
62
+ let y = 0;
63
+ points.forEach((point) => {
64
+ const xi = Math.round(point[0] * scale);
65
+ const yi = Math.round(point[1] * scale);
66
+ this.writeVarint(xi - x, true);
67
+ this.writeVarint(yi - y, true);
68
+ x = xi;
69
+ y = yi;
70
+ });
49
71
  }
50
- writeObject(state) {
51
- // eslint-disable-next-line @typescript-eslint/no-this-alias
52
- const me = this;
53
- Object.entries(state).forEach(([key, value]) => {
54
- if (value == null)
55
- return;
56
- switch (key) {
57
- case 'map':
58
- writeObject(10, value);
59
- break;
60
- case 'style':
61
- writeObject(11, value);
62
- break;
63
- case 'strokeStyle':
64
- writeObject(12, value);
65
- break;
66
- case 'elements':
67
- if (!Array.isArray(value))
68
- throw new Error(`Invalid elements: ${value}`);
69
- this.writeByte(20);
70
- this.writeUnsignedInteger(value.length);
71
- value.forEach((element) => this.writeObject(element));
72
- break;
73
- case 'point':
74
- if (!Array.isArray(value) || value.length !== 2)
75
- throw new Error(`Invalid point: ${value}`);
76
- this.writeByte(30);
77
- me.writeSignedInteger(Math.round(value[0] * 1e5));
78
- me.writeSignedInteger(Math.round(value[1] * 1e5));
79
- break;
80
- case 'points':
81
- if (!Array.isArray(value))
82
- throw new Error(`Invalid points: ${value}`);
83
- this.writeByte(31);
84
- this.writeUnsignedInteger(value.length);
85
- this.writeDifferential(value.map((p) => Math.round(p[0] * 1e5)));
86
- this.writeDifferential(value.map((p) => Math.round(p[1] * 1e5)));
87
- break;
88
- case 'color':
89
- this.writeByte(40);
90
- this.writeColor(value);
91
- break;
92
- case 'type':
93
- this.writeByte(50);
94
- switch (value) {
95
- case 'marker':
96
- this.writeByte(0);
97
- break;
98
- case 'line':
99
- this.writeByte(1);
100
- break;
101
- case 'polygon':
102
- this.writeByte(2);
103
- break;
104
- default:
105
- throw new Error(`Invalid type: ${value}`);
106
- }
107
- break;
108
- case 'label':
109
- if (typeof value !== 'string')
110
- throw new Error(`Invalid string: ${value}`);
111
- this.writeByte(60);
112
- this.writeString(value);
113
- break;
114
- case 'halo':
115
- writeInteger(70, value, 10);
116
- break;
117
- case 'opacity':
118
- writeInteger(71, value, 100);
119
- break;
120
- case 'pattern':
121
- writeInteger(72, value);
122
- break;
123
- case 'rotate':
124
- writeInteger(73, value);
125
- break;
126
- case 'size':
127
- writeInteger(74, value, 10);
128
- break;
129
- case 'width':
130
- writeInteger(75, value, 10);
131
- break;
132
- case 'zoom':
133
- writeInteger(76, value, 20);
134
- break;
135
- case 'visible':
136
- if (typeof value !== 'boolean')
137
- throw new Error(`Invalid boolean: ${value}`);
138
- this.writeByte(90);
139
- this.writeBoolean(value);
72
+ writeRoot(root) {
73
+ // Write the version
74
+ this.writeInteger(0, 3);
75
+ if (root.map) {
76
+ this.writeBit(true);
77
+ this.writeMap(root.map);
78
+ }
79
+ else {
80
+ this.writeBit(false);
81
+ }
82
+ // metadata is not used yet
83
+ this.writeBit(false);
84
+ root.elements.forEach((element) => {
85
+ switch (element.type) {
86
+ case 'marker':
87
+ this.writeInteger(1, 3);
88
+ this.writeElementMarker(element);
89
+ break;
90
+ case 'line':
91
+ this.writeInteger(2, 3);
92
+ this.writeElementLine(element);
93
+ break;
94
+ case 'polygon':
95
+ this.writeInteger(3, 3);
96
+ this.writeElementPolygon(element);
140
97
  break;
141
- default:
142
- throw new Error(`Invalid state key: ${key}`);
143
98
  }
144
99
  });
145
- this.writeByte(0);
146
- function writeObject(id, obj) {
147
- if (typeof obj !== 'object' || obj == null)
148
- throw new Error(`Invalid object: ${obj}`);
149
- me.writeByte(id);
150
- me.writeObject(obj);
151
- }
152
- function writeInteger(id, obj, factor = 1) {
153
- if (typeof obj !== 'number')
154
- throw new Error(`Invalid number: ${obj}`);
155
- const value = Math.round(obj);
156
- if (value < 0)
157
- throw new Error(`Negative Number: ${obj}`);
158
- me.writeByte(id);
159
- me.writeUnsignedInteger(value * factor);
100
+ }
101
+ writeMap(map) {
102
+ this.writeInteger(Math.round(map.zoom * 32), 10);
103
+ this.writePoint(map.center, Math.ceil(map.zoom));
104
+ }
105
+ writeElementMarker(element) {
106
+ this.writePoint(element.point);
107
+ if (element.style) {
108
+ this.writeBit(true);
109
+ this.writeStyle(element.style);
110
+ }
111
+ else {
112
+ this.writeBit(false);
113
+ }
114
+ return element;
115
+ }
116
+ writeElementLine(element) {
117
+ this.writePoints(element.points);
118
+ if (element.style) {
119
+ this.writeBit(true);
120
+ this.writeStyle(element.style);
121
+ }
122
+ else {
123
+ this.writeBit(false);
124
+ }
125
+ return element;
126
+ }
127
+ writeElementPolygon(element) {
128
+ this.writePoints(element.points);
129
+ if (element.style) {
130
+ this.writeBit(true);
131
+ this.writeStyle(element.style);
132
+ }
133
+ else {
134
+ this.writeBit(false);
135
+ }
136
+ if (element.strokeStyle) {
137
+ this.writeBit(true);
138
+ this.writeStyle(element.strokeStyle);
139
+ }
140
+ else {
141
+ this.writeBit(false);
160
142
  }
161
143
  }
144
+ writeStyle(style) {
145
+ if (style.halo != null) {
146
+ this.writeInteger(1, 4);
147
+ this.writeVarint(Math.round(style.halo * 10));
148
+ }
149
+ if (style.opacity != null) {
150
+ this.writeInteger(2, 4);
151
+ this.writeVarint(Math.round(style.opacity * 100));
152
+ }
153
+ if (style.pattern != null) {
154
+ this.writeInteger(3, 4);
155
+ this.writeVarint(style.pattern);
156
+ }
157
+ if (style.rotate != null) {
158
+ this.writeInteger(4, 4);
159
+ this.writeVarint(style.rotate, true);
160
+ }
161
+ if (style.size != null) {
162
+ this.writeInteger(5, 4);
163
+ this.writeVarint(Math.round(style.size * 10));
164
+ }
165
+ if (style.width != null) {
166
+ this.writeInteger(6, 4);
167
+ this.writeVarint(Math.round(style.width * 10));
168
+ }
169
+ if (style.align != null) {
170
+ this.writeInteger(7, 4);
171
+ this.writeVarint(style.align);
172
+ }
173
+ if (style.color != null) {
174
+ this.writeInteger(8, 4);
175
+ this.writeColor(style.color);
176
+ }
177
+ if (style.label != null) {
178
+ this.writeInteger(9, 4);
179
+ this.writeString(style.label);
180
+ }
181
+ if (style.visible === false) {
182
+ this.writeInteger(10, 4);
183
+ }
184
+ this.writeInteger(0, 4);
185
+ }
162
186
  writeColor(color) {
163
- if (typeof color !== 'string')
164
- throw new Error(`Invalid color: ${color}`);
165
- const c = Color.parse(color).asRGB().round().asArray();
166
- this.writeByte(c[0]);
167
- this.writeByte(c[1]);
168
- this.writeByte(c[2]);
169
- }
170
- writeDifferential(values) {
171
- if (values.length === 0)
172
- return;
173
- this.writeSignedInteger(values[0]);
174
- for (let i = 1; i < values.length; i++) {
175
- this.writeSignedInteger(values[i] - values[i - 1]);
187
+ const rgb = Color.parse(color).toRGB();
188
+ this.writeInteger(rgb.r, 8);
189
+ this.writeInteger(rgb.g, 8);
190
+ this.writeInteger(rgb.b, 8);
191
+ if (rgb.a == 1) {
192
+ this.bits.push(false);
193
+ }
194
+ else {
195
+ this.bits.push(true);
196
+ this.writeInteger(Math.round(rgb.a * 255), 8);
176
197
  }
177
198
  }
199
+ writeString(value) {
200
+ const charCodes = value.split('').map((c) => c.charCodeAt(0));
201
+ this.writeVarint(charCodes.length);
202
+ charCodes.forEach((c) => this.writeVarint(c < 128 ? CHAR_CODE2VALUE[c] : c));
203
+ return value;
204
+ }
178
205
  }
@@ -1,9 +1,6 @@
1
1
  import type { ElementPoint } from './element/types.js';
2
+ import type { StateStyle } from './state/types.js';
2
3
  export declare function getMiddlePoint(p0: ElementPoint, p1: ElementPoint): ElementPoint;
3
4
  export declare function lat2mercator(lat: number): number;
4
5
  export declare function mercator2lat(y: number): number;
5
- export declare function base64ToUint8Array(base64: string): Uint8Array;
6
- export declare function uint8ArrayToBase64(data: Uint8Array): string;
7
- export declare function compress(data: Uint8Array): Promise<Uint8Array>;
8
- export declare function decompress(data: Uint8Array): Promise<Uint8Array>;
9
- export declare function removeDefaultFields<T extends Record<string, unknown>>(value: T, def: T): Partial<T> | undefined;
6
+ export declare function removeDefaultFields(value: StateStyle, def: StateStyle): Partial<StateStyle> | undefined;
@@ -9,25 +9,6 @@ export function lat2mercator(lat) {
9
9
  export function mercator2lat(y) {
10
10
  return ((2 * Math.atan(Math.exp(y)) - Math.PI / 2) * 180) / Math.PI;
11
11
  }
12
- export function base64ToUint8Array(base64) {
13
- const binaryString = atob(base64);
14
- return Uint8Array.from(binaryString, (c) => c.charCodeAt(0));
15
- }
16
- export function uint8ArrayToBase64(data) {
17
- const binaryString = String.fromCharCode(...data);
18
- return btoa(binaryString);
19
- }
20
- export async function compress(data) {
21
- const stream = new Blob([data]).stream();
22
- const compressedStream = stream.pipeThrough(new CompressionStream('deflate-raw'));
23
- return new Uint8Array(await new Response(compressedStream).arrayBuffer());
24
- }
25
- export async function decompress(data) {
26
- const stream = new Blob([data]).stream();
27
- const decompressedStream = stream.pipeThrough(new DecompressionStream('deflate-raw'));
28
- const arrayBuffer = await new Response(decompressedStream).arrayBuffer();
29
- return new Uint8Array(arrayBuffer);
30
- }
31
12
  export function removeDefaultFields(value, def) {
32
13
  const entries = Object.entries(value).filter(([k, v]) => {
33
14
  if (v === undefined)
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
2
  "name": "@versatiles/svelte",
3
- "version": "1.1.1",
3
+ "version": "2.0.0",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "build": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json && vite build && npm run package",
7
- "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
8
- "check": "npm run lint && npm run build && npm run test",
7
+ "check-watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
8
+ "check": "npm run format && npm run lint && npm run build && npm run test",
9
9
  "dev": "vite dev",
10
- "format": "prettier --write .",
10
+ "format": "prettier --write --log-level warn .",
11
11
  "lint": "prettier --check . && eslint --color .",
12
12
  "package": "svelte-kit sync && svelte-package && publint",
13
13
  "prepack": "npm run build",
14
14
  "prepublishOnly": "npm run package",
15
15
  "preview": "vite preview",
16
- "screenshots": "npm run build && npx tsx ./scripts/screenshots.ts && pngquant --nofs --force --ext .png screenshots/*.png && optipng -quiet screenshots/*.png",
16
+ "screenshots": "npx tsx ./scripts/screenshots.ts",
17
17
  "release": "vrt release-npm",
18
- "test:integration": "playwright test",
19
- "test:unit": "vitest run",
20
- "test:coverage": "vitest run --coverage",
21
- "test": "npm run test:unit && npm run test:integration",
18
+ "test-integration": "playwright test",
19
+ "test-unit": "vitest run",
20
+ "test-coverage": "vitest run --coverage",
21
+ "test": "npm run test-unit && npm run test-integration",
22
22
  "upgrade": "vrt deps-upgrade"
23
23
  },
24
24
  "exports": {
@@ -30,50 +30,51 @@
30
30
  "files": [
31
31
  "dist",
32
32
  "!dist/**/*.spec.*",
33
+ "!dist/**/__mocks__/*",
33
34
  "!dist/**/*.test.*",
34
35
  "!dist/BBoxMap/data/*",
35
36
  "!dist/BBoxMap/helpers/*"
36
37
  ],
37
38
  "peerDependencies": {
38
- "sass-embedded": "^1.86.0",
39
- "svelte": "^5.0.3"
39
+ "sass-embedded": "^1.86.3",
40
+ "svelte": "^5.27.0"
40
41
  },
41
42
  "devDependencies": {
42
43
  "@playwright/test": "^1.51.1",
43
44
  "@sveltejs/adapter-static": "^3.0.8",
44
- "@sveltejs/kit": "^2.20.0",
45
- "@sveltejs/package": "^2.3.10",
45
+ "@sveltejs/kit": "^2.20.7",
46
+ "@sveltejs/package": "^2.3.11",
46
47
  "@sveltejs/vite-plugin-svelte": "^5.0.3",
47
48
  "@turf/turf": "^7.2.0",
48
49
  "@types/eslint": "^9.6.1",
49
- "@types/node": "^22.13.10",
50
+ "@types/node": "^22.14.1",
50
51
  "@versatiles/release-tool": "^2.4.2",
51
- "@vitest/coverage-v8": "^3.0.9",
52
+ "@vitest/coverage-v8": "^3.1.1",
52
53
  "cookie": "^1.0.2",
53
- "eslint": "^9.22.0",
54
- "eslint-config-prettier": "^10.1.1",
55
- "eslint-plugin-svelte": "^3.3.2",
54
+ "eslint": "^9.24.0",
55
+ "eslint-config-prettier": "^10.1.2",
56
+ "eslint-plugin-svelte": "^3.5.1",
56
57
  "geojson": "^0.5.0",
57
58
  "globals": "^16.0.0",
58
59
  "happy-dom": "^17.4.4",
59
60
  "prettier": "^3.5.3",
60
61
  "prettier-plugin-svelte": "^3.3.3",
61
- "publint": "^0.3.9",
62
- "sass": "^1.86.0",
63
- "svelte": "^5.23.1",
64
- "svelte-check": "^4.1.5",
62
+ "publint": "^0.3.12",
63
+ "sass": "^1.86.3",
64
+ "svelte": "^5.27.0",
65
+ "svelte-check": "^4.1.6",
65
66
  "svelte-preprocess": "^6.0.3",
66
67
  "tsx": "^4.19.3",
67
- "typescript": "^5.8.2",
68
- "typescript-eslint": "^8.26.1",
69
- "vite": "^6.2.2",
70
- "vitest": "^3.0.9"
68
+ "typescript": "^5.8.3",
69
+ "typescript-eslint": "^8.30.1",
70
+ "vite": "^6.2.6",
71
+ "vitest": "^3.1.1"
71
72
  },
72
73
  "svelte": "./dist/index.js",
73
74
  "types": "./dist/index.d.ts",
74
75
  "type": "module",
75
76
  "dependencies": {
76
77
  "@versatiles/style": "^5.6.0",
77
- "maplibre-gl": "^5.2.0"
78
+ "maplibre-gl": "^5.3.1"
78
79
  }
79
80
  }
@@ -1,5 +0,0 @@
1
- export declare class MockCursor {
2
- grab: import("vitest").Mock<(...args: any[]) => any>;
3
- hover: import("vitest").Mock<(...args: any[]) => any>;
4
- precise: import("vitest").Mock<(...args: any[]) => any>;
5
- }
@@ -1,6 +0,0 @@
1
- import { vi } from 'vitest';
2
- export class MockCursor {
3
- grab = vi.fn();
4
- hover = vi.fn();
5
- precise = vi.fn();
6
- }
@@ -1,22 +0,0 @@
1
- import { type Writable } from 'svelte/store';
2
- import type { AbstractElement } from '../element/abstract.js';
3
- import type { StateObject } from '../state/types.js';
4
- import { MockMap } from './map.js';
5
- import { MockCursor } from './cursor.js';
6
- export declare class MockGeometryManager {
7
- readonly elements: Writable<AbstractElement[]>;
8
- readonly activeElement: Writable<AbstractElement | undefined>;
9
- readonly map: MockMap;
10
- readonly cursor: MockCursor;
11
- constructor();
12
- setActiveElement: import("vitest").Mock<(...args: any[]) => any>;
13
- getState: import("vitest").Mock<() => StateObject>;
14
- saveState: import("vitest").Mock<(...args: any[]) => any>;
15
- loadState: import("vitest").Mock<(...args: any[]) => any>;
16
- getElement: import("vitest").Mock<(index: number) => AbstractElement>;
17
- addNewMarker: import("vitest").Mock<() => AbstractElement>;
18
- addNewLine: import("vitest").Mock<() => AbstractElement>;
19
- addNewPolygon: import("vitest").Mock<() => AbstractElement>;
20
- deleteElement: import("vitest").Mock<(...args: any[]) => any>;
21
- drawSelectionNodes: import("vitest").Mock<(...args: any[]) => any>;
22
- }
@@ -1,21 +0,0 @@
1
- import { writable } from 'svelte/store';
2
- import { vi } from 'vitest';
3
- import { MockMap } from './map.js';
4
- import { MockCursor } from './cursor.js';
5
- export class MockGeometryManager {
6
- elements = writable([]);
7
- activeElement = writable(undefined);
8
- map = new MockMap();
9
- cursor = new MockCursor();
10
- constructor() { }
11
- setActiveElement = vi.fn();
12
- getState = vi.fn(() => ({ map: { point: [0, 0], zoom: 10 }, elements: [] }));
13
- saveState = vi.fn();
14
- loadState = vi.fn();
15
- getElement = vi.fn((index) => ({ index }));
16
- addNewMarker = vi.fn(() => ({}));
17
- addNewLine = vi.fn(() => ({}));
18
- addNewPolygon = vi.fn(() => ({}));
19
- deleteElement = vi.fn();
20
- drawSelectionNodes = vi.fn();
21
- }
@@ -1,36 +0,0 @@
1
- export declare class MockMap {
2
- getCanvasContainer: import("vitest").Mock<() => {
3
- style: {
4
- cursor: string;
5
- };
6
- }>;
7
- addSource: import("vitest").Mock<(...args: any[]) => any>;
8
- removeSource: import("vitest").Mock<(...args: any[]) => any>;
9
- getSource: import("vitest").Mock<() => {
10
- setData: import("vitest").Mock<(...args: any[]) => any>;
11
- }>;
12
- addLayer: import("vitest").Mock<(...args: any[]) => any>;
13
- on: import("vitest").Mock<(...args: any[]) => any>;
14
- setCenter: import("vitest").Mock<(...args: any[]) => any>;
15
- setZoom: import("vitest").Mock<(...args: any[]) => any>;
16
- getZoom: import("vitest").Mock<() => number>;
17
- getCenter: import("vitest").Mock<() => {
18
- lng: number;
19
- lat: number;
20
- }>;
21
- queryRenderedFeatures: import("vitest").Mock<() => {
22
- properties: {};
23
- }[]>;
24
- setPaintProperty: import("vitest").Mock<(...args: any[]) => any>;
25
- setLayoutProperty: import("vitest").Mock<(...args: any[]) => any>;
26
- removeLayer: import("vitest").Mock<(...args: any[]) => any>;
27
- hasImage: import("vitest").Mock<(...args: any[]) => any>;
28
- removeImage: import("vitest").Mock<(...args: any[]) => any>;
29
- addImage: import("vitest").Mock<(...args: any[]) => any>;
30
- getBounds: import("vitest").Mock<() => {
31
- getWest: () => -180;
32
- getEast: () => 180;
33
- getSouth: () => -90;
34
- getNorth: () => 90;
35
- }>;
36
- }
@@ -1,26 +0,0 @@
1
- import { vi } from 'vitest';
2
- export class MockMap {
3
- getCanvasContainer = vi.fn(() => ({ style: { cursor: 'default' } }));
4
- addSource = vi.fn();
5
- removeSource = vi.fn();
6
- getSource = vi.fn(() => ({ setData: vi.fn() }));
7
- addLayer = vi.fn();
8
- on = vi.fn();
9
- setCenter = vi.fn();
10
- setZoom = vi.fn();
11
- getZoom = vi.fn(() => 10);
12
- getCenter = vi.fn(() => ({ lng: 0, lat: 0 }));
13
- queryRenderedFeatures = vi.fn(() => [{ properties: {} }]);
14
- setPaintProperty = vi.fn();
15
- setLayoutProperty = vi.fn();
16
- removeLayer = vi.fn();
17
- hasImage = vi.fn();
18
- removeImage = vi.fn();
19
- addImage = vi.fn();
20
- getBounds = vi.fn(() => ({
21
- getWest: () => -180,
22
- getEast: () => 180,
23
- getSouth: () => -90,
24
- getNorth: () => 90
25
- }));
26
- }