Releases: CodyJasonBennett/shaderkit
v0.5.0
What's Changed
- fix: add InvariantStatement by @CodyJasonBennett in #28
- feat: GLSL ES 3.1 support by @CodyJasonBennett in #29
- fix(minifier): don't use reserved words for mangled identifiers by @CodyJasonBennett in #30
Full Changelog: v0.4.1...v0.5.0
v0.4.1
What's Changed
- fix: add main key for Bundlephobia resolver by @CodyJasonBennett in #27
Full Changelog: v0.4.0...v0.4.1
v0.4.0
What's Changed
- feat: visit API by @CodyJasonBennett in #26
This release follows up v0.3.0 with a visitor API to recurse AST. Useful for reflecting or modifying a shader program.
import { type Program, parse, visit, generate } from 'shaderkit'
// https://github.com/CodyJasonBennett/shaderkit#ast
const program: Program = parse(glsl)
// optionally reflect program here (e.g. collect all global uniforms)
const uniforms: string[] = []
visit(program, {
VariableDeclarator(node) {
if (node.qualifiers.includes('uniform')) {
uniforms.push(node.id.name)
}
},
})
// optionally modify program here (e.g. remove version header)
visit(program, {
PreprocessorStatement(node, ancestors) {
const parent = ancestors.at(-1)
if (node.name === 'version' && parent?.type === 'Program') {
parent.body.splice(parent.body.indexOf(node), 1)
}
},
})
// Compile back into GLSL
const output: string = generate(program, { target: 'GLSL' })
Full Changelog: v0.3.1...v0.4.0
v0.3.1
What's Changed
- fix(minifier): preserve whitespace after #if directives by @CodyJasonBennett in #24
- fix(parser): handle preprocessor in struct declarations by @CodyJasonBennett in #25
Full Changelog: v0.3.0...v0.3.1
v0.3.0
What's Changed
- fix(tokenizer): greedy match for complex numbers by @CodyJasonBennett in 3695286
- fix(tokenizer): aggregate shorthand floats, better EOL handling in comments by @CodyJasonBennett in 4182b4d
- fix(parser): include version header by @CodyJasonBennett in e0dcff2
- fix(minifier): pad after define arguments by @CodyJasonBennett in 342a7b7
- fix!: publish as ESM, tree-shaking by @CodyJasonBennett in 5ba6897
- fix(generator): don't add whitespace by @CodyJasonBennett in 630f249
- fix(parser): handle UBOs by @CodyJasonBennett in 0a5b29d
- fix(parser): handle variable declarator array specifiers by @CodyJasonBennett in e5d1643
- fix(generator): re-implement with new AST by @CodyJasonBennett in 73c13a8
- refactor(parser)!: align AST between spec and ESTree by @CodyJasonBennett in 3052467
- fix(parser): newlines, begin validating type errors by @CodyJasonBennett in ec4f802
- fix(generator): remaining combinatorics by @CodyJasonBennett in 01cd281
- fix(parser): remaining combinatorics by @CodyJasonBennett in 5129fc9
- refactor(parser): robust expression parsing, error handling by @CodyJasonBennett in #22
This release includes a rewrite to the AST parser and generator, with minor fixes to the tokenizer and minifier (note this will be rewritten once WGSL AST is implemented #21).
Both GLSL and WGSL are supported by the tokenizer and minifier, but only GLSL is supported so far by the parser and generator (#20).
This enables code modification and reflection of GLSL programs, although a visitor API does not yet exist, and AST nodes must be manually recursed.
import { type Program, parse, generate } from 'shaderkit'
// https://github.com/CodyJasonBennett/shaderkit#ast
const program: Program = parse(glsl)
// optionally reflect program here (e.g. collect all global uniforms)
const uniforms: string[] = []
for (const node of program.body) {
if (node.type === 'VariableDeclaration') {
for (const declaration of node.declarations) {
if (declaration.qualifiers.includes('uniform') {
uniforms.push(declaration.id.name)
}
}
}
}
// optionally modify program here (e.g. remove version header)
if (program.body[0].type === 'PreprocessorStatement') program.body.shift()
// Compile back into GLSL
const output: string = generate(program, { target: 'GLSL' })
Full Changelog: v0.2.1...v0.3.0
v0.2.1
What's Changed
- fix: add WebGL1 keywords for three.js by @CodyJasonBennett in #23
Full Changelog: v0.2.0...v0.2.1
v0.2.0
v0.1.14
What's Changed
- fix(tokenizer): harden WGSL detection by @CodyJasonBennett in #18
Full Changelog: v0.1.13...v0.1.14
v0.1.13
What's Changed
- fix(minifier): track member prefixes for mangling by @CodyJasonBennett in #17
Full Changelog: v0.1.12...v0.1.13
v0.1.12
What's Changed
- fix(minifier): track and only write externals to mangleMap by @CodyJasonBennett in #16
Full Changelog: v0.1.11...v0.1.12