react-native-persona 2.2.0 → 2.2.3
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/CHANGELOG.md +29 -0
- package/README.md +149 -2
- package/RNPersonaInquiry2.podspec +1 -1
- package/android/build.gradle +1 -2
- package/android/src/main/java/com/withpersona/sdk2/reactnative/PersonaInquiryModule2.java +8 -2
- package/bin/persona-tool +1 -2
- package/ios/PersonaInquiry2.swift +4 -0
- package/lib/commonjs/index.js +66 -4
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/persona-tool/AndroidResourcePrinter.js +497 -0
- package/lib/commonjs/persona-tool/AndroidResourcePrinter.js.map +1 -0
- package/lib/commonjs/persona-tool/Config.js +95 -0
- package/lib/commonjs/persona-tool/Config.js.map +1 -0
- package/lib/commonjs/persona-tool/Theme.js +199 -0
- package/lib/commonjs/persona-tool/Theme.js.map +1 -0
- package/lib/commonjs/persona-tool/index.js +41 -0
- package/lib/commonjs/persona-tool/index.js.map +1 -0
- package/lib/commonjs/persona-tool/prompts.js +48 -0
- package/lib/commonjs/persona-tool/prompts.js.map +1 -0
- package/lib/commonjs/persona-tool/tools/AndroidThemeGenerator.js +99 -0
- package/lib/commonjs/persona-tool/tools/AndroidThemeGenerator.js.map +1 -0
- package/lib/commonjs/persona-tool/tools/IosThemeInstructions.js +50 -0
- package/lib/commonjs/persona-tool/tools/IosThemeInstructions.js.map +1 -0
- package/lib/commonjs/versions.js +25 -0
- package/lib/commonjs/versions.js.map +1 -0
- package/lib/module/index.js +58 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/persona-tool/AndroidResourcePrinter.js +489 -0
- package/lib/module/persona-tool/AndroidResourcePrinter.js.map +1 -0
- package/lib/module/persona-tool/Config.js +82 -0
- package/lib/module/persona-tool/Config.js.map +1 -0
- package/lib/module/persona-tool/Theme.js +183 -0
- package/lib/module/persona-tool/Theme.js.map +1 -0
- package/lib/module/persona-tool/index.js +33 -0
- package/lib/module/persona-tool/index.js.map +1 -0
- package/lib/module/persona-tool/prompts.js +31 -0
- package/lib/module/persona-tool/prompts.js.map +1 -0
- package/lib/module/persona-tool/tools/AndroidThemeGenerator.js +72 -0
- package/lib/module/persona-tool/tools/AndroidThemeGenerator.js.map +1 -0
- package/lib/module/persona-tool/tools/IosThemeInstructions.js +37 -0
- package/lib/module/persona-tool/tools/IosThemeInstructions.js.map +1 -0
- package/lib/module/versions.js +14 -0
- package/lib/module/versions.js.map +1 -0
- package/lib/typescript/{src/fields.d.ts → fields.d.ts} +0 -0
- package/lib/typescript/{src/index.d.ts → index.d.ts} +50 -0
- package/lib/typescript/{persona-tools/lib → persona-tool}/AndroidResourcePrinter.d.ts +2 -2
- package/lib/typescript/{persona-tools → persona-tool}/Config.d.ts +0 -0
- package/lib/typescript/{persona-tools → persona-tool}/Theme.d.ts +0 -0
- package/lib/typescript/{persona-tools → persona-tool}/index.d.ts +0 -0
- package/lib/typescript/{persona-tools/lib → persona-tool}/prompts.d.ts +1 -1
- package/lib/typescript/{persona-tools → persona-tool}/tools/AndroidThemeGenerator.d.ts +0 -0
- package/lib/typescript/{persona-tools → persona-tool}/tools/IosThemeInstructions.d.ts +0 -0
- package/lib/typescript/{src/util.d.ts → util.d.ts} +0 -0
- package/lib/typescript/versions.d.ts +6 -0
- package/package.json +4 -5
- package/src/index.ts +65 -3
- package/{persona-tools/lib → src/persona-tool}/AndroidResourcePrinter.ts +182 -182
- package/{persona-tools → src/persona-tool}/Config.ts +0 -0
- package/{persona-tools → src/persona-tool}/Theme.ts +0 -0
- package/{persona-tools → src/persona-tool}/index.ts +1 -1
- package/{persona-tools/lib → src/persona-tool}/prompts.ts +11 -11
- package/{persona-tools → src/persona-tool}/tools/AndroidThemeGenerator.ts +2 -2
- package/{persona-tools → src/persona-tool}/tools/IosThemeInstructions.ts +1 -1
- package/src/versions.ts +12 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["Config.ts"],"names":["Configuration","loadConfig","config","explorer","packageProp","result","search","e","console","error","process","exit","get","androidThemeLines","key","ANDROID_THEME_CONFIG_KEY","push","iosThemeLines","IOS_THEME_CONFIG_KEY","log","chalk","yellow","join"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;AAOA,MAAMA,aAAN,CAAoB;AAAA;AAAA;AAAA;;AAGF,QAAVC,UAAU,GAA6C;AAC3D,QAAI,KAAKC,MAAT,EAAiB,OAAO,KAAKA,MAAZ;;AAEjB,QAAI;AACF,YAAMC,QAAQ,GAAG,8BAAY,SAAZ,EAAuB;AAAEC,QAAAA,WAAW,EAAE;AAAf,OAAvB,CAAjB;AACA,YAAMC,MAAM,GAAG,MAAMF,QAAQ,CAACG,MAAT,EAArB;;AACA,UAAID,MAAM,IAAI,IAAd,EAAoB;AAClB,eAAO,IAAP;AACD;;AAED,WAAKH,MAAL,GAAcG,MAAM,CAACH,MAArB;AAEA,aAAO,KAAKA,MAAZ;AACD,KAVD,CAUE,OAAOK,CAAP,EAAU;AACVC,MAAAA,OAAO,CAACC,KAAR,CAAcF,CAAd;AACAG,MAAAA,OAAO,CAACC,IAAR,CAAa,CAAb;AACD;AACF;;AAEQ,QAAHC,GAAG,GAA0B;AACjC,QAAIV,MAAM,GAAG,MAAM,KAAKD,UAAL,EAAnB;AAEA,UAAMY,iBAAiB,GAAG,EAA1B;;AACA,SAAK,MAAMC,GAAX,IAAkBC,+BAAlB,EAA4C;AAC1CF,MAAAA,iBAAiB,CAACG,IAAlB,CAAwB,UAASF,GAAI,SAArC;AACD;;AAED,UAAMG,aAAa,GAAG,EAAtB;;AACA,SAAK,MAAMH,GAAX,IAAkBI,2BAAlB,EAAwC;AACtCD,MAAAA,aAAa,CAACD,IAAd,CAAoB,UAASF,GAAI,SAAjC;AACD;;AAED,QAAIZ,MAAM,IAAI,IAAd,EAAoB;AAClBM,MAAAA,OAAO,CAACW,GAAR,CACG;AACT;AACA;AACA,2DAA2DC,eAAMC,MAAN,CACjD,SADiD,CAEjD;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAfQ,GAgBER,iBAAiB,CAACS,IAAlB,CAAuB,KAAvB,CAhBF,GAiBG;AACX;AACA;AACA,CApBQ,GAqBEL,aAAa,CAACK,IAAd,CAAmB,KAAnB,CArBF,GAsBG;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CA/BM;AAiCAZ,MAAAA,OAAO,CAACC,IAAR,CAAa,CAAb;AACD;;AAED,WAAOT,MAAP;AACD;;AAzEiB;;eA4EL,IAAIF,aAAJ,E","sourcesContent":["import { cosmiconfig } from 'cosmiconfig';\nimport chalk from 'chalk';\nimport { ANDROID_THEME_CONFIG_KEY, IOS_THEME_CONFIG_KEY } from './Theme';\n\nexport interface ConfigObject {\n androidTheme: { [key: string]: string | null | undefined };\n iosTheme: { [key: string]: string | null | undefined };\n}\n\nclass Configuration {\n config?: ConfigObject | null;\n\n async loadConfig(): Promise<ConfigObject | null | undefined> {\n if (this.config) return this.config;\n\n try {\n const explorer = cosmiconfig('persona', { packageProp: 'persona' });\n const result = await explorer.search();\n if (result == null) {\n return null;\n }\n\n this.config = result.config;\n\n return this.config;\n } catch (e) {\n console.error(e);\n process.exit(1);\n }\n }\n\n async get(): Promise<ConfigObject> {\n let config = await this.loadConfig();\n\n const androidThemeLines = [];\n for (const key in ANDROID_THEME_CONFIG_KEY) {\n androidThemeLines.push(` \"${key}\": null`);\n }\n\n const iosThemeLines = [];\n for (const key in IOS_THEME_CONFIG_KEY) {\n iosThemeLines.push(` \"${key}\": null`);\n }\n\n if (config == null) {\n console.log(\n `\nMissing configuration.\n\nIn order to use this tool, it must be configured using a ${chalk.yellow(\n 'persona'\n )} object within\nyour package.json.\n\nTo get started, paste the following configuration into your package.json\n\n{\n ...\n\n \"persona\": {\n \"androidTheme\": {\n` +\n androidThemeLines.join(',\\n') +\n `\n },\n \"iosTheme\": {\n` +\n iosThemeLines.join(',\\n') +\n `\n }\n }\n\n ...\n}\n\nand re-run this tool :).\n`\n );\n process.exit(1);\n }\n\n return config as ConfigObject;\n }\n}\n\nexport default new Configuration();\n"]}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.IOS_THEME_CONFIG_KEY = exports.ANDROID_THEME_CONFIG_KEY = void 0;
|
|
7
|
+
|
|
8
|
+
var _cliTable = _interopRequireDefault(require("cli-table"));
|
|
9
|
+
|
|
10
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
|
+
|
|
12
|
+
var _Config = _interopRequireDefault(require("./Config"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
const COLOR_REGEX = /^[a-zA-Z0-9]{6}$/;
|
|
17
|
+
let ANDROID_THEME_CONFIG_KEY;
|
|
18
|
+
exports.ANDROID_THEME_CONFIG_KEY = ANDROID_THEME_CONFIG_KEY;
|
|
19
|
+
|
|
20
|
+
(function (ANDROID_THEME_CONFIG_KEY) {
|
|
21
|
+
ANDROID_THEME_CONFIG_KEY["backgroundColor"] = "backgroundColor";
|
|
22
|
+
ANDROID_THEME_CONFIG_KEY["primaryColor"] = "primaryColor";
|
|
23
|
+
ANDROID_THEME_CONFIG_KEY["darkPrimaryColor"] = "darkPrimaryColor";
|
|
24
|
+
ANDROID_THEME_CONFIG_KEY["accentColor"] = "accentColor";
|
|
25
|
+
ANDROID_THEME_CONFIG_KEY["titleTextColor"] = "titleTextColor";
|
|
26
|
+
ANDROID_THEME_CONFIG_KEY["titleTextFont"] = "titleTextFont";
|
|
27
|
+
ANDROID_THEME_CONFIG_KEY["bodyTextColor"] = "bodyTextColor";
|
|
28
|
+
ANDROID_THEME_CONFIG_KEY["bodyTextFont"] = "bodyTextFont";
|
|
29
|
+
ANDROID_THEME_CONFIG_KEY["footnoteTextColor"] = "footnoteTextColor";
|
|
30
|
+
ANDROID_THEME_CONFIG_KEY["footnoteTextFont"] = "footnoteTextFont";
|
|
31
|
+
ANDROID_THEME_CONFIG_KEY["textFieldTextColor"] = "textFieldTextColor";
|
|
32
|
+
ANDROID_THEME_CONFIG_KEY["textFieldTextFont"] = "textFieldTextFont";
|
|
33
|
+
ANDROID_THEME_CONFIG_KEY["pickerTextColor"] = "pickerTextColor";
|
|
34
|
+
ANDROID_THEME_CONFIG_KEY["pickerTextFont"] = "pickerTextFont";
|
|
35
|
+
ANDROID_THEME_CONFIG_KEY["buttonBackgroundColor"] = "buttonBackgroundColor";
|
|
36
|
+
ANDROID_THEME_CONFIG_KEY["buttonDisabledBackgroundColor"] = "buttonDisabledBackgroundColor";
|
|
37
|
+
ANDROID_THEME_CONFIG_KEY["buttonTouchedBackgroundColor"] = "buttonTouchedBackgroundColor";
|
|
38
|
+
ANDROID_THEME_CONFIG_KEY["buttonTextColor"] = "buttonTextColor";
|
|
39
|
+
ANDROID_THEME_CONFIG_KEY["buttonDisabledTextColor"] = "buttonDisabledTextColor";
|
|
40
|
+
ANDROID_THEME_CONFIG_KEY["buttonCornerRadius"] = "buttonCornerRadius";
|
|
41
|
+
ANDROID_THEME_CONFIG_KEY["buttonFont"] = "buttonFont";
|
|
42
|
+
ANDROID_THEME_CONFIG_KEY["progressColor"] = "progressColor";
|
|
43
|
+
ANDROID_THEME_CONFIG_KEY["successAsset"] = "successAsset";
|
|
44
|
+
ANDROID_THEME_CONFIG_KEY["failAsset"] = "failAsset";
|
|
45
|
+
ANDROID_THEME_CONFIG_KEY["loadingAnimationAsset"] = "loadingAnimationAsset";
|
|
46
|
+
ANDROID_THEME_CONFIG_KEY["loadingAnimationWidthPercent"] = "loadingAnimationWidthPercent";
|
|
47
|
+
ANDROID_THEME_CONFIG_KEY["selfieAnimationAsset"] = "selfieAnimationAsset";
|
|
48
|
+
ANDROID_THEME_CONFIG_KEY["selfieAnimationWidthPercent"] = "selfieAnimationWidthPercent";
|
|
49
|
+
})(ANDROID_THEME_CONFIG_KEY || (exports.ANDROID_THEME_CONFIG_KEY = ANDROID_THEME_CONFIG_KEY = {}));
|
|
50
|
+
|
|
51
|
+
let IOS_THEME_CONFIG_KEY;
|
|
52
|
+
exports.IOS_THEME_CONFIG_KEY = IOS_THEME_CONFIG_KEY;
|
|
53
|
+
|
|
54
|
+
(function (IOS_THEME_CONFIG_KEY) {
|
|
55
|
+
IOS_THEME_CONFIG_KEY["backgroundColor"] = "backgroundColor";
|
|
56
|
+
IOS_THEME_CONFIG_KEY["primaryColor"] = "primaryColor";
|
|
57
|
+
IOS_THEME_CONFIG_KEY["darkPrimaryColor"] = "darkPrimaryColor";
|
|
58
|
+
IOS_THEME_CONFIG_KEY["accentColor"] = "accentColor";
|
|
59
|
+
IOS_THEME_CONFIG_KEY["overlayBackgroundColor"] = "overlayBackgroundColor";
|
|
60
|
+
IOS_THEME_CONFIG_KEY["titleTextColor"] = "titleTextColor";
|
|
61
|
+
IOS_THEME_CONFIG_KEY["titleTextFont"] = "titleTextFont";
|
|
62
|
+
IOS_THEME_CONFIG_KEY["bodyTextColor"] = "bodyTextColor";
|
|
63
|
+
IOS_THEME_CONFIG_KEY["bodyTextFont"] = "bodyTextFont";
|
|
64
|
+
IOS_THEME_CONFIG_KEY["footnoteTextColor"] = "footnoteTextColor";
|
|
65
|
+
IOS_THEME_CONFIG_KEY["footnoteTextFont"] = "footnoteTextFont";
|
|
66
|
+
IOS_THEME_CONFIG_KEY["formLabelTextColor"] = "formLabelTextColor";
|
|
67
|
+
IOS_THEME_CONFIG_KEY["formLabelTextFont"] = "formLabelTextFont";
|
|
68
|
+
IOS_THEME_CONFIG_KEY["textFieldTextColor"] = "textFieldTextColor";
|
|
69
|
+
IOS_THEME_CONFIG_KEY["textFieldBackgroundColor"] = "textFieldBackgroundColor";
|
|
70
|
+
IOS_THEME_CONFIG_KEY["textFieldBorderColor"] = "textFieldBorderColor";
|
|
71
|
+
IOS_THEME_CONFIG_KEY["pickerTextColor"] = "pickerTextColor";
|
|
72
|
+
IOS_THEME_CONFIG_KEY["pickerTextFont"] = "pickerTextFont";
|
|
73
|
+
IOS_THEME_CONFIG_KEY["buttonBackgroundColor"] = "buttonBackgroundColor";
|
|
74
|
+
IOS_THEME_CONFIG_KEY["buttonDisabledBackgroundColor"] = "buttonDisabledBackgroundColor";
|
|
75
|
+
IOS_THEME_CONFIG_KEY["buttonTouchedBackgroundColor"] = "buttonTouchedBackgroundColor";
|
|
76
|
+
IOS_THEME_CONFIG_KEY["buttonImageTintColor"] = "buttonImageTintColor";
|
|
77
|
+
IOS_THEME_CONFIG_KEY["buttonTextColor"] = "buttonTextColor";
|
|
78
|
+
IOS_THEME_CONFIG_KEY["buttonDisabledTextColor"] = "buttonDisabledTextColor";
|
|
79
|
+
IOS_THEME_CONFIG_KEY["buttonTextAlignment"] = "buttonTextAlignment";
|
|
80
|
+
IOS_THEME_CONFIG_KEY["buttonCornerRadius"] = "buttonCornerRadius";
|
|
81
|
+
IOS_THEME_CONFIG_KEY["buttonFont"] = "buttonFont";
|
|
82
|
+
IOS_THEME_CONFIG_KEY["selectedCellBackgroundColor"] = "selectedCellBackgroundColor";
|
|
83
|
+
IOS_THEME_CONFIG_KEY["closeButtonTintColor"] = "closeButtonTintColor";
|
|
84
|
+
IOS_THEME_CONFIG_KEY["cancelButtonBackgroundColor"] = "cancelButtonBackgroundColor";
|
|
85
|
+
IOS_THEME_CONFIG_KEY["progressColor"] = "progressColor";
|
|
86
|
+
IOS_THEME_CONFIG_KEY["cameraGuideCornersColor"] = "cameraGuideCornersColor";
|
|
87
|
+
IOS_THEME_CONFIG_KEY["cameraButtonBackgroundColor"] = "cameraButtonBackgroundColor";
|
|
88
|
+
IOS_THEME_CONFIG_KEY["successAssetName"] = "successAssetName";
|
|
89
|
+
IOS_THEME_CONFIG_KEY["successAssetWidth"] = "successAssetWidth";
|
|
90
|
+
IOS_THEME_CONFIG_KEY["successAssetHeight"] = "successAssetHeight";
|
|
91
|
+
IOS_THEME_CONFIG_KEY["verificationFailAssetName"] = "verificationFailAssetName";
|
|
92
|
+
IOS_THEME_CONFIG_KEY["verificationFailAssetWidth"] = "verificationFailAssetWidth";
|
|
93
|
+
IOS_THEME_CONFIG_KEY["verificationFailAssetHeight"] = "verificationFailAssetHeight";
|
|
94
|
+
IOS_THEME_CONFIG_KEY["failAssetName"] = "failAssetName";
|
|
95
|
+
IOS_THEME_CONFIG_KEY["failAssetWidth"] = "failAssetWidth";
|
|
96
|
+
IOS_THEME_CONFIG_KEY["failAssetHeight"] = "failAssetHeight";
|
|
97
|
+
IOS_THEME_CONFIG_KEY["loadingAnimationAssetName"] = "loadingAnimationAssetName";
|
|
98
|
+
IOS_THEME_CONFIG_KEY["loadingAnimationAssetWidth"] = "loadingAnimationAssetWidth";
|
|
99
|
+
IOS_THEME_CONFIG_KEY["loadingAnimationAssetHeight"] = "loadingAnimationAssetHeight";
|
|
100
|
+
IOS_THEME_CONFIG_KEY["processingAnimationAssetName"] = "processingAnimationAssetName";
|
|
101
|
+
IOS_THEME_CONFIG_KEY["processingAnimationAssetWidth"] = "processingAnimationAssetWidth";
|
|
102
|
+
IOS_THEME_CONFIG_KEY["processingAnimationAssetHeight"] = "processingAnimationAssetHeight";
|
|
103
|
+
IOS_THEME_CONFIG_KEY["selfieAnimationAssetName"] = "selfieAnimationAssetName";
|
|
104
|
+
IOS_THEME_CONFIG_KEY["selfieAnimationAssetWidth"] = "selfieAnimationAssetWidth";
|
|
105
|
+
IOS_THEME_CONFIG_KEY["selfieAnimationAssetHeight"] = "selfieAnimationAssetHeight";
|
|
106
|
+
})(IOS_THEME_CONFIG_KEY || (exports.IOS_THEME_CONFIG_KEY = IOS_THEME_CONFIG_KEY = {}));
|
|
107
|
+
|
|
108
|
+
class Theme {
|
|
109
|
+
async print() {
|
|
110
|
+
let platform = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'android';
|
|
111
|
+
const config = await _Config.default.get();
|
|
112
|
+
const themeConfig = platform === 'android' ? config.androidTheme : config.iosTheme;
|
|
113
|
+
let usesCustomFontAndroid = false;
|
|
114
|
+
let usesCustomFontIos = false;
|
|
115
|
+
const head = platform === 'android' ? ['Style Item', 'Value', 'Note'] : ['Style Item', 'Value', 'Note'];
|
|
116
|
+
const table = new _cliTable.default({
|
|
117
|
+
head,
|
|
118
|
+
// prettier-ignore
|
|
119
|
+
chars: {
|
|
120
|
+
'mid': '',
|
|
121
|
+
'left-mid': '',
|
|
122
|
+
'mid-mid': '',
|
|
123
|
+
'right-mid': ''
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
console.log('Specified theme values:');
|
|
127
|
+
const keyEnum = platform === 'android' ? ANDROID_THEME_CONFIG_KEY : IOS_THEME_CONFIG_KEY;
|
|
128
|
+
|
|
129
|
+
for (const key in keyEnum) {
|
|
130
|
+
let override = themeConfig[key];
|
|
131
|
+
let colorOverride = key.includes('Color') || key.includes('color');
|
|
132
|
+
|
|
133
|
+
if (override) {
|
|
134
|
+
if (colorOverride) {
|
|
135
|
+
override = normalizeColor(override, key);
|
|
136
|
+
} else {
|
|
137
|
+
override = override.toString();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (key.includes('Font')) {
|
|
142
|
+
if (platform == 'android') {
|
|
143
|
+
usesCustomFontAndroid = true;
|
|
144
|
+
} else {
|
|
145
|
+
usesCustomFontIos = true;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let row;
|
|
150
|
+
row = [key, override ? valueColor(colorOverride, override) : _chalk.default.yellow('unspecified'), key.includes('Font') ? _chalk.default.cyan('Fonts that are not built-in need to be installed.') : ''];
|
|
151
|
+
table.push(row);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
console.log(table.toString());
|
|
155
|
+
|
|
156
|
+
if (usesCustomFontAndroid) {
|
|
157
|
+
console.log(_chalk.default.yellow(' NOTE') + ': A font customization was made. If the font is not built-in to the Android platform (https://github.com/react-native-training/react-native-fonts#android), then the font(s) must first be installed. A guide to install a font can be found here: https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (usesCustomFontIos) {
|
|
161
|
+
console.log(_chalk.default.yellow(' NOTE') + ': A font customization was made. If the font is not built-in iOS (https://github.com/react-native-training/react-native-ios), then the font(s) must first be installed. A guide to install a font can be found here: https://developer.apple.com/documentation/uikit/text_display_and_fonts/adding_a_custom_font_to_your_app');
|
|
162
|
+
} // Add newline for spacing
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
console.log('');
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
} // set default print color for non-color overrides
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
function valueColor(isColorOverride, override) {
|
|
172
|
+
return isColorOverride ? _chalk.default.hex(override)(override) : _chalk.default.magentaBright(override);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
function normalizeColor(colorHex, themeKey) {
|
|
176
|
+
let hex = colorHex;
|
|
177
|
+
|
|
178
|
+
if (colorHex[0] === '#') {
|
|
179
|
+
hex = colorHex.slice(1);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (!COLOR_REGEX.test(hex)) {
|
|
183
|
+
if (themeKey) {
|
|
184
|
+
console.error(`Received a color value of ${_chalk.default.yellow(colorHex)} for ${_chalk.default.red(themeKey)}.\nFormat must follow standard 6 character hexadecimal color code. Eg. ${_chalk.default.bgHex('#FFFFFF').hex('#7E66B7')('#290087')}`);
|
|
185
|
+
} else {
|
|
186
|
+
console.error(`Received a color value of ${_chalk.default.yellow(colorHex)}.\nFormat must follow standard 6 character hexadecimal color code. Eg. ${_chalk.default.bgHex('#FFFFFF').hex('#7E66B7')('#290087')}`);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
console.log('');
|
|
190
|
+
process.exit(1);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return colorHex;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
var _default = new Theme();
|
|
197
|
+
|
|
198
|
+
exports.default = _default;
|
|
199
|
+
//# sourceMappingURL=Theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["Theme.ts"],"names":["COLOR_REGEX","ANDROID_THEME_CONFIG_KEY","IOS_THEME_CONFIG_KEY","Theme","print","platform","config","Config","get","themeConfig","androidTheme","iosTheme","usesCustomFontAndroid","usesCustomFontIos","head","table","Table","chars","console","log","keyEnum","key","override","colorOverride","includes","normalizeColor","toString","row","valueColor","chalk","yellow","cyan","push","isColorOverride","hex","magentaBright","colorHex","themeKey","slice","test","error","red","bgHex","process","exit"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;AAEA,MAAMA,WAAW,GAAG,kBAApB;IAEYC,wB;;;WAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;AAAAA,EAAAA,wB;GAAAA,wB,wCAAAA,wB;;IAyCAC,oB;;;WAAAA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;AAAAA,EAAAA,oB;AAAAA,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E,EAExER,GAFwE,CAEpE,SAFoE,EAEzD,SAFyD,CAE9C,EAL/B;AAOD;;AACDhB,IAAAA,OAAO,CAACC,GAAR,CAAY,EAAZ;AACAwB,IAAAA,OAAO,CAACC,IAAR,CAAa,CAAb;AACD;;AAED,SAAOR,QAAP;AACD;;eAEc,IAAIjC,KAAJ,E","sourcesContent":["import Table from 'cli-table';\nimport chalk from 'chalk';\n\nimport Config from './Config';\n\nconst COLOR_REGEX = /^[a-zA-Z0-9]{6}$/;\n\nexport enum ANDROID_THEME_CONFIG_KEY {\n backgroundColor = 'backgroundColor',\n primaryColor = 'primaryColor',\n darkPrimaryColor = 'darkPrimaryColor',\n accentColor = 'accentColor',\n\n titleTextColor = 'titleTextColor',\n titleTextFont = 'titleTextFont',\n\n bodyTextColor = 'bodyTextColor',\n bodyTextFont = 'bodyTextFont',\n\n footnoteTextColor = 'footnoteTextColor',\n footnoteTextFont = 'footnoteTextFont',\n\n // formLabelTextColor = \"formLabelTextColor\",\n // formLabelTextFont = \"formLabelTextFont\",\n\n textFieldTextColor = 'textFieldTextColor',\n textFieldTextFont = 'textFieldTextFont',\n\n pickerTextColor = 'pickerTextColor',\n pickerTextFont = 'pickerTextFont',\n\n buttonBackgroundColor = 'buttonBackgroundColor',\n buttonDisabledBackgroundColor = 'buttonDisabledBackgroundColor',\n buttonTouchedBackgroundColor = 'buttonTouchedBackgroundColor',\n buttonTextColor = 'buttonTextColor',\n buttonDisabledTextColor = 'buttonDisabledTextColor',\n // buttonTextAlignment = \"buttonTextAlignment\",\n buttonCornerRadius = 'buttonCornerRadius',\n buttonFont = 'buttonFont',\n progressColor = 'progressColor',\n successAsset = 'successAsset',\n failAsset = 'failAsset',\n loadingAnimationAsset = 'loadingAnimationAsset',\n loadingAnimationWidthPercent = 'loadingAnimationWidthPercent',\n selfieAnimationAsset = 'selfieAnimationAsset',\n selfieAnimationWidthPercent = 'selfieAnimationWidthPercent',\n}\n\nexport enum IOS_THEME_CONFIG_KEY {\n backgroundColor = 'backgroundColor',\n primaryColor = 'primaryColor',\n darkPrimaryColor = 'darkPrimaryColor',\n accentColor = 'accentColor',\n overlayBackgroundColor = 'overlayBackgroundColor',\n titleTextColor = 'titleTextColor',\n titleTextFont = 'titleTextFont',\n bodyTextColor = 'bodyTextColor',\n bodyTextFont = 'bodyTextFont',\n footnoteTextColor = 'footnoteTextColor',\n footnoteTextFont = 'footnoteTextFont',\n formLabelTextColor = 'formLabelTextColor',\n formLabelTextFont = 'formLabelTextFont',\n textFieldTextColor = 'textFieldTextColor',\n textFieldBackgroundColor = 'textFieldBackgroundColor',\n textFieldBorderColor = 'textFieldBorderColor',\n pickerTextColor = 'pickerTextColor',\n pickerTextFont = 'pickerTextFont',\n buttonBackgroundColor = 'buttonBackgroundColor',\n buttonDisabledBackgroundColor = 'buttonDisabledBackgroundColor',\n buttonTouchedBackgroundColor = 'buttonTouchedBackgroundColor',\n buttonImageTintColor = 'buttonImageTintColor',\n buttonTextColor = 'buttonTextColor',\n buttonDisabledTextColor = 'buttonDisabledTextColor',\n buttonTextAlignment = 'buttonTextAlignment',\n buttonCornerRadius = 'buttonCornerRadius',\n buttonFont = 'buttonFont',\n selectedCellBackgroundColor = 'selectedCellBackgroundColor',\n closeButtonTintColor = 'closeButtonTintColor',\n cancelButtonBackgroundColor = 'cancelButtonBackgroundColor',\n progressColor = 'progressColor',\n cameraGuideCornersColor = 'cameraGuideCornersColor',\n cameraButtonBackgroundColor = 'cameraButtonBackgroundColor',\n successAssetName = 'successAssetName',\n successAssetWidth = 'successAssetWidth',\n successAssetHeight = 'successAssetHeight',\n verificationFailAssetName = 'verificationFailAssetName',\n verificationFailAssetWidth = 'verificationFailAssetWidth',\n verificationFailAssetHeight = 'verificationFailAssetHeight',\n failAssetName = 'failAssetName',\n failAssetWidth = 'failAssetWidth',\n failAssetHeight = 'failAssetHeight',\n loadingAnimationAssetName = 'loadingAnimationAssetName',\n loadingAnimationAssetWidth = 'loadingAnimationAssetWidth',\n loadingAnimationAssetHeight = 'loadingAnimationAssetHeight',\n processingAnimationAssetName = 'processingAnimationAssetName',\n processingAnimationAssetWidth = 'processingAnimationAssetWidth',\n processingAnimationAssetHeight = 'processingAnimationAssetHeight',\n selfieAnimationAssetName = 'selfieAnimationAssetName',\n selfieAnimationAssetWidth = 'selfieAnimationAssetWidth',\n selfieAnimationAssetHeight = 'selfieAnimationAssetHeight',\n}\n\nexport type AndroidThemeObject = {\n [key in ANDROID_THEME_CONFIG_KEY]: string | null | undefined;\n};\n\nexport type IosThemeObject = {\n [key in IOS_THEME_CONFIG_KEY]: string | null | undefined;\n};\n\nexport type ThemeObject = AndroidThemeObject | IosThemeObject;\n\nclass Theme {\n async print(platform: string = 'android') {\n const config = await Config.get();\n const themeConfig =\n platform === 'android' ? config.androidTheme : config.iosTheme;\n let usesCustomFontAndroid = false;\n let usesCustomFontIos = false;\n\n const head =\n platform === 'android'\n ? ['Style Item', 'Value', 'Note']\n : ['Style Item', 'Value', 'Note'];\n\n const table = new Table({\n head,\n // prettier-ignore\n chars: { 'mid': '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' },\n });\n\n console.log('Specified theme values:');\n const keyEnum =\n platform === 'android' ? ANDROID_THEME_CONFIG_KEY : IOS_THEME_CONFIG_KEY;\n for (const key in keyEnum) {\n let override =\n themeConfig[key as ANDROID_THEME_CONFIG_KEY | IOS_THEME_CONFIG_KEY];\n let colorOverride = key.includes('Color') || key.includes('color');\n\n if (override) {\n if (colorOverride) {\n override = normalizeColor(override, key);\n } else {\n override = override.toString();\n }\n }\n\n if (key.includes('Font')) {\n if (platform == 'android') {\n usesCustomFontAndroid = true;\n } else {\n usesCustomFontIos = true;\n }\n }\n\n let row;\n\n row = [\n key,\n override\n ? valueColor(colorOverride, override)\n : chalk.yellow('unspecified'),\n key.includes('Font')\n ? chalk.cyan('Fonts that are not built-in need to be installed.')\n : '',\n ];\n\n table.push(row);\n }\n\n console.log(table.toString());\n\n if (usesCustomFontAndroid) {\n console.log(\n chalk.yellow(' NOTE') +\n ': A font customization was made. If the font is not built-in to the Android platform (https://github.com/react-native-training/react-native-fonts#android), then the font(s) must first be installed. A guide to install a font can be found here: https://developer.android.com/guide/topics/ui/look-and-feel/fonts-in-xml'\n );\n }\n\n if (usesCustomFontIos) {\n console.log(\n chalk.yellow(' NOTE') +\n ': A font customization was made. If the font is not built-in iOS (https://github.com/react-native-training/react-native-ios), then the font(s) must first be installed. A guide to install a font can be found here: https://developer.apple.com/documentation/uikit/text_display_and_fonts/adding_a_custom_font_to_your_app'\n );\n }\n\n // Add newline for spacing\n console.log('');\n }\n}\n\n// set default print color for non-color overrides\nfunction valueColor(isColorOverride: boolean, override: string) {\n return isColorOverride\n ? chalk.hex(override)(override)\n : chalk.magentaBright(override);\n}\n\nfunction normalizeColor(colorHex: string, themeKey: string) {\n let hex = colorHex;\n if (colorHex[0] === '#') {\n hex = colorHex.slice(1);\n }\n\n if (!COLOR_REGEX.test(hex)) {\n if (themeKey) {\n console.error(\n `Received a color value of ${chalk.yellow(colorHex)} for ${chalk.red(\n themeKey\n )}.\\nFormat must follow standard 6 character hexadecimal color code. Eg. ${chalk\n .bgHex('#FFFFFF')\n .hex('#7E66B7')('#290087')}`\n );\n } else {\n console.error(\n `Received a color value of ${chalk.yellow(\n colorHex\n )}.\\nFormat must follow standard 6 character hexadecimal color code. Eg. ${chalk\n .bgHex('#FFFFFF')\n .hex('#7E66B7')('#290087')}`\n );\n }\n console.log('');\n process.exit(1);\n }\n\n return colorHex;\n}\n\nexport default new Theme();\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _Config = _interopRequireDefault(require("./Config"));
|
|
4
|
+
|
|
5
|
+
var _prompts = require("./prompts");
|
|
6
|
+
|
|
7
|
+
var _AndroidThemeGenerator = _interopRequireDefault(require("./tools/AndroidThemeGenerator"));
|
|
8
|
+
|
|
9
|
+
var _IosThemeInstructions = _interopRequireDefault(require("./tools/IosThemeInstructions"));
|
|
10
|
+
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
|
|
13
|
+
console.log('');
|
|
14
|
+
console.log('============================================');
|
|
15
|
+
console.log('Persona React Native SDK customization tool.');
|
|
16
|
+
console.log('============================================');
|
|
17
|
+
console.log('');
|
|
18
|
+
|
|
19
|
+
const run = async () => {
|
|
20
|
+
// Run this once to print warning messages if it's not configured.
|
|
21
|
+
await _Config.default.get();
|
|
22
|
+
const {
|
|
23
|
+
choice
|
|
24
|
+
} = await (0, _prompts.whatWouldYouLikePrompt)();
|
|
25
|
+
|
|
26
|
+
switch (choice) {
|
|
27
|
+
case _prompts.TOOL_CHOICE.AndroidTheme:
|
|
28
|
+
await _AndroidThemeGenerator.default.run();
|
|
29
|
+
break;
|
|
30
|
+
|
|
31
|
+
case _prompts.TOOL_CHOICE.iosTheme:
|
|
32
|
+
await _IosThemeInstructions.default.run();
|
|
33
|
+
break;
|
|
34
|
+
|
|
35
|
+
default:
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
run();
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["console","log","run","Config","get","choice","TOOL_CHOICE","AndroidTheme","AndroidThemeGenerator","iosTheme","IosThemeInstructions"],"mappings":";;AAAA;;AACA;;AACA;;AACA;;;;AAEAA,OAAO,CAACC,GAAR,CAAY,EAAZ;AACAD,OAAO,CAACC,GAAR,CAAY,8CAAZ;AACAD,OAAO,CAACC,GAAR,CAAY,8CAAZ;AACAD,OAAO,CAACC,GAAR,CAAY,8CAAZ;AACAD,OAAO,CAACC,GAAR,CAAY,EAAZ;;AAEA,MAAMC,GAAG,GAAG,YAAY;AACtB;AACA,QAAMC,gBAAOC,GAAP,EAAN;AAEA,QAAM;AAAEC,IAAAA;AAAF,MAAa,MAAM,sCAAzB;;AAEA,UAAQA,MAAR;AACE,SAAKC,qBAAYC,YAAjB;AACE,YAAMC,+BAAsBN,GAAtB,EAAN;AACA;;AACF,SAAKI,qBAAYG,QAAjB;AACE,YAAMC,8BAAqBR,GAArB,EAAN;AACA;;AACF;AACE;AARJ;AAUD,CAhBD;;AAkBAA,GAAG","sourcesContent":["import Config from './Config';\nimport { TOOL_CHOICE, whatWouldYouLikePrompt } from './prompts';\nimport AndroidThemeGenerator from './tools/AndroidThemeGenerator';\nimport IosThemeInstructions from './tools/IosThemeInstructions';\n\nconsole.log('');\nconsole.log('============================================');\nconsole.log('Persona React Native SDK customization tool.');\nconsole.log('============================================');\nconsole.log('');\n\nconst run = async () => {\n // Run this once to print warning messages if it's not configured.\n await Config.get();\n\n const { choice } = await whatWouldYouLikePrompt();\n\n switch (choice) {\n case TOOL_CHOICE.AndroidTheme:\n await AndroidThemeGenerator.run();\n break;\n case TOOL_CHOICE.iosTheme:\n await IosThemeInstructions.run();\n break;\n default:\n return;\n }\n};\n\nrun();\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.TOOL_CHOICE = void 0;
|
|
7
|
+
exports.confirmResourceFiles = confirmResourceFiles;
|
|
8
|
+
exports.confirmThemeValues = confirmThemeValues;
|
|
9
|
+
exports.whatWouldYouLikePrompt = whatWouldYouLikePrompt;
|
|
10
|
+
|
|
11
|
+
var _inquirer = _interopRequireDefault(require("inquirer"));
|
|
12
|
+
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
|
|
15
|
+
const TOOL_CHOICE = {
|
|
16
|
+
AndroidTheme: 'Update Android theme',
|
|
17
|
+
iosTheme: 'Update iOS theme'
|
|
18
|
+
};
|
|
19
|
+
exports.TOOL_CHOICE = TOOL_CHOICE;
|
|
20
|
+
|
|
21
|
+
async function whatWouldYouLikePrompt() {
|
|
22
|
+
const questions = {
|
|
23
|
+
name: 'choice',
|
|
24
|
+
type: 'list',
|
|
25
|
+
choices: [TOOL_CHOICE.AndroidTheme, TOOL_CHOICE.iosTheme],
|
|
26
|
+
message: 'What would you like to do?'
|
|
27
|
+
};
|
|
28
|
+
return _inquirer.default.prompt(questions);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async function confirmThemeValues() {
|
|
32
|
+
const questions = {
|
|
33
|
+
name: 'isConfirmed',
|
|
34
|
+
type: 'confirm',
|
|
35
|
+
message: 'Do these values look right?'
|
|
36
|
+
};
|
|
37
|
+
return _inquirer.default.prompt(questions);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function confirmResourceFiles() {
|
|
41
|
+
const questions = {
|
|
42
|
+
name: 'isConfirmed',
|
|
43
|
+
type: 'confirm',
|
|
44
|
+
message: `Continue?`
|
|
45
|
+
};
|
|
46
|
+
return _inquirer.default.prompt(questions);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["prompts.ts"],"names":["TOOL_CHOICE","AndroidTheme","iosTheme","whatWouldYouLikePrompt","questions","name","type","choices","message","inquirer","prompt","confirmThemeValues","confirmResourceFiles"],"mappings":";;;;;;;;;;AAAA;;;;AAEO,MAAMA,WAAW,GAAG;AACzBC,EAAAA,YAAY,EAAE,sBADW;AAEzBC,EAAAA,QAAQ,EAAE;AAFe,CAApB;;;AAIA,eAAeC,sBAAf,GAAwC;AAC7C,QAAMC,SAAS,GAAG;AAChBC,IAAAA,IAAI,EAAE,QADU;AAEhBC,IAAAA,IAAI,EAAE,MAFU;AAGhBC,IAAAA,OAAO,EAAE,CAACP,WAAW,CAACC,YAAb,EAA2BD,WAAW,CAACE,QAAvC,CAHO;AAIhBM,IAAAA,OAAO,EAAE;AAJO,GAAlB;AAOA,SAAOC,kBAASC,MAAT,CAAgBN,SAAhB,CAAP;AACD;;AAEM,eAAeO,kBAAf,GAAoC;AACzC,QAAMP,SAAS,GAAG;AAChBC,IAAAA,IAAI,EAAE,aADU;AAEhBC,IAAAA,IAAI,EAAE,SAFU;AAGhBE,IAAAA,OAAO,EAAE;AAHO,GAAlB;AAMA,SAAOC,kBAASC,MAAT,CAAgBN,SAAhB,CAAP;AACD;;AAEM,eAAeQ,oBAAf,GAAsC;AAC3C,QAAMR,SAAS,GAAG;AAChBC,IAAAA,IAAI,EAAE,aADU;AAEhBC,IAAAA,IAAI,EAAE,SAFU;AAGhBE,IAAAA,OAAO,EAAG;AAHM,GAAlB;AAMA,SAAOC,kBAASC,MAAT,CAAgBN,SAAhB,CAAP;AACD","sourcesContent":["import inquirer, { QuestionCollection } from 'inquirer';\n\nexport const TOOL_CHOICE = {\n AndroidTheme: 'Update Android theme',\n iosTheme: 'Update iOS theme',\n};\nexport async function whatWouldYouLikePrompt() {\n const questions = {\n name: 'choice',\n type: 'list',\n choices: [TOOL_CHOICE.AndroidTheme, TOOL_CHOICE.iosTheme],\n message: 'What would you like to do?',\n } as QuestionCollection;\n\n return inquirer.prompt(questions);\n}\n\nexport async function confirmThemeValues() {\n const questions = {\n name: 'isConfirmed',\n type: 'confirm',\n message: 'Do these values look right?',\n } as QuestionCollection;\n\n return inquirer.prompt(questions);\n}\n\nexport async function confirmResourceFiles() {\n const questions = {\n name: 'isConfirmed',\n type: 'confirm',\n message: `Continue?`,\n } as QuestionCollection;\n\n return inquirer.prompt(questions);\n}\n"]}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
+
|
|
10
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
|
+
|
|
12
|
+
var _path = _interopRequireDefault(require("path"));
|
|
13
|
+
|
|
14
|
+
var _Theme = _interopRequireDefault(require("../Theme"));
|
|
15
|
+
|
|
16
|
+
var _prompts = require("../prompts");
|
|
17
|
+
|
|
18
|
+
var _AndroidResourcePrinter = _interopRequireDefault(require("../AndroidResourcePrinter"));
|
|
19
|
+
|
|
20
|
+
var _Config = _interopRequireDefault(require("../Config"));
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
+
|
|
24
|
+
const ANDROID_STYLES_RESOURCE_PATH = './android/app/src/main/res/values/styles_persona.xml';
|
|
25
|
+
const ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH = './android/app/src/main/res/drawable/rn_persona_button.xml';
|
|
26
|
+
const ANDROID_BUTTON_COLOR_RESOURCE_PATH = './android/app/src/main/res/color/rn_persona_button.xml';
|
|
27
|
+
|
|
28
|
+
class ThemeGenerator {
|
|
29
|
+
async run() {
|
|
30
|
+
await _Theme.default.print();
|
|
31
|
+
const {
|
|
32
|
+
isConfirmed: themeValuesConfirmed
|
|
33
|
+
} = await (0, _prompts.confirmThemeValues)();
|
|
34
|
+
|
|
35
|
+
if (!themeValuesConfirmed) {
|
|
36
|
+
console.log(_chalk.default.yellow('\nPlease adjust the values in package.json.\n'));
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
console.log(`\n${_chalk.default.yellow('Creating an Android Resource files for your project at:')}\n
|
|
41
|
+
- ${ANDROID_STYLES_RESOURCE_PATH}
|
|
42
|
+
- ${ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH}
|
|
43
|
+
- ${ANDROID_BUTTON_COLOR_RESOURCE_PATH}\n`);
|
|
44
|
+
console.log('Building your application with this resource file themes your Persona Inquiry flow.\n');
|
|
45
|
+
const config = await _Config.default.get();
|
|
46
|
+
const theme = config.androidTheme;
|
|
47
|
+
const {
|
|
48
|
+
style,
|
|
49
|
+
buttonDrawable,
|
|
50
|
+
buttonColor
|
|
51
|
+
} = new _AndroidResourcePrinter.default(theme).process();
|
|
52
|
+
let {
|
|
53
|
+
isConfirmed: confirmed
|
|
54
|
+
} = await (0, _prompts.confirmResourceFiles)();
|
|
55
|
+
|
|
56
|
+
if (!confirmed) {
|
|
57
|
+
process.exit(1);
|
|
58
|
+
} // Add a line after confirmation
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
console.log('');
|
|
62
|
+
|
|
63
|
+
_fs.default.mkdirSync(_path.default.dirname(ANDROID_STYLES_RESOURCE_PATH), {
|
|
64
|
+
recursive: true
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
_fs.default.writeFileSync(ANDROID_STYLES_RESOURCE_PATH, style.end({
|
|
68
|
+
prettyPrint: true
|
|
69
|
+
}));
|
|
70
|
+
|
|
71
|
+
console.log(`${_chalk.default.green('Saved an Android style file at path:')} ${ANDROID_STYLES_RESOURCE_PATH}.`);
|
|
72
|
+
|
|
73
|
+
_fs.default.mkdirSync(_path.default.dirname(ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH), {
|
|
74
|
+
recursive: true
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
_fs.default.writeFileSync(ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH, buttonDrawable.end({
|
|
78
|
+
prettyPrint: true
|
|
79
|
+
}));
|
|
80
|
+
|
|
81
|
+
console.log(`${_chalk.default.green('Saved an Android drawable file at path:')} ${ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH}.`);
|
|
82
|
+
|
|
83
|
+
_fs.default.mkdirSync(_path.default.dirname(ANDROID_BUTTON_COLOR_RESOURCE_PATH), {
|
|
84
|
+
recursive: true
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
_fs.default.writeFileSync(ANDROID_BUTTON_COLOR_RESOURCE_PATH, buttonColor.end({
|
|
88
|
+
prettyPrint: true
|
|
89
|
+
}));
|
|
90
|
+
|
|
91
|
+
console.log(`${_chalk.default.green('Saved an Android color file at path:')} ${ANDROID_BUTTON_COLOR_RESOURCE_PATH}.`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var _default = new ThemeGenerator();
|
|
97
|
+
|
|
98
|
+
exports.default = _default;
|
|
99
|
+
//# sourceMappingURL=AndroidThemeGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["AndroidThemeGenerator.ts"],"names":["ANDROID_STYLES_RESOURCE_PATH","ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH","ANDROID_BUTTON_COLOR_RESOURCE_PATH","ThemeGenerator","run","Theme","print","isConfirmed","themeValuesConfirmed","console","log","chalk","yellow","config","Configuration","get","theme","androidTheme","style","buttonDrawable","buttonColor","AndroidResourcePrinter","process","confirmed","exit","fs","mkdirSync","path","dirname","recursive","writeFileSync","end","prettyPrint","green"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;AAEA,MAAMA,4BAA4B,GAChC,sDADF;AAEA,MAAMC,qCAAqC,GACzC,2DADF;AAEA,MAAMC,kCAAkC,GACtC,wDADF;;AAGA,MAAMC,cAAN,CAAqB;AACV,QAAHC,GAAG,GAAG;AACV,UAAMC,eAAMC,KAAN,EAAN;AAEA,UAAM;AAAEC,MAAAA,WAAW,EAAEC;AAAf,QAAwC,MAAM,kCAApD;;AAEA,QAAI,CAACA,oBAAL,EAA2B;AACzBC,MAAAA,OAAO,CAACC,GAAR,CACEC,eAAMC,MAAN,CAAa,+CAAb,CADF;AAGA;AACD;;AAEDH,IAAAA,OAAO,CAACC,GAAR,CACG,KAAIC,eAAMC,MAAN,CACH,yDADG,CAEH;AACR,UAAUZ,4BAA6B;AACvC,UAAUC,qCAAsC;AAChD,UAAUC,kCAAmC,IANzC;AAQAO,IAAAA,OAAO,CAACC,GAAR,CACE,uFADF;AAIA,UAAMG,MAAM,GAAG,MAAMC,gBAAcC,GAAd,EAArB;AACA,UAAMC,KAAK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AAA,WAAW,EAAE;AAAf,KAAhB,CAFF;;AAIAvB,IAAAA,OAAO,CAACC,GAAR,CACG,GAAEC,eAAMsB,KAAN,CACD,sCADC,CAED,IAAG/B,kCAAmC,GAH1C;AAKD;;AAhFkB;;eAmFN,IAAIC,cAAJ,E","sourcesContent":["import fs from 'fs';\nimport chalk from 'chalk';\nimport path from 'path';\n\nimport Theme, { AndroidThemeObject } from '../Theme';\nimport { confirmThemeValues, confirmResourceFiles } from '../prompts';\nimport AndroidResourcePrinter from '../AndroidResourcePrinter';\nimport Configuration from '../Config';\n\nconst ANDROID_STYLES_RESOURCE_PATH =\n './android/app/src/main/res/values/styles_persona.xml';\nconst ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH =\n './android/app/src/main/res/drawable/rn_persona_button.xml';\nconst ANDROID_BUTTON_COLOR_RESOURCE_PATH =\n './android/app/src/main/res/color/rn_persona_button.xml';\n\nclass ThemeGenerator {\n async run() {\n await Theme.print();\n\n const { isConfirmed: themeValuesConfirmed } = await confirmThemeValues();\n\n if (!themeValuesConfirmed) {\n console.log(\n chalk.yellow('\\nPlease adjust the values in package.json.\\n')\n );\n return;\n }\n\n console.log(\n `\\n${chalk.yellow(\n 'Creating an Android Resource files for your project at:'\n )}\\n\n - ${ANDROID_STYLES_RESOURCE_PATH}\n - ${ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH}\n - ${ANDROID_BUTTON_COLOR_RESOURCE_PATH}\\n`\n );\n console.log(\n 'Building your application with this resource file themes your Persona Inquiry flow.\\n'\n );\n\n const config = await Configuration.get();\n const theme = config.androidTheme as AndroidThemeObject;\n\n const { style, buttonDrawable, buttonColor } = new AndroidResourcePrinter(\n theme\n ).process();\n\n let { isConfirmed: confirmed } = await confirmResourceFiles();\n\n if (!confirmed) {\n process.exit(1);\n }\n\n // Add a line after confirmation\n console.log('');\n\n fs.mkdirSync(path.dirname(ANDROID_STYLES_RESOURCE_PATH), {\n recursive: true,\n });\n fs.writeFileSync(\n ANDROID_STYLES_RESOURCE_PATH,\n style.end({ prettyPrint: true })\n );\n\n console.log(\n `${chalk.green(\n 'Saved an Android style file at path:'\n )} ${ANDROID_STYLES_RESOURCE_PATH}.`\n );\n\n fs.mkdirSync(path.dirname(ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH), {\n recursive: true,\n });\n fs.writeFileSync(\n ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH,\n buttonDrawable.end({ prettyPrint: true })\n );\n console.log(\n `${chalk.green(\n 'Saved an Android drawable file at path:'\n )} ${ANDROID_BUTTON_DRAWABLE_RESOURCE_PATH}.`\n );\n\n fs.mkdirSync(path.dirname(ANDROID_BUTTON_COLOR_RESOURCE_PATH), {\n recursive: true,\n });\n fs.writeFileSync(\n ANDROID_BUTTON_COLOR_RESOURCE_PATH,\n buttonColor.end({ prettyPrint: true })\n );\n console.log(\n `${chalk.green(\n 'Saved an Android color file at path:'\n )} ${ANDROID_BUTTON_COLOR_RESOURCE_PATH}.`\n );\n }\n}\n\nexport default new ThemeGenerator();\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _Theme = _interopRequireDefault(require("../Theme"));
|
|
9
|
+
|
|
10
|
+
var _prompts = require("../prompts");
|
|
11
|
+
|
|
12
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
class IosThemeInstructions {
|
|
17
|
+
async run() {
|
|
18
|
+
await _Theme.default.print('ios');
|
|
19
|
+
const {
|
|
20
|
+
isConfirmed: themeValuesConfirmed
|
|
21
|
+
} = await (0, _prompts.confirmThemeValues)();
|
|
22
|
+
|
|
23
|
+
if (!themeValuesConfirmed) {
|
|
24
|
+
console.log(_chalk.default.yellow('\nPlease adjust the values in package.json.\n'));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
console.log(`\n${_chalk.default.yellow('To theme the Persona Inquiry flow for iOS:')}`);
|
|
29
|
+
console.log('Add the theme values to the Persona Inquiry SDK client by using the `.iosTheme` builder function');
|
|
30
|
+
console.log(`
|
|
31
|
+
${_chalk.default.green(`+ import { persona } from '../package.json'`)}
|
|
32
|
+
...
|
|
33
|
+
Inquiry.fromTemplate(selectedTemplateId)
|
|
34
|
+
.onSuccess(handleSuccess)
|
|
35
|
+
.onCanceled(handleCanceled)
|
|
36
|
+
.onFailed(handleFailed)
|
|
37
|
+
.onError(handleError)
|
|
38
|
+
${_chalk.default.green('+ .iosTheme(persona.iosTheme)')}
|
|
39
|
+
.build()
|
|
40
|
+
.start();
|
|
41
|
+
...
|
|
42
|
+
`);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var _default = new IosThemeInstructions();
|
|
48
|
+
|
|
49
|
+
exports.default = _default;
|
|
50
|
+
//# sourceMappingURL=IosThemeInstructions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["IosThemeInstructions.ts"],"names":["IosThemeInstructions","run","Theme","print","isConfirmed","themeValuesConfirmed","console","log","chalk","yellow","green"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAEA,MAAMA,oBAAN,CAA2B;AAChB,QAAHC,GAAG,GAAG;AACV,UAAMC,eAAMC,KAAN,CAAY,KAAZ,CAAN;AAEA,UAAM;AAAEC,MAAAA,WAAW,EAAEC;AAAf,QAAwC,MAAM,kCAApD;;AAEA,QAAI,CAACA,oBAAL,EAA2B;AACzBC,MAAAA,OAAO,CAACC,GAAR,CACEC,eAAMC,MAAN,CAAa,+CAAb,CADF;AAGA;AACD;;AAEDH,IAAAA,OAAO,CAACC,GAAR,CACG,KAAIC,eAAMC,MAAN,CAAa,4CAAb,CAA2D,EADlE;AAGAH,IAAAA,OAAO,CAACC,GAAR,CACE,kGADF;AAIAD,IAAAA,OAAO,CAACC,GAAR,CAAa;AACjB,MAAMC,eAAME,KAAN,CAAa,6CAAb,CAA2D;AACjE;AACA;AACA;AACA;AACA;AACA;AACA,MAAMF,eAAME,KAAN,CAAY,iCAAZ,CAA+C;AACrD;AACA;AACA;AACA,KAZI;AAaD;;AAjCwB;;eAoCZ,IAAIV,oBAAJ,E","sourcesContent":["import Theme from '../Theme';\nimport { confirmThemeValues } from '../prompts';\nimport chalk from 'chalk';\n\nclass IosThemeInstructions {\n async run() {\n await Theme.print('ios');\n\n const { isConfirmed: themeValuesConfirmed } = await confirmThemeValues();\n\n if (!themeValuesConfirmed) {\n console.log(\n chalk.yellow('\\nPlease adjust the values in package.json.\\n')\n );\n return;\n }\n\n console.log(\n `\\n${chalk.yellow('To theme the Persona Inquiry flow for iOS:')}`\n );\n console.log(\n 'Add the theme values to the Persona Inquiry SDK client by using the `.iosTheme` builder function'\n );\n\n console.log(`\n ${chalk.green(`+ import { persona } from '../package.json'`)}\n ...\n Inquiry.fromTemplate(selectedTemplateId)\n .onSuccess(handleSuccess)\n .onCanceled(handleCanceled)\n .onFailed(handleFailed)\n .onError(handleError)\n ${chalk.green('+ .iosTheme(persona.iosTheme)')}\n .build()\n .start();\n ...\n `);\n }\n}\n\nexport default new IosThemeInstructions();\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Versions = void 0;
|
|
7
|
+
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
PersonaInquiry2
|
|
12
|
+
} = _reactNative.NativeModules;
|
|
13
|
+
|
|
14
|
+
class Versions {
|
|
15
|
+
/**
|
|
16
|
+
* @return version of the underlying Android/iOS Inquiry SDK
|
|
17
|
+
*/
|
|
18
|
+
static nativeSdkVersion() {
|
|
19
|
+
return PersonaInquiry2.getConstants().INQUIRY_SDK_VERSION;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
exports.Versions = Versions;
|
|
25
|
+
//# sourceMappingURL=versions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["versions.ts"],"names":["PersonaInquiry2","NativeModules","Versions","nativeSdkVersion","getConstants","INQUIRY_SDK_VERSION"],"mappings":";;;;;;;AAAA;;AAEA,MAAM;AAAEA,EAAAA;AAAF,IAAsBC,0BAA5B;;AAEO,MAAMC,QAAN,CAAe;AACpB;AACF;AACA;AACyB,SAAhBC,gBAAgB,GAAW;AAChC,WAAOH,eAAe,CAACI,YAAhB,GAA+BC,mBAAtC;AACD;;AANmB","sourcesContent":["import { NativeModules } from 'react-native';\n\nconst { PersonaInquiry2 } = NativeModules;\n\nexport class Versions {\n /**\n * @return version of the underlying Android/iOS Inquiry SDK\n */\n static nativeSdkVersion(): String {\n return PersonaInquiry2.getConstants().INQUIRY_SDK_VERSION;\n }\n}\n"]}
|
package/lib/module/index.js
CHANGED
|
@@ -4,6 +4,8 @@ import { NativeEventEmitter, NativeModules } from 'react-native';
|
|
|
4
4
|
import { processThemeValues } from './util';
|
|
5
5
|
import { Fields, InquiryField } from './fields';
|
|
6
6
|
export { Fields };
|
|
7
|
+
import { Versions } from './versions';
|
|
8
|
+
export { Versions };
|
|
7
9
|
const {
|
|
8
10
|
PersonaInquiry2
|
|
9
11
|
} = NativeModules; // Using Opaque types + Smart Constructor enforces validation at
|
|
@@ -133,6 +135,55 @@ export class Inquiry {
|
|
|
133
135
|
if (this.onCanceledListener) this.onCanceledListener.remove();
|
|
134
136
|
if (this.onErrorListener) this.onErrorListener.remove();
|
|
135
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Create an Inquiry flow builder based on a template ID.
|
|
140
|
+
*
|
|
141
|
+
* You can find your template ID on the Dashboard under Inquiries > Templates.
|
|
142
|
+
* {@link https://app.withpersona.com/dashboard/inquiry-templates}
|
|
143
|
+
*
|
|
144
|
+
* @param templateId template ID from your Persona Dashboard
|
|
145
|
+
* @return builder for the Inquiry flow
|
|
146
|
+
*/
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
static fromTemplate(templateId) {
|
|
150
|
+
return new TemplateBuilder(makeTemplateId(templateId), null);
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Create an Inquiry flow builder based on a template ID version.
|
|
154
|
+
*
|
|
155
|
+
* You can find your template ID version on the Dashboard under the
|
|
156
|
+
* settings view of a specific template.
|
|
157
|
+
* {@link https://app.withpersona.com/dashboard/inquiry-templates}
|
|
158
|
+
*
|
|
159
|
+
* @param templateVersion template version from your Persona Dashboard
|
|
160
|
+
* @return builder for the Inquiry flow
|
|
161
|
+
*/
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
static fromTemplateVersion(templateVersion) {
|
|
165
|
+
return new TemplateBuilder(null, makeTemplateVersion(templateVersion));
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Create an Inquiry flow builder based on an inquiry ID.
|
|
169
|
+
*
|
|
170
|
+
* You will need to generate the inquiry ID on the server. To try it out, you can create an
|
|
171
|
+
* inquiry from the Persona Dashboard under "Inquiries". Click on the "Create Inquiry" button
|
|
172
|
+
* and copy the inquiry ID from the URL.
|
|
173
|
+
* {@link https://app.withpersona.com/dashboard/inquiries}
|
|
174
|
+
*
|
|
175
|
+
* @param inquiryId inquiry ID from your server
|
|
176
|
+
* @return builder for the Inquiry flow
|
|
177
|
+
*/
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
static fromInquiry(inquiryId) {
|
|
181
|
+
return new InquiryBuilder(makeInquiryId(inquiryId));
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Launch the Persona Inquiry.
|
|
185
|
+
*/
|
|
186
|
+
|
|
136
187
|
|
|
137
188
|
start() {
|
|
138
189
|
this.onCompleteListener = eventEmitter.addListener('onComplete', event => {
|
|
@@ -353,24 +404,28 @@ class TemplateBuilder {
|
|
|
353
404
|
}
|
|
354
405
|
|
|
355
406
|
}
|
|
407
|
+
/**
|
|
408
|
+
* @deprecated Use the `Inquiry` static methods instead
|
|
409
|
+
*/
|
|
410
|
+
|
|
356
411
|
|
|
357
412
|
let InquiryBuilders;
|
|
358
413
|
|
|
359
414
|
(function (_InquiryBuilders) {
|
|
360
415
|
function fromInquiry(inquiryId) {
|
|
361
|
-
return
|
|
416
|
+
return Inquiry.fromInquiry(inquiryId);
|
|
362
417
|
}
|
|
363
418
|
|
|
364
419
|
_InquiryBuilders.fromInquiry = fromInquiry;
|
|
365
420
|
|
|
366
421
|
function fromTemplate(templateId) {
|
|
367
|
-
return
|
|
422
|
+
return Inquiry.fromTemplate(templateId);
|
|
368
423
|
}
|
|
369
424
|
|
|
370
425
|
_InquiryBuilders.fromTemplate = fromTemplate;
|
|
371
426
|
|
|
372
427
|
function fromTemplateVersion(templateVersion) {
|
|
373
|
-
return
|
|
428
|
+
return Inquiry.fromTemplateVersion(templateVersion);
|
|
374
429
|
}
|
|
375
430
|
|
|
376
431
|
_InquiryBuilders.fromTemplateVersion = fromTemplateVersion;
|