diff --git a/README.md b/README.md index b82589990e..e93eb7e605 100644 --- a/README.md +++ b/README.md @@ -118,7 +118,7 @@ compute shaders, and `@abc/plot` is a library for plots and visualization using WebGPU. ```ts -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import gen from '@xyz/gen'; import plot from '@abc/plot'; diff --git a/apps/bun-example/index.ts b/apps/bun-example/index.ts index 9b46b38ce7..ac2b1cb46d 100644 --- a/apps/bun-example/index.ts +++ b/apps/bun-example/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { randf } from '@typegpu/noise'; const Boid = d.struct({ diff --git a/apps/resolution-time/procedural.ts b/apps/resolution-time/procedural.ts index 2c8916a740..99c31f024e 100644 --- a/apps/resolution-time/procedural.ts +++ b/apps/resolution-time/procedural.ts @@ -1,6 +1,6 @@ import { writeFileSync } from 'node:fs'; import { resolve } from 'node:path'; -import tgpu, { d, std, type TgpuComptime } from 'typegpu'; +import { tgpu, d, std, type TgpuComptime } from 'typegpu'; interface ProcGenConfig { mainBranching: number; diff --git a/apps/treeshake-test/generateTests.ts b/apps/treeshake-test/generateTests.ts index 5efe9d5a1b..99f913bab7 100644 --- a/apps/treeshake-test/generateTests.ts +++ b/apps/treeshake-test/generateTests.ts @@ -1,55 +1,47 @@ import * as fs from 'node:fs/promises'; -import * as tgpuAll from 'typegpu'; -import * as dAll from 'typegpu/data'; -import * as stdAll from 'typegpu/std'; +import { tgpu, d, std, common } from 'typegpu'; const TESTS_DIR = new URL('./tests/', import.meta.url); async function generateTestFiles() { await fs.mkdir(TESTS_DIR, { recursive: true }); - const tgpuAllImports = Object.keys(tgpuAll) - .filter((key) => key !== 'default') - .map((exportName) => ({ - export: exportName, - from: 'typegpu', - log: exportName, + const tgpuImports = Object.keys(tgpu) + .filter((key) => key !== '~unstable') + .map((importName) => ({ + import: 'tgpu', + item: importName, })); - const dAllImports = Object.keys(dAll).map((exportName) => ({ - export: exportName, - from: 'typegpu/data', - log: exportName, + const dImports = Object.keys(d).map((importName) => ({ + import: 'd', + item: importName, })); - const stdAllImports = Object.keys(stdAll).map((exportName) => ({ - export: exportName, - from: 'typegpu/std', - log: exportName, + const stdImports = Object.keys(std).map((importName) => ({ + import: 'std', + item: importName, })); - const tgpuImports = Object.keys(tgpuAll.tgpu) - .filter((key) => key !== '~unstable') - .map((exportName) => ({ - export: 'tgpu', - from: 'typegpu', - log: `tgpu.${exportName}`, - })); + const commonImports = Object.keys(common).map((importName) => ({ + import: 'common', + item: importName, + })); - const imports: { export: string; from: string; log: string }[] = [ - ...tgpuAllImports, - ...dAllImports, - ...stdAllImports, + const imports: { import: string; item: string }[] = [ ...tgpuImports, + ...dImports, + ...stdImports, + ...commonImports, ]; - for (const { export: exportName, from, log } of imports) { + for (const { import: importName, item } of imports) { const testContent = ` -import { ${exportName} } from '${from}/$built$'; -console.log(${log}); +import { ${importName} } from 'typegpu/$built$'; +console.log(${importName}.${item}); `; - const fileName = `${log}_from_${from.replaceAll('/', '')}.ts`; + const fileName = `${importName}_${item}.ts`; await fs.writeFile(new URL(fileName, TESTS_DIR), testContent); } } diff --git a/apps/treeshake-test/tests/importEntireLibrary.ts b/apps/treeshake-test/tests/importEntireLibrary.ts index 73f1583418..1760a95136 100644 --- a/apps/treeshake-test/tests/importEntireLibrary.ts +++ b/apps/treeshake-test/tests/importEntireLibrary.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu/$built$'; +import { tgpu } from 'typegpu/$built$'; import * as d from 'typegpu/data/$built$'; import * as std from 'typegpu/std/$built$'; diff --git a/apps/treeshake-test/tests/importEntireLibraryUnused.ts b/apps/treeshake-test/tests/importEntireLibraryUnused.ts index 751c5dd543..b69c7eafd8 100644 --- a/apps/treeshake-test/tests/importEntireLibraryUnused.ts +++ b/apps/treeshake-test/tests/importEntireLibraryUnused.ts @@ -1,3 +1,3 @@ -import tgpu from 'typegpu/$built$'; +import { tgpu } from 'typegpu/$built$'; import * as d from 'typegpu/data/$built$'; import * as std from 'typegpu/std/$built$'; diff --git a/apps/treeshake-test/tests/tgpuImportEverything.ts b/apps/treeshake-test/tests/tgpuImportEverything.ts index 74a0836982..3af6bfbee3 100644 --- a/apps/treeshake-test/tests/tgpuImportEverything.ts +++ b/apps/treeshake-test/tests/tgpuImportEverything.ts @@ -1,3 +1,3 @@ -import tgpu from 'typegpu/$built$'; +import { tgpu } from 'typegpu/$built$'; console.log(tgpu); diff --git a/apps/treeshake-test/tests/tgpuImportOne.ts b/apps/treeshake-test/tests/tgpuImportOne.ts index d526e1176c..29d2be6a7b 100644 --- a/apps/treeshake-test/tests/tgpuImportOne.ts +++ b/apps/treeshake-test/tests/tgpuImportOne.ts @@ -1,3 +1,3 @@ -import tgpu from 'typegpu/$built$'; +import { tgpu } from 'typegpu/$built$'; console.log(tgpu.resolve([])); diff --git a/apps/typegpu-docs/src/components/ComputeShadersArrayExample.tsx b/apps/typegpu-docs/src/components/ComputeShadersArrayExample.tsx index 53827a6153..07a6d1e0f3 100644 --- a/apps/typegpu-docs/src/components/ComputeShadersArrayExample.tsx +++ b/apps/typegpu-docs/src/components/ComputeShadersArrayExample.tsx @@ -10,7 +10,7 @@ import { const VALUE_COUNT = 16; const ValuesSchema = d.arrayOf(d.u32, VALUE_COUNT); -export const COMPUTE_SHADER_ARRAY_SNIPPET = `import tgpu, { d } from 'typegpu'; +export const COMPUTE_SHADER_ARRAY_SNIPPET = `import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/components/ComputeShadersBindGroupsExample.tsx b/apps/typegpu-docs/src/components/ComputeShadersBindGroupsExample.tsx index 4c93ea0e6e..fe6da8bd79 100644 --- a/apps/typegpu-docs/src/components/ComputeShadersBindGroupsExample.tsx +++ b/apps/typegpu-docs/src/components/ComputeShadersBindGroupsExample.tsx @@ -14,7 +14,7 @@ const BUFFER_OPTIONS: readonly BufferOption[] = [ { colorCss: '#bef264', label: 'Buffer C', name: 'Burst' }, ]; -export const COMPUTE_SHADER_BIND_GROUPS_SNIPPET = `import tgpu, { d, std } from 'typegpu'; +export const COMPUTE_SHADER_BIND_GROUPS_SNIPPET = `import { tgpu, d, std } from 'typegpu'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/components/ComputeShadersBindGroupsRuntime.ts b/apps/typegpu-docs/src/components/ComputeShadersBindGroupsRuntime.ts index 8aa6f8f0b3..cf83b1449a 100644 --- a/apps/typegpu-docs/src/components/ComputeShadersBindGroupsRuntime.ts +++ b/apps/typegpu-docs/src/components/ComputeShadersBindGroupsRuntime.ts @@ -1,5 +1,5 @@ import { sdBox2d } from '@typegpu/sdf'; -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { createExampleRoot } from './runnable/index.ts'; const PARTICLE_COUNT = 96; diff --git a/apps/typegpu-docs/src/components/ComputeShadersGridExample.tsx b/apps/typegpu-docs/src/components/ComputeShadersGridExample.tsx index 80f9314d06..5d41cad62e 100644 --- a/apps/typegpu-docs/src/components/ComputeShadersGridExample.tsx +++ b/apps/typegpu-docs/src/components/ComputeShadersGridExample.tsx @@ -11,7 +11,7 @@ const GRID_WIDTH = 8; const GRID_HEIGHT = 6; const GridSchema = d.arrayOf(d.arrayOf(d.u32, GRID_HEIGHT), GRID_WIDTH); -export const COMPUTE_SHADER_GRID_SNIPPET = `import tgpu, { d } from 'typegpu'; +export const COMPUTE_SHADER_GRID_SNIPPET = `import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/components/FirstGpuProgramExample.tsx b/apps/typegpu-docs/src/components/FirstGpuProgramExample.tsx index e2c9824af9..48cae7cdd9 100644 --- a/apps/typegpu-docs/src/components/FirstGpuProgramExample.tsx +++ b/apps/typegpu-docs/src/components/FirstGpuProgramExample.tsx @@ -8,7 +8,7 @@ const CounterState = d.struct({ }); export const FIRST_GPU_PROGRAM_SNIPPETS = { - consoleLog: `import tgpu, { d } from 'typegpu'; + consoleLog: `import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -31,7 +31,7 @@ export function execute() { } `, - readValue: `import tgpu, { d } from 'typegpu'; + readValue: `import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -54,7 +54,7 @@ export async function execute() { } `, - updateIncrementBy: `import tgpu, { d } from 'typegpu'; + updateIncrementBy: `import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/components/runnable/RunnableSnippet.tsx b/apps/typegpu-docs/src/components/runnable/RunnableSnippet.tsx index e64fa13315..20de24a69c 100644 --- a/apps/typegpu-docs/src/components/runnable/RunnableSnippet.tsx +++ b/apps/typegpu-docs/src/components/runnable/RunnableSnippet.tsx @@ -1,6 +1,6 @@ import { Play } from 'lucide-react'; import { useEffect, useRef, useState, type ReactNode } from 'react'; -import tgpu, { type TgpuRoot } from 'typegpu'; +import { tgpu, type TgpuRoot } from 'typegpu'; import { useConsoleCapture } from './useConsoleCapture.ts'; const unsupportedMessage = diff --git a/apps/typegpu-docs/src/components/translator/lib/constants.ts b/apps/typegpu-docs/src/components/translator/lib/constants.ts index 62d2a9d874..b1f2b13653 100644 --- a/apps/typegpu-docs/src/components/translator/lib/constants.ts +++ b/apps/typegpu-docs/src/components/translator/lib/constants.ts @@ -20,7 +20,7 @@ fn fs_main() -> @location(0) vec4 { return vec4(1.0, 0.0, 0.0, 1.0); }`; -export const DEFAULT_TGSL = `import tgpu, { d } from 'typegpu'; +export const DEFAULT_TGSL = `import { tgpu, d } from 'typegpu'; const Particle = d.struct({ position: d.vec3f, diff --git a/apps/typegpu-docs/src/components/translator/lib/tgslExecutor.ts b/apps/typegpu-docs/src/components/translator/lib/tgslExecutor.ts index 37e742a066..708f1b39c1 100644 --- a/apps/typegpu-docs/src/components/translator/lib/tgslExecutor.ts +++ b/apps/typegpu-docs/src/components/translator/lib/tgslExecutor.ts @@ -20,7 +20,7 @@ async function executeTgslModule(tgslCode: string): Promise { '/shader.ts': { content: tgslCode }, '/index.ts': { content: ` - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as exports from './shader.ts'; const shaderCode = tgpu.resolve({ externals: exports }); diff --git a/apps/typegpu-docs/src/content/docs/apis/accessors.mdx b/apps/typegpu-docs/src/content/docs/apis/accessors.mdx index 8f4c14a4b1..b158360607 100644 --- a/apps/typegpu-docs/src/content/docs/apis/accessors.mdx +++ b/apps/typegpu-docs/src/content/docs/apis/accessors.mdx @@ -6,7 +6,7 @@ description: Accessors are schema-aware typed placeholders for GPU resources, al When writing reusable GPU functions in TypeGPU, you often need to reference "some global value" without coupling to a specific buffer, texture or variable. [Slots](/TypeGPU/apis/slots) seem like the right tool for the job, but they encode the delivery mechanism into the slot type (e.g. a buffer or texture), making it inflexible for reusable functions. ```ts twoslash -import tgpu, { type TgpuUniform, d } from 'typegpu'; +import { tgpu, type TgpuUniform, d } from 'typegpu'; // ---cut--- // 👎 only works with JS literals const staticColorSlot = tgpu.slot(); @@ -28,7 +28,7 @@ const colorAccess = tgpu.accessor(d.vec3f); Create an accessor with `tgpu.accessor(schema)`. Optionally pass a default value as the second argument: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- // No default — must be bound before resolving. const colorAccess = tgpu.accessor(d.vec3f); @@ -40,7 +40,7 @@ const colorWithDefault = tgpu.accessor(d.vec3f, d.vec3f(1, 0, 0)); Inside a GPU function, read the accessor's value using `.$`: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const colorAccess = tgpu.accessor(d.vec3f, d.vec3f(1, 0, 0)); // ---cut--- @@ -58,7 +58,7 @@ Accessing it outside GPU context throws a runtime error. If no default is set and no binding is provided at resolution time, TypeGPU throws a descriptive error: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const colorAccess = tgpu.accessor(d.vec3f); @@ -79,7 +79,7 @@ tgpu.resolve([getColor]); Use `.with(accessor, value)` on a function or pipeline — the same pattern as [slots](/apis/slots): ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const RED = d.vec3f(1, 0, 0); const GREEN = d.vec3f(0, 1, 0); @@ -112,7 +112,7 @@ fn getColor_1() -> vec3f { You can also override on a pipeline: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -136,7 +136,7 @@ Accessors accept several types of GPU resources as values. The simplest binding — the value is resolved at compile time and inlined directly into the WGSL: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const colorAccess = tgpu.accessor(d.vec3f); const multiplierAccess = tgpu.accessor(d.f32); @@ -168,7 +168,7 @@ Notice how, because the values are known at compile time, the result is precompu Resolves to a function call in the generated WGSL: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const colorAccess = tgpu.accessor(d.vec3f, () => { 'use gpu'; @@ -196,7 +196,7 @@ fn getColor() -> vec3f { Resolves to the WGSL variable declaration for that buffer binding: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); const RED = d.vec3f(1, 0, 0); @@ -225,7 +225,7 @@ fn getColor() -> vec3f { A common pattern for library-style code: use a bind group layout entry as the default, making it easy to swap the resource via `.with()`: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const ImageData = (count: number) => d.struct({ @@ -247,7 +247,7 @@ const imageAccess = tgpu.accessor(ImageData, () => layout.$.image); Bind a private or workgroup variable: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const colorAccess = tgpu.accessor(d.vec3f); @@ -280,7 +280,7 @@ fn getColor_1() -> vec3f { ### Constant ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const colorAccess = tgpu.accessor(d.vec3f); @@ -304,7 +304,7 @@ fn getColor() -> vec3f { ### Texture view ```ts twoslash -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -335,7 +335,7 @@ fn main() { Because accessors know the schema of their resource, you can access struct fields directly through `.$`: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const ImageData = (count: number) => d.struct({ @@ -379,7 +379,7 @@ fn getPixel(x: i32, y: i32) -> vec4f { You can also access deeply nested references — e.g., a specific element of a buffer's array field: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -415,7 +415,7 @@ fn main() { Use `tgpu.mutableAccessor` when you need to *write* to the resource: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -447,7 +447,7 @@ The split between `tgpu.accessor` and `tgpu.mutableAccessor` is useful, as the r You can also mutate fields of a non-primitive struct: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/content/docs/apis/bind-groups.mdx b/apps/typegpu-docs/src/content/docs/apis/bind-groups.mdx index 16cabf2dff..6c2e0dcda7 100644 --- a/apps/typegpu-docs/src/content/docs/apis/bind-groups.mdx +++ b/apps/typegpu-docs/src/content/docs/apis/bind-groups.mdx @@ -12,7 +12,7 @@ A bind group is a collection of resources that are bound to a shader. These reso It's a way to define what resources are available to a shader and how they are accessed. ```ts -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // Defining the layout of resources we want the shader to // have access to. diff --git a/apps/typegpu-docs/src/content/docs/apis/buffers.mdx b/apps/typegpu-docs/src/content/docs/apis/buffers.mdx index 9ea79a6df7..51ef758979 100644 --- a/apps/typegpu-docs/src/content/docs/apis/buffers.mdx +++ b/apps/typegpu-docs/src/content/docs/apis/buffers.mdx @@ -19,7 +19,7 @@ results of parallel computation back to JS. When creating a buffer, a schema for As an example, let's create a buffer for storing particles. ```ts twoslash {22-28} -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // Defining a struct type const Particle = d.struct({ @@ -66,7 +66,7 @@ To create a buffer, you will need to define its schema by composing data types i structs and arrays. They will be explored in more detail in [a following chapter](/TypeGPU/apis/data-schemas). ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const countBuffer = root.createBuffer(d.u32); @@ -85,7 +85,7 @@ To be able to use these buffers in WGSL shaders, we have to declare their usage ```ts twoslash // @noErrors -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const buffer = root.createBuffer(d.u32) @@ -98,7 +98,7 @@ You can also add all flags in a single `$usage()`. ```ts twoslash // @noErrors -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const buffer = root.createBuffer(d.u32) @@ -109,7 +109,7 @@ const buffer = root.createBuffer(d.u32) :::note Along with passing the appropriate flags to WebGPU, the methods will also embed type information into the buffer. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -126,7 +126,7 @@ or indirectly through the `.$usage` method. ```ts twoslash /// -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); const buffer = root.createBuffer(d.f32); // ---cut--- @@ -147,7 +147,7 @@ You can also pass an initial value to the `root.createBuffer` function. When the buffer is created, it will be mapped at creation, and the initial value will be written to the buffer. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- // Will be initialized to `100` @@ -164,7 +164,7 @@ For cases where a plain typed value is not enough, you can also pass an initiali It receives the newly created typed buffer while it is still mapped, so you can populate it with multiple writes or helper utilities before the first upload. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -186,7 +186,7 @@ You can also create a buffer using an existing WebGPU buffer. This is useful whe ```ts twoslash {7} /// -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); const device = root.device; // ---cut--- @@ -212,7 +212,7 @@ method's arguments. ```ts twoslash // @noErrors -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const Particle = d.struct({ @@ -255,7 +255,7 @@ The same API is used internally for buffer writes. When data already lives in tuples or typed arrays, skipping typed instance construction avoids allocating TypeGPU wrapper objects, which can reduce garbage-collector pressure in hot paths such as per-frame updates or simulation ticks. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const vecBuffer = root.createBuffer(d.vec3f); @@ -278,7 +278,7 @@ WGSL matrices are stored by columns, not rows. For `mat3x3f`, use packed `number[]` (9 floats) or padded `Float32Array` (12 floats, one padding float per column). ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const mat3Buffer = root.createBuffer(d.mat3x3f); @@ -303,7 +303,7 @@ mat3Buffer.write(new Float32Array([ Wherever a `TypedArray` or `ArrayBuffer` is passed, the bytes are copied directly without any interpretation. The data must already match the GPU memory layout, including any padding. For example, each element in `d.arrayOf(d.vec3f, N)` occupies **16 bytes** (12 bytes of data + 4 bytes of padding), so the input must include those padding bytes. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const arrBuffer = root.createBuffer(d.arrayOf(d.vec3f, 2)); @@ -329,7 +329,7 @@ Use `d.memoryLayoutOf` to obtain the correct byte offset for a given schema elem ::: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const schema = d.arrayOf(d.u32, 6); @@ -351,7 +351,7 @@ Both offsets are **byte-based**. Any component whose byte position falls at or b ::: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const schema = d.arrayOf(d.vec3u, 4); @@ -386,7 +386,7 @@ The format of the `data` value depends on your schema type: a plain array for full replacement, or a `TypedArray` for byte-level replacement. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const Planet = d.struct({ @@ -413,7 +413,7 @@ When the buffer schema is an `array>`, you can write the data in a s This is useful when your CPU-side data is already stored per-field, such as simulation attributes kept in separate typed arrays. ```ts twoslash -import tgpu, { d, common } from 'typegpu'; +import { tgpu, d, common } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -455,7 +455,7 @@ TypeGPU inserts the required WGSL padding while scattering the data into the tar You can also restrict the write to a slice of the destination buffer: ```ts twoslash -import tgpu, { d, common } from 'typegpu'; +import { tgpu, d, common } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -498,7 +498,7 @@ There's also an option to copy value from another typed buffer using the `.copyF as long as both buffers have a matching data schema. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); const Particle = d.struct({ @@ -518,7 +518,7 @@ To read data from a buffer on the CPU, you can use the `.read()` method. It returns a promise that resolves to the data read from the buffer. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const buffer = root.createBuffer(d.arrayOf(d.u32, 10)); @@ -549,7 +549,7 @@ TypeGPU also allows for the use of index buffers. An index buffer is a buffer co You may refer to the [pipelines](/TypeGPU/apis/pipelines/#drawing-with-drawindexed) section for usage details. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -570,7 +570,7 @@ The default option is to create bind group layouts and bind your buffers via bin Read more in the chapter dedicated to [bind groups](/TypeGPU/apis/bind-groups). ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -608,7 +608,7 @@ Fixed buffers are created using dedicated root methods. | `var` | `root.createMutable()` | ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- diff --git a/apps/typegpu-docs/src/content/docs/apis/data-schemas.mdx b/apps/typegpu-docs/src/content/docs/apis/data-schemas.mdx index 35d88ddff3..34255e3674 100644 --- a/apps/typegpu-docs/src/content/docs/apis/data-schemas.mdx +++ b/apps/typegpu-docs/src/content/docs/apis/data-schemas.mdx @@ -363,7 +363,7 @@ Texture schemas serve two main purposes: - providing argument types for user defined functions ```ts twoslash -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; const root = await tgpu.init(); const texture = root.createTexture({ @@ -479,7 +479,7 @@ const AtomicI32 = d.atomic(d.i32); The `std` module provides functions for manipulating atomic data in 'use gpu' functions. ```ts twoslash -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; // ---cut--- const count = tgpu.workgroupVar(d.atomic(d.u32)); @@ -520,7 +520,7 @@ One of the biggest differences between JavaScript and WGSL is the existence of v Let's take a look at a simple TypeGPU function and the WGSL code it resolves to. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const MyStruct = d.struct({ n: d.u32 }); @@ -552,7 +552,7 @@ Even though modifying `s2` results in a change to `s1` in both cases, it happens To force an explicit copy in both cases, use a schema when the exact type is known: ```ts twoslash -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; // ---cut--- const MyStruct = d.struct({ n: d.u32 }); @@ -565,7 +565,7 @@ function myFn() { Or use `std.copy` when the schema may vary: ```ts twoslash -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; // ---cut--- function myFn(arg: d.v2u | d.v3u | d.v4u) { 'use gpu'; diff --git a/apps/typegpu-docs/src/content/docs/apis/functions/index.mdx b/apps/typegpu-docs/src/content/docs/apis/functions/index.mdx index e04a8d926d..36021eb3b0 100644 --- a/apps/typegpu-docs/src/content/docs/apis/functions/index.mdx +++ b/apps/typegpu-docs/src/content/docs/apis/functions/index.mdx @@ -25,7 +25,7 @@ though we recommend reading through anyway. The simplest and most powerful way to define TypeGPU functions is to just place `'use gpu'` at the beginning of the function body. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const neighborhood = (a: number, r: number) => { 'use gpu'; @@ -40,7 +40,7 @@ the same on the CPU and GPU. There are three main ways to use TypeGPU functions. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); const neighborhood = (a: number, r: number) => { @@ -193,7 +193,7 @@ Since TypeScript types not taken into account when generating the shader code, t limitation on use of generic types. ```ts twoslash -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; // ---cut--- const double = (a: T): T => { 'use gpu'; @@ -247,7 +247,7 @@ After seeing this, you might be tempted to use this mechanism for sharing data b global variables used across functions, but values referenced by TypeGPU functions *are assumed to be constant*. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -331,7 +331,7 @@ It accepts two arguments: - (Optionally) a schema representing the return type. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const neighborhood = (a: number, r: number) => { 'use gpu'; return d.vec2f(a - r, a + r); @@ -346,7 +346,7 @@ const neighborhoodF32 = neighborhoodShell(neighborhood); Although you can define the function and shell separately, the most common way to use shells is immediately wrapping functions with them: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const neighborhood = tgpu.fn([d.f32, d.f32], d.vec2f)((a, r) => { 'use gpu'; @@ -365,7 +365,7 @@ We assume that you are familiar with the following concepts: Instead of passing JavaScript functions to shells, you can pass WGSL code directly: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const neighborhood = tgpu.fn([d.f32, d.f32], d.vec2f)`(a: f32, r: f32) -> vec2f { return vec2f(a - r, a + r); @@ -375,7 +375,7 @@ const neighborhood = tgpu.fn([d.f32, d.f32], d.vec2f)`(a: f32, r: f32) -> vec2f Since type information is already present in the shell, the WGSL header can be simplified to include only the argument names. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const neighborhood = tgpu.fn([d.f32, d.f32], d.vec2f)`(a, r) { @@ -388,7 +388,7 @@ const neighborhood = tgpu.fn([d.f32, d.f32], d.vec2f)`(a, r) { If you're using Visual Studio Code, you can use [this extension](https://marketplace.visualstudio.com/items?itemName=ggsimm.wgsl-literal) that brings syntax highlighting to code fragments marked with `/* wgsl */` comments. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const neighborhood = tgpu.fn([d.f32, d.f32], d.vec2f)/* wgsl */`(a, r) { return vec2f(a - r, a + r); @@ -402,7 +402,7 @@ Shelled WGSL functions can use external resources passed via the `$uses` method. *Externals* can include anything that can be resolved to WGSL by TypeGPU (numbers, vectors, matrices, constants, TypeGPU functions, buffer usages, textures, samplers, slots, accessors etc.). ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const getBlue = tgpu.fn([], d.vec4f)`() { @@ -488,7 +488,7 @@ Since TypeGPU wraps `IORecord`s into automatically generated structs, you can al - `workgroupSize` -- a JS array of 1-3 numbers that corresponds to the `@workgroup_size` attribute. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -547,7 +547,7 @@ struct mainCompute_Input { - `out` -- `d.vec4f`, or an `IORecord` describing the output of the function. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const getGradientColor = tgpu.fn([d.f32], d.vec4f)``; // ---cut--- @@ -628,7 +628,7 @@ Pipelines are an *unstable* feature. The API may be subject to change in the nea Typed functions are crucial for simplified [pipeline](/TypeGPU/apis/pipelines) creation offered by TypeGPU. You can define and run pipelines as follows: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const context = undefined as any; const presentationFormat = "rgba8unorm"; diff --git a/apps/typegpu-docs/src/content/docs/apis/pipelines.mdx b/apps/typegpu-docs/src/content/docs/apis/pipelines.mdx index 00a1926688..f892cb0772 100644 --- a/apps/typegpu-docs/src/content/docs/apis/pipelines.mdx +++ b/apps/typegpu-docs/src/content/docs/apis/pipelines.mdx @@ -21,7 +21,7 @@ A pipeline can be defined with one of the following methods on the [root](/TypeG ```ts twoslash /// -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -73,7 +73,7 @@ The `createRenderPipeline` method creates a render pipeline by accepting an opti The vertex function's input parameters (non-builtin) are matched to vertex attributes specified in the pipeline's vertex layout when executing. Vertex attributes are validated at the type level for compatibility. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); const presentationFormat = 'rgba8unorm'; @@ -123,7 +123,7 @@ When a custom location is provided by the user (via the `d.location` attribute f as long as there is no conflict between vertex and fragment location values. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const vertex = tgpu.vertexFn({ out: { pos: d.builtin.position }, @@ -152,7 +152,7 @@ The `createComputePipeline` method creates a compute pipeline by accepting an op - `compute`: The `TgpuComputeFn` to use as the compute shader. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -176,7 +176,7 @@ Instead of dispatching workgroups, the guarded pipeline allows calling an exact Under the hood, it creates a compute pipeline that calls the provided callback only if the current thread ID is within the requested range. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const data = root.createMutable(d.arrayOf(d.u32, 8), [0, 1, 2, 3, 4, 5, 6, 7]); @@ -210,7 +210,7 @@ Buffer initialization commonly uses random number generators. For that, you can use the [`@typegpu/noise`](TypeGPU/ecosystem/typegpu-noise) library. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- import { randf } from '@typegpu/noise'; @@ -342,7 +342,7 @@ Compute pipelines are executed using the `dispatchWorkgroups` method, which acce The `drawIndexed` is analogous to draw, but takes advantage of [index buffer](/TypeGPU/apis/buffers/#index-buffers) to explicitly map vertex data onto primitives. When using an index buffer, you don't need to list every vertex for every primitive explicitly. Instead, you provide a list of unique vertices in a vertex buffer. Then, the index buffer defines how these vertices are connected to form primitives. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); const presentationFormat = "rgba8unorm"; @@ -428,7 +428,7 @@ That way, they can be used with a regular WebGPU API, but unlike the `root['~uns resources. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/content/docs/apis/resolve.mdx b/apps/typegpu-docs/src/content/docs/apis/resolve.mdx index 33e27e2f85..f0ad4eccdb 100644 --- a/apps/typegpu-docs/src/content/docs/apis/resolve.mdx +++ b/apps/typegpu-docs/src/content/docs/apis/resolve.mdx @@ -15,7 +15,7 @@ The `tgpu.resolve` API takes in TypeGPU resources (and optionally a WGSL templat The first `tgpu.resolve` overload takes in an array of items to resolve, and an optional argument with options. Here's a simple example: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const Boid = d.struct({ size: d.f32, @@ -57,7 +57,7 @@ As you may note, the resolved WGSL code contains exactly the set of definitions You can also resolve other resources, like consts, buffers, textures, entry point functions or even entire pipelines. Here's an example with a pipeline: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const root = await tgpu.init(); @@ -116,7 +116,7 @@ Use it when you are already provided with existing WGSL code and want to extend Here's an example: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -156,7 +156,7 @@ As you may note, in this case `tgpu.resolve` uses the structure of the `external Here is another example. Assume, that the bind group index `0` is already taken by some existing code: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const LightSource = d.struct({ ambientColor: d.vec3f, @@ -269,7 +269,7 @@ For these cases, you can use `tgpu.resolveWithContext`, which has the same input An example, where the "catchall" bind group is created: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -293,7 +293,7 @@ console.log(catchall?.[1]); // the catchall bind group An example, where a bind group layout is automatically included via a TypeScript function: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- diff --git a/apps/typegpu-docs/src/content/docs/apis/roots.mdx b/apps/typegpu-docs/src/content/docs/apis/roots.mdx index ec8beb5eb8..a9b3c9b1bb 100644 --- a/apps/typegpu-docs/src/content/docs/apis/roots.mdx +++ b/apps/typegpu-docs/src/content/docs/apis/roots.mdx @@ -16,7 +16,7 @@ It requests a GPU device with default requirements. An optional parameter can be passed in with special requirements for the GPU device. ```ts twoslash -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; const root = await tgpu.init(); ``` @@ -24,7 +24,7 @@ const root = await tgpu.init(); If you already have a device that you want to use, you can pass it into `tgpu.initFromDevice` instead. ```ts twoslash -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; const adapter = await navigator.gpu.requestAdapter(); const device = await adapter?.requestDevice() as GPUDevice; @@ -42,7 +42,7 @@ To retrieve the device that is associated with a root, you can use the `root.dev In order to draw on a canvas, you need to create and configure a context that will be later passed to a pipeline. ```ts twoslash -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; const root = await tgpu.init(); const canvas = {} as HTMLCanvasElement; // ---cut--- @@ -56,7 +56,7 @@ context.configure({ ``` TypeGPU streamlines this process with `root.configureContext` method. ```ts twoslash -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; const root = await tgpu.init(); const canvas = {} as HTMLCanvasElement; // ---cut--- diff --git a/apps/typegpu-docs/src/content/docs/apis/slots.mdx b/apps/typegpu-docs/src/content/docs/apis/slots.mdx index 7ffdc7272d..5e0c198996 100644 --- a/apps/typegpu-docs/src/content/docs/apis/slots.mdx +++ b/apps/typegpu-docs/src/content/docs/apis/slots.mdx @@ -20,7 +20,7 @@ Main use cases for slots include: A slot is created using the `tgpu.slot()` function and can optionally take a default value: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const filterColorSlot = tgpu.slot(); // Slot for a 3D vector. const mySlot = tgpu.slot(42); // Slot with a default value. @@ -53,7 +53,7 @@ Instead, you can bind it in one of two ways. The first way to bind a value to a slot is to call the `with` method on a wrapped TypeGPU function: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const filterColorSlot = tgpu.slot(); @@ -91,7 +91,7 @@ fn filter_1(color: vec3f) -> vec3f{ The other way to fill in a slot is to call the `with` method during the creation of a `TgpuComputePipeline` or `TgpuRenderPipeline`: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -129,7 +129,7 @@ They enable internal behavior to be modified without sacrificing type safety or ```ts twoslash // physics.ts -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { add, mul } from 'typegpu/std'; const root = await tgpu.init(); @@ -186,7 +186,7 @@ Slots can be used for conditional compilation of segments of shaders. When the slot holding a boolean value is filled with `false`, all `if` statements depending on the value of that slot will be pruned by our tree-shaking mechanism. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { max } from 'typegpu/std'; const root = await tgpu.init(); @@ -222,7 +222,7 @@ const processObjects = tgpu.fn([])(() => { It is possible to use slots even in TypeGPU functions that are implemented in WGSL: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const colorSlot = tgpu.slot(d.vec3f(1, 0, 0)); diff --git a/apps/typegpu-docs/src/content/docs/apis/textures.mdx b/apps/typegpu-docs/src/content/docs/apis/textures.mdx index a14907fc26..5ba121c912 100644 --- a/apps/typegpu-docs/src/content/docs/apis/textures.mdx +++ b/apps/typegpu-docs/src/content/docs/apis/textures.mdx @@ -17,7 +17,7 @@ TypeGPU textures serve as a wrapper that provides type safety and higher level u Let's look at an example of creating and using a typed texture. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -54,7 +54,7 @@ type TextureProps = { ``` ```ts twoslash -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const texture = root.createTexture({ @@ -71,7 +71,7 @@ const texture = root.createTexture({ Similar to buffers, textures need usage flags to specify how they will be used. You can add usage flags using the `.$usage(...)` method. ```ts twoslash -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const texture = root.createTexture({ @@ -86,7 +86,7 @@ const texture = root.createTexture({ You can also add multiple flags at once: ```ts twoslash -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const texture = root.createTexture({ @@ -119,7 +119,7 @@ You can write various image sources to textures. `ExternalImageSource` includes: - `VideoFrame` ```ts twoslash -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const texture = root.createTexture({ @@ -149,7 +149,7 @@ If image dimensions don't match the texture size, the image will be automaticall For 3D textures or texture arrays, you can write multiple images: ```ts twoslash -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; const root = await tgpu.init(); declare const imageBitmap1: ImageBitmap; declare const imageBitmap2: ImageBitmap; @@ -170,7 +170,7 @@ texture3d.write([imageBitmap1, imageBitmap2, imageBitmap3]); You can write raw binary data directly to textures using `ArrayBuffer`, typed arrays, or `DataView`: ```ts twoslash -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const texture = root.createTexture({ @@ -195,7 +195,7 @@ texture.write(mipData, 1); // Write to mip level 1 You can also copy from another texture: ```ts twoslash -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const sourceTexture = root.createTexture({ @@ -216,7 +216,7 @@ targetTexture.copyFrom(sourceTexture); TypeGPU provides automatic mipmap generation for textures: ```ts twoslash -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; const root = await tgpu.init(); declare const imageBitmap: ImageBitmap; // ---cut--- @@ -239,7 +239,7 @@ The `generateMipmaps()` method requires both `'sampled'` and `'render'` usage fl To create a view - which will also serve as fixed texture usage - you can use one of the available [texture schemas](/TypeGPU/apis/data-schemas/#textures). You can pass it to the `.createView` method of the texture. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const texture = root.createTexture({ @@ -257,7 +257,7 @@ const sampledView = texture.createView(d.texture2d(d.f32)); If type information is available the view schema will be staticly checked against the texture properties. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const texture = root.createTexture({ @@ -270,7 +270,7 @@ const sampledView = texture.createView(d.texture2d(d.f32)); ``` ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const texture = root.createTexture({ @@ -288,7 +288,7 @@ const sampledView = texture.createView(d.textureStorage2d('rgba8unorm')); // <-- To sample textures in shaders, you'll often need a sampler that defines how the texture should be filtered and addressed. The `createSampler` method accepts the same descriptor as the vanilla WebGPU `GPUSamplerDescriptor`: ```ts twoslash -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const sampler = root.createSampler({ @@ -309,7 +309,7 @@ Textures can be used in shaders through bind groups or as fixed resources, simil ### Manual binding ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const texture = root.createTexture({ @@ -340,7 +340,7 @@ const bindGroup = root.createBindGroup(bindGroupLayout, { For textures that remain consistent across operations, you can create fixed texture views: ```ts twoslash -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const texture = root.createTexture({ diff --git a/apps/typegpu-docs/src/content/docs/apis/utils.mdx b/apps/typegpu-docs/src/content/docs/apis/utils.mdx index 2ee5f0908e..830cf107ee 100644 --- a/apps/typegpu-docs/src/content/docs/apis/utils.mdx +++ b/apps/typegpu-docs/src/content/docs/apis/utils.mdx @@ -9,7 +9,7 @@ When working on top of some existing shader code, sometimes you may know for cer In such scenario you can use `tgpu['~unstable'].rawCodeSnippet` -- an advanced API that creates a typed shader expression which can be injected into the final shader bundle upon use. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- // `EXISTING_GLOBAL` is an identifier that we know will be in the @@ -62,7 +62,7 @@ tgpu.resolve([innerPipeline]); This can be used to precompute and inject a value into the final shader code. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const color = tgpu.comptime((int: number) => { @@ -98,7 +98,7 @@ Comptime-known conditions include: - values returned by `comptime` functions. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- const counterEnabledSlot = tgpu.slot(false); @@ -129,7 +129,7 @@ since we treat `tgpu.const` as a way to opt-out of inlining. Branch pruning also works for ternary operators. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); const counterEnabledSlot = tgpu.slot(false); const counter = root.createMutable(d.u32); @@ -150,7 +150,7 @@ When working on top of some existing shader code, sometimes you may know for cer In such scenario you can use `tgpu['~unstable'].rawCodeSnippet` -- an advanced API that creates a typed shader expression which can be injected into the final shader bundle upon use. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- // `EXISTING_GLOBAL` is an identifier that we know will be in the @@ -193,7 +193,7 @@ Yes, you read that correctly, TypeGPU implements logging to the console on the G Just call `console.log` like you would in plain JavaScript, and open the console to see the results. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -220,7 +220,7 @@ The buffer is of fixed size, which may limit the total amount of information tha If that's an issue, you may specify the size manually when creating the `root` object. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const presentationFormat = undefined as any; const canvas = undefined as any; @@ -273,7 +273,7 @@ This is due to a [WebGPU limitation](https://www.w3.org/TR/WGSL/#address-space) TypeGPU supports `for...of...` loops in shader functions. The only constraints are that the loop variable must be declared with `const` and the iterable must be stored in a variable. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const processNeighbor = (cell: d.v2i) => {}; @@ -303,7 +303,7 @@ For code with small, fixed iteration counts, you can use `tgpu.unroll` to unroll Wrap your iterable with `tgpu.unroll()`: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const processNeighbor = (cell: d.v2i) => {}; diff --git a/apps/typegpu-docs/src/content/docs/apis/variables.mdx b/apps/typegpu-docs/src/content/docs/apis/variables.mdx index 835339e216..348cbc384e 100644 --- a/apps/typegpu-docs/src/content/docs/apis/variables.mdx +++ b/apps/typegpu-docs/src/content/docs/apis/variables.mdx @@ -11,7 +11,7 @@ For example, in the code snippet below, the external `counter` is automatically In this case, the group and index match the automatically generated "catchall" bind group, used for fixed, "bindless" resources. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -53,7 +53,7 @@ struct increment_Input { For variables of `private` and `workgroup` address spaces, TypeGPU provides `tgpu.privateVar()` and `tgpu.workgroupVar()` constructor functions. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -82,7 +82,7 @@ In JS, a `const` is a reference that cannot be reassigned, while in WGSL, it mea Therefore, to use the WGSL `const`, TypeGPU provides `tgpu.const()`, an interface analogous to `tgpu.privateVar()` and `tgpu.workgroupVar()`, with the only difference being that the previously optional init value is now required. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- const Boid = d.struct({ pos: d.vec3f, diff --git a/apps/typegpu-docs/src/content/docs/apis/vertex-layouts.mdx b/apps/typegpu-docs/src/content/docs/apis/vertex-layouts.mdx index 581e73c904..35c862006b 100644 --- a/apps/typegpu-docs/src/content/docs/apis/vertex-layouts.mdx +++ b/apps/typegpu-docs/src/content/docs/apis/vertex-layouts.mdx @@ -18,7 +18,7 @@ Vertex layouts are much like bind group layouts, in that they define the relatio To create a vertex layout, use the `tgpu.vertexLayout` function. It takes an array schema constructor, i.e., partially applied `d.arrayOf` or `d.disarrayOf`. To determine what each element of the array corresponds to, you can pass an optional `stepMode` argument, which can be either `vertex` (default) or `instance`. ```ts -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const ParticleGeometry = d.struct({ tilt: d.f32, diff --git a/apps/typegpu-docs/src/content/docs/blog/typegpu-0.11/index.mdx b/apps/typegpu-docs/src/content/docs/blog/typegpu-0.11/index.mdx index c4e146e464..e3dd0a2581 100644 --- a/apps/typegpu-docs/src/content/docs/blog/typegpu-0.11/index.mdx +++ b/apps/typegpu-docs/src/content/docs/blog/typegpu-0.11/index.mdx @@ -255,7 +255,7 @@ There has been a lot of work outside of the `typegpu` package, both internally a Aleksander Katan ([@aleksanderkatan](https://github.com/aleksanderkatan)) has been working behind the scenes on an ESLint/Oxlint plugin, capable of catching user errors that types cannot. ```ts -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; function increment(n: number) { 'use gpu'; diff --git a/apps/typegpu-docs/src/content/docs/ecosystem/typegpu-noise.mdx b/apps/typegpu-docs/src/content/docs/ecosystem/typegpu-noise.mdx index 4e28e39aa6..240b73bc1d 100644 --- a/apps/typegpu-docs/src/content/docs/ecosystem/typegpu-noise.mdx +++ b/apps/typegpu-docs/src/content/docs/ecosystem/typegpu-noise.mdx @@ -24,7 +24,7 @@ Calling utility functions from [TypeGPU functions](/TypeGPU/apis/functions/) lin In the example below, resolving `randomVec2f` into a shader will include the code for `randf.sample` and all of its dependencies. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- import { randf } from '@typegpu/noise'; @@ -50,7 +50,7 @@ import { d } from 'typegpu'; // ---cut--- import { randf } from '@typegpu/noise'; // `typegpu` is necessary to inject library code into your custom shader -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; const shader = tgpu.resolve({ template: ` @@ -81,7 +81,7 @@ Each call to `randf.sample` returns the next random float in the sequence, allow using a set of `randf.seedN` functions, where `N` is the number of components our seed has. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { randf } from '@typegpu/noise'; const main = tgpu.fragmentFn({ @@ -144,7 +144,7 @@ The package exports an implementation for both 2D and 3D Perlin noise, `perlin2d Using it is as simple as calling the `.sample` function with the desired coordinates, and it returns a value in the range `[-1, 1]`. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- import { perlin2d } from '@typegpu/noise'; @@ -165,7 +165,7 @@ To improve performance, you can precompute the gradients using either a *Static* A static cache presumes that the domain of the noise function is fixed, and cannot change between shader invocations. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); import { perlin3d } from '@typegpu/noise'; @@ -189,7 +189,7 @@ Or in WebGPU: import { d } from 'typegpu'; declare const device: GPUDevice; -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import { perlin3d } from '@typegpu/noise'; // ---cut--- @@ -221,7 +221,7 @@ without having to recompile the shader, you have to use a dynamic cache. With it complex setup. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { perlin3d } from '@typegpu/noise'; const main = tgpu.computeFn({ workgroupSize: [1] })(() => { @@ -266,7 +266,7 @@ The package provides convenient way to change PRNG as needed. You can easily implement your own PRNG and plug it into the pipeline. ```ts twoslash -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { randf } from '@typegpu/noise'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/content/docs/ecosystem/typegpu-radiance-cascades.mdx b/apps/typegpu-docs/src/content/docs/ecosystem/typegpu-radiance-cascades.mdx index 3390c92bf3..9cd0ad8274 100644 --- a/apps/typegpu-docs/src/content/docs/ecosystem/typegpu-radiance-cascades.mdx +++ b/apps/typegpu-docs/src/content/docs/ecosystem/typegpu-radiance-cascades.mdx @@ -29,7 +29,7 @@ The package currently focuses on 2D radiance fields. It expects distances in UV- ```ts twoslash import * as rc from '@typegpu/radiance-cascades'; import * as sdf from '@typegpu/sdf'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; const root = await tgpu.init(); const previewSize = { width: 512, height: 512 }; @@ -87,7 +87,7 @@ A common setup is to generate an SDF texture with [`@typegpu/sdf`](/TypeGPU/ecos ```ts import * as rc from '@typegpu/radiance-cascades'; import * as sdf from '@typegpu/sdf'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; const root = await tgpu.init(); const floodSize = { width: 2048, height: 2048 }; diff --git a/apps/typegpu-docs/src/content/docs/ecosystem/typegpu-sdf.mdx b/apps/typegpu-docs/src/content/docs/ecosystem/typegpu-sdf.mdx index 7c346f478b..b48651bccf 100644 --- a/apps/typegpu-docs/src/content/docs/ecosystem/typegpu-sdf.mdx +++ b/apps/typegpu-docs/src/content/docs/ecosystem/typegpu-sdf.mdx @@ -37,7 +37,7 @@ Resolving the function includes the SDF code and its dependencies automatically. ```ts twoslash -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import * as sdf from '@typegpu/sdf'; const renderRoundedBox = tgpu.fn([d.vec2f], d.vec4f)((uv) => { @@ -65,7 +65,7 @@ The package includes a few common operators. They take distances as input, so yo ```ts twoslash -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import * as sdf from '@typegpu/sdf'; const sceneSdf = tgpu.fn([d.vec2f], d.f32)((p) => { @@ -102,7 +102,7 @@ The 3D primitives follow the same rules as the 2D ones. They are useful for ray ```ts twoslash -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import * as sdf from '@typegpu/sdf'; const sceneSdf = tgpu.fn([d.vec3f], d.f32)((p) => { @@ -185,7 +185,7 @@ Here the source shape is a triangle mask baked into a texture first, then jump f ```ts twoslash -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import * as sdf from '@typegpu/sdf'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/content/docs/ecosystem/typegpu-three/index.mdx b/apps/typegpu-docs/src/content/docs/ecosystem/typegpu-three/index.mdx index 26f3ad740e..9ae167a31b 100644 --- a/apps/typegpu-docs/src/content/docs/ecosystem/typegpu-three/index.mdx +++ b/apps/typegpu-docs/src/content/docs/ecosystem/typegpu-three/index.mdx @@ -60,7 +60,7 @@ Calling `t3.toTSL` with a TypeGPU function will return a TSL node, which can the
```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- import * as THREE from 'three/webgpu'; import * as t3 from '@typegpu/three'; @@ -112,7 +112,7 @@ There are a handful of builtin TSL node accessors in the `t3` namespace:
```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // ---cut--- import * as THREE from 'three/webgpu'; import * as t3 from '@typegpu/three'; @@ -138,7 +138,7 @@ Other TypeGPU functions (user-defined or from libraries) can be called to achiev
```ts twoslash -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; // ---cut--- import { perlin3d } from '@typegpu/noise'; import * as THREE from 'three/webgpu'; diff --git a/apps/typegpu-docs/src/content/docs/fundamentals/compute-shaders.mdx b/apps/typegpu-docs/src/content/docs/fundamentals/compute-shaders.mdx index 1165b781aa..a4a38d4309 100644 --- a/apps/typegpu-docs/src/content/docs/fundamentals/compute-shaders.mdx +++ b/apps/typegpu-docs/src/content/docs/fundamentals/compute-shaders.mdx @@ -11,7 +11,7 @@ In the previous section, we went over the basics of creating compute shaders and So far, most of our shaders have looked like this: ```ts twoslash -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; const root = await tgpu.init(); @@ -45,7 +45,7 @@ We still have to be careful not to read or write outside the bounds of the array If the dispatch size might be larger than the buffer length, guard the array access inside the shader: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -81,7 +81,7 @@ This is a useful analogy for understanding how the thread index maps to data. Bu When one thread reads data that another thread may be writing, the loop analogy breaks down: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -149,7 +149,7 @@ Laid out resources split the setup into two pieces: The layout is created first, without providing any actual buffers. For buffers, each layout entry uses the same schema we would use to create the buffer. If the entry is a storage buffer, it can also include an access mode: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const bindGroupLayout = tgpu.bindGroupLayout({ counter: { storage: d.u32, access: 'mutable' }, @@ -170,7 +170,7 @@ Storage entries are readonly by default, so `{ storage: d.u32 }` and `{ storage: To provide the resources, create a bind group with `root.createBindGroup(layout, entries)`: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -192,7 +192,7 @@ const bindGroup = root.createBindGroup(bindGroupLayout, { Because bind group entries are typed, providing a resource with the wrong schema or usage is a TypeScript error. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -221,7 +221,7 @@ Now the same simulation step can be written in either style. The Fixed Resources ```ts twoslash {13-16, 18-21} - import tgpu, { d } from 'typegpu'; + import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -255,7 +255,7 @@ Now the same simulation step can be written in either style. The Fixed Resources ```ts twoslash {10-11} - import tgpu, { d } from 'typegpu'; + import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/content/docs/fundamentals/vertices-and-fragments.mdx b/apps/typegpu-docs/src/content/docs/fundamentals/vertices-and-fragments.mdx index bf260cc12e..390a419f20 100644 --- a/apps/typegpu-docs/src/content/docs/fundamentals/vertices-and-fragments.mdx +++ b/apps/typegpu-docs/src/content/docs/fundamentals/vertices-and-fragments.mdx @@ -29,7 +29,7 @@ The code itself works on a canvas of any size. ::: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -70,7 +70,7 @@ Let us go through the code step by step. 1. **Initialize the `root`**, just like we did in a previous guide. ```ts - import tgpu, { d } from 'typegpu'; + import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); ``` @@ -148,7 +148,7 @@ We can actually return more values. In the example below, we pass in an additional color prop. ```ts twoslash {12-18, 20, 22} -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); const canvas = document.querySelector('canvas') as HTMLCanvasElement; @@ -238,7 +238,7 @@ In all examples above, we draw once and stop. To animate, two things change: we call `pipeline.draw()` every frame, and we pass a value from JS into the shader that each frame can vary. ```ts twoslash {1, 13-15, 23-28} -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; const root = await tgpu.init(); const canvas = document.querySelector('canvas') as HTMLCanvasElement; @@ -291,7 +291,7 @@ To draw bigger points and lines, people usually use many triangles to approximat There is however a different approach, that skips the geometry altogether. ```ts twoslash -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { fullScreenTriangle } from 'typegpu/common'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/content/docs/fundamentals/your-first-gpu-program.mdx b/apps/typegpu-docs/src/content/docs/fundamentals/your-first-gpu-program.mdx index 4603ace7af..d5f966907a 100644 --- a/apps/typegpu-docs/src/content/docs/fundamentals/your-first-gpu-program.mdx +++ b/apps/typegpu-docs/src/content/docs/fundamentals/your-first-gpu-program.mdx @@ -19,7 +19,7 @@ Most code snippets on this page are inspectable: hover over an identifier to see ::: ```ts twoslash -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; const root = await tgpu.init(); @@ -84,7 +84,7 @@ That gives us a few useful properties: Let's use that to create a simple GPU program that actually writes data to GPU memory. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -118,7 +118,7 @@ This is useful for fast debugging, but `console.log` only displays the value. It In the previous examples, we used `createMutable()` without paying much attention to what it creates. In short, it allocates GPU memory that can be accessed directly from a TypeGPU shader and modified from shader code. You might wonder why you could not just do something like: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -141,7 +141,7 @@ That is why we use buffers for state that the GPU can read or write. You can thi The `createMutable()` function is a shorthand for creating a storage buffer and viewing it as mutable: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -170,7 +170,7 @@ So far, we know how to allocate GPU buffers, update them from inside shaders, an With our current knowledge, we could just write a shader that writes some values to the buffer: ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -198,7 +198,7 @@ This will work correctly (as long as we always want to increment by 10), and som Because this version always increments by `10`, we could also drop the `incrementBy` field from our GPU state and capture a JavaScript constant instead. Captured constants are inlined into the generated shader, so this only works for values that do not need to change at runtime. ```ts twoslash -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ---cut--- @@ -228,7 +228,7 @@ As we can see, our program grew quite a bit. Let's examine what changed: 1. **Add a new value to our GPU state**, which we will use to control each increment step. We used `d.struct`, which works exactly like you would expect a struct to: it lets us group data together. ```ts twoslash - import tgpu, { d } from 'typegpu'; + import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -241,7 +241,7 @@ As we can see, our program grew quite a bit. Let's examine what changed: 2. **Add initial data.** Apart from the schema, buffer constructors also take a second argument, which lets you efficiently write data at buffer creation time. ```ts twoslash - import tgpu, { d } from 'typegpu'; + import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -257,7 +257,7 @@ As we can see, our program grew quite a bit. Let's examine what changed: This data will be typed according to the schema, so there is no byte counting involved. If you want to modify a buffer after it has been created, you can use the `.write()` method, which takes the same data shape. ```ts twoslash - import tgpu, { d } from 'typegpu'; + import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -276,7 +276,7 @@ As we can see, our program grew quite a bit. Let's examine what changed: 3. **Update the shader code** so that it uses the new field and increments `counter` by the current `incrementBy` value. ```ts twoslash - import tgpu, { d } from 'typegpu'; + import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); @@ -295,7 +295,7 @@ As we can see, our program grew quite a bit. Let's examine what changed: 4. **Use `.patch()` to update just one buffer field.** By default, `.write()` expects you to write the entire buffer at once. Since we do not have the current `counter` value available on the CPU side, we would need to read it each time (or track mirrored state on the CPU) - in short, not something we want to do. The `.patch()` API allows us to pass a subset of the buffer and write only the present values. ```ts twoslash - import tgpu, { d } from 'typegpu'; + import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/content/docs/integration/react-native/index.mdx b/apps/typegpu-docs/src/content/docs/integration/react-native/index.mdx index 161f8eaf66..c1b3c96d9c 100644 --- a/apps/typegpu-docs/src/content/docs/integration/react-native/index.mdx +++ b/apps/typegpu-docs/src/content/docs/integration/react-native/index.mdx @@ -127,7 +127,7 @@ that you can use in your app: ```ts import { useMemo } from 'react'; import { Canvas } from 'react-native-wgpu'; -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { useRoot, useFrame, useConfigureContext } from '@typegpu/react'; const positions = tgpu.const(d.arrayOf(d.vec2f), [ diff --git a/apps/typegpu-docs/src/content/docs/integration/webgpu-interoperability.mdx b/apps/typegpu-docs/src/content/docs/integration/webgpu-interoperability.mdx index bfb8c4838e..fa1f3f0631 100644 --- a/apps/typegpu-docs/src/content/docs/integration/webgpu-interoperability.mdx +++ b/apps/typegpu-docs/src/content/docs/integration/webgpu-interoperability.mdx @@ -12,7 +12,7 @@ The **non-contagious** nature of TypeGPU means that ejecting out, in case raw We Some of the following code snippets assume that TypeGPU is already initialized. ```ts -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); // ...or pass in an existing WebGPU device diff --git a/apps/typegpu-docs/src/content/docs/integration/wesl-interoperability.mdx b/apps/typegpu-docs/src/content/docs/integration/wesl-interoperability.mdx index 0a5ba9bee6..173f39ae28 100644 --- a/apps/typegpu-docs/src/content/docs/integration/wesl-interoperability.mdx +++ b/apps/typegpu-docs/src/content/docs/integration/wesl-interoperability.mdx @@ -105,7 +105,7 @@ reified references to any struct definition. import { Fish } from './shaders/shared.wesl?typegpu'; // ---cut-start--- // @filename: ./main.ts -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); const BoidState = d.struct({ position: d.vec3f, diff --git a/apps/typegpu-docs/src/content/docs/tooling/tgpu-gen.mdx b/apps/typegpu-docs/src/content/docs/tooling/tgpu-gen.mdx index 9491460808..d743f35cbd 100644 --- a/apps/typegpu-docs/src/content/docs/tooling/tgpu-gen.mdx +++ b/apps/typegpu-docs/src/content/docs/tooling/tgpu-gen.mdx @@ -209,7 +209,7 @@ The generated TypeScript definitions look like this: Click to see the content ```typescript /* generated via tgpu-gen by TypeGPU */ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; /* structs */ diff --git a/apps/typegpu-docs/src/content/docs/tooling/unplugin-typegpu.mdx b/apps/typegpu-docs/src/content/docs/tooling/unplugin-typegpu.mdx index 4a1deaa622..f86a6d939b 100644 --- a/apps/typegpu-docs/src/content/docs/tooling/unplugin-typegpu.mdx +++ b/apps/typegpu-docs/src/content/docs/tooling/unplugin-typegpu.mdx @@ -13,7 +13,7 @@ The package includes the following functionalities: The parsing of JavaScript happens ahead of time, emitting a highly compact AST format, called [tinyest](https://www.npmjs.com/package/tinyest). ```ts - import tgpu, { d } from 'typegpu'; + import { tgpu, d } from 'typegpu'; // Found by the plugin and decorated with 'tinyest' metadata const add = (a: number, b: number) => { diff --git a/apps/typegpu-docs/src/content/docs/tutorials/game-of-life/index.mdx b/apps/typegpu-docs/src/content/docs/tutorials/game-of-life/index.mdx index d8b437f8be..c37bf68617 100644 --- a/apps/typegpu-docs/src/content/docs/tutorials/game-of-life/index.mdx +++ b/apps/typegpu-docs/src/content/docs/tutorials/game-of-life/index.mdx @@ -33,7 +33,7 @@ Canvas’ inner width and height need to be adjusted to its outer properties mul Then, start off with TypeGPU by creating its [`root`](/TypeGPU/apis/roots/) object: ```ts -import tgpu from "typegpu"; +import { tgpu } from "typegpu"; const root = await tgpu.init(); ``` diff --git a/apps/typegpu-docs/src/content/docs/tutorials/triangle-to-boids/code/step1-typegpu.ts b/apps/typegpu-docs/src/content/docs/tutorials/triangle-to-boids/code/step1-typegpu.ts index 9ee6e304bd..1a40164f17 100644 --- a/apps/typegpu-docs/src/content/docs/tutorials/triangle-to-boids/code/step1-typegpu.ts +++ b/apps/typegpu-docs/src/content/docs/tutorials/triangle-to-boids/code/step1-typegpu.ts @@ -2,7 +2,7 @@ // TODO: ^ REMOVE WHEN CODE WORKS AGAIN import { addElement, onFrame } from '@typegpu/example-toolkit'; -import tgpu, { builtin } from 'typegpu/experimental'; +import { tgpu, builtin } from 'typegpu/experimental'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/content/docs/tutorials/triangle-to-boids/index.mdx b/apps/typegpu-docs/src/content/docs/tutorials/triangle-to-boids/index.mdx index 71e4ceb4eb..17784f61a1 100644 --- a/apps/typegpu-docs/src/content/docs/tutorials/triangle-to-boids/index.mdx +++ b/apps/typegpu-docs/src/content/docs/tutorials/triangle-to-boids/index.mdx @@ -43,7 +43,7 @@ This setup will mostly look very similar in every project that draws something t ```ts - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; // Create the root const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/examples/algorithms/bitonic-sort/index.ts b/apps/typegpu-docs/src/examples/algorithms/bitonic-sort/index.ts index ad5bb150c0..459d3d296f 100644 --- a/apps/typegpu-docs/src/examples/algorithms/bitonic-sort/index.ts +++ b/apps/typegpu-docs/src/examples/algorithms/bitonic-sort/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { type BitonicSorter, type BitonicSorterOptions, diff --git a/apps/typegpu-docs/src/examples/algorithms/concurrent-chart/index.ts b/apps/typegpu-docs/src/examples/algorithms/concurrent-chart/index.ts index 6ea3771b9d..a85e1aa83f 100644 --- a/apps/typegpu-docs/src/examples/algorithms/concurrent-chart/index.ts +++ b/apps/typegpu-docs/src/examples/algorithms/concurrent-chart/index.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; import { performCalculationsWithTime } from './calculator.ts'; diff --git a/apps/typegpu-docs/src/examples/algorithms/genetic-racing/ga.ts b/apps/typegpu-docs/src/examples/algorithms/genetic-racing/ga.ts index 2bf055d1a6..68f12e74fc 100644 --- a/apps/typegpu-docs/src/examples/algorithms/genetic-racing/ga.ts +++ b/apps/typegpu-docs/src/examples/algorithms/genetic-racing/ga.ts @@ -1,5 +1,5 @@ import { randf } from '@typegpu/noise'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import type { TgpuRoot, TgpuUniform } from 'typegpu'; export const MAX_POP = 65536; diff --git a/apps/typegpu-docs/src/examples/algorithms/genetic-racing/index.ts b/apps/typegpu-docs/src/examples/algorithms/genetic-racing/index.ts index 86a13accbb..3ced130931 100644 --- a/apps/typegpu-docs/src/examples/algorithms/genetic-racing/index.ts +++ b/apps/typegpu-docs/src/examples/algorithms/genetic-racing/index.ts @@ -1,4 +1,4 @@ -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; import { generateGridTrack, type TrackResult } from './track.ts'; import { diff --git a/apps/typegpu-docs/src/examples/algorithms/jump-flood-distance/index.ts b/apps/typegpu-docs/src/examples/algorithms/jump-flood-distance/index.ts index ce3767e05b..ebba4d5f20 100644 --- a/apps/typegpu-docs/src/examples/algorithms/jump-flood-distance/index.ts +++ b/apps/typegpu-docs/src/examples/algorithms/jump-flood-distance/index.ts @@ -1,4 +1,4 @@ -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { distanceFrag } from './visualization.ts'; import { BrushParams, diff --git a/apps/typegpu-docs/src/examples/algorithms/jump-flood-distance/types.ts b/apps/typegpu-docs/src/examples/algorithms/jump-flood-distance/types.ts index d733ef435f..a418e30b05 100644 --- a/apps/typegpu-docs/src/examples/algorithms/jump-flood-distance/types.ts +++ b/apps/typegpu-docs/src/examples/algorithms/jump-flood-distance/types.ts @@ -1,4 +1,4 @@ -import tgpu, { d, type SampledFlag, type StorageFlag, type TgpuTexture } from 'typegpu'; +import { tgpu, d, type SampledFlag, type StorageFlag, type TgpuTexture } from 'typegpu'; export const VisualizationParams = d.struct({ showInside: d.u32, diff --git a/apps/typegpu-docs/src/examples/algorithms/jump-flood-distance/visualization.ts b/apps/typegpu-docs/src/examples/algorithms/jump-flood-distance/visualization.ts index 2bb25d0e55..18b3ae48c0 100644 --- a/apps/typegpu-docs/src/examples/algorithms/jump-flood-distance/visualization.ts +++ b/apps/typegpu-docs/src/examples/algorithms/jump-flood-distance/visualization.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { distSampleLayout, paramsAccess } from './types.ts'; const outsideGradient = tgpu.const(d.arrayOf(d.vec3f, 5), [ diff --git a/apps/typegpu-docs/src/examples/algorithms/jump-flood-voronoi/index.ts b/apps/typegpu-docs/src/examples/algorithms/jump-flood-voronoi/index.ts index fa64ed38b4..b435b73a5d 100644 --- a/apps/typegpu-docs/src/examples/algorithms/jump-flood-voronoi/index.ts +++ b/apps/typegpu-docs/src/examples/algorithms/jump-flood-voronoi/index.ts @@ -1,5 +1,5 @@ import { randf } from '@typegpu/noise'; -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import type { SampledFlag, StorageFlag, TgpuTexture } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; diff --git a/apps/typegpu-docs/src/examples/algorithms/matrix-multiplication/index.ts b/apps/typegpu-docs/src/examples/algorithms/matrix-multiplication/index.ts index 5f745fc1da..af6a8daf89 100644 --- a/apps/typegpu-docs/src/examples/algorithms/matrix-multiplication/index.ts +++ b/apps/typegpu-docs/src/examples/algorithms/matrix-multiplication/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const WORKGROUP_SIZE = [8, 8] as [number, number]; diff --git a/apps/typegpu-docs/src/examples/algorithms/matrix-next/computeShared.ts b/apps/typegpu-docs/src/examples/algorithms/matrix-next/computeShared.ts index 80549ac007..1c6363faa9 100644 --- a/apps/typegpu-docs/src/examples/algorithms/matrix-next/computeShared.ts +++ b/apps/typegpu-docs/src/examples/algorithms/matrix-next/computeShared.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { TILE_SIZE, WORKGROUP_SIZE } from './params.ts'; import { computeLayout } from './types.ts'; diff --git a/apps/typegpu-docs/src/examples/algorithms/matrix-next/computeSimple.ts b/apps/typegpu-docs/src/examples/algorithms/matrix-next/computeSimple.ts index 6759dbe27f..7b6ee080d4 100644 --- a/apps/typegpu-docs/src/examples/algorithms/matrix-next/computeSimple.ts +++ b/apps/typegpu-docs/src/examples/algorithms/matrix-next/computeSimple.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { getIndex } from './computeShared.ts'; import { WORKGROUP_SIZE } from './params.ts'; import { computeLayout } from './types.ts'; diff --git a/apps/typegpu-docs/src/examples/algorithms/matrix-next/index.ts b/apps/typegpu-docs/src/examples/algorithms/matrix-next/index.ts index afc3e10130..600db8e552 100644 --- a/apps/typegpu-docs/src/examples/algorithms/matrix-next/index.ts +++ b/apps/typegpu-docs/src/examples/algorithms/matrix-next/index.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import { INITIAL_MAX_MATRIX_SIZE, TILE_SIZE } from './params.ts'; import { type CalculationStrategy, computeLayout, createMatrixData, MatrixInfo } from './types.ts'; import { computeSharedMemory } from './computeShared.ts'; diff --git a/apps/typegpu-docs/src/examples/algorithms/matrix-next/types.ts b/apps/typegpu-docs/src/examples/algorithms/matrix-next/types.ts index 2fcaf1c05a..95296326b7 100644 --- a/apps/typegpu-docs/src/examples/algorithms/matrix-next/types.ts +++ b/apps/typegpu-docs/src/examples/algorithms/matrix-next/types.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; export type CalculationStrategy = 'gpu-optimized' | 'gpu-simple' | 'cpu'; diff --git a/apps/typegpu-docs/src/examples/algorithms/mnist-inference/data.ts b/apps/typegpu-docs/src/examples/algorithms/mnist-inference/data.ts index 7f9ddd7694..bec769a600 100644 --- a/apps/typegpu-docs/src/examples/algorithms/mnist-inference/data.ts +++ b/apps/typegpu-docs/src/examples/algorithms/mnist-inference/data.ts @@ -1,4 +1,4 @@ -import tgpu, { d, type StorageFlag, type TgpuBuffer } from 'typegpu'; +import { tgpu, d, type StorageFlag, type TgpuBuffer } from 'typegpu'; export const ReadonlyFloats = { storage: d.arrayOf(d.f32), diff --git a/apps/typegpu-docs/src/examples/algorithms/mnist-inference/index.ts b/apps/typegpu-docs/src/examples/algorithms/mnist-inference/index.ts index 4fe7ed0d89..98a3a18cb1 100644 --- a/apps/typegpu-docs/src/examples/algorithms/mnist-inference/index.ts +++ b/apps/typegpu-docs/src/examples/algorithms/mnist-inference/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { ioLayout, type LayerData, type Network, weightsBiasesLayout } from './data.ts'; import { downloadLayers } from './helpers.ts'; import { defineControls } from '../../common/defineControls.ts'; diff --git a/apps/typegpu-docs/src/examples/algorithms/probability/executor.ts b/apps/typegpu-docs/src/examples/algorithms/probability/executor.ts index d436cf6d2b..ecd1062c51 100644 --- a/apps/typegpu-docs/src/examples/algorithms/probability/executor.ts +++ b/apps/typegpu-docs/src/examples/algorithms/probability/executor.ts @@ -10,7 +10,7 @@ import type { TgpuRoot, TgpuSlot, } from 'typegpu'; -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; export class Executor { // don't exceed max workgroup grid X dimension size diff --git a/apps/typegpu-docs/src/examples/algorithms/probability/helpers.ts b/apps/typegpu-docs/src/examples/algorithms/probability/helpers.ts index f214cdb2f2..cac3b0c628 100644 --- a/apps/typegpu-docs/src/examples/algorithms/probability/helpers.ts +++ b/apps/typegpu-docs/src/examples/algorithms/probability/helpers.ts @@ -1,5 +1,5 @@ import { randf } from '@typegpu/noise'; -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import * as c from './constants.ts'; import { Distribution, PlotType, type PRNG } from './types.ts'; diff --git a/apps/typegpu-docs/src/examples/algorithms/probability/index.ts b/apps/typegpu-docs/src/examples/algorithms/probability/index.ts index 6c4c807686..9696685d66 100644 --- a/apps/typegpu-docs/src/examples/algorithms/probability/index.ts +++ b/apps/typegpu-docs/src/examples/algorithms/probability/index.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import { Plotter } from './plotter.ts'; import { Executor } from './executor.ts'; diff --git a/apps/typegpu-docs/src/examples/geometry/circles/index.ts b/apps/typegpu-docs/src/examples/geometry/circles/index.ts index 549f4b0d4b..1428c861b5 100644 --- a/apps/typegpu-docs/src/examples/geometry/circles/index.ts +++ b/apps/typegpu-docs/src/examples/geometry/circles/index.ts @@ -1,5 +1,5 @@ import { circle, circleVertexCount } from '@typegpu/geometry'; -import tgpu, { d, std as s } from 'typegpu'; +import { tgpu, d, std as s } from 'typegpu'; const presentationFormat = navigator.gpu.getPreferredCanvasFormat(); const canvas = document.querySelector('canvas'); diff --git a/apps/typegpu-docs/src/examples/geometry/lines-combinations/index.ts b/apps/typegpu-docs/src/examples/geometry/lines-combinations/index.ts index 6943a1e79e..119c2c7865 100644 --- a/apps/typegpu-docs/src/examples/geometry/lines-combinations/index.ts +++ b/apps/typegpu-docs/src/examples/geometry/lines-combinations/index.ts @@ -9,7 +9,7 @@ import { lineSegmentWireframeIndices, startCapSlot, } from '@typegpu/geometry'; -import tgpu, { type ColorAttachment } from 'typegpu'; +import { tgpu, type ColorAttachment } from 'typegpu'; import { arrayOf, builtin, diff --git a/apps/typegpu-docs/src/examples/geometry/lines-combinations/testCases.ts b/apps/typegpu-docs/src/examples/geometry/lines-combinations/testCases.ts index 86ba518cdb..3cbfe09b07 100644 --- a/apps/typegpu-docs/src/examples/geometry/lines-combinations/testCases.ts +++ b/apps/typegpu-docs/src/examples/geometry/lines-combinations/testCases.ts @@ -1,6 +1,6 @@ import { LineControlPoint } from '@typegpu/geometry'; import { perlin2d, randf } from '@typegpu/noise'; -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import { arrayOf, f32, i32, mat2x2f, u32, vec2f } from 'typegpu/data'; import { abs, clamp, cos, floor, max, pow, select, sin } from 'typegpu/std'; import { TEST_SEGMENT_COUNT } from './constants.ts'; diff --git a/apps/typegpu-docs/src/examples/image-processing/ascii-filter/index.ts b/apps/typegpu-docs/src/examples/image-processing/ascii-filter/index.ts index 0adc3b6b4f..b47993c246 100644 --- a/apps/typegpu-docs/src/examples/image-processing/ascii-filter/index.ts +++ b/apps/typegpu-docs/src/examples/image-processing/ascii-filter/index.ts @@ -1,4 +1,4 @@ -import tgpu, { common, d, std, type TgpuBindGroup } from 'typegpu'; +import { tgpu, common, d, std, type TgpuBindGroup } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/examples/image-processing/background-segmentation/index.ts b/apps/typegpu-docs/src/examples/image-processing/background-segmentation/index.ts index 0c08feb8f6..4c67334490 100644 --- a/apps/typegpu-docs/src/examples/image-processing/background-segmentation/index.ts +++ b/apps/typegpu-docs/src/examples/image-processing/background-segmentation/index.ts @@ -1,5 +1,5 @@ import type { RenderFlag, SampledFlag, StorageFlag, TgpuBindGroup, TgpuTexture } from 'typegpu'; -import tgpu, { common, d } from 'typegpu'; +import { tgpu, common, d } from 'typegpu'; import { MODEL_HEIGHT, MODEL_WIDTH, MODELS, prepareSession } from './model.ts'; import { diff --git a/apps/typegpu-docs/src/examples/image-processing/background-segmentation/schemas.ts b/apps/typegpu-docs/src/examples/image-processing/background-segmentation/schemas.ts index a40024d6f9..4eefeee961 100644 --- a/apps/typegpu-docs/src/examples/image-processing/background-segmentation/schemas.ts +++ b/apps/typegpu-docs/src/examples/image-processing/background-segmentation/schemas.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // constants diff --git a/apps/typegpu-docs/src/examples/image-processing/background-segmentation/shaders.ts b/apps/typegpu-docs/src/examples/image-processing/background-segmentation/shaders.ts index 19dc796639..a66bf17781 100644 --- a/apps/typegpu-docs/src/examples/image-processing/background-segmentation/shaders.ts +++ b/apps/typegpu-docs/src/examples/image-processing/background-segmentation/shaders.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std, type TgpuFragmentFn } from 'typegpu'; +import { tgpu, d, std, type TgpuFragmentFn } from 'typegpu'; import { MODEL_HEIGHT, MODEL_WIDTH } from './model.ts'; import { blockDim, diff --git a/apps/typegpu-docs/src/examples/image-processing/blur/index.ts b/apps/typegpu-docs/src/examples/image-processing/blur/index.ts index a6bd7bd0de..890d30e9cd 100644 --- a/apps/typegpu-docs/src/examples/image-processing/blur/index.ts +++ b/apps/typegpu-docs/src/examples/image-processing/blur/index.ts @@ -1,7 +1,7 @@ // Original implementation: // https://webgpu.github.io/webgpu-samples/?sample=imageBlur -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/examples/image-processing/camera-thresholding/index.ts b/apps/typegpu-docs/src/examples/image-processing/camera-thresholding/index.ts index b72f79e1fb..b3e82e2720 100644 --- a/apps/typegpu-docs/src/examples/image-processing/camera-thresholding/index.ts +++ b/apps/typegpu-docs/src/examples/image-processing/camera-thresholding/index.ts @@ -1,5 +1,5 @@ import { rgbToYcbcrMatrix } from '@typegpu/color'; -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const textureLayout = tgpu.bindGroupLayout({ diff --git a/apps/typegpu-docs/src/examples/image-processing/chroma-keying/index.ts b/apps/typegpu-docs/src/examples/image-processing/chroma-keying/index.ts index 498c3cf8b6..de68f71817 100644 --- a/apps/typegpu-docs/src/examples/image-processing/chroma-keying/index.ts +++ b/apps/typegpu-docs/src/examples/image-processing/chroma-keying/index.ts @@ -1,5 +1,5 @@ import { rgbToYcbcrMatrix } from '@typegpu/color'; -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/examples/image-processing/image-tuning/index.ts b/apps/typegpu-docs/src/examples/image-processing/image-tuning/index.ts index 4720c0aeb9..edc6de826c 100644 --- a/apps/typegpu-docs/src/examples/image-processing/image-tuning/index.ts +++ b/apps/typegpu-docs/src/examples/image-processing/image-tuning/index.ts @@ -1,4 +1,4 @@ -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; type LUTData = { diff --git a/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/index.ts b/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/index.ts index 5a9d385632..e241bdbc08 100644 --- a/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/index.ts +++ b/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/index.ts @@ -1,4 +1,4 @@ -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import type { TgpuBindGroup } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; import { diff --git a/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/inference/kernels/compute.ts b/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/inference/kernels/compute.ts index c18ddd7473..8a9e37be34 100644 --- a/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/inference/kernels/compute.ts +++ b/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/inference/kernels/compute.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { BroadcastFlag } from '../bundle.ts'; import { binaryLayout, diff --git a/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/inference/kernels/helpers.ts b/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/inference/kernels/helpers.ts index b799b9049a..090f1bd85b 100644 --- a/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/inference/kernels/helpers.ts +++ b/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/inference/kernels/helpers.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { headLayout, weightedLayout } from './layouts.ts'; export type Vec4Op = (value: d.v4f) => d.v4f; diff --git a/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/inference/kernels/layouts.ts b/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/inference/kernels/layouts.ts index 6e2cb51852..8b0891711c 100644 --- a/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/inference/kernels/layouts.ts +++ b/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/inference/kernels/layouts.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; export const WeightedOffsets = d.struct({ weightBase: d.u32, diff --git a/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/inference/video-preprocess.ts b/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/inference/video-preprocess.ts index 4b72fa1206..036671a302 100644 --- a/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/inference/video-preprocess.ts +++ b/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/inference/video-preprocess.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import type { TgpuBindGroup, TgpuRoot } from 'typegpu'; import { FrameCropParams, initialFrameCropParams, type VideoFrameCrop } from '../frame.ts'; import { WORKGROUP_SIZE, type Vec4Buffer } from './kernels/types.ts'; diff --git a/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/post-processing/kernels.ts b/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/post-processing/kernels.ts index fcec57c114..5d57dc8de7 100644 --- a/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/post-processing/kernels.ts +++ b/apps/typegpu-docs/src/examples/image-processing/selfie-segmentation/post-processing/kernels.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { initialFrameCropParams } from '../frame.ts'; const MODEL_WIDTH = 256; diff --git a/apps/typegpu-docs/src/examples/react/confetti/index.tsx b/apps/typegpu-docs/src/examples/react/confetti/index.tsx index 87aeb7ed43..2a7fb460bf 100644 --- a/apps/typegpu-docs/src/examples/react/confetti/index.tsx +++ b/apps/typegpu-docs/src/examples/react/confetti/index.tsx @@ -1,4 +1,4 @@ -import tgpu, { d, std, type TgpuBuffer, type TgpuVertexFn } from 'typegpu'; +import { tgpu, d, std, type TgpuBuffer, type TgpuVertexFn } from 'typegpu'; import { useFrame, useRoot, diff --git a/apps/typegpu-docs/src/examples/react/spinning-triangle/index.tsx b/apps/typegpu-docs/src/examples/react/spinning-triangle/index.tsx index a1bcf3352e..cbdfa25e7b 100644 --- a/apps/typegpu-docs/src/examples/react/spinning-triangle/index.tsx +++ b/apps/typegpu-docs/src/examples/react/spinning-triangle/index.tsx @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { hexToOklab, oklabToRgb } from '@typegpu/color'; import { useConfigureContext, useFrame, useRoot, useUniform } from '@typegpu/react'; import React, { useMemo } from 'react'; diff --git a/apps/typegpu-docs/src/examples/rendering/3d-fish/compute.ts b/apps/typegpu-docs/src/examples/rendering/3d-fish/compute.ts index 1bc12594ec..ab7257d82f 100644 --- a/apps/typegpu-docs/src/examples/rendering/3d-fish/compute.ts +++ b/apps/typegpu-docs/src/examples/rendering/3d-fish/compute.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import * as p from './params.ts'; import { computeBindGroupLayout as layout } from './schemas.ts'; import { projectPointOnLine } from './tgsl-helpers.ts'; diff --git a/apps/typegpu-docs/src/examples/rendering/3d-fish/index.ts b/apps/typegpu-docs/src/examples/rendering/3d-fish/index.ts index e94a1d7b5d..fa073a3fdf 100644 --- a/apps/typegpu-docs/src/examples/rendering/3d-fish/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/3d-fish/index.ts @@ -1,5 +1,5 @@ import { randf } from '@typegpu/noise'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import * as m from 'wgpu-matrix'; import { simulate } from './compute.ts'; import { loadModel } from './load-model.ts'; diff --git a/apps/typegpu-docs/src/examples/rendering/3d-fish/render.ts b/apps/typegpu-docs/src/examples/rendering/3d-fish/render.ts index d5955e9e83..ffa93cffb6 100644 --- a/apps/typegpu-docs/src/examples/rendering/3d-fish/render.ts +++ b/apps/typegpu-docs/src/examples/rendering/3d-fish/render.ts @@ -1,5 +1,5 @@ import { hsvToRgb, rgbToHsv } from '@typegpu/color'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import * as p from './params.ts'; import { ModelVertexInput, ModelVertexOutput, renderBindGroupLayout as layout } from './schemas.ts'; import { applySinWave, PosAndNormal } from './tgsl-helpers.ts'; diff --git a/apps/typegpu-docs/src/examples/rendering/3d-fish/schemas.ts b/apps/typegpu-docs/src/examples/rendering/3d-fish/schemas.ts index ca9c55702b..8a43f179a3 100644 --- a/apps/typegpu-docs/src/examples/rendering/3d-fish/schemas.ts +++ b/apps/typegpu-docs/src/examples/rendering/3d-fish/schemas.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // schemas diff --git a/apps/typegpu-docs/src/examples/rendering/box-raytracing/index.ts b/apps/typegpu-docs/src/examples/rendering/box-raytracing/index.ts index b75bb209ef..463186b86c 100644 --- a/apps/typegpu-docs/src/examples/rendering/box-raytracing/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/box-raytracing/index.ts @@ -1,5 +1,5 @@ import { linearToSrgb, srgbToLinear } from '@typegpu/color'; -import tgpu, { d, type TgpuFragmentFn, type TgpuVertexFn } from 'typegpu'; +import { tgpu, d, type TgpuFragmentFn, type TgpuVertexFn } from 'typegpu'; import { discard, max, min, mul, normalize, pow, sub } from 'typegpu/std'; import { mat4 } from 'wgpu-matrix'; import { defineControls } from '../../common/defineControls.ts'; diff --git a/apps/typegpu-docs/src/examples/rendering/caustics/index.ts b/apps/typegpu-docs/src/examples/rendering/caustics/index.ts index 5b970d312b..c8b515e9c0 100644 --- a/apps/typegpu-docs/src/examples/rendering/caustics/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/caustics/index.ts @@ -1,5 +1,5 @@ import { perlin3d } from '@typegpu/noise'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const mainVertex = tgpu.vertexFn({ diff --git a/apps/typegpu-docs/src/examples/rendering/clouds/index.ts b/apps/typegpu-docs/src/examples/rendering/clouds/index.ts index dd23f5f385..5f7290566f 100644 --- a/apps/typegpu-docs/src/examples/rendering/clouds/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/clouds/index.ts @@ -1,4 +1,4 @@ -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { FOV_FACTOR, NOISE_TEXTURE_SIZE, diff --git a/apps/typegpu-docs/src/examples/rendering/clouds/types.ts b/apps/typegpu-docs/src/examples/rendering/clouds/types.ts index c4945fb27c..87de334d65 100644 --- a/apps/typegpu-docs/src/examples/rendering/clouds/types.ts +++ b/apps/typegpu-docs/src/examples/rendering/clouds/types.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; export const CloudsParams = d.struct({ time: d.f32, diff --git a/apps/typegpu-docs/src/examples/rendering/clouds/utils.ts b/apps/typegpu-docs/src/examples/rendering/clouds/utils.ts index 5f98475544..330f7c8818 100644 --- a/apps/typegpu-docs/src/examples/rendering/clouds/utils.ts +++ b/apps/typegpu-docs/src/examples/rendering/clouds/utils.ts @@ -1,5 +1,5 @@ import { randf } from '@typegpu/noise'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { CLOUD_AMPLITUDE, CLOUD_BRIGHT, diff --git a/apps/typegpu-docs/src/examples/rendering/cubemap-reflection/icosphere.ts b/apps/typegpu-docs/src/examples/rendering/cubemap-reflection/icosphere.ts index 7ce8f82f9e..19efd69904 100644 --- a/apps/typegpu-docs/src/examples/rendering/cubemap-reflection/icosphere.ts +++ b/apps/typegpu-docs/src/examples/rendering/cubemap-reflection/icosphere.ts @@ -1,5 +1,5 @@ import type { TgpuBuffer, TgpuComputePipeline, TgpuRoot, UniformFlag, VertexFlag } from 'typegpu'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { ComputeVertex, Vertex } from './dataTypes.ts'; import { calculateMidpoint, getAverageNormal, packVec2u, unpackVec2u } from './helpers.ts'; diff --git a/apps/typegpu-docs/src/examples/rendering/cubemap-reflection/index.ts b/apps/typegpu-docs/src/examples/rendering/cubemap-reflection/index.ts index e82e818df7..913fc2187f 100644 --- a/apps/typegpu-docs/src/examples/rendering/cubemap-reflection/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/cubemap-reflection/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import * as m from 'wgpu-matrix'; import { type CubemapNames, cubeVertices, loadCubemap } from './cubemap.ts'; import { Camera, CubeVertex, DirectionalLight, Material, Vertex } from './dataTypes.ts'; diff --git a/apps/typegpu-docs/src/examples/rendering/disco/consts.ts b/apps/typegpu-docs/src/examples/rendering/disco/consts.ts index c973c2d485..b2c5e6db00 100644 --- a/apps/typegpu-docs/src/examples/rendering/disco/consts.ts +++ b/apps/typegpu-docs/src/examples/rendering/disco/consts.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; export const timeAccess = tgpu.accessor(d.f32); export const resolutionAccess = tgpu.accessor(d.vec2f); // (width, height) diff --git a/apps/typegpu-docs/src/examples/rendering/disco/index.ts b/apps/typegpu-docs/src/examples/rendering/disco/index.ts index 85ecec9513..513d735869 100644 --- a/apps/typegpu-docs/src/examples/rendering/disco/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/disco/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { resolutionAccess, timeAccess } from './consts.ts'; import { mainFragment1, diff --git a/apps/typegpu-docs/src/examples/rendering/disco/shaders/fragment.ts b/apps/typegpu-docs/src/examples/rendering/disco/shaders/fragment.ts index ad166f6b39..137559b989 100644 --- a/apps/typegpu-docs/src/examples/rendering/disco/shaders/fragment.ts +++ b/apps/typegpu-docs/src/examples/rendering/disco/shaders/fragment.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { resolutionAccess, timeAccess } from '../consts.ts'; import { palette } from '../utils.ts'; diff --git a/apps/typegpu-docs/src/examples/rendering/disco/shaders/vertex.ts b/apps/typegpu-docs/src/examples/rendering/disco/shaders/vertex.ts index 4648a86853..f0f4d301e4 100644 --- a/apps/typegpu-docs/src/examples/rendering/disco/shaders/vertex.ts +++ b/apps/typegpu-docs/src/examples/rendering/disco/shaders/vertex.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; export const mainVertex = tgpu.vertexFn({ in: { vertexIndex: d.builtin.vertexIndex }, diff --git a/apps/typegpu-docs/src/examples/rendering/function-visualizer/index.ts b/apps/typegpu-docs/src/examples/rendering/function-visualizer/index.ts index b426e67e53..a547923370 100644 --- a/apps/typegpu-docs/src/examples/rendering/function-visualizer/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/function-visualizer/index.ts @@ -1,5 +1,5 @@ import type { TgpuGuardedComputePipeline, TgpuRawCodeSnippet } from 'typegpu'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { mat4 } from 'wgpu-matrix'; import { defineControls } from '../../common/defineControls.ts'; diff --git a/apps/typegpu-docs/src/examples/rendering/jelly-slider/dataTypes.ts b/apps/typegpu-docs/src/examples/rendering/jelly-slider/dataTypes.ts index 47cf5a4f2f..0f470b6ff7 100644 --- a/apps/typegpu-docs/src/examples/rendering/jelly-slider/dataTypes.ts +++ b/apps/typegpu-docs/src/examples/rendering/jelly-slider/dataTypes.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; export const DirectionalLight = d.struct({ direction: d.vec3f, diff --git a/apps/typegpu-docs/src/examples/rendering/jelly-slider/index.ts b/apps/typegpu-docs/src/examples/rendering/jelly-slider/index.ts index 36f5ba3c56..472ff8bb56 100644 --- a/apps/typegpu-docs/src/examples/rendering/jelly-slider/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/jelly-slider/index.ts @@ -1,5 +1,5 @@ import * as sdf from '@typegpu/sdf'; -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { randf } from '@typegpu/noise'; import { Slider } from './slider.ts'; diff --git a/apps/typegpu-docs/src/examples/rendering/jelly-slider/taa.ts b/apps/typegpu-docs/src/examples/rendering/jelly-slider/taa.ts index 2e32a023b6..5e6a2b1f00 100644 --- a/apps/typegpu-docs/src/examples/rendering/jelly-slider/taa.ts +++ b/apps/typegpu-docs/src/examples/rendering/jelly-slider/taa.ts @@ -1,5 +1,5 @@ import type { TgpuComputePipeline, TgpuRoot, TgpuTextureView } from 'typegpu'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { taaResolveLayout } from './dataTypes.ts'; export const taaResolveFn = tgpu.computeFn({ diff --git a/apps/typegpu-docs/src/examples/rendering/jelly-switch/dataTypes.ts b/apps/typegpu-docs/src/examples/rendering/jelly-switch/dataTypes.ts index 2830776156..4719a0cce3 100644 --- a/apps/typegpu-docs/src/examples/rendering/jelly-switch/dataTypes.ts +++ b/apps/typegpu-docs/src/examples/rendering/jelly-switch/dataTypes.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; export const DirectionalLight = d.struct({ direction: d.vec3f, diff --git a/apps/typegpu-docs/src/examples/rendering/jelly-switch/index.ts b/apps/typegpu-docs/src/examples/rendering/jelly-switch/index.ts index a84d6f9e2f..69f7b99204 100644 --- a/apps/typegpu-docs/src/examples/rendering/jelly-switch/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/jelly-switch/index.ts @@ -1,4 +1,4 @@ -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import * as sdf from '@typegpu/sdf'; import { randf } from '@typegpu/noise'; diff --git a/apps/typegpu-docs/src/examples/rendering/jelly-switch/taa.ts b/apps/typegpu-docs/src/examples/rendering/jelly-switch/taa.ts index 3ec98bf46b..a97d320e88 100644 --- a/apps/typegpu-docs/src/examples/rendering/jelly-switch/taa.ts +++ b/apps/typegpu-docs/src/examples/rendering/jelly-switch/taa.ts @@ -1,5 +1,5 @@ import type { TgpuComputePipeline, TgpuRoot, TgpuTextureView } from 'typegpu'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { taaResolveLayout } from './dataTypes.ts'; export const taaResolveFn = tgpu.computeFn({ diff --git a/apps/typegpu-docs/src/examples/rendering/os-awards/cubemap.ts b/apps/typegpu-docs/src/examples/rendering/os-awards/cubemap.ts index ff88ff4e94..52a4c8dfeb 100644 --- a/apps/typegpu-docs/src/examples/rendering/os-awards/cubemap.ts +++ b/apps/typegpu-docs/src/examples/rendering/os-awards/cubemap.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std, type TgpuRoot } from 'typegpu'; +import { tgpu, d, std, type TgpuRoot } from 'typegpu'; const convertLayout = tgpu.bindGroupLayout({ equirect: { texture: d.texture2d(d.f32) }, diff --git a/apps/typegpu-docs/src/examples/rendering/os-awards/index.ts b/apps/typegpu-docs/src/examples/rendering/os-awards/index.ts index fbaaf7f3f2..c2c67af3f0 100644 --- a/apps/typegpu-docs/src/examples/rendering/os-awards/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/os-awards/index.ts @@ -1,4 +1,4 @@ -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import * as m from 'wgpu-matrix'; import { directionToEquirectUv, loadEnvironmentCubemap } from './cubemap.ts'; import { loadModel, ModelVertex } from './model.ts'; diff --git a/apps/typegpu-docs/src/examples/rendering/perlin-noise/index.ts b/apps/typegpu-docs/src/examples/rendering/perlin-noise/index.ts index 9d3de4ec8e..72f36af744 100644 --- a/apps/typegpu-docs/src/examples/rendering/perlin-noise/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/perlin-noise/index.ts @@ -1,5 +1,5 @@ import { perlin3d } from '@typegpu/noise'; -import tgpu, { common, d } from 'typegpu'; +import { tgpu, common, d } from 'typegpu'; import { abs, mix, mul, pow, sign, tanh } from 'typegpu/std'; import { defineControls } from '../../common/defineControls.ts'; diff --git a/apps/typegpu-docs/src/examples/rendering/phong-reflection/index.ts b/apps/typegpu-docs/src/examples/rendering/phong-reflection/index.ts index 5005a7cdd6..e45e91208f 100644 --- a/apps/typegpu-docs/src/examples/rendering/phong-reflection/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/phong-reflection/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import * as p from './params.ts'; import { ExampleControls, diff --git a/apps/typegpu-docs/src/examples/rendering/phong-reflection/schemas.ts b/apps/typegpu-docs/src/examples/rendering/phong-reflection/schemas.ts index 6b294234b9..f8f13dddc2 100644 --- a/apps/typegpu-docs/src/examples/rendering/phong-reflection/schemas.ts +++ b/apps/typegpu-docs/src/examples/rendering/phong-reflection/schemas.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // schemas diff --git a/apps/typegpu-docs/src/examples/rendering/point-light-shadow/index.ts b/apps/typegpu-docs/src/examples/rendering/point-light-shadow/index.ts index 6a047a4580..fbf700ce06 100644 --- a/apps/typegpu-docs/src/examples/rendering/point-light-shadow/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/point-light-shadow/index.ts @@ -1,4 +1,4 @@ -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { BoxGeometry } from './box-geometry.ts'; import { Camera } from './camera.ts'; import { PointLight } from './point-light.ts'; diff --git a/apps/typegpu-docs/src/examples/rendering/point-light-shadow/types.ts b/apps/typegpu-docs/src/examples/rendering/point-light-shadow/types.ts index ebdcd0f5f6..ea35324b60 100644 --- a/apps/typegpu-docs/src/examples/rendering/point-light-shadow/types.ts +++ b/apps/typegpu-docs/src/examples/rendering/point-light-shadow/types.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; export const CameraData = d.struct({ viewProjectionMatrix: d.mat4x4f, diff --git a/apps/typegpu-docs/src/examples/rendering/pom/index.ts b/apps/typegpu-docs/src/examples/rendering/pom/index.ts index 7778bd2e79..4b5fc1f4ec 100644 --- a/apps/typegpu-docs/src/examples/rendering/pom/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/pom/index.ts @@ -1,5 +1,5 @@ import { randf } from '@typegpu/noise'; -import tgpu, { d, std, type RenderFlag, type TgpuTexture } from 'typegpu'; +import { tgpu, d, std, type RenderFlag, type TgpuTexture } from 'typegpu'; import { Camera, setupOrbitCamera } from '../../common/setup-orbit-camera.ts'; import { defineControls } from '../../common/defineControls.ts'; import { diff --git a/apps/typegpu-docs/src/examples/rendering/pom/types.ts b/apps/typegpu-docs/src/examples/rendering/pom/types.ts index 644747af47..7dda70f828 100644 --- a/apps/typegpu-docs/src/examples/rendering/pom/types.ts +++ b/apps/typegpu-docs/src/examples/rendering/pom/types.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; export const Vertex = d.struct({ position: d.vec3f, diff --git a/apps/typegpu-docs/src/examples/rendering/radiance-cascades-drawing/index.ts b/apps/typegpu-docs/src/examples/rendering/radiance-cascades-drawing/index.ts index 9d317a16a5..c82b0a917e 100644 --- a/apps/typegpu-docs/src/examples/rendering/radiance-cascades-drawing/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/radiance-cascades-drawing/index.ts @@ -1,6 +1,6 @@ import * as rc from '@typegpu/radiance-cascades'; import * as sdf from '@typegpu/sdf'; -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; import { createDrawInteraction } from './drawInteraction.ts'; diff --git a/apps/typegpu-docs/src/examples/rendering/radiance-cascades/index.ts b/apps/typegpu-docs/src/examples/rendering/radiance-cascades/index.ts index 2895fbc41e..15b96c6e1a 100644 --- a/apps/typegpu-docs/src/examples/rendering/radiance-cascades/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/radiance-cascades/index.ts @@ -4,7 +4,7 @@ // and the packaged example: // https://docs.swmansion.com/TypeGPU/examples#example=rendering--radiance-cascades-drawing import * as sdf from '@typegpu/sdf'; -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; import { DragController } from './drag-controller.ts'; import { SceneData, sceneData, sceneDataAccess, sceneSDF, updateElementPosition } from './scene.ts'; diff --git a/apps/typegpu-docs/src/examples/rendering/radiance-cascades/scene.ts b/apps/typegpu-docs/src/examples/rendering/radiance-cascades/scene.ts index a002a37f90..d1b306e499 100644 --- a/apps/typegpu-docs/src/examples/rendering/radiance-cascades/scene.ts +++ b/apps/typegpu-docs/src/examples/rendering/radiance-cascades/scene.ts @@ -1,5 +1,5 @@ import * as sdf from '@typegpu/sdf'; -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; export interface SceneElement { id: string; diff --git a/apps/typegpu-docs/src/examples/rendering/ray-marching/index.ts b/apps/typegpu-docs/src/examples/rendering/ray-marching/index.ts index fd87b161d9..3eaadee790 100644 --- a/apps/typegpu-docs/src/examples/rendering/ray-marching/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/ray-marching/index.ts @@ -1,5 +1,5 @@ import { sdBoxFrame3d, sdPlane, sdSphere } from '@typegpu/sdf'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; const root = await tgpu.init(); const canvas = document.querySelector('canvas') as HTMLCanvasElement; diff --git a/apps/typegpu-docs/src/examples/rendering/render-bundles-with/index.ts b/apps/typegpu-docs/src/examples/rendering/render-bundles-with/index.ts index ac7bf9f395..ebb184f6ef 100644 --- a/apps/typegpu-docs/src/examples/rendering/render-bundles-with/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/render-bundles-with/index.ts @@ -1,5 +1,5 @@ import { perlin2d } from '@typegpu/noise'; -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import * as m from 'wgpu-matrix'; import { defineControls } from '../../common/defineControls.ts'; import { setupOrbitCamera } from '../../common/setup-orbit-camera.ts'; diff --git a/apps/typegpu-docs/src/examples/rendering/render-bundles-with/schemas.ts b/apps/typegpu-docs/src/examples/rendering/render-bundles-with/schemas.ts index f1bef9b0ef..18046b88d8 100644 --- a/apps/typegpu-docs/src/examples/rendering/render-bundles-with/schemas.ts +++ b/apps/typegpu-docs/src/examples/rendering/render-bundles-with/schemas.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { Camera } from '../../common/setup-orbit-camera.ts'; export { Camera }; diff --git a/apps/typegpu-docs/src/examples/rendering/render-bundles-with/shaders.ts b/apps/typegpu-docs/src/examples/rendering/render-bundles-with/shaders.ts index 8d6702de51..3b0d6b6568 100644 --- a/apps/typegpu-docs/src/examples/rendering/render-bundles-with/shaders.ts +++ b/apps/typegpu-docs/src/examples/rendering/render-bundles-with/shaders.ts @@ -1,5 +1,5 @@ import { perlin2d } from '@typegpu/noise'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { cameraLayout, cubeLayout, terrainLayout, Vertex } from './schemas.ts'; const LOW_COLOR = d.vec3f(0.28, 0.52, 0.3); diff --git a/apps/typegpu-docs/src/examples/rendering/render-bundles/index.ts b/apps/typegpu-docs/src/examples/rendering/render-bundles/index.ts index dd0b073176..16dda08ae5 100644 --- a/apps/typegpu-docs/src/examples/rendering/render-bundles/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/render-bundles/index.ts @@ -1,5 +1,5 @@ import { perlin2d } from '@typegpu/noise'; -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import * as m from 'wgpu-matrix'; import { defineControls } from '../../common/defineControls.ts'; import { setupOrbitCamera } from '../../common/setup-orbit-camera.ts'; diff --git a/apps/typegpu-docs/src/examples/rendering/render-bundles/schemas.ts b/apps/typegpu-docs/src/examples/rendering/render-bundles/schemas.ts index f1bef9b0ef..18046b88d8 100644 --- a/apps/typegpu-docs/src/examples/rendering/render-bundles/schemas.ts +++ b/apps/typegpu-docs/src/examples/rendering/render-bundles/schemas.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { Camera } from '../../common/setup-orbit-camera.ts'; export { Camera }; diff --git a/apps/typegpu-docs/src/examples/rendering/render-bundles/shaders.ts b/apps/typegpu-docs/src/examples/rendering/render-bundles/shaders.ts index e1532d761a..e3a0f8f60f 100644 --- a/apps/typegpu-docs/src/examples/rendering/render-bundles/shaders.ts +++ b/apps/typegpu-docs/src/examples/rendering/render-bundles/shaders.ts @@ -1,5 +1,5 @@ import { perlin2d } from '@typegpu/noise'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { cameraLayout, cubeLayout, terrainLayout, Vertex } from './schemas.ts'; const LOW_COLOR = d.vec3f(0.28, 0.52, 0.3); diff --git a/apps/typegpu-docs/src/examples/rendering/simple-shadow/index.ts b/apps/typegpu-docs/src/examples/rendering/simple-shadow/index.ts index 33fb648256..870fa136bc 100644 --- a/apps/typegpu-docs/src/examples/rendering/simple-shadow/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/simple-shadow/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { mat4 } from 'wgpu-matrix'; import { createCuboid, createPlane } from './geometry.ts'; import { diff --git a/apps/typegpu-docs/src/examples/rendering/simple-shadow/schema.ts b/apps/typegpu-docs/src/examples/rendering/simple-shadow/schema.ts index f8fd4a6ddc..0d85943550 100644 --- a/apps/typegpu-docs/src/examples/rendering/simple-shadow/schema.ts +++ b/apps/typegpu-docs/src/examples/rendering/simple-shadow/schema.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; // Data structures export const Material = d.struct({ diff --git a/apps/typegpu-docs/src/examples/rendering/smoky-triangle/index.ts b/apps/typegpu-docs/src/examples/rendering/smoky-triangle/index.ts index bb750e7a7e..fd07d9fdc6 100644 --- a/apps/typegpu-docs/src/examples/rendering/smoky-triangle/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/smoky-triangle/index.ts @@ -1,5 +1,5 @@ import { perlin3d } from '@typegpu/noise'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; const Params = d.struct({ fromColor: d.vec3f, diff --git a/apps/typegpu-docs/src/examples/rendering/suika-sdf/index.ts b/apps/typegpu-docs/src/examples/rendering/suika-sdf/index.ts index c2c5b6450a..d1261b1e05 100644 --- a/apps/typegpu-docs/src/examples/rendering/suika-sdf/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/suika-sdf/index.ts @@ -1,5 +1,5 @@ import * as sdf from '@typegpu/sdf'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { fullScreenTriangle } from 'typegpu/common'; import { DROP_Y, diff --git a/apps/typegpu-docs/src/examples/rendering/suika-sdf/sdfGen.ts b/apps/typegpu-docs/src/examples/rendering/suika-sdf/sdfGen.ts index 861674bf4e..833c6c12ce 100644 --- a/apps/typegpu-docs/src/examples/rendering/suika-sdf/sdfGen.ts +++ b/apps/typegpu-docs/src/examples/rendering/suika-sdf/sdfGen.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import type { SampledFlag, TgpuRoot, TgpuSampler, TgpuTexture } from 'typegpu'; import { LEVEL_COUNT } from './constants.ts'; diff --git a/apps/typegpu-docs/src/examples/rendering/two-boxes/index.ts b/apps/typegpu-docs/src/examples/rendering/two-boxes/index.ts index feecac1b2a..170eefbe43 100644 --- a/apps/typegpu-docs/src/examples/rendering/two-boxes/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/two-boxes/index.ts @@ -1,5 +1,5 @@ import type { RenderFlag, TgpuBindGroup, TgpuBuffer, TgpuTexture, VertexFlag } from 'typegpu'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import * as m from 'wgpu-matrix'; // Initialization diff --git a/apps/typegpu-docs/src/examples/rendering/xor-dev-centrifuge-2/index.ts b/apps/typegpu-docs/src/examples/rendering/xor-dev-centrifuge-2/index.ts index 20dbe57d37..f6bdfc3924 100644 --- a/apps/typegpu-docs/src/examples/rendering/xor-dev-centrifuge-2/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/xor-dev-centrifuge-2/index.ts @@ -10,7 +10,7 @@ * ``` */ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { abs, atan2, cos, gt, length, normalize, select, sign, tanh } from 'typegpu/std'; import { defineControls } from '../../common/defineControls.ts'; diff --git a/apps/typegpu-docs/src/examples/rendering/xor-dev-runner/index.ts b/apps/typegpu-docs/src/examples/rendering/xor-dev-runner/index.ts index 99225f1ed4..ee86a5a2c9 100644 --- a/apps/typegpu-docs/src/examples/rendering/xor-dev-runner/index.ts +++ b/apps/typegpu-docs/src/examples/rendering/xor-dev-runner/index.ts @@ -12,7 +12,7 @@ * ``` */ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { abs, add, cos, max, min, mul, select, sign, sin, sub, tanh } from 'typegpu/std'; import { defineControls } from '../../common/defineControls.ts'; import { Camera, setupFirstPersonCamera } from '../../common/setup-first-person-camera.ts'; diff --git a/apps/typegpu-docs/src/examples/simple/gradient-tiles/index.ts b/apps/typegpu-docs/src/examples/simple/gradient-tiles/index.ts index f53a95ac67..dbda082b81 100644 --- a/apps/typegpu-docs/src/examples/simple/gradient-tiles/index.ts +++ b/apps/typegpu-docs/src/examples/simple/gradient-tiles/index.ts @@ -1,4 +1,4 @@ -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/examples/simple/increment/index.ts b/apps/typegpu-docs/src/examples/simple/increment/index.ts index f8db1a83a3..0485faab74 100644 --- a/apps/typegpu-docs/src/examples/simple/increment/index.ts +++ b/apps/typegpu-docs/src/examples/simple/increment/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/examples/simple/liquid-glass/index.ts b/apps/typegpu-docs/src/examples/simple/liquid-glass/index.ts index fd572f9cef..7e7b5597bb 100644 --- a/apps/typegpu-docs/src/examples/simple/liquid-glass/index.ts +++ b/apps/typegpu-docs/src/examples/simple/liquid-glass/index.ts @@ -1,5 +1,5 @@ import { sdRoundedBox2d } from '@typegpu/sdf'; -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/examples/simple/mesh-skinning/index.ts b/apps/typegpu-docs/src/examples/simple/mesh-skinning/index.ts index 397903641f..369167922b 100644 --- a/apps/typegpu-docs/src/examples/simple/mesh-skinning/index.ts +++ b/apps/typegpu-docs/src/examples/simple/mesh-skinning/index.ts @@ -1,4 +1,4 @@ -import tgpu, { common } from 'typegpu'; +import { tgpu, common } from 'typegpu'; import * as d from 'typegpu/data'; import * as std from 'typegpu/std'; import { mat4, vec3 } from 'wgpu-matrix'; diff --git a/apps/typegpu-docs/src/examples/simple/oklab/index.ts b/apps/typegpu-docs/src/examples/simple/oklab/index.ts index 41dc549df1..9150cccb87 100644 --- a/apps/typegpu-docs/src/examples/simple/oklab/index.ts +++ b/apps/typegpu-docs/src/examples/simple/oklab/index.ts @@ -5,7 +5,7 @@ import { oklabToLinearRgb, oklabToRgb, } from '@typegpu/color'; -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const cssProbePosition = d.vec2f(0.5, 0.5); diff --git a/apps/typegpu-docs/src/examples/simple/ripple-cube/background.ts b/apps/typegpu-docs/src/examples/simple/ripple-cube/background.ts index a7167823ff..f5eeef6853 100644 --- a/apps/typegpu-docs/src/examples/simple/ripple-cube/background.ts +++ b/apps/typegpu-docs/src/examples/simple/ripple-cube/background.ts @@ -1,6 +1,6 @@ import { perlin3d, randf } from '@typegpu/noise'; import type { TgpuRoot, TgpuTextureView } from 'typegpu'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { CUBEMAP_SIZE } from './constants.ts'; const spaceNebula = (rd: d.v3f): d.v3f => { diff --git a/apps/typegpu-docs/src/examples/simple/ripple-cube/index.ts b/apps/typegpu-docs/src/examples/simple/ripple-cube/index.ts index 1ddb0d0a29..c9cf3e5bc4 100644 --- a/apps/typegpu-docs/src/examples/simple/ripple-cube/index.ts +++ b/apps/typegpu-docs/src/examples/simple/ripple-cube/index.ts @@ -1,6 +1,6 @@ import { perlin3d, randf } from '@typegpu/noise'; import * as sdf from '@typegpu/sdf'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { Camera, setupOrbitCamera } from '../../common/setup-orbit-camera.ts'; import { createBackgroundCubemap } from './background.ts'; import { GRID_SIZE, halton, LIGHT_COUNT, MAX_DIST, MAX_STEPS, SURF_DIST } from './constants.ts'; diff --git a/apps/typegpu-docs/src/examples/simple/ripple-cube/pbr.ts b/apps/typegpu-docs/src/examples/simple/ripple-cube/pbr.ts index e784da9f23..e0c2850bd7 100644 --- a/apps/typegpu-docs/src/examples/simple/ripple-cube/pbr.ts +++ b/apps/typegpu-docs/src/examples/simple/ripple-cube/pbr.ts @@ -1,5 +1,5 @@ import { perlin3d } from '@typegpu/noise'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { LIGHT_COUNT, PI } from './constants.ts'; import { Light, Material } from './types.ts'; diff --git a/apps/typegpu-docs/src/examples/simple/ripple-cube/post-processing.ts b/apps/typegpu-docs/src/examples/simple/ripple-cube/post-processing.ts index 063c9af504..da14cf8b3a 100644 --- a/apps/typegpu-docs/src/examples/simple/ripple-cube/post-processing.ts +++ b/apps/typegpu-docs/src/examples/simple/ripple-cube/post-processing.ts @@ -1,5 +1,5 @@ import type { ColorAttachment, TgpuRoot } from 'typegpu'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { fullScreenTriangle } from 'typegpu/common'; import { BLUR_RADIUS, TAA_BLEND } from './constants.ts'; import { BloomParams } from './types.ts'; diff --git a/apps/typegpu-docs/src/examples/simple/ripple-cube/sdf-scene.ts b/apps/typegpu-docs/src/examples/simple/ripple-cube/sdf-scene.ts index 981b17fed9..35d70863b3 100644 --- a/apps/typegpu-docs/src/examples/simple/ripple-cube/sdf-scene.ts +++ b/apps/typegpu-docs/src/examples/simple/ripple-cube/sdf-scene.ts @@ -1,5 +1,5 @@ import * as sdf from '@typegpu/sdf'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; export const timeAccess = tgpu.accessor(d.f32); export const blendFactorAccess = tgpu.accessor(d.f32); diff --git a/apps/typegpu-docs/src/examples/simple/square/index.ts b/apps/typegpu-docs/src/examples/simple/square/index.ts index f4aa851d4d..4d94260076 100644 --- a/apps/typegpu-docs/src/examples/simple/square/index.ts +++ b/apps/typegpu-docs/src/examples/simple/square/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/examples/simple/stencil/index.ts b/apps/typegpu-docs/src/examples/simple/stencil/index.ts index 2cfdb28016..7860359473 100644 --- a/apps/typegpu-docs/src/examples/simple/stencil/index.ts +++ b/apps/typegpu-docs/src/examples/simple/stencil/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); const canvas = document.querySelector('canvas') as HTMLCanvasElement; diff --git a/apps/typegpu-docs/src/examples/simple/triangle/index.ts b/apps/typegpu-docs/src/examples/simple/triangle/index.ts index 5794dfc374..f785d16d01 100644 --- a/apps/typegpu-docs/src/examples/simple/triangle/index.ts +++ b/apps/typegpu-docs/src/examples/simple/triangle/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; // Constants and helper functions diff --git a/apps/typegpu-docs/src/examples/simple/vaporrave/floor.ts b/apps/typegpu-docs/src/examples/simple/vaporrave/floor.ts index c9df8462c6..2c918d8cd4 100644 --- a/apps/typegpu-docs/src/examples/simple/vaporrave/floor.ts +++ b/apps/typegpu-docs/src/examples/simple/vaporrave/floor.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import * as c from './constants.ts'; diff --git a/apps/typegpu-docs/src/examples/simple/vaporrave/helpers.ts b/apps/typegpu-docs/src/examples/simple/vaporrave/helpers.ts index f024898b6f..6d5cb2be1e 100644 --- a/apps/typegpu-docs/src/examples/simple/vaporrave/helpers.ts +++ b/apps/typegpu-docs/src/examples/simple/vaporrave/helpers.ts @@ -1,4 +1,4 @@ -import tgpu, { std } from 'typegpu'; +import { tgpu, std } from 'typegpu'; import { Ray } from './types.ts'; diff --git a/apps/typegpu-docs/src/examples/simple/vaporrave/index.ts b/apps/typegpu-docs/src/examples/simple/vaporrave/index.ts index 5dabe04333..5dea6db061 100644 --- a/apps/typegpu-docs/src/examples/simple/vaporrave/index.ts +++ b/apps/typegpu-docs/src/examples/simple/vaporrave/index.ts @@ -1,6 +1,6 @@ import { perlin3d } from '@typegpu/noise'; import { sdPlane } from '@typegpu/sdf'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import * as c from './constants.ts'; import { circles, grid } from './floor.ts'; diff --git a/apps/typegpu-docs/src/examples/simple/vaporrave/sphere.ts b/apps/typegpu-docs/src/examples/simple/vaporrave/sphere.ts index 41c5d10624..7b01f8fb50 100644 --- a/apps/typegpu-docs/src/examples/simple/vaporrave/sphere.ts +++ b/apps/typegpu-docs/src/examples/simple/vaporrave/sphere.ts @@ -1,6 +1,6 @@ import { perlin3d } from '@typegpu/noise'; import { sdSphere } from '@typegpu/sdf'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import * as c from './constants.ts'; import { Ray } from './types.ts'; diff --git a/apps/typegpu-docs/src/examples/simulation/boids/index.ts b/apps/typegpu-docs/src/examples/simulation/boids/index.ts index 0f484559cb..996198b0ce 100644 --- a/apps/typegpu-docs/src/examples/simulation/boids/index.ts +++ b/apps/typegpu-docs/src/examples/simulation/boids/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const triangleAmount = 1000; diff --git a/apps/typegpu-docs/src/examples/simulation/confetti/index.ts b/apps/typegpu-docs/src/examples/simulation/confetti/index.ts index f92e441102..97a4d007ea 100644 --- a/apps/typegpu-docs/src/examples/simulation/confetti/index.ts +++ b/apps/typegpu-docs/src/examples/simulation/confetti/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; // constants diff --git a/apps/typegpu-docs/src/examples/simulation/fluid-double-buffering/index.ts b/apps/typegpu-docs/src/examples/simulation/fluid-double-buffering/index.ts index 06b40b268a..13094f052d 100644 --- a/apps/typegpu-docs/src/examples/simulation/fluid-double-buffering/index.ts +++ b/apps/typegpu-docs/src/examples/simulation/fluid-double-buffering/index.ts @@ -1,5 +1,5 @@ import { randf } from '@typegpu/noise'; -import tgpu, { d, std, type TgpuBufferMutable, type TgpuBufferReadonly } from 'typegpu'; +import { tgpu, d, std, type TgpuBufferMutable, type TgpuBufferReadonly } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const MAX_GRID_SIZE = 1024; diff --git a/apps/typegpu-docs/src/examples/simulation/fluid-with-atomics/index.ts b/apps/typegpu-docs/src/examples/simulation/fluid-with-atomics/index.ts index 3e550a0eff..45add979d1 100644 --- a/apps/typegpu-docs/src/examples/simulation/fluid-with-atomics/index.ts +++ b/apps/typegpu-docs/src/examples/simulation/fluid-with-atomics/index.ts @@ -1,5 +1,5 @@ import { sdLine } from '@typegpu/sdf'; -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/examples/simulation/game-of-life/index.ts b/apps/typegpu-docs/src/examples/simulation/game-of-life/index.ts index f6276a9478..d7f57cad9e 100644 --- a/apps/typegpu-docs/src/examples/simulation/game-of-life/index.ts +++ b/apps/typegpu-docs/src/examples/simulation/game-of-life/index.ts @@ -1,5 +1,5 @@ import { randf } from '@typegpu/noise'; -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import type { SampledFlag, StorageFlag, TgpuBindGroup, TgpuComputeFn, TgpuTexture } from 'typegpu'; import { computeLayout, displayLayout, gameSizeAccessor, TILE_SIZE } from './shaders/common.ts'; import { tiledCompute } from './shaders/tiled-compute.ts'; diff --git a/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/bitpacked-compute.ts b/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/bitpacked-compute.ts index 77ff35bb18..189e407a7d 100644 --- a/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/bitpacked-compute.ts +++ b/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/bitpacked-compute.ts @@ -1,6 +1,6 @@ import * as d from 'typegpu/data'; import * as std from 'typegpu/std'; -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import { computeLayout, gameSizeAccessor, TILE_SIZE } from './common.ts'; // oxfmt-ignore diff --git a/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/common.ts b/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/common.ts index 4f2ee34708..44a046f846 100644 --- a/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/common.ts +++ b/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/common.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; import * as std from 'typegpu/std'; diff --git a/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/fragment.ts b/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/fragment.ts index 32ca811f54..ea55bffbc5 100644 --- a/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/fragment.ts +++ b/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/fragment.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; import * as std from 'typegpu/std'; diff --git a/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/naive-compute.ts b/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/naive-compute.ts index 869636aef2..07779d541a 100644 --- a/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/naive-compute.ts +++ b/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/naive-compute.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; import * as std from 'typegpu/std'; import { computeLayout, gameSizeAccessor, loadTexAt, TILE_SIZE } from './common.ts'; diff --git a/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/tiled-compute.ts b/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/tiled-compute.ts index e47a5db799..cdf24e856f 100644 --- a/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/tiled-compute.ts +++ b/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/tiled-compute.ts @@ -1,6 +1,6 @@ import * as d from 'typegpu/data'; import * as std from 'typegpu/std'; -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import { computeLayout, gameSizeAccessor, golNextState, TILE_SIZE } from './common.ts'; const HALO = 1; diff --git a/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/vertex.ts b/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/vertex.ts index 40cd615161..9164f5149c 100644 --- a/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/vertex.ts +++ b/apps/typegpu-docs/src/examples/simulation/game-of-life/shaders/vertex.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; import * as std from 'typegpu/std'; diff --git a/apps/typegpu-docs/src/examples/simulation/gravity/compute.ts b/apps/typegpu-docs/src/examples/simulation/gravity/compute.ts index 850937de7d..f1b653e5d3 100644 --- a/apps/typegpu-docs/src/examples/simulation/gravity/compute.ts +++ b/apps/typegpu-docs/src/examples/simulation/gravity/compute.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { collisionBehaviors } from './enums.ts'; import { radiusOf } from './helpers.ts'; import { CelestialBody, computeLayout, timeAccess } from './schemas.ts'; diff --git a/apps/typegpu-docs/src/examples/simulation/gravity/index.ts b/apps/typegpu-docs/src/examples/simulation/gravity/index.ts index 39601f5c9e..613cb24061 100644 --- a/apps/typegpu-docs/src/examples/simulation/gravity/index.ts +++ b/apps/typegpu-docs/src/examples/simulation/gravity/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d, type StorageFlag, type TgpuBindGroup, type TgpuBuffer } from 'typegpu'; +import { tgpu, d, type StorageFlag, type TgpuBindGroup, type TgpuBuffer } from 'typegpu'; import { computeCollisionsShader, computeGravityShader } from './compute.ts'; import { collisionBehaviors, diff --git a/apps/typegpu-docs/src/examples/simulation/gravity/render.ts b/apps/typegpu-docs/src/examples/simulation/gravity/render.ts index 3f968def2a..087baf0a37 100644 --- a/apps/typegpu-docs/src/examples/simulation/gravity/render.ts +++ b/apps/typegpu-docs/src/examples/simulation/gravity/render.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { radiusOf } from './helpers.ts'; import { cameraAccess, diff --git a/apps/typegpu-docs/src/examples/simulation/gravity/schemas.ts b/apps/typegpu-docs/src/examples/simulation/gravity/schemas.ts index 452c414231..4c53b4dc9e 100644 --- a/apps/typegpu-docs/src/examples/simulation/gravity/schemas.ts +++ b/apps/typegpu-docs/src/examples/simulation/gravity/schemas.ts @@ -1,4 +1,4 @@ -import tgpu, { d, type TgpuSampler } from 'typegpu'; +import { tgpu, d, type TgpuSampler } from 'typegpu'; import { Camera } from '../../common/setup-orbit-camera.ts'; export type CelestialBody = d.Infer; diff --git a/apps/typegpu-docs/src/examples/simulation/slime-mold-3d/index.ts b/apps/typegpu-docs/src/examples/simulation/slime-mold-3d/index.ts index dbe6d00016..7d821abc59 100644 --- a/apps/typegpu-docs/src/examples/simulation/slime-mold-3d/index.ts +++ b/apps/typegpu-docs/src/examples/simulation/slime-mold-3d/index.ts @@ -1,5 +1,5 @@ import { randf } from '@typegpu/noise'; -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import * as m from 'wgpu-matrix'; import { defineControls } from '../../common/defineControls.ts'; diff --git a/apps/typegpu-docs/src/examples/simulation/slime-mold/index.ts b/apps/typegpu-docs/src/examples/simulation/slime-mold/index.ts index ecc3184d6f..46a53589d0 100644 --- a/apps/typegpu-docs/src/examples/simulation/slime-mold/index.ts +++ b/apps/typegpu-docs/src/examples/simulation/slime-mold/index.ts @@ -1,5 +1,5 @@ import { randf } from '@typegpu/noise'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/examples/simulation/stable-fluid/index.ts b/apps/typegpu-docs/src/examples/simulation/stable-fluid/index.ts index 420c81d294..5bc17e56ab 100644 --- a/apps/typegpu-docs/src/examples/simulation/stable-fluid/index.ts +++ b/apps/typegpu-docs/src/examples/simulation/stable-fluid/index.ts @@ -1,4 +1,5 @@ -import tgpu, { +import { + tgpu, d, type TgpuBindGroup, type TgpuComputeFn, diff --git a/apps/typegpu-docs/src/examples/simulation/stable-fluid/render.ts b/apps/typegpu-docs/src/examples/simulation/stable-fluid/render.ts index 0e9aba9c4a..27fafe2073 100644 --- a/apps/typegpu-docs/src/examples/simulation/stable-fluid/render.ts +++ b/apps/typegpu-docs/src/examples/simulation/stable-fluid/render.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { SIM_N } from './params.ts'; export const renderLayout = tgpu.bindGroupLayout({ diff --git a/apps/typegpu-docs/src/examples/simulation/stable-fluid/simulation.ts b/apps/typegpu-docs/src/examples/simulation/stable-fluid/simulation.ts index 492855b4e4..c888fb2aeb 100644 --- a/apps/typegpu-docs/src/examples/simulation/stable-fluid/simulation.ts +++ b/apps/typegpu-docs/src/examples/simulation/stable-fluid/simulation.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import * as p from './params.ts'; const getNeighbors = (coords: d.v2i, bounds: d.v2i): d.v2i[] => { diff --git a/apps/typegpu-docs/src/examples/simulation/wind-map/index.ts b/apps/typegpu-docs/src/examples/simulation/wind-map/index.ts index 639d4914d8..f28589b923 100644 --- a/apps/typegpu-docs/src/examples/simulation/wind-map/index.ts +++ b/apps/typegpu-docs/src/examples/simulation/wind-map/index.ts @@ -6,7 +6,7 @@ import { lineSegmentVariableWidth, startCapSlot, } from '@typegpu/geometry'; -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import { arrayOf, builtin, f32, i32, struct, u16, u32, vec2f, vec4f } from 'typegpu/data'; import { clamp, mix, normalize, select } from 'typegpu/std'; import { defineControls } from '../../common/defineControls.ts'; diff --git a/apps/typegpu-docs/src/examples/tests/buffer-write-benchmark/index.ts b/apps/typegpu-docs/src/examples/tests/buffer-write-benchmark/index.ts index f58bfa02e9..f5d79614c4 100644 --- a/apps/typegpu-docs/src/examples/tests/buffer-write-benchmark/index.ts +++ b/apps/typegpu-docs/src/examples/tests/buffer-write-benchmark/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/examples/tests/dispatch/index.ts b/apps/typegpu-docs/src/examples/tests/dispatch/index.ts index c3b0c2cbaa..f0e178a8c9 100644 --- a/apps/typegpu-docs/src/examples/tests/dispatch/index.ts +++ b/apps/typegpu-docs/src/examples/tests/dispatch/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/examples/tests/log-test/index.ts b/apps/typegpu-docs/src/examples/tests/log-test/index.ts index 585a9bccbb..35f411688e 100644 --- a/apps/typegpu-docs/src/examples/tests/log-test/index.ts +++ b/apps/typegpu-docs/src/examples/tests/log-test/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std, type TgpuVertexFn } from 'typegpu'; +import { tgpu, d, std, type TgpuVertexFn } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const root = await tgpu.init({ diff --git a/apps/typegpu-docs/src/examples/tests/prefix-scan/functions.ts b/apps/typegpu-docs/src/examples/tests/prefix-scan/functions.ts index 9f086f1cf9..c75068e8f9 100644 --- a/apps/typegpu-docs/src/examples/tests/prefix-scan/functions.ts +++ b/apps/typegpu-docs/src/examples/tests/prefix-scan/functions.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; import * as std from 'typegpu/std'; import type { BinaryOp } from '@typegpu/sort'; diff --git a/apps/typegpu-docs/src/examples/tests/prefix-scan/index.ts b/apps/typegpu-docs/src/examples/tests/prefix-scan/index.ts index 87c3d2b779..9049fd9982 100644 --- a/apps/typegpu-docs/src/examples/tests/prefix-scan/index.ts +++ b/apps/typegpu-docs/src/examples/tests/prefix-scan/index.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; import { type BinaryOp, prefixScan, scan } from '@typegpu/sort'; import * as std from 'typegpu/std'; diff --git a/apps/typegpu-docs/src/examples/tests/rc-docs-examples/index.ts b/apps/typegpu-docs/src/examples/tests/rc-docs-examples/index.ts index cd1b337b22..b4652a5d46 100644 --- a/apps/typegpu-docs/src/examples/tests/rc-docs-examples/index.ts +++ b/apps/typegpu-docs/src/examples/tests/rc-docs-examples/index.ts @@ -1,6 +1,6 @@ import * as rc from '@typegpu/radiance-cascades'; import * as sdf from '@typegpu/sdf'; -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/examples/tests/sdf-docs-examples/index.ts b/apps/typegpu-docs/src/examples/tests/sdf-docs-examples/index.ts index 8702000434..22b32eaf33 100644 --- a/apps/typegpu-docs/src/examples/tests/sdf-docs-examples/index.ts +++ b/apps/typegpu-docs/src/examples/tests/sdf-docs-examples/index.ts @@ -1,5 +1,5 @@ import * as sdf from '@typegpu/sdf'; -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/examples/tests/texture-test/index.ts b/apps/typegpu-docs/src/examples/tests/texture-test/index.ts index 9b0f7efccf..9de885a762 100644 --- a/apps/typegpu-docs/src/examples/tests/texture-test/index.ts +++ b/apps/typegpu-docs/src/examples/tests/texture-test/index.ts @@ -1,4 +1,4 @@ -import tgpu, { common, d } from 'typegpu'; +import { tgpu, common, d } from 'typegpu'; import { defineControls } from '../../common/defineControls.ts'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/array-and-struct-constructors.ts b/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/array-and-struct-constructors.ts index 9a77cf0f71..78b9ba51a4 100644 --- a/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/array-and-struct-constructors.ts +++ b/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/array-and-struct-constructors.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; const SimpleStruct = d.struct({ vec: d.vec2f }); const SimpleArray = d.arrayOf(d.i32, 2); diff --git a/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/index.ts b/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/index.ts index 404fc1e25a..3cf1fcfbab 100644 --- a/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/index.ts +++ b/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { arrayAndStructConstructorsTest } from './array-and-struct-constructors.ts'; import { infixOperatorsTests } from './infix-operators.ts'; import { logicalExpressionTests } from './logical-expressions.ts'; diff --git a/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/infix-operators.ts b/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/infix-operators.ts index c76799aa59..9de06a8ca0 100644 --- a/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/infix-operators.ts +++ b/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/infix-operators.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; const getVec = tgpu.fn([], d.vec3f)(() => d.vec3f(1, 2, 3)); diff --git a/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/logical-expressions.ts b/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/logical-expressions.ts index b6807232ce..1e79f6a257 100644 --- a/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/logical-expressions.ts +++ b/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/logical-expressions.ts @@ -1,5 +1,5 @@ // oxlint-disable typescript/no-unnecessary-boolean-literal-compare -- this is a test -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; const Schema = d.struct({ vec2b: d.vec2b, diff --git a/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/matrix-ops.ts b/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/matrix-ops.ts index 6e1f80f6df..46517fb9a7 100644 --- a/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/matrix-ops.ts +++ b/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/matrix-ops.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; // TODO: replace `s = s &&` with `s &&=` when implemented export const matrixOpsTests = tgpu.fn( diff --git a/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/pointers.ts b/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/pointers.ts index dcb1c86460..0119b0a3c8 100644 --- a/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/pointers.ts +++ b/apps/typegpu-docs/src/examples/tests/tgsl-parsing-test/pointers.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; const SimpleStruct = d.struct({ vec: d.vec2f }); diff --git a/apps/typegpu-docs/src/examples/tests/uniformity/index.ts b/apps/typegpu-docs/src/examples/tests/uniformity/index.ts index 62267e1c4a..fb9194ee06 100644 --- a/apps/typegpu-docs/src/examples/tests/uniformity/index.ts +++ b/apps/typegpu-docs/src/examples/tests/uniformity/index.ts @@ -1,5 +1,5 @@ import { randf, randomGeneratorSlot } from '@typegpu/noise'; -import tgpu, { common, d, std, type TgpuRenderPipeline } from 'typegpu'; +import { tgpu, common, d, std, type TgpuRenderPipeline } from 'typegpu'; import * as c from './constants.ts'; import { getPRNG, type PRNG } from './prngs.ts'; diff --git a/apps/typegpu-docs/src/examples/tests/uniformity/lcg.ts b/apps/typegpu-docs/src/examples/tests/uniformity/lcg.ts index f6bffe867c..d9db09be43 100644 --- a/apps/typegpu-docs/src/examples/tests/uniformity/lcg.ts +++ b/apps/typegpu-docs/src/examples/tests/uniformity/lcg.ts @@ -1,5 +1,5 @@ import type { StatefulGenerator } from '@typegpu/noise'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; export const LCG: StatefulGenerator = (() => { const seed = tgpu.privateVar(d.u32); diff --git a/apps/typegpu-docs/src/examples/tests/wgsl-resolution/index.ts b/apps/typegpu-docs/src/examples/tests/wgsl-resolution/index.ts index 84f3261344..7bcc04609a 100644 --- a/apps/typegpu-docs/src/examples/tests/wgsl-resolution/index.ts +++ b/apps/typegpu-docs/src/examples/tests/wgsl-resolution/index.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; const root = await tgpu.init(); diff --git a/apps/typegpu-docs/src/examples/threejs/compute-cloth/triNoise.ts b/apps/typegpu-docs/src/examples/threejs/compute-cloth/triNoise.ts index 33af55c481..c4227a539a 100644 --- a/apps/typegpu-docs/src/examples/threejs/compute-cloth/triNoise.ts +++ b/apps/typegpu-docs/src/examples/threejs/compute-cloth/triNoise.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; const tri = (x: number): number => { 'use gpu'; diff --git a/apps/typegpu-docs/src/examples/threejs/test-reused-functions/functions.ts b/apps/typegpu-docs/src/examples/threejs/test-reused-functions/functions.ts index 650cbda179..b73951ee8e 100644 --- a/apps/typegpu-docs/src/examples/threejs/test-reused-functions/functions.ts +++ b/apps/typegpu-docs/src/examples/threejs/test-reused-functions/functions.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; export const getColorA = () => { 'use gpu'; diff --git a/packages/tgpu-gen/gen.mjs b/packages/tgpu-gen/gen.mjs index 6d5acd5878..c6c7c7f39d 100644 --- a/packages/tgpu-gen/gen.mjs +++ b/packages/tgpu-gen/gen.mjs @@ -494,7 +494,7 @@ function generateImports(options) { options.usedImports?.tgpu ? options.moduleSyntax === 'commonjs' ? "const tgpu = require('typegpu').default;" - : "import tgpu from 'typegpu';" + : "import { tgpu } from 'typegpu';" : null, options.usedImports?.data diff --git a/packages/tgpu-gen/tests/bindGroupLayouts.test.ts b/packages/tgpu-gen/tests/bindGroupLayouts.test.ts index 147bd45ea8..b85f6a2d9e 100644 --- a/packages/tgpu-gen/tests/bindGroupLayouts.test.ts +++ b/packages/tgpu-gen/tests/bindGroupLayouts.test.ts @@ -212,7 +212,7 @@ export const layout3 = tgpu.bindGroupLayout({ }); it('adds typegpu import to the generated code', () => { - const importStatement = "import tgpu from 'typegpu';"; + const importStatement = "import { tgpu } from 'typegpu';"; expect(generate('@binding(0) @group(0) var a : f32;')).toContain(importStatement); expect(generate('')).not.toContain(importStatement); diff --git a/packages/tgpu-gen/tests/functions.test.ts b/packages/tgpu-gen/tests/functions.test.ts index 3c09d12cc5..2999728ad9 100644 --- a/packages/tgpu-gen/tests/functions.test.ts +++ b/packages/tgpu-gen/tests/functions.test.ts @@ -36,6 +36,6 @@ export const foo = tgpu.fn([])(/* wgsl */ \`() { it('adds tgpu import', () => { const wgsl = 'fn f() {}'; - expect(generate(wgsl)).toContain("import tgpu from 'typegpu';"); + expect(generate(wgsl)).toContain("import { tgpu } from 'typegpu';"); }); }); diff --git a/packages/typegpu-cli/templates/template-vite-complex/src/main.ts b/packages/typegpu-cli/templates/template-vite-complex/src/main.ts index 1a92565541..dc715557a8 100644 --- a/packages/typegpu-cli/templates/template-vite-complex/src/main.ts +++ b/packages/typegpu-cli/templates/template-vite-complex/src/main.ts @@ -1,4 +1,4 @@ -import tgpu, { common, d, std } from 'typegpu'; +import { tgpu, common, d, std } from 'typegpu'; import { hexToOklab, oklabToRgb } from '@typegpu/color'; import { perlin2d } from '@typegpu/noise'; diff --git a/packages/typegpu-cli/templates/template-vite-simple/src/main.ts b/packages/typegpu-cli/templates/template-vite-simple/src/main.ts index 53de8d3c06..902d86678e 100644 --- a/packages/typegpu-cli/templates/template-vite-simple/src/main.ts +++ b/packages/typegpu-cli/templates/template-vite-simple/src/main.ts @@ -1,4 +1,4 @@ -import tgpu, { common, d } from 'typegpu'; +import { tgpu, common, d } from 'typegpu'; const root = await tgpu.init(); diff --git a/packages/typegpu-color/src/hex.ts b/packages/typegpu-color/src/hex.ts index ea2c039d69..8c54ea5f8a 100644 --- a/packages/typegpu-color/src/hex.ts +++ b/packages/typegpu-color/src/hex.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { rgbToOklab } from './oklab.ts'; export const hexToRgb = tgpu.comptime((hex: string | number): d.v3f => { diff --git a/packages/typegpu-color/src/hsv.ts b/packages/typegpu-color/src/hsv.ts index f945e777b5..d8d0cb5ca9 100644 --- a/packages/typegpu-color/src/hsv.ts +++ b/packages/typegpu-color/src/hsv.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import { f32, vec3f } from 'typegpu/data'; import { floor, max, min } from 'typegpu/std'; diff --git a/packages/typegpu-color/src/oklab.ts b/packages/typegpu-color/src/oklab.ts index f18efcc05d..22f36f63ec 100644 --- a/packages/typegpu-color/src/oklab.ts +++ b/packages/typegpu-color/src/oklab.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import { f32, struct, vec3f } from 'typegpu/data'; import { abs, clamp, length, max, min, mix, pow, select, sign, sqrt } from 'typegpu/std'; import { linearToSrgb, srgbToLinear } from './srgb.ts'; diff --git a/packages/typegpu-color/src/srgb.ts b/packages/typegpu-color/src/srgb.ts index a451546a81..257e406fdf 100644 --- a/packages/typegpu-color/src/srgb.ts +++ b/packages/typegpu-color/src/srgb.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import { vec3f } from 'typegpu/data'; import { gt, pow, select } from 'typegpu/std'; diff --git a/packages/typegpu-color/src/ycbcr.ts b/packages/typegpu-color/src/ycbcr.ts index e220558d31..5081cd3888 100644 --- a/packages/typegpu-color/src/ycbcr.ts +++ b/packages/typegpu-color/src/ycbcr.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import { mat3x3f, vec3f } from 'typegpu/data'; import { mul } from 'typegpu/std'; diff --git a/packages/typegpu-geometry/src/circle.ts b/packages/typegpu-geometry/src/circle.ts index 9b0e876b05..d0434ff305 100644 --- a/packages/typegpu-geometry/src/circle.ts +++ b/packages/typegpu-geometry/src/circle.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import { f32, struct, u32, vec2f } from 'typegpu/data'; import { cos, select, sin } from 'typegpu/std'; diff --git a/packages/typegpu-geometry/src/lines/externalNormals.ts b/packages/typegpu-geometry/src/lines/externalNormals.ts index 4ff671ad64..8af49ad7cb 100644 --- a/packages/typegpu-geometry/src/lines/externalNormals.ts +++ b/packages/typegpu-geometry/src/lines/externalNormals.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import type { Infer } from 'typegpu/data'; import { f32, struct, vec2f } from 'typegpu/data'; import { dot, max, sqrt } from 'typegpu/std'; diff --git a/packages/typegpu-geometry/src/lines/joins/miter.ts b/packages/typegpu-geometry/src/lines/joins/miter.ts index 7a83cdab69..c17f031af4 100644 --- a/packages/typegpu-geometry/src/lines/joins/miter.ts +++ b/packages/typegpu-geometry/src/lines/joins/miter.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import type { v2f } from 'typegpu/data'; import { vec2f } from 'typegpu/data'; import { dot, normalize, select } from 'typegpu/std'; diff --git a/packages/typegpu-geometry/src/lines/lines.ts b/packages/typegpu-geometry/src/lines/lines.ts index aca1f14f1a..7ae8993d90 100644 --- a/packages/typegpu-geometry/src/lines/lines.ts +++ b/packages/typegpu-geometry/src/lines/lines.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import { u32, vec2f } from 'typegpu/data'; import { dot, neg, select } from 'typegpu/std'; import { intersectLines } from '../utils.ts'; diff --git a/packages/typegpu-geometry/src/utils.ts b/packages/typegpu-geometry/src/utils.ts index 11c58732bf..438582f217 100644 --- a/packages/typegpu-geometry/src/utils.ts +++ b/packages/typegpu-geometry/src/utils.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import { bool, f32, struct, vec2f } from 'typegpu/data'; import { dot, mix, normalize, select } from 'typegpu/std'; diff --git a/packages/typegpu-gl/src/glslGenerator.ts b/packages/typegpu-gl/src/glslGenerator.ts index 4c549bdac7..b7ffd8293d 100644 --- a/packages/typegpu-gl/src/glslGenerator.ts +++ b/packages/typegpu-gl/src/glslGenerator.ts @@ -1,6 +1,6 @@ import { NodeTypeCatalog as NODE } from 'tinyest'; import type { Return } from 'tinyest'; -import tgpu, { d, ShaderGenerator, WgslGenerator } from 'typegpu'; +import { tgpu, d, ShaderGenerator, WgslGenerator } from 'typegpu'; type ResolutionCtx = ShaderGenerator.ResolutionCtx; diff --git a/packages/typegpu-gl/src/initWithGLFallback.ts b/packages/typegpu-gl/src/initWithGLFallback.ts index e11022b5b2..7c81859b5f 100644 --- a/packages/typegpu-gl/src/initWithGLFallback.ts +++ b/packages/typegpu-gl/src/initWithGLFallback.ts @@ -1,4 +1,4 @@ -import tgpu, { type TgpuRoot } from 'typegpu'; +import { tgpu, type TgpuRoot } from 'typegpu'; export async function initWithGLFallback(): Promise { // Try WebGPU first diff --git a/packages/typegpu-gl/src/tgpuRootWebGL.ts b/packages/typegpu-gl/src/tgpuRootWebGL.ts index c010352abe..729c2f4f6d 100644 --- a/packages/typegpu-gl/src/tgpuRootWebGL.ts +++ b/packages/typegpu-gl/src/tgpuRootWebGL.ts @@ -6,7 +6,7 @@ * Compute operations, storage buffers, textures, etc. throw WebGLFallbackUnsupportedError. */ -import tgpu, { d, ShaderGenerator, type TgpuFragmentFn, type TgpuVertexFn } from 'typegpu'; +import { tgpu, d, ShaderGenerator, type TgpuFragmentFn, type TgpuVertexFn } from 'typegpu'; import glslGenerator, { translateWgslTypeToGlsl } from './glslGenerator.ts'; // ---------- diff --git a/packages/typegpu-gl/tests/glslGenerator.test.ts b/packages/typegpu-gl/tests/glslGenerator.test.ts index a396d3df94..e72a8d7d03 100644 --- a/packages/typegpu-gl/tests/glslGenerator.test.ts +++ b/packages/typegpu-gl/tests/glslGenerator.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { glOptions } from '@typegpu/gl'; import { translateWgslTypeToGlsl } from '../src/glslGenerator.ts'; diff --git a/packages/typegpu-gl/tests/webglFallback.test.ts b/packages/typegpu-gl/tests/webglFallback.test.ts index 6bf5da8552..4e9c1ba44d 100644 --- a/packages/typegpu-gl/tests/webglFallback.test.ts +++ b/packages/typegpu-gl/tests/webglFallback.test.ts @@ -1,5 +1,5 @@ import { describe, expect, vi } from 'vitest'; -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { initWithGL } from '../src/index.ts'; import { it } from './utils/extendedTest.ts'; diff --git a/packages/typegpu-noise/src/generator.ts b/packages/typegpu-noise/src/generator.ts index fa9d1153ef..2b2e98cec9 100644 --- a/packages/typegpu-noise/src/generator.ts +++ b/packages/typegpu-noise/src/generator.ts @@ -1,4 +1,4 @@ -import tgpu, { d, type TgpuFnShell, type TgpuSlot } from 'typegpu'; +import { tgpu, d, type TgpuFnShell, type TgpuSlot } from 'typegpu'; import { cos, dot, fract } from 'typegpu/std'; export interface StatefulGenerator { diff --git a/packages/typegpu-noise/src/perlin-2d/algorithm.ts b/packages/typegpu-noise/src/perlin-2d/algorithm.ts index 5b815ed893..5e0a67cabc 100644 --- a/packages/typegpu-noise/src/perlin-2d/algorithm.ts +++ b/packages/typegpu-noise/src/perlin-2d/algorithm.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { dot, floor, fract } from 'typegpu/std'; import { randOnUnitCircle, randSeed2 } from '../random.ts'; import { quinticDerivative, quinticInterpolation } from '../utils.ts'; diff --git a/packages/typegpu-noise/src/perlin-2d/dynamic-cache.ts b/packages/typegpu-noise/src/perlin-2d/dynamic-cache.ts index c3a8224d27..36d3e07a39 100644 --- a/packages/typegpu-noise/src/perlin-2d/dynamic-cache.ts +++ b/packages/typegpu-noise/src/perlin-2d/dynamic-cache.ts @@ -1,4 +1,5 @@ -import tgpu, { +import { + tgpu, type Configurable, type StorageFlag, type TgpuAccessor, diff --git a/packages/typegpu-noise/src/perlin-2d/static-cache.ts b/packages/typegpu-noise/src/perlin-2d/static-cache.ts index 27ceeef6ef..527f6f2c5f 100644 --- a/packages/typegpu-noise/src/perlin-2d/static-cache.ts +++ b/packages/typegpu-noise/src/perlin-2d/static-cache.ts @@ -1,4 +1,4 @@ -import tgpu, { type Configurable, type TgpuFn, type TgpuRoot } from 'typegpu'; +import { tgpu, type Configurable, type TgpuFn, type TgpuRoot } from 'typegpu'; import * as d from 'typegpu/data'; import { computeJunctionGradient, getJunctionGradientSlot } from './algorithm.ts'; diff --git a/packages/typegpu-noise/src/perlin-3d/algorithm.ts b/packages/typegpu-noise/src/perlin-3d/algorithm.ts index 5fe3d9f151..93fab312a4 100644 --- a/packages/typegpu-noise/src/perlin-3d/algorithm.ts +++ b/packages/typegpu-noise/src/perlin-3d/algorithm.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; import { dot, floor, mix } from 'typegpu/std'; import { randOnUnitSphere, randSeed3 } from '../random.ts'; diff --git a/packages/typegpu-noise/src/perlin-3d/dynamic-cache.ts b/packages/typegpu-noise/src/perlin-3d/dynamic-cache.ts index ab14314407..0cad3c0d8b 100644 --- a/packages/typegpu-noise/src/perlin-3d/dynamic-cache.ts +++ b/packages/typegpu-noise/src/perlin-3d/dynamic-cache.ts @@ -1,4 +1,5 @@ -import tgpu, { +import { + tgpu, type Configurable, type StorageFlag, type TgpuAccessor, diff --git a/packages/typegpu-noise/src/perlin-3d/static-cache.ts b/packages/typegpu-noise/src/perlin-3d/static-cache.ts index eacf40b5fc..74ee6d5d44 100644 --- a/packages/typegpu-noise/src/perlin-3d/static-cache.ts +++ b/packages/typegpu-noise/src/perlin-3d/static-cache.ts @@ -1,4 +1,4 @@ -import tgpu, { type Configurable, type TgpuFn, type TgpuRoot } from 'typegpu'; +import { tgpu, type Configurable, type TgpuFn, type TgpuRoot } from 'typegpu'; import * as d from 'typegpu/data'; import { computeJunctionGradient, getJunctionGradientSlot } from './algorithm.ts'; diff --git a/packages/typegpu-noise/src/random.ts b/packages/typegpu-noise/src/random.ts index e1ddd472b2..d0b4bdf314 100644 --- a/packages/typegpu-noise/src/random.ts +++ b/packages/typegpu-noise/src/random.ts @@ -1,4 +1,4 @@ -import tgpu, { d, type TgpuFn } from 'typegpu'; +import { tgpu, d, type TgpuFn } from 'typegpu'; import { cos, dot, log, normalize, select, sign, sin, sqrt, step, tan } from 'typegpu/std'; import { randomGeneratorSlot } from './generator.ts'; diff --git a/packages/typegpu-radiance-cascades/src/cascades.ts b/packages/typegpu-radiance-cascades/src/cascades.ts index d63217faaf..5a32202d24 100644 --- a/packages/typegpu-radiance-cascades/src/cascades.ts +++ b/packages/typegpu-radiance-cascades/src/cascades.ts @@ -1,4 +1,4 @@ -import tgpu, { std, d } from 'typegpu'; +import { tgpu, std, d } from 'typegpu'; const ERODE_BIAS = 2; diff --git a/packages/typegpu-react/src/core/root-context.tsx b/packages/typegpu-react/src/core/root-context.tsx index 4b16f69c01..f3ea20c647 100644 --- a/packages/typegpu-react/src/core/root-context.tsx +++ b/packages/typegpu-react/src/core/root-context.tsx @@ -6,7 +6,7 @@ import React, { useMemo, useState, } from 'react'; -import tgpu, { type TgpuRoot } from 'typegpu'; +import { tgpu, type TgpuRoot } from 'typegpu'; import { useDeferredCleanup } from './helper-hooks.ts'; function attachPromiseStatus( diff --git a/packages/typegpu-react/src/core/use-render.ts b/packages/typegpu-react/src/core/use-render.ts index 65602cf459..514f10c8f7 100644 --- a/packages/typegpu-react/src/core/use-render.ts +++ b/packages/typegpu-react/src/core/use-render.ts @@ -1,5 +1,5 @@ import * as d from 'typegpu/data'; -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import { useMemo, useRef } from 'react'; import { useRoot } from './root-context.tsx'; diff --git a/packages/typegpu-react/tests/root-context.test.tsx b/packages/typegpu-react/tests/root-context.test.tsx index 81c873c585..cdf1c8ec9c 100644 --- a/packages/typegpu-react/tests/root-context.test.tsx +++ b/packages/typegpu-react/tests/root-context.test.tsx @@ -1,6 +1,6 @@ import { act, render } from '@testing-library/react'; import { afterEach, beforeEach, describe, expect, vi } from 'vitest'; -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import type { TgpuRoot } from 'typegpu'; import { Root, useRootWithStatus } from '@typegpu/react'; import { useEffect } from 'react'; diff --git a/packages/typegpu-sdf/README.md b/packages/typegpu-sdf/README.md index 2b5e059f69..47dd16b61f 100644 --- a/packages/typegpu-sdf/README.md +++ b/packages/typegpu-sdf/README.md @@ -7,7 +7,7 @@ A set of signed distance functions and utilities for use in WebGPU/TypeGPU apps. ```ts -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import * as sdf from '@typegpu/sdf'; const mainFragment = tgpu.fragmentFn({ diff --git a/packages/typegpu-sdf/src/2d.ts b/packages/typegpu-sdf/src/2d.ts index 507616c315..72e525f41b 100644 --- a/packages/typegpu-sdf/src/2d.ts +++ b/packages/typegpu-sdf/src/2d.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import { f32, type v2f, vec2f, vec3f } from 'typegpu/data'; import { abs, diff --git a/packages/typegpu-sdf/src/3d.ts b/packages/typegpu-sdf/src/3d.ts index d2cd9848ab..010272dfbe 100644 --- a/packages/typegpu-sdf/src/3d.ts +++ b/packages/typegpu-sdf/src/3d.ts @@ -1,4 +1,4 @@ -import tgpu from 'typegpu'; +import { tgpu } from 'typegpu'; import { f32, vec3f } from 'typegpu/data'; import { abs, distance, dot, length, max, min, saturate } from 'typegpu/std'; diff --git a/packages/typegpu-sdf/src/jumpFlood.ts b/packages/typegpu-sdf/src/jumpFlood.ts index 7ce91a6b4e..b0ea202b42 100644 --- a/packages/typegpu-sdf/src/jumpFlood.ts +++ b/packages/typegpu-sdf/src/jumpFlood.ts @@ -1,4 +1,5 @@ -import tgpu, { +import { + tgpu, type SampledFlag, type StorageFlag, type TgpuBindGroup, diff --git a/packages/typegpu-sdf/src/operators.ts b/packages/typegpu-sdf/src/operators.ts index e652148f05..1d2e34b25c 100644 --- a/packages/typegpu-sdf/src/operators.ts +++ b/packages/typegpu-sdf/src/operators.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; /** * Union operator for combining two SDFs diff --git a/packages/typegpu-sort/README.md b/packages/typegpu-sort/README.md index a318da18a8..217b269409 100644 --- a/packages/typegpu-sort/README.md +++ b/packages/typegpu-sort/README.md @@ -11,7 +11,7 @@ GPU sorting and scanning algorithms for TypeGPU. Sorts a `u32` storage buffer in-place. Arrays with non-power-of-2 lengths are padded automatically. ```ts -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { createBitonicSorter } from '@typegpu/sort'; const root = await tgpu.init(); diff --git a/packages/typegpu-sort/src/bitonic/bitonicSort.ts b/packages/typegpu-sort/src/bitonic/bitonicSort.ts index 3eb5538029..a4bba2eade 100644 --- a/packages/typegpu-sort/src/bitonic/bitonicSort.ts +++ b/packages/typegpu-sort/src/bitonic/bitonicSort.ts @@ -1,4 +1,5 @@ -import tgpu, { +import { + tgpu, d, std, type StorageFlag, diff --git a/packages/typegpu-sort/src/bitonic/slots.ts b/packages/typegpu-sort/src/bitonic/slots.ts index edf09b21c2..4a91f26cd2 100644 --- a/packages/typegpu-sort/src/bitonic/slots.ts +++ b/packages/typegpu-sort/src/bitonic/slots.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; /** Default comparison function: ascending order (a < b means a comes before b) */ export const defaultCompare = tgpu.fn([d.u32, d.u32], d.bool)((a, b) => a < b); diff --git a/packages/typegpu-sort/src/scan/compute/applySums.ts b/packages/typegpu-sort/src/scan/compute/applySums.ts index d1e713e24a..64b7db6578 100644 --- a/packages/typegpu-sort/src/scan/compute/applySums.ts +++ b/packages/typegpu-sort/src/scan/compute/applySums.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { operatorSlot, uniformOpLayout, WORKGROUP_SIZE } from '../schemas.ts'; export const uniformOp = tgpu.computeFn({ diff --git a/packages/typegpu-sort/src/scan/compute/scan.ts b/packages/typegpu-sort/src/scan/compute/scan.ts index 25bea70d24..fca23d6c0c 100644 --- a/packages/typegpu-sort/src/scan/compute/scan.ts +++ b/packages/typegpu-sort/src/scan/compute/scan.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { identitySlot, onlyGreatestElementSlot, diff --git a/packages/typegpu-sort/src/scan/compute/shared.ts b/packages/typegpu-sort/src/scan/compute/shared.ts index 6d6b78322c..adbdbe048f 100644 --- a/packages/typegpu-sort/src/scan/compute/shared.ts +++ b/packages/typegpu-sort/src/scan/compute/shared.ts @@ -1,4 +1,4 @@ -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; import { operatorSlot, WORKGROUP_SIZE } from '../schemas.ts'; export const workgroupMemory = tgpu.workgroupVar(d.arrayOf(d.f32, WORKGROUP_SIZE)); diff --git a/packages/typegpu-sort/src/scan/schemas.ts b/packages/typegpu-sort/src/scan/schemas.ts index 692920e1ee..f8709b4e4c 100644 --- a/packages/typegpu-sort/src/scan/schemas.ts +++ b/packages/typegpu-sort/src/scan/schemas.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; export const WORKGROUP_SIZE = 256; diff --git a/packages/typegpu-testing-utility/src/extendedIt.ts b/packages/typegpu-testing-utility/src/extendedIt.ts index 00ba17e02c..dd1438d401 100644 --- a/packages/typegpu-testing-utility/src/extendedIt.ts +++ b/packages/typegpu-testing-utility/src/extendedIt.ts @@ -1,6 +1,6 @@ // oxlint-disable no-empty-pattern import { test as base, vi } from 'vitest'; -import tgpu, { type TgpuRoot } from 'typegpu'; +import { tgpu, type TgpuRoot } from 'typegpu'; // oxlint-disable-next-line import/no-unassigned-import -- imported for side effects import './webgpuGlobals.ts'; diff --git a/packages/typegpu-three/src/builtin-accessors.ts b/packages/typegpu-three/src/builtin-accessors.ts index 7a1cbe5aaa..d65c94fdc1 100644 --- a/packages/typegpu-three/src/builtin-accessors.ts +++ b/packages/typegpu-three/src/builtin-accessors.ts @@ -1,5 +1,5 @@ import * as TSL from 'three/tsl'; -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { fromTSL } from './typegpu-node.ts'; export const uv = tgpu.comptime((index?: number) => fromTSL(TSL.uv(index), d.vec2f)); diff --git a/packages/typegpu-three/src/typegpu-node.ts b/packages/typegpu-three/src/typegpu-node.ts index 63d588f7eb..fabf7460e0 100644 --- a/packages/typegpu-three/src/typegpu-node.ts +++ b/packages/typegpu-three/src/typegpu-node.ts @@ -1,7 +1,7 @@ import type NodeFunction from 'three/src/nodes/core/NodeFunction.js'; import * as THREE from 'three/webgpu'; import * as TSL from 'three/tsl'; -import tgpu, { type Namespace, type TgpuVar } from 'typegpu'; +import { tgpu, type Namespace, type TgpuVar } from 'typegpu'; import * as d from 'typegpu/data'; import WGSLNodeBuilder from 'three/src/renderers/webgpu/nodes/WGSLNodeBuilder.js'; diff --git a/packages/typegpu/src/index.d.ts b/packages/typegpu/src/index.d.ts index faedbf3a41..36a9ea2e5b 100644 --- a/packages/typegpu/src/index.d.ts +++ b/packages/typegpu/src/index.d.ts @@ -4,30 +4,7 @@ // NOTE: This is a barrel file, internal files should not import things from this file -export declare const tgpu: { - const: typeof import('./core/constant/tgpuConstant.ts').constant; - fn: typeof import('./core/function/tgpuFn.ts').fn; - comptime: typeof import('./core/function/comptime.ts').comptime; - resolve: typeof import('./core/resolve/tgpuResolve.ts').resolve; - resolveWithContext: typeof import('./core/resolve/tgpuResolve.ts').resolveWithContext; - init: typeof import('./core/root/init.ts').init; - initFromDevice: typeof import('./core/root/init.ts').initFromDevice; - slot: typeof import('./core/slot/slot.ts').slot; - lazy: typeof import('./core/slot/lazy.ts').lazy; - accessor: typeof import('./core/slot/accessor.ts').accessor; - mutableAccessor: typeof import('./core/slot/accessor.ts').mutableAccessor; - privateVar: typeof import('./core/variable/tgpuVariable.ts').privateVar; - workgroupVar: typeof import('./core/variable/tgpuVariable.ts').workgroupVar; - vertexLayout: typeof import('./core/vertexLayout/vertexLayout.ts').vertexLayout; - bindGroupLayout: typeof import('./tgpuBindGroupLayout.ts').bindGroupLayout; - computeFn: typeof import('./core/function/tgpuComputeFn.ts').computeFn; - fragmentFn: typeof import('./core/function/tgpuFragmentFn.ts').fragmentFn; - vertexFn: typeof import('./core/function/tgpuVertexFn.ts').vertexFn; - unroll: typeof import('./core/unroll/tgpuUnroll.ts').unroll; - - '~unstable': typeof import('./tgpuUnstable.ts'); -}; - +declare const tgpu: typeof import('./tgpu.ts').tgpu; export default tgpu; export * from './indexNamedExports.ts'; diff --git a/packages/typegpu/src/index.js b/packages/typegpu/src/index.js index a97d1744e6..dcb171d631 100644 --- a/packages/typegpu/src/index.js +++ b/packages/typegpu/src/index.js @@ -4,8 +4,7 @@ // NOTE: This is a barrel file, internal files should not import things from this file -import * as tgpu from './tgpu.ts'; -export * as tgpu from './tgpu.ts'; +import { tgpu } from './tgpu.ts'; export default tgpu; export * from './indexNamedExports.ts'; diff --git a/packages/typegpu/src/indexNamedExports.ts b/packages/typegpu/src/indexNamedExports.ts index 8a4ba4d469..d491e60353 100644 --- a/packages/typegpu/src/indexNamedExports.ts +++ b/packages/typegpu/src/indexNamedExports.ts @@ -1,5 +1,6 @@ // NOTE: This is a barrel file, internal files should not import things from this file +export { tgpu } from './tgpu.ts'; export * as d from './data/index.ts'; export * as std from './std/index.ts'; export * as common from './common/index.ts'; diff --git a/packages/typegpu/src/tgpu.ts b/packages/typegpu/src/tgpu.ts index 346be531ae..087fddcfaa 100644 --- a/packages/typegpu/src/tgpu.ts +++ b/packages/typegpu/src/tgpu.ts @@ -1,19 +1,62 @@ // NOTE: This is a barrel file, internal files should not import things from this file -export { constant as const } from './core/constant/tgpuConstant.ts'; -export { fn } from './core/function/tgpuFn.ts'; -export { comptime } from './core/function/comptime.ts'; -export { resolve, resolveWithContext } from './core/resolve/tgpuResolve.ts'; -export { init, initFromDevice } from './core/root/init.ts'; -export { slot } from './core/slot/slot.ts'; -export { lazy } from './core/slot/lazy.ts'; -export { accessor, mutableAccessor } from './core/slot/accessor.ts'; -export { privateVar, workgroupVar } from './core/variable/tgpuVariable.ts'; -export { vertexLayout } from './core/vertexLayout/vertexLayout.ts'; -export { bindGroupLayout } from './tgpuBindGroupLayout.ts'; -export { computeFn } from './core/function/tgpuComputeFn.ts'; -export { fragmentFn } from './core/function/tgpuFragmentFn.ts'; -export { vertexFn } from './core/function/tgpuVertexFn.ts'; -export { unroll } from './core/unroll/tgpuUnroll.ts'; +import { constant } from './core/constant/tgpuConstant.ts'; +import { fn } from './core/function/tgpuFn.ts'; +import { comptime } from './core/function/comptime.ts'; +import { resolve, resolveWithContext } from './core/resolve/tgpuResolve.ts'; +import { init, initFromDevice } from './core/root/init.ts'; +import { slot } from './core/slot/slot.ts'; +import { lazy } from './core/slot/lazy.ts'; +import { accessor, mutableAccessor } from './core/slot/accessor.ts'; +import { privateVar, workgroupVar } from './core/variable/tgpuVariable.ts'; +import { vertexLayout } from './core/vertexLayout/vertexLayout.ts'; +import { bindGroupLayout } from './tgpuBindGroupLayout.ts'; +import { computeFn } from './core/function/tgpuComputeFn.ts'; +import { fragmentFn } from './core/function/tgpuFragmentFn.ts'; +import { vertexFn } from './core/function/tgpuVertexFn.ts'; +import { unroll } from './core/unroll/tgpuUnroll.ts'; +import * as unstable from './tgpuUnstable.ts'; -export * as '~unstable' from './tgpuUnstable.ts'; +export const tgpu: { + const: typeof constant; + fn: typeof fn; + comptime: typeof comptime; + resolve: typeof resolve; + resolveWithContext: typeof resolveWithContext; + init: typeof init; + initFromDevice: typeof initFromDevice; + slot: typeof slot; + lazy: typeof lazy; + accessor: typeof accessor; + mutableAccessor: typeof mutableAccessor; + privateVar: typeof privateVar; + workgroupVar: typeof workgroupVar; + vertexLayout: typeof vertexLayout; + bindGroupLayout: typeof bindGroupLayout; + computeFn: typeof computeFn; + fragmentFn: typeof fragmentFn; + vertexFn: typeof vertexFn; + unroll: typeof unroll; + '~unstable': typeof unstable; +} = { + const: constant, + fn, + comptime, + resolve, + resolveWithContext, + init, + initFromDevice, + slot, + lazy, + accessor, + mutableAccessor, + privateVar, + workgroupVar, + vertexLayout, + bindGroupLayout, + computeFn, + fragmentFn, + vertexFn, + unroll, + '~unstable': unstable, +}; diff --git a/packages/typegpu/tests/accessor.test.ts b/packages/typegpu/tests/accessor.test.ts index 12c83520da..44974640e5 100644 --- a/packages/typegpu/tests/accessor.test.ts +++ b/packages/typegpu/tests/accessor.test.ts @@ -1,5 +1,5 @@ import { describe, expect, expectTypeOf } from 'vitest'; -import tgpu, { d, std, type TgpuAccessor } from '../src/index.js'; +import { tgpu, d, std, type TgpuAccessor } from '../src/index.js'; import { it } from 'typegpu-testing-utility'; const RED = d.vec3f(1, 0, 0); diff --git a/packages/typegpu/tests/entryFnBuiltinArgs.test.ts b/packages/typegpu/tests/entryFnBuiltinArgs.test.ts index d064eb9148..2db921b42d 100644 --- a/packages/typegpu/tests/entryFnBuiltinArgs.test.ts +++ b/packages/typegpu/tests/entryFnBuiltinArgs.test.ts @@ -1,6 +1,6 @@ import { describe, it } from 'vitest'; import * as d from '../src/data/index.ts'; -import tgpu, { type TgpuComputeFn, type TgpuFragmentFn, type TgpuVertexFn } from '../src/index.js'; +import { tgpu, type TgpuComputeFn, type TgpuFragmentFn, type TgpuVertexFn } from '../src/index.js'; import { attest } from '@ark/attest'; describe('entry functions accepting only the allowed subset of builtins', () => { diff --git a/packages/typegpu/tests/entryFnHeaderGen.test.ts b/packages/typegpu/tests/entryFnHeaderGen.test.ts index a0b9abfa69..fb3385b7a1 100644 --- a/packages/typegpu/tests/entryFnHeaderGen.test.ts +++ b/packages/typegpu/tests/entryFnHeaderGen.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; import * as d from '../src/data/index.ts'; -import tgpu from '../src/index.js'; +import { tgpu } from '../src/index.js'; describe('autogenerating wgsl headers for tgpu entry functions with raw string WGSL implementations', () => { it('works for fragment entry function with non-decorated non-struct output', () => { diff --git a/packages/typegpu/tests/function.test.ts b/packages/typegpu/tests/function.test.ts index e9ae56ecc6..c4b93125f3 100644 --- a/packages/typegpu/tests/function.test.ts +++ b/packages/typegpu/tests/function.test.ts @@ -3,7 +3,7 @@ import { describe, expect, expectTypeOf, it } from 'vitest'; import type { InferIO, InheritArgNames, IOLayout } from '../src/core/function/fnTypes.ts'; import * as d from '../src/data/index.ts'; import { Void } from '../src/data/wgslTypes.ts'; -import tgpu, { type TgpuFn, type TgpuFnShell } from '../src/index.js'; +import { tgpu, type TgpuFn, type TgpuFnShell } from '../src/index.js'; import type { Prettify } from '../src/shared/utilityTypes.ts'; const empty = tgpu.fn([])`() { diff --git a/packages/typegpu/tests/functionTagged.test.ts b/packages/typegpu/tests/functionTagged.test.ts index 6d86b8c85d..db8ffcceaa 100644 --- a/packages/typegpu/tests/functionTagged.test.ts +++ b/packages/typegpu/tests/functionTagged.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; import * as d from '../src/data/index.ts'; -import tgpu from '../src/index.js'; +import { tgpu } from '../src/index.js'; describe('tagged syntax', () => { describe('function', () => { diff --git a/packages/typegpu/tests/gpuValueOf.test.ts b/packages/typegpu/tests/gpuValueOf.test.ts index 9c4a87abc3..592fca621a 100644 --- a/packages/typegpu/tests/gpuValueOf.test.ts +++ b/packages/typegpu/tests/gpuValueOf.test.ts @@ -1,6 +1,6 @@ import { describe, expectTypeOf } from 'vitest'; import * as d from '../src/data/index.ts'; -import tgpu from '../src/index.js'; +import { tgpu } from '../src/index.js'; import type { GPUValueOf } from '../src/shared/repr.ts'; import { it } from 'typegpu-testing-utility'; diff --git a/packages/typegpu/tests/indent.test.ts b/packages/typegpu/tests/indent.test.ts index 2261eda3b4..b34860e961 100644 --- a/packages/typegpu/tests/indent.test.ts +++ b/packages/typegpu/tests/indent.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import tgpu, { d, std } from '../src/index.js'; +import { tgpu, d, std } from '../src/index.js'; describe('indents', () => { it('should indent sanely', () => { diff --git a/packages/typegpu/tests/internal/dualImpl.test.ts b/packages/typegpu/tests/internal/dualImpl.test.ts index 078b384868..e141a2738f 100644 --- a/packages/typegpu/tests/internal/dualImpl.test.ts +++ b/packages/typegpu/tests/internal/dualImpl.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it } from 'vitest'; import { dualImpl, MissingCpuImplError } from '../../src/core/function/dualImpl.ts'; import { getName } from '../../src/shared/meta.ts'; -import tgpu, { d } from '../../src/index.js'; +import { tgpu, d } from '../../src/index.js'; describe('dualImpl', () => { it('names functions created by dualImpl', () => { diff --git a/packages/typegpu/tests/internal/tseynit.test.ts b/packages/typegpu/tests/internal/tseynit.test.ts index 873864f408..8fe16839e9 100644 --- a/packages/typegpu/tests/internal/tseynit.test.ts +++ b/packages/typegpu/tests/internal/tseynit.test.ts @@ -2,7 +2,7 @@ import { describe, expect, it } from 'vitest'; import * as tinyest from 'tinyest'; import { getFunctionMetadata } from '../../src/shared/meta.ts'; import { stringifyNode } from '../../src/shared/tseynit.ts'; -import tgpu, { d } from '../../src/index.js'; +import { tgpu, d } from '../../src/index.js'; function getBodyAst(fn: () => void) { const meta = getFunctionMetadata(fn); diff --git a/packages/typegpu/tests/invariant.test.ts b/packages/typegpu/tests/invariant.test.ts index 2a83ef94dc..1d64e1f999 100644 --- a/packages/typegpu/tests/invariant.test.ts +++ b/packages/typegpu/tests/invariant.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import tgpu, { d } from '../src/index.js'; +import { tgpu, d } from '../src/index.js'; describe('invariant', () => { it('adds @invariant attribute to position builtin', () => { diff --git a/packages/typegpu/tests/jsMath.test.ts b/packages/typegpu/tests/jsMath.test.ts index 54297965f9..4f1c6fa9b1 100644 --- a/packages/typegpu/tests/jsMath.test.ts +++ b/packages/typegpu/tests/jsMath.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import tgpu, { d } from '../src/index.js'; +import { tgpu, d } from '../src/index.js'; describe('Math', () => { it('allows using Math.PI', () => { diff --git a/packages/typegpu/tests/lazy.test.ts b/packages/typegpu/tests/lazy.test.ts index 5f06e809d3..10c4b8bd89 100644 --- a/packages/typegpu/tests/lazy.test.ts +++ b/packages/typegpu/tests/lazy.test.ts @@ -1,6 +1,6 @@ import { describe, expect, expectTypeOf, vi } from 'vitest'; import * as d from '../src/data/index.ts'; -import tgpu, { type TgpuLazy } from '../src/index.js'; +import { tgpu, type TgpuLazy } from '../src/index.js'; import { mul } from '../src/std/index.ts'; import { it } from 'typegpu-testing-utility'; diff --git a/packages/typegpu/tests/limitsOverflow.test.ts b/packages/typegpu/tests/limitsOverflow.test.ts index f0630e8ee5..937fa3beb5 100644 --- a/packages/typegpu/tests/limitsOverflow.test.ts +++ b/packages/typegpu/tests/limitsOverflow.test.ts @@ -1,6 +1,6 @@ import { describe, expect, vi } from 'vitest'; import { it } from 'typegpu-testing-utility'; -import tgpu, { d } from '../src/index.js'; +import { tgpu, d } from '../src/index.js'; import { warnIfOverflow } from '../src/core/pipeline/limitsOverflow.ts'; describe('warnIfOverflow', () => { diff --git a/packages/typegpu/tests/matrix.test.ts b/packages/typegpu/tests/matrix.test.ts index 989f6f4c8f..c17960775c 100644 --- a/packages/typegpu/tests/matrix.test.ts +++ b/packages/typegpu/tests/matrix.test.ts @@ -1,6 +1,6 @@ import { BufferReader, BufferWriter } from 'typed-binary'; import { describe, expect, expectTypeOf, it } from 'vitest'; -import tgpu, { d } from '../src/index.js'; +import { tgpu, d } from '../src/index.js'; import { readData, writeData } from '../src/data/dataIO.ts'; import { isCloseTo } from '../src/std/index.ts'; diff --git a/packages/typegpu/tests/mutabilityTracking.test.ts b/packages/typegpu/tests/mutabilityTracking.test.ts index 053861b6d5..2f8943d859 100644 --- a/packages/typegpu/tests/mutabilityTracking.test.ts +++ b/packages/typegpu/tests/mutabilityTracking.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import tgpu, { d, std } from '../src/index.js'; +import { tgpu, d, std } from '../src/index.js'; const fnShell = tgpu.fn([d.vec4u], d.u32); diff --git a/packages/typegpu/tests/namespace.test.ts b/packages/typegpu/tests/namespace.test.ts index 7ac6407b43..5b63b82e7f 100644 --- a/packages/typegpu/tests/namespace.test.ts +++ b/packages/typegpu/tests/namespace.test.ts @@ -1,5 +1,5 @@ import { describe, expect } from 'vitest'; -import tgpu, { d } from '../src/index.js'; +import { tgpu, d } from '../src/index.js'; import { it } from 'typegpu-testing-utility'; describe('tgpu.namespace', () => { diff --git a/packages/typegpu/tests/numeric.test.ts b/packages/typegpu/tests/numeric.test.ts index 54137cd623..7c470b7605 100644 --- a/packages/typegpu/tests/numeric.test.ts +++ b/packages/typegpu/tests/numeric.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import tgpu, { d } from '../src/index.js'; +import { tgpu, d } from '../src/index.js'; describe('f32', () => { it('differs in type from other numeric schemas', () => { diff --git a/packages/typegpu/tests/pipeline-resolution.test.ts b/packages/typegpu/tests/pipeline-resolution.test.ts index 5bbf9618ca..2504749b50 100644 --- a/packages/typegpu/tests/pipeline-resolution.test.ts +++ b/packages/typegpu/tests/pipeline-resolution.test.ts @@ -1,5 +1,5 @@ import { describe, expect } from 'vitest'; -import tgpu, { d } from '../src/index.js'; +import { tgpu, d } from '../src/index.js'; import { it } from 'typegpu-testing-utility'; describe('resolve', () => { diff --git a/packages/typegpu/tests/rawFn.test.ts b/packages/typegpu/tests/rawFn.test.ts index b63036de3b..9d04560213 100644 --- a/packages/typegpu/tests/rawFn.test.ts +++ b/packages/typegpu/tests/rawFn.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import tgpu, { d } from '../src/index.js'; +import { tgpu, d } from '../src/index.js'; import { getName } from '../src/shared/meta.ts'; describe('tgpu.fn with raw string WGSL implementation', () => { diff --git a/packages/typegpu/tests/ref.test.ts b/packages/typegpu/tests/ref.test.ts index f6594ac34e..8f2c075db5 100644 --- a/packages/typegpu/tests/ref.test.ts +++ b/packages/typegpu/tests/ref.test.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from '../src/index.js'; +import { tgpu, d } from '../src/index.js'; import { describe, expect } from 'vitest'; import { it } from 'typegpu-testing-utility'; diff --git a/packages/typegpu/tests/renderPipeline.test.ts b/packages/typegpu/tests/renderPipeline.test.ts index 8c10b79f5b..e7d5ac4ce6 100644 --- a/packages/typegpu/tests/renderPipeline.test.ts +++ b/packages/typegpu/tests/renderPipeline.test.ts @@ -2,7 +2,8 @@ import { describe, expect, expectTypeOf, vi } from 'vitest'; import { matchUpVaryingLocations } from '../src/core/pipeline/renderPipeline.ts'; import type { ExperimentalTgpuRoot } from '../src/core/root/rootTypes.ts'; import type { TgpuQuerySet } from '../src/core/querySet/querySet.ts'; -import tgpu, { +import { + tgpu, common, d, MissingBindGroupsError, diff --git a/packages/typegpu/tests/resolve.test.ts b/packages/typegpu/tests/resolve.test.ts index 83e8e1e787..ab19a228d9 100644 --- a/packages/typegpu/tests/resolve.test.ts +++ b/packages/typegpu/tests/resolve.test.ts @@ -1,5 +1,5 @@ import { describe, expect, vi } from 'vitest'; -import tgpu, { d } from '../src/index.js'; +import { tgpu, d } from '../src/index.js'; import { getName, setName } from '../src/shared/meta.ts'; import { $gpuValueOf, $internal, $ownSnippet, $resolve } from '../src/shared/symbols.ts'; import type { ResolutionCtx } from '../src/types.ts'; diff --git a/packages/typegpu/tests/root.test.ts b/packages/typegpu/tests/root.test.ts index 525e9a0007..ff404fd990 100644 --- a/packages/typegpu/tests/root.test.ts +++ b/packages/typegpu/tests/root.test.ts @@ -1,6 +1,6 @@ import { describe, expect, vi } from 'vitest'; import { Void } from '../src/data/wgslTypes.ts'; -import tgpu, { d } from '../src/index.js'; +import { tgpu, d } from '../src/index.js'; import { it } from 'typegpu-testing-utility'; describe('TgpuRoot', () => { diff --git a/packages/typegpu/tests/simulate.test.ts b/packages/typegpu/tests/simulate.test.ts index b3310f1f71..3a9d46a386 100644 --- a/packages/typegpu/tests/simulate.test.ts +++ b/packages/typegpu/tests/simulate.test.ts @@ -1,5 +1,5 @@ import { describe, expect } from 'vitest'; -import tgpu, { d } from '../src/index.js'; +import { tgpu, d } from '../src/index.js'; import { it } from 'typegpu-testing-utility'; describe('tgpu.simulate()', () => { diff --git a/packages/typegpu/tests/slot.test.ts b/packages/typegpu/tests/slot.test.ts index 8e6d38fb76..60c263ad3c 100644 --- a/packages/typegpu/tests/slot.test.ts +++ b/packages/typegpu/tests/slot.test.ts @@ -1,5 +1,5 @@ import { describe, expect } from 'vitest'; -import tgpu, { d, std } from '../src/index.js'; +import { tgpu, d, std } from '../src/index.js'; import { it } from 'typegpu-testing-utility'; import { getName } from '../src/shared/meta.ts'; diff --git a/packages/typegpu/tests/std/bitcast.test.ts b/packages/typegpu/tests/std/bitcast.test.ts index 949344fdf1..80c319dbe5 100644 --- a/packages/typegpu/tests/std/bitcast.test.ts +++ b/packages/typegpu/tests/std/bitcast.test.ts @@ -10,7 +10,7 @@ import { vec4i, vec4u, } from '../../src/data/vector.ts'; -import tgpu, { d, std } from '../../src/index.js'; +import { tgpu, d, std } from '../../src/index.js'; describe('bitcast', () => { it('bitcastU32toF32', () => { diff --git a/packages/typegpu/tests/std/boolean/not.test.ts b/packages/typegpu/tests/std/boolean/not.test.ts index 6e479d7963..4e7c0ff4de 100644 --- a/packages/typegpu/tests/std/boolean/not.test.ts +++ b/packages/typegpu/tests/std/boolean/not.test.ts @@ -1,7 +1,7 @@ import { describe, expect } from 'vitest'; import { it } from 'typegpu-testing-utility'; import { not } from '../../../src/std/boolean.ts'; -import tgpu, { d, std } from '../../../src/index.js'; +import { tgpu, d, std } from '../../../src/index.js'; describe('not', () => { it('negates booleans', () => { diff --git a/packages/typegpu/tests/std/boolean/select.test.ts b/packages/typegpu/tests/std/boolean/select.test.ts index 3c1bdc908a..840e6e39a7 100644 --- a/packages/typegpu/tests/std/boolean/select.test.ts +++ b/packages/typegpu/tests/std/boolean/select.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import tgpu, { d } from '../../../src/index.js'; +import { tgpu, d } from '../../../src/index.js'; import { vec2b, vec2f, diff --git a/packages/typegpu/tests/std/copy.test.ts b/packages/typegpu/tests/std/copy.test.ts index c8204407fd..e6d0ffb1ca 100644 --- a/packages/typegpu/tests/std/copy.test.ts +++ b/packages/typegpu/tests/std/copy.test.ts @@ -1,6 +1,6 @@ import { it } from 'typegpu-testing-utility'; import { describe, expect } from 'vitest'; -import tgpu, { d, std } from '../../src/index.js'; +import { tgpu, d, std } from '../../src/index.js'; describe('std.copy', () => { describe('on the CPU', () => { diff --git a/packages/typegpu/tests/std/environment.test.ts b/packages/typegpu/tests/std/environment.test.ts index 4818237d22..d47c26a4cd 100644 --- a/packages/typegpu/tests/std/environment.test.ts +++ b/packages/typegpu/tests/std/environment.test.ts @@ -1,7 +1,7 @@ import { it } from 'typegpu-testing-utility'; import { expect, describe } from 'vitest'; -import tgpu, { d, std } from 'typegpu'; +import { tgpu, d, std } from 'typegpu'; describe('isBeingTranspiled', () => { it('returns false top level', () => { diff --git a/packages/typegpu/tests/std/matrix/rotate.test.ts b/packages/typegpu/tests/std/matrix/rotate.test.ts index 2b6642afc4..c211b1d284 100644 --- a/packages/typegpu/tests/std/matrix/rotate.test.ts +++ b/packages/typegpu/tests/std/matrix/rotate.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; import { mat4x4f, vec4f } from '../../../src/data/index.ts'; -import tgpu from '../../../src/index.js'; +import { tgpu } from '../../../src/index.js'; import { isCloseTo, mul } from '../../../src/std/index.ts'; import { rotateX4, rotateY4, rotateZ4 } from '../../../src/std/matrix.ts'; diff --git a/packages/typegpu/tests/std/matrix/scale.test.ts b/packages/typegpu/tests/std/matrix/scale.test.ts index 706085a81f..bc7bd2371d 100644 --- a/packages/typegpu/tests/std/matrix/scale.test.ts +++ b/packages/typegpu/tests/std/matrix/scale.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; import { mat4x4f, vec3f, vec4f } from '../../../src/data/index.ts'; -import tgpu from '../../../src/index.js'; +import { tgpu } from '../../../src/index.js'; import { isCloseTo, mul, scale4, translate4 } from '../../../src/std/index.ts'; describe('scale', () => { diff --git a/packages/typegpu/tests/std/matrix/translate.test.ts b/packages/typegpu/tests/std/matrix/translate.test.ts index bf46e6565a..a8c7ef87e6 100644 --- a/packages/typegpu/tests/std/matrix/translate.test.ts +++ b/packages/typegpu/tests/std/matrix/translate.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; import { mat4x4f, vec3f, vec4f } from '../../../src/data/index.ts'; -import tgpu from '../../../src/index.js'; +import { tgpu } from '../../../src/index.js'; import { isCloseTo, mul, scale4, translate4 } from '../../../src/std/index.ts'; describe('translate', () => { diff --git a/packages/typegpu/tests/std/numeric/bitShift.test.ts b/packages/typegpu/tests/std/numeric/bitShift.test.ts index aecfb3cecf..88eeafa08b 100644 --- a/packages/typegpu/tests/std/numeric/bitShift.test.ts +++ b/packages/typegpu/tests/std/numeric/bitShift.test.ts @@ -1,7 +1,7 @@ import { describe, expect, it, vi } from 'vitest'; import { u32, i32, vec3f, vec3i, vec3u, f32, vec2u } from '../../../src/data/index.ts'; import { bitShiftLeft, bitShiftRight } from '../../../src/std/index.ts'; -import tgpu from '../../../src/index.js'; +import { tgpu } from '../../../src/index.js'; describe('bit shift', () => { it('casts rhs to u32', () => { diff --git a/packages/typegpu/tests/std/numeric/div.test.ts b/packages/typegpu/tests/std/numeric/div.test.ts index 498bde3937..619438f4b1 100644 --- a/packages/typegpu/tests/std/numeric/div.test.ts +++ b/packages/typegpu/tests/std/numeric/div.test.ts @@ -1,5 +1,5 @@ import { describe, expect, expectTypeOf, it } from 'vitest'; -import tgpu, { d } from '../../../src/index.js'; +import { tgpu, d } from '../../../src/index.js'; import { div, isCloseTo } from '../../../src/std/index.ts'; describe('div', () => { diff --git a/packages/typegpu/tests/std/numeric/max.test.ts b/packages/typegpu/tests/std/numeric/max.test.ts index 40eee2dfd1..f038029ab8 100644 --- a/packages/typegpu/tests/std/numeric/max.test.ts +++ b/packages/typegpu/tests/std/numeric/max.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import tgpu, { d, std } from '../../../src/index.js'; +import { tgpu, d, std } from '../../../src/index.js'; describe('max', () => { it('acts as identity when called with one argument', () => { diff --git a/packages/typegpu/tests/std/numeric/min.test.ts b/packages/typegpu/tests/std/numeric/min.test.ts index ac3fa8da8a..4fb2738759 100644 --- a/packages/typegpu/tests/std/numeric/min.test.ts +++ b/packages/typegpu/tests/std/numeric/min.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import tgpu, { d, std } from '../../../src/index.js'; +import { tgpu, d, std } from '../../../src/index.js'; describe('min', () => { it('acts as identity when called with one argument', () => { diff --git a/packages/typegpu/tests/std/numeric/mod.test.ts b/packages/typegpu/tests/std/numeric/mod.test.ts index 7f04ef2077..3aa67f5ccb 100644 --- a/packages/typegpu/tests/std/numeric/mod.test.ts +++ b/packages/typegpu/tests/std/numeric/mod.test.ts @@ -28,7 +28,7 @@ import type { v4u, } from '../../../src/data/wgslTypes.ts'; import { isCloseTo, mod } from '../../../src/std/index.ts'; -import tgpu, { d } from '../../../src/index.js'; +import { tgpu, d } from '../../../src/index.js'; describe('mod', () => { it('computes modulo of a number and a number', () => { diff --git a/packages/typegpu/tests/std/numeric/mul.test.ts b/packages/typegpu/tests/std/numeric/mul.test.ts index 1b66472427..179c7f7aa3 100644 --- a/packages/typegpu/tests/std/numeric/mul.test.ts +++ b/packages/typegpu/tests/std/numeric/mul.test.ts @@ -1,5 +1,5 @@ import { describe, expect, expectTypeOf, it } from 'vitest'; -import tgpu, { d } from '../../../src/index.js'; +import { tgpu, d } from '../../../src/index.js'; import { mat2x2f, mat3x3f, diff --git a/packages/typegpu/tests/std/numeric/round.test.ts b/packages/typegpu/tests/std/numeric/round.test.ts index 119f4762ec..0fe5edc353 100644 --- a/packages/typegpu/tests/std/numeric/round.test.ts +++ b/packages/typegpu/tests/std/numeric/round.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import tgpu, { d, std } from '../../../src/index.js'; +import { tgpu, d, std } from '../../../src/index.js'; describe('round', () => { it('rounds to even numbers', () => { diff --git a/packages/typegpu/tests/std/range.test.ts b/packages/typegpu/tests/std/range.test.ts index 8e0c8a95f1..7550d880a0 100644 --- a/packages/typegpu/tests/std/range.test.ts +++ b/packages/typegpu/tests/std/range.test.ts @@ -1,7 +1,7 @@ import { test } from 'typegpu-testing-utility'; import { describe, expect } from 'vitest'; import { d, std } from '../../src/index.js'; -import tgpu from '../../src/index.js'; +import { tgpu } from '../../src/index.js'; // range(n) — single argument, generates [0, n) test('std.range - single arg', () => { diff --git a/packages/typegpu/tests/std/texture/textureGather.test.ts b/packages/typegpu/tests/std/texture/textureGather.test.ts index d341c1f105..0ee9094d03 100644 --- a/packages/typegpu/tests/std/texture/textureGather.test.ts +++ b/packages/typegpu/tests/std/texture/textureGather.test.ts @@ -1,7 +1,7 @@ import { describe, expect, expectTypeOf } from 'vitest'; import { it } from 'typegpu-testing-utility'; import { textureGather } from '../../../src/std/texture.ts'; -import tgpu from '../../../src/index.js'; +import { tgpu } from '../../../src/index.js'; import * as d from '../../../src/data/index.ts'; import { bindGroupLayout } from '../../../src/tgpuBindGroupLayout.ts'; import { resolve } from '../../../src/core/resolve/tgpuResolve.ts'; diff --git a/packages/typegpu/tests/std/texture/textureLoad.test.ts b/packages/typegpu/tests/std/texture/textureLoad.test.ts index af44f4b706..84eb63bb42 100644 --- a/packages/typegpu/tests/std/texture/textureLoad.test.ts +++ b/packages/typegpu/tests/std/texture/textureLoad.test.ts @@ -1,7 +1,7 @@ import { describe, expect, expectTypeOf } from 'vitest'; import { it } from 'typegpu-testing-utility'; import { textureLoad } from '../../../src/std/texture.ts'; -import tgpu from '../../../src/index.js'; +import { tgpu } from '../../../src/index.js'; import * as d from '../../../src/data/index.ts'; import { bindGroupLayout } from '../../../src/tgpuBindGroupLayout.ts'; import { resolve } from '../../../src/core/resolve/tgpuResolve.ts'; diff --git a/packages/typegpu/tests/struct.test.ts b/packages/typegpu/tests/struct.test.ts index fedd2c4594..8e8ce13cb7 100644 --- a/packages/typegpu/tests/struct.test.ts +++ b/packages/typegpu/tests/struct.test.ts @@ -18,7 +18,7 @@ import { vec3h, vec3u, } from '../src/data/index.ts'; -import tgpu from '../src/index.js'; +import { tgpu } from '../src/index.js'; import * as d from '../src/data/index.ts'; import type { Infer } from '../src/shared/repr.ts'; import { frexp } from '../src/std/numeric.ts'; diff --git a/packages/typegpu/tests/swizzleMixedValidation.test.ts b/packages/typegpu/tests/swizzleMixedValidation.test.ts index e615ff3e48..aca0ca4741 100644 --- a/packages/typegpu/tests/swizzleMixedValidation.test.ts +++ b/packages/typegpu/tests/swizzleMixedValidation.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import tgpu, { d } from '../src/index.js'; +import { tgpu, d } from '../src/index.js'; describe('Mixed swizzle validation', () => { describe('JS validation', () => { diff --git a/packages/typegpu/tests/texture.test.ts b/packages/typegpu/tests/texture.test.ts index 450537c8f5..f2588ca821 100644 --- a/packages/typegpu/tests/texture.test.ts +++ b/packages/typegpu/tests/texture.test.ts @@ -5,7 +5,7 @@ import type { ExperimentalTgpuRoot } from '../src/core/root/rootTypes.ts'; import { it } from 'typegpu-testing-utility'; import * as d from '../src/data/index.ts'; import { attest } from '@ark/attest'; -import tgpu from '../src/index.js'; +import { tgpu } from '../src/index.js'; import { getName } from '../src/shared/meta.ts'; describe('TgpuTexture', () => { diff --git a/packages/typegpu/tests/tgpuGenericFn.test.ts b/packages/typegpu/tests/tgpuGenericFn.test.ts index fd136ced01..c45c0b7f56 100644 --- a/packages/typegpu/tests/tgpuGenericFn.test.ts +++ b/packages/typegpu/tests/tgpuGenericFn.test.ts @@ -1,6 +1,6 @@ import { describe, expect } from 'vitest'; import * as d from '../src/data/index.ts'; -import tgpu, { std } from '../src/index.js'; +import { tgpu, std } from '../src/index.js'; import { it } from 'typegpu-testing-utility'; describe('TgpuGenericFn - shellless callback wrapper', () => { diff --git a/packages/typegpu/tests/tgsl/argumentOrigin.test.ts b/packages/typegpu/tests/tgsl/argumentOrigin.test.ts index 3297717b24..4f1e9297d2 100644 --- a/packages/typegpu/tests/tgsl/argumentOrigin.test.ts +++ b/packages/typegpu/tests/tgsl/argumentOrigin.test.ts @@ -1,6 +1,6 @@ import { describe, expect } from 'vitest'; import { it } from 'typegpu-testing-utility'; -import tgpu, { d } from '../../src/index.js'; +import { tgpu, d } from '../../src/index.js'; describe('function argument origin tracking', () => { it('should fail on mutation of primitive arguments', () => { diff --git a/packages/typegpu/tests/tgsl/assignment.test.ts b/packages/typegpu/tests/tgsl/assignment.test.ts index dc8961413d..4552ad625d 100644 --- a/packages/typegpu/tests/tgsl/assignment.test.ts +++ b/packages/typegpu/tests/tgsl/assignment.test.ts @@ -1,6 +1,6 @@ import { beforeEach, expect, type MockInstance, vi } from 'vitest'; import { it } from 'typegpu-testing-utility'; -import tgpu, { d } from '../../src/index.js'; +import { tgpu, d } from '../../src/index.js'; let warnSpy: MockInstance; diff --git a/packages/typegpu/tests/tgsl/codeGen.test.ts b/packages/typegpu/tests/tgsl/codeGen.test.ts index b5db914b79..c59e1baab4 100644 --- a/packages/typegpu/tests/tgsl/codeGen.test.ts +++ b/packages/typegpu/tests/tgsl/codeGen.test.ts @@ -1,7 +1,7 @@ import { describe, expect } from 'vitest'; import { it } from 'typegpu-testing-utility'; -import tgpu, { d } from '../../src/index.js'; +import { tgpu, d } from '../../src/index.js'; describe('codeGen', () => { describe('vectors', () => { diff --git a/packages/typegpu/tests/tgsl/comptime.test.ts b/packages/typegpu/tests/tgsl/comptime.test.ts index f4fc57f42c..e4294dec33 100644 --- a/packages/typegpu/tests/tgsl/comptime.test.ts +++ b/packages/typegpu/tests/tgsl/comptime.test.ts @@ -1,6 +1,6 @@ import { describe, expect } from 'vitest'; import { it } from 'typegpu-testing-utility'; -import tgpu, { d } from '../../src/index.js'; +import { tgpu, d } from '../../src/index.js'; describe('comptime', () => { it('should work in JS', () => { diff --git a/packages/typegpu/tests/tgsl/consoleLog.test.ts b/packages/typegpu/tests/tgsl/consoleLog.test.ts index 997b15d46f..81801a9410 100644 --- a/packages/typegpu/tests/tgsl/consoleLog.test.ts +++ b/packages/typegpu/tests/tgsl/consoleLog.test.ts @@ -1,6 +1,6 @@ import { describe, expect, vi } from 'vitest'; import { it } from 'typegpu-testing-utility'; -import tgpu, { d } from '../../src/index.js'; +import { tgpu, d } from '../../src/index.js'; describe('wgslGenerator with console.log', () => { it('Parses console.log in a stray function to a comment and warns', () => { diff --git a/packages/typegpu/tests/tgsl/conversion.test.ts b/packages/typegpu/tests/tgsl/conversion.test.ts index d1d6ab5ef4..2daa37ddf7 100644 --- a/packages/typegpu/tests/tgsl/conversion.test.ts +++ b/packages/typegpu/tests/tgsl/conversion.test.ts @@ -1,7 +1,7 @@ import { describe, expect, vi } from 'vitest'; import { it } from 'typegpu-testing-utility'; import { expectDataTypeOf } from '../utils/parseResolved.ts'; -import tgpu, { d } from '../../src/index.js'; +import { tgpu, d } from '../../src/index.js'; describe('convertToCommonType', () => { it('converts identical types', () => { diff --git a/packages/typegpu/tests/tgsl/entryFnParamPruning.test.ts b/packages/typegpu/tests/tgsl/entryFnParamPruning.test.ts index b60274fede..1573449fb9 100644 --- a/packages/typegpu/tests/tgsl/entryFnParamPruning.test.ts +++ b/packages/typegpu/tests/tgsl/entryFnParamPruning.test.ts @@ -1,7 +1,7 @@ import { describe, expect } from 'vitest'; import { it } from 'typegpu-testing-utility'; -import tgpu, { d, std } from '../../src/index.js'; +import { tgpu, d, std } from '../../src/index.js'; const layout = tgpu.bindGroupLayout({ output: { storage: d.arrayOf(d.f32), access: 'mutable' }, diff --git a/packages/typegpu/tests/tgsl/extensionEnabled.test.ts b/packages/typegpu/tests/tgsl/extensionEnabled.test.ts index 58150fbee5..57d5c26e34 100644 --- a/packages/typegpu/tests/tgsl/extensionEnabled.test.ts +++ b/packages/typegpu/tests/tgsl/extensionEnabled.test.ts @@ -1,7 +1,7 @@ import { describe, expect } from 'vitest'; import { it } from 'typegpu-testing-utility'; -import tgpu, { d, std } from '../../src/index.js'; +import { tgpu, d, std } from '../../src/index.js'; describe('extension based pruning', () => { it('should include extension code when the feature is used', () => { diff --git a/packages/typegpu/tests/tgsl/infixOperators.test.ts b/packages/typegpu/tests/tgsl/infixOperators.test.ts index aa7fcdea6c..f5cc4e9a04 100644 --- a/packages/typegpu/tests/tgsl/infixOperators.test.ts +++ b/packages/typegpu/tests/tgsl/infixOperators.test.ts @@ -1,5 +1,5 @@ import { describe, expect } from 'vitest'; -import tgpu, { d } from '../../src/index.js'; +import { tgpu, d } from '../../src/index.js'; import { it } from 'typegpu-testing-utility'; describe('wgslGenerator', () => { diff --git a/packages/typegpu/tests/tgsl/letDeclaration.test.ts b/packages/typegpu/tests/tgsl/letDeclaration.test.ts index ae0b822676..ed88e09832 100644 --- a/packages/typegpu/tests/tgsl/letDeclaration.test.ts +++ b/packages/typegpu/tests/tgsl/letDeclaration.test.ts @@ -1,6 +1,6 @@ import { it } from 'typegpu-testing-utility'; import { describe, expect } from 'vitest'; -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { expectSnippetOf } from '../utils/parseResolved.ts'; describe('let declarations', () => { diff --git a/packages/typegpu/tests/tgsl/memberAccess.test.ts b/packages/typegpu/tests/tgsl/memberAccess.test.ts index 77c1e294bd..89c9795d7c 100644 --- a/packages/typegpu/tests/tgsl/memberAccess.test.ts +++ b/packages/typegpu/tests/tgsl/memberAccess.test.ts @@ -1,7 +1,7 @@ import { describe } from 'vitest'; import { it } from 'typegpu-testing-utility'; import { expectSnippetOf } from '../utils/parseResolved.ts'; -import tgpu, { d } from '../../src/index.js'; +import { tgpu, d } from '../../src/index.js'; describe('Member Access', () => { const Boid = d.struct({ diff --git a/packages/typegpu/tests/tgsl/multiplication.test.ts b/packages/typegpu/tests/tgsl/multiplication.test.ts index 5f0c0ad22f..67b618e9d4 100644 --- a/packages/typegpu/tests/tgsl/multiplication.test.ts +++ b/packages/typegpu/tests/tgsl/multiplication.test.ts @@ -2,7 +2,7 @@ import { test } from 'typegpu-testing-utility'; import { expect, vi } from 'vitest'; import { expectSnippetOf } from '../utils/parseResolved.ts'; -import tgpu, { d } from '../../src/index.js'; +import { tgpu, d } from '../../src/index.js'; test('multiplying i32 with a float literal should implicitly convert to an f32', () => { using consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}); diff --git a/packages/typegpu/tests/tgsl/nameClashes.test.ts b/packages/typegpu/tests/tgsl/nameClashes.test.ts index 586e8e3bf1..f33d725a4e 100644 --- a/packages/typegpu/tests/tgsl/nameClashes.test.ts +++ b/packages/typegpu/tests/tgsl/nameClashes.test.ts @@ -1,5 +1,5 @@ import { expect } from 'vitest'; -import tgpu, { d, std } from '../../src/index.js'; +import { tgpu, d, std } from '../../src/index.js'; import { test } from 'typegpu-testing-utility'; test('should differentiate parameter names from existing declarations', () => { diff --git a/packages/typegpu/tests/tgsl/rawCodeSnippet.test.ts b/packages/typegpu/tests/tgsl/rawCodeSnippet.test.ts index b0dcd5f70b..6eabcbb0d5 100644 --- a/packages/typegpu/tests/tgsl/rawCodeSnippet.test.ts +++ b/packages/typegpu/tests/tgsl/rawCodeSnippet.test.ts @@ -1,6 +1,6 @@ import { describe, expect, expectTypeOf } from 'vitest'; import { it } from 'typegpu-testing-utility'; -import tgpu, { d } from '../../src/index.js'; +import { tgpu, d } from '../../src/index.js'; describe('rawCodeSnippet', () => { it('should throw a descriptive error when called in JS', () => { diff --git a/packages/typegpu/tests/tgsl/shellless.test.ts b/packages/typegpu/tests/tgsl/shellless.test.ts index dffa03992f..65a14096cc 100644 --- a/packages/typegpu/tests/tgsl/shellless.test.ts +++ b/packages/typegpu/tests/tgsl/shellless.test.ts @@ -1,5 +1,6 @@ import { describe, expect } from 'vitest'; -import tgpu, { +import { + tgpu, d, std, type TgpuAccessor, diff --git a/packages/typegpu/tests/tgsl/sideEffects.test.ts b/packages/typegpu/tests/tgsl/sideEffects.test.ts index 6dace72133..1e20d622b3 100644 --- a/packages/typegpu/tests/tgsl/sideEffects.test.ts +++ b/packages/typegpu/tests/tgsl/sideEffects.test.ts @@ -1,4 +1,4 @@ -import tgpu, { d } from 'typegpu'; +import { tgpu, d } from 'typegpu'; import { test } from 'typegpu-testing-utility'; import { expectSideEffects } from '../utils/parseResolved.ts'; import { describe } from 'vitest'; diff --git a/packages/typegpu/tests/tgsl/ternaryOperator.test.ts b/packages/typegpu/tests/tgsl/ternaryOperator.test.ts index 651fccb0dc..cf377a0a63 100644 --- a/packages/typegpu/tests/tgsl/ternaryOperator.test.ts +++ b/packages/typegpu/tests/tgsl/ternaryOperator.test.ts @@ -1,6 +1,6 @@ import { describe, expect } from 'vitest'; import { it } from 'typegpu-testing-utility'; -import tgpu, { d, std } from '../../src/index.js'; +import { tgpu, d, std } from '../../src/index.js'; describe('ternary operator', () => { it('should resolve to one of the branches', () => { diff --git a/packages/typegpu/tests/tgsl/typeInference.test.ts b/packages/typegpu/tests/tgsl/typeInference.test.ts index 0f6add0bcd..4346337ba0 100644 --- a/packages/typegpu/tests/tgsl/typeInference.test.ts +++ b/packages/typegpu/tests/tgsl/typeInference.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it, vi } from 'vitest'; -import tgpu, { d, std } from '../../src/index.js'; +import { tgpu, d, std } from '../../src/index.js'; describe('wgsl generator type inference', () => { it('coerces nested structs', () => { diff --git a/packages/typegpu/tests/tgsl/wgslGenerator.test.ts b/packages/typegpu/tests/tgsl/wgslGenerator.test.ts index 5889999237..155ae2d539 100644 --- a/packages/typegpu/tests/tgsl/wgslGenerator.test.ts +++ b/packages/typegpu/tests/tgsl/wgslGenerator.test.ts @@ -1,7 +1,7 @@ import { beforeEach, describe, expect } from 'vitest'; import { it } from 'typegpu-testing-utility'; import { expectDataTypeOf, extractSnippetFromFn } from '../utils/parseResolved.ts'; -import tgpu, { d, std } from '../../src/index.js'; +import { tgpu, d, std } from '../../src/index.js'; const numberSlot = tgpu.slot(44); const lazyV4u = tgpu.lazy(() => d.vec4u(1, 2, 3, 4).mul(numberSlot.$)); diff --git a/packages/typegpu/tests/tgslFn.test.ts b/packages/typegpu/tests/tgslFn.test.ts index ba4d5165f2..41ba89a46b 100644 --- a/packages/typegpu/tests/tgslFn.test.ts +++ b/packages/typegpu/tests/tgslFn.test.ts @@ -1,7 +1,7 @@ import { attest } from '@ark/attest'; import { describe, expect } from 'vitest'; import { builtin } from '../src/builtin.ts'; -import tgpu, { d, type TgpuFn, type TgpuSlot } from '../src/index.js'; +import { tgpu, d, type TgpuFn, type TgpuSlot } from '../src/index.js'; import { getName } from '../src/shared/meta.ts'; import { it } from 'typegpu-testing-utility'; diff --git a/packages/typegpu/tests/unplugin/autoname.test.ts b/packages/typegpu/tests/unplugin/autoname.test.ts index 09cba71d5b..2565f475ab 100644 --- a/packages/typegpu/tests/unplugin/autoname.test.ts +++ b/packages/typegpu/tests/unplugin/autoname.test.ts @@ -1,6 +1,6 @@ import { describe, expect } from 'vitest'; import { struct } from '../../src/data/index.ts'; -import tgpu, { d, type TgpuBindGroupLayout } from '../../src/index.js'; +import { tgpu, d, type TgpuBindGroupLayout } from '../../src/index.js'; import { getName } from '../../src/shared/meta.ts'; import { it } from 'typegpu-testing-utility'; @@ -201,7 +201,7 @@ describe('autonaming', () => { }) && $.f)({})); - const main = (/*#__PURE__*/(globalThis.__TYPEGPU_AUTONAME__ ?? (a => a))(__vite_ssr_import_2__.default.fn([])((/*#__PURE__*/($ => (globalThis.__TYPEGPU_META__ ??= new WeakMap()).set($.f = (() => { + const main = (/*#__PURE__*/(globalThis.__TYPEGPU_AUTONAME__ ?? (a => a))(__vite_ssr_import_2__.tgpu.fn([])((/*#__PURE__*/($ => (globalThis.__TYPEGPU_META__ ??= new WeakMap()).set($.f = (() => { myFun(); }), { v: 1, diff --git a/packages/typegpu/tests/unroll.test.ts b/packages/typegpu/tests/unroll.test.ts index 1faef12f99..051cf49636 100644 --- a/packages/typegpu/tests/unroll.test.ts +++ b/packages/typegpu/tests/unroll.test.ts @@ -1,7 +1,7 @@ import { describe, expect } from 'vitest'; import { it } from 'typegpu-testing-utility'; import * as d from '../src/data/index.ts'; -import tgpu, { std } from '../src/index.js'; +import { tgpu, std } from '../src/index.js'; describe('tgpu.unroll', () => { it('called outside the gpu function returns passed iterable', () => { diff --git a/packages/typegpu/tests/utils/parseResolved.ts b/packages/typegpu/tests/utils/parseResolved.ts index a197e5ec97..3a0503e976 100644 --- a/packages/typegpu/tests/utils/parseResolved.ts +++ b/packages/typegpu/tests/utils/parseResolved.ts @@ -1,7 +1,7 @@ import type * as tinyest from 'tinyest'; import { NodeTypeCatalog as NODE } from 'tinyest'; import { type Assertion, expect } from 'vitest'; -import tgpu, { d, ShaderGenerator, WgslGenerator, type TgpuFn } from 'typegpu'; +import { tgpu, d, ShaderGenerator, WgslGenerator, type TgpuFn } from 'typegpu'; type Snippet = ShaderGenerator.Snippet; type UnknownData = ShaderGenerator.UnknownData; diff --git a/packages/typegpu/tests/variable.test.ts b/packages/typegpu/tests/variable.test.ts index fc425ab9ef..6ce8027945 100644 --- a/packages/typegpu/tests/variable.test.ts +++ b/packages/typegpu/tests/variable.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from 'vitest'; import type { TgpuVar, VariableScope } from '../src/core/variable/tgpuVariable.ts'; -import tgpu, { d, std } from '../src/index.js'; +import { tgpu, d, std } from '../src/index.js'; describe('tgpu.privateVar|tgpu.workgroupVar', () => { it('should inject variable declaration when used in functions', () => { diff --git a/packages/typegpu/tests/vector.test.ts b/packages/typegpu/tests/vector.test.ts index c8700e4f55..d4c51d6d3c 100644 --- a/packages/typegpu/tests/vector.test.ts +++ b/packages/typegpu/tests/vector.test.ts @@ -2,7 +2,7 @@ import { BufferReader, BufferWriter } from 'typed-binary'; import { describe, expect, expectTypeOf, it } from 'vitest'; import { readData, writeData } from '../src/data/dataIO.ts'; import { sizeOf } from '../src/data/sizeOf.ts'; -import tgpu, { d } from '../src/index.js'; +import { tgpu, d } from '../src/index.js'; import * as std from '../src/std/index.ts'; describe('constructors', () => { diff --git a/packages/typegpu/tests/vertexLayout.test.ts b/packages/typegpu/tests/vertexLayout.test.ts index b107968e88..8ed2b3035b 100644 --- a/packages/typegpu/tests/vertexLayout.test.ts +++ b/packages/typegpu/tests/vertexLayout.test.ts @@ -1,7 +1,7 @@ import { describe, expect, expectTypeOf, it } from 'vitest'; import { connectAttributesToShader } from '../src/core/vertexLayout/connectAttributesToShader.ts'; import type { ArrayToContainedAttribs } from '../src/core/vertexLayout/vertexAttribute.ts'; -import tgpu, { d } from '../src/index.js'; +import { tgpu, d } from '../src/index.js'; import type { TgpuVertexAttrib } from '../src/shared/vertexFormat.ts'; describe('ArrayToContainedAttribs', () => { diff --git a/packages/unplugin-typegpu/src/core/common.ts b/packages/unplugin-typegpu/src/core/common.ts index 9fddc69e3a..2a2de42f9d 100644 --- a/packages/unplugin-typegpu/src/core/common.ts +++ b/packages/unplugin-typegpu/src/core/common.ts @@ -176,7 +176,7 @@ export function getBlockScope( /** * Checks if `node` is an alias for the 'tgpu' object, traditionally - * available via `import tgpu from 'typegpu'`. + * available via `import { tgpu } from 'typegpu'`. */ function isTgpu(state: PluginState, node: t.Node): boolean { let path = ''; diff --git a/packages/unplugin-typegpu/test/auto-naming.test.ts b/packages/unplugin-typegpu/test/auto-naming.test.ts index b9a1f01bf8..9c1fc89193 100644 --- a/packages/unplugin-typegpu/test/auto-naming.test.ts +++ b/packages/unplugin-typegpu/test/auto-naming.test.ts @@ -4,7 +4,7 @@ import { babelTransform, rollupTransform } from './transform.ts'; describe('[BABEL] auto naming', () => { it('works with tgpu items', () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const bindGroupLayout = tgpu.bindGroupLayout({}); @@ -17,7 +17,7 @@ describe('[BABEL] auto naming', () => { `; expect(babelTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const bindGroupLayout = /*#__PURE__*/(globalThis.__TYPEGPU_AUTONAME__ ?? (a => a))(tgpu.bindGroupLayout({}), "bindGroupLayout"); const vertexLayout = /*#__PURE__*/(globalThis.__TYPEGPU_AUTONAME__ ?? (a => a))(tgpu.vertexLayout(d.arrayOf(d.u32)), "vertexLayout"); @@ -41,7 +41,7 @@ describe('[BABEL] auto naming', () => { it(`works with tgpu['~unstable'] items`, () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; let nothing, accessor = tgpu['~unstable'].accessor(d.u32); @@ -51,7 +51,7 @@ describe('[BABEL] auto naming', () => { `; expect(babelTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; let nothing, accessor = /*#__PURE__*/(globalThis.__TYPEGPU_AUTONAME__ ?? (a => a))(tgpu['~unstable'].accessor(d.u32), "accessor"); @@ -88,7 +88,7 @@ describe('[BABEL] auto naming', () => { it('works with root items', () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; const root = await tgpu.init(); const myBuffer = root.createBuffer(d.u32, 2); @@ -97,7 +97,7 @@ describe('[BABEL] auto naming', () => { `; expect(babelTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; const root = await tgpu.init(); const myBuffer = /*#__PURE__*/(globalThis.__TYPEGPU_AUTONAME__ ?? (a => a))(root.createBuffer(d.u32, 2), "myBuffer"); console.log(myBuffer);" @@ -106,7 +106,7 @@ describe('[BABEL] auto naming', () => { it('works with functions', () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const myFunction = tgpu.fn([])(() => 0); @@ -125,7 +125,7 @@ describe('[BABEL] auto naming', () => { `; expect(babelTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const myFunction = /*#__PURE__*/(globalThis.__TYPEGPU_AUTONAME__ ?? (a => a))(tgpu.fn([])(/*#__PURE__*/($ => (globalThis.__TYPEGPU_META__ ??= new WeakMap()).set($.f = () => 0, { v: 1, @@ -229,7 +229,7 @@ describe('[BABEL] auto naming', () => { it('does not name already named items', () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; import { struct } from 'typegpu/data'; @@ -243,7 +243,7 @@ describe('[BABEL] auto naming', () => { `; expect(babelTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; import { struct } from 'typegpu/data'; const root = await tgpu.init(); @@ -379,7 +379,7 @@ describe('[BABEL] auto naming', () => { it('works with class properties', () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); @@ -389,7 +389,7 @@ describe('[BABEL] auto naming', () => { `; expect(babelTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); class MyController { @@ -400,7 +400,7 @@ describe('[BABEL] auto naming', () => { it('works with object properties', () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); @@ -410,7 +410,7 @@ describe('[BABEL] auto naming', () => { `; expect(babelTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); const items: { @@ -424,7 +424,7 @@ describe('[BABEL] auto naming', () => { it('works with assigning to "this" property', () => { const code = `\ - import tgpu, { type TgpuUniform } from 'typegpu'; + import { tgpu, type TgpuUniform } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); @@ -438,7 +438,7 @@ describe('[BABEL] auto naming', () => { `; expect(babelTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu, { type TgpuUniform } from 'typegpu'; + "import { tgpu, type TgpuUniform } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); class MyController { @@ -452,7 +452,7 @@ describe('[BABEL] auto naming', () => { it('works with assigning to "this" private property', () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); @@ -473,7 +473,7 @@ describe('[BABEL] auto naming', () => { `; expect(babelTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); class MyController { @@ -491,7 +491,7 @@ describe('[BABEL] auto naming', () => { it('works with guarded pipelines', () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; const root = await tgpu.init(); @@ -508,7 +508,7 @@ describe('[BABEL] auto naming', () => { `; expect(babelTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; const root = await tgpu.init(); const myGuardedPipeline = /*#__PURE__*/(globalThis.__TYPEGPU_AUTONAME__ ?? (a => a))(root.createGuardedComputePipeline(/*#__PURE__*/($ => (globalThis.__TYPEGPU_META__ ??= new WeakMap()).set($.f = () => { 'use gpu'; @@ -546,7 +546,7 @@ describe('[BABEL] auto naming', () => { describe('[ROLLUP] auto naming', () => { it('works with tgpu items', async () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const bindGroupLayout = tgpu.bindGroupLayout({}); @@ -560,7 +560,7 @@ describe('[ROLLUP] auto naming', () => { `; expect(await rollupTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const bindGroupLayout = (/*#__PURE__*/(globalThis.__TYPEGPU_AUTONAME__ ?? (a => a))(tgpu.bindGroupLayout({}), "bindGroupLayout")); @@ -607,7 +607,7 @@ describe('[ROLLUP] auto naming', () => { it('works with root items', async () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; const root = await tgpu.init(); const myBuffer = root.createBuffer(d.u32, 2); @@ -616,7 +616,7 @@ describe('[ROLLUP] auto naming', () => { `; expect(await rollupTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; const root = await tgpu.init(); const myBuffer = (/*#__PURE__*/(globalThis.__TYPEGPU_AUTONAME__ ?? (a => a))(root.createBuffer(d.u32, 2), "myBuffer")); @@ -628,7 +628,7 @@ describe('[ROLLUP] auto naming', () => { it('works with functions', async () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const myFunction = tgpu.fn([])(() => 0); @@ -647,7 +647,7 @@ describe('[ROLLUP] auto naming', () => { `; expect(await rollupTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; (/*#__PURE__*/(globalThis.__TYPEGPU_AUTONAME__ ?? (a => a))(tgpu.fn([])((/*#__PURE__*/($ => (globalThis.__TYPEGPU_META__ ??= new WeakMap()).set($.f = (() => 0), { @@ -722,7 +722,7 @@ describe('[ROLLUP] auto naming', () => { it('does not name already named items', async () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; import { struct } from 'typegpu/data'; @@ -736,7 +736,7 @@ describe('[ROLLUP] auto naming', () => { `; expect(await rollupTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; import { struct } from 'typegpu/data'; @@ -867,7 +867,7 @@ describe('[ROLLUP] auto naming', () => { it('works with class properties', async () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); @@ -879,7 +879,7 @@ describe('[ROLLUP] auto naming', () => { `; expect(await rollupTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); @@ -895,7 +895,7 @@ describe('[ROLLUP] auto naming', () => { it('works with object properties', async () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); @@ -907,7 +907,7 @@ describe('[ROLLUP] auto naming', () => { `; expect(await rollupTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); @@ -923,7 +923,7 @@ describe('[ROLLUP] auto naming', () => { it('works with assigning to "this" property', async () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); @@ -939,7 +939,7 @@ describe('[ROLLUP] auto naming', () => { `; expect(await rollupTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); @@ -959,7 +959,7 @@ describe('[ROLLUP] auto naming', () => { it('works with assigning to "this" private property', async () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); @@ -980,7 +980,7 @@ describe('[ROLLUP] auto naming', () => { `; expect(await rollupTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); @@ -1004,7 +1004,7 @@ describe('[ROLLUP] auto naming', () => { it('works with guarded pipelines', async () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; const root = await tgpu.init(); @@ -1022,7 +1022,7 @@ describe('[ROLLUP] auto naming', () => { `; expect(await rollupTransform(code, { autoNamingEnabled: true })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; const root = await tgpu.init(); diff --git a/packages/unplugin-typegpu/test/parser-options.test.ts b/packages/unplugin-typegpu/test/parser-options.test.ts index 76225b0695..1b7d16952f 100644 --- a/packages/unplugin-typegpu/test/parser-options.test.ts +++ b/packages/unplugin-typegpu/test/parser-options.test.ts @@ -4,7 +4,7 @@ import { babelTransform, rollupTransform } from './transform.ts'; describe('[BABEL] parser options', () => { it('with no include option, import determines whether to run the plugin', () => { const codeWithImport = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; const increment = tgpu.fn([])(() => { const x = 2+2; @@ -12,7 +12,7 @@ describe('[BABEL] parser options', () => { `; expect(babelTransform(codeWithImport, { include: [/virtual:/] })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; const increment = tgpu.fn([])(/*#__PURE__*/($ => (globalThis.__TYPEGPU_META__ ??= new WeakMap()).set($.f = () => { const x = 2 + 2; }, { @@ -46,7 +46,7 @@ describe('[BABEL] parser options', () => { describe('[ROLLUP] tgpu alias gathering', async () => { it('with no include option, import determines whether to run the plugin', async () => { const codeWithImport = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; const increment = tgpu.fn([])(() => { }); @@ -55,7 +55,7 @@ describe('[ROLLUP] tgpu alias gathering', async () => { `; expect(await rollupTransform(codeWithImport, { include: [/virtual:/] })).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; const increment = tgpu.fn([])((/*#__PURE__*/($ => (globalThis.__TYPEGPU_META__ ??= new WeakMap()).set($.f = (() => { }), { diff --git a/packages/unplugin-typegpu/test/tgsl-transpiling.test.ts b/packages/unplugin-typegpu/test/tgsl-transpiling.test.ts index 3ba05a8b9b..2449dcba62 100644 --- a/packages/unplugin-typegpu/test/tgsl-transpiling.test.ts +++ b/packages/unplugin-typegpu/test/tgsl-transpiling.test.ts @@ -4,7 +4,7 @@ import { babelTransform, rollupTransform } from './transform.ts'; describe('[BABEL] plugin for transpiling tgsl functions to tinyest', () => { it('wraps argument passed to function shell with globalThis set call', () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const counterBuffer = root @@ -22,7 +22,7 @@ describe('[BABEL] plugin for transpiling tgsl functions to tinyest', () => { `; expect(babelTransform(code)).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const counterBuffer = root.createBuffer(d.vec3f, d.vec3f(0, 1, 0)).$usage('storage'); const counter = counterBuffer.as('mutable'); @@ -59,7 +59,7 @@ describe('[BABEL] plugin for transpiling tgsl functions to tinyest', () => { it('works for multiple functions, skips wgsl-implemented', () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; const a = tgpu.computeFn({ workgroupSize: [1] })((input) => { const x = true; @@ -76,7 +76,7 @@ describe('[BABEL] plugin for transpiling tgsl functions to tinyest', () => { `; expect(babelTransform(code)).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; const a = tgpu.computeFn({ workgroupSize: [1] })(/*#__PURE__*/($ => (globalThis.__TYPEGPU_META__ ??= new WeakMap()).set($.f = input => { @@ -131,14 +131,14 @@ describe('[BABEL] plugin for transpiling tgsl functions to tinyest', () => { it('transpiles only function shell invocations', () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; tgpu.x()(d.arrayOf(d.u32)); `; expect(babelTransform(code)).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; tgpu.x()(d.arrayOf(d.u32));" `); @@ -146,7 +146,7 @@ describe('[BABEL] plugin for transpiling tgsl functions to tinyest', () => { it('works with some typescript features', () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; const fun = tgpu.computeFn({ workgroupSize: [1] })((input) => { const x = true; @@ -162,7 +162,7 @@ describe('[BABEL] plugin for transpiling tgsl functions to tinyest', () => { `; expect(babelTransform(code)).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; const fun = tgpu.computeFn({ workgroupSize: [1] })(/*#__PURE__*/($ => (globalThis.__TYPEGPU_META__ ??= new WeakMap()).set($.f = input => { @@ -225,7 +225,7 @@ describe('[BABEL] plugin for transpiling tgsl functions to tinyest', () => { it('correctly lists "this" in externals', () => { const code = ` - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); @@ -242,7 +242,7 @@ describe('[BABEL] plugin for transpiling tgsl functions to tinyest', () => { console.log(tgpu.resolve([myController.myFn]));`; expect(babelTransform(code)).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); class MyController { @@ -273,7 +273,7 @@ describe('[BABEL] plugin for transpiling tgsl functions to tinyest', () => { describe('[ROLLUP] plugin for transpiling tgsl functions to tinyest', () => { it('wraps argument passed to function shell with globalThis set call', async () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const counterBuffer = root @@ -291,7 +291,7 @@ describe('[ROLLUP] plugin for transpiling tgsl functions to tinyest', () => { `; expect(await rollupTransform(code)).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const counterBuffer = root @@ -317,7 +317,7 @@ describe('[ROLLUP] plugin for transpiling tgsl functions to tinyest', () => { it('works for multiple functions, skips wgsl-implemented', async () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; const a = tgpu.computeFn({ workgroupSize: [1] })((input) => { const x = true; @@ -334,7 +334,7 @@ describe('[ROLLUP] plugin for transpiling tgsl functions to tinyest', () => { `; expect(await rollupTransform(code)).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; tgpu.computeFn({ workgroupSize: [1] })((/*#__PURE__*/($ => (globalThis.__TYPEGPU_META__ ??= new WeakMap()).set($.f = ((input) => { }), { @@ -367,14 +367,14 @@ describe('[ROLLUP] plugin for transpiling tgsl functions to tinyest', () => { it('transpiles only function shell invocations', async () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; tgpu.x()(d.arrayOf(d.u32)); `; expect(await rollupTransform(code)).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; tgpu.x()(d.arrayOf(d.u32)); @@ -384,7 +384,7 @@ describe('[ROLLUP] plugin for transpiling tgsl functions to tinyest', () => { it('correctly lists "this" in externals', async () => { const code = ` - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); @@ -401,7 +401,7 @@ describe('[ROLLUP] plugin for transpiling tgsl functions to tinyest', () => { console.log(tgpu.resolve([myController.myFn]));`; expect(await rollupTransform(code)).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; import * as d from 'typegpu/data'; const root = await tgpu.init(); diff --git a/packages/unplugin-typegpu/test/use-gpu-directive.test.ts b/packages/unplugin-typegpu/test/use-gpu-directive.test.ts index 9a32b06b5a..8544987d9b 100644 --- a/packages/unplugin-typegpu/test/use-gpu-directive.test.ts +++ b/packages/unplugin-typegpu/test/use-gpu-directive.test.ts @@ -76,7 +76,7 @@ describe('"use gpu" marked arrow function, assigned to a const', () => { describe('marked arrow functions passed to shells', () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; const shell = tgpu.fn([]); @@ -92,7 +92,7 @@ describe('marked arrow functions passed to shells', () => { test('babel', () => { expect(babelTransform(code)).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; const shell = tgpu.fn([]); shell(/*#__PURE__*/($ => (globalThis.__TYPEGPU_META__ ??= new WeakMap()).set($.f = (a, b) => { 'use gpu'; @@ -124,7 +124,7 @@ describe('marked arrow functions passed to shells', () => { test('rollup', async () => { expect(await rollupTransform(code)).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; const shell = tgpu.fn([]); @@ -148,7 +148,7 @@ describe('marked arrow functions passed to shells', () => { describe('marked anonymous function expressions passed to shells', () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; const shell = tgpu.fn([]); @@ -164,7 +164,7 @@ describe('marked anonymous function expressions passed to shells', () => { test('babel', () => { expect(babelTransform(code)).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; const shell = tgpu.fn([]); shell(/*#__PURE__*/($ => (globalThis.__TYPEGPU_META__ ??= new WeakMap()).set($.f = function (a, b) { 'use gpu'; @@ -196,7 +196,7 @@ describe('marked anonymous function expressions passed to shells', () => { test('rollup', async () => { expect(await rollupTransform(code)).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; const shell = tgpu.fn([]); @@ -220,7 +220,7 @@ describe('marked anonymous function expressions passed to shells', () => { describe('marked named function expressions passed to shells', () => { const code = `\ - import tgpu from 'typegpu'; + import { tgpu } from 'typegpu'; const shell = tgpu.fn([]); @@ -236,7 +236,7 @@ describe('marked named function expressions passed to shells', () => { test('babel', () => { expect(babelTransform(code)).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; const shell = tgpu.fn([]); shell(/*#__PURE__*/($ => (globalThis.__TYPEGPU_META__ ??= new WeakMap()).set($.f = function addGPU(a, b) { 'use gpu'; @@ -268,7 +268,7 @@ describe('marked named function expressions passed to shells', () => { test('rollup', async () => { expect(await rollupTransform(code)).toMatchInlineSnapshot(` - "import tgpu from 'typegpu'; + "import { tgpu } from 'typegpu'; const shell = tgpu.fn([]); @@ -500,7 +500,7 @@ describe('marked object methods', () => { describe('transforms numeric operations', () => { const code = `\ - import tgpu, { d } from 'typegpu'; + import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); const countMutable = root.createMutable(d.i32, 0); @@ -519,7 +519,7 @@ describe('transforms numeric operations', () => { test('babel', () => { expect(babelTransform(code)).toMatchInlineSnapshot(` - "import tgpu, { d } from 'typegpu'; + "import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); const countMutable = root.createMutable(d.i32, 0); @@ -557,7 +557,7 @@ describe('transforms numeric operations', () => { test('rollup', async () => { expect(await rollupTransform(code)).toMatchInlineSnapshot(` - "import tgpu, { d } from 'typegpu'; + "import { tgpu, d } from 'typegpu'; const root = await tgpu.init(); const countMutable = root.createMutable(d.i32, 0);