@caelo-cms/shared 0.10.24 → 0.10.26
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 +15 -10
- package/dist/ai-tools.d.ts.map +1 -1
- package/dist/ai-tools.js +13 -15
- package/dist/ai-tools.js.map +1 -1
- package/dist/build-page.d.ts +0 -2
- package/dist/build-page.d.ts.map +1 -1
- package/dist/build-page.js +2 -3
- package/dist/build-page.js.map +1 -1
- package/dist/content.d.ts +0 -3
- package/dist/content.d.ts.map +1 -1
- package/dist/content.js +91 -7
- package/dist/content.js.map +1 -1
- package/dist/context.d.ts +6 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/font-assets.d.ts +89 -0
- package/dist/font-assets.d.ts.map +1 -0
- package/dist/font-assets.js +61 -0
- package/dist/font-assets.js.map +1 -0
- package/dist/google-models.d.ts +35 -0
- package/dist/google-models.d.ts.map +1 -0
- package/dist/google-models.js +20 -0
- package/dist/google-models.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/media.d.ts +0 -3
- package/dist/media.d.ts.map +1 -1
- package/dist/media.js +0 -5
- package/dist/media.js.map +1 -1
- package/dist/plugin-preview.d.ts +44 -0
- package/dist/plugin-preview.d.ts.map +1 -0
- package/dist/plugin-preview.js +69 -0
- package/dist/plugin-preview.js.map +1 -0
- package/dist/preview-compose.d.ts +26 -0
- package/dist/preview-compose.d.ts.map +1 -1
- package/dist/preview-compose.js +92 -46
- package/dist/preview-compose.js.map +1 -1
- package/dist/responsive-images.d.ts +6 -5
- package/dist/responsive-images.d.ts.map +1 -1
- package/dist/responsive-images.js +6 -5
- package/dist/responsive-images.js.map +1 -1
- package/dist/seo.d.ts +10 -14
- package/dist/seo.d.ts.map +1 -1
- package/dist/seo.js +11 -12
- package/dist/seo.js.map +1 -1
- package/dist/template-engine.d.ts +18 -0
- package/dist/template-engine.d.ts.map +1 -1
- package/dist/template-engine.js +39 -2
- package/dist/template-engine.js.map +1 -1
- package/dist/theme-importers/loose.js +1 -1
- package/dist/theme-importers/loose.js.map +1 -1
- package/dist/theme-normalize.d.ts +9 -0
- package/dist/theme-normalize.d.ts.map +1 -1
- package/dist/theme-normalize.js +65 -6
- package/dist/theme-normalize.js.map +1 -1
- package/dist/theme-render.d.ts +15 -0
- package/dist/theme-render.d.ts.map +1 -1
- package/dist/theme-render.js +39 -0
- package/dist/theme-render.js.map +1 -1
- package/dist/themes.d.ts +15 -1
- package/dist/themes.d.ts.map +1 -1
- package/dist/themes.js +48 -1
- package/dist/themes.js.map +1 -1
- package/dist/url.d.ts +45 -0
- package/dist/url.d.ts.map +1 -0
- package/dist/url.js +64 -0
- package/dist/url.js.map +1 -0
- package/dist/version.d.ts +2 -2
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/src/__tests__/redos-hardening.test.ts +1 -1
- package/src/ai-tools.ts +13 -15
- package/src/build-page.ts +3 -5
- package/src/content.test.ts +99 -17
- package/src/content.ts +95 -8
- package/src/context.ts +6 -0
- package/src/font-assets.ts +63 -0
- package/src/google-models.ts +20 -0
- package/src/index.ts +4 -2
- package/src/media.ts +0 -6
- package/src/plugin-preview.test.ts +79 -0
- package/src/plugin-preview.ts +81 -0
- package/src/preview-compose-deferrals.test.ts +144 -0
- package/src/preview-compose.test.ts +16 -0
- package/src/preview-compose.ts +125 -37
- package/src/responsive-images.ts +6 -5
- package/src/seo.test.ts +8 -8
- package/src/seo.ts +15 -23
- package/src/template-engine-data-lists.test.ts +90 -0
- package/src/template-engine.ts +72 -1
- package/src/theme-importers/loose.ts +1 -1
- package/src/theme-normalize.ts +70 -8
- package/src/theme-render.ts +36 -0
- package/src/theme-token-roles.test.ts +182 -0
- package/src/themes.ts +53 -0
- package/src/url.test.ts +40 -0
- package/src/url.ts +69 -0
- package/src/version.ts +1 -1
- package/dist/design-manifest.d.ts +0 -36
- package/dist/design-manifest.d.ts.map +0 -1
- package/dist/design-manifest.js +0 -90
- package/dist/design-manifest.js.map +0 -1
- package/dist/i18n.d.ts +0 -42
- package/dist/i18n.d.ts.map +0 -1
- package/dist/i18n.js +0 -85
- package/dist/i18n.js.map +0 -1
- package/src/design-manifest.ts +0 -93
- package/src/i18n.test.ts +0 -58
- package/src/i18n.ts +0 -91
package/src/i18n.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Slug/URL primitives shared between the static generator, the preview
|
|
5
|
-
* op, and the admin UI. Epic #380 Phase A (#383): locale URL shaping
|
|
6
|
-
* (resolveLocaleUrl, buildHreflangLinks) is deleted — URL shape beyond
|
|
7
|
-
* base + slug becomes a plugin contribution on the URL composition
|
|
8
|
-
* point (#390). What survives until the page-identity cut (#384):
|
|
9
|
-
*
|
|
10
|
-
* isHomeSlug / pageIsLocaleHome — the home-decision predicate.
|
|
11
|
-
* computeContentHash — drives `pages.content_hash` (removed in #384).
|
|
12
|
-
* trimSlashes / trimTrailingSlashes — linear-scan slug hygiene.
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const TEXT_ENCODER = new TextEncoder();
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Strip leading and trailing `/` characters with a single linear scan.
|
|
19
|
-
*
|
|
20
|
-
* Replaces the regex `/^\/+|\/+$/g`, whose trailing-slash branch
|
|
21
|
-
* backtracks O(n²) on a long run of slashes that is not at end-of-string
|
|
22
|
-
* (CodeQL js/polynomial-redos). This char-index walk is unconditionally
|
|
23
|
-
* linear and produces byte-identical output for every input.
|
|
24
|
-
*/
|
|
25
|
-
export function trimSlashes(s: string): string {
|
|
26
|
-
let start = 0;
|
|
27
|
-
let end = s.length;
|
|
28
|
-
while (start < end && s.charCodeAt(start) === 47 /* '/' */) start += 1;
|
|
29
|
-
while (end > start && s.charCodeAt(end - 1) === 47 /* '/' */) end -= 1;
|
|
30
|
-
return s.slice(start, end);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Strip only trailing `/` characters with a single linear scan — the
|
|
35
|
-
* non-backtracking replacement for `/\/+$/` (same ReDoS class as above).
|
|
36
|
-
* Used for base URLs, which carry a scheme and must keep their leading
|
|
37
|
-
* characters.
|
|
38
|
-
*/
|
|
39
|
-
export function trimTrailingSlashes(s: string): string {
|
|
40
|
-
let end = s.length;
|
|
41
|
-
while (end > 0 && s.charCodeAt(end - 1) === 47 /* '/' */) end -= 1;
|
|
42
|
-
return s.slice(0, end);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* The "magic slug" sentinel test: a page whose slug is empty, `home`,
|
|
47
|
-
* or `index` is the locale root by convention even without an explicit
|
|
48
|
-
* `locales.home_page_id` designation. Leading/trailing slashes are
|
|
49
|
-
* ignored so `/home/` reads the same as `home`.
|
|
50
|
-
*/
|
|
51
|
-
export function isHomeSlug(slug: string): boolean {
|
|
52
|
-
const s = trimSlashes(slug);
|
|
53
|
-
return s === "" || s === "home" || s === "index";
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* The single home-decision predicate every URL/output-path site must
|
|
58
|
-
* use so canonical, hreflang, redirects, and the emitted file agree
|
|
59
|
-
* (0184 explicit-homepage feature). A page is the locale root when it
|
|
60
|
-
* IS the locale's designated `home_page_id` OR carries a magic slug.
|
|
61
|
-
*
|
|
62
|
-
* @param pageId The page being resolved.
|
|
63
|
-
* @param slug That page's slug.
|
|
64
|
-
* @param localeHomePageId `locales.home_page_id` for the page's locale
|
|
65
|
-
* (null/undefined when no page is designated).
|
|
66
|
-
*/
|
|
67
|
-
export function pageIsLocaleHome(
|
|
68
|
-
pageId: string,
|
|
69
|
-
slug: string,
|
|
70
|
-
localeHomePageId: string | null | undefined,
|
|
71
|
-
): boolean {
|
|
72
|
-
return (localeHomePageId != null && pageId === localeHomePageId) || isHomeSlug(slug);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Canonical-JSON serializer + sha256 → hex. Stable across runs because
|
|
77
|
-
* keys are sorted. The output is used for `pages.content_hash` so that
|
|
78
|
-
* a Mode-2 translation can detect whether its source has changed.
|
|
79
|
-
*/
|
|
80
|
-
export async function computeContentHash(value: unknown): Promise<string> {
|
|
81
|
-
const canonical = JSON.stringify(value, (_key, val) => {
|
|
82
|
-
if (val && typeof val === "object" && !Array.isArray(val)) {
|
|
83
|
-
const sorted: Record<string, unknown> = {};
|
|
84
|
-
for (const k of Object.keys(val).sort()) sorted[k] = (val as Record<string, unknown>)[k];
|
|
85
|
-
return sorted;
|
|
86
|
-
}
|
|
87
|
-
return val;
|
|
88
|
-
});
|
|
89
|
-
const digest = await crypto.subtle.digest("SHA-256", TEXT_ENCODER.encode(canonical));
|
|
90
|
-
return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
91
|
-
}
|