@teyik0/furin 0.1.0-alpha.10
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/adapter/bun.d.ts +3 -0
- package/dist/adapter/static.d.ts +3 -0
- package/dist/build/client.d.ts +25 -0
- package/dist/build/compile-entry.d.ts +35 -0
- package/dist/build/entry-template.d.ts +26 -0
- package/dist/build/hydrate.d.ts +24 -0
- package/dist/build/index.d.ts +7 -0
- package/dist/build/index.js +4716 -0
- package/dist/build/route-types.d.ts +21 -0
- package/dist/build/scan-server.d.ts +8 -0
- package/dist/build/server-routes-entry.d.ts +35 -0
- package/dist/build/shared.d.ts +11 -0
- package/dist/build/types.d.ts +76 -0
- package/dist/cli/config.d.ts +9 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +4751 -0
- package/dist/client.d.ts +195 -0
- package/dist/client.js +20 -0
- package/dist/config.d.ts +50 -0
- package/dist/config.js +28 -0
- package/dist/context-logger.d.ts +28 -0
- package/dist/dev-page-plugin.d.ts +109 -0
- package/dist/error.d.ts +23 -0
- package/dist/furin.d.ts +52 -0
- package/dist/furin.js +3948 -0
- package/dist/internal.d.ts +33 -0
- package/dist/link.d.ts +454 -0
- package/dist/link.js +1790 -0
- package/dist/not-found.d.ts +19 -0
- package/dist/plugin/index.d.ts +20 -0
- package/dist/plugin/index.js +1408 -0
- package/dist/plugin/transform-client.d.ts +9 -0
- package/dist/render/assemble.d.ts +15 -0
- package/dist/render/boundaries.d.ts +79 -0
- package/dist/render/cache.d.ts +96 -0
- package/dist/render/default-screens.d.ts +11 -0
- package/dist/render/digest.d.ts +16 -0
- package/dist/render/element.d.ts +8 -0
- package/dist/render/index.d.ts +53 -0
- package/dist/render/loaders.d.ts +21 -0
- package/dist/render/shell.d.ts +29 -0
- package/dist/render/template.d.ts +6 -0
- package/dist/router.d.ts +96 -0
- package/dist/router.js +2693 -0
- package/dist/runtime-env.d.ts +3 -0
- package/dist/utils.d.ts +6 -0
- package/package.json +77 -0
- package/src/adapter/README.md +13 -0
- package/src/adapter/bun.ts +239 -0
- package/src/adapter/static.ts +341 -0
- package/src/build/client.ts +153 -0
- package/src/build/compile-entry.ts +129 -0
- package/src/build/entry-template.ts +126 -0
- package/src/build/hydrate.ts +250 -0
- package/src/build/index.ts +151 -0
- package/src/build/route-types.ts +89 -0
- package/src/build/scan-server.ts +110 -0
- package/src/build/server-routes-entry.ts +55 -0
- package/src/build/shared.ts +78 -0
- package/src/build/types.ts +85 -0
- package/src/cli/config.ts +68 -0
- package/src/cli/index.ts +115 -0
- package/src/client.ts +278 -0
- package/src/config.ts +66 -0
- package/src/context-logger.ts +74 -0
- package/src/dev-page-plugin.ts +434 -0
- package/src/env.d.ts +49 -0
- package/src/error.ts +32 -0
- package/src/furin.ts +383 -0
- package/src/internal.ts +51 -0
- package/src/link.tsx +1578 -0
- package/src/not-found.ts +40 -0
- package/src/plugin/index.ts +80 -0
- package/src/plugin/transform-client.ts +372 -0
- package/src/render/assemble.ts +66 -0
- package/src/render/boundaries.tsx +176 -0
- package/src/render/cache.ts +251 -0
- package/src/render/default-screens.tsx +299 -0
- package/src/render/digest.ts +71 -0
- package/src/render/element.tsx +119 -0
- package/src/render/index.ts +867 -0
- package/src/render/loaders.ts +127 -0
- package/src/render/shell.ts +187 -0
- package/src/render/template.ts +55 -0
- package/src/router.ts +779 -0
- package/src/runtime-env.ts +6 -0
- package/src/utils.ts +68 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { Context } from "elysia";
|
|
2
|
+
import type { RuntimeRoute } from "../client";
|
|
3
|
+
import { useLogger } from "../context-logger.ts";
|
|
4
|
+
import { type FurinNotFoundError, isNotFoundError } from "../not-found.ts";
|
|
5
|
+
import type { ResolvedRoute } from "../router";
|
|
6
|
+
|
|
7
|
+
export type LoaderResult =
|
|
8
|
+
| { type: "data"; data: Record<string, unknown>; headers: Record<string, string> }
|
|
9
|
+
| { type: "redirect"; response: Response }
|
|
10
|
+
| { type: "not-found"; error: FurinNotFoundError; headers: Record<string, string> }
|
|
11
|
+
| { type: "error"; error: unknown; headers: Record<string, string> };
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Wraps the Elysia context so that any property NOT present on `ctx` is
|
|
15
|
+
* returned as an individual `Promise<value>` resolved from the accumulated
|
|
16
|
+
* parent data. Properties that ARE present on `ctx` (request, params, set, …)
|
|
17
|
+
* are returned as-is.
|
|
18
|
+
*
|
|
19
|
+
* A per-prop cache ensures the same Promise instance is returned on repeated
|
|
20
|
+
* access of the same field (stable reference for Promise.all etc.).
|
|
21
|
+
*/
|
|
22
|
+
function createLoaderCtx(
|
|
23
|
+
ctx: Record<string, unknown>,
|
|
24
|
+
accumulatedParentPromise: Promise<Record<string, unknown>>
|
|
25
|
+
): Record<string, unknown> {
|
|
26
|
+
const cache = new Map<string, Promise<unknown>>();
|
|
27
|
+
return new Proxy(ctx, {
|
|
28
|
+
get(target, prop: string | symbol) {
|
|
29
|
+
if (typeof prop !== "string") {
|
|
30
|
+
return Reflect.get(target, prop);
|
|
31
|
+
}
|
|
32
|
+
// Short-circuit well-known Promise/serialisation introspection keys so
|
|
33
|
+
// the proxy is never treated as a thenable by Promise.resolve() or
|
|
34
|
+
// JSON.stringify(), which would cause silent infinite loops or wrong types.
|
|
35
|
+
if (prop === "then" || prop === "catch" || prop === "finally" || prop === "toJSON") {
|
|
36
|
+
return Reflect.get(target, prop);
|
|
37
|
+
}
|
|
38
|
+
// RouteContext fields (request, params, query, set, headers, cookie,
|
|
39
|
+
// path, redirect) are present on target — return directly.
|
|
40
|
+
// Use hasOwn so prototype keys (toString, constructor, …) are not
|
|
41
|
+
// mistaken for context fields and incorrectly hide parent loader data.
|
|
42
|
+
if (Object.hasOwn(target, prop)) {
|
|
43
|
+
return target[prop];
|
|
44
|
+
}
|
|
45
|
+
// Everything else is a parent-data field → individual lazy Promise.
|
|
46
|
+
let entry = cache.get(prop);
|
|
47
|
+
if (!entry) {
|
|
48
|
+
entry = accumulatedParentPromise.then((data) => data[prop]);
|
|
49
|
+
cache.set(prop, entry);
|
|
50
|
+
}
|
|
51
|
+
return entry;
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// TODO: remove _rootLayout parameter in next refactor (unused; routeChain[0] is root layout)
|
|
57
|
+
export async function runLoaders(
|
|
58
|
+
route: ResolvedRoute,
|
|
59
|
+
ctx: Context,
|
|
60
|
+
_rootLayout: RuntimeRoute
|
|
61
|
+
): Promise<LoaderResult> {
|
|
62
|
+
try {
|
|
63
|
+
// Inject `log` so loaders can destructure it directly as `({ log })`.
|
|
64
|
+
// useLogger() resolves the correct logger for every rendering context:
|
|
65
|
+
// live request → evlog request-scoped logger, synthetic render → detached
|
|
66
|
+
// createLogger() from runInSyntheticRenderScope, outside any context → no-op.
|
|
67
|
+
const ctxRecord = { ...(ctx as Record<string, unknown>), log: useLogger() };
|
|
68
|
+
const loaderMap = new Map<RuntimeRoute, Promise<Record<string, unknown>>>();
|
|
69
|
+
|
|
70
|
+
// All loaders in the chain start immediately. Each receives a Proxy where
|
|
71
|
+
// parent-data fields are individually-awaitable Promises. The loader opts
|
|
72
|
+
// in to waiting by doing `await user` (or `Promise.all([user, org])`);
|
|
73
|
+
// if it never awaits a parent field it runs in full parallel.
|
|
74
|
+
let accumulatedParentPromise: Promise<Record<string, unknown>> = Promise.resolve({});
|
|
75
|
+
|
|
76
|
+
for (const r of route.routeChain) {
|
|
77
|
+
const parentAccum = accumulatedParentPromise; // capture for closure
|
|
78
|
+
|
|
79
|
+
if (r.loader) {
|
|
80
|
+
const loaderCtx = createLoaderCtx(ctxRecord, parentAccum);
|
|
81
|
+
const loaderPromise = Promise.resolve(r.loader(loaderCtx)).then((res) => res ?? {});
|
|
82
|
+
loaderMap.set(r, loaderPromise);
|
|
83
|
+
|
|
84
|
+
// Accumulate: previous ancestors + this loader's result.
|
|
85
|
+
// A void .catch() suppresses the "unhandled rejection" warning that
|
|
86
|
+
// fires when a sibling or child loader throws — but unlike `.catch(
|
|
87
|
+
// () => ({}))` it does NOT resolve the promise, so child loaders'
|
|
88
|
+
// field-accesses via createLoaderCtx still receive the rejection
|
|
89
|
+
// instead of silently resolving to undefined. The real rejection is
|
|
90
|
+
// re-thrown by the Promise.all below.
|
|
91
|
+
accumulatedParentPromise = Promise.all([parentAccum, loaderPromise]).then(([acc, own]) => ({
|
|
92
|
+
...acc,
|
|
93
|
+
...own,
|
|
94
|
+
}));
|
|
95
|
+
accumulatedParentPromise.catch(() => {
|
|
96
|
+
/* suppress unhandled-rejection warning */
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Page loader receives all route-chain fields as individual Promises.
|
|
102
|
+
const pageCtx = createLoaderCtx(ctxRecord, accumulatedParentPromise);
|
|
103
|
+
const pagePromise: Promise<Record<string, unknown>> = route.page?.loader
|
|
104
|
+
? Promise.resolve(route.page.loader(pageCtx)).then((r) => r ?? {})
|
|
105
|
+
: Promise.resolve({});
|
|
106
|
+
|
|
107
|
+
// Await everything in parallel, then flat-merge (same contract as before).
|
|
108
|
+
const results = await Promise.all([...loaderMap.values(), pagePromise]);
|
|
109
|
+
const data = Object.assign({}, ...results);
|
|
110
|
+
const headers: Record<string, string> = {};
|
|
111
|
+
Object.assign(headers, ctx.set.headers);
|
|
112
|
+
|
|
113
|
+
return { type: "data", data, headers };
|
|
114
|
+
} catch (err) {
|
|
115
|
+
if (isNotFoundError(err)) {
|
|
116
|
+
const headers: Record<string, string> = {};
|
|
117
|
+
Object.assign(headers, ctx.set.headers);
|
|
118
|
+
return { type: "not-found", error: err, headers };
|
|
119
|
+
}
|
|
120
|
+
if (err instanceof Response) {
|
|
121
|
+
return { type: "redirect", response: err };
|
|
122
|
+
}
|
|
123
|
+
const headers: Record<string, string> = {};
|
|
124
|
+
Object.assign(headers, ctx.set.headers);
|
|
125
|
+
return { type: "error", error: err, headers };
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import type { HeadOptions, MetaDescriptor } from "../client.ts";
|
|
2
|
+
|
|
3
|
+
export function extractTitle(meta?: MetaDescriptor[]): string | undefined {
|
|
4
|
+
if (!meta) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
for (const entry of meta) {
|
|
8
|
+
if ("title" in entry) {
|
|
9
|
+
return (entry as { title: string }).title;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function isMetaTag(entry: MetaDescriptor): boolean {
|
|
16
|
+
return !(
|
|
17
|
+
"title" in entry ||
|
|
18
|
+
"charSet" in entry ||
|
|
19
|
+
"script:ld+json" in entry ||
|
|
20
|
+
"tagName" in entry
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function escapeHtml(str: string): string {
|
|
25
|
+
return str
|
|
26
|
+
.replace(/&/g, "&")
|
|
27
|
+
.replace(/</g, "<")
|
|
28
|
+
.replace(/>/g, ">")
|
|
29
|
+
.replace(/"/g, """)
|
|
30
|
+
.replace(/'/g, "'");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function safeJson(value: unknown): string {
|
|
34
|
+
return JSON.stringify(value)
|
|
35
|
+
.replace(/</g, "\\u003c")
|
|
36
|
+
.replace(/>/g, "\\u003e")
|
|
37
|
+
.replace(/\u2028/g, "\\u2028")
|
|
38
|
+
.replace(/\u2029/g, "\\u2029");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function renderAttrs(obj: Record<string, string | undefined>): string {
|
|
42
|
+
return Object.entries(obj)
|
|
43
|
+
.filter(([, v]) => v !== undefined)
|
|
44
|
+
.map(([k, v]) => `${k}="${escapeHtml(String(v))}"`)
|
|
45
|
+
.join(" ");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
// Head injection helpers
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
export function buildMetaParts(meta: MetaDescriptor[]): string[] {
|
|
53
|
+
const parts: string[] = [];
|
|
54
|
+
const title = extractTitle(meta);
|
|
55
|
+
if (title) {
|
|
56
|
+
parts.push(`<title>${escapeHtml(title)}</title>`);
|
|
57
|
+
}
|
|
58
|
+
for (const m of meta) {
|
|
59
|
+
if (isMetaTag(m)) {
|
|
60
|
+
parts.push(`<meta ${renderAttrs(m as Record<string, string>)} />`);
|
|
61
|
+
}
|
|
62
|
+
if ("script:ld+json" in m) {
|
|
63
|
+
parts.push(`<script type="application/ld+json">${safeJson(m["script:ld+json"])}</script>`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return parts;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function buildLinkParts(links: NonNullable<HeadOptions["links"]>): string[] {
|
|
70
|
+
return links.map((link) => `<link ${renderAttrs(link)} />`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function buildScriptParts(scripts: NonNullable<HeadOptions["scripts"]>): string[] {
|
|
74
|
+
return scripts.map((script) => {
|
|
75
|
+
const { children, ...rest } = script;
|
|
76
|
+
const attrs = renderAttrs(rest as Record<string, string | undefined>);
|
|
77
|
+
if (children) {
|
|
78
|
+
return `<script ${attrs}>${children}</script>`;
|
|
79
|
+
}
|
|
80
|
+
return `<script ${attrs}></script>`;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function buildStyleParts(styles: NonNullable<HeadOptions["styles"]>): string[] {
|
|
85
|
+
return styles.map((style) => {
|
|
86
|
+
const typeAttr = style.type ? ` type="${escapeHtml(style.type)}"` : "";
|
|
87
|
+
return `<style${typeAttr}>${style.children}</style>`;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Builds the string to inject into the <!--ssr-head--> placeholder.
|
|
93
|
+
* Handles title, meta tags, links, inline scripts, and inline styles from
|
|
94
|
+
* the page's `head()` function. CSS is handled by Bun (imported in user files).
|
|
95
|
+
*/
|
|
96
|
+
export function buildHeadInjection(headData: HeadOptions | undefined): string {
|
|
97
|
+
const parts: string[] = [];
|
|
98
|
+
|
|
99
|
+
if (headData?.meta) {
|
|
100
|
+
parts.push(...buildMetaParts(headData.meta));
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (headData?.links) {
|
|
104
|
+
parts.push(...buildLinkParts(headData.links));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (headData?.scripts) {
|
|
108
|
+
parts.push(...buildScriptParts(headData.scripts));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (headData?.styles) {
|
|
112
|
+
parts.push(...buildStyleParts(headData.styles));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return parts.length > 0 ? `\n ${parts.join("\n ")}\n` : "";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Inline script that synchronously applies the persisted theme class to <html>
|
|
120
|
+
* before the first paint, preventing a flash of unstyled content (FOUC).
|
|
121
|
+
* Reads the `furin-theme` key from localStorage; defaults to "dark" on error.
|
|
122
|
+
*/
|
|
123
|
+
const THEME_INIT_SCRIPT =
|
|
124
|
+
`<script>try{var __t=localStorage.getItem("furin-theme");` +
|
|
125
|
+
`document.documentElement.classList.add(__t==="light"?"light":"dark")}` +
|
|
126
|
+
`catch(e){document.documentElement.classList.add("dark")}</script>`;
|
|
127
|
+
|
|
128
|
+
export function generateIndexHtml(): string {
|
|
129
|
+
return `<!DOCTYPE html>
|
|
130
|
+
<html lang="en">
|
|
131
|
+
<head>
|
|
132
|
+
<meta charset="UTF-8">
|
|
133
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
134
|
+
${THEME_INIT_SCRIPT}
|
|
135
|
+
<!--ssr-head-->
|
|
136
|
+
</head>
|
|
137
|
+
<body>
|
|
138
|
+
<div id="root"><!--ssr-outlet--></div>
|
|
139
|
+
<script type="module" src="./_hydrate.tsx"></script>
|
|
140
|
+
</body>
|
|
141
|
+
</html>
|
|
142
|
+
`;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Generates the production SSR template (index.html) with hashed asset paths.
|
|
147
|
+
* Called after Bun.build() completes so we can inject the correct entry chunk
|
|
148
|
+
* and CSS paths derived from result.outputs.
|
|
149
|
+
*
|
|
150
|
+
* @param buildId - Short hash identifying this specific build. Injected as a
|
|
151
|
+
* `<meta name="furin-build-id">` tag so the client can detect stale deploys.
|
|
152
|
+
* @param faviconHref - Absolute href for the favicon (e.g. "/furin/favicon.ico").
|
|
153
|
+
* When provided, a `<link rel="icon">` tag is injected so browsers can locate
|
|
154
|
+
* the favicon even when the site is served from a sub-path.
|
|
155
|
+
*/
|
|
156
|
+
export function generateProdIndexHtml(
|
|
157
|
+
entryChunk: string,
|
|
158
|
+
cssChunks: string[],
|
|
159
|
+
buildId?: string,
|
|
160
|
+
faviconHref?: string
|
|
161
|
+
): string {
|
|
162
|
+
const cssLinks = cssChunks
|
|
163
|
+
.map((c) => ` <link rel="stylesheet" crossorigin href="${c}">`)
|
|
164
|
+
.join("\n");
|
|
165
|
+
const scriptTag = `<script type="module" crossorigin src="${entryChunk}"></script>`;
|
|
166
|
+
const buildIdMeta = buildId
|
|
167
|
+
? ` <meta name="furin-build-id" content="${escapeHtml(buildId)}">\n`
|
|
168
|
+
: "";
|
|
169
|
+
const faviconLink = faviconHref
|
|
170
|
+
? ` <link rel="icon" href="${escapeHtml(faviconHref)}">\n`
|
|
171
|
+
: "";
|
|
172
|
+
|
|
173
|
+
return `<!DOCTYPE html>
|
|
174
|
+
<html lang="en">
|
|
175
|
+
<head>
|
|
176
|
+
<meta charset="UTF-8">
|
|
177
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
178
|
+
${THEME_INIT_SCRIPT}
|
|
179
|
+
${buildIdMeta}${faviconLink}${cssLinks ? `${cssLinks}\n` : ""} <!--ssr-head-->
|
|
180
|
+
</head>
|
|
181
|
+
<body>
|
|
182
|
+
<div id="root"><!--ssr-outlet--></div>
|
|
183
|
+
${scriptTag}
|
|
184
|
+
</body>
|
|
185
|
+
</html>
|
|
186
|
+
`;
|
|
187
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// ── Dev template ─────────────────────────────────────────────────────────────
|
|
2
|
+
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
|
+
|
|
5
|
+
let _prodTemplatePath: string | null = null;
|
|
6
|
+
let _prodTemplateContent: string | null = null;
|
|
7
|
+
|
|
8
|
+
/** Dev template cache — avoids a loopback HTTP fetch on every SSR request. */
|
|
9
|
+
let _devTemplateCache: { html: string; ts: number } | null = null;
|
|
10
|
+
const DEV_TEMPLATE_TTL_MS = 1000;
|
|
11
|
+
|
|
12
|
+
export async function getDevTemplate(origin: string): Promise<string> {
|
|
13
|
+
if (_devTemplateCache && Date.now() - _devTemplateCache.ts < DEV_TEMPLATE_TTL_MS) {
|
|
14
|
+
return _devTemplateCache.html;
|
|
15
|
+
}
|
|
16
|
+
const r = await fetch(`${origin}/_bun_hmr_entry`);
|
|
17
|
+
if (!r.ok) {
|
|
18
|
+
throw new Error(`/_bun_hmr_entry returned ${r.status}`);
|
|
19
|
+
}
|
|
20
|
+
const html = await r.text();
|
|
21
|
+
_devTemplateCache = { html, ts: Date.now() };
|
|
22
|
+
return html;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function setProductionTemplatePath(path: string | null): void {
|
|
26
|
+
_prodTemplatePath = path;
|
|
27
|
+
_prodTemplateContent = null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function setProductionTemplateContent(content: string): void {
|
|
31
|
+
_prodTemplatePath = null;
|
|
32
|
+
_prodTemplateContent = content;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function getProductionTemplate(): string | null {
|
|
36
|
+
if (_prodTemplateContent !== null) {
|
|
37
|
+
return _prodTemplateContent;
|
|
38
|
+
}
|
|
39
|
+
if (!_prodTemplatePath) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
_prodTemplateContent = readFileSync(_prodTemplatePath, "utf8");
|
|
44
|
+
return _prodTemplateContent;
|
|
45
|
+
} catch {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** @internal test-only — resets all template state */
|
|
51
|
+
export function __resetTemplateState(): void {
|
|
52
|
+
_prodTemplatePath = null;
|
|
53
|
+
_prodTemplateContent = null;
|
|
54
|
+
_devTemplateCache = null;
|
|
55
|
+
}
|