buner 0.0.2 → 1.0.1

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 (177) 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/react-loader-init.tsx +4 -0
  148. package/xpack/react-loader.tsx +54 -0
  149. package/xpack/renderer.ts +141 -0
  150. package/xpack/root/active-item-options.tsx +98 -0
  151. package/xpack/root/frame-controls.tsx +139 -0
  152. package/xpack/root/index.tsx +107 -0
  153. package/xpack/root/rendered-item.tsx +25 -0
  154. package/xpack/root/root-context.ts +22 -0
  155. package/xpack/root/root-nav.tsx +162 -0
  156. package/xpack/root/state-animation-html.tsx +18 -0
  157. package/xpack/root/template.tsx +23 -0
  158. package/xpack/root/use-click-outside.ts +37 -0
  159. package/xpack/scripts/color-mode.entry.ts +28 -0
  160. package/xpack/scripts/mock-api.entry.ts +11 -0
  161. package/xpack/scripts/pl-states.entry.ts +321 -0
  162. package/xpack/scripts/root.entry.ts +135 -0
  163. package/xpack/scripts/theme-critical.entry.ts +20 -0
  164. package/xpack/states.schema.json +61 -0
  165. package/xpack/styles/_border.scss +22 -0
  166. package/xpack/styles/_breakpoint.scss +117 -0
  167. package/xpack/styles/_form.scss +23 -0
  168. package/xpack/styles/_px2rem.scss +5 -0
  169. package/xpack/styles/_reset.scss +134 -0
  170. package/xpack/styles/_state-toggle.scss +121 -0
  171. package/xpack/styles/_theme.scss +68 -0
  172. package/xpack/styles/_top-panel.scss +87 -0
  173. package/xpack/styles/_xpack-root.scss +322 -0
  174. package/xpack/styles/pl-states.scss +308 -0
  175. package/xpack/styles/root.scss +129 -0
  176. package/.github/workflows/deploy.yaml +0 -32
  177. package/index.ts +0 -1
@@ -0,0 +1,42 @@
1
+ /* eslint-disable no-console */
2
+ import { execSync } from 'child_process';
3
+
4
+ import { glob } from 'glob';
5
+
6
+ const migration = async () => {
7
+ const usableFiles = ['./xpack/styles/root.scss'];
8
+
9
+ const forwardableFiles = [
10
+ './src/assets/styles/style-base.scss',
11
+ './src/assets/styles/style.all.scss',
12
+ './src/assets/styles/00-abstracts/_abstracts.scss',
13
+ './src/assets/styles/01-mixins/_mixins.scss',
14
+ './src/assets/styles/02-base/_base.scss',
15
+ ];
16
+
17
+ for (const file of forwardableFiles) {
18
+ try {
19
+ console.log(`Migrating ${file}`);
20
+ execSync(`bunx sass-migrator --migrate-deps module --forward=all ${file}`, { stdio: 'inherit' });
21
+ } catch (err) {
22
+ console.error((err as Error).message);
23
+ }
24
+ }
25
+
26
+ const componentFiles = await glob(['./src/atoms/**/*.scss', './src/molecules/**/*.scss', './src/organisms/**/*.scss'], { nodir: true });
27
+
28
+ const allFiles = [...usableFiles, ...componentFiles];
29
+
30
+ for (const file of allFiles) {
31
+ try {
32
+ console.log(`Migrating ${file}`);
33
+ execSync(`bunx sass-migrator module --migrate-deps ${file}`, { stdio: 'inherit' });
34
+ } catch (err) {
35
+ console.error((err as Error).message);
36
+ }
37
+ }
38
+ };
39
+
40
+ migration().catch((err) => {
41
+ console.error('An error occurred during migration:', (err as Error).message);
42
+ });
package/package.json CHANGED
@@ -1,15 +1,143 @@
1
1
  {
2
- "version": "0.0.2",
3
2
  "name": "buner",
4
- "module": "index.ts",
3
+ "version": "1.0.1",
4
+ "description": "Frontend build toolkit for Vite + React SSR projects — SCSS pipeline, prerender, SSR dev server, and backend integration.",
5
5
  "type": "module",
6
- "devDependencies": {
7
- "@types/bun": "latest"
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/precise-alloy/buner.git"
10
+ },
11
+ "homepage": "https://www.npmjs.com/package/buner",
12
+ "keywords": [
13
+ "vite",
14
+ "react",
15
+ "ssr",
16
+ "scss",
17
+ "prerender",
18
+ "frontend",
19
+ "build-tool",
20
+ "cli"
21
+ ],
22
+ "bin": {
23
+ "buner": "./bin/buner.js"
24
+ },
25
+ "files": [
26
+ "bin",
27
+ "cli",
28
+ "xpack",
29
+ "public",
30
+ "server.ts",
31
+ "prerender.ts",
32
+ "integration.ts",
33
+ "styles.ts",
34
+ "scripts.ts",
35
+ "states.ts",
36
+ "migrate-scss.ts",
37
+ "vite.config.ts",
38
+ "index.html",
39
+ "tsconfig.json",
40
+ "eslint.config.mjs",
41
+ "types.d.ts",
42
+ ".env",
43
+ ".env.development",
44
+ ".env.eshn",
45
+ "README.md"
46
+ ],
47
+ "scripts": {
48
+ "start": "bun run dev",
49
+ "predev": "bun upgrade",
50
+ "dev": "concurrently --kill-others \"bun styles.ts --watch\" \"bun states.ts --watch\" \"cross-env scriptOnly=true vite build --mode development --watch\" \"bun server.ts --mode development\"",
51
+ "serve": "bun server.ts",
52
+ "watch": "bun server.ts",
53
+ "build": "bun run build:static && bun run build:server",
54
+ "build:eshn": "bun run build:static:eshn && bun run build:server:eshn",
55
+ "preview": "vite preview",
56
+ "build:server": "vite build --ssr src/entry-server.tsx --outDir dist/server",
57
+ "build:server:eshn": "vite build --ssr src/entry-server.tsx --outDir dist/server --mode eshn",
58
+ "build:static": "vite build --outDir dist/static",
59
+ "build:static:eshn": "vite build --outDir dist/static --mode eshn",
60
+ "generate": "bun states.ts && bun run styles && bun run build && bun prerender.ts --add-hash",
61
+ "eshn": "bun states.ts && bun run styles && bun run build:eshn && bun prerender.ts --add-hash --mode eshn",
62
+ "inte": "bun run styles && bun run build && bun prerender.ts && bun integration.ts",
63
+ "styles": "bun styles.ts",
64
+ "format": "prettier --write .",
65
+ "lint": "eslint --fix",
66
+ "cli:start": "vite build -c vite.cli.config.ts --watch",
67
+ "cli:build": "vite build -c vite.cli.config.ts"
68
+ },
69
+ "engines": {
70
+ "node": ">=20.0.0"
71
+ },
72
+ "dependencies": {
73
+ "@vitejs/plugin-react": "^5.1.4",
74
+ "autoprefixer": "^10.4.27",
75
+ "chalk": "^5.5.0",
76
+ "cheerio": "^1.2.0",
77
+ "chokidar": "^4.0.3",
78
+ "commander": "^14.0.3",
79
+ "concurrently": "^9.2.0",
80
+ "cross-env": "^10.1.0",
81
+ "cssnano": "^7.1.0",
82
+ "debounce": "^3.0.0",
83
+ "express": "^5.2.1",
84
+ "glob": "^13.0.6",
85
+ "globby": "^16.1.1",
86
+ "js-beautify": "^1.15.4",
87
+ "lodash": "^4.17.21",
88
+ "magic-string": "^0.30.17",
89
+ "node-fetch": "^3.3.2",
90
+ "postcss": "^8.5.8",
91
+ "prompts": "^2.4.2",
92
+ "sass": "^1.89.2",
93
+ "slash": "^5.1.0",
94
+ "validate-npm-package-name": "^7.0.0",
95
+ "vite": "^7.0.6"
8
96
  },
9
97
  "peerDependencies": {
10
- "typescript": "^5"
98
+ "react": "^18.0.0 || ^19.0.0",
99
+ "react-dom": "^18.0.0 || ^19.0.0",
100
+ "react-router-dom": "^6.0.0 || ^7.0.0"
101
+ },
102
+ "devDependencies": {
103
+ "@eslint/compat": "^2.0.0",
104
+ "@next/eslint-plugin-next": "^16.0.8",
105
+ "@types/css": "^0.0.38",
106
+ "@types/debounce": "^1.2.4",
107
+ "@types/express": "^5.0.6",
108
+ "@types/js-beautify": "^1.14.3",
109
+ "@types/lodash": "^4.17.24",
110
+ "@types/node": "^24.11.0",
111
+ "@types/prettier": "^3.0.0",
112
+ "@types/prompts": "^2.4.9",
113
+ "@types/react": "^19.2.14",
114
+ "@types/react-dom": "^19.1.7",
115
+ "@types/validate-npm-package-name": "^4.0.2",
116
+ "@typescript-eslint/eslint-plugin": "^8.50.0",
117
+ "@typescript-eslint/parser": "^8.50.0",
118
+ "css": "^3.0.0",
119
+ "eslint": "^9.39.2",
120
+ "eslint-config-next": "^16.0.8",
121
+ "eslint-config-prettier": "10.1.8",
122
+ "eslint-plugin-import": "2.32.0",
123
+ "eslint-plugin-jsx-a11y": "6.10.2",
124
+ "eslint-plugin-node": "11.1.0",
125
+ "eslint-plugin-prettier": "^5.5.5",
126
+ "eslint-plugin-react": "7.37.5",
127
+ "eslint-plugin-react-hooks": "7.0.1",
128
+ "eslint-plugin-react-refresh": "^0.5.2",
129
+ "eslint-plugin-unused-imports": "^4.4.1",
130
+ "globals": "^16.3.0",
131
+ "msw": "^2.12.10",
132
+ "postcss-scss": "^4.0.9",
133
+ "prettier": "^3.6.2",
134
+ "react": "^19.2.4",
135
+ "react-dom": "^19.2.4",
136
+ "react-router-dom": "^7.13.1",
137
+ "rollup": "^4.59.0",
138
+ "svgo": "^4.0.0"
11
139
  },
12
- "publishConfig": {
13
- "access": "public"
140
+ "msw": {
141
+ "workerDirectory": "public"
14
142
  }
15
143
  }
package/prerender.ts ADDED
@@ -0,0 +1,229 @@
1
+ /* eslint-disable no-console */
2
+ // Pre-render the app into static HTML.
3
+ // run `npm run generate` and then `dist/static` can be served as a static site.
4
+
5
+ import fs from 'fs';
6
+ import path from 'path';
7
+ import { pathToFileURL } from 'url';
8
+ import crypto from 'node:crypto';
9
+
10
+ import jsBeautify, { CSSBeautifyOptions, HTMLBeautifyOptions, JSBeautifyOptions } from 'js-beautify';
11
+ import * as cheerio from 'cheerio';
12
+ import slash from 'slash';
13
+ import _ from 'lodash';
14
+ import { loadEnv } from 'vite';
15
+ import chalk from 'chalk';
16
+
17
+ interface RenderedPage {
18
+ name: string;
19
+ url: string;
20
+ fileName: string;
21
+ }
22
+ const argvModeIndex = process.argv.indexOf('--mode');
23
+ const mode =
24
+ argvModeIndex >= 0 && argvModeIndex < process.argv.length - 1 && !process.argv[argvModeIndex + 1].startsWith('-')
25
+ ? process.argv[argvModeIndex + 1]
26
+ : 'production';
27
+
28
+ const projectRoot = process.cwd();
29
+ const xpackEnv = loadEnv(mode, projectRoot);
30
+ const toAbsolute = (p: string) => path.resolve(projectRoot, p);
31
+ const log = console.log.bind(console);
32
+
33
+ const template = fs.readFileSync(toAbsolute(process.env.VITE_TEMPLATE ?? 'dist/static/index.html'), 'utf-8');
34
+ const { render, routesToPrerender } = await import(pathToFileURL(toAbsolute('./dist/server/entry-server.js')).href);
35
+
36
+ const beautifyOptions: HTMLBeautifyOptions | JSBeautifyOptions | CSSBeautifyOptions = {
37
+ indent_size: 2,
38
+ indent_char: ' ',
39
+ keep_array_indentation: false,
40
+ break_chained_methods: false,
41
+ indent_scripts: 'normal',
42
+ brace_style: 'collapse',
43
+ space_before_conditional: true,
44
+ unescape_strings: false,
45
+ jslint_happy: false,
46
+ end_with_newline: false,
47
+ wrap_line_length: 0,
48
+ indent_inner_html: false,
49
+ comma_first: false,
50
+ e4x: false,
51
+ indent_empty_lines: false,
52
+ wrap_attributes: 'force',
53
+ max_preserve_newlines: 5,
54
+ preserve_newlines: true,
55
+ };
56
+
57
+ // determine routes to pre-render from src/pages
58
+
59
+ const updateResourcePath = ($: cheerio.CheerioAPI, tagName: string, attr: string, addHash: boolean) => {
60
+ $(tagName).each((_, el) => {
61
+ const href = $(el).attr(attr);
62
+
63
+ if (href && href.startsWith('/')) {
64
+ let newPath = href;
65
+
66
+ if (process.env.VITE_DOMAIN) {
67
+ newPath = process.env.VITE_DOMAIN + newPath;
68
+ }
69
+
70
+ if (
71
+ href.startsWith(xpackEnv.VITE_BASE_URL) &&
72
+ !href.startsWith(xpackEnv.VITE_BASE_URL + 'assets/vendors/') &&
73
+ ['.css', '.ico', '.js', '.webmanifest', '.svg'].includes(path.extname(href).toLowerCase()) &&
74
+ !/\.0x[a-z0-9]{8}\.\w+$/gi.test(href)
75
+ ) {
76
+ const path = toAbsolute('dist/static/' + href.substring(xpackEnv.VITE_BASE_URL.length));
77
+
78
+ if (fs.existsSync(path)) {
79
+ const content = fs.readFileSync(path);
80
+ const sha1Hash = crypto.createHash('sha1');
81
+
82
+ sha1Hash.update(content);
83
+ const hash = sha1Hash.digest('base64url').substring(0, 10);
84
+
85
+ if (addHash) {
86
+ newPath += '?v=' + hash;
87
+ }
88
+ } else if (path.endsWith('mock-api.js')) {
89
+ // Skip
90
+ } else {
91
+ // Log warning
92
+ log(chalk.yellow('Cannot find:', path));
93
+ }
94
+ }
95
+
96
+ if (newPath != href) {
97
+ $(el).attr(attr, newPath);
98
+ }
99
+ }
100
+ });
101
+ };
102
+
103
+ const removeStyleBase = ($: cheerio.CheerioAPI) => {
104
+ $('link[rel="stylesheet"]').each((_, el) => {
105
+ const href = $(el).attr('href');
106
+
107
+ if (href?.includes('style-base')) {
108
+ $(el).remove();
109
+ }
110
+ });
111
+ };
112
+
113
+ const removeDuplicateAssets = ($: cheerio.CheerioAPI, selector: string, attr: string, paths: string[]) => {
114
+ $(selector).each((_, el) => {
115
+ if ($(el).attr('data-pl-inplace') === 'true') {
116
+ return;
117
+ }
118
+
119
+ const path = $(el).attr(attr);
120
+
121
+ if (!path) {
122
+ return;
123
+ }
124
+
125
+ const index = $(el).index();
126
+ const parent = $(el).parent().clone();
127
+ const child = parent.children()[index];
128
+
129
+ parent.empty();
130
+ parent.append(child);
131
+ const html = parent.html();
132
+
133
+ $(el).after('\n<!-- ' + html + ' -->');
134
+
135
+ if (paths.includes(path)) {
136
+ $(el).remove();
137
+
138
+ return;
139
+ }
140
+
141
+ paths.push(path);
142
+
143
+ $(el).removeAttr('data-pl-require');
144
+
145
+ if ($(el).attr('type') === 'module') {
146
+ const deferValue = $(el).attr('defer');
147
+
148
+ if ($(el).attr('defer') === '' || deferValue === 'defer' || deferValue === 'true') {
149
+ $(el).removeAttr('defer');
150
+ }
151
+ }
152
+
153
+ $('head').append(el);
154
+ });
155
+ };
156
+
157
+ const viteAbsoluteUrl = (remain: string, addExtension = false): string => {
158
+ const baseUrl = xpackEnv.VITE_BASE_URL;
159
+ const normalizedRemain =
160
+ (remain?.startsWith('/') ? remain : '/' + remain) + (addExtension && !remain.endsWith('/') ? (xpackEnv.VITE_PATH_EXTENSION ?? '') : '');
161
+
162
+ if (!baseUrl) {
163
+ return normalizedRemain;
164
+ }
165
+
166
+ if (!baseUrl.endsWith('/')) {
167
+ return baseUrl + normalizedRemain;
168
+ }
169
+
170
+ const len = baseUrl.length;
171
+
172
+ return baseUrl.substring(0, len - 1) + normalizedRemain;
173
+ };
174
+
175
+ const renderPage = async (renderedPages: RenderedPage[], addHash: boolean) => {
176
+ // pre-render each route...
177
+ for (const route of routesToPrerender) {
178
+ const output = await render(viteAbsoluteUrl(route.route, true));
179
+
180
+ const destLocalizedFolderPath = toAbsolute('dist/static');
181
+
182
+ let html = template.replace('<!--app-html-->', output.html ?? '').replace('@style.scss', '/assets/css/' + route.name + '.css');
183
+ const $ = cheerio.load(html);
184
+ const paths: string[] = [];
185
+
186
+ removeDuplicateAssets($, 'link[data-pl-require][href]', 'href', paths);
187
+ removeDuplicateAssets($, 'script[data-pl-require][src]', 'src', paths);
188
+ updateResourcePath($, 'link', 'href', addHash);
189
+ updateResourcePath($, 'script', 'src', addHash);
190
+ updateResourcePath($, 'img', 'src', addHash);
191
+ if (route.route === '/') {
192
+ removeStyleBase($);
193
+ }
194
+
195
+ $('head title').text(route.name);
196
+
197
+ const fileName = (route.route === '/' ? '/index' : route.route) + '.html';
198
+ const filePath = `${destLocalizedFolderPath}${fileName}`;
199
+
200
+ if (!fs.existsSync(path.dirname(filePath))) {
201
+ fs.mkdirSync(path.dirname(filePath), { recursive: true });
202
+ }
203
+
204
+ html = $.html();
205
+
206
+ html = jsBeautify.html_beautify(html, beautifyOptions);
207
+ html = html.replace('/* app-styles */', output.styles);
208
+
209
+ fs.writeFileSync(toAbsolute(filePath), html);
210
+ log('pre-rendered:', slash(filePath));
211
+
212
+ renderedPages.push({
213
+ name: _.kebabCase(fileName.replaceAll(/\.\w+$/gi, '')),
214
+ url: `${process.env.VITE_DOMAIN ?? ''}${fileName}`,
215
+ fileName: fileName,
216
+ });
217
+ }
218
+ };
219
+
220
+ (async () => {
221
+ const renderedPages: RenderedPage[] = [];
222
+ const pool: Promise<unknown>[] = [];
223
+
224
+ const addHash = !!process.argv.includes('--add-hash');
225
+
226
+ pool.push(renderPage(renderedPages, addHash));
227
+
228
+ await Promise.all(pool);
229
+ })();
@@ -0,0 +1 @@
1
+ This file makes sure that Github Pages doesn't process mdBook's output.
@@ -0,0 +1 @@
1
+ <h1>400</h1>
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <link rel="icon" href="/favicon.svg" />
7
+
8
+ <title>401 - Unauthorized</title>
9
+ </head>
10
+
11
+ <body>
12
+ <script>
13
+ const path = window.location.pathname;
14
+ if (path.toLowerCase() !== '/401.html') {
15
+ let encodedPath = encodeURIComponent(window.location.href);
16
+ window.location.href = '/.auth/login/github?post_login_redirect_uri=' + encodedPath;
17
+ }
18
+ </script>
19
+ </body>
20
+
21
+ </html>
@@ -0,0 +1,252 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <link rel="icon" href="/favicon.svg" />
7
+
8
+ <title>403 - Forbidden</title>
9
+ <style>
10
+ @import url('https://fonts.googleapis.com/css?family=Creepster|Nosifer|Roboto');
11
+ </style>
12
+ <style>
13
+ html {
14
+ background-color: #000121;
15
+ font-family: 'Roboto', sans-serif;
16
+
17
+ }
18
+
19
+ .maincontainer {
20
+ position: relative;
21
+ top: -50px;
22
+ transform: scale(0.8);
23
+ background: url("/__images__/haunted-house-background.png");
24
+ background-repeat: no-repeat;
25
+ background-position: center;
26
+ background-size: 700px 600px;
27
+ width: 800px;
28
+ height: 600px;
29
+ margin: 0px auto;
30
+ display: grid;
31
+ }
32
+
33
+ .foregroundimg {
34
+ position: relative;
35
+ width: 100%;
36
+ top: -230px;
37
+ z-index: 5;
38
+ }
39
+
40
+ .errorcode {
41
+ position: relative;
42
+ top: -200px;
43
+ font-family: 'Creepster', cursive;
44
+ color: white;
45
+ text-align: center;
46
+ font-size: 6em;
47
+ letter-spacing: 0.1em;
48
+ }
49
+
50
+ .errortext {
51
+ position: relative;
52
+ top: -260px;
53
+ color: #FBD130;
54
+ text-align: center;
55
+ text-transform: uppercase;
56
+ font-size: 1.8em;
57
+ }
58
+
59
+ .bat {
60
+ opacity: 0;
61
+ position: relative;
62
+ transform-origin: center;
63
+ z-index: 3;
64
+ }
65
+
66
+ .bat:nth-child(1) {
67
+ top: 380px;
68
+ left: 120px;
69
+ transform: scale(0.5);
70
+ animation: 13s 1s flyBat1 infinite linear;
71
+ }
72
+
73
+ .bat:nth-child(2) {
74
+ top: 280px;
75
+ left: 80px;
76
+ transform: scale(0.3);
77
+ animation: 8s 4s flyBat2 infinite linear;
78
+ }
79
+
80
+ .bat:nth-child(3) {
81
+ top: 200px;
82
+ left: 150px;
83
+ transform: scale(0.4);
84
+ animation: 12s 2s flyBat3 infinite linear;
85
+ }
86
+
87
+ .body {
88
+ position: relative;
89
+ width: 50px;
90
+ top: 12px;
91
+ }
92
+
93
+ .wing {
94
+ width: 150px;
95
+ position: relative;
96
+ transform-origin: right center;
97
+ }
98
+
99
+ .leftwing {
100
+ left: 30px;
101
+ animation: 0.8s flapLeft infinite ease-in-out;
102
+ }
103
+
104
+ .rightwing {
105
+ left: -180px;
106
+ transform: scaleX(-1);
107
+ animation: 0.8s flapRight infinite ease-in-out;
108
+ }
109
+
110
+ @keyframes flapLeft {
111
+ 0% {
112
+ transform: rotateZ(0);
113
+ }
114
+
115
+ 50% {
116
+ transform: rotateZ(10deg) rotateY(40deg);
117
+ }
118
+
119
+ 100% {
120
+ transform: rotateZ(0);
121
+ }
122
+ }
123
+
124
+ @keyframes flapRight {
125
+ 0% {
126
+ transform: scaleX(-1) rotateZ(0);
127
+ }
128
+
129
+ 50% {
130
+ transform: scaleX(-1) rotateZ(10deg) rotateY(40deg);
131
+ }
132
+
133
+ 100% {
134
+ transform: scaleX(-1) rotateZ(0);
135
+ }
136
+ }
137
+
138
+ @keyframes flyBat1 {
139
+ 0% {
140
+ opacity: 1;
141
+ transform: scale(0.5)
142
+ }
143
+
144
+ 25% {
145
+ opacity: 1;
146
+ transform: scale(0.5) translate(-400px, -330px)
147
+ }
148
+
149
+ 50% {
150
+ opacity: 1;
151
+ transform: scale(0.5) translate(400px, -800px)
152
+ }
153
+
154
+ 75% {
155
+ opacity: 1;
156
+ transform: scale(0.5) translate(600px, 100px)
157
+ }
158
+
159
+ 100% {
160
+ opacity: 1;
161
+ transform: scale(0.5) translate(100px, 300px)
162
+ }
163
+ }
164
+
165
+ @keyframes flyBat2 {
166
+ 0% {
167
+ opacity: 1;
168
+ transform: scale(0.3)
169
+ }
170
+
171
+ 25% {
172
+ opacity: 1;
173
+ transform: scale(0.3) translate(200px, -330px)
174
+ }
175
+
176
+ 50% {
177
+ opacity: 1;
178
+ transform: scale(0.3) translate(-300px, -800px)
179
+ }
180
+
181
+ 75% {
182
+ opacity: 1;
183
+ transform: scale(0.3) translate(-400px, 100px)
184
+ }
185
+
186
+ 100% {
187
+ opacity: 1;
188
+ transform: scale(0.3) translate(100px, 300px)
189
+ }
190
+ }
191
+
192
+ @keyframes flyBat3 {
193
+ 0% {
194
+ opacity: 1;
195
+ transform: scale(0.4)
196
+ }
197
+
198
+ 25% {
199
+ opacity: 1;
200
+ transform: scale(0.4) translate(-350px, -330px)
201
+ }
202
+
203
+ 50% {
204
+ opacity: 1;
205
+ transform: scale(0.4) translate(400px, -800px)
206
+ }
207
+
208
+ 75% {
209
+ opacity: 1;
210
+ transform: scale(0.4) translate(-600px, 100px)
211
+ }
212
+
213
+ 100% {
214
+ opacity: 1;
215
+ transform: scale(0.4) translate(100px, 300px)
216
+ }
217
+ }
218
+ </style>
219
+ <script>
220
+ window.console = window.console || function (t) { };
221
+ </script>
222
+ <script>
223
+ if (document.location.search.match(/type=embed/gi)) {
224
+ window.parent.postMessage("resize", "*");
225
+ }
226
+ </script>
227
+ </head>
228
+
229
+ <body translate="no">
230
+ <div class="maincontainer">
231
+ <div class="bat">
232
+ <img class="wing leftwing" src="/__images__/bat-wing.png">
233
+ <img class="body" src="/__images__/bat-body.png" alt="bat">
234
+ <img class="wing rightwing" src="/__images__/bat-wing.png">
235
+ </div>
236
+ <div class="bat">
237
+ <img class="wing leftwing" src="/__images__/bat-wing.png">
238
+ <img class="body" src="/__images__/bat-body.png" alt="bat">
239
+ <img class="wing rightwing" src="/__images__/bat-wing.png">
240
+ </div>
241
+ <div class="bat">
242
+ <img class="wing leftwing" src="/__images__/bat-wing.png">
243
+ <img class="body" src="/__images__/bat-body.png" alt="bat">
244
+ <img class="wing rightwing" src="/__images__/bat-wing.png">
245
+ </div>
246
+ <img class="foregroundimg" src="/__images__/haunted-house-foreground.png" alt="haunted house">
247
+ </div>
248
+ <h1 class="errorcode">ERROR 403</h1>
249
+ <div class="errortext">This area is forbidden. Turn back now!</div>
250
+ </body>
251
+
252
+ </html>