@abreen/tada 1.0.2 → 1.1.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.
- package/README.md +29 -33
- package/bin/tada.ts +356 -0
- package/bin/validators.test.ts +204 -0
- package/bin/validators.ts +83 -0
- package/{webpack/apply-base-path-plugin.js → build/apply-base-path-plugin.ts} +16 -7
- package/build/bundle.ts +117 -0
- package/{webpack/code.test.js → build/code.test.ts} +6 -7
- package/build/colors.ts +25 -0
- package/build/content-watch.ts +107 -0
- package/build/copy.ts +118 -0
- package/{webpack/deflist-id-plugin.js → build/deflist-id-plugin.ts} +7 -6
- package/{webpack/external-links-plugin.js → build/external-links-plugin.ts} +14 -5
- package/build/features.ts +11 -0
- package/build/generate-content-assets.ts +315 -0
- package/build/generate-favicon.ts +165 -0
- package/build/generate-fonts.ts +31 -0
- package/{webpack/generate-manifest-plugin.js → build/generate-manifest.ts} +29 -36
- package/build/globals.test.ts +101 -0
- package/{webpack/globals.js → build/globals.ts} +28 -13
- package/{webpack/heading-subtitle-plugin.js → build/heading-subtitle-plugin.ts} +4 -2
- package/build/json-schema.test.ts +57 -0
- package/build/json-schema.ts +33 -0
- package/build/log.test.ts +111 -0
- package/build/log.ts +167 -0
- package/{webpack/markdown-plugins.test.js → build/markdown-plugins.test.ts} +94 -9
- package/{webpack/pagefind-plugin.test.js → build/pagefind.test.ts} +74 -13
- package/build/pagefind.ts +339 -0
- package/{webpack/pdf-text.js → build/pdf-text.ts} +47 -27
- package/build/pipeline.ts +93 -0
- package/{webpack/reachability.test.js → build/reachability.test.ts} +3 -3
- package/{webpack/reachability.js → build/reachability.ts} +77 -34
- package/build/serve.ts +112 -0
- package/{webpack/site-variables.js → build/site-variables.ts} +22 -15
- package/{webpack → build}/site.schema.json +3 -10
- package/{webpack/templates.js → build/templates.ts} +35 -33
- package/{webpack/text-to-id.js → build/text-to-id.ts} +2 -2
- package/build/toc-plugin.test.ts +105 -0
- package/{webpack/toc-plugin.js → build/toc-plugin.ts} +32 -13
- package/build/types.ts +172 -0
- package/build/util.ts +26 -0
- package/{webpack/utils/code.js → build/utils/code.ts} +119 -60
- package/{webpack/utils/content-files.js → build/utils/content-files.ts} +40 -35
- package/build/utils/derive-theme.test.ts +111 -0
- package/build/utils/derive-theme.ts +85 -0
- package/build/utils/file-types.test.ts +61 -0
- package/build/utils/file-types.ts +13 -0
- package/build/utils/front-matter.test.ts +80 -0
- package/{webpack/utils/front-matter.js → build/utils/front-matter.ts} +22 -9
- package/{webpack → build}/utils/jdi-runner/LiterateRunner.java +1 -1
- package/{webpack/utils/literate-java.js → build/utils/literate-java.ts} +63 -34
- package/{webpack/utils/markdown.js → build/utils/markdown.ts} +94 -49
- package/build/utils/paths.test.ts +91 -0
- package/{webpack/utils/paths.js → build/utils/paths.ts} +14 -22
- package/{webpack/utils/render.js → build/utils/render.ts} +188 -123
- package/build/utils/shiki-highlighter.ts +29 -0
- package/build/validate-internal-links-plugin.test.ts +106 -0
- package/{webpack/validate-internal-links-plugin.js → build/validate-internal-links-plugin.ts} +47 -20
- package/{webpack/watch-reachability-state.test.js → build/watch-reachability-state.test.ts} +8 -8
- package/{webpack/watch-reachability-state.js → build/watch-reachability-state.ts} +63 -24
- package/{webpack/watch-reload-client.js → build/watch-reload-client.ts} +3 -1
- package/build/watch.ts +573 -0
- package/content/index.md +9 -3
- package/content/markdown.md +2 -1
- package/content/problem_sets/index.html +14 -0
- package/fonts/google-sans-code/woff2/GoogleSansCodeVariable-Italic.woff2 +0 -0
- package/fonts/google-sans-code/woff2/GoogleSansCodeVariable.woff2 +0 -0
- package/fonts/inter/woff2/InterVariable-Italic.woff2 +0 -0
- package/fonts/inter/woff2/InterVariable.woff2 +0 -0
- package/package.json +28 -19
- package/src/_alerts.scss +92 -0
- package/src/_base.scss +106 -0
- package/src/{layout.scss → _layout.scss} +0 -2
- package/src/anchor/style.scss +1 -9
- package/src/code/index.ts +3 -3
- package/src/code.scss +1 -1
- package/src/critical.scss +5 -0
- package/src/header/_base.scss +129 -0
- package/src/header/style.scss +3 -131
- package/src/index.ts +1 -2
- package/src/question/style.scss +1 -1
- package/src/search/index.ts +36 -15
- package/src/search/style.scss +9 -15
- package/src/style.scss +6 -269
- package/src/toc/style.scss +5 -39
- package/src/util.ts +8 -5
- package/templates/_theme.scss +38 -14
- package/tsconfig.json +10 -6
- package/types/file-system-access.d.ts +5 -0
- package/types/markdown-it-plugins.d.ts +11 -0
- package/types/untyped-modules.d.ts +40 -0
- package/bin/tada.js +0 -361
- package/content/problem_sets/index.md +0 -6
- package/webpack/build-state.js +0 -97
- package/webpack/colors.js +0 -15
- package/webpack/config.base.js +0 -151
- package/webpack/config.dev.js +0 -23
- package/webpack/config.prod.js +0 -32
- package/webpack/content-watch-plugin.js +0 -153
- package/webpack/features.js +0 -5
- package/webpack/generate-content-assets-plugin.js +0 -308
- package/webpack/generate-favicon-plugin.js +0 -198
- package/webpack/generate-fonts-plugin.js +0 -69
- package/webpack/json-schema.js +0 -19
- package/webpack/log.js +0 -143
- package/webpack/pagefind-plugin.js +0 -379
- package/webpack/print-flair-plugin.js +0 -22
- package/webpack/serve.js +0 -104
- package/webpack/util.js +0 -49
- package/webpack/utils/define-plugin.js +0 -20
- package/webpack/utils/file-types.js +0 -26
- package/webpack/utils/parse-hsl.js +0 -8
- package/webpack/utils/shiki-highlighter.js +0 -26
- package/webpack/watch.js +0 -166
- /package/{webpack → build}/flair.json +0 -0
- /package/{webpack → build}/utils/jdi-runner/LiterateRunner.class +0 -0
- /package/fonts/google-sans-code/{GoogleSansCodeVariable-Italic.ttf → ttf/GoogleSansCodeVariable-Italic.ttf} +0 -0
- /package/fonts/google-sans-code/{GoogleSansCodeVariable.ttf → ttf/GoogleSansCodeVariable.ttf} +0 -0
- /package/fonts/inter/{InterVariable-Italic.ttf → ttf/InterVariable-Italic.ttf} +0 -0
- /package/fonts/inter/{InterVariable.ttf → ttf/InterVariable.ttf} +0 -0
- /package/types/{dev.ts → dev.d.ts} +0 -0
package/webpack/watch.js
DELETED
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const webpack = require('webpack');
|
|
3
|
-
const { fork } = require('child_process');
|
|
4
|
-
const path = require('path');
|
|
5
|
-
const WebSocket = require('ws');
|
|
6
|
-
const { B, G } = require('./colors');
|
|
7
|
-
const { makeLogger, getFlair } = require('./log');
|
|
8
|
-
const getConfig = require('./config.dev');
|
|
9
|
-
const ContentWatchPlugin = require('./content-watch-plugin');
|
|
10
|
-
const { getContentDir } = require('./util');
|
|
11
|
-
|
|
12
|
-
const WEBSOCKET_PORT = 35729;
|
|
13
|
-
|
|
14
|
-
const log = makeLogger(__filename);
|
|
15
|
-
const wslog = makeLogger('WebSocket');
|
|
16
|
-
const contentDir = getContentDir();
|
|
17
|
-
|
|
18
|
-
function broadcast(msg) {
|
|
19
|
-
if (wss == null || !webSocketsReady) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
wslog.debug(`Broadcasting "${msg}" to WebSocket clients...`);
|
|
23
|
-
wss.clients.forEach(client => {
|
|
24
|
-
if (client.readyState === WebSocket.OPEN) {
|
|
25
|
-
client.send(msg);
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function serve() {
|
|
31
|
-
const child = fork(path.join(__dirname, 'serve.js'), { stdio: 'inherit' });
|
|
32
|
-
child.on('close', code => {
|
|
33
|
-
webServerReady = false;
|
|
34
|
-
log.error`Web server exited with code ${code}`;
|
|
35
|
-
process.exit(2);
|
|
36
|
-
});
|
|
37
|
-
child.on('error', err => {
|
|
38
|
-
webServerReady = false;
|
|
39
|
-
log.error`Web server failed: ${err.message}`;
|
|
40
|
-
});
|
|
41
|
-
child.on('message', msg => {
|
|
42
|
-
if (msg.ready) {
|
|
43
|
-
webServerReady = true;
|
|
44
|
-
clearTimeout(webServerTimeout);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
webServerTimeout = setTimeout(() => {
|
|
49
|
-
if (webServerReady) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
log.error`Web server failed to report within 10 seconds, exiting`;
|
|
53
|
-
process.exit(3);
|
|
54
|
-
}, 10000);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function toContentMarkdownPath(filePath) {
|
|
58
|
-
if (!filePath) {
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
const ext = path.extname(filePath).toLowerCase();
|
|
62
|
-
if (!['.md', '.markdown'].includes(ext)) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const normalizedContentDir = path.resolve(contentDir) + path.sep;
|
|
67
|
-
const normalizedFilePath = path.resolve(filePath);
|
|
68
|
-
if (!normalizedFilePath.startsWith(normalizedContentDir)) {
|
|
69
|
-
return null;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return path
|
|
73
|
-
.relative(contentDir, normalizedFilePath)
|
|
74
|
-
.split(path.sep)
|
|
75
|
-
.join(path.posix.sep);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function logChangedMarkdownFiles(files, { skip = new Set() } = {}) {
|
|
79
|
-
if (!files) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const markdownPaths = [...files]
|
|
84
|
-
.map(toContentMarkdownPath)
|
|
85
|
-
.filter(markdownPath => markdownPath && !skip.has(markdownPath))
|
|
86
|
-
.sort();
|
|
87
|
-
|
|
88
|
-
for (const markdownPath of markdownPaths) {
|
|
89
|
-
log.event`${B`${markdownPath}`} changed, rebuilding...`;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
let webSocketsReady = false;
|
|
94
|
-
let webServerReady = false;
|
|
95
|
-
let webServerTimeout;
|
|
96
|
-
let serveStarted = false;
|
|
97
|
-
let currentWatcher = null;
|
|
98
|
-
|
|
99
|
-
let wss = null;
|
|
100
|
-
try {
|
|
101
|
-
wss = new WebSocket.Server({ port: WEBSOCKET_PORT });
|
|
102
|
-
|
|
103
|
-
wss.on('connection', conn => {
|
|
104
|
-
wslog.debug`WebSocket client connected`;
|
|
105
|
-
conn.on('close', () => {
|
|
106
|
-
wslog.debug`WebSocket client disconnected`;
|
|
107
|
-
});
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
wss.on('error', err => {
|
|
111
|
-
wslog.error`WebSocket server error: ${err.message}`;
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
wss.on('listening', () => {
|
|
115
|
-
wslog.debug`WebSocket server listening at ws://localhost:${WEBSOCKET_PORT}`;
|
|
116
|
-
webSocketsReady = true;
|
|
117
|
-
});
|
|
118
|
-
} catch (err) {
|
|
119
|
-
wslog.error`Failed to start WebSocket server on port ${WEBSOCKET_PORT}: ${err.message}`;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
async function startWatching() {
|
|
123
|
-
const config = await getConfig({ watchMode: true });
|
|
124
|
-
const compiler = webpack(config);
|
|
125
|
-
const loggedInvalidationFiles = new Set();
|
|
126
|
-
|
|
127
|
-
compiler.hooks.invalid.tap('WatchChangedFileLog', fileName => {
|
|
128
|
-
broadcast('rebuilding');
|
|
129
|
-
|
|
130
|
-
const markdownPath = toContentMarkdownPath(fileName);
|
|
131
|
-
if (markdownPath) {
|
|
132
|
-
loggedInvalidationFiles.add(markdownPath);
|
|
133
|
-
log.event`${B`${markdownPath}`} changed, rebuilding...`;
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
currentWatcher = compiler.watch({ aggregateTimeout: 300 }, (err, stats) => {
|
|
138
|
-
logChangedMarkdownFiles(compiler.modifiedFiles, {
|
|
139
|
-
skip: loggedInvalidationFiles,
|
|
140
|
-
});
|
|
141
|
-
loggedInvalidationFiles.clear();
|
|
142
|
-
|
|
143
|
-
if (ContentWatchPlugin.needsRestart()) {
|
|
144
|
-
ContentWatchPlugin.clearRestart();
|
|
145
|
-
log.event`Content changed, restarting Webpack compiler...`;
|
|
146
|
-
currentWatcher.close(() => startWatching());
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (err) {
|
|
151
|
-
log.error`Build failed: ${err.message}`;
|
|
152
|
-
} else if (stats.hasErrors()) {
|
|
153
|
-
process.stderr.write(stats.toString('errors-only') + '\n');
|
|
154
|
-
log.error`Build failed`;
|
|
155
|
-
} else {
|
|
156
|
-
log.event`${getFlair()} Webpack build completed ${G`successfully`}`;
|
|
157
|
-
broadcast('reload');
|
|
158
|
-
}
|
|
159
|
-
if (!serveStarted && !err && !stats.hasErrors()) {
|
|
160
|
-
serveStarted = true;
|
|
161
|
-
serve();
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
startWatching();
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/fonts/google-sans-code/{GoogleSansCodeVariable.ttf → ttf/GoogleSansCodeVariable.ttf}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|