@solidrt/core 0.0.40 → 0.0.41
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/AGENTS.md +3 -2
- package/README.md +1 -1
- package/examples/README.md +5 -4
- package/examples/gpu-instancing.tsx +70 -0
- package/examples/gpu-particles.tsx +35 -35
- package/examples/gpu-pipeline.tsx +40 -37
- package/examples/gpu-raw-program.tsx +59 -40
- package/examples/gpu-shader.tsx +48 -41
- package/examples/gpu-texture-blend.tsx +20 -19
- package/examples/inline-image.tsx +1 -1
- package/examples/parse-svg.tsx +94 -0
- package/examples/text-import.tsx +2 -2
- package/examples/wave.glsl +5 -3
- package/examples/window-shader-history.tsx +23 -23
- package/examples/window-shader.tsx +30 -28
- package/jsx-runtime.d.ts +17 -9
- package/package.json +2 -2
- package/src/camera.ts +8 -4
- package/src/color.ts +14 -2
- package/src/gpu.ts +176 -75
- package/src/image.ts +12 -11
- package/src/index.ts +3 -0
- package/src/renderer.ts +9 -8
- package/src/runtime-modules.d.ts +2 -2
- package/src/speech-recognition.ts +2 -1
- package/src/svg.ts +71 -0
- package/src/types.d.ts +72 -36
- package/examples/svg.tsx +0 -49
package/src/types.d.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/// <reference path="./runtime-modules.d.ts" />
|
|
3
3
|
|
|
4
4
|
import type { Gradient } from "./color"
|
|
5
|
+
import type { ProgramId, TextureId } from "flux:gpu"
|
|
5
6
|
import type { Element } from "solid-js"
|
|
6
7
|
|
|
7
8
|
// The "srt:*" lattice runner modules are declared in ./runtime-modules.d.ts
|
|
@@ -173,6 +174,9 @@ export interface TransformProps {
|
|
|
173
174
|
// Perspective viewing distance in pixels (CSS `perspective`). Enables the 3D
|
|
174
175
|
// depth for rotateY; larger values give a shallower effect.
|
|
175
176
|
perspective?: number
|
|
177
|
+
// Subtree translation in pixels, composited post-layout (no re-record, no
|
|
178
|
+
// layout). Unlike the draw primitives' detached-only x/y, these exist on
|
|
179
|
+
// layout views too - the drag/thumb idiom animates them freely.
|
|
176
180
|
x?: number
|
|
177
181
|
y?: number
|
|
178
182
|
originX?: OriginX
|
|
@@ -264,11 +268,53 @@ export interface PointerProps {
|
|
|
264
268
|
pointerEvents?: "auto" | "none" | "all"
|
|
265
269
|
}
|
|
266
270
|
|
|
267
|
-
|
|
271
|
+
/**
|
|
272
|
+
* Detached-only geometry, in paint-space pixels. Never affects layout: these
|
|
273
|
+
* props exist only on the d-* forms, where there is no layout box and the
|
|
274
|
+
* element owns its geometry. The layout forms of the draw primitives derive
|
|
275
|
+
* their geometry from the layout box instead (size it with width/height).
|
|
276
|
+
*/
|
|
277
|
+
export interface PositionProps {
|
|
278
|
+
/** Horizontal offset of the drawn geometry; defaults to 0. */
|
|
268
279
|
x?: number
|
|
280
|
+
/** Vertical offset of the drawn geometry; defaults to 0. */
|
|
269
281
|
y?: number
|
|
270
282
|
}
|
|
271
283
|
|
|
284
|
+
/** See {@link PositionProps}: detached-only, never affects layout. */
|
|
285
|
+
export interface GeometryProps extends PositionProps {
|
|
286
|
+
/** Drawn width; defaults to the inherited box width. */
|
|
287
|
+
w?: number
|
|
288
|
+
/** Drawn height; defaults to the inherited box height. */
|
|
289
|
+
h?: number
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/** See {@link PositionProps}: detached-only, never affects layout. */
|
|
293
|
+
export interface OvalGeometryProps extends PositionProps {
|
|
294
|
+
/** Bounding box width of the ellipse (not a radius); defaults to the inherited box. */
|
|
295
|
+
w?: number
|
|
296
|
+
/** Bounding box height of the ellipse (not a radius); defaults to the inherited box. */
|
|
297
|
+
h?: number
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** See {@link PositionProps}: detached-only, never affects layout. */
|
|
301
|
+
export interface TextGeometryProps extends PositionProps {
|
|
302
|
+
// Shaping (wrap) width. Detached text wraps at the inherited ancestor size
|
|
303
|
+
// by default; set w for an unwrapped natural line or an explicit wrap width.
|
|
304
|
+
w?: number
|
|
305
|
+
// Reported-bounds height only; paragraph height always falls out of the text.
|
|
306
|
+
h?: number
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** See {@link PositionProps}: detached-only, never affects layout. */
|
|
310
|
+
export interface LineGeometryProps {
|
|
311
|
+
/** Endpoints default to spanning the box: (0,0) to (box width, box height). */
|
|
312
|
+
x1?: number
|
|
313
|
+
y1?: number
|
|
314
|
+
x2?: number
|
|
315
|
+
y2?: number
|
|
316
|
+
}
|
|
317
|
+
|
|
272
318
|
// Primitives
|
|
273
319
|
|
|
274
320
|
export interface WindowProps extends LayoutProps, PointerProps {
|
|
@@ -298,7 +344,7 @@ export interface WindowProps extends LayoutProps, PointerProps {
|
|
|
298
344
|
*/
|
|
299
345
|
export interface WindowShaderProps {
|
|
300
346
|
/** Linked program handle from linkProgram. */
|
|
301
|
-
program:
|
|
347
|
+
program: ProgramId
|
|
302
348
|
/**
|
|
303
349
|
* Uniforms filled by name, paced to the next real repaint. A number drives
|
|
304
350
|
* a scalar (`float`/`int`); a flat number array drives the declared GLSL
|
|
@@ -306,7 +352,7 @@ export interface WindowShaderProps {
|
|
|
306
352
|
*/
|
|
307
353
|
params?: Record<string, number | number[]>
|
|
308
354
|
/** Extra sampler2D inputs: uniform name to texture id. */
|
|
309
|
-
textures?: Record<string,
|
|
355
|
+
textures?: Record<string, TextureId>
|
|
310
356
|
/** Vertices drawn (attributeless triangles). Default 3, the covering triangle. */
|
|
311
357
|
vertexCount?: number
|
|
312
358
|
/**
|
|
@@ -320,9 +366,23 @@ export interface WindowShaderProps {
|
|
|
320
366
|
previous?: boolean
|
|
321
367
|
}
|
|
322
368
|
|
|
323
|
-
|
|
369
|
+
// Everything a view offers besides layout: d-view uses this directly (a
|
|
370
|
+
// detached view has no taffy presence, so layout props would be rejected at
|
|
371
|
+
// runtime); the layout `view` adds LayoutProps below.
|
|
372
|
+
export interface ViewOwnProps extends TransformProps, PointerProps {
|
|
324
373
|
children?: Children
|
|
325
374
|
trace?: boolean
|
|
375
|
+
/**
|
|
376
|
+
* Design-space size `[w, h]` for the children: content drawn in that
|
|
377
|
+
* coordinate space is uniformly scaled to fit and centered in the element's
|
|
378
|
+
* box (SVG's default preserveAspectRatio, generalized). A pure fit
|
|
379
|
+
* transform - it never sizes the element, so give the box its size with
|
|
380
|
+
* layout props. Composed innermost: the transform props still operate in
|
|
381
|
+
* box space, and pointer events on children arrive in design coordinates.
|
|
382
|
+
* The natural wrapper for parseSvg draws, or any d-* subtree authored in
|
|
383
|
+
* fixed design units.
|
|
384
|
+
*/
|
|
385
|
+
viewBox?: [number, number]
|
|
326
386
|
/**
|
|
327
387
|
* Corner radii for the clip applied when overflow is non-visible (hidden,
|
|
328
388
|
* clip, scroll on both axes). A single number rounds all four corners; an
|
|
@@ -349,54 +409,32 @@ export interface ViewProps extends LayoutProps, TransformProps, PointerProps {
|
|
|
349
409
|
repaintBoundary?: boolean | "snapshot" | "snapshot-no-aa"
|
|
350
410
|
}
|
|
351
411
|
|
|
412
|
+
export interface ViewProps extends ViewOwnProps, LayoutProps {}
|
|
413
|
+
|
|
352
414
|
// draw primitives
|
|
353
415
|
|
|
354
|
-
export interface RectProps extends
|
|
355
|
-
w?: number
|
|
356
|
-
h?: number
|
|
416
|
+
export interface RectProps extends PaintProps, PointerProps {
|
|
357
417
|
// Corner radius. A single number applies to all four corners; an array is
|
|
358
418
|
// [top-left, top-right, bottom-right, bottom-left] (CSS border-radius order).
|
|
359
419
|
radius?: number | [number, number, number, number]
|
|
360
420
|
}
|
|
361
421
|
|
|
362
|
-
export interface OvalProps extends
|
|
363
|
-
/** Bounding box width of the ellipse (not a radius); defaults to the layout box. */
|
|
364
|
-
w?: number
|
|
365
|
-
/** Bounding box height of the ellipse (not a radius); defaults to the layout box. */
|
|
366
|
-
h?: number
|
|
367
|
-
}
|
|
422
|
+
export interface OvalProps extends PaintProps, PointerProps {}
|
|
368
423
|
|
|
369
424
|
export interface LineProps extends PaintProps, PointerProps {
|
|
370
|
-
x1?: number
|
|
371
|
-
y1?: number
|
|
372
|
-
x2?: number
|
|
373
|
-
y2?: number
|
|
374
425
|
/** Dash pattern in local units: the drawn segment length. Both onLength and offLength must be set to dash; with either unset the line is solid. */
|
|
375
426
|
onLength?: number
|
|
376
427
|
/** Dash pattern in local units: the gap length. Both onLength and offLength must be set to dash; with either unset the line is solid. */
|
|
377
428
|
offLength?: number
|
|
378
429
|
}
|
|
379
430
|
|
|
380
|
-
export interface PathProps extends
|
|
431
|
+
export interface PathProps extends PaintProps, PointerProps {
|
|
381
432
|
d?: string
|
|
382
433
|
fillRule?: "nonzero" | "evenodd"
|
|
383
434
|
}
|
|
384
435
|
|
|
385
|
-
export interface
|
|
386
|
-
// A whole SVG document as a string (an imported asset, a fetched string, or a
|
|
387
|
-
// template literal). Parsed and rendered as one unit; takes no JSX children.
|
|
388
|
-
src?: string
|
|
389
|
-
// Drives currentColor in the document. Explicit fills/strokes still win.
|
|
390
|
-
color?: Color
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
export interface TextProps extends Position, PaintProps, PointerProps {
|
|
436
|
+
export interface TextProps extends PaintProps, PointerProps {
|
|
394
437
|
children?: Children
|
|
395
|
-
// Shaping (wrap) width. Detached text wraps at the inherited ancestor size
|
|
396
|
-
// by default; set w for an unwrapped natural line or an explicit wrap width.
|
|
397
|
-
w?: number
|
|
398
|
-
// Reported-bounds height only; paragraph height always falls out of the text.
|
|
399
|
-
h?: number
|
|
400
438
|
fontFamily?: "sans" | "serif" | "mono" | (string & {})
|
|
401
439
|
fontSize?: number
|
|
402
440
|
/**
|
|
@@ -420,8 +458,8 @@ export interface TextProps extends Position, PaintProps, PointerProps {
|
|
|
420
458
|
* Texture alpha is premultiplied, so additive modes need no manual
|
|
421
459
|
* premultiplication.
|
|
422
460
|
*/
|
|
423
|
-
export interface TextureProps extends
|
|
424
|
-
src?:
|
|
461
|
+
export interface TextureProps extends PaintProps, PointerProps {
|
|
462
|
+
src?: TextureId
|
|
425
463
|
/**
|
|
426
464
|
* How the texture's pixels map to the element box (CSS object-fit).
|
|
427
465
|
* "fill" (default) stretches; "cover" and "none" crop; "contain" and
|
|
@@ -430,8 +468,6 @@ export interface TextureProps extends Position, PaintProps, PointerProps {
|
|
|
430
468
|
* bars and "cover" cropped edges still hit-test as part of the element.
|
|
431
469
|
*/
|
|
432
470
|
fit?: "fill" | "cover" | "contain" | "none" | "scale-down"
|
|
433
|
-
w?: number
|
|
434
|
-
h?: number
|
|
435
471
|
srcX?: number
|
|
436
472
|
srcY?: number
|
|
437
473
|
srcW?: number
|
package/examples/svg.tsx
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// <svg> draws a whole SVG *document* passed as a STRING in the `src` prop. This
|
|
2
|
-
// is not HTML: there are no per-element <rect>/<circle>/<path> JSX children to
|
|
3
|
-
// nest. You hand it the SVG source text and usvg parses it (CSS, transforms,
|
|
4
|
-
// defs/use, gradients, clips) into a flat path tree the element renders. So an
|
|
5
|
-
// SVG is a value (a string you import, fetch, or inline), not markup you author
|
|
6
|
-
// inline with JSX.
|
|
7
|
-
//
|
|
8
|
-
// width/height set the drawn box (percentages work too); a multi-color document
|
|
9
|
-
// keeps each shape's own fill, while a monochrome icon using stroke/fill
|
|
10
|
-
// "currentColor" is recolored by the host `color` prop. For per-shape authored
|
|
11
|
-
// or animated vector art, compose <d-path> instead of this document layer.
|
|
12
|
-
//
|
|
13
|
-
// Being a vector, an <svg> is resolution-independent: it stays crisp at any
|
|
14
|
-
// drawn size x displayScale(). Prefer it over a raster <texture> (image.tsx)
|
|
15
|
-
// whenever the render size is fluid or the display DPI varies.
|
|
16
|
-
//
|
|
17
|
-
// This is how you use an existing icon library (Lucide, Heroicons, Feather,
|
|
18
|
-
// Material, etc.): those ship SVG source, so import/inline the icon string and
|
|
19
|
-
// hand it to `src`. The `currentColor` convention they follow means the `color`
|
|
20
|
-
// prop recolors them, exactly as `currentColor` would in a browser.
|
|
21
|
-
import { render } from "@solidrt/core"
|
|
22
|
-
|
|
23
|
-
// Multi-color document: each shape carries its own fill, no host color needed.
|
|
24
|
-
const HOUSE = `
|
|
25
|
-
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
|
26
|
-
<rect x="20" y="45" width="60" height="45" fill="#457b9d"/>
|
|
27
|
-
<path d="M10 50 L50 15 L90 50 Z" fill="#e63946"/>
|
|
28
|
-
<rect x="42" y="62" width="16" height="28" fill="#f1faee"/>
|
|
29
|
-
<circle cx="50" cy="35" r="6" fill="#ffd166"/>
|
|
30
|
-
</svg>`
|
|
31
|
-
|
|
32
|
-
// Monochrome icon (Lucide arrow-right) drawn with currentColor, recolored below.
|
|
33
|
-
const ARROW = `
|
|
34
|
-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
|
|
35
|
-
stroke-linecap="round" stroke-linejoin="round">
|
|
36
|
-
<path d="M5 12h14"/>
|
|
37
|
-
<path d="M12 5l7 7-7 7"/>
|
|
38
|
-
</svg>`
|
|
39
|
-
|
|
40
|
-
function App() {
|
|
41
|
-
return (
|
|
42
|
-
<window justifyContent="center" alignItems="center" flexDirection="row" gap={32}>
|
|
43
|
-
<svg width={120} height={120} src={HOUSE} />
|
|
44
|
-
<svg width={120} height={120} src={ARROW} color="#4f8cff" />
|
|
45
|
-
</window>
|
|
46
|
-
)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
render(() => <App />)
|