wgsl-play 0.0.35 → 0.0.37
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/dist/WgslPlay-B86UkrM7.d.ts +121 -0
- package/dist/WgslPlay-DZgeJ1h6.js +636 -0
- package/dist/WgslPlay.d.ts +1 -106
- package/dist/WgslPlay.js +2 -454
- package/dist/index.d.ts +1 -2
- package/dist/index.js +3 -7
- package/dist/wgsl-play.js +103 -205
- package/package.json +4 -4
- package/src/Renderer.ts +17 -11
- package/src/WgslPlay.ts +73 -92
- package/dist/Config-BV15Y2ZJ.d.ts +0 -14
- package/dist/WgslPlay-Ben4VdsC.js +0 -203
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { Conditions, LinkParams } from "wesl";
|
|
2
|
+
|
|
3
|
+
//#region src/Config.d.ts
|
|
4
|
+
/** Configuration for wgsl-play. */
|
|
5
|
+
interface WgslPlayConfig {
|
|
6
|
+
/** Root path for internal imports (package::, super::). Default: "/shaders" */
|
|
7
|
+
shaderRoot: string;
|
|
8
|
+
}
|
|
9
|
+
/** Set global defaults for all wgsl-play instances. */
|
|
10
|
+
declare function defaults(config: Partial<WgslPlayConfig>): void;
|
|
11
|
+
/** Get resolved config, merging element overrides with global defaults. */
|
|
12
|
+
declare function getConfig(overrides?: Partial<WgslPlayConfig>): WgslPlayConfig;
|
|
13
|
+
/** Reset config to defaults (useful for testing). */
|
|
14
|
+
declare function resetConfig(): void;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/WgslPlay.d.ts
|
|
17
|
+
/** Project configuration for multi-file shaders (subset of wesl link() API). */
|
|
18
|
+
type WeslProject = Pick<LinkParams, "weslSrc" | "rootModuleName" | "conditions" | "constants" | "libs" | "packageName">;
|
|
19
|
+
/** One source location within a compile error. */
|
|
20
|
+
interface CompileErrorLocation {
|
|
21
|
+
file?: string;
|
|
22
|
+
line: number;
|
|
23
|
+
column: number;
|
|
24
|
+
length?: number;
|
|
25
|
+
severity: "error" | "warning" | "info";
|
|
26
|
+
message: string;
|
|
27
|
+
}
|
|
28
|
+
/** Compile error detail for events. */
|
|
29
|
+
interface CompileErrorDetail {
|
|
30
|
+
message: string;
|
|
31
|
+
source: "wesl" | "webgpu";
|
|
32
|
+
locations: CompileErrorLocation[];
|
|
33
|
+
}
|
|
34
|
+
/** <wgsl-play> web component for rendering WESL/WGSL fragment shaders. */
|
|
35
|
+
declare class WgslPlay extends HTMLElement {
|
|
36
|
+
static observedAttributes: string[];
|
|
37
|
+
private canvas;
|
|
38
|
+
private errorOverlay;
|
|
39
|
+
private controls;
|
|
40
|
+
private resizeObserver;
|
|
41
|
+
private stopRenderLoop?;
|
|
42
|
+
private renderState?;
|
|
43
|
+
private playback;
|
|
44
|
+
private _weslSrc;
|
|
45
|
+
private _rootModuleName;
|
|
46
|
+
private _libs?;
|
|
47
|
+
private _linkOptions;
|
|
48
|
+
private _fromFullProject;
|
|
49
|
+
private _initPromise?;
|
|
50
|
+
private _sourceEl;
|
|
51
|
+
private _sourceListener;
|
|
52
|
+
private _fetchLibs;
|
|
53
|
+
private _dirty;
|
|
54
|
+
private _building;
|
|
55
|
+
private _theme;
|
|
56
|
+
private _mediaQuery;
|
|
57
|
+
private _onFullscreenChange;
|
|
58
|
+
/** Get config overrides from element attributes. */
|
|
59
|
+
private getConfigOverrides;
|
|
60
|
+
constructor();
|
|
61
|
+
connectedCallback(): void;
|
|
62
|
+
disconnectedCallback(): void;
|
|
63
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
64
|
+
/** Current shader source code (main module). */
|
|
65
|
+
get source(): string;
|
|
66
|
+
/** Set shader source directly. */
|
|
67
|
+
set source(value: string);
|
|
68
|
+
/** Conditions for conditional compilation (@if/@elif/@else). */
|
|
69
|
+
get conditions(): Conditions;
|
|
70
|
+
set conditions(value: Conditions);
|
|
71
|
+
/** Set project configuration (mirrors wesl link() API). */
|
|
72
|
+
set project(value: WeslProject);
|
|
73
|
+
/** Set sources from a full project with weslSrc. */
|
|
74
|
+
private setProjectSources;
|
|
75
|
+
/** Whether to auto-fetch missing library packages from npm (default: true). */
|
|
76
|
+
get fetchLibs(): boolean;
|
|
77
|
+
set fetchLibs(value: boolean);
|
|
78
|
+
/** Whether autoplay is enabled (default: true). Set autoplay="false" to start paused. */
|
|
79
|
+
get autoplay(): boolean;
|
|
80
|
+
set autoplay(value: boolean | string);
|
|
81
|
+
/** Whether the shader is currently playing. */
|
|
82
|
+
get isPlaying(): boolean;
|
|
83
|
+
/** Current animation time in seconds. */
|
|
84
|
+
get time(): number;
|
|
85
|
+
/** Number of frames rendered (for testing/debugging). */
|
|
86
|
+
get frameCount(): number;
|
|
87
|
+
/** Whether there's a compilation error. */
|
|
88
|
+
get hasError(): boolean;
|
|
89
|
+
/** Current error message, or null if no error. */
|
|
90
|
+
get errorMessage(): string | null;
|
|
91
|
+
/** Start playback. */
|
|
92
|
+
play(): void;
|
|
93
|
+
/** Pause playback. */
|
|
94
|
+
pause(): void;
|
|
95
|
+
private setPlaying;
|
|
96
|
+
/** Reset animation to time 0 and pause. */
|
|
97
|
+
rewind(): void;
|
|
98
|
+
/** Display error message in overlay. Pass empty string to clear. */
|
|
99
|
+
showError(message: string): void;
|
|
100
|
+
/** Toggle fullscreen on this element. */
|
|
101
|
+
toggleFullscreen(): void;
|
|
102
|
+
private updateTheme;
|
|
103
|
+
/** Set up WebGPU and load initial shader. Returns true if successful. */
|
|
104
|
+
private initialize;
|
|
105
|
+
private doInitialize;
|
|
106
|
+
/** Load from source element, src URL, script child, or inline textContent. */
|
|
107
|
+
private loadInitialContent;
|
|
108
|
+
/** Connect to a source provider element (e.g., wgsl-edit). */
|
|
109
|
+
private connectToSource;
|
|
110
|
+
/** Fetch shader from URL, then trigger a build. */
|
|
111
|
+
private loadFromUrl;
|
|
112
|
+
/** Mark build as needed. Coalesces rapid requests into a single build. */
|
|
113
|
+
private requestBuild;
|
|
114
|
+
/** Run builds until no longer dirty. Only one instance runs at a time. */
|
|
115
|
+
private runBuild;
|
|
116
|
+
private handleCompileError;
|
|
117
|
+
/** Extract source locations from a WESL parse error or GPU compilation error. */
|
|
118
|
+
private extractLocations;
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { WgslPlayConfig as a, resetConfig as c, WgslPlay as i, CompileErrorLocation as n, defaults as o, WeslProject as r, getConfig as s, CompileErrorDetail as t };
|