@moku-labs/web 1.7.0 → 1.8.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/dist/browser.d.mts +13 -0
- package/dist/browser.mjs +44 -6
- package/dist/index.cjs +359 -87
- package/dist/index.d.cts +43 -4
- package/dist/index.d.mts +43 -4
- package/dist/index.mjs +359 -87
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1157,6 +1157,19 @@ type Api$4 = {
|
|
|
1157
1157
|
url: string;
|
|
1158
1158
|
locale?: string;
|
|
1159
1159
|
}): string;
|
|
1160
|
+
/**
|
|
1161
|
+
* Resolve the FINAL document title for a route's head config — the same value `render`
|
|
1162
|
+
* emits in its `<title>` element (`titleTemplate` applied; a route-pinned `title`-keyed
|
|
1163
|
+
* element wins). Used by `spa` to sync `document.title` on client DATA-path navigation.
|
|
1164
|
+
*
|
|
1165
|
+
* @param head - The route's head config (may be `undefined` for head-less routes).
|
|
1166
|
+
* @returns The final document title string.
|
|
1167
|
+
* @example
|
|
1168
|
+
* ```ts
|
|
1169
|
+
* api.composeTitle({ title: "Page 2" }); // "Page 2 — Site"
|
|
1170
|
+
* ```
|
|
1171
|
+
*/
|
|
1172
|
+
composeTitle(head: HeadConfig | undefined): string;
|
|
1160
1173
|
};
|
|
1161
1174
|
declare namespace types_d_exports$9 {
|
|
1162
1175
|
export { COMPONENT_HOOK_NAMES, ComponentContext, ComponentDef, ComponentHooks, ComponentInstance, ExtractApi$1 as ExtractApi, PageData, ResolvedSpaConfig, SpaApi, SpaConfig, SpaContext, SpaDataReader, SpaEmitFunction, SpaEvents, SpaKernel, SpaKernelDeps, SpaRequire, SpaState };
|
|
@@ -1667,8 +1680,13 @@ type Config$3 = {
|
|
|
1667
1680
|
* - `true` — the built-in default page.
|
|
1668
1681
|
* - `{ body }` — literal HTML body content, wrapped in a minimal document shell.
|
|
1669
1682
|
* - `{ path }` — path to a complete HTML page file (resolved from the project
|
|
1670
|
-
* root)
|
|
1671
|
-
*
|
|
1683
|
+
* root) so the app owns the whole document (its own `<head>`, asset links,
|
|
1684
|
+
* and body).
|
|
1685
|
+
*
|
|
1686
|
+
* In every variant the `<!--moku:assets-->` / `<!--moku:assets:css-->` /
|
|
1687
|
+
* `<!--moku:assets:js-->` placeholders are substituted with the fingerprinted
|
|
1688
|
+
* bundle tags (bundle filenames embed a content hash, so a 404 page cannot
|
|
1689
|
+
* hardcode them); a page without placeholders is written byte-for-byte.
|
|
1672
1690
|
*
|
|
1673
1691
|
* `path` takes precedence over `body` when both are set. Default `false`.
|
|
1674
1692
|
*/
|
|
@@ -1685,10 +1703,31 @@ type Config$3 = {
|
|
|
1685
1703
|
* `<!--moku:lang-->` (page locale for `<html lang>`),
|
|
1686
1704
|
* `<!--moku:head-->` (composed `<head>` inner HTML),
|
|
1687
1705
|
* `<!--moku:assets-->` (injected `<link>`/`<script>` tags),
|
|
1706
|
+
* `<!--moku:assets:css-->` / `<!--moku:assets:js-->` (one asset kind each, for
|
|
1707
|
+
* shells that link stylesheets in `<head>` but script tags elsewhere),
|
|
1688
1708
|
* `<!--moku:body-->` (SSR body HTML).
|
|
1689
1709
|
* When unset, the built-in shell is used (it emits charset + viewport by default).
|
|
1690
1710
|
*/
|
|
1691
1711
|
template?: string;
|
|
1712
|
+
/**
|
|
1713
|
+
* Emit `outDir/_headers` (Cloudflare Pages header rules) for CDN/browser cache
|
|
1714
|
+
* protection. Generated rules: every fingerprinted bundle output gets a
|
|
1715
|
+
* per-file `Cache-Control: <assets>` rule (default immutable, 1 year — its URL
|
|
1716
|
+
* embeds a content hash, so the bytes behind it can never change), and every
|
|
1717
|
+
* other URL — pages, content images, feeds, data sidecars: stable URLs whose
|
|
1718
|
+
* bytes MAY change between deploys — gets the catch-all
|
|
1719
|
+
* `Cache-Control: <pages>` rule (default always-revalidate: unchanged files
|
|
1720
|
+
* still answer `304 Not Modified` from their ETag, changed files are picked up
|
|
1721
|
+
* immediately). The app's own `<publicDir>/_headers` content is appended AFTER
|
|
1722
|
+
* the generated rules so the app can override them (detach a generated header
|
|
1723
|
+
* first with `! Cache-Control` — Cloudflare comma-joins duplicate headers).
|
|
1724
|
+
* `false` disables the phase; an object overrides one or both values.
|
|
1725
|
+
* Default `true`.
|
|
1726
|
+
*/
|
|
1727
|
+
cacheHeaders?: boolean | {
|
|
1728
|
+
assets?: string;
|
|
1729
|
+
pages?: string;
|
|
1730
|
+
};
|
|
1692
1731
|
};
|
|
1693
1732
|
/**
|
|
1694
1733
|
* A typed asset-manifest entry for one bundled asset kind (CSS or JS): a map of the
|
|
@@ -1755,7 +1794,7 @@ interface State$3 {
|
|
|
1755
1794
|
* const phase: PhaseName = "bundle";
|
|
1756
1795
|
* ```
|
|
1757
1796
|
*/
|
|
1758
|
-
type PhaseName = "bundle" | "content" | "images" | "pages" | "content-images" | "feeds" | "sitemap" | "og-images" | "public" | "not-found" | "locale-redirects" | "root-index";
|
|
1797
|
+
type PhaseName = "bundle" | "content" | "images" | "pages" | "content-images" | "feeds" | "sitemap" | "og-images" | "public" | "not-found" | "locale-redirects" | "cache-headers" | "root-index";
|
|
1759
1798
|
/**
|
|
1760
1799
|
* Result of a completed build run.
|
|
1761
1800
|
*
|
|
@@ -1784,7 +1823,7 @@ interface BuildResult {
|
|
|
1784
1823
|
* const dev: BuildRunOverrides = { minify: false, feeds: false, sitemap: false };
|
|
1785
1824
|
* ```
|
|
1786
1825
|
*/
|
|
1787
|
-
type BuildRunOverrides = Readonly<Partial<Pick<Config$3, "minify" | "feeds" | "sitemap" | "ogImage" | "images" | "localeRedirects" | "notFound">>>;
|
|
1826
|
+
type BuildRunOverrides = Readonly<Partial<Pick<Config$3, "minify" | "feeds" | "sitemap" | "ogImage" | "images" | "localeRedirects" | "notFound" | "cacheHeaders">>>;
|
|
1788
1827
|
/**
|
|
1789
1828
|
* Options for a single {@link Api.run} call. All fields are optional; an absent/empty
|
|
1790
1829
|
* options object runs the full production build (clean + every configured phase). The
|
package/dist/index.d.mts
CHANGED
|
@@ -1157,6 +1157,19 @@ type Api$4 = {
|
|
|
1157
1157
|
url: string;
|
|
1158
1158
|
locale?: string;
|
|
1159
1159
|
}): string;
|
|
1160
|
+
/**
|
|
1161
|
+
* Resolve the FINAL document title for a route's head config — the same value `render`
|
|
1162
|
+
* emits in its `<title>` element (`titleTemplate` applied; a route-pinned `title`-keyed
|
|
1163
|
+
* element wins). Used by `spa` to sync `document.title` on client DATA-path navigation.
|
|
1164
|
+
*
|
|
1165
|
+
* @param head - The route's head config (may be `undefined` for head-less routes).
|
|
1166
|
+
* @returns The final document title string.
|
|
1167
|
+
* @example
|
|
1168
|
+
* ```ts
|
|
1169
|
+
* api.composeTitle({ title: "Page 2" }); // "Page 2 — Site"
|
|
1170
|
+
* ```
|
|
1171
|
+
*/
|
|
1172
|
+
composeTitle(head: HeadConfig | undefined): string;
|
|
1160
1173
|
};
|
|
1161
1174
|
declare namespace types_d_exports$9 {
|
|
1162
1175
|
export { COMPONENT_HOOK_NAMES, ComponentContext, ComponentDef, ComponentHooks, ComponentInstance, ExtractApi$1 as ExtractApi, PageData, ResolvedSpaConfig, SpaApi, SpaConfig, SpaContext, SpaDataReader, SpaEmitFunction, SpaEvents, SpaKernel, SpaKernelDeps, SpaRequire, SpaState };
|
|
@@ -1667,8 +1680,13 @@ type Config$3 = {
|
|
|
1667
1680
|
* - `true` — the built-in default page.
|
|
1668
1681
|
* - `{ body }` — literal HTML body content, wrapped in a minimal document shell.
|
|
1669
1682
|
* - `{ path }` — path to a complete HTML page file (resolved from the project
|
|
1670
|
-
* root)
|
|
1671
|
-
*
|
|
1683
|
+
* root) so the app owns the whole document (its own `<head>`, asset links,
|
|
1684
|
+
* and body).
|
|
1685
|
+
*
|
|
1686
|
+
* In every variant the `<!--moku:assets-->` / `<!--moku:assets:css-->` /
|
|
1687
|
+
* `<!--moku:assets:js-->` placeholders are substituted with the fingerprinted
|
|
1688
|
+
* bundle tags (bundle filenames embed a content hash, so a 404 page cannot
|
|
1689
|
+
* hardcode them); a page without placeholders is written byte-for-byte.
|
|
1672
1690
|
*
|
|
1673
1691
|
* `path` takes precedence over `body` when both are set. Default `false`.
|
|
1674
1692
|
*/
|
|
@@ -1685,10 +1703,31 @@ type Config$3 = {
|
|
|
1685
1703
|
* `<!--moku:lang-->` (page locale for `<html lang>`),
|
|
1686
1704
|
* `<!--moku:head-->` (composed `<head>` inner HTML),
|
|
1687
1705
|
* `<!--moku:assets-->` (injected `<link>`/`<script>` tags),
|
|
1706
|
+
* `<!--moku:assets:css-->` / `<!--moku:assets:js-->` (one asset kind each, for
|
|
1707
|
+
* shells that link stylesheets in `<head>` but script tags elsewhere),
|
|
1688
1708
|
* `<!--moku:body-->` (SSR body HTML).
|
|
1689
1709
|
* When unset, the built-in shell is used (it emits charset + viewport by default).
|
|
1690
1710
|
*/
|
|
1691
1711
|
template?: string;
|
|
1712
|
+
/**
|
|
1713
|
+
* Emit `outDir/_headers` (Cloudflare Pages header rules) for CDN/browser cache
|
|
1714
|
+
* protection. Generated rules: every fingerprinted bundle output gets a
|
|
1715
|
+
* per-file `Cache-Control: <assets>` rule (default immutable, 1 year — its URL
|
|
1716
|
+
* embeds a content hash, so the bytes behind it can never change), and every
|
|
1717
|
+
* other URL — pages, content images, feeds, data sidecars: stable URLs whose
|
|
1718
|
+
* bytes MAY change between deploys — gets the catch-all
|
|
1719
|
+
* `Cache-Control: <pages>` rule (default always-revalidate: unchanged files
|
|
1720
|
+
* still answer `304 Not Modified` from their ETag, changed files are picked up
|
|
1721
|
+
* immediately). The app's own `<publicDir>/_headers` content is appended AFTER
|
|
1722
|
+
* the generated rules so the app can override them (detach a generated header
|
|
1723
|
+
* first with `! Cache-Control` — Cloudflare comma-joins duplicate headers).
|
|
1724
|
+
* `false` disables the phase; an object overrides one or both values.
|
|
1725
|
+
* Default `true`.
|
|
1726
|
+
*/
|
|
1727
|
+
cacheHeaders?: boolean | {
|
|
1728
|
+
assets?: string;
|
|
1729
|
+
pages?: string;
|
|
1730
|
+
};
|
|
1692
1731
|
};
|
|
1693
1732
|
/**
|
|
1694
1733
|
* A typed asset-manifest entry for one bundled asset kind (CSS or JS): a map of the
|
|
@@ -1755,7 +1794,7 @@ interface State$3 {
|
|
|
1755
1794
|
* const phase: PhaseName = "bundle";
|
|
1756
1795
|
* ```
|
|
1757
1796
|
*/
|
|
1758
|
-
type PhaseName = "bundle" | "content" | "images" | "pages" | "content-images" | "feeds" | "sitemap" | "og-images" | "public" | "not-found" | "locale-redirects" | "root-index";
|
|
1797
|
+
type PhaseName = "bundle" | "content" | "images" | "pages" | "content-images" | "feeds" | "sitemap" | "og-images" | "public" | "not-found" | "locale-redirects" | "cache-headers" | "root-index";
|
|
1759
1798
|
/**
|
|
1760
1799
|
* Result of a completed build run.
|
|
1761
1800
|
*
|
|
@@ -1784,7 +1823,7 @@ interface BuildResult {
|
|
|
1784
1823
|
* const dev: BuildRunOverrides = { minify: false, feeds: false, sitemap: false };
|
|
1785
1824
|
* ```
|
|
1786
1825
|
*/
|
|
1787
|
-
type BuildRunOverrides = Readonly<Partial<Pick<Config$3, "minify" | "feeds" | "sitemap" | "ogImage" | "images" | "localeRedirects" | "notFound">>>;
|
|
1826
|
+
type BuildRunOverrides = Readonly<Partial<Pick<Config$3, "minify" | "feeds" | "sitemap" | "ogImage" | "images" | "localeRedirects" | "notFound" | "cacheHeaders">>>;
|
|
1788
1827
|
/**
|
|
1789
1828
|
* Options for a single {@link Api.run} call. All fields are optional; an absent/empty
|
|
1790
1829
|
* options object runs the full production build (clean + every configured phase). The
|