@jsb188/app 1.1.10 → 1.1.12

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 (79) hide show
  1. package/package.json +57 -45
  2. package/src/constants/agent.ts +51 -41
  3. package/src/constants/app.ts +34 -13
  4. package/src/constants/emoji.ts +9144 -8936
  5. package/src/constants/other.ts +1 -5
  6. package/src/constants/user.ts +16 -25
  7. package/src/constants/wsActions.ts +27 -0
  8. package/src/i18n/account.ts +129 -107
  9. package/src/i18n/agent.ts +331 -73
  10. package/src/i18n/agentToolBusiness.ts +196 -0
  11. package/src/i18n/agentToolGrid.ts +137 -0
  12. package/src/i18n/agentToolWorkflow.ts +101 -0
  13. package/src/i18n/agent_note.ts +109 -0
  14. package/src/i18n/app.ts +107 -91
  15. package/src/i18n/auth.ts +117 -102
  16. package/src/i18n/billing.ts +5 -92
  17. package/src/i18n/c.ts +907 -0
  18. package/src/i18n/campaign.ts +919 -0
  19. package/src/i18n/country.ts +248 -248
  20. package/src/i18n/datetime.ts +32 -26
  21. package/src/i18n/editor.ts +58 -0
  22. package/src/i18n/error.ts +577 -192
  23. package/src/i18n/field_doc_editor.ts +21 -0
  24. package/src/i18n/field_doc_programs.ts +52 -0
  25. package/src/i18n/field_docs.ts +190 -0
  26. package/src/i18n/index.ts +42 -19
  27. package/src/i18n/log.ts +272 -238
  28. package/src/i18n/memory.ts +53 -0
  29. package/src/i18n/message.ts +3 -4
  30. package/src/i18n/note.ts +19 -0
  31. package/src/i18n/org.ts +164 -109
  32. package/src/i18n/schedule.ts +209 -0
  33. package/src/i18n/sheet.ts +333 -4
  34. package/src/i18n/sheet_formula.ts +165 -0
  35. package/src/i18n/workflow.ts +109 -23
  36. package/src/main.ts +68 -64
  37. package/src/platform.ts +90 -49
  38. package/src/types/ai.d.ts +52 -23
  39. package/src/types/app.d.ts +95 -44
  40. package/src/types/auth.d.ts +66 -40
  41. package/src/types/console.d.ts +3 -0
  42. package/src/types/other.d.ts +13 -6
  43. package/src/types.d.ts +12 -14
  44. package/src/utils/account.ts +64 -58
  45. package/src/utils/api.ts +326 -77
  46. package/src/utils/authSession.ts +24 -0
  47. package/src/utils/clientIP.ts +213 -0
  48. package/src/utils/color.ts +279 -0
  49. package/src/utils/cron.ts +49 -18
  50. package/src/utils/csv.ts +19 -0
  51. package/src/utils/datetime.ts +445 -117
  52. package/src/utils/deferredSave.ts +89 -0
  53. package/src/utils/email.ts +50 -0
  54. package/src/utils/emoji.ts +107 -84
  55. package/src/utils/expression.helpers.ts +470 -0
  56. package/src/utils/expression.test.ts +793 -0
  57. package/src/utils/expression.ts +2261 -0
  58. package/src/utils/interval.ts +80 -0
  59. package/src/utils/language.ts +9 -0
  60. package/src/utils/logic.ts +141 -121
  61. package/src/utils/managedSession.ts +34 -0
  62. package/src/utils/managedSessionBff.test.ts +60 -0
  63. package/src/utils/managedSessionBff.ts +117 -0
  64. package/src/utils/number.ts +85 -38
  65. package/src/utils/object.ts +227 -30
  66. package/src/utils/promise.ts +98 -0
  67. package/src/utils/queryReset.ts +266 -0
  68. package/src/utils/recurringTask.ts +60 -0
  69. package/src/utils/schema.ts +293 -0
  70. package/src/utils/string.test.ts +205 -208
  71. package/src/utils/string.ts +426 -463
  72. package/src/utils/timeZone.ts +309 -851
  73. package/src/utils/url_client.ts +145 -72
  74. package/tsconfig.json +10 -10
  75. package/src/constants/billing.ts +0 -146
  76. package/src/i18n/form.ts +0 -376
  77. package/src/i18n/product.ts +0 -76
  78. package/src/types/form.d.ts +0 -97
  79. package/src/utils/billing.ts +0 -134
@@ -1,6 +1,18 @@
1
+ import { getENVVariable } from '../main.ts';
1
2
 
2
3
  type LinkType = 'USER' | 'KAJI' | 'DATASET' | 'VOICE' | 'FEED' | 'ROOM' | 'THREAD' | 'OTHER';
3
4
 
5
+ /*
6
+ * Format a keyboard shortcut with the command modifier used by the current
7
+ * client platform.
8
+ */
9
+ export function getClientShortcutText(key: string, shiftKey: boolean = false): string {
10
+ const platform = globalThis.navigator?.platform || globalThis.navigator?.userAgent || '';
11
+ return [/Mac|iPhone|iPod|iPad/i.test(platform) ? 'cmd' : 'ctrl', shiftKey ? 'shift' : null, key.toLowerCase()]
12
+ .filter(Boolean)
13
+ .join('+');
14
+ }
15
+
4
16
  // links to consider for User cards
5
17
  // instagram
6
18
  // tiktok
@@ -15,26 +27,76 @@ type LinkType = 'USER' | 'KAJI' | 'DATASET' | 'VOICE' | 'FEED' | 'ROOM' | 'THREA
15
27
  * Uploaded assets
16
28
  */
17
29
 
18
- export function makeUploadsUrl(
19
- urlPath?: string | null,
20
- size?: 'small' | 'medium' | 'original',
21
- download?: boolean,
22
- ): string {
23
- if (!urlPath) {
24
- return '';
25
- }
26
-
27
- const searchParams: string[] = [];
28
- if (size) {
29
- searchParams.push(`size=${encodeURIComponent(size)}`);
30
- }
31
- if (download) {
32
- searchParams.push('download=1');
33
- }
34
-
35
- const searchPath = searchParams.length ? `?${searchParams.join('&')}` : '';
36
-
37
- return 'https://assets.chiefhappiness.co/marketday/' + urlPath + searchPath;
30
+ export function makeUploadsUrl(urlPath?: string | null, size?: 'small' | 'medium' | 'original', download?: boolean): string {
31
+ if (!urlPath) {
32
+ return '';
33
+ }
34
+
35
+ const searchParams: string[] = [];
36
+ if (size) {
37
+ searchParams.push(`size=${encodeURIComponent(size)}`);
38
+ }
39
+ if (download) {
40
+ searchParams.push('download=1');
41
+ }
42
+
43
+ const searchPath = searchParams.length ? `?${searchParams.join('&')}` : '';
44
+
45
+ return 'https://assets.chiefhappiness.co/marketday/' + urlPath + searchPath;
46
+ }
47
+
48
+ /**
49
+ * Local object URLs
50
+ */
51
+
52
+ // Hold counts and pending revocations of object URLs shared between components
53
+ const objectUrlHolds = new Map<string, number>();
54
+ const objectUrlRevokeTimers = new Map<string, ReturnType<typeof setTimeout>>();
55
+
56
+ /*
57
+ * Add one hold on a local object URL (e.g. an image preview from
58
+ * URL.createObjectURL()) and cancel a revocation scheduled by a holder that
59
+ * just released it.
60
+ */
61
+ export function retainObjectUrl(url: string) {
62
+ clearTimeout(objectUrlRevokeTimers.get(url));
63
+ objectUrlRevokeTimers.delete(url);
64
+ objectUrlHolds.set(url, (objectUrlHolds.get(url) || 0) + 1);
65
+ }
66
+
67
+ /*
68
+ * Release one hold on a local object URL and revoke it shortly after its last
69
+ * holder lets go, so a holder that unmounts in the same render as the one
70
+ * taking over (e.g. a page handing a preview to the next page) never breaks it.
71
+ */
72
+ export function releaseObjectUrl(url: string) {
73
+ const holds = (objectUrlHolds.get(url) || 0) - 1;
74
+ if (holds > 0) {
75
+ objectUrlHolds.set(url, holds);
76
+ return;
77
+ }
78
+
79
+ objectUrlHolds.delete(url);
80
+ clearTimeout(objectUrlRevokeTimers.get(url));
81
+ objectUrlRevokeTimers.set(
82
+ url,
83
+ setTimeout(() => {
84
+ objectUrlRevokeTimers.delete(url);
85
+ URL.revokeObjectURL(url);
86
+ }, 1000),
87
+ );
88
+ }
89
+
90
+ /**
91
+ * Make a campaign-template preview asset URL, preserving older non-campaign paths.
92
+ */
93
+ export function makePreviewAssetUrl(uri?: string | null): string {
94
+ const assetsUrl = String(getENVVariable('ASSETS_URL') || 'https://assets.chiefhappiness.co').replace(/\/+$/, '');
95
+ const campaignPath = uri?.match(/^(\d+)\/previews\/(campaigns|campaign-instances)\/([^/]+)\.webp$/);
96
+ if (campaignPath) {
97
+ return `${assetsUrl}/previews/${campaignPath[2]}/${campaignPath[1]}/${campaignPath[3]}.webp`;
98
+ }
99
+ return uri ? `${assetsUrl}/preview/${uri}` : '';
38
100
  }
39
101
 
40
102
  /**
@@ -42,7 +104,7 @@ export function makeUploadsUrl(
42
104
  */
43
105
 
44
106
  export function makeStaticAssetUrl(urlPath?: string | null): string {
45
- return 'https://assets.chiefhappiness.co/marketday/static/' + urlPath;
107
+ return 'https://assets.chiefhappiness.co/marketday/static/' + urlPath;
46
108
  }
47
109
 
48
110
  /**
@@ -50,28 +112,25 @@ export function makeStaticAssetUrl(urlPath?: string | null): string {
50
112
  */
51
113
 
52
114
  export function makeChatUrl(
53
- firstChatId?: string | null,
54
- secondChatId?: string | null,
55
- nextFirstChatId?: string | null,
56
- nextSecondChatId?: string | null,
115
+ firstChatId?: string | null,
116
+ secondChatId?: string | null,
117
+ nextFirstChatId?: string | null,
118
+ nextSecondChatId?: string | null,
57
119
  ) {
58
- const path = 'chat';
120
+ const path = 'chat';
59
121
 
60
- if (
61
- nextFirstChatId &&
62
- nextFirstChatId === secondChatId
63
- ) {
64
- return `/${path}/${firstChatId}/${secondChatId}`;
65
- }
122
+ if (nextFirstChatId && nextFirstChatId === secondChatId) {
123
+ return `/${path}/${firstChatId}/${secondChatId}`;
124
+ }
66
125
 
67
- const first = nextFirstChatId || firstChatId || 'none';
68
- const second = nextSecondChatId || secondChatId;
126
+ const first = nextFirstChatId || firstChatId || 'none';
127
+ const second = nextSecondChatId || secondChatId;
69
128
 
70
- if (first === second) {
71
- return `/${path}/${first}`;
72
- }
129
+ if (first === second) {
130
+ return `/${path}/${first}`;
131
+ }
73
132
 
74
- return `/${path}/${first}${second ? `/${second}` : ''}`;
133
+ return `/${path}/${first}${second ? `/${second}` : ''}`;
75
134
  }
76
135
 
77
136
  /**
@@ -79,24 +138,24 @@ export function makeChatUrl(
79
138
  */
80
139
 
81
140
  export function getUrlType(type: LinkType) {
82
- switch (type) {
83
- case 'USER':
84
- return 'User';
85
- case 'KAJI':
86
- return 'AI';
87
- case 'DATASET':
88
- return 'Dataset';
89
- case 'VOICE':
90
- return 'Voice';
91
- case 'FEED':
92
- return 'Feed post';
93
- case 'ROOM':
94
- return 'Room';
95
- case 'THREAD':
96
- return 'Forum thread';
97
- default:
98
- return 'Link';
99
- }
141
+ switch (type) {
142
+ case 'USER':
143
+ return 'User';
144
+ case 'KAJI':
145
+ return 'AI';
146
+ case 'DATASET':
147
+ return 'Dataset';
148
+ case 'VOICE':
149
+ return 'Voice';
150
+ case 'FEED':
151
+ return 'Feed post';
152
+ case 'ROOM':
153
+ return 'Room';
154
+ case 'THREAD':
155
+ return 'Forum thread';
156
+ default:
157
+ return 'Link';
158
+ }
100
159
  }
101
160
 
102
161
  /**
@@ -104,20 +163,20 @@ export function getUrlType(type: LinkType) {
104
163
  */
105
164
 
106
165
  export function locationSearchToObject(searchParams?: string) {
107
- if (!searchParams) {
108
- return {};
109
- }
166
+ if (!searchParams) {
167
+ return {};
168
+ }
110
169
 
111
- const search = searchParams.substring(1);
112
- const searchParamsArray = search.split('&');
113
- const searchParamsObject: Record<string, string> = {};
170
+ const search = searchParams.substring(1);
171
+ const searchParamsArray = search.split('&');
172
+ const searchParamsObject: Record<string, string> = {};
114
173
 
115
- searchParamsArray.forEach((param) => {
116
- const [key, value] = param.split('=');
117
- searchParamsObject[key] = value;
118
- });
174
+ searchParamsArray.forEach((param) => {
175
+ const [key, value] = param.split('=');
176
+ searchParamsObject[key] = value;
177
+ });
119
178
 
120
- return searchParamsObject;
179
+ return searchParamsObject;
121
180
  }
122
181
 
123
182
  /**
@@ -125,9 +184,23 @@ export function locationSearchToObject(searchParams?: string) {
125
184
  */
126
185
 
127
186
  export function isChatPage() {
128
- const pathname = globalThis?.location?.pathname?.toLowerCase();
129
- if (pathname) {
130
- return /^\/(?:chat|dm)\//i.test(pathname);
131
- }
132
- return false;
187
+ const pathname = globalThis?.location?.pathname?.toLowerCase();
188
+ if (pathname) {
189
+ return /^\/(?:chat|dm)\//i.test(pathname);
190
+ }
191
+ return false;
192
+ }
193
+
194
+ /**
195
+ * Check if a pathname falls under any of the given route prefixes.
196
+ * Matching is segment-aware: '/app/s' or '/app/s/' matches '/app/s' and '/app/s/12345', but not '/app/sheets'.
197
+ * Only the pathname is compared, so query strings and hashes never affect the result.
198
+ */
199
+
200
+ export function isPathnameUnderRoutes(pathname: string, routes: string[]) {
201
+ const [path] = pathname.split(/[?#]/);
202
+ return routes.some((route) => {
203
+ const prefix = route.replace(/\/+$/, '');
204
+ return prefix === '' || path === prefix || path.startsWith(prefix + '/');
205
+ });
133
206
  }
package/tsconfig.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "moduleResolution": "Bundler",
6
- "allowImportingTsExtensions": true,
7
- "noEmit": true,
8
- "strict": true,
9
- "esModuleInterop": true
10
- },
11
- "include": ["src/**/*"]
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "allowImportingTsExtensions": true,
7
+ "noEmit": true,
8
+ "strict": true,
9
+ "esModuleInterop": true
10
+ },
11
+ "include": ["src/**/*"]
12
12
  }
@@ -1,146 +0,0 @@
1
- export const PLATFORM_PRODUCT_ENUMS = [
2
- // Subscriptions
3
- 'perks',
4
- 'kajiwoto_plus',
5
- 'kajiwoto_plus_yearly',
6
- 'kajiwoto_pro',
7
- 'kajiwoto_pro_yearly',
8
-
9
- // These are for future proofing; don't use these until they're in the database
10
- 'big_planet_plus',
11
- 'big_planet_plus_yearly',
12
- 'big_planet_pro',
13
- 'big_planet_pro_yearly',
14
-
15
- // Consumables
16
- 'coins_10',
17
- 'coins_20',
18
- 'coins_100',
19
-
20
- // Expired
21
- 'kajiwoto_creator',
22
- 'creator_dataset_sub',
23
- ];
24
-
25
- export const SUBSCRIPTION_CATALOG = [
26
- // [groupName, stripeProductId, stripePriceId]
27
- ['PLUS', 'prod_H0WgTKq5qiK51Q', 'plan_H0WhZdwYcq9Fn7'],
28
- ['PRO', 'prod_H0WgTKq5qiK51Q', 'price_1MkLqjJI6Kvu2OvUPzFwwncH'],
29
- ];
30
-
31
- export const SUBSCRIPTION_CATALOG_TEST = [
32
- // [groupName, stripeProductId, stripePriceId]
33
- ['PLUS', 'prod_O2uOYfarTaRqJX', 'price_1QBox9JI6Kvu2OvUoy9vBmKL'],
34
- ['PRO', 'prod_O2uOYfarTaRqJX', 'price_1QBox9JI6Kvu2OvUQ86KgX5C'],
35
- ];
36
-
37
- export const PRICE_ID_TO_PRODUCT = {
38
- plan_H0WhZdwYcq9Fn7: {
39
- name: 'kajiwoto_plus',
40
- group: 'PLUS',
41
- },
42
- price_1HmqX5JI6Kvu2OvUM1edHUMw: {
43
- name: 'kajiwoto_plus_yearly',
44
- group: 'PLUS',
45
- },
46
- price_1MkLqjJI6Kvu2OvUPzFwwncH: {
47
- name: 'kajiwoto_pro',
48
- group: 'PRO',
49
- },
50
- price_1MkLrzJI6Kvu2OvUMPyWvKdt: {
51
- name: 'kajiwoto_pro_yearly',
52
- group: 'PRO',
53
- },
54
- price_1IOudjJI6Kvu2OvU6znCc2oZ: {
55
- name: 'coins_10',
56
- group: 'COINS',
57
- },
58
- price_1IOudjJI6Kvu2OvUnRFoUQUm: {
59
- name: 'coins_20',
60
- group: 'COINS',
61
- },
62
- price_1K3y6EJI6Kvu2OvUYUDJgMy6: {
63
- name: 'coins_100',
64
- group: 'COINS',
65
- },
66
- // price_HNzF3cC8hMxs0Q: 'kajiwoto_creator',
67
- // plan_HIXtNYWIEx9eST: 'creator_dataset_sub',
68
- } as {
69
- [key: string]: {
70
- name: string;
71
- group: string;
72
- };
73
- };
74
-
75
- export const PRICE_ID_TO_PRODUCT_TEST = {
76
- price_1QBox9JI6Kvu2OvUoy9vBmKL: {
77
- name: 'kajiwoto_plus',
78
- group: 'PLUS',
79
- },
80
- price_1QBox9JI6Kvu2OvU7bKCLUYq: {
81
- name: 'kajiwoto_plus_yearly',
82
- group: 'PLUS',
83
- },
84
- price_1QBox9JI6Kvu2OvUQ86KgX5C: {
85
- name: 'kajiwoto_pro',
86
- group: 'PRO',
87
- },
88
- price_1QBox9JI6Kvu2OvU8Fn4ftXb: {
89
- name: 'kajiwoto_pro_yearly',
90
- group: 'PRO',
91
- },
92
- price_1NGnmKJI6Kvu2OvUx3bykj0F: {
93
- name: 'coins_10',
94
- group: 'COINS',
95
- },
96
- price_1NGoBHJI6Kvu2OvUONbOujKG: {
97
- name: 'coins_20',
98
- group: 'COINS',
99
- },
100
- price_1NGoAjJI6Kvu2OvUSRWartW3: {
101
- name: 'coins_100',
102
- group: 'COINS',
103
- },
104
- // price_HNzJjKRMAhEakr: 'kajiwoto_creator',
105
- // plan_HIYFVZvX8lLTol: 'creator_dataset_sub',
106
- } as {
107
- [key: string]: {
108
- name: string;
109
- group: string;
110
- };
111
- };
112
-
113
- // Products
114
- // export const PRICES = {
115
- // kajiwoto_plus: 7.99,
116
- // kajiwoto_plus_yearly: 87.89,
117
- // kajiwoto_pro: 29.99,
118
- // kajiwoto_pro_yearly: 299.99,
119
- // coins_10: 9.99,
120
- // coins_20: 19.98,
121
- // coins_100: 99.90,
122
-
123
- // // Skin Prices
124
- // SKIN_PRICE_1: 2.99,
125
- // SKIN_PRICE_2: 4.99,
126
- // SKIN_PRICE_3: 9.99,
127
- // SKIN_PRICE_4: 19.99
128
- // };
129
-
130
- // export const SUBSCRIPTION_PRODUCTS = [
131
- // 'kajiwoto_plus',
132
- // 'kajiwoto_plus_yearly',
133
- // 'kajiwoto_pro',
134
- // 'kajiwoto_pro_yearly',
135
- // 'kajiwoto_creator',
136
- // 'kplus_test'
137
- // ];
138
-
139
- // export const HAS_PLUS_SUB_TYPES = [
140
- // 'plus',
141
- // 'pro'
142
- // ];
143
-
144
- // export const HAS_PRO_SUB_TYPES = [
145
- // 'pro'
146
- // ];