react-native-persona 2.0.1 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/CHANGELOG.md +28 -2
  2. package/RNPersonaInquiry.podspec +1 -1
  3. package/android/build.gradle +1 -1
  4. package/generatedTypes/persona-tools/Theme.d.ts +95 -0
  5. package/generatedTypes/persona-tools/config.d.ts +15 -0
  6. package/generatedTypes/persona-tools/index.d.ts +1 -0
  7. package/generatedTypes/persona-tools/lib/AndroidResourcePrinter.d.ts +35 -0
  8. package/generatedTypes/persona-tools/lib/AndroidResourcePrinter.spec.d.ts +1 -0
  9. package/generatedTypes/persona-tools/lib/prompts.d.ts +8 -0
  10. package/generatedTypes/persona-tools/tools/AndroidThemeGenerator.d.ts +5 -0
  11. package/generatedTypes/persona-tools/tools/IosThemeInstructions.d.ts +5 -0
  12. package/generatedTypes/src/fields.d.ts +42 -0
  13. package/generatedTypes/src/fields.spec.d.ts +1 -0
  14. package/generatedTypes/src/index.d.ts +107 -0
  15. package/generatedTypes/src/util.d.ts +3 -0
  16. package/generatedTypes/src/util.spec.d.ts +1 -0
  17. package/package.json +5 -3
  18. package/persona-tools/Theme.js +186 -0
  19. package/persona-tools/config.js +72 -0
  20. package/persona-tools/index.js +30 -0
  21. package/persona-tools/index.ts +1 -1
  22. package/persona-tools/lib/AndroidResourcePrinter.js +573 -0
  23. package/persona-tools/lib/AndroidResourcePrinter.spec.js +914 -0
  24. package/persona-tools/lib/prompts.js +39 -0
  25. package/persona-tools/tools/AndroidThemeGenerator.js +55 -0
  26. package/persona-tools/tools/IosThemeInstructions.js +34 -0
  27. package/src/fields.js +88 -0
  28. package/src/fields.spec.js +18 -0
  29. package/src/index.js +271 -0
  30. package/src/util.js +29 -0
  31. package/src/util.spec.js +17 -0
package/CHANGELOG.md CHANGED
@@ -7,9 +7,35 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ## [v2.1.1] - 2021-12-02
11
+
12
+ ### Changed
13
+
14
+ - Upgrade to iOS Inquiry SDK 2.1.1
15
+
16
+ ## [v2.1.0] - 2021-11-18
17
+
18
+ ### Changed
19
+
20
+ - Upgrade to iOS Inquiry SDK 2.1.0
21
+ - Upgrade to Android Inquiry SDK 2.1.0
22
+
23
+ ## [v2.0.3] - 2021-10-14
24
+
25
+ ### Changed
26
+
27
+ - Upgrade to Android Inquiry SDK 2.0.2
28
+
29
+ ## [v2.0.2] - 2021-09-09
30
+
31
+ ### Fixed
32
+
33
+ - Re-added missing compiled JavaScript files
34
+
10
35
  ## [v2.0.1] - 2021-09-08
11
36
 
12
37
  ### Changed
38
+
13
39
  - Upgrade to iOS Inquiry SDK 2.0.1
14
40
 
15
41
  ## [v2.0.0] - 2021-08-26
@@ -22,8 +48,8 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
22
48
 
23
49
  - Upgrade to iOS Inquiry SDK 2.0.0
24
50
  - Upgrade to Android Inquiry SDK 2.0.0
25
- - `onSuccess` and `onFailure` callbacks are now represented by `onComplete` with a `status` of "completed" or "failed" (though can
26
- be customizable in the future)
51
+ - `onSuccess` and `onFailure` callbacks are now represented by `onComplete` with a `status` of "completed" or "failed" (
52
+ though can be customizable in the future)
27
53
  - Support Inquiry templates prefixed with `itmpl_` instead of `tmpl_`
28
54
  - `Attributes` returned in the `Success` response are now in the `Complete`'s `fields` response
29
55
  - `accessToken` has been renamed to `sessionToken` on the Inquiry builder
@@ -22,7 +22,7 @@ Pod::Spec.new do |s|
22
22
  s.requires_arc = true
23
23
 
24
24
  s.dependency 'React-Core'
25
- s.dependency 'PersonaInquirySDK', '~> 2.0.1'
25
+ s.dependency 'PersonaInquirySDK', '~> 2.1.1'
26
26
 
27
27
  s.static_framework = true
28
28
  end
@@ -79,7 +79,7 @@ dependencies {
79
79
  implementation 'com.facebook.react:react-native:+' // From node_modules
80
80
 
81
81
  // NOTE: After updating, please update the `sdkVersions.android` in example/package.json
82
- implementation 'com.withpersona.sdk:inquiry:2.0.0'
82
+ implementation 'com.withpersona.sdk:inquiry:2.1.0'
83
83
  }
84
84
 
85
85
  def configureReactNativePom(def pom) {
@@ -0,0 +1,95 @@
1
+ export declare enum ANDROID_THEME_CONFIG_KEY {
2
+ backgroundColor = "backgroundColor",
3
+ primaryColor = "primaryColor",
4
+ darkPrimaryColor = "darkPrimaryColor",
5
+ accentColor = "accentColor",
6
+ titleTextColor = "titleTextColor",
7
+ titleTextFont = "titleTextFont",
8
+ bodyTextColor = "bodyTextColor",
9
+ bodyTextFont = "bodyTextFont",
10
+ footnoteTextColor = "footnoteTextColor",
11
+ footnoteTextFont = "footnoteTextFont",
12
+ textFieldTextColor = "textFieldTextColor",
13
+ textFieldTextFont = "textFieldTextFont",
14
+ pickerTextColor = "pickerTextColor",
15
+ pickerTextFont = "pickerTextFont",
16
+ buttonBackgroundColor = "buttonBackgroundColor",
17
+ buttonDisabledBackgroundColor = "buttonDisabledBackgroundColor",
18
+ buttonTouchedBackgroundColor = "buttonTouchedBackgroundColor",
19
+ buttonTextColor = "buttonTextColor",
20
+ buttonDisabledTextColor = "buttonDisabledTextColor",
21
+ buttonCornerRadius = "buttonCornerRadius",
22
+ buttonFont = "buttonFont",
23
+ progressColor = "progressColor",
24
+ successAsset = "successAsset",
25
+ failAsset = "failAsset",
26
+ loadingAnimationAsset = "loadingAnimationAsset",
27
+ loadingAnimationWidthPercent = "loadingAnimationWidthPercent",
28
+ selfieAnimationAsset = "selfieAnimationAsset",
29
+ selfieAnimationWidthPercent = "selfieAnimationWidthPercent"
30
+ }
31
+ export declare enum IOS_THEME_CONFIG_KEY {
32
+ backgroundColor = "backgroundColor",
33
+ primaryColor = "primaryColor",
34
+ darkPrimaryColor = "darkPrimaryColor",
35
+ accentColor = "accentColor",
36
+ overlayBackgroundColor = "overlayBackgroundColor",
37
+ titleTextColor = "titleTextColor",
38
+ titleTextFont = "titleTextFont",
39
+ bodyTextColor = "bodyTextColor",
40
+ bodyTextFont = "bodyTextFont",
41
+ footnoteTextColor = "footnoteTextColor",
42
+ footnoteTextFont = "footnoteTextFont",
43
+ formLabelTextColor = "formLabelTextColor",
44
+ formLabelTextFont = "formLabelTextFont",
45
+ textFieldTextColor = "textFieldTextColor",
46
+ textFieldBackgroundColor = "textFieldBackgroundColor",
47
+ textFieldBorderColor = "textFieldBorderColor",
48
+ pickerTextColor = "pickerTextColor",
49
+ pickerTextFont = "pickerTextFont",
50
+ buttonBackgroundColor = "buttonBackgroundColor",
51
+ buttonDisabledBackgroundColor = "buttonDisabledBackgroundColor",
52
+ buttonTouchedBackgroundColor = "buttonTouchedBackgroundColor",
53
+ buttonImageTintColor = "buttonImageTintColor",
54
+ buttonTextColor = "buttonTextColor",
55
+ buttonDisabledTextColor = "buttonDisabledTextColor",
56
+ buttonTextAlignment = "buttonTextAlignment",
57
+ buttonCornerRadius = "buttonCornerRadius",
58
+ buttonFont = "buttonFont",
59
+ selectedCellBackgroundColor = "selectedCellBackgroundColor",
60
+ closeButtonTintColor = "closeButtonTintColor",
61
+ cancelButtonBackgroundColor = "cancelButtonBackgroundColor",
62
+ progressColor = "progressColor",
63
+ cameraGuideCornersColor = "cameraGuideCornersColor",
64
+ cameraButtonBackgroundColor = "cameraButtonBackgroundColor",
65
+ successAssetName = "successAssetName",
66
+ successAssetWidth = "successAssetWidth",
67
+ successAssetHeight = "successAssetHeight",
68
+ verificationFailAssetName = "verificationFailAssetName",
69
+ verificationFailAssetWidth = "verificationFailAssetWidth",
70
+ verificationFailAssetHeight = "verificationFailAssetHeight",
71
+ failAssetName = "failAssetName",
72
+ failAssetWidth = "failAssetWidth",
73
+ failAssetHeight = "failAssetHeight",
74
+ loadingAnimationAssetName = "loadingAnimationAssetName",
75
+ loadingAnimationAssetWidth = "loadingAnimationAssetWidth",
76
+ loadingAnimationAssetHeight = "loadingAnimationAssetHeight",
77
+ processingAnimationAssetName = "processingAnimationAssetName",
78
+ processingAnimationAssetWidth = "processingAnimationAssetWidth",
79
+ processingAnimationAssetHeight = "processingAnimationAssetHeight",
80
+ selfieAnimationAssetName = "selfieAnimationAssetName",
81
+ selfieAnimationAssetWidth = "selfieAnimationAssetWidth",
82
+ selfieAnimationAssetHeight = "selfieAnimationAssetHeight"
83
+ }
84
+ export declare type AndroidThemeObject = {
85
+ [key in ANDROID_THEME_CONFIG_KEY]: string | null | undefined;
86
+ };
87
+ export declare type IosThemeObject = {
88
+ [key in IOS_THEME_CONFIG_KEY]: string | null | undefined;
89
+ };
90
+ export declare type ThemeObject = AndroidThemeObject | IosThemeObject;
91
+ declare class Theme {
92
+ print(platform?: string): Promise<void>;
93
+ }
94
+ declare const _default: Theme;
95
+ export default _default;
@@ -0,0 +1,15 @@
1
+ export interface ConfigObject {
2
+ androidTheme: {
3
+ [key: string]: string | null | undefined;
4
+ };
5
+ iosTheme: {
6
+ [key: string]: string | null | undefined;
7
+ };
8
+ }
9
+ declare class Configuration {
10
+ config?: ConfigObject | null;
11
+ loadConfig(): Promise<ConfigObject | null | undefined>;
12
+ get(): Promise<ConfigObject>;
13
+ }
14
+ declare const _default: Configuration;
15
+ export default _default;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,35 @@
1
+ import { AndroidThemeObject } from "../Theme";
2
+ import { XMLBuilder } from "xmlbuilder2/lib/interfaces";
3
+ declare class AndroidResourcePrinter {
4
+ theme: AndroidThemeObject;
5
+ root: XMLBuilder;
6
+ buttonDrawable: XMLBuilder;
7
+ buttonColor: XMLBuilder;
8
+ preprintQueue: (() => void)[];
9
+ printQueue: (() => void)[];
10
+ postPrintQueue: (() => void)[];
11
+ constructor(theme: AndroidThemeObject);
12
+ process(): {
13
+ style: XMLBuilder;
14
+ buttonDrawable: XMLBuilder;
15
+ buttonColor: XMLBuilder;
16
+ };
17
+ private print;
18
+ private hasTheme;
19
+ private primaryColor;
20
+ private accentColor;
21
+ private darkPrimaryColor;
22
+ private backgroundColor;
23
+ private titleText;
24
+ private bodyText;
25
+ private footnoteText;
26
+ private textField;
27
+ private pickerText;
28
+ private button;
29
+ private progressColor;
30
+ private successAsset;
31
+ private failAsset;
32
+ private loadingAnimationAsset;
33
+ private selfieAnimationAsset;
34
+ }
35
+ export default AndroidResourcePrinter;
@@ -0,0 +1,8 @@
1
+ import inquirer from "inquirer";
2
+ export declare const TOOL_CHOICE: {
3
+ AndroidTheme: string;
4
+ iosTheme: string;
5
+ };
6
+ export declare function whatWouldYouLikePrompt(): Promise<inquirer.Answers>;
7
+ export declare function confirmThemeValues(): Promise<inquirer.Answers>;
8
+ export declare function confirmResourceFiles(): Promise<inquirer.Answers>;
@@ -0,0 +1,5 @@
1
+ declare class ThemeGenerator {
2
+ run(): Promise<void>;
3
+ }
4
+ declare const _default: ThemeGenerator;
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ declare class IosThemeInstructions {
2
+ run(): Promise<void>;
3
+ }
4
+ declare const _default: IosThemeInstructions;
5
+ export default _default;
@@ -0,0 +1,42 @@
1
+ interface InquiryField {
2
+ readonly type: string;
3
+ }
4
+ export declare type RawInquiryField = {
5
+ type: string;
6
+ value?: any;
7
+ };
8
+ export declare namespace InquiryField {
9
+ class Integer implements InquiryField {
10
+ readonly type: string;
11
+ readonly value?: number;
12
+ constructor(value?: number);
13
+ }
14
+ class String implements InquiryField {
15
+ readonly type: string;
16
+ readonly value?: string;
17
+ constructor(value?: string);
18
+ }
19
+ class Boolean implements InquiryField {
20
+ readonly type: string;
21
+ readonly value?: boolean;
22
+ constructor(value?: boolean);
23
+ }
24
+ class Unknown implements InquiryField {
25
+ readonly type: string;
26
+ constructor(type: string);
27
+ }
28
+ function parse({ type, value }: RawInquiryField): InquiryField | null;
29
+ }
30
+ export declare type Fields = Record<string, InquiryField | null>;
31
+ export declare namespace Fields {
32
+ function builder(): Builder;
33
+ class Builder {
34
+ private _fields;
35
+ constructor();
36
+ integer(fieldKey: string, value?: number): this;
37
+ boolean(fieldKey: string, value?: boolean): this;
38
+ string(fieldKey: string, value?: string): this;
39
+ build(): Fields;
40
+ }
41
+ }
42
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,107 @@
1
+ import { Fields } from "./fields";
2
+ declare const Unique: unique symbol;
3
+ export declare type Opaque<T, Tag> = T & {
4
+ [Unique]: Tag;
5
+ };
6
+ declare type TemplateId = Opaque<string, "TemplateId">;
7
+ declare type TemplateVersion = Opaque<string, "TemplateVersion">;
8
+ declare type InquiryId = Opaque<string, "InquiryId">;
9
+ declare type AccountId = Opaque<string, "AccountId">;
10
+ export declare class InvalidTemplateId extends Error {
11
+ }
12
+ export declare class InvalidTemplateVersion extends Error {
13
+ }
14
+ export declare class InvalidInquiryId extends Error {
15
+ }
16
+ export declare class InvalidAccountId extends Error {
17
+ }
18
+ /**
19
+ * String enum for environments. These strings will be parsed
20
+ * on the native side bridge into Kotlin / Swift enums.
21
+ */
22
+ export declare enum Environment {
23
+ SANDBOX = "sandbox",
24
+ PRODUCTION = "production"
25
+ }
26
+ export interface InquiryOptions {
27
+ templateId?: TemplateId;
28
+ templateVersion?: TemplateVersion;
29
+ inquiryId?: InquiryId;
30
+ referenceId?: string;
31
+ accountId?: AccountId;
32
+ environment?: Environment;
33
+ sessionToken?: string;
34
+ fields?: Fields;
35
+ onComplete?: OnCompleteCallback;
36
+ onCanceled?: OnCanceledCallback;
37
+ onError?: OnErrorCallback;
38
+ iosThemeObject?: Object | null;
39
+ }
40
+ declare type OnCompleteCallback = (inquiryId: string, status: string, fields: Fields) => void;
41
+ declare type OnCanceledCallback = (inquiryId?: string, sessionToken?: string) => void;
42
+ declare type OnErrorCallback = (error: Error) => void;
43
+ export declare class Inquiry {
44
+ templateId?: TemplateId;
45
+ inquiryId?: InquiryId;
46
+ referenceId?: string;
47
+ accountId?: AccountId;
48
+ environment?: Environment;
49
+ sessionToken?: string;
50
+ iosThemeObject?: Object | null;
51
+ fields?: Fields | null;
52
+ private readonly onComplete?;
53
+ private readonly onCanceled?;
54
+ private readonly onError?;
55
+ private onCompleteListener?;
56
+ private onCanceledListener?;
57
+ private onErrorListener?;
58
+ constructor(options: InquiryOptions);
59
+ private clearListeners;
60
+ start(): void;
61
+ }
62
+ declare class InquiryBuilder {
63
+ private _inquiryId;
64
+ private _sessionToken?;
65
+ private _onComplete?;
66
+ private _onCanceled?;
67
+ private _onError?;
68
+ private _iosThemeObject?;
69
+ private _fields?;
70
+ constructor(inquiryId: InquiryId);
71
+ sessionToken(sessionToken: string): InquiryBuilder;
72
+ onComplete(callback: OnCompleteCallback): InquiryBuilder;
73
+ onCanceled(callback: OnCanceledCallback): InquiryBuilder;
74
+ onError(callback: OnErrorCallback): InquiryBuilder;
75
+ iosTheme(themeObject: Object): InquiryBuilder;
76
+ build(): Inquiry;
77
+ }
78
+ declare class TemplateBuilder {
79
+ private readonly _templateId?;
80
+ private readonly _templateVersion?;
81
+ private _accountId?;
82
+ private _referenceId?;
83
+ private _environment?;
84
+ private _fields?;
85
+ private _sessionToken?;
86
+ private _onComplete?;
87
+ private _onCanceled?;
88
+ private _onError?;
89
+ private _iosThemeObject?;
90
+ constructor(templateId?: TemplateId | null, templateVersion?: TemplateVersion | null);
91
+ referenceId(referenceId: string): TemplateBuilder;
92
+ accountId(accountId: string): TemplateBuilder;
93
+ environment(environment: Environment): TemplateBuilder;
94
+ sessionToken(sessionToken: string): TemplateBuilder;
95
+ fields(fields: Fields): TemplateBuilder;
96
+ onComplete(callback: OnCompleteCallback): TemplateBuilder;
97
+ onCanceled(callback: OnCanceledCallback): TemplateBuilder;
98
+ onError(callback: OnErrorCallback): TemplateBuilder;
99
+ iosTheme(themeObject: Object): TemplateBuilder;
100
+ build(): Inquiry;
101
+ }
102
+ declare namespace InquiryBuilders {
103
+ function fromInquiry(inquiryId: string): InquiryBuilder;
104
+ function fromTemplate(templateId: string): TemplateBuilder;
105
+ function fromTemplateVersion(templateVersion: string): TemplateBuilder;
106
+ }
107
+ export default InquiryBuilders;
@@ -0,0 +1,3 @@
1
+ export declare function processThemeValues(themeObject: Object): {
2
+ [key: string]: string;
3
+ };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-persona",
3
3
  "title": "React Native Persona",
4
- "version": "2.0.1",
4
+ "version": "2.1.1",
5
5
  "description": "Launch a mobile native implementation of the Persona inquiry flow from React Native.",
6
6
  "main": "src/index.js",
7
7
  "bin": {
@@ -26,7 +26,9 @@
26
26
  "README.md"
27
27
  ],
28
28
  "keywords": [
29
- "react-native"
29
+ "react-native",
30
+ "persona",
31
+ "idv"
30
32
  ],
31
33
  "author": {
32
34
  "name": "Persona Identities, Inc.",
@@ -59,7 +61,7 @@
59
61
  "cosmiconfig": "^6.0.0",
60
62
  "inquirer": "^7.1.0",
61
63
  "minimist": "^1.2.5",
62
- "object-path": "^0.11.4",
64
+ "object-path": "^0.11.8",
63
65
  "pkg-up": "^3.1.0",
64
66
  "xmlbuilder2": "^2.1.2"
65
67
  }
@@ -0,0 +1,186 @@
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();