@cube-drone/marquee-html-renderer 0.6.1 → 0.7.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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Profile } from "./profile.ts";
2
- export { render, escapeText, escapeAttr, FONTS, usedFontTokens } from "./render.ts";
2
+ export { render, escapeText, escapeAttr, FONTS, usedFontTokens, containerLook } from "./render.ts";
3
3
  export { bareWebProfile } from "./profile.ts";
4
4
  export type { EmojiResolution, Profile, MediaResolution, TurbolinkLevel } from "./profile.ts";
5
5
  /** Parse and render in one step. Throws UnsupportedVersionError for unknown
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@
6
6
  // tap-to-skip) belong to the interactive renderer.
7
7
  import { parse } from "@cube-drone/marquee-parser";
8
8
  import { render } from "./render.js";
9
- export { render, escapeText, escapeAttr, FONTS, usedFontTokens } from "./render.js";
9
+ export { render, escapeText, escapeAttr, FONTS, usedFontTokens, containerLook } from "./render.js";
10
10
  export { bareWebProfile } from "./profile.js";
11
11
  /** Parse and render in one step. Throws UnsupportedVersionError for unknown
12
12
  * dialect versions, exactly as the parser does. */
package/dist/render.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Node } from "@cube-drone/marquee-parser";
1
+ import type { Attrs, Node } from "@cube-drone/marquee-parser";
2
2
  import { type Profile } from "./profile.ts";
3
3
  export declare function render(node: Node, profile?: Profile): string;
4
4
  /** The font vocabulary (closed, two tiers): four standard stacks that need
@@ -12,5 +12,15 @@ export declare const FONTS: Record<string, string>;
12
12
  * @cube-drone/marquee-fonts (externalFontFaces / inlineFontFaces) to deliver
13
13
  * exactly those faces and not one byte more. */
14
14
  export declare function usedFontTokens(html: string): string[];
15
+ /** The visual identity a layout container (:::page / :::section) wears -
16
+ * its scheme/font classes and validated style knobs - as bare class/style
17
+ * values. For surfaces that paint a container's look onto elements THEY
18
+ * own instead of rendering the container: the live editor washes it across
19
+ * the container's source lines. Same gates as rendering, so the two can't
20
+ * disagree. */
21
+ export declare function containerLook(attrs: Attrs, profile?: Profile): {
22
+ classes: string;
23
+ style: string;
24
+ };
15
25
  export declare function escapeText(s: string): string;
16
26
  export declare function escapeAttr(s: string): string;
package/dist/render.js CHANGED
@@ -247,7 +247,7 @@ function cssUrl(url) {
247
247
  * color, or `tile:<target>` - a tiled background image, resolved through
248
248
  * the embedder's media policy exactly as an embed (a background fetch is a
249
249
  * fetch): out-of-policy or non-image targets degrade to no background. */
250
- function styleVars(attrs, profile) {
250
+ function styleVarList(attrs, profile) {
251
251
  const vars = [];
252
252
  if (isColorValue(attrs["color"])) {
253
253
  vars.push(`--mq-color:${attrs["color"]}`);
@@ -264,7 +264,23 @@ function styleVars(attrs, profile) {
264
264
  else if (isColorValue(bg)) {
265
265
  vars.push(`--mq-bg:${bg}`);
266
266
  }
267
- return vars.length === 0 ? "" : ` style="${vars.join(";")}"`;
267
+ return vars.join(";");
268
+ }
269
+ function styleVars(attrs, profile) {
270
+ const list = styleVarList(attrs, profile);
271
+ return list === "" ? "" : ` style="${list}"`;
272
+ }
273
+ /** The visual identity a layout container (:::page / :::section) wears -
274
+ * its scheme/font classes and validated style knobs - as bare class/style
275
+ * values. For surfaces that paint a container's look onto elements THEY
276
+ * own instead of rendering the container: the live editor washes it across
277
+ * the container's source lines. Same gates as rendering, so the two can't
278
+ * disagree. */
279
+ export function containerLook(attrs, profile = bareWebProfile) {
280
+ return {
281
+ classes: `${schemeClass(attrs)}${fontClass(attrs)}`.trim(),
282
+ style: styleVarList(attrs, profile),
283
+ };
268
284
  }
269
285
  function schemeClass(attrs) {
270
286
  return isToken(attrs["scheme"]) ? ` mq-scheme-${attrs["scheme"]}` : "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cube-drone/marquee-html-renderer",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "description": "Reference static HTML renderer for the Marquee markup language",
5
5
  "license": "MPL-2.0",
6
6
  "repository": {
@@ -35,12 +35,12 @@
35
35
  "prepack": "npm run build"
36
36
  },
37
37
  "dependencies": {
38
- "@cube-drone/marquee-parser": "^0.6.1"
38
+ "@cube-drone/marquee-parser": "^0.7.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@cube-drone/marquee-css": "^0.6.1",
42
- "@cube-drone/marquee-fonts": "^0.6.1",
43
- "@cube-drone/marquee-turbolink": "^0.6.1",
41
+ "@cube-drone/marquee-css": "^0.7.0",
42
+ "@cube-drone/marquee-fonts": "^0.7.0",
43
+ "@cube-drone/marquee-turbolink": "^0.7.0",
44
44
  "@types/node": "^24.0.0",
45
45
  "typescript": "^5.9.0"
46
46
  }
package/src/index.ts CHANGED
@@ -9,7 +9,7 @@ import { parse } from "@cube-drone/marquee-parser";
9
9
  import { render } from "./render.ts";
10
10
  import type { Profile } from "./profile.ts";
11
11
 
12
- export { render, escapeText, escapeAttr, FONTS, usedFontTokens } from "./render.ts";
12
+ export { render, escapeText, escapeAttr, FONTS, usedFontTokens, containerLook } from "./render.ts";
13
13
  export { bareWebProfile } from "./profile.ts";
14
14
  export type { EmojiResolution, Profile, MediaResolution, TurbolinkLevel } from "./profile.ts";
15
15
 
package/src/render.ts CHANGED
@@ -279,7 +279,7 @@ function cssUrl(url: string): string {
279
279
  * color, or `tile:<target>` - a tiled background image, resolved through
280
280
  * the embedder's media policy exactly as an embed (a background fetch is a
281
281
  * fetch): out-of-policy or non-image targets degrade to no background. */
282
- function styleVars(attrs: Attrs, profile: Profile): string {
282
+ function styleVarList(attrs: Attrs, profile: Profile): string {
283
283
  const vars: string[] = [];
284
284
  if (isColorValue(attrs["color"])) {
285
285
  vars.push(`--mq-color:${attrs["color"]}`);
@@ -295,7 +295,25 @@ function styleVars(attrs: Attrs, profile: Profile): string {
295
295
  } else if (isColorValue(bg)) {
296
296
  vars.push(`--mq-bg:${bg}`);
297
297
  }
298
- return vars.length === 0 ? "" : ` style="${vars.join(";")}"`;
298
+ return vars.join(";");
299
+ }
300
+
301
+ function styleVars(attrs: Attrs, profile: Profile): string {
302
+ const list = styleVarList(attrs, profile);
303
+ return list === "" ? "" : ` style="${list}"`;
304
+ }
305
+
306
+ /** The visual identity a layout container (:::page / :::section) wears -
307
+ * its scheme/font classes and validated style knobs - as bare class/style
308
+ * values. For surfaces that paint a container's look onto elements THEY
309
+ * own instead of rendering the container: the live editor washes it across
310
+ * the container's source lines. Same gates as rendering, so the two can't
311
+ * disagree. */
312
+ export function containerLook(attrs: Attrs, profile: Profile = bareWebProfile): { classes: string; style: string } {
313
+ return {
314
+ classes: `${schemeClass(attrs)}${fontClass(attrs)}`.trim(),
315
+ style: styleVarList(attrs, profile),
316
+ };
299
317
  }
300
318
 
301
319
  function schemeClass(attrs: Attrs): string {