@bigmistqke/view.gl 0.1.12 → 0.1.13
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/dist/index.d.mts +2 -2
- package/dist/tag.d.mts +1 -1
- package/dist/{types-C0zNqcsE.d.mts → types-Cggy6Gkm.d.mts} +9 -2
- package/package.json +1 -1
- package/src/types.ts +52 -33
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { V as ViewSchema, G as GL, a as ViewOptions, b as View, U as UniformSchema, c as UniformView, A as AttributeSchema, d as AttributeView, I as InterleavedAttributeSchema, e as InterleavedAttributeView, B as BufferSchema, f as BufferView } from './types-
|
|
2
|
-
export {
|
|
1
|
+
import { V as ViewSchema, G as GL, a as ViewOptions, b as View, U as UniformSchema, c as UniformView, A as AttributeSchema, d as AttributeView, I as InterleavedAttributeSchema, e as InterleavedAttributeView, B as BufferSchema, f as BufferView } from './types-Cggy6Gkm.mjs';
|
|
2
|
+
export { y as AttributeDefinition, x as AttributeKind, z as AttributeMethods, w as AttributeShortHand, a4 as AttributeToken, a5 as AttributeTokenFn, F as BufferDefinition, H as BufferMethods, ac as CompileResult, aa as FlattenSlots, X as Format, L as Framebuffer, J as FramebufferDefinition, a1 as GLSL, $ as GLSLResult, a0 as GLSLSlot, a9 as GLSLSlotsToSchema, a7 as GLSLToSchema, a8 as GLSLToView, g as GLTarget, l as GLTextureFilter, j as GLTextureFormat, i as GLTextureTarget, k as GLTextureType, m as GLTextureWrap, h as GLUsage, a6 as InterleaveToken, D as InterleavedAttributeDefinition, C as InterleavedAttributeLayout, E as InterleavedAttributeMethods, W as InternalFormat, n as KIND_TO_SIZE_MAP, K as KIND_TO_UNIFORM_FN_NAME_MAP, ab as MergeGLSLSchema, Y as PixelType, Z as TexImage2DOptions, T as TextureDefinition, O as TextureMethods, Q as TextureParameterName, R as TextureParameterValue, S as TextureParameters, N as TextureSchema, M as TextureTarget, P as TextureView, t as UniformArrayMethods, r as UniformDefinition, s as UniformElementMethods, o as UniformFnName, p as UniformKind, q as UniformKindMap, u as UniformMethods, a2 as UniformToken, a3 as UniformTokenFn, v as UniformValue, _ as ViewSchemaPartial } from './types-Cggy6Gkm.mjs';
|
|
3
3
|
|
|
4
4
|
declare function toID(key: string | number | symbol): any;
|
|
5
5
|
/**********************************************************************************/
|
package/dist/tag.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a0 as GLSLSlot, a1 as GLSL, a3 as UniformTokenFn, a5 as AttributeTokenFn, a4 as AttributeToken, x as AttributeKind, y as AttributeDefinition, a6 as InterleaveToken, _ as ViewSchemaPartial, ac as CompileResult, ad as Prettify, a7 as GLSLToSchema, G as GL } from './types-Cggy6Gkm.mjs';
|
|
2
2
|
|
|
3
3
|
declare function glsl<TSlot extends GLSLSlot, const TSlots extends TSlot[]>(template: TemplateStringsArray, ...slots: [...TSlots]): GLSL<TSlots>;
|
|
4
4
|
declare const uniform: {
|
|
@@ -178,6 +178,7 @@ type UniformMethods<TDefinition extends UniformDefinition> = TDefinition['size']
|
|
|
178
178
|
type UniformView<T extends UniformSchema> = {
|
|
179
179
|
[K in keyof T]: UniformMethods<T[K]>;
|
|
180
180
|
};
|
|
181
|
+
type UniformValue = UniformKindMap[UniformKind];
|
|
181
182
|
/**********************************************************************************/
|
|
182
183
|
/**********************************************************************************/
|
|
183
184
|
type AttributeShortHand = '1f' | '2f' | '3f' | '4f' | '1i' | '2i' | '3i' | '4i' | '1ui' | '2ui' | '3ui' | '4ui';
|
|
@@ -375,7 +376,13 @@ type GLSLSlotsToSchema<TSlots extends Array<GLSLSlot>> = {
|
|
|
375
376
|
};
|
|
376
377
|
};
|
|
377
378
|
type FlattenSlots<T, MaxDepth extends Depth = 10> = T extends Array<GLSLSlot> ? _FlattenSlots<T, [], MaxDepth> : T extends GLSL<infer TSlots> ? _FlattenSlots<TSlots, [], MaxDepth> : never;
|
|
378
|
-
type _FlattenSlots<T extends Array<GLSLSlot>, Acc extends Array<any> = [], CurrentDepth extends Depth = 10> = CurrentDepth extends 0 ? [...Acc, ...T] : T extends [infer First, ...infer Rest extends Array<GLSLSlot>] ? First extends GLSL<infer TSlots> ? _FlattenSlots<Rest, [
|
|
379
|
+
type _FlattenSlots<T extends Array<GLSLSlot>, Acc extends Array<any> = [], CurrentDepth extends Depth = 10> = CurrentDepth extends 0 ? [...Acc, ...T] : T extends [infer First, ...infer Rest extends Array<GLSLSlot>] ? First extends GLSL<infer TSlots> ? _FlattenSlots<Rest, [
|
|
380
|
+
...Acc,
|
|
381
|
+
..._FlattenSlots<TSlots, [], Dec<CurrentDepth>>
|
|
382
|
+
], Dec<CurrentDepth>> : First extends GLSLSlot[] ? _FlattenSlots<Rest, [
|
|
383
|
+
...Acc,
|
|
384
|
+
..._FlattenSlots<First, [], Dec<CurrentDepth>>
|
|
385
|
+
], Dec<CurrentDepth>> : _FlattenSlots<Rest, [...Acc, First], Dec<CurrentDepth>> : [...Acc, ...T];
|
|
379
386
|
/**********************************************************************************/
|
|
380
387
|
/**********************************************************************************/
|
|
381
388
|
type Depth = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
|
@@ -406,4 +413,4 @@ type CompileResult<TVertex extends GLSL, TFragment extends GLSL, TOverrideSchema
|
|
|
406
413
|
fragment: string;
|
|
407
414
|
} : never;
|
|
408
415
|
|
|
409
|
-
export type {
|
|
416
|
+
export type { GLSLResult as $, AttributeSchema as A, BufferSchema as B, InterleavedAttributeLayout as C, InterleavedAttributeDefinition as D, InterleavedAttributeMethods as E, BufferDefinition as F, GL as G, BufferMethods as H, InterleavedAttributeSchema as I, FramebufferDefinition as J, KIND_TO_UNIFORM_FN_NAME_MAP as K, Framebuffer as L, TextureTarget as M, TextureSchema as N, TextureMethods as O, TextureView as P, TextureParameterName as Q, TextureParameterValue as R, TextureParameters as S, TextureDefinition as T, UniformSchema as U, ViewSchema as V, InternalFormat as W, Format as X, PixelType as Y, TexImage2DOptions as Z, ViewSchemaPartial as _, ViewOptions as a, GLSLSlot as a0, GLSL as a1, UniformToken as a2, UniformTokenFn as a3, AttributeToken as a4, AttributeTokenFn as a5, InterleaveToken as a6, GLSLToSchema as a7, GLSLToView as a8, GLSLSlotsToSchema as a9, FlattenSlots as aa, MergeGLSLSchema as ab, CompileResult as ac, Prettify as ad, View as b, UniformView as c, AttributeView as d, InterleavedAttributeView as e, BufferView as f, GLTarget as g, GLUsage as h, GLTextureTarget as i, GLTextureFormat as j, GLTextureType as k, GLTextureFilter as l, GLTextureWrap as m, KIND_TO_SIZE_MAP as n, UniformFnName as o, UniformKind as p, UniformKindMap as q, UniformDefinition as r, UniformElementMethods as s, UniformArrayMethods as t, UniformMethods as u, UniformValue as v, AttributeShortHand as w, AttributeKind as x, AttributeDefinition as y, AttributeMethods as z };
|
package/package.json
CHANGED
package/src/types.ts
CHANGED
|
@@ -146,7 +146,7 @@ export type UniformKind = keyof KIND_TO_UNIFORM_FN_NAME_MAP
|
|
|
146
146
|
|
|
147
147
|
type MatrixArray<Size extends number> = [Float32Array] | number[]
|
|
148
148
|
|
|
149
|
-
interface UniformKindMap {
|
|
149
|
+
export interface UniformKindMap {
|
|
150
150
|
// Float scalars and vectors
|
|
151
151
|
float: [number]
|
|
152
152
|
vec2: [number, number]
|
|
@@ -187,11 +187,11 @@ interface UniformKindMap {
|
|
|
187
187
|
// Samplers — always a single number (texture unit)
|
|
188
188
|
sampler2D: [number]
|
|
189
189
|
samplerCube: [number]
|
|
190
|
-
sampler3D: [number]
|
|
191
|
-
sampler2DArray: [number]
|
|
192
|
-
sampler2DShadow: [number]
|
|
193
|
-
samplerCubeShadow: [number]
|
|
194
|
-
sampler2DArrayShadow: [number]
|
|
190
|
+
sampler3D: [number] // WebGL2
|
|
191
|
+
sampler2DArray: [number] // WebGL2
|
|
192
|
+
sampler2DShadow: [number] // WebGL2
|
|
193
|
+
samplerCubeShadow: [number] // WebGL2
|
|
194
|
+
sampler2DArrayShadow: [number] // WebGL2
|
|
195
195
|
|
|
196
196
|
// Integer samplers (WebGL2)
|
|
197
197
|
isampler2D: [number]
|
|
@@ -219,11 +219,12 @@ export type UniformElementMethods<TKind extends UniformKind> = {
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
/** Methods for array uniforms - supports both bulk set and indexed access */
|
|
222
|
-
export type UniformArrayMethods<TKind extends UniformKind, TSize extends number> =
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
222
|
+
export type UniformArrayMethods<TKind extends UniformKind, TSize extends number> = Array<
|
|
223
|
+
UniformElementMethods<TKind>
|
|
224
|
+
> & {
|
|
225
|
+
/** Bulk set all elements at once */
|
|
226
|
+
set(arg: Float32Array): void
|
|
227
|
+
}
|
|
227
228
|
|
|
228
229
|
export type UniformMethods<TDefinition extends UniformDefinition> =
|
|
229
230
|
TDefinition['size'] extends number
|
|
@@ -234,6 +235,8 @@ export type UniformView<T extends UniformSchema> = {
|
|
|
234
235
|
[K in keyof T]: UniformMethods<T[K]>
|
|
235
236
|
}
|
|
236
237
|
|
|
238
|
+
export type UniformValue = UniformKindMap[UniformKind]
|
|
239
|
+
|
|
237
240
|
/**********************************************************************************/
|
|
238
241
|
/* */
|
|
239
242
|
/* Attributes */
|
|
@@ -507,9 +510,8 @@ export interface ViewSchema {
|
|
|
507
510
|
buffers?: BufferSchema
|
|
508
511
|
}
|
|
509
512
|
|
|
510
|
-
type PartialSchema<T> =
|
|
511
|
-
? Record<string | symbol, Partial<V>>
|
|
512
|
-
: never
|
|
513
|
+
type PartialSchema<T> =
|
|
514
|
+
T extends Record<string | symbol, infer V> ? Record<string | symbol, Partial<V>> : never
|
|
513
515
|
|
|
514
516
|
export interface ViewSchemaPartial {
|
|
515
517
|
uniforms?: PartialSchema<UniformSchema>
|
|
@@ -630,12 +632,11 @@ export type GLSLToSchema<T extends GLSL> =
|
|
|
630
632
|
|
|
631
633
|
export type GLSLToView<T extends GLSL> = View<GLSLToSchema<T>>
|
|
632
634
|
|
|
633
|
-
type ExtractTokens<TSlots extends Array<GLSLSlot>, TTokenType> =
|
|
634
|
-
|
|
635
|
-
? U
|
|
636
|
-
? U
|
|
637
|
-
: never
|
|
635
|
+
type ExtractTokens<TSlots extends Array<GLSLSlot>, TTokenType> = TSlots[number] extends infer U
|
|
636
|
+
? U extends TTokenType
|
|
637
|
+
? U
|
|
638
638
|
: never
|
|
639
|
+
: never
|
|
639
640
|
|
|
640
641
|
export type GLSLSlotsToSchema<TSlots extends Array<GLSLSlot>> = {
|
|
641
642
|
uniforms: {
|
|
@@ -659,14 +660,22 @@ export type FlattenSlots<T, MaxDepth extends Depth = 10> =
|
|
|
659
660
|
type _FlattenSlots<
|
|
660
661
|
T extends Array<GLSLSlot>,
|
|
661
662
|
Acc extends Array<any> = [],
|
|
662
|
-
CurrentDepth extends Depth = 10
|
|
663
|
+
CurrentDepth extends Depth = 10,
|
|
663
664
|
> = CurrentDepth extends 0
|
|
664
665
|
? [...Acc, ...T]
|
|
665
666
|
: T extends [infer First, ...infer Rest extends Array<GLSLSlot>]
|
|
666
667
|
? First extends GLSL<infer TSlots>
|
|
667
|
-
? _FlattenSlots<
|
|
668
|
+
? _FlattenSlots<
|
|
669
|
+
Rest,
|
|
670
|
+
[...Acc, ..._FlattenSlots<TSlots, [], Dec<CurrentDepth>>],
|
|
671
|
+
Dec<CurrentDepth>
|
|
672
|
+
>
|
|
668
673
|
: First extends GLSLSlot[]
|
|
669
|
-
? _FlattenSlots<
|
|
674
|
+
? _FlattenSlots<
|
|
675
|
+
Rest,
|
|
676
|
+
[...Acc, ..._FlattenSlots<First, [], Dec<CurrentDepth>>],
|
|
677
|
+
Dec<CurrentDepth>
|
|
678
|
+
>
|
|
670
679
|
: _FlattenSlots<Rest, [...Acc, First], Dec<CurrentDepth>>
|
|
671
680
|
: [...Acc, ...T]
|
|
672
681
|
|
|
@@ -677,17 +686,27 @@ type _FlattenSlots<
|
|
|
677
686
|
/**********************************************************************************/
|
|
678
687
|
|
|
679
688
|
type Depth = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
|
|
680
|
-
type Dec<T extends number> = T extends 10
|
|
681
|
-
|
|
682
|
-
: T extends
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
689
|
+
type Dec<T extends number> = T extends 10
|
|
690
|
+
? 9
|
|
691
|
+
: T extends 9
|
|
692
|
+
? 8
|
|
693
|
+
: T extends 8
|
|
694
|
+
? 7
|
|
695
|
+
: T extends 7
|
|
696
|
+
? 6
|
|
697
|
+
: T extends 6
|
|
698
|
+
? 5
|
|
699
|
+
: T extends 5
|
|
700
|
+
? 4
|
|
701
|
+
: T extends 4
|
|
702
|
+
? 3
|
|
703
|
+
: T extends 3
|
|
704
|
+
? 2
|
|
705
|
+
: T extends 2
|
|
706
|
+
? 1
|
|
707
|
+
: T extends 1
|
|
708
|
+
? 0
|
|
709
|
+
: 0
|
|
691
710
|
|
|
692
711
|
export type MergeGLSLSchema<
|
|
693
712
|
TVertex extends ViewSchema,
|