@jsb188/app 1.0.0 → 1.0.2
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/constants/app.ts +47 -0
- package/i18n/app.ts +4 -12
- package/i18n/auth.ts +18 -1
- package/i18n/billing.ts +2 -3
- package/i18n/error.ts +13 -6
- package/i18n/form.ts +1 -0
- package/i18n/user.ts +4 -1
- package/main.ts +51 -10
- package/package.json +3 -1
- package/types/app.d.ts +1 -8
- package/types/form.d.ts +3 -0
- package/utils/api.ts +22 -0
- package/utils/datetime.ts +4 -2
- package/utils/logic.ts +25 -0
package/constants/app.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
|
|
2
|
+
// App constants
|
|
3
|
+
|
|
4
|
+
export const NOTIF_EXPIRE_DAYS = 30;
|
|
5
|
+
|
|
6
|
+
// DOM element names (ids)
|
|
7
|
+
|
|
8
|
+
export const DOM_IDS = {
|
|
9
|
+
sidebarInput: 'sidebar_input',
|
|
10
|
+
mainFocusTextarea: 'main_tx_',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// Local storage
|
|
14
|
+
|
|
15
|
+
export const STORAGE_KEYS = {
|
|
16
|
+
// Authentication
|
|
17
|
+
AUTH_TOKEN: 'AT', // There's no ":", so this is used as-is
|
|
18
|
+
LAST_VERSION: 'LV:', // ":" at end means it's a prefix
|
|
19
|
+
CURRENT_USER_ID: 'CU:',
|
|
20
|
+
|
|
21
|
+
// Settings
|
|
22
|
+
LIGHT_MODE: 'LM:',
|
|
23
|
+
} as Record<string, string>;
|
|
24
|
+
|
|
25
|
+
// Support e-mails
|
|
26
|
+
|
|
27
|
+
export const SUPPORT_EMAILS = {
|
|
28
|
+
default: 'hi@kajiwoto.ai',
|
|
29
|
+
big_planet: 'hi@kajiwoto.ai',
|
|
30
|
+
cosmic: 'hi@kajiwoto.ai',
|
|
31
|
+
} as Record<string, string>;
|
|
32
|
+
|
|
33
|
+
// Social media
|
|
34
|
+
|
|
35
|
+
export const SOCIAL_URLS = {
|
|
36
|
+
big_planet: {
|
|
37
|
+
x: 'https://x.com/bigplanetai',
|
|
38
|
+
x_username: 'BigPlanetAI',
|
|
39
|
+
},
|
|
40
|
+
cosmic: {
|
|
41
|
+
x: 'https://x.com/bigplanetai',
|
|
42
|
+
x_username: 'BigPlanetAI',
|
|
43
|
+
}
|
|
44
|
+
} as Record<string, {
|
|
45
|
+
x: string;
|
|
46
|
+
x_username: string;
|
|
47
|
+
}>;
|
package/i18n/app.ts
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
en: {
|
|
3
3
|
|
|
4
|
-
// General
|
|
5
|
-
follow_on_x: 'Follow us on X',
|
|
6
|
-
x_acc: 'X account',
|
|
7
|
-
on_x_label: 'Big Planet on X',
|
|
8
|
-
|
|
9
4
|
// Site meta
|
|
10
|
-
|
|
11
|
-
description: 'Meet new people, chat with friends or chat with AI!',
|
|
12
|
-
copyright_text: 'Big Planet. All rights reserved.',
|
|
5
|
+
copyright_text: 'All rights reserved.',
|
|
13
6
|
privacy: 'Privacy Policy',
|
|
14
7
|
tos: 'Terms of Service',
|
|
15
8
|
|
|
16
|
-
// All
|
|
17
|
-
route_: '
|
|
9
|
+
// All apps
|
|
10
|
+
route_: 'App | %{text}',
|
|
18
11
|
route_auth: 'Log in or sign up',
|
|
19
12
|
|
|
20
13
|
// @home screen
|
|
@@ -70,8 +63,7 @@ export default {
|
|
|
70
63
|
change_status: 'Change status',
|
|
71
64
|
|
|
72
65
|
// External link popup
|
|
73
|
-
|
|
74
|
-
leaving_bp_desc: 'You are about to visit an external website. Are you sure you want to continue?',
|
|
66
|
+
leaving_app_desc: 'You are about to visit an external website. Are you sure you want to continue?',
|
|
75
67
|
link_yes: 'Yes, take me away',
|
|
76
68
|
|
|
77
69
|
// Notifications/Alerts
|
package/i18n/auth.ts
CHANGED
|
@@ -7,8 +7,15 @@ export default {
|
|
|
7
7
|
continue_with_discord: 'Continue with Discord',
|
|
8
8
|
continue_with_apple: 'Continue with Apple',
|
|
9
9
|
login_opts: 'Continue with e-mail, ID, or @username',
|
|
10
|
+
resend_verification_email: 'Send verification e-mail', // This is for title of <ModalHeader /> in <AuthSwitch />
|
|
11
|
+
reset_password: 'Reset password',
|
|
12
|
+
forgot_password_: 'Forgot password or username?',
|
|
10
13
|
signup_email: 'Sign up using e-mail',
|
|
11
|
-
|
|
14
|
+
signup_using_other: 'Sign up using other methods',
|
|
15
|
+
change_password: 'Change password',
|
|
16
|
+
you_are_verified_: 'You are verified!',
|
|
17
|
+
account_is_verified: 'Thank you for verifying your account with e-mail address: %{emailAddress}',
|
|
18
|
+
continue_to_login: 'Continue to log in',
|
|
12
19
|
|
|
13
20
|
// Auth
|
|
14
21
|
username_not_found: 'No one was found with that username.',
|
|
@@ -16,6 +23,15 @@ export default {
|
|
|
16
23
|
hello_: 'Hello %{name}!',
|
|
17
24
|
you_are_logged_in: 'You are logged in.',
|
|
18
25
|
password_changed_msg: 'Your password has been changed.',
|
|
26
|
+
request_reset_password_instr: 'Enter your e-mail address and we will send you instructions to reset your password.',
|
|
27
|
+
resend_verification_instr: 'Enter your e-mail address for your account and we will send you a new verification e-mail.',
|
|
28
|
+
reset_password_instr: 'Choose a new password for your account with the e-mail address: %{emailAddress}',
|
|
29
|
+
_send_new_verification: 'to send a new verification e-mail.',
|
|
30
|
+
|
|
31
|
+
// Reset password (requested)
|
|
32
|
+
reset_password_requested_1: 'Please check your e-mail at ',
|
|
33
|
+
reset_password_requested_2: ' for instructions to reset your password.',
|
|
34
|
+
if_need_more_help: 'If you need more help, please contact us at ',
|
|
19
35
|
|
|
20
36
|
// Sign up
|
|
21
37
|
sign_up: 'Sign up',
|
|
@@ -23,6 +39,7 @@ export default {
|
|
|
23
39
|
sign_up_notice_1: 'By selecting "Agree and continue", I agree to the ',
|
|
24
40
|
sign_up_notice_2: ' and acknowledge the ',
|
|
25
41
|
account_created: 'Account created',
|
|
42
|
+
email_sent: 'E-mail sent',
|
|
26
43
|
check_email_1: 'Please check your e-mail at ',
|
|
27
44
|
check_email_2: ' to verify your account.',
|
|
28
45
|
check_email_3: 'Click "continue" to log in as ',
|
package/i18n/billing.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { SOCIAL_URLS } from "../constants/app";
|
|
2
2
|
|
|
3
3
|
// NOTE: Can't use /constants/ here because this file is loaded before all else
|
|
4
|
-
const XAccountUsername = 'BigPlanetAI';
|
|
5
4
|
const PerksSubDays = 14;
|
|
6
5
|
|
|
7
6
|
export default {
|
|
@@ -41,7 +40,7 @@ export default {
|
|
|
41
40
|
choose_payment_opt: 'Choose a payment option',
|
|
42
41
|
|
|
43
42
|
PERKS_desc_1: 'Say something nice on YouTube, TikTok, Instagram, X, personal blog, or anywhere you want.',
|
|
44
|
-
PERKS_desc_2: `Follow us on X and share your message mentioning us (@${
|
|
43
|
+
PERKS_desc_2: `Follow us on X and share your message mentioning us (@${SOCIAL_URLS.big_planet.x_username}) with your Big Planet ID or username.`,
|
|
45
44
|
PERKS_desc_3: `Wait until you receive a reply on X, Perks subscription (${PerksSubDays} days) will be added to your account.`,
|
|
46
45
|
|
|
47
46
|
PLUS_year: 'Plus (yearly)',
|
package/i18n/error.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
en: {
|
|
3
3
|
error: 'Error',
|
|
4
|
+
invalid: 'Invalid',
|
|
4
5
|
network_error_title: 'Network error',
|
|
5
6
|
unknown_error: 'An unknown error occured.',
|
|
6
7
|
network_error: 'Failed to connect to server. Please try again in a moment.',
|
|
@@ -9,6 +10,9 @@ export default {
|
|
|
9
10
|
not_allowed: 'Not allowed',
|
|
10
11
|
not_allowed_perms: 'You do not have permission to do that.',
|
|
11
12
|
login_changed: 'Login changed',
|
|
13
|
+
link_expired: 'Link expired',
|
|
14
|
+
link_expired_msg: 'This link expired. Please try again by requesting another link.',
|
|
15
|
+
invalid_link_msg: 'This link is invalid. Please try again by requesting another link.',
|
|
12
16
|
|
|
13
17
|
// 1x
|
|
14
18
|
'10000_title': 'App updated!',
|
|
@@ -35,14 +39,14 @@ export default {
|
|
|
35
39
|
20003: 'Please use "Continue with Google" to log in. (%{value})',
|
|
36
40
|
'20004_title': 'Continue with Apple',
|
|
37
41
|
20004: 'Please use "Continue with Apple" to log in. (%{value})',
|
|
38
|
-
20005: '
|
|
39
|
-
20006: '
|
|
40
|
-
20007: '
|
|
42
|
+
20005: 'Could not find user with that username (@%{value})',
|
|
43
|
+
20006: 'Could not find user with that e-mail. (%{value})',
|
|
44
|
+
20007: 'Could not find user with that ID. (%{value})',
|
|
41
45
|
20008: 'Your password is incorrect. You have %{value} try(s) remaining.',
|
|
42
46
|
20009: 'Please wait 10 minutes before trying to log in again.',
|
|
43
|
-
20010: '
|
|
44
|
-
20011: 'Your token expired, please
|
|
45
|
-
20012: 'Your token is invalid, please
|
|
47
|
+
20010: 'Could not find user.',
|
|
48
|
+
20011: 'Your token expired, please request a new link.',
|
|
49
|
+
20012: 'Your token is invalid, please request a new link.',
|
|
46
50
|
20013: 'User already exists with that e-mail address. (%{value})',
|
|
47
51
|
20014: 'User already exists with that username. (%{value})',
|
|
48
52
|
20015: "Sorry, we couldn't find that user in our database.",
|
|
@@ -79,6 +83,8 @@ export default {
|
|
|
79
83
|
20045: 'Your password is incorrect.',
|
|
80
84
|
20046: 'Your new password must be different from your current password.',
|
|
81
85
|
20047: 'You must enter a valid password.',
|
|
86
|
+
20048: 'This action is forbidden because you deleted your account.',
|
|
87
|
+
20049: 'You must activate your account before you can use the app.',
|
|
82
88
|
|
|
83
89
|
'29999_title': 'Not ready',
|
|
84
90
|
29999: 'AI chat is not ready right now.',
|
|
@@ -101,6 +107,7 @@ export default {
|
|
|
101
107
|
30022: 'Your CVC number is incorrect.',
|
|
102
108
|
30023: 'Your card expiration date is incorrect.',
|
|
103
109
|
30024: 'Stripe customer and payment method was mismatched.',
|
|
110
|
+
30025: 'Sorry, e-mail server is experiencing an outage. Please try again in a moment.',
|
|
104
111
|
|
|
105
112
|
// Form errors
|
|
106
113
|
|
package/i18n/form.ts
CHANGED
package/i18n/user.ts
CHANGED
|
@@ -14,7 +14,7 @@ export default {
|
|
|
14
14
|
email_ph: 'e.g., jane_doe@email.com',
|
|
15
15
|
password: 'Password',
|
|
16
16
|
password_ph: 'Enter your password',
|
|
17
|
-
passwordRepeat: 'Password (
|
|
17
|
+
passwordRepeat: 'Password (please repeat)',
|
|
18
18
|
search_ph: 'Search @ or ID',
|
|
19
19
|
no_one_found_: 'No one found: "%{query}"',
|
|
20
20
|
from_friends_list: 'From your friends list',
|
|
@@ -27,6 +27,8 @@ export default {
|
|
|
27
27
|
profile: 'Profile',
|
|
28
28
|
profile_desc: 'Change how your profile looks to others.',
|
|
29
29
|
personas: 'Personas',
|
|
30
|
+
show_password: 'Show password',
|
|
31
|
+
hide_password: 'Hide password',
|
|
30
32
|
change_password: 'Change password',
|
|
31
33
|
change_password_desc: 'Change your account\'s login password.',
|
|
32
34
|
// personas_desc: 'Manage your roleplay personas. Persona for the chat (your name and photo) can be changed by clicking your photo next to the chat textarea.',
|
|
@@ -42,6 +44,7 @@ export default {
|
|
|
42
44
|
// Change password
|
|
43
45
|
currentPassword: 'Current password',
|
|
44
46
|
newPassword: 'New password',
|
|
47
|
+
newPasswordRepeat: 'New password (repeat)',
|
|
45
48
|
|
|
46
49
|
// Log out
|
|
47
50
|
logout: 'Log out',
|
package/main.ts
CHANGED
|
@@ -7,15 +7,56 @@ import error from './i18n/error';
|
|
|
7
7
|
import form from './i18n/form';
|
|
8
8
|
import user from './i18n/user';
|
|
9
9
|
|
|
10
|
+
let ENV: Record<string, string> = {};
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Extend i18n with app specific texts
|
|
14
|
+
*/
|
|
15
|
+
|
|
10
16
|
export function configI18n(texts: Record<string, any>) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
|
|
18
|
+
// Locale support for later
|
|
19
|
+
const locale = 'en';
|
|
20
|
+
|
|
21
|
+
const extendedObj = {
|
|
22
|
+
app: app[locale],
|
|
23
|
+
auth: auth[locale],
|
|
24
|
+
billing: billing[locale],
|
|
25
|
+
datetime: datetime[locale],
|
|
26
|
+
error: error[locale],
|
|
27
|
+
form: form[locale],
|
|
28
|
+
user: user[locale],
|
|
29
|
+
} as Record<string, any>;
|
|
30
|
+
|
|
31
|
+
for (const key in texts) {
|
|
32
|
+
const obj = texts[key][locale];
|
|
33
|
+
|
|
34
|
+
if (extendedObj[key]) {
|
|
35
|
+
extendedObj[key] = {
|
|
36
|
+
...extendedObj[key],
|
|
37
|
+
...obj
|
|
38
|
+
};
|
|
39
|
+
} else {
|
|
40
|
+
extendedObj[key] = obj;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
i18n.extend(extendedObj);
|
|
21
45
|
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Register environment variables so the package may use it
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
export function registerENV(env: Record<string, string>) {
|
|
52
|
+
// Do not use process.env; because this package is used in client + server
|
|
53
|
+
ENV = { ...env };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Get environment variables
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
export function getENVVariable(namespace: string): string | undefined {
|
|
61
|
+
return ENV[namespace];
|
|
62
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsb188/app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Contains all the basic requirements for all @jsb188 apps.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "jsb188",
|
|
@@ -10,10 +10,12 @@
|
|
|
10
10
|
"exports": {
|
|
11
11
|
".": "./main.ts",
|
|
12
12
|
"./i18n": "./i18n/index.ts",
|
|
13
|
+
"./constants/app": "./constants/app.ts",
|
|
13
14
|
"./constants/billing": "./constants/billing.ts",
|
|
14
15
|
"./constants/emoji": "./constants/emoji.ts",
|
|
15
16
|
"./constants/user": "./constants/user.ts",
|
|
16
17
|
"./constants/ws": "./constants/ws.ts",
|
|
18
|
+
"./utils/api": "./utils/api.ts",
|
|
17
19
|
"./utils/billing": "./utils/billing.ts",
|
|
18
20
|
"./utils/datetime": "./utils/datetime.ts",
|
|
19
21
|
"./utils/emoji": "./utils/emoji.ts",
|
package/types/app.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export type DarkOrLightEnum = 'light' | 'dark';
|
|
|
28
28
|
|
|
29
29
|
export type PlatformProductGroupEnum = 'PERKS' | 'PLUS' | 'PRO' | 'COINS';
|
|
30
30
|
|
|
31
|
-
// Server types
|
|
31
|
+
// Server/API related types
|
|
32
32
|
|
|
33
33
|
export interface ServerErrorObj {
|
|
34
34
|
statusCode: number;
|
|
@@ -44,10 +44,3 @@ export interface SimpleErrorType {
|
|
|
44
44
|
title?: string;
|
|
45
45
|
message: string;
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
export interface APIRequestOutput {
|
|
49
|
-
aborted?: boolean;
|
|
50
|
-
error: ServerErrorObj | null;
|
|
51
|
-
[apiName: string]: any; // Different data depends on API
|
|
52
|
-
}
|
|
53
|
-
|
package/types/form.d.ts
CHANGED
|
@@ -44,6 +44,9 @@ interface FormGroupType {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export interface FormItemIfaceObj extends FormItemSchemaObj {
|
|
47
|
+
name: string;
|
|
48
|
+
hidden?: boolean | ((dataForSchema: any) => boolean);
|
|
49
|
+
locked?: boolean | ((dataForSchema: any) => boolean);
|
|
47
50
|
formValues: any;
|
|
48
51
|
setFormValues: (values: any) => void;
|
|
49
52
|
onInput?: (e: React.FormEvent, name: string) => void;
|
package/utils/api.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getENVVariable } from '../main';
|
|
2
|
+
|
|
3
|
+
let AUTH_TOKEN: string | null = null;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Global; save auth token to memory
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export function setAuthToken(token: string | null) {
|
|
10
|
+
if (getENVVariable('IS_BROWSER')) {
|
|
11
|
+
// Only set auth token if it's browser; we don't want to share it across users
|
|
12
|
+
AUTH_TOKEN = token || null;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Global; get auth token for all API middleware use
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export function getAuthToken(): string | null {
|
|
21
|
+
return getENVVariable('IS_BROWSER') ? AUTH_TOKEN : null;
|
|
22
|
+
}
|
package/utils/datetime.ts
CHANGED
|
@@ -153,10 +153,12 @@ export function getTimeAgo(
|
|
|
153
153
|
|
|
154
154
|
let d;
|
|
155
155
|
if (_d instanceof Date) {
|
|
156
|
-
d = _d
|
|
156
|
+
d = _d
|
|
157
|
+
} else if (!isNaN(Number(_d))) {
|
|
158
|
+
d = new Date(Number(_d))
|
|
157
159
|
} else {
|
|
158
160
|
// Make sure date is not null, before using this function
|
|
159
|
-
d = _d ? new Date(_d) : new Date(-1)
|
|
161
|
+
d = _d ? new Date(_d) : new Date(-1)
|
|
160
162
|
}
|
|
161
163
|
|
|
162
164
|
const ts = d.getTime();
|
package/utils/logic.ts
CHANGED
|
@@ -88,3 +88,28 @@ export function checkLastSetTime(time?: number, minsThreshold: number = 5) {
|
|
|
88
88
|
export function delay(ms: number) {
|
|
89
89
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
90
90
|
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Promise with timeout
|
|
94
|
+
*/
|
|
95
|
+
|
|
96
|
+
// export function timeoutPromise(promiseFn: Function, ms = 10000) {
|
|
97
|
+
// return new Promise((resolve, reject) => {
|
|
98
|
+
// // Set up the timeout
|
|
99
|
+
// const timer = setTimeout(() => {
|
|
100
|
+
// reject(new Error(`Promise timed out after ${ms} ms`));
|
|
101
|
+
// }, ms);
|
|
102
|
+
|
|
103
|
+
// // Set up the real work
|
|
104
|
+
// promiseFn(
|
|
105
|
+
// (value: any) => {
|
|
106
|
+
// clearTimeout(timer);
|
|
107
|
+
// resolve(value);
|
|
108
|
+
// },
|
|
109
|
+
// (error: any) => {
|
|
110
|
+
// clearTimeout(timer);
|
|
111
|
+
// reject(error);
|
|
112
|
+
// }
|
|
113
|
+
// );
|
|
114
|
+
// });
|
|
115
|
+
// }
|