@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.
Files changed (110) hide show
  1. package/dist/ai-tools.d.ts +15 -10
  2. package/dist/ai-tools.d.ts.map +1 -1
  3. package/dist/ai-tools.js +13 -15
  4. package/dist/ai-tools.js.map +1 -1
  5. package/dist/build-page.d.ts +0 -2
  6. package/dist/build-page.d.ts.map +1 -1
  7. package/dist/build-page.js +2 -3
  8. package/dist/build-page.js.map +1 -1
  9. package/dist/content.d.ts +0 -3
  10. package/dist/content.d.ts.map +1 -1
  11. package/dist/content.js +91 -7
  12. package/dist/content.js.map +1 -1
  13. package/dist/context.d.ts +6 -0
  14. package/dist/context.d.ts.map +1 -1
  15. package/dist/font-assets.d.ts +89 -0
  16. package/dist/font-assets.d.ts.map +1 -0
  17. package/dist/font-assets.js +61 -0
  18. package/dist/font-assets.js.map +1 -0
  19. package/dist/google-models.d.ts +35 -0
  20. package/dist/google-models.d.ts.map +1 -0
  21. package/dist/google-models.js +20 -0
  22. package/dist/google-models.js.map +1 -0
  23. package/dist/index.d.ts +4 -2
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +4 -2
  26. package/dist/index.js.map +1 -1
  27. package/dist/media.d.ts +0 -3
  28. package/dist/media.d.ts.map +1 -1
  29. package/dist/media.js +0 -5
  30. package/dist/media.js.map +1 -1
  31. package/dist/plugin-preview.d.ts +44 -0
  32. package/dist/plugin-preview.d.ts.map +1 -0
  33. package/dist/plugin-preview.js +69 -0
  34. package/dist/plugin-preview.js.map +1 -0
  35. package/dist/preview-compose.d.ts +26 -0
  36. package/dist/preview-compose.d.ts.map +1 -1
  37. package/dist/preview-compose.js +92 -46
  38. package/dist/preview-compose.js.map +1 -1
  39. package/dist/responsive-images.d.ts +6 -5
  40. package/dist/responsive-images.d.ts.map +1 -1
  41. package/dist/responsive-images.js +6 -5
  42. package/dist/responsive-images.js.map +1 -1
  43. package/dist/seo.d.ts +10 -14
  44. package/dist/seo.d.ts.map +1 -1
  45. package/dist/seo.js +11 -12
  46. package/dist/seo.js.map +1 -1
  47. package/dist/template-engine.d.ts +18 -0
  48. package/dist/template-engine.d.ts.map +1 -1
  49. package/dist/template-engine.js +39 -2
  50. package/dist/template-engine.js.map +1 -1
  51. package/dist/theme-importers/loose.js +1 -1
  52. package/dist/theme-importers/loose.js.map +1 -1
  53. package/dist/theme-normalize.d.ts +9 -0
  54. package/dist/theme-normalize.d.ts.map +1 -1
  55. package/dist/theme-normalize.js +65 -6
  56. package/dist/theme-normalize.js.map +1 -1
  57. package/dist/theme-render.d.ts +15 -0
  58. package/dist/theme-render.d.ts.map +1 -1
  59. package/dist/theme-render.js +39 -0
  60. package/dist/theme-render.js.map +1 -1
  61. package/dist/themes.d.ts +15 -1
  62. package/dist/themes.d.ts.map +1 -1
  63. package/dist/themes.js +48 -1
  64. package/dist/themes.js.map +1 -1
  65. package/dist/url.d.ts +45 -0
  66. package/dist/url.d.ts.map +1 -0
  67. package/dist/url.js +64 -0
  68. package/dist/url.js.map +1 -0
  69. package/dist/version.d.ts +2 -2
  70. package/dist/version.js +1 -1
  71. package/package.json +1 -1
  72. package/src/__tests__/redos-hardening.test.ts +1 -1
  73. package/src/ai-tools.ts +13 -15
  74. package/src/build-page.ts +3 -5
  75. package/src/content.test.ts +99 -17
  76. package/src/content.ts +95 -8
  77. package/src/context.ts +6 -0
  78. package/src/font-assets.ts +63 -0
  79. package/src/google-models.ts +20 -0
  80. package/src/index.ts +4 -2
  81. package/src/media.ts +0 -6
  82. package/src/plugin-preview.test.ts +79 -0
  83. package/src/plugin-preview.ts +81 -0
  84. package/src/preview-compose-deferrals.test.ts +144 -0
  85. package/src/preview-compose.test.ts +16 -0
  86. package/src/preview-compose.ts +125 -37
  87. package/src/responsive-images.ts +6 -5
  88. package/src/seo.test.ts +8 -8
  89. package/src/seo.ts +15 -23
  90. package/src/template-engine-data-lists.test.ts +90 -0
  91. package/src/template-engine.ts +72 -1
  92. package/src/theme-importers/loose.ts +1 -1
  93. package/src/theme-normalize.ts +70 -8
  94. package/src/theme-render.ts +36 -0
  95. package/src/theme-token-roles.test.ts +182 -0
  96. package/src/themes.ts +53 -0
  97. package/src/url.test.ts +40 -0
  98. package/src/url.ts +69 -0
  99. package/src/version.ts +1 -1
  100. package/dist/design-manifest.d.ts +0 -36
  101. package/dist/design-manifest.d.ts.map +0 -1
  102. package/dist/design-manifest.js +0 -90
  103. package/dist/design-manifest.js.map +0 -1
  104. package/dist/i18n.d.ts +0 -42
  105. package/dist/i18n.d.ts.map +0 -1
  106. package/dist/i18n.js +0 -85
  107. package/dist/i18n.js.map +0 -1
  108. package/src/design-manifest.ts +0 -93
  109. package/src/i18n.test.ts +0 -58
  110. 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
- }