forked from mejackreed/Leaflet-IIIF
-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.ts
202 lines (194 loc) · 3.89 KB
/
types.ts
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
import L, { ControlOptions, Point, TileLayerOptions } from "leaflet";
import { IIIFLayer } from "./layer";
import { IIIFControl } from "./toolbar";
/**
* List the capabilities of the server.
*/
export interface ServerCapabilities {
/**
* IIIF version of the server (1.1, 2.0 or 3.0)
*/
version: string;
/**
* List of supported formats
*/
formats: Array<string>;
/**
* List of supported qualities
*/
qualities: Array<string>;
/**
* Support 90s rotation ?
* @default false
*/
rotation: boolean;
/**
* Support mirroring ?
* @default false
*/
mirroring: boolean;
/**
* Min zoom (related to Scale factors)
* @default 0
*/
minZoom: number;
/**
* max zoom (related to Scale factors)
* @default 0
*/
maxZoom: number;
/**
* Prefered tile size
*/
tileSize: Point | null;
}
/**
* Default values for server capabilties
*/
export const SERVER_CAPABILITIES_DEFAULT: ServerCapabilities = {
version: "3.0",
formats: [],
qualities: [],
rotation: false,
mirroring: false,
tileSize: null,
minZoom: -2,
maxZoom: 0,
};
/**
* Settings for {@link IIIFLayer | IIIF layer}
*/
export interface IIIFLayerOptions extends TileLayerOptions {
/**
* Size of the tile (as a square)
* If not specified and the server has a preference, we take it, otherwise 256
* @default 256
*/
tileSize: Point;
/**
* Format of the tiles (ie png, jpg, ...).
* @Default "jpg"
*/
tileFormat: string;
/**
* Quality
* @default: "default"
*/
quality: string;
/**
* Rotation (ex: 0, 90, 180, 270).
* @default 0
*/
rotation: number;
/**
* Mirroring
* @default false
*/
mirroring: boolean;
/**
* When initialiazed the layer, do you want to see the full picture ?
* @default true
*/
fitBounds: boolean;
/**
* Does the user can pan outside the image ?
* @default false
*/
setMaxBounds: boolean;
/**
* Min level zoom of the layer.
* @default 0
*/
minZoom: number;
/**
* Max level zoom of the layer.
* @default 0
*/
maxZoom: number;
}
/**
* Default values for {@link IIIFLayerOptions}
*/
export const DEFAULT_OPTIONS: IIIFLayerOptions = {
tileSize: L.point(256, 256),
tileFormat: "jpg",
quality: "default",
rotation: 0,
mirroring: false,
fitBounds: true,
setMaxBounds: false,
minZoom: 0,
maxZoom: 0,
zoomOffset: 0,
};
/**
* Configuration of an action on the control bar.
* An action is an entry on the toolbal like, quality, format, ...
*/
interface IIIFControlAction {
/**
* Does the action is enabled ?
*/
enabled: boolean;
/**
* Title of the action (used for title attribute in html)
*/
title: string;
/**
* The html code to display the action entry in the toolbar.
*/
html: string;
/**
* An optional list of possible values for this action.
* It's usefull for qualities, formats, ...
*/
values?: Array<string>;
}
/**
* Settings of {@link IIIFControl | IIIF control layer}
*/
export interface IIIFControlOptions extends ControlOptions {
quality: IIIFControlAction;
format: IIIFControlAction;
rotation: IIIFControlAction;
mirroring: IIIFControlAction;
}
/**
* Default values for {@link IIIFControlOptions}
*/
export const DEFAULT_CONTROL_OPTIONS: IIIFControlOptions = {
quality: {
enabled: true,
title: "Quality",
html: `<span />`,
},
format: {
enabled: true,
title: "Format",
html: `<span />`,
},
rotation: {
enabled: true,
title: "Rotation",
html: `<span />`,
},
mirroring: {
enabled: true,
title: "Mirroring",
html: `<span />`,
},
};
declare global {
interface LeafletIIFWindow {
Iiif: { Event: unknown };
tileLayer: {
iiif: (url: string, options: IIIFLayerOptions) => IIIFLayer;
};
control: {
iiif: (layer: IIIFLayer, options: IIIFControlOptions) => IIIFControl;
};
}
interface Window {
L: LeafletIIFWindow;
}
}