Skip to content

Commit 88056f7

Browse files
committed
Editor hardening, test baseline, CI validation, export fixes, and blob-tracking groundwork
- fix pre-existing biome lint errors (4 errors across app + package) - add first test suite: 75 tests over .lab parsing, parameter schema, timeline evaluation, composition math, blob tracker, inner effects - CI now lints, typechecks and tests the editor app, not just the package - .lab import: zod schema validation, consent prompt before imported custom-shader code runs, SVG raster resolution capped at 8192 - lazy-load export dialog and video muxers (-99.9 KB first-load JS) - close the video encoder on failed/cancelled exports; 30s timeout on stalled video texture loads - onRuntimeError no longer fires with null after successful init - renderer dedup: drift inventory + consolidation design (plans/006-artifacts) - drop localeCompare from per-frame parameter signatures - blob-tracking foundation: pure CPU tracker + inner-effects modules (unwired) Includes patch changesets for the two package changes.
1 parent 84c1d09 commit 88056f7

35 files changed

Lines changed: 2606 additions & 69 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@basementstudio/shader-lab": patch
3+
---
4+
5+
`onRuntimeError` on `<ShaderLabComposition>` is no longer called with `null` after every successful renderer initialization. It now only fires with `null` once a previously reported error has been resolved, and consecutive identical messages are not repeated. Consumers that surfaced the message without a null check no longer show a false error state.

.changeset/lint-cleanup.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@basementstudio/shader-lab": patch
3+
---
4+
5+
Lint cleanup: convert type-only `three/webgpu` imports to `import type`, remove an unused suppression comment, and simplify a guard expression in the fluid runtime. No behavior changes.

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@ jobs:
3232
- name: Build package
3333
run: bun run --cwd packages/shader-lab-react build
3434

35+
- name: Lint app
36+
run: bun run lint
37+
38+
- name: Type check app
39+
run: bun run typecheck:tsc
40+
41+
- name: Test
42+
run: bun test
43+
3544
- name: Ensure changeset exists for PR changes
3645
if: github.event_name == 'pull_request'
3746
run: bunx changeset status --since=origin/${{ github.base_ref }}

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,21 @@ Handle runtime errors:
9090
<ShaderLabComposition
9191
config={config}
9292
onRuntimeError={(message) => {
93-
console.error(message)
93+
if (message) {
94+
console.error(message)
95+
} else {
96+
console.info("Shader Lab runtime error resolved.")
97+
}
9498
}}
9599
/>
96100
```
97101

102+
`onRuntimeError` is called with a string message when a runtime error occurs
103+
(renderer initialization failure, shader compilation error, missing WebGPU
104+
support). After an error has been reported, it is called once with `null` when
105+
the error is resolved so error UIs can recover. It is never called with `null`
106+
before an error has been reported.
107+
98108
## 2. Use a Composition as a Texture
99109

100110
`useShaderLab` can manage the runtime and return a ready-to-use `THREE.CanvasTexture`.

packages/shader-lab-react/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,21 @@ Handle runtime errors:
9090
<ShaderLabComposition
9191
config={config}
9292
onRuntimeError={(message) => {
93-
console.error(message)
93+
if (message) {
94+
console.error(message)
95+
} else {
96+
console.info("Shader Lab runtime error resolved.")
97+
}
9498
}}
9599
/>
96100
```
97101

102+
`onRuntimeError` is called with a string message when a runtime error occurs
103+
(renderer initialization failure, shader compilation error, missing WebGPU
104+
support). After an error has been reported, it is called once with `null` when
105+
the error is resolved so error UIs can recover. It is never called with `null`
106+
before an error has been reported.
107+
98108
## 2. Use a Composition as a Texture
99109

100110
`useShaderLab` can manage the runtime and return a ready-to-use `THREE.CanvasTexture`.

packages/shader-lab-react/src/ambient/three-tsl.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ declare module "three/tsl" {
9292
export function cross(left: unknown, right: unknown): TSLNode
9393
export function div(left: unknown, right: unknown): TSLNode
9494
export function dot(left: unknown, right: unknown): TSLNode
95-
// biome-ignore lint/suspicious/noExplicitAny: TSL Fn accepts both positional and destructured params
9695
export function Fn(
9796
fn: ShaderNodeFn | ((...args: never[]) => unknown),
9897
layout?: unknown

packages/shader-lab-react/src/fluid/runtime.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,9 +351,14 @@ export class ShaderLabFluidRuntime {
351351
color?: ShaderLabFluidSplatColor
352352
): void {
353353
if (
354-
!(this.readyState && this.renderer && this.velocity && this.density) ||
355-
!this.splatMaterial ||
356-
!this.splatTargetNode
354+
!(
355+
this.readyState &&
356+
this.renderer &&
357+
this.velocity &&
358+
this.density &&
359+
this.splatMaterial &&
360+
this.splatTargetNode
361+
)
357362
) {
358363
return
359364
}

packages/shader-lab-react/src/renderer/chromatic-aberration-pass.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
vec2,
1212
vec4,
1313
} from "three/tsl"
14-
import * as THREE from "three/webgpu"
14+
import type * as THREE from "three/webgpu"
1515
import type { ShaderLabLayerConfig } from "../types"
1616
import { createPipelinePlaceholder, PassNode } from "./pass-node"
1717

packages/shader-lab-react/src/renderer/directional-blur-pass.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as THREE from "three/webgpu"
1+
import type * as THREE from "three/webgpu"
22
import {
33
cos,
44
float,

packages/shader-lab-react/src/renderer/displacement-map-pass.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
vec2,
99
vec4,
1010
} from "three/tsl"
11-
import * as THREE from "three/webgpu"
11+
import type * as THREE from "three/webgpu"
1212
import type { ShaderLabLayerConfig } from "../types"
1313
import { createPipelinePlaceholder, PassNode } from "./pass-node"
1414

0 commit comments

Comments
 (0)