@caelo-cms/shared 0.10.28 → 0.10.30
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/ai-tools.d.ts +1 -0
- package/dist/ai-tools.d.ts.map +1 -1
- package/dist/ai-tools.js +1 -0
- package/dist/ai-tools.js.map +1 -1
- package/dist/database-url.d.ts +38 -0
- package/dist/database-url.d.ts.map +1 -0
- package/dist/database-url.js +73 -0
- package/dist/database-url.js.map +1 -0
- package/dist/document-language.d.ts +56 -0
- package/dist/document-language.d.ts.map +1 -0
- package/dist/document-language.js +142 -0
- package/dist/document-language.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/media.d.ts +3 -1
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +8 -0
- package/dist/media.js.map +1 -1
- package/dist/preview-compose.d.ts +6 -0
- package/dist/preview-compose.d.ts.map +1 -1
- package/dist/preview-compose.js +32 -1
- package/dist/preview-compose.js.map +1 -1
- package/dist/seo.d.ts +77 -13
- package/dist/seo.d.ts.map +1 -1
- package/dist/seo.js +117 -21
- package/dist/seo.js.map +1 -1
- package/dist/static-cache-policy.d.ts +50 -0
- package/dist/static-cache-policy.d.ts.map +1 -0
- package/dist/static-cache-policy.js +54 -0
- package/dist/static-cache-policy.js.map +1 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/ai-tools.ts +1 -0
- package/src/database-url.test.ts +116 -0
- package/src/database-url.ts +83 -0
- package/src/design-draft-shell.test.ts +5 -1
- package/src/document-language.test.ts +118 -0
- package/src/document-language.ts +146 -0
- package/src/index.ts +3 -0
- package/src/media.test.ts +8 -0
- package/src/media.ts +8 -0
- package/src/preview-compose.test.ts +82 -0
- package/src/preview-compose.ts +40 -1
- package/src/seo.test.ts +145 -1
- package/src/seo.ts +151 -28
- package/src/static-cache-policy.test.ts +66 -0
- package/src/static-cache-policy.ts +60 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Cache-Control policy for the published static site — the single
|
|
5
|
+
* source of truth every static publisher (GCS object metadata,
|
|
6
|
+
* Firebase Hosting version headers, self-hosted Caddy) derives from.
|
|
7
|
+
*
|
|
8
|
+
* The rule: only a URL whose bytes can never change may be cached
|
|
9
|
+
* forever. That holds exactly when the URL itself changes whenever the
|
|
10
|
+
* content does, i.e. the file name carries a content hash. Everything
|
|
11
|
+
* else (pages, robots.txt, sitemap.xml, manifests, media served by its
|
|
12
|
+
* stable slug under `_assets/<slug>…`) must stay short-lived or
|
|
13
|
+
* revalidating so a publish shows up promptly.
|
|
14
|
+
*
|
|
15
|
+
* Content-hashed paths the static generator emits today:
|
|
16
|
+
*
|
|
17
|
+
* - `_assets/fonts/<family-slug>/<16 hex>.woff2` — self-hosted
|
|
18
|
+
* Google Fonts faces; the name is a hash of the upstream face URL,
|
|
19
|
+
* which Google versions per file (a changed face gets a new URL,
|
|
20
|
+
* hence a new name).
|
|
21
|
+
* - `_assets/fonts/pinned/<sha256>.<ttf|otf|woff|woff2>` — library
|
|
22
|
+
* fonts pinned by the sha256 of their bytes. (The sibling
|
|
23
|
+
* `pinned/<font-id>.license.txt` is id-named, NOT hashed.)
|
|
24
|
+
* - `_caelo/plugin/<slug>/<stem>.<12 hex>.<js|css>` — plugin client
|
|
25
|
+
* assets, sha256 of the content in the name
|
|
26
|
+
* (`plugin-host/src/client-assets.ts`).
|
|
27
|
+
* - `_app/immutable/**` — Vite's hashed-output convention, kept for
|
|
28
|
+
* builds that ship SvelteKit-style bundles.
|
|
29
|
+
*
|
|
30
|
+
* NOT content-hashed (deliberately excluded): media under
|
|
31
|
+
* `_assets/<slug>.<ext>` / `_assets/<slug>/<variant>.<ext>` — the slug is
|
|
32
|
+
* stable while the operator can replace the bytes behind it.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/** Long-lived policy for content-addressed files. */
|
|
36
|
+
export const IMMUTABLE_CACHE_CONTROL = "public, max-age=31536000, immutable";
|
|
37
|
+
|
|
38
|
+
/** Short, background-revalidated policy for pages (HTML documents). */
|
|
39
|
+
export const HTML_CACHE_CONTROL = "public, max-age=60, stale-while-revalidate=86400";
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Regex (source string) matching every content-hashed URL path. It is
|
|
43
|
+
* matched against a site-absolute path ("/_assets/…") and uses only the
|
|
44
|
+
* syntax shared by ECMAScript and RE2 (no lookaround, no backrefs), so
|
|
45
|
+
* the same string can be handed to Firebase Hosting's `regex` header
|
|
46
|
+
* matcher and Caddy's `path_regexp` (both RE2) and to `RegExp` here.
|
|
47
|
+
*/
|
|
48
|
+
export const CONTENT_HASHED_PATH_PATTERN =
|
|
49
|
+
"^/(?:_app/immutable/.+|_assets/fonts/[^/]+/[0-9a-f]{16,64}\\.(?:woff2|woff|ttf|otf)|_caelo/plugin/[^/]+/[^/]+\\.[0-9a-f]{12}\\.(?:js|css))$";
|
|
50
|
+
|
|
51
|
+
const CONTENT_HASHED_PATH_RE = new RegExp(CONTENT_HASHED_PATH_PATTERN);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* True when `path` names a content-addressed build output. Accepts a
|
|
55
|
+
* build-dir-relative key (`_assets/fonts/inter/ab….woff2`, as the GCS
|
|
56
|
+
* publisher sees it) or a site-absolute URL path (`/_assets/…`).
|
|
57
|
+
*/
|
|
58
|
+
export function isContentHashedPath(path: string): boolean {
|
|
59
|
+
return CONTENT_HASHED_PATH_RE.test(path.startsWith("/") ? path : `/${path}`);
|
|
60
|
+
}
|