buner 0.0.2 → 1.0.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 (175) hide show
  1. package/.env +15 -0
  2. package/.env.development +6 -0
  3. package/.env.eshn +5 -0
  4. package/README.md +141 -5
  5. package/bin/buner.js +566 -0
  6. package/cli/README.md +1 -0
  7. package/cli/buner.ts +234 -0
  8. package/cli/cli.ts +125 -0
  9. package/cli/create-app.ts +59 -0
  10. package/cli/helpers/copy.ts +62 -0
  11. package/cli/helpers/format-files.ts +189 -0
  12. package/cli/helpers/git.ts +77 -0
  13. package/cli/helpers/install.ts +26 -0
  14. package/cli/helpers/is-folder-empty.ts +40 -0
  15. package/cli/helpers/is-writeable.ts +14 -0
  16. package/cli/helpers/make-dir.ts +7 -0
  17. package/cli/helpers/validate-pkg.ts +17 -0
  18. package/cli/install-template.ts +77 -0
  19. package/eslint.config.mjs +187 -0
  20. package/index.html +44 -0
  21. package/integration.ts +179 -0
  22. package/migrate-scss.ts +42 -0
  23. package/package.json +135 -7
  24. package/prerender.ts +229 -0
  25. package/public/.nojekyll +1 -0
  26. package/public/400.html +1 -0
  27. package/public/401.html +21 -0
  28. package/public/403.html +252 -0
  29. package/public/404.css +51 -0
  30. package/public/404.html +29 -0
  31. package/public/__images__/awww.jpeg +0 -0
  32. package/public/__images__/bat-body.png +0 -0
  33. package/public/__images__/bat-wing.png +0 -0
  34. package/public/__images__/haunted-house-background.png +0 -0
  35. package/public/__images__/haunted-house-foreground.png +0 -0
  36. package/public/assets/fonts/crimson-text/CrimsonText-Bold.ttf +0 -0
  37. package/public/assets/fonts/crimson-text/CrimsonText-BoldItalic.ttf +0 -0
  38. package/public/assets/fonts/crimson-text/CrimsonText-Italic.ttf +0 -0
  39. package/public/assets/fonts/crimson-text/CrimsonText-Regular.ttf +0 -0
  40. package/public/assets/fonts/crimson-text/CrimsonText-SemiBold.ttf +0 -0
  41. package/public/assets/fonts/crimson-text/CrimsonText-SemiBoldItalic.ttf +0 -0
  42. package/public/assets/fonts/crimson-text/CrimsonText.woff2 +0 -0
  43. package/public/assets/fonts/crimson-text/OFL.txt +93 -0
  44. package/public/assets/fonts/work-sans/OFL.txt +93 -0
  45. package/public/assets/fonts/work-sans/README.txt +81 -0
  46. package/public/assets/fonts/work-sans/WorkSans-Italic-VariableFont_wght.ttf +0 -0
  47. package/public/assets/fonts/work-sans/WorkSans-VariableFont_wght.ttf +0 -0
  48. package/public/assets/fonts/work-sans/WorkSans.woff2 +0 -0
  49. package/public/assets/fonts/work-sans/static/WorkSans-Black.ttf +0 -0
  50. package/public/assets/fonts/work-sans/static/WorkSans-BlackItalic.ttf +0 -0
  51. package/public/assets/fonts/work-sans/static/WorkSans-Bold.ttf +0 -0
  52. package/public/assets/fonts/work-sans/static/WorkSans-BoldItalic.ttf +0 -0
  53. package/public/assets/fonts/work-sans/static/WorkSans-ExtraBold.ttf +0 -0
  54. package/public/assets/fonts/work-sans/static/WorkSans-ExtraBoldItalic.ttf +0 -0
  55. package/public/assets/fonts/work-sans/static/WorkSans-ExtraLight.ttf +0 -0
  56. package/public/assets/fonts/work-sans/static/WorkSans-ExtraLightItalic.ttf +0 -0
  57. package/public/assets/fonts/work-sans/static/WorkSans-Italic.ttf +0 -0
  58. package/public/assets/fonts/work-sans/static/WorkSans-Light.ttf +0 -0
  59. package/public/assets/fonts/work-sans/static/WorkSans-LightItalic.ttf +0 -0
  60. package/public/assets/fonts/work-sans/static/WorkSans-Medium.ttf +0 -0
  61. package/public/assets/fonts/work-sans/static/WorkSans-MediumItalic.ttf +0 -0
  62. package/public/assets/fonts/work-sans/static/WorkSans-Regular.ttf +0 -0
  63. package/public/assets/fonts/work-sans/static/WorkSans-SemiBold.ttf +0 -0
  64. package/public/assets/fonts/work-sans/static/WorkSans-SemiBoldItalic.ttf +0 -0
  65. package/public/assets/fonts/work-sans/static/WorkSans-Thin.ttf +0 -0
  66. package/public/assets/fonts/work-sans/static/WorkSans-ThinItalic.ttf +0 -0
  67. package/public/assets/images/icons.svg +67 -0
  68. package/public/assets/images/logo.svg +14 -0
  69. package/public/assets/images/root.svg +49 -0
  70. package/public/assets/vendors/axios@0.24.0/axios.js +2275 -0
  71. package/public/assets/vendors/axios@0.24.0/axios.map +1 -0
  72. package/public/assets/vendors/axios@0.24.0/axios.min.js +2 -0
  73. package/public/assets/vendors/axios@0.24.0/axios.min.map +1 -0
  74. package/public/favicon.ico +0 -0
  75. package/public/favicon.svg +3 -0
  76. package/public/icon-128.png +0 -0
  77. package/public/icon-16.png +0 -0
  78. package/public/icon-192.png +0 -0
  79. package/public/icon-48.png +0 -0
  80. package/public/icon-512.png +0 -0
  81. package/public/json/avatar.json +42 -0
  82. package/public/manifest.webmanifest +29 -0
  83. package/public/mockServiceWorker.js +349 -0
  84. package/public/pl-states.svg +4 -0
  85. package/public/samples/01.svg +1 -0
  86. package/public/samples/Airbnb.svg +3 -0
  87. package/public/samples/Facebook.svg +3 -0
  88. package/public/samples/Google.svg +8 -0
  89. package/public/samples/Microsoft.svg +7 -0
  90. package/public/samples/Spotify.svg +3 -0
  91. package/public/samples/alexandra-stolz.svg +35 -0
  92. package/public/samples/browserconfig.xml +9 -0
  93. package/public/samples/cliff-curtis.jpg +0 -0
  94. package/public/samples/emilia-clarke.jpg +0 -0
  95. package/public/samples/favicon.ico +0 -0
  96. package/public/samples/icons/android-chrome-192x192.png +0 -0
  97. package/public/samples/icons/apple-touch-icon.png +0 -0
  98. package/public/samples/icons/favicon-144x144.png +0 -0
  99. package/public/samples/icons/favicon-150x150.png +0 -0
  100. package/public/samples/icons/favicon-16x16.png +0 -0
  101. package/public/samples/icons/favicon-32x32.png +0 -0
  102. package/public/samples/icons/favicon-48x48.png +0 -0
  103. package/public/samples/icons/favicon-70x70.png +0 -0
  104. package/public/samples/icons/favicon.ico +0 -0
  105. package/public/samples/image-1.svg +166 -0
  106. package/public/samples/image-2.svg +110 -0
  107. package/public/samples/image-3.svg +113 -0
  108. package/public/samples/janet-bray.svg +36 -0
  109. package/public/samples/kate-winslet.jpg +0 -0
  110. package/public/samples/manifest.json +19 -0
  111. package/public/samples/michelle-yeoh.jpg +0 -0
  112. package/public/samples/peg-legge.svg +37 -0
  113. package/public/samples/richard-guerra.svg +42 -0
  114. package/public/samples/rose-leslie.jpg +0 -0
  115. package/public/samples/sample-1.svg +365 -0
  116. package/public/samples/sample-2.svg +129 -0
  117. package/public/samples/sample-3.svg +93 -0
  118. package/public/samples/sample-4.svg +168 -0
  119. package/public/samples/sample-5.svg +155 -0
  120. package/public/samples/sample-6.svg +445 -0
  121. package/public/samples/sample-7.svg +404 -0
  122. package/public/samples/sample-8.png +0 -0
  123. package/public/staticwebapp.config.json +138 -0
  124. package/scripts.ts +56 -0
  125. package/server.ts +29 -0
  126. package/states.ts +63 -0
  127. package/styles.ts +232 -0
  128. package/tsconfig.json +71 -25
  129. package/types.d.ts +54 -0
  130. package/vite.config.ts +3 -0
  131. package/xpack/alias.ts +21 -0
  132. package/xpack/config.ts +59 -0
  133. package/xpack/create-server.ts +68 -0
  134. package/xpack/create-vite-dev-server.ts +33 -0
  135. package/xpack/deploy/deploy-inte.ts +3 -0
  136. package/xpack/filename.ts +43 -0
  137. package/xpack/hooks/build-start.ts +17 -0
  138. package/xpack/hooks/close-bundle.ts +19 -0
  139. package/xpack/hooks/handle-hot-update.ts +22 -0
  140. package/xpack/hooks/options.ts +55 -0
  141. package/xpack/hooks/resolve-dynamic-import.ts +18 -0
  142. package/xpack/hooks/transform-index-html.ts +18 -0
  143. package/xpack/hooks/transform.ts +72 -0
  144. package/xpack/hooks/write-bundle.ts +16 -0
  145. package/xpack/manual-chunk.ts +56 -0
  146. package/xpack/paths.ts +30 -0
  147. package/xpack/renderer.ts +141 -0
  148. package/xpack/root/active-item-options.tsx +98 -0
  149. package/xpack/root/frame-controls.tsx +139 -0
  150. package/xpack/root/index.tsx +107 -0
  151. package/xpack/root/rendered-item.tsx +25 -0
  152. package/xpack/root/root-context.ts +22 -0
  153. package/xpack/root/root-nav.tsx +162 -0
  154. package/xpack/root/state-animation-html.tsx +18 -0
  155. package/xpack/root/template.tsx +23 -0
  156. package/xpack/root/use-click-outside.ts +37 -0
  157. package/xpack/scripts/color-mode.entry.ts +28 -0
  158. package/xpack/scripts/mock-api.entry.ts +11 -0
  159. package/xpack/scripts/pl-states.entry.ts +321 -0
  160. package/xpack/scripts/root.entry.ts +135 -0
  161. package/xpack/scripts/theme-critical.entry.ts +20 -0
  162. package/xpack/states.schema.json +61 -0
  163. package/xpack/styles/_border.scss +22 -0
  164. package/xpack/styles/_breakpoint.scss +117 -0
  165. package/xpack/styles/_form.scss +23 -0
  166. package/xpack/styles/_px2rem.scss +5 -0
  167. package/xpack/styles/_reset.scss +134 -0
  168. package/xpack/styles/_state-toggle.scss +121 -0
  169. package/xpack/styles/_theme.scss +68 -0
  170. package/xpack/styles/_top-panel.scss +87 -0
  171. package/xpack/styles/_xpack-root.scss +322 -0
  172. package/xpack/styles/pl-states.scss +308 -0
  173. package/xpack/styles/root.scss +129 -0
  174. package/.github/workflows/deploy.yaml +0 -32
  175. package/index.ts +0 -1
Binary file
@@ -0,0 +1,138 @@
1
+ {
2
+ "routes": [
3
+ {
4
+ "route": "/.auth/login/aad",
5
+ "statusCode": 404,
6
+ "allowedRoles": [
7
+ "anonymous"
8
+ ],
9
+ "headers": {
10
+ "X-Robots-Tag": "noindex, nofollow"
11
+ }
12
+ },
13
+ {
14
+ "route": "/.auth/login/twitter",
15
+ "statusCode": 404,
16
+ "allowedRoles": [
17
+ "anonymous"
18
+ ],
19
+ "headers": {
20
+ "X-Robots-Tag": "noindex, nofollow"
21
+ }
22
+ },
23
+ {
24
+ "route": "/logout",
25
+ "redirect": "/.auth/logout",
26
+ "allowedRoles": [
27
+ "anonymous"
28
+ ],
29
+ "headers": {
30
+ "X-Robots-Tag": "noindex, nofollow"
31
+ }
32
+ },
33
+ {
34
+ "route": "/api/avatar",
35
+ "rewrite": "/json/avatar.json",
36
+ "allowedRoles": [
37
+ "anonymous"
38
+ ],
39
+ "headers": {
40
+ "X-Robots-Tag": "noindex, nofollow",
41
+ "Content-Type": "application/json"
42
+ }
43
+ },
44
+ {
45
+ "route": "/api",
46
+ "allowedRoles": [
47
+ "anonymous"
48
+ ],
49
+ "headers": {
50
+ "X-Robots-Tag": "noindex, nofollow"
51
+ }
52
+ },
53
+ {
54
+ "route": "/favicon.*",
55
+ "allowedRoles": [
56
+ "anonymous"
57
+ ],
58
+ "headers": {
59
+ "X-Robots-Tag": "noindex, nofollow"
60
+ }
61
+ },
62
+ {
63
+ "route": "/40{0,1,2,3,4}.html",
64
+ "allowedRoles": [
65
+ "anonymous"
66
+ ],
67
+ "headers": {
68
+ "X-Robots-Tag": "noindex, nofollow"
69
+ }
70
+ },
71
+ {
72
+ "route": "/*.{png,jpg,jpeg,gif,woff2,otf,ttf,pdf,doc,docx,ppt,pptx,xls,xlsx,csv,rtf,zip,rar,7z,webp}",
73
+ "headers": {
74
+ "Cache-Control": "public, max-age=604800, immutable",
75
+ "X-Robots-Tag": "noindex, nofollow"
76
+ },
77
+ "allowedRoles": [
78
+ "anonymous"
79
+ ]
80
+ },
81
+ {
82
+ "route": "/*.{js,css,svg}",
83
+ "headers": {
84
+ "Cache-Control": "public, max-age=3600, immutable",
85
+ "X-Robots-Tag": "noindex, nofollow"
86
+ },
87
+ "allowedRoles": [
88
+ "anonymous"
89
+ ]
90
+ },
91
+ {
92
+ "route": "/*.{pdf,doc,docx,ppt,pptx,xls,xlsx,csv,rtf,zip,rar,7z}",
93
+ "headers": {
94
+ "Content-Disposition": "attachment",
95
+ "Content-Type": "application/octet-stream",
96
+ "Content-Transfer-Encoding": "binary",
97
+ "X-Robots-Tag": "noindex, nofollow"
98
+ },
99
+ "allowedRoles": [
100
+ "anonymous"
101
+ ]
102
+ },
103
+ {
104
+ "route": "/*.{html,json}",
105
+ "allowedRoles": [
106
+ "anonymous"
107
+ ],
108
+ "headers": {
109
+ "X-Robots-Tag": "noindex, nofollow"
110
+ }
111
+ }
112
+ ],
113
+ "responseOverrides": {
114
+ "400": {
115
+ "rewrite": "/400.html"
116
+ },
117
+ "401": {
118
+ "rewrite": "/401.html"
119
+ },
120
+ "403": {
121
+ "rewrite": "/403.html"
122
+ },
123
+ "404": {
124
+ "rewrite": "/404.html"
125
+ }
126
+ },
127
+ "globalHeaders": {
128
+ "content-security-policy": "default-src * data: blob: filesystem: about: ws: wss: 'unsafe-inline' 'unsafe-eval'; script-src * data: blob: 'unsafe-inline' 'unsafe-eval'; connect-src * data: blob: 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src * data: blob:; style-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline'; frame-ancestors * data: blob:; object-src * data: blob:; media-src * data: blob:; worker-src * data: blob:;",
129
+ "Access-Control-Allow-Origin": "*",
130
+ "Access-Control-Allow-Methods": "*"
131
+ },
132
+ "mimeTypes": {
133
+ ".json": "text/json"
134
+ },
135
+ "platform": {
136
+ "apiRuntime": "node:18"
137
+ }
138
+ }
package/scripts.ts ADDED
@@ -0,0 +1,56 @@
1
+ /* eslint-disable no-console */
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+
5
+ import chokidar from 'chokidar';
6
+ import { glob } from 'glob';
7
+ import slash from 'slash';
8
+ import { transformWithEsbuild } from 'vite';
9
+
10
+ const log = console.log.bind(console);
11
+
12
+ const scriptCompile = async (inputPath: string) => {
13
+ console.log('compile:', slash(inputPath));
14
+
15
+ const code = fs.readFileSync(inputPath, 'utf8');
16
+
17
+ return transformWithEsbuild(code, inputPath, {
18
+ minify: true,
19
+ format: 'esm',
20
+ sourcemap: path.basename(inputPath).includes('critical') ? false : 'external',
21
+ })
22
+ .then((result) => {
23
+ const savePath = path.resolve('public/assets/js/' + path.parse(inputPath).name + '.js');
24
+ const saveDir = path.dirname(savePath);
25
+
26
+ if (!fs.existsSync(saveDir)) {
27
+ fs.mkdirSync(saveDir);
28
+ }
29
+
30
+ fs.writeFileSync(savePath, result.code);
31
+ })
32
+ .catch((error) => {
33
+ log(error);
34
+ });
35
+ };
36
+
37
+ const run = async () => {
38
+ if (process.argv.includes('--watch')) {
39
+ const watcher = chokidar.watch('src/assets/scripts/**/*.{js,jsx,ts,tsx}');
40
+
41
+ watcher
42
+ .on('add', scriptCompile)
43
+ .on('change', scriptCompile)
44
+ .on('unlink', (path) => log(`File ${path} has been removed`));
45
+ } else {
46
+ const pool: Promise<any>[] = [];
47
+
48
+ glob.sync('src/assets/scripts/**/*.{js,jsx,ts,tsx}').forEach((p) => pool.push(scriptCompile(p)));
49
+
50
+ await Promise.all(pool);
51
+ }
52
+ };
53
+
54
+ await run();
55
+
56
+ export {};
package/server.ts ADDED
@@ -0,0 +1,29 @@
1
+ /* eslint-disable no-console */
2
+ import path from 'path';
3
+
4
+ import { loadEnv } from 'vite';
5
+
6
+ import { startServer } from './xpack/create-server.js';
7
+
8
+ console.log('[INIT] server');
9
+
10
+ const argvModeIndex = process.argv.indexOf('--mode');
11
+ const mode =
12
+ argvModeIndex >= 0 && argvModeIndex < process.argv.length - 1 && !process.argv[argvModeIndex + 1].startsWith('-')
13
+ ? process.argv[argvModeIndex + 1]
14
+ : 'production';
15
+ const root = process.cwd();
16
+ const xpackEnv = loadEnv(mode, root);
17
+ const isTest = !!xpackEnv.VITE_TEST_BUILD || process.env.NODE_ENV === 'test';
18
+ const port = xpackEnv.VITE_PORT ? parseInt(xpackEnv.VITE_PORT) : 5000;
19
+
20
+ if (!isTest) {
21
+ console.log(root);
22
+ startServer({
23
+ root,
24
+ isTest,
25
+ port,
26
+ hmrPort: port + 1,
27
+ baseUrl: xpackEnv.VITE_BASE_URL,
28
+ });
29
+ }
package/states.ts ADDED
@@ -0,0 +1,63 @@
1
+ /* eslint-disable no-console */
2
+ import fs from 'fs';
3
+
4
+ import chokidar from 'chokidar';
5
+ import debounce from 'debounce';
6
+ import { glob } from 'glob';
7
+
8
+ const isWatch = process.argv.includes('--watch');
9
+ const log = console.log.bind(console);
10
+
11
+ const states: { [path: string]: string } = {};
12
+
13
+ const buildStates = debounce(() => {
14
+ const output: any[] = [];
15
+
16
+ const keys = Object.keys(states);
17
+
18
+ [].forEach.call(keys, (key) => {
19
+ const state = states[key];
20
+
21
+ if (!state) {
22
+ return;
23
+ }
24
+
25
+ try {
26
+ output.push(JSON.parse(state));
27
+ } catch (error: any) {
28
+ console.log(error);
29
+ }
30
+ });
31
+
32
+ const json = JSON.stringify(output, null, ' ');
33
+
34
+ fs.writeFileSync('public/pl-states.json', json);
35
+ }, 500);
36
+
37
+ const setStates = (statePath: string) => {
38
+ const state = fs.readFileSync(statePath, 'utf-8');
39
+
40
+ states[statePath] = state;
41
+ buildStates();
42
+ };
43
+
44
+ const removeStates = (statePath: string) => {
45
+ delete states[statePath];
46
+ buildStates();
47
+ };
48
+
49
+ if (isWatch) {
50
+ const watcher = chokidar.watch('src/**/*.states.json');
51
+
52
+ watcher
53
+ .on('ready', () => {
54
+ log('States are ready!');
55
+ })
56
+ .on('add', (path) => setStates(path))
57
+ .on('change', (path) => setStates(path))
58
+ .on('unlink', (path) => removeStates(path));
59
+ } else {
60
+ glob.sync('src/**/*.states.json').forEach((path) => setStates(path));
61
+ }
62
+
63
+ export {};
package/styles.ts ADDED
@@ -0,0 +1,232 @@
1
+ /* eslint-disable no-console */
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+ import { fileURLToPath, pathToFileURL } from 'url';
5
+
6
+ import { watch } from 'chokidar';
7
+ import * as sass from 'sass';
8
+ import slash from 'slash';
9
+ import debounce from 'debounce';
10
+ import { glob } from 'glob';
11
+ import postcss, { ProcessOptions } from 'postcss';
12
+ import autoprefixer from 'autoprefixer';
13
+ import cssnano from 'cssnano';
14
+
15
+ const isWatch = process.argv.includes('--watch');
16
+ const outDir = './public/assets/css';
17
+
18
+ if (!isWatch && fs.existsSync(outDir)) {
19
+ fs.rmSync(outDir, { force: true, recursive: true });
20
+ }
21
+
22
+ if (!fs.existsSync(outDir)) {
23
+ fs.mkdirSync(outDir, { recursive: true });
24
+ }
25
+
26
+ // Something to use when events are received.
27
+ const log = console.log.bind(console);
28
+
29
+ const prepareCssFileContent = ({
30
+ srcFile,
31
+ includeMixins = true,
32
+ includeAbstracts = true,
33
+ }: {
34
+ srcFile: string;
35
+ includeMixins?: boolean;
36
+ includeAbstracts?: boolean;
37
+ }) => {
38
+ return [
39
+ includeAbstracts
40
+ ? slash(`@use '${path.relative(path.dirname(srcFile), path.resolve('src/assets/styles/00-abstracts/abstracts'))}' as *;\n`)
41
+ : undefined,
42
+ includeMixins ? slash(`@use '${path.relative(path.dirname(srcFile), path.resolve('src/assets/styles/01-mixins/mixins'))}' as *;\n`) : undefined,
43
+ fs.readFileSync(srcFile, 'utf-8'),
44
+ ].filter(Boolean);
45
+ };
46
+
47
+ const stringOptions = (srcFile: string): sass.StringOptions<'sync' | 'async'> => {
48
+ const options: sass.StringOptions<'sync' | 'async'> = {
49
+ sourceMap: true,
50
+ sourceMapIncludeSources: true,
51
+ syntax: 'scss',
52
+ style: 'compressed',
53
+ url: pathToFileURL(path.resolve(srcFile)),
54
+ importer: {
55
+ canonicalize(url) {
56
+ return new URL(url);
57
+ },
58
+ load(canonicalUrl: URL) {
59
+ let filePath = fileURLToPath(canonicalUrl);
60
+
61
+ if (!filePath.endsWith('.scss')) {
62
+ const parentDir = path.dirname(filePath);
63
+ const fileName = path.basename(filePath);
64
+
65
+ filePath = path.join(parentDir, fileName + '.scss');
66
+
67
+ if (!fs.existsSync(filePath)) {
68
+ filePath = path.join(parentDir, '_' + fileName + '.scss');
69
+ }
70
+ }
71
+
72
+ if (!fs.existsSync(filePath)) return null;
73
+
74
+ if (filePath.includes('abstracts') || filePath.includes('_mixins') || filePath.includes('_base') || filePath.includes('xpack'))
75
+ return {
76
+ contents: fs.readFileSync(filePath, 'utf-8'),
77
+ syntax: 'scss',
78
+ };
79
+
80
+ let content = prepareCssFileContent({ srcFile: filePath });
81
+
82
+ if (filePath.includes('mixins')) {
83
+ content = prepareCssFileContent({ srcFile: filePath, includeMixins: false });
84
+ }
85
+
86
+ return {
87
+ contents: content.join(''),
88
+ syntax: 'scss',
89
+ };
90
+ },
91
+ },
92
+ };
93
+
94
+ return options;
95
+ };
96
+
97
+ const compile = (srcFile: string, options: { prefix?: string; isReady: boolean }) => {
98
+ if (options.isReady) {
99
+ log('compile:', slash(srcFile));
100
+ }
101
+
102
+ if (path.basename(srcFile).startsWith('_')) {
103
+ return;
104
+ }
105
+
106
+ const name =
107
+ path.basename(srcFile) === 'index.scss' ? path.basename(path.dirname(srcFile)) + '.css' : path.basename(srcFile).replace(/\.scss$/gi, '.css');
108
+
109
+ const outFile = (options.prefix ?? '') + name;
110
+
111
+ const cssStrings = srcFile.includes('xpack') ? [fs.readFileSync(srcFile, 'utf-8')] : prepareCssFileContent({ srcFile });
112
+
113
+ if (srcFile.includes('style-base') || srcFile.includes('style-all')) {
114
+ glob.sync('./src/atoms/**/*.scss').forEach((atomPath) => {
115
+ if (!path.basename(atomPath).startsWith('_')) {
116
+ cssStrings.push(sass.compileString(prepareCssFileContent({ srcFile: atomPath }).join(''), stringOptions(atomPath)).css);
117
+ }
118
+ });
119
+
120
+ glob.sync('./src/molecules/**/*.scss').forEach((molPath) => {
121
+ if (!path.basename(molPath).startsWith('_')) {
122
+ cssStrings.push(sass.compileString(prepareCssFileContent({ srcFile: molPath }).join(''), stringOptions(molPath)).css);
123
+ }
124
+ });
125
+ }
126
+
127
+ sass
128
+ .compileStringAsync(cssStrings.join(''), stringOptions(srcFile))
129
+ .then((result) => postcssProcess(result, srcFile, outFile))
130
+ .catch((error) => {
131
+ log(error);
132
+ });
133
+ };
134
+
135
+ const postcssProcess = (result: sass.CompileResult, from: string, to: string) => {
136
+ const postcssOptions: ProcessOptions = { from: pathToFileURL(from).href, to, map: { prev: result.sourceMap, absolute: false } };
137
+
138
+ postcss([autoprefixer({ grid: true }), cssnano])
139
+ .process(result.css, postcssOptions)
140
+ .then((result) => {
141
+ fs.writeFileSync(path.join(outDir, to), result.css + (result.map ? `\n/*# sourceMappingURL=${to}.map */` : ''));
142
+
143
+ if (result.map) {
144
+ fs.writeFileSync(path.join(outDir, to + '.map'), result.map.toString());
145
+ }
146
+ });
147
+ };
148
+
149
+ const styleOrganisms = debounce((isReady: boolean) => {
150
+ const paths = glob.sync('src/organisms/**/*.scss', { nodir: true });
151
+
152
+ [].forEach.call(paths, (p: string) => styleOrganism(p, isReady));
153
+ }, 200);
154
+
155
+ const styleTemplates = debounce((isReady: boolean) => {
156
+ const paths = glob.sync('src/templates/**/*.scss', { nodir: true });
157
+
158
+ [].forEach.call(paths, (p: string) => styleTemplate(p, isReady));
159
+ }, 200);
160
+
161
+ const styleBase = debounce((isReady: boolean) => compile('src/assets/styles/style-base.scss', { isReady }), 200);
162
+ const stylePlState = debounce((isReady: boolean) => compile('xpack/styles/pl-states.scss', { isReady }), 200);
163
+ const styleRoot = debounce((isReady: boolean) => compile('xpack/styles/root.scss', { isReady }), 200);
164
+ const styleOrganism = (srcFile: string, isReady: boolean) => compile(srcFile, { prefix: 'b-', isReady });
165
+ const styleTemplate = (srcFile: string, isReady: boolean) => compile(srcFile, { prefix: 'p-', isReady });
166
+
167
+ const sassCompile = (inputPath: string, isReady: boolean) => {
168
+ const p = slash(inputPath);
169
+
170
+ if (p.startsWith('src/assets/styles/00-abstracts/') || p.startsWith('src/assets/styles/01-mixins/')) {
171
+ styleBase(isReady);
172
+ styleOrganisms(isReady);
173
+ styleTemplates(isReady);
174
+ stylePlState(isReady);
175
+ }
176
+
177
+ if (p.startsWith('src/atoms') || p.startsWith('src/molecules') || p.startsWith('src/assets/styles/02-base')) {
178
+ styleBase(isReady);
179
+ }
180
+
181
+ if (p.startsWith('src/organisms')) {
182
+ if (path.basename(p).startsWith('_')) {
183
+ glob
184
+ .sync(path.dirname(p) + '/*.scss', { nodir: true })
185
+ .filter((p) => !path.basename(p).startsWith('_'))
186
+ .forEach((p) => styleOrganism(p, isReady));
187
+ } else {
188
+ styleOrganism(p, isReady);
189
+ }
190
+ }
191
+
192
+ if (p.startsWith('src/templates')) {
193
+ if (path.basename(p).startsWith('_')) {
194
+ glob
195
+ .sync(path.dirname(p) + '/*.scss', { nodir: true })
196
+ .filter((p) => !path.basename(p).startsWith('_'))
197
+ .forEach((p) => styleTemplate(p, isReady));
198
+ } else {
199
+ styleTemplate(p, isReady);
200
+ }
201
+ }
202
+
203
+ if (p.startsWith('xpack/styles/pl-states')) {
204
+ stylePlState(isReady);
205
+ } else if (p.startsWith('xpack/styles')) {
206
+ styleRoot(isReady);
207
+ }
208
+ };
209
+
210
+ if (isWatch) {
211
+ const watcher = watch(['src', 'xpack/styles'], { ignored: (path, stats) => !!stats?.isFile() && !path.endsWith('.scss') });
212
+ let isReady = false;
213
+
214
+ watcher
215
+ .on('ready', () => {
216
+ log('SCSS ready!');
217
+ isReady = true;
218
+ })
219
+ .on('add', (path) => sassCompile(path, isReady))
220
+ .on('change', (path) => sassCompile(path, isReady))
221
+ .on('unlink', (path) => log(`File ${path} has been removed`));
222
+ } else {
223
+ styleBase(true);
224
+ stylePlState(true);
225
+
226
+ glob
227
+ .sync(['src/{organisms,templates}/**/*.scss', 'xpack/styles/**/*.scss'])
228
+ .filter((p) => !path.basename(p).startsWith('_'))
229
+ .forEach((path) => sassCompile(path, true));
230
+ }
231
+
232
+ export {};
package/tsconfig.json CHANGED
@@ -1,29 +1,75 @@
1
1
  {
2
2
  "compilerOptions": {
3
- // Environment setup & latest features
4
- "lib": ["ESNext"],
5
3
  "target": "ESNext",
6
- "module": "Preserve",
7
- "moduleDetection": "force",
8
- "jsx": "react-jsx",
9
- "allowJs": true,
10
-
11
- // Bundler mode
12
- "moduleResolution": "bundler",
13
- "allowImportingTsExtensions": true,
14
- "verbatimModuleSyntax": true,
15
- "noEmit": true,
16
-
17
- // Best practices
18
- "strict": true,
4
+ "useDefineForClassFields": true,
5
+ "lib": [
6
+ "DOM",
7
+ "DOM.Iterable",
8
+ "ESNext"
9
+ ],
10
+ "composite": true,
11
+ "allowJs": false,
19
12
  "skipLibCheck": true,
20
- "noFallthroughCasesInSwitch": true,
21
- "noUncheckedIndexedAccess": true,
22
- "noImplicitOverride": true,
23
-
24
- // Some stricter flags (disabled by default)
25
- "noUnusedLocals": false,
26
- "noUnusedParameters": false,
27
- "noPropertyAccessFromIndexSignature": false
28
- }
29
- }
13
+ "esModuleInterop": false,
14
+ "allowSyntheticDefaultImports": true,
15
+ "strict": true,
16
+ "forceConsistentCasingInFileNames": true,
17
+ "module": "ESNext",
18
+ "moduleResolution": "Node",
19
+ "resolveJsonModule": true,
20
+ "isolatedModules": true,
21
+ "noEmit": true,
22
+ "jsx": "react-jsx",
23
+ "baseUrl": ".",
24
+ "sourceMap": true,
25
+ "paths": {
26
+ "@_types/*": [
27
+ "./src/_types/*"
28
+ ],
29
+ "@helpers/*": [
30
+ "./src/_helpers/*"
31
+ ],
32
+ "@assets/*": [
33
+ "./src/assets/*"
34
+ ],
35
+ "@data/*": [
36
+ "./src/_data/*"
37
+ ],
38
+ "@atoms/*": [
39
+ "./src/atoms/*"
40
+ ],
41
+ "@molecules/*": [
42
+ "./src/molecules/*"
43
+ ],
44
+ "@organisms/*": [
45
+ "./src/organisms/*"
46
+ ],
47
+ "@templates/*": [
48
+ "./src/templates/*"
49
+ ],
50
+ "@pages/*": [
51
+ "./src/pages/*"
52
+ ],
53
+ "@_http/*": [
54
+ "./src/_http/*"
55
+ ],
56
+ "@_api/*": [
57
+ "./src/_api/*"
58
+ ],
59
+ "@mocks/*": [
60
+ "./src/mocks/*"
61
+ ],
62
+ "@xpack/*": [
63
+ "./xpack/*"
64
+ ],
65
+ }
66
+ },
67
+ "include": [
68
+ "**/*.ts",
69
+ "**/*.tsx",
70
+ "**/*.json"
71
+ ],
72
+ "exclude": [
73
+ "node_modules"
74
+ ]
75
+ }
package/types.d.ts ADDED
@@ -0,0 +1,54 @@
1
+ declare module '*.svg?raw' {
2
+ const value: string;
3
+ export default value;
4
+ }
5
+
6
+ declare module '*.htm?raw' {
7
+ const value: string;
8
+ export default value;
9
+ }
10
+
11
+ declare const CONTENT: {
12
+ forgotpassword_link: string;
13
+ createaccount_intro: string;
14
+ button_signin: string;
15
+ social_intro: string;
16
+ remember_me: string;
17
+ unknown_error: string;
18
+ divider_title: string;
19
+ local_intro_email: string;
20
+ logonIdentifier_email: string;
21
+ requiredField_email: string;
22
+ invalid_email: string;
23
+ email_pattern: string;
24
+ local_intro_username: string;
25
+ logonIdentifier_username: string;
26
+ requiredField_username: string;
27
+ password: string;
28
+ requiredField_password: string;
29
+ createaccount_link: string;
30
+ cancel_message: string;
31
+ invalid_password: string;
32
+ createaccount_one_link: string;
33
+ createaccount_two_links: string;
34
+ createaccount_three_links: string;
35
+ local_intro_generic: string;
36
+ requiredField_generic: string;
37
+ invalid_generic: string;
38
+ heading: string;
39
+ };
40
+
41
+ declare module '*.htm?raw' {
42
+ const value: string;
43
+ export default value;
44
+ }
45
+
46
+ declare module '*.cshtml?raw' {
47
+ const value: string;
48
+ export default value;
49
+ }
50
+
51
+ declare module '*.svg?raw' {
52
+ const value: string;
53
+ export default value;
54
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,3 @@
1
+ import config from './xpack/config';
2
+
3
+ export default config;