xbintsc 0.6.8 → 0.6.10

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.
Files changed (71) hide show
  1. package/dist/src/cli/help.d.ts +1 -1
  2. package/dist/src/cli/main.js +1 -0
  3. package/dist/src/cli/main.js.map +1 -1
  4. package/dist/src/driver/config.js +1 -0
  5. package/dist/src/driver/config.js.map +1 -1
  6. package/dist/src/driver/toolchain.d.ts +10 -0
  7. package/dist/src/driver/toolchain.js +69 -8
  8. package/dist/src/driver/toolchain.js.map +1 -1
  9. package/dist/src/driver/version.d.ts +1 -1
  10. package/dist/src/driver/version.js +1 -1
  11. package/dist/src/driver/version.js.map +1 -1
  12. package/dist/tests/driver/config.test.js +15 -2
  13. package/dist/tests/driver/config.test.js.map +1 -1
  14. package/dist/tests/driver/toolchain.test.js +23 -2
  15. package/dist/tests/driver/toolchain.test.js.map +1 -1
  16. package/dist/tests/e2e/gui-helpers.d.ts +2 -0
  17. package/dist/tests/e2e/gui-helpers.js +1 -0
  18. package/dist/tests/e2e/gui-helpers.js.map +1 -1
  19. package/dist/tests/e2e/gui-layout.test.js +47 -0
  20. package/dist/tests/e2e/gui-layout.test.js.map +1 -1
  21. package/dist/tests/e2e/gui-paint.test.js +108 -0
  22. package/dist/tests/e2e/gui-paint.test.js.map +1 -1
  23. package/dist/tests/e2e/gui-unsupported.test.d.ts +6 -0
  24. package/dist/tests/e2e/gui-unsupported.test.js +123 -0
  25. package/dist/tests/e2e/gui-unsupported.test.js.map +1 -0
  26. package/doc/ai/extensions.md +7 -4
  27. package/doc/ai/zh-CN/extensions.md +6 -3
  28. package/doc/gui/dom.md +69 -1
  29. package/doc/gui/known-issues.md +12 -5
  30. package/doc/gui/layout.md +19 -6
  31. package/doc/gui/rendering.md +16 -9
  32. package/doc/requirements.md +5 -3
  33. package/doc/zh-CN/gui/dom.md +61 -1
  34. package/doc/zh-CN/gui/known-issues.md +11 -4
  35. package/doc/zh-CN/gui/layout.md +14 -4
  36. package/doc/zh-CN/gui/rendering.md +13 -10
  37. package/doc/zh-CN/requirements.md +5 -2
  38. package/package.json +7 -7
  39. package/runtime/ext_gui/clip_values.cpp +11 -0
  40. package/runtime/ext_gui/css.cpp +27 -2
  41. package/runtime/ext_gui/css_selector.cpp +23 -0
  42. package/runtime/ext_gui/css_sheet.cpp +7 -0
  43. package/runtime/ext_gui/document.cpp +3 -0
  44. package/runtime/ext_gui/document_animation.cpp +4 -1
  45. package/runtime/ext_gui/dom_api.cpp +3 -0
  46. package/runtime/ext_gui/dom_parse.cpp +4 -0
  47. package/runtime/ext_gui/effect_values.cpp +28 -7
  48. package/runtime/ext_gui/gradient_values.cpp +25 -5
  49. package/runtime/ext_gui/inline_svg.cpp +3 -0
  50. package/runtime/ext_gui/layout_flow.cpp +12 -2
  51. package/runtime/ext_gui/layout_inline.cpp +80 -7
  52. package/runtime/ext_gui/media_query.cpp +7 -1
  53. package/runtime/ext_gui/paint.cpp +58 -23
  54. package/runtime/ext_gui/paint.h +7 -4
  55. package/runtime/ext_gui/paint_clip.cpp +74 -19
  56. package/runtime/ext_gui/paint_internal.h +7 -1
  57. package/runtime/ext_gui/renderer_clip.cpp +19 -17
  58. package/runtime/ext_gui/style.cpp +5 -1
  59. package/runtime/ext_gui/style.h +5 -0
  60. package/runtime/ext_gui/style_cascade.cpp +2 -0
  61. package/runtime/ext_gui/style_internal.h +7 -2
  62. package/runtime/ext_gui/style_print.cpp +3 -0
  63. package/runtime/ext_gui/style_text.cpp +11 -0
  64. package/runtime/ext_gui/style_values.cpp +89 -90
  65. package/runtime/ext_gui/transform.cpp +2 -0
  66. package/runtime/ext_gui/warnings.cpp +300 -0
  67. package/runtime/ext_gui/warnings.h +59 -0
  68. package/src/cli/main.ts +1 -0
  69. package/src/driver/config.ts +1 -0
  70. package/src/driver/toolchain.ts +79 -8
  71. package/src/driver/version.ts +1 -1
@@ -27,7 +27,9 @@ doctype 跳过,实体解码(命名 + 十进制/十六进制),空元素
27
27
  颜色(十六进制、`rgb()`/`rgba()`、一个命名子集)、数字、关键字与简写
28
28
  (`margin`/`padding`/`border`/`flex`/`font`/`outline`)。
29
29
  `display: inline-flex`/`inline-grid` 生成行内级 flex/grid 容器;`grid-area`、
30
- `aspect-ratio`、`letter-spacing`、`text-transform`、`writing-mode`
30
+ `aspect-ratio`、`letter-spacing`、`text-transform`、`text-overflow`
31
+ (`clip`/`ellipsis`)、`white-space`
32
+ (`normal`/`nowrap`/`pre`/`pre-wrap`/`pre-line`)、`writing-mode`
31
33
  (`vertical-rl`/`vertical-lr` 文本)、`vertical-align`(长度形式)、百分比
32
34
  `border-radius`、`background-size`(`url()` 图层按尺寸与默认 repeat 平铺)与
33
35
  `currentColor` 都已支持。`font-variant-numeric`、`text-wrap`、`text-rendering`、
@@ -61,6 +63,64 @@ doctype 跳过,实体解码(命名 + 十进制/十六进制),空元素
61
63
  之前/之后;遍历、查询、`innerHTML` 与 `elementIndex()` 永远看不到它,命中测试
62
64
  则指向原始元素。
63
65
 
66
+ ### 不支持的特性会给出提示
67
+
68
+ 上面的子集是一条边界,但不是一条静默的边界。文档其余部分仍然会渲染——不支持的
69
+ 元素会变成普通盒子(`<template>` 这类标签则保持隐藏),不支持的声明会被丢弃——
70
+ 但每个名字的第一次使用会输出到 stderr:
71
+
72
+ ```text
73
+ xt_gui: warning: unsupported element <table>; the engine has no browser behaviour for it
74
+ xt_gui: warning: unsupported CSS property 'gap'; it is ignored
75
+ xt_gui: warning: unsupported at-rule '@supports'; its rule is ignored
76
+ xt_gui: warning: unsupported pseudo-class ':has'; it never matches
77
+ xt_gui: warning: unsupported CSS unit 'vmin'; the value is ignored
78
+ ```
79
+
80
+ 报告按名字在整个进程内去重:一个被多条规则使用的属性,或每行重复出现的表格
81
+ 单元格,只会出现一次。解析/层叠路径会报告:
82
+
83
+ - **HTML 元素**:引擎缺少其浏览器行为的标签——`applet`、`area`、`basefont`、
84
+ `bgsound`、`blink`、`caption`、`col`、`colgroup`、`datalist`、`details`、
85
+ `dialog`、`embed`、`frame`、`frameset`、`iframe`、`input`、`isindex`、
86
+ `keygen`、`map`、`marquee`、`math`、`meter`、`noembed`、`noframes`、
87
+ `object`、`optgroup`、`option`、`output`、`param`、`plaintext`、`progress`、
88
+ `select`、`summary`、`table`、`tbody`、`td`、`template`、`textarea`、`tfoot`、
89
+ `th`、`thead`、`tr`、`track` 与 `xmp`。其余标签——包括 `button`、`label`、
90
+ 自定义元素以及 `<dvi>` 这类拼写错误——都会渲染成普通盒子,这是预期的回退而
91
+ 不是被丢弃的特性,因此不会报告。
92
+ - **HTML 特性(attribute)**:请求了不支持行为的 `href`(链接不会导航)、
93
+ `srcset`、`sizes`、`poster`、`controls`、`contenteditable`、`draggable`、
94
+ `autofocus`、`tabindex`、`hidden`,以及 SVG 的
95
+ `filter`/`mask`/`clip-path`/`marker-*` 特性。
96
+ - **CSS 属性**:子集之外的属性名;以及解析器未实现的长度单位(`ch`、`ex`、
97
+ `vmin`、`dvh` 等)。已支持属性上的非法值不会按“不支持”报告——只检查属性的
98
+ *名字*。
99
+ - **CSS at-rule**:`@media`、`@font-face`、`@keyframes`(含厂商前缀拼写)之外的
100
+ at-rule,例如 `@supports`、`@layer`、`@container`、`@import`。
101
+ - **`@font-face` 描述符**:`font-family`、`src`、`font-weight`、`font-style`
102
+ 之外的描述符(`font-display`、`unicode-range` 等)。
103
+ - **选择器**:不支持的伪类(`:has`、`:is`、`:where`、`:nth-of-type` 等)、
104
+ 不支持的伪元素(`::selection`、`::marker` 等),以及解析器不得不丢弃的
105
+ 选择器。
106
+ - **媒体查询**:未知特性(`min-resolution`、`aspect-ratio` 等)会按不匹配处理并
107
+ 报告。
108
+ - **CSS 函数**:已支持属性里出现引擎未实现的函数——`hsl()`/`oklch()` 等颜色、
109
+ `perspective()`/`rotateX()` 等变换、`url()` 滤镜、`path()` 裁剪形状、
110
+ `conic-gradient()` 背景、`counter()` 生成内容。不支持的函数会使整条声明失效。
111
+ - **SVG 元素**:NanoSVG 不渲染的 `<text>`、`<use>`、`<filter>` 及其 `fe*`
112
+ 原语、`<mask>`、`<clipPath>`、`<pattern>`、`<marker>`、`<image>`、
113
+ `<foreignObject>` 与动画元素。内联 `<svg>` 在序列化用于绘制时报告;
114
+ `<img src="…svg">` 文件直接交给 NanoSVG,不经过这项检查。
115
+
116
+ `XT_GUI_NO_WARNINGS=1` 可以关闭这些报告。在 Windows 上,GUI 程序是
117
+ Windows 子系统可执行文件,只有设置 `app.console: true` 时才能看到 stderr
118
+ (见 [API](./api.md))。这些警告不影响退出状态。
119
+
120
+ 这是解析/层叠路径的审计,不是完整 API 审计:已支持属性上的不支持*值*
121
+ (例如 `display: contents`)、有意空实现的 DOM 方法和后端未实现的 WebGL 入口
122
+ 仍然保持静默(Canvas 与 WebGL 页面记录了各自的子集)。
123
+
64
124
  ## 交互式 DOM(M8)
65
125
 
66
126
  `win.document` 返回文档句柄;元素句柄具有稳定标识,并提供可读写的属性、
@@ -48,15 +48,21 @@
48
48
  `tests/e2e/gui-example-browser.test.ts` 中。
49
49
  - **`display: none -> flex` 的重排。** 通过类名切换让隐藏元素显示在 flex 容器上时,也曾观察
50
50
  到同样的崩溃;`examples/gui/pelican-bike` 改用 `opacity` 显示游戏结束遮罩。
51
- - **CSS 覆盖范围是有意为之的子集。** 已实现 Grid、`calc()`(含嵌套算术及
51
+ - **CSS 覆盖范围是有意为之的子集。** 不支持的属性名、at-rule、选择器、函数、
52
+ 单位、特性(attribute)以及
53
+ [DOM](./dom.md#不支持的特性会给出提示) 中列出的元素,会在 stderr 上报告一次,
54
+ 而不是被静默丢弃,因此从 Web 移植的页面能看出回退掉了什么。已实现
55
+ Grid、`calc()`(含嵌套算术及
52
56
  `min()`/`max()`/`clamp()` 内的 `calc()`)、`clamp()`/`min()`/`max()`/`env()`、
53
57
  `var()` 自定义属性、`inset` 简写、`box-sizing`、`visibility`/`pointer-events`、
54
58
  `@media` 查询、生成内容(`::before`/`::after`)、线性/径向多层背景、
55
59
  `text-shadow`(真正的高斯)、`box-shadow`(外阴影/内阴影、spread、多层)、
56
60
  `clip-path`(`inset`/`circle`/`ellipse`/`polygon`)、`filter` 颜色函数、
57
61
  `@keyframes` 动画、完整的 `transition` 时间函数、`letter-spacing`、
58
- `text-transform`、行内级 `flex`/`grid`、`grid-area`、`aspect-ratio`、自动
59
- 外边距、百分比 `border-radius`、`outline`、`url()` 图层的 `background-size`
62
+ `text-transform`、`white-space: nowrap`、`text-overflow: ellipsis`、行内级
63
+ `flex`/`grid`、`grid-area`、`aspect-ratio`、自动
64
+ 外边距、百分比 `border-radius`(含对子元素与替换内容的圆角 `overflow` 裁剪)、
65
+ `outline`、`url()` 图层的 `background-size`
60
66
  平铺,以及 SVG 子元素上的文档 CSS(`fill`/`stroke`/…)均已实现。仍有限制:
61
67
  `background-clip`、`background-position`、`background-repeat` 未实现
62
68
  (`background-size` 只覆盖默认平铺场景);`font-variant-numeric`、
@@ -67,7 +73,8 @@
67
73
  近似而非真正的组合成;D3D12/DXIL 后端没有混合与 `backdrop-filter` 合成器,
68
74
  那里会退回普通 source-over 绘制并跳过背景滤镜。`filter: blur()` 仍是按图形做
69
75
  九次偏移的近似,而不是真正的组模糊,重叠的子元素会加深;`drop-shadow` 用盒子
70
- 轮廓近似;最多只交叉两层嵌套 `clip-path`(更深时保留外侧两层);
76
+ 轮廓近似;最多只交叉四层裁剪形状(CSS `clip-path` 与圆角 `overflow` 盒一起
77
+ 计算;更深时保留外侧四层);
71
78
  图像/画布除图像着色器能携带的亮度与透明度染色外不做颜色滤镜。Canvas 纹理使用
72
79
  最近邻采样。背景渐变(线性与径向)都逐像素光栅化成纹理,盒子大于纹理时再拉伸
73
80
  (径向每边最大 1024 px;线性沿渐变线最大 4096 px,且沿渐变线之外只有一像素厚),
@@ -10,7 +10,10 @@
10
10
  几何信息的 `LayoutBox` 树:
11
11
 
12
12
  - **块级流** —— 块级子元素垂直堆叠;`display: none`
13
- 不生成盒;`width: auto` 填满包含块,`height: auto` 包裹内容。盒模型
13
+ 不生成盒;`width: auto` 填满包含块,`height: auto` 包裹内容。百分比
14
+ `height` 相对包含块**确定**的内容高度解析(由 `height`/`clamp()` 定尺的
15
+ 框架会把已用高度传给子元素);当整条链上都没有确定高度时,百分比按 `auto`
16
+ 处理。盒模型
14
17
  (margin/padding/border)会被解析,包括相对包含块宽度的百分比。相邻兄弟的
15
18
  垂直外边距会折叠为 `max(正值) + min(负值)`;父元素的下外边距不会与其最后一个
16
19
  子元素折叠(见下方限制)。
@@ -19,7 +22,10 @@
19
22
  的并集;`display: inline-block` 以 shrink-to-fit 宽度原子化布局。每一行会收缩到
20
23
  与之重叠的浮动(`float: left|right`)所留出的空白带,因此后续行会绕开它们。
21
24
  每个文本片段会记住它覆盖的 run,以便绘制时对它整形。文本使用 stb_truetype
22
- 技术栈测量(见[文本技术栈](./rendering.md))。
25
+ 技术栈测量(见[文本技术栈](./rendering.md))。`white-space: nowrap`
26
+ 让一段文本不在空格处换行(源码换行会折叠为空格);在 `overflow` 不是
27
+ `visible` 的盒子上,`text-overflow: ellipsis` 会把溢出线放不下的部分替换为
28
+ 单个 U+2026 省略号并丢弃其余内容。
23
29
  - **Flexbox** —— `row`/`column`(以及 `-reverse` 变体),支持 `gap`、
24
30
  `flex-basis`/`flex-grow`/`flex-shrink`、`justify-content` 与 `align-items`
25
31
  (当交叉轴尺寸确定时包括 `stretch`)。两个方向的主轴尺寸都先取
@@ -78,8 +84,12 @@
78
84
  会把后续块推到相关浮动的下方,而只包含浮动的块会增高以包裹它们。
79
85
  - **`overflow` 裁剪** —— `overflow: hidden`(或 `scroll`/`auto`)的盒子会将其
80
86
  子树裁剪到自身的 padding box,并与任一祖先裁剪区域取交集;渲染器用 GPU
81
- scissor 矩形实现该结果。目前还没有滚动,因此 `scroll`/`auto` 与 `hidden`
82
- 一样只做裁剪。
87
+ scissor 矩形实现该结果。`border-radius` 会让该裁剪变成圆角:padding box
88
+ 成为三角化多边形,加入 `clip-path` 的交集,因此圆形头像框会真正裁掉其中
89
+ 的方形图像,而不只是裁掉其包围盒的四角。同一半径也会裁剪盒子自身的
90
+ background 图像/渐变与替换内容(`<img>`、`<canvas>`、`<video>`、内联
91
+ `<svg>`),所以单独的 `border-radius: 50%` 即使没有 `overflow` 也能把图片
92
+ 变圆。目前还没有滚动,因此 `scroll`/`auto` 与 `hidden` 一样只做裁剪。
83
93
 
84
94
  尚未实现:父/子与空块的外边距折叠、由非空白文本产生的匿名 flex 项、完整的
85
95
  `z-index` 层叠上下文,以及 `float` 对块级子元素的影响(只有行内内容会绕排,
@@ -10,10 +10,11 @@
10
10
  `DisplayList`:一个按画家顺序排列的 `ops` 列表,包含**矩形**(背景与四条实心
11
11
  边框,带 `border-radius`)、**文本 run**(每个携带其文本、颜色与已解析的
12
12
  `FontSpec`)与**图像**,背后由并列的负载数组支撑。每个 op 还携带当前生效的裁剪
13
- 矩形(最近的 `overflow: hidden` 祖先的 padding box)以及最多两个指向显示列表
14
- 三角化 `clip-path` 多边形的下标,因此 `overflow`/`clip-path` 裁剪与 `z-index`
15
- 顺序都能保留到渲染器。`DisplayList::dump()` 为 `paintList()`/`paintCount()`
16
- 提供数据。
13
+ 矩形(最近的 `overflow: hidden` 祖先的 padding box)以及最多四个指向显示列表
14
+ 裁剪多边形的下标——CSS `clip-path` 形状,加上带 `border-radius` 的 `overflow`
15
+ 祖先的圆角 padding box——因此 `overflow`/`clip-path` 裁剪与 `z-index`
16
+ 顺序都能保留到渲染器,圆形头像框也真的是圆的。`DisplayList::dump()` 为
17
+ `paintList()`/`paintCount()` 提供数据。
17
18
 
18
19
  `opacity` 会乘到该盒子及其后代绘制的每个颜色 alpha 上(沿绘制链逐层相乘),
19
20
  因此小数 opacity 以及 CSS 解析器接受的 `opacity` 过渡都能看到效果。这是按图形
@@ -24,7 +25,8 @@
24
25
  `runtime/ext_gui/renderer.{h,cpp}` 把该列表转换为每个窗口的批处理顶点缓冲
25
26
  (图形、字形四边形与图像),并把管线、裁剪与纹理都相同的连续 op 合并为
26
27
  **绘制 run**。每个 run 用各自的 GPU scissor 矩形(按设备像素缩放)绘制,因此
27
- 画家顺序与 `overflow` 裁剪按 op 生效,并通过 SDL_GPU 图形管线完成:
28
+ 画家顺序与 `overflow` 裁剪按 op 生效,并通过 SDL_GPU 图形管线完成;scissor 只是
29
+ 包围矩形,圆角 `overflow` 裁剪与 `clip-path` 形状会切进下面描述的顶点几何:
28
30
 
29
31
  - 共享管线会依据设备支持的着色器格式延迟创建。SDL_GPU 的三个后端各自只接受一种
30
32
  二进制格式,且都不会在运行时编译 GLSL/HLSL,因此引擎三种都随包提供,由
@@ -122,11 +124,12 @@ rgba(…) calc(100% - 1px)` 这样的 1px 分割线要么落在两次采样之
122
124
  显示为 `backdrop …` op。
123
125
 
124
126
  **`clip-path`** 在 `paint_clip.cpp` 中解析为设备空间多边形(每个点都应用盒子的
125
- transform),用耳切法三角化,并存入 `DisplayList::clip_paths`。每个 op 的
126
- `PaintClip` 最多携带两个路径下标;`renderer_clip.cpp` 在上传时把每个凸的图形/
127
- 字形/图像四边形与这些三角形求交。即使 `polygon()` 是凹多边形也正确,无需模板或
128
- shader 改动,但边缘是硬边(没有解析抗锯齿)。支持两层嵌套路径求交;更深时保留
129
- 最外两层。
127
+ transform),用耳切法三角化,并存入 `DisplayList::clip_paths`。圆角 `overflow`
128
+ 裁剪使用同一表示:每个角用短弦近似,因此多边形是凸的,scissor 矩形只是它的
129
+ 包围盒。每个 op 的 `PaintClip` 最多携带四个路径下标;`renderer_clip.cpp` 在上传
130
+ 时把每个凸的图形/字形/图像四边形与这些三角形求交(先按一条路径裁剪,再把得到的
131
+ 每块交给下一条)。即使 `polygon()` 是凹多边形也正确,无需模板或 shader 改动,
132
+ 但边缘是硬边(没有解析抗锯齿)。嵌套超过四层时保留最外四层。
130
133
 
131
134
  **`filter`** 的颜色函数(`brightness`、`contrast`、`grayscale`、`sepia`、
132
135
  `invert`、`saturate`、`hue-rotate`、`opacity`)会折进每个绘制颜色,因此盒子与
@@ -154,8 +154,11 @@ winget install -e --id Microsoft.VisualStudio.2022.BuildTools `
154
154
  --override "--quiet --wait --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Llvm.Clang --includeRecommended"
155
155
  ```
156
156
 
157
- Visual Studio 2022 自带的 LLVM(`VC\Tools\Llvm\x64\bin\clang.exe`,当前版本
158
- 19.1.5)就是 `scripts/setup-vs-toolchain.ps1` 选择的工具链。独立安装的 LLVM
157
+ Visual Studio 自带的 LLVM(`VC\Tools\Llvm\x64\bin\clang.exe`,当前 2022 安装中
158
+ 为 19.1.5)就是 `scripts/setup-vs-toolchain.ps1` 选择的工具链。`xbintsc` 会探测
159
+ 两种安装布局——按年份命名的旧布局(`2019`、`2022`)以及 Visual Studio 2026 及
160
+ 之后按主版本号命名的布局(`18\Community`、`18\Insiders` 等)——因此更新版本的
161
+ 安装无需设置 `xbintsc_CLANG` 也能被发现。独立安装的 LLVM
159
162
  (`winget install -e --id LLVM.LLVM`)对 `xbintsc` 本身也可用,但 GUI/媒体
160
163
  归档构建与 CI 都使用 Visual Studio 这一套,从而让运行时、预编译归档与最终
161
164
  二进制出自同一条工具链。无论哪种,编译器必须以 MSVC ABI 为目标
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xbintsc",
3
- "version": "0.6.8",
3
+ "version": "0.6.10",
4
4
  "description": "xbintsc - a TypeScript binary compiler (TypeScript -> LLVM IR -> native binary)",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -72,12 +72,12 @@
72
72
  "vitest": "^2.1.8"
73
73
  },
74
74
  "optionalDependencies": {
75
- "@xbintsc/linux-x64": "0.6.8",
76
- "@xbintsc/linux-arm64": "0.6.8",
77
- "@xbintsc/darwin-x64": "0.6.8",
78
- "@xbintsc/darwin-arm64": "0.6.8",
79
- "@xbintsc/win32-x64": "0.6.8",
80
- "@xbintsc/win32-arm64": "0.6.8"
75
+ "@xbintsc/linux-x64": "0.6.10",
76
+ "@xbintsc/linux-arm64": "0.6.10",
77
+ "@xbintsc/darwin-x64": "0.6.10",
78
+ "@xbintsc/darwin-arm64": "0.6.10",
79
+ "@xbintsc/win32-x64": "0.6.10",
80
+ "@xbintsc/win32-arm64": "0.6.10"
81
81
  },
82
82
  "engines": {
83
83
  "node": ">=22"
@@ -13,6 +13,7 @@
13
13
  #include "css_internal.h"
14
14
  #include "style_internal.h"
15
15
  #include "style_values_internal.h"
16
+ #include "warnings.h"
16
17
 
17
18
  namespace xtgui {
18
19
 
@@ -219,6 +220,10 @@ bool xt_style_apply_clip_path(XtStyle *style, const std::string &property,
219
220
  return true;
220
221
  }
221
222
  if (text.size() < 8 || text.back() != ')') {
223
+ const size_t open = lower.find('(');
224
+ if (open != std::string::npos) {
225
+ xt_warn_unsupported_function("clip-path", xt_css_trim(lower.substr(0, open)));
226
+ }
222
227
  style->clip_path = spec;
223
228
  return true;
224
229
  }
@@ -239,6 +244,12 @@ bool xt_style_apply_clip_path(XtStyle *style, const std::string &property,
239
244
  return true;
240
245
  }
241
246
  /* `url(#…)`, `path()` and other shapes are not part of the subset. */
247
+ {
248
+ const size_t open = lower.find('(');
249
+ if (open != std::string::npos) {
250
+ xt_warn_unsupported_function("clip-path", xt_css_trim(lower.substr(0, open)));
251
+ }
252
+ }
242
253
  style->clip_path = spec;
243
254
  return true;
244
255
  }
@@ -6,10 +6,13 @@
6
6
 
7
7
  #include "css_internal.h"
8
8
 
9
+ #include "warnings.h"
10
+
9
11
  #include <cmath>
10
12
  #include <cstdlib>
11
13
  #include <cstring>
12
14
  #include <unordered_map>
15
+ #include <unordered_set>
13
16
 
14
17
  namespace xtgui {
15
18
 
@@ -131,7 +134,10 @@ static Length makeScalarLength(double number, const std::string &rawUnit) {
131
134
  else if (unit == "cm") { length.value = (float)number * (96.0f / 2.54f); length.unit = Unit::Px; }
132
135
  else if (unit == "mm") { length.value = (float)number * (96.0f / 25.4f); length.unit = Unit::Px; }
133
136
  else if (unit == "q") { length.value = (float)number * (96.0f / 101.6f); length.unit = Unit::Px; }
134
- else length.unit = Unit::Invalid;
137
+ else {
138
+ length.unit = Unit::Invalid;
139
+ if (!unit.empty()) xt_warn_unsupported_unit(unit);
140
+ }
135
141
  return length;
136
142
  }
137
143
 
@@ -404,7 +410,10 @@ bool parseFunctionColor(const std::string &text, Color *color) {
404
410
  for (size_t i = 0; i < parts.size() && i < 4; i++) {
405
411
  const std::string &part = parts[i];
406
412
  if (i < 3) {
407
- if (name == "hsl" || name == "hsla") return false; // hsl not supported yet
413
+ if (name == "hsl" || name == "hsla") {
414
+ xt_warn_unsupported_function("color", name);
415
+ return false;
416
+ }
408
417
  if (!part.empty() && part.back() == '%') {
409
418
  values[i] = strtof(part.c_str(), nullptr) / 100.0f;
410
419
  } else {
@@ -447,6 +456,14 @@ const std::unordered_map<std::string, unsigned int> &namedColors() {
447
456
 
448
457
  } // namespace
449
458
 
459
+ /** CSS Color 4 functions the engine does not implement (beyond hsl). */
460
+ static bool isUnsupportedColorFunction(const std::string &name) {
461
+ static const std::unordered_set<std::string> names = {
462
+ "color", "color-mix", "hwb", "lab", "lch", "light-dark", "oklab", "oklch",
463
+ };
464
+ return names.count(name) != 0;
465
+ }
466
+
450
467
  Color xt_css_parse_color(const std::string &value) {
451
468
  Color color;
452
469
  std::string text = xt_css_lower(xt_css_trim(value));
@@ -460,6 +477,14 @@ Color xt_css_parse_color(const std::string &value) {
460
477
  parseFunctionColor(text, &color);
461
478
  return color;
462
479
  }
480
+ const size_t open = text.find('(');
481
+ if (open != std::string::npos) {
482
+ const std::string name = xt_css_trim(text.substr(0, open));
483
+ if (isUnsupportedColorFunction(name)) {
484
+ xt_warn_unsupported_function("color", name);
485
+ return color;
486
+ }
487
+ }
463
488
  auto it = namedColors().find(text);
464
489
  if (it != namedColors().end()) {
465
490
  unsigned int rgba = it->second;
@@ -4,10 +4,27 @@
4
4
 
5
5
  #include "css_internal.h"
6
6
 
7
+ #include "warnings.h"
8
+
9
+ #include <string>
10
+ #include <unordered_set>
11
+
7
12
  namespace xtgui {
8
13
 
9
14
  namespace {
10
15
 
16
+ /** Pseudo-classes `css_match.cpp` can evaluate. `:not(...)` and
17
+ * `:nth-child(...)` are stored with their argument text, so the base name is
18
+ * what this set holds. */
19
+ const std::unordered_set<std::string> &supportedPseudoClasses() {
20
+ static const std::unordered_set<std::string> names = {
21
+ "active", "checked", "disabled", "empty", "first-child", "focus",
22
+ "focus-visible", "hover", "last-child", "not", "nth-child", "only-child",
23
+ "root",
24
+ };
25
+ return names;
26
+ }
27
+
11
28
  class SelectorParser {
12
29
  public:
13
30
  explicit SelectorParser(const std::string &text) : text_(text) {}
@@ -43,6 +60,9 @@ class SelectorParser {
43
60
  ComplexSelector selector;
44
61
  if (parseComplex(part, &selector) && !selector.compounds.empty()) {
45
62
  selectors.push_back(std::move(selector));
63
+ } else {
64
+ const std::string trimmed = xt_css_trim(part);
65
+ if (!trimmed.empty()) xt_warn_unsupported_selector(trimmed);
46
66
  }
47
67
  start = i + 1;
48
68
  }
@@ -93,10 +113,12 @@ class SelectorParser {
93
113
  /* `::before`/`::after` are generated-content elements, not states. The
94
114
  * single-colon spellings (`:before`) are the legacy equivalent. */
95
115
  if (pseudoElement || name == "before" || name == "after") {
116
+ if (name != "before" && name != "after") xt_warn_unsupported_pseudo_element(name);
96
117
  compound->pseudo_element = name;
97
118
  any = true;
98
119
  continue;
99
120
  }
121
+ const std::string base = name;
100
122
  if (!pseudoElement && *index < text.size() && text[*index] == '(') {
101
123
  int depth = 0;
102
124
  size_t start = *index;
@@ -113,6 +135,7 @@ class SelectorParser {
113
135
  }
114
136
  name += text.substr(start, *index - start);
115
137
  }
138
+ if (supportedPseudoClasses().count(base) == 0) xt_warn_unsupported_pseudo_class(base);
116
139
  compound->pseudoClasses.push_back(name);
117
140
  any = true;
118
141
  } else if (xt_css_is_ident_start(c)) {
@@ -8,6 +8,8 @@
8
8
 
9
9
  #include "css_internal.h"
10
10
 
11
+ #include "warnings.h"
12
+
11
13
  #include <algorithm>
12
14
  #include <cctype>
13
15
  #include <cstring>
@@ -287,6 +289,8 @@ void parseFontFaceBlock(const std::string &block, StyleSheet *sheet) {
287
289
  rule.has_italic = true;
288
290
  rule.italic = true;
289
291
  }
292
+ } else {
293
+ xt_warn_unsupported_descriptor(declaration.property);
290
294
  }
291
295
  }
292
296
  if (rule.family.empty() || rule.sources.empty()) return;
@@ -308,6 +312,9 @@ void parseRules(const std::string &text, const std::string &media, int *order,
308
312
  (std::isalnum((unsigned char)text[nameEnd]) || text[nameEnd] == '-'))
309
313
  nameEnd++;
310
314
  std::string name = xt_css_lower(text.substr(nameStart, nameEnd - nameStart));
315
+ const bool supported = name == "media" || name == "font-face" ||
316
+ (name.size() >= 9 && name.compare(name.size() - 9, 9, "keyframes") == 0);
317
+ if (!supported) xt_warn_unsupported_at_rule(name);
311
318
  size_t brace = text.find('{', nameEnd);
312
319
  size_t semi = text.find(';', nameEnd);
313
320
  if (brace != std::string::npos && (semi == std::string::npos || brace < semi)) {
@@ -4,6 +4,8 @@
4
4
 
5
5
  #include "document.h"
6
6
 
7
+ #include "warnings.h"
8
+
7
9
  #include <cmath>
8
10
  #include <string>
9
11
  #include <utility>
@@ -184,6 +186,7 @@ std::string XtDocument::toDebugString() const {
184
186
  /* -- DOM mutation --------------------------------------------------------- */
185
187
 
186
188
  Node *XtDocument::createElement(const std::string &tag) {
189
+ xt_warn_unsupported_element(tag);
187
190
  auto node = std::make_unique<Node>(NodeType::Element);
188
191
  node->tag = tag;
189
192
  Node *raw = node.get();
@@ -15,6 +15,7 @@
15
15
  #include <vector>
16
16
 
17
17
  #include "style_internal.h"
18
+ #include "warnings.h"
18
19
 
19
20
  namespace xtgui {
20
21
 
@@ -171,7 +172,9 @@ void applyKeyframeDeclarations(XtStyle *style, const std::vector<Declaration> &d
171
172
  declaration.property[1] == '-')
172
173
  continue;
173
174
  if (declaration.property.compare(0, 9, "animation") == 0) continue;
174
- xt_style_apply_declaration(style, declaration.property, declaration.value, context);
175
+ if (!xt_style_apply_declaration(style, declaration.property, declaration.value, context)) {
176
+ xt_warn_unsupported_property(declaration.property);
177
+ }
175
178
  }
176
179
  }
177
180
 
@@ -21,6 +21,8 @@
21
21
 
22
22
  #include "dom_api_internal.h"
23
23
 
24
+ #include "warnings.h"
25
+
24
26
  #include <cctype>
25
27
  #include <string>
26
28
  #include <vector>
@@ -132,6 +134,7 @@ void remove_attribute_raw(xtgui::Node *node, const std::string &name) {
132
134
 
133
135
  void set_attribute(XtGuiWindow *win, xtgui::Node *node, const std::string &name,
134
136
  const std::string &value) {
137
+ if (node != nullptr) xtgui::xt_warn_unsupported_attribute(node->tag, name);
135
138
  set_attribute_raw(node, name, value);
136
139
  mark_dirty(win);
137
140
  }
@@ -9,6 +9,8 @@
9
9
 
10
10
  #include "dom_internal.h"
11
11
 
12
+ #include "warnings.h"
13
+
12
14
  #include <cstdlib>
13
15
  #include <cstring>
14
16
  #include <string>
@@ -326,8 +328,10 @@ std::unique_ptr<Node> xt_html_parse(const std::string &html) {
326
328
  while (stack.size() > 1 && closesOpenElement(stack.back()->tag, token.name)) {
327
329
  stack.pop_back();
328
330
  }
331
+ xt_warn_unsupported_element(token.name);
329
332
  Node *element = stack.back()->addElement(token.name);
330
333
  element->attrs = std::move(token.attrs);
334
+ for (const Attr &attr : element->attrs) xt_warn_unsupported_attribute(token.name, attr.name);
331
335
  bool isVoid = voidElements().count(token.name) != 0;
332
336
  if (!isVoid && !token.selfClosing) stack.push_back(element);
333
337
  continue;
@@ -14,6 +14,7 @@
14
14
  #include "css_internal.h"
15
15
  #include "style_internal.h"
16
16
  #include "style_values_internal.h"
17
+ #include "warnings.h"
17
18
 
18
19
  namespace xtgui {
19
20
 
@@ -223,7 +224,8 @@ static bool parseShadowLengths(const std::string &value, Length *dx, Length *dy,
223
224
  return true;
224
225
  }
225
226
 
226
- static bool parseFilterList(const std::string &value, std::vector<FilterOp> *out) {
227
+ static bool parseFilterList(const std::string &value, const char *property,
228
+ std::vector<FilterOp> *out) {
227
229
  std::string text = xt_css_trim(value);
228
230
  std::string lower = xt_css_lower(text);
229
231
  if (lower == "none" || text.empty()) {
@@ -260,6 +262,7 @@ static bool parseFilterList(const std::string &value, std::vector<FilterOp> *out
260
262
  i = close + 1;
261
263
 
262
264
  FilterOp op;
265
+ bool knownName = true;
263
266
  bool known = true;
264
267
  if (name == "blur") {
265
268
  op.kind = FilterKind::Blur;
@@ -281,8 +284,12 @@ static bool parseFilterList(const std::string &value, std::vector<FilterOp> *out
281
284
  else if (name == "invert") op.kind = FilterKind::Invert;
282
285
  else if (name == "saturate") op.kind = FilterKind::Saturate;
283
286
  else if (name == "opacity") op.kind = FilterKind::Opacity;
284
- else known = false;
285
- if (known && !parseFilterAmount(args, &op.amount)) known = false;
287
+ else knownName = false;
288
+ if (knownName && !parseFilterAmount(args, &op.amount)) known = false;
289
+ }
290
+ if (!knownName) {
291
+ xt_warn_unsupported_function(property, name);
292
+ continue;
286
293
  }
287
294
  if (known) out->push_back(op);
288
295
  }
@@ -396,10 +403,24 @@ static bool parseAnimationShorthand(const std::string &value, std::vector<Animat
396
403
 
397
404
  bool xt_style_apply_effect(XtStyle *style, const std::string &property,
398
405
  const std::string &value) {
399
- if (property == "filter") return parseFilterList(value, &style->filters);
400
- if (property == "backdrop-filter") return parseFilterList(value, &style->backdrop_filters);
401
- if (property == "text-shadow") return parseTextShadow(value, &style->text_shadow);
402
- if (property == "box-shadow") return parseBoxShadow(value, &style->box_shadow);
406
+ /* A recognised property is "handled" even when the value fails to parse: the
407
+ * caller reports only unknown property names, never invalid values. */
408
+ if (property == "filter") {
409
+ parseFilterList(value, "filter", &style->filters);
410
+ return true;
411
+ }
412
+ if (property == "backdrop-filter") {
413
+ parseFilterList(value, "backdrop-filter", &style->backdrop_filters);
414
+ return true;
415
+ }
416
+ if (property == "text-shadow") {
417
+ parseTextShadow(value, &style->text_shadow);
418
+ return true;
419
+ }
420
+ if (property == "box-shadow") {
421
+ parseBoxShadow(value, &style->box_shadow);
422
+ return true;
423
+ }
403
424
  if (property == "animation") {
404
425
  parseAnimationShorthand(value, &style->animations);
405
426
  return true;
@@ -14,6 +14,7 @@
14
14
 
15
15
  #include "style_internal.h"
16
16
  #include "style_values_internal.h"
17
+ #include "warnings.h"
17
18
 
18
19
  namespace xtgui {
19
20
 
@@ -384,8 +385,22 @@ bool parseRadialGradient(const std::string &body, BackgroundLayer *layer) {
384
385
  return true;
385
386
  }
386
387
 
388
+ /** Image functions a browser accepts but this engine does not paint. */
389
+ bool isUnsupportedImageFunction(const std::string &name) {
390
+ static const char *const names[] = {
391
+ "-webkit-conic-gradient", "-webkit-cross-fade", "-webkit-image-set",
392
+ "conic-gradient", "cross-fade", "element",
393
+ "image", "image-set", "paint",
394
+ "repeating-conic-gradient",
395
+ };
396
+ for (const char *candidate : names) {
397
+ if (name == candidate) return true;
398
+ }
399
+ return false;
400
+ }
401
+
387
402
  /** Parse one layer, appending it when it is a supported gradient or image. */
388
- bool parseLayer(const std::string &part, BackgroundLayer *layer) {
403
+ bool parseLayer(const std::string &part, BackgroundLayer *layer, const char *property) {
389
404
  std::string body;
390
405
  /* The repeating prefix is checked first: a plain substring search for
391
406
  * `linear-gradient(` would also match inside `repeating-linear-gradient(`. */
@@ -410,19 +425,24 @@ bool parseLayer(const std::string &part, BackgroundLayer *layer) {
410
425
  layer->image_src = source;
411
426
  return true;
412
427
  }
428
+ const size_t open = part.find('(');
429
+ if (open != std::string::npos) {
430
+ const std::string name = xt_css_lower(xt_css_trim(part.substr(0, open)));
431
+ if (isUnsupportedImageFunction(name)) xt_warn_unsupported_function(property, name);
432
+ }
413
433
  return false;
414
434
  }
415
435
 
416
436
  /** Parse the layer list. `allowColor` is true for the `background` shorthand. */
417
437
  bool parseLayers(const std::string &value, std::vector<BackgroundLayer> *layers, Color *color,
418
- bool *hasColor, bool allowColor) {
438
+ bool *hasColor, bool allowColor, const char *property) {
419
439
  layers->clear();
420
440
  std::string text = xt_css_trim(value);
421
441
  std::string lower = xt_css_lower(text);
422
442
  if (lower == "none") return true;
423
443
  for (const std::string &part : splitCommas(text)) {
424
444
  BackgroundLayer layer;
425
- if (parseLayer(part, &layer)) {
445
+ if (parseLayer(part, &layer, property)) {
426
446
  layers->push_back(layer);
427
447
  /* `background: linear-gradient(...) #fff` mixes the final colour with the
428
448
  * image layer; the gradient itself is one token, so a colour scan cannot
@@ -460,7 +480,7 @@ void xt_style_apply_background_image(XtStyle *style, const std::string &value) {
460
480
  Color color;
461
481
  bool hasColor = false;
462
482
  std::vector<BackgroundLayer> layers;
463
- parseLayers(value, &layers, &color, &hasColor, false);
483
+ parseLayers(value, &layers, &color, &hasColor, false, "background-image");
464
484
  style->background_layers = std::move(layers);
465
485
  }
466
486
 
@@ -472,7 +492,7 @@ void xt_style_apply_background(XtStyle *style, const std::string &value) {
472
492
  Color color;
473
493
  bool hasColor = false;
474
494
  std::vector<BackgroundLayer> layers;
475
- parseLayers(value, &layers, &color, &hasColor, true);
495
+ parseLayers(value, &layers, &color, &hasColor, true, "background");
476
496
  style->background_layers = std::move(layers);
477
497
  style->background_sizes.clear();
478
498
  if (hasColor) {