@bigmistqke/view.gl 0.1.5 → 0.1.7

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.
@@ -0,0 +1,477 @@
1
+ type Prettify<T> = {
2
+ [K in keyof T]: T[K];
3
+ } & {};
4
+ type DeepMerge<A extends readonly [...any]> = A extends [infer L, ...infer R] ? DeepMergeTwo<L, DeepMerge<R>> : unknown;
5
+ type DeepMergeTwo<TBase, TOverride> = {
6
+ [K in keyof TBase | keyof TOverride]: K extends keyof TOverride ? K extends keyof TBase ? ShallowMerge<[TBase[K], TOverride[K]]> : TOverride[K] : K extends keyof TBase ? TBase[K] : never;
7
+ };
8
+ type ShallowMerge<A extends readonly [...any]> = A extends [infer L, ...infer R] ? ShallowMergeTwo<L, ShallowMerge<R>> : unknown;
9
+ type OptionalPropertyNames<T> = {
10
+ [K in keyof T]-?: {} extends {
11
+ [P in K]: T[K];
12
+ } ? K : never;
13
+ }[keyof T];
14
+ type SpreadProperties<L, R, K extends keyof L & keyof R> = {
15
+ [P in K]: L[P] | Exclude<R[P], undefined>;
16
+ };
17
+ type Id<T> = T extends infer U ? {
18
+ [K in keyof U]: U[K];
19
+ } : never;
20
+ type ShallowMergeTwo<L, R> = Id<Pick<L, Exclude<keyof L, keyof R>> & Pick<R, Exclude<keyof R, OptionalPropertyNames<R>>> & Pick<R, Exclude<OptionalPropertyNames<R>, keyof L>> & SpreadProperties<L, R, OptionalPropertyNames<R> & keyof L>>;
21
+
22
+ type GL = WebGLRenderingContext | WebGL2RenderingContext;
23
+ type GLTarget = 'ARRAY_BUFFER' | 'ELEMENT_ARRAY_BUFFER';
24
+ type GLUsage = 'STATIC_DRAW' | 'DYNAMIC_DRAW' | 'STREAM_DRAW';
25
+ type GLTextureTarget = 'TEXTURE_2D' | 'TEXTURE_CUBE_MAP';
26
+ type GLTextureFormat = 'RGBA' | 'RGB' | 'RGBA32F' | 'RGB32F' | 'RGBA16F' | 'RGB16F';
27
+ type GLTextureType = 'UNSIGNED_BYTE' | 'FLOAT' | 'HALF_FLOAT';
28
+ type GLTextureFilter = 'NEAREST' | 'LINEAR';
29
+ type GLTextureWrap = 'CLAMP_TO_EDGE' | 'REPEAT' | 'MIRRORED_REPEAT';
30
+ interface KIND_TO_UNIFORM_FN_NAME_MAP {
31
+ float: '1f';
32
+ vec2: '2f';
33
+ vec3: '3f';
34
+ vec4: '4f';
35
+ int: '1i';
36
+ ivec2: '2i';
37
+ ivec3: '3i';
38
+ ivec4: '4i';
39
+ mat2: 'Matrix2fv';
40
+ mat3: 'Matrix3fv';
41
+ mat4: 'Matrix4fv';
42
+ uint: '1ui';
43
+ uvec2: '2ui';
44
+ uvec3: '3ui';
45
+ uvec4: '4ui';
46
+ mat2x3: 'Matrix2x3fv';
47
+ mat2x4: 'Matrix2x4fv';
48
+ mat3x2: 'Matrix3x2fv';
49
+ mat3x4: 'Matrix3x4fv';
50
+ mat4x2: 'Matrix4x2fv';
51
+ mat4x3: 'Matrix4x3fv';
52
+ bool: '1i';
53
+ bvec2: '2i';
54
+ bvec3: '3i';
55
+ bvec4: '4i';
56
+ sampler2D: '1i';
57
+ samplerCube: '1i';
58
+ sampler2DArray: '1i';
59
+ sampler3D: '1i';
60
+ sampler2DShadow: '1i';
61
+ samplerCubeShadow: '1i';
62
+ sampler2DArrayShadow: '1i';
63
+ isampler2D: '1i';
64
+ isampler3D: '1i';
65
+ isamplerCube: '1i';
66
+ isampler2DArray: '1i';
67
+ usampler2D: '1i';
68
+ usampler3D: '1i';
69
+ usamplerCube: '1i';
70
+ usampler2DArray: '1i';
71
+ }
72
+ interface KIND_TO_SIZE_MAP {
73
+ float: 1;
74
+ vec2: 2;
75
+ vec3: 3;
76
+ vec4: 4;
77
+ int: 1;
78
+ ivec2: 2;
79
+ ivec3: 3;
80
+ ivec4: 4;
81
+ bool: 1;
82
+ bvec2: 2;
83
+ bvec3: 3;
84
+ bvec4: 4;
85
+ uint: 1;
86
+ uvec2: 2;
87
+ uvec3: 3;
88
+ uvec4: 4;
89
+ mat2: 4;
90
+ mat3: 9;
91
+ mat4: 16;
92
+ mat2x3: 6;
93
+ mat2x4: 8;
94
+ mat3x2: 6;
95
+ mat3x4: 12;
96
+ mat4x2: 8;
97
+ mat4x3: 12;
98
+ sampler2D: 1;
99
+ samplerCube: 1;
100
+ sampler3D: 1;
101
+ sampler2DArray: 1;
102
+ sampler2DShadow: 1;
103
+ samplerCubeShadow: 1;
104
+ sampler2DArrayShadow: 1;
105
+ isampler2D: 1;
106
+ isampler3D: 1;
107
+ isamplerCube: 1;
108
+ isampler2DArray: 1;
109
+ usampler2D: 1;
110
+ usampler3D: 1;
111
+ usamplerCube: 1;
112
+ usampler2DArray: 1;
113
+ }
114
+ /**********************************************************************************/
115
+ /**********************************************************************************/
116
+ type UniformFnName = '1f' | '2f' | '3f' | '4f' | '1i' | '2i' | '3i' | '4i' | '1ui' | '2ui' | '3ui' | '4ui' | 'mat2' | 'mat3' | 'mat4' | 'mat2x3' | 'mat2x4' | 'mat3x2' | 'mat3x4' | 'mat4x2' | 'mat4x3' | 'sampler2D' | 'samplerCube' | 'sampler2DArray' | 'isampler2D' | 'isamplerCube' | 'isampler2DArray' | 'usampler2D' | 'usamplerCube' | 'usampler2DArray';
117
+ type UniformKind = 'float' | 'vec2' | 'vec3' | 'vec4' | 'int' | 'ivec2' | 'ivec3' | 'ivec4' | 'bool' | 'bvec2' | 'bvec3' | 'bvec4' | 'mat2' | 'mat3' | 'mat4' | 'sampler2D' | 'samplerCube' | 'uint' | 'uvec2' | 'uvec3' | 'uvec4' | 'mat2x3' | 'mat2x4' | 'mat3x2' | 'mat3x4' | 'mat4x2' | 'mat4x3' | 'sampler3D' | 'sampler2DArray' | 'sampler2DShadow' | 'samplerCubeShadow' | 'sampler2DArrayShadow' | 'isampler2D' | 'isampler3D' | 'isamplerCube' | 'isampler2DArray' | 'usampler2D' | 'usampler3D' | 'usamplerCube' | 'usampler2DArray';
118
+ interface UniformKindMap {
119
+ float: [number];
120
+ vec2: [number, number];
121
+ vec3: [number, number, number];
122
+ vec4: [number, number, number, number];
123
+ int: [number];
124
+ ivec2: [number, number];
125
+ ivec3: [number, number, number];
126
+ ivec4: [number, number, number, number];
127
+ bool: [number];
128
+ bvec2: [number, number];
129
+ bvec3: [number, number, number];
130
+ bvec4: [number, number, number, number];
131
+ uint: [number];
132
+ uvec2: [number, number];
133
+ uvec3: [number, number, number];
134
+ uvec4: [number, number, number, number];
135
+ mat2: [Float32Array] | [
136
+ number,
137
+ number,
138
+ number,
139
+ number
140
+ ];
141
+ mat3: [Float32Array] | [
142
+ number,
143
+ number,
144
+ number,
145
+ number,
146
+ number,
147
+ number,
148
+ number,
149
+ number,
150
+ number
151
+ ];
152
+ mat4: [Float32Array] | [
153
+ number,
154
+ number,
155
+ number,
156
+ number,
157
+ number,
158
+ number,
159
+ number,
160
+ number,
161
+ number,
162
+ number,
163
+ number,
164
+ number,
165
+ number,
166
+ number,
167
+ number,
168
+ number
169
+ ];
170
+ mat2x3: [Float32Array] | [
171
+ number,
172
+ number,
173
+ number,
174
+ number,
175
+ number,
176
+ number
177
+ ];
178
+ mat2x4: [Float32Array] | [
179
+ number,
180
+ number,
181
+ number,
182
+ number,
183
+ number,
184
+ number,
185
+ number,
186
+ number
187
+ ];
188
+ mat3x2: [Float32Array] | [
189
+ number,
190
+ number,
191
+ number,
192
+ number,
193
+ number,
194
+ number
195
+ ];
196
+ mat3x4: [Float32Array] | [
197
+ number,
198
+ number,
199
+ number,
200
+ number,
201
+ number,
202
+ number,
203
+ number,
204
+ number,
205
+ number,
206
+ number,
207
+ number,
208
+ number
209
+ ];
210
+ mat4x2: [Float32Array] | [
211
+ number,
212
+ number,
213
+ number,
214
+ number,
215
+ number,
216
+ number,
217
+ number,
218
+ number
219
+ ];
220
+ mat4x3: [Float32Array] | [
221
+ number,
222
+ number,
223
+ number,
224
+ number,
225
+ number,
226
+ number,
227
+ number,
228
+ number,
229
+ number,
230
+ number,
231
+ number,
232
+ number
233
+ ];
234
+ sampler2D: [number];
235
+ samplerCube: [number];
236
+ sampler3D: [number];
237
+ sampler2DArray: [number];
238
+ sampler2DShadow: [number];
239
+ samplerCubeShadow: [number];
240
+ sampler2DArrayShadow: [number];
241
+ isampler2D: [number];
242
+ isampler3D: [number];
243
+ isamplerCube: [number];
244
+ isampler2DArray: [number];
245
+ usampler2D: [number];
246
+ usampler3D: [number];
247
+ usamplerCube: [number];
248
+ usampler2DArray: [number];
249
+ }
250
+ interface UniformDefinition {
251
+ kind: UniformKind;
252
+ size?: number;
253
+ }
254
+ type UniformSchema = Record<string | symbol, UniformDefinition>;
255
+ type UniformSchemaPartial = Record<string | symbol, Partial<UniformDefinition>>;
256
+ type UniformMethods<TDefinition extends UniformDefinition> = TDefinition['size'] extends number ? {
257
+ set(arg: Float32Array): void;
258
+ } : {
259
+ set(...args: UniformKindMap[TDefinition['kind']]): void;
260
+ };
261
+ type UniformView<T extends UniformSchema> = {
262
+ [K in keyof T]: UniformMethods<T[K]>;
263
+ };
264
+ /**********************************************************************************/
265
+ /**********************************************************************************/
266
+ type AttributeShortHand = '1f' | '2f' | '3f' | '4f' | '1i' | '2i' | '3i' | '4i' | '1ui' | '2ui' | '3ui' | '4ui';
267
+ type AttributeKind = 'float' | 'vec2' | 'vec3' | 'vec4' | 'mat2' | 'mat3' | 'mat4' | 'mat2x3' | 'mat2x4' | 'mat3x2' | 'mat3x4' | 'mat4x2' | 'mat4x3' | 'int' | 'ivec2' | 'ivec3' | 'ivec4' | 'uint' | 'uvec2' | 'uvec3' | 'uvec4';
268
+ interface AttributeDefinition {
269
+ kind: AttributeKind;
270
+ instanced?: boolean;
271
+ buffer?: WebGLBuffer;
272
+ }
273
+ type AttributeSchema = Record<string | symbol, AttributeDefinition>;
274
+ interface AttributeMethods<T = AttributeKind> {
275
+ buffer: WebGLBuffer;
276
+ bind(): void;
277
+ set(data: Float32Array, usage?: GLUsage): {
278
+ bind(): void;
279
+ };
280
+ dispose(): void;
281
+ }
282
+ type AttributeView<T extends AttributeSchema> = {
283
+ [K in keyof T]: AttributeMethods<T[K]['kind']>;
284
+ };
285
+ /**********************************************************************************/
286
+ /**********************************************************************************/
287
+ interface InterleavedAttributeLayout {
288
+ key: string | symbol;
289
+ kind: AttributeKind;
290
+ }
291
+ interface InterleavedAttributeDefinition {
292
+ layout: InterleavedAttributeLayout[];
293
+ instanced?: boolean;
294
+ }
295
+ type InterleavedAttributeSchema = Record<string | symbol, InterleavedAttributeDefinition>;
296
+ interface InterleavedAttributeMethods<T extends InterleavedAttributeLayout[] = InterleavedAttributeLayout[]> {
297
+ bind(): void;
298
+ unbind(): void;
299
+ set(data: Float32Array, usage?: GLUsage): void;
300
+ dispose(): void;
301
+ }
302
+ type InterleavedAttributeView<T extends InterleavedAttributeSchema> = {
303
+ [K in keyof T]: InterleavedAttributeMethods<T[K]['layout']>;
304
+ };
305
+ /**********************************************************************************/
306
+ /**********************************************************************************/
307
+ interface BufferDefinition {
308
+ target?: GLTarget;
309
+ usage?: GLUsage;
310
+ }
311
+ type BufferSchema = Record<string | symbol, BufferDefinition>;
312
+ interface BufferMethods {
313
+ set(data: Float32Array | Uint16Array | Uint32Array): void;
314
+ bind(): void;
315
+ dispose(): void;
316
+ }
317
+ type BufferView<T extends BufferSchema> = {
318
+ [K in keyof T]: BufferMethods;
319
+ };
320
+ /**********************************************************************************/
321
+ /**********************************************************************************/
322
+ interface FramebufferDefinition extends Omit<TextureDefinition, 'data'> {
323
+ attachment: 'color' | 'depth' | 'stencil' | 'depthStencil';
324
+ texture?: WebGLTexture;
325
+ }
326
+ interface TextureDefinition {
327
+ target?: GLTextureTarget;
328
+ width: number;
329
+ height: number;
330
+ level?: number;
331
+ border?: number;
332
+ internalFormat?: GLTextureFormat;
333
+ format?: GLTextureFormat;
334
+ type?: GLTextureType;
335
+ minFilter?: GLTextureFilter;
336
+ magFilter?: GLTextureFilter;
337
+ wrapS?: GLTextureWrap;
338
+ wrapT?: GLTextureWrap;
339
+ data?: ArrayBufferView | null;
340
+ }
341
+ interface Framebuffer {
342
+ texture: WebGLTexture;
343
+ framebuffer: WebGLFramebuffer;
344
+ }
345
+ /**********************************************************************************/
346
+ /**********************************************************************************/
347
+ type TextureTarget = 'TEXTURE_2D' | 'TEXTURE_CUBE_MAP' | 'TEXTURE_3D' | 'TEXTURE_2D_ARRAY';
348
+ type TextureSchema = Record<string | symbol, TextureDefinition>;
349
+ interface TextureMethods {
350
+ texture: WebGLTexture;
351
+ dispose(): void;
352
+ bind(unit?: number): void;
353
+ set(data: ImageBufferSource | null, options?: Partial<TexImage2DOptions>): void;
354
+ parameters(params: Record<number, number>): void;
355
+ }
356
+ type TextureView<T extends TextureSchema> = {
357
+ [K in keyof T]: TextureMethods;
358
+ };
359
+ type TextureParameterName = 'TEXTURE_MIN_FILTER' | 'TEXTURE_MAG_FILTER' | 'TEXTURE_WRAP_S' | 'TEXTURE_WRAP_T' | 'TEXTURE_WRAP_R';
360
+ type TextureParameterValue = 'NEAREST' | 'LINEAR' | 'NEAREST_MIPMAP_NEAREST' | 'LINEAR_MIPMAP_NEAREST' | 'NEAREST_MIPMAP_LINEAR' | 'LINEAR_MIPMAP_LINEAR' | 'CLAMP_TO_EDGE' | 'REPEAT' | 'MIRRORED_REPEAT';
361
+ type TextureParameters = Partial<Record<TextureParameterName, TextureParameterValue>>;
362
+ type InternalFormat = 'ALPHA' | 'RGB' | 'RGBA' | 'LUMINANCE' | 'LUMINANCE_ALPHA' | 'DEPTH_COMPONENT' | 'DEPTH_STENCIL' | 'R8' | 'RG8' | 'RGB8' | 'RGBA8' | 'DEPTH_COMPONENT16' | 'DEPTH_COMPONENT24' | 'DEPTH24_STENCIL8';
363
+ type Format = 'ALPHA' | 'RGB' | 'RGBA' | 'LUMINANCE' | 'LUMINANCE_ALPHA' | 'DEPTH_COMPONENT' | 'DEPTH_STENCIL';
364
+ type PixelType = 'UNSIGNED_BYTE' | 'UNSIGNED_SHORT_5_6_5' | 'UNSIGNED_SHORT_4_4_4_4' | 'UNSIGNED_SHORT_5_5_5_1' | 'FLOAT' | 'HALF_FLOAT' | 'UNSIGNED_INT_24_8' | 'UNSIGNED_INT' | 'BYTE' | 'SHORT' | 'INT';
365
+ type TexImage2DOptions = {
366
+ level: number;
367
+ internalFormat: InternalFormat;
368
+ width: number;
369
+ height: number;
370
+ border: number;
371
+ format: Format;
372
+ type: PixelType;
373
+ };
374
+ /**********************************************************************************/
375
+ /**********************************************************************************/
376
+ interface ViewOptions {
377
+ signal?: AbortSignal;
378
+ }
379
+ interface ViewSchema {
380
+ uniforms?: UniformSchema;
381
+ attributes?: AttributeSchema;
382
+ interleavedAttributes?: InterleavedAttributeSchema;
383
+ buffers?: BufferSchema;
384
+ }
385
+ interface ViewSchemaPartial {
386
+ uniforms?: Record<string | symbol, Partial<UniformDefinition>>;
387
+ attributes?: Record<string | symbol, Partial<AttributeDefinition>>;
388
+ interleavedAttributes?: Record<string | symbol, Partial<InterleavedAttributeDefinition>>;
389
+ buffers?: Record<string | symbol, Partial<BufferDefinition>>;
390
+ }
391
+ type View<T extends ViewSchema = ViewSchema> = {
392
+ attributes: T['attributes'] extends AttributeSchema ? AttributeView<T['attributes']> : undefined;
393
+ interleavedAttributes: T['interleavedAttributes'] extends InterleavedAttributeSchema ? InterleavedAttributeView<T['interleavedAttributes']> : undefined;
394
+ buffers: T['buffers'] extends BufferSchema ? BufferView<T['buffers']> : undefined;
395
+ uniforms: T['uniforms'] extends UniformSchema ? UniformView<T['uniforms']> : never;
396
+ };
397
+ /**********************************************************************************/
398
+ /**********************************************************************************/
399
+ interface GLSLResult {
400
+ program: WebGLProgram;
401
+ schema: ViewSchema;
402
+ }
403
+ type GLSLSlotItem = GLSLTag | UniformTag | AttributeTag | InterleaveTag | string | number | symbol;
404
+ type GLSLSlot = GLSLSlotItem | Array<GLSLSlotItem>;
405
+ interface GLSLTag<TSlots extends GLSLSlot[] = GLSLSlot[]> {
406
+ type: 'glsl';
407
+ template: TemplateStringsArray;
408
+ slots: TSlots;
409
+ }
410
+ type UniformTag<TKey extends string | symbol = string | symbol, TKind extends UniformKind = UniformKind, TDefinition extends Partial<UniformDefinition> = UniformDefinition> = TDefinition extends {
411
+ size: infer TSize;
412
+ } ? {
413
+ type: 'uniform';
414
+ kind: TKind;
415
+ key: TKey;
416
+ size: TSize;
417
+ } : {
418
+ type: 'uniform';
419
+ kind: TKind;
420
+ key: TKey;
421
+ };
422
+ interface UniformTagFn<TKind extends UniformKind> {
423
+ <const TKey extends string | symbol, const TDefinition extends Omit<UniformDefinition, 'kind'>>(key: TKey, TDefinition: TDefinition): Prettify<UniformTag<TKey, TKind, TDefinition>>;
424
+ <const TName extends string | symbol>(key: TName): Prettify<UniformTag<TName, TKind>>;
425
+ }
426
+ interface AttributeTag<TKey extends string | symbol = string | symbol, TKind extends AttributeKind = AttributeKind, TInstanced extends boolean | undefined = boolean | undefined> {
427
+ type: 'attribute';
428
+ kind: TKind;
429
+ instanced: TInstanced;
430
+ key: TKey;
431
+ }
432
+ interface AttributeTagFn<TKey extends AttributeKind> {
433
+ <TName extends string | symbol, TDefinition extends Omit<AttributeDefinition, 'kind'>>(key: TName, options: TDefinition): Prettify<AttributeTag<TName, TKey, TDefinition['instanced']>>;
434
+ <TName extends string | symbol>(key: TName): Prettify<AttributeTag<TName, TKey, undefined>>;
435
+ }
436
+ type InterleaveTag<TKey extends string | symbol = string | symbol, TLayout extends Array<AttributeTag<string | symbol, AttributeKind, undefined>> = Array<AttributeTag<string | symbol, AttributeKind, undefined>>, TDefinition extends Omit<AttributeDefinition, 'kind'> = Omit<AttributeDefinition, 'kind'>> = TDefinition & {
437
+ key: TKey;
438
+ type: 'interleavedAttribute';
439
+ layout: {
440
+ [TKey in keyof TLayout]: Prettify<Pick<TLayout[TKey], 'kind' | 'key'>>;
441
+ };
442
+ };
443
+ type GLSLTagToSchema<TTag extends GLSLTag> = FlattenSlots<TTag> extends infer TSlots ? TSlots extends Array<any> ? GLSLSlotsToSchema<TSlots> : never : never;
444
+ type GLSLSlotsToSchema<TSlots extends Array<GLSLSlot>> = {
445
+ uniforms: {
446
+ [K in Extract<TSlots[number], UniformTag> as K['key']]: Prettify<Omit<K, 'name' | 'type'>>;
447
+ };
448
+ attributes: {
449
+ [K in Extract<TSlots[number], AttributeTag> as K['key']]: Prettify<Omit<K, 'name' | 'type'>>;
450
+ };
451
+ interleavedAttributes: {
452
+ [K in Extract<TSlots[number], InterleaveTag> as K['key']]: Prettify<Omit<K, 'name' | 'type'>>;
453
+ };
454
+ };
455
+ type FlattenSlots<T> = T extends GLSLTag<infer TSlots> ? _FlattenSlots<TSlots> : T extends Array<GLSLSlot> ? _FlattenSlots<T> : never;
456
+ type _FlattenSlots<T extends Array<GLSLSlot>> = T extends [infer First, ...infer Rest] ? First extends GLSLTag ? [...FlattenSlots<First>, ...FlattenSlots<Rest>] : First extends unknown[] ? [...FlattenSlots<First>, ...FlattenSlots<Rest>] : [First, ...FlattenSlots<Rest>] : [];
457
+ type MergeGLSLSchema<TVertex extends ViewSchema, TFragment extends ViewSchema, TOverrides extends ViewSchemaPartial = {}> = {
458
+ uniforms: DeepMerge<[
459
+ ShallowMerge<[TVertex['uniforms'], TFragment['uniforms']]>,
460
+ TOverrides['uniforms']
461
+ ]>;
462
+ attributes: DeepMerge<[
463
+ ShallowMerge<[TVertex['attributes'], TFragment['attributes']]>,
464
+ TOverrides['attributes']
465
+ ]>;
466
+ interleavedAttributes: DeepMerge<[
467
+ ShallowMerge<[TVertex['interleavedAttributes'], TFragment['interleavedAttributes']]>,
468
+ TOverrides['interleavedAttributes']
469
+ ]>;
470
+ };
471
+ type CompileResult<TVertex extends GLSLTag, TFragment extends GLSLTag, TOverrides extends ViewSchemaPartial> = MergeGLSLSchema<GLSLTagToSchema<TVertex>, GLSLTagToSchema<TFragment>, TOverrides> extends infer TSchema extends ViewSchema ? {
472
+ program: WebGLProgram;
473
+ schema: TSchema;
474
+ view: View<TSchema>;
475
+ } : never;
476
+
477
+ export type { UniformTag as $, AttributeSchema as A, BufferSchema as B, BufferDefinition as C, BufferMethods as D, Framebuffer as E, FramebufferDefinition as F, GL as G, TextureTarget as H, InterleavedAttributeSchema as I, TextureSchema as J, KIND_TO_UNIFORM_FN_NAME_MAP as K, TextureMethods as L, TextureView as M, TextureParameterName as N, TextureParameterValue as O, TextureParameters as P, InternalFormat as Q, Format as R, PixelType as S, TextureDefinition as T, UniformSchema as U, ViewSchema as V, TexImage2DOptions as W, ViewSchemaPartial as X, GLSLResult as Y, GLSLSlot as Z, GLSLTag as _, ViewOptions as a, UniformTagFn as a0, AttributeTag as a1, AttributeTagFn as a2, InterleaveTag as a3, GLSLTagToSchema as a4, GLSLSlotsToSchema as a5, MergeGLSLSchema as a6, CompileResult as a7, Prettify as a8, 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, UniformDefinition as q, UniformSchemaPartial as r, UniformMethods as s, AttributeShortHand as t, AttributeKind as u, AttributeDefinition as v, AttributeMethods as w, InterleavedAttributeLayout as x, InterleavedAttributeDefinition as y, InterleavedAttributeMethods as z };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bigmistqke/view.gl",
3
- "version": "0.1.5",
4
- "description": "🪟 Utilities for managing WebGL resources.",
3
+ "version": "0.1.7",
4
+ "description": "👀 Utilities for managing WebGL resources.",
5
5
  "exports": {
6
6
  ".": {
7
7
  "import": "./dist/index.mjs",
package/src/features.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { GL, RemoveSuffix } from './types'
1
+ import { RemoveSuffix } from './type-utils'
2
+ import type { GL } from './types'
2
3
 
3
4
  const INSTANCED_ARRAYS_WRAPPER_MAP = new WeakMap<
4
5
  GL,
package/src/index.ts CHANGED
@@ -24,6 +24,7 @@ import {
24
24
  kindToUniformFnName,
25
25
  ObjectUtils,
26
26
  } from './utils'
27
+ export * from './types'
27
28
 
28
29
  /**********************************************************************************/
29
30
  /* */
@@ -33,8 +34,12 @@ import {
33
34
 
34
35
  let index = 0
35
36
  const PREFIX = 'VIEW_GL_ALIAS'
37
+ const IS_FIREFOX = navigator.userAgent.toLowerCase().indexOf('firefox') >= 0
36
38
 
37
- const SYMBOL_MAP = createUpsertMap(WeakMap<symbol, string>)
39
+ // NOTE: using symbol as key for WeakMap is currently broken in firefox
40
+ // see https://bugzilla.mozilla.org/show_bug.cgi?id=1710433
41
+ // fallback to Map will currently cause a memory leak.
42
+ const SYMBOL_MAP = createUpsertMap(IS_FIREFOX ? Map<symbol, string> : WeakMap<symbol, string>)
38
43
 
39
44
  export function toID(key: string | number | symbol) {
40
45
  if (typeof key === 'string') {