@maplibre/maplibre-react-native 10.0.0-alpha.24 → 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.
Files changed (62) hide show
  1. package/.husky/pre-commit +1 -1
  2. package/CHANGELOG.md +6 -0
  3. package/CONTRIBUTING.md +1 -1
  4. package/docs/Annotation.md +2 -11
  5. package/docs/BackgroundLayer.md +2 -1
  6. package/docs/Callout.md +2 -1
  7. package/docs/Camera.md +28 -29
  8. package/docs/CircleLayer.md +2 -1
  9. package/docs/FillExtrusionLayer.md +2 -1
  10. package/docs/FillLayer.md +2 -1
  11. package/docs/HeadingIndicator.md +2 -1
  12. package/docs/HeatmapLayer.md +2 -1
  13. package/docs/ImageSource.md +2 -1
  14. package/docs/Images.md +2 -1
  15. package/docs/Light.md +2 -1
  16. package/docs/LineLayer.md +2 -1
  17. package/docs/MapView.md +5 -4
  18. package/docs/MarkerView.md +2 -1
  19. package/docs/NativeUserLocation.md +2 -1
  20. package/docs/PointAnnotation.md +2 -1
  21. package/docs/RasterLayer.md +2 -1
  22. package/docs/RasterSource.md +2 -1
  23. package/docs/ShapeSource.md +2 -1
  24. package/docs/Style.md +2 -1
  25. package/docs/SymbolLayer.md +2 -1
  26. package/docs/UserLocation.md +2 -1
  27. package/docs/VectorSource.md +3 -2
  28. package/docs/coordinates.md +2 -1
  29. package/docs/docs.json +49 -88
  30. package/docs/location.md +2 -1
  31. package/docs/offlineManager.md +3 -2
  32. package/docs/snapshotManager.md +2 -1
  33. package/ios/RCTMLN/RCTMLNCamera.h +0 -3
  34. package/ios/RCTMLN/RCTMLNCamera.m +1 -1
  35. package/ios/RCTMLN/RCTMLNCameraManager.m +0 -3
  36. package/javascript/MLNModule.ts +9 -0
  37. package/javascript/Maplibre.ts +1 -1
  38. package/javascript/components/{annotations/Annotation.tsx → Annotation.tsx} +5 -5
  39. package/javascript/components/Camera.tsx +257 -388
  40. package/javascript/components/UserLocation.tsx +1 -1
  41. package/javascript/hooks/useNativeRef.ts +2 -1
  42. package/javascript/types/CameraMode.ts +6 -0
  43. package/package.json +7 -8
  44. package/scripts/codegen.ts +341 -0
  45. package/scripts/templates/MaplibreStyles.ts.ejs +8 -7
  46. package/scripts/templates/RCTMLNStyle.h.ejs +4 -3
  47. package/scripts/templates/RCTMLNStyle.m.ejs +11 -10
  48. package/scripts/templates/RCTMLNStyleFactory.java.ejs +12 -11
  49. package/scripts/templates/component.md.ejs +14 -12
  50. package/scripts/templates/index.d.ts.ejs +2 -1
  51. package/scripts/templates/styleMap.ts.ejs +2 -1
  52. package/scripts/utils/{DocJSONBuilder.js → DocJSONBuilder.ts} +133 -128
  53. package/scripts/utils/{JSDocNodeTree.js → JSDocNodeTree.ts} +14 -13
  54. package/scripts/utils/MarkdownBuilder.ts +44 -0
  55. package/scripts/utils/{template-globals.js → TemplateHelpers.ts} +65 -94
  56. package/scripts/utils/getNativeVersion.ts +53 -0
  57. package/tsconfig.json +2 -3
  58. package/docs/OfflineManager.md +0 -246
  59. package/scripts/download-style-spec.sh +0 -15
  60. package/scripts/generate-docs.js +0 -396
  61. package/scripts/utils/MarkdownBuilder.js +0 -37
  62. package/style-spec/v8.json +0 -6645
@@ -1,9 +1,9 @@
1
1
  import React, { ReactElement, useEffect, useImperativeHandle } from "react";
2
2
 
3
+ import Annotation from "./Annotation";
3
4
  import CircleLayer from "./CircleLayer";
4
5
  import HeadingIndicator from "./HeadingIndicator";
5
6
  import NativeUserLocation from "./NativeUserLocation";
6
- import Annotation from "./annotations/Annotation";
7
7
  import locationManager, { Location } from "../modules/location/locationManager";
8
8
  import { CircleLayerStyleProps } from "../utils/MaplibreStyles";
9
9
 
@@ -1,7 +1,8 @@
1
1
  import React, { Component, useRef } from "react";
2
2
  import { NativeMethods } from "react-native";
3
3
 
4
- type NativeRef<NativeProps> = Component<NativeProps> & Readonly<NativeMethods>;
4
+ export type NativeRef<NativeProps> = Component<NativeProps> &
5
+ Readonly<NativeMethods>;
5
6
 
6
7
  /**
7
8
  * Separate module which allows to be mocked in tests.
@@ -0,0 +1,6 @@
1
+ export enum CameraMode {
2
+ Flight = 1,
3
+ Ease = 2,
4
+ Linear = 3,
5
+ None = 4,
6
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maplibre/maplibre-react-native",
3
3
  "description": "React Native library for creating maps with MapLibre Native for Android & iOS",
4
- "version": "10.0.0-alpha.24",
4
+ "version": "10.0.0-alpha.25",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -21,9 +21,7 @@
21
21
  "url": "https://github.com/maplibre/maplibre-react-native"
22
22
  },
23
23
  "scripts": {
24
- "generate": "yarn generate:fetch-style-spec && yarn generate:docs",
25
- "generate:fetch-style-spec": "./scripts/download-style-spec.sh",
26
- "generate:docs": "yarn node ./scripts/generate-docs",
24
+ "codegen": "tsx scripts/codegen.ts",
27
25
  "test": "jest",
28
26
  "lint": "yarn lint:eslint && yarn lint:tsc",
29
27
  "lint:eslint": "eslint .",
@@ -64,16 +62,17 @@
64
62
  "@babel/plugin-proposal-class-properties": "7.18.6",
65
63
  "@babel/runtime": "7.17.2",
66
64
  "@expo/config-plugins": "^8.0.10",
65
+ "@maplibre/maplibre-gl-style-spec": "21.1.0",
67
66
  "@react-native/babel-preset": "^0.74.88",
68
67
  "@react-native/metro-config": "^0.74.88",
69
68
  "@sinonjs/fake-timers": "^11.2.2",
70
69
  "@testing-library/react-native": "^12.4.3",
71
- "@tsconfig/node14": "^14.1.0",
70
+ "@types/ejs": "^3.1.5",
72
71
  "@typescript-eslint/eslint-plugin": "^7.18.0",
73
72
  "@typescript-eslint/parser": "^7.18.0",
74
73
  "babel-jest": "^29.6.0",
75
74
  "documentation": "^14.0.0",
76
- "ejs": "^3.1.3",
75
+ "ejs": "^3.1.10",
77
76
  "ejs-lint": "^2.0.0",
78
77
  "eslint": "^8.57.1",
79
78
  "eslint-config-universe": "13.0.0",
@@ -82,13 +81,13 @@
82
81
  "jest": "^29.7.0",
83
82
  "jest-cli": "^29.7.0",
84
83
  "lint-staged": "^15.2.2",
85
- "node-dir": "0.1.17",
86
84
  "pinst": "^3.0.0",
87
85
  "prettier": "3.3.3",
88
86
  "react": "18.2.0",
89
- "react-docgen": "rnmapbox/react-docgen#rnmapbox-dist",
87
+ "react-docgen": "^7.1.0",
90
88
  "react-native": "^0.74.6",
91
89
  "react-test-renderer": "18.2.0",
90
+ "tsx": "^4.19.2",
92
91
  "typescript": "^5.3.3"
93
92
  },
94
93
  "resolutions": {
@@ -0,0 +1,341 @@
1
+ import maplibreGlStyleSpec from "@maplibre/maplibre-gl-style-spec/src/reference/latest";
2
+ import ejs from "ejs";
3
+ import { exec } from "node:child_process";
4
+ import { promises as fs } from "node:fs";
5
+ import path from "node:path";
6
+ import prettier from "prettier";
7
+
8
+ import { DocJSONBuilder } from "./utils/DocJSONBuilder";
9
+ import { MarkdownBuilder } from "./utils/MarkdownBuilder";
10
+ import { camelCase } from "./utils/TemplateHelpers";
11
+ import * as TemplateHelpers from "./utils/TemplateHelpers";
12
+ import {
13
+ getAndroidVersion,
14
+ getIosVersion,
15
+ isVersionGTE,
16
+ } from "./utils/getNativeVersion";
17
+
18
+ const TMPL_PATH = path.join(__dirname, "templates");
19
+
20
+ const IOS_OUTPUT_PATH = path.join(__dirname, "..", "ios", "RCTMLN");
21
+ const ANDROID_OUTPUT_PATH = path.join(
22
+ __dirname,
23
+ "..",
24
+ "android",
25
+ "rctmln",
26
+ "src",
27
+ "main",
28
+ "java",
29
+ "com",
30
+ "maplibre",
31
+ "rctmln",
32
+ "components",
33
+ "styles",
34
+ );
35
+
36
+ const JS_OUTPUT_PATH = path.join(__dirname, "..", "javascript", "utils");
37
+
38
+ const TEMPLATE_MAPPINGS = [
39
+ {
40
+ input: path.join(TMPL_PATH, "RCTMLNStyle.h.ejs"),
41
+ output: path.join(IOS_OUTPUT_PATH, "RCTMLNStyle.h"),
42
+ },
43
+ {
44
+ input: path.join(TMPL_PATH, "MaplibreStyles.ts.ejs"),
45
+ output: path.join(JS_OUTPUT_PATH, "MaplibreStyles.d.ts"),
46
+ },
47
+ {
48
+ input: path.join(TMPL_PATH, "RCTMLNStyle.m.ejs"),
49
+ output: path.join(IOS_OUTPUT_PATH, "RCTMLNStyle.m"),
50
+ },
51
+ {
52
+ input: path.join(TMPL_PATH, "RCTMLNStyleFactory.java.ejs"),
53
+ output: path.join(ANDROID_OUTPUT_PATH, "RCTMLNStyleFactory.java"),
54
+ },
55
+ {
56
+ input: path.join(TMPL_PATH, "styleMap.ts.ejs"),
57
+ output: path.join(JS_OUTPUT_PATH, "styleMap.ts"),
58
+ },
59
+ ];
60
+
61
+ async function generate() {
62
+ const androidVersion = await getAndroidVersion();
63
+ const iosVersion = await getIosVersion();
64
+
65
+ function getPropertiesForLight() {
66
+ const lightAttributes = maplibreGlStyleSpec.light;
67
+
68
+ return getSupportedProperties(lightAttributes).map((attrName) => {
69
+ return Object.assign({}, buildProperties(lightAttributes, attrName), {
70
+ allowedFunctionTypes: [],
71
+ });
72
+ });
73
+ }
74
+
75
+ function getPropertiesForLayer(layerName: string) {
76
+ const paintAttributes = maplibreGlStyleSpec[`paint_${layerName}`];
77
+ const layoutAttributes = maplibreGlStyleSpec[`layout_${layerName}`];
78
+
79
+ const paintProps = getSupportedProperties(paintAttributes).map(
80
+ (attrName) => {
81
+ const prop = buildProperties(paintAttributes, attrName);
82
+
83
+ // overrides
84
+ if (["line-width"].includes(attrName)) {
85
+ prop.allowedFunctionTypes = ["camera"];
86
+ }
87
+
88
+ return prop;
89
+ },
90
+ );
91
+
92
+ const layoutProps = getSupportedProperties(layoutAttributes).map(
93
+ (attrName) => {
94
+ const prop = buildProperties(layoutAttributes, attrName);
95
+
96
+ // overrides
97
+ if (
98
+ [
99
+ "line-join",
100
+ "text-max-width",
101
+ "text-letter-spacing",
102
+ "text-anchor",
103
+ "text-justify",
104
+ "text-font",
105
+ ].includes(attrName)
106
+ ) {
107
+ prop.allowedFunctionTypes = ["camera"];
108
+ }
109
+
110
+ // TODO
111
+ // Overide type padding
112
+ if (prop.type === "padding") {
113
+ prop.type = "array";
114
+ prop.value = "number";
115
+ prop.length = 4;
116
+ }
117
+
118
+ return prop;
119
+ },
120
+ );
121
+
122
+ return layoutProps.concat(paintProps);
123
+ }
124
+
125
+ function getSupportedLayers() {
126
+ return Object.entries(maplibreGlStyleSpec.layer.type.values)
127
+ .map(([layerName, layerProperties]) => {
128
+ if (
129
+ layerProperties &&
130
+ typeof layerProperties === "object" &&
131
+ "sdk-support" in layerProperties
132
+ ) {
133
+ const support = getAttributeSupport(layerProperties["sdk-support"]);
134
+
135
+ if (support.basic.android && support.basic.ios) {
136
+ return layerName;
137
+ }
138
+ }
139
+
140
+ return undefined;
141
+ })
142
+ .filter((layerName) => typeof layerName === "string");
143
+ }
144
+
145
+ function getSupportedProperties(attributes: any) {
146
+ return Object.keys(attributes).filter((attrName) =>
147
+ isAttrSupported(attributes[attrName]),
148
+ );
149
+ }
150
+
151
+ function buildProperties(attributes: any, attrName: string) {
152
+ return {
153
+ name: camelCase(attrName),
154
+ doc: {
155
+ default: attributes[attrName].default,
156
+ minimum: attributes[attrName].minimum,
157
+ maximum: attributes[attrName].maximum,
158
+ units: attributes[attrName].units,
159
+ description: formatDescription(attributes[attrName].doc),
160
+ requires: getRequires(attributes[attrName].requires),
161
+ disabledBy: getDisables(attributes[attrName].requires),
162
+ values: attributes[attrName].values,
163
+ },
164
+ type: attributes[attrName].type,
165
+ value: attributes[attrName].value,
166
+ length: undefined as undefined | number,
167
+ image: isImage(attrName),
168
+ translate: isTranslate(attrName),
169
+ transition: attributes[attrName].transition,
170
+ expression: attributes[attrName].expression,
171
+ expressionSupported:
172
+ Object.keys(attributes[attrName].expression || {}).length > 0,
173
+ support: getAttributeSupport(attributes[attrName]["sdk-support"]),
174
+ allowedFunctionTypes: getAllowedFunctionTypes(attributes[attrName]),
175
+ };
176
+ }
177
+
178
+ function formatDescription(description: string) {
179
+ const words = description.split(" ");
180
+
181
+ for (let i = 0; i < words.length; i++) {
182
+ const word = words[i];
183
+
184
+ if (word.includes("-")) {
185
+ words[i] = camelCase(word);
186
+ }
187
+ }
188
+
189
+ return words.join(" ");
190
+ }
191
+
192
+ function getRequires(requiredItems: any) {
193
+ const items: any[] = [];
194
+
195
+ if (!requiredItems) {
196
+ return items;
197
+ }
198
+
199
+ for (const item of requiredItems) {
200
+ if (typeof item === "string") {
201
+ items.push(camelCase(item, "-"));
202
+ }
203
+ }
204
+
205
+ return items;
206
+ }
207
+
208
+ function getDisables(disabledItems: any[]) {
209
+ const items: any[] = [];
210
+
211
+ if (!disabledItems) {
212
+ return items;
213
+ }
214
+
215
+ for (const item of disabledItems) {
216
+ if (item["!"]) {
217
+ items.push(camelCase(item["!"], "-"));
218
+ }
219
+ }
220
+
221
+ return items;
222
+ }
223
+
224
+ function isImage(attrName: string) {
225
+ return (
226
+ attrName.toLowerCase().indexOf("pattern") !== -1 ||
227
+ attrName.toLowerCase().indexOf("image") !== -1
228
+ );
229
+ }
230
+
231
+ function isTranslate(attrName: string) {
232
+ return attrName.toLowerCase().indexOf("translate") !== -1;
233
+ }
234
+
235
+ function isAttrSupported(attr: any) {
236
+ const support = getAttributeSupport(attr["sdk-support"]);
237
+ if (attr.private) {
238
+ return false;
239
+ }
240
+ return support.basic.android && support.basic.ios;
241
+ }
242
+
243
+ function getAttributeSupport(sdkSupport: any) {
244
+ const support = {
245
+ basic: { android: false, ios: false },
246
+ data: { android: false, ios: false },
247
+ };
248
+
249
+ const basicSupport = sdkSupport && sdkSupport["basic functionality"];
250
+ support.basic.android = isVersionGTE(androidVersion, basicSupport?.android);
251
+ support.basic.ios = isVersionGTE(iosVersion, basicSupport?.ios);
252
+
253
+ const dataDrivenSupport = sdkSupport && sdkSupport["data-driven styling"];
254
+ support.data.android = isVersionGTE(
255
+ androidVersion,
256
+ dataDrivenSupport?.android,
257
+ );
258
+ support.data.ios = isVersionGTE(iosVersion, dataDrivenSupport?.ios);
259
+
260
+ if (!support.data.ios || !support.data.android) {
261
+ support.data.ios = false;
262
+ support.data.android = false;
263
+ }
264
+
265
+ return support;
266
+ }
267
+
268
+ function getAllowedFunctionTypes(paintAttr: any) {
269
+ const allowedFunctionTypes = [];
270
+
271
+ if (paintAttr["zoom-function"]) {
272
+ allowedFunctionTypes.push("camera");
273
+ }
274
+
275
+ if (paintAttr["property-function"]) {
276
+ allowedFunctionTypes.push("source");
277
+ allowedFunctionTypes.push("composite");
278
+ }
279
+
280
+ return allowedFunctionTypes;
281
+ }
282
+
283
+ const layers = getSupportedLayers().map((layerName) => {
284
+ return {
285
+ name: layerName,
286
+ properties: getPropertiesForLayer(layerName),
287
+ };
288
+ });
289
+
290
+ // add light as a layer
291
+ layers.push({ name: "light", properties: getPropertiesForLight() });
292
+
293
+ // autogenerate code
294
+ await Promise.all(
295
+ TEMPLATE_MAPPINGS.map(async ({ input, output }) => {
296
+ const filename = path.parse(output).base;
297
+
298
+ console.log(`Generating ${filename}`);
299
+ const tmpl = ejs.compile(await fs.readFile(input, "utf8"), {
300
+ strict: true,
301
+ async: true,
302
+ });
303
+ let results = await tmpl({ layers, helpers: TemplateHelpers });
304
+ if (filename.endsWith("ts")) {
305
+ results = await prettier.format(results, {
306
+ filepath: filename,
307
+ });
308
+ // Ensure all enums are exported
309
+ results = results.replace(/enum (\w+Enum) \{[^}]+}\n/g, "export $&");
310
+ // Replace Array<any> with any[]
311
+ results = results.replace(/Array<any>/g, "any[]");
312
+ // Replace padding type with float array
313
+ results = results.replace(/padding: string;/g, "padding: number[];");
314
+ }
315
+ await fs.writeFile(output, results);
316
+ }),
317
+ );
318
+
319
+ // autogenerate docs
320
+ const docBuilder = new DocJSONBuilder(layers);
321
+ const markdownBuilder = new MarkdownBuilder();
322
+ await docBuilder.generate();
323
+ await markdownBuilder.generate();
324
+
325
+ // Check if any generated files changed
326
+ try {
327
+ exec(
328
+ `git diff --exit-code docs/ ${TEMPLATE_MAPPINGS.map((m) => m.output).join(" ")}`,
329
+ );
330
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
331
+ } catch (_error) {
332
+ console.error(
333
+ "\n\nThere are unstaged changes in the generated code. " +
334
+ "Please add them to your commit.\n" +
335
+ 'If you would really like to exclude them, run "git commit -n" to skip.\n\n',
336
+ );
337
+ process.exit(1);
338
+ }
339
+ }
340
+
341
+ generate();
@@ -1,5 +1,6 @@
1
1
  <%
2
2
  const layers = locals.layers;
3
+ const helpers = locals.helpers;
3
4
  -%>
4
5
  /* This file was generated from MapboxStyle.ts.ejs do not modify */
5
6
  import { type ImageSourcePropType } from 'react-native';
@@ -58,20 +59,20 @@ export type Value<T, AllowedParameters extends ExpressionParameters[] = []> =
58
59
  | T
59
60
  | Expression;
60
61
 
61
- <%_ for (let enumInfo of getEnums(layers)) { _%>
62
- enum <%- pascalCase(enumInfo.name) %>Enum {
62
+ <%_ for (let enumInfo of helpers.getEnums(layers)) { _%>
63
+ enum <%- helpers.pascalCase(enumInfo.name) %>Enum {
63
64
  <%_ for (let k of Object.keys(enumInfo.values)) { _%>
64
65
  /** <%- enumInfo.values[k].doc %> */
65
- <%- pascalCase(k) %> = '<%- k %>',
66
+ <%- helpers.pascalCase(k) %> = '<%- k %>',
66
67
  <%_ } _%>
67
68
  }
68
- type <%- pascalCase(enumInfo.name) %>EnumValues = <%- Object.keys(enumInfo.values).map(k => `'${k}'`).join(' | ') %>;
69
+ type <%- helpers.pascalCase(enumInfo.name) %>EnumValues = <%- Object.keys(enumInfo.values).map(k => `'${k}'`).join(' | ') %>;
69
70
  <%_ } _%>
70
71
 
71
72
  type Enum<EnumType, EnumValues> = EnumType | EnumValues;
72
73
 
73
74
  <%_ for (let layer of layers) { _%>
74
- export interface <%- pascalCase(layer.name) %>LayerStyleProps {
75
+ export interface <%- helpers.pascalCase(layer.name) %>LayerStyleProps {
75
76
  <%_ for (let prop of layer.properties) { _%>
76
77
  /**
77
78
  * <%- prop.doc.description %>
@@ -84,7 +85,7 @@ type Enum<EnumType, EnumValues> = EnumType | EnumValues;
84
85
  * @disabledBy <%- prop.doc.disabledBy.join(', ') %>
85
86
  <%_ } _%>
86
87
  */
87
- <%= prop.name %>?: <%- dtsInterfaceType(prop) %>
88
+ <%= prop.name %>?: <%- helpers.dtsInterfaceType(prop) %>
88
89
  <%_ if (true && prop.transition) { %>
89
90
  /**
90
91
  * The transition affecting any changes to this layer’s <%= prop.name %> property.
@@ -96,4 +97,4 @@ type Enum<EnumType, EnumValues> = EnumType | EnumValues;
96
97
  };
97
98
  <%_ } _%>
98
99
 
99
- export type AllLayerStyleProps = <%- layers.map(l => `${pascalCase(l.name)}LayerStyleProps`).join("|") -%>;
100
+ export type AllLayerStyleProps = <%- layers.map(l => `${helpers.pascalCase(l.name)}LayerStyleProps`).join("|") -%>;
@@ -1,5 +1,6 @@
1
1
  <%
2
2
  const layers = locals.layers;
3
+ const helpers = locals.helpers;
3
4
  -%>
4
5
  // DO NOT MODIFY
5
6
  // THIS FILE IS AUTOGENERATED
@@ -18,14 +19,14 @@
18
19
  - (id)initWithMLNStyle:(MLNStyle*)mlnStyle;
19
20
 
20
21
  <%_ for (const layer of layers) { _%>
21
- - (void)<%- setLayerMethodName(layer, 'ios') -%>:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyle:(NSDictionary *)reactStyle isValid:(BOOL (^)(void)) isValid;
22
+ - (void)<%- helpers.setLayerMethodName(layer, 'ios') -%>:(<%- helpers.getLayerType(layer, 'ios') -%> *)layer withReactStyle:(NSDictionary *)reactStyle isValid:(BOOL (^)(void)) isValid;
22
23
  <%_ } _%>
23
24
 
24
25
  <%_ for (const layer of layers) { _%>
25
26
  <%_ for (const prop of layer.properties) { _%>
26
- - (void)set<%- iosPropMethodName(layer, pascalCase(prop.name)) -%>:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue;
27
+ - (void)set<%- helpers.iosPropMethodName(layer, helpers.pascalCase(prop.name)) -%>:(<%- helpers.getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue;
27
28
  <%_ if (prop.transition) { _%>
28
- - (void)set<%- iosPropMethodName(layer, pascalCase(prop.name)) -%>Transition:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue;
29
+ - (void)set<%- helpers.iosPropMethodName(layer, helpers.pascalCase(prop.name)) -%>Transition:(<%- helpers.getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue;
29
30
  <%_ } _%>
30
31
  <%_ } _%>
31
32
  <% } %>
@@ -1,5 +1,6 @@
1
1
  <%
2
2
  const layers = locals.layers;
3
+ const helpers = locals.helpers;
3
4
  -%>
4
5
  // DO NOT MODIFY
5
6
  // THIS FILE IS AUTOGENERATED
@@ -18,7 +19,7 @@
18
19
  }
19
20
 
20
21
  <% for (const layer of layers) { %>
21
- - (void)<%- setLayerMethodName(layer, 'ios') -%>:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyle:(NSDictionary *)reactStyle isValid:(BOOL (^)(void)) isValid
22
+ - (void)<%- helpers.setLayerMethodName(layer, 'ios') -%>:(<%- helpers.getLayerType(layer, 'ios') -%> *)layer withReactStyle:(NSDictionary *)reactStyle isValid:(BOOL (^)(void)) isValid
22
23
  {
23
24
  if (![self _hasReactStyle:reactStyle]) {
24
25
  // TODO throw exception
@@ -34,10 +35,10 @@
34
35
  RCTMLNStyleValue *styleValue = [RCTMLNStyleValue make:reactStyle[prop]];
35
36
 
36
37
  <% for (let i = 0; i < layer.properties.length; i++) { -%>
37
- <%- ifOrElseIf(i) -%> ([prop isEqualToString:@"<%= layer.properties[i].name %>"]) {
38
+ <%- helpers.ifOrElseIf(i) -%> ([prop isEqualToString:@"<%= layer.properties[i].name %>"]) {
38
39
  <%_ if (layer.properties[i].image) { _%>
39
40
  if (![styleValue shouldAddImage]) {
40
- [self set<%- iosPropMethodName(layer, pascalCase(layer.properties[i].name)) -%>:layer withReactStyleValue:styleValue];
41
+ [self set<%- helpers.iosPropMethodName(layer, helpers.pascalCase(layer.properties[i].name)) -%>:layer withReactStyleValue:styleValue];
41
42
  } else {
42
43
  NSString *imageURI = [styleValue getImageURI];
43
44
 
@@ -46,18 +47,18 @@
46
47
  dispatch_async(dispatch_get_main_queue(), ^{
47
48
  if (isValid()) {
48
49
  [self->_style setImage:image forName:imageURI];
49
- [self set<%- iosPropMethodName(layer, pascalCase(layer.properties[i].name)) -%>:layer withReactStyleValue:styleValue];
50
+ [self set<%- helpers.iosPropMethodName(layer, helpers.pascalCase(layer.properties[i].name)) -%>:layer withReactStyleValue:styleValue];
50
51
  }
51
52
  });
52
53
  }
53
54
  }];
54
55
  }
55
56
  <%_ } else { _%>
56
- [self set<%- iosPropMethodName(layer, pascalCase(layer.properties[i].name)) -%>:layer withReactStyleValue:styleValue];
57
+ [self set<%- helpers.iosPropMethodName(layer, helpers.pascalCase(layer.properties[i].name)) -%>:layer withReactStyleValue:styleValue];
57
58
  <%_ } _%>
58
59
  <%_ if (layer.properties[i].transition) { _%>
59
60
  } else if ([prop isEqualToString:@"<%= layer.properties[i].name %>Transition"]) {
60
- [self set<%- iosPropMethodName(layer, pascalCase(layer.properties[i].name)) -%>Transition:layer withReactStyleValue:styleValue];
61
+ [self set<%- helpers.iosPropMethodName(layer, helpers.pascalCase(layer.properties[i].name)) -%>Transition:layer withReactStyleValue:styleValue];
61
62
  <%_ } _%>
62
63
  <% } -%>
63
64
  } else {
@@ -69,21 +70,21 @@
69
70
 
70
71
  <% for (const layer of layers) {%>
71
72
  <% for (const prop of layer.properties) {%>
72
- - (void)set<%- iosPropMethodName(layer, pascalCase(prop.name)) -%>:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue
73
+ - (void)set<%- helpers.iosPropMethodName(layer, helpers.pascalCase(prop.name)) -%>:(<%- helpers.getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue
73
74
  {
74
75
  <%_ if (layer.name === 'light' && prop.name === 'position') { _%>
75
76
  layer.position = [styleValue getSphericalPosition];
76
77
  <%_ } else if (prop.name === 'visibility') { _%>
77
78
  layer.visible = [styleValue isVisible];
78
79
  <%_ } else { _%>
79
- layer.<%- iosPropName(prop.name) -%> = styleValue.mlnStyleValue;
80
+ layer.<%- helpers.iosPropName(prop.name) -%> = styleValue.mlnStyleValue;
80
81
  <%_ } _%>
81
82
  }
82
83
  <%_ if (prop.transition) { _%>
83
84
 
84
- - (void)set<%- iosPropMethodName(layer, pascalCase(prop.name)) -%>Transition:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue
85
+ - (void)set<%- helpers.iosPropMethodName(layer, helpers.pascalCase(prop.name)) -%>Transition:(<%- helpers.getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue
85
86
  {
86
- layer.<%- iosPropName(prop.name) -%>Transition = [styleValue getTransition];
87
+ layer.<%- helpers.iosPropName(prop.name) -%>Transition = [styleValue getTransition];
87
88
  }
88
89
  <%_ } _%>
89
90
  <% } %>
@@ -1,5 +1,6 @@
1
1
  <%
2
2
  const layers = locals.layers;
3
+ const helpers = locals.helpers;
3
4
  -%>
4
5
  // DO NOT MODIFY
5
6
  // THIS FILE IS AUTOGENERATED
@@ -29,7 +30,7 @@ public class RCTMLNStyleFactory {
29
30
  public static final String SHOULD_ADD_IMAGE_KEY = "shouldAddImage";
30
31
 
31
32
  <%_ for (const layer of layers) { _%>
32
- public static void <%- setLayerMethodName(layer) -%>(final <%- getLayerType(layer, 'android') -%> layer, RCTMLNStyle style) {
33
+ public static void <%- helpers.setLayerMethodName(layer) -%>(final <%- helpers.getLayerType(layer, 'android') -%> layer, RCTMLNStyle style) {
33
34
  List<String> styleKeys = style.getAllStyleKeys();
34
35
 
35
36
  if (styleKeys.size() == 0) {
@@ -46,16 +47,16 @@ public class RCTMLNStyleFactory {
46
47
  style.addImage(styleValue, new DownloadMapImageTask.OnAllImagesLoaded() {
47
48
  @Override
48
49
  public void onAllImagesLoaded() {
49
- RCTMLNStyleFactory.set<%- pascalCase(prop.name) -%>(layer, styleValue);
50
+ RCTMLNStyleFactory.set<%- helpers.pascalCase(prop.name) -%>(layer, styleValue);
50
51
  }
51
52
  });
52
53
  <%_ } else { _%>
53
- RCTMLNStyleFactory.set<%- pascalCase(prop.name) -%>(layer, styleValue);
54
+ RCTMLNStyleFactory.set<%- helpers.pascalCase(prop.name) -%>(layer, styleValue);
54
55
  <%_ } _%>
55
56
  break;
56
57
  <%_ if (prop.transition) { _%>
57
58
  case "<%= prop.name %>Transition":
58
- RCTMLNStyleFactory.set<%- pascalCase(prop.name) -%>Transition(layer, styleValue);
59
+ RCTMLNStyleFactory.set<%- helpers.pascalCase(prop.name) -%>Transition(layer, styleValue);
59
60
  break;
60
61
  <%_ } _%>
61
62
  <%_ } _%>
@@ -66,12 +67,12 @@ public class RCTMLNStyleFactory {
66
67
 
67
68
  <%_ for (const layer of layers) { _%>
68
69
  <%_ for (const prop of layer.properties) { _%>
69
- public static void set<%- pascalCase(prop.name) -%>(<%- getLayerType(layer, 'android') -%> layer, RCTMLNStyleValue styleValue) {
70
+ public static void set<%- helpers.pascalCase(prop.name) -%>(<%- helpers.getLayerType(layer, 'android') -%> layer, RCTMLNStyleValue styleValue) {
70
71
  <%_ if (layer.name === 'light' && prop.name === 'position') { _%>
71
72
  Float[] values = styleValue.getFloatArray(VALUE_KEY);
72
- layer.set<%- pascalCase(prop.name) -%>(Position.fromPosition(values[0], values[1], values[2]));
73
+ layer.set<%- helpers.pascalCase(prop.name) -%>(Position.fromPosition(values[0], values[1], values[2]));
73
74
  <%_ } else if (layer.name === 'light') { _%>
74
- layer.set<%- pascalCase(prop.name) -%>(<%- androidGetConfigType(androidInputType(prop.type, prop.value), prop) -%>);
75
+ layer.set<%- helpers.pascalCase(prop.name) -%>(<%- helpers.androidGetConfigType(helpers.androidInputType(prop.type, prop.value), prop) -%>);
75
76
  <%_ } else if (prop.name === 'visibility') { _%>
76
77
  layer.setProperties(PropertyFactory.visibility(styleValue.getString(VALUE_KEY)));
77
78
  <%_ } else if (prop.type === 'resolvedImage') { _%>
@@ -82,22 +83,22 @@ public class RCTMLNStyleFactory {
82
83
  layer.setProperties(PropertyFactory.<%= prop.name %>(styleValue.getExpression()));
83
84
  }
84
85
  } else {
85
- layer.setProperties(PropertyFactory.<%= prop.name %>(<%- androidGetConfigType(androidInputType(prop.type, prop.value), prop) -%>));
86
+ layer.setProperties(PropertyFactory.<%= prop.name %>(<%- helpers.androidGetConfigType(helpers.androidInputType(prop.type, prop.value), prop) -%>));
86
87
  }
87
88
  <%_ } else { _%>
88
89
  if (styleValue.isExpression()) {
89
90
  layer.setProperties(PropertyFactory.<%= prop.name %>(styleValue.getExpression()));
90
91
  } else {
91
- layer.setProperties(PropertyFactory.<%= prop.name %>(<%- androidGetConfigType(androidInputType(prop.type, prop.value), prop) -%>));
92
+ layer.setProperties(PropertyFactory.<%= prop.name %>(<%- helpers.androidGetConfigType(helpers.androidInputType(prop.type, prop.value), prop) -%>));
92
93
  }
93
94
  <%_ } _%>
94
95
  }
95
96
 
96
97
  <%_ if (prop.transition) { %>
97
- public static void set<%- pascalCase(prop.name) -%>Transition(<%- getLayerType(layer, 'android') -%> layer, RCTMLNStyleValue styleValue) {
98
+ public static void set<%- helpers.pascalCase(prop.name) -%>Transition(<%- helpers.getLayerType(layer, 'android') -%> layer, RCTMLNStyleValue styleValue) {
98
99
  TransitionOptions transition = styleValue.getTransition();
99
100
  if (transition != null) {
100
- layer.set<%- pascalCase(prop.name) -%>Transition(transition);
101
+ layer.set<%- helpers.pascalCase(prop.name) -%>Transition(transition);
101
102
  }
102
103
  }
103
104