@awesomeness-js/server 1.1.6 → 1.1.8

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 (63) hide show
  1. package/index.js +101 -101
  2. package/package.json +1 -1
  3. package/src/componentDependencies.js +51 -47
  4. package/src/koa/routeRequest.js +87 -26
  5. package/example-site/example.awesomenessjs.com/components/example/index.js +0 -3
  6. package/example-site/example.awesomenessjs.com/components/notCommonExample/_.css +0 -1
  7. package/example-site/example.awesomenessjs.com/components/notCommonExample/index.js +0 -3
  8. package/ui/README.md +0 -438
  9. package/ui/awesomeness-ui.instructions.md +0 -156
  10. package/ui/build.js +0 -119
  11. package/ui/commonComponent.test.js +0 -27
  12. package/ui/components/blogPost/all.css +0 -371
  13. package/ui/components/blogPost/headerImage.js +0 -153
  14. package/ui/components/blogPost/index.js +0 -45
  15. package/ui/components/blogPost/marked.js +0 -74
  16. package/ui/components/blogPost/md.js +0 -73
  17. package/ui/components/blogPost/parseAwesomeness.jQuery.js +0 -47
  18. package/ui/components/blogPost/readme.md +0 -8
  19. package/ui/components/colors/README.md +0 -65
  20. package/ui/components/colors/dynamic.css +0 -1884
  21. package/ui/components/colors/dynamic.css.js +0 -135
  22. package/ui/components/colors/dynamic.css.php +0 -79
  23. package/ui/components/colors/example.js +0 -133
  24. package/ui/components/colors/index.js +0 -65
  25. package/ui/components/colors/map.js +0 -13
  26. package/ui/components/colors/random.js +0 -17
  27. package/ui/components/colors/tailwind-colors.css +0 -247
  28. package/ui/components/insertIntoList/insertIntoList.jquery.js +0 -150
  29. package/ui/components/statusPage/index.css +0 -120
  30. package/ui/components/statusPage/index.js +0 -39
  31. package/ui/components/tag/category.js +0 -8
  32. package/ui/components/tag/index.js +0 -33
  33. package/ui/components/tag/list.js +0 -42
  34. package/ui/components/tag/map.js +0 -64
  35. package/ui/components/tag/tagMap.css +0 -60
  36. package/ui/components/tag/tags.css +0 -20
  37. package/ui/core/css/_normalize.css +0 -57
  38. package/ui/core/css/dynamic/flex.js +0 -36
  39. package/ui/core/css/dynamic/grid.js +0 -185
  40. package/ui/core/css/dynamic/shortcuts.js +0 -48
  41. package/ui/core/css/dynamic/spacing.js +0 -61
  42. package/ui/core/css/dynamic/text.js +0 -80
  43. package/ui/core/css/dynamic/width.js +0 -75
  44. package/ui/core/css/dynamic.js +0 -40
  45. package/ui/core/js/app/api.js +0 -143
  46. package/ui/core/js/app/init.js +0 -88
  47. package/ui/core/js/app/initDarkMode.js +0 -26
  48. package/ui/core/js/app/initialScroll.js +0 -28
  49. package/ui/core/js/app/meta/update/components.js +0 -65
  50. package/ui/core/js/app/meta/update/pages.js +0 -86
  51. package/ui/core/js/app/metaUpdates.js +0 -10
  52. package/ui/core/js/app/page.js +0 -319
  53. package/ui/core/js/app/resize.js +0 -52
  54. package/ui/core/js/app/state/back.js +0 -16
  55. package/ui/core/js/app/state/create.js +0 -50
  56. package/ui/core/js/app/state/get.js +0 -5
  57. package/ui/core/js/app/state/init.js +0 -25
  58. package/ui/core/js/app.js +0 -41
  59. package/ui/core/js/jquery-3.7.1.min.js +0 -2
  60. package/ui/core/public/app.css +0 -1
  61. package/ui/core/public/app.js +0 -975
  62. package/ui/core/public/favicon.ico +0 -0
  63. package/ui/core/public/index.html +0 -40
@@ -1,185 +0,0 @@
1
- export default function({
2
- sizes = [
3
- 'xl',
4
- 'd',
5
- 't',
6
- 'p'
7
- ],
8
- pixels = 126
9
- } = {}) {
10
-
11
- let data = ` `;
12
-
13
- const grids = 12;
14
-
15
- data += `.grid { display: grid; grid-template-columns: auto auto; } `;
16
-
17
- // justify
18
- data += `.justify-center { justify-content: center; } `;
19
- data += `.justify-start { justify-content: start; } `;
20
- data += `.justify-end { justify-content: end; } `;
21
- data += `.justify-between { justify-content: space-between; } `;
22
- data += `.justify-around { justify-content: space-around; } `;
23
- data += `.justify-evenly { justify-content: space-evenly; } `;
24
-
25
- // align
26
- data += `.align-center { align-items: center; } `;
27
- data += `.align-start { align-items: start; } `;
28
- data += `.align-end { align-items: end; } `;
29
- data += `.align-baseline { align-items: baseline; } `;
30
- data += `.align-stretch { align-items: stretch; } `;
31
-
32
- // justify-items
33
- data += `.justify-items-start { justify-items: start; } `;
34
- data += `.justify-items-center { justify-items: center; } `;
35
- data += `.justify-items-end { justify-items: end; } `;
36
- data += `.justify-items-stretch { justify-items: stretch; } `;
37
-
38
- // justify
39
- data += `.grid.center { justify-self: center; } `;
40
- data += `.grid.left { justify-self: start; } `;
41
- data += `.grid.right { justify-self: end; } `;
42
-
43
- data += `.justify-self-center { justify-self: center; } `;
44
- data += `.justify-self-left { justify-self: start; } `;
45
- data += `.justify-self-right { justify-self: end; } `;
46
-
47
-
48
- data += `.span-full { grid-column: 1 / -1; } `;
49
- data += `.row-span-full { grid-row: 1 / -1; } `;
50
-
51
- sizes.forEach((s) => {
52
-
53
- data += `.app-size-${s} .grid.center-${s} { justify-self: center; } `;
54
- data += `.app-size-${s} .grid.left-${s} { justify-self: start; } `;
55
- data += `.app-size-${s} .grid.right-${s} { justify-self: end; } `;
56
-
57
- data += `.app-size-${s} .justify-self-center-${s} { justify-self: center; } `;
58
- data += `.app-size-${s} .justify-self-start-${s} { justify-self: start; } `;
59
- data += `.app-size-${s} .justify-self-end-${s} { justify-self: end; } `;
60
-
61
- data += `.app-size-${s} .span-full-${s} { grid-column: 1 / -1; } `;
62
- data += `.app-size-${s} .row-span-full-${s} { grid-row: 1 / -1; } `;
63
-
64
- // justify
65
- data += `.app-size-${s} .justify-center-${s} { justify-content: center; } `;
66
- data += `.app-size-${s} .justify-start-${s} { justify-content: start; } `;
67
- data += `.app-size-${s} .justify-end-${s} { justify-content: end; } `;
68
- data += `.app-size-${s} .justify-between-${s} { justify-content: space-between; } `;
69
- data += `.app-size-${s} .justify-around-${s} { justify-content: space-around; } `;
70
- data += `.app-size-${s} .justify-evenly-${s} { justify-content: space-evenly; } `;
71
-
72
- // justify-items
73
- data += `.app-size-${s} .justify-items-start-${s} { justify-items: start; } `;
74
- data += `.app-size-${s} .justify-items-center-${s} { justify-items: center; } `;
75
- data += `.app-size-${s} .justify-items-end-${s} { justify-items: end; } `;
76
- data += `.app-size-${s} .justify-items-stretch-${s} { justify-items: stretch; } `;
77
-
78
- // align
79
- data += `.app-size-${s} .align-center-${s} { align-items: center; } `;
80
- data += `.app-size-${s} .align-start-${s} { align-items: start; } `;
81
- data += `.app-size-${s} .align-end-${s} { align-items: end; } `;
82
- data += `.app-size-${s} .align-baseline-${s} { align-items: baseline; } `;
83
- data += `.app-size-${s} .align-stretch-${s} { align-items: stretch; } `;
84
-
85
- });
86
-
87
-
88
- for (let i = 1; i <= grids; i++) {
89
-
90
- // cols
91
- data += `.grid-${i} { display: grid; grid-template-columns: repeat(${i}, 1fr); } `;
92
-
93
- // spans
94
- data += `.span-${i} { grid-column: span ${i} / span ${i}; } `;
95
-
96
- // start
97
- data += `.start-${i} { grid-column-start: ${i}; } `;
98
-
99
- // end
100
- data += `.end-${i} { grid-column-end: ${i}; } `;
101
-
102
- // rows
103
- data += `.grid-rows-${i} { grid-template-rows: repeat(${i}, 1fr); } `;
104
-
105
- // spans
106
- data += `.row-span-${i} { grid-row: span ${i} / span ${i}; } `;
107
-
108
- // start
109
- data += `.row-start-${i} { grid-row-start: ${i}; } `;
110
-
111
- // end
112
- data += `.row-end-${i} { grid-row-end: ${i}; } `;
113
-
114
- // order
115
- data += `.order-${i} { order: ${i}; } `;
116
-
117
-
118
- sizes.forEach((s) => {
119
-
120
- // cols
121
- data += `.app-size-${s} .grid-${i}-${s} { display: grid; grid-template-columns: repeat(${i}, 1fr); } `;
122
-
123
- // spans
124
- data += `.app-size-${s} .span-${i}-${s} { grid-column: span ${i} / span ${i}; } `;
125
-
126
- // start
127
- data += `.app-size-${s} .start-${i}-${s} { grid-column-start: ${i}; } `;
128
-
129
- // end
130
- data += `.app-size-${s} .end-${i}-${s} { grid-column-end: ${i}; } `;
131
-
132
- // rows
133
- data += `.app-size-${s} .grid-rows-${i}-${s} { grid-template-rows: repeat(${i}, 1fr); } `;
134
-
135
- // spans
136
- data += `.app-size-${s} .row-span-${i}-${s} { grid-row: span ${i} / span ${i}; } `;
137
-
138
- // start
139
- data += `.app-size-${s} .row-start-${i}-${s} { grid-row-start: ${i}; } `;
140
-
141
- // end
142
- data += `.app-size-${s} .row-end-${i}-${s} { grid-row-end: ${i}; } `;
143
-
144
- // order
145
- data += `.app-size-${s} .order-${i}-${s} { order: ${i}; } `;
146
-
147
- });
148
-
149
- }
150
-
151
- // add and extra for start and end for both col and row
152
- data += `.start-${grids +1} { grid-column-start: ${grids +1}; } `;
153
- data += `.end-${grids +1} { grid-column-end: ${grids +1}; } `;
154
-
155
- sizes.forEach((s) => {
156
-
157
- data += `.app-size-${s} .start-${grids +1}-${s} { grid-column-start: ${grids +1}; } `;
158
- data += `.app-size-${s} .end-${grids +1}-${s} { grid-column-end: ${grids +1}; } `;
159
-
160
- });
161
-
162
-
163
- // gap
164
- for(let i = 1; i <= pixels; i++) {
165
-
166
- data += `.gap-${i} { gap: ${i}px; } `;
167
- data += `.gap-x-${i} { column-gap: ${i}px; } `;
168
- data += `.gap-y-${i} { row-gap: ${i}px; } `;
169
-
170
- sizes.forEach((s) => {
171
-
172
- data += `.app-size-${s} .gap-${i}-${s} { gap: ${i}px; } `;
173
- data += `.app-size-${s} .gap-x-${i}-${s} { column-gap: ${i}px; } `;
174
- data += `.app-size-${s} .gap-y-${i}-${s} { row-gap: ${i}px; } `;
175
-
176
- });
177
-
178
- }
179
-
180
-
181
- data += ` `;
182
-
183
- return data;
184
-
185
- }
@@ -1,48 +0,0 @@
1
- export default function(sizes = [
2
- 'xl',
3
- 'd',
4
- 't',
5
- 'p'
6
- ]) {
7
-
8
- let data = ` `;
9
-
10
- // dynamic display
11
- data += ".hidden {display: none !important;} ";
12
- data += ".fl{float:left !important;} ";
13
- data += ".fr{float:right !important;} ";
14
- data += ".m0a{margin: 0 auto;} ";
15
-
16
- // cursor pointer
17
- data += ".cursor-pointer {cursor: pointer !important;} ";
18
- data += ".cursor-default {cursor: default !important;} ";
19
-
20
- // position
21
- data += ".absolute {position:absolute !important;} ";
22
- data += ".relative {position:relative !important;} ";
23
- data += ".fixed {position:fixed !important;} ";
24
- data += ".sticky {position:sticky !important;} ";
25
-
26
-
27
- sizes.forEach((s) => {
28
-
29
- data += `.app-size-${s} .hidden-${s} {display: none !important;} `;
30
-
31
- data += `.app-size-${s} .cursor-pointer-${s} {cursor: pointer !important;} `;
32
- data += `.app-size-${s} .cursor-default${s} {cursor: default !important;} `;
33
-
34
- data += `.app-size-${s} .fl {float:left !important;} `;
35
- data += `.app-size-${s} .fr {float:right !important;} `;
36
-
37
- data += `.app-size-${s} .absolute {position:absolute !important;} `;
38
- data += `.app-size-${s} .relative {position:relative !important;} `;
39
- data += `.app-size-${s} .fixed {position:fixed !important;} `;
40
- data += `.app-size-${s} .sticky {position:sticky !important;} `;
41
-
42
-
43
- });
44
-
45
-
46
- return data;
47
-
48
- }
@@ -1,61 +0,0 @@
1
- export default function({
2
- sizes = [
3
- 'xl',
4
- 'd',
5
- 't',
6
- 'p'
7
- ],
8
- pixels = 126
9
- } = {}) {
10
-
11
- let data = ` `;
12
-
13
- // dynamic margin
14
- for( let i = 0; i < pixels; i += 5 ){
15
-
16
- data += `.gap-${i} { gap:${i}px; } `;
17
-
18
- data += `.m${i} { margin:${i}px; } `;
19
- data += `.mt${i} { margin-top:${i}px; } `;
20
- data += `.mb${i} { margin-bottom:${i}px; } `;
21
- data += `.ml${i} { margin-left:${i}px; } `;
22
- data += `.mr${i} { margin-right:${i}px; } `;
23
- data += `.mtb${i} { margin-top:${i}px; margin-bottom:${i}px; } `;
24
- data += `.mlr${i} { margin-left:${i}px; margin-right:${i}px; } `;
25
-
26
- data += `.p${i} { padding:${i}px; } `;
27
- data += `.pt${i} { padding-top:${i}px; } `;
28
- data += `.pb${i} { padding-bottom:${i}px; } `;
29
- data += `.pl${i} { padding-left:${i}px; } `;
30
- data += `.pr${i} { padding-right:${i}px; } `;
31
- data += `.ptb${i} { padding-top:${i}px; padding-bottom:${i}px; } `;
32
- data += `.plr${i} { padding-left:${i}px; padding-right:${i}px; } `;
33
-
34
- sizes.forEach((s) => {
35
-
36
- data += `.app-size-${s} .gap-${i}-${s} { gap:${i}px; } `;
37
-
38
- data += `.app-size-${s} .m${i}-${s} { margin:${i}px; } `;
39
- data += `.app-size-${s} .mt${i}-${s} { margin-top:${i}px; } `;
40
- data += `.app-size-${s} .mr${i}-${s} { margin-right:${i}px; } `;
41
- data += `.app-size-${s} .mb${i}-${s} { margin-bottom:${i}px; } `;
42
- data += `.app-size-${s} .ml${i}-${s} { margin-left:${i}px; } `;
43
- data += `.app-size-${s} .mtb${i}-${s} { margin-top:${i}px; margin-bottom:${i}px; } `;
44
- data += `.app-size-${s} .mlr${i}-${s} { margin-left:${i}px; margin-right:${i}px; } `;
45
-
46
-
47
- data += `.app-size-${s} .p${i}-${s} { padding:${i}px; } `;
48
- data += `.app-size-${s} .pt${i}-${s} { padding-top:${i}px; } `;
49
- data += `.app-size-${s} .pr${i}-${s} { padding-right:${i}px; } `;
50
- data += `.app-size-${s} .pb${i}-${s} { padding-bottom:${i}px; } `;
51
- data += `.app-size-${s} .pl${i}-${s} { padding-left:${i}px; } `;
52
- data += `.app-size-${s} .ptb${i}-${s} { padding-top:${i}px; padding-bottom:${i}px; } `;
53
- data += `.app-size-${s} .plr${i}-${s} { padding-left:${i}px; padding-right:${i}px; } `;
54
-
55
- });
56
-
57
- }
58
-
59
- return data;
60
-
61
- }
@@ -1,80 +0,0 @@
1
- export default function(sizes = [
2
- 'xl',
3
- 'd',
4
- 't',
5
- 'p'
6
- ]) {
7
-
8
- let data = ` `;
9
-
10
- data += `.text-center {text-align:center !important;} `;
11
- data += `.text-left {text-align:left !important;} `;
12
- data += `.text-right {text-align:right !important;} `;
13
-
14
- data += `.text-300 {font-weight:300 !important;} `;
15
- data += `.text-400 {font-weight:400 !important;} `;
16
- data += `.text-500 {font-weight:500 !important;} `;
17
- data += `.text-600 {font-weight:600 !important;} `;
18
- data += `.text-700 {font-weight:700 !important;} `;
19
- data += `.text-800 {font-weight:800 !important;} `;
20
- data += `.text-900 {font-weight:900 !important;} `;
21
-
22
- data += `.text-300--hover:hover{font-weight:300 !important;} `;
23
- data += `.text-400--hover:hover{font-weight:400 !important;} `;
24
- data += `.text-500--hover:hover{font-weight:500 !important;} `;
25
- data += `.text-600--hover:hover{font-weight:600 !important;} `;
26
- data += `.text-700--hover:hover{font-weight:700 !important;} `;
27
- data += `.text-800--hover:hover{font-weight:800 !important;} `;
28
- data += `.text-900--hover:hover{font-weight:900 !important;} `;
29
-
30
- data += `.text-xxs {font-size:.70em !important;} `;
31
- data += `.text-xs {font-size:.83em !important;} `;
32
- data += `.text-s {font-size:.9em !important;} `;
33
- data += `.text-m {font-size:1.1em !important;} `;
34
- data += `.text-l {font-size:1.2em !important;} `;
35
- data += `.text-xl {font-size:1.4em !important;} `;
36
- data += `.text-xxl {font-size:1.6em !important;} `;
37
- data += `.text-xxxl {font-size:2em !important;} `;
38
-
39
- data += `.text-i {font-style:italic !important;} `;
40
-
41
-
42
- sizes.forEach((s) => {
43
-
44
- data += `.app-size-${s} .text-center-${s}{text-align:center !important;} `;
45
- data += `.app-size-${s} .text-left-${s}{text-align:left !important;} `;
46
- data += `.app-size-${s} .text-right-${s}{text-align:right !important;} `;
47
-
48
- data += `.app-size-${s} .text-300-${s}{font-weight:300 !important;} `;
49
- data += `.app-size-${s} .text-400-${s}{font-weight:400 !important;} `;
50
- data += `.app-size-${s} .text-500-${s}{font-weight:500 !important;} `;
51
- data += `.app-size-${s} .text-600-${s}{font-weight:600 !important;} `;
52
- data += `.app-size-${s} .text-700-${s}{font-weight:700 !important;} `;
53
- data += `.app-size-${s} .text-800-${s}{font-weight:800 !important;} `;
54
- data += `.app-size-${s} .text-900-${s}{font-weight:900 !important;} `;
55
-
56
- data += `.app-size-${s} .text-300-${s}--hover:hover{font-weight:300 !important;} `;
57
- data += `.app-size-${s} .text-400-${s}--hover:hover{font-weight:400 !important;} `;
58
- data += `.app-size-${s} .text-500-${s}--hover:hover{font-weight:500 !important;} `;
59
- data += `.app-size-${s} .text-600-${s}--hover:hover{font-weight:600 !important;} `;
60
- data += `.app-size-${s} .text-700-${s}--hover:hover{font-weight:700 !important;} `;
61
- data += `.app-size-${s} .text-800-${s}--hover:hover{font-weight:800 !important;} `;
62
- data += `.app-size-${s} .text-900-${s}--hover:hover{font-weight:900 !important;} `;
63
-
64
-
65
- data += `.app-size-${s} .text-xxs-${s}{font-size:.70em !important;} `;
66
- data += `.app-size-${s} .text-xs-${s}{font-size:.83em !important;} `;
67
- data += `.app-size-${s} .text-s-${s}{font-size:.9em !important;} `;
68
- data += `.app-size-${s} .text-m-${s}{font-size:1.1em !important;} `;
69
- data += `.app-size-${s} .text-l-${s}{font-size:1.2em !important;} `;
70
- data += `.app-size-${s} .text-xl-${s}{font-size:1.4em !important;} `;
71
- data += `.app-size-${s} .text-xxl-${s}{font-size:1.6em !important;} `;
72
- data += `.app-size-${s} .text-xxxl-${s}{font-size:2em !important;} `;
73
-
74
- data += `.app-size-${s} .i-${s}{font-style:italic !important;} `;
75
-
76
- });
77
-
78
- return data;
79
-
80
- }
@@ -1,75 +0,0 @@
1
- export default function(sizes = [
2
- 'xl',
3
- 'd',
4
- 't',
5
- 'p'
6
- ]) {
7
-
8
- let data = ` `;
9
-
10
- // dynamic width
11
- for (let i = 1; i <= 100; i++) {
12
-
13
- // float
14
- data += `.width${i} { width:${i}%; } `;
15
- sizes.forEach((s) => {
16
-
17
- data += `.app-size-${s} .width${i}-${s} { width:${i}%; } `;
18
-
19
- });
20
-
21
- }
22
-
23
- // dynamic height
24
- for (let i = 1; i <= 1000; i++) {
25
-
26
- // float
27
- data += `.height${i} { height:${i}%; } `;
28
- sizes.forEach((s) => {
29
-
30
- data += `.app-size-${s} .height${i}-${s} { height:${i}%; } `;
31
-
32
- });
33
-
34
- }
35
-
36
-
37
- for (let i = 5; i <= 2000; i += 5) {
38
-
39
- // max width
40
- data += `.width-${i} { width:${i}px; } `;
41
- data += `.height-${i} { height:${i}px; } `;
42
- data += `.max-width-${i} { max-width:${i}px; } `;
43
- data += `.min-width-${i} { min-width:${i}px; } `;
44
- data += `.max-height-${i} { max-height:${i}px; } `;
45
- data += `.min-height-${i} { min-height:${i}px; } `;
46
-
47
- sizes.forEach((s) => {
48
-
49
- data += `.app-size-${s} .width-${i}-${s} { width:${i}px; } `;
50
- data += `.app-size-${s} .height-${i}-${s} { height:${i}px; } `;
51
- data += `.app-size-${s} .max-width-${i}-${s} { max-width:${i}px; } `;
52
- data += `.app-size-${s} .min-width-${i}-${s} { min-width:${i}px; } `;
53
- data += `.app-size-${s} .max-height-${i}-${s} { max-height:${i}px; } `;
54
- data += `.app-size-${s} .min-height-${i}-${s} { min-height:${i}px; } `;
55
-
56
- });
57
-
58
- }
59
-
60
-
61
- // span 1 - 12
62
- for (let i = 1; i <= 12; i++) {
63
-
64
- data += `.span${i} { width:${i / 12 * 100}%; } `;
65
- sizes.forEach((s) => {
66
-
67
- data += `.app-size-${s} .span${i}-${s} { width:${i / 12 * 100}%; } `;
68
-
69
- });
70
-
71
- }
72
-
73
- return data;
74
-
75
- }
@@ -1,40 +0,0 @@
1
- import grid from './dynamic/grid.js';
2
- import text from './dynamic/text.js';
3
- import spacing from './dynamic/spacing.js';
4
- import shortcuts from './dynamic/shortcuts.js';
5
- import width from './dynamic/width.js';
6
- import flex from './dynamic/flex.js';
7
-
8
- function dynamicCSS() {
9
-
10
- let sizes = [
11
- 'xl', // extra large
12
- 'd', // desktop
13
- 't', // tablet
14
- 'p' // phone
15
- ];
16
-
17
- let data = '';
18
-
19
- const pixels = 126;
20
-
21
- data += shortcuts(sizes);
22
- data += text(sizes);
23
- data += width(sizes);
24
- data += flex(sizes);
25
-
26
- data += spacing({
27
- sizes,
28
- pixels
29
- });
30
- data += grid({
31
- sizes,
32
- pixels
33
- });
34
-
35
- return data;
36
-
37
- }
38
-
39
-
40
- export { dynamicCSS };
@@ -1,143 +0,0 @@
1
- app.api = async function (route, data = {}) {
2
-
3
- const time = Date.now();
4
-
5
- if (!route) throw {
6
- reason: 'route undefined',
7
- route,
8
- data
9
- };
10
- if (route[0] === '/') route = route.substring(1);
11
- if (route.match(/[^a-zA-Z0-9/_\-]/)) throw {
12
- reason: 'route invalid',
13
- route,
14
- data
15
- };
16
-
17
- const deviceInfo = {
18
- device: 'web',
19
- userAgent: window.navigator.userAgent
20
- };
21
-
22
- let isFormData = false;
23
- let body;
24
-
25
- // Detect files
26
- if (data && Object.values(data).some((v) => v instanceof File || v instanceof FileList || (Array.isArray(v) && v[0] instanceof File))) {
27
-
28
- isFormData = true;
29
- const formData = new FormData();
30
-
31
- formData.append('awesomenessType', 'api');
32
- formData.append('meta', JSON.stringify(app.meta));
33
- formData.append('device', JSON.stringify(deviceInfo));
34
-
35
-
36
- for (const key in data) {
37
-
38
- const val = data[key];
39
-
40
- if (val instanceof FileList) {
41
-
42
- [ ...val ].forEach((f) => formData.append(key + '[]', f));
43
-
44
- } else if (Array.isArray(val) && val[0] instanceof File) {
45
-
46
- val.forEach((f) => formData.append(key + '[]', f));
47
-
48
- } else {
49
-
50
- formData.append(key, val);
51
-
52
- }
53
-
54
- }
55
-
56
- body = formData;
57
-
58
- } else {
59
-
60
- body = JSON.stringify({
61
- awesomenessType: 'api',
62
- meta: app.meta,
63
- device: deviceInfo,
64
- ... data,
65
- });
66
-
67
- }
68
-
69
- let headers = {
70
- 'Authorization': 'Bearer ' + (app.session ?? ''),
71
- };
72
-
73
- if (!isFormData) headers['Content-Type'] = 'application/json';
74
-
75
- let fetchOptions = {
76
- method: 'POST',
77
- headers,
78
- body,
79
- timeout: 5 * 60 * 1000,
80
- };
81
-
82
- try {
83
-
84
- if (app.testing) {
85
-
86
- console.log('%capi: ', 'color: blue; font-weight:bold;', route, isFormData ? body : JSON.parse(body));
87
-
88
- }
89
-
90
-
91
- const response = await fetch(app.apiBaseURL + route, fetchOptions);
92
-
93
- if (!response.ok) throw {
94
- status: response.status,
95
- ...(await response.json())
96
- };
97
-
98
- const doneData = await response.json();
99
-
100
- app.metaUpdates(doneData.meta);
101
-
102
- if (app.testing) {
103
-
104
- if (doneData.testing) {
105
-
106
- if (doneData.testing.perf) doneData.testing.perf.xhr = Date.now() - time;
107
- console.log('%ctesting: ', 'color: purple; font-weight:bold;', doneData.testing);
108
-
109
- }
110
-
111
- delete doneData.testing;
112
- console.log('%cmeta: ', 'color: #ff6f00; font-weight:bold;', doneData.meta ?? null);
113
- delete doneData.meta;
114
- console.log('%capi: ', 'color: green; font-weight:bold;', doneData);
115
-
116
- } else {
117
-
118
- delete doneData.testing;
119
- delete doneData.meta;
120
-
121
- }
122
-
123
-
124
- return doneData;
125
-
126
- } catch (errorData) {
127
-
128
- if (app.testing) console.log('%capi: ', 'color: red; font-weight:bold;', errorData);
129
-
130
- if (errorData.APP_SESSION) {
131
-
132
- app.session = null;
133
- app.user = null;
134
- window.localStorage.removeItem('awesomeness-appSession');
135
- location.reload();
136
-
137
- }
138
-
139
- throw errorData;
140
-
141
- }
142
-
143
- };