xbintsc 0.6.12 → 0.6.17

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 (189) hide show
  1. package/dist/src/ast/expressions.d.ts +6 -0
  2. package/dist/src/checker/type-infer.js +1 -1
  3. package/dist/src/checker/type-infer.js.map +1 -1
  4. package/dist/src/cli/help.d.ts +1 -1
  5. package/dist/src/codegen/generator/calls/literals.js +4 -1
  6. package/dist/src/codegen/generator/calls/literals.js.map +1 -1
  7. package/dist/src/codegen/generator/expressions/assignment.js +3 -1
  8. package/dist/src/codegen/generator/expressions/assignment.js.map +1 -1
  9. package/dist/src/codegen/generator/expressions/operators.js +2 -6
  10. package/dist/src/codegen/generator/expressions/operators.js.map +1 -1
  11. package/dist/src/codegen/generator/expressions/primary.d.ts +9 -0
  12. package/dist/src/codegen/generator/expressions/primary.js +44 -7
  13. package/dist/src/codegen/generator/expressions/primary.js.map +1 -1
  14. package/dist/src/driver/bundler/commonjs.js +1 -1
  15. package/dist/src/driver/bundler/commonjs.js.map +1 -1
  16. package/dist/src/driver/bundler/symbols.js +6 -0
  17. package/dist/src/driver/bundler/symbols.js.map +1 -1
  18. package/dist/src/driver/version.d.ts +1 -1
  19. package/dist/src/driver/version.js +1 -1
  20. package/dist/src/extensions/gui/features.d.ts +2 -0
  21. package/dist/src/extensions/gui/features.js +24 -0
  22. package/dist/src/extensions/gui/features.js.map +1 -1
  23. package/dist/src/extensions/gui/index.js +39 -0
  24. package/dist/src/extensions/gui/index.js.map +1 -1
  25. package/dist/src/extensions/node/index.js +2 -0
  26. package/dist/src/extensions/node/index.js.map +1 -1
  27. package/dist/src/extensions/node/readline/index.d.ts +12 -0
  28. package/dist/src/extensions/node/readline/index.js +27 -0
  29. package/dist/src/extensions/node/readline/index.js.map +1 -0
  30. package/dist/src/parser/declarations/functions.js +6 -0
  31. package/dist/src/parser/declarations/functions.js.map +1 -1
  32. package/dist/src/parser/literals.js +1 -1
  33. package/dist/src/parser/literals.js.map +1 -1
  34. package/dist/tests/e2e/compile-modules.test.js +22 -0
  35. package/dist/tests/e2e/compile-modules.test.js.map +1 -1
  36. package/dist/tests/e2e/date-parse.test.js +17 -0
  37. package/dist/tests/e2e/date-parse.test.js.map +1 -1
  38. package/dist/tests/e2e/gui-browser.test.js +61 -0
  39. package/dist/tests/e2e/gui-browser.test.js.map +1 -1
  40. package/dist/tests/e2e/gui-css-coverage.test.js +39 -0
  41. package/dist/tests/e2e/gui-css-coverage.test.js.map +1 -1
  42. package/dist/tests/e2e/gui-css-features.test.js +100 -0
  43. package/dist/tests/e2e/gui-css-features.test.js.map +1 -1
  44. package/dist/tests/e2e/gui-dom.test.js +34 -0
  45. package/dist/tests/e2e/gui-dom.test.js.map +1 -1
  46. package/dist/tests/e2e/gui-errors.test.d.ts +11 -0
  47. package/dist/tests/e2e/gui-errors.test.js +68 -0
  48. package/dist/tests/e2e/gui-errors.test.js.map +1 -0
  49. package/dist/tests/e2e/gui-example-pelican3d.test.d.ts +6 -4
  50. package/dist/tests/e2e/gui-example-pelican3d.test.js +103 -44
  51. package/dist/tests/e2e/gui-example-pelican3d.test.js.map +1 -1
  52. package/dist/tests/e2e/gui-example-webgpu.test.d.ts +9 -0
  53. package/dist/tests/e2e/gui-example-webgpu.test.js +59 -0
  54. package/dist/tests/e2e/gui-example-webgpu.test.js.map +1 -0
  55. package/dist/tests/e2e/gui-helpers.d.ts +1 -1
  56. package/dist/tests/e2e/gui-webgl2-shadow-sampler.test.js +7 -1
  57. package/dist/tests/e2e/gui-webgl2-shadow-sampler.test.js.map +1 -1
  58. package/dist/tests/e2e/gui-webgpu.test.d.ts +11 -0
  59. package/dist/tests/e2e/gui-webgpu.test.js +402 -0
  60. package/dist/tests/e2e/gui-webgpu.test.js.map +1 -0
  61. package/dist/tests/e2e/harness.d.ts +4 -0
  62. package/dist/tests/e2e/harness.js +2 -0
  63. package/dist/tests/e2e/harness.js.map +1 -1
  64. package/dist/tests/e2e/readline.test.d.ts +7 -0
  65. package/dist/tests/e2e/readline.test.js +73 -0
  66. package/dist/tests/e2e/readline.test.js.map +1 -0
  67. package/dist/tests/extensions/gui-features.test.js +18 -1
  68. package/dist/tests/extensions/gui-features.test.js.map +1 -1
  69. package/doc/ai/extensions.md +7 -1
  70. package/doc/ai/zh-CN/extensions.md +6 -1
  71. package/doc/gui/api.md +15 -0
  72. package/doc/gui/dom.md +7 -2
  73. package/doc/gui/known-issues.md +2 -1
  74. package/doc/gui/layout.md +5 -1
  75. package/doc/gui/webgpu.md +121 -0
  76. package/doc/gui.md +12 -1
  77. package/doc/implemented/node/readline.md +34 -0
  78. package/doc/implemented/node.md +1 -0
  79. package/doc/unimplemented/node/modules.md +2 -3
  80. package/doc/unimplemented/node.md +2 -2
  81. package/doc/zh-CN/gui/api.md +11 -0
  82. package/doc/zh-CN/gui/dom.md +6 -2
  83. package/doc/zh-CN/gui/known-issues.md +2 -1
  84. package/doc/zh-CN/gui/layout.md +4 -1
  85. package/doc/zh-CN/gui/webgpu.md +111 -0
  86. package/doc/zh-CN/gui.md +10 -1
  87. package/doc/zh-CN/implemented/node/readline.md +33 -0
  88. package/doc/zh-CN/implemented/node.md +1 -0
  89. package/doc/zh-CN/unimplemented/node/modules.md +1 -2
  90. package/doc/zh-CN/unimplemented/node.md +2 -2
  91. package/llms.txt +1 -0
  92. package/package.json +7 -7
  93. package/runtime/ext_gui/browser.cpp +10 -0
  94. package/runtime/ext_gui/browser_abort.cpp +2 -2
  95. package/runtime/ext_gui/browser_loop.cpp +1 -0
  96. package/runtime/ext_gui/browser_media.cpp +1 -1
  97. package/runtime/ext_gui/dom_api_canvas.cpp +21 -0
  98. package/runtime/ext_gui/dom_api_canvas_extra.cpp +61 -0
  99. package/runtime/ext_gui/dom_api_canvas_image.cpp +2 -1
  100. package/runtime/ext_gui/dom_api_events.cpp +1 -1
  101. package/runtime/ext_gui/dom_api_internal.h +2 -0
  102. package/runtime/ext_gui/dom_api_node.cpp +18 -12
  103. package/runtime/ext_gui/dom_api_node_read.cpp +27 -0
  104. package/runtime/ext_gui/dom_api_proto.cpp +2 -0
  105. package/runtime/ext_gui/error_report.cpp +166 -0
  106. package/runtime/ext_gui/gpu_feature.cpp +2 -0
  107. package/runtime/ext_gui/gpu_shader_api.h +6 -0
  108. package/runtime/ext_gui/gui.cpp +16 -0
  109. package/runtime/ext_gui/gui_canvas.cpp +18 -0
  110. package/runtime/ext_gui/gui_engine.h +13 -0
  111. package/runtime/ext_gui/gui_events.cpp +4 -1
  112. package/runtime/ext_gui/layout_inline.cpp +46 -14
  113. package/runtime/ext_gui/paint.cpp +22 -0
  114. package/runtime/ext_gui/renderer_image.cpp +6 -0
  115. package/runtime/ext_gui/script.cpp +1 -1
  116. package/runtime/ext_gui/style.cpp +1 -0
  117. package/runtime/ext_gui/style.h +13 -0
  118. package/runtime/ext_gui/style_print.cpp +99 -0
  119. package/runtime/ext_gui/style_text.cpp +79 -0
  120. package/runtime/ext_gui/webgl_glsl.h +8 -0
  121. package/runtime/ext_gui/webgl_glsl_compile.cpp +11 -5
  122. package/runtime/ext_gui/webgl_msl.cpp +20 -9
  123. package/runtime/ext_gui/webgl_msl.h +4 -0
  124. package/runtime/ext_gui/webgl_texture.cpp +0 -8
  125. package/runtime/ext_gui/webgpu.h +371 -0
  126. package/runtime/ext_gui/webgpu_api.h +42 -0
  127. package/runtime/ext_gui/webgpu_bindings.cpp +364 -0
  128. package/runtime/ext_gui/webgpu_bindings.h +59 -0
  129. package/runtime/ext_gui/webgpu_bridge.c +21 -0
  130. package/runtime/ext_gui/webgpu_buffer.cpp +293 -0
  131. package/runtime/ext_gui/webgpu_canvas.cpp +305 -0
  132. package/runtime/ext_gui/webgpu_command.cpp +510 -0
  133. package/runtime/ext_gui/webgpu_compute_pass.cpp +138 -0
  134. package/runtime/ext_gui/webgpu_convert.cpp +309 -0
  135. package/runtime/ext_gui/webgpu_device.cpp +370 -0
  136. package/runtime/ext_gui/webgpu_feature.cpp +74 -0
  137. package/runtime/ext_gui/webgpu_objects.cpp +125 -0
  138. package/runtime/ext_gui/webgpu_pass.cpp +295 -0
  139. package/runtime/ext_gui/webgpu_pass.h +33 -0
  140. package/runtime/ext_gui/webgpu_pipeline.cpp +463 -0
  141. package/runtime/ext_gui/webgpu_queue.cpp +222 -0
  142. package/runtime/ext_gui/webgpu_render_pass.cpp +417 -0
  143. package/runtime/ext_gui/webgpu_resources.cpp +315 -0
  144. package/runtime/ext_gui/webgpu_shader.cpp +242 -0
  145. package/runtime/ext_gui/wgsl.h +99 -0
  146. package/runtime/ext_gui/wgsl_api.cpp +137 -0
  147. package/runtime/ext_gui/wgsl_ast.h +233 -0
  148. package/runtime/ext_gui/wgsl_emit.cpp +452 -0
  149. package/runtime/ext_gui/wgsl_emit.h +128 -0
  150. package/runtime/ext_gui/wgsl_emit_call.cpp +281 -0
  151. package/runtime/ext_gui/wgsl_emit_expr.cpp +192 -0
  152. package/runtime/ext_gui/wgsl_emit_stmt.cpp +209 -0
  153. package/runtime/ext_gui/wgsl_entry.cpp +189 -0
  154. package/runtime/ext_gui/wgsl_infer.cpp +171 -0
  155. package/runtime/ext_gui/wgsl_lexer.cpp +179 -0
  156. package/runtime/ext_gui/wgsl_lexer.h +32 -0
  157. package/runtime/ext_gui/wgsl_parse_expr.cpp +215 -0
  158. package/runtime/ext_gui/wgsl_parse_stmt.cpp +259 -0
  159. package/runtime/ext_gui/wgsl_parser.cpp +457 -0
  160. package/runtime/ext_gui/wgsl_parser.h +77 -0
  161. package/runtime/ext_gui/wgsl_type.cpp +232 -0
  162. package/runtime/ext_gui/window.cpp +22 -8
  163. package/runtime/ext_gui/window_emit.cpp +1 -1
  164. package/runtime/ext_node/fs/parts/platform.inc +2 -0
  165. package/runtime/ext_node/readline/readline.c +572 -0
  166. package/runtime/rt.h +15 -0
  167. package/runtime/rt_internal.h +3 -2
  168. package/runtime/xt_io/exception.inc +29 -6
  169. package/runtime/xt_loop.c +36 -1
  170. package/runtime/xt_promise.c +26 -2
  171. package/runtime/xt_stdlib2/date.inc +2 -2
  172. package/runtime/xt_typed_array/elements.inc +0 -9
  173. package/runtime/xt_url.c +0 -6
  174. package/runtime/xt_url_object.c +1 -1
  175. package/src/ast/expressions.ts +6 -0
  176. package/src/checker/type-infer.ts +1 -1
  177. package/src/codegen/generator/calls/literals.ts +4 -1
  178. package/src/codegen/generator/expressions/assignment.ts +3 -1
  179. package/src/codegen/generator/expressions/operators.ts +2 -6
  180. package/src/codegen/generator/expressions/primary.ts +58 -6
  181. package/src/driver/bundler/commonjs.ts +1 -1
  182. package/src/driver/bundler/symbols.ts +6 -0
  183. package/src/driver/version.ts +1 -1
  184. package/src/extensions/gui/features.ts +24 -0
  185. package/src/extensions/gui/index.ts +39 -0
  186. package/src/extensions/node/index.ts +2 -0
  187. package/src/extensions/node/readline/index.ts +31 -0
  188. package/src/parser/declarations/functions.ts +6 -0
  189. package/src/parser/literals.ts +1 -1
@@ -0,0 +1,232 @@
1
+ /*
2
+ * xbintsc GUI engine — WGSL type model helpers.
3
+ */
4
+
5
+ #include "wgsl_ast.h"
6
+
7
+ #include <cstdlib>
8
+
9
+ namespace xtgui {
10
+ namespace wgsl {
11
+
12
+ TypePtr make_scalar(Scalar scalar) {
13
+ auto type = std::make_shared<Type>();
14
+ type->kind = Kind::Scalar;
15
+ type->scalar = scalar;
16
+ return type;
17
+ }
18
+
19
+ TypePtr make_vector(Scalar scalar, int width) {
20
+ auto type = std::make_shared<Type>();
21
+ type->kind = Kind::Vector;
22
+ type->scalar = scalar;
23
+ type->width = width;
24
+ return type;
25
+ }
26
+
27
+ TypePtr make_matrix(Scalar scalar, int cols, int rows) {
28
+ auto type = std::make_shared<Type>();
29
+ type->kind = Kind::Matrix;
30
+ type->scalar = scalar;
31
+ type->cols = cols;
32
+ type->rows = rows;
33
+ return type;
34
+ }
35
+
36
+ TypePtr make_array(TypePtr elem, int length) {
37
+ auto type = std::make_shared<Type>();
38
+ type->kind = Kind::Array;
39
+ type->elem = std::move(elem);
40
+ type->length = length;
41
+ return type;
42
+ }
43
+
44
+ std::string scalar_glsl(Scalar scalar) {
45
+ switch (scalar) {
46
+ case Scalar::Bool: return "bool";
47
+ case Scalar::I32: return "int";
48
+ case Scalar::U32: return "uint";
49
+ default: return "float";
50
+ }
51
+ }
52
+
53
+ namespace {
54
+
55
+ std::string vector_prefix(Scalar scalar) {
56
+ switch (scalar) {
57
+ case Scalar::Bool: return "b";
58
+ case Scalar::I32: return "i";
59
+ case Scalar::U32: return "u";
60
+ default: return "";
61
+ }
62
+ }
63
+
64
+ std::string texture_glsl(const Type &type) {
65
+ const bool storage = type.kind == Kind::StorageTexture;
66
+ const bool depth = type.depth;
67
+ const TextureDim dim = type.dim;
68
+ if (storage) {
69
+ switch (dim) {
70
+ case TextureDim::D1: return "image1D";
71
+ case TextureDim::D2Array: return "image2DArray";
72
+ case TextureDim::D3: return "image3D";
73
+ case TextureDim::Cube:
74
+ case TextureDim::CubeArray: return "imageCube";
75
+ default: return "image2D";
76
+ }
77
+ }
78
+ switch (dim) {
79
+ case TextureDim::D1: return "sampler1D";
80
+ case TextureDim::D2Array: return depth ? "sampler2DArrayShadow" : "sampler2DArray";
81
+ case TextureDim::D3: return "sampler3D";
82
+ case TextureDim::Cube: return depth ? "samplerCubeShadow" : "samplerCube";
83
+ case TextureDim::CubeArray: return "samplerCubeArray";
84
+ case TextureDim::Multisampled2D: return "sampler2DMS";
85
+ default: break;
86
+ }
87
+ return depth ? "sampler2DShadow" : "sampler2D";
88
+ }
89
+
90
+ } // namespace
91
+
92
+ std::string glsl_type(const Type &type) {
93
+ switch (type.kind) {
94
+ case Kind::Void: return "void";
95
+ case Kind::Scalar: return scalar_glsl(type.scalar);
96
+ case Kind::Vector:
97
+ return vector_prefix(type.scalar) + "vec" + std::to_string(type.width > 0 ? type.width : 1);
98
+ case Kind::Matrix: {
99
+ if (type.cols == type.rows) return "mat" + std::to_string(type.cols);
100
+ return "mat" + std::to_string(type.cols) + "x" + std::to_string(type.rows);
101
+ }
102
+ case Kind::Array: {
103
+ std::string element = type.elem != nullptr ? glsl_type(*type.elem) : "float";
104
+ return element + "[" + std::to_string(type.length) + "]";
105
+ }
106
+ case Kind::Struct: return type.strct != nullptr ? type.strct->name : "xt_unknown";
107
+ case Kind::Atomic: return "uint";
108
+ case Kind::Sampler: return "sampler2D";
109
+ case Kind::SamplerComparison: return "sampler2DShadow";
110
+ case Kind::Texture:
111
+ case Kind::StorageTexture: return texture_glsl(type);
112
+ default: return "float";
113
+ }
114
+ }
115
+
116
+ std::string glsl_decl(const Type &type, const std::string &name) {
117
+ if (type.kind == Kind::Array && type.elem != nullptr) {
118
+ return glsl_decl(*type.elem, name + "[" + std::to_string(type.length) + "]");
119
+ }
120
+ return glsl_type(type) + " " + name;
121
+ }
122
+
123
+ std::string wgsl_type(const Type &type) {
124
+ switch (type.kind) {
125
+ case Kind::Void: return "void";
126
+ case Kind::Scalar:
127
+ switch (type.scalar) {
128
+ case Scalar::Bool: return "bool";
129
+ case Scalar::I32: return "i32";
130
+ case Scalar::U32: return "u32";
131
+ default: return "f32";
132
+ }
133
+ case Kind::Vector: {
134
+ const std::string base = glsl_type(type);
135
+ return std::string("vec") + std::to_string(type.width) +
136
+ (base[0] == 'b' ? "b" : base[0] == 'i' ? "i" : base[0] == 'u' ? "u" : "f");
137
+ }
138
+ case Kind::Matrix: return "mat" + std::to_string(type.cols) + "x" + std::to_string(type.rows) + "f";
139
+ case Kind::Array: return "array<" + (type.elem ? wgsl_type(*type.elem) : "f32") + ", " +
140
+ std::to_string(type.length) + ">";
141
+ case Kind::Struct: return type.strct != nullptr ? type.strct->name : "struct";
142
+ case Kind::Atomic: return "atomic<u32>";
143
+ case Kind::Sampler: return "sampler";
144
+ case Kind::SamplerComparison: return "sampler_comparison";
145
+ case Kind::Texture: return "texture";
146
+ case Kind::StorageTexture: return "texture_storage";
147
+ default: return "unknown";
148
+ }
149
+ }
150
+
151
+ TypePtr type_by_name(const Module &module, const std::string &name) {
152
+ if (name == "f32" || name == "f16") return make_scalar(Scalar::F32);
153
+ if (name == "i32") return make_scalar(Scalar::I32);
154
+ if (name == "u32") return make_scalar(Scalar::U32);
155
+ if (name == "bool") return make_scalar(Scalar::Bool);
156
+ if (name == "sampler") {
157
+ auto type = std::make_shared<Type>();
158
+ type->kind = Kind::Sampler;
159
+ return type;
160
+ }
161
+ if (name == "sampler_comparison") {
162
+ auto type = std::make_shared<Type>();
163
+ type->kind = Kind::SamplerComparison;
164
+ return type;
165
+ }
166
+ /* Vector shorthands: vec3f, vec2i, vec4u (and the generic vec3<f32> form is
167
+ * parsed directly, not looked up by name). */
168
+ if (name.size() >= 5 && name.compare(0, 3, "vec") == 0 && name[3] >= '2' && name[3] <= '4') {
169
+ const int width = name[3] - '0';
170
+ const char suffix = name[4];
171
+ Scalar scalar = Scalar::F32;
172
+ if (suffix == 'i') scalar = Scalar::I32;
173
+ else if (suffix == 'u') scalar = Scalar::U32;
174
+ else if (suffix == 'b') scalar = Scalar::Bool;
175
+ return make_vector(scalar, width);
176
+ }
177
+ /* Matrix shorthands: mat4x4f, mat3x2f, mat2f (= mat2x2f). */
178
+ if (name.size() >= 5 && name.compare(0, 3, "mat") == 0) {
179
+ int cols = 0;
180
+ int rows = 0;
181
+ size_t at = 3;
182
+ while (at < name.size() && name[at] >= '0' && name[at] <= '9') {
183
+ cols = cols * 10 + (name[at] - '0');
184
+ at++;
185
+ }
186
+ if (at < name.size() && name[at] == 'x') {
187
+ at++;
188
+ while (at < name.size() && name[at] >= '0' && name[at] <= '9') {
189
+ rows = rows * 10 + (name[at] - '0');
190
+ at++;
191
+ }
192
+ }
193
+ if (rows == 0) rows = cols;
194
+ if (cols >= 2 && cols <= 4 && rows >= 2 && rows <= 4) return make_matrix(Scalar::F32, cols, rows);
195
+ }
196
+ for (const StructDecl &decl : module.structs) {
197
+ if (decl.name == name) {
198
+ auto type = std::make_shared<Type>();
199
+ type->kind = Kind::Struct;
200
+ type->strct = &decl;
201
+ type->width = 1;
202
+ return type;
203
+ }
204
+ }
205
+ for (const auto &alias : module.aliases) {
206
+ if (alias.first == name && alias.second != nullptr) {
207
+ return std::make_shared<Type>(*alias.second);
208
+ }
209
+ }
210
+ return nullptr;
211
+ }
212
+
213
+ std::string image_format_glsl(ImageFormat format) {
214
+ switch (format) {
215
+ case ImageFormat::Rgba8Unorm: return "rgba8";
216
+ case ImageFormat::Rgba8Snorm: return "rgba8_snorm";
217
+ case ImageFormat::Rgba8Uint: return "rgba8ui";
218
+ case ImageFormat::Rgba8Sint: return "rgba8i";
219
+ case ImageFormat::Rgba16Float: return "rgba16f";
220
+ case ImageFormat::Rgba32Float: return "rgba32f";
221
+ case ImageFormat::R32Float: return "r32f";
222
+ case ImageFormat::R32Uint: return "r32ui";
223
+ case ImageFormat::R32Sint: return "r32i";
224
+ case ImageFormat::Rgba16Uint: return "rgba16ui";
225
+ case ImageFormat::Rgba16Sint: return "rgba16i";
226
+ case ImageFormat::Bgra8Unorm: return "rgba8";
227
+ default: return "rgba8";
228
+ }
229
+ }
230
+
231
+ } // namespace wgsl
232
+ } // namespace xtgui
@@ -25,12 +25,6 @@ xt_value xt_gui_window_set_background(xt_value self, xt_value env, int32_t argc,
25
25
  xt_value xt_gui_window_paint_list(xt_value self, xt_value env, int32_t argc, xt_value *argv);
26
26
  xt_value xt_gui_window_paint_count(xt_value self, xt_value env, int32_t argc, xt_value *argv);
27
27
 
28
- /** String value of a runtime value, as `std::string` ("" for null/undefined). */
29
- static std::string window_string(xt_value value) {
30
- const char *data = xt_string_data(xt_to_string(value));
31
- return data != nullptr ? data : "";
32
- }
33
-
34
28
  /* -- methods -------------------------------------------------------------- */
35
29
 
36
30
  static xt_value win_set_title(xt_value self, xt_value env, int32_t argc, xt_value *argv) {
@@ -47,8 +41,28 @@ static xt_value win_set_size(xt_value self, xt_value env, int32_t argc, xt_value
47
41
  (void)env;
48
42
  XtGuiWindow *win = xt_gui_window_from_this(self);
49
43
  if (win != NULL && win->window != NULL && argc >= 2) {
50
- SDL_SetWindowSize(win->window, (int)xt_to_number(xt_arg(argc, argv, 0)),
51
- (int)xt_to_number(xt_arg(argc, argv, 1)));
44
+ int width = (int)xt_to_number(xt_arg(argc, argv, 0));
45
+ int height = (int)xt_to_number(xt_arg(argc, argv, 1));
46
+ SDL_SetWindowSize(win->window, width, height);
47
+ /* Settle the request with the window system (bounded by the backend's own
48
+ * timeout). `innerWidth` already reads the live size, so a host that does
49
+ * not pump SDL events — a page driven only by timers — otherwise never
50
+ * observes the matching `resize` event. */
51
+ SDL_SyncWindow(win->window);
52
+ int actualWidth = width;
53
+ int actualHeight = height;
54
+ SDL_GetWindowSize(win->window, &actualWidth, &actualHeight);
55
+ if (actualWidth != win->width || actualHeight != win->height) {
56
+ win->width = actualWidth;
57
+ win->height = actualHeight;
58
+ if (win->document != NULL) {
59
+ win->document->restyle((float)win->width, (float)win->height);
60
+ }
61
+ win->geometry.dirty = 1;
62
+ win->present_dirty = 1;
63
+ xt_gui_emit(win, "resize");
64
+ xt_gui_media_lists_notify(win);
65
+ }
52
66
  }
53
67
  return XT_UNDEFINED;
54
68
  }
@@ -46,6 +46,6 @@ void xt_gui_emit_payload(XtGuiWindow *win, const char *event, xt_value payload)
46
46
  continue;
47
47
  }
48
48
  if (listener.once) remove_window_listener(win, listener);
49
- if (XT_IS_FUNCTION(listener.fn)) xt_call_with_this(listener.fn, win->object, count, args);
49
+ if (XT_IS_FUNCTION(listener.fn)) xt_gui_invoke(listener.fn, win->object, count, args);
50
50
  }
51
51
  }
@@ -118,6 +118,8 @@ static inline size_t xt_fs_path_root(const char *path) {
118
118
  while (xt_fs_is_sep(path[i])) i++;
119
119
  return i;
120
120
  }
121
+ #else
122
+ (void)path;
121
123
  #endif
122
124
  return 0;
123
125
  }