@skathi-native/cli 0.1.0-beta.4 → 0.3.0

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 (63) hide show
  1. package/aot/host-globals.json +1 -1
  2. package/aot/pin.ts +1 -1
  3. package/aot/toolchain.lock.json +5 -5
  4. package/aot/transform.ts +9 -1
  5. package/aot-inputs.ts +21 -2
  6. package/build.ts +284 -64
  7. package/check/builtins.json +11 -11
  8. package/check/bundle.ts +265 -0
  9. package/check/codes.ts +46 -0
  10. package/check/css-catalog.json +451 -0
  11. package/check/css.ts +512 -0
  12. package/check/finding.ts +63 -1
  13. package/check/graph.ts +14 -1
  14. package/check/index.ts +30 -49
  15. package/check/program.ts +26 -6
  16. package/cli/aot-build.ts +2 -6
  17. package/cli/build-app.ts +19 -0
  18. package/cli/create.ts +70 -12
  19. package/cli/dev.ts +11 -6
  20. package/cli/effects.ts +39 -18
  21. package/cli/gallery.ts +106 -0
  22. package/cli/sk.ts +5 -2
  23. package/devtools/commands.ts +26 -1
  24. package/devtools/ctl.ts +4 -3
  25. package/effects/compile.ts +160 -31
  26. package/effects/sk.slang +359 -30
  27. package/gallery.json +1 -0
  28. package/package.json +9 -5
  29. package/prod.ts +78 -10
  30. package/svelte.ts +76 -0
  31. package/templates/icon.png +0 -0
  32. package/templates/showcase/assets/textures/golden.png +0 -0
  33. package/templates/showcase/assets/textures/hammered.png +0 -0
  34. package/templates/showcase/assets/textures/noir.png +0 -0
  35. package/templates/showcase/assets/textures/reeded.png +0 -0
  36. package/templates/showcase/assets/textures/teal-orange.png +0 -0
  37. package/templates/showcase/shaders/dissolve.slang +40 -0
  38. package/templates/showcase/shaders/fireflies.slang +58 -0
  39. package/templates/showcase/shaders/glass.slang +31 -0
  40. package/templates/showcase/shaders/grade.slang +34 -0
  41. package/templates/showcase/shaders/halftone.slang +42 -0
  42. package/templates/showcase/shaders/lens.slang +51 -0
  43. package/templates/showcase/shaders/nebula.slang +57 -0
  44. package/templates/showcase/shaders/orbit.slang +52 -0
  45. package/templates/showcase/shaders/pond.slang +76 -0
  46. package/templates/showcase/shaders/ripples.slang +71 -0
  47. package/templates/showcase/shaders/shatter.slang +116 -0
  48. package/templates/showcase/shaders/snow.slang +57 -0
  49. package/templates/showcase/shaders/spotlight.slang +52 -0
  50. package/templates/showcase/src/App.vue +11 -16
  51. package/templates/showcase/src/components/FullWindow.vue +77 -0
  52. package/templates/showcase/src/components/Page.vue +2 -0
  53. package/templates/showcase/src/fullwindow.ts +36 -0
  54. package/templates/showcase/src/icons.ts +2 -0
  55. package/templates/showcase/src/pages/GraphicsPage.vue +122 -0
  56. package/templates/showcase/src/pages/MotionPage.vue +71 -1
  57. package/templates/showcase/src/pages/ShadersPage.vue +443 -0
  58. package/templates/showcase/src/router.ts +32 -1
  59. package/templates/svelte/.vscode/settings.json +3 -0
  60. package/templates/svelte/assets/hello.txt +1 -0
  61. package/templates/svelte/src/App.svelte +142 -0
  62. package/templates/svelte/src/main.ts +4 -0
  63. package/vitecompat.ts +2 -0
package/effects/sk.slang CHANGED
@@ -34,7 +34,8 @@
34
34
  // the engine draws a premultiplied result (see `sk_finish`).
35
35
  // * Effects compile at `ps_5_0`; the rest of gpui stays at `ps_4_1`.
36
36
  // * An effect declares no textures, samplers or buffers: it reads
37
- // `EffectInput` and its own fields, nothing else.
37
+ // `EffectInput` and its own fields, nothing else. An image is a field
38
+ // too: `SkTexture lut;`, `url(...)` in CSS.
38
39
 
39
40
  module sk;
40
41
 
@@ -66,6 +67,62 @@ public struct SkBackdropAttribute
66
67
  {
67
68
  };
68
69
 
70
+ /// This effect shades its element's OWN painting: `input.content`,
71
+ /// `contentAt`, `contentAtPx`. The element and its whole subtree (background,
72
+ /// border, shadows, outline, children, text, video, carets, animations) paint
73
+ /// into an offscreen group the size of the window, at full opacity, and the
74
+ /// effect is drawn in their place; what it returns is all that shows of them.
75
+ ///
76
+ /// * The drawn quad is the border box, dilated by a `[SkBleed]` parameter:
77
+ /// content can be moved out to it (a box-shadow outside the box shows only
78
+ /// there). Sampling anywhere else in the window is allowed and reads
79
+ /// transparent where the element painted nothing.
80
+ /// * `opacity` applies once, to the result; the content is opaque in the
81
+ /// group. `overflow` clips of ancestors cut the result like any effect's.
82
+ /// * A transform moves the content and the quad together; a rotation or skew
83
+ /// cannot be drawn by an effect, and the element then shows unshaded.
84
+ /// * Hit testing is unchanged: it follows layout, never pixels.
85
+ /// * The group is a Backdrop Root: a `backdrop-filter` or backdrop effect
86
+ /// inside it sees the element's own painting, not the page. The element's
87
+ /// own `backdrop-filter` still reads the page. With `[SkBackdrop]` too, the
88
+ /// effect owns its quad and composites the content over the backdrop
89
+ /// itself (`sk_over(input.backdrop, input.content)`).
90
+ /// * Cost: one window-sized offscreen target per nesting depth (pooled,
91
+ /// released after 90 idle frames) and the subtree drawn into it every
92
+ /// frame the window paints.
93
+ [__AttributeUsage(_AttributeTargets.Struct)]
94
+ public struct SkContentAttribute
95
+ {
96
+ };
97
+
98
+ /// This effect keeps state from frame to frame: `input.history`,
99
+ /// `historyAt`, `historyAtPx` read what it stored the last time it stepped,
100
+ /// per element and effect. The history is two RGBA 16-bit float textures the
101
+ /// size of the drawn quad in device pixels (16 bytes a pixel), zero when the
102
+ /// element first draws, started over when that size changes and freed the
103
+ /// first frame the element is not painted.
104
+ ///
105
+ /// Each step stores what `update` returns for every texel, unclamped; an
106
+ /// effect that does not declare `override float4 update(EffectInput input)`
107
+ /// stores what `shade` returned. Both
108
+ /// `shade` and `update` read the state as the LAST step left it, so the first
109
+ /// frame reads zeros. `update` runs with `input.historyPass` set and reads
110
+ /// content and history but never the backdrop.
111
+ ///
112
+ /// * A history steps at most once per painted frame and at most about 75
113
+ /// times a second, so a simulation runs at the same speed at 60 and 144
114
+ /// Hz. It only steps while the window repaints: animate the effect
115
+ /// (`[SkAnimated]`, `[SkAnimatedFor]`, or `[SkPointer]`, which repaints
116
+ /// on pointer moves) for as long as the state should keep changing.
117
+ /// * Limits: no history on a quad longer than 4096 device pixels on a side,
118
+ /// and at most 256 MiB of histories per window; past them it reads zeros.
119
+ /// * The element needs an identity to key its state by (every Skathi element
120
+ /// has one).
121
+ [__AttributeUsage(_AttributeTargets.Struct)]
122
+ public struct SkHistoryAttribute
123
+ {
124
+ };
125
+
69
126
  /// One line of author-facing documentation, echoed in CSS advisories.
70
127
  [__AttributeUsage(_AttributeTargets.Struct)]
71
128
  public struct SkDocAttribute
@@ -122,7 +179,7 @@ public struct SkOptionalAttribute
122
179
  {
123
180
  };
124
181
 
125
- /// Pins this parameter to an explicit slot in the 8-float parameter block,
182
+ /// Pins this parameter to an explicit slot in the 32-float parameter block,
126
183
  /// instead of letting the packer choose. Unpinned fields then fill the gaps in
127
184
  /// declaration order.
128
185
  ///
@@ -156,11 +213,57 @@ public struct SkBackdropRadiusAttribute
156
213
  /// `input.time` (a speed), so `speed: 0` costs nothing. At most one per
157
214
  /// effect; an effect with no `[SkAnimated]` parameter never repaints on its
158
215
  /// own.
216
+ ///
217
+ /// Use it only as a factor of `input.time` (`input.time * speed`): the host
218
+ /// integrates the speed per element and hands the shader the value that makes
219
+ /// that product the phase reached so far, so a change of speed (or a
220
+ /// transition of it) carries on from where the motion is instead of jumping.
159
221
  [__AttributeUsage(_AttributeTargets.Var)]
160
222
  public struct SkAnimatedAttribute
161
223
  {
162
224
  };
163
225
 
226
+ /// Every component of this parameter is a time on the effect clock (the
227
+ /// clock `input.time` reads, which is `performance.now() / 1000` in JS). The
228
+ /// window keeps repainting until `seconds` after the latest of them, then the
229
+ /// effect costs nothing until a parameter changes: hand it the time something
230
+ /// started instead of rewriting an age every frame.
231
+ [__AttributeUsage(_AttributeTargets.Var)]
232
+ public struct SkAnimatedForAttribute
233
+ {
234
+ public float seconds;
235
+ };
236
+
237
+ /// A `float2` the host fills with the pointer's position in `input.local`
238
+ /// units: 0..1 across the element, beyond that outside it, anywhere in the
239
+ /// window. The last position stays when the pointer leaves the window. Not a
240
+ /// CSS argument. The element repaints when the pointer moves, and only
241
+ /// elements whose effect has a pointer parameter do.
242
+ [__AttributeUsage(_AttributeTargets.Var)]
243
+ public struct SkPointerAttribute
244
+ {
245
+ };
246
+
247
+ /// On an `SkTexture`: the image is data (a normal map, noise, a LUT), sampled
248
+ /// as its file stores it — no premultiplication, alpha is just a fourth
249
+ /// channel. Without it the image is colour, sampled premultiplied in the same
250
+ /// sRGB-encoded space as `input.backdrop`.
251
+ [__AttributeUsage(_AttributeTargets.Var)]
252
+ public struct SkLinearAttribute
253
+ {
254
+ };
255
+
256
+ /// A `float3` the host fills with times on the effect clock: when the pointer
257
+ /// last moved in the window, when it last entered the window and when it last
258
+ /// left it. It is in the window while `y > z`; `sk_pointer_presence` turns
259
+ /// the three into a fade. Long ago (about -1e4) until it happens. Not a CSS
260
+ /// argument; repaints like `[SkPointer]`, and with `[SkAnimatedFor]` keeps
261
+ /// repainting for a fade after each of them.
262
+ [__AttributeUsage(_AttributeTargets.Var)]
263
+ public struct SkPointerTimesAttribute
264
+ {
265
+ };
266
+
164
267
  // ===========================================================================
165
268
  // The engine's binding contract
166
269
  // ===========================================================================
@@ -169,16 +272,23 @@ public struct SkAnimatedAttribute
169
272
  // for EVERY gpui pipeline, t0 is the processed backdrop (the Dual-Kawase
170
273
  // pyramid's top level), t2 the untouched render-target snapshot, b0 the shared
171
274
  // globals. s1 clamps — s0 wraps, which bleeds the opposite screen edge into
172
- // anything sampling near the border.
275
+ // anything sampling near the border. t3..t6 are an effect's `SkTexture`
276
+ // images and s2 the sampler that repeats them.
173
277
  //
174
278
  // They are declared HERE, in the module, rather than in a generated wrapper:
175
279
  // Slang keeps explicit `register()` annotations through the HLSL and Metal
176
280
  // backends (Metal: b0 buffer(0), t1 buffer(1), t0/t2 texture(0/2), s1
177
- // sampler(1)), so the module is the right home and an effect cannot move one.
281
+ // sampler(1), t3..t6 texture(3..6), s2 sampler(2)), so the module is the right
282
+ // home and an effect cannot move one.
178
283
  //
179
284
  // `[[vk::binding(binding, group)]]` is the same contract for the WGSL target,
180
285
  // matching the pipeline layout in gpui_wgpu: group 0 the globals, group 1 the
181
- // instance buffer, group 2 the backdrop textures and their sampler.
286
+ // instance buffer, group 2 the backdrop textures and their sampler, then the
287
+ // images at 3..6 and their sampler at 9.
288
+ //
289
+ // t7 is the element's content (`[SkContent]`), t8 its history (`[SkHistory]`):
290
+ // WGSL group 2 bindings 7 and 8, Metal texture(7) and texture(8). Every effect
291
+ // pipeline binds them, transparent when the effect has neither.
182
292
 
183
293
  public struct SkBounds
184
294
  {
@@ -194,12 +304,12 @@ public struct SkCorners
194
304
  public float bottom_left;
195
305
  };
196
306
 
197
- /// Keep in sync with `gpui::EffectQuad` (vendor/zed/crates/gpui/src/scene.rs),
307
+ /// Keep in sync with `gpui::EffectQuad` (vendor/gpui/crates/gpui/src/scene.rs),
198
308
  /// `struct EffectQuad` in gpui_windows/src/effects.hlsl and in
199
- /// gpui_wgpu/src/shaders_effects.wgsl. 32 words / 128 bytes.
309
+ /// gpui_wgpu/src/shaders_effects.wgsl. 56 words / 224 bytes.
200
310
  ///
201
- /// The parameter banks are `float[4]`, not `float4`: a WGSL storage buffer
202
- /// aligns a `vec4` to 16 bytes, which would move `params0` from offset 72 to 80.
311
+ /// The parameter block is `float[]`, not `float4`s: a WGSL storage buffer
312
+ /// aligns a `vec4` to 16 bytes, which would move it from offset 72 to 80.
203
313
  public struct SkEffectQuad
204
314
  {
205
315
  public uint order;
@@ -209,8 +319,7 @@ public struct SkEffectQuad
209
319
  /// The content mask's rounded corners; see `sk_content_mask_coverage`.
210
320
  public SkCorners content_mask_radii;
211
321
  public SkCorners corner_radii;
212
- public float params0[4];
213
- public float params1[4];
322
+ public float params[32];
214
323
  public float opacity;
215
324
  public float time;
216
325
  public float bleed;
@@ -227,6 +336,23 @@ public Texture2D<float4> sk_backdrop_input : register(t0);
227
336
  public Texture2D<float4> sk_backdrop_original : register(t2);
228
337
  [[vk::binding(1, 2)]]
229
338
  public SamplerState sk_clamp_sampler : register(s1);
339
+ [[vk::binding(7, 2)]]
340
+ public Texture2D<float4> sk_content : register(t7);
341
+ [[vk::binding(8, 2)]]
342
+ public Texture2D<float4> sk_history : register(t8);
343
+
344
+ // The images of `SkTexture` parameters, in declaration order, and the sampler
345
+ // that repeats them.
346
+ [[vk::binding(3, 2)]]
347
+ Texture2D<float4> sk_texture0 : register(t3);
348
+ [[vk::binding(4, 2)]]
349
+ Texture2D<float4> sk_texture1 : register(t4);
350
+ [[vk::binding(5, 2)]]
351
+ Texture2D<float4> sk_texture2 : register(t5);
352
+ [[vk::binding(6, 2)]]
353
+ Texture2D<float4> sk_texture3 : register(t6);
354
+ [[vk::binding(9, 2)]]
355
+ SamplerState sk_repeat_sampler : register(s2);
230
356
 
231
357
  /// Scalar padding rather than a `uint3`: WGSL aligns a `vec3` to 16 bytes and
232
358
  /// would grow the block from 48 to 64.
@@ -243,8 +369,11 @@ public cbuffer GlobalParams : register(b0)
243
369
  public uint sk_global_pad2;
244
370
  };
245
371
 
246
- /// Bit 0 of `SkEffectQuad::flags`.
372
+ /// Bits of `SkEffectQuad::flags`, `gpui::EFFECT_FLAG_*`.
247
373
  public static const uint SK_FLAG_NEEDS_BACKDROP = 1u;
374
+ public static const uint SK_FLAG_NEEDS_CONTENT = 2u;
375
+ public static const uint SK_FLAG_HISTORY = 4u;
376
+ public static const uint SK_FLAG_HISTORY_PASS = 8u;
248
377
 
249
378
 
250
379
  // ===========================================================================
@@ -264,9 +393,8 @@ public struct EffectInput
264
393
  public float2 px;
265
394
  /// Element box size in device pixels.
266
395
  public float2 size;
267
- /// The backdrop behind this quad, premultiplied. Blurred to
268
- /// `[SkBackdropRadius]` when the effect declares one, otherwise the raw
269
- /// snapshot. All zero for effects that did not ask for it.
396
+ /// The backdrop behind this pixel, premultiplied: `backdropAt(uv)`. All
397
+ /// zero for effects that did not ask for it.
270
398
  public float4 backdrop;
271
399
  /// Signed distance to the ELEMENT's rounded rect in device pixels:
272
400
  /// negative inside, 0 on the edge, positive outside.
@@ -274,7 +402,8 @@ public struct EffectInput
274
402
  /// Antialiased coverage of the element's rounded rect. 1 well inside,
275
403
  /// 0 well outside.
276
404
  public float coverage;
277
- /// Seconds since the process started — the clock an animated effect uses.
405
+ /// Seconds on the effect clock, which shares its zero with JS:
406
+ /// `input.time == performance.now() / 1000` (rAF timestamps too).
278
407
  public float time;
279
408
  /// Device pixels per logical pixel (the DPI scale factor).
280
409
  public float scale;
@@ -292,12 +421,124 @@ public struct EffectInput
292
421
  public float clip;
293
422
  /// Whether this effect asked for the backdrop.
294
423
  public bool hasBackdrop;
295
- /// Parameter slots 0..3 — the raw packing behind the named fields on your
296
- /// effect struct. Reading these directly works but bypasses the schema;
297
- /// prefer the named fields.
298
- public float4 params0;
299
- /// Parameter slots 4..7.
300
- public float4 params1;
424
+ /// The element's own painting at this pixel, premultiplied:
425
+ /// `contentAt(uv)`. All zero without `[SkContent]`.
426
+ public float4 content;
427
+ /// Whether this effect reads its content (`[SkContent]`).
428
+ public bool hasContent;
429
+ /// This effect's state at this pixel as the last step stored it:
430
+ /// `historyAtPx(px)`. All zero without `[SkHistory]`, on the first frame,
431
+ /// and where the engine keeps no history (see `[SkHistory]`).
432
+ public float4 history;
433
+ /// Whether this quad has a history to read.
434
+ public bool hasHistory;
435
+ /// Whether this run computes the next history state (`update`) rather
436
+ /// than the element's pixels.
437
+ public bool historyPass;
438
+ /// This quad's index in the instance buffer.
439
+ public uint quad;
440
+
441
+ /// Parameter slot `slot` (0..31) — the raw packing behind the named
442
+ /// fields on your effect struct. Bypasses the schema; prefer the fields.
443
+ public float param(uint slot)
444
+ {
445
+ return sk_effect_quads[this.quad].params[slot];
446
+ }
447
+
448
+ // The backdrop. Both textures cover the whole window as it was painted
449
+ // before this effect, so any point may be sampled, not only the element's
450
+ // own area; outside the window they clamp to its edge. Neither holds the
451
+ // element's own background (a backdrop effect paints beneath it) nor
452
+ // another backdrop effect drawn in the same group (they never overlap).
453
+ // The blurred one is a lower-resolution pyramid level: blurred to
454
+ // `[SkBackdropRadius]`, or the raw snapshot when the effect has none.
455
+ // All four return zero for an effect without `[SkBackdrop]`.
456
+
457
+ /// The backdrop at a window UV (`input.uv` space), blurred to
458
+ /// `[SkBackdropRadius]` when the effect declares one.
459
+ public float4 backdropAt(float2 uv)
460
+ {
461
+ return this.hasBackdrop
462
+ ? sk_backdrop_input.SampleLevel(sk_clamp_sampler, uv, 0.0)
463
+ : float4(0.0, 0.0, 0.0, 0.0);
464
+ }
465
+
466
+ /// The backdrop at a point in this element's device pixels (`input.px`
467
+ /// space), blurred like `backdropAt`.
468
+ public float4 backdropAtPx(float2 px)
469
+ {
470
+ return this.backdropAt(this.pxToUv(px));
471
+ }
472
+
473
+ /// The untouched backdrop at a window UV, never blurred.
474
+ public float4 rawBackdropAt(float2 uv)
475
+ {
476
+ return this.hasBackdrop
477
+ ? sk_backdrop_original.SampleLevel(sk_clamp_sampler, uv, 0.0)
478
+ : float4(0.0, 0.0, 0.0, 0.0);
479
+ }
480
+
481
+ /// The untouched backdrop at a point in this element's device pixels.
482
+ public float4 rawBackdropAtPx(float2 px)
483
+ {
484
+ return this.rawBackdropAt(this.pxToUv(px));
485
+ }
486
+
487
+ /// A point in this element's device pixels as a window UV.
488
+ public float2 pxToUv(float2 px)
489
+ {
490
+ return this.uv + (px - this.px) / sk_viewport_size;
491
+ }
492
+
493
+ // The content. It covers the whole window, like the backdrop: the
494
+ // element's painting where it is, transparent elsewhere; outside the
495
+ // window it clamps to the edge. Zero without `[SkContent]`.
496
+
497
+ /// The element's painting at a window UV (`input.uv` space).
498
+ public float4 contentAt(float2 uv)
499
+ {
500
+ return this.hasContent
501
+ ? sk_content.SampleLevel(sk_clamp_sampler, uv, 0.0)
502
+ : float4(0.0, 0.0, 0.0, 0.0);
503
+ }
504
+
505
+ /// The element's painting at a point in its device pixels (`input.px`).
506
+ public float4 contentAtPx(float2 px)
507
+ {
508
+ return this.contentAt(this.pxToUv(px));
509
+ }
510
+
511
+ /// The size of the content texture in texels: the window's, in device
512
+ /// pixels. One texel is one `px` unit.
513
+ public float2 contentSize()
514
+ {
515
+ return sk_viewport_size;
516
+ }
517
+
518
+ // The history: the drawn quad (the border box dilated by `bleed`) in
519
+ // device pixels, one texel each, clamped at its edge. Zero without
520
+ // `[SkHistory]`.
521
+
522
+ /// The state at a point in this element's device pixels (`input.px`).
523
+ public float4 historyAtPx(float2 px)
524
+ {
525
+ float2 size = this.historySize();
526
+ return this.hasHistory
527
+ ? sk_history.SampleLevel(sk_clamp_sampler, (px + this.bleed) / size, 0.0)
528
+ : float4(0.0, 0.0, 0.0, 0.0);
529
+ }
530
+
531
+ /// The state at a window UV (`input.uv` space).
532
+ public float4 historyAt(float2 uv)
533
+ {
534
+ return this.historyAtPx(this.px + (uv - this.uv) * sk_viewport_size);
535
+ }
536
+
537
+ /// The size of the history in texels: the drawn quad's, in device pixels.
538
+ public float2 historySize()
539
+ {
540
+ return max(round(sk_effect_quads[this.quad].bounds.size), float2(1.0, 1.0));
541
+ }
301
542
 
302
543
  /// Antialiased 0..1 coverage from a signed distance in device pixels.
303
544
  /// One device pixel of feather, which is what the rest of gpui uses.
@@ -317,6 +558,68 @@ public struct EffectInput
317
558
  }
318
559
  };
319
560
 
561
+ /// An image parameter, written `url(...)` in CSS and resolved like an
562
+ /// `<img src>`. At most four per effect. Sampled bilinearly at mip 0, so it is
563
+ /// safe in loops and branches. Until the image has loaded, or when it fails or
564
+ /// is omitted, every read returns the field's `[SkDefault]` colour
565
+ /// (transparent without one) and `size` is zero.
566
+ public struct SkTexture
567
+ {
568
+ /// The image's size in texels; (0, 0) while it is missing.
569
+ public float2 size;
570
+ uint slot;
571
+ float4 fallback;
572
+
573
+ public bool loaded()
574
+ {
575
+ return this.size.x > 0.0;
576
+ }
577
+
578
+ /// The image at a 0..1 UV, clamped to its edge texels outside it.
579
+ public float4 sample(float2 uv)
580
+ {
581
+ return this.loaded() ? sk_texture_at(this.slot, sk_clamp_sampler, uv) : this.fallback;
582
+ }
583
+
584
+ /// The image at a UV, repeating outside 0..1.
585
+ public float4 sampleRepeat(float2 uv)
586
+ {
587
+ return this.loaded() ? sk_texture_at(this.slot, sk_repeat_sampler, uv) : this.fallback;
588
+ }
589
+ };
590
+
591
+ /// Built by the generated wrapper; an effect receives its `SkTexture` fields filled in.
592
+ public SkTexture sk_texture(uint slot, float2 size, float4 fallback)
593
+ {
594
+ SkTexture t;
595
+ t.size = size;
596
+ t.slot = slot;
597
+ t.fallback = fallback;
598
+ return t;
599
+ }
600
+
601
+ float4 sk_texture_at(uint slot, SamplerState s, float2 uv)
602
+ {
603
+ float4 texel = float4(0.0, 0.0, 0.0, 0.0);
604
+ if (slot == 0u)
605
+ {
606
+ texel = sk_texture0.SampleLevel(s, uv, 0.0);
607
+ }
608
+ else if (slot == 1u)
609
+ {
610
+ texel = sk_texture1.SampleLevel(s, uv, 0.0);
611
+ }
612
+ else if (slot == 2u)
613
+ {
614
+ texel = sk_texture2.SampleLevel(s, uv, 0.0);
615
+ }
616
+ else if (slot == 3u)
617
+ {
618
+ texel = sk_texture3.SampleLevel(s, uv, 0.0);
619
+ }
620
+ return texel;
621
+ }
622
+
320
623
  /// The one interface an effect implements.
321
624
  public interface IEffect
322
625
  {
@@ -333,6 +636,11 @@ public interface IEffect
333
636
  /// nothing at runtime and removes the single most common way to get an
334
637
  /// effect wrong.
335
638
  static bool straightAlpha() { return false; }
639
+
640
+ /// With `[SkHistory]`: the state to store for this texel, read back next
641
+ /// step through `input.history`. Raw: not premultiplied, clamped or
642
+ /// covered, kept at 16-bit float precision. Defaults to `shade`.
643
+ float4 update(EffectInput input) { return this.shade(input); }
336
644
  };
337
645
 
338
646
  // ===========================================================================
@@ -405,7 +713,10 @@ public float4 sk_clamp_premultiplied(float4 color)
405
713
  public EffectInput sk_begin(uint id, float4 frag_position)
406
714
  {
407
715
  SkEffectQuad q = sk_effect_quads[id];
408
- float2 position = frag_position.xy;
716
+ bool history_pass = (q.flags & SK_FLAG_HISTORY_PASS) != 0u;
717
+ // A history pass draws into the history texture, whose texel (0,0) is
718
+ // the drawn quad's top-left device pixel.
719
+ float2 position = history_pass ? q.bounds.origin + frag_position.xy : frag_position.xy;
409
720
  // SV_Position is the pixel centre, so this lands on a texel centre of the
410
721
  // full-resolution snapshot.
411
722
  float2 uv = position / sk_viewport_size;
@@ -428,19 +739,21 @@ public EffectInput sk_begin(uint id, float4 frag_position)
428
739
  i.px = position - element_origin;
429
740
  i.size = element_size;
430
741
  i.local = i.px / element_size;
431
- i.backdrop = has_backdrop
432
- ? sk_backdrop_input.SampleLevel(sk_clamp_sampler, uv, 0.0)
433
- : float4(0.0, 0.0, 0.0, 0.0);
742
+ i.hasBackdrop = has_backdrop;
743
+ i.hasContent = (q.flags & SK_FLAG_NEEDS_CONTENT) != 0u;
744
+ i.hasHistory = (q.flags & SK_FLAG_HISTORY) != 0u;
745
+ i.historyPass = history_pass;
746
+ i.quad = id;
747
+ i.bleed = q.bleed;
748
+ i.backdrop = i.backdropAt(uv);
749
+ i.content = i.contentAt(uv);
750
+ i.history = i.historyAtPx(i.px);
434
751
  i.sd = sd_element;
435
752
  i.coverage = saturate(0.5 - sd_element);
436
753
  i.time = q.time;
437
754
  i.scale = q.scale;
438
- i.bleed = q.bleed;
439
755
  i.opacity = q.opacity;
440
756
  i.clip = sk_content_mask_coverage(position, q.content_mask, q.content_mask_radii);
441
- i.hasBackdrop = has_backdrop;
442
- i.params0 = float4(q.params0[0], q.params0[1], q.params0[2], q.params0[3]);
443
- i.params1 = float4(q.params1[0], q.params1[1], q.params1[2], q.params1[3]);
444
757
  return i;
445
758
  }
446
759
 
@@ -455,6 +768,10 @@ public EffectInput sk_begin(uint id, float4 frag_position)
455
768
  /// OneMinusSrcAlpha); blending it by source alpha would apply alpha twice.
456
769
  public float4 sk_finish<T : IEffect>(T material, EffectInput i)
457
770
  {
771
+ if (i.historyPass)
772
+ {
773
+ return material.update(i);
774
+ }
458
775
  float4 shaded = material.shade(i);
459
776
  if (T.straightAlpha())
460
777
  {
@@ -485,6 +802,18 @@ public float4 sk_finish<T : IEffect>(T material, EffectInput i)
485
802
  // Helpers
486
803
  // ===========================================================================
487
804
 
805
+ /// 0..1: how present the pointer is in the window, from `[SkPointerTimes]`
806
+ /// and `input.time`, fading in over `seconds` after it enters and out over
807
+ /// `seconds` after it leaves. Pair the field with `[SkAnimatedFor(seconds)]`.
808
+ public float sk_pointer_presence(float3 times, float time, float seconds)
809
+ {
810
+ float fade = max(seconds, 1e-4);
811
+ float entered = saturate((time - times.y) / fade);
812
+ float atLeave = saturate((times.z - times.y) / fade);
813
+ float leaving = atLeave * (1.0 - saturate((time - times.z) / fade));
814
+ return times.y > times.z ? entered : leaving;
815
+ }
816
+
488
817
  /// Straight alpha -> premultiplied.
489
818
  public float4 sk_premultiply(float4 color)
490
819
  {
package/gallery.json ADDED
@@ -0,0 +1 @@
1
+ { "commit": "e0197b7ed18fa944aeca6f3960b9d20fb54f5ffb" }
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "url": "git+https://github.com/argon-chat/skathi.git",
7
7
  "directory": "packages/cli"
8
8
  },
9
- "version": "0.1.0-beta.4",
9
+ "version": "0.3.0",
10
10
  "type": "module",
11
11
  "files": [
12
12
  "aot",
@@ -14,6 +14,7 @@
14
14
  "check",
15
15
  "effects",
16
16
  "templates",
17
+ "gallery.json",
17
18
  "devtools/apps.ts",
18
19
  "devtools/commands.ts",
19
20
  "devtools/ctl.ts",
@@ -23,6 +24,7 @@
23
24
  "css-prefixes.ts",
24
25
  "prod.ts",
25
26
  "runtime-path.ts",
27
+ "svelte.ts",
26
28
  "tailwind.ts",
27
29
  "vitecompat.ts"
28
30
  ],
@@ -33,15 +35,16 @@
33
35
  "dependencies": {
34
36
  "@clack/prompts": "^1.9.0",
35
37
  "@commander-js/extra-typings": "~15.1.0",
36
- "@skathi-native/runtime": "0.1.0-beta.4",
38
+ "@skathi-native/runtime": "0.3.0",
37
39
  "@vue/compiler-sfc": "^3.5.41",
38
40
  "commander": "~15.1.0",
39
41
  "postcss": "^8.4.31",
40
42
  "tailwindcss": "3.4",
41
- "typescript": "5"
43
+ "typescript": "6"
42
44
  },
43
45
  "devDependencies": {
44
- "@modelcontextprotocol/sdk": "^1.30.0"
46
+ "@modelcontextprotocol/sdk": "^1.30.0",
47
+ "svelte": "5.57.3"
45
48
  },
46
49
  "engines": {
47
50
  "bun": ">=1.4"
@@ -57,7 +60,8 @@
57
60
  "comments": {
58
61
  "tailwindcss": "Pinned to 3.4.x: v3 emits literal declarations that crates/sk-css maps onto gpui; v4 uses var(--tw-*) + calc() + @property, which the engine does not fully resolve yet (see tailwind.ts).",
59
62
  "@modelcontextprotocol/sdk": "devDependency: used only by devtools/mcp.ts. devtools/ctl.ts is dependency-free so an agent can drive the app through Bash without bun install.",
60
- "typescript": "sk check and the AOT input inventory (sk build --aot-inputs). Builds do not invoke tsc: bun transpiles .ts directly."
63
+ "typescript": "sk check and the AOT input inventory (sk build --aot-inputs). Builds do not invoke tsc: bun transpiles .ts directly.",
64
+ "svelte": "devDependency: types and tests. A Svelte app compiles with its own svelte/compiler, the version its runtime is."
61
65
  },
62
66
  "publishConfig": {
63
67
  "access": "public"