Releases: CodyJasonBennett/shaderkit
Releases · CodyJasonBennett/shaderkit
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
v0.1.11
What's Changed
- fix(types): resolve as proper dual pkg via TypeScript by @CodyJasonBennett in #15
Full Changelog: v0.1.10...v0.1.11
v0.1.10
What's Changed
- fix(tokenizer): correctly filter E notation, hexadecimals by @CodyJasonBennett in #13
Full Changelog: v0.1.9...v0.1.10
v0.1.9
What's Changed
- fix(minifier): harden UBO namespace check by @CodyJasonBennett in #9
Full Changelog: v0.1.8...v0.1.9