@runeditrun/rer 0.2.61 → 0.2.62
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/global/CHANGELOG.md +5 -0
- package/modules/demo-host/README.md +7 -2
- package/modules/demo-host/native/prepare.mjs +1 -1
- package/modules/demo-host/page-style.mjs +2 -2
- package/modules/demo-host/pages.mjs +5 -5
- package/modules/demo-host/start-script.mjs +1 -1
- package/modules/demo-host/theme-css.mjs +49 -0
- package/modules/demo-host/theme-script.mjs +24 -7
- package/modules/demo-host/theme.mjs +8 -8
- package/package.json +1 -1
package/global/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.62
|
|
4
|
+
|
|
5
|
+
- **Themed demo gates keep waiting visibly disabled (#292).** Waiting, working and other non-actionable buttons use muted outlines from the seed’s theme tokens. Turnstile explicitly follows the card’s painted light/dark scheme, including declared dark media tokens.
|
|
6
|
+
- **First paint returns to the 0.2.59 baseline.** Critical theme/import/font CSS is inline under the existing CSP, font faces use swap or optional, and prefetch lists are unchanged. The reviewed browser-cold local-host Plinth medians for 0.2.59 / 0.2.60 / this fix were 20 / 28 / 20 ms; Default was 20 / 24 / 20 ms. Seeds pick up the fix with rer 0.2.62 and a normal demo refresh.
|
|
7
|
+
|
|
3
8
|
## 0.2.61
|
|
4
9
|
|
|
5
10
|
- **One import path for every seed (#272).** The signed-in move-in screen, rer and Business can share upload → plan → reviewed fingerprint → apply → reconcile → undo, retaining native edit protection, history and erasure across catch-up chains. This integration supersedes #246, #262, #252, #250, #259 and #267.
|
|
@@ -13,8 +13,13 @@ host. See [adoption and deployment](../../export/DEMO.md#hosting-the-demo).
|
|
|
13
13
|
- `worker.mjs`, `pages.mjs`, `start-script.mjs`: Turnstile start, progress,
|
|
14
14
|
cancellation and visitor routing. Static assets are served at the edge.
|
|
15
15
|
- `theme.mjs`, `page-style.mjs`, `theme-script.mjs`: the start and ended pages
|
|
16
|
-
|
|
17
|
-
colours, type and mark follow its `--rer-*` tokens,
|
|
16
|
+
inline the seed's built `rer-theme.css`, fonts CSS and imports in the same
|
|
17
|
+
cascade as the Lobby. Their colours, type and mark follow its `--rer-*` tokens,
|
|
18
|
+
including media rules. Font faces use swap or optional display, so neither
|
|
19
|
+
CSS fetches nor fonts hold first paint. Disabled buttons use the surface,
|
|
20
|
+
border and muted-text tokens; only actionable buttons use the accent fill.
|
|
21
|
+
`theme-script.mjs` sets the page and Turnstile scheme from the painted card's
|
|
22
|
+
background and text before the widget renders, and updates on preference changes.
|
|
18
23
|
The maintained default seed's theme assets supply missing tokens or an
|
|
19
24
|
absent theme, under `/__demo/theme/`. Styles, fonts and marks stay same-origin;
|
|
20
25
|
a missing mark leaves the product name visible.
|
|
@@ -40,7 +40,7 @@ export async function prepareNative(folder) {
|
|
|
40
40
|
const bundle = { iconHead, compatibilityDate: config.compatibility_date, compatibilityFlags: [...new Set([...(config.compatibility_flags ?? []), 'nodejs_compat'])], modules,
|
|
41
41
|
bindings, migrations: manifest.migrations, vars: config.vars ?? {}, crons: config.triggers?.crons ?? [],
|
|
42
42
|
assetPaths: [...assets.filter(file => !file.path.split('/').some(part => part.startsWith('.'))).map(file => '/' + file.path), ...theme.paths],
|
|
43
|
-
theme: theme.
|
|
43
|
+
theme: theme.css,
|
|
44
44
|
immutable: [...builtChunks(assets, manifest.assetsDir)].sort(),
|
|
45
45
|
warm: (await warmList(assets, root, manifest.operatorPath, manifest.assetsDir)).paths };
|
|
46
46
|
bundle.digest = createHash('sha256').update(JSON.stringify(bundle)).digest('hex');
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// Gate layout; presentation comes from the same --rer-* tokens as the Lobby.
|
|
2
|
-
export const STYLE =
|
|
2
|
+
export const STYLE = `:root{color-scheme:light}:root[data-demo-scheme=dark]{color-scheme:dark}*{box-sizing:border-box}body{margin:0;background:var(--rer-page);color:var(--rer-text);font-family:var(--rer-font-body);-webkit-font-smoothing:antialiased}
|
|
3
3
|
main{width:666px;margin:clamp(32px,18vh,184px) auto 48px}.card{padding:40px 42px 44px;background:var(--rer-surface);border:1px solid var(--rer-border);border-radius:var(--rer-radius);box-shadow:0 12px 45px color-mix(in srgb,var(--rer-text) 5%,transparent)}
|
|
4
4
|
.brand{display:flex;align-items:center;gap:12px;font-family:var(--rer-font-heading,var(--rer-font-body));font-size:18px;line-height:22px;font-weight:var(--rer-wordmark-weight,600);letter-spacing:var(--rer-wordmark-tracking,normal);color:var(--rer-text);margin:0 0 20px}.brand img{display:block;width:40px;height:40px;object-fit:contain}.brand img[hidden]{display:none}
|
|
5
5
|
h1{font-family:var(--rer-font-heading,var(--rer-font-body));font-size:42px;line-height:50px;letter-spacing:-1.3px;margin:0 0 14px;font-weight:700}.intro{font-size:20px;line-height:28px;color:var(--rer-muted);margin:0}
|
|
6
6
|
ul{padding:0;margin:23px 0 35px;list-style:none;color:var(--rer-muted);font-size:18px;line-height:33px}li{position:relative;padding-left:33px}li:before{content:'';position:absolute;left:7px;top:14px;width:7px;height:7px;background:var(--rer-accent);border-radius:50%}
|
|
7
7
|
.notice{margin:0 0 16px;padding:12px 16px;border-radius:8px;background:var(--rer-page);color:var(--rer-text);border:1px solid var(--rer-border);font-size:16px;line-height:22px}
|
|
8
8
|
.cf-turnstile{min-height:65px}.button{display:flex;align-items:center;justify-content:center;gap:12px;width:100%;margin-top:28px;min-height:58px;border:1px solid var(--rer-accent);border-radius:var(--rer-button-radius,var(--rer-radius));background:var(--rer-accent);color:var(--rer-accent-text);font:inherit;font-size:20px;font-weight:700;line-height:26px;padding:15px;text-align:center;text-decoration:none;cursor:pointer}
|
|
9
|
-
.button:disabled{
|
|
9
|
+
.button:disabled{background:var(--rer-surface);border-color:var(--rer-border);color:var(--rer-muted);font-weight:600;cursor:default}
|
|
10
10
|
.spinner{display:none;flex:none;width:20px;height:20px;border:3px solid color-mix(in srgb,currentColor 35%,transparent);border-top-color:currentColor;border-radius:50%;animation:spin .8s linear infinite}[data-state=working] .spinner,[data-state=signing] .spinner{display:block}@keyframes spin{to{transform:rotate(360deg)}}
|
|
11
11
|
ol.steps{display:none;list-style:none;margin:22px auto 0;padding:0;width:max-content;max-width:100%;font-size:16px;line-height:22px;color:var(--rer-muted)}[data-state=working] .steps,[data-state=signing] .steps,[data-state=slow] .steps{display:grid;gap:10px}[data-state=failed] .note{display:none}
|
|
12
12
|
.steps li{padding-left:30px;margin:0}.steps li:before{left:0;top:2px;width:18px;height:18px;box-sizing:border-box;background:none;border:2px solid var(--rer-muted)}.steps [data-at=done]{color:var(--rer-muted)}.steps [data-at=done]:before{content:'✓';border:0;background:var(--rer-accent);color:var(--rer-accent-text);font-size:12px;line-height:18px;font-weight:700;text-align:center}.steps [data-at=now]{color:var(--rer-text);font-weight:600}.steps [data-at=now]:before{border-color:var(--rer-border);border-top-color:var(--rer-accent);animation:spin .8s linear infinite}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Both are one card in the family's quiet sign-in style.
|
|
4
4
|
import { START_SCRIPT } from './start-script.mjs';
|
|
5
5
|
import { STYLE } from './page-style.mjs';
|
|
6
|
-
import {
|
|
6
|
+
import { THEME_SCRIPT } from './theme-script.mjs';
|
|
7
7
|
|
|
8
8
|
const escape = value => String(value).replace(/[&<>"']/g, character => `&#${character.charCodeAt(0)};`);
|
|
9
9
|
|
|
@@ -15,8 +15,8 @@ const warm = env => (env.DEMO_WARM ?? []).map(path => `<link rel="prefetch" href
|
|
|
15
15
|
function html(env, { page, title, body, status = 200, headers = {}, turnstile = false, refresh = false }) {
|
|
16
16
|
const nonce = crypto.randomUUID().replaceAll('-', ''), site = new URL(env.DEMO_SITE);
|
|
17
17
|
const policy = `default-src 'none'; style-src 'self' 'nonce-${nonce}'; font-src 'self'; img-src 'self'; form-action 'self'; base-uri 'none'; frame-ancestors 'none'; script-src 'nonce-${nonce}'${turnstile ? ` https://challenges.cloudflare.com; frame-src https://challenges.cloudflare.com; connect-src 'self' https://challenges.cloudflare.com` : ''}`;
|
|
18
|
-
return new Response(`<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>${escape(title)}</title>${env.DEMO_ICON_HEAD ?? ''}${refresh ? '<noscript><meta http-equiv="refresh" content="2;url=/__demo/status"></noscript>' : ''}${(env.DEMO_THEME ??
|
|
19
|
-
<body class="${page}"><main><section class="card" aria-labelledby="title"><p class="brand"><img class="mark" alt="${escape(env.DEMO_NAME)}" width="40" height="40" hidden><span>${escape(env.DEMO_NAME)}</span></p>${body}</section><nav class="back" aria-label="Return"><a href="${escape(site.origin)}/">Back to ${escape(site.host)}</a></nav></main><script nonce="${nonce}">${
|
|
18
|
+
return new Response(`<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="robots" content="noindex"><title>${escape(title)}</title>${env.DEMO_ICON_HEAD ?? ''}${refresh ? '<noscript><meta http-equiv="refresh" content="2;url=/__demo/status"></noscript>' : ''}<style nonce="${nonce}">${(env.DEMO_THEME ?? '').replace(/<(?=\/style)/gi, '\\3c ')}\n${STYLE}</style>${turnstile ? `<noscript><style nonce="${nonce}">#note{display:none}</style></noscript><script nonce="${nonce}">${START_SCRIPT}</script>${warm(env)}` : ''}</head>
|
|
19
|
+
<body class="${page}"><main><section class="card" aria-labelledby="title"><p class="brand"><img class="mark" alt="${escape(env.DEMO_NAME)}" width="40" height="40" hidden><span>${escape(env.DEMO_NAME)}</span></p>${body}</section><nav class="back" aria-label="Return"><a href="${escape(site.origin)}/">Back to ${escape(site.host)}</a></nav></main><script nonce="${nonce}">${THEME_SCRIPT}</script>${turnstile ? `<script nonce="${nonce}" src="https://challenges.cloudflare.com/turnstile/v0/api.js?onload=rerDemoRender&render=explicit" async defer></script>` : ''}</body></html>`,
|
|
20
20
|
{ status, headers: { 'content-type': 'text/html; charset=utf-8', 'cache-control': 'no-store', 'content-security-policy': policy, 'referrer-policy': 'strict-origin', 'x-content-type-options': 'nosniff', ...headers } });
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -26,8 +26,8 @@ export function startPage(env, { status = 200, notice, pending = false, headers
|
|
|
26
26
|
return html(env, { page: 'start', title: `Try ${env.DEMO_NAME}`, status, headers, turnstile: true, refresh: pending, body: `<h1 id="title">Try ${name}</h1>
|
|
27
27
|
<p class="intro">Your own copy of ${name}, signed in as its owner, with sample data.</p>
|
|
28
28
|
<ul><li>Public checks run live. Messages and account changes are simulated.</li><li>It ends after an hour, or 15 idle minutes.</li><li>Then it is deleted. Nobody else can see it.</li></ul>
|
|
29
|
-
<p class="notice" id="notice" role="alert"${notice ? '' : ' hidden'}>${notice ? escape(notice) : ''}</p><form id="start" method="post" action="/__demo/start" data-auto="${notice || pending ? '0' : '1'}"${pending ? ' data-resume="1" data-state="working"' : ''}><div class="cf-turnstile" data-sitekey="${escape(env.TURNSTILE_SITE_KEY)}" data-size="flexible" data-callback="rerDemoVerified" data-before-interactive-callback="rerDemoInteractive" data-after-interactive-callback="rerDemoChecking" data-expired-callback="rerDemoExpired" data-error-callback="rerDemoCheckFailed"></div>
|
|
30
|
-
<button class="button" type="submit"
|
|
29
|
+
<p class="notice" id="notice" role="alert"${notice ? '' : ' hidden'}>${notice ? escape(notice) : ''}</p><form id="start" method="post" action="/__demo/start" data-auto="${notice || pending ? '0' : '1'}"${pending ? ' data-resume="1" data-state="working"' : ' data-state="waiting"'}><div class="cf-turnstile" data-theme="light" data-sitekey="${escape(env.TURNSTILE_SITE_KEY)}" data-size="flexible" data-callback="rerDemoVerified" data-before-interactive-callback="rerDemoInteractive" data-after-interactive-callback="rerDemoChecking" data-expired-callback="rerDemoExpired" data-error-callback="rerDemoCheckFailed"></div>
|
|
30
|
+
<button class="button" type="submit" disabled><span class="spinner" aria-hidden="true"></span><span class="label">${pending ? 'Starting your demo…' : 'Waiting for the human check…'}</span></button>
|
|
31
31
|
<ol class="steps" aria-hidden="true"><li data-at="done">Checking you're human</li><li data-at="now">Starting a private copy</li><li data-at="next">Signing you in</li></ol>
|
|
32
32
|
<p class="note" id="note">${pending ? 'Your demo will open automatically when ready.' : 'Complete the human check to start your demo.'}</p><noscript><p class="note">The human check needs JavaScript. Turn it on to start the demo.</p></noscript><p class="visually-hidden" id="status" role="status"></p></form>` });
|
|
33
33
|
}
|
|
@@ -77,7 +77,7 @@ window.rerDemoExpired=()=>checking()&&waiting();
|
|
|
77
77
|
window.rerDemoCheckFailed=()=>checking()&&show('failed',{label:'Try again',note:'',live:'',notice:'The human check did not load. Try again.'});
|
|
78
78
|
addEventListener('DOMContentLoaded',()=>{
|
|
79
79
|
if(el().form.dataset.resume==='1')go(true);
|
|
80
|
-
else if(
|
|
80
|
+
else if(el().form.dataset.state==='waiting')waiting();
|
|
81
81
|
el().form.addEventListener('submit',event=>{
|
|
82
82
|
event.preventDefault();
|
|
83
83
|
const state=el().form.dataset.state;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Resolve the built seed's CSS before serving the gate: no stylesheet round
|
|
2
|
+
// trips, and relative imports/font/mark URLs still refer to their source file.
|
|
3
|
+
const origin = 'https://theme.invalid';
|
|
4
|
+
const imports = /@import\s+(?:url\(\s*(['"]?)([^'"\s)]+)\1\s*\)|(['"])([^'"]+)\3)\s*([^;]*);/gi;
|
|
5
|
+
|
|
6
|
+
function localURL(value, path) {
|
|
7
|
+
const url = new URL(value, origin + path);
|
|
8
|
+
if (url.origin !== origin) throw Error(`Demo theme must use same-origin assets: ${value}`);
|
|
9
|
+
return url.pathname + url.search + url.hash;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function conditioned(css, conditions) {
|
|
13
|
+
// @import allows layer, supports, then media; keep their cascade semantics.
|
|
14
|
+
const wrappers = [];
|
|
15
|
+
let rest = conditions.trim();
|
|
16
|
+
for (const kind of ['layer', 'supports']) {
|
|
17
|
+
if (!rest.startsWith(kind)) continue;
|
|
18
|
+
rest = rest.slice(kind.length).trimStart();
|
|
19
|
+
let value = '';
|
|
20
|
+
if (rest.startsWith('(')) {
|
|
21
|
+
let depth = 0, end = 0;
|
|
22
|
+
do { if (rest[end] === '(') depth++; if (rest[end] === ')') depth--; end++; } while (depth && end < rest.length);
|
|
23
|
+
if (depth) throw Error(`Invalid demo theme import: ${conditions}`);
|
|
24
|
+
value = rest.slice(1, end - 1); rest = rest.slice(end).trimStart();
|
|
25
|
+
} else if (kind === 'supports') throw Error(`Invalid demo theme import: ${conditions}`);
|
|
26
|
+
wrappers.push(kind === 'supports' ? `@supports (${value})` : `@layer ${value}`);
|
|
27
|
+
}
|
|
28
|
+
if (rest) wrappers.push(`@media ${rest}`);
|
|
29
|
+
return wrappers.reduceRight((body, wrapper) => `${wrapper}{${body}}`, css);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function inlineTheme(files, paths) {
|
|
33
|
+
function expand(path, parents = []) {
|
|
34
|
+
const key = new URL(path, origin).pathname;
|
|
35
|
+
if (parents.includes(key)) throw Error(`Cyclic demo theme import: ${[...parents, key].join(' -> ')}`);
|
|
36
|
+
const bytes = files.get(key);
|
|
37
|
+
if (!bytes) throw Error(`Demo theme asset missing: ${key}`);
|
|
38
|
+
const css = bytes.toString().replace(/\/\*[\s\S]*?\*\//g, '').replace(/@charset\s+['"][^'"]+['"]\s*;/gi, '');
|
|
39
|
+
// Rebase before expansion so an imported file keeps its own URL base.
|
|
40
|
+
const rebased = css.replace(/url\(\s*(['"]?)([^'"\s)]+)\1\s*\)/gi, (_, _quote, value) => `url("${localURL(value, key)}")`);
|
|
41
|
+
return rebased.replace(imports, (_, _q1, url, _q2, string, conditions) => conditioned(expand(localURL(url ?? string, key), [...parents, key]), conditions));
|
|
42
|
+
}
|
|
43
|
+
return paths.map(path => expand(path)).join('\n').replace(/@font-face\s*\{([^{}]*)\}/gi, (_, body) => {
|
|
44
|
+
// A seed's block/auto/default display must not hold the gate's first paint.
|
|
45
|
+
const declarations = body.replace(/font-display\s*:[^;}]*(;|$)/gi, '');
|
|
46
|
+
const display = /font-display\s*:\s*optional\s*(?:;|$)/i.test(body) ? 'optional' : 'swap';
|
|
47
|
+
return `@font-face{${declarations.trim().replace(/;?$/, ';')}font-display:${display};}`;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
export const
|
|
5
|
-
const
|
|
1
|
+
// Resolve the seed's actual painted palette, including CSS aliases and dark
|
|
2
|
+
// media rules, before Turnstile renders. A light-only seed stays light even
|
|
3
|
+
// when the visitor prefers dark. Marks follow the same media changes.
|
|
4
|
+
export const THEME_SCRIPT = `(()=>{
|
|
5
|
+
const root=document.documentElement,card=document.querySelector('.card');
|
|
6
|
+
const widget=document.querySelector('.cf-turnstile'),mark=document.querySelector('.brand img'),name=document.querySelector('.brand span');
|
|
7
|
+
let widgetId,pixel;
|
|
8
|
+
const luminance=colour=>{
|
|
9
|
+
if(!pixel){const canvas=document.createElement('canvas');canvas.width=canvas.height=1;pixel=canvas.getContext('2d',{willReadFrequently:true})}
|
|
10
|
+
pixel.fillStyle=colour;pixel.fillRect(0,0,1,1);
|
|
11
|
+
const [r,g,b]=[...pixel.getImageData(0,0,1,1).data].slice(0,3).map(value=>{const c=value/255;return c<=.04045?c/12.92:((c+.055)/1.055)**2.4});
|
|
12
|
+
return .2126*r+.7152*g+.0722*b;
|
|
13
|
+
};
|
|
14
|
+
window.rerDemoRender=()=>{update();if(widget)widgetId=turnstile.render(widget,{theme:widget.dataset.theme})};
|
|
6
15
|
const update=()=>{
|
|
7
|
-
const
|
|
16
|
+
const style=getComputedStyle(card),scheme=luminance(style.backgroundColor)<luminance(style.color)?'dark':'light';
|
|
17
|
+
root.dataset.demoScheme=scheme;
|
|
18
|
+
if(widget&&widget.dataset.theme!==scheme){
|
|
19
|
+
widget.dataset.theme=scheme;
|
|
20
|
+
if(widgetId!==undefined){window.rerDemoExpired();turnstile.remove(widgetId);window.rerDemoRender()}
|
|
21
|
+
}
|
|
22
|
+
const token=getComputedStyle(root).getPropertyValue('--rer-logo');
|
|
8
23
|
const match=/url\\(\\s*(['"]?)([^'"\\)]+)\\1\\s*\\)/.exec(token);
|
|
9
24
|
mark.hidden=true;name.removeAttribute('aria-hidden');
|
|
10
25
|
if(!match)return;
|
|
@@ -14,5 +29,7 @@ export const LOGO_SCRIPT = `(()=>{
|
|
|
14
29
|
mark.onerror=()=>{mark.hidden=true;name.removeAttribute('aria-hidden')};
|
|
15
30
|
mark.src=url.href;
|
|
16
31
|
};
|
|
17
|
-
|
|
32
|
+
// The inline CSS paints the card immediately; mark/scheme work follows that
|
|
33
|
+
// first frame. If Turnstile arrives sooner, its callback updates before render.
|
|
34
|
+
requestAnimationFrame(()=>setTimeout(update,0));matchMedia('(prefers-color-scheme: dark)').addEventListener('change',update);
|
|
18
35
|
})()`;
|
|
@@ -2,26 +2,26 @@ import { mkdir, writeFile } from 'node:fs/promises';
|
|
|
2
2
|
import { dirname, join } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
4
|
import { shared } from '../../cli/shared.mjs';
|
|
5
|
+
import { inlineTheme } from './theme-css.mjs';
|
|
5
6
|
|
|
6
7
|
const prefix = '/__demo/theme';
|
|
7
8
|
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// a seed's own files. The seed stylesheet follows it, just as in the Lobby;
|
|
11
|
-
// the browser resolves imports, token aliases and light/dark media rules.
|
|
9
|
+
// Keep the Lobby's cascade (maintained defaults, seed fonts, seed theme), but
|
|
10
|
+
// resolve it at build time so the gate can paint without blocking CSS fetches.
|
|
12
11
|
export async function prepareTheme(folder, assets) {
|
|
13
12
|
const { loadSeedTheme } = await shared('theme-files.mjs');
|
|
14
13
|
const defaults = await loadSeedTheme(fileURLToPath(new URL('../../default-seed/', import.meta.url)), 'public/rer-theme.css');
|
|
15
|
-
const paths = [];
|
|
14
|
+
const paths = [], files = new Map(assets.map(file => ['/' + file.path, Buffer.from(file.base64, 'base64')]));
|
|
16
15
|
for (const [path, file] of defaults.files) {
|
|
17
16
|
const target = join(folder, 'assets', prefix, path);
|
|
18
17
|
await mkdir(dirname(target), { recursive: true });
|
|
19
18
|
const bytes = file.type === 'text/css'
|
|
20
|
-
? file.bytes.toString().replace(/url\((['"]?)(\/[^)'"\s]+)\1\)/g, (_, quote, url) => `url(${quote}${prefix}${url}${quote})`)
|
|
19
|
+
? Buffer.from(file.bytes.toString().replace(/url\((['"]?)(\/[^)'"\s]+)\1\)/g, (_, quote, url) => `url(${quote}${prefix}${url}${quote})`))
|
|
21
20
|
: file.bytes;
|
|
22
21
|
await writeFile(target, bytes);
|
|
22
|
+
files.set(prefix + path, bytes);
|
|
23
23
|
paths.push(prefix + path);
|
|
24
24
|
}
|
|
25
|
-
const
|
|
26
|
-
return { paths,
|
|
25
|
+
const stylesheets = [prefix + '/rer-theme.css', ...['/fonts/fonts.css', '/rer-theme.css'].filter(path => files.has(path))];
|
|
26
|
+
return { paths, css: inlineTheme(files, stylesheets) };
|
|
27
27
|
}
|