react-native-persona 2.1.0 → 2.2.0
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 +28 -0
- package/{RNPersonaInquiry.podspec → RNPersonaInquiry2.podspec} +2 -2
- package/android/README.md +14 -0
- package/android/build.gradle +22 -98
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/withpersona/{sdk/reactnative/PersonaInquiryModule.java → sdk2/reactnative/PersonaInquiryModule2.java} +16 -12
- package/android/src/main/java/com/withpersona/{sdk/reactnative/PersonaInquiryPackage.java → sdk2/reactnative/PersonaInquiryPackage2.java} +3 -3
- package/android/src/main/java/com/withpersona/{sdk → sdk2}/reactnative/exceptions/InvalidConfiguration.java +1 -1
- package/android/src/main/res/values/theme.xml +2 -3
- package/ios/{PersonaInquiry.swift → PersonaInquiry2.swift} +13 -13
- package/ios/PersonaInquiryBridge.m +1 -1
- package/lib/commonjs/fields.js +141 -0
- package/lib/commonjs/fields.js.map +1 -0
- package/lib/commonjs/index.js +413 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/util.js +36 -0
- package/lib/commonjs/util.js.map +1 -0
- package/lib/module/fields.js +132 -0
- package/lib/module/fields.js.map +1 -0
- package/lib/module/index.js +380 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/util.js +29 -0
- package/lib/module/util.js.map +1 -0
- package/{generatedTypes/persona-tools/config.d.ts → lib/typescript/persona-tools/Config.d.ts} +0 -0
- package/{generatedTypes → lib/typescript}/persona-tools/Theme.d.ts +0 -0
- package/{generatedTypes → lib/typescript}/persona-tools/index.d.ts +0 -0
- package/{generatedTypes → lib/typescript}/persona-tools/lib/AndroidResourcePrinter.d.ts +2 -2
- package/{generatedTypes → lib/typescript}/persona-tools/lib/prompts.d.ts +0 -0
- package/{generatedTypes → lib/typescript}/persona-tools/tools/AndroidThemeGenerator.d.ts +0 -0
- package/{generatedTypes → lib/typescript}/persona-tools/tools/IosThemeInstructions.d.ts +0 -0
- package/{generatedTypes → lib/typescript}/src/fields.d.ts +0 -0
- package/{generatedTypes → lib/typescript}/src/index.d.ts +6 -5
- package/{generatedTypes → lib/typescript}/src/util.d.ts +0 -0
- package/package.json +73 -17
- package/persona-tools/{config.ts → Config.ts} +7 -7
- package/persona-tools/Theme.ts +107 -107
- package/persona-tools/index.ts +9 -9
- package/persona-tools/lib/AndroidResourcePrinter.ts +4 -4
- package/persona-tools/tools/AndroidThemeGenerator.ts +18 -18
- package/persona-tools/tools/IosThemeInstructions.ts +8 -8
- package/src/fields.ts +7 -7
- package/src/index.ts +24 -23
- package/src/util.ts +2 -2
- package/generatedTypes/persona-tools/lib/AndroidResourcePrinter.spec.d.ts +0 -1
- package/generatedTypes/src/fields.spec.d.ts +0 -1
- package/generatedTypes/src/util.spec.d.ts +0 -1
- package/jest.config.js +0 -10
- package/persona-tools/Theme.js +0 -186
- package/persona-tools/config.js +0 -72
- package/persona-tools/index.js +0 -30
- package/persona-tools/lib/AndroidResourcePrinter.js +0 -573
- package/persona-tools/lib/AndroidResourcePrinter.spec.js +0 -914
- package/persona-tools/lib/AndroidResourcePrinter.spec.ts +0 -952
- package/persona-tools/lib/prompts.js +0 -39
- package/persona-tools/tools/AndroidThemeGenerator.js +0 -55
- package/persona-tools/tools/IosThemeInstructions.js +0 -34
- package/src/fields.js +0 -88
- package/src/fields.spec.js +0 -18
- package/src/fields.spec.ts +0 -17
- package/src/index.js +0 -271
- package/src/util.js +0 -29
- package/src/util.spec.js +0 -17
- package/src/util.spec.ts +0 -22
- package/tsconfig.json +0 -29
package/src/index.ts
CHANGED
|
@@ -2,21 +2,22 @@ import {
|
|
|
2
2
|
EventSubscription,
|
|
3
3
|
NativeEventEmitter,
|
|
4
4
|
NativeModules,
|
|
5
|
-
} from
|
|
6
|
-
import { processThemeValues } from
|
|
7
|
-
import { Fields, InquiryField, RawInquiryField } from
|
|
5
|
+
} from 'react-native';
|
|
6
|
+
import { processThemeValues } from './util';
|
|
7
|
+
import { Fields, InquiryField, RawInquiryField } from './fields';
|
|
8
|
+
export { Fields };
|
|
8
9
|
|
|
9
|
-
const {
|
|
10
|
+
const { PersonaInquiry2 } = NativeModules;
|
|
10
11
|
|
|
11
12
|
// Using Opaque types + Smart Constructor enforces validation at
|
|
12
13
|
// instantiation time for IDS
|
|
13
14
|
declare const Unique: unique symbol;
|
|
14
15
|
export type Opaque<T, Tag> = T & { [Unique]: Tag };
|
|
15
16
|
|
|
16
|
-
type TemplateId = Opaque<string,
|
|
17
|
-
type TemplateVersion = Opaque<string,
|
|
18
|
-
type InquiryId = Opaque<string,
|
|
19
|
-
type AccountId = Opaque<string,
|
|
17
|
+
type TemplateId = Opaque<string, 'TemplateId'>;
|
|
18
|
+
type TemplateVersion = Opaque<string, 'TemplateVersion'>;
|
|
19
|
+
type InquiryId = Opaque<string, 'InquiryId'>;
|
|
20
|
+
type AccountId = Opaque<string, 'AccountId'>;
|
|
20
21
|
|
|
21
22
|
export class InvalidTemplateId extends Error {}
|
|
22
23
|
|
|
@@ -33,7 +34,7 @@ export class InvalidAccountId extends Error {}
|
|
|
33
34
|
* @param candidate
|
|
34
35
|
*/
|
|
35
36
|
function makeInquiryId(candidate: string): InquiryId {
|
|
36
|
-
if (candidate.startsWith(
|
|
37
|
+
if (candidate.startsWith('inq_')) return candidate as InquiryId;
|
|
37
38
|
|
|
38
39
|
throw new InvalidInquiryId(
|
|
39
40
|
`Valid template IDs start with "inq_". Received: ${candidate} `
|
|
@@ -47,7 +48,7 @@ function makeInquiryId(candidate: string): InquiryId {
|
|
|
47
48
|
* @param candidate
|
|
48
49
|
*/
|
|
49
50
|
function makeTemplateId(candidate: string): TemplateId {
|
|
50
|
-
if (candidate.startsWith(
|
|
51
|
+
if (candidate.startsWith('itmpl_')) {
|
|
51
52
|
return candidate as TemplateId;
|
|
52
53
|
}
|
|
53
54
|
|
|
@@ -63,7 +64,7 @@ function makeTemplateId(candidate: string): TemplateId {
|
|
|
63
64
|
* @param candidate
|
|
64
65
|
*/
|
|
65
66
|
function makeTemplateVersion(candidate: string): TemplateVersion {
|
|
66
|
-
if (candidate.startsWith(
|
|
67
|
+
if (candidate.startsWith('itmplv_')) {
|
|
67
68
|
return candidate as TemplateVersion;
|
|
68
69
|
}
|
|
69
70
|
|
|
@@ -79,7 +80,7 @@ function makeTemplateVersion(candidate: string): TemplateVersion {
|
|
|
79
80
|
* @param candidate
|
|
80
81
|
*/
|
|
81
82
|
function makeAccountId(candidate: string): AccountId {
|
|
82
|
-
if (candidate.startsWith(
|
|
83
|
+
if (candidate.startsWith('act_')) {
|
|
83
84
|
return candidate as AccountId;
|
|
84
85
|
}
|
|
85
86
|
|
|
@@ -93,8 +94,8 @@ function makeAccountId(candidate: string): AccountId {
|
|
|
93
94
|
* on the native side bridge into Kotlin / Swift enums.
|
|
94
95
|
*/
|
|
95
96
|
export enum Environment {
|
|
96
|
-
SANDBOX =
|
|
97
|
-
PRODUCTION =
|
|
97
|
+
SANDBOX = 'sandbox',
|
|
98
|
+
PRODUCTION = 'production',
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
export interface InquiryOptions {
|
|
@@ -128,7 +129,7 @@ type OnCanceledCallback = (inquiryId?: string, sessionToken?: string) => void;
|
|
|
128
129
|
|
|
129
130
|
type OnErrorCallback = (error: Error) => void;
|
|
130
131
|
|
|
131
|
-
const eventEmitter = new NativeEventEmitter(
|
|
132
|
+
const eventEmitter = new NativeEventEmitter(PersonaInquiry2);
|
|
132
133
|
|
|
133
134
|
export class Inquiry {
|
|
134
135
|
templateId?: TemplateId;
|
|
@@ -175,7 +176,7 @@ export class Inquiry {
|
|
|
175
176
|
|
|
176
177
|
start() {
|
|
177
178
|
this.onCompleteListener = eventEmitter.addListener(
|
|
178
|
-
|
|
179
|
+
'onComplete',
|
|
179
180
|
(event: {
|
|
180
181
|
inquiryId: string;
|
|
181
182
|
status: string;
|
|
@@ -186,19 +187,19 @@ export class Inquiry {
|
|
|
186
187
|
for (let key of Object.keys(event.fields || {})) {
|
|
187
188
|
let field = event.fields[key];
|
|
188
189
|
if (field == undefined) {
|
|
189
|
-
fields[key] = new InquiryField.Unknown(
|
|
190
|
+
fields[key] = new InquiryField.Unknown('null');
|
|
190
191
|
continue;
|
|
191
192
|
}
|
|
192
193
|
switch (field.type) {
|
|
193
|
-
case
|
|
194
|
+
case 'integer':
|
|
194
195
|
fields[key] = new InquiryField.Integer(
|
|
195
196
|
Number.parseInt(field.value)
|
|
196
197
|
);
|
|
197
198
|
break;
|
|
198
|
-
case
|
|
199
|
+
case 'boolean':
|
|
199
200
|
fields[key] = new InquiryField.Boolean(field.value);
|
|
200
201
|
break;
|
|
201
|
-
case
|
|
202
|
+
case 'string':
|
|
202
203
|
fields[key] = new InquiryField.String(field.value);
|
|
203
204
|
break;
|
|
204
205
|
default:
|
|
@@ -213,7 +214,7 @@ export class Inquiry {
|
|
|
213
214
|
);
|
|
214
215
|
|
|
215
216
|
this.onCanceledListener = eventEmitter.addListener(
|
|
216
|
-
|
|
217
|
+
'onCanceled',
|
|
217
218
|
(event: { inquiryId?: string; sessionToken?: string }) => {
|
|
218
219
|
if (this.onCanceled)
|
|
219
220
|
this.onCanceled(event.inquiryId, event.sessionToken);
|
|
@@ -222,14 +223,14 @@ export class Inquiry {
|
|
|
222
223
|
);
|
|
223
224
|
|
|
224
225
|
this.onErrorListener = eventEmitter.addListener(
|
|
225
|
-
|
|
226
|
+
'onError',
|
|
226
227
|
(event: { debugMessage: string }) => {
|
|
227
228
|
if (this.onError) this.onError(new Error(event.debugMessage));
|
|
228
229
|
this.clearListeners();
|
|
229
230
|
}
|
|
230
231
|
);
|
|
231
232
|
|
|
232
|
-
|
|
233
|
+
PersonaInquiry2.startInquiry({
|
|
233
234
|
templateId: this.templateId,
|
|
234
235
|
inquiryId: this.inquiryId,
|
|
235
236
|
referenceId: this.referenceId,
|
package/src/util.ts
CHANGED
|
@@ -6,9 +6,9 @@ export function processThemeValues(themeObject: Object) {
|
|
|
6
6
|
continue;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
if (key.includes(
|
|
9
|
+
if (key.includes('Color')) {
|
|
10
10
|
let colorValue = value;
|
|
11
|
-
if (value[0] ===
|
|
11
|
+
if (value[0] === '#') {
|
|
12
12
|
colorValue = value.slice(1);
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/jest.config.js
DELETED
package/persona-tools/Theme.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.IOS_THEME_CONFIG_KEY = exports.ANDROID_THEME_CONFIG_KEY = void 0;
|
|
7
|
-
const cli_table_1 = __importDefault(require("cli-table"));
|
|
8
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
-
const config_1 = __importDefault(require("./config"));
|
|
10
|
-
const COLOR_REGEX = /^[a-zA-Z0-9]{6}$/;
|
|
11
|
-
var ANDROID_THEME_CONFIG_KEY;
|
|
12
|
-
(function (ANDROID_THEME_CONFIG_KEY) {
|
|
13
|
-
ANDROID_THEME_CONFIG_KEY["backgroundColor"] = "backgroundColor";
|
|
14
|
-
ANDROID_THEME_CONFIG_KEY["primaryColor"] = "primaryColor";
|
|
15
|
-
ANDROID_THEME_CONFIG_KEY["darkPrimaryColor"] = "darkPrimaryColor";
|
|
16
|
-
ANDROID_THEME_CONFIG_KEY["accentColor"] = "accentColor";
|
|
17
|
-
ANDROID_THEME_CONFIG_KEY["titleTextColor"] = "titleTextColor";
|
|
18
|
-
ANDROID_THEME_CONFIG_KEY["titleTextFont"] = "titleTextFont";
|
|
19
|
-
ANDROID_THEME_CONFIG_KEY["bodyTextColor"] = "bodyTextColor";
|
|
20
|
-
ANDROID_THEME_CONFIG_KEY["bodyTextFont"] = "bodyTextFont";
|
|
21
|
-
ANDROID_THEME_CONFIG_KEY["footnoteTextColor"] = "footnoteTextColor";
|
|
22
|
-
ANDROID_THEME_CONFIG_KEY["footnoteTextFont"] = "footnoteTextFont";
|
|
23
|
-
// formLabelTextColor = "formLabelTextColor",
|
|
24
|
-
// formLabelTextFont = "formLabelTextFont",
|
|
25
|
-
ANDROID_THEME_CONFIG_KEY["textFieldTextColor"] = "textFieldTextColor";
|
|
26
|
-
ANDROID_THEME_CONFIG_KEY["textFieldTextFont"] = "textFieldTextFont";
|
|
27
|
-
ANDROID_THEME_CONFIG_KEY["pickerTextColor"] = "pickerTextColor";
|
|
28
|
-
ANDROID_THEME_CONFIG_KEY["pickerTextFont"] = "pickerTextFont";
|
|
29
|
-
ANDROID_THEME_CONFIG_KEY["buttonBackgroundColor"] = "buttonBackgroundColor";
|
|
30
|
-
ANDROID_THEME_CONFIG_KEY["buttonDisabledBackgroundColor"] = "buttonDisabledBackgroundColor";
|
|
31
|
-
ANDROID_THEME_CONFIG_KEY["buttonTouchedBackgroundColor"] = "buttonTouchedBackgroundColor";
|
|
32
|
-
ANDROID_THEME_CONFIG_KEY["buttonTextColor"] = "buttonTextColor";
|
|
33
|
-
ANDROID_THEME_CONFIG_KEY["buttonDisabledTextColor"] = "buttonDisabledTextColor";
|
|
34
|
-
// buttonTextAlignment = "buttonTextAlignment",
|
|
35
|
-
ANDROID_THEME_CONFIG_KEY["buttonCornerRadius"] = "buttonCornerRadius";
|
|
36
|
-
ANDROID_THEME_CONFIG_KEY["buttonFont"] = "buttonFont";
|
|
37
|
-
ANDROID_THEME_CONFIG_KEY["progressColor"] = "progressColor";
|
|
38
|
-
ANDROID_THEME_CONFIG_KEY["successAsset"] = "successAsset";
|
|
39
|
-
ANDROID_THEME_CONFIG_KEY["failAsset"] = "failAsset";
|
|
40
|
-
ANDROID_THEME_CONFIG_KEY["loadingAnimationAsset"] = "loadingAnimationAsset";
|
|
41
|
-
ANDROID_THEME_CONFIG_KEY["loadingAnimationWidthPercent"] = "loadingAnimationWidthPercent";
|
|
42
|
-
ANDROID_THEME_CONFIG_KEY["selfieAnimationAsset"] = "selfieAnimationAsset";
|
|
43
|
-
ANDROID_THEME_CONFIG_KEY["selfieAnimationWidthPercent"] = "selfieAnimationWidthPercent";
|
|
44
|
-
})(ANDROID_THEME_CONFIG_KEY = exports.ANDROID_THEME_CONFIG_KEY || (exports.ANDROID_THEME_CONFIG_KEY = {}));
|
|
45
|
-
var IOS_THEME_CONFIG_KEY;
|
|
46
|
-
(function (IOS_THEME_CONFIG_KEY) {
|
|
47
|
-
IOS_THEME_CONFIG_KEY["backgroundColor"] = "backgroundColor";
|
|
48
|
-
IOS_THEME_CONFIG_KEY["primaryColor"] = "primaryColor";
|
|
49
|
-
IOS_THEME_CONFIG_KEY["darkPrimaryColor"] = "darkPrimaryColor";
|
|
50
|
-
IOS_THEME_CONFIG_KEY["accentColor"] = "accentColor";
|
|
51
|
-
IOS_THEME_CONFIG_KEY["overlayBackgroundColor"] = "overlayBackgroundColor";
|
|
52
|
-
IOS_THEME_CONFIG_KEY["titleTextColor"] = "titleTextColor";
|
|
53
|
-
IOS_THEME_CONFIG_KEY["titleTextFont"] = "titleTextFont";
|
|
54
|
-
IOS_THEME_CONFIG_KEY["bodyTextColor"] = "bodyTextColor";
|
|
55
|
-
IOS_THEME_CONFIG_KEY["bodyTextFont"] = "bodyTextFont";
|
|
56
|
-
IOS_THEME_CONFIG_KEY["footnoteTextColor"] = "footnoteTextColor";
|
|
57
|
-
IOS_THEME_CONFIG_KEY["footnoteTextFont"] = "footnoteTextFont";
|
|
58
|
-
IOS_THEME_CONFIG_KEY["formLabelTextColor"] = "formLabelTextColor";
|
|
59
|
-
IOS_THEME_CONFIG_KEY["formLabelTextFont"] = "formLabelTextFont";
|
|
60
|
-
IOS_THEME_CONFIG_KEY["textFieldTextColor"] = "textFieldTextColor";
|
|
61
|
-
IOS_THEME_CONFIG_KEY["textFieldBackgroundColor"] = "textFieldBackgroundColor";
|
|
62
|
-
IOS_THEME_CONFIG_KEY["textFieldBorderColor"] = "textFieldBorderColor";
|
|
63
|
-
IOS_THEME_CONFIG_KEY["pickerTextColor"] = "pickerTextColor";
|
|
64
|
-
IOS_THEME_CONFIG_KEY["pickerTextFont"] = "pickerTextFont";
|
|
65
|
-
IOS_THEME_CONFIG_KEY["buttonBackgroundColor"] = "buttonBackgroundColor";
|
|
66
|
-
IOS_THEME_CONFIG_KEY["buttonDisabledBackgroundColor"] = "buttonDisabledBackgroundColor";
|
|
67
|
-
IOS_THEME_CONFIG_KEY["buttonTouchedBackgroundColor"] = "buttonTouchedBackgroundColor";
|
|
68
|
-
IOS_THEME_CONFIG_KEY["buttonImageTintColor"] = "buttonImageTintColor";
|
|
69
|
-
IOS_THEME_CONFIG_KEY["buttonTextColor"] = "buttonTextColor";
|
|
70
|
-
IOS_THEME_CONFIG_KEY["buttonDisabledTextColor"] = "buttonDisabledTextColor";
|
|
71
|
-
IOS_THEME_CONFIG_KEY["buttonTextAlignment"] = "buttonTextAlignment";
|
|
72
|
-
IOS_THEME_CONFIG_KEY["buttonCornerRadius"] = "buttonCornerRadius";
|
|
73
|
-
IOS_THEME_CONFIG_KEY["buttonFont"] = "buttonFont";
|
|
74
|
-
IOS_THEME_CONFIG_KEY["selectedCellBackgroundColor"] = "selectedCellBackgroundColor";
|
|
75
|
-
IOS_THEME_CONFIG_KEY["closeButtonTintColor"] = "closeButtonTintColor";
|
|
76
|
-
IOS_THEME_CONFIG_KEY["cancelButtonBackgroundColor"] = "cancelButtonBackgroundColor";
|
|
77
|
-
IOS_THEME_CONFIG_KEY["progressColor"] = "progressColor";
|
|
78
|
-
IOS_THEME_CONFIG_KEY["cameraGuideCornersColor"] = "cameraGuideCornersColor";
|
|
79
|
-
IOS_THEME_CONFIG_KEY["cameraButtonBackgroundColor"] = "cameraButtonBackgroundColor";
|
|
80
|
-
IOS_THEME_CONFIG_KEY["successAssetName"] = "successAssetName";
|
|
81
|
-
IOS_THEME_CONFIG_KEY["successAssetWidth"] = "successAssetWidth";
|
|
82
|
-
IOS_THEME_CONFIG_KEY["successAssetHeight"] = "successAssetHeight";
|
|
83
|
-
IOS_THEME_CONFIG_KEY["verificationFailAssetName"] = "verificationFailAssetName";
|
|
84
|
-
IOS_THEME_CONFIG_KEY["verificationFailAssetWidth"] = "verificationFailAssetWidth";
|
|
85
|
-
IOS_THEME_CONFIG_KEY["verificationFailAssetHeight"] = "verificationFailAssetHeight";
|
|
86
|
-
IOS_THEME_CONFIG_KEY["failAssetName"] = "failAssetName";
|
|
87
|
-
IOS_THEME_CONFIG_KEY["failAssetWidth"] = "failAssetWidth";
|
|
88
|
-
IOS_THEME_CONFIG_KEY["failAssetHeight"] = "failAssetHeight";
|
|
89
|
-
IOS_THEME_CONFIG_KEY["loadingAnimationAssetName"] = "loadingAnimationAssetName";
|
|
90
|
-
IOS_THEME_CONFIG_KEY["loadingAnimationAssetWidth"] = "loadingAnimationAssetWidth";
|
|
91
|
-
IOS_THEME_CONFIG_KEY["loadingAnimationAssetHeight"] = "loadingAnimationAssetHeight";
|
|
92
|
-
IOS_THEME_CONFIG_KEY["processingAnimationAssetName"] = "processingAnimationAssetName";
|
|
93
|
-
IOS_THEME_CONFIG_KEY["processingAnimationAssetWidth"] = "processingAnimationAssetWidth";
|
|
94
|
-
IOS_THEME_CONFIG_KEY["processingAnimationAssetHeight"] = "processingAnimationAssetHeight";
|
|
95
|
-
IOS_THEME_CONFIG_KEY["selfieAnimationAssetName"] = "selfieAnimationAssetName";
|
|
96
|
-
IOS_THEME_CONFIG_KEY["selfieAnimationAssetWidth"] = "selfieAnimationAssetWidth";
|
|
97
|
-
IOS_THEME_CONFIG_KEY["selfieAnimationAssetHeight"] = "selfieAnimationAssetHeight";
|
|
98
|
-
})(IOS_THEME_CONFIG_KEY = exports.IOS_THEME_CONFIG_KEY || (exports.IOS_THEME_CONFIG_KEY = {}));
|
|
99
|
-
class Theme {
|
|
100
|
-
async print(platform = "android") {
|
|
101
|
-
const config = await config_1.default.get();
|
|
102
|
-
const themeConfig = platform === "android" ? config["androidTheme"] : config["iosTheme"];
|
|
103
|
-
let usesCustomFontAndroid = false;
|
|
104
|
-
let usesCustomFontIos = false;
|
|
105
|
-
const head = platform === "android"
|
|
106
|
-
? ["Style Item", "Value", "Note"]
|
|
107
|
-
: ["Style Item", "Value", "Note"];
|
|
108
|
-
const table = new cli_table_1.default({
|
|
109
|
-
head,
|
|
110
|
-
// prettier-ignore
|
|
111
|
-
chars: { 'mid': '', 'left-mid': '', 'mid-mid': '', 'right-mid': '' },
|
|
112
|
-
});
|
|
113
|
-
console.log("Specified theme values:");
|
|
114
|
-
const keyEnum = platform === "android" ? ANDROID_THEME_CONFIG_KEY : IOS_THEME_CONFIG_KEY;
|
|
115
|
-
for (const key in keyEnum) {
|
|
116
|
-
let override = themeConfig[key];
|
|
117
|
-
let colorOverride = key.includes("Color") || key.includes("color");
|
|
118
|
-
if (override) {
|
|
119
|
-
if (colorOverride) {
|
|
120
|
-
override = normalizeColor(override, key);
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
override = override.toString();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
if (key.includes("Font")) {
|
|
127
|
-
if (platform == "android") {
|
|
128
|
-
usesCustomFontAndroid = true;
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
usesCustomFontIos = true;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
let row;
|
|
135
|
-
row = [
|
|
136
|
-
key,
|
|
137
|
-
override
|
|
138
|
-
? valueColor(colorOverride, override)
|
|
139
|
-
: chalk_1.default.yellow("unspecified"),
|
|
140
|
-
key.includes("Font")
|
|
141
|
-
? chalk_1.default.cyan("Fonts that are not built-in need to be installed.")
|
|
142
|
-
: "",
|
|
143
|
-
];
|
|
144
|
-
table.push(row);
|
|
145
|
-
}
|
|
146
|
-
console.log(table.toString());
|
|
147
|
-
if (usesCustomFontAndroid) {
|
|
148
|
-
console.log(chalk_1.default.yellow(" NOTE") +
|
|
149
|
-
": 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");
|
|
150
|
-
}
|
|
151
|
-
if (usesCustomFontIos) {
|
|
152
|
-
console.log(chalk_1.default.yellow(" NOTE") +
|
|
153
|
-
": 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");
|
|
154
|
-
}
|
|
155
|
-
// Add newline for spacing
|
|
156
|
-
console.log("");
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
// set default print color for non-color overrides
|
|
160
|
-
function valueColor(isColorOverride, override) {
|
|
161
|
-
return isColorOverride
|
|
162
|
-
? chalk_1.default.hex(override)(override)
|
|
163
|
-
: chalk_1.default.magentaBright(override);
|
|
164
|
-
}
|
|
165
|
-
function normalizeColor(colorHex, themeKey) {
|
|
166
|
-
let hex = colorHex;
|
|
167
|
-
if (colorHex[0] === "#") {
|
|
168
|
-
hex = colorHex.slice(1);
|
|
169
|
-
}
|
|
170
|
-
if (!COLOR_REGEX.test(hex)) {
|
|
171
|
-
if (themeKey) {
|
|
172
|
-
console.error(`Received a color value of ${chalk_1.default.yellow(colorHex)} for ${chalk_1.default.red(themeKey)}.\nFormat must follow standard 6 character hexadecimal color code. Eg. ${chalk_1.default
|
|
173
|
-
.bgHex("#FFFFFF")
|
|
174
|
-
.hex("#7E66B7")("#290087")}`);
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
console.error(`Received a color value of ${chalk_1.default.yellow(colorHex)}.\nFormat must follow standard 6 character hexadecimal color code. Eg. ${chalk_1.default
|
|
178
|
-
.bgHex("#FFFFFF")
|
|
179
|
-
.hex("#7E66B7")("#290087")}`);
|
|
180
|
-
}
|
|
181
|
-
console.log("");
|
|
182
|
-
process.exit(1);
|
|
183
|
-
}
|
|
184
|
-
return colorHex;
|
|
185
|
-
}
|
|
186
|
-
exports.default = new Theme();
|
package/persona-tools/config.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const cosmiconfig_1 = require("cosmiconfig");
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const Theme_1 = require("./Theme");
|
|
9
|
-
class Configuration {
|
|
10
|
-
async loadConfig() {
|
|
11
|
-
if (this.config)
|
|
12
|
-
return this.config;
|
|
13
|
-
try {
|
|
14
|
-
const explorer = cosmiconfig_1.cosmiconfig("persona", { packageProp: "persona" });
|
|
15
|
-
const result = await explorer.search();
|
|
16
|
-
if (result == null) {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
this.config = result.config;
|
|
20
|
-
return this.config;
|
|
21
|
-
}
|
|
22
|
-
catch (e) {
|
|
23
|
-
console.error(e);
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async get() {
|
|
28
|
-
let config = await this.loadConfig();
|
|
29
|
-
const androidThemeLines = [];
|
|
30
|
-
for (const key in Theme_1.ANDROID_THEME_CONFIG_KEY) {
|
|
31
|
-
androidThemeLines.push(` "${key}": null`);
|
|
32
|
-
}
|
|
33
|
-
const iosThemeLines = [];
|
|
34
|
-
for (const key in Theme_1.IOS_THEME_CONFIG_KEY) {
|
|
35
|
-
iosThemeLines.push(` "${key}": null`);
|
|
36
|
-
}
|
|
37
|
-
if (config == null) {
|
|
38
|
-
console.log(`
|
|
39
|
-
Missing configuration.
|
|
40
|
-
|
|
41
|
-
In order to use this tool, it must be configured using a ${chalk_1.default.yellow("persona")} object within
|
|
42
|
-
your package.json.
|
|
43
|
-
|
|
44
|
-
To get started, paste the following configuration into your package.json
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
...
|
|
48
|
-
|
|
49
|
-
"persona": {
|
|
50
|
-
"androidTheme": {
|
|
51
|
-
` +
|
|
52
|
-
androidThemeLines.join(",\n") +
|
|
53
|
-
`
|
|
54
|
-
},
|
|
55
|
-
"iosTheme": {
|
|
56
|
-
` +
|
|
57
|
-
iosThemeLines.join(",\n") +
|
|
58
|
-
`
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
...
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
and re-run this tool :).
|
|
66
|
-
`);
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
return config;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.default = new Configuration();
|
package/persona-tools/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const config_1 = __importDefault(require("./config"));
|
|
7
|
-
const prompts_1 = require("./lib/prompts");
|
|
8
|
-
const AndroidThemeGenerator_1 = __importDefault(require("./tools/AndroidThemeGenerator"));
|
|
9
|
-
const IosThemeInstructions_1 = __importDefault(require("./tools/IosThemeInstructions"));
|
|
10
|
-
console.log("");
|
|
11
|
-
console.log("============================================");
|
|
12
|
-
console.log("Persona React Native SDK customization tool.");
|
|
13
|
-
console.log("============================================");
|
|
14
|
-
console.log("");
|
|
15
|
-
const run = async () => {
|
|
16
|
-
// Run this once to print warning messages if it's not configured.
|
|
17
|
-
await config_1.default.get();
|
|
18
|
-
const { choice } = await prompts_1.whatWouldYouLikePrompt();
|
|
19
|
-
switch (choice) {
|
|
20
|
-
case prompts_1.TOOL_CHOICE.AndroidTheme:
|
|
21
|
-
await AndroidThemeGenerator_1.default.run();
|
|
22
|
-
break;
|
|
23
|
-
case prompts_1.TOOL_CHOICE.iosTheme:
|
|
24
|
-
await IosThemeInstructions_1.default.run();
|
|
25
|
-
break;
|
|
26
|
-
default:
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
run();
|