@rosalana/sandbox 0.0.5 → 0.2.0
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 +286 -47
- package/dist/errors/base.d.ts +6 -0
- package/dist/errors/context.d.ts +7 -0
- package/dist/errors/index.d.ts +7 -0
- package/dist/errors/module.d.ts +42 -0
- package/dist/errors/program.d.ts +5 -0
- package/dist/errors/shader.d.ts +34 -0
- package/dist/errors/texture.d.ts +12 -0
- package/dist/errors/unknown.d.ts +7 -0
- package/dist/globals.d.ts +17 -0
- package/dist/index.cjs.js +834 -8
- package/dist/index.d.ts +99 -1
- package/dist/index.es.js +2718 -485
- package/dist/tools/compilable.d.ts +79 -0
- package/dist/tools/module.d.ts +46 -0
- package/dist/tools/module_registry.d.ts +63 -0
- package/dist/tools/parser.d.ts +32 -0
- package/dist/tools/program.d.ts +1 -12
- package/dist/tools/shader.d.ts +4 -0
- package/dist/tools/texture.d.ts +64 -0
- package/dist/tools/textures.d.ts +48 -0
- package/dist/tools/uniforms.d.ts +0 -2
- package/dist/tools/web_gl.d.ts +16 -2
- package/dist/types.d.ts +123 -1
- package/package.json +8 -5
- package/dist/errors.d.ts +0 -32
package/README.md
CHANGED
|
@@ -18,13 +18,13 @@ It's **DX‑friendly**, small, and intentionally minimal — perfect for gradien
|
|
|
18
18
|
|
|
19
19
|
### Bundle size comparison
|
|
20
20
|
|
|
21
|
-
| Library | Minified | Gzipped
|
|
22
|
-
| ----------- | -------- |
|
|
23
|
-
| **Sandbox** |
|
|
24
|
-
| three.js | 694 KB | 175 KB
|
|
25
|
-
| p5.js | 1.1 MB | 351 KB
|
|
21
|
+
| Library | Minified | Gzipped |
|
|
22
|
+
| ----------- | -------- | --------- |
|
|
23
|
+
| **Sandbox** | 85 KB | **23 KB** |
|
|
24
|
+
| three.js | 694 KB | 175 KB |
|
|
25
|
+
| p5.js | 1.1 MB | 351 KB |
|
|
26
26
|
|
|
27
|
-
Sandbox is **~
|
|
27
|
+
Sandbox is **~8x smaller** than three.js and **~15x smaller** than p5.js.
|
|
28
28
|
|
|
29
29
|
It works in both **WebGL1 and WebGL2** contexts, with automatic fallback and detection.
|
|
30
30
|
|
|
@@ -35,12 +35,14 @@ It works in both **WebGL1 and WebGL2** contexts, with automatic fallback and det
|
|
|
35
35
|
- [Playback control](#playback-control)
|
|
36
36
|
- [Time control](#time-control)
|
|
37
37
|
- [Static rendering](#static-rendering)
|
|
38
|
-
- [Shaders](#shaders)
|
|
39
|
-
- [WebGL version detection](#webgl-version-detection)
|
|
40
|
-
- [Uniforms](#uniforms)
|
|
41
|
-
- [Built‑in uniforms](#built-in-uniforms)
|
|
38
|
+
- [Sandbox Shaders](#sandbox-shaders)
|
|
42
39
|
- [Hooks](#hooks)
|
|
43
40
|
- [Self-removing hooks](#self-removing-hooks)
|
|
41
|
+
- [Textures](#textures)
|
|
42
|
+
- [Texture options](#texture-options)
|
|
43
|
+
- [Dynamic textures](#dynamic-textures)
|
|
44
|
+
- [Export](#export)
|
|
45
|
+
- [Streaming](#streaming)
|
|
44
46
|
- [Chaining](#chaining)
|
|
45
47
|
- [Error handling](#error-handling)
|
|
46
48
|
- [Vue integration](#vue-integration)
|
|
@@ -120,76 +122,183 @@ Or render at a specific time — perfect for deterministic, reproducible output:
|
|
|
120
122
|
sandbox.renderAt(1.5);
|
|
121
123
|
```
|
|
122
124
|
|
|
123
|
-
## Shaders
|
|
125
|
+
## Sandbox Shaders
|
|
124
126
|
|
|
125
|
-
|
|
127
|
+
Writing GLSL from scratch means a lot of ceremony — uniform declarations, copy-pasting utility functions, wiring everything together. Sandbox takes care of the boring parts so you can focus on the shader itself.
|
|
126
128
|
|
|
127
|
-
|
|
129
|
+
The idea is simple: define reusable GLSL snippets as **modules**, then `#import` them with a single line. Sandbox resolves dependencies, declares uniforms, and injects everything into the final shader automatically.
|
|
130
|
+
|
|
131
|
+
### Writing shaders
|
|
132
|
+
|
|
133
|
+
You only need to provide a fragment shader. Sandbox ships with a default fullscreen vertex shader and automatically matches WebGL versions — so you can focus on the fun part.
|
|
128
134
|
|
|
129
135
|
```ts
|
|
130
136
|
sandbox.setFragment(fragmentSource);
|
|
131
137
|
```
|
|
132
138
|
|
|
133
|
-
|
|
139
|
+
Need full control over both shaders? No problem:
|
|
134
140
|
|
|
135
141
|
```ts
|
|
136
142
|
sandbox.setShader(vertexSource, fragmentSource);
|
|
137
143
|
```
|
|
138
144
|
|
|
139
|
-
|
|
145
|
+
Sandbox detects WebGL version from your code (`#version 300 es` → WebGL2, no directive → WebGL1) and falls back gracefully. You can always check what you're running:
|
|
140
146
|
|
|
141
|
-
|
|
147
|
+
```ts
|
|
148
|
+
sandbox.version; // 1 or 2
|
|
149
|
+
```
|
|
142
150
|
|
|
143
|
-
-
|
|
144
|
-
- no version directive → WebGL1
|
|
151
|
+
### Built-in uniforms
|
|
145
152
|
|
|
146
|
-
|
|
153
|
+
These uniforms are populated automatically every frame. Just use them in your shader — no declaration or setup needed:
|
|
154
|
+
|
|
155
|
+
| Uniform | Type | Description |
|
|
156
|
+
| -------------- | ----- | --------------------------- |
|
|
157
|
+
| `u_resolution` | vec2 | Canvas size in pixels |
|
|
158
|
+
| `u_time` | float | Elapsed time (seconds) |
|
|
159
|
+
| `u_delta` | float | Delta time since last frame |
|
|
160
|
+
| `u_mouse` | vec2 | Mouse position on canvas |
|
|
161
|
+
| `u_frame` | int | Frame counter |
|
|
162
|
+
|
|
163
|
+
Built-in uniforms are globally available — even inside imported module functions. They're never namespaced, so `u_time` is always just `u_time`, everywhere.
|
|
164
|
+
|
|
165
|
+
### Custom uniforms
|
|
166
|
+
|
|
167
|
+
Need your own data in the shader? Declare the uniform in GLSL, then set it from JavaScript:
|
|
147
168
|
|
|
148
169
|
```ts
|
|
149
|
-
sandbox.
|
|
170
|
+
sandbox.setUniform<number>("u_intensity", 0.8);
|
|
171
|
+
|
|
172
|
+
sandbox.setUniforms({
|
|
173
|
+
u_intensity: 0.75,
|
|
174
|
+
u_color: [1, 0.2, 0.3],
|
|
175
|
+
});
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Read a value back:
|
|
179
|
+
|
|
180
|
+
```ts
|
|
181
|
+
const intensity = sandbox.getUniform<number>("u_intensity");
|
|
150
182
|
```
|
|
151
183
|
|
|
152
|
-
|
|
184
|
+
Everything is **type-safe** and **chainable**. All numeric values are treated as floats — simple and predictable.
|
|
153
185
|
|
|
154
|
-
|
|
186
|
+
### Modules
|
|
155
187
|
|
|
156
|
-
|
|
188
|
+
> [!IMPORTANT]
|
|
189
|
+
> Sandbox's built-in GLSL modules are still in beta and may change at any time.
|
|
190
|
+
> We published them early to get feedback. If you have ideas for improvements, please open an issue or a PR — we'd love your input.
|
|
191
|
+
|
|
192
|
+
Modules are reusable GLSL snippets that you can import into any shader. Sandbox ships with a built-in `"sandbox"` module, and you can define your own:
|
|
157
193
|
|
|
158
194
|
```ts
|
|
159
|
-
|
|
195
|
+
Sandbox.defineModule("my_effects", myGLSLSource);
|
|
160
196
|
```
|
|
161
197
|
|
|
162
|
-
|
|
198
|
+
Then import any function from it:
|
|
199
|
+
|
|
200
|
+
```glsl
|
|
201
|
+
#import bloom from "my_effects"
|
|
202
|
+
#import hex from "sandbox"
|
|
203
|
+
|
|
204
|
+
void main() {
|
|
205
|
+
vec3 color = hex(0xFF5733);
|
|
206
|
+
fragColor = vec4(bloom(color), 1.0);
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
When you import a function, Sandbox pulls in everything it needs — the function body, any helper functions it calls, and any required uniforms. Each import is fully isolated, so importing the same function twice won't cause conflicts.
|
|
211
|
+
|
|
212
|
+
> [!NOTE]
|
|
213
|
+
> All imported code is namespaced automatically to avoid naming collisions.
|
|
214
|
+
|
|
215
|
+
Module names starting with `"sandbox"` are reserved for built-in modules. Each module can only be defined once — this prevents accidental overwrites.
|
|
216
|
+
|
|
217
|
+
Want to see what's available? Inspect all registered modules at any time:
|
|
163
218
|
|
|
164
219
|
```ts
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
220
|
+
Sandbox.availableModules();
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
You can also preview how your shader will look after processing:
|
|
224
|
+
|
|
225
|
+
```ts
|
|
226
|
+
Sandbox.compile(shaderSource);
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
This is useful for debugging or precompiling shaders before deploying.
|
|
230
|
+
|
|
231
|
+
### Module options
|
|
232
|
+
|
|
233
|
+
Imported functions can expose configurable options — friendly names that map to GLSL uniforms under the hood. You control them from JavaScript using `sandbox.module()`:
|
|
234
|
+
|
|
235
|
+
```ts
|
|
236
|
+
sandbox.module("effect", {
|
|
237
|
+
intensity: 0.8,
|
|
171
238
|
});
|
|
172
239
|
```
|
|
173
240
|
|
|
174
|
-
|
|
241
|
+
This is a powerful way to customize imported effects without touching any GLSL code.
|
|
242
|
+
|
|
243
|
+
#### Hardcoded vs. dynamic values
|
|
244
|
+
|
|
245
|
+
By default, a module's uniforms are only included in the final shader when you actually reference them. This gives you a choice — hardcode a value directly, or use the `@` syntax to wire it up as a configurable uniform:
|
|
246
|
+
|
|
247
|
+
```glsl
|
|
248
|
+
#import effect from "my_module"
|
|
249
|
+
|
|
250
|
+
void main() {
|
|
251
|
+
vec3 a = effect(v_texcoord, 2.0); // hardcoded value
|
|
252
|
+
vec3 b = effect(v_texcoord, @effect.intensity); // dynamic — set via sandbox.module()
|
|
253
|
+
fragColor = vec4(a + b, 1.0);
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
The `@effect.intensity` syntax tells Sandbox to inject the uniform and keep it in sync with whatever you set in JavaScript.
|
|
258
|
+
|
|
259
|
+
#### Defining options
|
|
260
|
+
|
|
261
|
+
When defining a module, you declare which options each function supports:
|
|
175
262
|
|
|
176
263
|
```ts
|
|
177
|
-
|
|
264
|
+
Sandbox.defineModule("my_gradient", gradientSource, {
|
|
265
|
+
myFunc: {
|
|
266
|
+
colors: {
|
|
267
|
+
uniform: "u_colors",
|
|
268
|
+
default: [
|
|
269
|
+
[1, 0, 0],
|
|
270
|
+
[0, 0, 1],
|
|
271
|
+
],
|
|
272
|
+
},
|
|
273
|
+
speed: { uniform: "u_speed", default: 1.0 },
|
|
274
|
+
},
|
|
275
|
+
});
|
|
178
276
|
```
|
|
179
277
|
|
|
180
|
-
|
|
278
|
+
Each option has a `uniform` (the GLSL name it maps to) and an optional `default` value applied automatically on import.
|
|
181
279
|
|
|
182
|
-
|
|
280
|
+
If all functions in your module share the same options, use the `default` key to avoid repetition:
|
|
183
281
|
|
|
184
|
-
|
|
282
|
+
```ts
|
|
283
|
+
Sandbox.defineModule("my_module", source, {
|
|
284
|
+
default: {
|
|
285
|
+
colors: {
|
|
286
|
+
uniform: "u_colors",
|
|
287
|
+
default: [
|
|
288
|
+
[1, 0, 0],
|
|
289
|
+
[0, 0, 1],
|
|
290
|
+
],
|
|
291
|
+
},
|
|
292
|
+
speed: { uniform: "u_speed", default: 1.0 },
|
|
293
|
+
},
|
|
294
|
+
specialFunc: {
|
|
295
|
+
speed: { uniform: "u_speed", default: 2.0 },
|
|
296
|
+
// "colors" is inherited from default
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
```
|
|
185
300
|
|
|
186
|
-
|
|
187
|
-
| -------------- | ----- | --------------------------- |
|
|
188
|
-
| `u_resolution` | vec2 | Canvas size in pixels |
|
|
189
|
-
| `u_time` | float | Elapsed time (seconds) |
|
|
190
|
-
| `u_delta` | float | Delta time since last frame |
|
|
191
|
-
| `u_mouse` | vec2 | Mouse position on canvas |
|
|
192
|
-
| `u_frame` | int | Frame counter |
|
|
301
|
+
Per-function options always take priority over `default` when both define the same key.
|
|
193
302
|
|
|
194
303
|
## Hooks
|
|
195
304
|
|
|
@@ -238,6 +347,124 @@ sandbox.hook(({ time }) => {
|
|
|
238
347
|
|
|
239
348
|
This is how `pauseAt()` works internally — it's hooks all the way down.
|
|
240
349
|
|
|
350
|
+
## Textures
|
|
351
|
+
|
|
352
|
+
Sandbox supports textures as `sampler2D` uniforms. Pass any image, canvas, or video element and Sandbox takes care of the WebGL plumbing — creating the texture, binding it to a texture unit, and setting the sampler uniform.
|
|
353
|
+
|
|
354
|
+
```ts
|
|
355
|
+
const img = new Image();
|
|
356
|
+
img.src = "photo.jpg";
|
|
357
|
+
img.onload = () => {
|
|
358
|
+
sandbox.setTexture("u_texture", img);
|
|
359
|
+
};
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Then sample it in your shader:
|
|
363
|
+
|
|
364
|
+
```glsl
|
|
365
|
+
uniform sampler2D u_texture;
|
|
366
|
+
|
|
367
|
+
void main() {
|
|
368
|
+
vec4 color = texture2D(u_texture, v_texcoord);
|
|
369
|
+
gl_FragColor = color;
|
|
370
|
+
}
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
Multiple textures work the same way — each gets its own texture unit automatically:
|
|
374
|
+
|
|
375
|
+
```ts
|
|
376
|
+
sandbox.setTexture("u_photo", photoImg);
|
|
377
|
+
sandbox.setTexture("u_mask", maskImg);
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
You can also set textures upfront via options:
|
|
381
|
+
|
|
382
|
+
```ts
|
|
383
|
+
Sandbox.create(canvas, {
|
|
384
|
+
fragment: shader,
|
|
385
|
+
textures: {
|
|
386
|
+
u_photo: photoImg,
|
|
387
|
+
u_mask: { source: maskImg, wrap: "repeat" },
|
|
388
|
+
},
|
|
389
|
+
});
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### Texture options
|
|
393
|
+
|
|
394
|
+
Each texture accepts optional configuration for wrapping, filtering, and orientation:
|
|
395
|
+
|
|
396
|
+
```ts
|
|
397
|
+
sandbox.setTexture("u_texture", img, {
|
|
398
|
+
wrap: "repeat", // both axes (default: "clamp")
|
|
399
|
+
minFilter: "nearest", // pixelated look (default: "linear")
|
|
400
|
+
flipY: false, // disable vertical flip (default: true)
|
|
401
|
+
});
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
| Option | Values | Default |
|
|
405
|
+
| ----------- | ---------------------------------- | ---------- |
|
|
406
|
+
| `wrap` | `"clamp"`, `"repeat"`, `"mirror"` | `"clamp"` |
|
|
407
|
+
| `wrapS` | same (overrides `wrap` for S axis) | `wrap` |
|
|
408
|
+
| `wrapT` | same (overrides `wrap` for T axis) | `wrap` |
|
|
409
|
+
| `minFilter` | `"nearest"`, `"linear"` | `"linear"` |
|
|
410
|
+
| `magFilter` | `"nearest"`, `"linear"` | `"linear"` |
|
|
411
|
+
| `flipY` | `boolean` | `true` |
|
|
412
|
+
| `dynamic` | `boolean` | auto |
|
|
413
|
+
|
|
414
|
+
### Dynamic textures
|
|
415
|
+
|
|
416
|
+
When you pass a video element, Sandbox automatically re-uploads pixels every frame so the texture stays in sync with playback. This also works for animated canvases — just set `dynamic: true`:
|
|
417
|
+
|
|
418
|
+
```ts
|
|
419
|
+
// Video — dynamic by default
|
|
420
|
+
sandbox.setTexture("u_video", videoElement);
|
|
421
|
+
|
|
422
|
+
// Animated canvas — opt in
|
|
423
|
+
sandbox.setTexture("u_canvas", canvasElement, { dynamic: true });
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
To remove a texture and free its GPU memory:
|
|
427
|
+
|
|
428
|
+
```ts
|
|
429
|
+
sandbox.removeTexture("u_texture");
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
## Export
|
|
433
|
+
|
|
434
|
+
Sandbox can export the current frame as an image or blob — useful for saving screenshots, generating thumbnails, or uploading processed images to a server.
|
|
435
|
+
|
|
436
|
+
```ts
|
|
437
|
+
// Data URL (synchronous)
|
|
438
|
+
const url = sandbox.renderAt(1.5).exportAsURL("image/png");
|
|
439
|
+
|
|
440
|
+
// Blob (async) — perfect for server uploads
|
|
441
|
+
const blob = await sandbox.renderAt(1.5).exportAsBlob("image/jpeg", 0.9);
|
|
442
|
+
await fetch("/upload", { method: "POST", body: blob });
|
|
443
|
+
|
|
444
|
+
// HTMLImageElement
|
|
445
|
+
const img = sandbox.renderAt(1.5).exportAsImage("image/png");
|
|
446
|
+
document.body.appendChild(img);
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
> [!NOTE]
|
|
450
|
+
> Export methods work reliably after `render()` or `renderAt()`. If you need to capture frames during an active render loop, set `preserveDrawingBuffer: true` in options.
|
|
451
|
+
|
|
452
|
+
### Streaming
|
|
453
|
+
|
|
454
|
+
For real-time use cases like video calls or recording, Sandbox can expose the canvas as a `MediaStream`:
|
|
455
|
+
|
|
456
|
+
```ts
|
|
457
|
+
// WebRTC — send shader output to a video call
|
|
458
|
+
const stream = sandbox.stream(30);
|
|
459
|
+
peerConnection.addTrack(stream.getVideoTracks()[0], stream);
|
|
460
|
+
|
|
461
|
+
// Recording — save as video file
|
|
462
|
+
const recorder = new MediaRecorder(sandbox.stream(30));
|
|
463
|
+
recorder.start();
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
This opens up workflows like **webcam → texture → shader effect → video call** with just a few lines of code.
|
|
467
|
+
|
|
241
468
|
## Chaining
|
|
242
469
|
|
|
243
470
|
Every method returns `this`, so you can chain calls for clean, expressive code:
|
|
@@ -264,11 +491,19 @@ Sandbox.create(canvas, {
|
|
|
264
491
|
|
|
265
492
|
The error object includes useful details:
|
|
266
493
|
|
|
267
|
-
- `error.code` — error
|
|
268
|
-
- `error.lines` — line numbers where errors occurred (for compilation errors)
|
|
494
|
+
- `error.code` — error category (see table below)
|
|
495
|
+
- `error.lines` — line numbers where errors occurred (for shader compilation errors)
|
|
269
496
|
- `error.shaderType` — which shader failed (`vertex` or `fragment`)
|
|
270
497
|
|
|
271
|
-
|
|
498
|
+
| Code | When |
|
|
499
|
+
| ------------------ | ------------------------------------------------------------------------------------- |
|
|
500
|
+
| `CONTEXT_ERROR` | WebGL not supported or context creation failed |
|
|
501
|
+
| `SHADER_ERROR` | Shader compilation failed, version mismatch, import syntax error, or missing function |
|
|
502
|
+
| `PROGRAM_ERROR` | Shader program linking failed |
|
|
503
|
+
| `VALIDATION_ERROR` | Vertex/fragment shader version mismatch |
|
|
504
|
+
| `MODULE_ERROR` | Module not found, method not found, forbidden name, or duplicate definition |
|
|
505
|
+
| `TEXTURE_ERROR` | Texture creation failed or texture unit limit exceeded |
|
|
506
|
+
| `UNKNOWN_ERROR` | Unexpected error in callbacks (onLoad, hooks) |
|
|
272
507
|
|
|
273
508
|
## Vue integration
|
|
274
509
|
|
|
@@ -337,6 +572,8 @@ interface SandboxOptions {
|
|
|
337
572
|
onBeforeRender?: HookCallback | null;
|
|
338
573
|
onAfterRender?: HookCallback | null;
|
|
339
574
|
uniforms?: UniformSchema;
|
|
575
|
+
modules?: Record<string, Record<string, AnyUniformValue>>;
|
|
576
|
+
textures?: TextureSchema;
|
|
340
577
|
}
|
|
341
578
|
```
|
|
342
579
|
|
|
@@ -355,12 +592,14 @@ interface SandboxOptions {
|
|
|
355
592
|
| `onBeforeRender` | — | Hook before each frame |
|
|
356
593
|
| `onAfterRender` | — | Hook after each frame |
|
|
357
594
|
| `uniforms` | — | Initial uniform values |
|
|
595
|
+
| `modules` | — | Configure module options per imported function |
|
|
596
|
+
| `textures` | — | Initial textures to bind to sampler uniforms |
|
|
358
597
|
|
|
359
598
|
## Limitations (by design)
|
|
360
599
|
|
|
361
|
-
- No textures (planned for future)
|
|
362
600
|
- No multi‑pass rendering
|
|
363
601
|
- No 3D scene graph
|
|
602
|
+
- No custom geometry (fullscreen quad only)
|
|
364
603
|
|
|
365
604
|
If you need a full engine, reach for three.js. For clean shader‑only effects, Sandbox is a joy to use.
|
|
366
605
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type SandboxErrorCode = "CONTEXT_ERROR" | "VALIDATION_ERROR" | "PROGRAM_ERROR" | "SHADER_ERROR" | "MODULE_ERROR" | "TEXTURE_ERROR" | "UNKNOWN_ERROR";
|
|
2
|
+
export declare class SandboxError extends Error {
|
|
3
|
+
readonly code: SandboxErrorCode;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
constructor(message: string, code: SandboxErrorCode);
|
|
6
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { SandboxError } from "./base";
|
|
2
|
+
export declare class SandboxModuleNotFoundError extends SandboxError {
|
|
3
|
+
readonly moduleName: string;
|
|
4
|
+
constructor(moduleName: string);
|
|
5
|
+
}
|
|
6
|
+
export declare class SandboxModuleMethodNotFoundError extends SandboxError {
|
|
7
|
+
readonly moduleName: string;
|
|
8
|
+
readonly methodName: string;
|
|
9
|
+
constructor(moduleName: string, methodName: string);
|
|
10
|
+
}
|
|
11
|
+
export declare class SandboxAttemptedToImportMainFunctionError extends SandboxError {
|
|
12
|
+
readonly moduleName: string;
|
|
13
|
+
constructor(moduleName: string);
|
|
14
|
+
}
|
|
15
|
+
export declare class SandboxAttemptedToImportDefaultFunctionError extends SandboxError {
|
|
16
|
+
readonly moduleName: string;
|
|
17
|
+
constructor(moduleName: string);
|
|
18
|
+
}
|
|
19
|
+
export declare class SandboxForbiddenModuleNameError extends SandboxError {
|
|
20
|
+
readonly moduleName: string;
|
|
21
|
+
constructor(moduleName: string);
|
|
22
|
+
}
|
|
23
|
+
export declare class SandboxOverwriteModuleError extends SandboxError {
|
|
24
|
+
readonly moduleName: string;
|
|
25
|
+
constructor(moduleName: string);
|
|
26
|
+
}
|
|
27
|
+
export declare class SandboxMentionUniformNotFoundError extends SandboxError {
|
|
28
|
+
readonly moduleName: string;
|
|
29
|
+
readonly functionName: string;
|
|
30
|
+
readonly uniformName: string;
|
|
31
|
+
constructor(moduleName: string, functionName: string, uniformName: string);
|
|
32
|
+
}
|
|
33
|
+
export declare class SandboxMentionFunctionNotFoundError extends SandboxError {
|
|
34
|
+
readonly functionName: string;
|
|
35
|
+
readonly uniformName: string;
|
|
36
|
+
constructor(functionName: string, uniformName: string);
|
|
37
|
+
}
|
|
38
|
+
export declare class SandboxMentionCouldNotBeReplacedError extends SandboxError {
|
|
39
|
+
readonly mentionName: string;
|
|
40
|
+
readonly calledInFunction: string;
|
|
41
|
+
constructor(mentionName: string, calledInFunction: string);
|
|
42
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { SandboxError } from "./base";
|
|
2
|
+
export declare class SandboxShaderVersionMismatchError extends SandboxError {
|
|
3
|
+
readonly vertexVersion: number;
|
|
4
|
+
readonly fragmentVersion: number;
|
|
5
|
+
constructor(vertexVersion: number, fragmentVersion: number);
|
|
6
|
+
}
|
|
7
|
+
export declare class SandboxGLSLShaderCompilationError extends SandboxError {
|
|
8
|
+
readonly shaderType: "vertex" | "fragment";
|
|
9
|
+
readonly source: string;
|
|
10
|
+
readonly infoLog: string;
|
|
11
|
+
readonly lines: number[];
|
|
12
|
+
constructor(shaderType: "vertex" | "fragment", source: string, infoLog: string);
|
|
13
|
+
private static parseErrorLines;
|
|
14
|
+
}
|
|
15
|
+
export declare class SandboxShaderRequirementMismatchError extends SandboxError {
|
|
16
|
+
readonly requirement: "uniform" | "function";
|
|
17
|
+
readonly name: string;
|
|
18
|
+
readonly expectedType: string;
|
|
19
|
+
readonly actualType: string;
|
|
20
|
+
constructor(requirement: "uniform" | "function", name: string, expectedType: string, actualType: string);
|
|
21
|
+
}
|
|
22
|
+
export declare class SandboxShaderWithoutFunctionError extends SandboxError {
|
|
23
|
+
constructor();
|
|
24
|
+
}
|
|
25
|
+
export declare class SandboxShaderImportSyntaxError extends SandboxError {
|
|
26
|
+
readonly line: number;
|
|
27
|
+
readonly details: string;
|
|
28
|
+
constructor(line: number, details: string);
|
|
29
|
+
}
|
|
30
|
+
export declare class SandboxShaderDuplicateImportNameError extends SandboxError {
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly line: number;
|
|
33
|
+
constructor(name: string, line: number);
|
|
34
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SandboxError } from "./base";
|
|
2
|
+
export declare class SandboxTextureCreationError extends SandboxError {
|
|
3
|
+
readonly textureName: string;
|
|
4
|
+
readonly name = "SandboxTextureCreationError";
|
|
5
|
+
constructor(textureName: string);
|
|
6
|
+
}
|
|
7
|
+
export declare class SandboxTextureUnitLimitError extends SandboxError {
|
|
8
|
+
readonly textureName: string;
|
|
9
|
+
readonly maxUnits: number;
|
|
10
|
+
readonly name = "SandboxTextureUnitLimitError";
|
|
11
|
+
constructor(textureName: string, maxUnits: number);
|
|
12
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SandboxError } from "./base";
|
|
2
|
+
export declare class SandboxOnLoadCallbackError extends SandboxError {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class SandboxOnHookCallbackError extends SandboxError {
|
|
6
|
+
constructor(id: string, message: string);
|
|
7
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import ModuleRegistry from "./tools/module_registry";
|
|
2
|
+
/**
|
|
3
|
+
* Default modules bundled with Sandbox.
|
|
4
|
+
* These modules are available for import in shader source without needing to be registered manually.
|
|
5
|
+
* This registry will grow when more modules are defined
|
|
6
|
+
*/
|
|
7
|
+
export declare const modules: ModuleRegistry;
|
|
8
|
+
/**
|
|
9
|
+
* A global registry of modules that are currently in use by the webGL context.
|
|
10
|
+
* This is flushed on every shader switch.
|
|
11
|
+
*/
|
|
12
|
+
export declare const runtime_modules: ModuleRegistry;
|
|
13
|
+
/**
|
|
14
|
+
* Global uniforms that are automatically provided by Sandbox.
|
|
15
|
+
* These uniforms will NOT be renamed during preprocessing.
|
|
16
|
+
*/
|
|
17
|
+
export declare const uniforms: Map<string, import("./types").GLSLType>;
|