typegpu 0.2.0 → 0.3.0-alpha.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,1122 @@
1
+ /**
2
+ * Extracts the inferred representation of a resource.
3
+ * @example
4
+ * type A = Infer<F32> // => number
5
+ * type B = Infer<TgpuArray<F32>> // => number[]
6
+ */
7
+ type Infer<T> = T extends {
8
+ readonly '~repr': infer TRepr;
9
+ } ? TRepr : T;
10
+ type InferRecord<T extends Record<string | number | symbol, unknown>> = {
11
+ [Key in keyof T]: Infer<T[Key]>;
12
+ };
13
+
14
+ interface NumberArrayView {
15
+ readonly length: number;
16
+ [n: number]: number;
17
+ }
18
+ interface BaseWgslData {
19
+ type: string;
20
+ /** Type-token, not available at runtime */
21
+ readonly '~repr': unknown;
22
+ }
23
+ interface Swizzle2<T2, T3, T4> {
24
+ readonly xx: T2;
25
+ readonly xy: T2;
26
+ readonly yx: T2;
27
+ readonly yy: T2;
28
+ readonly xxx: T3;
29
+ readonly xxy: T3;
30
+ readonly xyx: T3;
31
+ readonly xyy: T3;
32
+ readonly yxx: T3;
33
+ readonly yxy: T3;
34
+ readonly yyx: T3;
35
+ readonly yyy: T3;
36
+ readonly xxxx: T4;
37
+ readonly xxxy: T4;
38
+ readonly xxyx: T4;
39
+ readonly xxyy: T4;
40
+ readonly xyxx: T4;
41
+ readonly xyxy: T4;
42
+ readonly xyyx: T4;
43
+ readonly xyyy: T4;
44
+ readonly yxxx: T4;
45
+ readonly yxxy: T4;
46
+ readonly yxyx: T4;
47
+ readonly yxyy: T4;
48
+ readonly yyxx: T4;
49
+ readonly yyxy: T4;
50
+ readonly yyyx: T4;
51
+ readonly yyyy: T4;
52
+ }
53
+ interface Swizzle3<T2, T3, T4> extends Swizzle2<T2, T3, T4> {
54
+ readonly xz: T2;
55
+ readonly yz: T2;
56
+ readonly zx: T2;
57
+ readonly zy: T2;
58
+ readonly zz: T2;
59
+ readonly xxz: T3;
60
+ readonly xyz: T3;
61
+ readonly xzx: T3;
62
+ readonly xzy: T3;
63
+ readonly xzz: T3;
64
+ readonly yxz: T3;
65
+ readonly yyz: T3;
66
+ readonly yzx: T3;
67
+ readonly yzy: T3;
68
+ readonly yzz: T3;
69
+ readonly zxx: T3;
70
+ readonly zxy: T3;
71
+ readonly zxz: T3;
72
+ readonly zyx: T3;
73
+ readonly zyy: T3;
74
+ readonly zyz: T3;
75
+ readonly zzx: T3;
76
+ readonly zzy: T3;
77
+ readonly zzz: T3;
78
+ readonly xxxz: T4;
79
+ readonly xxyz: T4;
80
+ readonly xxzx: T4;
81
+ readonly xxzy: T4;
82
+ readonly xxzz: T4;
83
+ readonly xyxz: T4;
84
+ readonly xyyz: T4;
85
+ readonly xyzx: T4;
86
+ readonly xyzy: T4;
87
+ readonly xyzz: T4;
88
+ readonly xzxx: T4;
89
+ readonly xzxy: T4;
90
+ readonly xzxz: T4;
91
+ readonly xzyx: T4;
92
+ readonly xzyy: T4;
93
+ readonly xzyz: T4;
94
+ readonly xzzx: T4;
95
+ readonly xzzy: T4;
96
+ readonly xzzz: T4;
97
+ readonly yxxz: T4;
98
+ readonly yxyz: T4;
99
+ readonly yxzx: T4;
100
+ readonly yxzy: T4;
101
+ readonly yxzz: T4;
102
+ readonly yyxz: T4;
103
+ readonly yyyz: T4;
104
+ readonly yyzx: T4;
105
+ readonly yyzy: T4;
106
+ readonly yyzz: T4;
107
+ readonly yzxx: T4;
108
+ readonly yzxy: T4;
109
+ readonly yzxz: T4;
110
+ readonly yzyx: T4;
111
+ readonly yzyy: T4;
112
+ readonly yzyz: T4;
113
+ readonly yzzx: T4;
114
+ readonly yzzy: T4;
115
+ readonly yzzz: T4;
116
+ readonly zxxx: T4;
117
+ readonly zxxy: T4;
118
+ readonly zxxz: T4;
119
+ readonly zxyx: T4;
120
+ readonly zxyy: T4;
121
+ readonly zxyz: T4;
122
+ readonly zxzx: T4;
123
+ readonly zxzy: T4;
124
+ readonly zxzz: T4;
125
+ readonly zyxx: T4;
126
+ readonly zyxy: T4;
127
+ readonly zyxz: T4;
128
+ readonly zyyx: T4;
129
+ readonly zyyy: T4;
130
+ readonly zyyz: T4;
131
+ readonly zyzx: T4;
132
+ readonly zyzy: T4;
133
+ readonly zyzz: T4;
134
+ readonly zzxx: T4;
135
+ readonly zzxy: T4;
136
+ readonly zzxz: T4;
137
+ readonly zzyx: T4;
138
+ readonly zzyy: T4;
139
+ readonly zzyz: T4;
140
+ readonly zzzx: T4;
141
+ readonly zzzy: T4;
142
+ readonly zzzz: T4;
143
+ }
144
+ interface Swizzle4<T2, T3, T4> extends Swizzle3<T2, T3, T4> {
145
+ readonly yw: T2;
146
+ readonly zw: T2;
147
+ readonly wx: T2;
148
+ readonly wy: T2;
149
+ readonly wz: T2;
150
+ readonly ww: T2;
151
+ readonly xxw: T3;
152
+ readonly xyw: T3;
153
+ readonly xzw: T3;
154
+ readonly xwx: T3;
155
+ readonly xwy: T3;
156
+ readonly xwz: T3;
157
+ readonly xww: T3;
158
+ readonly yxw: T3;
159
+ readonly yyw: T3;
160
+ readonly yzw: T3;
161
+ readonly ywx: T3;
162
+ readonly ywy: T3;
163
+ readonly ywz: T3;
164
+ readonly yww: T3;
165
+ readonly zxw: T3;
166
+ readonly zyw: T3;
167
+ readonly zzw: T3;
168
+ readonly zwx: T3;
169
+ readonly zwy: T3;
170
+ readonly zwz: T3;
171
+ readonly zww: T3;
172
+ readonly wxx: T3;
173
+ readonly wxz: T3;
174
+ readonly wxy: T3;
175
+ readonly wyy: T3;
176
+ readonly wyz: T3;
177
+ readonly wzz: T3;
178
+ readonly wwx: T3;
179
+ readonly wwy: T3;
180
+ readonly wwz: T3;
181
+ readonly www: T3;
182
+ readonly xxxw: T4;
183
+ readonly xxyw: T4;
184
+ readonly xxzw: T4;
185
+ readonly xxwx: T4;
186
+ readonly xxwy: T4;
187
+ readonly xxwz: T4;
188
+ readonly xxww: T4;
189
+ readonly xyxw: T4;
190
+ readonly xyyw: T4;
191
+ readonly xyzw: T4;
192
+ readonly xywx: T4;
193
+ readonly xywy: T4;
194
+ readonly xywz: T4;
195
+ readonly xyww: T4;
196
+ readonly xzxw: T4;
197
+ readonly xzyw: T4;
198
+ readonly xzzw: T4;
199
+ readonly xzwx: T4;
200
+ readonly xzwy: T4;
201
+ readonly xzwz: T4;
202
+ readonly xzww: T4;
203
+ readonly xwxx: T4;
204
+ readonly xwxy: T4;
205
+ readonly xwxz: T4;
206
+ readonly xwyy: T4;
207
+ readonly xwyz: T4;
208
+ readonly xwzz: T4;
209
+ readonly xwwx: T4;
210
+ readonly xwwy: T4;
211
+ readonly xwwz: T4;
212
+ readonly xwww: T4;
213
+ readonly yxxw: T4;
214
+ readonly yxyw: T4;
215
+ readonly yxzw: T4;
216
+ readonly yxwx: T4;
217
+ readonly yxwy: T4;
218
+ readonly yxwz: T4;
219
+ readonly yxww: T4;
220
+ readonly yyxw: T4;
221
+ readonly yyyw: T4;
222
+ readonly yyzw: T4;
223
+ readonly yywx: T4;
224
+ readonly yywy: T4;
225
+ readonly yywz: T4;
226
+ readonly yyww: T4;
227
+ readonly yzxw: T4;
228
+ readonly yzyw: T4;
229
+ readonly yzzw: T4;
230
+ readonly yzwx: T4;
231
+ readonly yzwy: T4;
232
+ readonly yzwz: T4;
233
+ readonly yzww: T4;
234
+ readonly ywxx: T4;
235
+ readonly ywxy: T4;
236
+ readonly ywxz: T4;
237
+ readonly ywxw: T4;
238
+ readonly ywyy: T4;
239
+ readonly ywyz: T4;
240
+ readonly ywzz: T4;
241
+ readonly ywwx: T4;
242
+ readonly ywwy: T4;
243
+ readonly ywwz: T4;
244
+ readonly ywww: T4;
245
+ readonly zxxw: T4;
246
+ readonly zxyw: T4;
247
+ readonly zxzw: T4;
248
+ readonly zxwx: T4;
249
+ readonly zxwy: T4;
250
+ readonly zxwz: T4;
251
+ readonly zxww: T4;
252
+ readonly zyxw: T4;
253
+ readonly zyyw: T4;
254
+ readonly zyzw: T4;
255
+ readonly zywx: T4;
256
+ readonly zywy: T4;
257
+ readonly zywz: T4;
258
+ readonly zyww: T4;
259
+ readonly zzxw: T4;
260
+ readonly zzyw: T4;
261
+ readonly zzzw: T4;
262
+ readonly zzwx: T4;
263
+ readonly zzwy: T4;
264
+ readonly zzwz: T4;
265
+ readonly zzww: T4;
266
+ readonly zwxx: T4;
267
+ readonly zwxy: T4;
268
+ readonly zwxz: T4;
269
+ readonly zwxw: T4;
270
+ readonly zwyy: T4;
271
+ readonly zwyz: T4;
272
+ readonly zwzz: T4;
273
+ readonly zwwx: T4;
274
+ readonly zwwy: T4;
275
+ readonly zwwz: T4;
276
+ readonly zwww: T4;
277
+ readonly wxxx: T4;
278
+ readonly wxxy: T4;
279
+ readonly wxxz: T4;
280
+ readonly wxxw: T4;
281
+ readonly wxyx: T4;
282
+ readonly wxyy: T4;
283
+ readonly wxyz: T4;
284
+ readonly wxyw: T4;
285
+ readonly wxzx: T4;
286
+ readonly wxzy: T4;
287
+ readonly wxzz: T4;
288
+ readonly wxzw: T4;
289
+ readonly wxwx: T4;
290
+ readonly wxwy: T4;
291
+ readonly wxwz: T4;
292
+ readonly wxww: T4;
293
+ readonly wyxx: T4;
294
+ readonly wyxy: T4;
295
+ readonly wyxz: T4;
296
+ readonly wyxw: T4;
297
+ readonly wyyy: T4;
298
+ readonly wyyz: T4;
299
+ readonly wyzw: T4;
300
+ readonly wywx: T4;
301
+ readonly wywy: T4;
302
+ readonly wywz: T4;
303
+ readonly wyww: T4;
304
+ readonly wzxx: T4;
305
+ readonly wzxy: T4;
306
+ readonly wzxz: T4;
307
+ readonly wzxw: T4;
308
+ readonly wzyy: T4;
309
+ readonly wzyz: T4;
310
+ readonly wzzy: T4;
311
+ readonly wzzw: T4;
312
+ readonly wzwx: T4;
313
+ readonly wzwy: T4;
314
+ readonly wzwz: T4;
315
+ readonly wzww: T4;
316
+ readonly wwxx: T4;
317
+ readonly wwxy: T4;
318
+ readonly wwxz: T4;
319
+ readonly wwxw: T4;
320
+ readonly wwyy: T4;
321
+ readonly wwyz: T4;
322
+ readonly wwzz: T4;
323
+ readonly wwwx: T4;
324
+ readonly wwwy: T4;
325
+ readonly wwwz: T4;
326
+ readonly wwww: T4;
327
+ }
328
+ /**
329
+ * Interface representing its WGSL vector type counterpart: vec2f or vec2<f32>.
330
+ * A vector with 2 elements of type f32
331
+ */
332
+ interface v2f extends NumberArrayView, Swizzle2<v2f, v3f, v4f> {
333
+ /** use to distinguish between vectors of the same size on the type level */
334
+ readonly kind: 'vec2f';
335
+ x: number;
336
+ y: number;
337
+ }
338
+ /**
339
+ * Interface representing its WGSL vector type counterpart: vec2i or vec2<i32>.
340
+ * A vector with 2 elements of type i32
341
+ */
342
+ interface v2i extends NumberArrayView, Swizzle2<v2i, v3i, v4i> {
343
+ /** use to distinguish between vectors of the same size on the type level */
344
+ readonly kind: 'vec2i';
345
+ x: number;
346
+ y: number;
347
+ }
348
+ /**
349
+ * Interface representing its WGSL vector type counterpart: vec2u or vec2<u32>.
350
+ * A vector with 2 elements of type u32
351
+ */
352
+ interface v2u extends NumberArrayView, Swizzle2<v2u, v3u, v4u> {
353
+ /** use to distinguish between vectors of the same size on the type level */
354
+ readonly kind: 'vec2u';
355
+ x: number;
356
+ y: number;
357
+ }
358
+ /**
359
+ * Interface representing its WGSL vector type counterpart: vec3f or vec3<f32>.
360
+ * A vector with 3 elements of type f32
361
+ */
362
+ interface v3f extends NumberArrayView, Swizzle3<v2f, v3f, v4f> {
363
+ /** use to distinguish between vectors of the same size on the type level */
364
+ readonly kind: 'vec3f';
365
+ x: number;
366
+ y: number;
367
+ z: number;
368
+ }
369
+ /**
370
+ * Interface representing its WGSL vector type counterpart: vec3i or vec3<i32>.
371
+ * A vector with 3 elements of type i32
372
+ */
373
+ interface v3i extends NumberArrayView, Swizzle3<v2i, v3i, v4i> {
374
+ /** use to distinguish between vectors of the same size on the type level */
375
+ readonly kind: 'vec3i';
376
+ x: number;
377
+ y: number;
378
+ z: number;
379
+ }
380
+ /**
381
+ * Interface representing its WGSL vector type counterpart: vec3u or vec3<u32>.
382
+ * A vector with 3 elements of type u32
383
+ */
384
+ interface v3u extends NumberArrayView, Swizzle3<v2u, v3u, v4u> {
385
+ /** use to distinguish between vectors of the same size on the type level */
386
+ readonly kind: 'vec3u';
387
+ x: number;
388
+ y: number;
389
+ z: number;
390
+ }
391
+ /**
392
+ * Interface representing its WGSL vector type counterpart: vec4f or vec4<f32>.
393
+ * A vector with 4 elements of type f32
394
+ */
395
+ interface v4f extends NumberArrayView, Swizzle4<v2f, v3f, v4f> {
396
+ /** use to distinguish between vectors of the same size on the type level */
397
+ readonly kind: 'vec4f';
398
+ x: number;
399
+ y: number;
400
+ z: number;
401
+ w: number;
402
+ }
403
+ /**
404
+ * Interface representing its WGSL vector type counterpart: vec4i or vec4<i32>.
405
+ * A vector with 4 elements of type i32
406
+ */
407
+ interface v4i extends NumberArrayView, Swizzle4<v2i, v3i, v4i> {
408
+ /** use to distinguish between vectors of the same size on the type level */
409
+ readonly kind: 'vec4i';
410
+ x: number;
411
+ y: number;
412
+ z: number;
413
+ w: number;
414
+ }
415
+ /**
416
+ * Interface representing its WGSL vector type counterpart: vec4u or vec4<u32>.
417
+ * A vector with 4 elements of type u32
418
+ */
419
+ interface v4u extends NumberArrayView, Swizzle4<v2u, v3u, v4u> {
420
+ /** use to distinguish between vectors of the same size on the type level */
421
+ readonly kind: 'vec4u';
422
+ x: number;
423
+ y: number;
424
+ z: number;
425
+ w: number;
426
+ }
427
+ interface matBase<TColumn> extends NumberArrayView {
428
+ readonly columns: readonly TColumn[];
429
+ }
430
+ /**
431
+ * Interface representing its WGSL matrix type counterpart: mat2x2
432
+ * A matrix with 2 rows and 2 columns, with elements of type `TColumn`
433
+ */
434
+ interface mat2x2<TColumn> extends matBase<TColumn> {
435
+ readonly length: 4;
436
+ [n: number]: number;
437
+ }
438
+ /**
439
+ * Interface representing its WGSL matrix type counterpart: mat2x2f or mat2x2<f32>
440
+ * A matrix with 2 rows and 2 columns, with elements of type d.f32
441
+ */
442
+ interface m2x2f extends mat2x2<v2f> {
443
+ readonly kind: 'mat2x2f';
444
+ }
445
+ /**
446
+ * Interface representing its WGSL matrix type counterpart: mat3x3
447
+ * A matrix with 3 rows and 3 columns, with elements of type `TColumn`
448
+ */
449
+ interface mat3x3<TColumn> extends matBase<TColumn> {
450
+ readonly length: 12;
451
+ [n: number]: number;
452
+ }
453
+ /**
454
+ * Interface representing its WGSL matrix type counterpart: mat3x3f or mat3x3<f32>
455
+ * A matrix with 3 rows and 3 columns, with elements of type d.f32
456
+ */
457
+ interface m3x3f extends mat3x3<v3f> {
458
+ readonly kind: 'mat3x3f';
459
+ }
460
+ /**
461
+ * Interface representing its WGSL matrix type counterpart: mat4x4
462
+ * A matrix with 4 rows and 4 columns, with elements of type `TColumn`
463
+ */
464
+ interface mat4x4<TColumn> extends matBase<TColumn> {
465
+ readonly length: 16;
466
+ [n: number]: number;
467
+ }
468
+ /**
469
+ * Interface representing its WGSL matrix type counterpart: mat4x4f or mat4x4<f32>
470
+ * A matrix with 4 rows and 4 columns, with elements of type d.f32
471
+ */
472
+ interface m4x4f extends mat4x4<v4f> {
473
+ readonly kind: 'mat4x4f';
474
+ }
475
+ /**
476
+ * Boolean schema representing a single WGSL bool value.
477
+ * Cannot be used inside buffers as it is not host-shareable.
478
+ */
479
+ interface Bool {
480
+ readonly type: 'bool';
481
+ readonly '~repr': boolean;
482
+ }
483
+ interface F32 {
484
+ readonly type: 'f32';
485
+ /** Type-token, not available at runtime */
486
+ readonly '~repr': number;
487
+ }
488
+ interface F16 {
489
+ readonly type: 'f16';
490
+ /** Type-token, not available at runtime */
491
+ readonly '~repr': number;
492
+ }
493
+ interface I32 {
494
+ readonly type: 'i32';
495
+ /** Type-token, not available at runtime */
496
+ readonly '~repr': number;
497
+ }
498
+ interface U32 {
499
+ readonly type: 'u32';
500
+ /** Type-token, not available at runtime */
501
+ readonly '~repr': number;
502
+ }
503
+ interface Vec2f {
504
+ readonly type: 'vec2f';
505
+ /** Type-token, not available at runtime */
506
+ readonly '~repr': v2f;
507
+ }
508
+ interface Vec2i {
509
+ readonly type: 'vec2i';
510
+ /** Type-token, not available at runtime */
511
+ readonly '~repr': v2i;
512
+ }
513
+ interface Vec2u {
514
+ readonly type: 'vec2u';
515
+ /** Type-token, not available at runtime */
516
+ readonly '~repr': v2u;
517
+ }
518
+ interface Vec3f {
519
+ readonly type: 'vec3f';
520
+ /** Type-token, not available at runtime */
521
+ readonly '~repr': v3f;
522
+ }
523
+ interface Vec3i {
524
+ readonly type: 'vec3i';
525
+ /** Type-token, not available at runtime */
526
+ readonly '~repr': v3i;
527
+ }
528
+ interface Vec3u {
529
+ readonly type: 'vec3u';
530
+ /** Type-token, not available at runtime */
531
+ readonly '~repr': v3u;
532
+ }
533
+ interface Vec4f {
534
+ readonly type: 'vec4f';
535
+ /** Type-token, not available at runtime */
536
+ readonly '~repr': v4f;
537
+ }
538
+ interface Vec4i {
539
+ readonly type: 'vec4i';
540
+ /** Type-token, not available at runtime */
541
+ readonly '~repr': v4i;
542
+ }
543
+ interface Vec4u {
544
+ readonly type: 'vec4u';
545
+ /** Type-token, not available at runtime */
546
+ readonly '~repr': v4u;
547
+ }
548
+ interface Mat2x2f {
549
+ readonly type: 'mat2x2f';
550
+ /** Type-token, not available at runtime */
551
+ readonly '~repr': m2x2f;
552
+ }
553
+ interface Mat3x3f {
554
+ readonly type: 'mat3x3f';
555
+ /** Type-token, not available at runtime */
556
+ readonly '~repr': m3x3f;
557
+ }
558
+ interface Mat4x4f {
559
+ readonly type: 'mat4x4f';
560
+ /** Type-token, not available at runtime */
561
+ readonly '~repr': m4x4f;
562
+ }
563
+ interface WgslStruct<TProps extends Record<string, BaseWgslData> = Record<string, BaseWgslData>> {
564
+ readonly type: 'struct';
565
+ readonly label?: string | undefined;
566
+ readonly propTypes: TProps;
567
+ /** Type-token, not available at runtime */
568
+ readonly '~repr': InferRecord<TProps>;
569
+ }
570
+ interface WgslArray<TElement = BaseWgslData> {
571
+ readonly type: 'array';
572
+ readonly elementCount: number;
573
+ readonly elementType: TElement;
574
+ /** Type-token, not available at runtime */
575
+ readonly '~repr': Infer<TElement>[];
576
+ }
577
+ /**
578
+ * Schema representing the `atomic<...>` WGSL data type.
579
+ */
580
+ interface Atomic<TInner extends U32 | I32 = U32 | I32> {
581
+ readonly type: 'atomic';
582
+ readonly inner: TInner;
583
+ /** Type-token, not available at runtime */
584
+ readonly '~repr': Infer<TInner>;
585
+ }
586
+ interface Align<T extends number> {
587
+ readonly type: '@align';
588
+ readonly value: T;
589
+ }
590
+ interface Size<T extends number> {
591
+ readonly type: '@size';
592
+ readonly value: T;
593
+ }
594
+ interface Location<T extends number> {
595
+ readonly type: '@location';
596
+ readonly value: T;
597
+ }
598
+ interface Builtin<T extends string> {
599
+ readonly type: '@builtin';
600
+ readonly value: T;
601
+ }
602
+ interface Decorated<TInner extends BaseWgslData = BaseWgslData, TAttribs extends unknown[] = unknown[]> {
603
+ readonly type: 'decorated';
604
+ readonly inner: TInner;
605
+ readonly attribs: TAttribs;
606
+ /** Type-token, not available at runtime */
607
+ readonly '~repr': Infer<TInner>;
608
+ }
609
+ declare const wgslTypeLiterals: readonly ["bool", "f32", "f16", "i32", "u32", "vec2f", "vec2i", "vec2u", "vec3f", "vec3i", "vec3u", "vec4f", "vec4i", "vec4u", "mat2x2f", "mat3x3f", "mat4x4f", "struct", "array", "atomic", "decorated"];
610
+ type WgslTypeLiteral = (typeof wgslTypeLiterals)[number];
611
+ type AnyWgslData = Bool | F32 | F16 | I32 | U32 | Vec2f | Vec2i | Vec2u | Vec3f | Vec3i | Vec3u | Vec4f | Vec4i | Vec4u | Mat2x2f | Mat3x3f | Mat4x4f | WgslStruct | WgslArray | Atomic | Decorated;
612
+ declare function isWgslData(value: unknown): value is AnyWgslData;
613
+ /**
614
+ * Checks whether passed in value is an array schema,
615
+ * as opposed to, e.g., a looseArray schema.
616
+ *
617
+ * Array schemas can be used to describe uniform and storage buffers,
618
+ * whereas looseArray schemas cannot.
619
+ *
620
+ * @example
621
+ * isWgslArray(d.arrayOf(d.u32, 4)) // true
622
+ * isWgslArray(d.looseArrayOf(d.u32, 4)) // false
623
+ * isWgslArray(d.vec3f) // false
624
+ */
625
+ declare function isWgslArray<T extends WgslArray>(schema: T | unknown): schema is T;
626
+ /**
627
+ * Checks whether passed in value is a struct schema,
628
+ * as opposed to, e.g., a looseStruct schema.
629
+ *
630
+ * Struct schemas can be used to describe uniform and storage buffers,
631
+ * whereas looseStruct schemas cannot.
632
+ *
633
+ * @example
634
+ * isWgslStruct(d.struct({ a: d.u32 })) // true
635
+ * isWgslStruct(d.looseStruct({ a: d.u32 })) // false
636
+ * isWgslStruct(d.vec3f) // false
637
+ */
638
+ declare function isWgslStruct<T extends WgslStruct>(schema: T | unknown): schema is T;
639
+ /**
640
+ * Checks whether the passed in value is an atomic schema.
641
+ *
642
+ * @example
643
+ * isAtomic(d.atomic(d.u32)) // true
644
+ * isAtomic(d.u32) // false
645
+ */
646
+ declare function isAtomic<T extends Atomic<U32 | I32>>(schema: T | unknown): schema is T;
647
+ declare function isAlignAttrib<T extends Align<number>>(value: unknown | T): value is T;
648
+ declare function isSizeAttrib<T extends Size<number>>(value: unknown | T): value is T;
649
+ declare function isLocationAttrib<T extends Location<number>>(value: unknown | T): value is T;
650
+ declare function isBuiltinAttrib<T extends Builtin<string>>(value: unknown | T): value is T;
651
+ declare function isDecorated<T extends Decorated>(value: unknown | T): value is T;
652
+
653
+ /**
654
+ * A schema that represents a boolean value. (equivalent to `bool` in WGSL)
655
+ */
656
+ declare const bool: Bool;
657
+ /**
658
+ * Unsigned 32-bit integer schema representing a single WGSL u32 value.
659
+ */
660
+ type NativeU32 = U32 & {
661
+ '~exotic': U32;
662
+ } & ((v: number | boolean) => number);
663
+ /**
664
+ * A schema that represents an unsigned 32-bit integer value. (equivalent to `u32` in WGSL)
665
+ *
666
+ * Can also be called to cast a value to an u32 in accordance with WGSL casting rules.
667
+ *
668
+ * @example
669
+ * const value = u32(3.14); // 3
670
+ * @example
671
+ * const value = u32(-1); // 4294967295
672
+ * @example
673
+ * const value = u32(-3.1); // 0
674
+ */
675
+ declare const u32: NativeU32;
676
+ /**
677
+ * Signed 32-bit integer schema representing a single WGSL i32 value.
678
+ */
679
+ type NativeI32 = I32 & {
680
+ '~exotic': I32;
681
+ } & ((v: number | boolean) => number);
682
+ /**
683
+ * A schema that represents a signed 32-bit integer value. (equivalent to `i32` in WGSL)
684
+ *
685
+ * Can also be called to cast a value to an i32 in accordance with WGSL casting rules.
686
+ *
687
+ * @example
688
+ * const value = i32(3.14); // 3
689
+ * @example
690
+ * const value = i32(-3.9); // -3
691
+ * @example
692
+ * const value = i32(10000000000) // 1410065408
693
+ */
694
+ declare const i32: NativeI32;
695
+ /**
696
+ * 32-bit float schema representing a single WGSL f32 value.
697
+ */
698
+ type NativeF32 = F32 & {
699
+ '~exotic': F32;
700
+ } & ((v: number | boolean) => number);
701
+ /**
702
+ * A schema that represents a 32-bit float value. (equivalent to `f32` in WGSL)
703
+ *
704
+ * Can also be called to cast a value to an f32.
705
+ *
706
+ * @example
707
+ * const value = f32(true); // 1
708
+ */
709
+ declare const f32: NativeF32;
710
+ /**
711
+ * 16-bit float schema representing a single WGSL f16 value.
712
+ */
713
+ type NativeF16 = F16 & {
714
+ '~exotic': F16;
715
+ } & ((v: number | boolean) => number);
716
+ /**
717
+ * A schema that represents a 16-bit float value. (equivalent to `f16` in WGSL)
718
+ *
719
+ * Can also be called to cast a value to an f16.
720
+ *
721
+ * @example
722
+ * const value = f16(true); // 1
723
+ * @example
724
+ * const value = f16(21877.5); // 21872
725
+ */
726
+ declare const f16: NativeF16;
727
+
728
+ /**
729
+ * Type of the `d.vec2f` object/function: vector data type schema/constructor
730
+ */
731
+ type NativeVec2f = Vec2f & {
732
+ '~exotic': Vec2f;
733
+ } & ((x: number, y: number) => v2f) & ((xy: number) => v2f) & (() => v2f);
734
+ /**
735
+ *
736
+ * Schema representing vec2f - a vector with 2 elements of type f32.
737
+ * Also a constructor function for this vector value.
738
+ *
739
+ * @example
740
+ * const vector = d.vec2f(); // (0.0, 0.0)
741
+ * const vector = d.vec2f(1); // (1.0, 1.0)
742
+ * const vector = d.vec2f(0.5, 0.1); // (0.5, 0.1)
743
+ *
744
+ * @example
745
+ * const buffer = root.createBuffer(d.vec2f, d.vec2f(0, 1)); // buffer holding a d.vec2f value, with an initial value of vec2f(0, 1);
746
+ */
747
+ declare const vec2f: NativeVec2f;
748
+ /**
749
+ * Type of the `d.vec2i` object/function: vector data type schema/constructor
750
+ */
751
+ type NativeVec2i = Vec2i & {
752
+ '~exotic': Vec2i;
753
+ } & ((x: number, y: number) => v2i) & ((xy: number) => v2i) & (() => v2i);
754
+ /**
755
+ *
756
+ * Schema representing vec2i - a vector with 2 elements of type i32.
757
+ * Also a constructor function for this vector value.
758
+ *
759
+ * @example
760
+ * const vector = d.vec2i(); // (0, 0)
761
+ * const vector = d.vec2i(1); // (1, 1)
762
+ * const vector = d.vec2i(-1, 1); // (-1, 1)
763
+ *
764
+ * @example
765
+ * const buffer = root.createBuffer(d.vec2i, d.vec2i(0, 1)); // buffer holding a d.vec2i value, with an initial value of vec2i(0, 1);
766
+ */
767
+ declare const vec2i: NativeVec2i;
768
+ /**
769
+ * Type of the `d.vec2u` object/function: vector data type schema/constructor
770
+ */
771
+ type NativeVec2u = Vec2u & {
772
+ '~exotic': Vec2u;
773
+ } & ((x: number, y: number) => v2u) & ((xy: number) => v2u) & (() => v2u);
774
+ /**
775
+ *
776
+ * Schema representing vec2u - a vector with 2 elements of type u32.
777
+ * Also a constructor function for this vector value.
778
+ *
779
+ * @example
780
+ * const vector = d.vec2u(); // (0, 0)
781
+ * const vector = d.vec2u(1); // (1, 1)
782
+ * const vector = d.vec2u(1, 2); // (1, 2)
783
+ *
784
+ * @example
785
+ * const buffer = root.createBuffer(d.vec2u, d.vec2u(0, 1)); // buffer holding a d.vec2u value, with an initial value of vec2u(0, 1);
786
+ */
787
+ declare const vec2u: NativeVec2u;
788
+ /**
789
+ * Type of the `d.vec3f` object/function: vector data type schema/constructor
790
+ */
791
+ type NativeVec3f = Vec3f & {
792
+ '~exotic': Vec3f;
793
+ } & ((x: number, y: number, z: number) => v3f) & ((xyz: number) => v3f) & (() => v3f);
794
+ /**
795
+ *
796
+ * Schema representing vec3f - a vector with 3 elements of type f32.
797
+ * Also a constructor function for this vector value.
798
+ *
799
+ * @example
800
+ * const vector = d.vec3f(); // (0.0, 0.0, 0.0)
801
+ * const vector = d.vec3f(1); // (1.0, 1.0, 1.0)
802
+ * const vector = d.vec3f(1, 2, 3.5); // (1.0, 2.0, 3.5)
803
+ *
804
+ * @example
805
+ * const buffer = root.createBuffer(d.vec3f, d.vec3f(0, 1, 2)); // buffer holding a d.vec3f value, with an initial value of vec3f(0, 1, 2);
806
+ */
807
+ declare const vec3f: NativeVec3f;
808
+ /**
809
+ * Type of the `d.vec3i` object/function: vector data type schema/constructor
810
+ */
811
+ type NativeVec3i = Vec3i & {
812
+ '~exotic': Vec3i;
813
+ } & ((x: number, y: number, z: number) => v3i) & ((xyz: number) => v3i) & (() => v3i);
814
+ /**
815
+ *
816
+ * Schema representing vec3i - a vector with 3 elements of type i32.
817
+ * Also a constructor function for this vector value.
818
+ *
819
+ * @example
820
+ * const vector = d.vec3i(); // (0, 0, 0)
821
+ * const vector = d.vec3i(1); // (1, 1, 1)
822
+ * const vector = d.vec3i(1, 2, -3); // (1, 2, -3)
823
+ *
824
+ * @example
825
+ * const buffer = root.createBuffer(d.vec3i, d.vec3i(0, 1, 2)); // buffer holding a d.vec3i value, with an initial value of vec3i(0, 1, 2);
826
+ */
827
+ declare const vec3i: NativeVec3i;
828
+ /**
829
+ * Type of the `d.vec3u` object/function: vector data type schema/constructor
830
+ */
831
+ type NativeVec3u = Vec3u & {
832
+ '~exotic': Vec3u;
833
+ } & ((x: number, y: number, z: number) => v3u) & ((xyz: number) => v3u) & (() => v3u);
834
+ /**
835
+ *
836
+ * Schema representing vec3u - a vector with 3 elements of type u32.
837
+ * Also a constructor function for this vector value.
838
+ *
839
+ * @example
840
+ * const vector = d.vec3u(); // (0, 0, 0)
841
+ * const vector = d.vec3u(1); // (1, 1, 1)
842
+ * const vector = d.vec3u(1, 2, 3); // (1, 2, 3)
843
+ *
844
+ * @example
845
+ * const buffer = root.createBuffer(d.vec3u, d.vec3u(0, 1, 2)); // buffer holding a d.vec3u value, with an initial value of vec3u(0, 1, 2);
846
+ */
847
+ declare const vec3u: NativeVec3u;
848
+ /**
849
+ * Type of the `d.vec4f` object/function: vector data type schema/constructor
850
+ */
851
+ type NativeVec4f = Vec4f & {
852
+ '~exotic': Vec4f;
853
+ } & ((x: number, y: number, z: number, w: number) => v4f) & ((xyzw: number) => v4f) & (() => v4f);
854
+ /**
855
+ *
856
+ * Schema representing vec4f - a vector with 4 elements of type f32.
857
+ * Also a constructor function for this vector value.
858
+ *
859
+ * @example
860
+ * const vector = d.vec4f(); // (0.0, 0.0, 0.0, 0.0)
861
+ * const vector = d.vec4f(1); // (1.0, 1.0, 1.0, 1.0)
862
+ * const vector = d.vec4f(1, 2, 3, 4.5); // (1.0, 2.0, 3.0, 4.5)
863
+ *
864
+ * @example
865
+ * const buffer = root.createBuffer(d.vec4f, d.vec4f(0, 1, 2, 3)); // buffer holding a d.vec4f value, with an initial value of vec4f(0, 1, 2, 3);
866
+ */
867
+ declare const vec4f: NativeVec4f;
868
+ /**
869
+ * Type of the `d.vec4i` object/function: vector data type schema/constructor
870
+ */
871
+ type NativeVec4i = Vec4i & {
872
+ '~exotic': Vec4i;
873
+ } & ((x: number, y: number, z: number, w: number) => v4i) & ((xyzw: number) => v4i) & (() => v4i);
874
+ /**
875
+ *
876
+ * Schema representing vec4i - a vector with 4 elements of type i32.
877
+ * Also a constructor function for this vector value.
878
+ *
879
+ * @example
880
+ * const vector = d.vec4i(); // (0, 0, 0, 0)
881
+ * const vector = d.vec4i(1); // (1, 1, 1, 1)
882
+ * const vector = d.vec4i(1, 2, 3, -4); // (1, 2, 3, -4)
883
+ *
884
+ * @example
885
+ * const buffer = root.createBuffer(d.vec4i, d.vec4i(0, 1, 2, 3)); // buffer holding a d.vec4i value, with an initial value of vec4i(0, 1, 2, 3);
886
+ */
887
+ declare const vec4i: NativeVec4i;
888
+ /**
889
+ * Type of the `d.vec4u` object/function: vector data type schema/constructor
890
+ */
891
+ type NativeVec4u = Vec4u & {
892
+ '~exotic': Vec4u;
893
+ } & ((x: number, y: number, z: number, w: number) => v4u) & ((xyzw: number) => v4u) & (() => v4u);
894
+ /**
895
+ *
896
+ * Schema representing vec4u - a vector with 4 elements of type u32.
897
+ * Also a constructor function for this vector value.
898
+ *
899
+ * @example
900
+ * const vector = d.vec4u(); // (0, 0, 0, 0)
901
+ * const vector = d.vec4u(1); // (1, 1, 1, 1)
902
+ * const vector = d.vec4u(1, 2, 3, 4); // (1, 2, 3, 4)
903
+ *
904
+ * @example
905
+ * const buffer = root.createBuffer(d.vec4u, d.vec4u(0, 1, 2, 3)); // buffer holding a d.vec4u value, with an initial value of vec4u(0, 1, 2, 3);
906
+ */
907
+ declare const vec4u: NativeVec4u;
908
+
909
+ declare const vertexFormats: readonly ["uint8x2", "uint8x4", "sint8x2", "sint8x4", "unorm8x2", "unorm8x4", "snorm8x2", "snorm8x4", "uint16x2", "uint16x4", "sint16x2", "sint16x4", "unorm16x2", "unorm16x4", "snorm16x2", "snorm16x4", "float16x2", "float16x4", "float32", "float32x2", "float32x3", "float32x4", "uint32", "uint32x2", "uint32x3", "uint32x4", "sint32", "sint32x2", "sint32x3", "sint32x4", "unorm10-10-10-2"];
910
+ type VertexFormat = (typeof vertexFormats)[number];
911
+
912
+ type FormatToWGSLType<T extends VertexFormat> = (typeof formatToWGSLType)[T];
913
+ interface TgpuVertexFormatData<T extends VertexFormat> {
914
+ readonly '~repr': Infer<FormatToWGSLType<T>>;
915
+ readonly type: T;
916
+ }
917
+ declare const formatToWGSLType: {
918
+ readonly uint8x2: NativeVec2u;
919
+ readonly uint8x4: NativeVec4u;
920
+ readonly sint8x2: NativeVec2i;
921
+ readonly sint8x4: NativeVec4i;
922
+ readonly unorm8x2: NativeVec2f;
923
+ readonly unorm8x4: NativeVec4f;
924
+ readonly snorm8x2: NativeVec2f;
925
+ readonly snorm8x4: NativeVec4f;
926
+ readonly uint16x2: NativeVec2u;
927
+ readonly uint16x4: NativeVec4u;
928
+ readonly sint16x2: NativeVec2i;
929
+ readonly sint16x4: NativeVec4i;
930
+ readonly unorm16x2: NativeVec2f;
931
+ readonly unorm16x4: NativeVec4f;
932
+ readonly snorm16x2: NativeVec2f;
933
+ readonly snorm16x4: NativeVec4f;
934
+ readonly float16x2: NativeVec2f;
935
+ readonly float16x4: NativeVec4f;
936
+ readonly float32: NativeF32;
937
+ readonly float32x2: NativeVec2f;
938
+ readonly float32x3: NativeVec3f;
939
+ readonly float32x4: NativeVec4f;
940
+ readonly uint32: NativeU32;
941
+ readonly uint32x2: NativeVec2u;
942
+ readonly uint32x3: NativeVec3u;
943
+ readonly uint32x4: NativeVec4u;
944
+ readonly sint32: NativeI32;
945
+ readonly sint32x2: NativeVec2i;
946
+ readonly sint32x3: NativeVec3i;
947
+ readonly sint32x4: NativeVec4i;
948
+ readonly 'unorm10-10-10-2': NativeVec4f;
949
+ };
950
+ declare const packedFormats: string[];
951
+ type uint8x2 = TgpuVertexFormatData<'uint8x2'>;
952
+ declare const uint8x2: uint8x2;
953
+ type uint8x4 = TgpuVertexFormatData<'uint8x4'>;
954
+ declare const uint8x4: uint8x4;
955
+ type sint8x2 = TgpuVertexFormatData<'sint8x2'>;
956
+ declare const sint8x2: sint8x2;
957
+ type sint8x4 = TgpuVertexFormatData<'sint8x4'>;
958
+ declare const sint8x4: sint8x4;
959
+ type unorm8x2 = TgpuVertexFormatData<'unorm8x2'>;
960
+ declare const unorm8x2: unorm8x2;
961
+ type unorm8x4 = TgpuVertexFormatData<'unorm8x4'>;
962
+ declare const unorm8x4: unorm8x4;
963
+ type snorm8x2 = TgpuVertexFormatData<'snorm8x2'>;
964
+ declare const snorm8x2: snorm8x2;
965
+ type snorm8x4 = TgpuVertexFormatData<'snorm8x4'>;
966
+ declare const snorm8x4: snorm8x4;
967
+ type uint16x2 = TgpuVertexFormatData<'uint16x2'>;
968
+ declare const uint16x2: uint16x2;
969
+ type uint16x4 = TgpuVertexFormatData<'uint16x4'>;
970
+ declare const uint16x4: uint16x4;
971
+ type sint16x2 = TgpuVertexFormatData<'sint16x2'>;
972
+ declare const sint16x2: sint16x2;
973
+ type sint16x4 = TgpuVertexFormatData<'sint16x4'>;
974
+ declare const sint16x4: sint16x4;
975
+ type unorm16x2 = TgpuVertexFormatData<'unorm16x2'>;
976
+ declare const unorm16x2: unorm16x2;
977
+ type unorm16x4 = TgpuVertexFormatData<'unorm16x4'>;
978
+ declare const unorm16x4: unorm16x4;
979
+ type snorm16x2 = TgpuVertexFormatData<'snorm16x2'>;
980
+ declare const snorm16x2: snorm16x2;
981
+ type snorm16x4 = TgpuVertexFormatData<'snorm16x4'>;
982
+ declare const snorm16x4: snorm16x4;
983
+ type float16x2 = TgpuVertexFormatData<'float16x2'>;
984
+ declare const float16x2: float16x2;
985
+ type float16x4 = TgpuVertexFormatData<'float16x4'>;
986
+ declare const float16x4: float16x4;
987
+ type float32 = TgpuVertexFormatData<'float32'>;
988
+ declare const float32: float32;
989
+ type float32x2 = TgpuVertexFormatData<'float32x2'>;
990
+ declare const float32x2: float32x2;
991
+ type float32x3 = TgpuVertexFormatData<'float32x3'>;
992
+ declare const float32x3: float32x3;
993
+ type float32x4 = TgpuVertexFormatData<'float32x4'>;
994
+ declare const float32x4: float32x4;
995
+ type uint32 = TgpuVertexFormatData<'uint32'>;
996
+ declare const uint32: uint32;
997
+ type uint32x2 = TgpuVertexFormatData<'uint32x2'>;
998
+ declare const uint32x2: uint32x2;
999
+ type uint32x3 = TgpuVertexFormatData<'uint32x3'>;
1000
+ declare const uint32x3: uint32x3;
1001
+ type uint32x4 = TgpuVertexFormatData<'uint32x4'>;
1002
+ declare const uint32x4: uint32x4;
1003
+ type sint32 = TgpuVertexFormatData<'sint32'>;
1004
+ declare const sint32: sint32;
1005
+ type sint32x2 = TgpuVertexFormatData<'sint32x2'>;
1006
+ declare const sint32x2: sint32x2;
1007
+ type sint32x3 = TgpuVertexFormatData<'sint32x3'>;
1008
+ declare const sint32x3: sint32x3;
1009
+ type sint32x4 = TgpuVertexFormatData<'sint32x4'>;
1010
+ declare const sint32x4: sint32x4;
1011
+ type unorm10_10_10_2 = TgpuVertexFormatData<'unorm10-10-10-2'>;
1012
+ declare const unorm10_10_10_2: unorm10_10_10_2;
1013
+ type PackedData = uint8x2 | uint8x4 | sint8x2 | sint8x4 | unorm8x2 | unorm8x4 | snorm8x2 | snorm8x4 | uint16x2 | uint16x4 | sint16x2 | sint16x4 | unorm16x2 | unorm16x4 | snorm16x2 | snorm16x4 | float16x2 | float16x4 | float32 | float32x2 | float32x3 | float32x4 | uint32 | uint32x2 | uint32x3 | uint32x4 | sint32 | sint32x2 | sint32x3 | sint32x4 | unorm10_10_10_2;
1014
+
1015
+ /**
1016
+ * Array schema constructed via `d.looseArrayOf` function.
1017
+ *
1018
+ * Useful for defining vertex buffers.
1019
+ * Elements in the schema are not aligned in respect to their `byteAlignment`,
1020
+ * unless they are explicitly decorated with the custom align attribute
1021
+ * via `d.align` function.
1022
+ */
1023
+ interface LooseArray<TElement extends BaseWgslData = BaseWgslData> {
1024
+ readonly type: 'loose-array';
1025
+ readonly elementCount: number;
1026
+ readonly elementType: TElement;
1027
+ readonly '~repr': Infer<TElement>[];
1028
+ }
1029
+ /**
1030
+ * Struct schema constructed via `d.looseStruct` function.
1031
+ *
1032
+ * Useful for defining vertex buffers, as the standard layout restrictions do not apply.
1033
+ * Members are not aligned in respect to their `byteAlignment`,
1034
+ * unless they are explicitly decorated with the custom align attribute
1035
+ * via `d.align` function.
1036
+ */
1037
+ interface LooseStruct<TProps extends Record<string, BaseWgslData> = Record<string, BaseWgslData>> {
1038
+ readonly type: 'loose-struct';
1039
+ readonly propTypes: TProps;
1040
+ readonly '~repr': InferRecord<TProps>;
1041
+ }
1042
+ interface LooseDecorated<TInner extends BaseWgslData = BaseWgslData, TAttribs extends unknown[] = unknown[]> {
1043
+ readonly type: 'loose-decorated';
1044
+ readonly inner: TInner;
1045
+ readonly attribs: TAttribs;
1046
+ readonly '~repr': Infer<TInner>;
1047
+ }
1048
+ declare const looseTypeLiterals: readonly ["loose-struct", "loose-array", "loose-decorated", "uint8x2", "uint8x4", "sint8x2", "sint8x4", "unorm8x2", "unorm8x4", "snorm8x2", "snorm8x4", "uint16x2", "uint16x4", "sint16x2", "sint16x4", "unorm16x2", "unorm16x4", "snorm16x2", "snorm16x4", "float16x2", "float16x4", "float32", "float32x2", "float32x3", "float32x4", "uint32", "uint32x2", "uint32x3", "uint32x4", "sint32", "sint32x2", "sint32x3", "sint32x4", "unorm10-10-10-2"];
1049
+ type LooseTypeLiteral = (typeof looseTypeLiterals)[number];
1050
+ type AnyLooseData = LooseArray | LooseStruct | LooseDecorated | PackedData;
1051
+ declare function isLooseData(data: unknown): data is AnyLooseData;
1052
+ /**
1053
+ * Checks whether the passed in value is a loose-array schema,
1054
+ * as opposed to, e.g., a regular array schema.
1055
+ *
1056
+ * Array schemas can be used to describe uniform and storage buffers,
1057
+ * whereas looseArray schemas cannot. Loose arrays are useful for
1058
+ * defining vertex buffers instead.
1059
+ *
1060
+ * @example
1061
+ * isLooseArray(d.arrayOf(d.u32, 4)) // false
1062
+ * isLooseArray(d.looseArrayOf(d.u32, 4)) // true
1063
+ * isLooseArray(d.vec3f) // false
1064
+ */
1065
+ declare function isLooseArray<T extends LooseArray>(schema: T | unknown): schema is T;
1066
+ /**
1067
+ * Checks whether passed in value is a looseStruct schema,
1068
+ * as opposed to, e.g., a struct schema.
1069
+ *
1070
+ * Struct schemas can be used to describe uniform and storage buffers,
1071
+ * whereas looseStruct schemas cannot. Loose structs are useful for
1072
+ * defining vertex buffers instead.
1073
+ *
1074
+ * @example
1075
+ * isLooseStruct(d.struct({ a: d.u32 })) // false
1076
+ * isLooseStruct(d.looseStruct({ a: d.u32 })) // true
1077
+ * isLooseStruct(d.vec3f) // false
1078
+ */
1079
+ declare function isLooseStruct<T extends LooseStruct>(schema: T | unknown): schema is T;
1080
+ declare function isLooseDecorated<T extends LooseDecorated>(value: T | unknown): value is T;
1081
+ declare function isData(value: unknown): value is AnyData;
1082
+ type AnyData = AnyWgslData | AnyLooseData;
1083
+
1084
+ /**
1085
+ * Strips schema types down to their most basic forms. (native -> exotic)
1086
+ * This is used by schema constructors to be able to ingest native schemas (created by TypeGPU), and
1087
+ * spit out a type that matches non-native schemas as well.
1088
+ */
1089
+ type Exotic<T> = T extends {
1090
+ readonly '~exotic': infer TExotic;
1091
+ } ? TExotic : T;
1092
+ type ExoticRecord<T> = T extends Record<string | number | symbol, unknown> ? {
1093
+ [Key in keyof T]: Exotic<T[Key]>;
1094
+ } : T;
1095
+
1096
+ /**
1097
+ * Can be assigned a name. Not to be confused with
1098
+ * being able to HAVE a name.
1099
+ */
1100
+ interface TgpuNamable {
1101
+ $name(label?: string | undefined): this;
1102
+ }
1103
+
1104
+ type Default<T, TDefault> = unknown extends T ? TDefault : T extends undefined ? TDefault : T;
1105
+ type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
1106
+ type Prettify<T> = {
1107
+ [K in keyof T]: T[K];
1108
+ } & {};
1109
+ /**
1110
+ * Removes properties from record type that extend `Prop`
1111
+ */
1112
+ type OmitProps<T extends Record<string, unknown>, Prop> = Pick<T, {
1113
+ [Key in keyof T]: T[Key] extends Prop ? never : Key;
1114
+ }[keyof T]>;
1115
+ /**
1116
+ * The opposite of Readonly<T>
1117
+ */
1118
+ type Mutable<T> = {
1119
+ -readonly [P in keyof T]: T[P];
1120
+ };
1121
+
1122
+ export { isLocationAttrib as $, type AnyData as A, type BaseWgslData as B, bool as C, type Default as D, type Exotic as E, type F32 as F, f32 as G, f16 as H, type I32 as I, i32 as J, u32 as K, type Location as L, type Mutable as M, isWgslData as N, type OmitProps as O, type Prettify as P, isWgslArray as Q, isWgslStruct as R, type Size as S, type TgpuNamable as T, type U32 as U, type Vec4f as V, type WgslTypeLiteral as W, isAtomic as X, isDecorated as Y, isAlignAttrib as Z, isBuiltinAttrib as _, type Vec4u as a, type PackedData as a$, isSizeAttrib as a0, type Bool as a1, type F16 as a2, type Vec2f as a3, type Vec2i as a4, type Vec2u as a5, type Vec3f as a6, type Vec3i as a7, type Vec3u as a8, type v2i as a9, unorm8x2 as aA, unorm8x4 as aB, snorm8x2 as aC, snorm8x4 as aD, uint16x2 as aE, uint16x4 as aF, sint16x2 as aG, sint16x4 as aH, unorm16x2 as aI, unorm16x4 as aJ, snorm16x2 as aK, snorm16x4 as aL, float16x2 as aM, float16x4 as aN, float32 as aO, float32x2 as aP, float32x3 as aQ, float32x4 as aR, uint32 as aS, uint32x2 as aT, uint32x3 as aU, uint32x4 as aV, sint32 as aW, sint32x2 as aX, sint32x3 as aY, sint32x4 as aZ, unorm10_10_10_2 as a_, type v2u as aa, type v3i as ab, type v3u as ac, type v4i as ad, type v4u as ae, vec2f as af, vec2i as ag, vec2u as ah, vec3f as ai, vec3i as aj, vec3u as ak, vec4f as al, vec4i as am, vec4u as an, isLooseArray as ao, isLooseStruct as ap, isLooseDecorated as aq, isData as ar, isLooseData as as, type FormatToWGSLType as at, type TgpuVertexFormatData as au, packedFormats as av, uint8x2 as aw, uint8x4 as ax, sint8x2 as ay, sint8x4 as az, type Vec4i as b, type UnionToIntersection as c, type Infer as d, type AnyWgslData as e, type Align as f, type Builtin as g, type Decorated as h, type LooseDecorated as i, type AnyLooseData as j, type LooseTypeLiteral as k, type WgslStruct as l, type ExoticRecord as m, type WgslArray as n, type LooseArray as o, type LooseStruct as p, type m2x2f as q, type m3x3f as r, type m4x4f as s, type Mat2x2f as t, type Mat3x3f as u, type v2f as v, type v3f as w, type Mat4x4f as x, type v4f as y, type Atomic as z };