fix: Restrict using slot for strings#2700
Conversation
Bundle size comparison (
|
| 🟢 Decreased (max -0.20%) | ➖ Unchanged | 🔴 Increased (max 0.21%) | ❔ Unknown |
|---|---|---|---|
| 262 | 36 | 23 | 0 |
import { ... } in PR vs import * as ... in PR (is the library tree-Shakeable?):
| Test | tsdown |
|---|---|
| tgpu_init.ts | 256.72 kB ( |
| tgpu_initFromDevice.ts | 256.21 kB ( |
| tgpu_resolve.ts | 187.44 kB ( |
| tgpu_resolveWithContext.ts | 187.37 kB ( |
| tgpu_bindGroupLayout.ts | 68.97 kB ( |
| tgpu_mutableAccessor.ts | 65.90 kB ( |
| tgpu_accessor.ts | 65.88 kB ( |
| tgpu_privateVar.ts | 65.26 kB ( |
| tgpu_workgroupVar.ts | 65.26 kB ( |
| tgpu_const.ts | 64.49 kB ( |
| tgpu_fn.ts | 38.06 kB ( |
| tgpu_fragmentFn.ts | 37.99 kB ( |
| tgpu_vertexFn.ts | 37.81 kB ( |
| tgpu_computeFn.ts | 37.51 kB ( |
| tgpu_vertexLayout.ts | 26.60 kB ( |
| tgpu_comptime.ts | 14.40 kB ( |
| tgpu_unroll.ts | 2.59 kB ( |
| tgpu_slot.ts | 1.57 kB ( |
| tgpu_lazy.ts | 1.22 kB ( |
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.
Resolution Time Benchmark---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.69, 1.33, 2.65, 4.26, 5.15, 7.37, 13.87, 15.06]
line [0.67, 1.33, 2.90, 4.29, 4.61, 7.40, 14.18, 17.30]
line [0.70, 1.33, 2.78, 3.80, 4.64, 7.47, 13.82, 15.07]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.20, 0.34, 0.46, 0.54, 0.77, 0.76, 0.92, 1.06]
line [0.21, 0.46, 0.50, 0.62, 0.83, 0.87, 1.00, 1.09]
line [0.20, 0.39, 0.45, 0.57, 0.74, 0.81, 1.02, 1.07]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.73, 1.58, 2.66, 4.15, 8.14, 17.05, 36.32, 74.97]
line [0.69, 1.48, 3.15, 4.26, 8.02, 16.86, 36.96, 75.77]
line [0.76, 1.57, 3.35, 4.08, 8.18, 16.72, 36.58, 73.72]
|
1d3e3cd to
7ee8f2d
Compare
|
@pullfrog review |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — This PR prevents raw WGSL string injection through external maps, slots and TGSL expressions by requiring strings to carry a known schema type or be wrapped in a dedicated ResolvableString marker used for argument names.
- Adds
ResolvableStringto wrap raw-WGSL argument identifiers used during entry-function header generation. - Tightens
ResolutionCtx.resolveso that a bare string without a concrete schema throws a clear error instead of being injected. - Replaces
ctx.resolve(value, dataType).valuecalls withctx.resolveSnippetacross generation code for consistency. - Removes strings from the
isWgsl/Wgsltype union, since they are no longer first-class resolvable values. - Adds tests covering direct, indirect, slot-based and TGSL string-injection cases, and updates existing slot tests to use
d.v3fvalues instead of WGSL string snippets.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — This PR prevents raw WGSL string injection through external maps, slots and TGSL expressions by requiring strings to carry a known schema type or be wrapped in a dedicated ResolvableString marker used for argument names.
- Adds
ResolvableStringto wrap raw-WGSL argument identifiers used during entry-function header generation. - Tightens
ResolutionCtx.resolveso that a bare string without a concrete schema throws a clear error instead of being injected. - Replaces
ctx.resolve(value, dataType).valuecalls withctx.resolveSnippetacross generation code for consistency. - Removes strings from the
isWgsl/Wgsltype union, since they are no longer first-class resolvable values. - Adds tests covering direct, indirect, slot-based and TGSL string-injection cases, and updates existing slot tests to use
d.v3fvalues instead of WGSL string snippets.
Kimi K2 (free via Pullfrog for OSS) | 𝕏
|
Run failed. View the logs →
|
|
Important The runtime guard now rejects strings, but the Reviewed changes — restrict raw string injection into WGSL and route internal identifier strings through a new
|
|
Technical note: I attempted to submit the above feedback via
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — The latest commit aligns the type system with the runtime string-injection restriction.
- Removed
stringfromWgslandisWgsl()so plain JS strings no longer type-check as resolvable values, matching the runtime rejection added earlier. - Clarified the scoped string-identifer path in
ResolutionCtx.resolve()with an inline example showing how identifier snippets carry their concrete schema.
Kimi K2 (free via Pullfrog for OSS) | 𝕏

Includes changes from #2703 by @iwoplaza