@maplibre/maplibre-react-native 10.0.0-alpha.23 → 10.0.0-alpha.25
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/.husky/pre-commit +1 -1
- package/CHANGELOG.md +10 -0
- package/CONTRIBUTING.md +1 -1
- package/android/rctmln/build.gradle +5 -0
- package/android/rctmln/src/main/java/com/maplibre/rctmln/components/AbstractEventEmitter.java +9 -1
- package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNLocationModule.java +1 -1
- package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNLogging.java +1 -1
- package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNModule.java +1 -1
- package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNOfflineModule.java +1 -1
- package/android/rctmln/src/main/java/com/maplibre/rctmln/modules/RCTMLNSnapshotModule.java +1 -1
- package/docs/Annotation.md +2 -11
- package/docs/BackgroundLayer.md +2 -1
- package/docs/Callout.md +2 -1
- package/docs/Camera.md +28 -29
- package/docs/CircleLayer.md +2 -1
- package/docs/FillExtrusionLayer.md +2 -1
- package/docs/FillLayer.md +2 -1
- package/docs/HeadingIndicator.md +2 -1
- package/docs/HeatmapLayer.md +2 -1
- package/docs/ImageSource.md +2 -1
- package/docs/Images.md +2 -1
- package/docs/Light.md +2 -1
- package/docs/LineLayer.md +2 -1
- package/docs/MapView.md +7 -12
- package/docs/MarkerView.md +2 -1
- package/docs/NativeUserLocation.md +2 -1
- package/docs/PointAnnotation.md +2 -1
- package/docs/RasterLayer.md +2 -1
- package/docs/RasterSource.md +2 -1
- package/docs/ShapeSource.md +3 -5
- package/docs/Style.md +2 -1
- package/docs/SymbolLayer.md +2 -1
- package/docs/UserLocation.md +2 -1
- package/docs/VectorSource.md +3 -2
- package/docs/coordinates.md +2 -1
- package/docs/docs.json +49 -88
- package/docs/location.md +2 -1
- package/docs/offlineManager.md +3 -2
- package/docs/snapshotManager.md +2 -1
- package/ios/RCTMLN/RCTMLNCamera.h +0 -3
- package/ios/RCTMLN/RCTMLNCamera.m +1 -1
- package/ios/RCTMLN/RCTMLNCameraManager.m +0 -3
- package/javascript/MLNModule.ts +10 -1
- package/javascript/Maplibre.ts +1 -1
- package/javascript/components/{annotations/Annotation.tsx → Annotation.tsx} +5 -5
- package/javascript/components/Camera.tsx +257 -388
- package/javascript/components/UserLocation.tsx +1 -1
- package/javascript/hooks/useNativeRef.ts +2 -1
- package/javascript/types/CameraMode.ts +6 -0
- package/package.json +8 -9
- package/scripts/codegen.ts +341 -0
- package/scripts/templates/MaplibreStyles.ts.ejs +8 -7
- package/scripts/templates/RCTMLNStyle.h.ejs +4 -3
- package/scripts/templates/RCTMLNStyle.m.ejs +11 -10
- package/scripts/templates/RCTMLNStyleFactory.java.ejs +12 -11
- package/scripts/templates/component.md.ejs +14 -12
- package/scripts/templates/index.d.ts.ejs +2 -1
- package/scripts/templates/styleMap.ts.ejs +2 -1
- package/scripts/utils/{DocJSONBuilder.js → DocJSONBuilder.ts} +133 -128
- package/scripts/utils/{JSDocNodeTree.js → JSDocNodeTree.ts} +14 -13
- package/scripts/utils/MarkdownBuilder.ts +44 -0
- package/scripts/utils/{template-globals.js → TemplateHelpers.ts} +66 -95
- package/scripts/utils/getNativeVersion.ts +53 -0
- package/tsconfig.json +2 -3
- package/docs/OfflineManager.md +0 -246
- package/scripts/download-style-spec.sh +0 -15
- package/scripts/generate-docs.js +0 -396
- package/scripts/utils/MarkdownBuilder.js +0 -37
- package/style-spec/v8.json +0 -6645
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const iosPropNameOverrides = {};
|
|
1
|
+
const iosPropNameOverrides: Record<string, string> = {};
|
|
2
2
|
|
|
3
|
-
const iosSpecOverrides = {
|
|
3
|
+
const iosSpecOverrides: Record<string, string> = {
|
|
4
4
|
"icon-allow-overlap": "icon-allows-overlap",
|
|
5
5
|
"icon-image": "icon-image-name",
|
|
6
6
|
"icon-ignore-placement": "icon-ignores-placement",
|
|
@@ -40,19 +40,18 @@ const iosSpecOverrides = {
|
|
|
40
40
|
"text-writing-mode": "text-writing-modes",
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
function exists(value) {
|
|
43
|
+
export function exists<T>(value: T): value is NonNullable<T> {
|
|
44
44
|
return typeof value !== "undefined" && value !== null;
|
|
45
45
|
}
|
|
46
|
-
global.exists = exists;
|
|
47
46
|
|
|
48
|
-
|
|
47
|
+
export function getValue(value: any, defaultValue: any) {
|
|
49
48
|
if (!exists(value) || value === "") {
|
|
50
49
|
return defaultValue;
|
|
51
50
|
}
|
|
52
51
|
return value;
|
|
53
|
-
}
|
|
52
|
+
}
|
|
54
53
|
|
|
55
|
-
function camelCase(str, delimiter = "-") {
|
|
54
|
+
export function camelCase(str: string, delimiter = "-") {
|
|
56
55
|
const parts = str.split(delimiter);
|
|
57
56
|
return parts
|
|
58
57
|
.map((part, index) => {
|
|
@@ -63,9 +62,8 @@ function camelCase(str, delimiter = "-") {
|
|
|
63
62
|
})
|
|
64
63
|
.join("");
|
|
65
64
|
}
|
|
66
|
-
global.camelCase = camelCase;
|
|
67
65
|
|
|
68
|
-
function pascalCase(str, delimiter = "-") {
|
|
66
|
+
export function pascalCase(str: string, delimiter = "-") {
|
|
69
67
|
const parts = str.split(delimiter);
|
|
70
68
|
return parts
|
|
71
69
|
.map((part) => {
|
|
@@ -73,16 +71,15 @@ function pascalCase(str, delimiter = "-") {
|
|
|
73
71
|
})
|
|
74
72
|
.join("");
|
|
75
73
|
}
|
|
76
|
-
global.pascalCase = pascalCase;
|
|
77
74
|
|
|
78
|
-
|
|
75
|
+
export function setLayerMethodName(layer: any, platform: "android" | "ios") {
|
|
79
76
|
if (platform === "ios") {
|
|
80
77
|
return `${camelCase(layer.name)}Layer`;
|
|
81
78
|
}
|
|
82
79
|
return `set${pascalCase(layer.name)}LayerStyle`;
|
|
83
|
-
}
|
|
80
|
+
}
|
|
84
81
|
|
|
85
|
-
|
|
82
|
+
export function getLayerType(layer: any, platform: "android" | "ios") {
|
|
86
83
|
const isIOS = platform === "ios";
|
|
87
84
|
|
|
88
85
|
switch (layer.name) {
|
|
@@ -111,20 +108,20 @@ global.getLayerType = function (layer, platform) {
|
|
|
111
108
|
`Is ${layer.name} a new layer? We should add support for it!`,
|
|
112
109
|
);
|
|
113
110
|
}
|
|
114
|
-
}
|
|
111
|
+
}
|
|
115
112
|
|
|
116
|
-
|
|
113
|
+
export function ifOrElseIf(index: number) {
|
|
117
114
|
if (index === 0) {
|
|
118
115
|
return "if";
|
|
119
116
|
}
|
|
120
117
|
return "} else if";
|
|
121
|
-
}
|
|
118
|
+
}
|
|
122
119
|
|
|
123
|
-
|
|
124
|
-
return `@[@${
|
|
125
|
-
}
|
|
120
|
+
export function iosStringArrayLiteral(array: string[]) {
|
|
121
|
+
return `@[@${array.map((item) => `"${item}"`).join(", @")}]`;
|
|
122
|
+
}
|
|
126
123
|
|
|
127
|
-
function iosPropName(name) {
|
|
124
|
+
export function iosPropName(name: string) {
|
|
128
125
|
if (name.indexOf("visibility") !== -1) {
|
|
129
126
|
return "visible";
|
|
130
127
|
}
|
|
@@ -137,24 +134,22 @@ function iosPropName(name) {
|
|
|
137
134
|
return name;
|
|
138
135
|
}
|
|
139
136
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
global.iosMapLibrePropName = function (name) {
|
|
137
|
+
export function iosMapLibrePropName(name: string) {
|
|
143
138
|
const result = iosPropName(name);
|
|
144
139
|
if (result === "fillExtrusionVerticalGradient") {
|
|
145
140
|
return "fillExtrusionHasVerticalGradient";
|
|
146
141
|
}
|
|
147
142
|
return undefined;
|
|
148
|
-
}
|
|
143
|
+
}
|
|
149
144
|
|
|
150
|
-
|
|
145
|
+
export function iosPropMethodName(layer: any, name: string) {
|
|
151
146
|
if (name.indexOf("Visibility") !== -1) {
|
|
152
147
|
return pascalCase(layer.name) + "StyleLayer" + name;
|
|
153
148
|
}
|
|
154
149
|
return name;
|
|
155
|
-
}
|
|
150
|
+
}
|
|
156
151
|
|
|
157
|
-
function androidInputType(type, value) {
|
|
152
|
+
export function androidInputType(type: string, value?: string): string {
|
|
158
153
|
if (type === "array" && value) {
|
|
159
154
|
return `${androidInputType(value)}[]`;
|
|
160
155
|
}
|
|
@@ -171,9 +166,7 @@ function androidInputType(type, value) {
|
|
|
171
166
|
}
|
|
172
167
|
}
|
|
173
168
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
function androidOutputType(type, value) {
|
|
169
|
+
export function androidOutputType(type: string, value?: any): string {
|
|
177
170
|
if (type === "array" && value) {
|
|
178
171
|
return `${androidOutputType(value)}[]`;
|
|
179
172
|
}
|
|
@@ -190,9 +183,7 @@ function androidOutputType(type, value) {
|
|
|
190
183
|
}
|
|
191
184
|
}
|
|
192
185
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
global.androidGetConfigType = function (androidType, prop) {
|
|
186
|
+
export function androidGetConfigType(androidType: string, prop: any) {
|
|
196
187
|
switch (androidType) {
|
|
197
188
|
case "Integer":
|
|
198
189
|
return "styleValue.getInt(VALUE_KEY)";
|
|
@@ -211,9 +202,9 @@ global.androidGetConfigType = function (androidType, prop) {
|
|
|
211
202
|
return "styleValue.getString(VALUE_KEY)";
|
|
212
203
|
}
|
|
213
204
|
}
|
|
214
|
-
}
|
|
205
|
+
}
|
|
215
206
|
|
|
216
|
-
|
|
207
|
+
export function jsStyleType(prop: any) {
|
|
217
208
|
if (prop.type === "color") {
|
|
218
209
|
return "StyleTypes.Color";
|
|
219
210
|
}
|
|
@@ -235,9 +226,9 @@ global.jsStyleType = function (prop) {
|
|
|
235
226
|
}
|
|
236
227
|
|
|
237
228
|
return "StyleTypes.Constant";
|
|
238
|
-
}
|
|
229
|
+
}
|
|
239
230
|
|
|
240
|
-
|
|
231
|
+
export function jsDocPropRequires(prop: any) {
|
|
241
232
|
if (!prop.doc.requires) {
|
|
242
233
|
return;
|
|
243
234
|
}
|
|
@@ -250,13 +241,13 @@ global.jsDocPropRequires = function (prop) {
|
|
|
250
241
|
}
|
|
251
242
|
|
|
252
243
|
return desc;
|
|
253
|
-
}
|
|
244
|
+
}
|
|
254
245
|
|
|
255
|
-
|
|
256
|
-
const result = {};
|
|
246
|
+
export function getEnums(layers: any[]) {
|
|
247
|
+
const result: Record<string, any> = {};
|
|
257
248
|
|
|
258
249
|
layers.forEach((layer) => {
|
|
259
|
-
layer.properties.forEach((property) => {
|
|
250
|
+
layer.properties.forEach((property: any) => {
|
|
260
251
|
if (
|
|
261
252
|
property.type === "enum" ||
|
|
262
253
|
(property.type === "array" && property.value === "enum")
|
|
@@ -269,10 +260,10 @@ global.getEnums = function (layers) {
|
|
|
269
260
|
});
|
|
270
261
|
});
|
|
271
262
|
return Object.values(result);
|
|
272
|
-
}
|
|
263
|
+
}
|
|
273
264
|
|
|
274
|
-
|
|
275
|
-
const propTypes = [];
|
|
265
|
+
export function dtsInterfaceType(prop: any) {
|
|
266
|
+
const propTypes: string[] = [];
|
|
276
267
|
|
|
277
268
|
if (prop.name.indexOf("Translate") !== -1 && prop.type !== "enum") {
|
|
278
269
|
propTypes.push("Translation");
|
|
@@ -332,7 +323,7 @@ ${startAtSpace(2, "")}`;
|
|
|
332
323
|
let params = "";
|
|
333
324
|
if (prop.expression && prop.expression.parameters) {
|
|
334
325
|
params = `,[${prop.expression.parameters
|
|
335
|
-
.map((v) => `'${v}'`)
|
|
326
|
+
.map((v: string) => `'${v}'`)
|
|
336
327
|
.join(",")}]`;
|
|
337
328
|
}
|
|
338
329
|
return `Value<${propTypes[0]}${params}>`;
|
|
@@ -340,9 +331,9 @@ ${startAtSpace(2, "")}`;
|
|
|
340
331
|
return propTypes[0];
|
|
341
332
|
}
|
|
342
333
|
}
|
|
343
|
-
}
|
|
334
|
+
}
|
|
344
335
|
|
|
345
|
-
|
|
336
|
+
export function jsDocReactProp(prop: any) {
|
|
346
337
|
const propTypes = [];
|
|
347
338
|
|
|
348
339
|
if (prop.type === "color") {
|
|
@@ -394,9 +385,9 @@ ${startAtSpace(2, "])")}`;
|
|
|
394
385
|
} else {
|
|
395
386
|
return propTypes[0];
|
|
396
387
|
}
|
|
397
|
-
}
|
|
388
|
+
}
|
|
398
389
|
|
|
399
|
-
function startAtSpace(spaceCount, str) {
|
|
390
|
+
export function startAtSpace(spaceCount: number, str: string) {
|
|
400
391
|
let value = "";
|
|
401
392
|
|
|
402
393
|
for (let i = 0; i < spaceCount; i++) {
|
|
@@ -406,31 +397,21 @@ function startAtSpace(spaceCount, str) {
|
|
|
406
397
|
return `${value}${str}`;
|
|
407
398
|
}
|
|
408
399
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
function replaceNewLine(str) {
|
|
412
|
-
if (str === undefined) {
|
|
413
|
-
return undefined;
|
|
414
|
-
}
|
|
415
|
-
if (str === null) {
|
|
416
|
-
return null;
|
|
417
|
-
}
|
|
418
|
-
return str.replace(/\n/g, "<br/>");
|
|
400
|
+
export function replaceNewLine(str: string) {
|
|
401
|
+
return str?.replace(/\n/g, "<br/>");
|
|
419
402
|
}
|
|
420
403
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
global.styleMarkdownTableRow = function (style) {
|
|
404
|
+
export function styleMarkdownTableRow(style: any) {
|
|
424
405
|
return `| \`${style.name}\` | \`${style.type}\` | \`${
|
|
425
406
|
style.requires.join(", ") || "none"
|
|
426
407
|
}\` | \`${style.disabledBy.join(", ") || "none"}\` | ${replaceNewLine(
|
|
427
408
|
style.description,
|
|
428
409
|
)} |`;
|
|
429
|
-
}
|
|
410
|
+
}
|
|
430
411
|
|
|
431
|
-
|
|
412
|
+
export function methodMarkdownTableRow(method: any) {
|
|
432
413
|
return method.params
|
|
433
|
-
.map((param) => {
|
|
414
|
+
.map((param: any) => {
|
|
434
415
|
return `| \`${param.name}\` | \`${
|
|
435
416
|
(param.type && param.type.name) || "n/a"
|
|
436
417
|
}\` | \`${param.optional ? "No" : "Yes"}\` | ${replaceNewLine(
|
|
@@ -438,9 +419,9 @@ global.methodMarkdownTableRow = function (method) {
|
|
|
438
419
|
)} |`;
|
|
439
420
|
})
|
|
440
421
|
.join("\n");
|
|
441
|
-
}
|
|
422
|
+
}
|
|
442
423
|
|
|
443
|
-
function _propMarkdownTableRows(props, prefix = "") {
|
|
424
|
+
function _propMarkdownTableRows(props: any[], prefix = "") {
|
|
444
425
|
return props
|
|
445
426
|
.map((prop) => {
|
|
446
427
|
let { type } = prop;
|
|
@@ -449,51 +430,46 @@ function _propMarkdownTableRows(props, prefix = "") {
|
|
|
449
430
|
}
|
|
450
431
|
const defaultValue = prop.default || "";
|
|
451
432
|
const { description = "" } = prop;
|
|
433
|
+
|
|
452
434
|
let result = `| ${prefix}${
|
|
453
435
|
prop.name
|
|
454
|
-
} | \`${type}\` | \`${defaultValue}\` | \`${
|
|
436
|
+
} | \`${type.replace(/^\\\| /, "").replace(/\n/g, " ")}\` | \`${defaultValue}\` | \`${
|
|
455
437
|
prop.required
|
|
456
438
|
}\` | ${replaceNewLine(description)} |`;
|
|
439
|
+
|
|
457
440
|
if (type === "shape") {
|
|
458
441
|
result = `${result}\n${_propMarkdownTableRows(
|
|
459
442
|
prop.type.value,
|
|
460
443
|
` ${prefix}`,
|
|
461
444
|
)}`;
|
|
462
445
|
}
|
|
446
|
+
|
|
463
447
|
return result;
|
|
464
448
|
})
|
|
465
449
|
.join("\n");
|
|
466
450
|
}
|
|
467
451
|
|
|
468
|
-
|
|
452
|
+
export function propMarkdownTableRows(component: any) {
|
|
469
453
|
return _propMarkdownTableRows(component.props, "");
|
|
470
|
-
}
|
|
454
|
+
}
|
|
471
455
|
|
|
472
|
-
|
|
456
|
+
export function getMarkdownMethodSignature(method: {
|
|
457
|
+
name: string;
|
|
458
|
+
params: { name: string; optional: boolean }[];
|
|
459
|
+
}) {
|
|
473
460
|
const params = method.params
|
|
474
|
-
.map((param
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
let name = "";
|
|
478
|
-
|
|
479
|
-
if (i !== 0) {
|
|
480
|
-
name += ", ";
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
name += param.name;
|
|
484
|
-
return isOptional ? `[${name}]` : name;
|
|
485
|
-
})
|
|
486
|
-
.join("");
|
|
461
|
+
.map((param) => (param.optional ? `[${param.name}]` : param.name))
|
|
462
|
+
.join(", ");
|
|
487
463
|
|
|
488
464
|
return `${method.name}(${params})`;
|
|
489
|
-
}
|
|
465
|
+
}
|
|
490
466
|
|
|
491
|
-
|
|
467
|
+
export function getMarkdownMethodExamples(method: any) {
|
|
492
468
|
if (method.examples == null) {
|
|
493
469
|
return null;
|
|
494
470
|
}
|
|
495
471
|
return method.examples
|
|
496
|
-
.map((example) => {
|
|
472
|
+
.map((example: string) => {
|
|
497
473
|
return `
|
|
498
474
|
|
|
499
475
|
\`\`\`javascript
|
|
@@ -503,9 +479,9 @@ ${example.trim()}
|
|
|
503
479
|
`;
|
|
504
480
|
})
|
|
505
481
|
.join("");
|
|
506
|
-
}
|
|
482
|
+
}
|
|
507
483
|
|
|
508
|
-
|
|
484
|
+
export function getStyleDefaultValue(style: any) {
|
|
509
485
|
if (style.type === "string" && style.default === "") {
|
|
510
486
|
return "empty string";
|
|
511
487
|
} else if (style.type.includes("array")) {
|
|
@@ -513,7 +489,7 @@ global.getStyleDefaultValue = function (style) {
|
|
|
513
489
|
} else {
|
|
514
490
|
return style.default;
|
|
515
491
|
}
|
|
516
|
-
}
|
|
492
|
+
}
|
|
517
493
|
|
|
518
494
|
Object.keys(iosSpecOverrides).forEach((propName) => {
|
|
519
495
|
const camelCasePropName = camelCase(propName);
|
|
@@ -521,8 +497,3 @@ Object.keys(iosSpecOverrides).forEach((propName) => {
|
|
|
521
497
|
iosSpecOverrides[propName],
|
|
522
498
|
);
|
|
523
499
|
});
|
|
524
|
-
|
|
525
|
-
module.exports = {
|
|
526
|
-
camelCase,
|
|
527
|
-
pascalCase,
|
|
528
|
-
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { promises as fs } from "fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
4
|
+
async function getNativeVersion(pathSegments: string[], regex: RegExp) {
|
|
5
|
+
const resolvedFilePath = path.join(__dirname, "..", "..", ...pathSegments);
|
|
6
|
+
const lines = (await fs.readFile(resolvedFilePath, "utf8")).split("\n");
|
|
7
|
+
const line = lines.filter((i) => regex.exec(i))[0];
|
|
8
|
+
const version = regex.exec(line)?.[1];
|
|
9
|
+
|
|
10
|
+
if (!version) {
|
|
11
|
+
throw new Error("Could not find native version from " + resolvedFilePath);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return version;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
let cachedAndroidVersion: string;
|
|
18
|
+
let cachedIosVersion: string;
|
|
19
|
+
|
|
20
|
+
export const getAndroidVersion = async () => {
|
|
21
|
+
if (!cachedAndroidVersion) {
|
|
22
|
+
cachedAndroidVersion = await getNativeVersion(
|
|
23
|
+
["android", "rctmln", "build.gradle"],
|
|
24
|
+
/^\s+implementation\s+"org.maplibre.gl:android-sdk:(\d+\.\d+\.\d+)"$/,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return cachedAndroidVersion;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const getIosVersion = async () => {
|
|
32
|
+
if (!cachedIosVersion) {
|
|
33
|
+
cachedIosVersion = await getNativeVersion(
|
|
34
|
+
["maplibre-react-native.podspec"],
|
|
35
|
+
/^\s+version:\s*"(\d+\.\d+\.\d+)"$/,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return cachedIosVersion;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export function isVersionGTE(
|
|
43
|
+
version: string,
|
|
44
|
+
otherVersion: string | undefined,
|
|
45
|
+
) {
|
|
46
|
+
return (
|
|
47
|
+
!!otherVersion?.match(/^(\d+\.\d+\.\d+)$/) &&
|
|
48
|
+
version.localeCompare(otherVersion, undefined, {
|
|
49
|
+
numeric: true,
|
|
50
|
+
sensitivity: "base",
|
|
51
|
+
}) >= 0
|
|
52
|
+
);
|
|
53
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"isolatedModules": true,
|
|
11
11
|
"skipLibCheck": true,
|
|
12
12
|
"strict": true,
|
|
13
|
+
"strictNullChecks": true,
|
|
13
14
|
"types": ["node", "react-native", "geojson", "jest"],
|
|
14
15
|
"moduleResolution": "node",
|
|
15
16
|
"allowSyntheticDefaultImports": true,
|
|
@@ -17,7 +18,5 @@
|
|
|
17
18
|
"noUnusedLocals": true,
|
|
18
19
|
"noImplicitReturns": true
|
|
19
20
|
},
|
|
20
|
-
"include": [
|
|
21
|
-
"javascript/**/*", "index.ts"
|
|
22
|
-
],
|
|
21
|
+
"include": ["javascript/**/*", "index.ts"]
|
|
23
22
|
}
|
package/docs/OfflineManager.md
DELETED
|
@@ -1,246 +0,0 @@
|
|
|
1
|
-
<!-- This file was autogenerated from offlineManager.js do not modify -->
|
|
2
|
-
## <MapLibreGL.offlineManager />
|
|
3
|
-
### OfflineManager implements a singleton (shared object) that manages offline packs.<br/>All of this class’s instance methods are asynchronous, reflecting the fact that offline resources are stored in a database.<br/>The shared object maintains a canonical collection of offline packs.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
### methods
|
|
7
|
-
#### createPack(options[, progressListener][, errorListener])
|
|
8
|
-
|
|
9
|
-
Creates and registers an offline pack that downloads the resources needed to use the given region offline.
|
|
10
|
-
|
|
11
|
-
##### arguments
|
|
12
|
-
| Name | Type | Required | Description |
|
|
13
|
-
| ---- | :--: | :------: | :----------: |
|
|
14
|
-
| `options` | `OfflineCreatePackOptions` | `Yes` | Create options for a offline pack that specifices zoom levels, style url, and the region to download. |
|
|
15
|
-
| `progressListener` | `Callback` | `No` | Callback that listens for status events while downloading the offline resource. |
|
|
16
|
-
| `errorListener` | `Callback` | `No` | Callback that listens for status events while downloading the offline resource. |
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
```javascript
|
|
21
|
-
const progressListener = (offlineRegion, status) => console.log(offlineRegion, status);
|
|
22
|
-
const errorListener = (offlineRegion, err) => console.log(offlineRegion, err);
|
|
23
|
-
|
|
24
|
-
await MapLibreGL.offlineManager.createPack({
|
|
25
|
-
name: 'offlinePack',
|
|
26
|
-
styleURL: 'mapbox://...',
|
|
27
|
-
minZoom: 14,
|
|
28
|
-
maxZoom: 20,
|
|
29
|
-
bounds: [[neLng, neLat], [swLng, swLat]]
|
|
30
|
-
}, progressListener, errorListener)
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
#### invalidatePack(name)
|
|
35
|
-
|
|
36
|
-
Invalidates the specified offline pack. This method checks that the tiles in the specified offline pack match those from the server. Local tiles that do not match the latest version on the server are updated.This is more efficient than deleting the offline pack and downloading it again. If the data stored locally matches that on the server, new data will not be downloaded.
|
|
37
|
-
|
|
38
|
-
##### arguments
|
|
39
|
-
| Name | Type | Required | Description |
|
|
40
|
-
| ---- | :--: | :------: | :----------: |
|
|
41
|
-
| `name` | `String` | `Yes` | Name of the offline pack. |
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
```javascript
|
|
46
|
-
await MapLibreGL.offlineManager.invalidatePack('packName')
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
#### deletePack(name)
|
|
51
|
-
|
|
52
|
-
Unregisters the given offline pack and allows resources that are no longer required by any remaining packs to be potentially freed.
|
|
53
|
-
|
|
54
|
-
##### arguments
|
|
55
|
-
| Name | Type | Required | Description |
|
|
56
|
-
| ---- | :--: | :------: | :----------: |
|
|
57
|
-
| `name` | `String` | `Yes` | Name of the offline pack. |
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
```javascript
|
|
62
|
-
await MapLibreGL.offlineManager.deletePack('packName')
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
#### invalidateAmbientCache()
|
|
67
|
-
|
|
68
|
-
Forces a revalidation of the tiles in the ambient cache and downloads a fresh version of the tiles from the tile server.<br/>This is the recommend method for clearing the cache.<br/>This is the most efficient method because tiles in the ambient cache are re-downloaded to remove outdated data from a device.<br/>It does not erase resources from the ambient cache or delete the database, which can be computationally expensive operations that may carry unintended side effects.
|
|
69
|
-
|
|
70
|
-
##### arguments
|
|
71
|
-
| Name | Type | Required | Description |
|
|
72
|
-
| ---- | :--: | :------: | :----------: |
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
```javascript
|
|
78
|
-
await MapLibreGL.offlineManager.invalidateAmbientCache();
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
#### clearAmbientCache()
|
|
83
|
-
|
|
84
|
-
Erases resources from the ambient cache.<br/>This method clears the cache and decreases the amount of space that map resources take up on the device.
|
|
85
|
-
|
|
86
|
-
##### arguments
|
|
87
|
-
| Name | Type | Required | Description |
|
|
88
|
-
| ---- | :--: | :------: | :----------: |
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
```javascript
|
|
94
|
-
await MapLibreGL.offlineManager.clearAmbientCache();
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
#### setMaximumAmbientCacheSize(size)
|
|
99
|
-
|
|
100
|
-
Sets the maximum size of the ambient cache in bytes. Disables the ambient cache if set to 0.<br/>This method may be computationally expensive because it will erase resources from the ambient cache if its size is decreased.
|
|
101
|
-
|
|
102
|
-
##### arguments
|
|
103
|
-
| Name | Type | Required | Description |
|
|
104
|
-
| ---- | :--: | :------: | :----------: |
|
|
105
|
-
| `size` | `Number` | `Yes` | Size of ambient cache. |
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
```javascript
|
|
110
|
-
await MapLibreGL.offlineManager.setMaximumAmbientCacheSize(5000000);
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
#### resetDatabase()
|
|
115
|
-
|
|
116
|
-
Deletes the existing database, which includes both the ambient cache and offline packs, then reinitializes it.
|
|
117
|
-
|
|
118
|
-
##### arguments
|
|
119
|
-
| Name | Type | Required | Description |
|
|
120
|
-
| ---- | :--: | :------: | :----------: |
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
```javascript
|
|
126
|
-
await MapLibreGL.offlineManager.resetDatabase();
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
#### getPacks()
|
|
131
|
-
|
|
132
|
-
Retrieves all the current offline packs that are stored in the database.
|
|
133
|
-
|
|
134
|
-
##### arguments
|
|
135
|
-
| Name | Type | Required | Description |
|
|
136
|
-
| ---- | :--: | :------: | :----------: |
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
```javascript
|
|
142
|
-
const offlinePacks = await MapLibreGL.offlineManager.getPacks();
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
#### getPack(name)
|
|
147
|
-
|
|
148
|
-
Retrieves an offline pack that is stored in the database by name.
|
|
149
|
-
|
|
150
|
-
##### arguments
|
|
151
|
-
| Name | Type | Required | Description |
|
|
152
|
-
| ---- | :--: | :------: | :----------: |
|
|
153
|
-
| `name` | `String` | `Yes` | Name of the offline pack. |
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
```javascript
|
|
158
|
-
const offlinePack = await MapLibreGL.offlineManager.getPack();
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
#### mergeOfflineRegions(path)
|
|
163
|
-
|
|
164
|
-
Sideloads offline db
|
|
165
|
-
|
|
166
|
-
##### arguments
|
|
167
|
-
| Name | Type | Required | Description |
|
|
168
|
-
| ---- | :--: | :------: | :----------: |
|
|
169
|
-
| `path` | `String` | `Yes` | Path to offline tile db on file system. |
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
```javascript
|
|
174
|
-
await MapLibreGL.offlineManager.mergeOfflineRegions(path);
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
#### setTileCountLimit(limit)
|
|
179
|
-
|
|
180
|
-
Sets the maximum number of tiles that may be downloaded and stored on the current device.<br/>Consult the Terms of Service for your map tile host before changing this value.
|
|
181
|
-
|
|
182
|
-
##### arguments
|
|
183
|
-
| Name | Type | Required | Description |
|
|
184
|
-
| ---- | :--: | :------: | :----------: |
|
|
185
|
-
| `limit` | `Number` | `Yes` | Map tile limit count. |
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
```javascript
|
|
190
|
-
MapLibreGL.offlineManager.setTileCountLimit(1000);
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
#### setProgressEventThrottle(throttleValue)
|
|
195
|
-
|
|
196
|
-
Sets the period at which download status events will be sent over the React Native bridge.<br/>The default is 500ms.
|
|
197
|
-
|
|
198
|
-
##### arguments
|
|
199
|
-
| Name | Type | Required | Description |
|
|
200
|
-
| ---- | :--: | :------: | :----------: |
|
|
201
|
-
| `throttleValue` | `Number` | `Yes` | event throttle value in ms. |
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
```javascript
|
|
206
|
-
MapLibreGL.offlineManager.setProgressEventThrottle(500);
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
#### subscribe(packName, progressListener, errorListener)
|
|
211
|
-
|
|
212
|
-
Subscribe to download status/error events for the requested offline pack.<br/>Note that createPack calls this internally if listeners are provided.
|
|
213
|
-
|
|
214
|
-
##### arguments
|
|
215
|
-
| Name | Type | Required | Description |
|
|
216
|
-
| ---- | :--: | :------: | :----------: |
|
|
217
|
-
| `packName` | `String` | `Yes` | Name of the offline pack. |
|
|
218
|
-
| `progressListener` | `Callback` | `Yes` | Callback that listens for status events while downloading the offline resource. |
|
|
219
|
-
| `errorListener` | `Callback` | `Yes` | Callback that listens for status events while downloading the offline resource. |
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
```javascript
|
|
224
|
-
const progressListener = (offlinePack, status) => console.log(offlinePack, status)
|
|
225
|
-
const errorListener = (offlinePack, err) => console.log(offlinePack, err)
|
|
226
|
-
MapLibreGL.offlineManager.subscribe('packName', progressListener, errorListener)
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
#### unsubscribe(packName)
|
|
231
|
-
|
|
232
|
-
Unsubscribes any listeners associated with the offline pack.<br/>It's a good idea to call this on componentWillUnmount.
|
|
233
|
-
|
|
234
|
-
##### arguments
|
|
235
|
-
| Name | Type | Required | Description |
|
|
236
|
-
| ---- | :--: | :------: | :----------: |
|
|
237
|
-
| `packName` | `String` | `Yes` | Name of the offline pack. |
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
```javascript
|
|
242
|
-
MapLibreGL.offlineManager.unsubscribe('packName')
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
|
|
3
|
-
echo "Downloading MapLibre Style Spec"
|
|
4
|
-
cd style-spec/
|
|
5
|
-
|
|
6
|
-
FILENAME=v8.json
|
|
7
|
-
|
|
8
|
-
if [ -e "./${FILENAME}" ]; then
|
|
9
|
-
echo "Removing old style spec ${FILENAME}"
|
|
10
|
-
rm "./${FILENAME}"
|
|
11
|
-
fi
|
|
12
|
-
|
|
13
|
-
echo "Fetching new style spec ${FILENAME}"
|
|
14
|
-
curl -sS https://raw.githubusercontent.com/maplibre/maplibre-style-spec/main/src/reference/${FILENAME} -o ${FILENAME}
|
|
15
|
-
cd ..
|