@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,49 +1,47 @@
|
|
|
1
|
-
require(
|
|
1
|
+
require("./utils/template-globals");
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
3
|
+
const { execSync } = require("child_process");
|
|
4
|
+
const ejs = require("ejs");
|
|
5
|
+
const prettierrc = require("eslint-config-universe");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const prettier = require("prettier");
|
|
5
9
|
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const prettier = require('prettier');
|
|
11
|
-
const prettierrc = require('eslint-config-universe');
|
|
12
|
-
|
|
13
|
-
const styleSpecJSON = require('../style-spec/v8.json');
|
|
14
|
-
|
|
15
|
-
const DocJSONBuilder = require('./autogenHelpers/DocJSONBuilder');
|
|
16
|
-
const MarkdownBuilder = require('./autogenHelpers/MarkdownBuilder');
|
|
10
|
+
const { camelCase } = require("./utils/template-globals");
|
|
11
|
+
const styleSpecJSON = require("../style-spec/v8.json");
|
|
12
|
+
const DocJSONBuilder = require("./utils/DocJSONBuilder");
|
|
13
|
+
const MarkdownBuilder = require("./utils/MarkdownBuilder");
|
|
17
14
|
|
|
18
15
|
function readIosVersion() {
|
|
19
16
|
const podspecPath = path.join(
|
|
20
17
|
__dirname,
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
"..",
|
|
19
|
+
"maplibre-react-native.podspec",
|
|
23
20
|
);
|
|
24
|
-
const lines = fs.readFileSync(podspecPath,
|
|
21
|
+
const lines = fs.readFileSync(podspecPath, "utf8").split("\n");
|
|
25
22
|
const maplibreLineRegex = /^\s+version:\s*"(\d+\.\d+\.\d+)"$/;
|
|
26
|
-
const maplibreLine = lines.filter(i => maplibreLineRegex.exec(i))[0];
|
|
23
|
+
const maplibreLine = lines.filter((i) => maplibreLineRegex.exec(i))[0];
|
|
27
24
|
return `${maplibreLineRegex.exec(maplibreLine)[1]}.0`;
|
|
28
25
|
}
|
|
29
26
|
|
|
30
27
|
function readAndroidVersion() {
|
|
31
28
|
const buildGradlePath = path.join(
|
|
32
29
|
__dirname,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
"..",
|
|
31
|
+
"android",
|
|
32
|
+
"rctmln",
|
|
33
|
+
"build.gradle",
|
|
37
34
|
);
|
|
38
|
-
const lines = fs.readFileSync(buildGradlePath,
|
|
39
|
-
const maplibreLineRegex =
|
|
40
|
-
|
|
35
|
+
const lines = fs.readFileSync(buildGradlePath, "utf8").split("\n");
|
|
36
|
+
const maplibreLineRegex =
|
|
37
|
+
/^\s+implementation\s+"org.maplibre.gl:android-sdk:(\d+\.\d+\.\d+)"$/;
|
|
38
|
+
const maplibreLine = lines.filter((i) => maplibreLineRegex.exec(i))[0];
|
|
41
39
|
return maplibreLineRegex.exec(maplibreLine)[1];
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
if (!styleSpecJSON) {
|
|
45
43
|
console.log(
|
|
46
|
-
'Could not find style spec, try running "yarn
|
|
44
|
+
'Could not find style spec, try running "yarn generate:fetch-style-spec"',
|
|
47
45
|
);
|
|
48
46
|
process.exit(1);
|
|
49
47
|
}
|
|
@@ -52,42 +50,42 @@ const layers = [];
|
|
|
52
50
|
const androidVersion = readAndroidVersion();
|
|
53
51
|
const iosVersion = readIosVersion();
|
|
54
52
|
|
|
55
|
-
const TMPL_PATH = path.join(__dirname,
|
|
53
|
+
const TMPL_PATH = path.join(__dirname, "templates");
|
|
56
54
|
|
|
57
55
|
const outputToExample = false;
|
|
58
56
|
const OUTPUT_EXAMPLE_PREFIX = [
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
"..",
|
|
58
|
+
"example",
|
|
59
|
+
"node_modules",
|
|
60
|
+
"@maplibre",
|
|
61
|
+
"maplibre-react-native",
|
|
64
62
|
];
|
|
65
|
-
const OUTPUT_PREFIX = outputToExample ? OUTPUT_EXAMPLE_PREFIX : [
|
|
63
|
+
const OUTPUT_PREFIX = outputToExample ? OUTPUT_EXAMPLE_PREFIX : [".."];
|
|
66
64
|
|
|
67
|
-
const IOS_OUTPUT_PATH = path.join(__dirname, ...OUTPUT_PREFIX,
|
|
65
|
+
const IOS_OUTPUT_PATH = path.join(__dirname, ...OUTPUT_PREFIX, "ios", "RCTMLN");
|
|
68
66
|
const ANDROID_OUTPUT_PATH = path.join(
|
|
69
67
|
__dirname,
|
|
70
68
|
...OUTPUT_PREFIX,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
69
|
+
"android",
|
|
70
|
+
"rctmln",
|
|
71
|
+
"src",
|
|
72
|
+
"main",
|
|
73
|
+
"java",
|
|
74
|
+
"com",
|
|
75
|
+
"maplibre",
|
|
76
|
+
"rctmln",
|
|
77
|
+
"components",
|
|
78
|
+
"styles",
|
|
81
79
|
);
|
|
82
80
|
const JS_OUTPUT_PATH = path.join(
|
|
83
81
|
__dirname,
|
|
84
82
|
...OUTPUT_PREFIX,
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
"javascript",
|
|
84
|
+
"utils",
|
|
87
85
|
);
|
|
88
86
|
|
|
89
87
|
getSupportedLayers(Object.keys(styleSpecJSON.layer.type.values)).forEach(
|
|
90
|
-
layerName => {
|
|
88
|
+
(layerName) => {
|
|
91
89
|
layers.push({
|
|
92
90
|
name: layerName,
|
|
93
91
|
properties: getPropertiesForLayer(layerName),
|
|
@@ -96,12 +94,12 @@ getSupportedLayers(Object.keys(styleSpecJSON.layer.type.values)).forEach(
|
|
|
96
94
|
);
|
|
97
95
|
|
|
98
96
|
// add light as a layer
|
|
99
|
-
layers.push({name:
|
|
97
|
+
layers.push({ name: "light", properties: getPropertiesForLight() });
|
|
100
98
|
|
|
101
99
|
function getPropertiesForLight() {
|
|
102
100
|
const lightAttributes = styleSpecJSON.light;
|
|
103
101
|
|
|
104
|
-
return getSupportedProperties(lightAttributes).map(attrName => {
|
|
102
|
+
return getSupportedProperties(lightAttributes).map((attrName) => {
|
|
105
103
|
return Object.assign({}, buildProperties(lightAttributes, attrName), {
|
|
106
104
|
allowedFunctionTypes: [],
|
|
107
105
|
});
|
|
@@ -112,41 +110,43 @@ function getPropertiesForLayer(layerName) {
|
|
|
112
110
|
const paintAttributes = styleSpecJSON[`paint_${layerName}`];
|
|
113
111
|
const layoutAttributes = styleSpecJSON[`layout_${layerName}`];
|
|
114
112
|
|
|
115
|
-
const paintProps = getSupportedProperties(paintAttributes).map(attrName => {
|
|
113
|
+
const paintProps = getSupportedProperties(paintAttributes).map((attrName) => {
|
|
116
114
|
const prop = buildProperties(paintAttributes, attrName);
|
|
117
115
|
|
|
118
116
|
// overrides
|
|
119
|
-
if ([
|
|
120
|
-
prop.allowedFunctionTypes = [
|
|
117
|
+
if (["line-width"].includes(attrName)) {
|
|
118
|
+
prop.allowedFunctionTypes = ["camera"];
|
|
121
119
|
}
|
|
122
120
|
|
|
123
121
|
return prop;
|
|
124
122
|
});
|
|
125
123
|
|
|
126
|
-
const layoutProps = getSupportedProperties(layoutAttributes).map(
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
prop.type
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
124
|
+
const layoutProps = getSupportedProperties(layoutAttributes).map(
|
|
125
|
+
(attrName) => {
|
|
126
|
+
const prop = buildProperties(layoutAttributes, attrName);
|
|
127
|
+
|
|
128
|
+
// overrides
|
|
129
|
+
if (
|
|
130
|
+
[
|
|
131
|
+
"line-join",
|
|
132
|
+
"text-max-width",
|
|
133
|
+
"text-letter-spacing",
|
|
134
|
+
"text-anchor",
|
|
135
|
+
"text-justify",
|
|
136
|
+
"text-font",
|
|
137
|
+
].includes(attrName)
|
|
138
|
+
) {
|
|
139
|
+
prop.allowedFunctionTypes = ["camera"];
|
|
140
|
+
}
|
|
141
|
+
// Overide type padding
|
|
142
|
+
if (prop.type === "padding") {
|
|
143
|
+
prop.type = "array";
|
|
144
|
+
prop.value = "number";
|
|
145
|
+
prop.length = 4;
|
|
146
|
+
}
|
|
147
|
+
return prop;
|
|
148
|
+
},
|
|
149
|
+
);
|
|
150
150
|
|
|
151
151
|
return layoutProps.concat(paintProps);
|
|
152
152
|
}
|
|
@@ -157,7 +157,7 @@ function getSupportedLayers(layerNames) {
|
|
|
157
157
|
const supportedLayers = [];
|
|
158
158
|
for (const layerName of layerNames) {
|
|
159
159
|
const layer = layerMap[layerName];
|
|
160
|
-
const support = getAttributeSupport(layer[
|
|
160
|
+
const support = getAttributeSupport(layer["sdk-support"]);
|
|
161
161
|
|
|
162
162
|
if (support.basic.android && support.basic.ios) {
|
|
163
163
|
supportedLayers.push(layerName);
|
|
@@ -168,7 +168,7 @@ function getSupportedLayers(layerNames) {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
function getSupportedProperties(attributes) {
|
|
171
|
-
return Object.keys(attributes).filter(attrName =>
|
|
171
|
+
return Object.keys(attributes).filter((attrName) =>
|
|
172
172
|
isAttrSupported(attributes[attrName]),
|
|
173
173
|
);
|
|
174
174
|
}
|
|
@@ -194,23 +194,23 @@ function buildProperties(attributes, attrName) {
|
|
|
194
194
|
expression: attributes[attrName].expression,
|
|
195
195
|
expressionSupported:
|
|
196
196
|
Object.keys(attributes[attrName].expression || {}).length > 0,
|
|
197
|
-
support: getAttributeSupport(attributes[attrName][
|
|
197
|
+
support: getAttributeSupport(attributes[attrName]["sdk-support"]),
|
|
198
198
|
allowedFunctionTypes: getAllowedFunctionTypes(attributes[attrName]),
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
function formatDescription(description) {
|
|
203
|
-
const words = description.split(
|
|
203
|
+
const words = description.split(" ");
|
|
204
204
|
|
|
205
205
|
for (let i = 0; i < words.length; i++) {
|
|
206
206
|
const word = words[i];
|
|
207
207
|
|
|
208
|
-
if (word.includes(
|
|
208
|
+
if (word.includes("-")) {
|
|
209
209
|
words[i] = camelCase(word);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
return words.join(
|
|
213
|
+
return words.join(" ");
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
function getRequires(requiredItems) {
|
|
@@ -221,8 +221,8 @@ function getRequires(requiredItems) {
|
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
for (const item of requiredItems) {
|
|
224
|
-
if (typeof item ===
|
|
225
|
-
items.push(camelCase(item,
|
|
224
|
+
if (typeof item === "string") {
|
|
225
|
+
items.push(camelCase(item, "-"));
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
|
|
@@ -237,8 +237,8 @@ function getDisables(disabledItems) {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
for (const item of disabledItems) {
|
|
240
|
-
if (item[
|
|
241
|
-
items.push(camelCase(item[
|
|
240
|
+
if (item["!"]) {
|
|
241
|
+
items.push(camelCase(item["!"], "-"));
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
|
|
@@ -247,30 +247,30 @@ function getDisables(disabledItems) {
|
|
|
247
247
|
|
|
248
248
|
function isImage(attrName) {
|
|
249
249
|
return (
|
|
250
|
-
attrName.toLowerCase().indexOf(
|
|
251
|
-
attrName.toLowerCase().indexOf(
|
|
250
|
+
attrName.toLowerCase().indexOf("pattern") !== -1 ||
|
|
251
|
+
attrName.toLowerCase().indexOf("image") !== -1
|
|
252
252
|
);
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
function isTranslate(attrName) {
|
|
256
|
-
return attrName.toLowerCase().indexOf(
|
|
256
|
+
return attrName.toLowerCase().indexOf("translate") !== -1;
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
function isAttrSupported(attr) {
|
|
260
|
-
const support = getAttributeSupport(attr[
|
|
260
|
+
const support = getAttributeSupport(attr["sdk-support"]);
|
|
261
261
|
if (attr.private) {
|
|
262
|
-
return false
|
|
262
|
+
return false;
|
|
263
263
|
}
|
|
264
264
|
return support.basic.android && support.basic.ios;
|
|
265
265
|
}
|
|
266
266
|
|
|
267
267
|
function getAttributeSupport(sdkSupport) {
|
|
268
268
|
const support = {
|
|
269
|
-
basic: {android: false, ios: false},
|
|
270
|
-
data: {android: false, ios: false},
|
|
269
|
+
basic: { android: false, ios: false },
|
|
270
|
+
data: { android: false, ios: false },
|
|
271
271
|
};
|
|
272
272
|
|
|
273
|
-
const basicSupport = sdkSupport && sdkSupport[
|
|
273
|
+
const basicSupport = sdkSupport && sdkSupport["basic functionality"];
|
|
274
274
|
if (basicSupport && basicSupport.android) {
|
|
275
275
|
support.basic.android = isVersionGTE(androidVersion, basicSupport.android);
|
|
276
276
|
}
|
|
@@ -278,7 +278,7 @@ function getAttributeSupport(sdkSupport) {
|
|
|
278
278
|
support.basic.ios = isVersionGTE(iosVersion, basicSupport.ios);
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
const dataDrivenSupport = sdkSupport && sdkSupport[
|
|
281
|
+
const dataDrivenSupport = sdkSupport && sdkSupport["data-driven styling"];
|
|
282
282
|
if (dataDrivenSupport && dataDrivenSupport.android) {
|
|
283
283
|
support.data.android = isVersionGTE(
|
|
284
284
|
androidVersion,
|
|
@@ -299,26 +299,26 @@ function getAttributeSupport(sdkSupport) {
|
|
|
299
299
|
|
|
300
300
|
function isVersionGTE(version, otherVersion) {
|
|
301
301
|
const v = +version
|
|
302
|
-
.split(
|
|
303
|
-
.map(i => String(i).padStart(3,
|
|
304
|
-
.join(
|
|
302
|
+
.split(".")
|
|
303
|
+
.map((i) => String(i).padStart(3, "0"))
|
|
304
|
+
.join("");
|
|
305
305
|
const ov = +otherVersion
|
|
306
|
-
.split(
|
|
307
|
-
.map(i => String(i).padStart(3,
|
|
308
|
-
.join(
|
|
306
|
+
.split(".")
|
|
307
|
+
.map((i) => String(i).padStart(3, "0"))
|
|
308
|
+
.join("");
|
|
309
309
|
return v >= ov;
|
|
310
310
|
}
|
|
311
311
|
|
|
312
312
|
function getAllowedFunctionTypes(paintAttr) {
|
|
313
313
|
const allowedFunctionTypes = [];
|
|
314
314
|
|
|
315
|
-
if (paintAttr[
|
|
316
|
-
allowedFunctionTypes.push(
|
|
315
|
+
if (paintAttr["zoom-function"]) {
|
|
316
|
+
allowedFunctionTypes.push("camera");
|
|
317
317
|
}
|
|
318
318
|
|
|
319
|
-
if (paintAttr[
|
|
320
|
-
allowedFunctionTypes.push(
|
|
321
|
-
allowedFunctionTypes.push(
|
|
319
|
+
if (paintAttr["property-function"]) {
|
|
320
|
+
allowedFunctionTypes.push("source");
|
|
321
|
+
allowedFunctionTypes.push("composite");
|
|
322
322
|
}
|
|
323
323
|
|
|
324
324
|
return allowedFunctionTypes;
|
|
@@ -327,45 +327,52 @@ function getAllowedFunctionTypes(paintAttr) {
|
|
|
327
327
|
async function generate() {
|
|
328
328
|
const templateMappings = [
|
|
329
329
|
{
|
|
330
|
-
input: path.join(TMPL_PATH,
|
|
331
|
-
output: path.join(IOS_OUTPUT_PATH,
|
|
330
|
+
input: path.join(TMPL_PATH, "RCTMLNStyle.h.ejs"),
|
|
331
|
+
output: path.join(IOS_OUTPUT_PATH, "RCTMLNStyle.h"),
|
|
332
332
|
},
|
|
333
333
|
{
|
|
334
|
-
input: path.join(TMPL_PATH,
|
|
335
|
-
output: path.join(JS_OUTPUT_PATH,
|
|
334
|
+
input: path.join(TMPL_PATH, "MaplibreStyles.ts.ejs"),
|
|
335
|
+
output: path.join(JS_OUTPUT_PATH, "MaplibreStyles.d.ts"),
|
|
336
336
|
},
|
|
337
337
|
{
|
|
338
|
-
input: path.join(TMPL_PATH,
|
|
339
|
-
output: path.join(IOS_OUTPUT_PATH,
|
|
338
|
+
input: path.join(TMPL_PATH, "RCTMLNStyle.m.ejs"),
|
|
339
|
+
output: path.join(IOS_OUTPUT_PATH, "RCTMLNStyle.m"),
|
|
340
340
|
},
|
|
341
341
|
{
|
|
342
|
-
input: path.join(TMPL_PATH,
|
|
343
|
-
output: path.join(ANDROID_OUTPUT_PATH,
|
|
342
|
+
input: path.join(TMPL_PATH, "RCTMLNStyleFactory.java.ejs"),
|
|
343
|
+
output: path.join(ANDROID_OUTPUT_PATH, "RCTMLNStyleFactory.java"),
|
|
344
344
|
},
|
|
345
345
|
{
|
|
346
|
-
input: path.join(TMPL_PATH,
|
|
347
|
-
output: path.join(JS_OUTPUT_PATH,
|
|
346
|
+
input: path.join(TMPL_PATH, "styleMap.ts.ejs"),
|
|
347
|
+
output: path.join(JS_OUTPUT_PATH, "styleMap.ts"),
|
|
348
348
|
},
|
|
349
349
|
];
|
|
350
|
-
const outputPaths = templateMappings.map(m => m.output);
|
|
350
|
+
const outputPaths = templateMappings.map((m) => m.output);
|
|
351
351
|
|
|
352
352
|
// autogenerate code
|
|
353
|
-
await Promise.all(
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
353
|
+
await Promise.all(
|
|
354
|
+
templateMappings.map(async ({ input, output }) => {
|
|
355
|
+
const filename = output.split("/").pop();
|
|
356
|
+
console.log(`Generating ${filename}`);
|
|
357
|
+
const tmpl = ejs.compile(fs.readFileSync(input, "utf8"), {
|
|
358
|
+
strict: true,
|
|
359
|
+
});
|
|
360
|
+
let results = tmpl({ layers });
|
|
361
|
+
if (filename.endsWith("ts")) {
|
|
362
|
+
results = await prettier.format(results, {
|
|
363
|
+
...prettierrc,
|
|
364
|
+
filepath: filename,
|
|
365
|
+
});
|
|
366
|
+
// Ensure all enums are exported
|
|
367
|
+
results = results.replace(/enum (\w+Enum) \{[^}]+\}\n/g, "export $&");
|
|
368
|
+
// Replace Array<any> with any[]
|
|
369
|
+
results = results.replace(/Array<any>/g, "any[]");
|
|
370
|
+
// Replace padding type with float array
|
|
371
|
+
results = results.replace(/padding: string;/g, "padding: number[];");
|
|
372
|
+
}
|
|
373
|
+
fs.writeFileSync(output, results);
|
|
374
|
+
}),
|
|
375
|
+
);
|
|
369
376
|
|
|
370
377
|
// autogenerate docs
|
|
371
378
|
const docBuilder = new DocJSONBuilder(layers);
|
|
@@ -375,11 +382,11 @@ async function generate() {
|
|
|
375
382
|
|
|
376
383
|
// Check if any generated files changed
|
|
377
384
|
try {
|
|
378
|
-
execSync(`git diff --exit-code docs/ ${outputPaths.join(
|
|
379
|
-
} catch (
|
|
385
|
+
execSync(`git diff --exit-code docs/ ${outputPaths.join(" ")}`);
|
|
386
|
+
} catch (_error) {
|
|
380
387
|
console.error(
|
|
381
|
-
|
|
382
|
-
|
|
388
|
+
"\n\nThere are unstaged changes in the generated code. " +
|
|
389
|
+
"Please add them to your commit.\n" +
|
|
383
390
|
'If you would really like to exclude them, run "git commit -n" to skip.\n\n',
|
|
384
391
|
);
|
|
385
392
|
process.exit(1);
|
|
@@ -59,19 +59,19 @@ export type Value<T, AllowedParameters extends ExpressionParameters[] = []> =
|
|
|
59
59
|
| Expression;
|
|
60
60
|
|
|
61
61
|
<%_ for (let enumInfo of getEnums(layers)) { _%>
|
|
62
|
-
enum <%-
|
|
62
|
+
enum <%- pascalCase(enumInfo.name) %>Enum {
|
|
63
63
|
<%_ for (let k of Object.keys(enumInfo.values)) { _%>
|
|
64
64
|
/** <%- enumInfo.values[k].doc %> */
|
|
65
|
-
<%-
|
|
65
|
+
<%- pascalCase(k) %> = '<%- k %>',
|
|
66
66
|
<%_ } _%>
|
|
67
67
|
}
|
|
68
|
-
type <%-
|
|
68
|
+
type <%- pascalCase(enumInfo.name) %>EnumValues = <%- Object.keys(enumInfo.values).map(k => `'${k}'`).join(' | ') %>;
|
|
69
69
|
<%_ } _%>
|
|
70
70
|
|
|
71
71
|
type Enum<EnumType, EnumValues> = EnumType | EnumValues;
|
|
72
72
|
|
|
73
73
|
<%_ for (let layer of layers) { _%>
|
|
74
|
-
export interface <%-
|
|
74
|
+
export interface <%- pascalCase(layer.name) %>LayerStyleProps {
|
|
75
75
|
<%_ for (let prop of layer.properties) { _%>
|
|
76
76
|
/**
|
|
77
77
|
* <%- prop.doc.description %>
|
|
@@ -96,4 +96,4 @@ type Enum<EnumType, EnumValues> = EnumType | EnumValues;
|
|
|
96
96
|
};
|
|
97
97
|
<%_ } _%>
|
|
98
98
|
|
|
99
|
-
export type AllLayerStyleProps = <%- layers.map(l => `${
|
|
99
|
+
export type AllLayerStyleProps = <%- layers.map(l => `${pascalCase(l.name)}LayerStyleProps`).join("|") -%>;
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
|
|
24
24
|
<%_ for (const layer of layers) { _%>
|
|
25
25
|
<%_ for (const prop of layer.properties) { _%>
|
|
26
|
-
- (void)set<%- iosPropMethodName(layer,
|
|
26
|
+
- (void)set<%- iosPropMethodName(layer, pascalCase(prop.name)) -%>:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue;
|
|
27
27
|
<%_ if (prop.transition) { _%>
|
|
28
|
-
- (void)set<%- iosPropMethodName(layer,
|
|
28
|
+
- (void)set<%- iosPropMethodName(layer, pascalCase(prop.name)) -%>Transition:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue;
|
|
29
29
|
<%_ } _%>
|
|
30
30
|
<%_ } _%>
|
|
31
31
|
<% } %>
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
<%- ifOrElseIf(i) -%> ([prop isEqualToString:@"<%= layer.properties[i].name %>"]) {
|
|
38
38
|
<%_ if (layer.properties[i].image) { _%>
|
|
39
39
|
if (![styleValue shouldAddImage]) {
|
|
40
|
-
[self set<%- iosPropMethodName(layer,
|
|
40
|
+
[self set<%- iosPropMethodName(layer, pascalCase(layer.properties[i].name)) -%>:layer withReactStyleValue:styleValue];
|
|
41
41
|
} else {
|
|
42
42
|
NSString *imageURI = [styleValue getImageURI];
|
|
43
43
|
|
|
@@ -46,18 +46,18 @@
|
|
|
46
46
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
47
47
|
if (isValid()) {
|
|
48
48
|
[self->_style setImage:image forName:imageURI];
|
|
49
|
-
[self set<%- iosPropMethodName(layer,
|
|
49
|
+
[self set<%- iosPropMethodName(layer, pascalCase(layer.properties[i].name)) -%>:layer withReactStyleValue:styleValue];
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
}];
|
|
54
54
|
}
|
|
55
55
|
<%_ } else { _%>
|
|
56
|
-
[self set<%- iosPropMethodName(layer,
|
|
56
|
+
[self set<%- iosPropMethodName(layer, pascalCase(layer.properties[i].name)) -%>:layer withReactStyleValue:styleValue];
|
|
57
57
|
<%_ } _%>
|
|
58
58
|
<%_ if (layer.properties[i].transition) { _%>
|
|
59
59
|
} else if ([prop isEqualToString:@"<%= layer.properties[i].name %>Transition"]) {
|
|
60
|
-
[self set<%- iosPropMethodName(layer,
|
|
60
|
+
[self set<%- iosPropMethodName(layer, pascalCase(layer.properties[i].name)) -%>Transition:layer withReactStyleValue:styleValue];
|
|
61
61
|
<%_ } _%>
|
|
62
62
|
<% } -%>
|
|
63
63
|
} else {
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
|
|
70
70
|
<% for (const layer of layers) {%>
|
|
71
71
|
<% for (const prop of layer.properties) {%>
|
|
72
|
-
- (void)set<%- iosPropMethodName(layer,
|
|
72
|
+
- (void)set<%- iosPropMethodName(layer, pascalCase(prop.name)) -%>:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue
|
|
73
73
|
{
|
|
74
74
|
<%_ if (layer.name === 'light' && prop.name === 'position') { _%>
|
|
75
75
|
layer.position = [styleValue getSphericalPosition];
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
}
|
|
82
82
|
<%_ if (prop.transition) { _%>
|
|
83
83
|
|
|
84
|
-
- (void)set<%- iosPropMethodName(layer,
|
|
84
|
+
- (void)set<%- iosPropMethodName(layer, pascalCase(prop.name)) -%>Transition:(<%- getLayerType(layer, 'ios') -%> *)layer withReactStyleValue:(RCTMLNStyleValue *)styleValue
|
|
85
85
|
{
|
|
86
86
|
layer.<%- iosPropName(prop.name) -%>Transition = [styleValue getTransition];
|
|
87
87
|
}
|
|
@@ -46,16 +46,16 @@ public class RCTMLNStyleFactory {
|
|
|
46
46
|
style.addImage(styleValue, new DownloadMapImageTask.OnAllImagesLoaded() {
|
|
47
47
|
@Override
|
|
48
48
|
public void onAllImagesLoaded() {
|
|
49
|
-
RCTMLNStyleFactory.set<%-
|
|
49
|
+
RCTMLNStyleFactory.set<%- pascalCase(prop.name) -%>(layer, styleValue);
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
<%_ } else { _%>
|
|
53
|
-
RCTMLNStyleFactory.set<%-
|
|
53
|
+
RCTMLNStyleFactory.set<%- pascalCase(prop.name) -%>(layer, styleValue);
|
|
54
54
|
<%_ } _%>
|
|
55
55
|
break;
|
|
56
56
|
<%_ if (prop.transition) { _%>
|
|
57
57
|
case "<%= prop.name %>Transition":
|
|
58
|
-
RCTMLNStyleFactory.set<%-
|
|
58
|
+
RCTMLNStyleFactory.set<%- pascalCase(prop.name) -%>Transition(layer, styleValue);
|
|
59
59
|
break;
|
|
60
60
|
<%_ } _%>
|
|
61
61
|
<%_ } _%>
|
|
@@ -66,12 +66,12 @@ public class RCTMLNStyleFactory {
|
|
|
66
66
|
|
|
67
67
|
<%_ for (const layer of layers) { _%>
|
|
68
68
|
<%_ for (const prop of layer.properties) { _%>
|
|
69
|
-
public static void set<%-
|
|
69
|
+
public static void set<%- pascalCase(prop.name) -%>(<%- getLayerType(layer, 'android') -%> layer, RCTMLNStyleValue styleValue) {
|
|
70
70
|
<%_ if (layer.name === 'light' && prop.name === 'position') { _%>
|
|
71
71
|
Float[] values = styleValue.getFloatArray(VALUE_KEY);
|
|
72
|
-
layer.set<%-
|
|
72
|
+
layer.set<%- pascalCase(prop.name) -%>(Position.fromPosition(values[0], values[1], values[2]));
|
|
73
73
|
<%_ } else if (layer.name === 'light') { _%>
|
|
74
|
-
layer.set<%-
|
|
74
|
+
layer.set<%- pascalCase(prop.name) -%>(<%- androidGetConfigType(androidInputType(prop.type, prop.value), prop) -%>);
|
|
75
75
|
<%_ } else if (prop.name === 'visibility') { _%>
|
|
76
76
|
layer.setProperties(PropertyFactory.visibility(styleValue.getString(VALUE_KEY)));
|
|
77
77
|
<%_ } else if (prop.type === 'resolvedImage') { _%>
|
|
@@ -94,10 +94,10 @@ public class RCTMLNStyleFactory {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
<%_ if (prop.transition) { %>
|
|
97
|
-
public static void set<%-
|
|
97
|
+
public static void set<%- pascalCase(prop.name) -%>Transition(<%- getLayerType(layer, 'android') -%> layer, RCTMLNStyleValue styleValue) {
|
|
98
98
|
TransitionOptions transition = styleValue.getTransition();
|
|
99
99
|
if (transition != null) {
|
|
100
|
-
layer.set<%-
|
|
100
|
+
layer.set<%- pascalCase(prop.name) -%>Transition(transition);
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
|