@dokebi/template-inertia 0.4.20 → 0.4.22

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/dist/pages.js CHANGED
@@ -25,3 +25,85 @@ export function modulePages(table) {
25
25
  },
26
26
  });
27
27
  }
28
+ const REGISTRY = Symbol.for('dokebi.inertia.template-bundles.v1');
29
+ /**
30
+ * D-0291: the page lookup of views/app.js and views/ssr.js with template bundles. Without a
31
+ * bundle for this page's template it is the lookup of before: views/<template>, views/default,
32
+ * then the module pages. With one (the first HTML names it; on the server, the render's
33
+ * generation), the bundle's pages and Layout come first. In the browser a bundle page loads its
34
+ * stylesheets, then its module; one that cannot load falls back to the app's page (a console
35
+ * warning). Call it once per page load (browser) or per render (server), before
36
+ * createInertiaApp.
37
+ */
38
+ export async function templatePages(options) {
39
+ const { files, modulePages: modules } = options;
40
+ const template = options.template ?? 'default';
41
+ const own = (path) => files[`./${template}/${path}.vue`] ?? files[`./default/${path}.vue`];
42
+ const appPage = (name) => {
43
+ const found = own(`Pages/${name}`) ?? modules?.page(template, name);
44
+ if (!found)
45
+ throw new Error(`Unknown page: ${name}`);
46
+ return found;
47
+ };
48
+ const doc = (options.document ?? globalThis.document);
49
+ if (doc === undefined) {
50
+ // Server rendering: the registry template-inertia keeps for this render.
51
+ const registry = globalThis[REGISTRY];
52
+ const bundle = registry?.current();
53
+ const usable = bundle !== undefined && bundle.template === template ? bundle : undefined;
54
+ const layout = usable?.page('Layout');
55
+ return {
56
+ template,
57
+ bundle: usable ? 'server' : undefined,
58
+ page: (name) => usable?.page(`Pages/${name}`) ?? appPage(name),
59
+ layout: () => (layout ?? own('Layout'))?.default,
60
+ };
61
+ }
62
+ let table;
63
+ try {
64
+ const text = doc.getElementById('dokebi-template')?.textContent;
65
+ if (text) {
66
+ const parsed = JSON.parse(text);
67
+ if (parsed?.template === template && parsed.pages && typeof parsed.pages === 'object')
68
+ table = parsed;
69
+ }
70
+ }
71
+ catch (error) {
72
+ console.warn('dokebi: the template bundle table could not be read; the app pages answer', error);
73
+ }
74
+ const load = options.load ?? ((url) => import(/* @vite-ignore */ url));
75
+ const styles = (urls) => Promise.all(urls.map((href) => new Promise((done) => {
76
+ // The server wrote the first page's stylesheets; bundle URLs hold no quote or backslash.
77
+ const quoted = href.replace(/["\\]/g, '\\$&');
78
+ if (doc.querySelector(`link[rel="stylesheet"][href="${quoted}"]`))
79
+ return done();
80
+ const link = doc.createElement('link');
81
+ link.rel = 'stylesheet';
82
+ link.href = href;
83
+ link.onload = () => done();
84
+ link.onerror = () => done();
85
+ doc.head.appendChild(link);
86
+ })));
87
+ const fromBundle = async (key) => {
88
+ const entry = table?.pages[key];
89
+ if (!entry)
90
+ return undefined;
91
+ try {
92
+ await styles(entry.css);
93
+ return await load(entry.js);
94
+ }
95
+ catch (error) {
96
+ console.warn(`dokebi: the template bundle page ${key} could not be loaded; the app page answers`, error);
97
+ return undefined;
98
+ }
99
+ };
100
+ const layout = await fromBundle('Layout');
101
+ return {
102
+ template,
103
+ bundle: table?.buildId,
104
+ page: (name) => table?.pages[`Pages/${name}`]
105
+ ? fromBundle(`Pages/${name}`).then((module) => module ?? appPage(name))
106
+ : appPage(name),
107
+ layout: () => (layout ?? own('Layout'))?.default,
108
+ };
109
+ }
@@ -5,6 +5,7 @@ import type { FastifyReply, FastifyRequest } from 'fastify';
5
5
  import { type InertiaBootFallback, type NormalizedBootFallback } from './boot-fallback.js';
6
6
  import { type InertiaHead } from './head.js';
7
7
  import { type InertiaProp } from './props.js';
8
+ import type { TemplateUse } from './template-runtime.js';
8
9
  export type Json = null | boolean | number | string | readonly Json[] | {
9
10
  readonly [key: string]: Json;
10
11
  };
@@ -99,6 +100,11 @@ export interface InertiaHooks {
99
100
  * the session and answers 303 back; false when the request has no session or no way back.
100
101
  */
101
102
  readonly validation?: (request: FastifyRequest, reply: FastifyReply, errors: Readonly<Record<string, string>>) => Promise<boolean>;
103
+ /**
104
+ * D-0291: the template bundle of this request's template, or undefined: its asset version,
105
+ * the head markup of its first HTML and the server render under it.
106
+ */
107
+ readonly template?: (request: FastifyRequest, version: string) => TemplateUse | undefined;
102
108
  }
103
109
  /** The page object Inertia hands to the client and to the SSR bundle. */
104
110
  export interface InertiaPage {
package/dist/responder.js CHANGED
@@ -323,16 +323,20 @@ export class InertiaResponder {
323
323
  withShared = true) {
324
324
  vary(reply);
325
325
  const inertia = request.headers['x-inertia'] === 'true';
326
+ // D-0291: a template bundle of this request's template: its build is part of the version, so
327
+ // a page opened before a swap reloads on its next visit.
328
+ const template = this.hooks.template?.(request, this.options.version);
329
+ const version = template?.version ?? this.options.version;
326
330
  // The protocol's version check is for GET visits only (the official adapters'): the 409 makes
327
331
  // the client load X-Inertia-Location, so an error page of a POST must not turn into a GET.
328
332
  if (inertia &&
329
333
  (request.method === 'GET' || request.method === 'HEAD') &&
330
334
  request.headers['x-inertia-version'] !== undefined &&
331
- request.headers['x-inertia-version'] !== this.options.version) {
335
+ request.headers['x-inertia-version'] !== version) {
332
336
  return reply
333
337
  .code(409)
334
338
  .header('X-Inertia-Location', ownLocation(request.url))
335
- .header('X-Inertia-Version', this.options.version)
339
+ .header('X-Inertia-Version', version)
336
340
  .send();
337
341
  }
338
342
  // A sealed request (seal host, D-0062): the props leave as one sealed frame, never as HTML,
@@ -436,7 +440,7 @@ export class InertiaResponder {
436
440
  component,
437
441
  props: resolved,
438
442
  url: request.url,
439
- version: this.options.version,
443
+ version,
440
444
  clearHistory,
441
445
  encryptHistory,
442
446
  ...meta.page,
@@ -498,10 +502,12 @@ export class InertiaResponder {
498
502
  const frame = sealer.encode(json);
499
503
  return reply
500
504
  .type('text/html; charset=utf-8')
501
- .send(`<!doctype html><html${htmlLanguage}><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>${escapeHtml(title)}</title>${nonceMeta}${head?.tags ?? ''}${styles.map((url) => `<link rel="stylesheet" href="${escapeHtml(url)}">`).join('')}${boot?.head ?? ''}${moduleScripts}</head><body><script data-page="${rootId}" type="application/json" data-sealed="true">${escapeHtml(frame)}</script><div id="${rootId}">${boot?.root ?? ''}</div></body></html>`);
505
+ .send(`<!doctype html><html${htmlLanguage}><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>${escapeHtml(title)}</title>${nonceMeta}${head?.tags ?? ''}${styles.map((url) => `<link rel="stylesheet" href="${escapeHtml(url)}">`).join('')}${boot?.head ?? ''}${template?.head(component, cspNonce ?? '') ?? ''}${moduleScripts}</head><body><script data-page="${rootId}" type="application/json" data-sealed="true">${escapeHtml(frame)}</script><div id="${rootId}">${boot?.root ?? ''}</div></body></html>`);
502
506
  }
503
507
  // Only the first HTML is server rendered; Inertia visits above stay JSON.
504
- const rendered = this.ssr ? await this.#serverRender(JSON.parse(json), rootId) : undefined;
508
+ const rendered = this.ssr
509
+ ? await this.#serverRender(JSON.parse(json), rootId, template)
510
+ : undefined;
505
511
  if (publicPage !== undefined) {
506
512
  if (publicPage.cacheControl !== undefined) {
507
513
  reply.header('Cache-Control', publicPage.cacheControl);
@@ -531,7 +537,7 @@ export class InertiaResponder {
531
537
  const sealHost = sealer ? SEAL_HOST_META : '';
532
538
  return reply
533
539
  .type('text/html; charset=utf-8')
534
- .send(`<!doctype html><html${htmlLanguage}><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">${sealHost}${titled ? '' : `<title>${escapeHtml(title)}</title>`}${nonceMeta}${head?.tags ?? ''}${styles.map((url) => `<link rel="stylesheet" href="${escapeHtml(url)}">`).join('')}${rendered ? '' : (boot?.head ?? '')}${moduleScripts}${ssrHead.join('')}</head><body>${rendered?.body ?? `<script data-page="${rootId}" type="application/json">${safeJson}</script><div id="${rootId}">${boot?.root ?? ''}</div>`}</body></html>`);
540
+ .send(`<!doctype html><html${htmlLanguage}><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">${sealHost}${titled ? '' : `<title>${escapeHtml(title)}</title>`}${nonceMeta}${head?.tags ?? ''}${styles.map((url) => `<link rel="stylesheet" href="${escapeHtml(url)}">`).join('')}${rendered ? '' : (boot?.head ?? '')}${template?.head(component, cspNonce ?? '') ?? ''}${moduleScripts}${ssrHead.join('')}</head><body>${rendered?.body ?? `<script data-page="${rootId}" type="application/json">${safeJson}</script><div id="${rootId}">${boot?.root ?? ''}</div>`}</body></html>`);
535
541
  }
536
542
  /**
537
543
  * The value of one selected prop. A function runs here; a rescued deferred prop that throws is
@@ -567,10 +573,14 @@ export class InertiaResponder {
567
573
  * The SSR bundle's head and root for this page, or undefined to answer client rendered
568
574
  * (failure 'fallback'). The page object is a fresh copy, so the bundle cannot change the props.
569
575
  */
570
- async #serverRender(page, rootId) {
576
+ async #serverRender(page, rootId, template) {
571
577
  const ssr = this.ssr;
572
578
  try {
573
- const result = await ssr.render(page);
579
+ // D-0291: under the template's bundle; a bundle page that fails is set aside and the
580
+ // render runs once more with the app's own page.
581
+ const result = template
582
+ ? await template.render(() => Promise.resolve(ssr.render(page)), page.component)
583
+ : await ssr.render(page);
574
584
  const { head, body } = (result ?? {});
575
585
  if (!Array.isArray(head) ||
576
586
  head.some((tag) => typeof tag !== 'string') ||
@@ -5,20 +5,27 @@
5
5
  // shared modules (vue, @inertiajs/vue3, the app's SDK, …) left as imports, then the manifest with
6
6
  // each page's files, stylesheets, preloads and `meta`, and the sha256 of every file. The bundle
7
7
  // is checked like the app will check it before it is returned.
8
- import { existsSync, readFileSync } from 'node:fs';
9
- import { lstat, readdir, readFile, rm, stat, writeFile } from 'node:fs/promises';
8
+ import { existsSync, readFileSync, realpathSync } from 'node:fs';
9
+ import { lstat, mkdir, readdir, readFile, rm, stat, writeFile } from 'node:fs/promises';
10
10
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
11
11
  import { pathToFileURL } from 'node:url';
12
12
  import { ConsoleLogger } from '@dokebi/core';
13
13
  import { InertiaError, InertiaUsageError } from './errors.js';
14
14
  import { checkTemplateBundle, jsonValue, PAGE_META_MAX_BYTES, SHARED_DEFAULTS, SHARED_SPECIFIER, sha256, TEMPLATE_FORMAT, TEMPLATE_MANIFEST, TEMPLATE_MAX_BYTES, TEMPLATE_NAME, TEMPLATE_PAGE, TEMPLATE_VERSION, } from './template-bundle.js';
15
15
  import { packageVersion } from './template-shared.js';
16
+ import { registerVueTypeScript } from './vue-typescript.js';
16
17
  /** The builder written into `builtWith` (scripts/testing/check-metadata.mjs keeps it the package version). */
17
- const BUILDER = { name: 'dokebi-template-inertia', version: '0.4.20' };
18
+ const BUILDER = { name: 'dokebi-template-inertia', version: '0.4.22' };
18
19
  function defaultLogger() {
19
20
  return new ConsoleLogger({ level: 'info' }, { plugin: 'dokebi-template-inertia', process: 'template-build' });
20
21
  }
21
22
  const usage = (message) => new InertiaUsageError('INVALID_TEMPLATE_BUILD', message);
23
+ /** The file access of the Vue compiler for imported props types (TypeScript 7 has none of its own). */
24
+ const VUE_TYPE_FILES = {
25
+ fileExists: (file) => existsSync(file),
26
+ readFile: (file) => readFileSync(file, 'utf8'),
27
+ realpath: (file) => realpathSync(file),
28
+ };
22
29
  /** `a` is `b` or inside it. */
23
30
  function within(a, b) {
24
31
  const path = relative(b, a);
@@ -149,9 +156,22 @@ export async function buildTemplateBundle(options) {
149
156
  throw usage(`${options.dir} has no Layout.vue and no Pages/**/*.vue`);
150
157
  const input = Object.fromEntries(pages);
151
158
  const vite = await importPackage(root, 'vite', 'Install Vite in the template repository: npm install --save-dev vite');
152
- const vue = options.config
159
+ // The project's vite config (--config) may bring its own Vue plugin; otherwise one is added.
160
+ const configFile = options.config ? resolve(root, options.config) : undefined;
161
+ let ownVue = false;
162
+ if (configFile) {
163
+ const loaded = (await vite.loadConfigFromFile({ command: 'build', mode: 'production' }, configFile, root)) ?? {
164
+ config: {},
165
+ };
166
+ const names = (loaded.config.plugins ?? [])
167
+ .flat(Infinity)
168
+ .map((plugin) => plugin?.name);
169
+ ownVue = names.includes('vite:vue');
170
+ }
171
+ const vue = ownVue
153
172
  ? undefined
154
173
  : await importPackage(root, '@vitejs/plugin-vue', 'Install the Vue plugin in the template repository: npm install --save-dev @vitejs/plugin-vue');
174
+ registerVueTypeScript(root, logger);
155
175
  const isShared = (id) => shared.includes(id);
156
176
  logger.log('info', 'Template bundle build started', {
157
177
  code: 'INERTIA_TEMPLATE_BUILD_STARTED',
@@ -164,10 +184,11 @@ export async function buildTemplateBundle(options) {
164
184
  });
165
185
  const common = {
166
186
  root,
167
- configFile: options.config ? resolve(root, options.config) : false,
187
+ configFile: configFile ?? false,
168
188
  logLevel: 'warn',
169
189
  publicDir: false,
170
- plugins: vue ? [vue.default()] : [],
190
+ // The compiler reads the props types a page imports from files (as the app's vite config does).
191
+ plugins: vue ? [vue.default({ script: { fs: VUE_TYPE_FILES } })] : [],
171
192
  };
172
193
  const imported = new Set();
173
194
  const collect = (items) => {
@@ -178,6 +199,9 @@ export async function buildTemplateBundle(options) {
178
199
  };
179
200
  let browserItems;
180
201
  let serverItems;
202
+ // `vite build` sets process.env.NODE_ENV to production: a caller in the same process (a
203
+ // test, a script that builds and then serves) gets it back as it was.
204
+ const environment = process.env.NODE_ENV;
181
205
  try {
182
206
  browserItems = outputs(await vite.build({
183
207
  ...common,
@@ -225,6 +249,12 @@ export async function buildTemplateBundle(options) {
225
249
  catch (cause) {
226
250
  throw new InertiaError('TEMPLATE_BUILD_FAILED', `The Vite build of ${name} failed`, { cause });
227
251
  }
252
+ finally {
253
+ if (environment === undefined)
254
+ delete process.env.NODE_ENV;
255
+ else
256
+ process.env.NODE_ENV = environment;
257
+ }
228
258
  collect(browserItems);
229
259
  collect(serverItems);
230
260
  // The browser manifest gives each page its stylesheets and the chunks it imports.
@@ -287,8 +317,31 @@ export async function buildTemplateBundle(options) {
287
317
  ...(meta === undefined ? {} : { meta }),
288
318
  };
289
319
  }
320
+ // D-0291 stage 3b: the template's screen words, locales/<locale>/<namespace>.json, as they are
321
+ // (the app's @dokebi/i18n reads them with its own loader and rules).
322
+ const wordsFolder = join(folder, 'locales');
323
+ let wordFiles = 0;
324
+ if (existsSync(wordsFolder))
325
+ for (const file of await listFiles(wordsFolder)) {
326
+ if (file.split('/').some((part) => part.startsWith('.')))
327
+ continue;
328
+ if (!/^[A-Za-z][A-Za-z0-9_-]{0,34}(?:\/[A-Za-z0-9_][A-Za-z0-9_.-]{0,99}){1,8}\.json$/.test(file))
329
+ throw usage(`locales/${file} is not a screen-word file: locales/<locale>/<namespace>.json (letters, digits, _ . -)`);
330
+ const text = await readFile(join(wordsFolder, file), 'utf8');
331
+ try {
332
+ const parsed = JSON.parse(text);
333
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))
334
+ throw new Error('not an object of keys');
335
+ }
336
+ catch (cause) {
337
+ throw new InertiaError('TEMPLATE_BUILD_FAILED', `locales/${file} is not a JSON object of words: ${cause.message}`, { cause });
338
+ }
339
+ await mkdir(dirname(join(out, 'locales', file)), { recursive: true });
340
+ await writeFile(join(out, 'locales', file), text);
341
+ wordFiles++;
342
+ }
290
343
  const files = {};
291
- for (const top of ['browser', 'ssr'])
344
+ for (const top of wordFiles ? ['browser', 'ssr', 'locales'] : ['browser', 'ssr'])
292
345
  for (const file of await listFiles(join(out, top))) {
293
346
  const content = await readFile(join(out, top, file));
294
347
  files[`${top}/${file}`] = { bytes: content.length, sha256: sha256(content) };
@@ -326,6 +379,7 @@ export async function buildTemplateBundle(options) {
326
379
  buildId: result.buildId,
327
380
  out: relative(root, out),
328
381
  pages: result.pages.length,
382
+ words: wordFiles,
329
383
  files: result.files,
330
384
  bytes: result.bytes,
331
385
  shared: manifest.shared,
@@ -26,8 +26,13 @@ export const TEMPLATE_NAME = /^[a-z][a-z0-9-]{0,31}$/;
26
26
  export const TEMPLATE_VERSION = /^[0-9A-Za-z][0-9A-Za-z.+-]{0,63}$/;
27
27
  /** A page of a bundle: `Layout`, or `Pages/<path>` without the `.vue`. */
28
28
  export const TEMPLATE_PAGE = /^(?:Layout|Pages(?:\/[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}){1,16})$/;
29
- /** A file of a bundle: under browser/ or ssr/, plain path segments only. */
30
- const FILE = /^(?:browser|ssr)(?:\/[A-Za-z0-9_@+][A-Za-z0-9_.@+-]{0,199}){1,32}$/;
29
+ /**
30
+ * A file of a bundle: under browser/ or ssr/, or a screen-word file `locales/<locale>/<ns>.json`
31
+ * (D-0291 stage 3b), plain path segments only.
32
+ */
33
+ const FILE = /^(?:(?:browser|ssr)(?:\/[A-Za-z0-9_@+][A-Za-z0-9_.@+-]{0,199}){1,32}|locales\/[A-Za-z][A-Za-z0-9_-]{0,34}(?:\/[A-Za-z0-9_][A-Za-z0-9_.-]{0,99}){1,8}\.json)$/;
34
+ /** The folders of a bundle. */
35
+ const FOLDERS = ['browser', 'ssr', 'locales'];
31
36
  /** A shared module specifier: a package name with an optional subpath. */
32
37
  export const SHARED_SPECIFIER = /^(?:@[a-z0-9][a-z0-9._-]{0,213}\/)?[a-z0-9][a-z0-9._-]{0,213}(?:\/[A-Za-z0-9_.@+-]{1,200}){0,16}$/;
33
38
  /** A page's `meta` (JSON) may take this many bytes. */
@@ -86,7 +91,7 @@ export function manifestProblem(value) {
86
91
  return 'files must be an object of path → { bytes, sha256 }';
87
92
  for (const [file, entry] of Object.entries(value.files)) {
88
93
  if (!FILE.test(file) || file.split('/').some((part) => part === '..' || part === '.'))
89
- return `file ${file} is not a path under browser/ or ssr/`;
94
+ return `file ${file} is not a path under browser/ or ssr/, or a locales/<locale>/<namespace>.json`;
90
95
  if (!plain(entry) ||
91
96
  !Number.isSafeInteger(entry.bytes) ||
92
97
  entry.bytes < 0 ||
@@ -238,7 +243,7 @@ export async function checkTemplateBundle(dir, limits = {}) {
238
243
  return { manifest, buildId, bytes: 0, problems };
239
244
  const found = [];
240
245
  const links = [];
241
- for (const top of ['browser', 'ssr']) {
246
+ for (const top of FOLDERS) {
242
247
  try {
243
248
  const info = await lstat(join(dir, top));
244
249
  if (!info.isDirectory()) {
@@ -255,12 +260,11 @@ export async function checkTemplateBundle(dir, limits = {}) {
255
260
  for (const entry of await readdir(dir, { withFileTypes: true }))
256
261
  if (entry.name !== TEMPLATE_MANIFEST &&
257
262
  entry.name !== TEMPLATE_SIGNATURE &&
258
- entry.name !== 'browser' &&
259
- entry.name !== 'ssr')
263
+ !FOLDERS.includes(entry.name))
260
264
  problems.push({
261
265
  code: 'TEMPLATE_FILE_EXTRA',
262
266
  file: entry.name,
263
- message: `${entry.name} is not part of a bundle (only ${TEMPLATE_MANIFEST}, ${TEMPLATE_SIGNATURE}, browser/ and ssr/)`,
267
+ message: `${entry.name} is not part of a bundle (only ${TEMPLATE_MANIFEST}, ${TEMPLATE_SIGNATURE}, browser/, ssr/ and locales/)`,
264
268
  });
265
269
  for (const link of links)
266
270
  problems.push({
@@ -0,0 +1,38 @@
1
+ import { type Logger } from '@dokebi/core';
2
+ /** Where a page is drawn: `/__dokebi/preview/<page>?case=<case>`. */
3
+ export declare const PREVIEW_PREFIX = "/__dokebi/preview/";
4
+ export interface TemplatePreviewOptions {
5
+ /** The template repository root (its node_modules has vite and @vitejs/plugin-vue). */
6
+ readonly root?: string;
7
+ /** The template folder, relative to root. */
8
+ readonly dir: string;
9
+ /** 0 picks a free port (default 5180). */
10
+ readonly port?: number;
11
+ /** Default 127.0.0.1 (loopback only). */
12
+ readonly host?: string;
13
+ /** A vite config of the project to merge; @vitejs/plugin-vue is added unless it has its own. */
14
+ readonly config?: string;
15
+ readonly logger?: Logger;
16
+ }
17
+ export interface TemplatePreviewPage {
18
+ /** The page name (`Home`, `board/List`), as `render(…, 'Home')` names it. */
19
+ readonly page: string;
20
+ readonly cases: readonly string[];
21
+ }
22
+ export interface TemplatePreview {
23
+ readonly url: string;
24
+ readonly pages: readonly TemplatePreviewPage[];
25
+ close(): Promise<void>;
26
+ }
27
+ /** The cases of one page (`<Page>.preview.json`): case → props, checked. */
28
+ export declare function previewCases(file: string): Promise<Record<string, Record<string, unknown>>>;
29
+ /**
30
+ * D-0291 stage 3b: the `i18n` page prop of the preview from the template's own words
31
+ * (`locales/<locale>/<namespace>.json`), so pages that call t() draw; undefined without words.
32
+ */
33
+ export declare function previewWords(folder: string, wanted?: string): Promise<Record<string, unknown> | undefined>;
34
+ /**
35
+ * Starts the preview of the template folder `options.dir` (D-0291 stage 3). Resolves once the
36
+ * server listens; `close()` stops it.
37
+ */
38
+ export declare function startTemplatePreview(options: TemplatePreviewOptions): Promise<TemplatePreview>;