@crowdin/app-project-module 2.2.0 → 2.4.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.
Files changed (45) hide show
  1. package/out/middlewares/ui-module.js +1 -2
  2. package/out/modules/about.d.ts +4 -0
  3. package/out/modules/about.js +25 -3
  4. package/out/static/css/styles.css +2 -342
  5. package/out/static/ui/about.bundle.js +542 -0
  6. package/out/static/ui/about.bundle.js.map +1 -0
  7. package/out/static/ui/error.bundle.js +120 -2
  8. package/out/static/ui/error.bundle.js.map +1 -1
  9. package/out/static/ui/form.bundle.js +164 -12
  10. package/out/static/ui/form.bundle.js.map +1 -1
  11. package/out/static/ui/install.bundle.js +8 -2
  12. package/out/static/ui/install.bundle.js.map +1 -1
  13. package/out/static/ui/login.bundle.js +425 -35
  14. package/out/static/ui/login.bundle.js.map +1 -1
  15. package/out/static/ui/main.bundle.js +1798 -1377
  16. package/out/static/ui/main.bundle.js.map +1 -1
  17. package/out/static/ui/oauth.bundle.js +8 -2
  18. package/out/static/ui/oauth.bundle.js.map +1 -1
  19. package/out/static/ui/subscription.bundle.js +542 -0
  20. package/out/static/ui/subscription.bundle.js.map +1 -0
  21. package/out/storage/drizzle/postgresql/migrations/0002_equal_skrulls.sql +3 -0
  22. package/out/storage/drizzle/postgresql/migrations/meta/0002_snapshot.json +646 -0
  23. package/out/storage/drizzle/postgresql/migrations/meta/_journal.json +7 -0
  24. package/out/storage/drizzle/postgresql/schema.js +2 -1
  25. package/out/storage/drizzle/sqlite/migrations/0001_new_rhodey.sql +26 -0
  26. package/out/storage/drizzle/sqlite/migrations/meta/0001_snapshot.json +687 -0
  27. package/out/storage/drizzle/sqlite/migrations/meta/_journal.json +7 -0
  28. package/out/storage/drizzle/sqlite/schema.js +2 -1
  29. package/out/util/jsx-renderer.d.ts +2 -1
  30. package/out/util/jsx-renderer.js +8 -8
  31. package/out/views/FormPage.js +2 -2
  32. package/out/views/index.d.ts +0 -2
  33. package/out/views/index.js +1 -5
  34. package/out/views/layout/Head.js +0 -10
  35. package/package.json +5 -2
  36. package/out/static/css/about.css +0 -128
  37. package/out/static/css/crowdin-ui-colors.css +0 -115
  38. package/out/static/js/dependent.js +0 -315
  39. package/out/static/js/main.js +0 -96
  40. package/out/static/js/polyfills/fetch.js +0 -494
  41. package/out/static/js/polyfills/promise.js +0 -375
  42. package/out/views/AboutPage.d.ts +0 -10
  43. package/out/views/AboutPage.js +0 -88
  44. package/out/views/SubscriptionPage.d.ts +0 -7
  45. package/out/views/SubscriptionPage.js +0 -26
@@ -1,315 +0,0 @@
1
- function initializeDependencies() {
2
- const fields = document.querySelectorAll('[data-dependency]');
3
-
4
- if (fields.length > 0) {
5
- fields.forEach((field) => {
6
- try {
7
- const conditions = JSON.parse(field.dataset['dependency']);
8
- action(field, conditions);
9
-
10
- const success = check(conditions);
11
- showHide(field, success);
12
- } catch (e) {
13
- console.error('[Dependencies] Error parsing conditions for field:', field, e);
14
- }
15
- });
16
- }
17
- }
18
-
19
- document.addEventListener('DOMContentLoaded', initializeDependencies);
20
-
21
- // Expose globally so it can be called from React
22
- window.initializeDependencies = initializeDependencies;
23
-
24
- function action(field, conditions) {
25
- conditions.forEach((rules) => {
26
- for (const [selector, rule] of Object.entries(rules)) {
27
- ['input', 'change'].forEach((event) => {
28
- const element = document.querySelector(selector);
29
- if (element) {
30
- element.addEventListener(event, () => {
31
- const success = check(conditions);
32
- showHide(field, success);
33
- });
34
- }
35
- });
36
- }
37
- });
38
- }
39
-
40
- function showHide(element, success) {
41
- if (success) {
42
- element.classList.remove('dependency-show');
43
- element.classList.add('dependency-show');
44
- return true;
45
- } else {
46
- element.classList.remove('dependency-show');
47
- return false;
48
- }
49
- }
50
-
51
- function check(conditions) {
52
- return conditions.every((conditionObj) => {
53
- const selectors = Object.keys(conditionObj);
54
- return selectors.every((selector) => {
55
- const condition = conditionObj[selector];
56
- return decision(selector, condition);
57
- });
58
- });
59
- }
60
-
61
- function decision(selector, condition) {
62
- const type = condition['type'];
63
- const currentValue = getValue(selector);
64
-
65
- let checkValue = typeof condition['value'] === 'undefined' ? false : condition['value'];
66
-
67
- let minValue = typeof condition['min'] === 'undefined' ? false : parseInt(condition['min']);
68
- let maxValue = typeof condition['max'] === 'undefined' ? false : parseInt(condition['max']);
69
-
70
- const allowEmpty = typeof condition['empty'] === 'undefined' ? false : condition['empty'];
71
- const isEmpty = !allowEmpty && currentValue.length < 1;
72
-
73
- const likeSelector = typeof condition['like'] === 'undefined' ? false : condition['like'];
74
- const likeSelectorValue = getValue(likeSelector);
75
-
76
- const regExpPattern = typeof condition['pattern'] === 'undefined' ? false : condition['pattern'];
77
- const regExpModifier = typeof condition['modifier'] === 'undefined' ? 'gi' : condition['modifier'];
78
- const sign = typeof condition['sign'] === 'undefined' ? false : condition['sign'];
79
- const strict = typeof condition['strict'] === 'undefined' ? false : condition['strict'];
80
-
81
- const emptyTypes = ['empty', 'blank'];
82
- const notEmptyTypes = ['!empty', 'notEmpty', 'not-empty', 'notempty'];
83
-
84
- const equalTypes = ['equal', '=', '==', '==='];
85
- const notEqualTypes = ['!equal', '!=', '!==', '!===', 'notEqual', 'not-equal', 'notequal'];
86
-
87
- const regularExpressionTypes = ['regexp', 'exp', 'expression', 'match'];
88
-
89
- // if empty return true
90
- if (emptyTypes.includes(type)) {
91
- return currentValue.length < 1;
92
- }
93
-
94
- // if not empty return true
95
- if (notEmptyTypes.includes(type)) {
96
- return currentValue.length > 0;
97
- }
98
-
99
- // if equal return true
100
- if (equalTypes.includes(type)) {
101
- if (isEmpty) {
102
- return false;
103
- }
104
-
105
- // Match two selector value/s
106
- if (likeSelector) {
107
- if (strict) {
108
- return likeSelectorValue.every((value) => {
109
- return currentValue.includes(value);
110
- });
111
- } else {
112
- return likeSelectorValue.some((value) => {
113
- return currentValue.includes(value);
114
- });
115
- }
116
- }
117
-
118
- // Match pre-defined value/s
119
- if (strict) {
120
- if (checkValue && Array.isArray(checkValue)) {
121
- return checkValue.every((value) => {
122
- return currentValue.includes(value);
123
- });
124
- }
125
-
126
- if (checkValue && !Array.isArray(checkValue)) {
127
- return currentValue.includes(checkValue);
128
- }
129
- } else {
130
- if (checkValue && Array.isArray(checkValue)) {
131
- return checkValue.some((value) => {
132
- return currentValue.includes(value);
133
- });
134
- }
135
-
136
- if (checkValue && !Array.isArray(checkValue)) {
137
- return currentValue.includes(checkValue);
138
- }
139
- }
140
- }
141
-
142
- // if not equal return true
143
- if (notEqualTypes.includes(type)) {
144
- if (isEmpty) {
145
- return false;
146
- }
147
-
148
- // Match two selector value/s
149
- if (likeSelector) {
150
- if (strict) {
151
- return likeSelectorValue.every((value) => {
152
- return !currentValue.includes(value);
153
- });
154
- } else {
155
- return likeSelectorValue.some((value) => {
156
- return !currentValue.includes(value);
157
- });
158
- }
159
- }
160
-
161
- // Match pre-defined value/s
162
- if (strict) {
163
- if (checkValue && Array.isArray(checkValue)) {
164
- return checkValue.every((value) => {
165
- return !currentValue.includes(value);
166
- });
167
- }
168
-
169
- if (checkValue && !Array.isArray(checkValue)) {
170
- return !currentValue.includes(checkValue);
171
- }
172
- } else {
173
- if (checkValue && Array.isArray(checkValue)) {
174
- return checkValue.some((value) => {
175
- return !currentValue.includes(value);
176
- });
177
- }
178
-
179
- if (checkValue && !Array.isArray(checkValue)) {
180
- return !currentValue.includes(checkValue);
181
- }
182
- }
183
- }
184
-
185
- // if regexp match
186
- if (regularExpressionTypes.includes(type) && regExpPattern) {
187
- if (isEmpty) {
188
- return false;
189
- }
190
-
191
- const exp = new RegExp(regExpPattern, regExpModifier);
192
- return currentValue.every((value) => {
193
- return exp.test(value);
194
- });
195
- }
196
-
197
- // if length
198
- if ('length' === type) {
199
- if (isEmpty) {
200
- return false;
201
- }
202
-
203
- if (checkValue && Array.isArray(checkValue)) {
204
- minValue = parseInt(checkValue[0]);
205
- maxValue = typeof checkValue[1] === 'undefined' ? false : parseInt(checkValue[1]);
206
- }
207
-
208
- if (checkValue && !Array.isArray(checkValue)) {
209
- minValue = parseInt(checkValue);
210
- maxValue = false;
211
- }
212
-
213
- return currentValue.every((value) => {
214
- if (!maxValue) {
215
- return value.length >= minValue;
216
- }
217
-
218
- if (!minValue) {
219
- return value.length <= maxValue;
220
- }
221
-
222
- return value.length >= minValue && value.length <= maxValue;
223
- });
224
- }
225
-
226
- // if range
227
- if ('range' === type) {
228
- if (isEmpty) {
229
- return false;
230
- }
231
-
232
- if (checkValue && Array.isArray(checkValue)) {
233
- minValue = parseInt(checkValue[0]);
234
- maxValue = typeof checkValue[1] === 'undefined' ? false : parseInt(checkValue[1]);
235
- }
236
-
237
- return currentValue.every((value) => {
238
- if (!maxValue) {
239
- return parseInt(value) > minValue;
240
- }
241
-
242
- if (!minValue) {
243
- return parseInt(value) < maxValue;
244
- }
245
-
246
- return parseInt(value) > minValue && parseInt(value) < maxValue;
247
- });
248
- }
249
-
250
- // if compare
251
- if ('compare' === type && sign && checkValue) {
252
- if (isEmpty) {
253
- return false;
254
- }
255
-
256
- checkValue = parseInt(checkValue);
257
-
258
- switch (sign) {
259
- case '<':
260
- return currentValue.every((value) => {
261
- return parseInt(value) < checkValue;
262
- });
263
- break;
264
-
265
- case '<=':
266
- return currentValue.every((value) => {
267
- return parseInt(value) <= checkValue;
268
- });
269
- break;
270
-
271
- case '>':
272
- return currentValue.every((value) => {
273
- return parseInt(value) > checkValue;
274
- });
275
- break;
276
-
277
- case '>=':
278
- return currentValue.every((value) => {
279
- return parseInt(value) >= checkValue;
280
- });
281
- break;
282
-
283
- case '=':
284
- case '==':
285
- return currentValue.every((value) => {
286
- return parseInt(value) === checkValue;
287
- });
288
- break;
289
- }
290
- }
291
- }
292
-
293
- function getValue(selector) {
294
- const values = [];
295
- if (selector && document.querySelector(selector)) {
296
- const inputType = document.querySelector(selector).tagName.toLowerCase();``
297
-
298
- let currentSelector = selector;
299
-
300
- if ('crowdin-select' === inputType) {
301
- currentSelector = `${selector} option:checked`;
302
- }
303
-
304
- if ('crowdin-checkbox' === inputType) {
305
- currentSelector = `${selector}:not(input)`;
306
- }
307
-
308
- document.querySelectorAll(`${currentSelector}`).forEach((element) => {
309
- const value = element.value || element.checked;
310
- values.push(value);
311
- });
312
- }
313
-
314
- return values.filter((value) => value !== '');
315
- }
@@ -1,96 +0,0 @@
1
- if (!window.Promise) {
2
- window.Promise = Promise;
3
- }
4
-
5
- const urlParams = new URLSearchParams(window.location.search);
6
- const origin = urlParams.get('origin');
7
- const clientId = urlParams.get('client_id');
8
- let restParams = window.location.search;
9
- const frameData = JSON.parse(window.name);
10
-
11
- const postPromises = {};
12
-
13
- window.addEventListener('message', handleMessage);
14
-
15
- function isJson(string) {
16
- try {
17
- JSON.parse(string);
18
- } catch (e) {
19
- return false;
20
- }
21
-
22
- return true;
23
- }
24
-
25
- function handleMessage(event) {
26
- const eventData = event.data && typeof event.data === 'string' && isJson(event.data) ? JSON.parse(event.data) : {};
27
- if (postPromises[eventData.uid]) {
28
- if (postPromises[eventData.uid].timer) {
29
- clearTimeout(postPromises[eventData.uid].timer);
30
- }
31
- postPromises[eventData.uid].resolve(eventData.data);
32
- }
33
- }
34
-
35
- function showToast(message) {
36
- if (!!message) {
37
- const toasts = document.querySelector('crowdin-toasts');
38
- if (toasts && toasts.pushToasts) {
39
- toasts.pushToasts([message]);
40
- }
41
- }
42
- }
43
-
44
- function catchRejection(e, message) {
45
- //session expired
46
- if (e.code && e.code === 401) {
47
- reloadLocation();
48
- return;
49
- }
50
- //payment required
51
- if (e.code && e.code === 402 && window.app?.subscriptionModal.current) {
52
- if (window.app.subscriptionLink) {
53
- window.app.subscriptionLink.current = e.message || message;
54
- }
55
- window.app.openModal(window.app.subscriptionModal.current);
56
- return;
57
- }
58
- showToast(e.message || message);
59
- }
60
-
61
- function checkResponse(response) {
62
- return new Promise((resolve, reject) => {
63
- if (response.status === 204) {
64
- return resolve();
65
- }
66
- response
67
- .json()
68
- .then((res) => {
69
- if (![200, 201, 202, 304].includes(response.status)) {
70
- reject(res);
71
- } else {
72
- if (res.message) {
73
- setTimeout(() => showToast(res.message), 100);
74
- }
75
- resolve(res);
76
- }
77
- })
78
- .catch((e) => {
79
- reject(e);
80
- });
81
- });
82
- }
83
-
84
- function checkOrigin() {
85
- return new Promise((resolve, reject) => {
86
- AP.getJwtToken(jwtToken => {
87
- restParams = `?origin=${origin}&client_id=${clientId}&jwtToken=${jwtToken}`;
88
- resolve(restParams);
89
- });
90
- });
91
- }
92
-
93
- function reloadLocation() {
94
- window.location.href =
95
- window.location.protocol + '//' + window.location.host + window.location.pathname + restParams;
96
- }