@native-sdk/cli 0.8.2 → 0.8.4
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/build/app.zig +50 -3
- package/build.zig +134 -360
- package/native-sdk.d.ts +4 -0
- package/package.json +9 -9
- package/packages/core/compile-surface/core.ts +90 -1
- package/packages/core/package-lock.json +2 -2
- package/packages/core/package.json +1 -1
- package/packages/core/sdk/core.d.ts +65 -2
- package/packages/core/sdk/core.ts +189 -33
- package/packages/core/sdk/events.d.ts +14 -0
- package/packages/core/sdk/events.ts +18 -0
- package/packages/core/src/checker.ts +61 -1
- package/packages/core/src/devhost.ts +3 -3
- package/packages/core/src/diagnostics.ts +4 -4
- package/skill-data/core/SKILL.md +4 -2
- package/skill-data/core/references/project-anatomy.md +2 -1
- package/skill-data/core/references/web-engines-packaging-debugging.md +3 -1
- package/skill-data/native-ui/SKILL.md +8 -8
- package/skill-data/ts-core/SKILL.md +16 -13
- package/src/app_runner/app_assets.zig +138 -0
- package/src/app_runner/root.zig +2 -0
- package/src/app_runner/ts_core_main.zig +27 -3
- package/src/embed/host.zig +6 -0
- package/src/embed/ui_host.zig +2 -0
- package/src/platform/linux/root.zig +1 -0
- package/src/platform/macos/appkit_host.h +10 -0
- package/src/platform/macos/appkit_host.m +515 -93
- package/src/platform/macos/capture_info_plist.c +25 -0
- package/src/platform/macos/cef_host.mm +22 -0
- package/src/platform/macos/root.zig +68 -0
- package/src/platform/null_platform.zig +58 -0
- package/src/platform/root.zig +7 -0
- package/src/platform/types.zig +100 -0
- package/src/platform/windows/root.zig +56 -0
- package/src/platform/windows/webview2_host.cpp +171 -0
- package/src/primitives/app_manifest/types.zig +2 -0
- package/src/primitives/canvas/code_tests.zig +9 -9
- package/src/primitives/canvas/events.zig +12 -11
- package/src/primitives/canvas/frame.zig +44 -9
- package/src/primitives/canvas/icons/mic.svg +1 -0
- package/src/primitives/canvas/icons.zig +2 -0
- package/src/primitives/canvas/root.zig +8 -0
- package/src/primitives/canvas/text_span_tests.zig +39 -0
- package/src/primitives/canvas/ui.zig +23 -4
- package/src/primitives/canvas/ui_markup.zig +15 -0
- package/src/primitives/canvas/ui_markup_compiled.zig +9 -0
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +1 -1
- package/src/primitives/canvas/ui_markup_tests.zig +5 -0
- package/src/primitives/canvas/ui_markup_view.zig +9 -0
- package/src/primitives/canvas/ui_markup_view_tests.zig +9 -6
- package/src/primitives/canvas/ui_schema.zig +19 -10
- package/src/primitives/canvas/ui_schema_tests.zig +5 -3
- package/src/primitives/canvas/ui_tests.zig +18 -4
- package/src/primitives/canvas/widget_invalidation.zig +9 -2
- package/src/primitives/canvas/widget_render.zig +321 -115
- package/src/primitives/canvas/widget_runtime_tests.zig +173 -0
- package/src/primitives/canvas/widget_text_input.zig +10 -10
- package/src/primitives/canvas/widget_tree.zig +1 -1
- package/src/primitives/canvas/widgets.zig +41 -5
- package/src/root.zig +10 -0
- package/src/runtime/automation_widget_dispatch.zig +1 -0
- package/src/runtime/bridge_payload.zig +2 -0
- package/src/runtime/canvas_frame.zig +13 -2
- package/src/runtime/canvas_frame_invalidation_tests.zig +35 -10
- package/src/runtime/canvas_widget_anchored_tests.zig +83 -0
- package/src/runtime/canvas_widget_event_tests.zig +1 -0
- package/src/runtime/canvas_widget_events.zig +69 -24
- package/src/runtime/canvas_widget_runtime.zig +101 -6
- package/src/runtime/canvas_widget_scroll_driver_tests.zig +47 -4
- package/src/runtime/canvas_widget_scroll_drivers.zig +3 -3
- package/src/runtime/canvas_widget_semantics_tests.zig +2 -0
- package/src/runtime/canvas_widget_split_tree_tests.zig +228 -0
- package/src/runtime/canvas_widget_state.zig +10 -1
- package/src/runtime/canvas_widget_text_tests.zig +112 -3
- package/src/runtime/effects.zig +313 -2
- package/src/runtime/effects_audio_capture_tests.zig +251 -0
- package/src/runtime/root.zig +3 -0
- package/src/runtime/tests.zig +1 -0
- package/src/runtime/ts_core_host.zig +401 -32
- package/src/runtime/ts_core_host_tests.zig +407 -0
- package/src/runtime/ts_ui_app.zig +39 -1
- package/src/runtime/ui_app.zig +18 -3
- package/src/runtime/ui_app_tests.zig +48 -0
- package/src/runtime/view.zig +2 -0
- package/src/runtime/view_widget_scroll.zig +56 -5
- package/src/runtime/view_widget_text.zig +24 -5
- package/src/runtime/view_widget_tree.zig +1 -1
- package/src/tooling/manifest.zig +1034 -0
- package/src/tooling/package.zig +841 -10
- package/src/tooling/raw_manifest.zig +35 -0
- package/src/tooling/templates.zig +55 -0
- package/tools/corewire/emit_facade.zig +36 -0
|
@@ -605,6 +605,24 @@ struct AudioSpectrumState {
|
|
|
605
605
|
uint64_t generation = 0;
|
|
606
606
|
};
|
|
607
607
|
|
|
608
|
+
using AudioCapturePush = int (*)(void *context, int kind, int source,
|
|
609
|
+
uint32_t sample_rate, uint8_t channels, uint64_t timestamp_ns,
|
|
610
|
+
uint32_t frames, const uint8_t *pcm, size_t pcm_len);
|
|
611
|
+
|
|
612
|
+
struct AudioCaptureShared {
|
|
613
|
+
std::atomic<bool> stop{false};
|
|
614
|
+
int source = 0;
|
|
615
|
+
uint32_t sample_rate = 48000;
|
|
616
|
+
uint8_t channels = 1;
|
|
617
|
+
AudioCapturePush push = nullptr;
|
|
618
|
+
void *context = nullptr;
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
struct AudioCaptureState {
|
|
622
|
+
std::shared_ptr<AudioCaptureShared> shared;
|
|
623
|
+
std::thread worker;
|
|
624
|
+
};
|
|
625
|
+
|
|
608
626
|
/* The app's single audio player (see the audio section further down for
|
|
609
627
|
* the backend rationale). All fields are message-loop-thread state; the
|
|
610
628
|
* lifetime mutex additionally guards `generation` and `source` because
|
|
@@ -698,6 +716,7 @@ struct Host {
|
|
|
698
716
|
bool com_initialized = false;
|
|
699
717
|
AudioState audio;
|
|
700
718
|
AudioSpectrumState spectrum;
|
|
719
|
+
AudioCaptureState captures[2];
|
|
701
720
|
PendingContextMenu context_menu;
|
|
702
721
|
std::shared_ptr<HostLifetime> lifetime = std::make_shared<HostLifetime>();
|
|
703
722
|
};
|
|
@@ -4258,6 +4277,129 @@ static void audioHandleSpectrumMessage(Host *host, WPARAM generation) {
|
|
|
4258
4277
|
audioEmitSpectrum(host, bands);
|
|
4259
4278
|
}
|
|
4260
4279
|
|
|
4280
|
+
/* ------------------------------------------------------- audio capture
|
|
4281
|
+
* Default microphone capture uses the default eCapture endpoint; system
|
|
4282
|
+
* capture uses the default eRender endpoint with WASAPI's loopback flag.
|
|
4283
|
+
* Shared-mode conversion asks the in-box audio engine for the SDK's exact
|
|
4284
|
+
* signed-16 format, so device-native rates/layouts never leak across the
|
|
4285
|
+
* platform seam. Each source owns a joinable worker: stop is the required
|
|
4286
|
+
* quiescence fence before the Zig sink storage can be cleared. */
|
|
4287
|
+
static void audioCaptureThread(std::shared_ptr<AudioCaptureShared> shared) {
|
|
4288
|
+
HRESULT com_hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE);
|
|
4289
|
+
IMMDeviceEnumerator *enumerator = nullptr;
|
|
4290
|
+
IMMDevice *device = nullptr;
|
|
4291
|
+
IAudioClient *client = nullptr;
|
|
4292
|
+
IAudioCaptureClient *capture = nullptr;
|
|
4293
|
+
HANDLE ready = nullptr;
|
|
4294
|
+
bool running = false;
|
|
4295
|
+
do {
|
|
4296
|
+
if (FAILED(CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL,
|
|
4297
|
+
IID_IMMDeviceEnumerator, reinterpret_cast<void **>(&enumerator))) || !enumerator) break;
|
|
4298
|
+
const EDataFlow flow = shared->source == 1 ? eRender : eCapture;
|
|
4299
|
+
if (FAILED(enumerator->GetDefaultAudioEndpoint(flow, eConsole, &device)) || !device) break;
|
|
4300
|
+
if (FAILED(device->Activate(IID_IAudioClient, CLSCTX_ALL, nullptr,
|
|
4301
|
+
reinterpret_cast<void **>(&client))) || !client) break;
|
|
4302
|
+
WAVEFORMATEX format = {};
|
|
4303
|
+
format.wFormatTag = WAVE_FORMAT_PCM;
|
|
4304
|
+
format.nChannels = shared->channels;
|
|
4305
|
+
format.nSamplesPerSec = shared->sample_rate;
|
|
4306
|
+
format.wBitsPerSample = 16;
|
|
4307
|
+
format.nBlockAlign = (WORD)(format.nChannels * 2);
|
|
4308
|
+
format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign;
|
|
4309
|
+
DWORD flags = AUDCLNT_STREAMFLAGS_EVENTCALLBACK |
|
|
4310
|
+
AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM |
|
|
4311
|
+
AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY;
|
|
4312
|
+
if (shared->source == 1) flags |= AUDCLNT_STREAMFLAGS_LOOPBACK;
|
|
4313
|
+
if (FAILED(client->Initialize(AUDCLNT_SHAREMODE_SHARED, flags, 1000000, 0, &format, nullptr))) break;
|
|
4314
|
+
ready = CreateEventW(nullptr, FALSE, FALSE, nullptr);
|
|
4315
|
+
if (!ready || FAILED(client->SetEventHandle(ready))) break;
|
|
4316
|
+
if (FAILED(client->GetService(IID_IAudioCaptureClient, reinterpret_cast<void **>(&capture))) || !capture) break;
|
|
4317
|
+
if (FAILED(client->Start())) break;
|
|
4318
|
+
running = true;
|
|
4319
|
+
} while (false);
|
|
4320
|
+
|
|
4321
|
+
if (!running) {
|
|
4322
|
+
if (!shared->stop.load(std::memory_order_relaxed) && shared->push) {
|
|
4323
|
+
shared->push(shared->context, 2, shared->source, shared->sample_rate,
|
|
4324
|
+
shared->channels, 0, 0, nullptr, 0);
|
|
4325
|
+
}
|
|
4326
|
+
} else {
|
|
4327
|
+
if (shared->push && shared->push(shared->context, 0, shared->source,
|
|
4328
|
+
shared->sample_rate, shared->channels, 0, 0, nullptr, 0) == 1) {
|
|
4329
|
+
shared->stop.store(true, std::memory_order_relaxed);
|
|
4330
|
+
}
|
|
4331
|
+
const UINT32 max_frames = 3840u / ((UINT32)shared->channels * 2u);
|
|
4332
|
+
int16_t silence[1920] = {};
|
|
4333
|
+
bool terminal_error = false;
|
|
4334
|
+
while (!shared->stop.load(std::memory_order_relaxed)) {
|
|
4335
|
+
const DWORD wait_result = WaitForSingleObject(ready, 50);
|
|
4336
|
+
/* A timeout is also a polling fallback for loopback endpoints
|
|
4337
|
+
* whose event notification is late or absent. */
|
|
4338
|
+
if (wait_result != WAIT_OBJECT_0 && wait_result != WAIT_TIMEOUT) {
|
|
4339
|
+
terminal_error = true;
|
|
4340
|
+
break;
|
|
4341
|
+
}
|
|
4342
|
+
while (!shared->stop.load(std::memory_order_relaxed)) {
|
|
4343
|
+
UINT32 pending = 0;
|
|
4344
|
+
if (FAILED(capture->GetNextPacketSize(&pending))) {
|
|
4345
|
+
terminal_error = true;
|
|
4346
|
+
break;
|
|
4347
|
+
}
|
|
4348
|
+
if (pending == 0) break;
|
|
4349
|
+
BYTE *data = nullptr;
|
|
4350
|
+
UINT32 frames = 0;
|
|
4351
|
+
DWORD packet_flags = 0;
|
|
4352
|
+
if (FAILED(capture->GetBuffer(&data, &frames, &packet_flags, nullptr, nullptr))) {
|
|
4353
|
+
terminal_error = true;
|
|
4354
|
+
break;
|
|
4355
|
+
}
|
|
4356
|
+
UINT32 offset = 0;
|
|
4357
|
+
while (offset < frames && !shared->stop.load(std::memory_order_relaxed)) {
|
|
4358
|
+
const UINT32 chunk = std::min(max_frames, frames - offset);
|
|
4359
|
+
const size_t byte_len = (size_t)chunk * shared->channels * 2;
|
|
4360
|
+
const uint8_t *pcm = ((packet_flags & AUDCLNT_BUFFERFLAGS_SILENT) || !data)
|
|
4361
|
+
? reinterpret_cast<const uint8_t *>(silence)
|
|
4362
|
+
: data + (size_t)offset * shared->channels * 2;
|
|
4363
|
+
const int result = shared->push ? shared->push(shared->context, 1,
|
|
4364
|
+
shared->source, shared->sample_rate, shared->channels,
|
|
4365
|
+
gpuTimestampNs(), chunk, pcm, byte_len) : 1;
|
|
4366
|
+
if (result == 1) shared->stop.store(true, std::memory_order_relaxed);
|
|
4367
|
+
offset += chunk;
|
|
4368
|
+
}
|
|
4369
|
+
if (FAILED(capture->ReleaseBuffer(frames))) {
|
|
4370
|
+
terminal_error = true;
|
|
4371
|
+
break;
|
|
4372
|
+
}
|
|
4373
|
+
}
|
|
4374
|
+
if (terminal_error) break;
|
|
4375
|
+
}
|
|
4376
|
+
if (terminal_error && !shared->stop.load(std::memory_order_relaxed) && shared->push) {
|
|
4377
|
+
shared->push(shared->context, 2, shared->source, shared->sample_rate,
|
|
4378
|
+
shared->channels, 0, 0, nullptr, 0);
|
|
4379
|
+
}
|
|
4380
|
+
client->Stop();
|
|
4381
|
+
}
|
|
4382
|
+
if (capture) capture->Release();
|
|
4383
|
+
if (client) client->Release();
|
|
4384
|
+
if (device) device->Release();
|
|
4385
|
+
if (enumerator) enumerator->Release();
|
|
4386
|
+
if (ready) CloseHandle(ready);
|
|
4387
|
+
if (SUCCEEDED(com_hr)) CoUninitialize();
|
|
4388
|
+
}
|
|
4389
|
+
|
|
4390
|
+
static void audioCaptureStop(Host *host, int source) {
|
|
4391
|
+
if (!host || source < 0 || source > 1) return;
|
|
4392
|
+
AudioCaptureState &state = host->captures[source];
|
|
4393
|
+
if (state.shared) state.shared->stop.store(true, std::memory_order_relaxed);
|
|
4394
|
+
if (state.worker.joinable()) state.worker.join();
|
|
4395
|
+
state.shared.reset();
|
|
4396
|
+
}
|
|
4397
|
+
|
|
4398
|
+
static void audioCaptureStopAll(Host *host) {
|
|
4399
|
+
audioCaptureStop(host, 0);
|
|
4400
|
+
audioCaptureStop(host, 1);
|
|
4401
|
+
}
|
|
4402
|
+
|
|
4261
4403
|
/* Release the whole pipeline. The session retires through Close(): the
|
|
4262
4404
|
* event pump answers the MESessionClosed handshake by shutting source
|
|
4263
4405
|
* and session down on the worker thread, so the loop never blocks. The
|
|
@@ -5840,6 +5982,7 @@ Host *native_sdk_windows_create(const char *app_name, size_t app_name_len, const
|
|
|
5840
5982
|
|
|
5841
5983
|
void native_sdk_windows_destroy(Host *host) {
|
|
5842
5984
|
if (!host) return;
|
|
5985
|
+
audioCaptureStopAll(host);
|
|
5843
5986
|
std::shared_ptr<HostLifetime> lifetime = host->lifetime;
|
|
5844
5987
|
std::lock_guard<std::recursive_mutex> guard(lifetime->mutex);
|
|
5845
5988
|
lifetime->alive = false;
|
|
@@ -7608,4 +7751,32 @@ int native_sdk_windows_audio_spectrum_supported(Host *host) {
|
|
|
7608
7751
|
return audioSpectrumSupported() ? 1 : 0;
|
|
7609
7752
|
}
|
|
7610
7753
|
|
|
7754
|
+
int native_sdk_windows_audio_capture_start(Host *host, int source, uint32_t sample_rate,
|
|
7755
|
+
uint8_t channels, AudioCapturePush push_fn, void *push_context) {
|
|
7756
|
+
if (!host || source < 0 || source > 1 || !push_fn ||
|
|
7757
|
+
(sample_rate != 16000 && sample_rate != 24000 && sample_rate != 48000) ||
|
|
7758
|
+
(channels != 1 && channels != 2)) return 0;
|
|
7759
|
+
audioCaptureStop(host, source);
|
|
7760
|
+
AudioCaptureState &state = host->captures[source];
|
|
7761
|
+
state.shared = std::make_shared<AudioCaptureShared>();
|
|
7762
|
+
state.shared->source = source;
|
|
7763
|
+
state.shared->sample_rate = sample_rate;
|
|
7764
|
+
state.shared->channels = channels;
|
|
7765
|
+
state.shared->push = push_fn;
|
|
7766
|
+
state.shared->context = push_context;
|
|
7767
|
+
try {
|
|
7768
|
+
state.worker = std::thread(audioCaptureThread, state.shared);
|
|
7769
|
+
} catch (...) {
|
|
7770
|
+
state.shared.reset();
|
|
7771
|
+
return 0;
|
|
7772
|
+
}
|
|
7773
|
+
return 1;
|
|
7774
|
+
}
|
|
7775
|
+
|
|
7776
|
+
int native_sdk_windows_audio_capture_stop(Host *host, int source) {
|
|
7777
|
+
if (!host || source < 0 || source > 1) return 0;
|
|
7778
|
+
audioCaptureStop(host, source);
|
|
7779
|
+
return 1;
|
|
7780
|
+
}
|
|
7781
|
+
|
|
7611
7782
|
}
|
|
@@ -113,6 +113,7 @@ pub const PermissionKind = enum {
|
|
|
113
113
|
filesystem,
|
|
114
114
|
camera,
|
|
115
115
|
microphone,
|
|
116
|
+
system_audio,
|
|
116
117
|
location,
|
|
117
118
|
notifications,
|
|
118
119
|
clipboard,
|
|
@@ -129,6 +130,7 @@ pub const Permission = union(PermissionKind) {
|
|
|
129
130
|
filesystem: void,
|
|
130
131
|
camera: void,
|
|
131
132
|
microphone: void,
|
|
133
|
+
system_audio: void,
|
|
132
134
|
location: void,
|
|
133
135
|
notifications: void,
|
|
134
136
|
clipboard: void,
|
|
@@ -147,7 +147,7 @@ fn allTextSpansHaveColor(widget: canvas.Widget, color: canvas.TextSpanColor) boo
|
|
|
147
147
|
fn expectCodeTabInsertion(source: []const u8, expected: []const u8) !void {
|
|
148
148
|
const edit = canvas.widgetCodeTabTextEditEvent(.{
|
|
149
149
|
.kind = .textarea,
|
|
150
|
-
.code_editor = true,
|
|
150
|
+
.runtime_flags = .{ .code_editor = true },
|
|
151
151
|
.text = source,
|
|
152
152
|
}, .{
|
|
153
153
|
.phase = .key_down,
|
|
@@ -958,7 +958,7 @@ test "line number gutter reserves at least three marker columns" {
|
|
|
958
958
|
const tokens = canvas.DesignTokens{};
|
|
959
959
|
var numbered = canvas.Widget{
|
|
960
960
|
.kind = .textarea,
|
|
961
|
-
.code_editor = true,
|
|
961
|
+
.runtime_flags = .{ .code_editor = true },
|
|
962
962
|
.code_line_number_digits = 1,
|
|
963
963
|
};
|
|
964
964
|
const one_digit_width = widget_metrics.widgetCodeLineNumberGutterWidth(numbered, tokens);
|
|
@@ -1259,7 +1259,7 @@ test "numbered editable code does not invent trailing horizontal overflow" {
|
|
|
1259
1259
|
const tokens = canvas.DesignTokens{};
|
|
1260
1260
|
var editor = canvas.Widget{
|
|
1261
1261
|
.kind = .textarea,
|
|
1262
|
-
.code_editor = true,
|
|
1262
|
+
.runtime_flags = .{ .code_editor = true },
|
|
1263
1263
|
.code_line_number_digits = 2,
|
|
1264
1264
|
.text_no_wrap = true,
|
|
1265
1265
|
.text = source,
|
|
@@ -1301,7 +1301,7 @@ test "editable code caches one batched longest-line measurement across geometry
|
|
|
1301
1301
|
const tokens = canvas.DesignTokens{ .text_measure = &provider };
|
|
1302
1302
|
var editor = canvas.Widget{
|
|
1303
1303
|
.kind = .textarea,
|
|
1304
|
-
.code_editor = true,
|
|
1304
|
+
.runtime_flags = .{ .code_editor = true },
|
|
1305
1305
|
.text_no_wrap = true,
|
|
1306
1306
|
.text = source.items,
|
|
1307
1307
|
.frame = geometry.RectF.init(0, 0, 240, 80),
|
|
@@ -1445,7 +1445,7 @@ test "editable code Tab infers the file indentation and falls back to two spaces
|
|
|
1445
1445
|
}) == null);
|
|
1446
1446
|
try testing.expect(canvas.widgetCodeTabTextEditEvent(.{
|
|
1447
1447
|
.kind = .textarea,
|
|
1448
|
-
.code_editor = true,
|
|
1448
|
+
.runtime_flags = .{ .code_editor = true },
|
|
1449
1449
|
.text = "code",
|
|
1450
1450
|
}, .{
|
|
1451
1451
|
.phase = .key_down,
|
|
@@ -1454,7 +1454,7 @@ test "editable code Tab infers the file indentation and falls back to two spaces
|
|
|
1454
1454
|
}) == null);
|
|
1455
1455
|
try testing.expect(canvas.widgetCodeTabTextEditEvent(.{
|
|
1456
1456
|
.kind = .textarea,
|
|
1457
|
-
.code_editor = true,
|
|
1457
|
+
.runtime_flags = .{ .code_editor = true },
|
|
1458
1458
|
.text = "code",
|
|
1459
1459
|
}, .{
|
|
1460
1460
|
.phase = .key_down,
|
|
@@ -1642,7 +1642,7 @@ test "direct tree code emission honors scroll viewports and later layout pages"
|
|
|
1642
1642
|
.id = 1,
|
|
1643
1643
|
.kind = .scroll_view,
|
|
1644
1644
|
.frame = geometry.RectF.init(0, 0, 320, 80),
|
|
1645
|
-
.native_scroll = true,
|
|
1645
|
+
.runtime_flags = .{ .native_scroll = true },
|
|
1646
1646
|
.children = &horizontal_children,
|
|
1647
1647
|
};
|
|
1648
1648
|
var horizontal_commands: [64]canvas.CanvasCommand = undefined;
|
|
@@ -1669,7 +1669,7 @@ test "direct tree code emission honors scroll viewports and later layout pages"
|
|
|
1669
1669
|
.id = 3,
|
|
1670
1670
|
.kind = .scroll_view,
|
|
1671
1671
|
.frame = geometry.RectF.init(0, 0, 100, 100),
|
|
1672
|
-
.native_scroll = true,
|
|
1672
|
+
.runtime_flags = .{ .native_scroll = true },
|
|
1673
1673
|
.children = &vertical_children,
|
|
1674
1674
|
};
|
|
1675
1675
|
var vertical_commands: [64]canvas.CanvasCommand = undefined;
|
|
@@ -1709,7 +1709,7 @@ test "editable code highlights the visible tail of a ten-thousand-line source" {
|
|
|
1709
1709
|
.height = 100,
|
|
1710
1710
|
}, source.items));
|
|
1711
1711
|
var editor = findByText(view.root, source.items).?;
|
|
1712
|
-
try testing.expect(editor.code_editor);
|
|
1712
|
+
try testing.expect(editor.runtime_flags.code_editor);
|
|
1713
1713
|
try testing.expectEqual(code_model.Language.css, editor.code_language);
|
|
1714
1714
|
try testing.expectEqual(@as(usize, 1), editor.spans.len);
|
|
1715
1715
|
try testing.expectEqual(@as(u8, 5), editor.code_line_number_digits);
|
|
@@ -118,19 +118,20 @@ pub const WidgetKeyboardEvent = struct {
|
|
|
118
118
|
}
|
|
119
119
|
};
|
|
120
120
|
|
|
121
|
-
/// Enter in a multi-line editor EDITS instead of submitting
|
|
122
|
-
///
|
|
123
|
-
///
|
|
124
|
-
/// primary-modifier chord (cmd/ctrl+Enter) is deliberately
|
|
125
|
-
///
|
|
126
|
-
/// app shortcuts. Single-line kinds return null here and
|
|
127
|
-
/// enter-to-submit. Shared by the runtime edit path and the app
|
|
128
|
-
/// dispatch so
|
|
129
|
-
pub fn widgetKeyboardNewlineTextEditEvent(
|
|
130
|
-
if (kind != .textarea) return null;
|
|
121
|
+
/// Enter in a multi-line editor normally EDITS instead of submitting.
|
|
122
|
+
/// A textarea with `submit_on_enter` reverses only the plain gesture:
|
|
123
|
+
/// Enter is left for its submit handler while Shift+Enter stays a
|
|
124
|
+
/// newline. The primary-modifier chord (cmd/ctrl+Enter) is deliberately
|
|
125
|
+
/// excluded — it is always a textarea submit chord — as is alt+Enter,
|
|
126
|
+
/// left free for app shortcuts. Single-line kinds return null here and
|
|
127
|
+
/// keep enter-to-submit. Shared by the runtime edit path and the app
|
|
128
|
+
/// `on_input` dispatch so retained text and the model hear the same edit.
|
|
129
|
+
pub fn widgetKeyboardNewlineTextEditEvent(widget: Widget, event: WidgetKeyboardEvent) ?TextInputEvent {
|
|
130
|
+
if (widget.kind != .textarea) return null;
|
|
131
131
|
if (event.phase != .key_down or event.text.len != 0) return null;
|
|
132
132
|
if (event.modifiers.control or event.modifiers.alt or event.modifiers.super) return null;
|
|
133
133
|
if (!std.ascii.eqlIgnoreCase(event.key, "enter") and !std.ascii.eqlIgnoreCase(event.key, "return")) return null;
|
|
134
|
+
if (widget.submit_on_enter and !event.modifiers.shift) return null;
|
|
134
135
|
return .{ .insert_text = "\n" };
|
|
135
136
|
}
|
|
136
137
|
|
|
@@ -140,7 +141,7 @@ pub fn widgetKeyboardNewlineTextEditEvent(kind: WidgetKind, event: WidgetKeyboar
|
|
|
140
141
|
/// wider width winning exact ties (4-space files also divide by 2).
|
|
141
142
|
/// Ambiguous or unindented source falls back to two spaces.
|
|
142
143
|
pub fn widgetCodeTabTextEditEvent(widget: Widget, event: WidgetKeyboardEvent) ?TextInputEvent {
|
|
143
|
-
if (widget.kind != .textarea or !widget.code_editor or widget.state.disabled) return null;
|
|
144
|
+
if (widget.kind != .textarea or !widget.runtime_flags.code_editor or widget.state.disabled) return null;
|
|
144
145
|
if (event.phase != .key_down or event.focus_moved or event.text.len != 0) return null;
|
|
145
146
|
if (event.modifiers.shift or event.modifiers.hasNavigationModifier()) return null;
|
|
146
147
|
if (!std.ascii.eqlIgnoreCase(event.key, "tab")) return null;
|
|
@@ -457,6 +457,11 @@ pub const CanvasFrameOptions = struct {
|
|
|
457
457
|
timestamp_ns: u64 = 0,
|
|
458
458
|
surface_size: geometry.SizeF = .{},
|
|
459
459
|
scale: f32 = 1,
|
|
460
|
+
/// Renderer-specific read support relative to `Blur.radius`. The
|
|
461
|
+
/// reference and Windows renderers consume one radius; AppKit's
|
|
462
|
+
/// three-box Gaussian consumes at most three. Runtime-owned frame
|
|
463
|
+
/// planning sets this from the active platform.
|
|
464
|
+
backdrop_blur_sample_extent_multiplier: f32 = 1,
|
|
460
465
|
full_repaint: bool = false,
|
|
461
466
|
budget: CanvasFrameBudget = .{},
|
|
462
467
|
previous_pipeline_cache: []const RenderPipelineCacheEntry = &.{},
|
|
@@ -615,7 +620,11 @@ pub fn buildCanvasFrame(previous: ?DisplayList, next: DisplayList, options: Canv
|
|
|
615
620
|
// pixels so a fractional dirty edge cannot erase an unchanged
|
|
616
621
|
// neighbor's boundary-pixel coverage without redrawing it.
|
|
617
622
|
dirty_bounds = bleedAlignedDirtyBounds(unionOptionalBounds(dirtyBoundsFromChanges(changes), render_override_dirty_bounds), options.scale, 1, options.surface_size);
|
|
618
|
-
if (
|
|
623
|
+
if (incrementalDamageIntersectsBackdropBlurWithSampleExtent(
|
|
624
|
+
render_plan.commands,
|
|
625
|
+
dirty_bounds,
|
|
626
|
+
options.backdrop_blur_sample_extent_multiplier,
|
|
627
|
+
)) {
|
|
619
628
|
// A backdrop blur reads pixels around its output from the
|
|
620
629
|
// destination as it existed at this point in draw order.
|
|
621
630
|
// Retained pixels outside an incremental scissor already
|
|
@@ -666,8 +675,23 @@ pub fn buildCanvasFrame(previous: ?DisplayList, next: DisplayList, options: Canv
|
|
|
666
675
|
/// outside the scissor hold the previous fully composited frame rather
|
|
667
676
|
/// than the backdrop at the blur command's position in draw order.
|
|
668
677
|
pub fn incrementalDamageIntersectsBackdropBlur(commands: []const RenderCommand, dirty_bounds: ?geometry.RectF) bool {
|
|
678
|
+
return incrementalDamageIntersectsBackdropBlurWithSampleExtent(commands, dirty_bounds, 1);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/// Backend-aware form of `incrementalDamageIntersectsBackdropBlur`. Values
|
|
682
|
+
/// below one are normalized to the shared one-radius floor; wider renderers
|
|
683
|
+
/// pass their conservative maximum sampling support.
|
|
684
|
+
pub fn incrementalDamageIntersectsBackdropBlurWithSampleExtent(
|
|
685
|
+
commands: []const RenderCommand,
|
|
686
|
+
dirty_bounds: ?geometry.RectF,
|
|
687
|
+
requested_sample_extent_multiplier: f32,
|
|
688
|
+
) bool {
|
|
669
689
|
const dirty = dirty_bounds orelse return false;
|
|
670
690
|
const normalized_dirty = dirty.normalized();
|
|
691
|
+
const sample_extent_multiplier = if (std.math.isFinite(requested_sample_extent_multiplier))
|
|
692
|
+
@max(1, requested_sample_extent_multiplier)
|
|
693
|
+
else
|
|
694
|
+
1;
|
|
671
695
|
for (commands) |command| {
|
|
672
696
|
switch (command.command) {
|
|
673
697
|
.blur => |blur| {
|
|
@@ -677,14 +701,25 @@ pub fn incrementalDamageIntersectsBackdropBlur(commands: []const RenderCommand,
|
|
|
677
701
|
if (output.isEmpty()) continue;
|
|
678
702
|
|
|
679
703
|
// Do not use `command.bounds` here: the render planner
|
|
680
|
-
// intersects that inflated bound with the output
|
|
681
|
-
// while a clipped output pixel still samples backdrop
|
|
682
|
-
//
|
|
683
|
-
//
|
|
684
|
-
//
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
704
|
+
// intersects that radius-inflated bound with the output
|
|
705
|
+
// clip, while a clipped output pixel still samples backdrop
|
|
706
|
+
// outside the clip. Preserve the established local-radius
|
|
707
|
+
// footprint for one-radius renderers. Wider renderers operate
|
|
708
|
+
// on the transformed output with an isotropic device-space
|
|
709
|
+
// kernel, so scale their support by the transform's largest
|
|
710
|
+
// axis before inflating that output.
|
|
711
|
+
const read_footprint = if (sample_extent_multiplier == 1)
|
|
712
|
+
command.transform.transformRect(
|
|
713
|
+
blur.rect.normalized().inflate(geometry.InsetsF.all(@max(0, blur.radius))),
|
|
714
|
+
).normalized()
|
|
715
|
+
else extended: {
|
|
716
|
+
const transform = command.transform;
|
|
717
|
+
const x_scale = @sqrt(transform.a * transform.a + transform.b * transform.b);
|
|
718
|
+
const y_scale = @sqrt(transform.c * transform.c + transform.d * transform.d);
|
|
719
|
+
const transform_scale = @max(0.0001, @max(x_scale, y_scale));
|
|
720
|
+
const sample_extent = @max(0, blur.radius) * transform_scale * sample_extent_multiplier;
|
|
721
|
+
break :extended output.normalized().inflate(geometry.InsetsF.all(sample_extent));
|
|
722
|
+
};
|
|
688
723
|
if (read_footprint.intersects(normalized_dirty)) return true;
|
|
689
724
|
},
|
|
690
725
|
else => {},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="22"/><line x1="8" y1="22" x2="16" y2="22"/></svg>
|
|
@@ -67,6 +67,7 @@ const git_merge = builtin("git-merge");
|
|
|
67
67
|
const git_pull_request = builtin("git-pull-request");
|
|
68
68
|
const info = builtin("info");
|
|
69
69
|
const menu = builtin("menu");
|
|
70
|
+
const mic = builtin("mic");
|
|
70
71
|
const moon = builtin("moon");
|
|
71
72
|
const music = builtin("music");
|
|
72
73
|
const panel_left = builtin("panel-left");
|
|
@@ -121,6 +122,7 @@ pub const entries = [_]Entry{
|
|
|
121
122
|
.{ .name = "git-pull-request", .icon = &git_pull_request },
|
|
122
123
|
.{ .name = "info", .icon = &info },
|
|
123
124
|
.{ .name = "menu", .icon = &menu },
|
|
125
|
+
.{ .name = "mic", .icon = &mic },
|
|
124
126
|
.{ .name = "moon", .icon = &moon },
|
|
125
127
|
.{ .name = "music", .icon = &music },
|
|
126
128
|
.{ .name = "panel-left", .icon = &panel_left },
|
|
@@ -299,6 +299,7 @@ pub const CanvasFrame = frame_model.CanvasFrame;
|
|
|
299
299
|
pub const max_canvas_frame_dirty_rects = frame_model.max_canvas_frame_dirty_rects;
|
|
300
300
|
pub const buildCanvasFrame = frame_model.buildCanvasFrame;
|
|
301
301
|
pub const incrementalDamageIntersectsBackdropBlur = frame_model.incrementalDamageIntersectsBackdropBlur;
|
|
302
|
+
pub const incrementalDamageIntersectsBackdropBlurWithSampleExtent = frame_model.incrementalDamageIntersectsBackdropBlurWithSampleExtent;
|
|
302
303
|
|
|
303
304
|
// Canvas GPU packet and encoder data live in `gpu.zig`; root keeps the public API stable.
|
|
304
305
|
pub const CanvasRenderPassLoadAction = gpu_model.CanvasRenderPassLoadAction;
|
|
@@ -425,6 +426,7 @@ pub const DesignTokens = token_model.DesignTokens;
|
|
|
425
426
|
pub const WidgetKind = widget_model.WidgetKind;
|
|
426
427
|
pub const WidgetCursor = widget_model.WidgetCursor;
|
|
427
428
|
pub const WidgetState = widget_model.WidgetState;
|
|
429
|
+
pub const WidgetRuntimeFlags = widget_model.WidgetRuntimeFlags;
|
|
428
430
|
pub const WidgetLayoutMotion = widget_model.WidgetLayoutMotion;
|
|
429
431
|
pub const WidgetRenderState = widget_model.WidgetRenderState;
|
|
430
432
|
pub const WidgetMainAlignment = widget_model.WidgetMainAlignment;
|
|
@@ -740,6 +742,12 @@ pub const cursorForWidgetTarget = widget_runtime.cursorForWidgetTarget;
|
|
|
740
742
|
/// widget-level predicate is `widgetIsHitTarget`, which also admits any
|
|
741
743
|
/// widget carrying a bound press/toggle handler.
|
|
742
744
|
pub const widgetKindHitTarget = @import("widget_access.zig").widgetKindHitTarget;
|
|
745
|
+
/// Widget-level keyboard focusability without geometry/ancestor-clip
|
|
746
|
+
/// filtering. Runtime roving-focus groups use this to identify a logical
|
|
747
|
+
/// offscreen successor before scrolling it into view; ordinary focus
|
|
748
|
+
/// traversal still goes through `WidgetLayoutTree.focusTarget*`, which
|
|
749
|
+
/// rejects clipped targets.
|
|
750
|
+
pub const widgetIsFocusable = @import("widget_access.zig").isFocusable;
|
|
743
751
|
/// Widget-level hit-target-ness: kind-level `widgetKindHitTarget` plus
|
|
744
752
|
/// any widget with a bound press/toggle handler (stamped into
|
|
745
753
|
/// `semantics.actions` by the builder and both markup engines).
|
|
@@ -247,6 +247,45 @@ test "a later visual-line page retains an over-capacity wrapped paragraph" {
|
|
|
247
247
|
try testing.expect(!later.truncated);
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
test "ordinary span paragraphs paint a visible page after the line cap" {
|
|
251
|
+
const source = ("x\n" ** 139) ++ "TAIL_SENTINEL";
|
|
252
|
+
const spans = [_]TextSpan{.{ .text = source }};
|
|
253
|
+
const tokens = canvas.DesignTokens{};
|
|
254
|
+
const line_height = tokens.typography.body_size * 1.25;
|
|
255
|
+
const children = [_]canvas.Widget{.{
|
|
256
|
+
.id = 2,
|
|
257
|
+
.kind = .text,
|
|
258
|
+
// Put the final visual lines inside the scroll viewport while the
|
|
259
|
+
// first 128-line storage page is far above it.
|
|
260
|
+
.frame = geometry.RectF.init(0, -(139 * line_height) + 20, 100, 140 * line_height),
|
|
261
|
+
.text = source,
|
|
262
|
+
.spans = &spans,
|
|
263
|
+
}};
|
|
264
|
+
const root = canvas.Widget{
|
|
265
|
+
.id = 1,
|
|
266
|
+
.kind = .scroll_view,
|
|
267
|
+
.frame = geometry.RectF.init(0, 0, 100, 100),
|
|
268
|
+
.runtime_flags = .{ .native_scroll = true },
|
|
269
|
+
.children = &children,
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
var commands: [256]canvas.CanvasCommand = undefined;
|
|
273
|
+
var builder = canvas.Builder.init(&commands);
|
|
274
|
+
try canvas.emitWidgetTree(&builder, root, tokens);
|
|
275
|
+
|
|
276
|
+
var saw_tail = false;
|
|
277
|
+
var text_commands: usize = 0;
|
|
278
|
+
for (builder.displayList().commands) |command| {
|
|
279
|
+
if (command != .draw_text) continue;
|
|
280
|
+
text_commands += 1;
|
|
281
|
+
if (std.mem.indexOf(u8, command.draw_text.text, "TAIL_") != null) saw_tail = true;
|
|
282
|
+
}
|
|
283
|
+
try testing.expect(saw_tail);
|
|
284
|
+
// Viewport paging should not charge the 128 offscreen runs to the
|
|
285
|
+
// display list merely to reach the tail.
|
|
286
|
+
try testing.expect(text_commands < 16);
|
|
287
|
+
}
|
|
288
|
+
|
|
250
289
|
const VariableClusterMeasure = struct {
|
|
251
290
|
fn advance(text: []const u8) f32 {
|
|
252
291
|
return switch (text[0]) {
|
|
@@ -605,6 +605,12 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
605
605
|
/// re-steals focus from the user. Only focusable widgets
|
|
606
606
|
/// (interactive controls) can take it.
|
|
607
607
|
autofocus: bool = false,
|
|
608
|
+
/// Textarea Enter policy (markup `submit-on-enter`): plain
|
|
609
|
+
/// Enter submits through `on_submit`, while Shift+Enter
|
|
610
|
+
/// keeps the multiline newline path. False preserves the
|
|
611
|
+
/// default textarea contract (Enter inserts; primary+Enter
|
|
612
|
+
/// submits). Meaningless on every other element.
|
|
613
|
+
submit_on_enter: bool = false,
|
|
608
614
|
variant: canvas.WidgetVariant = .default,
|
|
609
615
|
size: canvas.WidgetSize = .default,
|
|
610
616
|
/// Definite width: the widget is exactly this wide (the value
|
|
@@ -620,6 +626,11 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
620
626
|
/// Split panes use it to constrain the divider drag (the
|
|
621
627
|
/// clamp band derives from both panes' floors).
|
|
622
628
|
min_width: f32 = 0,
|
|
629
|
+
/// Width ceiling WITHOUT the definite-min side of `width`:
|
|
630
|
+
/// the widget fills or hugs normally until this bound, then
|
|
631
|
+
/// stops growing. Pair with a centered flex parent for a
|
|
632
|
+
/// responsive content column.
|
|
633
|
+
max_width: f32 = 0,
|
|
623
634
|
grow: f32 = 0,
|
|
624
635
|
gap: f32 = 0,
|
|
625
636
|
padding: ?f32 = null,
|
|
@@ -1469,7 +1480,7 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
1469
1480
|
if (self.msgForTextEdit(target_id, stamped)) |msg| return msg;
|
|
1470
1481
|
} else {
|
|
1471
1482
|
const locally_derived = canvas.widgetCodeTabTextEditEvent(widget, keyboard) orelse
|
|
1472
|
-
canvas.widgetKeyboardNewlineTextEditEvent(widget
|
|
1483
|
+
canvas.widgetKeyboardNewlineTextEditEvent(widget, keyboard) orelse
|
|
1473
1484
|
keyboard.textEditEvent();
|
|
1474
1485
|
if (locally_derived) |text_edit| {
|
|
1475
1486
|
// Direct Tree consumers still sanitize locally:
|
|
@@ -2456,7 +2467,7 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
2456
2467
|
else
|
|
2457
2468
|
0;
|
|
2458
2469
|
if (diff_lines) |lines| editor.widget.setCodeDiffLines(lines);
|
|
2459
|
-
editor.widget.code_editor = true;
|
|
2470
|
+
editor.widget.runtime_flags.code_editor = true;
|
|
2460
2471
|
editor.widget.code_language = options.language;
|
|
2461
2472
|
editor.widget.layout.clip_content = true;
|
|
2462
2473
|
return editor;
|
|
@@ -3690,6 +3701,7 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3690
3701
|
.text_alignment = options.text_alignment,
|
|
3691
3702
|
.text_overflow = options.overflow,
|
|
3692
3703
|
.autofocus = options.autofocus,
|
|
3704
|
+
.submit_on_enter = options.submit_on_enter,
|
|
3693
3705
|
.image_id = options.image,
|
|
3694
3706
|
.value = options.value,
|
|
3695
3707
|
.value_x = options.value_x,
|
|
@@ -3728,7 +3740,10 @@ pub fn Ui(comptime Msg: type) type {
|
|
|
3728
3740
|
// is the exception: width documents the initial width
|
|
3729
3741
|
// and the engine's drag handle keeps writing larger
|
|
3730
3742
|
// frames past it.
|
|
3731
|
-
.max_size = if (kind == .resizable) .{} else .{
|
|
3743
|
+
.max_size = if (kind == .resizable) .{} else .{
|
|
3744
|
+
.width = if (options.width > 0) options.width else options.max_width,
|
|
3745
|
+
.height = options.height,
|
|
3746
|
+
},
|
|
3732
3747
|
},
|
|
3733
3748
|
.style = options.style,
|
|
3734
3749
|
.semantics = options.semantics,
|
|
@@ -3825,7 +3840,11 @@ fn isSubmitKeyboard(widget: Widget, keyboard: canvas.WidgetKeyboardEvent) bool {
|
|
|
3825
3840
|
// Multi-line entry: Enter edits (newline), so submit rides the
|
|
3826
3841
|
// primary chord — cmd+Enter on macOS, ctrl+Enter elsewhere.
|
|
3827
3842
|
// Shift/alt variants stay free for apps.
|
|
3828
|
-
.textarea =>
|
|
3843
|
+
.textarea => if (widget.submit_on_enter)
|
|
3844
|
+
(!keyboard.modifiers.hasNavigationModifier() and !keyboard.modifiers.shift) or
|
|
3845
|
+
(keyboard.modifiers.hasCommandModifier() and !keyboard.modifiers.alt and !keyboard.modifiers.shift)
|
|
3846
|
+
else
|
|
3847
|
+
keyboard.modifiers.hasCommandModifier() and !keyboard.modifiers.alt and !keyboard.modifiers.shift,
|
|
3829
3848
|
// List rows: plain Enter is the row's primary action when the
|
|
3830
3849
|
// app binds `on_submit` (play the track, open the record); the
|
|
3831
3850
|
// select activation keeps Space. `msgForKeyboard` resolves the
|
|
@@ -1175,6 +1175,8 @@ pub fn deadHandlerOnNonHitTarget(attr_name: []const u8) bool {
|
|
|
1175
1175
|
|
|
1176
1176
|
pub const autofocus_element_message = "autofocus is only supported on focusable controls (text fields, buttons, checkboxes, ...) - it moves keyboard focus to the element when it mounts or when the flag turns on, and nothing about this element can take focus";
|
|
1177
1177
|
|
|
1178
|
+
pub const submit_on_enter_element_message = "submit-on-enter is only supported on textarea - it makes plain Enter dispatch on-submit while Shift+Enter inserts a newline; single-line fields already submit on Enter, and other elements have no multiline Enter policy";
|
|
1179
|
+
|
|
1178
1180
|
pub const non_hit_target_handler_message = "on-change/on-submit/on-input never fire here: this element has no control or text behavior - put them on a control (input, checkbox, slider) inside it (on-press/on-double-press/on-toggle are fine anywhere: a bound press handler makes any element pressable, and clicks on plain text or icons inside it fall through to it)";
|
|
1179
1181
|
|
|
1180
1182
|
/// Elements whose widget kind layers its children on top of each other
|
|
@@ -3281,6 +3283,19 @@ fn validateNode(document: MarkupDocument, node: MarkupNode, parent_element: ?[]c
|
|
|
3281
3283
|
}
|
|
3282
3284
|
continue;
|
|
3283
3285
|
}
|
|
3286
|
+
if (std.mem.eql(u8, attribute.name, "submit-on-enter")) {
|
|
3287
|
+
// Only textarea has two meaningful Enter gestures:
|
|
3288
|
+
// submit or insert a newline. Single-line fields
|
|
3289
|
+
// already submit on plain Enter, and the option would
|
|
3290
|
+
// be dead on every other kind.
|
|
3291
|
+
if (!std.mem.eql(u8, node.name, "textarea")) {
|
|
3292
|
+
return attrError(node, attribute, submit_on_enter_element_message);
|
|
3293
|
+
}
|
|
3294
|
+
if (attrExpressionError(attribute.value, invalid_expression_message)) |message| {
|
|
3295
|
+
return attrError(node, attribute, message);
|
|
3296
|
+
}
|
|
3297
|
+
continue;
|
|
3298
|
+
}
|
|
3284
3299
|
if (std.mem.eql(u8, attribute.name, "icon")) {
|
|
3285
3300
|
// Inline vector icon, scoped to the labeled
|
|
3286
3301
|
// interactive elements that render it themselves
|
|
@@ -373,6 +373,15 @@ fn CompiledMarkupEngine(comptime ModelT: type, comptime MsgT: type, comptime res
|
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
|
+
// Interpreter parity: only textarea has a configurable
|
|
377
|
+
// Enter-vs-newline policy.
|
|
378
|
+
if (kind != .textarea) {
|
|
379
|
+
for (node.attrs) |attribute| {
|
|
380
|
+
if (std.mem.eql(u8, attribute.name, "submit-on-enter")) {
|
|
381
|
+
fail(node, markup.submit_on_enter_element_message);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
376
385
|
// Interpreter parity: the overflow policy's closed
|
|
377
386
|
// literal vocabulary. A compile error here; bindings
|
|
378
387
|
// resolve at runtime like any enum option.
|
|
@@ -1158,7 +1158,7 @@ test "compiled code element matches the interpreter and Ui.code" {
|
|
|
1158
1158
|
try expectSameTree(fixture.CodeMsg, editable_hand, editable_interpreted);
|
|
1159
1159
|
try expectSameTree(fixture.CodeMsg, editable_hand, editable_compiled);
|
|
1160
1160
|
try testing.expectEqual(canvas.WidgetKind.textarea, editable_compiled.root.kind);
|
|
1161
|
-
try testing.expect(editable_compiled.root.code_editor);
|
|
1161
|
+
try testing.expect(editable_compiled.root.runtime_flags.code_editor);
|
|
1162
1162
|
}
|
|
1163
1163
|
|
|
1164
1164
|
// ------------------------------------------- template/use + style parity
|