miniray 0.1.1 → 0.1.2
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/README.md +41 -5
- package/lib/main.d.ts +14 -0
- package/miniray.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,11 +75,13 @@ Minify WGSL source code.
|
|
|
75
75
|
|
|
76
76
|
```typescript
|
|
77
77
|
interface MinifyOptions {
|
|
78
|
-
minifyWhitespace?: boolean;
|
|
79
|
-
minifyIdentifiers?: boolean;
|
|
80
|
-
minifySyntax?: boolean;
|
|
81
|
-
mangleExternalBindings?: boolean;
|
|
82
|
-
|
|
78
|
+
minifyWhitespace?: boolean; // Remove whitespace (default: true)
|
|
79
|
+
minifyIdentifiers?: boolean; // Rename identifiers (default: true)
|
|
80
|
+
minifySyntax?: boolean; // Optimize syntax (default: true)
|
|
81
|
+
mangleExternalBindings?: boolean; // Mangle uniform/storage names (default: false)
|
|
82
|
+
treeShaking?: boolean; // Remove unused declarations (default: true)
|
|
83
|
+
preserveUniformStructTypes?: boolean; // Keep struct types used in uniforms (default: false)
|
|
84
|
+
keepNames?: string[]; // Names to preserve from renaming
|
|
83
85
|
}
|
|
84
86
|
|
|
85
87
|
interface MinifyResult {
|
|
@@ -133,6 +135,40 @@ fn getValue() -> f32 { return uniforms * 2.0; }
|
|
|
133
135
|
// Output: "@group(0) @binding(0) var<uniform> a:f32;fn b()->f32{return a*2.0;}"
|
|
134
136
|
```
|
|
135
137
|
|
|
138
|
+
### `treeShaking`
|
|
139
|
+
|
|
140
|
+
Enable dead code elimination to remove unused declarations (default: `true`):
|
|
141
|
+
|
|
142
|
+
```javascript
|
|
143
|
+
minify(source, {
|
|
144
|
+
treeShaking: true, // Remove unreachable code
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### `preserveUniformStructTypes`
|
|
149
|
+
|
|
150
|
+
Automatically preserve struct type names that are used in `var<uniform>` or `var<storage>` declarations (default: `false`):
|
|
151
|
+
|
|
152
|
+
```javascript
|
|
153
|
+
// Input
|
|
154
|
+
const shader = `
|
|
155
|
+
struct MyUniforms { time: f32 }
|
|
156
|
+
@group(0) @binding(0) var<uniform> u: MyUniforms;
|
|
157
|
+
@fragment fn main() -> @location(0) vec4f { return vec4f(u.time); }
|
|
158
|
+
`;
|
|
159
|
+
|
|
160
|
+
// With preserveUniformStructTypes: false (default)
|
|
161
|
+
// struct MyUniforms -> struct a
|
|
162
|
+
|
|
163
|
+
// With preserveUniformStructTypes: true
|
|
164
|
+
// struct MyUniforms preserved
|
|
165
|
+
minify(source, {
|
|
166
|
+
preserveUniformStructTypes: true,
|
|
167
|
+
});
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
This is particularly useful for frameworks like PNGine that detect builtin uniforms by struct type name.
|
|
171
|
+
|
|
136
172
|
### `keepNames`
|
|
137
173
|
|
|
138
174
|
Array of identifier names that should not be renamed:
|
package/lib/main.d.ts
CHANGED
|
@@ -29,6 +29,20 @@ export interface MinifyOptions {
|
|
|
29
29
|
*/
|
|
30
30
|
mangleExternalBindings?: boolean;
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Enable dead code elimination to remove unused declarations.
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
treeShaking?: boolean;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Automatically preserve struct type names that are used in
|
|
40
|
+
* var<uniform> or var<storage> declarations.
|
|
41
|
+
* Useful for frameworks that detect uniforms by struct type name.
|
|
42
|
+
* @default false
|
|
43
|
+
*/
|
|
44
|
+
preserveUniformStructTypes?: boolean;
|
|
45
|
+
|
|
32
46
|
/**
|
|
33
47
|
* Identifier names that should not be renamed.
|
|
34
48
|
*/
|
package/miniray.wasm
CHANGED
|
Binary file
|