@maplibre/maplibre-react-native 10.0.0-alpha.21 → 10.0.0-alpha.22
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/.eslintrc.js +5 -0
- package/.git-blame-ignore-revs +3 -0
- package/CHANGELOG.md +13 -0
- package/app.plugin.js +1 -1
- package/babel.config.js +6 -3
- package/javascript/components/HeadingIndicator.tsx +0 -1
- package/javascript/components/MapView.tsx +2 -3
- package/javascript/types/png.d.ts +1 -0
- package/jest-setup.ts +113 -0
- package/jest.config.js +8 -0
- package/package.json +22 -62
- package/react-native.config.js +1 -1
- package/scripts/.eslintrc.js +3 -0
- package/scripts/{autogenerate.js → generate-docs.js} +144 -137
- package/scripts/templates/MaplibreStyles.ts.ejs +5 -5
- package/scripts/templates/RCTMLNStyle.h.ejs +2 -2
- package/scripts/templates/RCTMLNStyle.m.ejs +6 -6
- package/scripts/templates/RCTMLNStyleFactory.java.ejs +8 -8
- package/scripts/{autogenHelpers → utils}/DocJSONBuilder.js +70 -70
- package/scripts/{autogenHelpers → utils}/JSDocNodeTree.js +33 -30
- package/scripts/utils/MarkdownBuilder.js +37 -0
- package/scripts/utils/template-globals.js +528 -0
- package/tsconfig.json +2 -2
- package/scripts/autogenHelpers/MarkdownBuilder.js +0 -29
- package/scripts/autogenHelpers/globals.js +0 -508
- package/setup-jest.js +0 -108
|
@@ -1,508 +0,0 @@
|
|
|
1
|
-
let iosPropNameOverrides = {};
|
|
2
|
-
|
|
3
|
-
const iosSpecOverrides = {
|
|
4
|
-
'icon-allow-overlap': 'icon-allows-overlap',
|
|
5
|
-
'icon-image': 'icon-image-name',
|
|
6
|
-
'icon-ignore-placement': 'icon-ignores-placement',
|
|
7
|
-
'icon-keep-upright': 'keeps-icon-upright',
|
|
8
|
-
'icon-rotate': 'icon-rotation',
|
|
9
|
-
'icon-size': 'icon-scale',
|
|
10
|
-
'symbol-avoid-edges': 'symbol-avoids-edges',
|
|
11
|
-
'text-allow-overlap': 'text-allows-overlap',
|
|
12
|
-
'text-field': 'text',
|
|
13
|
-
'text-font': 'text-font-names',
|
|
14
|
-
'text-ignore-placement': 'text-ignores-placement',
|
|
15
|
-
'text-justify': 'text-justification',
|
|
16
|
-
'text-keep-upright': 'keeps-text-upright',
|
|
17
|
-
'text-max-angle': 'maximum-text-angle',
|
|
18
|
-
'text-max-width': 'maximum-text-width',
|
|
19
|
-
'text-rotate': 'text-rotation',
|
|
20
|
-
'text-size': 'text-font-size',
|
|
21
|
-
'circle-pitch-scale': 'circle-scale-alignment',
|
|
22
|
-
'circle-translate': 'circle-translation',
|
|
23
|
-
'circle-translate-anchor': 'circle-translation-anchor',
|
|
24
|
-
'fill-antialias': 'fill-antialiased',
|
|
25
|
-
'fill-translate': 'fill-translation',
|
|
26
|
-
'fill-translate-anchor': 'fill-translation-anchor',
|
|
27
|
-
'fill-extrusion-translate': 'fill-extrusion-translation',
|
|
28
|
-
'fill-extrusion-translate-anchor': 'fill-extrusion-translation-anchor',
|
|
29
|
-
'raster-brightness-min': 'minimum-raster-brightness',
|
|
30
|
-
'raster-brightness-max': 'maximum-raster-brightness',
|
|
31
|
-
'raster-hue-rotate': 'raster-hue-rotation',
|
|
32
|
-
'line-dasharray': 'line-dash-pattern',
|
|
33
|
-
'line-translate': 'line-translation',
|
|
34
|
-
'line-translate-anchor': 'line-translation-anchor',
|
|
35
|
-
'icon-translate': 'icon-translation',
|
|
36
|
-
'icon-translate-anchor': 'icon-translation-anchor',
|
|
37
|
-
'text-translate': 'text-translation',
|
|
38
|
-
'text-translate-anchor': 'text-translation-anchor',
|
|
39
|
-
'raster-resampling': 'raster-resampling-mode',
|
|
40
|
-
'text-writing-mode': 'text-writing-modes',
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
global.getValue = function (value, defaultValue) {
|
|
44
|
-
if (!exists(value) || value === '') {
|
|
45
|
-
return defaultValue;
|
|
46
|
-
}
|
|
47
|
-
return value;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
global.exists = function (value) {
|
|
51
|
-
return typeof value !== 'undefined' && value !== null;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
global.camelCase = function (str, delimiter = '-') {
|
|
55
|
-
const parts = str.split(delimiter);
|
|
56
|
-
return parts
|
|
57
|
-
.map((part, index) => {
|
|
58
|
-
if (index === 0) {
|
|
59
|
-
return part;
|
|
60
|
-
}
|
|
61
|
-
return part.charAt(0).toUpperCase() + part.substring(1);
|
|
62
|
-
})
|
|
63
|
-
.join('');
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
global.pascelCase = function (str, delimiter = '-') {
|
|
67
|
-
const parts = str.split(delimiter);
|
|
68
|
-
return parts
|
|
69
|
-
.map((part, index) => {
|
|
70
|
-
return part.charAt(0).toUpperCase() + part.substring(1);
|
|
71
|
-
})
|
|
72
|
-
.join('');
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
global.setLayerMethodName = function (layer, platform) {
|
|
76
|
-
if (platform === 'ios') {
|
|
77
|
-
return `${camelCase(layer.name)}Layer`;
|
|
78
|
-
}
|
|
79
|
-
return `set${pascelCase(layer.name)}LayerStyle`;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
global.getLayerType = function (layer, platform) {
|
|
83
|
-
const isIOS = platform === 'ios';
|
|
84
|
-
|
|
85
|
-
switch (layer.name) {
|
|
86
|
-
case 'fill':
|
|
87
|
-
return isIOS ? 'MLNFillStyleLayer' : 'FillLayer';
|
|
88
|
-
case 'fill-extrusion':
|
|
89
|
-
return isIOS ? 'MLNFillExtrusionStyleLayer' : 'FillExtrusionLayer';
|
|
90
|
-
case 'line':
|
|
91
|
-
return isIOS ? 'MLNLineStyleLayer' : 'LineLayer';
|
|
92
|
-
case 'symbol':
|
|
93
|
-
return isIOS ? 'MLNSymbolStyleLayer' : 'SymbolLayer';
|
|
94
|
-
case 'circle':
|
|
95
|
-
return isIOS ? 'MLNCircleStyleLayer' : 'CircleLayer';
|
|
96
|
-
case 'background':
|
|
97
|
-
return isIOS ? 'MLNBackgroundStyleLayer' : 'BackgroundLayer';
|
|
98
|
-
case 'raster':
|
|
99
|
-
return isIOS ? 'MLNRasterStyleLayer' : 'RasterLayer';
|
|
100
|
-
case 'heatmap':
|
|
101
|
-
return isIOS ? 'MLNHeatmapStyleLayer' : 'HeatmapLayer';
|
|
102
|
-
case 'hillshade':
|
|
103
|
-
return isIOS ? 'MLNHillshadeStyleLayer' : 'HillshadeLayer';
|
|
104
|
-
case 'light':
|
|
105
|
-
return isIOS ? 'MLNLight' : 'Light';
|
|
106
|
-
default:
|
|
107
|
-
throw new Error(
|
|
108
|
-
`Is ${layer.name} a new layer? We should add support for it!`,
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
global.ifOrElseIf = function (index) {
|
|
114
|
-
if (index === 0) {
|
|
115
|
-
return 'if';
|
|
116
|
-
}
|
|
117
|
-
return '} else if';
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
global.iosStringArrayLiteral = function (arr) {
|
|
121
|
-
return `@[@${arr.map((item) => `"${item}"`).join(', @')}]`;
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
global.iosPropName = function (name) {
|
|
125
|
-
if (name.indexOf('visibility') !== -1) {
|
|
126
|
-
return 'visible';
|
|
127
|
-
}
|
|
128
|
-
if (name === 'fillExtrusionVerticalGradient') {
|
|
129
|
-
return 'fillExtrusionHasVerticalGradient';
|
|
130
|
-
}
|
|
131
|
-
if (iosPropNameOverrides[name]) {
|
|
132
|
-
return iosPropNameOverrides[name];
|
|
133
|
-
}
|
|
134
|
-
return name;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
global.iosMapLibrePropName = function (name) {
|
|
138
|
-
let result = iosPropName(name);
|
|
139
|
-
if (result === 'fillExtrusionVerticalGradient') {
|
|
140
|
-
return 'fillExtrusionHasVerticalGradient';
|
|
141
|
-
}
|
|
142
|
-
return undefined;
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
global.iosPropMethodName = function (layer, name) {
|
|
146
|
-
if (name.indexOf('Visibility') !== -1) {
|
|
147
|
-
return pascelCase(layer.name) + 'StyleLayer' + name;
|
|
148
|
-
}
|
|
149
|
-
return name;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
global.androidInputType = function (type, value) {
|
|
153
|
-
if (type === 'array' && value) {
|
|
154
|
-
return `${androidInputType(value)}[]`;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
switch (type) {
|
|
158
|
-
case 'color':
|
|
159
|
-
return 'Integer';
|
|
160
|
-
case 'boolean':
|
|
161
|
-
return 'Boolean';
|
|
162
|
-
case 'number':
|
|
163
|
-
return 'Float';
|
|
164
|
-
default:
|
|
165
|
-
return 'String';
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
global.androidOutputType = function (type, value) {
|
|
170
|
-
if (type === 'array' && value) {
|
|
171
|
-
return `${androidOutputType(value)}[]`;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
switch (type) {
|
|
175
|
-
case 'color':
|
|
176
|
-
return 'String';
|
|
177
|
-
case 'boolean':
|
|
178
|
-
return 'Boolean';
|
|
179
|
-
case 'number':
|
|
180
|
-
return 'Float';
|
|
181
|
-
default:
|
|
182
|
-
return 'String';
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
global.androidGetConfigType = function (androidType, prop) {
|
|
187
|
-
switch (androidType) {
|
|
188
|
-
case 'Integer':
|
|
189
|
-
return 'styleValue.getInt(VALUE_KEY)';
|
|
190
|
-
case 'Float':
|
|
191
|
-
return 'styleValue.getFloat(VALUE_KEY)';
|
|
192
|
-
case 'Boolean':
|
|
193
|
-
return 'styleValue.getBoolean(VALUE_KEY)';
|
|
194
|
-
case 'Float[]':
|
|
195
|
-
return 'styleValue.getFloatArray(VALUE_KEY)';
|
|
196
|
-
case 'String[]':
|
|
197
|
-
return 'styleValue.getStringArray(VALUE_KEY)';
|
|
198
|
-
default:
|
|
199
|
-
if (prop && prop.image) {
|
|
200
|
-
return 'styleValue.getImageURI()';
|
|
201
|
-
} else {
|
|
202
|
-
return 'styleValue.getString(VALUE_KEY)';
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
global.jsStyleType = function (prop) {
|
|
208
|
-
if (prop.type === 'color') {
|
|
209
|
-
return 'StyleTypes.Color';
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (prop.type === 'enum') {
|
|
213
|
-
return 'StyleTypes.Enum';
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (prop.type === 'string' && prop.image) {
|
|
217
|
-
return 'StyleTypes.Image';
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (prop.type === 'resolvedImage') {
|
|
221
|
-
return 'StyleTypes.Image';
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
if (prop.name.indexOf('Translate') !== -1) {
|
|
225
|
-
return 'StyleTypes.Translation';
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
return 'StyleTypes.Constant';
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
global.jsDocPropRequires = function (prop) {
|
|
232
|
-
if (!prop.doc.requires) {
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
let desc = '';
|
|
237
|
-
for (let item of prop.doc.requires) {
|
|
238
|
-
if (typeof item === 'string') {
|
|
239
|
-
desc += item + ', ';
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
return desc;
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
global.getEnums = function (layers) {
|
|
247
|
-
let result = {};
|
|
248
|
-
|
|
249
|
-
layers.forEach((layer) => {
|
|
250
|
-
layer.properties.forEach((property) => {
|
|
251
|
-
if (
|
|
252
|
-
property.type === 'enum' ||
|
|
253
|
-
(property.type === 'array' && property.value === 'enum')
|
|
254
|
-
) {
|
|
255
|
-
result[property.name] = {
|
|
256
|
-
values: property.doc.values,
|
|
257
|
-
name: property.name,
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
return Object.values(result);
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
global.dtsInterfaceType = function (prop) {
|
|
267
|
-
let propTypes = [];
|
|
268
|
-
|
|
269
|
-
if (prop.name.indexOf('Translate') !== -1 && prop.type != 'enum') {
|
|
270
|
-
propTypes.push('Translation');
|
|
271
|
-
} else if (prop.type === 'color') {
|
|
272
|
-
propTypes.push('string');
|
|
273
|
-
// propTypes.push('ConstantPropType');
|
|
274
|
-
} else if (prop.type === 'array') {
|
|
275
|
-
switch (prop.value) {
|
|
276
|
-
case 'number':
|
|
277
|
-
propTypes.push('number[]');
|
|
278
|
-
break;
|
|
279
|
-
case 'boolean':
|
|
280
|
-
propTypes.push('boolean[]');
|
|
281
|
-
break;
|
|
282
|
-
case 'string':
|
|
283
|
-
propTypes.push('string[]');
|
|
284
|
-
break;
|
|
285
|
-
case 'enum':
|
|
286
|
-
propTypes.push(
|
|
287
|
-
`Enum<${pascelCase(prop.name)}Enum, ${pascelCase(
|
|
288
|
-
prop.name,
|
|
289
|
-
)}EnumValues>[]`,
|
|
290
|
-
);
|
|
291
|
-
break;
|
|
292
|
-
}
|
|
293
|
-
// propTypes.push('ConstantPropType');
|
|
294
|
-
} else if (prop.type === 'number') {
|
|
295
|
-
propTypes.push('number');
|
|
296
|
-
} else if (prop.type === 'enum') {
|
|
297
|
-
propTypes.push(
|
|
298
|
-
`Enum<${pascelCase(prop.name)}Enum, ${pascelCase(prop.name)}EnumValues>`,
|
|
299
|
-
);
|
|
300
|
-
} else if (prop.type === 'boolean') {
|
|
301
|
-
propTypes.push('boolean');
|
|
302
|
-
} else if (prop.type === 'resolvedImage') {
|
|
303
|
-
propTypes.push('ResolvedImageType');
|
|
304
|
-
} else if (prop.type === 'formatted') {
|
|
305
|
-
propTypes.push('FormattedString');
|
|
306
|
-
} else if (prop.type === 'string') {
|
|
307
|
-
propTypes.push('string');
|
|
308
|
-
} else {
|
|
309
|
-
console.error('Unexpected type:', prop.type);
|
|
310
|
-
throw new Error(`Unexpected type: ${prop.type} for ${prop.name}`);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/*
|
|
314
|
-
if (prop.allowedFunctionTypes && prop.allowedFunctionTypes.length > 0) {
|
|
315
|
-
propTypes.push('StyleFunctionProps');
|
|
316
|
-
}
|
|
317
|
-
*/
|
|
318
|
-
|
|
319
|
-
if (propTypes.length > 1) {
|
|
320
|
-
return `${propTypes.map((p) => startAtSpace(4, p)).join(' | ')},
|
|
321
|
-
${startAtSpace(2, '')}`;
|
|
322
|
-
} else {
|
|
323
|
-
if (prop.expressionSupported) {
|
|
324
|
-
let params = '';
|
|
325
|
-
if (prop.expression && prop.expression.parameters) {
|
|
326
|
-
params = `,[${prop.expression.parameters
|
|
327
|
-
.map((v) => `'${v}'`)
|
|
328
|
-
.join(',')}]`;
|
|
329
|
-
}
|
|
330
|
-
return `Value<${propTypes[0]}${params}>`;
|
|
331
|
-
} else {
|
|
332
|
-
return propTypes[0];
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
|
|
337
|
-
global.jsDocReactProp = function (prop) {
|
|
338
|
-
let propTypes = [];
|
|
339
|
-
|
|
340
|
-
if (prop.type === 'color') {
|
|
341
|
-
propTypes.push('PropTypes.string');
|
|
342
|
-
} else if (prop.type === 'array') {
|
|
343
|
-
switch (prop.value) {
|
|
344
|
-
case 'number':
|
|
345
|
-
propTypes.push('PropTypes.arrayOf(PropTypes.number)');
|
|
346
|
-
break;
|
|
347
|
-
case 'boolean':
|
|
348
|
-
propTypes.push('PropTypes.arrayOf(PropTypes.bool)');
|
|
349
|
-
break;
|
|
350
|
-
case 'string':
|
|
351
|
-
propTypes.push('PropTypes.arrayOf(PropTypes.string)');
|
|
352
|
-
break;
|
|
353
|
-
default:
|
|
354
|
-
propTypes.push('PropTypes.array');
|
|
355
|
-
}
|
|
356
|
-
} else if (prop.type === 'number') {
|
|
357
|
-
propTypes.push('PropTypes.number');
|
|
358
|
-
} else if (prop.type === 'boolean') {
|
|
359
|
-
propTypes.push('PropTypes.bool');
|
|
360
|
-
} else if (prop.type === 'enum') {
|
|
361
|
-
if (prop.doc.values) {
|
|
362
|
-
propTypes.push(
|
|
363
|
-
`PropTypes.oneOf([${Object.keys(prop.doc.values)
|
|
364
|
-
.map((v) => `'${v}'`)
|
|
365
|
-
.join(', ')}])`,
|
|
366
|
-
);
|
|
367
|
-
} else {
|
|
368
|
-
propTypes.push('PropTypes.any');
|
|
369
|
-
}
|
|
370
|
-
} else {
|
|
371
|
-
// images can be required which result in a number
|
|
372
|
-
if (prop.image) {
|
|
373
|
-
propTypes.push('PropTypes.number');
|
|
374
|
-
}
|
|
375
|
-
propTypes.push('PropTypes.string');
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
if (prop.expressionSupported && !propTypes.includes('PropTypes.array')) {
|
|
379
|
-
propTypes.push('PropTypes.array');
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
if (propTypes.length > 1) {
|
|
383
|
-
return `PropTypes.oneOfType([
|
|
384
|
-
${propTypes.map((p) => startAtSpace(4, p)).join(',\n')},
|
|
385
|
-
${startAtSpace(2, '])')}`;
|
|
386
|
-
} else {
|
|
387
|
-
return propTypes[0];
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
global.startAtSpace = function (spaceCount, str) {
|
|
392
|
-
let value = '';
|
|
393
|
-
|
|
394
|
-
for (let i = 0; i < spaceCount; i++) {
|
|
395
|
-
value += ' ';
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
return `${value}${str}`;
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
global.replaceNewLine = function (str) {
|
|
402
|
-
if (str === undefined) {
|
|
403
|
-
return undefined;
|
|
404
|
-
}
|
|
405
|
-
if (str === null) {
|
|
406
|
-
return null;
|
|
407
|
-
}
|
|
408
|
-
return str.replace(/\n/g, '<br/>');
|
|
409
|
-
};
|
|
410
|
-
|
|
411
|
-
global.styleMarkdownTableRow = function (style) {
|
|
412
|
-
return `| \`${style.name}\` | \`${style.type}\` | \`${
|
|
413
|
-
style.requires.join(', ') || 'none'
|
|
414
|
-
}\` | \`${style.disabledBy.join(', ') || 'none'}\` | ${replaceNewLine(
|
|
415
|
-
style.description,
|
|
416
|
-
)} |`;
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
global.methodMarkdownTableRow = function (method) {
|
|
420
|
-
return method.params
|
|
421
|
-
.map((param) => {
|
|
422
|
-
return `| \`${param.name}\` | \`${
|
|
423
|
-
(param.type && param.type.name) || 'n/a'
|
|
424
|
-
}\` | \`${param.optional ? 'No' : 'Yes'}\` | ${replaceNewLine(
|
|
425
|
-
param.description,
|
|
426
|
-
)} |`;
|
|
427
|
-
})
|
|
428
|
-
.join('\n');
|
|
429
|
-
};
|
|
430
|
-
|
|
431
|
-
function _propMarkdownTableRows(props, prefix = '') {
|
|
432
|
-
return props
|
|
433
|
-
.map((prop) => {
|
|
434
|
-
let { type } = prop;
|
|
435
|
-
if (typeof type === 'object') {
|
|
436
|
-
type = type.name;
|
|
437
|
-
}
|
|
438
|
-
let defaultValue = prop.default || '';
|
|
439
|
-
let { description = '' } = prop;
|
|
440
|
-
let result = `| ${prefix}${
|
|
441
|
-
prop.name
|
|
442
|
-
} | \`${type}\` | \`${defaultValue}\` | \`${
|
|
443
|
-
prop.required
|
|
444
|
-
}\` | ${replaceNewLine(description)} |`;
|
|
445
|
-
if (type == 'shape') {
|
|
446
|
-
result = `${result}\n${_propMarkdownTableRows(
|
|
447
|
-
prop.type.value,
|
|
448
|
-
` ${prefix}`,
|
|
449
|
-
)}`;
|
|
450
|
-
}
|
|
451
|
-
return result;
|
|
452
|
-
})
|
|
453
|
-
.join('\n');
|
|
454
|
-
}
|
|
455
|
-
global.propMarkdownTableRows = function (component) {
|
|
456
|
-
return _propMarkdownTableRows(component.props, '');
|
|
457
|
-
};
|
|
458
|
-
|
|
459
|
-
global.getMarkdownMethodSignature = function (method) {
|
|
460
|
-
const params = method.params
|
|
461
|
-
.map((param, i) => {
|
|
462
|
-
const isOptional = param.optional;
|
|
463
|
-
|
|
464
|
-
let name = '';
|
|
465
|
-
|
|
466
|
-
if (i !== 0) {
|
|
467
|
-
name += ', ';
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
name += param.name;
|
|
471
|
-
return isOptional ? `[${name}]` : name;
|
|
472
|
-
})
|
|
473
|
-
.join('');
|
|
474
|
-
|
|
475
|
-
return `${method.name}(${params})`;
|
|
476
|
-
};
|
|
477
|
-
|
|
478
|
-
global.getMarkdownMethodExamples = function (method) {
|
|
479
|
-
if (method.examples == null) {
|
|
480
|
-
return null;
|
|
481
|
-
}
|
|
482
|
-
return method.examples
|
|
483
|
-
.map((example) => {
|
|
484
|
-
return `
|
|
485
|
-
|
|
486
|
-
\`\`\`javascript
|
|
487
|
-
${example.trim()}
|
|
488
|
-
\`\`\`
|
|
489
|
-
|
|
490
|
-
`;
|
|
491
|
-
})
|
|
492
|
-
.join('');
|
|
493
|
-
};
|
|
494
|
-
|
|
495
|
-
global.getStyleDefaultValue = function (style) {
|
|
496
|
-
if (style.type === 'string' && style.default === '') {
|
|
497
|
-
return 'empty string';
|
|
498
|
-
} else if (style.type.includes('array')) {
|
|
499
|
-
return `[${style.default}]`;
|
|
500
|
-
} else {
|
|
501
|
-
return style.default;
|
|
502
|
-
}
|
|
503
|
-
};
|
|
504
|
-
|
|
505
|
-
Object.keys(iosSpecOverrides).forEach((propName) => {
|
|
506
|
-
const camelCasePropName = camelCase(propName);
|
|
507
|
-
iosPropNameOverrides[camelCasePropName] = camelCase(iosSpecOverrides[propName]);
|
|
508
|
-
});
|
package/setup-jest.js
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import {NativeModules} from 'react-native';
|
|
2
|
-
|
|
3
|
-
function keyMirror(keys) {
|
|
4
|
-
const obj = {};
|
|
5
|
-
keys.forEach(key => (obj[key] = key));
|
|
6
|
-
return obj;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// Mock of what the native code puts on the JS object
|
|
10
|
-
NativeModules.MLNModule = {
|
|
11
|
-
// constants
|
|
12
|
-
UserTrackingModes: keyMirror([
|
|
13
|
-
'None',
|
|
14
|
-
'Follow',
|
|
15
|
-
'FollowWithCourse',
|
|
16
|
-
'FollowWithHeading',
|
|
17
|
-
]),
|
|
18
|
-
StyleURL: keyMirror(['Default']),
|
|
19
|
-
EventTypes: keyMirror([
|
|
20
|
-
'MapClick',
|
|
21
|
-
'MapLongClick',
|
|
22
|
-
'RegionWillChange',
|
|
23
|
-
'RegionIsChanging',
|
|
24
|
-
'RegionDidChange',
|
|
25
|
-
'WillStartLoadingMap',
|
|
26
|
-
'DidFinishLoadingMap',
|
|
27
|
-
'DidFailLoadingMap',
|
|
28
|
-
'WillStartRenderingFrame',
|
|
29
|
-
'DidFinishRenderingFrame',
|
|
30
|
-
'DidFinishRenderingFrameFully',
|
|
31
|
-
'DidFinishLoadingStyle',
|
|
32
|
-
'SetCameraComplete',
|
|
33
|
-
]),
|
|
34
|
-
CameraModes: keyMirror(['Flight', 'Ease', 'None']),
|
|
35
|
-
StyleSource: keyMirror(['DefaultSourceID']),
|
|
36
|
-
InterpolationMode: keyMirror([
|
|
37
|
-
'Exponential',
|
|
38
|
-
'Categorical',
|
|
39
|
-
'Interval',
|
|
40
|
-
'Identity',
|
|
41
|
-
]),
|
|
42
|
-
LineJoin: keyMirror(['Bevel', 'Round', 'Miter']),
|
|
43
|
-
LineCap: keyMirror(['Butt', 'Round', 'Square']),
|
|
44
|
-
LineTranslateAnchor: keyMirror(['Map', 'Viewport']),
|
|
45
|
-
CirclePitchScale: keyMirror(['Map', 'Viewport']),
|
|
46
|
-
CircleTranslateAnchor: keyMirror(['Map', 'Viewport']),
|
|
47
|
-
FillExtrusionTranslateAnchor: keyMirror(['Map', 'Viewport']),
|
|
48
|
-
FillTranslateAnchor: keyMirror(['Map', 'Viewport']),
|
|
49
|
-
IconRotationAlignment: keyMirror(['Auto', 'Map', 'Viewport']),
|
|
50
|
-
IconTextFit: keyMirror(['None', 'Width', 'Height', 'Both']),
|
|
51
|
-
IconTranslateAnchor: keyMirror(['Map', 'Viewport']),
|
|
52
|
-
SymbolPlacement: keyMirror(['Line', 'Point']),
|
|
53
|
-
TextAnchor: keyMirror([
|
|
54
|
-
'Center',
|
|
55
|
-
'Left',
|
|
56
|
-
'Right',
|
|
57
|
-
'Top',
|
|
58
|
-
'Bottom',
|
|
59
|
-
'TopLeft',
|
|
60
|
-
'TopRight',
|
|
61
|
-
'BottomLeft',
|
|
62
|
-
'BottomRight',
|
|
63
|
-
]),
|
|
64
|
-
TextJustify: keyMirror(['Center', 'Left', 'Right']),
|
|
65
|
-
TextPitchAlignment: keyMirror(['Auto', 'Map', 'Viewport']),
|
|
66
|
-
TextRotationAlignment: keyMirror(['Auto', 'Map', 'Viewport']),
|
|
67
|
-
TextTransform: keyMirror(['None', 'Lowercase', 'Uppercase']),
|
|
68
|
-
TextTranslateAnchor: keyMirror(['Map', 'Viewport']),
|
|
69
|
-
LightAnchor: keyMirror(['Map', 'Viewport']),
|
|
70
|
-
OfflinePackDownloadState: keyMirror(['Inactive', 'Active', 'Complete']),
|
|
71
|
-
OfflineCallbackName: keyMirror(['Progress', 'Error']),
|
|
72
|
-
|
|
73
|
-
// methods
|
|
74
|
-
setAccessToken: jest.fn(),
|
|
75
|
-
getAccessToken: () => Promise.resolve('test-token'),
|
|
76
|
-
setConnected: jest.fn(),
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
NativeModules.MLNOfflineModule = {
|
|
80
|
-
createPack: packOptions => {
|
|
81
|
-
return Promise.resolve({
|
|
82
|
-
bounds: packOptions.bounds,
|
|
83
|
-
metadata: JSON.stringify({name: packOptions.name}),
|
|
84
|
-
});
|
|
85
|
-
},
|
|
86
|
-
getPacks: () => Promise.resolve([]),
|
|
87
|
-
deletePack: () => Promise.resolve(),
|
|
88
|
-
getPackStatus: () => Promise.resolve({}),
|
|
89
|
-
pausePackDownload: () => Promise.resolve(),
|
|
90
|
-
resumePackDownload: () => Promise.resolve(),
|
|
91
|
-
setPackObserver: () => Promise.resolve(),
|
|
92
|
-
setTileCountLimit: jest.fn(),
|
|
93
|
-
setProgressEventThrottle: jest.fn(),
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
NativeModules.MLNSnapshotModule = {
|
|
97
|
-
takeSnap: () => {
|
|
98
|
-
return Promise.resolve('file://test.png');
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
NativeModules.MLNLocationModule = {
|
|
103
|
-
getLastKnownLocation: jest.fn(),
|
|
104
|
-
setMinDisplacement: jest.fn(),
|
|
105
|
-
start: jest.fn(),
|
|
106
|
-
stop: jest.fn(),
|
|
107
|
-
pause: jest.fn(),
|
|
108
|
-
};
|