@maplibre/maplibre-react-native 10.0.0-alpha.18 → 10.0.0-alpha.19

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.
@@ -178,6 +178,7 @@ const styleMap = {
178
178
  fillExtrusionHeightTransition: StyleTypes.Transition,
179
179
  fillExtrusionBase: StyleTypes.Constant,
180
180
  fillExtrusionBaseTransition: StyleTypes.Transition,
181
+ fillExtrusionVerticalGradient: StyleTypes.Constant,
181
182
 
182
183
  rasterOpacity: StyleTypes.Constant,
183
184
  rasterOpacityTransition: StyleTypes.Transition,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maplibre/maplibre-react-native",
3
3
  "description": "A MapLibre GL Native plugin for creating maps in React Native",
4
- "version": "10.0.0-alpha.18",
4
+ "version": "10.0.0-alpha.19",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -22,8 +22,8 @@
22
22
  },
23
23
  "scripts": {
24
24
  "fetch:style:spec": "./scripts/download-style-spec.sh",
25
- "generate": "yarn node ./scripts/autogenerate",
26
- "test": "npm run lint && npm run unittest",
25
+ "generate": "yarn fetch:style:spec && yarn node ./scripts/autogenerate",
26
+ "test": "yarn lint && yarn unittest",
27
27
  "unittest": "jest",
28
28
  "unittest:single": "jest --testNamePattern",
29
29
  "lint": "eslint .",
@@ -263,73 +263,30 @@ global.getEnums = function (layers) {
263
263
  };
264
264
 
265
265
  global.dtsInterfaceType = function (prop) {
266
- let propTypes = [];
267
-
268
- if (prop.name.indexOf('Translate') !== -1 && prop.type != 'enum') {
269
- propTypes.push('Translation');
270
- } else if (prop.type === 'color') {
271
- propTypes.push('string');
272
- // propTypes.push('ConstantPropType');
273
- } else if (prop.type === 'array') {
274
- switch (prop.value) {
275
- case 'number':
276
- propTypes.push('number[]');
277
- break;
278
- case 'boolean':
279
- propTypes.push('boolean[]');
280
- break;
281
- case 'string':
282
- propTypes.push('string[]');
283
- break;
284
- case 'enum':
285
- propTypes.push(
286
- `Enum<${pascelCase(prop.name)}Enum, ${pascelCase(
287
- prop.name,
288
- )}EnumValues>[]`,
289
- );
290
- break;
291
- }
292
- // propTypes.push('ConstantPropType');
293
- } else if (prop.type === 'number') {
294
- propTypes.push('number');
295
- } else if (prop.type === 'enum') {
296
- propTypes.push(
297
- `Enum<${pascelCase(prop.name)}Enum, ${pascelCase(prop.name)}EnumValues>`,
298
- );
299
- } else if (prop.type === 'boolean') {
300
- propTypes.push('boolean');
301
- } else if (prop.type === 'resolvedImage') {
302
- propTypes.push('ResolvedImageType');
303
- } else if (prop.type === 'formatted') {
304
- propTypes.push('FormattedString');
305
- } else if (prop.type === 'string') {
306
- propTypes.push('string');
307
- } else {
308
- console.error('Unexpected type:', prop.type);
309
- throw new Error(`Unexpected type: ${prop.type} for ${prop.name}`);
310
- }
311
-
312
- /*
313
- if (prop.allowedFunctionTypes && prop.allowedFunctionTypes.length > 0) {
314
- propTypes.push('StyleFunctionProps');
315
- }
316
- */
317
-
318
- if (propTypes.length > 1) {
319
- return `${propTypes.map((p) => startAtSpace(4, p)).join(' | ')},
320
- ${startAtSpace(2, '')}`;
321
- } else {
322
- if (prop.expressionSupported) {
323
- let params = '';
324
- if (prop.expression && prop.expression.parameters) {
325
- params = `,[${prop.expression.parameters
326
- .map((v) => `'${v}'`)
327
- .join(',')}]`;
328
- }
329
- return `Value<${propTypes[0]}${params}>`;
330
- } else {
331
- return propTypes[0];
332
- }
266
+ switch (prop.type) {
267
+ case 'number':
268
+ return 'number';
269
+ case 'string':
270
+ return 'string';
271
+ case 'boolean':
272
+ return 'boolean';
273
+ case 'array':
274
+ return 'any[]';
275
+ case 'padding':
276
+ return 'number[]';
277
+ case 'enum':
278
+ return prop.doc && prop.doc.values ?
279
+ Object.keys(prop.doc.values).map(value => `'${value}'`).join(' | ') :
280
+ 'string';
281
+ case 'color':
282
+ return 'string';
283
+ case 'resolvedImage':
284
+ return 'string';
285
+ case 'formatted':
286
+ return 'string';
287
+ // ... other cases ...
288
+ default:
289
+ throw new Error(`Unexpected type: ${prop.type} for ${prop.name}`);
333
290
  }
334
291
  };
335
292
 
@@ -139,7 +139,12 @@ function getPropertiesForLayer(layerName) {
139
139
  ) {
140
140
  prop.allowedFunctionTypes = ['camera'];
141
141
  }
142
-
142
+ // Overide type padding
143
+ if(prop.type === 'padding') {
144
+ prop.type = 'array';
145
+ prop.value = 'number';
146
+ prop.length = 4;
147
+ }
143
148
  return prop;
144
149
  });
145
150
 
@@ -325,10 +330,6 @@ async function generate() {
325
330
  input: path.join(TMPL_PATH, 'RCTMLNStyle.h.ejs'),
326
331
  output: path.join(IOS_OUTPUT_PATH, 'RCTMLNStyle.h'),
327
332
  },
328
- /*{
329
- input: path.join(TMPL_PATH, 'index.d.ts.ejs'),
330
- output: path.join(IOS_OUTPUT_PATH, 'index.d.ts'),
331
- },*/
332
333
  {
333
334
  input: path.join(TMPL_PATH, 'MaplibreStyles.ts.ejs'),
334
335
  output: path.join(JS_OUTPUT_PATH, 'MaplibreStyles.d.ts'),
@@ -356,6 +357,12 @@ async function generate() {
356
357
  let results = tmpl({layers});
357
358
  if (filename.endsWith('ts')) {
358
359
  results = await prettier.format(results, { ...prettierrc, filepath: filename});
360
+ // Ensure all enums are exported
361
+ results = results.replace(/enum (\w+Enum) \{[^}]+\}\n/g, 'export $&');
362
+ // Replace Array<any> with any[]
363
+ results = results.replace(/Array<any>/g, 'any[]');
364
+ // Replace padding type with float array
365
+ results = results.replace(/padding: string;/g, 'padding: number[];');
359
366
  }
360
367
  fs.writeFileSync(output, results);
361
368
  }));