Skip to content

Commit

Permalink
Remove explicit example-toolkit API from live code editor (#561)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhawryluk authored Nov 15, 2024
1 parent a9dbf63 commit 2e6f2f1
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 55 deletions.
2 changes: 0 additions & 2 deletions apps/typegpu-docs/src/components/CodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import webgpuTypes from '@webgpu/types/dist/index.d.ts?raw';
import type { editor } from 'monaco-editor';
import { entries, map, pipe } from 'remeda';
import typedBinary from 'typed-binary/dist/index.d.ts?raw';
import toolkitTypes from '../types/example-toolkit.d.ts?raw';
import { tsCompilerOptions } from '../utils/liveEditor/embeddedTypeScript';
import useEvent from '../utils/useEvent';

Expand Down Expand Up @@ -60,7 +59,6 @@ function handleEditorWillMount(monaco: Monaco) {
for (const lib of mediacaptureExtraLibs) {
tsDefaults.addExtraLib(lib.content, lib.filename);
}
tsDefaults.addExtraLib(toolkitTypes, 'example-toolkit.d.ts');
tsDefaults.addExtraLib(typedBinary, 'typed-binary.d.ts');
tsDefaults.addExtraLib(typegpuJitDts, 'typegpu-jit.d.ts');

Expand Down
10 changes: 0 additions & 10 deletions apps/typegpu-docs/src/types/example-toolkit.d.ts

This file was deleted.

43 changes: 0 additions & 43 deletions apps/typegpu-docs/src/utils/examples/exampleRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as Babel from '@babel/standalone';
import type TemplateGenerator from '@babel/template';
import type { TraverseOptions } from '@babel/traverse';
import { filter, isNonNull, map, pipe } from 'remeda';
import { wgsl } from 'typegpu/experimental';
import { transpileModule } from 'typescript';
import { tsCompilerOptions } from '../liveEditor/embeddedTypeScript';
import type { ExampleControlParam } from './exampleControlAtom';
Expand Down Expand Up @@ -192,46 +191,6 @@ export async function executeExample(
}
}

// TODO: remove after merging textures
function addSliderPlumParameter(
label: string,
initial: number,
options?: { min?: number; max?: number; step?: number },
) {
let value: string | number | boolean = initial;
const listeners = new Set<() => unknown>();

if (disposed) {
return;
}

controlParams.push({
label,
initial,
min: options?.min,
max: options?.max,
step: options?.step,
onSliderChange: (newValue) => {
value = newValue;
// Calling `listener` may cause more listeners to
// be attached, so copying.
for (const listener of [...listeners]) {
listener();
}
},
});

return wgsl
.plumFromEvent(
(listener) => {
listeners.add(listener);
return () => listeners.delete(listener);
},
() => value,
)
.$name(label);
}

try {
/**
* Simulated imports from within the sandbox, making only a subset of
Expand Down Expand Up @@ -261,8 +220,6 @@ export async function executeExample(
cleanupCallbacks.push(callback);
},
addParameters,
// TODO: remove after merging textures
addSliderPlumParameter,
};
}
throw new Error(`Module ${moduleKey} is not available in the sandbox.`);
Expand Down

0 comments on commit 2e6f2f1

Please sign in to comment.