@versatiles/svelte 1.0.1 → 1.1.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.
- package/dist/components/BBoxMap/AutoComplete.svelte +117 -90
- package/dist/components/BBoxMap/BBoxMap.svelte +49 -40
- package/dist/components/BBoxMap/BBoxMap.svelte.d.ts +0 -1
- package/dist/components/BasicMap/BasicMap.svelte +60 -34
- package/dist/components/LocatorMap/LocatorMap.svelte +66 -60
- package/dist/components/LocatorMap/LocatorMap.svelte.d.ts +0 -1
- package/dist/components/MapEditor/MapEditor.svelte +34 -80
- package/dist/components/MapEditor/MapEditor.svelte.d.ts +0 -1
- package/dist/components/MapEditor/components/Editor.svelte +53 -0
- package/dist/components/MapEditor/{Editor.svelte.d.ts → components/Editor.svelte.d.ts} +1 -1
- package/dist/components/MapEditor/components/EditorFill.svelte +28 -0
- package/dist/components/MapEditor/components/EditorFill.svelte.d.ts +7 -0
- package/dist/components/MapEditor/components/EditorStroke.svelte +28 -0
- package/dist/components/MapEditor/components/EditorStroke.svelte.d.ts +7 -0
- package/dist/components/MapEditor/components/EditorSymbol.svelte +43 -0
- package/dist/components/MapEditor/components/EditorSymbol.svelte.d.ts +7 -0
- package/dist/components/MapEditor/components/Sidebar.svelte +179 -0
- package/dist/components/MapEditor/components/Sidebar.svelte.d.ts +8 -0
- package/dist/components/MapEditor/components/SymbolSelector.svelte +118 -0
- package/dist/components/MapEditor/components/SymbolSelector.svelte.d.ts +8 -0
- package/dist/components/MapEditor/lib/__mocks__/cursor.d.ts +5 -0
- package/dist/components/MapEditor/lib/__mocks__/cursor.js +6 -0
- package/dist/components/MapEditor/lib/__mocks__/geometry_manager.d.ts +22 -0
- package/dist/components/MapEditor/lib/__mocks__/geometry_manager.js +21 -0
- package/dist/components/MapEditor/lib/__mocks__/map.d.ts +36 -0
- package/dist/components/MapEditor/lib/__mocks__/map.js +26 -0
- package/dist/components/MapEditor/lib/cursor.d.ts +10 -0
- package/dist/components/MapEditor/lib/cursor.js +43 -0
- package/dist/components/MapEditor/lib/element/abstract.d.ts +21 -0
- package/dist/components/MapEditor/lib/element/abstract.js +39 -0
- package/dist/components/MapEditor/lib/element/abstract_path.d.ts +11 -0
- package/dist/components/MapEditor/lib/element/abstract_path.js +79 -0
- package/dist/components/MapEditor/lib/element/line.d.ts +16 -0
- package/dist/components/MapEditor/lib/element/line.js +53 -0
- package/dist/components/MapEditor/lib/element/marker.d.ts +18 -0
- package/dist/components/MapEditor/lib/element/marker.js +62 -0
- package/dist/components/MapEditor/lib/element/polygon.d.ts +17 -0
- package/dist/components/MapEditor/lib/element/polygon.js +63 -0
- package/dist/components/MapEditor/lib/element/types.d.ts +11 -0
- package/dist/components/MapEditor/lib/geometry_manager.d.ts +20 -10
- package/dist/components/MapEditor/lib/geometry_manager.js +163 -57
- package/dist/components/MapEditor/lib/map_layer/abstract.d.ts +30 -0
- package/dist/components/MapEditor/lib/map_layer/abstract.js +94 -0
- package/dist/components/MapEditor/lib/map_layer/fill.d.ts +24 -0
- package/dist/components/MapEditor/lib/map_layer/fill.js +104 -0
- package/dist/components/MapEditor/lib/map_layer/line.d.ts +20 -0
- package/dist/components/MapEditor/lib/map_layer/line.js +90 -0
- package/dist/components/MapEditor/lib/map_layer/symbol.d.ts +19 -0
- package/dist/components/MapEditor/lib/map_layer/symbol.js +123 -0
- package/dist/components/MapEditor/lib/{types.d.ts → map_layer/types.d.ts} +7 -15
- package/dist/components/MapEditor/lib/map_layer/types.js +1 -0
- package/dist/components/MapEditor/lib/state/reader.d.ts +17 -0
- package/dist/components/MapEditor/lib/state/reader.js +161 -0
- package/dist/components/MapEditor/lib/state/types.d.ts +20 -0
- package/dist/components/MapEditor/lib/state/types.js +1 -0
- package/dist/components/MapEditor/lib/state/writer.d.ts +17 -0
- package/dist/components/MapEditor/lib/state/writer.js +178 -0
- package/dist/components/MapEditor/lib/symbols.d.ts +16 -0
- package/dist/components/MapEditor/lib/symbols.js +173 -0
- package/dist/components/MapEditor/lib/utils.d.ts +8 -1
- package/dist/components/MapEditor/lib/utils.js +33 -2
- package/dist/utils/draw/bbox.d.ts +1 -0
- package/dist/utils/draw/bbox.js +1 -1
- package/package.json +29 -30
- package/dist/components/MapEditor/Editor.svelte +0 -25
- package/dist/components/MapEditor/EditorLine.svelte +0 -27
- package/dist/components/MapEditor/EditorLine.svelte.d.ts +0 -7
- package/dist/components/MapEditor/EditorMarker.svelte +0 -42
- package/dist/components/MapEditor/EditorMarker.svelte.d.ts +0 -7
- package/dist/components/MapEditor/editor.scss +0 -16
- package/dist/components/MapEditor/lib/element_abstract.d.ts +0 -20
- package/dist/components/MapEditor/lib/element_abstract.js +0 -58
- package/dist/components/MapEditor/lib/element_line.d.ts +0 -14
- package/dist/components/MapEditor/lib/element_line.js +0 -76
- package/dist/components/MapEditor/lib/element_marker.d.ts +0 -20
- package/dist/components/MapEditor/lib/element_marker.js +0 -191
- package/dist/components/MapEditor/lib/map_layer.d.ts +0 -14
- package/dist/components/MapEditor/lib/map_layer.js +0 -61
- package/dist/utils/sprite_library.d.ts +0 -19
- package/dist/utils/sprite_library.js +0 -30
- /package/dist/components/MapEditor/lib/{types.js → element/types.js} +0 -0
@@ -1,20 +0,0 @@
|
|
1
|
-
import { AbstractElement } from './element_abstract.js';
|
2
|
-
import type { GeometryManager } from './geometry_manager.js';
|
3
|
-
import type { ElementPoint, LayerSymbol, SelectionNode } from './types.js';
|
4
|
-
export declare const symbols: Map<string, {
|
5
|
-
image: string;
|
6
|
-
offset?: [number, number];
|
7
|
-
}>;
|
8
|
-
export declare class MarkerElement extends AbstractElement<LayerSymbol> {
|
9
|
-
readonly color: import("svelte/store").Writable<string>;
|
10
|
-
readonly halo: import("svelte/store").Writable<number>;
|
11
|
-
readonly rotate: import("svelte/store").Writable<number>;
|
12
|
-
readonly size: import("svelte/store").Writable<number>;
|
13
|
-
readonly symbol: import("svelte/store").Writable<string>;
|
14
|
-
readonly label: import("svelte/store").Writable<string>;
|
15
|
-
private point;
|
16
|
-
constructor(manager: GeometryManager, name: string, point?: ElementPoint);
|
17
|
-
getFeature(): GeoJSON.Feature<GeoJSON.Point>;
|
18
|
-
getSelectionNodes(): SelectionNode[];
|
19
|
-
getSelectionNodeUpdater(): ((lng: number, lat: number) => void) | undefined;
|
20
|
-
}
|
@@ -1,191 +0,0 @@
|
|
1
|
-
import { Color } from '@versatiles/style';
|
2
|
-
import { AbstractElement } from './element_abstract.js';
|
3
|
-
import { get, writable } from 'svelte/store';
|
4
|
-
export const symbols = new Map([
|
5
|
-
['airplane', { image: 'basics:icon-airfield' }],
|
6
|
-
['airport', { image: 'basics:icon-airport' }],
|
7
|
-
['alcohol shop', { image: 'basics:icon-alcohol_shop' }],
|
8
|
-
['art gallery', { image: 'basics:icon-art_gallery' }],
|
9
|
-
['artwork', { image: 'basics:icon-artwork' }],
|
10
|
-
['atm', { image: 'basics:icon-atm' }],
|
11
|
-
['bakery', { image: 'basics:icon-bakery' }],
|
12
|
-
['bank', { image: 'basics:icon-bank' }],
|
13
|
-
['beauty', { image: 'basics:icon-beauty' }],
|
14
|
-
['beer', { image: 'basics:icon-beer' }],
|
15
|
-
['beergarden', { image: 'basics:icon-beergarden' }],
|
16
|
-
['bench', { image: 'basics:icon-bench' }],
|
17
|
-
['beverages', { image: 'basics:icon-beverages' }],
|
18
|
-
['bicycle share', { image: 'basics:icon-bicycle_share' }],
|
19
|
-
['books', { image: 'basics:icon-books' }],
|
20
|
-
['bus', { image: 'basics:icon-bus' }],
|
21
|
-
['butcher', { image: 'basics:icon-butcher' }],
|
22
|
-
['cafe', { image: 'basics:icon-cafe', offset: [2, 0] }],
|
23
|
-
['car rental', { image: 'basics:icon-car_rental' }],
|
24
|
-
['car wash', { image: 'basics:icon-car_wash' }],
|
25
|
-
['castle', { image: 'basics:icon-castle' }],
|
26
|
-
['cemetery', { image: 'basics:icon-cemetery' }],
|
27
|
-
['chalet', { image: 'basics:icon-chalet' }],
|
28
|
-
['chemist', { image: 'basics:icon-chemist' }],
|
29
|
-
['cinema', { image: 'basics:icon-cinema' }],
|
30
|
-
['clothes', { image: 'basics:icon-clothes' }],
|
31
|
-
['college', { image: 'basics:icon-college' }],
|
32
|
-
['community', { image: 'basics:icon-community' }],
|
33
|
-
['defibrillator', { image: 'basics:icon-defibrillator' }],
|
34
|
-
['doctor', { image: 'basics:icon-doctor' }],
|
35
|
-
['dog park', { image: 'basics:icon-dog_park' }],
|
36
|
-
['doityourself', { image: 'basics:icon-doityourself' }],
|
37
|
-
['drinking water', { image: 'basics:icon-drinking_water' }],
|
38
|
-
['drycleaning', { image: 'basics:icon-drycleaning' }],
|
39
|
-
['emergency phone', { image: 'basics:icon-emergency_phone' }],
|
40
|
-
['fast food', { image: 'basics:icon-fast_food' }],
|
41
|
-
['fire station', { image: 'basics:icon-fire_station' }],
|
42
|
-
['flag', { image: 'basics:icon-embassy', offset: [7.5, -10] }],
|
43
|
-
['florist', { image: 'basics:icon-florist' }],
|
44
|
-
['fountain', { image: 'basics:icon-fountain' }],
|
45
|
-
['furniture', { image: 'basics:icon-furniture' }],
|
46
|
-
['garden centre', { image: 'basics:icon-garden_centre' }],
|
47
|
-
['gift', { image: 'basics:icon-gift' }],
|
48
|
-
['glasses', { image: 'basics:icon-optician' }],
|
49
|
-
['golf', { image: 'basics:icon-golf' }],
|
50
|
-
['greengrocer', { image: 'basics:icon-greengrocer' }],
|
51
|
-
['hardware', { image: 'basics:icon-hardware' }],
|
52
|
-
['hospital', { image: 'basics:icon-hospital' }],
|
53
|
-
['huntingstand', { image: 'basics:icon-huntingstand' }],
|
54
|
-
['hydrant', { image: 'basics:icon-hydrant' }],
|
55
|
-
['icerink', { image: 'basics:icon-icerink' }],
|
56
|
-
['information', { image: 'basics:transport-information' }],
|
57
|
-
['jewelry store', { image: 'basics:icon-jewelry_store' }],
|
58
|
-
['kiosk', { image: 'basics:icon-kiosk' }],
|
59
|
-
['laundry', { image: 'basics:icon-laundry' }],
|
60
|
-
['letter', { image: 'basics:icon-post' }],
|
61
|
-
['library', { image: 'basics:icon-library' }],
|
62
|
-
['lighthouse', { image: 'basics:icon-lighthouse' }],
|
63
|
-
['marketplace', { image: 'basics:icon-marketplace' }],
|
64
|
-
['money', { image: 'basics:icon-bar' }],
|
65
|
-
['monument', { image: 'basics:icon-monument' }],
|
66
|
-
['newsagent', { image: 'basics:icon-newsagent' }],
|
67
|
-
['nightclub', { image: 'basics:icon-nightclub' }],
|
68
|
-
['nursinghome', { image: 'basics:icon-nursinghome' }],
|
69
|
-
['observation tower', { image: 'basics:icon-observation_tower' }],
|
70
|
-
['outdoor', { image: 'basics:icon-outdoor' }],
|
71
|
-
['pharmacy', { image: 'basics:icon-pharmacy' }],
|
72
|
-
['picnic site', { image: 'basics:icon-picnic_site' }],
|
73
|
-
['place of worship', { image: 'basics:icon-place_of_worship' }],
|
74
|
-
['playground', { image: 'basics:icon-playground' }],
|
75
|
-
['police', { image: 'basics:icon-police', offset: [-1, -3] }],
|
76
|
-
['postbox', { image: 'basics:icon-postbox' }],
|
77
|
-
['prison', { image: 'basics:icon-prison' }],
|
78
|
-
['rail light', { image: 'basics:icon-rail_light' }],
|
79
|
-
['rail metro', { image: 'basics:icon-rail_metro' }],
|
80
|
-
['rail', { image: 'basics:icon-rail' }],
|
81
|
-
['recycling', { image: 'basics:icon-recycling' }],
|
82
|
-
['restaurant', { image: 'basics:icon-restaurant' }],
|
83
|
-
['run', { image: 'basics:icon-pitch' }],
|
84
|
-
['school', { image: 'basics:icon-school' }],
|
85
|
-
['scissor', { image: 'basics:icon-hairdresser' }],
|
86
|
-
['shield', { image: 'basics:icon-historic', offset: [0, -10] }],
|
87
|
-
['shoes', { image: 'basics:icon-shoes', offset: [-5, 0] }],
|
88
|
-
['shop', { image: 'basics:icon-shop' }],
|
89
|
-
['shop', { image: 'basics:icon-shop' }],
|
90
|
-
['shrine', { image: 'basics:icon-shrine' }],
|
91
|
-
['sports', { image: 'basics:icon-sports' }],
|
92
|
-
['stadium', { image: 'basics:icon-stadium' }],
|
93
|
-
['stationery', { image: 'basics:icon-stationery' }],
|
94
|
-
['surveillance', { image: 'basics:icon-surveillance' }],
|
95
|
-
['swimming', { image: 'basics:icon-swimming' }],
|
96
|
-
['telephone', { image: 'basics:icon-telephone' }],
|
97
|
-
['theatre', { image: 'basics:icon-theatre' }],
|
98
|
-
['toilet', { image: 'basics:icon-toilet' }],
|
99
|
-
['tooth', { image: 'basics:icon-dentist' }],
|
100
|
-
['town hall', { image: 'basics:icon-town_hall' }],
|
101
|
-
['toys', { image: 'basics:icon-toys' }],
|
102
|
-
['tram', { image: 'basics:transport-tram' }],
|
103
|
-
['travel agent', { image: 'basics:icon-travel_agent' }],
|
104
|
-
['vendingmachine', { image: 'basics:icon-vendingmachine' }],
|
105
|
-
['veterinary', { image: 'basics:icon-veterinary' }],
|
106
|
-
['video', { image: 'basics:icon-video' }],
|
107
|
-
['viewpoint', { image: 'basics:icon-viewpoint', offset: [0, -6] }],
|
108
|
-
['waste basket', { image: 'basics:icon-waste_basket' }],
|
109
|
-
['watermill', { image: 'basics:icon-watermill' }],
|
110
|
-
['waterpark', { image: 'basics:icon-waterpark' }],
|
111
|
-
['windmill', { image: 'basics:icon-windmill' }],
|
112
|
-
['zoo', { image: 'basics:icon-zoo' }]
|
113
|
-
]);
|
114
|
-
export class MarkerElement extends AbstractElement {
|
115
|
-
color = writable('#ff0000');
|
116
|
-
halo = writable(1);
|
117
|
-
rotate = writable(0);
|
118
|
-
size = writable(1);
|
119
|
-
symbol = writable('flag');
|
120
|
-
label = writable('');
|
121
|
-
point = [0, 0];
|
122
|
-
constructor(manager, name, point) {
|
123
|
-
super(manager, name, 'symbol');
|
124
|
-
this.point = point ?? this.randomPositions(name, 1)[0];
|
125
|
-
const getSymbol = () => {
|
126
|
-
const entry = symbols.get(get(this.symbol)) ?? symbols.get('flag');
|
127
|
-
return { image: entry.image, offset: entry.offset ?? [0, 0] };
|
128
|
-
};
|
129
|
-
this.layer.setLayout({
|
130
|
-
'icon-image': getSymbol().image,
|
131
|
-
'icon-offset': getSymbol().offset,
|
132
|
-
'icon-overlap': 'always',
|
133
|
-
'icon-rotate': get(this.rotate),
|
134
|
-
'icon-size': get(this.size),
|
135
|
-
'text-field': get(this.label),
|
136
|
-
'text-font': ['noto_sans_regular'],
|
137
|
-
'text-justify': 'left',
|
138
|
-
'text-anchor': 'right',
|
139
|
-
'text-offset': [-0.4, -0.6]
|
140
|
-
});
|
141
|
-
this.layer.setPaint({
|
142
|
-
'icon-color': Color.parse(get(this.color)).asString(),
|
143
|
-
'icon-halo-blur': 0,
|
144
|
-
'icon-halo-color': '#FFFFFF',
|
145
|
-
'icon-halo-width': get(this.halo) * get(this.size),
|
146
|
-
'icon-opacity': 1,
|
147
|
-
'text-halo-blur': 0,
|
148
|
-
'text-halo-color': '#FFFFFF',
|
149
|
-
'text-halo-width': get(this.halo) * get(this.size)
|
150
|
-
});
|
151
|
-
this.color.subscribe((value) => this.layer.updatePaint('icon-color', Color.parse(value)));
|
152
|
-
this.halo.subscribe((value) => {
|
153
|
-
this.layer.updatePaint('icon-halo-width', value * get(this.size));
|
154
|
-
this.layer.updatePaint('text-halo-width', value * get(this.size));
|
155
|
-
});
|
156
|
-
this.label.subscribe((value) => this.layer.updateLayout('text-field', value));
|
157
|
-
this.rotate.subscribe((value) => this.layer.updateLayout('icon-rotate', value));
|
158
|
-
this.size.subscribe((value) => {
|
159
|
-
this.layer.updateLayout('icon-size', value);
|
160
|
-
this.layer.updatePaint('icon-halo-width', value * get(this.halo));
|
161
|
-
this.layer.updateLayout('text-size', value * 16);
|
162
|
-
this.layer.updatePaint('text-halo-width', value * get(this.halo));
|
163
|
-
});
|
164
|
-
this.symbol.subscribe(() => {
|
165
|
-
const symbol = getSymbol();
|
166
|
-
this.layer.updateLayout('icon-image', symbol.image);
|
167
|
-
this.layer.updateLayout('icon-offset', symbol.offset);
|
168
|
-
});
|
169
|
-
this.source.setData(this.getFeature());
|
170
|
-
}
|
171
|
-
getFeature() {
|
172
|
-
return {
|
173
|
-
type: 'Feature',
|
174
|
-
properties: {},
|
175
|
-
geometry: {
|
176
|
-
type: 'Point',
|
177
|
-
coordinates: this.point
|
178
|
-
}
|
179
|
-
};
|
180
|
-
}
|
181
|
-
getSelectionNodes() {
|
182
|
-
return [{ index: 0, coordinates: this.point }];
|
183
|
-
}
|
184
|
-
getSelectionNodeUpdater() {
|
185
|
-
return (lng, lat) => {
|
186
|
-
this.point[0] = lng;
|
187
|
-
this.point[1] = lat;
|
188
|
-
this.source.setData(this.getFeature());
|
189
|
-
};
|
190
|
-
}
|
191
|
-
}
|
@@ -1,14 +0,0 @@
|
|
1
|
-
import type { LayerFill, LayerLine, LayerSymbol } from './types.js';
|
2
|
-
type LayerSpec = LayerFill | LayerLine | LayerSymbol;
|
3
|
-
export declare class MapLayer<T extends LayerSpec> {
|
4
|
-
readonly map: maplibregl.Map;
|
5
|
-
readonly id: string;
|
6
|
-
readonly layoutProperties: T["layout"];
|
7
|
-
readonly paintProperties: T["paint"];
|
8
|
-
constructor(map: maplibregl.Map, id: string, source: string, type: 'symbol' | 'line' | 'fill');
|
9
|
-
setPaint(paint: T['paint']): void;
|
10
|
-
updatePaint<K extends keyof T['paint'], V extends T['paint'][K]>(key: K, value: V): void;
|
11
|
-
setLayout(layout: T['layout']): void;
|
12
|
-
updateLayout<K extends keyof T['layout'], V extends T['layout'][K]>(key: K, value: V): void;
|
13
|
-
}
|
14
|
-
export {};
|
@@ -1,61 +0,0 @@
|
|
1
|
-
import { Color } from '@versatiles/style';
|
2
|
-
export class MapLayer {
|
3
|
-
map;
|
4
|
-
id;
|
5
|
-
layoutProperties = {};
|
6
|
-
paintProperties = {};
|
7
|
-
constructor(map, id, source, type) {
|
8
|
-
this.map = map;
|
9
|
-
this.id = id;
|
10
|
-
let filter;
|
11
|
-
switch (type) {
|
12
|
-
case 'symbol':
|
13
|
-
filter = 'Point';
|
14
|
-
break;
|
15
|
-
case 'line':
|
16
|
-
filter = 'LineString';
|
17
|
-
break;
|
18
|
-
case 'fill':
|
19
|
-
filter = 'Polygon';
|
20
|
-
break;
|
21
|
-
default:
|
22
|
-
throw new Error('Invalid layer type');
|
23
|
-
}
|
24
|
-
this.map.addLayer({
|
25
|
-
id,
|
26
|
-
source,
|
27
|
-
type,
|
28
|
-
layout: this.layoutProperties,
|
29
|
-
paint: this.paintProperties,
|
30
|
-
filter: ['==', '$type', filter]
|
31
|
-
}, 'selection_nodes');
|
32
|
-
}
|
33
|
-
setPaint(paint) {
|
34
|
-
if (paint === undefined)
|
35
|
-
return;
|
36
|
-
const keys = new Set(Object.keys(paint).concat(Object.keys(this.paintProperties)));
|
37
|
-
for (const key of keys.values())
|
38
|
-
this.updatePaint(key, paint[key]);
|
39
|
-
}
|
40
|
-
updatePaint(key, value) {
|
41
|
-
if (value instanceof Color)
|
42
|
-
value = value.asString();
|
43
|
-
if (this.paintProperties[key] == value)
|
44
|
-
return;
|
45
|
-
this.map.setPaintProperty(this.id, key, value);
|
46
|
-
this.paintProperties[key] = value;
|
47
|
-
}
|
48
|
-
setLayout(layout) {
|
49
|
-
if (layout === undefined)
|
50
|
-
return;
|
51
|
-
const keys = new Set(Object.keys(layout).concat(Object.keys(this.layoutProperties)));
|
52
|
-
for (const key of keys.values())
|
53
|
-
this.updateLayout(key, layout[key]);
|
54
|
-
}
|
55
|
-
updateLayout(key, value) {
|
56
|
-
if (this.layoutProperties[key] == value)
|
57
|
-
return;
|
58
|
-
this.map.setLayoutProperty(this.id, key, value);
|
59
|
-
this.layoutProperties[key] = value;
|
60
|
-
}
|
61
|
-
}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
interface SpriteEntry {
|
2
|
-
width: number;
|
3
|
-
height: number;
|
4
|
-
x: number;
|
5
|
-
y: number;
|
6
|
-
pixelRatio: number;
|
7
|
-
sdf: boolean;
|
8
|
-
id: string;
|
9
|
-
name: string;
|
10
|
-
group: string;
|
11
|
-
}
|
12
|
-
export declare class SpriteLibrary {
|
13
|
-
private spriteList;
|
14
|
-
private pixelRatio;
|
15
|
-
constructor(pixelRatio?: number);
|
16
|
-
getSpriteList(): Promise<SpriteEntry[]>;
|
17
|
-
private loadSpriteList;
|
18
|
-
}
|
19
|
-
export default SpriteLibrary;
|
@@ -1,30 +0,0 @@
|
|
1
|
-
export class SpriteLibrary {
|
2
|
-
spriteList = [];
|
3
|
-
pixelRatio;
|
4
|
-
constructor(pixelRatio = 2) {
|
5
|
-
this.pixelRatio = pixelRatio;
|
6
|
-
}
|
7
|
-
async getSpriteList() {
|
8
|
-
await this.loadSpriteList();
|
9
|
-
return this.spriteList;
|
10
|
-
}
|
11
|
-
async loadSpriteList() {
|
12
|
-
if (this.spriteList.length)
|
13
|
-
return;
|
14
|
-
const spriteGroupList = (await fetch('https://tiles.versatiles.org/assets/sprites/index.json').then((r) => r.json()));
|
15
|
-
await Promise.all(spriteGroupList.map(async (group) => {
|
16
|
-
const spriteGroup = (await fetch(`https://tiles.versatiles.org/assets/sprites/${group}/sprites@${this.pixelRatio}x.json`).then((r) => r.json()));
|
17
|
-
Object.entries(spriteGroup).forEach(([name, entry]) => {
|
18
|
-
this.spriteList.push({
|
19
|
-
...entry,
|
20
|
-
pixelRatio: entry.pixelRatio ?? 1,
|
21
|
-
sdf: entry.sdf ?? false,
|
22
|
-
id: `${group}/${name}`,
|
23
|
-
group,
|
24
|
-
name
|
25
|
-
});
|
26
|
-
});
|
27
|
-
}));
|
28
|
-
}
|
29
|
-
}
|
30
|
-
export default SpriteLibrary;
|
File without changes
|