@refrakt-md/html 0.28.0 → 0.29.0
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/page-shell.d.ts +6 -0
- package/dist/page-shell.d.ts.map +1 -1
- package/dist/page-shell.js +20 -1
- package/dist/page-shell.js.map +1 -1
- package/package.json +5 -5
package/dist/page-shell.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { RenderPageInput } from './render.js';
|
|
2
2
|
import { type ResolvedTintCascade } from '@refrakt-md/content';
|
|
3
|
+
import { type LocaleContext } from '@refrakt-md/transform';
|
|
3
4
|
interface OgMeta {
|
|
4
5
|
title?: string;
|
|
5
6
|
description?: string;
|
|
@@ -22,6 +23,11 @@ export interface PageShellOptions {
|
|
|
22
23
|
bodyExtra?: string;
|
|
23
24
|
/** HTML lang attribute (default: "en") */
|
|
24
25
|
lang?: string;
|
|
26
|
+
/** SPEC-035 — render-scoped locale slice. Drives the inline `<meta
|
|
27
|
+
* name="rf-locale">` + `<script id="rf-strings">` behavior-string block
|
|
28
|
+
* (Zone 5) so client behaviors localize synchronously without a fetch.
|
|
29
|
+
* Omit for English (nothing emitted; output unchanged). */
|
|
30
|
+
locale?: LocaleContext;
|
|
25
31
|
/** Base URL for OpenGraph canonical URLs (e.g. "https://refrakt.md") */
|
|
26
32
|
baseUrl?: string;
|
|
27
33
|
/** Human-readable site name for og:site_name and JSON-LD entries */
|
package/dist/page-shell.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-shell.d.ts","sourceRoot":"","sources":["../src/page-shell.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAIN,KAAK,mBAAmB,EACxB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"page-shell.d.ts","sourceRoot":"","sources":["../src/page-shell.ts"],"names":[],"mappings":"AAA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
|
package/dist/page-shell.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { renderPage } from './render.js';
|
|
2
2
|
import { prePaintScript, htmlTintAttributes, colorSchemeMetaContent, } from '@refrakt-md/content';
|
|
3
|
+
import { collectBehaviorStrings, resolveDocumentLang } from '@refrakt-md/transform';
|
|
3
4
|
const PRE_PAINT_SCRIPT = prePaintScript();
|
|
4
5
|
const DEFAULT_CASCADE = { tint: null, tintMode: 'auto', locked: false };
|
|
5
6
|
function escapeHtml(s) {
|
|
@@ -26,7 +27,10 @@ function renderOgTag(property, content) {
|
|
|
26
27
|
*/
|
|
27
28
|
export function renderFullPage(input, options = {}) {
|
|
28
29
|
const { page } = input;
|
|
29
|
-
const {
|
|
30
|
+
const { locale, stylesheets = [], scripts = [], headExtra = '', bodyExtra = '', baseUrl, siteName, defaultImage, logo, seo, tintCascade = DEFAULT_CASCADE, } = options;
|
|
31
|
+
// SPEC-035 Zone 8 — the document lang follows the configured locale
|
|
32
|
+
// (explicit `lang` option still wins for callers that set it directly).
|
|
33
|
+
const lang = options.lang ?? resolveDocumentLang(locale?.locale);
|
|
30
34
|
const headParts = [];
|
|
31
35
|
headParts.push('<meta charset="utf-8">');
|
|
32
36
|
headParts.push('<meta name="viewport" content="width=device-width, initial-scale=1">');
|
|
@@ -107,6 +111,21 @@ export function renderFullPage(input, options = {}) {
|
|
|
107
111
|
if (headExtra) {
|
|
108
112
|
headParts.push(headExtra);
|
|
109
113
|
}
|
|
114
|
+
// SPEC-035 Zone 5 — inline behavior-string delivery (Decision D4). Emit the
|
|
115
|
+
// active-locale marker + a JSON block of the `behavior.*` strings so client
|
|
116
|
+
// behaviors localize synchronously with no fetch. Nothing is emitted for the
|
|
117
|
+
// English default (empty block → client behaviors use their English floor).
|
|
118
|
+
if (locale && locale.locale && locale.locale !== 'en') {
|
|
119
|
+
headParts.push(renderMetaTag('rf-locale', locale.locale));
|
|
120
|
+
}
|
|
121
|
+
if (locale) {
|
|
122
|
+
const behaviorStrings = collectBehaviorStrings(locale);
|
|
123
|
+
if (Object.keys(behaviorStrings).length > 0) {
|
|
124
|
+
// `</script>` in a value would break out of the block; escape the slash.
|
|
125
|
+
const json = JSON.stringify(behaviorStrings).replace(/</g, '\\u003c');
|
|
126
|
+
headParts.push(`<script type="application/json" id="rf-strings">${json}</script>`);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
110
129
|
// Context data for client-side behaviors
|
|
111
130
|
const contextData = JSON.stringify({
|
|
112
131
|
pages: page.pages,
|
package/dist/page-shell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page-shell.js","sourceRoot":"","sources":["../src/page-shell.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,cAAc,EACd,kBAAkB,EAClB,sBAAsB,GAEtB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"page-shell.js","sourceRoot":"","sources":["../src/page-shell.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,cAAc,EACd,kBAAkB,EAClB,sBAAsB,GAEtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAsB,MAAM,uBAAuB,CAAC;AAExG,MAAM,gBAAgB,GAAG,cAAc,EAAE,CAAC;AAC1C,MAAM,eAAe,GAAwB,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AA+C7F,SAAS,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACrG,CAAC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,CAAC,GAAG,CAAC,EAAE,CAAC,gBAAgB,UAAU,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAE/F,2EAA2E;IAC3E,sCAAsC;IACtC,MAAM,SAAS,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,eAAe,UAAU,CAAC,IAAI,CAAC,KAAK,SAAS,GAAG,CAAC,CAAC,CAAC,eAAe,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC;IAEnH,OAAO;EACN,OAAO;;EAEP,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;;;EAGpB,WAAW;kDACqC,WAAW;EAC3D,UAAU;EACV,SAAS;;QAEH,CAAC;AACT,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@refrakt-md/html",
|
|
3
3
|
"description": "Pure HTML renderer for refrakt.md content — no framework required",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.29.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"build": "tsc"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@refrakt-md/behaviors": "0.
|
|
35
|
-
"@refrakt-md/content": "0.
|
|
36
|
-
"@refrakt-md/transform": "0.
|
|
37
|
-
"@refrakt-md/types": "0.
|
|
34
|
+
"@refrakt-md/behaviors": "0.29.0",
|
|
35
|
+
"@refrakt-md/content": "0.29.0",
|
|
36
|
+
"@refrakt-md/transform": "0.29.0",
|
|
37
|
+
"@refrakt-md/types": "0.29.0"
|
|
38
38
|
}
|
|
39
39
|
}
|