@geastack/geatsc-plugin-gea 0.1.6 → 0.1.8
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/analyze-alpha.d.ts +5 -0
- package/dist/analyze-alpha.js +76 -0
- package/dist/analyze-classes.d.ts +1 -0
- package/dist/analyze-classes.js +157 -0
- package/dist/analyze-css-ranges.d.ts +4 -0
- package/dist/analyze-css-ranges.js +115 -0
- package/dist/analyze-css.d.ts +8 -0
- package/dist/analyze-css.js +205 -0
- package/dist/analyze-literals.d.ts +2 -0
- package/dist/analyze-literals.js +267 -0
- package/dist/analyze-nodes.d.ts +4 -0
- package/dist/analyze-nodes.js +68 -0
- package/dist/analyze-renderer.d.ts +23 -0
- package/dist/analyze-renderer.js +403 -0
- package/dist/analyze.js +96 -16
- package/dist/cpp-mounted-lowering.js +24 -6
- package/dist/cpp-template-renderer.js +21 -7
- package/dist/host-shims.js +17 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +43 -16
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { attributeLines, attributeSlotLines, childForMount, constantExpression, eventSetupLines, fieldNameForSlot, imageSrcAssetIdExpression, lowerRowSlots, isRootSetupSlot, mountSlotStyleSlot, mountSlotTag, objectArrayConstant, rootSetupLines, slotAttrName, storeFieldLocalName, } from './cpp-mounted-lowering.js';
|
|
2
|
-
import { cppString, isPxLengthStylePropertyName, isRuntimeNumericConstantIdentifier, nativeStyleColorExpression, opaqueCssHexColor, sanitizeCppIdentifier, styleDeclarationEnumForPropertyName, styleKeywordPropertiesForPropertyName, styleKeywordPropertyValuesForPropertyName, styleOpaqueColorTargetForPropertyName, stylePercentPropertyEnumForPropertyName, styleRawNumberPropertyEnumsForPropertyName, } from './utils.js';
|
|
2
|
+
import { cppString, isPxLengthStylePropertyName, isBorderWidthStylePropertyName, isRuntimeNumericConstantIdentifier, nativeStyleColorExpression, opaqueCssHexColor, sanitizeCppIdentifier, styleDeclarationEnumForPropertyName, styleKeywordPropertiesForPropertyName, styleKeywordPropertyValuesForPropertyName, styleOpaqueColorTargetForPropertyName, stylePercentPropertyEnumForPropertyName, styleRawNumberPropertyEnumsForPropertyName, } from './utils.js';
|
|
3
3
|
import { BoxedStoreFieldAccess } from './cpp-field-access.js';
|
|
4
4
|
import { arrayRevFieldName, reactiveArrayFieldInfo } from './cpp-reactive-component.js';
|
|
5
5
|
import { storeHubEmissionEnabled } from './cpp-store-hub.js';
|
|
@@ -1581,7 +1581,7 @@ function lowerRowPxLengthStyleExpr(expr, propertyName, itemParam, indexParam, it
|
|
|
1581
1581
|
if (parts[0].kind !== 'expr' || parts[1].kind !== 'text' || parts[1].value !== 'px')
|
|
1582
1582
|
return null;
|
|
1583
1583
|
const lowered = lowerRowExpr(parts[0].value, itemParam, indexParam, itemKind, constants);
|
|
1584
|
-
return lowered ? { cpp: rowExprAsNumber(lowered), kind: 'number' } : null;
|
|
1584
|
+
return lowered ? { cpp: rowExprAsNumber(lowered), kind: 'number', styleUnit: 'px' } : null;
|
|
1585
1585
|
}
|
|
1586
1586
|
function lowerRowPercentLengthStyleExpr(expr, propertyName, itemParam, indexParam, itemKind, constants = new Map()) {
|
|
1587
1587
|
if (!expr || !stylePercentPropertyEnumForPropertyName(propertyName))
|
|
@@ -2125,7 +2125,7 @@ function lowerPxLengthStyleValue(expr, propertyName, storeFields, constants, pro
|
|
|
2125
2125
|
const value = lowerTemplateExpression(parts[0].value, storeFields, constants, propBindings);
|
|
2126
2126
|
if (!value)
|
|
2127
2127
|
return null;
|
|
2128
|
-
return mergeLowered('number', loweredAsKind(value, 'number'), [value]);
|
|
2128
|
+
return { ...mergeLowered('number', loweredAsKind(value, 'number'), [value]), styleUnit: 'px' };
|
|
2129
2129
|
}
|
|
2130
2130
|
function lowerPercentLengthStyleValue(expr, propertyName, storeFields, constants, propBindings) {
|
|
2131
2131
|
if (!expr || !stylePercentPropertyEnumForPropertyName(propertyName))
|
|
@@ -2221,6 +2221,10 @@ function rotateDegreesTemplateExpression(parts, propertyName) {
|
|
|
2221
2221
|
return null;
|
|
2222
2222
|
}
|
|
2223
2223
|
function directNumberStyleApplyLine(node, propertyName, value) {
|
|
2224
|
+
if (isBorderWidthStylePropertyName(propertyName)) {
|
|
2225
|
+
const declaration = styleDeclarationEnumForPropertyName(propertyName);
|
|
2226
|
+
return `gea::embedded::ui::StyleSheet::instance().applyNumberProperty(${node}, gea::embedded::ui::StyleDeclaration::${declaration}, static_cast<double>(${value}));`;
|
|
2227
|
+
}
|
|
2224
2228
|
const rawNumber = rawNumberExpression(value);
|
|
2225
2229
|
const properties = styleRawNumberPropertyEnumsForPropertyName(propertyName);
|
|
2226
2230
|
if (properties) {
|
|
@@ -2236,8 +2240,10 @@ function directNumberStyleApplyLine(node, propertyName, value) {
|
|
|
2236
2240
|
if (propertyName === 'translate-y')
|
|
2237
2241
|
return `${node}.style().translateY(${rawNumber});`;
|
|
2238
2242
|
if (propertyName === 'scale')
|
|
2239
|
-
return `${node}.style().
|
|
2240
|
-
if (propertyName === '
|
|
2243
|
+
return `${node}.style().cssScale(static_cast<double>(${value}));`;
|
|
2244
|
+
if (propertyName === 'rotate')
|
|
2245
|
+
return `${node}.style().cssRotateDegrees(static_cast<double>(${value}));`;
|
|
2246
|
+
if (propertyName === 'transform')
|
|
2241
2247
|
return `${node}.style().rotateDegrees(static_cast<double>(${value}));`;
|
|
2242
2248
|
return null;
|
|
2243
2249
|
}
|
|
@@ -2248,6 +2254,12 @@ function opacityNumberExpression(value) {
|
|
|
2248
2254
|
return `([](double __v) -> int { if (!std::isfinite(__v)) return 0; if (__v <= 1.0) __v *= 255.0; if (__v < 0.0) __v = 0.0; if (__v > 255.0) __v = 255.0; return static_cast<int>(__v + 0.5); })(static_cast<double>(${value}))`;
|
|
2249
2255
|
}
|
|
2250
2256
|
function styleNumberApplyLine(node, propertyName, value, styleUnit) {
|
|
2257
|
+
if (styleUnit === 'px') {
|
|
2258
|
+
const declaration = styleDeclarationEnumForPropertyName(propertyName);
|
|
2259
|
+
return declaration
|
|
2260
|
+
? `gea::embedded::ui::StyleSheet::instance().applyPixelLengthProperty(${node}, gea::embedded::ui::StyleDeclaration::${declaration}, static_cast<double>(${value}));`
|
|
2261
|
+
: directNumberStyleApplyLine(node, propertyName, `(${value}) * gea::embedded::ui::devicePixelRatio()`);
|
|
2262
|
+
}
|
|
2251
2263
|
if (styleUnit === 'percent')
|
|
2252
2264
|
return directPercentStyleApplyLine(node, propertyName, value);
|
|
2253
2265
|
if (styleUnit === 'color')
|
|
@@ -2299,8 +2311,10 @@ function keywordCommonValue(entries) {
|
|
|
2299
2311
|
}
|
|
2300
2312
|
function directColorStyleApplyLine(node, propertyName, value) {
|
|
2301
2313
|
const target = styleOpaqueColorTargetForPropertyName(propertyName);
|
|
2302
|
-
if (target === 'background')
|
|
2303
|
-
|
|
2314
|
+
if (target === 'background') {
|
|
2315
|
+
const resetImage = propertyName === 'background' ? `${node}.style().set(gea::embedded::ui::Property::BackgroundImage, -1); ${node}.style().set(gea::embedded::ui::Property::BackgroundClip, 0); ` : '';
|
|
2316
|
+
return `${resetImage}${node}.style().backgroundColor(static_cast<int>(${value}));`;
|
|
2317
|
+
}
|
|
2304
2318
|
if (target === 'color')
|
|
2305
2319
|
return `${node}.style().color(static_cast<int>(${value}));`;
|
|
2306
2320
|
if (target === 'active-background') {
|
package/dist/host-shims.js
CHANGED
|
@@ -28,6 +28,9 @@ const NODE_HANDLE_RECEIVER_TYPES = [
|
|
|
28
28
|
// `NODE_HANDLE_RECEIVER_TYPES` above states.
|
|
29
29
|
const EVENT_RECEIVER_TYPES = [
|
|
30
30
|
"gea::framework::events::PointerEvent",
|
|
31
|
+
// The base interface every event extends, and the parameter `onScroll` and
|
|
32
|
+
// `EventTarget.addEventListener(type, listener)` declare.
|
|
33
|
+
"Event",
|
|
31
34
|
"PointerEvent",
|
|
32
35
|
"TouchEvent",
|
|
33
36
|
"RotaryEvent",
|
|
@@ -300,6 +303,11 @@ export function createGeaHostShims() {
|
|
|
300
303
|
PointerEvent: "gea::framework::events::PointerEvent",
|
|
301
304
|
TouchEvent: "gea::framework::events::PointerEvent",
|
|
302
305
|
RotaryEvent: "gea::framework::events::PointerEvent",
|
|
306
|
+
// The base interface, for `onScroll={e => ...}` and any listener typed by
|
|
307
|
+
// `EventTarget.addEventListener`. Without it `e` lowered to a synthesized
|
|
308
|
+
// record the listener adapter cannot build from `PointerEvent&`, so the
|
|
309
|
+
// app aborted on the first scroll.
|
|
310
|
+
Event: "gea::framework::events::PointerEvent",
|
|
303
311
|
TouchPoint: "gea::framework::events::TouchPoint",
|
|
304
312
|
// The text-input half of the same join. `onInput={e => ...}` /
|
|
305
313
|
// `onKeyDown={e => ...}` declare `InputEvent` / `KeyEvent` (index.d.ts),
|
|
@@ -1580,6 +1588,15 @@ export function createGeaHostShims() {
|
|
|
1580
1588
|
// member spellings, so emission refused `TouchEvent.clientX` by name --
|
|
1581
1589
|
// the fail-closed guard reporting, correctly, that this table was the
|
|
1582
1590
|
// thing missing.
|
|
1591
|
+
// `Event.type`: the engine keeps the kind as an enum and names it with
|
|
1592
|
+
// `typeName()` (events.cpp), the same string a listener was bound for.
|
|
1593
|
+
type: [
|
|
1594
|
+
{
|
|
1595
|
+
emit: "std::string(({receiver}).typeName())",
|
|
1596
|
+
returnType: "std::string",
|
|
1597
|
+
receiverTypes: EVENT_RECEIVER_TYPES,
|
|
1598
|
+
},
|
|
1599
|
+
],
|
|
1583
1600
|
pointerId: [
|
|
1584
1601
|
{
|
|
1585
1602
|
emit: "static_cast<double>(({receiver}).pointerId)",
|
package/dist/utils.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare function isRecord(value: unknown): value is Record<string, unknow
|
|
|
4
4
|
export declare function cppString(value: string): string;
|
|
5
5
|
export declare function cssPropertyName(value: string): string;
|
|
6
6
|
export declare function styleDeclarationEnumForPropertyName(propertyName: string): string | null;
|
|
7
|
+
export declare function isBorderWidthStylePropertyName(propertyName: string): boolean;
|
|
7
8
|
export declare function isPxLengthStylePropertyName(propertyName: string): boolean;
|
|
8
9
|
export declare function stylePercentPropertyEnumForPropertyName(propertyName: string): string | null;
|
|
9
10
|
export declare function styleRawNumberPropertyEnumsForPropertyName(propertyName: string): string[] | null;
|
package/dist/utils.js
CHANGED
|
@@ -18,6 +18,9 @@ export function styleDeclarationEnumForPropertyName(propertyName) {
|
|
|
18
18
|
return null;
|
|
19
19
|
return STYLE_DECLARATION_ENUM_BY_PROPERTY.get(propertyName) ?? null;
|
|
20
20
|
}
|
|
21
|
+
export function isBorderWidthStylePropertyName(propertyName) {
|
|
22
|
+
return /^border-(?:(?:top|right|bottom|left)-)?width$/.test(propertyName);
|
|
23
|
+
}
|
|
21
24
|
export function isPxLengthStylePropertyName(propertyName) {
|
|
22
25
|
return PX_LENGTH_STYLE_PROPERTIES.has(propertyName);
|
|
23
26
|
}
|
|
@@ -38,21 +41,20 @@ export function styleKeywordPropertyValuesForPropertyName(propertyName, rawValue
|
|
|
38
41
|
if (propertyName === 'justify-content')
|
|
39
42
|
return keywordValue('JustifyContent', FLEX_ALIGN_KEYWORDS, value);
|
|
40
43
|
if (propertyName === 'align-items')
|
|
41
|
-
return keywordValue('AlignItems',
|
|
44
|
+
return keywordValue('AlignItems', SELF_ALIGN_KEYWORDS, value);
|
|
42
45
|
if (propertyName === 'justify-items')
|
|
43
|
-
return keywordValue('JustifyItems',
|
|
46
|
+
return keywordValue('JustifyItems', SELF_ALIGN_KEYWORDS, value);
|
|
44
47
|
if (propertyName === 'align-content')
|
|
45
48
|
return keywordValue('AlignContent', FLEX_ALIGN_KEYWORDS, value);
|
|
46
49
|
if (propertyName === 'align-self')
|
|
47
50
|
return keywordValue('AlignSelf', ALIGN_SELF_KEYWORDS, value);
|
|
48
51
|
if (propertyName === 'place-items') {
|
|
49
|
-
const align =
|
|
52
|
+
const align = SELF_ALIGN_KEYWORDS.get(value);
|
|
50
53
|
return align === undefined
|
|
51
54
|
? null
|
|
52
55
|
: [
|
|
53
56
|
{ property: 'AlignItems', value: align },
|
|
54
57
|
{ property: 'JustifyItems', value: align },
|
|
55
|
-
{ property: 'JustifyContent', value: align },
|
|
56
58
|
];
|
|
57
59
|
}
|
|
58
60
|
if (propertyName === 'position')
|
|
@@ -127,9 +129,20 @@ function keywordValue(property, map, value) {
|
|
|
127
129
|
}
|
|
128
130
|
const STYLE_DECLARATION_ENUM_BY_PROPERTY = new Map([
|
|
129
131
|
['color-scheme', 'Ignored'],
|
|
130
|
-
['background-position', '
|
|
131
|
-
['
|
|
132
|
-
['
|
|
132
|
+
['background-position', 'BackgroundPosition'],
|
|
133
|
+
['background-repeat', 'BackgroundRepeat'],
|
|
134
|
+
['background-attachment', 'BackgroundAttachment'],
|
|
135
|
+
['background-origin', 'BackgroundOrigin'],
|
|
136
|
+
['box-sizing', 'BoxSizing'],
|
|
137
|
+
['float', 'Float'],
|
|
138
|
+
['clear', 'Clear'],
|
|
139
|
+
['margin-trim', 'MarginTrim'],
|
|
140
|
+
['writing-mode', 'WritingMode'],
|
|
141
|
+
['direction', 'Direction'],
|
|
142
|
+
['flex-flow', 'FlexFlow'],
|
|
143
|
+
['row-gap', 'RowGap'],
|
|
144
|
+
['column-gap', 'ColumnGap'],
|
|
145
|
+
['font', 'Font'],
|
|
133
146
|
['grid-column', 'Ignored'],
|
|
134
147
|
['isolation', 'Ignored'],
|
|
135
148
|
['letter-spacing', 'Ignored'],
|
|
@@ -147,12 +160,15 @@ const STYLE_DECLARATION_ENUM_BY_PROPERTY = new Map([
|
|
|
147
160
|
['display', 'Display'],
|
|
148
161
|
['flex-direction', 'FlexDirection'],
|
|
149
162
|
['flex-wrap', 'FlexWrap'],
|
|
163
|
+
['order', 'Order'],
|
|
150
164
|
['justify-content', 'JustifyContent'],
|
|
151
165
|
['align-items', 'AlignItems'],
|
|
152
166
|
['justify-items', 'JustifyItems'],
|
|
153
167
|
['align-content', 'AlignContent'],
|
|
154
168
|
['align-self', 'AlignSelf'],
|
|
155
169
|
['place-items', 'PlaceItems'],
|
|
170
|
+
['place-content', 'PlaceContent'],
|
|
171
|
+
['place-self', 'PlaceSelf'],
|
|
156
172
|
['grid-template-columns', 'GridTemplateColumns'],
|
|
157
173
|
['grid-template-rows', 'GridTemplateRows'],
|
|
158
174
|
['content', 'Content'],
|
|
@@ -186,9 +202,11 @@ const STYLE_DECLARATION_ENUM_BY_PROPERTY = new Map([
|
|
|
186
202
|
['z-index', 'ZIndex'],
|
|
187
203
|
['active-background-color', 'ActiveBackgroundColor'],
|
|
188
204
|
['active-background', 'ActiveBackgroundColor'],
|
|
189
|
-
['background-color', '
|
|
205
|
+
['background-color', 'BackgroundColor'],
|
|
190
206
|
['background', 'Background'],
|
|
191
|
-
['background-image', '
|
|
207
|
+
['background-image', 'BackgroundImage'],
|
|
208
|
+
['background-clip', 'BackgroundClip'],
|
|
209
|
+
['contain', 'Contain'],
|
|
192
210
|
['background-size', 'BackgroundSize'],
|
|
193
211
|
['color', 'Color'],
|
|
194
212
|
['opacity', 'Opacity'],
|
|
@@ -328,7 +346,7 @@ const STYLE_KEYWORD_PROPERTIES_BY_PROPERTY = new Map([
|
|
|
328
346
|
['justify-items', ['JustifyItems']],
|
|
329
347
|
['align-content', ['AlignContent']],
|
|
330
348
|
['align-self', ['AlignSelf']],
|
|
331
|
-
['place-items', ['AlignItems', 'JustifyItems'
|
|
349
|
+
['place-items', ['AlignItems', 'JustifyItems']],
|
|
332
350
|
['position', ['Position']],
|
|
333
351
|
['text-align', ['TextAlign']],
|
|
334
352
|
['white-space', ['WhiteSpace']],
|
|
@@ -353,24 +371,31 @@ const DISPLAY_KEYWORDS = new Map([
|
|
|
353
371
|
const FLEX_DIRECTION_KEYWORDS = new Map([
|
|
354
372
|
['column', 0],
|
|
355
373
|
['row', 1],
|
|
374
|
+
['column-reverse', 2],
|
|
375
|
+
['row-reverse', 3],
|
|
356
376
|
]);
|
|
357
377
|
const FLEX_WRAP_KEYWORDS = new Map([
|
|
358
378
|
['nowrap', 0],
|
|
359
379
|
['wrap', 1],
|
|
380
|
+
['wrap-reverse', 2],
|
|
360
381
|
]);
|
|
361
382
|
const FLEX_ALIGN_KEYWORDS = new Map([
|
|
362
|
-
['
|
|
363
|
-
['
|
|
383
|
+
['stretch', 0],
|
|
384
|
+
['normal', 0],
|
|
385
|
+
['flex-start', 6],
|
|
386
|
+
['start', 7],
|
|
364
387
|
['center', 1],
|
|
365
388
|
['flex-end', 2],
|
|
366
|
-
['end',
|
|
389
|
+
['end', 8],
|
|
367
390
|
['space-between', 3],
|
|
368
391
|
['space-around', 4],
|
|
392
|
+
['space-evenly', 14],
|
|
369
393
|
['baseline', 5],
|
|
370
394
|
]);
|
|
395
|
+
const SELF_ALIGN_KEYWORDS = new Map([...FLEX_ALIGN_KEYWORDS].filter(([key]) => !key.startsWith('space-')));
|
|
371
396
|
const ALIGN_SELF_KEYWORDS = new Map([
|
|
372
397
|
['auto', -1],
|
|
373
|
-
...
|
|
398
|
+
...SELF_ALIGN_KEYWORDS,
|
|
374
399
|
]);
|
|
375
400
|
const POSITION_KEYWORDS = new Map([
|
|
376
401
|
['static', 0],
|
|
@@ -386,9 +411,11 @@ const TEXT_ALIGN_KEYWORDS = new Map([
|
|
|
386
411
|
]);
|
|
387
412
|
const WHITE_SPACE_KEYWORDS = new Map([
|
|
388
413
|
['normal', 0],
|
|
389
|
-
['pre-line', 0],
|
|
390
414
|
['nowrap', 1],
|
|
391
|
-
['pre',
|
|
415
|
+
['pre', 2],
|
|
416
|
+
['pre-wrap', 3],
|
|
417
|
+
['pre-line', 4],
|
|
418
|
+
['break-spaces', 5],
|
|
392
419
|
]);
|
|
393
420
|
const TEXT_OVERFLOW_KEYWORDS = new Map([
|
|
394
421
|
['clip', 0],
|