@rangular-framework/compiler 1.1.0 → 1.1.2

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.
@@ -1353,10 +1353,19 @@ function renderPreview(component, ast, data = {}) {
1353
1353
  // the theme stop, stop by stop.
1354
1354
  const stopCss = (v, fallback) => v === undefined ? fallback : v.startsWith('#') ? v : `var(--role-${kebabRole(v)})`;
1355
1355
  const from = el.attrs['from'], via = el.attrs['via'], to = el.attrs['to'];
1356
+ const bg = `background: linear-gradient(115deg, ${stopCss(from, t.colors.gradientFrom)}, ${stopCss(via, t.colors.gradientVia)} 52%, ${stopCss(to, t.colors.gradientTo)});`;
1357
+ if (el.booleanAttrs.includes('bleed') && screenDepth > 0) {
1358
+ // Full bleed (full-bleed round, 2026-12-03): the fill
1359
+ // leaves the surface and covers the whole screen (the
1360
+ // .screen box is position:relative), and the children
1361
+ // render in a plain container floating on the wash.
1362
+ // Outside a screen the gradient keeps its surface, the
1363
+ // same fallback the app makes.
1364
+ return `<div class="gradient-bleed-fill" style="${bg}"></div><div class="gradient-bleed"${dirStyle}>${inner}</div>`;
1365
+ }
1356
1366
  if (from === undefined && via === undefined && to === undefined) {
1357
1367
  return `<div class="gradient"${dirStyle}>${inner}</div>`;
1358
1368
  }
1359
- const bg = `background: linear-gradient(115deg, ${stopCss(from, t.colors.gradientFrom)}, ${stopCss(via, t.colors.gradientVia)} 52%, ${stopCss(to, t.colors.gradientTo)});`;
1360
1369
  const styleAttr = dirStyle ? dirStyle.replace('style="', `style="${bg} `) : ` style="${bg}"`;
1361
1370
  return `<div class="gradient"${styleAttr}>${inner}</div>`;
1362
1371
  }
@@ -1683,6 +1692,11 @@ function renderPreview(component, ast, data = {}) {
1683
1692
  .appbar-children { margin-top: ${t.spacing.sm}px; }
1684
1693
  .appbar-action { display: inline-flex; }
1685
1694
  .gradient { background: linear-gradient(115deg, ${t.colors.gradientFrom}, ${t.colors.gradientVia} 52%, ${t.colors.gradientTo}); color: var(--on-primary); --text: var(--on-primary); --text-muted: var(--on-primary); border-radius: ${t.radius.lg}px; padding: ${t.spacing.md}px; display: flex; flex-direction: column; gap: ${t.spacing.sm}px; }
1695
+ /* Full bleed (full-bleed round, 2026-12-03): the fill covers
1696
+ the whole .screen box, padding and safe strips included; the
1697
+ children float on it in a plain container. */
1698
+ .gradient-bleed-fill { position: absolute; inset: 0; }
1699
+ .gradient-bleed { position: relative; display: flex; flex-direction: column; gap: ${t.spacing.sm}px; color: var(--on-primary); --text: var(--on-primary); --text-muted: var(--on-primary); }
1686
1700
  .section-head { display: flex; align-items: center; gap: ${t.spacing.sm}px; }
1687
1701
  .section-bar { width: 4px; height: 20px; border-radius: 2px; background: linear-gradient(180deg, ${t.colors.gradientVia}, ${t.colors.gradientTo}); flex: 0 0 4px; }
1688
1702
  .section-title { flex: 1; font-size: ${t.typography.title.fontSize}px; font-weight: 700; }
@@ -6876,7 +6890,19 @@ function __buildCore(el, scope, path, form) {
6876
6890
  return [f];
6877
6891
  }
6878
6892
  case 'header': return wrap('header', 'stack');
6879
- case 'gradient': return wrap('div', 'gradient');
6893
+ case 'gradient': {
6894
+ // Full bleed: the fill covers the whole screen box and the
6895
+ // children float on it, the static renderer's shape. Outside
6896
+ // a screen the gradient keeps its surface.
6897
+ if (el.booleanAttrs.indexOf('bleed') >= 0 && __screenDepth > 0) {
6898
+ var gstop = function (v, role) { return !v ? 'var(--role-' + role + ')' : (v.charAt(0) === '#' ? v : 'var(--role-' + v.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase() + ')'); };
6899
+ var gfill = document.createElement('div');
6900
+ gfill.className = 'gradient-bleed-fill';
6901
+ gfill.style.background = 'linear-gradient(115deg, ' + gstop(__attr(el, 'from', scope), 'gradient-from') + ', ' + gstop(__attr(el, 'via', scope), 'gradient-via') + ' 52%, ' + gstop(__attr(el, 'to', scope), 'gradient-to') + ')';
6902
+ return [gfill].concat(wrap('div', 'gradient-bleed'));
6903
+ }
6904
+ return wrap('div', 'gradient');
6905
+ }
6880
6906
  case 'section': {
6881
6907
  var secLabel = __attr(el, 'label', scope);
6882
6908
  if (!secLabel) { var secWrap = wrap('section', 'stack'); __attachEvents(secWrap[0], el, scope); return secWrap; }
@@ -39,7 +39,7 @@ exports.ELEMENT_PROPS = {
39
39
  'fab': ['label'],
40
40
  'file-picker': ['disabled', 'kind', 'label', 'multiple', 'placeholder', 'style'],
41
41
  'form': ['icon', 'label', 'meta', 'plain', 'style'],
42
- 'gradient': ['from', 'style', 'to', 'via'],
42
+ 'gradient': ['bleed', 'from', 'style', 'to', 'via'],
43
43
  'grid-list': ['cols', 'mode', 'style'],
44
44
  'grid-tile': ['__widthPct', 'style'],
45
45
  'h1': ['style', 'variant'],
@@ -54,6 +54,15 @@ export interface TextNode {
54
54
  type: 'text';
55
55
  parts: TextPart[];
56
56
  pos: SourcePos;
57
+ /** Parser scratch only: the raw text carried whitespace at its
58
+ * leading edge. The parser's boundary-space pass reads these
59
+ * three flags and clears them before the AST leaves the parser,
60
+ * so no other stage ever sees them. */
61
+ leadWs?: boolean;
62
+ /** Parser scratch: the raw text carried whitespace at its trailing edge. */
63
+ tailWs?: boolean;
64
+ /** Parser scratch: the raw text was whitespace only. */
65
+ wsOnly?: boolean;
57
66
  }
58
67
  export type TemplateNode = ElementNode | TextNode;
59
68
  export interface TemplateRoot {
@@ -67,13 +67,111 @@ function parseTemplate(source) {
67
67
  let raw = '';
68
68
  while (!eof() && source[i] !== '<')
69
69
  raw += advance(1);
70
- // Pure layout whitespace between elements is not content.
71
- if (raw.trim() === '')
70
+ if (raw === '')
72
71
  return undefined;
73
- const leadingWs = raw.length - raw.trimStart().length;
72
+ // Pure layout whitespace between elements is not content. The
73
+ // node is still returned, marked wsOnly, so the boundary-space
74
+ // pass in parseNodes can keep a single space where the
75
+ // whitespace separates two inline elements inside a text
76
+ // block; everywhere else the pass drops it, exactly as before.
77
+ if (raw.trim() === '') {
78
+ return { type: 'text', parts: [], pos: at, wsOnly: true };
79
+ }
74
80
  const trimmed = raw.trim();
75
- void leadingWs;
76
- return { type: 'text', parts: splitInterpolation(trimmed, at), pos: at };
81
+ return {
82
+ type: 'text',
83
+ parts: splitInterpolation(trimmed, at),
84
+ pos: at,
85
+ leadWs: /^\s/.test(raw),
86
+ tailWs: /\s$/.test(raw),
87
+ };
88
+ }
89
+ // The elements whose children form one text run: a heading, a
90
+ // paragraph, a label, a code block, a span, a button's label.
91
+ // Inside these, whitespace at a text run's edge, where the run
92
+ // touches an element sibling, is a real space the author typed
93
+ // ("Welcome to <span>Rangular</span>"), and Angular keeps one
94
+ // space there. Everywhere else (sections, cards, the root),
95
+ // edge whitespace is layout and is trimmed, as it always was.
96
+ const TEXT_FLOW_TAGS = new Set(['h1', 'h2', 'h3', 'p', 'label', 'span', 'code', 'button']);
97
+ function finishNodes(nodes, parentTag) {
98
+ const textFlow = parentTag !== undefined && TEXT_FLOW_TAGS.has(parentTag);
99
+ const isWsOnly = (n) => n.type === 'text' && !!n.wsOnly;
100
+ const kept = [];
101
+ for (let idx = 0; idx < nodes.length; idx++) {
102
+ const node = nodes[idx];
103
+ if (isWsOnly(node)) {
104
+ if (textFlow) {
105
+ const prev = nodes.slice(0, idx).reverse().find((n) => !isWsOnly(n));
106
+ const next = nodes.slice(idx + 1).find((n) => !isWsOnly(n));
107
+ if (prev?.type === 'element' && next?.type === 'element') {
108
+ kept.push({ type: 'text', parts: [{ type: 'static', value: ' ' }], pos: node.pos });
109
+ }
110
+ }
111
+ continue;
112
+ }
113
+ kept.push(node);
114
+ }
115
+ if (!textFlow) {
116
+ for (const n of kept) {
117
+ if (n.type === 'text') {
118
+ delete n.leadWs;
119
+ delete n.tailWs;
120
+ delete n.wsOnly;
121
+ }
122
+ }
123
+ return kept;
124
+ }
125
+ // Text runs that ended up adjacent (a dropped comment can
126
+ // split one run into two) merge back into one; the seam takes
127
+ // a single space when either side carried whitespace.
128
+ const merged = [];
129
+ for (const node of kept) {
130
+ const last = merged[merged.length - 1];
131
+ if (last && last.type === 'text' && node.type === 'text') {
132
+ const a = last;
133
+ const b = node;
134
+ if (a.tailWs || b.leadWs) {
135
+ const tail = a.parts[a.parts.length - 1];
136
+ if (tail && tail.type === 'static')
137
+ tail.value += ' ';
138
+ else
139
+ a.parts.push({ type: 'static', value: ' ' });
140
+ }
141
+ a.parts.push(...b.parts);
142
+ a.tailWs = b.tailWs;
143
+ continue;
144
+ }
145
+ merged.push(node);
146
+ }
147
+ // The boundary spaces themselves: one space at an edge that
148
+ // touched an element sibling through whitespace.
149
+ for (let idx = 0; idx < merged.length; idx++) {
150
+ const node = merged[idx];
151
+ if (node.type !== 'text')
152
+ continue;
153
+ const text = node;
154
+ const prev = merged[idx - 1];
155
+ const next = merged[idx + 1];
156
+ if (text.leadWs && prev?.type === 'element') {
157
+ const head = text.parts[0];
158
+ if (head && head.type === 'static')
159
+ head.value = ' ' + head.value;
160
+ else
161
+ text.parts.unshift({ type: 'static', value: ' ' });
162
+ }
163
+ if (text.tailWs && next?.type === 'element') {
164
+ const tail = text.parts[text.parts.length - 1];
165
+ if (tail && tail.type === 'static')
166
+ tail.value += ' ';
167
+ else
168
+ text.parts.push({ type: 'static', value: ' ' });
169
+ }
170
+ delete text.leadWs;
171
+ delete text.tailWs;
172
+ delete text.wsOnly;
173
+ }
174
+ return merged;
77
175
  }
78
176
  function skipComment() {
79
177
  const end = source.indexOf('-->', i + 4);
@@ -201,14 +299,14 @@ function parseTemplate(source) {
201
299
  advance(1);
202
300
  if (untilTag === undefined) {
203
301
  diagnostics.push((0, diagnostics_1.error)('TPL_CLOSE', `Unexpected closing tag </${closing}>`, at.line, at.column, `Remove the stray </${closing}> or add its opening <${closing}> before it`));
204
- return nodes;
302
+ return finishNodes(nodes, untilTag);
205
303
  }
206
304
  if (closing !== untilTag) {
207
305
  diagnostics.push((0, diagnostics_1.error)('TPL_MISMATCH', `Expected </${untilTag}> but found </${closing}>`, at.line, at.column, VOID_TAGS.has(closing.toLowerCase())
208
306
  ? `<${closing}> is a void element and takes no closing tag; remove the </${closing}>`
209
307
  : `Close <${untilTag}> with </${untilTag}>, check for a missing or mis-nested closing tag above`));
210
308
  }
211
- return nodes;
309
+ return finishNodes(nodes, untilTag);
212
310
  }
213
311
  if (source[i] === '<') {
214
312
  const el = parseElement();
@@ -223,7 +321,7 @@ function parseTemplate(source) {
223
321
  if (untilTag !== undefined) {
224
322
  diagnostics.push((0, diagnostics_1.error)('TPL_UNCLOSED', `Element <${untilTag}> is never closed`, openPos.line, openPos.column, `Add the missing closing tag </${untilTag}>`));
225
323
  }
226
- return nodes;
324
+ return finishNodes(nodes, untilTag);
227
325
  }
228
326
  const children = parseNodes(undefined, { line: 1, column: 1 });
229
327
  return { root: { type: 'root', children }, diagnostics };
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "main": "dist/compiler/src/index.js",
8
8
  "name": "@rangular-framework/compiler",
9
9
  "types": "dist/compiler/src/index.d.ts",
10
- "version": "1.1.0",
10
+ "version": "1.1.2",
11
11
  "files": [
12
12
  "dist"
13
13
  ],