@rangular-framework/compiler 1.1.2 → 1.2.1
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/compiler/src/codegen/generate.d.ts +13 -1
- package/dist/compiler/src/codegen/generate.js +120 -7
- package/dist/compiler/src/codegen/methods.d.ts +8 -1
- package/dist/compiler/src/codegen/methods.js +33 -1
- package/dist/compiler/src/diagnostics.js +2 -1
- package/dist/compiler/src/preview/renderPreview.js +51 -12
- package/dist/compiler/src/propTable.js +5 -5
- package/dist/compiler/src/style/css.js +2 -2
- package/dist/compiler/src/template/parser.js +53 -6
- package/dist/ui/src/icons.d.ts +6 -4
- package/dist/ui/src/icons.js +15 -8
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { CarriedImportBinding, ComponentInfo, DirectiveInfo, PipeInfo, ServiceIn
|
|
|
2
2
|
import { ResolvedRoute } from '../class/parseRoutes';
|
|
3
3
|
import { Diagnostic } from '../diagnostics';
|
|
4
4
|
import { ParsedCss } from '../style/css';
|
|
5
|
-
import { TemplateRoot } from '../template/ast';
|
|
5
|
+
import { ElementNode, TemplateRoot } from '../template/ast';
|
|
6
6
|
import { MethodHost } from './methods';
|
|
7
7
|
import { SourceMapV3 } from './sourceMap';
|
|
8
8
|
export interface GenerateResult {
|
|
@@ -80,6 +80,18 @@ export interface TagMapping {
|
|
|
80
80
|
/** Text variant for heading/paragraph mappings */
|
|
81
81
|
variant?: string;
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* The text tags that accept gradient text (1.2.0): a text-gradient
|
|
85
|
+
* flag plus from, via and to stops, the <gradient> stop contract
|
|
86
|
+
* on a text element. The flag and stops compile to the textGradient,
|
|
87
|
+
* from, via and to props of RgText, which paints the letters with
|
|
88
|
+
* the gradient. A span is in the set even though it normally
|
|
89
|
+
* compiles to plain RN Text: a span carrying the flag compiles to
|
|
90
|
+
* RgText instead (see renderCore).
|
|
91
|
+
*/
|
|
92
|
+
export declare const TEXT_GRADIENT_TAGS: Set<string>;
|
|
93
|
+
/** True when the element carries the text-gradient flag in any written form. */
|
|
94
|
+
export declare const carriesTextGradient: (el: ElementNode) => boolean;
|
|
83
95
|
/**
|
|
84
96
|
* The tag -> generated-component contract. Single source of truth:
|
|
85
97
|
* codegen renders from this table and the catalog is generated from it.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EVENT_PROPS = exports.TAG_MAP = void 0;
|
|
3
|
+
exports.EVENT_PROPS = exports.TAG_MAP = exports.carriesTextGradient = exports.TEXT_GRADIENT_TAGS = void 0;
|
|
4
4
|
exports.isLiteralInitializer = isLiteralInitializer;
|
|
5
5
|
exports.verbatimInitFields = verbatimInitFields;
|
|
6
6
|
exports.styleKeyName = styleKeyName;
|
|
@@ -27,6 +27,20 @@ const literal_1 = require("../template/literal");
|
|
|
27
27
|
const structural_1 = require("../template/structural");
|
|
28
28
|
const methods_1 = require("./methods");
|
|
29
29
|
const sourceMap_1 = require("./sourceMap");
|
|
30
|
+
/**
|
|
31
|
+
* The text tags that accept gradient text (1.2.0): a text-gradient
|
|
32
|
+
* flag plus from, via and to stops, the <gradient> stop contract
|
|
33
|
+
* on a text element. The flag and stops compile to the textGradient,
|
|
34
|
+
* from, via and to props of RgText, which paints the letters with
|
|
35
|
+
* the gradient. A span is in the set even though it normally
|
|
36
|
+
* compiles to plain RN Text: a span carrying the flag compiles to
|
|
37
|
+
* RgText instead (see renderCore).
|
|
38
|
+
*/
|
|
39
|
+
exports.TEXT_GRADIENT_TAGS = new Set(['h1', 'h2', 'h3', 'p', 'span', 'label']);
|
|
40
|
+
/** True when the element carries the text-gradient flag in any written form. */
|
|
41
|
+
const carriesTextGradient = (el) => el.booleanAttrs.includes('text-gradient') || el.attrs['text-gradient'] !== undefined ||
|
|
42
|
+
el.propBindings.some((b) => b.name === 'text-gradient' || b.name === 'textGradient');
|
|
43
|
+
exports.carriesTextGradient = carriesTextGradient;
|
|
30
44
|
/**
|
|
31
45
|
* The tag -> generated-component contract. Single source of truth:
|
|
32
46
|
* codegen renders from this table and the catalog is generated from it.
|
|
@@ -1159,7 +1173,11 @@ class Generator {
|
|
|
1159
1173
|
if (mapping?.fromUi && propTable_1.ELEMENT_PROPS[tag]) {
|
|
1160
1174
|
const allowed = [...propTable_1.ELEMENT_PROPS[tag], ...(propTable_1.ELEMENT_EXTRA_PROPS[tag] ?? []), ...propTable_1.GLOBAL_ATTRS, ...propTable_1.CODEGEN_ATTRS];
|
|
1161
1175
|
const allowedSet = new Set(allowed);
|
|
1162
|
-
|
|
1176
|
+
// The author writes the gradient flag kebab-case
|
|
1177
|
+
// (text-gradient); the prop it compiles to is
|
|
1178
|
+
// textGradient, which is what the allowed set holds.
|
|
1179
|
+
const names = [...Object.keys(node.attrs), ...node.booleanAttrs, ...node.propBindings.map((b) => b.name), ...node.twoWayBindings.map((b) => b.name)]
|
|
1180
|
+
.map((n) => (exports.TEXT_GRADIENT_TAGS.has(tag) && n === 'text-gradient' ? 'textGradient' : n));
|
|
1163
1181
|
for (const name of names) {
|
|
1164
1182
|
if (name.startsWith('data-') || name.startsWith('aria-'))
|
|
1165
1183
|
continue;
|
|
@@ -1812,10 +1830,32 @@ class Generator {
|
|
|
1812
1830
|
return entries.length ? `{ ${entries.join(', ')} }` : undefined;
|
|
1813
1831
|
};
|
|
1814
1832
|
const renderText = (node, indent) => {
|
|
1815
|
-
const parts = node.parts.map((p) => {
|
|
1816
|
-
if (p.type
|
|
1817
|
-
return
|
|
1818
|
-
|
|
1833
|
+
const parts = node.parts.map((p, idx) => {
|
|
1834
|
+
if (p.type !== 'static')
|
|
1835
|
+
return `{${codeExpr(p.expression)}}`;
|
|
1836
|
+
// A space at the very start or end of a text run is
|
|
1837
|
+
// emitted as an explicit {' '} expression (1.2.0): JSX
|
|
1838
|
+
// line rules and React Native both eat a literal edge
|
|
1839
|
+
// space at a piece join, which is how the 1.1.2 title
|
|
1840
|
+
// lost its space on device. The parser now attaches a
|
|
1841
|
+
// boundary space to the start of the following run, and
|
|
1842
|
+
// this emission is what lets it survive: {' '} renders
|
|
1843
|
+
// exactly one space in both renderers. Mid-run spaces
|
|
1844
|
+
// stay literal text.
|
|
1845
|
+
let value = p.value;
|
|
1846
|
+
let prefix = '';
|
|
1847
|
+
let suffix = '';
|
|
1848
|
+
if (idx === 0 && value.startsWith(' ')) {
|
|
1849
|
+
prefix = "{' '}";
|
|
1850
|
+
value = value.slice(1);
|
|
1851
|
+
}
|
|
1852
|
+
if (idx === node.parts.length - 1 && value.length > 0 && value.endsWith(' ')) {
|
|
1853
|
+
suffix = "{' '}";
|
|
1854
|
+
value = value.slice(0, -1);
|
|
1855
|
+
}
|
|
1856
|
+
if (value === '')
|
|
1857
|
+
return prefix + suffix;
|
|
1858
|
+
return prefix + jsxTextPart(value) + suffix;
|
|
1819
1859
|
});
|
|
1820
1860
|
return indent + parts.join('');
|
|
1821
1861
|
};
|
|
@@ -2548,7 +2588,13 @@ class Generator {
|
|
|
2548
2588
|
return renderSpinner(el, depth, extraProps);
|
|
2549
2589
|
const indent = ' '.repeat(depth + 2);
|
|
2550
2590
|
const lines = [];
|
|
2551
|
-
|
|
2591
|
+
let mapping = exports.TAG_MAP[el.tag.toLowerCase()];
|
|
2592
|
+
// A span normally compiles to plain RN Text, the inline
|
|
2593
|
+
// element; a span carrying the text-gradient flag needs the
|
|
2594
|
+
// gradient paint, so it compiles to RgText instead (1.2.0).
|
|
2595
|
+
if (el.tag.toLowerCase() === 'span' && (0, exports.carriesTextGradient)(el)) {
|
|
2596
|
+
mapping = { component: 'RgText', fromUi: true };
|
|
2597
|
+
}
|
|
2552
2598
|
const childInfo = !mapping ? this.childBySelector.get(el.tag) : undefined;
|
|
2553
2599
|
let componentName;
|
|
2554
2600
|
if (mapping) {
|
|
@@ -2690,6 +2736,51 @@ class Generator {
|
|
|
2690
2736
|
}
|
|
2691
2737
|
}
|
|
2692
2738
|
}
|
|
2739
|
+
// Gradient text (1.2.0): a text element carrying the
|
|
2740
|
+
// text-gradient flag paints its letters with a gradient
|
|
2741
|
+
// through its from, via and to stops, the <gradient> stop
|
|
2742
|
+
// contract on a text element. The flag with no from and no
|
|
2743
|
+
// to stop is a GEN_TEXT_GRADIENT error and the flag is
|
|
2744
|
+
// dropped, so the text renders in its normal colour; stops
|
|
2745
|
+
// without the flag are a GEN_TEXT_GRADIENT warning and the
|
|
2746
|
+
// stops are dropped. A bad static stop with the flag is the
|
|
2747
|
+
// GEN_GRADIENT_STOP error, the same rule as <gradient>, and
|
|
2748
|
+
// the stop is dropped. Bound stops pass through and resolve
|
|
2749
|
+
// at runtime, the [color] binding rule.
|
|
2750
|
+
const isTextGradientTag = exports.TEXT_GRADIENT_TAGS.has(el.tag.toLowerCase());
|
|
2751
|
+
let dropTextGradient = false;
|
|
2752
|
+
const dropBoundStops = new Set();
|
|
2753
|
+
if (isTextGradientTag) {
|
|
2754
|
+
const hasFlag = (0, exports.carriesTextGradient)(el);
|
|
2755
|
+
const hasFromOrTo = el.attrs['from'] !== undefined || el.attrs['to'] !== undefined
|
|
2756
|
+
|| el.propBindings.some((b) => b.name === 'from' || b.name === 'to');
|
|
2757
|
+
const hasStop = hasFromOrTo || el.attrs['via'] !== undefined
|
|
2758
|
+
|| el.propBindings.some((b) => b.name === 'via');
|
|
2759
|
+
if (hasFlag && !hasFromOrTo) {
|
|
2760
|
+
diagnostics.push((0, diagnostics_1.error)('GEN_TEXT_GRADIENT', `<${el.tag}> carries text-gradient with no from and no to stop; the flag was dropped and the text renders in its normal colour`, el.pos.line, el.pos.column, 'Add a from and a to stop, each a hex colour or a colour role name (text-gradient from="#a52a3a" to="#7e1220"), or remove text-gradient'));
|
|
2761
|
+
dropTextGradient = true;
|
|
2762
|
+
}
|
|
2763
|
+
else if (!hasFlag && hasStop) {
|
|
2764
|
+
diagnostics.push((0, diagnostics_1.warning)('GEN_TEXT_GRADIENT', `<${el.tag}> carries gradient stops (from, via, to) without text-gradient; the stops have no effect and were dropped`, el.pos.line, el.pos.column, 'Add the text-gradient flag to paint the text with the gradient, or remove the stops'));
|
|
2765
|
+
for (const s of ['from', 'via', 'to']) {
|
|
2766
|
+
dropStops.add(s);
|
|
2767
|
+
dropBoundStops.add(s);
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
else if (hasFlag) {
|
|
2771
|
+
for (const stopName of ['from', 'via', 'to']) {
|
|
2772
|
+
const stopValue = el.attrs[stopName];
|
|
2773
|
+
if (stopValue === undefined)
|
|
2774
|
+
continue;
|
|
2775
|
+
const isHex = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(stopValue);
|
|
2776
|
+
const isRole = Object.prototype.hasOwnProperty.call(tokens_1.colours.light, stopValue);
|
|
2777
|
+
if (!isHex && !isRole) {
|
|
2778
|
+
diagnostics.push((0, diagnostics_1.error)('GEN_GRADIENT_STOP', `<${el.tag}> ${stopName} '${stopValue}' is not a hex colour or a colour role; the stop was dropped and the theme gradient stop is used`, el.pos.line, el.pos.column, 'Write the stop as a hex colour (from="#fbcfe8") or a colour role name (via="accent")'));
|
|
2779
|
+
dropStops.add(stopName);
|
|
2780
|
+
}
|
|
2781
|
+
}
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2693
2784
|
for (const [name, value] of Object.entries(el.attrs)) {
|
|
2694
2785
|
if (name === 'class')
|
|
2695
2786
|
continue;
|
|
@@ -2712,6 +2803,14 @@ class Generator {
|
|
|
2712
2803
|
continue;
|
|
2713
2804
|
if (dropStops.has(name))
|
|
2714
2805
|
continue;
|
|
2806
|
+
// The gradient flag written with a value still means the
|
|
2807
|
+
// flag: it compiles to the textGradient prop, never to a
|
|
2808
|
+
// kebab-case attribute on the generated element.
|
|
2809
|
+
if (isTextGradientTag && name === 'text-gradient') {
|
|
2810
|
+
if (!dropTextGradient)
|
|
2811
|
+
props.push('textGradient');
|
|
2812
|
+
continue;
|
|
2813
|
+
}
|
|
2715
2814
|
// A button's type is forms machinery (Stage 8): type="submit"
|
|
2716
2815
|
// is consumed by the submit rewrite below, never a prop.
|
|
2717
2816
|
if (isButtonEl && name === 'type')
|
|
@@ -2721,6 +2820,11 @@ class Generator {
|
|
|
2721
2820
|
for (const b of el.booleanAttrs) {
|
|
2722
2821
|
if (consumedByDirective.has(b))
|
|
2723
2822
|
continue;
|
|
2823
|
+
if (isTextGradientTag && b === 'text-gradient') {
|
|
2824
|
+
if (!dropTextGradient)
|
|
2825
|
+
props.push('textGradient');
|
|
2826
|
+
continue;
|
|
2827
|
+
}
|
|
2724
2828
|
props.push(b);
|
|
2725
2829
|
}
|
|
2726
2830
|
for (const p of el.propBindings) {
|
|
@@ -2740,6 +2844,15 @@ class Generator {
|
|
|
2740
2844
|
continue;
|
|
2741
2845
|
if (p.name === 'tooltip' && dropTooltip)
|
|
2742
2846
|
continue;
|
|
2847
|
+
if (dropBoundStops.has(p.name))
|
|
2848
|
+
continue;
|
|
2849
|
+
// A bound gradient flag ([text-gradient] or [textGradient])
|
|
2850
|
+
// compiles to the textGradient prop under its camel name.
|
|
2851
|
+
if (isTextGradientTag && (p.name === 'text-gradient' || p.name === 'textGradient')) {
|
|
2852
|
+
if (!dropTextGradient)
|
|
2853
|
+
props.push(`textGradient={${codeExpr(p.expression)}}`);
|
|
2854
|
+
continue;
|
|
2855
|
+
}
|
|
2743
2856
|
props.push(`${p.name}={${codeExpr(p.expression)}}`);
|
|
2744
2857
|
}
|
|
2745
2858
|
// Form submit (Stage 8): a <button type="submit"> statically
|
|
@@ -66,7 +66,14 @@ export declare function analyzeMutatedFields(component: MethodHost): Set<string>
|
|
|
66
66
|
* round, 2026-11-29, point 9): the helper runs with the caller's
|
|
67
67
|
* render snapshot, so an assign in the caller, a read in the
|
|
68
68
|
* helper and an assign in the helper is the same trap split across
|
|
69
|
-
* the call. Deeper chains and recursion are not followed.
|
|
69
|
+
* the call. Deeper chains and recursion are not followed. Since
|
|
70
|
+
* 1.2.0 the helper read warns on its own, with no second assign
|
|
71
|
+
* needed: a helper called right after an assign reads the field
|
|
72
|
+
* as the value from before the method ran, so the read itself is
|
|
73
|
+
* the trap (the probe case of 2026-11-29: assign, call a helper
|
|
74
|
+
* that reads, done). A helper that writes the field before
|
|
75
|
+
* reading it stays silent, and a value passed to the helper as an
|
|
76
|
+
* argument is the fix the warning names.
|
|
70
77
|
*/
|
|
71
78
|
export declare function analyzeFieldRereads(component: MethodHost): Diagnostic[];
|
|
72
79
|
/**
|
|
@@ -163,7 +163,14 @@ function analyzeMutatedFields(component) {
|
|
|
163
163
|
* round, 2026-11-29, point 9): the helper runs with the caller's
|
|
164
164
|
* render snapshot, so an assign in the caller, a read in the
|
|
165
165
|
* helper and an assign in the helper is the same trap split across
|
|
166
|
-
* the call. Deeper chains and recursion are not followed.
|
|
166
|
+
* the call. Deeper chains and recursion are not followed. Since
|
|
167
|
+
* 1.2.0 the helper read warns on its own, with no second assign
|
|
168
|
+
* needed: a helper called right after an assign reads the field
|
|
169
|
+
* as the value from before the method ran, so the read itself is
|
|
170
|
+
* the trap (the probe case of 2026-11-29: assign, call a helper
|
|
171
|
+
* that reads, done). A helper that writes the field before
|
|
172
|
+
* reading it stays silent, and a value passed to the helper as an
|
|
173
|
+
* argument is the fix the warning names.
|
|
167
174
|
*/
|
|
168
175
|
function analyzeFieldRereads(component) {
|
|
169
176
|
const fieldNames = new Set(component.fields.map((f) => f.name));
|
|
@@ -180,10 +187,21 @@ function analyzeFieldRereads(component) {
|
|
|
180
187
|
continue;
|
|
181
188
|
let state = new Map();
|
|
182
189
|
const snapshot = (m) => new Map([...m].map(([k, v]) => [k, { ...v }]));
|
|
190
|
+
// The helper-call window: while the walk is inside a helper
|
|
191
|
+
// expanded from a direct call, the fields already assigned at
|
|
192
|
+
// the call are pending, and a read of one inside the helper
|
|
193
|
+
// warns at once (see the note above). helperName is null
|
|
194
|
+
// outside any expansion.
|
|
195
|
+
let helperName = null;
|
|
196
|
+
let helperPending = new Set();
|
|
183
197
|
const onRead = (name) => {
|
|
184
198
|
const s = state.get(name);
|
|
185
199
|
if (s?.assigned)
|
|
186
200
|
s.readSince = true;
|
|
201
|
+
if (helperName !== null && s && helperPending.has(name) && !s.flagged) {
|
|
202
|
+
s.flagged = true;
|
|
203
|
+
diagnostics.push((0, diagnostics_1.warning)('GEN_FIELD_REREAD', `Method '${method.name}' assigns this.${name} and then calls ${helperName}(), which reads this.${name}; the read sees the value from before the method ran, not the assigned value`, undefined, undefined, `Pass the new value to ${helperName} as an argument instead of reading this.${name} inside it, or assign this.${name} after the ${helperName}() call`));
|
|
204
|
+
}
|
|
187
205
|
};
|
|
188
206
|
const onWrite = (name) => {
|
|
189
207
|
const s = state.get(name) ?? { assigned: false, readSince: false, flagged: false };
|
|
@@ -194,6 +212,9 @@ function analyzeFieldRereads(component) {
|
|
|
194
212
|
s.assigned = true;
|
|
195
213
|
s.readSince = false;
|
|
196
214
|
state.set(name, s);
|
|
215
|
+
// A write inside the helper before its read settles the
|
|
216
|
+
// field: the read then sees the helper's own value.
|
|
217
|
+
helperPending.delete(name);
|
|
197
218
|
};
|
|
198
219
|
const walk = (node, depth = 0) => {
|
|
199
220
|
if (ts.isArrowFunction(node) || ts.isFunctionExpression(node))
|
|
@@ -207,8 +228,14 @@ function analyzeFieldRereads(component) {
|
|
|
207
228
|
if (callee && body) {
|
|
208
229
|
for (const arg of node.arguments)
|
|
209
230
|
walk(arg, depth);
|
|
231
|
+
const outerHelper = helperName;
|
|
232
|
+
const outerPending = helperPending;
|
|
233
|
+
helperName = callee.name;
|
|
234
|
+
helperPending = new Set([...state.entries()].filter(([, s]) => s.assigned).map(([f]) => f));
|
|
210
235
|
for (const s of body)
|
|
211
236
|
walk(s, depth + 1);
|
|
237
|
+
helperName = outerHelper;
|
|
238
|
+
helperPending = outerPending;
|
|
212
239
|
return;
|
|
213
240
|
}
|
|
214
241
|
}
|
|
@@ -221,12 +248,17 @@ function analyzeFieldRereads(component) {
|
|
|
221
248
|
// writes on any single path still flags.
|
|
222
249
|
walk(node.expression, depth);
|
|
223
250
|
const entry = snapshot(state);
|
|
251
|
+
const entryPending = new Set(helperPending);
|
|
224
252
|
walk(node.thenStatement, depth);
|
|
225
253
|
const afterThen = snapshot(state);
|
|
254
|
+
const pendingThen = new Set(helperPending);
|
|
226
255
|
state = entry;
|
|
256
|
+
helperPending = new Set(entryPending);
|
|
227
257
|
if (node.elseStatement)
|
|
228
258
|
walk(node.elseStatement, depth);
|
|
229
259
|
const afterElse = snapshot(state);
|
|
260
|
+
const pendingElse = new Set(helperPending);
|
|
261
|
+
helperPending = new Set([...pendingThen, ...pendingElse]);
|
|
230
262
|
const merged = new Map();
|
|
231
263
|
for (const name of new Set([...afterThen.keys(), ...afterElse.keys()])) {
|
|
232
264
|
const a = afterThen.get(name);
|
|
@@ -45,7 +45,7 @@ exports.DIAGNOSTIC_CODES = {
|
|
|
45
45
|
TPL_HANDLER: 'A template event binding names a method the component does not have; the handler would fail when the event fires.',
|
|
46
46
|
TPL_NESTED_SCREEN: 'A screen sits inside another screen in the same template; it renders embedded, as a flat themed region with no scroller of its own, so its scroll, refresh and end-reached settings have no effect.',
|
|
47
47
|
GEN_UNKNOWN_PROP: 'An attribute or binding on a known element is not one of that element\'s props; it would be passed through and ignored.',
|
|
48
|
-
GEN_FIELD_REREAD: 'A method assigns a field, reads it, then assigns it again; the read sees the value from before the method ran, not the assigned value.',
|
|
48
|
+
GEN_FIELD_REREAD: 'A method assigns a field, reads it, then assigns it again; or a method assigns a field and then calls a helper method that reads it. Either way the read sees the value from before the method ran, not the assigned value.',
|
|
49
49
|
GEN_TIMER_STALE: 'A timer created in ngOnInit or the constructor keeps the first render\'s field values; a callback that reads a component field reads the first value forever, so the display freezes or acts on stale state.',
|
|
50
50
|
GEN_DEEP_MUTATION: 'An assignment into a field\'s insides (an index or a property of the field) changes the data without the generated setter, so the view never re-renders; assign a new array or object to the field instead.',
|
|
51
51
|
GEN_LIST_CONTRACT_CLASH: 'A list that declares both (refresh) and (endReached) keeps only the end-reached contract; its pull-to-refresh never engages.',
|
|
@@ -77,6 +77,7 @@ exports.DIAGNOSTIC_CODES = {
|
|
|
77
77
|
GEN_BUTTON_COLOR: 'A <button> color is not one of the six colour roles (primary, secondary, danger, warning, success, neutral); the button keeps the primary colour.',
|
|
78
78
|
GEN_SWITCH_COLOR: 'A <switch> color is not one of the two colour roles (primary, success); the switch keeps the primary colour.',
|
|
79
79
|
GEN_GRADIENT_STOP: 'A <gradient> stop (from, via, to) is not a hex colour or a colour role name; the stop was dropped and the theme gradient stop is used instead.',
|
|
80
|
+
GEN_TEXT_GRADIENT: 'A text element (h1, h2, h3, p, span, label) carries text-gradient with no from and no to stop (an error: the flag is dropped and the text renders in its normal colour), or carries from, via or to stops without text-gradient (a warning: the stops have no effect and are dropped). Gradient text paints the letters with a gradient through the from, via and to stops, each a hex colour or a colour role name.',
|
|
80
81
|
GEN_CHART_TYPE: 'A <chart> type is not one of the three chart types (bar, line, pie); the chart would draw bars instead.',
|
|
81
82
|
GEN_OTP_LENGTH: 'An <otp> length is outside the supported 4 to 8; the generated control clamps it to the nearest of the two.',
|
|
82
83
|
GEN_PICKER_INTERVAL: 'A <datetime-picker> minuteInterval is not 1 or 5; the generated code uses the nearest of the two.',
|
|
@@ -1274,6 +1274,20 @@ function renderPreview(component, ast, data = {}) {
|
|
|
1274
1274
|
screenDepth--;
|
|
1275
1275
|
const title = bound(el, 'title', scope) ?? '';
|
|
1276
1276
|
const dirStyle = directiveStyleAttr(el, scope);
|
|
1277
|
+
// Gradient text (1.2.0): the text-gradient flag on a text
|
|
1278
|
+
// element paints its letters with the gradient in the app
|
|
1279
|
+
// (RgText through a masked view); the preview paints the same
|
|
1280
|
+
// stops with a CSS gradient clipped to the text. Static stops
|
|
1281
|
+
// only, like the <gradient> case below: a bound stop falls
|
|
1282
|
+
// back to the theme stop.
|
|
1283
|
+
let textStyle = dirStyle;
|
|
1284
|
+
if (['h1', 'h2', 'h3', 'p', 'span', 'label'].includes(el.tag)
|
|
1285
|
+
&& (el.booleanAttrs.includes('text-gradient') || el.attrs['text-gradient'] !== undefined
|
|
1286
|
+
|| el.propBindings.some((b) => b.name === 'text-gradient' || b.name === 'textGradient'))) {
|
|
1287
|
+
const gstop = (v, fallback) => v === undefined ? fallback : v.startsWith('#') ? v : `var(--role-${kebabRole(v)})`;
|
|
1288
|
+
const decl = `background: linear-gradient(115deg, ${gstop(el.attrs['from'], t.colors.gradientFrom)}, ${gstop(el.attrs['via'], t.colors.gradientVia)} 52%, ${gstop(el.attrs['to'], t.colors.gradientTo)}); -webkit-background-clip: text; background-clip: text; color: transparent;`;
|
|
1289
|
+
textStyle = dirStyle ? dirStyle.replace('style="', `style="${decl} `) : ` style="${decl}"`;
|
|
1290
|
+
}
|
|
1277
1291
|
switch (el.tag) {
|
|
1278
1292
|
case 'screen': {
|
|
1279
1293
|
// A screen inside a screen renders embedded (2026-11-27):
|
|
@@ -1335,15 +1349,15 @@ function renderPreview(component, ast, data = {}) {
|
|
|
1335
1349
|
return `<header class="${barCls}">${inner}</header>` + progHtml;
|
|
1336
1350
|
return `<header class="${barCls}">${rowHtml}${inner ? `<div class="appbar-children">${inner}</div>` : ''}</header>` + progHtml;
|
|
1337
1351
|
}
|
|
1338
|
-
case 'h1': return `<h1 class="display"${
|
|
1339
|
-
case 'h2': return `<h2 class="heading"${
|
|
1340
|
-
case 'h3': return `<h3 class="title"${
|
|
1341
|
-
case 'p': return `<p class="body"${
|
|
1352
|
+
case 'h1': return `<h1 class="display"${textStyle}>${inner}</h1>`;
|
|
1353
|
+
case 'h2': return `<h2 class="heading"${textStyle}>${inner}</h2>`;
|
|
1354
|
+
case 'h3': return `<h3 class="title"${textStyle}>${inner}</h3>`;
|
|
1355
|
+
case 'p': return `<p class="body"${textStyle}>${inner}</p>`;
|
|
1342
1356
|
case 'code': return `<pre class="code"${dirStyle}>${inner}</pre>`;
|
|
1343
|
-
case 'label': return `<span class="label"${
|
|
1357
|
+
case 'label': return `<span class="label"${textStyle}>${inner}</span>`;
|
|
1344
1358
|
case 'span': {
|
|
1345
1359
|
const cls = el.attrs['class'];
|
|
1346
|
-
return cls ? `<span class="${escapeHtml(cls)}"${
|
|
1360
|
+
return cls ? `<span class="${escapeHtml(cls)}"${textStyle}>${inner}</span>` : `<span${textStyle}>${inner}</span>`;
|
|
1347
1361
|
}
|
|
1348
1362
|
case 'card': return `<section class="card"${dirStyle}>${inner}</section>`;
|
|
1349
1363
|
case 'gradient': {
|
|
@@ -2626,6 +2640,31 @@ function __attr(el, name, scope) {
|
|
|
2626
2640
|
if (b !== undefined) return b;
|
|
2627
2641
|
return el.attrs[name];
|
|
2628
2642
|
}
|
|
2643
|
+
function __gradText(el, scope, nodes) {
|
|
2644
|
+
// Gradient text (1.2.0): the text-gradient flag in any written
|
|
2645
|
+
// form paints the node's letters with the gradient, the live
|
|
2646
|
+
// mirror of the static renderer's clipped CSS gradient. A stop
|
|
2647
|
+
// resolves bound first, then static; an absent stop falls back
|
|
2648
|
+
// to the theme stop, stop by stop.
|
|
2649
|
+
var has = el.booleanAttrs.indexOf('text-gradient') !== -1 || el.attrs['text-gradient'] !== undefined;
|
|
2650
|
+
if (!has) {
|
|
2651
|
+
for (var i = 0; i < el.propBindings.length; i++) {
|
|
2652
|
+
if (el.propBindings[i].name === 'text-gradient' || el.propBindings[i].name === 'textGradient') { has = true; break; }
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
if (!has || !nodes.length) return nodes;
|
|
2656
|
+
var gstop = function (v, fb) {
|
|
2657
|
+
if (v === undefined || v === null) return fb;
|
|
2658
|
+
v = String(v);
|
|
2659
|
+
return v.charAt(0) === '#' ? v : 'var(--role-' + __kebabRole(v) + ')';
|
|
2660
|
+
};
|
|
2661
|
+
var node = nodes[0];
|
|
2662
|
+
node.style.background = 'linear-gradient(115deg, ' + gstop(__attr(el, 'from', scope), 'var(--role-gradient-from)') + ', ' + gstop(__attr(el, 'via', scope), 'var(--role-gradient-via)') + ' 52%, ' + gstop(__attr(el, 'to', scope), 'var(--role-gradient-to)') + ')';
|
|
2663
|
+
node.style.webkitBackgroundClip = 'text';
|
|
2664
|
+
node.style.backgroundClip = 'text';
|
|
2665
|
+
node.style.color = 'transparent';
|
|
2666
|
+
return nodes;
|
|
2667
|
+
}
|
|
2629
2668
|
function __parseNgFor(expr) {
|
|
2630
2669
|
var segs = expr.split(';').map(function (x) { return x.trim(); }).filter(Boolean);
|
|
2631
2670
|
var m = /^let\s+([A-Za-z_$][\w$]*)\s+of\s+(.+)$/.exec(segs[0] || '');
|
|
@@ -6421,16 +6460,16 @@ function __buildCore(el, scope, path, form) {
|
|
|
6421
6460
|
return [bar];
|
|
6422
6461
|
}
|
|
6423
6462
|
|
|
6424
|
-
case 'h1': return wrap('h1', 'display');
|
|
6425
|
-
case 'h2': return wrap('h2', 'heading');
|
|
6426
|
-
case 'h3': return wrap('h3', 'title');
|
|
6427
|
-
case 'p': return wrap('p', 'body');
|
|
6463
|
+
case 'h1': return __gradText(el, scope, wrap('h1', 'display'));
|
|
6464
|
+
case 'h2': return __gradText(el, scope, wrap('h2', 'heading'));
|
|
6465
|
+
case 'h3': return __gradText(el, scope, wrap('h3', 'title'));
|
|
6466
|
+
case 'p': return __gradText(el, scope, wrap('p', 'body'));
|
|
6428
6467
|
case 'code': return wrap('pre', 'code');
|
|
6429
|
-
case 'label': return wrap('span', 'label');
|
|
6468
|
+
case 'label': return __gradText(el, scope, wrap('span', 'label'));
|
|
6430
6469
|
case 'span': {
|
|
6431
6470
|
var sp = wrap('span', '');
|
|
6432
6471
|
if (el.attrs['class']) sp[0].className = el.attrs['class'];
|
|
6433
|
-
return sp;
|
|
6472
|
+
return __gradText(el, scope, sp);
|
|
6434
6473
|
}
|
|
6435
6474
|
case 'card': {
|
|
6436
6475
|
var cardEl = wrap('section', 'card');
|
|
@@ -42,15 +42,15 @@ exports.ELEMENT_PROPS = {
|
|
|
42
42
|
'gradient': ['bleed', 'from', 'style', 'to', 'via'],
|
|
43
43
|
'grid-list': ['cols', 'mode', 'style'],
|
|
44
44
|
'grid-tile': ['__widthPct', 'style'],
|
|
45
|
-
'h1': ['style', 'variant'],
|
|
46
|
-
'h2': ['style', 'variant'],
|
|
47
|
-
'h3': ['style', 'variant'],
|
|
45
|
+
'h1': ['from', 'style', 'textGradient', 'to', 'variant', 'via'],
|
|
46
|
+
'h2': ['from', 'style', 'textGradient', 'to', 'variant', 'via'],
|
|
47
|
+
'h3': ['from', 'style', 'textGradient', 'to', 'variant', 'via'],
|
|
48
48
|
'header': ['icon', 'label', 'meta', 'plain', 'style'],
|
|
49
49
|
'icon': ['badge', 'color', 'name', 'size', 'style'],
|
|
50
50
|
'icon-button': ['color', 'name', 'size', 'style', 'tooltip'],
|
|
51
51
|
'image': ['height', 'resize', 'src', 'style', 'width'],
|
|
52
52
|
'input': ['avatarText', 'disabled', 'error', 'keyboardType', 'label', 'leadingIcon', 'mask', 'options', 'pillTone', 'placeholder', 'secure', 'style', 'value', 'variant'],
|
|
53
|
-
'label': ['style', 'variant'],
|
|
53
|
+
'label': ['from', 'style', 'textGradient', 'to', 'variant', 'via'],
|
|
54
54
|
'lightbox': ['open', 'src', 'style'],
|
|
55
55
|
'list': ['data', 'haptic', 'keyExtractor', 'refreshing', 'renderItem'],
|
|
56
56
|
'menu': ['open', 'style'],
|
|
@@ -58,7 +58,7 @@ exports.ELEMENT_PROPS = {
|
|
|
58
58
|
'nav-item': ['badge', 'icon', 'label'],
|
|
59
59
|
'option': ['value'],
|
|
60
60
|
'otp': ['disabled', 'length', 'style', 'value'],
|
|
61
|
-
'p': ['style', 'variant'],
|
|
61
|
+
'p': ['from', 'style', 'textGradient', 'to', 'variant', 'via'],
|
|
62
62
|
'panel': ['__groupExpanded', '__groupToggle', 'expanded', 'style', 'subtitle', 'title'],
|
|
63
63
|
'progress-bar': ['mode', 'style', 'value'],
|
|
64
64
|
'radio': ['value'],
|
|
@@ -8,7 +8,7 @@ const tokens_1 = require("../../../ui/src/tokens");
|
|
|
8
8
|
const diagnostics_1 = require("../diagnostics");
|
|
9
9
|
/** RN style properties Rangular's CSS subset supports in Stage 0+1. */
|
|
10
10
|
const SUPPORTED = new Set([
|
|
11
|
-
'color', 'backgroundColor', 'fontSize', 'fontWeight', 'fontStyle', 'lineHeight',
|
|
11
|
+
'color', 'backgroundColor', 'fontFamily', 'fontSize', 'fontWeight', 'fontStyle', 'lineHeight',
|
|
12
12
|
'letterSpacing', 'textAlign', 'margin', 'marginTop', 'marginBottom', 'marginLeft',
|
|
13
13
|
'marginRight', 'marginHorizontal', 'marginVertical', 'padding', 'paddingTop',
|
|
14
14
|
'paddingBottom', 'paddingLeft', 'paddingRight', 'paddingHorizontal',
|
|
@@ -150,7 +150,7 @@ function parseCss(cssText) {
|
|
|
150
150
|
const rawValue = decl.slice(colon + 1).trim();
|
|
151
151
|
const prop = camelCase(rawProp);
|
|
152
152
|
if (!SUPPORTED.has(prop)) {
|
|
153
|
-
diagnostics.push((0, diagnostics_1.warning)('CSS_UNSUPPORTED', `Unsupported CSS property '${rawProp}' in '${selector}', dropped`, undefined, undefined, `Remove '${rawProp}' or use a supported property (color, background-color, font-size, font-weight, margin/padding, border-radius, border-width/color, opacity, flex, flex-direction, align-items, justify-content, gap, width/height)`));
|
|
153
|
+
diagnostics.push((0, diagnostics_1.warning)('CSS_UNSUPPORTED', `Unsupported CSS property '${rawProp}' in '${selector}', dropped`, undefined, undefined, `Remove '${rawProp}' or use a supported property (color, background-color, font-family, font-size, font-weight, margin/padding, border-radius, border-width/color, opacity, flex, flex-direction, align-items, justify-content, gap, width/height)`));
|
|
154
154
|
continue;
|
|
155
155
|
}
|
|
156
156
|
styleObj[prop] = snapValue(prop, rawProp, convertValue(rawValue), diagnostics);
|
|
@@ -97,6 +97,28 @@ function parseTemplate(source) {
|
|
|
97
97
|
function finishNodes(nodes, parentTag) {
|
|
98
98
|
const textFlow = parentTag !== undefined && TEXT_FLOW_TAGS.has(parentTag);
|
|
99
99
|
const isWsOnly = (n) => n.type === 'text' && !!n.wsOnly;
|
|
100
|
+
// The first text run inside an element, walking the first
|
|
101
|
+
// child chain down: the run a boundary space moves to when it
|
|
102
|
+
// leaves the end of the run before the element (see the
|
|
103
|
+
// boundary pass below for why the space moves at all).
|
|
104
|
+
const firstTextRun = (el) => {
|
|
105
|
+
let level = el.children;
|
|
106
|
+
for (;;) {
|
|
107
|
+
const first = level.find((n) => !isWsOnly(n));
|
|
108
|
+
if (!first)
|
|
109
|
+
return undefined;
|
|
110
|
+
if (first.type === 'text')
|
|
111
|
+
return first;
|
|
112
|
+
level = first.children;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const prependSpace = (text) => {
|
|
116
|
+
const head = text.parts[0];
|
|
117
|
+
if (head && head.type === 'static')
|
|
118
|
+
head.value = ' ' + head.value;
|
|
119
|
+
else
|
|
120
|
+
text.parts.unshift({ type: 'static', value: ' ' });
|
|
121
|
+
};
|
|
100
122
|
const kept = [];
|
|
101
123
|
for (let idx = 0; idx < nodes.length; idx++) {
|
|
102
124
|
const node = nodes[idx];
|
|
@@ -105,7 +127,16 @@ function parseTemplate(source) {
|
|
|
105
127
|
const prev = nodes.slice(0, idx).reverse().find((n) => !isWsOnly(n));
|
|
106
128
|
const next = nodes.slice(idx + 1).find((n) => !isWsOnly(n));
|
|
107
129
|
if (prev?.type === 'element' && next?.type === 'element') {
|
|
108
|
-
|
|
130
|
+
// The space between two inline elements moves into
|
|
131
|
+
// the following element's first run, the same rule
|
|
132
|
+
// the tailWs case below follows; only when that
|
|
133
|
+
// element holds no text run does a standalone space
|
|
134
|
+
// node stay between them.
|
|
135
|
+
const run = firstTextRun(next);
|
|
136
|
+
if (run)
|
|
137
|
+
prependSpace(run);
|
|
138
|
+
else
|
|
139
|
+
kept.push({ type: 'text', parts: [{ type: 'static', value: ' ' }], pos: node.pos });
|
|
109
140
|
}
|
|
110
141
|
}
|
|
111
142
|
continue;
|
|
@@ -161,11 +192,27 @@ function parseTemplate(source) {
|
|
|
161
192
|
text.parts.unshift({ type: 'static', value: ' ' });
|
|
162
193
|
}
|
|
163
194
|
if (text.tailWs && next?.type === 'element') {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
195
|
+
// The space attaches to the START of the following
|
|
196
|
+
// element's first text run, not the end of this one
|
|
197
|
+
// (1.2.0): React Native drops a space at the end of a
|
|
198
|
+
// text piece where the next piece begins, so the 1.1.2
|
|
199
|
+
// shape compiled "Welcome to " and the phone rendered
|
|
200
|
+
// "Welcome toRangular" while the preview kept the
|
|
201
|
+
// space. A leading space on the following piece
|
|
202
|
+
// survives both renderers. When the following element
|
|
203
|
+
// holds no text run (an icon, an empty span), the space
|
|
204
|
+
// stays on this run's end, as before: there is no
|
|
205
|
+
// following piece for it to join.
|
|
206
|
+
const run = firstTextRun(next);
|
|
207
|
+
if (run)
|
|
208
|
+
prependSpace(run);
|
|
209
|
+
else {
|
|
210
|
+
const tail = text.parts[text.parts.length - 1];
|
|
211
|
+
if (tail && tail.type === 'static')
|
|
212
|
+
tail.value += ' ';
|
|
213
|
+
else
|
|
214
|
+
text.parts.push({ type: 'static', value: ' ' });
|
|
215
|
+
}
|
|
169
216
|
}
|
|
170
217
|
delete text.leadWs;
|
|
171
218
|
delete text.tailWs;
|
package/dist/ui/src/icons.d.ts
CHANGED
|
@@ -48,10 +48,12 @@ export declare const ICON_PATHS: Record<string, string[]>;
|
|
|
48
48
|
* (RgIcon in the app, both preview layers) draws from this one
|
|
49
49
|
* source, the same rule the icon paths follow.
|
|
50
50
|
*
|
|
51
|
-
* `logo` is the Rangular framework's own mark
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
51
|
+
* `logo` is the Rangular framework's own mark (redrawn
|
|
52
|
+
* 2026-12-04): the shield's top half is a maroon radial gradient,
|
|
53
|
+
* the bottom half an obsidian gradient with a soft gloss, the R
|
|
54
|
+
* is the true Cabin Medium glyph drawn as a path, and the React
|
|
55
|
+
* atom sits in cyan on the dark half. The master artwork lives
|
|
56
|
+
* at assets/logo.svg in the repo.
|
|
55
57
|
*/
|
|
56
58
|
export declare const BRAND_MARK_VIEWBOX = "0 0 100 100";
|
|
57
59
|
export declare const BRAND_MARKS: Record<string, string>;
|
package/dist/ui/src/icons.js
CHANGED
|
@@ -286,17 +286,24 @@ exports.ICON_PATHS = {
|
|
|
286
286
|
* (RgIcon in the app, both preview layers) draws from this one
|
|
287
287
|
* source, the same rule the icon paths follow.
|
|
288
288
|
*
|
|
289
|
-
* `logo` is the Rangular framework's own mark
|
|
290
|
-
*
|
|
291
|
-
*
|
|
292
|
-
*
|
|
289
|
+
* `logo` is the Rangular framework's own mark (redrawn
|
|
290
|
+
* 2026-12-04): the shield's top half is a maroon radial gradient,
|
|
291
|
+
* the bottom half an obsidian gradient with a soft gloss, the R
|
|
292
|
+
* is the true Cabin Medium glyph drawn as a path, and the React
|
|
293
|
+
* atom sits in cyan on the dark half. The master artwork lives
|
|
294
|
+
* at assets/logo.svg in the repo.
|
|
293
295
|
*/
|
|
294
296
|
exports.BRAND_MARK_VIEWBOX = '0 0 100 100';
|
|
295
297
|
exports.BRAND_MARKS = {
|
|
296
|
-
logo: '<
|
|
297
|
-
+ '<
|
|
298
|
-
+ '<
|
|
299
|
-
+ '<
|
|
298
|
+
logo: '<defs><linearGradient id="obs" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#2b2b31"/><stop offset="0.4" stop-color="#121216"/><stop offset="1" stop-color="#000000"/></linearGradient>'
|
|
299
|
+
+ '<radialGradient id="mar" gradientUnits="userSpaceOnUse" cx="50" cy="29" r="52"><stop offset="0" stop-color="#d42a35"/><stop offset="0.55" stop-color="#9c1420"/><stop offset="1" stop-color="#4a050d"/></radialGradient>'
|
|
300
|
+
+ '<radialGradient id="gloss" cx="0.5" cy="0.5" r="0.5"><stop offset="0" stop-color="#ffffff" stop-opacity="0.9"/><stop offset="1" stop-color="#ffffff" stop-opacity="0"/></radialGradient>'
|
|
301
|
+
+ '<radialGradient id="atomGlow" gradientUnits="userSpaceOnUse" cx="50" cy="66" r="30"><stop offset="0" stop-color="#2e3138"/><stop offset="1" stop-color="#2e3138" stop-opacity="0"/></radialGradient>'
|
|
302
|
+
+ '<clipPath id="bottomClip"><path d="M13 50 L87 50 L87 47 C87 71 71 85 50 97 C29 85 13 71 13 47 Z"/></clipPath></defs>'
|
|
303
|
+
+ '<path d="M50 3 L87 13 V47 C87 71 71 85 50 97 C29 85 13 71 13 47 V13 Z" fill="url(#obs)"/>'
|
|
304
|
+
+ '<path d="M50 3 L87 13 V50 H13 V13 Z" fill="url(#mar)"/>'
|
|
305
|
+
+ '<g clip-path="url(#bottomClip)"><rect x="13" y="50" width="74" height="47" fill="url(#atomGlow)"/><ellipse cx="50" cy="58" rx="46" ry="10" fill="url(#gloss)" opacity="0.20"/></g>'
|
|
306
|
+
+ '<path d="M157 0V1400H636Q782 1400 890.5 1354.5Q999 1309 1059.0 1215.0Q1119 1121 1119 975Q1119 827 1055.5 732.5Q992 638 878 583L1193 0H938L660 535Q657 535 655.0 535.0Q653 535 650 535H381V0ZM381 724H606Q755 724 823.5 791.0Q892 858 892 969Q892 1084 824.0 1147.5Q756 1211 610 1211H381Z" fill="#ffffff" transform="translate(37.46 41.00) scale(0.01857 -0.01857)"/>'
|
|
300
307
|
+ '<circle cx="50" cy="68" r="2.6" fill="#61DAFB"/>'
|
|
301
308
|
+ '<ellipse cx="50" cy="68" rx="17" ry="6.5" fill="none" stroke="#61DAFB" stroke-width="1.8"/>'
|
|
302
309
|
+ '<ellipse cx="50" cy="68" rx="17" ry="6.5" fill="none" stroke="#61DAFB" stroke-width="1.8" transform="rotate(60 50 68)"/>'
|