@profullstack/waitlist 0.16.0 → 0.16.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.
- package/package.json +1 -1
- package/src/build.js +28 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@profullstack/waitlist",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"description": "Email waitlist for any launch page: a <waitlist-form> web component, a live signup chart, and a static-site builder on @profullstack/css + @profullstack/charts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/src/build.js
CHANGED
|
@@ -202,10 +202,7 @@ export function shellHtml(s, { head, main, footers = '', slot = baseSlot(s) }) {
|
|
|
202
202
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
203
203
|
${s.ab ? abHeadScript(s.ab, s.look) : ''}
|
|
204
204
|
${head}
|
|
205
|
-
<link rel="stylesheet" href="assets/
|
|
206
|
-
<link rel="stylesheet" href="assets/looks.css">
|
|
207
|
-
<link rel="stylesheet" href="assets/charts.css">
|
|
208
|
-
<link rel="stylesheet" href="assets/waitlist.css">
|
|
205
|
+
<link rel="stylesheet" href="assets/site.css">
|
|
209
206
|
${slot.head.join('\n')}
|
|
210
207
|
</head>
|
|
211
208
|
<body class="waitlist-page">
|
|
@@ -215,7 +212,7 @@ ${navHtml(s, { community: s.community ?? null, esc })}
|
|
|
215
212
|
${main}
|
|
216
213
|
</main>
|
|
217
214
|
${footZoneHtml(s, footers)}
|
|
218
|
-
<script src="assets/charts.global.js"></script>
|
|
215
|
+
<script defer src="assets/charts.global.js"></script>
|
|
219
216
|
<script type="module" src="assets/waitlist.js"></script>
|
|
220
217
|
${slot.scripts.join('\n')}
|
|
221
218
|
${s.pwa ? '<script>if("serviceWorker"in navigator){var m=document.querySelector(\'link[rel="manifest"]\');if(m)navigator.serviceWorker.register(new URL("sw.js",m.href)).catch(function(){})}</script>' : ''}
|
|
@@ -248,6 +245,31 @@ export function pageHtml(s, { footers = '', noindex = false, slot = baseSlot(s)
|
|
|
248
245
|
return shellHtml(s, { head: `${headTags(s, { noindex })}\n${jsonLdTag(s)}`, main, footers, slot });
|
|
249
246
|
}
|
|
250
247
|
|
|
248
|
+
/**
|
|
249
|
+
* Every stylesheet a page needs, as one file.
|
|
250
|
+
*
|
|
251
|
+
* The page used to link four stylesheets, and profullstack.css @imports three
|
|
252
|
+
* more, which a browser only discovers after the first has arrived. That is
|
|
253
|
+
* seven requests in two rounds before anything paints, and one slow answer
|
|
254
|
+
* from a gateway holds the whole page blank. One file is one request.
|
|
255
|
+
*
|
|
256
|
+
* Order is the cascade order the separate files had: profullstack.css with its
|
|
257
|
+
* @imports put in where they stood (its @layer statement stays first), then
|
|
258
|
+
* looks, charts and the waitlist layer. The separate files are still written,
|
|
259
|
+
* for anything that links them by name.
|
|
260
|
+
*/
|
|
261
|
+
export async function bundleCss(cssDir, chartsCss, waitlistCss) {
|
|
262
|
+
const read = (f) => readFile(f, 'utf8');
|
|
263
|
+
let base = await read(join(cssDir, 'profullstack.css'));
|
|
264
|
+
for (const m of [...base.matchAll(/@import\s+url\(["']?\.\/([\w.-]+\.css)["']?\)\s*;/g)]) {
|
|
265
|
+
base = base.replace(m[0], `/* ${m[1]} */\n${await read(join(cssDir, m[1]))}`);
|
|
266
|
+
}
|
|
267
|
+
if (/@import\b/.test(base.replace(/\/\*[\s\S]*?\*\//g, ''))) throw new Error('profullstack.css has an @import the bundler does not know how to inline');
|
|
268
|
+
const rest = [];
|
|
269
|
+
for (const [label, file] of [['looks.css', join(cssDir, 'looks.css')], ['charts.css', chartsCss], ['waitlist.css', waitlistCss]]) rest.push(`/* ${label} */\n${await read(file)}`);
|
|
270
|
+
return [base, ...rest].join('\n');
|
|
271
|
+
}
|
|
272
|
+
|
|
251
273
|
/** Square icon in the look's colors (takes a normalized spec or a bare name). */
|
|
252
274
|
export function iconSvg(s) {
|
|
253
275
|
return lookIconSvg(typeof s === 'string' ? normalize({ name: s }) : s);
|
|
@@ -288,6 +310,7 @@ export async function buildSite(spec, out, { footers = true, images = true, fetc
|
|
|
288
310
|
await copyFile(join(chartsDir, 'charts.css'), join(out, 'assets', 'charts.css'));
|
|
289
311
|
await copyFile(join(here, 'index.js'), join(out, 'assets', 'waitlist.js'));
|
|
290
312
|
await copyFile(join(here, 'waitlist.css'), join(out, 'assets', 'waitlist.css'));
|
|
313
|
+
await writeFile(join(out, 'assets', 'site.css'), await bundleCss(cssDir, join(chartsDir, 'charts.css'), join(here, 'waitlist.css')));
|
|
291
314
|
const icon = iconSvg(s);
|
|
292
315
|
await writeFile(join(out, 'assets', 'icon.svg'), icon);
|
|
293
316
|
const og = ogSvg(s);
|